json-renderers-build-table 1.17.3 → 1.22.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.
Files changed (160) hide show
  1. package/README.md +197 -14
  2. package/package.json +3 -3
  3. package/src/index.js +2 -2
  4. package/src/v17/index.js +5 -5
  5. package/src/v17/simple/index.js +55 -55
  6. package/src/v17/spec.json +85 -85
  7. package/src/v18/bodyOnly/base.json +1 -0
  8. package/src/v18/bodyOnly/index.js +36 -0
  9. package/src/v18/bodyOnly/instructions/double.json +18 -0
  10. package/src/{v16 → v18/bodyOnly}/spec.json +86 -65
  11. package/src/{v16/common/writePath.js → v18/bodyOnly/writePath/index.js} +47 -55
  12. package/src/v18/headerOnly/index.js +42 -0
  13. package/src/{v15/simpleTable/config/instructions.json → v18/headerOnly/instructions/single.json} +8 -8
  14. package/src/{v14 → v18/headerOnly}/spec.json +22 -1
  15. package/src/{v14/buildSpec → v18/headerOnly}/writePath/index.js +8 -16
  16. package/src/v18/index.js +5 -0
  17. package/src/v18/simple/index.js +57 -0
  18. package/src/{v15/buildSpec/config/rowInstructions.json → v18/simple/instructions/double.json} +4 -5
  19. package/src/{v16/simpleTable/config/instructions.json → v18/simple/instructions/single.json} +38 -38
  20. package/src/{v15 → v18/simple}/spec.json +22 -1
  21. package/src/{v15/buildSpec → v18/simple}/writePath/index.js +8 -16
  22. package/src/v18/spec.json +86 -0
  23. package/src/v19/bodyOnly/base.json +1 -0
  24. package/src/v19/bodyOnly/index.js +36 -0
  25. package/src/v19/bodyOnly/instructions/double.json +18 -0
  26. package/src/v19/bodyOnly/spec.json +86 -0
  27. package/src/v19/headerOnly/index.js +42 -0
  28. package/src/{v14/buildSpec/config/columnInstructions.json → v19/headerOnly/instructions/single.json} +2 -20
  29. package/src/v19/headerOnly/spec.json +86 -0
  30. package/src/v19/index.js +5 -0
  31. package/src/v19/simple/index.js +57 -0
  32. package/src/{v15/tableHeadless/config/instructions.json → v19/simple/instructions/double.json} +4 -5
  33. package/src/v19/simple/instructions/single.json +38 -0
  34. package/src/v19/simple/spec.json +86 -0
  35. package/src/v19/spec.json +86 -0
  36. package/src/{v15/common/writePath.js → v19/writePath/index.js} +8 -16
  37. package/src/v20/bodyOnly/base.json +1 -0
  38. package/src/v20/bodyOnly/index.js +18 -0
  39. package/src/v20/bodyOnly/instructions/double.json +18 -0
  40. package/src/v20/bodyOnly/spec.json +86 -0
  41. package/src/v20/doubleInstruction/index.js +19 -0
  42. package/src/v20/headerOnly/base.json +53 -0
  43. package/src/v20/headerOnly/index.js +18 -0
  44. package/src/v20/headerOnly/instructions/single.json +38 -0
  45. package/src/v20/headerOnly/spec.json +86 -0
  46. package/src/v20/index.js +5 -0
  47. package/src/v20/simple/base.json +53 -0
  48. package/src/v20/simple/index.js +22 -0
  49. package/src/{v14/buildSpec/config/rowInstructions.json → v20/simple/instructions/double.json} +4 -5
  50. package/src/v20/simple/instructions/single.json +38 -0
  51. package/src/v20/simple/spec.json +86 -0
  52. package/src/v20/singleInstruction/index.js +17 -0
  53. package/src/v20/spec.json +86 -0
  54. package/src/v20/writePath/index.js +62 -0
  55. package/src/v21/bodyOnly/base.json +1 -0
  56. package/src/v21/bodyOnly/index.js +18 -0
  57. package/src/v21/bodyOnly/instructions/double.json +18 -0
  58. package/src/v21/bodyOnly/spec.json +86 -0
  59. package/src/v21/doubleInstruction/index.js +21 -0
  60. package/src/v21/guards/index.js +10 -0
  61. package/src/v21/guards/references/func/index.js +8 -0
  62. package/src/v21/guards/references/index.js +9 -0
  63. package/src/v21/guards/references/templateKey/index.js +8 -0
  64. package/src/v21/guards/structure/destinationPath/index.js +8 -0
  65. package/src/v21/guards/structure/func/index.js +8 -0
  66. package/src/v21/guards/structure/index.js +15 -0
  67. package/src/v21/guards/structure/sourcePath/index.js +8 -0
  68. package/src/v21/guards/structure/templateKey/index.js +9 -0
  69. package/src/v21/headerOnly/base.json +53 -0
  70. package/src/v21/headerOnly/index.js +18 -0
  71. package/src/v21/headerOnly/instructions/single.json +38 -0
  72. package/src/v21/headerOnly/spec.json +86 -0
  73. package/src/v21/index.js +5 -0
  74. package/src/v21/simple/base.json +53 -0
  75. package/src/v21/simple/index.js +22 -0
  76. package/src/v21/simple/instructions/double.json +19 -0
  77. package/src/v21/simple/instructions/single.json +38 -0
  78. package/src/v21/simple/spec.json +86 -0
  79. package/src/v21/singleInstruction/index.js +19 -0
  80. package/src/v21/spec.json +86 -0
  81. package/src/v21/writePath/index.js +62 -0
  82. package/src/v22/builders/bodyOnly/base.json +1 -0
  83. package/src/v22/builders/bodyOnly/index.js +18 -0
  84. package/src/v22/builders/bodyOnly/instructions/double.json +18 -0
  85. package/src/v22/builders/footerOnly/base.json +3 -0
  86. package/src/v22/builders/footerOnly/index.js +21 -0
  87. package/src/v22/builders/footerOnly/instructions/single.json +19 -0
  88. package/src/v22/builders/headerOnly/base.json +53 -0
  89. package/src/v22/builders/headerOnly/index.js +18 -0
  90. package/src/v22/builders/headerOnly/instructions/single.json +38 -0
  91. package/src/v22/builders/simple/base.json +53 -0
  92. package/src/v22/builders/simple/index.js +22 -0
  93. package/src/v22/builders/simple/instructions/double.json +19 -0
  94. package/src/v22/builders/simple/instructions/single.json +38 -0
  95. package/src/v22/builders/spec.json +86 -0
  96. package/src/v22/builders/withFooter/base.json +53 -0
  97. package/src/v22/builders/withFooter/index.js +22 -0
  98. package/src/v22/builders/withFooter/instructions/double.json +19 -0
  99. package/src/{v15/buildSpec/config/columnInstructions.json → v22/builders/withFooter/instructions/single.json} +3 -3
  100. package/src/v22/doubleInstruction/index.js +21 -0
  101. package/src/v22/guards/index.js +10 -0
  102. package/src/v22/guards/references/func/index.js +8 -0
  103. package/src/v22/guards/references/index.js +9 -0
  104. package/src/v22/guards/references/templateKey/index.js +8 -0
  105. package/src/v22/guards/structure/destinationPath/index.js +8 -0
  106. package/src/v22/guards/structure/func/index.js +8 -0
  107. package/src/v22/guards/structure/index.js +15 -0
  108. package/src/v22/guards/structure/sourcePath/index.js +8 -0
  109. package/src/v22/guards/structure/templateKey/index.js +9 -0
  110. package/src/v22/index.js +7 -0
  111. package/src/v22/singleInstruction/index.js +32 -0
  112. package/src/v22/spec.json +86 -0
  113. package/src/v22/writePath/index.js +62 -0
  114. package/src/v14/buildSpec/config/optionsInstructions.json +0 -82
  115. package/src/v14/buildSpec/config/serialInstructions.json +0 -82
  116. package/src/v14/buildSpec/index.js +0 -147
  117. package/src/v14/index.js +0 -56
  118. package/src/v14/register/index.js +0 -30
  119. package/src/v14/register/meta.js +0 -6
  120. package/src/v15/buildSpec/config/optionsInstructions.json +0 -82
  121. package/src/v15/buildSpec/config/serialInstructions.json +0 -82
  122. package/src/v15/buildSpec/index.js +0 -147
  123. package/src/v15/common/runner.js +0 -33
  124. package/src/v15/index.js +0 -85
  125. package/src/v15/register/index.js +0 -30
  126. package/src/v15/register/meta.js +0 -6
  127. package/src/v15/simpleTable/config/base.json +0 -31
  128. package/src/v15/simpleTable/index.js +0 -58
  129. package/src/v15/tableFullGrid/config/instructions.json +0 -234
  130. package/src/v15/tableFullGrid/index.js +0 -76
  131. package/src/v15/tableHeadless/config/base.json +0 -15
  132. package/src/v15/tableHeadless/index.js +0 -58
  133. package/src/v15/tableWithButtonCell/config/base.json +0 -38
  134. package/src/v15/tableWithButtonCell/config/instructions.json +0 -56
  135. package/src/v15/tableWithButtonCell/index.js +0 -57
  136. package/src/v15/tableWithFooter/config/instructions.json +0 -74
  137. package/src/v15/tableWithFooter/index.js +0 -58
  138. package/src/v15/tableWithOptions/config/base.json +0 -38
  139. package/src/v15/tableWithOptions/config/instructions.json +0 -116
  140. package/src/v15/tableWithOptions/index.js +0 -66
  141. package/src/v15/tableWithSerial/config/base.json +0 -38
  142. package/src/v15/tableWithSerial/config/instructions.json +0 -116
  143. package/src/v15/tableWithSerial/index.js +0 -66
  144. package/src/v15/tableWithWidths/config/base.json +0 -38
  145. package/src/v15/tableWithWidths/config/instructions.json +0 -56
  146. package/src/v15/tableWithWidths/index.js +0 -58
  147. package/src/v16/common/runner.js +0 -33
  148. package/src/v16/index.js +0 -7
  149. package/src/v16/simpleTable/config/base.json +0 -31
  150. package/src/v16/simpleTable/index.js +0 -58
  151. package/src/v16/tableWithOptions/config/base.json +0 -38
  152. package/src/v16/tableWithOptions/config/instructions.json +0 -116
  153. package/src/v16/tableWithOptions/index.js +0 -66
  154. package/src/v16/tableWithSerial/config/base.json +0 -38
  155. package/src/v16/tableWithSerial/config/instructions.json +0 -116
  156. package/src/v16/tableWithSerial/index.js +0 -66
  157. /package/src/{v14/buildSpec/config → v18/headerOnly}/base.json +0 -0
  158. /package/src/{v15/buildSpec/config → v18/simple}/base.json +0 -0
  159. /package/src/{v15/tableFullGrid/config → v19/headerOnly}/base.json +0 -0
  160. /package/src/{v15/tableWithFooter/config → v19/simple}/base.json +0 -0
