@builder-builder/builder 0.0.25 → 0.0.26

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 (81) hide show
  1. package/dist/client/schema.d.ts +4 -4
  2. package/dist/entities/builder/builder.js +2 -1
  3. package/dist/entities/collection/collection.js +2 -1
  4. package/dist/entities/collection/config.d.ts +20 -20
  5. package/dist/entities/collection/config.js +3 -2
  6. package/dist/entities/component/component.d.ts +30 -30
  7. package/dist/entities/component/component.js +2 -1
  8. package/dist/entities/component/config.d.ts +12 -12
  9. package/dist/entities/component/field.d.ts +4 -4
  10. package/dist/entities/component/field.js +4 -3
  11. package/dist/entities/expectation.d.ts +2 -2
  12. package/dist/entities/expectation.js +2 -1
  13. package/dist/entities/index.d.ts +1 -1
  14. package/dist/entities/kind.d.ts +1 -1
  15. package/dist/entities/kind.js +43 -3
  16. package/dist/entities/model/models.d.ts +3 -3
  17. package/dist/entities/option/config.d.ts +4 -4
  18. package/dist/entities/option/option.d.ts +22 -22
  19. package/dist/entities/option/option.js +2 -1
  20. package/dist/entities/option/select.d.ts +1 -1
  21. package/dist/entities/option/select.js +5 -4
  22. package/dist/entities/option/toggle.d.ts +1 -1
  23. package/dist/entities/option/toggle.js +4 -3
  24. package/dist/entities/paths.d.ts +2 -2
  25. package/dist/entities/paths.js +2 -1
  26. package/dist/entities/pricing/expression.js +5 -4
  27. package/dist/entities/pricing/rates.js +2 -1
  28. package/dist/entities/references.d.ts +2 -2
  29. package/dist/entities/references.js +2 -1
  30. package/dist/entities/serialise.d.ts +201 -113
  31. package/dist/entities/serialise.js +4 -3
  32. package/dist/entities/tags.d.ts +1 -1
  33. package/dist/entities/tags.js +2 -1
  34. package/dist/entities/ui/describe.d.ts +78 -34
  35. package/dist/entities/ui/describe.js +3 -2
  36. package/dist/entities/ui/input.d.ts +92 -48
  37. package/dist/entities/ui/input.js +5 -4
  38. package/dist/entities/ui/page.d.ts +76 -32
  39. package/dist/entities/ui/page.js +2 -1
  40. package/dist/entities/ui/pages.d.ts +3 -3
  41. package/dist/entities/ui/pages.js +3 -2
  42. package/dist/entities/validated.d.ts +1 -0
  43. package/dist/entities/when.d.ts +16 -16
  44. package/dist/entities/when.js +2 -2
  45. package/dist/errors/errors.d.ts +10 -0
  46. package/dist/errors/errors.js +6 -0
  47. package/dist/instance.d.ts +7 -7
  48. package/dist/instance.js +4 -4
  49. package/dist/mappers/index.d.ts +1 -1
  50. package/dist/mappers/price.js +1 -2
  51. package/dist/mappers/render/collection.d.ts +9 -0
  52. package/dist/mappers/render/collection.js +27 -0
  53. package/dist/mappers/render/compose.d.ts +5 -0
  54. package/dist/mappers/render/compose.js +15 -0
  55. package/dist/mappers/render/description.d.ts +3 -0
  56. package/dist/mappers/render/description.js +17 -0
  57. package/dist/mappers/render/index.d.ts +3 -1
  58. package/dist/mappers/render/option.d.ts +20 -0
  59. package/dist/mappers/render/option.js +25 -0
  60. package/dist/mappers/render/page.d.ts +11 -0
  61. package/dist/mappers/render/page.js +11 -0
  62. package/dist/mappers/render/paths.d.ts +3 -0
  63. package/dist/mappers/render/paths.js +21 -0
  64. package/dist/mappers/render/render.d.ts +1 -1
  65. package/dist/mappers/render/render.js +33 -98
  66. package/dist/mappers/resolve.d.ts +2 -1
  67. package/dist/mappers/resolve.js +24 -23
  68. package/dist/primitive.d.ts +5 -0
  69. package/dist/primitive.js +6 -1
  70. package/dist/public.d.ts +1 -1
  71. package/dist/references.d.ts +6 -6
  72. package/dist/references.js +3 -2
  73. package/dist/validate/model.js +16 -5
  74. package/dist/validate/paths.js +3 -5
  75. package/dist/validate/pricing.js +5 -6
  76. package/dist/validate/resolve.d.ts +2 -1
  77. package/dist/validate/resolve.js +87 -73
  78. package/dist/validate/ui.js +14 -13
  79. package/package.json +1 -1
  80. package/dist/mappers/render/pages.d.ts +0 -24
  81. package/dist/mappers/render/pages.js +0 -2
