data-restructor 3.4.4 → 3.4.6
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/.auto-changelog-template.hbs +1 -1
- package/.github/workflows/codeql-analysis.yml +6 -6
- package/.github/workflows/continuous-integration.yaml +11 -11
- package/.nvmrc +1 -0
- package/CHANGELOG.md +185 -1
- package/CONTRIBUTING.md +3 -3
- package/README.md +25 -25
- package/coverage/coverage-summary.json +4 -4
- package/coverage/datarestructor.js.html +133 -133
- package/coverage/describedfield.js.html +45 -45
- package/coverage/index.html +6 -6
- package/coverage/templateResolver.js.html +29 -38
- package/devdist/datarestructor-global-all.js +3 -6
- package/devdist/datarestructor-ie-global-all.js +3 -6
- package/devdist/datarestructor-ie.js +75 -13
- package/devdist/datarestructor.js +75 -13
- package/devdist/describedfield-ie.js +72 -7
- package/devdist/describedfield.js +72 -7
- package/devdist/templateResolver-ie.js +75 -13
- package/devdist/templateResolver.js +75 -13
- package/dist/datarestructor-global-all-min.js +1 -1
- package/dist/datarestructor-ie-global-all-min.js +1 -1
- 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 +26 -26
- 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 +4 -4
- package/docs/module-template_resolver.html +1 -1
- package/docs/templateResolver.js.html +4 -7
- package/merger-config.json +2 -2
- package/package.json +11 -11
- package/src/js/templateResolver.js +3 -6
|
@@ -6,7 +6,16 @@
|
|
|
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 (
|
|
9
|
+
(function (
|
|
10
|
+
modules,
|
|
11
|
+
entry,
|
|
12
|
+
mainEntry,
|
|
13
|
+
parcelRequireName,
|
|
14
|
+
externals,
|
|
15
|
+
distDir,
|
|
16
|
+
publicUrl,
|
|
17
|
+
devServer
|
|
18
|
+
) {
|
|
10
19
|
/* eslint-disable no-undef */
|
|
11
20
|
var globalObject =
|
|
12
21
|
typeof globalThis !== 'undefined'
|
|
@@ -25,6 +34,7 @@
|
|
|
25
34
|
typeof globalObject[parcelRequireName] === 'function' &&
|
|
26
35
|
globalObject[parcelRequireName];
|
|
27
36
|
|
|
37
|
+
var importMap = previousRequire.i || {};
|
|
28
38
|
var cache = previousRequire.cache || {};
|
|
29
39
|
// Do not use `require` to prevent Webpack from trying to bundle this call
|
|
30
40
|
var nodeRequire =
|
|
@@ -35,6 +45,9 @@
|
|
|
35
45
|
function newRequire(name, jumped) {
|
|
36
46
|
if (!cache[name]) {
|
|
37
47
|
if (!modules[name]) {
|
|
48
|
+
if (externals[name]) {
|
|
49
|
+
return externals[name];
|
|
50
|
+
}
|
|
38
51
|
// if we cannot find the module within our internal map or
|
|
39
52
|
// cache jump to the current global require ie. the last bundle
|
|
40
53
|
// that was added to the page.
|
|
@@ -81,7 +94,54 @@
|
|
|
81
94
|
|
|
82
95
|
function localRequire(x) {
|
|
83
96
|
var res = localRequire.resolve(x);
|
|
84
|
-
|
|
97
|
+
if (res === false) {
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
// Synthesize a module to follow re-exports.
|
|
101
|
+
if (Array.isArray(res)) {
|
|
102
|
+
var m = {__esModule: true};
|
|
103
|
+
res.forEach(function (v) {
|
|
104
|
+
var key = v[0];
|
|
105
|
+
var id = v[1];
|
|
106
|
+
var exp = v[2] || v[0];
|
|
107
|
+
var x = newRequire(id);
|
|
108
|
+
if (key === '*') {
|
|
109
|
+
Object.keys(x).forEach(function (key) {
|
|
110
|
+
if (
|
|
111
|
+
key === 'default' ||
|
|
112
|
+
key === '__esModule' ||
|
|
113
|
+
Object.prototype.hasOwnProperty.call(m, key)
|
|
114
|
+
) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
Object.defineProperty(m, key, {
|
|
119
|
+
enumerable: true,
|
|
120
|
+
get: function () {
|
|
121
|
+
return x[key];
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
} else if (exp === '*') {
|
|
126
|
+
Object.defineProperty(m, key, {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
value: x,
|
|
129
|
+
});
|
|
130
|
+
} else {
|
|
131
|
+
Object.defineProperty(m, key, {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
if (exp === 'default') {
|
|
135
|
+
return x.__esModule ? x.default : x;
|
|
136
|
+
}
|
|
137
|
+
return x[exp];
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return m;
|
|
143
|
+
}
|
|
144
|
+
return newRequire(res);
|
|
85
145
|
}
|
|
86
146
|
|
|
87
147
|
function resolve(x) {
|
|
@@ -93,6 +153,7 @@
|
|
|
93
153
|
function Module(moduleName) {
|
|
94
154
|
this.id = moduleName;
|
|
95
155
|
this.bundle = newRequire;
|
|
156
|
+
this.require = nodeRequire;
|
|
96
157
|
this.exports = {};
|
|
97
158
|
}
|
|
98
159
|
|
|
@@ -101,6 +162,10 @@
|
|
|
101
162
|
newRequire.modules = modules;
|
|
102
163
|
newRequire.cache = cache;
|
|
103
164
|
newRequire.parent = previousRequire;
|
|
165
|
+
newRequire.distDir = distDir;
|
|
166
|
+
newRequire.publicUrl = publicUrl;
|
|
167
|
+
newRequire.devServer = devServer;
|
|
168
|
+
newRequire.i = importMap;
|
|
104
169
|
newRequire.register = function (id, exports) {
|
|
105
170
|
modules[id] = [
|
|
106
171
|
function (require, module) {
|
|
@@ -110,6 +175,10 @@
|
|
|
110
175
|
];
|
|
111
176
|
};
|
|
112
177
|
|
|
178
|
+
// Only insert newRequire.load when it is actually used.
|
|
179
|
+
// The code in this file is linted against ES5, so dynamic import is not allowed.
|
|
180
|
+
// INSERT_LOAD_HERE
|
|
181
|
+
|
|
113
182
|
Object.defineProperty(newRequire, 'root', {
|
|
114
183
|
get: function () {
|
|
115
184
|
return globalObject[parcelRequireName];
|
|
@@ -136,10 +205,6 @@
|
|
|
136
205
|
define(function () {
|
|
137
206
|
return mainExports;
|
|
138
207
|
});
|
|
139
|
-
|
|
140
|
-
// <script>
|
|
141
|
-
} else if (globalName) {
|
|
142
|
-
this[globalName] = mainExports;
|
|
143
208
|
}
|
|
144
209
|
}
|
|
145
210
|
})({"bUhQb":[function(require,module,exports,__globalThis) {
|
|
@@ -215,12 +280,9 @@ template_resolver.Resolver = function() {
|
|
|
215
280
|
*/ this.replaceResolvableFields = function(stringContainingVariables, resolvableFields) {
|
|
216
281
|
var replaced = stringContainingVariables;
|
|
217
282
|
var propertyNames = Object.keys(resolvableFields);
|
|
218
|
-
var propertyIndex = 0;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
for(propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1){
|
|
222
|
-
propertyName = propertyNames[propertyIndex];
|
|
223
|
-
propertyValue = resolvableFields[propertyName];
|
|
283
|
+
for(var propertyIndex = 0; propertyIndex < propertyNames.length; propertyIndex += 1){
|
|
284
|
+
var propertyName = propertyNames[propertyIndex];
|
|
285
|
+
var propertyValue = resolvableFields[propertyName];
|
|
224
286
|
replaced = replaced.replace("{{" + propertyName + "}}", propertyValue);
|
|
225
287
|
}
|
|
226
288
|
return replaced;
|
|
@@ -343,5 +405,5 @@ template_resolver.Resolver = function() {
|
|
|
343
405
|
return result;
|
|
344
406
|
};
|
|
345
407
|
|
|
346
|
-
},{}]},["bUhQb"], "bUhQb", "
|
|
408
|
+
},{}]},["bUhQb"], "bUhQb", "parcelRequirec1f2", {})
|
|
347
409
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var require=require||function(){};"use strict";(internal_object_tools=(module=(module=module||{})||{}).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};var module=templateResolverInternalCreateIfNotExists(module);function templateResolverInternalCreateIfNotExists(e){return e||{}}(template_resolver=module.exports={}).internalCreateIfNotExists=templateResolverInternalCreateIfNotExists;var internal_object_tools=internal_object_tools||require("../../lib/js/flattenToArray");template_resolver.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="";return r>0&&(n=t.substr(0,r+1)),{group:n,groupWithoutArrayIndices:n.replace(e,""),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)i=a[r],o=e[i],"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(internal_object_tools.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}}}();module=describedFieldInternalCreateIfNotExists(module);function describedFieldInternalCreateIfNotExists(e){return e||{}}function datarestructorInternalCreateIfNotExists(e){return e||{}}(described_field=module.exports={}).internalCreateIfNotExists=describedFieldInternalCreateIfNotExists,described_field.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}}}(),described_field.copyWithoutGroups=function(e){return(new described_field.DescribedDataFieldBuilder).fromDescribedDataField(e).groupNames([]).build()},described_field.DescribedDataFieldGroup=function(){return 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}}}();var datarestructor=(module=datarestructorInternalCreateIfNotExists(module)).exports={};datarestructor.internalCreateIfNotExists=datarestructorInternalCreateIfNotExists;internal_object_tools=internal_object_tools||require("../../lib/js/flattenToArray");var template_resolver=template_resolver||require("../../src/js/templateResolver"),described_field=described_field||require("../../src/js/describedfield");datarestructor.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}}"),n=i.exec(e);return n&&""!=n[1]?n[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:(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(r=e(t)).length>1?r.charAt(0).toUpperCase()+r.slice(1):r;var r}}(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=(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;var e,t}}}(),datarestructor.DescribedEntryCreator=function(){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 template_resolver.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)}}}(),datarestructor.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 datarestructor.DescribedEntryCreator(e,t);o._isMatchingIndex&&i.push(o)}}),i}function i(e,t){var r=(new described_field.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 described_field.DescribedDataFieldGroup(r);return function(e,t){var r,i,n,o;for(r=0;r<e.groupNames.length;r+=1)for(n=e.groupNames[r],i=0;i<e[n].length;i+=1)o=e[n][i],t(n,o,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){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,n,o){var a,s,u,l,d,c=internal_object_tools.flattenToArray(e);a=c,s=new RegExp("\\[\\d+\\]$","gi"),u=[],l="",d="",a.filter(function(e){if(!e.name.match(s))return""!==l&&(u.push({name:l+"_comma_separated_values",value:d}),l=""),void u.push(e);var t=e.name.replace(s,"");l===t?d+=", "+e.value:(""!==l&&(u.push({name:l+"_comma_separated_values",value:d}),l=""),l=t,d=e.value),u.push(e)}),c=u,o.debugMode&&(console.log("flattened data with array values:"),console.log(c));var p,h,f,g=[];for(p=0;p<n.length;p+=1)h=n[p],f=r(c,h),g=t(g,f);return c=g,o.debugMode&&(console.log("describedData data:"),console.log(c)),c=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})}(c),o.debugMode&&(console.log("grouped describedData data:"),console.log(c)),c=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){var u=r[i];delete e[u]}return e}(c),o.debugMode&&(console.log("moved grouped describedData data:"),console.log(c)),c=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}(c=function(e){for(var t=[],r=Object.keys(e),i=0;i<r.length;i++){var n=r[i],o=e[n];t.push(o)}return t}(c),o),o.debugMode&&(console.log("transformed result:"),console.log(c)),c}(e,this.descriptions,this.config)}}}(),datarestructor.Restructor={},datarestructor.Restructor.processJsonUsingDescriptions=function(e,t,r){var i=new datarestructor.Transform(t);return r&&i.enableDebugMode(),i.processJson(e)};
|
|
1
|
+
var require=require||function(){};"use strict";(internal_object_tools=(module=(module=module||{})||{}).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};var module=templateResolverInternalCreateIfNotExists(module);function templateResolverInternalCreateIfNotExists(e){return e||{}}(template_resolver=module.exports={}).internalCreateIfNotExists=templateResolverInternalCreateIfNotExists;var internal_object_tools=internal_object_tools||require("../../lib/js/flattenToArray");template_resolver.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="";return r>0&&(n=t.substr(0,r+1)),{group:n,groupWithoutArrayIndices:n.replace(e,""),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)i=a[r],o=e[i],"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(internal_object_tools.flattenToArray(arguments[e],3),t,i);return t},this.replaceResolvableFields=function(e,t){for(var r=e,i=Object.keys(t),n=0;n<i.length;n+=1){var o=i[n],a=t[o];r=r.replace("{{"+o+"}}",a)}return r}}}();module=describedFieldInternalCreateIfNotExists(module);function describedFieldInternalCreateIfNotExists(e){return e||{}}function datarestructorInternalCreateIfNotExists(e){return e||{}}(described_field=module.exports={}).internalCreateIfNotExists=describedFieldInternalCreateIfNotExists,described_field.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}}}(),described_field.copyWithoutGroups=function(e){return(new described_field.DescribedDataFieldBuilder).fromDescribedDataField(e).groupNames([]).build()},described_field.DescribedDataFieldGroup=function(){return 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}}}();var datarestructor=(module=datarestructorInternalCreateIfNotExists(module)).exports={};datarestructor.internalCreateIfNotExists=datarestructorInternalCreateIfNotExists;internal_object_tools=internal_object_tools||require("../../lib/js/flattenToArray");var template_resolver=template_resolver||require("../../src/js/templateResolver"),described_field=described_field||require("../../src/js/describedfield");datarestructor.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}}"),n=i.exec(e);return n&&""!=n[1]?n[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:(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(r=e(t)).length>1?r.charAt(0).toUpperCase()+r.slice(1):r;var r}}(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=(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;var e,t}}}(),datarestructor.DescribedEntryCreator=function(){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 template_resolver.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)}}}(),datarestructor.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 datarestructor.DescribedEntryCreator(e,t);o._isMatchingIndex&&i.push(o)}}),i}function i(e,t){var r=(new described_field.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 described_field.DescribedDataFieldGroup(r);return function(e,t){var r,i,n,o;for(r=0;r<e.groupNames.length;r+=1)for(n=e.groupNames[r],i=0;i<e[n].length;i+=1)o=e[n][i],t(n,o,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){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,n,o){var a,s,u,l,d,c=internal_object_tools.flattenToArray(e);a=c,s=new RegExp("\\[\\d+\\]$","gi"),u=[],l="",d="",a.filter(function(e){if(!e.name.match(s))return""!==l&&(u.push({name:l+"_comma_separated_values",value:d}),l=""),void u.push(e);var t=e.name.replace(s,"");l===t?d+=", "+e.value:(""!==l&&(u.push({name:l+"_comma_separated_values",value:d}),l=""),l=t,d=e.value),u.push(e)}),c=u,o.debugMode&&(console.log("flattened data with array values:"),console.log(c));var p,h,f,g=[];for(p=0;p<n.length;p+=1)h=n[p],f=r(c,h),g=t(g,f);return c=g,o.debugMode&&(console.log("describedData data:"),console.log(c)),c=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})}(c),o.debugMode&&(console.log("grouped describedData data:"),console.log(c)),c=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){var u=r[i];delete e[u]}return e}(c),o.debugMode&&(console.log("moved grouped describedData data:"),console.log(c)),c=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}(c=function(e){for(var t=[],r=Object.keys(e),i=0;i<r.length;i++){var n=r[i],o=e[n];t.push(o)}return t}(c),o),o.debugMode&&(console.log("transformed result:"),console.log(c)),c}(e,this.descriptions,this.config)}}}(),datarestructor.Restructor={},datarestructor.Restructor.processJsonUsingDescriptions=function(e,t,r){var i=new datarestructor.Transform(t);return r&&i.enableDebugMode(),i.processJson(e)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var module=module||{},require=require||function(){};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)),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),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});"use strict";(internal_object_tools=(module=module||{}).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};module=templateResolverInternalCreateIfNotExists(module);function templateResolverInternalCreateIfNotExists(e){return e||{}}(template_resolver=module.exports={}).internalCreateIfNotExists=templateResolverInternalCreateIfNotExists;var internal_object_tools=internal_object_tools||require("../../lib/js/flattenToArray");template_resolver.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="";return r>0&&(n=t.substr(0,r+1)),{group:n,groupWithoutArrayIndices:n.replace(e,""),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)i=a[r],o=e[i],"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(internal_object_tools.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}}}();module=describedFieldInternalCreateIfNotExists(module);function describedFieldInternalCreateIfNotExists(e){return e||{}}function datarestructorInternalCreateIfNotExists(e){return e||{}}(described_field=module.exports={}).internalCreateIfNotExists=describedFieldInternalCreateIfNotExists,described_field.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}}}(),described_field.copyWithoutGroups=function(e){return(new described_field.DescribedDataFieldBuilder).fromDescribedDataField(e).groupNames([]).build()},described_field.DescribedDataFieldGroup=function(){return 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}}}();var datarestructor=(module=datarestructorInternalCreateIfNotExists(module)).exports={};datarestructor.internalCreateIfNotExists=datarestructorInternalCreateIfNotExists;internal_object_tools=internal_object_tools||require("../../lib/js/flattenToArray");var template_resolver=template_resolver||require("../../src/js/templateResolver"),described_field=described_field||require("../../src/js/describedfield");datarestructor.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}}"),n=i.exec(e);return n&&""!=n[1]?n[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:(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(r=e(t)).length>1?r.charAt(0).toUpperCase()+r.slice(1):r;var r}}(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=(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;var e,t}}}(),datarestructor.DescribedEntryCreator=function(){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 template_resolver.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)}}}(),datarestructor.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 datarestructor.DescribedEntryCreator(e,t);o._isMatchingIndex&&i.push(o)}}),i}function i(e,t){var r=(new described_field.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 described_field.DescribedDataFieldGroup(r);return function(e,t){var r,i,n,o;for(r=0;r<e.groupNames.length;r+=1)for(n=e.groupNames[r],i=0;i<e[n].length;i+=1)o=e[n][i],t(n,o,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){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,n,o){var a,s,u,l,d,c=internal_object_tools.flattenToArray(e);a=c,s=new RegExp("\\[\\d+\\]$","gi"),u=[],l="",d="",a.filter(function(e){if(!e.name.match(s))return""!==l&&(u.push({name:l+"_comma_separated_values",value:d}),l=""),void u.push(e);var t=e.name.replace(s,"");l===t?d+=", "+e.value:(""!==l&&(u.push({name:l+"_comma_separated_values",value:d}),l=""),l=t,d=e.value),u.push(e)}),c=u,o.debugMode&&(console.log("flattened data with array values:"),console.log(c));var p,h,f,g=[];for(p=0;p<n.length;p+=1)h=n[p],f=r(c,h),g=t(g,f);return c=g,o.debugMode&&(console.log("describedData data:"),console.log(c)),c=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})}(c),o.debugMode&&(console.log("grouped describedData data:"),console.log(c)),c=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){var u=r[i];delete e[u]}return e}(c),o.debugMode&&(console.log("moved grouped describedData data:"),console.log(c)),c=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}(c=function(e){for(var t=[],r=Object.keys(e),i=0;i<r.length;i++){var n=r[i],o=e[n];t.push(o)}return t}(c),o),o.debugMode&&(console.log("transformed result:"),console.log(c)),c}(e,this.descriptions,this.config)}}}(),datarestructor.Restructor={},datarestructor.Restructor.processJsonUsingDescriptions=function(e,t,r){var i=new datarestructor.Transform(t);return r&&i.enableDebugMode(),i.processJson(e)};
|
|
1
|
+
var module=module||{},require=require||function(){};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)),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),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});"use strict";(internal_object_tools=(module=module||{}).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};module=templateResolverInternalCreateIfNotExists(module);function templateResolverInternalCreateIfNotExists(e){return e||{}}(template_resolver=module.exports={}).internalCreateIfNotExists=templateResolverInternalCreateIfNotExists;var internal_object_tools=internal_object_tools||require("../../lib/js/flattenToArray");template_resolver.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="";return r>0&&(n=t.substr(0,r+1)),{group:n,groupWithoutArrayIndices:n.replace(e,""),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)i=a[r],o=e[i],"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(internal_object_tools.flattenToArray(arguments[e],3),t,i);return t},this.replaceResolvableFields=function(e,t){for(var r=e,i=Object.keys(t),n=0;n<i.length;n+=1){var o=i[n],a=t[o];r=r.replace("{{"+o+"}}",a)}return r}}}();module=describedFieldInternalCreateIfNotExists(module);function describedFieldInternalCreateIfNotExists(e){return e||{}}function datarestructorInternalCreateIfNotExists(e){return e||{}}(described_field=module.exports={}).internalCreateIfNotExists=describedFieldInternalCreateIfNotExists,described_field.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}}}(),described_field.copyWithoutGroups=function(e){return(new described_field.DescribedDataFieldBuilder).fromDescribedDataField(e).groupNames([]).build()},described_field.DescribedDataFieldGroup=function(){return 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}}}();var datarestructor=(module=datarestructorInternalCreateIfNotExists(module)).exports={};datarestructor.internalCreateIfNotExists=datarestructorInternalCreateIfNotExists;internal_object_tools=internal_object_tools||require("../../lib/js/flattenToArray");var template_resolver=template_resolver||require("../../src/js/templateResolver"),described_field=described_field||require("../../src/js/describedfield");datarestructor.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}}"),n=i.exec(e);return n&&""!=n[1]?n[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:(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(r=e(t)).length>1?r.charAt(0).toUpperCase()+r.slice(1):r;var r}}(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=(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;var e,t}}}(),datarestructor.DescribedEntryCreator=function(){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 template_resolver.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)}}}(),datarestructor.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 datarestructor.DescribedEntryCreator(e,t);o._isMatchingIndex&&i.push(o)}}),i}function i(e,t){var r=(new described_field.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 described_field.DescribedDataFieldGroup(r);return function(e,t){var r,i,n,o;for(r=0;r<e.groupNames.length;r+=1)for(n=e.groupNames[r],i=0;i<e[n].length;i+=1)o=e[n][i],t(n,o,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){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,n,o){var a,s,u,l,d,c=internal_object_tools.flattenToArray(e);a=c,s=new RegExp("\\[\\d+\\]$","gi"),u=[],l="",d="",a.filter(function(e){if(!e.name.match(s))return""!==l&&(u.push({name:l+"_comma_separated_values",value:d}),l=""),void u.push(e);var t=e.name.replace(s,"");l===t?d+=", "+e.value:(""!==l&&(u.push({name:l+"_comma_separated_values",value:d}),l=""),l=t,d=e.value),u.push(e)}),c=u,o.debugMode&&(console.log("flattened data with array values:"),console.log(c));var p,h,f,g=[];for(p=0;p<n.length;p+=1)h=n[p],f=r(c,h),g=t(g,f);return c=g,o.debugMode&&(console.log("describedData data:"),console.log(c)),c=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})}(c),o.debugMode&&(console.log("grouped describedData data:"),console.log(c)),c=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){var u=r[i];delete e[u]}return e}(c),o.debugMode&&(console.log("moved grouped describedData data:"),console.log(c)),c=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}(c=function(e){for(var t=[],r=Object.keys(e),i=0;i<r.length;i++){var n=r[i],o=e[n];t.push(o)}return t}(c),o),o.debugMode&&(console.log("transformed result:"),console.log(c)),c}(e,this.descriptions,this.config)}}}(),datarestructor.Restructor={},datarestructor.Restructor.processJsonUsingDescriptions=function(e,t,r){var i=new datarestructor.Transform(t);return r&&i.enableDebugMode(),i.processJson(e)};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=globalThis,t={},r={},i=e.parcelRequire94c2;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=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,t){r[e]=t},e.parcelRequire94c2=i);var n=i.register;n("dED0n",function(e,t){if(!Array.prototype.indexOf){var r,i,n;Array.prototype.indexOf=(r=Object,i=Math.max,n=Math.min,function(e,t){if(this===null||void 0===this)throw TypeError("Array.prototype.indexOf called on null or undefined");var o=r(this),a=o.length>>>0,s=n(0|t,a);if(s<0)s=i(0,a+s);else if(s>=a)return -1;if(void 0===e){for(;s!==a;++s)if(void 0===o[s]&&s in o)return s}else if(e!=e){for(;s!==a;++s)if(o[s]!=o[s])return s}else for(;s!==a;++s)if(o[s]===e)return s;return -1})}}),n("b1M0n",function(e,t){Object.keys||(Object.keys=function(e){if(e!==Object(e))throw 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})}),n("keJ9m",function(e,t){var r,n=o(n);function o(e){return e||{}}var a=n.exports={};a.internalCreateIfNotExists=o;var s=s||i("ccQZb"),u=u||i("ds403"),l=l||i("aJuQy");a.PropertyStructureDescriptionBuilder=function(){function e(e,i){var n;return o(e)?function(){return e}:i.propertyPatternTemplateMode?(n=i.propertyPattern,function(e){var i=r(n,"{{fieldName}}").exec(e);return i&&""!=i[1]?i[1]:t(e)}):function(e){return t(e)}}function t(e){var t=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)),RegExp(r="^"+(r=r.replace(t,"([-\\w]+)")),"i")}function i(e){var t=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){var r,i;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=(i=this.description.getDisplayNameForPropertyName,function(e){var t;return(t=i(e)).length>1?t.charAt(0).toUpperCase()+t.slice(1):t})),this},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=o(t=(e=this.description).propertyPattern)?e.propertyPatternTemplateMode?function(e){return null!=r(t,RegExp("\\\\\\{\\\\\\{[-\\w]+\\\\\\}\\\\\\}","gi")).exec(e)}: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=(r=RegExp("\\[\\d+\\]","gi"),function(e,t){var i=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}}(e.name,RegExp("\\[(\\d+)\\]","gi")),n=e.name.replace(r,""),o=new u.Resolver(this);this.category=t.category,this.type=t.type,this.abbreviation=t.abbreviation,this.image=t.image,this.index=i.numberArray,this.displayName=t.getDisplayNameForPropertyName(n),this.fieldName=t.getFieldNameForPropertyName(n),this.value=e.value,this.groupNames=[],this._isMatchingIndex=0==i.pointDelimited.indexOf(t.indexStartsWith),this._description=t,this._identifier={index:i.pointDelimited,propertyNameWithArrayIndices:e.name,propertyNameWithoutArrayIndices:n,groupId:"",groupDestinationId:"",deduplicationId:""},this._identifier.groupId=o.replaceResolvableFields(t.groupPattern,o.resolvableFieldsOfAll(this,this._description,this._identifier)),this._identifier.groupDestinationId=o.replaceResolvableFields(t.groupDestinationPattern,o.resolvableFieldsOfAll(this,this._description,this._identifier)),this._identifier.deduplicationId=o.replaceResolvableFields(t.deduplicationPattern,o.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,r){return t(e.category,"")===t(r.category,"")&&t(e.type,"")===t(r.type,"")&&e.fieldName===r.fieldName&&e.value===r.value}function t(e,t){return void 0!==e&&e?e:t}return function(t){this.descriptions=t,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(t){return function(t,r,i){var n,o,u,c,p,d,h,f,g=s.flattenToArray(t);n=g,o=RegExp("\\[\\d+\\]$","gi"),u=[],c="",p="",n.filter(function(e){if(!e.name.match(o)){""!==c&&(u.push({name:c+"_comma_separated_values",value:p}),c=""),u.push(e);return}var t=e.name.replace(o,"");c===t?p+=", "+e.value:(""!==c&&(u.push({name:c+"_comma_separated_values",value:p}),c=""),c=t,p=e.value),u.push(e)}),g=u,i.debugMode&&(console.log("flattened data with array values:"),console.log(g));var m=[];for(f=0;f<r.length;f+=1)d=m,h=function(e,t){var r=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}(g,r[f]),m=null==d||0==d.length?h:function(e,t,r){var i,n,o,a=function(e,t){for(var r={},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)s.push(n=t[i]);return s}(d,h,function(e){return e._identifier.deduplicationId});return g=m,i.debugMode&&(console.log("describedData data:"),console.log(g)),g=function(e,t,r){for(var i={},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}(g,function(e){return e._identifier.groupId},function(e){return e._description.groupName}),i.debugMode&&(console.log("grouped describedData data:"),console.log(g)),g=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){var u=r[i];delete e[u]}return e}(g),i.debugMode&&(console.log("moved grouped describedData data:"),console.log(g)),g=function(t,r){var i,n=[];for(i=0;i<t.length;i+=1)n.push(function t(r,i){var n=new l.DescribedDataFieldBuilder().category(r.category).type(r.type).abbreviation(r.abbreviation).image(r.image).index(r.index).displayName(r.displayName).fieldName(r.fieldName).value(r.value).build();if(i.recursionDepth>i.config.maxRecursionDepth)return n;var o=null,a="",s=new l.DescribedDataFieldGroup(n);return function(e,t){var r,i,n,o;for(r=0;r<e.groupNames.length;r+=1)for(i=0,n=e.groupNames[r];i<e[n].length;i+=1)o=e[n][i],t(n,o,e[n])}(r,function(r,n,u){if(i.groupToSkip===r){i.config.debugMode&&console.log("Removed duplicate group "+r+" at recursion depth "+i.recursionDepth);return}a="",i.recursionDepth>=i.config.removeDuplicationAboveRecursionDepth&&(a=!function(e,t,r){if(e===t)return!0;if(null==e||null==t||e.length!==t.length)return!1;for(var i=0;i<e.length;++i)if(!r(e[i],t[i]))return!1;return!0}(n[r],u,e)?"":r),o={recursionDepth:i.recursionDepth+1,config:i.config,groupToSkip:a},s.addGroupEntry(r,t(n,o))}),n}(t[i],{recursionDepth:0,config:r,groupToSkip:""}));return n}(g=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}(g),i),i.debugMode&&(console.log("transformed result:"),console.log(g)),g}(t,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)}}),n("ccQZb",function(e,t){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}}),n("ds403",function(e,t){var r,n=o(n);function o(e){return e||{}}var a=n.exports={};a.internalCreateIfNotExists=o;var s=s||i("ccQZb");a.Resolver=(r=RegExp("\\[\\d+\\]","gi"),function(e){this.sourceDataObject=e,this.resolveTemplate=function(e){return this.replaceResolvableFields(e,function(e){var t,i,n,o,a=Object.keys(e);for(t=0;t<a.length;t+=1)o=e[i=a[t]],"fieldName"===(n=function(e){var t=e.lastIndexOf("."),i=e;t>0&&(i=e.substr(t+1));var n="";t>0&&(n=e.substr(0,t+1));var o=n.replace(r,"");return{group:n,groupWithoutArrayIndices:o,name:i}}(i)).name&&"fieldName"!==o&&(e[n.groupWithoutArrayIndices+o]=e[n.group+"value"]);return e}(this.resolvableFieldsOfAll(this.sourceDataObject)))},this.resolvableFieldsOfAll=function(){var e,t={},r=function(e){return 0!==e.indexOf("_")&&0>e.indexOf("._")};for(e=0;e<arguments.length;e+=1)(function(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)})(s.flattenToArray(arguments[e],3),t,r);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}})}),n("aJuQy",function(e,t){var r=i(r);function i(e){return e||{}}var n=r.exports={};n.internalCreateIfNotExists=i,n.DescribedDataFieldBuilder=function(){function e(e,t){return"string"==typeof e&&null!==e&&""!==e?e:t}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){var t;return this.describedField.index=(t=[],null==e?t:e),this},this.groupNames=function(e){var t;return this.describedField.groupNames=(t=[],null==e?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){var r,i;if(!e||0===e.length||!t||0===t.length)return this;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 TypeError();var r,i=this.length>>>0,n=Array(i),o=0,a=-1;if(void 0===t)for(;++a!==i;)a in this&&(r=this[a],e(this[a],a,this)&&(n[o++]=r));else for(;++a!==i;)a in this&&(r=this[a],e.call(t,this[a],a,this)&&(n[o++]=r));return n.length=o,n}),i("dED0n"),i("b1M0n");var o=i("keJ9m");module.exports={datarestructor:o};
|
|
1
|
+
var $parcel$global=globalThis,$parcel$modules={},$parcel$inits={},parcelRequire=$parcel$global.parcelRequirec1f2;null==parcelRequire&&((parcelRequire=function(e){if(e in $parcel$modules)return $parcel$modules[e].exports;if(e in $parcel$inits){var t=$parcel$inits[e];delete $parcel$inits[e];var r={id:e,exports:{}};return $parcel$modules[e]=r,t.call(r.exports,r,r.exports),r.exports}var i=Error("Cannot find module '"+e+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(e,t){$parcel$inits[e]=t},$parcel$global.parcelRequirec1f2=parcelRequire);"use strict";var parcelRegister=parcelRequire.register;parcelRegister("dED0n",function(e,t){var r,i,n;Array.prototype.indexOf||(Array.prototype.indexOf=(r=Object,i=Math.max,n=Math.min,function(e,t){if(this===null||void 0===this)throw TypeError("Array.prototype.indexOf called on null or undefined");var o=r(this),a=o.length>>>0,s=n(0|t,a);if(s<0)s=i(0,a+s);else if(s>=a)return -1;if(void 0===e){for(;s!==a;++s)if(void 0===o[s]&&s in o)return s}else if(e!=e){for(;s!==a;++s)if(o[s]!=o[s])return s}else for(;s!==a;++s)if(o[s]===e)return s;return -1}))}),parcelRegister("b1M0n",function(e,t){Object.keys||(Object.keys=function(e){if(e!==Object(e))throw 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})}),parcelRegister("keJ9m",function(e,t){"use strict";var r,i=n(i);function n(e){return e||{}}var o=i.exports={};o.internalCreateIfNotExists=n;var a=a||parcelRequire("ccQZb"),s=s||parcelRequire("ds403"),u=u||parcelRequire("aJuQy");o.PropertyStructureDescriptionBuilder=function(){function e(e,i){var n;return o(e)?function(){return e}:i.propertyPatternTemplateMode?(n=i.propertyPattern,function(e){var i=r(n,"{{fieldName}}").exec(e);return i&&""!=i[1]?i[1]:t(e)}):function(e){return t(e)}}function t(e){var t=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)),RegExp(r="^"+(r=r.replace(t,"([-\\w]+)")),"i")}function i(e){var t=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){var r,i;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=(i=this.description.getDisplayNameForPropertyName,function(e){var t;return(t=i(e)).length>1?t.charAt(0).toUpperCase()+t.slice(1):t})),this},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=o(t=(e=this.description).propertyPattern)?e.propertyPatternTemplateMode?function(e){return null!=r(t,RegExp("\\\\\\{\\\\\\{[-\\w]+\\\\\\}\\\\\\}","gi")).exec(e)}: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}}}(),r=RegExp("\\[\\d+\\]","gi"),o.DescribedEntryCreator=function(e,t){var i=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}}(e.name,RegExp("\\[(\\d+)\\]","gi")),n=e.name.replace(r,""),o=new s.Resolver(this);this.category=t.category,this.type=t.type,this.abbreviation=t.abbreviation,this.image=t.image,this.index=i.numberArray,this.displayName=t.getDisplayNameForPropertyName(n),this.fieldName=t.getFieldNameForPropertyName(n),this.value=e.value,this.groupNames=[],this._isMatchingIndex=0==i.pointDelimited.indexOf(t.indexStartsWith),this._description=t,this._identifier={index:i.pointDelimited,propertyNameWithArrayIndices:e.name,propertyNameWithoutArrayIndices:n,groupId:"",groupDestinationId:"",deduplicationId:""},this._identifier.groupId=o.replaceResolvableFields(t.groupPattern,o.resolvableFieldsOfAll(this,this._description,this._identifier)),this._identifier.groupDestinationId=o.replaceResolvableFields(t.groupDestinationPattern,o.resolvableFieldsOfAll(this,this._description,this._identifier)),this._identifier.deduplicationId=o.replaceResolvableFields(t.deduplicationPattern,o.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)}},o.Transform=function(){function e(e,r){return t(e.category,"")===t(r.category,"")&&t(e.type,"")===t(r.type,"")&&e.fieldName===r.fieldName&&e.value===r.value}function t(e,t){return void 0!==e&&e?e:t}return function(t){this.descriptions=t,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(t){return function(t,r,i){var n,s,l,c,p,d,h,f,g=a.flattenToArray(t);n=g,s=RegExp("\\[\\d+\\]$","gi"),l=[],c="",p="",n.filter(function(e){if(!e.name.match(s)){""!==c&&(l.push({name:c+"_comma_separated_values",value:p}),c=""),l.push(e);return}var t=e.name.replace(s,"");c===t?p+=", "+e.value:(""!==c&&(l.push({name:c+"_comma_separated_values",value:p}),c=""),c=t,p=e.value),l.push(e)}),g=l,i.debugMode&&(console.log("flattened data with array values:"),console.log(g));var m=[];for(f=0;f<r.length;f+=1){d=m,h=function(e,t){var r=RegExp("\\[\\d+\\]","gi"),i=[];return e.filter(function(e){var n=e.name.replace(r,"");if(t.matchesPropertyName(n)){var a=new o.DescribedEntryCreator(e,t);a._isMatchingIndex&&i.push(a)}}),i}(g,r[f]),m=null==d||0==d.length?h:function(e,t,r){var i,n,o,a=function(e,t){for(var r={},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)s.push(n=t[i]);return s}(d,h,function(e){return e._identifier.deduplicationId})}return g=m,i.debugMode&&(console.log("describedData data:"),console.log(g)),g=function(e,t,r){for(var i={},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}(g,function(e){return e._identifier.groupId},function(e){return e._description.groupName}),i.debugMode&&(console.log("grouped describedData data:"),console.log(g)),g=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){var u=r[i];delete e[u]}return e}(g),i.debugMode&&(console.log("moved grouped describedData data:"),console.log(g)),g=function(t,r){var i,n=[];for(i=0;i<t.length;i+=1)n.push(function t(r,i){var n=new u.DescribedDataFieldBuilder().category(r.category).type(r.type).abbreviation(r.abbreviation).image(r.image).index(r.index).displayName(r.displayName).fieldName(r.fieldName).value(r.value).build();if(i.recursionDepth>i.config.maxRecursionDepth)return n;var o=null,a="",s=new u.DescribedDataFieldGroup(n);return function(e,t){var r,i,n,o;for(r=0;r<e.groupNames.length;r+=1)for(i=0,n=e.groupNames[r];i<e[n].length;i+=1)o=e[n][i],t(n,o,e[n])}(r,function(r,n,u){if(i.groupToSkip===r){i.config.debugMode&&console.log("Removed duplicate group "+r+" at recursion depth "+i.recursionDepth);return}a="",i.recursionDepth>=i.config.removeDuplicationAboveRecursionDepth&&(a=!function(e,t,r){if(e===t)return!0;if(null==e||null==t||e.length!==t.length)return!1;for(var i=0;i<e.length;++i)if(!r(e[i],t[i]))return!1;return!0}(n[r],u,e)?"":r),o={recursionDepth:i.recursionDepth+1,config:i.config,groupToSkip:a},s.addGroupEntry(r,t(n,o))}),n}(t[i],{recursionDepth:0,config:r,groupToSkip:""}));return n}(g=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}(g),i),i.debugMode&&(console.log("transformed result:"),console.log(g)),g}(t,this.descriptions,this.config)}}}(),o.Restructor={},o.Restructor.processJsonUsingDescriptions=function(e,t,r){var i=new o.Transform(t);return r&&i.enableDebugMode(),i.processJson(e)}}),parcelRegister("ccQZb",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}}),parcelRegister("ds403",function(e,t){"use strict";var r,i=n(i);function n(e){return e||{}}var o=i.exports={};o.internalCreateIfNotExists=n;var a=a||parcelRequire("ccQZb");r=RegExp("\\[\\d+\\]","gi"),o.Resolver=function(e){this.sourceDataObject=e,this.resolveTemplate=function(e){return this.replaceResolvableFields(e,function(e){var t,i,n,o,a=Object.keys(e);for(t=0;t<a.length;t+=1)o=e[i=a[t]],"fieldName"===(n=function(e){var t=e.lastIndexOf("."),i=e;t>0&&(i=e.substr(t+1));var n="";t>0&&(n=e.substr(0,t+1));var o=n.replace(r,"");return{group:n,groupWithoutArrayIndices:o,name:i}}(i)).name&&"fieldName"!==o&&(e[n.groupWithoutArrayIndices+o]=e[n.group+"value"]);return e}(this.resolvableFieldsOfAll(this.sourceDataObject)))},this.resolvableFieldsOfAll=function(){var e,t={},r=function(e){return 0!==e.indexOf("_")&&0>e.indexOf("._")};for(e=0;e<arguments.length;e+=1)!function(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)}(a.flattenToArray(arguments[e],3),t,r);return t},this.replaceResolvableFields=function(e,t){for(var r=e,i=Object.keys(t),n=0;n<i.length;n+=1){var o=i[n],a=t[o];r=r.replace("{{"+o+"}}",a)}return r}}}),parcelRegister("aJuQy",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"string"==typeof e&&null!==e&&""!==e?e:t}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){var t,r;return this.describedField.index=(r=[],null==(t=e)?r:t),this},this.groupNames=function(e){var t,r;return this.describedField.groupNames=(r=[],null==(t=e)?r:t),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){var r,i;if(!e||0===e.length||!t||0===t.length)return this;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 TypeError();var r,i=this.length>>>0,n=Array(i),o=0,a=-1;if(void 0===t)for(;++a!==i;)a in this&&(r=this[a],e(this[a],a,this)&&(n[o++]=r));else for(;++a!==i;)a in this&&(r=this[a],e.call(t,this[a],a,this)&&(n[o++]=r));return n.length=o,n}),parcelRequire("dED0n"),parcelRequire("b1M0n");var $keJ9m=parcelRequire("keJ9m");module.exports={datarestructor:$keJ9m};
|
|
2
2
|
//# sourceMappingURL=datarestructor-ie.js.map
|