@builder-builder/builder 0.0.19 → 0.0.21
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.d.ts +12 -14
- package/dist/bb.js +32 -6
- package/dist/entities/builder/bind.d.ts +1 -1
- package/dist/entities/builder/builder.d.ts +2 -4
- package/dist/entities/builder/builder.js +1 -1
- package/dist/entities/collection/collection.d.ts +689 -1
- package/dist/entities/collection/collection.js +5 -2
- package/dist/entities/collection/config.d.ts +290 -0
- package/dist/entities/collection/config.js +13 -2
- package/dist/entities/collection/expectation.d.ts +1 -1
- package/dist/entities/collection/index.d.ts +3 -3
- package/dist/entities/collection/index.js +2 -2
- package/dist/entities/collection/when.d.ts +1 -1
- package/dist/entities/component/component.d.ts +64 -10
- package/dist/entities/component/component.js +9 -6
- package/dist/entities/component/config.d.ts +145 -0
- package/dist/entities/component/config.js +42 -0
- package/dist/entities/component/field.js +1 -1
- package/dist/entities/component/index.d.ts +3 -3
- package/dist/entities/component/index.js +2 -2
- package/dist/entities/component/when.d.ts +6 -6
- package/dist/entities/component/when.js +3 -3
- package/dist/entities/expectation.d.ts +4 -0
- package/dist/entities/expectation.js +3 -1
- package/dist/entities/index.d.ts +18 -17
- package/dist/entities/index.js +11 -10
- package/dist/entities/kind.d.ts +10 -7
- package/dist/entities/kind.js +39 -5
- package/dist/entities/model/bind.d.ts +1 -1
- package/dist/entities/model/index.d.ts +1 -1
- package/dist/entities/model/methods.d.ts +12 -12
- package/dist/entities/model/methods.js +2 -2
- package/dist/entities/model/model.js +1 -1
- package/dist/entities/model/models.d.ts +1 -1
- package/dist/entities/option/config.d.ts +109 -0
- package/dist/entities/option/config.js +15 -0
- package/dist/entities/option/index.d.ts +7 -7
- package/dist/entities/option/index.js +4 -4
- package/dist/entities/option/option.d.ts +88 -10
- package/dist/entities/option/option.js +9 -6
- package/dist/entities/option/select.d.ts +24 -14
- package/dist/entities/option/select.js +17 -6
- package/dist/entities/option/toggle.d.ts +17 -10
- package/dist/entities/option/toggle.js +19 -8
- package/dist/entities/option/when.d.ts +6 -6
- package/dist/{paths.d.ts → entities/paths.d.ts} +2 -0
- package/dist/{paths.js → entities/paths.js} +3 -0
- package/dist/entities/pricing/index.d.ts +1 -1
- package/dist/entities/pricing/index.js +1 -1
- package/dist/entities/pricing/pricing.js +1 -1
- package/dist/entities/pricing/rates.d.ts +5 -0
- package/dist/entities/pricing/rates.js +3 -1
- package/dist/entities/references.d.ts +723 -0
- package/dist/entities/references.js +7 -0
- package/dist/entities/serialise.d.ts +49 -43
- package/dist/entities/serialise.js +19 -13
- package/dist/entities/ui/describe.d.ts +15 -0
- package/dist/entities/ui/describe.js +11 -2
- package/dist/entities/ui/index.d.ts +4 -4
- package/dist/entities/ui/index.js +4 -4
- package/dist/entities/ui/input.d.ts +12 -3
- package/dist/entities/ui/input.js +4 -2
- package/dist/entities/ui/page.d.ts +15 -0
- package/dist/entities/ui/page.js +11 -2
- package/dist/entities/ui/pages.d.ts +132 -0
- package/dist/entities/ui/pages.js +12 -2
- package/dist/entities/ui/ui.d.ts +2 -3
- package/dist/entities/ui/ui.js +2 -2
- package/dist/entities/ui/uis.d.ts +1 -1
- package/dist/entities/ui/uis.js +2 -2
- package/dist/entities/validated.d.ts +26 -18
- package/dist/entities/when.d.ts +4 -3
- package/dist/entities/when.js +22 -2
- package/dist/environment.d.ts +2 -2
- package/dist/{validate → errors}/errors.d.ts +57 -35
- package/dist/{validate → errors}/errors.js +40 -5
- package/dist/errors/exception.d.ts +5 -0
- package/dist/{exception.js → errors/exception.js} +0 -3
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +3 -0
- package/dist/index.d.ts +19 -18
- package/dist/index.js +5 -4
- package/dist/instance.d.ts +7 -7
- package/dist/instance.js +4 -4
- package/dist/mappers/index.d.ts +2 -4
- package/dist/mappers/index.js +1 -2
- package/dist/mappers/instance.d.ts +2 -2
- package/dist/mappers/instance.js +7 -7
- package/dist/mappers/order.d.ts +4 -4
- package/dist/mappers/order.js +5 -5
- package/dist/mappers/price.js +18 -18
- package/dist/mappers/render/pages.d.ts +2 -2
- package/dist/mappers/render/render.d.ts +2 -2
- package/dist/mappers/render/render.js +12 -12
- package/dist/mappers/resolve.d.ts +11 -12
- package/dist/mappers/resolve.js +29 -46
- package/dist/mappers/variants/option-graph.d.ts +2 -3
- package/dist/mappers/variants/option-graph.js +2 -3
- package/dist/mappers/variants/variants.d.ts +2 -2
- package/dist/mappers/variants/variants.js +1 -1
- package/dist/private.d.ts +1 -2
- package/dist/private.js +1 -2
- package/dist/references.js +1 -1
- package/dist/validate/brand.js +1 -2
- package/dist/validate/builder.d.ts +3 -4
- package/dist/validate/builder.js +2 -3
- package/dist/validate/expectations.d.ts +1 -1
- package/dist/validate/index.d.ts +5 -2
- package/dist/validate/index.js +1 -0
- package/dist/validate/instance.d.ts +2 -3
- package/dist/validate/instance.js +1 -2
- package/dist/validate/model.d.ts +3 -4
- package/dist/validate/model.js +39 -44
- package/dist/validate/paths.d.ts +2 -3
- package/dist/validate/paths.js +1 -1
- package/dist/validate/pricing.d.ts +3 -4
- package/dist/validate/pricing.js +2 -3
- package/dist/validate/resolve.d.ts +3 -3
- package/dist/validate/resolve.js +1 -1
- package/dist/validate/ui.d.ts +3 -4
- package/dist/validate/ui.js +14 -5
- package/dist/validate/variants.d.ts +4 -5
- package/dist/validate/variants.js +6 -7
- package/package.json +7 -2
- package/dist/entities/component/details.d.ts +0 -66
- package/dist/entities/component/details.js +0 -24
- package/dist/entities/entry.d.ts +0 -4
- package/dist/entities/entry.js +0 -1
- package/dist/entities/option/values.d.ts +0 -49
- package/dist/entities/option/values.js +0 -14
- package/dist/entities/refs.d.ts +0 -6
- package/dist/entities/refs.js +0 -1
- package/dist/exception.d.ts +0 -13
- package/dist/validate/result.d.ts +0 -2
- package/dist/validate/result.js +0 -1
- /package/dist/{serialisable.d.ts → entities/serialisable.d.ts} +0 -0
- /package/dist/{serialisable.js → entities/serialisable.js} +0 -0
- /package/dist/{check.d.ts → errors/check.d.ts} +0 -0
- /package/dist/{check.js → errors/check.js} +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export declare const BuilderOptionConfigSchema: v.UnionSchema<[v.InstanceSchema<typeof import("./select.js").BuilderSelectConfig, undefined>, v.InstanceSchema<typeof import("./toggle.js").BuilderToggleConfig, undefined>], undefined>;
|
|
3
|
+
export type BuilderOptionConfig = v.InferOutput<typeof BuilderOptionConfigSchema>;
|
|
4
|
+
export declare const BuilderOptionConfigSerialisedSchema: v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
5
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
6
|
+
readonly options: v.SchemaWithPipe<readonly [v.TupleWithRestSchema<[v.StringSchema<undefined>], v.StringSchema<undefined>, undefined>, v.ReadonlyAction<[string, ...string[]]>]>;
|
|
7
|
+
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
8
|
+
readonly isOptional: v.BooleanSchema<undefined>;
|
|
9
|
+
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
10
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
11
|
+
}, undefined>, v.ReadonlyAction<{
|
|
12
|
+
type: "select";
|
|
13
|
+
readonly options: readonly [string, ...string[]];
|
|
14
|
+
defaultValue: string | null;
|
|
15
|
+
isOptional: boolean;
|
|
16
|
+
optionLabels: {
|
|
17
|
+
[x: string]: string;
|
|
18
|
+
};
|
|
19
|
+
tags?: readonly string[] | undefined;
|
|
20
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
21
|
+
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
22
|
+
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
23
|
+
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
24
|
+
readonly isOptional: v.BooleanSchema<undefined>;
|
|
25
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
26
|
+
}, undefined>, v.ReadonlyAction<{
|
|
27
|
+
type: "toggle";
|
|
28
|
+
valueType: "string" | "number" | "boolean";
|
|
29
|
+
defaultValue: string | number | boolean | null;
|
|
30
|
+
isOptional: boolean;
|
|
31
|
+
tags?: readonly string[] | undefined;
|
|
32
|
+
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
33
|
+
type: "select";
|
|
34
|
+
readonly options: readonly [string, ...string[]];
|
|
35
|
+
defaultValue: string | null;
|
|
36
|
+
isOptional: boolean;
|
|
37
|
+
optionLabels: {
|
|
38
|
+
[x: string]: string;
|
|
39
|
+
};
|
|
40
|
+
tags?: readonly string[] | undefined;
|
|
41
|
+
}> | Readonly<{
|
|
42
|
+
type: "toggle";
|
|
43
|
+
valueType: "string" | "number" | "boolean";
|
|
44
|
+
defaultValue: string | number | boolean | null;
|
|
45
|
+
isOptional: boolean;
|
|
46
|
+
tags?: readonly string[] | undefined;
|
|
47
|
+
}>>]>;
|
|
48
|
+
export type BuilderOptionConfigSerialised = v.InferOutput<typeof BuilderOptionConfigSerialisedSchema>;
|
|
49
|
+
export declare const BuilderOptionConfigsSerialisedSchema: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
50
|
+
readonly type: v.LiteralSchema<"select", undefined>;
|
|
51
|
+
readonly options: v.SchemaWithPipe<readonly [v.TupleWithRestSchema<[v.StringSchema<undefined>], v.StringSchema<undefined>, undefined>, v.ReadonlyAction<[string, ...string[]]>]>;
|
|
52
|
+
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
53
|
+
readonly isOptional: v.BooleanSchema<undefined>;
|
|
54
|
+
readonly optionLabels: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
55
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
56
|
+
}, undefined>, v.ReadonlyAction<{
|
|
57
|
+
type: "select";
|
|
58
|
+
readonly options: readonly [string, ...string[]];
|
|
59
|
+
defaultValue: string | null;
|
|
60
|
+
isOptional: boolean;
|
|
61
|
+
optionLabels: {
|
|
62
|
+
[x: string]: string;
|
|
63
|
+
};
|
|
64
|
+
tags?: readonly string[] | undefined;
|
|
65
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
66
|
+
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
67
|
+
readonly valueType: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
68
|
+
readonly defaultValue: v.NullableSchema<v.UnionSchema<[v.BooleanSchema<undefined>, v.StringSchema<undefined>, v.NumberSchema<undefined>], undefined>, undefined>;
|
|
69
|
+
readonly isOptional: v.BooleanSchema<undefined>;
|
|
70
|
+
readonly tags: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ReadonlyAction<string[]>]>, undefined>;
|
|
71
|
+
}, undefined>, v.ReadonlyAction<{
|
|
72
|
+
type: "toggle";
|
|
73
|
+
valueType: "string" | "number" | "boolean";
|
|
74
|
+
defaultValue: string | number | boolean | null;
|
|
75
|
+
isOptional: boolean;
|
|
76
|
+
tags?: readonly string[] | undefined;
|
|
77
|
+
}>]>], undefined>, v.ReadonlyAction<Readonly<{
|
|
78
|
+
type: "select";
|
|
79
|
+
readonly options: readonly [string, ...string[]];
|
|
80
|
+
defaultValue: string | null;
|
|
81
|
+
isOptional: boolean;
|
|
82
|
+
optionLabels: {
|
|
83
|
+
[x: string]: string;
|
|
84
|
+
};
|
|
85
|
+
tags?: readonly string[] | undefined;
|
|
86
|
+
}> | Readonly<{
|
|
87
|
+
type: "toggle";
|
|
88
|
+
valueType: "string" | "number" | "boolean";
|
|
89
|
+
defaultValue: string | number | boolean | null;
|
|
90
|
+
isOptional: boolean;
|
|
91
|
+
tags?: readonly string[] | undefined;
|
|
92
|
+
}>>]>, undefined>, v.ReadonlyAction<(Readonly<Readonly<{
|
|
93
|
+
type: "select";
|
|
94
|
+
readonly options: readonly [string, ...string[]];
|
|
95
|
+
defaultValue: string | null;
|
|
96
|
+
isOptional: boolean;
|
|
97
|
+
optionLabels: {
|
|
98
|
+
[x: string]: string;
|
|
99
|
+
};
|
|
100
|
+
tags?: readonly string[] | undefined;
|
|
101
|
+
}>> | Readonly<Readonly<{
|
|
102
|
+
type: "toggle";
|
|
103
|
+
valueType: "string" | "number" | "boolean";
|
|
104
|
+
defaultValue: string | number | boolean | null;
|
|
105
|
+
isOptional: boolean;
|
|
106
|
+
tags?: readonly string[] | undefined;
|
|
107
|
+
}>>)[]>]>;
|
|
108
|
+
export type BuilderOptionConfigsSerialised = v.InferOutput<typeof BuilderOptionConfigsSerialisedSchema>;
|
|
109
|
+
export declare function optionValueSchema(payload: BuilderOptionConfigSerialised): v.GenericSchema;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { BuilderSelectConfigSchema, BuilderSelectConfigSerialisedSchema, selectValueSchema } from './select.js';
|
|
3
|
+
import { BuilderToggleConfigSchema, BuilderToggleConfigSerialisedSchema, toggleValueSchema } from './toggle.js';
|
|
4
|
+
export const BuilderOptionConfigSchema = v.union([
|
|
5
|
+
BuilderSelectConfigSchema,
|
|
6
|
+
BuilderToggleConfigSchema
|
|
7
|
+
]);
|
|
8
|
+
export const BuilderOptionConfigSerialisedSchema = v.pipe(v.variant('type', [BuilderSelectConfigSerialisedSchema, BuilderToggleConfigSerialisedSchema]), v.readonly());
|
|
9
|
+
export const BuilderOptionConfigsSerialisedSchema = v.pipe(v.array(BuilderOptionConfigSerialisedSchema), v.readonly());
|
|
10
|
+
export function optionValueSchema(payload) {
|
|
11
|
+
if (payload.type === 'select') {
|
|
12
|
+
return selectValueSchema(payload.options, payload.isOptional);
|
|
13
|
+
}
|
|
14
|
+
return toggleValueSchema(payload.valueType, payload.isOptional);
|
|
15
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export type { BuilderOptionPayload, BuilderOptions, BuilderOptionSerialised, BuilderOptionsSerialised, BuilderOptionWhenSerialised } from './option';
|
|
2
|
-
export type {
|
|
3
|
-
export type {
|
|
4
|
-
export type {
|
|
2
|
+
export type { BuilderSelectConfigLabels, BuilderSelectConfigSerialised, BuilderSelectConfigValues } from './select';
|
|
3
|
+
export type { BuilderToggleConfigSerialised, BuilderToggleValueType } from './toggle';
|
|
4
|
+
export type { BuilderOptionConfig, BuilderOptionConfigSerialised, BuilderOptionConfigsSerialised } from './config';
|
|
5
5
|
export type { BuilderOptionWhen } from './when';
|
|
6
|
-
export { BuilderOption, BuilderOptionSchema, BuilderOptionSelectMapSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionsSerialisedSchema, BuilderOptionWhenSerialisedSchema } from './option.js';
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
6
|
+
export { BuilderOption, BuilderOptionSchema, BuilderOptionSelectMapSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionsSerialisedSchema, BuilderOptionWhenSerialisedSchema, validateOptionSelectMap, validateOptionWhen } from './option.js';
|
|
7
|
+
export { BuilderSelectConfig, BuilderSelectConfigSchema, BuilderSelectConfigSerialisedSchema, select, validateSelect } from './select.js';
|
|
8
|
+
export { BuilderToggleConfig, BuilderToggleConfigSchema, BuilderToggleConfigSerialisedSchema, toggleBoolean, toggleNumber, toggleString, validateToggle } from './toggle.js';
|
|
9
|
+
export { BuilderOptionConfigSchema, BuilderOptionConfigSerialisedSchema, BuilderOptionConfigsSerialisedSchema, optionValueSchema } from './config.js';
|
|
10
10
|
export { optionExpectation } from './expectation.js';
|
|
11
11
|
export { optionWhen } from './when.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { BuilderOption, BuilderOptionSchema, BuilderOptionSelectMapSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionsSerialisedSchema, BuilderOptionWhenSerialisedSchema } from './option.js';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
1
|
+
export { BuilderOption, BuilderOptionSchema, BuilderOptionSelectMapSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionsSerialisedSchema, BuilderOptionWhenSerialisedSchema, validateOptionSelectMap, validateOptionWhen } from './option.js';
|
|
2
|
+
export { BuilderSelectConfig, BuilderSelectConfigSchema, BuilderSelectConfigSerialisedSchema, select, validateSelect } from './select.js';
|
|
3
|
+
export { BuilderToggleConfig, BuilderToggleConfigSchema, BuilderToggleConfigSerialisedSchema, toggleBoolean, toggleNumber, toggleString, validateToggle } from './toggle.js';
|
|
4
|
+
export { BuilderOptionConfigSchema, BuilderOptionConfigSerialisedSchema, BuilderOptionConfigsSerialisedSchema, optionValueSchema } from './config.js';
|
|
5
5
|
export { optionExpectation } from './expectation.js';
|
|
6
6
|
export { optionWhen } from './when.js';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { BuilderPaths } from '../../paths';
|
|
2
1
|
import type { Paramable } from '../../references';
|
|
2
|
+
import type { BuilderPaths } from '../paths';
|
|
3
3
|
import type { BuilderTags } from '../tags';
|
|
4
4
|
import type { BuilderWhenSerialised } from '../when';
|
|
5
|
-
import type {
|
|
5
|
+
import type { BuilderOptionConfig, BuilderOptionConfigSerialised } from './config';
|
|
6
6
|
import type { BuilderOptionWhen } from './when';
|
|
7
7
|
import * as v from 'valibot';
|
|
8
|
-
export type BuilderOptionPayload =
|
|
8
|
+
export type BuilderOptionPayload = BuilderOptionConfig | BuilderOptionWhen;
|
|
9
9
|
export declare class BuilderOption<const Name extends string = string, const Payload extends Paramable<BuilderOptionPayload> = Paramable<BuilderOptionPayload>, const Paths extends Paramable<BuilderPaths> = Paramable<BuilderPaths>> {
|
|
10
10
|
readonly type: 'option';
|
|
11
11
|
readonly name: Name;
|
|
@@ -33,7 +33,7 @@ export declare const BuilderOptionWhenSerialisedSchema: v.GenericSchema<BuilderW
|
|
|
33
33
|
isOptional: boolean;
|
|
34
34
|
tags?: readonly string[] | undefined;
|
|
35
35
|
}>>>>;
|
|
36
|
-
export type BuilderOptionWhenSerialised = BuilderWhenSerialised<
|
|
36
|
+
export type BuilderOptionWhenSerialised = BuilderWhenSerialised<BuilderOptionConfigSerialised>;
|
|
37
37
|
export declare const BuilderOptionSelectMapSerialisedSchema: v.GenericSchema<import("..").BuilderMatchSelectMap<Readonly<{
|
|
38
38
|
type: "parameter";
|
|
39
39
|
id: string;
|
|
@@ -185,14 +185,14 @@ export declare const BuilderOptionSerialisedSchema: v.SchemaWithPipe<readonly [v
|
|
|
185
185
|
isOptional: boolean;
|
|
186
186
|
tags?: readonly string[] | undefined;
|
|
187
187
|
}>>>;
|
|
188
|
-
paths?:
|
|
188
|
+
paths?: Readonly<{
|
|
189
189
|
type: "parameter";
|
|
190
190
|
id: string;
|
|
191
191
|
name: string;
|
|
192
192
|
}> | Readonly<{
|
|
193
193
|
type: "ref";
|
|
194
194
|
id: string;
|
|
195
|
-
}> | undefined;
|
|
195
|
+
}> | readonly (readonly (string | number)[])[] | undefined;
|
|
196
196
|
tags?: readonly string[] | undefined;
|
|
197
197
|
}>]>;
|
|
198
198
|
export type BuilderOptionSerialised = v.InferOutput<typeof BuilderOptionSerialisedSchema>;
|
|
@@ -327,14 +327,14 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
327
327
|
isOptional: boolean;
|
|
328
328
|
tags?: readonly string[] | undefined;
|
|
329
329
|
}>>>;
|
|
330
|
-
paths?:
|
|
330
|
+
paths?: Readonly<{
|
|
331
331
|
type: "parameter";
|
|
332
332
|
id: string;
|
|
333
333
|
name: string;
|
|
334
334
|
}> | Readonly<{
|
|
335
335
|
type: "ref";
|
|
336
336
|
id: string;
|
|
337
|
-
}> | undefined;
|
|
337
|
+
}> | readonly (readonly (string | number)[])[] | undefined;
|
|
338
338
|
tags?: readonly string[] | undefined;
|
|
339
339
|
}>]>, undefined>, v.ReadonlyAction<Readonly<{
|
|
340
340
|
name: string;
|
|
@@ -376,14 +376,92 @@ export declare const BuilderOptionsSerialisedSchema: v.SchemaWithPipe<readonly [
|
|
|
376
376
|
isOptional: boolean;
|
|
377
377
|
tags?: readonly string[] | undefined;
|
|
378
378
|
}>>>;
|
|
379
|
-
paths?:
|
|
379
|
+
paths?: Readonly<{
|
|
380
380
|
type: "parameter";
|
|
381
381
|
id: string;
|
|
382
382
|
name: string;
|
|
383
383
|
}> | Readonly<{
|
|
384
384
|
type: "ref";
|
|
385
385
|
id: string;
|
|
386
|
-
}> | undefined;
|
|
386
|
+
}> | readonly (readonly (string | number)[])[] | undefined;
|
|
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").BuilderValidateErrors) => import("..").ValidationResult<{
|
|
391
|
+
readonly type: "enable";
|
|
392
|
+
readonly payload: {
|
|
393
|
+
readonly type: "select";
|
|
394
|
+
readonly options: readonly [string, ...string[]];
|
|
395
|
+
readonly defaultValue: string | null;
|
|
396
|
+
readonly isOptional: boolean;
|
|
397
|
+
readonly optionLabels: {
|
|
398
|
+
readonly [x: string]: string;
|
|
399
|
+
} & import("../../validate").BuilderValidatedBrand;
|
|
400
|
+
readonly tags?: readonly string[] | undefined;
|
|
401
|
+
} | {
|
|
402
|
+
readonly type: "toggle";
|
|
403
|
+
readonly valueType: "string" | "number" | "boolean";
|
|
404
|
+
readonly defaultValue: string | number | boolean | null;
|
|
405
|
+
readonly isOptional: boolean;
|
|
406
|
+
readonly tags?: readonly string[] | undefined;
|
|
407
|
+
};
|
|
408
|
+
} | {
|
|
409
|
+
readonly type: "match";
|
|
410
|
+
readonly matchPath: readonly (string | number)[];
|
|
411
|
+
readonly selectMap: {
|
|
412
|
+
readonly [x: string]: {
|
|
413
|
+
readonly type: "select";
|
|
414
|
+
readonly options: readonly [string, ...string[]];
|
|
415
|
+
readonly defaultValue: string | null;
|
|
416
|
+
readonly isOptional: boolean;
|
|
417
|
+
readonly optionLabels: {
|
|
418
|
+
readonly [x: string]: string;
|
|
419
|
+
} & import("../../validate").BuilderValidatedBrand;
|
|
420
|
+
readonly tags?: readonly string[] | undefined;
|
|
421
|
+
} | {
|
|
422
|
+
readonly type: "toggle";
|
|
423
|
+
readonly valueType: "string" | "number" | "boolean";
|
|
424
|
+
readonly defaultValue: string | number | boolean | null;
|
|
425
|
+
readonly isOptional: boolean;
|
|
426
|
+
readonly tags?: readonly string[] | undefined;
|
|
427
|
+
} | null;
|
|
428
|
+
};
|
|
429
|
+
} | {
|
|
430
|
+
readonly type: "unless";
|
|
431
|
+
readonly unlessPath: readonly (string | number)[];
|
|
432
|
+
readonly disabledValues: readonly (string | number | boolean | null)[];
|
|
433
|
+
readonly payload: {
|
|
434
|
+
readonly type: "select";
|
|
435
|
+
readonly options: readonly [string, ...string[]];
|
|
436
|
+
readonly defaultValue: string | null;
|
|
437
|
+
readonly isOptional: boolean;
|
|
438
|
+
readonly optionLabels: {
|
|
439
|
+
readonly [x: string]: string;
|
|
440
|
+
} & import("../../validate").BuilderValidatedBrand;
|
|
441
|
+
readonly tags?: readonly string[] | undefined;
|
|
442
|
+
} | {
|
|
443
|
+
readonly type: "toggle";
|
|
444
|
+
readonly valueType: "string" | "number" | "boolean";
|
|
445
|
+
readonly defaultValue: string | number | boolean | null;
|
|
446
|
+
readonly isOptional: boolean;
|
|
447
|
+
readonly tags?: readonly string[] | undefined;
|
|
448
|
+
};
|
|
449
|
+
}>;
|
|
450
|
+
export declare const validateOptionSelectMap: (input: unknown, references?: import("..").BuilderReferences, errors?: import("../../errors").BuilderValidateErrors) => import("..").ValidationResult<{
|
|
451
|
+
readonly [x: string]: {
|
|
452
|
+
readonly type: "select";
|
|
453
|
+
readonly options: readonly [string, ...string[]];
|
|
454
|
+
readonly defaultValue: string | null;
|
|
455
|
+
readonly isOptional: boolean;
|
|
456
|
+
readonly optionLabels: {
|
|
457
|
+
readonly [x: string]: string;
|
|
458
|
+
} & import("../../validate").BuilderValidatedBrand;
|
|
459
|
+
readonly tags?: readonly string[] | undefined;
|
|
460
|
+
} | {
|
|
461
|
+
readonly type: "toggle";
|
|
462
|
+
readonly valueType: "string" | "number" | "boolean";
|
|
463
|
+
readonly defaultValue: string | number | boolean | null;
|
|
464
|
+
readonly isOptional: boolean;
|
|
465
|
+
readonly tags?: readonly string[] | undefined;
|
|
466
|
+
} | null;
|
|
467
|
+
}>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import { BuilderPathsSchema } from '../../paths.js';
|
|
3
2
|
import { paramable } from '../../references.js';
|
|
4
|
-
import {
|
|
3
|
+
import { createEntityValidator } from '../kind.js';
|
|
4
|
+
import { BuilderPathsSchema } from '../paths.js';
|
|
5
|
+
import { serialisable } from '../serialisable.js';
|
|
5
6
|
import { BuilderTagsSchema } from '../tags.js';
|
|
6
7
|
import { createSelectMapSerialisedSchema, createWhenSerialisedSchema } from '../when.js';
|
|
7
|
-
import {
|
|
8
|
+
import { BuilderOptionConfigSerialisedSchema } from './config.js';
|
|
8
9
|
export class BuilderOption {
|
|
9
10
|
name;
|
|
10
11
|
payload;
|
|
@@ -21,12 +22,14 @@ export class BuilderOption {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
export const BuilderOptionSchema = v.instance(BuilderOption);
|
|
24
|
-
export const BuilderOptionWhenSerialisedSchema = createWhenSerialisedSchema(
|
|
25
|
-
export const BuilderOptionSelectMapSerialisedSchema = createSelectMapSerialisedSchema(
|
|
25
|
+
export const BuilderOptionWhenSerialisedSchema = createWhenSerialisedSchema(BuilderOptionConfigSerialisedSchema);
|
|
26
|
+
export const BuilderOptionSelectMapSerialisedSchema = createSelectMapSerialisedSchema(BuilderOptionConfigSerialisedSchema);
|
|
26
27
|
export const BuilderOptionSerialisedSchema = serialisable(v.object({
|
|
27
28
|
name: v.string(),
|
|
28
|
-
payload: paramable(v.union([
|
|
29
|
+
payload: paramable(v.union([BuilderOptionConfigSerialisedSchema, BuilderOptionWhenSerialisedSchema])),
|
|
29
30
|
paths: v.optional(paramable(BuilderPathsSchema)),
|
|
30
31
|
tags: v.optional(BuilderTagsSchema)
|
|
31
32
|
}));
|
|
32
33
|
export const BuilderOptionsSerialisedSchema = v.pipe(v.array(BuilderOptionSerialisedSchema), v.readonly());
|
|
34
|
+
export const validateOptionWhen = createEntityValidator('optionWhen', BuilderOptionWhenSerialisedSchema);
|
|
35
|
+
export const validateOptionSelectMap = createEntityValidator('optionSelectMap', BuilderOptionSelectMapSerialisedSchema);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BuilderTags } from '../tags';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
-
export type
|
|
4
|
-
export type
|
|
5
|
-
export declare class
|
|
3
|
+
export type BuilderSelectConfigLabels<Values extends BuilderSelectConfigValues> = Partial<Record<Values[number], string>>;
|
|
4
|
+
export type BuilderSelectConfigValues = readonly [string, ...ReadonlyArray<string>];
|
|
5
|
+
export declare class BuilderSelectConfig<const Values extends BuilderSelectConfigValues = BuilderSelectConfigValues, const ValueSchema extends v.GenericSchema<string | null> = v.GenericSchema<string | null>> {
|
|
6
6
|
#private;
|
|
7
7
|
readonly value: v.InferOutput<ValueSchema>;
|
|
8
8
|
readonly type: "select";
|
|
@@ -10,20 +10,20 @@ export declare class BuilderSelectType<const Values extends BuilderSelectTypeVal
|
|
|
10
10
|
readonly valueSchema: ValueSchema;
|
|
11
11
|
readonly defaultValue: v.InferOutput<ValueSchema>;
|
|
12
12
|
readonly isOptional: boolean;
|
|
13
|
-
readonly optionLabels:
|
|
13
|
+
readonly optionLabels: BuilderSelectConfigLabels<Values>;
|
|
14
14
|
readonly tags?: BuilderTags;
|
|
15
|
-
constructor(values: Values, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean, optionLabels?:
|
|
16
|
-
default(newDefault: v.InferOutput<ValueSchema>):
|
|
17
|
-
optional():
|
|
18
|
-
labels(optionLabels:
|
|
19
|
-
tag(...tags: Array<string>):
|
|
15
|
+
constructor(values: Values, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean, optionLabels?: BuilderSelectConfigLabels<Values>, tags?: BuilderTags);
|
|
16
|
+
default(newDefault: v.InferOutput<ValueSchema>): BuilderSelectConfig<Values, ValueSchema>;
|
|
17
|
+
optional(): BuilderSelectConfig<Values, v.NullableSchema<ValueSchema, undefined>>;
|
|
18
|
+
labels(optionLabels: BuilderSelectConfigLabels<Values>): BuilderSelectConfig<Values, ValueSchema>;
|
|
19
|
+
tag(...tags: Array<string>): BuilderSelectConfig<Values, ValueSchema>;
|
|
20
20
|
}
|
|
21
|
-
type SelectSchema<Values extends
|
|
21
|
+
type SelectSchema<Values extends BuilderSelectConfigValues> = v.UnionSchema<{
|
|
22
22
|
[K in keyof Values]: v.LiteralSchema<Values[K], undefined>;
|
|
23
23
|
}, undefined>;
|
|
24
|
-
export declare function select<const Values extends
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
24
|
+
export declare function select<const Values extends BuilderSelectConfigValues>(values: Values): BuilderSelectConfig<Values, SelectSchema<Values>>;
|
|
25
|
+
export declare const BuilderSelectConfigSchema: v.InstanceSchema<typeof BuilderSelectConfig, undefined>;
|
|
26
|
+
export declare const BuilderSelectConfigSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
27
27
|
readonly type: v.LiteralSchema<"select", undefined>;
|
|
28
28
|
readonly options: v.SchemaWithPipe<readonly [v.TupleWithRestSchema<[v.StringSchema<undefined>], v.StringSchema<undefined>, undefined>, v.ReadonlyAction<[string, ...string[]]>]>;
|
|
29
29
|
readonly defaultValue: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -40,6 +40,16 @@ export declare const BuilderSelectTypeSerialisedSchema: v.SchemaWithPipe<readonl
|
|
|
40
40
|
};
|
|
41
41
|
tags?: readonly string[] | undefined;
|
|
42
42
|
}>]>;
|
|
43
|
-
export type
|
|
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").BuilderValidateErrors) => import("..").ValidationResult<{
|
|
46
|
+
readonly type: "select";
|
|
47
|
+
readonly options: readonly [string, ...string[]];
|
|
48
|
+
readonly defaultValue: string | null;
|
|
49
|
+
readonly isOptional: boolean;
|
|
50
|
+
readonly optionLabels: {
|
|
51
|
+
readonly [x: string]: string;
|
|
52
|
+
} & import("../../validate").BuilderValidatedBrand;
|
|
53
|
+
readonly tags?: readonly string[] | undefined;
|
|
54
|
+
}>;
|
|
45
55
|
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import {
|
|
2
|
+
import { createEntityValidator } from '../kind.js';
|
|
3
|
+
import { serialisable } from '../serialisable.js';
|
|
3
4
|
import { BuilderTagsSchema } from '../tags.js';
|
|
4
|
-
export class
|
|
5
|
+
export class BuilderSelectConfig {
|
|
5
6
|
type = 'select';
|
|
6
7
|
options;
|
|
7
8
|
valueSchema;
|
|
@@ -18,7 +19,7 @@ export class BuilderSelectType {
|
|
|
18
19
|
this.tags = tags;
|
|
19
20
|
}
|
|
20
21
|
#next(patch) {
|
|
21
|
-
return new
|
|
22
|
+
return new BuilderSelectConfig(this.options, 'defaultValue' in patch
|
|
22
23
|
? patch.defaultValue
|
|
23
24
|
: this.defaultValue, patch.optional ?? this.isOptional, patch.optionLabels ?? this.optionLabels, patch.tags ?? this.tags);
|
|
24
25
|
}
|
|
@@ -37,10 +38,10 @@ export class BuilderSelectType {
|
|
|
37
38
|
}
|
|
38
39
|
export function select(values) {
|
|
39
40
|
const [defaultValue] = values;
|
|
40
|
-
return new
|
|
41
|
+
return new BuilderSelectConfig(values, defaultValue, false);
|
|
41
42
|
}
|
|
42
|
-
export const
|
|
43
|
-
export const
|
|
43
|
+
export const BuilderSelectConfigSchema = v.instance(BuilderSelectConfig);
|
|
44
|
+
export const BuilderSelectConfigSerialisedSchema = serialisable(v.object({
|
|
44
45
|
type: v.literal('select'),
|
|
45
46
|
options: v.pipe(v.tupleWithRest([v.string()], v.string()), v.readonly()),
|
|
46
47
|
defaultValue: v.nullable(v.string()),
|
|
@@ -52,3 +53,13 @@ export function selectValueSchema(options, optional) {
|
|
|
52
53
|
const baseSchema = v.union(options.map((value) => v.literal(value)));
|
|
53
54
|
return optional ? v.nullable(baseSchema) : baseSchema;
|
|
54
55
|
}
|
|
56
|
+
export const validateSelect = createEntityValidator('select', BuilderSelectConfigSerialisedSchema, (input, errors) => {
|
|
57
|
+
if (input.defaultValue != null && !input.options.includes(input.defaultValue)) {
|
|
58
|
+
errors.invalidSelectDefault(input.defaultValue);
|
|
59
|
+
}
|
|
60
|
+
Object.keys(input.optionLabels).forEach((key) => {
|
|
61
|
+
if (!input.options.includes(key)) {
|
|
62
|
+
errors.invalidSelectLabel(key);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -3,7 +3,7 @@ import type { BuilderTags } from '../tags';
|
|
|
3
3
|
import * as v from 'valibot';
|
|
4
4
|
export declare const BuilderToggleValueTypeSchema: v.PicklistSchema<["string", "boolean", "number"], undefined>;
|
|
5
5
|
export type BuilderToggleValueType = v.InferOutput<typeof BuilderToggleValueTypeSchema>;
|
|
6
|
-
export declare class
|
|
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";
|
|
@@ -13,15 +13,15 @@ export declare class BuilderToggleType<const ValueSchema extends v.GenericSchema
|
|
|
13
13
|
readonly isOptional: boolean;
|
|
14
14
|
readonly tags?: BuilderTags;
|
|
15
15
|
constructor(valueType: BuilderToggleValueType, defaultValue: v.InferOutput<ValueSchema>, optional?: boolean, tags?: BuilderTags);
|
|
16
|
-
default(newDefault: v.InferOutput<ValueSchema>):
|
|
17
|
-
optional():
|
|
18
|
-
tag(...tags: Array<string>):
|
|
16
|
+
default(newDefault: v.InferOutput<ValueSchema>): BuilderToggleConfig<ValueSchema>;
|
|
17
|
+
optional(): BuilderToggleConfig<v.NullableSchema<ValueSchema, undefined>>;
|
|
18
|
+
tag(...tags: Array<string>): BuilderToggleConfig<ValueSchema>;
|
|
19
19
|
}
|
|
20
|
-
export declare function toggleString():
|
|
21
|
-
export declare function toggleBoolean():
|
|
22
|
-
export declare function toggleNumber():
|
|
23
|
-
export declare const
|
|
24
|
-
export declare const
|
|
20
|
+
export declare function toggleString(): BuilderToggleConfig<v.StringSchema<undefined>>;
|
|
21
|
+
export declare function toggleBoolean(): BuilderToggleConfig<v.BooleanSchema<undefined>>;
|
|
22
|
+
export declare function toggleNumber(): BuilderToggleConfig<v.NumberSchema<undefined>>;
|
|
23
|
+
export declare const BuilderToggleConfigSchema: v.InstanceSchema<typeof BuilderToggleConfig, undefined>;
|
|
24
|
+
export declare const BuilderToggleConfigSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
25
25
|
readonly type: v.LiteralSchema<"toggle", undefined>;
|
|
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>;
|
|
@@ -34,5 +34,12 @@ export declare const BuilderToggleTypeSerialisedSchema: v.SchemaWithPipe<readonl
|
|
|
34
34
|
isOptional: boolean;
|
|
35
35
|
tags?: readonly string[] | undefined;
|
|
36
36
|
}>]>;
|
|
37
|
-
export type
|
|
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("../../validate").BuilderValidateErrors) => import("..").ValidationResult<{
|
|
40
|
+
readonly type: "toggle";
|
|
41
|
+
readonly valueType: "string" | "number" | "boolean";
|
|
42
|
+
readonly defaultValue: string | number | boolean | null;
|
|
43
|
+
readonly isOptional: boolean;
|
|
44
|
+
readonly tags?: readonly string[] | undefined;
|
|
45
|
+
}>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import {
|
|
2
|
+
import { check } from '../../errors/index.js';
|
|
3
|
+
import { createEntityValidator } from '../kind.js';
|
|
4
|
+
import { serialisable } from '../serialisable.js';
|
|
3
5
|
import { BuilderTagsSchema } from '../tags.js';
|
|
4
6
|
export const BuilderToggleValueTypeSchema = v.picklist(['string', 'boolean', 'number']);
|
|
5
|
-
export class
|
|
7
|
+
export class BuilderToggleConfig {
|
|
6
8
|
type = 'toggle';
|
|
7
9
|
valueType;
|
|
8
10
|
valueSchema;
|
|
@@ -17,7 +19,7 @@ export class BuilderToggleType {
|
|
|
17
19
|
this.tags = tags;
|
|
18
20
|
}
|
|
19
21
|
#next(patch) {
|
|
20
|
-
return new
|
|
22
|
+
return new BuilderToggleConfig(this.valueType, 'defaultValue' in patch
|
|
21
23
|
? patch.defaultValue
|
|
22
24
|
: this.defaultValue, patch.optional ?? this.isOptional, patch.tags ?? this.tags);
|
|
23
25
|
}
|
|
@@ -32,16 +34,16 @@ export class BuilderToggleType {
|
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
export function toggleString() {
|
|
35
|
-
return new
|
|
37
|
+
return new BuilderToggleConfig('string', '');
|
|
36
38
|
}
|
|
37
39
|
export function toggleBoolean() {
|
|
38
|
-
return new
|
|
40
|
+
return new BuilderToggleConfig('boolean', false);
|
|
39
41
|
}
|
|
40
42
|
export function toggleNumber() {
|
|
41
|
-
return new
|
|
43
|
+
return new BuilderToggleConfig('number', 0);
|
|
42
44
|
}
|
|
43
|
-
export const
|
|
44
|
-
export const
|
|
45
|
+
export const BuilderToggleConfigSchema = v.instance(BuilderToggleConfig);
|
|
46
|
+
export const BuilderToggleConfigSerialisedSchema = serialisable(v.object({
|
|
45
47
|
type: v.literal('toggle'),
|
|
46
48
|
valueType: BuilderToggleValueTypeSchema,
|
|
47
49
|
defaultValue: v.nullable(v.union([v.boolean(), v.string(), v.number()])),
|
|
@@ -52,3 +54,12 @@ export function toggleValueSchema(valueType, optional) {
|
|
|
52
54
|
const baseSchema = valueType === 'string' ? v.string() : valueType === 'boolean' ? v.boolean() : v.number();
|
|
53
55
|
return optional ? v.nullable(baseSchema) : baseSchema;
|
|
54
56
|
}
|
|
57
|
+
export const validateToggle = createEntityValidator('toggle', BuilderToggleConfigSerialisedSchema, (input, errors) => {
|
|
58
|
+
if (input.defaultValue == null) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const valueSchema = toggleValueSchema(input.valueType, input.isOptional);
|
|
62
|
+
if (!check.is(valueSchema, input.defaultValue)) {
|
|
63
|
+
errors.invalidToggleDefault(input.defaultValue, input.valueType);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { BuilderPath } from '../../paths';
|
|
2
1
|
import type { Paramable } from '../../references';
|
|
2
|
+
import type { BuilderPath } from '../paths';
|
|
3
3
|
import type { BuilderWhen } from '../when';
|
|
4
|
-
import type {
|
|
5
|
-
export type BuilderOptionWhen = BuilderWhen<Paramable<
|
|
4
|
+
import type { BuilderOptionConfig } from './config';
|
|
5
|
+
export type BuilderOptionWhen = BuilderWhen<Paramable<BuilderOptionConfig>, Paramable<BuilderPath>, Paramable<Record<string, Paramable<BuilderOptionConfig> | null>>, Paramable<BuilderPath>>;
|
|
6
6
|
export declare const optionWhen: {
|
|
7
|
-
enable: <const Values extends Paramable<import("./select").
|
|
8
|
-
match: <const MatchPayload extends Paramable<import("./select").
|
|
9
|
-
unless: <const Values extends Paramable<import("./select").
|
|
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
|
+
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("../..").BuilderPrimitives, values: Values) => import("..").BuilderUnlessConfig<Values, UnlessPath>;
|
|
10
10
|
};
|
|
@@ -3,3 +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.StringSchema<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").BuilderValidateErrors) => import("./validated.js").ValidationResult<readonly (string | number)[]>;
|
|
7
|
+
export declare const validatePaths: (input: unknown, references?: import("./references.js").BuilderReferences, errors?: import("../errors/errors.js").BuilderValidateErrors) => import("./validated.js").ValidationResult<readonly (readonly (string | number)[])[]>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { createEntityValidator } from './kind.js';
|
|
2
3
|
export const BuilderPathSchema = v.pipe(v.array(v.union([v.string(), v.number()])), v.readonly());
|
|
3
4
|
export const BuilderPathsSchema = v.pipe(v.array(BuilderPathSchema), v.readonly());
|
|
5
|
+
export const validatePath = createEntityValidator('path', BuilderPathSchema);
|
|
6
|
+
export const validatePaths = createEntityValidator('paths', BuilderPathsSchema);
|
|
@@ -2,5 +2,5 @@ export type { BuilderPricingExpression, BuilderPricingLookupKey, BuilderPricingR
|
|
|
2
2
|
export type { BuilderRates } from './rates';
|
|
3
3
|
export type { BuilderPricingSerialised } from './pricing';
|
|
4
4
|
export { BuilderPricingExpressionSchema, BuilderPricingLookupKeySchema, BuilderPricingReduceSchema } from './expression.js';
|
|
5
|
-
export { BuilderRatesSchema } from './rates.js';
|
|
5
|
+
export { BuilderRatesSchema, validatePricingRates } from './rates.js';
|
|
6
6
|
export { BuilderPricing, BuilderPricingSchema, BuilderPricingSerialisedSchema, pricing } from './pricing.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { BuilderPricingExpressionSchema, BuilderPricingLookupKeySchema, BuilderPricingReduceSchema } from './expression.js';
|
|
2
|
-
export { BuilderRatesSchema } from './rates.js';
|
|
2
|
+
export { BuilderRatesSchema, validatePricingRates } from './rates.js';
|
|
3
3
|
export { BuilderPricing, BuilderPricingSchema, BuilderPricingSerialisedSchema, pricing } from './pricing.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { paramable } from '../../references.js';
|
|
3
|
-
import { serialisable } from '
|
|
3
|
+
import { serialisable } from '../serialisable.js';
|
|
4
4
|
import { BuilderPricingExpressionSchema } from './expression.js';
|
|
5
5
|
import { BuilderRatesSchema } from './rates.js';
|
|
6
6
|
export class BuilderPricing {
|