@workerstack/clients 1.0.0-rc.28 → 1.0.0-rc.30

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 (368) hide show
  1. package/README.md +403 -21
  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 +87 -66
  6. package/bin/installgen.js +19 -10
  7. package/dist/cli.d.ts +4 -4
  8. package/dist/cli.js +18 -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 +39 -13
  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 +18 -8
  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 +8 -4
  26. package/dist/emit/csharp/errors.js +4 -4
  27. package/dist/emit/csharp/json.js +8 -8
  28. package/dist/emit/csharp/realtime.d.ts +1 -8
  29. package/dist/emit/csharp/realtime.js +26 -26
  30. package/dist/emit/csharp/sdk-answer.d.ts +10 -2
  31. package/dist/emit/csharp/sdk-answer.js +4 -4
  32. package/dist/emit/csharp/sdk-body.js +8 -6
  33. package/dist/emit/csharp/sdk-client.d.ts +3 -3
  34. package/dist/emit/csharp/sdk-client.js +2 -2
  35. package/dist/emit/csharp/sdk-csproj.d.ts +7 -9
  36. package/dist/emit/csharp/sdk-csproj.js +10 -10
  37. package/dist/emit/csharp/sdk-doc.js +1 -1
  38. package/dist/emit/csharp/sdk-method.d.ts +0 -1
  39. package/dist/emit/csharp/sdk-method.js +19 -8
  40. package/dist/emit/csharp/sdk-plan.js +0 -1
  41. package/dist/emit/csharp/sdk.js +3 -3
  42. package/dist/emit/csharp/sse.d.ts +0 -13
  43. package/dist/emit/csharp/sse.js +92 -11
  44. package/dist/emit/csharp/transport.js +9 -9
  45. package/dist/emit/csharp/types-enum.js +3 -1
  46. package/dist/emit/csharp/types-messages.d.ts +47 -0
  47. package/dist/emit/csharp/types-messages.js +172 -0
  48. package/dist/emit/csharp/types-names.js +13 -14
  49. package/dist/emit/csharp/types-record.js +3 -3
  50. package/dist/emit/csharp/types-union.d.ts +1 -1
  51. package/dist/emit/csharp/types.d.ts +0 -1
  52. package/dist/emit/csharp/types.js +3 -3
  53. package/dist/emit/csharp/ws.d.ts +0 -15
  54. package/dist/emit/csharp/ws.js +26 -5
  55. package/dist/emit/go/errors.js +1 -1
  56. package/dist/emit/go/http.js +2 -2
  57. package/dist/emit/go/module-path.js +2 -2
  58. package/dist/emit/go/sdk-answer.d.ts +24 -1
  59. package/dist/emit/go/sdk-answer.js +1 -1
  60. package/dist/emit/go/sdk-body.js +11 -7
  61. package/dist/emit/go/sdk-client.js +1 -1
  62. package/dist/emit/go/sdk-method.d.ts +3 -0
  63. package/dist/emit/go/sdk-method.js +18 -12
  64. package/dist/emit/go/sdk-mirror.js +2 -2
  65. package/dist/emit/go/sdk-opts.d.ts +0 -2
  66. package/dist/emit/go/sdk-opts.js +3 -3
  67. package/dist/emit/go/sdk.d.ts +1 -1
  68. package/dist/emit/go/sdk.js +9 -9
  69. package/dist/emit/go/sse.d.ts +2 -10
  70. package/dist/emit/go/sse.js +88 -13
  71. package/dist/emit/go/types-names.js +5 -0
  72. package/dist/emit/go/types-struct.d.ts +2 -1
  73. package/dist/emit/go/types-struct.js +1 -1
  74. package/dist/emit/go/types-union.d.ts +3 -2
  75. package/dist/emit/go/types-union.js +2 -0
  76. package/dist/emit/go/types.d.ts +6 -0
  77. package/dist/emit/go/types.js +20 -9
  78. package/dist/emit/go/ws.d.ts +4 -11
  79. package/dist/emit/go/ws.js +215 -59
  80. package/dist/emit/java/gradle.d.ts +7 -9
  81. package/dist/emit/java/gradle.js +8 -8
  82. package/dist/emit/java/json.d.ts +3 -0
  83. package/dist/emit/java/json.js +1 -1
  84. package/dist/emit/java/layout-ast.d.ts +4 -1
  85. package/dist/emit/java/layout-ast.js +1 -1
  86. package/dist/emit/java/layout-decl.js +5 -4
  87. package/dist/emit/java/layout-doc.js +13 -7
  88. package/dist/emit/java/layout-dot.js +1 -1
  89. package/dist/emit/java/layout-strings.js +4 -5
  90. package/dist/emit/java/layout-types.js +7 -5
  91. package/dist/emit/java/layout-visitor.js +4 -3
  92. package/dist/emit/java/layout.js +5 -4
  93. package/dist/emit/java/models-names.d.ts +2 -0
  94. package/dist/emit/java/models-names.js +6 -4
  95. package/dist/emit/java/models-record.d.ts +0 -1
  96. package/dist/emit/java/models-record.js +3 -3
  97. package/dist/emit/java/models-union.d.ts +13 -2
  98. package/dist/emit/java/models-union.js +12 -6
  99. package/dist/emit/java/models.d.ts +5 -1
  100. package/dist/emit/java/models.js +44 -20
  101. package/dist/emit/java/realtime.d.ts +34 -26
  102. package/dist/emit/java/realtime.js +45 -10
  103. package/dist/emit/java/sdk-client.d.ts +6 -6
  104. package/dist/emit/java/sdk-client.js +1 -1
  105. package/dist/emit/java/sdk-decl.js +2 -2
  106. package/dist/emit/java/sdk-errors.js +1 -1
  107. package/dist/emit/java/sdk-headers.js +2 -2
  108. package/dist/emit/java/sdk-mirror.js +7 -6
  109. package/dist/emit/java/sdk-models.d.ts +1 -1
  110. package/dist/emit/java/sdk-models.js +7 -7
  111. package/dist/emit/java/sdk-op.d.ts +1 -10
  112. package/dist/emit/java/sdk-op.js +9 -9
  113. package/dist/emit/java/sdk-params.d.ts +5 -5
  114. package/dist/emit/java/sdk-params.js +3 -2
  115. package/dist/emit/java/sdk-plan.js +0 -1
  116. package/dist/emit/java/sdk.d.ts +1 -1
  117. package/dist/emit/java/sdk.js +14 -13
  118. package/dist/emit/java/sse.d.ts +12 -13
  119. package/dist/emit/java/sse.js +105 -6
  120. package/dist/emit/java/ws.d.ts +48 -9
  121. package/dist/emit/java/ws.js +88 -4
  122. package/dist/emit/mcp/annotations.js +8 -4
  123. package/dist/emit/mcp/files.js +9 -9
  124. package/dist/emit/mcp/mounted.js +2 -2
  125. package/dist/emit/mcp/output-schema.d.ts +4 -2
  126. package/dist/emit/mcp/output-schema.js +58 -14
  127. package/dist/emit/mcp/registry.d.ts +0 -2
  128. package/dist/emit/mcp/registry.js +5 -4
  129. package/dist/emit/mcp/runtime.js +2 -2
  130. package/dist/emit/mcp/schema.js +22 -11
  131. package/dist/emit/mcp/server.d.ts +7 -7
  132. package/dist/emit/mcp/server.js +7 -6
  133. package/dist/emit/mcp/tools.js +7 -6
  134. package/dist/emit/python/errors.js +3 -3
  135. package/dist/emit/python/realtime.d.ts +9 -6
  136. package/dist/emit/python/realtime.js +22 -20
  137. package/dist/emit/python/sdk-answer.d.ts +8 -8
  138. package/dist/emit/python/sdk-answer.js +2 -2
  139. package/dist/emit/python/sdk-body.js +4 -5
  140. package/dist/emit/python/sdk-client.js +5 -5
  141. package/dist/emit/python/sdk-doc.js +2 -2
  142. package/dist/emit/python/sdk-method.d.ts +1 -1
  143. package/dist/emit/python/sdk-method.js +38 -11
  144. package/dist/emit/python/sdk-plan.js +0 -1
  145. package/dist/emit/python/sdk-pyproject.d.ts +0 -2
  146. package/dist/emit/python/sdk-pyproject.js +8 -8
  147. package/dist/emit/python/sdk.d.ts +1 -1
  148. package/dist/emit/python/sdk.js +28 -8
  149. package/dist/emit/python/sse.d.ts +0 -7
  150. package/dist/emit/python/sse.js +36 -6
  151. package/dist/emit/python/transport.js +4 -4
  152. package/dist/emit/python/types-dict.d.ts +2 -2
  153. package/dist/emit/python/types-dict.js +1 -1
  154. package/dist/emit/python/types-names.js +2 -2
  155. package/dist/emit/python/types-union.js +1 -1
  156. package/dist/emit/python/types.d.ts +7 -0
  157. package/dist/emit/python/types.js +23 -6
  158. package/dist/emit/python/ws.d.ts +21 -10
  159. package/dist/emit/python/ws.js +69 -3
  160. package/dist/emit/rust/errors.js +3 -3
  161. package/dist/emit/rust/http.js +4 -4
  162. package/dist/emit/rust/realtime.d.ts +7 -5
  163. package/dist/emit/rust/realtime.js +15 -18
  164. package/dist/emit/rust/sdk-body.js +8 -5
  165. package/dist/emit/rust/sdk-cargo.d.ts +16 -18
  166. package/dist/emit/rust/sdk-cargo.js +12 -12
  167. package/dist/emit/rust/sdk-client.d.ts +1 -1
  168. package/dist/emit/rust/sdk-client.js +3 -3
  169. package/dist/emit/rust/sdk-method.js +3 -3
  170. package/dist/emit/rust/sdk-opts.d.ts +2 -1
  171. package/dist/emit/rust/sdk-opts.js +2 -2
  172. package/dist/emit/rust/sdk-plan.js +0 -1
  173. package/dist/emit/rust/sdk.d.ts +1 -1
  174. package/dist/emit/rust/sdk.js +5 -5
  175. package/dist/emit/rust/sse.d.ts +11 -12
  176. package/dist/emit/rust/sse.js +54 -8
  177. package/dist/emit/rust/types-names.js +3 -3
  178. package/dist/emit/rust/types-struct.js +1 -1
  179. package/dist/emit/rust/types-union.d.ts +10 -2
  180. package/dist/emit/rust/types-union.js +4 -0
  181. package/dist/emit/rust/types.d.ts +9 -0
  182. package/dist/emit/rust/types.js +20 -12
  183. package/dist/emit/rust/ws.d.ts +22 -15
  184. package/dist/emit/rust/ws.js +60 -10
  185. package/dist/emit/shared/escape.js +17 -17
  186. package/dist/emit/shared/format.js +1 -1
  187. package/dist/emit/shared/gofmt.js +1 -1
  188. package/dist/emit/shared/lang.js +10 -10
  189. package/dist/emit/shared/literals.d.ts +5 -0
  190. package/dist/emit/shared/literals.js +8 -0
  191. package/dist/emit/shared/metadata.d.ts +0 -6
  192. package/dist/emit/shared/metadata.js +8 -7
  193. package/dist/emit/shared/ruff.js +1 -1
  194. package/dist/emit/shared/rustfmt.js +1 -1
  195. package/dist/emit/shared/type-emitter.js +37 -20
  196. package/dist/emit/shared/unknown-type.constants.d.ts +2 -0
  197. package/dist/emit/shared/unknown-type.constants.js +2 -0
  198. package/dist/emit/ts/http.d.ts +0 -2
  199. package/dist/emit/ts/http.js +4 -4
  200. package/dist/emit/ts/package.d.ts +14 -12
  201. package/dist/emit/ts/package.js +9 -8
  202. package/dist/emit/ts/route-tree.js +2 -2
  203. package/dist/emit/ts/sdk-types-preamble.d.ts +1 -1
  204. package/dist/emit/ts/sdk-types-preamble.js +6 -2
  205. package/dist/emit/ts/sdk-types.js +59 -20
  206. package/dist/emit/ts/sdk.js +6 -6
  207. package/dist/emit/ts/service-map.d.ts +10 -3
  208. package/dist/emit/ts/service-map.js +30 -2
  209. package/dist/emit/ts/tanstack-query.js +6 -6
  210. package/dist/emit/ts/type-gen.js +36 -21
  211. package/dist/emit/ts/webhooks.d.ts +0 -2
  212. package/dist/emit/ts/webhooks.js +3 -3
  213. package/dist/extract/chain.js +5 -4
  214. package/dist/extract/extract.js +5 -5
  215. package/dist/extract/serialize.d.ts +0 -2
  216. package/dist/extract/serialize.js +14 -15
  217. package/dist/extract/walk.js +15 -12
  218. package/dist/gen/args.js +9 -5
  219. package/dist/gen/formatters.js +5 -3
  220. package/dist/gen/shipped.js +2 -2
  221. package/dist/gen/targets.d.ts +2 -4
  222. package/dist/gen/targets.js +8 -4
  223. package/dist/gen/write.js +4 -2
  224. package/dist/index.js +2 -2
  225. package/dist/installers/cli.d.ts +4 -4
  226. package/dist/installers/cli.js +24 -24
  227. package/dist/installers/commands/build.d.ts +4 -4
  228. package/dist/installers/commands/build.js +2 -3
  229. package/dist/installers/commands/check.d.ts +2 -2
  230. package/dist/installers/commands/check.js +11 -10
  231. package/dist/installers/commands/init.d.ts +2 -2
  232. package/dist/installers/commands/init.js +1 -2
  233. package/dist/installers/config/define-config.d.ts +16 -16
  234. package/dist/installers/config/define-config.js +1 -1
  235. package/dist/installers/config/hooks/bun.d.ts +6 -6
  236. package/dist/installers/config/hooks/node.js +1 -1
  237. package/dist/installers/config/load.d.ts +6 -8
  238. package/dist/installers/config/load.js +7 -8
  239. package/dist/installers/config/resolve.d.ts +1 -2
  240. package/dist/installers/config/resolve.js +28 -33
  241. package/dist/installers/config/types.d.ts +6 -6
  242. package/dist/installers/config/types.js +0 -1
  243. package/dist/installers/render/quote.js +3 -5
  244. package/dist/installers/render/render.d.ts +6 -6
  245. package/dist/installers/render/render.js +26 -26
  246. package/dist/installers/ui.d.ts +4 -4
  247. package/dist/installers/ui.js +3 -3
  248. package/dist/ir/build.d.ts +3 -3
  249. package/dist/ir/build.js +12 -5
  250. package/dist/ir/load.js +9 -10
  251. package/dist/ir/model.d.ts +16 -1
  252. package/dist/ir/model.js +0 -1
  253. package/dist/ir/resolve-refs.js +2 -2
  254. package/dist/ir/resource-tree.js +2 -1
  255. package/dist/ir/route-tree-intern.js +1 -1
  256. package/dist/ir/schema.js +3 -3
  257. package/dist/ir/sdk-model.d.ts +25 -1
  258. package/dist/ir/sdk-model.js +38 -8
  259. package/dist/ir/slots.d.ts +1 -1
  260. package/dist/ir/slots.js +22 -11
  261. package/dist/ir/streams.d.ts +16 -0
  262. package/dist/ir/streams.js +40 -0
  263. package/dist/release/bootstrap.d.ts +3 -3
  264. package/dist/release/bootstrap.js +7 -7
  265. package/dist/release/bump-args.js +4 -4
  266. package/dist/release/bump-command.d.ts +1 -1
  267. package/dist/release/bump-command.js +9 -10
  268. package/dist/release/bump.d.ts +5 -4
  269. package/dist/release/bump.js +2 -2
  270. package/dist/release/cli.d.ts +4 -4
  271. package/dist/release/cli.js +4 -4
  272. package/dist/release/codegen.js +1 -1
  273. package/dist/release/digest.js +5 -7
  274. package/dist/release/git.js +5 -8
  275. package/dist/release/load.js +3 -3
  276. package/dist/release/manifest.js +9 -10
  277. package/dist/release/oasdiff.d.ts +10 -15
  278. package/dist/release/oasdiff.js +5 -6
  279. package/dist/release/registries.d.ts +0 -11
  280. package/dist/release/registries.js +17 -17
  281. package/dist/release/release-state.d.ts +16 -13
  282. package/dist/release/release-workflow.js +5 -7
  283. package/dist/release/repo-settings.d.ts +2 -1
  284. package/dist/release/spec-gate.d.ts +0 -2
  285. package/dist/release/spec-gate.js +6 -10
  286. package/dist/release/sync-command.d.ts +2 -2
  287. package/dist/release/sync-command.js +1 -1
  288. package/dist/release/sync-tree.js +9 -13
  289. package/dist/release/sync.d.ts +6 -6
  290. package/dist/release/sync.js +12 -13
  291. package/dist/release/types.d.ts +22 -22
  292. package/dist/release/types.js +0 -1
  293. package/dist/release/version-files.d.ts +3 -4
  294. package/dist/release/version-files.js +4 -5
  295. package/dist/runtime/.oxfmtrc.jsonc +8 -0
  296. package/dist/runtime/cli/socket.go +107 -13
  297. package/dist/runtime/cli/stream.go +18 -11
  298. package/dist/runtime/csharp/Adapters.cs +12 -11
  299. package/dist/runtime/csharp/Events.cs +22 -17
  300. package/dist/runtime/csharp/Realtime.cs +50 -23
  301. package/dist/runtime/csharp/RealtimeLoop.cs +1 -1
  302. package/dist/runtime/csharp/TransportSse.cs +3 -3
  303. package/dist/runtime/csharp/Ws.cs +1 -1
  304. package/dist/runtime/csharp/WsDial.cs +19 -1
  305. package/dist/runtime/csharp/WsTyped.cs +109 -0
  306. package/dist/runtime/go/realtime.go +125 -41
  307. package/dist/runtime/go/realtime_loop.go +21 -18
  308. package/dist/runtime/go/result.go +2 -1
  309. package/dist/runtime/go/sse.go +11 -0
  310. package/dist/runtime/go/stream.go +29 -13
  311. package/dist/runtime/go/transport.go +15 -21
  312. package/dist/runtime/go/transport_longpoll.go +3 -4
  313. package/dist/runtime/go/transport_sse.go +6 -6
  314. package/dist/runtime/go/ws.go +157 -61
  315. package/dist/runtime/java/EventStream.java +47 -29
  316. package/dist/runtime/java/Exchange.java +5 -5
  317. package/dist/runtime/java/Flight.java +3 -3
  318. package/dist/runtime/java/Realtime.java +45 -11
  319. package/dist/runtime/java/ResumableConnection.java +77 -32
  320. package/dist/runtime/java/Socket.java +8 -4
  321. package/dist/runtime/java/SseAdapter.java +1 -1
  322. package/dist/runtime/java/TypedWebSocket.java +81 -24
  323. package/dist/runtime/java/WsAdapter.java +4 -2
  324. package/dist/runtime/java/WsDial.java +12 -5
  325. package/dist/runtime/mcp/files.ts +1 -1
  326. package/dist/runtime/mcp/http.ts +6 -2
  327. package/dist/runtime/mcp/listen.ts +1 -1
  328. package/dist/runtime/mcp/mount.ts +2 -2
  329. package/dist/runtime/mcp/protocol.ts +1 -1
  330. package/dist/runtime/python/events.py +25 -11
  331. package/dist/runtime/python/operation.py +6 -1
  332. package/dist/runtime/python/realtime.py +47 -33
  333. package/dist/runtime/python/send_async.py +1 -0
  334. package/dist/runtime/python/transport_sse.py +2 -2
  335. package/dist/runtime/python/transport_ws.py +1 -1
  336. package/dist/runtime/python/ws.py +100 -39
  337. package/dist/runtime/rust/events.rs +64 -41
  338. package/dist/runtime/rust/realtime.rs +80 -34
  339. package/dist/runtime/rust/realtime_loop.rs +37 -12
  340. package/dist/runtime/rust/sse.rs +3 -2
  341. package/dist/runtime/rust/transport_sse.rs +1 -1
  342. package/dist/runtime/rust/transport_ws.rs +3 -2
  343. package/dist/runtime/rust/ws.rs +122 -50
  344. package/dist/runtime/ts/realtime-connection.ts +22 -0
  345. package/dist/runtime/ts/realtime-transports.ts +13 -4
  346. package/dist/runtime/ts/realtime.ts +27 -3
  347. package/dist/runtime/ts/sdk-realtime.ts +1 -1
  348. package/dist/runtime/ts/sdk-sse.ts +31 -14
  349. package/dist/runtime/ts/sdk-ws.ts +2 -1
  350. package/dist/runtime/ts/sdk.ts +9 -2
  351. package/dist/runtime/ts/sse.ts +8 -0
  352. package/dist/runtime/ts/ws.ts +88 -50
  353. package/dist/runtime/ts-tanstack-query/query.ts +0 -2
  354. package/package.json +12 -40
  355. package/dist/emit/cli/index.d.ts +0 -1
  356. package/dist/emit/cli/index.js +0 -1
  357. package/dist/emit/csharp/index.d.ts +0 -1
  358. package/dist/emit/csharp/index.js +0 -1
  359. package/dist/emit/go/index.d.ts +0 -1
  360. package/dist/emit/go/index.js +0 -1
  361. package/dist/emit/java/index.d.ts +0 -2
  362. package/dist/emit/java/index.js +0 -2
  363. package/dist/emit/mcp/index.d.ts +0 -3
  364. package/dist/emit/mcp/index.js +0 -3
  365. package/dist/emit/python/index.d.ts +0 -1
  366. package/dist/emit/python/index.js +0 -1
  367. package/dist/emit/rust/index.d.ts +0 -1
  368. package/dist/emit/rust/index.js +0 -1
