@voxgig/sdkgen 4.34.5 → 4.34.7

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.
Files changed (26) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/package.json +1 -1
  3. package/project/.sdk/src/cmp/c/Config_c.ts +5 -0
  4. package/project/.sdk/src/cmp/go/Config_go.ts +4 -1
  5. package/project/.sdk/src/cmp/js/Config_js.ts +4 -1
  6. package/project/.sdk/src/cmp/lua/Config_lua.ts +4 -1
  7. package/project/.sdk/src/cmp/php/Config_php.ts +4 -1
  8. package/project/.sdk/src/cmp/py/Config_py.ts +4 -1
  9. package/project/.sdk/src/cmp/py-data/Main_py-data.ts +13 -5
  10. package/project/.sdk/src/cmp/zig/utility_zig.ts +19 -8
  11. package/project/.sdk/tm/c/tests/pipeline_test.c +4 -4
  12. package/project/.sdk/tm/cpp/test/pipeline_test.cpp +4 -4
  13. package/project/.sdk/tm/csharp/test/PipelineTest.cs +4 -4
  14. package/project/.sdk/tm/elixir/test/feature/secrets/secrets_test.exs +11 -1
  15. package/project/.sdk/tm/kotlin/test/PipelineTest.kt +4 -4
  16. package/project/.sdk/tm/kotlin/test/feature/secrets/SecretsTest.kt +1 -1
  17. package/project/.sdk/tm/lua/test/feature/secrets/secrets_feature_test.lua +6 -2
  18. package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +4 -3
  19. package/project/.sdk/tm/perl/t/feature/secrets/secrets.t +8 -0
  20. package/project/.sdk/tm/perl/t/runner.pm +6 -4
  21. package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +3 -1
  22. package/project/.sdk/tm/rust/tests/pipeline_test.rs +4 -4
  23. package/project/.sdk/tm/scala/sdktest/feature/secrets/SecretsTestMain.scala +7 -2
  24. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PipelineTest.swift +4 -4
  25. package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +12 -8
  26. package/project/sdkgen-package.json +1 -1
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.34.5'
11
+ const VERSION = '4.34.7'
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.34.5",
3
+ "version": "4.34.7",
4
4
  "main": "dist/sdkgen.js",
5
5
  "type": "commonjs",
