@workerstack/clients 1.0.0-rc.29 → 1.0.0-rc.31

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 (375) hide show
  1. package/README.md +548 -35
  2. package/assets/installers/examples/github.config.ts +17 -19
  3. package/assets/installers/examples/goreleaser.config.ts +16 -18
  4. package/assets/installers/examples/raw.config.ts +13 -15
  5. package/bin/clients.js +88 -68
  6. package/bin/installgen.js +18 -13
  7. package/dist/cli.d.ts +4 -4
  8. package/dist/cli.js +20 -12
  9. package/dist/emit/cli/channels.d.ts +2 -2
  10. package/dist/emit/cli/channels.js +18 -13
  11. package/dist/emit/cli/commands.d.ts +1 -1
  12. package/dist/emit/cli/commands.js +14 -8
  13. package/dist/emit/cli/discovery.d.ts +0 -6
  14. package/dist/emit/cli/discovery.js +9 -7
  15. package/dist/emit/cli/flags.d.ts +1 -3
  16. package/dist/emit/cli/flags.js +11 -5
  17. package/dist/emit/cli/install.d.ts +0 -8
  18. package/dist/emit/cli/install.js +3 -3
  19. package/dist/emit/cli/layout.d.ts +1 -1
  20. package/dist/emit/cli/layout.js +13 -10
  21. package/dist/emit/cli/module.d.ts +6 -6
  22. package/dist/emit/cli/module.js +10 -10
  23. package/dist/emit/cli/release.d.ts +0 -11
  24. package/dist/emit/cli/release.js +4 -4
  25. package/dist/emit/cli/skills.js +3 -3
  26. package/dist/emit/csharp/errors.js +4 -4
  27. package/dist/emit/csharp/json.js +8 -8
  28. package/dist/emit/csharp/realtime.js +3 -3
  29. package/dist/emit/csharp/sdk-answer.js +4 -4
  30. package/dist/emit/csharp/sdk-body.js +8 -6
  31. package/dist/emit/csharp/sdk-client.d.ts +3 -3
  32. package/dist/emit/csharp/sdk-client.js +2 -2
  33. package/dist/emit/csharp/sdk-csproj.d.ts +7 -9
  34. package/dist/emit/csharp/sdk-csproj.js +10 -10
  35. package/dist/emit/csharp/sdk-doc.js +1 -1
  36. package/dist/emit/csharp/sdk-method.d.ts +18 -2
  37. package/dist/emit/csharp/sdk-method.js +24 -9
  38. package/dist/emit/csharp/sdk-plan.js +0 -1
  39. package/dist/emit/csharp/sdk.js +7 -4
  40. package/dist/emit/csharp/sse.d.ts +0 -2
  41. package/dist/emit/csharp/sse.js +7 -7
  42. package/dist/emit/csharp/transport.js +7 -7
  43. package/dist/emit/csharp/types-enum.js +3 -1
  44. package/dist/emit/csharp/types-messages.js +3 -3
  45. package/dist/emit/csharp/types-names.js +10 -12
  46. package/dist/emit/csharp/types-record.js +3 -3
  47. package/dist/emit/csharp/types-union.d.ts +1 -1
  48. package/dist/emit/csharp/types.d.ts +0 -1
  49. package/dist/emit/csharp/types.js +3 -3
  50. package/dist/emit/csharp/ws.js +2 -2
  51. package/dist/emit/go/errors.js +1 -1
  52. package/dist/emit/go/http.js +2 -2
  53. package/dist/emit/go/module-path.js +2 -2
  54. package/dist/emit/go/sdk-answer.js +1 -1
  55. package/dist/emit/go/sdk-body.js +11 -7
  56. package/dist/emit/go/sdk-client.js +1 -1
  57. package/dist/emit/go/sdk-method.d.ts +9 -0
  58. package/dist/emit/go/sdk-method.js +12 -3
  59. package/dist/emit/go/sdk-mirror.js +2 -2
  60. package/dist/emit/go/sdk-opts.d.ts +0 -2
  61. package/dist/emit/go/sdk-opts.js +3 -3
  62. package/dist/emit/go/sdk.d.ts +1 -1
  63. package/dist/emit/go/sdk.js +12 -11
  64. package/dist/emit/go/sse.js +1 -1
  65. package/dist/emit/go/types-names.js +5 -0
  66. package/dist/emit/go/types-struct.d.ts +2 -1
  67. package/dist/emit/go/types-struct.js +1 -1
  68. package/dist/emit/go/types.js +9 -9
  69. package/dist/emit/go/ws.js +6 -6
  70. package/dist/emit/java/gradle.d.ts +7 -9
  71. package/dist/emit/java/gradle.js +8 -8
  72. package/dist/emit/java/json.js +1 -1
  73. package/dist/emit/java/layout-ast.js +1 -1
  74. package/dist/emit/java/layout-decl.js +5 -4
  75. package/dist/emit/java/layout-doc.js +13 -7
  76. package/dist/emit/java/layout-dot.js +1 -1
  77. package/dist/emit/java/layout-strings.js +4 -5
  78. package/dist/emit/java/layout-types.js +7 -5
  79. package/dist/emit/java/layout-visitor.js +4 -3
  80. package/dist/emit/java/layout.js +5 -4
  81. package/dist/emit/java/models-names.js +5 -4
  82. package/dist/emit/java/models-record.d.ts +0 -1
  83. package/dist/emit/java/models-record.js +3 -3
  84. package/dist/emit/java/models-union.d.ts +1 -1
  85. package/dist/emit/java/models-union.js +1 -1
  86. package/dist/emit/java/models.d.ts +1 -2
  87. package/dist/emit/java/models.js +25 -16
  88. package/dist/emit/java/realtime.d.ts +5 -17
  89. package/dist/emit/java/realtime.js +1 -1
  90. package/dist/emit/java/sdk-client.d.ts +6 -6
  91. package/dist/emit/java/sdk-client.js +2 -1
  92. package/dist/emit/java/sdk-decl.js +2 -2
  93. package/dist/emit/java/sdk-errors.js +1 -1
  94. package/dist/emit/java/sdk-headers.js +2 -2
  95. package/dist/emit/java/sdk-mirror.js +2 -2
  96. package/dist/emit/java/sdk-models.d.ts +1 -1
  97. package/dist/emit/java/sdk-models.js +7 -7
  98. package/dist/emit/java/sdk-op.d.ts +7 -11
  99. package/dist/emit/java/sdk-op.js +22 -10
  100. package/dist/emit/java/sdk-params.d.ts +5 -5
  101. package/dist/emit/java/sdk-params.js +3 -2
  102. package/dist/emit/java/sdk-plan.js +0 -1
  103. package/dist/emit/java/sdk.d.ts +1 -1
  104. package/dist/emit/java/sdk.js +21 -14
  105. package/dist/emit/java/sse.d.ts +2 -4
  106. package/dist/emit/java/sse.js +6 -6
  107. package/dist/emit/java/ws.d.ts +2 -2
  108. package/dist/emit/java/ws.js +3 -4
  109. package/dist/emit/mcp/annotations.js +8 -4
  110. package/dist/emit/mcp/files.js +9 -9
  111. package/dist/emit/mcp/mounted.js +2 -2
  112. package/dist/emit/mcp/output-schema.js +3 -3
  113. package/dist/emit/mcp/registry.d.ts +0 -2
  114. package/dist/emit/mcp/registry.js +5 -4
  115. package/dist/emit/mcp/runtime.js +2 -2
  116. package/dist/emit/mcp/schema.js +22 -11
  117. package/dist/emit/mcp/server.d.ts +7 -7
  118. package/dist/emit/mcp/server.js +7 -6
  119. package/dist/emit/mcp/tools.js +7 -6
  120. package/dist/emit/python/errors.js +3 -3
  121. package/dist/emit/python/realtime.js +2 -2
  122. package/dist/emit/python/sdk-answer.d.ts +3 -7
  123. package/dist/emit/python/sdk-answer.js +2 -2
  124. package/dist/emit/python/sdk-body.js +4 -5
  125. package/dist/emit/python/sdk-client.js +5 -5
  126. package/dist/emit/python/sdk-doc.js +2 -2
  127. package/dist/emit/python/sdk-method.d.ts +11 -0
  128. package/dist/emit/python/sdk-method.js +20 -5
  129. package/dist/emit/python/sdk-plan.js +0 -1
  130. package/dist/emit/python/sdk-pyproject.d.ts +0 -2
  131. package/dist/emit/python/sdk-pyproject.js +8 -8
  132. package/dist/emit/python/sdk.d.ts +1 -1
  133. package/dist/emit/python/sdk.js +12 -8
  134. package/dist/emit/python/sse.d.ts +0 -2
  135. package/dist/emit/python/sse.js +2 -2
  136. package/dist/emit/python/transport.js +4 -4
  137. package/dist/emit/python/types-dict.d.ts +2 -2
  138. package/dist/emit/python/types-dict.js +1 -1
  139. package/dist/emit/python/types-names.js +2 -2
  140. package/dist/emit/python/types-union.js +1 -1
  141. package/dist/emit/python/types.js +3 -3
  142. package/dist/emit/python/ws.d.ts +2 -5
  143. package/dist/emit/python/ws.js +4 -4
  144. package/dist/emit/rust/errors.js +3 -3
  145. package/dist/emit/rust/http.js +4 -4
  146. package/dist/emit/rust/realtime.js +2 -2
  147. package/dist/emit/rust/sdk-body.js +8 -5
  148. package/dist/emit/rust/sdk-cargo.d.ts +16 -18
  149. package/dist/emit/rust/sdk-cargo.js +12 -12
  150. package/dist/emit/rust/sdk-client.d.ts +1 -1
  151. package/dist/emit/rust/sdk-client.js +3 -3
  152. package/dist/emit/rust/sdk-method.d.ts +12 -1
  153. package/dist/emit/rust/sdk-method.js +12 -4
  154. package/dist/emit/rust/sdk-opts.d.ts +2 -1
  155. package/dist/emit/rust/sdk-opts.js +2 -2
  156. package/dist/emit/rust/sdk-plan.js +0 -1
  157. package/dist/emit/rust/sdk.d.ts +1 -1
  158. package/dist/emit/rust/sdk.js +9 -6
  159. package/dist/emit/rust/sse.d.ts +0 -5
  160. package/dist/emit/rust/sse.js +2 -2
  161. package/dist/emit/rust/types-names.js +3 -3
  162. package/dist/emit/rust/types-struct.js +1 -1
  163. package/dist/emit/rust/types-union.d.ts +1 -1
  164. package/dist/emit/rust/types.js +7 -5
  165. package/dist/emit/rust/ws.d.ts +0 -11
  166. package/dist/emit/rust/ws.js +5 -5
  167. package/dist/emit/shared/escape.js +17 -17
  168. package/dist/emit/shared/format.js +1 -1
  169. package/dist/emit/shared/gofmt.js +1 -1
  170. package/dist/emit/shared/lang.js +10 -10
  171. package/dist/emit/shared/literals.d.ts +5 -0
  172. package/dist/emit/shared/literals.js +8 -0
  173. package/dist/emit/shared/metadata.d.ts +0 -6
  174. package/dist/emit/shared/metadata.js +8 -7
  175. package/dist/emit/shared/ruff.js +1 -1
  176. package/dist/emit/shared/rustfmt.js +1 -1
  177. package/dist/emit/shared/type-emitter.js +37 -20
  178. package/dist/emit/shared/unknown-type.constants.d.ts +2 -0
  179. package/dist/emit/shared/unknown-type.constants.js +2 -0
  180. package/dist/emit/ts/http.d.ts +8 -2
  181. package/dist/emit/ts/http.js +51 -6
  182. package/dist/emit/ts/package.d.ts +14 -12
  183. package/dist/emit/ts/package.js +10 -8
  184. package/dist/emit/ts/route-tree.js +2 -2
  185. package/dist/emit/ts/sdk-types-preamble.d.ts +1 -1
  186. package/dist/emit/ts/sdk-types-preamble.js +12 -4
  187. package/dist/emit/ts/sdk-types.d.ts +0 -5
  188. package/dist/emit/ts/sdk-types.js +63 -19
  189. package/dist/emit/ts/sdk.d.ts +3 -1
  190. package/dist/emit/ts/sdk.js +44 -12
  191. package/dist/emit/ts/service-map.d.ts +7 -1
  192. package/dist/emit/ts/service-map.js +10 -1
  193. package/dist/emit/ts/single-flight-text.d.ts +3 -0
  194. package/dist/emit/ts/single-flight-text.js +38 -0
  195. package/dist/emit/ts/tanstack-query.d.ts +3 -2
  196. package/dist/emit/ts/tanstack-query.js +60 -35
  197. package/dist/emit/ts/type-gen.js +31 -18
  198. package/dist/emit/ts/webhooks.d.ts +0 -2
  199. package/dist/emit/ts/webhooks.js +3 -3
  200. package/dist/extract/chain.js +5 -4
  201. package/dist/extract/extract.js +5 -5
  202. package/dist/extract/serialize.d.ts +0 -2
  203. package/dist/extract/serialize.js +14 -15
  204. package/dist/extract/walk.js +15 -12
  205. package/dist/gen/args.js +9 -5
  206. package/dist/gen/formatters.js +5 -3
  207. package/dist/gen/process.js +2 -1
  208. package/dist/gen/shipped.js +2 -2
  209. package/dist/gen/switch-on.constants.d.ts +2 -0
  210. package/dist/gen/switch-on.constants.js +2 -0
  211. package/dist/gen/targets.d.ts +6 -7
  212. package/dist/gen/targets.js +11 -6
  213. package/dist/gen/write.js +4 -2
  214. package/dist/index.js +2 -2
  215. package/dist/installers/cli.d.ts +4 -4
  216. package/dist/installers/cli.js +24 -24
  217. package/dist/installers/commands/build.d.ts +4 -4
  218. package/dist/installers/commands/build.js +2 -3
  219. package/dist/installers/commands/check.d.ts +2 -2
  220. package/dist/installers/commands/check.js +11 -10
  221. package/dist/installers/commands/init.d.ts +2 -2
  222. package/dist/installers/commands/init.js +1 -2
  223. package/dist/installers/config/define-config.d.ts +16 -16
  224. package/dist/installers/config/define-config.js +1 -1
  225. package/dist/installers/config/hooks/bun.d.ts +6 -6
  226. package/dist/installers/config/hooks/node.js +1 -1
  227. package/dist/installers/config/load.d.ts +6 -8
  228. package/dist/installers/config/load.js +7 -8
  229. package/dist/installers/config/resolve.d.ts +1 -2
  230. package/dist/installers/config/resolve.js +28 -33
  231. package/dist/installers/config/types.d.ts +6 -6
  232. package/dist/installers/config/types.js +0 -1
  233. package/dist/installers/render/quote.js +3 -5
  234. package/dist/installers/render/render.d.ts +6 -6
  235. package/dist/installers/render/render.js +26 -26
  236. package/dist/installers/ui.d.ts +4 -4
  237. package/dist/installers/ui.js +3 -3
  238. package/dist/ir/build.d.ts +3 -3
  239. package/dist/ir/build.js +8 -5
  240. package/dist/ir/invalidate-reads.d.ts +17 -0
  241. package/dist/ir/invalidate-reads.js +104 -0
  242. package/dist/ir/load.d.ts +10 -0
  243. package/dist/ir/load.js +65 -18
  244. package/dist/ir/model.d.ts +2 -1
  245. package/dist/ir/model.js +0 -1
  246. package/dist/ir/read-method.constants.d.ts +2 -0
  247. package/dist/ir/read-method.constants.js +2 -0
  248. package/dist/ir/resolve-refs.js +2 -2
  249. package/dist/ir/resource-tree.js +2 -1
  250. package/dist/ir/route-tree-intern.js +1 -1
  251. package/dist/ir/schema.js +3 -3
  252. package/dist/ir/sdk-model.js +3 -3
  253. package/dist/ir/slots.js +13 -8
  254. package/dist/ir/streams.js +1 -1
  255. package/dist/release/bootstrap.d.ts +3 -3
  256. package/dist/release/bootstrap.js +7 -7
  257. package/dist/release/bump-args.js +4 -4
  258. package/dist/release/bump-command.d.ts +1 -1
  259. package/dist/release/bump-command.js +9 -10
  260. package/dist/release/bump.d.ts +5 -4
  261. package/dist/release/bump.js +2 -2
  262. package/dist/release/cli.d.ts +4 -4
  263. package/dist/release/cli.js +4 -4
  264. package/dist/release/codegen.js +1 -1
  265. package/dist/release/digest.js +5 -7
  266. package/dist/release/git.js +5 -8
  267. package/dist/release/load.js +4 -4
  268. package/dist/release/manifest.js +9 -10
  269. package/dist/release/oasdiff.d.ts +10 -15
  270. package/dist/release/oasdiff.js +5 -6
  271. package/dist/release/registries.d.ts +0 -11
  272. package/dist/release/registries.js +17 -17
  273. package/dist/release/release-state.d.ts +16 -13
  274. package/dist/release/release-workflow.js +5 -7
  275. package/dist/release/repo-settings.d.ts +2 -1
  276. package/dist/release/spec-gate.d.ts +0 -2
  277. package/dist/release/spec-gate.js +6 -10
  278. package/dist/release/sync-command.d.ts +2 -2
  279. package/dist/release/sync-command.js +1 -1
  280. package/dist/release/sync-tree.js +9 -13
  281. package/dist/release/sync.d.ts +6 -6
  282. package/dist/release/sync.js +12 -13
  283. package/dist/release/types.d.ts +22 -22
  284. package/dist/release/types.js +0 -1
  285. package/dist/release/version-files.d.ts +3 -4
  286. package/dist/release/version-files.js +4 -5
  287. package/dist/runtime/.oxfmtrc.jsonc +8 -0
  288. package/dist/runtime/csharp/Config.cs +9 -1
  289. package/dist/runtime/csharp/Exchange.cs +56 -4
  290. package/dist/runtime/csharp/Hooks.cs +9 -0
  291. package/dist/runtime/csharp/Operation.cs +6 -1
  292. package/dist/runtime/csharp/WsDial.cs +3 -1
  293. package/dist/runtime/go/config.go +5 -0
  294. package/dist/runtime/go/hooks.go +70 -0
  295. package/dist/runtime/go/request.go +6 -2
  296. package/dist/runtime/go/stream.go +4 -1
  297. package/dist/runtime/go/ws.go +3 -1
  298. package/dist/runtime/java/ClientConfig.java +11 -0
  299. package/dist/runtime/java/Flight.java +2 -12
  300. package/dist/runtime/java/Hooks.java +45 -0
  301. package/dist/runtime/java/InvalidateEvent.java +10 -0
  302. package/dist/runtime/java/InvalidateHook.java +12 -0
  303. package/dist/runtime/java/InvalidateTarget.java +7 -0
  304. package/dist/runtime/java/Operation.java +23 -3
  305. package/dist/runtime/java/Realtime.java +3 -1
  306. package/dist/runtime/java/WsDial.java +3 -0
  307. package/dist/runtime/mcp/files.ts +1 -1
  308. package/dist/runtime/mcp/http.ts +6 -2
  309. package/dist/runtime/mcp/listen.ts +1 -1
  310. package/dist/runtime/mcp/mount.ts +2 -2
  311. package/dist/runtime/mcp/protocol.ts +1 -1
  312. package/dist/runtime/python/config.py +8 -2
  313. package/dist/runtime/python/exchange.py +3 -1
  314. package/dist/runtime/python/hooks.py +110 -5
  315. package/dist/runtime/python/operation.py +2 -0
  316. package/dist/runtime/python/send_async.py +14 -2
  317. package/dist/runtime/python/send_sync.py +4 -2
  318. package/dist/runtime/python/ws.py +5 -1
  319. package/dist/runtime/rust/config.rs +6 -1
  320. package/dist/runtime/rust/exchange.rs +15 -3
  321. package/dist/runtime/rust/hooks.rs +127 -2
  322. package/dist/runtime/rust/log.rs +11 -3
  323. package/dist/runtime/rust/request.rs +17 -0
  324. package/dist/runtime/rust/ws.rs +9 -1
  325. package/dist/runtime/ts/config.ts +69 -0
  326. package/dist/runtime/ts/http.ts +12 -10
  327. package/dist/runtime/ts/request.ts +2 -0
  328. package/dist/runtime/ts/response.ts +7 -0
  329. package/dist/runtime/ts/sdk-invalidate.ts +82 -0
  330. package/dist/runtime/ts/sdk-single-flight.constants.ts +25 -0
  331. package/dist/runtime/ts/sdk-single-flight.ts +203 -0
  332. package/dist/runtime/ts/sdk-sse.ts +5 -1
  333. package/dist/runtime/ts/sdk-ws.ts +9 -3
  334. package/dist/runtime/ts/sdk.ts +55 -31
  335. package/dist/runtime/ts/single-flight-batch.ts +184 -0
  336. package/dist/runtime/ts/single-flight-body.ts +59 -0
  337. package/dist/runtime/ts/single-flight-run.ts +160 -0
  338. package/dist/runtime/ts/single-flight.constants.ts +31 -0
  339. package/dist/runtime/ts/single-flight.ts +158 -0
  340. package/dist/runtime/ts-tanstack-query/invalidate.ts +96 -92
  341. package/dist/runtime/ts-tanstack-query/query.ts +140 -170
  342. package/package.json +12 -17
  343. package/references/INDEX.md +31 -0
  344. package/references/cli.md +33 -0
  345. package/references/configuring.md +29 -0
  346. package/references/documentation.md +15 -0
  347. package/references/errors.md +23 -0
  348. package/references/flags.md +104 -0
  349. package/references/gates.md +46 -0
  350. package/references/generate.md +29 -0
  351. package/references/install-scripts.md +28 -0
  352. package/references/install.md +38 -0
  353. package/references/license.md +8 -0
  354. package/references/mcp.md +76 -0
  355. package/references/output.md +45 -0
  356. package/references/overview.md +14 -0
  357. package/references/release-tooling.md +34 -0
  358. package/references/release.md +305 -0
  359. package/references/sdks.md +393 -0
  360. package/references/start.md +22 -0
  361. package/references/tdd.md +16 -0
  362. package/dist/emit/cli/index.d.ts +0 -1
  363. package/dist/emit/cli/index.js +0 -1
  364. package/dist/emit/csharp/index.d.ts +0 -1
  365. package/dist/emit/csharp/index.js +0 -1
  366. package/dist/emit/go/index.d.ts +0 -1
  367. package/dist/emit/go/index.js +0 -1
  368. package/dist/emit/java/index.d.ts +0 -2
  369. package/dist/emit/java/index.js +0 -2
  370. package/dist/emit/mcp/index.d.ts +0 -3
  371. package/dist/emit/mcp/index.js +0 -3
  372. package/dist/emit/python/index.d.ts +0 -1
  373. package/dist/emit/python/index.js +0 -1
  374. package/dist/emit/rust/index.d.ts +0 -1
  375. package/dist/emit/rust/index.js +0 -1
