mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 04:11:57 +00:00
feat: Disabled on the types'
This commit is contained in:
@@ -4,6 +4,8 @@ import {
|
|||||||
Pattern,
|
Pattern,
|
||||||
UniqueBy,
|
UniqueBy,
|
||||||
ValueSpecList,
|
ValueSpecList,
|
||||||
|
ValueSpecListOf,
|
||||||
|
ValueSpecText,
|
||||||
} from "../configTypes"
|
} from "../configTypes"
|
||||||
import { Parser, arrayOf, number, string } from "ts-matches"
|
import { Parser, arrayOf, number, string } from "ts-matches"
|
||||||
/**
|
/**
|
||||||
@@ -62,9 +64,10 @@ export class List<Type, WD> {
|
|||||||
type: "list" as const,
|
type: "list" as const,
|
||||||
minLength: null,
|
minLength: null,
|
||||||
maxLength: null,
|
maxLength: null,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
spec,
|
spec,
|
||||||
}
|
} satisfies ValueSpecListOf<"text">
|
||||||
}, arrayOf(string))
|
}, arrayOf(string))
|
||||||
}
|
}
|
||||||
static dynamicText<WD>(
|
static dynamicText<WD>(
|
||||||
@@ -78,6 +81,7 @@ export class List<Type, WD> {
|
|||||||
default?: string[]
|
default?: string[]
|
||||||
minLength?: number | null
|
minLength?: number | null
|
||||||
maxLength?: number | null
|
maxLength?: number | null
|
||||||
|
disabled?: false | string
|
||||||
spec: {
|
spec: {
|
||||||
/** Default = false */
|
/** Default = false */
|
||||||
masked?: boolean
|
masked?: boolean
|
||||||
@@ -109,9 +113,10 @@ export class List<Type, WD> {
|
|||||||
type: "list" as const,
|
type: "list" as const,
|
||||||
minLength: null,
|
minLength: null,
|
||||||
maxLength: null,
|
maxLength: null,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
spec,
|
spec,
|
||||||
}
|
} satisfies ValueSpecListOf<"text">
|
||||||
}, arrayOf(string))
|
}, arrayOf(string))
|
||||||
}
|
}
|
||||||
static number<WD>(
|
static number<WD>(
|
||||||
@@ -150,9 +155,10 @@ export class List<Type, WD> {
|
|||||||
maxLength: null,
|
maxLength: null,
|
||||||
default: [],
|
default: [],
|
||||||
type: "list" as const,
|
type: "list" as const,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
spec,
|
spec,
|
||||||
}
|
} satisfies ValueSpecListOf<"number">
|
||||||
}, arrayOf(number))
|
}, arrayOf(number))
|
||||||
}
|
}
|
||||||
static dynamicNumber<WD>(
|
static dynamicNumber<WD>(
|
||||||
@@ -166,6 +172,7 @@ export class List<Type, WD> {
|
|||||||
default?: string[]
|
default?: string[]
|
||||||
minLength?: number | null
|
minLength?: number | null
|
||||||
maxLength?: number | null
|
maxLength?: number | null
|
||||||
|
disabled?: false | string
|
||||||
spec: {
|
spec: {
|
||||||
integer: boolean
|
integer: boolean
|
||||||
min?: number | null
|
min?: number | null
|
||||||
@@ -195,6 +202,7 @@ export class List<Type, WD> {
|
|||||||
maxLength: null,
|
maxLength: null,
|
||||||
default: [],
|
default: [],
|
||||||
type: "list" as const,
|
type: "list" as const,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
spec,
|
spec,
|
||||||
}
|
}
|
||||||
@@ -237,6 +245,7 @@ export class List<Type, WD> {
|
|||||||
minLength: null,
|
minLength: null,
|
||||||
maxLength: null,
|
maxLength: null,
|
||||||
type: "list" as const,
|
type: "list" as const,
|
||||||
|
disabled: false,
|
||||||
...value,
|
...value,
|
||||||
}
|
}
|
||||||
}, arrayOf(aSpec.spec.validator))
|
}, arrayOf(aSpec.spec.validator))
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ export class Value<Type, WD> {
|
|||||||
warning: null,
|
warning: null,
|
||||||
default: null,
|
default: null,
|
||||||
type: "toggle" as const,
|
type: "toggle" as const,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
}),
|
}),
|
||||||
boolean,
|
boolean,
|
||||||
@@ -123,6 +124,7 @@ export class Value<Type, WD> {
|
|||||||
description?: string | null
|
description?: string | null
|
||||||
warning?: string | null
|
warning?: string | null
|
||||||
default?: boolean | null
|
default?: boolean | null
|
||||||
|
disabled?: false | string
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
@@ -132,6 +134,7 @@ export class Value<Type, WD> {
|
|||||||
warning: null,
|
warning: null,
|
||||||
default: null,
|
default: null,
|
||||||
type: "toggle" as const,
|
type: "toggle" as const,
|
||||||
|
disabled: false,
|
||||||
...(await a(options)),
|
...(await a(options)),
|
||||||
}),
|
}),
|
||||||
boolean,
|
boolean,
|
||||||
@@ -163,6 +166,7 @@ export class Value<Type, WD> {
|
|||||||
maxLength: null,
|
maxLength: null,
|
||||||
patterns: [],
|
patterns: [],
|
||||||
inputmode: "text",
|
inputmode: "text",
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}),
|
}),
|
||||||
@@ -201,6 +205,7 @@ export class Value<Type, WD> {
|
|||||||
maxLength: null,
|
maxLength: null,
|
||||||
patterns: [],
|
patterns: [],
|
||||||
inputmode: "text",
|
inputmode: "text",
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}
|
}
|
||||||
@@ -224,6 +229,7 @@ export class Value<Type, WD> {
|
|||||||
maxLength: null,
|
maxLength: null,
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
type: "textarea" as const,
|
type: "textarea" as const,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
} satisfies ValueSpecTextarea),
|
} satisfies ValueSpecTextarea),
|
||||||
string,
|
string,
|
||||||
@@ -240,6 +246,7 @@ export class Value<Type, WD> {
|
|||||||
minLength?: number | null
|
minLength?: number | null
|
||||||
maxLength?: number | null
|
maxLength?: number | null
|
||||||
placeholder?: string | null
|
placeholder?: string | null
|
||||||
|
disabled?: false | string
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
@@ -252,6 +259,7 @@ export class Value<Type, WD> {
|
|||||||
maxLength: null,
|
maxLength: null,
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
type: "textarea" as const,
|
type: "textarea" as const,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
}
|
}
|
||||||
}, string)
|
}, string)
|
||||||
@@ -279,6 +287,7 @@ export class Value<Type, WD> {
|
|||||||
step: null,
|
step: null,
|
||||||
units: null,
|
units: null,
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}),
|
}),
|
||||||
@@ -300,6 +309,7 @@ export class Value<Type, WD> {
|
|||||||
integer: boolean
|
integer: boolean
|
||||||
units?: string | null
|
units?: string | null
|
||||||
placeholder?: string | null
|
placeholder?: string | null
|
||||||
|
disabled?: false | string
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
@@ -314,6 +324,7 @@ export class Value<Type, WD> {
|
|||||||
step: null,
|
step: null,
|
||||||
units: null,
|
units: null,
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}
|
}
|
||||||
@@ -330,6 +341,7 @@ export class Value<Type, WD> {
|
|||||||
type: "color" as const,
|
type: "color" as const,
|
||||||
description: null,
|
description: null,
|
||||||
warning: null,
|
warning: null,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}),
|
}),
|
||||||
@@ -346,6 +358,8 @@ export class Value<Type, WD> {
|
|||||||
description?: string | null
|
description?: string | null
|
||||||
warning?: string | null
|
warning?: string | null
|
||||||
required: RequiredDefault<string>
|
required: RequiredDefault<string>
|
||||||
|
|
||||||
|
disabled?: false | string
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
@@ -355,6 +369,7 @@ export class Value<Type, WD> {
|
|||||||
type: "color" as const,
|
type: "color" as const,
|
||||||
description: null,
|
description: null,
|
||||||
warning: null,
|
warning: null,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}
|
}
|
||||||
@@ -380,6 +395,7 @@ export class Value<Type, WD> {
|
|||||||
min: null,
|
min: null,
|
||||||
max: null,
|
max: null,
|
||||||
step: null,
|
step: null,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}),
|
}),
|
||||||
@@ -399,6 +415,7 @@ export class Value<Type, WD> {
|
|||||||
min?: string | null
|
min?: string | null
|
||||||
max?: string | null
|
max?: string | null
|
||||||
step?: string | null
|
step?: string | null
|
||||||
|
disabled?: false | string
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
@@ -412,6 +429,7 @@ export class Value<Type, WD> {
|
|||||||
min: null,
|
min: null,
|
||||||
max: null,
|
max: null,
|
||||||
step: null,
|
step: null,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}
|
}
|
||||||
@@ -421,7 +439,6 @@ export class Value<Type, WD> {
|
|||||||
Required extends RequiredDefault<string>,
|
Required extends RequiredDefault<string>,
|
||||||
B extends Record<string, string>,
|
B extends Record<string, string>,
|
||||||
WD,
|
WD,
|
||||||
CT,
|
|
||||||
>(a: {
|
>(a: {
|
||||||
name: string
|
name: string
|
||||||
description?: string | null
|
description?: string | null
|
||||||
@@ -434,6 +451,7 @@ export class Value<Type, WD> {
|
|||||||
description: null,
|
description: null,
|
||||||
warning: null,
|
warning: null,
|
||||||
type: "select" as const,
|
type: "select" as const,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}),
|
}),
|
||||||
@@ -454,6 +472,7 @@ export class Value<Type, WD> {
|
|||||||
warning?: string | null
|
warning?: string | null
|
||||||
required: RequiredDefault<string>
|
required: RequiredDefault<string>
|
||||||
values: Record<string, string>
|
values: Record<string, string>
|
||||||
|
disabled?: false | string
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
@@ -463,6 +482,7 @@ export class Value<Type, WD> {
|
|||||||
description: null,
|
description: null,
|
||||||
warning: null,
|
warning: null,
|
||||||
type: "select" as const,
|
type: "select" as const,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
...requiredLikeToAbove(a.required),
|
...requiredLikeToAbove(a.required),
|
||||||
}
|
}
|
||||||
@@ -484,6 +504,7 @@ export class Value<Type, WD> {
|
|||||||
maxLength: null,
|
maxLength: null,
|
||||||
warning: null,
|
warning: null,
|
||||||
description: null,
|
description: null,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
}),
|
}),
|
||||||
arrayOf(
|
arrayOf(
|
||||||
@@ -502,6 +523,7 @@ export class Value<Type, WD> {
|
|||||||
values: Record<string, string>
|
values: Record<string, string>
|
||||||
minLength?: number | null
|
minLength?: number | null
|
||||||
maxLength?: number | null
|
maxLength?: number | null
|
||||||
|
disabled?: false | string
|
||||||
}
|
}
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
@@ -513,6 +535,7 @@ export class Value<Type, WD> {
|
|||||||
maxLength: null,
|
maxLength: null,
|
||||||
warning: null,
|
warning: null,
|
||||||
description: null,
|
description: null,
|
||||||
|
disabled: false,
|
||||||
...a,
|
...a,
|
||||||
}
|
}
|
||||||
}, arrayOf(string))
|
}, arrayOf(string))
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export type ValueSpecOf<T extends ValueType> = T extends "text"
|
|||||||
export interface ValueSpecText extends ListValueSpecText, WithStandalone {
|
export interface ValueSpecText extends ListValueSpecText, WithStandalone {
|
||||||
required: boolean
|
required: boolean
|
||||||
default: DefaultString | null
|
default: DefaultString | null
|
||||||
|
disabled: false | string
|
||||||
}
|
}
|
||||||
export interface ValueSpecTextarea extends WithStandalone {
|
export interface ValueSpecTextarea extends WithStandalone {
|
||||||
type: "textarea"
|
type: "textarea"
|
||||||
@@ -50,15 +51,18 @@ export interface ValueSpecTextarea extends WithStandalone {
|
|||||||
minLength: number | null
|
minLength: number | null
|
||||||
maxLength: number | null
|
maxLength: number | null
|
||||||
required: boolean
|
required: boolean
|
||||||
|
disabled: false | string
|
||||||
}
|
}
|
||||||
export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone {
|
export interface ValueSpecNumber extends ListValueSpecNumber, WithStandalone {
|
||||||
required: boolean
|
required: boolean
|
||||||
default: number | null
|
default: number | null
|
||||||
|
disabled: false | string
|
||||||
}
|
}
|
||||||
export interface ValueSpecColor extends WithStandalone {
|
export interface ValueSpecColor extends WithStandalone {
|
||||||
type: "color"
|
type: "color"
|
||||||
required: boolean
|
required: boolean
|
||||||
default: string | null
|
default: string | null
|
||||||
|
disabled: false | string
|
||||||
}
|
}
|
||||||
export interface ValueSpecDatetime extends WithStandalone {
|
export interface ValueSpecDatetime extends WithStandalone {
|
||||||
type: "datetime"
|
type: "datetime"
|
||||||
@@ -68,21 +72,25 @@ export interface ValueSpecDatetime extends WithStandalone {
|
|||||||
max: string | null
|
max: string | null
|
||||||
step: string | null
|
step: string | null
|
||||||
default: string | null
|
default: string | null
|
||||||
|
disabled: false | string
|
||||||
}
|
}
|
||||||
export interface ValueSpecSelect extends SelectBase, WithStandalone {
|
export interface ValueSpecSelect extends SelectBase, WithStandalone {
|
||||||
type: "select"
|
type: "select"
|
||||||
required: boolean
|
required: boolean
|
||||||
default: string | null
|
default: string | null
|
||||||
|
disabled: false | string
|
||||||
}
|
}
|
||||||
export interface ValueSpecMultiselect extends SelectBase, WithStandalone {
|
export interface ValueSpecMultiselect extends SelectBase, WithStandalone {
|
||||||
type: "multiselect"
|
type: "multiselect"
|
||||||
minLength: number | null
|
minLength: number | null
|
||||||
maxLength: number | null
|
maxLength: number | null
|
||||||
|
disabled: false | string
|
||||||
default: string[]
|
default: string[]
|
||||||
}
|
}
|
||||||
export interface ValueSpecToggle extends WithStandalone {
|
export interface ValueSpecToggle extends WithStandalone {
|
||||||
type: "toggle"
|
type: "toggle"
|
||||||
default: boolean | null
|
default: boolean | null
|
||||||
|
disabled: false | string
|
||||||
}
|
}
|
||||||
export interface ValueSpecUnion extends WithStandalone {
|
export interface ValueSpecUnion extends WithStandalone {
|
||||||
type: "union"
|
type: "union"
|
||||||
@@ -131,6 +139,7 @@ export interface ValueSpecListOf<T extends ListValueSpecType>
|
|||||||
spec: ListValueSpecOf<T>
|
spec: ListValueSpecOf<T>
|
||||||
minLength: number | null
|
minLength: number | null
|
||||||
maxLength: number | null
|
maxLength: number | null
|
||||||
|
disabled: false | string
|
||||||
default:
|
default:
|
||||||
| string[]
|
| string[]
|
||||||
| number[]
|
| number[]
|
||||||
|
|||||||
@@ -18,26 +18,23 @@ describe("builder tests", () => {
|
|||||||
required: { default: null },
|
required: { default: null },
|
||||||
}),
|
}),
|
||||||
}).build({} as any)
|
}).build({} as any)
|
||||||
expect(JSON.stringify(bitcoinPropertiesBuilt)).toEqual(
|
expect(bitcoinPropertiesBuilt).toMatchObject({
|
||||||
/*json*/ `{
|
"peer-tor-address": {
|
||||||
"peer-tor-address": {
|
type: "text",
|
||||||
"type": "text",
|
description: "The Tor address of the peer interface",
|
||||||
"description": "The Tor address of the peer interface",
|
warning: null,
|
||||||
"warning": null,
|
masked: false,
|
||||||
"masked": false,
|
placeholder: null,
|
||||||
"placeholder": null,
|
minLength: null,
|
||||||
"minLength": null,
|
maxLength: null,
|
||||||
"maxLength": null,
|
patterns: [],
|
||||||
"patterns": [],
|
disabled: false,
|
||||||
"inputmode":"text",
|
inputmode: "text",
|
||||||
"name": "Peer tor address",
|
name: "Peer tor address",
|
||||||
"required": true,
|
required: true,
|
||||||
"default": null
|
default: null,
|
||||||
}}`
|
},
|
||||||
.replaceAll("\n", " ")
|
})
|
||||||
.replaceAll(/\s{2,}/g, "")
|
|
||||||
.replaceAll(": ", ":"),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user