@builder-builder/builder 0.0.13 → 0.0.15

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.
Files changed (96) hide show
  1. package/dist/bb.d.ts +3 -1
  2. package/dist/bb.js +6 -1
  3. package/dist/check.d.ts +2 -2
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.js +53 -0
  6. package/dist/codegen/index.d.ts +7 -0
  7. package/dist/codegen/index.js +212 -0
  8. package/dist/codegen/template.d.ts +5 -0
  9. package/dist/codegen/template.js +17 -0
  10. package/dist/entities/builder/builder.d.ts +11 -1
  11. package/dist/entities/builder/builder.js +22 -6
  12. package/dist/entities/collection/collection.d.ts +7 -1
  13. package/dist/entities/collection/collection.js +9 -2
  14. package/dist/entities/collection/config.d.ts +6 -1
  15. package/dist/entities/collection/config.js +9 -2
  16. package/dist/entities/component/component.d.ts +41 -1
  17. package/dist/entities/component/component.js +9 -2
  18. package/dist/entities/component/details.d.ts +11 -2
  19. package/dist/entities/component/details.js +9 -2
  20. package/dist/entities/component/field.d.ts +10 -1
  21. package/dist/entities/component/field.js +13 -3
  22. package/dist/entities/index.d.ts +7 -3
  23. package/dist/entities/index.js +3 -1
  24. package/dist/entities/kind.d.ts +1 -1
  25. package/dist/entities/model/model.d.ts +5 -1
  26. package/dist/entities/model/model.js +10 -3
  27. package/dist/entities/model/models.js +9 -5
  28. package/dist/entities/option/option.d.ts +41 -1
  29. package/dist/entities/option/option.js +9 -2
  30. package/dist/entities/option/select.d.ts +7 -1
  31. package/dist/entities/option/select.js +17 -6
  32. package/dist/entities/option/toggle.d.ts +7 -1
  33. package/dist/entities/option/toggle.js +16 -4
  34. package/dist/entities/option/values.d.ts +6 -0
  35. package/dist/entities/pricing.d.ts +64 -0
  36. package/dist/entities/pricing.js +48 -0
  37. package/dist/entities/serialise.d.ts +632 -8
  38. package/dist/entities/serialise.js +33 -12
  39. package/dist/entities/tags.d.ts +3 -0
  40. package/dist/entities/tags.js +2 -0
  41. package/dist/entities/ui/describe.d.ts +231 -8
  42. package/dist/entities/ui/describe.js +12 -5
  43. package/dist/entities/ui/index.d.ts +2 -0
  44. package/dist/entities/ui/index.js +1 -0
  45. package/dist/entities/ui/input.d.ts +343 -0
  46. package/dist/entities/ui/input.js +51 -0
  47. package/dist/entities/ui/page.d.ts +231 -8
  48. package/dist/entities/ui/page.js +12 -5
  49. package/dist/entities/ui/pages.d.ts +5 -1
  50. package/dist/entities/ui/pages.js +9 -2
  51. package/dist/entities/ui/ui.d.ts +9 -4
  52. package/dist/entities/ui/ui.js +29 -11
  53. package/dist/entities/validated.d.ts +7 -3
  54. package/dist/exception.d.ts +2 -2
  55. package/dist/index.d.ts +3 -3
  56. package/dist/index.js +1 -1
  57. package/dist/instance.d.ts +9 -0
  58. package/dist/instance.js +3 -1
  59. package/dist/mappers/index.d.ts +6 -4
  60. package/dist/mappers/index.js +3 -2
  61. package/dist/mappers/pricing.d.ts +3 -0
  62. package/dist/mappers/pricing.js +101 -0
  63. package/dist/mappers/render/index.d.ts +1 -1
  64. package/dist/mappers/render/pages.d.ts +8 -0
  65. package/dist/mappers/render/pages.js +2 -1
  66. package/dist/mappers/render/render.js +19 -3
  67. package/dist/mappers/resolve.d.ts +4 -4
  68. package/dist/mappers/variants/index.d.ts +2 -1
  69. package/dist/mappers/variants/index.js +2 -1
  70. package/dist/mappers/variants/variants.d.ts +5 -2
  71. package/dist/mappers/variants/variants.js +2 -2
  72. package/dist/validate/brand.d.ts +0 -7
  73. package/dist/validate/brand.js +5 -5
  74. package/dist/validate/builder.d.ts +2 -1
  75. package/dist/validate/builder.js +19 -13
  76. package/dist/validate/errors.d.ts +138 -0
  77. package/dist/validate/errors.js +148 -0
  78. package/dist/validate/expectations.d.ts +3 -10
  79. package/dist/validate/expectations.js +8 -10
  80. package/dist/validate/index.d.ts +10 -14
  81. package/dist/validate/index.js +5 -7
  82. package/dist/validate/instance.d.ts +2 -15
  83. package/dist/validate/instance.js +41 -40
  84. package/dist/validate/model.d.ts +4 -31
  85. package/dist/validate/model.js +157 -176
  86. package/dist/validate/pricing.d.ts +6 -0
  87. package/dist/validate/pricing.js +71 -0
  88. package/dist/validate/resolve.d.ts +3 -15
  89. package/dist/validate/resolve.js +66 -69
  90. package/dist/validate/result.d.ts +1 -7
  91. package/dist/validate/result.js +1 -4
  92. package/dist/validate/ui.d.ts +4 -4
  93. package/dist/validate/ui.js +80 -62
  94. package/dist/validate/variants.d.ts +2 -53
  95. package/dist/validate/variants.js +83 -86
  96. package/package.json +12 -3
