@aemforms/af-core 0.22.136 → 0.22.138
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/esm/afb-runtime.js +255 -73
- package/esm/types/src/BaseNode.d.ts +12 -3
- package/esm/types/src/Checkbox.d.ts +6 -1
- package/esm/types/src/Container.d.ts +117 -3
- package/esm/types/src/Field.d.ts +6 -1
- package/esm/types/src/Form.d.ts +117 -3
- package/esm/types/src/controller/Logger.d.ts +1 -0
- package/esm/types/src/rules/FunctionRuntime.d.ts +13 -1
- package/esm/types/src/rules/RuleEngine.d.ts +1 -1
- package/esm/types/src/types/Model.d.ts +1 -1
- package/lib/BaseNode.d.ts +12 -3
- package/lib/BaseNode.js +33 -24
- package/lib/Checkbox.d.ts +6 -1
- package/lib/Container.d.ts +117 -3
- package/lib/Container.js +18 -18
- package/lib/Field.d.ts +6 -1
- package/lib/Field.js +1 -1
- package/lib/Form.d.ts +117 -3
- package/lib/PropertiesManager.d.ts +14 -0
- package/lib/PropertiesManager.js +102 -0
- package/lib/controller/EventQueue.js +13 -1
- package/lib/controller/Logger.d.ts +1 -0
- package/lib/controller/Logger.js +3 -0
- package/lib/rules/FunctionRuntime.d.ts +13 -1
- package/lib/rules/FunctionRuntime.js +73 -12
- package/lib/rules/RuleEngine.d.ts +1 -1
- package/lib/rules/RuleEngine.js +2 -2
- package/lib/types/Model.d.ts +1 -1
- package/package.json +2 -2
package/lib/Container.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Action, BaseModel, ContainerJson, ContainerModel, FieldModel, FieldsetModel, FormCreationMode, FormModel, IFormFieldFactory, RulesJson } from './types/index';
|
|
1
|
+
import { Action, BaseModel, ContainerJson, ContainerModel, FieldJson, FieldModel, FieldsetModel, FormCreationMode, FormModel, IFormFieldFactory, RulesJson } from './types/index';
|
|
2
2
|
import Scriptable from './Scriptable';
|
|
3
3
|
import DataGroup from './data/DataGroup';
|
|
4
4
|
declare abstract class Container<T extends ContainerJson & RulesJson> extends Scriptable<T> implements ContainerModel {
|
|
@@ -29,12 +29,126 @@ declare abstract class Container<T extends ContainerJson & RulesJson> extends Sc
|
|
|
29
29
|
private _getFormAndSitesState;
|
|
30
30
|
private getItemsState;
|
|
31
31
|
getState(isRepeatableChild?: boolean, forRestore?: boolean): T & {
|
|
32
|
-
items: any[];
|
|
33
32
|
enabled: boolean | undefined;
|
|
34
33
|
readOnly: any;
|
|
34
|
+
_itemTemplate?: {
|
|
35
|
+
description?: string | undefined;
|
|
36
|
+
rules?: import("./types/Json").Items<string> | undefined;
|
|
37
|
+
events?: import("./types/Json").Items<string | string[] | undefined> | undefined;
|
|
38
|
+
enumNames?: string[] | undefined;
|
|
39
|
+
enum?: any[] | undefined;
|
|
40
|
+
accept?: string[] | undefined;
|
|
41
|
+
enforceEnum?: boolean | undefined;
|
|
42
|
+
exclusiveMinimum?: string | number | undefined;
|
|
43
|
+
exclusiveMaximum?: string | number | undefined;
|
|
44
|
+
format?: string | undefined;
|
|
45
|
+
maxFileSize?: string | number | undefined;
|
|
46
|
+
maxLength?: number | undefined;
|
|
47
|
+
maximum?: string | number | undefined;
|
|
48
|
+
maxItems?: number | undefined;
|
|
49
|
+
minOccur?: number | undefined;
|
|
50
|
+
maxOccur?: number | undefined;
|
|
51
|
+
minLength?: number | undefined;
|
|
52
|
+
minimum?: string | number | undefined;
|
|
53
|
+
minItems?: number | undefined;
|
|
54
|
+
pattern?: string | undefined;
|
|
55
|
+
required?: boolean | undefined;
|
|
56
|
+
step?: number | undefined;
|
|
57
|
+
type?: string | undefined;
|
|
58
|
+
validationExpression?: string | undefined;
|
|
59
|
+
uniqueItems?: boolean | undefined;
|
|
60
|
+
dataRef?: string | null | undefined;
|
|
61
|
+
lang?: string | undefined;
|
|
62
|
+
':type'?: string | undefined;
|
|
63
|
+
appliedCssClassNames?: string | undefined;
|
|
64
|
+
label?: import("./types/Json").Label | undefined;
|
|
65
|
+
enabled?: boolean | undefined;
|
|
66
|
+
visible?: boolean | undefined;
|
|
67
|
+
name?: string | undefined;
|
|
68
|
+
constraintMessages?: import("./types/Json").ConstraintsMessages | undefined;
|
|
69
|
+
fieldType?: string | undefined;
|
|
70
|
+
errorMessage?: string | undefined;
|
|
71
|
+
properties?: {
|
|
72
|
+
[key: string]: any;
|
|
73
|
+
} | undefined;
|
|
74
|
+
repeatable?: boolean | undefined;
|
|
75
|
+
screenReaderText?: string | undefined;
|
|
76
|
+
tooltip?: string | undefined;
|
|
77
|
+
altText?: string | undefined;
|
|
78
|
+
viewType?: string | undefined;
|
|
79
|
+
buttonType?: string | undefined;
|
|
80
|
+
placeholder?: string | undefined;
|
|
81
|
+
readOnly?: boolean | undefined;
|
|
82
|
+
valid?: boolean | undefined;
|
|
83
|
+
validity?: any;
|
|
84
|
+
validationMessage?: string | undefined;
|
|
85
|
+
default?: any;
|
|
86
|
+
value?: any;
|
|
87
|
+
displayFormat?: string | undefined;
|
|
88
|
+
editFormat?: string | undefined;
|
|
89
|
+
editValue?: string | undefined;
|
|
90
|
+
displayValue?: string | undefined;
|
|
91
|
+
displayValueExpression?: string | undefined;
|
|
92
|
+
emptyValue?: "" | "undefined" | "null" | undefined;
|
|
93
|
+
checked?: boolean | undefined;
|
|
94
|
+
} | {
|
|
95
|
+
description?: string | undefined;
|
|
96
|
+
rules?: import("./types/Json").Items<string> | undefined;
|
|
97
|
+
events?: import("./types/Json").Items<string | string[] | undefined> | undefined;
|
|
98
|
+
enumNames?: string[] | undefined;
|
|
99
|
+
enum?: any[] | undefined;
|
|
100
|
+
accept?: string[] | undefined;
|
|
101
|
+
enforceEnum?: boolean | undefined;
|
|
102
|
+
exclusiveMinimum?: string | number | undefined;
|
|
103
|
+
exclusiveMaximum?: string | number | undefined;
|
|
104
|
+
format?: string | undefined;
|
|
105
|
+
maxFileSize?: string | number | undefined;
|
|
106
|
+
maxLength?: number | undefined;
|
|
107
|
+
maximum?: string | number | undefined;
|
|
108
|
+
maxItems?: number | undefined;
|
|
109
|
+
minOccur?: number | undefined;
|
|
110
|
+
maxOccur?: number | undefined;
|
|
111
|
+
minLength?: number | undefined;
|
|
112
|
+
minimum?: string | number | undefined;
|
|
113
|
+
minItems?: number | undefined;
|
|
114
|
+
pattern?: string | undefined;
|
|
115
|
+
required?: boolean | undefined;
|
|
116
|
+
step?: number | undefined;
|
|
117
|
+
type?: "object" | "array" | undefined;
|
|
118
|
+
validationExpression?: string | undefined;
|
|
119
|
+
uniqueItems?: boolean | undefined;
|
|
120
|
+
dataRef?: string | null | undefined;
|
|
121
|
+
lang?: string | undefined;
|
|
122
|
+
':type'?: string | undefined;
|
|
123
|
+
appliedCssClassNames?: string | undefined;
|
|
124
|
+
label?: import("./types/Json").Label | undefined;
|
|
125
|
+
enabled?: boolean | undefined;
|
|
126
|
+
visible?: boolean | undefined;
|
|
127
|
+
name?: string | undefined;
|
|
128
|
+
constraintMessages?: import("./types/Json").ConstraintsMessages | undefined;
|
|
129
|
+
fieldType?: string | undefined;
|
|
130
|
+
errorMessage?: string | undefined;
|
|
131
|
+
properties?: {
|
|
132
|
+
[key: string]: any;
|
|
133
|
+
} | undefined;
|
|
134
|
+
repeatable?: boolean | undefined;
|
|
135
|
+
screenReaderText?: string | undefined;
|
|
136
|
+
tooltip?: string | undefined;
|
|
137
|
+
altText?: string | undefined;
|
|
138
|
+
viewType?: string | undefined;
|
|
139
|
+
buttonType?: string | undefined;
|
|
140
|
+
items: (FieldJson | ContainerJson)[];
|
|
141
|
+
initialItems?: number | undefined;
|
|
142
|
+
activeChild?: string | undefined;
|
|
143
|
+
readOnly?: boolean | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
items: any[];
|
|
35
146
|
':items'?: undefined;
|
|
36
147
|
':itemsOrder'?: undefined;
|
|
37
|
-
_dependents?:
|
|
148
|
+
_dependents?: {
|
|
149
|
+
id: string;
|
|
150
|
+
propertyName: string | undefined;
|
|
151
|
+
}[] | undefined;
|
|
38
152
|
allowedComponents?: undefined;
|
|
39
153
|
columnClassNames?: undefined;
|
|
40
154
|
columnCount?: undefined;
|
package/lib/Container.js
CHANGED
|
@@ -98,25 +98,25 @@ class Container extends Scriptable_1.default {
|
|
|
98
98
|
}) : [];
|
|
99
99
|
}
|
|
100
100
|
getItemsState(isRepeatableChild = false, forRestore = false) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return this._children.map(x => {
|
|
107
|
-
return Object.assign({}, x.getState(true, forRestore));
|
|
108
|
-
});
|
|
109
|
-
}
|
|
101
|
+
const isThisContainerRepeatable = this._jsonModel.type === 'array' || (0, JsonUtils_1.isRepeatable)(this._jsonModel);
|
|
102
|
+
if (isThisContainerRepeatable) {
|
|
103
|
+
return this._children.map(x => {
|
|
104
|
+
return Object.assign({}, x.getState(true, forRestore));
|
|
105
|
+
});
|
|
110
106
|
}
|
|
111
107
|
else {
|
|
112
108
|
return this._getFormAndSitesState(isRepeatableChild, forRestore);
|
|
113
109
|
}
|
|
114
110
|
}
|
|
115
111
|
getState(isRepeatableChild = false, forRestore = false) {
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
return this.withDependencyTrackingControl(true, () => {
|
|
113
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, super.getState(forRestore)), (forRestore ? {
|
|
114
|
+
':items': undefined,
|
|
115
|
+
':itemsOrder': undefined
|
|
116
|
+
} : {})), { items: this.getItemsState(isRepeatableChild, forRestore) }), ((this._jsonModel.type === 'array' || (0, JsonUtils_1.isRepeatable)(this._jsonModel)) && this._itemTemplate ? {
|
|
117
|
+
_itemTemplate: Object.assign({}, this._itemTemplate)
|
|
118
|
+
} : {})), { enabled: this.enabled, readOnly: this.readOnly });
|
|
119
|
+
});
|
|
120
120
|
}
|
|
121
121
|
_createChild(child, options) {
|
|
122
122
|
return this.fieldFactory.createField(child, options);
|
|
@@ -148,10 +148,10 @@ class Container extends Scriptable_1.default {
|
|
|
148
148
|
Object.defineProperty(parent._childrenReference, name, {
|
|
149
149
|
get: () => {
|
|
150
150
|
if (child.isContainer && child.hasDynamicItems()) {
|
|
151
|
-
self.ruleEngine.trackDependency(child);
|
|
151
|
+
self.ruleEngine.trackDependency(child, 'items');
|
|
152
152
|
}
|
|
153
153
|
if (self.hasDynamicItems()) {
|
|
154
|
-
self.ruleEngine.trackDependency(self);
|
|
154
|
+
self.ruleEngine.trackDependency(self, 'items');
|
|
155
155
|
if (this._children[name] !== undefined) {
|
|
156
156
|
return this._children[name].getRuleNode();
|
|
157
157
|
}
|
|
@@ -214,7 +214,8 @@ class Container extends Scriptable_1.default {
|
|
|
214
214
|
const items = this._jsonModel.items || [];
|
|
215
215
|
this._childrenReference = this._jsonModel.type == 'array' ? [] : {};
|
|
216
216
|
if (this._canHaveRepeatingChildren(mode)) {
|
|
217
|
-
this._itemTemplate = (0, JsonUtils_1.deepClone)(items[0]);
|
|
217
|
+
this._itemTemplate = this._jsonModel._itemTemplate || (0, JsonUtils_1.deepClone)(items[0]);
|
|
218
|
+
this._jsonModel._itemTemplate = undefined;
|
|
218
219
|
if (mode === 'restore') {
|
|
219
220
|
this._itemTemplate.repeatable = undefined;
|
|
220
221
|
}
|
|
@@ -401,9 +402,8 @@ class Container extends Scriptable_1.default {
|
|
|
401
402
|
if (items2Remove > 0) {
|
|
402
403
|
for (let i = 0; i < items2Remove; i++) {
|
|
403
404
|
this._childrenReference.pop();
|
|
404
|
-
this._children.pop();
|
|
405
|
+
result.removed.push(this._children.pop());
|
|
405
406
|
}
|
|
406
|
-
result.removed.push(...this._children);
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
this._children.forEach(x => {
|
package/lib/Field.d.ts
CHANGED
|
@@ -197,6 +197,8 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
197
197
|
errorMessage?: string | undefined;
|
|
198
198
|
properties: {
|
|
199
199
|
[key: string]: any;
|
|
200
|
+
} & {
|
|
201
|
+
[key: string]: any;
|
|
200
202
|
};
|
|
201
203
|
repeatable?: boolean | undefined;
|
|
202
204
|
screenReaderText?: string | undefined;
|
|
@@ -213,7 +215,10 @@ declare class Field extends Scriptable<FieldJson> implements FieldModel {
|
|
|
213
215
|
displayValueExpression?: string | undefined;
|
|
214
216
|
emptyValue?: "" | "undefined" | "null" | undefined;
|
|
215
217
|
checked?: boolean | undefined;
|
|
216
|
-
_dependents?:
|
|
218
|
+
_dependents?: {
|
|
219
|
+
id: string;
|
|
220
|
+
propertyName: string | undefined;
|
|
221
|
+
}[] | undefined;
|
|
217
222
|
allowedComponents?: undefined;
|
|
218
223
|
columnClassNames?: undefined;
|
|
219
224
|
columnCount?: undefined;
|
package/lib/Field.js
CHANGED
|
@@ -445,7 +445,7 @@ class Field extends Scriptable_1.default {
|
|
|
445
445
|
valueOf() {
|
|
446
446
|
const obj = this[BaseNode_1.target];
|
|
447
447
|
const actualField = obj === undefined ? this : obj;
|
|
448
|
-
actualField.ruleEngine.trackDependency(actualField);
|
|
448
|
+
actualField.ruleEngine.trackDependency(actualField, 'value');
|
|
449
449
|
return actualField._jsonModel.value || null;
|
|
450
450
|
}
|
|
451
451
|
toString() {
|
package/lib/Form.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import SubmitMetaData from './SubmitMetaData';
|
|
|
4
4
|
import EventQueue from './controller/EventQueue';
|
|
5
5
|
import { LogLevel, Logger } from './controller/Logger';
|
|
6
6
|
import RuleEngine from './rules/RuleEngine';
|
|
7
|
-
import { Action, BaseModel, FieldModel, FieldsetModel, FocusOption, FormCreationMode, FormJson, FormModel, IFormFieldFactory } from './types/index';
|
|
7
|
+
import { Action, BaseModel, FieldModel, FieldsetModel, FocusOption, FormCreationMode, FormJson, FormModel, IFormFieldFactory, Items } from './types/index';
|
|
8
8
|
import { Version } from './utils/Version';
|
|
9
9
|
export declare const currentVersion: Version;
|
|
10
10
|
declare class Form extends Container<FormJson> implements FormModel {
|
|
@@ -97,12 +97,126 @@ declare class Form extends Container<FormJson> implements FormModel {
|
|
|
97
97
|
adaptiveform?: string | undefined;
|
|
98
98
|
lang?: string | undefined;
|
|
99
99
|
} & {
|
|
100
|
-
items: any[];
|
|
101
100
|
enabled: boolean | undefined;
|
|
102
101
|
readOnly: any;
|
|
102
|
+
_itemTemplate?: {
|
|
103
|
+
description?: string | undefined;
|
|
104
|
+
rules?: Items<string> | undefined;
|
|
105
|
+
events?: Items<string | string[] | undefined> | undefined;
|
|
106
|
+
enumNames?: string[] | undefined;
|
|
107
|
+
enum?: any[] | undefined;
|
|
108
|
+
accept?: string[] | undefined;
|
|
109
|
+
enforceEnum?: boolean | undefined;
|
|
110
|
+
exclusiveMinimum?: string | number | undefined;
|
|
111
|
+
exclusiveMaximum?: string | number | undefined;
|
|
112
|
+
format?: string | undefined;
|
|
113
|
+
maxFileSize?: string | number | undefined;
|
|
114
|
+
maxLength?: number | undefined;
|
|
115
|
+
maximum?: string | number | undefined;
|
|
116
|
+
maxItems?: number | undefined;
|
|
117
|
+
minOccur?: number | undefined;
|
|
118
|
+
maxOccur?: number | undefined;
|
|
119
|
+
minLength?: number | undefined;
|
|
120
|
+
minimum?: string | number | undefined;
|
|
121
|
+
minItems?: number | undefined;
|
|
122
|
+
pattern?: string | undefined;
|
|
123
|
+
required?: boolean | undefined;
|
|
124
|
+
step?: number | undefined;
|
|
125
|
+
type?: string | undefined;
|
|
126
|
+
validationExpression?: string | undefined;
|
|
127
|
+
uniqueItems?: boolean | undefined;
|
|
128
|
+
dataRef?: string | null | undefined;
|
|
129
|
+
lang?: string | undefined;
|
|
130
|
+
':type'?: string | undefined;
|
|
131
|
+
appliedCssClassNames?: string | undefined;
|
|
132
|
+
label?: import("./types/Json").Label | undefined;
|
|
133
|
+
enabled?: boolean | undefined;
|
|
134
|
+
visible?: boolean | undefined;
|
|
135
|
+
name?: string | undefined;
|
|
136
|
+
constraintMessages?: import("./types/Json").ConstraintsMessages | undefined;
|
|
137
|
+
fieldType?: string | undefined;
|
|
138
|
+
errorMessage?: string | undefined;
|
|
139
|
+
properties?: {
|
|
140
|
+
[key: string]: any;
|
|
141
|
+
} | undefined;
|
|
142
|
+
repeatable?: boolean | undefined;
|
|
143
|
+
screenReaderText?: string | undefined;
|
|
144
|
+
tooltip?: string | undefined;
|
|
145
|
+
altText?: string | undefined;
|
|
146
|
+
viewType?: string | undefined;
|
|
147
|
+
buttonType?: string | undefined;
|
|
148
|
+
placeholder?: string | undefined;
|
|
149
|
+
readOnly?: boolean | undefined;
|
|
150
|
+
valid?: boolean | undefined;
|
|
151
|
+
validity?: any;
|
|
152
|
+
validationMessage?: string | undefined;
|
|
153
|
+
default?: any;
|
|
154
|
+
value?: any;
|
|
155
|
+
displayFormat?: string | undefined;
|
|
156
|
+
editFormat?: string | undefined;
|
|
157
|
+
editValue?: string | undefined;
|
|
158
|
+
displayValue?: string | undefined;
|
|
159
|
+
displayValueExpression?: string | undefined;
|
|
160
|
+
emptyValue?: "" | "undefined" | "null" | undefined;
|
|
161
|
+
checked?: boolean | undefined;
|
|
162
|
+
} | {
|
|
163
|
+
description?: string | undefined;
|
|
164
|
+
rules?: Items<string> | undefined;
|
|
165
|
+
events?: Items<string | string[] | undefined> | undefined;
|
|
166
|
+
enumNames?: string[] | undefined;
|
|
167
|
+
enum?: any[] | undefined;
|
|
168
|
+
accept?: string[] | undefined;
|
|
169
|
+
enforceEnum?: boolean | undefined;
|
|
170
|
+
exclusiveMinimum?: string | number | undefined;
|
|
171
|
+
exclusiveMaximum?: string | number | undefined;
|
|
172
|
+
format?: string | undefined;
|
|
173
|
+
maxFileSize?: string | number | undefined;
|
|
174
|
+
maxLength?: number | undefined;
|
|
175
|
+
maximum?: string | number | undefined;
|
|
176
|
+
maxItems?: number | undefined;
|
|
177
|
+
minOccur?: number | undefined;
|
|
178
|
+
maxOccur?: number | undefined;
|
|
179
|
+
minLength?: number | undefined;
|
|
180
|
+
minimum?: string | number | undefined;
|
|
181
|
+
minItems?: number | undefined;
|
|
182
|
+
pattern?: string | undefined;
|
|
183
|
+
required?: boolean | undefined;
|
|
184
|
+
step?: number | undefined;
|
|
185
|
+
type?: "object" | "array" | undefined;
|
|
186
|
+
validationExpression?: string | undefined;
|
|
187
|
+
uniqueItems?: boolean | undefined;
|
|
188
|
+
dataRef?: string | null | undefined;
|
|
189
|
+
lang?: string | undefined;
|
|
190
|
+
':type'?: string | undefined;
|
|
191
|
+
appliedCssClassNames?: string | undefined;
|
|
192
|
+
label?: import("./types/Json").Label | undefined;
|
|
193
|
+
enabled?: boolean | undefined;
|
|
194
|
+
visible?: boolean | undefined;
|
|
195
|
+
name?: string | undefined;
|
|
196
|
+
constraintMessages?: import("./types/Json").ConstraintsMessages | undefined;
|
|
197
|
+
fieldType?: string | undefined;
|
|
198
|
+
errorMessage?: string | undefined;
|
|
199
|
+
properties?: {
|
|
200
|
+
[key: string]: any;
|
|
201
|
+
} | undefined;
|
|
202
|
+
repeatable?: boolean | undefined;
|
|
203
|
+
screenReaderText?: string | undefined;
|
|
204
|
+
tooltip?: string | undefined;
|
|
205
|
+
altText?: string | undefined;
|
|
206
|
+
viewType?: string | undefined;
|
|
207
|
+
buttonType?: string | undefined;
|
|
208
|
+
items: (import("./types/Json").FieldJson | import("./types/Json").ContainerJson)[];
|
|
209
|
+
initialItems?: number | undefined;
|
|
210
|
+
activeChild?: string | undefined;
|
|
211
|
+
readOnly?: boolean | undefined;
|
|
212
|
+
} | undefined;
|
|
213
|
+
items: any[];
|
|
103
214
|
':items'?: undefined;
|
|
104
215
|
':itemsOrder'?: undefined;
|
|
105
|
-
_dependents?:
|
|
216
|
+
_dependents?: {
|
|
217
|
+
id: string;
|
|
218
|
+
propertyName: string | undefined;
|
|
219
|
+
}[] | undefined;
|
|
106
220
|
allowedComponents?: undefined;
|
|
107
221
|
columnClassNames?: undefined;
|
|
108
222
|
columnCount?: undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class PropertiesManager {
|
|
2
|
+
constructor(host: any);
|
|
3
|
+
host: any;
|
|
4
|
+
_definedProperties: Set<any>;
|
|
5
|
+
_propertiesWrapper: {};
|
|
6
|
+
_initialized: boolean;
|
|
7
|
+
set properties(arg: {});
|
|
8
|
+
get properties(): {};
|
|
9
|
+
ensurePropertyDescriptor(propertyName: any): void;
|
|
10
|
+
_setupInitialProperties(): void;
|
|
11
|
+
_ensurePropertyDescriptor(prop: any): void;
|
|
12
|
+
updateNestedProperty(propertyPath: any, value: any): void;
|
|
13
|
+
updateSimpleProperty(propertyName: any, value: any): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropertiesManager = void 0;
|
|
4
|
+
const Events_1 = require("./controller/Events");
|
|
5
|
+
class PropertiesManager {
|
|
6
|
+
constructor(host) {
|
|
7
|
+
this.host = host;
|
|
8
|
+
this._definedProperties = new Set();
|
|
9
|
+
this._propertiesWrapper = {};
|
|
10
|
+
this._initialized = false;
|
|
11
|
+
}
|
|
12
|
+
get properties() {
|
|
13
|
+
if (!this._initialized) {
|
|
14
|
+
this._setupInitialProperties();
|
|
15
|
+
this._initialized = true;
|
|
16
|
+
}
|
|
17
|
+
return this._propertiesWrapper;
|
|
18
|
+
}
|
|
19
|
+
set properties(p) {
|
|
20
|
+
const oldProperties = this.host._jsonModel.properties || {};
|
|
21
|
+
const newProperties = Object.assign({}, p);
|
|
22
|
+
this.host._jsonModel.properties = newProperties;
|
|
23
|
+
Object.keys(newProperties).forEach(prop => {
|
|
24
|
+
this._ensurePropertyDescriptor(prop);
|
|
25
|
+
});
|
|
26
|
+
Object.keys(Object.assign(Object.assign({}, oldProperties), newProperties)).forEach(prop => {
|
|
27
|
+
if (oldProperties[prop] !== newProperties[prop]) {
|
|
28
|
+
const changeAction = (0, Events_1.propertyChange)(`properties.${prop}`, newProperties[prop], oldProperties[prop]);
|
|
29
|
+
this.host.notifyDependents(changeAction);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
ensurePropertyDescriptor(propertyName) {
|
|
34
|
+
this._ensurePropertyDescriptor(propertyName);
|
|
35
|
+
}
|
|
36
|
+
_setupInitialProperties() {
|
|
37
|
+
const properties = this.host._jsonModel.properties || {};
|
|
38
|
+
Object.keys(properties).forEach(prop => {
|
|
39
|
+
this._ensurePropertyDescriptor(prop);
|
|
40
|
+
});
|
|
41
|
+
if (!this.host._jsonModel.properties) {
|
|
42
|
+
this.host._jsonModel.properties = {};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
_ensurePropertyDescriptor(prop) {
|
|
46
|
+
if (this._definedProperties.has(prop)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
Object.defineProperty(this._propertiesWrapper, prop, {
|
|
50
|
+
get: () => {
|
|
51
|
+
if (!prop.startsWith('fd:')) {
|
|
52
|
+
this.host.ruleEngine.trackDependency(this.host, `properties.${prop}`);
|
|
53
|
+
}
|
|
54
|
+
const properties = this.host._jsonModel.properties || {};
|
|
55
|
+
return properties[prop];
|
|
56
|
+
},
|
|
57
|
+
set: (value) => {
|
|
58
|
+
const properties = this.host._jsonModel.properties || {};
|
|
59
|
+
const oldValue = properties[prop];
|
|
60
|
+
if (oldValue !== value) {
|
|
61
|
+
const updatedProperties = Object.assign(Object.assign({}, properties), { [prop]: value });
|
|
62
|
+
this.host._jsonModel.properties = updatedProperties;
|
|
63
|
+
const changeAction = (0, Events_1.propertyChange)(`properties.${prop}`, value, oldValue);
|
|
64
|
+
this.host.notifyDependents(changeAction);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true
|
|
69
|
+
});
|
|
70
|
+
this._definedProperties.add(prop);
|
|
71
|
+
}
|
|
72
|
+
updateNestedProperty(propertyPath, value) {
|
|
73
|
+
const parts = propertyPath.split('.');
|
|
74
|
+
const topLevelProp = parts[0];
|
|
75
|
+
this._ensurePropertyDescriptor(topLevelProp);
|
|
76
|
+
const properties = this.host._jsonModel.properties || {};
|
|
77
|
+
const updatedProperties = JSON.parse(JSON.stringify(properties));
|
|
78
|
+
const currentObj = updatedProperties[topLevelProp] || {};
|
|
79
|
+
updatedProperties[topLevelProp] = currentObj;
|
|
80
|
+
let parentObj = currentObj;
|
|
81
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
82
|
+
if (!parentObj[parts[i]]) {
|
|
83
|
+
parentObj[parts[i]] = {};
|
|
84
|
+
}
|
|
85
|
+
else if (typeof parentObj[parts[i]] !== 'object') {
|
|
86
|
+
parentObj[parts[i]] = {};
|
|
87
|
+
}
|
|
88
|
+
parentObj = parentObj[parts[i]];
|
|
89
|
+
}
|
|
90
|
+
const finalProp = parts[parts.length - 1];
|
|
91
|
+
const oldValue = parentObj[finalProp];
|
|
92
|
+
parentObj[finalProp] = value;
|
|
93
|
+
this.host._jsonModel.properties = updatedProperties;
|
|
94
|
+
const changeAction = (0, Events_1.propertyChange)(`properties.${propertyPath}`, value, oldValue);
|
|
95
|
+
this.host.notifyDependents(changeAction);
|
|
96
|
+
}
|
|
97
|
+
updateSimpleProperty(propertyName, value) {
|
|
98
|
+
this._ensurePropertyDescriptor(propertyName);
|
|
99
|
+
this._propertiesWrapper[propertyName] = value;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.PropertiesManager = PropertiesManager;
|
|
@@ -47,10 +47,22 @@ class EventQueue {
|
|
|
47
47
|
events = [events];
|
|
48
48
|
}
|
|
49
49
|
events.forEach(e => {
|
|
50
|
+
var _a;
|
|
50
51
|
const evntNode = new EventNode(node, e);
|
|
51
52
|
const counter = this._runningEventCount[evntNode.valueOf()] || 0;
|
|
52
53
|
if (counter < EventQueue.MAX_EVENT_CYCLE_COUNT) {
|
|
53
|
-
|
|
54
|
+
let payloadAsStr = '';
|
|
55
|
+
if ((e === null || e === void 0 ? void 0 : e.type) === 'change' && !((_a = e === null || e === void 0 ? void 0 : e.payload) === null || _a === void 0 ? void 0 : _a.changes.map(_ => _.propertyName).includes('activeChild'))) {
|
|
56
|
+
payloadAsStr = JSON.stringify(e.payload.changes, null, 2);
|
|
57
|
+
}
|
|
58
|
+
else if (e === null || e === void 0 ? void 0 : e.type.includes('setProperty')) {
|
|
59
|
+
payloadAsStr = JSON.stringify(e.payload, null, 2);
|
|
60
|
+
}
|
|
61
|
+
if (this.logger.isLevelEnabled('info')) {
|
|
62
|
+
node.withDependencyTrackingControl(true, () => {
|
|
63
|
+
this.logger.info(`Queued event : ${e.type} node: ${node.id} - ${node.qualifiedName} - ${payloadAsStr}`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
54
66
|
if (priority) {
|
|
55
67
|
const index = this._isProcessing ? 1 : 0;
|
|
56
68
|
this._pendingEvents.splice(index, 0, evntNode);
|
package/lib/controller/Logger.js
CHANGED
|
@@ -33,7 +33,7 @@ declare class FunctionRuntimeImpl {
|
|
|
33
33
|
_signature: never[];
|
|
34
34
|
};
|
|
35
35
|
importData: {
|
|
36
|
-
_func: (args: Array<unknown>, data: unknown, interpreter: any) =>
|
|
36
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
|
|
37
37
|
_signature: never[];
|
|
38
38
|
};
|
|
39
39
|
submitForm: {
|
|
@@ -44,6 +44,14 @@ declare class FunctionRuntimeImpl {
|
|
|
44
44
|
_func: (args: Array<unknown>, data: unknown, interpreter: any) => {};
|
|
45
45
|
_signature: never[];
|
|
46
46
|
};
|
|
47
|
+
setVariable: {
|
|
48
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => {};
|
|
49
|
+
_signature: never[];
|
|
50
|
+
};
|
|
51
|
+
getVariable: {
|
|
52
|
+
_func: (args: Array<unknown>, data: unknown, interpreter: any) => any;
|
|
53
|
+
_signature: never[];
|
|
54
|
+
};
|
|
47
55
|
request: {
|
|
48
56
|
_func: (args: Array<unknown>, data: unknown, interpreter: any) => Promise<any>;
|
|
49
57
|
_signature: never[];
|
|
@@ -99,6 +107,10 @@ declare class FunctionRuntimeImpl {
|
|
|
99
107
|
_func: (args: Array<unknown>, data: unknown, interpreter: any) => number;
|
|
100
108
|
_signature: never[];
|
|
101
109
|
};
|
|
110
|
+
today: {
|
|
111
|
+
_func: () => number;
|
|
112
|
+
_signature: never[];
|
|
113
|
+
};
|
|
102
114
|
};
|
|
103
115
|
}
|
|
104
116
|
export declare const FunctionRuntime: FunctionRuntimeImpl;
|