@legalplace/prerenderx 2.3.1 → 2.3.2

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.
@@ -1,10 +1,11 @@
1
1
  import FillPdfFormBase from './misc/FillPdfFormBase';
2
+ declare type FDFType = {
3
+ id: string;
4
+ inputs: Record<string, string>;
5
+ boxes: Record<string, string>;
6
+ };
2
7
  declare class FillPdfForm extends FillPdfFormBase {
3
- fillDocument(documentName: string): {
4
- id: string;
5
- inputs: Record<string, string>;
6
- boxes: Record<string, string>;
7
- };
8
+ fillDocument(documentName: string): FDFType;
8
9
  private getInputValue;
9
10
  private getBoxValue;
10
11
  private getVariableValue;
@@ -9,8 +9,14 @@ declare type DocumentOutputIndex = {
9
9
  declare type DocumentPdfFormIndex = {
10
10
  name: string;
11
11
  form: boolean;
12
+ fdf: {
13
+ id: string;
14
+ inputs: Record<string, string>;
15
+ boxes: Record<string, string>;
16
+ };
12
17
  };
13
18
  declare type FDFType = {
19
+ id: string;
14
20
  inputs: Record<string, string>;
15
21
  boxes: Record<string, string>;
16
22
  };
@@ -28,6 +34,7 @@ declare class Prerender {
28
34
  getDocumentsIndex(): Record<string, DocumentOutputIndex | DocumentPdfFormIndex>;
29
35
  getDocument(documentNameHash: string): string | FDFType;
30
36
  private generateDocumentNamesHash;
37
+ private fillPdfForms;
31
38
  private generateAllDocuments;
32
39
  static isPdfForm(index: DocumentOutputIndex | DocumentPdfFormIndex): index is DocumentPdfFormIndex;
33
40
  static isOutput(index: DocumentOutputIndex | DocumentPdfFormIndex): index is DocumentOutputIndex;
@@ -25,6 +25,7 @@ var Prerender = (function () {
25
25
  this.pdfFiller = new FillPdfForm_1.default(this.references, this.conditions, inputs);
26
26
  this.generateDocumentNamesHash();
27
27
  this.generateAllDocuments();
28
+ this.fillPdfForms();
28
29
  }
29
30
  Prerender.prototype.getDocumentsIndex = function () {
30
31
  return this.documentsIndex;
@@ -48,7 +49,12 @@ var Prerender = (function () {
48
49
  if (typeof document.pdf === 'object' && typeof document.pdf.id === 'string' && typeof document.pdf.form === 'object') {
49
50
  _this.documentsIndex[hash] = {
50
51
  name: documentName,
51
- form: true
52
+ form: true,
53
+ fdf: {
54
+ id: '',
55
+ inputs: {},
56
+ boxes: {}
57
+ }
52
58
  };
53
59
  }
54
60
  else {
@@ -61,6 +67,15 @@ var Prerender = (function () {
61
67
  }
62
68
  });
63
69
  };
70
+ Prerender.prototype.fillPdfForms = function () {
71
+ var _this = this;
72
+ Object.keys(this.documentsIndex).forEach(function (documentNameHash) {
73
+ var index = _this.documentsIndex[documentNameHash];
74
+ if (Prerender.isPdfForm(index)) {
75
+ index.fdf = _this.getDocument(documentNameHash);
76
+ }
77
+ });
78
+ };
64
79
  Prerender.prototype.generateAllDocuments = function () {
65
80
  var _this = this;
66
81
  Object.keys(this.documentsIndex).forEach(function (documentNameHash) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/prerenderx",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "PrerenderX",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://git.legalplace.eu/legalplace/prerenderx",
@@ -1,13 +1,14 @@
1
1
  import { FDFBoxesV3, FDFInputsV3 } from '@legalplace/models-v3-types'
2
2
  import FillPdfFormBase from './misc/FillPdfFormBase'
3
3
 
4
+ type FDFType = {
5
+ id: string
6
+ inputs: Record<string, string>
7
+ boxes: Record<string, string>
8
+ }
4
9
  class FillPdfForm extends FillPdfFormBase {
5
10
  public fillDocument(documentName: string) {
6
- const result: {
7
- id: string
8
- inputs: Record<string, string>
9
- boxes: Record<string, string>
10
- } = {
11
+ const result: FDFType = {
11
12
  id: '',
12
13
  inputs: {},
13
14
  boxes: {}
@@ -17,11 +17,17 @@ type DocumentOutputIndex = {
17
17
  type DocumentPdfFormIndex = {
18
18
  name: string
19
19
  form: boolean
20
+ fdf: {
21
+ id: string
22
+ inputs: Record<string, string>
23
+ boxes: Record<string, string>
24
+ }
20
25
  }
21
26
 
22
27
  type DocumentIndex = Record<string, DocumentOutputIndex | DocumentPdfFormIndex>
23
28
 
24
29
  type FDFType = {
30
+ id: string
25
31
  inputs: Record<string, string>
26
32
  boxes: Record<string, string>
27
33
  }
@@ -71,6 +77,7 @@ class Prerender {
71
77
 
72
78
  this.generateDocumentNamesHash()
73
79
  this.generateAllDocuments()
80
+ this.fillPdfForms()
74
81
  }
75
82
 
76
83
  public getDocumentsIndex() {
@@ -99,7 +106,12 @@ class Prerender {
99
106
  if (typeof document.pdf === 'object' && typeof document.pdf.id === 'string' && typeof document.pdf.form === 'object') {
100
107
  this.documentsIndex[hash] = {
101
108
  name: documentName,
102
- form: true
109
+ form: true,
110
+ fdf: {
111
+ id: '',
112
+ inputs: {},
113
+ boxes: {}
114
+ }
103
115
  }
104
116
  } else {
105
117
  this.documentsIndex[hash] = {
@@ -112,6 +124,15 @@ class Prerender {
112
124
  })
113
125
  }
114
126
 
127
+ private fillPdfForms() {
128
+ Object.keys(this.documentsIndex).forEach(documentNameHash => {
129
+ const index = this.documentsIndex[documentNameHash]
130
+ if (Prerender.isPdfForm(index)) {
131
+ index.fdf = this.getDocument(documentNameHash) as FDFType
132
+ }
133
+ })
134
+ }
135
+
115
136
  private generateAllDocuments() {
116
137
  Object.keys(this.documentsIndex).forEach(documentNameHash => {
117
138
  const index = this.documentsIndex[documentNameHash]