@jsonforms/core 3.1.0-alpha.0 → 3.1.0-alpha.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.
Files changed (205) hide show
  1. package/README.md +3 -3
  2. package/lib/Helpers.d.ts +1 -1
  3. package/lib/actions/actions.d.ts +27 -26
  4. package/lib/generators/Generate.d.ts +1 -1
  5. package/lib/generators/schema.d.ts +1 -1
  6. package/lib/i18n/arrayTranslations.d.ts +24 -0
  7. package/lib/i18n/i18nTypes.d.ts +3 -2
  8. package/lib/i18n/i18nUtil.d.ts +5 -2
  9. package/lib/i18n/index.d.ts +1 -0
  10. package/lib/jsonforms-core.cjs.js +428 -259
  11. package/lib/jsonforms-core.cjs.js.map +1 -1
  12. package/lib/jsonforms-core.esm.js +313 -200
  13. package/lib/jsonforms-core.esm.js.map +1 -1
  14. package/lib/models/jsonSchema.d.ts +2 -2
  15. package/lib/models/uischema.d.ts +1 -1
  16. package/lib/reducers/cells.d.ts +2 -2
  17. package/lib/reducers/config.d.ts +1 -1
  18. package/lib/reducers/core.d.ts +3 -2
  19. package/lib/reducers/default-data.d.ts +1 -1
  20. package/lib/reducers/i18n.d.ts +1 -1
  21. package/lib/reducers/reducers.d.ts +4 -4
  22. package/lib/reducers/renderers.d.ts +2 -2
  23. package/lib/reducers/selectors.d.ts +6 -6
  24. package/lib/reducers/uischemas.d.ts +2 -2
  25. package/lib/store.d.ts +3 -3
  26. package/lib/testers/testers.d.ts +1 -1
  27. package/lib/util/cell.d.ts +3 -4
  28. package/lib/util/combinators.d.ts +1 -1
  29. package/lib/util/label.d.ts +1 -1
  30. package/lib/util/path.d.ts +6 -3
  31. package/lib/util/renderer.d.ts +11 -7
  32. package/lib/util/resolvers.d.ts +1 -1
  33. package/lib/util/runtime.d.ts +2 -2
  34. package/lib/util/util.d.ts +2 -2
  35. package/lib/util/validator.d.ts +1 -1
  36. package/package.json +16 -5
  37. package/src/Helpers.ts +2 -2
  38. package/src/actions/actions.ts +59 -61
  39. package/src/configDefault.ts +1 -1
  40. package/src/generators/Generate.ts +4 -2
  41. package/src/generators/schema.ts +30 -26
  42. package/src/generators/uischema.ts +7 -6
  43. package/src/i18n/arrayTranslations.ts +54 -0
  44. package/src/i18n/i18nTypes.ts +12 -7
  45. package/src/i18n/i18nUtil.ts +66 -16
  46. package/src/i18n/index.ts +1 -0
  47. package/src/models/draft4.ts +33 -33
  48. package/src/models/jsonSchema.ts +2 -2
  49. package/src/models/uischema.ts +18 -7
  50. package/src/reducers/cells.ts +10 -9
  51. package/src/reducers/config.ts +1 -1
  52. package/src/reducers/core.ts +115 -75
  53. package/src/reducers/default-data.ts +8 -8
  54. package/src/reducers/i18n.ts +22 -10
  55. package/src/reducers/reducers.ts +24 -34
  56. package/src/reducers/renderers.ts +9 -9
  57. package/src/reducers/selectors.ts +10 -11
  58. package/src/reducers/uischemas.ts +27 -26
  59. package/src/store.ts +4 -4
  60. package/src/testers/testers.ts +200 -147
  61. package/src/util/cell.ts +27 -29
  62. package/src/util/combinators.ts +6 -4
  63. package/src/util/label.ts +2 -2
  64. package/src/util/path.ts +15 -8
  65. package/src/util/renderer.ts +123 -72
  66. package/src/util/resolvers.ts +16 -14
  67. package/src/util/runtime.ts +4 -4
  68. package/src/util/schema.ts +1 -1
  69. package/src/util/type.ts +5 -3
  70. package/src/util/uischema.ts +9 -9
  71. package/src/util/util.ts +54 -54
  72. package/src/util/validator.ts +2 -2
  73. package/.nycrc +0 -6
  74. package/docs/assets/css/main.css +0 -1
  75. package/docs/assets/images/icons.png +0 -0
  76. package/docs/assets/images/icons@2x.png +0 -0
  77. package/docs/assets/images/widgets.png +0 -0
  78. package/docs/assets/images/widgets@2x.png +0 -0
  79. package/docs/assets/js/main.js +0 -51
  80. package/docs/assets/js/search.json +0 -1
  81. package/docs/classes/gen.html +0 -406
  82. package/docs/enums/ruleeffect.html +0 -214
  83. package/docs/globals.html +0 -10568
  84. package/docs/index.html +0 -1297
  85. package/docs/interfaces/action.html +0 -166
  86. package/docs/interfaces/addcellrendereraction.html +0 -181
  87. package/docs/interfaces/addrendereraction.html +0 -181
  88. package/docs/interfaces/adduischemaaction.html +0 -181
  89. package/docs/interfaces/andcondition.html +0 -181
  90. package/docs/interfaces/anyaction.html +0 -189
  91. package/docs/interfaces/arraycontrolprops.html +0 -653
  92. package/docs/interfaces/arraylayoutprops.html +0 -648
  93. package/docs/interfaces/categorization.html +0 -281
  94. package/docs/interfaces/category.html +0 -279
  95. package/docs/interfaces/cellprops.html +0 -452
  96. package/docs/interfaces/combinatorrendererprops.html +0 -503
  97. package/docs/interfaces/combinatorsubschemarenderinfo.html +0 -181
  98. package/docs/interfaces/composablecondition.html +0 -193
  99. package/docs/interfaces/condition.html +0 -176
  100. package/docs/interfaces/controlelement.html +0 -280
  101. package/docs/interfaces/controlprops.html +0 -497
  102. package/docs/interfaces/controlstate.html +0 -184
  103. package/docs/interfaces/controlwithdetailprops.html +0 -501
  104. package/docs/interfaces/dispatchcellprops.html +0 -388
  105. package/docs/interfaces/dispatchcellstateprops.html +0 -408
  106. package/docs/interfaces/dispatchpropsofarraycontrol.html +0 -322
  107. package/docs/interfaces/dispatchpropsofcontrol.html +0 -204
  108. package/docs/interfaces/dispatchpropsofmultienumcontrol.html +0 -215
  109. package/docs/interfaces/enumcellprops.html +0 -467
  110. package/docs/interfaces/enumoption.html +0 -167
  111. package/docs/interfaces/formatted.html +0 -226
  112. package/docs/interfaces/grouplayout.html +0 -284
  113. package/docs/interfaces/horizontallayout.html +0 -234
  114. package/docs/interfaces/initaction.html +0 -209
  115. package/docs/interfaces/initactionoptions.html +0 -181
  116. package/docs/interfaces/internationalizable.html +0 -170
  117. package/docs/interfaces/jsonformscellrendererregistryentry.html +0 -167
  118. package/docs/interfaces/jsonformscore.html +0 -251
  119. package/docs/interfaces/jsonformsdefaultdataregistryentry.html +0 -167
  120. package/docs/interfaces/jsonformsextendedstate.html +0 -175
  121. package/docs/interfaces/jsonformsi18nstate.html +0 -181
  122. package/docs/interfaces/jsonformsprops.html +0 -321
  123. package/docs/interfaces/jsonformsrendererregistryentry.html +0 -167
  124. package/docs/interfaces/jsonformsstate.html +0 -170
  125. package/docs/interfaces/jsonformsstore.html +0 -376
  126. package/docs/interfaces/jsonformssubstates.html +0 -276
  127. package/docs/interfaces/jsonformsuischemaregistryentry.html +0 -167
  128. package/docs/interfaces/jsonschema4.html +0 -758
  129. package/docs/interfaces/jsonschema7.html +0 -884
  130. package/docs/interfaces/labelable.html +0 -184
  131. package/docs/interfaces/labeldescription.html +0 -184
  132. package/docs/interfaces/labeled.html +0 -182
  133. package/docs/interfaces/labelelement.html +0 -251
  134. package/docs/interfaces/labelprops.html +0 -339
  135. package/docs/interfaces/layout.html +0 -253
  136. package/docs/interfaces/layoutprops.html +0 -359
  137. package/docs/interfaces/leafcondition.html +0 -209
  138. package/docs/interfaces/orcondition.html +0 -181
  139. package/docs/interfaces/ownpropsofcell.html +0 -321
  140. package/docs/interfaces/ownpropsofcontrol.html +0 -305
  141. package/docs/interfaces/ownpropsofenum.html +0 -161
  142. package/docs/interfaces/ownpropsofenumcell.html +0 -335
  143. package/docs/interfaces/ownpropsofjsonformsrenderer.html +0 -296
  144. package/docs/interfaces/ownpropsoflabel.html +0 -286
  145. package/docs/interfaces/ownpropsoflayout.html +0 -305
  146. package/docs/interfaces/ownpropsofmasterlistitem.html +0 -289
  147. package/docs/interfaces/ownpropsofrenderer.html +0 -292
  148. package/docs/interfaces/referenceschemamap.html +0 -138
  149. package/docs/interfaces/registerdefaultdataaction.html +0 -181
  150. package/docs/interfaces/removecellrendereraction.html +0 -181
  151. package/docs/interfaces/removerendereraction.html +0 -181
  152. package/docs/interfaces/removeuischemaaction.html +0 -167
  153. package/docs/interfaces/rendererprops.html +0 -331
  154. package/docs/interfaces/rule.html +0 -185
  155. package/docs/interfaces/schemabasedcondition.html +0 -202
  156. package/docs/interfaces/scopable.html +0 -171
  157. package/docs/interfaces/scoped.html +0 -183
  158. package/docs/interfaces/setajvaction.html +0 -167
  159. package/docs/interfaces/setconfigaction.html +0 -167
  160. package/docs/interfaces/setlocaleaction.html +0 -167
  161. package/docs/interfaces/setschemaaction.html +0 -167
  162. package/docs/interfaces/settranslatoraction.html +0 -181
  163. package/docs/interfaces/setuischemaaction.html +0 -167
  164. package/docs/interfaces/setvalidationmodeaction.html +0 -167
  165. package/docs/interfaces/statepropsofarraycontrol.html +0 -474
  166. package/docs/interfaces/statepropsofarraylayout.html +0 -461
  167. package/docs/interfaces/statepropsofcell.html +0 -408
  168. package/docs/interfaces/statepropsofcombinator.html +0 -449
  169. package/docs/interfaces/statepropsofcontrol.html +0 -451
  170. package/docs/interfaces/statepropsofcontrolwithdetail.html +0 -463
  171. package/docs/interfaces/statepropsofenumcell.html +0 -422
  172. package/docs/interfaces/statepropsofjsonformsrenderer.html +0 -324
  173. package/docs/interfaces/statepropsoflabel.html +0 -343
  174. package/docs/interfaces/statepropsoflayout.html +0 -369
  175. package/docs/interfaces/statepropsofmasteritem.html +0 -309
  176. package/docs/interfaces/statepropsofrenderer.html +0 -331
  177. package/docs/interfaces/statepropsofscopedrenderer.html +0 -391
  178. package/docs/interfaces/store.html +0 -386
  179. package/docs/interfaces/testercontext.html +0 -184
  180. package/docs/interfaces/uischemaelement.html +0 -225
  181. package/docs/interfaces/unregisterdefaultdataaction.html +0 -167
  182. package/docs/interfaces/updateaction.html +0 -202
  183. package/docs/interfaces/updatecoreaction.html +0 -209
  184. package/docs/interfaces/updateerrorsaction.html +0 -167
  185. package/docs/interfaces/updatei18naction.html +0 -195
  186. package/docs/interfaces/verticallayout.html +0 -234
  187. package/docs/interfaces/withclassname.html +0 -153
  188. package/rollup.config.js +0 -44
  189. package/stats.html +0 -3279
  190. package/test/actions/actions.test.ts +0 -93
  191. package/test/generators/schema.test.ts +0 -224
  192. package/test/generators/uischema.test.ts +0 -576
  193. package/test/i18n/i18nUtil.test.ts +0 -88
  194. package/test/reducers/core.test.ts +0 -1682
  195. package/test/reducers/uischemas.test.ts +0 -173
  196. package/test/testers.test.ts +0 -948
  197. package/test/util/array.test.ts +0 -28
  198. package/test/util/cell.test.ts +0 -354
  199. package/test/util/derivetype.test.ts +0 -101
  200. package/test/util/label.test.ts +0 -364
  201. package/test/util/path.test.ts +0 -259
  202. package/test/util/renderer.test.ts +0 -1830
  203. package/test/util/resolvers.test.ts +0 -157
  204. package/test/util/runtime.test.ts +0 -779
  205. package/tsconfig.json +0 -13
