@builder-builder/builder 0.0.7 → 0.0.8
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/check.d.ts +2 -1
- package/dist/check.js +6 -2
- package/dist/entities/builder/builder.d.ts +494 -0
- package/dist/entities/builder/builder.js +84 -0
- package/dist/entities/builder/builders.d.ts +20 -0
- package/dist/entities/builder/builders.js +18 -0
- package/dist/entities/builder/expectation.d.ts +12 -0
- package/dist/entities/builder/index.d.ts +7 -0
- package/dist/entities/builder/index.js +3 -0
- package/dist/entities/builder/methods.d.ts +58 -0
- package/dist/entities/builder/methods.js +30 -0
- package/dist/entities/builder/parameter.d.ts +61 -0
- package/dist/entities/builder/parameter.js +18 -0
- package/dist/entities/builder/state.d.ts +26 -0
- package/dist/entities/builder/validate.d.ts +3 -0
- package/dist/entities/builder/validate.js +108 -0
- package/dist/entities/collection/collection.d.ts +37 -0
- package/dist/entities/collection/collection.js +42 -0
- package/dist/entities/collection/config.d.ts +1094 -0
- package/dist/entities/collection/config.js +23 -0
- package/dist/entities/collection/expectation.d.ts +7 -0
- package/dist/entities/collection/expectation.js +4 -0
- package/dist/entities/collection/index.d.ts +8 -0
- package/dist/entities/collection/index.js +4 -0
- package/dist/entities/collection/when.d.ts +9 -0
- package/dist/entities/collection/when.js +2 -0
- package/dist/entities/component/component.d.ts +403 -0
- package/dist/entities/component/component.js +24 -0
- package/dist/entities/component/details.d.ts +82 -0
- package/dist/entities/component/details.js +17 -0
- package/dist/entities/component/expectation.d.ts +8 -0
- package/dist/entities/component/expectation.js +7 -0
- package/dist/entities/component/index.d.ts +8 -0
- package/dist/entities/component/index.js +4 -0
- package/dist/entities/component/when.d.ts +11 -0
- package/dist/entities/component/when.js +20 -0
- package/dist/entities/errors.d.ts +21 -0
- package/dist/entities/expectation.d.ts +44 -0
- package/dist/entities/expectation.js +23 -0
- package/dist/entities/index.d.ts +18 -0
- package/dist/entities/index.js +9 -0
- package/dist/entities/option/expectation.d.ts +2 -0
- package/dist/entities/option/expectation.js +4 -0
- package/dist/entities/option/index.d.ts +11 -0
- package/dist/entities/option/index.js +6 -0
- package/dist/entities/option/option.d.ts +347 -0
- package/dist/entities/option/option.js +24 -0
- package/dist/entities/option/select.d.ts +49 -0
- package/dist/entities/option/select.js +40 -0
- package/dist/entities/option/toggle.d.ts +39 -0
- package/dist/entities/option/toggle.js +42 -0
- package/dist/entities/option/values.d.ts +63 -0
- package/dist/entities/option/values.js +8 -0
- package/dist/entities/option/when.d.ts +9 -0
- package/dist/entities/option/when.js +2 -0
- package/dist/entities/serialise.d.ts +3801 -0
- package/dist/entities/serialise.js +41 -0
- package/dist/entities/ui/describe.d.ts +100 -0
- package/dist/entities/ui/describe.js +22 -0
- package/dist/entities/ui/index.d.ts +14 -0
- package/dist/entities/ui/index.js +7 -0
- package/dist/entities/ui/label.d.ts +18 -0
- package/dist/entities/ui/label.js +12 -0
- package/dist/entities/ui/page.d.ts +96 -0
- package/dist/entities/ui/page.js +20 -0
- package/dist/entities/ui/pages.d.ts +431 -0
- package/dist/entities/ui/pages.js +29 -0
- package/dist/entities/ui/parameter.d.ts +7 -0
- package/dist/entities/ui/parameter.js +29 -0
- package/dist/entities/ui/ui.d.ts +1582 -0
- package/dist/entities/ui/ui.js +53 -0
- package/dist/entities/ui/uis.d.ts +10 -0
- package/dist/entities/ui/uis.js +20 -0
- package/dist/entities/ui/validate.d.ts +8 -0
- package/dist/entities/ui/validate.js +21 -0
- package/dist/entities/validate.d.ts +28 -0
- package/dist/entities/validate.js +1 -0
- package/dist/entities/when.d.ts +176 -0
- package/dist/entities/when.js +47 -0
- package/dist/exception.d.ts +8 -0
- package/dist/exception.js +7 -0
- package/dist/index.d.ts +37 -13
- package/dist/index.js +22 -5
- package/dist/mappers/assert/builder.d.ts +2 -0
- package/dist/mappers/assert/builder.js +46 -0
- package/dist/mappers/assert/expectation.d.ts +2 -0
- package/dist/mappers/assert/expectation.js +23 -0
- package/dist/mappers/assert/index.d.ts +6 -0
- package/dist/mappers/assert/index.js +4 -0
- package/dist/mappers/assert/model.d.ts +13 -0
- package/dist/mappers/assert/model.js +47 -0
- package/dist/mappers/assert/models.d.ts +33 -0
- package/dist/mappers/assert/models.js +74 -0
- package/dist/mappers/assert/ui.d.ts +2 -0
- package/dist/mappers/assert/ui.js +22 -0
- package/dist/mappers/index.d.ts +7 -0
- package/dist/mappers/index.js +4 -0
- package/dist/mappers/instance/index.d.ts +1 -0
- package/dist/mappers/instance/index.js +1 -0
- package/dist/mappers/instance/instance.d.ts +4 -0
- package/dist/mappers/instance/instance.js +33 -0
- package/dist/mappers/models/component-graph.d.ts +9 -0
- package/dist/{core/component/graph.js → mappers/models/component-graph.js} +3 -3
- package/dist/{core → mappers/models}/graph.d.ts +4 -1
- package/dist/mappers/models/graph.js +17 -0
- package/dist/mappers/models/index.d.ts +1 -0
- package/dist/mappers/models/index.js +1 -0
- package/dist/mappers/models/models.d.ts +3 -0
- package/dist/mappers/models/models.js +37 -0
- package/dist/mappers/models/option-graph.d.ts +9 -0
- package/dist/mappers/models/option-graph.js +77 -0
- package/dist/mappers/order/index.d.ts +2 -0
- package/dist/mappers/order/index.js +1 -0
- package/dist/mappers/order/order.d.ts +14 -0
- package/dist/mappers/order/order.js +31 -0
- package/dist/mappers/render/index.d.ts +4 -0
- package/dist/mappers/render/index.js +2 -0
- package/dist/mappers/render/ordinal.d.ts +1 -0
- package/dist/mappers/render/ordinal.js +20 -0
- package/dist/mappers/render/pages.d.ts +15 -0
- package/dist/mappers/render/pages.js +1 -0
- package/dist/mappers/render/render.d.ts +8 -0
- package/dist/mappers/render/render.js +124 -0
- package/dist/mappers/resolve.d.ts +9 -0
- package/dist/mappers/resolve.js +57 -0
- package/dist/model.d.ts +8 -8
- package/dist/paths.d.ts +5 -16
- package/dist/paths.js +3 -0
- package/dist/primitive.d.ts +5 -0
- package/dist/{schemas/primitives.js → primitive.js} +0 -2
- package/dist/references.d.ts +60 -0
- package/dist/references.js +26 -0
- package/dist/serialisable.d.ts +10 -0
- package/dist/serialisable.js +5 -0
- package/dist/walker/index.d.ts +2 -0
- package/dist/walker/index.js +1 -0
- package/dist/walker/walkable.d.ts +4 -0
- package/dist/walker/walkable.js +4 -0
- package/dist/walker/walker.d.ts +18 -0
- package/dist/walker/walker.js +103 -0
- package/dist/walker/walkers.d.ts +8 -0
- package/dist/walker/walkers.js +51 -0
- package/package.json +9 -3
- package/dist/core/builder.d.ts +0 -74
- package/dist/core/builder.js +0 -109
- package/dist/core/collection/collection.d.ts +0 -32
- package/dist/core/collection/collection.js +0 -37
- package/dist/core/collection/index.d.ts +0 -4
- package/dist/core/collection/index.js +0 -2
- package/dist/core/collection/method.d.ts +0 -30
- package/dist/core/collection/method.js +0 -11
- package/dist/core/component/component.d.ts +0 -9
- package/dist/core/component/component.js +0 -10
- package/dist/core/component/graph.d.ts +0 -9
- package/dist/core/component/index.d.ts +0 -4
- package/dist/core/component/index.js +0 -2
- package/dist/core/component/method.d.ts +0 -11
- package/dist/core/expectation.d.ts +0 -42
- package/dist/core/expectation.js +0 -18
- package/dist/core/graph.js +0 -3
- package/dist/core/index.d.ts +0 -14
- package/dist/core/index.js +0 -7
- package/dist/core/option/graph.d.ts +0 -10
- package/dist/core/option/graph.js +0 -78
- package/dist/core/option/index.d.ts +0 -10
- package/dist/core/option/index.js +0 -5
- package/dist/core/option/method.d.ts +0 -70
- package/dist/core/option/method.js +0 -13
- package/dist/core/option/option.d.ts +0 -30
- package/dist/core/option/option.js +0 -42
- package/dist/core/option/select.d.ts +0 -22
- package/dist/core/option/select.js +0 -34
- package/dist/core/option/toggle.d.ts +0 -16
- package/dist/core/option/toggle.js +0 -29
- package/dist/core/parameter.d.ts +0 -48
- package/dist/core/parameter.js +0 -31
- package/dist/core/validate.d.ts +0 -26
- package/dist/core/validate.js +0 -43
- package/dist/core/when/config.d.ts +0 -20
- package/dist/core/when/config.js +0 -4
- package/dist/core/when/constrain.d.ts +0 -14
- package/dist/core/when/index.d.ts +0 -5
- package/dist/core/when/index.js +0 -2
- package/dist/core/when/nullability.d.ts +0 -18
- package/dist/core/when/resolve.d.ts +0 -18
- package/dist/core/when/resolve.js +0 -22
- package/dist/resolve/index.d.ts +0 -10
- package/dist/resolve/index.js +0 -5
- package/dist/resolve/instance.d.ts +0 -35
- package/dist/resolve/instance.js +0 -80
- package/dist/resolve/models.d.ts +0 -3
- package/dist/resolve/models.js +0 -20
- package/dist/resolve/order.d.ts +0 -21
- package/dist/resolve/order.js +0 -27
- package/dist/resolve/render.d.ts +0 -23
- package/dist/resolve/render.js +0 -171
- package/dist/resolve/validate.d.ts +0 -37
- package/dist/resolve/validate.js +0 -47
- package/dist/schemas/description.d.ts +0 -5
- package/dist/schemas/description.js +0 -3
- package/dist/schemas/index.d.ts +0 -6
- package/dist/schemas/index.js +0 -3
- package/dist/schemas/primitives.d.ts +0 -9
- package/dist/schemas/ui.d.ts +0 -96
- package/dist/schemas/ui.js +0 -23
- package/dist/serialise/deserialise.d.ts +0 -14
- package/dist/serialise/deserialise.js +0 -119
- package/dist/serialise/index.d.ts +0 -6
- package/dist/serialise/index.js +0 -4
- package/dist/serialise/schemas.d.ts +0 -1946
- package/dist/serialise/schemas.js +0 -150
- package/dist/serialise/serialise.d.ts +0 -13
- package/dist/serialise/serialise.js +0 -147
- package/dist/serialise/validate.d.ts +0 -26
- package/dist/serialise/validate.js +0 -148
- package/dist/ui.d.ts +0 -19
- package/dist/ui.js +0 -44
- /package/dist/{core/component/method.js → entities/builder/expectation.js} +0 -0
- /package/dist/{core/when/constrain.js → entities/builder/state.js} +0 -0
- /package/dist/{core/when/nullability.js → entities/errors.js} +0 -0
package/dist/check.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import * as v from 'valibot';
|
|
|
2
2
|
declare class Check {
|
|
3
3
|
truthy<Input>(input: Input, message?: `${string}! ❌`): asserts input is Exclude<Input, null | undefined | '' | 0 | false>;
|
|
4
4
|
falsy(input: unknown, message?: `${string}! ❌`): void;
|
|
5
|
-
|
|
5
|
+
is<const Schema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(schema: Schema, input: unknown): input is v.InferInput<Schema>;
|
|
6
|
+
assert<const Schema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>>(schema: Schema, input: unknown): asserts input is v.InferInput<Schema>;
|
|
6
7
|
}
|
|
7
8
|
export declare const check: Check;
|
|
8
9
|
export {};
|
package/dist/check.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { BuilderException } from './exception.js';
|
|
2
3
|
const DEFAULT_MESSAGE = 'Unexpected value! ❌';
|
|
3
4
|
class Check {
|
|
4
5
|
truthy(input, message = DEFAULT_MESSAGE) {
|
|
5
6
|
if (!input) {
|
|
6
|
-
throw new
|
|
7
|
+
throw new BuilderException([], message);
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
10
|
falsy(input, message = DEFAULT_MESSAGE) {
|
|
10
11
|
if (input) {
|
|
11
|
-
throw new
|
|
12
|
+
throw new BuilderException([], message);
|
|
12
13
|
}
|
|
13
14
|
}
|
|
15
|
+
is(schema, input) {
|
|
16
|
+
return v.is(schema, input);
|
|
17
|
+
}
|
|
14
18
|
assert(schema, input) {
|
|
15
19
|
v.assert(schema, input);
|
|
16
20
|
}
|
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
import type { Prettify } from '../../prettify';
|
|
2
|
+
import type { BuilderRefs, Refable } from '../../references';
|
|
3
|
+
import type { BuilderCollections } from '../collection/index';
|
|
4
|
+
import type { BuilderComponentDetails, BuilderComponents } from '../component/index';
|
|
5
|
+
import type { BuilderExpectation, BuilderExpectations } from '../expectation';
|
|
6
|
+
import type { BuilderOptions } from '../option/index';
|
|
7
|
+
import type { BuilderWhenConstrained } from '../when';
|
|
8
|
+
import type { BuilderStateAsserted } from './expectation';
|
|
9
|
+
import type { BuilderCollectionMethod, BuilderComponentMethod, BuilderOptionMethod } from './methods';
|
|
10
|
+
import type { BuilderBindings, BuilderBoundState } from './parameter';
|
|
11
|
+
import type { BuilderState, BuilderStateEmpty } from './state';
|
|
12
|
+
import * as v from 'valibot';
|
|
13
|
+
export declare class Builder<State extends BuilderState = BuilderStateEmpty> {
|
|
14
|
+
#private;
|
|
15
|
+
readonly type: 'builder';
|
|
16
|
+
readonly references: State['references'];
|
|
17
|
+
readonly options: State['options'];
|
|
18
|
+
readonly components: State['components'];
|
|
19
|
+
readonly collections: State['collections'];
|
|
20
|
+
readonly expectations: BuilderExpectations;
|
|
21
|
+
readonly id: `${string}-${string}-${string}-${string}-${string}`;
|
|
22
|
+
constructor(references?: BuilderRefs, options?: BuilderOptions, components?: BuilderComponents, collections?: BuilderCollections, expectations?: BuilderExpectations);
|
|
23
|
+
get option(): BuilderOptionMethod<State>;
|
|
24
|
+
get component(): BuilderComponentMethod<State>;
|
|
25
|
+
get collection(): BuilderCollectionMethod<State>;
|
|
26
|
+
expect<const Expectations extends readonly [BuilderExpectation, ...ReadonlyArray<BuilderExpectation>]>(...expectations: Expectations): Builder<BuilderStateAsserted<State, Expectations>>;
|
|
27
|
+
bind<const Bindings extends BuilderBindings<State>>(bindings: Bindings & {
|
|
28
|
+
readonly [Key in keyof Bindings]: BuilderWhenConstrained<State, Bindings[Key]>;
|
|
29
|
+
}): Builder<BuilderBoundState<State, Bindings>>;
|
|
30
|
+
}
|
|
31
|
+
export type BuilderGeneric = Builder<BuilderState>;
|
|
32
|
+
export declare const BuilderSchema: v.InstanceSchema<typeof Builder, undefined>;
|
|
33
|
+
export declare const BuilderSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
34
|
+
readonly references: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
35
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
36
|
+
readonly id: v.StringSchema<undefined>;
|
|
37
|
+
readonly name: v.StringSchema<undefined>;
|
|
38
|
+
}, undefined>, v.ReadonlyAction<{
|
|
39
|
+
type: "ref";
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
43
|
+
type: "ref";
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
}>[]>]>;
|
|
47
|
+
readonly options: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
48
|
+
readonly name: v.StringSchema<undefined>;
|
|
49
|
+
readonly payload: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
50
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
51
|
+
readonly id: v.StringSchema<undefined>;
|
|
52
|
+
readonly name: v.StringSchema<undefined>;
|
|
53
|
+
}, undefined>, v.ReadonlyAction<{
|
|
54
|
+
type: "ref";
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
}>]>, v.InstanceSchema<typeof import("../..").BuilderRef, undefined>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
58
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
59
|
+
readonly options: v.SchemaWithPipe<readonly [v.TupleWithRestSchema<[v.StringSchema<undefined>], v.StringSchema<undefined>, undefined>, v.ReadonlyAction<[string, ...string[]]>]>;
|
|
60
|
+
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
61
|
+
readonly isOptional: v.BooleanSchema<undefined>;
|
|
62
|
+
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
63
|
+
}, undefined>, v.MetadataAction<{
|
|
64
|
+
type: "select";
|
|
65
|
+
readonly options: readonly [string, ...string[]];
|
|
66
|
+
defaultValue: string | null;
|
|
67
|
+
isOptional: boolean;
|
|
68
|
+
optionLabels: {
|
|
69
|
+
[x: string]: string;
|
|
70
|
+
};
|
|
71
|
+
}, {
|
|
72
|
+
readonly serialisable: typeof import("..").BuilderSelectType;
|
|
73
|
+
readonly instance: v.InstanceSchema<typeof import("..").BuilderSelectType, undefined>;
|
|
74
|
+
}>, v.ReadonlyAction<{
|
|
75
|
+
type: "select";
|
|
76
|
+
readonly options: readonly [string, ...string[]];
|
|
77
|
+
defaultValue: string | null;
|
|
78
|
+
isOptional: boolean;
|
|
79
|
+
optionLabels: {
|
|
80
|
+
[x: string]: string;
|
|
81
|
+
};
|
|
82
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
83
|
+
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
84
|
+
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
85
|
+
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
86
|
+
readonly isOptional: v.BooleanSchema<undefined>;
|
|
87
|
+
}, undefined>, v.MetadataAction<{
|
|
88
|
+
type: "toggle";
|
|
89
|
+
valueType: "string" | "number" | "boolean";
|
|
90
|
+
defaultValue: string | number | boolean | null;
|
|
91
|
+
isOptional: boolean;
|
|
92
|
+
}, {
|
|
93
|
+
readonly serialisable: typeof import("..").BuilderToggleType;
|
|
94
|
+
readonly instance: v.InstanceSchema<typeof import("..").BuilderToggleType, undefined>;
|
|
95
|
+
}>, v.ReadonlyAction<{
|
|
96
|
+
type: "toggle";
|
|
97
|
+
valueType: "string" | "number" | "boolean";
|
|
98
|
+
defaultValue: string | number | boolean | null;
|
|
99
|
+
isOptional: boolean;
|
|
100
|
+
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
101
|
+
type: "select";
|
|
102
|
+
readonly options: readonly [string, ...string[]];
|
|
103
|
+
defaultValue: string | null;
|
|
104
|
+
isOptional: boolean;
|
|
105
|
+
optionLabels: {
|
|
106
|
+
[x: string]: string;
|
|
107
|
+
};
|
|
108
|
+
}> | Readonly<{
|
|
109
|
+
type: "toggle";
|
|
110
|
+
valueType: "string" | "number" | "boolean";
|
|
111
|
+
defaultValue: string | number | boolean | null;
|
|
112
|
+
isOptional: boolean;
|
|
113
|
+
}>>]>, v.GenericSchema], undefined>], undefined>, v.MetadataAction<unknown, {
|
|
114
|
+
readonly refable: v.UnionSchema<[v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
115
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
116
|
+
readonly options: v.SchemaWithPipe<readonly [v.TupleWithRestSchema<[v.StringSchema<undefined>], v.StringSchema<undefined>, undefined>, v.ReadonlyAction<[string, ...string[]]>]>;
|
|
117
|
+
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
118
|
+
readonly isOptional: v.BooleanSchema<undefined>;
|
|
119
|
+
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
120
|
+
}, undefined>, v.MetadataAction<{
|
|
121
|
+
type: "select";
|
|
122
|
+
readonly options: readonly [string, ...string[]];
|
|
123
|
+
defaultValue: string | null;
|
|
124
|
+
isOptional: boolean;
|
|
125
|
+
optionLabels: {
|
|
126
|
+
[x: string]: string;
|
|
127
|
+
};
|
|
128
|
+
}, {
|
|
129
|
+
readonly serialisable: typeof import("..").BuilderSelectType;
|
|
130
|
+
readonly instance: v.InstanceSchema<typeof import("..").BuilderSelectType, undefined>;
|
|
131
|
+
}>, v.ReadonlyAction<{
|
|
132
|
+
type: "select";
|
|
133
|
+
readonly options: readonly [string, ...string[]];
|
|
134
|
+
defaultValue: string | null;
|
|
135
|
+
isOptional: boolean;
|
|
136
|
+
optionLabels: {
|
|
137
|
+
[x: string]: string;
|
|
138
|
+
};
|
|
139
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
140
|
+
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
141
|
+
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
142
|
+
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
143
|
+
readonly isOptional: v.BooleanSchema<undefined>;
|
|
144
|
+
}, undefined>, v.MetadataAction<{
|
|
145
|
+
type: "toggle";
|
|
146
|
+
valueType: "string" | "number" | "boolean";
|
|
147
|
+
defaultValue: string | number | boolean | null;
|
|
148
|
+
isOptional: boolean;
|
|
149
|
+
}, {
|
|
150
|
+
readonly serialisable: typeof import("..").BuilderToggleType;
|
|
151
|
+
readonly instance: v.InstanceSchema<typeof import("..").BuilderToggleType, undefined>;
|
|
152
|
+
}>, v.ReadonlyAction<{
|
|
153
|
+
type: "toggle";
|
|
154
|
+
valueType: "string" | "number" | "boolean";
|
|
155
|
+
defaultValue: string | number | boolean | null;
|
|
156
|
+
isOptional: boolean;
|
|
157
|
+
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
158
|
+
type: "select";
|
|
159
|
+
readonly options: readonly [string, ...string[]];
|
|
160
|
+
defaultValue: string | null;
|
|
161
|
+
isOptional: boolean;
|
|
162
|
+
optionLabels: {
|
|
163
|
+
[x: string]: string;
|
|
164
|
+
};
|
|
165
|
+
}> | Readonly<{
|
|
166
|
+
type: "toggle";
|
|
167
|
+
valueType: "string" | "number" | "boolean";
|
|
168
|
+
defaultValue: string | number | boolean | null;
|
|
169
|
+
isOptional: boolean;
|
|
170
|
+
}>>]>, v.GenericSchema], undefined>;
|
|
171
|
+
}>]>;
|
|
172
|
+
readonly gatePaths: v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
173
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
174
|
+
readonly id: v.StringSchema<undefined>;
|
|
175
|
+
readonly name: v.StringSchema<undefined>;
|
|
176
|
+
}, undefined>, v.ReadonlyAction<{
|
|
177
|
+
type: "ref";
|
|
178
|
+
id: string;
|
|
179
|
+
name: string;
|
|
180
|
+
}>]>, v.InstanceSchema<typeof import("../..").BuilderRef, undefined>, 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>, v.MetadataAction<readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
181
|
+
type: "ref";
|
|
182
|
+
id: string;
|
|
183
|
+
name: string;
|
|
184
|
+
}>, {
|
|
185
|
+
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)[])[]>]>;
|
|
186
|
+
}>]>, undefined>;
|
|
187
|
+
}, undefined>, v.MetadataAction<{
|
|
188
|
+
name: string;
|
|
189
|
+
payload: unknown;
|
|
190
|
+
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
191
|
+
type: "ref";
|
|
192
|
+
id: string;
|
|
193
|
+
name: string;
|
|
194
|
+
}> | undefined;
|
|
195
|
+
}, {
|
|
196
|
+
readonly serialisable: typeof import("..").BuilderOption;
|
|
197
|
+
readonly instance: v.InstanceSchema<typeof import("..").BuilderOption, undefined>;
|
|
198
|
+
}>, v.ReadonlyAction<{
|
|
199
|
+
name: string;
|
|
200
|
+
payload: unknown;
|
|
201
|
+
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
202
|
+
type: "ref";
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
}> | undefined;
|
|
206
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
207
|
+
name: string;
|
|
208
|
+
payload: unknown;
|
|
209
|
+
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
210
|
+
type: "ref";
|
|
211
|
+
id: string;
|
|
212
|
+
name: string;
|
|
213
|
+
}> | undefined;
|
|
214
|
+
}>[]>]>;
|
|
215
|
+
readonly components: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
216
|
+
readonly name: v.StringSchema<undefined>;
|
|
217
|
+
readonly payload: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
218
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
219
|
+
readonly id: v.StringSchema<undefined>;
|
|
220
|
+
readonly name: v.StringSchema<undefined>;
|
|
221
|
+
}, undefined>, v.ReadonlyAction<{
|
|
222
|
+
type: "ref";
|
|
223
|
+
id: string;
|
|
224
|
+
name: string;
|
|
225
|
+
}>]>, v.InstanceSchema<typeof import("../..").BuilderRef, undefined>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
226
|
+
readonly expectations: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
227
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
228
|
+
readonly id: v.StringSchema<undefined>;
|
|
229
|
+
readonly name: v.StringSchema<undefined>;
|
|
230
|
+
}, undefined>, v.ReadonlyAction<{
|
|
231
|
+
type: "ref";
|
|
232
|
+
id: string;
|
|
233
|
+
name: string;
|
|
234
|
+
}>]>, v.InstanceSchema<typeof import("../..").BuilderRef, undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
235
|
+
readonly name: v.StringSchema<undefined>;
|
|
236
|
+
readonly kind: v.PicklistSchema<["option", "component", "collection", "detail"], undefined>;
|
|
237
|
+
}, undefined>, v.MetadataAction<{
|
|
238
|
+
name: string;
|
|
239
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
240
|
+
}, {
|
|
241
|
+
readonly serialisable: typeof BuilderExpectation;
|
|
242
|
+
readonly instance: v.InstanceSchema<typeof BuilderExpectation, undefined>;
|
|
243
|
+
}>, v.ReadonlyAction<{
|
|
244
|
+
name: string;
|
|
245
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
246
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
247
|
+
name: string;
|
|
248
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
249
|
+
}>[]>]>], undefined>, v.MetadataAction<import("../..").BuilderRef | Readonly<{
|
|
250
|
+
type: "ref";
|
|
251
|
+
id: string;
|
|
252
|
+
name: string;
|
|
253
|
+
}> | readonly Readonly<{
|
|
254
|
+
name: string;
|
|
255
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
256
|
+
}>[], {
|
|
257
|
+
readonly refable: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
258
|
+
readonly name: v.StringSchema<undefined>;
|
|
259
|
+
readonly kind: v.PicklistSchema<["option", "component", "collection", "detail"], undefined>;
|
|
260
|
+
}, undefined>, v.MetadataAction<{
|
|
261
|
+
name: string;
|
|
262
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
263
|
+
}, {
|
|
264
|
+
readonly serialisable: typeof BuilderExpectation;
|
|
265
|
+
readonly instance: v.InstanceSchema<typeof BuilderExpectation, undefined>;
|
|
266
|
+
}>, v.ReadonlyAction<{
|
|
267
|
+
name: string;
|
|
268
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
269
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
270
|
+
name: string;
|
|
271
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
272
|
+
}>[]>]>;
|
|
273
|
+
}>]>;
|
|
274
|
+
}, undefined>, v.MetadataAction<{
|
|
275
|
+
expectations: import("../..").BuilderRef | Readonly<{
|
|
276
|
+
type: "ref";
|
|
277
|
+
id: string;
|
|
278
|
+
name: string;
|
|
279
|
+
}> | readonly Readonly<{
|
|
280
|
+
name: string;
|
|
281
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
282
|
+
}>[];
|
|
283
|
+
}, {
|
|
284
|
+
readonly serialisable: typeof BuilderComponentDetails;
|
|
285
|
+
readonly instance: v.InstanceSchema<typeof BuilderComponentDetails, undefined>;
|
|
286
|
+
}>, v.ReadonlyAction<{
|
|
287
|
+
expectations: import("../..").BuilderRef | Readonly<{
|
|
288
|
+
type: "ref";
|
|
289
|
+
id: string;
|
|
290
|
+
name: string;
|
|
291
|
+
}> | readonly Readonly<{
|
|
292
|
+
name: string;
|
|
293
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
294
|
+
}>[];
|
|
295
|
+
}>]>, v.GenericSchema], undefined>], undefined>, v.MetadataAction<unknown, {
|
|
296
|
+
readonly refable: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
297
|
+
readonly expectations: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
298
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
299
|
+
readonly id: v.StringSchema<undefined>;
|
|
300
|
+
readonly name: v.StringSchema<undefined>;
|
|
301
|
+
}, undefined>, v.ReadonlyAction<{
|
|
302
|
+
type: "ref";
|
|
303
|
+
id: string;
|
|
304
|
+
name: string;
|
|
305
|
+
}>]>, v.InstanceSchema<typeof import("../..").BuilderRef, undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
306
|
+
readonly name: v.StringSchema<undefined>;
|
|
307
|
+
readonly kind: v.PicklistSchema<["option", "component", "collection", "detail"], undefined>;
|
|
308
|
+
}, undefined>, v.MetadataAction<{
|
|
309
|
+
name: string;
|
|
310
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
311
|
+
}, {
|
|
312
|
+
readonly serialisable: typeof BuilderExpectation;
|
|
313
|
+
readonly instance: v.InstanceSchema<typeof BuilderExpectation, undefined>;
|
|
314
|
+
}>, v.ReadonlyAction<{
|
|
315
|
+
name: string;
|
|
316
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
317
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
318
|
+
name: string;
|
|
319
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
320
|
+
}>[]>]>], undefined>, v.MetadataAction<import("../..").BuilderRef | Readonly<{
|
|
321
|
+
type: "ref";
|
|
322
|
+
id: string;
|
|
323
|
+
name: string;
|
|
324
|
+
}> | readonly Readonly<{
|
|
325
|
+
name: string;
|
|
326
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
327
|
+
}>[], {
|
|
328
|
+
readonly refable: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
329
|
+
readonly name: v.StringSchema<undefined>;
|
|
330
|
+
readonly kind: v.PicklistSchema<["option", "component", "collection", "detail"], undefined>;
|
|
331
|
+
}, undefined>, v.MetadataAction<{
|
|
332
|
+
name: string;
|
|
333
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
334
|
+
}, {
|
|
335
|
+
readonly serialisable: typeof BuilderExpectation;
|
|
336
|
+
readonly instance: v.InstanceSchema<typeof BuilderExpectation, undefined>;
|
|
337
|
+
}>, v.ReadonlyAction<{
|
|
338
|
+
name: string;
|
|
339
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
340
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
341
|
+
name: string;
|
|
342
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
343
|
+
}>[]>]>;
|
|
344
|
+
}>]>;
|
|
345
|
+
}, undefined>, v.MetadataAction<{
|
|
346
|
+
expectations: import("../..").BuilderRef | Readonly<{
|
|
347
|
+
type: "ref";
|
|
348
|
+
id: string;
|
|
349
|
+
name: string;
|
|
350
|
+
}> | readonly Readonly<{
|
|
351
|
+
name: string;
|
|
352
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
353
|
+
}>[];
|
|
354
|
+
}, {
|
|
355
|
+
readonly serialisable: typeof BuilderComponentDetails;
|
|
356
|
+
readonly instance: v.InstanceSchema<typeof BuilderComponentDetails, undefined>;
|
|
357
|
+
}>, v.ReadonlyAction<{
|
|
358
|
+
expectations: import("../..").BuilderRef | Readonly<{
|
|
359
|
+
type: "ref";
|
|
360
|
+
id: string;
|
|
361
|
+
name: string;
|
|
362
|
+
}> | readonly Readonly<{
|
|
363
|
+
name: string;
|
|
364
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
365
|
+
}>[];
|
|
366
|
+
}>]>, v.GenericSchema], undefined>;
|
|
367
|
+
}>]>;
|
|
368
|
+
readonly gatePaths: v.OptionalSchema<v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
369
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
370
|
+
readonly id: v.StringSchema<undefined>;
|
|
371
|
+
readonly name: v.StringSchema<undefined>;
|
|
372
|
+
}, undefined>, v.ReadonlyAction<{
|
|
373
|
+
type: "ref";
|
|
374
|
+
id: string;
|
|
375
|
+
name: string;
|
|
376
|
+
}>]>, v.InstanceSchema<typeof import("../..").BuilderRef, undefined>, 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>, v.MetadataAction<readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
377
|
+
type: "ref";
|
|
378
|
+
id: string;
|
|
379
|
+
name: string;
|
|
380
|
+
}>, {
|
|
381
|
+
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)[])[]>]>;
|
|
382
|
+
}>]>, undefined>;
|
|
383
|
+
}, undefined>, v.MetadataAction<{
|
|
384
|
+
name: string;
|
|
385
|
+
payload: unknown;
|
|
386
|
+
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
387
|
+
type: "ref";
|
|
388
|
+
id: string;
|
|
389
|
+
name: string;
|
|
390
|
+
}> | undefined;
|
|
391
|
+
}, {
|
|
392
|
+
readonly serialisable: typeof import("..").BuilderComponent;
|
|
393
|
+
readonly instance: v.InstanceSchema<typeof import("..").BuilderComponent, undefined>;
|
|
394
|
+
}>, v.ReadonlyAction<{
|
|
395
|
+
name: string;
|
|
396
|
+
payload: unknown;
|
|
397
|
+
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
398
|
+
type: "ref";
|
|
399
|
+
id: string;
|
|
400
|
+
name: string;
|
|
401
|
+
}> | undefined;
|
|
402
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
403
|
+
name: string;
|
|
404
|
+
payload: unknown;
|
|
405
|
+
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
406
|
+
type: "ref";
|
|
407
|
+
id: string;
|
|
408
|
+
name: string;
|
|
409
|
+
}> | undefined;
|
|
410
|
+
}>[]>]>;
|
|
411
|
+
readonly collections: v.SchemaWithPipe<readonly [v.ArraySchema<v.GenericSchema<import("..").BuilderCollectionSerialised>, undefined>, v.ReadonlyAction<import("..").BuilderCollectionSerialised[]>]>;
|
|
412
|
+
readonly expectations: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
413
|
+
readonly name: v.StringSchema<undefined>;
|
|
414
|
+
readonly kind: v.PicklistSchema<["option", "component", "collection", "detail"], undefined>;
|
|
415
|
+
}, undefined>, v.MetadataAction<{
|
|
416
|
+
name: string;
|
|
417
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
418
|
+
}, {
|
|
419
|
+
readonly serialisable: typeof BuilderExpectation;
|
|
420
|
+
readonly instance: v.InstanceSchema<typeof BuilderExpectation, undefined>;
|
|
421
|
+
}>, v.ReadonlyAction<{
|
|
422
|
+
name: string;
|
|
423
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
424
|
+
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
425
|
+
name: string;
|
|
426
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
427
|
+
}>[]>]>;
|
|
428
|
+
}, undefined>, v.MetadataAction<{
|
|
429
|
+
readonly references: readonly Readonly<{
|
|
430
|
+
type: "ref";
|
|
431
|
+
id: string;
|
|
432
|
+
name: string;
|
|
433
|
+
}>[];
|
|
434
|
+
readonly options: readonly Readonly<{
|
|
435
|
+
name: string;
|
|
436
|
+
payload: unknown;
|
|
437
|
+
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
438
|
+
type: "ref";
|
|
439
|
+
id: string;
|
|
440
|
+
name: string;
|
|
441
|
+
}> | undefined;
|
|
442
|
+
}>[];
|
|
443
|
+
readonly components: readonly Readonly<{
|
|
444
|
+
name: string;
|
|
445
|
+
payload: unknown;
|
|
446
|
+
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
447
|
+
type: "ref";
|
|
448
|
+
id: string;
|
|
449
|
+
name: string;
|
|
450
|
+
}> | undefined;
|
|
451
|
+
}>[];
|
|
452
|
+
readonly collections: readonly import("..").BuilderCollectionSerialised[];
|
|
453
|
+
readonly expectations: readonly Readonly<{
|
|
454
|
+
name: string;
|
|
455
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
456
|
+
}>[];
|
|
457
|
+
}, {
|
|
458
|
+
readonly serialisable: typeof Builder;
|
|
459
|
+
readonly instance: v.InstanceSchema<typeof Builder, undefined>;
|
|
460
|
+
}>, v.ReadonlyAction<{
|
|
461
|
+
readonly references: readonly Readonly<{
|
|
462
|
+
type: "ref";
|
|
463
|
+
id: string;
|
|
464
|
+
name: string;
|
|
465
|
+
}>[];
|
|
466
|
+
readonly options: readonly Readonly<{
|
|
467
|
+
name: string;
|
|
468
|
+
payload: unknown;
|
|
469
|
+
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
470
|
+
type: "ref";
|
|
471
|
+
id: string;
|
|
472
|
+
name: string;
|
|
473
|
+
}> | undefined;
|
|
474
|
+
}>[];
|
|
475
|
+
readonly components: readonly Readonly<{
|
|
476
|
+
name: string;
|
|
477
|
+
payload: unknown;
|
|
478
|
+
gatePaths?: readonly (readonly (string | number)[])[] | import("../..").BuilderRef | Readonly<{
|
|
479
|
+
type: "ref";
|
|
480
|
+
id: string;
|
|
481
|
+
name: string;
|
|
482
|
+
}> | undefined;
|
|
483
|
+
}>[];
|
|
484
|
+
readonly collections: readonly import("..").BuilderCollectionSerialised[];
|
|
485
|
+
readonly expectations: readonly Readonly<{
|
|
486
|
+
name: string;
|
|
487
|
+
kind: "option" | "component" | "collection" | "detail";
|
|
488
|
+
}>[];
|
|
489
|
+
}>]>;
|
|
490
|
+
export type BuilderSerialised = v.InferOutput<typeof BuilderSerialisedSchema>;
|
|
491
|
+
export type BuilderStateOf<Input extends Refable<BuilderGeneric>> = Input extends Builder<infer State extends BuilderState> ? State : BuilderStateEmpty;
|
|
492
|
+
export type BuilderInstanceOf<Input extends BuilderGeneric> = Input extends Builder<infer State extends BuilderState> ? Prettify<State['model']> : never;
|
|
493
|
+
export type BuilderReference = Refable<BuilderGeneric>;
|
|
494
|
+
export type BuilderReferences = ReadonlyArray<Refable<BuilderGeneric>>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { check } from '../../check.js';
|
|
3
|
+
import { BuilderRefsSerialisedSchema } from '../../references.js';
|
|
4
|
+
import { serialisable } from '../../serialisable.js';
|
|
5
|
+
import { BuilderCollectionsSerialisedSchema } from '../collection/index.js';
|
|
6
|
+
import { BuilderComponentDetailsSchema, BuilderComponentsSerialisedSchema, componentDetails } from '../component/index.js';
|
|
7
|
+
import { BuilderExpectationsSerialisedSchema } from '../expectation.js';
|
|
8
|
+
import { BuilderOptionsSerialisedSchema } from '../option/index.js';
|
|
9
|
+
import { builderCollectionMethod, builderComponentMethod, builderOptionMethod } from './methods.js';
|
|
10
|
+
import { bindBuilder } from './parameter.js';
|
|
11
|
+
import { validateDuplicates, validatePaths } from './validate.js';
|
|
12
|
+
export class Builder {
|
|
13
|
+
references;
|
|
14
|
+
options;
|
|
15
|
+
components;
|
|
16
|
+
collections;
|
|
17
|
+
expectations;
|
|
18
|
+
id = crypto.randomUUID();
|
|
19
|
+
constructor(references = [], options = [], components = [], collections = [], expectations = []) {
|
|
20
|
+
this.references = references;
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.components = components;
|
|
23
|
+
this.collections = collections;
|
|
24
|
+
this.expectations = expectations;
|
|
25
|
+
validateDuplicates(this);
|
|
26
|
+
validatePaths(this);
|
|
27
|
+
}
|
|
28
|
+
get option() {
|
|
29
|
+
const method = builderOptionMethod();
|
|
30
|
+
const add = (name, payload) => {
|
|
31
|
+
return this.#next({ options: [...this.options, method(name, payload)] });
|
|
32
|
+
};
|
|
33
|
+
const when = (gatePaths, name, config) => {
|
|
34
|
+
return this.#next({ options: [...this.options, method.when(gatePaths, name, config)] });
|
|
35
|
+
};
|
|
36
|
+
return Object.assign(add, { when });
|
|
37
|
+
}
|
|
38
|
+
get component() {
|
|
39
|
+
const method = builderComponentMethod();
|
|
40
|
+
const add = (name, details) => {
|
|
41
|
+
const wrappedDetails = check.is(BuilderComponentDetailsSchema, details)
|
|
42
|
+
? details
|
|
43
|
+
: details != null
|
|
44
|
+
? componentDetails(details)
|
|
45
|
+
: details;
|
|
46
|
+
return this.#next({ components: [...this.components, method(name, wrappedDetails)] });
|
|
47
|
+
};
|
|
48
|
+
const when = (gatePaths, name, config) => {
|
|
49
|
+
return this.#next({
|
|
50
|
+
components: [...this.components, method.when(gatePaths, name, config)]
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
return Object.assign(add, { when });
|
|
54
|
+
}
|
|
55
|
+
get collection() {
|
|
56
|
+
const method = builderCollectionMethod();
|
|
57
|
+
const add = (name, payload) => {
|
|
58
|
+
return this.#next({ collections: [...this.collections, method(name, payload)] });
|
|
59
|
+
};
|
|
60
|
+
const when = (gatePaths, name, config) => {
|
|
61
|
+
return this.#next({
|
|
62
|
+
collections: [...this.collections, method.when(gatePaths, name, config)]
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
return Object.assign(add, { when });
|
|
66
|
+
}
|
|
67
|
+
expect(...expectations) {
|
|
68
|
+
return this.#next({ expectations: [...this.expectations, ...expectations] });
|
|
69
|
+
}
|
|
70
|
+
bind(bindings) {
|
|
71
|
+
return bindBuilder(this, bindings);
|
|
72
|
+
}
|
|
73
|
+
#next(patch) {
|
|
74
|
+
return new Builder(this.references, patch.options ?? this.options, patch.components ?? this.components, patch.collections ?? this.collections, patch.expectations ?? this.expectations);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export const BuilderSchema = v.instance(Builder);
|
|
78
|
+
export const BuilderSerialisedSchema = serialisable(Builder, v.object({
|
|
79
|
+
references: BuilderRefsSerialisedSchema,
|
|
80
|
+
options: BuilderOptionsSerialisedSchema,
|
|
81
|
+
components: BuilderComponentsSerialisedSchema,
|
|
82
|
+
collections: BuilderCollectionsSerialisedSchema,
|
|
83
|
+
expectations: BuilderExpectationsSerialisedSchema
|
|
84
|
+
}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BuilderGeneric, BuilderReferences, BuilderStateOf } from './builder';
|
|
2
|
+
import type { BuilderState, BuilderStateEmpty } from './state';
|
|
3
|
+
import { Builder } from './builder.js';
|
|
4
|
+
export declare function builders<const References extends BuilderReferences>(...builders: References): Builder<BuilderBuildersMerge<References>>;
|
|
5
|
+
export declare function mergeBuilderParts(parts: ReadonlyArray<unknown>): {
|
|
6
|
+
references: import("../..").BuilderRef[];
|
|
7
|
+
options: import("..").BuilderOption<string, import("../..").Refable<import("..").BuilderOptionPayload>, import("../..").Refable<readonly (readonly (string | number)[])[]>>[];
|
|
8
|
+
components: import("..").BuilderComponent<string, import("../..").Refable<import("..").BuilderComponentPayload>, import("../..").Refable<readonly (readonly (string | number)[])[]>>[];
|
|
9
|
+
collections: import("..").BuilderCollection<string, import("../..").Refable<import("..").BuilderCollectionPayload>, import("../..").Refable<readonly (readonly (string | number)[])[]>>[];
|
|
10
|
+
expectations: import("..").BuilderExpectation<string, unknown, "option" | "component" | "collection" | "detail">[];
|
|
11
|
+
};
|
|
12
|
+
export type BuilderBuildersMerge<References extends BuilderReferences> = References extends readonly [infer Head, ...infer Tail extends BuilderReferences] ? Head extends BuilderGeneric ? BuilderStateMerge<BuilderStateOf<Head>, BuilderBuildersMerge<Tail>> : BuilderBuildersMerge<Tail> : BuilderStateEmpty;
|
|
13
|
+
type BuilderStateMerge<Left extends BuilderState, Right extends BuilderState> = {
|
|
14
|
+
model: Left['model'] & Right['model'];
|
|
15
|
+
references: Left['references'] & Right['references'];
|
|
16
|
+
options: [...Left['options'], ...Right['options']];
|
|
17
|
+
components: [...Left['components'], ...Right['components']];
|
|
18
|
+
collections: [...Left['collections'], ...Right['collections']];
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { isRef } from '../../references.js';
|
|
3
|
+
import { Builder, BuilderSchema } from './builder.js';
|
|
4
|
+
export function builders(...builders) {
|
|
5
|
+
const references = builders.filter((payload) => isRef(payload));
|
|
6
|
+
const merged = mergeBuilderParts(builders);
|
|
7
|
+
return new Builder([...references, ...merged.references], merged.options, merged.components, merged.collections, merged.expectations);
|
|
8
|
+
}
|
|
9
|
+
export function mergeBuilderParts(parts) {
|
|
10
|
+
const instances = parts.filter((part) => v.is(BuilderSchema, part));
|
|
11
|
+
return {
|
|
12
|
+
references: instances.flatMap((builder) => [...builder.references]),
|
|
13
|
+
options: instances.flatMap((builder) => [...builder.options]),
|
|
14
|
+
components: instances.flatMap((builder) => [...builder.components]),
|
|
15
|
+
collections: instances.flatMap((builder) => [...builder.collections]),
|
|
16
|
+
expectations: instances.flatMap((builder) => [...builder.expectations])
|
|
17
|
+
};
|
|
18
|
+
}
|