@voxgig/sdkgen 0.16.0 → 0.18.0

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 (112) hide show
  1. package/dist/action/feature.js +3 -2
  2. package/dist/action/feature.js.map +1 -1
  3. package/dist/action/target.js +11 -6
  4. package/dist/action/target.js.map +1 -1
  5. package/dist/cmp/Entity.js +2 -1
  6. package/dist/cmp/Entity.js.map +1 -1
  7. package/dist/cmp/Main.js +23 -9
  8. package/dist/cmp/Main.js.map +1 -1
  9. package/dist/sdkgen.d.ts +7 -1
  10. package/dist/sdkgen.js +5 -2
  11. package/dist/sdkgen.js.map +1 -1
  12. package/dist/tsconfig.tsbuildinfo +1 -1
  13. package/dist/utility.js +1 -2
  14. package/dist/utility.js.map +1 -1
  15. package/model/sdkgen.jsonic +8 -5
  16. package/package.json +7 -5
  17. package/project/.sdk/model/feature/limit.jsonic +12 -0
  18. package/project/.sdk/model/feature/log.jsonic +32 -0
  19. package/project/.sdk/model/feature/page.jsonic +9 -0
  20. package/project/.sdk/model/feature/telemetry.jsonic +10 -0
  21. package/project/.sdk/model/target/go.jsonic +7 -0
  22. package/project/.sdk/model/target/js.jsonic +23 -0
  23. package/project/.sdk/model/target/ts.jsonic +25 -0
  24. package/project/.sdk/src/cmp/js/Config_js.ts +49 -0
  25. package/project/.sdk/src/cmp/js/Entity_js.ts +92 -0
  26. package/project/.sdk/src/cmp/js/MainEntity_js.ts +22 -0
  27. package/project/.sdk/src/cmp/js/Main_js.ts +88 -0
  28. package/project/.sdk/src/cmp/js/Package_js.ts +58 -0
  29. package/project/.sdk/src/cmp/js/Quick_js.ts +82 -0
  30. package/project/.sdk/src/cmp/js/ReadmeInstall_js.ts +19 -0
  31. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +25 -0
  32. package/project/.sdk/src/cmp/js/TestAcceptEntity_js.ts +13 -0
  33. package/project/.sdk/src/cmp/js/TestAccept_js.ts +18 -0
  34. package/project/.sdk/src/cmp/js/TestEntity_js.ts +13 -0
  35. package/project/.sdk/src/cmp/js/TestMain_js.ts +19 -0
  36. package/project/.sdk/src/cmp/js/Test_js.ts +24 -0
  37. package/project/.sdk/src/cmp/js/fragment/Entity.fragment.js +79 -0
  38. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +61 -0
  39. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +57 -0
  40. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +61 -0
  41. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +61 -0
  42. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +61 -0
  43. package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +67 -0
  44. package/project/.sdk/src/cmp/ts/Config_ts.ts +36 -0
  45. package/project/.sdk/src/cmp/ts/Entity_ts.ts +93 -0
  46. package/project/.sdk/src/cmp/ts/MainEntity_ts.ts.off +22 -0
  47. package/project/.sdk/src/cmp/ts/Main_ts.ts +88 -0
  48. package/project/.sdk/src/cmp/ts/Main_ts.ts~ +88 -0
  49. package/project/.sdk/src/cmp/ts/Package_ts.ts +63 -0
  50. package/project/.sdk/src/cmp/ts/Package_ts.ts~ +58 -0
  51. package/project/.sdk/src/cmp/ts/Quick_ts.ts.off +82 -0
  52. package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts.off +19 -0
  53. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts.off +25 -0
  54. package/project/.sdk/src/cmp/ts/TestAcceptEntity_ts.ts.off +13 -0
  55. package/project/.sdk/src/cmp/ts/TestAccept_ts.ts.off +18 -0
  56. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts.off +13 -0
  57. package/project/.sdk/src/cmp/ts/TestMain_ts.ts.off +19 -0
  58. package/project/.sdk/src/cmp/ts/Test_ts.ts.off +24 -0
  59. package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +15 -0
  60. package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.js +79 -0
  61. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.js +61 -0
  62. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.js +57 -0
  63. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.js +61 -0
  64. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.js +61 -0
  65. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.js +61 -0
  66. package/project/.sdk/src/cmp/ts/fragment/Main.fragment.js +67 -0
  67. package/project/.sdk/tm/go/LICENSE +22 -0
  68. package/project/.sdk/tm/js/LICENSE +22 -0
  69. package/project/.sdk/tm/js/src/feature/log/LogFeature.js +108 -0
  70. package/project/.sdk/tm/js/src/utility/AuthUtility.js +21 -0
  71. package/project/.sdk/tm/js/src/utility/BodyUtility.js +29 -0
  72. package/project/.sdk/tm/js/src/utility/DoneUtility.js +15 -0
  73. package/project/.sdk/tm/js/src/utility/ErrorUtility.js +33 -0
  74. package/project/.sdk/tm/js/src/utility/FindparamUtility.js +31 -0
  75. package/project/.sdk/tm/js/src/utility/FullurlUtility.js +39 -0
  76. package/project/.sdk/tm/js/src/utility/HeadersUtility.js +13 -0
  77. package/project/.sdk/tm/js/src/utility/JoinurlUtility.js +14 -0
  78. package/project/.sdk/tm/js/src/utility/MethodUtility.js +22 -0
  79. package/project/.sdk/tm/js/src/utility/OperatorUtility.js +44 -0
  80. package/project/.sdk/tm/js/src/utility/OptionsUtility.js +54 -0
  81. package/project/.sdk/tm/js/src/utility/ParamsUtility.js +21 -0
  82. package/project/.sdk/tm/js/src/utility/QueryUtility.js +21 -0
  83. package/project/.sdk/tm/js/src/utility/ReqformUtility.js +32 -0
  84. package/project/.sdk/tm/js/src/utility/RequestUtility.js +48 -0
  85. package/project/.sdk/tm/js/src/utility/ResbasicUtility.js +27 -0
  86. package/project/.sdk/tm/js/src/utility/ResbodyUtility.js +15 -0
  87. package/project/.sdk/tm/js/src/utility/ResformUtility.js +34 -0
  88. package/project/.sdk/tm/js/src/utility/ResheadersUtility.js +19 -0
  89. package/project/.sdk/tm/js/src/utility/ResponseUtility.js +37 -0
  90. package/project/.sdk/tm/js/src/utility/ResultUtility.js +28 -0
  91. package/project/.sdk/tm/js/src/utility/SpecUtility.js +35 -0
  92. package/project/.sdk/tm/js/src/utility/StructUtility.js +1203 -0
  93. package/project/.sdk/tm/js/src/utility/Utility.js +74 -0
  94. package/project/.sdk/tm/js/test/runner.js +171 -0
  95. package/project/.sdk/tm/js/test/utility/Custom.test.js +85 -0
  96. package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +187 -0
  97. package/project/.sdk/tm/js/test/utility/StructUtility.test.js +367 -0
  98. package/project/.sdk/tm/py/LICENSE +22 -0
  99. package/project/.sdk/tm/ts/LICENSE +22 -0
  100. package/project/.sdk/tm/ts/src/README.md +1 -0
  101. package/project/.sdk/tm/ts/src/feature/README.md +1 -0
  102. package/project/.sdk/tm/ts/src/tsconfig.json +15 -0
  103. package/project/.sdk/tm/ts/src/utility/README.md +3 -0
  104. package/project/.sdk/tm/ts/test/README.md +2 -0
  105. package/project/.sdk/tm/ts/test/README.md~ +2 -0
  106. package/project/.sdk/tm/ts/test/tsconfig.json +13 -0
  107. package/src/action/feature.ts +4 -3
  108. package/src/action/target.ts +12 -6
  109. package/src/cmp/Entity.ts +3 -1
  110. package/src/cmp/Main.ts +30 -10
  111. package/src/sdkgen.ts +15 -5
  112. package/src/utility.ts +1 -2
