@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,79 @@
1
+ import { javaString } from "../shared/escape.js";
2
+ import { camelWords, compareCodeUnits, isJavaReserved, NameScope } from "../shared/lang.js";
3
+ import { typeHeader } from "./layout.js";
4
+ import { JSON_NODE } from "./models-names.js";
5
+ /* every member name a record component collides with: java.lang.Record's and Object's synthesized and final methods */
6
+ export const RECORD_MEMBERS = [
7
+ "clone",
8
+ "equals",
9
+ "finalize",
10
+ "getClass",
11
+ "hashCode",
12
+ "notify",
13
+ "notifyAll",
14
+ "toString",
15
+ "wait",
16
+ ];
17
+ const NON_NULL = { args: ["JsonInclude.Include.NON_NULL"], name: "JsonInclude" };
18
+ const NON_EMPTY = { args: ["JsonInclude.Include.NON_EMPTY"], name: "JsonInclude" };
19
+ /* a required, non-nullable use of these is written primitive */
20
+ const PRIMITIVE = { Boolean: "boolean", Double: "double", Long: "long" };
21
+ /** Whether an object, or any object part of an allOf (refs followed), declares `additionalProperties`. */
22
+ export function isOpen(schema, resolve) {
23
+ if (schema.kind === "object")
24
+ return schema.additional !== undefined && schema.additional !== false;
25
+ return schema.kind === "allOf" && schema.parts.some((part) => isOpen(resolve(part), resolve));
26
+ }
27
+ /** A schema's fields: an object's own, an allOf's merged (each ref followed, a key once, its first part's), else none. */
28
+ export function fieldsOf(schema, resolve) {
29
+ if (schema.kind === "object")
30
+ return schema.fields;
31
+ if (schema.kind !== "allOf")
32
+ return [];
33
+ const fields = schema.parts.flatMap((part) => fieldsOf(resolve(part), resolve));
34
+ return fields.filter((field, i) => fields.findIndex((first) => first.name === field.name) === i);
35
+ }
36
+ /** A component's base name: camelCase, a digit first `_`, nothing `value`. */
37
+ function fieldBase(key) {
38
+ const word = camelWords(key);
39
+ if (word === "")
40
+ return "value";
41
+ return /^[0-9]/.test(word) ? `_${word}` : word;
42
+ }
43
+ /** A component name claimed in `scope`: a keyword or literal is taken before the claim, so it gets `…2`. */
44
+ function claimField(scope, key) {
45
+ const base = fieldBase(key);
46
+ if (isJavaReserved(base))
47
+ scope.reserve(base);
48
+ return scope.claim(base);
49
+ }
50
+ /** One component: `@JsonProperty` with its inclusion rule, then its type as the field's shape decides. */
51
+ function component(field, name, member, at) {
52
+ const type = member(field.schema, field.name);
53
+ const key = { args: [javaString(field.name)], name: "JsonProperty" };
54
+ const nullable = at.names.resolve(field.schema).kind === "nullable";
55
+ if (field.required) {
56
+ const declared = PRIMITIVE[type] !== undefined && !nullable ? PRIMITIVE[type] : type;
57
+ return { annotations: [key], name, type: declared };
58
+ }
59
+ if (type === JSON_NODE)
60
+ return { annotations: [key, NON_NULL], name, type };
61
+ if (nullable)
62
+ return { annotations: [key, NON_EMPTY], name, type: `Opt<${type}>` };
63
+ return { annotations: [key, NON_NULL], name, type };
64
+ }
65
+ /** `public record <name>` of its fields in key order, then any map of the other members. */
66
+ export function recordDecl(name, { fields, open }, member, at) {
67
+ const scope = new NameScope(RECORD_MEMBERS);
68
+ const components = [...fields]
69
+ .sort((a, b) => compareCodeUnits(a.name, b.name))
70
+ .map((field) => component(field, claimField(scope, field.name), member, at));
71
+ if (open) {
72
+ components.push({
73
+ annotations: [{ name: "JsonAnySetter" }, { name: "JsonAnyGetter" }],
74
+ name: scope.claim("extra"),
75
+ type: `Map<String, ${JSON_NODE}>`,
76
+ });
77
+ }
78
+ return typeHeader(0, { components, end: "{}", kind: "record", modifiers: ["public"], name }).join("\n");
79
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Java unions (bit 16 phase b, B2, B4): a union of const strings alone is a string enum. A discriminated oneOf or
3
+ * anyOf is a `sealed interface` with record permits: one wrapper per variant, `<Union><Value>`, holding the variant's
4
+ * type as `@JsonValue`, and `<Union>Unknown` for a payload no variant selects. An inline object variant's payload is
5
+ * `<Union><Value>Body`. The nested `Deserializer` (json.ts) dispatches on the discriminator's value. Every permit and
6
+ * wrapper is `@JsonDeserialize` with no argument; no `@JsonTypeInfo` is ever written.
7
+ */
8
+ import type { IRSchema } from "../../ir/model.ts";
9
+ import type { JavaTypeContext, Member } from "./models.ts";
10
+ type Of<K extends IRSchema["kind"]> = Extract<IRSchema, {
11
+ kind: K;
12
+ }>;
13
+ /** Declares `schema` once under `key` and `base`; its name. */
14
+ export type Declare = (schema: IRSchema, key: string, base: string) => string;
15
+ /** What a union's declaration reaches: the context, its members' types, and the hoist. */
16
+ export type UnionScope = {
17
+ at: JavaTypeContext;
18
+ member: Member;
19
+ declare: Declare;
20
+ };
21
+ /** Whether a variant is a const string: a union of these alone is a string enum. */
22
+ export declare const isLiteral: (variant: IRSchema) => variant is Of<"const"> & {
23
+ value: string;
24
+ };
25
+ /** The declaration of a union `declares`: a string enum of its const strings, or a discriminated interface. */
26
+ export declare function unionDecl(name: string, union: Of<"union">, scope: UnionScope): string;
27
+ export {};
@@ -0,0 +1,86 @@
1
+ import { compareCodeUnits, javaTypeName } from "../shared/lang.js";
2
+ import { deserializerLines } from "./json.js";
3
+ import { classOf, typeHeader } from "./layout.js";
4
+ import { enumValues, stringEnumDecl } from "./models-enum.js";
5
+ import { fieldsOf } from "./models-record.js";
6
+ import { JSON_NODE } from "./models-names.js";
7
+ /** Whether a variant is a const string: a union of these alone is a string enum. */
8
+ export const isLiteral = (variant) => variant.kind === "const" && typeof variant.value === "string";
9
+ /** The values that select `variant`: its mapping keys, else its property's const or enum, else its ref's name. */
10
+ function selectors(variant, { mapping = {}, propertyName }, at) {
11
+ const mapped = Object.keys(mapping).filter((value) => variant.kind === "ref" && mapping[value] === variant.name);
12
+ if (mapped.length > 0)
13
+ return mapped;
14
+ const fields = fieldsOf(at.names.resolve(variant), at.names.resolve);
15
+ const property = fields.find((field) => field.name === propertyName)?.schema;
16
+ if (property?.kind === "const")
17
+ return [String(property.value)];
18
+ if (property?.kind === "scalar")
19
+ return enumValues(property).map(String);
20
+ return variant.kind === "ref" ? [variant.name] : [];
21
+ }
22
+ /** A variant's sort key: its first selecting value, else none (which sorts first). */
23
+ const firstValue = ({ values }) => values[0] ?? "";
24
+ /** The selectable variants in code-unit order of their first value; a value that an earlier variant holds is dropped. */
25
+ function selectedBy(union, at) {
26
+ const seen = new Set();
27
+ return union.variants
28
+ .flatMap((schema, index) => {
29
+ if (schema.kind !== "ref" && schema.kind !== "object")
30
+ return [];
31
+ const values = selectors(schema, union.discriminator, at).filter((value) => !seen.has(value));
32
+ for (const value of values)
33
+ seen.add(value);
34
+ return [{ index, schema, values }];
35
+ })
36
+ .sort((a, b) => compareCodeUnits(firstValue(a), firstValue(b)));
37
+ }
38
+ /** A wrapper record holding its payload as `@JsonValue`, implementing its union. */
39
+ const wrapperText = (wrapper, union, payload) => typeHeader(0, {
40
+ annotations: [{ name: "JsonDeserialize" }],
41
+ components: [{ annotations: [{ name: "JsonValue" }], name: "value", type: payload }],
42
+ end: "{}",
43
+ implements: union,
44
+ kind: "record",
45
+ modifiers: ["public"],
46
+ name: wrapper,
47
+ }).join("\n");
48
+ /** Each selectable variant's payload, wrapper and selecting values; the wrappers are declared here. */
49
+ function dispatchOf(name, union, scope) {
50
+ return selectedBy(union, scope.at).map(({ index, schema, values }) => {
51
+ const first = values[0] ?? `Variant${index}`;
52
+ const payload = schema.kind === "ref"
53
+ ? scope.member(schema, first)
54
+ : scope.declare(schema, `${name}.variant${index}`, `${name}${javaTypeName(first)}Body`);
55
+ const wrapper = scope.at.names.hoist(`${name}.wrap${index}`, `${name}${javaTypeName(first)}`);
56
+ scope.at.decls.set(wrapper, wrapperText(wrapper, name, payload));
57
+ return { payload, values, wrapper };
58
+ });
59
+ }
60
+ /** The sealed interface of `union`'s wrappers, its nested Deserializer, then the `<Union>Unknown` wrapper. */
61
+ function discriminatedDecl(name, union, scope) {
62
+ const dispatch = dispatchOf(name, union, scope);
63
+ const unknown = scope.at.names.hoist(`${name}.unknown`, `${name}Unknown`);
64
+ scope.at.decls.set(unknown, wrapperText(unknown, name, JSON_NODE));
65
+ const permits = [...dispatch.map((arm) => arm.wrapper), unknown];
66
+ return [
67
+ ...typeHeader(0, {
68
+ annotations: [{ args: [["using", classOf(`${name}.Deserializer`)]], name: "JsonDeserialize" }],
69
+ end: "{",
70
+ kind: "interface",
71
+ modifiers: ["public", "sealed"],
72
+ name,
73
+ permits,
74
+ }),
75
+ ...deserializerLines(name, union.discriminator.propertyName, dispatch, unknown),
76
+ "}",
77
+ ].join("\n");
78
+ }
79
+ /** The declaration of a union `declares`: a string enum of its const strings, or a discriminated interface. */
80
+ export function unionDecl(name, union, scope) {
81
+ if (union.variants.every(isLiteral)) {
82
+ const values = union.variants.map((variant) => variant.value);
83
+ return stringEnumDecl(name, [...new Set(values)]);
84
+ }
85
+ return discriminatedDecl(name, union, scope);
86
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Java types from the IR alone (bit 16 phase b, B2, B3, B4): the type at a use position, a component's top-level
3
+ * declaration, and what both hoist into the context: an enum, a record for every inline object, a union's wrappers. A
4
+ * use position is a reference type, since generics take one; a component that declares nothing is its use type. A
5
+ * type name is reserved where it collides (models-names.ts).
6
+ */
7
+ import type { IR, IRSchema } from "../../ir/model.ts";
8
+ import { type JavaTypeNames } from "./models-names.ts";
9
+ export type { JavaTypeNames } from "./models-names.ts";
10
+ /** Where a type is being written, the declarations it hoists, and the names. */
11
+ export type JavaTypeContext = {
12
+ parentName: string;
13
+ fieldName: string;
14
+ /** the path from the parent's field to here, `[]` per array item, so no two inline objects share a key */
15
+ path: string;
16
+ decls: Map<string, string>;
17
+ names: JavaTypeNames;
18
+ };
19
+ /** The Java type of `schema` at the member `fieldName` of the declaration being written. */
20
+ export type Member = (schema: IRSchema, fieldName: string) => string;
21
+ /** A context over `ir`'s components, with `taken` reserved besides (the client's and the runtime's own names). */
22
+ export declare function javaTypeContext(ir: IR, taken?: readonly string[]): JavaTypeContext;
23
+ /** Whether Java declares a type for a component of `ir`: an enum, a record, a discriminated or const-string union. */
24
+ export declare function declares(ir: IRSchema): boolean;
25
+ /** The Java type of `ir` at a use position of `at`. */
26
+ export declare function javaTypeOf(ir: IRSchema, at: JavaTypeContext): string;
27
+ /** The top-level declaration of the type `name` (a Java name already) for `ir`, which `declares`. */
28
+ export declare function javaTopLevel(name: string, ir: IRSchema, ctx: JavaTypeContext): string;
@@ -0,0 +1,118 @@
1
+ import { pascalWords, javaTypeName } from "../shared/lang.js";
2
+ import { enumDecl, enumValues } from "./models-enum.js";
3
+ import { fieldsOf, isOpen, recordDecl } from "./models-record.js";
4
+ import { javaNames, JSON_NODE } from "./models-names.js";
5
+ import { isLiteral, unionDecl } from "./models-union.js";
6
+ /* deeper than this, a schema is any JSON value */
7
+ const MAX_DEPTH = 12;
8
+ const SCALARS = {
9
+ boolean: "Boolean",
10
+ integer: "Long",
11
+ null: JSON_NODE,
12
+ number: "Double",
13
+ string: "String",
14
+ };
15
+ /** A context over `ir`'s components, with `taken` reserved besides (the client's and the runtime's own names). */
16
+ export function javaTypeContext(ir, taken = []) {
17
+ return { decls: new Map(), fieldName: "", names: javaNames(ir.schemas, taken, declares), parentName: "", path: "" };
18
+ }
19
+ /** Whether Java declares a type for a component of `ir`: an enum, a record, a discriminated or const-string union. */
20
+ export function declares(ir) {
21
+ if (ir.kind === "scalar")
22
+ return enumValues(ir).length > 0;
23
+ if (ir.kind === "object")
24
+ return ir.fields.length > 0 || ir.additional === false;
25
+ if (ir.kind === "allOf")
26
+ return ir.parts.length > 0 && ir.parts.every((p) => p.kind === "object" || p.kind === "ref");
27
+ if (ir.kind !== "union" || ir.variants.length === 0)
28
+ return false;
29
+ return ir.discriminator !== undefined || ir.variants.every(isLiteral);
30
+ }
31
+ /** `ir` declared once as `names.hoist(key, base)` into `at.decls`; its name. */
32
+ function declare(ir, at, key, base) {
33
+ const name = at.names.hoist(key, base);
34
+ if (!at.decls.has(name)) {
35
+ /* claimed before its body: what the body hoists in turn comes after it */
36
+ at.decls.set(name, "");
37
+ at.decls.set(name, javaTopLevel(name, ir, at));
38
+ }
39
+ return name;
40
+ }
41
+ /** `ir` hoisted as `<Parent><Field>`. */
42
+ const hoist = (ir, at) => declare(ir, at, `${at.parentName}.${at.path}${at.fieldName}`, `${javaTypeName(at.parentName)}${pascalWords(at.fieldName)}`);
43
+ const deeper = (at, fieldName = at.fieldName, path = "") => ({
44
+ ...at,
45
+ depth: at.depth + 1,
46
+ fieldName,
47
+ path: at.path + path,
48
+ });
49
+ /** A const's Java type: its value's, a declared `number` making an integral value double. */
50
+ function constType({ type, value }) {
51
+ if (typeof value === "number")
52
+ return type === "number" || !Number.isInteger(value) ? "Double" : "Long";
53
+ return typeof value === "boolean" ? "Boolean" : "String";
54
+ }
55
+ /** An object's use: a hoisted record when it has fields, a map of its additional values, else a map of any value. */
56
+ function objectUse(ir, at) {
57
+ if (ir.fields.length > 0)
58
+ return hoist(ir, at);
59
+ if (ir.additional)
60
+ return `Map<String, ${use(ir.additional, deeper(at))}>`;
61
+ return ir.additional === false ? JSON_NODE : `Map<String, ${JSON_NODE}>`;
62
+ }
63
+ /** An allOf of one part is that part; of more, its first ref (the rest is not typed here), else any JSON value. */
64
+ function allOfUse(ir, at) {
65
+ const part = ir.parts.length === 1 ? ir.parts[0] : ir.parts.find((p) => p.kind === "ref");
66
+ return part === undefined ? JSON_NODE : use(part, at);
67
+ }
68
+ /** A declared component's name, or the use type of one that declares nothing. */
69
+ function refUse(ir, at) {
70
+ const aliased = at.names.alias(ir.name);
71
+ return aliased === undefined ? at.names.ref(ir.name) : use(aliased, deeper(at));
72
+ }
73
+ /** The Java type of `ir` in use position; what it hoists lands in `at.decls`. */
74
+ function use(ir, at) {
75
+ if (at.depth > MAX_DEPTH)
76
+ return JSON_NODE;
77
+ switch (ir.kind) {
78
+ case "allOf":
79
+ return allOfUse(ir, at);
80
+ case "array":
81
+ return `List<${use(ir.items, deeper(at, `${at.fieldName}Item`, "[]"))}>`;
82
+ case "binary":
83
+ return "String";
84
+ case "const":
85
+ return constType(ir);
86
+ case "nullable":
87
+ return use(ir.inner, deeper(at));
88
+ case "object":
89
+ return objectUse(ir, at);
90
+ case "ref":
91
+ return refUse(ir, at);
92
+ case "scalar":
93
+ return enumValues(ir).length > 0 ? hoist(ir, at) : SCALARS[ir.type];
94
+ case "tuple":
95
+ return `List<${JSON_NODE}>`;
96
+ /* a union in use position is any JSON value; a component union is declared */
97
+ case "union":
98
+ case "unknown":
99
+ return JSON_NODE;
100
+ }
101
+ }
102
+ /** The Java type of `ir` at a use position of `at`. */
103
+ export function javaTypeOf(ir, at) {
104
+ return use(ir, { ...at, depth: 0, path: "" });
105
+ }
106
+ /** The top-level declaration of the type `name` (a Java name already) for `ir`, which `declares`. */
107
+ export function javaTopLevel(name, ir, ctx) {
108
+ const member = (schema, fieldName) => javaTypeOf(schema, { ...ctx, fieldName, parentName: name });
109
+ if (ir.kind === "scalar")
110
+ return enumDecl(name, ir);
111
+ const open = isOpen(ir, ctx.names.resolve);
112
+ if (ir.kind === "object")
113
+ return recordDecl(name, { fields: ir.fields, open }, member, ctx);
114
+ if (ir.kind === "allOf")
115
+ return recordDecl(name, { fields: fieldsOf(ir, ctx.names.resolve), open }, member, ctx);
116
+ const declareVariant = (schema, key, base) => declare(schema, ctx, key, base);
117
+ return unionDecl(name, ir, { at: ctx, declare: declareVariant, member });
118
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * A realtime operation's method (bit 16 phase d2b, R1/R8; C#'s `realtime.ts`, Fd6/Fd7): `ResumableConnection<T>`, `T`
3
+ * the declared event schema's type, else `JsonNode`, connected through `Realtime.open` over WebSocket, else SSE, else
4
+ * long-poll before the method returns. Its five fields are `TransportOptions.of`'s: the resume cursor (`lastEventId`,
5
+ * `reconnectToken`), the offered `protocols` and the reconnect policy (`maxReconnectAttempts`, `reconnectDelay`). The
6
+ * runtime puts the cursor on each dial, so none of them is a Call arg; a declared `last_event_id` or `reconnect_token`
7
+ * query, or a Last-Event-ID header, folds in, and a param spelled like a field claims `…2`. A realtime method is the
8
+ * same text in either mode: it answers no Result.
9
+ */
10
+ import type { SdkOp } from "../../ir/sdk-model.ts";
11
+ import { type JavaTypeContext } from "./models.ts";
12
+ /** The reconnect policy's Params fields. */
13
+ export declare const MAX_RECONNECT_ATTEMPTS = "maxReconnectAttempts";
14
+ export declare const RECONNECT_DELAY = "reconnectDelay";
15
+ /** A realtime op's own fields in `TransportOptions.of`'s order, each with its Java type. */
16
+ export declare const REALTIME_FIELDS: readonly [{
17
+ readonly field: "lastEventId";
18
+ readonly type: "String";
19
+ }, {
20
+ readonly field: "reconnectToken";
21
+ readonly type: "String";
22
+ }, {
23
+ readonly field: "protocols";
24
+ readonly type: "List<String>";
25
+ }, {
26
+ readonly field: "maxReconnectAttempts";
27
+ readonly type: "java.lang.Integer";
28
+ }, {
29
+ readonly field: "reconnectDelay";
30
+ readonly type: "Duration";
31
+ }];
32
+ /** Whether a declared param is on a realtime resume channel the cursor fields carry (C#'s `carries`). */
33
+ export declare const carriesRealtime: (name: string, where: "query" | "header") => boolean;
34
+ /**
35
+ * The realtime runtime's files: the connection, its loop and options, the transport contract and the three default
36
+ * adapters; only an SDK with a realtime operation ships them (with the WebSocket files, which its WebSocket adapter dials
37
+ * through).
38
+ */
39
+ export declare const REALTIME_FILES: string[];
40
+ /** The type a realtime op's messages decode to: the declared event schema's, else `JsonNode`. */
41
+ export declare const messageTypeOf: (op: SdkOp, ctx: JavaTypeContext) => string;
42
+ /** What a realtime method's lines need: its name and constant, its Params, and its Call's lines. */
43
+ export type RealtimeSite = {
44
+ readonly name: string;
45
+ readonly constant: string;
46
+ readonly params: string;
47
+ readonly call: readonly string[];
48
+ };
49
+ /** A realtime method's lines: `op(params)`, delegating to `op(params, options)`, which connects. */
50
+ export declare function realtimeMethodLines(op: SdkOp, site: RealtimeSite, ctx: JavaTypeContext): string[];
@@ -0,0 +1,69 @@
1
+ import { javaTypeOf } from "./models.js";
2
+ import { call as callOf, local, methodHeader, param, newOf, returnStmt, statement } from "./layout.js";
3
+ import { docOf } from "./sdk-decl.js";
4
+ import { CURSOR, isLastEventIdHeader } from "./sse.js";
5
+ import { isReconnectTokenQuery, PROTOCOLS, TOKEN } from "./ws.js";
6
+ /** The reconnect policy's Params fields. */
7
+ export const MAX_RECONNECT_ATTEMPTS = "maxReconnectAttempts";
8
+ export const RECONNECT_DELAY = "reconnectDelay";
9
+ /** A realtime op's own fields in `TransportOptions.of`'s order, each with its Java type. */
10
+ export const REALTIME_FIELDS = [
11
+ { field: CURSOR, type: "String" },
12
+ { field: TOKEN, type: "String" },
13
+ { field: PROTOCOLS, type: "List<String>" },
14
+ { field: MAX_RECONNECT_ATTEMPTS, type: "java.lang.Integer" },
15
+ { field: RECONNECT_DELAY, type: "Duration" },
16
+ ];
17
+ /** Whether a declared param is on a realtime resume channel the cursor fields carry (C#'s `carries`). */
18
+ export const carriesRealtime = (name, where) => where === "query" ? isReconnectTokenQuery(name) || name === "last_event_id" : isLastEventIdHeader(name);
19
+ /**
20
+ * The realtime runtime's files: the connection, its loop and options, the transport contract and the three default
21
+ * adapters; only an SDK with a realtime operation ships them (with the WebSocket files, which its WebSocket adapter dials
22
+ * through).
23
+ */
24
+ export const REALTIME_FILES = [
25
+ "ConnectionState",
26
+ "LongPollAdapter",
27
+ "Realtime",
28
+ "RealtimeLoop",
29
+ "ResumableConnection",
30
+ "SseAdapter",
31
+ "TransportAdapter",
32
+ "TransportConnection",
33
+ "TransportKind",
34
+ "TransportMessage",
35
+ "TransportOptions",
36
+ "WsAdapter",
37
+ ];
38
+ /** The type a realtime op's messages decode to: the declared event schema's, else `JsonNode`. */
39
+ export const messageTypeOf = (op, ctx) => op.events === undefined ? "JsonNode" : javaTypeOf(op.events, { ...ctx, fieldName: "Event", parentName: op.id });
40
+ /** A realtime method's lines: `op(params)`, delegating to `op(params, options)`, which connects. */
41
+ export function realtimeMethodLines(op, site, ctx) {
42
+ const { call, constant, name, params } = site;
43
+ const type = messageTypeOf(op, ctx);
44
+ const doc = docOf(`${op.id}: the connection over WebSocket, else SSE, else long-poll. It reconnects after a drop and resumes after the last message it delivered; close() ends it.`);
45
+ const signature = (args) => methodHeader(2, { modifiers: ["public"], name, params: args, returns: `ResumableConnection<${type}>` });
46
+ const transport = callOf("TransportOptions", "of", REALTIME_FIELDS.map((f) => callOf("params", f.field)));
47
+ const open = callOf("Realtime", "open", [
48
+ "exchange",
49
+ constant,
50
+ "call",
51
+ "options",
52
+ "transport",
53
+ newOf(`TypeReference<${type}>`, [], true),
54
+ ]);
55
+ return [
56
+ doc,
57
+ ...signature([param(params, "params")]),
58
+ ...statement(4, returnStmt(callOf(null, name, ["params", "null"]))),
59
+ " }",
60
+ "",
61
+ doc,
62
+ ...signature([param(params, "params"), param("RequestOptions", "options")]),
63
+ ...call,
64
+ ...statement(4, local({ init: transport, name: "transport", type: "TransportOptions" })),
65
+ ...statement(4, returnStmt(open)),
66
+ " }",
67
+ "",
68
+ ];
69
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The Java SDK's call surface (bit 16 phase c1, C3): the client with its builder, one `<Resource>` class per namespace of
3
+ * `IR.tree` (`row.list` is `client.row().list(…)`), and an operation with no resource on the client itself. Every method
4
+ * is an overload pair over its `<Op>Params` record and goes through the runtime's `Exchange`. Each operation's plan is
5
+ * written here, with the names the classes use, so the driver walks these and nothing else. The client's `safe()`
6
+ * mirror (bit 21 i6) is sdk-mirror.ts's; at the root a member spelled `safe` is `safe_`, noticed.
7
+ */
8
+ import type { IR, IRNamespace, IROperation } from "../../ir/model.ts";
9
+ import type { SdkOp } from "../../ir/sdk-model.ts";
10
+ import type { JavaTypeContext } from "./models.ts";
11
+ import { type JavaOp, type OpEnv } from "./sdk-op.ts";
12
+ import type { JavaCallPlan } from "./sdk-plan.ts";
13
+ /**
14
+ * What the surface is built from: the operations by id, the client's class, the marker and the package, and the
15
+ * notices the generation reports (a root member renamed for the mirror).
16
+ */
17
+ export type SurfaceEnv = OpEnv & {
18
+ readonly ops: ReadonlyMap<string, SdkOp>;
19
+ readonly client: string;
20
+ readonly marker: string;
21
+ readonly packageName: string;
22
+ readonly notices: string[];
23
+ };
24
+ /** A namespace of the tree: its path, its children by segment, its operations by segment. */
25
+ export type Node = {
26
+ readonly path: readonly string[];
27
+ readonly children: readonly {
28
+ readonly segment: string;
29
+ readonly node: Node;
30
+ }[];
31
+ readonly methods: readonly {
32
+ readonly segment: string;
33
+ readonly op: IROperation;
34
+ }[];
35
+ };
36
+ /**
37
+ * The resource class of `path`: its words in PascalCase, then `Resource`, claimed from the model scope after the
38
+ * components (C#'s order), so a component spelled the same keeps its name and this one is `…2`; one path, one name.
39
+ */
40
+ export declare const resourceName: (path: readonly string[], ctx: JavaTypeContext) => string;
41
+ export declare function nodeOf(ns: IRNamespace, path: readonly string[]): Node;
42
+ /**
43
+ * A node's members, claimed in one scope: each child's accessor name, each operation's method name. At the root the
44
+ * mirror's `safe` is held, so a member spelled `safe` is `safe_` instead, and noticed (shared/mirror.ts's one rule).
45
+ */
46
+ export declare function membersOf(node: Node, env: SurfaceEnv): {
47
+ children: {
48
+ child: Node;
49
+ name: string;
50
+ }[];
51
+ ops: {
52
+ name: string;
53
+ op: JavaOp;
54
+ }[];
55
+ };
56
+ /** A list of blocks, each set apart by one blank line; a block's own trailing blank lines are dropped. */
57
+ export declare const blocks: (parts: readonly (readonly string[])[]) => string[];
58
+ /** The client: its constructor, its root resources, its safe mirror, its ungrouped operations, and its builder. */
59
+ export declare function clientLines(ir: IR, root: Node, env: SurfaceEnv, mirror: string): string[];
60
+ /** A file's text: the marker, the package, the imports its code spells, then its lines. */
61
+ export declare function recordSource(lines: readonly string[], env: SurfaceEnv): string;
62
+ /** Every resource and record file of the call surface, and every operation's call plan, for `ir`. */
63
+ export declare function surfaceOf(ir: IR, env: SurfaceEnv): {
64
+ files: Record<string, string>;
65
+ plans: JavaCallPlan[];
66
+ };