@legalplace/tagextractor 1.1.4 → 1.1.7
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.
|
@@ -98,7 +98,6 @@ var DataPopulator = (function () {
|
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
DataPopulator.prototype.getVariableValues = function (variableId) {
|
|
101
|
-
var conditions = this.variableConditionValue(variableId);
|
|
102
101
|
var value = this.ovc.variables[variableId];
|
|
103
102
|
if (this.id === undefined || this.index === undefined) {
|
|
104
103
|
return value;
|
|
@@ -106,18 +105,9 @@ var DataPopulator = (function () {
|
|
|
106
105
|
var variableRootParent = this.getVariableRootParent(variableId);
|
|
107
106
|
var variableRootRelations = this.references.relations.options[variableRootParent];
|
|
108
107
|
if (variableRootRelations.children.options.includes(this.id) || variableRootRelations.dependants.includes(this.id) || this.id === variableRootParent) {
|
|
109
|
-
if (conditions !== undefined && conditions[this.index] === false)
|
|
110
|
-
return ['fAl$e'];
|
|
111
108
|
return [value[this.index]];
|
|
112
109
|
}
|
|
113
|
-
|
|
114
|
-
if (conditions === undefined)
|
|
115
|
-
return cleanValues;
|
|
116
|
-
return cleanValues.map(function (currentValue, index) {
|
|
117
|
-
if (conditions[index] === false)
|
|
118
|
-
return 'fAl$e';
|
|
119
|
-
return currentValue;
|
|
120
|
-
});
|
|
110
|
+
return this.cleanArrayFromNullValues(__spreadArrays(value));
|
|
121
111
|
};
|
|
122
112
|
DataPopulator.prototype.getVariableRootParent = function (variableId) {
|
|
123
113
|
var variableParents = this.references.relations.variables[variableId].parents;
|
|
@@ -134,7 +124,6 @@ var DataPopulator = (function () {
|
|
|
134
124
|
}
|
|
135
125
|
};
|
|
136
126
|
DataPopulator.prototype.getOptionInputs = function (optionId) {
|
|
137
|
-
var conditions = this.optionConditionValue(optionId);
|
|
138
127
|
var inputs = this.ovc.options[optionId];
|
|
139
128
|
if (this.id === undefined || this.index === undefined) {
|
|
140
129
|
return inputs;
|
|
@@ -142,17 +131,9 @@ var DataPopulator = (function () {
|
|
|
142
131
|
var optionRootParent = this.getOptionRootParent(optionId);
|
|
143
132
|
var optionRootRelations = this.references.relations.options[optionRootParent];
|
|
144
133
|
if (optionRootRelations.children.options.includes(this.id) || optionRootRelations.dependants.includes(this.id) || this.id === optionRootParent) {
|
|
145
|
-
if (conditions !== undefined && conditions[this.index] === false)
|
|
146
|
-
return [false];
|
|
147
134
|
return [inputs[this.index]];
|
|
148
135
|
}
|
|
149
|
-
|
|
150
|
-
return inputs;
|
|
151
|
-
return inputs.map(function (value, index) {
|
|
152
|
-
if (conditions[index] === false)
|
|
153
|
-
return false;
|
|
154
|
-
return value;
|
|
155
|
-
});
|
|
136
|
+
return inputs;
|
|
156
137
|
};
|
|
157
138
|
DataPopulator.prototype.getOptionRootParent = function (optionId) {
|
|
158
139
|
var optionParents = this.references.relations.options[optionId].parents;
|
|
@@ -6,6 +6,9 @@ declare class OvcConverter {
|
|
|
6
6
|
isOvc(_obj: InputsType | OvcType): _obj is OvcType;
|
|
7
7
|
isOptionsVariables(_obj: InputsType | OvcType): _obj is InputsType;
|
|
8
8
|
private pushStaticChildren;
|
|
9
|
+
private pushLeftOver;
|
|
10
|
+
private pushLeftOverOption;
|
|
11
|
+
private pushLeftOverVariable;
|
|
9
12
|
}
|
|
10
13
|
declare const _default: OvcConverter;
|
|
11
14
|
export default _default;
|
|
@@ -98,7 +98,7 @@ var OvcConverter = (function () {
|
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
-
return inputs;
|
|
101
|
+
return this.pushLeftOver(inputs, references);
|
|
102
102
|
};
|
|
103
103
|
OvcConverter.prototype.isOvc = function (_obj) {
|
|
104
104
|
if (typeof _obj !== 'object' || _obj === null)
|
|
@@ -132,6 +132,42 @@ var OvcConverter = (function () {
|
|
|
132
132
|
});
|
|
133
133
|
return result;
|
|
134
134
|
};
|
|
135
|
+
OvcConverter.prototype.pushLeftOver = function (inputs, references) {
|
|
136
|
+
var _this = this;
|
|
137
|
+
var result = __assign({}, inputs);
|
|
138
|
+
Object.values(references.sections).forEach(function (document) {
|
|
139
|
+
Object.values(document).forEach(function (section) {
|
|
140
|
+
section.options.forEach(function (optionId) {
|
|
141
|
+
var occurences = inputs.options[optionId] === undefined ? 1 : inputs.options[optionId].length;
|
|
142
|
+
result = _this.pushLeftOverOption(result, references, references.options[optionId], occurences);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
return result;
|
|
147
|
+
};
|
|
148
|
+
OvcConverter.prototype.pushLeftOverOption = function (inputs, references, option, occurences) {
|
|
149
|
+
var _a;
|
|
150
|
+
var _this = this;
|
|
151
|
+
var result = __assign({}, inputs);
|
|
152
|
+
var defaultValue = !['radio', 'checkbox'].includes(option.meta.type);
|
|
153
|
+
if (!Object.prototype.hasOwnProperty.call(result.options, option.meta.id)) {
|
|
154
|
+
result = __assign(__assign({}, result), { options: __assign(__assign({}, result.options), (_a = {}, _a[option.meta.id] = new Array(occurences).fill(defaultValue), _a)) });
|
|
155
|
+
}
|
|
156
|
+
option.options.forEach(function (optionId) {
|
|
157
|
+
result = _this.pushLeftOverOption(result, references, references.options[optionId], occurences);
|
|
158
|
+
});
|
|
159
|
+
option.variables.forEach(function (variableId) {
|
|
160
|
+
result = _this.pushLeftOverVariable(result, variableId, occurences);
|
|
161
|
+
});
|
|
162
|
+
return result;
|
|
163
|
+
};
|
|
164
|
+
OvcConverter.prototype.pushLeftOverVariable = function (inputs, id, occurences) {
|
|
165
|
+
var _a;
|
|
166
|
+
if (!Object.prototype.hasOwnProperty.call(inputs.variables, id)) {
|
|
167
|
+
return __assign(__assign({}, inputs), { variables: __assign(__assign({}, inputs.variables), (_a = {}, _a[id] = new Array(occurences).fill(''), _a)) });
|
|
168
|
+
}
|
|
169
|
+
return inputs;
|
|
170
|
+
};
|
|
135
171
|
return OvcConverter;
|
|
136
172
|
}());
|
|
137
173
|
exports.default = new OvcConverter();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/tagextractor",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "TagExtractor",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": "https://git.legalplace.eu/legalplace/tagextractor",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"build": "tsc"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@legalplace/lplogic": "^2.1.
|
|
17
|
+
"@legalplace/lplogic": "^2.1.6",
|
|
18
18
|
"@legalplace/models-v3-types": "^3.4.47",
|
|
19
|
-
"@legalplace/referencesparser": "^1.
|
|
19
|
+
"@legalplace/referencesparser": "^1.6.1",
|
|
20
20
|
"crypto": "^1.0.1",
|
|
21
21
|
"typescript": "3.9.3"
|
|
22
22
|
},
|
|
@@ -152,7 +152,6 @@ class DataPopulator {
|
|
|
152
152
|
* @param variableId Variable's id
|
|
153
153
|
*/
|
|
154
154
|
private getVariableValues(variableId: number): Readonly<(string | number)[]> {
|
|
155
|
-
const conditions = this.variableConditionValue(variableId)
|
|
156
155
|
const value = this.ovc.variables[variableId]
|
|
157
156
|
if (this.id === undefined || this.index === undefined) {
|
|
158
157
|
return value
|
|
@@ -162,19 +161,10 @@ class DataPopulator {
|
|
|
162
161
|
const variableRootParent = this.getVariableRootParent(variableId)
|
|
163
162
|
const variableRootRelations = this.references.relations.options[variableRootParent]
|
|
164
163
|
if (variableRootRelations.children.options.includes(this.id) || variableRootRelations.dependants.includes(this.id) || this.id === variableRootParent) {
|
|
165
|
-
// TODO: Replace fAl$e with a safer solution
|
|
166
|
-
if (conditions !== undefined && conditions[this.index] === false) return ['fAl$e']
|
|
167
164
|
return [value[this.index]]
|
|
168
165
|
}
|
|
169
166
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (conditions === undefined) return cleanValues
|
|
173
|
-
|
|
174
|
-
return cleanValues.map((currentValue, index) => {
|
|
175
|
-
if (conditions[index] === false) return 'fAl$e'
|
|
176
|
-
return currentValue
|
|
177
|
-
})
|
|
167
|
+
return this.cleanArrayFromNullValues([...value])
|
|
178
168
|
}
|
|
179
169
|
|
|
180
170
|
/**
|
|
@@ -213,7 +203,6 @@ class DataPopulator {
|
|
|
213
203
|
* @param optionId Option's id
|
|
214
204
|
*/
|
|
215
205
|
private getOptionInputs(optionId: number): Readonly<boolean[]> {
|
|
216
|
-
const conditions = this.optionConditionValue(optionId)
|
|
217
206
|
const inputs = this.ovc.options[optionId]
|
|
218
207
|
if (this.id === undefined || this.index === undefined) {
|
|
219
208
|
return inputs
|
|
@@ -223,16 +212,10 @@ class DataPopulator {
|
|
|
223
212
|
const optionRootParent = this.getOptionRootParent(optionId)
|
|
224
213
|
const optionRootRelations = this.references.relations.options[optionRootParent]
|
|
225
214
|
if (optionRootRelations.children.options.includes(this.id) || optionRootRelations.dependants.includes(this.id) || this.id === optionRootParent) {
|
|
226
|
-
if (conditions !== undefined && conditions[this.index] === false) return [false]
|
|
227
215
|
return [inputs[this.index]]
|
|
228
216
|
}
|
|
229
217
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return inputs.map((value, index) => {
|
|
233
|
-
if (conditions[index] === false) return false
|
|
234
|
-
return value
|
|
235
|
-
})
|
|
218
|
+
return inputs
|
|
236
219
|
}
|
|
237
220
|
|
|
238
221
|
/**
|
package/src/libs/OvcConverter.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OptionV3 } from '@legalplace/models-v3-types'
|
|
1
2
|
import { Types } from '@legalplace/referencesparser'
|
|
2
3
|
import InputsType from '../types/inputs.type'
|
|
3
4
|
import OvcType from '../types/ovc.type'
|
|
@@ -107,7 +108,8 @@ class OvcConverter {
|
|
|
107
108
|
})
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
|
|
111
|
+
// Pushing left over and returning inputs
|
|
112
|
+
return this.pushLeftOver(inputs, references)
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
public isOvc(_obj: InputsType | OvcType): _obj is OvcType {
|
|
@@ -150,6 +152,67 @@ class OvcConverter {
|
|
|
150
152
|
|
|
151
153
|
return result
|
|
152
154
|
}
|
|
155
|
+
|
|
156
|
+
private pushLeftOver(inputs: InputsType, references: Types.ReferencesType): InputsType {
|
|
157
|
+
let result = {
|
|
158
|
+
...inputs
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
Object.values(references.sections).forEach(document => {
|
|
162
|
+
Object.values(document).forEach(section => {
|
|
163
|
+
section.options.forEach(optionId => {
|
|
164
|
+
const occurences = inputs.options[optionId] === undefined ? 1 : inputs.options[optionId].length
|
|
165
|
+
result = this.pushLeftOverOption(result, references, references.options[optionId], occurences)
|
|
166
|
+
})
|
|
167
|
+
})
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
return result
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private pushLeftOverOption(inputs: InputsType, references: Types.ReferencesType, option: OptionV3, occurences: number): InputsType {
|
|
174
|
+
let result = {
|
|
175
|
+
...inputs
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const defaultValue = !['radio', 'checkbox'].includes(option.meta.type)
|
|
179
|
+
|
|
180
|
+
// Adding option if it doesn't exist
|
|
181
|
+
if (!Object.prototype.hasOwnProperty.call(result.options, option.meta.id)) {
|
|
182
|
+
result = {
|
|
183
|
+
...result,
|
|
184
|
+
options: {
|
|
185
|
+
...result.options,
|
|
186
|
+
[option.meta.id]: new Array(occurences).fill(defaultValue)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Reading option's children
|
|
192
|
+
option.options.forEach(optionId => {
|
|
193
|
+
result = this.pushLeftOverOption(result, references, references.options[optionId], occurences)
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
// Reading option variables
|
|
197
|
+
option.variables.forEach(variableId => {
|
|
198
|
+
result = this.pushLeftOverVariable(result, variableId, occurences)
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
return result
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
private pushLeftOverVariable(inputs: InputsType, id: number, occurences: number): InputsType {
|
|
205
|
+
if (!Object.prototype.hasOwnProperty.call(inputs.variables, id)) {
|
|
206
|
+
return {
|
|
207
|
+
...inputs,
|
|
208
|
+
variables: {
|
|
209
|
+
...inputs.variables,
|
|
210
|
+
[id]: new Array(occurences).fill('')
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return inputs
|
|
215
|
+
}
|
|
153
216
|
}
|
|
154
217
|
|
|
155
218
|
export default new OvcConverter()
|