@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,136 @@
1
+ /**
2
+ * The C# package's manifest and format rules (contract 45 §4.3): a net10.0 `.csproj` with nullable on, warnings as
3
+ * errors, the AOT and trim analyzers, and the XML doc file with only CS1591 off (Fb4); a root `.editorconfig`, so
4
+ * no parent file reaches the emitted sources (R6). Every name the manifest and the sources spell comes from a
5
+ * validated option, never from spec text (Fb3). The metadata nuget.org shows (the description, the authors, the SPDX
6
+ * license expression, the project and repository URLs, the copyright and the tags) is written when its option is
7
+ * given, each value validated and then escaped twice: for MSBuild, which would expand a `$(…)` or `@(…)` in it, and
8
+ * for XML. `dotnet pack` writes the symbols beside the package as a `.snupkg`, which nuget.org serves to debuggers
9
+ * (plan 39 8.6).
10
+ */
11
+ import { isCsReserved } from "../shared/lang.js";
12
+ import { checked, HTTPS_URL, LICENSE, README, SPDX_EXPRESSION, TEXT } from "../shared/metadata.js";
13
+ import { BCL, RUNTIME_BCL } from "./types-names.js";
14
+ /** The one target framework: the pinned SDK's major (R1). */
15
+ export const TARGET_FRAMEWORK = "net10.0";
16
+ /* authors: names joined by commas, each with a character other than a space, none with a control character */
17
+ const AUTHORS = /^(?=[^\p{Cc}]{1,4000}$)[^,]*[^,\s][^,]*(?:,[^,]*[^,\s][^,]*)*$/u;
18
+ /* tags: words joined by commas, none holding a space or a `;`, which NuGet splits PackageTags on */
19
+ const TAGS = /^(?=.{1,4000}$)[^\s,;\p{Cc}\p{Cs}]{1,50}(?:,[^\s,;\p{Cc}\p{Cs}]{1,50})*$/u;
20
+ /** The metadata options, each validated: the description and authors as text, the license as SPDX, the URLs https. */
21
+ export function packageMetadata(options) {
22
+ return {
23
+ authors: checked("authors", options.authors, AUTHORS),
24
+ copyright: checked("copyright", options.copyright, TEXT),
25
+ description: checked("description", options.description, TEXT),
26
+ homepage: checked("homepage", options.homepage, HTTPS_URL),
27
+ license: checked("license", options.license, SPDX_EXPRESSION),
28
+ repository: checked("repository", options.repository, HTTPS_URL),
29
+ tags: checked("tags", options.tags, TAGS),
30
+ };
31
+ }
32
+ /* the characters MSBuild expands or splits on in a property, written as its own %XX escapes, which it reads back */
33
+ const MSBUILD_SPECIAL = /[%*?@$();']/g;
34
+ /** `text` as a `.csproj` property value: MSBuild's escapes first, then XML's. */
35
+ const propertyText = (text) => text
36
+ .replace(MSBUILD_SPECIAL, (ch) => `%${ch.charCodeAt(0).toString(16).toUpperCase()}`)
37
+ .replaceAll("&", "&")
38
+ .replaceAll("<", "&lt;")
39
+ .replaceAll(">", "&gt;");
40
+ /** The metadata's property lines, in the order the options name them; none for an option not given. */
41
+ function metadataLines(metadata) {
42
+ const entries = [
43
+ ["Description", metadata?.description],
44
+ ["Authors", metadata?.authors],
45
+ ["Copyright", metadata?.copyright],
46
+ ["PackageLicenseExpression", metadata?.license],
47
+ ["PackageProjectUrl", metadata?.homepage],
48
+ ["RepositoryUrl", metadata?.repository],
49
+ ];
50
+ const lines = entries.flatMap(([element, value]) => value === undefined ? [] : [` <${element}>${propertyText(value)}</${element}>\n`]);
51
+ if (metadata?.repository !== undefined)
52
+ lines.push(" <RepositoryType>git</RepositoryType>\n");
53
+ /* each tag escaped on its own: the `;` between them is the list's, which MSBuild hands to NuGet as written */
54
+ const tags = metadata?.tags?.split(",").map(propertyText).join(";");
55
+ if (tags !== undefined)
56
+ lines.push(` <PackageTags>${tags}</PackageTags>\n`);
57
+ return lines.join("");
58
+ }
59
+ /* NuGet's id rule; a namespace segment is an identifier; a client is a PascalCase type */
60
+ const PACKAGE_ID = /^[A-Za-z0-9_]+(?:[.-][A-Za-z0-9_]+)*$/;
61
+ const SEGMENT = /^[A-Za-z_][A-Za-z0-9_]*$/;
62
+ const CLIENT_NAME = /^[A-Z][A-Za-z0-9_]*$/;
63
+ /* SemVer 2 (semver.org's recommended pattern), as Rust's sdk-cargo.ts takes it */
64
+ 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-]+)*))?$/;
65
+ const refuse = (option, value) => {
66
+ throw new Error(`Invalid ${option}: ${JSON.stringify(value)}`);
67
+ };
68
+ /** A NuGet package id: dot- or dash-separated words, at most 100 characters. */
69
+ export const validatePackageId = (value) => PACKAGE_ID.test(value) && value.length <= 100 ? value : refuse("packageId", value);
70
+ /** A namespace: dot-separated identifiers, none a keyword or a BCL type the sources spell, not under `System`. */
71
+ export function validateRootNamespace(value) {
72
+ const segments = value.split(".");
73
+ /* a segment naming a BCL type the sources spell unqualified turns that spelling into the namespace (CS0118) */
74
+ const bcl = new Set([...Object.values(BCL).flat(), ...RUNTIME_BCL]);
75
+ const valid = segments.every((s) => SEGMENT.test(s) && !isCsReserved(s) && !bcl.has(s));
76
+ return valid && segments[0] !== "System" ? value : refuse("rootNamespace", value);
77
+ }
78
+ /** A client class name: PascalCase. */
79
+ export const validateClientName = (value) => CLIENT_NAME.test(value) ? value : refuse("clientName", value);
80
+ /* MSBuild derives the assembly version from major.minor.patch, each part at most 65534 (CS7034 past it) */
81
+ const ASSEMBLY_PART_MAX = 65534;
82
+ /** A SemVer 2 version whose major, minor and patch each fit an assembly version part. */
83
+ export function validateVersion(value) {
84
+ const parts = SEMVER.exec(value)?.slice(1, 4);
85
+ return parts?.every((part) => Number(part) <= ASSEMBLY_PART_MAX) === true ? value : refuse("version", value);
86
+ }
87
+ /** The README and the icon nuget.org shows, then the items that pack each shipped file at the package's root. */
88
+ function shippedLines(shipped) {
89
+ const icon = shipped?.icon;
90
+ const packed = [
91
+ ...(shipped?.readme ? [README] : []),
92
+ ...(shipped?.licenseFile ? [LICENSE] : []),
93
+ ...(icon === undefined ? [] : [icon]),
94
+ ];
95
+ const properties = [
96
+ ...(shipped?.readme ? [` <PackageReadmeFile>${README}</PackageReadmeFile>\n`] : []),
97
+ ...(icon === undefined ? [] : [` <PackageIcon>${icon}</PackageIcon>\n`]),
98
+ ];
99
+ return {
100
+ items: packed.length === 0
101
+ ? ""
102
+ : ` <ItemGroup>\n${packed.map((file) => ` <None Include="${file}" Pack="true" PackagePath="\\" />\n`).join("")} </ItemGroup>\n`,
103
+ property: properties.join(""),
104
+ };
105
+ }
106
+ /** The `.csproj`: the package id as the assembly name, the metadata given, no package reference (H11). */
107
+ export const csproj = ({ metadata, packageId, rootNamespace, shipped, version, }) => `<!-- @generated by honey. DO NOT EDIT. -->
108
+ <Project Sdk="Microsoft.NET.Sdk">
109
+ <PropertyGroup>
110
+ <TargetFramework>${TARGET_FRAMEWORK}</TargetFramework>
111
+ <AssemblyName>${packageId}</AssemblyName>
112
+ <RootNamespace>${rootNamespace}</RootNamespace>
113
+ <PackageId>${packageId}</PackageId>
114
+ <Version>${version}</Version>
115
+ ${metadataLines(metadata)}${shippedLines(shipped).property} <Nullable>enable</Nullable>
116
+ <ImplicitUsings>disable</ImplicitUsings>
117
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
118
+ <IsAotCompatible>true</IsAotCompatible>
119
+ <GenerateDocumentationFile>true</GenerateDocumentationFile>
120
+ <NoWarn>$(NoWarn);CS1591</NoWarn>
121
+ <IncludeSymbols>true</IncludeSymbols>
122
+ <SymbolPackageFormat>snupkg</SymbolPackageFormat>
123
+ </PropertyGroup>
124
+ ${shippedLines(shipped).items}</Project>
125
+ `;
126
+ /** The root `.editorconfig` the emitted layout is written to and the format gate holds it to (Fb8). */
127
+ export const EDITORCONFIG = `# @generated by honey. DO NOT EDIT.
128
+ root = true
129
+
130
+ [*.cs]
131
+ charset = utf-8
132
+ end_of_line = lf
133
+ indent_size = 4
134
+ indent_style = space
135
+ insert_final_newline = true
136
+ `;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * XML doc comments (Fb4): a method's summary and its description as remarks, then (but on a `client.Safe` twin,
3
+ * which throws none of them) an `<exception>` per declared error status, ascending, naming the class the runtime throws for it (`UnexpectedStatusException`
4
+ * for one without a class of its own, Fb14). Spec text goes through `csDocLines`, so XML's specials are entities
5
+ * and a line break of any kind starts a new `///` line (Q7). A stream method ends with its `<returns>` line (contract
6
+ * 50 §2). No `<param>` tag: a partial set is CS1573.
7
+ */
8
+ import type { SdkOp } from "../../ir/sdk-model.ts";
9
+ /** `text` as `/// <tag>…</tag>` lines at `indent`; none for blank text. */
10
+ export declare function docLines(tag: string, text: string | undefined, indent?: string): string[];
11
+ /** The doc lines of `op`'s method at 4 spaces: its summary, its remarks, when it `raises` its exceptions, then `returns`. */
12
+ export declare function methodDoc(op: SdkOp, raises: boolean, returns?: string): string[];
@@ -0,0 +1,35 @@
1
+ import { csDocLines } from "../shared/escape.js";
2
+ /* the runtime's status classes (runtime/csharp/Errors.cs, Python's statuses); any other status throws UnexpectedStatusException */
3
+ const STATUS_EXCEPTIONS = {
4
+ 400: "BadRequestException",
5
+ 401: "UnauthorizedException",
6
+ 403: "ForbiddenException",
7
+ 404: "NotFoundException",
8
+ 409: "ConflictException",
9
+ 422: "UnprocessableEntityException",
10
+ 429: "RateLimitException",
11
+ 500: "InternalServerException",
12
+ 502: "BadGatewayException",
13
+ 503: "ServiceUnavailableException",
14
+ 504: "GatewayTimeoutException",
15
+ };
16
+ /** `text` as `/// <tag>…</tag>` lines at `indent`; none for blank text. */
17
+ export function docLines(tag, text, indent = "") {
18
+ const trimmed = (text ?? "").trim();
19
+ if (trimmed === "")
20
+ return [];
21
+ const lines = csDocLines(trimmed);
22
+ lines[0] = `<${tag}>${lines[0]}`;
23
+ lines[lines.length - 1] = `${lines.at(-1)}</${tag}>`;
24
+ return lines.map((line) => `${indent}/// ${line}`.trimEnd());
25
+ }
26
+ /** The doc lines of `op`'s method at 4 spaces: its summary, its remarks, when it `raises` its exceptions, then `returns`. */
27
+ export function methodDoc(op, raises, returns) {
28
+ const statuses = raises ? op.errorStatuses : [];
29
+ return [
30
+ ...docLines("summary", op.summary, " "),
31
+ ...docLines("remarks", op.description, " "),
32
+ ...statuses.map((status) => ` /// <exception cref="${STATUS_EXCEPTIONS[status] ?? "UnexpectedStatusException"}">HTTP ${status}</exception>`),
33
+ ...docLines("returns", returns, " "),
34
+ ];
35
+ }
@@ -0,0 +1,26 @@
1
+ import type { SdkOp } from "../../ir/sdk-model.ts";
2
+ import type { CSharpCallPlan } from "./sdk-plan.ts";
3
+ import { type CsTypeContext } from "./types.ts";
4
+ /** What every method of one SDK shares: the type context. */
5
+ export type MethodEnv = {
6
+ readonly at: CsTypeContext;
7
+ };
8
+ /** How a rendered method spells a type the context lists: its runtime type, and its `<Context>.Default.<Name>`. */
9
+ export type Spelling = {
10
+ readonly runtime: (type: string) => string;
11
+ readonly info: (type: string) => string;
12
+ };
13
+ /**
14
+ * One operation's method, once its names are claimed: its field, its lines, its `client.Safe` twin's (in the twin
15
+ * class, whose `_n` is the normal instance), the types it needs listed, its plan.
16
+ */
17
+ export type CsMethod = {
18
+ readonly field: string;
19
+ readonly lines: (spell: Spelling) => string[];
20
+ readonly twin: (spell: Spelling) => string[];
21
+ readonly types: readonly string[];
22
+ readonly plan: Omit<CSharpCallPlan, "accessors">;
23
+ };
24
+ export declare const METHOD_LOCALS: string[];
25
+ /** The method of `op` named `name`, its `Operation` in the private field `field`. */
26
+ export declare function csMethod(op: SdkOp, name: string, field: string, env: MethodEnv): CsMethod;
@@ -0,0 +1,187 @@
1
+ import { csString } from "../shared/escape.js";
2
+ import { compareCodeUnits, csIdentifier, NameScope } from "../shared/lang.js";
3
+ import { realtimeStream } from "./realtime.js";
4
+ import { csAnswer, csResponseHeaders, signatureType, } from "./sdk-answer.js";
5
+ import { csBody } from "./sdk-body.js";
6
+ import { methodDoc } from "./sdk-doc.js";
7
+ import { sseStream } from "./sse.js";
8
+ import { csTypeOf } from "./types.js";
9
+ import { wsStream } from "./ws.js";
10
+ /* the method's own parameters: a spec param that takes one of these names is claimed as `…2` */
11
+ export const METHOD_LOCALS = ["body", "cancellationToken", "headersInto", "idempotencyKey", "options"];
12
+ /* each stream's answer, its own fields, and the declared params its resume channels carry (the fold) */
13
+ const STREAMS = {
14
+ realtime: realtimeStream,
15
+ sse: sseStream,
16
+ ws: wsStream,
17
+ };
18
+ /** An identifier's metadata name: what reflection and named arguments see, `@` dropped. */
19
+ const bare = (ident) => ident.replace(/^@/, "");
20
+ /** `type` as a param left unset: nullable, once. */
21
+ const unset = (type) => `${type.replace(/\?$/, "")}?`;
22
+ /** The path params in path order, whatever order they were declared in. */
23
+ function pathParamsOf(op) {
24
+ const order = op.pathSegments.flatMap((segment) => (segment.kind === "param" ? [segment.name] : []));
25
+ return [...op.pathParams].sort((a, b) => order.indexOf(a.name) - order.indexOf(b.name));
26
+ }
27
+ /**
28
+ * The query then header params, each in code-unit order and claimed in `scope`, each typed at the op; one a field
29
+ * of `stream` carries has none.
30
+ */
31
+ function paramsOf(op, scope, at, stream) {
32
+ const headers = [...op.headers].sort((a, b) => compareCodeUnits(a.name, b.name));
33
+ return [
34
+ ...op.query.map((param) => ({ param, where: "query" })),
35
+ ...headers.map((param) => ({ param, where: "header" })),
36
+ ]
37
+ .filter(({ param, where }) => stream?.carries(param.name, where) !== true)
38
+ .map(({ param, where }) => {
39
+ const ident = scope.claim(csIdentifier(param.name));
40
+ const type = csTypeOf(param.schema, { ...at, fieldName: param.name, parentName: op.id });
41
+ return { ident, param, type: param.required === true ? type : unset(type), where };
42
+ });
43
+ }
44
+ /** A parameter: its declaration, then its name. */
45
+ const one = (decl, ident) => ({ decl: `${decl} ${ident}`, ident });
46
+ /** An optional parameter, defaulting to `fallback`. */
47
+ const optional = (decl, ident, fallback = "null") => ({ decl: `${decl} ${ident} = ${fallback}`, ident });
48
+ /**
49
+ * The parameters, each its declaration and its name, in C#4's order, the response-header holder after the
50
+ * idempotency key, then a stream's fields.
51
+ */
52
+ function parameters({ body, headers, keyed, op, params, path, stream }, spell) {
53
+ const required = op.body?.required === true;
54
+ const type = body.type;
55
+ return [
56
+ ...path.map(({ ident }) => one("string", ident)),
57
+ ...(type !== null && required ? [one(signatureType(type, spell), "body")] : []),
58
+ ...params.filter((p) => p.param.required === true).map((p) => one(signatureType(p.type, spell), p.ident)),
59
+ ...(type !== null && !required ? [optional(unset(signatureType(type, spell)), "body")] : []),
60
+ ...params.filter((p) => p.param.required !== true).map((p) => optional(signatureType(p.type, spell), p.ident)),
61
+ ...(keyed ? [optional("string?", "idempotencyKey")] : []),
62
+ ...(headers === null ? [] : [optional(`${headers.type}?`, "headersInto")]),
63
+ ...(stream?.fields ?? []).map((field) => optional(field.type, field.ident)),
64
+ optional("RequestOptions?", "options"),
65
+ optional("CancellationToken", "cancellationToken", "default"),
66
+ ];
67
+ }
68
+ /** The parameter list as the signature spells it. */
69
+ const signature = (parts, spell) => parameters(parts, spell).map(({ decl }) => decl);
70
+ /**
71
+ * The `Call` the method builds: path values, query and header args, the body, the idempotency key, the options,
72
+ * and the holder's `Read` where the op declares response headers.
73
+ */
74
+ function call({ body, headers, keyed, params, path }, spell) {
75
+ const args = (where) => `[${params
76
+ .filter((p) => p.where === where)
77
+ .map(({ ident, param, type }) => `Arg.Of(${csString(param.name)}, ${ident}, ${spell.info(type)})`)
78
+ .join(", ")}]`;
79
+ return [
80
+ `[${path.map(({ ident }) => ident).join(", ")}]`,
81
+ args("query"),
82
+ args("header"),
83
+ body.expr(spell),
84
+ keyed ? "idempotencyKey" : "null",
85
+ "options",
86
+ ...(headers === null ? [] : ["headersInto is null ? null : headersInto.Read"]),
87
+ ].join(", ");
88
+ }
89
+ /** The method's lines: its docs (its error statuses' exceptions), its signature, the one call into the transport (a stream's arguments after the `Call`). */
90
+ function methodLines(parts, spell) {
91
+ const { answer, stream } = parts;
92
+ const [returns, run] = answer.render(spell);
93
+ const args = [
94
+ ...(stream?.args ?? []),
95
+ ...(answer.type === null ? [] : [spell.info(answer.type)]),
96
+ "cancellationToken",
97
+ ];
98
+ return [
99
+ ...methodDoc(parts.op, true, stream?.returns),
100
+ ` public ${returns} ${parts.name}(${signature(parts, spell).join(", ")}) =>`,
101
+ ` _t.${run}(${parts.field}, new(${call(parts, spell)}), ${args.join(", ")});`,
102
+ ];
103
+ }
104
+ /* an SSE twin's <returns>: the open stream is its Ok, an error status opening it its Err */
105
+ const SAFE_STREAM = "Ok with the open stream, or Err with the opening answer's error status. No timeout bounds it after that, and a drop or an event that does not decode is the stream's own exception; the token, leaving await foreach or DisposeAsync ends it.";
106
+ /**
107
+ * The `client.Safe` twin's lines: the signature restated, answering `Task<Result<T>>` (`Task<Result>` for no body)
108
+ * through `Transport.Safe` and the normal method `_n.<name>`, its options given a response box (`_o`); a
109
+ * connection's twin is the very method, its docs and answer the normal one's (a refusal throws, as there).
110
+ */
111
+ function twinLines(parts, spell) {
112
+ const [returns] = parts.answer.render(spell);
113
+ const sig = `${signature(parts, spell).join(", ")})`;
114
+ const idents = parameters(parts, spell).map(({ ident }) => ident);
115
+ if (parts.op.stream === "ws" || parts.op.stream === "realtime")
116
+ return [
117
+ ...methodDoc(parts.op, true, parts.stream?.returns),
118
+ ` public ${returns} ${parts.name}(${sig} =>`,
119
+ ` _n.${parts.name}(${idents.join(", ")});`,
120
+ ];
121
+ const safe = returns === "Task" ? "Task<Result>" : `Task<Result<${returns.slice("Task<".length, -1)}>>`;
122
+ const sent = idents.map((ident) => (ident === "options" ? "_o" : ident));
123
+ return [
124
+ ...methodDoc(parts.op, false, parts.op.stream === "sse" ? SAFE_STREAM : undefined),
125
+ ` public ${safe} ${parts.name}(${sig} =>`,
126
+ ` Transport.Safe(options, _o => _n.${parts.name}(${sent.join(", ")}));`,
127
+ ];
128
+ }
129
+ /** The plan the reflection driver walks: every name as reflection sees it (Fb10). */
130
+ function planOf(parts) {
131
+ const { body, headers, keyed, name, op, params, path } = parts;
132
+ const by = (where) => Object.fromEntries(params.filter((p) => p.where === where).map(({ ident, param }) => [param.name, bare(ident)]));
133
+ const required = [
134
+ ...path.map(({ ident }) => ident),
135
+ ...(body.type !== null && op.body?.required === true ? ["body"] : []),
136
+ ...params.filter((p) => p.param.required === true).map(({ ident }) => ident),
137
+ ];
138
+ return {
139
+ body: op.body === undefined ? null : { kind: op.body.kind, param: "body" },
140
+ headers: by("header"),
141
+ idempotencyKey: keyed ? "idempotencyKey" : null,
142
+ method: name,
143
+ operation: op.id,
144
+ path: path.map(({ ident, param }) => ({ name: param.name, param: bare(ident) })),
145
+ query: by("query"),
146
+ required: required.map(bare),
147
+ response: op.success.kind,
148
+ responseHeaders: headers,
149
+ stream: op.stream,
150
+ };
151
+ }
152
+ /** What `op`'s request asks for: an event stream's media type, or a text or binary answer's. */
153
+ function acceptOf(op) {
154
+ if (op.stream === "sse")
155
+ return "text/event-stream";
156
+ return op.success.kind === "binary" || op.success.kind === "text" ? op.success.contentType : undefined;
157
+ }
158
+ /** The `Operation` field: method, path, path params, `Idempotent`, then `Accept` and `Invalidates` when they apply. */
159
+ function operationField({ field, keyed, op, path }) {
160
+ const accept = acceptOf(op);
161
+ const named = [
162
+ `Idempotent: ${keyed}`,
163
+ ...(accept === undefined ? [] : [`Accept: ${csString(accept)}`]),
164
+ ...(op.invalidates.length === 0 ? [] : [`Invalidates: [${op.invalidates.map(csString).join(", ")}]`]),
165
+ ];
166
+ const params = path.map(({ param }) => csString(param.name)).join(", ");
167
+ return ` private static readonly Operation ${field} = new(${csString(op.method)}, ${csString(op.path)}, [${params}], ${named.join(", ")});`;
168
+ }
169
+ /** The method of `op` named `name`, its `Operation` in the private field `field`. */
170
+ export function csMethod(op, name, field, env) {
171
+ const stream = op.stream === null ? null : STREAMS[op.stream];
172
+ const scope = new NameScope([...METHOD_LOCALS, ...(stream?.fields ?? []).map(({ ident }) => ident)], bare);
173
+ const path = pathParamsOf(op).map((param) => ({ ident: scope.claim(csIdentifier(param.name)), param }));
174
+ const params = paramsOf(op, scope, env.at, stream);
175
+ const body = csBody(op, env);
176
+ const answer = stream === null ? csAnswer(op, env) : stream.answer(op, env);
177
+ const headers = csResponseHeaders(op, env)?.plan ?? null;
178
+ const keyed = op.idempotent && stream === null;
179
+ const parts = { answer, body, field, headers, keyed, name, op, params, path, stream };
180
+ return {
181
+ field: operationField(parts),
182
+ lines: (spell) => methodLines(parts, spell),
183
+ plan: planOf(parts),
184
+ twin: (spell) => twinLines(parts, spell),
185
+ types: [...params.map(({ type }) => type), ...body.types, ...(answer.type === null ? [] : [answer.type])],
186
+ };
187
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The C# SDK's call plan for one operation (contract 45 §4.8), in the emitter's own names: what the fixed
3
+ * reflection driver (`__fixtures__/driver/Invoke.cs`) walks with `GetProperty` and `GetMethod`, binding each
4
+ * argument to its parameter by name through the SDK's own `JsonSerializerContext` (Fb10), so nothing is generated
5
+ * for it (G17). A plan carries no C# type: the driver reads each parameter's type from the method itself.
6
+ */
7
+ import type { SdkBody, SdkResponseKind, SdkStream } from "../../ir/sdk-model.ts";
8
+ export type CSharpCallPlan = {
9
+ readonly operation: string;
10
+ /** the property names from the client to the method's resource, root first: `["Orgs", "Members", "Notes"]` */
11
+ readonly accessors: readonly string[];
12
+ /** the method as emitted: `"CreateAsync"` */
13
+ readonly method: string;
14
+ /** each path param's spec name to its parameter name, in path order */
15
+ readonly path: readonly {
16
+ readonly name: string;
17
+ readonly param: string;
18
+ }[];
19
+ readonly body: {
20
+ readonly kind: SdkBody["kind"];
21
+ readonly param: string;
22
+ } | null;
23
+ /** each query param's spec name to its parameter name */
24
+ readonly query: Readonly<Record<string, string>>;
25
+ /** each header param's spec name to its parameter name */
26
+ readonly headers: Readonly<Record<string, string>>;
27
+ /** the parameters without a default */
28
+ readonly required: readonly string[];
29
+ /** the idempotency key's parameter name */
30
+ readonly idempotencyKey: string | null;
31
+ readonly response: SdkResponseKind;
32
+ /** the `<Op>Headers` holder the method takes as `headersInto`, each declared header to its property; null without one */
33
+ readonly responseHeaders: {
34
+ readonly type: string;
35
+ readonly fields: Readonly<Record<string, string>>;
36
+ } | null;
37
+ readonly stream: SdkStream;
38
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { type PackageIdentity, type Shipped } from "../shared/metadata.ts";
2
+ import type { CSharpCallPlan } from "./sdk-plan.ts";
3
+ export type CSharpSdkOptions = {
4
+ /** the NuGet package id and assembly name; `HoneySdk` by default */
5
+ readonly packageId?: string;
6
+ /** the namespace of every type; the package id by default */
7
+ readonly rootNamespace?: string;
8
+ /** the client class; `<last namespace segment>Client` by default */
9
+ readonly clientName?: string;
10
+ /** the package version; `0.1.0` by default */
11
+ readonly version?: string;
12
+ /** what nuget.org shows: one line of text; none by default */
13
+ readonly description?: string;
14
+ /** the package's authors, comma separated; none by default */
15
+ readonly authors?: string;
16
+ /** its SPDX license expression (`MIT`, `Apache-2.0 OR MIT`); none by default */
17
+ readonly license?: string;
18
+ /** the https home page nuget.org links; none by default */
19
+ readonly homepage?: string;
20
+ /** the https URL of its git repository; none by default */
21
+ readonly repository?: string;
22
+ /** the copyright notice nuget.org shows: one line of text; none by default */
23
+ readonly copyright?: string;
24
+ /** its NuGet tags, comma separated, none holding a space or a `;`; none by default */
25
+ readonly tags?: string;
26
+ };
27
+ /** The package's files by path, and what the generation reports: a component or a root group renamed (never silently). */
28
+ export type GeneratedCSharpSdk = {
29
+ readonly files: Readonly<Record<string, string>>;
30
+ readonly notices: readonly string[];
31
+ /** the package as nuget.org lists it */
32
+ readonly packages: readonly PackageIdentity[];
33
+ };
34
+ /** The package's files for `document`, by path; its `.csproj` packs the files it `shipped` beside. */
35
+ export declare function generateCSharpSdk(document: Record<string, unknown>, options?: CSharpSdkOptions, shipped?: Shipped): GeneratedCSharpSdk;
36
+ /**
37
+ * Each operation's call plan by id, from the very emit `generateCSharpSdk` runs with these options: the names the
38
+ * fixed reflection driver walks (Fb10), never re-derived outside the emitter.
39
+ */
40
+ export declare function csharpCallPlans(document: Record<string, unknown>, options?: CSharpSdkOptions): Readonly<Record<string, CSharpCallPlan>>;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * The C# SDK (bit 15): a package emitted from the IR alone (H2): `<PackageId>.csproj`, a root `.editorconfig`,
3
+ * `Client.cs` (the client and its resource classes), `Types.cs` (every component C# declares, then every hoisted
4
+ * declaration, in name order), `JsonContext.cs` (the public source-generated context) and the vendored runtime under
5
+ * `Runtime/`, every `.cs` file in the SDK's own namespace (Fb2) and marked `@generated`, never `<auto-generated`.
6
+ * `Types.cs` ends with `ErrorKey` when the API declares an error key (Fc3). Every body (JSON, form, multipart, text,
7
+ * binary) and every unary answer (JSON, text, bytes) emits, and so does every operation: SSE, WebSocket and
8
+ * realtime ones since phase d (contract 50 §2). The runtime ships the files the operations' stream kinds need. Every
9
+ * method throws its error statuses, and `client.Safe` mirrors it answering a `Result` (bit 21 i5); the generation
10
+ * reports every name it emits other than the spec's (`notices`, shared/mirror.ts), never silently.
11
+ */
12
+ import { toIR } from "../../ir/build.js";
13
+ import { sdkModel } from "../../ir/sdk-model.js";
14
+ import { compareCodeUnits, csTypeName } from "../shared/lang.js";
15
+ import { renameNotice } from "../shared/mirror.js";
16
+ import { csharpErrorKeys } from "./errors.js";
17
+ import { jsonContext, runtimeOf, strictConverters, typeInfoNames } from "./json.js";
18
+ import { clientDecls } from "./sdk-client.js";
19
+ import { csproj, EDITORCONFIG, packageMetadata, validateClientName, validatePackageId, validateRootNamespace, validateVersion, } from "./sdk-csproj.js";
20
+ import { packageOn } from "../shared/metadata.js";
21
+ import { docLines } from "./sdk-doc.js";
22
+ import { runtimeFiles } from "./transport.js";
23
+ import { usings } from "./types-names.js";
24
+ import { csTopLevel, csTypeContext, declares } from "./types.js";
25
+ /* the marker every .cs file opens with; never `<auto-generated`, which the format gate and the analyzers skip (Q4) */
26
+ const MARKER = "// @generated by honey. DO NOT EDIT.";
27
+ /** The options validated, each default filled in, and the client's and its context's class names. */
28
+ function identity(options) {
29
+ const packageId = validatePackageId(options.packageId ?? "HoneySdk");
30
+ const rootNamespace = validateRootNamespace(options.rootNamespace ?? packageId);
31
+ const client = validateClientName(options.clientName ?? `${csTypeName(rootNamespace.split(".").at(-1))}Client`);
32
+ const version = validateVersion(options.version ?? "0.1.0");
33
+ return {
34
+ client,
35
+ context: `${client.replace(/Client$/, "")}JsonContext`,
36
+ metadata: packageMetadata(options),
37
+ packageId,
38
+ rootNamespace,
39
+ version,
40
+ };
41
+ }
42
+ /** A `.cs` file: the marker, the usings its code needs, the namespace, then the code. */
43
+ const csFile = (namespace, code) => [MARKER, ...usings(code), "", `namespace ${namespace};`, ...(code === "" ? [] : ["", code]), ""].join("\n");
44
+ /** Each component C# declares, in code-unit order, its description as its summary: [name, text]. */
45
+ function componentDecls(ir, at) {
46
+ return Object.keys(ir.schemas)
47
+ .sort(compareCodeUnits)
48
+ .filter((name) => declares(ir.schemas[name]))
49
+ .map((name) => {
50
+ const claimed = at.names.ref(name);
51
+ const text = csTopLevel(claimed, ir.schemas[name], at);
52
+ return [claimed, [...docLines("summary", ir.schemaDescriptions[name]), text].join("\n")];
53
+ });
54
+ }
55
+ /** The package's files for `document`, and the call plan of every method in them. */
56
+ function emitCSharp(document, options, shipped) {
57
+ const id = { ...identity(options), shipped };
58
+ const ir = toIR(document, { deriveOperationIds: true });
59
+ const model = sdkModel(ir);
60
+ const at = csTypeContext(ir, [id.client, id.context]);
61
+ const components = componentDecls(ir, at);
62
+ const errorKey = csharpErrorKeys(model, at);
63
+ /* every component emitted under another name is noticed, as the mirror's rename is */
64
+ const notices = [...at.names.renamed].map(([name, renamed]) => renameNotice("csharp", {
65
+ because: `"${csTypeName(name)}" is a name the SDK's runtime, the BCL or another declaration holds`,
66
+ name,
67
+ renamed,
68
+ what: "component",
69
+ }));
70
+ const env = { at, client: id.client, context: id.context, notices, ops: model.opsById };
71
+ const client = clientDecls(ir, env);
72
+ const decls = [...components, ...[...at.decls].sort(([a], [b]) => compareCodeUnits(a, b))];
73
+ const types = [...decls.map(([, text]) => text), ...(errorKey === null ? [] : [errorKey])].join("\n\n");
74
+ const runtime = runtimeOf(at.enums);
75
+ const used = [...client.types, ...at.serialized, ...(/\bJsonElement\b/.test(types) ? ["JsonElement"] : [])];
76
+ const names = typeInfoNames(decls.map(([name]) => name).filter((name) => !at.unlisted.has(name)), used.map(runtime), id.context);
77
+ const spell = { info: (type) => `${id.context}.Default.${names.get(runtime(type))}`, runtime };
78
+ const ns = id.rootNamespace;
79
+ const features = {
80
+ realtime: model.ops.some((op) => op.stream === "realtime"),
81
+ ws: model.ops.some((op) => op.stream === "ws"),
82
+ };
83
+ const files = {
84
+ ".editorconfig": EDITORCONFIG,
85
+ [`${id.packageId}.csproj`]: csproj(id),
86
+ "Client.cs": csFile(ns, client.text(spell)),
87
+ "JsonContext.cs": csFile(ns, jsonContext(id.context, names, strictConverters(at.collections, runtime))),
88
+ "Types.cs": csFile(ns, types),
89
+ ...Object.fromEntries(Object.entries(runtimeFiles(features, ns)).map(([n, s]) => [`Runtime/${n}`, s])),
90
+ };
91
+ const sorted = Object.fromEntries(Object.entries(files).sort(([a], [b]) => compareCodeUnits(a, b)));
92
+ return { files: sorted, id, notices, plans: client.plans };
93
+ }
94
+ /** The package's files for `document`, by path; its `.csproj` packs the files it `shipped` beside. */
95
+ export function generateCSharpSdk(document, options = {}, shipped) {
96
+ const { files, id, notices } = emitCSharp(document, options, shipped);
97
+ return { files, notices, packages: [packageOn("nuget", id.packageId, id.version)] };
98
+ }
99
+ /**
100
+ * Each operation's call plan by id, from the very emit `generateCSharpSdk` runs with these options: the names the
101
+ * fixed reflection driver walks (Fb10), never re-derived outside the emitter.
102
+ */
103
+ export function csharpCallPlans(document, options = {}) {
104
+ return Object.fromEntries(emitCSharp(document, options).plans.map((plan) => [plan.operation, plan]));
105
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * An SSE operation's answer (contract 50 §2, Fd1, Fd4): `Task<EventStream<T>>` through `EventsAsync`, `T` the
3
+ * declared event schema's type, or `Task<EventStream<string>>` through `TextEventsAsync` for untyped events, opened
4
+ * by awaiting the method (G15). Its one field, `lastEventId`, is sent as Last-Event-ID only when set and non-empty;
5
+ * a declared Last-Event-ID header param is folded into that field.
6
+ */
7
+ import { type CsStream } from "./sdk-answer.ts";
8
+ /** The header the SSE and realtime dials resume an event stream with. */
9
+ export declare const LAST_EVENT_ID = "Last-Event-ID";
10
+ /** The resume cursor's event id, which the SSE and realtime methods take. */
11
+ export declare const LAST_EVENT_ID_FIELD: {
12
+ ident: string;
13
+ type: string;
14
+ };
15
+ /** Whether a declared param is the Last-Event-ID header (any casing), the resume channel an SSE dial sends. */
16
+ export declare const isLastEventIdHeader: (name: string, where: string) => boolean;
17
+ /** The SSE operation's answer, its one field and its `<returns>` text. */
18
+ export declare const sseStream: CsStream;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * An SSE operation's answer (contract 50 §2, Fd1, Fd4): `Task<EventStream<T>>` through `EventsAsync`, `T` the
3
+ * declared event schema's type, or `Task<EventStream<string>>` through `TextEventsAsync` for untyped events, opened
4
+ * by awaiting the method (G15). Its one field, `lastEventId`, is sent as Last-Event-ID only when set and non-empty;
5
+ * a declared Last-Event-ID header param is folded into that field.
6
+ */
7
+ import { eventType } from "./sdk-answer.js";
8
+ /** The header the SSE and realtime dials resume an event stream with. */
9
+ export const LAST_EVENT_ID = "Last-Event-ID";
10
+ /** The resume cursor's event id, which the SSE and realtime methods take. */
11
+ export const LAST_EVENT_ID_FIELD = { ident: "lastEventId", type: "string?" };
12
+ /** Whether a declared param is the Last-Event-ID header (any casing), the resume channel an SSE dial sends. */
13
+ export const isLastEventIdHeader = (name, where) => where === "header" && name.toLowerCase() === LAST_EVENT_ID.toLowerCase();
14
+ /** The SSE operation's answer, its one field and its `<returns>` text. */
15
+ export const sseStream = {
16
+ answer: (op, env) => {
17
+ const type = op.events === undefined ? null : eventType(op.events, op, env);
18
+ return {
19
+ render: (spell) => type === null
20
+ ? ["Task<EventStream<string>>", "TextEventsAsync"]
21
+ : [`Task<EventStream<${spell.runtime(type)}>>`, "EventsAsync"],
22
+ type,
23
+ };
24
+ },
25
+ args: ["lastEventId"],
26
+ carries: isLastEventIdHeader,
27
+ fields: [LAST_EVENT_ID_FIELD],
28
+ returns: "The open stream: an error status throws before any event. No timeout bounds it after that; the token, leaving await foreach or DisposeAsync ends it.",
29
+ };