@voxgig/sdkgen 0.34.7 → 0.34.10
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/bin/voxgig-sdkgen +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/js/Entity_js.ts +1 -0
- package/project/.sdk/src/cmp/ts/Entity_ts.ts +1 -0
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +2 -2
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +70 -15
- package/project/.sdk/tm/go/utility/make_target.go +5 -0
- package/project/.sdk/tm/ts/src/utility/MakePointUtility.ts +5 -0
package/bin/voxgig-sdkgen
CHANGED
package/package.json
CHANGED
|
@@ -121,7 +121,7 @@ function directSetup(mockres?: any) {
|
|
|
121
121
|
|
|
122
122
|
function generateDirectLoad(model: any, entity: any) {
|
|
123
123
|
const loadOp = entity.op.load
|
|
124
|
-
const loadPoint = loadOp
|
|
124
|
+
const loadPoint = loadOp?.points?.[0]
|
|
125
125
|
|
|
126
126
|
if (null == loadPoint) {
|
|
127
127
|
return
|
|
@@ -218,7 +218,7 @@ ${paramAsserts} }
|
|
|
218
218
|
|
|
219
219
|
function generateDirectList(model: any, entity: any) {
|
|
220
220
|
const listOp = entity.op.list
|
|
221
|
-
const listPoint = listOp
|
|
221
|
+
const listPoint = listOp?.points?.[0]
|
|
222
222
|
|
|
223
223
|
if (null == listPoint) {
|
|
224
224
|
return
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
} from './utility_ts'
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
type OpGen = (model: any, entity: any, flow: any, step: any, index: any) => void
|
|
40
|
+
type OpGen = (model: any, entity: any, flow: any, step: any, index: { key$: number, val$: any }) => void
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
const TestEntity = cmp(function TestEntity(props: any) {
|
|
@@ -183,17 +183,39 @@ const generateCreate: OpGen = (
|
|
|
183
183
|
entity: ModelEntity,
|
|
184
184
|
flow: ModelEntityFlow,
|
|
185
185
|
step: ModelEntityFlowStep,
|
|
186
|
-
index:
|
|
186
|
+
index: any
|
|
187
187
|
) => {
|
|
188
188
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
189
189
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
190
190
|
const datavar = step.input.datavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
191
191
|
|
|
192
|
+
const priorSteps = Object.values(flow.step).slice(0, Number(index))
|
|
193
|
+
const needsEnt = !priorSteps.some((s: any) =>
|
|
194
|
+
['create', 'list', 'load', 'remove'].includes(s.op))
|
|
195
|
+
|
|
196
|
+
const hasDatvar = priorSteps.some((s: any) => {
|
|
197
|
+
if ('create' === s.op) {
|
|
198
|
+
const priorRef = s.input?.ref ?? entity.name + '_ref01'
|
|
199
|
+
const priorDatvar = s.input?.datavar ?? (priorRef + '_data' + (s.input?.suffix ?? ''))
|
|
200
|
+
return priorDatvar === datavar
|
|
201
|
+
}
|
|
202
|
+
return false
|
|
203
|
+
})
|
|
204
|
+
|
|
192
205
|
Content(`
|
|
193
206
|
// CREATE
|
|
194
|
-
const ${entvar} = client.${nom(entity, 'Name')}()
|
|
195
|
-
let ${datavar} = setup.data.new.${entity.name}['${ref}']
|
|
196
207
|
`)
|
|
208
|
+
if (needsEnt) {
|
|
209
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
210
|
+
`)
|
|
211
|
+
}
|
|
212
|
+
if (hasDatvar) {
|
|
213
|
+
Content(` ${datavar} = setup.data.new.${entity.name}['${ref}']
|
|
214
|
+
`)
|
|
215
|
+
} else {
|
|
216
|
+
Content(` let ${datavar} = setup.data.new.${entity.name}['${ref}']
|
|
217
|
+
`)
|
|
218
|
+
}
|
|
197
219
|
|
|
198
220
|
each(step.match, (mi: any) => {
|
|
199
221
|
Content(` ${datavar}['${mi.key$}'] = setup.idmap['${mi.val$}']
|
|
@@ -212,16 +234,25 @@ const generateList: OpGen = (
|
|
|
212
234
|
entity: ModelEntity,
|
|
213
235
|
flow: ModelEntityFlow,
|
|
214
236
|
step: ModelEntityFlowStep,
|
|
215
|
-
index:
|
|
237
|
+
index: any
|
|
216
238
|
) => {
|
|
217
239
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
218
240
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
219
241
|
const matchvar = step.input.matchvar ?? (ref + '_match' + (step.input.suffix ?? ''))
|
|
220
242
|
const listvar = step.input.listvar ?? (ref + '_list' + (step.input.suffix ?? ''))
|
|
221
243
|
|
|
244
|
+
const priorSteps = Object.values(flow.step).slice(0, Number(index))
|
|
245
|
+
const needsEnt = !priorSteps.some((s: any) =>
|
|
246
|
+
['create', 'list', 'load', 'remove'].includes(s.op))
|
|
247
|
+
|
|
222
248
|
Content(`
|
|
223
249
|
// LIST
|
|
224
|
-
|
|
250
|
+
`)
|
|
251
|
+
if (needsEnt) {
|
|
252
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
253
|
+
`)
|
|
254
|
+
}
|
|
255
|
+
Content(` const ${matchvar}: any = {}
|
|
225
256
|
`)
|
|
226
257
|
|
|
227
258
|
each(step.match, (mi: any) => {
|
|
@@ -232,16 +263,21 @@ const generateList: OpGen = (
|
|
|
232
263
|
Content(`
|
|
233
264
|
const ${listvar} = await ${entvar}.list(${matchvar})
|
|
234
265
|
`)
|
|
266
|
+
const allSteps = Object.values(flow.step)
|
|
235
267
|
for (let vI = 0; vI < step.valid.length; vI++) {
|
|
236
268
|
const validator = step.valid[vI]
|
|
237
|
-
|
|
269
|
+
const validRef = validator.def?.ref
|
|
270
|
+
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.op &&
|
|
271
|
+
((s.input?.ref ?? entity.name + '_ref01') === validRef))
|
|
272
|
+
|
|
273
|
+
if ('ItemExists' === validator.apply && hasRefData) {
|
|
238
274
|
Content(`
|
|
239
|
-
assert(!isempty(select(${listvar}, { id: ${
|
|
275
|
+
assert(!isempty(select(${listvar}, { id: ${validRef}_data.id })))
|
|
240
276
|
`)
|
|
241
277
|
}
|
|
242
|
-
else if ('ItemNotExists' === validator.apply) {
|
|
278
|
+
else if ('ItemNotExists' === validator.apply && hasRefData) {
|
|
243
279
|
Content(`
|
|
244
|
-
assert(isempty(select(${listvar}, { id: ${
|
|
280
|
+
assert(isempty(select(${listvar}, { id: ${validRef}_data.id })))
|
|
245
281
|
`)
|
|
246
282
|
}
|
|
247
283
|
}
|
|
@@ -253,7 +289,7 @@ const generateUpdate: OpGen = (
|
|
|
253
289
|
entity: ModelEntity,
|
|
254
290
|
flow: ModelEntityFlow,
|
|
255
291
|
step: ModelEntityFlowStep,
|
|
256
|
-
index:
|
|
292
|
+
index: any
|
|
257
293
|
) => {
|
|
258
294
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
259
295
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
@@ -310,7 +346,7 @@ const generateLoad: OpGen = (
|
|
|
310
346
|
entity: ModelEntity,
|
|
311
347
|
flow: ModelEntityFlow,
|
|
312
348
|
step: ModelEntityFlowStep,
|
|
313
|
-
index:
|
|
349
|
+
index: any
|
|
314
350
|
) => {
|
|
315
351
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
316
352
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
@@ -318,9 +354,19 @@ const generateLoad: OpGen = (
|
|
|
318
354
|
const datavar = step.input.datavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
319
355
|
const srcdatavar = step.input.srcdatavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
320
356
|
|
|
357
|
+
const priorSteps = Object.values(flow.step).slice(0, Number(index))
|
|
358
|
+
const hasEntVar = priorSteps.some((s: any) =>
|
|
359
|
+
['create', 'list', 'load', 'remove'].includes(s.op))
|
|
360
|
+
|
|
321
361
|
Content(`
|
|
322
362
|
// LOAD
|
|
323
|
-
|
|
363
|
+
`)
|
|
364
|
+
if (!hasEntVar) {
|
|
365
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
366
|
+
const ${srcdatavar} = Object.values(setup.data.existing.${entity.name})[0] as any
|
|
367
|
+
`)
|
|
368
|
+
}
|
|
369
|
+
Content(` const ${matchvar}: any = {}
|
|
324
370
|
${matchvar}.id = ${srcdatavar}.id
|
|
325
371
|
const ${datavar} = await ${entvar}.load(${matchvar})
|
|
326
372
|
assert(${datavar}.id === ${srcdatavar}.id)
|
|
@@ -333,16 +379,25 @@ const generateRemove: OpGen = (
|
|
|
333
379
|
entity: ModelEntity,
|
|
334
380
|
flow: ModelEntityFlow,
|
|
335
381
|
step: ModelEntityFlowStep,
|
|
336
|
-
index:
|
|
382
|
+
index: any
|
|
337
383
|
) => {
|
|
338
384
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
339
385
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
340
386
|
const matchvar = step.input.matchvar ?? (ref + '_match' + (step.input.suffix ?? ''))
|
|
341
387
|
const srcdatavar = step.input.srcdatavar ?? (ref + '_data')
|
|
342
388
|
|
|
389
|
+
const priorSteps = Object.values(flow.step).slice(0, Number(index))
|
|
390
|
+
const needsEnt = !priorSteps.some((s: any) =>
|
|
391
|
+
['create', 'list', 'load', 'remove'].includes(s.op))
|
|
392
|
+
|
|
343
393
|
Content(`
|
|
344
394
|
// REMOVE
|
|
345
|
-
|
|
395
|
+
`)
|
|
396
|
+
if (needsEnt) {
|
|
397
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
398
|
+
`)
|
|
399
|
+
}
|
|
400
|
+
Content(` const ${matchvar}: any = {}
|
|
346
401
|
${matchvar}.id = ${srcdatavar}.id
|
|
347
402
|
await ${entvar}.remove(${matchvar})
|
|
348
403
|
`)
|
|
@@ -26,6 +26,11 @@ func makePointUtil(ctx *core.Context) (map[string]any, error) {
|
|
|
26
26
|
"\" not allowed by SDK option allow.op value: \""+allowOp+"\"")
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
if len(op.Points) == 0 {
|
|
30
|
+
return nil, ctx.MakeError("point_no_points",
|
|
31
|
+
"Operation \""+op.Name+"\" has no endpoint definitions.")
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
if len(op.Points) == 1 {
|
|
30
35
|
ctx.Point = op.Points[0]
|
|
31
36
|
} else {
|
|
@@ -16,6 +16,11 @@ function makePoint(ctx: Context): Point | Error {
|
|
|
16
16
|
'" not allowed by SDK option allow.op value: "' + options.allow.op + '"')
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
if (0 === op.points.length) {
|
|
20
|
+
return ctx.error('point_no_points',
|
|
21
|
+
'Operation "' + op.name + '" has no endpoint definitions.')
|
|
22
|
+
}
|
|
23
|
+
|
|
19
24
|
// Choose the appropriate point based on the match or data.
|
|
20
25
|
if (1 === op.points.length) {
|
|
21
26
|
ctx.point = op.points[0]
|