json-instructions 0.0.0-stage → 1.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.
Files changed (55) hide show
  1. package/README.md +211 -3
  2. package/package.json +26 -5
  3. package/src/guards/index.js +10 -0
  4. package/src/guards/references/func/index.js +8 -0
  5. package/src/guards/references/index.js +9 -0
  6. package/src/guards/references/templateKey/index.js +8 -0
  7. package/src/guards/structure/destinationPath/index.js +8 -0
  8. package/src/guards/structure/func/index.js +8 -0
  9. package/src/guards/structure/index.js +15 -0
  10. package/src/guards/structure/sourcePath/index.js +8 -0
  11. package/src/guards/structure/templateKey/index.js +9 -0
  12. package/src/index.js +2 -0
  13. package/src/singleInstruction/index.js +28 -0
  14. package/src/v1/actions/index.js +25 -0
  15. package/src/v1/actions/insertOptions/index.js +47 -0
  16. package/src/v1/actions/insertOptions/instructions/footer.json +22 -0
  17. package/src/v1/actions/insertOptions/instructions/single.json +62 -0
  18. package/src/v1/actions/insertSearch/index.js +7 -0
  19. package/src/v1/actions/insertSearch/instructions/template.json +20 -0
  20. package/src/v1/actions/insertSerial/index.js +47 -0
  21. package/src/v1/actions/insertSerial/instructions/footer.json +22 -0
  22. package/src/v1/actions/insertSerial/instructions/single.json +62 -0
  23. package/src/v1/index.js +21 -0
  24. package/src/v2/index.js +25 -0
  25. package/src/v2/insertOptions/index.js +47 -0
  26. package/src/v2/insertOptions/instructions/footer.json +22 -0
  27. package/src/v2/insertOptions/instructions/single.json +62 -0
  28. package/src/v2/insertSearch/index.js +7 -0
  29. package/src/v2/insertSearch/instructions/template.json +20 -0
  30. package/src/v2/insertSerial/index.js +47 -0
  31. package/src/v2/insertSerial/instructions/footer.json +22 -0
  32. package/src/v2/insertSerial/instructions/single.json +62 -0
  33. package/src/v3/index.js +25 -0
  34. package/src/v3/insertOptions/index.js +47 -0
  35. package/src/v3/insertOptions/instructions/footer.json +22 -0
  36. package/src/v3/insertOptions/instructions/single.json +62 -0
  37. package/src/v3/insertSearch/index.js +7 -0
  38. package/src/v3/insertSearch/instructions/template.json +20 -0
  39. package/src/v3/insertSerial/index.js +47 -0
  40. package/src/v3/insertSerial/instructions/footer.json +22 -0
  41. package/src/v3/insertSerial/instructions/single.json +62 -0
  42. package/src/v3/spec.json +107 -0
  43. package/src/v4/guards/index.js +10 -0
  44. package/src/v4/guards/references/func/index.js +8 -0
  45. package/src/v4/guards/references/index.js +9 -0
  46. package/src/v4/guards/references/templateKey/index.js +8 -0
  47. package/src/v4/guards/structure/destinationPath/index.js +8 -0
  48. package/src/v4/guards/structure/func/index.js +8 -0
  49. package/src/v4/guards/structure/index.js +15 -0
  50. package/src/v4/guards/structure/sourcePath/index.js +8 -0
  51. package/src/v4/guards/structure/templateKey/index.js +9 -0
  52. package/src/v4/index.js +28 -0
  53. package/src/v4/spec.json +107 -0
  54. package/src/v4/writePath/index.js +62 -0
  55. package/src/writePath/index.js +62 -0
