@legalplace/conditions-runner 2.4.10 → 2.4.11
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
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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.11](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/conditions-runner@2.4.10...@legalplace/conditions-runner@2.4.11) (2026-10-05)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- ignore groupMeta when evaluating conditions ([3bb571a](https://git.legalplace.eu/legalplace/monorepo/commits/3bb571a97381aa96d07a7f226d75c9a64d476851)), closes [api#124j4fvk6w6](https://git.legalplace.eu/api/issues/124j4fvk6w6)
|
|
11
|
+
|
|
6
12
|
## [2.4.10](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/conditions-runner@2.4.9...@legalplace/conditions-runner@2.4.10) (2026-10-01)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @legalplace/conditions-runner
|
package/dist/ConditionsRunner.js
CHANGED
|
@@ -87,7 +87,7 @@ class ConditionsRunner {
|
|
|
87
87
|
const deps = { references: this.references, ovc: this.ovc };
|
|
88
88
|
const aggregatedConditions = (0, ScopedLeafEvaluator_1.aggregateScopedLeaves)((0, referencesparser_1.lowerScope)(condition.conditions), new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap).getData(), resolverContext, deps);
|
|
89
89
|
const resolvedConditions = (0, ComparatorResolver_1.resolveConditionComparators)(aggregatedConditions, resolverContext, deps);
|
|
90
|
-
const result = (0, lplogic_1.default)(resolvedConditions, currentData);
|
|
90
|
+
const result = (0, lplogic_1.default)((0, referencesparser_1.stripConditionUiMetadata)(resolvedConditions), currentData);
|
|
91
91
|
this.executeConditionMemo[memoizedKey] = result;
|
|
92
92
|
return result;
|
|
93
93
|
}
|
|
@@ -302,6 +302,68 @@ describe("resolveConditionComparators", () => {
|
|
|
302
302
|
});
|
|
303
303
|
});
|
|
304
304
|
});
|
|
305
|
+
const buildMandatDocumentReferences = () => ({
|
|
306
|
+
options: {
|
|
307
|
+
3068: {
|
|
308
|
+
meta: { id: 3068, type: "static", label: "Section", step: "*" },
|
|
309
|
+
options: [],
|
|
310
|
+
variables: [3515],
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
variables: {
|
|
314
|
+
3515: {
|
|
315
|
+
meta: { id: 3515, type: "list", label: "MASTER CREATION avec LP" },
|
|
316
|
+
options: [],
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
outputs: {},
|
|
320
|
+
boxes: {},
|
|
321
|
+
documents: {
|
|
322
|
+
"mandat-2": { name: "Mandat", params: { formats: { pdf: true } } },
|
|
323
|
+
},
|
|
324
|
+
sections: {},
|
|
325
|
+
relations: {
|
|
326
|
+
options: {
|
|
327
|
+
3068: {
|
|
328
|
+
...emptyOptionRelations,
|
|
329
|
+
children: { options: [], variables: [3515] },
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
variables: {
|
|
333
|
+
3515: { ...emptyOptionRelations, parents: [3068] },
|
|
334
|
+
},
|
|
335
|
+
sections: {},
|
|
336
|
+
},
|
|
337
|
+
conditions: {
|
|
338
|
+
options: {},
|
|
339
|
+
variables: {},
|
|
340
|
+
documents: {},
|
|
341
|
+
sections: { main: {} },
|
|
342
|
+
prefillers: {},
|
|
343
|
+
validators: { options: {}, variables: {} },
|
|
344
|
+
},
|
|
345
|
+
defaults: {},
|
|
346
|
+
evaluations: {},
|
|
347
|
+
optionTags: {},
|
|
348
|
+
variableTags: {},
|
|
349
|
+
});
|
|
350
|
+
const mandatCondition = {
|
|
351
|
+
and: [{ "<>": [{ var: "v.3515" }, "non"] }],
|
|
352
|
+
groupMeta: { label: "", collapsed: false },
|
|
353
|
+
};
|
|
354
|
+
describe("document conditions carrying groupMeta", () => {
|
|
355
|
+
const runner = new ConditionsRunner_1.default(buildMandatDocumentReferences(), {
|
|
356
|
+
options: {},
|
|
357
|
+
variables: { 3515: ["oui"] },
|
|
358
|
+
});
|
|
359
|
+
it("returns true for the same rule when the AND group has no groupMeta", () => {
|
|
360
|
+
const { groupMeta: _groupMeta, ...rule } = mandatCondition;
|
|
361
|
+
expect(runner.executeCondition(mappedCondition(rule), 0, 0, "documents", "mandat-2")).toBe(true);
|
|
362
|
+
});
|
|
363
|
+
it("returns true for 3515 <> non when the AND group also has groupMeta", () => {
|
|
364
|
+
expect(runner.executeCondition(mappedCondition(mandatCondition), 0, 0, "documents", "mandat-2")).toBe(true);
|
|
365
|
+
});
|
|
366
|
+
});
|
|
305
367
|
describe("includes / does-not-include operators", () => {
|
|
306
368
|
it("should lower the operator to includes-any when the scope is any", () => {
|
|
307
369
|
expect((0, referencesparser_1.lowerScope)({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/conditions-runner",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.11",
|
|
4
4
|
"description": "Package containing method to execute conditions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/ConditionsRunner.js",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"jest-junit": "^13.0.0",
|
|
39
39
|
"ts-node": "^10.8.1"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "01a1d60bb5aeedd8f0582816e7e81d6c55be2600"
|
|
42
42
|
}
|
|
@@ -389,6 +389,82 @@ describe("resolveConditionComparators", () => {
|
|
|
389
389
|
});
|
|
390
390
|
});
|
|
391
391
|
|
|
392
|
+
/**
|
|
393
|
+
* Document condition as published for Mandat: variable 3515 is "oui",
|
|
394
|
+
* and the ET/OU group carries the editor's groupMeta.
|
|
395
|
+
*/
|
|
396
|
+
const buildMandatDocumentReferences = (): Types.ReferencesType =>
|
|
397
|
+
({
|
|
398
|
+
options: {
|
|
399
|
+
3068: {
|
|
400
|
+
meta: { id: 3068, type: "static", label: "Section", step: "*" },
|
|
401
|
+
options: [],
|
|
402
|
+
variables: [3515],
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
variables: {
|
|
406
|
+
3515: {
|
|
407
|
+
meta: { id: 3515, type: "list", label: "MASTER CREATION avec LP" },
|
|
408
|
+
options: [],
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
outputs: {},
|
|
412
|
+
boxes: {},
|
|
413
|
+
documents: {
|
|
414
|
+
"mandat-2": { name: "Mandat", params: { formats: { pdf: true } } },
|
|
415
|
+
},
|
|
416
|
+
sections: {},
|
|
417
|
+
relations: {
|
|
418
|
+
options: {
|
|
419
|
+
3068: {
|
|
420
|
+
...emptyOptionRelations,
|
|
421
|
+
children: { options: [], variables: [3515] },
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
variables: {
|
|
425
|
+
3515: { ...emptyOptionRelations, parents: [3068] },
|
|
426
|
+
},
|
|
427
|
+
sections: {},
|
|
428
|
+
},
|
|
429
|
+
conditions: {
|
|
430
|
+
options: {},
|
|
431
|
+
variables: {},
|
|
432
|
+
documents: {},
|
|
433
|
+
sections: { main: {} },
|
|
434
|
+
prefillers: {},
|
|
435
|
+
validators: { options: {}, variables: {} },
|
|
436
|
+
},
|
|
437
|
+
defaults: {},
|
|
438
|
+
evaluations: {},
|
|
439
|
+
optionTags: {},
|
|
440
|
+
variableTags: {},
|
|
441
|
+
} as unknown as Types.ReferencesType);
|
|
442
|
+
|
|
443
|
+
const mandatCondition = {
|
|
444
|
+
and: [{ "<>": [{ var: "v.3515" }, "non"] }],
|
|
445
|
+
groupMeta: { label: "", collapsed: false },
|
|
446
|
+
} as ConditionV3;
|
|
447
|
+
|
|
448
|
+
describe("document conditions carrying groupMeta", () => {
|
|
449
|
+
const runner = new ConditionsRunner(buildMandatDocumentReferences(), {
|
|
450
|
+
options: {},
|
|
451
|
+
variables: { 3515: ["oui"] },
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it("returns true for the same rule when the AND group has no groupMeta", () => {
|
|
455
|
+
const { groupMeta: _groupMeta, ...rule } = mandatCondition;
|
|
456
|
+
expect(runner.executeCondition(mappedCondition(rule), 0, 0, "documents", "mandat-2")).toBe(
|
|
457
|
+
true
|
|
458
|
+
);
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it("returns true for 3515 <> non when the AND group also has groupMeta", () => {
|
|
462
|
+
expect(
|
|
463
|
+
runner.executeCondition(mappedCondition(mandatCondition), 0, 0, "documents", "mandat-2")
|
|
464
|
+
).toBe(true);
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
|
|
392
468
|
describe("includes / does-not-include operators", () => {
|
|
393
469
|
it("should lower the operator to includes-any when the scope is any", () => {
|
|
394
470
|
expect(
|
package/src/ConditionsRunner.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
import LpLogic from "@legalplace/lplogic";
|
|
3
3
|
import type { Types } from "@legalplace/referencesparser";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
lowerScope,
|
|
6
|
+
stripConditionUiMetadata,
|
|
7
|
+
} from "@legalplace/referencesparser";
|
|
5
8
|
import type { ConditionV3 } from "@legalplace/models-v3-types";
|
|
6
9
|
import type InputsType from "@legalplace/types/dist/inputs";
|
|
7
10
|
import DataPopulator from "./DataPopulator";
|
|
@@ -224,7 +227,10 @@ class ConditionsRunner {
|
|
|
224
227
|
deps
|
|
225
228
|
);
|
|
226
229
|
|
|
227
|
-
const result = LpLogic(
|
|
230
|
+
const result = LpLogic(
|
|
231
|
+
stripConditionUiMetadata(resolvedConditions as ConditionV3 | boolean),
|
|
232
|
+
currentData
|
|
233
|
+
);
|
|
228
234
|
this.executeConditionMemo[memoizedKey] = result;
|
|
229
235
|
return result;
|
|
230
236
|
}
|