@@ -1,364 +0,0 @@
1
- /*
2
- The MIT License
3
-
4
- Copyright (c) 2017-2019 EclipseSource Munich
5
- https://github.com/eclipsesource/jsonforms
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
24
- */
25
- import test from 'ava';
26
-
27
- import { ControlElement } from '../../src';
28
- import { createLabelDescriptionFrom } from '../../src/util';
29
- import { JsonSchema } from '../../src/models/jsonSchema';
30
-
31
- test('control relative - no schema', t => {
32
- const controlElement: ControlElement = {
33
- type: 'Control',
34
- scope: '/properties/foo'
35
- };
36
- const labelObject = createLabelDescriptionFrom(controlElement, undefined);
37
- t.is(labelObject.show, true);
38
- t.is(labelObject.text, 'Foo');
39
- });
40
-
41
- test('control without label string, camel split - no schema', t => {
42
- const controlElement: ControlElement = {
43
- type: 'Control',
44
- scope: '#/properties/fooBarBaz'
45
- };
46
- const labelObject = createLabelDescriptionFrom(controlElement, undefined);
47
- t.is(labelObject.show, true);
48
- t.is(labelObject.text, 'Foo Bar Baz');
49
- });
50
-
51
- test('control with label string - no schema', t => {
52
- const controlElement: ControlElement = {
53
- type: 'Control',
54
- scope: '#/properties/foo',
55
- label: 'bar'
56
- };
57
- const labelObject = createLabelDescriptionFrom(controlElement, undefined);
58
- t.is(labelObject.show, true);
59
- t.is(labelObject.text, 'bar');
60
- });
61
-
62
- test('control with label boolean - no schema', t => {
63
- const controlElement: ControlElement = {
64
- type: 'Control',
65
- scope: '#/properties/foo',
66
- label: true
67
- };
68
- const labelObject = createLabelDescriptionFrom(controlElement, undefined);
69
- t.is(labelObject.show, true);
70
- t.is(labelObject.text, 'Foo');
71
- });
72
-
73
- test('control with label object, empty - no schema', t => {
74
- const controlElement: ControlElement = {
75
- type: 'Control',
76
- scope: '#/properties/foo',
77
- label: {}
78
- };
79
- const labelObject = createLabelDescriptionFrom(controlElement, undefined);
80
- t.is(labelObject.show, true);
81
- t.is(labelObject.text, 'Foo');
82
- });
83
-
84
- test('control with label object, text-only - no schema', t => {
85
- const controlElement: ControlElement = {
86
- type: 'Control',
87
- scope: '#/properties/foo',
88
- label: {
89
- text: 'mega bar'
90
- }
91
- };
92
- const labelObject = createLabelDescriptionFrom(controlElement, undefined);
93
- t.is(labelObject.show, true);
94
- t.is(labelObject.text, 'mega bar');
95
- });
96
-
97
- test('control with label object, visible-only - no schema', t => {
98
- const controlElement: ControlElement = {
99
- type: 'Control',
100
- scope: '#/properties/foo',
101
- label: {
102
- show: true
103
- }
104
- };
105
- const labelObject = createLabelDescriptionFrom(controlElement, undefined);
106
- t.is(labelObject.show, true);
107
- t.is(labelObject.text, 'Foo');
108
- });
109
-
110
- test('control with label object, full - no schema', t => {
111
- const controlElement: ControlElement = {
112
- type: 'Control',
113
- scope: '#/properties/foo',
114
- label: {
115
- show: false,
116
- text: 'mega bar'
117
- }
118
- };
119
- const labelObject = createLabelDescriptionFrom(controlElement, undefined);
120
- t.is(labelObject.show, false);
121
- t.is(labelObject.text, 'mega bar');
122
- });
123
-
124
- test('control relative - schema without title', t => {
125
- const controlElement: ControlElement = {
126
- type: 'Control',
127
- scope: '/properties/foo'
128
- };
129
- const schema: JsonSchema = {
130
- type: 'string'
131
- };
132
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
133
- t.is(labelObject.show, true);
134
- t.is(labelObject.text, 'Foo');
135
- });
136
-
137
- test('control without label string, camel split - schema without title', t => {
138
- const controlElement: ControlElement = {
139
- type: 'Control',
140
- scope: '#/properties/fooBarBaz'
141
- };
142
- const schema: JsonSchema = {
143
- type: 'string'
144
- };
145
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
146
- t.is(labelObject.show, true);
147
- t.is(labelObject.text, 'Foo Bar Baz');
148
- });
149
-
150
- test('control with label string - schema without title', t => {
151
- const controlElement: ControlElement = {
152
- type: 'Control',
153
- scope: '#/properties/foo',
154
- label: 'bar'
155
- };
156
- const schema: JsonSchema = {
157
- type: 'string'
158
- };
159
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
160
- t.is(labelObject.show, true);
161
- t.is(labelObject.text, 'bar');
162
- });
163
-
164
- test('control with label boolean - schema without title', t => {
165
- const controlElement: ControlElement = {
166
- type: 'Control',
167
- scope: '#/properties/foo',
168
- label: true
169
- };
170
- const schema: JsonSchema = {
171
- type: 'string'
172
- };
173
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
174
- t.is(labelObject.show, true);
175
- t.is(labelObject.text, 'Foo');
176
- });
177
-
178
- test('control with label object, empty - schema without title', t => {
179
- const controlElement: ControlElement = {
180
- type: 'Control',
181
- scope: '#/properties/foo',
182
- label: {}
183
- };
184
- const schema: JsonSchema = {
185
- type: 'string'
186
- };
187
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
188
- t.is(labelObject.show, true);
189
- t.is(labelObject.text, 'Foo');
190
- });
191
-
192
- test('control with label object, text-only - schema without title', t => {
193
- const controlElement: ControlElement = {
194
- type: 'Control',
195
- scope: '#/properties/foo',
196
- label: {
197
- text: 'mega bar'
198
- }
199
- };
200
- const schema: JsonSchema = {
201
- type: 'string'
202
- };
203
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
204
- t.is(labelObject.show, true);
205
- t.is(labelObject.text, 'mega bar');
206
- });
207
-
208
- test('control with label object, visible-only - schema without title', t => {
209
- const controlElement: ControlElement = {
210
- type: 'Control',
211
- scope: '#/properties/foo',
212
- label: {
213
- show: true
214
- }
215
- };
216
- const schema: JsonSchema = {
217
- type: 'string'
218
- };
219
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
220
- t.is(labelObject.show, true);
221
- t.is(labelObject.text, 'Foo');
222
- });
223
-
224
- test('control with label object, full - schema without title', t => {
225
- const controlElement: ControlElement = {
226
- type: 'Control',
227
- scope: '#/properties/foo',
228
- label: {
229
- show: false,
230
- text: 'mega bar'
231
- }
232
- };
233
- const schema: JsonSchema = {
234
- type: 'string'
235
- };
236
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
237
- t.is(labelObject.show, false);
238
- t.is(labelObject.text, 'mega bar');
239
- });
240
-
241
- test('control relative - schema with title', t => {
242
- const controlElement: ControlElement = {
243
- type: 'Control',
244
- scope: '/properties/foo'
245
- };
246
- const schema: JsonSchema = {
247
- type: 'string',
248
- title: 'Schema Title'
249
- };
250
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
251
- t.is(labelObject.show, true);
252
- t.is(labelObject.text, 'Schema Title');
253
- });
254
-
255
- test('control without label string, camel split - schema with title', t => {
256
- const controlElement: ControlElement = {
257
- type: 'Control',
258
- scope: '#/properties/fooBarBaz'
259
- };
260
- const schema: JsonSchema = {
261
- type: 'string',
262
- title: 'Schema Title'
263
- };
264
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
265
- t.is(labelObject.show, true);
266
- t.is(labelObject.text, 'Schema Title');
267
- });
268
-
269
- test('control with label string - schema with title', t => {
270
- const controlElement: ControlElement = {
271
- type: 'Control',
272
- scope: '#/properties/foo',
273
- label: 'bar'
274
- };
275
- const schema: JsonSchema = {
276
- type: 'string',
277
- title: 'Schema Title'
278
- };
279
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
280
- t.is(labelObject.show, true);
281
- t.is(labelObject.text, 'bar');
282
- });
283
-
284
- test('control with label boolean - schema with title', t => {
285
- const controlElement: ControlElement = {
286
- type: 'Control',
287
- scope: '#/properties/foo',
288
- label: true
289
- };
290
- const schema: JsonSchema = {
291
- type: 'string',
292
- title: 'Schema Title'
293
- };
294
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
295
- t.is(labelObject.show, true);
296
- t.is(labelObject.text, 'Schema Title');
297
- });
298
-
299
- test('control with label object, empty - schema with title', t => {
300
- const controlElement: ControlElement = {
301
- type: 'Control',
302
- scope: '#/properties/foo',
303
- label: {}
304
- };
305
- const schema: JsonSchema = {
306
- type: 'string',
307
- title: 'Schema Title'
308
- };
309
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
310
- t.is(labelObject.show, true);
311
- t.is(labelObject.text, 'Schema Title');
312
- });
313
-
314
- test('control with label object, text-only - schema with title', t => {
315
- const controlElement: ControlElement = {
316
- type: 'Control',
317
- scope: '#/properties/foo',
318
- label: {
319
- text: 'mega bar'
320
- }
321
- };
322
- const schema: JsonSchema = {
323
- type: 'string',
324
- title: 'Schema Title'
325
- };
326
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
327
- t.is(labelObject.show, true);
328
- t.is(labelObject.text, 'mega bar');
329
- });
330
-
331
- test('control with label object, visible-only - schema with title', t => {
332
- const controlElement: ControlElement = {
333
- type: 'Control',
334
- scope: '#/properties/foo',
335
- label: {
336
- show: true
337
- }
338
- };
339
- const schema: JsonSchema = {
340
- type: 'string',
341
- title: 'Schema Title'
342
- };
343
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
344
- t.is(labelObject.show, true);
345
- t.is(labelObject.text, 'Schema Title');
346
- });
347
-
348
- test('control with label object, full - schema with title', t => {
349
- const controlElement: ControlElement = {
350
- type: 'Control',
351
- scope: '#/properties/foo',
352
- label: {
353
- show: false,
354
- text: 'mega bar'
355
- }
356
- };
357
- const schema: JsonSchema = {
358
- type: 'string',
359
- title: 'Schema Title'
360
- };
361
- const labelObject = createLabelDescriptionFrom(controlElement, schema);
362
- t.is(labelObject.show, false);
363
- t.is(labelObject.text, 'mega bar');
364
- });
@@ -1,259 +0,0 @@
1
- /*
2
- The MIT License
3
-
4
- Copyright (c) 2017-2019 EclipseSource Munich
5
- https://github.com/eclipsesource/jsonforms
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
24
- */
25
- import test from 'ava';
26
- import { JsonSchema } from '../../src';
27
- import { Resolve, toDataPath } from '../../src/util';
28
-
29
- test('resolve ', t => {
30
- const schema: JsonSchema = {
31
- type: 'object',
32
- properties: {
33
- foo: {
34
- type: 'integer'
35
- }
36
- }
37
- };
38
- t.deepEqual(Resolve.schema(schema, '#/properties/foo', schema), {
39
- type: 'integer'
40
- });
41
- });
42
-
43
- test('toDataPath ', t => {
44
- t.is(toDataPath('#/properties/foo/properties/bar'), 'foo.bar');
45
- });
46
- test('toDataPath replace anyOf', t => {
47
- t.is(toDataPath('/anyOf/1/properties/foo/anyOf/1/properties/bar'), 'foo.bar');
48
- });
49
- test('toDataPath replace anyOf in combination with conditional schema compositions', t => {
50
- t.is(toDataPath('/anyOf/1/then/properties/foo'), 'foo');
51
- });
52
- test('toDataPath replace multiple directly nested anyOf in combination with conditional schema compositions', t => {
53
- t.is(toDataPath('/anyOf/1/then/anyOf/0/then/properties/foo'), 'foo');
54
- });
55
- test('toDataPath replace multiple nested properties with anyOf in combination with conditional schema compositions', t => {
56
- t.is(toDataPath('/anyOf/1/properties/foo/anyOf/0/then/properties/bar'), 'foo.bar');
57
- });
58
- test('toDataPath replace allOf', t => {
59
- t.is(toDataPath('/allOf/1/properties/foo/allOf/1/properties/bar'), 'foo.bar');
60
- });
61
- test('toDataPath replace allOf in combination with conditional schema compositions', t => {
62
- t.is(toDataPath('/allOf/1/then/properties/foo'), 'foo');
63
- });
64
- test('toDataPath replace multiple directly nested allOf in combination with conditional schema compositions', t => {
65
- t.is(toDataPath('/allOf/1/then/allOf/0/then/properties/foo'), 'foo');
66
- });
67
- test('toDataPath replace multiple nested properties with allOf in combination with conditional schema compositions', t => {
68
- t.is(toDataPath('/allOf/1/properties/foo/allOf/0/then/properties/bar'), 'foo.bar');
69
- });
70
- test('toDataPath replace oneOf', t => {
71
- t.is(toDataPath('/oneOf/1/properties/foo/oneOf/1/properties/bar'), 'foo.bar');
72
- });
73
- test('toDataPath replace oneOf in combination with conditional schema compositions', t => {
74
- t.is(toDataPath('/oneOf/1/then/properties/foo'), 'foo');
75
- });
76
- test('toDataPath replace multiple directly nested oneOf in combination with conditional schema compositions', t => {
77
- t.is(toDataPath('/oneOf/1/then/oneOf/0/then/properties/foo'), 'foo');
78
- });
79
- test('toDataPath replace multiple nested properties with oneOf in combination with conditional schema compositions', t => {
80
- t.is(toDataPath('/oneOf/1/properties/foo/oneOf/0/then/properties/bar'), 'foo.bar');
81
- });
82
- test('toDataPath replace all combinators', t => {
83
- t.is(
84
- toDataPath(
85
- '/oneOf/1/properties/foo/anyOf/1/properties/bar/allOf/1/properties/foobar'
86
- ),
87
- 'foo.bar.foobar'
88
- );
89
- });
90
- test('toDataPath use of keywords', t => {
91
- t.is(toDataPath('#/properties/properties'), 'properties');
92
- });
93
- test('toDataPath use of encoded paths', t => {
94
- const fooBar = encodeURIComponent('foo.bar');
95
- t.is(toDataPath(`#/properties/${fooBar}`), `${fooBar}`);
96
- });
97
- test('toDataPath relative with /', t => {
98
- t.is(toDataPath('/properties/foo/properties/bar'), 'foo.bar');
99
- });
100
- test('toDataPath use of keywords relative with /', t => {
101
- t.is(toDataPath('/properties/properties'), 'properties');
102
- });
103
- test('toDataPath use of encoded paths relative with /', t => {
104
- const fooBar = encodeURIComponent('foo/bar');
105
- t.is(toDataPath(`/properties/${fooBar}`), `${fooBar}`);
106
- });
107
- test('toDataPath relative without /', t => {
108
- t.is(toDataPath('properties/foo/properties/bar'), 'foo.bar');
109
- });
110
- test('toDataPath use of keywords relative without /', t => {
111
- t.is(toDataPath('properties/properties'), 'properties');
112
- });
113
- test('toDataPath use of encoded paths relative without /', t => {
114
- const fooBar = encodeURIComponent('foo/bar');
115
- t.is(toDataPath(`properties/${fooBar}`), `${fooBar}`);
116
- });
117
- test('toDataPath use of encoded special character in pathname', t => {
118
- t.is(toDataPath('properties/foo~0bar~1baz'), 'foo~bar/baz');
119
- });
120
- test('resolve instance', t => {
121
- const instance = { foo: 123 };
122
- const result = Resolve.data(instance, toDataPath('#/properties/foo'));
123
- t.is(result, 123);
124
- });
125
- test('resolve instance with keywords', t => {
126
- const instance = { properties: 123 };
127
- const result = Resolve.data(instance, toDataPath('#/properties/properties'));
128
- t.is(result, 123);
129
- });
130
- test('resolve instance with encoded', t => {
131
- const instance = { 'foo/bar': 123 };
132
- const fooBar = encodeURIComponent('foo/bar');
133
- const result = Resolve.data(instance, toDataPath(`#/properties/${fooBar}`));
134
- t.is(result, 123);
135
- });
136
- test('resolve nested instance', t => {
137
- const instance = { foo: { bar: 123 } };
138
- const result = Resolve.data(
139
- instance,
140
- toDataPath('#/properties/foo/properties/bar')
141
- );
142
- t.is(result, 123);
143
- });
144
- test('resolve uninitiated instance', t => {
145
- const instance = {};
146
- const result = Resolve.data(
147
- instance,
148
- toDataPath('#/properties/foo/properties/bar')
149
- );
150
- t.is(result, undefined);
151
- });
152
- test('resolve $ref', t => {
153
- const schema: JsonSchema = {
154
- definitions: {
155
- foo: {
156
- type: 'string'
157
- }
158
- },
159
- type: 'object',
160
- properties: {
161
- foos: {
162
- type: 'array',
163
- items: {
164
- $ref: '#/definitions/foo'
165
- }
166
- }
167
- }
168
- };
169
- const result = Resolve.schema(schema, '#/properties/foos/items', schema);
170
- t.deepEqual(result, { type: 'string' });
171
- });
172
- test('resolve $ref simple', t => {
173
- const schema: JsonSchema = {
174
- definitions: {
175
- foo: {
176
- type: 'object',
177
- properties: {
178
- bar: {
179
- type: 'array',
180
- items: {
181
- $ref: '#/definitions/foo'
182
- }
183
- }
184
- }
185
- }
186
- },
187
- type: 'object',
188
- properties: {
189
- foos: {
190
- type: 'array',
191
- items: {
192
- $ref: '#/definitions/foo'
193
- }
194
- }
195
- }
196
- };
197
- const result = Resolve.schema(schema, '#/properties/foos/items', schema);
198
- t.deepEqual(result, {
199
- type: 'object',
200
- properties: {
201
- bar: {
202
- type: 'array',
203
- items: {
204
- $ref: '#/definitions/foo'
205
- }
206
- }
207
- }
208
- });
209
- t.not((schema.definitions.foo.properties.bar.items as JsonSchema).$ref, '#');
210
- });
211
- test('resolve $ref complicated', t => {
212
- const schema: JsonSchema = {
213
- definitions: {
214
- foo: {
215
- type: 'object',
216
- properties: {
217
- bar: {
218
- type: 'array',
219
- items: {
220
- $ref: '#/definitions/foo2'
221
- }
222
- }
223
- }
224
- },
225
- foo2: {
226
- type: 'object',
227
- properties: {
228
- bar: {
229
- type: 'array',
230
- items: {
231
- $ref: '#/definitions/foo'
232
- }
233
- }
234
- }
235
- }
236
- },
237
- type: 'object',
238
- properties: {
239
- foos: {
240
- type: 'array',
241
- items: {
242
- $ref: '#/definitions/foo'
243
- }
244
- }
245
- }
246
- };
247
- const result = Resolve.schema(schema, '#/properties/foos/items', schema);
248
- t.deepEqual(result, {
249
- type: 'object',
250
- properties: {
251
- bar: {
252
- type: 'array',
253
- items: {
254
- $ref: '#/definitions/foo2'
255
- }
256
- }
257
- }
258
- });
259
- });