data-restructor 3.4.1 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/codeql-analysis.yml +1 -1
- package/.github/workflows/continuous-integration.yaml +10 -1
- package/CHANGELOG.md +23 -1
- package/coverage/datarestructor.js.html +133 -133
- package/coverage/describedfield.js.html +45 -45
- package/coverage/index.html +1 -1
- package/coverage/templateResolver.js.html +26 -26
- package/devdist/datarestructor-ie.js +12 -12
- package/devdist/datarestructor.js +6 -6
- package/devdist/describedfield-ie.js +2 -2
- package/devdist/templateResolver-ie.js +6 -6
- package/devdist/templateResolver.js +2 -2
- package/dist/datarestructor-ie.js +693 -1
- package/dist/datarestructor-ie.js.map +1 -1
- package/dist/datarestructor.js +687 -1
- package/dist/datarestructor.js.map +1 -1
- package/dist/describedfield-ie.js +142 -1
- package/dist/describedfield-ie.js.map +1 -1
- package/dist/describedfield.js +142 -1
- package/dist/describedfield.js.map +1 -1
- package/dist/templateResolver-ie.js +82 -1
- package/dist/templateResolver-ie.js.map +1 -1
- package/dist/templateResolver.js +76 -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 +1 -1
- package/docs/module-datarestructor.DescribedEntryCreator.html +1 -1
- package/docs/module-datarestructor.PropertyStructureDescriptionBuilder.html +1 -1
- package/docs/module-datarestructor.Restructor.html +1 -1
- package/docs/module-datarestructor.Transform.html +1 -1
- package/docs/module-datarestructor.html +1 -1
- package/docs/module-described_field.DescribedDataFieldBuilder.html +1 -1
- package/docs/module-described_field.DescribedDataFieldGroup.html +1 -1
- package/docs/module-described_field.html +1 -1
- package/docs/module-template_resolver.Resolver.html +1 -1
- package/docs/module-template_resolver.html +1 -1
- package/docs/templateResolver.js.html +1 -1
- package/package.json +7 -7
|
@@ -1,2 +1,143 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=globalThis,e={},t={},r=i.parcelRequirec1f2;null==r&&((r=function(i){if(i in e)return e[i].exports;if(i in t){var r=t[i];delete t[i];var s={id:i,exports:{}};return e[i]=s,r.call(s.exports,s,s.exports),s.exports}var n=Error("Cannot find module '"+i+"'");throw n.code="MODULE_NOT_FOUND",n}).register=function(i,e){t[i]=e},i.parcelRequirec1f2=r),(0,r.register)("d63jw",function(i,e){var t=r(t);// Fallback for vanilla js without modules
|
|
2
|
+
function r(i){return i||{}}/**
|
|
3
|
+
* Describes a data field of the restructured data.
|
|
4
|
+
* @module described_field
|
|
5
|
+
*/var s=t.exports={};// Export module for npm...
|
|
6
|
+
s.internalCreateIfNotExists=r,/**
|
|
7
|
+
* Describes a field of the restructured data.
|
|
8
|
+
* Dynamically added properties represent custom named groups containing DescribedDataField-Arrays.
|
|
9
|
+
*
|
|
10
|
+
* @typedef {Object} module:described_field.DescribedDataField
|
|
11
|
+
* @property {string} [category=""] - name of the category. Could contain a short domain name like "product" or "vendor".
|
|
12
|
+
* @property {string} [type=""] - type of the data element. Examples: "summary" for e.g. a list overview. "detail" e.g. when a summary is selected. "filter" e.g. for field/value pair results that can be selected as data filters.
|
|
13
|
+
* @property {string} [abbreviation=""] - one optional character, a symbol character or a short abbreviation of the category
|
|
14
|
+
* @property {string} [image=""] - one optional path to an image resource
|
|
15
|
+
* @property {string} index - array of numbers containing the splitted index. Example: "responses[2].hits.hits[4]._source.name" will have an index of [2,4]
|
|
16
|
+
* @property {string[]} groupNames - array of names of all dynamically added properties representing groups
|
|
17
|
+
* @property {string} displayName - display name of the field
|
|
18
|
+
* @property {string} fieldName - field name
|
|
19
|
+
* @property {{*}} value - content of the field
|
|
20
|
+
* @property {module:described_field.DescribedDataField[]} [couldBeAnyCustomGroupName] any number of groups attached to the field each containing multiple fields
|
|
21
|
+
*/s.DescribedDataFieldBuilder=function(){function i(i,e){return"string"==typeof i&&null!==i&&""!==i?i:e}return(/**
|
|
22
|
+
* Builds a {@link module:described_field.DescribedDataField}.
|
|
23
|
+
* DescribedDataField is the main element of the restructured data and therefore considered "public".
|
|
24
|
+
* @constructs DescribedDataFieldBuilder
|
|
25
|
+
* @alias module:described_field.DescribedDataFieldBuilder
|
|
26
|
+
*/function(){/**
|
|
27
|
+
* @type {module:described_field.DescribedDataField}
|
|
28
|
+
*/this.describedField={category:"",type:"",abbreviation:"",image:"",index:[],groupNames:[],displayName:"",fieldName:"",value:""},/**
|
|
29
|
+
* Takes over all values of the template {@link module:described_field.DescribedDataField}.
|
|
30
|
+
* @function
|
|
31
|
+
* @param {module:described_field.DescribedDataField} template
|
|
32
|
+
* @returns {DescribedDataFieldBuilder}
|
|
33
|
+
* @example fromDescribedDataField(sourceField)
|
|
34
|
+
*/this.fromDescribedDataField=function(i){return this.category(i.category),this.type(i.type),this.abbreviation(i.abbreviation),this.image(i.image),this.index(i.index),this.groupNames(i.groupNames),this.displayName(i.displayName),this.fieldName(i.fieldName),this.value(i.value),this},/**
|
|
35
|
+
* Sets the category.
|
|
36
|
+
*
|
|
37
|
+
* Contains a short domain nam, for example:
|
|
38
|
+
* - "product" for products
|
|
39
|
+
* - "vendor" for vendors
|
|
40
|
+
*
|
|
41
|
+
* @function
|
|
42
|
+
* @param {String} [value=""]
|
|
43
|
+
* @returns {DescribedDataFieldBuilder}
|
|
44
|
+
* @example category("Product")
|
|
45
|
+
*/this.category=function(e){return this.describedField.category=i(e,""),this},/**
|
|
46
|
+
* Sets the type.
|
|
47
|
+
*
|
|
48
|
+
* Contains the type of the entry, for example:
|
|
49
|
+
* - "summary" for e.g. a list overview.
|
|
50
|
+
* - "detail" e.g. when a summary is selected.
|
|
51
|
+
* - "filter" e.g. for field/value pair results that can be selected as search parameters.
|
|
52
|
+
*
|
|
53
|
+
* @function
|
|
54
|
+
* @param {String} [value=""]
|
|
55
|
+
* @returns {DescribedDataFieldBuilder}
|
|
56
|
+
* @example type("summary")
|
|
57
|
+
*/this.type=function(e){return this.describedField.type=i(e,""),this},/**
|
|
58
|
+
* Sets the optional abbreviation.
|
|
59
|
+
*
|
|
60
|
+
* Contains a symbol character or a very short abbreviation of the category.
|
|
61
|
+
* - "P" for products
|
|
62
|
+
* - "V" for vendors
|
|
63
|
+
*
|
|
64
|
+
* @function
|
|
65
|
+
* @param {String} [value=""]
|
|
66
|
+
* @returns {DescribedDataFieldBuilder}
|
|
67
|
+
* @example abbreviation("P")
|
|
68
|
+
*/this.abbreviation=function(e){return this.describedField.abbreviation=i(e,""),this},/**
|
|
69
|
+
* Sets the optional path to an image resource.
|
|
70
|
+
*
|
|
71
|
+
* @function
|
|
72
|
+
* @param {String} [value=""]
|
|
73
|
+
* @returns {DescribedDataFieldBuilder}
|
|
74
|
+
* @example image("img/product.png")
|
|
75
|
+
*/this.image=function(e){return this.describedField.image=i(e,""),this},/**
|
|
76
|
+
* Sets the index as an array of numbers containing the splitted array indexes of the source field.
|
|
77
|
+
* Example: "responses[2].hits.hits[4]._source.name" will have an index of [2,4].
|
|
78
|
+
*
|
|
79
|
+
* @function
|
|
80
|
+
* @param {number[]} [value=[]]
|
|
81
|
+
* @returns {DescribedDataFieldBuilder}
|
|
82
|
+
* @example index([2,4])
|
|
83
|
+
*/this.index=function(i){return this.describedField.index=null==i?[]:i,this},/**
|
|
84
|
+
* Sets the group names as an array of strings containing the names of the dynamically added properties,
|
|
85
|
+
* that contain an array of {@link module:described_field.DescribedDataField}-Objects.
|
|
86
|
+
*
|
|
87
|
+
* @function
|
|
88
|
+
* @param {string[]} [value=[]]
|
|
89
|
+
* @returns {DescribedDataFieldBuilder}
|
|
90
|
+
* @example groupNames(["summaries","details","options"])
|
|
91
|
+
*/this.groupNames=function(i){return this.describedField.groupNames=null==i?[]:i,this},/**
|
|
92
|
+
* Sets the display name.
|
|
93
|
+
*
|
|
94
|
+
* @function
|
|
95
|
+
* @param {String} [value=""]
|
|
96
|
+
* @returns {DescribedDataFieldBuilder}
|
|
97
|
+
* @example displayName("Color")
|
|
98
|
+
*/this.displayName=function(e){return this.describedField.displayName=i(e,""),this},/**
|
|
99
|
+
* Sets the (technical) field name.
|
|
100
|
+
*
|
|
101
|
+
* @function
|
|
102
|
+
* @param {String} [value=""]
|
|
103
|
+
* @returns {DescribedDataFieldBuilder}
|
|
104
|
+
* @example fieldName("color")
|
|
105
|
+
*/this.fieldName=function(e){return this.describedField.fieldName=i(e,""),this},/**
|
|
106
|
+
* Sets the value/content of the field.
|
|
107
|
+
*
|
|
108
|
+
* @function
|
|
109
|
+
* @param {*} value
|
|
110
|
+
* @returns {DescribedDataFieldBuilder}
|
|
111
|
+
* @example value("darkblue")
|
|
112
|
+
*/this.value=function(i){return this.describedField.value=i,this},/**
|
|
113
|
+
* Finalizes the settings and builds the {@link module:described_field.DescribedDataField}.
|
|
114
|
+
* @function
|
|
115
|
+
* @returns {module:described_field.DescribedDataField}
|
|
116
|
+
*/this.build=function(){return this.describedField}})}(),/**
|
|
117
|
+
* Creates a new described data field with all properties of the original one except for dynamically added groups.
|
|
118
|
+
* @param {module:described_field.DescribedDataField} describedDataField
|
|
119
|
+
* @returns {module:described_field.DescribedDataField}
|
|
120
|
+
* @memberof module:described_field
|
|
121
|
+
*/s.copyWithoutGroups=function(i){return new s.DescribedDataFieldBuilder().fromDescribedDataField(i).groupNames([]).build()},s.DescribedDataFieldGroup=/**
|
|
122
|
+
* Adds groups to {@link module:described_field.DescribedDataField}s. These groups are dynamically added properties
|
|
123
|
+
* that contain an array of sub fields of the same type {@link module:described_field.DescribedDataField}s.
|
|
124
|
+
*
|
|
125
|
+
* @param {module:described_field.DescribedDataField} dataField
|
|
126
|
+
* @constructs DescribedDataFieldGroup
|
|
127
|
+
* @alias module:described_field.DescribedDataFieldGroup
|
|
128
|
+
* @example new described_field.DescribedDataFieldGroup(field).addGroupEntry("details", detailField);
|
|
129
|
+
*/function(i){this.dataField=i,/**
|
|
130
|
+
* Adds an entry to the given group. If the group does not exist, it will be created.
|
|
131
|
+
* @function
|
|
132
|
+
* @param {String} groupName name of the group to which the entry will be added
|
|
133
|
+
* @param {module:described_field.DescribedDataField} describedField sub field that is added to the group
|
|
134
|
+
* @returns {DescribedDataFieldGroup}
|
|
135
|
+
*/this.addGroupEntry=function(i,e){return this.addGroupEntries(i,[e]),this},/**
|
|
136
|
+
* Adds entries to the given group. If the group does not exist, it will be created.
|
|
137
|
+
* @function
|
|
138
|
+
* @param {String} groupName name of the group to which the entries will be added
|
|
139
|
+
* @param {module:described_field.DescribedDataField[]} describedFields sub fields that are added to the group
|
|
140
|
+
* @returns {DescribedDataFieldGroup}
|
|
141
|
+
*/this.addGroupEntries=function(i,e){var t,r;if(!i||0===i.length||!e||0===e.length)return this;for(void 0===this.dataField[i]&&(this.dataField.groupNames.push(i),this.dataField[i]=[]),t=0;t<e.length;t+=1)r=e[t],this.dataField[i].push(r);return this}}});var s=r("d63jw");module.exports={described_field:s};//# sourceMappingURL=describedfield-ie.js.map
|
|
142
|
+
|
|
2
143
|
//# sourceMappingURL=describedfield-ie.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"sgBAMA,aACA,IAAIA,EAASC,EAAwCD,GAErD,SAASC,EAAwCC,GAC/C,OAAOA,GAAiB,CAAC,CAC3B,CAMA,IAAIC,EAAmBH,EAAOI,QAAU,CAAC,EACzCD,EAAgBE,0BAA4BJ,EAmB5CE,EAAgBG,0BAA6B,WAmL3C,SAASC,EAAkBC,EAAOC,GAChC,OALF,SAA2BD,GACzB,MAAwB,iBAAVA,GAAgC,OAAVA,GAA4B,KAAVA,CACxD,CAGSE,CAAkBF,GAASA,EAAQC,CAC5C,CAEA,SAASE,EAAiBH,EAAOC,GAC/B,OAAOD,QAAwCC,EAAeD,CAChE,CAEA,OApLA,WAIEI,KAAKC,eAAiB,CACpBC,SAAU,GACVC,KAAM,GACNC,aAAc,GACdC,MAAO,GACPC,MAAO,GACPC,WAAY,GACZC,YAAa,GACbC,UAAW,GACXb,MAAO,IASTI,KAAKU,uBAAyB,SAAUC,GAUtC,OATAX,KAAKE,SAASS,EAAST,UACvBF,KAAKG,KAAKQ,EAAS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,UAAYA,EASjBhB,KAAKiB,cAAgB,SAAUC,EAAWjB,GAExC,OADAD,KAAKmB,gBAAgBD,EAAW,CAACjB,IAC1BD,IACT,EASAA,KAAKmB,gBAAkB,SAAUD,EAAWE,GAC1C,IAAKF,GAAkC,IAArBA,EAAUG,OAC1B,OAAOrB,KAET,IAAKoB,GAA8C,IAA3BA,EAAgBC,OACtC,OAAOrB,KAMT,IAAIM,EACAL,EACJ,SANkCqB,IAA9BtB,KAAKgB,UAAUE,KACjBlB,KAAKgB,UAAUT,WAAWgB,KAAKL,GAC/BlB,KAAKgB,UAAUE,GAAa,IAIzBZ,EAAQ,EAAGA,EAAQc,EAAgBC,OAAQf,GAAS,EACvDL,EAAiBmB,EAAgBd,GACjCN,KAAKgB,UAAUE,GAAWK,KAAKtB,GAEjC,OAAOD,IACT,CACF,C,qBC9RFwB,OAAAhC,QAAiB,CAACiC,gBAAkBC","sources":["src/js/describedfield.js","src/js/describedfield-ie.js"],"sourcesContent":["/**\n * @file Describes a data field of the restructured data.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */\n\"use strict\";\nvar module = describedFieldInternalCreateIfNotExists(module); // Fallback for vanilla js without modules\n\nfunction describedFieldInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n\n/**\n * Describes a data field of the restructured data.\n * @module described_field\n */\nvar described_field = (module.exports = {}); // Export module for npm...\ndescribed_field.internalCreateIfNotExists = describedFieldInternalCreateIfNotExists;\n\n/**\n * Describes a field of the restructured data.\n * Dynamically added properties represent custom named groups containing DescribedDataField-Arrays.\n *\n * @typedef {Object} module:described_field.DescribedDataField\n * @property {string} [category=\"\"] - name of the category. Could contain a short domain name like \"product\" or \"vendor\".\n * @property {string} [type=\"\"] - type of the data element. Examples: \"summary\" for e.g. a list overview. \"detail\" e.g. when a summary is selected. \"filter\" e.g. for field/value pair results that can be selected as data filters.\n * @property {string} [abbreviation=\"\"] - one optional character, a symbol character or a short abbreviation of the category\n * @property {string} [image=\"\"] - one optional path to an image resource\n * @property {string} index - array of numbers containing the splitted index. Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4]\n * @property {string[]} groupNames - array of names of all dynamically added properties representing groups\n * @property {string} displayName - display name of the field\n * @property {string} fieldName - field name\n * @property {{*}} value - content of the field\n * @property {module:described_field.DescribedDataField[]} [couldBeAnyCustomGroupName] any number of groups attached to the field each containing multiple fields\n */\n\ndescribed_field.DescribedDataFieldBuilder = (function () {\n /**\n * Builds a {@link module:described_field.DescribedDataField}.\n * DescribedDataField is the main element of the restructured data and therefore considered \"public\".\n * @constructs DescribedDataFieldBuilder\n * @alias module:described_field.DescribedDataFieldBuilder\n */\n function DescribedDataFieldBuilder() {\n /**\n * @type {module:described_field.DescribedDataField}\n */\n this.describedField = {\n category: \"\",\n type: \"\",\n abbreviation: \"\",\n image: \"\",\n index: [],\n groupNames: [],\n displayName: \"\",\n fieldName: \"\",\n value: \"\"\n };\n /**\n * Takes over all values of the template {@link module:described_field.DescribedDataField}.\n * @function\n * @param {module:described_field.DescribedDataField} template\n * @returns {DescribedDataFieldBuilder}\n * @example fromDescribedDataField(sourceField)\n */\n this.fromDescribedDataField = function (template) {\n this.category(template.category);\n this.type(template.type);\n this.abbreviation(template.abbreviation);\n this.image(template.image);\n this.index(template.index);\n this.groupNames(template.groupNames);\n this.displayName(template.displayName);\n this.fieldName(template.fieldName);\n this.value(template.value);\n return this;\n };\n /**\n * Sets the category.\n *\n * Contains a short domain nam, for example:\n * - \"product\" for products\n * - \"vendor\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example category(\"Product\")\n */\n this.category = function (value) {\n this.describedField.category = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the type.\n *\n * Contains the type of the entry, for example:\n * - \"summary\" for e.g. a list overview.\n * - \"detail\" e.g. when a summary is selected.\n * - \"filter\" e.g. for field/value pair results that can be selected as search parameters.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example type(\"summary\")\n */\n this.type = function (value) {\n this.describedField.type = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional abbreviation.\n *\n * Contains a symbol character or a very short abbreviation of the category.\n * - \"P\" for products\n * - \"V\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example abbreviation(\"P\")\n */\n this.abbreviation = function (value) {\n this.describedField.abbreviation = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional path to an image resource.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example image(\"img/product.png\")\n */\n this.image = function (value) {\n this.describedField.image = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the index as an array of numbers containing the splitted array indexes of the source field.\n * Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4].\n *\n * @function\n * @param {number[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example index([2,4])\n */\n this.index = function (value) {\n this.describedField.index = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the group names as an array of strings containing the names of the dynamically added properties,\n * that contain an array of {@link module:described_field.DescribedDataField}-Objects.\n *\n * @function\n * @param {string[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example groupNames([\"summaries\",\"details\",\"options\"])\n */\n this.groupNames = function (value) {\n this.describedField.groupNames = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the display name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example displayName(\"Color\")\n */\n this.displayName = function (value) {\n this.describedField.displayName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the (technical) field name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example fieldName(\"color\")\n */\n this.fieldName = function (value) {\n this.describedField.fieldName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the value/content of the field.\n *\n * @function\n * @param {*} value\n * @returns {DescribedDataFieldBuilder}\n * @example value(\"darkblue\")\n */\n this.value = function (value) {\n this.describedField.value = value;\n return this;\n };\n\n /**\n * Finalizes the settings and builds the {@link module:described_field.DescribedDataField}.\n * @function\n * @returns {module:described_field.DescribedDataField}\n */\n this.build = function () {\n return this.describedField;\n };\n }\n\n function isSpecifiedString(value) {\n return typeof value === \"string\" && value !== null && value !== \"\";\n }\n\n function withDefaultString(value, defaultValue) {\n return isSpecifiedString(value) ? value : defaultValue;\n }\n\n function withDefaultArray(value, defaultValue) {\n return value === undefined || value === null ? defaultValue : value;\n }\n\n return DescribedDataFieldBuilder;\n}());\n\n/**\n * Creates a new described data field with all properties of the original one except for dynamically added groups.\n * @param {module:described_field.DescribedDataField} describedDataField\n * @returns {module:described_field.DescribedDataField}\n * @memberof module:described_field\n */\ndescribed_field.copyWithoutGroups = function (describedDataField) {\n return new described_field.DescribedDataFieldBuilder().fromDescribedDataField(describedDataField).groupNames([]).build();\n};\n\ndescribed_field.DescribedDataFieldGroup = (function () {\n /**\n * Adds groups to {@link module:described_field.DescribedDataField}s. These groups are dynamically added properties\n * that contain an array of sub fields of the same type {@link module:described_field.DescribedDataField}s.\n *\n * @param {module:described_field.DescribedDataField} dataField\n * @constructs DescribedDataFieldGroup\n * @alias module:described_field.DescribedDataFieldGroup\n * @example new described_field.DescribedDataFieldGroup(field).addGroupEntry(\"details\", detailField);\n */\n function DescribedDataFieldGroup(dataField) {\n this.dataField = dataField;\n\n /**\n * Adds an entry to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entry will be added\n * @param {module:described_field.DescribedDataField} describedField sub field that is added to the group\n * @returns {DescribedDataFieldGroup}\n */\n this.addGroupEntry = function (groupName, describedField) {\n this.addGroupEntries(groupName, [describedField]);\n return this;\n };\n\n /**\n * Adds entries to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entries will be added\n * @param {module:described_field.DescribedDataField[]} describedFields sub fields that are added to the group\n * @returns {DescribedDataFieldGroup}\n */\n this.addGroupEntries = function (groupName, describedFields) {\n if (!groupName || groupName.length === 0) {\n return this;\n }\n if (!describedFields || describedFields.length === 0) {\n return this;\n }\n if (this.dataField[groupName] === undefined) {\n this.dataField.groupNames.push(groupName);\n this.dataField[groupName] = [];\n }\n var index;\n var describedField;\n for (index = 0; index < describedFields.length; index += 1) {\n describedField = describedFields[index];\n this.dataField[groupName].push(describedField);\n }\n return this;\n };\n }\n\n return DescribedDataFieldGroup;\n}());\n","\"use strict\";\nvar described_field = require(\"../../src/js/describedfield.js\");\nmodule.exports = {described_field : described_field};\n"],"names":["$988e67f614ef1b49$var$module","$988e67f614ef1b49$var$describedFieldInternalCreateIfNotExists","objectToCheck","$988e67f614ef1b49$var$described_field","exports","internalCreateIfNotExists","DescribedDataFieldBuilder","withDefaultString","value","defaultValue","isSpecifiedString","withDefaultArray","this","describedField","category","type","abbreviation","image","index","groupNames","displayName","fieldName","fromDescribedDataField","template","build","copyWithoutGroups","describedDataField","DescribedDataFieldGroup","dataField","addGroupEntry","groupName","addGroupEntries","describedFields","length","undefined","push","module","described_field","$d63jw"],"version":3,"file":"describedfield-ie.js.map","sourceRoot":"../"}
|
|
1
|
+
{"mappings":"A,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,Q,C,S,C,C,C,E,C,C,E,C,C,E,E,iB,C,G,A,C,E,E,Q,A,E,Q,S,C,C,C,ECOA,IAAI,EAAS,EAAwC,EAAS,2CAA0C;AAExG,SAAS,EAAwC,CAAa,EAC5D,OAAO,GAAiB,CAAC,CAC3B,CAEA;;;CAGC,EACD,IAAI,EAAmB,EAAO,OAAO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;GAQC,EACD,SAAiC,CAAS,EACxC,IAAI,CAAC,SAAS,CAAG,EAEjB;;;;;;KAMC,EACD,IAAI,CAAC,aAAa,CAAG,SAAU,CAAS,CAAE,CAAc,EAEtD,OADA,IAAI,CAAC,eAAe,CAAC,EAAW,CAAC,EAAe,EACzC,IAAI,AACb,EAEA;;;;;;KAMC,EACD,IAAI,CAAC,eAAe,CAAG,SAAU,CAAS,CAAE,CAAe,MAWrD,EACA,EAXJ,GAAI,CAAC,GAAa,AAAqB,IAArB,EAAU,MAAM,EAG9B,CAAC,GAAmB,AAA2B,IAA3B,EAAgB,MAAM,CAF5C,OAAO,IAAI,CAWb,IANkC,KAAA,IAA9B,IAAI,CAAC,SAAS,CAAC,EAAU,GAC3B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAC/B,IAAI,CAAC,SAAS,CAAC,EAAU,CAAG,EAAE,EAI3B,EAAQ,EAAG,EAAQ,EAAgB,MAAM,CAAE,GAAS,EACvD,EAAiB,CAAe,CAAC,EAAM,CACvC,IAAI,CAAC,SAAS,CAAC,EAAU,CAAC,IAAI,CAAC,GAEjC,OAAO,IAAI,AACb,CACF,C,G,I,E,E,QC9RF,CAAA,OAAA,OAAA,CAAiB,CAAC,gBAAkB,CAAe,C,8C","sources":["<anon>","src/js/describedfield.js","src/js/describedfield-ie.js"],"sourcesContent":["\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirec1f2\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirec1f2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nparcelRegister(\"d63jw\", function(module, exports) {\n/**\n * @file Describes a data field of the restructured data.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */ \"use strict\";\nvar $988e67f614ef1b49$var$module = $988e67f614ef1b49$var$describedFieldInternalCreateIfNotExists($988e67f614ef1b49$var$module); // Fallback for vanilla js without modules\nfunction $988e67f614ef1b49$var$describedFieldInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n/**\n * Describes a data field of the restructured data.\n * @module described_field\n */ var $988e67f614ef1b49$var$described_field = $988e67f614ef1b49$var$module.exports = {}; // Export module for npm...\n$988e67f614ef1b49$var$described_field.internalCreateIfNotExists = $988e67f614ef1b49$var$describedFieldInternalCreateIfNotExists;\n/**\n * Describes a field of the restructured data.\n * Dynamically added properties represent custom named groups containing DescribedDataField-Arrays.\n *\n * @typedef {Object} module:described_field.DescribedDataField\n * @property {string} [category=\"\"] - name of the category. Could contain a short domain name like \"product\" or \"vendor\".\n * @property {string} [type=\"\"] - type of the data element. Examples: \"summary\" for e.g. a list overview. \"detail\" e.g. when a summary is selected. \"filter\" e.g. for field/value pair results that can be selected as data filters.\n * @property {string} [abbreviation=\"\"] - one optional character, a symbol character or a short abbreviation of the category\n * @property {string} [image=\"\"] - one optional path to an image resource\n * @property {string} index - array of numbers containing the splitted index. Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4]\n * @property {string[]} groupNames - array of names of all dynamically added properties representing groups\n * @property {string} displayName - display name of the field\n * @property {string} fieldName - field name\n * @property {{*}} value - content of the field\n * @property {module:described_field.DescribedDataField[]} [couldBeAnyCustomGroupName] any number of groups attached to the field each containing multiple fields\n */ $988e67f614ef1b49$var$described_field.DescribedDataFieldBuilder = function() {\n /**\n * Builds a {@link module:described_field.DescribedDataField}.\n * DescribedDataField is the main element of the restructured data and therefore considered \"public\".\n * @constructs DescribedDataFieldBuilder\n * @alias module:described_field.DescribedDataFieldBuilder\n */ function DescribedDataFieldBuilder() {\n /**\n * @type {module:described_field.DescribedDataField}\n */ this.describedField = {\n category: \"\",\n type: \"\",\n abbreviation: \"\",\n image: \"\",\n index: [],\n groupNames: [],\n displayName: \"\",\n fieldName: \"\",\n value: \"\"\n };\n /**\n * Takes over all values of the template {@link module:described_field.DescribedDataField}.\n * @function\n * @param {module:described_field.DescribedDataField} template\n * @returns {DescribedDataFieldBuilder}\n * @example fromDescribedDataField(sourceField)\n */ this.fromDescribedDataField = function(template) {\n this.category(template.category);\n this.type(template.type);\n this.abbreviation(template.abbreviation);\n this.image(template.image);\n this.index(template.index);\n this.groupNames(template.groupNames);\n this.displayName(template.displayName);\n this.fieldName(template.fieldName);\n this.value(template.value);\n return this;\n };\n /**\n * Sets the category.\n *\n * Contains a short domain nam, for example:\n * - \"product\" for products\n * - \"vendor\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example category(\"Product\")\n */ this.category = function(value) {\n this.describedField.category = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the type.\n *\n * Contains the type of the entry, for example:\n * - \"summary\" for e.g. a list overview.\n * - \"detail\" e.g. when a summary is selected.\n * - \"filter\" e.g. for field/value pair results that can be selected as search parameters.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example type(\"summary\")\n */ this.type = function(value) {\n this.describedField.type = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional abbreviation.\n *\n * Contains a symbol character or a very short abbreviation of the category.\n * - \"P\" for products\n * - \"V\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example abbreviation(\"P\")\n */ this.abbreviation = function(value) {\n this.describedField.abbreviation = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional path to an image resource.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example image(\"img/product.png\")\n */ this.image = function(value) {\n this.describedField.image = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the index as an array of numbers containing the splitted array indexes of the source field.\n * Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4].\n *\n * @function\n * @param {number[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example index([2,4])\n */ this.index = function(value) {\n this.describedField.index = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the group names as an array of strings containing the names of the dynamically added properties,\n * that contain an array of {@link module:described_field.DescribedDataField}-Objects.\n *\n * @function\n * @param {string[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example groupNames([\"summaries\",\"details\",\"options\"])\n */ this.groupNames = function(value) {\n this.describedField.groupNames = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the display name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example displayName(\"Color\")\n */ this.displayName = function(value) {\n this.describedField.displayName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the (technical) field name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example fieldName(\"color\")\n */ this.fieldName = function(value) {\n this.describedField.fieldName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the value/content of the field.\n *\n * @function\n * @param {*} value\n * @returns {DescribedDataFieldBuilder}\n * @example value(\"darkblue\")\n */ this.value = function(value) {\n this.describedField.value = value;\n return this;\n };\n /**\n * Finalizes the settings and builds the {@link module:described_field.DescribedDataField}.\n * @function\n * @returns {module:described_field.DescribedDataField}\n */ this.build = function() {\n return this.describedField;\n };\n }\n function isSpecifiedString(value) {\n return typeof value === \"string\" && value !== null && value !== \"\";\n }\n function withDefaultString(value, defaultValue) {\n return isSpecifiedString(value) ? value : defaultValue;\n }\n function withDefaultArray(value, defaultValue) {\n return value === undefined || value === null ? defaultValue : value;\n }\n return DescribedDataFieldBuilder;\n}();\n/**\n * Creates a new described data field with all properties of the original one except for dynamically added groups.\n * @param {module:described_field.DescribedDataField} describedDataField\n * @returns {module:described_field.DescribedDataField}\n * @memberof module:described_field\n */ $988e67f614ef1b49$var$described_field.copyWithoutGroups = function(describedDataField) {\n return new $988e67f614ef1b49$var$described_field.DescribedDataFieldBuilder().fromDescribedDataField(describedDataField).groupNames([]).build();\n};\n$988e67f614ef1b49$var$described_field.DescribedDataFieldGroup = function() {\n /**\n * Adds groups to {@link module:described_field.DescribedDataField}s. These groups are dynamically added properties\n * that contain an array of sub fields of the same type {@link module:described_field.DescribedDataField}s.\n *\n * @param {module:described_field.DescribedDataField} dataField\n * @constructs DescribedDataFieldGroup\n * @alias module:described_field.DescribedDataFieldGroup\n * @example new described_field.DescribedDataFieldGroup(field).addGroupEntry(\"details\", detailField);\n */ function DescribedDataFieldGroup(dataField) {\n this.dataField = dataField;\n /**\n * Adds an entry to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entry will be added\n * @param {module:described_field.DescribedDataField} describedField sub field that is added to the group\n * @returns {DescribedDataFieldGroup}\n */ this.addGroupEntry = function(groupName, describedField) {\n this.addGroupEntries(groupName, [\n describedField\n ]);\n return this;\n };\n /**\n * Adds entries to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entries will be added\n * @param {module:described_field.DescribedDataField[]} describedFields sub fields that are added to the group\n * @returns {DescribedDataFieldGroup}\n */ this.addGroupEntries = function(groupName, describedFields) {\n if (!groupName || groupName.length === 0) return this;\n if (!describedFields || describedFields.length === 0) return this;\n if (this.dataField[groupName] === undefined) {\n this.dataField.groupNames.push(groupName);\n this.dataField[groupName] = [];\n }\n var index;\n var describedField;\n for(index = 0; index < describedFields.length; index += 1){\n describedField = describedFields[index];\n this.dataField[groupName].push(describedField);\n }\n return this;\n };\n }\n return DescribedDataFieldGroup;\n}();\n\n});\n\n\"use strict\";\n\nvar $d63jw = parcelRequire(\"d63jw\");\nmodule.exports = {\n described_field: $d63jw\n};\n\n\n//# sourceMappingURL=describedfield-ie.js.map\n","/**\n * @file Describes a data field of the restructured data.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */\n\"use strict\";\nvar module = describedFieldInternalCreateIfNotExists(module); // Fallback for vanilla js without modules\n\nfunction describedFieldInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n\n/**\n * Describes a data field of the restructured data.\n * @module described_field\n */\nvar described_field = (module.exports = {}); // Export module for npm...\ndescribed_field.internalCreateIfNotExists = describedFieldInternalCreateIfNotExists;\n\n/**\n * Describes a field of the restructured data.\n * Dynamically added properties represent custom named groups containing DescribedDataField-Arrays.\n *\n * @typedef {Object} module:described_field.DescribedDataField\n * @property {string} [category=\"\"] - name of the category. Could contain a short domain name like \"product\" or \"vendor\".\n * @property {string} [type=\"\"] - type of the data element. Examples: \"summary\" for e.g. a list overview. \"detail\" e.g. when a summary is selected. \"filter\" e.g. for field/value pair results that can be selected as data filters.\n * @property {string} [abbreviation=\"\"] - one optional character, a symbol character or a short abbreviation of the category\n * @property {string} [image=\"\"] - one optional path to an image resource\n * @property {string} index - array of numbers containing the splitted index. Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4]\n * @property {string[]} groupNames - array of names of all dynamically added properties representing groups\n * @property {string} displayName - display name of the field\n * @property {string} fieldName - field name\n * @property {{*}} value - content of the field\n * @property {module:described_field.DescribedDataField[]} [couldBeAnyCustomGroupName] any number of groups attached to the field each containing multiple fields\n */\n\ndescribed_field.DescribedDataFieldBuilder = (function () {\n /**\n * Builds a {@link module:described_field.DescribedDataField}.\n * DescribedDataField is the main element of the restructured data and therefore considered \"public\".\n * @constructs DescribedDataFieldBuilder\n * @alias module:described_field.DescribedDataFieldBuilder\n */\n function DescribedDataFieldBuilder() {\n /**\n * @type {module:described_field.DescribedDataField}\n */\n this.describedField = {\n category: \"\",\n type: \"\",\n abbreviation: \"\",\n image: \"\",\n index: [],\n groupNames: [],\n displayName: \"\",\n fieldName: \"\",\n value: \"\"\n };\n /**\n * Takes over all values of the template {@link module:described_field.DescribedDataField}.\n * @function\n * @param {module:described_field.DescribedDataField} template\n * @returns {DescribedDataFieldBuilder}\n * @example fromDescribedDataField(sourceField)\n */\n this.fromDescribedDataField = function (template) {\n this.category(template.category);\n this.type(template.type);\n this.abbreviation(template.abbreviation);\n this.image(template.image);\n this.index(template.index);\n this.groupNames(template.groupNames);\n this.displayName(template.displayName);\n this.fieldName(template.fieldName);\n this.value(template.value);\n return this;\n };\n /**\n * Sets the category.\n *\n * Contains a short domain nam, for example:\n * - \"product\" for products\n * - \"vendor\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example category(\"Product\")\n */\n this.category = function (value) {\n this.describedField.category = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the type.\n *\n * Contains the type of the entry, for example:\n * - \"summary\" for e.g. a list overview.\n * - \"detail\" e.g. when a summary is selected.\n * - \"filter\" e.g. for field/value pair results that can be selected as search parameters.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example type(\"summary\")\n */\n this.type = function (value) {\n this.describedField.type = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional abbreviation.\n *\n * Contains a symbol character or a very short abbreviation of the category.\n * - \"P\" for products\n * - \"V\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example abbreviation(\"P\")\n */\n this.abbreviation = function (value) {\n this.describedField.abbreviation = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional path to an image resource.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example image(\"img/product.png\")\n */\n this.image = function (value) {\n this.describedField.image = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the index as an array of numbers containing the splitted array indexes of the source field.\n * Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4].\n *\n * @function\n * @param {number[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example index([2,4])\n */\n this.index = function (value) {\n this.describedField.index = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the group names as an array of strings containing the names of the dynamically added properties,\n * that contain an array of {@link module:described_field.DescribedDataField}-Objects.\n *\n * @function\n * @param {string[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example groupNames([\"summaries\",\"details\",\"options\"])\n */\n this.groupNames = function (value) {\n this.describedField.groupNames = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the display name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example displayName(\"Color\")\n */\n this.displayName = function (value) {\n this.describedField.displayName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the (technical) field name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example fieldName(\"color\")\n */\n this.fieldName = function (value) {\n this.describedField.fieldName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the value/content of the field.\n *\n * @function\n * @param {*} value\n * @returns {DescribedDataFieldBuilder}\n * @example value(\"darkblue\")\n */\n this.value = function (value) {\n this.describedField.value = value;\n return this;\n };\n\n /**\n * Finalizes the settings and builds the {@link module:described_field.DescribedDataField}.\n * @function\n * @returns {module:described_field.DescribedDataField}\n */\n this.build = function () {\n return this.describedField;\n };\n }\n\n function isSpecifiedString(value) {\n return typeof value === \"string\" && value !== null && value !== \"\";\n }\n\n function withDefaultString(value, defaultValue) {\n return isSpecifiedString(value) ? value : defaultValue;\n }\n\n function withDefaultArray(value, defaultValue) {\n return value === undefined || value === null ? defaultValue : value;\n }\n\n return DescribedDataFieldBuilder;\n}());\n\n/**\n * Creates a new described data field with all properties of the original one except for dynamically added groups.\n * @param {module:described_field.DescribedDataField} describedDataField\n * @returns {module:described_field.DescribedDataField}\n * @memberof module:described_field\n */\ndescribed_field.copyWithoutGroups = function (describedDataField) {\n return new described_field.DescribedDataFieldBuilder().fromDescribedDataField(describedDataField).groupNames([]).build();\n};\n\ndescribed_field.DescribedDataFieldGroup = (function () {\n /**\n * Adds groups to {@link module:described_field.DescribedDataField}s. These groups are dynamically added properties\n * that contain an array of sub fields of the same type {@link module:described_field.DescribedDataField}s.\n *\n * @param {module:described_field.DescribedDataField} dataField\n * @constructs DescribedDataFieldGroup\n * @alias module:described_field.DescribedDataFieldGroup\n * @example new described_field.DescribedDataFieldGroup(field).addGroupEntry(\"details\", detailField);\n */\n function DescribedDataFieldGroup(dataField) {\n this.dataField = dataField;\n\n /**\n * Adds an entry to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entry will be added\n * @param {module:described_field.DescribedDataField} describedField sub field that is added to the group\n * @returns {DescribedDataFieldGroup}\n */\n this.addGroupEntry = function (groupName, describedField) {\n this.addGroupEntries(groupName, [describedField]);\n return this;\n };\n\n /**\n * Adds entries to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entries will be added\n * @param {module:described_field.DescribedDataField[]} describedFields sub fields that are added to the group\n * @returns {DescribedDataFieldGroup}\n */\n this.addGroupEntries = function (groupName, describedFields) {\n if (!groupName || groupName.length === 0) {\n return this;\n }\n if (!describedFields || describedFields.length === 0) {\n return this;\n }\n if (this.dataField[groupName] === undefined) {\n this.dataField.groupNames.push(groupName);\n this.dataField[groupName] = [];\n }\n var index;\n var describedField;\n for (index = 0; index < describedFields.length; index += 1) {\n describedField = describedFields[index];\n this.dataField[groupName].push(describedField);\n }\n return this;\n };\n }\n\n return DescribedDataFieldGroup;\n}());\n","\"use strict\";\nvar described_field = require(\"../../src/js/describedfield.js\");\nmodule.exports = {described_field : described_field};\n"],"names":["$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","parcelRegister","$988e67f614ef1b49$var$module","$988e67f614ef1b49$var$describedFieldInternalCreateIfNotExists","objectToCheck","$988e67f614ef1b49$var$described_field","internalCreateIfNotExists","DescribedDataFieldBuilder","withDefaultString","value","defaultValue","isSpecifiedString","describedField","category","type","abbreviation","image","index","groupNames","displayName","fieldName","fromDescribedDataField","template","build","copyWithoutGroups","describedDataField","DescribedDataFieldGroup","dataField","addGroupEntry","groupName","addGroupEntries","describedFields","length","undefined","push","$d63jw","described_field"],"version":3,"file":"describedfield-ie.js.map","sourceRoot":"../"}
|
package/dist/describedfield.js
CHANGED
|
@@ -1,2 +1,143 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=globalThis,e={},t={},r=i.parcelRequirec1f2;null==r&&((r=function(i){if(i in e)return e[i].exports;if(i in t){var r=t[i];delete t[i];var s={id:i,exports:{}};return e[i]=s,r.call(s.exports,s,s.exports),s.exports}var n=Error("Cannot find module '"+i+"'");throw n.code="MODULE_NOT_FOUND",n}).register=function(i,e){t[i]=e},i.parcelRequirec1f2=r),(0,r.register)("d63jw",function(i,e){var t=r(t);// Fallback for vanilla js without modules
|
|
2
|
+
function r(i){return i||{}}/**
|
|
3
|
+
* Describes a data field of the restructured data.
|
|
4
|
+
* @module described_field
|
|
5
|
+
*/var s=t.exports={};// Export module for npm...
|
|
6
|
+
s.internalCreateIfNotExists=r,/**
|
|
7
|
+
* Describes a field of the restructured data.
|
|
8
|
+
* Dynamically added properties represent custom named groups containing DescribedDataField-Arrays.
|
|
9
|
+
*
|
|
10
|
+
* @typedef {Object} module:described_field.DescribedDataField
|
|
11
|
+
* @property {string} [category=""] - name of the category. Could contain a short domain name like "product" or "vendor".
|
|
12
|
+
* @property {string} [type=""] - type of the data element. Examples: "summary" for e.g. a list overview. "detail" e.g. when a summary is selected. "filter" e.g. for field/value pair results that can be selected as data filters.
|
|
13
|
+
* @property {string} [abbreviation=""] - one optional character, a symbol character or a short abbreviation of the category
|
|
14
|
+
* @property {string} [image=""] - one optional path to an image resource
|
|
15
|
+
* @property {string} index - array of numbers containing the splitted index. Example: "responses[2].hits.hits[4]._source.name" will have an index of [2,4]
|
|
16
|
+
* @property {string[]} groupNames - array of names of all dynamically added properties representing groups
|
|
17
|
+
* @property {string} displayName - display name of the field
|
|
18
|
+
* @property {string} fieldName - field name
|
|
19
|
+
* @property {{*}} value - content of the field
|
|
20
|
+
* @property {module:described_field.DescribedDataField[]} [couldBeAnyCustomGroupName] any number of groups attached to the field each containing multiple fields
|
|
21
|
+
*/s.DescribedDataFieldBuilder=function(){function i(i,e){return"string"==typeof i&&null!==i&&""!==i?i:e}return(/**
|
|
22
|
+
* Builds a {@link module:described_field.DescribedDataField}.
|
|
23
|
+
* DescribedDataField is the main element of the restructured data and therefore considered "public".
|
|
24
|
+
* @constructs DescribedDataFieldBuilder
|
|
25
|
+
* @alias module:described_field.DescribedDataFieldBuilder
|
|
26
|
+
*/function(){/**
|
|
27
|
+
* @type {module:described_field.DescribedDataField}
|
|
28
|
+
*/this.describedField={category:"",type:"",abbreviation:"",image:"",index:[],groupNames:[],displayName:"",fieldName:"",value:""},/**
|
|
29
|
+
* Takes over all values of the template {@link module:described_field.DescribedDataField}.
|
|
30
|
+
* @function
|
|
31
|
+
* @param {module:described_field.DescribedDataField} template
|
|
32
|
+
* @returns {DescribedDataFieldBuilder}
|
|
33
|
+
* @example fromDescribedDataField(sourceField)
|
|
34
|
+
*/this.fromDescribedDataField=function(i){return this.category(i.category),this.type(i.type),this.abbreviation(i.abbreviation),this.image(i.image),this.index(i.index),this.groupNames(i.groupNames),this.displayName(i.displayName),this.fieldName(i.fieldName),this.value(i.value),this},/**
|
|
35
|
+
* Sets the category.
|
|
36
|
+
*
|
|
37
|
+
* Contains a short domain nam, for example:
|
|
38
|
+
* - "product" for products
|
|
39
|
+
* - "vendor" for vendors
|
|
40
|
+
*
|
|
41
|
+
* @function
|
|
42
|
+
* @param {String} [value=""]
|
|
43
|
+
* @returns {DescribedDataFieldBuilder}
|
|
44
|
+
* @example category("Product")
|
|
45
|
+
*/this.category=function(e){return this.describedField.category=i(e,""),this},/**
|
|
46
|
+
* Sets the type.
|
|
47
|
+
*
|
|
48
|
+
* Contains the type of the entry, for example:
|
|
49
|
+
* - "summary" for e.g. a list overview.
|
|
50
|
+
* - "detail" e.g. when a summary is selected.
|
|
51
|
+
* - "filter" e.g. for field/value pair results that can be selected as search parameters.
|
|
52
|
+
*
|
|
53
|
+
* @function
|
|
54
|
+
* @param {String} [value=""]
|
|
55
|
+
* @returns {DescribedDataFieldBuilder}
|
|
56
|
+
* @example type("summary")
|
|
57
|
+
*/this.type=function(e){return this.describedField.type=i(e,""),this},/**
|
|
58
|
+
* Sets the optional abbreviation.
|
|
59
|
+
*
|
|
60
|
+
* Contains a symbol character or a very short abbreviation of the category.
|
|
61
|
+
* - "P" for products
|
|
62
|
+
* - "V" for vendors
|
|
63
|
+
*
|
|
64
|
+
* @function
|
|
65
|
+
* @param {String} [value=""]
|
|
66
|
+
* @returns {DescribedDataFieldBuilder}
|
|
67
|
+
* @example abbreviation("P")
|
|
68
|
+
*/this.abbreviation=function(e){return this.describedField.abbreviation=i(e,""),this},/**
|
|
69
|
+
* Sets the optional path to an image resource.
|
|
70
|
+
*
|
|
71
|
+
* @function
|
|
72
|
+
* @param {String} [value=""]
|
|
73
|
+
* @returns {DescribedDataFieldBuilder}
|
|
74
|
+
* @example image("img/product.png")
|
|
75
|
+
*/this.image=function(e){return this.describedField.image=i(e,""),this},/**
|
|
76
|
+
* Sets the index as an array of numbers containing the splitted array indexes of the source field.
|
|
77
|
+
* Example: "responses[2].hits.hits[4]._source.name" will have an index of [2,4].
|
|
78
|
+
*
|
|
79
|
+
* @function
|
|
80
|
+
* @param {number[]} [value=[]]
|
|
81
|
+
* @returns {DescribedDataFieldBuilder}
|
|
82
|
+
* @example index([2,4])
|
|
83
|
+
*/this.index=function(i){return this.describedField.index=null==i?[]:i,this},/**
|
|
84
|
+
* Sets the group names as an array of strings containing the names of the dynamically added properties,
|
|
85
|
+
* that contain an array of {@link module:described_field.DescribedDataField}-Objects.
|
|
86
|
+
*
|
|
87
|
+
* @function
|
|
88
|
+
* @param {string[]} [value=[]]
|
|
89
|
+
* @returns {DescribedDataFieldBuilder}
|
|
90
|
+
* @example groupNames(["summaries","details","options"])
|
|
91
|
+
*/this.groupNames=function(i){return this.describedField.groupNames=null==i?[]:i,this},/**
|
|
92
|
+
* Sets the display name.
|
|
93
|
+
*
|
|
94
|
+
* @function
|
|
95
|
+
* @param {String} [value=""]
|
|
96
|
+
* @returns {DescribedDataFieldBuilder}
|
|
97
|
+
* @example displayName("Color")
|
|
98
|
+
*/this.displayName=function(e){return this.describedField.displayName=i(e,""),this},/**
|
|
99
|
+
* Sets the (technical) field name.
|
|
100
|
+
*
|
|
101
|
+
* @function
|
|
102
|
+
* @param {String} [value=""]
|
|
103
|
+
* @returns {DescribedDataFieldBuilder}
|
|
104
|
+
* @example fieldName("color")
|
|
105
|
+
*/this.fieldName=function(e){return this.describedField.fieldName=i(e,""),this},/**
|
|
106
|
+
* Sets the value/content of the field.
|
|
107
|
+
*
|
|
108
|
+
* @function
|
|
109
|
+
* @param {*} value
|
|
110
|
+
* @returns {DescribedDataFieldBuilder}
|
|
111
|
+
* @example value("darkblue")
|
|
112
|
+
*/this.value=function(i){return this.describedField.value=i,this},/**
|
|
113
|
+
* Finalizes the settings and builds the {@link module:described_field.DescribedDataField}.
|
|
114
|
+
* @function
|
|
115
|
+
* @returns {module:described_field.DescribedDataField}
|
|
116
|
+
*/this.build=function(){return this.describedField}})}(),/**
|
|
117
|
+
* Creates a new described data field with all properties of the original one except for dynamically added groups.
|
|
118
|
+
* @param {module:described_field.DescribedDataField} describedDataField
|
|
119
|
+
* @returns {module:described_field.DescribedDataField}
|
|
120
|
+
* @memberof module:described_field
|
|
121
|
+
*/s.copyWithoutGroups=function(i){return new s.DescribedDataFieldBuilder().fromDescribedDataField(i).groupNames([]).build()},s.DescribedDataFieldGroup=/**
|
|
122
|
+
* Adds groups to {@link module:described_field.DescribedDataField}s. These groups are dynamically added properties
|
|
123
|
+
* that contain an array of sub fields of the same type {@link module:described_field.DescribedDataField}s.
|
|
124
|
+
*
|
|
125
|
+
* @param {module:described_field.DescribedDataField} dataField
|
|
126
|
+
* @constructs DescribedDataFieldGroup
|
|
127
|
+
* @alias module:described_field.DescribedDataFieldGroup
|
|
128
|
+
* @example new described_field.DescribedDataFieldGroup(field).addGroupEntry("details", detailField);
|
|
129
|
+
*/function(i){this.dataField=i,/**
|
|
130
|
+
* Adds an entry to the given group. If the group does not exist, it will be created.
|
|
131
|
+
* @function
|
|
132
|
+
* @param {String} groupName name of the group to which the entry will be added
|
|
133
|
+
* @param {module:described_field.DescribedDataField} describedField sub field that is added to the group
|
|
134
|
+
* @returns {DescribedDataFieldGroup}
|
|
135
|
+
*/this.addGroupEntry=function(i,e){return this.addGroupEntries(i,[e]),this},/**
|
|
136
|
+
* Adds entries to the given group. If the group does not exist, it will be created.
|
|
137
|
+
* @function
|
|
138
|
+
* @param {String} groupName name of the group to which the entries will be added
|
|
139
|
+
* @param {module:described_field.DescribedDataField[]} describedFields sub fields that are added to the group
|
|
140
|
+
* @returns {DescribedDataFieldGroup}
|
|
141
|
+
*/this.addGroupEntries=function(i,e){var t,r;if(!i||0===i.length||!e||0===e.length)return this;for(void 0===this.dataField[i]&&(this.dataField.groupNames.push(i),this.dataField[i]=[]),t=0;t<e.length;t+=1)r=e[t],this.dataField[i].push(r);return this}}}),r("d63jw");//# sourceMappingURL=describedfield.js.map
|
|
142
|
+
|
|
2
143
|
//# sourceMappingURL=describedfield.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"sgBAMA,aACA,IAAIA,EAASC,EAAwCD,GAErD,SAASC,EAAwCC,GAC/C,OAAOA,GAAiB,CAAC,CAC3B,CAMA,IAAIC,EAAmBH,EAAOI,QAAU,CAAC,EACzCD,EAAgBE,0BAA4BJ,EAmB5CE,EAAgBG,0BAA6B,WAmL3C,SAASC,EAAkBC,EAAOC,GAChC,OALF,S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T,EASAA,KAAKS,UAAY,SAAUb,GAEzB,OADAI,KAAKC,eAAeQ,UAAYd,EAAkBC,EAAO,IAClDI,IACT,EASAA,KAAKJ,MAAQ,SAAUA,GAErB,OADAI,KAAKC,eAAeL,MAAQA,EACrBI,IACT,EAOAA,KAAKY,MAAQ,WACX,OAAOZ,KAAKC,cACd,CACF,CAeF,CA5L6C,GAoM7CV,EAAgBsB,kBAAoB,SAAUC,GAC5C,OAAO,IAAIvB,EAAgBG,2BAA4BgB,uBAAuBI,GAAoBP,WAAW,IAAIK,OACnH,EAEArB,EAAgBwB,wBAUd,SAAiCC,GAC/BhB,KAAKgB,UAAYA,EASjBhB,KAAKiB,cAAgB,SAAUC,EAAWjB,GAExC,OADAD,KAAKmB,gBAAgBD,EAAW,CAACjB,IAC1BD,IACT,EASAA,KAAKmB,gBAAkB,SAAUD,EAAWE,GAC1C,IAAKF,GAAkC,IAArBA,EAAUG,OAC1B,OAAOrB,KAET,IAAKoB,GAA8C,IAA3BA,EAAgBC,OACtC,OAAOrB,KAMT,IAAIM,EACAL,EACJ,SANkCqB,IAA9BtB,KAAKgB,UAAUE,KACjBlB,KAAKgB,UAAUT,WAAWgB,KAAKL,GAC/BlB,KAAKgB,UAAUE,GAAa,IAIzBZ,EAAQ,EAAGA,EAAQc,EAAgBC,OAAQf,GAAS,EACvDL,EAAiBmB,EAAgBd,GACjCN,KAAKgB,UAAUE,GAAWK,KAAKtB,GAEjC,OAAOD,IACT,CACF,C","sources":["src/js/describedfield.js"],"sourcesContent":["/**\n * @file Describes a data field of the restructured data.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */\n\"use strict\";\nvar module = describedFieldInternalCreateIfNotExists(module); // Fallback for vanilla js without modules\n\nfunction describedFieldInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n\n/**\n * Describes a data field of the restructured data.\n * @module described_field\n */\nvar described_field = (module.exports = {}); // Export module for npm...\ndescribed_field.internalCreateIfNotExists = describedFieldInternalCreateIfNotExists;\n\n/**\n * Describes a field of the restructured data.\n * Dynamically added properties represent custom named groups containing DescribedDataField-Arrays.\n *\n * @typedef {Object} module:described_field.DescribedDataField\n * @property {string} [category=\"\"] - name of the category. Could contain a short domain name like \"product\" or \"vendor\".\n * @property {string} [type=\"\"] - type of the data element. Examples: \"summary\" for e.g. a list overview. \"detail\" e.g. when a summary is selected. \"filter\" e.g. for field/value pair results that can be selected as data filters.\n * @property {string} [abbreviation=\"\"] - one optional character, a symbol character or a short abbreviation of the category\n * @property {string} [image=\"\"] - one optional path to an image resource\n * @property {string} index - array of numbers containing the splitted index. Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4]\n * @property {string[]} groupNames - array of names of all dynamically added properties representing groups\n * @property {string} displayName - display name of the field\n * @property {string} fieldName - field name\n * @property {{*}} value - content of the field\n * @property {module:described_field.DescribedDataField[]} [couldBeAnyCustomGroupName] any number of groups attached to the field each containing multiple fields\n */\n\ndescribed_field.DescribedDataFieldBuilder = (function () {\n /**\n * Builds a {@link module:described_field.DescribedDataField}.\n * DescribedDataField is the main element of the restructured data and therefore considered \"public\".\n * @constructs DescribedDataFieldBuilder\n * @alias module:described_field.DescribedDataFieldBuilder\n */\n function DescribedDataFieldBuilder() {\n /**\n * @type {module:described_field.DescribedDataField}\n */\n this.describedField = {\n category: \"\",\n type: \"\",\n abbreviation: \"\",\n image: \"\",\n index: [],\n groupNames: [],\n displayName: \"\",\n fieldName: \"\",\n value: \"\"\n };\n /**\n * Takes over all values of the template {@link module:described_field.DescribedDataField}.\n * @function\n * @param {module:described_field.DescribedDataField} template\n * @returns {DescribedDataFieldBuilder}\n * @example fromDescribedDataField(sourceField)\n */\n this.fromDescribedDataField = function (template) {\n this.category(template.category);\n this.type(template.type);\n this.abbreviation(template.abbreviation);\n this.image(template.image);\n this.index(template.index);\n this.groupNames(template.groupNames);\n this.displayName(template.displayName);\n this.fieldName(template.fieldName);\n this.value(template.value);\n return this;\n };\n /**\n * Sets the category.\n *\n * Contains a short domain nam, for example:\n * - \"product\" for products\n * - \"vendor\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example category(\"Product\")\n */\n this.category = function (value) {\n this.describedField.category = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the type.\n *\n * Contains the type of the entry, for example:\n * - \"summary\" for e.g. a list overview.\n * - \"detail\" e.g. when a summary is selected.\n * - \"filter\" e.g. for field/value pair results that can be selected as search parameters.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example type(\"summary\")\n */\n this.type = function (value) {\n this.describedField.type = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional abbreviation.\n *\n * Contains a symbol character or a very short abbreviation of the category.\n * - \"P\" for products\n * - \"V\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example abbreviation(\"P\")\n */\n this.abbreviation = function (value) {\n this.describedField.abbreviation = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional path to an image resource.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example image(\"img/product.png\")\n */\n this.image = function (value) {\n this.describedField.image = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the index as an array of numbers containing the splitted array indexes of the source field.\n * Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4].\n *\n * @function\n * @param {number[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example index([2,4])\n */\n this.index = function (value) {\n this.describedField.index = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the group names as an array of strings containing the names of the dynamically added properties,\n * that contain an array of {@link module:described_field.DescribedDataField}-Objects.\n *\n * @function\n * @param {string[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example groupNames([\"summaries\",\"details\",\"options\"])\n */\n this.groupNames = function (value) {\n this.describedField.groupNames = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the display name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example displayName(\"Color\")\n */\n this.displayName = function (value) {\n this.describedField.displayName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the (technical) field name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example fieldName(\"color\")\n */\n this.fieldName = function (value) {\n this.describedField.fieldName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the value/content of the field.\n *\n * @function\n * @param {*} value\n * @returns {DescribedDataFieldBuilder}\n * @example value(\"darkblue\")\n */\n this.value = function (value) {\n this.describedField.value = value;\n return this;\n };\n\n /**\n * Finalizes the settings and builds the {@link module:described_field.DescribedDataField}.\n * @function\n * @returns {module:described_field.DescribedDataField}\n */\n this.build = function () {\n return this.describedField;\n };\n }\n\n function isSpecifiedString(value) {\n return typeof value === \"string\" && value !== null && value !== \"\";\n }\n\n function withDefaultString(value, defaultValue) {\n return isSpecifiedString(value) ? value : defaultValue;\n }\n\n function withDefaultArray(value, defaultValue) {\n return value === undefined || value === null ? defaultValue : value;\n }\n\n return DescribedDataFieldBuilder;\n}());\n\n/**\n * Creates a new described data field with all properties of the original one except for dynamically added groups.\n * @param {module:described_field.DescribedDataField} describedDataField\n * @returns {module:described_field.DescribedDataField}\n * @memberof module:described_field\n */\ndescribed_field.copyWithoutGroups = function (describedDataField) {\n return new described_field.DescribedDataFieldBuilder().fromDescribedDataField(describedDataField).groupNames([]).build();\n};\n\ndescribed_field.DescribedDataFieldGroup = (function () {\n /**\n * Adds groups to {@link module:described_field.DescribedDataField}s. These groups are dynamically added properties\n * that contain an array of sub fields of the same type {@link module:described_field.DescribedDataField}s.\n *\n * @param {module:described_field.DescribedDataField} dataField\n * @constructs DescribedDataFieldGroup\n * @alias module:described_field.DescribedDataFieldGroup\n * @example new described_field.DescribedDataFieldGroup(field).addGroupEntry(\"details\", detailField);\n */\n function DescribedDataFieldGroup(dataField) {\n this.dataField = dataField;\n\n /**\n * Adds an entry to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entry will be added\n * @param {module:described_field.DescribedDataField} describedField sub field that is added to the group\n * @returns {DescribedDataFieldGroup}\n */\n this.addGroupEntry = function (groupName, describedField) {\n this.addGroupEntries(groupName, [describedField]);\n return this;\n };\n\n /**\n * Adds entries to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entries will be added\n * @param {module:described_field.DescribedDataField[]} describedFields sub fields that are added to the group\n * @returns {DescribedDataFieldGroup}\n */\n this.addGroupEntries = function (groupName, describedFields) {\n if (!groupName || groupName.length === 0) {\n return this;\n }\n if (!describedFields || describedFields.length === 0) {\n return this;\n }\n if (this.dataField[groupName] === undefined) {\n this.dataField.groupNames.push(groupName);\n this.dataField[groupName] = [];\n }\n var index;\n var describedField;\n for (index = 0; index < describedFields.length; index += 1) {\n describedField = describedFields[index];\n this.dataField[groupName].push(describedField);\n }\n return this;\n };\n }\n\n return DescribedDataFieldGroup;\n}());\n"],"names":["$988e67f614ef1b49$var$module","$988e67f614ef1b49$var$describedFieldInternalCreateIfNotExists","objectToCheck","$988e67f614ef1b49$var$described_field","exports","internalCreateIfNotExists","DescribedDataFieldBuilder","withDefaultString","value","defaultValue","isSpecifiedString","withDefaultArray","this","describedField","category","type","abbreviation","image","index","groupNames","displayName","fieldName","fromDescribedDataField","template","build","copyWithoutGroups","describedDataField","DescribedDataFieldGroup","dataField","addGroupEntry","groupName","addGroupEntries","describedFields","length","undefined","push"],"version":3,"file":"describedfield.js.map","sourceRoot":"../"}
|
|
1
|
+
{"mappings":"A,I,E,W,E,C,E,E,C,E,E,E,iB,A,O,I,A,C,E,S,C,E,G,K,E,O,C,C,E,C,O,C,G,K,E,C,I,E,C,C,E,A,Q,C,C,E,C,I,E,C,G,E,Q,C,C,E,O,C,C,E,C,E,E,I,C,E,O,C,E,E,O,E,E,O,A,C,I,E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C,KAAK,CAAG,WACX,OAAO,IAAI,CAAC,cAAc,AAC5B,CACF,EAeF,IAEA;;;;;CAKC,EACD,EAAgB,iBAAiB,CAAG,SAAU,CAAkB,EAC9D,OAAO,IAAI,EAAgB,yBAAyB,GAAG,sBAAsB,CAAC,GAAoB,UAAU,CAAC,EAAE,EAAE,KAAK,EACxH,EAEA,EAAgB,uBAAuB,CACrC;;;;;;;;GAQC,EACD,SAAiC,CAAS,EACxC,IAAI,CAAC,SAAS,CAAG,EAEjB;;;;;;KAMC,EACD,IAAI,CAAC,aAAa,CAAG,SAAU,CAAS,CAAE,CAAc,EAEtD,OADA,IAAI,CAAC,eAAe,CAAC,EAAW,CAAC,EAAe,EACzC,IAAI,AACb,EAEA;;;;;;KAMC,EACD,IAAI,CAAC,eAAe,CAAG,SAAU,CAAS,CAAE,CAAe,MAWrD,EACA,EAXJ,GAAI,CAAC,GAAa,AAAqB,IAArB,EAAU,MAAM,EAG9B,CAAC,GAAmB,AAA2B,IAA3B,EAAgB,MAAM,CAF5C,OAAO,IAAI,CAWb,IANkC,KAAA,IAA9B,IAAI,CAAC,SAAS,CAAC,EAAU,GAC3B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAC/B,IAAI,CAAC,SAAS,CAAC,EAAU,CAAG,EAAE,EAI3B,EAAQ,EAAG,EAAQ,EAAgB,MAAM,CAAE,GAAS,EACvD,EAAiB,CAAe,CAAC,EAAM,CACvC,IAAI,CAAC,SAAS,CAAC,EAAU,CAAC,IAAI,CAAC,GAEjC,OAAO,IAAI,AACb,CACF,C,G,E,Q,2C","sources":["<anon>","src/js/describedfield.js"],"sourcesContent":["\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequirec1f2\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequirec1f2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nparcelRegister(\"d63jw\", function(module, exports) {\n/**\n * @file Describes a data field of the restructured data.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */ \"use strict\";\nvar $988e67f614ef1b49$var$module = $988e67f614ef1b49$var$describedFieldInternalCreateIfNotExists($988e67f614ef1b49$var$module); // Fallback for vanilla js without modules\nfunction $988e67f614ef1b49$var$describedFieldInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n/**\n * Describes a data field of the restructured data.\n * @module described_field\n */ var $988e67f614ef1b49$var$described_field = $988e67f614ef1b49$var$module.exports = {}; // Export module for npm...\n$988e67f614ef1b49$var$described_field.internalCreateIfNotExists = $988e67f614ef1b49$var$describedFieldInternalCreateIfNotExists;\n/**\n * Describes a field of the restructured data.\n * Dynamically added properties represent custom named groups containing DescribedDataField-Arrays.\n *\n * @typedef {Object} module:described_field.DescribedDataField\n * @property {string} [category=\"\"] - name of the category. Could contain a short domain name like \"product\" or \"vendor\".\n * @property {string} [type=\"\"] - type of the data element. Examples: \"summary\" for e.g. a list overview. \"detail\" e.g. when a summary is selected. \"filter\" e.g. for field/value pair results that can be selected as data filters.\n * @property {string} [abbreviation=\"\"] - one optional character, a symbol character or a short abbreviation of the category\n * @property {string} [image=\"\"] - one optional path to an image resource\n * @property {string} index - array of numbers containing the splitted index. Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4]\n * @property {string[]} groupNames - array of names of all dynamically added properties representing groups\n * @property {string} displayName - display name of the field\n * @property {string} fieldName - field name\n * @property {{*}} value - content of the field\n * @property {module:described_field.DescribedDataField[]} [couldBeAnyCustomGroupName] any number of groups attached to the field each containing multiple fields\n */ $988e67f614ef1b49$var$described_field.DescribedDataFieldBuilder = function() {\n /**\n * Builds a {@link module:described_field.DescribedDataField}.\n * DescribedDataField is the main element of the restructured data and therefore considered \"public\".\n * @constructs DescribedDataFieldBuilder\n * @alias module:described_field.DescribedDataFieldBuilder\n */ function DescribedDataFieldBuilder() {\n /**\n * @type {module:described_field.DescribedDataField}\n */ this.describedField = {\n category: \"\",\n type: \"\",\n abbreviation: \"\",\n image: \"\",\n index: [],\n groupNames: [],\n displayName: \"\",\n fieldName: \"\",\n value: \"\"\n };\n /**\n * Takes over all values of the template {@link module:described_field.DescribedDataField}.\n * @function\n * @param {module:described_field.DescribedDataField} template\n * @returns {DescribedDataFieldBuilder}\n * @example fromDescribedDataField(sourceField)\n */ this.fromDescribedDataField = function(template) {\n this.category(template.category);\n this.type(template.type);\n this.abbreviation(template.abbreviation);\n this.image(template.image);\n this.index(template.index);\n this.groupNames(template.groupNames);\n this.displayName(template.displayName);\n this.fieldName(template.fieldName);\n this.value(template.value);\n return this;\n };\n /**\n * Sets the category.\n *\n * Contains a short domain nam, for example:\n * - \"product\" for products\n * - \"vendor\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example category(\"Product\")\n */ this.category = function(value) {\n this.describedField.category = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the type.\n *\n * Contains the type of the entry, for example:\n * - \"summary\" for e.g. a list overview.\n * - \"detail\" e.g. when a summary is selected.\n * - \"filter\" e.g. for field/value pair results that can be selected as search parameters.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example type(\"summary\")\n */ this.type = function(value) {\n this.describedField.type = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional abbreviation.\n *\n * Contains a symbol character or a very short abbreviation of the category.\n * - \"P\" for products\n * - \"V\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example abbreviation(\"P\")\n */ this.abbreviation = function(value) {\n this.describedField.abbreviation = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional path to an image resource.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example image(\"img/product.png\")\n */ this.image = function(value) {\n this.describedField.image = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the index as an array of numbers containing the splitted array indexes of the source field.\n * Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4].\n *\n * @function\n * @param {number[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example index([2,4])\n */ this.index = function(value) {\n this.describedField.index = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the group names as an array of strings containing the names of the dynamically added properties,\n * that contain an array of {@link module:described_field.DescribedDataField}-Objects.\n *\n * @function\n * @param {string[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example groupNames([\"summaries\",\"details\",\"options\"])\n */ this.groupNames = function(value) {\n this.describedField.groupNames = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the display name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example displayName(\"Color\")\n */ this.displayName = function(value) {\n this.describedField.displayName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the (technical) field name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example fieldName(\"color\")\n */ this.fieldName = function(value) {\n this.describedField.fieldName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the value/content of the field.\n *\n * @function\n * @param {*} value\n * @returns {DescribedDataFieldBuilder}\n * @example value(\"darkblue\")\n */ this.value = function(value) {\n this.describedField.value = value;\n return this;\n };\n /**\n * Finalizes the settings and builds the {@link module:described_field.DescribedDataField}.\n * @function\n * @returns {module:described_field.DescribedDataField}\n */ this.build = function() {\n return this.describedField;\n };\n }\n function isSpecifiedString(value) {\n return typeof value === \"string\" && value !== null && value !== \"\";\n }\n function withDefaultString(value, defaultValue) {\n return isSpecifiedString(value) ? value : defaultValue;\n }\n function withDefaultArray(value, defaultValue) {\n return value === undefined || value === null ? defaultValue : value;\n }\n return DescribedDataFieldBuilder;\n}();\n/**\n * Creates a new described data field with all properties of the original one except for dynamically added groups.\n * @param {module:described_field.DescribedDataField} describedDataField\n * @returns {module:described_field.DescribedDataField}\n * @memberof module:described_field\n */ $988e67f614ef1b49$var$described_field.copyWithoutGroups = function(describedDataField) {\n return new $988e67f614ef1b49$var$described_field.DescribedDataFieldBuilder().fromDescribedDataField(describedDataField).groupNames([]).build();\n};\n$988e67f614ef1b49$var$described_field.DescribedDataFieldGroup = function() {\n /**\n * Adds groups to {@link module:described_field.DescribedDataField}s. These groups are dynamically added properties\n * that contain an array of sub fields of the same type {@link module:described_field.DescribedDataField}s.\n *\n * @param {module:described_field.DescribedDataField} dataField\n * @constructs DescribedDataFieldGroup\n * @alias module:described_field.DescribedDataFieldGroup\n * @example new described_field.DescribedDataFieldGroup(field).addGroupEntry(\"details\", detailField);\n */ function DescribedDataFieldGroup(dataField) {\n this.dataField = dataField;\n /**\n * Adds an entry to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entry will be added\n * @param {module:described_field.DescribedDataField} describedField sub field that is added to the group\n * @returns {DescribedDataFieldGroup}\n */ this.addGroupEntry = function(groupName, describedField) {\n this.addGroupEntries(groupName, [\n describedField\n ]);\n return this;\n };\n /**\n * Adds entries to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entries will be added\n * @param {module:described_field.DescribedDataField[]} describedFields sub fields that are added to the group\n * @returns {DescribedDataFieldGroup}\n */ this.addGroupEntries = function(groupName, describedFields) {\n if (!groupName || groupName.length === 0) return this;\n if (!describedFields || describedFields.length === 0) return this;\n if (this.dataField[groupName] === undefined) {\n this.dataField.groupNames.push(groupName);\n this.dataField[groupName] = [];\n }\n var index;\n var describedField;\n for(index = 0; index < describedFields.length; index += 1){\n describedField = describedFields[index];\n this.dataField[groupName].push(describedField);\n }\n return this;\n };\n }\n return DescribedDataFieldGroup;\n}();\n\n});\n\n\nparcelRequire(\"d63jw\");\n\n//# sourceMappingURL=describedfield.js.map\n","/**\n * @file Describes a data field of the restructured data.\n * @version {@link https://github.com/JohT/data-restructor-js/releases/latest latest version}\n * @author JohT\n * @version ${project.version}\n */\n\"use strict\";\nvar module = describedFieldInternalCreateIfNotExists(module); // Fallback for vanilla js without modules\n\nfunction describedFieldInternalCreateIfNotExists(objectToCheck) {\n return objectToCheck || {};\n}\n\n/**\n * Describes a data field of the restructured data.\n * @module described_field\n */\nvar described_field = (module.exports = {}); // Export module for npm...\ndescribed_field.internalCreateIfNotExists = describedFieldInternalCreateIfNotExists;\n\n/**\n * Describes a field of the restructured data.\n * Dynamically added properties represent custom named groups containing DescribedDataField-Arrays.\n *\n * @typedef {Object} module:described_field.DescribedDataField\n * @property {string} [category=\"\"] - name of the category. Could contain a short domain name like \"product\" or \"vendor\".\n * @property {string} [type=\"\"] - type of the data element. Examples: \"summary\" for e.g. a list overview. \"detail\" e.g. when a summary is selected. \"filter\" e.g. for field/value pair results that can be selected as data filters.\n * @property {string} [abbreviation=\"\"] - one optional character, a symbol character or a short abbreviation of the category\n * @property {string} [image=\"\"] - one optional path to an image resource\n * @property {string} index - array of numbers containing the splitted index. Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4]\n * @property {string[]} groupNames - array of names of all dynamically added properties representing groups\n * @property {string} displayName - display name of the field\n * @property {string} fieldName - field name\n * @property {{*}} value - content of the field\n * @property {module:described_field.DescribedDataField[]} [couldBeAnyCustomGroupName] any number of groups attached to the field each containing multiple fields\n */\n\ndescribed_field.DescribedDataFieldBuilder = (function () {\n /**\n * Builds a {@link module:described_field.DescribedDataField}.\n * DescribedDataField is the main element of the restructured data and therefore considered \"public\".\n * @constructs DescribedDataFieldBuilder\n * @alias module:described_field.DescribedDataFieldBuilder\n */\n function DescribedDataFieldBuilder() {\n /**\n * @type {module:described_field.DescribedDataField}\n */\n this.describedField = {\n category: \"\",\n type: \"\",\n abbreviation: \"\",\n image: \"\",\n index: [],\n groupNames: [],\n displayName: \"\",\n fieldName: \"\",\n value: \"\"\n };\n /**\n * Takes over all values of the template {@link module:described_field.DescribedDataField}.\n * @function\n * @param {module:described_field.DescribedDataField} template\n * @returns {DescribedDataFieldBuilder}\n * @example fromDescribedDataField(sourceField)\n */\n this.fromDescribedDataField = function (template) {\n this.category(template.category);\n this.type(template.type);\n this.abbreviation(template.abbreviation);\n this.image(template.image);\n this.index(template.index);\n this.groupNames(template.groupNames);\n this.displayName(template.displayName);\n this.fieldName(template.fieldName);\n this.value(template.value);\n return this;\n };\n /**\n * Sets the category.\n *\n * Contains a short domain nam, for example:\n * - \"product\" for products\n * - \"vendor\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example category(\"Product\")\n */\n this.category = function (value) {\n this.describedField.category = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the type.\n *\n * Contains the type of the entry, for example:\n * - \"summary\" for e.g. a list overview.\n * - \"detail\" e.g. when a summary is selected.\n * - \"filter\" e.g. for field/value pair results that can be selected as search parameters.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example type(\"summary\")\n */\n this.type = function (value) {\n this.describedField.type = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional abbreviation.\n *\n * Contains a symbol character or a very short abbreviation of the category.\n * - \"P\" for products\n * - \"V\" for vendors\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example abbreviation(\"P\")\n */\n this.abbreviation = function (value) {\n this.describedField.abbreviation = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the optional path to an image resource.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example image(\"img/product.png\")\n */\n this.image = function (value) {\n this.describedField.image = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the index as an array of numbers containing the splitted array indexes of the source field.\n * Example: \"responses[2].hits.hits[4]._source.name\" will have an index of [2,4].\n *\n * @function\n * @param {number[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example index([2,4])\n */\n this.index = function (value) {\n this.describedField.index = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the group names as an array of strings containing the names of the dynamically added properties,\n * that contain an array of {@link module:described_field.DescribedDataField}-Objects.\n *\n * @function\n * @param {string[]} [value=[]]\n * @returns {DescribedDataFieldBuilder}\n * @example groupNames([\"summaries\",\"details\",\"options\"])\n */\n this.groupNames = function (value) {\n this.describedField.groupNames = withDefaultArray(value, []);\n return this;\n };\n /**\n * Sets the display name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example displayName(\"Color\")\n */\n this.displayName = function (value) {\n this.describedField.displayName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the (technical) field name.\n *\n * @function\n * @param {String} [value=\"\"]\n * @returns {DescribedDataFieldBuilder}\n * @example fieldName(\"color\")\n */\n this.fieldName = function (value) {\n this.describedField.fieldName = withDefaultString(value, \"\");\n return this;\n };\n /**\n * Sets the value/content of the field.\n *\n * @function\n * @param {*} value\n * @returns {DescribedDataFieldBuilder}\n * @example value(\"darkblue\")\n */\n this.value = function (value) {\n this.describedField.value = value;\n return this;\n };\n\n /**\n * Finalizes the settings and builds the {@link module:described_field.DescribedDataField}.\n * @function\n * @returns {module:described_field.DescribedDataField}\n */\n this.build = function () {\n return this.describedField;\n };\n }\n\n function isSpecifiedString(value) {\n return typeof value === \"string\" && value !== null && value !== \"\";\n }\n\n function withDefaultString(value, defaultValue) {\n return isSpecifiedString(value) ? value : defaultValue;\n }\n\n function withDefaultArray(value, defaultValue) {\n return value === undefined || value === null ? defaultValue : value;\n }\n\n return DescribedDataFieldBuilder;\n}());\n\n/**\n * Creates a new described data field with all properties of the original one except for dynamically added groups.\n * @param {module:described_field.DescribedDataField} describedDataField\n * @returns {module:described_field.DescribedDataField}\n * @memberof module:described_field\n */\ndescribed_field.copyWithoutGroups = function (describedDataField) {\n return new described_field.DescribedDataFieldBuilder().fromDescribedDataField(describedDataField).groupNames([]).build();\n};\n\ndescribed_field.DescribedDataFieldGroup = (function () {\n /**\n * Adds groups to {@link module:described_field.DescribedDataField}s. These groups are dynamically added properties\n * that contain an array of sub fields of the same type {@link module:described_field.DescribedDataField}s.\n *\n * @param {module:described_field.DescribedDataField} dataField\n * @constructs DescribedDataFieldGroup\n * @alias module:described_field.DescribedDataFieldGroup\n * @example new described_field.DescribedDataFieldGroup(field).addGroupEntry(\"details\", detailField);\n */\n function DescribedDataFieldGroup(dataField) {\n this.dataField = dataField;\n\n /**\n * Adds an entry to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entry will be added\n * @param {module:described_field.DescribedDataField} describedField sub field that is added to the group\n * @returns {DescribedDataFieldGroup}\n */\n this.addGroupEntry = function (groupName, describedField) {\n this.addGroupEntries(groupName, [describedField]);\n return this;\n };\n\n /**\n * Adds entries to the given group. If the group does not exist, it will be created.\n * @function\n * @param {String} groupName name of the group to which the entries will be added\n * @param {module:described_field.DescribedDataField[]} describedFields sub fields that are added to the group\n * @returns {DescribedDataFieldGroup}\n */\n this.addGroupEntries = function (groupName, describedFields) {\n if (!groupName || groupName.length === 0) {\n return this;\n }\n if (!describedFields || describedFields.length === 0) {\n return this;\n }\n if (this.dataField[groupName] === undefined) {\n this.dataField.groupNames.push(groupName);\n this.dataField[groupName] = [];\n }\n var index;\n var describedField;\n for (index = 0; index < describedFields.length; index += 1) {\n describedField = describedFields[index];\n this.dataField[groupName].push(describedField);\n }\n return this;\n };\n }\n\n return DescribedDataFieldGroup;\n}());\n"],"names":["$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","parcelRegister","$988e67f614ef1b49$var$module","$988e67f614ef1b49$var$describedFieldInternalCreateIfNotExists","objectToCheck","$988e67f614ef1b49$var$described_field","internalCreateIfNotExists","DescribedDataFieldBuilder","withDefaultString","value","defaultValue","isSpecifiedString","describedField","category","type","abbreviation","image","index","groupNames","displayName","fieldName","fromDescribedDataField","template","build","copyWithoutGroups","describedDataField","DescribedDataFieldGroup","dataField","addGroupEntry","groupName","addGroupEntries","describedFields","length","undefined","push"],"version":3,"file":"describedfield.js.map","sourceRoot":"../"}
|
|
@@ -1,2 +1,83 @@
|
|
|
1
|
-
var e=
|
|
1
|
+
var e=globalThis,r={},t={},n=e.parcelRequirec1f2;null==n&&((n=function(e){if(e in r)return r[e].exports;if(e in t){var n=t[e];delete t[e];var o={id:e,exports:{}};return r[e]=o,n.call(o.exports,o,o.exports),o.exports}var i=Error("Cannot find module '"+e+"'");throw i.code="MODULE_NOT_FOUND",i}).register=function(e,r){t[e]=r},e.parcelRequirec1f2=n);var o=n.register;o("3kxfc",function(e,r){//https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf#Polyfill
|
|
2
|
+
if(!Array.prototype.indexOf){var t,n,o;Array.prototype.indexOf=(t=Object,n=Math.max,o=Math.min,function(e,r){if(this===null||void 0===this)throw TypeError("Array.prototype.indexOf called on null or undefined");var i=t(this),a=i.length>>>0,f=o(0|r,a);if(f<0)f=n(0,a+f);else if(f>=a)return -1;if(void 0===e){for(;f!==a;++f)if(void 0===i[f]&&f in i)return f;// undefined
|
|
3
|
+
}else if(e!=e){for(;f!==a;++f)if(i[f]!=i[f])return f;// NaN
|
|
4
|
+
}else for(;f!==a;++f)if(i[f]===e)return f;// all else
|
|
5
|
+
return -1;// if the value was not found, then return -1
|
|
6
|
+
})}}),o("26y7f",function(e,r){//http://tokenposts.blogspot.com/2012/04/javascript-objectkeys-browser.html
|
|
7
|
+
Object.keys||(Object.keys=function(e){if(e!==Object(e))throw TypeError("Object.keys called on a non-object");var r,t=[];for(r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t})}),o("8ZIyB",function(e,r){var t,o=i(o);// Fallback for vanilla js without modules
|
|
8
|
+
function i(e){return e||{}}/**
|
|
9
|
+
* Provides a simple template resolver, that replaces variables in double curly brackets with the values of a given object.
|
|
10
|
+
* @module template_resolver
|
|
11
|
+
*/var a=o.exports={};// Export module for npm...
|
|
12
|
+
a.internalCreateIfNotExists=i;var f=f||n("7HmuL");// supports vanilla js & npm
|
|
13
|
+
a.Resolver=(t=RegExp("\\[\\d+\\]","gi"),/**
|
|
14
|
+
* Resolver. Is used inside this repository. It could also be used outside.
|
|
15
|
+
* @param {*} sourceDataObject The properties of this object will be used to replace the placeholders in the template.
|
|
16
|
+
* @constructs Resolver
|
|
17
|
+
* @alias module:template_resolver.Resolver
|
|
18
|
+
*/function(e){/**
|
|
19
|
+
* The properties of this source data object will be used to replace the placeholders in the template.
|
|
20
|
+
*/this.sourceDataObject=e,/**
|
|
21
|
+
* Resolves the given template.
|
|
22
|
+
*
|
|
23
|
+
* The template may contain variables in double curly brackets.
|
|
24
|
+
* Supported variables are all properties of this object, e.g. "{{fieldName}}", "{{displayName}}", "{{value}}".
|
|
25
|
+
* Since this object may also contains (described) groups of sub objects, they can also be used, e.g. "{{summaries[0].value}}"
|
|
26
|
+
* Parts of the index can be inserted by using e.g. "{{index[1]}}".
|
|
27
|
+
*
|
|
28
|
+
* @param {string} template
|
|
29
|
+
* @returns {string} resolved template
|
|
30
|
+
*/this.resolveTemplate=function(e){return this.replaceResolvableFields(e,/**
|
|
31
|
+
* Adds the value of the "fieldName" property (including its group prefix) and its associated "value" property content.
|
|
32
|
+
* For example: detail[2].fieldName="name", detail[2].value="Smith" lead to the additional property detail.name="Smith".
|
|
33
|
+
* @param {object} object with resolvable field names and their values.
|
|
34
|
+
* @returns {object} object with resolvable field names and their values.
|
|
35
|
+
* @protected
|
|
36
|
+
* @memberof module:template_resolver.Resolver
|
|
37
|
+
*/function(e){var r,n,o,i,a=Object.keys(e);for(r=0;r<a.length;r+=1)i=e[n=a[r]],"fieldName"===(o=/**
|
|
38
|
+
* Infos about the full property name including the name of the group (followed by the separator) and the name of the property itself.
|
|
39
|
+
* @param {String} fullPropertyName
|
|
40
|
+
* @returns {Object} Contains "group" (empty or group name including trailing separator "."), "groupWithoutArrayIndices" and "name" (property name).
|
|
41
|
+
* @protected
|
|
42
|
+
* @memberof module:template_resolver.Resolver
|
|
43
|
+
*/function(e){var r=e.lastIndexOf("."),n=e;r>0&&(n=e.substr(r+1));var o="";r>0&&(o=e.substr(0,r+1));//includes the trailing ".".
|
|
44
|
+
var i=o.replace(t,"");return{group:o,groupWithoutArrayIndices:i,name:n}}(n)).name&&"fieldName"!==i&&(e[o.groupWithoutArrayIndices+i]=e[o.group+"value"]);return e}(this.resolvableFieldsOfAll(this.sourceDataObject)))},/**
|
|
45
|
+
* Returns a map like object, that contains all resolvable fields and their values as properties.
|
|
46
|
+
* This function takes a variable count of input parameters,
|
|
47
|
+
* each containing an object that contains resolvable fields to extract from.
|
|
48
|
+
*
|
|
49
|
+
* The recursion depth is limited to 3, so that an object,
|
|
50
|
+
* that contains an object can contain another object (but not further).
|
|
51
|
+
*
|
|
52
|
+
* Properties beginning with an underscore in their name will be filtered out, since they are considered as internal fields.
|
|
53
|
+
*
|
|
54
|
+
* @param {...object} varArgs variable count of parameters. Each parameter contains an object that fields should be resolvable for variables.
|
|
55
|
+
* @returns {object} object with resolvable field names and their values.
|
|
56
|
+
* @public
|
|
57
|
+
*/this.resolvableFieldsOfAll=function(){var e,r={},t=function(e){return 0!==e.indexOf("_")&&0>e.indexOf("._")};for(e=0;e<arguments.length;e+=1)/**
|
|
58
|
+
* Collects all flattened name-value-pairs into one object using the property names as keys and their values as values (map-like).
|
|
59
|
+
* Example: `{name: "accountNumber", value: "12345"}` becomes `mapObject["accountNumber"]="12345"`.
|
|
60
|
+
*
|
|
61
|
+
* @param {NameValuePair[]} elements flattened array of name-value-pairs
|
|
62
|
+
* @param {object} mapObject container to collect the results. Needs to be created before e.g. using `{}`.
|
|
63
|
+
* @param {function} filterMatchesFunction takes the property name as string argument and returns true (include) or false (exclude).
|
|
64
|
+
* @protected
|
|
65
|
+
* @memberof module:template_resolver.Resolver
|
|
66
|
+
*/(function(e,r,t){var n,o;for(n=0;n<e.length;n+=1)o=e[n],"function"==typeof t&&t(o.name)&&(r[o.name]=o.value)})(f.flattenToArray(arguments[e],3),r,t);return r},/**
|
|
67
|
+
* Replaces all variables in double curly brackets, e.g. {{property}},
|
|
68
|
+
* with the value of that property from the resolvableProperties.
|
|
69
|
+
*
|
|
70
|
+
* Supported property types: string, number, boolean
|
|
71
|
+
* @param {string} stringContainingVariables
|
|
72
|
+
* @param {object[]} resolvableFields (name=value)
|
|
73
|
+
*/this.replaceResolvableFields=function(e,r){var t=e,n=Object.keys(r),o=0,i="",a="";for(o=0;o<n.length;o+=1)a=r[i=n[o]],t=t.replace("{{"+i+"}}",a);return t}})}),o("7HmuL",function(e,r){/**
|
|
74
|
+
* @typedef {Object} NameValuePair
|
|
75
|
+
* @property {string} name - point separated names of the flattened main and sub properties, e.g. "responses[2].hits.hits[4]._source.name".
|
|
76
|
+
* @property {string} value - value of the property
|
|
77
|
+
*//**
|
|
78
|
+
* @param {object} data hierarchical object that may consist fo fields, subfields and arrays.
|
|
79
|
+
* @param {number} maxRecursionDepth
|
|
80
|
+
* @returns {NameValuePair[]} array of property name and value pairs
|
|
81
|
+
*/(($59adffa3db62607f$var$module||{}).exports={}).flattenToArray=function(e,r){var t=[];return("number"!=typeof r||r<1)&&(r=20),function e(n,o,i){if(!(i>r)&&"function"!=typeof n){if(Object(n)!==n)t.push({name:o,value:n});else if(Array.isArray(n)){var a,f=n.length;for(a=0;a<f;a+=1)e(n[a],o+"["+a+"]",i+1);0===f&&(t[o]=[],t.push({name:o,value:""}))}else{var l,u=!0;for(l in n)u=!1,e(n[l],o?o+"."+l:l,i+1);u&&o&&t.push({name:o,value:""})}}}(e,"",0),t}}),n("3kxfc"),n("26y7f");var i=n("8ZIyB");module.exports={template_resolver:i};//# sourceMappingURL=templateResolver-ie.js.map
|
|
82
|
+
|
|
2
83
|
//# sourceMappingURL=templateResolver-ie.js.map
|