@workerstack/clients 0.0.0-stage → 1.0.0-rc.23

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 (558) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +619 -2
  3. package/bin/honey-clients.js +94 -0
  4. package/dist/cli.d.ts +102 -0
  5. package/dist/cli.js +190 -0
  6. package/dist/emit/cli/channels.d.ts +73 -0
  7. package/dist/emit/cli/channels.js +197 -0
  8. package/dist/emit/cli/commands.d.ts +27 -0
  9. package/dist/emit/cli/commands.js +187 -0
  10. package/dist/emit/cli/discovery.d.ts +35 -0
  11. package/dist/emit/cli/discovery.js +202 -0
  12. package/dist/emit/cli/flags.d.ts +59 -0
  13. package/dist/emit/cli/flags.js +186 -0
  14. package/dist/emit/cli/index.d.ts +1 -0
  15. package/dist/emit/cli/index.js +1 -0
  16. package/dist/emit/cli/install.d.ts +37 -0
  17. package/dist/emit/cli/install.js +88 -0
  18. package/dist/emit/cli/layout.d.ts +23 -0
  19. package/dist/emit/cli/layout.js +118 -0
  20. package/dist/emit/cli/module.d.ts +30 -0
  21. package/dist/emit/cli/module.js +186 -0
  22. package/dist/emit/cli/release.d.ts +40 -0
  23. package/dist/emit/cli/release.js +183 -0
  24. package/dist/emit/cli/skills.d.ts +11 -0
  25. package/dist/emit/cli/skills.js +56 -0
  26. package/dist/emit/csharp/errors.d.ts +7 -0
  27. package/dist/emit/csharp/errors.js +69 -0
  28. package/dist/emit/csharp/index.d.ts +1 -0
  29. package/dist/emit/csharp/index.js +1 -0
  30. package/dist/emit/csharp/json.d.ts +13 -0
  31. package/dist/emit/csharp/json.js +113 -0
  32. package/dist/emit/csharp/realtime.d.ts +10 -0
  33. package/dist/emit/csharp/realtime.js +33 -0
  34. package/dist/emit/csharp/sdk-answer.d.ts +48 -0
  35. package/dist/emit/csharp/sdk-answer.js +85 -0
  36. package/dist/emit/csharp/sdk-body.d.ts +10 -0
  37. package/dist/emit/csharp/sdk-body.js +87 -0
  38. package/dist/emit/csharp/sdk-client.d.ts +32 -0
  39. package/dist/emit/csharp/sdk-client.js +177 -0
  40. package/dist/emit/csharp/sdk-csproj.d.ts +36 -0
  41. package/dist/emit/csharp/sdk-csproj.js +136 -0
  42. package/dist/emit/csharp/sdk-doc.d.ts +12 -0
  43. package/dist/emit/csharp/sdk-doc.js +35 -0
  44. package/dist/emit/csharp/sdk-method.d.ts +26 -0
  45. package/dist/emit/csharp/sdk-method.js +187 -0
  46. package/dist/emit/csharp/sdk-plan.d.ts +38 -0
  47. package/dist/emit/csharp/sdk-plan.js +1 -0
  48. package/dist/emit/csharp/sdk.d.ts +40 -0
  49. package/dist/emit/csharp/sdk.js +105 -0
  50. package/dist/emit/csharp/sse.d.ts +18 -0
  51. package/dist/emit/csharp/sse.js +29 -0
  52. package/dist/emit/csharp/transport.d.ts +11 -0
  53. package/dist/emit/csharp/transport.js +67 -0
  54. package/dist/emit/csharp/types-enum.d.ts +19 -0
  55. package/dist/emit/csharp/types-enum.js +63 -0
  56. package/dist/emit/csharp/types-names.d.ts +33 -0
  57. package/dist/emit/csharp/types-names.js +182 -0
  58. package/dist/emit/csharp/types-record.d.ts +25 -0
  59. package/dist/emit/csharp/types-record.js +65 -0
  60. package/dist/emit/csharp/types-union.d.ts +27 -0
  61. package/dist/emit/csharp/types-union.js +113 -0
  62. package/dist/emit/csharp/types.d.ts +36 -0
  63. package/dist/emit/csharp/types.js +126 -0
  64. package/dist/emit/csharp/ws.d.ts +20 -0
  65. package/dist/emit/csharp/ws.js +14 -0
  66. package/dist/emit/go/errors.d.ts +7 -0
  67. package/dist/emit/go/errors.js +44 -0
  68. package/dist/emit/go/http.d.ts +11 -0
  69. package/dist/emit/go/http.js +50 -0
  70. package/dist/emit/go/index.d.ts +1 -0
  71. package/dist/emit/go/index.js +1 -0
  72. package/dist/emit/go/module-path.d.ts +2 -0
  73. package/dist/emit/go/module-path.js +27 -0
  74. package/dist/emit/go/sdk-answer.d.ts +28 -0
  75. package/dist/emit/go/sdk-answer.js +41 -0
  76. package/dist/emit/go/sdk-body.d.ts +24 -0
  77. package/dist/emit/go/sdk-body.js +76 -0
  78. package/dist/emit/go/sdk-client.d.ts +29 -0
  79. package/dist/emit/go/sdk-client.js +141 -0
  80. package/dist/emit/go/sdk-method.d.ts +68 -0
  81. package/dist/emit/go/sdk-method.js +172 -0
  82. package/dist/emit/go/sdk-mirror.d.ts +23 -0
  83. package/dist/emit/go/sdk-mirror.js +97 -0
  84. package/dist/emit/go/sdk-opts.d.ts +55 -0
  85. package/dist/emit/go/sdk-opts.js +100 -0
  86. package/dist/emit/go/sdk.d.ts +26 -0
  87. package/dist/emit/go/sdk.js +111 -0
  88. package/dist/emit/go/sse.d.ts +16 -0
  89. package/dist/emit/go/sse.js +26 -0
  90. package/dist/emit/go/types-codec.d.ts +15 -0
  91. package/dist/emit/go/types-codec.js +171 -0
  92. package/dist/emit/go/types-names.d.ts +14 -0
  93. package/dist/emit/go/types-names.js +64 -0
  94. package/dist/emit/go/types-struct.d.ts +29 -0
  95. package/dist/emit/go/types-struct.js +65 -0
  96. package/dist/emit/go/types-union.d.ts +17 -0
  97. package/dist/emit/go/types-union.js +84 -0
  98. package/dist/emit/go/types.d.ts +32 -0
  99. package/dist/emit/go/types.js +177 -0
  100. package/dist/emit/go/ws.d.ts +12 -0
  101. package/dist/emit/go/ws.js +70 -0
  102. package/dist/emit/java/gradle.d.ts +57 -0
  103. package/dist/emit/java/gradle.js +221 -0
  104. package/dist/emit/java/index.d.ts +2 -0
  105. package/dist/emit/java/index.js +2 -0
  106. package/dist/emit/java/json.d.ts +13 -0
  107. package/dist/emit/java/json.js +84 -0
  108. package/dist/emit/java/layout-ast.d.ts +146 -0
  109. package/dist/emit/java/layout-ast.js +102 -0
  110. package/dist/emit/java/layout-decl.d.ts +20 -0
  111. package/dist/emit/java/layout-decl.js +155 -0
  112. package/dist/emit/java/layout-doc.d.ts +55 -0
  113. package/dist/emit/java/layout-doc.js +166 -0
  114. package/dist/emit/java/layout-dot.d.ts +18 -0
  115. package/dist/emit/java/layout-dot.js +127 -0
  116. package/dist/emit/java/layout-strings.d.ts +8 -0
  117. package/dist/emit/java/layout-strings.js +76 -0
  118. package/dist/emit/java/layout-types.d.ts +11 -0
  119. package/dist/emit/java/layout-types.js +95 -0
  120. package/dist/emit/java/layout-visitor.d.ts +38 -0
  121. package/dist/emit/java/layout-visitor.js +232 -0
  122. package/dist/emit/java/layout.d.ts +61 -0
  123. package/dist/emit/java/layout.js +121 -0
  124. package/dist/emit/java/models-enum.d.ts +17 -0
  125. package/dist/emit/java/models-enum.js +51 -0
  126. package/dist/emit/java/models-names.d.ts +29 -0
  127. package/dist/emit/java/models-names.js +97 -0
  128. package/dist/emit/java/models-record.d.ts +24 -0
  129. package/dist/emit/java/models-record.js +79 -0
  130. package/dist/emit/java/models-union.d.ts +27 -0
  131. package/dist/emit/java/models-union.js +86 -0
  132. package/dist/emit/java/models.d.ts +28 -0
  133. package/dist/emit/java/models.js +118 -0
  134. package/dist/emit/java/realtime.d.ts +50 -0
  135. package/dist/emit/java/realtime.js +69 -0
  136. package/dist/emit/java/sdk-client.d.ts +66 -0
  137. package/dist/emit/java/sdk-client.js +207 -0
  138. package/dist/emit/java/sdk-decl.d.ts +11 -0
  139. package/dist/emit/java/sdk-decl.js +63 -0
  140. package/dist/emit/java/sdk-errors.d.ts +13 -0
  141. package/dist/emit/java/sdk-errors.js +141 -0
  142. package/dist/emit/java/sdk-headers.d.ts +12 -0
  143. package/dist/emit/java/sdk-headers.js +74 -0
  144. package/dist/emit/java/sdk-mirror.d.ts +14 -0
  145. package/dist/emit/java/sdk-mirror.js +107 -0
  146. package/dist/emit/java/sdk-models.d.ts +16 -0
  147. package/dist/emit/java/sdk-models.js +68 -0
  148. package/dist/emit/java/sdk-op.d.ts +57 -0
  149. package/dist/emit/java/sdk-op.js +216 -0
  150. package/dist/emit/java/sdk-params.d.ts +38 -0
  151. package/dist/emit/java/sdk-params.js +133 -0
  152. package/dist/emit/java/sdk-plan.d.ts +52 -0
  153. package/dist/emit/java/sdk-plan.js +1 -0
  154. package/dist/emit/java/sdk-record.d.ts +16 -0
  155. package/dist/emit/java/sdk-record.js +99 -0
  156. package/dist/emit/java/sdk.d.ts +49 -0
  157. package/dist/emit/java/sdk.js +216 -0
  158. package/dist/emit/java/sse.d.ts +35 -0
  159. package/dist/emit/java/sse.js +57 -0
  160. package/dist/emit/java/ws.d.ts +27 -0
  161. package/dist/emit/java/ws.js +31 -0
  162. package/dist/emit/mcp/annotations.d.ts +15 -0
  163. package/dist/emit/mcp/annotations.js +15 -0
  164. package/dist/emit/mcp/files.d.ts +18 -0
  165. package/dist/emit/mcp/files.js +42 -0
  166. package/dist/emit/mcp/index.d.ts +3 -0
  167. package/dist/emit/mcp/index.js +3 -0
  168. package/dist/emit/mcp/literal.d.ts +2 -0
  169. package/dist/emit/mcp/literal.js +33 -0
  170. package/dist/emit/mcp/mounted.d.ts +21 -0
  171. package/dist/emit/mcp/mounted.js +89 -0
  172. package/dist/emit/mcp/output-schema.d.ts +18 -0
  173. package/dist/emit/mcp/output-schema.js +38 -0
  174. package/dist/emit/mcp/registry.d.ts +23 -0
  175. package/dist/emit/mcp/registry.js +83 -0
  176. package/dist/emit/mcp/runtime.d.ts +10 -0
  177. package/dist/emit/mcp/runtime.js +47 -0
  178. package/dist/emit/mcp/schema.d.ts +19 -0
  179. package/dist/emit/mcp/schema.js +88 -0
  180. package/dist/emit/mcp/server.d.ts +30 -0
  181. package/dist/emit/mcp/server.js +246 -0
  182. package/dist/emit/mcp/tools.d.ts +51 -0
  183. package/dist/emit/mcp/tools.js +153 -0
  184. package/dist/emit/python/errors.d.ts +8 -0
  185. package/dist/emit/python/errors.js +68 -0
  186. package/dist/emit/python/index.d.ts +1 -0
  187. package/dist/emit/python/index.js +1 -0
  188. package/dist/emit/python/realtime.d.ts +10 -0
  189. package/dist/emit/python/realtime.js +33 -0
  190. package/dist/emit/python/sdk-answer.d.ts +49 -0
  191. package/dist/emit/python/sdk-answer.js +89 -0
  192. package/dist/emit/python/sdk-body.d.ts +11 -0
  193. package/dist/emit/python/sdk-body.js +40 -0
  194. package/dist/emit/python/sdk-client.d.ts +36 -0
  195. package/dist/emit/python/sdk-client.js +163 -0
  196. package/dist/emit/python/sdk-doc.d.ts +9 -0
  197. package/dist/emit/python/sdk-doc.js +32 -0
  198. package/dist/emit/python/sdk-imports.d.ts +14 -0
  199. package/dist/emit/python/sdk-imports.js +38 -0
  200. package/dist/emit/python/sdk-method.d.ts +29 -0
  201. package/dist/emit/python/sdk-method.js +183 -0
  202. package/dist/emit/python/sdk-plan.d.ts +33 -0
  203. package/dist/emit/python/sdk-plan.js +1 -0
  204. package/dist/emit/python/sdk-pyproject.d.ts +27 -0
  205. package/dist/emit/python/sdk-pyproject.js +103 -0
  206. package/dist/emit/python/sdk.d.ts +22 -0
  207. package/dist/emit/python/sdk.js +154 -0
  208. package/dist/emit/python/sse.d.ts +12 -0
  209. package/dist/emit/python/sse.js +23 -0
  210. package/dist/emit/python/transport.d.ts +15 -0
  211. package/dist/emit/python/transport.js +60 -0
  212. package/dist/emit/python/types-dict.d.ts +31 -0
  213. package/dist/emit/python/types-dict.js +45 -0
  214. package/dist/emit/python/types-names.d.ts +16 -0
  215. package/dist/emit/python/types-names.js +52 -0
  216. package/dist/emit/python/types-union.d.ts +32 -0
  217. package/dist/emit/python/types-union.js +46 -0
  218. package/dist/emit/python/types.d.ts +36 -0
  219. package/dist/emit/python/types.js +128 -0
  220. package/dist/emit/python/ws.d.ts +14 -0
  221. package/dist/emit/python/ws.js +16 -0
  222. package/dist/emit/rust/errors.d.ts +7 -0
  223. package/dist/emit/rust/errors.js +107 -0
  224. package/dist/emit/rust/http.d.ts +13 -0
  225. package/dist/emit/rust/http.js +67 -0
  226. package/dist/emit/rust/index.d.ts +1 -0
  227. package/dist/emit/rust/index.js +1 -0
  228. package/dist/emit/rust/realtime.d.ts +11 -0
  229. package/dist/emit/rust/realtime.js +29 -0
  230. package/dist/emit/rust/sdk-body.d.ts +19 -0
  231. package/dist/emit/rust/sdk-body.js +53 -0
  232. package/dist/emit/rust/sdk-cargo.d.ts +43 -0
  233. package/dist/emit/rust/sdk-cargo.js +178 -0
  234. package/dist/emit/rust/sdk-client.d.ts +25 -0
  235. package/dist/emit/rust/sdk-client.js +108 -0
  236. package/dist/emit/rust/sdk-method.d.ts +15 -0
  237. package/dist/emit/rust/sdk-method.js +119 -0
  238. package/dist/emit/rust/sdk-opts.d.ts +58 -0
  239. package/dist/emit/rust/sdk-opts.js +117 -0
  240. package/dist/emit/rust/sdk-plan.d.ts +33 -0
  241. package/dist/emit/rust/sdk-plan.js +1 -0
  242. package/dist/emit/rust/sdk.d.ts +23 -0
  243. package/dist/emit/rust/sdk.js +111 -0
  244. package/dist/emit/rust/sse.d.ts +19 -0
  245. package/dist/emit/rust/sse.js +20 -0
  246. package/dist/emit/rust/types-enum.d.ts +13 -0
  247. package/dist/emit/rust/types-enum.js +62 -0
  248. package/dist/emit/rust/types-names.d.ts +19 -0
  249. package/dist/emit/rust/types-names.js +66 -0
  250. package/dist/emit/rust/types-struct.d.ts +21 -0
  251. package/dist/emit/rust/types-struct.js +59 -0
  252. package/dist/emit/rust/types-union.d.ts +24 -0
  253. package/dist/emit/rust/types-union.js +97 -0
  254. package/dist/emit/rust/types.d.ts +34 -0
  255. package/dist/emit/rust/types.js +105 -0
  256. package/dist/emit/rust/ws.d.ts +21 -0
  257. package/dist/emit/rust/ws.js +20 -0
  258. package/dist/emit/shared/escape.d.ts +55 -0
  259. package/dist/emit/shared/escape.js +144 -0
  260. package/dist/emit/shared/format.d.ts +24 -0
  261. package/dist/emit/shared/format.js +23 -0
  262. package/dist/emit/shared/gofmt.d.ts +3 -0
  263. package/dist/emit/shared/gofmt.js +26 -0
  264. package/dist/emit/shared/lang.d.ts +60 -0
  265. package/dist/emit/shared/lang.js +233 -0
  266. package/dist/emit/shared/literals.d.ts +4 -0
  267. package/dist/emit/shared/literals.js +31 -0
  268. package/dist/emit/shared/metadata.d.ts +106 -0
  269. package/dist/emit/shared/metadata.js +130 -0
  270. package/dist/emit/shared/mirror.d.ts +22 -0
  271. package/dist/emit/shared/mirror.js +26 -0
  272. package/dist/emit/shared/ruff.d.ts +3 -0
  273. package/dist/emit/shared/ruff.js +31 -0
  274. package/dist/emit/shared/rustfmt.d.ts +3 -0
  275. package/dist/emit/shared/rustfmt.js +32 -0
  276. package/dist/emit/shared/status-keys.d.ts +7 -0
  277. package/dist/emit/shared/status-keys.js +67 -0
  278. package/dist/emit/shared/type-emitter.d.ts +19 -0
  279. package/dist/emit/shared/type-emitter.js +100 -0
  280. package/dist/emit/ts/app-client.d.ts +4 -0
  281. package/dist/emit/ts/app-client.js +68 -0
  282. package/dist/emit/ts/http.d.ts +20 -0
  283. package/dist/emit/ts/http.js +74 -0
  284. package/dist/emit/ts/package.d.ts +36 -0
  285. package/dist/emit/ts/package.js +126 -0
  286. package/dist/emit/ts/route-tree.d.ts +68 -0
  287. package/dist/emit/ts/route-tree.js +240 -0
  288. package/dist/emit/ts/sdk-types-preamble.d.ts +14 -0
  289. package/dist/emit/ts/sdk-types-preamble.js +123 -0
  290. package/dist/emit/ts/sdk-types.d.ts +13 -0
  291. package/dist/emit/ts/sdk-types.js +213 -0
  292. package/dist/emit/ts/sdk.d.ts +21 -0
  293. package/dist/emit/ts/sdk.js +173 -0
  294. package/dist/emit/ts/service-map.d.ts +40 -0
  295. package/dist/emit/ts/service-map.js +171 -0
  296. package/dist/emit/ts/tanstack-query.d.ts +12 -0
  297. package/dist/emit/ts/tanstack-query.js +156 -0
  298. package/dist/emit/ts/type-gen.d.ts +26 -0
  299. package/dist/emit/ts/type-gen.js +255 -0
  300. package/dist/emit/ts/webhooks.d.ts +19 -0
  301. package/dist/emit/ts/webhooks.js +81 -0
  302. package/dist/extract/chain.d.ts +34 -0
  303. package/dist/extract/chain.js +84 -0
  304. package/dist/extract/extract.d.ts +41 -0
  305. package/dist/extract/extract.js +191 -0
  306. package/dist/extract/serialize.d.ts +34 -0
  307. package/dist/extract/serialize.js +295 -0
  308. package/dist/extract/walk.d.ts +47 -0
  309. package/dist/extract/walk.js +109 -0
  310. package/dist/gen/args.d.ts +28 -0
  311. package/dist/gen/args.js +133 -0
  312. package/dist/gen/formatters.d.ts +62 -0
  313. package/dist/gen/formatters.js +146 -0
  314. package/dist/gen/process.d.ts +13 -0
  315. package/dist/gen/process.js +35 -0
  316. package/dist/gen/shipped.d.ts +17 -0
  317. package/dist/gen/shipped.js +55 -0
  318. package/dist/gen/targets.d.ts +93 -0
  319. package/dist/gen/targets.js +171 -0
  320. package/dist/gen/write.d.ts +33 -0
  321. package/dist/gen/write.js +118 -0
  322. package/dist/index.d.ts +13 -0
  323. package/dist/index.js +15 -0
  324. package/dist/ir/build.d.ts +37 -0
  325. package/dist/ir/build.js +152 -0
  326. package/dist/ir/load.d.ts +11 -0
  327. package/dist/ir/load.js +112 -0
  328. package/dist/ir/model.d.ts +206 -0
  329. package/dist/ir/model.js +5 -0
  330. package/dist/ir/resolve-refs.d.ts +11 -0
  331. package/dist/ir/resolve-refs.js +66 -0
  332. package/dist/ir/resource-tree.d.ts +9 -0
  333. package/dist/ir/resource-tree.js +53 -0
  334. package/dist/ir/route-tree-intern.d.ts +18 -0
  335. package/dist/ir/route-tree-intern.js +174 -0
  336. package/dist/ir/schema.d.ts +11 -0
  337. package/dist/ir/schema.js +192 -0
  338. package/dist/ir/sdk-model.d.ts +86 -0
  339. package/dist/ir/sdk-model.js +204 -0
  340. package/dist/ir/slots.d.ts +42 -0
  341. package/dist/ir/slots.js +245 -0
  342. package/dist/runtime/cli/body.go +176 -0
  343. package/dist/runtime/cli/config.go +243 -0
  344. package/dist/runtime/cli/discovery.go +147 -0
  345. package/dist/runtime/cli/format.go +174 -0
  346. package/dist/runtime/cli/log.go +117 -0
  347. package/dist/runtime/cli/output.go +247 -0
  348. package/dist/runtime/cli/params.go +197 -0
  349. package/dist/runtime/cli/run.go +226 -0
  350. package/dist/runtime/cli/socket.go +60 -0
  351. package/dist/runtime/cli/stream.go +217 -0
  352. package/dist/runtime/cli/target.go +117 -0
  353. package/dist/runtime/csharp/Adapters.cs +183 -0
  354. package/dist/runtime/csharp/Auth.cs +56 -0
  355. package/dist/runtime/csharp/Body.cs +135 -0
  356. package/dist/runtime/csharp/Config.cs +161 -0
  357. package/dist/runtime/csharp/Envelope.cs +149 -0
  358. package/dist/runtime/csharp/Errors.cs +194 -0
  359. package/dist/runtime/csharp/Events.cs +155 -0
  360. package/dist/runtime/csharp/Exchange.cs +247 -0
  361. package/dist/runtime/csharp/Handler.cs +103 -0
  362. package/dist/runtime/csharp/Hooks.cs +128 -0
  363. package/dist/runtime/csharp/Invalidation.cs +102 -0
  364. package/dist/runtime/csharp/Json.cs +144 -0
  365. package/dist/runtime/csharp/Log.cs +48 -0
  366. package/dist/runtime/csharp/Operation.cs +33 -0
  367. package/dist/runtime/csharp/Path.cs +65 -0
  368. package/dist/runtime/csharp/Query.cs +72 -0
  369. package/dist/runtime/csharp/Realtime.cs +118 -0
  370. package/dist/runtime/csharp/RealtimeLoop.cs +236 -0
  371. package/dist/runtime/csharp/Redirect.cs +53 -0
  372. package/dist/runtime/csharp/Result.cs +57 -0
  373. package/dist/runtime/csharp/Sse.cs +122 -0
  374. package/dist/runtime/csharp/Stale.cs +151 -0
  375. package/dist/runtime/csharp/Transport.cs +143 -0
  376. package/dist/runtime/csharp/TransportLongPoll.cs +63 -0
  377. package/dist/runtime/csharp/TransportSse.cs +54 -0
  378. package/dist/runtime/csharp/TransportWs.cs +40 -0
  379. package/dist/runtime/csharp/Wire.cs +109 -0
  380. package/dist/runtime/csharp/Ws.cs +300 -0
  381. package/dist/runtime/csharp/WsDial.cs +127 -0
  382. package/dist/runtime/go/auth.go +127 -0
  383. package/dist/runtime/go/body.go +129 -0
  384. package/dist/runtime/go/config.go +75 -0
  385. package/dist/runtime/go/errors.go +185 -0
  386. package/dist/runtime/go/export.go +37 -0
  387. package/dist/runtime/go/hooks.go +53 -0
  388. package/dist/runtime/go/invalidation.go +112 -0
  389. package/dist/runtime/go/log.go +92 -0
  390. package/dist/runtime/go/nullable.go +64 -0
  391. package/dist/runtime/go/options.go +118 -0
  392. package/dist/runtime/go/path.go +156 -0
  393. package/dist/runtime/go/query.go +147 -0
  394. package/dist/runtime/go/realtime.go +239 -0
  395. package/dist/runtime/go/realtime_loop.go +208 -0
  396. package/dist/runtime/go/redirect.go +124 -0
  397. package/dist/runtime/go/request.go +222 -0
  398. package/dist/runtime/go/result.go +86 -0
  399. package/dist/runtime/go/sse.go +186 -0
  400. package/dist/runtime/go/stale.go +229 -0
  401. package/dist/runtime/go/stream.go +105 -0
  402. package/dist/runtime/go/transport.go +242 -0
  403. package/dist/runtime/go/transport_longpoll.go +121 -0
  404. package/dist/runtime/go/transport_sse.go +175 -0
  405. package/dist/runtime/go/ws.go +205 -0
  406. package/dist/runtime/java/Answer.java +107 -0
  407. package/dist/runtime/java/ApiException.java +110 -0
  408. package/dist/runtime/java/BinaryBody.java +36 -0
  409. package/dist/runtime/java/Body.java +105 -0
  410. package/dist/runtime/java/Call.java +23 -0
  411. package/dist/runtime/java/CallLog.java +51 -0
  412. package/dist/runtime/java/ClientConfig.java +233 -0
  413. package/dist/runtime/java/ConnectionState.java +12 -0
  414. package/dist/runtime/java/Credential.java +58 -0
  415. package/dist/runtime/java/Deadline.java +38 -0
  416. package/dist/runtime/java/Decode.java +181 -0
  417. package/dist/runtime/java/Envelope.java +141 -0
  418. package/dist/runtime/java/ErrorEnvelope.java +23 -0
  419. package/dist/runtime/java/EventStream.java +129 -0
  420. package/dist/runtime/java/Exchange.java +62 -0
  421. package/dist/runtime/java/FilePart.java +5 -0
  422. package/dist/runtime/java/Flight.java +306 -0
  423. package/dist/runtime/java/HoneyException.java +14 -0
  424. package/dist/runtime/java/Hooks.java +47 -0
  425. package/dist/runtime/java/Hops.java +133 -0
  426. package/dist/runtime/java/InvalidationConfig.java +73 -0
  427. package/dist/runtime/java/Json.java +23 -0
  428. package/dist/runtime/java/Keepalive.java +60 -0
  429. package/dist/runtime/java/LogEntry.java +14 -0
  430. package/dist/runtime/java/LongPollAdapter.java +68 -0
  431. package/dist/runtime/java/Operation.java +21 -0
  432. package/dist/runtime/java/Opt.java +121 -0
  433. package/dist/runtime/java/Pump.java +160 -0
  434. package/dist/runtime/java/RawResponse.java +48 -0
  435. package/dist/runtime/java/Realtime.java +152 -0
  436. package/dist/runtime/java/RealtimeLoop.java +371 -0
  437. package/dist/runtime/java/RedirectPolicy.java +13 -0
  438. package/dist/runtime/java/Redirects.java +126 -0
  439. package/dist/runtime/java/RequestContext.java +78 -0
  440. package/dist/runtime/java/RequestHook.java +9 -0
  441. package/dist/runtime/java/RequestOptions.java +91 -0
  442. package/dist/runtime/java/ResponseContext.java +70 -0
  443. package/dist/runtime/java/ResponseHook.java +12 -0
  444. package/dist/runtime/java/Result.java +32 -0
  445. package/dist/runtime/java/ResumableConnection.java +165 -0
  446. package/dist/runtime/java/SdkException.java +11 -0
  447. package/dist/runtime/java/Socket.java +301 -0
  448. package/dist/runtime/java/Sse.java +171 -0
  449. package/dist/runtime/java/SseAdapter.java +61 -0
  450. package/dist/runtime/java/SseEvent.java +10 -0
  451. package/dist/runtime/java/StaleMeta.java +16 -0
  452. package/dist/runtime/java/StaleTracker.java +287 -0
  453. package/dist/runtime/java/Transport.java +16 -0
  454. package/dist/runtime/java/TransportAdapter.java +14 -0
  455. package/dist/runtime/java/TransportConnection.java +15 -0
  456. package/dist/runtime/java/TransportKind.java +12 -0
  457. package/dist/runtime/java/TransportMessage.java +9 -0
  458. package/dist/runtime/java/TransportOptions.java +138 -0
  459. package/dist/runtime/java/TypedWebSocket.java +83 -0
  460. package/dist/runtime/java/UrlPath.java +49 -0
  461. package/dist/runtime/java/UrlQuery.java +99 -0
  462. package/dist/runtime/java/WsAdapter.java +52 -0
  463. package/dist/runtime/java/WsClose.java +47 -0
  464. package/dist/runtime/java/WsDial.java +148 -0
  465. package/dist/runtime/java/WsMessage.java +18 -0
  466. package/dist/runtime/mcp/call.ts +167 -0
  467. package/dist/runtime/mcp/files.ts +183 -0
  468. package/dist/runtime/mcp/guard.ts +176 -0
  469. package/dist/runtime/mcp/http.ts +159 -0
  470. package/dist/runtime/mcp/jsonrpc.ts +50 -0
  471. package/dist/runtime/mcp/listen.ts +76 -0
  472. package/dist/runtime/mcp/mount.ts +123 -0
  473. package/dist/runtime/mcp/protocol.ts +219 -0
  474. package/dist/runtime/mcp/reader.ts +57 -0
  475. package/dist/runtime/mcp/result.ts +85 -0
  476. package/dist/runtime/mcp/stdio.ts +79 -0
  477. package/dist/runtime/mcp/stream.ts +62 -0
  478. package/dist/runtime/python/__init__.py +2 -0
  479. package/dist/runtime/python/auth.py +67 -0
  480. package/dist/runtime/python/body.py +83 -0
  481. package/dist/runtime/python/config.py +139 -0
  482. package/dist/runtime/python/errors.py +213 -0
  483. package/dist/runtime/python/events.py +152 -0
  484. package/dist/runtime/python/exchange.py +298 -0
  485. package/dist/runtime/python/hooks.py +86 -0
  486. package/dist/runtime/python/invalidation.py +57 -0
  487. package/dist/runtime/python/log.py +60 -0
  488. package/dist/runtime/python/operation.py +25 -0
  489. package/dist/runtime/python/path.py +41 -0
  490. package/dist/runtime/python/query.py +48 -0
  491. package/dist/runtime/python/realtime.py +244 -0
  492. package/dist/runtime/python/redirect.py +93 -0
  493. package/dist/runtime/python/result.py +58 -0
  494. package/dist/runtime/python/send_async.py +189 -0
  495. package/dist/runtime/python/send_sync.py +105 -0
  496. package/dist/runtime/python/sse.py +81 -0
  497. package/dist/runtime/python/stale.py +94 -0
  498. package/dist/runtime/python/transport.py +157 -0
  499. package/dist/runtime/python/transport_longpoll.py +60 -0
  500. package/dist/runtime/python/transport_sse.py +60 -0
  501. package/dist/runtime/python/transport_ws.py +57 -0
  502. package/dist/runtime/python/ws.py +276 -0
  503. package/dist/runtime/rust/Cargo.lock +1763 -0
  504. package/dist/runtime/rust/answer.rs +120 -0
  505. package/dist/runtime/rust/auth.rs +80 -0
  506. package/dist/runtime/rust/body.rs +150 -0
  507. package/dist/runtime/rust/call.rs +200 -0
  508. package/dist/runtime/rust/config.rs +254 -0
  509. package/dist/runtime/rust/envelope.rs +84 -0
  510. package/dist/runtime/rust/errors.rs +235 -0
  511. package/dist/runtime/rust/events.rs +177 -0
  512. package/dist/runtime/rust/exchange.rs +287 -0
  513. package/dist/runtime/rust/hooks.rs +63 -0
  514. package/dist/runtime/rust/invalidation.rs +84 -0
  515. package/dist/runtime/rust/log.rs +88 -0
  516. package/dist/runtime/rust/nullable.rs +13 -0
  517. package/dist/runtime/rust/path.rs +83 -0
  518. package/dist/runtime/rust/query.rs +84 -0
  519. package/dist/runtime/rust/realtime.rs +182 -0
  520. package/dist/runtime/rust/realtime_loop.rs +177 -0
  521. package/dist/runtime/rust/redirect.rs +121 -0
  522. package/dist/runtime/rust/request.rs +178 -0
  523. package/dist/runtime/rust/result.rs +101 -0
  524. package/dist/runtime/rust/sse.rs +104 -0
  525. package/dist/runtime/rust/stale.rs +209 -0
  526. package/dist/runtime/rust/transport.rs +221 -0
  527. package/dist/runtime/rust/transport_longpoll.rs +108 -0
  528. package/dist/runtime/rust/transport_sse.rs +91 -0
  529. package/dist/runtime/rust/transport_ws.rs +75 -0
  530. package/dist/runtime/rust/ws.rs +322 -0
  531. package/dist/runtime/ts/app-types.ts +200 -0
  532. package/dist/runtime/ts/app.ts +104 -0
  533. package/dist/runtime/ts/config.ts +124 -0
  534. package/dist/runtime/ts/defaults.ts +48 -0
  535. package/dist/runtime/ts/error.ts +113 -0
  536. package/dist/runtime/ts/hooks.ts +92 -0
  537. package/dist/runtime/ts/http.ts +228 -0
  538. package/dist/runtime/ts/media-type.ts +36 -0
  539. package/dist/runtime/ts/path.ts +152 -0
  540. package/dist/runtime/ts/realtime-connection.ts +296 -0
  541. package/dist/runtime/ts/realtime-transports.ts +149 -0
  542. package/dist/runtime/ts/realtime.ts +293 -0
  543. package/dist/runtime/ts/redirect-policy.ts +17 -0
  544. package/dist/runtime/ts/redirects.ts +74 -0
  545. package/dist/runtime/ts/request.ts +239 -0
  546. package/dist/runtime/ts/response.ts +219 -0
  547. package/dist/runtime/ts/sdk-realtime.ts +10 -0
  548. package/dist/runtime/ts/sdk-sse.ts +55 -0
  549. package/dist/runtime/ts/sdk-ws.ts +21 -0
  550. package/dist/runtime/ts/sdk.ts +242 -0
  551. package/dist/runtime/ts/sse.ts +175 -0
  552. package/dist/runtime/ts/stale.ts +137 -0
  553. package/dist/runtime/ts/stream.ts +87 -0
  554. package/dist/runtime/ts/webhook.ts +116 -0
  555. package/dist/runtime/ts/ws.ts +155 -0
  556. package/dist/runtime/ts-tanstack-query/invalidate.ts +152 -0
  557. package/dist/runtime/ts-tanstack-query/query.ts +261 -0
  558. package/package.json +84 -5
