@voxgig/sdkgen 4.41.1 → 4.43.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.
Files changed (48) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/cmp/ReadmeIntro.js +21 -6
  3. package/dist/cmp/ReadmeIntro.js.map +1 -1
  4. package/dist/cmp/ReadmeTop.js +3 -7
  5. package/dist/cmp/ReadmeTop.js.map +1 -1
  6. package/dist/helpers/alongside.d.ts +3 -0
  7. package/dist/helpers/alongside.js +38 -0
  8. package/dist/helpers/alongside.js.map +1 -0
  9. package/dist/helpers/opShape.d.ts +2 -1
  10. package/dist/helpers/opShape.js +17 -0
  11. package/dist/helpers/opShape.js.map +1 -1
  12. package/dist/sdkgen.d.ts +3 -2
  13. package/dist/sdkgen.js +7 -4
  14. package/dist/sdkgen.js.map +1 -1
  15. package/dist/tsconfig.tsbuildinfo +1 -1
  16. package/package.json +1 -1
  17. package/project/.sdk/src/cmp/c/ReadmeIntro_c.ts +5 -27
  18. package/project/.sdk/src/cmp/clojure/ReadmeIntro_clojure.ts +5 -27
  19. package/project/.sdk/src/cmp/cpp/ReadmeIntro_cpp.ts +5 -27
  20. package/project/.sdk/src/cmp/csharp/ReadmeIntro_csharp.ts +5 -27
  21. package/project/.sdk/src/cmp/elixir/ReadmeIntro_elixir.ts +5 -27
  22. package/project/.sdk/src/cmp/go/ReadmeIntro_go.ts +7 -37
  23. package/project/.sdk/src/cmp/java/ReadmeIntro_java.ts +5 -27
  24. package/project/.sdk/src/cmp/js/ReadmeIntro_js.ts +5 -27
  25. package/project/.sdk/src/cmp/kotlin/ReadmeIntro_kotlin.ts +5 -27
  26. package/project/.sdk/src/cmp/lua/ReadmeIntro_lua.ts +5 -27
  27. package/project/.sdk/src/cmp/ocaml/ReadmeIntro_ocaml.ts +5 -27
  28. package/project/.sdk/src/cmp/perl/ReadmeIntro_perl.ts +5 -27
  29. package/project/.sdk/src/cmp/php/ReadmeIntro_php.ts +6 -28
  30. package/project/.sdk/src/cmp/py/ReadmeIntro_py.ts +5 -27
  31. package/project/.sdk/src/cmp/rb/ReadmeIntro_rb.ts +6 -28
  32. package/project/.sdk/src/cmp/rust/ReadmeIntro_rust.ts +5 -27
  33. package/project/.sdk/src/cmp/scala/ReadmeIntro_scala.ts +5 -27
  34. package/project/.sdk/src/cmp/swift/ReadmeIntro_swift.ts +5 -27
  35. package/project/.sdk/src/cmp/ts/ReadmeIntro_ts.ts +6 -36
  36. package/project/.sdk/src/cmp/zig/ReadmeIntro_zig.ts +5 -27
  37. package/project/.sdk/tm/c/tests/feature_harness.h +19 -0
  38. package/project/.sdk/tm/c/tests/feature_test.c +2 -2
  39. package/project/.sdk/tm/c/tests/primary_utility_test.c +3 -3
  40. package/project/.sdk/tm/cpp/test/primary_utility_test.cpp +20 -3
  41. package/project/.sdk/tm/perl/t/primary_utility.t +2 -1
  42. package/project/.sdk/tm/swift/Tests/ProjectNameSDKTests/PrimaryUtilityTest.swift +8 -1
  43. package/project/sdkgen-package.json +1 -1
  44. package/src/cmp/ReadmeIntro.ts +22 -8
  45. package/src/cmp/ReadmeTop.ts +1 -8
  46. package/src/helpers/alongside.ts +46 -0
  47. package/src/helpers/opShape.ts +17 -0
  48. package/src/sdkgen.ts +4 -1