@@ -1,34 +1,28 @@
1
1
  /**
2
- * A realtime operation's method (bit 16 phase d2b, R1/R8; C#'s `realtime.ts`, Fd6/Fd7): `ResumableConnection<T>`, `T`
3
- * the declared event schema's type, else `JsonNode`, connected through `Realtime.open` over WebSocket, else SSE, else
4
- * long-poll before the method returns. Its five fields are `TransportOptions.of`'s: the resume cursor (`lastEventId`,
5
- * `reconnectToken`), the offered `protocols` and the reconnect policy (`maxReconnectAttempts`, `reconnectDelay`). The
6
- * runtime puts the cursor on each dial, so none of them is a Call arg; a declared `last_event_id` or `reconnect_token`
7
- * query, or a Last-Event-ID header, folds in, and a param spelled like a field claims `…2`. A realtime method is the
8
- * same text in either mode: it answers no Result.
2
+ * A realtime operation's method (bit 16 phase d2b, R1/R8, D9; C#'s `realtime.ts`, Fd6/Fd7):
3
+ * `ResumableConnection<TIn, TOut>`, `TIn` what the server sends (`send`), else the declared event schema's type, else
4
+ * `JsonNode`, and `TOut` what it receives (`receive`), else `JsonNode`; an inline side is hoisted as `<Op>Send` or
5
+ * `<Op>Receive`. A keyed read side (the sealed interface models-union.ts declares) with a member to handle answers
6
+ * `<Read>Connection<TOut>`, whose `on<Value>` per member matches inside `onMessage`, none for a `message` member; its
7
+ * name is claimed after the union's wrappers, as ws.ts claims a socket's. An op that declares its messages connects
8
+ * through `Realtime.typed`, which refuses a message that is no JSON; any other through `Realtime.open`, which reads it
9
+ * as a JSON string; either before the method returns, over WebSocket, else SSE, else long-poll. Its five fields are
10
+ * `TransportOptions.of`'s: the resume cursor (`lastEventId`, `reconnectToken`), the offered `protocols` and the
11
+ * reconnect policy (`maxReconnectAttempts`, `reconnectDelay`). The runtime puts the cursor on each dial, so none of
12
+ * them is a Call arg; a declared `last_event_id` or `reconnect_token` query, or a Last-Event-ID header, folds in, and a
13
+ * param spelled like a field claims `…2`. A realtime method is the same text in either mode: it answers no Result.
9
14
  */
