mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-31 04:33:40 +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 {
|
import {
|
||||||
ListValueSpecText,
|
ListValueSpecText,
|
||||||
Pattern,
|
Pattern,
|
||||||
|
RandomString,
|
||||||
UniqueBy,
|
UniqueBy,
|
||||||
ValueSpecList,
|
ValueSpecList,
|
||||||
ValueSpecListOf,
|
ValueSpecListOf,
|
||||||
@@ -45,6 +46,7 @@ export class List<Type, WD> {
|
|||||||
patterns: Pattern[]
|
patterns: Pattern[]
|
||||||
/** Default = "text" */
|
/** Default = "text" */
|
||||||
inputmode?: ListValueSpecText["inputmode"]
|
inputmode?: ListValueSpecText["inputmode"]
|
||||||
|
generate?: null | RandomString
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
return new List<string[], never>(() => {
|
return new List<string[], never>(() => {
|
||||||
@@ -55,6 +57,7 @@ export class List<Type, WD> {
|
|||||||
maxLength: null,
|
maxLength: null,
|
||||||
masked: false,
|
masked: false,
|
||||||
inputmode: "text" as const,
|
inputmode: "text" as const,
|
||||||
|
generate: null,
|
||||||
...aSpec,
|
...aSpec,
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@@ -82,6 +85,7 @@ export class List<Type, WD> {
|
|||||||
minLength?: number | null
|
minLength?: number | null
|
||||||
maxLength?: number | null
|
maxLength?: number | null
|
||||||
disabled?: false | string
|
disabled?: false | string
|
||||||
|
generate?: null | RandomString
|
||||||
spec: {
|
spec: {
|
||||||
/** Default = false */
|
/** Default = false */
|
||||||
masked?: boolean
|
masked?: boolean
|
||||||
@@ -104,6 +108,7 @@ export class List<Type, WD> {
|
|||||||
maxLength: null,
|
maxLength: null,
|
||||||
masked: false,
|
masked: false,
|
||||||
inputmode: "text" as const,
|
inputmode: "text" as const,
|
||||||
|
generate: null,
|
||||||
...aSpec,
|
...aSpec,
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { List } from "./list"
|
|||||||
import { Variants } from "./variants"
|
import { Variants } from "./variants"
|
||||||
import {
|
import {
|
||||||
Pattern,
|
Pattern,
|
||||||
|
RandomString,
|
||||||
ValueSpec,
|
ValueSpec,
|
||||||
ValueSpecDatetime,
|
ValueSpecDatetime,
|
||||||
ValueSpecText,
|
ValueSpecText,
|
||||||
@@ -162,6 +163,7 @@ export class Value<Type, WD> {
|
|||||||
/** Immutable means it can only be configed at the first config then never again
|
/** Immutable means it can only be configed at the first config then never again
|
||||||
Default is false */
|
Default is false */
|
||||||
immutable?: boolean
|
immutable?: boolean
|
||||||
|
generate?: null | RandomString
|
||||||
}) {
|
}) {
|
||||||
return new Value<AsRequired<string, Required>, never>(
|
return new Value<AsRequired<string, Required>, never>(
|
||||||
async () => ({
|
async () => ({
|
||||||
@@ -176,6 +178,7 @@ export class Value<Type, WD> {
|
|||||||
inputmode: "text",
|
inputmode: "text",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
immutable: a.immutable ?? false,
|
immutable: a.immutable ?? false,
|
||||||
|
generate: a.generate ?? null,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}),
|
}),
|
||||||
@@ -199,6 +202,7 @@ export class Value<Type, WD> {
|
|||||||
patterns?: Pattern[]
|
patterns?: Pattern[]
|
||||||
/** Default = 'text' */
|
/** Default = 'text' */
|
||||||
inputmode?: ValueSpecText["inputmode"]
|
inputmode?: ValueSpecText["inputmode"]
|
||||||
|
generate?: null | RandomString
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
@@ -216,6 +220,7 @@ export class Value<Type, WD> {
|
|||||||
inputmode: "text",
|
inputmode: "text",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
immutable: false,
|
immutable: false,
|
||||||
|
generate: a.generate ?? null,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...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
|
/** Immutable means it can only be configed at the first config then never again
|
||||||
Default is false */
|
Default is false */
|
||||||
immutable?: boolean
|
immutable?: boolean
|
||||||
|
generate?: null | RandomString
|
||||||
}) {
|
}) {
|
||||||
return new Value<string, never>(
|
return new Value<string, never>(
|
||||||
async () =>
|
async () =>
|
||||||
@@ -244,6 +250,7 @@ export class Value<Type, WD> {
|
|||||||
type: "textarea" as const,
|
type: "textarea" as const,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
immutable: a.immutable ?? false,
|
immutable: a.immutable ?? false,
|
||||||
|
generate: a.generate ?? null,
|
||||||
...a,
|
...a,
|
||||||
} satisfies ValueSpecTextarea),
|
} satisfies ValueSpecTextarea),
|
||||||
string,
|
string,
|
||||||
@@ -261,6 +268,7 @@ export class Value<Type, WD> {
|
|||||||
maxLength?: number | null
|
maxLength?: number | null
|
||||||
placeholder?: string | null
|
placeholder?: string | null
|
||||||
disabled?: false | string
|
disabled?: false | string
|
||||||
|
generate?: null | RandomString
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
@@ -275,6 +283,7 @@ export class Value<Type, WD> {
|
|||||||
type: "textarea" as const,
|
type: "textarea" as const,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
immutable: false,
|
immutable: false,
|
||||||
|
generate: a.generate ?? null,
|
||||||
...a,
|
...a,
|
||||||
}
|
}
|
||||||
}, string)
|
}, string)
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export interface ValueSpecText extends ListValueSpecText, WithStandalone {
|
|||||||
required: boolean
|
required: boolean
|
||||||
default: DefaultString | null
|
default: DefaultString | null
|
||||||
disabled: false | string
|
disabled: false | string
|
||||||
|
generate: null | RandomString
|
||||||
/** Immutable means it can only be configed at the first config then never again */
|
/** Immutable means it can only be configed at the first config then never again */
|
||||||
immutable: boolean
|
immutable: boolean
|
||||||
}
|
}
|
||||||
@@ -54,6 +55,7 @@ export interface ValueSpecTextarea extends WithStandalone {
|
|||||||
maxLength: number | null
|
maxLength: number | null
|
||||||
required: boolean
|
required: boolean
|
||||||
disabled: false | string
|
disabled: false | string
|
||||||
|
generate: null | RandomString
|
||||||
/** Immutable means it can only be configed at the first config then never again */
|
/** Immutable means it can only be configed at the first config then never again */
|
||||||
immutable: boolean
|
immutable: boolean
|
||||||
}
|
}
|
||||||
@@ -178,6 +180,8 @@ export interface ListValueSpecText {
|
|||||||
minLength: number | null
|
minLength: number | null
|
||||||
maxLength: number | null
|
maxLength: number | null
|
||||||
masked: boolean
|
masked: boolean
|
||||||
|
|
||||||
|
generate: null | RandomString
|
||||||
inputmode: "text" | "email" | "tel" | "url"
|
inputmode: "text" | "email" | "tel" | "url"
|
||||||
placeholder: string | null
|
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