@voxgig/sdkgen 4.46.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 (209) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/action/check.js +58 -4
  3. package/dist/action/check.js.map +1 -1
  4. package/dist/action/doctor.d.ts +5 -0
  5. package/dist/action/doctor.js +44 -4
  6. package/dist/action/doctor.js.map +1 -1
  7. package/dist/action/package.d.ts +1 -1
  8. package/dist/action/package.js +6 -16
  9. package/dist/action/package.js.map +1 -1
  10. package/dist/action/remove.js +15 -4
  11. package/dist/action/remove.js.map +1 -1
  12. package/dist/action/resolve.d.ts +1 -0
  13. package/dist/action/resolve.js +10 -4
  14. package/dist/action/resolve.js.map +1 -1
  15. package/dist/admin/status.d.ts +7 -1
  16. package/dist/admin/status.js +34 -5
  17. package/dist/admin/status.js.map +1 -1
  18. package/dist/cmp/AgentGuide.js +27 -15
  19. package/dist/cmp/AgentGuide.js.map +1 -1
  20. package/dist/cmp/AgentGuideContent.d.ts +3 -3
  21. package/dist/cmp/AgentGuideContent.js +22 -11
  22. package/dist/cmp/AgentGuideContent.js.map +1 -1
  23. package/dist/cmp/AgentGuideFeature.js +14 -6
  24. package/dist/cmp/AgentGuideFeature.js.map +1 -1
  25. package/dist/cmp/AgentGuideTop.js +16 -8
  26. package/dist/cmp/AgentGuideTop.js.map +1 -1
  27. package/dist/cmp/Changelog.js +37 -7
  28. package/dist/cmp/Changelog.js.map +1 -1
  29. package/dist/cmp/Deploy.js +52 -16
  30. package/dist/cmp/Deploy.js.map +1 -1
  31. package/dist/cmp/Entity.js +1 -1
  32. package/dist/cmp/Entity.js.map +1 -1
  33. package/dist/cmp/ExternalTarget.js +5 -0
  34. package/dist/cmp/ExternalTarget.js.map +1 -1
  35. package/dist/cmp/Feature.js +2 -2
  36. package/dist/cmp/Feature.js.map +1 -1
  37. package/dist/cmp/Main.js +1 -1
  38. package/dist/cmp/Main.js.map +1 -1
  39. package/dist/cmp/PublishWorkflow.js +63 -53
  40. package/dist/cmp/PublishWorkflow.js.map +1 -1
  41. package/dist/cmp/ReadmeIntro.js +1 -1
  42. package/dist/cmp/ReadmeIntro.js.map +1 -1
  43. package/dist/cmp/ReadmeModel.js +2 -2
  44. package/dist/cmp/ReadmeModel.js.map +1 -1
  45. package/dist/cmp/ReadmeStation.js +3 -3
  46. package/dist/cmp/ReadmeStation.js.map +1 -1
  47. package/dist/cmp/ReadmeTop.js +57 -59
  48. package/dist/cmp/ReadmeTop.js.map +1 -1
  49. package/dist/cmp/Registered.js +1 -1
  50. package/dist/cmp/Registered.js.map +1 -1
  51. package/dist/cmp/Security.js +23 -3
  52. package/dist/cmp/Security.js.map +1 -1
  53. package/dist/cmp/Test.js +1 -1
  54. package/dist/cmp/Test.js.map +1 -1
  55. package/dist/helpers/alongside.d.ts +2 -3
  56. package/dist/helpers/alongside.js +16 -15
  57. package/dist/helpers/alongside.js.map +1 -1
  58. package/dist/helpers/applicability.d.ts +2 -1
  59. package/dist/helpers/applicability.js +14 -1
  60. package/dist/helpers/applicability.js.map +1 -1
  61. package/dist/helpers/component.js +9 -1
  62. package/dist/helpers/component.js.map +1 -1
  63. package/dist/helpers/definitionPlan.js +0 -1
  64. package/dist/helpers/definitionPlan.js.map +1 -1
  65. package/dist/helpers/doctext.js +1 -0
  66. package/dist/helpers/doctext.js.map +1 -1
  67. package/dist/helpers/facts.js +174 -4
  68. package/dist/helpers/facts.js.map +1 -1
  69. package/dist/helpers/flowGuard.d.ts +1 -1
  70. package/dist/helpers/flowGuard.js +20 -7
  71. package/dist/helpers/flowGuard.js.map +1 -1
  72. package/dist/helpers/generated.d.ts +1 -0
  73. package/dist/helpers/generated.js +1 -1
  74. package/dist/helpers/generated.js.map +1 -1
  75. package/dist/helpers/graphqlPoint.d.ts +2 -1
  76. package/dist/helpers/graphqlPoint.js +17 -0
  77. package/dist/helpers/graphqlPoint.js.map +1 -1
  78. package/dist/helpers/guardModel.d.ts +2 -0
  79. package/dist/helpers/guardModel.js +41 -0
  80. package/dist/helpers/guardModel.js.map +1 -0
  81. package/dist/helpers/manifest.d.ts +2 -1
  82. package/dist/helpers/manifest.js +16 -0
  83. package/dist/helpers/manifest.js.map +1 -1
  84. package/dist/helpers/mcpTools.d.ts +2 -1
  85. package/dist/helpers/mcpTools.js +8 -1
  86. package/dist/helpers/mcpTools.js.map +1 -1
  87. package/dist/helpers/opShape.js +17 -17
  88. package/dist/helpers/opShape.js.map +1 -1
  89. package/dist/helpers/packageMeta.d.ts +6 -4
  90. package/dist/helpers/packageMeta.js +68 -46
  91. package/dist/helpers/packageMeta.js.map +1 -1
  92. package/dist/helpers/placement.d.ts +15 -0
  93. package/dist/helpers/placement.js +76 -0
  94. package/dist/helpers/placement.js.map +1 -0
  95. package/dist/helpers/semver.d.ts +2 -1
  96. package/dist/helpers/semver.js +21 -0
  97. package/dist/helpers/semver.js.map +1 -1
  98. package/dist/helpers/serverVars.js +3 -2
  99. package/dist/helpers/serverVars.js.map +1 -1
  100. package/dist/helpers/shipped.d.ts +2 -1
  101. package/dist/helpers/shipped.js +12 -0
  102. package/dist/helpers/shipped.js.map +1 -1
  103. package/dist/helpers/sourcestring.d.ts +3 -0
  104. package/dist/helpers/sourcestring.js +43 -0
  105. package/dist/helpers/sourcestring.js.map +1 -0
  106. package/dist/helpers/stdrep.d.ts +1 -1
  107. package/dist/helpers/stdrep.js +5 -1
  108. package/dist/helpers/stdrep.js.map +1 -1
  109. package/dist/helpers/surface.d.ts +7 -0
  110. package/dist/helpers/surface.js +69 -0
  111. package/dist/helpers/surface.js.map +1 -0
  112. package/dist/helpers/targetguard.d.ts +13 -0
  113. package/dist/helpers/targetguard.js +65 -0
  114. package/dist/helpers/targetguard.js.map +1 -0
  115. package/dist/helpers/text.d.ts +3 -1
  116. package/dist/helpers/text.js +16 -0
  117. package/dist/helpers/text.js.map +1 -1
  118. package/dist/helpers/textguard.d.ts +31 -0
  119. package/dist/helpers/textguard.js +157 -0
  120. package/dist/helpers/textguard.js.map +1 -0
  121. package/dist/helpers/title.d.ts +4 -0
  122. package/dist/helpers/title.js +52 -0
  123. package/dist/helpers/title.js.map +1 -0
  124. package/dist/sdkgen.d.ts +4 -6
  125. package/dist/sdkgen.js +59 -69
  126. package/dist/sdkgen.js.map +1 -1
  127. package/dist/testkit.d.ts +6 -2
  128. package/dist/testkit.js +4 -1
  129. package/dist/testkit.js.map +1 -1
  130. package/dist/tsconfig.tsbuildinfo +1 -1
  131. package/model/fact.aontu +106 -0
  132. package/model/sdkgen.aontu +9 -1
  133. package/package.json +1 -1
  134. package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +1 -1
  135. package/project/.sdk/src/cmp/clojure/ReadmeQuick_clojure.ts +1 -1
  136. package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +1 -1
  137. package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +1 -1
  138. package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +1 -1
  139. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +1 -1
  140. package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +1 -1
  141. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +1 -1
  142. package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +1 -1
  143. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +1 -1
  144. package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +1 -1
  145. package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +1 -1
  146. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +1 -1
  147. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +1 -1
  148. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +1 -1
  149. package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +1 -1
  150. package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +1 -1
  151. package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +1 -1
  152. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +1 -1
  153. package/project/.sdk/src/cmp/ts/TestDefinition_ts.ts +3 -1
  154. package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +1 -1
  155. package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +3 -1
  156. package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +2 -1
  157. package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +11 -2
  158. package/project/sdkgen-package.json +1 -1
  159. package/src/action/check.ts +78 -4
  160. package/src/action/doctor.ts +62 -4
  161. package/src/action/package.ts +1 -13
  162. package/src/action/remove.ts +19 -5
  163. package/src/action/resolve.ts +11 -4
  164. package/src/admin/status.ts +25 -5
  165. package/src/cmp/AgentGuide.ts +28 -15
  166. package/src/cmp/AgentGuideContent.ts +22 -11
  167. package/src/cmp/AgentGuideFeature.ts +15 -6
  168. package/src/cmp/AgentGuideTop.ts +17 -8
  169. package/src/cmp/Changelog.ts +46 -6
  170. package/src/cmp/Deploy.ts +59 -20
  171. package/src/cmp/Entity.ts +1 -1
  172. package/src/cmp/ExternalTarget.ts +6 -0
  173. package/src/cmp/Feature.ts +3 -3
  174. package/src/cmp/Main.ts +1 -1
  175. package/src/cmp/PublishWorkflow.ts +66 -58
  176. package/src/cmp/ReadmeIntro.ts +1 -1
  177. package/src/cmp/ReadmeModel.ts +2 -2
  178. package/src/cmp/ReadmeStation.ts +4 -5
  179. package/src/cmp/ReadmeTop.ts +60 -60
  180. package/src/cmp/Registered.ts +1 -1
  181. package/src/cmp/Security.ts +32 -5
  182. package/src/cmp/Test.ts +1 -1
  183. package/src/helpers/alongside.ts +16 -19
  184. package/src/helpers/applicability.ts +16 -1
  185. package/src/helpers/component.ts +11 -1
  186. package/src/helpers/definitionPlan.ts +0 -1
  187. package/src/helpers/doctext.ts +3 -1
  188. package/src/helpers/facts.ts +214 -5
  189. package/src/helpers/flowGuard.ts +22 -7
  190. package/src/helpers/generated.ts +3 -1
  191. package/src/helpers/graphqlPoint.ts +20 -1
  192. package/src/helpers/guardModel.ts +50 -0
  193. package/src/helpers/manifest.ts +19 -0
  194. package/src/helpers/mcpTools.ts +11 -1
  195. package/src/helpers/opShape.ts +16 -16
  196. package/src/helpers/packageMeta.ts +67 -43
  197. package/src/helpers/placement.ts +114 -0
  198. package/src/helpers/semver.ts +26 -0
  199. package/src/helpers/serverVars.ts +4 -2
  200. package/src/helpers/shipped.ts +13 -0
  201. package/src/helpers/sourcestring.ts +47 -0
  202. package/src/helpers/stdrep.ts +6 -1
  203. package/src/helpers/surface.ts +82 -0
  204. package/src/helpers/targetguard.ts +91 -0
  205. package/src/helpers/text.ts +22 -0
  206. package/src/helpers/textguard.ts +208 -0
  207. package/src/helpers/title.ts +59 -0
  208. package/src/sdkgen.ts +65 -85
  209. package/src/testkit.ts +12 -0