@@ -15,44 +15,44 @@ export declare const BuilderUIPageSerialisedSchema: v.SchemaWithPipe<readonly [v
15
15
  readonly type: v.LiteralSchema<"page", undefined>;
16
16
  readonly label: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
17
17
  readonly type: v.LiteralSchema<"parameter", undefined>;
18
- readonly id: v.StringSchema<undefined>;
19
- readonly name: v.StringSchema<undefined>;
18
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
19
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
20
20
  }, undefined>, v.ReadonlyAction<{
21
21
  type: "parameter";
22
22
  id: string;
23
23
  name: string;
24
24
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
25
25
  readonly type: v.LiteralSchema<"ref", undefined>;
26
- readonly id: v.StringSchema<undefined>;
26
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
27
27
  }, undefined>, v.ReadonlyAction<{
28
28
  type: "ref";
29
29
  id: string;
30
- }>]>, v.StringSchema<undefined>], undefined>;
30
+ }>]>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>], undefined>;
31
31
  readonly inputs: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
32
32
  readonly type: v.LiteralSchema<"parameter", undefined>;
33
- readonly id: v.StringSchema<undefined>;
34
- readonly name: v.StringSchema<undefined>;
33
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
34
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
35
35
  }, undefined>, v.ReadonlyAction<{
36
36
  type: "parameter";
37
37
  id: string;
38
38
  name: string;
39
39
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
40
40
  readonly type: v.LiteralSchema<"ref", undefined>;
41
- readonly id: v.StringSchema<undefined>;
41
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
42
42
  }, undefined>, v.ReadonlyAction<{
43
43
  type: "ref";
44
44
  id: string;
45
45
  }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
46
46
  readonly type: v.LiteralSchema<"parameter", undefined>;
47
- readonly id: v.StringSchema<undefined>;
48
- readonly name: v.StringSchema<undefined>;
47
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
48
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
49
49
  }, undefined>, v.ReadonlyAction<{
50
50
  type: "parameter";
51
51
  id: string;
52
52
  name: string;
53
53
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
54
54
  readonly type: v.LiteralSchema<"ref", undefined>;
55
- readonly id: v.StringSchema<undefined>;
55
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
56
56
  }, undefined>, v.ReadonlyAction<{
57
57
  type: "ref";
58
58
  id: string;
@@ -60,81 +60,81 @@ export declare const BuilderUIPageSerialisedSchema: v.SchemaWithPipe<readonly [v
60
60
  readonly type: v.LiteralSchema<"input", undefined>;
61
61
  readonly path: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
62
62
  readonly type: v.LiteralSchema<"parameter", undefined>;
63
- readonly id: v.StringSchema<undefined>;
64
- readonly name: v.StringSchema<undefined>;
63
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
64
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
65
65
  }, undefined>, v.ReadonlyAction<{
66
66
  type: "parameter";
67
67
  id: string;
68
68
  name: string;
69
69
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
70
70
  readonly type: v.LiteralSchema<"ref", undefined>;
71
- readonly id: v.StringSchema<undefined>;
71
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
72
72
  }, undefined>, v.ReadonlyAction<{
73
73
  type: "ref";
74
74
  id: string;
75
- }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
75
+ }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
76
76
  readonly displayName: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
77
77
  readonly type: v.LiteralSchema<"parameter", undefined>;
78
- readonly id: v.StringSchema<undefined>;
79
- readonly name: v.StringSchema<undefined>;
78
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
79
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
80
80
  }, undefined>, v.ReadonlyAction<{
81
81
  type: "parameter";
82
82
  id: string;
83
83
  name: string;
84
84
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
85
85
  readonly type: v.LiteralSchema<"ref", undefined>;
86
- readonly id: v.StringSchema<undefined>;
86
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
87
87
  }, undefined>, v.ReadonlyAction<{
88
88
  type: "ref";
89
89
  id: string;
90
- }>]>, v.StringSchema<undefined>], undefined>, undefined>;
90
+ }>]>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>], undefined>, undefined>;
91
91
  readonly kind: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
