@aemforms/af-core 0.22.19 → 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 (122) 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} +10 -69
  5. package/lib/{BaseNode.js → esm/BaseNode.js} +84 -184
  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/{Container.d.ts → esm/Container.d.ts} +12 -59
  11. package/lib/{Container.js → esm/Container.js} +54 -116
  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} +39 -104
  15. package/lib/{Field.js → esm/Field.js} +142 -208
  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/{Form.d.ts → esm/Form.d.ts} +19 -85
  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} +11 -54
  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 +15 -34
  42. package/lib/{data → esm/data}/DataValue.d.ts +1 -7
  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 +41 -117
  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 +3 -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 +0 -6
  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/DateField.js +0 -35
  81. package/lib/Fieldset.d.ts +0 -24
  82. package/lib/Fieldset.js +0 -74
  83. package/lib/FileObject.js +0 -39
  84. package/lib/FileUpload.js +0 -155
  85. package/lib/Form.js +0 -252
  86. package/lib/FormInstance.d.ts +0 -38
  87. package/lib/FormInstance.js +0 -127
  88. package/lib/FormMetaData.d.ts +0 -11
  89. package/lib/FormMetaData.js +0 -28
  90. package/lib/InstanceManager.d.ts +0 -16
  91. package/lib/InstanceManager.js +0 -53
  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 -255
  96. package/lib/controller/Controller.js +0 -328
  97. package/lib/controller/index.d.ts +0 -1
  98. package/lib/controller/index.js +0 -24
  99. package/lib/data/DataValue.js +0 -56
  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 -393
  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 -87
  111. package/lib/utils/FormCreationUtils.d.ts +0 -11
  112. package/lib/utils/FormCreationUtils.js +0 -83
  113. package/lib/utils/FormUtils.d.ts +0 -47
  114. package/lib/utils/FormUtils.js +0 -257
  115. package/lib/utils/JsonUtils.d.ts +0 -63
  116. package/lib/utils/JsonUtils.js +0 -157
  117. package/lib/utils/LogUtils.js +0 -17
  118. package/lib/utils/SchemaUtils.d.ts +0 -16
  119. package/lib/utils/SchemaUtils.js +0 -92
  120. package/lib/utils/TranslationUtils.d.ts +0 -41
  121. package/lib/utils/TranslationUtils.js +0 -185
  122. package/lib/utils/ValidationUtils.d.ts +0 -170
