@builder-builder/builder 0.0.28 → 0.0.29

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 (77) hide show
  1. package/dist/bb.js +5 -6
  2. package/dist/client/schema.d.ts +49 -29
  3. package/dist/components/BuilderOption.svelte.d.ts +12 -12
  4. package/dist/components/BuilderOptionValueBoolean.svelte.d.ts +20 -0
  5. package/dist/components/BuilderOptionValueNumber.svelte.d.ts +21 -0
  6. package/dist/components/BuilderOptionValueSelect.svelte.d.ts +21 -0
  7. package/dist/components/BuilderOptionValueString.svelte.d.ts +21 -0
  8. package/dist/components/index.d.ts +8 -8
  9. package/dist/components/index.js +2479 -2435
  10. package/dist/components/index.min.js +3 -3
  11. package/dist/entities/collection/collection.d.ts +162 -372
  12. package/dist/entities/collection/collection.js +7 -4
  13. package/dist/entities/collection/{when.d.ts → condition.d.ts} +3 -4
  14. package/dist/entities/collection/condition.js +2 -0
  15. package/dist/entities/collection/config.d.ts +52 -70
  16. package/dist/entities/collection/index.d.ts +4 -4
  17. package/dist/entities/collection/index.js +2 -2
  18. package/dist/entities/component/component.d.ts +11 -23
  19. package/dist/entities/component/component.js +4 -4
  20. package/dist/entities/component/{when.d.ts → condition.d.ts} +3 -4
  21. package/dist/entities/component/{when.js → condition.js} +3 -9
  22. package/dist/entities/component/index.d.ts +4 -4
  23. package/dist/entities/component/index.js +2 -2
  24. package/dist/entities/{when.d.ts → condition.d.ts} +21 -34
  25. package/dist/entities/{when.js → condition.js} +20 -25
  26. package/dist/entities/expectation.d.ts +135 -3
  27. package/dist/entities/expectation.js +6 -2
  28. package/dist/entities/index.d.ts +8 -8
  29. package/dist/entities/index.js +4 -4
  30. package/dist/entities/kind.d.ts +1 -1
  31. package/dist/entities/kind.js +4 -5
  32. package/dist/entities/model/bind.d.ts +5 -5
  33. package/dist/entities/model/methods.d.ts +18 -27
  34. package/dist/entities/model/methods.js +4 -22
  35. package/dist/entities/model/model.d.ts +3 -1
  36. package/dist/entities/model/model.js +25 -27
  37. package/dist/entities/option/condition.d.ts +9 -0
  38. package/dist/entities/option/condition.js +2 -0
  39. package/dist/entities/option/config.d.ts +44 -69
  40. package/dist/entities/option/config.js +6 -6
  41. package/dist/entities/option/expectation.d.ts +6 -1
  42. package/dist/entities/option/expectation.js +2 -2
  43. package/dist/entities/option/index.d.ts +8 -8
  44. package/dist/entities/option/index.js +4 -4
  45. package/dist/entities/option/option.d.ts +171 -202
  46. package/dist/entities/option/option.js +4 -4
  47. package/dist/entities/option/select.d.ts +16 -43
  48. package/dist/entities/option/select.js +8 -31
  49. package/dist/entities/option/value.d.ts +73 -0
  50. package/dist/entities/option/value.js +99 -0
  51. package/dist/entities/references.d.ts +104 -64
  52. package/dist/entities/serialise.d.ts +147 -80
  53. package/dist/entities/serialise.js +26 -21
  54. package/dist/entities/ui/input.d.ts +1 -1
  55. package/dist/entities/validated.d.ts +1 -1
  56. package/dist/errors/errors.d.ts +8 -3
  57. package/dist/errors/errors.js +5 -2
  58. package/dist/index.d.ts +1 -1
  59. package/dist/index.js +1 -1
  60. package/dist/mappers/dependencies.js +4 -3
  61. package/dist/mappers/resolve.js +23 -22
  62. package/dist/mappers/variants/option-graph.js +1 -1
  63. package/dist/public.d.ts +17 -17
  64. package/dist/public.js +17 -9
  65. package/dist/validate/expectations.js +21 -3
  66. package/dist/validate/model.js +8 -11
  67. package/dist/validate/resolve.js +14 -18
  68. package/package.json +1 -1
  69. package/dist/components/BuilderOptionSelect.svelte.d.ts +0 -21
  70. package/dist/components/BuilderOptionToggleBoolean.svelte.d.ts +0 -20
  71. package/dist/components/BuilderOptionToggleNumber.svelte.d.ts +0 -21
  72. package/dist/components/BuilderOptionToggleString.svelte.d.ts +0 -21
  73. package/dist/entities/collection/when.js +0 -2
  74. package/dist/entities/option/toggle.d.ts +0 -45
  75. package/dist/entities/option/toggle.js +0 -71
  76. package/dist/entities/option/when.d.ts +0 -10
  77. package/dist/entities/option/when.js +0 -2
@@ -5,7 +5,7 @@ import { createEntityValidator } from '../kind.js';
5
5
  import { BuilderPathsSchema } from '../paths.js';
6
6
  import { serialisable } from '../serialisable.js';
7
7
  import { BuilderTagsSchema } from '../tags.js';
8
- import { createSelectMapSerialisedSchema, createWhenSerialisedSchema } from '../when.js';
8
+ import { createSelectMapSerialisedSchema, createConditionSerialisedSchema } from '../condition.js';
9
9
  import { BuilderCollectionConfigSerialisedSchema } from './config.js';
10
10
  export class BuilderCollection {
11
11
  name;
@@ -23,14 +23,17 @@ export class BuilderCollection {
23
23
  }
24
24
  }
25
25
  export const BuilderCollectionSchema = v.instance(BuilderCollection);
26
- export const BuilderCollectionWhenSerialisedSchema = createWhenSerialisedSchema(BuilderCollectionConfigSerialisedSchema);
26
+ export const BuilderCollectionConditionSerialisedSchema = createConditionSerialisedSchema(BuilderCollectionConfigSerialisedSchema);
27
27
  export const BuilderCollectionSelectMapSerialisedSchema = createSelectMapSerialisedSchema(BuilderCollectionConfigSerialisedSchema);