@@ -1,5 +1,6 @@
1
1
  import type { BuilderPaths } from '../../paths';
2
2
  import type { Paramable } from '../../references';
3
+ import type { BuilderTags } from '../tags';
3
4
  import type { BuilderWhenSerialised } from '../when';
4
5
  import type { BuilderOptionValues, BuilderOptionValuesSerialised } from './values';
5
6
  import type { BuilderOptionWhen } from './when';
@@ -10,7 +11,9 @@ export declare class BuilderOption<const Name extends string = string, const Pay
10
11
  readonly name: Name;
11
12
  readonly payload: Payload;
12
13
  readonly paths?: Paths;
13
- constructor(name: Name, payload: Payload, paths?: Paths);
14
+ readonly tags?: BuilderTags;
15
+ constructor(name: Name, payload: Payload, paths?: Paths, tags?: BuilderTags);
16
+ tag(...tags: Array<string>): BuilderOption<Name, Payload, Paths>;
14
17
  }
15
18
  export declare const BuilderOptionSchema: v.InstanceSchema<typeof BuilderOption, undefined>;
16
19
  export type BuilderOptions = ReadonlyArray<BuilderOption>;
@@ -22,11 +25,13 @@ export declare const BuilderOptionWhenSerialisedSchema: v.GenericSchema<BuilderW
22
25
  optionLabels: {
23
26
  [x: string]: string;
24
27
  };
28
+ tags?: readonly string[] | undefined;
25
29
  }>> | Readonly<Readonly<{
26
30
  type: "toggle";
27
31
  valueType: "string" | "number" | "boolean";
28
32
  defaultValue: string | number | boolean | null;
29
33
  isOptional: boolean;
34
+ tags?: readonly string[] | undefined;
30
35
  }>>>>;
31
36
  export type BuilderOptionWhenSerialised = BuilderWhenSerialised<BuilderOptionValuesSerialised>;
32
37
  export declare const BuilderOptionSelectMapSerialisedSchema: v.GenericSchema<import("..").BuilderMatchSelectMap<Readonly<{
@@ -41,11 +46,13 @@ export declare const BuilderOptionSelectMapSerialisedSchema: v.GenericSchema<imp
41
46
  optionLabels: {
42
47
  [x: string]: string;
43
48
  };
49
+ tags?: readonly string[] | undefined;
44
50
  }>> | Readonly<Readonly<{
45
51
  type: "toggle";
46
52
  valueType: "string" | "number" | "boolean";
47
53
  defaultValue: string | number | boolean | null;
48
54
  isOptional: boolean;
55
+ tags?: readonly string[] | undefined;
49
56
  }>>>>;
50
57
  export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
51
58
  readonly name: v.StringSchema<undefined>;
@@ -69,6 +76,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
69
76
  readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
70
77
  readonly isOptional: v.BooleanSchema<undefined>;
71
78
  readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
79
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
72
80
  }, undefined>, v.ReadonlyAction<{
73
81
  type: "select";
74
82
  readonly options: readonly [string, ...string[]];
@@ -77,16 +85,19 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
77
85
  optionLabels: {
78
86
  [x: string]: string;
79
87
  };
88
+ tags?: readonly string[] | undefined;
80
89
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
81
90
  readonly type: v.LiteralSchema<"toggle", undefined>;
82
91
  readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
83
92
  readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
84
93
  readonly isOptional: v.BooleanSchema<undefined>;
94
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
85
95
  }, undefined>, v.ReadonlyAction<{
86
96
  type: "toggle";
87
97
  valueType: "string" | "number" | "boolean";
88
98
  defaultValue: string | number | boolean | null;
89
99
  isOptional: boolean;
100
+ tags?: readonly string[] | undefined;
90
101
  }>]>], undefined>, v.ReadonlyAction<Readonly<{
91
102
  type: "select";
92
103
  readonly options: readonly [string, ...string[]];
@@ -95,11 +106,13 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
95
106
  optionLabels: {
96
107
  [x: string]: string;
97
108
  };
109
+ tags?: readonly string[] | undefined;
98
110
  }> | Readonly<{
99
111
  type: "toggle";
100
112
  valueType: "string" | "number" | "boolean";
101
113
  defaultValue: string | number | boolean | null;
102
114
  isOptional: boolean;
115
+ tags?: readonly string[] | undefined;
103
116
  }>>]>, v.GenericSchema<BuilderWhenSerialised<Readonly<Readonly<{
104
117
  type: "select";
105
118
  readonly options: readonly [string, ...string[]];
@@ -108,11 +121,13 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
108
121
  optionLabels: {
109
122
  [x: string]: string;
110
123
  };
124
+ tags?: readonly string[] | undefined;
111
125
  }>> | Readonly<Readonly<{
112
126
  type: "toggle";
113
127
  valueType: "string" | "number" | "boolean";
114
128
  defaultValue: string | number | boolean | null;
115
129
  isOptional: boolean;
130
+ tags?: readonly string[] | undefined;
116
131
  }>>>>], undefined>], undefined>;
