json-renderers-run-instructions 1.15.1 → 1.20.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 (68) hide show
  1. package/README.md +42 -31
  2. package/package.json +13 -6
  3. package/src/index.js +2 -2
  4. package/src/v15/index.js +5 -1
  5. package/src/v16/index.js +50 -0
  6. package/src/v16/registerGlobal/meta.js +6 -0
  7. package/src/v16/runOptions/applyFeature.js +20 -0
  8. package/src/v16/runOptions/applyInstructionBundle.js +45 -0
  9. package/src/v16/runOptions/helpers.js +41 -0
  10. package/src/v16/runOptions/index.js +73 -0
  11. package/src/v17/index.js +50 -0
  12. package/src/v17/registerGlobal/meta.js +6 -0
  13. package/src/v17/runOptions/applyFeature.js +20 -0
  14. package/src/v17/runOptions/applyInstructionBundle.js +45 -0
  15. package/src/v17/runOptions/helpers.js +41 -0
  16. package/src/v17/runOptions/index.js +73 -0
  17. package/src/v18/README.md +21 -0
  18. package/src/v18/data/definitions.json +334 -0
  19. package/src/v18/data/instructions.json +650 -0
  20. package/src/v18/data/spec.json +1605 -0
  21. package/src/v18/index.js +58 -0
  22. package/src/v18/instructions/executeBuildInstruction.js +53 -0
  23. package/src/v18/instructions/executeWriteBundle.js +21 -0
  24. package/src/v18/instructions/index.js +35 -0
  25. package/src/{v13/types/helpers → v18/instructions}/resolveSource.js +24 -27
  26. package/src/v18/instructions/writeResult.js +29 -0
  27. package/src/v18/registerGlobal/index.js +16 -0
  28. package/src/{v13 → v18}/registerGlobal/meta.js +1 -1
  29. package/src/v18/runOptions/index.js +47 -0
  30. package/src/v19/data/definitions.json +149 -0
  31. package/src/v19/data/instructions.json +650 -0
  32. package/src/v19/data/spec.json +1605 -0
  33. package/src/v19/index.js +54 -0
  34. package/src/v19/instructions/executeBuildInstruction.js +53 -0
  35. package/src/v19/instructions/executeWriteBundle.js +21 -0
  36. package/src/v19/instructions/index.js +35 -0
  37. package/src/v19/instructions/resolveSource.js +24 -0
  38. package/src/v19/instructions/writeResult.js +29 -0
  39. package/src/v19/registerGlobal/index.js +16 -0
  40. package/src/{v12 → v19}/registerGlobal/meta.js +6 -6
  41. package/src/v19/runOptions/index.js +78 -0
  42. package/src/v20/index.js +54 -0
  43. package/src/v20/instructions/executeBuildInstruction.js +53 -0
  44. package/src/v20/instructions/executeWriteBundle.js +21 -0
  45. package/src/v20/instructions/index.js +35 -0
  46. package/src/v20/instructions/resolveSource.js +24 -0
  47. package/src/v20/instructions/writeResult.js +29 -0
  48. package/src/v20/registerGlobal/index.js +16 -0
  49. package/src/v20/registerGlobal/meta.js +6 -0
  50. package/src/v20/runOptions/index.js +36 -0
  51. package/src/v20/runOptions/normalizeOptions.js +28 -0
  52. package/src/v20/runOptions/resolveFeatureKeys.js +43 -0
  53. package/src/v12/index.js +0 -178
  54. package/src/v12/runOptions/index.js +0 -66
  55. package/src/v12/transformers/columnOnRow.js +0 -33
  56. package/src/v12/transformers/index.js +0 -21
  57. package/src/v13/index.js +0 -49
  58. package/src/v13/runOptions/index.js +0 -66
  59. package/src/v13/transformers/columnOnRow.js +0 -33
  60. package/src/v13/transformers/index.js +0 -21
  61. package/src/v13/types/columnOnRow.js +0 -34
  62. package/src/v13/types/helpers/guards.js +0 -38
  63. package/src/v13/types/helpers/writeResult.js +0 -19
  64. package/src/v13/types/index.js +0 -33
  65. package/src/v13/types/rowOnColumn.js +0 -22
  66. package/src/v13/types/single.js +0 -28
  67. /package/src/{v12 → v16}/registerGlobal/index.js +0 -0
  68. /package/src/{v13 → v17}/registerGlobal/index.js +0 -0