28
28
  export const BuilderCollectionSerialisedSchema = serialisable(v.object({
29
29
  name: NameSchema,
30
- payload: paramable(v.union([BuilderCollectionConfigSerialisedSchema, BuilderCollectionWhenSerialisedSchema])),
30
+ payload: paramable(v.union([
31
+ BuilderCollectionConfigSerialisedSchema,
32
+ BuilderCollectionConditionSerialisedSchema
33
+ ])),
31
34
  paths: v.optional(paramable(BuilderPathsSchema)),
32
35
  tags: v.optional(BuilderTagsSchema)
33
36
  }));
34
37
  export const BuilderCollectionsSerialisedSchema = v.pipe(v.array(BuilderCollectionSerialisedSchema), v.readonly());
35
- export const validateCollectionWhen = createEntityValidator('collectionWhen', BuilderCollectionWhenSerialisedSchema);
38
+ export const validateCollectionCondition = createEntityValidator('collectionCondition', BuilderCollectionConditionSerialisedSchema);
36
39
  export const validateCollectionSelectMap = createEntityValidator('collectionSelectMap', BuilderCollectionSelectMapSerialisedSchema);
@@ -1,10 +1,9 @@
1
1
  import type { Paramable } from '../../references';
2
2
  import type { BuilderPath } from '../paths';
3
- import type { BuilderWhen } from '../when';
3
+ import type { BuilderCondition } from '../condition';
4
4
  import type { BuilderCollectionConfig } from './config';