92
92
  readonly type: v.LiteralSchema<"parameter", undefined>;
93
- readonly id: v.StringSchema<undefined>;
94
- readonly name: v.StringSchema<undefined>;
93
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
94
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
95
95
  }, undefined>, v.ReadonlyAction<{
96
96
  type: "parameter";
97
97
  id: string;
98
98
  name: string;
99
99
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
100
100
  readonly type: v.LiteralSchema<"ref", undefined>;
101
- readonly id: v.StringSchema<undefined>;
101
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
102
102
  }, undefined>, v.ReadonlyAction<{
103
103
  type: "ref";
104
104
  id: string;
105
- }>]>, v.StringSchema<undefined>], undefined>, undefined>;
105
+ }>]>, v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>], undefined>, undefined>;
106
106
  readonly metadata: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
107
107
  readonly type: v.LiteralSchema<"parameter", undefined>;
108
- readonly id: v.StringSchema<undefined>;
109
- readonly name: v.StringSchema<undefined>;
108
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
109
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
110
110
  }, undefined>, v.ReadonlyAction<{
111
111
  type: "parameter";
112
112
  id: string;
113
113
  name: string;
114
114
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
115
115
  readonly type: v.LiteralSchema<"ref", undefined>;
116
- readonly id: v.StringSchema<undefined>;
116
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
117
117
  }, undefined>, v.ReadonlyAction<{
118
118
  type: "ref";
119
119
  id: string;
120
- }>]>, v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
120
+ }>]>, v.SchemaWithPipe<readonly [v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
121
121
  readonly type: v.LiteralSchema<"parameter", undefined>;
122
- readonly id: v.StringSchema<undefined>;
123
- readonly name: v.StringSchema<undefined>;
122
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
123
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
124
124
  }, undefined>, v.ReadonlyAction<{
125
125
  type: "parameter";
126
126
  id: string;
127
127
  name: string;
128
128
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
129
129
  readonly type: v.LiteralSchema<"ref", undefined>;
130
- readonly id: v.StringSchema<undefined>;
130
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
131
131
  }, undefined>, v.ReadonlyAction<{
132
132
  type: "ref";
133
133
  id: string;
134
134
  }>]>, v.UnknownSchema], undefined>, undefined>, v.ReadonlyAction<{
135
135
  [x: string]: unknown;
136
136
  }>]>], undefined>, undefined>;
137
- readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
137
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
138
138
  }, undefined>, v.ReadonlyAction<{
139
139
  type: "input";
140
140
  path: readonly (string | number)[] | Readonly<{
@@ -172,7 +172,51 @@ export declare const BuilderUIPageSerialisedSchema: v.SchemaWithPipe<readonly [v
172
172
  [x: string]: unknown;
173
173
  }> | undefined;
174
174
  tags?: readonly string[] | undefined;
175
- }>]>], undefined>, undefined>, v.ReadonlyAction<(Readonly<{
175
+ }>]>], undefined>, undefined>, v.MinLengthAction<(Readonly<{
176
+ type: "parameter";
177
+ id: string;
178
+ name: string;
179
+ }> | Readonly<{
180
+ type: "ref";
181
+ id: string;
182
+ }> | Readonly<{
183
+ type: "input";
184
+ path: readonly (string | number)[] | Readonly<{
185
+ type: "parameter";
186
+ id: string;
187
+ name: string;
188
+ }> | Readonly<{
189
+ type: "ref";
190
+ id: string;
191
+ }>;
192
+ displayName?: string | Readonly<{
193
+ type: "parameter";
194
+ id: string;
195
+ name: string;
196
+ }> | Readonly<{
197
+ type: "ref";
198
+ id: string;
199
+ }> | undefined;
200
+ kind?: string | Readonly<{
201
+ type: "parameter";
202
+ id: string;
203
+ name: string;
204
+ }> | Readonly<{
205
+ type: "ref";
206
+ id: string;
207
+ }> | undefined;
208
+ metadata?: Readonly<{
209
+ type: "parameter";
210
+ id: string;
211
+ name: string;
212
+ }> | Readonly<{
213
+ type: "ref";
214
+ id: string;
215
+ }> | Readonly<{
216
+ [x: string]: unknown;
217
+ }> | undefined;
218
+ tags?: readonly string[] | undefined;
219
+ }>)[], 1, undefined>, v.ReadonlyAction<(Readonly<{
176
220
  type: "parameter";
177
221
  id: string;
178
222
  name: string;
@@ -217,7 +261,7 @@ export declare const BuilderUIPageSerialisedSchema: v.SchemaWithPipe<readonly [v
217
261
  }> | undefined;
218
262
  tags?: readonly string[] | undefined;
219
263
  }>)[]>]>], undefined>;
