@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/dist/libs/Prerender.d.ts
CHANGED
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
import { ModelV3 } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
slug: string;
|
|
7
|
-
pdf: boolean;
|
|
8
|
-
docx: boolean;
|
|
9
|
-
};
|
|
10
|
-
declare type DocumentPdfFormIndex = {
|
|
11
|
-
name: string;
|
|
12
|
-
slug: string;
|
|
13
|
-
form: boolean;
|
|
14
|
-
fdf: {
|
|
15
|
-
id: string;
|
|
16
|
-
fields: Record<string, string>;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
declare type FDFType = {
|
|
20
|
-
id: string;
|
|
21
|
-
fields: Record<string, string>;
|
|
22
|
-
};
|
|
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";
|
|
23
6
|
declare class Prerender {
|
|
24
|
-
private model;
|
|
25
7
|
private references;
|
|
26
8
|
private ovc;
|
|
27
9
|
private conditions;
|
|
@@ -30,9 +12,9 @@ declare class Prerender {
|
|
|
30
12
|
private NumAuto;
|
|
31
13
|
private documentsIndex;
|
|
32
14
|
private renderedDocuments;
|
|
33
|
-
constructor(model: ModelV3, ovc: InputsType | OvcType);
|
|
34
|
-
getDocumentsIndexWithoutFdf():
|
|
35
|
-
getDocumentsIndex():
|
|
15
|
+
constructor(model: ModelV3 | Types.ReferencesType, ovc: InputsType | OvcType);
|
|
16
|
+
getDocumentsIndexWithoutFdf(): DocumentIndex;
|
|
17
|
+
getDocumentsIndex(): DocumentIndex;
|
|
36
18
|
getDocument(documentNameHash: string): string | FDFType;
|
|
37
19
|
private generateDocumentNamesHash;
|
|
38
20
|
private fillPdfForms;
|
package/dist/libs/Prerender.js
CHANGED
|
@@ -16,10 +16,13 @@ var Prerender = (function () {
|
|
|
16
16
|
function Prerender(model, ovc) {
|
|
17
17
|
this.documentsIndex = {};
|
|
18
18
|
this.renderedDocuments = {};
|
|
19
|
-
this.model = model;
|
|
20
19
|
this.NumAuto = new NumAuto_1.default();
|
|
21
|
-
this.references =
|
|
22
|
-
|
|
20
|
+
this.references = referencesparser_1.ReferencesParser.isReferences(model)
|
|
21
|
+
? model
|
|
22
|
+
: new referencesparser_1.ReferencesParser(model).getReferences();
|
|
23
|
+
this.ovc = ovc_converter_1.default.isOvc(ovc)
|
|
24
|
+
? ovc_converter_1.default.convertToOptionsVariables(ovc, this.references)
|
|
25
|
+
: ovc;
|
|
23
26
|
var inputs = new InputsInitiator_1.default(this.references, this.ovc).getInputs();
|
|
24
27
|
this.conditions = new conditions_runner_1.default(this.references, inputs);
|
|
25
28
|
this.documentRender = new DocumentRender_1.default(this.references, this.conditions, inputs, this.NumAuto);
|
|
@@ -39,39 +42,42 @@ var Prerender = (function () {
|
|
|
39
42
|
return this.renderedDocuments[documentNameHash];
|
|
40
43
|
}
|
|
41
44
|
var index = this.documentsIndex[documentNameHash];
|
|
42
|
-
this.renderedDocuments[documentNameHash] = Prerender.isPdfForm(index)
|
|
45
|
+
this.renderedDocuments[documentNameHash] = Prerender.isPdfForm(index)
|
|
46
|
+
? this.pdfFiller.fillDocument(index.slug)
|
|
47
|
+
: this.documentRender.renderDocument(index.slug);
|
|
43
48
|
return this.renderedDocuments[documentNameHash];
|
|
44
49
|
};
|
|
45
50
|
Prerender.prototype.generateDocumentNamesHash = function () {
|
|
46
51
|
var _this = this;
|
|
47
|
-
Object.keys(this.
|
|
52
|
+
Object.keys(this.references.documents).forEach(function (slug) {
|
|
48
53
|
var _a, _b;
|
|
49
|
-
var document = _this.
|
|
50
|
-
var documentParams = _this.
|
|
54
|
+
var document = _this.references.documents[slug];
|
|
55
|
+
var documentParams = _this.references.documents[slug].params;
|
|
51
56
|
var conditionObject = _this.references.conditions.documents[slug];
|
|
52
|
-
var condition = conditionObject === undefined
|
|
57
|
+
var condition = conditionObject === undefined
|
|
58
|
+
? true
|
|
59
|
+
: _this.conditions.executeCondition(conditionObject, 0, 0, "documents");
|
|
53
60
|
if (condition === true) {
|
|
54
|
-
var hash = crypto_1.default
|
|
55
|
-
|
|
56
|
-
.
|
|
57
|
-
.
|
|
58
|
-
if (typeof document.pdf === 'object' && typeof document.pdf.id === 'string' && typeof document.pdf.form === 'object') {
|
|
61
|
+
var hash = crypto_1.default.createHash("sha1").update(slug).digest("hex");
|
|
62
|
+
if (typeof document.pdf === "object" &&
|
|
63
|
+
typeof document.pdf.id === "string" &&
|
|
64
|
+
typeof document.pdf.form === "object") {
|
|
59
65
|
_this.documentsIndex[hash] = {
|
|
60
|
-
name: OutputParser_1.parseDocumentNameWithVariables(document.name, _this.ovc, _this.references, document.fallbackName),
|
|
66
|
+
name: (0, OutputParser_1.parseDocumentNameWithVariables)(document.name, _this.ovc, _this.references, document.fallbackName),
|
|
61
67
|
slug: slug,
|
|
62
68
|
form: true,
|
|
63
69
|
fdf: {
|
|
64
|
-
id:
|
|
65
|
-
fields: {}
|
|
66
|
-
}
|
|
70
|
+
id: "",
|
|
71
|
+
fields: {},
|
|
72
|
+
},
|
|
67
73
|
};
|
|
68
74
|
}
|
|
69
75
|
else {
|
|
70
76
|
_this.documentsIndex[hash] = {
|
|
71
|
-
name: OutputParser_1.parseDocumentNameWithVariables(document.name, _this.ovc, _this.references, document.fallbackName),
|
|
77
|
+
name: (0, OutputParser_1.parseDocumentNameWithVariables)(document.name, _this.ovc, _this.references, document.fallbackName),
|
|
72
78
|
slug: slug,
|
|
73
|
-
pdf: ((_a = documentParams === null || documentParams === void 0 ? void 0 : documentParams.formats) === null || _a === void 0 ? void 0 : _a.pdf)
|
|
74
|
-
docx: ((_b = documentParams === null || documentParams === void 0 ? void 0 : documentParams.formats) === null || _b === void 0 ? void 0 : _b.docx)
|
|
79
|
+
pdf: ((_a = documentParams === null || documentParams === void 0 ? void 0 : documentParams.formats) === null || _a === void 0 ? void 0 : _a.pdf) !== false,
|
|
80
|
+
docx: ((_b = documentParams === null || documentParams === void 0 ? void 0 : documentParams.formats) === null || _b === void 0 ? void 0 : _b.docx) !== false,
|
|
75
81
|
};
|
|
76
82
|
}
|
|
77
83
|
}
|
|
@@ -94,15 +100,16 @@ var Prerender = (function () {
|
|
|
94
100
|
_this.renderedDocuments[documentNameHash] = _this.pdfFiller.fillDocument(_this.documentsIndex[documentNameHash].slug);
|
|
95
101
|
}
|
|
96
102
|
else {
|
|
97
|
-
_this.renderedDocuments[documentNameHash] =
|
|
103
|
+
_this.renderedDocuments[documentNameHash] =
|
|
104
|
+
_this.documentRender.renderDocument(_this.documentsIndex[documentNameHash].slug);
|
|
98
105
|
}
|
|
99
106
|
});
|
|
100
107
|
};
|
|
101
108
|
Prerender.isPdfForm = function (index) {
|
|
102
|
-
return Object.prototype.hasOwnProperty.call(index,
|
|
109
|
+
return Object.prototype.hasOwnProperty.call(index, "form");
|
|
103
110
|
};
|
|
104
111
|
Prerender.isOutput = function (index) {
|
|
105
|
-
return !Object.prototype.hasOwnProperty.call(index,
|
|
112
|
+
return !Object.prototype.hasOwnProperty.call(index, "form");
|
|
106
113
|
};
|
|
107
114
|
return Prerender;
|
|
108
115
|
}());
|
|
@@ -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 SectionRender {
|
|
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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -29,28 +31,35 @@ var SectionRender = (function () {
|
|
|
29
31
|
var _this = this;
|
|
30
32
|
var section = this.references.sections[this.documentName][this.currentSection];
|
|
31
33
|
var conditionObject = this.references.conditions.sections[this.documentName][this.currentSection];
|
|
32
|
-
var condition = conditionObject === undefined
|
|
34
|
+
var condition = conditionObject === undefined
|
|
35
|
+
? true
|
|
36
|
+
: this.conditions.executeCondition(conditionObject, 0, 0, "sections");
|
|
33
37
|
if (condition === true) {
|
|
34
38
|
section.options.forEach(function (optionId) {
|
|
35
39
|
var option = _this.references.options[optionId];
|
|
36
40
|
var repeatOption = optionId;
|
|
37
|
-
if (option.meta.type ===
|
|
41
|
+
if (option.meta.type === "repeated") {
|
|
38
42
|
if (option.meta.repeatOption === undefined)
|
|
39
43
|
return;
|
|
40
|
-
repeatOption =
|
|
44
|
+
repeatOption =
|
|
45
|
+
typeof option.meta.repeatOption === "number"
|
|
46
|
+
? option.meta.repeatOption
|
|
47
|
+
: parseInt(option.meta.repeatOption, 10);
|
|
41
48
|
}
|
|
42
|
-
var inputs = _this.ovc.options[repeatOption] || [
|
|
49
|
+
var inputs = _this.ovc.options[repeatOption] || [
|
|
50
|
+
!["radio", "checkbox"].includes(option.meta.type),
|
|
51
|
+
];
|
|
43
52
|
inputs.forEach(function (value, index) {
|
|
44
53
|
if (value !== true)
|
|
45
54
|
return;
|
|
46
|
-
_this.outputs =
|
|
55
|
+
_this.outputs = __spreadArray(__spreadArray([], _this.outputs, true), new OptionRender_1.default({
|
|
47
56
|
references: _this.references,
|
|
48
57
|
id: optionId,
|
|
49
58
|
ovc: _this.ovc,
|
|
50
59
|
index: index,
|
|
51
60
|
conditions: _this.conditions,
|
|
52
|
-
numauto: _this.NumAuto
|
|
53
|
-
}).getOutputs());
|
|
61
|
+
numauto: _this.NumAuto,
|
|
62
|
+
}).getOutputs(), true);
|
|
54
63
|
});
|
|
55
64
|
});
|
|
56
65
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Types } from
|
|
2
|
-
import ConditionsRunner from
|
|
3
|
-
import InputsType 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
4
|
declare class FillPdfFormBase {
|
|
5
5
|
references: Types.ReferencesType;
|
|
6
6
|
conditions: ConditionsRunner;
|
|
@@ -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 FillPdfFormBase = (function () {
|
|
@@ -18,34 +20,40 @@ var FillPdfFormBase = (function () {
|
|
|
18
20
|
var variableCondition = this.getVariableCondition(id, index);
|
|
19
21
|
var variableParents = ((_a = this.references.relations.variables[id]) === null || _a === void 0 ? void 0 : _a.parents) || [];
|
|
20
22
|
var parentOptionIsDisplayed = this.isOptionDisplayed(variableParents[0], index);
|
|
21
|
-
return [variableCondition, parentOptionIsDisplayed].filter(function (c) { return c !== true; })
|
|
23
|
+
return ([variableCondition, parentOptionIsDisplayed].filter(function (c) { return c !== true; })
|
|
24
|
+
.length === 0);
|
|
22
25
|
};
|
|
23
26
|
FillPdfFormBase.prototype.isOptionDisplayed = function (id, index) {
|
|
24
27
|
var _this = this;
|
|
25
28
|
var _a;
|
|
26
29
|
var optionCondition = this.getOptionCondition(id, index);
|
|
27
30
|
var optionParents = ((_a = this.references.relations.options[id]) === null || _a === void 0 ? void 0 : _a.parents) || [];
|
|
28
|
-
var parentsConditions = optionParents.map(function (optionId) {
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
var parentsInputs = optionParents.map(function (optionId) {
|
|
32
|
-
return _this.ovc.options[optionId][index];
|
|
33
|
-
});
|
|
31
|
+
var parentsConditions = optionParents.map(function (optionId) { return _this.getOptionCondition(optionId, index) !== false; });
|
|
32
|
+
var parentsInputs = optionParents.map(function (optionId) { return _this.ovc.options[optionId][index]; });
|
|
34
33
|
var parentSectionId = this.getOptionParentSection(id);
|
|
35
34
|
var parentSectionCondition = this.getSectionCondition(parentSectionId) !== false;
|
|
36
|
-
return
|
|
35
|
+
return (__spreadArray(__spreadArray([
|
|
36
|
+
optionCondition,
|
|
37
|
+
parentSectionCondition
|
|
38
|
+
], parentsConditions, true), parentsInputs, true).filter(function (c) { return c !== true; }).length === 0);
|
|
37
39
|
};
|
|
38
40
|
FillPdfFormBase.prototype.getVariableCondition = function (id, index) {
|
|
39
41
|
var conditionObject = this.references.conditions.variables[id];
|
|
40
|
-
return conditionObject === undefined
|
|
42
|
+
return conditionObject === undefined
|
|
43
|
+
? true
|
|
44
|
+
: this.conditions.executeCondition(conditionObject, id, index, "variables");
|
|
41
45
|
};
|
|
42
46
|
FillPdfFormBase.prototype.getOptionCondition = function (id, index) {
|
|
43
47
|
var conditionObject = this.references.conditions.options[id];
|
|
44
|
-
return conditionObject === undefined
|
|
48
|
+
return conditionObject === undefined
|
|
49
|
+
? true
|
|
50
|
+
: this.conditions.executeCondition(conditionObject, id, index, "options");
|
|
45
51
|
};
|
|
46
52
|
FillPdfFormBase.prototype.getSectionCondition = function (id) {
|
|
47
53
|
var conditionObject = this.references.conditions.sections.main[id];
|
|
48
|
-
return conditionObject === undefined
|
|
54
|
+
return conditionObject === undefined
|
|
55
|
+
? true
|
|
56
|
+
: this.conditions.executeCondition(conditionObject, id, 0, "sections");
|
|
49
57
|
};
|
|
50
58
|
FillPdfFormBase.prototype.getOptionParentSection = function (id) {
|
|
51
59
|
var parents = this.references.relations.options[id].parents;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare type DocumentOutputIndex = {
|
|
2
|
+
name: string;
|
|
3
|
+
slug: string;
|
|
4
|
+
pdf: boolean;
|
|
5
|
+
docx: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare type DocumentPdfFormIndex = {
|
|
8
|
+
name: string;
|
|
9
|
+
slug: string;
|
|
10
|
+
form: boolean;
|
|
11
|
+
fdf: FDFType;
|
|
12
|
+
};
|
|
13
|
+
export declare type DocumentIndex = Record<string, DocumentOutputIndex | DocumentPdfFormIndex>;
|
|
14
|
+
export declare type FDFType = {
|
|
15
|
+
id: string;
|
|
16
|
+
fields: Record<string, string>;
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/prerenderx",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "PrerenderX",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": "https://git.legalplace.eu/legalplace/prerenderx",
|
|
@@ -12,35 +12,31 @@
|
|
|
12
12
|
"lint:fix": "tsc && eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
|
|
13
13
|
"test": "jest",
|
|
14
14
|
"build": "tsc",
|
|
15
|
+
"build:ci": "tsc",
|
|
15
16
|
"release": "standard-version -a --no-verify"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
|
-
"@legalplace/conditions-runner": "
|
|
19
|
+
"@legalplace/conditions-runner": "^2.0.3",
|
|
20
|
+
"@legalplace/eslint-config-base": "^1.1.1",
|
|
19
21
|
"@legalplace/lplogic": "2.1.6",
|
|
20
|
-
"@legalplace/models-v3-types": "
|
|
21
|
-
"@legalplace/ovc-converter": "
|
|
22
|
-
"@legalplace/
|
|
22
|
+
"@legalplace/models-v3-types": "^5.1.16",
|
|
23
|
+
"@legalplace/ovc-converter": "^2.0.3",
|
|
24
|
+
"@legalplace/prettier-config": "^2.1.3",
|
|
25
|
+
"@legalplace/referencesparser": "^3.0.3",
|
|
23
26
|
"crypto": "^1.0.1",
|
|
24
27
|
"standard-version": "^9.3.1",
|
|
25
|
-
"typescript": "
|
|
28
|
+
"typescript": "4.4.3"
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
28
31
|
"@babel/core": "^7.7.2",
|
|
29
32
|
"@babel/preset-typescript": "^7.7.2",
|
|
30
|
-
"@legalplace/types": "
|
|
33
|
+
"@legalplace/types": "^2.0.17",
|
|
31
34
|
"@types/jest": "^24.0.15",
|
|
32
|
-
"@types/node": "^
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^2.6.1",
|
|
34
|
-
"@typescript-eslint/parser": "^2.6.1",
|
|
35
|
-
"airbnb-standard": "^1.0.0",
|
|
36
|
-
"eslint": "^6.6.0",
|
|
37
|
-
"eslint-config-airbnb-base": "^14.0.0",
|
|
38
|
-
"eslint-config-prettier": "^6.5.0",
|
|
39
|
-
"eslint-plugin-import": "^2.18.2",
|
|
40
|
-
"eslint-plugin-prettier": "^3.1.1",
|
|
35
|
+
"@types/node": "^20.8.10",
|
|
41
36
|
"jest": "^24.8.0",
|
|
42
|
-
"prettier": "1.19.1",
|
|
43
37
|
"redux-mock-store": "^1.5.3",
|
|
44
38
|
"ts-jest": "^24.0.2"
|
|
45
|
-
}
|
|
39
|
+
},
|
|
40
|
+
"prettier": "@legalplace/prettier-config",
|
|
41
|
+
"gitHead": "51ad188d81ea4168bcd0f5922f1b19d730deacfe"
|
|
46
42
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
import { Types } from
|
|
2
|
-
import ConditionsRunner from
|
|
3
|
-
import InputsType from
|
|
4
|
-
import SectionRender from
|
|
5
|
-
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 SectionRender from "./SectionRender";
|
|
5
|
+
import type NumAuto from "./NumAuto";
|
|
6
6
|
|
|
7
7
|
class DocumentRender {
|
|
8
|
-
references: Types.ReferencesType
|
|
8
|
+
references: Types.ReferencesType;
|
|
9
9
|
|
|
10
|
-
conditions: ConditionsRunner
|
|
10
|
+
conditions: ConditionsRunner;
|
|
11
11
|
|
|
12
|
-
ovc: InputsType
|
|
12
|
+
ovc: InputsType;
|
|
13
13
|
|
|
14
|
-
private NumAuto: NumAuto
|
|
14
|
+
private NumAuto: NumAuto;
|
|
15
15
|
|
|
16
|
-
constructor(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
constructor(
|
|
17
|
+
references: Types.ReferencesType,
|
|
18
|
+
conditions: ConditionsRunner,
|
|
19
|
+
ovc: InputsType,
|
|
20
|
+
numauto: NumAuto
|
|
21
|
+
) {
|
|
22
|
+
this.references = references;
|
|
23
|
+
this.conditions = conditions;
|
|
24
|
+
this.ovc = ovc;
|
|
25
|
+
this.NumAuto = numauto;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
public renderDocument(documentName: string) {
|
|
24
|
-
const documentOutputs: string[] = []
|
|
25
|
-
this.NumAuto.resetIndexes()
|
|
26
|
-
Object.keys(this.references.sections[documentName]).forEach(sectionId => {
|
|
29
|
+
const documentOutputs: string[] = [];
|
|
30
|
+
this.NumAuto.resetIndexes();
|
|
31
|
+
Object.keys(this.references.sections[documentName]).forEach((sectionId) => {
|
|
27
32
|
documentOutputs.push(
|
|
28
33
|
...new SectionRender({
|
|
29
34
|
references: this.references,
|
|
@@ -31,13 +36,13 @@ class DocumentRender {
|
|
|
31
36
|
documentName,
|
|
32
37
|
ovc: this.ovc,
|
|
33
38
|
currentSection: parseInt(sectionId, 10),
|
|
34
|
-
numauto: this.NumAuto
|
|
39
|
+
numauto: this.NumAuto,
|
|
35
40
|
}).getOutputs()
|
|
36
|
-
)
|
|
37
|
-
})
|
|
41
|
+
);
|
|
42
|
+
});
|
|
38
43
|
|
|
39
|
-
return documentOutputs.join(
|
|
44
|
+
return documentOutputs.join("");
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
export default DocumentRender
|
|
48
|
+
export default DocumentRender;
|