@builder-builder/builder 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bb.js +4 -4
- package/dist/client/client.d.ts +2 -1
- package/dist/client/client.js +4 -1
- package/dist/client/public.d.ts +2 -2
- package/dist/client/public.js +1 -1
- package/dist/client/schema.d.ts +79 -18
- package/dist/client/schema.js +6 -1
- package/dist/components/BuilderRender.svelte.d.ts +2 -2
- package/dist/components/index.js +4377 -4303
- package/dist/components/index.min.js +3 -0
- package/dist/entities/collection/collection.d.ts +66 -66
- package/dist/entities/collection/config.d.ts +17 -17
- package/dist/entities/collection/when.d.ts +1 -1
- package/dist/entities/component/component.d.ts +64 -64
- package/dist/entities/component/config.d.ts +33 -33
- package/dist/entities/component/config.js +18 -16
- package/dist/entities/component/detail.d.ts +61 -0
- package/dist/entities/component/detail.js +71 -0
- package/dist/entities/component/index.d.ts +2 -2
- package/dist/entities/component/index.js +1 -1
- package/dist/entities/component/when.d.ts +2 -2
- package/dist/entities/expectation.d.ts +1 -1
- package/dist/entities/index.d.ts +4 -4
- package/dist/entities/index.js +1 -1
- package/dist/entities/kind.d.ts +3 -3
- package/dist/entities/kind.js +20 -20
- package/dist/entities/model/methods.d.ts +1 -1
- package/dist/entities/option/config.d.ts +7 -7
- package/dist/entities/option/config.js +1 -1
- package/dist/entities/option/index.d.ts +4 -4
- package/dist/entities/option/index.js +2 -2
- package/dist/entities/option/option.d.ts +22 -22
- package/dist/entities/option/select.d.ts +1 -1
- package/dist/entities/option/toggle.d.ts +9 -9
- package/dist/entities/option/toggle.js +15 -10
- package/dist/entities/option/when.d.ts +1 -1
- package/dist/entities/paths.d.ts +2 -2
- package/dist/entities/pricing/expression.d.ts +16 -39
- package/dist/entities/pricing/expression.js +1 -16
- package/dist/entities/pricing/index.d.ts +1 -1
- package/dist/entities/pricing/rates.d.ts +1 -1
- package/dist/entities/references.d.ts +24 -24
- package/dist/entities/serialise.d.ts +31 -32
- package/dist/entities/serialise.js +7 -7
- package/dist/entities/ui/describe.d.ts +1 -1
- package/dist/entities/ui/input.d.ts +1 -1
- package/dist/entities/ui/page.d.ts +1 -1
- package/dist/entities/ui/pages.d.ts +2 -2
- package/dist/entities/validated.d.ts +2 -2
- package/dist/entities/when.d.ts +5 -5
- package/dist/environment.d.ts +2 -2
- package/dist/errors/errors.d.ts +86 -55
- package/dist/errors/errors.js +36 -5
- package/dist/errors/exception.d.ts +3 -3
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/errors/public.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/instance.d.ts +53 -9
- package/dist/instance.js +6 -2
- package/dist/mappers/dependencies.d.ts +3 -0
- package/dist/mappers/dependencies.js +44 -0
- package/dist/mappers/index.d.ts +2 -2
- package/dist/mappers/index.js +2 -1
- package/dist/mappers/instance.js +26 -21
- package/dist/mappers/price.js +6 -4
- package/dist/mappers/variants/index.d.ts +1 -2
- package/dist/mappers/variants/index.js +1 -2
- package/dist/mappers/variants/option-graph.d.ts +1 -2
- package/dist/mappers/variants/option-graph.js +3 -17
- package/dist/mappers/variants/variants.d.ts +3 -6
- package/dist/mappers/variants/variants.js +34 -11
- package/dist/primitive.d.ts +3 -0
- package/dist/primitive.js +2 -0
- package/dist/public.d.ts +8 -8
- package/dist/public.js +1 -1
- package/dist/validate/builder.d.ts +2 -2
- package/dist/validate/builder.js +15 -15
- package/dist/validate/expectations.d.ts +2 -2
- package/dist/validate/expectations.js +3 -3
- package/dist/validate/instance.d.ts +2 -2
- package/dist/validate/instance.js +31 -13
- package/dist/validate/model.d.ts +4 -4
- package/dist/validate/model.js +51 -42
- package/dist/validate/paths.d.ts +2 -2
- package/dist/validate/paths.js +19 -14
- package/dist/validate/pricing.d.ts +4 -4
- package/dist/validate/pricing.js +31 -31
- package/dist/validate/resolve.d.ts +2 -2
- package/dist/validate/resolve.js +18 -18
- package/dist/validate/ui.d.ts +4 -4
- package/dist/validate/ui.js +38 -38
- package/dist/validate/variants.d.ts +3 -3
- package/dist/validate/variants.js +32 -31
- package/package.json +4 -2
- package/dist/entities/component/field.d.ts +0 -59
- package/dist/entities/component/field.js +0 -52
|
@@ -28,7 +28,7 @@ export declare const BuilderOptionWhenSerialisedSchema: v.GenericSchema<BuilderW
|
|
|
28
28
|
tags?: readonly string[] | undefined;
|
|
29
29
|
}>> | Readonly<Readonly<{
|
|
30
30
|
type: "toggle";
|
|
31
|
-
|
|
31
|
+
kind: "string" | "number" | "boolean";
|
|
32
32
|
defaultValue: string | number | boolean | null;
|
|
33
33
|
isOptional: boolean;
|
|
34
34
|
tags?: readonly string[] | undefined;
|
|
@@ -49,7 +49,7 @@ export declare const BuilderOptionSelectMapSerialisedSchema: v.GenericSchema<imp
|
|
|
49
49
|
tags?: readonly string[] | undefined;
|
|
50
50
|
}>> | Readonly<Readonly<{
|
|
51
51
|
type: "toggle";
|
|
52
|
-
|
|
52
|
+
kind: "string" | "number" | "boolean";
|
|
53
53
|
defaultValue: string | number | boolean | null;
|
|
54
54
|
isOptional: boolean;
|
|
55
55
|
tags?: readonly string[] | undefined;
|
|
@@ -88,13 +88,13 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
88
88
|
tags?: readonly string[] | undefined;
|
|
89
89
|
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
90
90
|
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
91
|
-
readonly
|
|
91
|
+
readonly kind: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
92
92
|
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
93
93
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
94
94
|
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>;
|
|
95
95
|
}, undefined>, v.ReadonlyAction<{
|
|
96
96
|
type: "toggle";
|
|
97
|
-
|
|
97
|
+
kind: "string" | "number" | "boolean";
|
|
98
98
|
defaultValue: string | number | boolean | null;
|
|
99
99
|
isOptional: boolean;
|
|
100
100
|
tags?: readonly string[] | undefined;
|
|
@@ -109,7 +109,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
109
109
|
tags?: readonly string[] | undefined;
|
|
110
110
|
}> | Readonly<{
|
|
111
111
|
type: "toggle";
|
|
112
|
-
|
|
112
|
+
kind: "string" | "number" | "boolean";
|
|
113
113
|
defaultValue: string | number | boolean | null;
|
|
114
114
|
isOptional: boolean;
|
|
115
115
|
tags?: readonly string[] | undefined;
|
|
@@ -124,7 +124,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
124
124
|
tags?: readonly string[] | undefined;
|
|
125
125
|
}>> | Readonly<Readonly<{
|
|
126
126
|
type: "toggle";
|
|
127
|
-
|
|
127
|
+
kind: "string" | "number" | "boolean";
|
|
128
128
|
defaultValue: string | number | boolean | null;
|
|
129
129
|
isOptional: boolean;
|
|
130
130
|
tags?: readonly string[] | undefined;
|
|
@@ -165,7 +165,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
165
165
|
tags?: readonly string[] | undefined;
|
|
166
166
|
}>> | Readonly<Readonly<{
|
|
167
167
|
type: "toggle";
|
|
168
|
-
|
|
168
|
+
kind: "string" | "number" | "boolean";
|
|
169
169
|
defaultValue: string | number | boolean | null;
|
|
170
170
|
isOptional: boolean;
|
|
171
171
|
tags?: readonly string[] | undefined;
|
|
@@ -180,7 +180,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
180
180
|
tags?: readonly string[] | undefined;
|
|
181
181
|
}>> | Readonly<Readonly<{
|
|
182
182
|
type: "toggle";
|
|
183
|
-
|
|
183
|
+
kind: "string" | "number" | "boolean";
|
|
184
184
|
defaultValue: string | number | boolean | null;
|
|
185
185
|
isOptional: boolean;
|
|
186
186
|
tags?: readonly string[] | undefined;
|
|
@@ -230,13 +230,13 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
230
230
|
tags?: readonly string[] | undefined;
|
|
231
231
|
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
232
232
|
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
233
|
-
readonly
|
|
233
|
+
readonly kind: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
234
234
|
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
235
235
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
236
236
|
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>;
|
|
237
237
|
}, undefined>, v.ReadonlyAction<{
|
|
238
238
|
type: "toggle";
|
|
239
|
-
|
|
239
|
+
kind: "string" | "number" | "boolean";
|
|
240
240
|
defaultValue: string | number | boolean | null;
|
|
241
241
|
isOptional: boolean;
|
|
242
242
|
tags?: readonly string[] | undefined;
|
|
@@ -251,7 +251,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
251
251
|
tags?: readonly string[] | undefined;
|
|
252
252
|
}> | Readonly<{
|
|
253
253
|
type: "toggle";
|
|
254
|
-
|
|
254
|
+
kind: "string" | "number" | "boolean";
|
|
255
255
|
defaultValue: string | number | boolean | null;
|
|
256
256
|
isOptional: boolean;
|
|
257
257
|
tags?: readonly string[] | undefined;
|
|
@@ -266,7 +266,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
266
266
|
tags?: readonly string[] | undefined;
|
|
267
267
|
}>> | Readonly<Readonly<{
|
|
268
268
|
type: "toggle";
|
|
269
|
-
|
|
269
|
+
kind: "string" | "number" | "boolean";
|
|
270
270
|
defaultValue: string | number | boolean | null;
|
|
271
271
|
isOptional: boolean;
|
|
272
272
|
tags?: readonly string[] | undefined;
|
|
@@ -307,7 +307,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
307
307
|
tags?: readonly string[] | undefined;
|
|
308
308
|
}>> | Readonly<Readonly<{
|
|
309
309
|
type: "toggle";
|
|
310
|
-
|
|
310
|
+
kind: "string" | "number" | "boolean";
|
|
311
311
|
defaultValue: string | number | boolean | null;
|
|
312
312
|
isOptional: boolean;
|
|
313
313
|
tags?: readonly string[] | undefined;
|
|
@@ -322,7 +322,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
322
322
|
tags?: readonly string[] | undefined;
|
|
323
323
|
}>> | Readonly<Readonly<{
|
|
324
324
|
type: "toggle";
|
|
325
|
-
|
|
325
|
+
kind: "string" | "number" | "boolean";
|
|
326
326
|
defaultValue: string | number | boolean | null;
|
|
327
327
|
isOptional: boolean;
|
|
328
328
|
tags?: readonly string[] | undefined;
|
|
@@ -356,7 +356,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
356
356
|
tags?: readonly string[] | undefined;
|
|
357
357
|
}>> | Readonly<Readonly<{
|
|
358
358
|
type: "toggle";
|
|
359
|
-
|
|
359
|
+
kind: "string" | "number" | "boolean";
|
|
360
360
|
defaultValue: string | number | boolean | null;
|
|
361
361
|
isOptional: boolean;
|
|
362
362
|
tags?: readonly string[] | undefined;
|
|
@@ -371,7 +371,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
371
371
|
tags?: readonly string[] | undefined;
|
|
372
372
|
}>> | Readonly<Readonly<{
|
|
373
373
|
type: "toggle";
|
|
374
|
-
|
|
374
|
+
kind: "string" | "number" | "boolean";
|
|
375
375
|
defaultValue: string | number | boolean | null;
|
|
376
376
|
isOptional: boolean;
|
|
377
377
|
tags?: readonly string[] | undefined;
|
|
@@ -387,7 +387,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
387
387
|
tags?: readonly string[] | undefined;
|
|
388
388
|
}>[]>]>;
|
|
389
389
|
export type BuilderOptionsSerialised = v.InferOutput<typeof BuilderOptionsSerialisedSchema>;
|
|
390
|
-
export declare const validateOptionWhen: (input: unknown, references?: import("..").BuilderReferences,
|
|
390
|
+
export declare const validateOptionWhen: (input: unknown, references?: import("..").BuilderReferences, issues?: import("../../errors").BuilderIssuesScope) => import("..").ValidationResult<{
|
|
391
391
|
readonly type: "enable";
|
|
392
392
|
readonly payload: {
|
|
393
393
|
readonly type: "select";
|
|
@@ -400,7 +400,7 @@ export declare const validateOptionWhen: (input: unknown, references?: import(".
|
|
|
400
400
|
readonly tags?: readonly string[] | undefined;
|
|
401
401
|
} | {
|
|
402
402
|
readonly type: "toggle";
|
|
403
|
-
readonly
|
|
403
|
+
readonly kind: "string" | "number" | "boolean";
|
|
404
404
|
readonly defaultValue: string | number | boolean | null;
|
|
405
405
|
readonly isOptional: boolean;
|
|
406
406
|
readonly tags?: readonly string[] | undefined;
|
|
@@ -420,7 +420,7 @@ export declare const validateOptionWhen: (input: unknown, references?: import(".
|
|
|
420
420
|
readonly tags?: readonly string[] | undefined;
|
|
421
421
|
} | {
|
|
422
422
|
readonly type: "toggle";
|
|
423
|
-
readonly
|
|
423
|
+
readonly kind: "string" | "number" | "boolean";
|
|
424
424
|
readonly defaultValue: string | number | boolean | null;
|
|
425
425
|
readonly isOptional: boolean;
|
|
426
426
|
readonly tags?: readonly string[] | undefined;
|
|
@@ -441,13 +441,13 @@ export declare const validateOptionWhen: (input: unknown, references?: import(".
|
|
|
441
441
|
readonly tags?: readonly string[] | undefined;
|
|
442
442
|
} | {
|
|
443
443
|
readonly type: "toggle";
|
|
444
|
-
readonly
|
|
444
|
+
readonly kind: "string" | "number" | "boolean";
|
|
445
445
|
readonly defaultValue: string | number | boolean | null;
|
|
446
446
|
readonly isOptional: boolean;
|
|
447
447
|
readonly tags?: readonly string[] | undefined;
|
|
448
448
|
};
|
|
449
449
|
}>;
|
|
450
|
-
export declare const validateOptionSelectMap: (input: unknown, references?: import("..").BuilderReferences,
|
|
450
|
+
export declare const validateOptionSelectMap: (input: unknown, references?: import("..").BuilderReferences, issues?: import("../../errors").BuilderIssuesScope) => import("..").ValidationResult<{
|
|
451
451
|
readonly [x: string]: {
|
|
452
452
|
readonly type: "select";
|
|
453
453
|
readonly options: readonly [string, ...string[]];
|
|
@@ -459,7 +459,7 @@ export declare const validateOptionSelectMap: (input: unknown, references?: impo
|
|
|
459
459
|
readonly tags?: readonly string[] | undefined;
|
|
460
460
|
} | {
|
|
461
461
|
readonly type: "toggle";
|
|
462
|
-
readonly
|
|
462
|
+
readonly kind: "string" | "number" | "boolean";
|
|
463
463
|
readonly defaultValue: string | number | boolean | null;
|
|
464
464
|
readonly isOptional: boolean;
|
|
465
465
|
readonly tags?: readonly string[] | undefined;
|
|
@@ -42,7 +42,7 @@ export declare const BuilderSelectConfigSerialisedSchema: v.SchemaWithPipe<reado
|
|
|
42
42
|
}>]>;
|
|
43
43
|
export type BuilderSelectConfigSerialised = v.InferOutput<typeof BuilderSelectConfigSerialisedSchema>;
|
|
44
44
|
export declare function selectValueSchema(options: ReadonlyArray<string>, optional: boolean): v.GenericSchema<string | null>;
|
|
45
|
-
export declare const validateSelect: (input: unknown, references?: import("..").BuilderReferences,
|
|
45
|
+
export declare const validateSelect: (input: unknown, references?: import("..").BuilderReferences, issues?: import("../../errors").BuilderIssuesScope) => import("..").ValidationResult<{
|
|
46
46
|
readonly type: "select";
|
|
47
47
|
readonly options: readonly [string, ...string[]];
|
|
48
48
|
readonly defaultValue: string | null;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { BuilderPrimitive } from '../../primitive';
|
|
2
2
|
import type { BuilderTags } from '../tags';
|
|
3
3
|
import * as v from 'valibot';
|
|
4
|
-
export declare const
|
|
5
|
-
export type
|
|
4
|
+
export declare const BuilderToggleKindSchema: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
5
|
+
export type BuilderToggleKind = v.InferOutput<typeof BuilderToggleKindSchema>;
|
|
6
6
|
export declare class BuilderToggleConfig<const ValueSchema extends v.GenericSchema<BuilderPrimitive> = v.GenericSchema<BuilderPrimitive>> {
|
|
7
7
|
#private;
|
|
8
8
|
readonly value: v.InferOutput<ValueSchema>;
|
|
9
9
|
readonly type: "toggle";
|
|
10
|
-
readonly
|
|
10
|
+
readonly kind: BuilderToggleKind;
|
|
11
11
|
readonly valueSchema: ValueSchema;
|
|
12
12
|
readonly defaultValue: v.InferOutput<ValueSchema>;
|
|
13
13
|
readonly isOptional: boolean;
|
|
14
14
|
readonly tags?: BuilderTags;
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(kind: BuilderToggleKind, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean, tags?: BuilderTags);
|
|
16
16
|
default(newDefault: v.InferOutput<ValueSchema>): BuilderToggleConfig<ValueSchema>;
|
|
17
17
|
optional(): BuilderToggleConfig<v.NullableSchema<ValueSchema, undefined>>;
|
|
18
18
|
tag(...tags: Array<string>): BuilderToggleConfig<ValueSchema>;
|
|
@@ -23,22 +23,22 @@ export declare function toggleNumber(): BuilderToggleConfig<v.NumberSchema<undef
|
|
|
23
23
|
export declare const BuilderToggleConfigSchema: v.InstanceSchema<typeof BuilderToggleConfig, undefined>;
|
|
24
24
|
export declare const BuilderToggleConfigSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
25
25
|
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
26
|
-
readonly
|
|
26
|
+
readonly kind: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
27
27
|
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
28
28
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
29
29
|
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>;
|
|
30
30
|
}, undefined>, v.ReadonlyAction<{
|
|
31
31
|
type: "toggle";
|
|
32
|
-
|
|
32
|
+
kind: "string" | "number" | "boolean";
|
|
33
33
|
defaultValue: string | number | boolean | null;
|
|
34
34
|
isOptional: boolean;
|
|
35
35
|
tags?: readonly string[] | undefined;
|
|
36
36
|
}>]>;
|
|
37
37
|
export type BuilderToggleConfigSerialised = v.InferOutput<typeof BuilderToggleConfigSerialisedSchema>;
|
|
38
|
-
export declare function toggleValueSchema(
|
|
39
|
-
export declare const validateToggle: (input: unknown, references?: import("..").BuilderReferences,
|
|
38
|
+
export declare function toggleValueSchema(kind: BuilderToggleKind, optional: boolean): v.GenericSchema;
|
|
39
|
+
export declare const validateToggle: (input: unknown, references?: import("..").BuilderReferences, issues?: import("../../errors/errors").BuilderIssuesScope) => import("..").ValidationResult<{
|
|
40
40
|
readonly type: "toggle";
|
|
41
|
-
readonly
|
|
41
|
+
readonly kind: "string" | "number" | "boolean";
|
|
42
42
|
readonly defaultValue: string | number | boolean | null;
|
|
43
43
|
readonly isOptional: boolean;
|
|
44
44
|
readonly tags?: readonly string[] | undefined;
|
|
@@ -4,23 +4,23 @@ import { BooleanSchema, NumberSchema, StringSchema } from '../../primitive.js';
|
|
|
4
4
|
import { createEntityValidator } from '../kind.js';
|
|
5
5
|
import { serialisable } from '../serialisable.js';
|
|
6
6
|
import { BuilderTagsSchema } from '../tags.js';
|
|
7
|
-
export const
|
|
7
|
+
export const BuilderToggleKindSchema = v.picklist(['string', 'boolean', 'number']);
|
|
8
8
|
export class BuilderToggleConfig {
|
|
9
9
|
type = 'toggle';
|
|
10
|
-
|
|
10
|
+
kind;
|
|
11
11
|
valueSchema;
|
|
12
12
|
defaultValue;
|
|
13
13
|
isOptional;
|
|
14
14
|
tags;
|
|
15
|
-
constructor(
|
|
16
|
-
this.
|
|
17
|
-
this.valueSchema = toggleValueSchema(
|
|
15
|
+
constructor(kind, defaultValue, optional, tags) {
|
|
16
|
+
this.kind = kind;
|
|
17
|
+
this.valueSchema = toggleValueSchema(kind, optional || false);
|
|
18
18
|
this.defaultValue = defaultValue;
|
|
19
19
|
this.isOptional = optional || false;
|
|
20
20
|
this.tags = tags;
|
|
21
21
|
}
|
|
22
22
|
#next(patch) {
|
|
23
|
-
return new BuilderToggleConfig(this.
|
|
23
|
+
return new BuilderToggleConfig(this.kind, 'defaultValue' in patch
|
|
24
24
|
? patch.defaultValue
|
|
25
25
|
: this.defaultValue, patch.optional ?? this.isOptional, patch.tags ?? this.tags);
|
|
26
26
|
}
|
|
@@ -46,20 +46,25 @@ export function toggleNumber() {
|
|
|
46
46
|
export const BuilderToggleConfigSchema = v.instance(BuilderToggleConfig);
|
|
47
47
|
export const BuilderToggleConfigSerialisedSchema = serialisable(v.object({
|
|
48
48
|
type: v.literal('toggle'),
|
|
49
|
-
|
|
49
|
+
kind: BuilderToggleKindSchema,
|
|
50
50
|
defaultValue: v.nullable(v.union([BooleanSchema, StringSchema, NumberSchema])),
|
|
51
51
|
isOptional: BooleanSchema,
|
|
52
52
|
tags: v.optional(BuilderTagsSchema)
|
|
53
53
|
}));
|
|
54
|
-
export function toggleValueSchema(
|
|
55
|
-
const
|
|
54
|
+
export function toggleValueSchema(kind, optional) {
|
|
55
|
+
const kindSchemas = {
|
|
56
|
+
string: StringSchema,
|
|
57
|
+
boolean: BooleanSchema,
|
|
58
|
+
number: NumberSchema
|
|
59
|
+
};
|
|
60
|
+
const baseSchema = kindSchemas[kind];
|
|
56
61
|
return optional ? v.nullable(baseSchema) : baseSchema;
|
|
57
62
|
}
|
|
58
63
|
export const validateToggle = createEntityValidator('toggle', BuilderToggleConfigSerialisedSchema, (input, errors) => {
|
|
59
64
|
if (input.defaultValue == null) {
|
|
60
65
|
return;
|
|
61
66
|
}
|
|
62
|
-
const valueSchema = toggleValueSchema(input.
|
|
67
|
+
const valueSchema = toggleValueSchema(input.kind, input.isOptional);
|
|
63
68
|
if (!check.is(valueSchema, input.defaultValue)) {
|
|
64
69
|
errors.scope('defaultValue', () => errors.entityInvalidToggleDefault());
|
|
65
70
|
}
|
|
@@ -6,5 +6,5 @@ export type BuilderOptionWhen = BuilderWhen<Paramable<BuilderOptionConfig>, Para
|
|
|
6
6
|
export declare const optionWhen: {
|
|
7
7
|
enable: <const Values extends Paramable<import("./select").BuilderSelectConfig<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import("./toggle").BuilderToggleConfig<import("valibot").GenericSchema<string | number | boolean | null>>>>(values: Values) => import("..").BuilderEnableConfig<Values>;
|
|
8
8
|
match: <const MatchPayload extends Paramable<import("./select").BuilderSelectConfig<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import("./toggle").BuilderToggleConfig<import("valibot").GenericSchema<string | number | boolean | null>>>, const MatchPath extends Paramable<BuilderPath>, const SelectMap extends Paramable<import("..").BuilderMatchSelectMap<Paramable<import("./select").BuilderSelectConfig<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import("./toggle").BuilderToggleConfig<import("valibot").GenericSchema<string | number | boolean | null>>>>>>(matchPath: MatchPath, selectMap: SelectMap) => import("..").BuilderMatchConfig<MatchPayload, MatchPath, SelectMap>;
|
|
9
|
-
unless: <const Values extends Paramable<import("./select").BuilderSelectConfig<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import("./toggle").BuilderToggleConfig<import("valibot").GenericSchema<string | number | boolean | null>>>, const UnlessPath extends Paramable<BuilderPath>>(unlessPath: UnlessPath, disabledValues: import("
|
|
9
|
+
unless: <const Values extends Paramable<import("./select").BuilderSelectConfig<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import("./toggle").BuilderToggleConfig<import("valibot").GenericSchema<string | number | boolean | null>>>, const UnlessPath extends Paramable<BuilderPath>>(unlessPath: UnlessPath, disabledValues: import("../../primitive").BuilderPrimitivesNonEmpty, values: Values) => import("..").BuilderUnlessConfig<Values, UnlessPath>;
|
|
10
10
|
};
|
package/dist/entities/paths.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export declare const BuilderPathSchema: v.SchemaWithPipe<readonly [v.ArraySchema
|
|
|
3
3
|
export type BuilderPath = v.InferOutput<typeof BuilderPathSchema>;
|
|
4
4
|
export declare const BuilderPathsSchema: v.SchemaWithPipe<readonly [v.ArraySchema<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>, v.ReadonlyAction<(readonly (string | number)[])[]>]>;
|
|
5
5
|
export type BuilderPaths = v.InferOutput<typeof BuilderPathsSchema>;
|
|
6
|
-
export declare const validatePath: (input: unknown, references?: import("./references.js").BuilderReferences,
|
|
7
|
-
export declare const validatePaths: (input: unknown, references?: import("./references.js").BuilderReferences,
|
|
6
|
+
export declare const validatePath: (input: unknown, references?: import("./references.js").BuilderReferences, issues?: import("../errors/errors.js").BuilderIssuesScope) => import("./validated.js").ValidationResult<readonly (string | number)[]>;
|
|
7
|
+
export declare const validatePaths: (input: unknown, references?: import("./references.js").BuilderReferences, issues?: import("../errors/errors.js").BuilderIssuesScope) => import("./validated.js").ValidationResult<readonly (readonly (string | number)[])[]>;
|
|
@@ -9,62 +9,39 @@ export type BuilderPricingLookupKey = {
|
|
|
9
9
|
readonly name: string;
|
|
10
10
|
};
|
|
11
11
|
export declare const BuilderPricingLookupKeySchema: v.GenericSchema<BuilderPricingLookupKey>;
|
|
12
|
-
|
|
12
|
+
type BuilderPricingLiteral = number;
|
|
13
|
+
type BuilderPricingVariantPrice = {
|
|
13
14
|
readonly kind: 'variantPrice';
|
|
14
|
-
}
|
|
15
|
+
};
|
|
16
|
+
export type BuilderPricingLookup = {
|
|
15
17
|
readonly kind: 'lookup';
|
|
16
18
|
readonly rate: string;
|
|
17
19
|
readonly key: BuilderPricingLookupKey;
|
|
18
20
|
readonly reduce?: BuilderPricingReduce;
|
|
19
|
-
}
|
|
21
|
+
};
|
|
22
|
+
export type BuilderPricingVariants = {
|
|
20
23
|
readonly kind: 'variants';
|
|
21
24
|
readonly tag?: string;
|
|
22
25
|
readonly expression: Paramable<BuilderPricingExpression>;
|
|
23
26
|
readonly reduce?: BuilderPricingReduce;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
readonly
|
|
27
|
-
readonly right: Paramable<BuilderPricingExpression>;
|
|
28
|
-
} | {
|
|
29
|
-
readonly kind: 'sub';
|
|
30
|
-
readonly left: Paramable<BuilderPricingExpression>;
|
|
31
|
-
readonly right: Paramable<BuilderPricingExpression>;
|
|
32
|
-
} | {
|
|
33
|
-
readonly kind: 'mul';
|
|
34
|
-
readonly left: Paramable<BuilderPricingExpression>;
|
|
35
|
-
readonly right: Paramable<BuilderPricingExpression>;
|
|
36
|
-
} | {
|
|
37
|
-
readonly kind: 'div';
|
|
27
|
+
};
|
|
28
|
+
type BuilderPricingArithmetic = {
|
|
29
|
+
readonly kind: 'add' | 'sub' | 'mul' | 'div';
|
|
38
30
|
readonly left: Paramable<BuilderPricingExpression>;
|
|
39
31
|
readonly right: Paramable<BuilderPricingExpression>;
|
|
40
32
|
};
|
|
41
|
-
export type
|
|
42
|
-
|
|
43
|
-
} | {
|
|
44
|
-
readonly kind: 'lookup';
|
|
45
|
-
readonly rate: string;
|
|
46
|
-
readonly key: BuilderPricingLookupKey;
|
|
47
|
-
readonly reduce?: BuilderPricingReduce;
|
|
48
|
-
} | {
|
|
33
|
+
export type BuilderPricingExpression = BuilderPricingLiteral | BuilderPricingVariantPrice | BuilderPricingLookup | BuilderPricingVariants | BuilderPricingArithmetic;
|
|
34
|
+
type BuilderPricingVariantsSerialised = {
|
|
49
35
|
readonly kind: 'variants';
|
|
50
36
|
readonly tag?: string;
|
|
51
37
|
readonly expression: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
52
38
|
readonly reduce?: BuilderPricingReduce;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
readonly
|
|
56
|
-
readonly right: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
57
|
-
} | {
|
|
58
|
-
readonly kind: 'sub';
|
|
59
|
-
readonly left: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
60
|
-
readonly right: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
61
|
-
} | {
|
|
62
|
-
readonly kind: 'mul';
|
|
63
|
-
readonly left: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
64
|
-
readonly right: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
65
|
-
} | {
|
|
66
|
-
readonly kind: 'div';
|
|
39
|
+
};
|
|
40
|
+
type BuilderPricingArithmeticSerialised = {
|
|
41
|
+
readonly kind: 'add' | 'sub' | 'mul' | 'div';
|
|
67
42
|
readonly left: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
68
43
|
readonly right: ParamableSerialised<BuilderPricingExpressionSerialised>;
|
|
69
44
|
};
|
|
45
|
+
export type BuilderPricingExpressionSerialised = BuilderPricingLiteral | BuilderPricingVariantPrice | BuilderPricingLookup | BuilderPricingVariantsSerialised | BuilderPricingArithmeticSerialised;
|
|
70
46
|
export declare const BuilderPricingExpressionSchema: v.GenericSchema<BuilderPricingExpression>;
|
|
47
|
+
export {};
|
|
@@ -22,22 +22,7 @@ export const BuilderPricingExpressionSchema = v.lazy(() => v.union([
|
|
|
22
22
|
reduce: v.optional(BuilderPricingReduceSchema)
|
|
23
23
|
}),
|
|
24
24
|
v.object({
|
|
25
|
-
kind: v.
|
|
26
|
-
left: paramable(BuilderPricingExpressionSchema),
|
|
27
|
-
right: paramable(BuilderPricingExpressionSchema)
|
|
28
|
-
}),
|
|
29
|
-
v.object({
|
|
30
|
-
kind: v.literal('sub'),
|
|
31
|
-
left: paramable(BuilderPricingExpressionSchema),
|
|
32
|
-
right: paramable(BuilderPricingExpressionSchema)
|
|
33
|
-
}),
|
|
34
|
-
v.object({
|
|
35
|
-
kind: v.literal('mul'),
|
|
36
|
-
left: paramable(BuilderPricingExpressionSchema),
|
|
37
|
-
right: paramable(BuilderPricingExpressionSchema)
|
|
38
|
-
}),
|
|
39
|
-
v.object({
|
|
40
|
-
kind: v.literal('div'),
|
|
25
|
+
kind: v.picklist(['add', 'sub', 'mul', 'div']),
|
|
41
26
|
left: paramable(BuilderPricingExpressionSchema),
|
|
42
27
|
right: paramable(BuilderPricingExpressionSchema)
|
|
43
28
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { BuilderPricingExpression, BuilderPricingLookupKey, BuilderPricingReduce } from './expression';
|
|
1
|
+
export type { BuilderPricingExpression, BuilderPricingLookup, BuilderPricingLookupKey, BuilderPricingReduce, BuilderPricingVariants } from './expression';
|
|
2
2
|
export type { BuilderRates } from './rates';
|
|
3
3
|
export type { BuilderPricingSerialised } from './pricing';
|
|
4
4
|
export { BuilderPricingExpressionSchema, BuilderPricingLookupKeySchema, BuilderPricingReduceSchema } from './expression.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
export type BuilderRates = Record<string, Record<string, number>>;
|
|
3
3
|
export declare const BuilderRatesSchema: v.GenericSchema<BuilderRates>;
|
|
4
|
-
export declare const validatePricingRates: (input: unknown, references?: import("../references.js").BuilderReferences,
|
|
4
|
+
export declare const validatePricingRates: (input: unknown, references?: import("../references.js").BuilderReferences, issues?: import("../../errors/errors.js").BuilderIssuesScope) => import("../validated.js").ValidationResult<{
|
|
5
5
|
readonly [x: string]: {
|
|
6
6
|
readonly [x: string]: number;
|
|
7
7
|
} & import("../../validate/brand.js").BuilderValidatedBrand;
|
|
@@ -12,7 +12,7 @@ export declare const BuilderReferenceSchema: v.ObjectSchema<{
|
|
|
12
12
|
tags?: readonly string[] | undefined;
|
|
13
13
|
}> | Readonly<{
|
|
14
14
|
type: "toggle";
|
|
15
|
-
|
|
15
|
+
kind: "string" | "number" | "boolean";
|
|
16
16
|
defaultValue: string | number | boolean | null;
|
|
17
17
|
isOptional: boolean;
|
|
18
18
|
tags?: readonly string[] | undefined;
|
|
@@ -31,7 +31,7 @@ export declare const BuilderReferenceSchema: v.ObjectSchema<{
|
|
|
31
31
|
tags?: readonly string[] | undefined;
|
|
32
32
|
}>> | Readonly<Readonly<{
|
|
33
33
|
type: "toggle";
|
|
34
|
-
|
|
34
|
+
kind: "string" | "number" | "boolean";
|
|
35
35
|
defaultValue: string | number | boolean | null;
|
|
36
36
|
isOptional: boolean;
|
|
37
37
|
tags?: readonly string[] | undefined;
|
|
@@ -46,12 +46,12 @@ export declare const BuilderReferenceSchema: v.ObjectSchema<{
|
|
|
46
46
|
tags?: readonly string[] | undefined;
|
|
47
47
|
}>> | Readonly<Readonly<{
|
|
48
48
|
type: "toggle";
|
|
49
|
-
|
|
49
|
+
kind: "string" | "number" | "boolean";
|
|
50
50
|
defaultValue: string | number | boolean | null;
|
|
51
51
|
isOptional: boolean;
|
|
52
52
|
tags?: readonly string[] | undefined;
|
|
53
53
|
}>>> | Readonly<{
|
|
54
|
-
|
|
54
|
+
details: Readonly<{
|
|
55
55
|
type: "parameter";
|
|
56
56
|
id: string;
|
|
57
57
|
name: string;
|
|
@@ -59,9 +59,9 @@ export declare const BuilderReferenceSchema: v.ObjectSchema<{
|
|
|
59
59
|
type: "ref";
|
|
60
60
|
id: string;
|
|
61
61
|
}> | readonly Readonly<{
|
|
62
|
-
type: "component-
|
|
62
|
+
type: "component-detail";
|
|
63
63
|
name: string;
|
|
64
|
-
|
|
64
|
+
kind: "string" | "number" | "boolean" | "price" | "image";
|
|
65
65
|
isOptional: boolean;
|
|
66
66
|
tags?: readonly string[] | undefined;
|
|
67
67
|
}>[];
|
|
@@ -71,7 +71,7 @@ export declare const BuilderReferenceSchema: v.ObjectSchema<{
|
|
|
71
71
|
id: string;
|
|
72
72
|
name: string;
|
|
73
73
|
}> | Readonly<{
|
|
74
|
-
|
|
74
|
+
details: Readonly<{
|
|
75
75
|
type: "parameter";
|
|
76
76
|
id: string;
|
|
77
77
|
name: string;
|
|
@@ -79,15 +79,15 @@ export declare const BuilderReferenceSchema: v.ObjectSchema<{
|
|
|
79
79
|
type: "ref";
|
|
80
80
|
id: string;
|
|
81
81
|
}> | readonly Readonly<{
|
|
82
|
-
type: "component-
|
|
82
|
+
type: "component-detail";
|
|
83
83
|
name: string;
|
|
84
|
-
|
|
84
|
+
kind: "string" | "number" | "boolean" | "price" | "image";
|
|
85
85
|
isOptional: boolean;
|
|
86
86
|
tags?: readonly string[] | undefined;
|
|
87
87
|
}>[];
|
|
88
88
|
tags?: readonly string[] | undefined;
|
|
89
89
|
}>> | import("./when.js").BuilderWhenSerialised<Readonly<{
|
|
90
|
-
|
|
90
|
+
details: Readonly<{
|
|
91
91
|
type: "parameter";
|
|
92
92
|
id: string;
|
|
93
93
|
name: string;
|
|
@@ -95,9 +95,9 @@ export declare const BuilderReferenceSchema: v.ObjectSchema<{
|
|
|
95
95
|
type: "ref";
|
|
96
96
|
id: string;
|
|
97
97
|
}> | readonly Readonly<{
|
|
98
|
-
type: "component-
|
|
98
|
+
type: "component-detail";
|
|
99
99
|
name: string;
|
|
100
|
-
|
|
100
|
+
kind: "string" | "number" | "boolean" | "price" | "image";
|
|
101
101
|
isOptional: boolean;
|
|
102
102
|
tags?: readonly string[] | undefined;
|
|
103
103
|
}>[];
|
|
@@ -397,7 +397,7 @@ export declare const BuilderReferencesSchema: v.ArraySchema<v.ObjectSchema<{
|
|
|
397
397
|
tags?: readonly string[] | undefined;
|
|
398
398
|
}> | Readonly<{
|
|
399
399
|
type: "toggle";
|
|
400
|
-
|
|
400
|
+
kind: "string" | "number" | "boolean";
|
|
401
401
|
defaultValue: string | number | boolean | null;
|
|
402
402
|
isOptional: boolean;
|
|
403
403
|
tags?: readonly string[] | undefined;
|
|
@@ -416,7 +416,7 @@ export declare const BuilderReferencesSchema: v.ArraySchema<v.ObjectSchema<{
|
|
|
416
416
|
tags?: readonly string[] | undefined;
|
|
417
417
|
}>> | Readonly<Readonly<{
|
|
418
418
|
type: "toggle";
|
|
419
|
-
|
|
419
|
+
kind: "string" | "number" | "boolean";
|
|
420
420
|
defaultValue: string | number | boolean | null;
|
|
421
421
|
isOptional: boolean;
|
|
422
422
|
tags?: readonly string[] | undefined;
|
|
@@ -431,12 +431,12 @@ export declare const BuilderReferencesSchema: v.ArraySchema<v.ObjectSchema<{
|
|
|
431
431
|
tags?: readonly string[] | undefined;
|
|
432
432
|
}>> | Readonly<Readonly<{
|
|
433
433
|
type: "toggle";
|
|
434
|
-
|
|
434
|
+
kind: "string" | "number" | "boolean";
|
|
435
435
|
defaultValue: string | number | boolean | null;
|
|
436
436
|
isOptional: boolean;
|
|
437
437
|
tags?: readonly string[] | undefined;
|
|
438
438
|
}>>> | Readonly<{
|
|
439
|
-
|
|
439
|
+
details: Readonly<{
|
|
440
440
|
type: "parameter";
|
|
441
441
|
id: string;
|
|
442
442
|
name: string;
|
|
@@ -444,9 +444,9 @@ export declare const BuilderReferencesSchema: v.ArraySchema<v.ObjectSchema<{
|
|
|
444
444
|
type: "ref";
|
|
445
445
|
id: string;
|
|
446
446
|
}> | readonly Readonly<{
|
|
447
|
-
type: "component-
|
|
447
|
+
type: "component-detail";
|
|
448
448
|
name: string;
|
|
449
|
-
|
|
449
|
+
kind: "string" | "number" | "boolean" | "price" | "image";
|
|
450
450
|
isOptional: boolean;
|
|
451
451
|
tags?: readonly string[] | undefined;
|
|
452
452
|
}>[];
|
|
@@ -456,7 +456,7 @@ export declare const BuilderReferencesSchema: v.ArraySchema<v.ObjectSchema<{
|
|
|
456
456
|
id: string;
|
|
457
457
|
name: string;
|
|
458
458
|
}> | Readonly<{
|
|
459
|
-
|
|
459
|
+
details: Readonly<{
|
|
460
460
|
type: "parameter";
|
|
461
461
|
id: string;
|
|
462
462
|
name: string;
|
|
@@ -464,15 +464,15 @@ export declare const BuilderReferencesSchema: v.ArraySchema<v.ObjectSchema<{
|
|
|
464
464
|
type: "ref";
|
|
465
465
|
id: string;
|
|
466
466
|
}> | readonly Readonly<{
|
|
467
|
-
type: "component-
|
|
467
|
+
type: "component-detail";
|
|
468
468
|
name: string;
|
|
469
|
-
|
|
469
|
+
kind: "string" | "number" | "boolean" | "price" | "image";
|
|
470
470
|
isOptional: boolean;
|
|
471
471
|
tags?: readonly string[] | undefined;
|
|
472
472
|
}>[];
|
|
473
473
|
tags?: readonly string[] | undefined;
|
|
474
474
|
}>> | import("./when.js").BuilderWhenSerialised<Readonly<{
|
|
475
|
-
|
|
475
|
+
details: Readonly<{
|
|
476
476
|
type: "parameter";
|
|
477
477
|
id: string;
|
|
478
478
|
name: string;
|
|
@@ -480,9 +480,9 @@ export declare const BuilderReferencesSchema: v.ArraySchema<v.ObjectSchema<{
|
|
|
480
480
|
type: "ref";
|
|
481
481
|
id: string;
|
|
482
482
|
}> | readonly Readonly<{
|
|
483
|
-
type: "component-
|
|
483
|
+
type: "component-detail";
|
|
484
484
|
name: string;
|
|
485
|
-
|
|
485
|
+
kind: "string" | "number" | "boolean" | "price" | "image";
|
|
486
486
|
isOptional: boolean;
|
|
487
487
|
tags?: readonly string[] | undefined;
|
|
488
488
|
}>[];
|