6
6
  "engines": {
@@ -11,6 +11,7 @@ import {
11
11
  isConfigData,
12
12
  resolveAuthIn,
13
13
  resolveAuthName,
14
+ isHttpBasicAuth,
14
15
  resolveAuthPrefix,
15
16
  targetFeatures,
16
17
  } from '@voxgig/sdkgen'
@@ -304,6 +305,7 @@ const Config = cmp(async function Config(props: any) {
304
305
  // to what it generated before (Config_ts and Config_go do the same).
305
306
  const authIn = resolveAuthIn(model)
306
307
  const authName = resolveAuthName(model)
308
+ const authBasic = isHttpBasicAuth(model)
307
309
 
308
310
  let baseUrl = ''
309
311
  try { baseUrl = getModelPath(model, `main.${KIT}.info.servers.0.url`) } catch (_e) { }
@@ -336,6 +338,9 @@ const Config = cmp(async function Config(props: any) {
336
338
  }
337
339
  if (authActive) {
338
340
  options.auth = { prefix: authPrefix }
341
+ if (authBasic) {
342
+ options.auth.basic = true
343
+ }
339
344
  if ('header' !== authIn) {
340
345
  options.auth.in = authIn
341
346
  }
@@ -16,6 +16,7 @@ import {
16
16
  isConfigData,
17
17
  resolveAuthIn,
18
18
  resolveAuthName,
19
+ isHttpBasicAuth,
19
20
  resolveAuthPrefix,
20
21
  serverVariables,
21
22
  targetFeatures,
@@ -67,9 +68,11 @@ const Config = cmp(async function Config(props: any) {
67
68
  // what it generated before.
68
69
  const authIn = resolveAuthIn(model)
69
70
  const authName = resolveAuthName(model)
71
+ const authBasic = isHttpBasicAuth(model)
70
72
  const authBlock = authActive
71
73
  ? ` "auth": map[string]any{
72
- "prefix": "${authPrefix}",${'header' === authIn ? '' : `
74
+ "prefix": "${authPrefix}",${authBasic ? `
75
+ "basic": true,` : ''}${'header' === authIn ? '' : `
73
76
  "in": "${authIn}",`}${'Authorization' === authName ? '' : `
74
77
  "name": "${authName}",`}
75
78
  },\n`
@@ -16,6 +16,7 @@ import {
16
16
  isConfigData,
17
17
  resolveAuthIn,
18
18
  resolveAuthName,
19
+ isHttpBasicAuth,
19
20
  resolveAuthPrefix,
20
21
  serverVariables,
21
22
  targetFeatures,
@@ -57,9 +58,11 @@ const Config = cmp(async function Config(props: any) {
57
58
  // what it generated before.
58
59
  const authIn = resolveAuthIn(model)
59
60
  const authName = resolveAuthName(model)
61
+ const authBasic = isHttpBasicAuth(model)
60
62
  const authBlock = authActive
61
63
  ? `auth: {
62
- prefix: '${authPrefix}',${'header' === authIn ? '' : `
64
+ prefix: '${authPrefix}',${authBasic ? `
65
+ basic: true,` : ''}${'header' === authIn ? '' : `
63
66
  in: '${authIn}',`}${'Authorization' === authName ? '' : `
64
67
  name: '${authName}',`}
65
68
  },
@@ -15,6 +15,7 @@ import {
15
15
  isConfigData,
16
16
  resolveAuthIn,
17
17
  resolveAuthName,
18
+ isHttpBasicAuth,
18
19
  resolveAuthPrefix,
19
20
  serverVariables,
20
21
  targetFeatures,
@@ -97,9 +98,11 @@ const Config = cmp(async function Config(props: any) {
97
98
 
98
99
  const authIn = resolveAuthIn(model)
99
100
  const authName = resolveAuthName(model)
101
+ const authBasic = isHttpBasicAuth(model)
100
102
  const authBlock = authActive
101
103
  ? ` auth = {
102
- prefix = "${authPrefix}",${'header' === authIn ? '' : `
104
+ prefix = "${authPrefix}",${authBasic ? `
105
+ basic = true,` : ''}${'header' === authIn ? '' : `
103
106
  ["in"] = "${authIn}",`}${'Authorization' === authName ? '' : `
104
107
  name = "${authName}",`}
105
108
  },\n`
@@ -16,6 +16,7 @@ import {
16
16
  rawStringLiteral,
17
17
  resolveAuthIn,
18
18
  resolveAuthName,
19
+ isHttpBasicAuth,
19
20
  resolveAuthPrefix,
20
21
  serverVariables,
21
22
  targetFeatures,
@@ -88,6 +89,7 @@ const Config = cmp(async function Config(props: any) {
88
89
  // what it generated before.
89
90
  const authIn = resolveAuthIn(model)
90
91
  const authName = resolveAuthName(model)
92
+ const authBasic = isHttpBasicAuth(model)
91
93
 
92
94
  let baseUrl = ''
93
95
  try { baseUrl = getModelPath(model, `main.${KIT}.info.servers.0.url`) } catch (_e) { }
@@ -101,7 +103,8 @@ const Config = cmp(async function Config(props: any) {
101
103
 
102
104
  const authBlock = authActive
103
105
  ? ` "auth" => [
104
- "prefix" => "${authPrefix}",${'header' === authIn ? '' : `
106
+ "prefix" => "${authPrefix}",${authBasic ? `
107
+ "basic" => true,` : ''}${'header' === authIn ? '' : `
105
108
  "in" => ${phps(authIn)},`}${'Authorization' === authName ? '' : `
106
109
  "name" => ${phps(authName)},`}
107
110
  ],\n`
@@ -15,6 +15,7 @@ import {
15
15
  isConfigData,
16
16
  resolveAuthIn,
17
17
  resolveAuthName,
18
+ isHttpBasicAuth,
18
19
  resolveAuthPrefix,
19
20
  serverVariables,
20
21
  targetFeatures,
@@ -89,6 +90,7 @@ const Config = cmp(async function Config(props: any) {
89
90
  // what it generated before.
90
91
  const authIn = resolveAuthIn(model)
91
92
  const authName = resolveAuthName(model)
93
+ const authBasic = isHttpBasicAuth(model)
92
94
 
93
95
  let baseUrl = ''
94
96
  try { baseUrl = getModelPath(model, `main.${KIT}.info.servers.0.url`) } catch (_e) { }
@@ -101,7 +103,8 @@ const Config = cmp(async function Config(props: any) {
101
103
 
102
104
  const authBlock = authActive
103
105
  ? ` "auth": {
104
- "prefix": "${authPrefix}",${'header' === authIn ? '' : `
106
+ "prefix": "${authPrefix}",${authBasic ? `
107
+ "basic": True,` : ''}${'header' === authIn ? '' : `
105
108
  "in": "${authIn}",`}${'Authorization' === authName ? '' : `
106
109
  "name": "${authName}",`}
107
110
  },\n`
@@ -486,6 +486,13 @@ const EntityFramesTest = cmp(function EntityFramesTest(props: any) {
486
486
  const accessors = frameEnts.map((e: any) => pluralAccessor(e))
487
487
  const singles = seriesEnts.map((e: any) => singularAccessor(e))
488
488
 
489
+ // The test-mode cases call an accessor with no match, so they need one whose
490
+ // list route names no parent.
491
+ const vals = (x: any): any[] => null == x ? [] : Array.isArray(x) ? x : Object.values(x)
492
+ const unrouted = frameEnts.find((e: any) => vals(e.op?.list?.points).some((pt: any) =>
493
+ null != pt && false !== pt.a && 0 === vals(pt.g?.params).filter((p: any) => null != p && false !== p.a).length))
494
+ const testAccessor = unrouted ? pluralAccessor(unrouted) : null
495
+
489
496
  File({ name: 'test/test_entity_frames.py' }, () => Content(
490
497
  `# Generated accessor tests.
491
498
  #
@@ -503,6 +510,7 @@ from ${dataModule}.entity_frames import EntityFrames
503
510
 
504
511
  FRAME_ACCESSORS = ${pyList(accessors)}
505
512
  SERIES_ACCESSORS = ${pyList(singles)}
513
+ TEST_ACCESSOR = ${null == testAccessor ? 'None' : JSON.stringify(testAccessor)}
506
514
 
507
515
 
508
516
  class TestAccessorSurface:
@@ -531,8 +539,8 @@ class TestAccessorSurface:
531
539
  f"accessor {a} would shadow the client surface"
532
540
 
533
541
 
534
- @pytest.mark.skipif(len(FRAME_ACCESSORS) == 0,
535
- reason="this API exposes no list operations")
542
+ @pytest.mark.skipif(TEST_ACCESSOR is None,
543
+ reason="this API exposes no list operation without a parent")
536
544
  class TestFramesAgainstTestMode:
537
545
 
538
546
  def _client(self):
@@ -541,20 +549,20 @@ class TestFramesAgainstTestMode:
541
549
 
542
550
  def test_first_frame_accessor_returns_a_dataframe(self):
543
551
  ad = self._client()
544
- df = getattr(ad, FRAME_ACCESSORS[0])(quiet=True)
552
+ df = getattr(ad, TEST_ACCESSOR)(quiet=True)
545
553
  assert isinstance(df, pd.DataFrame)
546
554
 
547
555
  def test_declared_columns_have_their_model_dtypes(self):
548
556
  # Any column the model declared AND the API returned must carry the
549
557
  # model's dtype — this is what makes groupby/merge behave.
550
558
  ad = self._client()
551
- df = getattr(ad, FRAME_ACCESSORS[0])(quiet=True)
559
+ df = getattr(ad, TEST_ACCESSOR)(quiet=True)
552
560
  for col in df.columns:
553
561
  assert str(df[col].dtype) != "float64" or True # dtypes applied
554
562
 
555
563
  def test_limit_is_respected(self):
556
564
  ad = self._client()
557
- df = getattr(ad, FRAME_ACCESSORS[0])(limit=1, quiet=True)
565
+ df = getattr(ad, TEST_ACCESSOR)(limit=1, quiet=True)
558
566
  assert len(df) <= 1
559
567
  `))
560
568
  })
@@ -26,23 +26,34 @@ function zigVarName(name: string): string {
26
26
  }
27
27
 
28
28
 
29
+ // A name zig would refuse as too long keeps its head and gains a hash of the whole.
30
+ const ZIG_NAME_MAX = 32
31
+
32
+
29
33
  function zigModuleName(model: any): string {
30
- const name = `${model.name}_sdk`.toLowerCase().replace(/[^a-z0-9_]/g, '_')
31
- return /^[0-9]/.test(name) ? '_' + name : name
34
+ const snake = `${model.name}_sdk`.toLowerCase().replace(/[^a-z0-9_]/g, '_')
35
+ const name = /^[0-9]/.test(snake) ? '_' + snake : snake
36
+ return name.length <= ZIG_NAME_MAX ? name :
37
+ name.slice(0, ZIG_NAME_MAX - 9) + '_' + crc32(name).toString(16).padStart(8, '0')
32
38
  }
33
39
 
34
40
 
35
- function zigPackageFingerprint(name: string): string {
36
- // CRC-32 (IEEE 802.3, reflected, poly 0xEDB88320) — the one zig's
37
- // std.hash.Crc32 and zlib both compute.
41
+ // CRC-32 (IEEE 802.3, reflected, poly 0xEDB88320) — the one zig's
42
+ // std.hash.Crc32 and zlib both compute.
43
+ function crc32(text: string): number {
38
44
  let crc = 0xffffffff
39
- for (let i = 0; i < name.length; i++) {
40
- crc ^= name.charCodeAt(i) & 0xff
45
+ for (let i = 0; i < text.length; i++) {
46
+ crc ^= text.charCodeAt(i) & 0xff
41
47
  for (let b = 0; b < 8; b++) {
42
48
  crc = (crc >>> 1) ^ (0xedb88320 & -(crc & 1))
43
49
  }
44
50
  }
45
- const checksum = (crc ^ 0xffffffff) >>> 0
51
+ return (crc ^ 0xffffffff) >>> 0
52
+ }
53
+
54
+
55
+ function zigPackageFingerprint(name: string): string {
56
+ const checksum = crc32(name)
46
57
 
47
58
  // FNV-1a 32-bit, folded into the 1..0xfffffffe zig accepts.
48
59
  let fnv = 0x811c9dc5
@@ -403,7 +403,7 @@ static void test_prepare_auth_guards_missing_spec(void) {
403
403
  }
404
404
 
405
405
  static void test_prepare_auth_apikey_with_prefix_space_joined(void) {
406
- pl_client(cmap(2, "apikey", v_str("K"), "auth", cmap(1, "prefix", v_str("Bearer"))));
406
+ pl_client(cmap(2, "apikey", v_str("K"), "auth", cmap(2, "prefix", v_str("Bearer"), "basic", v_bool(false))));
407
407
  Context* ctx = pl_ctx(NULL);
408
408
  ctx->spec = auth_spec(v_undef());
409
409
  PNError* err = NULL;
@@ -413,7 +413,7 @@ static void test_prepare_auth_apikey_with_prefix_space_joined(void) {
413
413
  }
414
414
 
415
415
  static void test_prepare_auth_raw_apikey_empty_prefix_as_is(void) {
416
- pl_client(cmap(2, "apikey", v_str("K"), "auth", cmap(1, "prefix", v_str(""))));
416
+ pl_client(cmap(2, "apikey", v_str("K"), "auth", cmap(2, "prefix", v_str(""), "basic", v_bool(false))));
417
417
  Context* ctx = pl_ctx(NULL);
418
418
  ctx->spec = auth_spec(v_undef());
419
419
  PNError* err = NULL;
@@ -422,7 +422,7 @@ static void test_prepare_auth_raw_apikey_empty_prefix_as_is(void) {
422
422
  }
423
423
 
424
424
  static void test_prepare_auth_empty_apikey_drops_header(void) {
425
- pl_client(cmap(2, "apikey", v_str(""), "auth", cmap(1, "prefix", v_str("Bearer"))));
425
+ pl_client(cmap(2, "apikey", v_str(""), "auth", cmap(2, "prefix", v_str("Bearer"), "basic", v_bool(false))));
426
426
  Context* ctx = pl_ctx(NULL);
427
427
  ctx->spec = auth_spec(cmap(1, "authorization", v_str("stale")));
428
428
  PNError* err = NULL;
@@ -432,7 +432,7 @@ static void test_prepare_auth_empty_apikey_drops_header(void) {
432
432
  }
433
433
 
434
434
  static void test_prepare_auth_missing_apikey_drops_header(void) {
435
- pl_client(cmap(1, "auth", cmap(1, "prefix", v_str("Bearer"))));
435
+ pl_client(cmap(1, "auth", cmap(2, "prefix", v_str("Bearer"), "basic", v_bool(false))));
436
436
  voxgig_value* options = sdk_options_map(PL_CLIENT);
437
437
  const char* k = get_str(options, "apikey");
438
438
  if (k && k[0] != '\0') {
@@ -390,7 +390,7 @@ static void prepareAuth_guardsMissingSpec() {
390
390
  }
391
391
 
392
392
  static void prepareAuth_apikeyWithPrefixSpaceJoined() {
393
- auto client = plClient(fhMap({{"apikey", Value("K")}, {"auth", fhMap({{"prefix", Value("Bearer")}})}}));
393
+ auto client = plClient(fhMap({{"apikey", Value("K")}, {"auth", fhMap({{"prefix", Value("Bearer")}, {"basic", Value(false)}})}}));
394
394
  UtilityPtr utility = client->getUtility();
395
395
  CtxPtr ctx = plCtx(client, utility, Value::undef());
396
396
  ctx->spec = authSpec(Value::undef());
@@ -399,7 +399,7 @@ static void prepareAuth_apikeyWithPrefixSpaceJoined() {
399
399
  }
400
400
 
401
401
  static void prepareAuth_rawApikeyEmptyPrefixAsIs() {
402
- auto client = plClient(fhMap({{"apikey", Value("K")}, {"auth", fhMap({{"prefix", Value("")}})}}));
402
+ auto client = plClient(fhMap({{"apikey", Value("K")}, {"auth", fhMap({{"prefix", Value("")}, {"basic", Value(false)}})}}));
403
403
  UtilityPtr utility = client->getUtility();
404
404
  CtxPtr ctx = plCtx(client, utility, Value::undef());
405
405
  ctx->spec = authSpec(Value::undef());
@@ -408,7 +408,7 @@ static void prepareAuth_rawApikeyEmptyPrefixAsIs() {
408
408
  }
409
409
 
410
410
  static void prepareAuth_emptyApikeyDropsHeader() {
411
- auto client = plClient(fhMap({{"apikey", Value("")}, {"auth", fhMap({{"prefix", Value("Bearer")}})}}));
411
+ auto client = plClient(fhMap({{"apikey", Value("")}, {"auth", fhMap({{"prefix", Value("Bearer")}, {"basic", Value(false)}})}}));
412
412
  UtilityPtr utility = client->getUtility();
413
413
  CtxPtr ctx = plCtx(client, utility, Value::undef());
414
414
  ctx->spec = authSpec(fhMap({{"authorization", Value("stale")}}));
@@ -417,7 +417,7 @@ static void prepareAuth_emptyApikeyDropsHeader() {
417
417
  }
418
418
 
419
419
  static void prepareAuth_missingApikeyDropsHeader() {
420
- auto client = plClient(fhMap({{"auth", fhMap({{"prefix", Value("Bearer")}})}}));
420
+ auto client = plClient(fhMap({{"auth", fhMap({{"prefix", Value("Bearer")}, {"basic", Value(false)}})}}));
421
421
  Value options = client->optionsMap();
422
422
  Value apikey = getp(options, "apikey");
423
423
  if (apikey.is_string() && !apikey.as_string().empty()) {
@@ -559,7 +559,7 @@ public class PipelineTest
559
559
  var (client, utility) = PlClient(new Dictionary<string, object?>
560
560
  {
561
561
  ["apikey"] = "K",
562
- ["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer" },
562
+ ["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer", ["basic"] = false },
563
563
  });
564
564
  var ctx = PlCtx(client, utility, null);
565
565
  ctx.Spec = AuthSpec(null);
@@ -573,7 +573,7 @@ public class PipelineTest
573
573
  var (client, utility) = PlClient(new Dictionary<string, object?>
574
574
  {
575
575
  ["apikey"] = "K",
576
- ["auth"] = new Dictionary<string, object?> { ["prefix"] = "" },
576
+ ["auth"] = new Dictionary<string, object?> { ["prefix"] = "", ["basic"] = false },
577
577
  });
578
578
  var ctx = PlCtx(client, utility, null);
579
579
  ctx.Spec = AuthSpec(null);
@@ -587,7 +587,7 @@ public class PipelineTest
587
587
  var (client, utility) = PlClient(new Dictionary<string, object?>
588
588
  {
589
589
  ["apikey"] = "",
590
- ["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer" },
590
+ ["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer", ["basic"] = false },
591
591
  });
592
592
  var ctx = PlCtx(client, utility, null);
593
593
  ctx.Spec = AuthSpec(new Dictionary<string, object?>
@@ -604,7 +604,7 @@ public class PipelineTest
604
604
  {
605
605
  var (client, utility) = PlClient(new Dictionary<string, object?>
606
606
  {
607
- ["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer" },
607
+ ["auth"] = new Dictionary<string, object?> { ["prefix"] = "Bearer", ["basic"] = false },
608
608
  });
609
609
  var options = client.OptionsMap();
610
610
  if (options.TryGetValue("apikey", out var apikey) &&
@@ -1066,7 +1066,8 @@ defmodule ProjectName.SecretsTest do
1066
1066
  nil
1067
1067
  else
1068
1068
  Enum.find_value(S.keysof(ents), fn name ->
1069
- if S.ismap(S.getpath(ents, name <> ".op.list")) do
1069
+ if S.ismap(S.getpath(ents, name <> ".op.list")) and
1070
+ unrouted?(S.getpath(ents, name <> ".op.list.points")) do
1070
1071
  factory = existing_atom(name)
1071
1072
 
1072
1073
  if factory != nil and
@@ -1083,6 +1084,15 @@ defmodule ProjectName.SecretsTest do
1083
1084
  end
1084
1085
  end
1085
1086
 
1087
+ # A list called with no match can take only a route naming no path parameter.
1088
+ defp unrouted?(points) do
1089
+ is_list(points) and
1090
+ Enum.any?(points, fn pt ->
1091
+ params = S.getpath(pt, "args.params")
1092
+ not is_list(params) or params == []
1093
+ end)
1094
+ end
1095
+
1086
1096
  # Run an entity op and answer with its failure MESSAGE ("" when it
1087
1097
  # succeeded). An entity op raises by default rather than returning its
1088
1098
  # error, so a fail-closed assertion has to reach the message through the
@@ -495,7 +495,7 @@ class PipelineTest {
495
495
 
496
496
  @Test
497
497
  fun prepareAuth_apikeyWithPrefixSpaceJoined() {
498
- val client = plClient(fhMap("apikey", "K", "auth", fhMap("prefix", "Bearer")))
498
+ val client = plClient(fhMap("apikey", "K", "auth", fhMap("prefix", "Bearer", "basic", false)))
499
499
  val utility = client.getUtility()
500
500
  val ctx = plCtx(client, utility, null)
501
501
  ctx.spec = authSpec(null)
@@ -505,7 +505,7 @@ class PipelineTest {
505
505
 
506
506
  @Test
507
507
  fun prepareAuth_rawApikeyEmptyPrefixAsIs() {
508
- val client = plClient(fhMap("apikey", "K", "auth", fhMap("prefix", "")))
508
+ val client = plClient(fhMap("apikey", "K", "auth", fhMap("prefix", "", "basic", false)))
509
509
  val utility = client.getUtility()
510
510
  val ctx = plCtx(client, utility, null)
511
511
  ctx.spec = authSpec(null)
@@ -515,7 +515,7 @@ class PipelineTest {
515
515
 
516
516
  @Test
517
517
  fun prepareAuth_emptyApikeyDropsHeader() {
518
- val client = plClient(fhMap("apikey", "", "auth", fhMap("prefix", "Bearer")))
518
+ val client = plClient(fhMap("apikey", "", "auth", fhMap("prefix", "Bearer", "basic", false)))
519
519
  val utility = client.getUtility()
520
520
  val ctx = plCtx(client, utility, null)
521
521
  ctx.spec = authSpec(fhMap("authorization", "stale"))
@@ -525,7 +525,7 @@ class PipelineTest {
525
525
 
526
526
  @Test
527
527
  fun prepareAuth_missingApikeyDropsHeader() {
528
- val client = plClient(fhMap("auth", fhMap("prefix", "Bearer")))
528
+ val client = plClient(fhMap("auth", fhMap("prefix", "Bearer", "basic", false)))
529
529
  val options = client.optionsMap()
530
530
  val apikey = options["apikey"]
531
531
  if (apikey is String && "" != apikey) {
@@ -270,7 +270,7 @@ class SecretsTest {
270
270
 
271
271
  for (op in listOf<(SdkEntity) -> Any?>(
272
272
  { it.list(null, null) },
273
- { it.load(null, null) },
273
+ { it.load(mutableMapOf<String, Any?>("id" to "x"), null) },
274
274
  )) {
275
275
  try {
276
276
  op(ent)
@@ -225,7 +225,7 @@ local function drive_entity_op_until(client, what, stop)
225
225
  for _, opname in ipairs({ "list", "load" }) do
226
226
  if type(ent[opname]) == "function" then
227
227
  last_res, last_err = ent[opname](ent, { id = "id01" })
228
- if stop() then return last_res, last_err end
228
+ if stop(last_res, last_err) then return last_res, last_err end
229
229
  end
230
230
  end
231
231
  end
@@ -539,7 +539,11 @@ describe("secrets", function()
539
539
  "expected sekreto's own message (" .. fragment .. "), got: " .. tostring(res.err))
540
540
  assert.are.equal(0, #w.api(), "nothing may reach the wire")
541
541
 
542
- local err = drive_refusal(client, function() return true end)
542
+ -- An op whose route the call cannot fill fails before the chain is
543
+ -- consulted, so drive until one refuses with sekreto's message.
544
+ local err = drive_refusal(client, function(_, e)
545
+ return nil ~= e and nil ~= tostring(e):find(fragment, 1, true)
546
+ end)
543
547
  assert.is_table(err, "the entity path must refuse too")
544
548
  assert.is_truthy(tostring(err):find(fragment, 1, true), "got: " .. tostring(err))
545
549
  assert.are.equal(0, #w.api())
@@ -288,9 +288,10 @@ let drive_entity (client : sdk_client) (r : recorder) : (unit, string) Stdlib.re
288
288
  out := Ok ();
289
289
  if before < List.length (api_calls r) then () else ops more
290
290
  | exception Sdk_error_exc e ->
291
- (* An op the entity does not define fails before the chain
292
- * is consulted: keep going. Anything else is the answer. *)
293
- if e.err_code = "unsupported_op" then ops more
291
+ (* An op the entity does not define, or a route the call
292
+ * cannot fill, fails before the chain is consulted: keep
293
+ * going. Anything else is the answer. *)
294
+ if e.err_code = "unsupported_op" || e.err_code = "url_param_missing" then ops more
294
295
  else (out := Error e.err_msg)
295
296
  | exception e -> out := Error (Printexc.to_string e))
296
297
  in
@@ -209,7 +209,15 @@ sub listable_op {
209
209
  my ($sdk) = @_;
210
210
  my $entities = ProjectNameHelpers::to_map(
211
211
  ProjectNameHelpers::gp($sdk->options_map, 'entity')) || {};
212
+ my $config = ProjectNameConfig::make_config();
212
213
  for my $name (sort keys %$entities) {
214
+ # A list called with no match can take only a route naming no path
215
+ # parameter.
216
+ my $points = ProjectNameHelpers::gpath($config, "entity.$name.op.list.points");
217
+ next unless 'ARRAY' eq ref($points) && grep {
218
+ my $ps = 'HASH' eq ref($_) ? ProjectNameHelpers::gpath($_, 'args.params') : undef;
219
+ 'ARRAY' ne ref($ps) || 0 == scalar(@$ps)
220
+ } @$points;
213
221
  my $accessor = ucfirst($name);
214
222
  next unless $sdk->can($accessor);
215
223
  my $ent = eval { $sdk->$accessor() };
@@ -75,13 +75,15 @@ sub entity_list_to_data {
75
75
  my ($list) = @_;
76
76
  my $out = [];
77
77
  for my $item (@{ $list || [] }) {
78
- if (Voxgig::Struct::ismap($item)) {
79
- push @$out, $item;
80
- }
81
- elsif (Scalar::Util::blessed($item) && $item->can('data_get')) {
78
+ # An entity is a blessed hash, which ismap also accepts, so it is asked
79
+ # for its data first.
80
+ if (Scalar::Util::blessed($item) && $item->can('data_get')) {
82
81
  my $d = $item->data_get;
83
82
  push @$out, $d if Voxgig::Struct::ismap($d);
84
83
  }
84
+ elsif (Voxgig::Struct::ismap($item)) {
85
+ push @$out, $item;
86
+ }
85
87
  }
86
88
  return $out;
87
89
  }
@@ -275,7 +275,9 @@ class ProjectNameSecretsTest extends TestCase
275
275
  $this->driveUntil($client, 'returned an SDK error',
276
276
  function () use (&$caught) { return $caught !== null; },
277
277
  function (\Throwable $error) use (&$caught) {
278
- if ($error instanceof ProjectNameError) {
278
+ // A call whose route it cannot fill is refused before the
279
+ // chain is consulted, so it is not the refusal under test.
280
+ if ($error instanceof ProjectNameError && 'url_param_missing' !== $error->sdk_code) {
279
281
  $caught = $error;
280
282
  }
281
283
  });
@@ -599,7 +599,7 @@ fn pipeline_prepare_auth_guards_missing_spec() {
599
599
  fn pipeline_prepare_auth_apikey_with_prefix_space_joined() {
600
600
  let (client, utility) = pl_client(jo(vec![
601
601
  ("apikey", Value::str("K")),
602
- ("auth", jo(vec![("prefix", Value::str("Bearer"))])),
602
+ ("auth", jo(vec![("prefix", Value::str("Bearer")), ("basic", Value::Bool(false))])),
603
603
  ]));
604
604
  let ctx = pl_ctx(&client, &utility, None);
605
605
  *ctx.spec.borrow_mut() = Some(auth_spec(Value::Noval));
@@ -613,7 +613,7 @@ fn pipeline_prepare_auth_apikey_with_prefix_space_joined() {
613
613
  fn pipeline_prepare_auth_raw_apikey_empty_prefix_as_is() {
614
614
  let (client, utility) = pl_client(jo(vec![
615
615
  ("apikey", Value::str("K")),
616
- ("auth", jo(vec![("prefix", Value::str(""))])),
616
+ ("auth", jo(vec![("prefix", Value::str("")), ("basic", Value::Bool(false))])),
617
617
  ]));
618
618
  let ctx = pl_ctx(&client, &utility, None);
619
619
  *ctx.spec.borrow_mut() = Some(auth_spec(Value::Noval));
@@ -627,7 +627,7 @@ fn pipeline_prepare_auth_raw_apikey_empty_prefix_as_is() {
627
627
  fn pipeline_prepare_auth_empty_apikey_drops_header() {
628
628
  let (client, utility) = pl_client(jo(vec![
629
629
  ("apikey", Value::str("")),
630
- ("auth", jo(vec![("prefix", Value::str("Bearer"))])),
630
+ ("auth", jo(vec![("prefix", Value::str("Bearer")), ("basic", Value::Bool(false))])),
631
631
  ]));
632
632
  let ctx = pl_ctx(&client, &utility, None);
633
633
  *ctx.spec.borrow_mut() = Some(auth_spec(jo(vec![(
@@ -647,7 +647,7 @@ fn pipeline_prepare_auth_empty_apikey_drops_header() {
647
647
  fn pipeline_prepare_auth_missing_apikey_drops_header() {
648
648
  let (client, utility) = pl_client(jo(vec![(
649
649
  "auth",
650
- jo(vec![("prefix", Value::str("Bearer"))]),
650
+ jo(vec![("prefix", Value::str("Bearer")), ("basic", Value::Bool(false))]),
651
651
  )]));
652
652
  let options = client.options_map();
653
653
  if get_str(&options, "apikey")
@@ -62,9 +62,14 @@ object SecretsTestMain {
62
62
  // let the prefix be whatever this SDK's API declares - pinning the whole
63
63
  // header value passes only for a prefix-less API, and this file ships to
64
64
  // every project that selects the feature.
65
+ // HTTP Basic carries base64(key:secret) instead, and scala ships this suite
66
+ // untrimmed, so it also runs for a Basic API.
65
67
  private def credentialIs(name: String, header: String, token: String): Unit = {
66
68
  val got = if (header == null) "" else header
67
- check(name, got == token || got.endsWith(" " + token),
69
+ val basic = got.startsWith("Basic ") && (try {
70
+ new String(java.util.Base64.getDecoder.decode(got.substring(6)), "UTF-8").startsWith(token + ":")
71
+ } catch { case _: IllegalArgumentException => false })
72
+ check(name, got == token || got.endsWith(" " + token) || basic,
68
73
  "expected the authorization header to carry " + token + ", got \"" + got + "\"")
69
74
  }
70
75
 
@@ -264,7 +269,7 @@ object SecretsTestMain {
264
269
  var done = false
265
270
  // A plain while, not a for-comprehension: a `return` out of a
266
271
  // for-comprehension is a NON-LOCAL return, which scala 3 has deprecated.
267
- val ops = entities(client).flatMap(ent => List(() => ent.list(null, null), () => ent.load(null, null)))
272
+ val ops = entities(client).flatMap(ent => List(() => ent.list(null, null), () => ent.load(jmap("id" -> "x"), null)))
268
273
  var index = 0
269
274
  while (!done && index < ops.length) {
270
275
  try ops(index)()
@@ -351,7 +351,7 @@ final class PipelineTest: XCTestCase {
351
351
 
352
352
  func testPrepareAuthApikeyWithPrefixSpaceJoined() {
353
353
  let (client, utility) = plClient(vm(
354
- ("apikey", .string("K")), ("auth", .map(vm(("prefix", .string("Bearer")))))))
354
+ ("apikey", .string("K")), ("auth", .map(vm(("prefix", .string("Bearer")), ("basic", .bool(false)))))))
355
355
  let ctx = plCtx(client, utility, nil)
356
356
  ctx.spec = authSpec(nil)
357
357
  _ = try! utility.prepareAuth(ctx)
@@ -360,7 +360,7 @@ final class PipelineTest: XCTestCase {
360
360
 
361
361
  func testPrepareAuthRawApikeyEmptyPrefixAsIs() {
362
362
  let (client, utility) = plClient(vm(
363
- ("apikey", .string("K")), ("auth", .map(vm(("prefix", .string("")))))))
363
+ ("apikey", .string("K")), ("auth", .map(vm(("prefix", .string("")), ("basic", .bool(false)))))))
364
364
  let ctx = plCtx(client, utility, nil)
365
365
  ctx.spec = authSpec(nil)
366
366
  _ = try! utility.prepareAuth(ctx)
@@ -369,7 +369,7 @@ final class PipelineTest: XCTestCase {
369
369
 
370
370
  func testPrepareAuthEmptyApikeyDropsHeader() {
371
371
  let (client, utility) = plClient(vm(
372
- ("apikey", .string("")), ("auth", .map(vm(("prefix", .string("Bearer")))))))
372
+ ("apikey", .string("")), ("auth", .map(vm(("prefix", .string("Bearer")), ("basic", .bool(false)))))))
373
373
  let ctx = plCtx(client, utility, nil)
374
374
  ctx.spec = authSpec(vm(("authorization", .string("stale"))))
375
375
  _ = try! utility.prepareAuth(ctx)
@@ -377,7 +377,7 @@ final class PipelineTest: XCTestCase {
377
377
  }
378
378
 
379
379
  func testPrepareAuthMissingApikeyDropsHeader() {
380
- let (client, utility) = plClient(vm(("auth", .map(vm(("prefix", .string("Bearer")))))))
380
+ let (client, utility) = plClient(vm(("auth", .map(vm(("prefix", .string("Bearer")), ("basic", .bool(false)))))))
381
381
  let options = client.optionsMap()
382
382
  if let apikey = options.entries["apikey"]?.asString, apikey != "" { return }
383
383
  let ctx = plCtx(client, utility, nil)
@@ -273,18 +273,22 @@ fn drive_entity(client: *sdk.SDK) Drive {
273
273
  {
274
274
  const ent = @field(sdk.SDK, d.name)(client, vnull());
275
275
  const ops = h.getpath(&.{ "entity", ent.name, "op" }, cfg);
276
+ // A call whose route it cannot fill is refused before
277
+ // the chain is consulted, so the next entity is tried.
276
278
  if (h.getp(ops, "load") == .object) {
277
279
  const res = ent.load(h.jo(&.{.{ "id", h.vstr("s01") }}), vnull());
278
- return switch (res) {
279
- .err => |e| .{ .ran = true, .ok = false, .msg = e.msg },
280
- .ok => .{ .ran = true, .ok = true, .msg = "" },
281
- };
280
+ switch (res) {
281
+ .err => |e| if (!std.mem.eql(u8, e.code, "url_param_missing"))
282
+ return .{ .ran = true, .ok = false, .msg = e.msg },
283
+ .ok => return .{ .ran = true, .ok = true, .msg = "" },
284
+ }
282
285
  } else if (h.getp(ops, "list") == .object) {
283
286
  const res = ent.list(h.omap(), vnull());
284
- return switch (res) {
285
- .err => |e| .{ .ran = true, .ok = false, .msg = e.msg },
286
- .ok => .{ .ran = true, .ok = true, .msg = "" },
287
- };
287
+ switch (res) {
288
+ .err => |e| if (!std.mem.eql(u8, e.code, "url_param_missing"))
289
+ return .{ .ran = true, .ok = false, .msg = e.msg },
290
+ .ok => return .{ .ran = true, .ok = true, .msg = "" },
291
+ }
288
292
  }
289
293
  }
290
294
  }
@@ -3,7 +3,7 @@
3
3
  "package": 1
4
4
  },
5
5
  "name": "@voxgig/sdkgen",
6
- "version": "4.34.5",
6
+ "version": "4.34.7",
7
7
  "provides": {
8
8
  "target": [
9
9
  "c",