117
132
  readonly paths: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
118
133
  readonly type: v.LiteralSchema<"parameter", undefined>;
@@ -129,6 +144,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
129
144
  type: "ref";
130
145
  id: string;
131
146
  }>]>, 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>;
147
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
132
148
  }, undefined>, v.ReadonlyAction<{
133
149
  name: string;
134
150
  payload: Readonly<{
@@ -146,11 +162,13 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
146
162
  optionLabels: {
147
163
  [x: string]: string;
148
164
  };
165
+ tags?: readonly string[] | undefined;
149
166
  }>> | Readonly<Readonly<{
150
167
  type: "toggle";
151
168
  valueType: "string" | "number" | "boolean";
152
169
  defaultValue: string | number | boolean | null;
153
170
  isOptional: boolean;
171
+ tags?: readonly string[] | undefined;
154
172
  }>> | BuilderWhenSerialised<Readonly<Readonly<{
155
173
  type: "select";
156
174
  readonly options: readonly [string, ...string[]];
@@ -159,11 +177,13 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
159
177
  optionLabels: {
160
178
  [x: string]: string;
161
179
  };
180
+ tags?: readonly string[] | undefined;
162
181
  }>> | Readonly<Readonly<{
163
182
  type: "toggle";
164
183
  valueType: "string" | "number" | "boolean";
165
184
  defaultValue: string | number | boolean | null;
166
185
  isOptional: boolean;
186
+ tags?: readonly string[] | undefined;
167
187
  }>>>;
168
188
  paths?: readonly (readonly (string | number)[])[] | Readonly<{
169
189
  type: "parameter";
@@ -173,6 +193,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
173
193
  type: "ref";
174
194
  id: string;
175
195
  }> | undefined;
196
+ tags?: readonly string[] | undefined;
176
197
  }>]>;
177
198
  export type BuilderOptionSerialised = v.InferOutput<typeof BuilderOptionSerialisedSchema>;
178
199
  export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
@@ -197,6 +218,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
197
218
  readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
198
219
  readonly isOptional: v.BooleanSchema<undefined>;
199
220
  readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
221
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
200
222
  }, undefined>, v.ReadonlyAction<{
201
223
  type: "select";
202
224
  readonly options: readonly [string, ...string[]];
@@ -205,16 +227,19 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
205
227
  optionLabels: {
206
228
  [x: string]: string;
207
229
  };
230
+ tags?: readonly string[] | undefined;
208
231
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
209
232
  readonly type: v.LiteralSchema<"toggle", undefined>;
210
233
  readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
211
234
  readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
212
235
  readonly isOptional: v.BooleanSchema<undefined>;
236
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
213
237
  }, undefined>, v.ReadonlyAction<{
214
238
  type: "toggle";
215
239
  valueType: "string" | "number" | "boolean";
216
240
  defaultValue: string | number | boolean | null;
217
241
  isOptional: boolean;
242
+ tags?: readonly string[] | undefined;
218
243
  }>]>], undefined>, v.ReadonlyAction<Readonly<{
219
244
  type: "select";
220
245
  readonly options: readonly [string, ...string[]];
@@ -223,11 +248,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
223
248
  optionLabels: {
224
249
  [x: string]: string;
225
250
  };
251
+ tags?: readonly string[] | undefined;
226
252
  }> | Readonly<{
227
253
  type: "toggle";
228
254
  valueType: "string" | "number" | "boolean";
229
255
  defaultValue: string | number | boolean | null;
230
256
  isOptional: boolean;
257
+ tags?: readonly string[] | undefined;
231
258
  }>>]>, v.GenericSchema<BuilderWhenSerialised<Readonly<Readonly<{
232
259
  type: "select";
233
260
  readonly options: readonly [string, ...string[]];
@@ -236,11 +263,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
236
263
  optionLabels: {
237
264
  [x: string]: string;
238
265
  };
266
+ tags?: readonly string[] | undefined;
239
267
  }>> | Readonly<Readonly<{
240
268
  type: "toggle";
241
269
  valueType: "string" | "number" | "boolean";
242
270
  defaultValue: string | number | boolean | null;
243
271
  isOptional: boolean;
272
+ tags?: readonly string[] | undefined;
244
273
  }>>>>], undefined>], undefined>;