10
15
  import type { SdkOp } from "../../ir/sdk-model.ts";
16
+ import { type Expr } from "./layout.ts";
11
17
  import { type JavaTypeContext } from "./models.ts";
12
18
  /** The reconnect policy's Params fields. */
13
19
  export declare const MAX_RECONNECT_ATTEMPTS = "maxReconnectAttempts";
14
20
  export declare const RECONNECT_DELAY = "reconnectDelay";
15
21
  /** A realtime op's own fields in `TransportOptions.of`'s order, each with its Java type. */
16
- export declare const REALTIME_FIELDS: readonly [{
17
- readonly field: "lastEventId";
18
- readonly type: "String";
19
- }, {
20
- readonly field: "reconnectToken";
21
- readonly type: "String";
22
- }, {
23
- readonly field: "protocols";
24
- readonly type: "List<String>";
25
- }, {
26
- readonly field: "maxReconnectAttempts";
27
- readonly type: "java.lang.Integer";
28
- }, {
29
- readonly field: "reconnectDelay";
30
- readonly type: "Duration";
31
- }];
22
+ export declare const REALTIME_FIELDS: readonly {
23
+ readonly field: string;
24
+ readonly type: string;
25
+ }[];
32
26
  /** Whether a declared param is on a realtime resume channel the cursor fields carry (C#'s `carries`). */
