@voxgig/sdkgen 4.45.0 → 4.47.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 (276) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/action/check.js +73 -4
  3. package/dist/action/check.js.map +1 -1
  4. package/dist/action/copies.js +1 -0
  5. package/dist/action/copies.js.map +1 -1
  6. package/dist/action/doctor.d.ts +26 -2
  7. package/dist/action/doctor.js +208 -11
  8. package/dist/action/doctor.js.map +1 -1
  9. package/dist/action/package.d.ts +1 -1
  10. package/dist/action/package.js +15 -16
  11. package/dist/action/package.js.map +1 -1
  12. package/dist/action/remove.js +16 -4
  13. package/dist/action/remove.js.map +1 -1
  14. package/dist/action/resolve.d.ts +1 -0
  15. package/dist/action/resolve.js +10 -4
  16. package/dist/action/resolve.js.map +1 -1
  17. package/dist/action/target.d.ts +2 -1
  18. package/dist/action/target.js +50 -11
  19. package/dist/action/target.js.map +1 -1
  20. package/dist/admin/status.d.ts +7 -1
  21. package/dist/admin/status.js +34 -5
  22. package/dist/admin/status.js.map +1 -1
  23. package/dist/cmp/AgentGuide.js +46 -23
  24. package/dist/cmp/AgentGuide.js.map +1 -1
  25. package/dist/cmp/AgentGuideContent.d.ts +9 -7
  26. package/dist/cmp/AgentGuideContent.js +73 -43
  27. package/dist/cmp/AgentGuideContent.js.map +1 -1
  28. package/dist/cmp/AgentGuideFeature.js +19 -9
  29. package/dist/cmp/AgentGuideFeature.js.map +1 -1
  30. package/dist/cmp/AgentGuideTop.js +95 -49
  31. package/dist/cmp/AgentGuideTop.js.map +1 -1
  32. package/dist/cmp/Changelog.js +45 -4
  33. package/dist/cmp/Changelog.js.map +1 -1
  34. package/dist/cmp/Deploy.js +73 -35
  35. package/dist/cmp/Deploy.js.map +1 -1
  36. package/dist/cmp/Entity.js +1 -1
  37. package/dist/cmp/Entity.js.map +1 -1
  38. package/dist/cmp/ExternalTarget.js +10 -5
  39. package/dist/cmp/ExternalTarget.js.map +1 -1
  40. package/dist/cmp/Feature.js +12 -5
  41. package/dist/cmp/Feature.js.map +1 -1
  42. package/dist/cmp/FeatureDocs.d.ts +6 -4
  43. package/dist/cmp/FeatureDocs.js +14 -39
  44. package/dist/cmp/FeatureDocs.js.map +1 -1
  45. package/dist/cmp/FeatureHook.d.ts +7 -1
  46. package/dist/cmp/FeatureHook.js +34 -1
  47. package/dist/cmp/FeatureHook.js.map +1 -1
  48. package/dist/cmp/Main.js +1 -1
  49. package/dist/cmp/Main.js.map +1 -1
  50. package/dist/cmp/PublishWorkflow.js +89 -55
  51. package/dist/cmp/PublishWorkflow.js.map +1 -1
  52. package/dist/cmp/ReadmeErrors.js +521 -18
  53. package/dist/cmp/ReadmeErrors.js.map +1 -1
  54. package/dist/cmp/ReadmeExplanation.js +280 -44
  55. package/dist/cmp/ReadmeExplanation.js.map +1 -1
  56. package/dist/cmp/ReadmeFeatures.js +16 -7
  57. package/dist/cmp/ReadmeFeatures.js.map +1 -1
  58. package/dist/cmp/ReadmeIntro.js +4 -3
  59. package/dist/cmp/ReadmeIntro.js.map +1 -1
  60. package/dist/cmp/ReadmeModel.js +2 -2
  61. package/dist/cmp/ReadmeModel.js.map +1 -1
  62. package/dist/cmp/ReadmeRefFeatures.js +34 -24
  63. package/dist/cmp/ReadmeRefFeatures.js.map +1 -1
  64. package/dist/cmp/ReadmeStation.js +12 -9
  65. package/dist/cmp/ReadmeStation.js.map +1 -1
  66. package/dist/cmp/ReadmeTop.js +479 -382
  67. package/dist/cmp/ReadmeTop.js.map +1 -1
  68. package/dist/cmp/ReadmeUnions.js +8 -2
  69. package/dist/cmp/ReadmeUnions.js.map +1 -1
  70. package/dist/cmp/Registered.js +1 -1
  71. package/dist/cmp/Registered.js.map +1 -1
  72. package/dist/cmp/Security.js +26 -5
  73. package/dist/cmp/Security.js.map +1 -1
  74. package/dist/cmp/Test.js +1 -1
  75. package/dist/cmp/Test.js.map +1 -1
  76. package/dist/helpers/alongside.d.ts +2 -3
  77. package/dist/helpers/alongside.js +16 -15
  78. package/dist/helpers/alongside.js.map +1 -1
  79. package/dist/helpers/applicability.d.ts +3 -1
  80. package/dist/helpers/applicability.js +40 -1
  81. package/dist/helpers/applicability.js.map +1 -1
  82. package/dist/helpers/component.js +9 -1
  83. package/dist/helpers/component.js.map +1 -1
  84. package/dist/helpers/copymerge.d.ts +3 -0
  85. package/dist/helpers/copymerge.js +43 -10
  86. package/dist/helpers/copymerge.js.map +1 -1
  87. package/dist/helpers/definitionPlan.js +0 -1
  88. package/dist/helpers/definitionPlan.js.map +1 -1
  89. package/dist/helpers/doccheck.d.ts +11 -0
  90. package/dist/helpers/doccheck.js +146 -0
  91. package/dist/helpers/doccheck.js.map +1 -0
  92. package/dist/helpers/doctext.d.ts +11 -0
  93. package/dist/helpers/doctext.js +85 -0
  94. package/dist/helpers/doctext.js.map +1 -0
  95. package/dist/helpers/exampleCall.d.ts +16 -0
  96. package/dist/helpers/exampleCall.js +334 -0
  97. package/dist/helpers/exampleCall.js.map +1 -0
  98. package/dist/helpers/exportnames.d.ts +4 -0
  99. package/dist/helpers/exportnames.js +35 -0
  100. package/dist/helpers/exportnames.js.map +1 -0
  101. package/dist/helpers/facts.d.ts +2 -1
  102. package/dist/helpers/facts.js +210 -5
  103. package/dist/helpers/facts.js.map +1 -1
  104. package/dist/helpers/flowGuard.d.ts +1 -1
  105. package/dist/helpers/flowGuard.js +20 -7
  106. package/dist/helpers/flowGuard.js.map +1 -1
  107. package/dist/helpers/generated.d.ts +1 -0
  108. package/dist/helpers/generated.js +1 -1
  109. package/dist/helpers/generated.js.map +1 -1
  110. package/dist/helpers/graphqlPoint.d.ts +2 -1
  111. package/dist/helpers/graphqlPoint.js +17 -0
  112. package/dist/helpers/graphqlPoint.js.map +1 -1
  113. package/dist/helpers/guardModel.d.ts +2 -0
  114. package/dist/helpers/guardModel.js +41 -0
  115. package/dist/helpers/guardModel.js.map +1 -0
  116. package/dist/helpers/manifest.d.ts +2 -1
  117. package/dist/helpers/manifest.js +16 -0
  118. package/dist/helpers/manifest.js.map +1 -1
  119. package/dist/helpers/mcpTools.d.ts +2 -1
  120. package/dist/helpers/mcpTools.js +8 -1
  121. package/dist/helpers/mcpTools.js.map +1 -1
  122. package/dist/helpers/modelcheck.d.ts +2 -1
  123. package/dist/helpers/modelcheck.js +13 -0
  124. package/dist/helpers/modelcheck.js.map +1 -1
  125. package/dist/helpers/opExample.d.ts +9 -2
  126. package/dist/helpers/opExample.js +22 -2
  127. package/dist/helpers/opExample.js.map +1 -1
  128. package/dist/helpers/opShape.d.ts +2 -1
  129. package/dist/helpers/opShape.js +29 -17
  130. package/dist/helpers/opShape.js.map +1 -1
  131. package/dist/helpers/packageMeta.d.ts +6 -4
  132. package/dist/helpers/packageMeta.js +88 -53
  133. package/dist/helpers/packageMeta.js.map +1 -1
  134. package/dist/helpers/placement.d.ts +15 -0
  135. package/dist/helpers/placement.js +76 -0
  136. package/dist/helpers/placement.js.map +1 -0
  137. package/dist/helpers/semver.d.ts +3 -1
  138. package/dist/helpers/semver.js +28 -0
  139. package/dist/helpers/semver.js.map +1 -1
  140. package/dist/helpers/serverVars.js +3 -2
  141. package/dist/helpers/serverVars.js.map +1 -1
  142. package/dist/helpers/shipped.d.ts +2 -1
  143. package/dist/helpers/shipped.js +12 -0
  144. package/dist/helpers/shipped.js.map +1 -1
  145. package/dist/helpers/sourcestring.d.ts +3 -0
  146. package/dist/helpers/sourcestring.js +43 -0
  147. package/dist/helpers/sourcestring.js.map +1 -0
  148. package/dist/helpers/stdrep.d.ts +1 -1
  149. package/dist/helpers/stdrep.js +5 -1
  150. package/dist/helpers/stdrep.js.map +1 -1
  151. package/dist/helpers/surface.d.ts +7 -0
  152. package/dist/helpers/surface.js +69 -0
  153. package/dist/helpers/surface.js.map +1 -0
  154. package/dist/helpers/targetguard.d.ts +13 -0
  155. package/dist/helpers/targetguard.js +65 -0
  156. package/dist/helpers/targetguard.js.map +1 -0
  157. package/dist/helpers/text.d.ts +3 -1
  158. package/dist/helpers/text.js +16 -0
  159. package/dist/helpers/text.js.map +1 -1
  160. package/dist/helpers/textguard.d.ts +31 -0
  161. package/dist/helpers/textguard.js +157 -0
  162. package/dist/helpers/textguard.js.map +1 -0
  163. package/dist/helpers/title.d.ts +4 -0
  164. package/dist/helpers/title.js +52 -0
  165. package/dist/helpers/title.js.map +1 -0
  166. package/dist/sdkgen.d.ts +4 -6
  167. package/dist/sdkgen.js +72 -63
  168. package/dist/sdkgen.js.map +1 -1
  169. package/dist/testkit.d.ts +7 -2
  170. package/dist/testkit.js +27 -20
  171. package/dist/testkit.js.map +1 -1
  172. package/dist/tsconfig.tsbuildinfo +1 -1
  173. package/dist/utility.js +2 -1
  174. package/dist/utility.js.map +1 -1
  175. package/model/fact.aontu +150 -0
  176. package/model/sdkgen.aontu +15 -3
  177. package/package.json +3 -1
  178. package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +2 -2
  179. package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +1 -1
  180. package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +12 -3
  181. package/project/.sdk/src/cmp/clojure/ReadmeQuick_clojure.ts +1 -1
  182. package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +1 -1
  183. package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +1 -1
  184. package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +1 -1
  185. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +1 -1
  186. package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +1 -1
  187. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +1 -1
  188. package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +1 -1
  189. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +1 -1
  190. package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +1 -1
  191. package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +1 -1
  192. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +1 -1
  193. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +1 -1
  194. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +1 -1
  195. package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +1 -1
  196. package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +1 -1
  197. package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +4 -1
  198. package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +2 -1
  199. package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -0
  200. package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -1
  201. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +1 -1
  202. package/project/.sdk/src/cmp/ts/TestDefinition_ts.ts +3 -1
  203. package/project/.sdk/src/cmp/zig/ReadmeOptions_zig.ts +1 -1
  204. package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +3 -3
  205. package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
  206. package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +3 -1
  207. package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +2 -1
  208. package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +11 -2
  209. package/project/sdkgen-package.json +1 -1
  210. package/src/action/check.ts +99 -4
  211. package/src/action/copies.ts +2 -0
  212. package/src/action/doctor.ts +304 -15
  213. package/src/action/package.ts +11 -13
  214. package/src/action/remove.ts +20 -5
  215. package/src/action/resolve.ts +11 -4
  216. package/src/action/target.ts +66 -15
  217. package/src/admin/status.ts +25 -5
  218. package/src/cmp/AgentGuide.ts +52 -25
  219. package/src/cmp/AgentGuideContent.ts +75 -43
  220. package/src/cmp/AgentGuideFeature.ts +21 -10
  221. package/src/cmp/AgentGuideTop.ts +119 -49
  222. package/src/cmp/Changelog.ts +56 -5
  223. package/src/cmp/Deploy.ts +81 -40
  224. package/src/cmp/Entity.ts +1 -1
  225. package/src/cmp/ExternalTarget.ts +12 -6
  226. package/src/cmp/Feature.ts +13 -6
  227. package/src/cmp/FeatureDocs.ts +21 -40
  228. package/src/cmp/FeatureHook.ts +38 -1
  229. package/src/cmp/Main.ts +1 -1
  230. package/src/cmp/PublishWorkflow.ts +94 -60
  231. package/src/cmp/ReadmeErrors.ts +555 -25
  232. package/src/cmp/ReadmeExplanation.ts +316 -52
  233. package/src/cmp/ReadmeFeatures.ts +18 -8
  234. package/src/cmp/ReadmeIntro.ts +4 -3
  235. package/src/cmp/ReadmeModel.ts +2 -2
  236. package/src/cmp/ReadmeRefFeatures.ts +39 -27
  237. package/src/cmp/ReadmeStation.ts +13 -16
  238. package/src/cmp/ReadmeTop.ts +538 -397
  239. package/src/cmp/ReadmeUnions.ts +10 -2
  240. package/src/cmp/Registered.ts +1 -1
  241. package/src/cmp/Security.ts +35 -7
  242. package/src/cmp/Test.ts +1 -1
  243. package/src/helpers/alongside.ts +16 -19
  244. package/src/helpers/applicability.ts +44 -1
  245. package/src/helpers/component.ts +11 -1
  246. package/src/helpers/copymerge.ts +58 -10
  247. package/src/helpers/definitionPlan.ts +0 -1
  248. package/src/helpers/doccheck.ts +174 -0
  249. package/src/helpers/doctext.ts +115 -0
  250. package/src/helpers/exampleCall.ts +415 -0
  251. package/src/helpers/exportnames.ts +47 -0
  252. package/src/helpers/facts.ts +259 -5
  253. package/src/helpers/flowGuard.ts +22 -7
  254. package/src/helpers/generated.ts +3 -1
  255. package/src/helpers/graphqlPoint.ts +20 -1
  256. package/src/helpers/guardModel.ts +50 -0
  257. package/src/helpers/manifest.ts +19 -0
  258. package/src/helpers/mcpTools.ts +11 -1
  259. package/src/helpers/modelcheck.ts +16 -0
  260. package/src/helpers/opExample.ts +34 -2
  261. package/src/helpers/opShape.ts +29 -16
  262. package/src/helpers/packageMeta.ts +89 -52
  263. package/src/helpers/placement.ts +114 -0
  264. package/src/helpers/semver.ts +35 -0
  265. package/src/helpers/serverVars.ts +4 -2
  266. package/src/helpers/shipped.ts +13 -0
  267. package/src/helpers/sourcestring.ts +47 -0
  268. package/src/helpers/stdrep.ts +6 -1
  269. package/src/helpers/surface.ts +82 -0
  270. package/src/helpers/targetguard.ts +91 -0
  271. package/src/helpers/text.ts +22 -0
  272. package/src/helpers/textguard.ts +208 -0
  273. package/src/helpers/title.ts +59 -0
  274. package/src/sdkgen.ts +82 -78
  275. package/src/testkit.ts +42 -20
  276. package/src/utility.ts +2 -1