@@ -1,185 +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
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.createTranslationObject = exports.createTranslationObj = exports.getOrElse = exports.addTranslationId = exports.invalidateTranslation = exports.CUSTOM_PROPS_KEY = exports.TRANSLATION_ID = exports.TRANSLATION_TOKEN = void 0;
11
- /**
12
- * Defines generic utilities to translated form model definition
13
- */
14
- // todo: The API's defined in this file could move to a different package later on
15
- const types_1 = require("../types");
16
- /** Token used while creating translation specific properties from `adaptive form specification` */
17
- exports.TRANSLATION_TOKEN = '##';
18
- /** Name of the object which holds all translation specific properties */
19
- exports.TRANSLATION_ID = 'afs:translationIds';
20
- exports.CUSTOM_PROPS_KEY = 'properties';
21
- const defaultBcp47LangTags = [
22
- 'de-DE',
23
- 'en-US',
24
- 'es-ES',
25
- 'fr-FR',
26
- 'it-IT',
27
- 'ja-JP',
28
- 'ko-KR',
29
- 'pt-BR',
30
- 'zh-CN',
31
- 'zh-TW'
32
- ];
33
- /**
34
- * @private
35
- */
36
- const invalidateTranslation = (input, updates) => {
37
- types_1.translationProps.forEach((prop) => {
38
- var _a, _b, _c, _d;
39
- if (prop in updates && ((_b = (_a = input === null || input === void 0 ? void 0 : input[exports.CUSTOM_PROPS_KEY]) === null || _a === void 0 ? void 0 : _a[exports.TRANSLATION_ID]) === null || _b === void 0 ? void 0 : _b[prop])) {
40
- (_d = (_c = input === null || input === void 0 ? void 0 : input[exports.CUSTOM_PROPS_KEY]) === null || _c === void 0 ? void 0 : _c[exports.TRANSLATION_ID]) === null || _d === void 0 ? true : delete _d[prop];
41
- }
42
- });
43
- };
44
- exports.invalidateTranslation = invalidateTranslation;
45
- /**
46
- * @private
47
- */
48
- const addTranslationId = (input, additionalTranslationProps = []) => {
49
- // don't create a schema copy, add it to the existing
50
- const model = input;
51
- const transProps = [...types_1.translationProps, ...additionalTranslationProps];
52
- _createTranslationId(model, '', transProps);
53
- return model;
54
- };
55
- exports.addTranslationId = addTranslationId;
56
- /**
57
- * @private
58
- */
59
- const _createTranslationId = (input, path, transProps) => {
60
- Object.entries(input).forEach(([key, value]) => {
61
- if (typeof value == 'object') {
62
- if (input instanceof Array) {
63
- if (value && 'name' in value) {
64
- // @ts-ignore
65
- _createTranslationId(value, `${path === '' ? path : path + exports.TRANSLATION_TOKEN}${value.name}`, transProps);
66
- }
67
- }
68
- else {
69
- _createTranslationId(value, ((key === 'items') ? path : `${path === '' ? path : path + exports.TRANSLATION_TOKEN}${key}`), transProps);
70
- }
71
- }
72
- else {
73
- // set it only if either of type or fieldType properties is present
74
- if (':type' in input ||
75
- 'type' in input ||
76
- 'fieldType' in input) {
77
- for (const transProp of transProps) {
78
- // if property exist add it
79
- if ((0, exports.getOrElse)(input, transProp) != null) {
80
- // if translation id is not yet set, set it
81
- if (!(exports.CUSTOM_PROPS_KEY in input)) {
82
- input[exports.CUSTOM_PROPS_KEY] = {};
83
- }
84
- if (!(exports.TRANSLATION_ID in input[exports.CUSTOM_PROPS_KEY])) {
85
- input[exports.CUSTOM_PROPS_KEY][exports.TRANSLATION_ID] = {};
86
- }
87
- // if transprop is not yet set, set it
88
- // this is done to prevent overwrite
89
- if (!(transProp in input[exports.CUSTOM_PROPS_KEY][exports.TRANSLATION_ID])) {
90
- input[exports.CUSTOM_PROPS_KEY][exports.TRANSLATION_ID][transProp] = `${path}${exports.TRANSLATION_TOKEN}${transProp}${exports.TRANSLATION_TOKEN}${Math.floor(Math.random() * 10000) + 1}`;
91
- }
92
- }
93
- }
94
- }
95
- }
96
- });
97
- };
98
- /**
99
- * @param input
100
- * @param translationObj
101
- * @param translationProps
102
- * @private
103
- */
104
- const _createTranslationObj = (input, translationObj, translationProps) => {
105
- Object.values(input).forEach((value) => {
106
- var _a, _b;
107
- if (typeof value == 'object') {
108
- _createTranslationObj(value, translationObj, translationProps);
109
- }
110
- else {
111
- for (const translationProp of translationProps) {
112
- const objValue = (0, exports.getOrElse)(input, translationProp);
113
- if (objValue && ((_b = (_a = input === null || input === void 0 ? void 0 : input[exports.CUSTOM_PROPS_KEY]) === null || _a === void 0 ? void 0 : _a[exports.TRANSLATION_ID]) === null || _b === void 0 ? void 0 : _b[translationProp])) {
114
- // todo: right now we create only for english
115
- if (objValue instanceof Array) {
116
- objValue.forEach((item, index) => {
117
- if (typeof item === 'string') { // only if string, then convert, since values can also be boolean
118
- // @ts-ignore
119
- translationObj[`${input[exports.CUSTOM_PROPS_KEY][exports.TRANSLATION_ID][translationProp]}${exports.TRANSLATION_TOKEN}${index}`] = item;
120
- }
121
- });
122
- }
123
- else {
124
- // @ts-ignore
125
- translationObj[`${input[exports.CUSTOM_PROPS_KEY][exports.TRANSLATION_ID][translationProp]}`] = objValue;
126
- }
127
- }
128
- }
129
- }
130
- });
131
- };
132
- /**
133
- * Gets the value for the given key from the input, in case of no value, default is returned
134
- * @param input input object
135
- * @param key key to return from input object (key could be comma separated, example, label.value)
136
- * @param defaultValue default value
137
- */
138
- const getOrElse = (input, key, defaultValue = null) => {
139
- if (!key) {
140
- return defaultValue;
141
- }
142
- const arr = Array.isArray(key) ? key : key.split('.');
143
- let objValue = input, index = 0;
144
- while (index < arr.length && objValue.hasOwnProperty(arr[index])) {
145
- objValue = objValue[arr[index]];
146
- index++;
147
- }
148
- return index == arr.length ? objValue : defaultValue;
149
- };
150
- exports.getOrElse = getOrElse;
151
- /**
152
- * @param input
153
- * @param additionalTranslationProps
154
- * @private
155
- */
156
- const createTranslationObj = (input, additionalTranslationProps = []) => {
157
- const obj = {};
158
- const transProps = [...types_1.translationProps, ...additionalTranslationProps];
159
- _createTranslationObj(input, obj, transProps);
160
- return obj;
161
- };
162
- exports.createTranslationObj = createTranslationObj;
163
- /**
164
- * Creates translation object with [BCP 47](https://tools.ietf.org/search/bcp47) language tags as key and value is a translation object. Key of translation object is
165
- * generated based on the form hierarchy and it is separated by "##" token to signify that the id is machine generated (ie its not a human generated string)
166
- * @param input form model definition
167
- * @param additionalTranslationProps optional properties which needs to be translated, by default, only OOTB properties of form model definition is translated
168
- * @param bcp47LangTags optional additional language tags
169
- * @returns translation object for each bcp 47 language tag
170
- */
171
- const createTranslationObject = (input, additionalTranslationProps = [], bcp47LangTags = []) => {
172
- const transProps = [...types_1.translationProps, ...additionalTranslationProps];
173
- // create a copy of the input
174
- const inputCopy = JSON.parse(JSON.stringify(input));
175
- const obj = (0, exports.createTranslationObj)((0, exports.addTranslationId)(inputCopy, additionalTranslationProps), transProps);
176
- const langTags = [...defaultBcp47LangTags, ...bcp47LangTags];
177
- const allLangs = {};
178
- for (const langTag of langTags) {
179
- // todo: added temporarily to test
180
- // todo: need to fix this as per machine translation
181
- allLangs[langTag] = JSON.parse(JSON.stringify(obj));
182
- }
183
- return [inputCopy, allLangs];
184
- };
185
- exports.createTranslationObject = createTranslationObject;
@@ -1,170 +0,0 @@
1
- /** Validation result type **/
2
- declare type ValidationResult = {
3
- valid: boolean;
4
- value: any;
5
- };
6
- export declare const isDataUrl: (str: string) => boolean;
7
- export declare const ValidConstraints: {
8
- date: string[];
9
- string: string[];
10
- number: string[];
11
- array: string[];
12
- file: string[];
13
- };
14
- /**
15
- * Implementation of all constraints defined by `adaptive form specification`
16
- */
17
- export declare const Constraints: {
18
- /**
19
- * Implementation of type constraint
20
- * @param constraint `type` property of the form object
21
- * @param inputVal value of the form object
22
- * @return {@link ValidationResult | validation result}
23
- */
24
- type: (constraint: string, inputVal: any) => ValidationResult;
25
- /**
26
- * Implementation of format constraint
27
- * @param constraint `format` property of the form object
28
- * @param input value of the form object
29
- * @return {@link ValidationResult | validation result}
30
- */
31
- format: (constraint: string, input: string | null) => {
32
- value: string | null;
33
- valid: boolean;
34
- };
35
- /**
36
- * Implementation of minimum constraint
37
- * @param constraint `minimum` property of the form object
38
- * @param value value of the form object
39
- * @return {@link ValidationResult | validation result}
40
- */
41
- minimum: (constraint: number, value: number) => {
42
- valid: boolean;
43
- value: number;
44
- };
45
- /**
46
- * Implementation of maximum constraint
47
- * @param constraint `maximum` property of the form object
48
- * @param value value of the form object
49
- * @return {@link ValidationResult | validation result}
50
- */
51
- maximum: (constraint: number, value: number) => {
52
- valid: boolean;
53
- value: number;
54
- };
55
- /**
56
- * Implementation of exclusiveMinimum constraint
57
- * @param constraint `minimum` property of the form object
58
- * @param value value of the form object
59
- * @return {@link ValidationResult | validation result}
60
- */
61
- exclusiveMinimum: (constraint: number, value: number) => {
62
- valid: boolean;
63
- value: number;
64
- };
65
- /**
66
- * Implementation of exclusiveMaximum constraint
67
- * @param constraint `maximum` property of the form object
68
- * @param value value of the form object
69
- * @return {@link ValidationResult | validation result}
70
- */
71
- exclusiveMaximum: (constraint: number, value: number) => {
72
- valid: boolean;
73
- value: number;
74
- };
75
- /**
76
- * Implementation of the minItems constraint
77
- * @param constraint `minItems` constraint from object
78
- * @param value value of the form object
79
- */
80
- minItems: <T>(constraint: number, value: T[]) => {
81
- valid: boolean;
82
- value: T[];
83
- };
84
- /**
85
- * Implementation of the maxItems constraint
86
- * @param constraint `maxItems` constraint from object
87
- * @param value value of the form object
88
- */
89
- maxItems: <T_1>(constraint: number, value: T_1[]) => {
90
- valid: boolean;
91
- value: T_1[];
92
- };
93
- /**
94
- * Implementation of the uniqueItems constraint
95
- * @param constraint `uniqueItems` constraint from object
96
- * @param value value of the form object
97
- */
98
- uniqueItems: <T_2>(constraint: boolean, value: T_2[]) => {
99
- valid: boolean;
100
- value: T_2[];
101
- };
102
- /**
103
- * Implementation of minLength constraint
104
- * @param constraint `minLength` property of the form object
105
- * @param value value of the form object
106
- * @return {@link ValidationResult | validation result}
107
- */
108
- minLength: (constraint: number, value: string) => {
109
- value: string;
110
- valid: boolean;
111
- };
112
- /**
113
- * Implementation of maxLength constraint
114
- * @param constraint `maxLength` property of the form object
115
- * @param value value of the form object
116
- * @return {@link ValidationResult | validation result}
117
- */
118
- maxLength: (constraint: number, value: string) => {
119
- value: string;
120
- valid: boolean;
121
- };
122
- /**
123
- * Implementation of pattern constraint
124
- * @param constraint `pattern` property of the form object
125
- * @param value value of the form object
126
- * @return {@link ValidationResult | validation result}
127
- */
128
- pattern: (constraint: RegExp | string, value: string) => {
129
- valid: boolean;
130
- value: string;
131
- };
132
- /**
133
- * Implementation of required constraint
134
- * @param constraint `required` property of the form object
135
- * @param value value of the form object
136
- * @return {@link ValidationResult | validation result}
137
- */
138
- required: (constraint: boolean, value: any) => {
139
- valid: boolean;
140
- value: any;
141
- };
142
- /**
143
- * Implementation of enum constraint
144
- * @param constraint `enum` property of the form object
145
- * @param value value of the form object
146
- * @return {@link ValidationResult | validation result}
147
- */
148
- enum: (constraint: any[], value: any) => {
149
- valid: boolean;
150
- value: any;
151
- };
152
- /**
153
- *
154
- * @param constraint
155
- * @param value
156
- */
157
- accept: (constraint: string[], value: any) => {
158
- valid: boolean;
159
- value: any;
160
- };
161
- /**
162
- * @param constraint
163
- * @param value
164
- */
165
- maxFileSize: (constraint: number | string, value: any) => {
166
- valid: boolean;
167
- value: any;
168
- };
169
- };
170
- export {};