@builder-builder/builder 0.0.16 → 0.0.18
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/validate/brand.js +3 -12
- package/dist/validate/ui.js +5 -6
- package/package.json +1 -1
package/dist/validate/brand.js
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import { BuilderException } from '../exception.js';
|
|
2
2
|
import { BuilderValidateErrors } from './errors.js';
|
|
3
|
-
const
|
|
3
|
+
const VALIDATED_ENTITIES = new WeakSet();
|
|
4
4
|
export function validate(value) {
|
|
5
|
-
|
|
6
|
-
// rejects any property that isn't writable, configurable, and enumerable.
|
|
7
|
-
// Symbol keys are skipped by `JSON.stringify` regardless of enumerability,
|
|
8
|
-
// so the brand never leaks through a serialise round-trip.
|
|
9
|
-
Object.defineProperty(value, VALIDATED, {
|
|
10
|
-
value: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
enumerable: true,
|
|
13
|
-
configurable: true
|
|
14
|
-
});
|
|
5
|
+
VALIDATED_ENTITIES.add(value);
|
|
15
6
|
return value;
|
|
16
7
|
}
|
|
17
8
|
export function assertValidated(value) {
|
|
18
|
-
if (typeof value !== 'object' || value === null || !(
|
|
9
|
+
if (typeof value !== 'object' || value === null || !VALIDATED_ENTITIES.has(value)) {
|
|
19
10
|
const errors = new BuilderValidateErrors();
|
|
20
11
|
errors.unvalidated(value);
|
|
21
12
|
throw new BuilderException(errors.errors);
|
package/dist/validate/ui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { check } from '../check.js';
|
|
2
|
-
import { BuilderModelSerialisedSchema, BuilderUIInputMetadataSchema, BuilderUISerialisedSchema, serialise, uis } from '../entities/index.js';
|
|
2
|
+
import { BuilderModelSerialisedSchema, BuilderUIInputMetadataSchema, BuilderUISerialisedSchema, modelsMerge, serialise, uis } from '../entities/index.js';
|
|
3
3
|
import { validate } from './brand.js';
|
|
4
4
|
import { BuilderValidateErrors } from './errors.js';
|
|
5
5
|
import { checkExpectations } from './expectations.js';
|
|
@@ -119,11 +119,10 @@ export function checkUIExpectations(mergedModel, ui, errors) {
|
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
const innerModels = collectionConfigs(collection).flatMap(({ model: configModel }) => check.is(BuilderModelSerialisedSchema, configModel) ? [configModel] : []);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
errors.scope('items', () => walkItems(firstInnerModel, pages.items));
|
|
122
|
+
innerModels.forEach((innerModel) => {
|
|
123
|
+
const mergedInnerModel = modelsMerge(innerModel);
|
|
124
|
+
errors.scope('items', () => walkItems(mergedInnerModel, pages.items));
|
|
125
|
+
});
|
|
127
126
|
}
|
|
128
127
|
function walkInput(model, input) {
|
|
129
128
|
const path = input.path;
|