@@ -0,0 +1,31 @@
1
+ /**
2
+ * TypedDicts (Fb6): a total `TypedDict` whose required key is a bare `T` and optional one `NotRequired[T]`, in
3
+ * code-unit order of the JSON key. The class form when every key is an ASCII identifier, no hard keyword and
4
+ * not `__`-prefixed (a class body would mangle it); else the functional form, each value one quoted string.
5
+ * An allOf over dict-shaped refs inherits them; its inline objects' keys are merged, the first part's winning.
6
+ */
7
+ import type { IRField, IRSchema } from "../../ir/model.ts";
8
+ type Of<K extends IRSchema["kind"]> = Extract<IRSchema, {
9
+ kind: K;
10
+ }>;
11
+ /** The Python type of `schema` at the key `fieldName` of the declaration being written. */
12
+ export type Member = (schema: IRSchema, fieldName: string) => string;
13
+ /** One key as declared: its JSON spelling and its annotation. */
14
+ export type DictKey = {
15
+ readonly key: string;
16
+ readonly type: string;
17
+ };
18
+ /** How a dict is declared beyond its keys: its bases and its docstring. */
19
+ export type DictShape = {
20
+ readonly bases?: readonly string[];
21
+ readonly doc?: string;
22
+ };
23
+ /** The TypedDict `name` over `keys`: the class form when every key is spellable, else the functional form. */
24
+ export declare function dictDecl(name: string, keys: readonly DictKey[], shape?: DictShape): string;
25
+ /** `fields` as keys: a required one bare, an optional one `NotRequired[T]`; `optional` when it reads that. */
26
+ export declare function keysOf(fields: readonly IRField[], member: Member, optional: () => void): DictKey[];
27
+ /** The fields of `parts`' inline objects, a repeated key once (its first part's). */
28
+ export declare function mergedFields(parts: readonly IRSchema[]): IRField[];
29
+ /** Whether an allOf can be one class: every part a ref to a TypedDict or an inline object. */
30
+ export declare function dictParts(ir: Of<"allOf">, isDict: (schema: IRSchema) => boolean): boolean;
31
+ export {};
@@ -0,0 +1,45 @@
1
+ import { lineComment, pyDocLines, pyString } from "../shared/escape.js";
2
+ import { compareCodeUnits } from "../shared/lang.js";
3
+ /* the hard keywords: no class body can spell one as a key */
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
+ /** Whether a class body can spell `key` as it is. */
6
+ const spellable = (key) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(key) && !HARD_KEYWORDS.includes(` ${key} `) && !key.startsWith("__");
7
+ /** A class docstring's lines, then the blank line ruff keeps after one. */
8
+ const docLines = (doc) => {
9
+ if (doc === undefined)
10
+ return [];
11
+ const lines = pyDocLines(doc);
12
+ const body = lines.length === 1 ? [`"""${lines[0]}"""`] : [`"""${lines[0]}`, ...lines.slice(1), '"""'];
13
+ return [...body.map((line) => (line === "" ? "" : ` ${line}`)), ""];
14
+ };
15
+ /** The TypedDict `name` over `keys`: the class form when every key is spellable, else the functional form. */
16
+ export function dictDecl(name, keys, shape = {}) {
17
+ if (keys.every(({ key }) => spellable(key))) {
18
+ const body = keys.length > 0 ? keys.map(({ key, type }) => ` ${key}: ${type}`) : [" pass"];
19
+ return [`class ${name}(${(shape.bases ?? ["TypedDict"]).join(", ")}):`, ...docLines(shape.doc), ...body].join("\n");
20
+ }
21
+ const entries = keys.map(({ key, type }) => `${pyString(key)}: ${pyString(type)}`).join(", ");
22
+ const doc = shape.doc === undefined ? [] : lineComment(shape.doc, "#");
23
+ return [...doc, `${name} = TypedDict(`, ` ${pyString(name)},`, ` {${entries}},`, ")"].join("\n");
24
+ }
25
+ const byKey = (a, b) => compareCodeUnits(a.name, b.name);
26
+ /** `fields` as keys: a required one bare, an optional one `NotRequired[T]`; `optional` when it reads that. */
27
+ export function keysOf(fields, member, optional) {
28
+ return [...fields].sort(byKey).map((field) => {
29
+ const type = member(field.schema, field.name);
30
+ if (field.required)
31
+ return { key: field.name, type };
32
+ optional();
33
+ return { key: field.name, type: `NotRequired[${type}]` };
34
+ });
35
+ }
36
+ /** The fields of `parts`' inline objects, a repeated key once (its first part's). */
37
+ export function mergedFields(parts) {
38
+ return parts
39
+ .flatMap((part) => (part.kind === "object" ? part.fields : []))
40
+ .filter((field, i, all) => all.findIndex((first) => first.name === field.name) === i);
41
+ }
42
+ /** Whether an allOf can be one class: every part a ref to a TypedDict or an inline object. */
43
+ export function dictParts(ir, isDict) {
44
+ return (ir.parts.length > 0 && ir.parts.every((part) => part.kind === "object" || (part.kind === "ref" && isDict(part))));
45
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The module-level names Python types are declared under: one scope that components, hoisted declarations,
3
+ * `<Op>Headers` and the client's resource classes all claim from, clear of every public name the runtime
4
+ * defines (whichever runtime files an SDK ships), of the clients' own names, and of the `typing` and
5
+ * `collections.abc` names the emitted modules import (H52).
6
+ */
7
+ import type { IR } from "../../ir/model.ts";
8
+ import type { PyTypeNames } from "./types.ts";
9
+ /** Names for one schema on its own: each as asked for, refs left unresolved. */
10
+ export declare function plainNames(): PyTypeNames;
11
+ /**
12
+ * Names for the SDK of `ir`: each component claims its class name in code-unit order, as `<Name>Model` when
13
+ * a reserved name owns it; every later declaration claims after them, a hoist key always getting the name it
14
+ * got first.
15
+ */
16
+ export declare function irNames(ir: IR): PyTypeNames;
@@ -0,0 +1,52 @@
1
+ import { irResolver } from "../../ir/schema.js";
2
+ import { compareCodeUnits, NameScope, pyClassName } from "../shared/lang.js";
3
+ import { publicNames, runtimeFiles } from "./transport.js";
4
+ /* the names the emitted modules import or declare beside the runtime's */
5
+ const EMITTED = [
6
+ "SDK",
7
+ "AsyncSDK",
8
+ "ErrorKey",
9
+ "StrEnum",
10
+ "Any",
11
+ "Literal",
12
+ "NotRequired",
13
+ "Required",
14
+ "Self",
15
+ "TypeAlias",
16
+ "TypedDict",
17
+ "AsyncIterable",
18
+ "Iterable",
19
+ "Sequence",
20
+ ];
21
+ /** A name as asked for. */
22
+ const asked = (base) => base;
23
+ /** Names for one schema on its own: each as asked for, refs left unresolved. */
24
+ export function plainNames() {
25
+ return { claim: asked, hoist: (_key, base) => asked(base), ref: pyClassName, resolve: (schema) => schema };
26
+ }
27
+ /**
28
+ * Names for the SDK of `ir`: each component claims its class name in code-unit order, as `<Name>Model` when
29
+ * a reserved name owns it; every later declaration claims after them, a hoist key always getting the name it
30
+ * got first.
31
+ */
32
+ export function irNames(ir) {
33
+ const runtime = Object.values(runtimeFiles({ realtime: true, ws: true })).flatMap(publicNames);
34
+ const scope = new NameScope([...runtime, ...EMITTED]);
35
+ const components = new Map();
36
+ for (const name of Object.keys(ir.schemas).sort(compareCodeUnits)) {
37
+ const base = pyClassName(name);
38
+ components.set(name, scope.claim(scope.has(base) ? `${base}Model` : base));
39
+ }
40
+ const hoisted = new Map();
41
+ return {
42
+ claim: (base) => scope.claim(base),
43
+ hoist: (key, base) => {
44
+ const name = hoisted.get(key) ?? scope.claim(base);
45
+ hoisted.set(key, name);
46
+ return name;
47
+ },
48
+ /* only a declared component is referred to by name (types.ts reads a dangling ref as Any) */
49
+ ref: (name) => components.get(name),
50
+ resolve: irResolver(ir.schemas),
51
+ };
52
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Unions and aliases (Fb6 e, f): a union is its members joined `A | B`, flattened and deduplicated, `None`
3
+ * last; consts and enum values collapse into one `Literal[...]` where the first of them sits; an `Any` member
4
+ * makes the whole union `Any`. An inline object variant hoists as `<Parent><Field>Variant<i>`, or under a
5
+ * discriminator as `<Parent><Field><Const>`. A component that is no TypedDict is a `TypeAlias` of one quoted
6
+ * string, so it needs no declaration order.
7
+ */
8
+ import type { IRDiscriminator, IRSchema } from "../../ir/model.ts";
9
+ type Of<K extends IRSchema["kind"]> = Extract<IRSchema, {
10
+ kind: K;
11
+ }>;
12
+ /** One union member: a `Literal` value, or a type. */
13
+ export type Part = {
14
+ readonly literal: string;
15
+ } | {
16
+ readonly type: string;
17
+ };
18
+ /**
19
+ * An enum or const value as a member: a `Literal` value, or `float` (PEP 586 has no float literals). Never a null: the
20
+ * IR keeps null out of every enum's values (a nullable says it) and reads a null const as unknown.
21
+ */
22
+ export declare function valuePart(value: boolean | number | string): Part;
23
+ /** `parts` as one annotation, and whether it spells `Literal`. */
24
+ export declare function joined(parts: readonly Part[]): {
25
+ readonly text: string;
26
+ readonly literal: boolean;
27
+ };
28
+ /** The name suffix of an inline object variant: its discriminator const, else `Variant<i>`. */
29
+ export declare function variantSuffix(variant: Of<"object">, i: number, discriminator: IRDiscriminator | undefined): string;
30
+ /** `name` declared as an alias of `text`, its description as comment lines above it. */
31
+ export declare function aliasDecl(name: string, text: string, doc?: string): string;
32
+ export {};
@@ -0,0 +1,46 @@
1
+ import { lineComment, pyString } from "../shared/escape.js";
2
+ import { pascalWords } from "../shared/lang.js";
3
+ /**
4
+ * An enum or const value as a member: a `Literal` value, or `float` (PEP 586 has no float literals). Never a null: the
5
+ * IR keeps null out of every enum's values (a nullable says it) and reads a null const as unknown.
6
+ */
7
+ export function valuePart(value) {
8
+ if (typeof value === "string")
9
+ return { literal: pyString(value) };
10
+ if (typeof value === "boolean")
11
+ return { literal: value ? "True" : "False" };
12
+ const integral = typeof value === "number" && Number.isInteger(value);
13
+ return integral ? { literal: BigInt(value).toString() } : { type: "float" };
14
+ }
15
+ /* where the Literal goes among a union's types: a string no type is spelled as */
16
+ const LITERAL = "\u0000";
17
+ /** `parts` as one annotation, and whether it spells `Literal`. */
18
+ export function joined(parts) {
19
+ const types = new Set();
20
+ const literals = new Set();
21
+ for (const part of parts) {
22
+ if ("type" in part) {
23
+ types.add(part.type);
24
+ continue;
25
+ }
26
+ if (literals.size === 0)
27
+ types.add(LITERAL);
28
+ literals.add(part.literal);
29
+ }
30
+ if (types.has("Any"))
31
+ return { literal: false, text: "Any" };
32
+ const shown = [...types]
33
+ .filter((type) => type !== "None")
34
+ .map((type) => (type === LITERAL ? `Literal[${[...literals].join(", ")}]` : type));
35
+ return { literal: literals.size > 0, text: [...shown, ...(types.has("None") ? ["None"] : [])].join(" | ") };
36
+ }
37
+ /** The name suffix of an inline object variant: its discriminator const, else `Variant<i>`. */
38
+ export function variantSuffix(variant, i, discriminator) {
39
+ const property = variant.fields.find((field) => field.name === discriminator?.propertyName);
40
+ const value = property?.schema.kind === "const" ? pascalWords(String(property.schema.value)) : "";
41
+ return value === "" ? `Variant${i}` : value;
42
+ }
43
+ /** `name` declared as an alias of `text`, its description as comment lines above it. */
44
+ export function aliasDecl(name, text, doc) {
45
+ return [...(doc === undefined ? [] : lineComment(doc, "#")), `${name}: TypeAlias = ${pyString(text)}`].join("\n");
46
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Python types from the IR alone (H2): the annotation at a use position, a component's declaration, and the
3
+ * declarations both hoist: a TypedDict for every inline object, one per inline union variant (Fb6). Every
4
+ * emitted module has `from __future__ import annotations`, so annotations are never quoted; an alias is one
5
+ * quoted string. Spec text reaches the source only through the shared escape layer.
6
+ */
7
+ import type { IR, IRSchema } from "../../ir/model.ts";
8
+ /** How component and hoisted names are claimed. */
9
+ export type PyTypeNames = {
10
+ /** the class name of the component `name` */
11
+ ref(name: string): string;
12
+ /** a unique module-level name for a hoisted declaration; one key always gets the same name */
13
+ hoist(key: string, base: string): string;
14
+ /** a unique module-level name for any other declaration (`<Op>Headers`, a resource class) */
15
+ claim(base: string): string;
16
+ resolve(schema: IRSchema): IRSchema;
17
+ };
18
+ /**
19
+ * Where a type is being written: its parent and field, the declarations it hoists, the names, and the `typing`
20
+ * names its module imports. `declTyping` takes a hoisted declaration's own names when `typing` is another
21
+ * module's (the client's signatures hoist into the types module).
22
+ */
23
+ export type PyTypeContext = {
24
+ parentName: string;
25
+ fieldName: string;
26
+ decls: Map<string, string>;
27
+ names: PyTypeNames;
28
+ typing: Set<string>;
29
+ declTyping?: Set<string>;
30
+ };
31
+ /** A context over `ir`'s components, or plain names without one. */
32
+ export declare function pyTypeContext(ir?: IR): PyTypeContext;
33
+ /** The Python type of `ir` in use position; what it hoists lands in `at.decls`. */
34
+ export declare function pyTypeOf(ir: IRSchema, at: PyTypeContext): string;
35
+ /** The declaration of `name` (a class name already) for `ir`, `doc` its description. */
36
+ export declare function pyTopLevel(name: string, ir: IRSchema, at: PyTypeContext, doc?: string): string;
@@ -0,0 +1,128 @@
1
+ import { pascalWords, pyClassName } from "../shared/lang.js";
2
+ import { dictDecl, dictParts, keysOf, mergedFields } from "./types-dict.js";
3
+ import { irNames, plainNames } from "./types-names.js";
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) */
6
+ const MAX_DEPTH = 12;
7
+ const SCALARS = {
8
+ boolean: "bool",
9
+ integer: "int",
10
+ null: "None",
11
+ number: "float",
12
+ string: "str",
13
+ };
14
+ /** A context over `ir`'s components, or plain names without one. */
15
+ export function pyTypeContext(ir) {
16
+ const names = ir ? irNames(ir) : plainNames();
17
+ return { decls: new Map(), fieldName: "", names, parentName: "", typing: new Set() };
18
+ }
19
+ /** `ir` declared once as `names.hoist(key, base)` into `at.decls`, its typing names into the declaring module's; its name. */
20
+ function declare(ir, at, key, base) {
21
+ const name = at.names.hoist(key, base);
22
+ if (!at.decls.has(name)) {
23
+ /* claimed before its body: what the body hoists in turn comes after it */
24
+ at.decls.set(name, "");
25
+ at.decls.set(name, pyTopLevel(name, ir, { ...at, typing: at.declTyping }));
26
+ }
27
+ return name;
28
+ }
29
+ /** `ir` hoisted as `<Parent><Field><suffix>`. */
30
+ const hoist = (ir, at, suffix = "") => declare(ir, at, `${at.parentName}.${at.fieldName}${suffix}`, `${pyClassName(at.parentName)}${pascalWords(at.fieldName)}${suffix}`);
31
+ const deeper = (at, fieldName = at.fieldName) => ({ ...at, depth: at.depth + 1, fieldName });
32
+ /** Whether `schema` is declared as a TypedDict: an object with keys or closed, or an allOf of such. */
33
+ function isDict(schema, at, seen = new Set()) {
34
+ const resolved = at.names.resolve(schema);
35
+ if (seen.has(resolved))
36
+ return false;
37
+ seen.add(resolved);
38
+ if (resolved.kind === "object")
39
+ return resolved.fields.length > 0 || resolved.additional === false;
40
+ return resolved.kind === "allOf" && dictParts(resolved, (part) => isDict(part, at, seen));
41
+ }
42
+ function objectUse(ir, at) {
43
+ if (ir.fields.length > 0)
44
+ return hoist(ir, at);
45
+ const value = ir.additional ? use(ir.additional, deeper(at, `${at.fieldName}Value`)) : use({ kind: "unknown" }, at);
46
+ return `dict[str, ${value}]`;
47
+ }
48
+ function tupleUse(ir, at) {
49
+ if (ir.required !== undefined && ir.required < ir.items.length)
50
+ return `list[${use({ kind: "unknown" }, at)}]`;
51
+ const items = ir.items.map((item, i) => use(item, deeper(at, `${at.fieldName}Item${i}`)));
52
+ if (ir.rest === undefined)
53
+ return `tuple[${items.length > 0 ? items.join(", ") : "()"}]`;
54
+ const rest = use(ir.rest, deeper(at, `${at.fieldName}Rest`));
55
+ return items.length > 0 ? `tuple[${items.join(", ")}, *tuple[${rest}, ...]]` : `tuple[${rest}, ...]`;
56
+ }
57
+ /** An allOf of one part is that part; of TypedDict-shaped parts, one hoisted class; anything else is Any. */
58
+ function allOfUse(ir, at) {
59
+ if (ir.parts.length === 1)
60
+ return use(ir.parts[0], at);
61
+ return isDict(ir, at) ? hoist(ir, at) : use({ kind: "unknown" }, at);
62
+ }
63
+ /** The members a schema contributes to a union: its own type, or its variants', consts and enum values. */
64
+ function partsOf(ir, at) {
65
+ if (at.depth > MAX_DEPTH)
66
+ return [{ type: "Any" }];
67
+ if (ir.kind === "const")
68
+ return [valuePart(ir.value)];
69
+ if (ir.kind === "scalar" && ir.enum !== undefined)
70
+ return ir.enum.map(valuePart);
71
+ if (ir.kind === "nullable")
72
+ return [...partsOf(ir.inner, deeper(at)), { type: "None" }];
73
+ if (ir.kind !== "union")
74
+ return [{ type: single(ir, at) }];
75
+ return ir.variants.flatMap((variant, i) => variant.kind === "object" && variant.fields.length > 0
76
+ ? [{ type: hoist(variant, deeper(at), variantSuffix(variant, i, ir.discriminator)) }]
77
+ : partsOf(variant, deeper(at)));
78
+ }
79
+ /** A type that is never a union by itself. */
80
+ function single(ir, at) {
81
+ if (ir.kind === "array")
82
+ return `list[${use(ir.items, deeper(at, `${at.fieldName}Item`))}]`;
83
+ if (ir.kind === "tuple")
84
+ return tupleUse(ir, at);
85
+ if (ir.kind === "object")
86
+ return objectUse(ir, at);
87
+ if (ir.kind === "allOf")
88
+ return allOfUse(ir, deeper(at));
89
+ /* a ref to no component reads as any JSON value: the IR resolves it to unknown */
90
+ if (ir.kind === "ref")
91
+ return at.names.resolve(ir).kind === "unknown" ? "Any" : at.names.ref(ir.name);
92
+ if (ir.kind === "scalar")
93
+ return SCALARS[ir.type];
94
+ return ir.kind === "binary" ? "str" : "Any";
95
+ }
96
+ /** `ir`'s annotation; the `typing` names it spells land in `at.typing`, those of what it hoists in the declaring module's. */
97
+ function use(ir, at) {
98
+ const spelled = new Set();
99
+ const { literal, text } = joined(partsOf(ir, { ...at, typing: spelled }));
100
+ for (const name of text === "Any" ? ["Any"] : [...spelled, ...(literal ? ["Literal"] : [])])
101
+ at.typing.add(name);
102
+ return text;
103
+ }
104
+ /** The Python type of `ir` in use position; what it hoists lands in `at.decls`. */
105
+ export function pyTypeOf(ir, at) {
106
+ return use(ir, { ...at, declTyping: at.declTyping ?? at.typing, depth: 0 });
107
+ }
108
+ /** The keys of the TypedDict `name` declares for `fields`, `NotRequired` noted when one is optional. */
109
+ function dictKeys(name, fields, at) {
110
+ const member = (schema, fieldName) => use(schema, { ...at, declTyping: at.declTyping ?? at.typing, depth: 0, fieldName, parentName: name });
111
+ return keysOf(fields, member, () => at.typing.add("NotRequired"));
112
+ }
113
+ /** The declaration of `name` (a class name already) for `ir`, `doc` its description. */
114
+ export function pyTopLevel(name, ir, at, doc) {
115
+ if (ir.kind === "object" && (ir.fields.length > 0 || ir.additional === false)) {
116
+ at.typing.add("TypedDict");
117
+ return dictDecl(name, dictKeys(name, ir.fields, at), { doc });
118
+ }
119
+ if (ir.kind === "allOf" && ir.parts.length > 1 && isDict(ir, at)) {
120
+ const bases = ir.parts.flatMap((part) => (part.kind === "ref" ? [at.names.ref(part.name)] : []));
121
+ const keys = dictKeys(name, mergedFields(ir.parts), at);
122
+ if (bases.length === 0)
123
+ at.typing.add("TypedDict");
124
+ return dictDecl(name, keys, { bases: bases.length > 0 ? bases : undefined, doc });
125
+ }
126
+ at.typing.add("TypeAlias");
127
+ return aliasDecl(name, pyTypeOf(ir, { ...at, fieldName: "", parentName: name }), doc);
128
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A WebSocket operation's answer (contract 34 §2.0, §2.2): `TypedWebSocket`, opened by awaiting the method and
3
+ * dialed offering `protocols`, its `reconnect_token` sent as one query param only when set and non-empty; a
4
+ * declared `reconnect_token` query param is folded into that field (Fd3).
5
+ */
6
+ import type { PyStream } from "./sdk-answer.ts";
7
+ /** The resume cursor's token, which the WebSocket and realtime methods take. */
8
+ export declare const RECONNECT_TOKEN = "reconnect_token: str | None = None";
9
+ /** The subprotocols a WebSocket or realtime dial offers. */
10
+ export declare const PROTOCOLS = "protocols: Sequence[str] | None = None";
11
+ /** Whether a declared param is the `reconnect_token` query param, the resume channel a socket dial sends. */
12
+ export declare const isReconnectToken: (name: string, where: string) => boolean;
13
+ /** The WebSocket operation's answer, its two fields and its docstring's lines. */
14
+ export declare const wsStream: PyStream;
@@ -0,0 +1,16 @@
1
+ /** The resume cursor's token, which the WebSocket and realtime methods take. */
2
+ export const RECONNECT_TOKEN = "reconnect_token: str | None = None";
3
+ /** The subprotocols a WebSocket or realtime dial offers. */
4
+ export const PROTOCOLS = "protocols: Sequence[str] | None = None";
5
+ /** Whether a declared param is the `reconnect_token` query param, the resume channel a socket dial sends. */
6
+ export const isReconnectToken = (name, where) => where === "query" && name === "reconnect_token";
7
+ /** The WebSocket operation's answer, its two fields and its docstring's lines. */
8
+ export const wsStream = {
9
+ answer: () => ({ returns: "TypedWebSocket", run: "websocket", type: "None" }),
10
+ carries: isReconnectToken,
11
+ doc: [
12
+ 'Opens the socket: a refused handshake raises its status\'s error; options["cancel"], close() or',
13
+ "dropping it ends it.",
14
+ ],
15
+ fields: [PROTOCOLS, RECONNECT_TOKEN],
16
+ };
@@ -0,0 +1,7 @@
1
+ import { type SdkModel } from "../../ir/sdk-model.ts";
2
+ import { type RustTypeContext } from "./types.ts";
3
+ /**
4
+ * `ErrorKey` over every key `model` declares, its variants claimed in code-unit order beside `Other` (a
5
+ * collision gets `…2`), each `<Key>Data` hoisted into `at.decls`; with no key, `Other` alone.
6
+ */
7
+ export declare function rustErrorKeys(model: SdkModel, at: RustTypeContext): string;
@@ -0,0 +1,107 @@
1
+ import { irErrorEnvelope, isJsonMedia } from "../../ir/sdk-model.js";
2
+ import { lineComment, rustString } from "../shared/escape.js";
3
+ import { compareCodeUnits, NameScope, rustTypeIdent } from "../shared/lang.js";
4
+ import { rustTopLevel } from "./types.js";
5
+ /** The keys an error response's envelope names, over every operation's JSON error statuses (the runtime reads JSON only). */
6
+ function envelopeKeys(model) {
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 */
9
+ const { contentType, schema } = op.ir.responses[String(status)];
10
+ if (schema === undefined || !isJsonMedia(contentType))
11
+ return [];
12
+ return irErrorEnvelope(schema, model.resolve)?.keys ?? [];
13
+ }));
14
+ }
15
+ /**
16
+ * Every declared key in code-unit order with its schema: `x-honey-errors`' (the first operation by id to
17
+ * declare the key, so the document's path order never changes it), then an envelope's keys, which carry none.
18
+ */
19
+ function declaredKeys(model) {
20
+ const byId = [...model.ops].sort((a, b) => compareCodeUnits(a.id, b.id));
21
+ const declared = byId.flatMap((op) => Object.entries(op.ir.extensions.errors ?? {}));
22
+ /* reversed, so a key ends on its first declaration */
23
+ const keys = new Map(declared.toReversed().map(([key, { schema }]) => [key, schema]));
24
+ for (const key of envelopeKeys(model))
25
+ if (!keys.has(key))
26
+ keys.set(key, undefined);
27
+ return [...keys].sort(([a], [b]) => compareCodeUnits(a, b));
28
+ }
29
+ /** What a body carrying `key` decodes into: its component, a new `<Key>Data`, or nothing to name (no schema, the envelope). */
30
+ function bodyType(key, schema, model, at) {
31
+ if (schema === undefined)
32
+ return undefined;
33
+ if (schema.kind === "ref")
34
+ return at.names.ref(schema.name);
35
+ if (irErrorEnvelope(schema, model.resolve) !== null)
36
+ return undefined;
37
+ const name = at.names.claim(`${rustTypeIdent(key)}Data`);
38
+ at.decls.set(name, rustTopLevel(name, schema, at));
39
+ return name;
40
+ }
41
+ /** The enum and its `as_str`, a variant per key and `Other` last. */
42
+ function enumLines(keys) {
43
+ const variants = keys.flatMap(({ data, variant, wire }) => {
44
+ const decodes = data === undefined ? "" : `: its body decodes into [\`${data}\`] (\`ApiError::decode_body\`).`;
45
+ return [...lineComment(`\`${wire}\`${decodes}`, "///", " "), ` ${variant},`];
46
+ });
47
+ return [
48
+ "/// The error keys the API declares (G6): `ApiError::key()` reads one; any other key is `Other`.",
49
+ "#[derive(Debug, Clone, PartialEq, Eq, Hash)]",
50
+ "#[non_exhaustive]",
51
+ "pub enum ErrorKey {",
52
+ ...variants,
53
+ " /// a key the API does not declare, as the server sent it",
54
+ " Other(String),",
55
+ "}",
56
+ "",
57
+ "impl ErrorKey {",
58
+ " /// The key as the wire spells it.",
59
+ " pub fn as_str(&self) -> &str {",
60
+ " match self {",
61
+ ...keys.map(({ variant, wire }) => ` ErrorKey::${variant} => ${rustString(wire)},`),
62
+ " ErrorKey::Other(key) => key,",
63
+ " }",
64
+ " }",
65
+ "}",
66
+ ];
67
+ }
68
+ /** `From<&str>`: a declared key's variant, any other `Other`; with no key declared, always `Other`. */
69
+ function fromLines(keys) {
70
+ const parse = keys.length === 0
71
+ ? [" ErrorKey::Other(key.to_owned())"]
72
+ : [
73
+ " match key {",
74
+ ...keys.map(({ variant, wire }) => ` ${rustString(wire)} => ErrorKey::${variant},`),
75
+ " other => ErrorKey::Other(other.to_owned()),",
76
+ " }",
77
+ ];
78
+ return ["impl From<&str> for ErrorKey {", " fn from(key: &str) -> Self {", ...parse, " }", "}"];
79
+ }
80
+ /* Display as the wire spells it, and ApiError::key() over the runtime's raw key */
81
+ const TAIL = [
82
+ "impl std::fmt::Display for ErrorKey {",
83
+ " fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {",
84
+ " f.write_str(self.as_str())",
85
+ " }",
86
+ "}",
87
+ "",
88
+ "impl crate::ApiError {",
89
+ " /// honey's error key in the body: the declared one it names, else `Other`; `None` without one.",
90
+ " pub fn key(&self) -> Option<ErrorKey> {",
91
+ " self.raw_key().map(ErrorKey::from)",
92
+ " }",
93
+ "}",
94
+ ];
95
+ /**
96
+ * `ErrorKey` over every key `model` declares, its variants claimed in code-unit order beside `Other` (a
97
+ * collision gets `…2`), each `<Key>Data` hoisted into `at.decls`; with no key, `Other` alone.
98
+ */
99
+ export function rustErrorKeys(model, at) {
100
+ const variants = new NameScope(["Other"]);
101
+ const keys = declaredKeys(model).map(([wire, schema]) => ({
102
+ data: bodyType(wire, schema, model, at),
103
+ variant: variants.claim(rustTypeIdent(wire)),
104
+ wire,
105
+ }));
106
+ return [...enumLines(keys), "", ...fromLines(keys), "", ...TAIL].join("\n");
107
+ }
@@ -0,0 +1,13 @@
1
+ /** What the API needs from the runtime beyond plain HTTP. */
2
+ export type RustRuntimeFeatures = {
3
+ readonly realtime: boolean;
4
+ readonly ws: boolean;
5
+ };
6
+ /** The runtime `.rs` file names an SDK with `features` ships, in code-unit order. */
7
+ export declare function runtimeFileNames(features: RustRuntimeFeatures): string[];
8
+ /** Whether these features make the crate depend on `tokio-tungstenite` (Fb3). */
9
+ export declare const needsWebSocket: (features: RustRuntimeFeatures) => boolean;
10
+ /** The runtime files an SDK with `features` ships, by file name, read verbatim, and the `Cargo.lock` template. */
11
+ export declare function runtimeFiles(features: RustRuntimeFeatures): Record<string, string>;
12
+ /** The names of a Rust file's top-level public items (column 0), in source order: what the crate root exports. */
13
+ export declare function publicItems(source: string): string[];
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The vendored Rust runtime, as the files a Rust SDK ships (H9/F5): `runtime/rust/*.rs`, read here and
3
+ * nowhere else, emitted verbatim under `src/`, and the `Cargo.lock` template the crate's lock is cut from.
4
+ * The WebSocket file ships for a WebSocket or realtime API and the realtime files for a realtime API, so a
5
+ * plain HTTP SDK carries neither them nor their dependency. The one reader is the F8 mutation target.
6
+ */
7
+ import { readFileSync } from "node:fs";
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 */
10
+ const CORE = [
11
+ "answer",
12
+ "auth",
13
+ "body",
14
+ "call",
15
+ "config",
16
+ "envelope",
17
+ "errors",
18
+ "events",
19
+ "exchange",
20
+ "hooks",
21
+ "invalidation",
22
+ "log",
23
+ "nullable",
24
+ "path",
25
+ "query",
26
+ "redirect",
27
+ "request",
28
+ "result",
29
+ "sse",
30
+ "stale",
31
+ ];
32
+ /* a WebSocket operation; realtime adds the transports on top of it */
33
+ const WS = ["ws"];
34
+ const REALTIME = [
35
+ "realtime",
36
+ "realtime_loop",
37
+ "transport",
38
+ "transport_longpoll",
39
+ "transport_sse",
40
+ "transport_ws",
41
+ ];
42
+ /* the lock template every crate's Cargo.lock is cut from */
43
+ const LOCK = "Cargo.lock";
44
+ /* a top-level public item: `pub struct Name`, `pub fn name`, … at column 0 */
45
+ const PUBLIC_ITEM = /^pub (?:struct|enum|trait|type|fn|const|static) ([A-Za-z_][A-Za-z0-9_]*)/gm;
46
+ /** The runtime `.rs` file names an SDK with `features` ships, in code-unit order. */
47
+ export function runtimeFileNames(features) {
48
+ const names = [...CORE];
49
+ if (needsWebSocket(features))
50
+ names.push(...WS);
51
+ if (features.realtime)
52
+ names.push(...REALTIME);
53
+ return names.map((name) => `${name}.rs`).sort(compareCodeUnits);
54
+ }
55
+ /** Whether these features make the crate depend on `tokio-tungstenite` (Fb3). */
56
+ export const needsWebSocket = (features) => features.ws || features.realtime;
57
+ /** The runtime files an SDK with `features` ships, by file name, read verbatim, and the `Cargo.lock` template. */
58
+ export function runtimeFiles(features) {
59
+ return Object.fromEntries([...runtimeFileNames(features), LOCK].map((name) => [
60
+ name,
61
+ readFileSync(new URL(`../../runtime/rust/${name}`, import.meta.url), "utf8"),
62
+ ]));
63
+ }
64
+ /** The names of a Rust file's top-level public items (column 0), in source order: what the crate root exports. */
65
+ export function publicItems(source) {
66
+ return [...source.matchAll(PUBLIC_ITEM)].map((match) => match[1]);
67
+ }
@@ -0,0 +1 @@
1
+ export { type GeneratedRustSdk, generateRustSdk, type RustSdkOptions, rustCallPlans } from "./sdk.ts";
@@ -0,0 +1 @@
1
+ export { generateRustSdk, rustCallPlans } from "./sdk.js";
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A realtime operation's answer (contract 20 §2.0, §2.3): `ResumableConnection<E>`, `E` the declared event
3
+ * schema's type (`serde_json::Value` for a string or absent one), opened before the call resolves over
4
+ * WebSocket, else SSE, else long-poll. Its Opts carry the resume cursor, the offered subprotocols and the
5
+ * reconnect policy as the `TransportOpts` of their names; a declared param on a resume channel is folded in.
6
+ */
7
+ import type { SdkOp } from "../../ir/sdk-model.ts";
8
+ import type { StreamAnswer } from "./sdk-opts.ts";
9
+ import type { RustTypeContext } from "./types.ts";
10
+ /** The realtime operation `op`'s answer. */
11
+ export declare function realtimeAnswer(op: SdkOp, at: RustTypeContext): StreamAnswer;