@@ -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
 
@@ -173,31 +164,54 @@ function goPackageIdent(model: any, target: string): string {
173
164
 
174
165
  // A registry named `none` is no registry: c, cpp and zig declare it.
175
166
  function registryState(model: any, target: string): 'tag' | 'pending' | 'active' | 'inactive' {
176
- const eco = originName(model, target)
177
- if ('go' === eco || 'go-cli' === eco || 'go-mcp' === eco) return 'tag'
178
167
  const reg = model?.main?.[KIT]?.target?.[target]?.publish?.registry
179
- if (null == reg || '' === registryName(model, target)) return 'tag'
168
+ if (null == reg || '' === registryName(model, target) || goFamily(model, target)) return 'tag'
180
169
  if (true === reg.active) return 'active'
181
170
  const s = reg.state
182
171
  if ('active' === s || 'inactive' === s || 'pending' === s) return s
183
172
  return 'pending'
184
173
  }
185
174
 
186
- // True only when the package is actually live on its registry (so a README
187
- // may print the real `npm install`/`pip install`/... command). Everything
188
- // 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.
189
177
  function isPublished(model: any, target: string): boolean {
190
178
  return 'active' === registryState(model, target)
191
179
  }
192
180
 
193
- // The registry a target uploads to (npm | pypi | packagist | ...), or ''
194
- // for tag-only ports. Used in the "not yet on <registry>" pending message.
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)
186
+ }
187
+
188
+ // The registry a target uploads to (npm | pypi | packagist | ...), or '' for a tag-only port.
195
189
  function registryName(model: any, target: string): string {
196
190
  const reg = model?.main?.[KIT]?.target?.[target]?.publish?.registry
197
191
  const name = (reg && reg.name) ? String(reg.name) : ''
198
192
  return 'none' === name ? '' : name
199
193
  }
