@jsonforms/core 3.1.0-alpha.2 → 3.1.0-beta.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 +35 -17
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +24 -17
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/util/schema.d.ts +5 -0
- package/package.json +2 -2
- package/src/generators/schema.ts +7 -3
- package/src/reducers/core.ts +12 -4
- package/src/testers/testers.ts +26 -15
- package/src/util/resolvers.ts +4 -1
- package/src/util/schema.ts +10 -0
|
@@ -58,7 +58,7 @@ var distinct = function (properties, discriminator) {
|
|
|
58
58
|
var known = {};
|
|
59
59
|
return properties.filter(function (item) {
|
|
60
60
|
var discriminatorValue = discriminator(item);
|
|
61
|
-
if (
|
|
61
|
+
if (Object.prototype.hasOwnProperty.call(known, discriminatorValue)) {
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
@@ -157,12 +157,12 @@ instance, options) {
|
|
|
157
157
|
return function (optionName) {
|
|
158
158
|
switch (optionName) {
|
|
159
159
|
case ADDITIONAL_PROPERTIES:
|
|
160
|
-
if (
|
|
160
|
+
if (Object.prototype.hasOwnProperty.call(options, ADDITIONAL_PROPERTIES)) {
|
|
161
161
|
return options[ADDITIONAL_PROPERTIES];
|
|
162
162
|
}
|
|
163
163
|
return true;
|
|
164
164
|
case REQUIRED_PROPERTIES:
|
|
165
|
-
if (
|
|
165
|
+
if (Object.prototype.hasOwnProperty.call(options, REQUIRED_PROPERTIES)) {
|
|
166
166
|
return options[REQUIRED_PROPERTIES](props);
|
|
167
167
|
}
|
|
168
168
|
return Object.keys(props);
|
|
@@ -471,7 +471,8 @@ var initState = {
|
|
|
471
471
|
additionalErrors: [],
|
|
472
472
|
};
|
|
473
473
|
var reuseAjvForSchema = function (ajv, schema) {
|
|
474
|
-
if (
|
|
474
|
+
if (Object.prototype.hasOwnProperty.call(schema, 'id') ||
|
|
475
|
+
Object.prototype.hasOwnProperty.call(schema, '$id')) {
|
|
475
476
|
ajv.removeSchema(schema);
|
|
476
477
|
}
|
|
477
478
|
return ajv;
|
|
@@ -659,7 +660,8 @@ var errorsAt = function (instancePath, schema, matchPath) {
|
|
|
659
660
|
return function (errors) {
|
|
660
661
|
var combinatorPaths = filter__default["default"](errors, function (error) { return error.keyword === 'oneOf' || error.keyword === 'anyOf'; }).map(function (error) { return getControlPath(error); });
|
|
661
662
|
return filter__default["default"](errors, function (error) {
|
|
662
|
-
if (filteredErrorKeywords.indexOf(error.keyword) !== -1
|
|
663
|
+
if (filteredErrorKeywords.indexOf(error.keyword) !== -1 &&
|
|
664
|
+
!isOneOfEnumSchema(error.parentSchema)) {
|
|
663
665
|
return false;
|
|
664
666
|
}
|
|
665
667
|
var controlPath = getControlPath(error);
|
|
@@ -667,6 +669,7 @@ var errorsAt = function (instancePath, schema, matchPath) {
|
|
|
667
669
|
var parentSchema = error.parentSchema;
|
|
668
670
|
if (result &&
|
|
669
671
|
!isObjectSchema$1(parentSchema) &&
|
|
672
|
+
!isOneOfEnumSchema(parentSchema) &&
|
|
670
673
|
combinatorPaths.findIndex(function (p) { return instancePath.startsWith(p); }) !== -1) {
|
|
671
674
|
result = result && isEqual__default["default"](parentSchema, schema);
|
|
672
675
|
}
|
|
@@ -1034,14 +1037,21 @@ var withIncreasedRank = function (by, rankedTester) {
|
|
|
1034
1037
|
};
|
|
1035
1038
|
var isBooleanControl = and(uiTypeIs('Control'), schemaTypeIs('boolean'));
|
|
1036
1039
|
var isObjectControl = and(uiTypeIs('Control'), schemaTypeIs('object'));
|
|
1037
|
-
var isAllOfControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
var
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1040
|
+
var isAllOfControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
|
|
1041
|
+
return Object.prototype.hasOwnProperty.call(schema, 'allOf');
|
|
1042
|
+
}));
|
|
1043
|
+
var isAnyOfControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
|
|
1044
|
+
return Object.prototype.hasOwnProperty.call(schema, 'anyOf');
|
|
1045
|
+
}));
|
|
1046
|
+
var isOneOfControl = and(uiTypeIs('Control'), schemaMatches(function (schema) {
|
|
1047
|
+
return Object.prototype.hasOwnProperty.call(schema, 'oneOf');
|
|
1044
1048
|
}));
|
|
1049
|
+
var isEnumControl = and(uiTypeIs('Control'), or(schemaMatches(function (schema) {
|
|
1050
|
+
return Object.prototype.hasOwnProperty.call(schema, 'enum');
|
|
1051
|
+
}), schemaMatches(function (schema) {
|
|
1052
|
+
return Object.prototype.hasOwnProperty.call(schema, 'const');
|
|
1053
|
+
})));
|
|
1054
|
+
var isOneOfEnumControl = and(uiTypeIs('Control'), schemaMatches(function (schema) { return isOneOfEnumSchema(schema); }));
|
|
1045
1055
|
var isIntegerControl = and(uiTypeIs('Control'), schemaTypeIs('integer'));
|
|
1046
1056
|
var isNumberControl = and(uiTypeIs('Control'), schemaTypeIs('number'));
|
|
1047
1057
|
var isStringControl = and(uiTypeIs('Control'), schemaTypeIs('string'));
|
|
@@ -1103,7 +1113,7 @@ var isObjectArrayWithNesting = function (uischema, schema, context) {
|
|
|
1103
1113
|
if (val.anyOf || val.allOf) {
|
|
1104
1114
|
return true;
|
|
1105
1115
|
}
|
|
1106
|
-
if (val.oneOf && !
|
|
1116
|
+
if (val.oneOf && !isOneOfEnumSchema(val)) {
|
|
1107
1117
|
return true;
|
|
1108
1118
|
}
|
|
1109
1119
|
if (hasType(val, 'object')) {
|
|
@@ -1145,9 +1155,9 @@ var isPrimitiveArrayControl = and(uiTypeIs('Control'), schemaMatches(function (s
|
|
|
1145
1155
|
includes__default["default"](['integer', 'number', 'boolean', 'string'], types[0]));
|
|
1146
1156
|
}));
|
|
1147
1157
|
var isRangeControl = and(uiTypeIs('Control'), or(schemaTypeIs('number'), schemaTypeIs('integer')), schemaMatches(function (schema) {
|
|
1148
|
-
return
|
|
1149
|
-
|
|
1150
|
-
|
|
1158
|
+
return Object.prototype.hasOwnProperty.call(schema, 'maximum') &&
|
|
1159
|
+
Object.prototype.hasOwnProperty.call(schema, 'minimum') &&
|
|
1160
|
+
Object.prototype.hasOwnProperty.call(schema, 'default');
|
|
1151
1161
|
}), optionIs('slider', true));
|
|
1152
1162
|
var isNumberFormatControl = and(uiTypeIs('Control'), schemaTypeIs('integer'), optionIs('format', true));
|
|
1153
1163
|
var isCategorization = function (category) { return category.type === 'Categorization'; };
|
|
@@ -1379,7 +1389,8 @@ var resolveData = function (instance, dataPath) {
|
|
|
1379
1389
|
}
|
|
1380
1390
|
var dataPathSegments = dataPath.split('.');
|
|
1381
1391
|
return dataPathSegments.reduce(function (curInstance, decodedSegment) {
|
|
1382
|
-
if (!curInstance ||
|
|
1392
|
+
if (!curInstance ||
|
|
1393
|
+
!Object.prototype.hasOwnProperty.call(curInstance, decodedSegment)) {
|
|
1383
1394
|
return undefined;
|
|
1384
1395
|
}
|
|
1385
1396
|
return curInstance[decodedSegment];
|
|
@@ -2164,6 +2175,12 @@ var getFirstPrimitiveProp = function (schema) {
|
|
|
2164
2175
|
}
|
|
2165
2176
|
return undefined;
|
|
2166
2177
|
};
|
|
2178
|
+
var isOneOfEnumSchema = function (schema) {
|
|
2179
|
+
return !!schema &&
|
|
2180
|
+
Object.prototype.hasOwnProperty.call(schema, 'oneOf') &&
|
|
2181
|
+
schema.oneOf &&
|
|
2182
|
+
schema.oneOf.every(function (s) { return s.const !== undefined; });
|
|
2183
|
+
};
|
|
2167
2184
|
|
|
2168
2185
|
var setReadonlyPropertyValue = function (value) {
|
|
2169
2186
|
return function (child) {
|
|
@@ -2609,6 +2626,7 @@ exports.isObjectArrayWithNesting = isObjectArrayWithNesting;
|
|
|
2609
2626
|
exports.isObjectControl = isObjectControl;
|
|
2610
2627
|
exports.isOneOfControl = isOneOfControl;
|
|
2611
2628
|
exports.isOneOfEnumControl = isOneOfEnumControl;
|
|
2629
|
+
exports.isOneOfEnumSchema = isOneOfEnumSchema;
|
|
2612
2630
|
exports.isPrimitiveArrayControl = isPrimitiveArrayControl;
|
|
2613
2631
|
exports.isRangeControl = isRangeControl;
|
|
2614
2632
|
exports.isScopable = isScopable;
|