@legalplace/prerenderx 3.2.0 → 3.3.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/.eslintrc +3 -47
- package/CHANGELOG.md +28 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +11 -0
- package/dist/libs/DocumentRender.d.ts +4 -4
- package/dist/libs/DocumentRender.js +2 -2
- package/dist/libs/FillPdfForm.d.ts +1 -1
- package/dist/libs/FillPdfForm.js +30 -24
- package/dist/libs/InputsInitiator.d.ts +1 -1
- package/dist/libs/InputsInitiator.js +35 -11
- package/dist/libs/NumAuto.js +1 -1
- package/dist/libs/OptionRender.d.ts +4 -4
- package/dist/libs/OptionRender.js +30 -18
- package/dist/libs/OutputParser.d.ts +2 -2
- package/dist/libs/OutputParser.js +34 -25
- package/dist/libs/Prerender.d.ts +8 -26
- package/dist/libs/Prerender.js +30 -23
- package/dist/libs/SectionRender.d.ts +4 -4
- package/dist/libs/SectionRender.js +22 -13
- package/dist/libs/misc/FillPdfFormBase.d.ts +3 -3
- package/dist/libs/misc/FillPdfFormBase.js +25 -17
- package/dist/types/types.d.ts +17 -0
- package/dist/types/types.js +2 -0
- package/package.json +14 -18
- package/src/index.ts +4 -2
- package/src/libs/DocumentRender.ts +27 -22
- package/src/libs/FillPdfForm.ts +72 -59
- package/src/libs/InputsInitiator.ts +91 -53
- package/src/libs/NumAuto.ts +16 -14
- package/src/libs/OptionRender.ts +85 -45
- package/src/libs/OutputParser.ts +112 -58
- package/src/libs/Prerender.ts +120 -98
- package/src/libs/SectionRender.ts +57 -38
- package/src/libs/misc/FillPdfFormBase.ts +71 -39
- package/src/types/types.ts +22 -0
- package/tsconfig.json +3 -1
- package/.gitlab-ci.yml +0 -43
- package/.prettierrc.js +0 -10
- package/.vscode/settings.json +0 -17
- package/.vscode/tasks.json +0 -24
- package/tsconfig.eslint.json +0 -12
package/.eslintrc
CHANGED
|
@@ -1,52 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"commonjs": true,
|
|
5
|
-
"es6": true,
|
|
6
|
-
"jest": true,
|
|
7
|
-
"node": true
|
|
8
|
-
},
|
|
9
|
-
|
|
10
2
|
"extends": [
|
|
11
|
-
"
|
|
12
|
-
"plugin:prettier/recommended"
|
|
3
|
+
"@legalplace/eslint-config"
|
|
13
4
|
],
|
|
14
|
-
|
|
15
|
-
"parser": "@typescript-eslint/parser",
|
|
16
5
|
"parserOptions": {
|
|
17
|
-
"project": "./tsconfig.
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
"plugins": [
|
|
21
|
-
"prettier", "@typescript-eslint"
|
|
22
|
-
],
|
|
23
|
-
|
|
24
|
-
"rules": {
|
|
25
|
-
"prettier/prettier": ["error"],
|
|
26
|
-
"no-unused-vars": "off",
|
|
27
|
-
"@typescript-eslint/no-unused-vars": ["error", {
|
|
28
|
-
"vars": "all",
|
|
29
|
-
"args": "after-used",
|
|
30
|
-
"ignoreRestSiblings": false
|
|
31
|
-
}],
|
|
32
|
-
"import/no-extraneous-dependencies": ["error", {
|
|
33
|
-
"devDependencies": true
|
|
34
|
-
}],
|
|
35
|
-
"no-continue": 0,
|
|
36
|
-
"class-methods-use-this": 0,
|
|
37
|
-
"no-underscore-dangle": 0,
|
|
38
|
-
"import/prefer-default-export": "warn",
|
|
39
|
-
"camelcase": "error",
|
|
40
|
-
"no-undef": 0,
|
|
41
|
-
"no-dupe-class-members": "off"
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"settings": {
|
|
46
|
-
"import/resolver": {
|
|
47
|
-
"node": {
|
|
48
|
-
"extensions": [".js", ".jsx", ".ts", ".tsx"]
|
|
49
|
-
}
|
|
50
|
-
}
|
|
6
|
+
"project": "./tsconfig.json"
|
|
51
7
|
}
|
|
52
|
-
}
|
|
8
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 3.3.0 (2023-11-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* fix file paths api[#9919](https://git.legalplace.eu/legalplace/prerenderx/issues/9919) ([bb60aa5](https://git.legalplace.eu/legalplace/prerenderx/commits/bb60aa59e91de27c094c8da08c9103e48212d914))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* adding prerenderx to monorepo api[#9919](https://git.legalplace.eu/legalplace/prerenderx/issues/9919) ([f9a121d](https://git.legalplace.eu/legalplace/prerenderx/commits/f9a121d8a613541c346ea48e3dd27314d5a2267f))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
1
22
|
# Changelog
|
|
2
23
|
|
|
3
24
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
25
|
|
|
26
|
+
### [3.2.1](https://git.legalplace.eu/legalplace/prerenderx/compare/v3.2.0...v3.2.1) (2022-12-07)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* enabling pdf/docx when model value is null api[#7032](https://git.legalplace.eu/legalplace/prerenderx/issues/7032) ([12c6983](https://git.legalplace.eu/legalplace/prerenderx/commit/12c698324add0c0723aea21a2b8db6b309c59336))
|
|
32
|
+
|
|
5
33
|
## [3.2.0](https://git.legalplace.eu/legalplace/prerenderx/compare/v3.1.0...v3.2.0) (2022-04-04)
|
|
6
34
|
|
|
7
35
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
2
12
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
14
|
};
|
|
5
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
16
|
var Prerender_1 = __importDefault(require("./libs/Prerender"));
|
|
17
|
+
__exportStar(require("./types/types"), exports);
|
|
7
18
|
exports.default = Prerender_1.default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Types } from
|
|
2
|
-
import ConditionsRunner from
|
|
3
|
-
import InputsType from
|
|
4
|
-
import NumAuto from
|
|
1
|
+
import type { Types } from "@legalplace/referencesparser";
|
|
2
|
+
import type ConditionsRunner from "@legalplace/conditions-runner";
|
|
3
|
+
import type InputsType from "@legalplace/types/dist/inputs";
|
|
4
|
+
import type NumAuto from "./NumAuto";
|
|
5
5
|
declare class DocumentRender {
|
|
6
6
|
references: Types.ReferencesType;
|
|
7
7
|
conditions: ConditionsRunner;
|
|
@@ -22,10 +22,10 @@ var DocumentRender = (function () {
|
|
|
22
22
|
documentName: documentName,
|
|
23
23
|
ovc: _this.ovc,
|
|
24
24
|
currentSection: parseInt(sectionId, 10),
|
|
25
|
-
numauto: _this.NumAuto
|
|
25
|
+
numauto: _this.NumAuto,
|
|
26
26
|
}).getOutputs());
|
|
27
27
|
});
|
|
28
|
-
return documentOutputs.join(
|
|
28
|
+
return documentOutputs.join("");
|
|
29
29
|
};
|
|
30
30
|
return DocumentRender;
|
|
31
31
|
}());
|
package/dist/libs/FillPdfForm.js
CHANGED
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -25,12 +27,12 @@ var FillPdfForm = (function (_super) {
|
|
|
25
27
|
FillPdfForm.prototype.fillDocument = function (documentName) {
|
|
26
28
|
var _this = this;
|
|
27
29
|
var result = {
|
|
28
|
-
id:
|
|
29
|
-
fields: {}
|
|
30
|
+
id: "",
|
|
31
|
+
fields: {},
|
|
30
32
|
};
|
|
31
33
|
var document = this.references.documents[documentName];
|
|
32
34
|
var pdf = document.pdf;
|
|
33
|
-
if (typeof pdf ===
|
|
35
|
+
if (typeof pdf === "undefined")
|
|
34
36
|
return result;
|
|
35
37
|
var form = pdf.form;
|
|
36
38
|
result.id = pdf.id;
|
|
@@ -41,7 +43,8 @@ var FillPdfForm = (function (_super) {
|
|
|
41
43
|
form.boxes.forEach(function (box) {
|
|
42
44
|
var id = "" + box.name;
|
|
43
45
|
var value = _this.getBoxValue(box);
|
|
44
|
-
if (!(value ===
|
|
46
|
+
if (!(value === "" &&
|
|
47
|
+
Object.prototype.hasOwnProperty.call(result.fields, id)))
|
|
45
48
|
result.fields[id] = value;
|
|
46
49
|
});
|
|
47
50
|
return result;
|
|
@@ -54,61 +57,64 @@ var FillPdfForm = (function (_super) {
|
|
|
54
57
|
var dateRegex = /^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;
|
|
55
58
|
if (variable.date && dateRegex.test(currentValue)) {
|
|
56
59
|
switch (variable.date) {
|
|
57
|
-
case
|
|
58
|
-
return currentValue.replace(dateRegex,
|
|
59
|
-
case
|
|
60
|
-
return currentValue.replace(dateRegex,
|
|
61
|
-
case
|
|
62
|
-
return currentValue.replace(dateRegex,
|
|
60
|
+
case "DD":
|
|
61
|
+
return currentValue.replace(dateRegex, "$1");
|
|
62
|
+
case "MM":
|
|
63
|
+
return currentValue.replace(dateRegex, "$2");
|
|
64
|
+
case "YYYY":
|
|
65
|
+
return currentValue.replace(dateRegex, "$3");
|
|
63
66
|
default:
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
var hourRegex = /^([0-9]{2}:[0-9]{2})$/;
|
|
67
70
|
if (variable.hour && hourRegex.test(currentValue)) {
|
|
68
71
|
switch (variable.hour) {
|
|
69
|
-
case
|
|
70
|
-
return currentValue.replace(hourRegex,
|
|
71
|
-
case
|
|
72
|
-
return currentValue.replace(hourRegex,
|
|
72
|
+
case "HH":
|
|
73
|
+
return currentValue.replace(hourRegex, "$1");
|
|
74
|
+
case "MM":
|
|
75
|
+
return currentValue.replace(hourRegex, "$2");
|
|
73
76
|
default:
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
var emailRegex = /^(.*)@(.*)$/;
|
|
77
80
|
if (variable.email && emailRegex.test(currentValue)) {
|
|
78
81
|
switch (variable.email) {
|
|
79
|
-
case
|
|
80
|
-
return currentValue.split(
|
|
81
|
-
case
|
|
82
|
-
return currentValue.split(
|
|
82
|
+
case "ADDRESS":
|
|
83
|
+
return currentValue.split("@")[0];
|
|
84
|
+
case "PROVIDER":
|
|
85
|
+
return currentValue.split("@")[1];
|
|
83
86
|
default:
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
|
-
if (variable.fragment &&
|
|
89
|
+
if (variable.fragment &&
|
|
90
|
+
typeof variable.fragment.from === "number" &&
|
|
91
|
+
typeof variable.fragment.to === "number") {
|
|
87
92
|
var _a = variable.fragment, from = _a.from, to = _a.to;
|
|
88
93
|
return currentValue.slice(from, to);
|
|
89
94
|
}
|
|
90
95
|
return currentValue;
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
|
-
return
|
|
98
|
+
return "";
|
|
94
99
|
};
|
|
95
100
|
FillPdfForm.prototype.getBoxValue = function (box) {
|
|
96
101
|
for (var i = 0; i < box.options.length; i += 1) {
|
|
97
102
|
var option = box.options[i];
|
|
98
103
|
var currentValue = this.getOptionValue(option.id);
|
|
99
104
|
if (currentValue === true) {
|
|
100
|
-
if (this.references.options[option.id].meta.type === "checkbox" &&
|
|
105
|
+
if (this.references.options[option.id].meta.type === "checkbox" &&
|
|
106
|
+
box.value === "Off")
|
|
101
107
|
return "On";
|
|
102
108
|
return box.value;
|
|
103
109
|
}
|
|
104
110
|
}
|
|
105
|
-
return
|
|
111
|
+
return "";
|
|
106
112
|
};
|
|
107
113
|
FillPdfForm.prototype.getVariableValue = function (variableId) {
|
|
108
114
|
var _a;
|
|
109
115
|
if (this.isVariableDisplayed(variableId, 0) === false)
|
|
110
116
|
return false;
|
|
111
|
-
return (((_a = this.ovc.variables[variableId]) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
117
|
+
return (((_a = this.ovc.variables[variableId]) === null || _a === void 0 ? void 0 : _a[0]) || "").toString();
|
|
112
118
|
};
|
|
113
119
|
FillPdfForm.prototype.getOptionValue = function (optionId) {
|
|
114
120
|
var _a;
|
|
@@ -4,7 +4,7 @@ var IntputsInitiator = (function () {
|
|
|
4
4
|
function IntputsInitiator(references, ovc) {
|
|
5
5
|
this.inputs = {
|
|
6
6
|
options: {},
|
|
7
|
-
variables: {}
|
|
7
|
+
variables: {},
|
|
8
8
|
};
|
|
9
9
|
this.references = references;
|
|
10
10
|
this.ovc = ovc;
|
|
@@ -28,7 +28,7 @@ var IntputsInitiator = (function () {
|
|
|
28
28
|
var rootOptionId = parentsTree.length > 0 ? parentsTree[parentsTree.length - 1] : id;
|
|
29
29
|
if (!_this.ovc.options[rootOptionId]) {
|
|
30
30
|
var rootReference = _this.references.options[rootOptionId];
|
|
31
|
-
if (rootReference.meta.type ===
|
|
31
|
+
if (rootReference.meta.type === "static") {
|
|
32
32
|
_this.ovc.options[rootOptionId] = new Array(inputs.length).fill(true);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -41,15 +41,30 @@ var IntputsInitiator = (function () {
|
|
|
41
41
|
var optionId = optionsIds[i];
|
|
42
42
|
var option = this.references.options[optionId];
|
|
43
43
|
var values = [false];
|
|
44
|
-
if (this.ovc &&
|
|
45
|
-
|
|
44
|
+
if (this.ovc &&
|
|
45
|
+
Object.prototype.hasOwnProperty.call(this.ovc.options, optionId)) {
|
|
46
|
+
if ([
|
|
47
|
+
"static",
|
|
48
|
+
"hidden",
|
|
49
|
+
"brut-text",
|
|
50
|
+
"repeated",
|
|
51
|
+
"box",
|
|
52
|
+
"separator",
|
|
53
|
+
].includes(option.meta.type)) {
|
|
46
54
|
values = new Array(this.ovc.options[optionId].length).fill(true);
|
|
47
55
|
}
|
|
48
56
|
else {
|
|
49
57
|
values = this.ovc.options[optionId];
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
|
-
else if ([
|
|
60
|
+
else if ([
|
|
61
|
+
"static",
|
|
62
|
+
"hidden",
|
|
63
|
+
"brut-text",
|
|
64
|
+
"repeated",
|
|
65
|
+
"box",
|
|
66
|
+
"separator",
|
|
67
|
+
].includes(option.meta.type)) {
|
|
53
68
|
values = [true];
|
|
54
69
|
}
|
|
55
70
|
this.inputs.options[optionId] = values;
|
|
@@ -59,16 +74,25 @@ var IntputsInitiator = (function () {
|
|
|
59
74
|
var variablesIds = Object.keys(this.references.variables);
|
|
60
75
|
for (var i = 0; i < variablesIds.length; i += 1) {
|
|
61
76
|
var variableId = variablesIds[i];
|
|
62
|
-
var values = [
|
|
63
|
-
if (this.ovc &&
|
|
77
|
+
var values = [""];
|
|
78
|
+
if (this.ovc &&
|
|
79
|
+
Object.prototype.hasOwnProperty.call(this.ovc.variables, variableId)) {
|
|
64
80
|
values = this.ovc.variables[variableId];
|
|
65
81
|
}
|
|
66
82
|
else {
|
|
67
|
-
var defaultValue =
|
|
83
|
+
var defaultValue = "";
|
|
68
84
|
var prefillings = this.references.variables[variableId].prefillings;
|
|
69
|
-
if (prefillings &&
|
|
70
|
-
|
|
71
|
-
|
|
85
|
+
if (prefillings &&
|
|
86
|
+
Array.isArray(prefillings) &&
|
|
87
|
+
prefillings.length > 0) {
|
|
88
|
+
var noConditionsPrefills = prefillings.filter(function (prefill) {
|
|
89
|
+
return typeof prefill.conditions === "undefined" ||
|
|
90
|
+
Object.keys(prefill.conditions).length === 0;
|
|
91
|
+
});
|
|
92
|
+
defaultValue =
|
|
93
|
+
noConditionsPrefills.length > 0
|
|
94
|
+
? noConditionsPrefills[0].value
|
|
95
|
+
: "";
|
|
72
96
|
}
|
|
73
97
|
values = [defaultValue];
|
|
74
98
|
}
|
package/dist/libs/NumAuto.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Types } from
|
|
2
|
-
import ConditionsRunner from
|
|
3
|
-
import InputsType from
|
|
4
|
-
import NumAuto from
|
|
1
|
+
import type { Types } from "@legalplace/referencesparser";
|
|
2
|
+
import type ConditionsRunner from "@legalplace/conditions-runner";
|
|
3
|
+
import type InputsType from "@legalplace/types/dist/inputs";
|
|
4
|
+
import type NumAuto from "./NumAuto";
|
|
5
5
|
declare class OptionRender {
|
|
6
6
|
outputs: string[];
|
|
7
7
|
references: Types.ReferencesType;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
8
10
|
};
|
|
9
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
12
|
var OutputParser_1 = require("./OutputParser");
|
|
@@ -26,22 +28,32 @@ var OptionRender = (function () {
|
|
|
26
28
|
var _this = this;
|
|
27
29
|
var option = this.references.options[this.id];
|
|
28
30
|
var conditionObject = this.references.conditions.options[this.id];
|
|
29
|
-
var condition = conditionObject === undefined
|
|
31
|
+
var condition = conditionObject === undefined
|
|
32
|
+
? true
|
|
33
|
+
: this.conditions.executeCondition(conditionObject, this.id, this.index, "options");
|
|
30
34
|
if (condition === true) {
|
|
31
|
-
if (typeof option.meta.output ===
|
|
35
|
+
if (typeof option.meta.output === "string" &&
|
|
36
|
+
option.meta.output.trim().length > 0) {
|
|
32
37
|
var outputReference = this.references.outputs[this.id];
|
|
33
38
|
var autonums = [];
|
|
34
39
|
if (condition !== false) {
|
|
35
40
|
autonums = outputReference.autonums.map(function (currentAn) {
|
|
36
|
-
var fn = currentAn[0] ===
|
|
37
|
-
|
|
41
|
+
var fn = currentAn[0] === "numauto-pre"
|
|
42
|
+
? _this.NumAuto.getNumPre
|
|
43
|
+
: _this.NumAuto.getNum;
|
|
44
|
+
return [
|
|
45
|
+
currentAn[0],
|
|
46
|
+
currentAn[1],
|
|
47
|
+
fn(currentAn[1], currentAn[2]),
|
|
48
|
+
currentAn[2],
|
|
49
|
+
];
|
|
38
50
|
});
|
|
39
51
|
}
|
|
40
|
-
var variables = OutputParser_1.getRelatedVariablesValues(this.id, this.index, outputReference.variables, this.ovc, this.references);
|
|
41
|
-
var output = OutputParser_1.parseOutputWithVariables(option.meta.output, this.index, variables, autonums);
|
|
42
|
-
output = output.replace(/<\/([a-z]+)>([\n\s]+)</gi,
|
|
43
|
-
output = output.replace(/\n/g,
|
|
44
|
-
output = output.replace(/\xA0/g,
|
|
52
|
+
var variables = (0, OutputParser_1.getRelatedVariablesValues)(this.id, this.index, outputReference.variables, this.ovc, this.references);
|
|
53
|
+
var output = (0, OutputParser_1.parseOutputWithVariables)(option.meta.output, this.index, variables, autonums);
|
|
54
|
+
output = output.replace(/<\/([a-z]+)>([\n\s]+)</gi, "</$1><");
|
|
55
|
+
output = output.replace(/\n/g, "<br />");
|
|
56
|
+
output = output.replace(/\xA0/g, " ");
|
|
45
57
|
this.outputs.push(output);
|
|
46
58
|
}
|
|
47
59
|
this.renderChildren();
|
|
@@ -51,14 +63,14 @@ var OptionRender = (function () {
|
|
|
51
63
|
var _this = this;
|
|
52
64
|
var option = this.references.options[this.id];
|
|
53
65
|
option.options.forEach(function (optionId) {
|
|
54
|
-
_this.outputs =
|
|
66
|
+
_this.outputs = __spreadArray(__spreadArray([], _this.outputs, true), new OptionRender({
|
|
55
67
|
references: _this.references,
|
|
56
68
|
id: optionId,
|
|
57
69
|
ovc: _this.ovc,
|
|
58
70
|
index: _this.index,
|
|
59
71
|
conditions: _this.conditions,
|
|
60
|
-
numauto: _this.NumAuto
|
|
61
|
-
}).getOutputs());
|
|
72
|
+
numauto: _this.NumAuto,
|
|
73
|
+
}).getOutputs(), true);
|
|
62
74
|
});
|
|
63
75
|
};
|
|
64
76
|
return OptionRender;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Types } from
|
|
2
|
-
import InputsType from
|
|
1
|
+
import type { Types } from "@legalplace/referencesparser";
|
|
2
|
+
import type InputsType from "@legalplace/types/dist/inputs";
|
|
3
3
|
declare type relVarsValsT = Record<string, string | number>;
|
|
4
4
|
declare type getRelatedVarsT = (optionId: number, index: number, variables: number[], ovc: InputsType, references: Types.ReferencesType) => relVarsValsT;
|
|
5
5
|
export declare const getRelatedVariablesValues: getRelatedVarsT;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
8
10
|
};
|
|
9
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
12
|
exports.parseDocumentNameWithVariables = exports.parseOutputWithVariables = exports.getRelatedVariablesValues = void 0;
|
|
11
13
|
var frenchNumber = function (value) {
|
|
12
|
-
var result = typeof value ===
|
|
14
|
+
var result = typeof value === "number" ? value.toString() : value;
|
|
13
15
|
if (/^([0-9]+)\.([0-9]+)$/.test(result.trim()))
|
|
14
|
-
result = result.trim().replace(
|
|
16
|
+
result = result.trim().replace(".", ",");
|
|
15
17
|
return result;
|
|
16
18
|
};
|
|
17
|
-
|
|
19
|
+
var getRelatedVariablesValues = function (optionId, index, variables, ovc, references) {
|
|
18
20
|
var variablesValues = {};
|
|
19
21
|
variables.forEach(function (currentVariableId) {
|
|
20
|
-
var value = ovc.variables[currentVariableId] || [
|
|
22
|
+
var value = ovc.variables[currentVariableId] || [""];
|
|
21
23
|
var variableParents = references.relations.variables[currentVariableId].parents;
|
|
22
24
|
if (variableParents === undefined)
|
|
23
25
|
throw new Error("Variable " + currentVariableId + " parents object does not exist");
|
|
@@ -25,33 +27,38 @@ exports.getRelatedVariablesValues = function (optionId, index, variables, ovc, r
|
|
|
25
27
|
var rootVariableParentRelations = references.relations.options[rootVariableParentId];
|
|
26
28
|
if (rootVariableParentRelations === undefined)
|
|
27
29
|
throw new Error("Option " + rootVariableParentId + " does not exist");
|
|
28
|
-
if (typeof variableParents ===
|
|
30
|
+
if (typeof variableParents === "undefined")
|
|
29
31
|
return;
|
|
30
|
-
if (rootVariableParentRelations.children.options.includes(optionId) ||
|
|
32
|
+
if (rootVariableParentRelations.children.options.includes(optionId) ||
|
|
33
|
+
rootVariableParentRelations.dependants.includes(optionId) ||
|
|
34
|
+
optionId === rootVariableParentId)
|
|
31
35
|
value = [value[index]];
|
|
32
36
|
var cleanValues = value.map(function (currentValue) {
|
|
33
|
-
if ([
|
|
37
|
+
if (["number", "string"].includes(typeof currentValue))
|
|
34
38
|
return frenchNumber(currentValue);
|
|
35
|
-
return
|
|
39
|
+
return "";
|
|
36
40
|
});
|
|
37
|
-
var currentVariableValue = cleanValues.length === 1 ? cleanValues[0] : cleanValues.join(
|
|
41
|
+
var currentVariableValue = cleanValues.length === 1 ? cleanValues[0] : cleanValues.join(", ");
|
|
38
42
|
variablesValues[currentVariableId] = currentVariableValue;
|
|
39
43
|
});
|
|
40
44
|
return variablesValues;
|
|
41
45
|
};
|
|
42
|
-
exports.
|
|
46
|
+
exports.getRelatedVariablesValues = getRelatedVariablesValues;
|
|
47
|
+
var parseOutputWithVariables = function (output, index, variables, autonums) {
|
|
43
48
|
var parsedOutput = "" + output;
|
|
44
49
|
Object.keys(variables).forEach(function (variableId) {
|
|
45
50
|
var value = variables[variableId].toString();
|
|
46
51
|
if (value.trim().length === 0) {
|
|
47
|
-
value = new Array(16).join(
|
|
52
|
+
value = new Array(16).join("_");
|
|
48
53
|
}
|
|
49
|
-
value = value.replace(/\n/g,
|
|
50
|
-
parsedOutput = parsedOutput.replace(new RegExp("\\[var:" + variableId + "\\]",
|
|
54
|
+
value = value.replace(/\n/g, "<br />");
|
|
55
|
+
parsedOutput = parsedOutput.replace(new RegExp("\\[var:" + variableId + "\\]", "g"), value);
|
|
51
56
|
});
|
|
52
57
|
parsedOutput = parsedOutput.replace(/\[\[PAGE_BREAK\]\]/gi, '<div style="page-break-after:always"></div>');
|
|
53
|
-
parsedOutput = parsedOutput.replace(/\[(E|B)_BLUR\]/gi,
|
|
54
|
-
parsedOutput = parsedOutput.replace(/\[signature:([0-9]+)\]/g, function (v, signatureId) {
|
|
58
|
+
parsedOutput = parsedOutput.replace(/\[(E|B)_BLUR\]/gi, "");
|
|
59
|
+
parsedOutput = parsedOutput.replace(/\[signature:([0-9]+)\]/g, function (v, signatureId) {
|
|
60
|
+
return "<span data-signature-id=\"" + signatureId + "\" data-signer-index=\"" + index + "\"></span>";
|
|
61
|
+
});
|
|
55
62
|
autonums.forEach(function (currentAn) {
|
|
56
63
|
if (currentAn[3] === null)
|
|
57
64
|
parsedOutput = parsedOutput.replace("[" + currentAn[0] + ":" + currentAn[1] + "]", "<span class=\"" + currentAn[0] + "\">" + currentAn[2] + "</span>");
|
|
@@ -60,11 +67,12 @@ exports.parseOutputWithVariables = function (output, index, variables, autonums)
|
|
|
60
67
|
});
|
|
61
68
|
return parsedOutput;
|
|
62
69
|
};
|
|
63
|
-
exports.
|
|
70
|
+
exports.parseOutputWithVariables = parseOutputWithVariables;
|
|
71
|
+
var parseDocumentNameWithVariables = function (text, ovc, references, fallback) {
|
|
64
72
|
var tagsMatch = text.match(/\[var:([0-9]+)\]/gi);
|
|
65
73
|
var variables = [];
|
|
66
74
|
if (tagsMatch !== null) {
|
|
67
|
-
var variablesTags =
|
|
75
|
+
var variablesTags = __spreadArray([], tagsMatch, true);
|
|
68
76
|
variables = variablesTags.map(function (current) {
|
|
69
77
|
var outputVariableMatch = current.match(/([0-9]+)/);
|
|
70
78
|
if (outputVariableMatch === null)
|
|
@@ -77,7 +85,7 @@ exports.parseDocumentNameWithVariables = function (text, ovc, references, fallba
|
|
|
77
85
|
var variablesValues = {};
|
|
78
86
|
variables.forEach(function (variableId) {
|
|
79
87
|
var _a;
|
|
80
|
-
var value = ((_a = ovc.variables[variableId]) === null || _a === void 0 ? void 0 : _a[0]) ||
|
|
88
|
+
var value = ((_a = ovc.variables[variableId]) === null || _a === void 0 ? void 0 : _a[0]) || "";
|
|
81
89
|
variablesValues[variableId] = value.toString();
|
|
82
90
|
});
|
|
83
91
|
var parsedText = "" + text;
|
|
@@ -87,7 +95,8 @@ exports.parseDocumentNameWithVariables = function (text, ovc, references, fallba
|
|
|
87
95
|
parsedText = fallback;
|
|
88
96
|
if (parsedText === fallback && fallback)
|
|
89
97
|
return;
|
|
90
|
-
parsedText = parsedText.replace(new RegExp("\\[var:" + variableId + "\\]",
|
|
98
|
+
parsedText = parsedText.replace(new RegExp("\\[var:" + variableId + "\\]", "gi"), value);
|
|
91
99
|
});
|
|
92
100
|
return parsedText;
|
|
93
101
|
};
|
|
102
|
+
exports.parseDocumentNameWithVariables = parseDocumentNameWithVariables;
|