@@ -0,0 +1,53 @@
1
+ {
2
+ "tagName": "table",
3
+ "attributes": {
4
+ "class": "table table-hover table-striped align-middle border mb-0"
5
+ },
6
+ "children": [
7
+ {
8
+ "tagName": "colgroup",
9
+ "attributes": {
10
+ "data-role": "table-colgroup"
11
+ },
12
+ "children": []
13
+ },
14
+ {
15
+ "tagName": "thead",
16
+ "attributes": {
17
+ "class": "table-dark",
18
+ "data-role": "table-header"
19
+ },
20
+ "children": [
21
+ {
22
+ "tagName": "tr",
23
+ "attributes": {
24
+ "data-role": "table-header-row"
25
+ },
26
+ "children": []
27
+ }
28
+ ]
29
+ },
30
+ {
31
+ "tagName": "tbody",
32
+ "attributes": {
33
+ "data-role": "table-body"
34
+ },
35
+ "children": []
36
+ },
37
+ {
38
+ "tagName": "tfoot",
39
+ "attributes": {
40
+ "data-role": "table-footer"
41
+ },
42
+ "children": [
43
+ {
44
+ "tagName": "tr",
45
+ "attributes": {
46
+ "data-role": "table-footer-row"
47
+ },
48
+ "children": []
49
+ }
50
+ ]
51
+ }
52
+ ]
53
+ }
@@ -0,0 +1,22 @@
1
+ import fromCollection from "json-transformer-funcs-one-dimension";
2
+ import twoDimensional from "json-transformer-funcs-two-dimensions";
3
+
4
+ import spec from "../spec.json" with { type: "json" };
5
+ import base from "./base.json" with { type: "json" };
6
+ import singleInstructions from "./instructions/single.json" with { type: "json" };
7
+ import doubleInstructions from "./instructions/double.json" with { type: "json" };
8
+
9
+ import runSingleInstructions from "../../singleInstruction/index.js";
10
+ import runDoubleInstructions from "../../doubleInstruction/index.js";
11
+
12
+ const registry = { data: {}, base, spec };
13
+ const functions = { fromCollection, twoDimensional };
14
+
15
+ const startFunc = (data, showLog = false, returnLog = []) => {
16
+ registry.data = data;
17
+ runSingleInstructions(singleInstructions, registry, functions, spec, showLog, returnLog);
18
+ runDoubleInstructions(doubleInstructions, registry, functions, spec, showLog, returnLog);
19
+ return base;
20
+ };
21
+
22
+ export default startFunc;
@@ -0,0 +1,19 @@
1
+ [
2
+ {
3
+ "narration": "Build the table body rows for the table using the configured columns and data.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-body",
7
+ "filePath": [
8
+ "children"
9
+ ]
10
+ },
11
+ "sourcePath": {
12
+ "fileName": "data",
13
+ "filePath": [
14
+ "columns"
15
+ ]
16
+ },
17
+ "func": "twoDimensional"
18
+ }
19
+ ]
@@ -0,0 +1,38 @@
1
+ [
2
+ {
3
+ "narration": "Build the column widths for the table using the configured columns.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-colgroup",
7
+ "filePath": [
8
+ "children"
9
+ ]
10
+ },
11
+ "sourcePath": {
12
+ "fileName": "data",
13
+ "filePath": [
14
+ "columns"
15
+ ]
16
+ },
17
+ "templateKey": "buildColGroup",
18
+ "func": "fromCollection"
19
+ },
20
+ {
21
+ "narration": "Build the header row for the table using the configured columns.",
22
+ "destinationPath": {
23
+ "fileName": "base",
24
+ "dataRole": "table-header-row",
25
+ "filePath": [
26
+ "children"
27
+ ]
28
+ },
29
+ "sourcePath": {
30
+ "fileName": "data",
31
+ "filePath": [
32
+ "columns"
33
+ ]
34
+ },
35
+ "templateKey": "buildHeader",
36
+ "func": "fromCollection"
37
+ }
38
+ ]
@@ -0,0 +1,86 @@
1
+ {
2
+ "buildBodyTr": {
3
+ "tagName": "tr",
4
+ "attributes": {
5
+ "class": "align-middle"
6
+ },
7
+ "children": []
8
+ },
9
+ "buildColGroup": {
10
+ "tagName": "col",
11
+ "attributes": {
12
+ "width": "${width}"
13
+ }
14
+ },
15
+ "buildHeader": {
16
+ "tagName": "th",
17
+ "textContent": "${columnName}",
18
+ "attributes": {
19
+ "class": "py-3 px-3 fw-semibold text-uppercase small"
20
+ }
21
+ },
22
+ "buildFooter": {
23
+ "tagName": "td",
24
+ "children": [
25
+ {
26
+ "tagName": "input",
27
+ "attributes": {
28
+ "type": "text",
29
+ "placeholder": "enter ${columnName}",
30
+ "name": "${columnName}",
31
+ "class": "form-control"
32
+ }
33
+ }
34
+ ]
35
+ },
36
+ "buildBodyCell": {
37
+ "tagName": "td",
38
+ "textContent": "${rowValue}",
39
+ "attributes": {
40
+ "class": "py-3 px-3 text-secondary"
41
+ }
42
+ },
43
+ "button": {
44
+ "tagName": "button",
45
+ "textContent": "${columnName}",
46
+ "attributes": {
47
+ "class": "btn btn-primary btn-sm"
48
+ }
49
+ },
50
+ "buttonCell": {
51
+ "tagName": "td",
52
+ "attributes": {
53
+ "class": "py-2 px-3 text-center"
54
+ },
55
+ "children": [
56
+ {
57
+ "tagName": "button",
58
+ "textContent": "${agg:count}",
59
+ "attributes": {
60
+ "class": "btn btn-primary btn-sm"
61
+ }
62
+ }
63
+ ]
64
+ },
65
+ "buildOption": {
66
+ "tagName": "option",
67
+ "textContent": "${rowValue}",
68
+ "attributes": {
69
+ "value": "${rowValue}"
70
+ }
71
+ },
72
+ "buildSelect": {
73
+ "tagName": "select",
74
+ "attributes": {
75
+ "id": "LedgerName"
76
+ },
77
+ "children": []
78
+ },
79
+ "buildDataList": {
80
+ "tagName": "datalist",
81
+ "attributes": {
82
+ "data-name": "${columnName}"
83
+ },
84
+ "children": []
85
+ }
86
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "tagName": "table",
3
+ "attributes": {
4
+ "class": "table table-hover table-striped align-middle border mb-0"
5
+ },
6
+ "children": [
7
+ {
8
+ "tagName": "colgroup",
9
+ "attributes": {
10
+ "data-role": "table-colgroup"
11
+ },
12
+ "children": []
13
+ },
14
+ {
15
+ "tagName": "thead",
16
+ "attributes": {
17
+ "class": "table-dark",
18
+ "data-role": "table-header"
19
+ },
20
+ "children": [
21
+ {
22
+ "tagName": "tr",
23
+ "attributes": {
24
+ "data-role": "table-header-row"
25
+ },
26
+ "children": []
27
+ }
28
+ ]
29
+ },
30
+ {
31
+ "tagName": "tbody",
32
+ "attributes": {
33
+ "data-role": "table-body"
34
+ },
35
+ "children": []
36
+ },
37
+ {
38
+ "tagName": "tfoot",
39
+ "attributes": {
40
+ "data-role": "table-footer"
41
+ },
42
+ "children": [
43
+ {
44
+ "tagName": "tr",
45
+ "attributes": {
46
+ "data-role": "table-footer-row"
47
+ },
48
+ "children": []
49
+ }
50
+ ]
51
+ }
52
+ ]
53
+ }
@@ -0,0 +1,22 @@
1
+ import fromCollection from "json-transformer-funcs-one-dimension";
2
+ import twoDimensional from "json-transformer-funcs-two-dimensions";
3
+
4
+ import spec from "../spec.json" with { type: "json" };
5
+ import base from "./base.json" with { type: "json" };
6
+ import singleInstructions from "./instructions/single.json" with { type: "json" };
7
+ import doubleInstructions from "./instructions/double.json" with { type: "json" };
8
+
9
+ import runSingleInstructions from "../../singleInstruction/index.js";
10
+ import runDoubleInstructions from "../../doubleInstruction/index.js";
11
+
12
+ const registry = { data: {}, base, spec };
13
+ const functions = { fromCollection, twoDimensional };
14
+
15
+ const startFunc = (data, showLog = false, returnLog = []) => {
16
+ registry.data = data;
17
+ runSingleInstructions(singleInstructions, registry, functions, spec, showLog, returnLog);
18
+ runDoubleInstructions(doubleInstructions, registry, functions, spec, showLog, returnLog);
19
+ return base;
20
+ };
21
+
22
+ export default startFunc;
@@ -0,0 +1,19 @@
1
+ [
2
+ {
3
+ "narration": "Build the table body rows for the table using the configured columns and data.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-body",
7
+ "filePath": [
8
+ "children"
9
+ ]
10
+ },
11
+ "sourcePath": {
12
+ "fileName": "data",
13
+ "filePath": [
14
+ "columns"
15
+ ]
16
+ },
17
+ "func": "twoDimensional"
18
+ }
19
+ ]
@@ -18,7 +18,7 @@
18
18
  "func": "fromCollection"