245
274
  readonly paths: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
246
275
  readonly type: v.LiteralSchema<"parameter", undefined>;
@@ -257,6 +286,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
257
286
  type: "ref";
258
287
  id: string;
259
288
  }>]>, 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>;
289
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
260
290
  }, undefined>, v.ReadonlyAction<{
261
291
  name: string;
262
292
  payload: Readonly<{
@@ -274,11 +304,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
274
304
  optionLabels: {
275
305
  [x: string]: string;
276
306
  };
307
+ tags?: readonly string[] | undefined;
277
308
  }>> | Readonly<Readonly<{
278
309
  type: "toggle";
279
310
  valueType: "string" | "number" | "boolean";
280
311
  defaultValue: string | number | boolean | null;
281
312
  isOptional: boolean;
313
+ tags?: readonly string[] | undefined;
282
314
  }>> | BuilderWhenSerialised<Readonly<Readonly<{
283
315
  type: "select";
284
316
  readonly options: readonly [string, ...string[]];
@@ -287,11 +319,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
287
319
  optionLabels: {
288
320
  [x: string]: string;
289
321
  };
322
+ tags?: readonly string[] | undefined;
290
323
  }>> | Readonly<Readonly<{
291
324
  type: "toggle";
292
325
  valueType: "string" | "number" | "boolean";
293
326
  defaultValue: string | number | boolean | null;
294
327
  isOptional: boolean;
328
+ tags?: readonly string[] | undefined;
295
329
  }>>>;
296
330
  paths?: readonly (readonly (string | number)[])[] | Readonly<{
297
331
  type: "parameter";
@@ -301,6 +335,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
301
335
  type: "ref";
302
336
  id: string;
303
337
  }> | undefined;
338
+ tags?: readonly string[] | undefined;
304
339
  }>]>, undefined>, v.ReadonlyAction<Readonly<{
305
340
  name: string;
306
341
  payload: Readonly<{
@@ -318,11 +353,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
318
353
  optionLabels: {
319
354
  [x: string]: string;
320
355
  };
356
+ tags?: readonly string[] | undefined;
321
357
  }>> | Readonly<Readonly<{
322
358
  type: "toggle";
323
359
  valueType: "string" | "number" | "boolean";
324
360
  defaultValue: string | number | boolean | null;
325
361
  isOptional: boolean;
362
+ tags?: readonly string[] | undefined;
326
363
  }>> | BuilderWhenSerialised<Readonly<Readonly<{
327
364
  type: "select";
328
365
  readonly options: readonly [string, ...string[]];
@@ -331,11 +368,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
331
368
  optionLabels: {
332
369
  [x: string]: string;
333
370
  };
371
+ tags?: readonly string[] | undefined;
334
372
  }>> | Readonly<Readonly<{
335
373
  type: "toggle";
336
374
  valueType: "string" | "number" | "boolean";
337
375
  defaultValue: string | number | boolean | null;
338
376
  isOptional: boolean;
377
+ tags?: readonly string[] | undefined;
339
378
  }>>>;
340
379
  paths?: readonly (readonly (string | number)[])[] | Readonly<{
341
380
  type: "parameter";
@@ -345,5 +384,6 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
345
384
  type: "ref";
346
385
  id: string;
347
386
  }> | undefined;
387
+ tags?: readonly string[] | undefined;
348
388
  }>[]>]>;
349
389
  export type BuilderOptionsSerialised = v.InferOutput<typeof BuilderOptionsSerialisedSchema>;
@@ -2,16 +2,22 @@ import * as v from 'valibot';
2
2
  import { BuilderPathsSchema } from '../../paths.js';
3
3
  import { paramable } from '../../references.js';
4
4
  import { serialisable } from '../../serialisable.js';
5
+ import { BuilderTagsSchema } from '../tags.js';
5
6
  import { createSelectMapSerialisedSchema, createWhenSerialisedSchema } from '../when.js';
6
7
  import { BuilderOptionValuesSerialisedSchema } from './values.js';
