mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-26 10:21:55 +00:00
feat: add generate to the string like things
This commit is contained in:
@@ -2,6 +2,7 @@ import { Config, LazyBuild } from "./config"
|
||||
import {
|
||||
ListValueSpecText,
|
||||
Pattern,
|
||||
RandomString,
|
||||
UniqueBy,
|
||||
ValueSpecList,
|
||||
ValueSpecListOf,
|
||||
@@ -45,6 +46,7 @@ export class List<Type, WD> {
|
||||
patterns: Pattern[]
|
||||
/** Default = "text" */
|
||||
inputmode?: ListValueSpecText["inputmode"]
|
||||
generate?: null | RandomString
|
||||
},
|
||||
) {
|
||||
return new List<string[], never>(() => {
|
||||
@@ -55,6 +57,7 @@ export class List<Type, WD> {
|
||||
maxLength: null,
|
||||
masked: false,
|
||||
inputmode: "text" as const,
|
||||
generate: null,
|
||||
...aSpec,
|
||||
}
|
||||
return {
|
||||
@@ -82,6 +85,7 @@ export class List<Type, WD> {
|
||||
minLength?: number | null
|
||||
maxLength?: number | null
|
||||
disabled?: false | string
|
||||
generate?: null | RandomString
|
||||
spec: {
|
||||
/** Default = false */
|
||||
masked?: boolean
|
||||
@@ -104,6 +108,7 @@ export class List<Type, WD> {
|
||||
maxLength: null,
|
||||
masked: false,
|
||||
inputmode: "text" as const,
|
||||
generate: null,
|
||||
...aSpec,
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -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<Type, WD> {
|
||||
/** 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<AsRequired<string, Required>, never>(
|
||||
async () => ({
|
||||
@@ -176,6 +178,7 @@ export class Value<Type, WD> {
|
||||
inputmode: "text",
|
||||
disabled: false,
|
||||
immutable: a.immutable ?? false,
|
||||
generate: a.generate ?? null,
|
||||
...a,
|
||||
...requiredLikeToAbove(a.required),
|
||||
}),
|
||||
@@ -199,6 +202,7 @@ export class Value<Type, WD> {
|
||||
patterns?: Pattern[]
|
||||
/** Default = 'text' */
|
||||
inputmode?: ValueSpecText["inputmode"]
|
||||
generate?: null | RandomString
|
||||
}
|
||||
>,
|
||||
) {
|
||||
@@ -216,6 +220,7 @@ export class Value<Type, WD> {
|
||||
inputmode: "text",
|
||||
disabled: false,
|
||||
immutable: false,
|
||||
generate: a.generate ?? null,
|
||||
...a,
|
||||
...requiredLikeToAbove(a.required),
|
||||
}
|
||||
@@ -232,6 +237,7 @@ export class Value<Type, WD> {
|
||||
/** 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<string, never>(
|
||||
async () =>
|
||||
@@ -244,6 +250,7 @@ export class Value<Type, WD> {
|
||||
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<Type, WD> {
|
||||
maxLength?: number | null
|
||||
placeholder?: string | null
|
||||
disabled?: false | string
|
||||
generate?: null | RandomString
|
||||
}
|
||||
>,
|
||||
) {
|
||||
@@ -275,6 +283,7 @@ export class Value<Type, WD> {
|
||||
type: "textarea" as const,
|
||||
disabled: false,
|
||||
immutable: false,
|
||||
generate: a.generate ?? null,
|
||||
...a,
|
||||
}
|
||||
}, string)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -59,5 +59,3 @@ export const smtpConfig = Value.filteredUnion(async ({ effects, utils }) => {
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
export const password =
|
||||
|
||||
Reference in New Issue
Block a user