data-restructor 3.3.4 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/codeql-analysis.yml +4 -4
- package/.github/workflows/continuous-integration.yaml +84 -0
- package/CHANGELOG.md +98 -76
- package/CONTRIBUTING.md +51 -43
- package/Commands.md +15 -15
- package/README.md +188 -137
- package/SECURITY.md +2 -2
- package/coverage/coverage-summary.json +3 -3
- package/coverage/datarestructor.js.html +133 -133
- package/coverage/describedfield.js.html +45 -45
- package/coverage/index.html +1 -1
- package/coverage/templateResolver.js.html +26 -26
- package/devdist/datarestructor-ie.js +1479 -1665
- package/devdist/datarestructor.js +1439 -1608
- package/devdist/describedfield-ie.js +259 -279
- package/devdist/describedfield.js +257 -277
- package/devdist/templateResolver-ie.js +220 -252
- package/devdist/templateResolver.js +196 -227
- package/dist/datarestructor-ie.js +1 -1
- package/dist/datarestructor-ie.js.map +1 -1
- package/dist/datarestructor.js +1 -1
- package/dist/datarestructor.js.map +1 -1
- package/dist/describedfield-ie.js +1 -1
- package/dist/describedfield-ie.js.map +1 -1
- package/dist/describedfield.js +1 -1
- package/dist/describedfield.js.map +1 -1
- package/dist/templateResolver-ie.js +1 -1
- package/dist/templateResolver-ie.js.map +1 -1
- package/dist/templateResolver.js +1 -1
- package/dist/templateResolver.js.map +1 -1
- package/docs/datarestructor.js.html +1 -1
- package/docs/describedfield.js.html +1 -1
- package/docs/index.html +49 -44
- package/docs/module-datarestructor.DescribedEntryCreator.html +1 -1
- package/docs/module-datarestructor.PropertyStructureDescriptionBuilder.html +1 -1
- package/docs/module-datarestructor.Restructor.html +1 -1
- package/docs/module-datarestructor.Transform.html +1 -1
- package/docs/module-datarestructor.html +1 -1
- package/docs/module-described_field.DescribedDataFieldBuilder.html +1 -1
- package/docs/module-described_field.DescribedDataFieldGroup.html +1 -1
- package/docs/module-described_field.html +1 -1
- package/docs/module-template_resolver.Resolver.html +1 -1
- package/docs/module-template_resolver.html +1 -1
- package/docs/templateResolver.js.html +1 -1
- package/package.json +16 -14
- package/renovate.json +20 -0
- package/.github/workflows/action.yaml +0 -44
package/docs/index.html
CHANGED
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
<section>
|
|
46
|
-
<article><
|
|
46
|
+
<article><h1>data-restructor-js</h1>
|
|
47
|
+
<p><a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License"></a>
|
|
47
48
|
<img src="https://img.shields.io/github/languages/top/JohT/data-restructor-js" alt="Language">
|
|
48
|
-
<img src="https://img.shields.io/badge/branches-94.61%25-brightgreen.svg" alt="Branches">
|
|
49
|
+
<img src="https://img.shields.io/badge/branches-94.61%25-brightgreen.svg?style=flat" alt="Branches">
|
|
49
50
|
<img src="https://aleen42.github.io/badges/src/npm.svg" alt="npm">
|
|
50
51
|
<img src="https://aleen42.github.io/badges/src/jasmine.svg" alt="jasmine">
|
|
51
52
|
<img src="https://aleen42.github.io/badges/src/eslint.svg" alt="eslint">
|
|
52
53
|
<img src="https://img.shields.io/github/package-json/dependency-version/JohT/data-restructor-js/dev/jsdoc" alt="JSDoc">
|
|
53
54
|
<img src="https://img.shields.io/github/package-json/dependency-version/JohT/data-restructor-js/dev/nyc" alt="nyc">
|
|
54
|
-
<img src="https://img.shields.io/github/package-json/dependency-version/JohT/data-restructor-js/dev/parcel
|
|
55
|
-
<h1>data-restructor-js</h1>
|
|
55
|
+
<img src="https://img.shields.io/github/package-json/dependency-version/JohT/data-restructor-js/dev/parcel" alt="parcel-bundler"></p>
|
|
56
56
|
<p>When parsing JSON on client-side, the structure of it attracts most of our attention.<br>
|
|
57
57
|
If the structure evolves over time, it leads to recurring changes in the code that depends on it.</p>
|
|
58
|
-
<h2>Features
|
|
58
|
+
<h2>Features</h2>
|
|
59
59
|
<ul>
|
|
60
60
|
<li>Adapter that takes e.g. parsed JSON and transforms it into a uniform structure</li>
|
|
61
61
|
<li>Multiple transformation steps including flattening, removing duplicates, grouping, ...</li>
|
|
@@ -71,7 +71,7 @@ If the structure evolves over time, it leads to recurring changes in the code th
|
|
|
71
71
|
</ul>
|
|
72
72
|
<h2>Quickstart</h2>
|
|
73
73
|
<p>Use the following command to install the library using npm:</p>
|
|
74
|
-
<pre class="prettyprint source"><code>npm install data-restructor
|
|
74
|
+
<pre class="prettyprint source lang-shell"><code>npm install data-restructor
|
|
75
75
|
</code></pre>
|
|
76
76
|
<p>Alternatively, the sources can be found inside the
|
|
77
77
|
<a href="https://github.com/JohT/data-restructor-js/tree/master/src/">source folder</a>:</p>
|
|
@@ -178,7 +178,7 @@ function detailsDescription() {
|
|
|
178
178
|
}
|
|
179
179
|
</code></pre>
|
|
180
180
|
<h3>Output Java Object</h3>
|
|
181
|
-
<p>An Javascript object with mainly this structure (see <a href="#
|
|
181
|
+
<p>An Javascript object with mainly this structure (see <a href="#describedentry">DescribedEntry</a> for more details) and content is returned, when the function <code>restructureJson</code> from above is called:</p>
|
|
182
182
|
<pre class="prettyprint source lang-yaml"><code>category: "account"
|
|
183
183
|
displayName: "Accountnumber"
|
|
184
184
|
fieldName: "accountnumber"
|
|
@@ -221,7 +221,7 @@ details:
|
|
|
221
221
|
fieldName: "tags_comma_separated_values"
|
|
222
222
|
value: "active, online"
|
|
223
223
|
</code></pre>
|
|
224
|
-
<h2>Transformation Steps
|
|
224
|
+
<h2>Transformation Steps</h2>
|
|
225
225
|
<h3>1. Flatten hierarchical data object</h3>
|
|
226
226
|
<p>The input data object, e.g. parsed from JSON, is converted to an array of point separated property names and their values.
|
|
227
227
|
For example this structure...</p>
|
|
@@ -245,7 +245,7 @@ For example this structure...</p>
|
|
|
245
245
|
}
|
|
246
246
|
</code></pre>
|
|
247
247
|
<p>...is flattened to...</p>
|
|
248
|
-
<pre class="prettyprint source"><code>responses[0].hits.total.value=1
|
|
248
|
+
<pre class="prettyprint source lang-javascript"><code>responses[0].hits.total.value=1
|
|
249
249
|
responses[0].hits.hits[0]._source.accountnumber=123
|
|
250
250
|
</code></pre>
|
|
251
251
|
<h3>2. Add array value properties ending with "_comma_separated_values"</h3>
|
|
@@ -255,12 +255,12 @@ that contains the values in a comma separated way.
|
|
|
255
255
|
This newly created property gets the name of the array property followed by "_comma_separated_values"
|
|
256
256
|
and is inserted right after the single array values.</p>
|
|
257
257
|
<p>For example these lines...</p>
|
|
258
|
-
<pre class="prettyprint source"><code>responses[0].hits.total.value=1
|
|
258
|
+
<pre class="prettyprint source lang-javascript"><code>responses[0].hits.total.value=1
|
|
259
259
|
responses[0].hits.hits[0]._source.tags[0]=active
|
|
260
260
|
responses[0].hits.hits[0]._source.tags[1]=online
|
|
261
261
|
</code></pre>
|
|
262
262
|
<p>...will lead to an additional property that looks like this...</p>
|
|
263
|
-
<pre class="prettyprint source"><code>responses[0].hits.hits[0]._source.tags_comma_separated_values=active, online
|
|
263
|
+
<pre class="prettyprint source lang-javascript"><code>responses[0].hits.hits[0]._source.tags_comma_separated_values=active, online
|
|
264
264
|
</code></pre>
|
|
265
265
|
<h3>3. Attach description to matching properties</h3>
|
|
266
266
|
<p>For every given description, all properties are searched for matches.
|
|
@@ -268,45 +268,50 @@ If a description matches a property, the description gets attached to it.
|
|
|
268
268
|
This can be used to categorize and filter properties.
|
|
269
269
|
The description builder accepts these ways to configure property matching:</p>
|
|
270
270
|
<ul>
|
|
271
|
-
<li>
|
|
271
|
+
<li>
|
|
272
|
+
<p>Equal Mode (default):<br>
|
|
272
273
|
The property name needs to match the described pattern exactly. It is not needed to set equal mode.
|
|
273
274
|
The field name will be (by default) taken from the right most (after the last separator <code>.</code>) element of the property name.
|
|
274
275
|
In the example below the field name will be "accountnumber".
|
|
275
|
-
Example
|
|
276
|
+
Example:</p>
|
|
277
|
+
<pre class="prettyprint source lang-javascript"><code>new datarestructor.PropertyStructureDescriptionBuilder()
|
|
276
278
|
.propertyPatternEqualMode()
|
|
277
279
|
.propertyPattern("responses.hits.hits._source.accountnumber")
|
|
278
280
|
...
|
|
279
281
|
</code></pre>
|
|
280
282
|
</li>
|
|
281
|
-
<li>
|
|
283
|
+
<li>
|
|
284
|
+
<p>Pattern Mode:<br>
|
|
282
285
|
The property name needs to start with the described pattern.
|
|
283
286
|
The pattern may contain variables inside double curly brackets.<br>
|
|
284
287
|
The variable <code>{{fieldName}}</code> is a special case which describes from where the field name should be taken.
|
|
285
288
|
If <code>{{fieldName}}</code> is not specified, the field name will be taken from the right most (after the last separator <code>.</code>) element of the property name, which is the same behavior as in "Equal Mode".
|
|
286
289
|
This mode needs to set using <code>propertyPatternTemplateMode</code>, since the default mode is <code>propertyPatternEqualMode</code>.
|
|
287
|
-
Example
|
|
290
|
+
Example:</p>
|
|
291
|
+
<pre class="prettyprint source lang-javascript"><code>new datarestructor.PropertyStructureDescriptionBuilder()
|
|
288
292
|
.propertyPatternTemplateMode()
|
|
289
293
|
.propertyPattern("responses.hits.hits._source.{{fieldName}}")
|
|
290
294
|
...
|
|
291
295
|
</code></pre>
|
|
292
296
|
</li>
|
|
293
|
-
<li>
|
|
297
|
+
<li>
|
|
298
|
+
<p>Index Matching (Optional):<br>
|
|
294
299
|
If the source data is structured in an top level array and all property names look pretty much the same
|
|
295
300
|
it may be needed to describe data based on the array index.
|
|
296
301
|
The index of an property is taken out of its array qualifiers.<br>
|
|
297
302
|
For example, the property name <code>responses[0].hits.hits[1]._source.tags[2]</code> has the index <code>0.1.2</code>.<br>
|
|
298
303
|
Index Matching can be combined with property name matching.
|
|
299
|
-
This example restricts the description to the first top level array
|
|
304
|
+
This example restricts the description to the first top level array:</p>
|
|
305
|
+
<pre class="prettyprint source lang-javascript"><code>new datarestructor.PropertyStructureDescriptionBuilder()
|
|
300
306
|
.indexStartsWith("0.")
|
|
301
307
|
...
|
|
302
308
|
</code></pre>
|
|
303
309
|
</li>
|
|
304
310
|
</ul>
|
|
305
|
-
<h3>4. Removing duplicates (deduplication)
|
|
311
|
+
<h3>4. Removing duplicates (deduplication)</h3>
|
|
306
312
|
<p>To remove duplicate properties or to override properties with other ones when they exist,
|
|
307
313
|
a <code>deduplicationPattern</code> can be defined.<br/><br/>
|
|
308
|
-
Variables (listed below) are put into double curly brackets and will be replaced with the contents
|
|
309
|
-
of the description and the matching property.<br>
|
|
314
|
+
Variables (listed below) are put into double curly brackets and will be replaced with the contents of the description and the matching property.<br>
|
|
310
315
|
If there are two entries with the same resolved <code>deduplicationPattern</code> (=<code>_identifier.deduplicationId</code>),
|
|
311
316
|
the second one will override the first (the first one will be removed).
|
|
312
317
|
Example:</p>
|
|
@@ -314,7 +319,7 @@ Example:</p>
|
|
|
314
319
|
.deduplicationPattern("{{category}}--{{type}}--{{index[0]}}--{{index[1]}}--{{fieldName}}")
|
|
315
320
|
...
|
|
316
321
|
</code></pre>
|
|
317
|
-
<h3>5. Grouping
|
|
322
|
+
<h3>5. Grouping</h3>
|
|
318
323
|
<p>Since data had been flattened in the step 1., it is structured as a list of property names and their values.
|
|
319
324
|
This non-hierarchical structure is ideal to add further properties, attach descriptions and remove duplicates.
|
|
320
325
|
After all, a fully flat structure might not be suitable to display overviews/details or to collect options. <br/><br/>
|
|
@@ -330,7 +335,7 @@ same group will be put into. Example:</p>
|
|
|
330
335
|
.groupPattern("{{category}}--{{type}}--{{index[0]}}--{{index[1]}}")
|
|
331
336
|
...
|
|
332
337
|
</code></pre>
|
|
333
|
-
<h3>6. Moving groups (destination group)
|
|
338
|
+
<h3>6. Moving groups (destination group)</h3>
|
|
334
339
|
<p>After grouping in step 5., every property containing a group and the remaining non-grouped properties
|
|
335
340
|
are listed one after another. To organize them further, a group can be moved beneath another (destination) group. <br/><br/>
|
|
336
341
|
The <code>groupDestinationPattern</code> contains the pattern of the group to where the own group should be moved.
|
|
@@ -351,9 +356,9 @@ var detailsDescription = new datarestructor.PropertyStructureDescriptionBuilder(
|
|
|
351
356
|
.groupDestinationName("details")
|
|
352
357
|
...
|
|
353
358
|
</code></pre>
|
|
354
|
-
<h3>7. Convert data into an array of DescribedFields
|
|
355
|
-
<p>The result is finally converted into an array of <a href="#
|
|
356
|
-
<h2>Types, fields, variables
|
|
359
|
+
<h3>7. Convert data into an array of DescribedFields</h3>
|
|
360
|
+
<p>The result is finally converted into an array of <a href="#describeddatafield">DescribedDataField</a>s.</p>
|
|
361
|
+
<h2>Types, fields, variables</h2>
|
|
357
362
|
<p>This section lists the types and their fields in detail (mostly taken from jsdoc).
|
|
358
363
|
Every field can be used as variable in double curly brackets inside pattern properties.
|
|
359
364
|
Additionally, single elements of the index can be used by specifying the index position e.g. <code>{{index[0]}}</code> (first), <code>{{index[1]}}</code> (second),...</p>
|
|
@@ -363,34 +368,34 @@ Additionally, single elements of the index can be used by specifying the index p
|
|
|
363
368
|
<li><strong>category</strong> - name of the category. Default = "". Could contain a symbol character or a short domain name. (e.g. "city")</li>
|
|
364
369
|
<li><strong>abbreviation</strong> - ""(default). One optional character, a symbol character or a short abbreviation of the category.</li>
|
|
365
370
|
<li><strong>image</strong> - ""(default). One optional path to an image resource.</li>
|
|
366
|
-
<li><strong>propertyPatternTemplateMode</strong> - boolean "false"(default): property name needs to be equal to the pattern. "true" allows variables like
|
|
367
|
-
<li><strong>propertyPattern</strong> - property name pattern (without array indices) to match. A pattern may contain variables in double curly brackets {{variable}}. See also: <a href="#public-fields">variables</a>, <a href="#public-functions">further details</a></li>
|
|
371
|
+
<li><strong>propertyPatternTemplateMode</strong> - boolean "false"(default): property name needs to be equal to the pattern. "true" allows variables like <code>{{fieldname}}</code> inside the pattern.</li>
|
|
372
|
+
<li><strong>propertyPattern</strong> - property name pattern (without array indices) to match. A pattern may contain variables in double curly brackets {{variable}}. See also: <a href="#describeddatafield-public-fields">variables</a>, <a href="#describeddatafield-public-functions">further details</a></li>
|
|
368
373
|
<li><strong>indexStartsWith</strong> - ""(default) matches all ids. String that needs to match the beginning of the id. E.g. "1." will match id="1.3.4" but not "0.1.2".</li>
|
|
369
374
|
<li><strong>groupName</strong> - name of the property, that contains grouped entries. Default="group".</li>
|
|
370
|
-
<li><strong>groupPattern</strong> - Pattern that describes how to group entries. "groupName" defines the name of this group. A pattern may contain variables in double curly brackets {{variable}}. See also: <a href="#public-fields">variables</a>, <a href="#public-functions">further details</a></li>
|
|
371
|
-
<li><strong>groupDestinationPattern</strong> - Pattern that describes where the group should be moved to. Default=""=Group will not be moved. A pattern may contain variables in double curly brackets {{variable}}. See also: <a href="#public-fields">variables</a>, <a href="#public-functions">further details</a></li>
|
|
375
|
+
<li><strong>groupPattern</strong> - Pattern that describes how to group entries. "groupName" defines the name of this group. A pattern may contain variables in double curly brackets {{variable}}. See also: <a href="#describeddatafield-public-fields">variables</a>, <a href="#describeddatafield-public-functions">further details</a></li>
|
|
376
|
+
<li><strong>groupDestinationPattern</strong> - Pattern that describes where the group should be moved to. Default=""=Group will not be moved. A pattern may contain variables in double curly brackets {{variable}}. See also: <a href="#describeddatafield-public-fields">variables</a>, <a href="#describeddatafield-public-functions">further details</a></li>
|
|
372
377
|
<li><strong>groupDestinationName</strong> - (default=groupName) Name of the group when it had been moved to the destination.</li>
|
|
373
|
-
<li><strong>deduplicationPattern</strong> - Pattern to use to remove duplicate entries. A pattern may contain variables in double curly brackets {{variable}}. See also: <a href="#public-fields">variables</a>, <a href="#public-functions">further details</a></li>
|
|
378
|
+
<li><strong>deduplicationPattern</strong> - Pattern to use to remove duplicate entries. A pattern may contain variables in double curly brackets {{variable}}. See also: <a href="#describeddatafield-public-fields">variables</a>, <a href="#describeddatafield-public-functions">further details</a></li>
|
|
374
379
|
</ul>
|
|
375
380
|
<h3>DescribedDataField</h3>
|
|
376
381
|
<p>This is the data structure of a single output element representing a field.
|
|
377
382
|
Beside the properties described below, the described data field can also contain
|
|
378
383
|
custom properties containing groups (arrays) of sub fields of type DescribedDataField.</p>
|
|
379
|
-
<p>Before version 3.0.0 this structure was named <a href="#
|
|
380
|
-
Since 3.0.0 and above, <a href="#
|
|
381
|
-
<h4>Public
|
|
384
|
+
<p>Before version 3.0.0 this structure was named <a href="#describedentry">DescribedEntry</a> and also contained internal fields.<br>
|
|
385
|
+
Since 3.0.0 and above, <a href="#describedentry">DescribedEntry</a> is only used internally and is not public any more.</p>
|
|
386
|
+
<h4>DescribedDataField Public Fields</h4>
|
|
382
387
|
<ul>
|
|
383
388
|
<li><strong>category</strong> - category of the result from the PropertyStructureDescription using a short name or e.g. a symbol character</li>
|
|
384
389
|
<li><strong>type</strong> - type of the result from PropertyStructureDescription</li>
|
|
385
390
|
<li><strong>abbreviation</strong> - one optional character, a symbol character or a short abbreviation of the category</li>
|
|
386
391
|
<li><strong>image</strong> - one optional path to an image resource</li>
|
|
387
392
|
<li><strong>index</strong> - contains an array of numbers representing the hierarchical index for list entries (and their sub lists ...). Example: <code>"responses[2].hits.hits[4]._source.name"</code> will have an index of [2,4].</li>
|
|
388
|
-
<li><strong>groupNames</strong> - contains an array of String names. Every name represents a group that had been dynamically added as property. Groups should be added using <a href="#
|
|
393
|
+
<li><strong>groupNames</strong> - contains an array of String names. Every name represents a group that had been dynamically added as property. Groups should be added using <a href="#describeddatafieldgroup">DescribedDataFieldGroup</a>, which will also update the group names.</li>
|
|
389
394
|
<li><strong>displayName</strong> - display name extracted from the point separated hierarchical property name, e.g. "Name"</li>
|
|
390
395
|
<li><strong>fieldName</strong> - field name extracted from the point separated hierarchical property name, e.g. "name"</li>
|
|
391
396
|
<li><strong>value</strong> - content of the field</li>
|
|
392
397
|
</ul>
|
|
393
|
-
<h4>Public
|
|
398
|
+
<h4>DescribedDataField Public Functions</h4>
|
|
394
399
|
<p>Since version 3.0.0 and above, there are no functions any more.</p>
|
|
395
400
|
<h4>Described groups</h4>
|
|
396
401
|
<ul>
|
|
@@ -398,9 +403,9 @@ Since 3.0.0 and above, <a href="#DescribedEntry">DescribedEntry</a> is only used
|
|
|
398
403
|
<li><strong>"names of moved groups"</strong> as described in PropertyStructureDescription of the group that had been moved</li>
|
|
399
404
|
</ul>
|
|
400
405
|
<h3>DescribedDataFieldGroup</h3>
|
|
401
|
-
<p>This helper was added with version 3.0.0. It adds groups to <a href="#
|
|
402
|
-
These groups are dynamically added properties that contain an array of sub fields also of type <a href="#
|
|
403
|
-
<h4>Public
|
|
406
|
+
<p>This helper was added with version 3.0.0. It adds groups to <a href="#describeddatafield">DescribedDataField</a>s.
|
|
407
|
+
These groups are dynamically added properties that contain an array of sub fields also of type <a href="#describeddatafield">DescribedDataField</a>.</p>
|
|
408
|
+
<h4>DescribedDataFieldGroup Public Functions</h4>
|
|
404
409
|
<ul>
|
|
405
410
|
<li><strong>addGroupEntry(groupName, entry)</strong> Adds an entry to the given group. If the group does not exist, it will be created and added to the "groupNames".</li>
|
|
406
411
|
<li><strong>addGroupEntries(groupName, entries)</strong> Adds an array of entries to the given group. If the group does not exist, it will be created and added to the "groupNames".</li>
|
|
@@ -411,7 +416,7 @@ It is documented here for sake of completeness and for maintenance purposes.
|
|
|
411
416
|
See JSDoc for a more comprehensive reference.</p>
|
|
412
417
|
<h4>Properties</h4>
|
|
413
418
|
<ul>
|
|
414
|
-
<li><strong>describedField</strong> - contains the <a href="#
|
|
419
|
+
<li><strong>describedField</strong> - contains the <a href="#describeddatafield">DescribedDataField</a></li>
|
|
415
420
|
<li><strong>isMatchingIndex</strong> - true, if _identifier.index matches the described "indexStartsWith"</li>
|
|
416
421
|
<li><strong>_identifier</strong> - internal structure for identifier. Avoid using it outside since it may change.</li>
|
|
417
422
|
<li><strong>_identifier.index</strong> - array indices in hierarchical order separated by points, e.g. "0.0"</li>
|
|
@@ -433,12 +438,12 @@ var template = "{{type}}-{{category}}";
|
|
|
433
438
|
var resolvedString = resolver.resolveTemplate(template);
|
|
434
439
|
//resolvedString will contain "MyType-MyCategory"
|
|
435
440
|
</code></pre>
|
|
436
|
-
<h4>Public
|
|
441
|
+
<h4>Template Resolver Public Functions</h4>
|
|
437
442
|
<ul>
|
|
438
443
|
<li><strong>resolveTemplate</strong> - resolves the given template string. The template may contain variables in double curly brackets:
|
|
439
444
|
<ul>
|
|
440
|
-
<li>All <a href="#public-fields">public fields</a> can be used as variables, e.g. <code>"{{fieldName}}"</code>, <code>"{{displayName}}"</code>, <code>"{{value}}"</code>.</li>
|
|
441
|
-
<li>Described groups that contain an array of <a href="#
|
|
445
|
+
<li>All <a href="#describeddatafield-public-fields">public fields</a> can be used as variables, e.g. <code>"{{fieldName}}"</code>, <code>"{{displayName}}"</code>, <code>"{{value}}"</code>.</li>
|
|
446
|
+
<li>Described groups that contain an array of <a href="#describeddatafield">described entries</a> can also be used, e.g. <code>"{{summaries[0].value}}"</code>.</li>
|
|
442
447
|
<li>Parts of the index can be inserted by using e.g. <code>"{{index[1]}}"</code>.</li>
|
|
443
448
|
<li>Besides the meta data, a described field can be used directly by its "fieldName", e.g. <code>"{{customernumber}}"</code> will be replaced by <code>123</code>, if the structure contains <code>fieldname="customernumber", value="123"</code>. This also applies to sub groups, e.g. <code>"{{details.customernumber}}"</code> will be replaced by <code>321</code>, if the structure contains <code>details[4].fieldname="customernumber", details[4].value="321"</code>.</li>
|
|
444
449
|
</ul>
|
|
@@ -449,7 +454,7 @@ var resolvedString = resolver.resolveTemplate(template);
|
|
|
449
454
|
<p>The restructured data is by nature hierarchical and may contain cyclic data references. Fields may contain groups of fields that may contain groups of fields....
|
|
450
455
|
Since JSON can't be generated out of objects with cyclic references, sub-structures are expressed by copies.
|
|
451
456
|
That leads to recursion and duplication, that need to be limited. This can be configured here.</p>
|
|
452
|
-
<h4>Properties</h4>
|
|
457
|
+
<h4>TransformConfig Properties</h4>
|
|
453
458
|
<ul>
|
|
454
459
|
<li><strong>debugMode</strong> boolean value, that enables/disables detailed logging</li>
|
|
455
460
|
<li><strong>maxRecursionDepth</strong> numeric value that defines the maximum recursion depth</li>
|
|
@@ -807,7 +812,7 @@ That leads to recursion and duplication, that need to be limited. This can be co
|
|
|
807
812
|
<br class="clear">
|
|
808
813
|
|
|
809
814
|
<footer>
|
|
810
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
815
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
811
816
|
</footer>
|
|
812
817
|
|
|
813
818
|
<script> prettyPrint(); </script>
|
|
@@ -905,7 +905,7 @@ This is the public version of the internal variable _identifier.index, which con
|
|
|
905
905
|
<br class="clear">
|
|
906
906
|
|
|
907
907
|
<footer>
|
|
908
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
908
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
909
909
|
</footer>
|
|
910
910
|
|
|
911
911
|
<script> prettyPrint(); </script>
|
|
@@ -2948,7 +2948,7 @@ starts with the "propertyPattern".</p>
|
|
|
2948
2948
|
<br class="clear">
|
|
2949
2949
|
|
|
2950
2950
|
<footer>
|
|
2951
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
2951
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
2952
2952
|
</footer>
|
|
2953
2953
|
|
|
2954
2954
|
<script> prettyPrint(); </script>
|
|
@@ -339,7 +339,7 @@ var result = datarestructor.Restructor.processJsonUsingDescriptions(jsonData, al
|
|
|
339
339
|
<br class="clear">
|
|
340
340
|
|
|
341
341
|
<footer>
|
|
342
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
342
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
343
343
|
</footer>
|
|
344
344
|
|
|
345
345
|
<script> prettyPrint(); </script>
|
|
@@ -3094,7 +3094,7 @@ recursion depth, above which further duplication won't be used and should be rem
|
|
|
3094
3094
|
<br class="clear">
|
|
3095
3095
|
|
|
3096
3096
|
<footer>
|
|
3097
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
3097
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
3098
3098
|
</footer>
|
|
3099
3099
|
|
|
3100
3100
|
<script> prettyPrint(); </script>
|
|
@@ -2770,7 +2770,7 @@ how the data should be transformed.</p>
|
|
|
2770
2770
|
<br class="clear">
|
|
2771
2771
|
|
|
2772
2772
|
<footer>
|
|
2773
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
2773
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
2774
2774
|
</footer>
|
|
2775
2775
|
|
|
2776
2776
|
<script> prettyPrint(); </script>
|
|
@@ -2123,7 +2123,7 @@ Example: "responses[2].hits.hits[4]._source.name" will have an index o
|
|
|
2123
2123
|
<br class="clear">
|
|
2124
2124
|
|
|
2125
2125
|
<footer>
|
|
2126
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
2126
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
2127
2127
|
</footer>
|
|
2128
2128
|
|
|
2129
2129
|
<script> prettyPrint(); </script>
|
|
@@ -577,7 +577,7 @@ that contain an array of sub fields of the same type <a href="module-described_f
|
|
|
577
577
|
<br class="clear">
|
|
578
578
|
|
|
579
579
|
<footer>
|
|
580
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
580
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
581
581
|
</footer>
|
|
582
582
|
|
|
583
583
|
<script> prettyPrint(); </script>
|
|
@@ -783,7 +783,7 @@ Dynamically added properties represent custom named groups containing DescribedD
|
|
|
783
783
|
<br class="clear">
|
|
784
784
|
|
|
785
785
|
<footer>
|
|
786
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
786
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
787
787
|
</footer>
|
|
788
788
|
|
|
789
789
|
<script> prettyPrint(); </script>
|
|
@@ -1285,7 +1285,7 @@ Parts of the index can be inserted by using e.g. "{{index[1]}}".</p>
|
|
|
1285
1285
|
<br class="clear">
|
|
1286
1286
|
|
|
1287
1287
|
<footer>
|
|
1288
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
1288
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
1289
1289
|
</footer>
|
|
1290
1290
|
|
|
1291
1291
|
<script> prettyPrint(); </script>
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
<br class="clear">
|
|
164
164
|
|
|
165
165
|
<footer>
|
|
166
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
166
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
167
167
|
</footer>
|
|
168
168
|
|
|
169
169
|
<script> prettyPrint(); </script>
|
|
@@ -210,7 +210,7 @@ template_resolver.Resolver = (function () {
|
|
|
210
210
|
<br class="clear">
|
|
211
211
|
|
|
212
212
|
<footer>
|
|
213
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.
|
|
213
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Mon Oct 31 2022 17:00:02 GMT+0000 (Coordinated Universal Time)
|
|
214
214
|
</footer>
|
|
215
215
|
|
|
216
216
|
<script> prettyPrint(); </script>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "data-restructor",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Transforms parsed JSON objects into a uniform data structure",
|
|
5
5
|
"directories": {
|
|
6
6
|
"test": "test"
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"context": "node",
|
|
11
11
|
"includeNodeModules": true,
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": "
|
|
13
|
+
"node": "14"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
|
-
"node": "
|
|
18
|
+
"node": "18"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"prebuild": "rm -rf dist",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"coverage": "nyc npm run test",
|
|
25
25
|
"coverage-badge": "istanbul-badges-readme",
|
|
26
26
|
"doc": "jsdoc -d docs --configure ./docs/jsdoc.json --readme ./README.md ./src/js/*.js",
|
|
27
|
-
"merger": "merger build",
|
|
27
|
+
"merger": "echo -ne \"k\n\" | npx merger build",
|
|
28
28
|
"dev": "rm -rf devdist && parcel --out-dir devdist ./src/js/*.js",
|
|
29
29
|
"devbuild": "rm -rf devdist && NODE_ENV=development parcel build --dist-dir devdist ./src/js/*.js --no-optimize --no-source-maps --no-scope-hoist --no-content-hash --detailed-report",
|
|
30
|
-
"build": "parcel build ./src/js/*.js",
|
|
31
|
-
"package": "npm run lint && npm run coverage && npm run coverage-badge && npm run doc && npm run devbuild && npm run build && merger"
|
|
30
|
+
"build": "export NODE_OPTIONS=--no-experimental-fetch;parcel build ./src/js/*.js",
|
|
31
|
+
"package": "npm run lint && npm run coverage && npm run coverage-badge && npm run doc && npm run devbuild && npm run build && npm run merger"
|
|
32
32
|
},
|
|
33
33
|
"repository": {
|
|
34
34
|
"type": "git",
|
|
@@ -46,12 +46,14 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://joht.github.io/data-restructor-js",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"eslint": "
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
"eslint": "8.26.0",
|
|
50
|
+
"inquirer": "9.1.4",
|
|
51
|
+
"istanbul-badges-readme": "1.8.2",
|
|
52
|
+
"jasmine": "4.5.0",
|
|
53
|
+
"jsdoc": "3.6.11",
|
|
54
|
+
"merger-js": "3.10.3",
|
|
55
|
+
"node-notifier": "10.0.1",
|
|
56
|
+
"nyc": "15.1.0",
|
|
57
|
+
"parcel": "2.0.0"
|
|
58
|
+
}
|
|
57
59
|
}
|
package/renovate.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"config:base",
|
|
4
|
+
":pinAllExceptPeerDependencies",
|
|
5
|
+
":combinePatchMinorReleases",
|
|
6
|
+
":prConcurrentLimit10",
|
|
7
|
+
":automergeDigest",
|
|
8
|
+
":automergePatch",
|
|
9
|
+
":automergeMinor",
|
|
10
|
+
":automergeRequireAllStatusChecks",
|
|
11
|
+
":automergeLinters",
|
|
12
|
+
":automergeTesters"
|
|
13
|
+
],
|
|
14
|
+
"packageRules": [
|
|
15
|
+
{
|
|
16
|
+
"matchPackageNames": ["parcel"],
|
|
17
|
+
"enabled": false
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
name: Node CI
|
|
2
|
-
|
|
3
|
-
on: [push]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
build:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
steps:
|
|
9
|
-
- uses: actions/checkout@v2
|
|
10
|
-
- uses: actions/setup-node@v2
|
|
11
|
-
with:
|
|
12
|
-
node-version: '12'
|
|
13
|
-
- name: Install nodes packages
|
|
14
|
-
run: npm ci
|
|
15
|
-
- name: Run tests
|
|
16
|
-
run: npm test
|
|
17
|
-
- name: Measure test coverage
|
|
18
|
-
run: npm run coverage
|
|
19
|
-
- name: Run linter
|
|
20
|
-
run: npm run lint
|
|
21
|
-
- name: Generate documentation
|
|
22
|
-
run: npm run doc
|
|
23
|
-
- name: Build
|
|
24
|
-
run: npm run build --if-present
|
|
25
|
-
- name: Archive code coverage results
|
|
26
|
-
uses: actions/upload-artifact@v2
|
|
27
|
-
with:
|
|
28
|
-
name: code-coverage-report
|
|
29
|
-
path: coverage
|
|
30
|
-
retention-days: 2
|
|
31
|
-
- name: Archive documentation
|
|
32
|
-
uses: actions/upload-artifact@v2
|
|
33
|
-
with:
|
|
34
|
-
name: documentation
|
|
35
|
-
path: docs
|
|
36
|
-
retention-days: 2
|
|
37
|
-
- name: Archive build artifacts
|
|
38
|
-
uses: actions/upload-artifact@v2
|
|
39
|
-
with:
|
|
40
|
-
name: dist-without-markdown
|
|
41
|
-
path: |
|
|
42
|
-
dist
|
|
43
|
-
!dist/**/*.md
|
|
44
|
-
retention-days: 2
|