@builder-builder/builder 0.0.20 → 0.0.22
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/README.md +33 -24
- package/dist/bb.d.ts +10 -11
- package/dist/bb.js +25 -2
- package/dist/client/client.d.ts +7 -0
- package/dist/client/client.js +19 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.js +2 -0
- package/dist/client/schema.d.ts +396 -0
- package/dist/client/schema.js +13 -0
- package/dist/entities/builder/bind.d.ts +1 -1
- 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 +189 -0
- package/dist/entities/collection/config.js +12 -2
- package/dist/entities/collection/expectation.d.ts +1 -1
- package/dist/entities/collection/index.d.ts +2 -2
- package/dist/entities/collection/index.js +2 -2
- package/dist/entities/collection/when.d.ts +1 -1
- package/dist/entities/component/component.d.ts +61 -7
- package/dist/entities/component/component.js +5 -2
- package/dist/entities/component/config.d.ts +10 -0
- package/dist/entities/component/config.js +19 -2
- package/dist/entities/component/field.js +1 -1
- package/dist/entities/component/index.d.ts +2 -2
- package/dist/entities/component/index.js +2 -2
- package/dist/entities/component/when.d.ts +1 -1
- package/dist/entities/expectation.d.ts +4 -0
- package/dist/entities/expectation.js +3 -1
- package/dist/entities/index.d.ts +15 -13
- 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/methods.d.ts +4 -4
- package/dist/entities/model/model.js +1 -1
- package/dist/entities/option/index.d.ts +3 -3
- package/dist/entities/option/index.js +3 -3
- package/dist/entities/option/option.d.ts +85 -7
- package/dist/entities/option/option.js +5 -2
- package/dist/entities/option/select.d.ts +10 -0
- package/dist/entities/option/select.js +12 -1
- package/dist/entities/option/toggle.d.ts +7 -0
- package/dist/entities/option/toggle.js +12 -1
- package/dist/entities/option/when.d.ts +1 -1
- 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 -6
- package/dist/entities/references.js +7 -1
- package/dist/entities/serialise.d.ts +48 -42
- package/dist/entities/serialise.js +9 -3
- 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 +11 -1
- 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 +1 -1
- package/dist/entities/ui/ui.js +2 -2
- package/dist/entities/ui/uis.js +1 -1
- 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 +14 -14
- package/dist/index.js +3 -2
- package/dist/instance.d.ts +7 -7
- package/dist/instance.js +4 -4
- package/dist/mappers/instance.js +1 -1
- package/dist/mappers/order.d.ts +4 -4
- package/dist/mappers/order.js +1 -1
- package/dist/mappers/price.js +18 -18
- package/dist/mappers/render/render.js +1 -1
- package/dist/mappers/resolve.d.ts +1 -2
- package/dist/mappers/resolve.js +3 -20
- package/dist/mappers/variants/option-graph.d.ts +1 -2
- 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 +2 -3
- package/dist/validate/builder.js +2 -3
- package/dist/validate/expectations.d.ts +1 -1
- package/dist/validate/index.d.ts +4 -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 +2 -3
- 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 +2 -3
- package/dist/validate/pricing.js +2 -3
- package/dist/validate/resolve.d.ts +1 -1
- package/dist/validate/resolve.js +1 -1
- package/dist/validate/ui.d.ts +2 -3
- package/dist/validate/ui.js +13 -4
- package/dist/validate/variants.d.ts +4 -5
- package/dist/validate/variants.js +4 -5
- package/package.json +17 -5
- 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
package/dist/entities/kind.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type { BuilderReferences } from './references';
|
|
1
2
|
import type { EntitiesMap } from './serialise';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export declare const
|
|
3
|
+
import type { BuilderValidatedMap, ValidationResult } from './validated';
|
|
4
|
+
import type * as v from 'valibot';
|
|
5
|
+
import { BuilderValidateErrors } from '../errors/index.js';
|
|
6
|
+
export declare const builderEntityKinds: readonly ["builder", "model", "select", "toggle", "optionSelectMap", "optionWhen", "componentConfig", "componentSelectMap", "componentWhen", "collectionConfig", "collectionSelectMap", "collectionWhen", "ui", "uiDescribe", "uiItems", "uiPage", "uiPages", "uiInput", "pricing", "pricingRates", "expectations", "paths", "path", "number", "string", "boolean"];
|
|
7
|
+
export type BuilderEntityKind = (typeof builderEntityKinds)[number];
|
|
6
8
|
export type BuilderEntitySerialised = {
|
|
7
|
-
[Kind in
|
|
8
|
-
}[
|
|
9
|
-
export
|
|
9
|
+
[Kind in BuilderEntityKind]: v.InferOutput<EntitiesMap[Kind]['serialised']>;
|
|
10
|
+
}[BuilderEntityKind];
|
|
11
|
+
export type EntityValidate<Kind extends BuilderEntityKind> = (input: BuilderValidatedMap[Kind], errors: BuilderValidateErrors, references: BuilderReferences) => void;
|
|
12
|
+
export declare function createEntityValidator<Kind extends BuilderEntityKind>(kind: Kind, schema: v.GenericSchema, validate?: EntityValidate<Kind>): (input: unknown, references?: BuilderReferences, errors?: BuilderValidateErrors) => ValidationResult<BuilderValidatedMap[Kind]>;
|
package/dist/entities/kind.js
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { BuilderValidateErrors, check } from '../errors/index.js';
|
|
2
|
+
export const builderEntityKinds = [
|
|
3
|
+
'builder',
|
|
4
|
+
'model',
|
|
5
|
+
'select',
|
|
6
|
+
'toggle',
|
|
7
|
+
'optionSelectMap',
|
|
8
|
+
'optionWhen',
|
|
9
|
+
'componentConfig',
|
|
10
|
+
'componentSelectMap',
|
|
11
|
+
'componentWhen',
|
|
12
|
+
'collectionConfig',
|
|
13
|
+
'collectionSelectMap',
|
|
14
|
+
'collectionWhen',
|
|
15
|
+
'ui',
|
|
16
|
+
'uiDescribe',
|
|
17
|
+
'uiItems',
|
|
18
|
+
'uiPage',
|
|
19
|
+
'uiPages',
|
|
20
|
+
'uiInput',
|
|
21
|
+
'pricing',
|
|
22
|
+
'pricingRates',
|
|
23
|
+
'expectations',
|
|
24
|
+
'paths',
|
|
25
|
+
'path',
|
|
26
|
+
'number',
|
|
27
|
+
'string',
|
|
28
|
+
'boolean'
|
|
29
|
+
];
|
|
30
|
+
export function createEntityValidator(kind, schema, validate) {
|
|
31
|
+
return (input, references = [], errors = new BuilderValidateErrors()) => {
|
|
32
|
+
if (!check.is(schema, input)) {
|
|
33
|
+
errors.invalidEntity(kind);
|
|
34
|
+
return [input, errors.errors];
|
|
35
|
+
}
|
|
36
|
+
validate?.(input, errors, references);
|
|
37
|
+
return [input, errors.errors];
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { BuilderPaths } from '../../paths';
|
|
2
1
|
import type { BuilderParameter, BuilderRef, Paramable } from '../../references';
|
|
3
2
|
import type { BuilderCollectionConfig, BuilderCollectionPayload } from '../collection/index';
|
|
4
3
|
import type { BuilderComponentPayload } from '../component/index';
|
|
5
4
|
import type { BuilderOptionPayload } from '../option/index';
|
|
5
|
+
import type { BuilderPaths } from '../paths';
|
|
6
6
|
import type { BuilderWhenConstrained, BuilderWhenGeneric, WhenConfigNullable } from '../when';
|
|
7
7
|
import type { BuilderModelGeneric } from './model';
|
|
8
8
|
import type { BuilderModels } from './models';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { BuilderPaths } from '../../paths';
|
|
2
1
|
import type { BuilderParameter, Paramable } from '../../references';
|
|
3
2
|
import type { BuilderCollectionConfig, BuilderCollectionWhen } from '../collection/index';
|
|
4
3
|
import type { BuilderComponentConfig, BuilderComponentWhen } from '../component/index';
|
|
5
4
|
import type { BuilderOptionConfig, BuilderOptionWhen } from '../option/index';
|
|
5
|
+
import type { BuilderPaths } from '../paths';
|
|
6
6
|
import type { BuilderValidPaths, BuilderWhenConstrained, WhenConfigPayload, WhenNullability } from '../when';
|
|
7
7
|
import type { BuilderModel } from './model';
|
|
8
8
|
import type { BuilderModelState, BuilderModelStateAppend } from './state';
|
|
@@ -46,12 +46,12 @@ type CollectionInstanceOf<Collection extends BuilderCollection> = [Collection['p
|
|
|
46
46
|
type CollectionShape<Collection extends BuilderCollection, Item> = Collection['payload'] extends BuilderCollectionConfig ? Collection['payload']['min'] extends number ? Collection['payload']['max'] extends number ? number extends Collection['payload']['min'] ? ReadonlyArray<Item> : number extends Collection['payload']['max'] ? ReadonlyArray<Item> : Collection['payload']['min'] extends Collection['payload']['max'] ? CollectionTuple<Item, Collection['payload']['min']> : ReadonlyArray<Item> : ReadonlyArray<Item> : ReadonlyArray<Item> : ReadonlyArray<Item>;
|
|
47
47
|
type CollectionTuple<Item, Length extends number, Result extends ReadonlyArray<Item> = []> = Result['length'] extends Length ? Result : CollectionTuple<Item, Length, [...Result, Item]>;
|
|
48
48
|
export declare function builderOptionMethod(): ((name: string, payload: Paramable<BuilderOptionConfig>) => BuilderOption<string, Paramable<import("..").BuilderSelectConfig<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import("..").BuilderToggleConfig<import("valibot").GenericSchema<string | number | boolean | null>>>, Paramable<readonly (readonly (string | number)[])[]>>) & {
|
|
49
|
-
when(paths: Paramable<BuilderPaths>, name: string, payload: Paramable<BuilderOptionWhen>): BuilderOption<string, Paramable<BuilderOptionWhen>, readonly (readonly (string | number)[])[]
|
|
49
|
+
when(paths: Paramable<BuilderPaths>, name: string, payload: Paramable<BuilderOptionWhen>): BuilderOption<string, Paramable<BuilderOptionWhen>, BuilderParameter<string> | import("../..").BuilderRef | readonly (readonly (string | number)[])[]>;
|
|
50
50
|
};
|
|
51
51
|
export declare function builderComponentMethod(): ((name: string, payload?: Paramable<BuilderComponentConfig>) => BuilderComponent<string, Paramable<BuilderComponentConfig<Paramable<readonly import("..").BuilderComponentField<string, import("valibot").GenericSchema<string | number | boolean | null>>[]>>>, Paramable<readonly (readonly (string | number)[])[]>>) & {
|
|
52
|
-
when(paths: Paramable<BuilderPaths>, name: string, payload?: Paramable<BuilderComponentWhen>): BuilderComponent<string, Paramable<BuilderComponentWhen>, readonly (readonly (string | number)[])[]
|
|
52
|
+
when(paths: Paramable<BuilderPaths>, name: string, payload?: Paramable<BuilderComponentWhen>): BuilderComponent<string, Paramable<BuilderComponentWhen>, BuilderParameter<string> | import("../..").BuilderRef | readonly (readonly (string | number)[])[]>;
|
|
53
53
|
};
|
|
54
54
|
export declare function builderCollectionMethod(): ((name: string, payload: Paramable<BuilderCollectionConfig>) => BuilderCollection<string, Paramable<BuilderCollectionConfig<Paramable<import("./model").BuilderModelGeneric>, Paramable<number>, Paramable<number>>>, Paramable<readonly (readonly (string | number)[])[]>>) & {
|
|
55
|
-
when(paths: Paramable<BuilderPaths>, name: string, payload: Paramable<BuilderCollectionWhen>): BuilderCollection<string, Paramable<BuilderCollectionWhen>, readonly (readonly (string | number)[])[]
|
|
55
|
+
when(paths: Paramable<BuilderPaths>, name: string, payload: Paramable<BuilderCollectionWhen>): BuilderCollection<string, Paramable<BuilderCollectionWhen>, BuilderParameter<string> | import("../..").BuilderRef | readonly (readonly (string | number)[])[]>;
|
|
56
56
|
};
|
|
57
57
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import { serialisable } from '../../serialisable.js';
|
|
3
2
|
import { BuilderCollectionsSerialisedSchema } from '../collection/index.js';
|
|
4
3
|
import { BuilderComponentsSerialisedSchema } from '../component/index.js';
|
|
5
4
|
import { BuilderExpectationsSerialisedSchema } from '../expectation.js';
|
|
6
5
|
import { BuilderOptionsSerialisedSchema } from '../option/index.js';
|
|
6
|
+
import { serialisable } from '../serialisable.js';
|
|
7
7
|
import { BuilderTagsSchema } from '../tags.js';
|
|
8
8
|
import { builderCollectionMethod, builderComponentMethod, builderOptionMethod } from './methods.js';
|
|
9
9
|
import { BuilderModelsSerialisedSchema } from './models.js';
|
|
@@ -3,9 +3,9 @@ export type { BuilderSelectConfigLabels, BuilderSelectConfigSerialised, BuilderS
|
|
|
3
3
|
export type { BuilderToggleConfigSerialised, BuilderToggleValueType } from './toggle';
|
|
4
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 { BuilderSelectConfig, BuilderSelectConfigSchema, BuilderSelectConfigSerialisedSchema, select } from './select.js';
|
|
8
|
-
export { BuilderToggleConfig, BuilderToggleConfigSchema, BuilderToggleConfigSerialisedSchema, toggleBoolean, toggleNumber, toggleString } from './toggle.js';
|
|
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
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 { BuilderSelectConfig, BuilderSelectConfigSchema, BuilderSelectConfigSerialisedSchema, select } from './select.js';
|
|
3
|
-
export { BuilderToggleConfig, BuilderToggleConfigSchema, BuilderToggleConfigSerialisedSchema, toggleBoolean, toggleNumber, toggleString } from './toggle.js';
|
|
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
4
|
export { BuilderOptionConfigSchema, BuilderOptionConfigSerialisedSchema, BuilderOptionConfigsSerialisedSchema, optionValueSchema } from './config.js';
|
|
5
5
|
export { optionExpectation } from './expectation.js';
|
|
6
6
|
export { optionWhen } from './when.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
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
5
|
import type { BuilderOptionConfig, BuilderOptionConfigSerialised } from './config';
|
|
@@ -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,7 +1,8 @@
|
|
|
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
8
|
import { BuilderOptionConfigSerialisedSchema } from './config.js';
|
|
@@ -30,3 +31,5 @@ export const BuilderOptionSerialisedSchema = serialisable(v.object({
|
|
|
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);
|
|
@@ -42,4 +42,14 @@ 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").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,5 +1,6 @@
|
|
|
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
5
|
export class BuilderSelectConfig {
|
|
5
6
|
type = 'select';
|
|
@@ -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
|
+
});
|
|
@@ -36,3 +36,10 @@ 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("../../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,5 +1,7 @@
|
|
|
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
7
|
export class BuilderToggleConfig {
|
|
@@ -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,5 +1,5 @@
|
|
|
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
4
|
import type { BuilderOptionConfig } from './config';
|
|
5
5
|
export type BuilderOptionWhen = BuilderWhen<Paramable<BuilderOptionConfig>, Paramable<BuilderPath>, Paramable<Record<string, Paramable<BuilderOptionConfig> | null>>, Paramable<BuilderPath>>;
|
|
@@ -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 {
|
|
@@ -1,3 +1,8 @@
|
|
|
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").BuilderValidateErrors) => import("../validated.js").ValidationResult<{
|
|
5
|
+
readonly [x: string]: {
|
|
6
|
+
readonly [x: string]: number;
|
|
7
|
+
} & import("../../validate/brand.js").BuilderValidatedBrand;
|
|
8
|
+
}>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import { serialisable } from '
|
|
2
|
+
import { serialisable } from '../serialisable.js';
|
|
3
|
+
import { createEntityValidator } from '../kind.js';
|
|
3
4
|
export const BuilderRatesSchema = serialisable(v.record(v.string(), v.record(v.string(), v.number())));
|
|
5
|
+
export const validatePricingRates = createEntityValidator('pricingRates', BuilderRatesSchema);
|