data-restructor 3.3.4 → 3.4.1

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.
Files changed (49) hide show
  1. package/.auto-changelog +9 -0
  2. package/.auto-changelog-template.hbs +36 -0
  3. package/.github/workflows/codeql-analysis.yml +4 -4
  4. package/.github/workflows/continuous-integration.yaml +84 -0
  5. package/CHANGELOG.md +199 -94
  6. package/CONTRIBUTING.md +51 -43
  7. package/Commands.md +16 -15
  8. package/README.md +193 -137
  9. package/SECURITY.md +2 -2
  10. package/coverage/coverage-summary.json +3 -3
  11. package/coverage/datarestructor.js.html +133 -133
  12. package/coverage/describedfield.js.html +45 -45
  13. package/coverage/index.html +1 -1
  14. package/coverage/templateResolver.js.html +26 -26
  15. package/devdist/datarestructor-ie.js +1487 -1678
  16. package/devdist/datarestructor.js +1438 -1614
  17. package/devdist/describedfield-ie.js +260 -282
  18. package/devdist/describedfield.js +257 -279
  19. package/devdist/templateResolver-ie.js +221 -257
  20. package/devdist/templateResolver.js +192 -228
  21. package/dist/datarestructor-ie.js +1 -1
  22. package/dist/datarestructor-ie.js.map +1 -1
  23. package/dist/datarestructor.js +1 -1
  24. package/dist/datarestructor.js.map +1 -1
  25. package/dist/describedfield-ie.js +1 -1
  26. package/dist/describedfield-ie.js.map +1 -1
  27. package/dist/describedfield.js +1 -1
  28. package/dist/describedfield.js.map +1 -1
  29. package/dist/templateResolver-ie.js +1 -1
  30. package/dist/templateResolver-ie.js.map +1 -1
  31. package/dist/templateResolver.js +1 -1
  32. package/dist/templateResolver.js.map +1 -1
  33. package/docs/datarestructor.js.html +1 -1
  34. package/docs/describedfield.js.html +1 -1
  35. package/docs/index.html +54 -44
  36. package/docs/module-datarestructor.DescribedEntryCreator.html +94 -94
  37. package/docs/module-datarestructor.PropertyStructureDescriptionBuilder.html +1 -1
  38. package/docs/module-datarestructor.Restructor.html +1 -1
  39. package/docs/module-datarestructor.Transform.html +605 -605
  40. package/docs/module-datarestructor.html +959 -995
  41. package/docs/module-described_field.DescribedDataFieldBuilder.html +1 -1
  42. package/docs/module-described_field.DescribedDataFieldGroup.html +1 -1
  43. package/docs/module-described_field.html +1 -37
  44. package/docs/module-template_resolver.Resolver.html +167 -167
  45. package/docs/module-template_resolver.html +1 -37
  46. package/docs/templateResolver.js.html +1 -1
  47. package/package.json +20 -14
  48. package/renovate.json +14 -0
  49. 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
- return newRequire(localRequire.resolve(x));
83
+ var res = localRequire.resolve(x);
84
+ return res === false ? {} : newRequire(res);
84
85
  }
85
86
 
86
87
  function resolve(x) {
87
- return modules[name][1][x] || x;
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,206 @@
140
142
  this[globalName] = mainExports;
141
143
  }
142
144
  }
