@legalplace/prerenderx 3.1.0 → 3.2.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 CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  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
4
 
5
+ ## [3.2.0](https://git.legalplace.eu/legalplace/prerenderx/compare/v3.1.0...v3.2.0) (2022-04-04)
6
+
7
+
8
+ ### Features
9
+
10
+ * bump conditions-runner ([7df10d2](https://git.legalplace.eu/legalplace/prerenderx/commit/7df10d2a778ed69f6cb803dc355b983e55492b8d))
11
+ * optimization of documents rendering ([f0afac8](https://git.legalplace.eu/legalplace/prerenderx/commit/f0afac8839ceb75b1415187c7970de9edf0f99ee))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * fix review ([ec04225](https://git.legalplace.eu/legalplace/prerenderx/commit/ec04225660d5a412af5ac5e351fc2916d603fb24))
17
+
5
18
  ## [3.1.0](https://git.legalplace.eu/legalplace/prerenderx/compare/v2.5.5-alpha...v3.1.0) (2021-12-16)
6
19
 
7
20
 
@@ -31,6 +31,7 @@ declare class Prerender {
31
31
  private documentsIndex;
32
32
  private renderedDocuments;
33
33
  constructor(model: ModelV3, ovc: InputsType | OvcType);
34
+ getDocumentsIndexWithoutFdf(): Record<string, DocumentOutputIndex | DocumentPdfFormIndex>;
34
35
  getDocumentsIndex(): Record<string, DocumentOutputIndex | DocumentPdfFormIndex>;
35
36
  getDocument(documentNameHash: string): string | FDFType;
36
37
  private generateDocumentNamesHash;
@@ -19,21 +19,27 @@ var Prerender = (function () {
19
19
  this.model = model;
20
20
  this.NumAuto = new NumAuto_1.default();
21
21
  this.references = new referencesparser_1.ReferencesParser(model).getReferences();
22
- this.ovc = ovc_converter_1.default.isOvc(ovc)
23
- ? ovc_converter_1.default.convertToOptionsVariables(ovc, this.references)
24
- : ovc;
22
+ this.ovc = ovc_converter_1.default.isOvc(ovc) ? ovc_converter_1.default.convertToOptionsVariables(ovc, this.references) : ovc;
25
23
  var inputs = new InputsInitiator_1.default(this.references, this.ovc).getInputs();
26
24
  this.conditions = new conditions_runner_1.default(this.references, inputs);
27
25
  this.documentRender = new DocumentRender_1.default(this.references, this.conditions, inputs, this.NumAuto);
28
26
  this.pdfFiller = new FillPdfForm_1.default(this.references, this.conditions, inputs);
29
27
  this.generateDocumentNamesHash();
30
- this.generateAllDocuments();
31
- this.fillPdfForms();
32
28
  }
29
+ Prerender.prototype.getDocumentsIndexWithoutFdf = function () {
30
+ return this.documentsIndex;
31
+ };
33
32
  Prerender.prototype.getDocumentsIndex = function () {
33
+ this.generateAllDocuments();
34
+ this.fillPdfForms();
34
35
  return this.documentsIndex;
35
36
  };
36
37
  Prerender.prototype.getDocument = function (documentNameHash) {
38
+ if (this.renderedDocuments[documentNameHash]) {
39
+ return this.renderedDocuments[documentNameHash];
40
+ }
41
+ var index = this.documentsIndex[documentNameHash];
42
+ this.renderedDocuments[documentNameHash] = Prerender.isPdfForm(index) ? this.pdfFiller.fillDocument(index.slug) : this.documentRender.renderDocument(index.slug);
37
43
  return this.renderedDocuments[documentNameHash];
38
44
  };
39
45
  Prerender.prototype.generateDocumentNamesHash = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/prerenderx",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "PrerenderX",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://git.legalplace.eu/legalplace/prerenderx",
@@ -15,7 +15,7 @@
15
15
  "release": "standard-version -a --no-verify"
16
16
  },
17
17
  "dependencies": {
18
- "@legalplace/conditions-runner": "1.1.0",
18
+ "@legalplace/conditions-runner": "1.1.7",
19
19
  "@legalplace/lplogic": "2.1.6",
20
20
  "@legalplace/models-v3-types": "3.5.1",
21
21
  "@legalplace/ovc-converter": "1.1.0",
@@ -63,9 +63,7 @@ class Prerender {
63
63
  this.references = new ReferencesParser(model).getReferences()
64
64
 
65
65
  // Converting OVC if needed
66
- this.ovc = OvcConverter.isOvc(ovc)
67
- ? OvcConverter.convertToOptionsVariables(ovc, this.references)
68
- : ovc
66
+ this.ovc = OvcConverter.isOvc(ovc) ? OvcConverter.convertToOptionsVariables(ovc, this.references) : ovc
69
67
 
70
68
  // Initiating inputs
71
69
  const inputs = new IntputsInitiator(this.references, this.ovc).getInputs()
@@ -80,15 +78,27 @@ class Prerender {
80
78
  this.pdfFiller = new FillPdfForm(this.references, this.conditions, inputs)
81
79
 
82
80
  this.generateDocumentNamesHash()
83
- this.generateAllDocuments()
84
- this.fillPdfForms()
81
+ }
82
+
83
+ public getDocumentsIndexWithoutFdf() {
84
+ return this.documentsIndex
85
85
  }
86
86
 
87
87
  public getDocumentsIndex() {
88
+ this.generateAllDocuments()
89
+ this.fillPdfForms()
88
90
  return this.documentsIndex
89
91
  }
90
92
 
91
93
  public getDocument(documentNameHash: string) {
94
+ if (this.renderedDocuments[documentNameHash]) {
95
+ return this.renderedDocuments[documentNameHash]
96
+ }
97
+
98
+ const index = this.documentsIndex[documentNameHash]
99
+
100
+ this.renderedDocuments[documentNameHash] = Prerender.isPdfForm(index) ? this.pdfFiller.fillDocument(index.slug) : this.documentRender.renderDocument(index.slug)
101
+
92
102
  return this.renderedDocuments[documentNameHash]
93
103
  }
94
104