220
- readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
264
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
221
265
  }, undefined>, v.ReadonlyAction<{
222
266
  type: "page";
223
267
  label: string | Readonly<{
@@ -1,4 +1,5 @@
1
1
  import * as v from 'valibot';
2
+ import { NameSchema } from '../../primitive.js';
2
3
  import { isParamable, paramable } from '../../references.js';
3
4
  import { createEntityValidator } from '../kind.js';
4
5
  import { serialisable } from '../serialisable.js';
@@ -21,7 +22,7 @@ export class BuilderUIPage {
21
22
  export const BuilderUIPageSchema = v.instance(BuilderUIPage);
22
23
  export const BuilderUIPageSerialisedSchema = serialisable(v.object({
23
24
  type: v.literal('page'),
24
- label: paramable(v.string()),
25
+ label: paramable(NameSchema),
25
26
  inputs: paramable(BuilderUIInputsSerialisedSchema),
26
27
  tags: v.optional(BuilderTagsSchema)
27
28
  }));
@@ -28,15 +28,15 @@ export declare const BuilderUIPagesSerialisedSchema: v.GenericSchema<BuilderUIPa
28
28
  export declare const BuilderUIItemSerialisedSchema: v.GenericSchema<BuilderUIItemSerialised>;
29
29
  export declare const BuilderUIItemsSerialisedSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
30
30
  readonly type: v.LiteralSchema<"parameter", undefined>;
31
- readonly id: v.StringSchema<undefined>;
32
- readonly name: v.StringSchema<undefined>;
31
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
32
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
33
33
  }, undefined>, v.ReadonlyAction<{
34
34
  type: "parameter";
35
35
  id: string;
36
36
  name: string;
37
37
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
38
38
  readonly type: v.LiteralSchema<"ref", undefined>;
39
- readonly id: v.StringSchema<undefined>;
39
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
40
40
  }, undefined>, v.ReadonlyAction<{
41
41
  type: "ref";
42
42
  id: string;
@@ -1,4 +1,5 @@
1
1
  import * as v from 'valibot';
2
+ import { NameSchema } from '../../primitive.js';
2
3
  import { isParamable, paramable } from '../../references.js';
3
4
  import { createEntityValidator } from '../kind.js';
4
5
  import { serialisable } from '../serialisable.js';
@@ -24,8 +25,8 @@ export class BuilderUIPages {
24
25
  export const BuilderUIPagesSchema = v.instance(BuilderUIPages);
25
26
  export const BuilderUIPagesSerialisedSchema = serialisable(v.object({
26
27
  type: v.literal('pages'),
27
- name: v.string(),
28
- label: paramable(v.string()),
28
+ name: NameSchema,
29
+ label: paramable(NameSchema),
29
30
  items: paramable(v.lazy(() => BuilderUIItemsSerialisedSchema)),
30
31
  tags: v.optional(BuilderTagsSchema)
31
32
  }));
@@ -30,6 +30,7 @@ export type BuilderModelValidated = BuilderValidatedMap['model'];
30
30
  export type BuilderPricingValidated = BuilderValidatedMap['pricing'];
31
31
  export type BuilderUIValidated = BuilderValidatedMap['ui'];
32
32
  export type BuilderUIDescribeValidated = BuilderValidatedMap['uiDescribe'];
33
+ export type BuilderUIInputValidated = BuilderValidatedMap['uiInput'];
33
34
  export type BuilderUIItemsValidated = BuilderValidatedMap['uiItems'];
34
35
  export type BuilderUIPageValidated = BuilderValidatedMap['uiPage'];
35
36
  export type BuilderInstanceValidated = Prettify<Validated<BuilderInstance>>;
@@ -43,37 +43,37 @@ export declare const BuilderWhenMatchSchema: v.ObjectSchema<{
43
43
  readonly type: v.LiteralSchema<"match", undefined>;
44
44
  readonly matchPath: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
45
45
  readonly type: v.LiteralSchema<"parameter", undefined>;
46
- readonly id: v.StringSchema<undefined>;
47
- readonly name: v.StringSchema<undefined>;
46
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
47
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
48
48
  }, undefined>, v.ReadonlyAction<{
49
49
  type: "parameter";
50
50
  id: string;
51
51
  name: string;
52
52
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
53
53
  readonly type: v.LiteralSchema<"ref", undefined>;
54
- readonly id: v.StringSchema<undefined>;
54
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
55
55
  }, undefined>, v.ReadonlyAction<{
56
56
  type: "ref";
57
57
  id: string;
58
- }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
58
+ }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
59
59
  }, undefined>;
60
60
  export declare const BuilderWhenUnlessSchema: v.ObjectSchema<{
61
61
  readonly type: v.LiteralSchema<"unless", undefined>;
62
62
  readonly unlessPath: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
63
63
  readonly type: v.LiteralSchema<"parameter", undefined>;
64
- readonly id: v.StringSchema<undefined>;
65
- readonly name: v.StringSchema<undefined>;
64
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
65
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
66
66
  }, undefined>, v.ReadonlyAction<{
67
67
  type: "parameter";
68
68
  id: string;
69
69
  name: string;
70
70
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
71
71
  readonly type: v.LiteralSchema<"ref", undefined>;
72
- readonly id: v.StringSchema<undefined>;
72
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
73
73
  }, undefined>, v.ReadonlyAction<{
74
74
  type: "ref";
75
75
  id: string;
76
- }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
76
+ }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
77
77
  }, undefined>;
