@builder-builder/builder 0.0.13 → 0.0.14
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/cli.d.ts +2 -0
- package/dist/cli.js +53 -0
- package/dist/codegen/index.d.ts +7 -0
- package/dist/codegen/index.js +212 -0
- package/dist/codegen/template.d.ts +5 -0
- package/dist/codegen/template.js +17 -0
- package/dist/entities/index.d.ts +3 -3
- package/dist/entities/index.js +1 -1
- package/dist/entities/kind.d.ts +1 -1
- package/dist/entities/serialise.d.ts +554 -8
- package/dist/entities/serialise.js +5 -3
- package/dist/entities/ui/describe.d.ts +222 -8
- package/dist/entities/ui/describe.js +5 -5
- package/dist/entities/ui/index.d.ts +2 -0
- package/dist/entities/ui/index.js +1 -0
- package/dist/entities/ui/input.d.ts +334 -0
- package/dist/entities/ui/input.js +39 -0
- package/dist/entities/ui/page.d.ts +222 -8
- package/dist/entities/ui/page.js +5 -5
- package/dist/entities/ui/ui.d.ts +3 -3
- package/dist/entities/ui/ui.js +7 -4
- package/dist/entities/validated.d.ts +4 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/mappers/index.d.ts +3 -2
- package/dist/mappers/index.js +1 -1
- package/dist/mappers/render/index.d.ts +1 -1
- package/dist/mappers/render/pages.d.ts +8 -0
- package/dist/mappers/render/pages.js +2 -1
- package/dist/mappers/render/render.js +19 -3
- package/dist/mappers/resolve.d.ts +4 -4
- package/dist/mappers/variants/index.d.ts +2 -1
- package/dist/mappers/variants/index.js +2 -1
- package/dist/mappers/variants/variants.d.ts +5 -2
- package/dist/mappers/variants/variants.js +2 -2
- package/dist/validate/brand.d.ts +0 -7
- package/dist/validate/brand.js +5 -5
- package/dist/validate/builder.d.ts +2 -1
- package/dist/validate/builder.js +14 -12
- package/dist/validate/errors.d.ts +130 -0
- package/dist/validate/errors.js +141 -0
- package/dist/validate/expectations.d.ts +3 -10
- package/dist/validate/expectations.js +8 -10
- package/dist/validate/index.d.ts +8 -14
- package/dist/validate/index.js +4 -7
- package/dist/validate/instance.d.ts +2 -15
- package/dist/validate/instance.js +41 -40
- package/dist/validate/model.d.ts +4 -31
- package/dist/validate/model.js +157 -176
- package/dist/validate/resolve.d.ts +3 -15
- package/dist/validate/resolve.js +66 -69
- package/dist/validate/result.d.ts +1 -7
- package/dist/validate/result.js +1 -4
- package/dist/validate/ui.d.ts +4 -4
- package/dist/validate/ui.js +80 -62
- package/dist/validate/variants.d.ts +2 -53
- package/dist/validate/variants.js +83 -86
- package/package.json +12 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { BuilderPathSchema } from '../../paths.js';
|
|
3
|
+
import { paramable } from '../../references.js';
|
|
4
|
+
import { serialisable } from '../../serialisable.js';
|
|
5
|
+
export class BuilderUIInput {
|
|
6
|
+
type = 'input';
|
|
7
|
+
path;
|
|
8
|
+
displayName;
|
|
9
|
+
kind;
|
|
10
|
+
metadata;
|
|
11
|
+
constructor(path, displayName, kind, metadata) {
|
|
12
|
+
this.path = path;
|
|
13
|
+
this.displayName = displayName;
|
|
14
|
+
this.kind = kind;
|
|
15
|
+
this.metadata = metadata;
|
|
16
|
+
}
|
|
17
|
+
display(displayName) {
|
|
18
|
+
return new BuilderUIInput(this.path, displayName, this.kind, this.metadata);
|
|
19
|
+
}
|
|
20
|
+
as(kind) {
|
|
21
|
+
return new BuilderUIInput(this.path, this.displayName, kind, this.metadata);
|
|
22
|
+
}
|
|
23
|
+
meta(metadata) {
|
|
24
|
+
return new BuilderUIInput(this.path, this.displayName, this.kind, metadata);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function input(path) {
|
|
28
|
+
return new BuilderUIInput(path);
|
|
29
|
+
}
|
|
30
|
+
export const BuilderUIInputSchema = v.instance(BuilderUIInput);
|
|
31
|
+
export const BuilderUIInputMetadataSchema = v.pipe(v.record(v.string(), paramable(v.unknown())), v.readonly());
|
|
32
|
+
export const BuilderUIInputSerialisedSchema = serialisable(v.object({
|
|
33
|
+
type: v.literal('input'),
|
|
34
|
+
path: paramable(BuilderPathSchema),
|
|
35
|
+
displayName: v.optional(paramable(v.string())),
|
|
36
|
+
kind: v.optional(paramable(v.string())),
|
|
37
|
+
metadata: v.optional(paramable(BuilderUIInputMetadataSchema))
|
|
38
|
+
}));
|
|
39
|
+
export const BuilderUIInputsSerialisedSchema = v.pipe(v.array(paramable(BuilderUIInputSerialisedSchema)), v.readonly());
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { BuilderPaths } from '../../paths';
|
|
2
1
|
import type { Paramable } from '../../references';
|
|
2
|
+
import type { BuilderUIInputs } from './input';
|
|
3
3
|
import * as v from 'valibot';
|
|
4
|
-
export declare class BuilderUIPage<const Label extends Paramable<string> = Paramable<string>, const
|
|
4
|
+
export declare class BuilderUIPage<const Label extends Paramable<string> = Paramable<string>, const Inputs extends Paramable<BuilderUIInputs> = Paramable<BuilderUIInputs>> {
|
|
5
5
|
readonly type: "page";
|
|
6
6
|
readonly label: Label;
|
|
7
|
-
readonly
|
|
8
|
-
constructor(label: Label,
|
|
7
|
+
readonly inputs: Inputs;
|
|
8
|
+
constructor(label: Label, inputs: Inputs);
|
|
9
9
|
}
|
|
10
10
|
export declare const BuilderUIPageSchema: v.InstanceSchema<typeof BuilderUIPage, undefined>;
|
|
11
11
|
export declare const BuilderUIPageSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
@@ -25,7 +25,7 @@ export declare const BuilderUIPageSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
25
25
|
type: "ref";
|
|
26
26
|
id: string;
|
|
27
27
|
}>]>, v.StringSchema<undefined>], undefined>;
|
|
28
|
-
readonly
|
|
28
|
+
readonly inputs: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
29
29
|
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
30
30
|
readonly id: v.StringSchema<undefined>;
|
|
31
31
|
readonly name: v.StringSchema<undefined>;
|
|
@@ -39,7 +39,178 @@ export declare const BuilderUIPageSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
39
39
|
}, undefined>, v.ReadonlyAction<{
|
|
40
40
|
type: "ref";
|
|
41
41
|
id: string;
|
|
42
|
-
}>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.
|
|
42
|
+
}>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
43
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
44
|
+
readonly id: v.StringSchema<undefined>;
|
|
45
|
+
readonly name: v.StringSchema<undefined>;
|
|
46
|
+
}, undefined>, v.ReadonlyAction<{
|
|
47
|
+
type: "parameter";
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
51
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
52
|
+
readonly id: v.StringSchema<undefined>;
|
|
53
|
+
}, undefined>, v.ReadonlyAction<{
|
|
54
|
+
type: "ref";
|
|
55
|
+
id: string;
|
|
56
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
57
|
+
readonly type: v.LiteralSchema<"input", undefined>;
|
|
58
|
+
readonly path: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
59
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
60
|
+
readonly id: v.StringSchema<undefined>;
|
|
61
|
+
readonly name: v.StringSchema<undefined>;
|
|
62
|
+
}, undefined>, v.ReadonlyAction<{
|
|
63
|
+
type: "parameter";
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
67
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
68
|
+
readonly id: v.StringSchema<undefined>;
|
|
69
|
+
}, undefined>, v.ReadonlyAction<{
|
|
70
|
+
type: "ref";
|
|
71
|
+
id: string;
|
|
72
|
+
}>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
|
|
73
|
+
readonly displayName: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
74
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
75
|
+
readonly id: v.StringSchema<undefined>;
|
|
76
|
+
readonly name: v.StringSchema<undefined>;
|
|
77
|
+
}, undefined>, v.ReadonlyAction<{
|
|
78
|
+
type: "parameter";
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
82
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
83
|
+
readonly id: v.StringSchema<undefined>;
|
|
84
|
+
}, undefined>, v.ReadonlyAction<{
|
|
85
|
+
type: "ref";
|
|
86
|
+
id: string;
|
|
87
|
+
}>]>, v.StringSchema<undefined>], undefined>, undefined>;
|
|
88
|
+
readonly kind: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
89
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
90
|
+
readonly id: v.StringSchema<undefined>;
|
|
91
|
+
readonly name: v.StringSchema<undefined>;
|
|
92
|
+
}, undefined>, v.ReadonlyAction<{
|
|
93
|
+
type: "parameter";
|
|
94
|
+
id: string;
|
|
95
|
+
name: string;
|
|
96
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
97
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
98
|
+
readonly id: v.StringSchema<undefined>;
|
|
99
|
+
}, undefined>, v.ReadonlyAction<{
|
|
100
|
+
type: "ref";
|
|
101
|
+
id: string;
|
|
102
|
+
}>]>, v.StringSchema<undefined>], undefined>, undefined>;
|
|
103
|
+
readonly metadata: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
104
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
105
|
+
readonly id: v.StringSchema<undefined>;
|
|
106
|
+
readonly name: v.StringSchema<undefined>;
|
|
107
|
+
}, undefined>, v.ReadonlyAction<{
|
|
108
|
+
type: "parameter";
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
112
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
113
|
+
readonly id: v.StringSchema<undefined>;
|
|
114
|
+
}, undefined>, v.ReadonlyAction<{
|
|
115
|
+
type: "ref";
|
|
116
|
+
id: string;
|
|
117
|
+
}>]>, v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
118
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
119
|
+
readonly id: v.StringSchema<undefined>;
|
|
120
|
+
readonly name: v.StringSchema<undefined>;
|
|
121
|
+
}, undefined>, v.ReadonlyAction<{
|
|
122
|
+
type: "parameter";
|
|
123
|
+
id: string;
|
|
124
|
+
name: string;
|
|
125
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
126
|
+
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
127
|
+
readonly id: v.StringSchema<undefined>;
|
|
128
|
+
}, undefined>, v.ReadonlyAction<{
|
|
129
|
+
type: "ref";
|
|
130
|
+
id: string;
|
|
131
|
+
}>]>, v.UnknownSchema], undefined>, undefined>, v.ReadonlyAction<{
|
|
132
|
+
[x: string]: unknown;
|
|
133
|
+
}>]>], undefined>, undefined>;
|
|
134
|
+
}, undefined>, v.ReadonlyAction<{
|
|
135
|
+
type: "input";
|
|
136
|
+
path: readonly (string | number)[] | Readonly<{
|
|
137
|
+
type: "parameter";
|
|
138
|
+
id: string;
|
|
139
|
+
name: string;
|
|
140
|
+
}> | Readonly<{
|
|
141
|
+
type: "ref";
|
|
142
|
+
id: string;
|
|
143
|
+
}>;
|
|
144
|
+
displayName?: string | Readonly<{
|
|
145
|
+
type: "parameter";
|
|
146
|
+
id: string;
|
|
147
|
+
name: string;
|
|
148
|
+
}> | Readonly<{
|
|
149
|
+
type: "ref";
|
|
150
|
+
id: string;
|
|
151
|
+
}> | undefined;
|
|
152
|
+
kind?: string | Readonly<{
|
|
153
|
+
type: "parameter";
|
|
154
|
+
id: string;
|
|
155
|
+
name: string;
|
|
156
|
+
}> | Readonly<{
|
|
157
|
+
type: "ref";
|
|
158
|
+
id: string;
|
|
159
|
+
}> | undefined;
|
|
160
|
+
metadata?: Readonly<{
|
|
161
|
+
type: "parameter";
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
}> | Readonly<{
|
|
165
|
+
type: "ref";
|
|
166
|
+
id: string;
|
|
167
|
+
}> | Readonly<{
|
|
168
|
+
[x: string]: unknown;
|
|
169
|
+
}> | undefined;
|
|
170
|
+
}>]>], undefined>, undefined>, v.ReadonlyAction<(Readonly<{
|
|
171
|
+
type: "parameter";
|
|
172
|
+
id: string;
|
|
173
|
+
name: string;
|
|
174
|
+
}> | Readonly<{
|
|
175
|
+
type: "ref";
|
|
176
|
+
id: string;
|
|
177
|
+
}> | Readonly<{
|
|
178
|
+
type: "input";
|
|
179
|
+
path: readonly (string | number)[] | Readonly<{
|
|
180
|
+
type: "parameter";
|
|
181
|
+
id: string;
|
|
182
|
+
name: string;
|
|
183
|
+
}> | Readonly<{
|
|
184
|
+
type: "ref";
|
|
185
|
+
id: string;
|
|
186
|
+
}>;
|
|
187
|
+
displayName?: string | Readonly<{
|
|
188
|
+
type: "parameter";
|
|
189
|
+
id: string;
|
|
190
|
+
name: string;
|
|
191
|
+
}> | Readonly<{
|
|
192
|
+
type: "ref";
|
|
193
|
+
id: string;
|
|
194
|
+
}> | undefined;
|
|
195
|
+
kind?: string | Readonly<{
|
|
196
|
+
type: "parameter";
|
|
197
|
+
id: string;
|
|
198
|
+
name: string;
|
|
199
|
+
}> | Readonly<{
|
|
200
|
+
type: "ref";
|
|
201
|
+
id: string;
|
|
202
|
+
}> | undefined;
|
|
203
|
+
metadata?: Readonly<{
|
|
204
|
+
type: "parameter";
|
|
205
|
+
id: string;
|
|
206
|
+
name: string;
|
|
207
|
+
}> | Readonly<{
|
|
208
|
+
type: "ref";
|
|
209
|
+
id: string;
|
|
210
|
+
}> | Readonly<{
|
|
211
|
+
[x: string]: unknown;
|
|
212
|
+
}> | undefined;
|
|
213
|
+
}>)[]>]>], undefined>;
|
|
43
214
|
}, undefined>, v.ReadonlyAction<{
|
|
44
215
|
type: "page";
|
|
45
216
|
label: string | Readonly<{
|
|
@@ -50,13 +221,56 @@ export declare const BuilderUIPageSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
50
221
|
type: "ref";
|
|
51
222
|
id: string;
|
|
52
223
|
}>;
|
|
53
|
-
|
|
224
|
+
inputs: Readonly<{
|
|
54
225
|
type: "parameter";
|
|
55
226
|
id: string;
|
|
56
227
|
name: string;
|
|
57
228
|
}> | Readonly<{
|
|
58
229
|
type: "ref";
|
|
59
230
|
id: string;
|
|
60
|
-
}
|
|
231
|
+
}> | readonly (Readonly<{
|
|
232
|
+
type: "parameter";
|
|
233
|
+
id: string;
|
|
234
|
+
name: string;
|
|
235
|
+
}> | Readonly<{
|
|
236
|
+
type: "ref";
|
|
237
|
+
id: string;
|
|
238
|
+
}> | Readonly<{
|
|
239
|
+
type: "input";
|
|
240
|
+
path: readonly (string | number)[] | Readonly<{
|
|
241
|
+
type: "parameter";
|
|
242
|
+
id: string;
|
|
243
|
+
name: string;
|
|
244
|
+
}> | Readonly<{
|
|
245
|
+
type: "ref";
|
|
246
|
+
id: string;
|
|
247
|
+
}>;
|
|
248
|
+
displayName?: string | Readonly<{
|
|
249
|
+
type: "parameter";
|
|
250
|
+
id: string;
|
|
251
|
+
name: string;
|
|
252
|
+
}> | Readonly<{
|
|
253
|
+
type: "ref";
|
|
254
|
+
id: string;
|
|
255
|
+
}> | undefined;
|
|
256
|
+
kind?: string | Readonly<{
|
|
257
|
+
type: "parameter";
|
|
258
|
+
id: string;
|
|
259
|
+
name: string;
|
|
260
|
+
}> | Readonly<{
|
|
261
|
+
type: "ref";
|
|
262
|
+
id: string;
|
|
263
|
+
}> | undefined;
|
|
264
|
+
metadata?: Readonly<{
|
|
265
|
+
type: "parameter";
|
|
266
|
+
id: string;
|
|
267
|
+
name: string;
|
|
268
|
+
}> | Readonly<{
|
|
269
|
+
type: "ref";
|
|
270
|
+
id: string;
|
|
271
|
+
}> | Readonly<{
|
|
272
|
+
[x: string]: unknown;
|
|
273
|
+
}> | undefined;
|
|
274
|
+
}>)[];
|
|
61
275
|
}>]>;
|
|
62
276
|
export type BuilderUIPageSerialised = v.InferOutput<typeof BuilderUIPageSerialisedSchema>;
|
package/dist/entities/ui/page.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import { BuilderPathsSchema } from '../../paths.js';
|
|
3
2
|
import { paramable } from '../../references.js';
|
|
4
3
|
import { serialisable } from '../../serialisable.js';
|
|
4
|
+
import { BuilderUIInputsSerialisedSchema } from './input.js';
|
|
5
5
|
export class BuilderUIPage {
|
|
6
6
|
type = 'page';
|
|
7
7
|
label;
|
|
8
|
-
|
|
9
|
-
constructor(label,
|
|
8
|
+
inputs;
|
|
9
|
+
constructor(label, inputs) {
|
|
10
10
|
this.label = label;
|
|
11
|
-
this.
|
|
11
|
+
this.inputs = inputs;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export const BuilderUIPageSchema = v.instance(BuilderUIPage);
|
|
15
15
|
export const BuilderUIPageSerialisedSchema = serialisable(v.object({
|
|
16
16
|
type: v.literal('page'),
|
|
17
17
|
label: paramable(v.string()),
|
|
18
|
-
|
|
18
|
+
inputs: paramable(BuilderUIInputsSerialisedSchema)
|
|
19
19
|
}));
|
package/dist/entities/ui/ui.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { BuilderExpectation, BuilderExpectations, BuilderExpectationsSerial
|
|
|
3
3
|
import type { CollectionNamesOf } from '../collection/index';
|
|
4
4
|
import type { BuilderModel, BuilderModelGeneric, BuilderModelStateOf } from '../model/model';
|
|
5
5
|
import type { BuilderModelStateAsserted } from '../model/expectation';
|
|
6
|
-
import type {
|
|
6
|
+
import type { BuilderUIValidInputsOf } from './input';
|
|
7
7
|
import type { BuilderUIItems, BuilderUIItemsSerialised } from './pages';
|
|
8
8
|
import * as v from 'valibot';
|
|
9
9
|
export type BuilderUIs = ReadonlyArray<Paramable<BuilderUI>>;
|
|
@@ -16,8 +16,8 @@ export declare class BuilderUI<Model extends BuilderModelGeneric = BuilderModelG
|
|
|
16
16
|
readonly expectations: BuilderExpectations;
|
|
17
17
|
constructor(uis: BuilderUIs, items: BuilderUIItems, expectations: BuilderExpectations);
|
|
18
18
|
expect<const Exps extends readonly [BuilderExpectation, ...ReadonlyArray<BuilderExpectation>]>(...expectations: Exps): BuilderUI<BuilderModel<BuilderModelStateAsserted<BuilderModelStateOf<Model>, Exps>>>;
|
|
19
|
-
page(label: Paramable<string>,
|
|
20
|
-
describe(label: Paramable<string>,
|
|
19
|
+
page(label: Paramable<string>, inputs: Paramable<BuilderUIValidInputsOf<Model>>): BuilderUI<Model>;
|
|
20
|
+
describe(label: Paramable<string>, inputs: Paramable<BuilderUIValidInputsOf<Model>>): BuilderUI<Model>;
|
|
21
21
|
pages<const Name extends CollectionNamesOf<BuilderModelStateOf<Model>>>(name: Name, label: Paramable<string>, itemUI: Paramable<BuilderUI<BuilderModelGeneric>>): BuilderUI<Model>;
|
|
22
22
|
}
|
|
23
23
|
export declare const BuilderUISchema: v.InstanceSchema<typeof BuilderUI, undefined>;
|
package/dist/entities/ui/ui.js
CHANGED
|
@@ -21,11 +21,14 @@ export class BuilderUI {
|
|
|
21
21
|
...expectations
|
|
22
22
|
]);
|
|
23
23
|
}
|
|
24
|
-
page(label,
|
|
25
|
-
return new BuilderUI(this.uis, [...this.items, new BuilderUIPage(label,
|
|
24
|
+
page(label, inputs) {
|
|
25
|
+
return new BuilderUI(this.uis, [...this.items, new BuilderUIPage(label, inputs)], this.expectations);
|
|
26
26
|
}
|
|
27
|
-
describe(label,
|
|
28
|
-
return new BuilderUI(this.uis, [
|
|
27
|
+
describe(label, inputs) {
|
|
28
|
+
return new BuilderUI(this.uis, [
|
|
29
|
+
...this.items,
|
|
30
|
+
new BuilderUIDescribe(label, inputs)
|
|
31
|
+
], this.expectations);
|
|
29
32
|
}
|
|
30
33
|
pages(name, label, itemUI) {
|
|
31
34
|
const items = check.is(BuilderUISchema, itemUI) ? itemUI.items : itemUI;
|
|
@@ -4,9 +4,9 @@ import type { Prettify } from '../prettify';
|
|
|
4
4
|
import type { BuilderParameter, BuilderParameterSerialised, BuilderRef, BuilderRefSerialised } from '../references';
|
|
5
5
|
import type { BuilderSerialised } from './builder/index';
|
|
6
6
|
import type { BuilderCollectionConfigSerialised, BuilderCollectionSerialised, BuilderCollectionsSerialised } from './collection/index';
|
|
7
|
-
import type { BuilderComponentSerialised, BuilderComponentsSerialised } from './component/index';
|
|
7
|
+
import type { BuilderComponentDetailsSerialised, BuilderComponentSerialised, BuilderComponentsSerialised } from './component/index';
|
|
8
8
|
import type { BuilderModelSerialised } from './model/index';
|
|
9
|
-
import type { BuilderOptionSerialised, BuilderOptionsSerialised } from './option/index';
|
|
9
|
+
import type { BuilderOptionSerialised, BuilderOptionsSerialised, BuilderOptionValuesSerialised } from './option/index';
|
|
10
10
|
import type { BuilderUIDescribeSerialised, BuilderUIItemsSerialised, BuilderUIPageSerialised, BuilderUISerialised } from './ui/index';
|
|
11
11
|
export type Validated<Input> = Input extends BuilderComponentVariants | BuilderInstance | BuilderModelSerialised | BuilderSerialised | BuilderUISerialised ? Validate<Input> & BuilderValidatedBrand : Validate<Input>;
|
|
12
12
|
type Validate<Input> = Input extends BuilderParameter<string> | BuilderParameterSerialised | BuilderRef | BuilderRefSerialised ? never : Input extends ReadonlyArray<unknown> ? ValidatedTuple<Input> : Input extends object ? {
|
|
@@ -24,8 +24,10 @@ export type BuilderInstancesValidated = Prettify<Validated<BuilderInstances>>;
|
|
|
24
24
|
export type BuilderComponentVariantsValidated = Prettify<Validated<BuilderComponentVariants>>;
|
|
25
25
|
export type BuilderOptionValidated = Prettify<Validated<BuilderOptionSerialised>>;
|
|
26
26
|
export type BuilderOptionsValidated = Prettify<Validated<BuilderOptionsSerialised>>;
|
|
27
|
+
export type BuilderOptionValuesValidated = Prettify<Validated<BuilderOptionValuesSerialised>>;
|
|
27
28
|
export type BuilderComponentValidated = Prettify<Validated<BuilderComponentSerialised>>;
|
|
28
29
|
export type BuilderComponentsValidated = Prettify<Validated<BuilderComponentsSerialised>>;
|
|
30
|
+
export type BuilderComponentDetailsValidated = Prettify<Validated<BuilderComponentDetailsSerialised>>;
|
|
29
31
|
export type BuilderCollectionValidated = Prettify<Validated<BuilderCollectionSerialised>>;
|
|
30
32
|
export type BuilderCollectionsValidated = Prettify<Validated<BuilderCollectionsSerialised>>;
|
|
31
33
|
export type BuilderCollectionConfigValidated = Prettify<Validated<BuilderCollectionConfigSerialised>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export type { BB, BBOptions } from './bb';
|
|
2
|
-
export type { BuilderBindings, BuilderBindingsSerialised, BuilderCollection, BuilderCollectionConfig, BuilderCollectionConfigSerialised, BuilderCollections, BuilderCollectionSerialised, BuilderCollectionsSerialised, BuilderCollectionWhen, BuilderCollectionWhenSerialised, BuilderComponent, BuilderComponentDetails, BuilderComponentDetailsSerialised, BuilderComponentField, BuilderComponentFields, BuilderComponentFieldSerialised, BuilderComponentFieldsSerialised, BuilderComponentFieldValueType, BuilderComponents, BuilderComponentSerialised, BuilderComponentsSerialised, BuilderComponentWhen, BuilderComponentWhenSerialised, BuilderDescription, BuilderDescriptionItem, BuilderEntityKind, BuilderEntitySerialised, BuilderExpectation, BuilderExpectationKind, BuilderExpectations, BuilderExpectationSerialised, BuilderExpectationsSerialised, BuilderInstanceOf, BuilderModel, BuilderModels, BuilderModelSerialised, BuilderModelValidated, BuilderOption, BuilderOptions, BuilderOptionSerialised, BuilderOptionsSerialised, BuilderOptionValues, BuilderOptionValuesSerialised, BuilderOptionWhen, BuilderOptionWhenSerialised, BuilderRefEntities, BuilderRefEntity, BuilderSelectType, BuilderSelectTypeLabels, BuilderSelectTypeSerialised, BuilderSelectTypeValues, BuilderSerialised, BuilderToggleType, BuilderToggleTypeSerialised, BuilderToggleValueType, BuilderUI, BuilderUIDescribe, BuilderUIDescribeSerialised, BuilderUIItem, BuilderUIItems, BuilderUIItemsSerialised, BuilderUIPage, BuilderUIPages, BuilderUIPageSerialised, BuilderUIPagesSerialised, BuilderUIs, BuilderUIsSerialised, BuilderUISerialised, BuilderUIValidated, BuilderValidated, BuilderComponentVariantsValidated, BuilderInstanceValidated, BuilderEnableConfig, BuilderMatchConfig, BuilderMatchSelectMap, BuilderUnlessConfig, BuilderWhen, BuilderWhenConfig, BuilderWhenSerialised } from './entities/index';
|
|
2
|
+
export type { BuilderBindings, BuilderBindingsSerialised, BuilderCollection, BuilderCollectionConfig, BuilderCollectionConfigSerialised, BuilderCollections, BuilderCollectionSerialised, BuilderCollectionsSerialised, BuilderCollectionWhen, BuilderCollectionWhenSerialised, BuilderComponent, BuilderComponentDetails, BuilderComponentDetailsSerialised, BuilderComponentField, BuilderComponentFields, BuilderComponentFieldSerialised, BuilderComponentFieldsSerialised, BuilderComponentFieldValueType, BuilderComponents, BuilderComponentSerialised, BuilderComponentsSerialised, BuilderComponentWhen, BuilderComponentWhenSerialised, BuilderDescription, BuilderDescriptionItem, BuilderEntityKind, BuilderEntitySerialised, BuilderExpectation, BuilderExpectationKind, BuilderExpectations, BuilderExpectationSerialised, BuilderExpectationsSerialised, BuilderInstanceOf, BuilderModel, BuilderModels, BuilderModelSerialised, BuilderModelValidated, BuilderOption, BuilderOptions, BuilderOptionSerialised, BuilderOptionsSerialised, BuilderOptionValues, BuilderOptionValuesSerialised, BuilderOptionWhen, BuilderOptionWhenSerialised, BuilderRefEntities, BuilderRefEntity, BuilderSelectType, BuilderSelectTypeLabels, BuilderSelectTypeSerialised, BuilderSelectTypeValues, BuilderSerialised, BuilderToggleType, BuilderToggleTypeSerialised, BuilderToggleValueType, BuilderUI, BuilderUIDescribe, BuilderUIDescribeSerialised, BuilderUIInput, BuilderUIInputMetadata, BuilderUIInputMetadataSerialised, BuilderUIInputs, BuilderUIInputsSerialised, BuilderUIInputSerialised, BuilderUIItem, BuilderUIItems, BuilderUIItemsSerialised, BuilderUIPage, BuilderUIPages, BuilderUIPageSerialised, BuilderUIPagesSerialised, BuilderUIs, BuilderUIsSerialised, BuilderUISerialised, BuilderUIValidated, BuilderValidated, BuilderComponentVariantsValidated, BuilderInstanceValidated, BuilderEnableConfig, BuilderMatchConfig, BuilderMatchSelectMap, BuilderUnlessConfig, BuilderWhen, BuilderWhenConfig, BuilderWhenSerialised } from './entities/index';
|
|
3
3
|
export type { BuilderEnvironment } from './environment';
|
|
4
4
|
export type { BuilderError, BuilderErrorBase, BuilderErrorLocation, BuilderErrors } from './exception';
|
|
5
|
-
export type { BuilderComponentVariantsValidationResult, BuilderErrorDuplicateName, BuilderErrorInvalidCollection, BuilderErrorInvalidCollectionBounds, BuilderErrorInvalidDetail, BuilderErrorInvalidInput, BuilderErrorInvalidOption, BuilderErrorInvalidPath, BuilderErrorInvalidPathReason, BuilderErrorInvalidSelectMapKey, BuilderErrorInvalidVariant, BuilderErrorMissingComponent, BuilderErrorMissingDetail, BuilderErrorMissingReference, BuilderErrorMissingVariant, BuilderErrorUnboundParameter, BuilderErrorUnexpectedComponent, BuilderErrorUnexpectedDetail, BuilderErrorUnmetExpectation, BuilderErrorUnvalidated, BuilderInstanceValidationResult, BuilderModelValidationResult, BuilderOrder, BuilderRenderOption, BuilderRenderOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderResult, BuilderRenderUpdate, BuilderUIValidationResult, BuilderValidationResult, BuilderVariantsValidationOptions } from './mappers/index';
|
|
5
|
+
export type { BuilderComponentVariantsValidationResult, BuilderErrorDuplicateName, BuilderErrorInvalidCollection, BuilderErrorInvalidCollectionBounds, BuilderErrorInvalidDetail, BuilderErrorInvalidInput, BuilderErrorInvalidOption, BuilderErrorInvalidPath, BuilderErrorInvalidPathReason, BuilderErrorInvalidSelectMapKey, BuilderErrorInvalidVariant, BuilderErrorMissingComponent, BuilderErrorMissingDetail, BuilderErrorMissingReference, BuilderErrorMissingVariant, BuilderErrorUnboundParameter, BuilderErrorUnexpectedComponent, BuilderErrorUnexpectedDetail, BuilderErrorUnmetExpectation, BuilderErrorUnvalidated, BuilderInstanceValidationResult, BuilderModelValidationResult, BuilderOrder, BuilderRenderMetadata, BuilderRenderOption, BuilderRenderOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderResult, BuilderRenderUpdate, BuilderUIValidationResult, BuilderValidationResult, BuilderVariantsValidationOptions } from './mappers/index';
|
|
6
6
|
export type { BuilderComponentVariants, BuilderInstance, BuilderInstanceInput, BuilderInstances, BuilderVariant, BuilderVariants } from './instance';
|
|
7
7
|
export type { BuilderPath, BuilderPaths } from './paths';
|
|
8
8
|
export type { BuilderPrimitive, BuilderPrimitives } from './primitive';
|
|
9
9
|
export type { BuilderParameter, BuilderParameterSerialised, BuilderRef, Paramable, ParamableSerialised } from './references';
|
|
10
10
|
export { bb } from './bb.js';
|
|
11
|
-
export { Builder, builder, detailBoolean, detailNumber, detailString, model, parameter, ref, select, serialise, toggleBoolean, toggleNumber, toggleString } from './entities/index.js';
|
|
11
|
+
export { Builder, builder, detailBoolean, detailNumber, detailString, input, model, parameter, ref, select, serialise, toggleBoolean, toggleNumber, toggleString } from './entities/index.js';
|
|
12
12
|
export { BuilderException } from './exception.js';
|
|
13
13
|
export { ordinal } from './mappers/index.js';
|
|
14
14
|
import { collectionConfig, collectionExpectation, componentDetails, componentExpectation, optionExpectation, uis } from './entities/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { bb } from './bb.js';
|
|
2
|
-
export { Builder, builder, detailBoolean, detailNumber, detailString, model, parameter, ref, select, serialise, toggleBoolean, toggleNumber, toggleString } from './entities/index.js';
|
|
2
|
+
export { Builder, builder, detailBoolean, detailNumber, detailString, input, model, parameter, ref, select, serialise, toggleBoolean, toggleNumber, toggleString } from './entities/index.js';
|
|
3
3
|
export { BuilderException } from './exception.js';
|
|
4
4
|
export { ordinal } from './mappers/index.js';
|
|
5
5
|
import { collectionConfig, collectionExpectation, collectionWhen, componentDetails, componentExpectation, componentWhen, optionExpectation, optionWhen, uis } from './entities/index.js';
|
package/dist/mappers/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export type { BuilderComponentVariantsValidationResult, BuilderErrorDuplicateName, BuilderErrorInvalidCollection, BuilderErrorInvalidCollectionBounds, BuilderErrorInvalidDetail, BuilderErrorInvalidInput, BuilderErrorInvalidOption, BuilderErrorInvalidPath, BuilderErrorInvalidPathReason, BuilderErrorInvalidSelectMapKey, BuilderErrorInvalidVariant, BuilderErrorMissingComponent, BuilderErrorMissingDetail, BuilderErrorMissingReference, BuilderErrorMissingVariant, BuilderErrorUnboundParameter, BuilderErrorUnexpectedComponent, BuilderErrorUnexpectedDetail, BuilderErrorUnmetExpectation, BuilderErrorUnvalidated, BuilderInstanceValidationResult, BuilderModelValidationResult, BuilderUIValidationResult, BuilderValidationResult, BuilderVariantsValidationOptions } from '../validate/index';
|
|
2
2
|
export type { BuilderOrder } from './order';
|
|
3
|
-
export type { BuilderRenderOption, BuilderRenderOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderResult, BuilderRenderUpdate } from './render/index';
|
|
3
|
+
export type { BuilderRenderMetadata, BuilderRenderOption, BuilderRenderOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderResult, BuilderRenderUpdate } from './render/index';
|
|
4
4
|
export { assertValidated, validateBuilder, validateInstance, validateModel, validateUI, validateVariants } from '../validate/index.js';
|
|
5
|
+
export type { BuilderOptionGraph } from './variants/index.js';
|
|
5
6
|
export { createInstance } from './instance.js';
|
|
6
|
-
export { createVariants } from './variants/index.js';
|
|
7
|
+
export { createVariants, optionGraph, variantsFor } from './variants/index.js';
|
|
7
8
|
export { order } from './order.js';
|
|
8
9
|
export { ordinal, render } from './render/index.js';
|
|
9
10
|
export { resolveCollection, resolveComponent, resolveOption } from './resolve.js';
|
package/dist/mappers/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { assertValidated, validateBuilder, validateInstance, validateModel, validateUI, validateVariants } from '../validate/index.js';
|
|
2
2
|
export { createInstance } from './instance.js';
|
|
3
|
-
export { createVariants } from './variants/index.js';
|
|
3
|
+
export { createVariants, optionGraph, variantsFor } from './variants/index.js';
|
|
4
4
|
export { order } from './order.js';
|
|
5
5
|
export { ordinal, render } from './render/index.js';
|
|
6
6
|
export { resolveCollection, resolveComponent, resolveOption } from './resolve.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { BuilderRenderOption, BuilderRenderOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderUpdate } from './pages';
|
|
1
|
+
export type { BuilderRenderMetadata, BuilderRenderOption, BuilderRenderOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderUpdate } from './pages';
|
|
2
2
|
export type { BuilderRenderResult } from './render';
|
|
3
3
|
export { render } from './render.js';
|
|
4
4
|
export { ordinal } from './ordinal.js';
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { BuilderOptionValuesSerialised } from '../../entities/index';
|
|
2
2
|
import type { BuilderPrimitive } from '../../primitive';
|
|
3
3
|
import type { BuilderInstance } from '../../instance';
|
|
4
|
+
import * as v from 'valibot';
|
|
4
5
|
export type BuilderRenderUpdate = (model: BuilderInstance, primitive: BuilderPrimitive) => BuilderInstance;
|
|
6
|
+
export declare const BuilderRenderMetadataSchema: v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, v.ReadonlyAction<{
|
|
7
|
+
[x: string]: unknown;
|
|
8
|
+
}>]>;
|
|
9
|
+
export type BuilderRenderMetadata = v.InferOutput<typeof BuilderRenderMetadataSchema>;
|
|
5
10
|
export type BuilderRenderOption = Readonly<{
|
|
6
11
|
name: string;
|
|
7
12
|
value: BuilderPrimitive;
|
|
8
13
|
update: BuilderRenderUpdate;
|
|
9
14
|
option: BuilderOptionValuesSerialised;
|
|
15
|
+
displayName?: string;
|
|
16
|
+
kind?: string;
|
|
17
|
+
metadata?: BuilderRenderMetadata;
|
|
10
18
|
}>;
|
|
11
19
|
export type BuilderRenderOptions = ReadonlyArray<BuilderRenderOption>;
|
|
12
20
|
export type BuilderRenderPage = Readonly<{
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export const BuilderRenderMetadataSchema = v.pipe(v.record(v.string(), v.unknown()), v.readonly());
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BuilderRenderMetadataSchema } from './pages.js';
|
|
1
2
|
import * as v from 'valibot';
|
|
2
3
|
import { check } from '../../check.js';
|
|
3
4
|
import { BuilderInstancesSchema } from '../../instance.js';
|
|
@@ -37,7 +38,8 @@ export function render(builder, instance, refs = []) {
|
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
function emitPage(page, model, collectionPath, labelContext, currentInstance) {
|
|
40
|
-
const options = page.
|
|
41
|
+
const options = page.inputs.flatMap((input) => {
|
|
42
|
+
const { path } = input;
|
|
41
43
|
const found = resolvePath(model, currentInstance, path, refs);
|
|
42
44
|
if (found == null) {
|
|
43
45
|
return [];
|
|
@@ -49,7 +51,10 @@ export function render(builder, instance, refs = []) {
|
|
|
49
51
|
name: found.name,
|
|
50
52
|
option: found.payload,
|
|
51
53
|
value: found.value,
|
|
52
|
-
update: (updateInstance, updateValue) => createInstance(builder, setPath(updateInstance, fullPath, updateValue), refs)
|
|
54
|
+
update: (updateInstance, updateValue) => createInstance(builder, setPath(updateInstance, fullPath, updateValue), refs),
|
|
55
|
+
displayName: input.displayName && composeString(input.displayName, 'displayName'),
|
|
56
|
+
kind: input.kind && composeString(input.kind, 'kind'),
|
|
57
|
+
metadata: input.metadata && composeMetadata(input.metadata)
|
|
53
58
|
}
|
|
54
59
|
];
|
|
55
60
|
});
|
|
@@ -60,7 +65,8 @@ export function render(builder, instance, refs = []) {
|
|
|
60
65
|
}
|
|
61
66
|
function emitDescribe(describe, model, labelContext, currentInstance) {
|
|
62
67
|
const composedLabel = composeLabel(describe.label, labelContext);
|
|
63
|
-
const values = describe.
|
|
68
|
+
const values = describe.inputs.flatMap((input) => {
|
|
69
|
+
const { path } = input;
|
|
64
70
|
const found = resolvePath(model, currentInstance, path, refs);
|
|
65
71
|
if (found?.value == null) {
|
|
66
72
|
return [];
|
|
@@ -84,6 +90,16 @@ export function render(builder, instance, refs = []) {
|
|
|
84
90
|
}
|
|
85
91
|
return `${labelContext.join(', ')}, ${resolved}`;
|
|
86
92
|
}
|
|
93
|
+
function composeString(value, fieldLabel) {
|
|
94
|
+
const resolved = resolveRef(value, refs);
|
|
95
|
+
check.assert(v.string(), resolved, `Input ${fieldLabel} did not resolve to a string! ❌`);
|
|
96
|
+
return resolved;
|
|
97
|
+
}
|
|
98
|
+
function composeMetadata(value) {
|
|
99
|
+
const resolved = resolveRef(value, refs);
|
|
100
|
+
check.assert(BuilderRenderMetadataSchema, resolved, 'Input metadata did not resolve to an object! ❌');
|
|
101
|
+
return Object.fromEntries(Object.entries(resolved).map(([key, entry]) => [key, resolveRef(entry, refs)]));
|
|
102
|
+
}
|
|
87
103
|
function findCollection(model, instance, collectionName) {
|
|
88
104
|
const entry = model.collections.find((candidate) => candidate.name === collectionName);
|
|
89
105
|
return entry == null ? null : resolveCollection(entry, model, instance, refs);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { BuilderCollectionConfigValidated, BuilderCollectionValidated,
|
|
1
|
+
import type { BuilderCollectionConfigValidated, BuilderCollectionValidated, BuilderComponentDetailsValidated, BuilderComponentValidated, BuilderModelValidated, BuilderOptionValidated, BuilderOptionValuesValidated, BuilderRefEntities } from '../entities/index';
|
|
2
2
|
import type { BuilderInstance } from '../instance';
|
|
3
3
|
import type { BuilderPath } from '../paths';
|
|
4
|
-
export declare function resolveOption(option: BuilderOptionValidated, model: BuilderModelValidated, instance: unknown, refs?: BuilderRefEntities):
|
|
5
|
-
export declare function resolveComponent(component: BuilderComponentValidated, model: BuilderModelValidated, instance: unknown, refs?: BuilderRefEntities):
|
|
4
|
+
export declare function resolveOption(option: BuilderOptionValidated, model: BuilderModelValidated, instance: unknown, refs?: BuilderRefEntities): BuilderOptionValuesValidated | null;
|
|
5
|
+
export declare function resolveComponent(component: BuilderComponentValidated, model: BuilderModelValidated, instance: unknown, refs?: BuilderRefEntities): BuilderComponentDetailsValidated | null;
|
|
6
6
|
export declare function resolveCollection(collection: BuilderCollectionValidated, model: BuilderModelValidated, instance: unknown, refs?: BuilderRefEntities): BuilderCollectionConfigValidated | null;
|
|
7
7
|
export declare function resolveRef(value: unknown, refs: BuilderRefEntities): unknown;
|
|
8
8
|
export type ResolvedPath = {
|
|
9
9
|
readonly name: string;
|
|
10
|
-
readonly payload:
|
|
10
|
+
readonly payload: BuilderOptionValuesValidated;
|
|
11
11
|
readonly value: unknown;
|
|
12
12
|
};
|
|
13
13
|
export declare function resolvePath(model: BuilderModelValidated, instance: unknown, path: BuilderPath, refs?: BuilderRefEntities): ResolvedPath | null;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { BuilderOptionGraph } from './option-graph.js';
|
|
2
|
+
export { createVariants, optionGraph, variantsFor } from './variants.js';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { BuilderOptionGraph } from './option-graph.js';
|
|
2
|
+
export { createVariants, optionGraph, variantsFor } from './variants.js';
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type { BuilderModelValidated, BuilderValidated } from '../../entities/index';
|
|
2
|
-
import type { BuilderComponentVariants } from '../../instance';
|
|
1
|
+
import type { BuilderCollectionValidated, BuilderComponentValidated, BuilderModelValidated, BuilderValidated } from '../../entities/index';
|
|
2
|
+
import type { BuilderComponentVariants, BuilderInstances } from '../../instance';
|
|
3
|
+
import { BuilderOptionGraph } from './option-graph.js';
|
|
3
4
|
export declare function createVariants(entity: BuilderValidated | BuilderModelValidated): BuilderComponentVariants;
|
|
5
|
+
export declare function optionGraph(model: BuilderModelValidated): BuilderOptionGraph;
|
|
6
|
+
export declare function variantsFor(entity: BuilderComponentValidated | BuilderCollectionValidated, options: BuilderOptionGraph): BuilderInstances;
|
|
@@ -24,10 +24,10 @@ function buildVariants(model) {
|
|
|
24
24
|
]))
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function optionGraph(model) {
|
|
27
|
+
export function optionGraph(model) {
|
|
28
28
|
return model.options.reduce((graph, option) => graph.add(option, model), new BuilderOptionGraph());
|
|
29
29
|
}
|
|
30
|
-
function variantsFor(entity, options) {
|
|
30
|
+
export function variantsFor(entity, options) {
|
|
31
31
|
const keys = new Set(dependencyKeys(entity.payload, entity.paths));
|
|
32
32
|
const graphPaths = Array.from(keys)
|
|
33
33
|
.map((key) => options.get(key))
|
package/dist/validate/brand.d.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import type { BuilderErrorLocation } from '../exception';
|
|
2
1
|
declare const VALIDATED: unique symbol;
|
|
3
2
|
export type BuilderValidatedBrand = {
|
|
4
3
|
readonly [VALIDATED]: true;
|
|
5
4
|
};
|
|
6
|
-
export declare function builderErrorUnvalidated(value: unknown, location?: BuilderErrorLocation): {
|
|
7
|
-
value: unknown;
|
|
8
|
-
kind: "unvalidated";
|
|
9
|
-
location: BuilderErrorLocation;
|
|
10
|
-
};
|
|
11
|
-
export type BuilderErrorUnvalidated = ReturnType<typeof builderErrorUnvalidated>;
|
|
12
5
|
export declare function validate<Input extends object>(value: Input): Input & BuilderValidatedBrand;
|
|
13
6
|
export declare function assertValidated<Input>(value: Input): asserts value is Input & BuilderValidatedBrand;
|
|
14
7
|
export {};
|
package/dist/validate/brand.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuilderException } from '../exception.js';
|
|
2
|
+
import { BuilderValidateErrors } from './errors.js';
|
|
2
3
|
const VALIDATED = Symbol('builder.validated');
|
|
3
|
-
export function builderErrorUnvalidated(value, location = []) {
|
|
4
|
-
return { ...builderError('unvalidated', location), value };
|
|
5
|
-
}
|
|
6
4
|
export function validate(value) {
|
|
7
5
|
// Descriptor flags chosen for Svelte 5 `$state` proxy compatibility — `$state`
|
|
8
6
|
// rejects any property that isn't writable, configurable, and enumerable.
|
|
@@ -18,6 +16,8 @@ export function validate(value) {
|
|
|
18
16
|
}
|
|
19
17
|
export function assertValidated(value) {
|
|
20
18
|
if (typeof value !== 'object' || value === null || !(VALIDATED in value)) {
|
|
21
|
-
|
|
19
|
+
const errors = new BuilderValidateErrors();
|
|
20
|
+
errors.unvalidated(value);
|
|
21
|
+
throw new BuilderException(errors.errors);
|
|
22
22
|
}
|
|
23
23
|
}
|