@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
@@ -8,7 +8,7 @@ const { Shape, One, Skip } = require('shape')
8
8
 
9
9
  const { SdkGen } = require('../dist/sdkgen.js')
10
10
 
11
- const VERSION = '4.17.5'
11
+ const VERSION = '4.17.6'
12
12
  const KONSOLE = console
13
13
 
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxgig/sdkgen",
3
- "version": "4.17.5",
3
+ "version": "4.17.6",
4
4
  "main": "dist/sdkgen.js",
5
5
  "type": "commonjs",
6
6
  "engines": {
@@ -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
- const name = names[0]
381
- const accessor = name.charAt(0).toUpperCase() + name.slice(1)
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
- // The op itself may fail (no seeded data, no live API) — irrelevant
384
- // here. What matters is that the awaited PreSpec hook ran and the
385
- // credential reached the live options before the spec was built.
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')
@@ -3,7 +3,7 @@
3
3
  "package": 1
4
4
  },
5
5
  "name": "@voxgig/sdkgen",
6
- "version": "4.17.5",
6
+ "version": "4.17.6",
7
7
  "provides": {
8
8
  "target": [
9
9
  "c",