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

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 +135 -5
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Go types from the IR (v0 go-type-emitter's IR path): the type at a use position, a component's
3
+ * top-level declaration, and the declarations both hoist into the context — enum types with their
4
+ * constants, and a named struct for every inline object. Spec text reaches the source only through
5
+ * the shared escape layer.
6
+ */
7
+ import type { IR, IRSchema } from "../../ir/model.ts";
8
+ /** Package-level naming shared by every type one SDK declares. */
9
+ export type GoTypeNames = {
10
+ /** the Go type name of the component `schema` */
11
+ ref(schema: string): string;
12
+ /** a unique package-level name for a hoisted declaration; one key always gets the same name */
13
+ hoist(key: string, base: string): string;
14
+ /** a unique package-level name for a constant */
15
+ claimConst(base: string): string;
16
+ /** the components that reach themselves by value: a reference to one is a pointer */
17
+ cyclic: ReadonlySet<string>;
18
+ resolve(schema: IRSchema): IRSchema;
19
+ };
20
+ /** Where a type is used: the field `fieldName` of `parentName`; hoisted declarations land in `decls` by name. */
21
+ export type GoTypeContext = {
22
+ parentName: string;
23
+ fieldName: string;
24
+ decls: Map<string, string>;
25
+ names: GoTypeNames;
26
+ };
27
+ /** A fresh context; with `ir`, its names are claimed against the runtime and the IR's components. */
28
+ export declare function goTypeContext(ir?: IR): GoTypeContext;
29
+ /** The Go type of `ir` at a use position (v0 irRenderUse); what it hoists lands in `at.decls`. */
30
+ export declare function goTypeOf(ir: IRSchema, at: GoTypeContext): string;
31
+ /** The top-level declaration of the type `name` (a Go identifier already) for `ir` (v0 irRenderTopLevel). */
32
+ export declare function goTopLevel(name: string, ir: IRSchema, at: GoTypeContext): string;
@@ -0,0 +1,177 @@
1
+ import { goString } from "../shared/escape.js";
2
+ import { compareCodeUnits, goExported, NameScope } from "../shared/lang.js";
3
+ import { irNames, plainNames } from "./types-names.js";
4
+ import { isNilable } from "./types-codec.js";
5
+ import { isTagName, structDecl } from "./types-struct.js";
6
+ import { unionDecl } from "./types-union.js";
7
+ const RAW = "json.RawMessage";
8
+ /* deeper than this, a schema is raw JSON */
9
+ const MAX_DEPTH = 12;
10
+ const SCALARS = {
11
+ boolean: "bool",
12
+ integer: "int64",
13
+ null: RAW,
14
+ number: "float64",
15
+ string: "string",
16
+ };
17
+ /** A fresh context; with `ir`, its names are claimed against the runtime and the IR's components. */
18
+ export function goTypeContext(ir) {
19
+ return { decls: new Map(), fieldName: "", names: ir ? irNames(ir) : plainNames(), parentName: "" };
20
+ }
21
+ /** `ir` declared once as `names.hoist(key, base)` into `at.decls`; its name. */
22
+ function declare(ir, at, key, base) {
23
+ const name = at.names.hoist(key, base);
24
+ if (!at.decls.has(name)) {
25
+ /* claimed before its body: what the body hoists in turn comes after it */
26
+ at.decls.set(name, "");
27
+ at.decls.set(name, goTopLevel(name, ir, at));
28
+ }
29
+ return name;
30
+ }
31
+ /** `ir` hoisted as `<Parent><Field>`. */
32
+ const hoist = (ir, at) => declare(ir, at, `${at.parentName}.${at.fieldName}`, `${goExported(at.parentName)}${goExported(at.fieldName)}`);
33
+ const deeper = (at, fieldName = at.fieldName) => ({ ...at, depth: at.depth + 1, fieldName });
34
+ /** A slice or map element: it already breaks a cycle, so a ref in it needs no pointer. */
35
+ const element = (item, type) => (item.kind === "ref" && type.startsWith("*") ? type.slice(1) : type);
36
+ function objectUse(ir, at) {
37
+ if (ir.fields.length > 0)
38
+ return hoist(ir, at);
39
+ if (ir.additional)
40
+ return `map[string]${element(ir.additional, use(ir.additional, deeper(at)))}`;
41
+ return ir.additional === false ? "struct{}" : "map[string]interface{}";
42
+ }
43
+ function allOfUse(ir, at) {
44
+ if (ir.parts.length > 1)
45
+ return hoist(ir, at);
46
+ return ir.parts[0] === undefined ? RAW : use(ir.parts[0], at);
47
+ }
48
+ function nullableUse(ir, at) {
49
+ const inner = use(ir.inner, deeper(at));
50
+ return isNilable(inner) ? inner : `*${inner}`;
51
+ }
52
+ function refUse(ir, at) {
53
+ const name = at.names.ref(ir.name);
54
+ return name === at.self || at.names.cyclic.has(ir.name) ? `*${name}` : name;
55
+ }
56
+ /** Whether a scalar is a string or integer enum: a named type with one constant per value. */
57
+ const isEnum = (ir) => ir.enum !== undefined && (ir.type === "string" || ir.type === "integer");
58
+ /** A const's Go type: its value's, a declared `number` making an integral value float64. */
59
+ const constType = ({ type, value }) => {
60
+ if (typeof value === "number")
61
+ return type === "number" || !Number.isInteger(value) ? "float64" : "int64";
62
+ return typeof value === "boolean" ? "bool" : "string";
63
+ };
64
+ const USES = {
65
+ allOf: allOfUse,
66
+ array: (ir, at) => `[]${element(ir.items, use(ir.items, deeper(at, `${at.fieldName}Item`)))}`,
67
+ binary: () => "string",
68
+ const: constType,
69
+ nullable: nullableUse,
70
+ object: objectUse,
71
+ ref: refUse,
72
+ scalar: (ir, at) => (isEnum(ir) ? hoist(ir, at) : SCALARS[ir.type]),
73
+ tuple: (ir) => `[${ir.items.length}]interface{}`,
74
+ /* Go has no union type */
75
+ union: () => RAW,
76
+ unknown: () => RAW,
77
+ };
78
+ function use(ir, at) {
79
+ return at.depth > MAX_DEPTH ? RAW : USES[ir.kind](ir, at);
80
+ }
81
+ /** The Go type of `ir` at a use position (v0 irRenderUse); what it hoists lands in `at.decls`. */
82
+ export function goTypeOf(ir, at) {
83
+ return use(ir, { ...at, depth: 0 });
84
+ }
85
+ /** A label for an enum value inside a constant name: `""` is `Empty`, a negative number `Neg<n>`. */
86
+ function enumLabel(value) {
87
+ if (typeof value === "number")
88
+ return `${value < 0 ? "Neg" : ""}${String(Math.abs(value)).replace(/\W/g, "_")}`;
89
+ return value === "" ? "Empty" : goExported(String(value));
90
+ }
91
+ /** `type <name> string|int` and one `<name><Label>` constant per value of its kind. */
92
+ function enumDecl(name, ir, names) {
93
+ const integer = ir.type === "integer";
94
+ /* a value of the other kind (or a null) has no constant */
95
+ const values = ir.enum.filter((value) => integer ? Number.isInteger(value) : value !== null);
96
+ const labels = new NameScope();
97
+ const consts = values.map((value) => {
98
+ const constName = names.claimConst(labels.claim(`${name}${enumLabel(value)}`));
99
+ return `\t${constName} ${name} = ${integer ? String(value) : goString(String(value))}`;
100
+ });
101
+ return [`type ${name} ${integer ? "int" : "string"}`, "const (", ...consts, ")"].join("\n");
102
+ }
103
+ function constDecl(name, ir, names) {
104
+ const literal = typeof ir.value === "string" ? goString(ir.value) : String(ir.value);
105
+ return [`type ${name} ${constType(ir)}`, `const ${names.claimConst(`${name}Value`)} ${name} = ${literal}`].join("\n");
106
+ }
107
+ const byKey = (a, b) => compareCodeUnits(a.name, b.name);
108
+ /** A struct field for `field`: optional is `*T` omitempty, optional and nullable `Nullable[T]` omitzero. */
109
+ function structField(field, goName, at) {
110
+ const triState = !field.required && field.schema.kind === "nullable";
111
+ const rendered = use(triState ? field.schema.inner : field.schema, at);
112
+ const type = triState ? `Nullable[${rendered}]` : field.required || isNilable(rendered) ? rendered : `*${rendered}`;
113
+ return { goName, key: field.name, required: field.required, tagged: isTagName(field.name), triState, type };
114
+ }
115
+ /** The use position of field `fieldName` in the declaration of `name`. */
116
+ const member = (name, at, fieldName) => ({
117
+ ...at,
118
+ depth: 0,
119
+ fieldName,
120
+ parentName: name,
121
+ self: name,
122
+ });
123
+ /** A struct of the object's fields in key order, and an `Extra` map when it admits more keys. */
124
+ function objectDecl(name, ir, at) {
125
+ const scope = new NameScope(["UnmarshalJSON", "MarshalJSON"]);
126
+ const extraName = ir.additional ? scope.claim("Extra") : "";
127
+ const fields = [...ir.fields]
128
+ .sort(byKey)
129
+ .map((field) => structField(field, scope.claim(goExported(field.name)), member(name, at, field.name)));
130
+ const extra = ir.additional
131
+ ? { goName: extraName, valueType: use(ir.additional, member(name, at, "Extra")) }
132
+ : undefined;
133
+ return structDecl(name, { embeds: [], extra, fields });
134
+ }
135
+ /* the kinds a required field may render as a slice or a map, whose nil a MarshalJSON fills */
136
+ const SLICE_OR_MAP = ["allOf", "array", "nullable", "object"];
137
+ /** A field encoding/json handles alone: a key a tag can name, never a required slice or map. */
138
+ const plainField = (field) => isTagName(field.name) && !(field.required && SLICE_OR_MAP.includes(field.schema.kind));
139
+ /**
140
+ * Whether the type of an allOf's ref part may have its own (un)marshal methods, which embedding
141
+ * would promote over the outer struct's fields. Only a plain object is known not to; a ref the
142
+ * names cannot resolve declares no type here.
143
+ */
144
+ function encodesItself(part, names) {
145
+ const ir = names.resolve(part);
146
+ return ir.kind !== "ref" && !(ir.kind === "object" && !ir.additional && ir.fields.every(plainField));
147
+ }
148
+ /** A struct embedding each ref part, with every object part's fields inlined (a key once, its first part's). */
149
+ function allOfDecl(name, ir, at) {
150
+ const scope = new NameScope(["UnmarshalJSON", "MarshalJSON"]);
151
+ const refs = ir.parts.filter((part) => part.kind === "ref");
152
+ for (const part of refs)
153
+ scope.reserve(at.names.ref(part.name));
154
+ const embeds = refs.map((part) => use(part, member(name, at, part.name)));
155
+ const fields = ir.parts
156
+ .flatMap((part) => (part.kind === "object" ? [...part.fields].sort(byKey) : []))
157
+ .filter((field, i, all) => all.findIndex((first) => first.name === field.name) === i)
158
+ .map((field) => structField(field, scope.claim(goExported(field.name)), member(name, at, field.name)));
159
+ return structDecl(name, { embeds, embedsEncode: refs.some((part) => encodesItself(part, at.names)), fields });
160
+ }
161
+ /** The top-level declaration of the type `name` (a Go identifier already) for `ir` (v0 irRenderTopLevel). */
162
+ export function goTopLevel(name, ir, at) {
163
+ if (ir.kind === "scalar" && isEnum(ir))
164
+ return enumDecl(name, ir, at.names);
165
+ if (ir.kind === "const")
166
+ return constDecl(name, ir, at.names);
167
+ if (ir.kind === "allOf")
168
+ return allOfDecl(name, ir, at);
169
+ if (ir.kind === "object" && ir.fields.length > 0)
170
+ return objectDecl(name, ir, at);
171
+ if (ir.kind === "union" && ir.discriminator) {
172
+ const variant = (schema, key, base) => declare(schema, at, key, base);
173
+ return unionDecl(name, { ...ir, discriminator: ir.discriminator }, at.names, variant);
174
+ }
175
+ /* a map or an empty struct is a named type; anything else an alias */
176
+ return `type ${name} ${ir.kind === "object" ? "" : "= "}${use(ir, member(name, at, "Value"))}`;
177
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A WebSocket or realtime operation as a Go method. A WebSocket operation dials its socket and
3
+ * returns `(*TypedWebSocket, error)`: `<Op>Opts.ReconnectToken` rides as the `reconnect_token`
4
+ * query param after the declared ones, and `Protocols` are the subprotocols it offers. A realtime
5
+ * operation returns `(*ResumableConnection, error)`, already open over the WebSocket, SSE and
6
+ * long-poll chain, its ctx bounding the open (Fd1); its Opts carry the resume cursor, the protocols
7
+ * and the reconnect policy. A declared param on a resume channel the runtime sends itself is carried
8
+ * by those fields, so the wire holds one pair (Fd3). Neither declares a response a caller receives.
9
+ */
10
+ import { type GoStream } from "./sdk-answer.ts";
11
+ /** The method of a WebSocket or realtime operation. */
12
+ export declare const socketStream: (stream: "realtime" | "ws") => GoStream;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * A WebSocket or realtime operation as a Go method. A WebSocket operation dials its socket and
3
+ * returns `(*TypedWebSocket, error)`: `<Op>Opts.ReconnectToken` rides as the `reconnect_token`
4
+ * query param after the declared ones, and `Protocols` are the subprotocols it offers. A realtime
5
+ * operation returns `(*ResumableConnection, error)`, already open over the WebSocket, SSE and
6
+ * long-poll chain, its ctx bounding the open (Fd1); its Opts carry the resume cursor, the protocols
7
+ * and the reconnect policy. A declared param on a resume channel the runtime sends itself is carried
8
+ * by those fields, so the wire holds one pair (Fd3). Neither declares a response a caller receives.
9
+ */
10
+ import { sendArgs } from "./sdk-answer.js";
11
+ import { isLastEventIdHeader } from "./sse.js";
12
+ /** Whether a declared param is the `reconnect_token` query param a WebSocket dial sends. */
13
+ const isReconnectToken = (param, where) => where === "query" && param === "reconnect_token";
14
+ /* both open a socket: a dial fails before any stream exists */
15
+ const FAIL = "nil, err";
16
+ const WS_STREAM = {
17
+ doc: "",
18
+ opts: {
19
+ before: [],
20
+ carries: isReconnectToken,
21
+ fields: [
22
+ { name: "ReconnectToken", type: "string" },
23
+ { name: "Protocols", type: "[]string" },
24
+ ],
25
+ sets: [
26
+ 'if opts.ReconnectToken != "" {',
27
+ '\tc.query.set("reconnect_token", opts.ReconnectToken)',
28
+ "}",
29
+ "c.protocols = opts.Protocols",
30
+ ],
31
+ },
32
+ shape: {
33
+ fail: FAIL,
34
+ returns: "(*TypedWebSocket, error)",
35
+ tail: (client) => [`\treturn dialWebSocket(${sendArgs(client)})`],
36
+ },
37
+ };
38
+ /* the realtime Opts' own fields: each is the TransportOpts field of its name, which `sets` copies */
39
+ const REALTIME_FIELDS = [
40
+ { name: "LastEventID", type: "string" },
41
+ { name: "ReconnectToken", type: "string" },
42
+ { name: "Protocols", type: "[]string" },
43
+ {
44
+ doc: "MaxReconnectAttempts caps reconnects after a drop. Zero means 5; negative means unlimited.",
45
+ name: "MaxReconnectAttempts",
46
+ type: "int",
47
+ },
48
+ { doc: "ReconnectDelayMs is the first backoff delay. Zero means 1000.", name: "ReconnectDelayMs", type: "int" },
49
+ ];
50
+ const REALTIME_STREAM = {
51
+ doc: "The connection is open on return; Close it when done.",
52
+ opts: {
53
+ before: ["var topts TransportOpts"],
54
+ /* the WebSocket and long-poll dials send the cursor as query params, the SSE dial its id as Last-Event-ID */
55
+ carries: (param, where) => isReconnectToken(param, where) ||
56
+ (where === "query" && param === "last_event_id") ||
57
+ isLastEventIdHeader(param, where),
58
+ fields: REALTIME_FIELDS,
59
+ sets: [
60
+ "topts = TransportOpts{LastEventID: opts.LastEventID, ReconnectToken: opts.ReconnectToken, Protocols: opts.Protocols, MaxReconnectAttempts: opts.MaxReconnectAttempts, ReconnectDelayMs: opts.ReconnectDelayMs}",
61
+ ],
62
+ },
63
+ shape: {
64
+ fail: FAIL,
65
+ returns: "(*ResumableConnection, error)",
66
+ tail: (client) => [`\treturn newRealtime(${sendArgs(client, "topts")})`],
67
+ },
68
+ };
69
+ /** The method of a WebSocket or realtime operation. */
70
+ export const socketStream = (stream) => (stream === "ws" ? WS_STREAM : REALTIME_STREAM);
@@ -0,0 +1,57 @@
1
+ /** The package's identity, each part validated. */
2
+ export type JavaPackage = {
3
+ readonly artifactId: string;
4
+ readonly clientName: string;
5
+ readonly groupId: string;
6
+ readonly packageName: string;
7
+ readonly version: string;
8
+ };
9
+ /** The one runtime dependency, its coordinates pinned with the test classpath's (java-pins.json). */
10
+ export declare const JACKSON = "tools.jackson.core:jackson-databind:3.2.4";
11
+ /** A Maven group id: lowercase dotted words. */
12
+ export declare const validateGroupId: (value: string) => string;
13
+ /** A Maven artifact id: lowercase words joined by `-`. */
14
+ export declare const validateArtifactId: (value: string) => string;
15
+ /** A package: dotted lowercase identifiers, none a keyword, not under `java` or `javax`. */
16
+ export declare function validatePackageName(value: string): string;
17
+ /** A client class name: PascalCase, and none of the types its own file spells. */
18
+ export declare const validateClientName: (value: string) => string;
19
+ /** A SemVer 2 version. */
20
+ export declare const validateVersion: (value: string) => string;
21
+ /** What Maven Central requires of a POM beyond its name and description, each part the caller gave, validated. */
22
+ export type JavaPomMetadata = {
23
+ /** the POM's description, over the document's */
24
+ readonly description?: string;
25
+ /** the project's https home page, the POM's `url` */
26
+ readonly homepage?: string;
27
+ /** one SPDX license id */
28
+ readonly license?: string;
29
+ /** the https URL of its git repository, without a trailing `/` or `.git` */
30
+ readonly repository?: string;
31
+ /** the POM's developers, comma separated: each a name, or `Name <email>` */
32
+ readonly developers?: string;
33
+ };
34
+ /** The POM metadata validated: the developers one entry each. */
35
+ type PomFields = Omit<JavaPomMetadata, "developers"> & {
36
+ readonly developers?: readonly string[];
37
+ };
38
+ /** The POM's words: the document's name and description (spec text, written only through `groovyString`), the rest. */
39
+ export type JavaPom = PomFields & {
40
+ readonly name?: string;
41
+ };
42
+ /** The POM for `options` over the document's `info`: the metadata validated, its description over the document's. */
43
+ export declare function pomOf(options: JavaPomMetadata, info: {
44
+ readonly title?: string;
45
+ readonly description?: string;
46
+ }): JavaPom;
47
+ /**
48
+ * The `build.gradle`: the coordinates, `--release 17` under `-Xlint:all -Werror`, Maven Central, Jackson, and the
49
+ * publication Maven Central takes: `maven-publish`'s `mavenJava` from the Java component with its sources and javadoc
50
+ * jars, its POM named and described by the document (the artifact id and the name when it has none), with the URL,
51
+ * license, developer and scm the options give. Javadoc fails on every doclint finding but a missing comment (C#'s doc
52
+ * build waives CS1591 alone); signing is the publisher's.
53
+ */
54
+ export declare const buildGradle: (pkg: JavaPackage, pom: JavaPom) => string;
55
+ /** The `settings.gradle`: the artifact id as the root project's name. */
56
+ export declare const settingsGradle: (pkg: JavaPackage) => string;
57
+ export {};
@@ -0,0 +1,221 @@
1
+ /**
2
+ * The Java package's build and its option rules (bit 16 phase a, D3, D4): a Gradle `java-library` build compiled
3
+ * `--release 17` with `-Xlint:all -Werror`, Maven Central, the one Jackson 3 dependency and the `mavenJava` publication;
4
+ * no toolchain block, since auto-provisioning would fetch, and no wrapper, a binary the consumer's own Gradle 9
5
+ * replaces. Every name the build and the sources spell comes from a validated option, never from spec text; the POM's
6
+ * name and description are the document's words, written only as escaped single-quoted Groovy strings. The rest of
7
+ * what Maven Central requires of a POM (its URL, license, developers and scm) comes from options, each validated and
8
+ * written the same way, and is left out when not given.
9
+ */
10
+ import { escapeText } from "../shared/escape.js";
11
+ import { AUTHOR, authorOf, checked, HTTPS_URL, SPDX_ID, TEXT } from "../shared/metadata.js";
12
+ /** The one runtime dependency, its coordinates pinned with the test classpath's (java-pins.json). */
13
+ export const JACKSON = "tools.jackson.core:jackson-databind:3.2.4";
14
+ /* Java's keywords and literals (JLS 3.9, 3.10.3, 3.10.7): no package segment may be one, and `_` is one since 9 */
15
+ const RESERVED = [
16
+ "abstract",
17
+ "assert",
18
+ "boolean",
19
+ "break",
20
+ "byte",
21
+ "case",
22
+ "catch",
23
+ "char",
24
+ "class",
25
+ "const",
26
+ "continue",
27
+ "default",
28
+ "do",
29
+ "double",
30
+ "else",
31
+ "enum",
32
+ "extends",
33
+ "final",
34
+ "finally",
35
+ "float",
36
+ "for",
37
+ "goto",
38
+ "if",
39
+ "implements",
40
+ "import",
41
+ "instanceof",
42
+ "int",
43
+ "interface",
44
+ "long",
45
+ "native",
46
+ "new",
47
+ "package",
48
+ "private",
49
+ "protected",
50
+ "public",
51
+ "return",
52
+ "short",
53
+ "static",
54
+ "strictfp",
55
+ "super",
56
+ "switch",
57
+ "synchronized",
58
+ "this",
59
+ "throw",
60
+ "throws",
61
+ "transient",
62
+ "try",
63
+ "void",
64
+ "volatile",
65
+ "while",
66
+ "true",
67
+ "false",
68
+ "null",
69
+ "_",
70
+ ];
71
+ /* the type names the client file spells or imports, and its nested Builder: a client of one of these clashes */
72
+ const SPELLED = ["Builder", "IllegalStateException", "String", "Transport", "URI"];
73
+ /* a Maven group: lowercase dotted words; an artifact: lowercase words joined by `-`; a package segment: a lowercase
74
+ * identifier; a client: a PascalCase type */
75
+ const GROUP_ID = /^[a-z][a-z0-9_]*(?:\.[a-z][a-z0-9_]*)*$/;
76
+ const ARTIFACT_ID = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
77
+ const SEGMENT = /^[a-z_][a-z0-9_]*$/;
78
+ const CLIENT_NAME = /^[A-Z][A-Za-z0-9_]*$/;
79
+ /* SemVer 2 (semver.org's recommended pattern), as the C# and Rust packages take it */
80
+ const SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
81
+ const refuse = (option, value) => {
82
+ throw new Error(`Invalid ${option}: ${JSON.stringify(value)}`);
83
+ };
84
+ /** A Maven group id: lowercase dotted words. */
85
+ export const validateGroupId = (value) => (GROUP_ID.test(value) ? value : refuse("groupId", value));
86
+ /** A Maven artifact id: lowercase words joined by `-`. */
87
+ export const validateArtifactId = (value) => ARTIFACT_ID.test(value) ? value : refuse("artifactId", value);
88
+ /** A package: dotted lowercase identifiers, none a keyword, not under `java` or `javax`. */
89
+ export function validatePackageName(value) {
90
+ const segments = value.split(".");
91
+ const valid = segments.every((segment) => SEGMENT.test(segment) && !RESERVED.includes(segment));
92
+ return valid && segments[0] !== "java" && segments[0] !== "javax" ? value : refuse("packageName", value);
93
+ }
94
+ /** A client class name: PascalCase, and none of the types its own file spells. */
95
+ export const validateClientName = (value) => CLIENT_NAME.test(value) && !SPELLED.includes(value) ? value : refuse("clientName", value);
96
+ /** A SemVer 2 version. */
97
+ export const validateVersion = (value) => (SEMVER.test(value) ? value : refuse("version", value));
98
+ /* a repository is a path on its host: `https://host/owner/name` */
99
+ const REPOSITORY_PATH = /^https:\/\/[^/]+\/[^/]/;
100
+ /** The developers option as one author each, or a refusal of the whole value when any is not a name or `Name <email>`. */
101
+ function developersOf(value) {
102
+ const authors = value?.split(",").map((author) => author.trim());
103
+ return authors?.every((author) => AUTHOR.test(author)) === false ? refuse("developers", value) : authors;
104
+ }
105
+ /**
106
+ * The metadata options, each validated; the repository's trailing `/` and `.git` dropped, as the scm block adds `.git`
107
+ * to its connections and shows the rest as its web URL.
108
+ */
109
+ function pomMetadata(options) {
110
+ const repository = checked("repository", options.repository, HTTPS_URL);
111
+ return {
112
+ description: checked("description", options.description, TEXT),
113
+ developers: developersOf(options.developers),
114
+ homepage: checked("homepage", options.homepage, HTTPS_URL),
115
+ license: checked("license", options.license, SPDX_ID),
116
+ repository: checked("repository", repository, REPOSITORY_PATH)
117
+ ?.replace(/\/+$/, "")
118
+ .replace(/\.git$/, ""),
119
+ };
120
+ }
121
+ /** The POM for `options` over the document's `info`: the metadata validated, its description over the document's. */
122
+ export function pomOf(options, info) {
123
+ const metadata = pomMetadata(options);
124
+ return { ...metadata, description: metadata.description ?? info.description, name: info.title };
125
+ }
126
+ /**
127
+ * `text` as a single-quoted Groovy string: Java's escapes (Groovy reads the same ones) and the apostrophe's, so spec
128
+ * text neither interpolates (no `$` in `'…'`) nor ends the string.
129
+ */
130
+ const groovyString = (text) => `'${escapeText(text, "java").replaceAll("'", "\\'")}'`;
131
+ /* the indent of the `pom { … }` block's members, and of one level in */
132
+ const POM = " ";
133
+ const IN = " ";
134
+ /** `key = '…'` lines at `indent`, each value a Groovy string. */
135
+ const assignments = (indent, entries) => entries.map(([key, value]) => `${indent}${key} = ${groovyString(value)}\n`).join("");
136
+ /** A `key { … }` block at `indent` around `body`. */
137
+ const nested = (indent, key, body) => `${indent}${key} {\n${body}${indent}}\n`;
138
+ /** A `key { … }` block one level into the POM, its entries as Groovy strings. */
139
+ const member = (key, entries) => nested(POM + IN, key, assignments(POM + IN + IN, entries));
140
+ /** One author's `developer { … }` block: its name, and its email when it gives one. */
141
+ function developerBlock(author) {
142
+ const { email, name } = authorOf(author);
143
+ return member("developer", [["name", name], ...(email === undefined ? [] : [["email", email]])]);
144
+ }
145
+ /** The POM's url, license, developers and scm lines, each only when its option was given. */
146
+ function pomMetadataLines(pom) {
147
+ const connection = `scm:git:${pom.repository}.git`;
148
+ return [
149
+ pom.homepage === undefined ? "" : assignments(POM, [["url", pom.homepage]]),
150
+ pom.license === undefined
151
+ ? ""
152
+ : nested(POM, "licenses", member("license", [
153
+ ["name", pom.license],
154
+ ["url", `https://spdx.org/licenses/${pom.license}.html`],
155
+ ])),
156
+ pom.developers === undefined ? "" : nested(POM, "developers", pom.developers.map(developerBlock).join("")),
157
+ pom.repository === undefined
158
+ ? ""
159
+ : nested(POM, "scm", assignments(POM + IN, [
160
+ ["url", pom.repository],
161
+ ["connection", connection],
162
+ ["developerConnection", connection],
163
+ ])),
164
+ ].join("");
165
+ }
166
+ /**
167
+ * The `build.gradle`: the coordinates, `--release 17` under `-Xlint:all -Werror`, Maven Central, Jackson, and the
168
+ * publication Maven Central takes: `maven-publish`'s `mavenJava` from the Java component with its sources and javadoc
169
+ * jars, its POM named and described by the document (the artifact id and the name when it has none), with the URL,
170
+ * license, developer and scm the options give. Javadoc fails on every doclint finding but a missing comment (C#'s doc
171
+ * build waives CS1591 alone); signing is the publisher's.
172
+ */
173
+ export const buildGradle = (pkg, pom) => {
174
+ const name = pom.name ?? pkg.artifactId;
175
+ const metadata = pomMetadataLines(pom);
176
+ return `plugins {
177
+ id 'java-library'
178
+ id 'maven-publish'
179
+ }
180
+
181
+ group = '${pkg.groupId}'
182
+ version = '${pkg.version}'
183
+
184
+ java {
185
+ withSourcesJar()
186
+ withJavadocJar()
187
+ }
188
+
189
+ tasks.withType(JavaCompile).configureEach {
190
+ options.release = 17
191
+ options.compilerArgs += ['-Xlint:all', '-Werror']
192
+ }
193
+
194
+ tasks.withType(Javadoc).configureEach {
195
+ options.addBooleanOption('Xdoclint:all,-missing', true)
196
+ options.addBooleanOption('Werror', true)
197
+ }
198
+
199
+ repositories {
200
+ mavenCentral()
201
+ }
202
+
203
+ dependencies {
204
+ api '${JACKSON}'
205
+ }
206
+
207
+ publishing {
208
+ publications {
209
+ mavenJava(MavenPublication) {
210
+ from components.java
211
+ pom {
212
+ name = ${groovyString(name)}
213
+ description = ${groovyString(pom.description ?? name)}
214
+ ${metadata} }
215
+ }
216
+ }
217
+ }
218
+ `;
219
+ };
220
+ /** The `settings.gradle`: the artifact id as the root project's name. */
221
+ export const settingsGradle = (pkg) => `rootProject.name = '${pkg.artifactId}'\n`;
@@ -0,0 +1,2 @@
1
+ /** The Java SDK emitter (bit 16). */
2
+ export { type GeneratedJavaSdk, generateJavaSdk, type JavaSdkOptions } from "./sdk.ts";
@@ -0,0 +1,2 @@
1
+ /** The Java SDK emitter (bit 16). */
2
+ export { generateJavaSdk } from "./sdk.js";
@@ -0,0 +1,13 @@
1
+ /** One dispatch: the values that select a wrapper, the wrapper, and the payload type it reads. */
2
+ export type Dispatch = {
3
+ readonly values: readonly string[];
4
+ readonly wrapper: string;
5
+ readonly payload: string;
6
+ };
7
+ /** A union's nested `Deserializer`, two spaces in: from its `final class` line to its closing brace. */
8
+ export declare function deserializerLines(name: string, property: string, dispatch: readonly Dispatch[], unknown: string): string[];
9
+ /**
10
+ * The members an integer enum adds after its constants: the `long` value, `@JsonValue` and `@JsonCreator fromValue`,
11
+ * which takes only a JSON integer. The caller writes the closing brace.
12
+ */
13
+ export declare function intEnumJsonLines(name: string): string[];