@legalplace/prerenderx 3.1.0 → 3.2.1

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,26 @@
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.1](https://git.legalplace.eu/legalplace/prerenderx/compare/v3.2.0...v3.2.1) (2022-12-07)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * 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))
11
+
12
+ ## [3.2.0](https://git.legalplace.eu/legalplace/prerenderx/compare/v3.1.0...v3.2.0) (2022-04-04)
13
+
14
+
15
+ ### Features
16
+
17
+ * bump conditions-runner ([7df10d2](https://git.legalplace.eu/legalplace/prerenderx/commit/7df10d2a778ed69f6cb803dc355b983e55492b8d))
18
+ * optimization of documents rendering ([f0afac8](https://git.legalplace.eu/legalplace/prerenderx/commit/f0afac8839ceb75b1415187c7970de9edf0f99ee))
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * fix review ([ec04225](https://git.legalplace.eu/legalplace/prerenderx/commit/ec04225660d5a412af5ac5e351fc2916d603fb24))
24
+
5
25
  ## [3.1.0](https://git.legalplace.eu/legalplace/prerenderx/compare/v2.5.5-alpha...v3.1.0) (2021-12-16)
6
26
 
7
27
 
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import Prerender from './libs/Prerender';
2
+ export * from './types/types';
2
3
  export default Prerender;
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" && !exports.hasOwnProperty(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,25 +1,7 @@
1
1
  import { ModelV3 } from '@legalplace/models-v3-types';
2
2
  import OvcType from '@legalplace/types/dist/ovc';
3
3
  import InputsType from '@legalplace/types/dist/inputs';
4
- declare type DocumentOutputIndex = {
5
- name: string;
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
- };
4
+ import type { FDFType, DocumentOutputIndex, DocumentPdfFormIndex } from "../types/types";
23
5
  declare class Prerender {
24
6
  private model;
25
7
  private references;
@@ -31,6 +13,7 @@ declare class Prerender {
31
13
  private documentsIndex;
32
14
  private renderedDocuments;
33
15
  constructor(model: ModelV3, ovc: InputsType | OvcType);
16
+ getDocumentsIndexWithoutFdf(): Record<string, DocumentOutputIndex | DocumentPdfFormIndex>;
34
17
  getDocumentsIndex(): Record<string, DocumentOutputIndex | DocumentPdfFormIndex>;
35
18
  getDocument(documentNameHash: string): string | FDFType;
36
19
  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 () {
@@ -64,8 +70,8 @@ var Prerender = (function () {
64
70
  _this.documentsIndex[hash] = {
65
71
  name: OutputParser_1.parseDocumentNameWithVariables(document.name, _this.ovc, _this.references, document.fallbackName),
66
72
  slug: slug,
67
- pdf: ((_a = documentParams === null || documentParams === void 0 ? void 0 : documentParams.formats) === null || _a === void 0 ? void 0 : _a.pdf) === undefined ? true : documentParams.formats.pdf,
68
- docx: ((_b = documentParams === null || documentParams === void 0 ? void 0 : documentParams.formats) === null || _b === void 0 ? void 0 : _b.docx) === undefined ? true : documentParams.formats.docx
73
+ pdf: ((_a = documentParams === null || documentParams === void 0 ? void 0 : documentParams.formats) === null || _a === void 0 ? void 0 : _a.pdf) !== false,
74
+ docx: ((_b = documentParams === null || documentParams === void 0 ? void 0 : documentParams.formats) === null || _b === void 0 ? void 0 : _b.docx) !== false
69
75
  };
70
76
  }
71
77
  }
@@ -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
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/prerenderx",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
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",
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import Prerender from './libs/Prerender'
2
2
 
3
+ export * from './types/types'
4
+
3
5
  export default Prerender
@@ -10,29 +10,7 @@ import NumAuto from './NumAuto'
10
10
  import IntputsInitiator from './InputsInitiator'
11
11
  import FillPdfForm from './FillPdfForm'
12
12
  import { parseDocumentNameWithVariables } from './OutputParser'
13
-
14
- type DocumentOutputIndex = {
15
- name: string
16
- slug: string
17
- pdf: boolean
18
- docx: boolean
19
- }
20
- type DocumentPdfFormIndex = {
21
- name: string
22
- slug: string
23
- form: boolean
24
- fdf: {
25
- id: string
26
- fields: Record<string, string>
27
- }
28
- }
29
-
30
- type DocumentIndex = Record<string, DocumentOutputIndex | DocumentPdfFormIndex>
31
-
32
- type FDFType = {
33
- id: string
34
- fields: Record<string, string>
35
- }
13
+ import type { FDFType, DocumentIndex, DocumentOutputIndex, DocumentPdfFormIndex } from "../types/types"
36
14
 
37
15
  class Prerender {
38
16
  private model: ModelV3
@@ -63,9 +41,7 @@ class Prerender {
63
41
  this.references = new ReferencesParser(model).getReferences()
64
42
 
65
43
  // Converting OVC if needed
66
- this.ovc = OvcConverter.isOvc(ovc)
67
- ? OvcConverter.convertToOptionsVariables(ovc, this.references)
68
- : ovc
44
+ this.ovc = OvcConverter.isOvc(ovc) ? OvcConverter.convertToOptionsVariables(ovc, this.references) : ovc
69
45
 
70
46
  // Initiating inputs
71
47
  const inputs = new IntputsInitiator(this.references, this.ovc).getInputs()
@@ -80,15 +56,27 @@ class Prerender {
80
56
  this.pdfFiller = new FillPdfForm(this.references, this.conditions, inputs)
81
57
 
82
58
  this.generateDocumentNamesHash()
83
- this.generateAllDocuments()
84
- this.fillPdfForms()
59
+ }
60
+
61
+ public getDocumentsIndexWithoutFdf() {
62
+ return this.documentsIndex
85
63
  }
86
64
 
87
65
  public getDocumentsIndex() {
66
+ this.generateAllDocuments()
67
+ this.fillPdfForms()
88
68
  return this.documentsIndex
89
69
  }
90
70
 
91
71
  public getDocument(documentNameHash: string) {
72
+ if (this.renderedDocuments[documentNameHash]) {
73
+ return this.renderedDocuments[documentNameHash]
74
+ }
75
+
76
+ const index = this.documentsIndex[documentNameHash]
77
+
78
+ this.renderedDocuments[documentNameHash] = Prerender.isPdfForm(index) ? this.pdfFiller.fillDocument(index.slug) : this.documentRender.renderDocument(index.slug)
79
+
92
80
  return this.renderedDocuments[documentNameHash]
93
81
  }
94
82
 
@@ -121,8 +109,8 @@ class Prerender {
121
109
  this.documentsIndex[hash] = {
122
110
  name: parseDocumentNameWithVariables(document.name, this.ovc, this.references, document.fallbackName),
123
111
  slug,
124
- pdf: documentParams?.formats?.pdf === undefined ? true : documentParams.formats.pdf,
125
- docx: documentParams?.formats?.docx === undefined ? true : documentParams.formats.docx
112
+ pdf: documentParams?.formats?.pdf !== false,
113
+ docx: documentParams?.formats?.docx !== false
126
114
  }
127
115
  }
128
116
  }
@@ -0,0 +1,19 @@
1
+ export type DocumentOutputIndex = {
2
+ name: string
3
+ slug: string
4
+ pdf: boolean
5
+ docx: boolean
6
+ }
7
+ export type DocumentPdfFormIndex = {
8
+ name: string
9
+ slug: string
10
+ form: boolean
11
+ fdf: FDFType
12
+ }
13
+
14
+ export type DocumentIndex = Record<string, DocumentOutputIndex | DocumentPdfFormIndex>
15
+
16
+ export type FDFType = {
17
+ id: string
18
+ fields: Record<string, string>
19
+ }