143
- })({"7hyUl":[function(require,module,exports) {
145
+ })({"5qyN0":[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
- "use strict";
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
- return objectToCheck || ({});
154
+ return objectToCheck || {};
155
155
  }
156
156
  /**
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
- var template_resolver = module.exports = {};
161
- // Export module for npm...
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
+ */ var template_resolver = module.exports = {}; // Export module for npm...
162
160
  template_resolver.internalCreateIfNotExists = templateResolverInternalCreateIfNotExists;
163
- var internal_object_tools = internal_object_tools || require("../../lib/js/flattenToArray");
164
- // supports vanilla js & npm
165
- template_resolver.Resolver = (function () {
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;
161
+ var internal_object_tools = internal_object_tools || require("2bc8fdaaf35dfa57"); // supports vanilla js & npm
162
+ template_resolver.Resolver = function() {
163
+ var removeArrayBracketsRegEx = new RegExp("\\[\\d+\\]", "gi");
178
164
  /**
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
- };
192
- /**
193
- * Returns a map like object, that contains all resolvable fields and their values as properties.
194
- * This function takes a variable count of input parameters,
195
- * each containing an object that contains resolvable fields to extract from.
196
- *
197
- * The recursion depth is limited to 3, so that an object,
198
- * that contains an object can contain another object (but not further).
199
- *
200
- * Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.
201
- *
202
- * @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.
203
- * @returns {object} object with resolvable field names and their values.
204
- * @public
205
- */
206
- this.resolvableFieldsOfAll = function () {
207
- var map = {};
208
- var ignoreInternalFields = function (propertyName) {
209
- return propertyName.indexOf("_") !== 0 && propertyName.indexOf("._") < 0;
210
- };
211
- var index;
212
- for (index = 0; index < arguments.length; index += 1) {
213
- addToFilteredMapObject(internal_object_tools.flattenToArray(arguments[index], 3), map, ignoreInternalFields);
214
- }
215
- return map;
216
- };
217
- /**
218
- * Replaces all variables in double curly brackets, e.g. {{property}},
219
- * with the value of that property from the resolvableProperties.
220
- *
221
- * Supported property types: string, number, boolean
222
- * @param {string} stringContainingVariables
223
- * @param {object[]} resolvableFields (name=value)
224
- */
225
- this.replaceResolvableFields = function (stringContainingVariables, resolvableFields) {
226
- var replaced = stringContainingVariables;
227
- var propertyNames = Object.keys(resolvableFields);
228
- var propertyIndex = 0;
229
- var propertyName = "";
230
- var propertyValue = "";
231
- for (propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1) {
232
- propertyName = propertyNames[propertyIndex];
233
- propertyValue = resolvableFields[propertyName];
234
- replaced = replaced.replace("{{" + propertyName + "}}", propertyValue);
235
- }
236
- return replaced;
237
- };
238
- }
239
- /**
240
- * Adds the value of the "fieldName" property (including its group prefix) and its associated "value" property content.
241
- * For example: detail[2].fieldName="name", detail[2].value="Smith" lead to the additional property detail.name="Smith".
242
- * @param {object} object with resolvable field names and their values.
243
- * @returns {object} object with resolvable field names and their values.
244
- * @protected
245
- * @memberof module:template_resolver.Resolver
246
- */
247
- function addFieldsPerGroup(map) {
248
- var propertyNames = Object.keys(map);
249
- var i, fullPropertyName, propertyInfo, propertyValue;
250
- for (i = 0; i < propertyNames.length; i += 1) {
251
- fullPropertyName = propertyNames[i];
252
- propertyValue = map[fullPropertyName];
253
- propertyInfo = getPropertyNameInfos(fullPropertyName);
254
- // Supports fields that are defined by a property named "fieldName" (containing the name)
255
- // and a property named "value" inside the same sub object (containing its value).
256
- // Ignore custom fields that are named "fieldName"(propertyValue), since this would lead to an unpredictable behavior.
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
- }
165
+ * Resolver. Is used inside this repository. It could also be used outside.
166
+ * @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.
167
+ * @constructs Resolver
168
+ * @alias module:template_resolver.Resolver
169
+ */ function Resolver(sourceDataObject) {
170
+ /**
171
+ * The properties of this source data object will be used to replace the placeholders in the template.
172
+ */ this.sourceDataObject = sourceDataObject;
173
+ /**
174
+ * Resolves the given template.
175
+ *
176
+ * The template may contain variables in double curly brackets.
177
+ * Supported variables are all properties of this object, e.g. "{{fieldName}}", "{{displayName}}", "{{value}}".
178
+ * Since this object may also contains (described) groups of sub objects, they can also be used, e.g. "{{summaries[0].value}}"
179
+ * Parts of the index can be inserted by using e.g. "{{index[1]}}".
180
+ *
181
+ * @param {string} template
182
+ * @returns {string} resolved template
183
+ */ this.resolveTemplate = function(template) {
184
+ return this.replaceResolvableFields(template, addFieldsPerGroup(this.resolvableFieldsOfAll(this.sourceDataObject)));
185
+ };
186
+ /**
187
+ * Returns a map like object, that contains all resolvable fields and their values as properties.
188
+ * This function takes a variable count of input parameters,
189
+ * each containing an object that contains resolvable fields to extract from.
190
+ *
191
+ * The recursion depth is limited to 3, so that an object,
192
+ * that contains an object can contain another object (but not further).
193
+ *
194
+ * Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.
195
+ *
196
+ * @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.
197
+ * @returns {object} object with resolvable field names and their values.
198
+ * @public
199
+ */ this.resolvableFieldsOfAll = function() {
200
+ var map = {};
201
+ var ignoreInternalFields = function(propertyName) {
202
+ return propertyName.indexOf("_") !== 0 && propertyName.indexOf("._") < 0;
203
+ };
204
+ var index;
205
+ for(index = 0; index < arguments.length; index += 1)addToFilteredMapObject(internal_object_tools.flattenToArray(arguments[index], 3), map, ignoreInternalFields);
206
+ return map;
207
+ };
208
+ /**
209
+ * Replaces all variables in double curly brackets, e.g. {{property}},
210
+ * with the value of that property from the resolvableProperties.
211
+ *
212
+ * Supported property types: string, number, boolean
213
+ * @param {string} stringContainingVariables
214
+ * @param {object[]} resolvableFields (name=value)
215
+ */ this.replaceResolvableFields = function(stringContainingVariables, resolvableFields) {
216
+ var replaced = stringContainingVariables;
217
+ var propertyNames = Object.keys(resolvableFields);
218
+ var propertyIndex = 0;
219
+ var propertyName = "";
220
+ var propertyValue = "";
221
+ for(propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1){
222
+ propertyName = propertyNames[propertyIndex];
223
+ propertyValue = resolvableFields[propertyName];
224
+ replaced = replaced.replace("{{" + propertyName + "}}", propertyValue);
225
+ }
226
+ return replaced;
227
+ };
261
228
  }
262
- return map;
263
- }
264
- /**
265
- * Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.
266
- * @param {String} fullPropertyName
267
- * @returns {Object} Contains "group" (empty or group name including trailing separator "."), "groupWithoutArrayIndices" and "name" (property name).
268
- * @protected
269
- * @memberof module:template_resolver.Resolver
270
- */
271
- function getPropertyNameInfos(fullPropertyName) {
272
- var positionOfRightMostSeparator = fullPropertyName.lastIndexOf(".");
273
- var propertyName = fullPropertyName;
274
- if (positionOfRightMostSeparator > 0) {
275
- propertyName = fullPropertyName.substr(positionOfRightMostSeparator + 1);
229
+ /**
230
+ * Adds the value of the "fieldName" property (including its group prefix) and its associated "value" property content.
231
+ * For example: detail[2].fieldName="name", detail[2].value="Smith" lead to the additional property detail.name="Smith".
232
+ * @param {object} object with resolvable field names and their values.
233
+ * @returns {object} object with resolvable field names and their values.
234
+ * @protected
235
+ * @memberof module:template_resolver.Resolver
236
+ */ function addFieldsPerGroup(map) {
237
+ var propertyNames = Object.keys(map);
238
+ var i, fullPropertyName, propertyInfo, propertyValue;
239
+ for(i = 0; i < propertyNames.length; i += 1){
240
+ fullPropertyName = propertyNames[i];
241
+ propertyValue = map[fullPropertyName];
242
+ propertyInfo = getPropertyNameInfos(fullPropertyName);
243
+ // Supports fields that are defined by a property named "fieldName" (containing the name)
244
+ // and a property named "value" inside the same sub object (containing its value).
245
+ // Ignore custom fields that are named "fieldName"(propertyValue), since this would lead to an unpredictable behavior.
246
+ // TODO could make "fieldName" and "value" configurable
247
+ if (propertyInfo.name === "fieldName" && propertyValue !== "fieldName") map[propertyInfo.groupWithoutArrayIndices + propertyValue] = map[propertyInfo.group + "value"];
248
+ }
249
+ return map;
276
250
  }
277
- var propertyGroup = "";
278
- if (positionOfRightMostSeparator > 0) {
279
- propertyGroup = fullPropertyName.substr(0, positionOfRightMostSeparator + 1);
251
+ /**
252
+ * Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.
253
+ * @param {String} fullPropertyName
254
+ * @returns {Object} Contains "group" (empty or group name including trailing separator "."), "groupWithoutArrayIndices" and "name" (property name).
255
+ * @protected
256
+ * @memberof module:template_resolver.Resolver
257
+ */ function getPropertyNameInfos(fullPropertyName) {
258
+ var positionOfRightMostSeparator = fullPropertyName.lastIndexOf(".");
259
+ var propertyName = fullPropertyName;
260
+ if (positionOfRightMostSeparator > 0) propertyName = fullPropertyName.substr(positionOfRightMostSeparator + 1);
261
+ var propertyGroup = "";
262
+ if (positionOfRightMostSeparator > 0) propertyGroup = fullPropertyName.substr(0, positionOfRightMostSeparator + 1); //includes the trailing ".".
263
+ var propertyGroupWithoutArrayIndices = propertyGroup.replace(removeArrayBracketsRegEx, "");
264
+ return {
265
+ group: propertyGroup,
266
+ groupWithoutArrayIndices: propertyGroupWithoutArrayIndices,
267
+ name: propertyName
268
+ };
280
269
  }
281
- var propertyGroupWithoutArrayIndices = propertyGroup.replace(removeArrayBracketsRegEx, "");
282
- return {
283
- group: propertyGroup,
284
- groupWithoutArrayIndices: propertyGroupWithoutArrayIndices,
285
- name: propertyName
286
- };
287
- }
288
- /**
289
- * Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).
290
- * Example: `{name: "accountNumber", value: "12345"}` becomes `mapObject["accountNumber"]="12345"`.
291
- *
292
- * @param {NameValuePair[]} elements flattened array of name-value-pairs
293
- * @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.
294
- * @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).
295
- * @protected
296
- * @memberof module:template_resolver.Resolver
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
- }
270
+ /**
271
+ * Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).
272
+ * Example: `{name: "accountNumber", value: "12345"}` becomes `mapObject["accountNumber"]="12345"`.
273
+ *
274
+ * @param {NameValuePair[]} elements flattened array of name-value-pairs
275
+ * @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.
276
+ * @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).
277
+ * @protected
278
+ * @memberof module:template_resolver.Resolver
279
+ */ function addToFilteredMapObject(elements, mapObject, filterMatchesFunction) {
280
+ var index, element;
281
+ for(index = 0; index < elements.length; index += 1){
282
+ element = elements[index];
283
+ if (typeof filterMatchesFunction === "function" && filterMatchesFunction(element.name)) mapObject[element.name] = element.value;
284
+ }
285
+ return mapObject;
305
286
  }
306
- return mapObject;
307
- }
308
- return Resolver;
309
- })();
287
+ return Resolver;
288
+ }();
310
289
 
311
- },{"../../lib/js/flattenToArray":"3Qsn4"}],"3Qsn4":[function(require,module,exports) {
290
+ },{"2bc8fdaaf35dfa57":"i4dBQ"}],"i4dBQ":[function(require,module,exports) {
312
291
  "use strict";
313
292
  /**
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
- var module = module || ({});
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...
293
+ * @fileOverview Modded (compatibility, recursion depth) version of: https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss
294
+ * @version ${project.version}
295
+ * @see {@link https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objectss|stackoverflow flatten nested json objects}
296
+ */ var module = module || {}; // Fallback for vanilla js without modules
326
297
  /**
327
- * @typedef {Object} NameValuePair
328
- * @property {string} name - point separated names of the flattened main and sub properties, e.g. "responses[2].hits.hits[4]._source.name".
329
- * @property {string} value - value of the property
330
- */
298
+ * internal_object_tools. Not meant to be used outside this repository.
299
+ * @default {}
300
+ */ var internal_object_tools = module.exports = {}; // Export module for npm...
331
301
  /**
332
- * @param {object} data hierarchical object that may consist fo fields, subfields and arrays.
333
- * @param {number} maxRecursionDepth
334
- * @returns {NameValuePair[]} array of property name and value pairs
335
- */
336
- internal_object_tools.flattenToArray = function (data, maxRecursionDepth) {
337
- var result = [];
338
- if (typeof maxRecursionDepth !== "number" || maxRecursionDepth < 1) {
339
- maxRecursionDepth = 20;
340
- }
341
- function recurse(cur, prop, depth) {
342
- if (depth > maxRecursionDepth || typeof cur === "function") {
343
- return;
344
- }
345
- if (Object(cur) !== cur) {
346
- result.push({
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: ""
302
+ * @typedef {Object} NameValuePair
303
+ * @property {string} name - point separated names of the flattened main and sub properties, e.g. "responses[2].hits.hits[4]._source.name".
304
+ * @property {string} value - value of the property
305
+ */ /**
306
+ * @param {object} data hierarchical object that may consist fo fields, subfields and arrays.
307
+ * @param {number} maxRecursionDepth
308
+ * @returns {NameValuePair[]} array of property name and value pairs
309
+ */ internal_object_tools.flattenToArray = function(data, maxRecursionDepth) {
310
+ var result = [];
311
+ if (typeof maxRecursionDepth !== "number" || maxRecursionDepth < 1) maxRecursionDepth = 20;
312
+ function recurse(cur, prop, depth) {
313
+ if (depth > maxRecursionDepth || typeof cur === "function") return;
314
+ if (Object(cur) !== cur) result.push({
315
+ name: prop,
316
+ value: cur
374
317
  });
375
- }
318
+ else if (Array.isArray(cur)) {
319
+ var i;
320
+ var l = cur.length;
321
+ for(i = 0; i < l; i += 1)recurse(cur[i], prop + "[" + i + "]", depth + 1);
322
+ if (l === 0) {
323
+ result[prop] = [];
324
+ result.push({
325
+ name: prop,
326
+ value: ""
327
+ });
328
+ }
329
+ } else {
330
+ var isEmpty = true;
331
+ var p;
332
+ for(p in cur){
333
+ isEmpty = false;
334
+ recurse(cur[p], prop ? prop + "." + p : p, depth + 1);
335
+ }
336
+ if (isEmpty && prop) result.push({
337
+ name: prop,
338
+ value: ""
339
+ });
340
+ }
376
341
  }
377
- }
378
- recurse(data, "", 0);
379
- return result;
342
+ recurse(data, "", 0);
343
+ return result;
380
344
  };
381
345
 
382
- },{}]},["7hyUl"], "7hyUl", "parcelRequire9661")
346
+ },{}]},["5qyN0"], "5qyN0", "parcelRequirec1f2")
383
347
 
