@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,393 +0,0 @@
1
- /**
2
- * Defines generic interface's for form runtime model
3
- */
4
- import { ConstraintsJson, ContainerJson, FieldJson, FieldsetJson, FormJson, Label, MetaDataJson } from './Json';
5
- import RuleEngine from '../rules/RuleEngine';
6
- import EventQueue from '../controller/EventQueue';
7
- import DataGroup from '../data/DataGroup';
8
- import { Logger } from '../controller/Logger';
9
- /**
10
- * Generic Scriptable field interface. All non-transparent fields which support rule/events
11
- * should implement this interface
12
- */
13
- export interface ScriptableField {
14
- /**
15
- * Rules that modify the property of the object dynamically. The rules are evaluated whenever the dependency changes.
16
- */
17
- rules?: {
18
- [key: string]: string;
19
- };
20
- /**
21
- * Events is a dictionary of eventName to the actions to perform.
22
- */
23
- events?: {
24
- [key: string]: string;
25
- };
26
- /**
27
- * Instance of rule engine
28
- * @private
29
- */
30
- ruleEngine: RuleEngine;
31
- }
32
- /**
33
- * Generic interface which defines {@link State | form object state}.
34
- * @typeparam T type of the form object (for example, {@link FieldJson | form field}
35
- */
36
- interface WithState<T> {
37
- /**
38
- * {@link State | state} of the form object
39
- */
40
- getState: () => any;
41
- }
42
- declare type stateProps = {
43
- id: string;
44
- index: number;
45
- ':type': string;
46
- };
47
- /** Generic type for a form object state */
48
- export declare type State<T> = stateProps & (T extends ContainerJson ? T & {
49
- items: Array<State<FieldJson | ContainerJson>>;
50
- } : T);
51
- /**
52
- * @private
53
- */
54
- export declare type Subscription = {
55
- unsubscribe(): void;
56
- };
57
- /**
58
- * Generic Action/Event interface.
59
- * Defines common properties that each action/event should have
60
- */
61
- export interface Action {
62
- /**
63
- * Name of the event.
64
- */
65
- type: string;
66
- /**
67
- * Event payload as defined by the event.
68
- */
69
- payload: any;
70
- /**
71
- * Event metadata.
72
- */
73
- metadata: any;
74
- /**
75
- * Is the event custom
76
- */
77
- readonly isCustomEvent: boolean;
78
- /**
79
- * The field element on which the event is triggered.
80
- */
81
- readonly target: FormModel | FieldModel | FieldsetModel;
82
- /**
83
- * Original event. If the event is dispatched, this refers the original event
84
- */
85
- readonly originalAction?: Action;
86
- }
87
- /**
88
- * @private
89
- */
90
- export declare type callbackFn = (action: Action) => void;
91
- /**
92
- * @private
93
- */
94
- export interface WithController {
95
- /**
96
- * @param callback
97
- * @param eventName
98
- * @private
99
- */
100
- subscribe(callback: callbackFn, eventName?: string): Subscription;
101
- /**
102
- * @param action
103
- * @private
104
- */
105
- dispatch(action: Action): void;
106
- }
107
- /**
108
- * Generic base model interface.
109
- * Defines common properties that each form field should have
110
- */
111
- export interface BaseModel extends ConstraintsJson, WithController {
112
- /**
113
- * Name of the form field.
114
- */
115
- readonly name?: string;
116
- /**
117
- * To map the field’s value to a property in the data model.
118
- */
119
- readonly dataRef?: string | null;
120
- /**
121
- * Unique id of the form field.
122
- */
123
- readonly id: string;
124
- /**
125
- * The index of the Field within its parent.
126
- */
127
- readonly index: number;
128
- /**
129
- *
130
- */
131
- readonly qualifiedName: string;
132
- /**
133
- * Label to be used for the field.
134
- */
135
- label?: Label;
136
- /**
137
- * Extra description to be shown to the user to aid in form filling experience. It can be rich text.
138
- */
139
- description?: string;
140
- /**
141
- * Whether the field should be readOnly to end user or not.
142
- */
143
- readOnly?: boolean;
144
- /**
145
- * Whether the field is enabled and takes part in rules, events etc.
146
- */
147
- enabled?: boolean;
148
- /**
149
- * Whether the field should be visible to author or not.
150
- */
151
- visible?: boolean;
152
- /**
153
- * The placeholder to show on the widget.
154
- */
155
- placeholder?: string;
156
- /**
157
- * The current validation state of the Field. The property is always computed after merging the Data Model with the Form
158
- */
159
- valid?: boolean;
160
- /**
161
- * Custom widget type show to the user for capturing the data.
162
- */
163
- readonly ':type': string;
164
- /**
165
- * Type of field to capture the user data.
166
- */
167
- readonly 'fieldType': string;
168
- /**
169
- * Custom properties of the form field.
170
- */
171
- properties: {
172
- [key: string]: any;
173
- };
174
- /**
175
- * Whether the form field is container or not
176
- */
177
- readonly isContainer: boolean;
178
- /**
179
- * The Parent Panel of the Field/Panel.
180
- */
181
- readonly parent: ContainerModel | null;
182
- /**
183
- * Array containing Fields or Panels.
184
- */
185
- readonly items?: Array<FieldsetModel | FieldModel>;
186
- /**
187
- * The current value of the Field. The property is serialized in the Data Model.
188
- */
189
- value: any;
190
- /**
191
- * Default value of the Field.
192
- */
193
- readonly default?: any;
194
- /**
195
- * Field is repeatable or not
196
- */
197
- readonly repeatable?: boolean;
198
- /**
199
- * Validates the given form field
200
- * @returns list of {@link ValidationError | validation errors}
201
- */
202
- validate(): Array<ValidationError>;
203
- /**
204
- * Resets the form model
205
- */
206
- reset(): any;
207
- /**
208
- * Imports data to the form field
209
- * @private
210
- */
211
- importData(a?: DataGroup): any;
212
- /**
213
- * @private
214
- */
215
- getRuleNode(): any;
216
- /**
217
- * @private
218
- */
219
- ruleNodeReference(): any;
220
- /**
221
- * @private
222
- */
223
- _initialize(): any;
224
- /**
225
- * @private
226
- */
227
- _addDependent(dependent: BaseModel): any;
228
- }
229
- /**
230
- * Generic field model interface.
231
- * Defines properties that each form field should have
232
- */
233
- export interface FieldModel extends BaseModel, ScriptableField, WithState<FieldJson> {
234
- /**
235
- * Parent of the current field
236
- */
237
- parent: ContainerModel;
238
- /**
239
- * format in which user will edit the value
240
- */
241
- readonly editFormat?: string;
242
- /**
243
- * format in which user will see the value after update
244
- */
245
- readonly displayFormat?: string;
246
- /**
247
- * value to be displayed to the user after update
248
- */
249
- readonly displayValue?: string;
250
- /**
251
- * value to be displayed to the user for edit
252
- */
253
- readonly editValue?: string;
254
- }
255
- /**
256
- * Defines form meta data properties
257
- */
258
- export interface FormMetaDataModel {
259
- /**
260
- * Version of the adaptive form specification
261
- */
262
- readonly version: string;
263
- /**
264
- * Version of the rule grammar
265
- */
266
- readonly grammar: string;
267
- /**
268
- * Form locale
269
- */
270
- readonly locale: string;
271
- }
272
- /**
273
- * Generic container model interface.
274
- * Defines properties that each container should have
275
- */
276
- export interface ContainerModel extends BaseModel, ScriptableField {
277
- /**
278
- * Defines the children/items of the container
279
- */
280
- items: Array<FieldsetModel | FieldModel>;
281
- /**
282
- * Defines the parent of the container
283
- */
284
- parent: ContainerModel;
285
- /**
286
- * Returns the index of the {@link FieldModel | child item} or the {@link FieldsetModel | child container}
287
- * @param f child item
288
- * @returns `index` of the item
289
- */
290
- indexOf(f: FieldModel | FieldsetModel): number;
291
- isTransparent(): boolean;
292
- activeChild: BaseModel | null;
293
- }
294
- /**
295
- * Generic field set model interface.
296
- * Defines properties that each field set should have
297
- */
298
- export interface FieldsetModel extends ContainerModel, WithState<FieldsetJson> {
299
- type?: 'array' | 'object';
300
- }
301
- /**
302
- * Defines the interface for form model
303
- */
304
- export interface FormModel extends ContainerModel, WithState<FormJson> {
305
- /**
306
- * Id of the form.
307
- */
308
- readonly id: string;
309
- /**
310
- * Form data
311
- */
312
- readonly data?: any;
313
- /**
314
- * Form metadata
315
- */
316
- readonly metadata?: MetaDataJson;
317
- /**
318
- * Form title.
319
- */
320
- readonly title: string;
321
- readonly logger: Logger;
322
- /**
323
- * Imports the given form data
324
- * @param data form data
325
- */
326
- importData(data: any): any;
327
- /**
328
- * Exports the form data
329
- */
330
- exportData(): any;
331
- /**
332
- * Get form element model based on the id of the form element
333
- * @param id id of the form element
334
- */
335
- getElement(id: string): FieldModel | FormModel | FieldsetModel;
336
- /**
337
- * @private
338
- */
339
- getUniqueId(): string;
340
- /**
341
- * @private
342
- */
343
- getEventQueue(): EventQueue;
344
- /**
345
- * visits each element in the form
346
- * @param callBack a function which is invoked on each form element
347
- * (including container type elements) visited
348
- */
349
- visit(callBack: (field: FieldModel | FieldsetModel) => void): void;
350
- }
351
- /**
352
- * Defines file object interface.
353
- */
354
- export interface IFileObject {
355
- /**
356
- * Name of the file
357
- */
358
- name: string;
359
- /**
360
- * Media type of the file data
361
- */
362
- mediaType: string;
363
- /**
364
- * Data of the file attachment. It can be uri or any file interface specific to channel (in web, it is file object).
365
- */
366
- data?: any;
367
- /**
368
- * Size of the file binary as per iec specification.
369
- */
370
- size?: number;
371
- }
372
- /**
373
- * Defines Validation Error interface.
374
- */
375
- export interface IValidationError {
376
- /**
377
- * {@link FieldModel.id | name} of the field
378
- */
379
- fieldName: string;
380
- /**
381
- * List of error messages
382
- */
383
- errorMessages: Array<string>;
384
- }
385
- /**
386
- * Implementation of {@link IValidationError | Validation Error} interface
387
- */
388
- export declare class ValidationError implements IValidationError {
389
- fieldName: string;
390
- errorMessages: Array<string>;
391
- constructor(fieldName?: string, errorMessages?: Array<any>);
392
- }
393
- export {};
@@ -1,20 +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.ValidationError = void 0;
11
- /**
12
- * Implementation of {@link IValidationError | Validation Error} interface
13
- */
14
- class ValidationError {
15
- constructor(fieldName = '', errorMessages = []) {
16
- this.errorMessages = errorMessages;
17
- this.fieldName = fieldName;
18
- }
19
- }
20
- exports.ValidationError = ValidationError;
@@ -1,2 +0,0 @@
1
- export * from './Json';
2
- export * from './Model';
@@ -1,25 +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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- __exportStar(require("./Json"), exports);
25
- __exportStar(require("./Model"), exports);
@@ -1,87 +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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
- return new (P || (P = Promise))(function (resolve, reject) {
12
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
- step((generator = generator.apply(thisArg, _arguments || [])).next());
16
- });
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.convertQueryString = exports.request = void 0;
20
- /**
21
- *
22
- * @param url
23
- * @param data
24
- * @param options
25
- */
26
- const request = (url, data = null, options = {}) => {
27
- const opts = Object.assign(Object.assign({}, defaultRequestOptions), options);
28
- const updatedUrl = opts.method === 'GET' && data ? (0, exports.convertQueryString)(url, data) : url;
29
- if (opts.method !== 'GET') {
30
- opts.body = data;
31
- }
32
- return fetch(updatedUrl, Object.assign({}, opts)).then((response) => __awaiter(void 0, void 0, void 0, function* () {
33
- var _a, _b, _c;
34
- let body;
35
- if (!response.ok) {
36
- console.error(`Error fetching response from ${url} : ${response.statusText}`);
37
- body = response.statusText;
38
- }
39
- else {
40
- if ((_b = (_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a.get('Content-Type')) === null || _b === void 0 ? void 0 : _b.includes('application/json')) {
41
- body = yield response.json();
42
- }
43
- else {
44
- body = yield response.text();
45
- }
46
- }
47
- const headers = {};
48
- (_c = response === null || response === void 0 ? void 0 : response.headers) === null || _c === void 0 ? void 0 : _c.forEach((value, key) => {
49
- headers[key] = value;
50
- });
51
- return {
52
- status: response.status,
53
- body,
54
- headers
55
- };
56
- }));
57
- };
58
- exports.request = request;
59
- const defaultRequestOptions = {
60
- method: 'GET'
61
- };
62
- const convertQueryString = (endpoint, payload) => {
63
- if (!payload) {
64
- return endpoint;
65
- }
66
- let updatedPayload = {};
67
- try {
68
- updatedPayload = JSON.parse(payload);
69
- }
70
- catch (err) {
71
- console.log('Query params invalid');
72
- }
73
- const params = [];
74
- Object.keys(updatedPayload).forEach((key) => {
75
- if (Array.isArray(updatedPayload[key])) {
76
- params.push(`${encodeURIComponent(key)}=${encodeURIComponent(JSON.stringify(updatedPayload[key]))}`);
77
- }
78
- else {
79
- params.push(`${encodeURIComponent(key)}=${encodeURIComponent(updatedPayload[key])}`);
80
- }
81
- });
82
- if (!params.length) {
83
- return endpoint;
84
- }
85
- return endpoint.includes('?') ? `${endpoint}&${params.join('&')}` : `${endpoint}?${params.join('&')}`;
86
- };
87
- exports.convertQueryString = convertQueryString;
@@ -1,11 +0,0 @@
1
- import { ContainerModel, FieldJson, FieldModel, FieldsetJson, FieldsetModel, FormModel } from '../types';
2
- /**
3
- * Creates a child model inside the given parent
4
- * @param child
5
- * @param options
6
- * @private
7
- */
8
- export declare const createChild: (child: FieldsetJson | FieldJson, options: {
9
- form: FormModel;
10
- parent: ContainerModel;
11
- }, repeatableInstance?: boolean) => FieldModel | FieldsetModel;
@@ -1,83 +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 __rest = (this && this.__rest) || function (s, e) {
10
- var t = {};
11
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
12
- t[p] = s[p];
13
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
14
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
15
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
16
- t[p[i]] = s[p[i]];
17
- }
18
- return t;
19
- };
20
- var __importDefault = (this && this.__importDefault) || function (mod) {
21
- return (mod && mod.__esModule) ? mod : { "default": mod };
22
- };
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.createChild = void 0;
25
- const InstanceManager_1 = require("../InstanceManager");
26
- const Fieldset_1 = require("../Fieldset");
27
- const JsonUtils_1 = require("./JsonUtils");
28
- const FileUpload_1 = __importDefault(require("../FileUpload"));
29
- const Checkbox_1 = __importDefault(require("../Checkbox"));
30
- const CheckboxGroup_1 = __importDefault(require("../CheckboxGroup"));
31
- const DateField_1 = __importDefault(require("../DateField"));
32
- const Field_1 = __importDefault(require("../Field"));
33
- /**
34
- * Creates a child model inside the given parent
35
- * @param child
36
- * @param options
37
- * @private
38
- */
39
- const createChild = (child, options, repeatableInstance = false) => {
40
- let retVal;
41
- // if repeatable is set
42
- if ((0, JsonUtils_1.isRepeatable)(child) && !repeatableInstance) {
43
- const childItemsWithMinAndMaxOccur = Object.assign(Object.assign({}, child), ('items' in child && { 'type': 'object' }));
44
- // remove minOccur and maxOccur from child items
45
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
- const { minOccur, maxOccur } = childItemsWithMinAndMaxOccur, childItems = __rest(childItemsWithMinAndMaxOccur, ["minOccur", "maxOccur"]);
47
- const newJson = Object.assign({
48
- minItems: child.minOccur || 0,
49
- maxItems: child.maxOccur || -1,
50
- fieldType: child.fieldType,
51
- type: 'array',
52
- name: child.name,
53
- dataRef: child.dataRef // can't destructure entire child here
54
- }, {
55
- 'items': [childItems]
56
- });
57
- retVal = new InstanceManager_1.InstanceManager(newJson, options);
58
- }
59
- else if ('items' in child) {
60
- retVal = new Fieldset_1.Fieldset(child, options);
61
- }
62
- else {
63
- if ((0, JsonUtils_1.isFile)(child) || child.fieldType === 'file-input') {
64
- // @ts-ignore
65
- retVal = new FileUpload_1.default(child, options);
66
- }
67
- else if ((0, JsonUtils_1.isCheckbox)(child)) {
68
- retVal = new Checkbox_1.default(child, options);
69
- }
70
- else if ((0, JsonUtils_1.isCheckboxGroup)(child)) {
71
- retVal = new CheckboxGroup_1.default(child, options);
72
- }
73
- else if ((0, JsonUtils_1.isDateField)(child)) {
74
- retVal = new DateField_1.default(child, options);
75
- }
76
- else {
77
- retVal = new Field_1.default(child, options);
78
- }
79
- }
80
- options.form.fieldAdded(retVal);
81
- return retVal;
82
- };
83
- exports.createChild = createChild;
@@ -1,47 +0,0 @@
1
- import { ContainerModel } from '../types';
2
- /**
3
- * Utility to generate a random word from seed
4
- * @param l seed value
5
- * @returns random word
6
- */
7
- export declare const randomWord: (l: number) => string;
8
- /**
9
- * Utility to check if the value is empty
10
- * @param value value
11
- * @returns `true` if value is empty, `false` otherwise
12
- */
13
- export declare const isEmpty: (value: any) => boolean;
14
- /**
15
- * Returns the list of attachments with its data reference
16
- * @param input form model
17
- * @returns list of file attachments {@link FileObject} present in the form
18
- */
19
- export declare const getAttachments: (input: ContainerModel) => any;
20
- /**
21
- * Converts file size in string to bytes based on IEC specification
22
- * @param str file size
23
- * @returns file size as bytes (in kb) based on IEC specification
24
- */
25
- export declare const getFileSizeInBytes: (str: any) => number;
26
- /**
27
- * ID Generator
28
- * @param initial
29
- * @constructor
30
- * @private
31
- */
32
- export declare const IdGenerator: (initial?: number) => Generator<string, void, string>;
33
- /**
34
- * Utility to extract {@link FileObject} from string or HTML File data type
35
- * @param file
36
- * @returns list of {@link FileObject}
37
- */
38
- export declare const extractFileInfo: (file: any) => any;
39
- /**
40
- * Utility to convert data URI to a `blob` object
41
- * @param dataURI uri to convert to blob
42
- * @returns `Blob` object for the data URI
43
- */
44
- export declare const dataURItoBlob: (dataURI: string) => {
45
- name: string;
46
- blob: Blob;
47
- } | null;