@builder-builder/builder 0.0.24 → 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.
- package/dist/client/client.d.ts +3 -1
- package/dist/client/client.js +29 -20
- package/dist/client/index.d.ts +1 -4
- package/dist/client/index.js +1 -2
- package/dist/client/public.d.ts +4 -0
- package/dist/client/public.js +2 -0
- package/dist/client/schema.d.ts +26 -18
- package/dist/client/schema.js +7 -1
- package/dist/entities/builder/builder.js +2 -1
- package/dist/entities/collection/collection.d.ts +2 -2
- package/dist/entities/collection/collection.js +2 -1
- package/dist/entities/collection/config.d.ts +21 -21
- package/dist/entities/collection/config.js +4 -3
- package/dist/entities/component/component.d.ts +32 -32
- package/dist/entities/component/component.js +2 -1
- package/dist/entities/component/config.d.ts +13 -13
- package/dist/entities/component/config.js +1 -1
- package/dist/entities/component/field.d.ts +4 -4
- package/dist/entities/component/field.js +4 -3
- package/dist/entities/expectation.d.ts +3 -3
- package/dist/entities/expectation.js +2 -1
- package/dist/entities/index.d.ts +1 -1
- package/dist/entities/kind.d.ts +4 -4
- package/dist/entities/kind.js +44 -4
- package/dist/entities/model/models.d.ts +3 -3
- package/dist/entities/option/config.d.ts +4 -4
- package/dist/entities/option/option.d.ts +24 -24
- package/dist/entities/option/option.js +2 -1
- package/dist/entities/option/select.d.ts +2 -2
- package/dist/entities/option/select.js +12 -9
- package/dist/entities/option/toggle.d.ts +2 -2
- package/dist/entities/option/toggle.js +5 -4
- package/dist/entities/paths.d.ts +4 -4
- package/dist/entities/paths.js +2 -1
- package/dist/entities/pricing/expression.js +5 -4
- package/dist/entities/pricing/rates.d.ts +1 -1
- package/dist/entities/pricing/rates.js +2 -1
- package/dist/entities/references.d.ts +2 -2
- package/dist/entities/references.js +2 -1
- package/dist/entities/serialise.d.ts +204 -116
- package/dist/entities/serialise.js +4 -3
- package/dist/entities/tags.d.ts +1 -1
- package/dist/entities/tags.js +2 -1
- package/dist/entities/ui/describe.d.ts +79 -35
- package/dist/entities/ui/describe.js +5 -4
- package/dist/entities/ui/input.d.ts +93 -49
- package/dist/entities/ui/input.js +5 -4
- package/dist/entities/ui/page.d.ts +77 -33
- package/dist/entities/ui/page.js +4 -3
- package/dist/entities/ui/pages.d.ts +5 -5
- package/dist/entities/ui/pages.js +5 -4
- package/dist/entities/validated.d.ts +1 -0
- package/dist/entities/when.d.ts +16 -16
- package/dist/entities/when.js +2 -2
- package/dist/errors/check.d.ts +2 -3
- package/dist/errors/check.js +5 -10
- package/dist/errors/errors.d.ts +241 -158
- package/dist/errors/errors.js +149 -173
- package/dist/errors/exception.d.ts +6 -4
- package/dist/errors/exception.js +11 -66
- package/dist/errors/index.d.ts +2 -4
- package/dist/errors/index.js +2 -2
- package/dist/errors/public.d.ts +2 -0
- package/dist/errors/public.js +1 -0
- package/dist/index.d.ts +4 -36
- package/dist/index.js +4 -19
- package/dist/instance.d.ts +7 -7
- package/dist/instance.js +4 -4
- package/dist/mappers/index.d.ts +1 -1
- package/dist/mappers/price.js +2 -3
- package/dist/mappers/render/collection.d.ts +9 -0
- package/dist/mappers/render/collection.js +27 -0
- package/dist/mappers/render/compose.d.ts +5 -0
- package/dist/mappers/render/compose.js +15 -0
- package/dist/mappers/render/description.d.ts +3 -0
- package/dist/mappers/render/description.js +17 -0
- package/dist/mappers/render/index.d.ts +3 -1
- package/dist/mappers/render/option.d.ts +20 -0
- package/dist/mappers/render/option.js +25 -0
- package/dist/mappers/render/page.d.ts +11 -0
- package/dist/mappers/render/page.js +11 -0
- package/dist/mappers/render/paths.d.ts +3 -0
- package/dist/mappers/render/paths.js +21 -0
- package/dist/mappers/render/render.d.ts +1 -1
- package/dist/mappers/render/render.js +33 -98
- package/dist/mappers/resolve.d.ts +2 -1
- package/dist/mappers/resolve.js +26 -25
- package/dist/mappers/variants/option-graph.js +11 -4
- package/dist/mappers/variants/variants.js +7 -6
- package/dist/primitive.d.ts +5 -0
- package/dist/primitive.js +6 -1
- package/dist/public.d.ts +37 -0
- package/dist/public.js +19 -0
- package/dist/references.d.ts +6 -6
- package/dist/references.js +3 -2
- package/dist/validate/brand.js +2 -4
- package/dist/validate/builder.d.ts +2 -2
- package/dist/validate/builder.js +3 -3
- package/dist/validate/expectations.d.ts +2 -2
- package/dist/validate/expectations.js +1 -1
- package/dist/validate/index.d.ts +0 -1
- package/dist/validate/instance.d.ts +2 -2
- package/dist/validate/instance.js +6 -6
- package/dist/validate/model.d.ts +4 -4
- package/dist/validate/model.js +129 -101
- package/dist/validate/paths.d.ts +2 -2
- package/dist/validate/paths.js +47 -25
- package/dist/validate/pricing.d.ts +4 -4
- package/dist/validate/pricing.js +30 -18
- package/dist/validate/resolve.d.ts +4 -3
- package/dist/validate/resolve.js +88 -63
- package/dist/validate/ui.d.ts +4 -4
- package/dist/validate/ui.js +17 -16
- package/dist/validate/variants.d.ts +2 -2
- package/dist/validate/variants.js +16 -16
- package/package.json +11 -7
- package/dist/mappers/render/pages.d.ts +0 -24
- package/dist/mappers/render/pages.js +0 -2
- package/dist/private.d.ts +0 -3
- package/dist/private.js +0 -3
|
@@ -55,18 +55,18 @@ export declare const BuilderOptionSelectMapSerialisedSchema: v.GenericSchema<imp
|
|
|
55
55
|
tags?: readonly string[] | undefined;
|
|
56
56
|
}>>>>;
|
|
57
57
|
export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
58
|
-
readonly name: v.StringSchema<undefined>;
|
|
58
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
59
59
|
readonly payload: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
60
60
|
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
61
|
-
readonly id: v.StringSchema<undefined>;
|
|
62
|
-
readonly name: v.StringSchema<undefined>;
|
|
61
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
62
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
63
63
|
}, undefined>, v.ReadonlyAction<{
|
|
64
64
|
type: "parameter";
|
|
65
65
|
id: string;
|
|
66
66
|
name: string;
|
|
67
67
|
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
68
68
|
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
69
|
-
readonly id: v.StringSchema<undefined>;
|
|
69
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
70
70
|
}, undefined>, v.ReadonlyAction<{
|
|
71
71
|
type: "ref";
|
|
72
72
|
id: string;
|
|
@@ -76,7 +76,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
76
76
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
77
77
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
78
78
|
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
79
|
-
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
79
|
+
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>;
|
|
80
80
|
}, undefined>, v.ReadonlyAction<{
|
|
81
81
|
type: "select";
|
|
82
82
|
readonly options: readonly [string, ...string[]];
|
|
@@ -91,7 +91,7 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
91
91
|
readonly valueType: 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
|
-
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
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
|
valueType: "string" | "number" | "boolean";
|
|
@@ -131,20 +131,20 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
131
131
|
}>>>>], undefined>], undefined>;
|
|
132
132
|
readonly paths: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
133
133
|
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
134
|
-
readonly id: v.StringSchema<undefined>;
|
|
135
|
-
readonly name: v.StringSchema<undefined>;
|
|
134
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
135
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
136
136
|
}, undefined>, v.ReadonlyAction<{
|
|
137
137
|
type: "parameter";
|
|
138
138
|
id: string;
|
|
139
139
|
name: string;
|
|
140
140
|
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
141
141
|
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
142
|
-
readonly id: v.StringSchema<undefined>;
|
|
142
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
143
143
|
}, undefined>, v.ReadonlyAction<{
|
|
144
144
|
type: "ref";
|
|
145
145
|
id: string;
|
|
146
|
-
}>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>, undefined>, v.ReadonlyAction<(readonly (string | number)[])[]>]>], undefined>, undefined>;
|
|
147
|
-
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
146
|
+
}>]>, 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)[])[]>]>], undefined>, undefined>;
|
|
147
|
+
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>;
|
|
148
148
|
}, undefined>, v.ReadonlyAction<{
|
|
149
149
|
name: string;
|
|
150
150
|
payload: Readonly<{
|
|
@@ -197,18 +197,18 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
197
197
|
}>]>;
|
|
198
198
|
export type BuilderOptionSerialised = v.InferOutput<typeof BuilderOptionSerialisedSchema>;
|
|
199
199
|
export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
200
|
-
readonly name: v.StringSchema<undefined>;
|
|
200
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
201
201
|
readonly payload: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
202
202
|
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
203
|
-
readonly id: v.StringSchema<undefined>;
|
|
204
|
-
readonly name: v.StringSchema<undefined>;
|
|
203
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
204
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
205
205
|
}, undefined>, v.ReadonlyAction<{
|
|
206
206
|
type: "parameter";
|
|
207
207
|
id: string;
|
|
208
208
|
name: string;
|
|
209
209
|
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
210
210
|
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
211
|
-
readonly id: v.StringSchema<undefined>;
|
|
211
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
212
212
|
}, undefined>, v.ReadonlyAction<{
|
|
213
213
|
type: "ref";
|
|
214
214
|
id: string;
|
|
@@ -218,7 +218,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
218
218
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
219
219
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
220
220
|
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
221
|
-
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
221
|
+
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>;
|
|
222
222
|
}, undefined>, v.ReadonlyAction<{
|
|
223
223
|
type: "select";
|
|
224
224
|
readonly options: readonly [string, ...string[]];
|
|
@@ -233,7 +233,7 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
233
233
|
readonly valueType: 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
|
-
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
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
|
valueType: "string" | "number" | "boolean";
|
|
@@ -273,20 +273,20 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
273
273
|
}>>>>], undefined>], undefined>;
|
|
274
274
|
readonly paths: v.OptionalSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
275
275
|
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
276
|
-
readonly id: v.StringSchema<undefined>;
|
|
277
|
-
readonly name: v.StringSchema<undefined>;
|
|
276
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
277
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
278
278
|
}, undefined>, v.ReadonlyAction<{
|
|
279
279
|
type: "parameter";
|
|
280
280
|
id: string;
|
|
281
281
|
name: string;
|
|
282
282
|
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
283
283
|
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
284
|
-
readonly id: v.StringSchema<undefined>;
|
|
284
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
285
285
|
}, undefined>, v.ReadonlyAction<{
|
|
286
286
|
type: "ref";
|
|
287
287
|
id: string;
|
|
288
|
-
}>]>, v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>, undefined>, v.ReadonlyAction<(readonly (string | number)[])[]>]>], undefined>, undefined>;
|
|
289
|
-
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
288
|
+
}>]>, 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)[])[]>]>], undefined>, undefined>;
|
|
289
|
+
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>;
|
|
290
290
|
}, undefined>, v.ReadonlyAction<{
|
|
291
291
|
name: string;
|
|
292
292
|
payload: Readonly<{
|
|
@@ -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, errors?: import("../../errors").
|
|
390
|
+
export declare const validateOptionWhen: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
391
391
|
readonly type: "enable";
|
|
392
392
|
readonly payload: {
|
|
393
393
|
readonly type: "select";
|
|
@@ -447,7 +447,7 @@ export declare const validateOptionWhen: (input: unknown, references?: import(".
|
|
|
447
447
|
readonly tags?: readonly string[] | undefined;
|
|
448
448
|
};
|
|
449
449
|
}>;
|
|
450
|
-
export declare const validateOptionSelectMap: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").
|
|
450
|
+
export declare const validateOptionSelectMap: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
451
451
|
readonly [x: string]: {
|
|
452
452
|
readonly type: "select";
|
|
453
453
|
readonly options: readonly [string, ...string[]];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { NameSchema } from '../../primitive.js';
|
|
2
3
|
import { paramable } from '../../references.js';
|
|
3
4
|
import { createEntityValidator } from '../kind.js';
|
|
4
5
|
import { BuilderPathsSchema } from '../paths.js';
|
|
@@ -25,7 +26,7 @@ export const BuilderOptionSchema = v.instance(BuilderOption);
|
|
|
25
26
|
export const BuilderOptionWhenSerialisedSchema = createWhenSerialisedSchema(BuilderOptionConfigSerialisedSchema);
|
|
26
27
|
export const BuilderOptionSelectMapSerialisedSchema = createSelectMapSerialisedSchema(BuilderOptionConfigSerialisedSchema);
|
|
27
28
|
export const BuilderOptionSerialisedSchema = serialisable(v.object({
|
|
28
|
-
name:
|
|
29
|
+
name: NameSchema,
|
|
29
30
|
payload: paramable(v.union([BuilderOptionConfigSerialisedSchema, BuilderOptionWhenSerialisedSchema])),
|
|
30
31
|
paths: v.optional(paramable(BuilderPathsSchema)),
|
|
31
32
|
tags: v.optional(BuilderTagsSchema)
|
|
@@ -29,7 +29,7 @@ export declare const BuilderSelectConfigSerialisedSchema: v.SchemaWithPipe<reado
|
|
|
29
29
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
30
30
|
readonly isOptional: v.BooleanSchema<undefined>;
|
|
31
31
|
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
32
|
-
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
32
|
+
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>;
|
|
33
33
|
}, undefined>, v.ReadonlyAction<{
|
|
34
34
|
type: "select";
|
|
35
35
|
readonly options: readonly [string, ...string[]];
|
|
@@ -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, errors?: import("../../errors").
|
|
45
|
+
export declare const validateSelect: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
46
46
|
readonly type: "select";
|
|
47
47
|
readonly options: readonly [string, ...string[]];
|
|
48
48
|
readonly defaultValue: string | null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { BooleanSchema, StringSchema } from '../../primitive.js';
|
|
2
3
|
import { createEntityValidator } from '../kind.js';
|
|
3
4
|
import { serialisable } from '../serialisable.js';
|
|
4
5
|
import { BuilderTagsSchema } from '../tags.js';
|
|
@@ -43,10 +44,10 @@ export function select(values) {
|
|
|
43
44
|
export const BuilderSelectConfigSchema = v.instance(BuilderSelectConfig);
|
|
44
45
|
export const BuilderSelectConfigSerialisedSchema = serialisable(v.object({
|
|
45
46
|
type: v.literal('select'),
|
|
46
|
-
options: v.pipe(v.tupleWithRest([
|
|
47
|
-
defaultValue: v.nullable(
|
|
48
|
-
isOptional:
|
|
49
|
-
optionLabels: v.record(
|
|
47
|
+
options: v.pipe(v.tupleWithRest([StringSchema], StringSchema), v.readonly()),
|
|
48
|
+
defaultValue: v.nullable(StringSchema),
|
|
49
|
+
isOptional: BooleanSchema,
|
|
50
|
+
optionLabels: v.record(StringSchema, StringSchema),
|
|
50
51
|
tags: v.optional(BuilderTagsSchema)
|
|
51
52
|
}));
|
|
52
53
|
export function selectValueSchema(options, optional) {
|
|
@@ -55,11 +56,13 @@ export function selectValueSchema(options, optional) {
|
|
|
55
56
|
}
|
|
56
57
|
export const validateSelect = createEntityValidator('select', BuilderSelectConfigSerialisedSchema, (input, errors) => {
|
|
57
58
|
if (input.defaultValue != null && !input.options.includes(input.defaultValue)) {
|
|
58
|
-
errors.
|
|
59
|
+
errors.scope('defaultValue', () => errors.entityInvalidSelectDefault());
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
errors.scope('optionLabels', () => {
|
|
62
|
+
Object.keys(input.optionLabels).forEach((key) => {
|
|
63
|
+
if (!input.options.includes(key)) {
|
|
64
|
+
errors.scope(key, () => errors.entityInvalidSelectLabel());
|
|
65
|
+
}
|
|
66
|
+
});
|
|
64
67
|
});
|
|
65
68
|
});
|
|
@@ -26,7 +26,7 @@ export declare const BuilderToggleConfigSerialisedSchema: v.SchemaWithPipe<reado
|
|
|
26
26
|
readonly valueType: 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
|
-
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
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
|
valueType: "string" | "number" | "boolean";
|
|
@@ -36,7 +36,7 @@ export declare const BuilderToggleConfigSerialisedSchema: v.SchemaWithPipe<reado
|
|
|
36
36
|
}>]>;
|
|
37
37
|
export type BuilderToggleConfigSerialised = v.InferOutput<typeof BuilderToggleConfigSerialisedSchema>;
|
|
38
38
|
export declare function toggleValueSchema(valueType: BuilderToggleValueType, optional: boolean): v.GenericSchema;
|
|
39
|
-
export declare const validateToggle: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../
|
|
39
|
+
export declare const validateToggle: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors/errors").BuilderErrorsScope) => import("..").ValidationResult<{
|
|
40
40
|
readonly type: "toggle";
|
|
41
41
|
readonly valueType: "string" | "number" | "boolean";
|
|
42
42
|
readonly defaultValue: string | number | boolean | null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { check } from '../../errors/index.js';
|
|
3
|
+
import { BooleanSchema, NumberSchema, StringSchema } from '../../primitive.js';
|
|
3
4
|
import { createEntityValidator } from '../kind.js';
|
|
4
5
|
import { serialisable } from '../serialisable.js';
|
|
5
6
|
import { BuilderTagsSchema } from '../tags.js';
|
|
@@ -46,12 +47,12 @@ export const BuilderToggleConfigSchema = v.instance(BuilderToggleConfig);
|
|
|
46
47
|
export const BuilderToggleConfigSerialisedSchema = serialisable(v.object({
|
|
47
48
|
type: v.literal('toggle'),
|
|
48
49
|
valueType: BuilderToggleValueTypeSchema,
|
|
49
|
-
defaultValue: v.nullable(v.union([
|
|
50
|
-
isOptional:
|
|
50
|
+
defaultValue: v.nullable(v.union([BooleanSchema, StringSchema, NumberSchema])),
|
|
51
|
+
isOptional: BooleanSchema,
|
|
51
52
|
tags: v.optional(BuilderTagsSchema)
|
|
52
53
|
}));
|
|
53
54
|
export function toggleValueSchema(valueType, optional) {
|
|
54
|
-
const baseSchema = valueType === 'string' ?
|
|
55
|
+
const baseSchema = valueType === 'string' ? StringSchema : valueType === 'boolean' ? BooleanSchema : NumberSchema;
|
|
55
56
|
return optional ? v.nullable(baseSchema) : baseSchema;
|
|
56
57
|
}
|
|
57
58
|
export const validateToggle = createEntityValidator('toggle', BuilderToggleConfigSerialisedSchema, (input, errors) => {
|
|
@@ -60,6 +61,6 @@ export const validateToggle = createEntityValidator('toggle', BuilderToggleConfi
|
|
|
60
61
|
}
|
|
61
62
|
const valueSchema = toggleValueSchema(input.valueType, input.isOptional);
|
|
62
63
|
if (!check.is(valueSchema, input.defaultValue)) {
|
|
63
|
-
errors.
|
|
64
|
+
errors.scope('defaultValue', () => errors.entityInvalidToggleDefault());
|
|
64
65
|
}
|
|
65
66
|
});
|
package/dist/entities/paths.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
export declare const BuilderPathSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>;
|
|
2
|
+
export declare const BuilderPathSchema: 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)[]>]>;
|
|
3
3
|
export type BuilderPath = v.InferOutput<typeof BuilderPathSchema>;
|
|
4
|
-
export declare const BuilderPathsSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.UnionSchema<[v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>, v.ReadonlyAction<(string | number)[]>]>, undefined>, v.ReadonlyAction<(readonly (string | number)[])[]>]>;
|
|
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, errors?: import("../errors/errors.js").
|
|
7
|
-
export declare const validatePaths: (input: unknown, references?: import("./references.js").BuilderReferences, errors?: import("../errors/errors.js").
|
|
6
|
+
export declare const validatePath: (input: unknown, references?: import("./references.js").BuilderReferences, errors?: import("../errors/errors.js").BuilderErrorsScope) => import("./validated.js").ValidationResult<readonly (string | number)[]>;
|
|
7
|
+
export declare const validatePaths: (input: unknown, references?: import("./references.js").BuilderReferences, errors?: import("../errors/errors.js").BuilderErrorsScope) => import("./validated.js").ValidationResult<readonly (readonly (string | number)[])[]>;
|
package/dist/entities/paths.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { NameSchema, NumberSchema } from '../primitive.js';
|
|
2
3
|
import { createEntityValidator } from './kind.js';
|
|
3
|
-
export const BuilderPathSchema = v.pipe(v.array(v.union([
|
|
4
|
+
export const BuilderPathSchema = v.pipe(v.array(v.union([NameSchema, NumberSchema])), v.readonly());
|
|
4
5
|
export const BuilderPathsSchema = v.pipe(v.array(BuilderPathSchema), v.readonly());
|
|
5
6
|
export const validatePath = createEntityValidator('path', BuilderPathSchema);
|
|
6
7
|
export const validatePaths = createEntityValidator('paths', BuilderPathsSchema);
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { NameSchema, NumberSchema } from '../../primitive.js';
|
|
2
3
|
import { paramable } from '../../references.js';
|
|
3
4
|
export const BuilderPricingReduceSchema = v.picklist(['product', 'sum', 'first']);
|
|
4
5
|
export const BuilderPricingLookupKeySchema = v.variant('kind', [
|
|
5
6
|
v.object({ kind: v.literal('variantTags') }),
|
|
6
|
-
v.object({ kind: v.literal('option'), name:
|
|
7
|
+
v.object({ kind: v.literal('option'), name: NameSchema })
|
|
7
8
|
]);
|
|
8
9
|
export const BuilderPricingExpressionSchema = v.lazy(() => v.union([
|
|
9
|
-
|
|
10
|
+
NumberSchema,
|
|
10
11
|
v.object({ kind: v.literal('variantPrice') }),
|
|
11
12
|
v.object({
|
|
12
13
|
kind: v.literal('lookup'),
|
|
13
|
-
rate:
|
|
14
|
+
rate: NameSchema,
|
|
14
15
|
key: BuilderPricingLookupKeySchema,
|
|
15
16
|
reduce: v.optional(BuilderPricingReduceSchema)
|
|
16
17
|
}),
|
|
17
18
|
v.object({
|
|
18
19
|
kind: v.literal('variants'),
|
|
19
|
-
tag: v.optional(
|
|
20
|
+
tag: v.optional(NameSchema),
|
|
20
21
|
expression: paramable(BuilderPricingExpressionSchema),
|
|
21
22
|
reduce: v.optional(BuilderPricingReduceSchema)
|
|
22
23
|
}),
|
|
@@ -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, errors?: import("../../errors/errors.js").
|
|
4
|
+
export declare const validatePricingRates: (input: unknown, references?: import("../references.js").BuilderReferences, errors?: import("../../errors/errors.js").BuilderErrorsScope) => import("../validated.js").ValidationResult<{
|
|
5
5
|
readonly [x: string]: {
|
|
6
6
|
readonly [x: string]: number;
|
|
7
7
|
} & import("../../validate/brand.js").BuilderValidatedBrand;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { NameSchema, NumberSchema } from '../../primitive.js';
|
|
2
3
|
import { serialisable } from '../serialisable.js';
|
|
3
4
|
import { createEntityValidator } from '../kind.js';
|
|
4
|
-
export const BuilderRatesSchema = serialisable(v.record(
|
|
5
|
+
export const BuilderRatesSchema = serialisable(v.record(NameSchema, v.record(NameSchema, NumberSchema)));
|
|
5
6
|
export const validatePricingRates = createEntityValidator('pricingRates', BuilderRatesSchema);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
export declare const BuilderReferenceSchema: v.ObjectSchema<{
|
|
3
|
-
readonly id: v.StringSchema<undefined>;
|
|
3
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4
4
|
readonly serialised: v.GenericSchema<string | number | boolean | readonly (string | number)[] | readonly (readonly (string | number)[])[] | import("./index.js").BuilderSerialised | import("./index.js").BuilderModelSerialised | Readonly<{
|
|
5
5
|
type: "select";
|
|
6
6
|
readonly options: readonly [string, ...string[]];
|
|
@@ -361,7 +361,7 @@ export declare const BuilderReferenceSchema: v.ObjectSchema<{
|
|
|
361
361
|
}, undefined>;
|
|
362
362
|
export type BuilderReference = v.InferOutput<typeof BuilderReferenceSchema>;
|
|
363
363
|
export declare const BuilderReferencesSchema: v.ArraySchema<v.ObjectSchema<{
|
|
364
|
-
readonly id: v.StringSchema<undefined>;
|
|
364
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
365
365
|
readonly serialised: v.GenericSchema<string | number | boolean | readonly (string | number)[] | readonly (readonly (string | number)[])[] | import("./index.js").BuilderSerialised | import("./index.js").BuilderModelSerialised | Readonly<{
|
|
366
366
|
type: "select";
|
|
367
367
|
readonly options: readonly [string, ...string[]];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { IdSchema } from '../primitive.js';
|
|
2
3
|
import { BuilderEntitySerialisedSchema } from './serialise.js';
|
|
3
4
|
export const BuilderReferenceSchema = v.object({
|
|
4
|
-
id:
|
|
5
|
+
id: IdSchema,
|
|
5
6
|
serialised: BuilderEntitySerialisedSchema
|
|
6
7
|
});
|
|
7
8
|
export const BuilderReferencesSchema = v.array(BuilderReferenceSchema);
|