@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
@@ -17,13 +17,13 @@ export const realtimeStream = {
17
17
  answer: (op, env) => socketAnswer(op, env, {
18
18
  base: "ResumableConnection",
19
19
  in: "object",
20
- /* the one event a connection's `on` takes for itself */
20
+ // the one event a connection's `on` takes for itself
21
21
  lifecycle: (out) => [["message", out]],
22
22
  out: () => eventType(op, env, () => pyTypeOf({ kind: "unknown" }, env.at)),
23
23
  run: "realtime",
24
24
  suffix: "Connection",
25
25
  }),
26
- /* the WebSocket and long-poll dials send the cursor as query params, the SSE dial its id as Last-Event-ID */
26
+ // the WebSocket and long-poll dials send the cursor as query params, the SSE dial its id as Last-Event-ID
27
27
  carries: (name, where) => isReconnectToken(name, where) ||
28
28
  (where === "query" && name === "last_event_id") ||
29
29
  isLastEventIdHeader(name, where),
@@ -8,6 +8,7 @@
8
8
  import type { IRParam } from "../../ir/model.ts";
9
9
  import type { SdkOp } from "../../ir/sdk-model.ts";
10
10
  import type { MethodEnv } from "./sdk-method.ts";
11
+ import type { PythonCallPlan } from "./sdk-plan.ts";
11
12
  /** `schema`'s type at `<Op><field>`, written in the client module. */
12
13
  export declare const typeAt: (op: SdkOp, field: string, schema: IRParam["schema"], env: MethodEnv) => string;
13
14
  /** The body parameter's type: its schema's for JSON and a form, `<Op>Body` for multipart, `str` for text, bytes or chunks for binary. */
@@ -43,11 +44,6 @@ export declare function answerOf(op: SdkOp, env: MethodEnv): Answer;
43
44
  export declare function shapeOf(op: SdkOp, env: MethodEnv): string | null;
44
45
  /** `<Op>Headers` (total=False) hoisted beside the types, and how `Operation.headers` reads each; null without any. */
45
46
  export declare function responseHeaders(op: SdkOp, env: MethodEnv): {
46
- plan: {
47
- fields: {
48
- [k: string]: string;
49
- };
50
- type: string;
51
- };
52
- read: string[];
47
+ readonly plan: NonNullable<PythonCallPlan["responseHeaders"]>;
48
+ readonly read: string[];
53
49
  } | null;
@@ -75,14 +75,14 @@ export function responseHeaders(op, env) {
75
75
  const fields = headers.map((header) => {
76
76
  const resolved = env.at.names.resolve(header.schema);
77
77
  const at = { ...env.at, fieldName: header.name, parentName: type, typing };
78
- /* a scalar is read as its kind; any other schema as the header's text, which is what arrives */
78
+ // a scalar is read as its kind; any other schema as the header's text, which is what arrives
79
79
  const read = resolved.kind === "scalar" && resolved.type !== "null"
80
80
  ? { kind: resolved.type, type: pyTypeOf(header.schema, at) }
81
81
  : { kind: "string", type: "str" };
82
82
  return { header: header.name, key: scope.claim(pyIdentifier(header.name)), required: header.required, ...read };
83
83
  });
84
84
  typing.add("TypedDict");
85
- /* every key is an identifier (pyIdentifier), so the class form always spells it */
85
+ // every key is an identifier (pyIdentifier), so the class form always spells it
86
86
  env.at.decls.set(type, [`class ${type}(TypedDict, total=False):`, ...fields.map((f) => ` ${f.key}: ${f.type}`)].join("\n"));
87
87
  const read = fields.map(({ header, key, kind, required }) => `(${pyString(header)}, ${pyString(key)}, ${pyString(kind)}, ${required ? "True" : "False"})`);
88
88
  return { plan: { fields: Object.fromEntries(fields.map((f) => [f.header, f.key])), type }, read };
@@ -3,17 +3,16 @@ import { dictDecl } from "./types-dict.js";
3
3
  import { pyTypeOf } from "./types.js";
4
4
  /** The parts the body schema of `op` requires: none unless it is an object. */
5
5
  function requiredParts(op, env) {
6
- /* a multipart body, with file parts or text parts alone, is declared with its form's schema */
6
+ // a multipart body, with file parts or text parts alone, is declared with its form's schema
7
7
  const form = env.at.names.resolve(op.ir.body.schema);
8
8
  return new Set(form.kind === "object" ? form.fields.flatMap((f) => (f.required ? [f.name] : [])) : []);
9
9
  }
10
10
  /** The type of `part` as a key of `parent`: `FilePart` or its list for a file, its schema's type for text. */
11
11
  function partType(part, parent, env) {
12
- /* the IR gives every part its schema (ir/slots.ts partsOf, ir/sdk-model.ts bodyOf) */
12
+ // the IR gives every part its schema (ir/slots.ts partsOf, ir/sdk-model.ts bodyOf)
13
13
  const schema = part.schema;
14
- if (part.type === "text") {
14
+ if (part.type === "text")
15
15
  return pyTypeOf(schema, { ...env.at, fieldName: part.name, parentName: parent, typing: env.at.declTyping });
16
- }
17
16
  env.typesImports.add("FilePart");
18
17
  return env.at.names.resolve(schema).kind === "array" ? "list[FilePart]" : "FilePart";
19
18
  }
@@ -22,7 +21,7 @@ export function multipartBody(op, parts, env) {
22
21
  const name = env.at.names.hoist(`${op.id}.Body`, `${pyClassName(op.id)}Body`);
23
22
  if (env.at.decls.has(name))
24
23
  return name;
25
- /* claimed before its keys: what a text part hoists in turn comes after it */
24
+ // claimed before its keys: what a text part hoists in turn comes after it
26
25
  env.at.decls.set(name, "");
27
26
  const required = requiredParts(op, env);
28
27
  const keys = [...parts]
@@ -3,7 +3,7 @@ import { pyDocLines, pyString } from "../shared/escape.js";
3
3
  import { compareCodeUnits, NameScope, pyClassName, pyIdentifier } from "../shared/lang.js";
4
4
  import { MIRROR, mirrorNotice } from "../shared/mirror.js";
5
5
  import { BUILTINS, pyMethod } from "./sdk-method.js";
6
- /* the root clients' own members: no namespace or operation takes their names */
6
+ // the root clients' own members: no namespace or operation takes their names
7
7
  const ROOT_NAMES = ["close", "aclose", "is_stale", MIRROR];
8
8
  /**
9
9
  * `ns` at `path`: its children first, so a method never takes an attribute's name. A root member spelled `safe` is
@@ -37,7 +37,7 @@ const below = (node) => node.children.flatMap(({ node: child }) => [...below(chi
37
37
  */
38
38
  function classNames(root, env) {
39
39
  const base = (node) => (node === root ? "SDK" : `${node.path.map(pyClassName).join("")}Resource`);
40
- /* the normal classes first, so a twin never moves the name one of them had */
40
+ // the normal classes first, so a twin never moves the name one of them had
41
41
  const claimed = (nodes, prefix) => new Map(nodes.map((node) => {
42
42
  const sync = node === root || hasSync(node) ? env.at.names.claim(`${prefix}${base(node)}`) : undefined;
43
43
  const async = env.at.names.claim(`Async${prefix}${base(node)}`);
@@ -76,7 +76,7 @@ function methodBlocks(node, side) {
76
76
  }
77
77
  /** The class of `node` on `side`; a safe mirror's methods one line each, with no blank line between them. */
78
78
  function resourceClass(node, side) {
79
- const init = [" def __init__(self, transport: " + side.transport + ") -> None:", " self._t = transport"];
79
+ const init = [` def __init__(self, transport: ${side.transport}) -> None:`, " self._t = transport"];
80
80
  const methods = methodBlocks(node, side);
81
81
  return [
82
82
  `class ${side.name(node)}:`,
@@ -105,7 +105,7 @@ function rootClass(root, side, safe, doc) {
105
105
  [` ${a ? "async " : ""}def ${a}close(self) -> None:`, ` ${aw}self._t.${a}close()`],
106
106
  [` ${a ? "async " : ""}def __${a}enter__(self) -> Self:`, " return self"],
107
107
  [` ${a ? "async " : ""}def __${a}exit__(self, *exc: object) -> None:`, ` ${aw}self.${a}close()`],
108
- /* after the client's own methods: an operation named like a builtin shadows only what follows it */
108
+ // after the client's own methods: an operation named like a builtin shadows only what follows it
109
109
  ...methodBlocks(root, side),
110
110
  ];
111
111
  return [`class ${side.async ? "AsyncSDK" : "SDK"}:`, ` """${doc}"""`, "", ...members(own)];
@@ -153,7 +153,7 @@ export function clientDecls(ir, env) {
153
153
  ...nodes.map((node) => resourceClass(node, async)),
154
154
  rootClass(root, sync, safeSync, clientTitle(ir)),
155
155
  rootClass(root, async, safeAsync, clientTitle(ir)),
156
- /* after the classes they twin: each method line reads its normal class */
156
+ // after the classes they twin: each method line reads its normal class
157
157
  ...nodes.filter((node) => sync.name(node) !== undefined).map((node) => resourceClass(node, safeSync)),
158
158
  ...nodes.map((node) => resourceClass(node, safeAsync)),
159
159
  resourceClass(root, safeSync),
@@ -1,5 +1,5 @@
1
1
  import { pyDocLines } from "../shared/escape.js";
2
- /* the runtime's STATUS_ERRORS (runtime/python/errors.py); any other status raises APIStatusError */
2
+ // the runtime's STATUS_ERRORS (runtime/python/errors.py); any other status raises APIStatusError
3
3
  const STATUS_ERRORS = {
4
4
  400: "BadRequestError",
5
5
  401: "UnauthorizedError",
@@ -25,7 +25,7 @@ export function methodDoc(op, stream) {
25
25
  const lines = parts.flatMap((part, i) => (i === 0 ? part : ["", ...part]));
26
26
  if (lines.length === 0)
27
27
  return [];
28
- /* a docstring that opens on its Raises: block opens on a line of its own, so the block keeps its shape */
28
+ // a docstring that opens on its Raises: block opens on a line of its own, so the block keeps its shape
29
29
  const open = lines[0] === "Raises:" ? ['"""', ...lines] : [`"""${lines[0]}`, ...lines.slice(1)];
30
30
  const body = lines.length === 1 ? [`"""${lines[0]}"""`] : [...open, '"""'];
31
31
  return body.map((line) => (line === "" ? "" : ` ${line}`));
@@ -1,3 +1,12 @@
1
+ /**
2
+ * One operation (G1, G3, G5): its `_<NAME>: Operation[T]` constant, its method on the resource classes (async
3
+ * only for a stream), its `<Op>Headers` TypedDict, and its call plan. A method takes `self`, its path params as
4
+ * `str` in path order, then its body, then keyword-only query and header params (a required one without a
5
+ * default), `idempotency_key`, `headers_into`, its stream's own fields, and `options` last. The body is one
6
+ * call into the transport, evaluating only `self` and module globals named `_<UPPER>`: no parameter can
7
+ * shadow one (S3). Spec text reaches the source only through the shared escape layer.
8
+ */
9
+ import type { InvalidatedRead } from "../../ir/invalidate-reads.ts";
1
10
  import { type SdkOp } from "../../ir/sdk-model.ts";
2
11
  import { NameScope } from "../shared/lang.ts";
3
12
  import type { PythonCallPlan } from "./sdk-plan.ts";
@@ -12,6 +21,8 @@ export type MethodEnv = {
12
21
  readonly imports: Set<string>;
13
22
  /** the runtime names types.py imports (a multipart body's `FilePart`, a named event's `SseEventOf`) */
14
23
  readonly typesImports: Set<string>;
24
+ /** each write's reads by operationId (`invalidateReads`): what its `on_invalidate` event names */
25
+ readonly reads: ReadonlyMap<string, readonly InvalidatedRead[]>;
15
26
  };
16
27
  /**
17
28
  * One operation's constant, its methods (no sync one for a stream) written given the builtins its class's
@@ -6,23 +6,23 @@ import { answerOf, bodyType, responseHeaders, shapeOf, typeAt } from "./sdk-answ
6
6
  import { methodDoc } from "./sdk-doc.js";
7
7
  import { sseStream } from "./sse.js";
8
8
  import { wsStream } from "./ws.js";
9
- /* the builtins an annotation may spell that a method may be named: a method so named shadows it below */
9
+ // the builtins an annotation may spell that a method may be named: a method so named shadows it below
10
10
  export const BUILTINS = ["bool", "bytes", "dict", "float", "int", "list", "str", "tuple"];
11
11
  /**
12
12
  * `type` with each builtin `shadowed` names spelled `_builtins.<name>`; strings inside it kept. The module is
13
13
  * aliased because a method may be named `builtins`, and `pyIdentifier` never yields a leading `_`.
14
14
  */
15
15
  function qualified(type, shadowed, env) {
16
- return type.replace(/("(?:[^"\\]|\\.)*")|\b([a-z]+)\b/g, (whole, text, name) => {
16
+ return type.replaceAll(/("(?:[^"\\]|\\.)*")|\b([a-z]+)\b/g, (whole, text, name) => {
17
17
  if (text !== undefined || !shadowed.has(name))
18
18
  return whole;
19
19
  env.imports.add("builtins");
20
20
  return `_builtins.${name}`;
21
21
  });
22
22
  }
23
- /* the method's own names, a stream's fields among them: a parameter that takes one is claimed as `…2` */
23
+ // the method's own names, a stream's fields among them: a parameter that takes one is claimed as `…2`
24
24
  const METHOD_LOCALS = ["self", "body", "options", "idempotency_key", "headers_into"];
25
- /* each stream's answer, its own fields, and the declared params its resume channels carry (Fd3) */
25
+ // each stream's answer, its own fields, and the declared params its resume channels carry (Fd3)
26
26
  const STREAMS = {
27
27
  realtime: realtimeStream,
28
28
  sse: sseStream,
@@ -89,6 +89,20 @@ function framing(op, env) {
89
89
  ["dispatch", key === undefined ? null : pyString(key)],
90
90
  ];
91
91
  }
92
+ /**
93
+ * The `Operation(…)` keywords an `on_invalidate` event comes from: the write's operationId and each read a success
94
+ * makes stale with its own path params; none for a write with no reads, nor a realtime connection, which reconnects.
95
+ */
96
+ function invalidating(op, env) {
97
+ const reads = op.stream === "realtime" ? undefined : env.reads.get(op.id);
98
+ if (reads === undefined || reads.length === 0)
99
+ return [];
100
+ const each = reads.map((read) => `(${pyString(read.operationId)}, ${tuple(read.params.map(pyString))})`);
101
+ return [
102
+ ["by", pyString(op.id)],
103
+ ["reads", tuple(each)],
104
+ ];
105
+ }
92
106
  /** The `Operation(…)` keywords that differ from its defaults, in its field order. */
93
107
  function namedArgs(parts, env) {
94
108
  const { answer, headers, op } = parts;
@@ -103,6 +117,7 @@ function namedArgs(parts, env) {
103
117
  ["shape", shape === null ? null : pyString(shape)],
104
118
  ["idempotent", op.idempotent && op.stream === null ? "True" : null],
105
119
  ["invalidates", op.invalidates.length > 0 ? tuple(op.invalidates.map(pyString)) : null],
120
+ ...invalidating(op, env),
106
121
  ["stream", op.stream === null ? null : pyString(op.stream)],
107
122
  ["headers", headers === null ? null : tuple(headers.read)],
108
123
  ["events", jsonEvents(op, env)],
@@ -131,7 +146,7 @@ function methodLines(parts, async, env, shadowed) {
131
146
  const required = op.body?.required === true;
132
147
  const keyed = op.idempotent && op.stream === null;
133
148
  const own = op.stream === null ? [] : STREAMS[op.stream].fields;
134
- /* `name: type`, or `name: type = default`, its type qualified where an earlier method shadows a builtin */
149
+ // `name: type`, or `name: type = default`, its type qualified where an earlier method shadows a builtin
135
150
  const param = (text) => {
136
151
  const [name, rest] = [text.slice(0, text.indexOf(": ")), text.slice(text.indexOf(": ") + 2)];
137
152
  const unset = rest.endsWith(" = None");
@@ -1 +0,0 @@
1
- export {};
@@ -14,8 +14,6 @@ export declare const PYTHON_REQUIRES = ">=3.11";
14
14
  export declare const PYTHON_CLASSIFIERS: readonly string[];
15
15
  /** The lowest httpx2 every emitted package accepts. */
16
16
  export declare const HTTPX2_FLOOR = "2.12.0";
17
- /** The dependency string every emitted package declares (`httpx2[ws]` when it needs WebSockets). */
18
- export declare const HTTPX2 = "httpx2>=2.12.0,<3";
19
17
  /** `name` when it is an import name a package may take: lower snake case, no keyword, not the runtime's. */
20
18
  export declare function validatePackageName(name: string): string;
21
19
  /** `version` when it is in PEP 440's release, pre, post and dev subset. */
@@ -20,26 +20,24 @@ export const PYTHON_CLASSIFIERS = [
20
20
  "Programming Language :: Python :: 3.14",
21
21
  "Typing :: Typed",
22
22
  ];
23
- /* clients' own record of what it wrote (gen/write.ts MANIFEST), which no sdist ships */
23
+ // clients' own record of what it wrote (gen/write.ts MANIFEST), which no sdist ships
24
24
  const MANIFEST = ".clients-generated.json";
25
25
  /** The lowest httpx2 every emitted package accepts. */
26
26
  export const HTTPX2_FLOOR = "2.12.0";
27
27
  /** The dependency string every emitted package declares (`httpx2[ws]` when it needs WebSockets). */
28
- export const HTTPX2 = `httpx2>=${HTTPX2_FLOOR},<3`;
29
- /* the hard keywords and the soft ones, none an import name */
28
+ const HTTPX2 = `httpx2>=${HTTPX2_FLOOR},<3`;
29
+ // the hard keywords and the soft ones, none an import name
30
30
  const KEYWORDS = " False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield match case type _ ";
31
31
  /** `name` when it is an import name a package may take: lower snake case, no keyword, not the runtime's. */
32
32
  export function validatePackageName(name) {
33
- if (!/^[a-z][a-z0-9_]*$/.test(name) || KEYWORDS.includes(` ${name} `) || name === "_http") {
33
+ if (!/^[a-z][a-z0-9_]*$/.test(name) || KEYWORDS.includes(` ${name} `) || name === "_http")
34
34
  throw new Error(`Invalid package name: "${name}"`);
35
- }
36
35
  return name;
37
36
  }
38
37
  /** `version` when it is in PEP 440's release, pre, post and dev subset. */
39
38
  export function validateVersion(version) {
40
- if (!/^\d+(\.\d+)*((a|b|rc)\d+)?(\.post\d+)?(\.dev\d+)?$/.test(version)) {
39
+ if (!/^\d+(\.\d+)*((a|b|rc)\d+)?(\.post\d+)?(\.dev\d+)?$/.test(version))
41
40
  throw new Error(`Invalid version: "${version}"`);
42
- }
43
41
  return version;
44
42
  }
45
43
  /** A TOML basic string of `text`. */
@@ -74,7 +72,9 @@ function urls(metadata) {
74
72
  ["Documentation", documentation],
75
73
  ["Changelog", changelog],
76
74
  ].filter((entry) => entry[1] !== undefined);
77
- return labeled.length === 0 ? [] : ["[project.urls]", ...labeled.map(([label, url]) => `${label} = ${toml(url)}`), ""];
75
+ return labeled.length === 0
76
+ ? []
77
+ : ["[project.urls]", ...labeled.map(([label, url]) => `${label} = ${toml(url)}`), ""];
78
78
  }
79
79
  /** The manifest of package `pkg` (its import name; the distribution name has `-` for `_`). */
80
80
  export function pyproject(pkg, ws, metadata = {}) {
@@ -1,5 +1,5 @@
1
- import type { PythonCallPlan } from "./sdk-plan.ts";
2
1
  import { type Metadata, type PackageIdentity } from "../shared/metadata.ts";
2
+ import type { PythonCallPlan } from "./sdk-plan.ts";
3
3
  export type PythonSdkOptions = {
4
4
  /** the import name; `http_sdk` by default, its distribution name with `-` for `_` */
5
5
  readonly packageName?: string;
@@ -8,19 +8,20 @@
8
8
  * is no error-mode option.
9
9
  */
10
10
  import { toIR } from "../../ir/build.js";
11
+ import { invalidateReads } from "../../ir/invalidate-reads.js";
11
12
  import { sdkModel } from "../../ir/sdk-model.js";
12
13
  import { pyDocLines } from "../shared/escape.js";
13
14
  import { compareCodeUnits, NameScope } from "../shared/lang.js";
15
+ import { packageOn } from "../shared/metadata.js";
14
16
  import { pythonErrorKeys } from "./errors.js";
15
17
  import { clientDecls, clientTitle } from "./sdk-client.js";
16
18
  import { allOrder, importBlock, importLine } from "./sdk-imports.js";
17
- import { packageOn } from "../shared/metadata.js";
18
19
  import { pyproject, validatePackageName, validateVersion } from "./sdk-pyproject.js";
19
20
  import { needsWebSocket, runtimeExports, runtimeFiles } from "./transport.js";
20
21
  import { pyTopLevel, pyTypeContext } from "./types.js";
21
- /* the marker ruff, mypy and linguist read */
22
+ // the marker ruff, mypy and linguist read
22
23
  const MARKER = "# @generated by clients. DO NOT EDIT.";
23
- /* where client.py imports each runtime name from, under `._http.` */
24
+ // where client.py imports each runtime name from, under `._http.`
24
25
  const RUNTIME = {
25
26
  AsyncRealtimeTransport: "realtime",
26
27
  AsyncTransport: "send_async",
@@ -37,7 +38,7 @@ const RUNTIME = {
37
38
  TransportOpts: "transport",
38
39
  TypedWebSocket: "ws",
39
40
  };
40
- /* where types.py imports each runtime name from, under `._http.`; any other it spells is `collections.abc`'s */
41
+ // where types.py imports each runtime name from, under `._http.`; any other it spells is `collections.abc`'s
41
42
  const TYPES_RUNTIME = {
42
43
  FilePart: "body",
43
44
  HttpError: "errors",
@@ -71,7 +72,7 @@ function componentDecls(ir, at) {
71
72
  });
72
73
  }
73
74
  /** The identifiers `text` spells outside its strings. */
74
- const spelled = (text) => new Set(Array.from(text.replace(/"""[\s\S]*?"""|"(?:[^"\\\n]|\\.)*"/g, '""').matchAll(/[A-Za-z_]\w*/g), (match) => match[0]));
75
+ const spelled = (text) => new Set(Array.from(text.replaceAll(/"""[\s\S]*?"""|"(?:[^"\\\n]|\\.)*"/g, '""').matchAll(/[A-Za-z_]\w*/g), (match) => match[0]));
75
76
  /** client.py: the marker, the API's doc, its imports, then its declarations. */
76
77
  function clientFile(ir, env, body) {
77
78
  const doc = pyDocLines([clientTitle(ir), ir.info.description].filter((part) => part !== undefined).join("\n\n"));
@@ -115,15 +116,16 @@ function emitPython(document, options, metadata = {}) {
115
116
  const ir = toIR(document, { deriveOperationIds: true });
116
117
  const model = sdkModel(ir);
117
118
  const at = pyTypeContext(ir);
118
- /* components first: the client's hoisted types then land beside them */
119
+ // components first: the client's hoisted types then land beside them
119
120
  const components = componentDecls(ir, at);
120
- /* before the client: its `_DEFAULTS` names ErrorKey, and each `<Key>Data` lands among the hoisted declarations */
121
+ // before the client: its `_DEFAULTS` names ErrorKey, and each `<Key>Data` lands among the hoisted declarations
121
122
  const errorKey = pythonErrorKeys(model, at);
122
123
  const features = {
123
124
  realtime: model.ops.some((op) => op.stream === "realtime"),
124
125
  ws: model.ops.some((op) => op.stream === "ws"),
125
126
  };
126
127
  const transport = features.realtime ? "AsyncRealtimeTransport" : features.ws ? "AsyncWsTransport" : "AsyncTransport";
128
+ const { reads, warnings } = invalidateReads(ir);
127
129
  const env = {
128
130
  at: { ...at, declTyping: at.typing, typing: new Set() },
129
131
  constants: new NameScope(),
@@ -131,6 +133,7 @@ function emitPython(document, options, metadata = {}) {
131
133
  keyed: errorKey !== null,
132
134
  notices: [],
133
135
  ops: model.opsById,
136
+ reads,
134
137
  transport,
135
138
  typesImports: new Set(),
136
139
  };
@@ -158,7 +161,8 @@ function emitPython(document, options, metadata = {}) {
158
161
  ...Object.fromEntries(Object.entries(runtime).map(([name, source]) => [`${root}/_http/${name}`, source])),
159
162
  };
160
163
  const sorted = Object.fromEntries(Object.entries(files).sort(([a], [b]) => compareCodeUnits(a, b)));
161
- return { files: sorted, notices: env.notices, pkg, plans: client.plans };
164
+ const notices = [...env.notices, ...warnings.map((warning) => `python: ${warning}`)];
165
+ return { files: sorted, notices, pkg, plans: client.plans };
162
166
  }
163
167
  /** The package's files for `document`, by path, and its notices; `metadata` fills pyproject.toml's description fields. */
164
168
  export function generatePythonSdk(document, options = {}, metadata = {}) {
@@ -1,6 +1,4 @@
1
1
  import { type PyStream } from "./sdk-answer.ts";
2
- /** The header the SSE and realtime dials resume an event stream with. */
3
- export declare const LAST_EVENT_ID = "Last-Event-ID";
4
2
  /** Whether a declared param is the Last-Event-ID header (any casing), the resume channel an SSE dial sends. */
5
3
  export declare const isLastEventIdHeader: (name: string, where: string) => boolean;
6
4
  /** The SSE operation's answer, its one field and its docstring's lines. */
@@ -8,10 +8,10 @@
8
8
  import { sseEvents } from "../../ir/sdk-model.js";
9
9
  import { pyClassName } from "../shared/lang.js";
10
10
  import { eventType } from "./sdk-answer.js";
11
- import { pyTypeOf } from "./types.js";
12
11
  import { aliasDecl } from "./types-union.js";
12
+ import { pyTypeOf } from "./types.js";
13
13
  /** The header the SSE and realtime dials resume an event stream with. */
14
- export const LAST_EVENT_ID = "Last-Event-ID";
14
+ const LAST_EVENT_ID = "Last-Event-ID";
15
15
  /** Whether a declared param is the Last-Event-ID header (any casing), the resume channel an SSE dial sends. */
16
16
  export const isLastEventIdHeader = (name, where) => where === "header" && name.toLowerCase() === LAST_EVENT_ID.toLowerCase();
17
17
  /**
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { readFileSync } from "node:fs";
8
8
  import { compareCodeUnits } from "../shared/lang.js";
9
- /* every SDK: the sans-IO core and its two shells, config, errors, hooks, log, redirects, SSE, invalidation */
9
+ // every SDK: the sans-IO core and its two shells, config, errors, hooks, log, redirects, SSE, invalidation
10
10
  const CORE = [
11
11
  "__init__",
12
12
  "auth",
@@ -28,12 +28,12 @@ const CORE = [
28
28
  "sse",
29
29
  "stale",
30
30
  ];
31
- /* a WebSocket operation; realtime adds the transports on top of it */
31
+ // a WebSocket operation; realtime adds the transports on top of it
32
32
  const WS = ["ws"];
33
33
  const REALTIME = ["realtime", "transport", "transport_longpoll", "transport_sse", "transport_ws"];
34
- /* a module's `__all__ = [...]`, one name per line or on one line */
34
+ // a module's `__all__ = [...]`, one name per line or on one line
35
35
  const ALL = /^__all__ = \[([^\]]*)\]/m;
36
- /* a top-level public name: `class X`, `def x`, `async def x`, `X =` or `X: T =` at column 0 */
36
+ // a top-level public name: `class X`, `def x`, `async def x`, `X =` or `X: T =` at column 0
37
37
  const PUBLIC_NAME = /^(?:class (?<cls>[A-Za-z]\w*)|(?:async )?def (?<fn>[A-Za-z]\w*)\(|(?<bound>[A-Za-z]\w*)(?:: [^=\n]+)? = )/gm;
38
38
  /** Whether these features make the package depend on `httpx2[ws]` (Fb3). */
39
39
  export const needsWebSocket = (features) => features.ws || features.realtime;
@@ -17,8 +17,8 @@ export type DictKey = {
17
17
  };
18
18
  /** How a dict is declared beyond its keys: its bases and its docstring. */
19
19
  export type DictShape = {
20
- readonly bases?: readonly string[];
21
- readonly doc?: string;
20
+ readonly bases?: readonly string[] | undefined;
21
+ readonly doc?: string | undefined;
22
22
  };
23
23
  /** The TypedDict `name` over `keys`: the class form when every key is spellable, else the functional form. */
24
24
  export declare function dictDecl(name: string, keys: readonly DictKey[], shape?: DictShape): string;
@@ -1,6 +1,6 @@
1
1
  import { lineComment, pyDocLines, pyString } from "../shared/escape.js";
2
2
  import { compareCodeUnits } from "../shared/lang.js";
3
- /* the hard keywords: no class body can spell one as a key */
3
+ // the hard keywords: no class body can spell one as a key
4
4
  const HARD_KEYWORDS = " False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield ";
5
5
  /** Whether a class body can spell `key` as it is. */
6
6
  const spellable = (key) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(key) && !HARD_KEYWORDS.includes(` ${key} `) && !key.startsWith("__");
@@ -1,7 +1,7 @@
1
1
  import { irResolver } from "../../ir/schema.js";
2
2
  import { compareCodeUnits, NameScope, pyClassName } from "../shared/lang.js";
3
3
  import { publicNames, runtimeFiles } from "./transport.js";
4
- /* the names the emitted modules import or declare beside the runtime's */
4
+ // the names the emitted modules import or declare beside the runtime's
5
5
  const EMITTED = [
6
6
  "SDK",
7
7
  "AsyncSDK",
@@ -45,7 +45,7 @@ export function irNames(ir) {
45
45
  hoisted.set(key, name);
46
46
  return name;
47
47
  },
48
- /* only a declared component is referred to by name (types.ts reads a dangling ref as Any) */
48
+ // only a declared component is referred to by name (types.ts reads a dangling ref as Any)
49
49
  ref: (name) => components.get(name),
50
50
  resolve: irResolver(ir.schemas),
51
51
  };
@@ -12,7 +12,7 @@ export function valuePart(value) {
12
12
  const integral = typeof value === "number" && Number.isInteger(value);
13
13
  return integral ? { literal: BigInt(value).toString() } : { type: "float" };
14
14
  }
15
- /* where the Literal goes among a union's types: a string no type is spelled as */
15
+ // where the Literal goes among a union's types: a string no type is spelled as
16
16
  const LITERAL = "\u0000";
17
17
  /** `parts` as one annotation, and whether it spells `Literal`. */
18
18
  export function joined(parts) {
@@ -2,7 +2,7 @@ import { pascalWords, pyClassName } from "../shared/lang.js";
2
2
  import { dictDecl, dictParts, keysOf, mergedFields } from "./types-dict.js";
3
3
  import { irNames, plainNames } from "./types-names.js";
4
4
  import { aliasDecl, joined, valuePart, variantSuffix } from "./types-union.js";
5
- /* deeper than this, a schema is Any (Go and Rust parity; v0 Python stopped at 8) */
5
+ // deeper than this, a schema is Any (Go and Rust parity; v0 Python stopped at 8)
6
6
  const MAX_DEPTH = 12;
7
7
  const SCALARS = {
8
8
  boolean: "bool",
@@ -20,7 +20,7 @@ export function pyTypeContext(ir) {
20
20
  function declare(ir, at, key, base) {
21
21
  const name = at.names.hoist(key, base);
22
22
  if (!at.decls.has(name)) {
23
- /* claimed before its body: what the body hoists in turn comes after it */
23
+ // claimed before its body: what the body hoists in turn comes after it
24
24
  at.decls.set(name, "");
25
25
  at.decls.set(name, pyTopLevel(name, ir, { ...at, typing: at.declTyping }));
26
26
  }
@@ -90,7 +90,7 @@ function single(ir, at) {
90
90
  return objectUse(ir, at);
91
91
  if (ir.kind === "allOf")
92
92
  return allOfUse(ir, deeper(at));
93
- /* a ref to no component reads as any JSON value: the IR resolves it to unknown */
93
+ // a ref to no component reads as any JSON value: the IR resolves it to unknown
94
94
  if (ir.kind === "ref")
95
95
  return at.names.resolve(ir).kind === "unknown" ? "Any" : at.names.ref(ir.name);
96
96
  if (ir.kind === "scalar")
@@ -1,14 +1,10 @@
1
1
  import { type SdkOp } from "../../ir/sdk-model.ts";
2
2
  import { type Answer, type PyStream } from "./sdk-answer.ts";
3
3
  import type { MethodEnv } from "./sdk-method.ts";
4
- /** The resume cursor's token, which the WebSocket and realtime methods take. */
5
- export declare const RECONNECT_TOKEN = "reconnect_token: str | None = None";
6
- /** The subprotocols a WebSocket or realtime dial offers. */
7
- export declare const PROTOCOLS = "protocols: Sequence[str] | None = None";
8
4
  /** Whether a declared param is the `reconnect_token` query param, the resume channel a socket dial sends. */
9
5
  export declare const isReconnectToken: (name: string, where: string) => boolean;
10
6
  /** A socket class's `on` events beyond its members', given its `Out`: each with the type its handler takes. */
11
- export type Lifecycle = (out: string) => readonly (readonly [event: string, handler: string])[];
7
+ type Lifecycle = (out: string) => readonly (readonly [event: string, handler: string])[];
12
8
  /**
13
9
  * How a socket stream answers: its generic class `base[Out, In]` and the transport call it makes; what it reads and
14
10
  * sends when its op declares no `send` or `receive`; the subclass suffix a keyed `send` union names; the events
@@ -26,3 +22,4 @@ export type SocketShape = {
26
22
  export declare function socketAnswer(op: SdkOp, env: MethodEnv, shape: SocketShape): Answer;
27
23
  /** The WebSocket operation's answer, its two fields and its docstring's lines. */
28
24
  export declare const wsStream: PyStream;
25
+ export {};
@@ -4,9 +4,9 @@ import { pyClassName } from "../shared/lang.js";
4
4
  import { typeAt } from "./sdk-answer.js";
5
5
  import { pyKeyedMembers, pyTypeOf } from "./types.js";
6
6
  /** The resume cursor's token, which the WebSocket and realtime methods take. */
7
- export const RECONNECT_TOKEN = "reconnect_token: str | None = None";
7
+ const RECONNECT_TOKEN = "reconnect_token: str | None = None";
8
8
  /** The subprotocols a WebSocket or realtime dial offers. */
9
- export const PROTOCOLS = "protocols: Sequence[str] | None = None";
9
+ const PROTOCOLS = "protocols: Sequence[str] | None = None";
10
10
  /** Whether a declared param is the `reconnect_token` query param, the resume channel a socket dial sends. */
11
11
  export const isReconnectToken = (name, where) => where === "query" && name === "reconnect_token";
12
12
  /** One `on` overload: `event` hands its handler a `type`. */
@@ -24,7 +24,7 @@ function keyedClass(op, env, shape, dispatch) {
24
24
  const { receive, send } = op.ir.messages;
25
25
  const typing = env.at.declTyping;
26
26
  const at = { ...env.at, fieldName: "Send", parentName: op.id, typing };
27
- /* spelled in types.py, whose typing names they then take: the same hoist keys, so the names client.py spells */
27
+ // spelled in types.py, whose typing names they then take: the same hoist keys, so the names client.py spells
28
28
  const out = pyTypeOf(send, at);
29
29
  const inType = receive === undefined ? shape.in : pyTypeOf(receive, { ...at, fieldName: "Receive" });
30
30
  const lifecycle = shape.lifecycle(out);
@@ -63,7 +63,7 @@ export const wsStream = {
63
63
  answer: (op, env) => socketAnswer(op, env, {
64
64
  base: "TypedWebSocket",
65
65
  in: "object",
66
- /* the events every socket's `on` takes, with what each hands its handler */
66
+ // the events every socket's `on` takes, with what each hands its handler
67
67
  lifecycle: (out) => [
68
68
  ["message", out],
69
69
  ["close", "WsClose"],
@@ -5,7 +5,7 @@ import { rustTopLevel } from "./types.js";
5
5
  /** The keys an error response's envelope names, over every operation's JSON error statuses (the runtime reads JSON only). */
6
6
  function envelopeKeys(model) {
7
7
  return model.ops.flatMap((op) => op.errorStatuses.flatMap((status) => {
8
- /* an error status is a declared response, and a schema comes with the content type it is under */
8
+ // an error status is a declared response, and a schema comes with the content type it is under
9
9
  const { contentType, schema } = op.ir.responses[String(status)];
10
10
  if (schema === undefined || !isJsonMedia(contentType))
11
11
  return [];
@@ -19,7 +19,7 @@ function envelopeKeys(model) {
19
19
  function declaredKeys(model) {
20
20
  const byId = [...model.ops].sort((a, b) => compareCodeUnits(a.id, b.id));
21
21
  const declared = byId.flatMap((op) => Object.entries(op.ir.extensions.errors ?? {}));
22
- /* reversed, so a key ends on its first declaration */
22
+ // reversed, so a key ends on its first declaration
23
23
  const keys = new Map(declared.toReversed().map(([key, { schema }]) => [key, schema]));
24
24
  for (const key of envelopeKeys(model))
25
25
  if (!keys.has(key))
@@ -77,7 +77,7 @@ function fromLines(keys) {
77
77
  ];
78
78
  return ["impl From<&str> for ErrorKey {", " fn from(key: &str) -> Self {", ...parse, " }", "}"];
79
79
  }
80
- /* Display as the wire spells it, and ApiError::key() over the runtime's raw key */
80
+ // Display as the wire spells it, and ApiError::key() over the runtime's raw key
81
81
  const TAIL = [
82
82
  "impl std::fmt::Display for ErrorKey {",
83
83
  " fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {",
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import { readFileSync } from "node:fs";
8
8
  import { compareCodeUnits } from "../shared/lang.js";
9
- /* every SDK: config, the call, its request and exchange, redirects, auth, hooks, log, errors and their envelope, answers, SSE, invalidation */
9
+ // every SDK: config, the call, its request and exchange, redirects, auth, hooks, log, errors and their envelope, answers, SSE, invalidation
10
10
  const CORE = [
11
11
  "answer",
12
12
  "auth",
@@ -29,7 +29,7 @@ const CORE = [
29
29
  "sse",
30
30
  "stale",
31
31
  ];
32
- /* a WebSocket operation; realtime adds the transports on top of it */
32
+ // a WebSocket operation; realtime adds the transports on top of it
33
33
  const WS = ["ws"];
34
34
  const REALTIME = [
35
35
  "realtime",
@@ -39,9 +39,9 @@ const REALTIME = [
39
39
  "transport_sse",
40
40
  "transport_ws",
41
41
  ];
42
- /* the lock template every crate's Cargo.lock is cut from */
42
+ // the lock template every crate's Cargo.lock is cut from
43
43
  const LOCK = "Cargo.lock";
44
- /* a top-level public item: `pub struct Name`, `pub fn name`, … at column 0 */
44
+ // a top-level public item: `pub struct Name`, `pub fn name`, … at column 0
45
45
  const PUBLIC_ITEM = /^pub (?:struct|enum|trait|type|fn|const|static) ([A-Za-z_][A-Za-z0-9_]*)/gm;
46
46
  /** The runtime `.rs` file names an SDK with `features` ships, in code-unit order. */
47
47
  export function runtimeFileNames(features) {