@aemforms/af-core 0.22.162 → 0.22.164
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 +54 -28
- package/esm/types/src/BaseNode.d.ts +3 -2
- package/esm/types/src/types/Model.d.ts +3 -1
- package/lib/BaseNode.d.ts +3 -2
- package/lib/BaseNode.js +19 -7
- package/lib/Container.js +18 -17
- package/lib/Field.js +6 -1
- package/lib/Form.js +3 -3
- package/lib/rules/RuleEngine.js +14 -7
- package/lib/types/Model.d.ts +3 -1
- package/package.json +2 -2
package/esm/afb-runtime.js
CHANGED
|
@@ -1457,6 +1457,7 @@ class BaseNode {
|
|
|
1457
1457
|
_ruleNode;
|
|
1458
1458
|
_lang = '';
|
|
1459
1459
|
_callbacks = {};
|
|
1460
|
+
_onlyViewNotify;
|
|
1460
1461
|
_dependents = [];
|
|
1461
1462
|
_jsonModel;
|
|
1462
1463
|
_tokens = [];
|
|
@@ -1647,12 +1648,13 @@ class BaseNode {
|
|
|
1647
1648
|
};
|
|
1648
1649
|
});
|
|
1649
1650
|
}
|
|
1650
|
-
subscribe(callback, eventName = 'change') {
|
|
1651
|
+
subscribe(callback, eventName = 'change', dependentType = 'view') {
|
|
1651
1652
|
this._callbacks[eventName] = this._callbacks[eventName] || [];
|
|
1652
|
-
|
|
1653
|
+
const entry = { callback, dependentType };
|
|
1654
|
+
this._callbacks[eventName].push(entry);
|
|
1653
1655
|
return {
|
|
1654
1656
|
unsubscribe: () => {
|
|
1655
|
-
this._callbacks[eventName] = this._callbacks[eventName].filter(x => x !== callback);
|
|
1657
|
+
this._callbacks[eventName] = this._callbacks[eventName].filter(x => x.callback !== callback);
|
|
1656
1658
|
}
|
|
1657
1659
|
};
|
|
1658
1660
|
}
|
|
@@ -1680,7 +1682,7 @@ class BaseNode {
|
|
|
1680
1682
|
dependent.dispatch(new ExecuteRule());
|
|
1681
1683
|
}
|
|
1682
1684
|
}
|
|
1683
|
-
});
|
|
1685
|
+
}, 'change', 'model');
|
|
1684
1686
|
this._dependents.push({ node: dependent, propertyName, subscription });
|
|
1685
1687
|
}
|
|
1686
1688
|
}
|
|
@@ -1692,10 +1694,17 @@ class BaseNode {
|
|
|
1692
1694
|
}
|
|
1693
1695
|
}
|
|
1694
1696
|
queueEvent(action) {
|
|
1697
|
+
if (this._onlyViewNotify) {
|
|
1698
|
+
return;
|
|
1699
|
+
}
|
|
1695
1700
|
const actionWithTarget = new ActionImplWithTarget(action, this);
|
|
1696
1701
|
this.form.getEventQueue().queue(this, actionWithTarget, ['valid', 'invalid'].indexOf(actionWithTarget.type) > -1);
|
|
1697
1702
|
}
|
|
1698
1703
|
dispatch(action) {
|
|
1704
|
+
if (this._onlyViewNotify) {
|
|
1705
|
+
this.notifyDependents(new ActionImplWithTarget(action, this));
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1699
1708
|
this.queueEvent(action);
|
|
1700
1709
|
this.form.getEventQueue().runPendingQueue();
|
|
1701
1710
|
}
|
|
@@ -1724,10 +1733,14 @@ class BaseNode {
|
|
|
1724
1733
|
});
|
|
1725
1734
|
this._jsonModel._dependents = undefined;
|
|
1726
1735
|
}
|
|
1727
|
-
const
|
|
1728
|
-
|
|
1736
|
+
const onlyView = this._onlyViewNotify;
|
|
1737
|
+
const entries = this._callbacks[action.type] || [];
|
|
1738
|
+
const toRun = onlyView
|
|
1739
|
+
? entries.filter(e => e.dependentType === 'view' || e.dependentType === undefined)
|
|
1740
|
+
: entries;
|
|
1741
|
+
toRun.forEach(({ callback }) => {
|
|
1729
1742
|
this.withDependencyTrackingControl(true, () => {
|
|
1730
|
-
|
|
1743
|
+
callback(new ActionImplWithTarget(action, this));
|
|
1731
1744
|
});
|
|
1732
1745
|
});
|
|
1733
1746
|
}
|
|
@@ -2539,25 +2552,26 @@ class Container extends Scriptable {
|
|
|
2539
2552
|
super.dispatch(action);
|
|
2540
2553
|
}
|
|
2541
2554
|
importData(dataModel) {
|
|
2542
|
-
if (typeof this._data
|
|
2543
|
-
const dataGroup = new DataGroup(this._data.$name, dataModel, this._data.$type, this._data.parent);
|
|
2544
|
-
try {
|
|
2545
|
-
this._data.parent?.$addDataNode(dataGroup.$name, dataGroup, true);
|
|
2546
|
-
}
|
|
2547
|
-
catch (e) {
|
|
2548
|
-
this.form.logger.error(`unable to setItems for ${this.qualifiedName} : ${e}`);
|
|
2549
|
-
return;
|
|
2550
|
-
}
|
|
2551
|
-
this._data = dataGroup;
|
|
2552
|
-
this.syncDataAndFormModel(dataGroup);
|
|
2553
|
-
const newLength = this.items.length;
|
|
2554
|
-
for (let i = 0; i < newLength; i += 1) {
|
|
2555
|
-
this._children[i].dispatch(new ExecuteRule());
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
else if (typeof this._data === 'undefined') {
|
|
2555
|
+
if (typeof this._data === 'undefined') {
|
|
2559
2556
|
console.warn(`Data node is null, hence importData did not work for panel "${this.name}". Check if parent has a dataRef set to null.`);
|
|
2557
|
+
return;
|
|
2558
|
+
}
|
|
2559
|
+
const isArrayPanel = this.type === 'array' && Array.isArray(dataModel);
|
|
2560
|
+
const isObjectPanel = this.type === 'object' && typeof dataModel === 'object' && dataModel !== null && !Array.isArray(dataModel);
|
|
2561
|
+
if (!isArrayPanel && !isObjectPanel) {
|
|
2562
|
+
return;
|
|
2563
|
+
}
|
|
2564
|
+
const dataGroup = new DataGroup(this._data.$name, dataModel, this._data.$type, this._data.parent);
|
|
2565
|
+
try {
|
|
2566
|
+
this._data.parent?.$addDataNode(dataGroup.$name, dataGroup, true);
|
|
2560
2567
|
}
|
|
2568
|
+
catch (e) {
|
|
2569
|
+
this.form.logger.error(`unable to importData for ${this.qualifiedName} : ${e}`);
|
|
2570
|
+
return;
|
|
2571
|
+
}
|
|
2572
|
+
this._data = dataGroup;
|
|
2573
|
+
this.syncDataAndFormModel(dataGroup);
|
|
2574
|
+
this._children.forEach((child) => child.dispatch(new ExecuteRule()));
|
|
2561
2575
|
}
|
|
2562
2576
|
syncDataAndFormModel(contextualDataModel) {
|
|
2563
2577
|
const result = {
|
|
@@ -4201,13 +4215,13 @@ class Form extends Container {
|
|
|
4201
4215
|
if (this._invalidFields.indexOf(action.target.id) === -1) {
|
|
4202
4216
|
this._invalidFields.push(action.target.id);
|
|
4203
4217
|
}
|
|
4204
|
-
}, 'invalid');
|
|
4218
|
+
}, 'invalid', 'model');
|
|
4205
4219
|
field.subscribe((action) => {
|
|
4206
4220
|
const index = this._invalidFields.indexOf(action.target.id);
|
|
4207
4221
|
if (index > -1) {
|
|
4208
4222
|
this._invalidFields.splice(index, 1);
|
|
4209
4223
|
}
|
|
4210
|
-
}, 'valid');
|
|
4224
|
+
}, 'valid', 'model');
|
|
4211
4225
|
field.subscribe((action) => {
|
|
4212
4226
|
const field = action.target.getState();
|
|
4213
4227
|
if (action.payload.changes.length > 0 && field) {
|
|
@@ -4232,7 +4246,7 @@ class Form extends Container {
|
|
|
4232
4246
|
const fieldChangedAction = new FieldChanged(changes, field, action.payload.eventSource);
|
|
4233
4247
|
this.notifyDependents(fieldChangedAction);
|
|
4234
4248
|
}
|
|
4235
|
-
});
|
|
4249
|
+
}, 'change', 'model');
|
|
4236
4250
|
}
|
|
4237
4251
|
visit(callBack) {
|
|
4238
4252
|
this.traverseChild(this, callBack);
|
|
@@ -4379,6 +4393,13 @@ class RuleEngine {
|
|
|
4379
4393
|
this._context = globals;
|
|
4380
4394
|
let res = undefined;
|
|
4381
4395
|
try {
|
|
4396
|
+
this._context?.form?.logger?.info({
|
|
4397
|
+
message: 'Executing rule',
|
|
4398
|
+
expression: eString,
|
|
4399
|
+
fieldName: this._context.field?.name,
|
|
4400
|
+
fieldId: this._context.field?.id,
|
|
4401
|
+
eventType: this._context?.$event?.type
|
|
4402
|
+
});
|
|
4382
4403
|
res = formula.run(ast, data, 'en-US', globals);
|
|
4383
4404
|
}
|
|
4384
4405
|
catch (err) {
|
|
@@ -4875,7 +4896,12 @@ class Field extends Scriptable {
|
|
|
4875
4896
|
if (updates.valid) {
|
|
4876
4897
|
this.triggerValidationEvent(updates);
|
|
4877
4898
|
}
|
|
4878
|
-
const
|
|
4899
|
+
const allChanges = changes.concat(Object.values(updates));
|
|
4900
|
+
const changesWithCurrentState = allChanges.map((change) => {
|
|
4901
|
+
const valueToUse = change.propertyName === 'value' ? this._jsonModel.value : change.currentValue;
|
|
4902
|
+
return { ...change, currentValue: valueToUse };
|
|
4903
|
+
});
|
|
4904
|
+
const changeAction = new Change({ changes: changesWithCurrentState, eventSource: this._eventSource });
|
|
4879
4905
|
this.dispatch(changeAction);
|
|
4880
4906
|
}
|
|
4881
4907
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormCreationMode, FormModel, Primitives, ValidationError, EventSource } from './types/index';
|
|
1
|
+
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, DependentType, FormCreationMode, FormModel, Primitives, ValidationError, EventSource } from './types/index';
|
|
2
2
|
import { PropertiesManager } from './PropertiesManager.js';
|
|
3
3
|
import DataGroup from './data/DataGroup';
|
|
4
4
|
import DataValue from './data/DataValue';
|
|
@@ -15,6 +15,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
15
15
|
private _ruleNode;
|
|
16
16
|
private _lang?;
|
|
17
17
|
private _callbacks;
|
|
18
|
+
_onlyViewNotify?: boolean;
|
|
18
19
|
private _dependents;
|
|
19
20
|
protected _jsonModel: T & {
|
|
20
21
|
id: string;
|
|
@@ -83,7 +84,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
83
84
|
qualifiedName: any;
|
|
84
85
|
id: string;
|
|
85
86
|
};
|
|
86
|
-
subscribe(callback: callbackFn, eventName?: string): {
|
|
87
|
+
subscribe(callback: callbackFn, eventName?: string, dependentType?: DependentType): {
|
|
87
88
|
unsubscribe: () => void;
|
|
88
89
|
};
|
|
89
90
|
_addDependent(dependent: BaseModel, propertyName?: string): void;
|
|
@@ -38,8 +38,9 @@ export interface Action {
|
|
|
38
38
|
readonly currentTarget: FormModel | FieldModel | FieldsetModel;
|
|
39
39
|
}
|
|
40
40
|
export type callbackFn = (action: Action) => void;
|
|
41
|
+
export type DependentType = 'view' | 'model';
|
|
41
42
|
export interface WithController {
|
|
42
|
-
subscribe(callback: callbackFn, eventName?: string): Subscription;
|
|
43
|
+
subscribe(callback: callbackFn, eventName?: string, dependentType?: DependentType): Subscription;
|
|
43
44
|
dispatch(action: Action): void;
|
|
44
45
|
}
|
|
45
46
|
export type FormCreationMode = 'create' | 'restore';
|
|
@@ -80,6 +81,7 @@ export interface BaseModel extends ConstraintsJson, WithController {
|
|
|
80
81
|
ruleNodeReference(): any;
|
|
81
82
|
_initialize(mode?: FormCreationMode): any;
|
|
82
83
|
_addDependent(dependent: BaseModel, propertyName?: string): any;
|
|
84
|
+
_onlyViewNotify?: boolean;
|
|
83
85
|
_eventSource: EventSource;
|
|
84
86
|
readonly fragment: string;
|
|
85
87
|
}
|
package/lib/BaseNode.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, FormCreationMode, FormModel, Primitives, ValidationError, EventSource } from './types/index';
|
|
1
|
+
import { Action, BaseJson, BaseModel, callbackFn, ContainerModel, DependentType, FormCreationMode, FormModel, Primitives, ValidationError, EventSource } from './types/index';
|
|
2
2
|
import { PropertiesManager } from './PropertiesManager.js';
|
|
3
3
|
import DataGroup from './data/DataGroup';
|
|
4
4
|
import DataValue from './data/DataValue';
|
|
@@ -15,6 +15,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
15
15
|
private _ruleNode;
|
|
16
16
|
private _lang?;
|
|
17
17
|
private _callbacks;
|
|
18
|
+
_onlyViewNotify?: boolean;
|
|
18
19
|
private _dependents;
|
|
19
20
|
protected _jsonModel: T & {
|
|
20
21
|
id: string;
|
|
@@ -83,7 +84,7 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
83
84
|
qualifiedName: any;
|
|
84
85
|
id: string;
|
|
85
86
|
};
|
|
86
|
-
subscribe(callback: callbackFn, eventName?: string): {
|
|
87
|
+
subscribe(callback: callbackFn, eventName?: string, dependentType?: DependentType): {
|
|
87
88
|
unsubscribe: () => void;
|
|
88
89
|
};
|
|
89
90
|
_addDependent(dependent: BaseModel, propertyName?: string): void;
|
package/lib/BaseNode.js
CHANGED
|
@@ -298,12 +298,13 @@ class BaseNode {
|
|
|
298
298
|
} : {}));
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
|
-
subscribe(callback, eventName = 'change') {
|
|
301
|
+
subscribe(callback, eventName = 'change', dependentType = 'view') {
|
|
302
302
|
this._callbacks[eventName] = this._callbacks[eventName] || [];
|
|
303
|
-
|
|
303
|
+
const entry = { callback, dependentType };
|
|
304
|
+
this._callbacks[eventName].push(entry);
|
|
304
305
|
return {
|
|
305
306
|
unsubscribe: () => {
|
|
306
|
-
this._callbacks[eventName] = this._callbacks[eventName].filter(x => x !== callback);
|
|
307
|
+
this._callbacks[eventName] = this._callbacks[eventName].filter(x => x.callback !== callback);
|
|
307
308
|
}
|
|
308
309
|
};
|
|
309
310
|
}
|
|
@@ -331,7 +332,7 @@ class BaseNode {
|
|
|
331
332
|
dependent.dispatch(new Events_1.ExecuteRule());
|
|
332
333
|
}
|
|
333
334
|
}
|
|
334
|
-
});
|
|
335
|
+
}, 'change', 'model');
|
|
335
336
|
this._dependents.push({ node: dependent, propertyName, subscription });
|
|
336
337
|
}
|
|
337
338
|
}
|
|
@@ -343,10 +344,17 @@ class BaseNode {
|
|
|
343
344
|
}
|
|
344
345
|
}
|
|
345
346
|
queueEvent(action) {
|
|
347
|
+
if (this._onlyViewNotify) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
346
350
|
const actionWithTarget = new ActionImplWithTarget(action, this);
|
|
347
351
|
this.form.getEventQueue().queue(this, actionWithTarget, ['valid', 'invalid'].indexOf(actionWithTarget.type) > -1);
|
|
348
352
|
}
|
|
349
353
|
dispatch(action) {
|
|
354
|
+
if (this._onlyViewNotify) {
|
|
355
|
+
this.notifyDependents(new ActionImplWithTarget(action, this));
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
350
358
|
this.queueEvent(action);
|
|
351
359
|
this.form.getEventQueue().runPendingQueue();
|
|
352
360
|
}
|
|
@@ -376,10 +384,14 @@ class BaseNode {
|
|
|
376
384
|
});
|
|
377
385
|
this._jsonModel._dependents = undefined;
|
|
378
386
|
}
|
|
379
|
-
const
|
|
380
|
-
|
|
387
|
+
const onlyView = this._onlyViewNotify;
|
|
388
|
+
const entries = this._callbacks[action.type] || [];
|
|
389
|
+
const toRun = onlyView
|
|
390
|
+
? entries.filter(e => e.dependentType === 'view' || e.dependentType === undefined)
|
|
391
|
+
: entries;
|
|
392
|
+
toRun.forEach(({ callback }) => {
|
|
381
393
|
this.withDependencyTrackingControl(true, () => {
|
|
382
|
-
|
|
394
|
+
callback(new ActionImplWithTarget(action, this));
|
|
383
395
|
});
|
|
384
396
|
});
|
|
385
397
|
}
|
package/lib/Container.js
CHANGED
|
@@ -357,25 +357,26 @@ class Container extends Scriptable_1.default {
|
|
|
357
357
|
}
|
|
358
358
|
importData(dataModel) {
|
|
359
359
|
var _a;
|
|
360
|
-
if (typeof this._data
|
|
361
|
-
const dataGroup = new DataGroup_1.default(this._data.$name, dataModel, this._data.$type, this._data.parent);
|
|
362
|
-
try {
|
|
363
|
-
(_a = this._data.parent) === null || _a === void 0 ? void 0 : _a.$addDataNode(dataGroup.$name, dataGroup, true);
|
|
364
|
-
}
|
|
365
|
-
catch (e) {
|
|
366
|
-
this.form.logger.error(`unable to setItems for ${this.qualifiedName} : ${e}`);
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
this._data = dataGroup;
|
|
370
|
-
this.syncDataAndFormModel(dataGroup);
|
|
371
|
-
const newLength = this.items.length;
|
|
372
|
-
for (let i = 0; i < newLength; i += 1) {
|
|
373
|
-
this._children[i].dispatch(new Events_1.ExecuteRule());
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
else if (typeof this._data === 'undefined') {
|
|
360
|
+
if (typeof this._data === 'undefined') {
|
|
377
361
|
console.warn(`Data node is null, hence importData did not work for panel "${this.name}". Check if parent has a dataRef set to null.`);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
const isArrayPanel = this.type === 'array' && Array.isArray(dataModel);
|
|
365
|
+
const isObjectPanel = this.type === 'object' && typeof dataModel === 'object' && dataModel !== null && !Array.isArray(dataModel);
|
|
366
|
+
if (!isArrayPanel && !isObjectPanel) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const dataGroup = new DataGroup_1.default(this._data.$name, dataModel, this._data.$type, this._data.parent);
|
|
370
|
+
try {
|
|
371
|
+
(_a = this._data.parent) === null || _a === void 0 ? void 0 : _a.$addDataNode(dataGroup.$name, dataGroup, true);
|
|
372
|
+
}
|
|
373
|
+
catch (e) {
|
|
374
|
+
this.form.logger.error(`unable to importData for ${this.qualifiedName} : ${e}`);
|
|
375
|
+
return;
|
|
378
376
|
}
|
|
377
|
+
this._data = dataGroup;
|
|
378
|
+
this.syncDataAndFormModel(dataGroup);
|
|
379
|
+
this._children.forEach((child) => child.dispatch(new Events_1.ExecuteRule()));
|
|
379
380
|
}
|
|
380
381
|
syncDataAndFormModel(contextualDataModel) {
|
|
381
382
|
const result = {
|
package/lib/Field.js
CHANGED
|
@@ -404,7 +404,12 @@ class Field extends Scriptable_1.default {
|
|
|
404
404
|
if (updates.valid) {
|
|
405
405
|
this.triggerValidationEvent(updates);
|
|
406
406
|
}
|
|
407
|
-
const
|
|
407
|
+
const allChanges = changes.concat(Object.values(updates));
|
|
408
|
+
const changesWithCurrentState = allChanges.map((change) => {
|
|
409
|
+
const valueToUse = change.propertyName === 'value' ? this._jsonModel.value : change.currentValue;
|
|
410
|
+
return Object.assign(Object.assign({}, change), { currentValue: valueToUse });
|
|
411
|
+
});
|
|
412
|
+
const changeAction = new Events_1.Change({ changes: changesWithCurrentState, eventSource: this._eventSource });
|
|
408
413
|
this.dispatch(changeAction);
|
|
409
414
|
}
|
|
410
415
|
}
|
package/lib/Form.js
CHANGED
|
@@ -270,13 +270,13 @@ class Form extends Container_1.default {
|
|
|
270
270
|
if (this._invalidFields.indexOf(action.target.id) === -1) {
|
|
271
271
|
this._invalidFields.push(action.target.id);
|
|
272
272
|
}
|
|
273
|
-
}, 'invalid');
|
|
273
|
+
}, 'invalid', 'model');
|
|
274
274
|
field.subscribe((action) => {
|
|
275
275
|
const index = this._invalidFields.indexOf(action.target.id);
|
|
276
276
|
if (index > -1) {
|
|
277
277
|
this._invalidFields.splice(index, 1);
|
|
278
278
|
}
|
|
279
|
-
}, 'valid');
|
|
279
|
+
}, 'valid', 'model');
|
|
280
280
|
field.subscribe((action) => {
|
|
281
281
|
const field = action.target.getState();
|
|
282
282
|
if (action.payload.changes.length > 0 && field) {
|
|
@@ -301,7 +301,7 @@ class Form extends Container_1.default {
|
|
|
301
301
|
const fieldChangedAction = new Events_1.FieldChanged(changes, field, action.payload.eventSource);
|
|
302
302
|
this.notifyDependents(fieldChangedAction);
|
|
303
303
|
}
|
|
304
|
-
});
|
|
304
|
+
}, 'change', 'model');
|
|
305
305
|
}
|
|
306
306
|
visit(callBack) {
|
|
307
307
|
this.traverseChild(this, callBack);
|
package/lib/rules/RuleEngine.js
CHANGED
|
@@ -30,18 +30,25 @@ class RuleEngine {
|
|
|
30
30
|
return { formula, ast: formula.compile(rule, this._globalNames) };
|
|
31
31
|
}
|
|
32
32
|
execute(node, data, globals, useValueOf = false, eString) {
|
|
33
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
34
34
|
const { formula, ast } = node;
|
|
35
35
|
const oldContext = this._context;
|
|
36
36
|
this._context = globals;
|
|
37
37
|
let res = undefined;
|
|
38
38
|
try {
|
|
39
|
+
(_c = (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.logger) === null || _c === void 0 ? void 0 : _c.info({
|
|
40
|
+
message: 'Executing rule',
|
|
41
|
+
expression: eString,
|
|
42
|
+
fieldName: (_d = this._context.field) === null || _d === void 0 ? void 0 : _d.name,
|
|
43
|
+
fieldId: (_e = this._context.field) === null || _e === void 0 ? void 0 : _e.id,
|
|
44
|
+
eventType: (_g = (_f = this._context) === null || _f === void 0 ? void 0 : _f.$event) === null || _g === void 0 ? void 0 : _g.type
|
|
45
|
+
});
|
|
39
46
|
res = formula.run(ast, data, 'en-US', globals);
|
|
40
47
|
}
|
|
41
48
|
catch (err) {
|
|
42
|
-
(
|
|
43
|
-
if ((
|
|
44
|
-
const field = (
|
|
49
|
+
(_k = (_j = (_h = this._context) === null || _h === void 0 ? void 0 : _h.form) === null || _j === void 0 ? void 0 : _j.logger) === null || _k === void 0 ? void 0 : _k.error(err);
|
|
50
|
+
if ((_l = this._context) === null || _l === void 0 ? void 0 : _l.form) {
|
|
51
|
+
const field = (_m = this._context) === null || _m === void 0 ? void 0 : _m.field;
|
|
45
52
|
const fieldName = field === null || field === void 0 ? void 0 : field.name;
|
|
46
53
|
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
47
54
|
const fullError = fieldName
|
|
@@ -50,7 +57,7 @@ class RuleEngine {
|
|
|
50
57
|
const errorPayload = {
|
|
51
58
|
name: fieldName,
|
|
52
59
|
error: fullError,
|
|
53
|
-
event: (
|
|
60
|
+
event: (_p = (_o = this._context) === null || _o === void 0 ? void 0 : _o.$event) === null || _p === void 0 ? void 0 : _p.type,
|
|
54
61
|
rule: eString,
|
|
55
62
|
stack: err instanceof Error ? err.stack : undefined
|
|
56
63
|
};
|
|
@@ -58,9 +65,9 @@ class RuleEngine {
|
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
if (this.debugInfo.length) {
|
|
61
|
-
(
|
|
68
|
+
(_s = (_r = (_q = this._context) === null || _q === void 0 ? void 0 : _q.form) === null || _r === void 0 ? void 0 : _r.logger) === null || _s === void 0 ? void 0 : _s.warn(`Form rule expression string: ${eString}`);
|
|
62
69
|
while (this.debugInfo.length > 0) {
|
|
63
|
-
(
|
|
70
|
+
(_v = (_u = (_t = this._context) === null || _t === void 0 ? void 0 : _t.form) === null || _u === void 0 ? void 0 : _u.logger) === null || _v === void 0 ? void 0 : _v.warn(this.debugInfo.pop());
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
let finalRes = res;
|
package/lib/types/Model.d.ts
CHANGED
|
@@ -38,8 +38,9 @@ export interface Action {
|
|
|
38
38
|
readonly currentTarget: FormModel | FieldModel | FieldsetModel;
|
|
39
39
|
}
|
|
40
40
|
export declare type callbackFn = (action: Action) => void;
|
|
41
|
+
export declare type DependentType = 'view' | 'model';
|
|
41
42
|
export interface WithController {
|
|
42
|
-
subscribe(callback: callbackFn, eventName?: string): Subscription;
|
|
43
|
+
subscribe(callback: callbackFn, eventName?: string, dependentType?: DependentType): Subscription;
|
|
43
44
|
dispatch(action: Action): void;
|
|
44
45
|
}
|
|
45
46
|
export declare type FormCreationMode = 'create' | 'restore';
|
|
@@ -80,6 +81,7 @@ export interface BaseModel extends ConstraintsJson, WithController {
|
|
|
80
81
|
ruleNodeReference(): any;
|
|
81
82
|
_initialize(mode?: FormCreationMode): any;
|
|
82
83
|
_addDependent(dependent: BaseModel, propertyName?: string): any;
|
|
84
|
+
_onlyViewNotify?: boolean;
|
|
83
85
|
_eventSource: EventSource;
|
|
84
86
|
readonly fragment: string;
|
|
85
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.164",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@adobe/json-formula": "0.1.50",
|
|
40
|
-
"@aemforms/af-formatters": "^0.22.
|
|
40
|
+
"@aemforms/af-formatters": "^0.22.164"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/preset-env": "^7.20.2",
|