5
- export type BuilderCollectionWhen = BuilderWhen<Paramable<BuilderCollectionConfig>, Paramable<BuilderPath>, Paramable<Record<string, Paramable<BuilderCollectionConfig> | null>>, Paramable<BuilderPath>>;
6
- export declare const collectionWhen: {
7
- enable: <const Values extends Paramable<BuilderCollectionConfig<Paramable<import("..").BuilderModelGeneric>, Paramable<number>, Paramable<number>>>>(values: Values) => import("..").BuilderEnableConfig<Values>;
5
+ export type BuilderCollectionCondition = BuilderCondition<Paramable<BuilderCollectionConfig>, Paramable<BuilderPath>, Paramable<Record<string, Paramable<BuilderCollectionConfig> | null>>, Paramable<BuilderPath>>;
6
+ export declare const collectionCondition: {
8
7
  match: <const MatchPayload extends Paramable<BuilderCollectionConfig<Paramable<import("..").BuilderModelGeneric>, Paramable<number>, Paramable<number>>>, const MatchPath extends Paramable<BuilderPath>, const SelectMap extends Paramable<import("..").BuilderMatchSelectMap<Paramable<BuilderCollectionConfig<Paramable<import("..").BuilderModelGeneric>, Paramable<number>, Paramable<number>>>>>>(matchPath: MatchPath, selectMap: SelectMap) => import("..").BuilderMatchConfig<MatchPayload, MatchPath, SelectMap>;
9
8
  unless: <const Values extends Paramable<BuilderCollectionConfig<Paramable<import("..").BuilderModelGeneric>, Paramable<number>, Paramable<number>>>, const UnlessPath extends Paramable<BuilderPath>>(unlessPath: UnlessPath, disabledValues: import("../../primitive").BuilderPrimitivesNonEmpty, values: Values) => import("..").BuilderUnlessConfig<Values, UnlessPath>;
10
9
  };
@@ -0,0 +1,2 @@
1
+ import { createConditionFactories } from '../condition.js';
2
+ export const collectionCondition = createConditionFactories();
@@ -195,39 +195,38 @@ export declare const validateCollectionConfig: (input: unknown, references?: imp
195
195
  readonly options: readonly {
196
196
  readonly name: string;
197
197
  readonly payload: {
198
- readonly type: "enable";
199
- readonly payload: {
200
- readonly type: "select";
201
- readonly options: readonly [string, ...string[]];
202
- readonly defaultValue: string | null;
203
- readonly isOptional: boolean;
204
- readonly optionLabels: {
205
- readonly [x: string]: string;
206
- } & import("../../validate").BuilderValidatedBrand;
207
- readonly tags?: readonly string[] | undefined;
208
- } | {
209
- readonly type: "toggle";
210
- readonly kind: "string" | "number" | "boolean";
211
- readonly defaultValue: string | number | boolean | null;
212
- readonly isOptional: boolean;
213
- readonly tags?: readonly string[] | undefined;
214
- };
198
+ readonly kind: "string" | "number" | "boolean";
199
+ readonly type: "value";
200
+ readonly defaultValue: string | number | boolean | null;
201
+ readonly isOptional: boolean;
202
+ readonly tags?: readonly string[] | undefined;
203
+ } | {
204
+ readonly kind: "select";
205
+ readonly options: readonly [string, ...string[]];
206
+ readonly optionLabels?: ({
207
+ readonly [x: string]: string;
208
+ } & import("../../validate").BuilderValidatedBrand) | undefined;
209
+ readonly type: "value";
210
+ readonly defaultValue: string | number | boolean | null;
211
+ readonly isOptional: boolean;
212
+ readonly tags?: readonly string[] | undefined;
215
213
  } | {
216
214
  readonly type: "match";
217
215
  readonly matchPath: readonly (string | number)[];
218
216
  readonly selectMap: {
219
217
  readonly [x: string]: {
220
- readonly type: "select";
221
- readonly options: readonly [string, ...string[]];
222
- readonly defaultValue: string | null;
218
+ readonly kind: "string" | "number" | "boolean";
219
+ readonly type: "value";
220
+ readonly defaultValue: string | number | boolean | null;
223
221
  readonly isOptional: boolean;
224
- readonly optionLabels: {
225
- readonly [x: string]: string;
226
- } & import("../../validate").BuilderValidatedBrand;
227
222
  readonly tags?: readonly string[] | undefined;
228
223
  } | {
229
- readonly type: "toggle";
230
- readonly kind: "string" | "number" | "boolean";
224
+ readonly kind: "select";
225
+ readonly options: readonly [string, ...string[]];
226
+ readonly optionLabels?: ({
227
+ readonly [x: string]: string;
228
+ } & import("../../validate").BuilderValidatedBrand) | undefined;
229
+ readonly type: "value";
231
230
  readonly defaultValue: string | number | boolean | null;
232
231
  readonly isOptional: boolean;
233
232
  readonly tags?: readonly string[] | undefined;
@@ -238,36 +237,22 @@ export declare const validateCollectionConfig: (input: unknown, references?: imp
238
237
  readonly unlessPath: readonly (string | number)[];
239
238
  readonly disabledValues: readonly (string | number | boolean | null)[];
240
239
  readonly payload: {
241
- readonly type: "select";
242
- readonly options: readonly [string, ...string[]];
243
- readonly defaultValue: string | null;
240
+ readonly kind: "string" | "number" | "boolean";
241
+ readonly type: "value";
242
+ readonly defaultValue: string | number | boolean | null;
244
243
  readonly isOptional: boolean;
245
- readonly optionLabels: {
246
- readonly [x: string]: string;
247
- } & import("../../validate").BuilderValidatedBrand;
248
244
  readonly tags?: readonly string[] | undefined;
249
245
  } | {
250
- readonly type: "toggle";
251
- readonly kind: "string" | "number" | "boolean";
246
+ readonly kind: "select";
247
+ readonly options: readonly [string, ...string[]];
248
+ readonly optionLabels?: ({
249
+ readonly [x: string]: string;
250
+ } & import("../../validate").BuilderValidatedBrand) | undefined;
251
+ readonly type: "value";
252
252
  readonly defaultValue: string | number | boolean | null;
253
253
  readonly isOptional: boolean;
254
254
  readonly tags?: readonly string[] | undefined;
255
255
  };
256
- } | {
257
- readonly type: "select";
258
- readonly options: readonly [string, ...string[]];
259
- readonly defaultValue: string | null;
260
- readonly isOptional: boolean;
261
- readonly optionLabels: {
262
- readonly [x: string]: string;
263
- } & import("../../validate").BuilderValidatedBrand;
264
- readonly tags?: readonly string[] | undefined;
265
- } | {
266
- readonly type: "toggle";
267
- readonly kind: "string" | "number" | "boolean";
268
- readonly defaultValue: string | number | boolean | null;
269
- readonly isOptional: boolean;
270
- readonly tags?: readonly string[] | undefined;
271
256
  };
272
257
  readonly paths?: readonly (readonly (string | number)[])[] | undefined;
273
258
  readonly tags?: readonly string[] | undefined;
@@ -283,18 +268,6 @@ export declare const validateCollectionConfig: (input: unknown, references?: imp
283
268
  readonly tags?: readonly string[] | undefined;
284
269
  }[];
285
270
  readonly tags?: readonly string[] | undefined;
286
- } | {
287
- readonly type: "enable";
288
- readonly payload: {
289
- readonly details: readonly {
290
- readonly type: "component-detail";
291
- readonly name: string;
292
- readonly kind: "string" | "number" | "boolean" | "price" | "image";
293
- readonly isOptional: boolean;
294
- readonly tags?: readonly string[] | undefined;
295
- }[];
296
- readonly tags?: readonly string[] | undefined;
297
- };
298
271
  } | {
299
272
  readonly type: "match";
300
273
  readonly matchPath: readonly (string | number)[];
@@ -336,14 +309,6 @@ export declare const validateCollectionConfig: (input: unknown, references?: imp
336
309
  readonly min: number;
337
310
  readonly max: number;
338
311
  readonly tags?: readonly string[] | undefined;
339
- } | {
340
- readonly type: "enable";
341
- readonly payload: {
342
- readonly model: /*elided*/ any & import("../../validate").BuilderValidatedBrand;
343
- readonly min: number;
344
- readonly max: number;
345
- readonly tags?: readonly string[] | undefined;
346
- };
347
312
  } | {
348
313
  readonly type: "match";
349
314
  readonly matchPath: readonly (string | number)[];
@@ -368,10 +333,27 @@ export declare const validateCollectionConfig: (input: unknown, references?: imp
368
333
  };
369
334
  readonly tags?: readonly string[] | undefined;
370
335
  }[];
371
- readonly expectations: readonly ({
336
+ readonly expectations: readonly {
372
337
  readonly name: string;
373
338
  readonly kind: "option" | "component" | "collection";
374
- } & import("../../validate").BuilderValidatedBrand)[];
339
+ readonly payload?: {
340
+ readonly kind: "string" | "number" | "boolean";
341
+ readonly type: "value";
342
+ readonly defaultValue: string | number | boolean | null;
343
+ readonly isOptional: boolean;
344
+ readonly tags?: readonly string[] | undefined;
345
+ } | {
346
+ readonly kind: "select";
347
+ readonly options: readonly [string, ...string[]];
348
+ readonly optionLabels?: ({
349
+ readonly [x: string]: string;
350
+ } & import("../../validate").BuilderValidatedBrand) | undefined;
351
+ readonly type: "value";
352
+ readonly defaultValue: string | number | boolean | null;
353
+ readonly isOptional: boolean;
354
+ readonly tags?: readonly string[] | undefined;
355
+ } | undefined;
356
+ }[];
375
357
  readonly tags?: readonly string[] | undefined;
376
358
  } & import("../../validate").BuilderValidatedBrand;
377
359
  readonly min: number;
@@ -1,8 +1,8 @@
1
- export type { BuilderCollectionPayload, BuilderCollections, BuilderCollectionSerialised, BuilderCollectionsSerialised, BuilderCollectionWhenSerialised, CollectionNamesOf, CollectionShape } from './collection';
1
+ export type { BuilderCollectionPayload, BuilderCollections, BuilderCollectionSerialised, BuilderCollectionsSerialised, BuilderCollectionConditionSerialised, CollectionNamesOf, CollectionShape } from './collection';
2
2
  export type { BuilderCollectionConfigSerialised, BuilderCollectionConfigsSerialised } from './config';
3
3
  export type { CollectionsAsserted } from './expectation';
4
- export type { BuilderCollectionWhen } from './when';
5
- export { BuilderCollection, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionWhenSerialisedSchema, validateCollectionSelectMap, validateCollectionWhen } from './collection.js';
4
+ export type { BuilderCollectionCondition } from './condition';
5
+ export { BuilderCollection, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionConditionSerialisedSchema, validateCollectionSelectMap, validateCollectionCondition } from './collection.js';
6
6
  export { BuilderCollectionConfig, BuilderCollectionConfigSchema, BuilderCollectionConfigSerialisedSchema, BuilderCollectionConfigsSerialisedSchema, collectionConfig, validateCollectionConfig } from './config.js';
7
7
  export { collectionExpectation } from './expectation.js';
8
- export { collectionWhen } from './when.js';
8
+ export { collectionCondition } from './condition.js';
@@ -1,4 +1,4 @@
1
- export { BuilderCollection, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionWhenSerialisedSchema, validateCollectionSelectMap, validateCollectionWhen } from './collection.js';
1
+ export { BuilderCollection, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionConditionSerialisedSchema, validateCollectionSelectMap, validateCollectionCondition } from './collection.js';
2
2
  export { BuilderCollectionConfig, BuilderCollectionConfigSchema, BuilderCollectionConfigSerialisedSchema, BuilderCollectionConfigsSerialisedSchema, collectionConfig, validateCollectionConfig } from './config.js';
3
3
  export { collectionExpectation } from './expectation.js';
4
- export { collectionWhen } from './when.js';
4
+ export { collectionCondition } from './condition.js';
@@ -1,11 +1,11 @@
1
1
  import type { Paramable } from '../../references';
2
2
  import type { BuilderPaths } from '../paths';
3
3
  import type { BuilderTags } from '../tags';
4
- import type { BuilderWhenSerialised } from '../when';
4
+ import type { BuilderConditionSerialised } from '../condition';
5
5
  import type { BuilderComponentConfig, BuilderComponentConfigSerialised } from './config';
6
- import type { BuilderComponentWhen } from './when';
6
+ import type { BuilderComponentCondition } from './condition';
7
7
  import * as v from 'valibot';
8
- export type BuilderComponentPayload = BuilderComponentConfig | BuilderComponentWhen;
8
+ export type BuilderComponentPayload = BuilderComponentConfig | BuilderComponentCondition;
9
9
  export declare class BuilderComponent<const Name extends string = string, const Payload extends Paramable<BuilderComponentPayload> = Paramable<BuilderComponentPayload>, const Paths extends Paramable<BuilderPaths> = Paramable<BuilderPaths>> {
10
10
  readonly type: 'component';
11
11
  readonly name: Name;
@@ -17,7 +17,7 @@ export declare class BuilderComponent<const Name extends string = string, const
17
17
  }
18
18
  export declare const BuilderComponentSchema: v.InstanceSchema<typeof BuilderComponent, undefined>;
19
19
  export type BuilderComponents = ReadonlyArray<BuilderComponent>;
20
- export declare const BuilderComponentWhenSerialisedSchema: v.GenericSchema<BuilderWhenSerialised<Readonly<{
20
+ export declare const BuilderComponentConditionSerialisedSchema: v.GenericSchema<BuilderConditionSerialised<Readonly<{
21
21
  details: Readonly<{
22
22
  type: "parameter";
23
23
  id: string;
@@ -34,7 +34,7 @@ export declare const BuilderComponentWhenSerialisedSchema: v.GenericSchema<Build
34
34
  }>[];
35
35
  tags?: readonly string[] | undefined;
36
36
  }>>>;
37
- export type BuilderComponentWhenSerialised = BuilderWhenSerialised<BuilderComponentConfigSerialised>;
37
+ export type BuilderComponentConditionSerialised = BuilderConditionSerialised<BuilderComponentConfigSerialised>;
38
38
  export declare const BuilderComponentSelectMapSerialisedSchema: v.GenericSchema<import("..").BuilderMatchSelectMap<Readonly<{
39
39
  type: "parameter";
40
40
  id: string;
@@ -123,7 +123,7 @@ export declare const BuilderComponentSerialisedSchema: v.SchemaWithPipe<readonly
123
123
  tags?: readonly string[] | undefined;
124
124
  }>[];
125
125
  tags?: readonly string[] | undefined;
126
- }>]>, v.GenericSchema<BuilderWhenSerialised<Readonly<{
126
+ }>]>, v.GenericSchema<BuilderConditionSerialised<Readonly<{
127
127
  details: Readonly<{
128
128
  type: "parameter";
129
129
  id: string;
@@ -181,7 +181,7 @@ export declare const BuilderComponentSerialisedSchema: v.SchemaWithPipe<readonly
181
181
  tags?: readonly string[] | undefined;
182
182
  }>[];
183
183
  tags?: readonly string[] | undefined;
184
- }> | BuilderWhenSerialised<Readonly<{
184
+ }> | BuilderConditionSerialised<Readonly<{
185
185
  details: Readonly<{
186
186
  type: "parameter";
187
187
  id: string;
@@ -276,7 +276,7 @@ export declare const BuilderComponentsSerialisedSchema: v.SchemaWithPipe<readonl
276
276
  tags?: readonly string[] | undefined;
277
277
  }>[];
278
278
  tags?: readonly string[] | undefined;
279
- }>]>, v.GenericSchema<BuilderWhenSerialised<Readonly<{
279
+ }>]>, v.GenericSchema<BuilderConditionSerialised<Readonly<{
280
280
  details: Readonly<{
281
281
  type: "parameter";
282
282
  id: string;
@@ -334,7 +334,7 @@ export declare const BuilderComponentsSerialisedSchema: v.SchemaWithPipe<readonl
334
334
  tags?: readonly string[] | undefined;
335
335
  }>[];
336
336
  tags?: readonly string[] | undefined;
337
- }> | BuilderWhenSerialised<Readonly<{
337
+ }> | BuilderConditionSerialised<Readonly<{
338
338
  details: Readonly<{
339
339
  type: "parameter";
340
340
  id: string;
@@ -385,7 +385,7 @@ export declare const BuilderComponentsSerialisedSchema: v.SchemaWithPipe<readonl
385
385
  tags?: readonly string[] | undefined;
386
386
  }>[];
387
387
  tags?: readonly string[] | undefined;
388
- }> | BuilderWhenSerialised<Readonly<{
388
+ }> | BuilderConditionSerialised<Readonly<{
389
389
  details: Readonly<{
390
390
  type: "parameter";
391
391
  id: string;
@@ -413,19 +413,7 @@ export declare const BuilderComponentsSerialisedSchema: v.SchemaWithPipe<readonl
413
413
  tags?: readonly string[] | undefined;
414
414
  }>[]>]>;
415
415
  export type BuilderComponentsSerialised = v.InferOutput<typeof BuilderComponentsSerialisedSchema>;
416
- export declare const validateComponentWhen: (input: unknown, references?: import("..").BuilderReferences, issues?: import("../../errors").BuilderIssuesScope) => import("..").ValidationResult<{
417
- readonly type: "enable";
418
- readonly payload: {
419
- readonly details: readonly {
420
- readonly type: "component-detail";
421
- readonly name: string;
422
- readonly kind: "string" | "number" | "boolean" | "price" | "image";
423
- readonly isOptional: boolean;
424
- readonly tags?: readonly string[] | undefined;
425
- }[];
426
- readonly tags?: readonly string[] | undefined;
427
- };
428
- } | {
416
+ export declare const validateComponentCondition: (input: unknown, references?: import("..").BuilderReferences, issues?: import("../../errors").BuilderIssuesScope) => import("..").ValidationResult<{
429
417
  readonly type: "match";
430
418
  readonly matchPath: readonly (string | number)[];
431
419
  readonly selectMap: {
@@ -5,7 +5,7 @@ import { createEntityValidator } from '../kind.js';
5
5
  import { BuilderPathsSchema } from '../paths.js';
6
6
  import { serialisable } from '../serialisable.js';
7
7
  import { BuilderTagsSchema } from '../tags.js';
8
- import { createSelectMapSerialisedSchema, createWhenSerialisedSchema } from '../when.js';
8
+ import { createSelectMapSerialisedSchema, createConditionSerialisedSchema } from '../condition.js';
9
9
  import { BuilderComponentConfigSerialisedSchema } from './config.js';
10
10
  export class BuilderComponent {
11
11
  name;
@@ -23,14 +23,14 @@ export class BuilderComponent {
23
23
  }
24
24
  }
25
25
  export const BuilderComponentSchema = v.instance(BuilderComponent);
26
- export const BuilderComponentWhenSerialisedSchema = createWhenSerialisedSchema(BuilderComponentConfigSerialisedSchema);
26
+ export const BuilderComponentConditionSerialisedSchema = createConditionSerialisedSchema(BuilderComponentConfigSerialisedSchema);
27
27
  export const BuilderComponentSelectMapSerialisedSchema = createSelectMapSerialisedSchema(BuilderComponentConfigSerialisedSchema);
28
28
  export const BuilderComponentSerialisedSchema = serialisable(v.object({
29
29
  name: NameSchema,
30
- payload: paramable(v.union([BuilderComponentConfigSerialisedSchema, BuilderComponentWhenSerialisedSchema])),
30
+ payload: paramable(v.union([BuilderComponentConfigSerialisedSchema, BuilderComponentConditionSerialisedSchema])),
31
31
  paths: v.optional(paramable(BuilderPathsSchema)),
32
32
  tags: v.optional(BuilderTagsSchema)
33
33
  }));
34
34
  export const BuilderComponentsSerialisedSchema = v.pipe(v.array(BuilderComponentSerialisedSchema), v.readonly());
35
- export const validateComponentWhen = createEntityValidator('componentWhen', BuilderComponentWhenSerialisedSchema);
35
+ export const validateComponentCondition = createEntityValidator('componentCondition', BuilderComponentConditionSerialisedSchema);
36
36
  export const validateComponentSelectMap = createEntityValidator('componentSelectMap', BuilderComponentSelectMapSerialisedSchema);
@@ -1,11 +1,10 @@
1
1
  import type { BuilderPrimitivesNonEmpty } from '../../primitive';
2
2
  import type { Paramable } from '../../references';
3
3
  import type { BuilderPath } from '../paths';
4
- import type { BuilderEnableConfig, BuilderMatchConfig, BuilderMatchSelectMap, BuilderUnlessConfig, BuilderWhen } from '../when';
4
+ import type { BuilderMatchConfig, BuilderMatchSelectMap, BuilderUnlessConfig, BuilderCondition } from '../condition';
5
5
  import type { BuilderComponentConfig } from './config';
6
- export type BuilderComponentWhen = BuilderWhen<Paramable<BuilderComponentConfig>, Paramable<BuilderPath>, Paramable<Record<string, Paramable<BuilderComponentConfig> | null>>, Paramable<BuilderPath>>;
7
- export declare const componentWhen: {
8
- enable: <const Payload extends Paramable<BuilderComponentConfig>>(payload?: Payload) => BuilderEnableConfig<Payload>;
6
+ export type BuilderComponentCondition = BuilderCondition<Paramable<BuilderComponentConfig>, Paramable<BuilderPath>, Paramable<Record<string, Paramable<BuilderComponentConfig> | null>>, Paramable<BuilderPath>>;
7
+ export declare const componentCondition: {
9
8
  match: <const Payload extends Paramable<BuilderComponentConfig>, const MatchPath extends Paramable<BuilderPath>, const SelectMap extends Paramable<BuilderMatchSelectMap<Paramable<BuilderComponentConfig>>>>(matchPath: MatchPath, selectMap: SelectMap) => BuilderMatchConfig<Payload, MatchPath, SelectMap>;
10
9
  unless: <const UnlessPath extends Paramable<BuilderPath>, const Payload extends Paramable<BuilderComponentConfig>>(unlessPath: UnlessPath, disabledValues: BuilderPrimitivesNonEmpty, payload?: Payload) => BuilderUnlessConfig<Payload, UnlessPath>;
11
10
  };
@@ -1,13 +1,7 @@
1
- import { createWhenFactories } from '../when.js';
1
+ import { createConditionFactories } from '../condition.js';
2
2
  import { componentConfig } from './config.js';
3
- const baseFactories = createWhenFactories();
4
- export const componentWhen = {
5
- enable: (payload) => {
6
- return {
7
- type: 'enable',
8
- payload: (payload ?? componentConfig())
9
- };
10
- },
3
+ const baseFactories = createConditionFactories();
4
+ export const componentCondition = {
11
5
  match: baseFactories.match,
12
6
  unless: (unlessPath, disabledValues, payload) => {
13
7
  return {
@@ -1,10 +1,10 @@
1
- export type { BuilderComponentPayload, BuilderComponents, BuilderComponentSerialised, BuilderComponentsSerialised, BuilderComponentWhenSerialised } from './component';
1
+ export type { BuilderComponentPayload, BuilderComponents, BuilderComponentSerialised, BuilderComponentsSerialised, BuilderComponentConditionSerialised } from './component';
2
2
  export type { BuilderComponentConfigSerialised, BuilderComponentConfigsSerialised } from './config';
3
3
  export type { ComponentAsserted } from './expectation';
4
4
  export type { BuilderComponentDetailKind, BuilderComponentDetails, BuilderComponentDetailSerialised, BuilderComponentDetailsSerialised } from './detail';
5
- export type { BuilderComponentWhen } from './when';
6
- export { BuilderComponent, BuilderComponentSchema, BuilderComponentSelectMapSerialisedSchema, BuilderComponentSerialisedSchema, BuilderComponentsSerialisedSchema, BuilderComponentWhenSerialisedSchema, validateComponentSelectMap, validateComponentWhen } from './component.js';
5
+ export type { BuilderComponentCondition } from './condition';
6
+ export { BuilderComponent, BuilderComponentSchema, BuilderComponentSelectMapSerialisedSchema, BuilderComponentSerialisedSchema, BuilderComponentsSerialisedSchema, BuilderComponentConditionSerialisedSchema, validateComponentSelectMap, validateComponentCondition } from './component.js';
7
7
  export { BuilderComponentConfig, BuilderComponentConfigSchema, BuilderComponentConfigSerialisedSchema, BuilderComponentConfigsSerialisedSchema, componentConfig, validateComponentConfig } from './config.js';
8
8
  export { componentExpectation } from './expectation.js';
9
9
  export { BuilderComponentDetail, BuilderComponentDetailKindSchema, BuilderComponentDetailSchema, BuilderComponentDetailSerialisedSchema, BuilderComponentDetailsSchema, BuilderComponentDetailsSerialisedSchema, detailBoolean, detailImage, detailNumber, detailPrice, detailString, detailValueSchema } from './detail.js';
10
- export { componentWhen } from './when.js';
10
+ export { componentCondition } from './condition.js';
@@ -1,5 +1,5 @@
1
- export { BuilderComponent, BuilderComponentSchema, BuilderComponentSelectMapSerialisedSchema, BuilderComponentSerialisedSchema, BuilderComponentsSerialisedSchema, BuilderComponentWhenSerialisedSchema, validateComponentSelectMap, validateComponentWhen } from './component.js';
1
+ export { BuilderComponent, BuilderComponentSchema, BuilderComponentSelectMapSerialisedSchema, BuilderComponentSerialisedSchema, BuilderComponentsSerialisedSchema, BuilderComponentConditionSerialisedSchema, validateComponentSelectMap, validateComponentCondition } from './component.js';
2
2
  export { BuilderComponentConfig, BuilderComponentConfigSchema, BuilderComponentConfigSerialisedSchema, BuilderComponentConfigsSerialisedSchema, componentConfig, validateComponentConfig } from './config.js';
3
3
  export { componentExpectation } from './expectation.js';
4
4
  export { BuilderComponentDetail, BuilderComponentDetailKindSchema, BuilderComponentDetailSchema, BuilderComponentDetailSerialisedSchema, BuilderComponentDetailsSchema, BuilderComponentDetailsSerialisedSchema, detailBoolean, detailImage, detailNumber, detailPrice, detailString, detailValueSchema } from './detail.js';
5
- export { componentWhen } from './when.js';
5
+ export { componentCondition } from './condition.js';
@@ -3,10 +3,6 @@ import type { BuilderParameter, BuilderParameterSerialised, Paramable } from '..
3
3
  import type { BuilderModelGeneric, BuilderModelState, BuilderModelStateOf } from './model/index';
4
4
  import type { BuilderPath, BuilderPaths } from './paths';
5
5
  import * as v from 'valibot';
6
- export type BuilderEnableConfig<Payload = unknown> = {
7
- readonly type: 'enable';
8
- readonly payload: Payload;
9
- };
10
6
  export type BuilderMatchSelectMap<Item> = Record<string, Item | null>;
11
7
  export type BuilderMatchConfig<Payload = unknown, MatchPath = BuilderPath, SelectMap = BuilderMatchSelectMap<Payload>> = {
12
8
  readonly type: 'match';
@@ -19,11 +15,10 @@ export type BuilderUnlessConfig<Payload = unknown, UnlessPath = BuilderPath> = {
19
15
  readonly disabledValues: BuilderPrimitives;
20
16
  readonly payload: Payload;
21
17
  };
22
- export type BuilderWhen<Payload = unknown, MatchPath = BuilderPath, MatchSelectMap = Record<string, Payload | null>, UnlessPath = BuilderPath> = BuilderEnableConfig<Payload> | BuilderMatchConfig<Payload, MatchPath, MatchSelectMap> | BuilderUnlessConfig<Payload, UnlessPath>;
23
- export type BuilderWhenSerialised<Payload> = {
24
- readonly type: 'enable';
25
- readonly payload: Payload | BuilderParameterSerialised;
26
- } | {
18
+ export type BuilderCondition<Payload = unknown, MatchPath = BuilderPath, MatchSelectMap = Record<string, Payload | null>, UnlessPath = BuilderPath> = BuilderMatchConfig<Payload, MatchPath, MatchSelectMap> | BuilderUnlessConfig<Payload, UnlessPath>;
19
+ export declare function match<const MatchPath extends Paramable<BuilderPath>, const SelectMap extends Paramable<BuilderMatchSelectMap<unknown>>>(matchPath: MatchPath, selectMap: SelectMap): BuilderMatchConfig<unknown, MatchPath, SelectMap>;
20
+ export declare function unless<const Values, const UnlessPath extends Paramable<BuilderPath>>(unlessPath: UnlessPath, disabledValues: BuilderPrimitivesNonEmpty, values: Values): BuilderUnlessConfig<Values, UnlessPath>;
21
+ export type BuilderConditionSerialised<Payload> = {
27
22
  readonly type: 'match';
28
23
  readonly matchPath: BuilderParameterSerialised | BuilderPath;
29
24
  readonly selectMap: Record<string, (Payload | BuilderParameterSerialised) | null> | BuilderParameterSerialised;
@@ -33,13 +28,10 @@ export type BuilderWhenSerialised<Payload> = {
33
28
  readonly disabledValues: BuilderPrimitives;
34
29
  readonly payload: Payload | BuilderParameterSerialised;
35
30
  };
36
- export type WhenConfigPayload<Config extends BuilderWhenGeneric, Payload> = Config extends {
31
+ export type ConditionConfigPayload<Config extends BuilderConditionGeneric, Payload> = Config extends {
37
32
  readonly payload: infer Inner extends Payload;
38
33
  } ? Inner : Config extends BuilderMatchConfig ? NonNullable<Config['selectMap'][keyof Config['selectMap']]> & Payload : never;
39
- export declare const BuilderWhenEnableSchema: v.ObjectSchema<{
40
- readonly type: v.LiteralSchema<"enable", undefined>;
41
- }, undefined>;
42
- export declare const BuilderWhenMatchSchema: v.ObjectSchema<{
34
+ export declare const BuilderConditionMatchSchema: v.ObjectSchema<{
43
35
  readonly type: v.LiteralSchema<"match", undefined>;
44
36
  readonly matchPath: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
45
37
  readonly type: v.LiteralSchema<"parameter", undefined>;
@@ -57,7 +49,7 @@ export declare const BuilderWhenMatchSchema: v.ObjectSchema<{
57
49
  id: string;
58
50
  }>]>, 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
51
  }, undefined>;
60
- export declare const BuilderWhenUnlessSchema: v.ObjectSchema<{
52
+ export declare const BuilderConditionUnlessSchema: v.ObjectSchema<{
61
53
  readonly type: v.LiteralSchema<"unless", undefined>;
62
54
  readonly unlessPath: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
63
55
  readonly type: v.LiteralSchema<"parameter", undefined>;
@@ -75,9 +67,7 @@ export declare const BuilderWhenUnlessSchema: v.ObjectSchema<{
75
67
  id: string;
76
68
  }>]>, 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
69
  }, undefined>;
78
- export declare const BuilderWhenConfigSchema: v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.ObjectSchema<{
79
- readonly type: v.LiteralSchema<"enable", undefined>;
80
- }, undefined>, v.ObjectSchema<{
70
+ export declare const BuilderConditionConfigSchema: v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.ObjectSchema<{
81
71
  readonly type: v.LiteralSchema<"match", undefined>;
82
72
  readonly matchPath: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
83
73
  readonly type: v.LiteralSchema<"parameter", undefined>;
@@ -112,8 +102,6 @@ export declare const BuilderWhenConfigSchema: v.SchemaWithPipe<readonly [v.Varia
112
102
  id: string;
113
103
  }>]>, 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
104
  }, undefined>], undefined>, v.ReadonlyAction<{
115
- type: "enable";
116
- } | {
117
105
  type: "match";
118
106
  matchPath: readonly (string | number)[] | Readonly<{
119
107
  type: "parameter";
@@ -134,21 +122,20 @@ export declare const BuilderWhenConfigSchema: v.SchemaWithPipe<readonly [v.Varia
134
122
  id: string;
135
123
  }>;
136
124
  }>]>;
137
- export type BuilderWhenConfig = v.InferOutput<typeof BuilderWhenConfigSchema>;
138
- export type BuilderWhenGeneric = BuilderWhen<unknown, unknown, unknown, unknown>;
139
- export declare const BuilderWhenSerialisedSchema: v.GenericSchema<BuilderWhenSerialised<unknown>>;
140
- export declare function whenBranches<Leaf>(payload: unknown, schema: v.GenericSchema<Leaf>): ReadonlyArray<Leaf>;
125
+ export type BuilderConditionConfig = v.InferOutput<typeof BuilderConditionConfigSchema>;
126
+ export type BuilderConditionGeneric = BuilderCondition<unknown, unknown, unknown, unknown>;
127
+ export declare const BuilderConditionSerialisedSchema: v.GenericSchema<BuilderConditionSerialised<unknown>>;
128
+ export declare function conditionBranches<Leaf>(payload: unknown, schema: v.GenericSchema<Leaf>): ReadonlyArray<Leaf>;
141
129
  export declare function createSelectMapSerialisedSchema<Payload extends v.GenericSchema>(payloadSchema: Payload): v.GenericSchema<BuilderMatchSelectMap<v.InferOutput<Payload> | BuilderParameterSerialised>>;
142
- export declare function createWhenSerialisedSchema<Payload extends v.GenericSchema>(payloadSchema: Payload): v.GenericSchema<BuilderWhenSerialised<v.InferOutput<Payload>>>;
143
- export declare function createWhenFactories<Payload>(): {
144
- enable: <const Values extends Paramable<Payload>>(values: Values) => BuilderEnableConfig<Values>;
130
+ export declare function createConditionSerialisedSchema<Payload extends v.GenericSchema>(payloadSchema: Payload): v.GenericSchema<BuilderConditionSerialised<v.InferOutput<Payload>>>;
131
+ export declare function createConditionFactories<Payload>(): {
145
132
  match: <const MatchPayload extends Paramable<Payload>, const MatchPath extends Paramable<BuilderPath>, const SelectMap extends Paramable<BuilderMatchSelectMap<Paramable<Payload>>>>(matchPath: MatchPath, selectMap: SelectMap) => BuilderMatchConfig<MatchPayload, MatchPath, SelectMap>;
146
133
  unless: <const Values extends Paramable<Payload>, const UnlessPath extends Paramable<BuilderPath>>(unlessPath: UnlessPath, disabledValues: BuilderPrimitivesNonEmpty, values: Values) => BuilderUnlessConfig<Values, UnlessPath>;
147
134
  };
148
135
  export type BuilderValidPath<State extends BuilderModelState> = InstanceValidPath<State['instance']>;
149
136
  export type BuilderValidPaths<State extends BuilderModelState> = ReadonlyArray<BuilderValidPath<State>>;
150
137
  export type BuilderValidPathsOf<Input extends Paramable<BuilderModelGeneric>> = BuilderValidPaths<BuilderModelStateOf<Input>>;
151
- export type BuilderWhenConstrained<State extends BuilderModelState, Config> = Config extends BuilderParameter ? Config : Config extends {
138
+ export type BuilderConditionConstrained<State extends BuilderModelState, Config> = Config extends BuilderParameter ? Config : Config extends {
152
139
  readonly type: 'match';
153
140
  readonly matchPath: infer MatchPath extends BuilderPath;
154
141
  readonly selectMap: infer SelectMap;
@@ -161,25 +148,25 @@ export type BuilderWhenConstrained<State extends BuilderModelState, Config> = Co
161
148
  } ? Config & {
162
149
  readonly unlessPath: [UnlessPath] extends [Readonly<BuilderValidPath<State>>] ? UnlessPath : Readonly<BuilderValidPath<State>>;
163
150
  } : Config;
164
- export type WhenConfigNullable<Config extends BuilderWhenGeneric> = Config extends {
151
+ export type ConditionConfigNullable<Config extends BuilderConditionGeneric> = Config extends {
165
152
  readonly type: 'unless';
166
153
  } ? null : Config extends {
167
154
  readonly type: 'match';
168
155
  readonly selectMap: infer SelectMap;
169
156
  } ? null extends SelectMap[keyof SelectMap] ? null : never : never;
170
- export type WhenNullability<State extends BuilderModelState, ConditionPaths extends Paramable<BuilderPaths>, Config extends Paramable<BuilderWhenGeneric>> = [ConditionPaths] extends [BuilderParameter] ? null : WhenNullabilityFromPaths<State['instance'], Extract<ConditionPaths, BuilderValidPaths<State>>, Config>;
157
+ export type ConditionNullability<State extends BuilderModelState, ConditionPaths extends Paramable<BuilderPaths>, Config extends Paramable<BuilderConditionGeneric>> = [ConditionPaths] extends [BuilderParameter] ? null : ConditionNullabilityFromPaths<State['instance'], Extract<ConditionPaths, BuilderValidPaths<State>>, Config>;
171
158
  type BuilderResolvePath<Instance, Path extends BuilderPath> = Path extends readonly [
172
159
  infer Head extends keyof Instance & string
173
160
  ] ? Instance[Head] : Path extends readonly [
174
161
  infer Head extends keyof Instance & string,
175
162
  ...infer Tail extends BuilderPath
176
163
  ] ? Instance[Head] extends ReadonlyArray<infer Item> ? Tail extends readonly [number, ...infer Rest extends BuilderPath] ? BuilderResolvePath<Item, Rest> : never : BuilderResolvePath<Instance[Head], Tail> : never;
177
- type WhenNullabilityFromPaths<Instance, ConditionPaths extends BuilderPaths, Config extends Paramable<BuilderWhenGeneric>> = Config extends BuilderParameter ? WhenPathsNullable<Instance, ConditionPaths> : Config extends BuilderWhenGeneric ? WhenPathsNullable<Instance, ConditionPaths> | WhenConfigNullable<Config> : never;
178
- type WhenPathsNullable<Instance, ConditionPaths extends BuilderPaths> = ConditionPaths extends readonly [
164
+ type ConditionNullabilityFromPaths<Instance, ConditionPaths extends BuilderPaths, Config extends Paramable<BuilderConditionGeneric>> = Config extends BuilderParameter ? ConditionPathsNullable<Instance, ConditionPaths> : Config extends BuilderConditionGeneric ? ConditionPathsNullable<Instance, ConditionPaths> | ConditionConfigNullable<Config> : never;
165
+ type ConditionPathsNullable<Instance, ConditionPaths extends BuilderPaths> = ConditionPaths extends readonly [
179
166
  infer Head extends BuilderPath,
180
167
  ...infer Tail extends BuilderPaths
181
- ] ? WhenPathNullable<Instance, Head> | WhenPathsNullable<Instance, Tail> : never;
182
- type WhenPathNullable<Instance, Path extends BuilderPath> = null extends BuilderResolvePath<Instance, Path> ? null : never;
168
+ ] ? ConditionPathNullable<Instance, Head> | ConditionPathsNullable<Instance, Tail> : never;
169
+ type ConditionPathNullable<Instance, Path extends BuilderPath> = null extends BuilderResolvePath<Instance, Path> ? null : never;
183
170
  type InstanceValidPath<Instance, Depth extends ReadonlyArray<never> = []> = Depth['length'] extends 10 ? never : Instance extends BuilderPrimitive | null ? never : Instance extends ReadonlyArray<infer Item> ? [number] | [number, ...InstanceValidPath<Item, [...Depth, never]>] : {
184
171
  [Key in keyof Instance & string]: [Key] | (Instance[Key] extends BuilderPrimitive | null ? never : [Key, ...InstanceValidPath<Instance[Key], [...Depth, never]>]);
185
172
  }[keyof Instance & string];