@legalplace/prerenderx 2.6.2 → 2.6.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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
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
4
 
5
+ ### [2.6.3](https://git.legalplace.eu/legalplace/prerenderx/compare/v2.6.2...v2.6.3) (2021-10-04)
6
+
5
7
  ### [2.6.2](https://git.legalplace.eu/legalplace/prerenderx/compare/v2.2.0...v2.6.2) (2021-10-01)
6
8
 
7
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/prerenderx",
3
- "version": "2.6.2",
3
+ "version": "2.6.3",
4
4
  "description": "PrerenderX",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://git.legalplace.eu/legalplace/prerenderx",
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import Prerender from './libs/Prerender';
2
- export default Prerender;
package/dist/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var Prerender_1 = __importDefault(require("./libs/Prerender"));
7
- exports.default = Prerender_1.default;
@@ -1,24 +0,0 @@
1
- import { Types } from '@legalplace/referencesparser';
2
- import { ConditionV3 } from '@legalplace/models-v3-types';
3
- import { ConditionDataMap } from './DataPopulator';
4
- declare type OVC_TYPE = {
5
- options: {
6
- [key: string]: boolean[];
7
- };
8
- variables: {
9
- [key: string]: (number | string)[];
10
- };
11
- };
12
- declare class ConditionsRunner {
13
- private references;
14
- private ovc;
15
- constructor(references: Types.ReferencesType, ovc: OVC_TYPE);
16
- isOptionRelatedToOption(optionA: number, optionB: number): boolean;
17
- isVariableRelatedToOption(variableId: number, optionId: number): boolean;
18
- isVariableRelatedToVariable(variableA: number, variableB: number): boolean;
19
- executeCondition(condition: {
20
- dataMap: ConditionDataMap;
21
- conditions: ConditionV3;
22
- }, id: number, index: number, conditionType: 'options' | 'optionValidator' | 'variables' | 'prefillers' | 'variableValidator' | 'sections' | 'documents'): any;
23
- }
24
- export default ConditionsRunner;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var lplogic_1 = __importDefault(require("@legalplace/lplogic"));
7
- var DataPopulator_1 = __importDefault(require("./DataPopulator"));
8
- var conditionsCache = {};
9
- var createConditionCacheKey = function (condition, id, index, conditionType) {
10
- var conditionString = JSON.stringify(condition);
11
- return id + "-" + index + "-" + conditionType + "-" + conditionString;
12
- };
13
- var ConditionsRunner = (function () {
14
- function ConditionsRunner(references, ovc) {
15
- this.references = references;
16
- this.ovc = ovc;
17
- }
18
- ConditionsRunner.prototype.isOptionRelatedToOption = function (optionA, optionB) {
19
- var OptionBParents = this.references.relations.options[optionB].parents;
20
- var OptionBRoot = OptionBParents[OptionBParents.length - 1];
21
- var OptionBRootRelations = OptionBRoot ? this.references.relations.options[OptionBRoot] : undefined;
22
- if (OptionBRootRelations) {
23
- if (optionA === optionB || OptionBRootRelations.children.options.includes(optionA) || OptionBRootRelations.dependants.includes(optionA)) {
24
- return true;
25
- }
26
- }
27
- return false;
28
- };
29
- ConditionsRunner.prototype.isVariableRelatedToOption = function (variableId, optionId) {
30
- var variableParentId = this.references.relations.variables[variableId].parents[0];
31
- var optionParents = this.references.relations.options[variableParentId].parents;
32
- var optionRoot = optionParents[optionParents.length - 1];
33
- var optionRootRelations = optionRoot ? this.references.relations.options[optionRoot] : undefined;
34
- if (optionRootRelations) {
35
- if (optionRootRelations.children.options.includes(optionId) || optionRootRelations.dependants.includes(optionId)) {
36
- return true;
37
- }
38
- }
39
- return false;
40
- };
41
- ConditionsRunner.prototype.isVariableRelatedToVariable = function (variableA, variableB) {
42
- var optionA = this.references.relations.variables[variableA].parents[0];
43
- var optionB = this.references.relations.variables[variableB].parents[0];
44
- var OptionBParents = this.references.relations.options[optionB].parents;
45
- var OptionBRoot = OptionBParents[OptionBParents.length - 1];
46
- var OptionBRootRelations = OptionBRoot ? this.references.relations.options[OptionBRoot] : undefined;
47
- if (OptionBRootRelations) {
48
- if (optionA === optionB || OptionBRootRelations.children.options.includes(optionA) || OptionBRootRelations.dependants.includes(optionA)) {
49
- return true;
50
- }
51
- }
52
- return false;
53
- };
54
- ConditionsRunner.prototype.executeCondition = function (condition, id, index, conditionType) {
55
- var _this = this;
56
- if (Array.isArray(condition))
57
- return condition.map(function (_condition) { return _this.executeCondition(_condition, id, index, conditionType); });
58
- var cacheKey = createConditionCacheKey(condition, id, index, conditionType);
59
- if (Object.prototype.hasOwnProperty.call(conditionsCache, cacheKey))
60
- return conditionsCache[cacheKey];
61
- var currentData;
62
- if (conditionType === 'options' || conditionType === 'optionValidator') {
63
- currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index).getData();
64
- }
65
- else if (conditionType === 'variables' || conditionType === 'prefillers' || conditionType === 'variableValidator') {
66
- var dataId = this.references.relations.variables[id].parents[0];
67
- currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, dataId, index).getData();
68
- }
69
- else if (conditionType === 'sections' || conditionType === 'documents') {
70
- currentData = new DataPopulator_1.default(this, this.references, this.ovc, condition.dataMap, id, index).getData();
71
- }
72
- conditionsCache[cacheKey] = lplogic_1.default(condition.conditions, currentData);
73
- return conditionsCache[cacheKey];
74
- };
75
- return ConditionsRunner;
76
- }());
77
- exports.default = ConditionsRunner;
@@ -1,53 +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 getOptionConditions;
23
- private getVariablesConditions;
24
- private populateVariables;
25
- private getVariableValues;
26
- private getVariableRootParent;
27
- private cleanArrayFromNullValues;
28
- populateOptions(): void;
29
- private getOptionInputs;
30
- private getOptionRootParent;
31
- private optionConditionValue;
32
- private variableConditionValue;
33
- private sectionConditionValue;
34
- }
35
- export interface ConditionDataMap {
36
- o: number[];
37
- v: number[];
38
- c: {
39
- o: number[];
40
- s: number[];
41
- v: number[];
42
- };
43
- }
44
- export interface ConditionData {
45
- o: Record<string, boolean[]>;
46
- v: Record<string, (string | number)[]>;
47
- c: {
48
- o: Record<string, boolean[]>;
49
- s: Record<string, boolean[]>;
50
- v: Record<string, boolean[]>;
51
- };
52
- }
53
- export default DataPopulator;
@@ -1,175 +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
- v: {}
19
- }
20
- };
21
- this.id = id;
22
- this.ovc = ovc;
23
- this.index = index;
24
- this.dataMap = dataMap;
25
- this.references = references;
26
- this.conditionsRunner = conditionsRunner;
27
- this.populateVariables();
28
- this.populateOptions();
29
- this.populateConditions();
30
- }
31
- DataPopulator.prototype.getData = function () {
32
- return this.data;
33
- };
34
- DataPopulator.prototype.populateConditions = function () {
35
- for (var i = 0; i < this.dataMap.c.s.length; i += 1) {
36
- var sectionId = this.dataMap.c.s[i];
37
- var sectionCondition = this.sectionConditionValue(sectionId);
38
- this.data.c.s[sectionId] = [sectionCondition !== false];
39
- }
40
- for (var i = 0; i < this.dataMap.c.o.length; i += 1) {
41
- var optionId = this.dataMap.c.o[i];
42
- var optionCondition = __spreadArrays(this.getOptionConditions(optionId));
43
- this.data.c.o[optionId] = optionCondition === undefined ? [false] : optionCondition;
44
- }
45
- for (var i = 0; i < this.dataMap.c.v.length; i += 1) {
46
- var variableId = this.dataMap.c.v[i];
47
- var variableCondition = __spreadArrays(this.getVariablesConditions(variableId));
48
- this.data.c.v[variableId] = variableCondition === undefined ? [false] : variableCondition;
49
- }
50
- };
51
- DataPopulator.prototype.getOptionConditions = function (optionId) {
52
- var conditions = this.optionConditionValue(optionId);
53
- if (conditions === undefined)
54
- return [true];
55
- if (this.id === undefined || this.index === undefined) {
56
- return conditions;
57
- }
58
- var optionRootParent = this.getOptionRootParent(optionId);
59
- var optionRootRelations = this.references.relations.options[optionRootParent];
60
- if (optionRootRelations.children.options.includes(this.id) ||
61
- optionRootRelations.dependants.includes(this.id) ||
62
- this.id === optionRootParent) {
63
- if (conditions !== undefined && conditions[this.index] === false)
64
- return [false];
65
- return [conditions[this.index]];
66
- }
67
- return conditions;
68
- };
69
- DataPopulator.prototype.getVariablesConditions = function (variableId) {
70
- var conditions = this.variableConditionValue(variableId);
71
- if (conditions === undefined)
72
- return [true];
73
- if (this.id === undefined || this.index === undefined) {
74
- return conditions;
75
- }
76
- var variableRootParent = this.getVariableRootParent(variableId);
77
- var variableRootRelations = this.references.relations.options[variableRootParent];
78
- if (variableRootRelations.children.options.includes(this.id) ||
79
- variableRootRelations.dependants.includes(this.id) ||
80
- this.id === variableRootParent) {
81
- return [conditions[this.index]];
82
- }
83
- return conditions;
84
- };
85
- DataPopulator.prototype.populateVariables = function () {
86
- var _loop_1 = function (i) {
87
- var variableId = this_1.dataMap.v[i];
88
- var variableReference = this_1.references.variables[variableId];
89
- var values = this_1.getVariableValues(variableId);
90
- var parseNumber = function (v) {
91
- var result = parseFloat(v);
92
- return Number.isNaN(result) ? '' : result;
93
- };
94
- if (variableReference.type === 'number') {
95
- values = values.map(function (v) { return (typeof v === 'number' ? v : parseNumber(v)); });
96
- }
97
- this_1.data.v[variableId] = __spreadArrays(values);
98
- };
99
- var this_1 = this;
100
- for (var i = 0; i < this.dataMap.v.length; i += 1) {
101
- _loop_1(i);
102
- }
103
- };
104
- DataPopulator.prototype.getVariableValues = function (variableId) {
105
- var value = this.ovc.variables[variableId];
106
- if (this.id === undefined || this.index === undefined) {
107
- return value;
108
- }
109
- var variableRootParent = this.getVariableRootParent(variableId);
110
- var variableRootRelations = this.references.relations.options[variableRootParent];
111
- if (variableRootRelations.children.options.includes(this.id) || variableRootRelations.dependants.includes(this.id) || this.id === variableRootParent) {
112
- return [value[this.index]];
113
- }
114
- return this.cleanArrayFromNullValues(__spreadArrays(value));
115
- };
116
- DataPopulator.prototype.getVariableRootParent = function (variableId) {
117
- var variableParents = this.references.relations.variables[variableId].parents;
118
- return variableParents[variableParents.length - 1];
119
- };
120
- DataPopulator.prototype.cleanArrayFromNullValues = function (arr) {
121
- return arr.map(function (v) { return (v === null ? '' : v); });
122
- };
123
- DataPopulator.prototype.populateOptions = function () {
124
- for (var i = 0; i < this.dataMap.o.length; i += 1) {
125
- var optionId = this.dataMap.o[i];
126
- var inputs = this.getOptionInputs(optionId);
127
- this.data.o[optionId] = __spreadArrays(inputs);
128
- }
129
- };
130
- DataPopulator.prototype.getOptionInputs = function (optionId) {
131
- var inputs = this.ovc.options[optionId];
132
- if (this.id === undefined || this.index === undefined) {
133
- return inputs;
134
- }
135
- var optionRootParent = this.getOptionRootParent(optionId);
136
- var optionRootRelations = this.references.relations.options[optionRootParent];
137
- if (optionRootRelations.children.options.includes(this.id) || optionRootRelations.dependants.includes(this.id) || this.id === optionRootParent) {
138
- return [inputs[this.index]];
139
- }
140
- return inputs;
141
- };
142
- DataPopulator.prototype.getOptionRootParent = function (optionId) {
143
- var optionParents = this.references.relations.options[optionId].parents;
144
- return optionParents.length > 0 ? optionParents[optionParents.length - 1] : optionId;
145
- };
146
- DataPopulator.prototype.optionConditionValue = function (optionId) {
147
- var _this = this;
148
- var conditions = this.references.conditions.options[optionId];
149
- if (conditions === undefined)
150
- return undefined;
151
- var inputs = this.ovc.options[optionId];
152
- return inputs.map(function (input, index) {
153
- return _this.conditionsRunner.executeCondition(conditions, optionId, index, 'options');
154
- });
155
- };
156
- DataPopulator.prototype.variableConditionValue = function (variableId) {
157
- var _this = this;
158
- var conditions = this.references.conditions.variables[variableId];
159
- if (conditions === undefined)
160
- return undefined;
161
- var inputs = this.ovc.variables[variableId];
162
- var result = inputs.map(function (input, index) {
163
- return _this.conditionsRunner.executeCondition(conditions, variableId, index, 'variables');
164
- });
165
- return result;
166
- };
167
- DataPopulator.prototype.sectionConditionValue = function (sectionId) {
168
- var conditions = this.references.conditions.sections.main[sectionId];
169
- if (conditions === undefined)
170
- return undefined;
171
- return this.conditionsRunner.executeCondition(conditions, 0, 0, 'sections');
172
- };
173
- return DataPopulator;
174
- }());
175
- exports.default = DataPopulator;
@@ -1,13 +0,0 @@
1
- import { Types } from '@legalplace/referencesparser';
2
- import ConditionsRunner from './ConditionsRunner';
3
- import OVC_TYPE from './ovc.type';
4
- import NumAuto from './NumAuto';
5
- declare class DocumentRender {
6
- references: Types.ReferencesType;
7
- conditions: ConditionsRunner;
8
- ovc: OVC_TYPE;
9
- private NumAuto;
10
- constructor(references: Types.ReferencesType, conditions: ConditionsRunner, ovc: OVC_TYPE, numauto: NumAuto);
11
- renderDocument(documentName: string): string;
12
- }
13
- export default DocumentRender;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var SectionRender_1 = __importDefault(require("./SectionRender"));
7
- var DocumentRender = (function () {
8
- function DocumentRender(references, conditions, ovc, numauto) {
9
- this.references = references;
10
- this.conditions = conditions;
11
- this.ovc = ovc;
12
- this.NumAuto = numauto;
13
- }
14
- DocumentRender.prototype.renderDocument = function (documentName) {
15
- var _this = this;
16
- var documentOutputs = [];
17
- this.NumAuto.resetIndexes();
18
- Object.keys(this.references.sections[documentName]).forEach(function (sectionId) {
19
- documentOutputs.push.apply(documentOutputs, new SectionRender_1.default({
20
- references: _this.references,
21
- conditions: _this.conditions,
22
- documentName: documentName,
23
- ovc: _this.ovc,
24
- currentSection: parseInt(sectionId, 10),
25
- numauto: _this.NumAuto
26
- }).getOutputs());
27
- });
28
- return documentOutputs.join('');
29
- };
30
- return DocumentRender;
31
- }());
32
- exports.default = DocumentRender;
@@ -1,13 +0,0 @@
1
- import FillPdfFormBase from './misc/FillPdfFormBase';
2
- declare type FDFType = {
3
- id: string;
4
- fields: Record<string, string>;
5
- };
6
- declare class FillPdfForm extends FillPdfFormBase {
7
- fillDocument(documentName: string): FDFType;
8
- private getInputValue;
9
- private getBoxValue;
10
- private getVariableValue;
11
- private getOptionValue;
12
- }
13
- export default FillPdfForm;
@@ -1,121 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __importDefault = (this && this.__importDefault) || function (mod) {
16
- return (mod && mod.__esModule) ? mod : { "default": mod };
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- var FillPdfFormBase_1 = __importDefault(require("./misc/FillPdfFormBase"));
20
- var FillPdfForm = (function (_super) {
21
- __extends(FillPdfForm, _super);
22
- function FillPdfForm() {
23
- return _super !== null && _super.apply(this, arguments) || this;
24
- }
25
- FillPdfForm.prototype.fillDocument = function (documentName) {
26
- var _this = this;
27
- var result = {
28
- id: '',
29
- fields: {}
30
- };
31
- var document = this.references.documents[documentName];
32
- var pdf = document.pdf;
33
- if (typeof pdf === 'undefined')
34
- return result;
35
- var form = pdf.form;
36
- result.id = pdf.id;
37
- form.inputs.forEach(function (input) {
38
- var id = "" + input.name;
39
- result.fields[id] = _this.getInputValue(input);
40
- });
41
- form.boxes.forEach(function (box) {
42
- var id = "" + box.name;
43
- var value = _this.getBoxValue(box);
44
- if (!(value === '' && Object.prototype.hasOwnProperty.call(result.fields, id)))
45
- result.fields[id] = value;
46
- });
47
- return result;
48
- };
49
- FillPdfForm.prototype.getInputValue = function (input) {
50
- for (var i = 0; i < input.variables.length; i += 1) {
51
- var variable = input.variables[i];
52
- var currentValue = this.getVariableValue(variable.id);
53
- if (currentValue !== false) {
54
- var dateRegex = /^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;
55
- if (variable.date && dateRegex.test(currentValue)) {
56
- switch (variable.date) {
57
- case 'DD':
58
- return currentValue.replace(dateRegex, '$1');
59
- case 'MM':
60
- return currentValue.replace(dateRegex, '$2');
61
- case 'YYYY':
62
- return currentValue.replace(dateRegex, '$3');
63
- default:
64
- }
65
- }
66
- var hourRegex = /^([0-9]{2}:[0-9]{2})$/;
67
- if (variable.hour && hourRegex.test(currentValue)) {
68
- switch (variable.hour) {
69
- case 'HH':
70
- return currentValue.replace(hourRegex, '$1');
71
- case 'MM':
72
- return currentValue.replace(hourRegex, '$2');
73
- default:
74
- }
75
- }
76
- var emailRegex = /^(.*)@(.*)$/;
77
- if (variable.email && emailRegex.test(currentValue)) {
78
- switch (variable.email) {
79
- case 'ADDRESS':
80
- return currentValue.split('@')[0];
81
- case 'PROVIDER':
82
- return currentValue.split('@')[1];
83
- default:
84
- }
85
- }
86
- if (variable.fragment && typeof variable.fragment.from === 'number' && typeof variable.fragment.to === 'number') {
87
- var _a = variable.fragment, from = _a.from, to = _a.to;
88
- return currentValue.slice(from, to);
89
- }
90
- return currentValue;
91
- }
92
- }
93
- return '';
94
- };
95
- FillPdfForm.prototype.getBoxValue = function (box) {
96
- for (var i = 0; i < box.options.length; i += 1) {
97
- var option = box.options[i];
98
- var currentValue = this.getOptionValue(option.id);
99
- if (currentValue === true) {
100
- if (this.references.options[option.id].meta.type === "checkbox" && box.value === "Off")
101
- return "On";
102
- return box.value;
103
- }
104
- }
105
- return '';
106
- };
107
- FillPdfForm.prototype.getVariableValue = function (variableId) {
108
- var _a;
109
- if (this.isVariableDisplayed(variableId, 0) === false)
110
- return false;
111
- return (((_a = this.ovc.variables[variableId]) === null || _a === void 0 ? void 0 : _a[0]) || '').toString();
112
- };
113
- FillPdfForm.prototype.getOptionValue = function (optionId) {
114
- var _a;
115
- if (this.isOptionDisplayed(optionId, 0) === false)
116
- return false;
117
- return ((_a = this.ovc.options[optionId]) === null || _a === void 0 ? void 0 : _a[0]) === true;
118
- };
119
- return FillPdfForm;
120
- }(FillPdfFormBase_1.default));
121
- exports.default = FillPdfForm;
@@ -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,80 +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 && Object.prototype.hasOwnProperty.call(this.ovc.options, optionId)) {
45
- if (['static', 'hidden', 'brut-text', 'repeated', 'box', 'separator'].includes(option.meta.type)) {
46
- values = new Array(this.ovc.options[optionId].length).fill(true);
47
- }
48
- else {
49
- values = this.ovc.options[optionId];
50
- }
51
- }
52
- else if (['static', 'hidden', 'brut-text', 'repeated', 'box', 'separator'].includes(option.meta.type)) {
53
- values = [true];
54
- }
55
- this.inputs.options[optionId] = values;
56
- }
57
- };
58
- IntputsInitiator.prototype.initVariablesInputs = function () {
59
- var variablesIds = Object.keys(this.references.variables);
60
- for (var i = 0; i < variablesIds.length; i += 1) {
61
- var variableId = variablesIds[i];
62
- var values = [''];
63
- if (this.ovc && Object.prototype.hasOwnProperty.call(this.ovc.variables, variableId)) {
64
- values = this.ovc.variables[variableId];
65
- }
66
- else {
67
- var defaultValue = '';
68
- var prefillings = this.references.variables[variableId].prefillings;
69
- if (prefillings && Array.isArray(prefillings) && prefillings.length > 0) {
70
- var noConditionsPrefills = prefillings.filter(function (prefill) { return typeof prefill.conditions === 'undefined' || Object.keys(prefill.conditions).length === 0; });
71
- defaultValue = noConditionsPrefills.length > 0 ? noConditionsPrefills[0].value : '';
72
- }
73
- values = [defaultValue];
74
- }
75
- this.inputs.variables[variableId] = values;
76
- }
77
- };
78
- return IntputsInitiator;
79
- }());
80
- exports.default = IntputsInitiator;
@@ -1,8 +0,0 @@
1
- declare class NumAuto {
2
- indexesList: Record<string, any>;
3
- tagsIndex: Record<string, number>;
4
- getNum: (index: string, tag: string | null) => number;
5
- getNumPre: (index: string) => number;
6
- resetIndexes: () => void;
7
- }
8
- export default NumAuto;