package/dist/ir/load.js CHANGED
@@ -11,12 +11,12 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
11
11
  * document generated by the app's own core, `@workerstack/backend/http/openapi`, resolved from the app as it would be at run
12
12
  * time, so gen imports no core itself (H2). The named export, else `app`, else `default`, is the app; the module's
13
13
  * `openApi` export, if any, is the document's options (core's GenerateOpenApiOptions), else a bare `info`. On Node
14
- * the module loads through jiti, a core checkout read from its source by alias; on Bun through Bun's own import, a
15
- * checkout read from its source by the backend-source condition, refused when this Bun resolves it elsewhere (bit 20).
16
- * With no core installed where the app resolves it, the refusal names it.
14
+ * the module loads through Vite's module runner, a core checkout read from its source by alias; on Bun through Bun's
15
+ * own import, a checkout read from its source by the backend-source condition, refused when this Bun resolves it
16
+ * elsewhere (bit 20). With no core installed where the app resolves it, the refusal names it.
17
17
  */
18
18
  import { existsSync, readFileSync, realpathSync } from "node:fs";
19
- import { dirname, join, relative, resolve } from "node:path";
19
+ import { dirname, isAbsolute, join, relative, resolve } from "node:path";
20
20
  import { pathToFileURL } from "node:url";
