@builder-builder/builder 0.0.23 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/client.d.ts +3 -1
- package/dist/client/client.js +30 -18
- package/dist/client/index.d.ts +1 -4
- package/dist/client/index.js +1 -2
- package/dist/client/public.d.ts +4 -0
- package/dist/client/public.js +2 -0
- package/dist/client/schema.d.ts +23 -14
- package/dist/client/schema.js +9 -2
- package/dist/entities/collection/collection.d.ts +2 -2
- package/dist/entities/collection/config.d.ts +1 -1
- package/dist/entities/collection/config.js +1 -1
- package/dist/entities/component/component.d.ts +2 -2
- package/dist/entities/component/config.d.ts +1 -1
- package/dist/entities/component/config.js +1 -1
- package/dist/entities/expectation.d.ts +1 -1
- package/dist/entities/kind.d.ts +3 -3
- package/dist/entities/kind.js +3 -3
- package/dist/entities/option/option.d.ts +2 -2
- package/dist/entities/option/select.d.ts +1 -1
- package/dist/entities/option/select.js +7 -5
- package/dist/entities/option/toggle.d.ts +1 -1
- package/dist/entities/option/toggle.js +1 -1
- package/dist/entities/paths.d.ts +2 -2
- package/dist/entities/pricing/rates.d.ts +1 -1
- package/dist/entities/serialise.d.ts +3 -3
- package/dist/entities/ui/describe.d.ts +1 -1
- package/dist/entities/ui/describe.js +2 -2
- package/dist/entities/ui/input.d.ts +1 -1
- package/dist/entities/ui/page.d.ts +1 -1
- package/dist/entities/ui/page.js +2 -2
- package/dist/entities/ui/pages.d.ts +2 -2
- package/dist/entities/ui/pages.js +2 -2
- package/dist/errors/check.d.ts +2 -3
- package/dist/errors/check.js +5 -10
- package/dist/errors/errors.d.ts +231 -158
- package/dist/errors/errors.js +143 -173
- package/dist/errors/exception.d.ts +6 -4
- package/dist/errors/exception.js +11 -66
- package/dist/errors/index.d.ts +2 -4
- package/dist/errors/index.js +2 -2
- package/dist/errors/public.d.ts +2 -0
- package/dist/errors/public.js +1 -0
- package/dist/index.d.ts +4 -36
- package/dist/index.js +4 -19
- package/dist/mappers/price.js +1 -1
- package/dist/mappers/render/render.js +7 -7
- package/dist/mappers/resolve.js +5 -5
- package/dist/mappers/variants/option-graph.js +11 -4
- package/dist/mappers/variants/variants.js +7 -6
- package/dist/public.d.ts +37 -0
- package/dist/public.js +19 -0
- package/dist/validate/brand.js +2 -4
- package/dist/validate/builder.d.ts +2 -2
- package/dist/validate/builder.js +3 -3
- package/dist/validate/expectations.d.ts +2 -2
- package/dist/validate/expectations.js +1 -1
- package/dist/validate/index.d.ts +0 -1
- package/dist/validate/instance.d.ts +2 -2
- package/dist/validate/instance.js +6 -6
- package/dist/validate/model.d.ts +4 -4
- package/dist/validate/model.js +118 -101
- package/dist/validate/paths.d.ts +2 -2
- package/dist/validate/paths.js +45 -21
- package/dist/validate/pricing.d.ts +4 -4
- package/dist/validate/pricing.js +26 -13
- package/dist/validate/resolve.d.ts +2 -2
- package/dist/validate/resolve.js +14 -3
- package/dist/validate/ui.d.ts +4 -4
- package/dist/validate/ui.js +3 -3
- package/dist/validate/variants.d.ts +2 -2
- package/dist/validate/variants.js +16 -16
- package/package.json +11 -7
- package/dist/private.d.ts +0 -3
- package/dist/private.js +0 -3
package/dist/validate/paths.js
CHANGED
|
@@ -5,47 +5,71 @@ import { resolveCollections } from '../mappers/index.js';
|
|
|
5
5
|
const NumberSchema = v.number();
|
|
6
6
|
const StringSchema = v.string();
|
|
7
7
|
export function checkPath(model, path, errors) {
|
|
8
|
-
|
|
8
|
+
if (path.length === 0) {
|
|
9
|
+
errors.pathEmpty();
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const lastIndex = path.length - 1;
|
|
13
|
+
const models = walkPath([model], path.slice(0, -1), 0, errors);
|
|
9
14
|
if (models == null) {
|
|
10
15
|
return;
|
|
11
16
|
}
|
|
12
17
|
const optionName = path.at(-1);
|
|
13
18
|
if (!check.is(StringSchema, optionName)) {
|
|
14
|
-
errors.
|
|
19
|
+
errors.scope(lastIndex, () => errors.pathInvalidSegment());
|
|
15
20
|
return;
|
|
16
21
|
}
|
|
17
|
-
if (
|
|
18
|
-
|
|
22
|
+
if (models.some((model) => model.options.some((option) => option.name === optionName))) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const isCollection = models.some((model) => model.collections.some((entry) => entry.name === optionName));
|
|
26
|
+
if (isCollection) {
|
|
27
|
+
errors.scope(lastIndex, () => errors.pathTargetIsCollection());
|
|
28
|
+
return;
|
|
19
29
|
}
|
|
30
|
+
const isComponent = models.some((model) => model.components.some((entry) => entry.name === optionName));
|
|
31
|
+
if (isComponent) {
|
|
32
|
+
errors.scope(lastIndex, () => errors.pathTargetIsComponent());
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
errors.scope(lastIndex, () => errors.pathMissingOption());
|
|
20
36
|
}
|
|
21
|
-
function walkPath(
|
|
37
|
+
function walkPath(models, remaining, offset, errors) {
|
|
22
38
|
if (remaining.length === 0) {
|
|
23
|
-
return
|
|
39
|
+
return models;
|
|
24
40
|
}
|
|
25
41
|
const [collectionName, index, ...rest] = remaining;
|
|
26
|
-
if (!check.is(StringSchema, collectionName)
|
|
27
|
-
errors.
|
|
42
|
+
if (!check.is(StringSchema, collectionName)) {
|
|
43
|
+
errors.scope(offset, () => errors.pathInvalidSegment());
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (!check.is(NumberSchema, index)) {
|
|
47
|
+
errors.scope(offset + 1, () => errors.pathInvalidSegment());
|
|
28
48
|
return null;
|
|
29
49
|
}
|
|
30
|
-
const
|
|
31
|
-
const collection =
|
|
32
|
-
return collection == null ? [] :
|
|
50
|
+
const collectionConfigs = models.flatMap((model) => {
|
|
51
|
+
const collection = model.collections.find((entry) => entry.name === collectionName);
|
|
52
|
+
return collection == null ? [] : resolveCollections(collection);
|
|
33
53
|
});
|
|
34
|
-
if (
|
|
35
|
-
errors.
|
|
54
|
+
if (collectionConfigs.length === 0) {
|
|
55
|
+
errors.scope(offset, () => errors.pathMissingCollection());
|
|
36
56
|
return null;
|
|
37
57
|
}
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
58
|
+
const indexableConfigs = collectionConfigs.filter(({ max }) => !check.is(NumberSchema, max) || index < max);
|
|
59
|
+
if (indexableConfigs.length === 0) {
|
|
60
|
+
const max = collectionConfigs.reduce((highest, { max }) => {
|
|
61
|
+
if (!check.is(NumberSchema, max)) {
|
|
62
|
+
return highest;
|
|
63
|
+
}
|
|
64
|
+
return max > highest ? max : highest;
|
|
65
|
+
}, 0);
|
|
66
|
+
errors.scope(offset + 1, () => errors.pathInvalidIndex(max));
|
|
41
67
|
return null;
|
|
42
68
|
}
|
|
43
|
-
const next =
|
|
44
|
-
.filter(({ max }) => !check.is(NumberSchema, max) || index < max)
|
|
45
|
-
.flatMap(({ model: configModel }) => check.is(BuilderModelSerialisedSchema, configModel) ? [configModel] : []));
|
|
69
|
+
const next = indexableConfigs.flatMap((collectionConfig) => check.is(BuilderModelSerialisedSchema, collectionConfig.model) ? [collectionConfig.model] : []);
|
|
46
70
|
if (next.length === 0) {
|
|
47
|
-
errors.
|
|
71
|
+
errors.scope(offset, () => errors.pathMissingCollection());
|
|
48
72
|
return null;
|
|
49
73
|
}
|
|
50
|
-
return walkPath(next, rest, errors);
|
|
74
|
+
return walkPath(next, rest, offset + 2, errors);
|
|
51
75
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BuilderModelSerialised, BuilderPricingSerialised, BuilderPricingValidated, BuilderReferences, ValidationResult } from '../entities/index';
|
|
2
2
|
import type { BuilderResolve } from './resolve';
|
|
3
|
-
import {
|
|
3
|
+
import { BuilderErrorsScope } from '../errors/index.js';
|
|
4
4
|
export type BuilderPricingValidationResult = ValidationResult<BuilderPricingValidated>;
|
|
5
|
-
export declare function validatePricing(input: unknown, references?: BuilderReferences, errors?:
|
|
6
|
-
export declare function validatePricingStructure(input: BuilderPricingSerialised, resolve: BuilderResolve, errors:
|
|
7
|
-
export declare function checkPricingExpectations(model: BuilderModelSerialised, pricing: BuilderPricingSerialised, errors:
|
|
5
|
+
export declare function validatePricing(input: unknown, references?: BuilderReferences, errors?: BuilderErrorsScope): BuilderPricingValidationResult;
|
|
6
|
+
export declare function validatePricingStructure(input: BuilderPricingSerialised, resolve: BuilderResolve, errors: BuilderErrorsScope): BuilderPricingSerialised;
|
|
7
|
+
export declare function checkPricingExpectations(model: BuilderModelSerialised, pricing: BuilderPricingSerialised, errors: BuilderErrorsScope): void;
|
package/dist/validate/pricing.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { BuilderPricingExpressionSchema, BuilderPricingSerialisedSchema, BuilderRatesSchema, pricing, serialise } from '../entities/index.js';
|
|
3
|
-
import {
|
|
3
|
+
import { BuilderErrorsScope, check } from '../errors/index.js';
|
|
4
4
|
import { validate } from './brand.js';
|
|
5
5
|
import { resolver } from './resolve.js';
|
|
6
6
|
const EMPTY_PRICING = validate(serialise.pricing(pricing()));
|
|
7
7
|
const NumberSchema = v.number();
|
|
8
|
-
export function validatePricing(input, references = [], errors = new
|
|
8
|
+
export function validatePricing(input, references = [], errors = new BuilderErrorsScope(input)) {
|
|
9
9
|
if (!check.is(BuilderPricingSerialisedSchema, input)) {
|
|
10
|
-
errors.
|
|
10
|
+
errors.entityInvalid('pricing');
|
|
11
11
|
return [EMPTY_PRICING, errors.errors];
|
|
12
12
|
}
|
|
13
13
|
const resolve = resolver(errors, references);
|
|
@@ -15,10 +15,14 @@ export function validatePricing(input, references = [], errors = new BuilderVali
|
|
|
15
15
|
return [validate(structure), errors.errors];
|
|
16
16
|
}
|
|
17
17
|
export function validatePricingStructure(input, resolve, errors) {
|
|
18
|
-
const rates = input.rates.flatMap((entry) => {
|
|
18
|
+
const rates = errors.scope('rates', () => input.rates.flatMap((entry, index) => {
|
|
19
19
|
const resolved = resolve(entry);
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (v.is(BuilderRatesSchema, resolved)) {
|
|
21
|
+
return [resolved];
|
|
22
|
+
}
|
|
23
|
+
errors.scope(index, () => errors.pricingInvalidRateValue());
|
|
24
|
+
return [];
|
|
25
|
+
}));
|
|
22
26
|
const formula = input.formula == null ? null : resolveExpression(input.formula);
|
|
23
27
|
if (formula != null) {
|
|
24
28
|
walkExpression(formula, false);
|
|
@@ -27,6 +31,7 @@ export function validatePricingStructure(input, resolve, errors) {
|
|
|
27
31
|
function resolveExpression(input) {
|
|
28
32
|
const resolved = resolve(input);
|
|
29
33
|
if (!check.is(BuilderPricingExpressionSchema, resolved)) {
|
|
34
|
+
errors.pricingMalformedExpression();
|
|
30
35
|
return null;
|
|
31
36
|
}
|
|
32
37
|
if (check.is(NumberSchema, resolved)) {
|
|
@@ -50,24 +55,29 @@ export function validatePricingStructure(input, resolve, errors) {
|
|
|
50
55
|
switch (expression.kind) {
|
|
51
56
|
case 'variantPrice':
|
|
52
57
|
if (!insideVariants) {
|
|
53
|
-
errors.
|
|
58
|
+
errors.pricingInvalidScope();
|
|
54
59
|
}
|
|
55
60
|
return;
|
|
56
61
|
case 'lookup':
|
|
57
62
|
errors.scope('lookup', () => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
if (rates.length === 0) {
|
|
64
|
+
errors.pricingEmptyRates();
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const exists = rates.some((entry) => entry[expression.rate] != null);
|
|
68
|
+
if (!exists) {
|
|
69
|
+
errors.pricingMissingRate();
|
|
70
|
+
}
|
|
61
71
|
}
|
|
62
72
|
if (!insideVariants) {
|
|
63
|
-
errors.
|
|
73
|
+
errors.pricingInvalidScope();
|
|
64
74
|
}
|
|
65
75
|
});
|
|
66
76
|
return;
|
|
67
77
|
case 'variants':
|
|
68
78
|
errors.scope('variants', () => {
|
|
69
79
|
if (insideVariants) {
|
|
70
|
-
errors.
|
|
80
|
+
errors.pricingNestedVariants();
|
|
71
81
|
}
|
|
72
82
|
const inner = expression.expression;
|
|
73
83
|
check.assert(BuilderPricingExpressionSchema, inner);
|
|
@@ -81,6 +91,9 @@ export function validatePricingStructure(input, resolve, errors) {
|
|
|
81
91
|
const { left, right } = expression;
|
|
82
92
|
check.assert(BuilderPricingExpressionSchema, left);
|
|
83
93
|
check.assert(BuilderPricingExpressionSchema, right);
|
|
94
|
+
if (expression.kind === 'div' && check.is(NumberSchema, right) && right === 0) {
|
|
95
|
+
errors.pricingDivideByZero();
|
|
96
|
+
}
|
|
84
97
|
errors.scope('left', () => walkExpression(left, insideVariants));
|
|
85
98
|
errors.scope('right', () => walkExpression(right, insideVariants));
|
|
86
99
|
return;
|
|
@@ -105,7 +118,7 @@ export function checkPricingExpectations(model, pricing, errors) {
|
|
|
105
118
|
case 'lookup':
|
|
106
119
|
errors.scope('lookup', () => {
|
|
107
120
|
if (expression.key.kind === 'option' && !optionNames.has(expression.key.name)) {
|
|
108
|
-
errors.
|
|
121
|
+
errors.pricingMissingOption();
|
|
109
122
|
}
|
|
110
123
|
});
|
|
111
124
|
return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { BuilderBindings, BuilderReferences } from '../entities/index';
|
|
2
|
-
import type {
|
|
2
|
+
import type { BuilderErrorsScope } from '../errors/index';
|
|
3
3
|
export type BuilderResolve = (value: unknown) => unknown;
|
|
4
|
-
export declare function resolver(errors:
|
|
4
|
+
export declare function resolver(errors: BuilderErrorsScope, references?: BuilderReferences, bindings?: BuilderBindings): BuilderResolve;
|
package/dist/validate/resolve.js
CHANGED
|
@@ -3,6 +3,7 @@ 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 = {}) {
|
|
6
|
+
const resolving = new Set();
|
|
6
7
|
function resolve(value) {
|
|
7
8
|
if (check.is(BuilderParameterSerialisedSchema, value)) {
|
|
8
9
|
return resolveParameter(value);
|
|
@@ -18,16 +19,26 @@ export function resolver(errors, references = [], bindings = {}) {
|
|
|
18
19
|
}
|
|
19
20
|
return value;
|
|
20
21
|
function resolveReference(reference) {
|
|
22
|
+
if (resolving.has(reference.id)) {
|
|
23
|
+
errors.referenceCircular();
|
|
24
|
+
return reference;
|
|
25
|
+
}
|
|
21
26
|
const found = references.find((entry) => entry.id === reference.id);
|
|
22
27
|
if (found == null) {
|
|
23
|
-
errors.
|
|
28
|
+
errors.referenceMissing();
|
|
24
29
|
return reference;
|
|
25
30
|
}
|
|
26
|
-
|
|
31
|
+
resolving.add(reference.id);
|
|
32
|
+
try {
|
|
33
|
+
return resolve(found.serialised);
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
resolving.delete(reference.id);
|
|
37
|
+
}
|
|
27
38
|
}
|
|
28
39
|
function resolveParameter(parameter) {
|
|
29
40
|
if (!(parameter.name in bindings)) {
|
|
30
|
-
errors.
|
|
41
|
+
errors.referenceUnboundParameter();
|
|
31
42
|
return null;
|
|
32
43
|
}
|
|
33
44
|
const binding = bindings[parameter.name];
|
package/dist/validate/ui.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BuilderModelSerialised, BuilderReferences, BuilderUISerialised, BuilderUIValidated, ValidationResult } from '../entities/index';
|
|
2
2
|
import type { BuilderResolve } from './resolve';
|
|
3
|
-
import {
|
|
3
|
+
import { BuilderErrorsScope } from '../errors/index.js';
|
|
4
4
|
export type BuilderUIValidationResult = ValidationResult<BuilderUIValidated>;
|
|
5
|
-
export declare function validateUI(input: unknown, references?: BuilderReferences, errors?:
|
|
6
|
-
export declare function validateUIStructure(ui: BuilderUISerialised, resolve: BuilderResolve, errors:
|
|
7
|
-
export declare function checkUIExpectations(mergedModel: BuilderModelSerialised, ui: BuilderUIValidated, errors:
|
|
5
|
+
export declare function validateUI(input: unknown, references?: BuilderReferences, errors?: BuilderErrorsScope): BuilderUIValidationResult;
|
|
6
|
+
export declare function validateUIStructure(ui: BuilderUISerialised, resolve: BuilderResolve, errors: BuilderErrorsScope): BuilderUIValidated;
|
|
7
|
+
export declare function checkUIExpectations(mergedModel: BuilderModelSerialised, ui: BuilderUIValidated, errors: BuilderErrorsScope): void;
|
package/dist/validate/ui.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { BuilderModelSerialisedSchema, BuilderUIInputMetadataSchema, BuilderUISerialisedSchema, modelsMerge, serialise, uis, validateUIDescribe, validateUIInput, validateUIPage, validateUIPages } from '../entities/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { BuilderErrorsScope, check } from '../errors/index.js';
|
|
3
3
|
import { resolveCollections } from '../mappers/index.js';
|
|
4
4
|
import { validate } from './brand.js';
|
|
5
5
|
import { checkExpectations } from './expectations.js';
|
|
6
6
|
import { checkPath } from './paths.js';
|
|
7
7
|
import { resolver } from './resolve.js';
|
|
8
|
-
export function validateUI(input, references = [], errors = new
|
|
8
|
+
export function validateUI(input, references = [], errors = new BuilderErrorsScope(input)) {
|
|
9
9
|
if (!check.is(BuilderUISerialisedSchema, input)) {
|
|
10
|
-
errors.
|
|
10
|
+
errors.entityInvalid('ui');
|
|
11
11
|
return [validate(serialise.ui(uis())), errors.errors];
|
|
12
12
|
}
|
|
13
13
|
const resolve = resolver(errors, references);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BuilderModelValidated, BuilderVariantsValidated, ValidationResult } from '../entities/index';
|
|
2
|
-
import {
|
|
2
|
+
import { BuilderErrorsScope } from '../errors/index.js';
|
|
3
3
|
export type BuilderVariantsValidationOptions = {
|
|
4
4
|
readonly partial?: boolean;
|
|
5
5
|
};
|
|
6
6
|
export type BuilderVariantsValidationResult = ValidationResult<BuilderVariantsValidated>;
|
|
7
|
-
export declare function validateVariants(model: BuilderModelValidated, input: unknown, options?: BuilderVariantsValidationOptions, errors?:
|
|
7
|
+
export declare function validateVariants(model: BuilderModelValidated, input: unknown, options?: BuilderVariantsValidationOptions, errors?: BuilderErrorsScope): BuilderVariantsValidationResult;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { BuilderComponentConfigSerialisedSchema, detailValueSchema } from '../entities/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { BuilderErrorsScope, check } from '../errors/index.js';
|
|
3
3
|
import { BuilderVariantsSchema } from '../instance.js';
|
|
4
4
|
import { createVariants } from '../mappers/index.js';
|
|
5
5
|
import { validate } from './brand.js';
|
|
6
|
-
export function validateVariants(model, input, options = {}, errors = new
|
|
6
|
+
export function validateVariants(model, input, options = {}, errors = new BuilderErrorsScope(input)) {
|
|
7
7
|
if (!check.is(BuilderVariantsSchema, input)) {
|
|
8
|
-
errors.
|
|
8
|
+
errors.variantsInvalid();
|
|
9
9
|
return [validate({}), errors.errors];
|
|
10
10
|
}
|
|
11
11
|
const variants = input;
|
|
12
12
|
const expected = createVariants(model);
|
|
13
13
|
if (Object.keys(expected).length === 0) {
|
|
14
|
-
errors.
|
|
14
|
+
errors.modelEmptyComponents();
|
|
15
15
|
return [validate({}), errors.errors];
|
|
16
16
|
}
|
|
17
17
|
errors.scope('variants', () => {
|
|
@@ -21,26 +21,26 @@ export function validateVariants(model, input, options = {}, errors = new Builde
|
|
|
21
21
|
function checkVariants() {
|
|
22
22
|
Object.entries(expected).forEach(([component, expectedVariants]) => {
|
|
23
23
|
const componentVariants = variants[component];
|
|
24
|
-
if (componentVariants == null) {
|
|
25
|
-
if (options.partial !== false) {
|
|
26
|
-
errors.missingComponent(component);
|
|
27
|
-
}
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
24
|
errors.scope(component, () => {
|
|
25
|
+
if (componentVariants == null) {
|
|
26
|
+
if (options.partial !== false) {
|
|
27
|
+
errors.variantsMissingComponent();
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
31
|
const expectedKeys = new Map(expectedVariants.map(({ instance }) => [sortedKey(instance), instance]));
|
|
32
32
|
const actualKeys = new Set(componentVariants.map(({ instance }) => sortedKey(instance)));
|
|
33
33
|
componentVariants.forEach((variant, index) => {
|
|
34
34
|
errors.scope(index, () => {
|
|
35
35
|
const { instance } = variant;
|
|
36
36
|
if (!expectedKeys.has(sortedKey(instance))) {
|
|
37
|
-
errors.
|
|
37
|
+
errors.variantsInvalidVariant();
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
41
|
Array.from(expectedKeys).forEach(([key, instance]) => {
|
|
42
42
|
if (!actualKeys.has(key)) {
|
|
43
|
-
errors.
|
|
43
|
+
errors.variantsMissingVariant(instance);
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
});
|
|
@@ -50,7 +50,7 @@ export function validateVariants(model, input, options = {}, errors = new Builde
|
|
|
50
50
|
Object.keys(variants).forEach((component) => {
|
|
51
51
|
errors.scope(component, () => {
|
|
52
52
|
if (expected[component] == null) {
|
|
53
|
-
errors.
|
|
53
|
+
errors.variantsUnexpectedComponent();
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
});
|
|
@@ -72,18 +72,18 @@ export function validateVariants(model, input, options = {}, errors = new Builde
|
|
|
72
72
|
fields.forEach(({ name, valueType, isOptional }) => {
|
|
73
73
|
errors.scope(name, () => {
|
|
74
74
|
if (!(name in details)) {
|
|
75
|
-
errors.
|
|
75
|
+
errors.variantsMissingDetail();
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
if (!check.is(detailValueSchema(valueType, isOptional), details[name])) {
|
|
79
|
-
errors.
|
|
79
|
+
errors.variantsInvalidDetail();
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
Object.keys(details).forEach((detail) => {
|
|
84
84
|
if (!expectedNames.has(detail)) {
|
|
85
85
|
errors.scope(detail, () => {
|
|
86
|
-
errors.
|
|
86
|
+
errors.variantsUnexpectedDetail();
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
});
|
package/package.json
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder-builder/builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
7
7
|
},
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./dist/
|
|
11
|
-
"default": "./dist/
|
|
10
|
+
"types": "./dist/public.d.ts",
|
|
11
|
+
"default": "./dist/public.js"
|
|
12
12
|
},
|
|
13
13
|
"./client": {
|
|
14
|
-
"types": "./dist/client/
|
|
15
|
-
"default": "./dist/client/
|
|
14
|
+
"types": "./dist/client/public.d.ts",
|
|
15
|
+
"default": "./dist/client/public.js"
|
|
16
|
+
},
|
|
17
|
+
"./errors": {
|
|
18
|
+
"types": "./dist/errors/public.d.ts",
|
|
19
|
+
"default": "./dist/errors/public.js"
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
22
|
"files": [
|
|
19
23
|
"dist"
|
|
20
24
|
],
|
|
21
|
-
"svelte": "./dist/
|
|
22
|
-
"types": "./dist/
|
|
25
|
+
"svelte": "./dist/public.js",
|
|
26
|
+
"types": "./dist/public.d.ts",
|
|
23
27
|
"publishConfig": {
|
|
24
28
|
"access": "public"
|
|
25
29
|
},
|
package/dist/private.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
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
|
-
export { BuilderEnvironmentSchema } from './environment.js';
|
|
3
|
-
export { BuilderComponentVariantsSchema, BuilderVariantsSchema } from './instance.js';
|
package/dist/private.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
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
|
-
export { BuilderEnvironmentSchema } from './environment.js';
|
|
3
|
-
export { BuilderComponentVariantsSchema, BuilderVariantsSchema } from './instance.js';
|