78
78
  export declare const BuilderWhenConfigSchema: v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.ObjectSchema<{
79
79
  readonly type: v.LiteralSchema<"enable", undefined>;
@@ -81,36 +81,36 @@ export declare const BuilderWhenConfigSchema: v.SchemaWithPipe<readonly [v.Varia
81
81
  readonly type: v.LiteralSchema<"match", undefined>;
82
82
  readonly matchPath: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
83
83
  readonly type: v.LiteralSchema<"parameter", undefined>;
84
- readonly id: v.StringSchema<undefined>;
85
- readonly name: v.StringSchema<undefined>;
84
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
85
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
86
86
  }, undefined>, v.ReadonlyAction<{
87
87
  type: "parameter";
88
88
  id: string;
89
89
  name: string;
90
90
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
91
91
  readonly type: v.LiteralSchema<"ref", undefined>;
92
- readonly id: v.StringSchema<undefined>;
92
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
93
93
  }, undefined>, v.ReadonlyAction<{
94
94
  type: "ref";
95
95
  id: string;
96
- }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
96
+ }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
97
97
  }, undefined>, v.ObjectSchema<{
98
98
  readonly type: v.LiteralSchema<"unless", undefined>;
99
99
  readonly unlessPath: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
100
100
  readonly type: v.LiteralSchema<"parameter", undefined>;
101
- readonly id: v.StringSchema<undefined>;
102
- readonly name: v.StringSchema<undefined>;
101
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
102
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
103
103
  }, undefined>, v.ReadonlyAction<{
104
104
  type: "parameter";
105
105
  id: string;
106
106
  name: string;
107
107
  }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
108
108
  readonly type: v.LiteralSchema<"ref", undefined>;