21
21
  const CORE = "@workerstack/backend";
22
22
  const DEFAULT_OPTIONS = { info: { title: "API", version: "0.0.0" } };
@@ -63,18 +63,64 @@ function appOf(mod, ref, name) {
63
63
  const which = name === undefined ? "no `app` or `default` export" : `no export ${JSON.stringify(name)}`;
64
64
  throw new Error(`--app ${ref}: ${which} that is a backend app (name one as <module>#<export>)`);
65
65
  }
66
- /* Node: jiti, its one module cache shared by the app and its document, so both see one core module (its GRAPH symbol) */
67
- async function jitiImporter(path, alias) {
68
- const { createJiti } = await import("jiti");
69
- const jiti = createJiti(path, { alias, fsCache: false, interopDefault: true });
70
- return (specifier) => jiti.import(specifier);
66
+ /** The id of a module that re-exports what its suffix names, as an import from the app's directory would read it. */
67
+ const REEXPORT = "clients-reexport:";
68
+ /** The plugin serving each REEXPORT module: one `export *` of its specifier. */
69
+ const reexports = {
70
+ load: (id) => id.startsWith(`\0${REEXPORT}`) ? `export * from ${JSON.stringify(id.slice(REEXPORT.length + 1))}\n` : null,
71
+ name: "clients-reexport",
72
+ resolveId: (id) => (id.startsWith(REEXPORT) ? `\0${id}` : null),
73
+ };
74
+ /** The characters a RegExp reads as syntax. */
75
+ const REGEX_SYNTAX = /[$()*+.?[\\\]^{|}]/g;
76
+ /** `text` matched literally in a RegExp. */
77
+ function literal(text) {
78
+ return text.replaceAll(REGEX_SYNTAX, String.raw `\$&`);
79
+ }
80
+ /** Vite's server API, or why `generate --app` can't run on Node without it. */
81
+ function loadVite(vite) {
82
+ return vite().catch((error) => {
83
+ if (error.message.startsWith("Cannot find package 'vite' "))
84
+ throw new Error("clients generate --app on Node loads TypeScript through Vite: install vite, or run it with Bun");
85
+ throw error;
86
+ });
71
87
  }
72
- /*
73
- * Bun: its own import, never jiti, which there retries a module that threw through its Babel (evaluating it twice),
74
- * whose Error.prepareStackTrace hook then breaks Bun's captureStackTrace on a non-Error (Vite's follow-redirects), and
75
- * whose native mode ignores the aliases (bit 20). A checkout's aliases hold by the backend-source condition instead:
76
- * each must resolve to its source, never to an unbuilt or stale dist/.
88
+ /**
89
+ * Node: Vite's SSR runner rooted at the module's directory, one graph shared by the app and its document, so both see
90
+ * one core module (its GRAPH symbol). Each alias matches its specifier exactly, never as a prefix of a longer subpath.
91
+ * The app's Vite config is never applied, and the server holds no handle (no socket, no watcher, no dependency scan),
92
+ * so it is left for the process to end. `vite` is the import, a parameter so its absence can be tested.
77
93
  */
94
+ export async function viteImporter(path, aliases, vite = () => import("vite")) {
95
+ const { createServer, createServerModuleRunner } = await loadVite(vite);
96
+ const server = await createServer({
97
+ appType: "custom",
98
+ configFile: false,
99
+ logLevel: "silent",
100
+ // nothing here serves a browser: no dependency scan of the root
101
+ optimizeDeps: { entries: [], noDiscovery: true },
102
+ plugins: [reexports],
103
+ resolve: {
104
+ alias: Object.entries(aliases).map(([find, replacement]) => ({
105
+ find: new RegExp(`^${literal(find)}$`),
106
+ replacement,
107
+ })),
108
+ },
109
+ root: dirname(path),
110
+ server: { middlewareMode: true, watch: null, ws: false },
111
+ });
112
+ // its own source-map hook, not Node's: a stack frame names the app's line even where another hook owns stacks
113
+ const runner = createServerModuleRunner(server.environments.ssr, {
114
+ hmr: false,
115
+ sourcemapInterceptor: "prepareStackTrace",
116
+ });
117
+ // a bare specifier through a module re-exporting it, so Vite resolves it as it resolves the app's own imports
118
+ // (aliased, inlined or externalized alike) and the app and its document share one core
119
+ return (specifier) => runner.import(isAbsolute(specifier) ? specifier : `${REEXPORT}${specifier}`);
120
+ }
121
+ // Bun: its own import, never Vite's runner, whose source-map hook is the class of Error.prepareStackTrace replacer that
122
+ // breaks Bun's captureStackTrace on a non-Error (Vite's follow-redirects; bit 20). A checkout's aliases hold by the
123
+ // backend-source condition instead: each must resolve to its source, never to an unbuilt or stale dist/.
78
124
  function bunImporter(bun, path, aliases, ref) {
79
125
  const from = dirname(path);
80
126
  for (const [specifier, source] of Object.entries(aliases)) {
@@ -83,10 +129,11 @@ function bunImporter(bun, path, aliases, ref) {
83
129
  resolved = bun.resolveSync(specifier, from);
84
130
  }
85
131
  catch {
86
- /* unresolvable without the condition (a checkout has no dist/): refused below, as one resolved elsewhere */
132
+ // unresolvable without the condition (a checkout has no dist/): refused below, as one resolved elsewhere
87
133
  }
88
- if (resolved !== realpathSync(source))
134
+ if (resolved !== realpathSync(source)) {
89
135
  throw new Error(`--app ${ref}: ${specifier} is a checkout, read from its source only under the backend-source condition: start Bun with --conditions=backend-source`);
136
+ }
90
137
  }
91
138
  return (specifier) => import(__rewriteRelativeImportExtension(pathToFileURL(bun.resolveSync(specifier, from)).href));
92
139
  }
@@ -101,9 +148,9 @@ export async function loadAppDocument(ref, cwd) {
101
148
  throw new Error(`--app ${ref}: no ${CORE} is installed where ${relative(cwd, path)} resolves it`);
102
149
  const bun = globalThis.Bun;
103
150
  const aliases = sourceAliases(root);
104
- /* Bun resolves core's own imports under the backend-source condition, through core's package.json */
151
+ // Bun resolves core's own imports under the backend-source condition, through core's package.json
105
152
  const load = bun === undefined
106
- ? await jitiImporter(path, { ...aliases.exports, ...aliases.imports })
153
+ ? await viteImporter(path, { ...aliases.exports, ...aliases.imports })
107
154
  : bunImporter(bun, path, aliases.exports, ref);
108
155
  const mod = await load(path);
109
156
  const app = appOf(mod, ref, name);
@@ -4,7 +4,7 @@
4
4
  */
5
5
  export type IRScalarType = "boolean" | "integer" | "null" | "number" | "string";
6
6
  /** A value's constraint keywords as the spec states them (bit 19 c): a string's, a number's, an array's. */
7
- export type IRBounds = {
7
+ type IRBounds = {
8
8
  minLength?: number;
9
9
  maxLength?: number;
10
10
  pattern?: string;
@@ -220,3 +220,4 @@ export type IR = {
220
220
  /** every webhook, by name in code-unit order */
221
221
  webhooks: IRWebhook[];
222
222
  };
223
+ export {};
package/dist/ir/model.js CHANGED
@@ -2,4 +2,3 @@
2
2
  * The IR: what every emitter reads, built from an OpenAPI document and nothing else (H2). This
3
3
  * file holds its types; `schema.ts` reads a JSON Schema into an IR schema and follows refs.
4
4
  */
5
- export {};
@@ -0,0 +1,2 @@
1
+ /** The only method a cache reads from, as the IR spells an operation's method. */
2
+ export declare const READ_METHOD = "GET";
@@ -0,0 +1,2 @@
1
+ /** The only method a cache reads from, as the IR spells an operation's method. */
2
+ export const READ_METHOD = "GET";
@@ -1,5 +1,5 @@
1
1
  const PREFIX = "#/components/schemas/";
2
- /* past this many schema nodes, inlining fails loudly instead of eating the machine */
2
+ // past this many schema nodes, inlining fails loudly instead of eating the machine
3
3
  const MAX_NODES = 200_000;
4
4
  const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
5
5
  /** `schema` with its component ref, if it is one, replaced by a copy of the component, inlined. */
@@ -60,7 +60,7 @@ export function resolveRefs(doc) {
60
60
  inlineContent(response, run);
61
61
  }
62
62
  }
63
- /* schemas were there, so components are */
63
+ // schemas were there, so components are
64
64
  const { schemas: _inlined, ...rest } = components;
65
65
  return { ...doc, components: Object.keys(rest).length > 0 ? rest : undefined, paths };
66
66
  }
@@ -41,8 +41,9 @@ export function buildResourceTree(operations) {
41
41
  at.entries.set(segment, { kind: "namespace", ns });
42
42
  at = ns;
43
43
  }
44
- else
44
+ else {
45
45
  at = entry.ns;
46
+ }
46
47
  }
47
48
  const existing = at.entries.get(leaf);
48
49
  if (existing?.kind === "namespace")
@@ -4,7 +4,7 @@
4
4
  * values JSON cannot carry first, so equal JSON always means equal values.
5
5
  */
6
6
  import { tsString } from "../emit/shared/escape.js";
7
- /* shorter strings and numbers cost less inline than a name */
7
+ // shorter strings and numbers cost less inline than a name
8
8
  const STRING_MIN = 8;
9
9
  const NUMBER_MIN = 8;
10
10
  /** How deeply `value` nests: 0 for a primitive. */
package/dist/ir/schema.js CHANGED
@@ -12,7 +12,7 @@ function isNullable(schema) {
12
12
  /** The schema `schema` makes nullable; never wrapped twice. */
13
13
  function nullableOf(schema) {
14
14
  let inner;
15
- /* only a type list that holds null is stripped; a flag beside any other list drops the flag below */
15
+ // only a type list that holds null is stripped; a flag beside any other list drops the flag below
16
16
  if (Array.isArray(schema.type) && schema.type.includes("null")) {
17
17
  const rest = schema.type.filter((type) => type !== "null");
18
18
  inner = schemaToIR({ ...schema, type: rest.length === 1 ? rest[0] : rest });
@@ -119,7 +119,7 @@ function constOf(schema) {
119
119
  const typed = SCALARS.includes(schema.type) && schema.type !== "null";
120
120
  return typed ? { kind: "const", type: schema.type, value } : { kind: "const", value };
121
121
  }
122
- /* the constraint keywords a value carries (bit 19 c), each read when the spec states it with its JSON type */
122
+ // the constraint keywords a value carries (bit 19 c), each read when the spec states it with its JSON type
123
123
  const BOUNDS = ["minLength", "maxLength", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum"];
124
124
  function scalarOf(schema) {
125
125
  if (!SCALARS.includes(schema.type))
@@ -147,7 +147,7 @@ function arrayOf(schema) {
147
147
  array.maxItems = schema.maxItems;
148
148
  return array;
149
149
  }
150
- /* the order matters: a ref before anything it might also say, const before type, nullability before unions */
150
+ // the order matters: a ref before anything it might also say, const before type, nullability before unions
151
151
  const READERS = [
152
152
  (schema) => (typeof schema.$ref === "string" ? { kind: "ref", name: lastSegment(schema.$ref) } : null),
153
153
  (schema) => (Array.isArray(schema.allOf) ? { kind: "allOf", parts: schema.allOf.map(schemaToIR) } : null),
@@ -4,6 +4,7 @@
4
4
  * realtime calls alike, instead of in each emitter.
5
5
  */
6
6
  import { compareCodeUnits } from "../emit/shared/lang.js";
7
+ import {} from "./model.js";
7
8
  import { irResolver } from "./schema.js";
8
9
  import { parseOpenApiPath } from "./slots.js";
9
10
  /** A media type's essence: `Application/JSON; charset=utf-8` → `application/json`. */
@@ -34,9 +35,8 @@ function successOf(op) {
34
35
  const status = codes.find((code) => op.responses[code]?.contentType !== undefined) ?? codes[0];
35
36
  if (status === undefined) {
36
37
  const fallback = op.responses["2XX"] ?? op.responses.default;
37
- if (fallback?.contentType === undefined || !isJsonMedia(fallback.contentType)) {
38
+ if (fallback?.contentType === undefined || !isJsonMedia(fallback.contentType))
38
39
  return { kind: Object.keys(op.responses).length === 0 ? "json" : "none", status: "200" };
39
- }
40
40
  const out = { contentType: fallback.contentType, kind: "json", status: fallback.status };
41
41
  if (fallback.schema !== undefined)
42
42
  out.schema = fallback.schema;
@@ -81,7 +81,7 @@ function streamOf(op) {
81
81
  return "ws";
82
82
  return sse === true ? "sse" : null;
83
83
  }
84
- /* a string-typed schema: a scalar string, or a string const or enum */
84
+ // a string-typed schema: a scalar string, or a string const or enum
85
85
  const isStringSchema = (schema) => (schema.kind === "scalar" && schema.type === "string") ||
86
86
  (schema.kind === "const" && typeof schema.value === "string");
87
87
  /** The SSE response of `op`: its `text/event-stream` answer, if any. */
package/dist/ir/slots.js CHANGED
@@ -1,6 +1,13 @@
1
+ import { compareCodeUnits } from "../emit/shared/lang.js";
2
+ /**
3
+ * One operation's slots in the IR: its parameters by where they travel, its request bodies in
4
+ * preference order, its responses by status, and the backend extensions it carries (realtime, SSE,
5
+ * websocket, invalidation…), and for a Standard Webhooks event, its type and data. Component `$ref`s on
6
+ * parameters, bodies, responses and an event's envelope are followed.
7
+ */
8
+ import {} from "./model.js";
1
9
  import { schemaToIR } from "./schema.js";
2
10
  import { sseEventsOf, websocketMessagesOf } from "./streams.js";
3
- import { compareCodeUnits } from "../emit/shared/lang.js";
4
11
  /** Splits an OpenAPI path template into literal text and `{param}` pieces. */
5
12
  export function parseOpenApiPath(path) {
6
13
  const out = [];
@@ -67,13 +74,12 @@ export function paramsOf(path, op, item, components) {
67
74
  const declared = (op.parameters ?? [])
68
75
  .map((p) => deref(p, components))
69
76
  .filter((p) => p !== undefined);
70
- for (const p of (item.parameters ?? []).map((q) => deref(q, components))) {
77
+ for (const p of (item.parameters ?? []).map((q) => deref(q, components)))
71
78
  if (p !== undefined && !declared.some((d) => d.name === p.name && d.in === p.in))
72
79
  declared.push(p);
73
- }
74
80
  const by = (place) => declared.filter((p) => p.in === place).map(paramOf);
75
81
  const pathParams = by("path");
76
- /* path params in template order; one the template lacks cannot be sent, one it has but nobody declared is a string */
82
+ // path params in template order; one the template lacks cannot be sent, one it has but nobody declared is a string
77
83
  const params = {
78
84
  header: by("header"),
79
85
  path: openApiPathParams(path).map((name) => pathParams.find((p) => p.name === name) ?? { name, required: true, schema: STRING }),
@@ -84,7 +90,7 @@ export function paramsOf(path, op, item, components) {
84
90
  params.cookie = cookie;
85
91
  return params;
86
92
  }
87
- /* JSON first, then the structured kinds; other JSON-like types next, then the rest as listed */
93
+ // JSON first, then the structured kinds; other JSON-like types next, then the rest as listed
88
94
  const PREFERENCE = [
89
95
  "application/json",
90
96
  "application/x-www-form-urlencoded",
@@ -125,12 +131,11 @@ function bodyOf(type, media, required, components) {
125
131
  return { contentType: "application/octet-stream", kind: "stream", required };
126
132
  const ir = schemaToIR(schema);
127
133
  const parts = essence === "multipart/form-data" ? partsOf(ir, components) : [];
128
- if (parts.some((part) => part.type === "file")) {
134
+ if (parts.some((part) => part.type === "file"))
129
135
  return { contentType: "multipart/form-data", kind: "multipart", parts, required, schema: ir };
130
- }
131
136
  return { contentType: type, kind: "raw", required, schema: ir };
132
137
  }
133
- /* a urlencoded form cannot carry a file, so a multipart one with a file part ranks just above it */
138
+ // a urlencoded form cannot carry a file, so a multipart one with a file part ranks just above it
134
139
  const weight = (body) => body.kind === "multipart" ? rank("application/x-www-form-urlencoded") - 0.5 : rank(body.contentType);
135
140
  /** Every request body the operation declares, preferred first. */
136
141
  export function requestBodies(op, components) {
@@ -21,7 +21,7 @@ export function sseEventsOf(itemSchema, follow) {
21
21
  return [{ data: dataOf(properties.data), name: event ?? "message" }];
22
22
  });
23
23
  }
24
- /* an event's data: what `contentSchema` encodes when it is there, else the schema itself */
24
+ // an event's data: what `contentSchema` encodes when it is there, else the schema itself
25
25
  function dataOf(data) {
26
26
  if (!isObject(data))
27
27
  return { kind: "unknown" };
@@ -2,7 +2,7 @@ import { type ReleaseContext } from "./context.ts";
2
2
  /** The most commits a public repo's branch may hold for `--force-bootstrap` to overwrite it: a stub, not history. */
3
3
  export declare const FORCE_COMMIT_LIMIT = 2;
4
4
  /** What `release bootstrap` prints when it is not told what to target. */
5
- export declare const USAGE: string[];
5
+ export declare const USAGE: readonly string[];
6
6
  /**
7
7
  * Returns commit count on the remote branch, capped at FORCE_COMMIT_LIMIT + 1.
8
8
  * Used to gate --force-bootstrap: only mirrors with ≤FORCE_COMMIT_LIMIT commits
@@ -10,7 +10,7 @@ export declare const USAGE: string[];
10
10
  */
11
11
  export declare function countRemoteCommits(httpsUrl: string, branch: string): Promise<number>;
12
12
  /** What `release bootstrap` was asked for. */
13
- export interface BootstrapOptions {
13
+ export type BootstrapOptions = {
14
14
  /** Every package of the release. */
15
15
  all: boolean;
16
16
  /** The release config's path; required. */
@@ -19,7 +19,7 @@ export interface BootstrapOptions {
19
19
  forceBootstrap: boolean;
20
20
  /** The packages to bootstrap, by `name` or `project/name`. */
21
21
  only: string[] | undefined;
22
- }
22
+ };
23
23
  /** A parse that succeeded with `options`, or failed with an `error` to show the caller. */
24
24
  export type ParsedArgs = {
25
25
  error: string;
@@ -44,7 +44,7 @@ export async function countRemoteCommits(httpsUrl, branch) {
44
44
  rmSync(tmpDir, { force: true, recursive: true });
45
45
  }
46
46
  }
47
- /* Unknown arguments are ignored. */
47
+ // Unknown arguments are ignored.
48
48
  const SWITCHES = { "--all": "all", "--force-bootstrap": "forceBootstrap" };
49
49
  const VALUE_FLAGS = { "--config": "config", "--name": "only", "--only": "only" };
50
50
  const isSwitch = (arg) => Object.hasOwn(SWITCHES, arg);
@@ -106,7 +106,7 @@ export function judgeMirror(input) {
106
106
  }
107
107
  return { proceed: true };
108
108
  }
109
- /* one package bootstrapped: its outcome, reported as it goes */
109
+ // one package bootstrapped: its outcome, reported as it goes
110
110
  async function bootstrapOne(entry, run, ctx) {
111
111
  ctx.out(`\n→ ${packageKey(entry)} → ${entry.mirror}\n`);
112
112
  const httpsUrl = sshToHttps(entry.mirror, run.token);
@@ -121,9 +121,9 @@ async function bootstrapOne(entry, run, ctx) {
121
121
  ctx.err(` fail: ${verdict.reason}\n`);
122
122
  return "failed";
123
123
  }
124
- /* Bootstrap commits force-overwrite the mirror with a fresh "initial release" snapshot. bootstrapExclude globs
125
- skip generated source on the initial push, so the next sync adds it cleanly. A repo bootstrap creates is exactly
126
- one whose description, website and topics are empty, so the settings step fills them. */
124
+ // Bootstrap commits force-overwrite the mirror with a fresh "initial release" snapshot. bootstrapExclude globs
125
+ // skip generated source on the initial push, so the next sync adds it cleanly. A repo bootstrap creates is exactly
126
+ // one whose description, website and topics are empty, so the settings step fills them.
127
127
  const result = await syncPackage(entry, {
128
128
  applyBootstrapExclude: true,
129
129
  dryRun: false,
@@ -142,12 +142,12 @@ async function bootstrapOne(entry, run, ctx) {
142
142
  ctx.out(` skip: ${result.reason}\n`);
143
143
  return "skipped";
144
144
  }
145
- /* a push that is no dry run always reports both shas */
145
+ // a push that is no dry run always reports both shas
146
146
  const [source, mirror] = [result.sourceSha, result.mirrorSha];
147
147
  ctx.out(` ok: source=${source.slice(0, SHORT_SHA_LENGTH)} mirror=${mirror.slice(0, SHORT_SHA_LENGTH)}\n`);
148
148
  return "synced";
149
149
  }
150
- /* the packages a bootstrap targets, bootstrapped one after another; the exit code it ends with */
150
+ // the packages a bootstrap targets, bootstrapped one after another; the exit code it ends with
151
151
  async function bootstrapAll(release, options, token, ctx) {
152
152
  const targets = filterPackages(release.packages, { only: options.only });
153
153
  if (targets.length === 0) {
@@ -1,9 +1,9 @@
1
- /* Each flag takes the next argument as its value, unless that argument is a switch. */
1
+ // Each flag takes the next argument as its value, unless that argument is a switch.
2
2
  const BUMP_FLAGS = { "--config": "config" };
3
- /* Bare flags: present or not. */
3
+ // Bare flags: present or not.
4
4
  const BUMP_SWITCHES = { "--major": "major" };
5
- /* The value of every `flags` entry and the presence of every `switches` entry in `argv`, or the first argument that
6
- * is neither. */
5
+ // The value of every `flags` entry and the presence of every `switches` entry in `argv`, or the first argument that
6
+ // is neither.
7
7
  function readFlags(flags, switches, argv) {
8
8
  const values = {};
9
9
  const set = {};
@@ -1,6 +1,6 @@
1
1
  import type { ReleaseContext } from "./context.ts";
2
- import type { Release } from "./types.ts";
3
2
  import { type ReleaseState } from "./release-state.ts";
3
+ import type { Release } from "./types.ts";
4
4
  /** The header every CHANGELOG bump writes starts with; entries go directly under it, newest first. */
5
5
  export declare const CHANGELOG_HEADER = "# Changelog\n\n";
6
6
  /**
@@ -9,8 +9,8 @@ import * as fs from "node:fs/promises";
9
9
  import { tmpdir } from "node:os";
10
10
  import * as path from "node:path";
11
11
  import { decide } from "./bump.js";
12
- import { CHANGELOG_FILE, ENOENT, MAX_OUTPUT_BYTES, PORCELAIN_PREFIX_LENGTH, RELEASE_STATE } from "./constants.js";
13
12
  import { regenerate } from "./codegen.js";
13
+ import { CHANGELOG_FILE, ENOENT, MAX_OUTPUT_BYTES, PORCELAIN_PREFIX_LENGTH, RELEASE_STATE } from "./constants.js";
14
14
  import { handDigest, outputDigest } from "./digest.js";
15
15
  import { apiChanges } from "./oasdiff.js";
16
16
  import { releaseStateSchema } from "./release-state.js";
@@ -50,7 +50,7 @@ async function prependChangelog(changelogFile, entry) {
50
50
  await fs.writeFile(changelogFile, prependEntry(existing, entry), "utf8");
51
51
  }
52
52
  const git = (root, ...args) => execFileSync("git", args, { cwd: root, encoding: "utf8", maxBuffer: MAX_OUTPUT_BYTES });
53
- /* The committed spec as HEAD holds it; refuses a working copy that differs, since the state records HEAD. */
53
+ // The committed spec as HEAD holds it; refuses a working copy that differs, since the state records HEAD.
54
54
  function committedSpec({ root, spec }) {
55
55
  const specPath = path.relative(root, spec.committedPath);
56
56
  const sha = canonicalSha(JSON.parse(readFileSync(spec.committedPath, "utf8")));
@@ -66,7 +66,7 @@ function committedSpec({ root, spec }) {
66
66
  }
67
67
  return { commit: git(root, "rev-parse", "HEAD").trim(), path: specPath, sha };
68
68
  }
69
- /* oasdiff from each released spec to the committed one, run once per released spec. */
69
+ // oasdiff from each released spec to the committed one, run once per released spec.
70
70
  function changesSince(release, env) {
71
71
  const found = new Map();
72
72
  return (released) => {
@@ -74,9 +74,8 @@ function changesSince(release, env) {
74
74
  if (cached !== undefined)
75
75
  return cached;
76
76
  const base = git(release.root, "show", `${released.commit}:${released.path}`);
77
- if (canonicalSha(JSON.parse(base)) !== released.sha) {
77
+ if (canonicalSha(JSON.parse(base)) !== released.sha)
78
78
  throw new Error(`${released.commit}:${released.path} is not the spec the release recorded (${released.sha})`);
79
- }
80
79
  const dir = mkdtempSync(path.join(tmpdir(), "oss-release-spec-"));
81
80
  try {
82
81
  const file = path.join(dir, "released.json");
@@ -90,14 +89,14 @@ function changesSince(release, env) {
90
89
  }
91
90
  };
92
91
  }
93
- /* Paths under `dir` that differ from HEAD (tracked or new, never ignored), repo-relative. */
92
+ // Paths under `dir` that differ from HEAD (tracked or new, never ignored), repo-relative.
94
93
  function changedPaths(root, dir) {
95
94
  return git(root, "status", "--porcelain=v1", "-z", "--untracked-files=all", "--", dir)
96
95
  .split("\0")
97
96
  .filter((entry) => entry.length > PORCELAIN_PREFIX_LENGTH)
98
97
  .map((entry) => entry.slice(PORCELAIN_PREFIX_LENGTH));
99
98
  }
100
- /* each package's decision from its digests now and its last release */
99
+ // each package's decision from its digests now and its last release
101
100
  async function plan(release, major, env) {
102
101
  const spec = committedSpec(release);
103
102
  const changes = changesSince(release, env);
@@ -105,7 +104,7 @@ async function plan(release, major, env) {
105
104
  const planned = [];
106
105
  for (const pkg of release.packages) {
107
106
  const dir = path.join(release.root, pkg.path);
108
- /* a version file bump cannot read fails the run before anything is written */
107
+ // a version file bump cannot read fails the run before anything is written
109
108
  readVersions(dir);
110
109
  const previous = await readPrevious(path.join(dir, RELEASE_STATE));
111
110
  const observed = { hand: handDigest(release.root, pkg), output: outputDigest(release.root, pkg, spec.sha), spec };
@@ -121,7 +120,7 @@ async function plan(release, major, env) {
121
120
  }
122
121
  return planned;
123
122
  }
124
- /* writes one package's state and changelog, and reports every path its release touched */
123
+ // writes one package's state and changelog, and reports every path its release touched
125
124
  async function record(release, { decision, dir, now, observed, pkg }, versionFiles, ctx) {
126
125
  const { root } = release;
127
126
  const state = {
@@ -174,7 +173,7 @@ export async function runBump(release, major, ctx) {
174
173
  ctx.out("no changes since last release\n");
175
174
  return 0;
176
175
  }
177
- /* versions first, then codegen at those versions, so the recorded digests are the released output's */
176
+ // versions first, then codegen at those versions, so the recorded digests are the released output's
178
177
  const written = releasing.map((planned) => ({
179
178
  files: writeVersions(planned.dir, planned.decision.nextVersion),
180
179
  planned,
@@ -6,7 +6,7 @@ export type Observed = {
6
6
  output: string;
7
7
  spec: ReleaseState["spec"];
8
8
  };
9
- export type ReleaseKind = "initial" | "major" | "minor" | "patch";
9
+ type ReleaseKind = "initial" | "major" | "minor" | "patch";
10
10
  export type Decision = {
11
11
  kind: "none";
12
12
  } | {
@@ -14,7 +14,7 @@ export type Decision = {
14
14
  kind: ReleaseKind;
15
15
  nextVersion: string;
16
16
  };
17
- export interface DecideInput {
17
+ export type DecideInput = {
18
18
  /** oasdiff from the released spec to the observed one; called only when the output changed and the spec moved */
19
19
  changes: (released: ReleaseState["spec"]) => readonly ApiChange[];
20
20
  /** the first release's CHANGELOG text */
@@ -23,11 +23,12 @@ export interface DecideInput {
23
23
  major?: boolean;
24
24
  now: Date;
25
25
  observed: Observed;
26
- previous?: ReleaseState;
27
- }
26
+ previous?: ReleaseState | undefined;
27
+ };
28
28
  /**
29
29
  * Whether a package releases and at what level. Nothing releases while its output and hand files match the last
30
30
  * release, even when the spec moved (a package may expose only part of it). A changed output on a moved spec with
31
31
  * any oasdiff entry is a minor; every other change is a patch; `major` makes any release a major.
32
32
  */
33
33
  export declare function decide(input: DecideInput): Decision;
34
+ export {};
@@ -7,11 +7,11 @@ function nextVersion(version, kind) {
7
7
  return `${major}.${minor + 1}.0`;
8
8
  return `${major}.${minor}.${patch + 1}`;
9
9
  }
10
- /* Every package stays on its major line: any API change, breaking or not, is a minor; a major is only ever asked for. */
10
+ // Every package stays on its major line: any API change, breaking or not, is a minor; a major is only ever asked for.
11
11
  function levelOf(changes) {
12
12
  return changes.length > 0 ? "minor" : "patch";
13
13
  }
14
- /* Each operation once, under the first section it belongs to: breaking, then added, then changed. */
14
+ // Each operation once, under the first section it belongs to: breaking, then added, then changed.
15
15
  function sections(changes) {
16
16
  const byOperation = new Map();
17
17
  for (const change of changes) {
@@ -6,15 +6,15 @@
6
6
  import type { Io } from "../cli.ts";
7
7
  import { type LoadReleaseOptions } from "./load.ts";
8
8
  /** What `clients release` prints when it is given no command, or one it does not know. */
9
- export declare const USAGE = "usage: clients release <command> --config <path> [options]\n\n bump --config <path> [--major]\n regenerate, then release each package whose output or hand files changed: any API change is a minor,\n --major makes each release a major\n sync --config <path> [--only <names>] [--dry-run] [--validate-only]\n mirror each package into its public repo (release sync --help says more)\n bootstrap --config <path> (--all | --only <names>) [--force-bootstrap]\n the first push to an empty public repo, or over the stub a new one starts with\n codegen --config <path>\n run the config's codegen from the repo root, as bump does before it decides\n toolchains --config <path>\n print the config's toolchains, one per line: the system.config.ts names its codegen needs\n";
9
+ export declare const USAGE: string;
10
10
  /** What a release run reads beside its arguments; each defaults to the running process's own. */
11
11
  export type ReleaseOptions = {
12
12
  /** The environment: `GH_TOKEN`, and what codegen and Go run with. */
13
- readonly env?: NodeJS.ProcessEnv;
13
+ readonly env?: NodeJS.ProcessEnv | undefined;
14
14
  /** The fetch the spec gate and the GitHub settings step use. */
15
- readonly fetch?: typeof fetch;
15
+ readonly fetch?: typeof fetch | undefined;
16
16
  /** How the release config is imported (`loadRelease`'s options). */
17
- readonly load?: LoadReleaseOptions;
17
+ readonly load?: LoadReleaseOptions | undefined;
18
18
  };
19
19
  /**
20
20
  * Runs `clients release <argv>`: the exit code it ends with. A usage mistake is one line naming the command; any
@@ -5,7 +5,7 @@ import { regenerate } from "./codegen.js";
5
5
  import { parseConfigOnly, ReleaseUsageError } from "./context.js";
6
6
  import { readRelease } from "./load.js";
7
7
  import { sync } from "./sync-command.js";
8
- /* the usage entries of the commands that take only --config, each also its own --help */
8
+ // the usage entries of the commands that take only --config, each also its own --help
9
9
  const CODEGEN_USAGE = `codegen --config <path>
10
10
  run the config's codegen from the repo root, as bump does before it decides
11
11
  `;
@@ -23,14 +23,14 @@ export const USAGE = `usage: clients release <command> --config <path> [options]
23
23
  bootstrap --config <path> (--all | --only <names>) [--force-bootstrap]
24
24
  the first push to an empty public repo, or over the stub a new one starts with
25
25
  ${CODEGEN_USAGE} ${TOOLCHAINS_USAGE}`;
26
- /* `release bump <argv>`: the release its config describes, bumped */
26
+ // `release bump <argv>`: the release its config describes, bumped
27
27
  async function bump(argv, ctx) {
28
28
  const parsed = parseBumpArgs(argv);
29
29
  if (!parsed.ok)
30
30
  throw new ReleaseUsageError(parsed.error);
31
31
  return runBump(await ctx.load(parsed.value.config), parsed.value.major, ctx);
32
32
  }
33
- /* `release codegen <argv>`: the config's codegen, run as bump runs it */
33
+ // `release codegen <argv>`: the config's codegen, run as bump runs it
34
34
  async function codegen(argv, ctx) {
35
35
  const parsed = parseConfigOnly(argv);
36
36
  if (parsed.help) {
@@ -40,7 +40,7 @@ async function codegen(argv, ctx) {
40
40
  regenerate(await ctx.load(parsed.config), ctx.env);
41
41
  return 0;
42
42
  }
43
- /* `release toolchains <argv>`: the config's toolchains, one per line, for a workflow to install before codegen */
43
+ // `release toolchains <argv>`: the config's toolchains, one per line, for a workflow to install before codegen
44
44
  async function toolchains(argv, ctx) {
45
45
  const parsed = parseConfigOnly(argv);
46
46
  if (parsed.help) {
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { spawnSync } from "node:child_process";
7
7
  import { RELEASE_VERSIONS_ENV } from "./manifest.js";
8
- /* codegen's own output goes to stderr's descriptor, so stdout stays the command's report */
8
+ // codegen's own output goes to stderr's descriptor, so stdout stays the command's report
9
9
  const STDERR_FD = 2;
10
10
  /**
11
11
  * Runs the product's codegen from the repo root in `env`, with `versions` (package name to version) as