@legalplace/conditions-runner 2.4.0 → 2.4.2
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 +19 -0
- package/dist/ConditionsRunner.d.ts +1 -1
- package/dist/ConditionsRunner.js +6 -6
- package/dist/DataPopulator.d.ts +2 -1
- package/dist/DataPopulator.js +5 -3
- package/package.json +4 -4
- package/src/ConditionsRunner.ts +16 -7
- package/src/DataPopulator.ts +14 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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.2](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/conditions-runner@2.4.1...@legalplace/conditions-runner@2.4.2) (2026-09-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* fix section handling across multiple documents ([6ff17f7](https://git.legalplace.eu/legalplace/monorepo/commits/6ff17f7374ce746b304839566d1ef1222e6f9033))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.4.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/conditions-runner@2.4.0...@legalplace/conditions-runner@2.4.1) (2026-09-10)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @legalplace/conditions-runner
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
# [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
26
|
|
|
8
27
|
|
|
@@ -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"): any;
|
|
17
|
+
}, id: number, index: number, conditionType: "options" | "optionValidator" | "variables" | "prefillers" | "variableValidator" | "sections" | "documents" | "multiples", documentSlug?: string): 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) => `${JSON.stringify(condition)}-${id}-${index}-${conditionType}`;
|
|
14
|
+
this.buildMemoizeKey = (condition, id, index, conditionType, documentSlug) => `${JSON.stringify(condition)}-${id}-${index}-${conditionType}-${documentSlug}`;
|
|
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, documentSlug = "main") {
|
|
66
|
+
const memoizedKey = this.buildMemoizeKey(condition, id, index, conditionType, documentSlug);
|
|
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).getData();
|
|
72
|
+
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index, documentSlug).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).getData();
|
|
78
|
+
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, dataId, index, documentSlug).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).getData();
|
|
81
|
+
currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index, documentSlug).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,8 +9,9 @@ declare class DataPopulator {
|
|
|
9
9
|
private id?;
|
|
10
10
|
private index?;
|
|
11
11
|
private dataMap;
|
|
12
|
+
private documentSlug;
|
|
12
13
|
private data;
|
|
13
|
-
constructor(conditionsRunner: ConditionsRunner, references: Types.ReferencesType, ovc: InputsType, dataMap: ConditionDataMap, id?: number, index?: number);
|
|
14
|
+
constructor(conditionsRunner: ConditionsRunner, references: Types.ReferencesType, ovc: InputsType, dataMap: ConditionDataMap, id?: number, index?: number, documentSlug?: string);
|
|
14
15
|
getData(): Readonly<ConditionData>;
|
|
15
16
|
private populateConditions;
|
|
16
17
|
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, documentSlug = "main") {
|
|
5
5
|
this.data = {
|
|
6
6
|
o: {},
|
|
7
7
|
v: {},
|
|
@@ -11,6 +11,7 @@ class DataPopulator {
|
|
|
11
11
|
v: {},
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
|
+
this.documentSlug = documentSlug;
|
|
14
15
|
this.id = id;
|
|
15
16
|
this.ovc = ovc;
|
|
16
17
|
this.index = index;
|
|
@@ -156,10 +157,11 @@ class DataPopulator {
|
|
|
156
157
|
return result;
|
|
157
158
|
}
|
|
158
159
|
sectionConditionValue(sectionId) {
|
|
159
|
-
|
|
160
|
+
var _a;
|
|
161
|
+
const conditions = (_a = this.references.conditions.sections[this.documentSlug]) === null || _a === void 0 ? void 0 : _a[sectionId];
|
|
160
162
|
if (conditions === undefined)
|
|
161
163
|
return undefined;
|
|
162
|
-
return this.conditionsRunner.executeCondition(conditions, 0, 0, "sections");
|
|
164
|
+
return this.conditionsRunner.executeCondition(conditions, 0, 0, "sections", this.documentSlug);
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
167
|
exports.default = DataPopulator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/conditions-runner",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "Package containing method to execute conditions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/ConditionsRunner.js",
|
|
@@ -22,13 +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.4.
|
|
25
|
+
"@legalplace/models-v3-types": "^5.20.0",
|
|
26
|
+
"@legalplace/referencesparser": "^3.4.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@legalplace/prettier-config": "^2.1.3",
|
|
30
30
|
"@legalplace/types": "^2.22.13",
|
|
31
31
|
"ts-node": "^10.8.1"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "77ecb5b41ff0081d809928dc772da3ddc079975e"
|
|
34
34
|
}
|
package/src/ConditionsRunner.ts
CHANGED
|
@@ -114,8 +114,12 @@ class ConditionsRunner {
|
|
|
114
114
|
| "variableValidator"
|
|
115
115
|
| "sections"
|
|
116
116
|
| "documents"
|
|
117
|
-
| "multiples"
|
|
118
|
-
|
|
117
|
+
| "multiples",
|
|
118
|
+
documentSlug: string
|
|
119
|
+
) =>
|
|
120
|
+
`${JSON.stringify(
|
|
121
|
+
condition
|
|
122
|
+
)}-${id}-${index}-${conditionType}-${documentSlug}`;
|
|
119
123
|
|
|
120
124
|
executeCondition(
|
|
121
125
|
condition: {
|
|
@@ -132,13 +136,15 @@ class ConditionsRunner {
|
|
|
132
136
|
| "variableValidator"
|
|
133
137
|
| "sections"
|
|
134
138
|
| "documents"
|
|
135
|
-
| "multiples"
|
|
139
|
+
| "multiples",
|
|
140
|
+
documentSlug = "main"
|
|
136
141
|
): any {
|
|
137
142
|
const memoizedKey = this.buildMemoizeKey(
|
|
138
143
|
condition,
|
|
139
144
|
id,
|
|
140
145
|
index,
|
|
141
|
-
conditionType
|
|
146
|
+
conditionType,
|
|
147
|
+
documentSlug
|
|
142
148
|
);
|
|
143
149
|
if (this.executeConditionMemo[memoizedKey] !== undefined) {
|
|
144
150
|
return this.executeConditionMemo[memoizedKey];
|
|
@@ -153,7 +159,8 @@ class ConditionsRunner {
|
|
|
153
159
|
this.ovc,
|
|
154
160
|
condition.dataMap,
|
|
155
161
|
id,
|
|
156
|
-
index
|
|
162
|
+
index,
|
|
163
|
+
documentSlug
|
|
157
164
|
).getData();
|
|
158
165
|
} else if (
|
|
159
166
|
conditionType === "variables" ||
|
|
@@ -167,7 +174,8 @@ class ConditionsRunner {
|
|
|
167
174
|
this.ovc,
|
|
168
175
|
condition.dataMap,
|
|
169
176
|
dataId,
|
|
170
|
-
index
|
|
177
|
+
index,
|
|
178
|
+
documentSlug
|
|
171
179
|
).getData();
|
|
172
180
|
} else if (conditionType === "sections" || conditionType === "documents") {
|
|
173
181
|
currentData = new DataPopulator(
|
|
@@ -176,7 +184,8 @@ class ConditionsRunner {
|
|
|
176
184
|
this.ovc,
|
|
177
185
|
condition.dataMap,
|
|
178
186
|
id,
|
|
179
|
-
index
|
|
187
|
+
index,
|
|
188
|
+
documentSlug
|
|
180
189
|
).getData();
|
|
181
190
|
} else if (conditionType === "multiples") {
|
|
182
191
|
// Multiple CTA conditions are evaluated once for the whole group
|
package/src/DataPopulator.ts
CHANGED
|
@@ -16,6 +16,8 @@ class DataPopulator {
|
|
|
16
16
|
|
|
17
17
|
private dataMap: ConditionDataMap;
|
|
18
18
|
|
|
19
|
+
private documentSlug: string;
|
|
20
|
+
|
|
19
21
|
private data: ConditionData = {
|
|
20
22
|
o: {},
|
|
21
23
|
v: {},
|
|
@@ -32,8 +34,10 @@ class DataPopulator {
|
|
|
32
34
|
ovc: InputsType,
|
|
33
35
|
dataMap: ConditionDataMap,
|
|
34
36
|
id?: number,
|
|
35
|
-
index?: number
|
|
37
|
+
index?: number,
|
|
38
|
+
documentSlug = "main"
|
|
36
39
|
) {
|
|
40
|
+
this.documentSlug = documentSlug;
|
|
37
41
|
this.id = id;
|
|
38
42
|
this.ovc = ovc;
|
|
39
43
|
this.index = index;
|
|
@@ -306,10 +310,17 @@ class DataPopulator {
|
|
|
306
310
|
*/
|
|
307
311
|
private sectionConditionValue(sectionId: number) {
|
|
308
312
|
// Getting section conditions
|
|
309
|
-
const conditions =
|
|
313
|
+
const conditions =
|
|
314
|
+
this.references.conditions.sections[this.documentSlug]?.[sectionId];
|
|
310
315
|
if (conditions === undefined) return undefined;
|
|
311
316
|
|
|
312
|
-
return this.conditionsRunner.executeCondition(
|
|
317
|
+
return this.conditionsRunner.executeCondition(
|
|
318
|
+
conditions,
|
|
319
|
+
0,
|
|
320
|
+
0,
|
|
321
|
+
"sections",
|
|
322
|
+
this.documentSlug
|
|
323
|
+
);
|
|
313
324
|
}
|
|
314
325
|
}
|
|
315
326
|
|