@builder-builder/builder 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bb.d.ts +28 -0
- package/dist/bb.js +49 -0
- package/dist/check.d.ts +1 -1
- package/dist/check.js +4 -2
- package/dist/entities/builder/bind.d.ts +4 -0
- package/dist/entities/builder/builder.d.ts +17 -490
- package/dist/entities/builder/builder.js +19 -76
- package/dist/entities/builder/factory.d.ts +7 -0
- package/dist/entities/builder/factory.js +4 -0
- package/dist/entities/builder/index.d.ts +3 -6
- package/dist/entities/builder/index.js +1 -2
- package/dist/entities/collection/collection.d.ts +71 -20
- package/dist/entities/collection/collection.js +10 -27
- package/dist/entities/collection/config.d.ts +40 -1049
- package/dist/entities/collection/config.js +11 -11
- package/dist/entities/collection/expectation.d.ts +8 -4
- package/dist/entities/collection/index.d.ts +3 -3
- package/dist/entities/collection/index.js +1 -1
- package/dist/entities/collection/when.d.ts +6 -5
- package/dist/entities/component/component.d.ts +272 -300
- package/dist/entities/component/component.js +9 -8
- package/dist/entities/component/details.d.ts +35 -60
- package/dist/entities/component/details.js +9 -9
- package/dist/entities/component/expectation.d.ts +7 -4
- package/dist/entities/component/expectation.js +0 -3
- package/dist/entities/component/field.d.ts +50 -0
- package/dist/entities/component/field.js +41 -0
- package/dist/entities/component/index.d.ts +5 -3
- package/dist/entities/component/index.js +3 -2
- package/dist/entities/component/when.d.ts +5 -5
- package/dist/entities/component/when.js +2 -2
- package/dist/entities/entry.d.ts +4 -0
- package/dist/entities/expectation.d.ts +10 -22
- package/dist/entities/expectation.js +2 -7
- package/dist/entities/index.d.ts +21 -16
- package/dist/entities/index.js +10 -8
- package/dist/entities/kind.d.ts +9 -0
- package/dist/entities/kind.js +5 -0
- package/dist/entities/model/bind.d.ts +83 -0
- package/dist/entities/model/expectation.d.ts +16 -0
- package/dist/entities/model/index.d.ts +7 -0
- package/dist/entities/model/index.js +2 -0
- package/dist/entities/model/methods.d.ts +57 -0
- package/dist/entities/{builder → model}/methods.js +8 -8
- package/dist/entities/model/model.d.ts +39 -0
- package/dist/entities/model/model.js +73 -0
- package/dist/entities/model/models.d.ts +39 -0
- package/dist/entities/model/models.js +14 -0
- package/dist/entities/{builder → model}/state.d.ts +10 -10
- package/dist/entities/option/index.d.ts +2 -2
- package/dist/entities/option/index.js +2 -2
- package/dist/entities/option/option.d.ts +216 -214
- package/dist/entities/option/option.js +9 -8
- package/dist/entities/option/select.d.ts +2 -12
- package/dist/entities/option/select.js +6 -3
- package/dist/entities/option/toggle.d.ts +2 -9
- package/dist/entities/option/toggle.js +3 -3
- package/dist/entities/option/values.d.ts +4 -24
- package/dist/entities/option/values.js +10 -4
- package/dist/entities/option/when.d.ts +6 -5
- package/dist/entities/refs.d.ts +6 -0
- package/dist/entities/refs.js +1 -0
- package/dist/entities/serialise.d.ts +393 -3568
- package/dist/entities/serialise.js +160 -31
- package/dist/entities/ui/describe.d.ts +23 -57
- package/dist/entities/ui/describe.js +4 -5
- package/dist/entities/ui/index.d.ts +4 -9
- package/dist/entities/ui/index.js +2 -4
- package/dist/entities/ui/page.d.ts +23 -57
- package/dist/entities/ui/page.js +4 -5
- package/dist/entities/ui/pages.d.ts +18 -403
- package/dist/entities/ui/pages.js +7 -7
- package/dist/entities/ui/ui.d.ts +22 -1575
- package/dist/entities/ui/ui.js +15 -28
- package/dist/entities/ui/uis.d.ts +5 -9
- package/dist/entities/ui/uis.js +12 -19
- package/dist/entities/validated.d.ts +35 -0
- package/dist/entities/validated.js +1 -0
- package/dist/entities/when.d.ts +79 -70
- package/dist/entities/when.js +11 -7
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +2 -0
- package/dist/exception.d.ts +8 -3
- package/dist/exception.js +3 -0
- package/dist/index.d.ts +21 -24
- package/dist/index.js +5 -10
- package/dist/instance.d.ts +56 -0
- package/dist/instance.js +10 -0
- package/dist/mappers/index.d.ts +7 -5
- package/dist/mappers/index.js +5 -3
- package/dist/mappers/instance.d.ts +3 -0
- package/dist/mappers/instance.js +35 -0
- package/dist/mappers/order.d.ts +6 -0
- package/dist/mappers/order.js +22 -0
- package/dist/mappers/render/pages.d.ts +4 -4
- package/dist/mappers/render/render.d.ts +2 -3
- package/dist/mappers/render/render.js +83 -78
- package/dist/mappers/resolve.d.ts +5 -9
- package/dist/mappers/resolve.js +25 -33
- package/dist/mappers/variants/index.d.ts +1 -0
- package/dist/mappers/variants/index.js +1 -0
- package/dist/mappers/variants/option-graph.d.ts +19 -0
- package/dist/mappers/{models → variants}/option-graph.js +33 -22
- package/dist/mappers/variants/variants.d.ts +3 -0
- package/dist/mappers/variants/variants.js +57 -0
- package/dist/private.d.ts +4 -0
- package/dist/private.js +4 -0
- package/dist/references.d.ts +27 -36
- package/dist/references.js +19 -12
- package/dist/serialisable.d.ts +1 -9
- package/dist/serialisable.js +2 -3
- package/dist/validate/brand.d.ts +14 -0
- package/dist/validate/brand.js +17 -0
- package/dist/validate/builder.d.ts +4 -0
- package/dist/validate/builder.js +27 -0
- package/dist/validate/expectations.d.ts +10 -0
- package/dist/validate/expectations.js +12 -0
- package/dist/validate/index.d.ts +18 -0
- package/dist/validate/index.js +9 -0
- package/dist/validate/instance.d.ts +19 -0
- package/dist/validate/instance.js +46 -0
- package/dist/validate/model.d.ts +36 -0
- package/dist/validate/model.js +196 -0
- package/dist/validate/resolve.d.ts +16 -0
- package/dist/validate/resolve.js +91 -0
- package/dist/validate/result.d.ts +8 -0
- package/dist/validate/result.js +4 -0
- package/dist/validate/ui.d.ts +8 -0
- package/dist/validate/ui.js +77 -0
- package/dist/validate/variants.d.ts +59 -0
- package/dist/validate/variants.js +102 -0
- package/package.json +12 -9
- package/dist/entities/builder/builders.d.ts +0 -20
- package/dist/entities/builder/builders.js +0 -18
- package/dist/entities/builder/expectation.d.ts +0 -12
- package/dist/entities/builder/methods.d.ts +0 -58
- package/dist/entities/builder/parameter.d.ts +0 -62
- package/dist/entities/builder/parameter.js +0 -18
- package/dist/entities/builder/validate.d.ts +0 -3
- package/dist/entities/builder/validate.js +0 -108
- package/dist/entities/errors.d.ts +0 -21
- package/dist/entities/ui/label.d.ts +0 -18
- package/dist/entities/ui/label.js +0 -12
- package/dist/entities/ui/parameter.d.ts +0 -7
- package/dist/entities/ui/parameter.js +0 -29
- package/dist/entities/ui/validate.d.ts +0 -8
- package/dist/entities/ui/validate.js +0 -21
- package/dist/entities/validate.d.ts +0 -28
- package/dist/mappers/assert/builder.d.ts +0 -2
- package/dist/mappers/assert/builder.js +0 -46
- package/dist/mappers/assert/expectation.d.ts +0 -2
- package/dist/mappers/assert/expectation.js +0 -23
- package/dist/mappers/assert/index.d.ts +0 -6
- package/dist/mappers/assert/index.js +0 -4
- package/dist/mappers/assert/model.d.ts +0 -13
- package/dist/mappers/assert/model.js +0 -47
- package/dist/mappers/assert/models.d.ts +0 -33
- package/dist/mappers/assert/models.js +0 -74
- package/dist/mappers/assert/ui.d.ts +0 -2
- package/dist/mappers/assert/ui.js +0 -22
- package/dist/mappers/instance/index.d.ts +0 -1
- package/dist/mappers/instance/index.js +0 -1
- package/dist/mappers/instance/instance.d.ts +0 -4
- package/dist/mappers/instance/instance.js +0 -33
- package/dist/mappers/models/component-graph.d.ts +0 -9
- package/dist/mappers/models/component-graph.js +0 -51
- package/dist/mappers/models/graph.d.ts +0 -12
- package/dist/mappers/models/graph.js +0 -17
- package/dist/mappers/models/index.d.ts +0 -1
- package/dist/mappers/models/index.js +0 -1
- package/dist/mappers/models/models.d.ts +0 -3
- package/dist/mappers/models/models.js +0 -37
- package/dist/mappers/models/option-graph.d.ts +0 -9
- package/dist/mappers/order/index.d.ts +0 -2
- package/dist/mappers/order/index.js +0 -1
- package/dist/mappers/order/order.d.ts +0 -14
- package/dist/mappers/order/order.js +0 -31
- package/dist/model.d.ts +0 -14
- package/dist/walker/index.d.ts +0 -2
- package/dist/walker/index.js +0 -1
- package/dist/walker/walkable.d.ts +0 -4
- package/dist/walker/walkable.js +0 -4
- package/dist/walker/walker.d.ts +0 -18
- package/dist/walker/walker.js +0 -103
- package/dist/walker/walkers.d.ts +0 -8
- package/dist/walker/walkers.js +0 -51
- /package/dist/entities/builder/{expectation.js → bind.js} +0 -0
- /package/dist/entities/{builder/state.js → entry.js} +0 -0
- /package/dist/entities/{errors.js → model/bind.js} +0 -0
- /package/dist/entities/{validate.js → model/expectation.js} +0 -0
- /package/dist/{model.js → entities/model/state.js} +0 -0
|
@@ -1,48 +1,75 @@
|
|
|
1
1
|
import type { BuilderPaths } from '../../paths';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { Paramable } from '../../references';
|
|
3
|
+
import type { BuilderWhenSerialised } from '../when';
|
|
4
4
|
import type { BuilderOptionValues, BuilderOptionValuesSerialised } from './values';
|
|
5
|
+
import type { BuilderOptionWhen } from './when';
|
|
5
6
|
import * as v from 'valibot';
|
|
6
|
-
export type BuilderOptionPayload = BuilderOptionValues |
|
|
7
|
-
export declare class BuilderOption<const Name extends string = string, const Payload extends
|
|
7
|
+
export type BuilderOptionPayload = BuilderOptionValues | BuilderOptionWhen;
|
|
8
|
+
export declare class BuilderOption<const Name extends string = string, const Payload extends Paramable<BuilderOptionPayload> = Paramable<BuilderOptionPayload>, const Paths extends Paramable<BuilderPaths> = Paramable<BuilderPaths>> {
|
|
8
9
|
readonly type: 'option';
|
|
9
10
|
readonly name: Name;
|
|
10
11
|
readonly payload: Payload;
|
|
11
|
-
readonly
|
|
12
|
-
constructor(name: Name, payload: Payload,
|
|
12
|
+
readonly paths?: Paths;
|
|
13
|
+
constructor(name: Name, payload: Payload, paths?: Paths);
|
|
13
14
|
}
|
|
14
15
|
export declare const BuilderOptionSchema: v.InstanceSchema<typeof BuilderOption, undefined>;
|
|
15
16
|
export type BuilderOptions = ReadonlyArray<BuilderOption>;
|
|
16
|
-
export declare const BuilderOptionWhenSerialisedSchema: v.GenericSchema
|
|
17
|
-
|
|
17
|
+
export declare const BuilderOptionWhenSerialisedSchema: v.GenericSchema<BuilderWhenSerialised<Readonly<Readonly<{
|
|
18
|
+
type: "select";
|
|
19
|
+
readonly options: readonly [string, ...string[]];
|
|
20
|
+
defaultValue: string | null;
|
|
21
|
+
isOptional: boolean;
|
|
22
|
+
optionLabels: {
|
|
23
|
+
[x: string]: string;
|
|
24
|
+
};
|
|
25
|
+
}>> | Readonly<Readonly<{
|
|
26
|
+
type: "toggle";
|
|
27
|
+
valueType: "string" | "number" | "boolean";
|
|
28
|
+
defaultValue: string | number | boolean | null;
|
|
29
|
+
isOptional: boolean;
|
|
30
|
+
}>>>>;
|
|
31
|
+
export type BuilderOptionWhenSerialised = BuilderWhenSerialised<BuilderOptionValuesSerialised>;
|
|
32
|
+
export declare const BuilderOptionSelectMapSerialisedSchema: v.GenericSchema<import("..").BuilderMatchSelectMap<Readonly<{
|
|
33
|
+
type: "parameter";
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
}> | Readonly<Readonly<{
|
|
37
|
+
type: "select";
|
|
38
|
+
readonly options: readonly [string, ...string[]];
|
|
39
|
+
defaultValue: string | null;
|
|
40
|
+
isOptional: boolean;
|
|
41
|
+
optionLabels: {
|
|
42
|
+
[x: string]: string;
|
|
43
|
+
};
|
|
44
|
+
}>> | Readonly<Readonly<{
|
|
45
|
+
type: "toggle";
|
|
46
|
+
valueType: "string" | "number" | "boolean";
|
|
47
|
+
defaultValue: string | number | boolean | null;
|
|
48
|
+
isOptional: boolean;
|
|
49
|
+
}>>>>;
|
|
18
50
|
export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
19
51
|
readonly name: v.StringSchema<undefined>;
|
|
20
|
-
readonly payload: v.
|
|
21
|
-
readonly type: v.LiteralSchema<"
|
|
52
|
+
readonly payload: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
53
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
22
54
|
readonly id: v.StringSchema<undefined>;
|
|
23
55
|
readonly name: v.StringSchema<undefined>;
|
|
24
56
|
}, undefined>, v.ReadonlyAction<{
|
|
25
|
-
type: "
|
|
57
|
+
type: "parameter";
|
|
26
58
|
id: string;
|
|
27
59
|
name: string;
|
|
28
|
-
}>]>, v.
|
|
60
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
61
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
62
|
+
readonly id: v.StringSchema<undefined>;
|
|
63
|
+
}, undefined>, v.ReadonlyAction<{
|
|
64
|
+
type: "ref";
|
|
65
|
+
id: string;
|
|
66
|
+
}>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
29
67
|
readonly type: v.LiteralSchema<"select", undefined>;
|
|
30
68
|
readonly options: v.SchemaWithPipe<readonly [v.TupleWithRestSchema<[v.StringSchema<undefined>], v.StringSchema<undefined>, undefined>, v.ReadonlyAction<[string, ...string[]]>]>;
|
|
31
69
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
32
70
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
33
71
|
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
34
|
-
}, undefined>, v.
|
|
35
|
-
type: "select";
|
|
36
|
-
readonly options: readonly [string, ...string[]];
|
|
37
|
-
defaultValue: string | null;
|
|
38
|
-
isOptional: boolean;
|
|
39
|
-
optionLabels: {
|
|
40
|
-
[x: string]: string;
|
|
41
|
-
};
|
|
42
|
-
}, {
|
|
43
|
-
readonly serialisable: typeof import("./select").BuilderSelectType;
|
|
44
|
-
readonly instance: v.InstanceSchema<typeof import("./select").BuilderSelectType, undefined>;
|
|
45
|
-
}>, v.ReadonlyAction<{
|
|
72
|
+
}, undefined>, v.ReadonlyAction<{
|
|
46
73
|
type: "select";
|
|
47
74
|
readonly options: readonly [string, ...string[]];
|
|
48
75
|
defaultValue: string | null;
|
|
@@ -55,20 +82,25 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
55
82
|
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
56
83
|
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
57
84
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
58
|
-
}, undefined>, v.
|
|
85
|
+
}, undefined>, v.ReadonlyAction<{
|
|
59
86
|
type: "toggle";
|
|
60
87
|
valueType: "string" | "number" | "boolean";
|
|
61
88
|
defaultValue: string | number | boolean | null;
|
|
62
89
|
isOptional: boolean;
|
|
63
|
-
}, {
|
|
64
|
-
|
|
65
|
-
readonly
|
|
66
|
-
|
|
90
|
+
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
91
|
+
type: "select";
|
|
92
|
+
readonly options: readonly [string, ...string[]];
|
|
93
|
+
defaultValue: string | null;
|
|
94
|
+
isOptional: boolean;
|
|
95
|
+
optionLabels: {
|
|
96
|
+
[x: string]: string;
|
|
97
|
+
};
|
|
98
|
+
}> | Readonly<{
|
|
67
99
|
type: "toggle";
|
|
68
100
|
valueType: "string" | "number" | "boolean";
|
|
69
101
|
defaultValue: string | number | boolean | null;
|
|
70
102
|
isOptional: boolean;
|
|
71
|
-
}
|
|
103
|
+
}>>]>, v.GenericSchema<BuilderWhenSerialised<Readonly<Readonly<{
|
|
72
104
|
type: "select";
|
|
73
105
|
readonly options: readonly [string, ...string[]];
|
|
74
106
|
defaultValue: string | null;
|
|
@@ -76,134 +108,96 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
76
108
|
optionLabels: {
|
|
77
109
|
[x: string]: string;
|
|
78
110
|
};
|
|
79
|
-
}
|
|
111
|
+
}>> | Readonly<Readonly<{
|
|
80
112
|
type: "toggle";
|
|
81
113
|
valueType: "string" | "number" | "boolean";
|
|
82
114
|
defaultValue: string | number | boolean | null;
|
|
83
115
|
isOptional: boolean;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
readonly options: v.SchemaWithPipe<readonly [v.TupleWithRestSchema<[v.StringSchema<undefined>], v.StringSchema<undefined>, undefined>, v.ReadonlyAction<[string, ...string[]]>]>;
|
|
88
|
-
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
89
|
-
readonly isOptional: v.BooleanSchema<undefined>;
|
|
90
|
-
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
91
|
-
}, undefined>, v.MetadataAction<{
|
|
92
|
-
type: "select";
|
|
93
|
-
readonly options: readonly [string, ...string[]];
|
|
94
|
-
defaultValue: string | null;
|
|
95
|
-
isOptional: boolean;
|
|
96
|
-
optionLabels: {
|
|
97
|
-
[x: string]: string;
|
|
98
|
-
};
|
|
99
|
-
}, {
|
|
100
|
-
readonly serialisable: typeof import("./select").BuilderSelectType;
|
|
101
|
-
readonly instance: v.InstanceSchema<typeof import("./select").BuilderSelectType, undefined>;
|
|
102
|
-
}>, v.ReadonlyAction<{
|
|
103
|
-
type: "select";
|
|
104
|
-
readonly options: readonly [string, ...string[]];
|
|
105
|
-
defaultValue: string | null;
|
|
106
|
-
isOptional: boolean;
|
|
107
|
-
optionLabels: {
|
|
108
|
-
[x: string]: string;
|
|
109
|
-
};
|
|
110
|
-
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
111
|
-
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
112
|
-
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
113
|
-
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
114
|
-
readonly isOptional: v.BooleanSchema<undefined>;
|
|
115
|
-
}, undefined>, v.MetadataAction<{
|
|
116
|
-
type: "toggle";
|
|
117
|
-
valueType: "string" | "number" | "boolean";
|
|
118
|
-
defaultValue: string | number | boolean | null;
|
|
119
|
-
isOptional: boolean;
|
|
120
|
-
}, {
|
|
121
|
-
readonly serialisable: typeof import("./toggle").BuilderToggleType;
|
|
122
|
-
readonly instance: v.InstanceSchema<typeof import("./toggle").BuilderToggleType, undefined>;
|
|
123
|
-
}>, v.ReadonlyAction<{
|
|
124
|
-
type: "toggle";
|
|
125
|
-
valueType: "string" | "number" | "boolean";
|
|
126
|
-
defaultValue: string | number | boolean | null;
|
|
127
|
-
isOptional: boolean;
|
|
128
|
-
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
129
|
-
type: "select";
|
|
130
|
-
readonly options: readonly [string, ...string[]];
|
|
131
|
-
defaultValue: string | null;
|
|
132
|
-
isOptional: boolean;
|
|
133
|
-
optionLabels: {
|
|
134
|
-
[x: string]: string;
|
|
135
|
-
};
|
|
136
|
-
}> | Readonly<{
|
|
137
|
-
type: "toggle";
|
|
138
|
-
valueType: "string" | "number" | "boolean";
|
|
139
|
-
defaultValue: string | number | boolean | null;
|
|
140
|
-
isOptional: boolean;
|
|
141
|
-
}>>]>, v.GenericSchema], undefined>;
|
|
142
|
-
}>]>;
|
|
143
|
-
readonly gatePaths: v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
144
|
-
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
116
|
+
}>>>>], undefined>], undefined>;
|
|
117
|
+
readonly paths: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
118
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
145
119
|
readonly id: v.StringSchema<undefined>;
|
|
146
120
|
readonly name: v.StringSchema<undefined>;
|
|
147
121
|
}, undefined>, v.ReadonlyAction<{
|
|
148
|
-
type: "
|
|
122
|
+
type: "parameter";
|
|
149
123
|
id: string;
|
|
150
124
|
name: string;
|
|
151
|
-
}>]>, v.
|
|
125
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
126
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
127
|
+
readonly id: v.StringSchema<undefined>;
|
|
128
|
+
}, undefined>, v.ReadonlyAction<{
|
|
152
129
|
type: "ref";
|
|
153
130
|
id: string;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
readonly refable: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>, undefined>, v.ReadonlyAction<(readonly (string | number)[])[]>]>;
|
|
157
|
-
}>]>, undefined>;
|
|
158
|
-
}, undefined>, v.MetadataAction<{
|
|
131
|
+
}>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>, undefined>, v.ReadonlyAction<(readonly (string | number)[])[]>]>], undefined>, undefined>;
|
|
132
|
+
}, undefined>, v.ReadonlyAction<{
|
|
159
133
|
name: string;
|
|
160
|
-
payload:
|
|
161
|
-
|
|
162
|
-
type: "ref";
|
|
134
|
+
payload: Readonly<{
|
|
135
|
+
type: "parameter";
|
|
163
136
|
id: string;
|
|
164
137
|
name: string;
|
|
165
|
-
}> |
|
|
166
|
-
}, {
|
|
167
|
-
readonly serialisable: typeof BuilderOption;
|
|
168
|
-
readonly instance: v.InstanceSchema<typeof BuilderOption, undefined>;
|
|
169
|
-
}>, v.ReadonlyAction<{
|
|
170
|
-
name: string;
|
|
171
|
-
payload: unknown;
|
|
172
|
-
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
138
|
+
}> | Readonly<{
|
|
173
139
|
type: "ref";
|
|
174
140
|
id: string;
|
|
141
|
+
}> | Readonly<Readonly<{
|
|
142
|
+
type: "select";
|
|
143
|
+
readonly options: readonly [string, ...string[]];
|
|
144
|
+
defaultValue: string | null;
|
|
145
|
+
isOptional: boolean;
|
|
146
|
+
optionLabels: {
|
|
147
|
+
[x: string]: string;
|
|
148
|
+
};
|
|
149
|
+
}>> | Readonly<Readonly<{
|
|
150
|
+
type: "toggle";
|
|
151
|
+
valueType: "string" | "number" | "boolean";
|
|
152
|
+
defaultValue: string | number | boolean | null;
|
|
153
|
+
isOptional: boolean;
|
|
154
|
+
}>> | BuilderWhenSerialised<Readonly<Readonly<{
|
|
155
|
+
type: "select";
|
|
156
|
+
readonly options: readonly [string, ...string[]];
|
|
157
|
+
defaultValue: string | null;
|
|
158
|
+
isOptional: boolean;
|
|
159
|
+
optionLabels: {
|
|
160
|
+
[x: string]: string;
|
|
161
|
+
};
|
|
162
|
+
}>> | Readonly<Readonly<{
|
|
163
|
+
type: "toggle";
|
|
164
|
+
valueType: "string" | "number" | "boolean";
|
|
165
|
+
defaultValue: string | number | boolean | null;
|
|
166
|
+
isOptional: boolean;
|
|
167
|
+
}>>>;
|
|
168
|
+
paths?: readonly (readonly (string | number)[])[] | Readonly<{
|
|
169
|
+
type: "parameter";
|
|
170
|
+
id: string;
|
|
175
171
|
name: string;
|
|
172
|
+
}> | Readonly<{
|
|
173
|
+
type: "ref";
|
|
174
|
+
id: string;
|
|
176
175
|
}> | undefined;
|
|
177
176
|
}>]>;
|
|
178
177
|
export type BuilderOptionSerialised = v.InferOutput<typeof BuilderOptionSerialisedSchema>;
|
|
179
178
|
export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
180
179
|
readonly name: v.StringSchema<undefined>;
|
|
181
|
-
readonly payload: v.
|
|
182
|
-
readonly type: v.LiteralSchema<"
|
|
180
|
+
readonly payload: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
181
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
183
182
|
readonly id: v.StringSchema<undefined>;
|
|
184
183
|
readonly name: v.StringSchema<undefined>;
|
|
185
184
|
}, undefined>, v.ReadonlyAction<{
|
|
186
|
-
type: "
|
|
185
|
+
type: "parameter";
|
|
187
186
|
id: string;
|
|
188
187
|
name: string;
|
|
189
|
-
}>]>, v.
|
|
188
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
189
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
190
|
+
readonly id: v.StringSchema<undefined>;
|
|
191
|
+
}, undefined>, v.ReadonlyAction<{
|
|
192
|
+
type: "ref";
|
|
193
|
+
id: string;
|
|
194
|
+
}>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
190
195
|
readonly type: v.LiteralSchema<"select", undefined>;
|
|
191
196
|
readonly options: v.SchemaWithPipe<readonly [v.TupleWithRestSchema<[v.StringSchema<undefined>], v.StringSchema<undefined>, undefined>, v.ReadonlyAction<[string, ...string[]]>]>;
|
|
192
197
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
193
198
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
194
199
|
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
195
|
-
}, undefined>, v.
|
|
196
|
-
type: "select";
|
|
197
|
-
readonly options: readonly [string, ...string[]];
|
|
198
|
-
defaultValue: string | null;
|
|
199
|
-
isOptional: boolean;
|
|
200
|
-
optionLabels: {
|
|
201
|
-
[x: string]: string;
|
|
202
|
-
};
|
|
203
|
-
}, {
|
|
204
|
-
readonly serialisable: typeof import("./select").BuilderSelectType;
|
|
205
|
-
readonly instance: v.InstanceSchema<typeof import("./select").BuilderSelectType, undefined>;
|
|
206
|
-
}>, v.ReadonlyAction<{
|
|
200
|
+
}, undefined>, v.ReadonlyAction<{
|
|
207
201
|
type: "select";
|
|
208
202
|
readonly options: readonly [string, ...string[]];
|
|
209
203
|
defaultValue: string | null;
|
|
@@ -216,20 +210,25 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
216
210
|
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
217
211
|
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
218
212
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
219
|
-
}, undefined>, v.
|
|
213
|
+
}, undefined>, v.ReadonlyAction<{
|
|
220
214
|
type: "toggle";
|
|
221
215
|
valueType: "string" | "number" | "boolean";
|
|
222
216
|
defaultValue: string | number | boolean | null;
|
|
223
217
|
isOptional: boolean;
|
|
224
|
-
}, {
|
|
225
|
-
|
|
226
|
-
readonly
|
|
227
|
-
|
|
218
|
+
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
219
|
+
type: "select";
|
|
220
|
+
readonly options: readonly [string, ...string[]];
|
|
221
|
+
defaultValue: string | null;
|
|
222
|
+
isOptional: boolean;
|
|
223
|
+
optionLabels: {
|
|
224
|
+
[x: string]: string;
|
|
225
|
+
};
|
|
226
|
+
}> | Readonly<{
|
|
228
227
|
type: "toggle";
|
|
229
228
|
valueType: "string" | "number" | "boolean";
|
|
230
229
|
defaultValue: string | number | boolean | null;
|
|
231
230
|
isOptional: boolean;
|
|
232
|
-
}
|
|
231
|
+
}>>]>, v.GenericSchema<BuilderWhenSerialised<Readonly<Readonly<{
|
|
233
232
|
type: "select";
|
|
234
233
|
readonly options: readonly [string, ...string[]];
|
|
235
234
|
defaultValue: string | null;
|
|
@@ -237,111 +236,114 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
237
236
|
optionLabels: {
|
|
238
237
|
[x: string]: string;
|
|
239
238
|
};
|
|
240
|
-
}
|
|
239
|
+
}>> | Readonly<Readonly<{
|
|
241
240
|
type: "toggle";
|
|
242
241
|
valueType: "string" | "number" | "boolean";
|
|
243
242
|
defaultValue: string | number | boolean | null;
|
|
244
243
|
isOptional: boolean;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
readonly options: v.SchemaWithPipe<readonly [v.TupleWithRestSchema<[v.StringSchema<undefined>], v.StringSchema<undefined>, undefined>, v.ReadonlyAction<[string, ...string[]]>]>;
|
|
249
|
-
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
250
|
-
readonly isOptional: v.BooleanSchema<undefined>;
|
|
251
|
-
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
252
|
-
}, undefined>, v.MetadataAction<{
|
|
253
|
-
type: "select";
|
|
254
|
-
readonly options: readonly [string, ...string[]];
|
|
255
|
-
defaultValue: string | null;
|
|
256
|
-
isOptional: boolean;
|
|
257
|
-
optionLabels: {
|
|
258
|
-
[x: string]: string;
|
|
259
|
-
};
|
|
260
|
-
}, {
|
|
261
|
-
readonly serialisable: typeof import("./select").BuilderSelectType;
|
|
262
|
-
readonly instance: v.InstanceSchema<typeof import("./select").BuilderSelectType, undefined>;
|
|
263
|
-
}>, v.ReadonlyAction<{
|
|
264
|
-
type: "select";
|
|
265
|
-
readonly options: readonly [string, ...string[]];
|
|
266
|
-
defaultValue: string | null;
|
|
267
|
-
isOptional: boolean;
|
|
268
|
-
optionLabels: {
|
|
269
|
-
[x: string]: string;
|
|
270
|
-
};
|
|
271
|
-
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
272
|
-
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
273
|
-
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
274
|
-
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
275
|
-
readonly isOptional: v.BooleanSchema<undefined>;
|
|
276
|
-
}, undefined>, v.MetadataAction<{
|
|
277
|
-
type: "toggle";
|
|
278
|
-
valueType: "string" | "number" | "boolean";
|
|
279
|
-
defaultValue: string | number | boolean | null;
|
|
280
|
-
isOptional: boolean;
|
|
281
|
-
}, {
|
|
282
|
-
readonly serialisable: typeof import("./toggle").BuilderToggleType;
|
|
283
|
-
readonly instance: v.InstanceSchema<typeof import("./toggle").BuilderToggleType, undefined>;
|
|
284
|
-
}>, v.ReadonlyAction<{
|
|
285
|
-
type: "toggle";
|
|
286
|
-
valueType: "string" | "number" | "boolean";
|
|
287
|
-
defaultValue: string | number | boolean | null;
|
|
288
|
-
isOptional: boolean;
|
|
289
|
-
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
290
|
-
type: "select";
|
|
291
|
-
readonly options: readonly [string, ...string[]];
|
|
292
|
-
defaultValue: string | null;
|
|
293
|
-
isOptional: boolean;
|
|
294
|
-
optionLabels: {
|
|
295
|
-
[x: string]: string;
|
|
296
|
-
};
|
|
297
|
-
}> | Readonly<{
|
|
298
|
-
type: "toggle";
|
|
299
|
-
valueType: "string" | "number" | "boolean";
|
|
300
|
-
defaultValue: string | number | boolean | null;
|
|
301
|
-
isOptional: boolean;
|
|
302
|
-
}>>]>, v.GenericSchema], undefined>;
|
|
303
|
-
}>]>;
|
|
304
|
-
readonly gatePaths: v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
305
|
-
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
244
|
+
}>>>>], undefined>], undefined>;
|
|
245
|
+
readonly paths: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
246
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
306
247
|
readonly id: v.StringSchema<undefined>;
|
|
307
248
|
readonly name: v.StringSchema<undefined>;
|
|
308
249
|
}, undefined>, v.ReadonlyAction<{
|
|
309
|
-
type: "
|
|
250
|
+
type: "parameter";
|
|
310
251
|
id: string;
|
|
311
252
|
name: string;
|
|
312
|
-
}>]>, v.
|
|
253
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
254
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
255
|
+
readonly id: v.StringSchema<undefined>;
|
|
256
|
+
}, undefined>, v.ReadonlyAction<{
|
|
313
257
|
type: "ref";
|
|
314
258
|
id: string;
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
readonly refable: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>, undefined>, v.ReadonlyAction<(readonly (string | number)[])[]>]>;
|
|
318
|
-
}>]>, undefined>;
|
|
319
|
-
}, undefined>, v.MetadataAction<{
|
|
259
|
+
}>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>, undefined>, v.ReadonlyAction<(readonly (string | number)[])[]>]>], undefined>, undefined>;
|
|
260
|
+
}, undefined>, v.ReadonlyAction<{
|
|
320
261
|
name: string;
|
|
321
|
-
payload:
|
|
322
|
-
|
|
323
|
-
type: "ref";
|
|
262
|
+
payload: Readonly<{
|
|
263
|
+
type: "parameter";
|
|
324
264
|
id: string;
|
|
325
265
|
name: string;
|
|
326
|
-
}> |
|
|
327
|
-
}, {
|
|
328
|
-
readonly serialisable: typeof BuilderOption;
|
|
329
|
-
readonly instance: v.InstanceSchema<typeof BuilderOption, undefined>;
|
|
330
|
-
}>, v.ReadonlyAction<{
|
|
331
|
-
name: string;
|
|
332
|
-
payload: unknown;
|
|
333
|
-
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
266
|
+
}> | Readonly<{
|
|
334
267
|
type: "ref";
|
|
335
268
|
id: string;
|
|
269
|
+
}> | Readonly<Readonly<{
|
|
270
|
+
type: "select";
|
|
271
|
+
readonly options: readonly [string, ...string[]];
|
|
272
|
+
defaultValue: string | null;
|
|
273
|
+
isOptional: boolean;
|
|
274
|
+
optionLabels: {
|
|
275
|
+
[x: string]: string;
|
|
276
|
+
};
|
|
277
|
+
}>> | Readonly<Readonly<{
|
|
278
|
+
type: "toggle";
|
|
279
|
+
valueType: "string" | "number" | "boolean";
|
|
280
|
+
defaultValue: string | number | boolean | null;
|
|
281
|
+
isOptional: boolean;
|
|
282
|
+
}>> | BuilderWhenSerialised<Readonly<Readonly<{
|
|
283
|
+
type: "select";
|
|
284
|
+
readonly options: readonly [string, ...string[]];
|
|
285
|
+
defaultValue: string | null;
|
|
286
|
+
isOptional: boolean;
|
|
287
|
+
optionLabels: {
|
|
288
|
+
[x: string]: string;
|
|
289
|
+
};
|
|
290
|
+
}>> | Readonly<Readonly<{
|
|
291
|
+
type: "toggle";
|
|
292
|
+
valueType: "string" | "number" | "boolean";
|
|
293
|
+
defaultValue: string | number | boolean | null;
|
|
294
|
+
isOptional: boolean;
|
|
295
|
+
}>>>;
|
|
296
|
+
paths?: readonly (readonly (string | number)[])[] | Readonly<{
|
|
297
|
+
type: "parameter";
|
|
298
|
+
id: string;
|
|
336
299
|
name: string;
|
|
300
|
+
}> | Readonly<{
|
|
301
|
+
type: "ref";
|
|
302
|
+
id: string;
|
|
337
303
|
}> | undefined;
|
|
338
304
|
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
339
305
|
name: string;
|
|
340
|
-
payload:
|
|
341
|
-
|
|
306
|
+
payload: Readonly<{
|
|
307
|
+
type: "parameter";
|
|
308
|
+
id: string;
|
|
309
|
+
name: string;
|
|
310
|
+
}> | Readonly<{
|
|
342
311
|
type: "ref";
|
|
343
312
|
id: string;
|
|
313
|
+
}> | Readonly<Readonly<{
|
|
314
|
+
type: "select";
|
|
315
|
+
readonly options: readonly [string, ...string[]];
|
|
316
|
+
defaultValue: string | null;
|
|
317
|
+
isOptional: boolean;
|
|
318
|
+
optionLabels: {
|
|
319
|
+
[x: string]: string;
|
|
320
|
+
};
|
|
321
|
+
}>> | Readonly<Readonly<{
|
|
322
|
+
type: "toggle";
|
|
323
|
+
valueType: "string" | "number" | "boolean";
|
|
324
|
+
defaultValue: string | number | boolean | null;
|
|
325
|
+
isOptional: boolean;
|
|
326
|
+
}>> | BuilderWhenSerialised<Readonly<Readonly<{
|
|
327
|
+
type: "select";
|
|
328
|
+
readonly options: readonly [string, ...string[]];
|
|
329
|
+
defaultValue: string | null;
|
|
330
|
+
isOptional: boolean;
|
|
331
|
+
optionLabels: {
|
|
332
|
+
[x: string]: string;
|
|
333
|
+
};
|
|
334
|
+
}>> | Readonly<Readonly<{
|
|
335
|
+
type: "toggle";
|
|
336
|
+
valueType: "string" | "number" | "boolean";
|
|
337
|
+
defaultValue: string | number | boolean | null;
|
|
338
|
+
isOptional: boolean;
|
|
339
|
+
}>>>;
|
|
340
|
+
paths?: readonly (readonly (string | number)[])[] | Readonly<{
|
|
341
|
+
type: "parameter";
|
|
342
|
+
id: string;
|
|
344
343
|
name: string;
|
|
344
|
+
}> | Readonly<{
|
|
345
|
+
type: "ref";
|
|
346
|
+
id: string;
|
|
345
347
|
}> | undefined;
|
|
346
348
|
}>[]>]>;
|
|
347
349
|
export type BuilderOptionsSerialised = v.InferOutput<typeof BuilderOptionsSerialisedSchema>;
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { BuilderPathsSchema } from '../../paths.js';
|
|
3
|
-
import {
|
|
3
|
+
import { paramable } from '../../references.js';
|
|
4
4
|
import { serialisable } from '../../serialisable.js';
|
|
5
|
-
import { createWhenSerialisedSchema } from '../when.js';
|
|
5
|
+
import { createSelectMapSerialisedSchema, createWhenSerialisedSchema } from '../when.js';
|
|
6
6
|
import { BuilderOptionValuesSerialisedSchema } from './values.js';
|
|
7
7
|
export class BuilderOption {
|
|
8
8
|
name;
|
|
9
9
|
payload;
|
|
10
|
-
|
|
11
|
-
constructor(name, payload,
|
|
10
|
+
paths;
|
|
11
|
+
constructor(name, payload, paths) {
|
|
12
12
|
this.name = name;
|
|
13
13
|
this.payload = payload;
|
|
14
|
-
this.
|
|
14
|
+
this.paths = paths;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
export const BuilderOptionSchema = v.instance(BuilderOption);
|
|
18
18
|
export const BuilderOptionWhenSerialisedSchema = createWhenSerialisedSchema(BuilderOptionValuesSerialisedSchema);
|
|
19
|
-
export const
|
|
19
|
+
export const BuilderOptionSelectMapSerialisedSchema = createSelectMapSerialisedSchema(BuilderOptionValuesSerialisedSchema);
|
|
20
|
+
export const BuilderOptionSerialisedSchema = serialisable(v.object({
|
|
20
21
|
name: v.string(),
|
|
21
|
-
payload:
|
|
22
|
-
|
|
22
|
+
payload: paramable(v.union([BuilderOptionValuesSerialisedSchema, BuilderOptionWhenSerialisedSchema])),
|
|
23
|
+
paths: v.optional(paramable(BuilderPathsSchema))
|
|
23
24
|
}));
|
|
24
25
|
export const BuilderOptionsSerialisedSchema = v.pipe(v.array(BuilderOptionSerialisedSchema), v.readonly());
|
|
@@ -25,18 +25,7 @@ export declare const BuilderSelectTypeSerialisedSchema: v.SchemaWithPipe<readonl
|
|
|
25
25
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
26
26
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
27
27
|
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
28
|
-
}, undefined>, v.
|
|
29
|
-
type: "select";
|
|
30
|
-
readonly options: readonly [string, ...string[]];
|
|
31
|
-
defaultValue: string | null;
|
|
32
|
-
isOptional: boolean;
|
|
33
|
-
optionLabels: {
|
|
34
|
-
[x: string]: string;
|
|
35
|
-
};
|
|
36
|
-
}, {
|
|
37
|
-
readonly serialisable: typeof BuilderSelectType;
|
|
38
|
-
readonly instance: v.InstanceSchema<typeof BuilderSelectType, undefined>;
|
|
39
|
-
}>, v.ReadonlyAction<{
|
|
28
|
+
}, undefined>, v.ReadonlyAction<{
|
|
40
29
|
type: "select";
|
|
41
30
|
readonly options: readonly [string, ...string[]];
|
|
42
31
|
defaultValue: string | null;
|
|
@@ -46,4 +35,5 @@ export declare const BuilderSelectTypeSerialisedSchema: v.SchemaWithPipe<readonl
|
|
|
46
35
|
};
|
|
47
36
|
}>]>;
|
|
48
37
|
export type BuilderSelectTypeSerialised = v.InferOutput<typeof BuilderSelectTypeSerialisedSchema>;
|
|
38
|
+
export declare function selectValueSchema(options: ReadonlyArray<string>, optional: boolean): v.GenericSchema<string | null>;
|
|
49
39
|
export {};
|
|
@@ -9,8 +9,7 @@ export class BuilderSelectType {
|
|
|
9
9
|
optionLabels;
|
|
10
10
|
constructor(values, defaultValue, optional = false, optionLabels = {}) {
|
|
11
11
|
this.options = values;
|
|
12
|
-
|
|
13
|
-
this.valueSchema = (optional ? v.nullable(baseSchema) : baseSchema);
|
|
12
|
+
this.valueSchema = selectValueSchema(values, optional);
|
|
14
13
|
this.defaultValue = defaultValue;
|
|
15
14
|
this.isOptional = optional;
|
|
16
15
|
this.optionLabels = optionLabels;
|
|
@@ -31,10 +30,14 @@ export function select(values) {
|
|
|
31
30
|
return new BuilderSelectType(values, defaultValue, false);
|
|
32
31
|
}
|
|
33
32
|
export const BuilderSelectTypeSchema = v.instance(BuilderSelectType);
|
|
34
|
-
export const BuilderSelectTypeSerialisedSchema = serialisable(
|
|
33
|
+
export const BuilderSelectTypeSerialisedSchema = serialisable(v.object({
|
|
35
34
|
type: v.literal('select'),
|
|
36
35
|
options: v.pipe(v.tupleWithRest([v.string()], v.string()), v.readonly()),
|
|
37
36
|
defaultValue: v.nullable(v.string()),
|
|
38
37
|
isOptional: v.boolean(),
|
|
39
38
|
optionLabels: v.record(v.string(), v.string())
|
|
40
39
|
}));
|
|
40
|
+
export function selectValueSchema(options, optional) {
|
|
41
|
+
const baseSchema = v.union(options.map((value) => v.literal(value)));
|
|
42
|
+
return optional ? v.nullable(baseSchema) : baseSchema;
|
|
43
|
+
}
|