@@ -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("7HmuL",(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,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.register("8ZIyB",(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("7HmuL");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("d63jw",(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){"use strict";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){"use strict";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=s||i("7HmuL"),u=u||i("8ZIyB"),c=c||i("d63jw");a.PropertyStructureDescriptionBuilder=function(){"use strict";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=function(){"use strict";var e=new RegExp("\\[\\d+\\]","gi");return function(t,r){var i,n,o=(i=t.name,n=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}}(i,n)),a=t.name.replace(e,""),s=new u.Resolver(this);this.category=r.category,this.type=r.type,this.abbreviation=r.abbreviation,this.image=r.image,this.index=o.numberArray,this.displayName=r.getDisplayNameForPropertyName(a),this.fieldName=r.getFieldNameForPropertyName(a),this.value=t.value,this.groupNames=[],this._isMatchingIndex=0==o.pointDelimited.indexOf(r.indexStartsWith),this._description=r,this._identifier={index:o.pointDelimited,propertyNameWithArrayIndices:t.name,propertyNameWithoutArrayIndices:a,groupId:"",groupDestinationId:"",deduplicationId:""},this._identifier.groupId=s.replaceResolvableFields(r.groupPattern,s.resolvableFieldsOfAll(this,this._description,this._identifier)),this._identifier.groupDestinationId=s.replaceResolvableFields(r.groupDestinationPattern,s.resolvableFieldsOfAll(this,this._description,this._identifier)),this._identifier.deduplicationId=s.replaceResolvableFields(r.deduplicationPattern,s.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(){"use strict";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=s.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 u,c=[];for(u=0;u<n.length;u+=1)c=t(c,r(a,n[u]));a=c,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