@jsonforms/core 3.0.0-beta.0 → 3.0.0-beta.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.
Files changed (91) hide show
  1. package/docs/assets/js/search.json +1 -1
  2. package/docs/globals.html +318 -209
  3. package/docs/index.html +13 -4
  4. package/docs/interfaces/addcellrendereraction.html +3 -3
  5. package/docs/interfaces/addrendereraction.html +3 -3
  6. package/docs/interfaces/adduischemaaction.html +3 -3
  7. package/docs/interfaces/arraycontrolprops.html +21 -21
  8. package/docs/interfaces/arraylayoutprops.html +21 -21
  9. package/docs/interfaces/cellprops.html +12 -12
  10. package/docs/interfaces/combinatorrendererprops.html +143 -36
  11. package/docs/interfaces/controlprops.html +16 -16
  12. package/docs/interfaces/controlstate.html +2 -2
  13. package/docs/interfaces/controlwithdetailprops.html +17 -17
  14. package/docs/interfaces/dispatchcellprops.html +10 -10
  15. package/docs/interfaces/dispatchcellstateprops.html +10 -10
  16. package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
  17. package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
  18. package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
  19. package/docs/interfaces/enumcellprops.html +13 -13
  20. package/docs/interfaces/enumoption.html +2 -2
  21. package/docs/interfaces/initactionoptions.html +14 -0
  22. package/docs/interfaces/jsonformscore.html +17 -3
  23. package/docs/interfaces/jsonformsprops.html +9 -9
  24. package/docs/interfaces/layoutprops.html +10 -10
  25. package/docs/interfaces/ownpropsofcell.html +9 -9
  26. package/docs/interfaces/ownpropsofcontrol.html +9 -12
  27. package/docs/interfaces/ownpropsofenum.html +1 -1
  28. package/docs/interfaces/ownpropsofenumcell.html +10 -10
  29. package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
  30. package/docs/interfaces/ownpropsoflayout.html +9 -9
  31. package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
  32. package/docs/interfaces/ownpropsofrenderer.html +8 -8
  33. package/docs/interfaces/registerdefaultdataaction.html +3 -3
  34. package/docs/interfaces/removecellrendereraction.html +3 -3
  35. package/docs/interfaces/removerendereraction.html +3 -3
  36. package/docs/interfaces/removeuischemaaction.html +2 -2
  37. package/docs/interfaces/rendererprops.html +9 -9
  38. package/docs/interfaces/setajvaction.html +2 -2
  39. package/docs/interfaces/setconfigaction.html +2 -2
  40. package/docs/interfaces/setlocaleaction.html +2 -2
  41. package/docs/interfaces/setschemaaction.html +2 -2
  42. package/docs/interfaces/settranslatoraction.html +3 -3
  43. package/docs/interfaces/setuischemaaction.html +2 -2
  44. package/docs/interfaces/setvalidationmodeaction.html +2 -2
  45. package/docs/interfaces/statepropsofarraycontrol.html +17 -17
  46. package/docs/interfaces/statepropsofarraylayout.html +17 -17
  47. package/docs/interfaces/statepropsofcell.html +11 -11
  48. package/docs/interfaces/statepropsofcombinator.html +147 -40
  49. package/docs/interfaces/statepropsofcontrol.html +18 -15
  50. package/docs/interfaces/statepropsofcontrolwithdetail.html +16 -16
  51. package/docs/interfaces/statepropsofenumcell.html +12 -12
  52. package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -9
  53. package/docs/interfaces/statepropsoflayout.html +10 -10
  54. package/docs/interfaces/statepropsofmasteritem.html +7 -7
  55. package/docs/interfaces/statepropsofrenderer.html +9 -9
  56. package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
  57. package/docs/interfaces/unregisterdefaultdataaction.html +2 -2
  58. package/docs/interfaces/updatei18naction.html +4 -4
  59. package/docs/interfaces/withclassname.html +1 -1
  60. package/lib/actions/actions.d.ts +1 -0
  61. package/lib/jsonforms-core.cjs.js +191 -176
  62. package/lib/jsonforms-core.cjs.js.map +1 -1
  63. package/lib/jsonforms-core.esm.js +174 -164
  64. package/lib/jsonforms-core.esm.js.map +1 -1
  65. package/lib/reducers/core.d.ts +1 -0
  66. package/lib/reducers/reducers.d.ts +2 -2
  67. package/lib/testers/testers.d.ts +8 -7
  68. package/lib/util/combinators.d.ts +0 -1
  69. package/lib/util/path.d.ts +10 -0
  70. package/lib/util/renderer.d.ts +2 -2
  71. package/lib/util/resolvers.d.ts +1 -1
  72. package/lib/util/util.d.ts +1 -1
  73. package/package.json +2 -2
  74. package/src/actions/actions.ts +1 -0
  75. package/src/generators/uischema.ts +4 -4
  76. package/src/i18n/i18nUtil.ts +5 -5
  77. package/src/reducers/core.ts +30 -3
  78. package/src/reducers/reducers.ts +12 -4
  79. package/src/testers/testers.ts +60 -33
  80. package/src/util/combinators.ts +17 -32
  81. package/src/util/label.ts +2 -2
  82. package/src/util/path.ts +18 -6
  83. package/src/util/renderer.ts +20 -32
  84. package/src/util/resolvers.ts +57 -68
  85. package/src/util/util.ts +1 -1
  86. package/stats.html +1 -1
  87. package/test/generators/uischema.test.ts +18 -0
  88. package/test/reducers/core.test.ts +203 -1
  89. package/test/testers.test.ts +208 -120
  90. package/test/util/path.test.ts +37 -20
  91. package/test/util/resolvers.test.ts +99 -8
