@legalplace/prerenderx 3.9.2 → 3.9.4-staging.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 +12 -0
- package/dist/libs/DocumentRender.d.ts +1 -1
- package/dist/libs/OptionRender.js +5 -3
- package/dist/libs/Prerender.d.ts +1 -1
- package/dist/libs/SectionRender.js +1 -1
- package/dist/libs/misc/FillPdfFormBase.js +7 -5
- package/dist/libs/outputTableRendering.d.ts +16 -0
- package/dist/libs/outputTableRendering.js +130 -0
- package/dist/libs/regionHelpers.d.ts +5 -0
- package/dist/libs/regionHelpers.js +22 -0
- package/dist/libs/tableOutputExpansion.d.ts +1 -2
- package/package.json +10 -11
- package/src/libs/DocumentRender.ts +2 -5
- package/src/libs/OptionRender.ts +4 -3
- package/src/libs/Prerender.ts +2 -5
- package/src/libs/SectionRender.ts +2 -1
- package/src/libs/misc/FillPdfFormBase.ts +14 -7
- package/src/libs/tableOutputExpansion.ts +4 -2
- package/tests/Prerender.documentMultiple.test.ts +3 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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
|
+
## [3.9.3](https://git.legalplace.eu/legalplace/prerenderx/compare/@legalplace/prerenderx@3.9.2...@legalplace/prerenderx@3.9.3) (2026-09-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* pin lplogic 2.4.1 and add includes/does-not-include ([b35fdc5](https://git.legalplace.eu/legalplace/prerenderx/commits/b35fdc54e74246c954ad6483eb5b6282c749c639))
|
|
12
|
+
* restore contains/does-not-contain as equality aliases of is/not ([3902bdf](https://git.legalplace.eu/legalplace/prerenderx/commits/3902bdf7d8ace558215a7eb98edd2c7f5b6b5555))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [3.9.2](https://git.legalplace.eu/legalplace/prerenderx/compare/@legalplace/prerenderx@3.9.1...@legalplace/prerenderx@3.9.2) (2026-09-01)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @legalplace/prerenderx
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type ConditionsRunner from "@legalplace/conditions-runner";
|
|
2
|
-
import {
|
|
2
|
+
import type { OutputRegionRole, Types } from "@legalplace/referencesparser";
|
|
3
3
|
import type InputsType from "@legalplace/types/dist/inputs";
|
|
4
4
|
import type NumAuto from "./NumAuto";
|
|
5
5
|
declare class DocumentRender {
|
|
@@ -29,7 +29,9 @@ var OptionRender = (function () {
|
|
|
29
29
|
OptionRender.prototype.isDisplayed = function (optionId) {
|
|
30
30
|
var _this = this;
|
|
31
31
|
if (optionId === void 0) { optionId = this.id; }
|
|
32
|
-
return (0, referencesparser_1.isOptionDisplayed)(this.references, this.ovc, function (type, entityId, entityIndex) {
|
|
32
|
+
return (0, referencesparser_1.isOptionDisplayed)(this.references, this.ovc, function (type, entityId, entityIndex, documentSlug) {
|
|
33
|
+
var _a;
|
|
34
|
+
if (documentSlug === void 0) { documentSlug = "main"; }
|
|
33
35
|
if (type === "options") {
|
|
34
36
|
var conditionObject = _this.references.conditions.options[entityId];
|
|
35
37
|
return conditionObject === undefined
|
|
@@ -37,10 +39,10 @@ var OptionRender = (function () {
|
|
|
37
39
|
: _this.conditions.executeCondition(conditionObject, entityId, entityIndex, "options");
|
|
38
40
|
}
|
|
39
41
|
if (type === "sections") {
|
|
40
|
-
var conditionObject = _this.references.conditions.sections
|
|
42
|
+
var conditionObject = (_a = _this.references.conditions.sections[documentSlug]) === null || _a === void 0 ? void 0 : _a[entityId];
|
|
41
43
|
return conditionObject === undefined
|
|
42
44
|
? true
|
|
43
|
-
: _this.conditions.executeCondition(conditionObject, entityId, entityIndex, "sections");
|
|
45
|
+
: _this.conditions.executeCondition(conditionObject, entityId, entityIndex, "sections", documentSlug);
|
|
44
46
|
}
|
|
45
47
|
return true;
|
|
46
48
|
}, optionId, this.index);
|
package/dist/libs/Prerender.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModelV3 } from "@legalplace/models-v3-types";
|
|
2
|
-
import {
|
|
2
|
+
import type { Types } from "@legalplace/referencesparser";
|
|
3
3
|
import type OvcType from "@legalplace/types/dist/ovc";
|
|
4
4
|
import type InputsType from "@legalplace/types/dist/inputs";
|
|
5
5
|
import type { FDFType, DocumentIndex, DocumentOutputIndex, DocumentPdfFormIndex, DocumentLayout } from "../types/types";
|
|
@@ -44,7 +44,7 @@ var SectionRender = (function () {
|
|
|
44
44
|
var conditionObject = this.references.conditions.sections[this.documentName][this.currentSection];
|
|
45
45
|
var condition = conditionObject === undefined
|
|
46
46
|
? true
|
|
47
|
-
: this.conditions.executeCondition(conditionObject, 0, this.baseIndex, "sections");
|
|
47
|
+
: this.conditions.executeCondition(conditionObject, 0, this.baseIndex, "sections", this.documentName);
|
|
48
48
|
if (condition !== true)
|
|
49
49
|
return;
|
|
50
50
|
var documentMultipleSource = this.getDocumentMultipleSource();
|
|
@@ -4,12 +4,12 @@ var referencesparser_1 = require("@legalplace/referencesparser");
|
|
|
4
4
|
var FillPdfFormBase = (function () {
|
|
5
5
|
function FillPdfFormBase(references, conditions, ovc) {
|
|
6
6
|
var _this = this;
|
|
7
|
-
this.conditionEvaluator = function (type, id, index) {
|
|
7
|
+
this.conditionEvaluator = function (type, id, index, documentSlug) {
|
|
8
8
|
if (type === "options")
|
|
9
9
|
return _this.getOptionCondition(id, index);
|
|
10
10
|
if (type === "variables")
|
|
11
11
|
return _this.getVariableCondition(id, index);
|
|
12
|
-
return _this.getSectionCondition(id);
|
|
12
|
+
return _this.getSectionCondition(id, documentSlug);
|
|
13
13
|
};
|
|
14
14
|
this.references = references;
|
|
15
15
|
this.conditions = conditions;
|
|
@@ -33,11 +33,13 @@ var FillPdfFormBase = (function () {
|
|
|
33
33
|
? true
|
|
34
34
|
: this.conditions.executeCondition(conditionObject, id, index, "options");
|
|
35
35
|
};
|
|
36
|
-
FillPdfFormBase.prototype.getSectionCondition = function (id) {
|
|
37
|
-
var
|
|
36
|
+
FillPdfFormBase.prototype.getSectionCondition = function (id, documentSlug) {
|
|
37
|
+
var _a;
|
|
38
|
+
if (documentSlug === void 0) { documentSlug = "main"; }
|
|
39
|
+
var conditionObject = (_a = this.references.conditions.sections[documentSlug]) === null || _a === void 0 ? void 0 : _a[id];
|
|
38
40
|
return conditionObject === undefined
|
|
39
41
|
? true
|
|
40
|
-
: this.conditions.executeCondition(conditionObject, id, 0, "sections");
|
|
42
|
+
: this.conditions.executeCondition(conditionObject, id, 0, "sections", documentSlug);
|
|
41
43
|
};
|
|
42
44
|
return FillPdfFormBase;
|
|
43
45
|
}());
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OptionV3 } from "@legalplace/models-v3-types";
|
|
2
|
+
export type OutputTableCellStyle = Record<string, string>;
|
|
3
|
+
export type OutputTableStyle = {
|
|
4
|
+
columnWidths?: number[];
|
|
5
|
+
width?: number;
|
|
6
|
+
borderStyle?: string;
|
|
7
|
+
borderColor?: string;
|
|
8
|
+
borderWidth?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const expandOutputTableCellStyle: (styles: OutputTableCellStyle) => OutputTableCellStyle;
|
|
11
|
+
export declare const serializeInlineStyle: (styles: OutputTableCellStyle) => string;
|
|
12
|
+
export declare const buildOutputTableStyleAttr: (tableStyle?: OutputTableStyle) => string;
|
|
13
|
+
export declare const buildOutputTableCellStyleAttr: (cellStyle?: OutputTableCellStyle | null) => string;
|
|
14
|
+
export declare const getOutputTableCellStyle: (option: OptionV3) => OutputTableCellStyle | undefined;
|
|
15
|
+
export declare const replaceOutputTableMarkers: (html: string, renderTable: (tableId: number) => string) => string;
|
|
16
|
+
export declare const stripOutputTableMarkers: (html: string) => string;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.stripOutputTableMarkers = exports.replaceOutputTableMarkers = exports.getOutputTableCellStyle = exports.buildOutputTableCellStyleAttr = exports.buildOutputTableStyleAttr = exports.serializeInlineStyle = exports.expandOutputTableCellStyle = void 0;
|
|
15
|
+
var DEFAULT_OUTPUT_TABLE_CELL_STYLE = {
|
|
16
|
+
paddingTop: "4px",
|
|
17
|
+
paddingRight: "4px",
|
|
18
|
+
paddingBottom: "4px",
|
|
19
|
+
paddingLeft: "4px",
|
|
20
|
+
borderTopWidth: "1px",
|
|
21
|
+
borderTopStyle: "solid",
|
|
22
|
+
borderTopColor: "#000000",
|
|
23
|
+
borderRightWidth: "1px",
|
|
24
|
+
borderRightStyle: "solid",
|
|
25
|
+
borderRightColor: "#000000",
|
|
26
|
+
borderBottomWidth: "1px",
|
|
27
|
+
borderBottomStyle: "solid",
|
|
28
|
+
borderBottomColor: "#000000",
|
|
29
|
+
borderLeftWidth: "1px",
|
|
30
|
+
borderLeftStyle: "solid",
|
|
31
|
+
borderLeftColor: "#000000",
|
|
32
|
+
};
|
|
33
|
+
var BORDER_SIDES = ["Top", "Right", "Bottom", "Left"];
|
|
34
|
+
var parseBoxShorthand = function (parts) {
|
|
35
|
+
var first = parts[0], second = parts[1], third = parts[2], fourth = parts[3];
|
|
36
|
+
if (parts.length === 1) {
|
|
37
|
+
return [first, first, first, first];
|
|
38
|
+
}
|
|
39
|
+
if (parts.length === 2) {
|
|
40
|
+
return [first, second, first, second];
|
|
41
|
+
}
|
|
42
|
+
if (parts.length === 3) {
|
|
43
|
+
return [first, second, third, second];
|
|
44
|
+
}
|
|
45
|
+
return [first, second, third, fourth];
|
|
46
|
+
};
|
|
47
|
+
var parseBorderShorthand = function (border) {
|
|
48
|
+
var parts = border.trim().split(/\s+/);
|
|
49
|
+
var width = parts.find(function (part) { return /^[0-9.]+(px|pt|em|rem|%)?$/i.test(part); }) || "1px";
|
|
50
|
+
var style = parts.find(function (part) {
|
|
51
|
+
return ["solid", "dashed", "dotted", "double", "none"].includes(part.toLowerCase());
|
|
52
|
+
}) || "solid";
|
|
53
|
+
var color = parts.find(function (part) { return part.startsWith("#") || part.startsWith("rgb"); }) ||
|
|
54
|
+
"#000000";
|
|
55
|
+
return { width: width, style: style, color: color };
|
|
56
|
+
};
|
|
57
|
+
var expandOutputTableCellStyle = function (styles) {
|
|
58
|
+
var expanded = __assign({}, styles);
|
|
59
|
+
if (expanded.padding) {
|
|
60
|
+
var _a = parseBoxShorthand(expanded.padding.trim().split(/\s+/)), top_1 = _a[0], right = _a[1], bottom = _a[2], left = _a[3];
|
|
61
|
+
delete expanded.padding;
|
|
62
|
+
expanded.paddingTop = expanded.paddingTop || top_1;
|
|
63
|
+
expanded.paddingRight = expanded.paddingRight || right;
|
|
64
|
+
expanded.paddingBottom = expanded.paddingBottom || bottom;
|
|
65
|
+
expanded.paddingLeft = expanded.paddingLeft || left;
|
|
66
|
+
}
|
|
67
|
+
if (expanded.border) {
|
|
68
|
+
var _b = parseBorderShorthand(expanded.border), width_1 = _b.width, style_1 = _b.style, color_1 = _b.color;
|
|
69
|
+
delete expanded.border;
|
|
70
|
+
BORDER_SIDES.forEach(function (side) {
|
|
71
|
+
var widthKey = "border".concat(side, "Width");
|
|
72
|
+
var styleKey = "border".concat(side, "Style");
|
|
73
|
+
var colorKey = "border".concat(side, "Color");
|
|
74
|
+
expanded[widthKey] = expanded[widthKey] || width_1;
|
|
75
|
+
expanded[styleKey] = expanded[styleKey] || style_1;
|
|
76
|
+
expanded[colorKey] = expanded[colorKey] || color_1;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return expanded;
|
|
80
|
+
};
|
|
81
|
+
exports.expandOutputTableCellStyle = expandOutputTableCellStyle;
|
|
82
|
+
var camelToKebab = function (property) {
|
|
83
|
+
return property.replace(/[A-Z]/g, function (match) { return "-".concat(match.toLowerCase()); });
|
|
84
|
+
};
|
|
85
|
+
var serializeInlineStyle = function (styles) {
|
|
86
|
+
return Object.entries(styles)
|
|
87
|
+
.filter(function (_a) {
|
|
88
|
+
var value = _a[1];
|
|
89
|
+
return value !== undefined && value !== "";
|
|
90
|
+
})
|
|
91
|
+
.map(function (_a) {
|
|
92
|
+
var property = _a[0], value = _a[1];
|
|
93
|
+
return "".concat(camelToKebab(property), ":").concat(value);
|
|
94
|
+
})
|
|
95
|
+
.join(";");
|
|
96
|
+
};
|
|
97
|
+
exports.serializeInlineStyle = serializeInlineStyle;
|
|
98
|
+
var buildOutputTableStyleAttr = function (tableStyle) {
|
|
99
|
+
var styles = [
|
|
100
|
+
"table-layout:fixed",
|
|
101
|
+
"border-spacing:0",
|
|
102
|
+
"border-collapse:collapse",
|
|
103
|
+
];
|
|
104
|
+
if (typeof (tableStyle === null || tableStyle === void 0 ? void 0 : tableStyle.width) === "number") {
|
|
105
|
+
styles.push("width:".concat(tableStyle.width, "%"));
|
|
106
|
+
}
|
|
107
|
+
return " style=\"".concat(styles.join(";"), "\"");
|
|
108
|
+
};
|
|
109
|
+
exports.buildOutputTableStyleAttr = buildOutputTableStyleAttr;
|
|
110
|
+
var buildOutputTableCellStyleAttr = function (cellStyle) {
|
|
111
|
+
var styles = (0, exports.expandOutputTableCellStyle)(__assign(__assign({}, DEFAULT_OUTPUT_TABLE_CELL_STYLE), (cellStyle || {})));
|
|
112
|
+
var serialized = (0, exports.serializeInlineStyle)(styles);
|
|
113
|
+
return serialized.length > 0 ? " style=\"".concat(serialized, "\"") : "";
|
|
114
|
+
};
|
|
115
|
+
exports.buildOutputTableCellStyleAttr = buildOutputTableCellStyleAttr;
|
|
116
|
+
var getOutputTableCellStyle = function (option) {
|
|
117
|
+
return option.meta.cellStyle;
|
|
118
|
+
};
|
|
119
|
+
exports.getOutputTableCellStyle = getOutputTableCellStyle;
|
|
120
|
+
var OUTPUT_TABLE_MARKER_REGEX = /<output-table\s+data-id="(\d+)"\s*><\/output-table>/gi;
|
|
121
|
+
var replaceOutputTableMarkers = function (html, renderTable) {
|
|
122
|
+
return html.replace(OUTPUT_TABLE_MARKER_REGEX, function (_match, tableId) {
|
|
123
|
+
return renderTable(parseInt(tableId, 10));
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
exports.replaceOutputTableMarkers = replaceOutputTableMarkers;
|
|
127
|
+
var stripOutputTableMarkers = function (html) {
|
|
128
|
+
return html.replace(OUTPUT_TABLE_MARKER_REGEX, "");
|
|
129
|
+
};
|
|
130
|
+
exports.stripOutputTableMarkers = stripOutputTableMarkers;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SectionRoleV3, SectionV3 } from "@legalplace/models-v3-types";
|
|
2
|
+
export type OutputRegionRole = SectionRoleV3;
|
|
3
|
+
export declare const isBodySection: (section: SectionV3) => boolean;
|
|
4
|
+
export declare const isRegionSection: (section: SectionV3, role: OutputRegionRole) => boolean;
|
|
5
|
+
export declare const getSectionIdsForRole: (sections: Record<string, SectionV3>, role: OutputRegionRole) => number[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSectionIdsForRole = exports.isRegionSection = exports.isBodySection = void 0;
|
|
4
|
+
var isBodySection = function (section) {
|
|
5
|
+
return !section.role || section.role === "body";
|
|
6
|
+
};
|
|
7
|
+
exports.isBodySection = isBodySection;
|
|
8
|
+
var isRegionSection = function (section, role) {
|
|
9
|
+
if (role === "body")
|
|
10
|
+
return (0, exports.isBodySection)(section);
|
|
11
|
+
return section.role === role;
|
|
12
|
+
};
|
|
13
|
+
exports.isRegionSection = isRegionSection;
|
|
14
|
+
var getSectionIdsForRole = function (sections, role) {
|
|
15
|
+
return Object.keys(sections)
|
|
16
|
+
.map(function (sectionId) { return parseInt(sectionId, 10); })
|
|
17
|
+
.filter(function (sectionId) {
|
|
18
|
+
var section = sections[sectionId];
|
|
19
|
+
return section && (0, exports.isRegionSection)(section, role);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.getSectionIdsForRole = getSectionIdsForRole;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ConditionV3 } from "@legalplace/models-v3-types";
|
|
2
2
|
import type ConditionsRunner from "@legalplace/conditions-runner";
|
|
3
|
-
import type { Types } from "@legalplace/referencesparser";
|
|
4
|
-
import { type ExpandTableMarkupContext } from "@legalplace/referencesparser";
|
|
3
|
+
import type { Types, ExpandTableMarkupContext } from "@legalplace/referencesparser";
|
|
5
4
|
import type InputsType from "@legalplace/types/dist/inputs";
|
|
6
5
|
export declare const evaluateInlineTableCondition: (condition: ConditionV3, contextOptionId: number, occurrenceIndex: number, conditionsRunner: ConditionsRunner, references: Types.ReferencesType, ovc: InputsType) => boolean;
|
|
7
6
|
type CreateTableMarkupContextParams = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/prerenderx",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.4-staging.0",
|
|
4
4
|
"description": "PrerenderX",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": "https://git.legalplace.eu/legalplace/prerenderx",
|
|
@@ -16,26 +16,25 @@
|
|
|
16
16
|
"release": "standard-version -a --no-verify"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@legalplace/conditions-runner": "
|
|
20
|
-
"@legalplace/lplogic": "2.
|
|
21
|
-
"@legalplace/models-v3-types": "
|
|
22
|
-
"@legalplace/ovc-converter": "
|
|
23
|
-
"@legalplace/referencesparser": "
|
|
19
|
+
"@legalplace/conditions-runner": "2.3.4-staging.0",
|
|
20
|
+
"@legalplace/lplogic": "2.4.1",
|
|
21
|
+
"@legalplace/models-v3-types": "5.18.3-staging.0",
|
|
22
|
+
"@legalplace/ovc-converter": "2.2.25-staging.0",
|
|
23
|
+
"@legalplace/referencesparser": "3.3.5-staging.0",
|
|
24
24
|
"@legalplace/yousign": "^0.9.23",
|
|
25
25
|
"crypto": "^1.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.7.2",
|
|
29
29
|
"@babel/preset-typescript": "^7.7.2",
|
|
30
|
-
"@legalplace/eslint-config-base": "
|
|
31
|
-
"@legalplace/prettier-config": "
|
|
32
|
-
"@legalplace/types": "
|
|
30
|
+
"@legalplace/eslint-config-base": "1.2.1-staging.0",
|
|
31
|
+
"@legalplace/prettier-config": "2.1.4-staging.0",
|
|
32
|
+
"@legalplace/types": "2.22.15-staging.0",
|
|
33
33
|
"@types/jest": "^24.0.15",
|
|
34
34
|
"jest": "^24.8.0",
|
|
35
35
|
"redux-mock-store": "^1.5.3",
|
|
36
36
|
"standard-version": "^9.3.1",
|
|
37
37
|
"ts-jest": "^24.0.2"
|
|
38
38
|
},
|
|
39
|
-
"prettier": "@legalplace/prettier-config"
|
|
40
|
-
"gitHead": "9915cad70819d4cf395ccdf7e006482a02b195fa"
|
|
39
|
+
"prettier": "@legalplace/prettier-config"
|
|
41
40
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type ConditionsRunner from "@legalplace/conditions-runner";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type OutputRegionRole,
|
|
5
|
-
type Types,
|
|
6
|
-
} from "@legalplace/referencesparser";
|
|
2
|
+
import type { OutputRegionRole, Types } from "@legalplace/referencesparser";
|
|
3
|
+
import { getSectionIdsForRole } from "@legalplace/referencesparser";
|
|
7
4
|
import type InputsType from "@legalplace/types/dist/inputs";
|
|
8
5
|
import SectionRender from "./SectionRender";
|
|
9
6
|
import type NumAuto from "./NumAuto";
|
package/src/libs/OptionRender.ts
CHANGED
|
@@ -67,7 +67,7 @@ class OptionRender {
|
|
|
67
67
|
return isOptionDisplayed(
|
|
68
68
|
this.references,
|
|
69
69
|
this.ovc,
|
|
70
|
-
(type, entityId, entityIndex) => {
|
|
70
|
+
(type, entityId, entityIndex, documentSlug = "main") => {
|
|
71
71
|
if (type === "options") {
|
|
72
72
|
const conditionObject = this.references.conditions.options[entityId];
|
|
73
73
|
return conditionObject === undefined
|
|
@@ -81,14 +81,15 @@ class OptionRender {
|
|
|
81
81
|
}
|
|
82
82
|
if (type === "sections") {
|
|
83
83
|
const conditionObject =
|
|
84
|
-
this.references.conditions.sections
|
|
84
|
+
this.references.conditions.sections[documentSlug]?.[entityId];
|
|
85
85
|
return conditionObject === undefined
|
|
86
86
|
? true
|
|
87
87
|
: this.conditions.executeCondition(
|
|
88
88
|
conditionObject,
|
|
89
89
|
entityId,
|
|
90
90
|
entityIndex,
|
|
91
|
-
"sections"
|
|
91
|
+
"sections",
|
|
92
|
+
documentSlug
|
|
92
93
|
);
|
|
93
94
|
}
|
|
94
95
|
return true;
|
package/src/libs/Prerender.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { ModelV3 } from "@legalplace/models-v3-types";
|
|
2
2
|
import ConditionsRunner from "@legalplace/conditions-runner";
|
|
3
3
|
import OvcConverter from "@legalplace/ovc-converter";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
type OutputRegionRole,
|
|
7
|
-
type Types,
|
|
8
|
-
} from "@legalplace/referencesparser";
|
|
4
|
+
import type { OutputRegionRole, Types } from "@legalplace/referencesparser";
|
|
5
|
+
import { ReferencesParser } from "@legalplace/referencesparser";
|
|
9
6
|
import type OvcType from "@legalplace/types/dist/ovc";
|
|
10
7
|
import type InputsType from "@legalplace/types/dist/inputs";
|
|
11
8
|
import crypto from "crypto";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { Types } from "@legalplace/referencesparser";
|
|
1
|
+
import type { Types, ConditionEvaluator } from "@legalplace/referencesparser";
|
|
2
2
|
import type ConditionsRunner from "@legalplace/conditions-runner";
|
|
3
3
|
import type InputsType from "@legalplace/types/dist/inputs";
|
|
4
4
|
import {
|
|
5
5
|
isOptionDisplayed as sharedIsOptionDisplayed,
|
|
6
6
|
isVariableDisplayed as sharedIsVariableDisplayed,
|
|
7
|
-
type ConditionEvaluator,
|
|
8
7
|
} from "@legalplace/referencesparser";
|
|
9
8
|
|
|
10
9
|
class FillPdfFormBase {
|
|
@@ -30,11 +29,12 @@ class FillPdfFormBase {
|
|
|
30
29
|
private readonly conditionEvaluator: ConditionEvaluator = (
|
|
31
30
|
type,
|
|
32
31
|
id,
|
|
33
|
-
index
|
|
32
|
+
index,
|
|
33
|
+
documentSlug
|
|
34
34
|
) => {
|
|
35
35
|
if (type === "options") return this.getOptionCondition(id, index);
|
|
36
36
|
if (type === "variables") return this.getVariableCondition(id, index);
|
|
37
|
-
return this.getSectionCondition(id);
|
|
37
|
+
return this.getSectionCondition(id, documentSlug);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -91,11 +91,18 @@ class FillPdfFormBase {
|
|
|
91
91
|
/**
|
|
92
92
|
* Returns a section's conditions.
|
|
93
93
|
*/
|
|
94
|
-
private getSectionCondition(id: number) {
|
|
95
|
-
const conditionObject =
|
|
94
|
+
private getSectionCondition(id: number, documentSlug = "main") {
|
|
95
|
+
const conditionObject =
|
|
96
|
+
this.references.conditions.sections[documentSlug]?.[id];
|
|
96
97
|
return conditionObject === undefined
|
|
97
98
|
? true
|
|
98
|
-
: this.conditions.executeCondition(
|
|
99
|
+
: this.conditions.executeCondition(
|
|
100
|
+
conditionObject,
|
|
101
|
+
id,
|
|
102
|
+
0,
|
|
103
|
+
"sections",
|
|
104
|
+
documentSlug
|
|
105
|
+
);
|
|
99
106
|
}
|
|
100
107
|
}
|
|
101
108
|
|
|
@@ -2,13 +2,15 @@ import LpLogic from "@legalplace/lplogic";
|
|
|
2
2
|
import type { ConditionV3 } from "@legalplace/models-v3-types";
|
|
3
3
|
import type ConditionsRunner from "@legalplace/conditions-runner";
|
|
4
4
|
import DataPopulator from "@legalplace/conditions-runner/dist/DataPopulator";
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
Types,
|
|
7
|
+
ExpandTableMarkupContext,
|
|
8
|
+
} from "@legalplace/referencesparser";
|
|
6
9
|
import {
|
|
7
10
|
expandTableMarkup,
|
|
8
11
|
extractConditionDataMap,
|
|
9
12
|
hasTableDynamicMarkup,
|
|
10
13
|
stripConditionUiMetadata,
|
|
11
|
-
type ExpandTableMarkupContext,
|
|
12
14
|
} from "@legalplace/referencesparser";
|
|
13
15
|
import type InputsType from "@legalplace/types/dist/inputs";
|
|
14
16
|
import {
|
|
@@ -6,9 +6,7 @@ import Prerender from "../src/libs/Prerender";
|
|
|
6
6
|
* (`params.multiple.enabled = true`, source = option #2). The output
|
|
7
7
|
* `[var:3]` interpolates the partner name at each occurrence.
|
|
8
8
|
*/
|
|
9
|
-
const buildMultipleDocumentModel = (
|
|
10
|
-
filenameTemplate?: string
|
|
11
|
-
): ModelV3 => ({
|
|
9
|
+
const buildMultipleDocumentModel = (filenameTemplate?: string): ModelV3 => ({
|
|
12
10
|
documents: {
|
|
13
11
|
main: {
|
|
14
12
|
name: "Contract",
|
|
@@ -160,8 +158,8 @@ describe("Prerender — document multiple", () => {
|
|
|
160
158
|
((b[1].occurrenceIndex ?? 0) as number)
|
|
161
159
|
);
|
|
162
160
|
|
|
163
|
-
const rendered = entries.map(
|
|
164
|
-
prerender.getDocument(hash) as string
|
|
161
|
+
const rendered = entries.map(
|
|
162
|
+
([hash]) => prerender.getDocument(hash) as string
|
|
165
163
|
);
|
|
166
164
|
|
|
167
165
|
expect(rendered[0]).toContain("Hello Alice");
|