@legalplace/prerenderx 2.2.1 → 2.2.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/.gitlab-ci.yml CHANGED
@@ -1,8 +1,9 @@
1
- image: node:11-alpine
1
+ image: 148253454541.dkr.ecr.eu-west-1.amazonaws.com/legalplace:latest
2
2
 
3
3
 
4
4
  stages:
5
- - deploy
5
+ - setup
6
+ - publish
6
7
 
7
8
  before_script:
8
9
  - export PATH=$PATH:./node_modules/.bin/
@@ -10,18 +11,30 @@ before_script:
10
11
  variables:
11
12
  DOCKER_DRIVER: overlay2
12
13
 
14
+ setup:
15
+ stage: setup
16
+ cache:
17
+ key: yarn-cache-front
18
+ untracked: true
19
+ paths:
20
+ - .yarn-cache-front
21
+ policy: pull-push
22
+ only:
23
+ changes:
24
+ - yarn.lock
25
+ - package.json
26
+ - .gitlab-ci.yml
27
+ script:
28
+ - yarn install --frozen-lockfile --check-files --silent --cache-folder .yarn-cache-front
29
+ - yarn build
30
+
13
31
  publish:
14
- image: node:11-alpine
15
- stage: deploy
32
+ stage: publish
16
33
  except:
17
34
  variables:
18
35
  - $CI_COMMIT_MESSAGE =~ /skip-publish/
19
- script:
20
- - echo -e "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
21
- - yarn install
22
- - yarn build
36
+ script:
23
37
  - npm publish
24
- - echo "PUBLISHED SUCCESSFULLY"
25
38
  environment:
26
39
  name: development
27
40
  only:
@@ -38,7 +38,7 @@ exports.parseOutputWithVariables = function (output, variables, autonums) {
38
38
  }
39
39
  parsedOutput = parsedOutput.replace(new RegExp("\\[var:" + variableId + "\\]", "g"), value);
40
40
  });
41
- parsedOutput = parsedOutput.replace(/\[\[PAGE_BREAK\]\]/gi, '<p class="pagebreak"><!-- pagebreak --></p>');
41
+ parsedOutput = parsedOutput.replace(/\[\[PAGE_BREAK\]\]/gi, '<div style="page-break-after:always"></div>');
42
42
  parsedOutput = parsedOutput.replace(/\[(E|B)_BLUR\]/gi, "");
