@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,113 @@
1
+ /**
2
+ * The SDK's public source-generated `JsonSerializerContext` (§4.6): writing skips null, reading honors the nullable
3
+ * annotations and the required members (Fb5) and skips unknown members. It lists every type the SDK reads or
4
+ * writes, each under an explicit `TypeInfoPropertyName` claimed in the context's own scope, so the emitter never
5
+ * predicts the generator's names, and closes each list and map of a non-nullable reference type with the
6
+ * runtime's strict converter, unless some use of that runtime type gives it nullable items (Fb6's rule: nullable
7
+ * annotations are erased at run time, so such a type stays lenient everywhere).
8
+ */
9
+ import { compareCodeUnits, NameScope } from "../shared/lang.js";
10
+ /* the value types emitted text spells, besides the declared enums: `T?` of one is `Nullable<T>` at run time */
11
+ const VALUE_TYPES = ["bool", "double", "JsonElement", "long"];
12
+ /* the names the generator gives the BCL types it lists, which the context's own names follow */
13
+ const BCL_NAMES = {
14
+ bool: "Boolean",
15
+ double: "Double",
16
+ JsonElement: "JsonElement",
17
+ long: "Int64",
18
+ string: "String",
19
+ };
20
+ const LIST = /^IReadOnlyList<(.*)>$/;
21
+ const MAP = /^IReadOnlyDictionary<string, (.*)>$/;
22
+ /* the context's own members and the members every class has: no TypeInfoPropertyName may take one */
23
+ const CONTEXT_MEMBERS = [
24
+ "Default",
25
+ "Equals",
26
+ "Finalize",
27
+ "GeneratedSerializerOptions",
28
+ "GetHashCode",
29
+ "GetType",
30
+ "GetTypeInfo",
31
+ "MemberwiseClone",
32
+ "Options",
33
+ "ToString",
34
+ ];
35
+ /** The runtime type of a C# type: each nullable reference's `?` dropped at every depth, a nullable value type's kept. */
36
+ export function runtimeOf(enums) {
37
+ const values = new Set([...VALUE_TYPES, ...enums]);
38
+ const runtime = (type) => {
39
+ const bare = type.replace(/\?$/, "");
40
+ const list = LIST.exec(bare)?.[1];
41
+ const map = MAP.exec(bare)?.[1];
42
+ const inner = list === undefined
43
+ ? map === undefined
44
+ ? bare
45
+ : `IReadOnlyDictionary<string, ${runtime(map)}>`
46
+ : `IReadOnlyList<${runtime(list)}>`;
47
+ return values.has(bare) && type.endsWith("?") ? `${inner}?` : inner;
48
+ };
49
+ return runtime;
50
+ }
51
+ /** The name the generator would give a runtime type, which its entry claims. */
52
+ function baseName(type) {
53
+ const list = LIST.exec(type)?.[1];
54
+ const map = MAP.exec(type)?.[1];
55
+ if (type.endsWith("?"))
56
+ return `Nullable${baseName(type.slice(0, -1))}`;
57
+ if (list !== undefined)
58
+ return `${baseName(list)}List`;
59
+ return map === undefined ? (BCL_NAMES[type] ?? type) : `${baseName(map)}Map`;
60
+ }
61
+ /** Each runtime type's `TypeInfoPropertyName`: the declared types first, then the rest by name, each unique. */
62
+ export function typeInfoNames(declared, others, context) {
63
+ const scope = new NameScope([...CONTEXT_MEMBERS, context]);
64
+ const names = new Map();
65
+ const rest = others
66
+ .filter((type) => !declared.includes(type))
67
+ .sort((a, b) => compareCodeUnits(baseName(a), baseName(b)));
68
+ for (const type of [...declared, ...rest])
69
+ if (!names.has(type))
70
+ names.set(type, scope.claim(baseName(type)));
71
+ return names;
72
+ }
73
+ /**
74
+ * The strict converters for `collections` (each as written, item nullability kept): `NonNullList<T>` or
75
+ * `NonNullMap<T>` per runtime collection type of a reference item no use gives `?`, in code-unit order of the text.
76
+ */
77
+ export function strictConverters(collections, runtime) {
78
+ const lenient = new Set();
79
+ const strict = new Set();
80
+ for (const type of collections) {
81
+ const list = LIST.exec(type)?.[1];
82
+ const item = list ?? MAP.exec(type)?.[1];
83
+ const base = runtime(item).replace(/\?$/, "");
84
+ /* a value type keeps its `?` at run time: its null item fails the read already (Q2) */
85
+ if (runtime(`${base}?`).endsWith("?"))
86
+ continue;
87
+ const converter = `typeof(${list === undefined ? "NonNullMap" : "NonNullList"}<${base}>)`;
88
+ (item.endsWith("?") ? lenient : strict).add(converter);
89
+ }
90
+ return [...strict].filter((converter) => !lenient.has(converter)).sort(compareCodeUnits);
91
+ }
92
+ /** The context class `context`: its options, its converters, then one entry per runtime type, sorted by name. */
93
+ export function jsonContext(context, names, converters) {
94
+ const entries = [...names]
95
+ .sort(([, a], [, b]) => compareCodeUnits(a, b))
96
+ .map(([type, name]) => `[JsonSerializable(typeof(${type}), TypeInfoPropertyName = "${name}")]`);
97
+ const options = [
98
+ " DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull",
99
+ " RespectNullableAnnotations = true",
100
+ " RespectRequiredConstructorParameters = true",
101
+ " UnmappedMemberHandling = JsonUnmappedMemberHandling.Skip",
102
+ ...(converters.length > 0 ? [` Converters = [${converters.join(", ")}]`] : []),
103
+ ];
104
+ return [
105
+ "/// <summary>Every type the SDK reads or writes, with source-generated metadata (AOT- and trim-safe).</summary>",
106
+ "[JsonSourceGenerationOptions(",
107
+ `${options.join(",\n")})]`,
108
+ ...entries,
109
+ `public sealed partial class ${context} : JsonSerializerContext`,
110
+ "{",
111
+ "}",
112
+ ].join("\n");
113
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A realtime operation's answer (contract 50 §2, Fd6, Fd7): `Task<ResumableConnection<T>>` through `RealtimeAsync`,
3
+ * `T` the declared event schema's type (`JsonElement` for a string or absent one), opened by awaiting the method over
4
+ * WebSocket, else SSE, else long-poll. Its five fields are `TransportOptions.Of`'s: the resume cursor, the offered
5
+ * subprotocols and the reconnect policy (`TimeSpan? reconnectDelay`). A declared param on a resume channel is folded
6
+ * in, and one named like a field is claimed as `…2` (`sdk-method.ts`).
7
+ */
8
+ import { type CsStream } from "./sdk-answer.ts";
9
+ /** The realtime operation's answer, its five fields and its `<returns>` text. */
10
+ export declare const realtimeStream: CsStream;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A realtime operation's answer (contract 50 §2, Fd6, Fd7): `Task<ResumableConnection<T>>` through `RealtimeAsync`,
3
+ * `T` the declared event schema's type (`JsonElement` for a string or absent one), opened by awaiting the method over
4
+ * WebSocket, else SSE, else long-poll. Its five fields are `TransportOptions.Of`'s: the resume cursor, the offered
5
+ * subprotocols and the reconnect policy (`TimeSpan? reconnectDelay`). A declared param on a resume channel is folded
6
+ * in, and one named like a field is claimed as `…2` (`sdk-method.ts`).
7
+ */
8
+ import { eventType } from "./sdk-answer.js";
9
+ import { isLastEventIdHeader, LAST_EVENT_ID_FIELD } from "./sse.js";
10
+ import { isReconnectToken, PROTOCOLS, RECONNECT_TOKEN } from "./ws.js";
11
+ /** The realtime operation's answer, its five fields and its `<returns>` text. */
12
+ export const realtimeStream = {
13
+ answer: (op, env) => {
14
+ const type = op.events === undefined ? "JsonElement" : eventType(op.events, op, env);
15
+ return {
16
+ render: (spell) => [`Task<ResumableConnection<${spell.runtime(type)}>>`, "RealtimeAsync"],
17
+ type,
18
+ };
19
+ },
20
+ args: ["TransportOptions.Of(lastEventId, reconnectToken, protocols, maxReconnectAttempts, reconnectDelay)"],
21
+ /* the WebSocket and long-poll dials send the cursor as query params, the SSE dial its id as Last-Event-ID */
22
+ carries: (name, where) => isReconnectToken(name, where) ||
23
+ (where === "query" && name === "last_event_id") ||
24
+ isLastEventIdHeader(name, where),
25
+ fields: [
26
+ LAST_EVENT_ID_FIELD,
27
+ RECONNECT_TOKEN,
28
+ PROTOCOLS,
29
+ { ident: "maxReconnectAttempts", type: "int?" },
30
+ { ident: "reconnectDelay", type: "TimeSpan?" },
31
+ ],
32
+ returns: "The connection over WebSocket, else SSE, else long-poll: it reconnects after a drop and resumes after the last message it delivered; the token, CloseAsync or DisposeAsync ends it.",
33
+ };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * What a method answers (§2.1, C#2) and the response headers it can read (Fc7, §2.2). A JSON answer is its schema's
3
+ * type through `CallAsync`/`NullableAsync`, text a `string` through `TextAsync`, bytes a `byte[]` through
4
+ * `BytesAsync`, none a bare `Task` (its `client.Safe` twin a `Result` of each: sdk-method.ts). An
5
+ * operation whose 2xx responses declare headers gets `<Op>Headers`, a class hoisted beside the types (never listed
6
+ * in the JSON context) with one nullable `{ get; private set; }` property per header in code-unit order of its
7
+ * name, typed by the header's scalar (`long?`, `double?`, `bool?`, else `string?`), and an `internal` `Read` the
8
+ * transport calls on a 2xx; a WebSocket or realtime operation, whose 2xx no caller receives, gets none. A
9
+ * stream operation answers as its `CsStream` says (`sse.ts`, `ws.ts`, `realtime.ts`).
10
+ */
11
+ import type { IRSchema } from "../../ir/model.ts";
12
+ import type { SdkOp } from "../../ir/sdk-model.ts";
13
+ import type { MethodEnv, Spelling } from "./sdk-method.ts";
14
+ /** A method's answer: its JSON type (null for any other kind), and its return type and transport method. */
15
+ export type CsAnswer = {
16
+ readonly type: string | null;
17
+ readonly render: (spell: Spelling) => readonly [returns: string, run: string];
18
+ };
19
+ /**
20
+ * What a stream operation's method is (contract 50 §2): whether a declared param is one its own fields carry (the
21
+ * fold), those fields (each `<type> <ident> = null`, after `headersInto`), the arguments its call passes after the
22
+ * `Call`, its answer, and its `<returns>` text.
23
+ */
24
+ export type CsStream = {
25
+ readonly carries: (name: string, where: string) => boolean;
26
+ readonly fields: readonly {
27
+ readonly ident: string;
28
+ readonly type: string;
29
+ }[];
30
+ readonly args: readonly string[];
31
+ answer(op: SdkOp, env: MethodEnv): CsAnswer;
32
+ readonly returns: string;
33
+ };
34
+ /** The C# type of `op`'s declared event schema `events`. */
35
+ export declare const eventType: (events: IRSchema, op: SdkOp, env: MethodEnv) => string;
36
+ /** The `<Op>Headers` holder's type and each declared header (as written) to its property. */
37
+ export type CsHeadersPlan = {
38
+ readonly type: string;
39
+ readonly fields: Readonly<Record<string, string>>;
40
+ };
41
+ /** A signature's spelling of `type`: its runtime type, keeping a nullable reference's `?` at the top. */
42
+ export declare const signatureType: (type: string, spell: Spelling) => string;
43
+ /** The answer of `op`: `T` typed as the signature spells it. */
44
+ export declare function csAnswer(op: SdkOp, env: MethodEnv): CsAnswer;
45
+ /** `<Op>Headers` hoisted into `env.at.decls` (never listed), and its plan; null when `op` declares none. */
46
+ export declare function csResponseHeaders(op: SdkOp, env: MethodEnv): {
47
+ readonly plan: CsHeadersPlan;
48
+ } | null;
@@ -0,0 +1,85 @@
1
+ import { csString } from "../shared/escape.js";
2
+ import { compareCodeUnits, csTypeName, NameScope } from "../shared/lang.js";
3
+ import { docLines } from "./sdk-doc.js";
4
+ import { csTypeOf } from "./types.js";
5
+ const UNKNOWN = { kind: "unknown" };
6
+ /** The C# type of `op`'s declared event schema `events`. */
7
+ export const eventType = (events, op, env) => csTypeOf(events, { ...env.at, fieldName: "Event", parentName: op.id });
8
+ /** How an answer is typed and which transport method reads it, by its kind (`json?` a nullable one). */
9
+ const ANSWERS = {
10
+ binary: () => ["Task<byte[]>", "BytesAsync"],
11
+ json: (t) => [`Task<${t}>`, "CallAsync"],
12
+ "json?": (t) => [`Task<${t}>`, "NullableAsync"],
13
+ none: () => ["Task", "CallAsync"],
14
+ text: () => ["Task<string>", "TextAsync"],
15
+ };
16
+ /** A signature's spelling of `type`: its runtime type, keeping a nullable reference's `?` at the top. */
17
+ export const signatureType = (type, spell) => `${spell.runtime(type).replace(/\?$/, "")}${type.endsWith("?") ? "?" : ""}`;
18
+ /** The answer of `op`: `T` typed as the signature spells it. */
19
+ export function csAnswer(op, env) {
20
+ const json = op.success.kind === "json";
21
+ const type = json
22
+ ? csTypeOf(op.success.schema ?? UNKNOWN, { ...env.at, fieldName: "Response", parentName: op.id })
23
+ : null;
24
+ const kind = type === null ? op.success.kind : `json${type.endsWith("?") ? "?" : ""}`;
25
+ return {
26
+ render: (spell) => ANSWERS[kind](type === null ? "" : signatureType(type, spell)),
27
+ type,
28
+ };
29
+ }
30
+ /** The headers `op`'s 2xx responses declare, statuses ascending, a name's first spelling (any casing) kept; by name. */
31
+ function declaredHeaders(op) {
32
+ if (op.stream === "ws" || op.stream === "realtime")
33
+ return [];
34
+ const all = Object.keys(op.ir.responses)
35
+ .filter((status) => /^2(?:\d\d|XX)$/i.test(status))
36
+ .sort(compareCodeUnits)
37
+ .flatMap((status) => op.ir.responses[status].headers ?? []);
38
+ /* reversed, so the first spelling of a name is the one its key ends on */
39
+ const first = new Map(all.toReversed().map((header) => [header.name.toLowerCase(), header]));
40
+ return [...first.values()].sort((a, b) => compareCodeUnits(a.name, b.name));
41
+ }
42
+ /* a scalar header's C# type and its reader; anything else is its text */
43
+ const READERS = {
44
+ boolean: ["bool?", "Bool"],
45
+ integer: ["long?", "Int64"],
46
+ number: ["double?", "Double"],
47
+ };
48
+ /* the holder's own members and the members every class has */
49
+ const HOLDER_MEMBERS = ["Equals", "Finalize", "GetHashCode", "GetType", "MemberwiseClone", "Read", "ToString"];
50
+ /** `<Op>Headers` hoisted into `env.at.decls` (never listed), and its plan; null when `op` declares none. */
51
+ export function csResponseHeaders(op, env) {
52
+ const headers = declaredHeaders(op);
53
+ if (headers.length === 0)
54
+ return null;
55
+ const type = env.at.names.claim(`${csTypeName(op.id)}Headers`);
56
+ env.at.unlisted.add(type);
57
+ const scope = new NameScope([...HOLDER_MEMBERS, type]);
58
+ const fields = headers.map((header) => {
59
+ const resolved = env.at.names.resolve(header.schema);
60
+ const [cs, reader] = (resolved.kind === "scalar" && READERS[resolved.type]) || ["string?", "Text"];
61
+ return {
62
+ cs,
63
+ header: header.name,
64
+ property: scope.claim(csTypeName(header.name)),
65
+ reader,
66
+ required: header.required,
67
+ };
68
+ });
69
+ env.at.decls.set(type, [
70
+ ...docLines("summary", `The response headers of ${op.id}, set when the call answers 2xx.`),
71
+ `public sealed class ${type}`,
72
+ "{",
73
+ ...fields.flatMap(({ cs, property }, i) => [
74
+ ...(i > 0 ? [""] : []),
75
+ ` public ${cs} ${property} { get; private set; }`,
76
+ ]),
77
+ "",
78
+ " internal void Read(IReadOnlyDictionary<string, string> headers)",
79
+ " {",
80
+ ...fields.map((f) => ` ${f.property} = ResponseHeaders.${f.reader}(headers, ${csString(f.header)}, required: ${f.required === true});`),
81
+ " }",
82
+ "}",
83
+ ].join("\n"));
84
+ return { plan: { fields: Object.fromEntries(fields.map((f) => [f.header, f.property])), type } };
85
+ }
@@ -0,0 +1,10 @@
1
+ import type { SdkOp } from "../../ir/sdk-model.ts";
2
+ import type { MethodEnv, Spelling } from "./sdk-method.ts";
3
+ /** A body as the method takes and sends it: its parameter type (null: none), its expression, the types it lists. */
4
+ export type CsBody = {
5
+ readonly type: string | null;
6
+ readonly expr: (spell: Spelling) => string;
7
+ readonly types: readonly string[];
8
+ };
9
+ /** The body of `op`: its parameter type, its `Body.*` expression, and the types the context lists for it. */
10
+ export declare function csBody(op: SdkOp, env: MethodEnv): CsBody;
@@ -0,0 +1,87 @@
1
+ import { csString } from "../shared/escape.js";
2
+ import { compareCodeUnits, csTypeName, NameScope } from "../shared/lang.js";
3
+ import { docLines } from "./sdk-doc.js";
4
+ import { RECORD_MEMBERS } from "./types-record.js";
5
+ import { csTypeOf } from "./types.js";
6
+ const NONE = { expr: () => "null", type: null, types: [] };
7
+ /** The parts the body schema of `op` requires: none unless it is an object. */
8
+ function requiredParts(op, env) {
9
+ /* a multipart body, with file parts or text parts alone, is declared with its form's schema */
10
+ const form = env.at.names.resolve(op.ir.body.schema);
11
+ return new Set(form.kind === "object" ? form.fields.flatMap((f) => (f.required ? [f.name] : [])) : []);
12
+ }
13
+ /** The C# type of `part` as a property of `parent`: `FilePart` or its list for a file, its schema's type for text. */
14
+ function partType(part, parent, env) {
15
+ /* the IR gives every part its schema (ir/slots.ts partsOf, ir/sdk-model.ts bodyOf) */
16
+ const schema = part.schema;
17
+ if (part.type === "text")
18
+ return csTypeOf(schema, { ...env.at, fieldName: part.name, parentName: parent });
19
+ return env.at.names.resolve(schema).kind === "array" ? "IReadOnlyList<FilePart>" : "FilePart";
20
+ }
21
+ /** `<Op>Body` for `parts`, declared once into `env.at.decls` and never listed; its name and its parts. */
22
+ function multipartBody(op, parts, env) {
23
+ const name = env.at.names.hoist(`${op.id}.Body`, `${csTypeName(op.id)}Body`);
24
+ /* claimed before its parts: what a text part hoists in turn comes after it */
25
+ env.at.decls.set(name, "");
26
+ env.at.unlisted.add(name);
27
+ const required = requiredParts(op, env);
28
+ const scope = new NameScope([...RECORD_MEMBERS, name]);
29
+ const typed = [...parts]
30
+ .sort((a, b) => compareCodeUnits(a.name, b.name))
31
+ .map((part) => {
32
+ const type = partType(part, name, env);
33
+ /* a part left unset is null: a value type's `?` makes it Nullable<T>, which the context lists */
34
+ return {
35
+ file: part.type === "file",
36
+ name: part.name,
37
+ property: scope.claim(csTypeName(part.name)),
38
+ required: required.has(part.name),
39
+ type: required.has(part.name) ? type : `${type.replace(/\?$/, "")}?`,
40
+ };
41
+ });
42
+ const property = ({ property: own, required: must, type }) => `public ${must ? "required " : ""}${type} ${own} { get; init; }`;
43
+ env.at.decls.set(name, [
44
+ ...docLines("summary", `The multipart body of ${op.id}: one part per property.`),
45
+ `public sealed record ${name}`,
46
+ "{",
47
+ ...typed.flatMap((part, i) => [...(i > 0 ? [""] : []), ` ${property(part)}`]),
48
+ "}",
49
+ ].join("\n"));
50
+ return { name, parts: typed };
51
+ }
52
+ /** `Part.File`, `Part.Files` or `Part.Text` for one part of `body`. */
53
+ function partExpr({ file, name, property, type }, spell) {
54
+ if (file)
55
+ return `Part.${type.startsWith("FilePart") ? "File" : "Files"}(${csString(name)}, body.${property})`;
56
+ return `Part.Text(${csString(name)}, body.${property}, ${spell.info(type)})`;
57
+ }
58
+ /** `expr` for a body the method may be called without: null then. */
59
+ const guarded = (op, expr) => (op.body?.required === true ? expr : `body is null ? null : ${expr}`);
60
+ /** The body of `op`: its parameter type, its `Body.*` expression, and the types the context lists for it. */
61
+ export function csBody(op, env) {
62
+ const body = op.body;
63
+ if (body === undefined)
64
+ return NONE;
65
+ const schemaType = (schema) => csTypeOf(schema, { ...env.at, fieldName: "Body", parentName: op.id });
66
+ const media = csString(body.contentType);
67
+ switch (body.kind) {
68
+ case "json": {
69
+ const type = schemaType(body.schema);
70
+ const declared = body.contentType === "application/json" ? "" : `, ${media}`;
71
+ return { expr: (spell) => `Body.Json(body, ${spell.info(type)}${declared})`, type, types: [type] };
72
+ }
73
+ case "form": {
74
+ const type = schemaType(body.schema);
75
+ return { expr: (spell) => `Body.Form(body, ${spell.info(type)})`, type, types: [type] };
76
+ }
77
+ case "text":
78
+ return { expr: () => `Body.Text(body, ${media})`, type: "string", types: [] };
79
+ case "binary":
80
+ return { expr: () => `Body.Binary(body, ${media})`, type: "BinaryBody", types: [] };
81
+ case "multipart": {
82
+ const { name, parts } = multipartBody(op, body.parts, env);
83
+ const expr = (spell) => guarded(op, `Body.Multipart([${parts.map((part) => partExpr(part, spell)).join(", ")}])`);
84
+ return { expr, type: name, types: parts.filter((p) => !p.file).map((p) => p.type) };
85
+ }
86
+ }
87
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Client.cs's classes (§4.4, C#3): the client, then a `<Path>Resource` per namespace of `IR.tree` in code-unit
3
+ * order of its path, each child namespace a read-only property built once in the constructor and each operation an
4
+ * `…Async` method; then their `client.Safe` mirror (bit 21 i5), a `Safe<Client>` and a `Safe<Path>Resource` per
5
+ * class with the same members, each method a twin answering a `Result` through the normal one. A class's members
6
+ * claim names clear of the members every class has, of the names its method bodies spell in an expression and of
7
+ * its own and its twin's name (CS0542), properties before methods; the client's root also keeps `Safe` for the
8
+ * mirror, a root group spelled so emitted as `Safe_` and noticed (shared/mirror.ts). The client owns the transport
9
+ * and disposes it. Nothing here reads spec text but through the escape layer.
10
+ */
11
+ import type { IR } from "../../ir/model.ts";
12
+ import type { SdkOp } from "../../ir/sdk-model.ts";
13
+ import { type MethodEnv, type Spelling } from "./sdk-method.ts";
14
+ import type { CSharpCallPlan } from "./sdk-plan.ts";
15
+ /** The method env, the operations by id, the client's and the JSON context's class names, and the notices. */
16
+ export type ClientEnv = MethodEnv & {
17
+ readonly ops: ReadonlyMap<string, SdkOp>;
18
+ readonly client: string;
19
+ readonly context: string;
20
+ /** what the generation reports: a root group renamed off the mirror */
21
+ readonly notices: string[];
22
+ };
23
+ /**
24
+ * Client.cs's classes for `ir`, once the JSON context can spell each type; the types its methods need listed; and
25
+ * every method's call plan. Resource class names are claimed after every type the methods hoist, their twins' after
26
+ * them.
27
+ */
28
+ export declare function clientDecls(ir: IR, env: ClientEnv): {
29
+ plans: CSharpCallPlan[];
30
+ text: (spell: Spelling) => string;
31
+ types: string[];
32
+ };
@@ -0,0 +1,177 @@
1
+ import { methodsOf, namespacesOf } from "../../ir/resource-tree.js";
2
+ import { csString } from "../shared/escape.js";
3
+ import { csIdentifier, csTypeName, NameScope } from "../shared/lang.js";
4
+ import { mirrorNotice } from "../shared/mirror.js";
5
+ import { docLines } from "./sdk-doc.js";
6
+ import { csMethod } from "./sdk-method.js";
7
+ /* every class's own members, and the names a method body spells in an expression (a property would shadow them) */
8
+ const CLASS_MEMBERS = [
9
+ "Arg",
10
+ "Body",
11
+ "ClientConfig",
12
+ "Dispose",
13
+ "Equals",
14
+ "Finalize",
15
+ "GetHashCode",
16
+ "GetType",
17
+ "MemberwiseClone",
18
+ "Part",
19
+ "ToString",
20
+ "Transport",
21
+ "TransportOptions",
22
+ ];
23
+ /* the client's mirror property, `client.Safe` (shared/mirror.ts's name as C# spells it) */
24
+ const SAFE = "Safe";
25
+ /** A namespace's class name before it is claimed: its path PascalCase, then `Resource`. */
26
+ const baseName = (path) => `${path.map(csTypeName).join("")}Resource`;
27
+ /** A child namespace's property: its segment PascalCase, a root one spelled `Safe` moved to `Safe_`, noticed. */
28
+ function propertyOf(segment, root, members, env) {
29
+ const wanted = csTypeName(segment);
30
+ const property = members.claim(root && wanted === SAFE ? `${SAFE}_` : wanted);
31
+ const notice = root ? mirrorNotice("csharp", SAFE, wanted, property) : null;
32
+ if (notice !== null)
33
+ env.notices.push(notice);
34
+ return property;
35
+ }
36
+ /** `ns` at `path`, its own class named `own`: its children first, so a method never takes a property's name. */
37
+ function resourceOf(ns, path, own, env) {
38
+ const root = path.length === 0;
39
+ const members = new NameScope([...CLASS_MEMBERS, env.context, own, `${SAFE}${own}`, ...(root ? [SAFE] : [])]);
40
+ const fields = new NameScope(["_defaults", "_n", "_t"]);
41
+ const children = namespacesOf(ns).map(([segment, child]) => {
42
+ const property = propertyOf(segment, root, members, env);
43
+ return { node: resourceOf(child, [...path, segment], baseName([...path, segment]), env), property };
44
+ });
45
+ const methods = methodsOf(ns).map(([segment, op]) => csMethod(env.ops.get(op.id), members.claim(`${csTypeName(segment)}Async`), fields.claim(`_${csIdentifier(segment).replace(/^@/, "")}`), env));
46
+ return { children, methods, path };
47
+ }
48
+ /** Every resource below `node`, in code-unit order of its path: children are sorted, so pre-order is path order. */
49
+ const below = (node) => node.children.flatMap(({ node: child }) => [child, ...below(child)]);
50
+ /** Each class's member blocks, a blank line apart. */
51
+ const members = (blocks) => blocks.flatMap((lines, i) => [...(i > 0 ? [""] : []), ...lines]);
52
+ /** A class's own members: its operation fields, the transport field when it has methods, its constructor's body. */
53
+ function body(node, transport, { names, spell }) {
54
+ const owns = node.methods.length > 0;
55
+ return {
56
+ construct: [
57
+ ...(owns && transport === "t" ? [" _t = t;"] : []),
58
+ ...node.children.map(({ node: child, property }) => ` ${property} = new ${names.get(child)}(${transport});`),
59
+ ],
60
+ fields: [...node.methods.map((method) => method.field), ...(owns ? [" private readonly Transport _t;"] : [])],
61
+ methods: node.methods.map((method) => method.lines(spell)),
62
+ properties: node.children.map(({ node: child, property }) => [
63
+ ` public ${names.get(child)} ${property} { get; }`,
64
+ ]),
65
+ };
66
+ }
67
+ /** A resource class: its fields, its internal constructor, its properties, its methods. */
68
+ function resourceClass(node, render) {
69
+ const name = render.names.get(node);
70
+ const own = body(node, "t", render);
71
+ const constructor = [` internal ${name}(Transport t)`, " {", ...own.construct, " }"];
72
+ const blocks = [...(own.fields.length > 0 ? [own.fields] : []), constructor, ...own.properties, ...own.methods];
73
+ return [`public sealed class ${name}`, "{", ...members(blocks), "}"];
74
+ }
75
+ /**
76
+ * `node`'s `client.Safe` twin of the class `normal`: the normal instance it calls (`_n`, when it has methods), each
77
+ * child's twin built from the normal child, and each method's twin (CsMethod.twin).
78
+ */
79
+ function safeClass(node, normal, render) {
80
+ const name = render.safe.get(node);
81
+ const owns = node.methods.length > 0;
82
+ const constructor = [
83
+ ` internal ${name}(${normal} n)`,
84
+ " {",
85
+ ...(owns ? [" _n = n;"] : []),
86
+ ...node.children.map(({ node: child, property }) => ` ${property} = new ${render.safe.get(child)}(n.${property});`),
87
+ " }",
88
+ ];
89
+ const blocks = [
90
+ ...(owns ? [[` private readonly ${normal} _n;`]] : []),
91
+ constructor,
92
+ ...node.children.map(({ node: child, property }) => [` public ${render.safe.get(child)} ${property} { get; }`]),
93
+ ...node.methods.map((method) => method.twin(render.spell)),
94
+ ];
95
+ return [
96
+ `/// <summary><see cref="${normal}"/>'s safe mirror: each method answers a <c>Result</c>, an answer (an error status, a body that does not decode) its Err; no answer still throws.</summary>`,
97
+ `public sealed class ${name}`,
98
+ "{",
99
+ ...members(blocks),
100
+ "}",
101
+ ];
102
+ }
103
+ /** The client class: its docs, its defaults, its fields, its constructor, its properties, its methods, `Dispose`. */
104
+ function clientClass(ir, root, env, render) {
105
+ const own = body(root, "_t", render);
106
+ const mirror = render.safe.get(root);
107
+ const server = ir.servers[0];
108
+ const defaults = [
109
+ server === undefined ? "null" : csString(server),
110
+ csString(ir.auth.headerName),
111
+ csString(ir.auth.prefix),
112
+ `${env.context}.Default.Options`,
113
+ ];
114
+ const title = ir.info.title === undefined ? "The API's client" : `The ${ir.info.title} client`;
115
+ const fields = [
116
+ ` private static readonly Defaults _defaults = new(${defaults.join(", ")});`,
117
+ ...root.methods.map((method) => method.field),
118
+ " private readonly Transport _t;",
119
+ ];
120
+ const constructor = [
121
+ ` public ${env.client}(ClientConfig? config = null)`,
122
+ " {",
123
+ " _t = new Transport(config ?? new ClientConfig(), _defaults);",
124
+ ...own.construct,
125
+ ` ${SAFE} = new ${mirror}(this);`,
126
+ " }",
127
+ ];
128
+ const safe = [
129
+ " /// <summary>This client's methods answering a <c>Result</c>: an answer is its Err, never thrown; no answer still throws.</summary>",
130
+ ` public ${mirror} ${SAFE} { get; }`,
131
+ ];
132
+ return [
133
+ ...docLines("summary", `${title}, generated by honey.`),
134
+ ...docLines("remarks", ir.info.description),
135
+ `public sealed class ${env.client} : IDisposable`,
136
+ "{",
137
+ ...members([
138
+ fields,
139
+ constructor,
140
+ ...own.properties,
141
+ safe,
142
+ ...own.methods,
143
+ [" public void Dispose() => _t.Dispose();"],
144
+ ]),
145
+ "}",
146
+ ];
147
+ }
148
+ /** Every method's call plan below `node`, reached through `accessors`, depth first. */
149
+ const plansIn = (node, accessors) => [
150
+ ...node.methods.map((method) => ({ ...method.plan, accessors })),
151
+ ...node.children.flatMap(({ node: child, property }) => plansIn(child, [...accessors, property])),
152
+ ];
153
+ /**
154
+ * Client.cs's classes for `ir`, once the JSON context can spell each type; the types its methods need listed; and
155
+ * every method's call plan. Resource class names are claimed after every type the methods hoist, their twins' after
156
+ * them.
157
+ */
158
+ export function clientDecls(ir, env) {
159
+ const root = resourceOf(ir.tree, [], env.client, env);
160
+ const nodes = below(root);
161
+ const names = new Map(nodes.map((node) => [node, env.at.names.claim(baseName(node.path))]));
162
+ const all = [root, ...nodes];
163
+ const normalOf = (node) => (node === root ? env.client : names.get(node));
164
+ const safe = new Map(all.map((node) => [node, env.at.names.claim(`${SAFE}${normalOf(node)}`)]));
165
+ return {
166
+ plans: plansIn(root, []),
167
+ text: (spell) => {
168
+ const render = { names, safe, spell };
169
+ return members([
170
+ clientClass(ir, root, env, render),
171
+ ...nodes.map((node) => resourceClass(node, render)),
172
+ ...all.map((node) => safeClass(node, normalOf(node), render)),
173
+ ]).join("\n");
174
+ },
175
+ types: all.flatMap((node) => node.methods.flatMap((method) => method.types)),
176
+ };
177
+ }
@@ -0,0 +1,36 @@
1
+ import { type Shipped } from "../shared/metadata.ts";
2
+ /** The one target framework: the pinned SDK's major (R1). */
3
+ export declare const TARGET_FRAMEWORK = "net10.0";
4
+ /** What nuget.org shows about the package, each part the caller gave, validated. */
5
+ export type CSharpMetadata = {
6
+ readonly description?: string;
7
+ readonly authors?: string;
8
+ readonly license?: string;
9
+ readonly homepage?: string;
10
+ readonly repository?: string;
11
+ readonly copyright?: string;
12
+ /** comma separated, as the CLI gives it */
13
+ readonly tags?: string;
14
+ };
15
+ /** The package's identity, each part validated, its metadata, and the files it ships beside the code. */
16
+ export type CSharpPackage = {
17
+ readonly packageId: string;
18
+ readonly rootNamespace: string;
19
+ readonly version: string;
20
+ readonly metadata?: CSharpMetadata;
21
+ readonly shipped?: Shipped | undefined;
22
+ };
23
+ /** The metadata options, each validated: the description and authors as text, the license as SPDX, the URLs https. */
24
+ export declare function packageMetadata(options: CSharpMetadata): CSharpMetadata;
25
+ /** A NuGet package id: dot- or dash-separated words, at most 100 characters. */
26
+ export declare const validatePackageId: (value: string) => string;
27
+ /** A namespace: dot-separated identifiers, none a keyword or a BCL type the sources spell, not under `System`. */
28
+ export declare function validateRootNamespace(value: string): string;
29
+ /** A client class name: PascalCase. */
30
+ export declare const validateClientName: (value: string) => string;
31
+ /** A SemVer 2 version whose major, minor and patch each fit an assembly version part. */
32
+ export declare function validateVersion(value: string): string;
33
+ /** The `.csproj`: the package id as the assembly name, the metadata given, no package reference (H11). */
34
+ export declare const csproj: ({ metadata, packageId, rootNamespace, shipped, version, }: CSharpPackage) => string;
35
+ /** The root `.editorconfig` the emitted layout is written to and the format gate holds it to (Fb8). */
36
+ export declare const EDITORCONFIG = "# @generated by honey. DO NOT EDIT.\nroot = true\n\n[*.cs]\ncharset = utf-8\nend_of_line = lf\nindent_size = 4\nindent_style = space\ninsert_final_newline = true\n";