@@ -395,19 +395,17 @@ function invalidRequest(ent: any):
395
395
  }
396
396
 
397
397
 
398
- // The entity's ACTIVE op names, in canonical CRUD order, then any others
399
- // sorted. Doc generators gate an op example on this, NOT on the raw
400
- // `Object.keys(ent.op)`: an `active: false` op generates no method, and an op
401
- // whose every route is an action is refused without one, so a plain example
402
- // of either would fail.
398
+ // The entity's ACTIVE op names that the bundled targets generate, in canonical
399
+ // CRUD order. Doc generators gate an op example on this, NOT on the raw
400
+ // `Object.keys(ent.op)`: an op outside `CANON_OP_ORDER` generates no method,
401
+ // and an op whose every route is an action is refused without one, so a plain
402
+ // example of either would fail.
403
403
  const CANON_OP_ORDER = ['list', 'load', 'create', 'update', 'patch', 'remove']
404
404
 
405
405
  function entityOps(ent: any): string[] {
406
406
  const ops = (ent && ent.op) || {}
407
- const active = Object.keys(ops).filter((o: string) =>
407
+ return CANON_OP_ORDER.filter((o: string) =>
408
408
  ops[o] && ops[o].active !== false && !opNeedsAction(ops[o]))
409
- return CANON_OP_ORDER.filter((o) => active.includes(o))
410
- .concat(active.filter((o) => !CANON_OP_ORDER.includes(o)).sort())
411
409
  }
412
410
 
413
411
 
@@ -422,11 +420,22 @@ function introOps(model: any): string[] {
422
420
  }
423
421
  }
