diff --git a/lib/config/builder/list.ts b/lib/config/builder/list.ts index 12ad60c..bc9e94a 100644 --- a/lib/config/builder/list.ts +++ b/lib/config/builder/list.ts @@ -2,8 +2,8 @@ import { BuilderExtract, IBuilder } from "./builder"; import { Config } from "./config"; import { InputSpec, - ListValueSpecNumber, - ListValueSpecString, + ListValueSpecText, + Pattern, UniqueBy, ValueSpecList, } from "../configTypes"; @@ -22,31 +22,33 @@ export const auth = Value.list(authorizationList); ``` */ export class List extends IBuilder { - static string( + static text( a: { name: string; description?: string | null; warning?: string | null; /** Default = [] */ default?: string[]; - /** Default = "(\*,\*)" */ - range?: string; + /** Default = 0 */ + minLength?: number | null; + maxLength?: number | null; }, aSpec: { /** Default = false */ masked?: boolean; placeholder?: string | null; - pattern?: string | null; - patternDescription?: string | null; + minLength?: number | null; + maxLength?: number | null; + patterns: Pattern[]; /** Default = "text" */ - inputmode?: ListValueSpecString["inputmode"]; + inputmode?: ListValueSpecText["inputmode"]; }, ) { const spec = { - type: "string" as const, + type: "text" as const, placeholder: null, - pattern: null, - patternDescription: null, + minLength: null, + maxLength: null, masked: false, inputmode: "text" as const, ...aSpec, @@ -56,7 +58,8 @@ export class List extends IBuilder { warning: null, default: [], type: "list" as const, - range: "(*,*)", + minLength: 0, + maxLength: null, ...a, spec, }); @@ -68,13 +71,15 @@ export class List extends IBuilder { warning?: string | null; /** Default = [] */ default?: string[]; - /** Default = "(\*,\*)" */ - range?: string; + /** Default = 0 */ + minLength?: number | null; + maxLength?: number | null; }, aSpec: { - integral: boolean; - /** Default = "(\*,\*)" */ - range?: string; + integer: boolean; + min?: number | null; + max?: number | null; + step?: string | null; units?: string | null; placeholder?: string | null; }, @@ -82,15 +87,17 @@ export class List extends IBuilder { const spec = { type: "number" as const, placeholder: null, - range: "(*,*)", + min: null, + max: null, + step: null, units: null, ...aSpec, }; return new List({ description: null, warning: null, - units: null, - range: "(*,*)", + minLength: 0, + maxLength: null, default: [], type: "list" as const, ...a, @@ -104,8 +111,9 @@ export class List extends IBuilder { warning?: string | null; /** Default [] */ default?: []; - /** Default = "(\*,\*)" */ - range?: string; + /** Default = 0 */ + minLength?: number | null; + maxLength?: number | null; }, aSpec: { spec: Spec; @@ -130,7 +138,8 @@ export class List extends IBuilder { return new List({ description: null, warning: null, - range: "(*,*)", + minLength: 0, + maxLength: null, type: "list" as const, ...value, }); diff --git a/lib/config/builder/value.ts b/lib/config/builder/value.ts index 39f6c08..c40ba6e 100644 --- a/lib/config/builder/value.ts +++ b/lib/config/builder/value.ts @@ -4,10 +4,13 @@ import { List } from "./list"; import { Variants } from "./variants"; import { InputSpec, - ListValueSpecString, + Pattern, ValueSpec, + ValueSpecColor, + ValueSpecDatetime, ValueSpecList, ValueSpecNumber, + ValueSpecText, ValueSpecTextarea, } from "../configTypes"; import { guardAll } from "../../util"; @@ -35,7 +38,7 @@ const username = Value.string({ ``` */ export class Value extends IBuilder { - static boolean(a: { + static toggle(a: { name: string; description?: string | null; warning?: string | null; @@ -45,11 +48,11 @@ export class Value extends IBuilder { description: null, warning: null, default: null, - type: "boolean" as const, + type: "toggle" as const, ...a, }); } - static string(a: { + static text(a: { name: string; description?: string | null; warning?: string | null; @@ -58,20 +61,22 @@ export class Value extends IBuilder { /** Default = false */ masked?: boolean; placeholder?: string | null; - pattern?: string | null; - patternDescription?: string | null; + minLength?: number | null; + maxLength?: number | null; + patterns?: Pattern[]; /** Default = 'text' */ - inputmode?: ListValueSpecString["inputmode"]; + inputmode?: ValueSpecText["inputmode"]; }) { return new Value({ - type: "string" as const, + type: "text" as const, default: null, description: null, warning: null, masked: false, placeholder: null, - pattern: null, - patternDescription: null, + minLength: null, + maxLength: null, + patterns: [], inputmode: "text", ...a, }); @@ -81,11 +86,15 @@ export class Value extends IBuilder { description?: string | null; warning?: string | null; required: boolean; + minLength?: number | null; + maxLength?: number | null; placeholder?: string | null; }) { return new Value({ description: null, warning: null, + minLength: null, + maxLength: null, placeholder: null, type: "textarea" as const, ...a, @@ -97,9 +106,11 @@ export class Value extends IBuilder { warning?: string | null; required: boolean; default?: number | null; - /** default = "(\*,\*)" */ - range?: string; - integral: boolean; + min?: number | null; + max?: number | null; + /** Default = '1' */ + step?: string | null; + integer: boolean; units?: string | null; placeholder?: string | null; }) { @@ -108,12 +119,53 @@ export class Value extends IBuilder { description: null, warning: null, default: null, - range: "(*,*)", + min: null, + max: null, + step: null, units: null, placeholder: null, ...a, } as ValueSpecNumber); } + static color(a: { + name: string; + description?: string | null; + warning?: string | null; + required: boolean; + default?: number | null; + }) { + return new Value({ + type: "color" as const, + description: null, + warning: null, + default: null, + ...a, + } as ValueSpecColor); + } + static datetime(a: { + name: string; + description?: string | null; + warning?: string | null; + required: boolean; + /** Default = 'datetime-local' */ + inputMode?: ValueSpecDatetime['inputMode'] + min?: string | null + max?: string | null + step?: string | null + default?: number | null; + }) { + return new Value({ + type: "datetime" as const, + description: null, + warning: null, + inputMode: 'datetime-local', + min: null, + max: null, + step: null, + default: null, + ...a, + } as ValueSpecDatetime); + } static select>(a: { name: string; description?: string | null; @@ -134,16 +186,16 @@ export class Value extends IBuilder { name: string; description?: string | null; warning?: string | null; - default?: string[]; + default: string[]; values: Values; - /** default = "(\*,\*)" */ - range?: string; + minLength?: number | null; + maxLength?: number | null; }) { return new Value({ type: "multiselect" as const, - range: "(*,*)", + minLength: null, + maxLength: null, warning: null, - default: [], description: null, ...a, }); diff --git a/lib/config/configTypes.ts b/lib/config/configTypes.ts index 6da0dd1..c49977c 100644 --- a/lib/config/configTypes.ts +++ b/lib/config/configTypes.ts @@ -1,9 +1,11 @@ export type InputSpec = Record; export type ValueType = - | "string" + | "text" | "textarea" | "number" - | "boolean" + | "color" + | "datetime" + | "toggle" | "select" | "multiselect" | "list" @@ -12,14 +14,18 @@ export type ValueType = | "union"; export type ValueSpec = ValueSpecOf; /** core spec types. These types provide the metadata for performing validations */ -export type ValueSpecOf = T extends "string" - ? ValueSpecString - : T extends "number" - ? ValueSpecTextarea +export type ValueSpecOf = T extends "text" + ? ValueSpecText : T extends "textarea" + ? ValueSpecTextarea + : T extends "number" ? ValueSpecNumber - : T extends "boolean" - ? ValueSpecBoolean + : T extends "color" + ? ValueSpecColor + : T extends "datetime" + ? ValueSpecDatetime + : T extends "toggle" + ? ValueSpecToggle : T extends "select" ? ValueSpecSelect : T extends "multiselect" @@ -34,19 +40,35 @@ export type ValueSpecOf = T extends "string" ? ValueSpecUnion : never; -export interface ValueSpecString extends ListValueSpecString, WithStandalone { +export interface ValueSpecText extends ListValueSpecText, WithStandalone { required: boolean; default: DefaultString | null; } export interface ValueSpecTextarea extends WithStandalone { type: "textarea"; placeholder: string | null; + minLength: number | null; + maxLength: number | null; required: boolean; } export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone { required: boolean; default: number | null; } +export interface ValueSpecColor extends WithStandalone { + type: "color" + required: boolean; + default: string | null; +} +export interface ValueSpecDatetime extends WithStandalone { + type: "datetime" + required: boolean; + inputMode: 'date' | 'time' | 'datetime-local' + min: string | null + max: string | null + step: string | null + default: string | null; +} export interface ValueSpecSelect extends SelectBase, WithStandalone { type: "select"; required: boolean; @@ -54,12 +76,12 @@ export interface ValueSpecSelect extends SelectBase, WithStandalone { } export interface ValueSpecMultiselect extends SelectBase, WithStandalone { type: "multiselect"; - /**'[0,1]' (inclusive) OR '[0,*)' (right unbounded), normal math rules */ - range: string; + minLength: number | null; + maxLength: number | null; default: string[]; } -export interface ValueSpecBoolean extends WithStandalone { - type: "boolean"; +export interface ValueSpecToggle extends WithStandalone { + type: "toggle"; default: boolean | null; } export interface ValueSpecUnion extends WithStandalone { @@ -91,10 +113,10 @@ export interface WithStandalone { export interface SelectBase { values: Record; } -export type ListValueSpecType = "string" | "number" | "object"; +export type ListValueSpecType = "text" | "number" | "object"; /** represents a spec for the values of a list */ -export type ListValueSpecOf = T extends "string" - ? ListValueSpecString +export type ListValueSpecOf = T extends "text" + ? ListValueSpecText : T extends "number" ? ListValueSpecNumber : T extends "object" @@ -106,7 +128,8 @@ export interface ValueSpecListOf extends WithStandalone { type: "list"; spec: ListValueSpecOf; - range: string; + minLength: number | null; + maxLength: number | null; default: | string[] | number[] @@ -117,18 +140,25 @@ export interface ValueSpecListOf | readonly DefaultString[] | readonly Record[]; } -export interface ListValueSpecString { - type: "string"; - pattern: string | null; - patternDescription: string | null; +export interface Pattern { + regex: string + description: string +} +export interface ListValueSpecText { + type: "text"; + patterns: Pattern[] + minLength: number | null + maxLength: number | null masked: boolean; inputmode: "text" | "email" | "tel" | "url"; placeholder: string | null; } export interface ListValueSpecNumber { type: "number"; - range: string; - integral: boolean; + min: number | null; + max: number | null; + integer: boolean; + step: string | null; units: string | null; placeholder: string | null; } diff --git a/lib/config/setupConfigExports.ts b/lib/config/setupConfigExports.ts index 9e25cf5..0df3800 100644 --- a/lib/config/setupConfigExports.ts +++ b/lib/config/setupConfigExports.ts @@ -2,7 +2,6 @@ import { Config } from "./builder"; import { DeepPartial, Dependencies, - DependsOn, Effects, ExpectedExports, } from "../types"; diff --git a/lib/config/specToBuilder.ts b/lib/config/specToBuilder.ts index a70cc7a..8eeb733 100644 --- a/lib/config/specToBuilder.ts +++ b/lib/config/specToBuilder.ts @@ -50,10 +50,12 @@ export async function specToBuilder( } function convertValueSpec(value: C.ValueSpec): string { switch (value.type) { - case "string": + case "text": case "textarea": case "number": - case "boolean": + case "color": + case "datetime": + case "toggle": case "select": case "multiselect": { const { type, ...rest } = value; @@ -91,11 +93,12 @@ export async function specToBuilder( function convertList(valueSpecList: C.ValueSpecList) { const { spec, ...value } = valueSpecList; switch (spec.type) { - case "string": { - return `List.string(${JSON.stringify( + case "text": { + return `List.text(${JSON.stringify( { name: value.name || null, - range: value.range || null, + minLength: value.minLength || null, + maxLength: value.maxLength || null, default: value.default || null, description: value.description || null, warning: value.warning || null, @@ -105,16 +108,16 @@ export async function specToBuilder( )}, ${JSON.stringify({ masked: spec?.masked || false, placeholder: spec?.placeholder || null, - pattern: spec?.pattern || null, - patternDescription: spec?.patternDescription || null, - inputMode: spec?.inputmode || null, + pattern: spec?.patterns || [], + inputMode: spec?.inputmode || 'text', })})`; } case "number": { return `List.number(${JSON.stringify( { name: value.name || null, - range: value.range || null, + minLength: value.minLength || null, + maxLength: value.maxLength || null, default: value.default || null, description: value.description || null, warning: value.warning || null, @@ -122,8 +125,10 @@ export async function specToBuilder( null, 2, )}, ${JSON.stringify({ - range: spec?.range || null, - integral: spec?.integral || false, + integer: spec?.integer || false, + min: spec?.min || null, + max: spec?.max || null, + step: spec?.step || null, units: spec?.units || null, placeholder: spec?.placeholder || null, })})`; @@ -135,7 +140,8 @@ export async function specToBuilder( ); return `List.obj({ name: ${JSON.stringify(value.name || null)}, - range: ${JSON.stringify(value.range || null)}, + minLength: ${JSON.stringify(value.minLength || null)}, + maxLength: ${JSON.stringify(value.maxLength || null)}, default: ${JSON.stringify(value.default || null)}, description: ${JSON.stringify(value.description || null)}, warning: ${JSON.stringify(value.warning || null)}, diff --git a/lib/test/configBuilder.test.ts b/lib/test/configBuilder.test.ts index 832bf32..978f291 100644 --- a/lib/test/configBuilder.test.ts +++ b/lib/test/configBuilder.test.ts @@ -3,40 +3,41 @@ import { Config } from "../config/builder/config"; import { List } from "../config/builder/list"; import { Value } from "../config/builder/value"; import { Variants } from "../config/builder/variants"; -import { Parser } from "ts-matches"; describe("builder tests", () => { - test("String", () => { + test("text", () => { const bitcoinPropertiesBuilt: { "peer-tor-address": { name: string; description: string | null; - type: "string"; + type: "text"; }; } = Config.of({ - "peer-tor-address": Value.string({ + "peer-tor-address": Value.text({ name: "Peer tor address", - default: "", + default: null, description: "The Tor address of the peer interface", warning: null, required: true, masked: true, placeholder: null, - pattern: null, - patternDescription: null, + minLength: null, + maxLength: null, + patterns: [], }), }).build(); expect(JSON.stringify(bitcoinPropertiesBuilt)).toEqual( /*json*/ `{ "peer-tor-address": { - "type": "string", - "default": "", + "type": "text", + "default": null, "description": "The Tor address of the peer interface", "warning": null, "masked": true, "placeholder": null, - "pattern": null, - "patternDescription": null, + "minLength": null, + "maxLength": null, + "patterns": [], "inputmode":"text", "name": "Peer tor address", "required": true @@ -49,16 +50,16 @@ describe("builder tests", () => { }); describe("values", () => { - test("boolean", () => { - const value = Value.boolean({ + test("toggle", () => { + const value = Value.toggle({ name: "Testing", }); const validator = value.validator(); validator.unsafeCast(false); testOutput()(null); }); - test("string", () => { - const value = Value.string({ + test("text", () => { + const value = Value.text({ name: "Testing", required: false, }); @@ -79,7 +80,7 @@ describe("values", () => { const value = Value.number({ name: "Testing", required: false, - integral: false, + integer: false, }); const validator = value.validator(); validator.unsafeCast(2); @@ -106,6 +107,7 @@ describe("values", () => { a: "A", b: "B", }, + default: [], }); const validator = value.validator(); validator.unsafeCast([]); @@ -118,7 +120,7 @@ describe("values", () => { name: "Testing", }, Config.of({ - a: Value.boolean({ + a: Value.toggle({ name: "test", }), }), @@ -136,7 +138,7 @@ describe("values", () => { Variants.of({ a: { name: "a", - spec: Config.of({ b: Value.boolean({ name: "b" }) }), + spec: Config.of({ b: Value.toggle({ name: "b" }) }), }, }), ); @@ -155,7 +157,7 @@ describe("values", () => { name: "test", }, { - integral: false, + integer: false, }, ), ); @@ -173,7 +175,7 @@ describe("Builder List", () => { name: "test", }, { - spec: Config.of({ test: Value.boolean({ name: "test" }) }), + spec: Config.of({ test: Value.toggle({ name: "test" }) }), }, ), ); @@ -181,13 +183,15 @@ describe("Builder List", () => { validator.unsafeCast([{ test: true }]); testOutput()(null); }); - test("string", () => { + test("text", () => { const value = Value.list( - List.string( + List.text( { name: "test", }, - {}, + { + patterns: [], + }, ), ); const validator = value.validator(); @@ -200,7 +204,7 @@ describe("Builder List", () => { { name: "test", }, - { integral: true }, + { integer: true }, ), ); const validator = value.validator(); diff --git a/lib/test/configTypes.test.ts b/lib/test/configTypes.test.ts index e42b1f1..12227d7 100644 --- a/lib/test/configTypes.test.ts +++ b/lib/test/configTypes.test.ts @@ -1,6 +1,5 @@ import { ListValueSpecOf, - ValueSpecList, isValueSpecListOf, } from "../config/configTypes"; import { Config } from "../config/builder/config"; @@ -9,12 +8,12 @@ import { Value } from "../config/builder/value"; describe("Config Types", () => { test("isValueSpecListOf", () => { - const options = [List.obj, List.string, List.number]; + const options = [List.obj, List.text, List.number]; for (const option of options) { const test = option({} as any, { spec: Config.of({}) } as any) as any; const someList = Value.list(test).build(); - if (isValueSpecListOf(someList, "string")) { - someList.spec satisfies ListValueSpecOf<"string">; + if (isValueSpecListOf(someList, "text")) { + someList.spec satisfies ListValueSpecOf<"text">; } else if (isValueSpecListOf(someList, "number")) { someList.spec satisfies ListValueSpecOf<"number">; } else if (isValueSpecListOf(someList, "object")) { diff --git a/lib/test/output.test.ts b/lib/test/output.test.ts index c26fa58..1aa330b 100644 --- a/lib/test/output.test.ts +++ b/lib/test/output.test.ts @@ -1,4 +1,3 @@ -import { Parser } from "ts-matches"; import { UnionSelectKey, unionSelectKey, diff --git a/lib/util/index.ts b/lib/util/index.ts index 737a31a..b4279dc 100644 --- a/lib/util/index.ts +++ b/lib/util/index.ts @@ -1,4 +1,4 @@ -import { Parser, string } from "ts-matches"; +import { Parser } from "ts-matches"; import * as T from "../types"; import FileHelper from "./fileHelper"; import nullIfEmpty from "./nullIfEmpty"; diff --git a/lib/util/propertiesMatcher.ts b/lib/util/propertiesMatcher.ts index 419c877..f582ba0 100644 --- a/lib/util/propertiesMatcher.ts +++ b/lib/util/propertiesMatcher.ts @@ -19,14 +19,16 @@ const { boolean, } = matches; -type TypeBoolean = "boolean"; -type TypeString = "string"; +type TypeToggle = "toggle"; +type TypeText = "text"; type TypeTextarea = "textarea"; type TypeNumber = "number"; type TypeObject = "object"; type TypeList = "list"; type TypeSelect = "select"; type TypeMultiselect = "multiselect"; +type TypeColor = "color"; +type TypeDatetime = "datetime"; type TypeUnion = "union"; // prettier-ignore @@ -41,19 +43,17 @@ type GuardNumber = A extends { type: TypeNumber } ? GuardDefaultRequired : unknown // prettier-ignore -type GuardString = - A extends { type: TypeString } ? GuardDefaultRequired : +type GuardText = + A extends { type: TypeText } ? GuardDefaultRequired : unknown // prettier-ignore type GuardTextarea = A extends { type: TypeTextarea } ? GuardDefaultRequired : unknown - // prettier-ignore -type GuardBoolean = - A extends { type: TypeBoolean } ? GuardDefaultRequired : +type GuardToggle = + A extends { type: TypeToggle } ? GuardDefaultRequired : unknown - // prettier-ignore type GuardObject = A extends { type: TypeObject, spec: infer B } ? ( @@ -72,11 +72,18 @@ type GuardSelect = B extends Record ? keyof B : never ) : unknown - // prettier-ignore type GuardMultiselect = A extends { type: TypeMultiselect, values: infer B} ?(keyof B)[] : unknown +// prettier-ignore +type GuardColor = + A extends { type: TypeColor } ? GuardDefaultRequired : + unknown + // prettier-ignore +type GuardDatetime = +A extends { type: TypeDatetime } ? GuardDefaultRequired : +unknown // prettier-ignore type VariantValue = @@ -91,14 +98,16 @@ type GuardUnion = type _ = T; export type GuardAll = GuardNumber & - GuardString & + GuardText & GuardTextarea & - GuardBoolean & + GuardToggle & GuardObject & GuardList & GuardUnion & GuardSelect & - GuardMultiselect; + GuardMultiselect & + GuardColor & + GuardDatetime; // prettier-ignore export type TypeFromProps = A extends Record ? { [K in keyof A & string]: _> } : @@ -114,7 +123,7 @@ const matchDefault = object({ default: unknown }); const matchRequired = object({ required: literals(false) }); const rangeRegex = /(\[|\()(\*|(\d|\.)+),(\*|(\d|\.)+)(\]|\))/; const matchRange = object({ range: string }); -const matchIntegral = object({ integral: literals(true) }); +const matchInteger = object({ integer: literals(true) }); const matchSpec = object({ spec: recordString }); const matchUnion = object({ variants: dictionary([string, matchVariant]), @@ -199,8 +208,8 @@ export function matchNumberWithRange(range: string) { `lessThan${rightValue}`, ); } -function withIntegral(parser: Parser, value: unknown) { - if (matchIntegral.test(value)) { +function withInteger(parser: Parser, value: unknown) { + if (matchInteger.test(value)) { return parser.validate(Number.isInteger, "isIntegral"); } return parser; @@ -243,18 +252,24 @@ export function guardAll( return unknown as any; } switch (value.type) { - case "boolean": + case "toggle": return defaultRequired(boolean, value) as any; - case "string": + case "text": return defaultRequired(string, value) as any; case "textarea": return defaultRequired(string, value) as any; + case "color": + return defaultRequired(string, value) as any; + + case "datetime": + return defaultRequired(string, value) as any; + case "number": return defaultRequired( - withIntegral(withRange(value), value), + withInteger(withRange(value), value), value, ) as any; diff --git a/scripts/oldSpecToBuilder.ts b/scripts/oldSpecToBuilder.ts index ee15d0a..46af34c 100644 --- a/scripts/oldSpecToBuilder.ts +++ b/scripts/oldSpecToBuilder.ts @@ -1,7 +1,6 @@ import camelCase from "lodash/camelCase"; import * as fs from "fs"; import { string } from "ts-matches"; -import { unionSelectKey } from "../lib/config/configTypes"; export async function writeConvertedFile( file: string, @@ -65,7 +64,7 @@ export default async function makeFileContent( 2, )})`; } - return `Value.string(${JSON.stringify( + return `Value.text(${JSON.stringify( { name: value.name || null, default: value.default || null, @@ -74,8 +73,11 @@ export default async function makeFileContent( required: !(value.nullable || false), masked: value.masked || false, placeholder: value.placeholder || null, - pattern: value.pattern || null, - patternDescription: value["pattern-description"] || null, + patterns: value.pattern ? + [{ regex: value.pattern, description: value["pattern-description"] }] : + [], + minLength: null, + maxLength: null, }, null, 2, @@ -89,8 +91,10 @@ export default async function makeFileContent( description: value.description || null, warning: value.warning || null, required: !(value.nullable || false), - range: value.range || null, - integral: value.integral || false, + min: null, + max: null, + step: null, + integer: value.integral || false, units: value.units || null, placeholder: value.placeholder || null, }, @@ -99,7 +103,7 @@ export default async function makeFileContent( )})`; } case "boolean": { - return `Value.boolean(${JSON.stringify( + return `Value.toggle(${JSON.stringify( { name: value.name || null, default: value.default || false, @@ -172,12 +176,11 @@ export default async function makeFileContent( function convertList(value: any) { switch (value.subtype) { case "string": { - return `List.${ - value?.spec?.textarea === true ? "textarea" : "string" - }(${JSON.stringify( + return `List.text(${JSON.stringify( { name: value.name || null, - range: value.range || null, + minLength: null, + maxLength: null, default: value.default || null, description: value.description || null, warning: value.warning || null, @@ -187,15 +190,19 @@ export default async function makeFileContent( )}, ${JSON.stringify({ masked: value?.spec?.masked || false, placeholder: value?.spec?.placeholder || null, - pattern: value?.spec?.pattern || null, - patternDescription: value?.spec?.["pattern-description"] || null, + patterns: value?.spec?.pattern ? + [{ regex: value.spec.pattern, description: value?.spec?.["pattern-description"] }] : + [], + minLength: null, + maxLength: null, })})`; } case "number": { return `List.number(${JSON.stringify( { name: value.name || null, - range: value.range || null, + minLength: null, + maxLength: null, default: value.default || null, description: value.description || null, warning: value.warning || null, @@ -203,8 +210,9 @@ export default async function makeFileContent( null, 2, )}, ${JSON.stringify({ - range: value?.spec?.range || null, - integral: value?.spec?.integral || false, + integer: value?.spec?.integral || false, + min: null, + max: null, units: value?.spec?.units || null, placeholder: value?.spec?.placeholder || null, })})`; @@ -225,7 +233,8 @@ export default async function makeFileContent( return `Value.multiselect(${JSON.stringify( { name: value.name || null, - range: value.range || null, + minLength: null, + maxLength: null, default: value.default || null, description: value.description || null, warning: value.warning || null, @@ -242,7 +251,8 @@ export default async function makeFileContent( ); return `List.obj({ name: ${JSON.stringify(value.name || null)}, - range: ${JSON.stringify(value.range || null)}, + minLength: ${JSON.stringify(null)}, + maxLength: ${JSON.stringify(null)}, default: ${JSON.stringify(value.default || null)}, description: ${JSON.stringify(value.description || null)}, warning: ${JSON.stringify(value.warning || null)}, @@ -284,7 +294,8 @@ export default async function makeFileContent( ); return `List.obj({ name:${JSON.stringify(value.name || null)}, - range:${JSON.stringify(value.range || null)}, + minLength:${JSON.stringify(null)}, + maxLength:${JSON.stringify(null)}, default: [], description: ${JSON.stringify(value.description || null)}, warning: ${JSON.stringify(value.warning || null)},