@jsonforms/core 3.0.0-alpha.3 → 3.0.0-beta.2
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/docs/assets/js/search.json +1 -1
- package/docs/globals.html +207 -165
- package/docs/index.html +7 -4
- package/docs/interfaces/arraycontrolprops.html +21 -21
- package/docs/interfaces/arraylayoutprops.html +21 -21
- package/docs/interfaces/cellprops.html +12 -12
- package/docs/interfaces/combinatorrendererprops.html +143 -36
- package/docs/interfaces/controlprops.html +16 -16
- package/docs/interfaces/controlstate.html +2 -2
- package/docs/interfaces/controlwithdetailprops.html +17 -17
- package/docs/interfaces/dispatchcellprops.html +10 -10
- package/docs/interfaces/dispatchcellstateprops.html +10 -10
- package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
- package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
- package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
- package/docs/interfaces/enumcellprops.html +13 -13
- package/docs/interfaces/enumoption.html +2 -2
- package/docs/interfaces/jsonformsprops.html +9 -9
- package/docs/interfaces/layoutprops.html +10 -10
- package/docs/interfaces/ownpropsofcell.html +9 -9
- package/docs/interfaces/ownpropsofcontrol.html +9 -12
- package/docs/interfaces/ownpropsofenum.html +1 -1
- package/docs/interfaces/ownpropsofenumcell.html +10 -10
- package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
- package/docs/interfaces/ownpropsoflayout.html +9 -9
- package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
- package/docs/interfaces/ownpropsofrenderer.html +8 -8
- package/docs/interfaces/rendererprops.html +9 -9
- package/docs/interfaces/statepropsofarraycontrol.html +17 -17
- package/docs/interfaces/statepropsofarraylayout.html +17 -17
- package/docs/interfaces/statepropsofcell.html +11 -11
- package/docs/interfaces/statepropsofcombinator.html +147 -40
- package/docs/interfaces/statepropsofcontrol.html +18 -15
- package/docs/interfaces/statepropsofcontrolwithdetail.html +16 -16
- package/docs/interfaces/statepropsofenumcell.html +12 -12
- package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -9
- package/docs/interfaces/statepropsoflayout.html +10 -10
- package/docs/interfaces/statepropsofmasteritem.html +7 -7
- package/docs/interfaces/statepropsofrenderer.html +9 -9
- package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
- package/docs/interfaces/withclassname.html +1 -1
- package/lib/Helpers.d.ts +5 -5
- package/lib/actions/actions.d.ts +181 -181
- package/lib/actions/index.d.ts +1 -1
- package/lib/configDefault.d.ts +6 -6
- package/lib/generators/Generate.d.ts +6 -6
- package/lib/generators/index.d.ts +3 -3
- package/lib/generators/schema.d.ts +8 -8
- package/lib/generators/uischema.d.ts +12 -12
- package/lib/i18n/i18nTypes.d.ts +15 -15
- package/lib/i18n/i18nUtil.d.ts +18 -18
- package/lib/i18n/index.d.ts +2 -2
- package/lib/index.d.ts +11 -11
- package/lib/jsonforms-core.cjs.js +2441 -0
- package/lib/jsonforms-core.cjs.js.map +1 -0
- package/lib/jsonforms-core.esm.js +2152 -0
- package/lib/jsonforms-core.esm.js.map +1 -0
- package/lib/models/draft4.d.ts +198 -198
- package/lib/models/index.d.ts +5 -5
- package/lib/models/jsonSchema.d.ts +3 -3
- package/lib/models/jsonSchema4.d.ts +110 -110
- package/lib/models/jsonSchema7.d.ts +119 -119
- package/lib/models/uischema.d.ts +201 -201
- package/lib/reducers/cells.d.ts +11 -11
- package/lib/reducers/config.d.ts +3 -3
- package/lib/reducers/core.d.ts +24 -24
- package/lib/reducers/default-data.d.ts +10 -10
- package/lib/reducers/i18n.d.ts +8 -8
- package/lib/reducers/index.d.ts +9 -9
- package/lib/reducers/reducers.d.ts +29 -29
- package/lib/reducers/renderers.d.ts +10 -10
- package/lib/reducers/selectors.d.ts +15 -15
- package/lib/reducers/uischemas.d.ts +10 -10
- package/lib/store.d.ts +53 -53
- package/lib/testers/index.d.ts +1 -1
- package/lib/testers/testers.d.ts +204 -203
- package/lib/util/Formatted.d.ts +19 -19
- package/lib/util/array.d.ts +3 -3
- package/lib/util/cell.d.ts +79 -79
- package/lib/util/combinators.d.ts +9 -10
- package/lib/util/ids.d.ts +3 -3
- package/lib/util/index.d.ts +15 -15
- package/lib/util/label.d.ts +9 -9
- package/lib/util/path.d.ts +35 -25
- package/lib/util/renderer.d.ts +398 -397
- package/lib/util/resolvers.d.ts +25 -25
- package/lib/util/runtime.d.ts +18 -18
- package/lib/util/schema.d.ts +1 -1
- package/lib/util/type.d.ts +174 -174
- package/lib/util/uischema.d.ts +5 -5
- package/lib/util/util.d.ts +31 -31
- package/lib/util/validator.d.ts +3 -3
- package/package.json +16 -13
- package/rollup.config.js +44 -0
- package/src/generators/uischema.ts +4 -4
- package/src/reducers/reducers.ts +14 -6
- package/src/testers/testers.ts +60 -33
- package/src/util/cell.ts +4 -4
- package/src/util/combinators.ts +17 -32
- package/src/util/label.ts +2 -2
- package/src/util/path.ts +18 -6
- package/src/util/renderer.ts +22 -36
- package/src/util/resolvers.ts +57 -68
- package/src/util/util.ts +1 -1
- package/stats.html +3279 -0
- package/test/generators/uischema.test.ts +18 -0
- package/test/testers.test.ts +208 -120
- package/test/util/path.test.ts +37 -20
- package/test/util/resolvers.test.ts +99 -8
- package/lib/Helpers.js +0 -33
- package/lib/Helpers.js.map +0 -1
- package/lib/actions/actions.js +0 -173
- package/lib/actions/actions.js.map +0 -1
- package/lib/actions/index.js +0 -29
- package/lib/actions/index.js.map +0 -1
- package/lib/configDefault.js +0 -48
- package/lib/configDefault.js.map +0 -1
- package/lib/generators/Generate.js +0 -35
- package/lib/generators/Generate.js.map +0 -1
- package/lib/generators/index.js +0 -31
- package/lib/generators/index.js.map +0 -1
- package/lib/generators/schema.js +0 -154
- package/lib/generators/schema.js.map +0 -1
- package/lib/generators/uischema.js +0 -169
- package/lib/generators/uischema.js.map +0 -1
- package/lib/i18n/i18nTypes.js +0 -3
- package/lib/i18n/i18nTypes.js.map +0 -1
- package/lib/i18n/i18nUtil.js +0 -71
- package/lib/i18n/i18nUtil.js.map +0 -1
- package/lib/i18n/index.js +0 -6
- package/lib/i18n/index.js.map +0 -1
- package/lib/index.js +0 -40
- package/lib/index.js.map +0 -1
- package/lib/jsonforms-core.js +0 -25
- package/lib/jsonforms-core.js.map +0 -1
- package/lib/models/draft4.js +0 -174
- package/lib/models/draft4.js.map +0 -1
- package/lib/models/index.js +0 -33
- package/lib/models/index.js.map +0 -1
- package/lib/models/jsonSchema.js +0 -27
- package/lib/models/jsonSchema.js.map +0 -1
- package/lib/models/jsonSchema4.js +0 -30
- package/lib/models/jsonSchema4.js.map +0 -1
- package/lib/models/jsonSchema7.js +0 -30
- package/lib/models/jsonSchema7.js.map +0 -1
- package/lib/models/uischema.js +0 -58
- package/lib/models/uischema.js.map +0 -1
- package/lib/reducers/cells.js +0 -42
- package/lib/reducers/cells.js.map +0 -1
- package/lib/reducers/config.js +0 -46
- package/lib/reducers/config.js.map +0 -1
- package/lib/reducers/core.js +0 -294
- package/lib/reducers/core.js.map +0 -1
- package/lib/reducers/default-data.js +0 -45
- package/lib/reducers/default-data.js.map +0 -1
- package/lib/reducers/i18n.js +0 -83
- package/lib/reducers/i18n.js.map +0 -1
- package/lib/reducers/index.js +0 -37
- package/lib/reducers/index.js.map +0 -1
- package/lib/reducers/reducers.js +0 -98
- package/lib/reducers/reducers.js.map +0 -1
- package/lib/reducers/renderers.js +0 -43
- package/lib/reducers/renderers.js.map +0 -1
- package/lib/reducers/selectors.js +0 -56
- package/lib/reducers/selectors.js.map +0 -1
- package/lib/reducers/uischemas.js +0 -60
- package/lib/reducers/uischemas.js.map +0 -1
- package/lib/store.js +0 -27
- package/lib/store.js.map +0 -1
- package/lib/testers/index.js +0 -29
- package/lib/testers/index.js.map +0 -1
- package/lib/testers/testers.js +0 -421
- package/lib/testers/testers.js.map +0 -1
- package/lib/util/Formatted.js +0 -27
- package/lib/util/Formatted.js.map +0 -1
- package/lib/util/array.js +0 -44
- package/lib/util/array.js.map +0 -1
- package/lib/util/cell.js +0 -148
- package/lib/util/cell.js.map +0 -1
- package/lib/util/combinators.js +0 -59
- package/lib/util/combinators.js.map +0 -1
- package/lib/util/ids.js +0 -54
- package/lib/util/ids.js.map +0 -1
- package/lib/util/index.js +0 -43
- package/lib/util/index.js.map +0 -1
- package/lib/util/label.js +0 -73
- package/lib/util/label.js.map +0 -1
- package/lib/util/path.js +0 -90
- package/lib/util/path.js.map +0 -1
- package/lib/util/renderer.js +0 -530
- package/lib/util/renderer.js.map +0 -1
- package/lib/util/resolvers.js +0 -169
- package/lib/util/resolvers.js.map +0 -1
- package/lib/util/runtime.js +0 -167
- package/lib/util/runtime.js.map +0 -1
- package/lib/util/schema.js +0 -42
- package/lib/util/schema.js.map +0 -1
- package/lib/util/type.js +0 -27
- package/lib/util/type.js.map +0 -1
- package/lib/util/uischema.js +0 -56
- package/lib/util/uischema.js.map +0 -1
- package/lib/util/util.js +0 -112
- package/lib/util/util.js.map +0 -1
- package/lib/util/validator.js +0 -37
- package/lib/util/validator.js.map +0 -1
- package/webpack.build.js +0 -13
package/src/util/resolvers.ts
CHANGED
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
|
|
26
26
|
import isEmpty from 'lodash/isEmpty';
|
|
27
27
|
import get from 'lodash/get';
|
|
28
|
-
import { JsonSchema } from '../models';
|
|
28
|
+
import { JsonSchema, JsonSchema7 } from '../models';
|
|
29
|
+
import { decode } from './path';
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Map for storing refs and the respective schemas they are pointing to.
|
|
@@ -110,80 +111,68 @@ const invalidSegment = (pathSegment: string) =>
|
|
|
110
111
|
export const resolveSchema = (
|
|
111
112
|
schema: JsonSchema,
|
|
112
113
|
schemaPath: string,
|
|
113
|
-
rootSchema
|
|
114
|
+
rootSchema: JsonSchema
|
|
115
|
+
): JsonSchema => {
|
|
116
|
+
const segments = schemaPath?.split('/').map(decode);
|
|
117
|
+
return resolveSchemaWithSegments(schema, segments, rootSchema);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const resolveSchemaWithSegments = (
|
|
121
|
+
schema: JsonSchema,
|
|
122
|
+
pathSegments: string[],
|
|
123
|
+
rootSchema: JsonSchema
|
|
114
124
|
): JsonSchema => {
|
|
115
125
|
if (isEmpty(schema)) {
|
|
116
126
|
return undefined;
|
|
117
127
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
let pathSegment = validPathSegments[i];
|
|
122
|
-
resultSchema =
|
|
123
|
-
resultSchema === undefined || resultSchema.$ref === undefined
|
|
124
|
-
? resultSchema
|
|
125
|
-
: resolveSchema(schema, resultSchema.$ref);
|
|
126
|
-
if (invalidSegment(pathSegment)) {
|
|
127
|
-
// skip invalid segments
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
let curSchema = get(resultSchema, pathSegment);
|
|
131
|
-
if (!curSchema) {
|
|
132
|
-
// resolving was not successful, check whether the scope omitted an oneOf, allOf or anyOf and resolve anyway
|
|
133
|
-
const schemas = [].concat(
|
|
134
|
-
resultSchema?.oneOf ?? [],
|
|
135
|
-
resultSchema?.allOf ?? [],
|
|
136
|
-
resultSchema?.anyOf ?? []
|
|
137
|
-
);
|
|
138
|
-
for (let item of schemas) {
|
|
139
|
-
curSchema = resolveSchema(item, validPathSegments.slice(i).join('/'));
|
|
140
|
-
if (curSchema) {
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (curSchema) {
|
|
145
|
-
// already resolved rest of the path
|
|
146
|
-
resultSchema = curSchema;
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
resultSchema = curSchema;
|
|
128
|
+
|
|
129
|
+
if (schema.$ref) {
|
|
130
|
+
schema = resolveSchema(rootSchema, schema.$ref, rootSchema);
|
|
151
131
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// schemas around
|
|
156
|
-
if (resultSchema !== undefined && resultSchema.$ref !== undefined) {
|
|
157
|
-
try {
|
|
158
|
-
return retrieveResolvableSchema(schema, resultSchema.$ref);
|
|
159
|
-
} catch (e) {
|
|
160
|
-
return retrieveResolvableSchema(rootSchema, resultSchema.$ref);
|
|
161
|
-
}
|
|
132
|
+
|
|
133
|
+
if (!pathSegments || pathSegments.length === 0) {
|
|
134
|
+
return schema;
|
|
162
135
|
}
|
|
163
136
|
|
|
164
|
-
|
|
165
|
-
};
|
|
137
|
+
const [segment, ...remainingSegments] = pathSegments;
|
|
166
138
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
*
|
|
170
|
-
* @param {JsonSchema} full the JSON schema to resolved the reference against
|
|
171
|
-
* @param {string} reference the reference to be resolved
|
|
172
|
-
* @returns {JsonSchema} the resolved sub-schema
|
|
173
|
-
*/
|
|
174
|
-
// disable rule because resolve is mutually recursive
|
|
175
|
-
// tslint:disable:only-arrow-functions
|
|
176
|
-
function retrieveResolvableSchema(
|
|
177
|
-
full: JsonSchema,
|
|
178
|
-
reference: string
|
|
179
|
-
): JsonSchema {
|
|
180
|
-
// tslint:enable:only-arrow-functions
|
|
181
|
-
const child = resolveSchema(full, reference);
|
|
182
|
-
const allRefs = findAllRefs(child);
|
|
183
|
-
const innerSelfReference = allRefs[reference];
|
|
184
|
-
if (innerSelfReference !== undefined) {
|
|
185
|
-
innerSelfReference.$ref = '#';
|
|
139
|
+
if (invalidSegment(segment)) {
|
|
140
|
+
return resolveSchemaWithSegments(schema, remainingSegments, rootSchema);
|
|
186
141
|
}
|
|
187
142
|
|
|
188
|
-
|
|
189
|
-
|
|
143
|
+
const singleSegmentResolveSchema = get(schema, segment);
|
|
144
|
+
|
|
145
|
+
const resolvedSchema = resolveSchemaWithSegments(singleSegmentResolveSchema, remainingSegments, rootSchema);
|
|
146
|
+
if (resolvedSchema) {
|
|
147
|
+
return resolvedSchema;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (segment === 'properties' || segment === 'items') {
|
|
151
|
+
// Let's try to resolve the path, assuming oneOf/allOf/anyOf/then/else was omitted.
|
|
152
|
+
// We only do this when traversing an object or array as we want to avoid
|
|
153
|
+
// following a property which is named oneOf, allOf, anyOf, then or else.
|
|
154
|
+
let alternativeResolveResult = undefined;
|
|
155
|
+
|
|
156
|
+
const subSchemas = [].concat(
|
|
157
|
+
schema.oneOf ?? [],
|
|
158
|
+
schema.allOf ?? [],
|
|
159
|
+
schema.anyOf ?? [],
|
|
160
|
+
(schema as JsonSchema7).then ?? [],
|
|
161
|
+
(schema as JsonSchema7).else ?? []
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
for (const subSchema of subSchemas) {
|
|
165
|
+
alternativeResolveResult = resolveSchemaWithSegments(
|
|
166
|
+
subSchema,
|
|
167
|
+
[segment, ...remainingSegments],
|
|
168
|
+
rootSchema
|
|
169
|
+
);
|
|
170
|
+
if (alternativeResolveResult) {
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return alternativeResolveResult;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|