@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
package/dist/mappers/resolve.js
CHANGED
|
@@ -1,40 +1,39 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { BuilderCollectionConfigSerialisedSchema, BuilderComponentConfigSerialisedSchema, BuilderOptionConfigSerialisedSchema, BuilderPathsSchema, BuilderWhenSerialisedSchema, modelsMerge, whenBranches } from '../entities/index.js';
|
|
3
|
+
import { check } from '../errors/index.js';
|
|
4
4
|
import { BuilderInstanceSchema, BuilderInstancesSchema } from '../instance.js';
|
|
5
|
-
import { BuilderPathsSchema } from '../paths.js';
|
|
6
5
|
import { BuilderPrimitiveSchema } from '../primitive.js';
|
|
7
6
|
import { BuilderRefSerialisedSchema } from '../references.js';
|
|
8
|
-
export function resolveOption(option, model, instance,
|
|
9
|
-
return resolveEntryInstance(option,
|
|
7
|
+
export function resolveOption(option, model, instance, references = []) {
|
|
8
|
+
return resolveEntryInstance(option, BuilderOptionConfigSerialisedSchema, model, instance, references);
|
|
10
9
|
}
|
|
11
|
-
export function resolveOptions(option,
|
|
12
|
-
return resolveEntryExhaustive(option,
|
|
10
|
+
export function resolveOptions(option, references = []) {
|
|
11
|
+
return resolveEntryExhaustive(option, BuilderOptionConfigSerialisedSchema, references);
|
|
13
12
|
}
|
|
14
|
-
export function resolveComponent(component, model, instance,
|
|
15
|
-
return resolveEntryInstance(component,
|
|
13
|
+
export function resolveComponent(component, model, instance, references = []) {
|
|
14
|
+
return resolveEntryInstance(component, BuilderComponentConfigSerialisedSchema, model, instance, references);
|
|
16
15
|
}
|
|
17
|
-
export function resolveComponents(component,
|
|
18
|
-
return resolveEntryExhaustive(component,
|
|
16
|
+
export function resolveComponents(component, references = []) {
|
|
17
|
+
return resolveEntryExhaustive(component, BuilderComponentConfigSerialisedSchema, references);
|
|
19
18
|
}
|
|
20
|
-
export function resolveCollection(collection, model, instance,
|
|
21
|
-
return resolveEntryInstance(collection, BuilderCollectionConfigSerialisedSchema, model, instance,
|
|
19
|
+
export function resolveCollection(collection, model, instance, references = []) {
|
|
20
|
+
return resolveEntryInstance(collection, BuilderCollectionConfigSerialisedSchema, model, instance, references);
|
|
22
21
|
}
|
|
23
|
-
export function resolveCollections(collection,
|
|
24
|
-
return resolveEntryExhaustive(collection, BuilderCollectionConfigSerialisedSchema,
|
|
22
|
+
export function resolveCollections(collection, references = []) {
|
|
23
|
+
return resolveEntryExhaustive(collection, BuilderCollectionConfigSerialisedSchema, references);
|
|
25
24
|
}
|
|
26
|
-
export function
|
|
25
|
+
export function resolveReference(value, references) {
|
|
27
26
|
if (!check.is(BuilderRefSerialisedSchema, value)) {
|
|
28
27
|
return value;
|
|
29
28
|
}
|
|
30
|
-
const found =
|
|
29
|
+
const found = references.find((entry) => entry.id === value.id);
|
|
31
30
|
check.truthy(found, `Reference '${value.id}' not found! ❌`);
|
|
32
31
|
return found.serialised;
|
|
33
32
|
}
|
|
34
|
-
export function resolvePath(model, instance, path,
|
|
33
|
+
export function resolvePath(model, instance, path, references = []) {
|
|
35
34
|
const optionName = path.at(-1);
|
|
36
35
|
check.assert(v.string(), optionName, 'Path must end at an option name! ❌');
|
|
37
|
-
const descended = resolveItems(model, instance, path.slice(0, -1),
|
|
36
|
+
const descended = resolveItems(model, instance, path.slice(0, -1), references);
|
|
38
37
|
if (descended == null) {
|
|
39
38
|
return null;
|
|
40
39
|
}
|
|
@@ -42,13 +41,13 @@ export function resolvePath(model, instance, path, refs = []) {
|
|
|
42
41
|
const merged = modelsMerge(scopeModel);
|
|
43
42
|
const option = merged.options.find((entry) => entry.name === optionName);
|
|
44
43
|
check.truthy(option, `Path target '${optionName}' is not an option! ❌`);
|
|
45
|
-
const payload = resolveOption(option, scopeModel, scopeInstance,
|
|
44
|
+
const payload = resolveOption(option, scopeModel, scopeInstance, references);
|
|
46
45
|
if (payload == null) {
|
|
47
46
|
return null;
|
|
48
47
|
}
|
|
49
48
|
return { name: optionName, payload, value: scopeInstance[optionName] };
|
|
50
49
|
}
|
|
51
|
-
export function resolveItems(model, instance, pairs,
|
|
50
|
+
export function resolveItems(model, instance, pairs, references = []) {
|
|
52
51
|
check.assert(BuilderInstanceSchema, instance);
|
|
53
52
|
if (pairs.length === 0) {
|
|
54
53
|
return [model, instance];
|
|
@@ -59,7 +58,7 @@ export function resolveItems(model, instance, pairs, refs = []) {
|
|
|
59
58
|
const merged = modelsMerge(model);
|
|
60
59
|
const collection = merged.collections.find((entry) => entry.name === name);
|
|
61
60
|
check.truthy(collection, `Path segment '${name}' is not a collection! ❌`);
|
|
62
|
-
const resolved = resolveCollection(collection, model, instance,
|
|
61
|
+
const resolved = resolveCollection(collection, model, instance, references);
|
|
63
62
|
if (resolved == null) {
|
|
64
63
|
return null;
|
|
65
64
|
}
|
|
@@ -69,17 +68,17 @@ export function resolveItems(model, instance, pairs, refs = []) {
|
|
|
69
68
|
if (item == null) {
|
|
70
69
|
return null;
|
|
71
70
|
}
|
|
72
|
-
return resolveItems(resolved.model, item, rest,
|
|
71
|
+
return resolveItems(resolved.model, item, rest, references);
|
|
73
72
|
}
|
|
74
|
-
function resolveEntryInstance(entry, schema, model, instance,
|
|
75
|
-
const payload =
|
|
73
|
+
function resolveEntryInstance(entry, schema, model, instance, references) {
|
|
74
|
+
const payload = resolveReference(entry.payload, references);
|
|
76
75
|
if (check.is(schema, payload)) {
|
|
77
76
|
return payload;
|
|
78
77
|
}
|
|
79
78
|
check.assert(BuilderWhenSerialisedSchema, payload);
|
|
80
79
|
check.assert(BuilderPathsSchema, entry.paths);
|
|
81
80
|
const config = payload;
|
|
82
|
-
if (!entry.paths.every((path) => Boolean(resolvePath(model, instance, path,
|
|
81
|
+
if (!entry.paths.every((path) => Boolean(resolvePath(model, instance, path, references)?.value))) {
|
|
83
82
|
return null;
|
|
84
83
|
}
|
|
85
84
|
switch (config.type) {
|
|
@@ -88,11 +87,11 @@ function resolveEntryInstance(entry, schema, model, instance, refs) {
|
|
|
88
87
|
}
|
|
89
88
|
case 'match': {
|
|
90
89
|
const selectMap = config.selectMap;
|
|
91
|
-
const matched = resolvePath(model, instance, config.matchPath,
|
|
90
|
+
const matched = resolvePath(model, instance, config.matchPath, references);
|
|
92
91
|
return selectMap[`${matched?.value}`] ?? null;
|
|
93
92
|
}
|
|
94
93
|
case 'unless': {
|
|
95
|
-
const value = resolvePath(model, instance, config.unlessPath,
|
|
94
|
+
const value = resolvePath(model, instance, config.unlessPath, references)?.value;
|
|
96
95
|
if (!value) {
|
|
97
96
|
return null;
|
|
98
97
|
}
|
|
@@ -104,22 +103,6 @@ function resolveEntryInstance(entry, schema, model, instance, refs) {
|
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
|
-
function resolveEntryExhaustive(entry, schema,
|
|
108
|
-
|
|
109
|
-
if (check.is(schema, payload)) {
|
|
110
|
-
return [payload];
|
|
111
|
-
}
|
|
112
|
-
if (!check.is(BuilderWhenSerialisedSchema, payload)) {
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
115
|
-
const when = payload;
|
|
116
|
-
switch (when.type) {
|
|
117
|
-
case 'enable':
|
|
118
|
-
case 'unless': {
|
|
119
|
-
return [when.payload];
|
|
120
|
-
}
|
|
121
|
-
case 'match': {
|
|
122
|
-
return Object.values(when.selectMap).filter((branch) => branch != null);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
106
|
+
function resolveEntryExhaustive(entry, schema, references) {
|
|
107
|
+
return whenBranches(resolveReference(entry.payload, references), schema);
|
|
125
108
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { BuilderModelValidated, BuilderOptionValidated,
|
|
1
|
+
import type { BuilderModelValidated, BuilderOptionValidated, BuilderPaths } from '../../entities/index';
|
|
2
2
|
import type { BuilderInstances } from '../../instance';
|
|
3
|
-
import type { BuilderPaths } from '../../paths';
|
|
4
3
|
export type GraphKeys = ReadonlySet<string>;
|
|
5
4
|
export type GraphPath = {
|
|
6
5
|
name: string;
|
|
@@ -9,7 +8,7 @@ export type GraphPath = {
|
|
|
9
8
|
};
|
|
10
9
|
export type GraphPaths = ReadonlyArray<GraphPath>;
|
|
11
10
|
export declare function crossProduct(left: BuilderInstances, right: BuilderInstances): BuilderInstances;
|
|
12
|
-
export declare function dependencyKeys(payload: unknown
|
|
11
|
+
export declare function dependencyKeys(payload: unknown, paths?: BuilderPaths): ReadonlyArray<string>;
|
|
13
12
|
export declare class BuilderOptionGraph {
|
|
14
13
|
#private;
|
|
15
14
|
readonly paths: GraphPaths;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BuilderPathSchema } from '../../paths.js';
|
|
1
|
+
import { BuilderPathSchema, BuilderWhenMatchSchema, BuilderWhenUnlessSchema } from '../../entities/index.js';
|
|
2
|
+
import { check } from '../../errors/index.js';
|
|
4
3
|
import { resolveOption } from '../resolve.js';
|
|
5
4
|
export function crossProduct(left, right) {
|
|
6
5
|
return left.flatMap((leftModel) => right.map((rightModel) => ({ ...leftModel, ...rightModel })));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BuilderCollectionValidated, BuilderComponentValidated, BuilderModelValidated, BuilderValidated } from '../../entities/index';
|
|
2
|
-
import type {
|
|
2
|
+
import type { BuilderVariants, BuilderInstances } from '../../instance';
|
|
3
3
|
import { BuilderOptionGraph } from './option-graph.js';
|
|
4
|
-
export declare function createVariants(entity: BuilderValidated | BuilderModelValidated):
|
|
4
|
+
export declare function createVariants(entity: BuilderValidated | BuilderModelValidated): BuilderVariants;
|
|
5
5
|
export declare function optionGraph(model: BuilderModelValidated): BuilderOptionGraph;
|
|
6
6
|
export declare function variantsFor(entity: BuilderComponentValidated | BuilderCollectionValidated, options: BuilderOptionGraph): BuilderInstances;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { check } from '../../check.js';
|
|
2
1
|
import { BuilderModelSerialisedSchema, BuilderSerialisedSchema } from '../../entities/index.js';
|
|
2
|
+
import { check } from '../../errors/index.js';
|
|
3
3
|
import { resolveCollection } from '../resolve.js';
|
|
4
4
|
import { BuilderOptionGraph, crossProduct, dependencyKeys } from './option-graph.js';
|
|
5
5
|
export function createVariants(entity) {
|
package/dist/private.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { BuilderCollectionConfigSchema, BuilderCollectionConfigSerialisedSchema, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionWhenSerialisedSchema,
|
|
1
|
+
export { BuilderCollectionConfigSchema, BuilderCollectionConfigSerialisedSchema, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionWhenSerialisedSchema, BuilderComponentConfigSchema, BuilderComponentConfigSerialisedSchema, BuilderComponentFieldSchema, BuilderComponentFieldSerialisedSchema, BuilderComponentFieldsSchema, BuilderComponentFieldsSerialisedSchema, BuilderComponentFieldValueTypeSchema, BuilderComponentSchema, BuilderComponentSelectMapSerialisedSchema, BuilderComponentSerialisedSchema, BuilderComponentsSerialisedSchema, BuilderComponentWhenSerialisedSchema, BuilderDescriptionItemSchema, BuilderDescriptionSchema, BuilderEntityKindSchema, BuilderEntitySerialisedSchema, BuilderExpectationKindSchema, BuilderExpectationSchema, BuilderExpectationSerialisedSchema, BuilderExpectationsSchema, BuilderExpectationsSerialisedSchema, BuilderModelSchema, BuilderModelSerialisedSchema, BuilderOptionConfigSchema, BuilderOptionConfigSerialisedSchema, BuilderOptionSchema, BuilderOptionSelectMapSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionsSerialisedSchema, BuilderOptionWhenSerialisedSchema, BuilderPathSchema, BuilderPathsSchema, BuilderReferenceSchema, BuilderReferencesSchema, BuilderSchema, BuilderSelectConfigSchema, BuilderSelectConfigSerialisedSchema, BuilderSerialisedSchema, BuilderToggleConfigSchema, BuilderToggleConfigSerialisedSchema, BuilderUIDescribeSchema, BuilderUIDescribeSerialisedSchema, BuilderUIItemSerialisedSchema, BuilderUIItemsSerialisedSchema, BuilderUIPageSchema, BuilderUIPageSerialisedSchema, BuilderUIPagesSchema, BuilderUIPagesSerialisedSchema, BuilderUISchema, BuilderUISerialisedSchema, BuilderWhenConfigSchema, BuilderWhenEnableSchema, BuilderWhenMatchSchema, BuilderWhenUnlessSchema } from './entities/index.js';
|
|
2
2
|
export { BuilderEnvironmentSchema } from './environment.js';
|
|
3
3
|
export { BuilderComponentVariantsSchema, BuilderVariantsSchema } from './instance.js';
|
|
4
|
-
export { BuilderPathSchema, BuilderPathsSchema } from './paths.js';
|
package/dist/private.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { BuilderCollectionConfigSchema, BuilderCollectionConfigSerialisedSchema, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionWhenSerialisedSchema,
|
|
1
|
+
export { BuilderCollectionConfigSchema, BuilderCollectionConfigSerialisedSchema, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionWhenSerialisedSchema, BuilderComponentConfigSchema, BuilderComponentConfigSerialisedSchema, BuilderComponentFieldSchema, BuilderComponentFieldSerialisedSchema, BuilderComponentFieldsSchema, BuilderComponentFieldsSerialisedSchema, BuilderComponentFieldValueTypeSchema, BuilderComponentSchema, BuilderComponentSelectMapSerialisedSchema, BuilderComponentSerialisedSchema, BuilderComponentsSerialisedSchema, BuilderComponentWhenSerialisedSchema, BuilderDescriptionItemSchema, BuilderDescriptionSchema, BuilderEntityKindSchema, BuilderEntitySerialisedSchema, BuilderExpectationKindSchema, BuilderExpectationSchema, BuilderExpectationSerialisedSchema, BuilderExpectationsSchema, BuilderExpectationsSerialisedSchema, BuilderModelSchema, BuilderModelSerialisedSchema, BuilderOptionConfigSchema, BuilderOptionConfigSerialisedSchema, BuilderOptionSchema, BuilderOptionSelectMapSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionsSerialisedSchema, BuilderOptionWhenSerialisedSchema, BuilderPathSchema, BuilderPathsSchema, BuilderReferenceSchema, BuilderReferencesSchema, BuilderSchema, BuilderSelectConfigSchema, BuilderSelectConfigSerialisedSchema, BuilderSerialisedSchema, BuilderToggleConfigSchema, BuilderToggleConfigSerialisedSchema, BuilderUIDescribeSchema, BuilderUIDescribeSerialisedSchema, BuilderUIItemSerialisedSchema, BuilderUIItemsSerialisedSchema, BuilderUIPageSchema, BuilderUIPageSerialisedSchema, BuilderUIPagesSchema, BuilderUIPagesSerialisedSchema, BuilderUISchema, BuilderUISerialisedSchema, BuilderWhenConfigSchema, BuilderWhenEnableSchema, BuilderWhenMatchSchema, BuilderWhenUnlessSchema } from './entities/index.js';
|
|
2
2
|
export { BuilderEnvironmentSchema } from './environment.js';
|
|
3
3
|
export { BuilderComponentVariantsSchema, BuilderVariantsSchema } from './instance.js';
|
|
4
|
-
export { BuilderPathSchema, BuilderPathsSchema } from './paths.js';
|
package/dist/references.js
CHANGED
package/dist/validate/brand.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { BuilderException } from '../
|
|
2
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
1
|
+
import { BuilderException, BuilderValidateErrors } from '../errors/index.js';
|
|
3
2
|
const VALIDATED_ENTITIES = new WeakSet();
|
|
4
3
|
export function validate(value) {
|
|
5
4
|
VALIDATED_ENTITIES.add(value);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
1
|
+
import type { BuilderReferences, BuilderValidated, ValidationResult } from '../entities/index';
|
|
2
|
+
import { BuilderValidateErrors } from '../errors/index.js';
|
|
4
3
|
export type BuilderValidationResult = ValidationResult<BuilderValidated>;
|
|
5
|
-
export declare function validateBuilder(input: unknown, references?:
|
|
4
|
+
export declare function validateBuilder(input: unknown, references?: BuilderReferences, errors?: BuilderValidateErrors): BuilderValidationResult;
|
package/dist/validate/builder.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { check } from '../check.js';
|
|
2
1
|
import { builder, BuilderSerialisedSchema, modelsMerge, serialise } from '../entities/index.js';
|
|
2
|
+
import { BuilderValidateErrors, check } from '../errors/index.js';
|
|
3
3
|
import { validate } from './brand.js';
|
|
4
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
5
4
|
import { checkModelExpectations, validateModelStructure } from './model.js';
|
|
6
5
|
import { checkPricingExpectations, validatePricingStructure } from './pricing.js';
|
|
7
6
|
import { resolver } from './resolve.js';
|
|
@@ -9,7 +8,7 @@ import { checkUIExpectations, validateUIStructure } from './ui.js';
|
|
|
9
8
|
const EMPTY_BUILDER = validate(serialise.builder(builder()));
|
|
10
9
|
export function validateBuilder(input, references = [], errors = new BuilderValidateErrors()) {
|
|
11
10
|
if (!check.is(BuilderSerialisedSchema, input)) {
|
|
12
|
-
errors.
|
|
11
|
+
errors.invalidEntity('builder');
|
|
13
12
|
return [EMPTY_BUILDER, errors.errors];
|
|
14
13
|
}
|
|
15
14
|
const resolve = resolver(errors, references, input.bindings);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { BuilderExpectationsSerialised, BuilderModelSerialised } from '../entities/index';
|
|
2
|
-
import type { BuilderValidateErrors } from '
|
|
2
|
+
import type { BuilderValidateErrors } from '../errors/index';
|
|
3
3
|
export declare function checkExpectations(model: BuilderModelSerialised, expectations: BuilderExpectationsSerialised, errors: BuilderValidateErrors): void;
|
package/dist/validate/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
export type { BuilderValidatedMap, ValidationResult } from '../entities/index';
|
|
2
|
+
export type { BuilderErrorKind, BuilderValidateErrors } from '../errors/index';
|
|
3
|
+
export type { BuilderValidatedBrand } from './brand';
|
|
1
4
|
export type { BuilderValidationResult } from './builder';
|
|
2
|
-
export type { BuilderErrorDuplicateName, BuilderErrorInvalidCollection, BuilderErrorInvalidCollectionBounds, BuilderErrorInvalidDetail, BuilderErrorInvalidInput, BuilderErrorInvalidOption, BuilderErrorInvalidPath, BuilderErrorInvalidPathReason, BuilderErrorInvalidPricing, BuilderErrorInvalidSelectMapKey, BuilderErrorInvalidPricingReason, BuilderErrorInvalidVariant, BuilderErrorMissingComponent, BuilderErrorMissingDetail, BuilderErrorMissingRate, BuilderErrorMissingReference, BuilderErrorMissingVariant, BuilderErrorUnboundParameter, BuilderErrorUnexpectedComponent, BuilderErrorUnexpectedDetail, BuilderErrorUnmetExpectation, BuilderErrorUnvalidated, BuilderInvalidInputTarget } from './errors';
|
|
3
5
|
export type { BuilderInstanceValidationResult } from './instance';
|
|
4
6
|
export type { BuilderModelValidationResult } from './model';
|
|
5
7
|
export type { BuilderPricingValidationResult } from './pricing';
|
|
6
8
|
export type { BuilderUIValidationResult } from './ui';
|
|
7
|
-
export type {
|
|
9
|
+
export type { BuilderVariantsValidationOptions, BuilderVariantsValidationResult } from './variants';
|
|
10
|
+
export { createEntityValidator } from '../entities/index.js';
|
|
8
11
|
export { assertValidated } from './brand.js';
|
|
9
12
|
export { validateBuilder } from './builder.js';
|
|
10
13
|
export { validateInstance } from './instance.js';
|
package/dist/validate/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { BuilderInstanceValidated, BuilderModelValidated } from '../entities/index';
|
|
1
|
+
import type { BuilderInstanceValidated, BuilderModelValidated, ValidationResult } from '../entities/index';
|
|
2
2
|
import type { BuilderInstance } from '../instance';
|
|
3
|
-
import
|
|
4
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
3
|
+
import { BuilderValidateErrors } from '../errors/index.js';
|
|
5
4
|
export type BuilderInstanceValidationResult = ValidationResult<BuilderInstanceValidated>;
|
|
6
5
|
export declare function validateInstance(model: BuilderModelValidated, instance: BuilderInstance, errors?: BuilderValidateErrors): BuilderInstanceValidationResult;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { check } from '../check.js';
|
|
2
1
|
import { optionValueSchema } from '../entities/index.js';
|
|
2
|
+
import { BuilderValidateErrors, check } from '../errors/index.js';
|
|
3
3
|
import { BuilderInstancesSchema } from '../instance.js';
|
|
4
4
|
import { resolveCollection, resolveOption } from '../mappers/index.js';
|
|
5
5
|
import { validate } from './brand.js';
|
|
6
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
7
6
|
export function validateInstance(model, instance, errors = new BuilderValidateErrors()) {
|
|
8
7
|
errors.scope('instance', () => {
|
|
9
8
|
checkInstance(model, instance);
|
package/dist/validate/model.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { BuilderModelSerialised, BuilderModelValidated,
|
|
1
|
+
import type { BuilderModelSerialised, BuilderModelValidated, BuilderReferences, ValidationResult } from '../entities/index';
|
|
2
2
|
import type { ParamableSerialised } from '../references';
|
|
3
3
|
import type { BuilderResolve } from './resolve';
|
|
4
|
-
import
|
|
5
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
4
|
+
import { BuilderValidateErrors } from '../errors/index.js';
|
|
6
5
|
export type BuilderModelValidationResult = ValidationResult<BuilderModelValidated>;
|
|
7
|
-
export declare function validateModel(input: unknown, references?:
|
|
6
|
+
export declare function validateModel(input: unknown, references?: BuilderReferences, errors?: BuilderValidateErrors): BuilderModelValidationResult;
|
|
8
7
|
export declare function checkModelExpectations(mergedModel: BuilderModelSerialised, rootModel: BuilderModelSerialised, errors: BuilderValidateErrors): void;
|
|
9
8
|
export declare function validateModelStructure(input: ParamableSerialised<BuilderModelSerialised>, resolve: BuilderResolve, errors: BuilderValidateErrors): BuilderModelValidated;
|
package/dist/validate/model.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BuilderCollectionConfigSerialisedSchema, BuilderComponentConfigSerialisedSchema, BuilderModelSerialisedSchema, BuilderOptionConfigSerialisedSchema, BuilderWhenSerialisedSchema, whenBranches, model, modelsMerge, serialise, validateCollectionConfig, validateComponentConfig, validateSelect, validateToggle } from '../entities/index.js';
|
|
2
|
+
import { BuilderValidateErrors, check } from '../errors/index.js';
|
|
3
|
+
import { isParamable } from '../references.js';
|
|
3
4
|
import { validate } from './brand.js';
|
|
4
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
5
|
-
import { resolveCollections } from '../mappers/index.js';
|
|
6
5
|
import { checkExpectations } from './expectations.js';
|
|
7
6
|
import { checkPath } from './paths.js';
|
|
8
7
|
import { resolver } from './resolve.js';
|
|
9
8
|
const EMPTY_MODEL = validate(serialise.model(model()));
|
|
10
9
|
export function validateModel(input, references = [], errors = new BuilderValidateErrors()) {
|
|
11
10
|
if (!check.is(BuilderModelSerialisedSchema, input)) {
|
|
12
|
-
errors.
|
|
11
|
+
errors.invalidEntity('model');
|
|
13
12
|
return [EMPTY_MODEL, errors.errors];
|
|
14
13
|
}
|
|
15
14
|
const resolve = resolver(errors, references);
|
|
@@ -41,9 +40,32 @@ export function validateModelStructure(input, resolve, errors) {
|
|
|
41
40
|
const modelInput = resolved;
|
|
42
41
|
const skipPathValidation = modelInput.expectations.length > 0;
|
|
43
42
|
const childModels = errors.scope('models', () => modelInput.models.flatMap((part, partIndex) => errors.scope(partIndex, () => [validateModelStructure(part, resolve, errors)])));
|
|
44
|
-
const options = walkEntries(modelInput.options,
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const options = errors.scope('options', () => walkEntries(modelInput.options, (resolved) => {
|
|
44
|
+
whenBranches(resolved.payload, BuilderOptionConfigSerialisedSchema)
|
|
45
|
+
.filter((config) => !isParamable(config))
|
|
46
|
+
.forEach((config) => {
|
|
47
|
+
if (config.type === 'select') {
|
|
48
|
+
validateSelect(config, [], errors);
|
|
49
|
+
}
|
|
50
|
+
else if (config.type === 'toggle') {
|
|
51
|
+
validateToggle(config, [], errors);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}));
|
|
55
|
+
const components = errors.scope('components', () => walkEntries(modelInput.components, (resolved) => {
|
|
56
|
+
whenBranches(resolved.payload, BuilderComponentConfigSerialisedSchema)
|
|
57
|
+
.filter((config) => !isParamable(config))
|
|
58
|
+
.forEach((config) => {
|
|
59
|
+
validateComponentConfig(config, [], errors);
|
|
60
|
+
});
|
|
61
|
+
}));
|
|
62
|
+
const collections = errors.scope('collections', () => walkEntries(modelInput.collections, (resolved) => {
|
|
63
|
+
whenBranches(resolved.payload, BuilderCollectionConfigSerialisedSchema)
|
|
64
|
+
.filter((config) => !isParamable(config))
|
|
65
|
+
.forEach((config) => {
|
|
66
|
+
validateCollectionConfig(config, [], errors);
|
|
67
|
+
});
|
|
68
|
+
}));
|
|
47
69
|
return {
|
|
48
70
|
...modelInput,
|
|
49
71
|
models: childModels,
|
|
@@ -51,34 +73,17 @@ export function validateModelStructure(input, resolve, errors) {
|
|
|
51
73
|
components,
|
|
52
74
|
collections
|
|
53
75
|
};
|
|
54
|
-
function walkEntries(entries,
|
|
76
|
+
function walkEntries(entries, validateBranches) {
|
|
55
77
|
const seen = new Set();
|
|
56
78
|
const items = [];
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
return items;
|
|
68
|
-
}
|
|
69
|
-
function walkCollections() {
|
|
70
|
-
const seen = new Set();
|
|
71
|
-
const items = [];
|
|
72
|
-
errors.scope('collections', () => {
|
|
73
|
-
modelInput.collections.forEach((entry, entryIndex) => {
|
|
74
|
-
errors.scope(entryIndex, () => {
|
|
75
|
-
const resolved = resolveEntry(entry, seen);
|
|
76
|
-
if (resolved == null) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
checkCollectionBounds(resolved);
|
|
80
|
-
items.push(resolved);
|
|
81
|
-
});
|
|
79
|
+
entries.forEach((entry, entryIndex) => {
|
|
80
|
+
errors.scope(entryIndex, () => {
|
|
81
|
+
const resolved = resolveEntry(entry, seen);
|
|
82
|
+
if (resolved == null) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
validateBranches(resolved);
|
|
86
|
+
items.push(resolved);
|
|
82
87
|
});
|
|
83
88
|
});
|
|
84
89
|
return items;
|
|
@@ -135,14 +140,4 @@ export function validateModelStructure(input, resolve, errors) {
|
|
|
135
140
|
});
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
|
-
function checkCollectionBounds(collection) {
|
|
139
|
-
resolveCollections(collection).forEach(({ min, max }) => {
|
|
140
|
-
if (typeof min !== 'number' || typeof max !== 'number') {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (min < 0 || max <= 0 || max < min) {
|
|
144
|
-
errors.invalidCollectionBounds(collection.name, min, max);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
143
|
}
|
package/dist/validate/paths.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { BuilderModelSerialised } from '../entities/index';
|
|
2
|
-
import type {
|
|
3
|
-
import type { BuilderValidateErrors } from './errors';
|
|
1
|
+
import type { BuilderModelSerialised, BuilderPath } from '../entities/index';
|
|
2
|
+
import type { BuilderValidateErrors } from '../errors/index';
|
|
4
3
|
export declare function checkPath(model: BuilderModelSerialised, path: BuilderPath, errors: BuilderValidateErrors): void;
|
package/dist/validate/paths.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import { check } from '../check.js';
|
|
3
2
|
import { BuilderModelSerialisedSchema } from '../entities/index.js';
|
|
3
|
+
import { check } from '../errors/index.js';
|
|
4
4
|
import { resolveCollections } from '../mappers/index.js';
|
|
5
5
|
const NumberSchema = v.number();
|
|
6
6
|
const StringSchema = v.string();
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { BuilderModelSerialised, BuilderPricingSerialised, BuilderPricingValidated,
|
|
1
|
+
import type { BuilderModelSerialised, BuilderPricingSerialised, BuilderPricingValidated, BuilderReferences, ValidationResult } from '../entities/index';
|
|
2
2
|
import type { BuilderResolve } from './resolve';
|
|
3
|
-
import
|
|
4
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
3
|
+
import { BuilderValidateErrors } from '../errors/index.js';
|
|
5
4
|
export type BuilderPricingValidationResult = ValidationResult<BuilderPricingValidated>;
|
|
6
|
-
export declare function validatePricing(input: unknown, references?:
|
|
5
|
+
export declare function validatePricing(input: unknown, references?: BuilderReferences, errors?: BuilderValidateErrors): BuilderPricingValidationResult;
|
|
7
6
|
export declare function validatePricingStructure(input: BuilderPricingSerialised, resolve: BuilderResolve, errors: BuilderValidateErrors): BuilderPricingSerialised;
|
|
8
7
|
export declare function checkPricingExpectations(model: BuilderModelSerialised, pricing: BuilderPricingSerialised, errors: BuilderValidateErrors): void;
|
package/dist/validate/pricing.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
import { check } from '../check.js';
|
|
3
2
|
import { BuilderPricingExpressionSchema, BuilderPricingSerialisedSchema, BuilderRatesSchema, pricing, serialise } from '../entities/index.js';
|
|
3
|
+
import { BuilderValidateErrors, check } from '../errors/index.js';
|
|
4
4
|
import { validate } from './brand.js';
|
|
5
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
6
5
|
import { resolver } from './resolve.js';
|
|
7
6
|
const EMPTY_PRICING = validate(serialise.pricing(pricing()));
|
|
8
7
|
const NumberSchema = v.number();
|
|
9
8
|
export function validatePricing(input, references = [], errors = new BuilderValidateErrors()) {
|
|
10
9
|
if (!check.is(BuilderPricingSerialisedSchema, input)) {
|
|
11
|
-
errors.
|
|
10
|
+
errors.invalidEntity('pricing');
|
|
12
11
|
return [EMPTY_PRICING, errors.errors];
|
|
13
12
|
}
|
|
14
13
|
const resolve = resolver(errors, references);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BuilderBindings,
|
|
2
|
-
import type { BuilderValidateErrors } from '
|
|
1
|
+
import type { BuilderBindings, BuilderReferences } from '../entities/index';
|
|
2
|
+
import type { BuilderValidateErrors } from '../errors/index';
|
|
3
3
|
export type BuilderResolve = (value: unknown) => unknown;
|
|
4
|
-
export declare function resolver(errors: BuilderValidateErrors, references?:
|
|
4
|
+
export declare function resolver(errors: BuilderValidateErrors, references?: BuilderReferences, bindings?: BuilderBindings): BuilderResolve;
|
package/dist/validate/resolve.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { check } from '../check.js';
|
|
2
1
|
import { BuilderCollectionConfigSerialisedSchema, BuilderModelSerialisedSchema, BuilderWhenSerialisedSchema } from '../entities/index.js';
|
|
2
|
+
import { check } from '../errors/index.js';
|
|
3
3
|
import { BuilderParameterSerialisedSchema, BuilderRefSerialisedSchema } from '../references.js';
|
|
4
4
|
import { validateModelStructure } from './model.js';
|
|
5
5
|
export function resolver(errors, references = [], bindings = {}) {
|
package/dist/validate/ui.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { BuilderModelSerialised,
|
|
1
|
+
import type { BuilderModelSerialised, BuilderReferences, BuilderUISerialised, BuilderUIValidated, ValidationResult } from '../entities/index';
|
|
2
2
|
import type { BuilderResolve } from './resolve';
|
|
3
|
-
import
|
|
4
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
3
|
+
import { BuilderValidateErrors } from '../errors/index.js';
|
|
5
4
|
export type BuilderUIValidationResult = ValidationResult<BuilderUIValidated>;
|
|
6
|
-
export declare function validateUI(input: unknown, references?:
|
|
5
|
+
export declare function validateUI(input: unknown, references?: BuilderReferences, errors?: BuilderValidateErrors): BuilderUIValidationResult;
|
|
7
6
|
export declare function validateUIStructure(ui: BuilderUISerialised, resolve: BuilderResolve, errors: BuilderValidateErrors): BuilderUIValidated;
|
|
8
7
|
export declare function checkUIExpectations(mergedModel: BuilderModelSerialised, ui: BuilderUIValidated, errors: BuilderValidateErrors): void;
|
package/dist/validate/ui.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { validate } from './brand.js';
|
|
4
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
1
|
+
import { BuilderModelSerialisedSchema, BuilderUIInputMetadataSchema, BuilderUISerialisedSchema, modelsMerge, serialise, uis, validateUIDescribe, validateUIInput, validateUIPage, validateUIPages } from '../entities/index.js';
|
|
2
|
+
import { BuilderValidateErrors, check } from '../errors/index.js';
|
|
5
3
|
import { resolveCollections } from '../mappers/index.js';
|
|
4
|
+
import { validate } from './brand.js';
|
|
6
5
|
import { checkExpectations } from './expectations.js';
|
|
7
6
|
import { checkPath } from './paths.js';
|
|
8
7
|
import { resolver } from './resolve.js';
|
|
9
8
|
export function validateUI(input, references = [], errors = new BuilderValidateErrors()) {
|
|
10
9
|
if (!check.is(BuilderUISerialisedSchema, input)) {
|
|
11
|
-
errors.
|
|
10
|
+
errors.invalidEntity('ui');
|
|
12
11
|
return [validate(serialise.ui(uis())), errors.errors];
|
|
13
12
|
}
|
|
14
13
|
const resolve = resolver(errors, references);
|
|
@@ -40,6 +39,15 @@ export function validateUIStructure(ui, resolve, errors) {
|
|
|
40
39
|
}));
|
|
41
40
|
}
|
|
42
41
|
function walkUIItem(item) {
|
|
42
|
+
if (item.type === 'page') {
|
|
43
|
+
validateUIPage(item, [], errors);
|
|
44
|
+
}
|
|
45
|
+
else if (item.type === 'pages') {
|
|
46
|
+
validateUIPages(item, [], errors);
|
|
47
|
+
}
|
|
48
|
+
else if (item.type === 'describe') {
|
|
49
|
+
validateUIDescribe(item, [], errors);
|
|
50
|
+
}
|
|
43
51
|
const label = errors.scope('label', () => resolve(item.label) ?? item.label);
|
|
44
52
|
if (item.type === 'pages') {
|
|
45
53
|
const innerItems = errors.scope('items', () => {
|
|
@@ -65,6 +73,7 @@ export function validateUIStructure(ui, resolve, errors) {
|
|
|
65
73
|
}));
|
|
66
74
|
}
|
|
67
75
|
function walkInput(value) {
|
|
76
|
+
validateUIInput(value, [], errors);
|
|
68
77
|
const path = errors.scope('path', () => resolve(value.path) ?? value.path);
|
|
69
78
|
const displayName = value.displayName &&
|
|
70
79
|
errors.scope('displayName', () => resolve(value.displayName) ?? value.displayName);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
1
|
+
import type { BuilderModelValidated, BuilderVariantsValidated, ValidationResult } from '../entities/index';
|
|
2
|
+
import { BuilderValidateErrors } from '../errors/index.js';
|
|
4
3
|
export type BuilderVariantsValidationOptions = {
|
|
5
4
|
readonly partial?: boolean;
|
|
6
5
|
};
|
|
7
|
-
export type
|
|
8
|
-
export declare function validateVariants(model: BuilderModelValidated, input: unknown, options?: BuilderVariantsValidationOptions, errors?: BuilderValidateErrors):
|
|
6
|
+
export type BuilderVariantsValidationResult = ValidationResult<BuilderVariantsValidated>;
|
|
7
|
+
export declare function validateVariants(model: BuilderModelValidated, input: unknown, options?: BuilderVariantsValidationOptions, errors?: BuilderValidateErrors): BuilderVariantsValidationResult;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { BuilderComponentConfigSerialisedSchema, detailValueSchema } from '../entities/index.js';
|
|
2
|
+
import { BuilderValidateErrors, check } from '../errors/index.js';
|
|
3
|
+
import { BuilderVariantsSchema } from '../instance.js';
|
|
4
4
|
import { createVariants } from '../mappers/index.js';
|
|
5
5
|
import { validate } from './brand.js';
|
|
6
|
-
import { BuilderValidateErrors } from './errors.js';
|
|
7
6
|
export function validateVariants(model, input, options = {}, errors = new BuilderValidateErrors()) {
|
|
8
|
-
if (!check.is(
|
|
9
|
-
errors.
|
|
7
|
+
if (!check.is(BuilderVariantsSchema, input)) {
|
|
8
|
+
errors.invalidVariants();
|
|
10
9
|
return [validate({}), errors.errors];
|
|
11
10
|
}
|
|
12
11
|
const variants = input;
|
|
@@ -99,7 +98,7 @@ export function validateVariants(model, input, options = {}, errors = new Builde
|
|
|
99
98
|
}
|
|
100
99
|
function variantDetails(component, variantInstance) {
|
|
101
100
|
const { payload } = component;
|
|
102
|
-
if (check.is(
|
|
101
|
+
if (check.is(BuilderComponentConfigSerialisedSchema, payload)) {
|
|
103
102
|
return payload;
|
|
104
103
|
}
|
|
105
104
|
if (payload.type === 'match') {
|