33
27
  export declare const carriesRealtime: (name: string, where: "query" | "header") => boolean;
34
28
  /**
@@ -36,9 +30,23 @@ export declare const carriesRealtime: (name: string, where: "query" | "header")
36
30
  * adapters; only an SDK with a realtime operation ships them (with the WebSocket files, which its WebSocket adapter dials
37
31
  * through).
38
32
  */
39
- export declare const REALTIME_FILES: string[];
40
- /** The type a realtime op's messages decode to: the declared event schema's, else `JsonNode`. */
41
- export declare const messageTypeOf: (op: SdkOp, ctx: JavaTypeContext) => string;
33
+ export declare const REALTIME_FILES: readonly string[];
34
+ /**
35
+ * What a realtime method answers: its type, the type its messages decode to, whether they must be JSON (the op
36
+ * declares its messages), and the wrap of the opened connection.
37
+ */
38
+ export type RealtimeConnection = {
39
+ readonly type: string;
40
+ readonly read: string;
41
+ readonly strict: boolean;
42
+ readonly wrap: (opened: Expr) => Expr;
43
+ };
44
+ /**
45
+ * What `op`'s realtime method answers: `ResumableConnection<TIn, TOut>`, `TIn` the declared read side's type, else
46
+ * the event schema's, else `JsonNode`, `TOut` the declared write side's, else `JsonNode`; a keyed read side with a
47
+ * member to handle answers its `<Read>Connection<TOut>`, wrapping the opened one.
48
+ */
49
+ export declare function connectionOf(op: SdkOp, ctx: JavaTypeContext): RealtimeConnection;
42
50
  /** What a realtime method's lines need: its name and constant, its Params, and its Call's lines. */
