@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
@@ -3,13 +3,13 @@ import { goString } from "../shared/escape.js";
3
3
  import { compareCodeUnits } from "../shared/lang.js";
4
4
  import { commandFlags, helpText } from "./flags.js";
5
5
  /** How deep a schema sketch shows objects: deeper ones are `{…}`. */
6
- export const SKETCH_DEPTH = 3;
6
+ const SKETCH_DEPTH = 3;
7
7
  /** The longest summary an index line carries, in characters, `…` included. */
8
- export const SUMMARY_MAX = 80;
8
+ const SUMMARY_MAX = 80;
9
9
  /** The most values an index line spells out for an enum: more show as `<enum:N>` (the schema lists them all). */
10
- export const ENUM_MAX = 6;
10
+ const ENUM_MAX = 6;
11
11
  /** Spec text on one line: helpText's, its whitespace runs one space. */
12
- const oneLine = (text) => helpText(text).replace(/\s+/g, " ").trim();
12
+ const oneLine = (text) => helpText(text).replaceAll(/\s+/g, " ").trim();
13
13
  /** A summary as the index carries it: its first sentence, at most SUMMARY_MAX characters with `…`. */
14
14
  export function summaryOf(text) {
15
15
  const line = oneLine(text);
@@ -18,7 +18,7 @@ export function summaryOf(text) {
18
18
  return chars.length <= SUMMARY_MAX ? sentence : `${chars.slice(0, SUMMARY_MAX - 1).join("")}…`;
19
19
  }
20
20
  /** JSON text with DEL, C1, the BOM and the line separators escaped too (JSON.stringify leaves them raw): exact, and safe. */
21
- const json = (value) => JSON.stringify(value).replace(/[\u007f-\u009f\u2028\u2029\ufeff]/g, (ch) => `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`);
21
+ const json = (value) => JSON.stringify(value).replaceAll(/[\u007f-\u009f\u2028\u2029\ufeff]/g, (ch) => `\\u${ch.charCodeAt(0).toString(16).padStart(4, "0")}`);
22
22
  /** A value as a usage line shows it: bare when it is a plain word, else quoted. */
23
23
  const word = (value) => (/^[\w.:/@+-]+$/.test(value) ? value : json(value));
24
24
  /** A flag's value as the usage line shows it: its enum, `<enum:N>` past `enumMax`, else its kind; repeatable `...`. */
@@ -64,7 +64,9 @@ function objectSketch(schema, at) {
64
64
  /** A ref's sketch: its schema inlined, or its name when it is already open (recursive) or unknown. */
65
65
  function refSketch(name, at) {
66
66
  const target = at.model.ir.schemas[name];
67
- return target === undefined || at.open.includes(name) ? key(name) : shown(target, { ...at, open: [...at.open, name] });
67
+ return target === undefined || at.open.includes(name)
68
+ ? key(name)
69
+ : shown(target, { ...at, open: [...at.open, name] });
68
70
  }
69
71
  /** The sketch of a schema of each kind. */
70
72
  const SKETCHES = {
@@ -92,7 +94,7 @@ export const sketch = (schema, model) => shown(schema, { depth: 0, model, open:
92
94
  /** Each declared error status, with the keys its backend error envelope names: `[status, keys]`. */
93
95
  function errorsOf(op, model) {
94
96
  return op.errorStatuses.map((status) => {
95
- /* an error status is one of the operation's declared responses */
97
+ // an error status is one of the operation's declared responses
96
98
  const { schema } = op.ir.responses[String(status)];
97
99
  return [status, schema === undefined ? [] : (irErrorEnvelope(schema, model.resolve)?.keys ?? [])];
98
100
  });
@@ -9,8 +9,6 @@
9
9
  import type { IRSchema } from "../../ir/model.ts";
10
10
  import type { SdkOp } from "../../ir/sdk-model.ts";
11
11
  import type { GoCallPlan } from "../go/sdk-client.ts";
12
- /** The flags every command has, and those later phases give it: a parameter never takes one of these names. */
13
- export declare const GLOBAL_FLAGS: string[];
14
12
  /** A flag's kind as the runtime checks it, whether it repeats, and its allowed values. */
15
13
  export type Kind = {
16
14
  readonly kind: string;
@@ -45,7 +43,7 @@ export type Usage = {
45
43
  readonly kind: Kind;
46
44
  readonly required: boolean;
47
45
  /** the parameter's own name, for a path, query or header parameter */
48
- readonly param?: string;
46
+ readonly param?: string | undefined;
49
47
  };
50
48
  /** One multipart part's flag, `--<part>`: a value of `kind` for a text part, a path for a file part. */
51
49
  export type PartFlag = {
@@ -1,7 +1,7 @@
1
1
  import { goString, invisible } from "../shared/escape.js";
2
2
  import { NameScope, words } from "../shared/lang.js";
3
3
  /** The flags every command has, and those later phases give it: a parameter never takes one of these names. */
4
- export const GLOBAL_FLAGS = [
4
+ const GLOBAL_FLAGS = [
5
5
  "api-key",
6
6
  "base-url",
7
7
  "config",
@@ -29,7 +29,7 @@ const JSON_KIND = { enum: [], kind: "json", list: false };
29
29
  * the BOM, the line and paragraph separators, the bidi controls) dropped, so no spec can move the cursor, recolor a
30
30
  * user's terminal or reorder what it shows.
31
31
  */
32
- export const helpText = (text) => [...text.replace(/\r\n?/g, "\n")].filter((ch) => !hidden(ch.codePointAt(0))).join("");
32
+ export const helpText = (text) => [...text.replaceAll(/\r\n?/g, "\n")].filter((ch) => !hidden(ch.codePointAt(0))).join("");
33
33
  /** Whether a code point is one help drops: a C0 control but tab and line feed, DEL, C1, the BOM, U+2028, U+2029, bidi. */
34
34
  const hidden = (cp) => (cp < 0x20 && cp !== 0x09 && cp !== 0x0a) ||
35
35
  cp === 0x7f ||
@@ -98,7 +98,7 @@ export function commandFlags(op, plan, schemas) {
98
98
  lines.push(`\tp.Path(${names.map(goString).join(", ")})`);
99
99
  usage.push(...names.map((name, i) => ({ kind: STRING, name, param: plan.pathParams[i], positional: true, required: true })));
100
100
  }
101
- /* each param the SDK gives an Opts field, by the plan: a stream's channel param (Last-Event-ID) has none */
101
+ // each param the SDK gives an Opts field, by the plan: a stream's channel param (Last-Event-ID) has none
102
102
  const params = (specs, fields) => {
103
103
  for (const [param, field] of Object.entries(fields)) {
104
104
  const spec = specs.find((each) => each.name === param);
@@ -122,8 +122,14 @@ export function commandFlags(op, plan, schemas) {
122
122
  return { declare: lines, fields: [], opts, parts, usage };
123
123
  }
124
124
  const fields = bodyFields(op, schemas, scope, lines);
125
- if (op.body !== undefined)
126
- usage.push({ kind: { ...STRING, kind: op.body.kind }, name: "data", positional: false, required: op.body.required });
125
+ if (op.body !== undefined) {
126
+ usage.push({
127
+ kind: { ...STRING, kind: op.body.kind },
128
+ name: "data",
129
+ positional: false,
130
+ required: op.body.required,
131
+ });
132
+ }
127
133
  return { declare: lines, fields, opts, parts: [], usage };
128
134
  }
129
135
  /** A stream's cursor flags, each `[flag, its Opts field, usage]`: the names GLOBAL_FLAGS keeps from a parameter. */
@@ -19,8 +19,6 @@ export type InstallApp = {
19
19
  readonly prefix: string;
20
20
  readonly installUrl: string;
21
21
  };
22
- /** The issuer of the OIDC token a GitHub Actions run signs with. */
23
- export declare const ISSUER = "https://token.actions.githubusercontent.com";
24
22
  /**
25
23
  * The `npx` that runs installgen from the clients release that wrote the scripts: the release workflow's `check` runs
26
24
  * it on installgen.config.mts in the module's root, so the scripts and their check always come from one release.
@@ -30,11 +28,5 @@ export declare function installgenCommand(): string;
30
28
  export declare const INSTALLGEN_CONFIG = "installgen.config.mts";
31
29
  /** installgen's config for `app`, its files under `base` (the repository's GitHub Releases outside a test). */
32
30
  export declare function installerConfig(app: InstallApp, base?: string): InstallgenConfig;
33
- /**
34
- * `installgen.config.mts` for `app`: `installerConfig`'s config as a module installgen loads with no local install
35
- * (its one import is type-only, which Node 22.18+ strips), so `installgenCommand()`'s `check` runs in the module's root
36
- * with nothing installed.
37
- */
38
- export declare function installgenConfigFile(app: InstallApp): string;
39
31
  /** `install.sh`, `install.ps1` and `installgen.config.mts` for `app`, by file name. */
40
32
  export declare function installFiles(app: InstallApp): Record<string, string>;
@@ -14,7 +14,7 @@
14
14
  import { generateInstallers } from "../../installers/index.js";
15
15
  import { clientsVersion } from "../../version.js";
16
16
  /** The issuer of the OIDC token a GitHub Actions run signs with. */
17
- export const ISSUER = "https://token.actions.githubusercontent.com";
17
+ const ISSUER = "https://token.actions.githubusercontent.com";
18
18
  /**
19
19
  * The `npx` that runs installgen from the clients release that wrote the scripts: the release workflow's `check` runs
20
20
  * it on installgen.config.mts in the module's root, so the scripts and their check always come from one release.
@@ -60,7 +60,7 @@ export function installerConfig(app, base = `https://github.com/${app.repo}/rele
60
60
  * (its one import is type-only, which Node 22.18+ strips), so `installgenCommand()`'s `check` runs in the module's root
61
61
  * with nothing installed.
62
62
  */
63
- export function installgenConfigFile(app) {
63
+ function installgenConfigFile(app) {
64
64
  const installgen = installgenCommand();
65
65
  const { asset, checksums, identity, plain } = layout(app, `https://github.com/${app.repo}/releases`);
66
66
  const value = (key) => `\t${key}: ${JSON.stringify(plain[key])},\n`;
@@ -83,7 +83,7 @@ ${value("envPrefix")}${value("installDir")}${value("latestPath")}${value("messag
83
83
  /** `install.sh`, `install.ps1` and `installgen.config.mts` for `app`, by file name. */
84
84
  export function installFiles(app) {
85
85
  const { ps1, sh } = generateInstallers(installerConfig(app));
86
- /* every platform is configured, so installgen writes both */
86
+ // every platform is configured, so installgen writes both
87
87
  const scripts = [
88
88
  ["install.ps1", ps1],
89
89
  ["install.sh", sh],
@@ -10,7 +10,7 @@ import { type Entry } from "./discovery.ts";
10
10
  /** The CLI's name, description and environment prefix, and its module. */
11
11
  export type CliApp = {
12
12
  /** the base URL the root command is built with; none when the document declares no server */
13
- readonly baseUrl?: string;
13
+ readonly baseUrl?: string | undefined;
14
14
  readonly binaryName: string;
15
15
  readonly short: string;
16
16
  readonly envPrefix: string;
@@ -4,12 +4,15 @@ import { compareCodeUnits, NameScope, snakeWords } from "../shared/lang.js";
4
4
  import { groupFuncs } from "./commands.js";
5
5
  import { discoveryBody } from "./discovery.js";
6
6
  import { helpText } from "./flags.js";
7
- /* the marker gopls and linters read, apart from the package doc by a blank line */
7
+ // the marker gopls and linters read, apart from the package doc by a blank line
8
8
  const MARKER = "// Code generated by clients. DO NOT EDIT.";
9
9
  /** What a cmd file imports, by the packages its code names: the runtime always. */
10
10
  const importsOf = (text) => {
11
11
  const code = text.replace(NOT_CODE, "");
12
- return ["cli", ...["cobra", "errors", "http", "json", "sdk"].filter((name) => new RegExp(`\\b${name}\\.`).test(code))];
12
+ return [
13
+ "cli",
14
+ ...["cobra", "errors", "http", "json", "sdk"].filter((name) => new RegExp(`\\b${name}\\.`).test(code)),
15
+ ];
13
16
  };
14
17
  /** Each package a cmd file may import, by name, in its import group: the standard library, cobra, the module's own. */
15
18
  const PACKAGES = {
@@ -34,7 +37,7 @@ function cmdFile(module, body, doc = "") {
34
37
  return `${MARKER}\n\n${doc}package cmd\n\nimport (\n${block}\n)\n\n${body}\n`;
35
38
  }
36
39
  /** cmd/root.go: the root command, named by the binary, its skill given, its top-level commands its API ones. */
37
- function rootBody(app, ir, nodes) {
40
+ function rootBody(app, nodes) {
38
41
  const fields = [
39
42
  `Name: ${goString(app.binaryName)}`,
40
43
  `Short: ${goString(helpText(app.short))}`,
@@ -55,15 +58,15 @@ function rootBody(app, ir, nodes) {
55
58
  * cmd/client.go: the SDK client the run's settings configure, its requests and responses logged under --verbose, and
56
59
  * an answer outside 2xx as the runtime's APIError. An API that declares no server needs a base URL set.
57
60
  */
58
- function clientBody(app, ir) {
61
+ function clientBody(app) {
59
62
  const env = `$${app.envPrefix}_BASE_URL`;
60
- const noServer = app.baseUrl !== undefined
61
- ? []
62
- : [
63
+ const noServer = app.baseUrl === undefined
64
+ ? [
63
65
  '\tif s.BaseURL == "" {',
64
66
  `\t\treturn nil, cli.Usage(${goString(`no base URL: set --base-url, ${env} or base_url in the config file`)})`,
65
67
  "\t}",
66
- ];
68
+ ]
69
+ : [];
67
70
  return [
68
71
  "// newClient is the API client the run's settings configure.",
69
72
  "func newClient(c *cobra.Command) (*sdk.Client, error) {",
@@ -104,9 +107,9 @@ function clientBody(app, ir) {
104
107
  export function cmdFiles(app, ir, nodes, entries) {
105
108
  const stems = new NameScope(["client", "root"]);
106
109
  const files = {
107
- "cmd/client.go": cmdFile(app.modulePath, clientBody(app, ir)),
110
+ "cmd/client.go": cmdFile(app.modulePath, clientBody(app)),
108
111
  "cmd/discovery.go": cmdFile(app.modulePath, discoveryBody(entries)),
109
- "cmd/root.go": cmdFile(app.modulePath, rootBody(app, ir, nodes), `// Package cmd holds the ${app.binaryName} commands.\n`),
112
+ "cmd/root.go": cmdFile(app.modulePath, rootBody(app, nodes), `// Package cmd holds the ${app.binaryName} commands.\n`),
110
113
  };
111
114
  for (const node of nodes) {
112
115
  const body = groupFuncs(node, [], ir)
@@ -2,20 +2,20 @@ import { type PackageIdentity } from "../shared/metadata.ts";
2
2
  import { type ReleaseOptions } from "./release.ts";
3
3
  export type GoCliOptions = ReleaseOptions & {
4
4
  /** the binary and root command name: lowercase words joined by `-`, at most 64 characters; the title's, else `api` */
5
- readonly binaryName?: string;
5
+ readonly binaryName?: string | undefined;
6
6
  /** the module path go.mod declares, a domain first; `example.com/<binaryName>` by default */
7
- readonly modulePath?: string;
7
+ readonly modulePath?: string | undefined;
8
8
  /** the module's version, semver: from v2 on, its major suffix (`/v2`) ends the module path */
9
- readonly version?: string;
9
+ readonly version?: string | undefined;
10
10
  /** the environment variables' prefix: uppercase words joined by `_`; the binary name's by default */
11
- readonly envPrefix?: string;
11
+ readonly envPrefix?: string | undefined;
12
12
  /** the GitHub repository the release is published to, `owner/name`; none by default (then no install scripts) */
13
- readonly repo?: string;
13
+ readonly repo?: string | undefined;
14
14
  /**
15
15
  * the base URL the binary calls by default, absolute; the document's first server by default. A document
16
16
  * served under a path (a gateway's `servers: [{ url: "/api" }]`) names no host a CLI can call, so it needs this.
17
17
  */
18
- readonly baseUrl?: string;
18
+ readonly baseUrl?: string | undefined;
19
19
  };
20
20
  export type GeneratedGoCli = {
21
21
  readonly files: Readonly<Record<string, string>>;
@@ -11,17 +11,17 @@
11
11
  import { readFileSync } from "node:fs";
12
12
  import { toIR } from "../../ir/build.js";
13
13
  import { sdkModel } from "../../ir/sdk-model.js";
14
- import { compareCodeUnits } from "../shared/lang.js";
15
- import { packageOn } from "../shared/metadata.js";
16
14
  import { goModulePath } from "../go/module-path.js";
17
15
  import { generateGoSdk, goCallPlans, WEBSOCKET, WEBSOCKET_SUM } from "../go/sdk.js";
16
+ import { compareCodeUnits } from "../shared/lang.js";
17
+ import { packageOn } from "../shared/metadata.js";
18
18
  import { commandTree } from "./commands.js";
19
19
  import { discoveryEntries } from "./discovery.js";
20
20
  import { installFiles } from "./install.js";
21
21
  import { cmdFiles } from "./layout.js";
22
22
  import { goreleaserFile, releaseWorkflow, REPO, resolvedRelease } from "./release.js";
23
23
  import { skillFile, skillPath } from "./skills.js";
24
- /* the marker gopls and linters read, apart from the package doc by a blank line */
24
+ // the marker gopls and linters read, apart from the package doc by a blank line
25
25
  const MARKER = "// Code generated by clients. DO NOT EDIT.";
26
26
  /** The runtime files a CLI ships, read from `runtime/cli/` and nowhere else; SOCKET only beside the WebSocket library. */
27
27
  export const CLI_RUNTIME = [
@@ -39,7 +39,7 @@ export const CLI_RUNTIME = [
39
39
  ];
40
40
  /** The runtime file that names the WebSocket library: shipped only when the SDK requires it. */
41
41
  const SOCKET = "socket.go";
42
- /* the CLI's own requirements and their go.sum lines, exactly as `go mod tidy` writes them */
42
+ // the CLI's own requirements and their go.sum lines, exactly as `go mod tidy` writes them
43
43
  const DIRECT = [
44
44
  "github.com/pelletier/go-toml/v2 v2.4.3",
45
45
  "github.com/spf13/cobra v1.10.2",
@@ -61,11 +61,11 @@ const SUM = [
61
61
  "go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=",
62
62
  "gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=",
63
63
  ];
64
- /* a binary: lowercase words joined by `-`, at most 64 characters (its agent skill's name is the binary's); an
65
- * environment prefix: uppercase words joined by `_` */
64
+ // a binary: lowercase words joined by `-`, at most 64 characters (its agent skill's name is the binary's); an
65
+ // environment prefix: uppercase words joined by `_`
66
66
  const BINARY_NAME = /^(?=.{1,64}$)[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
67
67
  const ENV_PREFIX = /^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/;
68
- /* a base URL a CLI can call: a scheme and a host, never a path alone */
68
+ // a base URL a CLI can call: a scheme and a host, never a path alone
69
69
  const ABSOLUTE_URL = /^https?:\/\/[^\s/]+/;
70
70
  const refuse = (option, value) => {
71
71
  throw new Error(`Invalid ${option}: ${JSON.stringify(value)}`);
@@ -73,8 +73,8 @@ const refuse = (option, value) => {
73
73
  /** The binary name a title gives: its letters and digits, lowercased, joined by `-`; `api` when it has none. */
74
74
  export const binaryNameOf = (title) => (title ?? "")
75
75
  .toLowerCase()
76
- .replace(/[^a-z0-9]+/g, "-")
77
- .replace(/^[^a-z]+|-+$/g, "") || "api";
76
+ .replaceAll(/[^a-z0-9]+/g, "-")
77
+ .replaceAll(/^[^a-z]+|-+$/g, "") || "api";
78
78
  /**
79
79
  * The base URL the binary calls: the option, else the document's first server when that is absolute. A relative
80
80
  * server is no base URL a CLI can call — a gateway's document says `servers: [{ url: "/api" }]` — so it is left
@@ -103,7 +103,7 @@ function resolved(options, title) {
103
103
  return { baseUrl: options.baseUrl, binaryName, envPrefix, modulePath, repo: options.repo };
104
104
  }
105
105
  /** A go.sum line's order key: its module path, then its version with each number zero-padded, as Go sorts them. */
106
- const sumKey = (line) => line.replace(/\d+/g, (digits) => digits.padStart(20, "0"));
106
+ const sumKey = (line) => line.replaceAll(/\d+/g, (digits) => digits.padStart(20, "0"));
107
107
  /** A require directive as `go mod tidy` writes it: one requirement on its line, more in a block. */
108
108
  const requireOf = (lines) => lines.length === 1 ? `require ${lines[0]}\n` : `require (\n${lines.map((line) => `\t${line}`).join("\n")}\n)\n`;
109
109
  /** go.mod and go.sum: the CLI's requirements, and the WebSocket library's when the embedded SDK needs it. */
@@ -18,19 +18,8 @@
18
18
  */
19
19
  import { type Release } from "./channels.ts";
20
20
  export { REPO, type Release, type ReleaseOptions, resolvedRelease } from "./channels.ts";
21
- /** The tools release.yml runs, each pinned by commit (its release in the comment beside it). */
22
- export declare const RELEASE_ACTIONS: {
23
- attest: string;
24
- checkout: string;
25
- cosign: string;
26
- goreleaser: string;
27
- setupGo: string;
28
- setupNode: string;
29
- };
30
21
  /** A value as a YAML double-quoted scalar (a JSON string is one): a name like `true` or `1e3` stays a string. */
31
22
  export declare const q: (value: string) => string;
32
- /** The goreleaser release the action installs: the one the tests check the config with. */
33
- export declare const GORELEASER_VERSION = "v2.18.3";
34
23
  /** .goreleaser.yaml for the CLI `bin` in module `modulePath`, released per `release` when it names a repository. */
35
24
  export declare function goreleaserFile(bin: string, modulePath: string, release: Release | undefined): string;
36
25
  /**
@@ -19,10 +19,10 @@
19
19
  import { channelBlock, SECRETS } from "./channels.js";
20
20
  import { installgenCommand } from "./install.js";
21
21
  export { REPO, resolvedRelease } from "./channels.js";
22
- /* the marker generated YAML carries on its first line */
22
+ // the marker generated YAML carries on its first line
23
23
  const MARKER = "# Code generated by clients. DO NOT EDIT.";
24
24
  /** The tools release.yml runs, each pinned by commit (its release in the comment beside it). */
25
- export const RELEASE_ACTIONS = {
25
+ const RELEASE_ACTIONS = {
26
26
  attest: "actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2",
27
27
  checkout: "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1",
28
28
  cosign: "sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2",
@@ -33,10 +33,10 @@ export const RELEASE_ACTIONS = {
33
33
  /** A value as a YAML double-quoted scalar (a JSON string is one): a name like `true` or `1e3` stays a string. */
34
34
  export const q = (value) => JSON.stringify(value);
35
35
  /** The goreleaser release the action installs: the one the tests check the config with. */
36
- export const GORELEASER_VERSION = "v2.18.3";
36
+ const GORELEASER_VERSION = "v2.18.3";
37
37
  /** .goreleaser.yaml for the CLI `bin` in module `modulePath`, released per `release` when it names a repository. */
38
38
  export function goreleaserFile(bin, modulePath, release) {
39
- /* without a repository, goreleaser releases to the git remote's, and there is no version file to serve */
39
+ // without a repository, goreleaser releases to the git remote's, and there is no version file to serve
40
40
  const before = release === undefined
41
41
  ? ""
42
42
  : `# the release's tag, which the install scripts read through releases/latest/download
@@ -7,8 +7,8 @@ export const skillPath = (binaryName) => `skills/${binaryName}/SKILL.md`;
7
7
  const streamsOf = (ops) => ["sse", "ws", "realtime"].filter((kind) => ops.some((op) => op.stream === kind));
8
8
  /** SKILL.md for the CLI `bin` over the API `title` and its operations, its env variables prefixed `prefix`. */
9
9
  export function skillFile(bin, title, prefix, ops) {
10
- const named = [...(helpText(title).replace(/\s+/g, " ").trim() || bin)];
11
- /* the description stays within the format's 1024 characters whatever the title */
10
+ const named = [...(helpText(title).replaceAll(/\s+/g, " ").trim() || bin)];
11
+ // the description stays within the format's 1024 characters whatever the title
12
12
  const api = named.length <= TITLE_MAX ? named.join("") : `${named.slice(0, TITLE_MAX - 1).join("")}…`;
13
13
  const description = `Call the ${api} API from the shell with ${bin}: find a command, read its request and answer, call it, and branch on its JSON output and exit code.`;
14
14
  const streams = streamsOf(ops);
@@ -32,7 +32,7 @@ export function skillFile(bin, title, prefix, ops) {
32
32
  return [
33
33
  "---",
34
34
  `name: ${bin}`,
35
- /* a JSON string is a YAML double-quoted scalar: a colon or quote in the title cannot end it */
35
+ // a JSON string is a YAML double-quoted scalar: a colon or quote in the title cannot end it
36
36
  `description: ${JSON.stringify(description)}`,
37
37
  "---",
38
38
  "",
@@ -3,12 +3,12 @@ import { csString } from "../shared/escape.js";
3
3
  import { compareCodeUnits, csTypeName, NameScope } from "../shared/lang.js";
4
4
  import { docLines } from "./sdk-doc.js";
5
5
  import { csTopLevel, declares } from "./types.js";
6
- /* the class's own name (CS0542) and the members a static class would hide (CS0108 under warnings as errors) */
6
+ // the class's own name (CS0542) and the members a static class would hide (CS0108 under warnings as errors)
7
7
  const RESERVED = ["ErrorKey", "Equals", "GetHashCode", "GetType", "MemberwiseClone", "ReferenceEquals", "ToString"];
8
8
  /** The keys an error response's envelope names, over every operation's JSON error statuses. */
9
9
  function envelopeKeys(model) {
10
10
  return model.ops.flatMap((op) => op.errorStatuses.flatMap((status) => {
11
- /* an error status is a declared response, and a schema comes with the content type it is under */
11
+ // an error status is a declared response, and a schema comes with the content type it is under
12
12
  const { contentType, schema } = op.ir.responses[String(status)];
13
13
  if (schema === undefined || !isJsonMedia(contentType))
14
14
  return [];
@@ -37,7 +37,7 @@ function bodyType(key, schema, model, at) {
37
37
  if (!declares(schema) || irErrorEnvelope(schema, model.resolve) !== null)
38
38
  return undefined;
39
39
  const name = at.names.claim(`${csTypeName(key)}Data`);
40
- /* claimed before its body: what the body hoists in turn comes after it */
40
+ // claimed before its body: what the body hoists in turn comes after it
41
41
  at.decls.set(name, "");
42
42
  at.decls.set(name, csTopLevel(name, schema, at));
43
43
  return name;
@@ -56,7 +56,7 @@ export function csharpErrorKeys(model, at) {
56
56
  member: members.claim(csTypeName(wire)),
57
57
  wire,
58
58
  }));
59
- const decoded = keys.flatMap(({ data, wire }) => (data === undefined ? [] : [`${wire}: its body decodes as ${data}`]));
59
+ const decoded = keys.flatMap(({ data, wire }) => data === undefined ? [] : [`${wire}: its body decodes as ${data}`]);
60
60
  const remark = decoded.map((line, i) => `${line}${i === 0 ? " (ApiStatusException.DecodeBody)" : ""}.`).join(" ");
61
61
  return [
62
62
  "/// <summary>The error keys the API declares: ApiStatusException.Key is one of these, else the server's own string.</summary>",
@@ -7,19 +7,19 @@
7
7
  * annotations are erased at run time, so such a type stays lenient everywhere).
8
8
  */
9
9
  import { compareCodeUnits, NameScope } from "../shared/lang.js";
10
- /* the value types emitted text spells, besides the declared enums: `T?` of one is `Nullable<T>` at run time */
10
+ // the value types emitted text spells, besides the declared enums: `T?` of one is `Nullable<T>` at run time
11
11
  const VALUE_TYPES = ["bool", "double", "JsonElement", "long"];
12
- /* the names the generator gives the BCL types it lists, which the context's own names follow */
12
+ // the names the generator gives the BCL types it lists, which the context's own names follow
13
13
  const BCL_NAMES = {
14
+ JsonElement: "JsonElement",
14
15
  bool: "Boolean",
15
16
  double: "Double",
16
- JsonElement: "JsonElement",
17
17
  long: "Int64",
18
18
  string: "String",
19
19
  };
20
20
  const LIST = /^IReadOnlyList<(.*)>$/;
21
21
  const MAP = /^IReadOnlyDictionary<string, (.*)>$/;
22
- /* the context's own members and the members every class has: no TypeInfoPropertyName may take one */
22
+ // the context's own members and the members every class has: no TypeInfoPropertyName may take one
23
23
  const CONTEXT_MEMBERS = [
24
24
  "Default",
25
25
  "Equals",
@@ -78,13 +78,13 @@ export function strictConverters(collections, runtime) {
78
78
  const lenient = new Set();
79
79
  const strict = new Set();
80
80
  for (const type of collections) {
81
- const list = LIST.exec(type)?.[1];
82
- const item = list ?? MAP.exec(type)?.[1];
81
+ const list = LIST.test(type);
82
+ const item = type.replace(list ? LIST : MAP, "$1");
83
83
  const base = runtime(item).replace(/\?$/, "");
84
- /* a value type keeps its `?` at run time: its null item fails the read already (Q2) */
84
+ // a value type keeps its `?` at run time: its null item fails the read already (Q2)
85
85
  if (runtime(`${base}?`).endsWith("?"))
86
86
  continue;
87
- const converter = `typeof(${list === undefined ? "NonNullMap" : "NonNullList"}<${base}>)`;
87
+ const converter = `typeof(${list ? "NonNullList" : "NonNullMap"}<${base}>)`;
88
88
  (item.endsWith("?") ? lenient : strict).add(converter);
89
89
  }
90
90
  return [...strict].filter((converter) => !lenient.has(converter)).sort(compareCodeUnits);
@@ -1,9 +1,9 @@
1
1
  import { eventType } from "./sdk-answer.js";
2
2
  import { isLastEventIdHeader } from "./sse.js";
3
- import { JSON_ELEMENT } from "./types.js";
4
3
  import { messageType, valueHandlers } from "./types-messages.js";
4
+ import { JSON_ELEMENT } from "./types.js";
5
5
  import { isReconnectToken } from "./ws.js";
6
- /* the connection, and its own event: a member whose On<Value> it names gets none */
6
+ // the connection, and its own event: a member whose On<Value> it names gets none
7
7
  const READER = { base: "ResumableConnection", handlers: ["OnMessage"], receiver: "connection" };
8
8
  /** The realtime operation `op`'s answer, its message types hoisted into `env.at`. */
9
9
  function realtimeAnswer(op, env) {
@@ -24,7 +24,7 @@ function realtimeAnswer(op, env) {
24
24
  export const realtimeStream = {
25
25
  answer: realtimeAnswer,
26
26
  args: ["(transport ?? new()).Copy()"],
27
- /* the WebSocket and long-poll dials send the cursor as query params, the SSE dial its id as Last-Event-ID */
27
+ // the WebSocket and long-poll dials send the cursor as query params, the SSE dial its id as Last-Event-ID
28
28
  carries: (name, where) => isReconnectToken(name, where) ||
29
29
  (where === "query" && name === "last_event_id") ||
30
30
  isLastEventIdHeader(name, where),
@@ -35,17 +35,17 @@ function declaredHeaders(op) {
35
35
  .filter((status) => /^2(?:\d\d|XX)$/i.test(status))
36
36
  .sort(compareCodeUnits)
37
37
  .flatMap((status) => op.ir.responses[status].headers ?? []);
38
- /* reversed, so the first spelling of a name is the one its key ends on */
38
+ // reversed, so the first spelling of a name is the one its key ends on
39
39
  const first = new Map(all.toReversed().map((header) => [header.name.toLowerCase(), header]));
40
40
  return [...first.values()].sort((a, b) => compareCodeUnits(a.name, b.name));
41
41
  }
42
- /* a scalar header's C# type and its reader; anything else is its text */
42
+ // a scalar header's C# type and its reader; anything else is its text
43
43
  const READERS = {
44
44
  boolean: ["bool?", "Bool"],
45
45
  integer: ["long?", "Int64"],
46
46
  number: ["double?", "Double"],
47
47
  };
48
- /* the holder's own members and the members every class has */
48
+ // the holder's own members and the members every class has
49
49
  const HOLDER_MEMBERS = ["Equals", "Finalize", "GetHashCode", "GetType", "MemberwiseClone", "Read", "ToString"];
50
50
  /** `<Op>Headers` hoisted into `env.at.decls` (never listed), and its plan; null when `op` declares none. */
51
51
  export function csResponseHeaders(op, env) {
@@ -77,7 +77,7 @@ export function csResponseHeaders(op, env) {
77
77
  "",
78
78
  " internal void Read(IReadOnlyDictionary<string, string> headers)",
79
79
  " {",
80
- ...fields.map((f) => ` ${f.property} = ResponseHeaders.${f.reader}(headers, ${csString(f.header)}, required: ${f.required === true});`),
80
+ ...fields.map((f) => ` ${f.property} = ResponseHeaders.${f.reader}(headers, ${csString(f.header)}, required: ${f.required});`),
81
81
  " }",
82
82
  "}",
83
83
  ].join("\n"));
@@ -6,13 +6,13 @@ import { csTypeOf } from "./types.js";
6
6
  const NONE = { expr: () => "null", type: null, types: [] };
7
7
  /** The parts the body schema of `op` requires: none unless it is an object. */
8
8
  function requiredParts(op, env) {
9
- /* a multipart body, with file parts or text parts alone, is declared with its form's schema */
9
+ // a multipart body, with file parts or text parts alone, is declared with its form's schema
10
10
  const form = env.at.names.resolve(op.ir.body.schema);
11
11
  return new Set(form.kind === "object" ? form.fields.flatMap((f) => (f.required ? [f.name] : [])) : []);
12
12
  }
13
13
  /** The C# type of `part` as a property of `parent`: `FilePart` or its list for a file, its schema's type for text. */
14
14
  function partType(part, parent, env) {
15
- /* the IR gives every part its schema (ir/slots.ts partsOf, ir/sdk-model.ts bodyOf) */
15
+ // the IR gives every part its schema (ir/slots.ts partsOf, ir/sdk-model.ts bodyOf)
16
16
  const schema = part.schema;
17
17
  if (part.type === "text")
18
18
  return csTypeOf(schema, { ...env.at, fieldName: part.name, parentName: parent });
@@ -21,7 +21,7 @@ function partType(part, parent, env) {
21
21
  /** `<Op>Body` for `parts`, declared once into `env.at.decls` and never listed; its name and its parts. */
22
22
  function multipartBody(op, parts, env) {
23
23
  const name = env.at.names.hoist(`${op.id}.Body`, `${csTypeName(op.id)}Body`);
24
- /* claimed before its parts: what a text part hoists in turn comes after it */
24
+ // claimed before its parts: what a text part hoists in turn comes after it
25
25
  env.at.decls.set(name, "");
26
26
  env.at.unlisted.add(name);
27
27
  const required = requiredParts(op, env);
@@ -30,7 +30,7 @@ function multipartBody(op, parts, env) {
30
30
  .sort((a, b) => compareCodeUnits(a.name, b.name))
31
31
  .map((part) => {
32
32
  const type = partType(part, name, env);
33
- /* a part left unset is null: a value type's `?` makes it Nullable<T>, which the context lists */
33
+ // a part left unset is null: a value type's `?` makes it Nullable<T>, which the context lists
34
34
  return {
35
35
  file: part.type === "file",
36
36
  name: part.name,
@@ -74,10 +74,12 @@ export function csBody(op, env) {
74
74
  const type = schemaType(body.schema);
75
75
  return { expr: (spell) => `Body.Form(body, ${spell.info(type)})`, type, types: [type] };
76
76
  }
77
- case "text":
77
+ case "text": {
78
78
  return { expr: () => `Body.Text(body, ${media})`, type: "string", types: [] };
79
- case "binary":
79
+ }
80
+ case "binary": {
80
81
  return { expr: () => `Body.Binary(body, ${media})`, type: "BinaryBody", types: [] };
82
+ }
81
83
  case "multipart": {
82
84
  const { name, parts } = multipartBody(op, body.parts, env);
83
85
  const expr = (spell) => guarded(op, `Body.Multipart([${parts.map((part) => partExpr(part, spell)).join(", ")}])`);
@@ -26,7 +26,7 @@ export type ClientEnv = MethodEnv & {
26
26
  * them.
27
27
  */
28
28
  export declare function clientDecls(ir: IR, env: ClientEnv): {
29
- plans: CSharpCallPlan[];
30
- text: (spell: Spelling) => string;
31
- types: string[];
29
+ readonly plans: CSharpCallPlan[];
30
+ readonly text: (spell: Spelling) => string;
31
+ readonly types: string[];
32
32
  };
@@ -4,7 +4,7 @@ import { csIdentifier, csTypeName, NameScope } from "../shared/lang.js";
4
4
  import { mirrorNotice } from "../shared/mirror.js";
5
5
  import { docLines } from "./sdk-doc.js";
6
6
  import { csMethod } from "./sdk-method.js";
7
- /* every class's own members, and the names a method body spells in an expression (a property would shadow them) */
7
+ // every class's own members, and the names a method body spells in an expression (a property would shadow them)
8
8
  const CLASS_MEMBERS = [
9
9
  "Arg",
10
10
  "Body",
@@ -20,7 +20,7 @@ const CLASS_MEMBERS = [
20
20
  "Transport",
21
21
  "TransportOptions",
22
22
  ];
23
- /* the client's mirror property, `client.Safe` (shared/mirror.ts's name as C# spells it) */
23
+ // the client's mirror property, `client.Safe` (shared/mirror.ts's name as C# spells it)
24
24
  const SAFE = "Safe";
25
25
  /** A namespace's class name before it is claimed: its path PascalCase, then `Resource`. */
26
26
  const baseName = (path) => `${path.map(csTypeName).join("")}Resource`;
@@ -1,16 +1,14 @@
1
1
  import { type Shipped } from "../shared/metadata.ts";
2
- /** The one target framework: the pinned SDK's major (R1). */
3
- export declare const TARGET_FRAMEWORK = "net10.0";
4
2
  /** What nuget.org shows about the package, each part the caller gave, validated. */
5
3
  export type CSharpMetadata = {
6
- readonly description?: string;
7
- readonly authors?: string;
8
- readonly license?: string;
9
- readonly homepage?: string;
10
- readonly repository?: string;
11
- readonly copyright?: string;
4
+ readonly description?: string | undefined;
5
+ readonly authors?: string | undefined;
6
+ readonly license?: string | undefined;
7
+ readonly homepage?: string | undefined;
8
+ readonly repository?: string | undefined;
9
+ readonly copyright?: string | undefined;
12
10
  /** comma separated, as the CLI gives it */
13
- readonly tags?: string;
11
+ readonly tags?: string | undefined;
14
12
  };
15
13
  /** The package's identity, each part validated, its metadata, and the files it ships beside the code. */
16
14
  export type CSharpPackage = {