7
8
  export class BuilderOption {
8
9
  name;
9
10
  payload;
10
11
  paths;
11
- constructor(name, payload, paths) {
12
+ tags;
13
+ constructor(name, payload, paths, tags) {
12
14
  this.name = name;
13
15
  this.payload = payload;
14
16
  this.paths = paths;
17
+ this.tags = tags;
18
+ }
19
+ tag(...tags) {
20
+ return new BuilderOption(this.name, this.payload, this.paths, tags);
15
21
  }
16
22
  }
17
23
  export const BuilderOptionSchema = v.instance(BuilderOption);
@@ -20,6 +26,7 @@ export const BuilderOptionSelectMapSerialisedSchema = createSelectMapSerialisedS
20
26
  export const BuilderOptionSerialisedSchema = serialisable(v.object({
21
27
  name: v.string(),
22
28
  payload: paramable(v.union([BuilderOptionValuesSerialisedSchema, BuilderOptionWhenSerialisedSchema])),
23
- paths: v.optional(paramable(BuilderPathsSchema))
29
+ paths: v.optional(paramable(BuilderPathsSchema)),
30
+ tags: v.optional(BuilderTagsSchema)
24
31
  }));
25
32
  export const BuilderOptionsSerialisedSchema = v.pipe(v.array(BuilderOptionSerialisedSchema), v.readonly());
@@ -1,7 +1,9 @@
1
+ import type { BuilderTags } from '../tags';
1
2
  import * as v from 'valibot';
2
3
  export type BuilderSelectTypeLabels<Values extends BuilderSelectTypeValues> = Partial<Record<Values[number], string>>;
3
4
  export type BuilderSelectTypeValues = readonly [string, ...ReadonlyArray<string>];
4
5
  export declare class BuilderSelectType<const Values extends BuilderSelectTypeValues = BuilderSelectTypeValues, const ValueSchema extends v.GenericSchema<string | null> = v.GenericSchema<string | null>> {
6
+ #private;
5
7
  readonly value: v.InferOutput<ValueSchema>;
6
8
  readonly type: "select";
7
9
  readonly options: Values;
@@ -9,10 +11,12 @@ export declare class BuilderSelectType<const Values extends BuilderSelectTypeVal
9
11
  readonly defaultValue: v.InferOutput<ValueSchema>;
10
12
  readonly isOptional: boolean;
11
13
  readonly optionLabels: BuilderSelectTypeLabels<Values>;
12
- constructor(values: Values, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean, optionLabels?: BuilderSelectTypeLabels<Values>);
14
+ readonly tags?: BuilderTags;
15
+ constructor(values: Values, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean, optionLabels?: BuilderSelectTypeLabels<Values>, tags?: BuilderTags);
13
16
  default(newDefault: v.InferOutput<ValueSchema>): BuilderSelectType<Values, ValueSchema>;
14
17
  optional(): BuilderSelectType<Values, v.NullableSchema<ValueSchema, undefined>>;
15
18
  labels(optionLabels: BuilderSelectTypeLabels<Values>): BuilderSelectType<Values, ValueSchema>;
19
+ tag(...tags: Array<string>): BuilderSelectType<Values, ValueSchema>;
16
20
  }
17
21
  type SelectSchema<Values extends BuilderSelectTypeValues> = v.UnionSchema<{
18
22
  [K in keyof Values]: v.LiteralSchema<Values[K], undefined>;
@@ -25,6 +29,7 @@ export declare const BuilderSelectTypeSerialisedSchema: v.SchemaWithPipe<readonl
25
29
  readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
26
30
  readonly isOptional: v.BooleanSchema<undefined>;
27
31
  readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
32
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
28
33
  }, undefined>, v.ReadonlyAction<{
29
34
  type: "select";
30
35
  readonly options: readonly [string, ...string[]];
@@ -33,6 +38,7 @@ export declare const BuilderSelectTypeSerialisedSchema: v.SchemaWithPipe<readonl
33
38
  optionLabels: {
34
39
  [x: string]: string;
35
40
  };
41
+ tags?: readonly string[] | undefined;
36
42
  }>]>;
37
43
  export type BuilderSelectTypeSerialised = v.InferOutput<typeof BuilderSelectTypeSerialisedSchema>;
38
44
  export declare function selectValueSchema(options: ReadonlyArray<string>, optional: boolean): v.GenericSchema<string | null>;
@@ -1,5 +1,6 @@
1
1
  import * as v from 'valibot';
2
2
  import { serialisable } from '../../serialisable.js';
