@squiz/dx-json-schema-lib 1.82.2 → 1.82.3
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/CHANGELOG.md +6 -2
- package/lib/JsonSchemaService.d.ts +4 -0
- package/lib/JsonSchemaService.js +46 -1
- package/lib/JsonSchemaService.js.map +1 -1
- package/lib/hasAllOfCombinator.spec.d.ts +1 -0
- package/lib/hasAllOfCombinator.spec.js +394 -0
- package/lib/hasAllOfCombinator.spec.js.map +1 -0
- package/package.json +3 -1
- package/src/JsonSchemaService.ts +44 -1
- package/src/hasAllOfCombinator.spec.ts +456 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.82.3
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 8f49dec: squiz link allof fix
|
8
|
+
|
3
9
|
## 1.82.2
|
4
10
|
|
5
11
|
### Patch Changes
|
@@ -173,7 +179,6 @@
|
|
173
179
|
- 985e1a5: ### Updates to DAM asset resolver package
|
174
180
|
|
175
181
|
**Changes:**
|
176
|
-
|
177
182
|
- Updated DAM resolver package versions.
|
178
183
|
- Updated Json validation schema so multiple resolvers can be used for SquizImage type.
|
179
184
|
- Updated higher order node map so Dam images could be resolved to simple url.
|
@@ -186,7 +191,6 @@
|
|
186
191
|
- 4d4c053: ### Updates to DAM asset resolver package
|
187
192
|
|
188
193
|
**Changes:**
|
189
|
-
|
190
194
|
- Updated DAM resolver package versions.
|
191
195
|
- Updated Json validation schema so multiple resolvers can be used for SquizImage type.
|
192
196
|
- Updated higher order node map so Dam images could be resolved to simple url.
|
@@ -17,6 +17,10 @@ export declare class JSONSchemaService<P extends AnyPrimitiveType, R extends Any
|
|
17
17
|
schema: Draft;
|
18
18
|
constructor(typeResolver: TypeResolver<P, R>, metaSchema: MetaSchemaInput);
|
19
19
|
private doResolveRef;
|
20
|
+
/**
|
21
|
+
* Recursively check if a schema contains allOf combinators that could cause mutation
|
22
|
+
*/
|
23
|
+
private hasAllOfCombinator;
|
20
24
|
/**
|
21
25
|
* Validate an input value against a specified schema
|
22
26
|
* @throws {SchemaValidationError} if the input is invalid
|
package/lib/JsonSchemaService.js
CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.JSONSchemaService = exports.JobV1MetaSchema = exports.ManifestV1MetaSchema = exports.RenderInputMetaSchema = exports.ComponentInputMetaSchema = void 0;
|
7
7
|
const json_query_1 = __importDefault(require("@sagold/json-query"));
|
8
|
+
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
|
8
9
|
const DxComponentInputSchema_json_1 = __importDefault(require("./manifest/v1/DxComponentInputSchema.json"));
|
9
10
|
const DxComponentIcons_json_1 = __importDefault(require("./manifest/v1/DxComponentIcons.json"));
|
10
11
|
const DxContentMetaSchema_json_1 = __importDefault(require("./manifest/v1/DxContentMetaSchema.json"));
|
@@ -90,6 +91,46 @@ class JSONSchemaService {
|
|
90
91
|
};
|
91
92
|
return this.schema.compileSchema(fullValidationSchema);
|
92
93
|
}
|
94
|
+
/**
|
95
|
+
* Recursively check if a schema contains allOf combinators that could cause mutation
|
96
|
+
*/
|
97
|
+
hasAllOfCombinator(schema, visited = new WeakSet()) {
|
98
|
+
var _a, _b;
|
99
|
+
if (!schema || typeof schema !== 'object')
|
100
|
+
return false;
|
101
|
+
// Prevent infinite recursion from circular references
|
102
|
+
if (visited.has(schema))
|
103
|
+
return false;
|
104
|
+
visited.add(schema);
|
105
|
+
// Direct allOf check
|
106
|
+
if (schema.allOf)
|
107
|
+
return true;
|
108
|
+
// Check in properties
|
109
|
+
if (schema.properties) {
|
110
|
+
for (const prop of Object.values(schema.properties)) {
|
111
|
+
if (this.hasAllOfCombinator(prop, visited))
|
112
|
+
return true;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
// Check in items (arrays)
|
116
|
+
if (schema.items && this.hasAllOfCombinator(schema.items, visited))
|
117
|
+
return true;
|
118
|
+
// Check in nested combinators
|
119
|
+
if ((_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.some((subSchema) => this.hasAllOfCombinator(subSchema, visited)))
|
120
|
+
return true;
|
121
|
+
if ((_b = schema.anyOf) === null || _b === void 0 ? void 0 : _b.some((subSchema) => this.hasAllOfCombinator(subSchema, visited)))
|
122
|
+
return true;
|
123
|
+
if (schema.not && this.hasAllOfCombinator(schema.not, visited))
|
124
|
+
return true;
|
125
|
+
// Check in conditional schemas (if/then/else)
|
126
|
+
if (schema.if && this.hasAllOfCombinator(schema.if, visited))
|
127
|
+
return true;
|
128
|
+
if (schema.then && this.hasAllOfCombinator(schema.then, visited))
|
129
|
+
return true;
|
130
|
+
if (schema.else && this.hasAllOfCombinator(schema.else, visited))
|
131
|
+
return true;
|
132
|
+
return false;
|
133
|
+
}
|
93
134
|
/**
|
94
135
|
* Validate an input value against a specified schema
|
95
136
|
* @throws {SchemaValidationError} if the input is invalid
|
@@ -97,7 +138,11 @@ class JSONSchemaService {
|
|
97
138
|
*/
|
98
139
|
validateInput(input, inputSchema = this.schema.rootSchema) {
|
99
140
|
inputSchema = this.schema.compileSchema(inputSchema);
|
100
|
-
|
141
|
+
// Only clone if schema contains allOf combinators that could cause mutation
|
142
|
+
// This optimizes performance by avoiding unnecessary cloning for simple schemas
|
143
|
+
const needsCloning = this.hasAllOfCombinator(inputSchema);
|
144
|
+
const inputToValidate = needsCloning ? (0, lodash_clonedeep_1.default)(input) : input;
|
145
|
+
const errors = this.schema.validate(inputToValidate, inputSchema);
|
101
146
|
return (0, processValidationResult_1.processValidationResult)(errors);
|
102
147
|
}
|
103
148
|
/**
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"JsonSchemaService.js","sourceRoot":"","sources":["../src/JsonSchemaService.ts"],"names":[],"mappings":";;;;;;AAAA,o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,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,yBAAyB,CAAC,MAAM,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,2CAA2C,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrG,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAtJD,8CAsJC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,394 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const JsonSchemaService_1 = require("./JsonSchemaService");
|
4
|
+
const JsonSchemaService_2 = require("./JsonSchemaService");
|
5
|
+
const TypeResolverBuilder_1 = require("./jsonTypeResolution/TypeResolverBuilder");
|
6
|
+
describe('JSONSchemaService - hasAllOfCombinator', () => {
|
7
|
+
let jsonSchemaService;
|
8
|
+
beforeAll(() => {
|
9
|
+
const typeResolverBuilder = new TypeResolverBuilder_1.TypeResolverBuilder();
|
10
|
+
const typeResolver = typeResolverBuilder.build();
|
11
|
+
jsonSchemaService = new JsonSchemaService_1.JSONSchemaService(typeResolver, JsonSchemaService_2.ComponentInputMetaSchema);
|
12
|
+
});
|
13
|
+
// Helper to access private method
|
14
|
+
const hasAllOfCombinator = (schema) => jsonSchemaService.hasAllOfCombinator(schema);
|
15
|
+
describe('Direct allOf detection', () => {
|
16
|
+
it('should detect direct allOf usage', () => {
|
17
|
+
const schema = {
|
18
|
+
type: 'object',
|
19
|
+
allOf: [{ properties: { name: { type: 'string' } } }, { properties: { age: { type: 'number' } } }],
|
20
|
+
};
|
21
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
22
|
+
});
|
23
|
+
it('should detect empty allOf array', () => {
|
24
|
+
const schema = {
|
25
|
+
type: 'object',
|
26
|
+
allOf: [],
|
27
|
+
};
|
28
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
29
|
+
});
|
30
|
+
});
|
31
|
+
describe('Nested allOf detection', () => {
|
32
|
+
it('should detect allOf in properties', () => {
|
33
|
+
const schema = {
|
34
|
+
type: 'object',
|
35
|
+
properties: {
|
36
|
+
user: {
|
37
|
+
allOf: [{ properties: { name: { type: 'string' } } }, { properties: { email: { type: 'string' } } }],
|
38
|
+
},
|
39
|
+
},
|
40
|
+
};
|
41
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
42
|
+
});
|
43
|
+
it('should detect allOf in deeply nested properties', () => {
|
44
|
+
const schema = {
|
45
|
+
type: 'object',
|
46
|
+
properties: {
|
47
|
+
componentContent: {
|
48
|
+
type: 'object',
|
49
|
+
properties: {
|
50
|
+
heroSection: {
|
51
|
+
allOf: [
|
52
|
+
{ properties: { title: { type: 'string' } } },
|
53
|
+
{ properties: { subtitle: { type: 'string' } } },
|
54
|
+
],
|
55
|
+
},
|
56
|
+
},
|
57
|
+
},
|
58
|
+
},
|
59
|
+
};
|
60
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
61
|
+
});
|
62
|
+
it('should detect allOf in array items', () => {
|
63
|
+
const schema = {
|
64
|
+
type: 'object',
|
65
|
+
properties: {
|
66
|
+
items: {
|
67
|
+
type: 'array',
|
68
|
+
items: {
|
69
|
+
allOf: [{ properties: { id: { type: 'number' } } }, { properties: { name: { type: 'string' } } }],
|
70
|
+
},
|
71
|
+
},
|
72
|
+
},
|
73
|
+
};
|
74
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
75
|
+
});
|
76
|
+
});
|
77
|
+
describe('Combinator traversal', () => {
|
78
|
+
it('should detect allOf within oneOf', () => {
|
79
|
+
const schema = {
|
80
|
+
type: 'object',
|
81
|
+
oneOf: [
|
82
|
+
{
|
83
|
+
allOf: [{ properties: { type: { const: 'A' } } }, { properties: { valueA: { type: 'string' } } }],
|
84
|
+
},
|
85
|
+
{ properties: { type: { const: 'B' } } },
|
86
|
+
],
|
87
|
+
};
|
88
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
89
|
+
});
|
90
|
+
it('should detect allOf within anyOf', () => {
|
91
|
+
const schema = {
|
92
|
+
type: 'object',
|
93
|
+
anyOf: [
|
94
|
+
{ properties: { simple: { type: 'string' } } },
|
95
|
+
{
|
96
|
+
allOf: [{ properties: { complex: { type: 'object' } } }, { properties: { nested: { type: 'array' } } }],
|
97
|
+
},
|
98
|
+
],
|
99
|
+
};
|
100
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
101
|
+
});
|
102
|
+
it('should detect allOf within not schema', () => {
|
103
|
+
const schema = {
|
104
|
+
type: 'object',
|
105
|
+
not: {
|
106
|
+
allOf: [{ properties: { forbidden: { type: 'string' } } }, { properties: { invalid: { type: 'number' } } }],
|
107
|
+
},
|
108
|
+
};
|
109
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
110
|
+
});
|
111
|
+
});
|
112
|
+
describe('Conditional schema detection', () => {
|
113
|
+
it('should detect allOf in if condition', () => {
|
114
|
+
const schema = {
|
115
|
+
type: 'object',
|
116
|
+
if: {
|
117
|
+
allOf: [{ properties: { type: { const: 'special' } } }, { properties: { mode: { const: 'advanced' } } }],
|
118
|
+
},
|
119
|
+
then: { properties: { specialValue: { type: 'string' } } },
|
120
|
+
};
|
121
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
122
|
+
});
|
123
|
+
it('should detect allOf in then branch', () => {
|
124
|
+
const schema = {
|
125
|
+
type: 'object',
|
126
|
+
if: { properties: { type: { const: 'special' } } },
|
127
|
+
then: {
|
128
|
+
allOf: [{ properties: { requiredProp: { type: 'string' } } }, { required: ['requiredProp'] }],
|
129
|
+
},
|
130
|
+
};
|
131
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
132
|
+
});
|
133
|
+
it('should detect allOf in else branch', () => {
|
134
|
+
const schema = {
|
135
|
+
type: 'object',
|
136
|
+
if: { properties: { type: { const: 'simple' } } },
|
137
|
+
then: { properties: { simpleValue: { type: 'string' } } },
|
138
|
+
else: {
|
139
|
+
allOf: [
|
140
|
+
{ properties: { complexValue: { type: 'object' } } },
|
141
|
+
{ properties: { metadata: { type: 'object' } } },
|
142
|
+
],
|
143
|
+
},
|
144
|
+
};
|
145
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
146
|
+
});
|
147
|
+
});
|
148
|
+
describe('Complex nested scenarios', () => {
|
149
|
+
it('should detect allOf in Hero Banner-like schema', () => {
|
150
|
+
const heroBannerSchema = {
|
151
|
+
type: 'object',
|
152
|
+
properties: {
|
153
|
+
componentContent: {
|
154
|
+
allOf: [
|
155
|
+
{
|
156
|
+
if: { properties: { heroType: { const: 'Supporting content' } } },
|
157
|
+
then: {
|
158
|
+
type: 'object',
|
159
|
+
properties: {
|
160
|
+
heroType: { type: 'string' },
|
161
|
+
heading: { type: 'string' },
|
162
|
+
content: { type: 'string' },
|
163
|
+
links: {
|
164
|
+
type: 'array',
|
165
|
+
items: {
|
166
|
+
type: 'object',
|
167
|
+
properties: {
|
168
|
+
text: { type: 'string' },
|
169
|
+
url: { type: 'string' },
|
170
|
+
target: { type: 'string' },
|
171
|
+
},
|
172
|
+
},
|
173
|
+
},
|
174
|
+
},
|
175
|
+
},
|
176
|
+
},
|
177
|
+
{
|
178
|
+
if: { properties: { heroType: { const: 'Supporting image' } } },
|
179
|
+
then: {
|
180
|
+
properties: {
|
181
|
+
image: { type: 'object' },
|
182
|
+
},
|
183
|
+
},
|
184
|
+
},
|
185
|
+
],
|
186
|
+
},
|
187
|
+
},
|
188
|
+
};
|
189
|
+
expect(hasAllOfCombinator(heroBannerSchema)).toBe(true);
|
190
|
+
});
|
191
|
+
it('should detect allOf in very deeply nested structure', () => {
|
192
|
+
const deepSchema = {
|
193
|
+
type: 'object',
|
194
|
+
properties: {
|
195
|
+
level1: {
|
196
|
+
properties: {
|
197
|
+
level2: {
|
198
|
+
oneOf: [
|
199
|
+
{
|
200
|
+
properties: {
|
201
|
+
level3: {
|
202
|
+
anyOf: [
|
203
|
+
{
|
204
|
+
allOf: [{ properties: { deep: { type: 'string' } } }],
|
205
|
+
},
|
206
|
+
],
|
207
|
+
},
|
208
|
+
},
|
209
|
+
},
|
210
|
+
],
|
211
|
+
},
|
212
|
+
},
|
213
|
+
},
|
214
|
+
},
|
215
|
+
};
|
216
|
+
expect(hasAllOfCombinator(deepSchema)).toBe(true);
|
217
|
+
});
|
218
|
+
});
|
219
|
+
describe('Negative cases - should return false', () => {
|
220
|
+
it('should return false for simple object schema', () => {
|
221
|
+
const schema = {
|
222
|
+
type: 'object',
|
223
|
+
properties: {
|
224
|
+
name: { type: 'string' },
|
225
|
+
age: { type: 'number' },
|
226
|
+
},
|
227
|
+
required: ['name'],
|
228
|
+
};
|
229
|
+
expect(hasAllOfCombinator(schema)).toBe(false);
|
230
|
+
});
|
231
|
+
it('should return false for schema with only oneOf', () => {
|
232
|
+
const schema = {
|
233
|
+
type: 'object',
|
234
|
+
oneOf: [{ properties: { typeA: { type: 'string' } } }, { properties: { typeB: { type: 'number' } } }],
|
235
|
+
};
|
236
|
+
expect(hasAllOfCombinator(schema)).toBe(false);
|
237
|
+
});
|
238
|
+
it('should return false for schema with only anyOf', () => {
|
239
|
+
const schema = {
|
240
|
+
type: 'object',
|
241
|
+
anyOf: [{ properties: { option1: { type: 'string' } } }, { properties: { option2: { type: 'boolean' } } }],
|
242
|
+
};
|
243
|
+
expect(hasAllOfCombinator(schema)).toBe(false);
|
244
|
+
});
|
245
|
+
it('should return false for array schema without allOf', () => {
|
246
|
+
const schema = {
|
247
|
+
type: 'array',
|
248
|
+
items: {
|
249
|
+
type: 'object',
|
250
|
+
properties: {
|
251
|
+
id: { type: 'number' },
|
252
|
+
name: { type: 'string' },
|
253
|
+
},
|
254
|
+
},
|
255
|
+
};
|
256
|
+
expect(hasAllOfCombinator(schema)).toBe(false);
|
257
|
+
});
|
258
|
+
it('should return false for conditional schema without allOf', () => {
|
259
|
+
const schema = {
|
260
|
+
type: 'object',
|
261
|
+
if: { properties: { type: { const: 'special' } } },
|
262
|
+
then: { properties: { specialValue: { type: 'string' } } },
|
263
|
+
else: { properties: { normalValue: { type: 'string' } } },
|
264
|
+
};
|
265
|
+
expect(hasAllOfCombinator(schema)).toBe(false);
|
266
|
+
});
|
267
|
+
});
|
268
|
+
describe('Edge cases', () => {
|
269
|
+
it('should return false for null', () => {
|
270
|
+
expect(hasAllOfCombinator(null)).toBe(false);
|
271
|
+
});
|
272
|
+
it('should return false for undefined', () => {
|
273
|
+
expect(hasAllOfCombinator(undefined)).toBe(false);
|
274
|
+
});
|
275
|
+
it('should return false for string', () => {
|
276
|
+
expect(hasAllOfCombinator('not an object')).toBe(false);
|
277
|
+
});
|
278
|
+
it('should return false for number', () => {
|
279
|
+
expect(hasAllOfCombinator(42)).toBe(false);
|
280
|
+
});
|
281
|
+
it('should return false for boolean', () => {
|
282
|
+
expect(hasAllOfCombinator(true)).toBe(false);
|
283
|
+
});
|
284
|
+
it('should return false for array', () => {
|
285
|
+
expect(hasAllOfCombinator(['not', 'a', 'schema'])).toBe(false);
|
286
|
+
});
|
287
|
+
it('should return false for empty object', () => {
|
288
|
+
expect(hasAllOfCombinator({})).toBe(false);
|
289
|
+
});
|
290
|
+
it('should handle circular references gracefully', () => {
|
291
|
+
const schema = {
|
292
|
+
type: 'object',
|
293
|
+
properties: {
|
294
|
+
self: null,
|
295
|
+
},
|
296
|
+
};
|
297
|
+
schema.properties.self = schema; // Create circular reference
|
298
|
+
// Should not crash and should return false (no allOf)
|
299
|
+
expect(hasAllOfCombinator(schema)).toBe(false);
|
300
|
+
});
|
301
|
+
it('should handle circular references with allOf', () => {
|
302
|
+
const schema = {
|
303
|
+
type: 'object',
|
304
|
+
allOf: [{ properties: { name: { type: 'string' } } }],
|
305
|
+
properties: {
|
306
|
+
self: null,
|
307
|
+
},
|
308
|
+
};
|
309
|
+
schema.properties.self = schema; // Create circular reference
|
310
|
+
// Should detect allOf despite circular reference
|
311
|
+
expect(hasAllOfCombinator(schema)).toBe(true);
|
312
|
+
});
|
313
|
+
it('should handle deeply circular references', () => {
|
314
|
+
const schemaA = {
|
315
|
+
type: 'object',
|
316
|
+
properties: {
|
317
|
+
b: null,
|
318
|
+
},
|
319
|
+
};
|
320
|
+
const schemaB = {
|
321
|
+
type: 'object',
|
322
|
+
properties: {
|
323
|
+
a: schemaA,
|
324
|
+
c: null,
|
325
|
+
},
|
326
|
+
};
|
327
|
+
const schemaC = {
|
328
|
+
type: 'object',
|
329
|
+
properties: {
|
330
|
+
b: schemaB,
|
331
|
+
},
|
332
|
+
};
|
333
|
+
// Create circular chain: A -> B -> C -> B
|
334
|
+
schemaA.properties.b = schemaB;
|
335
|
+
schemaB.properties.c = schemaC;
|
336
|
+
// Should not crash and should return false (no allOf in any of them)
|
337
|
+
expect(hasAllOfCombinator(schemaA)).toBe(false);
|
338
|
+
expect(hasAllOfCombinator(schemaB)).toBe(false);
|
339
|
+
expect(hasAllOfCombinator(schemaC)).toBe(false);
|
340
|
+
});
|
341
|
+
it('should handle malformed properties object', () => {
|
342
|
+
const schema = {
|
343
|
+
type: 'object',
|
344
|
+
properties: null, // Malformed properties
|
345
|
+
};
|
346
|
+
expect(hasAllOfCombinator(schema)).toBe(false);
|
347
|
+
});
|
348
|
+
});
|
349
|
+
describe('Performance characteristics', () => {
|
350
|
+
it('should quickly process large schema without allOf', () => {
|
351
|
+
const largeSchema = {
|
352
|
+
type: 'object',
|
353
|
+
properties: {},
|
354
|
+
};
|
355
|
+
// Generate 100 properties
|
356
|
+
for (let i = 0; i < 100; i++) {
|
357
|
+
largeSchema.properties[`prop${i}`] = {
|
358
|
+
type: 'object',
|
359
|
+
properties: {
|
360
|
+
[`nested${i}`]: { type: 'string' },
|
361
|
+
[`array${i}`]: {
|
362
|
+
type: 'array',
|
363
|
+
items: { type: 'number' },
|
364
|
+
},
|
365
|
+
},
|
366
|
+
};
|
367
|
+
}
|
368
|
+
const startTime = performance.now();
|
369
|
+
const result = hasAllOfCombinator(largeSchema);
|
370
|
+
const endTime = performance.now();
|
371
|
+
expect(result).toBe(false);
|
372
|
+
expect(endTime - startTime).toBeLessThan(10); // Should be very fast (< 10ms)
|
373
|
+
});
|
374
|
+
it('should quickly detect allOf in large schema', () => {
|
375
|
+
const largeSchemaWithAllOf = {
|
376
|
+
type: 'object',
|
377
|
+
allOf: [{ properties: { detected: { type: 'string' } } }],
|
378
|
+
properties: {},
|
379
|
+
};
|
380
|
+
// Generate 100 properties
|
381
|
+
for (let i = 0; i < 100; i++) {
|
382
|
+
largeSchemaWithAllOf.properties[`prop${i}`] = {
|
383
|
+
type: 'string',
|
384
|
+
};
|
385
|
+
}
|
386
|
+
const startTime = performance.now();
|
387
|
+
const result = hasAllOfCombinator(largeSchemaWithAllOf);
|
388
|
+
const endTime = performance.now();
|
389
|
+
expect(result).toBe(true);
|
390
|
+
expect(endTime - startTime).toBeLessThan(5); // Should be very fast due to early detection
|
391
|
+
});
|
392
|
+
});
|
393
|
+
});
|
394
|
+
//# sourceMappingURL=hasAllOfCombinator.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"hasAllOfCombinator.spec.js","sourceRoot":"","sources":["../src/hasAllOfCombinator.spec.ts"],"names":[],"mappings":";;AAAA,2DAAwD;AACxD,2DAA+D;AAC/D,kFAA+E;AAE/E,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACtD,IAAI,iBAA8C,CAAC;IAEnD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,mBAAmB,GAAG,IAAI,yCAAmB,EAAE,CAAC;QACtD,MAAM,YAAY,GAAG,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACjD,iBAAiB,GAAG,IAAI,qCAAiB,CAAC,YAAY,EAAE,4CAAwB,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;IAEH,kCAAkC;IAClC,MAAM,kBAAkB,GAAG,CAAC,MAAW,EAAE,EAAE,CAAE,iBAAyB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAElG,QAAQ,CAAC,wBAAwB,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,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;YACrD,MAAM,oBAAoB,GAAG;gBAC3B,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;gBACzD,UAAU,EAAE,EAAE;aACf,CAAC;YAEF,0BAA0B;YAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC5B,oBAAoB,CAAC,UAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG;oBACrD,IAAI,EAAE,QAAQ;iBACf,CAAC;YACJ,CAAC;YAED,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;YACxD,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;YAElC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,6CAA6C;QAC5F,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@squiz/dx-json-schema-lib",
|
3
|
-
"version": "1.82.
|
3
|
+
"version": "1.82.3",
|
4
4
|
"description": "",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"private": false,
|
@@ -18,6 +18,7 @@
|
|
18
18
|
"license": "ISC",
|
19
19
|
"devDependencies": {
|
20
20
|
"@types/jest": "28.1.8",
|
21
|
+
"@types/lodash.clonedeep": "4.5.9",
|
21
22
|
"@types/node": "20.12.12",
|
22
23
|
"dotenv": "16.0.3",
|
23
24
|
"jest": "29.4.1",
|
@@ -30,6 +31,7 @@
|
|
30
31
|
"@sagold/json-query": "^6.2.0",
|
31
32
|
"@squiz/json-schema-library": "^7.4.7",
|
32
33
|
"@types/exif": "^0.6.5",
|
34
|
+
"lodash.clonedeep": "4.5.0",
|
33
35
|
"ts-brand": "0.0.2"
|
34
36
|
}
|
35
37
|
}
|
package/src/JsonSchemaService.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import JSONQuery, { Input } from '@sagold/json-query';
|
2
|
+
import cloneDeep from 'lodash.clonedeep';
|
2
3
|
|
3
4
|
import DxComponentInputSchema from './manifest/v1/DxComponentInputSchema.json';
|
4
5
|
import DxComponentIcons from './manifest/v1/DxComponentIcons.json';
|
@@ -103,6 +104,42 @@ export class JSONSchemaService<P extends AnyPrimitiveType, R extends AnyResolvab
|
|
103
104
|
return this.schema.compileSchema(fullValidationSchema);
|
104
105
|
}
|
105
106
|
|
107
|
+
/**
|
108
|
+
* Recursively check if a schema contains allOf combinators that could cause mutation
|
109
|
+
*/
|
110
|
+
private hasAllOfCombinator(schema: any, visited: WeakSet<object> = new WeakSet()): boolean {
|
111
|
+
if (!schema || typeof schema !== 'object') return false;
|
112
|
+
|
113
|
+
// Prevent infinite recursion from circular references
|
114
|
+
if (visited.has(schema)) return false;
|
115
|
+
visited.add(schema);
|
116
|
+
|
117
|
+
// Direct allOf check
|
118
|
+
if (schema.allOf) return true;
|
119
|
+
|
120
|
+
// Check in properties
|
121
|
+
if (schema.properties) {
|
122
|
+
for (const prop of Object.values(schema.properties)) {
|
123
|
+
if (this.hasAllOfCombinator(prop, visited)) return true;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
// Check in items (arrays)
|
128
|
+
if (schema.items && this.hasAllOfCombinator(schema.items, visited)) return true;
|
129
|
+
|
130
|
+
// Check in nested combinators
|
131
|
+
if (schema.oneOf?.some((subSchema: any) => this.hasAllOfCombinator(subSchema, visited))) return true;
|
132
|
+
if (schema.anyOf?.some((subSchema: any) => this.hasAllOfCombinator(subSchema, visited))) return true;
|
133
|
+
if (schema.not && this.hasAllOfCombinator(schema.not, visited)) return true;
|
134
|
+
|
135
|
+
// Check in conditional schemas (if/then/else)
|
136
|
+
if (schema.if && this.hasAllOfCombinator(schema.if, visited)) return true;
|
137
|
+
if (schema.then && this.hasAllOfCombinator(schema.then, visited)) return true;
|
138
|
+
if (schema.else && this.hasAllOfCombinator(schema.else, visited)) return true;
|
139
|
+
|
140
|
+
return false;
|
141
|
+
}
|
142
|
+
|
106
143
|
/**
|
107
144
|
* Validate an input value against a specified schema
|
108
145
|
* @throws {SchemaValidationError} if the input is invalid
|
@@ -110,7 +147,13 @@ export class JSONSchemaService<P extends AnyPrimitiveType, R extends AnyResolvab
|
|
110
147
|
*/
|
111
148
|
public validateInput(input: unknown, inputSchema: JSONSchema = this.schema.rootSchema): true | never {
|
112
149
|
inputSchema = this.schema.compileSchema(inputSchema);
|
113
|
-
|
150
|
+
|
151
|
+
// Only clone if schema contains allOf combinators that could cause mutation
|
152
|
+
// This optimizes performance by avoiding unnecessary cloning for simple schemas
|
153
|
+
const needsCloning = this.hasAllOfCombinator(inputSchema);
|
154
|
+
const inputToValidate = needsCloning ? cloneDeep(input) : input;
|
155
|
+
|
156
|
+
const errors = this.schema.validate(inputToValidate, inputSchema);
|
114
157
|
return processValidationResult(errors);
|
115
158
|
}
|
116
159
|
|