@@ -0,0 +1,367 @@
1
+
2
+ const { readFileSync } = require('node:fs')
3
+ const { join } = require('node:path')
4
+ const { test, describe } = require('node:test')
5
+ const { equal, deepEqual, fail } = require('node:assert')
6
+
7
+
8
+ const {
9
+ clone,
10
+ escre,
11
+ escurl,
12
+ getpath,
13
+ getprop,
14
+ inject,
15
+ isempty,
16
+ iskey,
17
+ islist,
18
+ ismap,
19
+ isnode,
20
+ items,
21
+ haskey,
22
+ keysof,
23
+ merge,
24
+ setprop,
25
+ stringify,
26
+ transform,
27
+ walk,
28
+ validate,
29
+ joinurl,
30
+ } = require('../../src/utility/StructUtility')
31
+
32
+
33
+ const { runner } = require('../runner')
34
+
35
+
36
+ function walkpath(_key, val, _parent, path) {
37
+ return 'string' === typeof val ? val + '~' + path.join('.') : val
38
+ }
39
+
40
+
41
+ function nullModifier(
42
+ key,
43
+ val,
44
+ parent
45
+ ) {
46
+ if ("__NULL__" === val) {
47
+ setprop(parent, key, null)
48
+ }
49
+ else if ('string' === typeof val) {
50
+ setprop(parent, key, val.replaceAll('__NULL__', 'null'))
51
+ }
52
+ }
53
+
54
+
55
+ describe('struct', async () => {
56
+
57
+ const { spec, runset, subject } = await runner('struct')
58
+
59
+
60
+ // minor tests
61
+ // ===========
62
+
63
+ test('minor-exists', () => {
64
+ equal('function', typeof clone)
65
+ equal('function', typeof escre)
66
+ equal('function', typeof escurl)
67
+ equal('function', typeof getprop)
68
+ equal('function', typeof isempty)
69
+ equal('function', typeof iskey)
70
+ equal('function', typeof islist)
71
+ equal('function', typeof ismap)
72
+ equal('function', typeof isnode)
73
+ equal('function', typeof items)
74
+ equal('function', typeof setprop)
75
+ equal('function', typeof stringify)
76
+ equal('function', typeof haskey)
77
+ equal('function', typeof keysof)
78
+ equal('function', typeof joinurl)
79
+ })
80
+
81
+ test('minor-clone', async () => {
82
+ await runset(spec.minor.clone, clone)
83
+ })
84
+
85
+ test('minor-isnode', async () => {
86
+ await runset(spec.minor.isnode, isnode)
87
+ })
88
+
89
+ test('minor-ismap', async () => {
90
+ await runset(spec.minor.ismap, ismap)
91
+ })
92
+
93
+ test('minor-islist', async () => {
94
+ await runset(spec.minor.islist, islist)
95
+ })
96
+
97
+ test('minor-iskey', async () => {
98
+ await runset(spec.minor.iskey, iskey)
99
+ })
100
+
101
+ test('minor-isempty', async () => {
102
+ await runset(spec.minor.isempty, isempty)
103
+ })
104
+
105
+ test('minor-escre', async () => {
106
+ await runset(spec.minor.escre, escre)
107
+ })
108
+
109
+ test('minor-escurl', async () => {
110
+ await runset(spec.minor.escurl, escurl)
111
+ })
112
+
113
+ test('minor-stringify', async () => {
114
+ await runset(spec.minor.stringify, (vin) =>
115
+ null == vin.max ? stringify(vin.val) : stringify(vin.val, vin.max))
116
+ })
117
+
118
+ test('minor-items', async () => {
119
+ await runset(spec.minor.items, items)
120
+ })
121
+
122
+ test('minor-getprop', async () => {
123
+ await runset(spec.minor.getprop, (vin) =>
124
+ null == vin.alt ? getprop(vin.val, vin.key) : getprop(vin.val, vin.key, vin.alt))
125
+ })
126
+
127
+ test('minor-setprop', async () => {
128
+ await runset(spec.minor.setprop, (vin) =>
129
+ setprop(vin.parent, vin.key, vin.val))
130
+ })
131
+
132
+ test('minor-haskey', async () => {
133
+ await runset(spec.minor.haskey, haskey)
134
+ })
135
+
136
+ test('minor-keysof', async () => {
137
+ await runset(spec.minor.keysof, keysof)
138
+ })
139
+
140
+ test('minor-joinurl', async () => {
141
+ await runset(spec.minor.joinurl, joinurl)
142
+ })
143
+
144
+
145
+ // walk tests
146
+ // ==========
147
+
148
+ test('walk-exists', async () => {
149
+ equal('function', typeof merge)
150
+ })
151
+
152
+ test('walk-basic', async () => {
153
+ await runset(spec.walk.basic, (vin) => walk(vin, walkpath))
154
+ })
155
+
156
+
157
+ // merge tests
158
+ // ===========
159
+
160
+ test('merge-exists', async () => {
161
+ equal('function', typeof merge)
162
+ })
163
+
164
+ test('merge-basic', async () => {
165
+ const test = clone(spec.merge.basic)
166
+ deepEqual(merge(test.in), test.out)
167
+ })
168
+
169
+ test('merge-cases', async () => {
170
+ await runset(spec.merge.cases, merge)
171
+ })
172
+
173
+ test('merge-array', async () => {
174
+ await runset(spec.merge.array, merge)
175
+ })
176
+
177
+ test('merge-special', async () => {
178
+ const f0 = ()=>null
179
+ deepEqual(merge([f0]), f0)
180
+ deepEqual(merge([null,f0]), f0)
181
+ deepEqual(merge([{a:f0}]), {a:f0})
182
+ deepEqual(merge([{a:{b:f0}}]), {a:{b:f0}})
183
+
184
+ deepEqual(merge([{a:global.fetch}]), {a:global.fetch})
185
+ deepEqual(merge([{a:{b:global.fetch}}]), {a:{b:global.fetch}})
186
+ })
187
+
188
+
189
+ // getpath tests
190
+ // =============
191
+
192
+ test('getpath-exists', async () => {
193
+ equal('function', typeof getpath)
194
+ })
195
+
196
+ test('getpath-basic', async () => {
197
+ await runset(spec.getpath.basic, (vin) => getpath(vin.path, vin.store))
198
+ })
199
+
200
+ test('getpath-current', async () => {
201
+ await runset(spec.getpath.current, (vin) =>
202
+ getpath(vin.path, vin.store, vin.current))
203
+ })
204
+
205
+ test('getpath-state', async () => {
206
+ const state = {
207
+ handler: (state, val, _current, _store) => {
208
+ let out = state.step + ':' + val
209
+ state.step++
210
+ return out
211
+ },
212
+ step: 0,
213
+ mode: 'val',
214
+ full: false,
215
+ keyI: 0,
216
+ keys: ['$TOP'],
217
+ key: '$TOP',
218
+ val: '',
219
+ parent: {},
220
+ path: ['$TOP'],
221
+ nodes: [{}],
222
+ base: '$TOP'
223
+ }
224
+ await runset(spec.getpath.state, (vin) =>
225
+ getpath(vin.path, vin.store, vin.current, state))
226
+ })
227
+
228
+
229
+ // inject tests
230
+ // ============
231
+
232
+ test('inject-exists', async () => {
233
+ equal('function', typeof inject)
234
+ })
235
+
236
+ test('inject-basic', async () => {
237
+ const test = clone(spec.inject.basic)
238
+ deepEqual(inject(test.in.val, test.in.store), test.out)
239
+ })
240
+
241
+ test('inject-string', async () => {
242
+ await runset(spec.inject.string, (vin) =>
243
+ inject(vin.val, vin.store, nullModifier, vin.current))
244
+ })
245
+
246
+ test('inject-deep', async () => {
247
+ await runset(spec.inject.deep, (vin) => inject(vin.val, vin.store))
248
+ })
249
+
250
+
251
+ // transform tests
252
+ // ===============
253
+
254
+ test('transform-exists', async () => {
255
+ equal('function', typeof transform)
256
+ })
257
+
258
+ test('transform-basic', async () => {
259
+ const test = clone(spec.transform.basic)
260
+ deepEqual(transform(test.in.data, test.in.spec, test.in.store), test.out)
261
+ })
262
+
263
+ test('transform-paths', async () => {
264
+ await runset(spec.transform.paths, (vin) =>
265
+ transform(vin.data, vin.spec, vin.store))
266
+ })
267
+
268
+ test('transform-cmds', async () => {
269
+ await runset(spec.transform.cmds, (vin) =>
270
+ transform(vin.data, vin.spec, vin.store))
271
+ })
272
+
273
+ test('transform-each', async () => {
274
+ await runset(spec.transform.each, (vin) =>
275
+ transform(vin.data, vin.spec, vin.store))
276
+ })
277
+
278
+ test('transform-pack', async () => {
279
+ await runset(spec.transform.pack, (vin) =>
280
+ transform(vin.data, vin.spec, vin.store))
281
+ })
282
+
283
+
284
+ test('transform-modify', async () => {
285
+ await runset(spec.transform.modify, (vin) =>
286
+ transform(vin.data, vin.spec, vin.store,
287
+ (key, val, parent) => {
288
+ if (null != key && null != parent && 'string' === typeof val) {
289
+ val = parent[key] = '@' + val
290
+ }
291
+ }
292
+ ))
293
+ })
294
+
295
+ test('transform-extra', async () => {
296
+ deepEqual(transform(
297
+ { a: 1 },
298
+ { x: '`a`', b: '`$COPY`', c: '`$UPPER`' },
299
+ {
300
+ b: 2, $UPPER: (state) => {
301
+ const { path } = state
302
+ return ('' + getprop(path, path.length - 1)).toUpperCase()
303
+ }
304
+ }
305
+ ), {
306
+ x: 1,
307
+ b: 2,
308
+ c: 'C'
309
+ })
310
+ })
311
+
312
+
313
+ test('transform-funcval', async () => {
314
+ const f0 = ()=>99
315
+ deepEqual(transform({},{x:1}), {x:1})
316
+ deepEqual(transform({},{x:f0}), {x:f0})
317
+ deepEqual(transform({a:1},{x:'`a`'}), {x:1})
318
+ deepEqual(transform({f0},{x:'`f0`'}), {x:f0})
319
+ })
320
+
321
+
322
+ // validate tests
323
+ // ===============
324
+
325
+ test('validate-exists', async () => {
326
+ equal('function', typeof validate)
327
+ })
328
+
329
+
330
+ test('validate-basic', async () => {
331
+ await runset(spec.validate.basic, (vin)=>validate(vin.data,vin.spec))
332
+ })
333
+
334
+
335
+ test('validate-node', async () => {
336
+ await runset(spec.validate.node, (vin)=>validate(vin.data,vin.spec))
337
+ })
338
+
339
+
340
+ test('validate-custom', async () => {
341
+ const errs = []
342
+ const extra = {
343
+ $INTEGER: (state, val, current)=>{
344
+ const { mode, key, parent } = state
345
+ let out = getprop(current, key)
346
+
347
+ let t = typeof out
348
+ if('number' !== t && !Number.isInteger(out)) {
349
+ state.errs.push('Not an integer at '+state.path.slice(1).join('.')+': '+out)
350
+ return
351
+ }
352
+
353
+ return out
354
+ },
355
+ }
356
+
357
+ validate({a:1},{a:'`$INTEGER`'},extra,errs)
358
+ equal(errs.length, 0)
359
+
360
+ validate({a:'A'},{a:'`$INTEGER`'},extra,errs)
361
+ deepEqual(errs, [ 'Not an integer at a: A' ])
362
+ })
363
+
364
+
365
+ })
366
+
367
+
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) $$const.year$$ $$const.Name$$
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) $$const.year$$ $$const.Name$$
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1 @@
1
+ # src
@@ -0,0 +1 @@
1
+ # Feature
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "esModuleInterop": true,
4
+ "module": "nodenext",
5
+ "noEmitOnError": true,
6
+ "outDir":"../dist",
7
+ "rootDir":".",
8
+ "resolveJsonModule": true,
9
+ "sourceMap": true,
10
+ "strict": true,
11
+ "target": "es2021",
12
+ "declaration": true,
13
+ "declarationDir": "../dist"
14
+ }
15
+ }
@@ -0,0 +1,3 @@
1
+ # Utility
2
+
3
+
@@ -0,0 +1,2 @@
1
+ # test
2
+
@@ -0,0 +1,2 @@
1
+ # Test
2
+
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "esModuleInterop": true,
4
+ "module": "nodenext",
5
+ "noEmitOnError": true,
6
+ "outDir":"../dist-test",
7
+ "rootDir":".",
8
+ "resolveJsonModule": true,
9
+ "sourceMap": true,
10
+ "strict": true,
11
+ "target": "ES2021"
12
+ }
13
+ }
@@ -20,6 +20,7 @@ const CMD_MAP: any = {
20
20
 
21
21
  const BASE = 'node_modules/@voxgig/sdkgen'
22
22
 
23
+
23
24
  async function action_feature(args: any[], ctx: any) {
24
25
 
25
26
  const cmdname = args[1]
@@ -49,7 +50,6 @@ async function cmd_feature_add(args: any[], ctx: any) {
49
50
  }
50
51
 
51
52
  await jostraca.generate(opts, () => FeatureRoot({ features }))
52
-
53
53
  }
54
54
 
55
55
 
@@ -67,7 +67,8 @@ const FeatureRoot = cmp(function FeatureRoot(props: any) {
67
67
 
68
68
  Folder({ name: 'model/feature' }, () => {
69
69
  Copy({
70
- from: BASE + '/project/generate/model/feature/' + name + '.jsonic',
70
+ // TODO: these paths needs to be parameterised
71
+ from: BASE + '/project/.sdk/model/feature/' + name + '.jsonic',
71
72
  exclude: true
72
73
  })
73
74
  })
@@ -75,7 +76,7 @@ const FeatureRoot = cmp(function FeatureRoot(props: any) {
75
76
  each(target, (target) =>
76
77
  Folder({ name: 'tm/' + target.name + '/src/feature/' + name }, () => {
77
78
  Copy({
78
- from: BASE + '/project/generate/tm/' + target.name + '/src/feature/' + name,
79
+ from: BASE + '/project/.sdk/tm/' + target.name + '/src/feature/' + name,
79
80
  exclude: true
80
81
  })
81
82
  }))
@@ -43,7 +43,8 @@ async function cmd_target_add(args: any[], ctx: any) {
43
43
  fs: ctx.fs,
44
44
  folder: ctx.folder,
45
45
  log: ctx.log.child({ cmp: 'jostraca' }),
46
- meta: { model: ctx.model, tree: ctx.tree }
46
+ meta: { model: ctx.model, tree: ctx.tree },
47
+ model: ctx.model
47
48
  }
48
49
 
49
50
  await jostraca.generate(opts, () => TargetRoot({ targets }))
@@ -55,11 +56,13 @@ const TargetRoot = cmp(function TargetRoot(props: any) {
55
56
  const { ctx$, targets } = props
56
57
 
57
58
  // TODO: model should be a top level ctx property
58
- ctx$.model = ctx$.meta.model
59
+ // ctx$.model = ctx$.meta.model
59
60
 
60
61
  // console.log('MODEL')
61
62
  // console.dir(ctx$.model, { depth: null })
62
63
 
64
+ const { model } = ctx$
65
+
63
66
  Project({}, () => {
64
67
  each(targets, (n) => {
65
68
  // TODO: validate target is a-z0-9-_. only
@@ -67,22 +70,25 @@ const TargetRoot = cmp(function TargetRoot(props: any) {
67
70
 
68
71
  Folder({ name: 'model/target' }, () => {
69
72
  Copy({
70
- from: 'node_modules/@voxgig/sdkgen/project/generate/model/target/' + name + '.jsonic',
73
+ from: 'node_modules/@voxgig/sdkgen/project/.sdk/model/target/' + name + '.jsonic',
71
74
  // exclude: true
72
75
  })
73
76
  })
74
77
 
75
78
  Folder({ name: 'src/cmp/' + name }, () => {
76
79
  Copy({
77
- from: 'node_modules/@voxgig/sdkgen/project/generate/src/cmp/' + name,
80
+ from: 'node_modules/@voxgig/sdkgen/project/.sdk/src/cmp/' + name,
78
81
  // exclude: true
79
82
  })
80
83
  })
81
84
 
82
85
  Folder({ name: 'tm/' + name }, () => {
83
86
  Copy({
84
- from: 'node_modules/@voxgig/sdkgen/project/generate/tm/' + name,
85
- exclude: [/src\/feature/]
87
+ from: 'node_modules/@voxgig/sdkgen/project/.sdk/tm/' + name,
88
+ exclude: [/src\/feature/],
89
+ replace: {
90
+ Name: model.const.Name,
91
+ }
86
92
  })
87
93
  })
88
94
 
package/src/cmp/Entity.ts CHANGED
@@ -9,8 +9,10 @@ import { requirePath } from '../utility'
9
9
  const Entity = cmp(function Entity(props: any) {
10
10
  const { target, entity, ctx$ } = props
11
11
 
12
+ const entitySDK = ctx$.model.main.sdk.entity[entity.name]
13
+
12
14
  const Entity_sdk = requirePath(ctx$, `./cmp/${target.name}/Entity_${target.name}`)
13
- Entity_sdk['Entity']({ target, entity })
15
+ Entity_sdk['Entity']({ target, entity, entitySDK })
14
16
  })
15
17
 
16
18
 
package/src/cmp/Main.ts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { cmp, Copy, Folder } from 'jostraca'
2
+ import { cmp, names, Copy, Folder } from 'jostraca'
3
3
 
4
4
  import { resolvePath } from '../utility'
5
5
 
@@ -8,20 +8,40 @@ const Main = cmp(function Main(props: any) {
8
8
  const { target, ctx$ } = props
9
9
  const { model } = ctx$
10
10
 
11
+ names(model, model.name)
12
+ console.log('MODEL name', model.name, model.Name)
13
+
14
+ Copy({
15
+ from: 'tm/' + target.name,
16
+ replace: {
17
+
18
+ Name: model.Name,
19
+
20
+ // '/"`([^"]+)`"/': '$1'
21
+ }
22
+ })
23
+
11
24
  const Main_sdk = require(resolvePath(ctx$, `cmp/${target.name}/Main_${target.name}`))
12
25
 
13
26
  Main_sdk['Main']({ model, target })
14
27
 
15
- // TODO: make optional via target model
16
- Copy({ from: 'tm/' + target.name + '/LICENSE', to: 'LICENSE' })
28
+ // // TODO: make optional via target model
29
+ // Copy({ from: 'tm/' + target.name + '/LICENSE', to: 'LICENSE' })
30
+
31
+ // Folder({ name: 'src/utility' }, () => {
32
+ // Copy({
33
+ // from: 'tm/' + target.name + '/src/utility',
34
+ // // TODO: make this work for folders
35
+ // // to: target + '/src'
36
+ // })
37
+ // })
38
+
39
+ // Folder({ name: 'test' }, () => {
40
+ // Copy({
41
+ // from: 'tm/' + target.name + '/test',
42
+ // })
43
+ // })
17
44
 
18
- Folder({ name: 'src/utility' }, () => {
19
- Copy({
20
- from: 'tm/' + target.name + '/src/utility',
21
- // TODO: make this work for folders
22
- // to: target + '/src'
23
- })
24
- })
25
45
  })
26
46
 
27
47
 
package/src/sdkgen.ts CHANGED
@@ -8,7 +8,7 @@ import { Jsonic } from 'jsonic'
8
8
  import * as JostracaModule from 'jostraca'
9
9
  import { Aontu, Context } from 'aontu'
10
10
 
11
- import { SdkGenError } from './utility'
11
+ import { SdkGenError, requirePath } from './utility'
12
12
 
13
13
  import { Main } from './cmp/Main'
14
14
  import { Entity } from './cmp/Entity'
@@ -23,7 +23,7 @@ import { action_target } from './action/target'
23
23
  import { action_feature } from './action/feature'
24
24
 
25
25
 
26
-
26
+ // TODO: use shape
27
27
  type SdkGenOptions = {
28
28
  folder: string
29
29
  fs: any
@@ -38,6 +38,13 @@ type SdkGenOptions = {
38
38
  }
39
39
  debug?: boolean | string
40
40
  pino?: ReturnType<typeof Pino>
41
+ now?: () => number
42
+
43
+ // TODO: match Jostraca
44
+ existing?: {
45
+ txt?: any
46
+ bin?: any
47
+ }
41
48
  }
42
49
 
43
50
 
@@ -53,7 +60,9 @@ const ACTION_MAP: any = {
53
60
  function SdkGen(opts: SdkGenOptions) {
54
61
  const fs = opts.fs || Fs
55
62
  const folder = opts.folder || '../'
56
- const jostraca = Jostraca()
63
+ const now = opts.now || (() => Date.now())
64
+
65
+ const jostraca = Jostraca({ now })
57
66
 
58
67
  const pino = prettyPino('sdkgen', opts)
59
68
  const log = pino.child({ cmp: 'sdkgen' })
@@ -80,6 +89,7 @@ function SdkGen(opts: SdkGenOptions) {
80
89
  log: log.child({ cmp: 'jostraca' }),
81
90
  meta: { spec },
82
91
  debug: opts.debug,
92
+ existing: opts.existing
83
93
  }
84
94
 
85
95
  await jostraca.generate(jopts, () => Root({ model }))
@@ -100,10 +110,8 @@ function SdkGen(opts: SdkGenOptions) {
100
110
  throw new SdkGenError('Unknown action: ' + actname)
101
111
  }
102
112
 
103
-
104
113
  const { model, tree } = resolveModel()
105
114
 
106
-
107
115
  const ctx = {
108
116
  fs: () => fs,
109
117
  log,
@@ -294,4 +302,6 @@ export {
294
302
 
295
303
  Jostraca,
296
304
  SdkGen,
305
+
306
+ requirePath,
297
307
  }