43
43
  autonums.forEach(function (currentAn) {
44
44
  if (currentAn[3] === null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/prerenderx",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "PrerenderX",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://git.legalplace.eu/legalplace/prerenderx",
@@ -101,7 +101,7 @@ export const parseOutputWithVariables: parseOutputT = (
101
101
  // Inserting page breaks
102
102
  parsedOutput = parsedOutput.replace(
103
103
  /\[\[PAGE_BREAK\]\]/gi,
104
- '<p class="pagebreak"><!-- pagebreak --></p>'
104
+ '<div style="page-break-after:always"></div>'
105
105
  );
106
106
 
107
107
  // Cleaning BLURS
@@ -1,49 +0,0 @@
1
- import { Types } from "@legalplace/referencesparser";
2
- import ConditionsRunner from "./ConditionsRunner";
3
- declare type OVC_TYPE = {
4
- options: {
5
- [key: string]: boolean[];
6
- };
7
- variables: {
8
- [key: string]: (number | string)[];
9
- };
10
- };
11
- declare class DataPopulator {
12
- private references;
13
- private ovc;
14
- private conditionsRunner;
15
- private id?;
16
- private index?;
17
- private dataMap;
18
- private data;
19
- constructor(conditionsRunner: ConditionsRunner, references: Types.ReferencesType, ovc: OVC_TYPE, dataMap: ConditionDataMap, id?: number, index?: number);
20
- getData(): Readonly<ConditionData>;
21
- private populateConditions;
22
- private populateVariables;
23
- private getVariableValues;
24
- private getVariableRootParent;
25
- private cleanArrayFromNullValues;
26
- populateOptions(): void;
27
- private getOptionInputs;
28
- private getOptionRootParent;
29
- private optionConditionValue;
30
- private variableConditionValue;
31
- private sectionConditionValue;
32
- }
33
- export interface ConditionDataMap {
34
- o: number[];
35
- v: number[];
36
- c: {
37
- o: number[];
38
- s: number[];
39
- };
40
- }
41
- export interface ConditionData {
42
- o: Record<string, boolean[]>;
43
- v: Record<string, (string | number)[]>;
44
- c: {
45
- o: Record<string, boolean[]>;
46
- s: Record<string, boolean[]>;
47
- };
48
- }
49
- export default DataPopulator;
@@ -1,153 +0,0 @@
1
- "use strict";
2
- var __spreadArrays = (this && this.__spreadArrays) || function () {
3
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
- r[k] = a[j];
7
- return r;
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- var DataPopulator = (function () {
11
- function DataPopulator(conditionsRunner, references, ovc, dataMap, id, index) {
12
- this.data = {
13
- o: {},
14
- v: {},
15
- c: {
16
- o: {},
17
- s: {}
18
- }
19
- };
20
- this.id = id;
21
- this.ovc = ovc;
22
- this.index = index;
23
- this.dataMap = dataMap;
24
- this.references = references;
25
- this.conditionsRunner = conditionsRunner;
26
- this.populateVariables();
27
- this.populateOptions();
28
- this.populateConditions();
29
- }
30
- DataPopulator.prototype.getData = function () {
31
- return this.data;
32
- };
33
- DataPopulator.prototype.populateConditions = function () {
34
- for (var i = 0; i < this.dataMap.c.s.length; i += 1) {
35
- var sectionId = this.dataMap.c.s[i];
36
- var sectionCondition = this.sectionConditionValue(sectionId);
37
- this.data.c.s[sectionId] = [sectionCondition === true];
38
- }
39
- for (var i = 0; i < this.dataMap.c.o.length; i += 1) {
40
- var optionId = this.dataMap.c.o[i];
41
- var optionCondition = this.optionConditionValue(optionId);
42
- this.data.c.o[optionId] =
43
- optionCondition === undefined ? [false] : optionCondition;
44
- }
45
- };
46
- DataPopulator.prototype.populateVariables = function () {
47
- for (var i = 0; i < this.dataMap.v.length; i += 1) {
48
- var variableId = this.dataMap.v[i];
49
- var variableReference = this.references.variables[variableId];
50
- var values = this.getVariableValues(variableId);
51
- if (variableReference.type === "number") {
52
- values = values.map(function (v) { return (typeof v === "number" ? v : parseFloat(v)); });
53
- }
54
- this.data.v[variableId] = __spreadArrays(values);
55
- }
56
- };
57
- DataPopulator.prototype.getVariableValues = function (variableId) {
58
- var conditions = this.variableConditionValue(variableId);
59
- var value = this.ovc.variables[variableId];
60
- if (this.id === undefined || this.index === undefined) {
61
- return value;
62
- }
63
- var variableRootParent = this.getVariableRootParent(variableId);
64
- var variableRootRelations = this.references.relations.options[variableRootParent];
65
- if (variableRootRelations.children.options.includes(this.id) ||
66
- variableRootRelations.dependants.includes(this.id) ||
67
- this.id === variableRootParent) {
68
- if (conditions !== undefined && conditions[this.index] === false)
69
- return ["fAl$e"];
70
- return [value[this.index]];
71
- }
72
- var cleanValues = this.cleanArrayFromNullValues(__spreadArrays(value));
73
- if (conditions === undefined)
74
- return cleanValues;
75
- return cleanValues.map(function (currentValue, index) {
76
- if (conditions[index] === false)
77
- return "fAl$e";
78
- return currentValue;
79
- });
80
- };
81
- DataPopulator.prototype.getVariableRootParent = function (variableId) {
82
- var variableParents = this.references.relations.variables[variableId]
83
- .parents;
84
- return variableParents[variableParents.length - 1];
85
- };
86
- DataPopulator.prototype.cleanArrayFromNullValues = function (arr) {
87
- return arr.map(function (v) { return (v === null ? "" : v); });
88
- };
89
- DataPopulator.prototype.populateOptions = function () {
90
- for (var i = 0; i < this.dataMap.o.length; i += 1) {
91
- var optionId = this.dataMap.o[i];
92
- var inputs = this.getOptionInputs(optionId);
93
- this.data.o[optionId] = __spreadArrays(inputs);
94
- }
95
- };
96
- DataPopulator.prototype.getOptionInputs = function (optionId) {
97
- var conditions = this.optionConditionValue(optionId);
98
- var inputs = this.ovc.options[optionId];
99
- if (this.id === undefined || this.index === undefined) {
100
- return inputs;
101
- }
102
- var optionRootParent = this.getOptionRootParent(optionId);
103
- var optionRootRelations = this.references.relations.options[optionRootParent];
104
- if (optionRootRelations.children.options.includes(this.id) ||
105
- optionRootRelations.dependants.includes(this.id) ||
106
- this.id === optionRootParent) {
107
- if (conditions !== undefined && conditions[this.index] === false)
108
- return [false];
109
- return [inputs[this.index]];
110
- }
111
- if (conditions === undefined)
112
- return inputs;
113
- return inputs.map(function (value, index) {
114
- if (conditions[index] === false)
115
- return false;
116
- return value;
117
- });
118
- };
119
- DataPopulator.prototype.getOptionRootParent = function (optionId) {
120
- var optionParents = this.references.relations.options[optionId].parents;
121
- return optionParents.length > 0
122
- ? optionParents[optionParents.length - 1]
123
- : optionId;
124
- };
125
- DataPopulator.prototype.optionConditionValue = function (optionId) {
126
- var _this = this;
127
- var conditions = this.references.conditions.options[optionId];
128
- if (conditions === undefined)
129
- return undefined;
130
- var inputs = this.ovc.options[optionId];
131
- return inputs.map(function (input, index) {
132
- return _this.conditionsRunner.executeCondition(conditions, optionId, index, "options");
133
- });
134
- };
135
- DataPopulator.prototype.variableConditionValue = function (variableId) {
136
- var _this = this;
137
- var conditions = this.references.conditions.variables[variableId];
138
- if (conditions === undefined)
139
- return undefined;
140
- var inputs = this.ovc.variables[variableId];
141
- return inputs.map(function (input, index) {
142
- return _this.conditionsRunner.executeCondition(conditions, variableId, index, "variables");
143
- });
144
- };
145
- DataPopulator.prototype.sectionConditionValue = function (sectionId) {
146
- var conditions = this.references.conditions.sections.main[sectionId];
147
- if (conditions === undefined)
148
- return undefined;
149
- return this.conditionsRunner.executeCondition(conditions, 0, 0, "sections");
150
- };
151
- return DataPopulator;
152
- }());
153
- exports.default = DataPopulator;
@@ -1,21 +0,0 @@
1
- import { Types } from "@legalplace/referencesparser";
2
- declare type References = Types.ReferencesType;
3
- declare type OVC_TYPE = {
4
- options: {
5
- [key: string]: boolean[];
6
- };
7
- variables: {
8
- [key: string]: (number | string)[];
9
- };
10
- };
11
- declare class IntputsInitiator {
12
- private inputs;
13
- private references;
14
- private ovc;
15
- constructor(references: References, ovc: OVC_TYPE | null);
16
- getInputs(): OVC_TYPE;
17
- private setMultiples;
18
- private initOptionsInputs;
19
- private initVariablesInputs;
20
- }
21
- export default IntputsInitiator;
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var IntputsInitiator = (function () {
4
- function IntputsInitiator(references, ovc) {
5
- this.inputs = {
6
- options: {},
7
- variables: {}
8
- };
9
- this.references = references;
10
- this.ovc = ovc;
11
- this.setMultiples();
12
- this.initOptionsInputs();
13
- this.initVariablesInputs();
14
- }
15
- IntputsInitiator.prototype.getInputs = function () {
16
- return this.inputs;
17
- };
18
- IntputsInitiator.prototype.setMultiples = function () {
19
- var _this = this;
20
- if (this.ovc === null)
21
- return;
22
- Object.keys(this.ovc.options).forEach(function (id) {
23
- if (_this.ovc === null)
24
- return;
25
- var inputs = _this.ovc.options[id];
26
- if (inputs.length > 1) {
27
- var parentsTree = _this.references.relations.options[id].parents;
28
- var rootOptionId = parentsTree.length > 0 ? parentsTree[parentsTree.length - 1] : id;
29
- if (!_this.ovc.options[rootOptionId]) {
30
- var rootReference = _this.references.options[rootOptionId];
31
- if (rootReference.meta.type === "static") {
32
- _this.ovc.options[rootOptionId] = new Array(inputs.length).fill(true);
33
- }
34
- }
35
- }
36
- });
37
- };
38
- IntputsInitiator.prototype.initOptionsInputs = function () {
39
- var optionsIds = Object.keys(this.references.options);
40
- for (var i = 0; i < optionsIds.length; i += 1) {
41
- var optionId = optionsIds[i];
42
- var option = this.references.options[optionId];
43
- var values = [false];
44
- if (this.ovc &&
45
- Object.prototype.hasOwnProperty.call(this.ovc.options, optionId)) {
46
- if ([
47
- "static",
48
- "hidden",
49
- "brut-text",
50
- "repeated",
51
- "box",
52
- "separator"
53
- ].includes(option.meta.type)) {
54
- values = new Array(this.ovc.options[optionId].length).fill(true);
55
- }
56
- else {
57
- values = this.ovc.options[optionId];
58
- }
59
- }
60
- else if ([
61
- "static",
62
- "hidden",
63
- "brut-text",
64
- "repeated",
65
- "box",
66
- "separator"
67
- ].includes(option.meta.type)) {
68
- values = [true];
69
- }
70
- this.inputs.options[optionId] = values;
71
- }
72
- };
73
- IntputsInitiator.prototype.initVariablesInputs = function () {
74
- var variablesIds = Object.keys(this.references.variables);
75
- for (var i = 0; i < variablesIds.length; i += 1) {
76
- var variableId = variablesIds[i];
77
- var values = [""];
78
- if (this.ovc &&
79
- Object.prototype.hasOwnProperty.call(this.ovc.variables, variableId)) {
80
- values = this.ovc.variables[variableId];
81
- }
82
- else {
83
- var defaultValue = "";
84
- var prefillings = this.references.variables[variableId].prefillings;
85
- if (prefillings &&
86
- Array.isArray(prefillings) &&
87
- prefillings.length > 0) {
88
- var noConditionsPrefills = prefillings.filter(function (prefill) {
89
- return typeof prefill.conditions === "undefined" ||
90
- Object.keys(prefill.conditions).length === 0;
91
- });
92
- defaultValue =
93
- noConditionsPrefills.length > 0
94
- ? noConditionsPrefills[0].value
95
- : "";
96
- }
97
- values = [defaultValue];
98
- }
99
- this.inputs.variables[variableId] = values;
100
- }
101
- };
102
- return IntputsInitiator;
103
- }());
104
- exports.default = IntputsInitiator;
@@ -1,19 +0,0 @@
1
- import OVC_TYPE from "./ovc.type";
2
- export interface OldOVC {
3
- o: {
4
- [k: string]: string | number | (string | number)[];
5
- };
6
- v: {
7
- [k: string]: string | number | (string | number)[];
8
- };
9
- c: {
10
- [k: string]: boolean | boolean[];
11
- };
12
- }
13
- declare class OvcConverter {
14
- convertToOptionsVariables(ovc: OldOVC): OVC_TYPE;
15
- isOvc(_obj: OVC_TYPE | OldOVC): _obj is OldOVC;
16
- isOptionsVariables(_obj: OVC_TYPE | OldOVC): boolean;
17
- }
18
- declare const _default: OvcConverter;
19
- export default _default;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var OvcConverter = (function () {
4
- function OvcConverter() {
5
- }
6
- OvcConverter.prototype.convertToOptionsVariables = function (ovc) {
7
- var inputs = {
8
- options: {},
9
- variables: {}
10
- };
11
- if (typeof ovc !== "object")
12
- return inputs;
13
- if (typeof ovc.o === "object") {
14
- Object.keys(ovc.o).forEach(function (id) {
15
- var currentOption = ovc.o[id];
16
- if (Array.isArray(currentOption)) {
17
- var occurences_1 = currentOption.length;
18
- currentOption.forEach(function (childId, index) {
19
- if (typeof childId === "string" && childId.trim().length === 0) {
20
- if (!Object.prototype.hasOwnProperty.call(inputs.options, childId)) {
21
- inputs.options[id] = new Array(occurences_1).fill(false);
22
- }
23
- return;
24
- }
25
- if (!Object.prototype.hasOwnProperty.call(inputs.options, childId)) {
26
- inputs.options[childId] = new Array(occurences_1).fill(false);
27
- }
28
- inputs.options[childId][index] = true;
29
- });
30
- }
31
- else {
32
- if (typeof currentOption === "string" &&
33
- currentOption.trim().length === 0)
34
- return;
35
- inputs.options[currentOption] = [true];
36
- }
37
- });
38
- }
39
- if (typeof ovc.v === "object") {
40
- Object.keys(ovc.v).forEach(function (id) {
41
- var currentVariable = ovc.v[id];
42
- if (Array.isArray(currentVariable)) {
43
- inputs.variables[id] = currentVariable;
44
- }
45
- else {
46
- inputs.variables[id] = [currentVariable];
47
- }
48
- });
49
- }
50
- if (typeof ovc.c === "object") {
51
- Object.keys(ovc.c).forEach(function (id) {
52
- var currentCheckbox = ovc.c[id];
53
- if (typeof id === "string" && id.trim().length === 0)
54
- return;
55
- if (Array.isArray(currentCheckbox)) {
56
- inputs.options[id] = currentCheckbox;
57
- }
58
- else {
59
- inputs.options[id] = [currentCheckbox];
60
- }
61
- });
62
- }
63
- return inputs;
64
- };
65
- OvcConverter.prototype.isOvc = function (_obj) {
66
- if (typeof _obj !== "object" || _obj === null)
67
- return false;
68
- var ovcKeys = ["o", "v", "c"];
69
- var foundKeys = Object.keys(_obj)
70
- .map(function (key) { return (ovcKeys.includes(key) ? 1 : 0); })
71
- .reduce(function (a, b) { return a + b; }, 0);
72
- return foundKeys > 1;
73
- };
74
- OvcConverter.prototype.isOptionsVariables = function (_obj) {
75
- if (typeof _obj !== "object" || _obj === null)
76
- return false;
77
- var optionsVariablesKeys = ["options", "variables"];
78
- var foundKeys = Object.keys(_obj)
79
- .map(function (key) { return (optionsVariablesKeys.includes(key) ? 1 : 0); })
80
- .reduce(function (a, b) { return a + b; }, 0);
81
- return foundKeys === 2;
82
- };
83
- return OvcConverter;
84
- }());
85
- exports.default = new OvcConverter();