mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 20:24:47 +00:00
feat: Add effect of smtp & withWrapperData
This commit is contained in:
@@ -114,6 +114,9 @@ export class Config<Type extends Record<string, any>, WD> {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
withWrapperData<NewWrapperData extends WD>() {
|
||||||
|
return this as any as Config<Type, NewWrapperData>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function topConfig<WrapperData>() {
|
export function topConfig<WrapperData>() {
|
||||||
|
|||||||
@@ -626,4 +626,8 @@ export class Value<Type, WD> {
|
|||||||
a.validator,
|
a.validator,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
withWrapperData<NewWrapperData extends WD>() {
|
||||||
|
return this as any as Value<Type, NewWrapperData>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,4 +103,8 @@ export class Variants<Type, WD> {
|
|||||||
return variants
|
return variants
|
||||||
}, validator)
|
}, validator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
withWrapperData<NewWrapperData extends WD>() {
|
||||||
|
return this as any as Variants<Type, NewWrapperData>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Config, Value, Variants } from "./builder"
|
import { SmtpValue } from "../types"
|
||||||
|
import { Config, Value, Variants, topConfig } from "./builder"
|
||||||
|
|
||||||
export const smtpConfig = Value.union(
|
export const smtpConfig = Value.union(
|
||||||
{
|
{
|
||||||
@@ -11,7 +12,7 @@ export const smtpConfig = Value.union(
|
|||||||
system: { name: "System Credentials", spec: Config.of({}) },
|
system: { name: "System Credentials", spec: Config.of({}) },
|
||||||
custom: {
|
custom: {
|
||||||
name: "Custom Credentials",
|
name: "Custom Credentials",
|
||||||
spec: Config.of({
|
spec: Config.of<SmtpValue, unknown>({
|
||||||
server: Value.text({
|
server: Value.text({
|
||||||
name: "SMTP Server",
|
name: "SMTP Server",
|
||||||
required: {
|
required: {
|
||||||
|
|||||||
13
lib/types.ts
13
lib/types.ts
@@ -133,6 +133,15 @@ export type Daemon = {
|
|||||||
|
|
||||||
export type HealthStatus = "passing" | "warning" | "failing" | "disabled"
|
export type HealthStatus = "passing" | "warning" | "failing" | "disabled"
|
||||||
|
|
||||||
|
export type SmtpValue = {
|
||||||
|
server: string
|
||||||
|
port: number
|
||||||
|
from: string
|
||||||
|
login: string
|
||||||
|
password: string | null | undefined
|
||||||
|
tls: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export type CommandType<A extends string> =
|
export type CommandType<A extends string> =
|
||||||
| ValidIfNoStupidEscape<A>
|
| ValidIfNoStupidEscape<A>
|
||||||
| [string, ...string[]]
|
| [string, ...string[]]
|
||||||
@@ -308,6 +317,10 @@ export type Effects = {
|
|||||||
callback: (config: unknown, previousConfig: unknown) => void
|
callback: (config: unknown, previousConfig: unknown) => void
|
||||||
}): Promise<ExtractWrapperData<WrapperData, Path>>
|
}): Promise<ExtractWrapperData<WrapperData, Path>>
|
||||||
|
|
||||||
|
getSystemSmtp(input: {
|
||||||
|
callback: (config: unknown, previousConfig: unknown) => void
|
||||||
|
}): Promise<SmtpValue>
|
||||||
|
|
||||||
/** Used to store values that can be accessed and subscribed to */
|
/** Used to store values that can be accessed and subscribed to */
|
||||||
setWrapperData<WrapperData = never, Path extends string = never>(options: {
|
setWrapperData<WrapperData = never, Path extends string = never>(options: {
|
||||||
/** Sets the value for the wrapper at the path, it will override, using the [JsonPath](https://jsonpath.com/) */
|
/** Sets the value for the wrapper at the path, it will override, using the [JsonPath](https://jsonpath.com/) */
|
||||||
|
|||||||
Reference in New Issue
Block a user