@aemforms/af-core 0.22.18 → 0.22.20

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 (120) hide show
  1. package/lib/browser/afb-events.js +151 -0
  2. package/lib/browser/afb-runtime.js +3620 -0
  3. package/lib/cjs/index.cjs +8886 -0
  4. package/lib/{BaseNode.d.ts → esm/BaseNode.d.ts} +11 -68
  5. package/lib/{BaseNode.js → esm/BaseNode.js} +86 -182
  6. package/lib/esm/Checkbox.d.ts +79 -0
  7. package/lib/esm/Checkbox.js +27 -0
  8. package/lib/{CheckboxGroup.d.ts → esm/CheckboxGroup.d.ts} +2 -14
  9. package/lib/esm/CheckboxGroup.js +23 -0
  10. package/lib/esm/Container.d.ts +53 -0
  11. package/lib/{Container.js → esm/Container.js} +76 -124
  12. package/lib/{DateField.d.ts → esm/DateField.d.ts} +1 -1
  13. package/lib/esm/DateField.js +21 -0
  14. package/lib/{Field.d.ts → esm/Field.d.ts} +44 -98
  15. package/lib/{Field.js → esm/Field.js} +172 -206
  16. package/lib/esm/Fieldset.d.ts +16 -0
  17. package/lib/esm/Fieldset.js +45 -0
  18. package/lib/{FileObject.d.ts → esm/FileObject.d.ts} +1 -4
  19. package/lib/esm/FileObject.js +26 -0
  20. package/lib/{FileUpload.d.ts → esm/FileUpload.d.ts} +3 -18
  21. package/lib/esm/FileUpload.js +108 -0
  22. package/lib/esm/Form.d.ts +113 -0
  23. package/lib/esm/Form.js +176 -0
  24. package/lib/esm/FormInstance.d.ts +13 -0
  25. package/lib/esm/FormInstance.js +81 -0
  26. package/lib/esm/FormMetaData.d.ts +7 -0
  27. package/lib/esm/FormMetaData.js +10 -0
  28. package/lib/esm/InstanceManager.d.ts +9 -0
  29. package/lib/esm/InstanceManager.js +31 -0
  30. package/lib/esm/Node.d.ts +7 -0
  31. package/lib/esm/Node.js +16 -0
  32. package/lib/esm/Scriptable.d.ts +17 -0
  33. package/lib/{Scriptable.js → esm/Scriptable.js} +12 -55
  34. package/lib/{controller → esm/controller}/EventQueue.d.ts +3 -11
  35. package/lib/{controller → esm/controller}/EventQueue.js +10 -26
  36. package/lib/esm/controller/Events.d.ts +85 -0
  37. package/lib/esm/controller/Events.js +149 -0
  38. package/lib/{controller → esm/controller}/Logger.d.ts +0 -6
  39. package/lib/{controller → esm/controller}/Logger.js +5 -11
  40. package/lib/{data → esm/data}/DataGroup.d.ts +1 -7
  41. package/lib/{data → esm/data}/DataGroup.js +20 -35
  42. package/lib/{data → esm/data}/DataValue.d.ts +2 -8
  43. package/lib/esm/data/DataValue.js +46 -0
  44. package/lib/{data → esm/data}/EmptyDataValue.d.ts +1 -1
  45. package/lib/esm/data/EmptyDataValue.js +29 -0
  46. package/lib/esm/index.d.ts +21 -0
  47. package/lib/esm/index.js +21 -0
  48. package/lib/{rules → esm/rules}/FunctionRuntime.d.ts +2 -24
  49. package/lib/{rules → esm/rules}/FunctionRuntime.js +44 -114
  50. package/lib/esm/rules/RuleEngine.d.ts +12 -0
  51. package/lib/esm/rules/RuleEngine.js +47 -0
  52. package/lib/{types → esm/types}/Json.d.ts +6 -22
  53. package/lib/esm/types/Json.js +7 -0
  54. package/lib/esm/types/Model.d.ts +131 -0
  55. package/lib/esm/types/Model.js +8 -0
  56. package/lib/esm/types/index.d.ts +2 -0
  57. package/lib/esm/types/index.js +2 -0
  58. package/lib/{utils → esm/utils}/DataRefParser.d.ts +2 -5
  59. package/lib/{utils → esm/utils}/DataRefParser.js +22 -49
  60. package/lib/{utils → esm/utils}/Fetch.d.ts +1 -0
  61. package/lib/esm/utils/Fetch.js +61 -0
  62. package/lib/esm/utils/FormCreationUtils.d.ts +9 -0
  63. package/lib/esm/utils/FormCreationUtils.js +74 -0
  64. package/lib/esm/utils/FormUtils.d.ts +12 -0
  65. package/lib/esm/utils/FormUtils.js +187 -0
  66. package/lib/esm/utils/JsonUtils.d.ts +11 -0
  67. package/lib/esm/utils/JsonUtils.js +76 -0
  68. package/lib/{utils → esm/utils}/LogUtils.d.ts +1 -4
  69. package/lib/esm/utils/LogUtils.js +6 -0
  70. package/lib/esm/utils/SchemaUtils.d.ts +3 -0
  71. package/lib/esm/utils/SchemaUtils.js +71 -0
  72. package/lib/esm/utils/TranslationUtils.d.ts +11 -0
  73. package/lib/esm/utils/TranslationUtils.js +115 -0
  74. package/lib/esm/utils/ValidationUtils.d.ts +19 -0
  75. package/lib/{utils → esm/utils}/ValidationUtils.js +29 -187
  76. package/package.json +17 -10
  77. package/lib/Checkbox.d.ts +0 -88
  78. package/lib/Checkbox.js +0 -49
  79. package/lib/CheckboxGroup.js +0 -43
  80. package/lib/Container.d.ts +0 -199
  81. package/lib/DateField.js +0 -35
  82. package/lib/Fieldset.d.ts +0 -34
  83. package/lib/Fieldset.js +0 -113
  84. package/lib/FileObject.js +0 -39
  85. package/lib/FileUpload.js +0 -155
  86. package/lib/Form.d.ts +0 -262
  87. package/lib/Form.js +0 -230
  88. package/lib/FormInstance.d.ts +0 -38
  89. package/lib/FormInstance.js +0 -119
  90. package/lib/FormMetaData.d.ts +0 -11
  91. package/lib/FormMetaData.js +0 -28
  92. package/lib/Node.d.ts +0 -12
  93. package/lib/Node.js +0 -27
  94. package/lib/Scriptable.d.ts +0 -31
  95. package/lib/controller/Controller.d.ts +0 -223
  96. package/lib/controller/Controller.js +0 -287
  97. package/lib/controller/index.d.ts +0 -1
  98. package/lib/controller/index.js +0 -24
  99. package/lib/data/DataValue.js +0 -52
  100. package/lib/data/EmptyDataValue.js +0 -46
  101. package/lib/index.d.ts +0 -28
  102. package/lib/index.js +0 -63
  103. package/lib/rules/RuleEngine.d.ts +0 -23
  104. package/lib/rules/RuleEngine.js +0 -62
  105. package/lib/types/Json.js +0 -19
  106. package/lib/types/Model.d.ts +0 -379
  107. package/lib/types/Model.js +0 -20
  108. package/lib/types/index.d.ts +0 -2
  109. package/lib/types/index.js +0 -25
  110. package/lib/utils/Fetch.js +0 -29
  111. package/lib/utils/FormUtils.d.ts +0 -47
  112. package/lib/utils/FormUtils.js +0 -257
  113. package/lib/utils/JsonUtils.d.ts +0 -62
  114. package/lib/utils/JsonUtils.js +0 -143
  115. package/lib/utils/LogUtils.js +0 -17
  116. package/lib/utils/SchemaUtils.d.ts +0 -16
  117. package/lib/utils/SchemaUtils.js +0 -92
  118. package/lib/utils/TranslationUtils.d.ts +0 -41
  119. package/lib/utils/TranslationUtils.js +0 -185
  120. package/lib/utils/ValidationUtils.d.ts +0 -170
