data-restructor 3.3.4 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.auto-changelog +9 -0
- package/.auto-changelog-template.hbs +36 -0
- package/.github/workflows/codeql-analysis.yml +4 -4
- package/.github/workflows/continuous-integration.yaml +84 -0
- package/CHANGELOG.md +199 -94
- package/CONTRIBUTING.md +51 -43
- package/Commands.md +16 -15
- package/README.md +193 -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 +1487 -1678
- package/devdist/datarestructor.js +1438 -1614
- package/devdist/describedfield-ie.js +260 -282
- package/devdist/describedfield.js +257 -279
- package/devdist/templateResolver-ie.js +221 -257
- package/devdist/templateResolver.js +192 -228
- 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 +54 -44
- package/docs/module-datarestructor.DescribedEntryCreator.html +94 -94
- package/docs/module-datarestructor.PropertyStructureDescriptionBuilder.html +1 -1
- package/docs/module-datarestructor.Restructor.html +1 -1
- package/docs/module-datarestructor.Transform.html +605 -605
- package/docs/module-datarestructor.html +959 -995
- 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 -37
- package/docs/module-template_resolver.Resolver.html +167 -167
- package/docs/module-template_resolver.html +1 -37
- package/docs/templateResolver.js.html +1 -1
- package/package.json +20 -14
- package/renovate.json +14 -0
- package/.github/workflows/action.yaml +0 -44
|
@@ -334,7 +334,7 @@ described_field.DescribedDataFieldGroup = (function () {
|
|
|
334
334
|
<br class="clear">
|
|
335
335
|
|
|
336
336
|
<footer>
|
|
337
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc
|
|
337
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Feb 28 2023 21:27:12 GMT+0100 (Central European Standard Time)
|
|
338
338
|
</footer>
|
|
339
339
|
|
|
340
340
|
<script> prettyPrint(); </script>
|
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>
|
|
@@ -461,6 +466,11 @@ That leads to recursion and duplication, that need to be limited. This can be co
|
|
|
461
466
|
<li><strong>setMaxRecursionDepth(number)</strong> numeric value that defines the maximum recursion depth</li>
|
|
462
467
|
<li><strong>setRemoveDuplicationAboveRecursionDepth(number)</strong> numeric value that defines the recursion depth, above which duplications inside groups will be removed.</li>
|
|
463
468
|
</ul>
|
|
469
|
+
<h2>Related blog articles</h2>
|
|
470
|
+
<ul>
|
|
471
|
+
<li><a href="https://joht.github.io/johtizen/build/2022/01/20/github-actions-push-into-repository.html">Most effective ways to push within GitHub Actions</a></li>
|
|
472
|
+
<li><a href="https://joht.github.io/johtizen/build/2021/02/21/continuous-integration-javascript.html">Continuous Integration for JavaScript with npm</a></li>
|
|
473
|
+
</ul>
|
|
464
474
|
<h2>References</h2>
|
|
465
475
|
<ul>
|
|
466
476
|
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#Polyfill">Mozilla MDN web docs - polyfill for 'Array.filter'</a> for browser compatibility</li>
|
|
@@ -807,7 +817,7 @@ That leads to recursion and duplication, that need to be limited. This can be co
|
|
|
807
817
|
<br class="clear">
|
|
808
818
|
|
|
809
819
|
<footer>
|
|
810
|
-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc
|
|
820
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue Feb 28 2023 21:27:12 GMT+0100 (Central European Standard Time)
|
|
811
821
|
</footer>
|
|
812
822
|
|
|
813
823
|
<script> prettyPrint(); </script>
|