424
422
  const names = CANON_OP_ORDER.filter((o) => found.has(o))
425
- .concat([...found].filter((o) => !CANON_OP_ORDER.includes(o)))
426
423
  return 0 < names.length ? names : ['list', 'load']
427
424
  }
428
425
 
429
426
 
427
+ // The operations the active entities have a generated method for, in
428
+ // canonical order; none when no entity has one.
429
+ function generatedOps(model: any): string[] {
430
+ const entity = getModelPath(model, `main.${KIT}.entity`, { required: false }) || {}
431
+ const found = new Set<string>()
432
+ for (const e of Object.values(entity) as any[]) {
433
+ for (const o of entityOps(e)) found.add(o)
434
+ }
435
+ return CANON_OP_ORDER.filter((o) => found.has(o))
436
+ }
437
+
438
+
430
439
  type UngeneratedOp = { entity: string, op: string, points: string[] }
431
440
 
432
441
 
@@ -470,8 +479,8 @@ function ungeneratedOps(model: any): UngeneratedOp[] {
470
479
  }
471
480
 
472
481
 
473
- // Speaks only for the bundled targets: a target from another package may
474
- // generate more ops, so it is named as outside the claim rather than judged.
482
+ // Speaks only for the bundled targets: a target from another package or the
483
+ // project's own may generate more ops, so it is named outside the claim.
475
484
  function warnUngeneratedOps(
476
485
  model: any, log: any, origins: TargetOrigins,
477
486
  ): UngeneratedOp[] {
@@ -481,11 +490,14 @@ function warnUngeneratedOps(
481
490
  (0 < d.points.length ? ` (${d.points.join(', ')})` : ''))
482
491
  const generated = CANON_OP_ORDER.slice(0, -1).join(', ') + ' and ' +
483
492
  CANON_OP_ORDER[CANON_OP_ORDER.length - 1]
484
- const external = origins.external.map((t) => `${t.name} from ${t.from}`)
493
+ const outside = [
494
+ ...origins.external.map((t) => `${t.name} from ${t.from}`),
495
+ ...origins.owned.map((name) => `${name} (the project's own)`),
496
+ ]
485
497
  log.warn({
486
498
  point: 'entity-op-ungenerated', ops: dropped,
487
- bundled: origins.bundled, external: origins.external,
488
- note: 0 === external.length
499
+ bundled: origins.bundled, external: origins.external, owned: origins.owned,
500
+ note: 0 === outside.length
489
501
  ? `operation(s) in the model that the bundled targets do not ` +
490
502
  `generate (each generates ${generated} only), so the SDK has no ` +
491
503
  `method for them: ${listed.join(', ')}. To reach one, reclassify it ` +
@@ -494,8 +506,8 @@ function warnUngeneratedOps(
494
506
  : `operation(s) in the model that the bundled targets ` +
495
507
  `(${origins.bundled.join(', ')}) do not generate (each generates ` +
496
508
  `${generated} only), so their SDKs have no method for them: ` +
497
- `${listed.join(', ')}. Targets installed from elsewhere may ` +
498
- `generate them, so they are not judged here: ${external.join(', ')}. ` +
509
+ `${listed.join(', ')}. Targets from elsewhere may generate them, ` +
510
+ `so they are not judged here: ${outside.join(', ')}. ` +
499
511
  `To reach one in a bundled target, reclassify it in the guide ` +
500
512
  `(.sdk/model/guide/guide.aontu)`,
501
513
  })
@@ -792,6 +804,7 @@ export {
792
804
  entityRecordIdField,
793
805
  entityOps,
794
806
  introOps,
807
+ generatedOps,
795
808
  invalidRequest,
796
809
  entityPrimaryOp,
797
810
  pickExampleEntity,
@@ -3,33 +3,16 @@ import { each } from 'jostraca'
3
3
 
4
4
  import { KIT, nom } from '@voxgig/apidef'
5
5
 
6
- import { isConsumer } from './alongside'
6
+ import { surfaceName, surfaceOf } from './surface'
7
+ import { fact } from './facts'
7
8
  import { kindCollection } from './kindCollection'
8
- import { modelText } from './text'
9
+ import { LANG_LABEL, langLabel } from './title'
9
10
 
10
11
  const PUBLISHER = 'Voxgig'
11
12
  const PUBLISHER_URL = 'https://voxgig.com'
12
13
  const SECURITY_EMAIL = 'security@voxgig.com'
13
14
  const GENERATOR_URL = 'https://github.com/voxgig/sdkgen'
14
15
 
15
- const LANG_LABEL: Record<string, string> = {
16
- ts: 'TypeScript',
17
- js: 'JavaScript',
18
- py: 'Python',
19
- php: 'PHP',
20
- rb: 'Ruby',
21
- lua: 'Lua',
22
- go: 'Go',
23
- 'go-cli': 'Go CLI',
24
- 'go-mcp': 'Go MCP server',
25
- 'py-data': 'Python Data',
26
- }
27
-
28
- function langLabel(target: string): string {
29
- return LANG_LABEL[target] || target
30
- }
31
-
32
-
33
16
  function originName(model: any, target: string): string {
34
17
  const orig = model?.main?.[KIT]?.target?.[target]?.origname
35
18
  return (null != orig && '' !== orig) ? String(orig) : target
@@ -40,20 +23,22 @@ function sdkName(slug: string): string {
40
23
  }
41
24
 
42
25
 
43
- function repoInfo(model: any) {
26
+ function repoInfo(model: any, target?: string) {
44
27
  const slug = model.name
45
28
  const origin = model.origin || 'voxgig-sdk'
46
29
 
47
30
  const declared = (model && model.main && model.main[KIT] && model.main[KIT].repo) || {}
31
+ const targetRepo = null == target ? '' : model?.main?.[KIT]?.target?.[target]?.output?.repo
48
32
 
49
33
  const host = '' === (declared.host || '') ? 'github.com' : (declared.host || 'github.com')
50
- const path = '' === (declared.path || '') ? `${origin}/${sdkName(slug)}` : String(declared.path)
34
+ const path = null != targetRepo && '' !== targetRepo ? String(targetRepo) :
35
+ '' === (declared.path || '') ? `${origin}/${sdkName(slug)}` : String(declared.path)
51
36
 
52
37
  const seg = path.split('/')
53
38
  const repo = seg[seg.length - 1]
54
39
 
55
40
  const repoUrl = `https://${host}/${path}`
56
- const pages = repoPages(host, repoUrl)
41
+ const pages = repoPages(host, repoUrl, releaseBranch(model))
57
42
 
58
43
  return {
59
44
  slug,
@@ -73,12 +58,12 @@ function repoInfo(model: any) {
73
58
 
74
59
  // GitLab keeps a project's pages under `/-/`, and Bitbucket lists its tags
75
60
  // among its downloads; any other host is laid out as GitHub is.
76
- function repoPages(host: string, repoUrl: string) {
61
+ function repoPages(host: string, repoUrl: string, branch: string) {
77
62
  if (host.includes('gitlab')) {
78
63
  return {
79
64
  name: 'GitLab',
80
65
  issues: `${repoUrl}/-/issues`,
81
- changelog: `${repoUrl}/-/blob/main/CHANGELOG.md`,
66
+ changelog: `${repoUrl}/-/blob/${branch}/CHANGELOG.md`,
82
67
  releases: `${repoUrl}/-/releases`,
83
68
  tags: `${repoUrl}/-/tags`,
84
69
  }
@@ -87,7 +72,7 @@ function repoPages(host: string, repoUrl: string) {
87
72
  return {
88
73
  name: 'Bitbucket',
89
74
  issues: `${repoUrl}/issues`,
90
- changelog: `${repoUrl}/src/main/CHANGELOG.md`,
75
+ changelog: `${repoUrl}/src/${branch}/CHANGELOG.md`,
91
76
  releases: `${repoUrl}/downloads/?tab=tags`,
92
77
  tags: `${repoUrl}/downloads/?tab=tags`,
93
78
  }
@@ -95,13 +80,19 @@ function repoPages(host: string, repoUrl: string) {
95
80
  return {
96
81
  name: host.includes('github') ? 'GitHub' : host,
97
82
  issues: `${repoUrl}/issues`,
98
- changelog: `${repoUrl}/blob/main/CHANGELOG.md`,
83
+ changelog: `${repoUrl}/blob/${branch}/CHANGELOG.md`,
99
84
  releases: `${repoUrl}/releases`,
100
85
  tags: `${repoUrl}/tags`,
101
86
  }
102
87
  }
103
88
 
104
89
 
90
+ function releaseBranch(model: any): string {
91
+ const branch = model?.main?.[KIT]?.doc?.ci?.branch
92
+ return 'string' === typeof branch && '' !== branch ? branch : 'main'
93
+ }
94
+
95
+
105
96
  function docsSiteUrl(model: any): string {
106
97
  const { host, path } = repoInfo(model)
107
98
 
@@ -171,36 +162,60 @@ function goPackageIdent(model: any, target: string): string {
171
162
  }
172
163
 
173
164
 
165
+ // A registry named `none` is no registry: c, cpp and zig declare it.
174
166
  function registryState(model: any, target: string): 'tag' | 'pending' | 'active' | 'inactive' {
175
- const eco = originName(model, target)
176
- if ('go' === eco || 'go-cli' === eco || 'go-mcp' === eco) return 'tag'
177
167
  const reg = model?.main?.[KIT]?.target?.[target]?.publish?.registry
178
- if (null == reg || '' === (reg.name || '')) return 'tag'
168
+ if (null == reg || '' === registryName(model, target) || goFamily(model, target)) return 'tag'
179
169
  if (true === reg.active) return 'active'
180
170
  const s = reg.state
181
171
  if ('active' === s || 'inactive' === s || 'pending' === s) return s
182
172
  return 'pending'
183
173
  }
184
174
 
185
- // True only when the package is actually live on its registry (so a README
186
- // may print the real `npm install`/`pip install`/... command). Everything
187
- // else — pending, inactive, tag-only — installs from the git tag instead.
175
+ // Only a package live on its registry gets a registry install command; any
176
+ // other installs from the git tag.
188
177
  function isPublished(model: any, target: string): boolean {
189
178
  return 'active' === registryState(model, target)
190
179
  }
191
180
 
192
- // The registry a target uploads to (npm | pypi | packagist | ...), or ''
193
- // for tag-only ports. Used in the "not yet on <registry>" pending message.
194
- function registryName(model: any, target: string): string {
195
- const reg = model?.main?.[KIT]?.target?.[target]?.publish?.registry
196
- return (reg && reg.name) ? String(reg.name) : ''
181
+ // Go installs from its git tag whatever the registry, as does a target built on it.
182
+ function goFamily(model: any, target: string): boolean {
183
+ if ('go' === originName(model, target)) return true
184
+ const wraps = fact(model.main[KIT].target[target], 'consumes')
185
+ return '' !== wraps && 'go' === originName(model, wraps)
197
186
  }
198
187
 
199
- // The vendor / git-tag install pointer for a NOT-yet-published target. For
200
- // go this is the canonical install (`go get <module>@latest`, which the Go
201
- // proxy resolves from the `go/vX.Y.Z` tag); go-cli and go-mcp get ''. For registry
202
- // ports it is a short "not yet on <registry> — install from the git tag"
203
- // pointer carrying the tags URL.
188
+ // The registry a target uploads to (npm | pypi | packagist | ...), or '' for a tag-only port.
189
+ function registryName(model: any, target: string): string {
190
+ const reg = model?.main?.[KIT]?.target?.[target]?.publish?.registry
191
+ const name = (reg && reg.name) ? String(reg.name) : ''
192
+ return 'none' === name ? '' : name
193
+ }
194
+
195
+ const REGISTRY_LABEL: Record<string, string> = {
196
+ npm: 'npm',
197
+ pypi: 'PyPI',
198
+ packagist: 'Packagist',
199
+ rubygems: 'RubyGems',
200
+ luarocks: 'LuaRocks',
201
+ 'crates.io': 'crates.io',
202
+ nuget: 'NuGet',
203
+ 'maven-central': 'Maven Central',
204
+ clojars: 'Clojars',
205
+ hex: 'Hex',
206
+ cpan: 'CPAN',
207
+ opam: 'opam',
208
+ swiftpm: 'Swift Package Manager',
209
+ }
210
+
211
+ function registryLabel(name: string): string {
212
+ return REGISTRY_LABEL[name] || name
213
+ }
214
+
215
+ // The install route for a target not on a registry: `go get <module>@latest`
216
+ // for go, resolved by the proxy from the `go/vX.Y.Z` tag. go-cli, go-mcp and a
217
+ // port with no registry get '', and their README's build steps are the route.
218
+ // A declared registry gets a "not yet on <registry>" pointer to the git tag.
204
219
  function vendorCommand(model: any, target: string): string {
205
220
  const { tagsUrl } = repoInfo(model)
206
221
  switch (originName(model, target)) {
@@ -218,15 +233,15 @@ function vendorCommand(model: any, target: string): string {
218
233
  return ''
219
234
  default: {
220
235
  const reg = registryName(model, target)
221
- return `not yet on ${reg || 'the registry'} — install from the git tag: ${tagsUrl}`
236
+ return '' === reg ? '' : `not yet on ${reg} — install from the git tag: ${tagsUrl}`
222
237
  }
223
238
  }
224
239
  }
225
240
 
241
+ // The API's name fact without a trailing "API", for "the <name> public API".
226
242
  function apiName(model: any): string {
227
- const info = modelText(model)
228
- const raw = (null != info.title ? String(info.title) : '').trim()
229
- const stripped = raw.replace(/\s*API\s*$/i, '').trim()
243
+ const stripped = String(fact(model.main[KIT], 'apiName').raw).trim()
244
+ .replace(/\s*API\s*$/i, '').trim()
230
245
  return stripped || nom(model, 'Name') || model.name
231
246
  }
232
247
 
@@ -286,7 +301,7 @@ const NAMED_CONSUMERS = ['go-cli', 'go-mcp', 'py-data']
286
301
 
287
302
  function hasPackageName(model: any, target: string): boolean {
288
303
  const declared = model?.main?.[KIT]?.target?.[target]
289
- if (!isConsumer(declared)) {
304
+ if ('sdk' === surfaceOf(declared)) {
290
305
  return true
291
306
  }
292
307
  const pkg = declared?.publish?.registry?.package
@@ -317,13 +332,28 @@ function installCommand(model: any, target: string): string {
317
332
  return `luarocks install ${packageName(model, target)}`
318
333
  case 'go':
319
334
  return `go get ${packageName(model, target)}`
335
+ case 'rust':
336
+ return `cargo add ${packageName(model, target)}`
337
+ case 'csharp':
338
+ return `dotnet add package ${packageName(model, target)}`
339
+ case 'perl':
340
+ return `cpanm ${packageName(model, target)}`
341
+ case 'ocaml':
342
+ return `opam install ${packageName(model, target)}`
343
+ // No package manager installs these: the release tag is the route.
344
+ case 'c':
345
+ case 'zig':
346
+ return `install from the git tag: ${repoInfo(model).tagsUrl}`
320
347
  default:
321
348
  return ''
322
349
  }
323
350
  }
324
351
 
325
352
  function pkgDescription(model: any, target: string): string {
326
- return `Unofficial generated ${langLabel(originName(model, target))} SDK` +
353
+ const what = surfaceName(model.main[KIT].target[target])
354
+ return publisherInfo(model).official ?
355
+ `Generated ${what} for the ${apiName(model)} API.` :
356
+ `Unofficial generated ${what}` +
327
357
  ` for the ${apiName(model)} public API.` +
328
358
  ` Not affiliated with or endorsed by the upstream API provider.`
329
359
  }
@@ -338,8 +368,12 @@ function tomlString(s: string): string {
338
368
  // SECURITY.md. Generic on the upstream owner (owner names are only ~45%
339
369
  // reliably known across the fleet).
340
370
  function nonAffiliation(model: any): string {
341
- return `This is an unofficial SDK for the ${apiName(model)} public API, generated by ` +
342
- `${publisherInfo(model).name} with [\`@voxgig/sdkgen\`](${GENERATOR_URL}). ` +
371
+ const { name, official } = publisherInfo(model)
372
+ return official ?
373
+ `This SDK for the ${apiName(model)} API is generated by ${name} with ` +
374
+ `[\`@voxgig/sdkgen\`](${GENERATOR_URL}).` :
375
+ `This is an unofficial SDK for the ${apiName(model)} public API, generated by ` +
376
+ `${name} with [\`@voxgig/sdkgen\`](${GENERATOR_URL}). ` +
343
377
  `It is not affiliated with, endorsed by, or sponsored by the upstream API provider.`
344
378
  }
345
379
 
@@ -355,7 +389,7 @@ function declaredText(value: any): string {
355
389
 
356
390
 
357
391
  // Voxgig's url and security contact apply only while Voxgig is the publisher.
358
- function publisherInfo(model: any): { name: string, url: string, security: string } {
392
+ function publisherInfo(model: any): { name: string, url: string, security: string, official: boolean } {
359
393
  const declared = model?.main?.[KIT]?.publisher || {}
360
394
 
361
395
  const name = declaredText(declared.name) || PUBLISHER
@@ -365,6 +399,7 @@ function publisherInfo(model: any): { name: string, url: string, security: strin
365
399
  name,
366
400
  url: declaredText(declared.url) || (own ? PUBLISHER_URL : ''),
367
401
  security: declaredText(declared.security) || (own ? SECURITY_EMAIL : ''),
402
+ official: true === declared.official,
368
403
  }
369
404
  }
370
405
 
@@ -428,6 +463,7 @@ export {
428
463
  langLabel,
429
464
  originName,
430
465
  repoInfo,
466
+ releaseBranch,
431
467
  apiName,
432
468
  packageName,
433
469
  hasPackageName,
@@ -435,6 +471,7 @@ export {
435
471
  registryState,
436
472
  isPublished,
437
473
  registryName,
474
+ registryLabel,
438
475
  vendorCommand,
439
476
  pkgDescription,
440
477
  tomlString,
@@ -0,0 +1,114 @@
1
+ import Path from 'node:path'
2
+
3
+ import { SdkGenError } from '../utility'
4
+
5
+
6
+ type ExternalOverride = {
7
+ path?: string
8
+ sdkrel?: string
9
+ enclosing?: boolean
10
+ }
11
+
12
+
13
+ type Place = 'root' | 'folder' | 'external'
14
+
15
+
16
+ // The run override for each target: the `external` build option, with
17
+ // SDKGEN_EXTERNAL merged over it. `named` lists the targets the variable names.
18
+ function readOverride(
19
+ declared: Record<string, ExternalOverride> | undefined,
20
+ raw: string | undefined,
21
+ targets: string[],
22
+ ): { override: Record<string, ExternalOverride>, named: string[] } {
23
+ const base = declared || {}
24
+
25
+ if (null == raw || '' === raw.trim()) {
26
+ return { override: base, named: [] }
27
+ }
28
+
29
+ let parsed: any
30
+
31
+ try {
32
+ parsed = JSON.parse(raw)
33
+ }
34
+ catch (err: any) {
35
+ throw new SdkGenError(
36
+ 'SDKGEN_EXTERNAL is not valid JSON: ' + (err?.message || err) +
37
+ '\n Expected an object keyed by item name, for example:' +
38
+ '\n {"seneca-provider":{"path":"../..","sdkrel":".sdksrc/acme-sdk","enclosing":true}}' +
39
+ '\n Got: ' + raw.slice(0, 200))
40
+ }
41
+
42
+ if (null == parsed || 'object' !== typeof parsed || Array.isArray(parsed)) {
43
+ throw new SdkGenError(
44
+ 'SDKGEN_EXTERNAL must be a JSON OBJECT keyed by item name, for example:' +
45
+ '\n {"seneca-provider":{"path":"../..","sdkrel":".sdksrc/acme-sdk","enclosing":true}}' +
46
+ '\n Got: ' + raw.slice(0, 200))
47
+ }
48
+
49
+ // A misspelled name would otherwise change nothing and still be logged as
50
+ // an override.
51
+ const unknown = Object.keys(parsed).filter((name: string) => !targets.includes(name)).sort()
52
+ if (0 < unknown.length) {
53
+ throw new SdkGenError(
54
+ 'SDKGEN_EXTERNAL names ' + unknown.join(', ') + ', which ' +
55
+ (1 === unknown.length ? 'is not a target' : 'are not targets') + ' of this model' +
56
+ '\n Its targets are: ' + [...targets].sort().join(', '))
57
+ }
58
+
59
+ const override: Record<string, ExternalOverride> = { ...base }
60
+ for (const name of Object.keys(parsed)) {
61
+ override[name] = { ...(base[name] || {}), ...(parsed[name] || {}) }
62
+ }
63
+
64
+ return { override, named: Object.keys(parsed).sort() }
65
+ }
66
+
67
+
68
+ // A target's output for this run, as a shallow copy: the override's path
69
+ // replaces the declared one, root placement included.
70
+ function runOutput(output: any, ov?: ExternalOverride): any {
71
+ const out = { ...(output || {}) }
72
+
73
+ if (null != ov?.path && '' !== ov.path) {
74
+ out.path = ov.path
75
+ delete out.root
76
+ }
77
+ if (null != ov?.sdkrel && '' !== ov.sdkrel) {
78
+ out.sdkrel = ov.sdkrel
79
+ }
80
+
81
+ return out
82
+ }
83
+
84
+
85
+ // Where this run writes a target: the override's path, else the place fact
86
+ // of a prepared model. A target with no `output` claims no place: in tree.
87
+ function runPlace(target: any, ov?: ExternalOverride): Place {
88
+ if (null != ov?.path && '' !== ov.path) {
89
+ return 'external'
90
+ }
91
+ const place = target?.fact?.place
92
+ return 'root' === place || 'external' === place ? place : 'folder'
93
+ }
94
+
95
+
96
+ function runFolder(target: any, name: string, project: string, ov?: ExternalOverride): string {
97
+ const place = runPlace(target, ov)
98
+ return 'root' === place ? Path.resolve(project) :
99
+ 'external' === place ? Path.resolve(project, String(runOutput(target?.output, ov).path)) :
100
+ Path.resolve(project, name)
101
+ }
102
+
103
+
104
+ export type {
105
+ ExternalOverride,
106
+ Place,
107
+ }
108
+
109
+ export {
110
+ readOverride,
111
+ runOutput,
112
+ runPlace,
113
+ runFolder,
114
+ }
@@ -86,6 +86,14 @@ function satisfiesOne(version: Parts, comparator: string): boolean | undefined {
86
86
  }
87
87
 
88
88
 
89
+ // Undefined when either is not a plain version, so no order is claimed.
90
+ function compareVersions(a: string, b: string): number | undefined {
91
+ const pa = parseVersion(a)
92
+ const pb = parseVersion(b)
93
+ return null == pa || null == pb ? undefined : compare(pa, pb)
94
+ }
95
+
96
+
89
97
  // Does `version` satisfy `range`?
90
98
  //
91
99
  // `true` / `false` / `undefined` — see the note at the top: undefined means
@@ -146,7 +154,34 @@ function satisfies(version: string, range: string): boolean | undefined {
146
154
  }
147
155
 
148
156
 
157
+ // Does `range` admit a release older than `version`? Tried at the versions the
158
+ // range names and the release just below; undefined when nothing is understood.
159
+ function admitsBelow(range: string, version: string): boolean | undefined {
160
+ const v = parseVersion(version)
161
+ if (null == v) {
162
+ return undefined
163
+ }
164
+
165
+ const named: Parts[] = (String(range ?? '').match(/\d+(?:\.\d+){0,2}/g) ?? [])
166
+ .map((m: string) => {
167
+ const p = m.split('.').map(Number)
168
+ return [p[0], p[1] ?? 0, p[2] ?? 0] as Parts
169
+ })
170
+ const top = Number.MAX_SAFE_INTEGER
171
+ const below: Parts | undefined = 0 < v[2] ? [v[0], v[1], v[2] - 1] :
172
+ 0 < v[1] ? [v[0], v[1] - 1, top] : 0 < v[0] ? [v[0] - 1, top, top] : undefined
173
+
174
+ const tried = [...named, ...(null == below ? [] : [below])]
175
+ .filter((p: Parts) => 0 > compare(p, v))
176
+ .map((p: Parts) => satisfies(p.join('.'), range))
177
+
178
+ return tried.includes(true) ? true : tried.includes(undefined) ? undefined : false
179
+ }
180
+
181
+
149
182
  export {
150
183
  satisfies,
151
184
  parseVersion,
185
+ compareVersions,
186
+ admitsBelow,
152
187
  }
@@ -1,3 +1,5 @@
1
+ import { KIT } from '@voxgig/apidef'
2
+
1
3
 
2
4
  // One declared server variable. `required` is true when the spec gives no
3
5
  // usable default — the caller MUST supply it for live use.
@@ -16,7 +18,7 @@ const SERVER_VAR_RE = /\{([A-Za-z0-9_]+)\}/g
16
18
 
17
19
 
18
20
  function serverVariables(model: any): ServerVar[] {
19
- const info = model?.main?.kit?.info || model?.main?.KIT?.info
21
+ const info = model?.main?.[KIT]?.info
20
22
  const server = info?.servers?.[0]
21
23
  const url: string = server?.url || ''
22
24
  const declared = server?.variables || {}
@@ -64,7 +66,7 @@ function serverVarEnv(projenvname: string, name: string): string {
64
66
 
65
67
  // Does the model's server URL contain any {name} placeholders at all?
66
68
  function hasServerVariables(model: any): boolean {
67
- const info = model?.main?.kit?.info || model?.main?.KIT?.info
69
+ const info = model?.main?.[KIT]?.info
68
70
  const url: string = info?.servers?.[0]?.url || ''
69
71
  SERVER_VAR_RE.lastIndex = 0
70
72
  return SERVER_VAR_RE.test(url)
@@ -23,7 +23,20 @@ function factRulesFile(): string {
23
23
  return Path.join(packageRoot(), 'model', 'fact.aontu')
24
24
  }
25
25
 
26
+
27
+ // This generator's own version, from the package.json beside `dist`. Not from
28
+ // the consumer's model: `engines.sdkgen` is about the generator running.
29
+ const SDKGEN_VERSION: string = (() => {
30
+ try {
31
+ return require(Path.join(packageRoot(), 'package.json')).version
32
+ }
33
+ catch (err: any) {
34
+ return '0.0.0'
35
+ }
36
+ })()
37
+
26
38
  export {
39
+ SDKGEN_VERSION,
27
40
  packageRoot,
28
41
  schemaFile,
29
42
  scaffoldFolder,
@@ -0,0 +1,47 @@
1
+ /* Copyright (c) 2024-2026 Voxgig Ltd, MIT License */
2
+
3
+
4
+ // How each language writes `$` inside an escape-processing string literal, so
5
+ // that vendor text a copy prints never shows jostraca's template pass a `$$`.
6
+ // C's hex escape runs on through every hex digit after it, so C and C++ take
7
+ // the fixed three-digit octal form.
8
+ const DOLLAR: Record<string, string> = {
9
+ json: '\\u0024',
10
+ ts: '\\u0024',
11
+ js: '\\u0024',
12
+ java: '\\u0024',
13
+ kotlin: '\\u0024',
14
+ scala: '\\u0024',
15
+ csharp: '\\u0024',
16
+ clojure: '\\u0024',
17
+ elixir: '\\u0024',
18
+ go: '\\u0024',
19
+ py: '\\u0024',
20
+ rb: '\\u0024',
21
+ swift: '\\u{24}',
22
+ rust: '\\u{24}',
23
+ lua: '\\u{24}',
24
+ php: '\\u{24}',
25
+ perl: '\\x{24}',
26
+ zig: '\\x24',
27
+ ocaml: '\\x24',
28
+ c: '\\044',
29
+ cpp: '\\044',
30
+ }
31
+
32
+
33
+ // The text for the inside of a string literal of `lang`, which the copy
34
+ // writes double-quoted, every `$` escaped. A language with no entry fails.
35
+ function sourceString(lang: string, text: string): string {
36
+ const dollar = DOLLAR[lang]
37
+ if (null == dollar) {
38
+ throw new Error(`sdkgen: no string escape for the language '${lang}'`)
39
+ }
40
+ return String(text).replace(/\$/g, dollar)
41
+ }
42
+
43
+
44
+ export {
45
+ DOLLAR,
46
+ sourceString,
47
+ }
@@ -1,10 +1,15 @@
1
1
 
2
2
  import { envName, packageVersion, publisherInfo } from './packageMeta'
3
+ import { fact } from './facts'
3
4
 
4
5
 
5
- function ensureStdrep(ctx$: any): any {
6
+ function ensureStdrep(ctx$: any, target?: any): any {
6
7
  const stdrep = ctx$.stdrep = (ctx$.stdrep || {})
7
8
 
9
+ if (null != target) {
10
+ stdrep.SDKREL = null != ctx$.sdkrelpath ? ctx$.sdkrelpath : fact(target, 'sdkrel')
11
+ }
12
+
8
13
  if (null == stdrep.PROJECTENV) {
9
14
  stdrep.PROJECTENV = envName(ctx$.model)
10
15
  }