@legalplace/prerenderx 2.6.1 → 2.6.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/CHANGELOG.md +25 -0
- package/dist/libs/OutputParser.js +8 -4
- package/dist/libs/Prerender.d.ts +2 -2
- package/dist/libs/Prerender.js +11 -9
- package/package.json +5 -3
- package/src/libs/OutputParser.ts +11 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
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
|
+
|
|
5
|
+
### [2.6.2](https://git.legalplace.eu/legalplace/prerenderx/compare/v2.2.0...v2.6.2) (2021-10-01)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* adding french numbers displaying ([ffc1c1e](https://git.legalplace.eu/legalplace/prerenderx/commit/ffc1c1e4279dbd5d6529da0394cf03998fe1d4a3))
|
|
11
|
+
* bump version ([1b94156](https://git.legalplace.eu/legalplace/prerenderx/commit/1b941562c157e4ee368ca6ced106bf5c2d1dddd3))
|
|
12
|
+
* supporting parsed references ([39d5a8d](https://git.legalplace.eu/legalplace/prerenderx/commit/39d5a8d74fc9d9fd91936ab8d2c1edb9780e5afc))
|
|
13
|
+
* supporting parsed references and rendering documents on-demand. ([17ccbeb](https://git.legalplace.eu/legalplace/prerenderx/commit/17ccbeb8fe6ef4529864df955fd83fbe4911e252))
|
|
14
|
+
* Supporting variables in documents names ([da853c0](https://git.legalplace.eu/legalplace/prerenderx/commit/da853c0a1b0325d45570543195ada5f292645bad))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add version logging ([4815571](https://git.legalplace.eu/legalplace/prerenderx/commit/4815571df9dbb1dc2a394683fe0bb16723eae57c))
|
|
20
|
+
* adding cache support for conditions ([34866b8](https://git.legalplace.eu/legalplace/prerenderx/commit/34866b8f7fc5b7e5d2bd1ff08dd50a80010c0262))
|
|
21
|
+
* bimp version ([f3fbd55](https://git.legalplace.eu/legalplace/prerenderx/commit/f3fbd55bba169a449a282c34c85fa48f98b03be5))
|
|
22
|
+
* datapopulator issue ([b8f8532](https://git.legalplace.eu/legalplace/prerenderx/commit/b8f8532fe7b03811e364387d3168c637d7bc6976))
|
|
23
|
+
* fixing cache ([53cf0dd](https://git.legalplace.eu/legalplace/prerenderx/commit/53cf0ddd2e1cd8c6c98c86869081aa949317f0cb))
|
|
24
|
+
* handle static chil in ovc converter ([5eadfab](https://git.legalplace.eu/legalplace/prerenderx/commit/5eadfab0aa8c0885f3e4268eb56c82e56e07d7ba))
|
|
25
|
+
* handle static child in prerender ([f6e6115](https://git.legalplace.eu/legalplace/prerenderx/commit/f6e6115f9d04bd585e0e05e52871217da9e1cf1b))
|
|
@@ -8,6 +8,12 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.parseDocumentNameWithVariables = exports.parseOutputWithVariables = exports.getRelatedVariablesValues = void 0;
|
|
11
|
+
var frenchNumber = function (value) {
|
|
12
|
+
var result = typeof value === 'number' ? value.toString() : value;
|
|
13
|
+
if (/^([0-9]+)\.([0-9]+)$/.test(result.trim()))
|
|
14
|
+
result = result.trim().replace('.', ',');
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
11
17
|
exports.getRelatedVariablesValues = function (optionId, index, variables, ovc, references) {
|
|
12
18
|
var variablesValues = {};
|
|
13
19
|
variables.forEach(function (currentVariableId) {
|
|
@@ -24,10 +30,8 @@ exports.getRelatedVariablesValues = function (optionId, index, variables, ovc, r
|
|
|
24
30
|
if (rootVariableParentRelations.children.options.includes(optionId) || rootVariableParentRelations.dependants.includes(optionId) || optionId === rootVariableParentId)
|
|
25
31
|
value = [value[index]];
|
|
26
32
|
var cleanValues = value.map(function (currentValue) {
|
|
27
|
-
if (typeof currentValue
|
|
28
|
-
return currentValue
|
|
29
|
-
if (typeof currentValue === 'string')
|
|
30
|
-
return currentValue;
|
|
33
|
+
if (['number', 'string'].includes(typeof currentValue))
|
|
34
|
+
return frenchNumber(currentValue);
|
|
31
35
|
return '';
|
|
32
36
|
});
|
|
33
37
|
var currentVariableValue = cleanValues.length === 1 ? cleanValues[0] : cleanValues.join(', ');
|
package/dist/libs/Prerender.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ModelV3 } from '@legalplace/models-v3-types';
|
|
2
|
+
import { Types } from '@legalplace/referencesparser';
|
|
2
3
|
import OVC_TYPE from './ovc.type';
|
|
3
4
|
import { OldOVC } from './OvcConverter';
|
|
4
5
|
declare type DocumentOutputIndex = {
|
|
@@ -21,7 +22,6 @@ declare type FDFType = {
|
|
|
21
22
|
fields: Record<string, string>;
|
|
22
23
|
};
|
|
23
24
|
declare class Prerender {
|
|
24
|
-
private model;
|
|
25
25
|
private references;
|
|
26
26
|
private ovc;
|
|
27
27
|
private conditions;
|
|
@@ -30,7 +30,7 @@ declare class Prerender {
|
|
|
30
30
|
private NumAuto;
|
|
31
31
|
private documentsIndex;
|
|
32
32
|
private renderedDocuments;
|
|
33
|
-
constructor(
|
|
33
|
+
constructor(entry: ModelV3 | Types.ReferencesType, ovc: OVC_TYPE | OldOVC);
|
|
34
34
|
getDocumentsIndex(): Record<string, DocumentOutputIndex | DocumentPdfFormIndex>;
|
|
35
35
|
getDocument(documentNameHash: string): string | FDFType;
|
|
36
36
|
private generateDocumentNamesHash;
|
package/dist/libs/Prerender.js
CHANGED
|
@@ -13,15 +13,17 @@ var InputsInitiator_1 = __importDefault(require("./InputsInitiator"));
|
|
|
13
13
|
var FillPdfForm_1 = __importDefault(require("./FillPdfForm"));
|
|
14
14
|
var OutputParser_1 = require("./OutputParser");
|
|
15
15
|
var Prerender = (function () {
|
|
16
|
-
function Prerender(
|
|
16
|
+
function Prerender(entry, ovc) {
|
|
17
17
|
this.documentsIndex = {};
|
|
18
18
|
this.renderedDocuments = {};
|
|
19
|
-
|
|
19
|
+
if (referencesparser_1.ReferencesParser.isReferences(entry)) {
|
|
20
|
+
this.references = entry;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
this.references = new referencesparser_1.ReferencesParser(entry).getReferences();
|
|
24
|
+
}
|
|
20
25
|
this.NumAuto = new NumAuto_1.default();
|
|
21
|
-
this.
|
|
22
|
-
this.ovc = OvcConverter_1.default.isOvc(ovc)
|
|
23
|
-
? OvcConverter_1.default.convertToOptionsVariables(ovc, this.references)
|
|
24
|
-
: ovc;
|
|
26
|
+
this.ovc = OvcConverter_1.default.isOvc(ovc) ? OvcConverter_1.default.convertToOptionsVariables(ovc, this.references) : ovc;
|
|
25
27
|
var inputs = new InputsInitiator_1.default(this.references, this.ovc).getInputs();
|
|
26
28
|
this.conditions = new ConditionsRunner_1.default(this.references, inputs);
|
|
27
29
|
this.documentRender = new DocumentRender_1.default(this.references, this.conditions, inputs, this.NumAuto);
|
|
@@ -38,10 +40,10 @@ var Prerender = (function () {
|
|
|
38
40
|
};
|
|
39
41
|
Prerender.prototype.generateDocumentNamesHash = function () {
|
|
40
42
|
var _this = this;
|
|
41
|
-
Object.keys(this.
|
|
43
|
+
Object.keys(this.references.documents).forEach(function (slug) {
|
|
42
44
|
var _a, _b;
|
|
43
|
-
var document = _this.
|
|
44
|
-
var documentParams = _this.
|
|
45
|
+
var document = _this.references.documents[slug];
|
|
46
|
+
var documentParams = _this.references.documents[slug].params;
|
|
45
47
|
var conditionObject = _this.references.conditions.documents[slug];
|
|
46
48
|
var condition = conditionObject === undefined ? true : _this.conditions.executeCondition(conditionObject, 0, 0, 'documents');
|
|
47
49
|
if (condition === true) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/prerenderx",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "PrerenderX",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": "https://git.legalplace.eu/legalplace/prerenderx",
|
|
@@ -11,13 +11,15 @@
|
|
|
11
11
|
"lint": "tsc && eslint ./src/ --ext ts,js",
|
|
12
12
|
"lint:fix": "tsc && eslint 'src/**/*.{js,jsx,ts,tsx}' --fix",
|
|
13
13
|
"test": "jest",
|
|
14
|
-
"build": "tsc"
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"release": "standard-version -a --no-verify"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@legalplace/lplogic": "^2.1.6",
|
|
18
19
|
"@legalplace/models-v3-types": "^3.5.1",
|
|
19
|
-
"@legalplace/referencesparser": "1.7.0",
|
|
20
|
+
"@legalplace/referencesparser": "^1.7.0",
|
|
20
21
|
"crypto": "^1.0.1",
|
|
22
|
+
"standard-version": "^9.3.1",
|
|
21
23
|
"typescript": "3.9.3"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
package/src/libs/OutputParser.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { Types } from '@legalplace/referencesparser'
|
|
2
2
|
import OVC_TYPE from './ovc.type'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Parses number to correct french number format ("," instead of ".")
|
|
6
|
+
*/
|
|
7
|
+
const frenchNumber = (value: string | number) => {
|
|
8
|
+
let result = typeof value === 'number' ? value.toString() : value;
|
|
9
|
+
if (/^([0-9]+)\.([0-9]+)$/.test(result.trim()))
|
|
10
|
+
result = result.trim().replace('.', ',');
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
|
|
4
14
|
/**
|
|
5
15
|
* Returns option's related variable values
|
|
6
16
|
* @param optionId Option's id
|
|
@@ -31,8 +41,7 @@ export const getRelatedVariablesValues: getRelatedVarsT = (optionId, index, vari
|
|
|
31
41
|
|
|
32
42
|
// Making sure all values are strings
|
|
33
43
|
const cleanValues = value.map(currentValue => {
|
|
34
|
-
if (typeof currentValue
|
|
35
|
-
if (typeof currentValue === 'string') return currentValue
|
|
44
|
+
if (['number', 'string'].includes(typeof currentValue)) return frenchNumber(currentValue)
|
|
36
45
|
return ''
|
|
37
46
|
})
|
|
38
47
|
|