@@ -1,23 +1,6 @@
1
- "use strict";
2
- /*
3
- * Copyright 2022 Adobe, Inc.
4
- *
5
- * Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
6
- *
7
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Constraints = exports.ValidConstraints = exports.isDataUrl = void 0;
11
- const FormUtils_1 = require("./FormUtils");
12
- const FileObject_1 = require("../FileObject");
13
- /**
14
- * Defines generic utilities to validate form runtime model based on the constraints defined
15
- * as per `adaptive form specification`
16
- */
17
- // issue with import
18
- //import {FieldJson, isFileObject} from '../types';
1
+ import { extractFileInfo, getFileSizeInBytes } from './FormUtils.js';
2
+ import { FileObject } from '../FileObject.js';
19
3
  const dateRegex = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
20
- const dataUrlRegex = /^data:([a-z]+\/[a-z0-9-+.]+)?;(?:name=(.*);)?base64,(.*)$/;
21
4
  const days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
22
5
  const daysInMonth = (leapYear, month) => {
23
6
  if (leapYear && month == 2) {
@@ -28,26 +11,27 @@ const daysInMonth = (leapYear, month) => {
28
11
  const isLeapYear = (year) => {
29
12
  return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
30
13
  };
31
- const isDataUrl = (str) => {
32
- return dataUrlRegex.exec(str.trim()) != null;
14
+ export const coerceType = (param, type) => {
15
+ let num;
16
+ switch (type) {
17
+ case 'string':
18
+ return param + '';
19
+ case 'number':
20
+ num = +param;
21
+ if (!isNaN(num)) {
22
+ return num;
23
+ }
24
+ break;
25
+ case 'boolean':
26
+ if (typeof param === 'string') {
27
+ return param === 'true';
28
+ }
29
+ else if (typeof param === 'number') {
30
+ return param !== 0;
31
+ }
32
+ }
33
+ throw `${param} has invalid type. Expected : ${type}, Actual ${typeof param}`;
33
34
  };
34
- exports.isDataUrl = isDataUrl;
35
- /**
36
- * Checks whether inputVal is valid number value or not
37
- *
38
- * ```
39
- * const x = checkNumber('12')
40
- * ```
41
- * would return
42
- * ```
43
- * {
44
- * value : 12,
45
- * valid : true
46
- * }
47
- * ```
48
- * @param inputVal input value
49
- * @returns {@link ValidationResult | Validation result}
50
- */
51
35
  const checkNumber = (inputVal) => {
52
36
  if (inputVal === '' || inputVal == null) {
53
37
  return {
@@ -63,10 +47,6 @@ const checkNumber = (inputVal) => {
63
47
  value, valid
64
48
  };
65
49
  };
66
- /**
67
- *
68
- * @param inputVal
69
- */
70
50
  const checkInteger = (inputVal) => {
71
51
  if (inputVal == '' || inputVal == null) {
72
52
  return {
@@ -82,55 +62,25 @@ const checkInteger = (inputVal) => {
82
62
  value, valid
83
63
  };
84
64
  };
85
- /**
86
- * Wraps a non-null value and not an array value into an array
87
- * @param inputVal input value
88
- * @returns wraps the input value into an array
89
- */
90
65
  const toArray = (inputVal) => {
91
66
  if (inputVal != null && !(inputVal instanceof Array)) {
92
67
  return [inputVal];
93
68
  }
94
69
  return inputVal;
95
70
  };
96
- /**
97
- * Checks whether inputVal is valid boolean value or not
98
- *
99
- * ```
100
- * const x = checkBool('false')
101
- * ```
102
- * would return
103
- * ```
104
- * {
105
- * value : false,
106
- * valid : true
107
- * }
108
- * ```
109
- * @param inputVal input value
110
- * @returns {@link ValidationResult | Validation result}
111
- */
112
71
  const checkBool = (inputVal) => {
113
72
  const valid = typeof inputVal === 'boolean' || inputVal === 'true' || inputVal === 'false';
114
73
  const value = typeof inputVal === 'boolean' ? inputVal : (valid ? inputVal === 'true' : inputVal);
115
74
  return { valid, value };
116
75
  };
117
- /**
118
- *
119
- * @param inputVal
120
- */
121
76
  const checkFile = (inputVal) => {
122
- const value = (0, FormUtils_1.extractFileInfo)(inputVal);
77
+ const value = extractFileInfo(inputVal);
123
78
  const valid = value !== null;
124
79
  return {
125
80
  value: valid ? value : inputVal,
126
81
  valid
127
82
  };
128
83
  };
129
- /**
130
- * validates whether the mediaType is one present in the accepts list
131
- * @param mediaType
132
- * @param accepts
133
- */
134
84
  const matchMediaType = (mediaType, accepts) => {
135
85
  return !mediaType || accepts.some((accept) => {
136
86
  const trimmedAccept = accept.trim();
@@ -141,13 +91,6 @@ const matchMediaType = (mediaType, accepts) => {
141
91
  (trimmedAccept === mediaType));
142
92
  });
143
93
  };
144
- /**
145
- * Validates an array of values using a validator function.
146
- * @param inputVal
147
- * @param validatorFn
148
- * @return an array containing two arrays, the first one with all the valid values and the second one with one invalid
149
- * value (if there is).
150
- */
151
94
  const partitionArray = (inputVal, validatorFn) => {
152
95
  const value = toArray(inputVal);
153
96
  if (value == null) {
@@ -162,23 +105,14 @@ const partitionArray = (inputVal, validatorFn) => {
162
105
  return acc;
163
106
  }, [[], []]);
164
107
  };
165
- exports.ValidConstraints = {
108
+ export const ValidConstraints = {
166
109
  date: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum', 'format'],
167
110
  string: ['minLength', 'maxLength', 'pattern'],
168
111
  number: ['minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum'],
169
112
  array: ['minItems', 'maxItems', 'uniqueItems'],
170
113
  file: ['accept', 'maxFileSize']
171
114
  };
172
- /**
173
- * Implementation of all constraints defined by `adaptive form specification`
174
- */
175
- exports.Constraints = {
176
- /**
177
- * Implementation of type constraint
178
- * @param constraint `type` property of the form object
179
- * @param inputVal value of the form object
180
- * @return {@link ValidationResult | validation result}
181
- */
115
+ export const Constraints = {
182
116
  type: (constraint, inputVal) => {
183
117
  let value = inputVal;
184
118
  if (inputVal == undefined) {
@@ -217,7 +151,6 @@ exports.Constraints = {
217
151
  value = valid ? res[0] : inputVal;
218
152
  break;
219
153
  case 'file':
220
- // for file types only, we support setting value via an array
221
154
  res = checkFile(inputVal instanceof Array ? inputVal[0] : inputVal);
222
155
  valid = res.valid;
223
156
  value = res.value;
@@ -243,12 +176,6 @@ exports.Constraints = {
243
176
  value
244
177
  };
245
178
  },
246
- /**
247
- * Implementation of format constraint
248
- * @param constraint `format` property of the form object
249
- * @param input value of the form object
250
- * @return {@link ValidationResult | validation result}
251
- */
252
179
  format: (constraint, input) => {
253
180
  let valid = true;
254
181
  const value = input;
@@ -260,7 +187,6 @@ exports.Constraints = {
260
187
  case 'date':
261
188
  res = dateRegex.exec((input || '').trim());
262
189
  if (res != null) {
263
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
264
190
  const [match, year, month, date] = res;
265
191
  const [nMonth, nDate] = [+month, +date];
266
192
  const leapYear = isLeapYear(+year);
@@ -272,101 +198,38 @@ exports.Constraints = {
272
198
  }
273
199
  break;
274
200
  case 'data-url':
275
- // todo: input is of type file, do we need this format ? since value is always of type file object
276
- //res = dataUrlRegex.exec(input.trim());
277
- //valid = res != null;
278
201
  valid = true;
279
202
  break;
280
203
  }
281
204
  return { valid, value };
282
205
  },
283
- //todo : add support for date
284
- /**
285
- * Implementation of minimum constraint
286
- * @param constraint `minimum` property of the form object
287
- * @param value value of the form object
288
- * @return {@link ValidationResult | validation result}
289
- */
290
206
  minimum: (constraint, value) => {
291
207
  return { valid: value >= constraint, value };
292
208
  },
293
- //todo : add support for date
294
- /**
295
- * Implementation of maximum constraint
296
- * @param constraint `maximum` property of the form object
297
- * @param value value of the form object
298
- * @return {@link ValidationResult | validation result}
299
- */
300
209
  maximum: (constraint, value) => {
301
210
  return { valid: value <= constraint, value };
302
211
  },
303
- /**
304
- * Implementation of exclusiveMinimum constraint
305
- * @param constraint `minimum` property of the form object
306
- * @param value value of the form object
307
- * @return {@link ValidationResult | validation result}
308
- */
309
212
  exclusiveMinimum: (constraint, value) => {
310
213
  return { valid: value > constraint, value };
311
214
  },
312
- //todo : add support for date
313
- /**
314
- * Implementation of exclusiveMaximum constraint
315
- * @param constraint `maximum` property of the form object
316
- * @param value value of the form object
317
- * @return {@link ValidationResult | validation result}
318
- */
319
215
  exclusiveMaximum: (constraint, value) => {
320
216
  return { valid: value < constraint, value };
321
217
  },
322
- /**
323
- * Implementation of the minItems constraint
324
- * @param constraint `minItems` constraint from object
325
- * @param value value of the form object
326
- */
327
218
  minItems: (constraint, value) => {
328
219
  return { valid: (value instanceof Array) && value.length >= constraint, value };
329
220
  },
330
- /**
331
- * Implementation of the maxItems constraint
332
- * @param constraint `maxItems` constraint from object
333
- * @param value value of the form object
334
- */
335
221
  maxItems: (constraint, value) => {
336
222
  return { valid: (value instanceof Array) && value.length <= constraint, value };
337
223
  },
338
- /**
339
- * Implementation of the uniqueItems constraint
340
- * @param constraint `uniqueItems` constraint from object
341
- * @param value value of the form object
342
- */
343
224
  uniqueItems: (constraint, value) => {
344
225
  return { valid: !constraint || ((value instanceof Array) && value.length === new Set(value).size), value };
345
226
  },
346
- /**
347
- * Implementation of minLength constraint
348
- * @param constraint `minLength` property of the form object
349
- * @param value value of the form object
350
- * @return {@link ValidationResult | validation result}
351
- */
352
227
  minLength: (constraint, value) => {
353
- return Object.assign(Object.assign({}, exports.Constraints.minimum(constraint, typeof value === 'string' ? value.length : 0)), { value });
228
+ return { ...Constraints.minimum(constraint, typeof value === 'string' ? value.length : 0), value };
354
229
  },
355
- /**
356
- * Implementation of maxLength constraint
357
- * @param constraint `maxLength` property of the form object
358
- * @param value value of the form object
359
- * @return {@link ValidationResult | validation result}
360
- */
361
230
  maxLength: (constraint, value) => {
362
- return Object.assign(Object.assign({}, exports.Constraints.maximum(constraint, typeof value === 'string' ? value.length : 0)), { value });
231
+ return { ...Constraints.maximum(constraint, typeof value === 'string' ? value.length : 0), value };
363
232
  },
364
- /**
365
- * Implementation of pattern constraint
366
- * @param constraint `pattern` property of the form object
367
- * @param value value of the form object
368
- * @return {@link ValidationResult | validation result}
369
- */
370
233
  pattern: (constraint, value) => {
371
234
  let regex;
372
235
  if (typeof constraint === 'string') {
@@ -377,33 +240,16 @@ exports.Constraints = {
377
240
  }
378
241
  return { valid: regex.test(value), value };
379
242
  },
380
- /**
381
- * Implementation of required constraint
382
- * @param constraint `required` property of the form object
383
- * @param value value of the form object
384
- * @return {@link ValidationResult | validation result}
385
- */
386
243
  required: (constraint, value) => {
387
244
  const valid = constraint ? value != null && value !== '' : true;
388
245
  return { valid, value };
389
246
  },
390
- /**
391
- * Implementation of enum constraint
392
- * @param constraint `enum` property of the form object
393
- * @param value value of the form object
394
- * @return {@link ValidationResult | validation result}
395
- */
396
247
  enum: (constraint, value) => {
397
248
  return {
398
249
  valid: constraint.indexOf(value) > -1,
399
250
  value
400
251
  };
401
252
  },
402
- /**
403
- *
404
- * @param constraint
405
- * @param value
406
- */
407
253
  accept: (constraint, value) => {
408
254
  if (!constraint || constraint.length === 0 || value === null || value === undefined) {
409
255
  return {
@@ -418,14 +264,10 @@ exports.Constraints = {
418
264
  value
419
265
  };
420
266
  },
421
- /**
422
- * @param constraint
423
- * @param value
424
- */
425
267
  maxFileSize: (constraint, value) => {
426
- const sizeLimit = typeof constraint === 'string' ? (0, FormUtils_1.getFileSizeInBytes)(constraint) : constraint;
268
+ const sizeLimit = typeof constraint === 'string' ? getFileSizeInBytes(constraint) : constraint;
427
269
  return {
428
- valid: !(value instanceof FileObject_1.FileObject) || value.size <= sizeLimit,
270
+ valid: !(value instanceof FileObject) || value.size <= sizeLimit,
429
271
  value
430
272
  };
431
273
  }
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "name": "@aemforms/af-core",
3
- "version": "0.22.18",
3
+ "version": "0.22.20",
4
4
  "description": "Core Module for Forms Runtime",
5
5
  "author": "Adobe Systems",
6
6
  "license": "Adobe Proprietary",
7
- "main": "lib/index.js",
7
+ "type": "module",
8
+ "module": "lib/esm/index.js",
9
+ "types": "lib/esm/index.d.ts",
10
+ "main": "lib/cjs/index.cjs",
11
+ "exports": {
12
+ ".": "./lib/esm/index.js"
13
+ },
8
14
  "directories": {
9
15
  "lib": "lib",
10
16
  "source": "src",
@@ -24,21 +30,21 @@
24
30
  "access": "public"
25
31
  },
26
32
  "scripts": {
27
- "test": "jest --silent",
33
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --silent",
28
34
  "eslint": "npx eslint src/**",
29
35
  "eslint:fix": "npx eslint --fix src/**",
30
- "test:ci": "jest --silent --coverage",
31
- "build": "npm run eslint && npx tsc",
36
+ "test:ci": "NODE_OPTIONS=--experimental-vm-modules jest --silent --coverage",
37
+ "build": "npm run clean && npm run eslint && npx tsc && rollup -c rollup.config.js",
32
38
  "clean": "rm -rf lib target",
33
39
  "prepublishOnly": "npm run build && npm run test",
34
40
  "docs": "npx typedoc --options .typedoc.cjs"
35
41
  },
36
42
  "dependencies": {
37
- "@adobe/json-formula": "^0.1.44",
38
- "@aemforms/af-formatters": "^0.22.18"
43
+ "@adobe/json-formula": "0.1.50",
44
+ "@aemforms/af-formatters": "^0.22.20"
39
45
  },
40
46
  "devDependencies": {
41
- "@types/jest": "^27.5.1",
47
+ "@types/jest": "29.2.4",
42
48
  "@types/lodash": "^4.14.171",
43
49
  "@typescript-eslint/eslint-plugin": "^4.28.2",
44
50
  "@typescript-eslint/parser": "^4.28.2",
@@ -50,11 +56,12 @@
50
56
  "eslint-plugin-node": "^11.1.0",
51
57
  "eslint-plugin-promise": "^5.1.0",
52
58
  "form-data": "^4.0.0",
53
- "jest": "^27.5.1",
59
+ "jest": "29.3",
60
+ "jest-environment-jsdom": "^29.3.1",
54
61
  "jest-junit": "^12.2.0",
55
62
  "nock": "^13.1.3",
56
63
  "node-fetch": "^2.6.1",
57
- "ts-jest": "^27.1.4",
64
+ "ts-jest": "29.0",
58
65
  "typedoc": "0.22.11",
59
66
  "typedoc-plugin-markdown": "3.11.13",
60
67
  "typescript": "^4.3.5"
package/lib/Checkbox.d.ts DELETED
@@ -1,88 +0,0 @@
1
- import Field from './Field';
2
- /**
3
- * Implementation of check box runtime model which extends from {@link Field | field} model
4
- */
5
- declare class Checkbox extends Field {
6
- private offValue;
7
- /**
8
- * @private
9
- */
10
- _getConstraintObject(): {
11
- type: (constraint: string, inputVal: any) => {
12
- valid: boolean;
13
- value: any;
14
- };
15
- format: (constraint: string, input: string | null) => {
16
- value: string | null;
17
- valid: boolean;
18
- };
19
- minimum: (constraint: number, value: number) => {
20
- valid: boolean;
21
- value: number;
22
- };
23
- maximum: (constraint: number, value: number) => {
24
- valid: boolean;
25
- value: number;
26
- };
27
- exclusiveMinimum: (constraint: number, value: number) => {
28
- valid: boolean;
29
- value: number;
30
- };
31
- exclusiveMaximum: (constraint: number, value: number) => {
32
- valid: boolean;
33
- value: number;
34
- };
35
- minItems: <T>(constraint: number, value: T[]) => {
36
- valid: boolean;
37
- value: T[];
38
- };
39
- maxItems: <T_1>(constraint: number, value: T_1[]) => {
40
- valid: boolean;
41
- value: T_1[];
42
- };
43
- uniqueItems: <T_2>(constraint: boolean, value: T_2[]) => {
44
- valid: boolean;
45
- value: T_2[];
46
- };
47
- minLength: (constraint: number, value: string) => {
48
- value: string;
49
- valid: boolean;
50
- };
51
- maxLength: (constraint: number, value: string) => {
52
- value: string;
53
- valid: boolean;
54
- };
55
- pattern: (constraint: string | RegExp, value: string) => {
56
- valid: boolean;
57
- value: string;
58
- };
59
- required: (constraint: boolean, value: any) => {
60
- valid: boolean;
61
- value: any;
62
- };
63
- enum: (constraint: any[], value: any) => {
64
- valid: boolean;
65
- value: any;
66
- };
67
- accept: (constraint: string[], value: any) => {
68
- valid: boolean;
69
- value: any;
70
- };
71
- maxFileSize: (constraint: string | number, value: any) => {
72
- valid: boolean;
73
- value: any;
74
- };
75
- };
76
- protected _getDefaults(): {
77
- enforceEnum: boolean;
78
- readOnly: boolean;
79
- enabled: boolean;
80
- visible: boolean;
81
- type: string | undefined;
82
- };
83
- /**
84
- * Returns the `enum` constraints from the json
85
- */
86
- get enum(): any[];
87
- }
88
- export default Checkbox;
package/lib/Checkbox.js DELETED
@@ -1,49 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2022 Adobe, Inc.
4
- *
5
- * Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
6
- *
7
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
- */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- const Field_1 = __importDefault(require("./Field"));
14
- const ValidationUtils_1 = require("./utils/ValidationUtils");
15
- /**
16
- * @param offValue
17
- * @private
18
- */
19
- const requiredConstraint = (offValue) => (constraint, value) => {
20
- const valid = ValidationUtils_1.Constraints.required(constraint, value).valid && (!constraint || value != offValue);
21
- return { valid, value };
22
- };
23
- /**
24
- * Implementation of check box runtime model which extends from {@link Field | field} model
25
- */
26
- class Checkbox extends Field_1.default {
27
- offValue() {
28
- const opts = this.enum;
29
- return opts.length > 1 ? opts[1] : null;
30
- }
31
- /**
32
- * @private
33
- */
34
- _getConstraintObject() {
35
- const baseConstraints = Object.assign({}, super._getConstraintObject());
36
- baseConstraints.required = requiredConstraint(this.offValue());
37
- return baseConstraints;
38
- }
39
- _getDefaults() {
40
- return Object.assign(Object.assign({}, super._getDefaults()), { enforceEnum: true });
41
- }
42
- /**
43
- * Returns the `enum` constraints from the json
44
- */
45
- get enum() {
46
- return this._jsonModel.enum || [];
47
- }
48
- }
49
- exports.default = Checkbox;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2022 Adobe, Inc.
4
- *
5
- * Your access and use of this software is governed by the Adobe Customer Feedback Program Terms and Conditions or other Beta License Agreement signed by your employer and Adobe, Inc.. This software is NOT open source and may not be used without one of the foregoing licenses. Even with a foregoing license, your access and use of this file is limited to the earlier of (a) 180 days, (b) general availability of the product(s) which utilize this software (i.e. AEM Forms), (c) January 1, 2023, (d) Adobe providing notice to you that you may no longer use the software or that your beta trial has otherwise ended.
6
- *
7
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ADOBE NOR ITS THIRD PARTY PROVIDERS AND PARTNERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
- */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- const Field_1 = __importDefault(require("./Field"));
14
- /**
15
- * Implementation of CheckBoxGroup runtime model which extends from {@link Field | field}
16
- */
17
- class CheckboxGroup extends Field_1.default {
18
- /**
19
- * @param params
20
- * @param _options
21
- * @private
22
- */
23
- constructor(params, _options) {
24
- super(params, _options);
25
- }
26
- /**
27
- * converts the fallback type, if required, to an array. Since checkbox-group has an array type
28
- * @protected
29
- */
30
- _getFallbackType() {
31
- const fallbackType = super._getFallbackType();
32
- if (typeof fallbackType === 'string') {
33
- return `${fallbackType}[]`;
34
- }
35
- else {
36
- return 'string[]';
37
- }
38
- }
39
- _getDefaults() {
40
- return Object.assign(Object.assign({}, super._getDefaults()), { enforceEnum: true, enum: [] });
41
- }
42
- }
43
- exports.default = CheckboxGroup;