@aemforms/af-core 0.22.23 → 0.22.25
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/package.json +2 -14
- package/lib/cjs/index.cjs +0 -7277
- package/lib/esm/BaseNode-dc59ab07.js +0 -478
- package/lib/esm/BaseNode.d.ts +0 -93
- package/lib/esm/BaseNode.js +0 -26
- package/lib/esm/Checkbox.d.ts +0 -79
- package/lib/esm/Checkbox.js +0 -63
- package/lib/esm/CheckboxGroup.d.ts +0 -18
- package/lib/esm/CheckboxGroup.js +0 -60
- package/lib/esm/Container.d.ts +0 -53
- package/lib/esm/Container.js +0 -311
- package/lib/esm/DateField.d.ts +0 -5
- package/lib/esm/DateField.js +0 -57
- package/lib/esm/Field.d.ts +0 -206
- package/lib/esm/Field.js +0 -692
- package/lib/esm/Fieldset.d.ts +0 -16
- package/lib/esm/Fieldset.js +0 -78
- package/lib/esm/FileObject.d.ts +0 -16
- package/lib/esm/FileObject.js +0 -48
- package/lib/esm/FileUpload.d.ts +0 -22
- package/lib/esm/FileUpload.js +0 -141
- package/lib/esm/Form.d.ts +0 -113
- package/lib/esm/Form.js +0 -208
- package/lib/esm/FormInstance.d.ts +0 -13
- package/lib/esm/FormInstance.js +0 -129
- package/lib/esm/FormMetaData.d.ts +0 -7
- package/lib/esm/FormMetaData.js +0 -35
- package/lib/esm/InstanceManager.d.ts +0 -9
- package/lib/esm/InstanceManager.js +0 -58
- package/lib/esm/Node.d.ts +0 -7
- package/lib/esm/Node.js +0 -40
- package/lib/esm/Scriptable.d.ts +0 -17
- package/lib/esm/Scriptable.js +0 -190
- package/lib/esm/controller/EventQueue.d.ts +0 -17
- package/lib/esm/controller/EventQueue.js +0 -108
- package/lib/esm/controller/Events.d.ts +0 -85
- package/lib/esm/controller/Events.js +0 -171
- package/lib/esm/controller/Logger.d.ts +0 -11
- package/lib/esm/controller/Logger.js +0 -52
- package/lib/esm/data/DataGroup.d.ts +0 -20
- package/lib/esm/data/DataGroup.js +0 -100
- package/lib/esm/data/DataValue.d.ts +0 -16
- package/lib/esm/data/DataValue.js +0 -68
- package/lib/esm/data/EmptyDataValue.d.ts +0 -14
- package/lib/esm/data/EmptyDataValue.js +0 -51
- package/lib/esm/index.d.ts +0 -21
- package/lib/esm/index.js +0 -55
- package/lib/esm/rules/FunctionRuntime.d.ts +0 -51
- package/lib/esm/rules/FunctionRuntime.js +0 -345
- package/lib/esm/rules/RuleEngine.d.ts +0 -12
- package/lib/esm/rules/RuleEngine.js +0 -76
- package/lib/esm/types/Json.d.ts +0 -119
- package/lib/esm/types/Json.js +0 -29
- package/lib/esm/types/Model.d.ts +0 -131
- package/lib/esm/types/Model.js +0 -30
- package/lib/esm/types/index.d.ts +0 -2
- package/lib/esm/types/index.js +0 -22
- package/lib/esm/utils/DataRefParser.d.ts +0 -27
- package/lib/esm/utils/DataRefParser.js +0 -247
- package/lib/esm/utils/Fetch.d.ts +0 -8
- package/lib/esm/utils/Fetch.js +0 -83
- package/lib/esm/utils/FormCreationUtils.d.ts +0 -9
- package/lib/esm/utils/FormCreationUtils.js +0 -112
- package/lib/esm/utils/FormUtils.d.ts +0 -12
- package/lib/esm/utils/FormUtils.js +0 -212
- package/lib/esm/utils/JsonUtils.d.ts +0 -11
- package/lib/esm/utils/JsonUtils.js +0 -99
- package/lib/esm/utils/LogUtils.d.ts +0 -4
- package/lib/esm/utils/LogUtils.js +0 -28
- package/lib/esm/utils/SchemaUtils.d.ts +0 -3
- package/lib/esm/utils/SchemaUtils.js +0 -93
- package/lib/esm/utils/TranslationUtils.d.ts +0 -11
- package/lib/esm/utils/TranslationUtils.js +0 -138
- package/lib/esm/utils/ValidationUtils.d.ts +0 -19
- package/lib/esm/utils/ValidationUtils.js +0 -300
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
type HTTP_VERB = 'GET' | 'POST';
|
|
2
|
-
export declare const request: (context: any, uri: string, httpVerb: HTTP_VERB, payload: any, success: string, error: string, headers: any) => Promise<void>;
|
|
3
|
-
export declare const submit: (context: any, success: string, error: string, submitAs?: 'application/json' | 'multipart/form-data', input_data?: any) => Promise<void>;
|
|
4
|
-
export type CustomFunction = Function;
|
|
5
|
-
export type FunctionDefinition = {
|
|
6
|
-
_func: CustomFunction;
|
|
7
|
-
_signature: Array<any>;
|
|
8
|
-
};
|
|
9
|
-
declare class FunctionRuntimeImpl {
|
|
10
|
-
private customFunctions;
|
|
11
|
-
registerFunctions(functions: {
|
|
12
|
-
[key: string]: FunctionDefinition | CustomFunction;
|
|
13
|
-
}): void;
|
|
14
|
-
unregisterFunctions(...names: string[]): void;
|
|
15
|
-
getFunctions(): {
|
|
16
|
-
validate: {
|
|
17
|
-
_func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
|
|
18
|
-
_signature: never[];
|
|
19
|
-
};
|
|
20
|
-
setFocus: {
|
|
21
|
-
_func: (args: Array<unknown>, data: unknown, interpreter: any) => void;
|
|
22
|
-
_signature: never[];
|
|
23
|
-
};
|
|
24
|
-
getData: {
|
|
25
|
-
_func: (args: unknown, data: unknown, interpreter: any) => any;
|
|
26
|
-
_signature: never[];
|
|
27
|
-
};
|
|
28
|
-
exportData: {
|
|
29
|
-
_func: (args: unknown, data: unknown, interpreter: any) => any;
|
|
30
|
-
_signature: never[];
|
|
31
|
-
};
|
|
32
|
-
importData: {
|
|
33
|
-
_func: (args: Array<unknown>, data: unknown, interpreter: any) => {};
|
|
34
|
-
_signature: never[];
|
|
35
|
-
};
|
|
36
|
-
submitForm: {
|
|
37
|
-
_func: (args: Array<unknown>, data: unknown, interpreter: any) => {};
|
|
38
|
-
_signature: never[];
|
|
39
|
-
};
|
|
40
|
-
request: {
|
|
41
|
-
_func: (args: Array<unknown>, data: unknown, interpreter: any) => {};
|
|
42
|
-
_signature: never[];
|
|
43
|
-
};
|
|
44
|
-
dispatchEvent: {
|
|
45
|
-
_func: (args: Array<unknown>, data: unknown, interpreter: any) => {};
|
|
46
|
-
_signature: never[];
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
export declare const FunctionRuntime: FunctionRuntimeImpl;
|
|
51
|
-
export {};
|
|
@@ -1,345 +0,0 @@
|
|
|
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 { CustomEvent, Submit, RemoveInstance, AddInstance, Reset, RemoveItem, AddItem, Click, Change } from '../controller/Events.js';
|
|
22
|
-
import { request as request$1 } from '../utils/Fetch.js';
|
|
23
|
-
import { FileObject } from '../FileObject.js';
|
|
24
|
-
import { getAttachments } from '../utils/FormUtils.js';
|
|
25
|
-
import { jsonString } from '../utils/JsonUtils.js';
|
|
26
|
-
import '../types/Json.js';
|
|
27
|
-
import '../utils/SchemaUtils.js';
|
|
28
|
-
|
|
29
|
-
const getCustomEventName = (name) => {
|
|
30
|
-
const eName = name;
|
|
31
|
-
if (eName.length > 0 && eName.startsWith('custom:')) {
|
|
32
|
-
return eName.substring('custom:'.length);
|
|
33
|
-
}
|
|
34
|
-
return eName;
|
|
35
|
-
};
|
|
36
|
-
const request = async (context, uri, httpVerb, payload, success, error, headers) => {
|
|
37
|
-
const endpoint = uri;
|
|
38
|
-
const requestOptions = {
|
|
39
|
-
method: httpVerb
|
|
40
|
-
};
|
|
41
|
-
let result;
|
|
42
|
-
let inputPayload;
|
|
43
|
-
try {
|
|
44
|
-
if (payload && payload instanceof FileObject && payload.data instanceof File) {
|
|
45
|
-
const formData = new FormData();
|
|
46
|
-
formData.append(payload.name, payload.data);
|
|
47
|
-
inputPayload = formData;
|
|
48
|
-
}
|
|
49
|
-
else if (payload instanceof FormData) {
|
|
50
|
-
inputPayload = payload;
|
|
51
|
-
}
|
|
52
|
-
else if (payload && typeof payload === 'object' && Object.keys(payload).length > 0) {
|
|
53
|
-
const headerNames = Object.keys(headers);
|
|
54
|
-
if (headerNames.length > 0) {
|
|
55
|
-
requestOptions.headers = {
|
|
56
|
-
...headers,
|
|
57
|
-
...(headerNames.indexOf('Content-Type') === -1 ? { 'Content-Type': 'application/json' } : {})
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
requestOptions.headers = { 'Content-Type': 'application/json' };
|
|
62
|
-
}
|
|
63
|
-
const contentType = requestOptions?.headers?.['Content-Type'] || 'application/json';
|
|
64
|
-
if (contentType === 'application/json') {
|
|
65
|
-
inputPayload = JSON.stringify(payload);
|
|
66
|
-
}
|
|
67
|
-
else if (contentType.indexOf('multipart/form-data') > -1) {
|
|
68
|
-
inputPayload = multipartFormData(payload);
|
|
69
|
-
}
|
|
70
|
-
else if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
71
|
-
inputPayload = urlEncoded(payload);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
result = await request$1(endpoint, inputPayload, requestOptions);
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
context.form.logger.error('Error invoking a rest API');
|
|
78
|
-
const eName = getCustomEventName(error);
|
|
79
|
-
context.form.dispatch(new CustomEvent(eName, {}, true));
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const eName = getCustomEventName(success);
|
|
83
|
-
context.form.dispatch(new CustomEvent(eName, result, true));
|
|
84
|
-
};
|
|
85
|
-
const urlEncoded = (data) => {
|
|
86
|
-
const formData = new URLSearchParams();
|
|
87
|
-
Object.entries(data).forEach(([key, value]) => {
|
|
88
|
-
if (value != null && typeof value === 'object') {
|
|
89
|
-
formData.append(key, jsonString(value));
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
formData.append(key, value);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
return formData;
|
|
96
|
-
};
|
|
97
|
-
const multipartFormData = (data, attachments) => {
|
|
98
|
-
const formData = new FormData();
|
|
99
|
-
Object.entries(data).forEach(([key, value]) => {
|
|
100
|
-
if (value != null && typeof value === 'object') {
|
|
101
|
-
formData.append(key, jsonString(value));
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
formData.append(key, value);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
const addAttachmentToFormData = (objValue, formData) => {
|
|
108
|
-
if (objValue?.data instanceof File) {
|
|
109
|
-
let attIdentifier = `${objValue?.dataRef}/${objValue?.name}`;
|
|
110
|
-
if (!attIdentifier.startsWith('/')) {
|
|
111
|
-
attIdentifier = `/${attIdentifier}`;
|
|
112
|
-
}
|
|
113
|
-
formData.append(attIdentifier, objValue.data);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
if (attachments) {
|
|
117
|
-
Object.keys(attachments).reduce((acc, curr) => {
|
|
118
|
-
const objValue = attachments[curr];
|
|
119
|
-
if (objValue && objValue instanceof Array) {
|
|
120
|
-
return [...acc, ...objValue.map((x) => addAttachmentToFormData(x, formData))];
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
return [...acc, addAttachmentToFormData(objValue, formData)];
|
|
124
|
-
}
|
|
125
|
-
}, []);
|
|
126
|
-
}
|
|
127
|
-
return formData;
|
|
128
|
-
};
|
|
129
|
-
const submit = async (context, success, error, submitAs = 'multipart/form-data', input_data = null) => {
|
|
130
|
-
const endpoint = context.form.action;
|
|
131
|
-
let data = input_data;
|
|
132
|
-
if (typeof data != 'object' || data == null) {
|
|
133
|
-
data = context.form.exportData();
|
|
134
|
-
}
|
|
135
|
-
const attachments = getAttachments(context.form);
|
|
136
|
-
let submitContentType = submitAs;
|
|
137
|
-
const submitDataAndMetaData = { 'data': data, 'submitMetadata': { 'lang': context.form.lang } };
|
|
138
|
-
let formData = submitDataAndMetaData;
|
|
139
|
-
if (Object.keys(attachments).length > 0 || submitAs === 'multipart/form-data') {
|
|
140
|
-
formData = multipartFormData(submitDataAndMetaData, attachments);
|
|
141
|
-
submitContentType = 'multipart/form-data';
|
|
142
|
-
}
|
|
143
|
-
await request(context, endpoint, 'POST', formData, success, error, {
|
|
144
|
-
'Content-Type': submitContentType
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
const createAction = (name, payload = {}) => {
|
|
148
|
-
switch (name) {
|
|
149
|
-
case 'change':
|
|
150
|
-
return new Change(payload);
|
|
151
|
-
case 'submit':
|
|
152
|
-
return new Submit(payload);
|
|
153
|
-
case 'click':
|
|
154
|
-
return new Click(payload);
|
|
155
|
-
case 'addItem':
|
|
156
|
-
return new AddItem(payload);
|
|
157
|
-
case 'removeItem':
|
|
158
|
-
return new RemoveItem(payload);
|
|
159
|
-
case 'reset':
|
|
160
|
-
return new Reset(payload);
|
|
161
|
-
case 'addInstance':
|
|
162
|
-
return new AddInstance(payload);
|
|
163
|
-
case 'removeInstance':
|
|
164
|
-
return new RemoveInstance(payload);
|
|
165
|
-
default:
|
|
166
|
-
console.error('invalid action');
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
class FunctionRuntimeImpl {
|
|
170
|
-
customFunctions = {};
|
|
171
|
-
registerFunctions(functions) {
|
|
172
|
-
Object.entries(functions).forEach(([name, funcDef]) => {
|
|
173
|
-
let finalFunction = funcDef;
|
|
174
|
-
if (typeof funcDef === 'function') {
|
|
175
|
-
finalFunction = {
|
|
176
|
-
_func: (args) => {
|
|
177
|
-
return funcDef(...args);
|
|
178
|
-
},
|
|
179
|
-
_signature: []
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
if (!finalFunction.hasOwnProperty('_func')) {
|
|
183
|
-
console.warn(`Unable to register function with name ${name}.`);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
this.customFunctions[name] = finalFunction;
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
unregisterFunctions(...names) {
|
|
190
|
-
names.forEach(name => {
|
|
191
|
-
if (name in this.customFunctions) {
|
|
192
|
-
delete this.customFunctions[name];
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
getFunctions() {
|
|
197
|
-
function isArray(obj) {
|
|
198
|
-
if (obj !== null) {
|
|
199
|
-
return Object.prototype.toString.call(obj) === '[object Array]';
|
|
200
|
-
}
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
function valueOf(a) {
|
|
204
|
-
if (a === null || a === undefined) {
|
|
205
|
-
return a;
|
|
206
|
-
}
|
|
207
|
-
if (isArray(a)) {
|
|
208
|
-
return a.map(i => valueOf(i));
|
|
209
|
-
}
|
|
210
|
-
return a.valueOf();
|
|
211
|
-
}
|
|
212
|
-
function toString(a) {
|
|
213
|
-
if (a === null || a === undefined) {
|
|
214
|
-
return '';
|
|
215
|
-
}
|
|
216
|
-
return a.toString();
|
|
217
|
-
}
|
|
218
|
-
const defaultFunctions = {
|
|
219
|
-
validate: {
|
|
220
|
-
_func: (args, data, interpreter) => {
|
|
221
|
-
const element = args[0];
|
|
222
|
-
let validation;
|
|
223
|
-
if (typeof element === 'string' || typeof element === 'undefined') {
|
|
224
|
-
validation = interpreter.globals.form.validate();
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
validation = interpreter.globals.form.getElement(element.$id).validate();
|
|
228
|
-
}
|
|
229
|
-
if (Array.isArray(validation) && validation.length) {
|
|
230
|
-
interpreter.globals.form.logger.error('Form Validation Error');
|
|
231
|
-
}
|
|
232
|
-
return validation;
|
|
233
|
-
},
|
|
234
|
-
_signature: []
|
|
235
|
-
},
|
|
236
|
-
setFocus: {
|
|
237
|
-
_func: (args, data, interpreter) => {
|
|
238
|
-
const element = args[0];
|
|
239
|
-
try {
|
|
240
|
-
const field = interpreter.globals.form.getElement(element.$id);
|
|
241
|
-
interpreter.globals.form.setFocus(field);
|
|
242
|
-
}
|
|
243
|
-
catch (e) {
|
|
244
|
-
interpreter.globals.form.logger.error('Invalid argument passed in setFocus. An element is expected');
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
_signature: []
|
|
248
|
-
},
|
|
249
|
-
getData: {
|
|
250
|
-
_func: (args, data, interpreter) => {
|
|
251
|
-
interpreter.globals.form.logger.warn('The `getData` function is depricated. Use `exportData` instead.');
|
|
252
|
-
return interpreter.globals.form.exportData();
|
|
253
|
-
},
|
|
254
|
-
_signature: []
|
|
255
|
-
},
|
|
256
|
-
exportData: {
|
|
257
|
-
_func: (args, data, interpreter) => {
|
|
258
|
-
return interpreter.globals.form.exportData();
|
|
259
|
-
},
|
|
260
|
-
_signature: []
|
|
261
|
-
},
|
|
262
|
-
importData: {
|
|
263
|
-
_func: (args, data, interpreter) => {
|
|
264
|
-
const inputData = args[0];
|
|
265
|
-
if (typeof inputData === 'object' && inputData !== null) {
|
|
266
|
-
interpreter.globals.form.importData(inputData);
|
|
267
|
-
}
|
|
268
|
-
return {};
|
|
269
|
-
},
|
|
270
|
-
_signature: []
|
|
271
|
-
},
|
|
272
|
-
submitForm: {
|
|
273
|
-
_func: (args, data, interpreter) => {
|
|
274
|
-
const success = toString(args[0]);
|
|
275
|
-
const error = toString(args[1]);
|
|
276
|
-
const submit_as = args.length > 2 ? toString(args[2]) : 'multipart/form-data';
|
|
277
|
-
const submit_data = args.length > 3 ? valueOf(args[3]) : null;
|
|
278
|
-
interpreter.globals.form.dispatch(new Submit({
|
|
279
|
-
success,
|
|
280
|
-
error,
|
|
281
|
-
submit_as,
|
|
282
|
-
data: submit_data
|
|
283
|
-
}));
|
|
284
|
-
return {};
|
|
285
|
-
},
|
|
286
|
-
_signature: []
|
|
287
|
-
},
|
|
288
|
-
request: {
|
|
289
|
-
_func: (args, data, interpreter) => {
|
|
290
|
-
const uri = toString(args[0]);
|
|
291
|
-
const httpVerb = toString(args[1]);
|
|
292
|
-
const payload = valueOf(args[2]);
|
|
293
|
-
let success, error, headers = {};
|
|
294
|
-
if (typeof (args[3]) === 'string') {
|
|
295
|
-
interpreter.globals.form.logger.warn('This usage of request is deprecated. Please see the documentation and update');
|
|
296
|
-
success = valueOf(args[3]);
|
|
297
|
-
error = valueOf(args[4]);
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
headers = valueOf(args[3]);
|
|
301
|
-
success = valueOf(args[4]);
|
|
302
|
-
error = valueOf(args[5]);
|
|
303
|
-
}
|
|
304
|
-
request(interpreter.globals, uri, httpVerb, payload, success, error, headers);
|
|
305
|
-
return {};
|
|
306
|
-
},
|
|
307
|
-
_signature: []
|
|
308
|
-
},
|
|
309
|
-
dispatchEvent: {
|
|
310
|
-
_func: (args, data, interpreter) => {
|
|
311
|
-
const element = args[0];
|
|
312
|
-
let eventName = valueOf(args[1]);
|
|
313
|
-
let payload = args.length > 2 ? valueOf(args[2]) : undefined;
|
|
314
|
-
let dispatch = false;
|
|
315
|
-
if (typeof element === 'string') {
|
|
316
|
-
payload = eventName;
|
|
317
|
-
eventName = element;
|
|
318
|
-
dispatch = true;
|
|
319
|
-
}
|
|
320
|
-
let event;
|
|
321
|
-
if (eventName.startsWith('custom:')) {
|
|
322
|
-
event = new CustomEvent(eventName.substring('custom:'.length), payload, dispatch);
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
event = createAction(eventName, payload);
|
|
326
|
-
}
|
|
327
|
-
if (event != null) {
|
|
328
|
-
if (typeof element === 'string') {
|
|
329
|
-
interpreter.globals.form.dispatch(event);
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
interpreter.globals.form.getElement(element.$id).dispatch(event);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return {};
|
|
336
|
-
},
|
|
337
|
-
_signature: []
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
return { ...defaultFunctions, ...this.customFunctions };
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
const FunctionRuntime = new FunctionRuntimeImpl();
|
|
344
|
-
|
|
345
|
-
export { FunctionRuntime, request, submit };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseModel } from '../types/index.js';
|
|
2
|
-
declare class RuleEngine {
|
|
3
|
-
private _context;
|
|
4
|
-
private _globalNames;
|
|
5
|
-
private formulaEngine;
|
|
6
|
-
private debugInfo;
|
|
7
|
-
constructor();
|
|
8
|
-
compileRule(rule: string): any;
|
|
9
|
-
execute(node: any, data: any, globals: any, useValueOf?: boolean): any;
|
|
10
|
-
trackDependency(subscriber: BaseModel): void;
|
|
11
|
-
}
|
|
12
|
-
export default RuleEngine;
|
|
@@ -1,76 +0,0 @@
|
|
|
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 Formula from '@adobe/json-formula';
|
|
22
|
-
import { FunctionRuntime } from './FunctionRuntime.js';
|
|
23
|
-
import '../controller/Events.js';
|
|
24
|
-
import '../utils/Fetch.js';
|
|
25
|
-
import '../FileObject.js';
|
|
26
|
-
import '../utils/FormUtils.js';
|
|
27
|
-
import '../utils/JsonUtils.js';
|
|
28
|
-
import '../types/Json.js';
|
|
29
|
-
import '../utils/SchemaUtils.js';
|
|
30
|
-
|
|
31
|
-
class RuleEngine {
|
|
32
|
-
_context;
|
|
33
|
-
_globalNames = [
|
|
34
|
-
'$form',
|
|
35
|
-
'$field',
|
|
36
|
-
'$event'
|
|
37
|
-
];
|
|
38
|
-
formulaEngine;
|
|
39
|
-
debugInfo = [];
|
|
40
|
-
constructor() {
|
|
41
|
-
const customFunctions = FunctionRuntime.getFunctions();
|
|
42
|
-
this.formulaEngine = new Formula(customFunctions, undefined, this.debugInfo);
|
|
43
|
-
}
|
|
44
|
-
compileRule(rule) {
|
|
45
|
-
return this.formulaEngine.compile(rule, this._globalNames);
|
|
46
|
-
}
|
|
47
|
-
execute(node, data, globals, useValueOf = false) {
|
|
48
|
-
const oldContext = this._context;
|
|
49
|
-
this._context = globals;
|
|
50
|
-
let res = undefined;
|
|
51
|
-
try {
|
|
52
|
-
res = this.formulaEngine.run(node, data, 'en-US', globals);
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
this._context?.form?.logger?.error(err);
|
|
56
|
-
}
|
|
57
|
-
while (this.debugInfo.length > 0) {
|
|
58
|
-
this._context?.form?.logger?.debug(this.debugInfo.pop());
|
|
59
|
-
}
|
|
60
|
-
let finalRes = res;
|
|
61
|
-
if (useValueOf) {
|
|
62
|
-
if (typeof res === 'object' && res !== null) {
|
|
63
|
-
finalRes = Object.getPrototypeOf(res).valueOf.call(res);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
this._context = oldContext;
|
|
67
|
-
return finalRes;
|
|
68
|
-
}
|
|
69
|
-
trackDependency(subscriber) {
|
|
70
|
-
if (this._context && this._context.field !== undefined && this._context.field !== subscriber) {
|
|
71
|
-
subscriber._addDependent(this._context.field);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export { RuleEngine as default };
|
package/lib/esm/types/Json.d.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
export type Items<T> = {
|
|
2
|
-
[key: string]: T;
|
|
3
|
-
};
|
|
4
|
-
export type Primitives = string | number | boolean | null | undefined;
|
|
5
|
-
export type Label = {
|
|
6
|
-
value: string;
|
|
7
|
-
richText?: boolean;
|
|
8
|
-
visible?: boolean;
|
|
9
|
-
};
|
|
10
|
-
type TranslationConstraintsJson = {
|
|
11
|
-
enumNames?: string[];
|
|
12
|
-
enum?: any[];
|
|
13
|
-
};
|
|
14
|
-
export type ConstraintsJson = TranslationConstraintsJson & {
|
|
15
|
-
accept?: string[];
|
|
16
|
-
enforceEnum?: boolean;
|
|
17
|
-
exclusiveMinimum?: number;
|
|
18
|
-
exclusiveMaximum?: number;
|
|
19
|
-
format?: string;
|
|
20
|
-
maxFileSize?: number | string;
|
|
21
|
-
maxLength?: number;
|
|
22
|
-
maximum?: number;
|
|
23
|
-
maxItems?: number;
|
|
24
|
-
minOccur?: number;
|
|
25
|
-
maxOccur?: number;
|
|
26
|
-
minLength?: number;
|
|
27
|
-
minimum?: number;
|
|
28
|
-
minItems?: number;
|
|
29
|
-
pattern?: string;
|
|
30
|
-
required?: boolean;
|
|
31
|
-
step?: number;
|
|
32
|
-
type?: string;
|
|
33
|
-
validationExpression?: string;
|
|
34
|
-
uniqueItems?: boolean;
|
|
35
|
-
};
|
|
36
|
-
export type ConstraintsMessages = {
|
|
37
|
-
accept?: string;
|
|
38
|
-
enum?: string;
|
|
39
|
-
exclusiveMinimum?: string;
|
|
40
|
-
exclusiveMaximum?: string;
|
|
41
|
-
format?: string;
|
|
42
|
-
maxFileSize?: string;
|
|
43
|
-
maxLength?: string;
|
|
44
|
-
maximum?: string;
|
|
45
|
-
maxItems?: string;
|
|
46
|
-
minLength?: string;
|
|
47
|
-
minimum?: string;
|
|
48
|
-
minItems?: string;
|
|
49
|
-
uniqueItems?: string;
|
|
50
|
-
pattern?: string;
|
|
51
|
-
required?: string;
|
|
52
|
-
step?: string;
|
|
53
|
-
type?: string;
|
|
54
|
-
validationExpression?: string;
|
|
55
|
-
};
|
|
56
|
-
export type RulesJson = {
|
|
57
|
-
rules?: Items<string>;
|
|
58
|
-
events?: Items<string[] | string | undefined>;
|
|
59
|
-
};
|
|
60
|
-
type TranslationBaseJson = {
|
|
61
|
-
description?: string;
|
|
62
|
-
};
|
|
63
|
-
export type BaseJson = TranslationBaseJson & RulesJson & ConstraintsJson & {
|
|
64
|
-
dataRef?: string | null;
|
|
65
|
-
':type'?: string;
|
|
66
|
-
label?: Label;
|
|
67
|
-
enabled?: boolean;
|
|
68
|
-
visible?: boolean;
|
|
69
|
-
name?: string;
|
|
70
|
-
constraintMessages?: ConstraintsMessages;
|
|
71
|
-
fieldType?: string;
|
|
72
|
-
errorMessage?: string;
|
|
73
|
-
properties?: {
|
|
74
|
-
[key: string]: any;
|
|
75
|
-
};
|
|
76
|
-
repeatable?: boolean;
|
|
77
|
-
screenReaderText?: string;
|
|
78
|
-
tooltip?: string;
|
|
79
|
-
altText?: string;
|
|
80
|
-
viewType?: string;
|
|
81
|
-
};
|
|
82
|
-
type TranslationFieldJson = {
|
|
83
|
-
placeholder?: string;
|
|
84
|
-
};
|
|
85
|
-
export type FieldJson = BaseJson & TranslationFieldJson & {
|
|
86
|
-
readOnly?: boolean;
|
|
87
|
-
valid?: boolean;
|
|
88
|
-
default?: any;
|
|
89
|
-
value?: any;
|
|
90
|
-
displayFormat?: string;
|
|
91
|
-
editFormat?: string;
|
|
92
|
-
editValue?: string;
|
|
93
|
-
displayValue?: string;
|
|
94
|
-
emptyValue?: 'null' | 'undefined' | '';
|
|
95
|
-
};
|
|
96
|
-
export type ContainerJson = BaseJson & {
|
|
97
|
-
items: Array<FieldJson | ContainerJson>;
|
|
98
|
-
initialItems?: number;
|
|
99
|
-
activeChild?: string;
|
|
100
|
-
};
|
|
101
|
-
export type MetaDataJson = {
|
|
102
|
-
version?: string;
|
|
103
|
-
grammar?: string;
|
|
104
|
-
};
|
|
105
|
-
export type FieldsetJson = ContainerJson & {
|
|
106
|
-
'type'?: 'array' | 'object';
|
|
107
|
-
};
|
|
108
|
-
export type FormJson = ContainerJson & {
|
|
109
|
-
metadata?: MetaDataJson;
|
|
110
|
-
data?: any;
|
|
111
|
-
title?: string;
|
|
112
|
-
action?: string;
|
|
113
|
-
adaptiveForm?: string;
|
|
114
|
-
lang?: string;
|
|
115
|
-
};
|
|
116
|
-
export type TranslationJson = TranslationBaseJson & TranslationFieldJson & TranslationConstraintsJson;
|
|
117
|
-
export declare const translationProps: string[];
|
|
118
|
-
export declare const constraintProps: string[];
|
|
119
|
-
export {};
|
package/lib/esm/types/Json.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
const translationProps = ['description', 'placeholder', 'enum', 'enumNames', 'label.value', 'constraintMessages.accept',
|
|
22
|
-
'constraintMessages.enum', 'constraintMessages.exclusiveMinimum', 'constraintMessages.exclusiveMaximum', 'constraintMessages.format', 'constraintMessages.maxFileSize', 'constraintMessages.maxLength',
|
|
23
|
-
'constraintMessages.maximum', 'constraintMessages.maxItems', 'constraintMessages.minLength', 'constraintMessages.minimum', 'constraintMessages.minItems', 'constraintMessages.pattern', 'constraintMessages.required',
|
|
24
|
-
'constraintMessages.step', 'constraintMessages.type', 'constraintMessages.validationExpression'];
|
|
25
|
-
const constraintProps = ['accept', 'enum', 'exclusiveMinimum', 'exclusiveMaximum',
|
|
26
|
-
'format', 'maxFileSize', 'maxLength', 'maximum', 'maxItems',
|
|
27
|
-
'minLength', 'minimum', 'minItems', 'pattern', 'required', 'step', 'validationExpression', 'enumNames'];
|
|
28
|
-
|
|
29
|
-
export { constraintProps, translationProps };
|