@legalplace/prerenderx 2.2.1 → 2.2.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.
- package/.gitlab-ci.yml +16 -9
- package/.prettierrc.js +10 -0
- package/.vscode/settings.json +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/libs/ConditionsRunner.d.ts +4 -4
- package/dist/libs/ConditionsRunner.js +12 -29
- package/dist/libs/DocumentRender.d.ts +4 -4
- package/dist/libs/DocumentRender.js +1 -1
- package/dist/libs/NumAuto.js +1 -1
- package/dist/libs/OptionRender.d.ts +4 -4
- package/dist/libs/OptionRender.js +4 -14
- package/dist/libs/OutputParser.d.ts +2 -2
- package/dist/libs/OutputParser.js +11 -14
- package/dist/libs/Prerender.d.ts +3 -3
- package/dist/libs/Prerender.js +4 -8
- package/dist/libs/SectionRender.d.ts +4 -4
- package/dist/libs/SectionRender.js +4 -11
- package/package.json +9 -8
- package/src/index.ts +2 -2
- package/src/libs/ConditionsRunner.ts +50 -104
- package/src/libs/DataPopulator.ts +96 -133
- package/src/libs/DocumentRender.ts +22 -27
- package/src/libs/InputsInitiator.ts +51 -89
- package/src/libs/NumAuto.ts +14 -16
- package/src/libs/OptionRender.ts +39 -78
- package/src/libs/OutputParser.ts +38 -83
- package/src/libs/OvcConverter.ts +44 -52
- package/src/libs/Prerender.ts +41 -62
- package/src/libs/SectionRender.ts +35 -54
- package/src/libs/ovc.type.ts +6 -6
- package/dist/libs/DataPopulator.d.ts +0 -49
- package/dist/libs/DataPopulator.js +0 -153
- package/dist/libs/InputsInitiator.d.ts +0 -21
- package/dist/libs/InputsInitiator.js +0 -104
- package/dist/libs/OvcConverter.d.ts +0 -19
- package/dist/libs/OvcConverter.js +0 -85
- package/yarn.lock +0 -5087
|
@@ -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();
|