@@ -0,0 +1,62 @@
1
+ [
2
+ {
3
+ "narration": "Prepend the serial column width to the table colgroup.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-colgroup",
7
+ "filePath": [
8
+ "children"
9
+ ],
10
+ "action": "unshift"
11
+ },
12
+ "sourcePath": {
13
+ "fileName": "data",
14
+ "filePath": [
15
+ "serial",
16
+ "col"
17
+ ]
18
+ },
19
+ "templateKey": "buildColGroup",
20
+ "func": "applyTemplate"
21
+ },
22
+ {
23
+ "narration": "Prepend the serial header cell to the table header row.",
24
+ "destinationPath": {
25
+ "fileName": "base",
26
+ "dataRole": "table-header-row",
27
+ "filePath": [
28
+ "children"
29
+ ],
30
+ "action": "unshift"
31
+ },
32
+ "sourcePath": {
33
+ "fileName": "data",
34
+ "filePath": [
35
+ "serial",
36
+ "header"
37
+ ]
38
+ },
39
+ "templateKey": "buildHeader",
40
+ "func": "applyTemplate"
41
+ },
42
+ {
43
+ "narration": "Prepend the serial number cell into each table body row.",
44
+ "destinationPath": {
45
+ "fileName": "base",
46
+ "dataRole": "table-body",
47
+ "filePath": [
48
+ "children"
49
+ ],
50
+ "action": "unshiftSerialToRows"
51
+ },
52
+ "sourcePath": {
53
+ "fileName": "data",
54
+ "filePath": [
55
+ "serial",
56
+ "body"
57
+ ]
58
+ },
59
+ "templateKey": "buildBodyCell",
60
+ "func": "applyTemplate"
61
+ }
62
+ ]
@@ -0,0 +1,21 @@
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 {
8
+ simple,
9
+ headerOnly,
10
+ bodyOnly,
11
+ withFooter,
12
+ footerOnly
13
+ };
14
+
15
+ export default {
16
+ simple,
17
+ headerOnly,
18
+ bodyOnly,
19
+ withFooter,
20
+ footerOnly
21
+ };
@@ -0,0 +1,25 @@
1
+ import insertSerial from "./insertSerial/index.js";
2
+ import insertOptions from "./insertOptions/index.js";
3
+ import insertSearch from "./insertSearch/index.js";
4
+
5
+ const startFunc = ({ inOptions = {}, inBase, showLog = false, returnLog = [] }) => {
6
+ const localOptions = inOptions;
7
+
8
+ const localBase = inBase;
9
+
10
+ if (localOptions.showSerial || localOptions.serial) {
11
+ insertSerial(localBase, localOptions.serial || {}, showLog, returnLog);
12
+ }
13
+
14
+ if (localOptions.showOptions || localOptions.options) {
15
+ insertOptions(localBase, localOptions.options || {}, showLog, returnLog);
16
+ };
17
+
18
+ if (localOptions.showSearch) {
19
+ insertSearch();
20
+ };
21
+
22
+ return localBase;
23
+ };
24
+
25
+ export default startFunc;
@@ -0,0 +1,47 @@
1
+ import applyTemplate from "json-transformer-funcs-primitive";
2
+ import { findByRole } from "json-transformer-funcs";
3
+
4
+ import spec from "../../../spec.json" with { type: "json" };
5
+ import singleInstructions from "./instructions/single.json" with { type: "json" };
6
+ import footerInstructions from "./instructions/footer.json" with { type: "json" };
7
+
8
+ import runSingleInstructions from "../../singleInstruction/index.js";
9
+
10
+ const functions = { applyTemplate };
11
+
12
+ const insertOptions = (input = {}, config = {}, showLog = false, returnLog = []) => {
13
+ let localTableSpec = input;
14
+ let localOptions = config;
15
+
16
+ if (input && typeof input === "object" && "inTableSpec" in input) {
17
+ localTableSpec = input.inTableSpec;
18
+ localOptions = input.inOptions || config;
19
+ }
20
+
21
+ const localOptionsMerged = {
22
+ col: { width: "100px" },
23
+ header: { columnName: "options" },
24
+ body: { columnName: "show" },
25
+ footer: {},
26
+ ...localOptions
27
+ };
28
+
29
+ const registry = {
30
+ data: {
31
+ options: localOptionsMerged
32
+ },
33
+ base: localTableSpec,
34
+ spec
35
+ };
36
+
37
+ runSingleInstructions(singleInstructions, registry, functions, spec, showLog, returnLog);
38
+
39
+ const footerRow = findByRole(localTableSpec, "table-footer-row");
40
+ if (footerRow && Array.isArray(footerRow.children) && footerRow.children.length > 0) {
41
+ runSingleInstructions(footerInstructions, registry, functions, spec, showLog, returnLog);
42
+ }
43
+
44
+ return localTableSpec;
45
+ };
46
+
47
+ export default insertOptions;
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "narration": "Append an empty cell into the table footer row if footer row is present.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-footer-row",
7
+ "filePath": [
8
+ "children"
9
+ ],
10
+ "action": "push"
11
+ },
12
+ "sourcePath": {
13
+ "fileName": "data",
14
+ "filePath": [
15
+ "options",
16
+ "footer"
17
+ ]
18
+ },
19
+ "templateKey": "emptyCell",
20
+ "func": "applyTemplate"
21
+ }
22
+ ]
@@ -0,0 +1,62 @@
1
+ [
2
+ {
3
+ "narration": "Append the options column width to the table colgroup.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-colgroup",
7
+ "filePath": [
8
+ "children"
9
+ ],
10
+ "action": "push"
11
+ },
12
+ "sourcePath": {
13
+ "fileName": "data",
14
+ "filePath": [
15
+ "options",
16
+ "col"
17
+ ]
18
+ },
19
+ "templateKey": "buildColGroup",
20
+ "func": "applyTemplate"
21
+ },
22
+ {
23
+ "narration": "Append the options header cell to the table header row.",
24
+ "destinationPath": {
25
+ "fileName": "base",
26
+ "dataRole": "table-header-row",
27
+ "filePath": [
28
+ "children"
29
+ ],
30
+ "action": "push"
31
+ },
32
+ "sourcePath": {
33
+ "fileName": "data",
34
+ "filePath": [
35
+ "options",
36
+ "header"
37
+ ]
38
+ },
39
+ "templateKey": "buildHeader",
40
+ "func": "applyTemplate"
41
+ },
42
+ {
43
+ "narration": "Append the options button cell into each table body row.",
44
+ "destinationPath": {
45
+ "fileName": "base",
46
+ "dataRole": "table-body",
47
+ "filePath": [
48
+ "children"
49
+ ],
50
+ "action": "pushToRows"
51
+ },
52
+ "sourcePath": {
53
+ "fileName": "data",
54
+ "filePath": [
55
+ "options",
56
+ "body"
57
+ ]
58
+ },
59
+ "templateKey": "optionsButtonCell",
60
+ "func": "applyTemplate"
61
+ }
62
+ ]
@@ -0,0 +1,7 @@
1
+ import template from "./instructions/template.json" with { type: "json" };
2
+
3
+ const startFunc = (input = {}, config = {}, showLog = false, returnLog = []) => {
4
+ return template;
5
+ };
6
+
7
+ export default startFunc;
@@ -0,0 +1,20 @@
1
+ {
2
+ "tagName": "div",
3
+ "children": [
4
+ {
5
+ "tagName": "label",
6
+ "textContent": "KeshavSoft"
7
+ },
8
+ {
9
+ "tagName": "input",
10
+ "attributes": {
11
+ "value": "KeshavSoft",
12
+ "placeholder": "KeshavSoft"
13
+ }
14
+ },
15
+ {
16
+ "tagName": "button",
17
+ "textContent": "show"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,47 @@
1
+ import applyTemplate from "json-transformer-funcs-primitive";
2
+ import { findByRole } from "json-transformer-funcs";
3
+
4
+ import spec from "../../../spec.json" with { type: "json" };
5
+ import singleInstructions from "./instructions/single.json" with { type: "json" };
6
+ import footerInstructions from "./instructions/footer.json" with { type: "json" };
7
+
8
+ import runSingleInstructions from "../../singleInstruction/index.js";
9
+
10
+ const functions = { applyTemplate };
11
+
12
+ const insertSerial = (input = {}, config = {}, showLog = false, returnLog = []) => {
13
+ let localTableSpec = input;
14
+ let localSerial = config;
15
+
16
+ if (input && typeof input === "object" && "inTableSpec" in input) {
17
+ localTableSpec = input.inTableSpec;
18
+ localSerial = input.inSerial || config;
19
+ }
20
+
21
+ const localSerialMerged = {
22
+ col: { width: "50px" },
23
+ header: { columnName: "#" },
24
+ body: {},
25
+ footer: {},
26
+ ...localSerial
27
+ };
28
+
29
+ const registry = {
30
+ data: {
31
+ serial: localSerialMerged
32
+ },
33
+ base: localTableSpec,
34
+ spec
35
+ };
36
+
37
+ runSingleInstructions(singleInstructions, registry, functions, spec, showLog, returnLog);
38
+
39
+ const footerRow = findByRole(localTableSpec, "table-footer-row");
40
+ if (footerRow && Array.isArray(footerRow.children) && footerRow.children.length > 0) {
41
+ runSingleInstructions(footerInstructions, registry, functions, spec, showLog, returnLog);
42
+ }
43
+
44
+ return localTableSpec;
45
+ };
46
+
47
+ export default insertSerial;
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "narration": "Prepend an empty cell into the table footer row if footer row is present.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-footer-row",
7
+ "filePath": [
8
+ "children"
9
+ ],
10
+ "action": "unshift"
11
+ },
12
+ "sourcePath": {
13
+ "fileName": "data",
14
+ "filePath": [
15
+ "serial",
16
+ "footer"
17
+ ]
18
+ },
19
+ "templateKey": "emptyCell",
20
+ "func": "applyTemplate"
21
+ }
22
+ ]
@@ -0,0 +1,62 @@
1
+ [
2
+ {
3
+ "narration": "Prepend the serial column width to the table colgroup.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-colgroup",
7
+ "filePath": [
8
+ "children"
9
+ ],
10
+ "action": "unshift"
11
+ },
12
+ "sourcePath": {
13
+ "fileName": "data",
14
+ "filePath": [
15
+ "serial",
16
+ "col"
17
+ ]
18
+ },
19
+ "templateKey": "buildColGroup",
20
+ "func": "applyTemplate"
21
+ },
22
+ {
23
+ "narration": "Prepend the serial header cell to the table header row.",
24
+ "destinationPath": {
25
+ "fileName": "base",
26
+ "dataRole": "table-header-row",
27
+ "filePath": [
28
+ "children"
29
+ ],
30
+ "action": "unshift"
31
+ },
32
+ "sourcePath": {
33
+ "fileName": "data",
34
+ "filePath": [
35
+ "serial",
36
+ "header"
37
+ ]
38
+ },
39
+ "templateKey": "buildHeader",
40
+ "func": "applyTemplate"
41
+ },
42
+ {
43
+ "narration": "Prepend the serial number cell into each table body row.",
44
+ "destinationPath": {
45
+ "fileName": "base",
46
+ "dataRole": "table-body",
47
+ "filePath": [
48
+ "children"
49
+ ],
50
+ "action": "unshiftSerialToRows"
51
+ },
52
+ "sourcePath": {
53
+ "fileName": "data",
54
+ "filePath": [
55
+ "serial",
56
+ "body"
57
+ ]
58
+ },
59
+ "templateKey": "buildBodyCell",
60
+ "func": "applyTemplate"
61
+ }
62
+ ]
@@ -0,0 +1,25 @@
1
+ import insertSerial from "./insertSerial/index.js";
2
+ import insertOptions from "./insertOptions/index.js";
3
+ import insertSearch from "./insertSearch/index.js";
4
+
5
+ const startFunc = ({ inOptions = {}, inBase, showLog = false, returnLog = [] }) => {
6
+ const localOptions = inOptions;
7
+
8
+ const localBase = inBase;
9
+
10
+ if (localOptions.showSerial || localOptions.serial) {
11
+ insertSerial(localBase, localOptions.serial || {}, showLog, returnLog);
12
+ }
13
+
14
+ if (localOptions.showOptions || localOptions.options) {
15
+ insertOptions(localBase, localOptions.options || {}, showLog, returnLog);
16
+ };
17
+
18
+ if (localOptions.showSearch) {
19
+ insertSearch();
20
+ };
21
+
22
+ return localBase;
23
+ };
24
+
25
+ export default startFunc;
@@ -0,0 +1,47 @@
1
+ import applyTemplate from "json-transformer-funcs-primitive";
2
+ import { findByRole } from "json-transformer-funcs";
3
+
4
+ import spec from "../spec.json" with { type: "json" };
5
+ import singleInstructions from "./instructions/single.json" with { type: "json" };
6
+ import footerInstructions from "./instructions/footer.json" with { type: "json" };
7
+
8
+ import runSingleInstructions from "../../singleInstruction/index.js";
9
+
10
+ const functions = { applyTemplate };
11
+
12
+ const insertOptions = (input = {}, config = {}, showLog = false, returnLog = []) => {
13
+ let localTableSpec = input;
14
+ let localOptions = config;
15
+
16
+ if (input && typeof input === "object" && "inTableSpec" in input) {
17
+ localTableSpec = input.inTableSpec;
18
+ localOptions = input.inOptions || config;
19
+ }
20
+
21
+ const localOptionsMerged = {
22
+ col: { width: "100px" },
23
+ header: { columnName: "options" },
24
+ body: { columnName: "show" },
25
+ footer: {},
26
+ ...localOptions
27
+ };
28
+
29
+ const registry = {
30
+ data: {
31
+ options: localOptionsMerged
32
+ },
33
+ base: localTableSpec,
34
+ spec
35
+ };
36
+
37
+ runSingleInstructions(singleInstructions, registry, functions, spec, showLog, returnLog);
38
+
39
+ const footerRow = findByRole(localTableSpec, "table-footer-row");
40
+ if (footerRow && Array.isArray(footerRow.children) && footerRow.children.length > 0) {
41
+ runSingleInstructions(footerInstructions, registry, functions, spec, showLog, returnLog);
42
+ }
43
+
44
+ return localTableSpec;
45
+ };
46
+
47
+ export default insertOptions;
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "narration": "Append an empty cell into the table footer row if footer row is present.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-footer-row",
7
+ "filePath": [
8
+ "children"
9
+ ],
10
+ "action": "push"
11
+ },
12
+ "sourcePath": {
13
+ "fileName": "data",
14
+ "filePath": [
15
+ "options",
16
+ "footer"
17
+ ]
18
+ },
19
+ "templateKey": "emptyCell",
20
+ "func": "applyTemplate"
21
+ }
22
+ ]
@@ -0,0 +1,62 @@
1
+ [
2
+ {
3
+ "narration": "Append the options column width to the table colgroup.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-colgroup",
7
+ "filePath": [
8
+ "children"
9
+ ],
10
+ "action": "push"
11
+ },
12
+ "sourcePath": {
13
+ "fileName": "data",
14
+ "filePath": [
15
+ "options",
16
+ "col"
17
+ ]
18
+ },
19
+ "templateKey": "buildColGroup",
20
+ "func": "applyTemplate"
21
+ },
22
+ {
23
+ "narration": "Append the options header cell to the table header row.",
24
+ "destinationPath": {
25
+ "fileName": "base",
26
+ "dataRole": "table-header-row",
27
+ "filePath": [
28
+ "children"
29
+ ],
30
+ "action": "push"
31
+ },
32
+ "sourcePath": {
33
+ "fileName": "data",
34
+ "filePath": [
35
+ "options",
36
+ "header"
37
+ ]
38
+ },
39
+ "templateKey": "buildHeader",
40
+ "func": "applyTemplate"
41
+ },
42
+ {
43
+ "narration": "Append the options button cell into each table body row.",
44
+ "destinationPath": {
45
+ "fileName": "base",
46
+ "dataRole": "table-body",
47
+ "filePath": [
48
+ "children"
49
+ ],
50
+ "action": "pushToRows"
51
+ },
52
+ "sourcePath": {
53
+ "fileName": "data",
54
+ "filePath": [
55
+ "options",
56
+ "body"
57
+ ]
58
+ },
59
+ "templateKey": "optionsButtonCell",
60
+ "func": "applyTemplate"
61
+ }
62
+ ]
@@ -0,0 +1,7 @@
1
+ import template from "./instructions/template.json" with { type: "json" };
2
+
3
+ const startFunc = (input = {}, config = {}, showLog = false, returnLog = []) => {
4
+ return template;
5
+ };
6
+
7
+ export default startFunc;
@@ -0,0 +1,20 @@
1
+ {
2
+ "tagName": "div",
3
+ "children": [
4
+ {
5
+ "tagName": "label",
6
+ "textContent": "KeshavSoft"
7
+ },
8
+ {
9
+ "tagName": "input",
10
+ "attributes": {
11
+ "value": "KeshavSoft",
12
+ "placeholder": "KeshavSoft"
13
+ }
14
+ },
15
+ {
16
+ "tagName": "button",
17
+ "textContent": "show"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,47 @@
1
+ import applyTemplate from "json-transformer-funcs-primitive";
2
+ import { findByRole } from "json-transformer-funcs";
3
+
4
+ import spec from "../spec.json" with { type: "json" };
5
+ import singleInstructions from "./instructions/single.json" with { type: "json" };
6
+ import footerInstructions from "./instructions/footer.json" with { type: "json" };
7
+
8
+ import runSingleInstructions from "../../singleInstruction/index.js";
9
+
10
+ const functions = { applyTemplate };
11
+
12
+ const insertSerial = (input = {}, config = {}, showLog = false, returnLog = []) => {
13
+ let localTableSpec = input;
14
+ let localSerial = config;
15
+
16
+ if (input && typeof input === "object" && "inTableSpec" in input) {
17
+ localTableSpec = input.inTableSpec;
18
+ localSerial = input.inSerial || config;
19
+ }
20
+
21
+ const localSerialMerged = {
22
+ col: { width: "50px" },
23
+ header: { columnName: "#" },
24
+ body: {},
25
+ footer: {},
26
+ ...localSerial
27
+ };
28
+
29
+ const registry = {
30
+ data: {
31
+ serial: localSerialMerged
32
+ },
33
+ base: localTableSpec,
34
+ spec
35
+ };
36
+
37
+ runSingleInstructions(singleInstructions, registry, functions, spec, showLog, returnLog);
38
+
39
+ const footerRow = findByRole(localTableSpec, "table-footer-row");
40
+ if (footerRow && Array.isArray(footerRow.children) && footerRow.children.length > 0) {
41
+ runSingleInstructions(footerInstructions, registry, functions, spec, showLog, returnLog);
42
+ }
43
+
44
+ return localTableSpec;
45
+ };
46
+
47
+ export default insertSerial;
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "narration": "Prepend an empty cell into the table footer row if footer row is present.",
4
+ "destinationPath": {
5
+ "fileName": "base",
6
+ "dataRole": "table-footer-row",
7
+ "filePath": [
8
+ "children"
9
+ ],
10
+ "action": "unshift"
11
+ },
12
+ "sourcePath": {
13
+ "fileName": "data",
14
+ "filePath": [
15
+ "serial",
16
+ "footer"
17
+ ]
18
+ },
19
+ "templateKey": "emptyCell",
20
+ "func": "applyTemplate"
21
+ }
22
+ ]