@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
package/lib/esm/FormInstance.js
DELETED
|
@@ -1,129 +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 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 };
|
|
@@ -1,7 +0,0 @@
|
|
|
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;
|
package/lib/esm/FormMetaData.js
DELETED
|
@@ -1,35 +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 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 };
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,58 +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 { _ 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.d.ts
DELETED
package/lib/esm/Node.js
DELETED
|
@@ -1,40 +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 { 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 };
|
package/lib/esm/Scriptable.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
package/lib/esm/Scriptable.js
DELETED
|
@@ -1,190 +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 { B as BaseNode, a as editableProperties } from './BaseNode-dc59ab07.js';
|
|
22
|
-
import './controller/Events.js';
|
|
23
|
-
import './utils/DataRefParser.js';
|
|
24
|
-
import './data/DataGroup.js';
|
|
25
|
-
import './data/DataValue.js';
|
|
26
|
-
import './data/EmptyDataValue.js';
|
|
27
|
-
|
|
28
|
-
class Scriptable extends BaseNode {
|
|
29
|
-
_events = {};
|
|
30
|
-
_rules = {};
|
|
31
|
-
getRules() {
|
|
32
|
-
return typeof this._jsonModel.rules !== 'object' ? {} : this._jsonModel.rules;
|
|
33
|
-
}
|
|
34
|
-
getCompiledRule(eName, rule) {
|
|
35
|
-
if (!(eName in this._rules)) {
|
|
36
|
-
const eString = rule || this.getRules()[eName];
|
|
37
|
-
if (typeof eString === 'string' && eString.length > 0) {
|
|
38
|
-
try {
|
|
39
|
-
this._rules[eName] = this.ruleEngine.compileRule(eString);
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
this.form.logger.error(`Unable to compile rule \`"${eName}" : "${eString}"\` Exception : ${e}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
throw new Error(`only expression strings are supported. ${typeof (eString)} types are not supported`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return this._rules[eName];
|
|
50
|
-
}
|
|
51
|
-
getCompiledEvent(eName) {
|
|
52
|
-
if (!(eName in this._events)) {
|
|
53
|
-
let eString = this._jsonModel.events?.[eName];
|
|
54
|
-
if (typeof eString === 'string' && eString.length > 0) {
|
|
55
|
-
eString = [eString];
|
|
56
|
-
}
|
|
57
|
-
if (typeof eString !== 'undefined' && eString.length > 0) {
|
|
58
|
-
this._events[eName] = eString.map(x => {
|
|
59
|
-
try {
|
|
60
|
-
return this.ruleEngine.compileRule(x);
|
|
61
|
-
}
|
|
62
|
-
catch (e) {
|
|
63
|
-
this.form.logger.error(`Unable to compile expression \`"${eName}" : "${eString}"\` Exception : ${e}`);
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}).filter(x => x !== null);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return this._events[eName] || [];
|
|
70
|
-
}
|
|
71
|
-
applyUpdates(updates) {
|
|
72
|
-
Object.entries(updates).forEach(([key, value]) => {
|
|
73
|
-
if (key in editableProperties || (key in this && typeof this[key] !== 'function')) {
|
|
74
|
-
try {
|
|
75
|
-
this[key] = value;
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
console.error(e);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
executeAllRules(context) {
|
|
84
|
-
const entries = Object.entries(this.getRules());
|
|
85
|
-
if (entries.length > 0) {
|
|
86
|
-
const scope = this.getExpressionScope();
|
|
87
|
-
entries.forEach(([prop, rule]) => {
|
|
88
|
-
const node = this.getCompiledRule(prop, rule);
|
|
89
|
-
if (node) {
|
|
90
|
-
const newVal = this.ruleEngine.execute(node, scope, context, true);
|
|
91
|
-
if (editableProperties.indexOf(prop) > -1) {
|
|
92
|
-
this[prop] = newVal;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
this.form.logger.warn(`${prop} is not a valid editable property.`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
getExpressionScope() {
|
|
102
|
-
const parent = this.getNonTransparentParent();
|
|
103
|
-
const target = {
|
|
104
|
-
self: this.getRuleNode(),
|
|
105
|
-
siblings: parent?.ruleNodeReference() || {}
|
|
106
|
-
};
|
|
107
|
-
const scope = new Proxy(target, {
|
|
108
|
-
get: (target, prop) => {
|
|
109
|
-
if (prop === Symbol.toStringTag) {
|
|
110
|
-
return 'Object';
|
|
111
|
-
}
|
|
112
|
-
prop = prop;
|
|
113
|
-
if (prop.startsWith('$')) {
|
|
114
|
-
const retValue = target.self[prop];
|
|
115
|
-
if (retValue instanceof BaseNode) {
|
|
116
|
-
return retValue.getRuleNode();
|
|
117
|
-
}
|
|
118
|
-
else if (retValue instanceof Array) {
|
|
119
|
-
return retValue.map(r => r instanceof BaseNode ? r.getRuleNode() : r);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
return retValue;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
if (prop in target.siblings) {
|
|
127
|
-
return target.siblings[prop];
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
return target.self[prop];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
has: (target, prop) => {
|
|
135
|
-
prop = prop;
|
|
136
|
-
const selfPropertyOrChild = target.self[prop];
|
|
137
|
-
const sibling = target.siblings[prop];
|
|
138
|
-
return typeof selfPropertyOrChild != 'undefined' || typeof sibling != 'undefined';
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
return scope;
|
|
142
|
-
}
|
|
143
|
-
executeEvent(context, node) {
|
|
144
|
-
let updates;
|
|
145
|
-
if (node) {
|
|
146
|
-
updates = this.ruleEngine.execute(node, this.getExpressionScope(), context);
|
|
147
|
-
}
|
|
148
|
-
if (typeof updates !== 'undefined' && updates != null) {
|
|
149
|
-
this.applyUpdates(updates);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
executeRule(event, context) {
|
|
153
|
-
if (typeof event.payload.ruleName === 'undefined') {
|
|
154
|
-
this.executeAllRules(context);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
executeExpression(expr) {
|
|
158
|
-
const ruleContext = {
|
|
159
|
-
'form': this.form,
|
|
160
|
-
'$form': this.form.getRuleNode(),
|
|
161
|
-
'$field': this.getRuleNode(),
|
|
162
|
-
'field': this
|
|
163
|
-
};
|
|
164
|
-
const node = this.ruleEngine.compileRule(expr);
|
|
165
|
-
return this.ruleEngine.execute(node, this.getExpressionScope(), ruleContext);
|
|
166
|
-
}
|
|
167
|
-
executeAction(action) {
|
|
168
|
-
const context = {
|
|
169
|
-
'form': this.form,
|
|
170
|
-
'$form': this.form.getRuleNode(),
|
|
171
|
-
'$field': this.getRuleNode(),
|
|
172
|
-
'field': this,
|
|
173
|
-
'$event': {
|
|
174
|
-
type: action.type,
|
|
175
|
-
payload: action.payload,
|
|
176
|
-
target: this.getRuleNode()
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
const eventName = action.isCustomEvent ? `custom:${action.type}` : action.type;
|
|
180
|
-
const funcName = action.isCustomEvent ? `custom_${action.type}` : action.type;
|
|
181
|
-
const node = this.getCompiledEvent(eventName);
|
|
182
|
-
if (funcName in this && typeof this[funcName] === 'function') {
|
|
183
|
-
this[funcName](action, context);
|
|
184
|
-
}
|
|
185
|
-
node.forEach((n) => this.executeEvent(context, n));
|
|
186
|
-
this.notifyDependents(action);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export { Scriptable as default };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Action, BaseJson } from '../types/index.js';
|
|
2
|
-
import { BaseNode } from '../BaseNode.js';
|
|
3
|
-
import { Logger } from './Logger.js';
|
|
4
|
-
declare class EventQueue {
|
|
5
|
-
private logger;
|
|
6
|
-
static readonly MAX_EVENT_CYCLE_COUNT = 10;
|
|
7
|
-
private _runningEventCount;
|
|
8
|
-
private _isProcessing;
|
|
9
|
-
private _pendingEvents;
|
|
10
|
-
constructor(logger?: Logger);
|
|
11
|
-
get length(): number;
|
|
12
|
-
get isProcessing(): boolean;
|
|
13
|
-
isQueued<T extends BaseJson>(node: BaseNode<T>, event: Action): boolean;
|
|
14
|
-
queue<T extends BaseJson>(node: BaseNode<T>, events: Action | Action[], priority?: boolean): void;
|
|
15
|
-
runPendingQueue(): void;
|
|
16
|
-
}
|
|
17
|
-
export default EventQueue;
|
|
@@ -1,108 +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 { Logger } from './Logger.js';
|
|
22
|
-
|
|
23
|
-
class EventNode {
|
|
24
|
-
_node;
|
|
25
|
-
_event;
|
|
26
|
-
constructor(_node, _event) {
|
|
27
|
-
this._node = _node;
|
|
28
|
-
this._event = _event;
|
|
29
|
-
}
|
|
30
|
-
get node() {
|
|
31
|
-
return this._node;
|
|
32
|
-
}
|
|
33
|
-
get event() {
|
|
34
|
-
return this._event;
|
|
35
|
-
}
|
|
36
|
-
isEqual(that) {
|
|
37
|
-
return that !== null && that !== undefined && this._node == that._node && this._event.type == that._event.type;
|
|
38
|
-
}
|
|
39
|
-
toString() {
|
|
40
|
-
return this._node.id + '__' + this.event.type;
|
|
41
|
-
}
|
|
42
|
-
valueOf() {
|
|
43
|
-
return this.toString();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
class EventQueue {
|
|
47
|
-
logger;
|
|
48
|
-
static MAX_EVENT_CYCLE_COUNT = 10;
|
|
49
|
-
_runningEventCount;
|
|
50
|
-
_isProcessing = false;
|
|
51
|
-
_pendingEvents = [];
|
|
52
|
-
constructor(logger = new Logger('off')) {
|
|
53
|
-
this.logger = logger;
|
|
54
|
-
this._runningEventCount = {};
|
|
55
|
-
}
|
|
56
|
-
get length() {
|
|
57
|
-
return this._pendingEvents.length;
|
|
58
|
-
}
|
|
59
|
-
get isProcessing() {
|
|
60
|
-
return this._isProcessing;
|
|
61
|
-
}
|
|
62
|
-
isQueued(node, event) {
|
|
63
|
-
const evntNode = new EventNode(node, event);
|
|
64
|
-
return this._pendingEvents.find(x => evntNode.isEqual(x)) !== undefined;
|
|
65
|
-
}
|
|
66
|
-
queue(node, events, priority = false) {
|
|
67
|
-
if (!node || !events) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
if (!(events instanceof Array)) {
|
|
71
|
-
events = [events];
|
|
72
|
-
}
|
|
73
|
-
events.forEach(e => {
|
|
74
|
-
const evntNode = new EventNode(node, e);
|
|
75
|
-
const counter = this._runningEventCount[evntNode.valueOf()] || 0;
|
|
76
|
-
if (counter < EventQueue.MAX_EVENT_CYCLE_COUNT) {
|
|
77
|
-
this.logger.info(`Queued event : ${e.type} node: ${node.id} - ${node.name}`);
|
|
78
|
-
if (priority) {
|
|
79
|
-
const index = this._isProcessing ? 1 : 0;
|
|
80
|
-
this._pendingEvents.splice(index, 0, evntNode);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
this._pendingEvents.push(evntNode);
|
|
84
|
-
}
|
|
85
|
-
this._runningEventCount[evntNode.valueOf()] = counter + 1;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
this.logger.info(`Skipped queueing event : ${e.type} node: ${node.id} - ${node.name} with count=${counter}`);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
runPendingQueue() {
|
|
93
|
-
if (this._isProcessing) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
this._isProcessing = true;
|
|
97
|
-
while (this._pendingEvents.length > 0) {
|
|
98
|
-
const e = this._pendingEvents[0];
|
|
99
|
-
this.logger.info(`Dequeued event : ${e.event.type} node: ${e.node.id} - ${e.node.name}`);
|
|
100
|
-
e.node.executeAction(e.event);
|
|
101
|
-
this._pendingEvents.shift();
|
|
102
|
-
}
|
|
103
|
-
this._runningEventCount = {};
|
|
104
|
-
this._isProcessing = false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export { EventQueue as default };
|