json-instruction-single 1.3.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -3
- package/src/index.js +2 -2
- package/src/{v2 → v4}/index.js +1 -1
- package/src/v1/index.js +0 -24
- package/src/v2/spec.json +0 -148
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-instruction-single",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
"README.md"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"json-instruction-guards": "^1.0.0",
|
|
15
|
-
"json-source-path": "^1.2.1",
|
|
16
14
|
"json-transformer-funcs-one-dimension": "^1.6.1",
|
|
17
15
|
"json-transformer-funcs-primitive": "^1.9.3",
|
|
18
16
|
"json-write-path": "^1.2.1",
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export { default } from "./
|
|
1
|
+
export * from "./v4/index.js";
|
|
2
|
+
export { default } from "./v4/index.js";
|
package/src/{v2 → v4}/index.js
RENAMED
|
@@ -4,7 +4,7 @@ import fromCollection from "json-transformer-funcs-one-dimension";
|
|
|
4
4
|
import writePath from "json-write-path";
|
|
5
5
|
import resolvePath from "json-source-path";
|
|
6
6
|
|
|
7
|
-
import spec from "
|
|
7
|
+
import spec from "spec-repo";
|
|
8
8
|
|
|
9
9
|
const functions = { applyTemplate, fromCollection };
|
|
10
10
|
|
package/src/v1/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import applyTemplate from "json-transformer-funcs-primitive";
|
|
2
|
-
import fromCollection from "json-transformer-funcs-one-dimension";
|
|
3
|
-
import writePath from "json-write-path";
|
|
4
|
-
import resolvePath from "json-source-path";
|
|
5
|
-
import validateInstruction from "json-instruction-guards";
|
|
6
|
-
|
|
7
|
-
const defaultFunctions = { applyTemplate, fromCollection };
|
|
8
|
-
|
|
9
|
-
export const runSingleInstruction = (instruction, registry, options = {}) => {
|
|
10
|
-
const { functions = defaultFunctions, showLog = false, returnLog = [] } = options;
|
|
11
|
-
const check = validateInstruction(instruction);
|
|
12
|
-
if (!check.valid) { if (showLog) console.warn("Invalid instruction:", check.errors); return { valid: false, errors: check.errors, registry }; }
|
|
13
|
-
if (typeof functions[instruction.func] !== "function") return { valid: false, errors: [`Unknown function: ${instruction.func}`], registry };
|
|
14
|
-
const source = instruction.sourcePath === null ? null : resolvePath(registry, instruction.sourcePath);
|
|
15
|
-
const template = instruction.templateKey ? registry.spec?.[instruction.templateKey] : undefined;
|
|
16
|
-
const result = source === null && instruction.templateKey ? template : functions[instruction.func](source, template);
|
|
17
|
-
writePath(registry, instruction.destinationPath, result);
|
|
18
|
-
if (showLog) returnLog.push({ instruction: instruction.narration || instruction.func, valid: true });
|
|
19
|
-
return { valid: true, result, registry };
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const runSingleInstructions = (instructions = [], registry, options = {}) => instructions.map(instruction => runSingleInstruction(instruction, registry, options));
|
|
23
|
-
|
|
24
|
-
export default runSingleInstructions;
|
package/src/v2/spec.json
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
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
|
-
"id": "${columnName}",
|
|
32
|
-
"list": "${columnName}",
|
|
33
|
-
"class": "form-control"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
},
|
|
38
|
-
"buildBodyCell": {
|
|
39
|
-
"tagName": "td",
|
|
40
|
-
"textContent": "${rowValue}",
|
|
41
|
-
"attributes": {
|
|
42
|
-
"class": "py-3 px-3 text-secondary"
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
"button": {
|
|
46
|
-
"tagName": "button",
|
|
47
|
-
"textContent": "${columnName}",
|
|
48
|
-
"attributes": {
|
|
49
|
-
"class": "btn btn-primary btn-sm"
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"buttonCell": {
|
|
53
|
-
"tagName": "td",
|
|
54
|
-
"attributes": {
|
|
55
|
-
"class": "py-2 px-3 text-center"
|
|
56
|
-
},
|
|
57
|
-
"children": [
|
|
58
|
-
{
|
|
59
|
-
"tagName": "button",
|
|
60
|
-
"textContent": "${agg:count}",
|
|
61
|
-
"attributes": {
|
|
62
|
-
"class": "btn btn-primary btn-sm"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
]
|
|
66
|
-
},
|
|
67
|
-
"optionsButtonCell": {
|
|
68
|
-
"tagName": "td",
|
|
69
|
-
"attributes": {
|
|
70
|
-
"class": "py-2 px-3 text-center"
|
|
71
|
-
},
|
|
72
|
-
"children": [
|
|
73
|
-
{
|
|
74
|
-
"tagName": "button",
|
|
75
|
-
"textContent": "show",
|
|
76
|
-
"attributes": {
|
|
77
|
-
"class": "btn btn-primary btn-sm ks-btn-show"
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
},
|
|
82
|
-
"buildOption": {
|
|
83
|
-
"tagName": "option",
|
|
84
|
-
"textContent": "${rowValue}",
|
|
85
|
-
"attributes": {
|
|
86
|
-
"value": "${rowValue}"
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
"buildSelect": {
|
|
90
|
-
"tagName": "select",
|
|
91
|
-
"attributes": {
|
|
92
|
-
"id": "LedgerName"
|
|
93
|
-
},
|
|
94
|
-
"children": []
|
|
95
|
-
},
|
|
96
|
-
"buildDataList": {
|
|
97
|
-
"tagName": "datalist",
|
|
98
|
-
"attributes": {
|
|
99
|
-
"data-name": "${columnName}"
|
|
100
|
-
},
|
|
101
|
-
"children": []
|
|
102
|
-
},
|
|
103
|
-
"emptyCell": {
|
|
104
|
-
"tagName": "td",
|
|
105
|
-
"children": []
|
|
106
|
-
},
|
|
107
|
-
"headerSerialCell": {
|
|
108
|
-
"tagName": "th",
|
|
109
|
-
"textContent": "#",
|
|
110
|
-
"attributes": {
|
|
111
|
-
"class": "py-3 px-3 fw-semibold text-uppercase small"
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
"colGroupForSerial": {
|
|
115
|
-
"tagName": "col",
|
|
116
|
-
"attributes": {
|
|
117
|
-
"width": "50px"
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
"colGroupForOption": {
|
|
121
|
-
"tagName": "col",
|
|
122
|
-
"attributes": {
|
|
123
|
-
"width": "100px"
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
"headerForOption": {
|
|
127
|
-
"tagName": "th",
|
|
128
|
-
"textContent": "options",
|
|
129
|
-
"attributes": {
|
|
130
|
-
"class": "py-3 px-3 fw-semibold text-uppercase small"
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
"tdWithButtonSaveWarning": {
|
|
134
|
-
"tagName": "td",
|
|
135
|
-
"attributes": {
|
|
136
|
-
"class": "py-2 px-3 text-center"
|
|
137
|
-
},
|
|
138
|
-
"children": [
|
|
139
|
-
{
|
|
140
|
-
"tagName": "button",
|
|
141
|
-
"textContent": "save",
|
|
142
|
-
"attributes": {
|
|
143
|
-
"class": "btn btn-warning btn-sm ks-btn-save"
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
]
|
|
147
|
-
}
|
|
148
|
-
}
|