@legalplace/prerenderx 2.3.1 → 2.3.3
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;
|
package/dist/libs/FillPdfForm.js
CHANGED
|
@@ -53,11 +53,9 @@ var FillPdfForm = (function (_super) {
|
|
|
53
53
|
var currentValue = this.getVariableValue(variable.id);
|
|
54
54
|
if (currentValue !== false) {
|
|
55
55
|
var dateRegex = /^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;
|
|
56
|
-
console.log('Value for', variable.id, currentValue, dateRegex.test(currentValue));
|
|
57
56
|
if (variable.date && dateRegex.test(currentValue)) {
|
|
58
57
|
switch (variable.date) {
|
|
59
58
|
case 'DD':
|
|
60
|
-
console.log('Value s', variable.id, input.name, currentValue.replace(dateRegex, '$1'), dateRegex.test(currentValue));
|
|
61
59
|
return currentValue.replace(dateRegex, '$1');
|
|
62
60
|
case 'MM':
|
|
63
61
|
return currentValue.replace(dateRegex, '$2');
|
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: {}
|
|
@@ -50,11 +51,9 @@ class FillPdfForm extends FillPdfFormBase {
|
|
|
50
51
|
if (currentValue !== false) {
|
|
51
52
|
// Date values
|
|
52
53
|
const dateRegex = /^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/
|
|
53
|
-
console.log('Value for', variable.id, currentValue, dateRegex.test(currentValue))
|
|
54
54
|
if (variable.date && dateRegex.test(currentValue)) {
|
|
55
55
|
switch (variable.date) {
|
|
56
56
|
case 'DD':
|
|
57
|
-
console.log('Value s', variable.id, input.name, currentValue.replace(dateRegex, '$1'), dateRegex.test(currentValue))
|
|
58
57
|
return currentValue.replace(dateRegex, '$1')
|
|
59
58
|
case 'MM':
|
|
60
59
|
return currentValue.replace(dateRegex, '$2')
|
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]
|