@voxgig/sdkgen 0.34.7 → 0.34.8
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
CHANGED
package/package.json
CHANGED
|
@@ -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,7 +183,7 @@ 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'
|
|
@@ -212,16 +212,24 @@ const generateList: OpGen = (
|
|
|
212
212
|
entity: ModelEntity,
|
|
213
213
|
flow: ModelEntityFlow,
|
|
214
214
|
step: ModelEntityFlowStep,
|
|
215
|
-
index:
|
|
215
|
+
index: any
|
|
216
216
|
) => {
|
|
217
217
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
218
218
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
219
219
|
const matchvar = step.input.matchvar ?? (ref + '_match' + (step.input.suffix ?? ''))
|
|
220
220
|
const listvar = step.input.listvar ?? (ref + '_list' + (step.input.suffix ?? ''))
|
|
221
221
|
|
|
222
|
+
const priorSteps = Object.values(flow.step).slice(0, index.key$)
|
|
223
|
+
const needsEnt = !priorSteps.some((s: any) => 'create' === s.op)
|
|
224
|
+
|
|
222
225
|
Content(`
|
|
223
226
|
// LIST
|
|
224
|
-
|
|
227
|
+
`)
|
|
228
|
+
if (needsEnt) {
|
|
229
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
230
|
+
`)
|
|
231
|
+
}
|
|
232
|
+
Content(` const ${matchvar}: any = {}
|
|
225
233
|
`)
|
|
226
234
|
|
|
227
235
|
each(step.match, (mi: any) => {
|
|
@@ -232,16 +240,21 @@ const generateList: OpGen = (
|
|
|
232
240
|
Content(`
|
|
233
241
|
const ${listvar} = await ${entvar}.list(${matchvar})
|
|
234
242
|
`)
|
|
243
|
+
const allSteps = Object.values(flow.step)
|
|
235
244
|
for (let vI = 0; vI < step.valid.length; vI++) {
|
|
236
245
|
const validator = step.valid[vI]
|
|
237
|
-
|
|
246
|
+
const validRef = validator.def?.ref
|
|
247
|
+
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.op &&
|
|
248
|
+
((s.input?.ref ?? entity.name + '_ref01') === validRef))
|
|
249
|
+
|
|
250
|
+
if ('ItemExists' === validator.apply && hasRefData) {
|
|
238
251
|
Content(`
|
|
239
|
-
assert(!isempty(select(${listvar}, { id: ${
|
|
252
|
+
assert(!isempty(select(${listvar}, { id: ${validRef}_data.id })))
|
|
240
253
|
`)
|
|
241
254
|
}
|
|
242
|
-
else if ('ItemNotExists' === validator.apply) {
|
|
255
|
+
else if ('ItemNotExists' === validator.apply && hasRefData) {
|
|
243
256
|
Content(`
|
|
244
|
-
assert(isempty(select(${listvar}, { id: ${
|
|
257
|
+
assert(isempty(select(${listvar}, { id: ${validRef}_data.id })))
|
|
245
258
|
`)
|
|
246
259
|
}
|
|
247
260
|
}
|
|
@@ -253,7 +266,7 @@ const generateUpdate: OpGen = (
|
|
|
253
266
|
entity: ModelEntity,
|
|
254
267
|
flow: ModelEntityFlow,
|
|
255
268
|
step: ModelEntityFlowStep,
|
|
256
|
-
index:
|
|
269
|
+
index: any
|
|
257
270
|
) => {
|
|
258
271
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
259
272
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
@@ -310,7 +323,7 @@ const generateLoad: OpGen = (
|
|
|
310
323
|
entity: ModelEntity,
|
|
311
324
|
flow: ModelEntityFlow,
|
|
312
325
|
step: ModelEntityFlowStep,
|
|
313
|
-
index:
|
|
326
|
+
index: any
|
|
314
327
|
) => {
|
|
315
328
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
316
329
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
@@ -318,9 +331,18 @@ const generateLoad: OpGen = (
|
|
|
318
331
|
const datavar = step.input.datavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
319
332
|
const srcdatavar = step.input.srcdatavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
320
333
|
|
|
334
|
+
const priorSteps = Object.values(flow.step).slice(0, index.key$)
|
|
335
|
+
const hasCreate = priorSteps.some((s: any) => 'create' === s.op)
|
|
336
|
+
|
|
321
337
|
Content(`
|
|
322
338
|
// LOAD
|
|
323
|
-
|
|
339
|
+
`)
|
|
340
|
+
if (!hasCreate) {
|
|
341
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
342
|
+
const ${srcdatavar} = Object.values(setup.data.existing.${entity.name})[0] as any
|
|
343
|
+
`)
|
|
344
|
+
}
|
|
345
|
+
Content(` const ${matchvar}: any = {}
|
|
324
346
|
${matchvar}.id = ${srcdatavar}.id
|
|
325
347
|
const ${datavar} = await ${entvar}.load(${matchvar})
|
|
326
348
|
assert(${datavar}.id === ${srcdatavar}.id)
|
|
@@ -333,16 +355,24 @@ const generateRemove: OpGen = (
|
|
|
333
355
|
entity: ModelEntity,
|
|
334
356
|
flow: ModelEntityFlow,
|
|
335
357
|
step: ModelEntityFlowStep,
|
|
336
|
-
index:
|
|
358
|
+
index: any
|
|
337
359
|
) => {
|
|
338
360
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
339
361
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
340
362
|
const matchvar = step.input.matchvar ?? (ref + '_match' + (step.input.suffix ?? ''))
|
|
341
363
|
const srcdatavar = step.input.srcdatavar ?? (ref + '_data')
|
|
342
364
|
|
|
365
|
+
const priorSteps = Object.values(flow.step).slice(0, index.key$)
|
|
366
|
+
const needsEnt = !priorSteps.some((s: any) => 'create' === s.op)
|
|
367
|
+
|
|
343
368
|
Content(`
|
|
344
369
|
// REMOVE
|
|
345
|
-
|
|
370
|
+
`)
|
|
371
|
+
if (needsEnt) {
|
|
372
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
373
|
+
`)
|
|
374
|
+
}
|
|
375
|
+
Content(` const ${matchvar}: any = {}
|
|
346
376
|
${matchvar}.id = ${srcdatavar}.id
|
|
347
377
|
await ${entvar}.remove(${matchvar})
|
|
348
378
|
`)
|