@jsonforms/core 2.5.2-alpha.0 → 3.0.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 (273) hide show
  1. package/README.md +1 -1
  2. package/docs/assets/js/search.json +1 -1
  3. package/docs/enums/ruleeffect.html +4 -4
  4. package/docs/globals.html +1061 -1120
  5. package/docs/index.html +64 -91
  6. package/docs/interfaces/addcellrendereraction.html +3 -3
  7. package/docs/interfaces/addrendereraction.html +3 -3
  8. package/docs/interfaces/adduischemaaction.html +3 -3
  9. package/docs/interfaces/andcondition.html +2 -2
  10. package/docs/interfaces/arraycontrolprops.html +22 -22
  11. package/docs/interfaces/arraylayoutprops.html +22 -22
  12. package/docs/interfaces/categorization.html +5 -5
  13. package/docs/interfaces/category.html +5 -5
  14. package/docs/interfaces/cellprops.html +14 -14
  15. package/docs/interfaces/combinatorrendererprops.html +13 -13
  16. package/docs/interfaces/combinatorsubschemarenderinfo.html +3 -3
  17. package/docs/interfaces/composablecondition.html +2 -2
  18. package/docs/interfaces/condition.html +1 -1
  19. package/docs/interfaces/controlelement.html +5 -5
  20. package/docs/interfaces/controlprops.html +17 -17
  21. package/docs/interfaces/controlstate.html +2 -2
  22. package/docs/interfaces/controlwithdetailprops.html +18 -18
  23. package/docs/interfaces/dispatchcellprops.html +13 -13
  24. package/docs/interfaces/dispatchcellstateprops.html +13 -13
  25. package/docs/interfaces/dispatchpropsofarraycontrol.html +4 -4
  26. package/docs/interfaces/dispatchpropsofcontrol.html +1 -1
  27. package/docs/interfaces/dispatchpropsofmultienumcontrol.html +2 -2
  28. package/docs/interfaces/enumcellprops.html +15 -15
  29. package/docs/interfaces/enumoption.html +2 -2
  30. package/docs/interfaces/formatted.html +2 -2
  31. package/docs/interfaces/grouplayout.html +5 -5
  32. package/docs/interfaces/horizontallayout.html +4 -4
  33. package/docs/interfaces/initaction.html +6 -6
  34. package/docs/interfaces/initactionoptions.html +3 -17
  35. package/docs/interfaces/jsonformscellrendererregistryentry.html +2 -2
  36. package/docs/interfaces/jsonformscore.html +7 -21
  37. package/docs/interfaces/jsonformsdefaultdataregistryentry.html +2 -2
  38. package/docs/interfaces/jsonformsextendedstate.html +1 -1
  39. package/docs/interfaces/{jsonformslocalestate.html → jsonformsi18nstate.html} +20 -20
  40. package/docs/interfaces/jsonformsprops.html +9 -24
  41. package/docs/interfaces/jsonformsrendererregistryentry.html +2 -2
  42. package/docs/interfaces/jsonformsstate.html +1 -1
  43. package/docs/interfaces/jsonformsstore.html +5 -5
  44. package/docs/interfaces/jsonformssubstates.html +18 -8
  45. package/docs/interfaces/jsonformsuischemaregistryentry.html +2 -2
  46. package/docs/interfaces/labeldescription.html +2 -2
  47. package/docs/interfaces/labelelement.html +4 -4
  48. package/docs/interfaces/layout.html +4 -4
  49. package/docs/interfaces/layoutprops.html +10 -10
  50. package/docs/interfaces/leafcondition.html +3 -3
  51. package/docs/interfaces/orcondition.html +2 -2
  52. package/docs/interfaces/ownpropsofcell.html +10 -10
  53. package/docs/interfaces/ownpropsofcontrol.html +9 -9
  54. package/docs/interfaces/ownpropsofenum.html +1 -1
  55. package/docs/interfaces/ownpropsofenumcell.html +11 -11
  56. package/docs/interfaces/ownpropsofjsonformsrenderer.html +8 -8
  57. package/docs/interfaces/ownpropsoflayout.html +9 -9
  58. package/docs/interfaces/ownpropsofmasterlistitem.html +6 -6
  59. package/docs/interfaces/ownpropsofrenderer.html +8 -8
  60. package/docs/interfaces/registerdefaultdataaction.html +3 -3
  61. package/docs/interfaces/removecellrendereraction.html +3 -3
  62. package/docs/interfaces/removerendereraction.html +3 -3
  63. package/docs/interfaces/removeuischemaaction.html +2 -2
  64. package/docs/interfaces/rendererprops.html +9 -9
  65. package/docs/interfaces/rule.html +2 -2
  66. package/docs/interfaces/schemabasedcondition.html +3 -3
  67. package/docs/interfaces/scopable.html +1 -1
  68. package/docs/interfaces/setajvaction.html +3 -3
  69. package/docs/interfaces/setconfigaction.html +2 -2
  70. package/docs/interfaces/setlocaleaction.html +3 -3
  71. package/docs/interfaces/setschemaaction.html +2 -2
  72. package/docs/interfaces/{setlocalizeduischemasaction.html → settranslatoraction.html} +29 -15
  73. package/docs/interfaces/setuischemaaction.html +2 -2
  74. package/docs/interfaces/setvalidationmodeaction.html +2 -2
  75. package/docs/interfaces/statepropsofarraycontrol.html +18 -18
  76. package/docs/interfaces/statepropsofarraylayout.html +18 -18
  77. package/docs/interfaces/statepropsofcell.html +13 -13
  78. package/docs/interfaces/statepropsofcombinator.html +12 -12
  79. package/docs/interfaces/statepropsofcontrol.html +16 -16
  80. package/docs/interfaces/statepropsofcontrolwithdetail.html +17 -17
  81. package/docs/interfaces/statepropsofenumcell.html +14 -14
  82. package/docs/interfaces/statepropsofjsonformsrenderer.html +9 -23
  83. package/docs/interfaces/statepropsoflayout.html +10 -10
  84. package/docs/interfaces/statepropsofmasteritem.html +7 -7
  85. package/docs/interfaces/statepropsofrenderer.html +9 -9
  86. package/docs/interfaces/statepropsofscopedrenderer.html +12 -12
  87. package/docs/interfaces/uischemaelement.html +3 -3
  88. package/docs/interfaces/unregisterdefaultdataaction.html +2 -2
  89. package/docs/interfaces/updateaction.html +3 -3
  90. package/docs/interfaces/updatecoreaction.html +6 -6
  91. package/docs/interfaces/updateerrorsaction.html +2 -2
  92. package/docs/interfaces/{setlocalizedschemasaction.html → updatei18naction.html} +43 -15
  93. package/docs/interfaces/verticallayout.html +4 -4
  94. package/docs/interfaces/withclassname.html +1 -1
  95. package/lib/Helpers.d.ts +5 -0
  96. package/lib/Helpers.js +33 -0
  97. package/lib/Helpers.js.map +1 -0
  98. package/lib/actions/actions.d.ts +181 -0
  99. package/lib/actions/actions.js +173 -0
  100. package/lib/actions/actions.js.map +1 -0
  101. package/lib/actions/index.d.ts +1 -180
  102. package/lib/actions/index.js +26 -122
  103. package/lib/actions/index.js.map +1 -1
  104. package/lib/configDefault.js +2 -1
  105. package/lib/configDefault.js.map +1 -1
  106. package/lib/generators/Generate.d.ts +6 -0
  107. package/lib/generators/Generate.js +35 -0
  108. package/lib/generators/Generate.js.map +1 -0
  109. package/lib/generators/index.d.ts +3 -10
  110. package/lib/generators/index.js +28 -9
  111. package/lib/generators/index.js.map +1 -1
  112. package/lib/generators/schema.d.ts +1 -1
  113. package/lib/generators/schema.js +3 -1
  114. package/lib/generators/schema.js.map +1 -1
  115. package/lib/generators/uischema.d.ts +1 -2
  116. package/lib/generators/uischema.js +12 -10
  117. package/lib/generators/uischema.js.map +1 -1
  118. package/lib/i18n/i18nTypes.d.ts +15 -0
  119. package/lib/i18n/i18nTypes.js +3 -0
  120. package/lib/i18n/i18nTypes.js.map +1 -0
  121. package/lib/i18n/i18nUtil.d.ts +11 -0
  122. package/lib/i18n/i18nUtil.js +58 -0
  123. package/lib/i18n/i18nUtil.js.map +1 -0
  124. package/lib/i18n/index.d.ts +2 -0
  125. package/lib/i18n/index.js +6 -0
  126. package/lib/i18n/index.js.map +1 -0
  127. package/lib/index.d.ts +6 -18
  128. package/lib/index.js +10 -15
  129. package/lib/index.js.map +1 -1
  130. package/lib/jsonforms-core.js +9 -12
  131. package/lib/jsonforms-core.js.map +1 -1
  132. package/lib/models/draft4.js +2 -1
  133. package/lib/models/draft4.js.map +1 -1
  134. package/lib/models/index.d.ts +5 -0
  135. package/lib/models/index.js +33 -0
  136. package/lib/models/index.js.map +1 -0
  137. package/lib/models/jsonSchema.js +24 -0
  138. package/lib/models/jsonSchema.js.map +1 -1
  139. package/lib/models/uischema.js +29 -2
  140. package/lib/models/uischema.js.map +1 -1
  141. package/lib/reducers/cells.d.ts +1 -1
  142. package/lib/reducers/cells.js +27 -1
  143. package/lib/reducers/cells.js.map +1 -1
  144. package/lib/reducers/config.d.ts +1 -1
  145. package/lib/reducers/config.js +5 -3
  146. package/lib/reducers/config.js.map +1 -1
  147. package/lib/reducers/core.d.ts +5 -7
  148. package/lib/reducers/core.js +78 -63
  149. package/lib/reducers/core.js.map +1 -1
  150. package/lib/reducers/default-data.d.ts +1 -1
  151. package/lib/reducers/default-data.js +6 -3
  152. package/lib/reducers/default-data.js.map +1 -1
  153. package/lib/reducers/i18n.d.ts +8 -11
  154. package/lib/reducers/i18n.js +40 -23
  155. package/lib/reducers/i18n.js.map +1 -1
  156. package/lib/reducers/index.d.ts +9 -49
  157. package/lib/reducers/index.js +33 -91
  158. package/lib/reducers/index.js.map +1 -1
  159. package/lib/reducers/reducers.d.ts +37 -0
  160. package/lib/reducers/reducers.js +107 -0
  161. package/lib/reducers/reducers.js.map +1 -0
  162. package/lib/reducers/renderers.d.ts +1 -1
  163. package/lib/reducers/renderers.js +27 -1
  164. package/lib/reducers/renderers.js.map +1 -1
  165. package/lib/reducers/selectors.d.ts +15 -0
  166. package/lib/reducers/selectors.js +56 -0
  167. package/lib/reducers/selectors.js.map +1 -0
  168. package/lib/reducers/uischemas.d.ts +2 -2
  169. package/lib/reducers/uischemas.js +9 -6
  170. package/lib/reducers/uischemas.js.map +1 -1
  171. package/lib/store.d.ts +5 -8
  172. package/lib/store.js +24 -0
  173. package/lib/store.js.map +1 -1
  174. package/lib/testers/index.d.ts +1 -204
  175. package/lib/testers/index.js +3 -376
  176. package/lib/testers/index.js.map +1 -1
  177. package/lib/testers/testers.d.ts +203 -0
  178. package/lib/testers/testers.js +421 -0
  179. package/lib/testers/testers.js.map +1 -0
  180. package/lib/util/Formatted.js +24 -0
  181. package/lib/util/Formatted.js.map +1 -1
  182. package/lib/util/array.js +25 -0
  183. package/lib/util/array.js.map +1 -1
  184. package/lib/util/cell.d.ts +11 -4
  185. package/lib/util/cell.js +61 -17
  186. package/lib/util/cell.js.map +1 -1
  187. package/lib/util/combinators.d.ts +2 -3
  188. package/lib/util/combinators.js +5 -2
  189. package/lib/util/combinators.js.map +1 -1
  190. package/lib/util/ids.js +8 -4
  191. package/lib/util/ids.js.map +1 -1
  192. package/lib/util/index.d.ts +11 -45
  193. package/lib/util/index.js +14 -104
  194. package/lib/util/index.js.map +1 -1
  195. package/lib/util/label.d.ts +1 -2
  196. package/lib/util/label.js +7 -4
  197. package/lib/util/label.js.map +1 -1
  198. package/lib/util/path.d.ts +2 -1
  199. package/lib/util/path.js +12 -6
  200. package/lib/util/path.js.map +1 -1
  201. package/lib/util/renderer.d.ts +17 -17
  202. package/lib/util/renderer.js +163 -76
  203. package/lib/util/renderer.js.map +1 -1
  204. package/lib/util/resolvers.d.ts +1 -14
  205. package/lib/util/resolvers.js +9 -215
  206. package/lib/util/resolvers.js.map +1 -1
  207. package/lib/util/runtime.d.ts +12 -2
  208. package/lib/util/runtime.js +59 -17
  209. package/lib/util/runtime.js.map +1 -1
  210. package/lib/util/schema.js +27 -1
  211. package/lib/util/schema.js.map +1 -1
  212. package/lib/util/uischema.d.ts +1 -1
  213. package/lib/util/uischema.js +11 -7
  214. package/lib/util/uischema.js.map +1 -1
  215. package/lib/util/util.d.ts +31 -0
  216. package/lib/util/util.js +112 -0
  217. package/lib/util/util.js.map +1 -0
  218. package/lib/util/validator.d.ts +3 -2
  219. package/lib/util/validator.js +6 -5
  220. package/lib/util/validator.js.map +1 -1
  221. package/package.json +7 -9
  222. package/src/Helpers.ts +38 -0
  223. package/src/actions/actions.ts +345 -0
  224. package/src/actions/index.ts +1 -312
  225. package/src/configDefault.ts +1 -0
  226. package/src/generators/Generate.ts +43 -0
  227. package/src/generators/index.ts +3 -21
  228. package/src/generators/schema.ts +1 -1
  229. package/src/generators/uischema.ts +4 -4
  230. package/src/i18n/i18nTypes.ts +17 -0
  231. package/src/i18n/i18nUtil.ts +76 -0
  232. package/src/i18n/index.ts +2 -0
  233. package/src/index.ts +7 -31
  234. package/src/models/draft4.ts +1 -0
  235. package/src/models/index.ts +30 -0
  236. package/src/models/jsonSchema.ts +1 -0
  237. package/src/models/uischema.ts +1 -0
  238. package/src/reducers/cells.ts +2 -1
  239. package/src/reducers/config.ts +2 -1
  240. package/src/reducers/core.ts +74 -81
  241. package/src/reducers/default-data.ts +2 -1
  242. package/src/reducers/i18n.ts +42 -35
  243. package/src/reducers/index.ts +9 -158
  244. package/src/reducers/reducers.ts +148 -0
  245. package/src/reducers/renderers.ts +2 -1
  246. package/src/reducers/selectors.ts +65 -0
  247. package/src/reducers/uischemas.ts +4 -2
  248. package/src/store.ts +11 -8
  249. package/src/testers/index.ts +1 -516
  250. package/src/testers/testers.ts +547 -0
  251. package/src/util/Formatted.ts +1 -0
  252. package/src/util/array.ts +25 -0
  253. package/src/util/cell.ts +91 -19
  254. package/src/util/combinators.ts +2 -4
  255. package/src/util/ids.ts +1 -0
  256. package/src/util/index.ts +11 -126
  257. package/src/util/label.ts +2 -2
  258. package/src/util/path.ts +4 -1
  259. package/src/util/renderer.ts +168 -85
  260. package/src/util/resolvers.ts +2 -261
  261. package/src/util/runtime.ts +46 -2
  262. package/src/util/schema.ts +26 -1
  263. package/src/util/uischema.ts +2 -1
  264. package/src/util/util.ts +127 -0
  265. package/src/util/validator.ts +5 -8
  266. package/test/reducers/core.test.ts +31 -223
  267. package/test/util/cell.test.ts +33 -2
  268. package/test/util/renderer.test.ts +483 -3
  269. package/test/util/resolvers.test.ts +1 -59
  270. package/test/util/runtime.test.ts +264 -4
  271. package/docs/interfaces/labels.html +0 -157
  272. package/docs/interfaces/schemaref.html +0 -160
  273. package/docs/interfaces/schemarefs.html +0 -138
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
2
  /*
5
3
  The MIT License
6
4
 
@@ -25,378 +23,7 @@ var tslib_1 = require("tslib");
25
23
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
24
  THE SOFTWARE.
27
25
  */