@@ -0,0 +1,73 @@
1
+ // import { spec, instructions } from "spec-repo";
2
+
3
+ import spec from "declarative-spec";
4
+ import instructions from "declarative-instructions";
5
+
6
+ import writePath from "json-write-path";
7
+ import { query } from "jsonpathly";
8
+ import applyFeature from "./applyFeature.js";
9
+ import {
10
+ getFeatureRequest,
11
+ isEnabledFeature,
12
+ isObject
13
+ } from "./helpers.js";
14
+
15
+ const isObjectCheck = value => value !== null && typeof value === "object" && !Array.isArray(value);
16
+
17
+ const getFeatureOptions = (options, featureKey) => {
18
+ if (!isObjectCheck(options)) return null;
19
+ if (options[featureKey] !== undefined) return options[featureKey];
20
+ const prefixed = `show${featureKey.charAt(0).toUpperCase()}${featureKey.slice(1)}`;
21
+ if (options[prefixed] !== undefined) return options[prefixed];
22
+ return null;
23
+ };
24
+
25
+ const applyOption = (instructionKey, base) => {
26
+ const list = instructions[instructionKey];
27
+ if (!list) return;
28
+
29
+ for (const step of list) {
30
+ if (step.skipIf && query(base, step.skipIf, { returnArray: true }).length > 0) continue;
31
+ const template = spec[step.templateKey];
32
+ try {
33
+ writePath({ base }, step.destinationPath, template);
34
+ } catch {
35
+ // Optional target node not in base (e.g. footer on table without footer)
36
+ }
37
+ }
38
+ };
39
+
40
+ /**
41
+ * Task 2: Applies key-value feature options (search, serial, actions) to base.
42
+ */
43
+ const runOptions = ({
44
+ options = {},
45
+ optionDefs = {},
46
+ base,
47
+ showLog = false
48
+ } = {}) => {
49
+ if (!base || !isObject(options) || !isObject(optionDefs)) {
50
+ return base;
51
+ }
52
+
53
+ for (const [featureKey, featureSwitches] of Object.entries(optionDefs)) {
54
+ if (!isObject(featureSwitches)) continue;
55
+
56
+ const featureRequest = getFeatureRequest(options, featureKey);
57
+ console.log("featureRequest : ", featureRequest);
58
+
59
+ if (!isEnabledFeature(featureRequest)) continue;
60
+
61
+ applyFeature({
62
+ featureKey,
63
+ featureSwitches,
64
+ featureRequest,
65
+ base,
66
+ showLog
67
+ });
68
+ }
69
+
70
+ return base;
71
+ };
72
+
73
+ export default runOptions;
@@ -0,0 +1,21 @@
1
+ # v18 instruction sequence experiment
2
+
3
+ This version keeps the public options grouped by feature, then resolves enabled
4
+ option steps into one ordered instruction sequence.
5
+
6
+ 1. Clone the component base spec.
7
+ 2. Add the component's normal build instruction keys to the sequence.
8
+ 3. Resolve requested option switches into named keys such as `set-search` and
9
+ `options-show-button`.
10
+ 4. Run each key in order. Object instructions build from data; array
11
+ instructions apply writes to the current spec.
12
+
13
+ The JSON files in `data/` are local snapshots copied from the declarative
14
+ definition, instruction, and spec repositories. The copied table option
15
+ definitions are reshaped here as ordered steps with `when` / `whenAny` gates.
16
+ This lets the runner be worked on before those repositories adopt the new
17
+ option sequence format.
18
+
19
+ The stable package entry point continues to use v17. This experiment is
20
+ available through the `./v18` package subpath and registers its browser global
21
+ at `ks.jsonRenderers.runInstructions.v18`.
@@ -0,0 +1,334 @@
1
+ {
2
+ "table": {
3
+ "headerOnly": {
4
+ "baseFromSpec": "tableHeaderOnly",
5
+ "instructions": [
6
+ "buildColgroup",
7
+ "buildHeader"
8
+ ],
9
+ "options": {
10
+ "search": [
11
+ {
12
+ "key": "set-search",
13
+ "whenAny": [
14
+ "showLabel",
15
+ "showHelper",
16
+ "showInput"
17
+ ],
18
+ "instructionKey": "searchFrame"
19
+ },
20
+ {
21
+ "key": "search-show-label",
22
+ "when": "showLabel",
23
+ "instructionKey": "searchLabel"
24
+ },
25
+ {
26
+ "key": "search-show-helper",
27
+ "when": "showHelper",
28
+ "instructionKey": "searchHelper"
29
+ },
30
+ {
31
+ "key": "search-show-input",
32
+ "when": "showInput",
33
+ "instructionKey": "searchInput"
34
+ }
35
+ ],
36
+ "serial": [
37
+ {
38
+ "key": "set-serial",
39
+ "whenAny": [
40
+ "showSerial"
41
+ ],
42
+ "instructionKey": "serialRoot"
43
+ },
44
+ {
45
+ "key": "serial-show-serial",
46
+ "when": "showSerial",
47
+ "instructionKey": "serialChild"
48
+ }
49
+ ]
50
+ }
51
+ },
52
+ "simple": {
53
+ "baseFromSpec": "tableSimple",
54
+ "instructions": [
55
+ "buildColgroup",
56
+ "buildHeader",
57
+ "buildBody"
58
+ ],
59
+ "options": {
60
+ "search": [
61
+ {
62
+ "key": "set-search",
63
+ "whenAny": [
64
+ "showLabel",
65
+ "showHelper",
66
+ "showInput"
67
+ ],
68
+ "instructionKey": "searchFrame"
69
+ },
70
+ {
71
+ "key": "search-show-label",
72
+ "when": "showLabel",
73
+ "instructionKey": "searchLabel"
74
+ },
75
+ {
76
+ "key": "search-show-helper",
77
+ "when": "showHelper",
78
+ "instructionKey": "searchHelper"
79
+ },
80
+ {
81
+ "key": "search-show-input",
82
+ "when": "showInput",
83
+ "instructionKey": "searchInput"
84
+ }
85
+ ],
86
+ "serial": [
87
+ {
88
+ "key": "set-serial",
89
+ "whenAny": [
90
+ "showSerial"
91
+ ],
92
+ "instructionKey": "serialRoot"
93
+ },
94
+ {
95
+ "key": "serial-show-serial",
96
+ "when": "showSerial",
97
+ "instructionKey": "serialChild"
98
+ }
99
+ ],
100
+ "options": [
101
+ {
102
+ "key": "options-show-button",
103
+ "when": "showButton",
104
+ "instructionKey": "optionsShowButton"
105
+ },
106
+ {
107
+ "key": "options-show-edit-button",
108
+ "when": "showEditButton",
109
+ "instructionKey": "optionsEditButton"
110
+ },
111
+ {
112
+ "key": "options-show-delete-button",
113
+ "when": "showDeleteButton",
114
+ "instructionKey": "optionsDeleteButton"
115
+ }
116
+ ]
117
+ }
118
+ },
119
+ "withFooter": {
120
+ "baseFromSpec": "tableWithFooter",
121
+ "instructions": [
122
+ "buildColgroup",
123
+ "buildHeader",
124
+ "buildFooter",
125
+ "buildBody"
126
+ ],
127
+ "options": {
128
+ "search": [
129
+ {
130
+ "key": "set-search",
131
+ "whenAny": [
132
+ "showLabel",
133
+ "showHelper",
134
+ "showInput"
135
+ ],
136
+ "instructionKey": "searchFrame"
137
+ },
138
+ {
139
+ "key": "search-show-label",
140
+ "when": "showLabel",
141
+ "instructionKey": "searchLabel"
142
+ },
143
+ {
144
+ "key": "search-show-helper",
145
+ "when": "showHelper",
146
+ "instructionKey": "searchHelper"
147
+ },
148
+ {
149
+ "key": "search-show-input",
150
+ "when": "showInput",
151
+ "instructionKey": "searchInput"
152
+ }
153
+ ],
154
+ "serial": [
155
+ {
156
+ "key": "set-serial",
157
+ "whenAny": [
158
+ "showSerial"
159
+ ],
160
+ "instructionKey": "serialRoot"
161
+ },
162
+ {
163
+ "key": "serial-show-serial",
164
+ "when": "showSerial",
165
+ "instructionKey": "serialChild"
166
+ }
167
+ ],
168
+ "options": [
169
+ {
170
+ "key": "options-show-button",
171
+ "when": "showButton",
172
+ "instructionKey": "optionsShowButton"
173
+ },
174
+ {
175
+ "key": "options-show-edit-button",
176
+ "when": "showEditButton",
177
+ "instructionKey": "optionsEditButton"
178
+ },
179
+ {
180
+ "key": "options-show-delete-button",
181
+ "when": "showDeleteButton",
182
+ "instructionKey": "optionsDeleteButton"
183
+ }
184
+ ]
185
+ }
186
+ },
187
+ "bodyOnly": {
188
+ "baseFromSpec": "tableBodyOnly",
189
+ "instructions": [
190
+ "buildBody"
191
+ ],
192
+ "options": {
193
+ "serial": [
194
+ {
195
+ "key": "serial-show-serial",
196
+ "when": "showSerial",
197
+ "instructionKey": "serialChild"
198
+ }
199
+ ]
200
+ }
201
+ }
202
+ },
203
+ "select": {
204
+ "simple": {
205
+ "baseFromSpec": "selectBase",
206
+ "instructions": [
207
+ "buildSelectWithOptions"
208
+ ],
209
+ "options": {}
210
+ }
211
+ },
212
+ "dataList": {
213
+ "simple": {
214
+ "baseFromSpec": "dataListSimple",
215
+ "instructions": [
216
+ "buildDataListWithOptions"
217
+ ],
218
+ "options": {}
219
+ }
220
+ },
221
+ "selectOptionsOnly": {
222
+ "simple": {
223
+ "baseFromSpec": "selectOptionsOnlyBase",
224
+ "instructions": [
225
+ "buildOptionsArray"
226
+ ],
227
+ "options": {}
228
+ }
229
+ },
230
+ "searchInput": {
231
+ "simple": {
232
+ "baseFromSpec": "searchInputBase",
233
+ "instructions": [],
234
+ "options": {}
235
+ }
236
+ },
237
+ "form": {
238
+ "simple": {
239
+ "baseFromSpec": "formSimple",
240
+ "instructions": [
241
+ "buildFormField"
242
+ ],
243
+ "options": {}
244
+ }
245
+ },
246
+ "accordion": {
247
+ "simple": {
248
+ "baseFromSpec": "accordionSimple",
249
+ "instructions": [
250
+ "buildAccordionItems"
251
+ ],
252
+ "options": {}
253
+ },
254
+ "flush": {
255
+ "baseFromSpec": "accordionFlush",
256
+ "instructions": [
257
+ "buildAccordionItems"
258
+ ],
259
+ "options": {}
260
+ }
261
+ },
262
+ "card": {
263
+ "simple": {
264
+ "baseFromSpec": "cardSimple",
265
+ "instructions": [
266
+ "buildCardBody"
267
+ ],
268
+ "options": {}
269
+ },
270
+ "withHeader": {
271
+ "baseFromSpec": "cardWithHeader",
272
+ "instructions": [
273
+ "buildCardHeader",
274
+ "buildCardBody"
275
+ ],
276
+ "options": {}
277
+ },
278
+ "withFooter": {
279
+ "baseFromSpec": "cardWithFooter",
280
+ "instructions": [
281
+ "buildCardHeader",
282
+ "buildCardBody",
283
+ "buildCardFooter"
284
+ ],
285
+ "options": {}
286
+ },
287
+ "imageTop": {
288
+ "baseFromSpec": "cardImageTop",
289
+ "instructions": [
290
+ "buildCardBody"
291
+ ],
292
+ "options": {}
293
+ }
294
+ },
295
+ "list": {
296
+ "simple": {
297
+ "baseFromSpec": "listSimple",
298
+ "instructions": [
299
+ "buildListItems"
300
+ ],
301
+ "options": {}
302
+ },
303
+ "group": {
304
+ "baseFromSpec": "listGroup",
305
+ "instructions": [
306
+ "buildListGroupItems"
307
+ ],
308
+ "options": {}
309
+ },
310
+ "ordered": {
311
+ "baseFromSpec": "listOrdered",
312
+ "instructions": [
313
+ "buildListGroupItems"
314
+ ],
315
+ "options": {}
316
+ }
317
+ },
318
+ "menu": {
319
+ "simple": {
320
+ "baseFromSpec": "menuSimple",
321
+ "instructions": [
322
+ "buildMenuItems"
323
+ ],
324
+ "options": {}
325
+ },
326
+ "cards": {
327
+ "baseFromSpec": "menuCardsBase",
328
+ "instructions": [
329
+ "buildMenuCards"
330
+ ],
331
+ "options": {}
332
+ }
333
+ }
334
+ }