3
+ import { BuilderTagsSchema } from '../tags.js';
3
4
  export class BuilderSelectType {
4
5
  type = 'select';
5
6
  options;
@@ -7,22 +8,31 @@ export class BuilderSelectType {
7
8
  defaultValue;
8
9
  isOptional;
9
10
  optionLabels;
10
- constructor(values, defaultValue, optional = false, optionLabels = {}) {
11
+ tags;
12
+ constructor(values, defaultValue, optional = false, optionLabels = {}, tags) {
11
13
  this.options = values;
12
14
  this.valueSchema = selectValueSchema(values, optional);
13
15
  this.defaultValue = defaultValue;
14
16
  this.isOptional = optional;
15
17
  this.optionLabels = optionLabels;
18
+ this.tags = tags;
19
+ }
20
+ #next(patch) {
21
+ return new BuilderSelectType(this.options, 'defaultValue' in patch
22
+ ? patch.defaultValue
23
+ : this.defaultValue, patch.optional ?? this.isOptional, patch.optionLabels ?? this.optionLabels, patch.tags ?? this.tags);
16
24
  }
17
25
  default(newDefault) {
18
- return new BuilderSelectType(this.options, newDefault, this.isOptional, this.optionLabels);
26
+ return this.#next({ defaultValue: newDefault });
19
27
  }
20
28
  optional() {
21
- const { options, defaultValue } = this;
22
- return new BuilderSelectType(options, defaultValue, true, this.optionLabels);
29
+ return this.#next({ optional: true });
23
30
  }
24
31
  labels(optionLabels) {
25
- return new BuilderSelectType(this.options, this.defaultValue, this.isOptional, optionLabels);
32
+ return this.#next({ optionLabels });
33
+ }
34
+ tag(...tags) {
35
+ return this.#next({ tags });
26
36
  }
27
37
  }
28
38
  export function select(values) {
@@ -35,7 +45,8 @@ export const BuilderSelectTypeSerialisedSchema = serialisable(v.object({
35
45
  options: v.pipe(v.tupleWithRest([v.string()], v.string()), v.readonly()),
36
46
  defaultValue: v.nullable(v.string()),
37
47
  isOptional: v.boolean(),
38
- optionLabels: v.record(v.string(), v.string())
48
+ optionLabels: v.record(v.string(), v.string()),
49
+ tags: v.optional(BuilderTagsSchema)
39
50
  }));
40
51
  export function selectValueSchema(options, optional) {
41
52
  const baseSchema = v.union(options.map((value) => v.literal(value)));
@@ -1,17 +1,21 @@
1
1
  import type { BuilderPrimitive } from '../../primitive';
2
+ import type { BuilderTags } from '../tags';
2
3
  import * as v from 'valibot';
3
4
  export declare const BuilderToggleValueTypeSchema: v.PicklistSchema<["string", "boolean", "number"], undefined>;
4
5
  export type BuilderToggleValueType = v.InferOutput<typeof BuilderToggleValueTypeSchema>;
5
6
  export declare class BuilderToggleType<const ValueSchema extends v.GenericSchema<BuilderPrimitive> = v.GenericSchema<BuilderPrimitive>> {
7
+ #private;
6
8
  readonly value: v.InferOutput<ValueSchema>;
7
9
  readonly type: "toggle";
8
10
  readonly valueType: BuilderToggleValueType;
9
11
  readonly valueSchema: ValueSchema;
10
12
  readonly defaultValue: v.InferOutput<ValueSchema>;
11
13
  readonly isOptional: boolean;
12
- constructor(valueType: BuilderToggleValueType, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean);
14
+ readonly tags?: BuilderTags;
15
+ constructor(valueType: BuilderToggleValueType, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean, tags?: BuilderTags);
13
16
  default(newDefault: v.InferOutput<ValueSchema>): BuilderToggleType<ValueSchema>;
14
17
  optional(): BuilderToggleType<v.NullableSchema<ValueSchema, undefined>>;
18
+ tag(...tags: Array<string>): BuilderToggleType<ValueSchema>;
15
19
  }
16
20
  export declare function toggleString(): BuilderToggleType<v.StringSchema<undefined>>;
17
21
  export declare function toggleBoolean(): BuilderToggleType<v.BooleanSchema<undefined>>;
@@ -22,11 +26,13 @@ export declare const BuilderToggleTypeSerialisedSchema: v.SchemaWithPipe<readonl
22
26
  readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
23
27
  readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
24
28
  readonly isOptional: v.BooleanSchema<undefined>;
29
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
25
30
  }, undefined>, v.ReadonlyAction<{
26
31
  type: "toggle";
27
32
  valueType: "string" | "number" | "boolean";
28
33
  defaultValue: string | number | boolean | null;
29
34
  isOptional: boolean;
35
+ tags?: readonly string[] | undefined;
30
36
  }>]>;
31
37
  export type BuilderToggleTypeSerialised = v.InferOutput<typeof BuilderToggleTypeSerialisedSchema>;
32
38
  export declare function toggleValueSchema(valueType: BuilderToggleValueType, optional: boolean): v.GenericSchema;
@@ -1,5 +1,6 @@
1
1
  import * as v from 'valibot';
2
2
  import { serialisable } from '../../serialisable.js';
3
+ import { BuilderTagsSchema } from '../tags.js';
3
4
  export const BuilderToggleValueTypeSchema = v.picklist(['string', 'boolean', 'number']);
4
5
  export class BuilderToggleType {
5
6
  type = 'toggle';
@@ -7,17 +8,27 @@ export class BuilderToggleType {
7
8
  valueSchema;
8
9
  defaultValue;
9
10
  isOptional;
10
- constructor(valueType, defaultValue, optional) {
11
+ tags;
12
+ constructor(valueType, defaultValue, optional, tags) {
11
13
  this.valueType = valueType;
12
14
  this.valueSchema = toggleValueSchema(valueType, optional || false);
13
15
  this.defaultValue = defaultValue;
14
16
  this.isOptional = optional || false;
17
+ this.tags = tags;
18
+ }
19
+ #next(patch) {
20
+ return new BuilderToggleType(this.valueType, 'defaultValue' in patch
21
+ ? patch.defaultValue
22
+ : this.defaultValue, patch.optional ?? this.isOptional, patch.tags ?? this.tags);
15
23
  }
16
24
  default(newDefault) {
17
- return new BuilderToggleType(this.valueType, newDefault, this.isOptional);
25
+ return this.#next({ defaultValue: newDefault });
18
26
  }
19
27
  optional() {
20
- return new BuilderToggleType(this.valueType, this.defaultValue, true);
28
+ return this.#next({ optional: true });
29
+ }
30
+ tag(...tags) {
31
+ return this.#next({ tags });
21
32
  }
22
33
  }
23
34
  export function toggleString() {
@@ -34,7 +45,8 @@ export const BuilderToggleTypeSerialisedSchema = serialisable(v.object({
34
45
  type: v.literal('toggle'),
35
46
  valueType: BuilderToggleValueTypeSchema,
36
47
  defaultValue: v.nullable(v.union([v.boolean(), v.string(), v.number()])),
37
- isOptional: v.boolean()
48
+ isOptional: v.boolean(),
49
+ tags: v.optional(BuilderTagsSchema)
38
50
  }));
39
51
  export function toggleValueSchema(valueType, optional) {
40
52
  const baseSchema = valueType === 'string' ? v.string() : valueType === 'boolean' ? v.boolean() : v.number();
@@ -7,6 +7,7 @@ export declare const BuilderOptionValuesSerialisedSchema: v.SchemaWithPipe<reado
7
7
  readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
8
8
  readonly isOptional: v.BooleanSchema<undefined>;
9
9
  readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
10
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
10
11
  }, undefined>, v.ReadonlyAction<{
11
12
  type: "select";
12
13
  readonly options: readonly [string, ...string[]];
@@ -15,16 +16,19 @@ export declare const BuilderOptionValuesSerialisedSchema: v.SchemaWithPipe<reado
15
16
  optionLabels: {
16
17
  [x: string]: string;
17
18
  };
19
+ tags?: readonly string[] | undefined;
18
20
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
19
21
  readonly type: v.LiteralSchema<"toggle", undefined>;
20
22
  readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
21
23
  readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
22
24
  readonly isOptional: v.BooleanSchema<undefined>;
25
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
23
26
  }, undefined>, v.ReadonlyAction<{
24
27
  type: "toggle";
25
28
  valueType: "string" | "number" | "boolean";
26
29
  defaultValue: string | number | boolean | null;
27
30
  isOptional: boolean;
31
+ tags?: readonly string[] | undefined;
28
32
  }>]>], undefined>, v.ReadonlyAction<Readonly<{
29
33
  type: "select";
30
34
  readonly options: readonly [string, ...string[]];
@@ -33,11 +37,13 @@ export declare const BuilderOptionValuesSerialisedSchema: v.SchemaWithPipe<reado
33
37
  optionLabels: {
34
38
  [x: string]: string;
35
39
  };
40
+ tags?: readonly string[] | undefined;
36
41
  }> | Readonly<{
37
42
  type: "toggle";
38
43
  valueType: "string" | "number" | "boolean";
39
44
  defaultValue: string | number | boolean | null;
40
45
  isOptional: boolean;
46
+ tags?: readonly string[] | undefined;
41
47
  }>>]>;
