@builder-builder/builder 0.0.24 → 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 +29 -20
- 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 +22 -14
- package/dist/client/schema.js +7 -1
- 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/errors/errors.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
return { kind, location };
|
|
3
|
-
}
|
|
4
|
-
export class BuilderValidateErrors {
|
|
1
|
+
export class BuilderErrorsScope {
|
|
5
2
|
#errors = [];
|
|
6
3
|
#location = [];
|
|
4
|
+
#root;
|
|
5
|
+
constructor(root) {
|
|
6
|
+
this.#root = root;
|
|
7
|
+
}
|
|
7
8
|
get errors() {
|
|
8
9
|
return this.#errors;
|
|
9
10
|
}
|
|
@@ -16,175 +17,144 @@ export class BuilderValidateErrors {
|
|
|
16
17
|
this.#location = this.#location.slice(0, -1);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
return this.#addError({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return this.#addError(
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return this.#addError(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return this.#addError(
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return this.#addError(
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return this.#addError(
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return this.#addError(
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return this.#addError(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return this.#addError(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return this.#addError(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return this.#addError(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return this.#addError({
|
|
158
|
-
...builderError('unexpected-detail', this.#location),
|
|
159
|
-
component,
|
|
160
|
-
detail,
|
|
161
|
-
instance
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
invalidDetail(component, detail, instance) {
|
|
165
|
-
return this.#addError({
|
|
166
|
-
...builderError('invalid-detail', this.#location),
|
|
167
|
-
component,
|
|
168
|
-
detail,
|
|
169
|
-
instance
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
invalidPricing(reason) {
|
|
173
|
-
return this.#addError({
|
|
174
|
-
...builderError('invalid-pricing', this.#location),
|
|
175
|
-
reason
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
missingRate(rate) {
|
|
179
|
-
return this.#addError({
|
|
180
|
-
...builderError('missing-rate', this.#location),
|
|
181
|
-
rate
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
noComponents() {
|
|
185
|
-
return this.#addError(builderError('no-components', this.#location));
|
|
186
|
-
}
|
|
187
|
-
#addError(error) {
|
|
20
|
+
entityInvalid(target) {
|
|
21
|
+
return this.#addError('entity-invalid', { target });
|
|
22
|
+
}
|
|
23
|
+
entityEmptyLabel() {
|
|
24
|
+
return this.#addError('entity-empty-label');
|
|
25
|
+
}
|
|
26
|
+
entityEmptyInputs() {
|
|
27
|
+
return this.#addError('entity-empty-inputs');
|
|
28
|
+
}
|
|
29
|
+
entityEmptyName() {
|
|
30
|
+
return this.#addError('entity-empty-name');
|
|
31
|
+
}
|
|
32
|
+
entityInvalidCollectionBounds() {
|
|
33
|
+
return this.#addError('entity-invalid-collection-bounds');
|
|
34
|
+
}
|
|
35
|
+
entityInvalidSelectDefault() {
|
|
36
|
+
return this.#addError('entity-invalid-select-default');
|
|
37
|
+
}
|
|
38
|
+
entityInvalidSelectLabel() {
|
|
39
|
+
return this.#addError('entity-invalid-select-label');
|
|
40
|
+
}
|
|
41
|
+
entityInvalidToggleDefault() {
|
|
42
|
+
return this.#addError('entity-invalid-toggle-default');
|
|
43
|
+
}
|
|
44
|
+
entityDuplicateField() {
|
|
45
|
+
return this.#addError('entity-duplicate-field');
|
|
46
|
+
}
|
|
47
|
+
modelDuplicateOption() {
|
|
48
|
+
return this.#addError('model-duplicate-option');
|
|
49
|
+
}
|
|
50
|
+
modelDuplicateComponent() {
|
|
51
|
+
return this.#addError('model-duplicate-component');
|
|
52
|
+
}
|
|
53
|
+
modelDuplicateCollection() {
|
|
54
|
+
return this.#addError('model-duplicate-collection');
|
|
55
|
+
}
|
|
56
|
+
modelOverriddenOption() {
|
|
57
|
+
return this.#addError('model-overridden-option');
|
|
58
|
+
}
|
|
59
|
+
modelOverriddenComponent() {
|
|
60
|
+
return this.#addError('model-overridden-component');
|
|
61
|
+
}
|
|
62
|
+
modelOverriddenCollection() {
|
|
63
|
+
return this.#addError('model-overridden-collection');
|
|
64
|
+
}
|
|
65
|
+
modelUnmetExpectation() {
|
|
66
|
+
return this.#addError('model-unmet-expectation');
|
|
67
|
+
}
|
|
68
|
+
modelEmptyComponents() {
|
|
69
|
+
return this.#addError('model-empty-components');
|
|
70
|
+
}
|
|
71
|
+
pathEmpty() {
|
|
72
|
+
return this.#addError('path-empty');
|
|
73
|
+
}
|
|
74
|
+
pathInvalidSegment() {
|
|
75
|
+
return this.#addError('path-invalid-segment');
|
|
76
|
+
}
|
|
77
|
+
pathInvalidIndex(max) {
|
|
78
|
+
return this.#addError('path-invalid-index', { max });
|
|
79
|
+
}
|
|
80
|
+
pathTargetIsCollection() {
|
|
81
|
+
return this.#addError('path-target-is-collection');
|
|
82
|
+
}
|
|
83
|
+
pathTargetIsComponent() {
|
|
84
|
+
return this.#addError('path-target-is-component');
|
|
85
|
+
}
|
|
86
|
+
pathMissingOption() {
|
|
87
|
+
return this.#addError('path-missing-option');
|
|
88
|
+
}
|
|
89
|
+
pathMissingCollection() {
|
|
90
|
+
return this.#addError('path-missing-collection');
|
|
91
|
+
}
|
|
92
|
+
referenceMissing() {
|
|
93
|
+
return this.#addError('reference-missing');
|
|
94
|
+
}
|
|
95
|
+
referenceCircular() {
|
|
96
|
+
return this.#addError('reference-circular');
|
|
97
|
+
}
|
|
98
|
+
referenceUnboundParameter() {
|
|
99
|
+
return this.#addError('reference-unbound-parameter');
|
|
100
|
+
}
|
|
101
|
+
instanceInvalidOption() {
|
|
102
|
+
return this.#addError('instance-invalid-option');
|
|
103
|
+
}
|
|
104
|
+
instanceInvalidCollection() {
|
|
105
|
+
return this.#addError('instance-invalid-collection');
|
|
106
|
+
}
|
|
107
|
+
variantsInvalid() {
|
|
108
|
+
return this.#addError('variants-invalid');
|
|
109
|
+
}
|
|
110
|
+
variantsMissingComponent() {
|
|
111
|
+
return this.#addError('variants-missing-component');
|
|
112
|
+
}
|
|
113
|
+
variantsUnexpectedComponent() {
|
|
114
|
+
return this.#addError('variants-unexpected-component');
|
|
115
|
+
}
|
|
116
|
+
variantsMissingVariant(instance) {
|
|
117
|
+
return this.#addError('variants-missing-variant', { instance });
|
|
118
|
+
}
|
|
119
|
+
variantsInvalidVariant() {
|
|
120
|
+
return this.#addError('variants-invalid-variant');
|
|
121
|
+
}
|
|
122
|
+
variantsMissingDetail() {
|
|
123
|
+
return this.#addError('variants-missing-detail');
|
|
124
|
+
}
|
|
125
|
+
variantsUnexpectedDetail() {
|
|
126
|
+
return this.#addError('variants-unexpected-detail');
|
|
127
|
+
}
|
|
128
|
+
variantsInvalidDetail() {
|
|
129
|
+
return this.#addError('variants-invalid-detail');
|
|
130
|
+
}
|
|
131
|
+
pricingInvalidScope() {
|
|
132
|
+
return this.#addError('pricing-invalid-scope');
|
|
133
|
+
}
|
|
134
|
+
pricingNestedVariants() {
|
|
135
|
+
return this.#addError('pricing-nested-variants');
|
|
136
|
+
}
|
|
137
|
+
pricingMalformedExpression() {
|
|
138
|
+
return this.#addError('pricing-malformed-expression');
|
|
139
|
+
}
|
|
140
|
+
pricingInvalidRateValue() {
|
|
141
|
+
return this.#addError('pricing-invalid-rate-value');
|
|
142
|
+
}
|
|
143
|
+
pricingEmptyRates() {
|
|
144
|
+
return this.#addError('pricing-empty-rates');
|
|
145
|
+
}
|
|
146
|
+
pricingDivideByZero() {
|
|
147
|
+
return this.#addError('pricing-divide-by-zero');
|
|
148
|
+
}
|
|
149
|
+
pricingMissingOption() {
|
|
150
|
+
return this.#addError('pricing-missing-option');
|
|
151
|
+
}
|
|
152
|
+
pricingMissingRate() {
|
|
153
|
+
return this.#addError('pricing-missing-rate');
|
|
154
|
+
}
|
|
155
|
+
#addError(kind, extras) {
|
|
156
|
+
const error = { kind, location: this.#location, ...extras };
|
|
157
|
+
Object.defineProperty(error, 'root', { value: this.#root, enumerable: false });
|
|
188
158
|
this.#errors = [...this.#errors, error];
|
|
189
159
|
return error;
|
|
190
160
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { BuilderErrors } from './errors';
|
|
2
|
-
import * as v from 'valibot';
|
|
2
|
+
import type * as v from 'valibot';
|
|
3
3
|
export type BuilderExceptionPayload = {
|
|
4
4
|
readonly category: 'validation';
|
|
5
5
|
readonly errors: BuilderErrors;
|
|
6
|
+
} | {
|
|
7
|
+
readonly category: 'invariant';
|
|
8
|
+
readonly value: unknown;
|
|
6
9
|
} | {
|
|
7
10
|
readonly category: 'assertion';
|
|
8
|
-
readonly
|
|
9
|
-
readonly issues
|
|
11
|
+
readonly value: unknown;
|
|
12
|
+
readonly issues: ReadonlyArray<v.BaseIssue<unknown>>;
|
|
10
13
|
} | {
|
|
11
14
|
readonly category: 'request';
|
|
12
15
|
readonly url: string;
|
|
@@ -19,4 +22,3 @@ export declare class BuilderException extends globalThis.Error {
|
|
|
19
22
|
constructor(payload: BuilderExceptionPayload);
|
|
20
23
|
get errors(): BuilderErrors;
|
|
21
24
|
}
|
|
22
|
-
export declare function formatSchemaIssues(issues: ReadonlyArray<v.BaseIssue<unknown>>): `${string}! ❌`;
|
package/dist/errors/exception.js
CHANGED
|
@@ -1,77 +1,22 @@
|
|
|
1
|
-
import * as v from 'valibot';
|
|
2
1
|
export class BuilderException extends globalThis.Error {
|
|
3
2
|
payload;
|
|
4
3
|
constructor(payload) {
|
|
5
|
-
super(
|
|
4
|
+
super(message(payload));
|
|
6
5
|
this.payload = payload;
|
|
7
6
|
}
|
|
8
7
|
get errors() {
|
|
9
8
|
return this.payload.category === 'validation' ? this.payload.errors : [];
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
function message(payload) {
|
|
12
|
+
switch (payload.category) {
|
|
13
|
+
case 'validation':
|
|
14
|
+
return `BuilderException[validation: ${payload.errors.length}]`;
|
|
15
|
+
case 'invariant':
|
|
16
|
+
return 'BuilderException[invariant]';
|
|
17
|
+
case 'assertion':
|
|
18
|
+
return 'BuilderException[assertion]';
|
|
19
|
+
case 'request':
|
|
20
|
+
return `BuilderException[request: ${payload.status}]`;
|
|
16
21
|
}
|
|
17
|
-
const path = formatIssuePath(first);
|
|
18
|
-
const location = path ? ` at ${path}` : '';
|
|
19
|
-
const more = rest.length > 0 ? ` (+${rest.length} more)` : '';
|
|
20
|
-
return `${first.message}${location}${more}! ❌`;
|
|
21
|
-
}
|
|
22
|
-
const HEADER = 'BuilderBuilder error 🏗️';
|
|
23
|
-
function formatMessage(payload) {
|
|
24
|
-
if (payload.category === 'validation') {
|
|
25
|
-
return formatValidation(payload.errors);
|
|
26
|
-
}
|
|
27
|
-
if (payload.category === 'assertion') {
|
|
28
|
-
return `${HEADER} — ${payload.summary}`;
|
|
29
|
-
}
|
|
30
|
-
return formatRequest(payload);
|
|
31
|
-
}
|
|
32
|
-
function formatValidation(errors) {
|
|
33
|
-
if (errors.length === 0) {
|
|
34
|
-
return `${HEADER} — validation failed`;
|
|
35
|
-
}
|
|
36
|
-
const noun = errors.length === 1 ? 'issue' : 'issues';
|
|
37
|
-
const lines = errors.map((error) => ` • ${formatBuilderError(error)}`);
|
|
38
|
-
return `${HEADER} — ${errors.length} validation ${noun}:\n${lines.join('\n')}`;
|
|
39
|
-
}
|
|
40
|
-
function formatBuilderError(error) {
|
|
41
|
-
const { kind, location, ...rest } = error;
|
|
42
|
-
const locationLabel = location.length > 0 ? ` at ${location.join('.')}` : '';
|
|
43
|
-
const detailEntries = Object.entries(rest);
|
|
44
|
-
if (detailEntries.length === 0) {
|
|
45
|
-
return `${kind}${locationLabel}`;
|
|
46
|
-
}
|
|
47
|
-
const details = detailEntries.map(([key, value]) => `${key}=${formatValue(value)}`).join(', ');
|
|
48
|
-
return `${kind}${locationLabel}: ${details}`;
|
|
49
|
-
}
|
|
50
|
-
function formatRequest(payload) {
|
|
51
|
-
const { url, status, statusText, body } = payload;
|
|
52
|
-
const statusLine = statusText ? `${status} ${statusText}` : `${status}`;
|
|
53
|
-
return `${HEADER} — Builder API request failed: ${statusLine}\n url: ${url}\n body: ${body}`;
|
|
54
|
-
}
|
|
55
|
-
function formatIssuePath(issue) {
|
|
56
|
-
if (!issue.path) {
|
|
57
|
-
return '';
|
|
58
|
-
}
|
|
59
|
-
return issue.path.map((segment) => segment.key).join('.');
|
|
60
|
-
}
|
|
61
|
-
function formatValue(value) {
|
|
62
|
-
if (typeof value === 'string') {
|
|
63
|
-
return JSON.stringify(value);
|
|
64
|
-
}
|
|
65
|
-
if (value === null || value === undefined) {
|
|
66
|
-
return String(value);
|
|
67
|
-
}
|
|
68
|
-
if (typeof value === 'object') {
|
|
69
|
-
try {
|
|
70
|
-
return JSON.stringify(value);
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
return String(value);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return String(value);
|
|
77
22
|
}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type { BuilderExceptionPayload } from './exception.js';
|
|
1
|
+
export * from './public.js';
|
|
3
2
|
export { check } from './check.js';
|
|
4
|
-
export {
|
|
5
|
-
export { BuilderException } from './exception.js';
|
|
3
|
+
export { BuilderErrorsScope } from './errors.js';
|
package/dist/errors/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BuilderException } from './exception.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,36 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export type { BuilderComponentVariant, BuilderComponentVariants, BuilderInstance, BuilderInstanceInput, BuilderInstances, BuilderVariants } from './instance';
|
|
6
|
-
export type { BuilderOrder, BuilderRenderMetadata, BuilderRenderOption, BuilderRenderOptions, BuilderRenderPage, BuilderRenderPages, BuilderRenderResult, BuilderRenderUpdate } from './mappers/index';
|
|
7
|
-
export type { BuilderPrimitive, BuilderPrimitives } from './primitive';
|
|
8
|
-
export type { BuilderParameter, BuilderParameterSerialised, BuilderRef, Paramable, ParamableSerialised } from './references';
|
|
9
|
-
export type { BuilderErrorKind, BuilderInstanceValidationResult, BuilderModelValidationResult, BuilderPricingValidationResult, BuilderUIValidationResult, BuilderValidationResult, BuilderVariantsValidationOptions, BuilderVariantsValidationResult } from './validate/index';
|
|
10
|
-
import { collectionConfig, collectionExpectation, componentConfig, componentExpectation, optionExpectation, uis } from './entities/index.js';
|
|
11
|
-
export { bb } from './bb.js';
|
|
12
|
-
export { builder, detailBoolean, detailNumber, detailString, input, model, pricing, select, serialise, toggleBoolean, toggleNumber, toggleString } from './entities/index.js';
|
|
13
|
-
export { BuilderException } from './errors/index.js';
|
|
14
|
-
export { parameter, ref } from './references.js';
|
|
15
|
-
export { ordinal } from './mappers/index.js';
|
|
16
|
-
export declare const collection: typeof collectionConfig & {
|
|
17
|
-
enable: <const Values extends import("./references").Paramable<import(".").BuilderCollectionConfig<import("./references").Paramable<import("./entities/model").BuilderModelGeneric>, import("./references").Paramable<number>, import("./references").Paramable<number>>>>(values: Values) => import(".").BuilderEnableConfig<Values>;
|
|
18
|
-
match: <const MatchPayload extends import("./references").Paramable<import(".").BuilderCollectionConfig<import("./references").Paramable<import("./entities/model").BuilderModelGeneric>, import("./references").Paramable<number>, import("./references").Paramable<number>>>, const MatchPath extends import("./references").Paramable<import(".").BuilderPath>, const SelectMap extends import("./references").Paramable<import(".").BuilderMatchSelectMap<import("./references").Paramable<import(".").BuilderCollectionConfig<import("./references").Paramable<import("./entities/model").BuilderModelGeneric>, import("./references").Paramable<number>, import("./references").Paramable<number>>>>>>(matchPath: MatchPath, selectMap: SelectMap) => import(".").BuilderMatchConfig<MatchPayload, MatchPath, SelectMap>;
|
|
19
|
-
unless: <const Values extends import("./references").Paramable<import(".").BuilderCollectionConfig<import("./references").Paramable<import("./entities/model").BuilderModelGeneric>, import("./references").Paramable<number>, import("./references").Paramable<number>>>, const UnlessPath extends import("./references").Paramable<import(".").BuilderPath>>(unlessPath: UnlessPath, disabledValues: import("./primitive").BuilderPrimitives, values: Values) => import(".").BuilderUnlessConfig<Values, UnlessPath>;
|
|
20
|
-
};
|
|
21
|
-
export declare const component: typeof componentConfig & {
|
|
22
|
-
enable: <const Payload extends import("./references").Paramable<import(".").BuilderComponentConfig>>(payload?: Payload) => import(".").BuilderEnableConfig<Payload>;
|
|
23
|
-
match: <const Payload extends import("./references").Paramable<import(".").BuilderComponentConfig>, const MatchPath extends import("./references").Paramable<import(".").BuilderPath>, const SelectMap extends import("./references").Paramable<import(".").BuilderMatchSelectMap<import("./references").Paramable<import(".").BuilderComponentConfig>>>>(matchPath: MatchPath, selectMap: SelectMap) => import(".").BuilderMatchConfig<Payload, MatchPath, SelectMap>;
|
|
24
|
-
unless: <const UnlessPath extends import("./references").Paramable<import(".").BuilderPath>, const Payload extends import("./references").Paramable<import(".").BuilderComponentConfig>>(unlessPath: UnlessPath, disabledValues: import("./primitive").BuilderPrimitives, payload?: Payload) => import(".").BuilderUnlessConfig<Payload, UnlessPath>;
|
|
25
|
-
};
|
|
26
|
-
export declare const has: {
|
|
27
|
-
collection: typeof collectionExpectation;
|
|
28
|
-
component: typeof componentExpectation;
|
|
29
|
-
option: typeof optionExpectation;
|
|
30
|
-
};
|
|
31
|
-
export declare const option: {
|
|
32
|
-
enable: <const Values extends import("./references").Paramable<import(".").BuilderSelectConfig<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import(".").BuilderToggleConfig<import("valibot").GenericSchema<string | number | boolean | null>>>>(values: Values) => import(".").BuilderEnableConfig<Values>;
|
|
33
|
-
match: <const MatchPayload extends import("./references").Paramable<import(".").BuilderSelectConfig<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import(".").BuilderToggleConfig<import("valibot").GenericSchema<string | number | boolean | null>>>, const MatchPath extends import("./references").Paramable<import(".").BuilderPath>, const SelectMap extends import("./references").Paramable<import(".").BuilderMatchSelectMap<import("./references").Paramable<import(".").BuilderSelectConfig<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import(".").BuilderToggleConfig<import("valibot").GenericSchema<string | number | boolean | null>>>>>>(matchPath: MatchPath, selectMap: SelectMap) => import(".").BuilderMatchConfig<MatchPayload, MatchPath, SelectMap>;
|
|
34
|
-
unless: <const Values extends import("./references").Paramable<import(".").BuilderSelectConfig<readonly [string, ...string[]], import("valibot").GenericSchema<string | null>> | import(".").BuilderToggleConfig<import("valibot").GenericSchema<string | number | boolean | null>>>, const UnlessPath extends import("./references").Paramable<import(".").BuilderPath>>(unlessPath: UnlessPath, disabledValues: import("./primitive").BuilderPrimitives, values: Values) => import(".").BuilderUnlessConfig<Values, UnlessPath>;
|
|
35
|
-
};
|
|
36
|
-
export declare const ui: typeof uis;
|
|
1
|
+
export * from './public.js';
|
|
2
|
+
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';
|
|
3
|
+
export { BuilderEnvironmentSchema } from './environment.js';
|
|
4
|
+
export { BuilderComponentVariantsSchema, BuilderVariantsSchema } from './instance.js';
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { parameter, ref } from './references.js';
|
|
6
|
-
export { ordinal } from './mappers/index.js';
|
|
7
|
-
export const collection = Object.assign(collectionConfig, {
|
|
8
|
-
...collectionWhen
|
|
9
|
-
});
|
|
10
|
-
export const component = Object.assign(componentConfig, {
|
|
11
|
-
...componentWhen
|
|
12
|
-
});
|
|
13
|
-
export const has = {
|
|
14
|
-
collection: collectionExpectation,
|
|
15
|
-
component: componentExpectation,
|
|
16
|
-
option: optionExpectation
|
|
17
|
-
};
|
|
18
|
-
export const option = optionWhen;
|
|
19
|
-
export const ui = uis;
|
|
1
|
+
export * from './public.js';
|
|
2
|
+
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';
|
|
3
|
+
export { BuilderEnvironmentSchema } from './environment.js';
|
|
4
|
+
export { BuilderComponentVariantsSchema, BuilderVariantsSchema } from './instance.js';
|
package/dist/mappers/price.js
CHANGED
|
@@ -91,7 +91,7 @@ function reduceValues(values, mode) {
|
|
|
91
91
|
if (mode === 'sum') {
|
|
92
92
|
return values.reduce((accumulator, value) => accumulator + value, 0);
|
|
93
93
|
}
|
|
94
|
-
check.
|
|
94
|
+
check.invariant(values.length > 0);
|
|
95
95
|
const [first] = values;
|
|
96
96
|
return first;
|
|
97
97
|
}
|
|
@@ -30,7 +30,7 @@ export function render(builder, instance, references = []) {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
const itemInstances = currentInstance[item.name];
|
|
33
|
-
check.assert(BuilderInstancesSchema, itemInstances
|
|
33
|
+
check.assert(BuilderInstancesSchema, itemInstances);
|
|
34
34
|
const mergedItemModel = collection.model;
|
|
35
35
|
itemInstances.forEach((itemInstance, index) => {
|
|
36
36
|
walkItems(item.items, mergedItemModel, [...collectionPath, item.name, index], [...labelContext, `${ordinal(index)} ${composeLabel(item.label)}`], itemInstance);
|
|
@@ -52,8 +52,8 @@ export function render(builder, instance, references = []) {
|
|
|
52
52
|
option: found.payload,
|
|
53
53
|
value: found.value,
|
|
54
54
|
update: (updateInstance, updateValue) => createInstance(builder, setPath(updateInstance, fullPath, updateValue), references),
|
|
55
|
-
displayName: input.displayName && composeString(input.displayName
|
|
56
|
-
kind: input.kind && composeString(input.kind
|
|
55
|
+
displayName: input.displayName && composeString(input.displayName),
|
|
56
|
+
kind: input.kind && composeString(input.kind),
|
|
57
57
|
metadata: input.metadata && composeMetadata(input.metadata)
|
|
58
58
|
}
|
|
59
59
|
];
|
|
@@ -81,7 +81,7 @@ export function render(builder, instance, references = []) {
|
|
|
81
81
|
}
|
|
82
82
|
function composeLabel(label, labelContext = []) {
|
|
83
83
|
const resolved = resolveReference(label, references);
|
|
84
|
-
check.assert(v.string(), resolved
|
|
84
|
+
check.assert(v.string(), resolved);
|
|
85
85
|
if (labelContext.length === 0) {
|
|
86
86
|
return resolved;
|
|
87
87
|
}
|
|
@@ -90,14 +90,14 @@ export function render(builder, instance, references = []) {
|
|
|
90
90
|
}
|
|
91
91
|
return `${labelContext.join(', ')}, ${resolved}`;
|
|
92
92
|
}
|
|
93
|
-
function composeString(value
|
|
93
|
+
function composeString(value) {
|
|
94
94
|
const resolved = resolveReference(value, references);
|
|
95
|
-
check.assert(v.string(), resolved
|
|
95
|
+
check.assert(v.string(), resolved);
|
|
96
96
|
return resolved;
|
|
97
97
|
}
|
|
98
98
|
function composeMetadata(value) {
|
|
99
99
|
const resolved = resolveReference(value, references);
|
|
100
|
-
check.assert(BuilderRenderMetadataSchema, resolved
|
|
100
|
+
check.assert(BuilderRenderMetadataSchema, resolved);
|
|
101
101
|
return Object.fromEntries(Object.entries(resolved).map(([key, entry]) => [key, resolveReference(entry, references)]));
|
|
102
102
|
}
|
|
103
103
|
function findCollection(model, instance, collectionName) {
|