@voxgig/sdkgen 0.44.0 → 0.45.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/ReadmeEntity.js +9 -153
- package/dist/cmp/ReadmeEntity.js.map +1 -1
- package/dist/cmp/ReadmeIntro.js +9 -14
- package/dist/cmp/ReadmeIntro.js.map +1 -1
- package/dist/cmp/ReadmeModel.js +6 -4
- package/dist/cmp/ReadmeModel.js.map +1 -1
- package/dist/cmp/ReadmeOptions.js +9 -61
- package/dist/cmp/ReadmeOptions.js.map +1 -1
- package/dist/cmp/ReadmeRef.js +10 -1328
- package/dist/cmp/ReadmeRef.js.map +1 -1
- package/dist/sdkgen.d.ts +2 -2
- package/dist/sdkgen.js +2 -1
- package/dist/sdkgen.js.map +1 -1
- package/dist/utility.d.ts +2 -1
- package/dist/utility.js +9 -0
- package/dist/utility.js.map +1 -1
- package/package.json +1 -1
- package/project/.sdk/src/cmp/go/Config_go.ts +9 -4
- package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +138 -0
- package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +6 -3
- package/project/.sdk/src/cmp/go/ReadmeIntro_go.ts +18 -0
- package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +6 -3
- package/project/.sdk/src/cmp/go/ReadmeOptions_go.ts +58 -0
- package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +11 -7
- package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +354 -0
- package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +6 -4
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +18 -8
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +105 -54
- package/project/.sdk/src/cmp/js/Config_js.ts +18 -0
- package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +138 -0
- package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +11 -6
- package/project/.sdk/src/cmp/js/ReadmeIntro_js.ts +18 -0
- package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +6 -3
- package/project/.sdk/src/cmp/js/ReadmeOptions_js.ts +58 -0
- package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +6 -4
- package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +384 -0
- package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +6 -4
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +23 -12
- package/project/.sdk/src/cmp/js/TestEntity_js.ts +107 -74
- package/project/.sdk/src/cmp/js/fragment/Config.fragment.js +1 -5
- package/project/.sdk/src/cmp/lua/Config_lua.ts +9 -4
- package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +138 -0
- package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +6 -3
- package/project/.sdk/src/cmp/lua/ReadmeIntro_lua.ts +18 -0
- package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +6 -3
- package/project/.sdk/src/cmp/lua/ReadmeOptions_lua.ts +58 -0
- package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +6 -4
- package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +360 -0
- package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +6 -4
- package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +18 -8
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +95 -51
- package/project/.sdk/src/cmp/php/Config_php.ts +10 -8
- package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +138 -0
- package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +6 -3
- package/project/.sdk/src/cmp/php/ReadmeIntro_php.ts +18 -0
- package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +6 -3
- package/project/.sdk/src/cmp/php/ReadmeOptions_php.ts +58 -0
- package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +6 -4
- package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +358 -0
- package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +6 -4
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +18 -8
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +101 -54
- package/project/.sdk/src/cmp/py/Config_py.ts +9 -4
- package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +138 -0
- package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +6 -3
- package/project/.sdk/src/cmp/py/ReadmeIntro_py.ts +18 -0
- package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +6 -3
- package/project/.sdk/src/cmp/py/ReadmeOptions_py.ts +58 -0
- package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +9 -6
- package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +356 -0
- package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +9 -6
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +18 -8
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +100 -50
- package/project/.sdk/src/cmp/rb/Config_rb.ts +9 -4
- package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +138 -0
- package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +6 -3
- package/project/.sdk/src/cmp/rb/ReadmeIntro_rb.ts +18 -0
- package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +6 -3
- package/project/.sdk/src/cmp/rb/ReadmeOptions_rb.ts +58 -0
- package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +6 -4
- package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +361 -0
- package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +6 -4
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +18 -8
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +95 -51
- package/project/.sdk/src/cmp/ts/Config_ts.ts +18 -0
- package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +138 -0
- package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +11 -6
- package/project/.sdk/src/cmp/ts/ReadmeIntro_ts.ts +18 -0
- package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +9 -5
- package/project/.sdk/src/cmp/ts/ReadmeOptions_ts.ts +58 -0
- package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +6 -4
- package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +384 -0
- package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +6 -4
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +68 -20
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +109 -74
- package/project/.sdk/src/cmp/ts/fragment/Config.fragment.ts +1 -5
- package/project/.sdk/tm/go/utility/prepare_auth.go +15 -1
- package/project/.sdk/tm/js/src/utility/PrepareAuthUtility.js +7 -1
- package/project/.sdk/tm/lua/utility/prepare_auth.lua +9 -1
- package/project/.sdk/tm/php/utility/PrepareAuth.php +11 -1
- package/project/.sdk/tm/py/utility/prepare_auth.py +10 -1
- package/project/.sdk/tm/rb/utility/prepare_auth.rb +8 -1
- package/project/.sdk/tm/ts/src/utility/MakeUrlUtility.ts +7 -8
- package/project/.sdk/tm/ts/src/utility/PrepareAuthUtility.ts +7 -1
- package/src/cmp/ReadmeEntity.ts +11 -178
- package/src/cmp/ReadmeIntro.ts +11 -25
- package/src/cmp/ReadmeModel.ts +7 -5
- package/src/cmp/ReadmeOptions.ts +12 -74
- package/src/cmp/ReadmeRef.ts +11 -1372
- package/src/sdkgen.ts +2 -1
- package/src/utility.ts +12 -0
- /package/project/.sdk/tm/go/utility/{make_target.go → make_point.go} +0 -0
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
Slot,
|
|
30
30
|
cmp,
|
|
31
31
|
each,
|
|
32
|
+
isAuthActive,
|
|
32
33
|
} from '@voxgig/sdkgen'
|
|
33
34
|
|
|
34
35
|
|
|
@@ -37,19 +38,38 @@ import {
|
|
|
37
38
|
} from './utility_ts'
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
// GenCtx is the per-language generation context passed to every OpGen.
|
|
42
|
+
// Languages with extra needs (Go's `gomodule`, PHP's `accessor`) extend
|
|
43
|
+
// this shape locally. The signature `(ctx, step, index)` is now uniform
|
|
44
|
+
// across all seven language tracks (Phase 1 of the templates refactor).
|
|
45
|
+
type GenCtx = {
|
|
46
|
+
model: Model
|
|
47
|
+
entity: ModelEntity
|
|
48
|
+
flow: ModelEntityFlow
|
|
49
|
+
PROJUPPER: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type OpGen = (ctx: GenCtx, step: ModelEntityFlowStep, index: number) => void
|
|
41
53
|
|
|
42
54
|
|
|
43
55
|
const TestEntity = cmp(function TestEntity(props: any) {
|
|
44
56
|
const ctx$ = props.ctx$
|
|
45
|
-
const model = ctx$.model
|
|
57
|
+
const model: Model = ctx$.model
|
|
46
58
|
const stdrep = ctx$.stdrep
|
|
47
59
|
|
|
48
60
|
const target = props.target
|
|
49
|
-
const entity = props.entity
|
|
61
|
+
const entity: ModelEntity = props.entity
|
|
50
62
|
|
|
51
63
|
const PROJENVNAME = nom(model.const, 'NAME').replace(/[^A-Z_]/g, '_')
|
|
52
64
|
const ENTENVNAME = nom(entity, 'NAME').replace(/[^A-Z_]/g, '_')
|
|
65
|
+
const authActive = isAuthActive(model)
|
|
66
|
+
const apikeyEnvEntry = authActive
|
|
67
|
+
? `\n '${PROJENVNAME}_APIKEY': 'NONE',`
|
|
68
|
+
: ''
|
|
69
|
+
const apikeyLiveField = authActive
|
|
70
|
+
? `
|
|
71
|
+
apikey: env.${PROJENVNAME}_APIKEY,`
|
|
72
|
+
: ''
|
|
53
73
|
|
|
54
74
|
// TODO: should be a utility function
|
|
55
75
|
const ff = projectPath('src/cmp/ts/fragment/')
|
|
@@ -67,7 +87,7 @@ const TestEntity = cmp(function TestEntity(props: any) {
|
|
|
67
87
|
}
|
|
68
88
|
}, () => {
|
|
69
89
|
|
|
70
|
-
const basicflow = getModelPath(model, `main.${KIT}.flow.Basic${entity
|
|
90
|
+
const basicflow = getModelPath(model, `main.${KIT}.flow.Basic${nom(entity, 'Name')}Flow`)
|
|
71
91
|
|
|
72
92
|
const dobasic = basicflow && true === basicflow.active
|
|
73
93
|
|
|
@@ -123,16 +143,14 @@ function basicSetup(extra?: any) {
|
|
|
123
143
|
const env = envOverride({
|
|
124
144
|
'${PROJENVNAME}_TEST_${ENTENVNAME}_ENTID': idmap,
|
|
125
145
|
'${PROJENVNAME}_TEST_LIVE': 'FALSE',
|
|
126
|
-
'${PROJENVNAME}_TEST_EXPLAIN': 'FALSE'
|
|
127
|
-
'${PROJENVNAME}_APIKEY': 'NONE',
|
|
146
|
+
'${PROJENVNAME}_TEST_EXPLAIN': 'FALSE',${apikeyEnvEntry}
|
|
128
147
|
})
|
|
129
148
|
|
|
130
149
|
idmap = env['${PROJENVNAME}_TEST_${ENTENVNAME}_ENTID']
|
|
131
150
|
|
|
132
151
|
if ('TRUE' === env.${PROJENVNAME}_TEST_LIVE) {
|
|
133
152
|
client = new ${model.Name}SDK(merge([
|
|
134
|
-
{
|
|
135
|
-
apikey: env.${PROJENVNAME}_APIKEY,
|
|
153
|
+
{${apikeyLiveField}
|
|
136
154
|
},
|
|
137
155
|
extra
|
|
138
156
|
]))
|
|
@@ -179,10 +197,15 @@ function basicSetup(extra?: any) {
|
|
|
179
197
|
`)
|
|
180
198
|
}
|
|
181
199
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
200
|
+
const genCtx: GenCtx = {
|
|
201
|
+
model, entity, flow: basicflow, PROJUPPER: PROJENVNAME,
|
|
202
|
+
}
|
|
203
|
+
each(basicflow.step, (step: ModelEntityFlowStep, index: number) => {
|
|
204
|
+
const opgen = GENERATE_OP[step.op]
|
|
205
|
+
if (null != opgen) {
|
|
206
|
+
opgen(genCtx, step, index)
|
|
207
|
+
Content('\n')
|
|
208
|
+
}
|
|
186
209
|
})
|
|
187
210
|
})
|
|
188
211
|
})
|
|
@@ -191,25 +214,20 @@ function basicSetup(extra?: any) {
|
|
|
191
214
|
})
|
|
192
215
|
|
|
193
216
|
|
|
194
|
-
const generateCreate: OpGen = (
|
|
195
|
-
|
|
196
|
-
entity: ModelEntity,
|
|
197
|
-
flow: ModelEntityFlow,
|
|
198
|
-
step: ModelEntityFlowStep,
|
|
199
|
-
index: any
|
|
200
|
-
) => {
|
|
217
|
+
const generateCreate: OpGen = (ctx, step, index) => {
|
|
218
|
+
const { entity, flow } = ctx
|
|
201
219
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
202
220
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
203
221
|
const datavar = step.input.datavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
204
222
|
|
|
205
|
-
const priorSteps =
|
|
206
|
-
const needsEnt = !priorSteps.some(
|
|
223
|
+
const priorSteps = flow.step.slice(0, Number(index))
|
|
224
|
+
const needsEnt = !priorSteps.some(s =>
|
|
207
225
|
['create', 'list', 'load', 'update', 'remove'].includes(s.op))
|
|
208
226
|
|
|
209
|
-
const hasDatvar = priorSteps.some(
|
|
227
|
+
const hasDatvar = priorSteps.some(s => {
|
|
210
228
|
if ('create' === s.op) {
|
|
211
|
-
const priorRef = s.input
|
|
212
|
-
const priorDatvar = s.input
|
|
229
|
+
const priorRef = s.input.ref ?? entity.name + '_ref01'
|
|
230
|
+
const priorDatvar = s.input.datavar ?? (priorRef + '_data' + (s.input.suffix ?? ''))
|
|
213
231
|
return priorDatvar === datavar
|
|
214
232
|
}
|
|
215
233
|
return false
|
|
@@ -235,27 +253,31 @@ const generateCreate: OpGen = (
|
|
|
235
253
|
`)
|
|
236
254
|
})
|
|
237
255
|
|
|
256
|
+
const hasEntIdC = null != entity.id
|
|
257
|
+
|
|
238
258
|
Content(`
|
|
239
259
|
${datavar} = await ${entvar}.create(${datavar})
|
|
240
|
-
assert(null != ${datavar}.id)
|
|
241
260
|
`)
|
|
261
|
+
if (hasEntIdC) {
|
|
262
|
+
Content(` assert(null != ${datavar}.id)
|
|
263
|
+
`)
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
Content(` assert(null != ${datavar})
|
|
267
|
+
`)
|
|
268
|
+
}
|
|
242
269
|
}
|
|
243
270
|
|
|
244
271
|
|
|
245
|
-
const generateList: OpGen = (
|
|
246
|
-
|
|
247
|
-
entity: ModelEntity,
|
|
248
|
-
flow: ModelEntityFlow,
|
|
249
|
-
step: ModelEntityFlowStep,
|
|
250
|
-
index: any
|
|
251
|
-
) => {
|
|
272
|
+
const generateList: OpGen = (ctx, step, index) => {
|
|
273
|
+
const { entity, flow } = ctx
|
|
252
274
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
253
275
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
254
276
|
const matchvar = step.input.matchvar ?? (ref + '_match' + (step.input.suffix ?? ''))
|
|
255
277
|
const listvar = step.input.listvar ?? (ref + '_list' + (step.input.suffix ?? ''))
|
|
256
278
|
|
|
257
|
-
const priorSteps =
|
|
258
|
-
const needsEnt = !priorSteps.some(
|
|
279
|
+
const priorSteps = flow.step.slice(0, Number(index))
|
|
280
|
+
const needsEnt = !priorSteps.some(s =>
|
|
259
281
|
['create', 'list', 'load', 'update', 'remove'].includes(s.op))
|
|
260
282
|
|
|
261
283
|
Content(`
|
|
@@ -276,12 +298,12 @@ const generateList: OpGen = (
|
|
|
276
298
|
Content(`
|
|
277
299
|
const ${listvar} = await ${entvar}.list(${matchvar})
|
|
278
300
|
`)
|
|
279
|
-
const allSteps =
|
|
301
|
+
const allSteps = flow.step
|
|
280
302
|
for (let vI = 0; vI < step.valid.length; vI++) {
|
|
281
303
|
const validator = step.valid[vI]
|
|
282
304
|
const validRef = validator.def?.ref
|
|
283
|
-
const hasRefData = validRef && allSteps.some(
|
|
284
|
-
((s.input
|
|
305
|
+
const hasRefData = validRef && allSteps.some(s => 'create' === s.op &&
|
|
306
|
+
((s.input.ref ?? entity.name + '_ref01') === validRef))
|
|
285
307
|
|
|
286
308
|
if ('ItemExists' === validator.apply && hasRefData) {
|
|
287
309
|
Content(`
|
|
@@ -297,13 +319,8 @@ const generateList: OpGen = (
|
|
|
297
319
|
}
|
|
298
320
|
|
|
299
321
|
|
|
300
|
-
const generateUpdate: OpGen = (
|
|
301
|
-
|
|
302
|
-
entity: ModelEntity,
|
|
303
|
-
flow: ModelEntityFlow,
|
|
304
|
-
step: ModelEntityFlowStep,
|
|
305
|
-
index: any
|
|
306
|
-
) => {
|
|
322
|
+
const generateUpdate: OpGen = (ctx, step, index) => {
|
|
323
|
+
const { entity, flow } = ctx
|
|
307
324
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
308
325
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
309
326
|
const datavar = step.input.datavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
@@ -311,10 +328,12 @@ const generateUpdate: OpGen = (
|
|
|
311
328
|
const markdefvar = step.input.markdefvar ?? (ref + '_markdef' + (step.input.suffix ?? ''))
|
|
312
329
|
const srcdatavar = step.input.srcdatavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
313
330
|
|
|
314
|
-
const priorSteps =
|
|
315
|
-
const needsEnt = !priorSteps.some(
|
|
331
|
+
const priorSteps = flow.step.slice(0, Number(index))
|
|
332
|
+
const needsEnt = !priorSteps.some(s =>
|
|
316
333
|
['create', 'list', 'load', 'update', 'remove'].includes(s.op))
|
|
317
334
|
|
|
335
|
+
const hasEntIdU = null != entity.id
|
|
336
|
+
|
|
318
337
|
Content(`
|
|
319
338
|
// UPDATE
|
|
320
339
|
`)
|
|
@@ -323,8 +342,11 @@ const generateUpdate: OpGen = (
|
|
|
323
342
|
`)
|
|
324
343
|
}
|
|
325
344
|
Content(` const ${datavar}: any = {}
|
|
326
|
-
${datavar}.id = ${srcdatavar}.id
|
|
327
345
|
`)
|
|
346
|
+
if (hasEntIdU) {
|
|
347
|
+
Content(` ${datavar}.id = ${srcdatavar}.id
|
|
348
|
+
`)
|
|
349
|
+
}
|
|
328
350
|
|
|
329
351
|
each(step.data, (mi: any) => {
|
|
330
352
|
if ('id' !== mi.key$) {
|
|
@@ -348,8 +370,15 @@ const generateUpdate: OpGen = (
|
|
|
348
370
|
|
|
349
371
|
Content(`
|
|
350
372
|
const ${resdatavar} = await ${entvar}.update(${datavar})
|
|
351
|
-
assert(${resdatavar}.id === ${datavar}.id)
|
|
352
373
|
`)
|
|
374
|
+
if (hasEntIdU) {
|
|
375
|
+
Content(` assert(${resdatavar}.id === ${datavar}.id)
|
|
376
|
+
`)
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
Content(` assert(null != ${resdatavar})
|
|
380
|
+
`)
|
|
381
|
+
}
|
|
353
382
|
|
|
354
383
|
for (let sI = 0; sI < step.spec.length; sI++) {
|
|
355
384
|
const spec = step.spec[sI]
|
|
@@ -363,37 +392,34 @@ const generateUpdate: OpGen = (
|
|
|
363
392
|
}
|
|
364
393
|
|
|
365
394
|
|
|
366
|
-
const generateLoad: OpGen = (
|
|
367
|
-
|
|
368
|
-
entity: ModelEntity,
|
|
369
|
-
flow: ModelEntityFlow,
|
|
370
|
-
step: ModelEntityFlowStep,
|
|
371
|
-
index: any
|
|
372
|
-
) => {
|
|
395
|
+
const generateLoad: OpGen = (ctx, step, index) => {
|
|
396
|
+
const { entity, flow } = ctx
|
|
373
397
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
374
398
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
375
399
|
const matchvar = step.input.matchvar ?? (ref + '_match' + (step.input.suffix ?? ''))
|
|
376
400
|
const datavar = step.input.datavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
377
401
|
const srcdatavar = step.input.srcdatavar ?? (ref + '_data' + (step.input.suffix ?? ''))
|
|
378
402
|
|
|
379
|
-
const priorSteps =
|
|
380
|
-
const hasEntVar = priorSteps.some(
|
|
403
|
+
const priorSteps = flow.step.slice(0, Number(index))
|
|
404
|
+
const hasEntVar = priorSteps.some(s =>
|
|
381
405
|
['create', 'list', 'load', 'update', 'remove'].includes(s.op))
|
|
382
406
|
|
|
383
407
|
// Check if srcdatavar was declared by a prior create step or by the
|
|
384
408
|
// preamble bootstrap (which runs when the flow has no create step)
|
|
385
|
-
const flowHasCreate =
|
|
409
|
+
const flowHasCreate = flow.step.some(s => s.op === 'create')
|
|
386
410
|
const preambleRef = entity.name + '_ref01'
|
|
387
411
|
const hasSrcData = (!flowHasCreate && srcdatavar === preambleRef + '_data') ||
|
|
388
|
-
priorSteps.some(
|
|
412
|
+
priorSteps.some(s => {
|
|
389
413
|
if ('create' === s.op) {
|
|
390
|
-
const priorRef = s.input
|
|
391
|
-
const priorDatvar = s.input
|
|
414
|
+
const priorRef = s.input.ref ?? entity.name + '_ref01'
|
|
415
|
+
const priorDatvar = s.input.datavar ?? (priorRef + '_data' + (s.input.suffix ?? ''))
|
|
392
416
|
return priorDatvar === srcdatavar
|
|
393
417
|
}
|
|
394
418
|
return false
|
|
395
419
|
})
|
|
396
420
|
|
|
421
|
+
const hasEntId = null != entity.id
|
|
422
|
+
|
|
397
423
|
Content(`
|
|
398
424
|
// LOAD
|
|
399
425
|
`)
|
|
@@ -401,34 +427,39 @@ const generateLoad: OpGen = (
|
|
|
401
427
|
Content(` const ${entvar} = client.${nom(entity, 'Name')}()
|
|
402
428
|
`)
|
|
403
429
|
}
|
|
404
|
-
if (!hasSrcData) {
|
|
430
|
+
if (!hasSrcData && hasEntId) {
|
|
405
431
|
Content(` const ${srcdatavar} = Object.values(setup.data.existing.${entity.name})[0] as any
|
|
406
432
|
`)
|
|
407
433
|
}
|
|
408
|
-
|
|
434
|
+
if (hasEntId) {
|
|
435
|
+
Content(` const ${matchvar}: any = {}
|
|
409
436
|
${matchvar}.id = ${srcdatavar}.id
|
|
410
437
|
const ${datavar} = await ${entvar}.load(${matchvar})
|
|
411
438
|
assert(${datavar}.id === ${srcdatavar}.id)
|
|
412
439
|
`)
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
Content(` const ${matchvar}: any = {}
|
|
443
|
+
const ${datavar} = await ${entvar}.load(${matchvar})
|
|
444
|
+
assert(null != ${datavar})
|
|
445
|
+
`)
|
|
446
|
+
}
|
|
413
447
|
}
|
|
414
448
|
|
|
415
449
|
|
|
416
|
-
const generateRemove: OpGen = (
|
|
417
|
-
|
|
418
|
-
entity: ModelEntity,
|
|
419
|
-
flow: ModelEntityFlow,
|
|
420
|
-
step: ModelEntityFlowStep,
|
|
421
|
-
index: any
|
|
422
|
-
) => {
|
|
450
|
+
const generateRemove: OpGen = (ctx, step, index) => {
|
|
451
|
+
const { entity, flow } = ctx
|
|
423
452
|
const ref = step.input.ref ?? entity.name + '_ref01'
|
|
424
453
|
const entvar = step.input.entvar ?? ref + '_ent'
|
|
425
454
|
const matchvar = step.input.matchvar ?? (ref + '_match' + (step.input.suffix ?? ''))
|
|
426
455
|
const srcdatavar = step.input.srcdatavar ?? (ref + '_data')
|
|
427
456
|
|
|
428
|
-
const priorSteps =
|
|
429
|
-
const needsEnt = !priorSteps.some(
|
|
457
|
+
const priorSteps = flow.step.slice(0, Number(index))
|
|
458
|
+
const needsEnt = !priorSteps.some(s =>
|
|
430
459
|
['create', 'list', 'load', 'update', 'remove'].includes(s.op))
|
|
431
460
|
|
|
461
|
+
const hasEntIdR = null != entity.id
|
|
462
|
+
|
|
432
463
|
Content(`
|
|
433
464
|
// REMOVE
|
|
434
465
|
`)
|
|
@@ -437,8 +468,12 @@ const generateRemove: OpGen = (
|
|
|
437
468
|
`)
|
|
438
469
|
}
|
|
439
470
|
Content(` const ${matchvar}: any = {}
|
|
440
|
-
|
|
441
|
-
|
|
471
|
+
`)
|
|
472
|
+
if (hasEntIdR) {
|
|
473
|
+
Content(` ${matchvar}.id = ${srcdatavar}.id
|
|
474
|
+
`)
|
|
475
|
+
}
|
|
476
|
+
Content(` await ${entvar}.remove(${matchvar})
|
|
442
477
|
`)
|
|
443
478
|
}
|
|
444
479
|
|
|
@@ -20,9 +20,23 @@ func prepareAuthUtil(ctx *core.Context) (*core.Spec, error) {
|
|
|
20
20
|
headers := spec.Headers
|
|
21
21
|
options := ctx.Client.OptionsMap()
|
|
22
22
|
|
|
23
|
+
// Public APIs that need no auth omit the options.auth block entirely.
|
|
24
|
+
if options["auth"] == nil {
|
|
25
|
+
delete(headers, headerAuth)
|
|
26
|
+
return spec, nil
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
apikey := vs.GetProp(options, optionApikey, notFound)
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
skip := false
|
|
32
|
+
if apikey == nil {
|
|
33
|
+
skip = true
|
|
34
|
+
} else if apikeyStr, ok := apikey.(string); ok &&
|
|
35
|
+
(apikeyStr == notFound || apikeyStr == "") {
|
|
36
|
+
skip = true
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if skip {
|
|
26
40
|
delete(headers, headerAuth)
|
|
27
41
|
} else {
|
|
28
42
|
authPrefix := ""
|
|
@@ -24,9 +24,15 @@ function prepareAuth(ctx) {
|
|
|
24
24
|
|
|
25
25
|
const options = client.options()
|
|
26
26
|
|
|
27
|
+
// Public APIs that need no auth omit the options.auth block entirely.
|
|
28
|
+
if (null == options.auth) {
|
|
29
|
+
delprop(headers, HEADER_auth)
|
|
30
|
+
return spec
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
const apikey = getprop(options, OPTION_apikey, NOTFOUND)
|
|
28
34
|
|
|
29
|
-
if (NOTFOUND === apikey) {
|
|
35
|
+
if (NOTFOUND === apikey || null == apikey || '' === apikey) {
|
|
30
36
|
delprop(headers, HEADER_auth)
|
|
31
37
|
}
|
|
32
38
|
else {
|
|
@@ -16,9 +16,17 @@ local function prepare_auth_util(ctx)
|
|
|
16
16
|
local headers = spec.headers
|
|
17
17
|
local options = ctx.client:options_map()
|
|
18
18
|
|
|
19
|
+
-- Public APIs that need no auth omit the options.auth block entirely.
|
|
20
|
+
if options.auth == nil then
|
|
21
|
+
headers[HEADER_AUTH] = nil
|
|
22
|
+
return spec, nil
|
|
23
|
+
end
|
|
24
|
+
|
|
19
25
|
local apikey = vs.getprop(options, OPTION_APIKEY, NOT_FOUND)
|
|
20
26
|
|
|
21
|
-
if
|
|
27
|
+
if apikey == nil
|
|
28
|
+
or (type(apikey) == "string" and (apikey == NOT_FOUND or apikey == ""))
|
|
29
|
+
then
|
|
22
30
|
headers[HEADER_AUTH] = nil
|
|
23
31
|
else
|
|
24
32
|
local auth_prefix = ""
|
|
@@ -18,9 +18,19 @@ class ProjectNamePrepareAuth
|
|
|
18
18
|
|
|
19
19
|
$headers = &$spec->headers;
|
|
20
20
|
$options = $ctx->client->options_map();
|
|
21
|
+
|
|
22
|
+
// Public APIs that need no auth omit the options.auth block entirely.
|
|
23
|
+
if (!isset($options['auth']) || $options['auth'] === null) {
|
|
24
|
+
unset($headers[self::HEADER_AUTH]);
|
|
25
|
+
return [$spec, null];
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
$apikey = \Voxgig\Struct\Struct::getprop($options, self::OPTION_APIKEY, self::NOT_FOUND);
|
|
22
29
|
|
|
23
|
-
if (
|
|
30
|
+
if (
|
|
31
|
+
(is_string($apikey) && ($apikey === self::NOT_FOUND || $apikey === ''))
|
|
32
|
+
|| $apikey === null
|
|
33
|
+
) {
|
|
24
34
|
unset($headers[self::HEADER_AUTH]);
|
|
25
35
|
} else {
|
|
26
36
|
$auth_prefix = \Voxgig\Struct\Struct::getpath($options, 'auth.prefix') ?? '';
|
|
@@ -17,9 +17,18 @@ def prepare_auth_util(ctx):
|
|
|
17
17
|
headers = spec.headers
|
|
18
18
|
options = ctx.client.options_map()
|
|
19
19
|
|
|
20
|
+
# Public APIs that need no auth omit the options.auth block entirely.
|
|
21
|
+
if options.get("auth") is None:
|
|
22
|
+
headers.pop(HEADER_AUTH, None)
|
|
23
|
+
return spec, None
|
|
24
|
+
|
|
20
25
|
apikey = vs.getprop(options, OPTION_APIKEY, NOT_FOUND)
|
|
21
26
|
|
|
22
|
-
if
|
|
27
|
+
if (
|
|
28
|
+
(isinstance(apikey, str) and apikey == NOT_FOUND)
|
|
29
|
+
or apikey is None
|
|
30
|
+
or apikey == ""
|
|
31
|
+
):
|
|
23
32
|
headers.pop(HEADER_AUTH, None)
|
|
24
33
|
else:
|
|
25
34
|
auth_prefix = ""
|
|
@@ -11,9 +11,16 @@ module ProjectNameUtilities
|
|
|
11
11
|
|
|
12
12
|
headers = spec.headers
|
|
13
13
|
options = ctx.client.options_map
|
|
14
|
+
|
|
15
|
+
# Public APIs that need no auth omit the options.auth block entirely.
|
|
16
|
+
if options["auth"].nil?
|
|
17
|
+
headers.delete(HEADER_AUTH)
|
|
18
|
+
return spec, nil
|
|
19
|
+
end
|
|
20
|
+
|
|
14
21
|
apikey = VoxgigStruct.getprop(options, OPTION_APIKEY, NOT_FOUND)
|
|
15
22
|
|
|
16
|
-
if apikey.is_a?(String) && apikey == NOT_FOUND
|
|
23
|
+
if apikey.nil? || (apikey.is_a?(String) && (apikey == NOT_FOUND || apikey == ""))
|
|
17
24
|
headers.delete(HEADER_AUTH)
|
|
18
25
|
else
|
|
19
26
|
auth_prefix = VoxgigStruct.getpath(options, "auth.prefix") || ""
|
|
@@ -37,18 +37,17 @@ function makeUrl(ctx: Context): Error | string {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
// Append query string from spec.query. Entity ops populate this via
|
|
41
|
+
// PrepareQueryUtility from the operation's reqmatch; direct() callers
|
|
42
|
+
// pass it as fetchargs.query.
|
|
41
43
|
let qsep = '?'
|
|
42
44
|
for (let [key, val] of items(spec.query)) {
|
|
43
|
-
if (null
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
resmatch[key] = val
|
|
48
|
-
}
|
|
45
|
+
if (null != val) {
|
|
46
|
+
url += qsep + escurl(key) + '=' + escurl(val)
|
|
47
|
+
qsep = '&'
|
|
48
|
+
resmatch[key] = val
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
*/
|
|
52
51
|
|
|
53
52
|
result.resmatch = resmatch
|
|
54
53
|
|
|
@@ -30,9 +30,15 @@ function prepareAuth(ctx: Context): Spec | Error {
|
|
|
30
30
|
|
|
31
31
|
const options = client.options()
|
|
32
32
|
|
|
33
|
+
// Public APIs that need no auth omit the options.auth block entirely.
|
|
34
|
+
if (null == options.auth) {
|
|
35
|
+
delprop(headers, HEADER_auth)
|
|
36
|
+
return spec
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
const apikey = getprop(options, OPTION_apikey, NOTFOUND)
|
|
34
40
|
|
|
35
|
-
if (NOTFOUND === apikey) {
|
|
41
|
+
if (NOTFOUND === apikey || null == apikey || '' === apikey) {
|
|
36
42
|
delprop(headers, HEADER_auth)
|
|
37
43
|
}
|
|
38
44
|
else {
|