data-restructor 3.3.4 → 3.4.0
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/.github/workflows/codeql-analysis.yml +4 -4
- package/.github/workflows/continuous-integration.yaml +84 -0
- package/CHANGELOG.md +98 -76
- package/CONTRIBUTING.md +51 -43
- package/Commands.md +15 -15
- package/README.md +188 -137
- package/SECURITY.md +2 -2
- package/coverage/coverage-summary.json +3 -3
- package/coverage/datarestructor.js.html +133 -133
- package/coverage/describedfield.js.html +45 -45
- package/coverage/index.html +1 -1
- package/coverage/templateResolver.js.html +26 -26
- package/devdist/datarestructor-ie.js +1479 -1665
- package/devdist/datarestructor.js +1439 -1608
- package/devdist/describedfield-ie.js +259 -279
- package/devdist/describedfield.js +257 -277
- package/devdist/templateResolver-ie.js +220 -252
- package/devdist/templateResolver.js +196 -227
- package/dist/datarestructor-ie.js +1 -1
- package/dist/datarestructor-ie.js.map +1 -1
- package/dist/datarestructor.js +1 -1
- package/dist/datarestructor.js.map +1 -1
- package/dist/describedfield-ie.js +1 -1
- package/dist/describedfield-ie.js.map +1 -1
- package/dist/describedfield.js +1 -1
- package/dist/describedfield.js.map +1 -1
- package/dist/templateResolver-ie.js +1 -1
- package/dist/templateResolver-ie.js.map +1 -1
- package/dist/templateResolver.js +1 -1
- package/dist/templateResolver.js.map +1 -1
- package/docs/datarestructor.js.html +1 -1
- package/docs/describedfield.js.html +1 -1
- package/docs/index.html +49 -44
- package/docs/module-datarestructor.DescribedEntryCreator.html +1 -1
- package/docs/module-datarestructor.PropertyStructureDescriptionBuilder.html +1 -1
- package/docs/module-datarestructor.Restructor.html +1 -1
- package/docs/module-datarestructor.Transform.html +1 -1
- package/docs/module-datarestructor.html +1 -1
- package/docs/module-described_field.DescribedDataFieldBuilder.html +1 -1
- package/docs/module-described_field.DescribedDataFieldGroup.html +1 -1
- package/docs/module-described_field.html +1 -1
- package/docs/module-template_resolver.Resolver.html +1 -1
- package/docs/module-template_resolver.html +1 -1
- package/docs/templateResolver.js.html +1 -1
- package/package.json +16 -14
- package/renovate.json +20 -0
- package/.github/workflows/action.yaml +0 -44
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// anything defined in a previous bundle is accessed via the
|
|
7
7
|
// orig method which is the require for previous bundles
|
|
8
8
|
|
|
9
|
-
(function(modules, entry, mainEntry, parcelRequireName, globalName) {
|
|
9
|
+
(function (modules, entry, mainEntry, parcelRequireName, globalName) {
|
|
10
10
|
/* eslint-disable no-undef */
|
|
11
11
|
var globalObject =
|
|
12
12
|
typeof globalThis !== 'undefined'
|
|
@@ -80,11 +80,13 @@
|
|
|
80
80
|
return cache[name].exports;
|
|
81
81
|
|
|
82
82
|
function localRequire(x) {
|
|
83
|
-
|
|
83
|
+
var res = localRequire.resolve(x);
|
|
84
|
+
return res === false ? {} : newRequire(res);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
function resolve(x) {
|
|
87
|
-
|
|
88
|
+
var id = modules[name][1][x];
|
|
89
|
+
return id != null ? id : x;
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -99,9 +101,9 @@
|
|
|
99
101
|
newRequire.modules = modules;
|
|
100
102
|
newRequire.cache = cache;
|
|
101
103
|
newRequire.parent = previousRequire;
|
|
102
|
-
newRequire.register = function(id, exports) {
|
|
104
|
+
newRequire.register = function (id, exports) {
|
|
103
105
|
modules[id] = [
|
|
104
|
-
function(require, module) {
|
|
106
|
+
function (require, module) {
|
|
105
107
|
module.exports = exports;
|
|
106
108
|
},
|
|
107
109
|
{},
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
};
|
|
110
112
|
|
|
111
113
|
Object.defineProperty(newRequire, 'root', {
|
|
112
|
-
get: function() {
|
|
114
|
+
get: function () {
|
|
113
115
|
return globalObject[parcelRequireName];
|
|
114
116
|
},
|
|
115
117
|
});
|
|
@@ -131,7 +133,7 @@
|
|
|
131
133
|
|
|
132
134
|
// RequireJS
|
|
133
135
|
} else if (typeof define === 'function' && define.amd) {
|
|
134
|
-
define(function() {
|
|
136
|
+
define(function () {
|
|
135
137
|
return mainExports;
|
|
136
138
|
});
|
|
137
139
|
|
|
@@ -140,244 +142,211 @@
|
|
|
140
142
|
this[globalName] = mainExports;
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
|
-
})({"
|
|
145
|
+
})({"41qn9":[function(require,module,exports) {
|
|
144
146
|
/**
|
|
145
|
-
* @file Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.
|
|
146
|
-
* @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}
|
|
147
|
-
* @author JohT
|
|
148
|
-
* @version ${project.version}
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
var module = templateResolverInternalCreateIfNotExists(module);
|
|
152
|
-
// Fallback for vanilla js without modules
|
|
147
|
+
* @file Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.
|
|
148
|
+
* @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}
|
|
149
|
+
* @author JohT
|
|
150
|
+
* @version ${project.version}
|
|
151
|
+
*/ "use strict";
|
|
152
|
+
var module = templateResolverInternalCreateIfNotExists(module); // Fallback for vanilla js without modules
|
|
153
153
|
function templateResolverInternalCreateIfNotExists(objectToCheck) {
|
|
154
|
-
|
|
154
|
+
return objectToCheck || {
|
|
155
|
+
};
|
|
155
156
|
}
|
|
156
157
|
/**
|
|
157
|
-
* Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.
|
|
158
|
-
* @module template_resolver
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
// Export module for npm...
|
|
158
|
+
* Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.
|
|
159
|
+
* @module template_resolver
|
|
160
|
+
*/ var template_resolver = module.exports = {
|
|
161
|
+
}; // Export module for npm...
|
|
162
162
|
template_resolver.internalCreateIfNotExists = templateResolverInternalCreateIfNotExists;
|
|
163
|
-
var internal_object_tools = internal_object_tools || require("../../lib/js/flattenToArray");
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var removeArrayBracketsRegEx = new RegExp("\\[\\d+\\]", "gi");
|
|
167
|
-
/**
|
|
168
|
-
* Resolver. Is used inside this repository. It could also be used outside.
|
|
169
|
-
* @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.
|
|
170
|
-
* @constructs Resolver
|
|
171
|
-
* @alias module:template_resolver.Resolver
|
|
172
|
-
*/
|
|
173
|
-
function Resolver(sourceDataObject) {
|
|
174
|
-
/**
|
|
175
|
-
* The properties of this source data object will be used to replace the placeholders in the template.
|
|
176
|
-
*/
|
|
177
|
-
this.sourceDataObject = sourceDataObject;
|
|
178
|
-
/**
|
|
179
|
-
* Resolves the given template.
|
|
180
|
-
*
|
|
181
|
-
* The template may contain variables in double curly brackets.
|
|
182
|
-
* Supported variables are all properties of this object, e.g. "{{fieldName}}", "{{displayName}}", "{{value}}".
|
|
183
|
-
* Since this object may also contains (described) groups of sub objects, they can also be used, e.g. "{{summaries[0].value}}"
|
|
184
|
-
* Parts of the index can be inserted by using e.g. "{{index[1]}}".
|
|
185
|
-
*
|
|
186
|
-
* @param {string} template
|
|
187
|
-
* @returns {string} resolved template
|
|
188
|
-
*/
|
|
189
|
-
this.resolveTemplate = function (template) {
|
|
190
|
-
return this.replaceResolvableFields(template, addFieldsPerGroup(this.resolvableFieldsOfAll(this.sourceDataObject)));
|
|
191
|
-
};
|
|
163
|
+
var internal_object_tools = internal_object_tools || require("../../lib/js/flattenToArray"); // supports vanilla js & npm
|
|
164
|
+
template_resolver.Resolver = (function() {
|
|
165
|
+
var removeArrayBracketsRegEx = new RegExp("\\[\\d+\\]", "gi");
|
|
192
166
|
/**
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
// TODO could make "fieldName" and "value" configurable
|
|
258
|
-
if (propertyInfo.name === "fieldName" && propertyValue !== "fieldName") {
|
|
259
|
-
map[propertyInfo.groupWithoutArrayIndices + propertyValue] = map[propertyInfo.group + "value"];
|
|
260
|
-
}
|
|
167
|
+
* Resolver. Is used inside this repository. It could also be used outside.
|
|
168
|
+
* @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.
|
|
169
|
+
* @constructs Resolver
|
|
170
|
+
* @alias module:template_resolver.Resolver
|
|
171
|
+
*/ function Resolver(sourceDataObject) {
|
|
172
|
+
/**
|
|
173
|
+
* The properties of this source data object will be used to replace the placeholders in the template.
|
|
174
|
+
*/ this.sourceDataObject = sourceDataObject;
|
|
175
|
+
/**
|
|
176
|
+
* Resolves the given template.
|
|
177
|
+
*
|
|
178
|
+
* The template may contain variables in double curly brackets.
|
|
179
|
+
* Supported variables are all properties of this object, e.g. "{{fieldName}}", "{{displayName}}", "{{value}}".
|
|
180
|
+
* Since this object may also contains (described) groups of sub objects, they can also be used, e.g. "{{summaries[0].value}}"
|
|
181
|
+
* Parts of the index can be inserted by using e.g. "{{index[1]}}".
|
|
182
|
+
*
|
|
183
|
+
* @param {string} template
|
|
184
|
+
* @returns {string} resolved template
|
|
185
|
+
*/ this.resolveTemplate = function(template) {
|
|
186
|
+
return this.replaceResolvableFields(template, addFieldsPerGroup(this.resolvableFieldsOfAll(this.sourceDataObject)));
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Returns a map like object, that contains all resolvable fields and their values as properties.
|
|
190
|
+
* This function takes a variable count of input parameters,
|
|
191
|
+
* each containing an object that contains resolvable fields to extract from.
|
|
192
|
+
*
|
|
193
|
+
* The recursion depth is limited to 3, so that an object,
|
|
194
|
+
* that contains an object can contain another object (but not further).
|
|
195
|
+
*
|
|
196
|
+
* Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.
|
|
197
|
+
*
|
|
198
|
+
* @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.
|
|
199
|
+
* @returns {object} object with resolvable field names and their values.
|
|
200
|
+
* @public
|
|
201
|
+
*/ this.resolvableFieldsOfAll = function() {
|
|
202
|
+
var map = {
|
|
203
|
+
};
|
|
204
|
+
var ignoreInternalFields = function(propertyName) {
|
|
205
|
+
return propertyName.indexOf("_") !== 0 && propertyName.indexOf("._") < 0;
|
|
206
|
+
};
|
|
207
|
+
var index;
|
|
208
|
+
for(index = 0; index < arguments.length; index += 1)addToFilteredMapObject(internal_object_tools.flattenToArray(arguments[index], 3), map, ignoreInternalFields);
|
|
209
|
+
return map;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Replaces all variables in double curly brackets, e.g. {{property}},
|
|
213
|
+
* with the value of that property from the resolvableProperties.
|
|
214
|
+
*
|
|
215
|
+
* Supported property types: string, number, boolean
|
|
216
|
+
* @param {string} stringContainingVariables
|
|
217
|
+
* @param {object[]} resolvableFields (name=value)
|
|
218
|
+
*/ this.replaceResolvableFields = function(stringContainingVariables, resolvableFields) {
|
|
219
|
+
var replaced = stringContainingVariables;
|
|
220
|
+
var propertyNames = Object.keys(resolvableFields);
|
|
221
|
+
var propertyIndex = 0;
|
|
222
|
+
var propertyName = "";
|
|
223
|
+
var propertyValue = "";
|
|
224
|
+
for(propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1){
|
|
225
|
+
propertyName = propertyNames[propertyIndex];
|
|
226
|
+
propertyValue = resolvableFields[propertyName];
|
|
227
|
+
replaced = replaced.replace("{{" + propertyName + "}}", propertyValue);
|
|
228
|
+
}
|
|
229
|
+
return replaced;
|
|
230
|
+
};
|
|
261
231
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
232
|
+
/**
|
|
233
|
+
* Adds the value of the "fieldName" property (including its group prefix) and its associated "value" property content.
|
|
234
|
+
* For example: detail[2].fieldName="name", detail[2].value="Smith" lead to the additional property detail.name="Smith".
|
|
235
|
+
* @param {object} object with resolvable field names and their values.
|
|
236
|
+
* @returns {object} object with resolvable field names and their values.
|
|
237
|
+
* @protected
|
|
238
|
+
* @memberof module:template_resolver.Resolver
|
|
239
|
+
*/ function addFieldsPerGroup(map) {
|
|
240
|
+
var propertyNames = Object.keys(map);
|
|
241
|
+
var i, fullPropertyName, propertyInfo, propertyValue;
|
|
242
|
+
for(i = 0; i < propertyNames.length; i += 1){
|
|
243
|
+
fullPropertyName = propertyNames[i];
|
|
244
|
+
propertyValue = map[fullPropertyName];
|
|
245
|
+
propertyInfo = getPropertyNameInfos(fullPropertyName);
|
|
246
|
+
// Supports fields that are defined by a property named "fieldName" (containing the name)
|
|
247
|
+
// and a property named "value" inside the same sub object (containing its value).
|
|
248
|
+
// Ignore custom fields that are named "fieldName"(propertyValue), since this would lead to an unpredictable behavior.
|
|
249
|
+
// TODO could make "fieldName" and "value" configurable
|
|
250
|
+
if (propertyInfo.name === "fieldName" && propertyValue !== "fieldName") map[propertyInfo.groupWithoutArrayIndices + propertyValue] = map[propertyInfo.group + "value"];
|
|
251
|
+
}
|
|
252
|
+
return map;
|
|
276
253
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.
|
|
256
|
+
* @param {String} fullPropertyName
|
|
257
|
+
* @returns {Object} Contains "group" (empty or group name including trailing separator "."), "groupWithoutArrayIndices" and "name" (property name).
|
|
258
|
+
* @protected
|
|
259
|
+
* @memberof module:template_resolver.Resolver
|
|
260
|
+
*/ function getPropertyNameInfos(fullPropertyName) {
|
|
261
|
+
var positionOfRightMostSeparator = fullPropertyName.lastIndexOf(".");
|
|
262
|
+
var propertyName = fullPropertyName;
|
|
263
|
+
if (positionOfRightMostSeparator > 0) propertyName = fullPropertyName.substr(positionOfRightMostSeparator + 1);
|
|
264
|
+
var propertyGroup = "";
|
|
265
|
+
if (positionOfRightMostSeparator > 0) propertyGroup = fullPropertyName.substr(0, positionOfRightMostSeparator + 1); //includes the trailing ".".
|
|
266
|
+
var propertyGroupWithoutArrayIndices = propertyGroup.replace(removeArrayBracketsRegEx, "");
|
|
267
|
+
return {
|
|
268
|
+
group: propertyGroup,
|
|
269
|
+
groupWithoutArrayIndices: propertyGroupWithoutArrayIndices,
|
|
270
|
+
name: propertyName
|
|
271
|
+
};
|
|
280
272
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
*/
|
|
298
|
-
function addToFilteredMapObject(elements, mapObject, filterMatchesFunction) {
|
|
299
|
-
var index, element;
|
|
300
|
-
for (index = 0; index < elements.length; index += 1) {
|
|
301
|
-
element = elements[index];
|
|
302
|
-
if (typeof filterMatchesFunction === "function" && filterMatchesFunction(element.name)) {
|
|
303
|
-
mapObject[element.name] = element.value;
|
|
304
|
-
}
|
|
273
|
+
/**
|
|
274
|
+
* Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).
|
|
275
|
+
* Example: `{name: "accountNumber", value: "12345"}` becomes `mapObject["accountNumber"]="12345"`.
|
|
276
|
+
*
|
|
277
|
+
* @param {NameValuePair[]} elements flattened array of name-value-pairs
|
|
278
|
+
* @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.
|
|
279
|
+
* @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).
|
|
280
|
+
* @protected
|
|
281
|
+
* @memberof module:template_resolver.Resolver
|
|
282
|
+
*/ function addToFilteredMapObject(elements, mapObject, filterMatchesFunction) {
|
|
283
|
+
var index, element;
|
|
284
|
+
for(index = 0; index < elements.length; index += 1){
|
|
285
|
+
element = elements[index];
|
|
286
|
+
if (typeof filterMatchesFunction === "function" && filterMatchesFunction(element.name)) mapObject[element.name] = element.value;
|
|
287
|
+
}
|
|
288
|
+
return mapObject;
|
|
305
289
|
}
|
|
306
|
-
return
|
|
307
|
-
}
|
|
308
|
-
return Resolver;
|
|
290
|
+
return Resolver;
|
|
309
291
|
})();
|
|
310
292
|
|
|
311
|
-
},{"../../lib/js/flattenToArray":"
|
|
293
|
+
},{"../../lib/js/flattenToArray":"ipjOk"}],"ipjOk":[function(require,module,exports) {
|
|
312
294
|
"use strict";
|
|
313
295
|
/**
|
|
314
|
-
* @fileOverview Modded (compatibility, recursion depth) version of: https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss
|
|
315
|
-
* @version ${project.version}
|
|
316
|
-
* @see {@link https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss|stackoverflow flatten nested json objects}
|
|
317
|
-
*/
|
|
318
|
-
|
|
319
|
-
// Fallback for vanilla js without modules
|
|
320
|
-
/**
|
|
321
|
-
* internal_object_tools. Not meant to be used outside this repository.
|
|
322
|
-
* @default {}
|
|
323
|
-
*/
|
|
324
|
-
var internal_object_tools = module.exports = {};
|
|
325
|
-
// Export module for npm...
|
|
296
|
+
* @fileOverview Modded (compatibility, recursion depth) version of: https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss
|
|
297
|
+
* @version ${project.version}
|
|
298
|
+
* @see {@link https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss|stackoverflow flatten nested json objects}
|
|
299
|
+
*/ var module = module || {
|
|
300
|
+
}; // Fallback for vanilla js without modules
|
|
326
301
|
/**
|
|
327
|
-
*
|
|
328
|
-
* @
|
|
329
|
-
|
|
330
|
-
|
|
302
|
+
* internal_object_tools. Not meant to be used outside this repository.
|
|
303
|
+
* @default {}
|
|
304
|
+
*/ var internal_object_tools = module.exports = {
|
|
305
|
+
}; // Export module for npm...
|
|
331
306
|
/**
|
|
332
|
-
* @
|
|
333
|
-
* @
|
|
334
|
-
* @
|
|
335
|
-
*/
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
name: prop,
|
|
348
|
-
value: cur
|
|
349
|
-
});
|
|
350
|
-
} else if (Array.isArray(cur)) {
|
|
351
|
-
var i;
|
|
352
|
-
var l = cur.length;
|
|
353
|
-
for (i = 0; i < l; i += 1) {
|
|
354
|
-
recurse(cur[i], prop + "[" + i + "]", depth + 1);
|
|
355
|
-
}
|
|
356
|
-
if (l === 0) {
|
|
357
|
-
result[prop] = [];
|
|
358
|
-
result.push({
|
|
359
|
-
name: prop,
|
|
360
|
-
value: ""
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
} else {
|
|
364
|
-
var isEmpty = true;
|
|
365
|
-
var p;
|
|
366
|
-
for (p in cur) {
|
|
367
|
-
isEmpty = false;
|
|
368
|
-
recurse(cur[p], prop ? prop + "." + p : p, depth + 1);
|
|
369
|
-
}
|
|
370
|
-
if (isEmpty && prop) {
|
|
371
|
-
result.push({
|
|
372
|
-
name: prop,
|
|
373
|
-
value: ""
|
|
307
|
+
* @typedef {Object} NameValuePair
|
|
308
|
+
* @property {string} name - point separated names of the flattened main and sub properties, e.g. "responses[2].hits.hits[4]._source.name".
|
|
309
|
+
* @property {string} value - value of the property
|
|
310
|
+
*/ /**
|
|
311
|
+
* @param {object} data hierarchical object that may consist fo fields, subfields and arrays.
|
|
312
|
+
* @param {number} maxRecursionDepth
|
|
313
|
+
* @returns {NameValuePair[]} array of property name and value pairs
|
|
314
|
+
*/ internal_object_tools.flattenToArray = function(data, maxRecursionDepth) {
|
|
315
|
+
var result = [];
|
|
316
|
+
if (typeof maxRecursionDepth !== "number" || maxRecursionDepth < 1) maxRecursionDepth = 20;
|
|
317
|
+
function recurse(cur, prop, depth) {
|
|
318
|
+
if (depth > maxRecursionDepth || typeof cur === "function") return;
|
|
319
|
+
if (Object(cur) !== cur) result.push({
|
|
320
|
+
name: prop,
|
|
321
|
+
value: cur
|
|
374
322
|
});
|
|
375
|
-
|
|
323
|
+
else if (Array.isArray(cur)) {
|
|
324
|
+
var i;
|
|
325
|
+
var l = cur.length;
|
|
326
|
+
for(i = 0; i < l; i += 1)recurse(cur[i], prop + "[" + i + "]", depth + 1);
|
|
327
|
+
if (l === 0) {
|
|
328
|
+
result[prop] = [];
|
|
329
|
+
result.push({
|
|
330
|
+
name: prop,
|
|
331
|
+
value: ""
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
} else {
|
|
335
|
+
var isEmpty = true;
|
|
336
|
+
var p;
|
|
337
|
+
for(p in cur){
|
|
338
|
+
isEmpty = false;
|
|
339
|
+
recurse(cur[p], prop ? prop + "." + p : p, depth + 1);
|
|
340
|
+
}
|
|
341
|
+
if (isEmpty && prop) result.push({
|
|
342
|
+
name: prop,
|
|
343
|
+
value: ""
|
|
344
|
+
});
|
|
345
|
+
}
|
|
376
346
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return result;
|
|
347
|
+
recurse(data, "", 0);
|
|
348
|
+
return result;
|
|
380
349
|
};
|
|
381
350
|
|
|
382
|
-
},{}]},["
|
|
351
|
+
},{}]},["41qn9"], "41qn9", "parcelRequirec1f2")
|
|
383
352
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),Array.prototype.filter||(Array.prototype.filter=function(e,t){if("Function"!=typeof e&&"function"!=typeof e||!this)throw new TypeError;var r,i=this.length>>>0,n=new Array(i),o=this,a=0,s=-1;if(void 0===t)for(;++s!==i;)s in this&&(r=o[s],e(o[s],s,o)&&(n[a++]=r));else for(;++s!==i;)s in this&&(r=o[s],e.call(t,o[s],s,o)&&(n[a++]=r));return n.length=a,n}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t,r){return function(i,n){if(null==this)throw TypeError("Array.prototype.indexOf called on null or undefined");var o=e(this),a=o.length>>>0,s=r(0|n,a);if(s<0)s=t(0,a+s);else if(s>=a)return-1;if(void 0===i){for(;s!==a;++s)if(void 0===o[s]&&s in o)return s}else if(i!=i){for(;s!==a;++s)if(o[s]!=o[s])return s}else for(;s!==a;++s)if(o[s]===i)return s;return-1}}(Object,Math.max,Math.min)),Object.keys||(Object.keys=function(e){if(e!==Object(e))throw new TypeError("Object.keys called on a non-object");var t,r=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.push(t);return r});var e=t(e);function t(e){return e||{}}var r=e.exports={};r.internalCreateIfNotExists=t;var i,n,o=!1;function a(){return o||(o=!0,i={},((n=n||{}).exports={}).flattenToArray=function(e,t){var r=[];return("number"!=typeof t||t<1)&&(t=20),function e(i,n,o){if(!(o>t||"function"==typeof i))if(Object(i)!==i)r.push({name:n,value:i});else if(Array.isArray(i)){var a,s=i.length;for(a=0;a<s;a+=1)e(i[a],n+"["+a+"]",o+1);0===s&&(r[n]=[],r.push({name:n,value:""}))}else{var u,c=!0;for(u in i)c=!1,e(i[u],n?n+"."+u:u,o+1);c&&n&&r.push({name:n,value:""})}}(e,"",0),r}),i}var s,u,c,l,p=p||a(),d=!1;function h(e){return e||{}}function f(){s={},u=h(u),(c=u.exports={}).internalCreateIfNotExists=h,l=l||a(),c.Resolver=function(){var e=new RegExp("\\[\\d+\\]","gi");function t(t){var r=t.lastIndexOf("."),i=t;r>0&&(i=t.substr(r+1));var n="";r>0&&(n=t.substr(0,r+1));var o=n.replace(e,"");return{group:n,groupWithoutArrayIndices:o,name:i}}function r(e,t,r){var i,n;for(i=0;i<e.length;i+=1)n=e[i],"function"==typeof r&&r(n.name)&&(t[n.name]=n.value);return t}return function(e){this.sourceDataObject=e,this.resolveTemplate=function(e){return this.replaceResolvableFields(e,function(e){var r,i,n,o,a=Object.keys(e);for(r=0;r<a.length;r+=1)o=e[i=a[r]],"fieldName"===(n=t(i)).name&&"fieldName"!==o&&(e[n.groupWithoutArrayIndices+o]=e[n.group+"value"]);return e}(this.resolvableFieldsOfAll(this.sourceDataObject)))},this.resolvableFieldsOfAll=function(){var e,t={},i=function(e){return 0!==e.indexOf("_")&&e.indexOf("._")<0};for(e=0;e<arguments.length;e+=1)r(l.flattenToArray(arguments[e],3),t,i);return t},this.replaceResolvableFields=function(e,t){var r=e,i=Object.keys(t),n=0,o="",a="";for(n=0;n<i.length;n+=1)a=t[o=i[n]],r=r.replace("{{"+o+"}}",a);return r}}}()}var g,m,y,v=v||(d||(d=!0,f()),s),b=!1;function N(e){return e||{}}var D,F=F||(b||(b=!0,g={},m=N(m),(y=m.exports={}).internalCreateIfNotExists=N,y.DescribedDataFieldBuilder=function(){function e(e,t){return function(e){return"string"==typeof e&&null!==e&&""!==e}(e)?e:t}function t(e,t){return null==e?t:e}return function(){this.describedField={category:"",type:"",abbreviation:"",image:"",index:[],groupNames:[],displayName:"",fieldName:"",value:""},this.fromDescribedDataField=function(e){return this.category(e.category),this.type(e.type),this.abbreviation(e.abbreviation),this.image(e.image),this.index(e.index),this.groupNames(e.groupNames),this.displayName(e.displayName),this.fieldName(e.fieldName),this.value(e.value),this},this.category=function(t){return this.describedField.category=e(t,""),this},this.type=function(t){return this.describedField.type=e(t,""),this},this.abbreviation=function(t){return this.describedField.abbreviation=e(t,""),this},this.image=function(t){return this.describedField.image=e(t,""),this},this.index=function(e){return this.describedField.index=t(e,[]),this},this.groupNames=function(e){return this.describedField.groupNames=t(e,[]),this},this.displayName=function(t){return this.describedField.displayName=e(t,""),this},this.fieldName=function(t){return this.describedField.fieldName=e(t,""),this},this.value=function(e){return this.describedField.value=e,this},this.build=function(){return this.describedField}}}(),y.copyWithoutGroups=function(e){return(new y.DescribedDataFieldBuilder).fromDescribedDataField(e).groupNames([]).build()},y.DescribedDataFieldGroup=function(e){this.dataField=e,this.addGroupEntry=function(e,t){return this.addGroupEntries(e,[t]),this},this.addGroupEntries=function(e,t){if(!e||0===e.length)return this;if(!t||0===t.length)return this;var r,i;for(void 0===this.dataField[e]&&(this.dataField.groupNames.push(e),this.dataField[e]=[]),r=0;r<t.length;r+=1)i=t[r],this.dataField[e].push(i);return this}}),g);r.PropertyStructureDescriptionBuilder=function(){function e(e,i){if(o(e))return function(){return e};if(i.propertyPatternTemplateMode){var n=i.propertyPattern;return a=n,function(e){var i=r(a,"{{fieldName}}").exec(e);return i&&""!=i[1]?i[1]:t(e)}}var a;return function(e){return t(e)}}function t(e){var t=new RegExp("(\\w+)$","gi"),r=e.match(t);return null!=r?r[0]:e}function r(e,t){var r=i(e);return"string"==typeof t&&(t=i(t)),r="^"+(r=r.replace(t,"([-\\w]+)")),new RegExp(r,"i")}function i(e){var t=new RegExp("([^-\\w])","gi");return e.replace(t,"\\$1")}function n(e,t){return o(e)?e:t}function o(e){return"string"==typeof e&&null!=e&&""!=e}return function(){this.description={type:"",category:"",abbreviation:"",image:"",propertyPatternTemplateMode:!1,propertyPattern:"",indexStartsWith:"",groupName:"group",groupPattern:"",groupDestinationPattern:"",groupDestinationName:null,deduplicationPattern:"",getDisplayNameForPropertyName:null,getFieldNameForPropertyName:null,matchesPropertyName:null},this.type=function(e){return this.description.type=n(e,""),this},this.category=function(e){return this.description.category=n(e,""),this},this.abbreviation=function(e){return this.description.abbreviation=n(e,""),this},this.image=function(e){return this.description.image=n(e,""),this},this.propertyPatternEqualMode=function(){return this.description.propertyPatternTemplateMode=!1,this},this.propertyPatternTemplateMode=function(){return this.description.propertyPatternTemplateMode=!0,this},this.propertyPattern=function(e){return this.description.propertyPattern=n(e,""),this},this.indexStartsWith=function(e){return this.description.indexStartsWith=n(e,""),this},this.displayPropertyName=function(t){return this.description.getDisplayNameForPropertyName=e(t,this.description),o(t)||(this.description.getDisplayNameForPropertyName=(r=this.description.getDisplayNameForPropertyName,function(e){var t=r(e);return(t=null!=t?t:"").replace("_comma_separated_values","")}),this.description.getDisplayNameForPropertyName=function(e){return function(t){return function(e){if(e.length>1)return e.charAt(0).toUpperCase()+e.slice(1);return e}(e(t))}}(this.description.getDisplayNameForPropertyName)),this;var r},this.fieldName=function(t){return this.description.getFieldNameForPropertyName=e(t,this.description),this},this.groupName=function(e){return this.description.groupName=n(e,""),this},this.groupPattern=function(e){return this.description.groupPattern=n(e,""),this},this.groupDestinationPattern=function(e){return this.description.groupDestinationPattern=n(e,""),this},this.groupDestinationName=function(e){return this.description.groupDestinationName=n(e,this.description.groupName),this},this.deduplicationPattern=function(e){return this.description.deduplicationPattern=n(e,""),this},this.build=function(){return this.description.matchesPropertyName=function(e){var t=e.propertyPattern;if(!o(t))return function(){return!1};if(e.propertyPatternTemplateMode)return function(e){return null!=(i=t,n=new RegExp("\\\\\\{\\\\\\{[-\\w]+\\\\\\}\\\\\\}","gi"),r(i,n)).exec(e);var i,n};return function(e){return e===t}}(this.description),null==this.description.getDisplayNameForPropertyName&&this.displayPropertyName(""),null==this.description.getFieldNameForPropertyName&&this.fieldName(""),null==this.description.groupDestinationName&&this.groupDestinationName(""),this.description}}}(),r.DescribedEntryCreator=(D=new RegExp("\\[\\d+\\]","gi"),function(e,t){var r,i,n=(r=e.name,i=new RegExp("\\[(\\d+)\\]","gi"),function(e,t){var r,i="",n=[];do{(r=t.exec(e))&&(i.length>0&&(i+="."),i+=r[1],n.push(parseInt(r[1])))}while(r);return{pointDelimited:i,numberArray:n}}(r,i)),o=e.name.replace(D,""),a=new v.Resolver(this);this.category=t.category,this.type=t.type,this.abbreviation=t.abbreviation,this.image=t.image,this.index=n.numberArray,this.displayName=t.getDisplayNameForPropertyName(o),this.fieldName=t.getFieldNameForPropertyName(o),this.value=e.value,this.groupNames=[],this._isMatchingIndex=0==n.pointDelimited.indexOf(t.indexStartsWith),this._description=t,this._identifier={index:n.pointDelimited,propertyNameWithArrayIndices:e.name,propertyNameWithoutArrayIndices:o,groupId:"",groupDestinationId:"",deduplicationId:""},this._identifier.groupId=a.replaceResolvableFields(t.groupPattern,a.resolvableFieldsOfAll(this,this._description,this._identifier)),this._identifier.groupDestinationId=a.replaceResolvableFields(t.groupDestinationPattern,a.resolvableFieldsOfAll(this,this._description,this._identifier)),this._identifier.deduplicationId=a.replaceResolvableFields(t.deduplicationPattern,a.resolvableFieldsOfAll(this,this._description,this._identifier)),this.addGroupEntry=function(e,t){this.addGroupEntries(e,[t])},this.addGroupEntries=function(e,t){var r,i;for(this[e]||(this.groupNames.push(e),this[e]=[]),r=0;r<t.length;r+=1)i=t[r],this[e].push(i)}}),r.Transform=function(){function e(e,t,r){var i,n,o,a=function(e,t){for(var r=new Object,i=0;i<e.length;i++){var n=e[i];r[t(n)]=n}return r}(t,r),s=[];for(i=0;i<e.length;i+=1)null!=(o=r(n=e[i]))&&""!==o&&null!=a[o]||s.push(n);for(i=0;i<t.length;i+=1)n=t[i],s.push(n);return s}function t(t,r){if(null==t||0==t.length)return r;return e(t,r,(function(e){return e._identifier.deduplicationId}))}function i(e,t){var i=new RegExp("\\[\\d+\\]","gi"),n=[];return e.filter((function(e){var o=e.name.replace(i,"");if(t.matchesPropertyName(o)){var a=new r.DescribedEntryCreator(e,t);a._isMatchingIndex&&n.push(a)}})),n}function n(e,t){var r=(new F.DescribedDataFieldBuilder).category(e.category).type(e.type).abbreviation(e.abbreviation).image(e.image).index(e.index).displayName(e.displayName).fieldName(e.fieldName).value(e.value).build();if(t.recursionDepth>t.config.maxRecursionDepth)return r;var i=null,a="",s=new F.DescribedDataFieldGroup(r);return function(e,t){var r,i,n;for(r=0;r<e.groupNames.length;r+=1)for(n=e.groupNames[r],i=0;i<e[n].length;i+=1)t(n,e[n][i],e[n])}(e,(function(e,r,u){t.groupToSkip!==e?(a="",t.recursionDepth>=t.config.removeDuplicationAboveRecursionDepth&&(a=function(e,t,r){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var i=0;i<e.length;++i)if(!r(e[i],t[i]))return!1;return!0}(r[e],u,o)?e:""),i={recursionDepth:t.recursionDepth+1,config:t.config,groupToSkip:a},s.addGroupEntry(e,n(r,i))):t.config.debugMode&&console.log("Removed duplicate group "+e+" at recursion depth "+t.recursionDepth)})),r}function o(e,t){return a(e.category)===a(t.category)&&a(e.type)===a(t.type)&&e.fieldName===t.fieldName&&e.value===t.value}function a(e){return function(e,t){if(void 0===e||!e)return t;return e}(e,"")}return function(e){this.descriptions=e,this.config={debugMode:!1,maxRecursionDepth:8,removeDuplicationAboveRecursionDepth:1},this.enableDebugMode=function(){return this.config.debugMode=!0,this},this.setMaxRecursionDepth=function(e){if("number"!=typeof e||e<0)throw"Invalid max recursion depth value: "+e;return this.config.maxRecursionDepth=e,this},this.setRemoveDuplicationAboveRecursionDepth=function(e){if("number"!=typeof e||e<0)throw"Invalid remove duplications above recursion depth value: "+e;return this.config.removeDuplicationAboveRecursionDepth=e,this},this.processJson=function(e){return function(e,r,o){var a=p.flattenToArray(e);a=function(e){var t=new RegExp("\\[\\d+\\]$","gi"),r=[],i="",n="";return e.filter((function(e){if(!e.name.match(t))return""!==i&&(r.push({name:i+"_comma_separated_values",value:n}),i=""),void r.push(e);var o=e.name.replace(t,"");i===o?n+=", "+e.value:(""!==i&&(r.push({name:i+"_comma_separated_values",value:n}),i=""),i=o,n=e.value),r.push(e)})),r}(a),o.debugMode&&(console.log("flattened data with array values:"),console.log(a));var s,u=[];for(s=0;s<r.length;s+=1)u=t(u,i(a,r[s]));a=u,o.debugMode&&(console.log("describedData data:"),console.log(a));a=function(e){return function(e,t,r){for(var i=new Object,n=0;n<e.length;n++){var o=e[n],a=t(o);if(""!==a){var s=r(o);null!=s&&""!==s&&(i[a]||(i[a]=o),i[a].addGroupEntry(s,o))}}return i}(e,(function(e){return e._identifier.groupId}),(function(e){return e._description.groupName}))}(a),o.debugMode&&(console.log("grouped describedData data:"),console.log(a));a=function(e){for(var t=Object.keys(e),r=[],i=0;i<t.length;i++){var n=t[i],o=e[n];if(""!=o._description.groupDestinationPattern){var a=o._identifier.groupDestinationId;if(null!=e[a]){var s=o[o._description.groupName];e[a].addGroupEntries(o._description.groupDestinationName,s),r.push(n)}}}for(i=0;i<r.length;i+=1){delete e[r[i]]}return e}(a),o.debugMode&&(console.log("moved grouped describedData data:"),console.log(a));a=function(e,t){var r,i,o=[];for(r=0;r<e.length;r+=1)i=e[r],o.push(n(i,{recursionDepth:0,config:t,groupToSkip:""}));return o}(a=function(e){for(var t=[],r=Object.keys(e),i=0;i<r.length;i++){var n=e[r[i]];t.push(n)}return t}(a),o),o.debugMode&&(console.log("transformed result:"),console.log(a));return a}(e,this.descriptions,this.config)}}}(),r.Restructor={},r.Restructor.processJsonUsingDescriptions=function(e,t,i){var n=new r.Transform(t);return i&&n.enableDebugMode(),n.processJson(e)};var x={};module.exports={datarestructor:x};
|
|
1
|
+
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},t={},r={},i=e.parcelRequirec1f2;null==i&&((i=function(e){if(e in t)return t[e].exports;if(e in r){var i=r[e];delete r[e];var n={id:e,exports:{}};return t[e]=n,i.call(n.exports,n,n.exports),n.exports}var o=new Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,t){r[e]=t},e.parcelRequirec1f2=i),i.register("6LZJB",(function(e,t){"use strict";var r=r||{};(r.exports={}).flattenToArray=function(e,t){var r=[];return("number"!=typeof t||t<1)&&(t=20),function e(i,n,o){if(!(o>t||"function"==typeof i))if(Object(i)!==i)r.push({name:n,value:i});else if(Array.isArray(i)){var a,s=i.length;for(a=0;a<s;a+=1)e(i[a],n+"["+a+"]",o+1);0===s&&(r[n]=[],r.push({name:n,value:""}))}else{var u,l=!0;for(u in i)l=!1,e(i[u],n?n+"."+u:u,o+1);l&&n&&r.push({name:n,value:""})}}(e,"",0),r}})),i.register("gIYWy",(function(e,t){"use strict";var r=n(r);function n(e){return e||{}}var o=r.exports={};o.internalCreateIfNotExists=n;var a=a||i("6LZJB");o.Resolver=function(){var e=new RegExp("\\[\\d+\\]","gi");function t(t){var r=t.lastIndexOf("."),i=t;r>0&&(i=t.substr(r+1));var n="";r>0&&(n=t.substr(0,r+1));var o=n.replace(e,"");return{group:n,groupWithoutArrayIndices:o,name:i}}function r(e,t,r){var i,n;for(i=0;i<e.length;i+=1)n=e[i],"function"==typeof r&&r(n.name)&&(t[n.name]=n.value);return t}return function(e){this.sourceDataObject=e,this.resolveTemplate=function(e){return this.replaceResolvableFields(e,function(e){var r,i,n,o,a=Object.keys(e);for(r=0;r<a.length;r+=1)o=e[i=a[r]],"fieldName"===(n=t(i)).name&&"fieldName"!==o&&(e[n.groupWithoutArrayIndices+o]=e[n.group+"value"]);return e}(this.resolvableFieldsOfAll(this.sourceDataObject)))},this.resolvableFieldsOfAll=function(){var e,t={},i=function(e){return 0!==e.indexOf("_")&&e.indexOf("._")<0};for(e=0;e<arguments.length;e+=1)r(a.flattenToArray(arguments[e],3),t,i);return t},this.replaceResolvableFields=function(e,t){var r=e,i=Object.keys(t),n=0,o="",a="";for(n=0;n<i.length;n+=1)a=t[o=i[n]],r=r.replace("{{"+o+"}}",a);return r}}}()})),i.register("1VoPT",(function(e,t){"use strict";var r=i(r);function i(e){return e||{}}var n=r.exports={};n.internalCreateIfNotExists=i,n.DescribedDataFieldBuilder=function(){function e(e,t){return function(e){return"string"==typeof e&&null!==e&&""!==e}(e)?e:t}function t(e,t){return null==e?t:e}return function(){this.describedField={category:"",type:"",abbreviation:"",image:"",index:[],groupNames:[],displayName:"",fieldName:"",value:""},this.fromDescribedDataField=function(e){return this.category(e.category),this.type(e.type),this.abbreviation(e.abbreviation),this.image(e.image),this.index(e.index),this.groupNames(e.groupNames),this.displayName(e.displayName),this.fieldName(e.fieldName),this.value(e.value),this},this.category=function(t){return this.describedField.category=e(t,""),this},this.type=function(t){return this.describedField.type=e(t,""),this},this.abbreviation=function(t){return this.describedField.abbreviation=e(t,""),this},this.image=function(t){return this.describedField.image=e(t,""),this},this.index=function(e){return this.describedField.index=t(e,[]),this},this.groupNames=function(e){return this.describedField.groupNames=t(e,[]),this},this.displayName=function(t){return this.describedField.displayName=e(t,""),this},this.fieldName=function(t){return this.describedField.fieldName=e(t,""),this},this.value=function(e){return this.describedField.value=e,this},this.build=function(){return this.describedField}}}(),n.copyWithoutGroups=function(e){return(new n.DescribedDataFieldBuilder).fromDescribedDataField(e).groupNames([]).build()},n.DescribedDataFieldGroup=function(e){this.dataField=e,this.addGroupEntry=function(e,t){return this.addGroupEntries(e,[t]),this},this.addGroupEntries=function(e,t){if(!e||0===e.length)return this;if(!t||0===t.length)return this;var r,i;for(void 0===this.dataField[e]&&(this.dataField.groupNames.push(e),this.dataField[e]=[]),r=0;r<t.length;r+=1)i=t[r],this.dataField[e].push(i);return this}}})),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),Array.prototype.filter||(Array.prototype.filter=function(e,t){if("Function"!=typeof e&&"function"!=typeof e||!this)throw new TypeError;var r,i=this.length>>>0,n=new Array(i),o=this,a=0,s=-1;if(void 0===t)for(;++s!==i;)s in this&&(r=o[s],e(o[s],s,o)&&(n[a++]=r));else for(;++s!==i;)s in this&&(r=o[s],e.call(t,o[s],s,o)&&(n[a++]=r));return n.length=a,n}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t,r){return function(i,n){if(null==this)throw TypeError("Array.prototype.indexOf called on null or undefined");var o=e(this),a=o.length>>>0,s=r(0|n,a);if(s<0)s=t(0,a+s);else if(s>=a)return-1;if(void 0===i){for(;s!==a;++s)if(void 0===o[s]&&s in o)return s}else if(i!=i){for(;s!==a;++s)if(o[s]!=o[s])return s}else for(;s!==a;++s)if(o[s]===i)return s;return-1}}(Object,Math.max,Math.min)),Object.keys||(Object.keys=function(e){if(e!==Object(e))throw new TypeError("Object.keys called on a non-object");var t,r=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.push(t);return r});var n=o(n);function o(e){return e||{}}var a=n.exports={};a.internalCreateIfNotExists=o;var s,u=u||i("6LZJB"),l=l||i("gIYWy"),c=c||i("1VoPT");a.PropertyStructureDescriptionBuilder=function(){function e(e,i){if(o(e))return function(){return e};if(i.propertyPatternTemplateMode){var n=i.propertyPattern;return a=n,function(e){var i=r(a,"{{fieldName}}").exec(e);return i&&""!=i[1]?i[1]:t(e)}}var a;return function(e){return t(e)}}function t(e){var t=new RegExp("(\\w+)$","gi"),r=e.match(t);return null!=r?r[0]:e}function r(e,t){var r=i(e);return"string"==typeof t&&(t=i(t)),r="^"+(r=r.replace(t,"([-\\w]+)")),new RegExp(r,"i")}function i(e){var t=new RegExp("([^-\\w])","gi");return e.replace(t,"\\$1")}function n(e,t){return o(e)?e:t}function o(e){return"string"==typeof e&&null!=e&&""!=e}return function(){this.description={type:"",category:"",abbreviation:"",image:"",propertyPatternTemplateMode:!1,propertyPattern:"",indexStartsWith:"",groupName:"group",groupPattern:"",groupDestinationPattern:"",groupDestinationName:null,deduplicationPattern:"",getDisplayNameForPropertyName:null,getFieldNameForPropertyName:null,matchesPropertyName:null},this.type=function(e){return this.description.type=n(e,""),this},this.category=function(e){return this.description.category=n(e,""),this},this.abbreviation=function(e){return this.description.abbreviation=n(e,""),this},this.image=function(e){return this.description.image=n(e,""),this},this.propertyPatternEqualMode=function(){return this.description.propertyPatternTemplateMode=!1,this},this.propertyPatternTemplateMode=function(){return this.description.propertyPatternTemplateMode=!0,this},this.propertyPattern=function(e){return this.description.propertyPattern=n(e,""),this},this.indexStartsWith=function(e){return this.description.indexStartsWith=n(e,""),this},this.displayPropertyName=function(t){return this.description.getDisplayNameForPropertyName=e(t,this.description),o(t)||(this.description.getDisplayNameForPropertyName=(r=this.description.getDisplayNameForPropertyName,function(e){var t=r(e);return(t=null!=t?t:"").replace("_comma_separated_values","")}),this.description.getDisplayNameForPropertyName=function(e){return function(t){return function(e){return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e}(e(t))}}(this.description.getDisplayNameForPropertyName)),this;var r},this.fieldName=function(t){return this.description.getFieldNameForPropertyName=e(t,this.description),this},this.groupName=function(e){return this.description.groupName=n(e,""),this},this.groupPattern=function(e){return this.description.groupPattern=n(e,""),this},this.groupDestinationPattern=function(e){return this.description.groupDestinationPattern=n(e,""),this},this.groupDestinationName=function(e){return this.description.groupDestinationName=n(e,this.description.groupName),this},this.deduplicationPattern=function(e){return this.description.deduplicationPattern=n(e,""),this},this.build=function(){var e,t;return this.description.matchesPropertyName=(e=this.description,o(t=e.propertyPattern)?e.propertyPatternTemplateMode?function(e){return null!=(i=t,n=new RegExp("\\\\\\{\\\\\\{[-\\w]+\\\\\\}\\\\\\}","gi"),r(i,n)).exec(e);var i,n}:function(e){return e===t}:function(){return!1}),null==this.description.getDisplayNameForPropertyName&&this.displayPropertyName(""),null==this.description.getFieldNameForPropertyName&&this.fieldName(""),null==this.description.groupDestinationName&&this.groupDestinationName(""),this.description}}}(),a.DescribedEntryCreator=(s=new RegExp("\\[\\d+\\]","gi"),function(e,t){var r,i,n=(r=e.name,i=new RegExp("\\[(\\d+)\\]","gi"),function(e,t){var r,i="",n=[];do{(r=t.exec(e))&&(i.length>0&&(i+="."),i+=r[1],n.push(parseInt(r[1])))}while(r);return{pointDelimited:i,numberArray:n}}(r,i)),o=e.name.replace(s,""),a=new l.Resolver(this);this.category=t.category,this.type=t.type,this.abbreviation=t.abbreviation,this.image=t.image,this.index=n.numberArray,this.displayName=t.getDisplayNameForPropertyName(o),this.fieldName=t.getFieldNameForPropertyName(o),this.value=e.value,this.groupNames=[],this._isMatchingIndex=0==n.pointDelimited.indexOf(t.indexStartsWith),this._description=t,this._identifier={index:n.pointDelimited,propertyNameWithArrayIndices:e.name,propertyNameWithoutArrayIndices:o,groupId:"",groupDestinationId:"",deduplicationId:""},this._identifier.groupId=a.replaceResolvableFields(t.groupPattern,a.resolvableFieldsOfAll(this,this._description,this._identifier)),this._identifier.groupDestinationId=a.replaceResolvableFields(t.groupDestinationPattern,a.resolvableFieldsOfAll(this,this._description,this._identifier)),this._identifier.deduplicationId=a.replaceResolvableFields(t.deduplicationPattern,a.resolvableFieldsOfAll(this,this._description,this._identifier)),this.addGroupEntry=function(e,t){this.addGroupEntries(e,[t])},this.addGroupEntries=function(e,t){var r,i;for(this[e]||(this.groupNames.push(e),this[e]=[]),r=0;r<t.length;r+=1)i=t[r],this[e].push(i)}}),a.Transform=function(){function e(e,t,r){var i,n,o,a=function(e,t){for(var r=new Object,i=0;i<e.length;i++){var n=e[i];r[t(n)]=n}return r}(t,r),s=[];for(i=0;i<e.length;i+=1)null!=(o=r(n=e[i]))&&""!==o&&null!=a[o]||s.push(n);for(i=0;i<t.length;i+=1)n=t[i],s.push(n);return s}function t(t,r){if(null==t||0==t.length)return r;return e(t,r,(function(e){return e._identifier.deduplicationId}))}function r(e,t){var r=new RegExp("\\[\\d+\\]","gi"),i=[];return e.filter((function(e){var n=e.name.replace(r,"");if(t.matchesPropertyName(n)){var o=new a.DescribedEntryCreator(e,t);o._isMatchingIndex&&i.push(o)}})),i}function i(e,t){var r=(new c.DescribedDataFieldBuilder).category(e.category).type(e.type).abbreviation(e.abbreviation).image(e.image).index(e.index).displayName(e.displayName).fieldName(e.fieldName).value(e.value).build();if(t.recursionDepth>t.config.maxRecursionDepth)return r;var o=null,a="",s=new c.DescribedDataFieldGroup(r);return function(e,t){var r,i,n;for(r=0;r<e.groupNames.length;r+=1)for(n=e.groupNames[r],i=0;i<e[n].length;i+=1)t(n,e[n][i],e[n])}(e,(function(e,r,u){t.groupToSkip!==e?(a="",t.recursionDepth>=t.config.removeDuplicationAboveRecursionDepth&&(a=function(e,t,r){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var i=0;i<e.length;++i)if(!r(e[i],t[i]))return!1;return!0}(r[e],u,n)?e:""),o={recursionDepth:t.recursionDepth+1,config:t.config,groupToSkip:a},s.addGroupEntry(e,i(r,o))):t.config.debugMode&&console.log("Removed duplicate group "+e+" at recursion depth "+t.recursionDepth)})),r}function n(e,t){return o(e.category)===o(t.category)&&o(e.type)===o(t.type)&&e.fieldName===t.fieldName&&e.value===t.value}function o(e){return function(e,t){return void 0!==e&&e?e:t}(e,"")}return function(e){this.descriptions=e,this.config={debugMode:!1,maxRecursionDepth:8,removeDuplicationAboveRecursionDepth:1},this.enableDebugMode=function(){return this.config.debugMode=!0,this},this.setMaxRecursionDepth=function(e){if("number"!=typeof e||e<0)throw"Invalid max recursion depth value: "+e;return this.config.maxRecursionDepth=e,this},this.setRemoveDuplicationAboveRecursionDepth=function(e){if("number"!=typeof e||e<0)throw"Invalid remove duplications above recursion depth value: "+e;return this.config.removeDuplicationAboveRecursionDepth=e,this},this.processJson=function(e){return function(e,n,o){var a=u.flattenToArray(e);a=function(e){var t=new RegExp("\\[\\d+\\]$","gi"),r=[],i="",n="";return e.filter((function(e){if(!e.name.match(t))return""!==i&&(r.push({name:i+"_comma_separated_values",value:n}),i=""),void r.push(e);var o=e.name.replace(t,"");i===o?n+=", "+e.value:(""!==i&&(r.push({name:i+"_comma_separated_values",value:n}),i=""),i=o,n=e.value),r.push(e)})),r}(a),o.debugMode&&(console.log("flattened data with array values:"),console.log(a));var s,l=[];for(s=0;s<n.length;s+=1)l=t(l,r(a,n[s]));a=l,o.debugMode&&(console.log("describedData data:"),console.log(a));a=function(e){return function(e,t,r){for(var i=new Object,n=0;n<e.length;n++){var o=e[n],a=t(o);if(""!==a){var s=r(o);null!=s&&""!==s&&(i[a]||(i[a]=o),i[a].addGroupEntry(s,o))}}return i}(e,(function(e){return e._identifier.groupId}),(function(e){return e._description.groupName}))}(a),o.debugMode&&(console.log("grouped describedData data:"),console.log(a));a=function(e){for(var t=Object.keys(e),r=[],i=0;i<t.length;i++){var n=t[i],o=e[n];if(""!=o._description.groupDestinationPattern){var a=o._identifier.groupDestinationId;if(null!=e[a]){var s=o[o._description.groupName];e[a].addGroupEntries(o._description.groupDestinationName,s),r.push(n)}}}for(i=0;i<r.length;i+=1){delete e[r[i]]}return e}(a),o.debugMode&&(console.log("moved grouped describedData data:"),console.log(a));a=function(e,t){var r,n,o=[];for(r=0;r<e.length;r+=1)n=e[r],o.push(i(n,{recursionDepth:0,config:t,groupToSkip:""}));return o}(a=function(e){for(var t=[],r=Object.keys(e),i=0;i<r.length;i++){var n=e[r[i]];t.push(n)}return t}(a),o),o.debugMode&&(console.log("transformed result:"),console.log(a));return a}(e,this.descriptions,this.config)}}}(),a.Restructor={},a.Restructor.processJsonUsingDescriptions=function(e,t,r){var i=new a.Transform(t);return r&&i.enableDebugMode(),i.processJson(e)},module.exports={datarestructor:{}};
|
|
2
2
|
//# sourceMappingURL=datarestructor-ie.js.map
|