@@ -133,6 +133,15 @@ test('core reducer - previous state - init without options should keep previous
133
133
  }
134
134
  };
135
135
  const myAjv = new Ajv();
136
+ const additionalErrors = [{
137
+ instancePath: '',
138
+ dataPath: '',
139
+ schemaPath: '#/required',
140
+ keyword: 'required',
141
+ params: {
142
+ missingProperty: 'foo'
143
+ },
144
+ }];
136
145
  const after = coreReducer(
137
146
  {
138
147
  data: {},
@@ -141,10 +150,12 @@ test('core reducer - previous state - init without options should keep previous
141
150
  type: 'Label'
142
151
  },
143
152
  ajv: myAjv,
153
+ additionalErrors
144
154
  },
145
155
  init({}, schema)
146
156
  );
147
157
  t.deepEqual(after.ajv, myAjv);
158
+ t.deepEqual(after.additionalErrors, additionalErrors);
148
159
  });
149
160
 
150
161
  test('core reducer - previous state - init with ajv options object should overwrite ajv', t => {
@@ -173,6 +184,49 @@ test('core reducer - previous state - init with ajv options object should overwr
173
184
  t.deepEqual(after.ajv, newAjv);
174
185
  });
175
186
 
187
+ test('core reducer - previous state - init with additionalErrors option object should overwrite additionalErrors', t => {
188
+ const schema: JsonSchema = {
189
+ type: 'object',
190
+ properties: {
191
+ foo: {
192
+ type: 'string',
193
+ const: 'bar'
194
+ }
195
+ }
196
+ };
197
+
198
+ const prevAdditionalErrors = [{
199
+ instancePath: '',
200
+ dataPath: '',
201
+ schemaPath: '#/required',
202
+ keyword: 'required',
203
+ params: {
204
+ missingProperty: 'foo'
205
+ },
206
+ }];
207
+ const currentAdditionalErrors = [{
208
+ instancePath: '',
209
+ dataPath: '',
210
+ schemaPath: '#/required',
211
+ keyword: 'required',
212
+ params: {
213
+ missingProperty: 'bar'
214
+ },
215
+ }];
216
+ const after = coreReducer(
217
+ {
218
+ data: {},
219
+ schema: {},
220
+ uischema: {
221
+ type: 'Label'
222
+ },
223
+ additionalErrors: prevAdditionalErrors
224
+ },
225
+ init({}, schema, undefined, { additionalErrors: currentAdditionalErrors })
226
+ );
227
+ t.deepEqual(after.additionalErrors, currentAdditionalErrors);
228
+ });
229
+
176
230
  test('core reducer - previous state - init with empty options should not overwrite', t => {
177
231
  const schema: JsonSchema = {
178
232
  type: 'object',
@@ -184,6 +238,15 @@ test('core reducer - previous state - init with empty options should not overwri
184
238
  }
185
239
  };
186
240
  const myAjv = new Ajv();
241
+ const additionalErrors = [{
242
+ instancePath: '',
243
+ dataPath: '',
244
+ schemaPath: '#/required',
245
+ keyword: 'required',
246
+ params: {
247
+ missingProperty: 'foo'
248
+ },
249
+ }];
187
250
  const after = coreReducer(
188
251
  {
189
252
  data: {},
@@ -192,10 +255,12 @@ test('core reducer - previous state - init with empty options should not overwri
192
255
  type: 'Label'
193
256
  },
194
257
  ajv: myAjv,
258
+ additionalErrors
195
259
  },
196
260
  init({}, schema, undefined, {})
197
261
  );
198
262
  t.deepEqual(after.ajv, myAjv);
263
+ t.deepEqual(after.additionalErrors, additionalErrors);
199
264
  });
200
265
 
201
266
  test('core reducer - previous state - init with undefined data should not change data', t => {
@@ -1181,6 +1246,108 @@ test('errorAt respects hide validation mode', t => {
1181
1246
  t.is(errorAt('animal', schema)(core).length, 0);
1182
1247
  })
1183
1248
 
1249
+ test('errorAt contains additionalErrors', t => {
1250
+ const schema = {
1251
+ type: 'object',
1252
+ properties: {
1253
+ animal: {
1254
+ type: 'string'
1255
+ }
1256
+ }
1257
+ };
1258
+
1259
+ const data = {
1260
+ animal: 100
1261
+ };
1262
+
1263
+ const additionalErrors = [{
1264
+ instancePath: '',
1265
+ dataPath: '',
1266
+ schemaPath: '#/required',
1267
+ keyword: 'required',
1268
+ params: {
1269
+ missingProperty: 'animal'
1270
+ },
1271
+ }];
1272
+ const core: JsonFormsCore = coreReducer(
1273
+ undefined,
1274
+ init(data, schema, undefined, { additionalErrors })
1275
+ );
1276
+ t.is(core.errors.length, 1);
1277
+ t.is(core.additionalErrors.length, 1);
1278
+ const errorsAt = errorAt('animal', schema)(core);
1279
+ t.is(errorsAt.length, 2);
1280
+ t.true(errorsAt.indexOf(additionalErrors[0]) > -1);
1281
+ });
1282
+
1283
+ test('errorAt contains additionalErrors for validation mode NoValidation ', t => {
1284
+ const schema = {
1285
+ type: 'object',
1286
+ properties: {
1287
+ animal: {
1288
+ type: 'string'
1289
+ }
1290
+ }
1291
+ };
1292
+
1293
+ const data = {
1294
+ animal: 100
1295
+ };
1296
+
1297
+ const additionalErrors = [{
1298
+ instancePath: '',
1299
+ dataPath: '',
1300
+ schemaPath: '#/required',
1301
+ keyword: 'required',
1302
+ params: {
1303
+ missingProperty: 'animal'
1304
+ },
1305
+ }];
1306
+ const core: JsonFormsCore = coreReducer(
1307
+ undefined,
1308
+ init(data, schema, undefined, { additionalErrors, validationMode: 'NoValidation' })
1309
+ );
1310
+ t.is(core.errors.length, 0);
1311
+ t.is(core.additionalErrors.length, 1);
1312
+ const errorsAt = errorAt('animal', schema)(core);
1313
+ t.is(errorsAt.length, 1);
1314
+ t.is(errorsAt.indexOf(additionalErrors[0]), 0);
1315
+ });
1316
+
1317
+ test('errorAt contains additionalErrors for validation mode ValidateAndHide ', t => {
1318
+ const schema = {
1319
+ type: 'object',
1320
+ properties: {
1321
+ animal: {
1322
+ type: 'string'
1323
+ }
1324
+ }
1325
+ };
1326
+
1327
+ const data = {
1328
+ animal: 100
1329
+ };
1330
+
1331
+ const additionalErrors = [{
1332
+ instancePath: '',
1333
+ dataPath: '',
1334
+ schemaPath: '#/required',
1335
+ keyword: 'required',
1336
+ params: {
1337
+ missingProperty: 'animal'
1338
+ },
1339
+ }];
1340
+ const core: JsonFormsCore = coreReducer(
1341
+ undefined,
1342
+ init(data, schema, undefined, { additionalErrors, validationMode: 'ValidateAndHide' })
1343
+ );
1344
+ t.is(core.errors.length, 1);
1345
+ t.is(core.additionalErrors.length, 1);
1346
+ const errorsAt = errorAt('animal', schema)(core);
1347
+ t.is(errorsAt.length, 1);
1348
+ t.is(errorsAt.indexOf(additionalErrors[0]), 0);
1349
+ });
1350
+
1184
1351
  test('core reducer - setValidationMode - No validation should not produce errors', t => {
1185
1352
  const schema = {
1186
1353
  type: 'object',
@@ -1424,7 +1591,7 @@ test('core reducer - update core - unchanged state properties should be unchange
1424
1591
  before,
1425
1592
  updateCore({
1426
1593
  animal: 'cat'
1427
- }, before.schema, before.uischema, before.ajv)
1594
+ }, before.schema, before.uischema, { ajv: before.ajv, additionalErrors: before.additionalErrors })
1428
1595
  );
1429
1596
  t.true(before.schema === afterDataUpdate.schema);
1430
1597
  t.true(before.ajv === afterDataUpdate.ajv);
@@ -1432,6 +1599,7 @@ test('core reducer - update core - unchanged state properties should be unchange
1432
1599
  t.true(before.uischema === afterDataUpdate.uischema);
1433
1600
  t.true(before.validationMode === afterDataUpdate.validationMode);
1434
1601
  t.true(before.validator === afterDataUpdate.validator);
1602
+ t.true(before.additionalErrors === afterDataUpdate.additionalErrors);
1435
1603
 
1436
1604
  const updatedSchema = {
1437
1605
  type: 'object',
@@ -1452,6 +1620,40 @@ test('core reducer - update core - unchanged state properties should be unchange
1452
1620
  t.true(before.data === afterSchemaUpdate.data);
1453
1621
  });
1454
1622
 
1623
+ test('core reducer - update core - additionalErrors should update', t => {
1624
+ const schema = {
1625
+ type: 'object',
1626
+ properties: {
1627
+ animal: {
1628
+ type: 'string'
1629
+ }
1630
+ }
1631
+ };
1632
+
1633
+ const data = {
1634
+ animal: 'dog'
1635
+ };
1636
+ const before: JsonFormsCore = coreReducer(
1637
+ undefined,
1638
+ init(data, schema, undefined, { additionalErrors: [] })
1639
+ );
1640
+
1641
+ const additionalErrors = [{
1642
+ instancePath: '',
1643
+ dataPath: '',
1644
+ schemaPath: '#/required',
1645
+ keyword: 'required',
1646
+ params: {
1647
+ missingProperty: 'animal'
1648
+ },
1649
+ }];
1650
+ const after: JsonFormsCore = coreReducer(
1651
+ before,
1652
+ updateCore(before.data, before.schema, before.uischema, { additionalErrors })
1653
+ );
1654
+ t.true(after.additionalErrors === additionalErrors);
1655
+ });
1656
+
1455
1657
  test('core reducer - setSchema - schema with id', t => {
1456
1658
  const schema: JsonSchema = {
1457
1659
  $id: 'https://www.jsonforms.io/example.json',