43
51
  export type RealtimeSite = {
44
52
  readonly name: string;
@@ -1,8 +1,9 @@
1
- import { javaTypeOf } from "./models.js";
2
- import { call as callOf, local, methodHeader, param, newOf, returnStmt, statement } from "./layout.js";
1
+ import { call as callOf, local, methodHeader, newOf, param, returnStmt, statement, } from "./layout.js";
2
+ import { JSON_NODE } from "./models-names.js";
3
+ import { declaredTypeOf, javaTypeOf, keyedArms } from "./models.js";
3
4
  import { docOf } from "./sdk-decl.js";
4
5
  import { CURSOR, isLastEventIdHeader } from "./sse.js";
5
- import { isReconnectTokenQuery, PROTOCOLS, TOKEN } from "./ws.js";
6
+ import { handledArms, isReconnectTokenQuery, keyedReader, PROTOCOLS, TOKEN } from "./ws.js";
6
7
  /** The reconnect policy's Params fields. */
7
8
  export const MAX_RECONNECT_ATTEMPTS = "maxReconnectAttempts";
8
9
  export const RECONNECT_DELAY = "reconnectDelay";
@@ -35,22 +36,56 @@ export const REALTIME_FILES = [
35
36
  "TransportOptions",
36
37
  "WsAdapter",
37
38
  ];
38
- /** The type a realtime op's messages decode to: the declared event schema's, else `JsonNode`. */
39
- export const messageTypeOf = (op, ctx) => op.events === undefined ? "JsonNode" : javaTypeOf(op.events, { ...ctx, fieldName: "Event", parentName: op.id });
39
+ /** The connection's reader: its own handler is onMessage. */
40
+ const CONNECTION = {
41
+ base: "ResumableConnection",
42
+ handlers: ["onMessage"],
43
+ noun: "connection",
44
+ suffix: "Connection",
45
+ };
46
+ /** The opened connection as it is: one whose read side has no member to handle. */
47
+ const AS_OPENED = (opened) => opened;
48
+ /**
49
+ * What `op`'s realtime method answers: `ResumableConnection<TIn, TOut>`, `TIn` the declared read side's type, else
50
+ * the event schema's, else `JsonNode`, `TOut` the declared write side's, else `JsonNode`; a keyed read side with a
51
+ * member to handle answers its `<Read>Connection<TOut>`, wrapping the opened one.
52
+ */
53
+ export function connectionOf(op, ctx) {
54
+ const messages = op.ir.messages;
55
+ const at = (fieldName) => ({ ...ctx, fieldName, parentName: op.id, path: "" });
56
+ const strict = messages !== undefined;
57
+ const write = messages?.receive === undefined ? JSON_NODE : declaredTypeOf(messages.receive, at("Receive"));
58
+ const plain = (read) => ({
59
+ read,
60
+ strict,
61
+ type: `ResumableConnection<${read}, ${write}>`,
62
+ wrap: AS_OPENED,
63
+ });
64
+ if (messages?.send === undefined) {
65
+ const events = { ...ctx, fieldName: "Event", parentName: op.id };
66
+ return plain(op.events === undefined ? JSON_NODE : javaTypeOf(op.events, events));
67
+ }
68
+ const read = declaredTypeOf(messages.send, at("Send"));
69
+ const arms = keyedArms(read, messages.send, ctx);
70
+ if (handledArms(CONNECTION, arms).length === 0)
71
+ return plain(read);
72
+ const sub = keyedReader(CONNECTION, read, arms, ctx);
73
+ return { read, strict, type: `${sub}<${write}>`, wrap: (opened) => newOf(`${sub}<${write}>`, [opened]) };
74
+ }
40
75
  /** A realtime method's lines: `op(params)`, delegating to `op(params, options)`, which connects. */
41
76
  export function realtimeMethodLines(op, site, ctx) {
42
77
  const { call, constant, name, params } = site;
43
- const type = messageTypeOf(op, ctx);
78
+ const connection = connectionOf(op, ctx);
44
79
  const doc = docOf(`${op.id}: the connection over WebSocket, else SSE, else long-poll. It reconnects after a drop and resumes after the last message it delivered; close() ends it.`);
45
- const signature = (args) => methodHeader(2, { modifiers: ["public"], name, params: args, returns: `ResumableConnection<${type}>` });
80
+ const signature = (args) => methodHeader(2, { modifiers: ["public"], name, params: args, returns: connection.type });
46
81
  const transport = callOf("TransportOptions", "of", REALTIME_FIELDS.map((f) => callOf("params", f.field)));
47
- const open = callOf("Realtime", "open", [
82
+ const open = callOf("Realtime", connection.strict ? "typed" : "open", [
48
83
  "exchange",
49
84
  constant,
50
85
  "call",
51
86
  "options",
52
87
  "transport",
53
- newOf(`TypeReference<${type}>`, [], true),
88
+ newOf(`TypeReference<${connection.read}>`, [], true),
54
89
  ]);
55
90
  return [
56
91
  doc,
@@ -62,7 +97,7 @@ export function realtimeMethodLines(op, site, ctx) {
62
97
  ...signature([param(params, "params"), param("RequestOptions", "options")]),
63
98
  ...call,
64
99
  ...statement(4, local({ init: transport, name: "transport", type: "TransportOptions" })),
65
- ...statement(4, returnStmt(open)),
100
+ ...statement(4, returnStmt(connection.wrap(open))),
66
101
  " }",
67
102
  "",
68
103
  ];
@@ -44,13 +44,13 @@ export declare function nodeOf(ns: IRNamespace, path: readonly string[]): Node;
44
44
  * mirror's `safe` is held, so a member spelled `safe` is `safe_` instead, and noticed (shared/mirror.ts's one rule).
45
45
  */
46
46
  export declare function membersOf(node: Node, env: SurfaceEnv): {
47
- children: {
48
- child: Node;
49
- name: string;
47
+ readonly children: {
48
+ readonly child: Node;
49
+ readonly name: string;
50
50
  }[];
51
- ops: {
52
- name: string;
53
- op: JavaOp;
51
+ readonly ops: {
52
+ readonly name: string;
53
+ readonly op: JavaOp;
54
54
  }[];
55
55
  };
56
56
  /** A list of blocks, each set apart by one blank line; a block's own trailing blank lines are dropped. */
@@ -60,7 +60,7 @@ export const blocks = (parts) => parts
60
60
  .flatMap((part, i) => (i === 0 ? part : ["", ...part]));
61
61
  /** The lines without their leading and trailing blank lines. */
62
62
  function trimmed(lines) {
63
- const text = lines.join("\n").replace(/^(?:\n)+|(?:\n)+$/g, "");
63
+ const text = lines.join("\n").replaceAll(/^(?:\n)+|(?:\n)+$/g, "");
64
64
  return text === "" ? [] : text.split("\n");
65
65
  }
66
66
  /** The operations' constants and methods of a class, each block set apart. */
@@ -15,8 +15,8 @@ const control = (cp) => cp < 0x20 || cp === 0x7f || cp === 0xfeff || cp === 0x20
15
15
  const docText = (text) => [...text.toWellFormed()]
16
16
  .map((ch) => (control(ch.codePointAt(0)) ? " " : ch))
17
17
  .join("")
18
- .replace(/\\/g, "&#92;")
19
- .replace(/\*\//g, "*&#47;");
18
+ .replaceAll("\\", "&#92;")
19
+ .replaceAll("*/", "*&#47;");
20
20
  /**
21
21
  * A `/** … *\/` doc comment at `indent`, its text made safe (docText): one line when it fits in 100 columns, else
22
22
  * google-java-format's filled lines, each word on the first line it fits, after ` * `.
@@ -60,7 +60,7 @@ function classLines({ name, doc, base, cause, param }) {
60
60
  `public final class ${name} extends ${base} {`,
61
61
  " private static final long serialVersionUID = 1L;",
62
62
  "",
63
- ` ${name}(${param === "failure" ? "Failure failure" : "String message" + (cause ? ", Throwable cause" : "")}) {`,
63
+ ` ${name}(${param === "failure" ? "Failure failure" : `String message${cause ? ", Throwable cause" : ""}`}) {`,
64
64
  ` super(${args});`,
65
65
  " }",
66
66
  "}",
@@ -23,7 +23,7 @@ function declaredHeaders(op) {
23
23
  .filter((status) => /^2(?:\d\d|XX)$/i.test(status))
24
24
  .sort(compareCodeUnits)
25
25
  .flatMap((status) => op.ir.responses[status].headers ?? []);
26
- /* reversed, so the first spelling of a name is the one its key ends on */
26
+ // reversed, so the first spelling of a name is the one its key ends on
27
27
  const first = new Map(all.toReversed().map((header) => [header.name.toLowerCase(), header]));
28
28
  return [...first.values()].sort((a, b) => compareCodeUnits(a.name, b.name));
29
29
  }
@@ -59,7 +59,7 @@ export function javaResponseHeaders(op, env) {
59
59
  ...fields.flatMap(({ accessor, header, parse, word }) => statement(4, exprStmt(assign(accessor, call("Answer", "header", [
60
60
  "headers",
61
61
  javaString(header.name),
62
- String(header.required === true),
62
+ String(header.required),
63
63
  javaString(word),
64
64
  parse,
65
65
  ]))))),
@@ -1,19 +1,20 @@
1
- import { messageTypeOf } from "./realtime.js";
2
1
  import { accessor, assign, call, classHeader, exprStmt, finalField, lambda, methodHeader, newOf, param, returnStmt, statement, } from "./layout.js";
2
+ import { connectionOf } from "./realtime.js";
3
+ import { blocks, clientLines, membersOf, nodeOf, recordSource, resourceName, } from "./sdk-client.js";
3
4
  import { docOf, docParagraphs } from "./sdk-decl.js";
4
5
  import { putFile } from "./sdk-models.js";
5
6
  import { answerOf, paragraphsOf } from "./sdk-op.js";
6
7
  import { paramsName } from "./sdk-params.js";
7
- import { blocks, clientLines, membersOf, nodeOf, recordSource, resourceName, } from "./sdk-client.js";
8
- import { eventTypeOf } from "./sse.js";
8
+ import { sseEventOf } from "./sse.js";
9
+ import { wsSocketOf } from "./ws.js";
9
10
  /** The type the normal method answers: a stream's, a connection's, or the answer's (`void` for none). */
10
11
  function returnsOf(op, env) {
11
12
  if (op.stream === "sse")
12
- return `EventStream<${eventTypeOf(op, env.ctx)}>`;
13
+ return `EventStream<${sseEventOf(op, env.ctx).type}>`;
13
14
  if (op.stream === "ws")
14
- return "TypedWebSocket";
15
+ return wsSocketOf(op, env.ctx).type;
15
16
  if (op.stream === "realtime")
16
- return `ResumableConnection<${messageTypeOf(op, env.ctx)}>`;
17
+ return connectionOf(op, env.ctx).type;
17
18
  return answerOf(op, env).type;
18
19
  }
19
20
  /**
@@ -1,5 +1,5 @@
1
- import { type JavaTypeContext } from "./models.ts";
2
1
  import type { IR } from "../../ir/model.ts";
2
+ import { type JavaTypeContext } from "./models.ts";
3
3
  /** The import lines `decl` needs, sorted as google-java-format sorts them. */
4
4
  export declare function importsOf(decl: string): string[];
5
5
  /** One model file's text: the marker, the package, its imports, its declaration. */
@@ -4,11 +4,14 @@
4
4
  * needs its own. A file imports exactly the types its text spells, in google-java-format's order: one block, sorted.
5
5
  */
6
6
  import { compareCodeUnits } from "../shared/lang.js";
7
- import { declares, javaTopLevel } from "./models.js";
8
7
  import { codeOf } from "./models-names.js";
9
- /* every type a model declaration may spell that java.lang does not hold, by its simple name */
8
+ import { declares, javaTopLevel } from "./models.js";
9
+ // every type a model declaration may spell that java.lang does not hold, by its simple name
10
10
  const IMPORTS = {
11
+ Consumer: "java.util.function.Consumer",
11
12
  DeserializationContext: "tools.jackson.databind.DeserializationContext",
13
+ Duration: "java.time.Duration",
14
+ InputStream: "java.io.InputStream",
12
15
  JsonAnyGetter: "com.fasterxml.jackson.annotation.JsonAnyGetter",
13
16
  JsonAnySetter: "com.fasterxml.jackson.annotation.JsonAnySetter",
14
17
  JsonCreator: "com.fasterxml.jackson.annotation.JsonCreator",
@@ -19,12 +22,9 @@ const IMPORTS = {
19
22
  JsonProperty: "com.fasterxml.jackson.annotation.JsonProperty",
20
23
  JsonValue: "com.fasterxml.jackson.annotation.JsonValue",
21
24
  LinkedHashMap: "java.util.LinkedHashMap",
25
+ List: "java.util.List",
22
26
  Map: "java.util.Map",
23
27
  StdDeserializer: "tools.jackson.databind.deser.std.StdDeserializer",
24
- Consumer: "java.util.function.Consumer",
25
- Duration: "java.time.Duration",
26
- InputStream: "java.io.InputStream",
27
- List: "java.util.List",
28
28
  Supplier: "java.util.function.Supplier",
29
29
  TypeReference: "tools.jackson.core.type.TypeReference",
30
30
  };
@@ -51,7 +51,7 @@ export function componentDecls(ir, ctx) {
51
51
  const name = ctx.names.ref(key);
52
52
  decls.set(name, javaTopLevel(name, schema, ctx));
53
53
  }
54
- /* a hoist claims its name from the same scope as the components, so it never repeats one */
54
+ // a hoist claims its name from the same scope as the components, so it never repeats one
55
55
  for (const [name, decl] of ctx.decls)
56
56
  decls.set(name, decl);
57
57
  return decls;
@@ -8,11 +8,10 @@
8
8
  */
9
9
  import type { IRSchema } from "../../ir/model.ts";
10
10
  import type { SdkOp } from "../../ir/sdk-model.ts";
11
- import { type JavaTypeContext } from "./models.ts";
12
11
  import { type Expr } from "./layout.ts";
12
+ import { type JavaTypeContext } from "./models.ts";
13
13
  import { type JavaHeaders } from "./sdk-headers.ts";
14
14
  import type { JavaCallPlan } from "./sdk-plan.ts";
15
- import { type Field } from "./sdk-params.ts";
16
15
  /** What an operation's text needs: the type context its types hoist into, and the array test. */
17
16
  export type OpEnv = {
18
17
  readonly ctx: JavaTypeContext;
@@ -40,18 +39,10 @@ export type JavaOp = {
40
39
  };
41
40
  /** A method's javadoc paragraphs: the operation's id, then its summary and description, as the other SDKs carry them. */
42
41
  export declare const paragraphsOf: (op: SdkOp) => string[];
43
- /** The constant's name for a method: its words upper-cased, `_OPERATION` after them. */
44
- export declare const constantOf: (method: string) => string;
45
42
  /** The answer's Java type and its reader on `answer`, for each response kind. */
46
43
  export declare function answerOf(op: SdkOp, env: OpEnv): {
47
44
  readonly reader: Expr;
48
45
  readonly type: string;
49
46
  };
50
- /** One method's name, its fields, and the holder of its response headers when it declares any. */
51
- export type MethodSite = {
52
- readonly name: string;
53
- readonly fields: readonly Field[];
54
- readonly headers: JavaHeaders | null;
55
- };
56
47
  /** One operation's text and plan, with its accessors left to the resource tree. */
57
48
  export declare function javaOp(op: SdkOp, name: string, env: OpEnv): JavaOp;
@@ -1,19 +1,19 @@
1
1
  import { javaString } from "../shared/escape.js";
2
2
  import { snakeWords } from "../shared/lang.js";
3
- import { javaTypeOf } from "./models.js";
4
3
  import { array, call, exprStmt, field, lit, local, methodHeader, param, newOf, returnStmt, statement, } from "./layout.js";
4
+ import { javaTypeOf } from "./models.js";
5
+ import { MAX_RECONNECT_ATTEMPTS, RECONNECT_DELAY, realtimeMethodLines } from "./realtime.js";
5
6
  import { docParagraphs } from "./sdk-decl.js";
6
7
  import { javaResponseHeaders } from "./sdk-headers.js";
7
- import { MAX_RECONNECT_ATTEMPTS, RECONNECT_DELAY, realtimeMethodLines } from "./realtime.js";
8
+ import { fieldsOf, multipartRecord, paramsName } from "./sdk-params.js";
9
+ import { multipartHelper, multipartRecordLines, paramsRecord } from "./sdk-record.js";
8
10
  import { CURSOR, sseMethodLines } from "./sse.js";
9
11
  import { PROTOCOLS, TOKEN, wsMethodLines } from "./ws.js";
10
- import { multipartHelper, multipartRecordLines, paramsRecord } from "./sdk-record.js";
11
- import { fieldsOf, multipartRecord, paramsName } from "./sdk-params.js";
12
12
  const UNKNOWN = { kind: "unknown" };
13
13
  /** A method's javadoc paragraphs: the operation's id, then its summary and description, as the other SDKs carry them. */
14
14
  export const paragraphsOf = (op) => [op.id, op.summary, op.description].filter((text) => text !== "");
15
15
  /** The constant's name for a method: its words upper-cased, `_OPERATION` after them. */
16
- export const constantOf = (method) => `${snakeWords(method).toUpperCase()}_OPERATION`;
16
+ const constantOf = (method) => `${snakeWords(method).toUpperCase()}_OPERATION`;
17
17
  /** The answer's Java type and its reader on `answer`, for each response kind. */
18
18
  export function answerOf(op, env) {
19
19
  const kind = op.success.kind;
@@ -80,7 +80,7 @@ function streamMethodLines(op, site, env) {
80
80
  if (op.stream === "sse")
81
81
  return sseMethodLines(op, { call: lines, constant, headers, name, params }, env.ctx);
82
82
  if (op.stream === "ws")
83
- return wsMethodLines(op, { call: lines, constant, name, params });
83
+ return wsMethodLines(op, { call: lines, constant, name, params }, env.ctx);
84
84
  return realtimeMethodLines(op, { call: lines, constant, name, params }, env.ctx);
85
85
  }
86
86
  /**
@@ -97,7 +97,7 @@ function methodLines(op, site, env) {
97
97
  const answer = answerOf(op, env);
98
98
  const returns = answer.type;
99
99
  const params = paramsName(op, env.ctx);
100
- /* `return value;`, or the statement alone for no answer */
100
+ // `return value;`, or the statement alone for no answer
101
101
  const ret = (value) => statement(4, returns === "void" ? exprStmt(value) : returnStmt(value));
102
102
  const delegate = (args) => ret(call(null, name, args));
103
103
  const fill = headers === null
@@ -205,10 +205,10 @@ export function javaOp(op, name, env) {
205
205
  body: multipart === null
206
206
  ? null
207
207
  : { lines: multipartRecordLines(multipart.name, op.id, multipart.components), name: multipart.name },
208
- headers,
209
- helper: multipartHelper(op, env),
210
208
  constant,
211
209
  constantLines: constantLines(op, constant),
210
+ headers,
211
+ helper: multipartHelper(op, env),
212
212
  lines: methodLines(op, { fields, headers, name }, env),
213
213
  params: paramsRecord(paramsName(op, env.ctx), op.id, fields),
214
214
  plan,
@@ -29,10 +29,10 @@ export declare const opTypeName: (op: SdkOp, kind: "Body" | "Headers" | "Params"
29
29
  export declare const paramsName: (op: SdkOp, ctx: JavaTypeContext) => string;
30
30
  /** Each multipart part as a record component: a file's `FilePart` or a list of them, a text part's type. */
31
31
  export declare function multipartRecord(op: SdkOp, parts: readonly IRMultipartPart[], ctx: JavaTypeContext, isArray: (s: IRSchema) => boolean): {
32
- components: {
33
- field: string;
34
- name: string;
35
- type: string;
32
+ readonly components: {
33
+ readonly field: string;
34
+ readonly name: string;
35
+ readonly type: string;
36
36
  }[];
37
- name: string;
37
+ readonly name: string;
38
38
  };
@@ -1,7 +1,7 @@
1
1
  import { compareCodeUnits, javaIdentifier, javaTypeName, NameScope } from "../shared/lang.js";
2
2
  import { javaTypeOf } from "./models.js";
3
- import { CURSOR, isLastEventIdHeader, LAST_EVENT_ID } from "./sse.js";
4
3
  import { carriesRealtime, REALTIME_FIELDS } from "./realtime.js";
4
+ import { CURSOR, isLastEventIdHeader, LAST_EVENT_ID } from "./sse.js";
5
5
  import { isReconnectTokenQuery, PROTOCOLS, RECONNECT_TOKEN, TOKEN } from "./ws.js";
6
6
  /** The record's own members, which a component may not take (`builder()` is static). */
7
7
  const RECORD_RESERVED = ["builder", "equals", "hashCode", "toString"];
@@ -88,7 +88,7 @@ export function fieldsOf(op, ctx) {
88
88
  function streamFields(op) {
89
89
  if (op.stream === "sse")
90
90
  return [{ field: CURSOR, name: LAST_EVENT_ID, required: false, type: "String", where: "cursor" }];
91
- if (op.stream === "realtime")
91
+ if (op.stream === "realtime") {
92
92
  return REALTIME_FIELDS.map((f) => ({
93
93
  field: f.field,
94
94
  name: f.field,
@@ -96,6 +96,7 @@ function streamFields(op) {
96
96
  type: f.type,
97
97
  where: "realtime",
98
98
  }));
99
+ }
99
100
  if (op.stream !== "ws")
100
101
  return [];
101
102
  return [
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +1,6 @@
1
+ import { type PackageIdentity } from "../shared/metadata.ts";
1
2
  import { type JavaPomMetadata } from "./gradle.ts";
2
3
  import { type JavaCallPlan } from "./sdk-plan.ts";
3
- import { type PackageIdentity } from "../shared/metadata.ts";
4
4
  /** The package's options, each defaulted and validated. */
5
5
  export type JavaSdkOptions = {
6
6
  /** the Maven group id; `com.example` by default, the reserved example domain as the Go SDK's `example.com/sdk`: Maven
@@ -5,23 +5,24 @@
5
5
  * no `HttpClient.close`). The emitted Java is google-java-format's canonical form by construction (format.test.ts).
6
6
  */
7
7
  import { readFileSync } from "node:fs";
8
+ import { toIR } from "../../ir/build.js";
9
+ import { sdkModel } from "../../ir/sdk-model.js";
8
10
  import { compareCodeUnits } from "../shared/lang.js";
11
+ import { packageOn } from "../shared/metadata.js";
12
+ import { renameNotice } from "../shared/mirror.js";
9
13
  import { buildGradle, pomOf, settingsGradle, validateArtifactId, validateClientName, validateGroupId, validatePackageName, validateVersion, } from "./gradle.js";
10
- import { componentDecls, modelFiles, putFile } from "./sdk-models.js";
11
- import { errorClassFiles, errorKeyFiles } from "./sdk-errors.js";
14
+ import { javaTypeContext } from "./models.js";
15
+ import { REALTIME_FILES } from "./realtime.js";
12
16
  import { surfaceOf } from "./sdk-client.js";
17
+ import { errorClassFiles, errorKeyFiles } from "./sdk-errors.js";
13
18
  import { mirrorOf } from "./sdk-mirror.js";
14
- import { renameNotice } from "../shared/mirror.js";
15
- import { packageOn } from "../shared/metadata.js";
16
- import { javaTypeContext } from "./models.js";
19
+ import { componentDecls, modelFiles, putFile } from "./sdk-models.js";
20
+ import {} from "./sdk-plan.js";
17
21
  import { SSE_FILES } from "./sse.js";
18
- import { REALTIME_FILES } from "./realtime.js";
19
22
  import { WS_FILES } from "./ws.js";
20
- import { sdkModel } from "../../ir/sdk-model.js";
21
- import { toIR } from "../../ir/build.js";
22
23
  /** The marker on line 1 of every emitted file. */
23
24
  const MARKER = "// @generated by clients. DO NOT EDIT.";
24
- /* the package line of every vendored runtime file */
25
+ // the package line of every vendored runtime file
25
26
  const RUNTIME_PACKAGE = /^package http\.runtime;$/m;
26
27
  /** The validated package for `options`. */
27
28
  function packageOf(options) {
@@ -114,8 +115,8 @@ const OPERATION_FILES = [
114
115
  /** The vendored runtime's files by class name, read from disk on every call, in `packageName`; every file by default. */
115
116
  export function runtimeFiles(packageName, features = {
116
117
  json: true,
117
- opt: true,
118
118
  operations: true,
119
+ opt: true,
119
120
  realtime: true,
120
121
  transport: true,
121
122
  ws: true,
@@ -164,7 +165,7 @@ function featuresOf(ops, decls) {
164
165
  function emitJava(document, options) {
165
166
  const pkg = packageOf(options);
166
167
  const dir = `src/main/java/${pkg.packageName.replaceAll(".", "/")}`;
167
- /* an operation without an operationId is named by the IR's derivation, as every sibling emitter asks */
168
+ // an operation without an operationId is named by the IR's derivation, as every sibling emitter asks
168
169
  const ir = toIR(document, { deriveOperationIds: true });
169
170
  const pom = pomOf(options, ir.info);
170
171
  const model = sdkModel(ir);
@@ -188,7 +189,7 @@ function emitJava(document, options) {
188
189
  }
189
190
  : {};
190
191
  const decls = componentDecls(ir, ctx);
191
- /* the mirror's names are claimed last, after every normal one (the components' own hoists included) */
192
+ // the mirror's names are claimed last, after every normal one (the components' own hoists included)
192
193
  const mirror = operations ? mirrorOf(ir, env) : {};
193
194
  const runtime = Object.entries(runtimeFiles(pkg.packageName, featuresOf(model.ops, decls))).map(([name, text]) => [`${dir}/${name}.java`, text]);
194
195
  const client = operations ? mirror[`${pkg.clientName}.java`] : `${MARKER}\n${clientJava(pkg)}`;
@@ -203,7 +204,7 @@ function emitJava(document, options) {
203
204
  .filter(([name]) => name !== `${pkg.clientName}.java`)
204
205
  .map(([name, text]) => [`${dir}/${name}`, text]),
205
206
  ];
206
- /* one declaration per file: a second claim of a path throws, never overwrites */
207
+ // one declaration per file: a second claim of a path throws, never overwrites
207
208
  const files = {};
208
209
  for (const [path, text] of entries)
209
210
  putFile(files, path, text);
@@ -1,11 +1,5 @@
1
- /**
2
- * An SSE operation's method (bit 16 phase d1, J1/J3/J7; C#'s `sse.ts`): `EventStream<T>`, `T` the declared event
3
- * schema's type, or `EventStream<String>` for untyped events, opened by the call through the exchange's `events`, so an
4
- * error status throws before any event. Its cursor field, `lastEventId`, is sent as Last-Event-ID only when set and
5
- * non-empty; a declared Last-Event-ID header param folds into it. A stream method is the same text in either mode: it
6
- * answers no Result. Its javadoc says how a stream lets its connection go (F1: a for-each `break` has no close hook).
7
- */
8
- import type { SdkOp } from "../../ir/sdk-model.ts";
1
+ import { type SdkOp } from "../../ir/sdk-model.ts";
2
+ import { type Expr } from "./layout.ts";
9
3
  import { type JavaTypeContext } from "./models.ts";
10
4
  import type { JavaHeaders } from "./sdk-headers.ts";
11
5
  /** The header an SSE open resumes an event stream with. */
@@ -14,12 +8,17 @@ export declare const LAST_EVENT_ID = "Last-Event-ID";
14
8
  export declare const CURSOR = "lastEventId";
15
9
  /** Whether a declared header param is Last-Event-ID (any casing), the resume channel the cursor field carries. */
16
10
  export declare const isLastEventIdHeader: (name: string) => boolean;
17
- /** F1's doc obligation: how a stream lets its connection go. */
18
- export declare const RELEASE = "Open it in try-with-resources: a for-each break without one keeps the connection.";
19
11
  /** The SSE runtime's files: the stream, its event, the parser and the body's pump; core, with every exchange. */
20
- export declare const SSE_FILES: string[];
21
- /** The type an SSE op's events decode to: the declared event schema's, else `String`. */
22
- export declare const eventTypeOf: (op: SdkOp, ctx: JavaTypeContext) => string;
12
+ export declare const SSE_FILES: readonly string[];
13
+ /**
14
+ * What an SSE op's stream yields and the decode the method hands the runtime: a named-event op's `<Op>Event` through
15
+ * its `of`; else `SseEvent<T>` through `EventStream.typed`, `T` the declared event schema's type, or `SseEvent<String>`
16
+ * as parsed for untyped or string events.
17
+ */
18
+ export declare function sseEventOf(op: SdkOp, ctx: JavaTypeContext): {
19
+ readonly type: string;
20
+ readonly decode: Expr;
21
+ };
23
22
  /** What an SSE method's lines need: its name and constant, its Params, its headers holder, and its Call's lines. */
24
23
  export type SseSite = {
25
24
  readonly name: string;