@jsonforms/core 2.5.2 → 3.0.0-alpha.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/README.md +1 -1
- package/docs/assets/js/search.json +1 -1
- package/docs/enums/ruleeffect.html +4 -4
- package/docs/globals.html +1124 -1081
- package/docs/index.html +70 -88
- package/docs/interfaces/addcellrendereraction.html +3 -3
- package/docs/interfaces/addrendereraction.html +3 -3
- package/docs/interfaces/adduischemaaction.html +3 -3
- package/docs/interfaces/andcondition.html +2 -2
- package/docs/interfaces/arraycontrolprops.html +22 -22
- package/docs/interfaces/arraylayoutprops.html +22 -22
- package/docs/interfaces/categorization.html +5 -5
- package/docs/interfaces/category.html +5 -5
- package/docs/interfaces/cellprops.html +14 -14
- package/docs/interfaces/combinatorrendererprops.html +13 -13
- package/docs/interfaces/combinatorsubschemarenderinfo.html +3 -3
- package/docs/interfaces/composablecondition.html +2 -2
- package/docs/interfaces/condition.html +1 -1
- package/docs/interfaces/controlelement.html +5 -5
- package/docs/interfaces/controlprops.html +17 -17
- package/docs/interfaces/controlstate.html +2 -2
- package/docs/interfaces/controlwithdetailprops.html +18 -18
- package/docs/interfaces/dispatchcellprops.html +13 -13
- package/docs/interfaces/dispatchcellstateprops.html +13 -13
- 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 +15 -15
- package/docs/interfaces/enumoption.html +2 -2
- package/docs/interfaces/formatted.html +2 -2
- package/docs/interfaces/grouplayout.html +5 -5
- package/docs/interfaces/horizontallayout.html +4 -4
- package/docs/interfaces/initaction.html +6 -6
- package/docs/interfaces/initactionoptions.html +3 -17
- package/docs/interfaces/jsonformscellrendererregistryentry.html +2 -2
- package/docs/interfaces/jsonformscore.html +7 -21
- package/docs/interfaces/jsonformsdefaultdataregistryentry.html +2 -2
- package/docs/interfaces/jsonformsextendedstate.html +1 -1
- package/docs/interfaces/{jsonformslocalestate.html → jsonformsi18nstate.html} +20 -20
- package/docs/interfaces/jsonformsprops.html +9 -24
- package/docs/interfaces/jsonformsrendererregistryentry.html +2 -2
- package/docs/interfaces/jsonformsstate.html +1 -1
- package/docs/interfaces/jsonformsstore.html +5 -5
- package/docs/interfaces/jsonformssubstates.html +18 -8
- package/docs/interfaces/jsonformsuischemaregistryentry.html +2 -2
- package/docs/interfaces/labeldescription.html +2 -2
- package/docs/interfaces/labelelement.html +4 -4
- package/docs/interfaces/layout.html +4 -4
- package/docs/interfaces/layoutprops.html +10 -10
- package/docs/interfaces/leafcondition.html +3 -3
- package/docs/interfaces/orcondition.html +2 -2
- package/docs/interfaces/ownpropsofcell.html +10 -10
- package/docs/interfaces/ownpropsofcontrol.html +9 -9
- package/docs/interfaces/ownpropsofenum.html +1 -1
- package/docs/interfaces/ownpropsofenumcell.html +11 -11
- 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/registerdefaultdataaction.html +3 -3
- package/docs/interfaces/removecellrendereraction.html +3 -3
- package/docs/interfaces/removerendereraction.html +3 -3
- package/docs/interfaces/removeuischemaaction.html +2 -2
- package/docs/interfaces/rendererprops.html +9 -9
- package/docs/interfaces/rule.html +2 -2
- package/docs/interfaces/schemabasedcondition.html +3 -3
- package/docs/interfaces/scopable.html +1 -1
- package/docs/interfaces/setajvaction.html +3 -3
- package/docs/interfaces/setconfigaction.html +2 -2
- package/docs/interfaces/setlocaleaction.html +3 -3
- package/docs/interfaces/setschemaaction.html +2 -2
- package/docs/interfaces/{setlocalizeduischemasaction.html → settranslatoraction.html} +29 -15
- package/docs/interfaces/setuischemaaction.html +2 -2
- package/docs/interfaces/setvalidationmodeaction.html +2 -2
- package/docs/interfaces/statepropsofarraycontrol.html +18 -18
- package/docs/interfaces/statepropsofarraylayout.html +18 -18
- package/docs/interfaces/statepropsofcell.html +13 -13
- package/docs/interfaces/statepropsofcombinator.html +12 -12
- package/docs/interfaces/statepropsofcontrol.html +16 -16
- package/docs/interfaces/statepropsofcontrolwithdetail.html +17 -17
- package/docs/interfaces/statepropsofenumcell.html +14 -14
- package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -23
- 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/uischemaelement.html +3 -3
- package/docs/interfaces/unregisterdefaultdataaction.html +2 -2
- package/docs/interfaces/updateaction.html +3 -3
- package/docs/interfaces/updatecoreaction.html +6 -6
- package/docs/interfaces/updateerrorsaction.html +2 -2
- package/docs/interfaces/{setlocalizedschemasaction.html → updatei18naction.html} +43 -15
- package/docs/interfaces/verticallayout.html +4 -4
- package/docs/interfaces/withclassname.html +1 -1
- package/lib/Helpers.d.ts +5 -0
- package/lib/Helpers.js +33 -0
- package/lib/Helpers.js.map +1 -0
- package/lib/actions/actions.d.ts +181 -0
- package/lib/actions/actions.js +173 -0
- package/lib/actions/actions.js.map +1 -0
- package/lib/actions/index.d.ts +1 -180
- package/lib/actions/index.js +26 -122
- package/lib/actions/index.js.map +1 -1
- package/lib/configDefault.js +2 -1
- package/lib/configDefault.js.map +1 -1
- package/lib/generators/Generate.d.ts +6 -0
- package/lib/generators/Generate.js +35 -0
- package/lib/generators/Generate.js.map +1 -0
- package/lib/generators/index.d.ts +3 -10
- package/lib/generators/index.js +28 -9
- package/lib/generators/index.js.map +1 -1
- package/lib/generators/schema.d.ts +1 -1
- package/lib/generators/schema.js +3 -1
- package/lib/generators/schema.js.map +1 -1
- package/lib/generators/uischema.d.ts +1 -2
- package/lib/generators/uischema.js +12 -10
- package/lib/generators/uischema.js.map +1 -1
- package/lib/i18n/i18nTypes.d.ts +15 -0
- package/lib/i18n/i18nTypes.js +3 -0
- package/lib/i18n/i18nTypes.js.map +1 -0
- package/lib/i18n/i18nUtil.d.ts +18 -0
- package/lib/i18n/i18nUtil.js +71 -0
- package/lib/i18n/i18nUtil.js.map +1 -0
- package/lib/i18n/index.d.ts +2 -0
- package/lib/i18n/index.js +6 -0
- package/lib/i18n/index.js.map +1 -0
- package/lib/index.d.ts +6 -18
- package/lib/index.js +10 -15
- package/lib/index.js.map +1 -1
- package/lib/jsonforms-core.js +9 -12
- package/lib/jsonforms-core.js.map +1 -1
- package/lib/models/draft4.js +2 -1
- package/lib/models/draft4.js.map +1 -1
- package/lib/models/index.d.ts +5 -0
- package/lib/models/index.js +33 -0
- package/lib/models/index.js.map +1 -0
- package/lib/models/jsonSchema.js +24 -0
- package/lib/models/jsonSchema.js.map +1 -1
- package/lib/models/uischema.js +29 -2
- package/lib/models/uischema.js.map +1 -1
- package/lib/reducers/cells.d.ts +1 -1
- package/lib/reducers/cells.js +27 -1
- package/lib/reducers/cells.js.map +1 -1
- package/lib/reducers/config.d.ts +1 -1
- package/lib/reducers/config.js +5 -3
- package/lib/reducers/config.js.map +1 -1
- package/lib/reducers/core.d.ts +5 -7
- package/lib/reducers/core.js +78 -63
- package/lib/reducers/core.js.map +1 -1
- package/lib/reducers/default-data.d.ts +1 -1
- package/lib/reducers/default-data.js +6 -3
- package/lib/reducers/default-data.js.map +1 -1
- package/lib/reducers/i18n.d.ts +8 -11
- package/lib/reducers/i18n.js +40 -23
- package/lib/reducers/i18n.js.map +1 -1
- package/lib/reducers/index.d.ts +9 -49
- package/lib/reducers/index.js +33 -91
- package/lib/reducers/index.js.map +1 -1
- package/lib/reducers/reducers.d.ts +29 -0
- package/lib/reducers/reducers.js +98 -0
- package/lib/reducers/reducers.js.map +1 -0
- package/lib/reducers/renderers.d.ts +1 -1
- package/lib/reducers/renderers.js +27 -1
- package/lib/reducers/renderers.js.map +1 -1
- package/lib/reducers/selectors.d.ts +15 -0
- package/lib/reducers/selectors.js +56 -0
- package/lib/reducers/selectors.js.map +1 -0
- package/lib/reducers/uischemas.d.ts +2 -2
- package/lib/reducers/uischemas.js +9 -6
- package/lib/reducers/uischemas.js.map +1 -1
- package/lib/store.d.ts +5 -8
- package/lib/store.js +24 -0
- package/lib/store.js.map +1 -1
- package/lib/testers/index.d.ts +1 -204
- package/lib/testers/index.js +3 -376
- package/lib/testers/index.js.map +1 -1
- package/lib/testers/testers.d.ts +203 -0
- package/lib/testers/testers.js +421 -0
- package/lib/testers/testers.js.map +1 -0
- package/lib/util/Formatted.js +24 -0
- package/lib/util/Formatted.js.map +1 -1
- package/lib/util/array.js +25 -0
- package/lib/util/array.js.map +1 -1
- package/lib/util/cell.d.ts +11 -4
- package/lib/util/cell.js +60 -17
- package/lib/util/cell.js.map +1 -1
- package/lib/util/combinators.d.ts +2 -3
- package/lib/util/combinators.js +5 -2
- package/lib/util/combinators.js.map +1 -1
- package/lib/util/ids.js +8 -4
- package/lib/util/ids.js.map +1 -1
- package/lib/util/index.d.ts +11 -45
- package/lib/util/index.js +14 -104
- package/lib/util/index.js.map +1 -1
- package/lib/util/label.d.ts +1 -2
- package/lib/util/label.js +7 -4
- package/lib/util/label.js.map +1 -1
- package/lib/util/path.d.ts +2 -1
- package/lib/util/path.js +12 -6
- package/lib/util/path.js.map +1 -1
- package/lib/util/renderer.d.ts +19 -18
- package/lib/util/renderer.js +163 -78
- package/lib/util/renderer.js.map +1 -1
- package/lib/util/resolvers.d.ts +1 -14
- package/lib/util/resolvers.js +9 -215
- package/lib/util/resolvers.js.map +1 -1
- package/lib/util/runtime.d.ts +12 -2
- package/lib/util/runtime.js +59 -17
- package/lib/util/runtime.js.map +1 -1
- package/lib/util/schema.js +27 -1
- package/lib/util/schema.js.map +1 -1
- package/lib/util/uischema.d.ts +1 -1
- package/lib/util/uischema.js +11 -7
- package/lib/util/uischema.js.map +1 -1
- package/lib/util/util.d.ts +31 -0
- package/lib/util/util.js +112 -0
- package/lib/util/util.js.map +1 -0
- package/lib/util/validator.d.ts +3 -2
- package/lib/util/validator.js +6 -5
- package/lib/util/validator.js.map +1 -1
- package/package.json +6 -8
- package/src/Helpers.ts +38 -0
- package/src/actions/actions.ts +345 -0
- package/src/actions/index.ts +1 -312
- package/src/configDefault.ts +1 -0
- package/src/generators/Generate.ts +43 -0
- package/src/generators/index.ts +3 -21
- package/src/generators/schema.ts +1 -1
- package/src/generators/uischema.ts +4 -4
- package/src/i18n/i18nTypes.ts +17 -0
- package/src/i18n/i18nUtil.ts +105 -0
- package/src/i18n/index.ts +2 -0
- package/src/index.ts +7 -31
- package/src/models/draft4.ts +1 -0
- package/src/models/index.ts +30 -0
- package/src/models/jsonSchema.ts +1 -0
- package/src/models/uischema.ts +1 -0
- package/src/reducers/cells.ts +2 -1
- package/src/reducers/config.ts +2 -1
- package/src/reducers/core.ts +74 -81
- package/src/reducers/default-data.ts +2 -1
- package/src/reducers/i18n.ts +42 -35
- package/src/reducers/index.ts +9 -158
- package/src/reducers/reducers.ts +128 -0
- package/src/reducers/renderers.ts +2 -1
- package/src/reducers/selectors.ts +65 -0
- package/src/reducers/uischemas.ts +4 -2
- package/src/store.ts +11 -8
- package/src/testers/index.ts +1 -516
- package/src/testers/testers.ts +547 -0
- package/src/util/Formatted.ts +1 -0
- package/src/util/array.ts +25 -0
- package/src/util/cell.ts +91 -19
- package/src/util/combinators.ts +2 -4
- package/src/util/ids.ts +1 -0
- package/src/util/index.ts +11 -126
- package/src/util/label.ts +2 -2
- package/src/util/path.ts +4 -1
- package/src/util/renderer.ts +170 -88
- package/src/util/resolvers.ts +2 -261
- package/src/util/runtime.ts +46 -2
- package/src/util/schema.ts +26 -1
- package/src/util/uischema.ts +2 -1
- package/src/util/util.ts +127 -0
- package/src/util/validator.ts +5 -8
- package/test/i18n/i18nUtil.test.ts +48 -0
- package/test/reducers/core.test.ts +33 -226
- package/test/util/cell.test.ts +33 -2
- package/test/util/renderer.test.ts +543 -31
- package/test/util/resolvers.test.ts +1 -59
- package/test/util/runtime.test.ts +264 -4
- package/docs/interfaces/labels.html +0 -157
- package/docs/interfaces/schemaref.html +0 -160
- package/docs/interfaces/schemarefs.html +0 -138
|
@@ -23,35 +23,19 @@
|
|
|
23
23
|
THE SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
import test from 'ava';
|
|
26
|
-
import
|
|
27
|
-
import RefParser from 'json-schema-ref-parser';
|
|
26
|
+
import Ajv from 'ajv';
|
|
28
27
|
import { coreReducer } from '../../src/reducers';
|
|
29
|
-
import { init, update, updateErrors } from '../../src/actions';
|
|
28
|
+
import { init, setSchema, setValidationMode, update, updateCore, updateErrors } from '../../src/actions';
|
|
30
29
|
import { JsonSchema } from '../../src/models/jsonSchema';
|
|
31
30
|
import {
|
|
32
31
|
errorAt,
|
|
33
32
|
JsonFormsCore,
|
|
34
|
-
|
|
33
|
+
validate,
|
|
35
34
|
subErrorsAt
|
|
36
35
|
} from '../../src/reducers/core';
|
|
37
36
|
|
|
38
|
-
import { createAjv, updateCore } from '../../src';
|
|
39
|
-
import { setSchema, setValidationMode } from '../../lib';
|
|
40
37
|
import { cloneDeep } from 'lodash';
|
|
41
|
-
|
|
42
|
-
const createRefParserOptions = (
|
|
43
|
-
encoding = 'testEncoding'
|
|
44
|
-
): RefParser.Options => {
|
|
45
|
-
const parserOptions: RefParser.ParserOptions & { encoding?: string } = {
|
|
46
|
-
encoding
|
|
47
|
-
};
|
|
48
|
-
const myOptions: RefParser.Options = {
|
|
49
|
-
parse: {
|
|
50
|
-
text: parserOptions
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
return myOptions;
|
|
54
|
-
};
|
|
38
|
+
import { createAjv } from '../../src/util/validator';
|
|
55
39
|
|
|
56
40
|
test('core reducer should support v7', t => {
|
|
57
41
|
const schema: JsonSchema = {
|
|
@@ -75,7 +59,7 @@ test('core reducer should support v7', t => {
|
|
|
75
59
|
t.is(after.errors.length, 1);
|
|
76
60
|
});
|
|
77
61
|
|
|
78
|
-
test('core reducer - no previous state - init without options should create new ajv
|
|
62
|
+
test('core reducer - no previous state - init without options should create new ajv', t => {
|
|
79
63
|
const schema: JsonSchema = {
|
|
80
64
|
type: 'object',
|
|
81
65
|
properties: {
|
|
@@ -87,7 +71,6 @@ test('core reducer - no previous state - init without options should create new
|
|
|
87
71
|
};
|
|
88
72
|
const after = coreReducer(undefined, init({}, schema, undefined, undefined));
|
|
89
73
|
t.true(after.ajv !== undefined);
|
|
90
|
-
t.true(after.refParserOptions === undefined);
|
|
91
74
|
});
|
|
92
75
|
|
|
93
76
|
test('core reducer - no previous state - init with ajv as options object should use it', t => {
|
|
@@ -100,12 +83,9 @@ test('core reducer - no previous state - init with ajv as options object should
|
|
|
100
83
|
}
|
|
101
84
|
}
|
|
102
85
|
};
|
|
103
|
-
const myAjv = new
|
|
104
|
-
errorDataPath: 'mypath'
|
|
105
|
-
});
|
|
86
|
+
const myAjv = new Ajv();
|
|
106
87
|
const after = coreReducer(undefined, init({}, schema, undefined, myAjv));
|
|
107
88
|
t.deepEqual(after.ajv, myAjv);
|
|
108
|
-
t.true(after.refParserOptions === undefined);
|
|
109
89
|
});
|
|
110
90
|
|
|
111
91
|
test('core reducer - no previous state - init with empty options object', t => {
|
|
@@ -120,7 +100,6 @@ test('core reducer - no previous state - init with empty options object', t => {
|
|
|
120
100
|
};
|
|
121
101
|
const after = coreReducer(undefined, init({}, schema, undefined, {}));
|
|
122
102
|
t.true(after.ajv !== undefined);
|
|
123
|
-
t.true(after.refParserOptions === undefined);
|
|
124
103
|
});
|
|
125
104
|
|
|
126
105
|
test('core reducer - no previous state - init with options object with ajv', t => {
|
|
@@ -133,9 +112,7 @@ test('core reducer - no previous state - init with options object with ajv', t =
|
|
|
133
112
|
}
|
|
134
113
|
}
|
|
135
114
|
};
|
|
136
|
-
const myAjv = new
|
|
137
|
-
errorDataPath: 'mypath'
|
|
138
|
-
});
|
|
115
|
+
const myAjv = new Ajv();
|
|
139
116
|
const after = coreReducer(
|
|
140
117
|
undefined,
|
|
141
118
|
init({}, schema, undefined, {
|
|
@@ -143,53 +120,6 @@ test('core reducer - no previous state - init with options object with ajv', t =
|
|
|
143
120
|
})
|
|
144
121
|
);
|
|
145
122
|
t.deepEqual(after.ajv, myAjv);
|
|
146
|
-
t.true(after.refParserOptions === undefined);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test('core reducer - no previous state - init with options object with ref parser options', t => {
|
|
150
|
-
const schema: JsonSchema = {
|
|
151
|
-
type: 'object',
|
|
152
|
-
properties: {
|
|
153
|
-
foo: {
|
|
154
|
-
type: 'string',
|
|
155
|
-
const: 'bar'
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const myOptions = createRefParserOptions();
|
|
160
|
-
const after = coreReducer(
|
|
161
|
-
undefined,
|
|
162
|
-
init({}, schema, undefined, {
|
|
163
|
-
refParserOptions: myOptions
|
|
164
|
-
})
|
|
165
|
-
);
|
|
166
|
-
t.true(after.ajv !== undefined);
|
|
167
|
-
t.deepEqual(after.refParserOptions, myOptions);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test('core reducer - no previous state - init with options object with ajv and ref parser options', t => {
|
|
171
|
-
const schema: JsonSchema = {
|
|
172
|
-
type: 'object',
|
|
173
|
-
properties: {
|
|
174
|
-
foo: {
|
|
175
|
-
type: 'string',
|
|
176
|
-
const: 'bar'
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
const myAjv = new AJV({
|
|
181
|
-
errorDataPath: 'mypath'
|
|
182
|
-
});
|
|
183
|
-
const myOptions = createRefParserOptions();
|
|
184
|
-
const after = coreReducer(
|
|
185
|
-
undefined,
|
|
186
|
-
init({}, schema, undefined, {
|
|
187
|
-
ajv: myAjv,
|
|
188
|
-
refParserOptions: myOptions
|
|
189
|
-
})
|
|
190
|
-
);
|
|
191
|
-
t.deepEqual(after.ajv, myAjv);
|
|
192
|
-
t.deepEqual(after.refParserOptions, myOptions);
|
|
193
123
|
});
|
|
194
124
|
|
|
195
125
|
test('core reducer - previous state - init without options should keep previous objects', t => {
|
|
@@ -202,10 +132,7 @@ test('core reducer - previous state - init without options should keep previous
|
|
|
202
132
|
}
|
|
203
133
|
}
|
|
204
134
|
};
|
|
205
|
-
const myAjv = new
|
|
206
|
-
errorDataPath: 'mypath'
|
|
207
|
-
});
|
|
208
|
-
const myOptions = createRefParserOptions();
|
|
135
|
+
const myAjv = new Ajv();
|
|
209
136
|
const after = coreReducer(
|
|
210
137
|
{
|
|
211
138
|
data: {},
|
|
@@ -214,15 +141,13 @@ test('core reducer - previous state - init without options should keep previous
|
|
|
214
141
|
type: 'Label'
|
|
215
142
|
},
|
|
216
143
|
ajv: myAjv,
|
|
217
|
-
refParserOptions: myOptions
|
|
218
144
|
},
|
|
219
145
|
init({}, schema)
|
|
220
146
|
);
|
|
221
147
|
t.deepEqual(after.ajv, myAjv);
|
|
222
|
-
t.deepEqual(after.refParserOptions, myOptions);
|
|
223
148
|
});
|
|
224
149
|
|
|
225
|
-
test('core reducer - previous state - init with ajv options object should overwrite ajv
|
|
150
|
+
test('core reducer - previous state - init with ajv options object should overwrite ajv', t => {
|
|
226
151
|
const schema: JsonSchema = {
|
|
227
152
|
type: 'object',
|
|
228
153
|
properties: {
|
|
@@ -232,13 +157,8 @@ test('core reducer - previous state - init with ajv options object should overwr
|
|
|
232
157
|
}
|
|
233
158
|
}
|
|
234
159
|
};
|
|
235
|
-
const previousAjv = new
|
|
236
|
-
|
|
237
|
-
});
|
|
238
|
-
const newAjv = new AJV({
|
|
239
|
-
errorDataPath: 'newajv'
|
|
240
|
-
});
|
|
241
|
-
const myOptions = createRefParserOptions();
|
|
160
|
+
const previousAjv = new Ajv();
|
|
161
|
+
const newAjv = new Ajv();
|
|
242
162
|
const after = coreReducer(
|
|
243
163
|
{
|
|
244
164
|
data: {},
|
|
@@ -247,117 +167,10 @@ test('core reducer - previous state - init with ajv options object should overwr
|
|
|
247
167
|
type: 'Label'
|
|
248
168
|
},
|
|
249
169
|
ajv: previousAjv,
|
|
250
|
-
refParserOptions: myOptions
|
|
251
170
|
},
|
|
252
171
|
init({}, schema, undefined, newAjv)
|
|
253
172
|
);
|
|
254
173
|
t.deepEqual(after.ajv, newAjv);
|
|
255
|
-
t.deepEqual(after.refParserOptions, myOptions);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
test('core reducer - previous state - init with options with ajv should overwrite ajv and keep ref parser options', t => {
|
|
259
|
-
const schema: JsonSchema = {
|
|
260
|
-
type: 'object',
|
|
261
|
-
properties: {
|
|
262
|
-
foo: {
|
|
263
|
-
type: 'string',
|
|
264
|
-
const: 'bar'
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
const previousAjv = new AJV({
|
|
269
|
-
errorDataPath: 'mypath'
|
|
270
|
-
});
|
|
271
|
-
const newAjv = new AJV({
|
|
272
|
-
errorDataPath: 'newajv'
|
|
273
|
-
});
|
|
274
|
-
const myOptions = createRefParserOptions();
|
|
275
|
-
const after = coreReducer(
|
|
276
|
-
{
|
|
277
|
-
data: {},
|
|
278
|
-
schema: {},
|
|
279
|
-
uischema: {
|
|
280
|
-
type: 'Label'
|
|
281
|
-
},
|
|
282
|
-
ajv: previousAjv,
|
|
283
|
-
refParserOptions: myOptions
|
|
284
|
-
},
|
|
285
|
-
init({}, schema, undefined, {
|
|
286
|
-
ajv: newAjv
|
|
287
|
-
})
|
|
288
|
-
);
|
|
289
|
-
t.deepEqual(after.ajv, newAjv);
|
|
290
|
-
t.deepEqual(after.refParserOptions, myOptions);
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
test('core reducer - previous state - init with options with ref parser options should overwrite ref parser options and keep ajv', t => {
|
|
294
|
-
const schema: JsonSchema = {
|
|
295
|
-
type: 'object',
|
|
296
|
-
properties: {
|
|
297
|
-
foo: {
|
|
298
|
-
type: 'string',
|
|
299
|
-
const: 'bar'
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
const myAjv = new AJV({
|
|
304
|
-
errorDataPath: 'mypath'
|
|
305
|
-
});
|
|
306
|
-
const previousOptions = createRefParserOptions();
|
|
307
|
-
const newOptions = createRefParserOptions('newEncoding');
|
|
308
|
-
const after = coreReducer(
|
|
309
|
-
{
|
|
310
|
-
data: {},
|
|
311
|
-
schema: {},
|
|
312
|
-
uischema: {
|
|
313
|
-
type: 'Label'
|
|
314
|
-
},
|
|
315
|
-
ajv: myAjv,
|
|
316
|
-
refParserOptions: previousOptions
|
|
317
|
-
},
|
|
318
|
-
init({}, schema, undefined, {
|
|
319
|
-
refParserOptions: newOptions
|
|
320
|
-
})
|
|
321
|
-
);
|
|
322
|
-
t.deepEqual(after.ajv, myAjv);
|
|
323
|
-
t.deepEqual(after.refParserOptions, newOptions);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
test('core reducer - previous state - init with both options should overwrite both', t => {
|
|
327
|
-
const schema: JsonSchema = {
|
|
328
|
-
type: 'object',
|
|
329
|
-
properties: {
|
|
330
|
-
foo: {
|
|
331
|
-
type: 'string',
|
|
332
|
-
const: 'bar'
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
const previousAjv = new AJV({
|
|
337
|
-
errorDataPath: 'mypath'
|
|
338
|
-
});
|
|
339
|
-
const newAjv = new AJV({
|
|
340
|
-
errorDataPath: 'newajv'
|
|
341
|
-
});
|
|
342
|
-
const previousOptions = createRefParserOptions();
|
|
343
|
-
const newOptions = createRefParserOptions('newEncoding');
|
|
344
|
-
const after = coreReducer(
|
|
345
|
-
{
|
|
346
|
-
data: {},
|
|
347
|
-
schema: {},
|
|
348
|
-
uischema: {
|
|
349
|
-
type: 'Label'
|
|
350
|
-
},
|
|
351
|
-
ajv: previousAjv,
|
|
352
|
-
refParserOptions: previousOptions
|
|
353
|
-
},
|
|
354
|
-
init({}, schema, undefined, {
|
|
355
|
-
ajv: newAjv,
|
|
356
|
-
refParserOptions: newOptions
|
|
357
|
-
})
|
|
358
|
-
);
|
|
359
|
-
t.deepEqual(after.ajv, newAjv);
|
|
360
|
-
t.deepEqual(after.refParserOptions, newOptions);
|
|
361
174
|
});
|
|
362
175
|
|
|
363
176
|
test('core reducer - previous state - init with empty options should not overwrite', t => {
|
|
@@ -370,10 +183,7 @@ test('core reducer - previous state - init with empty options should not overwri
|
|
|
370
183
|
}
|
|
371
184
|
}
|
|
372
185
|
};
|
|
373
|
-
const myAjv = new
|
|
374
|
-
errorDataPath: 'mypath'
|
|
375
|
-
});
|
|
376
|
-
const myOptions = createRefParserOptions();
|
|
186
|
+
const myAjv = new Ajv();
|
|
377
187
|
const after = coreReducer(
|
|
378
188
|
{
|
|
379
189
|
data: {},
|
|
@@ -382,12 +192,10 @@ test('core reducer - previous state - init with empty options should not overwri
|
|
|
382
192
|
type: 'Label'
|
|
383
193
|
},
|
|
384
194
|
ajv: myAjv,
|
|
385
|
-
refParserOptions: myOptions
|
|
386
195
|
},
|
|
387
196
|
init({}, schema, undefined, {})
|
|
388
197
|
);
|
|
389
198
|
t.deepEqual(after.ajv, myAjv);
|
|
390
|
-
t.deepEqual(after.refParserOptions, myOptions);
|
|
391
199
|
});
|
|
392
200
|
|
|
393
201
|
test('core reducer - previous state - init with undefined data should not change data', t => {
|
|
@@ -458,7 +266,7 @@ test('core reducer - update - undefined data should update for given path', t =>
|
|
|
458
266
|
type: 'Label'
|
|
459
267
|
},
|
|
460
268
|
errors: [],
|
|
461
|
-
validator: new
|
|
269
|
+
validator: new Ajv().compile(schema)
|
|
462
270
|
};
|
|
463
271
|
|
|
464
272
|
const after = coreReducer(
|
|
@@ -565,7 +373,7 @@ test('core reducer - update - empty path should update root state', t => {
|
|
|
565
373
|
uischema: {
|
|
566
374
|
type: 'Label'
|
|
567
375
|
},
|
|
568
|
-
validator: new
|
|
376
|
+
validator: new Ajv().compile(schema)
|
|
569
377
|
};
|
|
570
378
|
|
|
571
379
|
const after = coreReducer(
|
|
@@ -606,7 +414,7 @@ test('core reducer - update - providing a path should update data only belonging
|
|
|
606
414
|
uischema: {
|
|
607
415
|
type: 'Label'
|
|
608
416
|
},
|
|
609
|
-
validator: new
|
|
417
|
+
validator: new Ajv().compile(schema)
|
|
610
418
|
};
|
|
611
419
|
|
|
612
420
|
const after = coreReducer(
|
|
@@ -646,7 +454,7 @@ test('core reducer - update - should update errors', t => {
|
|
|
646
454
|
uischema: {
|
|
647
455
|
type: 'Label'
|
|
648
456
|
},
|
|
649
|
-
validator: new
|
|
457
|
+
validator: new Ajv().compile(schema)
|
|
650
458
|
};
|
|
651
459
|
|
|
652
460
|
const after = coreReducer(
|
|
@@ -661,9 +469,9 @@ test('core reducer - update - should update errors', t => {
|
|
|
661
469
|
data: { ...before.data, color: 'Yellow' },
|
|
662
470
|
errors: [
|
|
663
471
|
{
|
|
664
|
-
|
|
472
|
+
instancePath: '/color',
|
|
665
473
|
keyword: 'enum',
|
|
666
|
-
message: '
|
|
474
|
+
message: 'must be equal to one of the allowed values',
|
|
667
475
|
params: {
|
|
668
476
|
allowedValues: ['Blue', 'Green']
|
|
669
477
|
},
|
|
@@ -693,7 +501,7 @@ test('core reducer - updateErrors - should update errors with error', t => {
|
|
|
693
501
|
};
|
|
694
502
|
|
|
695
503
|
const error = {
|
|
696
|
-
|
|
504
|
+
instancePath: '/color',
|
|
697
505
|
keyword: 'enum',
|
|
698
506
|
message: 'should be equal to one of the allowed values',
|
|
699
507
|
params: {
|
|
@@ -735,7 +543,7 @@ test('errorAt filters enum', t => {
|
|
|
735
543
|
};
|
|
736
544
|
const data = { foo: '', bar: '' };
|
|
737
545
|
const v = ajv.compile(schema);
|
|
738
|
-
const errors =
|
|
546
|
+
const errors = validate(v, data);
|
|
739
547
|
|
|
740
548
|
const state: JsonFormsCore = {
|
|
741
549
|
data,
|
|
@@ -766,7 +574,7 @@ test('errorAt filters required', t => {
|
|
|
766
574
|
};
|
|
767
575
|
const data = {};
|
|
768
576
|
const v = ajv.compile(schema);
|
|
769
|
-
const errors =
|
|
577
|
+
const errors = validate(v, data);
|
|
770
578
|
|
|
771
579
|
const state: JsonFormsCore = {
|
|
772
580
|
data,
|
|
@@ -815,7 +623,7 @@ test('errorAt filters required in oneOf object', t => {
|
|
|
815
623
|
};
|
|
816
624
|
const data = { fooOrBar: { } };
|
|
817
625
|
const v = ajv.compile(schema);
|
|
818
|
-
const errors =
|
|
626
|
+
const errors = validate(v, data);
|
|
819
627
|
|
|
820
628
|
const state: JsonFormsCore = {
|
|
821
629
|
data,
|
|
@@ -867,7 +675,7 @@ test('errorAt filters required in anyOf object', t => {
|
|
|
867
675
|
};
|
|
868
676
|
const data = { fooOrBar: { } };
|
|
869
677
|
const v = ajv.compile(schema);
|
|
870
|
-
const errors =
|
|
678
|
+
const errors = validate(v, data);
|
|
871
679
|
|
|
872
680
|
const state: JsonFormsCore = {
|
|
873
681
|
data,
|
|
@@ -915,7 +723,7 @@ test('errorAt filters array minItems', t => {
|
|
|
915
723
|
numbers: []
|
|
916
724
|
};
|
|
917
725
|
const v = ajv.compile(schema);
|
|
918
|
-
const errors =
|
|
726
|
+
const errors = validate(v, data);
|
|
919
727
|
|
|
920
728
|
const state: JsonFormsCore = {
|
|
921
729
|
data,
|
|
@@ -960,7 +768,7 @@ test('errorAt filters array inner value', t => {
|
|
|
960
768
|
numbers: ['Bar']
|
|
961
769
|
};
|
|
962
770
|
const v = ajv.compile(schema);
|
|
963
|
-
const errors =
|
|
771
|
+
const errors = validate(v, data);
|
|
964
772
|
|
|
965
773
|
const state: JsonFormsCore = {
|
|
966
774
|
data,
|
|
@@ -996,7 +804,7 @@ test('errorAt filters oneOf simple', t => {
|
|
|
996
804
|
};
|
|
997
805
|
const data: { coloursOrNumbers: string } = { coloursOrNumbers: 'Foo' };
|
|
998
806
|
const v = ajv.compile(schema);
|
|
999
|
-
const errors =
|
|
807
|
+
const errors = validate(v, data);
|
|
1000
808
|
|
|
1001
809
|
const state: JsonFormsCore = {
|
|
1002
810
|
data,
|
|
@@ -1035,7 +843,7 @@ test('errorAt filters anyOf simple', t => {
|
|
|
1035
843
|
};
|
|
1036
844
|
const data: { coloursOrNumbers: string } = { coloursOrNumbers: 'Foo' };
|
|
1037
845
|
const v = ajv.compile(schema);
|
|
1038
|
-
const errors =
|
|
846
|
+
const errors = validate(v, data);
|
|
1039
847
|
|
|
1040
848
|
const state: JsonFormsCore = {
|
|
1041
849
|
data,
|
|
@@ -1089,7 +897,7 @@ test('errorAt filters oneOf objects', t => {
|
|
|
1089
897
|
};
|
|
1090
898
|
const data = { coloursOrNumbers: { colour: 'Foo' } };
|
|
1091
899
|
const v = ajv.compile(schema);
|
|
1092
|
-
const errors =
|
|
900
|
+
const errors = validate(v, data);
|
|
1093
901
|
|
|
1094
902
|
const state: JsonFormsCore = {
|
|
1095
903
|
data,
|
|
@@ -1141,7 +949,7 @@ test('errorAt filters oneOf objects same properties', t => {
|
|
|
1141
949
|
};
|
|
1142
950
|
const data = { coloursOrNumbers: { colourOrNumber: 'Foo' } };
|
|
1143
951
|
const v = ajv.compile(schema);
|
|
1144
|
-
const errors =
|
|
952
|
+
const errors = validate(v, data);
|
|
1145
953
|
|
|
1146
954
|
const state: JsonFormsCore = {
|
|
1147
955
|
data,
|
|
@@ -1190,7 +998,7 @@ test('errorAt filters oneOf array', t => {
|
|
|
1190
998
|
};
|
|
1191
999
|
const data: { coloursOrNumbers: string[] } = { coloursOrNumbers: [] };
|
|
1192
1000
|
const v = ajv.compile(schema);
|
|
1193
|
-
const errors =
|
|
1001
|
+
const errors = validate(v, data);
|
|
1194
1002
|
|
|
1195
1003
|
const state: JsonFormsCore = {
|
|
1196
1004
|
data,
|
|
@@ -1239,7 +1047,7 @@ test('errorAt filters oneOf array inner', t => {
|
|
|
1239
1047
|
};
|
|
1240
1048
|
const data: { coloursOrNumbers: string[] } = { coloursOrNumbers: ['Foo'] };
|
|
1241
1049
|
const v = ajv.compile(schema);
|
|
1242
|
-
const errors =
|
|
1050
|
+
const errors = validate(v, data);
|
|
1243
1051
|
|
|
1244
1052
|
const state: JsonFormsCore = {
|
|
1245
1053
|
data,
|
|
@@ -1286,7 +1094,7 @@ test('subErrorsAt filters array inner', t => {
|
|
|
1286
1094
|
numbers: ['Bar']
|
|
1287
1095
|
};
|
|
1288
1096
|
const v = ajv.compile(schema);
|
|
1289
|
-
const errors =
|
|
1097
|
+
const errors = validate(v, data);
|
|
1290
1098
|
|
|
1291
1099
|
const state: JsonFormsCore = {
|
|
1292
1100
|
data,
|
|
@@ -1335,7 +1143,7 @@ test('subErrorsAt filters oneOf array inner', t => {
|
|
|
1335
1143
|
};
|
|
1336
1144
|
const data: { coloursOrNumbers: string[] } = { coloursOrNumbers: ['Foo'] };
|
|
1337
1145
|
const v = ajv.compile(schema);
|
|
1338
|
-
const errors =
|
|
1146
|
+
const errors = validate(v, data);
|
|
1339
1147
|
|
|
1340
1148
|
const state: JsonFormsCore = {
|
|
1341
1149
|
data,
|
|
@@ -1621,7 +1429,6 @@ test('core reducer - update core - unchanged state properties should be unchange
|
|
|
1621
1429
|
t.true(before.schema === afterDataUpdate.schema);
|
|
1622
1430
|
t.true(before.ajv === afterDataUpdate.ajv);
|
|
1623
1431
|
t.true(before.errors === afterDataUpdate.errors);
|
|
1624
|
-
t.true(before.refParserOptions === afterDataUpdate.refParserOptions);
|
|
1625
1432
|
t.true(before.uischema === afterDataUpdate.uischema);
|
|
1626
1433
|
t.true(before.validationMode === afterDataUpdate.validationMode);
|
|
1627
1434
|
t.true(before.validator === afterDataUpdate.validator);
|
package/test/util/cell.test.ts
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
defaultMapDispatchToControlProps,
|
|
31
31
|
defaultMapStateToEnumCellProps,
|
|
32
32
|
DispatchPropsOfCell,
|
|
33
|
-
mapStateToCellProps
|
|
33
|
+
mapStateToCellProps, mapStateToOneOfEnumCellProps, oneOfToEnumOptionMapper
|
|
34
34
|
} from '../../src/util';
|
|
35
35
|
import { UPDATE_DATA, UpdateAction } from '../../src/actions';
|
|
36
36
|
import configureStore from 'redux-mock-store';
|
|
@@ -284,7 +284,38 @@ test('mapStateToEnumCellProps - set default options for dropdown list', t => {
|
|
|
284
284
|
};
|
|
285
285
|
|
|
286
286
|
const props = defaultMapStateToEnumCellProps(createState(uischema), ownProps);
|
|
287
|
-
t.deepEqual(
|
|
287
|
+
t.deepEqual(
|
|
288
|
+
props.options,
|
|
289
|
+
['DE', 'IT', 'JP', 'US', 'RU', 'Other'].map(e => enumToEnumOptionMapper(e))
|
|
290
|
+
);
|
|
291
|
+
t.is(props.data, undefined);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
test('mapStateToOneOfEnumCellProps - set one of options for dropdown list', t => {
|
|
296
|
+
const uischema: ControlElement = {
|
|
297
|
+
type: 'Control',
|
|
298
|
+
scope: '#/properties/country'
|
|
299
|
+
};
|
|
300
|
+
const ownProps = {
|
|
301
|
+
schema: {
|
|
302
|
+
oneOf: [
|
|
303
|
+
{
|
|
304
|
+
const: 'AU',
|
|
305
|
+
title: 'Australia'
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
const: 'NZ',
|
|
309
|
+
title: 'New Zealand'
|
|
310
|
+
}
|
|
311
|
+
]
|
|
312
|
+
},
|
|
313
|
+
uischema,
|
|
314
|
+
path: 'country'
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const props = mapStateToOneOfEnumCellProps(createState(uischema), ownProps);
|
|
318
|
+
t.deepEqual(props.options, [{title: 'Australia' , const: 'AU', }, { title: 'New Zealand', const: 'NZ' }].map(schema => oneOfToEnumOptionMapper(schema)));
|
|
288
319
|
t.is(props.data, undefined);
|
|
289
320
|
});
|
|
290
321
|
|