@legalplace/prerenderx 3.2.1 → 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.
Files changed (39) hide show
  1. package/.eslintrc +3 -47
  2. package/CHANGELOG.md +21 -0
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +1 -1
  5. package/dist/libs/DocumentRender.d.ts +4 -4
  6. package/dist/libs/DocumentRender.js +2 -2
  7. package/dist/libs/FillPdfForm.d.ts +1 -1
  8. package/dist/libs/FillPdfForm.js +30 -24
  9. package/dist/libs/InputsInitiator.d.ts +1 -1
  10. package/dist/libs/InputsInitiator.js +35 -11
  11. package/dist/libs/NumAuto.js +1 -1
  12. package/dist/libs/OptionRender.d.ts +4 -4
  13. package/dist/libs/OptionRender.js +30 -18
  14. package/dist/libs/OutputParser.d.ts +2 -2
  15. package/dist/libs/OutputParser.js +34 -25
  16. package/dist/libs/Prerender.d.ts +8 -8
  17. package/dist/libs/Prerender.js +29 -22
  18. package/dist/libs/SectionRender.d.ts +4 -4
  19. package/dist/libs/SectionRender.js +22 -13
  20. package/dist/libs/misc/FillPdfFormBase.d.ts +3 -3
  21. package/dist/libs/misc/FillPdfFormBase.js +25 -17
  22. package/package.json +14 -18
  23. package/src/index.ts +3 -3
  24. package/src/libs/DocumentRender.ts +27 -22
  25. package/src/libs/FillPdfForm.ts +72 -59
  26. package/src/libs/InputsInitiator.ts +91 -53
  27. package/src/libs/NumAuto.ts +16 -14
  28. package/src/libs/OptionRender.ts +85 -45
  29. package/src/libs/OutputParser.ts +112 -58
  30. package/src/libs/Prerender.ts +119 -75
  31. package/src/libs/SectionRender.ts +57 -38
  32. package/src/libs/misc/FillPdfFormBase.ts +71 -39
  33. package/src/types/types.ts +17 -14
  34. package/tsconfig.json +3 -1
  35. package/.gitlab-ci.yml +0 -43
  36. package/.prettierrc.js +0 -10
  37. package/.vscode/settings.json +0 -17
  38. package/.vscode/tasks.json +0 -24
  39. 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
- "airbnb-base",
12
- "plugin:prettier/recommended"
3
+ "@legalplace/eslint-config"
13
4
  ],
14
-
15
- "parser": "@typescript-eslint/parser",
16
5
  "parserOptions": {
17
- "project": "./tsconfig.eslint.json"
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,3 +1,24 @@
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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import Prerender from './libs/Prerender';
2
- export * from './types/types';
1
+ import Prerender from "./libs/Prerender";
2
+ export * from "./types/types";
3
3
  export default Prerender;
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
7
7
  o[k2] = m[k];
8
8
  }));
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -1,7 +1,7 @@
1
- import { Types } from '@legalplace/referencesparser';
2
- import ConditionsRunner from '@legalplace/conditions-runner';
3
- import InputsType from '@legalplace/types/dist/inputs';
4
- import NumAuto from './NumAuto';
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
  }());
@@ -1,4 +1,4 @@
1
- import FillPdfFormBase from './misc/FillPdfFormBase';
1
+ import FillPdfFormBase from "./misc/FillPdfFormBase";
2
2
  declare type FDFType = {
3
3
  id: string;
4
4
  fields: Record<string, string>;
@@ -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 (b.hasOwnProperty(p)) d[p] = b[p]; };
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 === 'undefined')
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 === '' && Object.prototype.hasOwnProperty.call(result.fields, id)))
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 'DD':
58
- return currentValue.replace(dateRegex, '$1');
59
- case 'MM':
60
- return currentValue.replace(dateRegex, '$2');
61
- case 'YYYY':
62
- return currentValue.replace(dateRegex, '$3');
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 'HH':
70
- return currentValue.replace(hourRegex, '$1');
71
- case 'MM':
72
- return currentValue.replace(hourRegex, '$2');
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 'ADDRESS':
80
- return currentValue.split('@')[0];
81
- case 'PROVIDER':
82
- return currentValue.split('@')[1];
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 && typeof variable.fragment.from === 'number' && typeof variable.fragment.to === 'number') {
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" && box.value === "Off")
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]) || '').toString();
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;
@@ -1,4 +1,4 @@
1
- import { Types } from '@legalplace/referencesparser';
1
+ import type { Types } from "@legalplace/referencesparser";
2
2
  declare type References = Types.ReferencesType;