200
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
+
201
215
  // The install route for a target not on a registry: `go get <module>@latest`
202
216
  // for go, resolved by the proxy from the `go/vX.Y.Z` tag. go-cli, go-mcp and a
203
217
  // port with no registry get '', and their README's build steps are the route.
@@ -224,10 +238,10 @@ function vendorCommand(model: any, target: string): string {
224
238
  }
225
239
  }
226
240
 
241
+ // The API's name fact without a trailing "API", for "the <name> public API".
227
242
  function apiName(model: any): string {
228
- const info = modelText(model)
229
- const raw = (null != info.title ? String(info.title) : '').trim()
230
- 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()
231
245
  return stripped || nom(model, 'Name') || model.name
232
246
  }
233
247
 
@@ -287,7 +301,7 @@ const NAMED_CONSUMERS = ['go-cli', 'go-mcp', 'py-data']
287
301
 
288
302
  function hasPackageName(model: any, target: string): boolean {
289
303
  const declared = model?.main?.[KIT]?.target?.[target]
290
- if (!isConsumer(declared)) {
304
+ if ('sdk' === surfaceOf(declared)) {
291
305
  return true
292
306
  }
293
307
  const pkg = declared?.publish?.registry?.package
@@ -336,7 +350,10 @@ function installCommand(model: any, target: string): string {
336
350
  }
337
351
 
338
352
  function pkgDescription(model: any, target: string): string {
339
- 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}` +
340
357
  ` for the ${apiName(model)} public API.` +
341
358
  ` Not affiliated with or endorsed by the upstream API provider.`
342
359
  }
@@ -351,8 +368,12 @@ function tomlString(s: string): string {
351
368
  // SECURITY.md. Generic on the upstream owner (owner names are only ~45%
352
369
  // reliably known across the fleet).
353
370
  function nonAffiliation(model: any): string {
354
- return `This is an unofficial SDK for the ${apiName(model)} public API, generated by ` +
355
- `${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}). ` +
356
377
  `It is not affiliated with, endorsed by, or sponsored by the upstream API provider.`
357
378
  }
358
379
 
@@ -368,7 +389,7 @@ function declaredText(value: any): string {
368
389
 
369
390
 
370
391
  // Voxgig's url and security contact apply only while Voxgig is the publisher.
371
- function publisherInfo(model: any): { name: string, url: string, security: string } {
392
+ function publisherInfo(model: any): { name: string, url: string, security: string, official: boolean } {
372
393
  const declared = model?.main?.[KIT]?.publisher || {}
373
394
 
374
395
  const name = declaredText(declared.name) || PUBLISHER
@@ -378,6 +399,7 @@ function publisherInfo(model: any): { name: string, url: string, security: strin
378
399
  name,
379
400
  url: declaredText(declared.url) || (own ? PUBLISHER_URL : ''),
380
401
  security: declaredText(declared.security) || (own ? SECURITY_EMAIL : ''),
402
+ official: true === declared.official,
381
403
  }
382
404
  }
383
405
 
@@ -441,6 +463,7 @@ export {
441
463
  langLabel,
442
464
  originName,
443
465
  repoInfo,
466
+ releaseBranch,
444
467
  apiName,
445
468
  packageName,
446
469
  hasPackageName,
@@ -448,6 +471,7 @@ export {
448
471
  registryState,
449
472
  isPublished,
450
473
  registryName,
474
+ registryLabel,
451
475
  vendorCommand,
452
476
  pkgDescription,
453
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
+ }
@@ -154,8 +154,34 @@ function satisfies(version: string, range: string): boolean | undefined {
154
154
  }
155
155
 
156
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
+
157
182
  export {
158
183
  satisfies,
159
184
  parseVersion,
160
185
  compareVersions,
186
+ admitsBelow,
161
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
  }
@@ -0,0 +1,82 @@
1
+ import { KIT, getModelPath } from '../types'
2
+ import { fact } from './facts'
3
+
4
+
5
+ // What the `surface` slot may hold, each word with the release that first
6
+ // reads it. The schema leaves the slot open; package check holds it to these,
7
+ // and a document names a target with any other word by its title alone.
8
+ const SURFACE_SINCE: Record<string, string> = {
9
+ sdk: '4.47.0',
10
+ cli: '4.47.0',
11
+ mcp: '4.47.0',
12
+ data: '4.47.0',
13
+ 'seneca-provider': '4.47.0',
14
+ }
15
+
16
+ const SURFACES = Object.keys(SURFACE_SINCE)
17
+
18
+
19
+ const SURFACE_WORD: Record<string, string> = {
20
+ sdk: 'SDK',
21
+ cli: 'CLI',
22
+ mcp: 'MCP',
23
+ data: 'data',
24
+ 'seneca-provider': 'Seneca provider',
25
+ }
26
+
27
+
28
+ const SURFACE_NOUN: Record<string, string> = {
29
+ sdk: 'SDK',
30
+ cli: 'CLI',
31
+ mcp: 'MCP server',
32
+ data: 'data package',
33
+ 'seneca-provider': 'Seneca provider',
34
+ }
35
+
36
+
37
+ function surfaceOf(target: any): string {
38
+ const surface = fact(target, 'surface')
39
+ return SURFACES.includes(surface) ? surface : ''
40
+ }
41
+
42
+
43
+ // The title and the noun for what the target is, with the noun's words the
44
+ // title already ends with said once: "Go CLI", "Python Data package".
45
+ function surfaceName(target: any): string {
46
+ const title = String(fact(target, 'title')).split(' ')
47
+ const noun = (SURFACE_NOUN[surfaceOf(target)] ?? 'package').split(' ')
48
+ for (let k = Math.min(title.length, noun.length); 0 < k; k--) {
49
+ if (title.slice(-k).join(' ').toLowerCase() === noun.slice(0, k).join(' ').toLowerCase()) {
50
+ return [...title, ...noun.slice(k)].join(' ')
51
+ }
52
+ }
53
+ return [...title, ...noun].join(' ')
54
+ }
55
+
56
+
57
+ // The configured languages by origin, then the rest, then the CLI and MCP server.
58
+ function documentOrder(model: any, targets: any[]): any[] {
59
+ const order: string[] = (getModelPath(model, `main.${KIT}.config.docs_order`,
60
+ { only_active: false, required: false }) as any) || []
61
+
62
+ const rank = (t: any): number => {
63
+ const i = order.indexOf(fact(t, 'origin'))
64
+ if (-1 !== i) return i
65
+ const surface = surfaceOf(t)
66
+ if ('cli' === surface) return order.length + 1
67
+ if ('mcp' === surface) return order.length + 2
68
+ return order.length
69
+ }
70
+
71
+ return targets.slice().sort((a: any, b: any) => rank(a) - rank(b))
72
+ }
73
+
74
+
75
+ export {
76
+ SURFACES,
77
+ SURFACE_SINCE,
78
+ SURFACE_WORD,
79
+ documentOrder,
80
+ surfaceName,
81
+ surfaceOf,
82
+ }
@@ -0,0 +1,91 @@
1
+ import { KIT } from '@voxgig/apidef'
2
+
3
+ import { fact } from './facts'
4
+ import { surfaceOf } from './surface'
5
+ import { SdkGenError } from '../utility'
6
+
7
+
8
+ // What every SDK target's generated suite and test mode need.
9
+ const REQUIRED_FEATURE = 'test'
10
+
11
+
12
+ type BrokenTarget = {
13
+ target: string
14
+ problem: 'untested' | 'entityless'
15
+ note: string
16
+ }
17
+
18
+
19
+ function activeTargets(model: any): [string, any][] {
20
+ const kit = model.main[KIT]
21
+ return (fact(kit, 'active') as string[]).map((name: string) => [name, kit.target[name]])
22
+ }
23
+
24
+
25
+ // An SDK, by its declared surface or by running an SDK's other phases,
26
+ // whose entity phase is off. A target that switches every phase off is a
27
+ // consumer, and one with a surface other than `sdk` says what it is.
28
+ function entityless(target: any): boolean {
29
+ const phase = fact(target, 'phase')
30
+ if (false !== phase.entity) {
31
+ return false
32
+ }
33
+ const surface = fact(target, 'surface')
34
+ return 'sdk' === surface ||
35
+ ('' === surface && (phase.feature || phase.readme || phase.agentguide || phase.test))
36
+ }
37
+
38
+
39
+ function untestedTargets(model: any): BrokenTarget[] {
40
+ if (true === model.main[KIT].feature?.[REQUIRED_FEATURE]?.active) {
41
+ return []
42
+ }
43
+ return activeTargets(model)
44
+ .filter(([, target]: [string, any]) => 'sdk' === surfaceOf(target))
45
+ .map(([name]: [string, any]) => ({
46
+ target: name, problem: 'untested',
47
+ note: 'Target "' + name + '" is an SDK, and the model has no active `' +
48
+ REQUIRED_FEATURE + '` feature, which its generated tests and test mode need. ' +
49
+ 'Run `voxgig-sdkgen target add ' + name + '`, which installs it.',
50
+ }))
51
+ }
52
+
53
+
54
+ function entitylessTargets(model: any): BrokenTarget[] {
55
+ return activeTargets(model)
56
+ .filter(([, target]: [string, any]) => entityless(target))
57
+ .map(([name]: [string, any]) => ({
58
+ target: name, problem: 'entityless',
59
+ note: entitylessNote(name),
60
+ }))
61
+ }
62
+
63
+
64
+ function entitylessNote(name: string): string {
65
+ return 'Target "' + name + '" is an SDK with its entity phase off: its main ' +
66
+ 'module and documents name the entity classes that phase writes, so the SDK ' +
67
+ 'does not build. Remove `phase: entity: active: false` from its model or, ' +
68
+ 'for a target that is not an SDK, declare its `surface`.'
69
+ }
70
+
71
+
72
+ function refuseBrokenTargets(model: any): void {
73
+ const broken = [...untestedTargets(model), ...entitylessTargets(model)]
74
+ if (0 < broken.length) {
75
+ throw new SdkGenError(broken.map((b: BrokenTarget) => b.note).join('\n'))
76
+ }
77
+ }
78
+
79
+
80
+ export type {
81
+ BrokenTarget,
82
+ }
83
+
84
+ export {
85
+ REQUIRED_FEATURE,
86
+ entityless,
87
+ untestedTargets,
88
+ entitylessTargets,
89
+ entitylessNote,
90
+ refuseBrokenTargets,
91
+ }