109
- readonly id: v.StringSchema<undefined>;
109
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
110
110
  }, undefined>, v.ReadonlyAction<{
111
111
  type: "ref";
112
112
  id: string;
113
- }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
113
+ }>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>], undefined>;
114
114
  }, undefined>], undefined>, v.ReadonlyAction<{
115
115
  type: "enable";
116
116
  } | {
@@ -1,6 +1,6 @@
1
1
  import * as v from 'valibot';
2
2
  import { check } from '../errors/index.js';
3
- import { BuilderPrimitivesSchema } from '../primitive.js';
3
+ import { BuilderPrimitivesSchema, StringSchema } from '../primitive.js';
4
4
  import { isParamable, paramable } from '../references.js';
5
5
  import { BuilderPathSchema } from './paths.js';
6
6
  export const BuilderWhenEnableSchema = v.object({
@@ -36,7 +36,7 @@ export function whenBranches(payload, schema) {
36
36
  }
37
37
  }
38
38
  export function createSelectMapSerialisedSchema(payloadSchema) {
39
- return v.pipe(v.record(v.string(), v.nullable(paramable(payloadSchema))), v.readonly());
39
+ return v.pipe(v.record(StringSchema, v.nullable(paramable(payloadSchema))), v.readonly());
40
40
  }
41
41
  export function createWhenSerialisedSchema(payloadSchema) {
42
42
  const paramablePayload = paramable(payloadSchema);
@@ -28,6 +28,11 @@ export declare class BuilderErrorsScope {
28
28
  location: BuilderErrorLocation;
29
29
  root: unknown;
30
30
  } & object;
31
+ entityEmptyId(): {
32
+ kind: "entity-empty-id";
33
+ location: BuilderErrorLocation;
34
+ root: unknown;
35
+ } & object;
31
36
  entityInvalidCollectionBounds(): {
32
37
  kind: "entity-invalid-collection-bounds";
33
38
  location: BuilderErrorLocation;
@@ -145,6 +150,11 @@ export declare class BuilderErrorsScope {
145
150
  location: BuilderErrorLocation;
146
151
  root: unknown;
147
152
  } & object;
153
+ referenceInvalid(): {
154
+ kind: "reference-invalid";
155
+ location: BuilderErrorLocation;
156
+ root: unknown;
157
+ } & object;
148
158
  instanceInvalidOption(): {
149
159
  kind: "instance-invalid-option";
150
160
  location: BuilderErrorLocation;
@@ -29,6 +29,9 @@ export class BuilderErrorsScope {
29
29
  entityEmptyName() {
30
30
  return this.#addError('entity-empty-name');
31
31
  }
32
+ entityEmptyId() {
33
+ return this.#addError('entity-empty-id');
34
+ }
32
35
  entityInvalidCollectionBounds() {
33
36
  return this.#addError('entity-invalid-collection-bounds');
34
37
  }
@@ -98,6 +101,9 @@ export class BuilderErrorsScope {
98
101
  referenceUnboundParameter() {
99
102
  return this.#addError('reference-unbound-parameter');
100
103
  }
104
+ referenceInvalid() {
105
+ return this.#addError('reference-invalid');
106
+ }
101
107
  instanceInvalidOption() {
102
108
  return this.#addError('instance-invalid-option');
103
109
  }
@@ -9,8 +9,8 @@ export type BuilderInstances = v.InferOutput<typeof BuilderInstancesSchema>;
9
9
  export type BuilderInstanceInput = Readonly<Record<string, unknown>>;
10
10
  export declare const BuilderComponentVariantSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
11
11
  readonly instance: v.GenericSchema<BuilderInstance>;
12
- readonly details: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.NullableSchema<v.UnionSchema<[v.StringSchema<undefined>, v.BooleanSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, undefined>, undefined>;
13
- readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
12
+ readonly details: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.NullableSchema<v.UnionSchema<[v.StringSchema<undefined>, v.BooleanSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, undefined>, undefined>;
13
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
14
14
  }, undefined>, v.ReadonlyAction<{
15
15
  instance: BuilderInstance;
16
16
  details?: {
@@ -21,8 +21,8 @@ export declare const BuilderComponentVariantSchema: v.SchemaWithPipe<readonly [v
21
21
  export type BuilderComponentVariant = v.InferOutput<typeof BuilderComponentVariantSchema>;
22
22
  export declare const BuilderComponentVariantsSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
23
23
  readonly instance: v.GenericSchema<BuilderInstance>;
24
- readonly details: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.NullableSchema<v.UnionSchema<[v.StringSchema<undefined>, v.BooleanSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, undefined>, undefined>;
25
- readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
24
+ readonly details: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.NullableSchema<v.UnionSchema<[v.StringSchema<undefined>, v.BooleanSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, undefined>, undefined>;
25
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
26
26
  }, undefined>, v.ReadonlyAction<{
27
27
  instance: BuilderInstance;
28
28
  details?: {
@@ -37,10 +37,10 @@ export declare const BuilderComponentVariantsSchema: v.SchemaWithPipe<readonly [
37
37
  tags?: readonly string[] | undefined;
38
38
  }>[]>]>;
39
39
  export type BuilderComponentVariants = v.InferOutput<typeof BuilderComponentVariantsSchema>;
40
- export declare const BuilderVariantsSchema: v.SchemaWithPipe<readonly [v.RecordSchema<v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
40
+ export declare const BuilderVariantsSchema: v.SchemaWithPipe<readonly [v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
41
41
  readonly instance: v.GenericSchema<BuilderInstance>;
42
- readonly details: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.NullableSchema<v.UnionSchema<[v.StringSchema<undefined>, v.BooleanSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, undefined>, undefined>;
43
- readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
42
+ readonly details: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, v.NullableSchema<v.UnionSchema<[v.StringSchema<undefined>, v.BooleanSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, undefined>, undefined>;
43
+ readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
44
44
  }, undefined>, v.ReadonlyAction<{
45
45
  instance: BuilderInstance;
46
46
  details?: {
package/dist/instance.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as v from 'valibot';
2
2
  import { BuilderTagsSchema } from './entities/index.js';
3
- import { BuilderPrimitiveSchema } from './primitive.js';
4
- export const BuilderInstanceSchema = v.pipe(v.record(v.string(), v.union([BuilderPrimitiveSchema, v.lazy(() => BuilderInstancesSchema)])), v.readonly());
3
+ import { BuilderPrimitiveSchema, NameSchema } from './primitive.js';
4
+ export const BuilderInstanceSchema = v.pipe(v.record(NameSchema, v.union([BuilderPrimitiveSchema, v.lazy(() => BuilderInstancesSchema)])), v.readonly());
5
5
  export const BuilderInstancesSchema = v.pipe(v.array(BuilderInstanceSchema), v.readonly());
6
6
  export const BuilderComponentVariantSchema = v.pipe(v.object({
7
7
  instance: BuilderInstanceSchema,
8
- details: v.optional(v.record(v.string(), BuilderPrimitiveSchema)),
8
+ details: v.optional(v.record(NameSchema, BuilderPrimitiveSchema)),
9
9
  tags: v.optional(BuilderTagsSchema)
10
10
  }), v.readonly());
11
11
  export const BuilderComponentVariantsSchema = v.pipe(v.array(BuilderComponentVariantSchema), v.readonly());
12
- export const BuilderVariantsSchema = v.pipe(v.record(v.string(), BuilderComponentVariantsSchema), v.readonly());
12
+ export const BuilderVariantsSchema = v.pipe(v.record(NameSchema, BuilderComponentVariantsSchema), v.readonly());
@@ -1,5 +1,5 @@
1
1
  export type { BuilderOrder } from './order';
2
- export type { BuilderRenderMetadata, BuilderRenderOption, BuilderRenderOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderResult, BuilderRenderUpdate } from './render/index';
2
+ export type { BuilderRenderCollection, BuilderRenderCollectionAddRemove, BuilderRenderCollections, BuilderRenderMetadata, BuilderRenderOption, BuilderRenderOptions, BuilderRenderOptionUpdate, BuilderRenderPage, BuilderRenderPages, BuilderRenderResult } from './render/index';
3
3
  export type { BuilderOptionGraph } from './variants/index';
4
4
  export { createInstance } from './instance.js';
5
5
  export { order } from './order.js';
@@ -1,8 +1,7 @@
1
- import * as v from 'valibot';
2
1
  import { BuilderPricingExpressionSchema } from '../entities/index.js';
3
2
  import { check } from '../errors/index.js';
4
3
  import { BuilderComponentVariantSchema } from '../instance.js';
5
- const NumberSchema = v.number();
4
+ import { NumberSchema } from '../primitive.js';
6
5
  export function price(pricingInput, order) {
7
6
  const { rates, formula } = pricingInput;
8
7
  if (formula == null) {
@@ -0,0 +1,9 @@
1
+ import type { BuilderPath, BuilderReferences, BuilderValidated } from '../../entities/index';
2
+ import type { BuilderInstance } from '../../instance';
3
+ export type BuilderRenderCollectionAddRemove = (instance: BuilderInstance) => BuilderInstance;
4
+ export type BuilderRenderCollection = Readonly<{
5
+ add?: BuilderRenderCollectionAddRemove;
6
+ remove?: BuilderRenderCollectionAddRemove;
7
+ }>;
8
+ export type BuilderRenderCollections = Readonly<Record<string, BuilderRenderCollection>>;
9
+ export declare function renderCollection(itemsPath: BuilderPath, index: number, min: number, max: number, length: number, builder: BuilderValidated, references: BuilderReferences): BuilderRenderCollection;
@@ -0,0 +1,27 @@
1
+ import { createInstance } from '../instance.js';
2
+ import { readPath, writePath } from './paths.js';
3
+ export function renderCollection(itemsPath, index, min, max, length, builder, references) {
4
+ let handlers = {};
5
+ if (length < max) {
6
+ handlers = {
7
+ ...handlers,
8
+ add: (updateInstance) => {
9
+ const current = (readPath(updateInstance, itemsPath) ?? []);
10
+ const clone = current[index] ?? {};
11
+ const next = [...current.slice(0, index + 1), clone, ...current.slice(index + 1)];
12
+ return createInstance(builder, writePath(updateInstance, itemsPath, next), references);
13
+ }
14
+ };
15
+ }
16
+ if (length > min) {
17
+ handlers = {
18
+ ...handlers,
19
+ remove: (updateInstance) => {
20
+ const current = (readPath(updateInstance, itemsPath) ?? []);
21
+ const next = [...current.slice(0, index), ...current.slice(index + 1)];
22
+ return createInstance(builder, writePath(updateInstance, itemsPath, next), references);
23
+ }
24
+ };
25
+ }
26
+ return handlers;
27
+ }
@@ -0,0 +1,5 @@
1
+ import type { BuilderReferences } from '../../entities/index';
2
+ import type { BuilderRenderMetadata } from './option';
3
+ export declare function composeLabel(label: unknown, labels: ReadonlyArray<string>, references: BuilderReferences): string;
4
+ export declare function composeString(value: unknown, references: BuilderReferences): string;
5
+ export declare function composeMetadata(value: unknown, references: BuilderReferences): BuilderRenderMetadata;
@@ -0,0 +1,15 @@
1
+ import { resolveReference } from '../resolve.js';
2
+ import { StringSchema } from '../../primitive.js';
3
+ import { BuilderRenderMetadataSchema } from './option.js';
4
+ export function composeLabel(label, labels, references) {
5
+ return [...labels, composeString(label, references)]
6
+ .filter((segment) => segment !== '')
7
+ .join(', ');
8
+ }
9
+ export function composeString(value, references) {
10
+ return resolveReference(value, references, StringSchema);
11
+ }
12
+ export function composeMetadata(value, references) {
13
+ const resolved = resolveReference(value, references, BuilderRenderMetadataSchema);
14
+ return Object.fromEntries(Object.entries(resolved).map(([key, entry]) => [key, resolveReference(entry, references)]));
15
+ }
@@ -0,0 +1,3 @@
1
+ import type { BuilderDescriptionItem, BuilderModelValidated, BuilderReferences, BuilderUIDescribeValidated } from '../../entities/index';
2
+ import type { BuilderInstance } from '../../instance';
3
+ export declare function renderDescription(describe: BuilderUIDescribeValidated, label: string, model: BuilderModelValidated, instance: BuilderInstance, references: BuilderReferences): BuilderDescriptionItem | null;
@@ -0,0 +1,17 @@
1
+ import { check } from '../../errors/index.js';
2
+ import { BuilderPrimitiveSchema } from '../../primitive.js';
3
+ import { resolvePath } from '../resolve.js';
4
+ export function renderDescription(describe, label, model, instance, references) {
5
+ const values = describe.inputs.flatMap((input) => {
6
+ const found = resolvePath(model, instance, input.path, references);
7
+ if (found?.value == null) {
8
+ return [];
9
+ }
10
+ check.assert(BuilderPrimitiveSchema, found.value);
11
+ return [found.value];
12
+ });
13
+ if (values.length === 0) {
14
+ return null;
15
+ }
16
+ return [label, values.join(' ')];
17
+ }
@@ -1,4 +1,6 @@
1
- export type { BuilderRenderMetadata, BuilderRenderOption, BuilderRenderOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderUpdate } from './pages';
1
+ export type { BuilderRenderCollection, BuilderRenderCollectionAddRemove, BuilderRenderCollections } from './collection';
2
+ export type { BuilderRenderMetadata, BuilderRenderOption, BuilderRenderOptionUpdate, BuilderRenderOptions } from './option';
3
+ export type { BuilderRenderPage, BuilderRenderPages } from './page';
2
4
  export type { BuilderRenderResult } from './render';
3
5
  export { render } from './render.js';
4
6
  export { ordinal } from './ordinal.js';