28
- var isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
29
- var get_1 = tslib_1.__importDefault(require("lodash/get"));
30
- var endsWith_1 = tslib_1.__importDefault(require("lodash/endsWith"));
31
- var last_1 = tslib_1.__importDefault(require("lodash/last"));
32
- var isArray_1 = tslib_1.__importDefault(require("lodash/isArray"));
33
- var reduce_1 = tslib_1.__importDefault(require("lodash/reduce"));
34
- var toPairs_1 = tslib_1.__importDefault(require("lodash/toPairs"));
35
- var includes_1 = tslib_1.__importDefault(require("lodash/includes"));
36
- var resolvers_1 = require("../util/resolvers");
37
- var util_1 = require("../util");
38
- /**
39
- * Constant that indicates that a tester is not capable of handling
40
- * a combination of schema/data.
41
- * @type {number}
42
- */
43
- exports.NOT_APPLICABLE = -1;
44
- exports.isControl = function (uischema) {
45
- return !isEmpty_1.default(uischema) && uischema.scope !== undefined;
46
- };
47
- /**
48
- * Only applicable for Controls.
49
- *
50
- * This function checks whether the given UI schema is of type Control
51
- * and if so, resolves the sub-schema referenced by the control and applies
52
- * the given predicate
53
- *
54
- * @param {(JsonSchema) => boolean} predicate the predicate that should be
55
- * applied to the resolved sub-schema
56
- */
57
- exports.schemaMatches = function (predicate) { return function (uischema, schema) {
58
- if (isEmpty_1.default(uischema) || !exports.isControl(uischema)) {
59
- return false;
60
- }
61
- if (isEmpty_1.default(schema)) {
62
- return false;
63
- }
64
- var schemaPath = uischema.scope;
65
- if (isEmpty_1.default(schemaPath)) {
66
- return false;
67
- }
68
- var currentDataSchema = schema;
69
- if (util_1.hasType(schema, 'object')) {
70
- currentDataSchema = resolvers_1.resolveSchema(schema, schemaPath);
71
- }
72
- if (currentDataSchema === undefined) {
73
- return false;
74
- }
75
- return predicate(currentDataSchema);
76
- }; };
77
- exports.schemaSubPathMatches = function (subPath, predicate) { return function (uischema, schema) {
78
- if (isEmpty_1.default(uischema) || !exports.isControl(uischema)) {
79
- return false;
80
- }
81
- var schemaPath = uischema.scope;
82
- var currentDataSchema = schema;
83
- if (util_1.hasType(schema, 'object')) {
84
- currentDataSchema = resolvers_1.resolveSchema(schema, schemaPath);
85
- }
86
- currentDataSchema = get_1.default(currentDataSchema, subPath);
87
- if (currentDataSchema === undefined) {
88
- return false;
89
- }
90
- return predicate(currentDataSchema);
91
- }; };
92
- /**
93
- * Only applicable for Controls.
94
- *
95
- * This function checks whether the given UI schema is of type Control
96
- * and if so, resolves the sub-schema referenced by the control and checks
97
- * whether the type of the sub-schema matches the expected one.
98
- *
99
- * @param {string} expectedType the expected type of the resolved sub-schema
100
- */
101
- exports.schemaTypeIs = function (expectedType) {
102
- return exports.schemaMatches(function (schema) { return !isEmpty_1.default(schema) && util_1.hasType(schema, expectedType); });
103
- };
104
- /**
105
- * Only applicable for Controls.
106
- *
107
- * This function checks whether the given UI schema is of type Control
108
- * and if so, resolves the sub-schema referenced by the control and checks
109
- * whether the format of the sub-schema matches the expected one.
110
- *
111
- * @param {string} expectedFormat the expected format of the resolved sub-schema
112
- */
113
- exports.formatIs = function (expectedFormat) {
114
- return exports.schemaMatches(function (schema) {
115
- return !isEmpty_1.default(schema) &&
116
- schema.format === expectedFormat &&
117
- schema.type === 'string';
118
- });
119
- };
120
- /**
121
- * Checks whether the given UI schema has the expected type.
122
- *
123
- * @param {string} expected the expected UI schema type
124
- */
125
- exports.uiTypeIs = function (expected) { return function (uischema) { return !isEmpty_1.default(uischema) && uischema.type === expected; }; };
126
- /**
127
- * Checks whether the given UI schema has an option with the given
128
- * name and whether it has the expected value. If no options property
129
- * is set, returns false.
130
- *
131
- * @param {string} optionName the name of the option to check
132
- * @param {any} optionValue the expected value of the option
133
- */
134
- exports.optionIs = function (optionName, optionValue) { return function (uischema) {
135
- if (isEmpty_1.default(uischema)) {
136
- return false;
137
- }
138
- var options = uischema.options;
139
- return !isEmpty_1.default(options) && options[optionName] === optionValue;
140
- }; };
141
- /**
142
- * Only applicable for Controls.
143
- *
144
- * Checks whether the scope of a control ends with the expected string.
145
- *
146
- * @param {string} expected the expected ending of the reference
147
- */
148
- exports.scopeEndsWith = function (expected) { return function (uischema) {
149
- if (isEmpty_1.default(expected) || !exports.isControl(uischema)) {
150
- return false;
151
- }
152
- return endsWith_1.default(uischema.scope, expected);
153
- }; };
154
- /**
155
- * Only applicable for Controls.
156
- *
157
- * Checks whether the last segment of the scope matches the expected string.
158
- *
159
- * @param {string} expected the expected ending of the reference
160
- */
161
- exports.scopeEndIs = function (expected) { return function (uischema) {
162
- if (isEmpty_1.default(expected) || !exports.isControl(uischema)) {
163
- return false;
164
- }
165
- var schemaPath = uischema.scope;
166
- return !isEmpty_1.default(schemaPath) && last_1.default(schemaPath.split('/')) === expected;
167
- }; };
168
- /**
169
- * A tester that allow composing other testers by && them.
170
- *
171
- * @param {Array<Tester>} testers the testers to be composed
172
- */
173
- exports.and = function () {
174
- var testers = [];
175
- for (var _i = 0; _i < arguments.length; _i++) {
176
- testers[_i] = arguments[_i];
177
- }
178
- return function (uischema, schema) { return testers.reduce(function (acc, tester) { return acc && tester(uischema, schema); }, true); };
179
- };
180
- /**
181
- * A tester that allow composing other testers by || them.
182
- *
183
- * @param {Array<Tester>} testers the testers to be composed
184
- */
185
- exports.or = function () {
186
- var testers = [];
187
- for (var _i = 0; _i < arguments.length; _i++) {
188
- testers[_i] = arguments[_i];
189
- }
190
- return function (uischema, schema) { return testers.reduce(function (acc, tester) { return acc || tester(uischema, schema); }, false); };
191
- };
192
- /**
193
- * Create a ranked tester that will associate a number with a given tester, if the
194
- * latter returns true.
195
- *
196
- * @param {number} rank the rank to be returned in case the tester returns true
197
- * @param {Tester} tester a tester
198
- */
199
- exports.rankWith = function (rank, tester) { return function (uischema, schema) {
200
- if (tester(uischema, schema)) {
201
- return rank;
202
- }
203
- return exports.NOT_APPLICABLE;
204
- }; };
205
- exports.withIncreasedRank = function (by, rankedTester) { return function (uischema, schema) {
206
- var rank = rankedTester(uischema, schema);
207
- if (rank === exports.NOT_APPLICABLE) {
208
- return exports.NOT_APPLICABLE;
209
- }
210
- return rank + by;
211
- }; };
212
- /**
213
- * Default tester for boolean.
214
- * @type {RankedTester}
215
- */
216
- exports.isBooleanControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('boolean'));
217
- // TODO: rather check for properties property
218
- exports.isObjectControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('object'));
219
- exports.isAllOfControl = exports.and(exports.uiTypeIs('Control'), exports.schemaMatches(function (schema) { return schema.hasOwnProperty('allOf'); }));
220
- exports.isAnyOfControl = exports.and(exports.uiTypeIs('Control'), exports.schemaMatches(function (schema) { return schema.hasOwnProperty('anyOf'); }));
221
- exports.isOneOfControl = exports.and(exports.uiTypeIs('Control'), exports.schemaMatches(function (schema) { return schema.hasOwnProperty('oneOf'); }));
222
- /**
223
- * Tests whether the given UI schema is of type Control and if the schema
224
- * has a 'date' format.
225
- * @type {Tester}
226
- */
227
- exports.isDateControl = exports.and(exports.uiTypeIs('Control'), exports.formatIs('date'));
228
- /**
229
- * Tests whether the given UI schema is of type Control and if the schema
230
- * has an enum.
231
- * @type {Tester}
232
- */
233
- exports.isEnumControl = exports.and(exports.uiTypeIs('Control'), exports.or(exports.schemaMatches(function (schema) { return schema.hasOwnProperty('enum'); }), exports.schemaMatches(function (schema) { return schema.hasOwnProperty('const'); })));
234
- /**
235
- * Tests whether the given UI schema is of type Control and if the schema
236
- * has an enum based on oneOf.
237
- * @type {Tester}
238
- */
239
- exports.isOneOfEnumControl = exports.and(exports.uiTypeIs('Control'), exports.schemaMatches(function (schema) {
240
- return schema.hasOwnProperty('oneOf') &&
241
- schema.oneOf.every(function (s) { return s.const !== undefined; });
242
- }));
243
- /**
244
- * Tests whether the given UI schema is of type Control and if the schema
245
- * is of type integer
246
- * @type {Tester}
247
- */
248
- exports.isIntegerControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('integer'));
249
- /**
250
- * Tests whether the given UI schema is of type Control and if the schema
251
- * is of type number
252
- * @type {Tester}
253
- */
254
- exports.isNumberControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('number'));
255
- /**
256
- * Tests whether the given UI schema is of type Control and if the schema
257
- * is of type string
258
- * @type {Tester}
259
- */
260
- exports.isStringControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('string'));
261
- /**
262
- * Tests whether the given UI schema is of type Control and if is has
263
- * a 'multi' option.
264
- * @type {Tester}
265
- */
266
- exports.isMultiLineControl = exports.and(exports.uiTypeIs('Control'), exports.optionIs('multi', true));
267
- /**
268
- * Tests whether the given UI schema is of type Control and if the schema
269
- * has a 'time' format.
270
- * @type {Tester}
271
- */
272
- exports.isTimeControl = exports.and(exports.uiTypeIs('Control'), exports.formatIs('time'));
273
- /**
274
- * Tests whether the given UI schema is of type Control and if the schema
275
- * has a 'date-time' format.
276
- * @type {Tester}
277
- */
278
- exports.isDateTimeControl = exports.and(exports.uiTypeIs('Control'), exports.formatIs('date-time'));
279
- /**
280
- * Tests whether the given schema is an array of objects.
281
- * @type {Tester}
282
- */
283
- exports.isObjectArray = exports.and(exports.schemaMatches(function (schema) { return util_1.hasType(schema, 'array') && !Array.isArray(schema.items); } // we don't care about tuples
284
- ), exports.schemaSubPathMatches('items', function (schema) { return util_1.hasType(schema, 'object'); }));
285
- /**
286
- * Tests whether the given UI schema is of type Control and if the schema
287
- * is an array of objects.
288
- * @type {Tester}
289
- */
290
- exports.isObjectArrayControl = exports.and(exports.uiTypeIs('Control'), exports.isObjectArray);
291
- var traverse = function (any, pred) {
292
- if (isArray_1.default(any)) {
293
- return reduce_1.default(any, function (acc, el) { return acc || traverse(el, pred); }, false);
294
- }
295
- if (pred(any)) {
296
- return true;
297
- }
298
- if (any.items) {
299
- return traverse(any.items, pred);
300
- }
301
- if (any.properties) {
302
- return reduce_1.default(toPairs_1.default(any.properties), function (acc, _a) {
303
- var _key = _a[0], val = _a[1];
304
- return acc || traverse(val, pred);
305
- }, false);
306
- }
307
- return false;
308
- };
309
- exports.isObjectArrayWithNesting = function (uischema, schema) {
310
- if (!exports.uiTypeIs('Control')(uischema, schema)) {
311
- return false;
312
- }
313
- var schemaPath = uischema.scope;
314
- var resolvedSchema = resolvers_1.resolveSchema(schema, schemaPath);
315
- var wantedNestingByType = {
316
- object: 2,
317
- array: 1
318
- };
319
- if (resolvedSchema !== undefined && resolvedSchema.items !== undefined) {
320
- // check if nested arrays
321
- if (traverse(resolvedSchema.items, function (val) {
322
- if (val === schema) {
323
- return false;
324
- }
325
- // we don't support multiple types
326
- if (typeof val.type !== 'string') {
327
- return true;
328
- }
329
- var typeCount = wantedNestingByType[val.type];
330
- if (typeCount === undefined) {
331
- return false;
332
- }
333
- wantedNestingByType[val.type] = typeCount - 1;
334
- return wantedNestingByType[val.type] === 0;
335
- })) {
336
- return true;
337
- }
338
- // check if uischema options detail is set
339
- if (uischema.options && uischema.options.detail) {
340
- if (typeof uischema.options.detail === 'string') {
341
- return uischema.options.detail.toUpperCase() !== 'DEFAULT';
342
- }
343
- else if (typeof uischema.options.detail === 'object' &&
344
- uischema.options.detail.type) {
345
- return true;
346
- }
347
- }
348
- }
349
- return false;
350
- };
351
- /**
352
- * Synonym for isObjectArrayControl
353
- */
354
- exports.isArrayObjectControl = exports.isObjectArrayControl;
355
- /**
356
- * Tests whether the given UI schema is of type Control and if the schema
357
- * is an array of a primitive type.
358
- * @type {Tester}
359
- */
360
- exports.isPrimitiveArrayControl = exports.and(exports.uiTypeIs('Control'), exports.schemaMatches(function (schema) { return util_1.deriveTypes(schema).length !== 0 && !Array.isArray(schema.items); } // we don't care about tuples
361
- ), exports.schemaSubPathMatches('items', function (schema) {
362
- var types = util_1.deriveTypes(schema);
363
- return (types.length === 1 &&
364
- includes_1.default(['integer', 'number', 'boolean', 'string'], types[0]));
365
- }));
366
- /**
367
- * Tests whether a given UI schema is of type Control,
368
- * if the schema is of type number or integer and
369
- * whether the schema defines a numerical range with a default value.
370
- * @type {Tester}
371
- */
372
- exports.isRangeControl = exports.and(exports.uiTypeIs('Control'), exports.or(exports.schemaTypeIs('number'), exports.schemaTypeIs('integer')), exports.schemaMatches(function (schema) {
373
- return schema.hasOwnProperty('maximum') &&
374
- schema.hasOwnProperty('minimum') &&
375
- schema.hasOwnProperty('default');
376
- }), exports.optionIs('slider', true));
377
- /**
378
- * Tests whether the given UI schema is of type Control, if the schema
379
- * is of type string and has option format
380
- * @type {Tester}
381
- */
382
- exports.isNumberFormatControl = exports.and(exports.uiTypeIs('Control'), exports.schemaTypeIs('integer'), exports.optionIs('format', true));
383
- exports.isCategorization = function (category) { return category.type === 'Categorization'; };
384
- exports.isCategory = function (uischema) {
385
- return uischema.type === 'Category';
386
- };
387
- exports.hasCategory = function (categorization) {
388
- if (isEmpty_1.default(categorization.elements)) {
389
- return false;
390
- }
391
- // all children of the categorization have to be categories
392
- return categorization.elements
393
- .map(function (elem) {
394
- return exports.isCategorization(elem) ? exports.hasCategory(elem) : exports.isCategory(elem);
395
- })
396
- .reduce(function (prev, curr) { return prev && curr; }, true);
397
- };
398
- exports.categorizationHasCategory = function (uischema) {
399
- return exports.hasCategory(uischema);
400
- };
401
- exports.not = function (tester) { return function (uischema, schema) { return !tester(uischema, schema); }; };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ var tslib_1 = require("tslib");
28
+ tslib_1.__exportStar(require("./testers"), exports);
402
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testers/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,mEAAqC;AACrC,2DAA6B;AAC7B,qEAAuC;AACvC,6DAA+B;AAC/B,mEAAqC;AACrC,iEAAmC;AACnC,mEAAqC;AACrC,qEAAuC;AAOvC,+CAAkD;AAClD,gCAA+C;AAE/C;;;;GAIG;AACU,QAAA,cAAc,GAAG,CAAC,CAAC,CAAC;AAcpB,QAAA,SAAS,GAAG,UAAC,QAAa;IACrC,OAAA,CAAC,iBAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;AAAlD,CAAkD,CAAC;AAErD;;;;;;;;;GASG;AACU,QAAA,aAAa,GAAG,UAC3B,SAA0C,IAC/B,OAAA,UAAC,QAAyB,EAAE,MAAkB;IACzD,IAAI,iBAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAS,CAAC,Q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AyB,EAHiB,CAGjB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testers/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;;;AAEF,oDAA0B"}
@@ -0,0 +1,203 @@
1
+ import { Categorization, ControlElement, JsonSchema, UISchemaElement } from '../models';
2
+ /**
3
+ * Constant that indicates that a tester is not capable of handling
4
+ * a combination of schema/data.
5
+ * @type {number}
6
+ */
7
+ export declare const NOT_APPLICABLE = -1;
8
+ /**
9
+ * A tester is a function that receives an UI schema and a JSON schema and returns a boolean.
10
+ */
11
+ export declare type Tester = (uischema: UISchemaElement, schema: JsonSchema) => boolean;
12
+ /**
13
+ * A ranked tester associates a tester with a number.
14
+ */
15
+ export declare type RankedTester = (uischema: UISchemaElement, schema: JsonSchema) => number;
16
+ export declare const isControl: (uischema: any) => uischema is ControlElement;
17
+ /**
18
+ * Only applicable for Controls.
19
+ *
20
+ * This function checks whether the given UI schema is of type Control
21
+ * and if so, resolves the sub-schema referenced by the control and applies
22
+ * the given predicate
23
+ *
24
+ * @param {(JsonSchema) => boolean} predicate the predicate that should be
25
+ * applied to the resolved sub-schema
26
+ */
27
+ export declare const schemaMatches: (predicate: (schema: JsonSchema) => boolean) => Tester;
28
+ export declare const schemaSubPathMatches: (subPath: string, predicate: (schema: JsonSchema) => boolean) => Tester;
29
+ /**
30
+ * Only applicable for Controls.
31
+ *
32
+ * This function checks whether the given UI schema is of type Control
33
+ * and if so, resolves the sub-schema referenced by the control and checks
34
+ * whether the type of the sub-schema matches the expected one.
35
+ *
36
+ * @param {string} expectedType the expected type of the resolved sub-schema
37
+ */
38
+ export declare const schemaTypeIs: (expectedType: string) => Tester;
39
+ /**
40
+ * Only applicable for Controls.
41
+ *
42
+ * This function checks whether the given UI schema is of type Control
43
+ * and if so, resolves the sub-schema referenced by the control and checks
44
+ * whether the format of the sub-schema matches the expected one.
45
+ *
46
+ * @param {string} expectedFormat the expected format of the resolved sub-schema
47
+ */
48
+ export declare const formatIs: (expectedFormat: string) => Tester;
49
+ /**
50
+ * Checks whether the given UI schema has the expected type.
51
+ *
52
+ * @param {string} expected the expected UI schema type
53
+ */
54
+ export declare const uiTypeIs: (expected: string) => Tester;
55
+ /**
56
+ * Checks whether the given UI schema has an option with the given
57
+ * name and whether it has the expected value. If no options property
58
+ * is set, returns false.
59
+ *
60
+ * @param {string} optionName the name of the option to check
61
+ * @param {any} optionValue the expected value of the option
62
+ */
63
+ export declare const optionIs: (optionName: string, optionValue: any) => Tester;
64
+ /**
65
+ * Only applicable for Controls.
66
+ *
67
+ * Checks whether the scope of a control ends with the expected string.
68
+ *
69
+ * @param {string} expected the expected ending of the reference
70
+ */
71
+ export declare const scopeEndsWith: (expected: string) => Tester;
72
+ /**
73
+ * Only applicable for Controls.
74
+ *
75
+ * Checks whether the last segment of the scope matches the expected string.
76
+ *
77
+ * @param {string} expected the expected ending of the reference
78
+ */
79
+ export declare const scopeEndIs: (expected: string) => Tester;
80
+ /**
81
+ * A tester that allow composing other testers by && them.
82
+ *
83
+ * @param {Array<Tester>} testers the testers to be composed
84
+ */
85
+ export declare const and: (...testers: Tester[]) => Tester;
86
+ /**
87
+ * A tester that allow composing other testers by || them.
88
+ *
89
+ * @param {Array<Tester>} testers the testers to be composed
90
+ */
91
+ export declare const or: (...testers: Tester[]) => Tester;
92
+ /**
93
+ * Create a ranked tester that will associate a number with a given tester, if the
94
+ * latter returns true.
95
+ *
96
+ * @param {number} rank the rank to be returned in case the tester returns true
97
+ * @param {Tester} tester a tester
98
+ */
99
+ export declare const rankWith: (rank: number, tester: Tester) => (uischema: UISchemaElement, schema: JsonSchema) => number;
100
+ export declare const withIncreasedRank: (by: number, rankedTester: RankedTester) => (uischema: UISchemaElement, schema: JsonSchema) => number;
101
+ /**
102
+ * Default tester for boolean.
103
+ * @type {RankedTester}
104
+ */
105
+ export declare const isBooleanControl: Tester;
106
+ export declare const isObjectControl: Tester;
107
+ export declare const isAllOfControl: Tester;
108
+ export declare const isAnyOfControl: Tester;
109
+ export declare const isOneOfControl: Tester;
110
+ /**
111
+ * Tests whether the given UI schema is of type Control and if the schema
112
+ * has an enum.
113
+ * @type {Tester}
114
+ */
115
+ export declare const isEnumControl: Tester;
116
+ /**
117
+ * Tests whether the given UI schema is of type Control and if the schema
118
+ * has an enum based on oneOf.
119
+ * @type {Tester}
120
+ */
121
+ export declare const isOneOfEnumControl: Tester;
122
+ /**
123
+ * Tests whether the given UI schema is of type Control and if the schema
124
+ * is of type integer
125
+ * @type {Tester}
126
+ */
127
+ export declare const isIntegerControl: Tester;
128
+ /**
129
+ * Tests whether the given UI schema is of type Control and if the schema
130
+ * is of type number
131
+ * @type {Tester}
132
+ */
133
+ export declare const isNumberControl: Tester;
134
+ /**
135
+ * Tests whether the given UI schema is of type Control and if the schema
136
+ * is of type string
137
+ * @type {Tester}
138
+ */
139
+ export declare const isStringControl: Tester;
140
+ /**
141
+ * Tests whether the given UI schema is of type Control and if is has
142
+ * a 'multi' option.
143
+ * @type {Tester}
144
+ */
145
+ export declare const isMultiLineControl: Tester;
146
+ /**
147
+ * Tests whether the given UI schema is of type Control and whether the schema
148
+ * or uischema options has a 'date' format.
149
+ * @type {Tester}
150
+ */
151
+ export declare const isDateControl: Tester;
152
+ /**
153
+ * Tests whether the given UI schema is of type Control and whether the schema
154
+ * or the uischema options has a 'time' format.
155
+ * @type {Tester}
156
+ */
157
+ export declare const isTimeControl: Tester;
158
+ /**
159
+ * Tests whether the given UI schema is of type Control and whether the schema
160
+ * or the uischema options has a 'date-time' format.
161
+ * @type {Tester}
162
+ */
163
+ export declare const isDateTimeControl: Tester;
164
+ /**
165
+ * Tests whether the given schema is an array of objects.
166
+ * @type {Tester}
167
+ */
168
+ export declare const isObjectArray: Tester;
169
+ /**
170
+ * Tests whether the given UI schema is of type Control and if the schema
171
+ * is an array of objects.
172
+ * @type {Tester}
173
+ */
174
+ export declare const isObjectArrayControl: Tester;
175
+ export declare const isObjectArrayWithNesting: (uischema: UISchemaElement, schema: JsonSchema) => boolean;
176
+ /**
177
+ * Synonym for isObjectArrayControl
178
+ */
179
+ export declare const isArrayObjectControl: Tester;
180
+ /**
181
+ * Tests whether the given UI schema is of type Control and if the schema
182
+ * is an array of a primitive type.
183
+ * @type {Tester}
184
+ */
185
+ export declare const isPrimitiveArrayControl: Tester;
186
+ /**
187
+ * Tests whether a given UI schema is of type Control,
188
+ * if the schema is of type number or integer and
189
+ * whether the schema defines a numerical range with a default value.
190
+ * @type {Tester}
191
+ */
192
+ export declare const isRangeControl: Tester;
193
+ /**
194
+ * Tests whether the given UI schema is of type Control, if the schema
195
+ * is of type string and has option format
196
+ * @type {Tester}
197
+ */
198
+ export declare const isNumberFormatControl: Tester;
199
+ export declare const isCategorization: (category: UISchemaElement) => category is Categorization;
200
+ export declare const isCategory: (uischema: UISchemaElement) => boolean;
201
+ export declare const hasCategory: (categorization: Categorization) => boolean;
202
+ export declare const categorizationHasCategory: (uischema: UISchemaElement) => boolean;
203
+ export declare const not: (tester: Tester) => Tester;