19
19
  },
20
20
  {
21
- "narration": "Build the table header row from the column metadata.",
21
+ "narration": "Build the header row for the table using the configured columns.",
22
22
  "destinationPath": {
23
23
  "fileName": "base",
24
24
  "dataRole": "table-header-row",
@@ -36,7 +36,7 @@
36
36
  "func": "fromCollection"
37
37
  },
38
38
  {
39
- "narration": "Build the table footer row from the column metadata.",
39
+ "narration": "Build the footer row for the table using the configured columns.",
40
40
  "destinationPath": {
41
41
  "fileName": "base",
42
42
  "dataRole": "table-footer-row",
@@ -53,4 +53,4 @@
53
53
  "templateKey": "buildFooter",
54
54
  "func": "fromCollection"
55
55
  }
56
- ]
56
+ ]
@@ -0,0 +1,21 @@
1
+ import writePath from "../writePath/index.js";
2
+ import checkInstruction from "../guards/index.js";
3
+
4
+ const runDoubleInstruction = (instruction, registry, functions, spec, showLog, returnLog) => {
5
+ if (!checkInstruction(instruction, functions, spec, showLog, returnLog)) return;
6
+ const result = functions[instruction.func](
7
+ registry.data.columns,
8
+ registry.data.data,
9
+ spec
10
+ );
11
+ writePath(registry, instruction.destinationPath, result);
12
+ };
13
+
14
+ const runDoubleInstructions = (instructions, registry, functions, spec, showLog, returnLog) => {
15
+ instructions.forEach(instruction => {
16
+ runDoubleInstruction(instruction, registry, functions, spec, showLog, returnLog);
17
+ });
18
+ };
19
+
20
+ export { runDoubleInstruction, runDoubleInstructions };
21
+ export default runDoubleInstructions;
@@ -0,0 +1,10 @@
1
+ import checkStructure from "./structure/index.js";
2
+ import checkReferences from "./references/index.js";
3
+
4
+ const checkInstruction = (instruction, functions, spec, showLog, returnLog) => {
5
+ const structurePassed = checkStructure(instruction, showLog, returnLog);
6
+ if (!structurePassed) return false;
7
+ return checkReferences(instruction, functions, spec, showLog, returnLog);
8
+ };
9
+ export { checkStructure, checkReferences, checkInstruction };
10
+ export default checkInstruction;
@@ -0,0 +1,8 @@
1
+ const checkFunctionReference = (instruction, functions, showLog, returnLog) => {
2
+ const passed = typeof functions[instruction.func] === "function";
3
+ const message = `references/func (${instruction.func}): ${passed ? "passed" : "failed"}`;
4
+ returnLog.push(message);
5
+ if (showLog) console.log(message);
6
+ return passed;
7
+ };
8
+ export default checkFunctionReference;
@@ -0,0 +1,9 @@
1
+ import checkFunctionReference from "./func/index.js";
2
+ import checkSpecReference from "./templateKey/index.js";
3
+
4
+ const checkReferences = (instruction, functions, spec, showLog, returnLog) => {
5
+ const functionPassed = checkFunctionReference(instruction, functions, showLog, returnLog);
6
+ const specPassed = checkSpecReference(instruction, spec, showLog, returnLog);
7
+ return functionPassed && specPassed;
8
+ };
9
+ export default checkReferences;
@@ -0,0 +1,8 @@
1
+ const checkSpecReference = (instruction, spec, showLog, returnLog) => {
2
+ const passed = instruction.templateKey === undefined || Object.hasOwn(spec, instruction.templateKey);
3
+ const message = `references/templateKey${instruction.templateKey === undefined ? " (not used)" : ` (${instruction.templateKey})`}: ${passed ? "passed" : "failed"}`;
4
+ returnLog.push(message);
5
+ if (showLog) console.log(message);
6
+ return passed;
7
+ };
8
+ export default checkSpecReference;
@@ -0,0 +1,8 @@
1
+ const checkDestinationPath = (instruction, showLog, returnLog) => {
2
+ const passed = Boolean(instruction.destinationPath?.fileName && Array.isArray(instruction.destinationPath?.filePath));
3
+ const message = `structure/destinationPath: ${passed ? "passed" : "failed"}`;
4
+ returnLog.push(message);
5
+ if (showLog) console.log(message);
6
+ return passed;
7
+ };
8
+ export default checkDestinationPath;
@@ -0,0 +1,8 @@
1
+ const checkFunc = (instruction, showLog, returnLog) => {
2
+ const passed = typeof instruction.func === "string" && instruction.func.length > 0;
3
+ const message = `structure/func: ${passed ? "passed" : "failed"}`;
4
+ returnLog.push(message);
5
+ if (showLog) console.log(message);
6
+ return passed;
7
+ };
8
+ export default checkFunc;
@@ -0,0 +1,15 @@
1
+ import checkSourcePath from "./sourcePath/index.js";
2
+ import checkDestinationPath from "./destinationPath/index.js";
3
+ import checkTemplateKey from "./templateKey/index.js";
4
+ import checkFunc from "./func/index.js";
5
+
6
+ const checkStructure = (instruction, showLog, returnLog) => {
7
+ const results = [
8
+ checkSourcePath(instruction, showLog, returnLog),
9
+ checkDestinationPath(instruction, showLog, returnLog),
10
+ checkTemplateKey(instruction, showLog, returnLog),
11
+ checkFunc(instruction, showLog, returnLog)
12
+ ];
13
+ return results.every(Boolean);
14
+ };
15
+ export default checkStructure;
@@ -0,0 +1,8 @@
1
+ const checkSourcePath = (instruction, showLog, returnLog) => {
2
+ const passed = Boolean(instruction.sourcePath?.fileName && Array.isArray(instruction.sourcePath?.filePath));
3
+ const message = `structure/sourcePath: ${passed ? "passed" : "failed"}`;
4
+ returnLog.push(message);
5
+ if (showLog) console.log(message);
6
+ return passed;
7
+ };
8
+ export default checkSourcePath;
@@ -0,0 +1,9 @@
1
+ const checkTemplateKey = (instruction, showLog, returnLog) => {
2
+ const passed = instruction.templateKey === undefined ||
3
+ (typeof instruction.templateKey === "string" && instruction.templateKey.length > 0);
4
+ const message = `structure/templateKey: ${passed ? "passed" : "failed"}`;
5
+ returnLog.push(message);
6
+ if (showLog) console.log(message);
7
+ return passed;
8
+ };
9
+ export default checkTemplateKey;
@@ -0,0 +1,7 @@
1
+ import simple from "./builders/simple/index.js";
2
+ import headerOnly from "./builders/headerOnly/index.js";
3
+ import bodyOnly from "./builders/bodyOnly/index.js";
4
+ import withFooter from "./builders/withFooter/index.js";
5
+ import footerOnly from "./builders/footerOnly/index.js";
6
+
7
+ export { simple, headerOnly, bodyOnly, withFooter, footerOnly };
@@ -0,0 +1,32 @@
1
+ import { resolvePath } from "json-transformer-funcs";
2
+ import writePath from "../writePath/index.js";
3
+ import checkInstruction from "../guards/index.js";
4
+
5
+ const runSingleInstruction = (instruction, registry, functions, spec, showLog, returnLog) => {
6
+ if (!checkInstruction(instruction, functions, spec, showLog, returnLog)) return;
7
+
8
+ const localSpec = spec;
9
+ const templateKey = instruction.templateKey;
10
+ const localSpecKey = localSpec[templateKey];
11
+
12
+ console.log("templateKey ; ", templateKey);
13
+ console.log("localSpecKey ; ", localSpecKey);
14
+
15
+ const source = resolvePath(registry, instruction.sourcePath);
16
+ const result = functions[instruction.func](source, localSpecKey);
17
+
18
+ if (templateKey === "buildFooter") {
19
+ console.log("result ; ", result);
20
+ };
21
+
22
+ writePath(registry, instruction.destinationPath, result);
23
+ };
24
+
25
+ const runSingleInstructions = (instructions, registry, functions, spec, showLog, returnLog) => {
26
+ instructions.forEach(instruction => {
27
+ runSingleInstruction(instruction, registry, functions, spec, showLog, returnLog);
28
+ });
29
+ };
30
+
31
+ export { runSingleInstruction, runSingleInstructions };
32
+ export default runSingleInstructions;
@@ -0,0 +1,86 @@
1
+ {
2
+ "buildBodyTr": {
3
+ "tagName": "tr",
4
+ "attributes": {
5
+ "class": "align-middle"
6
+ },
7
+ "children": []
8
+ },
9
+ "buildColGroup": {
10
+ "tagName": "col",
11
+ "attributes": {
12
+ "width": "${width}"
13
+ }
14
+ },
15
+ "buildHeader": {
16
+ "tagName": "th",
17
+ "textContent": "${columnName}",
18
+ "attributes": {
19
+ "class": "py-3 px-3 fw-semibold text-uppercase small"
20
+ }
21
+ },
22
+ "buildFooter": {
23
+ "tagName": "td",
24
+ "children": [
25
+ {
26
+ "tagName": "input",
27
+ "attributes": {
28
+ "type": "text",
29
+ "placeholder": "enter ${columnName}",
30
+ "name": "${columnName}",
31
+ "class": "form-control"
32
+ }
33
+ }
34
+ ]
35
+ },
36
+ "buildBodyCell": {
37
+ "tagName": "td",
38
+ "textContent": "${rowValue}",
39
+ "attributes": {
40
+ "class": "py-3 px-3 text-secondary"
41
+ }
42
+ },
43
+ "button": {
44
+ "tagName": "button",
45
+ "textContent": "${columnName}",
46
+ "attributes": {
47
+ "class": "btn btn-primary btn-sm"
48
+ }
49
+ },
50
+ "buttonCell": {
51
+ "tagName": "td",
52
+ "attributes": {
53
+ "class": "py-2 px-3 text-center"
54
+ },
55
+ "children": [
56
+ {
57
+ "tagName": "button",
58
+ "textContent": "${agg:count}",
59
+ "attributes": {
60
+ "class": "btn btn-primary btn-sm"
61
+ }
62
+ }
63
+ ]
64
+ },
65
+ "buildOption": {
66
+ "tagName": "option",
67
+ "textContent": "${rowValue}",
68
+ "attributes": {
69
+ "value": "${rowValue}"
70
+ }
71
+ },
72
+ "buildSelect": {
73
+ "tagName": "select",
74
+ "attributes": {
75
+ "id": "LedgerName"
76
+ },
77
+ "children": []
78
+ },
79
+ "buildDataList": {
80
+ "tagName": "datalist",
81
+ "attributes": {
82
+ "data-name": "${columnName}"
83
+ },
84
+ "children": []
85
+ }
86
+ }
@@ -0,0 +1,62 @@
1
+ import { findByRole } from "json-transformer-funcs";
2
+
3
+ const toArray = value => Array.isArray(value) ? value : [value];
4
+
5
+ const set = (parent, key, value) => {
6
+ parent[key] = value;
7
+ };
8
+
9
+ const push = (parent, key, value) => {
10
+ parent[key].push(...toArray(value));
11
+ };
12
+
13
+ const unshift = (parent, key, value) => {
14
+ parent[key].unshift(...toArray(value));
15
+ };
16
+
17
+ const pushToRows = (parent, key, value) => {
18
+ parent[key].forEach(row => {
19
+ row.children.push(...structuredClone(toArray(value)));
20
+ });
21
+ };
22
+
23
+ const unshiftToRows = (parent, key, value) => {
24
+ parent[key].forEach(row => {
25
+ row.children.unshift(...structuredClone(toArray(value)));
26
+ });
27
+ };
28
+
29
+ const unshiftSerialToRows = (parent, key, value) => {
30
+ parent[key].forEach((row, rowIndex) => {
31
+ const item = structuredClone(value);
32
+ item.textContent = rowIndex + 1;
33
+ row.children.unshift(item);
34
+ });
35
+ };
36
+
37
+ const actions = {
38
+ set,
39
+ push,
40
+ unshift,
41
+ pushToRows,
42
+ unshiftToRows,
43
+ unshiftSerialToRows
44
+ };
45
+
46
+ const resolveParent = (registry, path) => {
47
+ const root = path.dataRole
48
+ ? findByRole(registry[path.fileName], path.dataRole)
49
+ : registry[path.fileName];
50
+ const keys = [...(path.filePath ?? [])];
51
+ const key = keys.pop();
52
+ const parent = keys.reduce((current, nextKey) => current[nextKey], root);
53
+ return { parent, key };
54
+ };
55
+
56
+ const writePath = (registry, path, value) => {
57
+ const { parent, key } = resolveParent(registry, path);
58
+ const action = actions[path.action] || set;
59
+ action(parent, key, value);
60
+ };
61
+
62
+ export default writePath;