From 597aa485186dcd3246357dc1f8e3ad91f062e454 Mon Sep 17 00:00:00 2001 From: BluJ Date: Thu, 4 May 2023 16:15:57 -0600 Subject: [PATCH] feat: add generate to the string like things --- lib/config/builder/list.ts | 5 +++++ lib/config/builder/value.ts | 9 +++++++++ lib/config/configTypes.ts | 4 ++++ lib/config/constants.ts | 2 -- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/config/builder/list.ts b/lib/config/builder/list.ts index 95ba9e0..7157780 100644 --- a/lib/config/builder/list.ts +++ b/lib/config/builder/list.ts @@ -2,6 +2,7 @@ import { Config, LazyBuild } from "./config" import { ListValueSpecText, Pattern, + RandomString, UniqueBy, ValueSpecList, ValueSpecListOf, @@ -45,6 +46,7 @@ export class List { patterns: Pattern[] /** Default = "text" */ inputmode?: ListValueSpecText["inputmode"] + generate?: null | RandomString }, ) { return new List(() => { @@ -55,6 +57,7 @@ export class List { maxLength: null, masked: false, inputmode: "text" as const, + generate: null, ...aSpec, } return { @@ -82,6 +85,7 @@ export class List { minLength?: number | null maxLength?: number | null disabled?: false | string + generate?: null | RandomString spec: { /** Default = false */ masked?: boolean @@ -104,6 +108,7 @@ export class List { maxLength: null, masked: false, inputmode: "text" as const, + generate: null, ...aSpec, } return { diff --git a/lib/config/builder/value.ts b/lib/config/builder/value.ts index 7994781..435eb1b 100644 --- a/lib/config/builder/value.ts +++ b/lib/config/builder/value.ts @@ -3,6 +3,7 @@ import { List } from "./list" import { Variants } from "./variants" import { Pattern, + RandomString, ValueSpec, ValueSpecDatetime, ValueSpecText, @@ -162,6 +163,7 @@ export class Value { /** Immutable means it can only be configed at the first config then never again Default is false */ immutable?: boolean + generate?: null | RandomString }) { return new Value, never>( async () => ({ @@ -176,6 +178,7 @@ export class Value { inputmode: "text", disabled: false, immutable: a.immutable ?? false, + generate: a.generate ?? null, ...a, ...requiredLikeToAbove(a.required), }), @@ -199,6 +202,7 @@ export class Value { patterns?: Pattern[] /** Default = 'text' */ inputmode?: ValueSpecText["inputmode"] + generate?: null | RandomString } >, ) { @@ -216,6 +220,7 @@ export class Value { inputmode: "text", disabled: false, immutable: false, + generate: a.generate ?? null, ...a, ...requiredLikeToAbove(a.required), } @@ -232,6 +237,7 @@ export class Value { /** Immutable means it can only be configed at the first config then never again Default is false */ immutable?: boolean + generate?: null | RandomString }) { return new Value( async () => @@ -244,6 +250,7 @@ export class Value { type: "textarea" as const, disabled: false, immutable: a.immutable ?? false, + generate: a.generate ?? null, ...a, } satisfies ValueSpecTextarea), string, @@ -261,6 +268,7 @@ export class Value { maxLength?: number | null placeholder?: string | null disabled?: false | string + generate?: null | RandomString } >, ) { @@ -275,6 +283,7 @@ export class Value { type: "textarea" as const, disabled: false, immutable: false, + generate: a.generate ?? null, ...a, } }, string) diff --git a/lib/config/configTypes.ts b/lib/config/configTypes.ts index e90fea4..19f0c74 100644 --- a/lib/config/configTypes.ts +++ b/lib/config/configTypes.ts @@ -44,6 +44,7 @@ export interface ValueSpecText extends ListValueSpecText, WithStandalone { required: boolean default: DefaultString | null disabled: false | string + generate: null | RandomString /** Immutable means it can only be configed at the first config then never again */ immutable: boolean } @@ -54,6 +55,7 @@ export interface ValueSpecTextarea extends WithStandalone { maxLength: number | null required: boolean disabled: false | string + generate: null | RandomString /** Immutable means it can only be configed at the first config then never again */ immutable: boolean } @@ -178,6 +180,8 @@ export interface ListValueSpecText { minLength: number | null maxLength: number | null masked: boolean + + generate: null | RandomString inputmode: "text" | "email" | "tel" | "url" placeholder: string | null } diff --git a/lib/config/constants.ts b/lib/config/constants.ts index f8ecac8..b2e4002 100644 --- a/lib/config/constants.ts +++ b/lib/config/constants.ts @@ -59,5 +59,3 @@ export const smtpConfig = Value.filteredUnion(async ({ effects, utils }) => { }, }), ) - -export const password =