@legalplace/prerenderx 2.6.3 → 3.0.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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -0
- package/dist/libs/ConditionsRunner.d.ts +24 -0
- package/dist/libs/ConditionsRunner.js +69 -0
- package/dist/libs/DataPopulator.d.ts +53 -0
- package/dist/libs/DataPopulator.js +175 -0
- package/dist/libs/DocumentRender.d.ts +13 -0
- package/dist/libs/DocumentRender.js +32 -0
- package/dist/libs/FillPdfForm.d.ts +13 -0
- package/dist/libs/FillPdfForm.js +121 -0
- package/dist/libs/InputsInitiator.d.ts +21 -0
- package/dist/libs/InputsInitiator.js +80 -0
- package/dist/libs/NumAuto.d.ts +8 -0
- package/dist/libs/NumAuto.js +32 -0
- package/dist/libs/OptionRender.d.ts +25 -0
- package/dist/libs/OptionRender.js +66 -0
- package/dist/libs/OutputParser.d.ts +11 -0
- package/dist/libs/OutputParser.js +93 -0
- package/dist/libs/OvcConverter.d.ts +21 -0
- package/dist/libs/OvcConverter.js +132 -0
- package/dist/libs/Prerender.d.ts +42 -0
- package/dist/libs/Prerender.js +103 -0
- package/dist/libs/SectionRender.d.ts +24 -0
- package/dist/libs/SectionRender.js +60 -0
- package/dist/libs/misc/FillPdfFormBase.d.ts +16 -0
- package/dist/libs/misc/FillPdfFormBase.js +62 -0
- package/dist/libs/ovc.type.d.ts +9 -0
- package/dist/libs/ovc.type.js +2 -0
- package/package.json +4 -4
- package/src/libs/ConditionsRunner.ts +1 -34
- package/src/libs/Prerender.ts +13 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/prerenderx",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "PrerenderX",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": "https://git.legalplace.eu/legalplace/prerenderx",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"release": "standard-version -a --no-verify"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@legalplace/lplogic": "
|
|
19
|
-
"@legalplace/models-v3-types": "
|
|
20
|
-
"@legalplace/referencesparser": "
|
|
18
|
+
"@legalplace/lplogic": "2.1.6",
|
|
19
|
+
"@legalplace/models-v3-types": "3.5.1",
|
|
20
|
+
"@legalplace/referencesparser": "1.6.3",
|
|
21
21
|
"crypto": "^1.0.1",
|
|
22
22
|
"standard-version": "^9.3.1",
|
|
23
23
|
"typescript": "3.9.3"
|
|
@@ -22,29 +22,6 @@ const conditionsCache: {
|
|
|
22
22
|
[key: string]: boolean
|
|
23
23
|
} = {}
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
* Generates cache key
|
|
27
|
-
* @param condition
|
|
28
|
-
* @param id
|
|
29
|
-
* @param index
|
|
30
|
-
* @param conditionType
|
|
31
|
-
* @returns string
|
|
32
|
-
*/
|
|
33
|
-
const createConditionCacheKey = (
|
|
34
|
-
condition: {
|
|
35
|
-
dataMap: ConditionDataMap
|
|
36
|
-
conditions: ConditionV3
|
|
37
|
-
},
|
|
38
|
-
id: number,
|
|
39
|
-
index: number,
|
|
40
|
-
conditionType: 'options' | 'optionValidator' | 'variables' | 'prefillers' | 'variableValidator' | 'sections' | 'documents'
|
|
41
|
-
) => {
|
|
42
|
-
const conditionString = JSON.stringify(condition);
|
|
43
|
-
|
|
44
|
-
return `${id}-${index}-${conditionType}-${conditionString}`
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
25
|
class ConditionsRunner {
|
|
49
26
|
private references: Types.ReferencesType
|
|
50
27
|
|
|
@@ -122,13 +99,6 @@ class ConditionsRunner {
|
|
|
122
99
|
// In case we have multiple conditions let's run them here
|
|
123
100
|
if (Array.isArray(condition)) return condition.map(_condition => this.executeCondition(_condition, id, index, conditionType))
|
|
124
101
|
|
|
125
|
-
// Generating cache key
|
|
126
|
-
const cacheKey = createConditionCacheKey(condition, id, index, conditionType)
|
|
127
|
-
|
|
128
|
-
// Checking if condition was already calculated
|
|
129
|
-
if (Object.prototype.hasOwnProperty.call(conditionsCache, cacheKey))
|
|
130
|
-
return conditionsCache[cacheKey]
|
|
131
|
-
|
|
132
102
|
// Populating Data
|
|
133
103
|
let currentData
|
|
134
104
|
if (conditionType === 'options' || conditionType === 'optionValidator') {
|
|
@@ -140,11 +110,8 @@ class ConditionsRunner {
|
|
|
140
110
|
currentData = new DataPopulator(this, this.references, this.ovc, condition.dataMap, id, index).getData()
|
|
141
111
|
}
|
|
142
112
|
|
|
143
|
-
// Running condition and storing it in cache
|
|
144
|
-
conditionsCache[cacheKey] = LpLogic(condition.conditions, currentData);
|
|
145
|
-
|
|
146
113
|
// Returning cache result
|
|
147
|
-
return
|
|
114
|
+
return LpLogic(condition.conditions, currentData)
|
|
148
115
|
}
|
|
149
116
|
}
|
|
150
117
|
|
package/src/libs/Prerender.ts
CHANGED
|
@@ -34,6 +34,8 @@ type FDFType = {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
class Prerender {
|
|
37
|
+
private model: ModelV3
|
|
38
|
+
|
|
37
39
|
private references: Types.ReferencesType
|
|
38
40
|
|
|
39
41
|
private ovc: OVC_TYPE
|
|
@@ -50,20 +52,19 @@ class Prerender {
|
|
|
50
52
|
|
|
51
53
|
private renderedDocuments: Record<string, string | FDFType> = {}
|
|
52
54
|
|
|
53
|
-
constructor(
|
|
54
|
-
|
|
55
|
-
if (ReferencesParser.isReferences(entry)) {
|
|
56
|
-
this.references = entry
|
|
57
|
-
} else {
|
|
58
|
-
// Parsing references
|
|
59
|
-
this.references = new ReferencesParser(entry).getReferences()
|
|
60
|
-
}
|
|
55
|
+
constructor(model: ModelV3, ovc: OVC_TYPE | OldOVC) {
|
|
56
|
+
this.model = model
|
|
61
57
|
|
|
62
58
|
// Initiating num auto
|
|
63
59
|
this.NumAuto = new NumAuto()
|
|
64
60
|
|
|
61
|
+
// Parsing references
|
|
62
|
+
this.references = new ReferencesParser(model).getReferences()
|
|
63
|
+
|
|
65
64
|
// Converting OVC if needed
|
|
66
|
-
this.ovc = OvcConverter.isOvc(ovc)
|
|
65
|
+
this.ovc = OvcConverter.isOvc(ovc)
|
|
66
|
+
? OvcConverter.convertToOptionsVariables(ovc, this.references)
|
|
67
|
+
: ovc
|
|
67
68
|
|
|
68
69
|
// Initiating inputs
|
|
69
70
|
const inputs = new IntputsInitiator(this.references, this.ovc).getInputs()
|
|
@@ -91,9 +92,9 @@ class Prerender {
|
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
private generateDocumentNamesHash() {
|
|
94
|
-
Object.keys(this.
|
|
95
|
-
const document = this.
|
|
96
|
-
const documentParams = this.
|
|
95
|
+
Object.keys(this.model.documents).forEach(slug => {
|
|
96
|
+
const document = this.model.documents[slug]
|
|
97
|
+
const documentParams = this.model.documents[slug].params
|
|
97
98
|
const conditionObject = this.references.conditions.documents[slug]
|
|
98
99
|
const condition = conditionObject === undefined ? true : this.conditions.executeCondition(conditionObject, 0, 0, 'documents')
|
|
99
100
|
|