42
48
  export type BuilderOptionValuesSerialised = v.InferOutput<typeof BuilderOptionValuesSerialisedSchema>;
43
49
  export declare function optionValueSchema(payload: BuilderOptionValuesSerialised): v.GenericSchema;
@@ -0,0 +1,64 @@
1
+ import * as v from 'valibot';
2
+ export declare const BuilderPricingReduceSchema: v.PicklistSchema<["product", "sum", "first"], undefined>;
3
+ export type BuilderPricingReduce = v.InferOutput<typeof BuilderPricingReduceSchema>;
4
+ export type BuilderPricingTagExpression = {
5
+ readonly kind: 'tag';
6
+ readonly value: string;
7
+ } | {
8
+ readonly kind: 'modelTags';
9
+ } | {
10
+ readonly kind: 'variantTags';
11
+ };
12
+ export declare const BuilderPricingTagExpressionSchema: v.GenericSchema<BuilderPricingTagExpression>;
13
+ export type BuilderPricingExpression = {
14
+ readonly kind: 'num';
15
+ readonly value: number;
16
+ } | {
17
+ readonly kind: 'variantPrice';
18
+ } | {
19
+ readonly kind: 'rate';
20
+ readonly rate: string;
21
+ readonly tag: BuilderPricingTagExpression;
22
+ readonly reduce?: BuilderPricingReduce;
23
+ } | {
24
+ readonly kind: 'variants';
25
+ readonly tag?: BuilderPricingTagExpression;
26
+ readonly expression: BuilderPricingExpression;
27
+ readonly reduce?: BuilderPricingReduce;
28
+ } | {
29
+ readonly kind: 'add';
30
+ readonly left: BuilderPricingExpression;
31
+ readonly right: BuilderPricingExpression;
32
+ } | {
33
+ readonly kind: 'sub';
34
+ readonly left: BuilderPricingExpression;
35
+ readonly right: BuilderPricingExpression;
36
+ } | {
37
+ readonly kind: 'mul';
38
+ readonly left: BuilderPricingExpression;
39
+ readonly right: BuilderPricingExpression;
40
+ } | {
41
+ readonly kind: 'div';
42
+ readonly left: BuilderPricingExpression;
43
+ readonly right: BuilderPricingExpression;
44
+ };
45
+ export declare const BuilderPricingExpressionSchema: v.GenericSchema<BuilderPricingExpression>;
46
+ export type BuilderPricing = {
47
+ readonly rates: Record<string, Record<string, number>>;
48
+ readonly formula: BuilderPricingExpression;
49
+ };
50
+ export declare const BuilderPricingSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
51
+ readonly rates: v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.NumberSchema<undefined>, undefined>, undefined>, v.ReadonlyAction<{
52
+ [x: string]: {
53
+ [x: string]: number;
54
+ };
55
+ }>]>;
56
+ readonly formula: v.GenericSchema<BuilderPricingExpression>;
57
+ }, undefined>, v.ReadonlyAction<{
58
+ readonly rates: Readonly<{
59
+ [x: string]: {
60
+ [x: string]: number;
61
+ };
62
+ }>;
63
+ formula: BuilderPricingExpression;
64
+ }>]>;
@@ -0,0 +1,48 @@
1
+ import * as v from 'valibot';
2
+ import { serialisable } from '../serialisable.js';
3
+ export const BuilderPricingReduceSchema = v.picklist(['product', 'sum', 'first']);
4
+ export const BuilderPricingTagExpressionSchema = v.variant('kind', [
5
+ v.object({ kind: v.literal('tag'), value: v.string() }),
6
+ v.object({ kind: v.literal('modelTags') }),
7
+ v.object({ kind: v.literal('variantTags') })
8
+ ]);
9
+ export const BuilderPricingExpressionSchema = v.lazy(() => v.variant('kind', [
10
+ v.object({ kind: v.literal('num'), value: v.number() }),
11
+ v.object({ kind: v.literal('variantPrice') }),
12
+ v.object({
13
+ kind: v.literal('rate'),
14
+ rate: v.string(),
15
+ tag: BuilderPricingTagExpressionSchema,
16
+ reduce: v.optional(BuilderPricingReduceSchema)
17
+ }),
18
+ v.object({
19
+ kind: v.literal('variants'),
20
+ tag: v.optional(BuilderPricingTagExpressionSchema),
21
+ expression: BuilderPricingExpressionSchema,
22
+ reduce: v.optional(BuilderPricingReduceSchema)
23
+ }),
24
+ v.object({
25
+ kind: v.literal('add'),
26
+ left: BuilderPricingExpressionSchema,
27
+ right: BuilderPricingExpressionSchema
28
+ }),
29
+ v.object({
30
+ kind: v.literal('sub'),
31
+ left: BuilderPricingExpressionSchema,
32
+ right: BuilderPricingExpressionSchema
33
+ }),
34
+ v.object({
35
+ kind: v.literal('mul'),
36
+ left: BuilderPricingExpressionSchema,
37
+ right: BuilderPricingExpressionSchema
38
+ }),
39
+ v.object({
40
+ kind: v.literal('div'),
41
+ left: BuilderPricingExpressionSchema,
42
+ right: BuilderPricingExpressionSchema
43
+ })
44
+ ]));
45
+ export const BuilderPricingSchema = serialisable(v.object({
46
+ rates: v.pipe(v.record(v.string(), v.record(v.string(), v.number())), v.readonly()),
47
+ formula: BuilderPricingExpressionSchema
48
+ }));