3
3
  declare type OVC_TYPE = {
4
4
  options: {
@@ -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 === 'static') {
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 && Object.prototype.hasOwnProperty.call(this.ovc.options, optionId)) {
45
- if (['static', 'hidden', 'brut-text', 'repeated', 'box', 'separator'].includes(option.meta.type)) {
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 (['static', 'hidden', 'brut-text', 'repeated', 'box', 'separator'].includes(option.meta.type)) {
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 && Object.prototype.hasOwnProperty.call(this.ovc.variables, variableId)) {
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 && Array.isArray(prefillings) && prefillings.length > 0) {
70
- var noConditionsPrefills = prefillings.filter(function (prefill) { return typeof prefill.conditions === 'undefined' || Object.keys(prefill.conditions).length === 0; });
71
- defaultValue = noConditionsPrefills.length > 0 ? noConditionsPrefills[0].value : '';
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
  }
@@ -12,7 +12,7 @@ var NumAuto = (function () {
12
12
  _this.indexesList[index] = 0;
13
13
  }
14
14
  _this.indexesList[index] += 1;
15
- if (typeof tag === 'string')
15
+ if (typeof tag === "string")
16
16
  _this.tagsIndex[tag] = _this.indexesList[index];
17
17
  return _this.indexesList[index];
18
18
  };
@@ -1,7 +1,7 @@
1
- import { Types } from '@legalplace/referencesparser';
2
- import ConditionsRunner from '@legalplace/conditions-runner';
3
- import InputsType from '@legalplace/types/dist/inputs';
4
- import NumAuto from './NumAuto';
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 __spreadArrays = (this && this.__spreadArrays) || function () {
3
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
- r[k] = a[j];
7
- return r;
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 ? true : this.conditions.executeCondition(conditionObject, this.id, this.index, 'options');
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 === 'string' && option.meta.output.trim().length > 0) {
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] === 'numauto-pre' ? _this.NumAuto.getNumPre : _this.NumAuto.getNum;
37
- return [currentAn[0], currentAn[1], fn(currentAn[1], currentAn[2]), currentAn[2]];
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, '</$1><');
43
- output = output.replace(/\n/g, '<br />');
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 = __spreadArrays(_this.outputs, new OptionRender({
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 '@legalplace/referencesparser';
2
- import InputsType from '@legalplace/types/dist/inputs';
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 __spreadArrays = (this && this.__spreadArrays) || function () {
3
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
- r[k] = a[j];
7
- return r;
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 === 'number' ? value.toString() : 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
- exports.getRelatedVariablesValues = function (optionId, index, variables, ovc, references) {
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 === 'undefined')
30
+ if (typeof variableParents === "undefined")
29
31
  return;
30
- if (rootVariableParentRelations.children.options.includes(optionId) || rootVariableParentRelations.dependants.includes(optionId) || optionId === rootVariableParentId)
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 (['number', 'string'].includes(typeof currentValue))
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.parseOutputWithVariables = function (output, index, variables, autonums) {
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, '<br />');
50
- parsedOutput = parsedOutput.replace(new RegExp("\\[var:" + variableId + "\\]", 'g'), value);
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) { return "<span data-signature-id=\"" + signatureId + "\" data-signer-index=\"" + index + "\"></span>"; });
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.parseDocumentNameWithVariables = function (text, ovc, references, fallback) {
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 = __spreadArrays(tagsMatch);
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 + "\\]", 'gi'), value);
98
+ parsedText = parsedText.replace(new RegExp("\\[var:" + variableId + "\\]", "gi"), value);
91
99
  });
92
100
  return parsedText;
93
101
  };
102
+ exports.parseDocumentNameWithVariables = parseDocumentNameWithVariables;
@@ -1,9 +1,9 @@
1
- import { ModelV3 } from '@legalplace/models-v3-types';
2
- import OvcType from '@legalplace/types/dist/ovc';
3
- import InputsType from '@legalplace/types/dist/inputs';
4
- import type { FDFType, DocumentOutputIndex, DocumentPdfFormIndex } from "../types/types";
1
+ import type { ModelV3 } from "@legalplace/models-v3-types";
2
+ import type { Types } from "@legalplace/referencesparser";
3
+ import type OvcType from "@legalplace/types/dist/ovc";
4
+ import type InputsType from "@legalplace/types/dist/inputs";
5
+ import type { FDFType, DocumentIndex, DocumentOutputIndex, DocumentPdfFormIndex } from "../types/types";
5
6
  declare class Prerender {
6
- private model;
7
7
  private references;
8
8
  private ovc;
9
9
  private conditions;
@@ -12,9 +12,9 @@ declare class Prerender {
12
12
  private NumAuto;
13
13
  private documentsIndex;
14
14
  private renderedDocuments;
15
- constructor(model: ModelV3, ovc: InputsType | OvcType);
16
- getDocumentsIndexWithoutFdf(): Record<string, DocumentOutputIndex | DocumentPdfFormIndex>;
17
- getDocumentsIndex(): Record<string, DocumentOutputIndex | DocumentPdfFormIndex>;
15
+ constructor(model: ModelV3 | Types.ReferencesType, ovc: InputsType | OvcType);
16
+ getDocumentsIndexWithoutFdf(): DocumentIndex;
17
+ getDocumentsIndex(): DocumentIndex;
18
18
  getDocument(documentNameHash: string): string | FDFType;
19
19
  private generateDocumentNamesHash;
20
20
  private fillPdfForms;