@legalplace/conditions-runner 2.3.4-staging.0 → 2.4.0
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/CHANGELOG.md +11 -0
- package/dist/ConditionsRunner.d.ts +1 -1
- package/dist/ConditionsRunner.js +6 -6
- package/dist/DataPopulator.d.ts +1 -2
- package/dist/DataPopulator.js +3 -5
- package/package.json +7 -6
- package/src/ConditionsRunner.ts +7 -16
- package/src/DataPopulator.ts +3 -14
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.4.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/conditions-runner@2.3.3...@legalplace/conditions-runner@2.4.0) (2026-09-09)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* implement multiple CTA conditions handling ([fe14f33](https://git.legalplace.eu/legalplace/monorepo/commits/fe14f33f5b11ee4307cc8cca535386d59d8298a6))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [2.3.3](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/conditions-runner@2.3.2...@legalplace/conditions-runner@2.3.3) (2026-09-02)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -14,7 +14,7 @@ declare class ConditionsRunner {
|
|
|
14
14
|
executeCondition(condition: {
|
|
15
15
|
dataMap: ConditionDataMap;
|
|
16
16
|
conditions: ConditionV3;
|
|
17
|
-
}, id: number, index: number, conditionType: "options" | "optionValidator" | "variables" | "prefillers" | "variableValidator" | "sections" | "documents" | "multiples"
|
|
17
|
+
}, id: number, index: number, conditionType: "options" | "optionValidator" | "variables" | "prefillers" | "variableValidator" | "sections" | "documents" | "multiples"): any;
|
|
18
18
|
private buildComparatorResolverContext;
|
|
19
19
|
}
|
|
20
20
|
export default ConditionsRunner;
|
package/dist/ConditionsRunner.js
CHANGED
|
@@ -11,7 +11,7 @@ const ComparatorResolver_1 = require("./ComparatorResolver");
|
|
|
11
11
|
class ConditionsRunner {
|
|
12
12
|
constructor(references, ovc) {
|
|
13
13
|
this.executeConditionMemo = {};
|
|
14
|
-
this.buildMemoizeKey = (condition, id, index, conditionType
|
|
14
|
+
this.buildMemoizeKey = (condition, id, index, conditionType) => `${JSON.stringify(condition)}-${id}-${index}-${conditionType}`;
|
|
15
15
|
this.references = references;
|
|
16
16
|
this.ovc = ovc;
|
|
17
17
|
}
|
|
@@ -62,23 +62,23 @@ class ConditionsRunner {
|
|
|
62
62
|
}
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
65
|
-
executeCondition(condition, id, index, conditionType
|
|
66
|
-
const memoizedKey = this.buildMemoizeKey(condition, id, index, conditionType
|
|
65
|
+
executeCondition(condition, id, index, conditionType) {
|
|
66
|
+
const memoizedKey = this.buildMemoizeKey(condition, id, index, conditionType);
|
|
67
67
|
if (this.executeConditionMemo[memoizedKey] !== undefined) {
|
|
68
68
|
return this.executeConditionMemo[memoizedKey];
|
|
69
69
|
}
|
|
70
70
|
let currentData;
|
|
71
71
|
if (conditionType === "options" || conditionType === "optionValidator") {
|
|
72
|
-
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index
|
|
72
|
+
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index).getData();
|
|
73
73
|
}
|
|
74
74
|
else if (conditionType === "variables" ||
|
|
75
75
|
conditionType === "prefillers" ||
|
|
76
76
|
conditionType === "variableValidator") {
|
|
77
77
|
const dataId = this.references.relations.variables[id].parents[0];
|
|
78
|
-
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, dataId, index
|
|
78
|
+
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, dataId, index).getData();
|
|
79
79
|
}
|
|
80
80
|
else if (conditionType === "sections" || conditionType === "documents") {
|
|
81
|
-
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index
|
|
81
|
+
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index).getData();
|
|
82
82
|
}
|
|
83
83
|
else if (conditionType === "multiples") {
|
|
84
84
|
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap).getData();
|
package/dist/DataPopulator.d.ts
CHANGED
|
@@ -9,9 +9,8 @@ declare class DataPopulator {
|
|
|
9
9
|
private id?;
|
|
10
10
|
private index?;
|
|
11
11
|
private dataMap;
|
|
12
|
-
private documentSlug;
|
|
13
12
|
private data;
|
|
14
|
-
constructor(conditionsRunner: ConditionsRunner, references: Types.ReferencesType, ovc: InputsType, dataMap: ConditionDataMap, id?: number, index?: number
|
|
13
|
+
constructor(conditionsRunner: ConditionsRunner, references: Types.ReferencesType, ovc: InputsType, dataMap: ConditionDataMap, id?: number, index?: number);
|
|
15
14
|
getData(): Readonly<ConditionData>;
|
|
16
15
|
private populateConditions;
|
|
17
16
|
private getOptionConditions;
|
package/dist/DataPopulator.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class DataPopulator {
|
|
4
|
-
constructor(conditionsRunner, references, ovc, dataMap, id, index
|
|
4
|
+
constructor(conditionsRunner, references, ovc, dataMap, id, index) {
|
|
5
5
|
this.data = {
|
|
6
6
|
o: {},
|
|
7
7
|
v: {},
|
|
@@ -11,7 +11,6 @@ class DataPopulator {
|
|
|
11
11
|
v: {},
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
|
-
this.documentSlug = documentSlug;
|
|
15
14
|
this.id = id;
|
|
16
15
|
this.ovc = ovc;
|
|
17
16
|
this.index = index;
|
|
@@ -157,11 +156,10 @@ class DataPopulator {
|
|
|
157
156
|
return result;
|
|
158
157
|
}
|
|
159
158
|
sectionConditionValue(sectionId) {
|
|
160
|
-
|
|
161
|
-
const conditions = (_a = this.references.conditions.sections[this.documentSlug]) === null || _a === void 0 ? void 0 : _a[sectionId];
|
|
159
|
+
const conditions = this.references.conditions.sections.main[sectionId];
|
|
162
160
|
if (conditions === undefined)
|
|
163
161
|
return undefined;
|
|
164
|
-
return this.conditionsRunner.executeCondition(conditions, 0, 0, "sections"
|
|
162
|
+
return this.conditionsRunner.executeCondition(conditions, 0, 0, "sections");
|
|
165
163
|
}
|
|
166
164
|
}
|
|
167
165
|
exports.default = DataPopulator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/conditions-runner",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Package containing method to execute conditions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/ConditionsRunner.js",
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
"prettier": "@legalplace/prettier-config",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@legalplace/lplogic": "2.4.1",
|
|
25
|
-
"@legalplace/models-v3-types": "5.
|
|
26
|
-
"@legalplace/referencesparser": "3.
|
|
25
|
+
"@legalplace/models-v3-types": "^5.19.0",
|
|
26
|
+
"@legalplace/referencesparser": "^3.4.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@legalplace/prettier-config": "2.1.
|
|
30
|
-
"@legalplace/types": "2.22.
|
|
29
|
+
"@legalplace/prettier-config": "^2.1.3",
|
|
30
|
+
"@legalplace/types": "^2.22.13",
|
|
31
31
|
"ts-node": "^10.8.1"
|
|
32
|
-
}
|
|
32
|
+
},
|
|
33
|
+
"gitHead": "291ab9a10b1cad0ef43afc9cb1e1b0dcc7dfbcdb"
|
|
33
34
|
}
|
package/src/ConditionsRunner.ts
CHANGED
|
@@ -114,12 +114,8 @@ class ConditionsRunner {
|
|
|
114
114
|
| "variableValidator"
|
|
115
115
|
| "sections"
|
|
116
116
|
| "documents"
|
|
117
|
-
| "multiples"
|
|
118
|
-
|
|
119
|
-
) =>
|
|
120
|
-
`${JSON.stringify(
|
|
121
|
-
condition
|
|
122
|
-
)}-${id}-${index}-${conditionType}-${documentSlug}`;
|
|
117
|
+
| "multiples"
|
|
118
|
+
) => `${JSON.stringify(condition)}-${id}-${index}-${conditionType}`;
|
|
123
119
|
|
|
124
120
|
executeCondition(
|
|
125
121
|
condition: {
|
|
@@ -136,15 +132,13 @@ class ConditionsRunner {
|
|
|
136
132
|
| "variableValidator"
|
|
137
133
|
| "sections"
|
|
138
134
|
| "documents"
|
|
139
|
-
| "multiples"
|
|
140
|
-
documentSlug = "main"
|
|
135
|
+
| "multiples"
|
|
141
136
|
): any {
|
|
142
137
|
const memoizedKey = this.buildMemoizeKey(
|
|
143
138
|
condition,
|
|
144
139
|
id,
|
|
145
140
|
index,
|
|
146
|
-
conditionType
|
|
147
|
-
documentSlug
|
|
141
|
+
conditionType
|
|
148
142
|
);
|
|
149
143
|
if (this.executeConditionMemo[memoizedKey] !== undefined) {
|
|
150
144
|
return this.executeConditionMemo[memoizedKey];
|
|
@@ -159,8 +153,7 @@ class ConditionsRunner {
|
|
|
159
153
|
this.ovc,
|
|
160
154
|
condition.dataMap,
|
|
161
155
|
id,
|
|
162
|
-
index
|
|
163
|
-
documentSlug
|
|
156
|
+
index
|
|
164
157
|
).getData();
|
|
165
158
|
} else if (
|
|
166
159
|
conditionType === "variables" ||
|
|
@@ -174,8 +167,7 @@ class ConditionsRunner {
|
|
|
174
167
|
this.ovc,
|
|
175
168
|
condition.dataMap,
|
|
176
169
|
dataId,
|
|
177
|
-
index
|
|
178
|
-
documentSlug
|
|
170
|
+
index
|
|
179
171
|
).getData();
|
|
180
172
|
} else if (conditionType === "sections" || conditionType === "documents") {
|
|
181
173
|
currentData = new DataPopulator(
|
|
@@ -184,8 +176,7 @@ class ConditionsRunner {
|
|
|
184
176
|
this.ovc,
|
|
185
177
|
condition.dataMap,
|
|
186
178
|
id,
|
|
187
|
-
index
|
|
188
|
-
documentSlug
|
|
179
|
+
index
|
|
189
180
|
).getData();
|
|
190
181
|
} else if (conditionType === "multiples") {
|
|
191
182
|
// Multiple CTA conditions are evaluated once for the whole group
|
package/src/DataPopulator.ts
CHANGED
|
@@ -16,8 +16,6 @@ class DataPopulator {
|
|
|
16
16
|
|
|
17
17
|
private dataMap: ConditionDataMap;
|
|
18
18
|
|
|
19
|
-
private documentSlug: string;
|
|
20
|
-
|
|
21
19
|
private data: ConditionData = {
|
|
22
20
|
o: {},
|
|
23
21
|
v: {},
|
|
@@ -34,10 +32,8 @@ class DataPopulator {
|
|
|
34
32
|
ovc: InputsType,
|
|
35
33
|
dataMap: ConditionDataMap,
|
|
36
34
|
id?: number,
|
|
37
|
-
index?: number
|
|
38
|
-
documentSlug = "main"
|
|
35
|
+
index?: number
|
|
39
36
|
) {
|
|
40
|
-
this.documentSlug = documentSlug;
|
|
41
37
|
this.id = id;
|
|
42
38
|
this.ovc = ovc;
|
|
43
39
|
this.index = index;
|
|
@@ -310,17 +306,10 @@ class DataPopulator {
|
|
|
310
306
|
*/
|
|
311
307
|
private sectionConditionValue(sectionId: number) {
|
|
312
308
|
// Getting section conditions
|
|
313
|
-
const conditions =
|
|
314
|
-
this.references.conditions.sections[this.documentSlug]?.[sectionId];
|
|
309
|
+
const conditions = this.references.conditions.sections.main[sectionId];
|
|
315
310
|
if (conditions === undefined) return undefined;
|
|
316
311
|
|
|
317
|
-
return this.conditionsRunner.executeCondition(
|
|
318
|
-
conditions,
|
|
319
|
-
0,
|
|
320
|
-
0,
|
|
321
|
-
"sections",
|
|
322
|
-
this.documentSlug
|
|
323
|
-
);
|
|
312
|
+
return this.conditionsRunner.executeCondition(conditions, 0, 0, "sections");
|
|
324
313
|
}
|
|
325
314
|
}
|
|
326
315
|
|