@jsonforms/core 3.6.0 → 3.7.0-alpha.0
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/lib/jsonforms-core.cjs.js +133 -76
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +78 -21
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/util/resolvers.d.ts +2 -2
- package/package.json +2 -3
- package/src/util/resolvers.ts +161 -44
|
@@ -279,59 +279,6 @@ var labelDescription = function (text, show) { return ({
|
|
|
279
279
|
show: show,
|
|
280
280
|
}); };
|
|
281
281
|
|
|
282
|
-
/******************************************************************************
|
|
283
|
-
Copyright (c) Microsoft Corporation.
|
|
284
|
-
|
|
285
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
286
|
-
purpose with or without fee is hereby granted.
|
|
287
|
-
|
|
288
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
289
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
290
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
291
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
292
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
293
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
294
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
295
|
-
***************************************************************************** */
|
|
296
|
-
|
|
297
|
-
var __assign = function() {
|
|
298
|
-
__assign = Object.assign || function __assign(t) {
|
|
299
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
300
|
-
s = arguments[i];
|
|
301
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
302
|
-
}
|
|
303
|
-
return t;
|
|
304
|
-
};
|
|
305
|
-
return __assign.apply(this, arguments);
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
function __rest(s, e) {
|
|
309
|
-
var t = {};
|
|
310
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
311
|
-
t[p] = s[p];
|
|
312
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
313
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
314
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
315
|
-
t[p[i]] = s[p[i]];
|
|
316
|
-
}
|
|
317
|
-
return t;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function __spreadArray(to, from, pack) {
|
|
321
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
322
|
-
if (ar || !(i in from)) {
|
|
323
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
324
|
-
ar[i] = from[i];
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
331
|
-
var e = new Error(message);
|
|
332
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
282
|
var isObjectSchema$1 = function (schema) {
|
|
336
283
|
return schema.properties !== undefined;
|
|
337
284
|
};
|
|
@@ -383,43 +330,100 @@ var invalidSegment = function (pathSegment) {
|
|
|
383
330
|
return pathSegment === '#' || pathSegment === undefined || pathSegment === '';
|
|
384
331
|
};
|
|
385
332
|
var resolveSchema = function (schema, schemaPath, rootSchema) {
|
|
386
|
-
var
|
|
387
|
-
|
|
333
|
+
var result = doResolveSchema(schema, schemaPath, {
|
|
334
|
+
rootSchema: rootSchema,
|
|
335
|
+
resolutionMap: new Map(),
|
|
336
|
+
});
|
|
337
|
+
return result;
|
|
388
338
|
};
|
|
389
|
-
var
|
|
390
|
-
var
|
|
391
|
-
if (
|
|
392
|
-
|
|
339
|
+
var doResolveSchema = function (schema, schemaPath, ctx) {
|
|
340
|
+
var resolvedSchema = undefined;
|
|
341
|
+
if (schema && typeof schema.$ref === 'string') {
|
|
342
|
+
var baseSchema = resolvePath(ctx.rootSchema, schema.$ref, ctx);
|
|
343
|
+
if (baseSchema !== undefined) {
|
|
344
|
+
resolvedSchema = resolvePath(baseSchema, schemaPath, ctx);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (resolvedSchema === undefined) {
|
|
348
|
+
resolvedSchema = resolvePath(schema, schemaPath, ctx);
|
|
349
|
+
}
|
|
350
|
+
return resolvedSchema;
|
|
351
|
+
};
|
|
352
|
+
var resolvePath = function (schema, schemaPath, ctx) {
|
|
353
|
+
var visitedPaths = ctx.resolutionMap.get(schema);
|
|
354
|
+
if (!visitedPaths) {
|
|
355
|
+
visitedPaths = new Set();
|
|
356
|
+
ctx.resolutionMap.set(schema, visitedPaths);
|
|
357
|
+
}
|
|
358
|
+
if (visitedPaths.has(schemaPath)) {
|
|
359
|
+
return undefined;
|
|
393
360
|
}
|
|
361
|
+
visitedPaths.add(schemaPath);
|
|
362
|
+
var resolvedSchema = resolvePathSegmentsWithCombinatorFallback(schema, schemaPath === null || schemaPath === void 0 ? void 0 : schemaPath.split('/').map(decode), ctx);
|
|
363
|
+
visitedPaths.delete(schemaPath);
|
|
364
|
+
return resolvedSchema;
|
|
365
|
+
};
|
|
366
|
+
var resolvePathSegmentsWithCombinatorFallback = function (schema, pathSegments, ctx) {
|
|
367
|
+
var _a, _b, _c, _d, _e;
|
|
394
368
|
if (!pathSegments || pathSegments.length === 0) {
|
|
395
369
|
return schema;
|
|
396
370
|
}
|
|
397
371
|
if (isEmpty__default["default"](schema)) {
|
|
398
372
|
return undefined;
|
|
399
373
|
}
|
|
400
|
-
var
|
|
401
|
-
if (
|
|
402
|
-
return resolveSchemaWithSegments(schema, remainingSegments, rootSchema);
|
|
403
|
-
}
|
|
404
|
-
var singleSegmentResolveSchema = get__default["default"](schema, segment);
|
|
405
|
-
var resolvedSchema = resolveSchemaWithSegments(singleSegmentResolveSchema, remainingSegments, rootSchema);
|
|
406
|
-
if (resolvedSchema) {
|
|
374
|
+
var resolvedSchema = resolvePathSegments(schema, pathSegments, ctx);
|
|
375
|
+
if (resolvedSchema !== undefined) {
|
|
407
376
|
return resolvedSchema;
|
|
408
377
|
}
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
var
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
378
|
+
var subSchemas = [].concat((_a = schema.oneOf) !== null && _a !== void 0 ? _a : [], (_b = schema.allOf) !== null && _b !== void 0 ? _b : [], (_c = schema.anyOf) !== null && _c !== void 0 ? _c : [], (_d = schema.then) !== null && _d !== void 0 ? _d : [], (_e = schema.else) !== null && _e !== void 0 ? _e : []);
|
|
379
|
+
for (var _i = 0, subSchemas_1 = subSchemas; _i < subSchemas_1.length; _i++) {
|
|
380
|
+
var subSchema = subSchemas_1[_i];
|
|
381
|
+
var resolvedSubSchema = subSchema;
|
|
382
|
+
if (subSchema && typeof subSchema.$ref === 'string') {
|
|
383
|
+
resolvedSubSchema = doResolveSchema(ctx.rootSchema, subSchema.$ref, ctx);
|
|
384
|
+
}
|
|
385
|
+
var alternativeResolveResult = resolvePathSegmentsWithCombinatorFallback(resolvedSubSchema, pathSegments, ctx);
|
|
386
|
+
if (alternativeResolveResult) {
|
|
387
|
+
return alternativeResolveResult;
|
|
418
388
|
}
|
|
419
|
-
return alternativeResolveResult;
|
|
420
389
|
}
|
|
421
390
|
return undefined;
|
|
422
391
|
};
|
|
392
|
+
var resolvePathSegments = function (schema, pathSegments, ctx) {
|
|
393
|
+
if (!pathSegments || pathSegments.length === 0) {
|
|
394
|
+
return schema;
|
|
395
|
+
}
|
|
396
|
+
if (isEmpty__default["default"](schema)) {
|
|
397
|
+
return undefined;
|
|
398
|
+
}
|
|
399
|
+
var singleStepResult = resolveSingleStep(schema, pathSegments);
|
|
400
|
+
if (singleStepResult.schema &&
|
|
401
|
+
typeof singleStepResult.schema.$ref === 'string') {
|
|
402
|
+
singleStepResult.schema = doResolveSchema(ctx.rootSchema, singleStepResult.schema.$ref, ctx);
|
|
403
|
+
}
|
|
404
|
+
return resolvePathSegmentsWithCombinatorFallback(singleStepResult.schema, singleStepResult.remainingPathSegments, ctx);
|
|
405
|
+
};
|
|
406
|
+
var resolveSingleStep = function (schema, pathSegments) {
|
|
407
|
+
if (!pathSegments || pathSegments.length === 0) {
|
|
408
|
+
return { schema: schema, remainingPathSegments: [] };
|
|
409
|
+
}
|
|
410
|
+
if (isEmpty__default["default"](schema)) {
|
|
411
|
+
return {
|
|
412
|
+
schema: undefined,
|
|
413
|
+
remainingPathSegments: pathSegments,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
var segment = pathSegments[0], remainingPathSegments = pathSegments.slice(1);
|
|
417
|
+
if (invalidSegment(segment)) {
|
|
418
|
+
return resolveSingleStep(schema, remainingPathSegments);
|
|
419
|
+
}
|
|
420
|
+
var singleSegmentResolveSchema = get__default["default"](schema, segment);
|
|
421
|
+
return {
|
|
422
|
+
schema: singleSegmentResolveSchema,
|
|
423
|
+
remainingPathSegments: remainingPathSegments,
|
|
424
|
+
resolvedSegment: segment,
|
|
425
|
+
};
|
|
426
|
+
};
|
|
423
427
|
|
|
424
428
|
var Draft4 = {
|
|
425
429
|
id: 'http://json-schema.org/draft-04/schema#',
|
|
@@ -869,6 +873,59 @@ var Runtime = {
|
|
|
869
873
|
},
|
|
870
874
|
};
|
|
871
875
|
|
|
876
|
+
/******************************************************************************
|
|
877
|
+
Copyright (c) Microsoft Corporation.
|
|
878
|
+
|
|
879
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
880
|
+
purpose with or without fee is hereby granted.
|
|
881
|
+
|
|
882
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
883
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
884
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
885
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
886
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
887
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
888
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
889
|
+
***************************************************************************** */
|
|
890
|
+
|
|
891
|
+
var __assign = function() {
|
|
892
|
+
__assign = Object.assign || function __assign(t) {
|
|
893
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
894
|
+
s = arguments[i];
|
|
895
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
896
|
+
}
|
|
897
|
+
return t;
|
|
898
|
+
};
|
|
899
|
+
return __assign.apply(this, arguments);
|
|
900
|
+
};
|
|
901
|
+
|
|
902
|
+
function __rest(s, e) {
|
|
903
|
+
var t = {};
|
|
904
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
905
|
+
t[p] = s[p];
|
|
906
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
907
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
908
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
909
|
+
t[p[i]] = s[p[i]];
|
|
910
|
+
}
|
|
911
|
+
return t;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
function __spreadArray(to, from, pack) {
|
|
915
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
916
|
+
if (ar || !(i in from)) {
|
|
917
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
918
|
+
ar[i] = from[i];
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
925
|
+
var e = new Error(message);
|
|
926
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
927
|
+
};
|
|
928
|
+
|
|
872
929
|
var createAjv = function (options) {
|
|
873
930
|
var ajv = new Ajv__default["default"](__assign({ allErrors: true, verbose: true, strict: false, addUsedSchema: false }, options));
|
|
874
931
|
addFormats__default["default"](ajv);
|