@builder-builder/builder 0.0.9 → 0.0.11
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 +28 -0
- package/dist/bb.js +49 -0
- package/dist/check.d.ts +1 -1
- package/dist/check.js +4 -2
- package/dist/entities/builder/bind.d.ts +4 -0
- package/dist/entities/builder/builder.d.ts +17 -490
- package/dist/entities/builder/builder.js +19 -76
- package/dist/entities/builder/factory.d.ts +7 -0
- package/dist/entities/builder/factory.js +4 -0
- package/dist/entities/builder/index.d.ts +3 -6
- package/dist/entities/builder/index.js +1 -2
- package/dist/entities/collection/collection.d.ts +71 -20
- package/dist/entities/collection/collection.js +10 -27
- package/dist/entities/collection/config.d.ts +40 -1049
- package/dist/entities/collection/config.js +11 -11
- package/dist/entities/collection/expectation.d.ts +8 -4
- package/dist/entities/collection/index.d.ts +3 -3
- package/dist/entities/collection/index.js +1 -1
- package/dist/entities/collection/when.d.ts +6 -5
- package/dist/entities/component/component.d.ts +272 -300
- package/dist/entities/component/component.js +9 -8
- package/dist/entities/component/details.d.ts +35 -60
- package/dist/entities/component/details.js +9 -9
- package/dist/entities/component/expectation.d.ts +7 -4
- package/dist/entities/component/expectation.js +0 -3
- package/dist/entities/component/field.d.ts +50 -0
- package/dist/entities/component/field.js +41 -0
- package/dist/entities/component/index.d.ts +5 -3
- package/dist/entities/component/index.js +3 -2
- package/dist/entities/component/when.d.ts +5 -5
- package/dist/entities/component/when.js +2 -2
- package/dist/entities/entry.d.ts +4 -0
- package/dist/entities/expectation.d.ts +10 -22
- package/dist/entities/expectation.js +2 -7
- package/dist/entities/index.d.ts +21 -16
- package/dist/entities/index.js +10 -8
- package/dist/entities/kind.d.ts +9 -0
- package/dist/entities/kind.js +5 -0
- package/dist/entities/model/bind.d.ts +83 -0
- package/dist/entities/model/expectation.d.ts +16 -0
- package/dist/entities/model/index.d.ts +7 -0
- package/dist/entities/model/index.js +2 -0
- package/dist/entities/model/methods.d.ts +57 -0
- package/dist/entities/{builder → model}/methods.js +8 -8
- package/dist/entities/model/model.d.ts +39 -0
- package/dist/entities/model/model.js +73 -0
- package/dist/entities/model/models.d.ts +39 -0
- package/dist/entities/model/models.js +14 -0
- package/dist/entities/{builder → model}/state.d.ts +10 -10
- package/dist/entities/option/index.d.ts +2 -2
- package/dist/entities/option/index.js +2 -2
- package/dist/entities/option/option.d.ts +216 -214
- package/dist/entities/option/option.js +9 -8
- package/dist/entities/option/select.d.ts +2 -12
- package/dist/entities/option/select.js +6 -3
- package/dist/entities/option/toggle.d.ts +2 -9
- package/dist/entities/option/toggle.js +3 -3
- package/dist/entities/option/values.d.ts +4 -24
- package/dist/entities/option/values.js +10 -4
- package/dist/entities/option/when.d.ts +6 -5
- package/dist/entities/refs.d.ts +6 -0
- package/dist/entities/refs.js +1 -0
- package/dist/entities/serialise.d.ts +393 -3568
- package/dist/entities/serialise.js +160 -31
- package/dist/entities/ui/describe.d.ts +23 -57
- package/dist/entities/ui/describe.js +4 -5
- package/dist/entities/ui/index.d.ts +4 -9
- package/dist/entities/ui/index.js +2 -4
- package/dist/entities/ui/page.d.ts +23 -57
- package/dist/entities/ui/page.js +4 -5
- package/dist/entities/ui/pages.d.ts +18 -403
- package/dist/entities/ui/pages.js +7 -7
- package/dist/entities/ui/ui.d.ts +22 -1575
- package/dist/entities/ui/ui.js +15 -28
- package/dist/entities/ui/uis.d.ts +5 -9
- package/dist/entities/ui/uis.js +12 -19
- package/dist/entities/validated.d.ts +35 -0
- package/dist/entities/validated.js +1 -0
- package/dist/entities/when.d.ts +79 -70
- package/dist/entities/when.js +11 -7
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +2 -0
- package/dist/exception.d.ts +8 -3
- package/dist/exception.js +3 -0
- package/dist/index.d.ts +21 -24
- package/dist/index.js +5 -10
- package/dist/instance.d.ts +56 -0
- package/dist/instance.js +10 -0
- package/dist/mappers/index.d.ts +7 -5
- package/dist/mappers/index.js +5 -3
- package/dist/mappers/instance.d.ts +3 -0
- package/dist/mappers/instance.js +35 -0
- package/dist/mappers/order.d.ts +6 -0
- package/dist/mappers/order.js +22 -0
- package/dist/mappers/render/pages.d.ts +4 -4
- package/dist/mappers/render/render.d.ts +2 -3
- package/dist/mappers/render/render.js +83 -78
- package/dist/mappers/resolve.d.ts +5 -9
- package/dist/mappers/resolve.js +25 -33
- package/dist/mappers/variants/index.d.ts +1 -0
- package/dist/mappers/variants/index.js +1 -0
- package/dist/mappers/variants/option-graph.d.ts +19 -0
- package/dist/mappers/{models → variants}/option-graph.js +33 -22
- package/dist/mappers/variants/variants.d.ts +3 -0
- package/dist/mappers/variants/variants.js +57 -0
- package/dist/private.d.ts +4 -0
- package/dist/private.js +4 -0
- package/dist/references.d.ts +27 -36
- package/dist/references.js +19 -12
- package/dist/serialisable.d.ts +1 -9
- package/dist/serialisable.js +2 -3
- package/dist/validate/brand.d.ts +14 -0
- package/dist/validate/brand.js +17 -0
- package/dist/validate/builder.d.ts +4 -0
- package/dist/validate/builder.js +27 -0
- package/dist/validate/expectations.d.ts +10 -0
- package/dist/validate/expectations.js +12 -0
- package/dist/validate/index.d.ts +18 -0
- package/dist/validate/index.js +9 -0
- package/dist/validate/instance.d.ts +19 -0
- package/dist/validate/instance.js +46 -0
- package/dist/validate/model.d.ts +36 -0
- package/dist/validate/model.js +196 -0
- package/dist/validate/resolve.d.ts +16 -0
- package/dist/validate/resolve.js +91 -0
- package/dist/validate/result.d.ts +8 -0
- package/dist/validate/result.js +4 -0
- package/dist/validate/ui.d.ts +8 -0
- package/dist/validate/ui.js +77 -0
- package/dist/validate/variants.d.ts +59 -0
- package/dist/validate/variants.js +102 -0
- package/package.json +12 -9
- package/dist/entities/builder/builders.d.ts +0 -20
- package/dist/entities/builder/builders.js +0 -18
- package/dist/entities/builder/expectation.d.ts +0 -12
- package/dist/entities/builder/methods.d.ts +0 -58
- package/dist/entities/builder/parameter.d.ts +0 -62
- package/dist/entities/builder/parameter.js +0 -18
- package/dist/entities/builder/validate.d.ts +0 -3
- package/dist/entities/builder/validate.js +0 -108
- package/dist/entities/errors.d.ts +0 -21
- package/dist/entities/ui/label.d.ts +0 -18
- package/dist/entities/ui/label.js +0 -12
- package/dist/entities/ui/parameter.d.ts +0 -7
- package/dist/entities/ui/parameter.js +0 -29
- package/dist/entities/ui/validate.d.ts +0 -8
- package/dist/entities/ui/validate.js +0 -21
- package/dist/entities/validate.d.ts +0 -28
- package/dist/mappers/assert/builder.d.ts +0 -2
- package/dist/mappers/assert/builder.js +0 -46
- package/dist/mappers/assert/expectation.d.ts +0 -2
- package/dist/mappers/assert/expectation.js +0 -23
- package/dist/mappers/assert/index.d.ts +0 -6
- package/dist/mappers/assert/index.js +0 -4
- package/dist/mappers/assert/model.d.ts +0 -13
- package/dist/mappers/assert/model.js +0 -47
- package/dist/mappers/assert/models.d.ts +0 -33
- package/dist/mappers/assert/models.js +0 -74
- package/dist/mappers/assert/ui.d.ts +0 -2
- package/dist/mappers/assert/ui.js +0 -22
- package/dist/mappers/instance/index.d.ts +0 -1
- package/dist/mappers/instance/index.js +0 -1
- package/dist/mappers/instance/instance.d.ts +0 -4
- package/dist/mappers/instance/instance.js +0 -33
- package/dist/mappers/models/component-graph.d.ts +0 -9
- package/dist/mappers/models/component-graph.js +0 -51
- package/dist/mappers/models/graph.d.ts +0 -12
- package/dist/mappers/models/graph.js +0 -17
- package/dist/mappers/models/index.d.ts +0 -1
- package/dist/mappers/models/index.js +0 -1
- package/dist/mappers/models/models.d.ts +0 -3
- package/dist/mappers/models/models.js +0 -37
- package/dist/mappers/models/option-graph.d.ts +0 -9
- package/dist/mappers/order/index.d.ts +0 -2
- package/dist/mappers/order/index.js +0 -1
- package/dist/mappers/order/order.d.ts +0 -14
- package/dist/mappers/order/order.js +0 -31
- package/dist/model.d.ts +0 -14
- package/dist/walker/index.d.ts +0 -2
- package/dist/walker/index.js +0 -1
- package/dist/walker/walkable.d.ts +0 -4
- package/dist/walker/walkable.js +0 -4
- package/dist/walker/walker.d.ts +0 -18
- package/dist/walker/walker.js +0 -103
- package/dist/walker/walkers.d.ts +0 -8
- package/dist/walker/walkers.js +0 -51
- /package/dist/entities/builder/{expectation.js → bind.js} +0 -0
- /package/dist/entities/{builder/state.js → entry.js} +0 -0
- /package/dist/entities/{errors.js → model/bind.js} +0 -0
- /package/dist/entities/{validate.js → model/expectation.js} +0 -0
- /package/dist/{model.js → entities/model/state.js} +0 -0
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { check } from '../../check.js';
|
|
2
|
+
import { BuilderWhenMatchSchema, BuilderWhenUnlessSchema } from '../../entities/index.js';
|
|
2
3
|
import { resolveOption } from '../resolve.js';
|
|
3
|
-
|
|
4
|
+
export function crossProduct(left, right) {
|
|
5
|
+
return left.flatMap((leftModel) => right.map((rightModel) => ({ ...leftModel, ...rightModel })));
|
|
6
|
+
}
|
|
7
|
+
export function dependencyKeys(payload, paths = []) {
|
|
8
|
+
const keys = new Set(paths.map(([first]) => String(first)));
|
|
9
|
+
if (check.is(BuilderWhenMatchSchema, payload)) {
|
|
10
|
+
const [firstMatchSegment] = payload.matchPath;
|
|
11
|
+
keys.add(String(firstMatchSegment));
|
|
12
|
+
}
|
|
13
|
+
else if (check.is(BuilderWhenUnlessSchema, payload)) {
|
|
14
|
+
const [firstUnlessSegment] = payload.unlessPath;
|
|
15
|
+
keys.add(String(firstUnlessSegment));
|
|
16
|
+
}
|
|
17
|
+
return Array.from(keys);
|
|
18
|
+
}
|
|
4
19
|
export class BuilderOptionGraph {
|
|
5
20
|
paths;
|
|
6
21
|
constructor(paths = []) {
|
|
@@ -12,43 +27,39 @@ export class BuilderOptionGraph {
|
|
|
12
27
|
return graphPath;
|
|
13
28
|
}
|
|
14
29
|
add(option) {
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const optionDependencyKeys = dependencyKeys(payload, gatePaths);
|
|
30
|
+
const { paths, payload } = option;
|
|
31
|
+
const optionDependencyKeys = dependencyKeys(payload, paths);
|
|
18
32
|
if (optionDependencyKeys.length === 0) {
|
|
19
|
-
const
|
|
20
|
-
check.truthy(
|
|
21
|
-
const values = this.#optionValues(
|
|
33
|
+
const payload = resolveOption(option, {});
|
|
34
|
+
check.truthy(payload, `Option '${option.name}' without dependencies must resolve! ❌`);
|
|
35
|
+
const values = this.#optionValues(option.name, payload);
|
|
22
36
|
return new BuilderOptionGraph([
|
|
23
37
|
...this.paths,
|
|
24
38
|
{
|
|
25
39
|
name: option.name,
|
|
26
40
|
keys: new Set(),
|
|
27
|
-
|
|
41
|
+
instances: values.map((value) => ({ [option.name]: value }))
|
|
28
42
|
}
|
|
29
43
|
]);
|
|
30
44
|
}
|
|
31
45
|
const merged = this.#mergePaths(new Set(optionDependencyKeys), this.paths);
|
|
32
|
-
const
|
|
33
|
-
merged.
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
this.#optionValues(
|
|
37
|
-
|
|
46
|
+
const finalInstances = [];
|
|
47
|
+
merged.instances.forEach((instance) => {
|
|
48
|
+
const payload = resolveOption(option, instance);
|
|
49
|
+
if (payload) {
|
|
50
|
+
this.#optionValues(option.name, payload).forEach((value) => {
|
|
51
|
+
finalInstances.push({ ...instance, [option.name]: value });
|
|
38
52
|
});
|
|
39
53
|
}
|
|
40
54
|
else {
|
|
41
|
-
|
|
55
|
+
finalInstances.push({ ...instance });
|
|
42
56
|
}
|
|
43
57
|
});
|
|
44
58
|
return new BuilderOptionGraph([
|
|
45
59
|
...this.paths,
|
|
46
|
-
{ name: option.name, keys: merged.keys,
|
|
60
|
+
{ name: option.name, keys: merged.keys, instances: finalInstances }
|
|
47
61
|
]);
|
|
48
62
|
}
|
|
49
|
-
#has(name) {
|
|
50
|
-
return this.paths.some((graphPath) => graphPath.name === name);
|
|
51
|
-
}
|
|
52
63
|
#mergePaths(dependencyKeys, graphPaths) {
|
|
53
64
|
const dependencyPaths = Array.from(dependencyKeys).map((dependencyKey) => {
|
|
54
65
|
const dependencyPath = graphPaths.find((graphPath) => graphPath.name === dependencyKey);
|
|
@@ -58,9 +69,9 @@ export class BuilderOptionGraph {
|
|
|
58
69
|
const [first, ...rest] = dependencyPaths;
|
|
59
70
|
return rest.reduce((merged, next) => {
|
|
60
71
|
const keys = new Set([...merged.keys, ...next.keys, next.name]);
|
|
61
|
-
const
|
|
62
|
-
return { keys,
|
|
63
|
-
}, { keys: new Set([...first.keys, first.name]),
|
|
72
|
+
const instances = crossProduct(next.instances, merged.instances);
|
|
73
|
+
return { keys, instances };
|
|
74
|
+
}, { keys: new Set([...first.keys, first.name]), instances: first.instances });
|
|
64
75
|
}
|
|
65
76
|
#optionValues(name, values) {
|
|
66
77
|
if (values.type === 'select') {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { check } from '../../check.js';
|
|
2
|
+
import { BuilderSerialisedSchema } from '../../entities/index.js';
|
|
3
|
+
import { resolveCollection } from '../resolve.js';
|
|
4
|
+
import { BuilderOptionGraph, crossProduct, dependencyKeys } from './option-graph.js';
|
|
5
|
+
export function createVariants(entity) {
|
|
6
|
+
const model = check.is(BuilderSerialisedSchema, entity) ? entity.model : entity;
|
|
7
|
+
return buildVariants(model);
|
|
8
|
+
}
|
|
9
|
+
function buildVariants(model) {
|
|
10
|
+
const options = optionGraph(model.options);
|
|
11
|
+
const nestedVariants = model.collections.flatMap((entry) => variantsFor(entry, options).flatMap((instance) => {
|
|
12
|
+
const resolved = resolveCollection(entry, instance);
|
|
13
|
+
return resolved == null ? [] : [buildVariants(resolved.model)];
|
|
14
|
+
}));
|
|
15
|
+
return {
|
|
16
|
+
...nestedVariants.reduce((merged, component) => ({ ...merged, ...component }), {}),
|
|
17
|
+
...Object.fromEntries(model.components.map((component) => [
|
|
18
|
+
component.name,
|
|
19
|
+
variantsFor(component, options).map((instance) => ({ instance }))
|
|
20
|
+
]))
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function optionGraph(options) {
|
|
24
|
+
return options.reduce((graph, option) => graph.add(option), new BuilderOptionGraph());
|
|
25
|
+
}
|
|
26
|
+
function variantsFor(entity, options) {
|
|
27
|
+
const keys = new Set(dependencyKeys(entity.payload, entity.paths));
|
|
28
|
+
const graphPaths = Array.from(keys)
|
|
29
|
+
.map((key) => options.get(key))
|
|
30
|
+
.sort((pathA, pathB) => pathB.keys.size - pathA.keys.size);
|
|
31
|
+
const handledKeys = new Set();
|
|
32
|
+
let variants = [{}];
|
|
33
|
+
graphPaths.forEach((graphPath) => {
|
|
34
|
+
const isHandled = handledKeys.has(graphPath.name) &&
|
|
35
|
+
Array.from(graphPath.keys).every((key) => handledKeys.has(key));
|
|
36
|
+
if (!isHandled) {
|
|
37
|
+
const pickedInstances = pickKeys(graphPath, keys);
|
|
38
|
+
variants = crossProduct(variants, pickedInstances);
|
|
39
|
+
handledKeys.add(graphPath.name);
|
|
40
|
+
graphPath.keys.forEach((key) => handledKeys.add(key));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return variants;
|
|
44
|
+
}
|
|
45
|
+
function pickKeys(graphPath, keys) {
|
|
46
|
+
const seen = new Set();
|
|
47
|
+
const picked = [];
|
|
48
|
+
graphPath.instances.forEach((instance) => {
|
|
49
|
+
const filtered = Object.fromEntries(Object.entries(instance).filter(([key, value]) => keys.has(key) && value != null));
|
|
50
|
+
const identity = JSON.stringify(filtered);
|
|
51
|
+
if (identity !== '{}' && !seen.has(identity)) {
|
|
52
|
+
seen.add(identity);
|
|
53
|
+
picked.push(filtered);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return picked;
|
|
57
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { BuilderCollectionConfigSchema, BuilderCollectionConfigSerialisedSchema, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionWhenSerialisedSchema, BuilderComponentDetailsSchema, BuilderComponentDetailsSerialisedSchema, BuilderComponentFieldSchema, BuilderComponentFieldSerialisedSchema, BuilderComponentFieldsSchema, BuilderComponentFieldsSerialisedSchema, BuilderComponentFieldValueTypeSchema, BuilderComponentSchema, BuilderComponentSelectMapSerialisedSchema, BuilderComponentSerialisedSchema, BuilderComponentsSerialisedSchema, BuilderComponentWhenSerialisedSchema, BuilderDescriptionItemSchema, BuilderDescriptionSchema, BuilderEntityKindSchema, BuilderEntitySerialisedSchema, BuilderExpectationKindSchema, BuilderExpectationSchema, BuilderExpectationSerialisedSchema, BuilderExpectationsSchema, BuilderExpectationsSerialisedSchema, BuilderModelSchema, BuilderModelSerialisedSchema, BuilderOptionSchema, BuilderOptionSelectMapSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionsSerialisedSchema, BuilderOptionValuesSchema, BuilderOptionValuesSerialisedSchema, BuilderOptionWhenSerialisedSchema, BuilderSchema, BuilderSelectTypeSchema, BuilderSelectTypeSerialisedSchema, BuilderSerialisedSchema, BuilderToggleTypeSchema, BuilderToggleTypeSerialisedSchema, BuilderUIDescribeSchema, BuilderUIDescribeSerialisedSchema, BuilderUIItemSerialisedSchema, BuilderUIItemsSerialisedSchema, BuilderUIPageSchema, BuilderUIPageSerialisedSchema, BuilderUIPagesSchema, BuilderUIPagesSerialisedSchema, BuilderUISchema, BuilderUISerialisedSchema, BuilderWhenConfigSchema, BuilderWhenEnableSchema, BuilderWhenMatchSchema, BuilderWhenUnlessSchema } from './entities/index.js';
|
|
2
|
+
export { BuilderEnvironmentSchema } from './environment.js';
|
|
3
|
+
export { BuilderComponentVariantsSchema, BuilderVariantsSchema } from './instance.js';
|
|
4
|
+
export { BuilderPathSchema, BuilderPathsSchema } from './paths.js';
|
package/dist/private.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { BuilderCollectionConfigSchema, BuilderCollectionConfigSerialisedSchema, BuilderCollectionSchema, BuilderCollectionSelectMapSerialisedSchema, BuilderCollectionSerialisedSchema, BuilderCollectionsSerialisedSchema, BuilderCollectionWhenSerialisedSchema, BuilderComponentDetailsSchema, BuilderComponentDetailsSerialisedSchema, BuilderComponentFieldSchema, BuilderComponentFieldSerialisedSchema, BuilderComponentFieldsSchema, BuilderComponentFieldsSerialisedSchema, BuilderComponentFieldValueTypeSchema, BuilderComponentSchema, BuilderComponentSelectMapSerialisedSchema, BuilderComponentSerialisedSchema, BuilderComponentsSerialisedSchema, BuilderComponentWhenSerialisedSchema, BuilderDescriptionItemSchema, BuilderDescriptionSchema, BuilderEntityKindSchema, BuilderEntitySerialisedSchema, BuilderExpectationKindSchema, BuilderExpectationSchema, BuilderExpectationSerialisedSchema, BuilderExpectationsSchema, BuilderExpectationsSerialisedSchema, BuilderModelSchema, BuilderModelSerialisedSchema, BuilderOptionSchema, BuilderOptionSelectMapSerialisedSchema, BuilderOptionSerialisedSchema, BuilderOptionsSerialisedSchema, BuilderOptionValuesSchema, BuilderOptionValuesSerialisedSchema, BuilderOptionWhenSerialisedSchema, BuilderSchema, BuilderSelectTypeSchema, BuilderSelectTypeSerialisedSchema, BuilderSerialisedSchema, BuilderToggleTypeSchema, BuilderToggleTypeSerialisedSchema, BuilderUIDescribeSchema, BuilderUIDescribeSerialisedSchema, BuilderUIItemSerialisedSchema, BuilderUIItemsSerialisedSchema, BuilderUIPageSchema, BuilderUIPageSerialisedSchema, BuilderUIPagesSchema, BuilderUIPagesSerialisedSchema, BuilderUISchema, BuilderUISerialisedSchema, BuilderWhenConfigSchema, BuilderWhenEnableSchema, BuilderWhenMatchSchema, BuilderWhenUnlessSchema } from './entities/index.js';
|
|
2
|
+
export { BuilderEnvironmentSchema } from './environment.js';
|
|
3
|
+
export { BuilderComponentVariantsSchema, BuilderVariantsSchema } from './instance.js';
|
|
4
|
+
export { BuilderPathSchema, BuilderPathsSchema } from './paths.js';
|
package/dist/references.d.ts
CHANGED
|
@@ -1,60 +1,51 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
export type
|
|
3
|
-
export type
|
|
4
|
-
export
|
|
5
|
-
readonly refable?: v.GenericSchema;
|
|
6
|
-
};
|
|
7
|
-
export declare class BuilderRef {
|
|
2
|
+
export type Paramable<Value> = Value | BuilderParameter | BuilderRef;
|
|
3
|
+
export type ParamableSerialised<Value> = Value | BuilderParameterSerialised | BuilderRefSerialised;
|
|
4
|
+
export declare class BuilderParameter<const Name extends string = string> {
|
|
8
5
|
readonly id: string;
|
|
9
|
-
readonly name:
|
|
10
|
-
constructor(name:
|
|
6
|
+
readonly name: Name;
|
|
7
|
+
constructor(name: Name, id?: string);
|
|
11
8
|
}
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
|
|
15
|
-
export declare const BuilderRefSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
16
|
-
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
9
|
+
export declare const BuilderParameterSchema: v.InstanceSchema<typeof BuilderParameter, undefined>;
|
|
10
|
+
export declare const BuilderParameterSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
11
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
17
12
|
readonly id: v.StringSchema<undefined>;
|
|
18
13
|
readonly name: v.StringSchema<undefined>;
|
|
19
14
|
}, undefined>, v.ReadonlyAction<{
|
|
20
|
-
type: "
|
|
15
|
+
type: "parameter";
|
|
21
16
|
id: string;
|
|
22
17
|
name: string;
|
|
23
18
|
}>]>;
|
|
24
|
-
export type
|
|
25
|
-
export declare
|
|
19
|
+
export type BuilderParameterSerialised = v.InferOutput<typeof BuilderParameterSerialisedSchema>;
|
|
20
|
+
export declare class BuilderRef {
|
|
21
|
+
readonly type: "ref";
|
|
22
|
+
readonly id: string;
|
|
23
|
+
constructor(id: string);
|
|
24
|
+
}
|
|
25
|
+
export declare const BuilderRefSchema: v.InstanceSchema<typeof BuilderRef, undefined>;
|
|
26
|
+
export declare const BuilderRefSerialisedSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
26
27
|
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
27
28
|
readonly id: v.StringSchema<undefined>;
|
|
28
|
-
readonly name: v.StringSchema<undefined>;
|
|
29
29
|
}, undefined>, v.ReadonlyAction<{
|
|
30
30
|
type: "ref";
|
|
31
31
|
id: string;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export type BuilderRefsSerialised = v.InferOutput<typeof BuilderRefsSerialisedSchema>;
|
|
39
|
-
export declare function isRef(value: unknown): value is BuilderRef;
|
|
40
|
-
export declare function isSerialisedRef(value: unknown): value is BuilderRefSerialised;
|
|
41
|
-
export declare function parameter(name: string): BuilderRef;
|
|
42
|
-
export declare function refable<Schema extends v.GenericSchema>(refable: Schema): v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
43
|
-
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
32
|
+
}>]>;
|
|
33
|
+
export type BuilderRefSerialised = v.InferOutput<typeof BuilderRefSerialisedSchema>;
|
|
34
|
+
export declare function parameter<const Name extends string>(name: Name): BuilderParameter<Name>;
|
|
35
|
+
export declare function ref(id: string): BuilderRef;
|
|
36
|
+
export declare function paramable<Schema extends v.GenericSchema>(paramable: Schema): v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
37
|
+
readonly type: v.LiteralSchema<"parameter", undefined>;
|
|
44
38
|
readonly id: v.StringSchema<undefined>;
|
|
45
39
|
readonly name: v.StringSchema<undefined>;
|
|
46
40
|
}, undefined>, v.ReadonlyAction<{
|
|
47
|
-
type: "
|
|
41
|
+
type: "parameter";
|
|
48
42
|
id: string;
|
|
49
43
|
name: string;
|
|
50
|
-
}>]>, v.
|
|
44
|
+
}>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
51
45
|
readonly type: v.LiteralSchema<"ref", undefined>;
|
|
52
46
|
readonly id: v.StringSchema<undefined>;
|
|
53
|
-
readonly name: v.StringSchema<undefined>;
|
|
54
47
|
}, undefined>, v.ReadonlyAction<{
|
|
55
48
|
type: "ref";
|
|
56
49
|
id: string;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
readonly refable: Schema;
|
|
60
|
-
}>]>;
|
|
50
|
+
}>]>, Schema], undefined>;
|
|
51
|
+
export declare function isParamable(value: unknown): boolean;
|
package/dist/references.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { check } from './check.js';
|
|
3
|
-
export class
|
|
3
|
+
export class BuilderParameter {
|
|
4
4
|
id;
|
|
5
5
|
name;
|
|
6
6
|
constructor(name, id = crypto.randomUUID()) {
|
|
@@ -8,19 +8,26 @@ export class BuilderRef {
|
|
|
8
8
|
this.id = id;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
+
export const BuilderParameterSchema = v.instance(BuilderParameter);
|
|
12
|
+
export const BuilderParameterSerialisedSchema = v.pipe(v.object({ type: v.literal('parameter'), id: v.string(), name: v.string() }), v.readonly());
|
|
13
|
+
export class BuilderRef {
|
|
14
|
+
type = 'ref';
|
|
15
|
+
id;
|
|
16
|
+
constructor(id) {
|
|
17
|
+
this.id = id;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
export const BuilderRefSchema = v.instance(BuilderRef);
|
|
12
|
-
export const
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
export function isRef(value) {
|
|
16
|
-
return check.is(BuilderRefSchema, value);
|
|
21
|
+
export const BuilderRefSerialisedSchema = v.pipe(v.object({ type: v.literal('ref'), id: v.string() }), v.readonly());
|
|
22
|
+
export function parameter(name) {
|
|
23
|
+
return new BuilderParameter(name);
|
|
17
24
|
}
|
|
18
|
-
export function
|
|
19
|
-
return
|
|
25
|
+
export function ref(id) {
|
|
26
|
+
return new BuilderRef(id);
|
|
20
27
|
}
|
|
21
|
-
export function
|
|
22
|
-
return
|
|
28
|
+
export function paramable(paramable) {
|
|
29
|
+
return v.union([BuilderParameterSerialisedSchema, BuilderRefSerialisedSchema, paramable]);
|
|
23
30
|
}
|
|
24
|
-
export function
|
|
25
|
-
return
|
|
31
|
+
export function isParamable(value) {
|
|
32
|
+
return (check.is(BuilderParameterSerialisedSchema, value) || check.is(BuilderRefSerialisedSchema, value));
|
|
26
33
|
}
|
package/dist/serialisable.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
export
|
|
3
|
-
export type SerialisableMetadata = {
|
|
4
|
-
readonly serialisable?: SerialisableClass;
|
|
5
|
-
readonly instance?: v.GenericSchema;
|
|
6
|
-
};
|
|
7
|
-
export declare function serialisable<Serialisable extends SerialisableClass, Schema extends v.GenericSchema>(serialisable: Serialisable, schema: Schema): v.SchemaWithPipe<readonly [Schema, v.MetadataAction<v.InferOutput<Schema>, {
|
|
8
|
-
readonly serialisable: Serialisable;
|
|
9
|
-
readonly instance: v.InstanceSchema<Serialisable, undefined>;
|
|
10
|
-
}>, v.ReadonlyAction<v.InferOutput<Schema>>]>;
|
|
2
|
+
export declare function serialisable<Schema extends v.GenericSchema>(schema: Schema): v.SchemaWithPipe<readonly [Schema, v.ReadonlyAction<v.InferOutput<Schema>>]>;
|
package/dist/serialisable.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
-
export function serialisable(
|
|
3
|
-
|
|
4
|
-
return v.pipe(schema, v.metadata({ serialisable, instance }), v.readonly());
|
|
2
|
+
export function serialisable(schema) {
|
|
3
|
+
return v.pipe(schema, v.readonly());
|
|
5
4
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BuilderErrorLocation } from '../exception';
|
|
2
|
+
declare const VALIDATED: unique symbol;
|
|
3
|
+
export type BuilderValidatedBrand = {
|
|
4
|
+
readonly [VALIDATED]: true;
|
|
5
|
+
};
|
|
6
|
+
export declare function builderErrorUnvalidated(value: unknown, location?: BuilderErrorLocation): {
|
|
7
|
+
value: unknown;
|
|
8
|
+
kind: "unvalidated";
|
|
9
|
+
location: BuilderErrorLocation;
|
|
10
|
+
};
|
|
11
|
+
export type BuilderErrorUnvalidated = ReturnType<typeof builderErrorUnvalidated>;
|
|
12
|
+
export declare function validate<Input extends object>(value: Input): Input & BuilderValidatedBrand;
|
|
13
|
+
export declare function assertValidated<Input>(value: Input): asserts value is Input & BuilderValidatedBrand;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { builderError, BuilderException } from '../exception.js';
|
|
2
|
+
const VALIDATED = Symbol('builder.validated');
|
|
3
|
+
export function builderErrorUnvalidated(value, location = []) {
|
|
4
|
+
return { ...builderError('unvalidated', location), value };
|
|
5
|
+
}
|
|
6
|
+
export function validate(value) {
|
|
7
|
+
Object.defineProperty(value, VALIDATED, {
|
|
8
|
+
value: true,
|
|
9
|
+
enumerable: false
|
|
10
|
+
});
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
export function assertValidated(value) {
|
|
14
|
+
if (typeof value !== 'object' || value === null || !(VALIDATED in value)) {
|
|
15
|
+
throw new BuilderException([builderErrorUnvalidated(value)]);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BuilderRefEntities, BuilderValidated } from '../entities/index';
|
|
2
|
+
import type { ValidationResult } from './result';
|
|
3
|
+
export type BuilderValidationResult = ValidationResult<BuilderValidated>;
|
|
4
|
+
export declare function validateBuilder(input: unknown, references?: BuilderRefEntities): BuilderValidationResult;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { check } from '../check.js';
|
|
2
|
+
import { builder, BuilderSerialisedSchema, modelsMerge, serialise } from '../entities/index.js';
|
|
3
|
+
import { validate } from './brand.js';
|
|
4
|
+
import { checkModelExpectations, validateModelStructure } from './model.js';
|
|
5
|
+
import { resolver } from './resolve.js';
|
|
6
|
+
import { builderErrorInvalidInput } from './result.js';
|
|
7
|
+
import { checkUIExpectations, validateUIStructure } from './ui.js';
|
|
8
|
+
export function validateBuilder(input, references = []) {
|
|
9
|
+
if (!check.is(BuilderSerialisedSchema, input)) {
|
|
10
|
+
const errors = [builderErrorInvalidInput('builder')];
|
|
11
|
+
return [validate(serialise.builder(builder())), errors];
|
|
12
|
+
}
|
|
13
|
+
const resolve = resolver(references, input.bindings);
|
|
14
|
+
const [validatedModel, modelErrors] = validateModelStructure(input.model, resolve, ['model']);
|
|
15
|
+
const [validatedUI, uiErrors] = validateUIStructure(input.ui, resolve, ['ui']);
|
|
16
|
+
const mergedModel = modelsMerge(validatedModel);
|
|
17
|
+
const expectationErrors = [
|
|
18
|
+
...checkModelExpectations(mergedModel, validatedModel, ['model']),
|
|
19
|
+
...checkUIExpectations(mergedModel, validatedUI, ['ui'])
|
|
20
|
+
];
|
|
21
|
+
const data = validate({
|
|
22
|
+
...serialise.builder(builder()),
|
|
23
|
+
model: mergedModel,
|
|
24
|
+
ui: validatedUI
|
|
25
|
+
});
|
|
26
|
+
return [data, [...expectationErrors, ...modelErrors, ...uiErrors]];
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BuilderExpectationKind, BuilderExpectationsSerialised, BuilderModelSerialised } from '../entities/index';
|
|
2
|
+
import type { BuilderErrorLocation, BuilderErrors } from '../exception';
|
|
3
|
+
export declare function builderErrorUnmetExpectation(expectationKind: BuilderExpectationKind, name: string, location?: BuilderErrorLocation): {
|
|
4
|
+
expectationKind: "option" | "component" | "collection";
|
|
5
|
+
name: string;
|
|
6
|
+
kind: "unmet-expectation";
|
|
7
|
+
location: BuilderErrorLocation;
|
|
8
|
+
};
|
|
9
|
+
export type BuilderErrorUnmetExpectation = ReturnType<typeof builderErrorUnmetExpectation>;
|
|
10
|
+
export declare function checkExpectations(model: BuilderModelSerialised, expectations: BuilderExpectationsSerialised, location: BuilderErrorLocation): BuilderErrors;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { builderError } from '../exception.js';
|
|
2
|
+
export function builderErrorUnmetExpectation(expectationKind, name, location = []) {
|
|
3
|
+
return { ...builderError('unmet-expectation', location), expectationKind, name };
|
|
4
|
+
}
|
|
5
|
+
export function checkExpectations(model, expectations, location) {
|
|
6
|
+
return expectations.flatMap(({ kind, name }, index) => {
|
|
7
|
+
if (model[`${kind}s`].some((entry) => entry.name === name)) {
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
return [builderErrorUnmetExpectation(kind, name, [...location, index])];
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type { BuilderErrorUnvalidated } from './brand';
|
|
2
|
+
export type { BuilderValidationResult } from './builder';
|
|
3
|
+
export type { BuilderErrorUnmetExpectation } from './expectations';
|
|
4
|
+
export type { BuilderErrorInvalidCollection, BuilderErrorInvalidOption, BuilderInstanceValidationResult } from './instance';
|
|
5
|
+
export type { BuilderErrorDuplicateName, BuilderErrorInvalidCollectionBounds, BuilderErrorInvalidPath, BuilderErrorInvalidPathReason, BuilderErrorInvalidSelectMapKey, BuilderModelValidationResult } from './model';
|
|
6
|
+
export type { BuilderErrorMissingReference, BuilderErrorUnboundParameter } from './resolve';
|
|
7
|
+
export type { BuilderErrorInvalidInput } from './result';
|
|
8
|
+
export type { BuilderUIValidationResult } from './ui';
|
|
9
|
+
export type { BuilderComponentVariantsValidationResult, BuilderErrorInvalidDetail, BuilderErrorInvalidVariant, BuilderErrorMissingComponent, BuilderErrorMissingDetail, BuilderErrorMissingVariant, BuilderErrorUnexpectedComponent, BuilderErrorUnexpectedDetail, BuilderVariantsValidationOptions } from './variants';
|
|
10
|
+
export { assertValidated, builderErrorUnvalidated } from './brand.js';
|
|
11
|
+
export { validateBuilder } from './builder.js';
|
|
12
|
+
export { builderErrorUnmetExpectation } from './expectations.js';
|
|
13
|
+
export { builderErrorInvalidCollection, builderErrorInvalidOption, validateInstance } from './instance.js';
|
|
14
|
+
export { builderErrorDuplicateName, builderErrorInvalidCollectionBounds, builderErrorInvalidPath, builderErrorInvalidSelectMapKey, validateModel } from './model.js';
|
|
15
|
+
export { builderErrorMissingReference, builderErrorUnboundParameter } from './resolve.js';
|
|
16
|
+
export { builderErrorInvalidInput } from './result.js';
|
|
17
|
+
export { validateUI } from './ui.js';
|
|
18
|
+
export { builderErrorInvalidDetail, builderErrorInvalidVariant, builderErrorMissingComponent, builderErrorMissingDetail, builderErrorMissingVariant, builderErrorUnexpectedComponent, builderErrorUnexpectedDetail, validateVariants } from './variants.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { assertValidated, builderErrorUnvalidated } from './brand.js';
|
|
2
|
+
export { validateBuilder } from './builder.js';
|
|
3
|
+
export { builderErrorUnmetExpectation } from './expectations.js';
|
|
4
|
+
export { builderErrorInvalidCollection, builderErrorInvalidOption, validateInstance } from './instance.js';
|
|
5
|
+
export { builderErrorDuplicateName, builderErrorInvalidCollectionBounds, builderErrorInvalidPath, builderErrorInvalidSelectMapKey, validateModel } from './model.js';
|
|
6
|
+
export { builderErrorMissingReference, builderErrorUnboundParameter } from './resolve.js';
|
|
7
|
+
export { builderErrorInvalidInput } from './result.js';
|
|
8
|
+
export { validateUI } from './ui.js';
|
|
9
|
+
export { builderErrorInvalidDetail, builderErrorInvalidVariant, builderErrorMissingComponent, builderErrorMissingDetail, builderErrorMissingVariant, builderErrorUnexpectedComponent, builderErrorUnexpectedDetail, validateVariants } from './variants.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BuilderInstanceValidated, BuilderModelValidated } from '../entities/index';
|
|
2
|
+
import type { BuilderErrorLocation } from '../exception';
|
|
3
|
+
import type { BuilderInstance } from '../instance';
|
|
4
|
+
import type { ValidationResult } from './result';
|
|
5
|
+
export declare function builderErrorInvalidOption(name: string, value: unknown, location?: BuilderErrorLocation): {
|
|
6
|
+
name: string;
|
|
7
|
+
value: unknown;
|
|
8
|
+
kind: "invalid-option";
|
|
9
|
+
location: BuilderErrorLocation;
|
|
10
|
+
};
|
|
11
|
+
export type BuilderErrorInvalidOption = ReturnType<typeof builderErrorInvalidOption>;
|
|
12
|
+
export declare function builderErrorInvalidCollection(name: string, location?: BuilderErrorLocation): {
|
|
13
|
+
name: string;
|
|
14
|
+
kind: "invalid-collection";
|
|
15
|
+
location: BuilderErrorLocation;
|
|
16
|
+
};
|
|
17
|
+
export type BuilderErrorInvalidCollection = ReturnType<typeof builderErrorInvalidCollection>;
|
|
18
|
+
export type BuilderInstanceValidationResult = ValidationResult<BuilderInstanceValidated>;
|
|
19
|
+
export declare function validateInstance(model: BuilderModelValidated, instance: BuilderInstance): BuilderInstanceValidationResult;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { check } from '../check.js';
|
|
2
|
+
import { optionValueSchema } from '../entities/index.js';
|
|
3
|
+
import { builderError } from '../exception.js';
|
|
4
|
+
import { resolveCollection, resolveOption } from '../mappers/index.js';
|
|
5
|
+
import { validate } from './brand.js';
|
|
6
|
+
export function builderErrorInvalidOption(name, value, location = []) {
|
|
7
|
+
return { ...builderError('invalid-option', location), name, value };
|
|
8
|
+
}
|
|
9
|
+
export function builderErrorInvalidCollection(name, location = []) {
|
|
10
|
+
return { ...builderError('invalid-collection', location), name };
|
|
11
|
+
}
|
|
12
|
+
export function validateInstance(model, instance) {
|
|
13
|
+
const errors = checkInstance(model, instance, ['instance']);
|
|
14
|
+
return [validate(instance), errors];
|
|
15
|
+
}
|
|
16
|
+
function checkInstance(model, instance, location) {
|
|
17
|
+
const { options, collections } = model;
|
|
18
|
+
const optionErrors = options.flatMap((option) => {
|
|
19
|
+
const { name } = option;
|
|
20
|
+
const payload = resolveOption(option, instance);
|
|
21
|
+
if (!payload) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
const value = instance[name];
|
|
25
|
+
if (!check.is(optionValueSchema(payload), value)) {
|
|
26
|
+
return [builderErrorInvalidOption(name, value, [...location, name])];
|
|
27
|
+
}
|
|
28
|
+
return [];
|
|
29
|
+
});
|
|
30
|
+
const collectionErrors = collections.flatMap((collection) => {
|
|
31
|
+
const { name } = collection;
|
|
32
|
+
const payload = resolveCollection(collection, instance);
|
|
33
|
+
if (!payload) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const existing = instance[name];
|
|
37
|
+
if (!Array.isArray(existing)) {
|
|
38
|
+
return [builderErrorInvalidCollection(name, [...location, name])];
|
|
39
|
+
}
|
|
40
|
+
return existing.flatMap((itemInstance, index) => checkInstance(payload.model, itemInstance, [...location, name, index]).map((error) => ({
|
|
41
|
+
...error,
|
|
42
|
+
name: `${name}[${index}].${error.name}`
|
|
43
|
+
})));
|
|
44
|
+
});
|
|
45
|
+
return [...optionErrors, ...collectionErrors];
|
|
46
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { BuilderModelSerialised, BuilderModelValidated, BuilderRefEntities } from '../entities/index';
|
|
2
|
+
import type { BuilderErrorLocation, BuilderErrors } from '../exception';
|
|
3
|
+
import type { ParamableSerialised } from '../references';
|
|
4
|
+
import type { BuilderResolve } from './resolve';
|
|
5
|
+
import type { ValidationResult } from './result';
|
|
6
|
+
export type BuilderModelValidationResult = ValidationResult<BuilderModelValidated>;
|
|
7
|
+
export declare function builderErrorDuplicateName(name: string, location?: BuilderErrorLocation): {
|
|
8
|
+
name: string;
|
|
9
|
+
kind: "duplicate-name";
|
|
10
|
+
location: BuilderErrorLocation;
|
|
11
|
+
};
|
|
12
|
+
export type BuilderErrorDuplicateName = ReturnType<typeof builderErrorDuplicateName>;
|
|
13
|
+
export declare function builderErrorInvalidCollectionBounds(name: string, min: number, max: number, location?: BuilderErrorLocation): {
|
|
14
|
+
name: string;
|
|
15
|
+
min: number;
|
|
16
|
+
max: number;
|
|
17
|
+
kind: "invalid-collection-bounds";
|
|
18
|
+
location: BuilderErrorLocation;
|
|
19
|
+
};
|
|
20
|
+
export type BuilderErrorInvalidCollectionBounds = ReturnType<typeof builderErrorInvalidCollectionBounds>;
|
|
21
|
+
export type BuilderErrorInvalidPathReason = 'shape' | 'out-of-bounds' | 'missing-collection' | 'option-not-found';
|
|
22
|
+
export declare function builderErrorInvalidPath(reason: BuilderErrorInvalidPathReason, location?: BuilderErrorLocation): {
|
|
23
|
+
reason: BuilderErrorInvalidPathReason;
|
|
24
|
+
kind: "invalid-path";
|
|
25
|
+
location: BuilderErrorLocation;
|
|
26
|
+
};
|
|
27
|
+
export type BuilderErrorInvalidPath = ReturnType<typeof builderErrorInvalidPath>;
|
|
28
|
+
export declare function builderErrorInvalidSelectMapKey(key: string, location?: BuilderErrorLocation): {
|
|
29
|
+
key: string;
|
|
30
|
+
kind: "invalid-select-map-key";
|
|
31
|
+
location: BuilderErrorLocation;
|
|
32
|
+
};
|
|
33
|
+
export type BuilderErrorInvalidSelectMapKey = ReturnType<typeof builderErrorInvalidSelectMapKey>;
|
|
34
|
+
export declare function validateModel(input: unknown, references?: BuilderRefEntities): BuilderModelValidationResult;
|
|
35
|
+
export declare function checkModelExpectations(mergedModel: BuilderModelSerialised, model: BuilderModelSerialised, location: BuilderErrorLocation): BuilderErrors;
|
|
36
|
+
export declare function validateModelStructure(input: ParamableSerialised<BuilderModelSerialised>, resolve: BuilderResolve, location: BuilderErrorLocation): BuilderModelValidationResult;
|