@legalplace/prerenderx 2.3.0 → 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.
- package/README.md +0 -9
- package/dist/libs/FillPdfForm.d.ts +6 -5
- package/dist/libs/FillPdfForm.js +3 -1
- package/dist/libs/Prerender.d.ts +7 -0
- package/dist/libs/Prerender.js +16 -1
- package/package.json +1 -1
- package/src/libs/FillPdfForm.ts +8 -6
- package/src/libs/Prerender.ts +22 -1
package/README.md
CHANGED
|
@@ -64,12 +64,3 @@ const pdfFormsDocuments = documentsIndex.filter((documentDescription) => Prerend
|
|
|
64
64
|
// Extracting outputs documents only
|
|
65
65
|
const outputDocuments = documentsIndex.filter((documentDescription) => Prerender.isOutput(documentDescription))
|
|
66
66
|
```
|
|
67
|
-
|
|
68
|
-
Variable `documents` will now contain an object containing all documents and their respective outputs
|
|
69
|
-
```
|
|
70
|
-
{
|
|
71
|
-
'main': [..., 'some output', ...],
|
|
72
|
-
'some secondary document': [..., 'some other output', ...]
|
|
73
|
-
...
|
|
74
|
-
}
|
|
75
|
-
```
|
|
@@ -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;
|
package/dist/libs/FillPdfForm.js
CHANGED
|
@@ -41,7 +41,9 @@ var FillPdfForm = (function (_super) {
|
|
|
41
41
|
});
|
|
42
42
|
form.boxes.forEach(function (box) {
|
|
43
43
|
var id = "Page" + box.page + "[0]." + box.name;
|
|
44
|
-
|
|
44
|
+
var value = _this.getBoxValue(box);
|
|
45
|
+
if (!(value === '' && Object.prototype.hasOwnProperty.call(result.boxes, id)))
|
|
46
|
+
result.boxes[id] = value;
|
|
45
47
|
});
|
|
46
48
|
return result;
|
|
47
49
|
};
|
package/dist/libs/Prerender.d.ts
CHANGED
|
@@ -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;
|
package/dist/libs/Prerender.js
CHANGED
|
@@ -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
package/src/libs/FillPdfForm.ts
CHANGED
|
@@ -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: {}
|
|
@@ -31,7 +32,8 @@ class FillPdfForm extends FillPdfFormBase {
|
|
|
31
32
|
// Filling boxes
|
|
32
33
|
form.boxes.forEach(box => {
|
|
33
34
|
const id = `Page${box.page}[0].${box.name}`
|
|
34
|
-
|
|
35
|
+
const value = this.getBoxValue(box)
|
|
36
|
+
if (!(value === '' && Object.prototype.hasOwnProperty.call(result.boxes, id))) result.boxes[id] = value
|
|
35
37
|
})
|
|
36
38
|
|
|
37
39
|
return result
|
package/src/libs/Prerender.ts
CHANGED
|
@@ -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]
|