@voxgig/sdkgen 4.17.5 → 4.17.6
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
|
@@ -377,16 +377,45 @@ describe('secrets', () => {
|
|
|
377
377
|
// Before any op, nothing has been resolved.
|
|
378
378
|
assert.equal(sdk.options().apikey, '')
|
|
379
379
|
|
|
380
|
-
|
|
381
|
-
|
|
380
|
+
// AN OP THAT EXISTS, not `list` on whichever entity comes first.
|
|
381
|
+
//
|
|
382
|
+
// A generated TS entity carries only the ops its model DECLARES, so
|
|
383
|
+
// `list` is absent from an entity declaring `create` alone — and
|
|
384
|
+
// calling it throws before the PreSpec hook can run, failing the
|
|
385
|
+
// assertion below for a reason that has nothing to do with secrets.
|
|
386
|
+
// univec-sdk hit exactly that: its first entity declares `create`
|
|
387
|
+
// only, so this test failed on every run while PreSpec worked
|
|
388
|
+
// perfectly. Any real op exercises the hook; `list` is not special.
|
|
389
|
+
//
|
|
390
|
+
// This file is a TEMPLATE, so no project's op names are known here
|
|
391
|
+
// either. Discover the first callable one rather than assuming.
|
|
392
|
+
let ran = false
|
|
393
|
+
for (const one of names) {
|
|
394
|
+
const acc = one.charAt(0).toUpperCase() + one.slice(1)
|
|
395
|
+
const ent = (sdk as any)[acc]?.()
|
|
396
|
+
if (null == ent) {
|
|
397
|
+
continue
|
|
398
|
+
}
|
|
399
|
+
const opname = ['list', 'load', 'create']
|
|
400
|
+
.find((o: string) => 'function' === typeof (ent as any)[o])
|
|
401
|
+
if (null == opname) {
|
|
402
|
+
continue
|
|
403
|
+
}
|
|
404
|
+
// The op itself may fail (no seeded data, no live API) — irrelevant
|
|
405
|
+
// here. What matters is that the awaited PreSpec hook ran and the
|
|
406
|
+
// credential reached the live options before the spec was built.
|
|
407
|
+
try {
|
|
408
|
+
await (ent as any)[opname]({})
|
|
409
|
+
}
|
|
410
|
+
catch (_err) { }
|
|
411
|
+
ran = true
|
|
412
|
+
break
|
|
413
|
+
}
|
|
382
414
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
try {
|
|
387
|
-
await sdk[accessor]().list()
|
|
415
|
+
if (!ran) {
|
|
416
|
+
// Entities, but not one callable op between them: no PreSpec path.
|
|
417
|
+
return
|
|
388
418
|
}
|
|
389
|
-
catch (_err) { }
|
|
390
419
|
|
|
391
420
|
assert.equal(sdk.options().apikey, 'ENVKEY02',
|
|
392
421
|
'the entity op did not resolve the secret through PreSpec')
|