@@ -1059,14 +1059,14 @@ static void test_proxy_bypasses_noproxy_hosts(void) {
1059
1059
 
1060
1060
  static void test_proxy_fromenv_reads_https_proxy(void) {
1061
1061
  if (!fh_present("proxy")) return;
1062
- setenv("HTTPS_PROXY", "http://env-proxy:8080", 1);
1062
+ fh_setenv("HTTPS_PROXY", "http://env-proxy:8080");
1063
1063
  voxgig_value* calls;
1064
1064
  Fetcher* srv = fh_recorder(NULL, NULL, &calls);
1065
1065
  Feature* f = feature_proxy_new();
1066
1066
  FhFeat feats[] = {{f, cmap(1, "fromEnv", v_bool(true))}};
1067
1067
  FhHarness h = fh_make(srv, feats, 1);
1068
1068
  fh_op(&h, op_load());
1069
- unsetenv("HTTPS_PROXY");
1069
+ fh_unsetenv("HTTPS_PROXY");
1070
1070
  CHECK_STR_EQ(get_str(rec_fetchdef(calls, 0), "proxy"), "http://env-proxy:8080",
1071
1071
  "proxy: env proxy");
1072
1072
  }
@@ -540,7 +540,7 @@ static void test_primary_fetcher_getonly_guard(void) {
540
540
  const char* url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01";
541
541
  const char* prior = getenv("VOXGIG_GETONLY_GUARD");
542
542
  char* saved = NULL == prior ? NULL : strdup(prior);
543
- setenv("VOXGIG_GETONLY_GUARD", "TRUE", 1);
543
+ fh_setenv("VOXGIG_GETONLY_GUARD", "TRUE");
544
544
 
545
545
  PNError* err = NULL;
546
546
  utility_fetch(util, ctx, url, cmap(2, "method", v_str("POST"), "headers", v_map()), &err);
@@ -556,9 +556,9 @@ static void test_primary_fetcher_getonly_guard(void) {
556
556
  "fetcher getonly: a GET reaches the closed port");
557
557
 
558
558
  if (NULL == saved) {
559
- unsetenv("VOXGIG_GETONLY_GUARD");
559
+ fh_unsetenv("VOXGIG_GETONLY_GUARD");
560
560
  } else {
561
- setenv("VOXGIG_GETONLY_GUARD", saved, 1);
561
+ fh_setenv("VOXGIG_GETONLY_GUARD", saved);
562
562
  free(saved);
563
563
  }
564
564
  }
@@ -366,6 +366,23 @@ static void fetcherBlockedTestMode() {
366
366
  ASSERT_TRUE(msg.find("blocked") != std::string::npos, "expected error containing 'blocked'");
367
367
  }
368
368
 
369
+ // MinGW declares neither setenv nor unsetenv.
370
+ static void setEnv(const char* key, const char* val) {
371
+ #ifdef _WIN32
372
+ _putenv_s(key, val);
373
+ #else
374
+ setenv(key, val, 1);
375
+ #endif
376
+ }
377
+
378
+ static void unsetEnv(const char* key) {
379
+ #ifdef _WIN32
380
+ _putenv_s(key, "");
381
+ #else
382
+ unsetenv(key);
383
+ #endif
384
+ }
385
+
369
386
  // Nothing listens on port 9; this target has no transport of its own, so a
370
387
  // request the guard let through fails as fetch_no_transport.
371
388
  static void fetcherGetOnlyGuard() {
@@ -379,7 +396,7 @@ static void fetcherGetOnlyGuard() {
379
396
  std::string url = "http://127.0.0.1:9/planet/p1?apikey=GUARDKEY01";
380
397
  const char* prior = std::getenv("VOXGIG_GETONLY_GUARD");
381
398
  std::string saved = nullptr == prior ? "" : prior;
382
- setenv("VOXGIG_GETONLY_GUARD", "TRUE", 1);
399
+ setEnv("VOXGIG_GETONLY_GUARD", "TRUE");
383
400
 
384
401
  std::string codes[2];
385
402
  std::string msg;
@@ -392,8 +409,8 @@ static void fetcherGetOnlyGuard() {
392
409
  if (0 == i) msg = e->getMessage();
393
410
  }
394
411
  }
395
- if (nullptr == prior) unsetenv("VOXGIG_GETONLY_GUARD");
396
- else setenv("VOXGIG_GETONLY_GUARD", saved.c_str(), 1);
412
+ if (nullptr == prior) unsetEnv("VOXGIG_GETONLY_GUARD");
413
+ else setEnv("VOXGIG_GETONLY_GUARD", saved.c_str());
397
414
 
398
415
  ASSERT_TRUE(codes[0] == "fetch_getonly_block", "expected the POST to be refused");
399
416
  ASSERT_TRUE(msg.find("[GET-ONLY GUARD] blocked POST /planet/p1") != std::string::npos, "expected the path");
@@ -455,7 +455,8 @@ SKIP: {
455
455
  . 'Content-Length: ' . length($body) . "\r\nConnection: close\r\n\r\n" . $body;
456
456
  close $sock;
457
457
  }
458
- POSIX::_exit(0);
458
+ # Windows forks a thread, where _exit ends the whole test process.
459
+ $^O eq 'MSWin32' ? exit(0) : POSIX::_exit(0);
459
460
  }
460
461
  close $seen_w;
461
462
  my $base = 'http://127.0.0.1:' . $server->sockport;
@@ -438,7 +438,14 @@ final class PrimaryUtilityTest: XCTestCase {
438
438
  addr.sin_addr.s_addr = inet_addr("127.0.0.1")
439
439
  var len = socklen_t(MemoryLayout<sockaddr_in>.size)
440
440
  _ = withUnsafeMutablePointer(to: &addr) {
441
- $0.withMemoryRebound(to: sockaddr.self, capacity: 1) { bind(fd, $0, len) }
441
+ $0.withMemoryRebound(to: sockaddr.self, capacity: 1) { sa -> Int32 in
442
+ #if os(Linux)
443
+ return bind(fd, sa, len)
444
+ #else
445
+ // A bare bind here names an instance method XCTestCase inherits.
446
+ return Darwin.bind(fd, sa, len)
447
+ #endif
448
+ }
442
449
  }
443
450
  listen(fd, 8)
444
451
  _ = withUnsafeMutablePointer(to: &addr) {
@@ -3,7 +3,7 @@
3
3
  "package": 1
4
4
  },
5
5
  "name": "@voxgig/sdkgen",
6
- "version": "4.41.1",
6
+ "version": "4.43.0",
7
7
  "provides": {
8
8
  "target": [
9
9
  "c",
@@ -1,21 +1,35 @@
1
1
 
2
- import { cmp } from '../helpers/component'
2
+ import { Content } from 'jostraca'
3
3
 
4
+ import { cmp } from '../helpers/component'
4
5
  import { optionalComponent } from '../helpers/optional'
6
+ import { modelText } from '../helpers/text'
7
+ import { alongsideNote } from '../helpers/alongside'
5
8
 
6
9
 
7
- // Per-language intro lives in `project/.sdk/src/cmp/<lang>/ReadmeIntro_<lang>.ts`.
8
- // Each language declares its own tagline and stylistic emphasis (Go's
9
- // `map[string]any` data-flow note, TS's async/await emphasis, etc.).
10
+ // Every language README opens the same way: the title and tagline, the
11
+ // target's own ReadmeIntroBody, then the note naming the rest of the project.
12
+ // A component exporting a whole ReadmeIntro (a project's copy from before this
13
+ // frame, or a pack not yet moved to it) still writes its own introduction.
10
14
  const ReadmeIntro = cmp(function ReadmeIntro(props: any) {
11
15
  const { target, ctx$ } = props
16
+ const { model } = ctx$
12
17
 
13
- const ReadmeIntro_sdk =
14
- optionalComponent(ctx$, target, 'ReadmeIntro')
18
+ const intro = optionalComponent(ctx$, target, 'ReadmeIntro')
19
+ if (null == intro) return
15
20
 
16
- if (ReadmeIntro_sdk) {
17
- ReadmeIntro_sdk['ReadmeIntro']({ target })
21
+ if (null == intro.ReadmeIntroBody) {
22
+ intro.ReadmeIntro({ target })
23
+ return
18
24
  }
25
+
26
+ Content(`# ${model.Name} ${target.title} SDK
27
+
28
+ ${modelText(model).tagline || ''}
29
+
30
+ `)
31
+ intro.ReadmeIntroBody({ target })
32
+ Content(alongsideNote(model, target.name))
19
33
  })
20
34
 
21
35
 
@@ -21,6 +21,7 @@ import type { ExampleLang, PrimaryCall } from '../helpers/opExample'
21
21
  import { canonScalarKey } from '../helpers/canonType'
22
22
  import { safeVarName, exampleVarName, jsKey } from '../helpers/naming'
23
23
  import { modelText } from '../helpers/text'
24
+ import { isConsumer } from '../helpers/alongside'
24
25
 
25
26
  import {
26
27
  installCommand as pkgInstall,
@@ -64,14 +65,6 @@ function pickLeadTarget(sdkTargets: any[]): any | undefined {
64
65
  }
65
66
 
66
67
 
67
- const PHASES = ['entity', 'feature', 'readme', 'agentguide', 'test']
68
-
69
- // A consumer (py-data) switches every phase off and has no ReadmeTop components.
70
- function isConsumer(target: any): boolean {
71
- return PHASES.every((name: string) => false === target.phase?.[name]?.active)
72
- }
73
-
74
-
75
68
  const EXAMPLE_FENCE: Record<string, string> = {
76
69
  ts: 'ts', js: 'js', py: 'python', go: 'go', php: 'php', rb: 'ruby', lua: 'lua',
77
70
  }
@@ -0,0 +1,46 @@
1
+ import { KIT } from '@voxgig/apidef'
2
+
3
+
4
+ const PHASES = ['entity', 'feature', 'readme', 'agentguide', 'test']
5
+
6
+
7
+ // A consumer (py-data) switches every phase off and has no ReadmeTop components.
8
+ function isConsumer(target: any): boolean {
9
+ return PHASES.every((name: string) => false === target?.phase?.[name]?.active)
10
+ }
11
+
12
+
13
+ // Names only the active surfaces, so a project with go-mcp off is not promised one.
14
+ function alongsideNote(model: any, self: string): string {
15
+ const target = model?.main?.[KIT]?.target || {}
16
+ const others = Object.entries(target)
17
+ .filter(([name, t]: [string, any]) => name !== self && null != t && false !== t.active)
18
+
19
+ const has = (name: string) => others.some(([other]) => other === name)
20
+ const cli = has('go-cli')
21
+ const mcp = has('go-mcp')
22
+ const langs = others.some(([name, t]: [string, any]) =>
23
+ 'go-cli' !== name && 'go-mcp' !== name && !isConsumer(t))
24
+
25
+ const parts: string[] = []
26
+ if (langs) parts.push('Other languages')
27
+ if (cli) parts.push('the CLI')
28
+ if (mcp) parts.push(cli ? 'MCP server' : 'the MCP server')
29
+ if (0 === parts.length) return ''
30
+
31
+ const list = 1 === parts.length ? parts[0]
32
+ : 2 === parts.length ? parts.join(' and ')
33
+ : parts.slice(0, -1).join(', ') + ', and ' + parts[parts.length - 1]
34
+ const verb = 1 === parts.length && !langs ? 'lives' : 'live'
35
+
36
+ return `> ${list[0].toUpperCase() + list.slice(1)} ${verb} alongside this one — see
37
+ > the [top-level README](../README.md).
38
+
39
+ `
40
+ }
41
+
42
+
43
+ export {
44
+ isConsumer,
45
+ alongsideNote,
46
+ }
@@ -415,6 +415,22 @@ function entityOps(ent: any): string[] {
415
415
  }
416
416
 
417
417
 
418
+ // Unlike entityOps, keeps action-only ops: the README introductions always have.
419
+ function introOps(model: any): string[] {
420
+ const entity = model?.main?.[KIT]?.entity || {}
421
+ const found = new Set<string>()
422
+ for (const e of Object.values(entity) as any[]) {
423
+ if (!e || false === e.active) continue
424
+ for (const o of Object.keys(e.op || {})) {
425
+ if (e.op[o] && false !== e.op[o].active) found.add(o)
426
+ }
427
+ }
428
+ const names = CANON_OP_ORDER.filter((o) => found.has(o))
429
+ .concat([...found].filter((o) => !CANON_OP_ORDER.includes(o)))
430
+ return 0 < names.length ? names : ['list', 'load']
431
+ }
432
+
433
+
418
434
  type UngeneratedOp = { entity: string, op: string, points: string[] }
419
435
 
420
436
 
@@ -779,6 +795,7 @@ export {
779
795
  entityDataIdField,
780
796
  entityRecordIdField,
781
797
  entityOps,
798
+ introOps,
782
799
  invalidRequest,
783
800
  entityPrimaryOp,
784
801
  pickExampleEntity,
package/src/sdkgen.ts CHANGED
@@ -71,7 +71,7 @@ import type { DepEntry } from './helpers/collectDeps'
71
71
  import { canonToType, canonToDtype, canonKey, canonScalarKey } from './helpers/canonType'
72
72
  import { canonToSpec, entityDataSpec, entityOpSpec, entitySpecs, validateSeeds } from './helpers/canonSpec'
73
73
  import { optionSpec, featureOptionSpec, entitySpecMap } from './helpers/optspec'
74
- import { OP_SUFFIX, opTypeName, opParams, opReachable, opNeedsAction, ownPoint, opActions, entityActions, entityPath, opRequestShape, entityIdField, entityDataIdField, entityRecordIdField, entityOps, invalidRequest, entityPrimaryOp, pickExampleEntity, entityClassName, entityConstructorName, entityTypeCollisions, warnEntityTypeCollisions, ungeneratedOps, warnUngeneratedOps, deriveEntityNames, entityCollection } from './helpers/opShape'
74
+ import { OP_SUFFIX, opTypeName, opParams, opReachable, opNeedsAction, ownPoint, opActions, entityActions, entityPath, opRequestShape, entityIdField, entityDataIdField, entityRecordIdField, entityOps, introOps, invalidRequest, entityPrimaryOp, pickExampleEntity, entityClassName, entityConstructorName, entityTypeCollisions, warnEntityTypeCollisions, ungeneratedOps, warnUngeneratedOps, deriveEntityNames, entityCollection } from './helpers/opShape'
75
75
  import { isReservedName, safeVarName, exampleVarName, phpEntityAccessor, entityCacheField, isRbCoreConstant, isRbSdkConstant, rbSafeTypeName, isSwiftSdkType, swiftSafeTypeName, isPhpReservedType, isPhpSdkClass, phpSafeTypeName, isTsReservedType, isTsSdkType, tsSafeTypeName, isElixirReservedType, elixirSafeTypeName, elixirTypeNames, elixirTypeName, elixirAccessorNames, elixirAccessor, tsTypeName, rbTypeName, phpTypeName, swiftTypeName, jsProp, jsOptProp, jsKey, jsQuote, luaKey, luaString, prefixLeadingDigit } from './helpers/naming'
76
76
  import { serverVariables, hasServerVariables, serverVarEnv } from './helpers/serverVars'
77
77
  import { mcpTools, MCP_READ_OPS, MCP_WRITE_OPS } from './helpers/mcpTools'
@@ -158,6 +158,7 @@ import {
158
158
  GENERATOR_URL,
159
159
  } from './helpers/packageMeta'
160
160
  import { modelText } from './helpers/text'
161
+ import { alongsideNote } from './helpers/alongside'
161
162
  import {
162
163
  npmScriptRm,
163
164
  npmScriptEnv,
@@ -1175,6 +1176,7 @@ export {
1175
1176
  entityDataIdField,
1176
1177
  entityRecordIdField,
1177
1178
  entityOps,
1179
+ introOps,
1178
1180
  entityPrimaryOp,
1179
1181
  pickExampleEntity,
1180
1182
  entityClassName,
@@ -1327,6 +1329,7 @@ export {
1327
1329
  SECURITY_EMAIL,
1328
1330
  GENERATOR_URL,
1329
1331
  modelText,
1332
+ alongsideNote,
1330
1333
  npmScriptRm,
1331
1334
  npmScriptEnv,
1332
1335
  npmScriptTestSome,