From 27145c397459f99c1385cd0d45a30f1b6df929bd Mon Sep 17 00:00:00 2001 From: BluJ Date: Tue, 2 May 2023 15:34:49 -0600 Subject: [PATCH] feat: Add effect of smtp & withWrapperData --- lib/config/builder/config.ts | 3 +++ lib/config/builder/value.ts | 4 ++++ lib/config/builder/variants.ts | 4 ++++ lib/config/constants.ts | 5 +++-- lib/types.ts | 13 +++++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/config/builder/config.ts b/lib/config/builder/config.ts index 90f0e44..51bb612 100644 --- a/lib/config/builder/config.ts +++ b/lib/config/builder/config.ts @@ -114,6 +114,9 @@ export class Config, WD> { }, } } + withWrapperData() { + return this as any as Config + } } export function topConfig() { diff --git a/lib/config/builder/value.ts b/lib/config/builder/value.ts index ec84f92..807bb83 100644 --- a/lib/config/builder/value.ts +++ b/lib/config/builder/value.ts @@ -626,4 +626,8 @@ export class Value { a.validator, ) } + + withWrapperData() { + return this as any as Value + } } diff --git a/lib/config/builder/variants.ts b/lib/config/builder/variants.ts index 3155d3e..f0641aa 100644 --- a/lib/config/builder/variants.ts +++ b/lib/config/builder/variants.ts @@ -103,4 +103,8 @@ export class Variants { return variants }, validator) } + + withWrapperData() { + return this as any as Variants + } } diff --git a/lib/config/constants.ts b/lib/config/constants.ts index 963a7fa..7f7de28 100644 --- a/lib/config/constants.ts +++ b/lib/config/constants.ts @@ -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( { @@ -11,7 +12,7 @@ export const smtpConfig = Value.union( system: { name: "System Credentials", spec: Config.of({}) }, custom: { name: "Custom Credentials", - spec: Config.of({ + spec: Config.of({ server: Value.text({ name: "SMTP Server", required: { diff --git a/lib/types.ts b/lib/types.ts index db43aa4..4f827f5 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -133,6 +133,15 @@ export type Daemon = { 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 = | ValidIfNoStupidEscape | [string, ...string[]] @@ -308,6 +317,10 @@ export type Effects = { callback: (config: unknown, previousConfig: unknown) => void }): Promise> + getSystemSmtp(input: { + callback: (config: unknown, previousConfig: unknown) => void + }): Promise + /** Used to store values that can be accessed and subscribed to */ setWrapperData(options: { /** Sets the value for the wrapper at the path, it will override, using the [JsonPath](https://jsonpath.com/) */