@voxgig/sdkgen 0.36.0 → 0.37.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.
- package/bin/voxgig-sdkgen +1 -1
- package/dist/cmp/Main.js +0 -12
- package/dist/cmp/Main.js.map +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/go/Config_go.ts +6 -2
- package/project/.sdk/src/cmp/js/EntityBase_js.ts +34 -0
- package/project/.sdk/src/cmp/js/Main_js.ts +10 -0
- package/project/.sdk/src/cmp/js/ReadmeExplanation_js.ts +33 -0
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +123 -0
- package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +152 -0
- package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +25 -0
- package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +65 -0
- package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +36 -0
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +53 -5
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +114 -20
- package/project/.sdk/src/cmp/js/fragment/Entity.fragment.js +7 -139
- package/project/.sdk/src/cmp/js/fragment/EntityBase.fragment.js +149 -0
- package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +6 -10
- package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +6 -10
- package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +7 -11
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +2 -0
- package/project/.sdk/src/cmp/js/fragment/SdkError.fragment.js +0 -2
- package/project/.sdk/src/cmp/lua/Config_lua.ts +6 -2
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +3 -1
- package/project/.sdk/src/cmp/php/Config_php.ts +6 -2
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +2 -2
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +10 -15
- package/project/.sdk/src/cmp/py/Config_py.ts +6 -2
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +3 -1
- package/project/.sdk/src/cmp/rb/Config_rb.ts +6 -2
- package/project/.sdk/src/cmp/ts/Main_ts.ts +7 -0
- package/project/.sdk/tm/go/feature/log_feature.go +1 -1
- package/project/.sdk/tm/go/test/runner_test.go +16 -2
- package/project/.sdk/tm/js/src/Context.js +142 -0
- package/project/.sdk/tm/js/src/Control.js +16 -0
- package/project/.sdk/tm/js/src/Operation.js +19 -0
- package/project/.sdk/tm/js/src/Point.js +24 -0
- package/project/.sdk/tm/js/src/README.md +1 -0
- package/project/.sdk/tm/js/src/Response.js +19 -0
- package/project/.sdk/tm/js/src/Result.js +21 -0
- package/project/.sdk/tm/js/src/Spec.js +26 -0
- package/project/.sdk/tm/js/src/feature/README.md +1 -0
- package/project/.sdk/tm/js/src/feature/base/BaseFeature.js +45 -0
- package/project/.sdk/tm/js/src/feature/log/LogFeature.js +46 -47
- package/project/.sdk/tm/js/src/feature/test/TestFeature.js +207 -0
- package/project/.sdk/tm/js/src/types.js +22 -0
- package/project/.sdk/tm/js/src/utility/CleanUtility.js +31 -0
- package/project/.sdk/tm/js/src/utility/DoneUtility.js +11 -4
- package/project/.sdk/tm/js/src/utility/FeatureAddUtility.js +42 -0
- package/project/.sdk/tm/js/src/utility/FeatureHookUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/FeatureInitUtility.js +11 -0
- package/project/.sdk/tm/js/src/utility/FetcherUtility.js +28 -0
- package/project/.sdk/tm/js/src/utility/MakeContextUtility.js +11 -0
- package/project/.sdk/tm/js/src/utility/MakeErrorUtility.js +55 -0
- package/project/.sdk/tm/js/src/utility/MakeFetchDefUtility.js +44 -0
- package/project/.sdk/tm/js/src/utility/MakeOptionsUtility.js +93 -0
- package/project/.sdk/tm/js/src/utility/MakePointUtility.js +77 -0
- package/project/.sdk/tm/js/src/utility/MakeRequestUtility.js +63 -0
- package/project/.sdk/tm/js/src/utility/MakeResponseUtility.js +55 -0
- package/project/.sdk/tm/js/src/utility/MakeResultUtility.js +54 -0
- package/project/.sdk/tm/js/src/utility/MakeSpecUtility.js +58 -0
- package/project/.sdk/tm/js/src/utility/MakeUrlUtility.js +40 -0
- package/project/.sdk/tm/js/src/utility/ParamUtility.js +61 -0
- package/project/.sdk/tm/js/src/utility/PrepareAuthUtility.js +41 -0
- package/project/.sdk/tm/js/src/utility/PrepareBodyUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/PrepareHeadersUtility.js +18 -0
- package/project/.sdk/tm/js/src/utility/{MethodUtility.js → PrepareMethodUtility.js} +7 -7
- package/project/.sdk/tm/js/src/utility/PrepareParamsUtility.js +25 -0
- package/project/.sdk/tm/js/src/utility/PreparePathUtility.js +13 -0
- package/project/.sdk/tm/js/src/utility/PrepareQueryUtility.js +26 -0
- package/project/.sdk/tm/js/src/utility/README.md +1 -0
- package/project/.sdk/tm/js/src/utility/ResultBasicUtility.js +34 -0
- package/project/.sdk/tm/js/src/utility/ResultBodyUtility.js +18 -0
- package/project/.sdk/tm/js/src/utility/ResultHeadersUtility.js +22 -0
- package/project/.sdk/tm/js/src/utility/StructUtility.js +2219 -1078
- package/project/.sdk/tm/js/src/utility/TransformRequestUtility.js +28 -0
- package/project/.sdk/tm/js/src/utility/TransformResponseUtility.js +31 -0
- package/project/.sdk/tm/js/src/utility/Utility.js +61 -61
- package/project/.sdk/tm/js/test/README.md +1 -0
- package/project/.sdk/tm/js/test/exists.test.js +16 -0
- package/project/.sdk/tm/js/test/runner.js +323 -107
- package/project/.sdk/tm/js/test/utility/Custom.test.js +41 -63
- package/project/.sdk/tm/js/test/utility/PrimaryUtility.test.js +390 -116
- package/project/.sdk/tm/js/test/utility/StructUtility.test.js +728 -175
- package/project/.sdk/tm/js/test/utility/index.js +9 -0
- package/project/.sdk/tm/js/test/utility.js +72 -0
- package/project/.sdk/tm/lua/test/primary_utility_test.lua +1213 -0
- package/project/.sdk/tm/lua/test/runner.lua +2 -2
- package/project/.sdk/tm/lua/test/struct_runner.lua +602 -0
- package/project/.sdk/tm/lua/test/struct_utility_test.lua +959 -0
- package/project/.sdk/tm/lua/utility/struct/struct.lua +10 -0
- package/project/.sdk/tm/php/feature/TestFeature.php +59 -96
- package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +1309 -0
- package/project/.sdk/tm/php/test/Runner.php +24 -1
- package/project/.sdk/tm/php/test/StructRunner.php +275 -0
- package/project/.sdk/tm/php/test/StructUtilityTest.php +1336 -0
- package/project/.sdk/tm/php/utility/Fetcher.php +6 -2
- package/project/.sdk/tm/php/utility/MakeOptions.php +5 -1
- package/project/.sdk/tm/php/utility/MakeResult.php +3 -0
- package/project/.sdk/tm/php/utility/Param.php +9 -7
- package/project/.sdk/tm/php/utility/struct/Struct.php +312 -208
- package/project/.sdk/tm/py/test/runner.py +13 -0
- package/project/.sdk/tm/py/test/struct_runner.py +411 -0
- package/project/.sdk/tm/py/test/test_primary_utility.py +1101 -0
- package/project/.sdk/tm/py/test/test_struct_utility.py +751 -0
- package/project/.sdk/tm/rb/test/primary_utility_test.rb +1083 -0
- package/project/.sdk/tm/rb/test/runner.rb +5 -0
- package/project/.sdk/tm/rb/test/struct_runner.rb +309 -0
- package/project/.sdk/tm/rb/test/struct_utility_test.rb +670 -0
- package/src/cmp/Main.ts +1 -16
- package/project/.sdk/src/cmp/js/Quick_js.ts +0 -78
- package/project/.sdk/src/cmp/js/TestAcceptEntity_js.ts +0 -13
- package/project/.sdk/src/cmp/js/TestAccept_js.ts +0 -18
- package/project/.sdk/tm/js/src/utility/AuthUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/BodyUtility.js +0 -29
- package/project/.sdk/tm/js/src/utility/ErrorUtility.js +0 -33
- package/project/.sdk/tm/js/src/utility/FindparamUtility.js +0 -31
- package/project/.sdk/tm/js/src/utility/FullurlUtility.js +0 -39
- package/project/.sdk/tm/js/src/utility/HeadersUtility.js +0 -13
- package/project/.sdk/tm/js/src/utility/JoinurlUtility.js +0 -14
- package/project/.sdk/tm/js/src/utility/OperatorUtility.js +0 -44
- package/project/.sdk/tm/js/src/utility/OptionsUtility.js +0 -54
- package/project/.sdk/tm/js/src/utility/ParamsUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/QueryUtility.js +0 -21
- package/project/.sdk/tm/js/src/utility/ReqformUtility.js +0 -32
- package/project/.sdk/tm/js/src/utility/RequestUtility.js +0 -48
- package/project/.sdk/tm/js/src/utility/ResbasicUtility.js +0 -27
- package/project/.sdk/tm/js/src/utility/ResbodyUtility.js +0 -15
- package/project/.sdk/tm/js/src/utility/ResformUtility.js +0 -34
- package/project/.sdk/tm/js/src/utility/ResheadersUtility.js +0 -19
- package/project/.sdk/tm/js/src/utility/ResponseUtility.js +0 -37
- package/project/.sdk/tm/js/src/utility/ResultUtility.js +0 -28
- package/project/.sdk/tm/js/src/utility/SpecUtility.js +0 -35
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
} from './utility_js'
|
|
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) {
|
|
@@ -78,9 +78,9 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
78
78
|
const indent = 2
|
|
79
79
|
|
|
80
80
|
const idlist = flatten([
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
entity.name + '01',
|
|
82
|
+
entity.name + '02',
|
|
83
|
+
entity.name + '03',
|
|
84
84
|
flatten(items(entity.relations.ancestors, (ap: any) =>
|
|
85
85
|
items(ap[1], (a: any) =>
|
|
86
86
|
items(['01', '02', '03'], (n: any) =>
|
|
@@ -156,6 +156,10 @@ function basicSetup(extra) {
|
|
|
156
156
|
|
|
157
157
|
|
|
158
158
|
Slot({ name: 'basic' }, () => {
|
|
159
|
+
const flowHasCreate = Object.values(basicflow.step).some(
|
|
160
|
+
(s: any) => s.op === 'create'
|
|
161
|
+
)
|
|
162
|
+
|
|
159
163
|
Content(`
|
|
160
164
|
const setup = basicSetup()
|
|
161
165
|
const client = setup.client
|
|
@@ -166,6 +170,15 @@ function basicSetup(extra) {
|
|
|
166
170
|
|
|
167
171
|
`)
|
|
168
172
|
|
|
173
|
+
// When the flow has no create step, bootstrap the entity data variable
|
|
174
|
+
// from existing test data so that subsequent update/load/remove steps
|
|
175
|
+
// can reference it.
|
|
176
|
+
if (!flowHasCreate) {
|
|
177
|
+
const ref01 = entity.name + '_ref01'
|
|
178
|
+
Content(` let ${ref01}_data = Object.values(setup.data.existing.${entity.name})[0]
|
|
179
|
+
`)
|
|
180
|
+
}
|
|
181
|
+
|
|
169
182
|
each(basicflow.step, (step: any, index: any) => {
|
|
170
183
|
const opgen: OpGen = GENERATE_OP[step.op]
|
|
171
184
|
opgen(model, entity, basicflow, step, index)
|
|
@@ -183,17 +196,39 @@ const generateCreate: OpGen = (
|
|
|
183
196
|
entity: ModelEntity,
|
|
184
197
|
flow: ModelEntityFlow,
|
|
185
198
|
step: ModelEntityFlowStep,
|
|
186
|
-
index:
|
|
199
|
+
index: any
|
|
187
200
|
) => {
|
|
188
201
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
189
202
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
190
203
|
const datavar = step.input.datavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
191
204
|
|
|
205
|
+
const priorSteps = Object.values(flow.step).slice(0, Number(index))
|
|
206
|
+
const needsEnt = !priorSteps.some((s: any) =>
|
|
207
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.op))
|
|
208
|
+
|
|
209
|
+
const hasDatvar = priorSteps.some((s: any) => {
|
|
210
|
+
if ('create' === s.op) {
|
|
211
|
+
const priorRef = s.input?.ref ?? entity.name + '_ref01'
|
|
212
|
+
const priorDatvar = s.input?.datavar ?? (priorRef + '_data' + (s.input?.suffix ?? ''))
|
|
213
|
+
return priorDatvar === datavar
|
|
214
|
+
}
|
|
215
|
+
return false
|
|
216
|
+
})
|
|
217
|
+
|
|
192
218
|
Content(`
|
|
193
219
|
// CREATE
|
|
194
|
-
const ${entvar} = client.${nom(entity, 'Name')}()
|
|
195
|
-
let ${datavar} = setup.data.new.${entity.name}['${ref}']
|
|
196
220
|
`)
|
|
221
|
+
if (needsEnt) {
|
|
222
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
223
|
+
`)
|
|
224
|
+
}
|
|
225
|
+
if (hasDatvar) {
|
|
226
|
+
Content(` ${datavar} = setup.data.new.${entity.name}['${ref}']
|
|
227
|
+
`)
|
|
228
|
+
} else {
|
|
229
|
+
Content(` let ${datavar} = setup.data.new.${entity.name}['${ref}']
|
|
230
|
+
`)
|
|
231
|
+
}
|
|
197
232
|
|
|
198
233
|
each(step.match, (mi: any) => {
|
|
199
234
|
Content(` ${datavar}['${mi.key$}'] = setup.idmap['${mi.val$}']
|
|
@@ -212,16 +247,25 @@ const generateList: OpGen = (
|
|
|
212
247
|
entity: ModelEntity,
|
|
213
248
|
flow: ModelEntityFlow,
|
|
214
249
|
step: ModelEntityFlowStep,
|
|
215
|
-
index:
|
|
250
|
+
index: any
|
|
216
251
|
) => {
|
|
217
252
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
218
253
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
219
254
|
const matchvar = step.input.matchvar ?? (ref + '_match' + (step.input.suffix ?? ''))
|
|
220
255
|
const listvar = step.input.listvar ?? (ref + '_list' + (step.input.suffix ?? ''))
|
|
221
256
|
|
|
257
|
+
const priorSteps = Object.values(flow.step).slice(0, Number(index))
|
|
258
|
+
const needsEnt = !priorSteps.some((s: any) =>
|
|
259
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.op))
|
|
260
|
+
|
|
222
261
|
Content(`
|
|
223
262
|
// LIST
|
|
224
|
-
|
|
263
|
+
`)
|
|
264
|
+
if (needsEnt) {
|
|
265
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
266
|
+
`)
|
|
267
|
+
}
|
|
268
|
+
Content(` const ${matchvar} = {}
|
|
225
269
|
`)
|
|
226
270
|
|
|
227
271
|
each(step.match, (mi: any) => {
|
|
@@ -232,16 +276,21 @@ const generateList: OpGen = (
|
|
|
232
276
|
Content(`
|
|
233
277
|
const ${listvar} = await ${entvar}.list(${matchvar})
|
|
234
278
|
`)
|
|
279
|
+
const allSteps = Object.values(flow.step)
|
|
235
280
|
for (let vI = 0; vI < step.valid.length; vI++) {
|
|
236
281
|
const validator = step.valid[vI]
|
|
237
|
-
|
|
282
|
+
const validRef = validator.def?.ref
|
|
283
|
+
const hasRefData = validRef && allSteps.some((s: any) => 'create' === s.op &&
|
|
284
|
+
((s.input?.ref ?? entity.name + '_ref01') === validRef))
|
|
285
|
+
|
|
286
|
+
if ('ItemExists' === validator.apply && hasRefData) {
|
|
238
287
|
Content(`
|
|
239
|
-
assert(!isempty(select(${listvar}, { id: ${
|
|
288
|
+
assert(!isempty(select(${listvar}, { id: ${validRef}_data.id })))
|
|
240
289
|
`)
|
|
241
290
|
}
|
|
242
|
-
else if ('ItemNotExists' === validator.apply) {
|
|
291
|
+
else if ('ItemNotExists' === validator.apply && hasRefData) {
|
|
243
292
|
Content(`
|
|
244
|
-
assert(isempty(select(${listvar}, { id: ${
|
|
293
|
+
assert(isempty(select(${listvar}, { id: ${validRef}_data.id })))
|
|
245
294
|
`)
|
|
246
295
|
}
|
|
247
296
|
}
|
|
@@ -253,7 +302,7 @@ const generateUpdate: OpGen = (
|
|
|
253
302
|
entity: ModelEntity,
|
|
254
303
|
flow: ModelEntityFlow,
|
|
255
304
|
step: ModelEntityFlowStep,
|
|
256
|
-
index:
|
|
305
|
+
index: any
|
|
257
306
|
) => {
|
|
258
307
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
259
308
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
@@ -262,9 +311,18 @@ const generateUpdate: OpGen = (
|
|
|
262
311
|
const markdefvar = step.input.markdefvar ?? (ref + '_markdef' + (step.input.suffix ?? ''))
|
|
263
312
|
const srcdatavar = step.input.srcdatavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
264
313
|
|
|
314
|
+
const priorSteps = Object.values(flow.step).slice(0, Number(index))
|
|
315
|
+
const needsEnt = !priorSteps.some((s: any) =>
|
|
316
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.op))
|
|
317
|
+
|
|
265
318
|
Content(`
|
|
266
319
|
// UPDATE
|
|
267
|
-
|
|
320
|
+
`)
|
|
321
|
+
if (needsEnt) {
|
|
322
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
323
|
+
`)
|
|
324
|
+
}
|
|
325
|
+
Content(` const ${datavar} = {}
|
|
268
326
|
${datavar}.id = ${srcdatavar}.id
|
|
269
327
|
`)
|
|
270
328
|
|
|
@@ -295,7 +353,7 @@ const generateUpdate: OpGen = (
|
|
|
295
353
|
|
|
296
354
|
for (let sI = 0; sI < step.spec.length; sI++) {
|
|
297
355
|
const spec = step.spec[sI]
|
|
298
|
-
if ('TextFieldMark' === spec.apply) {
|
|
356
|
+
if ('TextFieldMark' === spec.apply && null != step.input.textfield) {
|
|
299
357
|
Content(`
|
|
300
358
|
assert(${resdatavar}[${markdefvar}.name] === ${markdefvar}.value)
|
|
301
359
|
`)
|
|
@@ -310,7 +368,7 @@ const generateLoad: OpGen = (
|
|
|
310
368
|
entity: ModelEntity,
|
|
311
369
|
flow: ModelEntityFlow,
|
|
312
370
|
step: ModelEntityFlowStep,
|
|
313
|
-
index:
|
|
371
|
+
index: any
|
|
314
372
|
) => {
|
|
315
373
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
316
374
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
@@ -318,9 +376,36 @@ const generateLoad: OpGen = (
|
|
|
318
376
|
const datavar = step.input.datavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
319
377
|
const srcdatavar = step.input.srcdatavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
320
378
|
|
|
379
|
+
const priorSteps = Object.values(flow.step).slice(0, Number(index))
|
|
380
|
+
const hasEntVar = priorSteps.some((s: any) =>
|
|
381
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.op))
|
|
382
|
+
|
|
383
|
+
// Check if srcdatavar was declared by a prior create step or by the
|
|
384
|
+
// preamble bootstrap (which runs when the flow has no create step)
|
|
385
|
+
const flowHasCreate = Object.values(flow.step).some((s: any) => s.op === 'create')
|
|
386
|
+
const preambleRef = entity.name + '_ref01'
|
|
387
|
+
const hasSrcData = (!flowHasCreate && srcdatavar === preambleRef + '_data') ||
|
|
388
|
+
priorSteps.some((s: any) => {
|
|
389
|
+
if ('create' === s.op) {
|
|
390
|
+
const priorRef = s.input?.ref ?? entity.name + '_ref01'
|
|
391
|
+
const priorDatvar = s.input?.datavar ?? (priorRef + '_data' + (s.input?.suffix ?? ''))
|
|
392
|
+
return priorDatvar === srcdatavar
|
|
393
|
+
}
|
|
394
|
+
return false
|
|
395
|
+
})
|
|
396
|
+
|
|
321
397
|
Content(`
|
|
322
398
|
// LOAD
|
|
323
|
-
|
|
399
|
+
`)
|
|
400
|
+
if (!hasEntVar) {
|
|
401
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
402
|
+
`)
|
|
403
|
+
}
|
|
404
|
+
if (!hasSrcData) {
|
|
405
|
+
Content(` const ${srcdatavar} = Object.values(setup.data.existing.${entity.name})[0]
|
|
406
|
+
`)
|
|
407
|
+
}
|
|
408
|
+
Content(` const ${matchvar} = {}
|
|
324
409
|
${matchvar}.id = ${srcdatavar}.id
|
|
325
410
|
const ${datavar} = await ${entvar}.load(${matchvar})
|
|
326
411
|
assert(${datavar}.id === ${srcdatavar}.id)
|
|
@@ -333,16 +418,25 @@ const generateRemove: OpGen = (
|
|
|
333
418
|
entity: ModelEntity,
|
|
334
419
|
flow: ModelEntityFlow,
|
|
335
420
|
step: ModelEntityFlowStep,
|
|
336
|
-
index:
|
|
421
|
+
index: any
|
|
337
422
|
) => {
|
|
338
423
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
339
424
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
340
425
|
const matchvar = step.input.matchvar ?? (ref + '_match' + (step.input.suffix ?? ''))
|
|
341
426
|
const srcdatavar = step.input.srcdatavar ?? (ref + '_data')
|
|
342
427
|
|
|
428
|
+
const priorSteps = Object.values(flow.step).slice(0, Number(index))
|
|
429
|
+
const needsEnt = !priorSteps.some((s: any) =>
|
|
430
|
+
['create', 'list', 'load', 'update', 'remove'].includes(s.op))
|
|
431
|
+
|
|
343
432
|
Content(`
|
|
344
433
|
// REMOVE
|
|
345
|
-
|
|
434
|
+
`)
|
|
435
|
+
if (needsEnt) {
|
|
436
|
+
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
437
|
+
`)
|
|
438
|
+
}
|
|
439
|
+
Content(` const ${matchvar} = {}
|
|
346
440
|
${matchvar}.id = ${srcdatavar}.id
|
|
347
441
|
await ${entvar}.remove(${matchvar})
|
|
348
442
|
`)
|
|
@@ -1,106 +1,22 @@
|
|
|
1
1
|
|
|
2
2
|
const { inspect } = require('node:util')
|
|
3
3
|
|
|
4
|
-
const {
|
|
5
|
-
SdkNameSDK,
|
|
6
|
-
SdkNameEntity,
|
|
7
|
-
} = require('../SdkNameSDK')
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
Utility
|
|
11
|
-
} = require('../utility/Utility')
|
|
4
|
+
const { ProjectNameEntityBase } = require('../ProjectNameEntityBase')
|
|
12
5
|
|
|
13
6
|
|
|
14
7
|
// TODO: needs Entity superclass
|
|
15
|
-
class EntityNameEntity {
|
|
16
|
-
name = 'entityname'
|
|
17
|
-
|
|
18
|
-
#client
|
|
19
|
-
#utility
|
|
20
|
-
#entopts
|
|
21
|
-
#data
|
|
22
|
-
#match
|
|
23
|
-
|
|
24
|
-
_entctx
|
|
8
|
+
class EntityNameEntity extends ProjectNameEntityBase {
|
|
25
9
|
|
|
26
10
|
constructor(client, entopts) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.#client = client
|
|
32
|
-
this.#entopts = entopts
|
|
33
|
-
this.#utility = client.utility()
|
|
34
|
-
this.#data = {}
|
|
35
|
-
this.#match = {}
|
|
36
|
-
|
|
37
|
-
const makeContext = this.#utility.makeContext
|
|
38
|
-
|
|
39
|
-
this._entctx = makeContext({
|
|
40
|
-
entity: this,
|
|
41
|
-
entopts,
|
|
42
|
-
}, client._rootctx)
|
|
43
|
-
|
|
44
|
-
const featureHook = this.#utility.featureHook
|
|
45
|
-
featureHook(this._entctx, 'PostConstructEntity')
|
|
11
|
+
super(client, entopts)
|
|
12
|
+
this.name = 'entityname'
|
|
13
|
+
this.name_ = 'entityname'
|
|
14
|
+
this.Name = 'EntityName'
|
|
46
15
|
}
|
|
47
16
|
|
|
48
|
-
entopts() {
|
|
49
|
-
return { ...this.#entopts }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
client() {
|
|
53
|
-
return this.#client
|
|
54
|
-
}
|
|
55
17
|
|
|
56
18
|
make() {
|
|
57
|
-
return new EntityNameEntity(this
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
data(data) {
|
|
62
|
-
const struct = this.#utility.struct
|
|
63
|
-
const featureHook = this.#utility.featureHook
|
|
64
|
-
|
|
65
|
-
if (null != data) {
|
|
66
|
-
this.#data = struct.clone(data)
|
|
67
|
-
featureHook(this._entctx, 'SetData')
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
featureHook(this._entctx, 'GetData')
|
|
71
|
-
let out = struct.clone(this.#data)
|
|
72
|
-
|
|
73
|
-
return out
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
match(match) {
|
|
78
|
-
const struct = this.#utility.struct
|
|
79
|
-
const featureHook = this.#utility.featureHook
|
|
80
|
-
|
|
81
|
-
if (null != match) {
|
|
82
|
-
this.#match = struct.clone(match)
|
|
83
|
-
featureHook(this._entctx, 'SetMatch')
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
featureHook(this._entctx, 'GetMatch')
|
|
87
|
-
let out = struct.clone(this.#match)
|
|
88
|
-
|
|
89
|
-
return out
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
toJSON() {
|
|
94
|
-
const struct = this.#utility.struct
|
|
95
|
-
return struct.merge([{}, struct.getdef(this.#data, {}), { $entity: 'EntityName' }])
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
toString() {
|
|
99
|
-
return 'EntityName ' + this.#utility.struct.jsonify(this.#data)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
[inspect.custom]() {
|
|
103
|
-
return this.toString()
|
|
19
|
+
return new EntityNameEntity(this._client, this.entopts())
|
|
104
20
|
}
|
|
105
21
|
|
|
106
22
|
|
|
@@ -114,54 +30,6 @@ class EntityNameEntity {
|
|
|
114
30
|
|
|
115
31
|
// #RemoveOp
|
|
116
32
|
|
|
117
|
-
|
|
118
|
-
#unexpected(ctx, err) {
|
|
119
|
-
const clean = this.#utility.clean
|
|
120
|
-
const struct = this.#utility.struct
|
|
121
|
-
|
|
122
|
-
const delprop = struct.delprop
|
|
123
|
-
const clone = struct.clone
|
|
124
|
-
const merge = struct.merge
|
|
125
|
-
|
|
126
|
-
const ctrl = ctx.ctrl
|
|
127
|
-
|
|
128
|
-
ctrl.err = err
|
|
129
|
-
|
|
130
|
-
if (ctrl.explain) {
|
|
131
|
-
ctx.ctrl.explain = clean(ctx, ctx.ctrl.explain)
|
|
132
|
-
delprop(ctx.ctrl.explain.result, 'err')
|
|
133
|
-
|
|
134
|
-
if (null != ctx.result && null != ctx.result.err) {
|
|
135
|
-
ctrl.explain.err = clean(ctx, merge([
|
|
136
|
-
clone({ err: ctx.result.err }).err,
|
|
137
|
-
{
|
|
138
|
-
message: ctx.result.err.message,
|
|
139
|
-
stack: ctx.result.err.stack,
|
|
140
|
-
}]))
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const cleanerr = clean(ctx, merge([
|
|
144
|
-
clone({ err }).err,
|
|
145
|
-
{
|
|
146
|
-
message: err.message,
|
|
147
|
-
stack: err.stack,
|
|
148
|
-
}]))
|
|
149
|
-
|
|
150
|
-
if (null == ctrl.explain.err) {
|
|
151
|
-
ctrl.explain.err = cleanerr
|
|
152
|
-
}
|
|
153
|
-
else if (ctrl.explain.err.message != cleanerr.message) {
|
|
154
|
-
ctrl.explain.unexpected = cleanerr
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (false === ctrl.throw) {
|
|
159
|
-
return undefined
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return err
|
|
163
|
-
}
|
|
164
|
-
|
|
165
33
|
}
|
|
166
34
|
|
|
167
35
|
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
|
|
2
|
+
const { inspect } = require('node:util')
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// TODO: needs Entity superclass
|
|
6
|
+
class ProjectNameEntityBase {
|
|
7
|
+
name = ''
|
|
8
|
+
name_ = ''
|
|
9
|
+
Name = ''
|
|
10
|
+
|
|
11
|
+
_client
|
|
12
|
+
_utility
|
|
13
|
+
_entopts
|
|
14
|
+
_data
|
|
15
|
+
_match
|
|
16
|
+
_entctx
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
constructor(client, entopts) {
|
|
20
|
+
entopts = entopts || {}
|
|
21
|
+
entopts.active = false !== entopts.active
|
|
22
|
+
|
|
23
|
+
this._client = client
|
|
24
|
+
this._entopts = entopts
|
|
25
|
+
this._utility = client.utility()
|
|
26
|
+
this._data = {}
|
|
27
|
+
this._match = {}
|
|
28
|
+
|
|
29
|
+
const makeContext = this._utility.makeContext
|
|
30
|
+
|
|
31
|
+
this._entctx = makeContext({
|
|
32
|
+
entity: this,
|
|
33
|
+
entopts,
|
|
34
|
+
}, client._rootctx)
|
|
35
|
+
|
|
36
|
+
const featureHook = this._utility.featureHook
|
|
37
|
+
featureHook(this._entctx, 'PostConstructEntity')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
entopts() {
|
|
41
|
+
return this._utility.struct.merge([{}, this._entopts])
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
client() {
|
|
45
|
+
return this._client
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
data(data) {
|
|
50
|
+
const struct = this._utility.struct
|
|
51
|
+
const featureHook = this._utility.featureHook
|
|
52
|
+
|
|
53
|
+
if (null != data) {
|
|
54
|
+
this._data = struct.clone(data)
|
|
55
|
+
featureHook(this._entctx, 'SetData')
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
featureHook(this._entctx, 'GetData')
|
|
59
|
+
let out = struct.clone(this._data)
|
|
60
|
+
|
|
61
|
+
return out
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
match(match) {
|
|
66
|
+
const struct = this._utility.struct
|
|
67
|
+
const featureHook = this._utility.featureHook
|
|
68
|
+
|
|
69
|
+
if (null != match) {
|
|
70
|
+
this._match = struct.clone(match)
|
|
71
|
+
featureHook(this._entctx, 'SetMatch')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
featureHook(this._entctx, 'GetMatch')
|
|
75
|
+
let out = struct.clone(this._match)
|
|
76
|
+
|
|
77
|
+
return out
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
toJSON() {
|
|
82
|
+
const struct = this._utility.struct
|
|
83
|
+
return struct.merge([{}, struct.getdef(this._data, {}), { entity$: this.Name }])
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
toString() {
|
|
88
|
+
return this.Name + ' ' + this._utility.struct.jsonify(this._data)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
[inspect.custom]() {
|
|
93
|
+
return this.toString()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
_unexpected(ctx, err) {
|
|
98
|
+
const clean = this._utility.clean
|
|
99
|
+
const struct = this._utility.struct
|
|
100
|
+
|
|
101
|
+
const delprop = struct.delprop
|
|
102
|
+
const clone = struct.clone
|
|
103
|
+
const merge = struct.merge
|
|
104
|
+
|
|
105
|
+
const ctrl = ctx.ctrl
|
|
106
|
+
|
|
107
|
+
ctrl.err = err
|
|
108
|
+
|
|
109
|
+
if (ctrl.explain) {
|
|
110
|
+
ctx.ctrl.explain = clean(ctx, ctx.ctrl.explain)
|
|
111
|
+
delprop(ctx.ctrl.explain.result, 'err')
|
|
112
|
+
|
|
113
|
+
if (null != ctx.result && null != ctx.result.err) {
|
|
114
|
+
ctrl.explain.err = clean(ctx, merge([
|
|
115
|
+
clone({ err: ctx.result.err }).err,
|
|
116
|
+
{
|
|
117
|
+
message: ctx.result.err.message,
|
|
118
|
+
stack: ctx.result.err.stack,
|
|
119
|
+
}]))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const cleanerr = clean(ctx, merge([
|
|
123
|
+
clone({ err }).err,
|
|
124
|
+
{
|
|
125
|
+
message: err.message,
|
|
126
|
+
stack: err.stack,
|
|
127
|
+
}]))
|
|
128
|
+
|
|
129
|
+
if (null == ctrl.explain.err) {
|
|
130
|
+
ctrl.explain.err = cleanerr
|
|
131
|
+
}
|
|
132
|
+
else if (ctrl.explain.err.message != cleanerr.message) {
|
|
133
|
+
ctrl.explain.unexpected = cleanerr
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (false === ctrl.throw) {
|
|
138
|
+
return undefined
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return err
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
module.exports = {
|
|
148
|
+
ProjectNameEntityBase
|
|
149
|
+
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
class EntityOperation {
|
|
3
3
|
|
|
4
|
-
#match
|
|
5
|
-
#data
|
|
6
|
-
#utility
|
|
7
|
-
|
|
8
4
|
|
|
9
5
|
// EJECT-START
|
|
10
6
|
|
|
11
7
|
async create(reqdata, ctrl) {
|
|
12
8
|
|
|
13
|
-
const utility = this
|
|
9
|
+
const utility = this._utility
|
|
14
10
|
const {
|
|
15
11
|
makeContext,
|
|
16
12
|
done,
|
|
@@ -28,8 +24,8 @@ class EntityOperation {
|
|
|
28
24
|
let ctx = makeContext({
|
|
29
25
|
opname: 'create',
|
|
30
26
|
ctrl,
|
|
31
|
-
match: this
|
|
32
|
-
data: this
|
|
27
|
+
match: this._match,
|
|
28
|
+
data: this._data,
|
|
33
29
|
reqdata
|
|
34
30
|
}, this._entctx)
|
|
35
31
|
|
|
@@ -78,7 +74,7 @@ class EntityOperation {
|
|
|
78
74
|
|
|
79
75
|
if (null != ctx.result) {
|
|
80
76
|
if (null != ctx.result.resdata) {
|
|
81
|
-
this
|
|
77
|
+
this._data = ctx.result.resdata
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
80
|
|
|
@@ -87,7 +83,7 @@ class EntityOperation {
|
|
|
87
83
|
catch (err) {
|
|
88
84
|
// #PreUnexpected-Hook
|
|
89
85
|
|
|
90
|
-
err = this
|
|
86
|
+
err = this._unexpected(ctx, err)
|
|
91
87
|
|
|
92
88
|
if (err) {
|
|
93
89
|
throw err
|
|
@@ -101,5 +97,5 @@ class EntityOperation {
|
|
|
101
97
|
// EJECT-END
|
|
102
98
|
|
|
103
99
|
|
|
104
|
-
|
|
100
|
+
_unexpected(ctx, err) { return err }
|
|
105
101
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
class EntityOperation {
|
|
3
3
|
|
|
4
|
-
#match
|
|
5
|
-
#data
|
|
6
|
-
#utility
|
|
7
|
-
|
|
8
4
|
|
|
9
5
|
// EJECT-START
|
|
10
6
|
|
|
11
7
|
async list(reqmatch, ctrl) {
|
|
12
8
|
|
|
13
|
-
const utility = this
|
|
9
|
+
const utility = this._utility
|
|
14
10
|
|
|
15
11
|
const {
|
|
16
12
|
makeContext,
|
|
@@ -29,8 +25,8 @@ class EntityOperation {
|
|
|
29
25
|
let ctx = makeContext({
|
|
30
26
|
opname: 'list',
|
|
31
27
|
ctrl,
|
|
32
|
-
match: this
|
|
33
|
-
data: this
|
|
28
|
+
match: this._match,
|
|
29
|
+
data: this._data,
|
|
34
30
|
reqmatch
|
|
35
31
|
}, this._entctx)
|
|
36
32
|
|
|
@@ -79,7 +75,7 @@ class EntityOperation {
|
|
|
79
75
|
|
|
80
76
|
if (null != ctx.result) {
|
|
81
77
|
if (null != ctx.result.resmatch) {
|
|
82
|
-
this
|
|
78
|
+
this._match = ctx.result.resmatch
|
|
83
79
|
}
|
|
84
80
|
}
|
|
85
81
|
|
|
@@ -88,7 +84,7 @@ class EntityOperation {
|
|
|
88
84
|
catch (err) {
|
|
89
85
|
// #PreUnexpected-Hook
|
|
90
86
|
|
|
91
|
-
err = this
|
|
87
|
+
err = this._unexpected(ctx, err)
|
|
92
88
|
|
|
93
89
|
if (err) {
|
|
94
90
|
throw err
|
|
@@ -102,7 +98,7 @@ class EntityOperation {
|
|
|
102
98
|
// EJECT-END
|
|
103
99
|
|
|
104
100
|
|
|
105
|
-
|
|
101
|
+
_unexpected(_ctx, err) { return err }
|
|
106
102
|
|
|
107
103
|
}
|
|
108
104
|
|