@aemforms/af-core 0.22.19 → 0.22.22
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.
- package/LICENSE +18 -4
- package/lib/cjs/index.cjs +7277 -0
- package/lib/{BaseNode.js → esm/BaseNode-dc59ab07.js} +108 -184
- package/lib/{BaseNode.d.ts → esm/BaseNode.d.ts} +10 -69
- package/lib/esm/BaseNode.js +26 -0
- package/lib/esm/Checkbox.d.ts +79 -0
- package/lib/esm/Checkbox.js +63 -0
- package/lib/{CheckboxGroup.d.ts → esm/CheckboxGroup.d.ts} +2 -14
- package/lib/esm/CheckboxGroup.js +60 -0
- package/lib/{Container.d.ts → esm/Container.d.ts} +12 -59
- package/lib/{Container.js → esm/Container.js} +81 -122
- package/lib/{DateField.d.ts → esm/DateField.d.ts} +1 -1
- package/lib/esm/DateField.js +57 -0
- package/lib/{Field.d.ts → esm/Field.d.ts} +41 -106
- package/lib/{Field.js → esm/Field.js} +186 -216
- package/lib/esm/Fieldset.d.ts +16 -0
- package/lib/esm/Fieldset.js +78 -0
- package/lib/{FileObject.d.ts → esm/FileObject.d.ts} +1 -4
- package/lib/esm/FileObject.js +48 -0
- package/lib/{FileUpload.d.ts → esm/FileUpload.d.ts} +3 -18
- package/lib/esm/FileUpload.js +141 -0
- package/lib/{Form.d.ts → esm/Form.d.ts} +20 -86
- package/lib/esm/Form.js +208 -0
- package/lib/esm/FormInstance.d.ts +13 -0
- package/lib/esm/FormInstance.js +129 -0
- package/lib/esm/FormMetaData.d.ts +7 -0
- package/lib/esm/FormMetaData.js +35 -0
- package/lib/esm/InstanceManager.d.ts +9 -0
- package/lib/esm/InstanceManager.js +58 -0
- package/lib/esm/Node.d.ts +7 -0
- package/lib/esm/Node.js +40 -0
- package/lib/esm/Scriptable.d.ts +17 -0
- package/lib/{Scriptable.js → esm/Scriptable.js} +38 -54
- package/lib/{controller → esm/controller}/EventQueue.d.ts +3 -11
- package/lib/{controller → esm/controller}/EventQueue.js +32 -26
- package/lib/esm/controller/Events.d.ts +85 -0
- package/lib/esm/controller/Events.js +171 -0
- package/lib/{controller → esm/controller}/Logger.d.ts +2 -8
- package/lib/esm/controller/Logger.js +52 -0
- package/lib/{data → esm/data}/DataGroup.d.ts +1 -7
- package/lib/{data → esm/data}/DataGroup.js +38 -34
- package/lib/{data → esm/data}/DataValue.d.ts +1 -7
- package/lib/esm/data/DataValue.js +68 -0
- package/lib/{data → esm/data}/EmptyDataValue.d.ts +1 -1
- package/lib/esm/data/EmptyDataValue.js +51 -0
- package/lib/esm/index.d.ts +21 -0
- package/lib/esm/index.js +55 -0
- package/lib/{rules → esm/rules}/FunctionRuntime.d.ts +3 -25
- package/lib/{rules → esm/rules}/FunctionRuntime.js +66 -117
- package/lib/esm/rules/RuleEngine.d.ts +12 -0
- package/lib/esm/rules/RuleEngine.js +76 -0
- package/lib/esm/types/Json.d.ts +119 -0
- package/lib/esm/types/Json.js +29 -0
- package/lib/esm/types/Model.d.ts +131 -0
- package/lib/esm/types/Model.js +30 -0
- package/lib/esm/types/index.d.ts +2 -0
- package/lib/esm/types/index.js +22 -0
- package/lib/{utils → esm/utils}/DataRefParser.d.ts +4 -7
- package/lib/{utils → esm/utils}/DataRefParser.js +42 -44
- package/lib/{utils → esm/utils}/Fetch.d.ts +1 -7
- package/lib/esm/utils/Fetch.js +83 -0
- package/lib/esm/utils/FormCreationUtils.d.ts +9 -0
- package/lib/esm/utils/FormCreationUtils.js +112 -0
- package/lib/esm/utils/FormUtils.d.ts +12 -0
- package/lib/esm/utils/FormUtils.js +212 -0
- package/lib/esm/utils/JsonUtils.d.ts +11 -0
- package/lib/esm/utils/JsonUtils.js +99 -0
- package/lib/{utils → esm/utils}/LogUtils.d.ts +1 -4
- package/lib/esm/utils/LogUtils.js +28 -0
- package/lib/esm/utils/SchemaUtils.d.ts +3 -0
- package/lib/esm/utils/SchemaUtils.js +93 -0
- package/lib/esm/utils/TranslationUtils.d.ts +11 -0
- package/lib/esm/utils/TranslationUtils.js +138 -0
- package/lib/esm/utils/ValidationUtils.d.ts +19 -0
- package/lib/{utils → esm/utils}/ValidationUtils.js +55 -187
- package/package.json +18 -10
- package/lib/Checkbox.d.ts +0 -88
- package/lib/Checkbox.js +0 -49
- package/lib/CheckboxGroup.js +0 -43
- package/lib/DateField.js +0 -35
- package/lib/Fieldset.d.ts +0 -24
- package/lib/Fieldset.js +0 -74
- package/lib/FileObject.js +0 -39
- package/lib/FileUpload.js +0 -155
- package/lib/Form.js +0 -252
- package/lib/FormInstance.d.ts +0 -38
- package/lib/FormInstance.js +0 -127
- package/lib/FormMetaData.d.ts +0 -11
- package/lib/FormMetaData.js +0 -28
- package/lib/InstanceManager.d.ts +0 -16
- package/lib/InstanceManager.js +0 -53
- package/lib/Node.d.ts +0 -12
- package/lib/Node.js +0 -27
- package/lib/Scriptable.d.ts +0 -31
- package/lib/controller/Controller.d.ts +0 -255
- package/lib/controller/Controller.js +0 -328
- package/lib/controller/Logger.js +0 -36
- package/lib/controller/index.d.ts +0 -1
- package/lib/controller/index.js +0 -24
- package/lib/data/DataValue.js +0 -56
- package/lib/data/EmptyDataValue.js +0 -46
- package/lib/index.d.ts +0 -28
- package/lib/index.js +0 -63
- package/lib/rules/RuleEngine.d.ts +0 -23
- package/lib/rules/RuleEngine.js +0 -62
- package/lib/types/Json.d.ts +0 -138
- package/lib/types/Json.js +0 -19
- package/lib/types/Model.d.ts +0 -393
- package/lib/types/Model.js +0 -20
- package/lib/types/index.d.ts +0 -2
- package/lib/types/index.js +0 -25
- package/lib/utils/Fetch.js +0 -87
- package/lib/utils/FormCreationUtils.d.ts +0 -11
- package/lib/utils/FormCreationUtils.js +0 -83
- package/lib/utils/FormUtils.d.ts +0 -47
- package/lib/utils/FormUtils.js +0 -257
- package/lib/utils/JsonUtils.d.ts +0 -63
- package/lib/utils/JsonUtils.js +0 -157
- package/lib/utils/LogUtils.js +0 -17
- package/lib/utils/SchemaUtils.d.ts +0 -16
- package/lib/utils/SchemaUtils.js +0 -92
- package/lib/utils/TranslationUtils.d.ts +0 -41
- package/lib/utils/TranslationUtils.js +0 -185
- package/lib/utils/ValidationUtils.d.ts +0 -170
package/lib/esm/Form.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* ___________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2022 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
|
|
17
|
+
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
+
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
+
*************************************************************************/
|
|
20
|
+
|
|
21
|
+
import Container from './Container.js';
|
|
22
|
+
import FormMetaData from './FormMetaData.js';
|
|
23
|
+
import EventQueue from './controller/EventQueue.js';
|
|
24
|
+
import { Logger } from './controller/Logger.js';
|
|
25
|
+
import { IdGenerator, getAttachments } from './utils/FormUtils.js';
|
|
26
|
+
import DataGroup from './data/DataGroup.js';
|
|
27
|
+
import { submit } from './rules/FunctionRuntime.js';
|
|
28
|
+
import { Initialize, ExecuteRule, FormLoad, FieldChanged, ValidationComplete } from './controller/Events.js';
|
|
29
|
+
import './BaseNode-dc59ab07.js';
|
|
30
|
+
import './utils/DataRefParser.js';
|
|
31
|
+
import './data/DataValue.js';
|
|
32
|
+
import './data/EmptyDataValue.js';
|
|
33
|
+
import './utils/JsonUtils.js';
|
|
34
|
+
import './types/Json.js';
|
|
35
|
+
import './utils/SchemaUtils.js';
|
|
36
|
+
import './Scriptable.js';
|
|
37
|
+
import './Node.js';
|
|
38
|
+
import './FileObject.js';
|
|
39
|
+
import './utils/Fetch.js';
|
|
40
|
+
|
|
41
|
+
class Form extends Container {
|
|
42
|
+
_ruleEngine;
|
|
43
|
+
_eventQueue;
|
|
44
|
+
_fields = {};
|
|
45
|
+
_ids;
|
|
46
|
+
_invalidFields = [];
|
|
47
|
+
_logger;
|
|
48
|
+
constructor(n, fieldFactory, _ruleEngine, _eventQueue = new EventQueue(), logLevel = 'off') {
|
|
49
|
+
super(n, { fieldFactory: fieldFactory });
|
|
50
|
+
this._ruleEngine = _ruleEngine;
|
|
51
|
+
this._eventQueue = _eventQueue;
|
|
52
|
+
this._logger = new Logger(logLevel);
|
|
53
|
+
this.queueEvent(new Initialize());
|
|
54
|
+
this.queueEvent(new ExecuteRule());
|
|
55
|
+
this._ids = IdGenerator();
|
|
56
|
+
this._bindToDataModel(new DataGroup('$form', {}));
|
|
57
|
+
this._initialize();
|
|
58
|
+
this.queueEvent(new FormLoad());
|
|
59
|
+
}
|
|
60
|
+
get logger() {
|
|
61
|
+
return this._logger;
|
|
62
|
+
}
|
|
63
|
+
dataRefRegex = /("[^"]+?"|[^.]+?)(?:\.|$)/g;
|
|
64
|
+
get metaData() {
|
|
65
|
+
const metaData = this._jsonModel.metadata || {};
|
|
66
|
+
return new FormMetaData(metaData);
|
|
67
|
+
}
|
|
68
|
+
get action() {
|
|
69
|
+
return this._jsonModel.action;
|
|
70
|
+
}
|
|
71
|
+
get lang() {
|
|
72
|
+
return this._jsonModel.lang || 'en';
|
|
73
|
+
}
|
|
74
|
+
importData(dataModel) {
|
|
75
|
+
this._bindToDataModel(new DataGroup('$form', dataModel));
|
|
76
|
+
this.syncDataAndFormModel(this.getDataNode());
|
|
77
|
+
this._eventQueue.runPendingQueue();
|
|
78
|
+
}
|
|
79
|
+
exportData() {
|
|
80
|
+
return this.getDataNode()?.$value;
|
|
81
|
+
}
|
|
82
|
+
setFocus(field) {
|
|
83
|
+
const parent = field.parent;
|
|
84
|
+
const currentField = field;
|
|
85
|
+
while (parent != null && parent.activeChild != currentField) {
|
|
86
|
+
parent.activeChild = currentField;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
getState() {
|
|
90
|
+
const self = this;
|
|
91
|
+
const res = super.getState();
|
|
92
|
+
res.id = '$form';
|
|
93
|
+
Object.defineProperty(res, 'data', {
|
|
94
|
+
get: function () {
|
|
95
|
+
return self.exportData();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(res, 'attachments', {
|
|
99
|
+
get: function () {
|
|
100
|
+
return getAttachments(self);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return res;
|
|
104
|
+
}
|
|
105
|
+
get type() {
|
|
106
|
+
return 'object';
|
|
107
|
+
}
|
|
108
|
+
isTransparent() {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
get form() {
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
get ruleEngine() {
|
|
115
|
+
return this._ruleEngine;
|
|
116
|
+
}
|
|
117
|
+
getUniqueId() {
|
|
118
|
+
if (this._ids == null) {
|
|
119
|
+
return '';
|
|
120
|
+
}
|
|
121
|
+
return this._ids.next().value;
|
|
122
|
+
}
|
|
123
|
+
fieldAdded(field) {
|
|
124
|
+
this._fields[field.id] = field;
|
|
125
|
+
field.subscribe((action) => {
|
|
126
|
+
if (this._invalidFields.indexOf(action.target.id) === -1) {
|
|
127
|
+
this._invalidFields.push(action.target.id);
|
|
128
|
+
}
|
|
129
|
+
}, 'invalid');
|
|
130
|
+
field.subscribe((action) => {
|
|
131
|
+
const index = this._invalidFields.indexOf(action.target.id);
|
|
132
|
+
if (index > -1) {
|
|
133
|
+
this._invalidFields.splice(index, 1);
|
|
134
|
+
}
|
|
135
|
+
}, 'valid');
|
|
136
|
+
field.subscribe((action) => {
|
|
137
|
+
const field = action.target.getState();
|
|
138
|
+
if (field) {
|
|
139
|
+
const fieldChangedAction = new FieldChanged(action.payload.changes, field);
|
|
140
|
+
this.dispatch(fieldChangedAction);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
visit(callBack) {
|
|
145
|
+
this.traverseChild(this, callBack);
|
|
146
|
+
}
|
|
147
|
+
traverseChild(container, callBack) {
|
|
148
|
+
container.items.forEach((field) => {
|
|
149
|
+
if (field.isContainer) {
|
|
150
|
+
this.traverseChild(field, callBack);
|
|
151
|
+
}
|
|
152
|
+
callBack(field);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
validate() {
|
|
156
|
+
const validationErrors = super.validate();
|
|
157
|
+
this.dispatch(new ValidationComplete(validationErrors));
|
|
158
|
+
return validationErrors;
|
|
159
|
+
}
|
|
160
|
+
isValid() {
|
|
161
|
+
return this._invalidFields.length === 0;
|
|
162
|
+
}
|
|
163
|
+
dispatch(action) {
|
|
164
|
+
if (action.type === 'submit') {
|
|
165
|
+
super.queueEvent(action);
|
|
166
|
+
this._eventQueue.runPendingQueue();
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
super.dispatch(action);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
submit(action, context) {
|
|
173
|
+
if (this.validate().length === 0) {
|
|
174
|
+
const payload = action?.payload || {};
|
|
175
|
+
submit(context, payload?.success, payload?.error, payload?.submit_as, payload?.data);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
reset() {
|
|
179
|
+
super.reset();
|
|
180
|
+
this._invalidFields = [];
|
|
181
|
+
}
|
|
182
|
+
getElement(id) {
|
|
183
|
+
if (id == this.id) {
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
return this._fields[id];
|
|
187
|
+
}
|
|
188
|
+
get qualifiedName() {
|
|
189
|
+
return '$form';
|
|
190
|
+
}
|
|
191
|
+
getEventQueue() {
|
|
192
|
+
return this._eventQueue;
|
|
193
|
+
}
|
|
194
|
+
get name() {
|
|
195
|
+
return '$form';
|
|
196
|
+
}
|
|
197
|
+
get value() {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
get id() {
|
|
201
|
+
return '$form';
|
|
202
|
+
}
|
|
203
|
+
get title() {
|
|
204
|
+
return this._jsonModel.title || '';
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export { Form as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FormModel } from './types/index.js';
|
|
2
|
+
import { LogLevel } from './controller/Logger.js';
|
|
3
|
+
import { CustomFunction, FunctionDefinition } from './rules/FunctionRuntime.js';
|
|
4
|
+
export declare const createFormInstance: (formModel: any, callback?: ((f: FormModel) => any) | undefined, logLevel?: LogLevel, fModel?: any) => FormModel;
|
|
5
|
+
export declare const validateFormInstance: (formModel: any, data: any) => boolean;
|
|
6
|
+
export declare const validateFormData: (formModel: any, data: any) => {
|
|
7
|
+
messages: any[];
|
|
8
|
+
valid: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const fetchForm: (url: string, headers?: any) => Promise<string>;
|
|
11
|
+
export declare const registerFunctions: (functions: {
|
|
12
|
+
[key: string]: Function | FunctionDefinition;
|
|
13
|
+
}) => void;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* ___________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2022 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
|
|
17
|
+
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
+
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
+
*************************************************************************/
|
|
20
|
+
|
|
21
|
+
import Form from './Form.js';
|
|
22
|
+
import { jsonString } from './utils/JsonUtils.js';
|
|
23
|
+
import { request } from './utils/Fetch.js';
|
|
24
|
+
import RuleEngine from './rules/RuleEngine.js';
|
|
25
|
+
import EventQueue from './controller/EventQueue.js';
|
|
26
|
+
import { Logger } from './controller/Logger.js';
|
|
27
|
+
import { FormFieldFactory } from './utils/FormCreationUtils.js';
|
|
28
|
+
import { FunctionRuntime } from './rules/FunctionRuntime.js';
|
|
29
|
+
import './Container.js';
|
|
30
|
+
import './BaseNode-dc59ab07.js';
|
|
31
|
+
import './controller/Events.js';
|
|
32
|
+
import './utils/DataRefParser.js';
|
|
33
|
+
import './data/DataGroup.js';
|
|
34
|
+
import './data/DataValue.js';
|
|
35
|
+
import './data/EmptyDataValue.js';
|
|
36
|
+
import './Scriptable.js';
|
|
37
|
+
import './types/Json.js';
|
|
38
|
+
import './utils/SchemaUtils.js';
|
|
39
|
+
import './FormMetaData.js';
|
|
40
|
+
import './Node.js';
|
|
41
|
+
import './utils/FormUtils.js';
|
|
42
|
+
import './FileObject.js';
|
|
43
|
+
import '@adobe/json-formula';
|
|
44
|
+
import './InstanceManager.js';
|
|
45
|
+
import './Fieldset.js';
|
|
46
|
+
import './FileUpload.js';
|
|
47
|
+
import './Field.js';
|
|
48
|
+
import './types/Model.js';
|
|
49
|
+
import './utils/ValidationUtils.js';
|
|
50
|
+
import '@aemforms/af-formatters';
|
|
51
|
+
import './Checkbox.js';
|
|
52
|
+
import './CheckboxGroup.js';
|
|
53
|
+
import './DateField.js';
|
|
54
|
+
|
|
55
|
+
const createFormInstance = (formModel, callback, logLevel = 'error', fModel = undefined) => {
|
|
56
|
+
try {
|
|
57
|
+
let f = fModel;
|
|
58
|
+
if (f == null) {
|
|
59
|
+
f = new Form({ ...formModel }, FormFieldFactory, new RuleEngine(), new EventQueue(new Logger(logLevel)), logLevel);
|
|
60
|
+
}
|
|
61
|
+
const formData = formModel?.data;
|
|
62
|
+
if (formData) {
|
|
63
|
+
f.importData(formData);
|
|
64
|
+
}
|
|
65
|
+
if (typeof callback === 'function') {
|
|
66
|
+
callback(f);
|
|
67
|
+
}
|
|
68
|
+
f.getEventQueue().runPendingQueue();
|
|
69
|
+
return f;
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
console.error(`Unable to create an instance of the Form ${e}`);
|
|
73
|
+
throw new Error(e);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const validateFormInstance = (formModel, data) => {
|
|
77
|
+
try {
|
|
78
|
+
const f = new Form({ ...formModel }, FormFieldFactory, new RuleEngine());
|
|
79
|
+
if (data) {
|
|
80
|
+
f.importData(data);
|
|
81
|
+
}
|
|
82
|
+
return f.validate().length === 0;
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
throw new Error(e);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const validateFormData = (formModel, data) => {
|
|
89
|
+
try {
|
|
90
|
+
const f = new Form({ ...formModel }, FormFieldFactory, new RuleEngine());
|
|
91
|
+
if (data) {
|
|
92
|
+
f.importData(data);
|
|
93
|
+
}
|
|
94
|
+
const res = f.validate();
|
|
95
|
+
return {
|
|
96
|
+
messages: res,
|
|
97
|
+
valid: res.length === 0
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
throw new Error(e);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const fetchForm = (url, headers = {}) => {
|
|
105
|
+
const headerObj = new Headers();
|
|
106
|
+
Object.entries(headers).forEach(([key, value]) => {
|
|
107
|
+
headerObj.append(key, value);
|
|
108
|
+
});
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
request(`${url}.model.json`, null, { headers }).then((response) => {
|
|
111
|
+
if (response.status !== 200) {
|
|
112
|
+
reject('Not Found');
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
let formObj = response.body;
|
|
116
|
+
if ('model' in formObj) {
|
|
117
|
+
const { model } = formObj;
|
|
118
|
+
formObj = model;
|
|
119
|
+
}
|
|
120
|
+
resolve(jsonString(formObj));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
const registerFunctions = (functions) => {
|
|
126
|
+
FunctionRuntime.registerFunctions(functions);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export { createFormInstance, fetchForm, registerFunctions, validateFormData, validateFormInstance };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormMetaDataModel, MetaDataJson } from './types/index.js';
|
|
2
|
+
import Node from './Node.js';
|
|
3
|
+
declare class FormMetaData extends Node<MetaDataJson> implements FormMetaDataModel {
|
|
4
|
+
get version(): string;
|
|
5
|
+
get grammar(): string;
|
|
6
|
+
}
|
|
7
|
+
export default FormMetaData;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* ___________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2022 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
|
|
17
|
+
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
+
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
+
*************************************************************************/
|
|
20
|
+
|
|
21
|
+
import Node from './Node.js';
|
|
22
|
+
import './utils/JsonUtils.js';
|
|
23
|
+
import './types/Json.js';
|
|
24
|
+
import './utils/SchemaUtils.js';
|
|
25
|
+
|
|
26
|
+
class FormMetaData extends Node {
|
|
27
|
+
get version() {
|
|
28
|
+
return this.getP('version', '');
|
|
29
|
+
}
|
|
30
|
+
get grammar() {
|
|
31
|
+
return this.getP('grammar', '');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { FormMetaData as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Action, FieldsetModel } from './types/index.js';
|
|
2
|
+
import { Fieldset } from './Fieldset.js';
|
|
3
|
+
export declare class InstanceManager extends Fieldset implements FieldsetModel {
|
|
4
|
+
get maxOccur(): number;
|
|
5
|
+
set maxOccur(m: number);
|
|
6
|
+
get minOccur(): number;
|
|
7
|
+
addInstance(action: Action): void;
|
|
8
|
+
removeInstance(action: Action): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* ___________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2022 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
|
|
17
|
+
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
+
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
+
*************************************************************************/
|
|
20
|
+
|
|
21
|
+
import { _ as __decorate, d as dependencyTracked } from './BaseNode-dc59ab07.js';
|
|
22
|
+
import { Fieldset } from './Fieldset.js';
|
|
23
|
+
import './controller/Events.js';
|
|
24
|
+
import './utils/DataRefParser.js';
|
|
25
|
+
import './data/DataGroup.js';
|
|
26
|
+
import './data/DataValue.js';
|
|
27
|
+
import './data/EmptyDataValue.js';
|
|
28
|
+
import './Container.js';
|
|
29
|
+
import './utils/JsonUtils.js';
|
|
30
|
+
import './types/Json.js';
|
|
31
|
+
import './utils/SchemaUtils.js';
|
|
32
|
+
import './Scriptable.js';
|
|
33
|
+
|
|
34
|
+
class InstanceManager extends Fieldset {
|
|
35
|
+
get maxOccur() {
|
|
36
|
+
return this._jsonModel.maxItems;
|
|
37
|
+
}
|
|
38
|
+
set maxOccur(m) {
|
|
39
|
+
this.maxItems = m;
|
|
40
|
+
}
|
|
41
|
+
get minOccur() {
|
|
42
|
+
return this.minItems;
|
|
43
|
+
}
|
|
44
|
+
addInstance(action) {
|
|
45
|
+
return this.addItem(action);
|
|
46
|
+
}
|
|
47
|
+
removeInstance(action) {
|
|
48
|
+
return this.removeItem(action);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
__decorate([
|
|
52
|
+
dependencyTracked()
|
|
53
|
+
], InstanceManager.prototype, "maxOccur", null);
|
|
54
|
+
__decorate([
|
|
55
|
+
dependencyTracked()
|
|
56
|
+
], InstanceManager.prototype, "minOccur", null);
|
|
57
|
+
|
|
58
|
+
export { InstanceManager };
|
package/lib/esm/Node.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*************************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* ___________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2022 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
|
|
17
|
+
* Adobe permits you to use and modify this file solely in accordance with
|
|
18
|
+
* the terms of the Adobe license agreement accompanying it.
|
|
19
|
+
*************************************************************************/
|
|
20
|
+
|
|
21
|
+
import { getProperty } from './utils/JsonUtils.js';
|
|
22
|
+
import './types/Json.js';
|
|
23
|
+
import './utils/SchemaUtils.js';
|
|
24
|
+
|
|
25
|
+
class Node {
|
|
26
|
+
_jsonModel;
|
|
27
|
+
constructor(inputModel) {
|
|
28
|
+
this._jsonModel = {
|
|
29
|
+
...inputModel
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
getP(key, def) {
|
|
33
|
+
return getProperty(this._jsonModel, key, def);
|
|
34
|
+
}
|
|
35
|
+
get isContainer() {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { Node as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Action, RulesJson, ScriptableField } from './types/index.js';
|
|
2
|
+
import { BaseNode } from './BaseNode.js';
|
|
3
|
+
declare abstract class Scriptable<T extends RulesJson> extends BaseNode<T> implements ScriptableField {
|
|
4
|
+
private _events;
|
|
5
|
+
private _rules;
|
|
6
|
+
getRules(): import("./types/Json.js").Items<string>;
|
|
7
|
+
private getCompiledRule;
|
|
8
|
+
private getCompiledEvent;
|
|
9
|
+
private applyUpdates;
|
|
10
|
+
protected executeAllRules(context: any): void;
|
|
11
|
+
private getExpressionScope;
|
|
12
|
+
private executeEvent;
|
|
13
|
+
executeRule(event: Action, context: any): void;
|
|
14
|
+
executeExpression(expr: string): any;
|
|
15
|
+
executeAction(action: Action): void;
|
|
16
|
+
}
|
|
17
|
+
export default Scriptable;
|