@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,11 @@
1
+ /** What the API needs from the runtime beyond plain HTTP. */
2
+ export type CSharpRuntimeFeatures = {
3
+ readonly realtime: boolean;
4
+ readonly ws: boolean;
5
+ };
6
+ /** The runtime file names an SDK with `features` ships, `.cs` included, in code-unit order. */
7
+ export declare function runtimeFileNames(features: CSharpRuntimeFeatures): string[];
8
+ /** The runtime files an SDK with `features` ships, by file name, read from disk on every call, in `rootNamespace`. */
9
+ export declare function runtimeFiles(features: CSharpRuntimeFeatures, rootNamespace: string): Record<string, string>;
10
+ /** Every top-level class, record, struct, enum and interface name in `source`: what a spec type may not take. */
11
+ export declare function runtimeTypeNames(source: string): string[];
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The vendored C# runtime, as the files a C# SDK ships under `Runtime/` (H9/F5): `runtime/csharp/*.cs`, read here
3
+ * and nowhere else (the F8 mutation target), each emitted as committed but for its one `namespace Honey.Runtime;`
4
+ * line, which becomes the SDK's own namespace (Fb2), so `using <RootNamespace>;` reaches the client, the config,
5
+ * the exceptions and the models alike. Every API ships the core, SSE among it; a WebSocket or realtime API adds the
6
+ * socket and its dial, and a realtime API the adapters and the connection (contract 50 §2).
7
+ */
8
+ import { readFileSync } from "node:fs";
9
+ import { compareCodeUnits } from "../shared/lang.js";
10
+ /* every SDK: the HTTP runtime (config, errors and envelopes, bodies, auth, hooks, log, redirects and the strip
11
+ * handler, stale tracking, the exchange, its wire readers and the transport), the safe result, the strict JSON
12
+ * converters, the encoders, and the SSE parser and its EventStream */
13
+ const CORE = [
14
+ "Auth",
15
+ "Body",
16
+ "Config",
17
+ "Envelope",
18
+ "Errors",
19
+ "Events",
20
+ "Exchange",
21
+ "Handler",
22
+ "Hooks",
23
+ "Invalidation",
24
+ "Json",
25
+ "Log",
26
+ "Operation",
27
+ "Path",
28
+ "Query",
29
+ "Redirect",
30
+ "Result",
31
+ "Sse",
32
+ "Stale",
33
+ "Transport",
34
+ "Wire",
35
+ ];
36
+ /* a WebSocket or realtime operation: the socket and its own HTTP/1.1 upgrade */
37
+ const WS = ["Ws", "WsDial"];
38
+ /* a realtime operation: the adapters, the resumable connection and its loop, and the three transports */
39
+ const REALTIME = [
40
+ "Adapters",
41
+ "Realtime",
42
+ "RealtimeLoop",
43
+ "TransportLongPoll",
44
+ "TransportSse",
45
+ "TransportWs",
46
+ ];
47
+ /* the one line each committed file holds, swapped for the SDK's namespace */
48
+ const NAMESPACE = /^namespace Honey\.Runtime;$/m;
49
+ /* a top-level type at column 0: its modifiers, its kind, its name (type parameters after it are not part of it) */
50
+ const TOP_LEVEL = /^(?:(?:public|internal|file|sealed|abstract|static|readonly|partial|unsafe)\s+)*(?:record\s+struct|record\s+class|class|record|struct|enum|interface)\s+([A-Za-z_]\w*)/gm;
51
+ /** The runtime file names an SDK with `features` ships, `.cs` included, in code-unit order. */
52
+ export function runtimeFileNames(features) {
53
+ return [...CORE, ...(features.ws || features.realtime ? WS : []), ...(features.realtime ? REALTIME : [])]
54
+ .map((name) => `${name}.cs`)
55
+ .sort(compareCodeUnits);
56
+ }
57
+ /** The runtime files an SDK with `features` ships, by file name, read from disk on every call, in `rootNamespace`. */
58
+ export function runtimeFiles(features, rootNamespace) {
59
+ return Object.fromEntries(runtimeFileNames(features).map((name) => [
60
+ name,
61
+ readFileSync(new URL(`../../runtime/csharp/${name}`, import.meta.url), "utf8").replace(NAMESPACE, () => `namespace ${rootNamespace};`),
62
+ ]));
63
+ }
64
+ /** Every top-level class, record, struct, enum and interface name in `source`: what a spec type may not take. */
65
+ export function runtimeTypeNames(source) {
66
+ return [...source.matchAll(TOP_LEVEL)].map((match) => match[1]);
67
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * C# enums for a string or integer `enum` (§1 rules, §4.5). A string enum has one member per value and a converter
3
+ * of its own with one exact `switch` arm per value each way: the stock `JsonStringEnumConverter` refuses a whole
4
+ * type holding `""`, reads `"dark,light"` and trims `" dark"`. An integer enum has an `L<n>`/`Neg<n>` member per
5
+ * value through the runtime's `IntEnumConverter<T>`, which takes only a declared JSON integer. Spec text reaches
6
+ * the source only through the escape layer.
7
+ */
8
+ import type { IRSchema } from "../../ir/model.ts";
9
+ import type { CsTypeContext } from "./types.ts";
10
+ type Scalar = Extract<IRSchema, {
11
+ kind: "scalar";
12
+ }>;
13
+ /** The values a string or integer enum declares, each once: a value of another kind has no member. */
14
+ export declare function enumValues(ir: Scalar): (number | string)[];
15
+ /** `public enum <name>` with one member per value, then its exact converter; `name` is noted as an enum. */
16
+ export declare function stringEnumDecl(name: string, values: readonly string[], at: CsTypeContext): string;
17
+ /** The enum `name` of the string or integer enum `ir`. */
18
+ export declare function enumDecl(name: string, ir: Scalar, at: CsTypeContext): string;
19
+ export {};
@@ -0,0 +1,63 @@
1
+ import { csString } from "../shared/escape.js";
2
+ import { csTypeName, NameScope } from "../shared/lang.js";
3
+ /** The values a string or integer enum declares, each once: a value of another kind has no member. */
4
+ export function enumValues(ir) {
5
+ const values = ir.enum ?? [];
6
+ const kept = ir.type === "string"
7
+ ? values.filter((value) => typeof value === "string")
8
+ : values.filter((value) => ir.type === "integer" && Number.isSafeInteger(value));
9
+ return [...new Set(kept)];
10
+ }
11
+ /** A string enum member's name, unique in `scope`: `""` is `Empty`, a repeat takes `…2`. */
12
+ const memberOf = (value, scope) => scope.claim(value === "" ? "Empty" : csTypeName(value));
13
+ /** `public enum <name>` with one member per value, then its exact converter; `name` is noted as an enum. */
14
+ export function stringEnumDecl(name, values, at) {
15
+ at.enums.add(name);
16
+ const scope = new NameScope();
17
+ const members = values.map((value) => [csString(value), memberOf(value, scope)]);
18
+ const converter = at.names.claim(`${name}Converter`);
19
+ return [
20
+ `[JsonConverter(typeof(${converter}))]`,
21
+ `public enum ${name}`,
22
+ "{",
23
+ ...members.map(([, member]) => ` ${member},`),
24
+ "}",
25
+ "",
26
+ `public sealed class ${converter} : JsonConverter<${name}>`,
27
+ "{",
28
+ ` public override ${name} Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>`,
29
+ " reader.TokenType == JsonTokenType.String",
30
+ " ? reader.GetString() switch",
31
+ " {",
32
+ ...members.map(([value, member]) => ` ${value} => ${name}.${member},`),
33
+ ` var other => throw new JsonException($"{other} is no ${name}"),`,
34
+ " }",
35
+ ` : throw new JsonException("a ${name} is a string");`,
36
+ "",
37
+ ` public override void Write(Utf8JsonWriter writer, ${name} value, JsonSerializerOptions options) =>`,
38
+ " writer.WriteStringValue(value switch",
39
+ " {",
40
+ ...members.map(([value, member]) => ` ${name}.${member} => ${value},`),
41
+ ` _ => throw new JsonException($"{(long)value} is no ${name}"),`,
42
+ " });",
43
+ "}",
44
+ ].join("\n");
45
+ }
46
+ /** An integer value's member: `L<n>`, or `Neg<n>` below zero. */
47
+ const label = (value) => `${value < 0 ? "Neg" : "L"}${String(Math.abs(value))}`;
48
+ /** `public enum <name>` with one `L<n>` member per value, read and written by `IntEnumConverter<T>`. */
49
+ function intEnumDecl(name, values, at) {
50
+ at.enums.add(name);
51
+ return [
52
+ `[JsonConverter(typeof(IntEnumConverter<${name}>))]`,
53
+ `public enum ${name}`,
54
+ "{",
55
+ ...values.map((value) => ` ${label(value)} = ${value},`),
56
+ "}",
57
+ ].join("\n");
58
+ }
59
+ /** The enum `name` of the string or integer enum `ir`. */
60
+ export function enumDecl(name, ir, at) {
61
+ const values = enumValues(ir);
62
+ return ir.type === "string" ? stringEnumDecl(name, values, at) : intEnumDecl(name, values, at);
63
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The C# names types are declared under (H52): one scope that components, hoisted types, converters, the client,
3
+ * its context and its resource classes all claim from, clear of every top-level type the runtime declares (in the
4
+ * SDK's own namespace, Fb2) and of the BCL names emitted text spells unqualified (§4.7). A component whose name is
5
+ * taken is `<Name>Model`; a later claim of a taken name is `…2`. The BCL names by namespace also give each emitted
6
+ * file exactly the `using` lines it needs.
7
+ */
8
+ import type { IR, IRSchema } from "../../ir/model.ts";
9
+ /** How component, hoisted and other declared names are claimed, and which declared types are enums. */
10
+ export type CsTypeNames = {
11
+ /** the C# name of the component `name` */
12
+ ref(name: string): string;
13
+ /** a unique name for a hoisted declaration; one key always gets the same name */
14
+ hoist(key: string, base: string): string;
15
+ /** a unique name for any other declaration (a converter, a resource class) */
16
+ claim(base: string): string;
17
+ /** each component emitted as `<Name>Model`, by its spec name: what the generation reports (bit 21 i5) */
18
+ readonly renamed: ReadonlyMap<string, string>;
19
+ /** the schema of the component `name` when C# declares nothing for it, so a ref to it is its use type */
20
+ alias(name: string): IRSchema | undefined;
21
+ resolve(schema: IRSchema): IRSchema;
22
+ };
23
+ export declare const BCL: Readonly<Record<string, readonly string[]>>;
24
+ export declare const RUNTIME_BCL: readonly string[];
25
+ /**
26
+ * Names for an SDK of the components `schemas` with `taken` reserved besides (its client and context): each
27
+ * component C# declares claims its name in code-unit order, as `<Name>Model` when it is taken; hoists and other
28
+ * declarations claim after them. A component `declares` nothing for is an alias, and one `schemas` lacks is any
29
+ * JSON value.
30
+ */
31
+ export declare function irNames(schemas: IR["schemas"], taken: readonly string[], declares: (ir: IRSchema) => boolean): CsTypeNames;
32
+ /** The `using` lines `code` needs: each namespace one of whose BCL names it spells as a type, in code-unit order. */
33
+ export declare function usings(code: string): string[];
@@ -0,0 +1,182 @@
1
+ import { irResolver } from "../../ir/schema.js";
2
+ import { compareCodeUnits, csTypeName, NameScope } from "../shared/lang.js";
3
+ import { runtimeFiles, runtimeTypeNames } from "./transport.js";
4
+ /* the BCL names emitted text spells unqualified, by the namespace a `using` brings them from (§4.7) */
5
+ export const BCL = {
6
+ System: ["Exception", "Func", "IDisposable", "Object", "String", "TimeSpan", "Type"],
7
+ "System.Collections.Generic": ["IDictionary", "IReadOnlyDictionary", "IReadOnlyList"],
8
+ "System.Text.Json": [
9
+ "JsonElement",
10
+ "JsonException",
11
+ "JsonSerializer",
12
+ "JsonSerializerOptions",
13
+ "JsonTokenType",
14
+ "JsonValueKind",
15
+ "Utf8JsonReader",
16
+ "Utf8JsonWriter",
17
+ ],
18
+ "System.Text.Json.Serialization": [
19
+ "JsonConverter",
20
+ "JsonExtensionData",
21
+ "JsonIgnore",
22
+ "JsonIgnoreCondition",
23
+ "JsonPropertyName",
24
+ "JsonSerializable",
25
+ "JsonSerializerContext",
26
+ "JsonSourceGenerationOptions",
27
+ "JsonUnmappedMemberHandling",
28
+ ],
29
+ "System.Text.Json.Serialization.Metadata": ["JsonTypeInfo"],
30
+ "System.Threading": ["CancellationToken"],
31
+ "System.Threading.Tasks": ["Task"],
32
+ };
33
+ /*
34
+ * the BCL names the vendored runtime spells unqualified (as a type or by static access) and emitted text never does:
35
+ * the emitted types share the runtime's namespace (Fb2), so each is reserved, never a `using`
36
+ */
37
+ export const RUNTIME_BCL = [
38
+ "Action",
39
+ "Array",
40
+ "ByteArrayContent",
41
+ "CancellationTokenRegistration",
42
+ "CancellationTokenSource",
43
+ "Convert",
44
+ "CultureInfo",
45
+ "DecompressionMethods",
46
+ "DelegatingHandler",
47
+ "Dictionary",
48
+ "Encoding",
49
+ "Enum",
50
+ "EqualityComparer",
51
+ "Guid",
52
+ "HashCode",
53
+ "HashSet",
54
+ "HttpClient",
55
+ "HttpClientHandler",
56
+ "HttpCompletionOption",
57
+ "HttpHeaders",
58
+ "HttpMessageHandler",
59
+ "HttpMethod",
60
+ "HttpRequestException",
61
+ "HttpRequestMessage",
62
+ "HttpRequestOptionsKey",
63
+ "HttpResponseMessage",
64
+ "HttpStatusCode",
65
+ "HttpVersion",
66
+ "HttpVersionPolicy",
67
+ "IAsyncEnumerable",
68
+ "IAsyncEnumerator",
69
+ "IEnumerable",
70
+ "IEquatable",
71
+ "Interlocked",
72
+ "InvalidOperationException",
73
+ "JsonDocument",
74
+ "JsonMetadataServices",
75
+ "JsonTypeInfoResolver",
76
+ "LinkedList",
77
+ "LinkedListNode",
78
+ "List",
79
+ "Math",
80
+ "MemoryStream",
81
+ "NotSupportedException",
82
+ "NumberStyles",
83
+ "OperationCanceledException",
84
+ "Random",
85
+ "RandomNumberGenerator",
86
+ "ReadOnlySpan",
87
+ "Rune",
88
+ "SHA1",
89
+ "SearchValues",
90
+ "SemaphoreSlim",
91
+ "SocketsHttpHandler",
92
+ "Stopwatch",
93
+ "Stream",
94
+ "StreamContent",
95
+ "StringBuilder",
96
+ "StringComparer",
97
+ "StringComparison",
98
+ /* System.Threading's, also a runtime property: the scan cannot tell `Timeout.InfiniteTimeSpan` (CS0117) from it */
99
+ "Timeout",
100
+ "UnicodeCategory",
101
+ "Uri",
102
+ "UriBuilder",
103
+ "UriKind",
104
+ "ValueTask",
105
+ "ValueWebSocketReceiveResult",
106
+ "WebSocket",
107
+ "WebSocketCloseStatus",
108
+ "WebSocketCreationOptions",
109
+ "WebSocketMessageType",
110
+ "WebSocketState",
111
+ ];
112
+ /* the attributes emitted text spells without their `Attribute` suffix: the suffixed name is taken too */
113
+ const ATTRIBUTES = [
114
+ "JsonConverter",
115
+ "JsonExtensionData",
116
+ "JsonIgnore",
117
+ "JsonPropertyName",
118
+ "JsonSerializable",
119
+ "JsonSourceGenerationOptions",
120
+ ];
121
+ const UNKNOWN = { kind: "unknown" };
122
+ /** Every name a declared type may not take: the runtime's types, the BCL's (emitted and runtime-spelled), `System` itself, and `taken`. */
123
+ const reserved = (taken) => [
124
+ ...Object.values(runtimeFiles({ realtime: true, ws: true }, "X")).flatMap(runtimeTypeNames),
125
+ ...Object.values(BCL).flat(),
126
+ ...RUNTIME_BCL,
127
+ ...ATTRIBUTES.map((name) => `${name}Attribute`),
128
+ /* the static class of the API's error keys (errors.ts), declared beside the types when any key is */
129
+ "ErrorKey",
130
+ "System",
131
+ ...taken,
132
+ ];
133
+ /**
134
+ * Names for an SDK of the components `schemas` with `taken` reserved besides (its client and context): each
135
+ * component C# declares claims its name in code-unit order, as `<Name>Model` when it is taken; hoists and other
136
+ * declarations claim after them. A component `declares` nothing for is an alias, and one `schemas` lacks is any
137
+ * JSON value.
138
+ */
139
+ export function irNames(schemas, taken, declares) {
140
+ const scope = new NameScope(reserved(taken));
141
+ const components = new Map();
142
+ const renamed = new Map();
143
+ for (const name of Object.keys(schemas)
144
+ .sort(compareCodeUnits)
145
+ .filter((n) => declares(schemas[n]))) {
146
+ const base = csTypeName(name);
147
+ const claimed = scope.claim(scope.has(base) ? `${base}Model` : base);
148
+ components.set(name, claimed);
149
+ if (claimed !== base)
150
+ renamed.set(name, claimed);
151
+ }
152
+ const hoisted = new Map();
153
+ return {
154
+ alias: (name) => {
155
+ const schema = schemas[name] ?? UNKNOWN;
156
+ return declares(schema) ? undefined : schema;
157
+ },
158
+ claim: (base) => scope.claim(base),
159
+ hoist: (key, base) => {
160
+ const name = hoisted.get(key) ?? scope.claim(base);
161
+ hoisted.set(key, name);
162
+ return name;
163
+ },
164
+ /* a ref reaches here only for a declared component: `alias` answers for every other one */
165
+ ref: (name) => components.get(name),
166
+ renamed,
167
+ resolve: irResolver(schemas),
168
+ };
169
+ }
170
+ /** `code` without its string and char literals and comments: the text that spells names. */
171
+ const codeOf = (code) => code
172
+ .replace(/"(?:[^"\\\n]|\\.)*"/g, '""')
173
+ .replace(/'(?:[^'\\\n]|\\.)'/g, "''")
174
+ .replace(/\/\/.*$/gm, "");
175
+ /** The `using` lines `code` needs: each namespace one of whose BCL names it spells as a type, in code-unit order. */
176
+ export function usings(code) {
177
+ const text = codeOf(code);
178
+ return Object.keys(BCL)
179
+ .filter((namespace) => BCL[namespace].some((name) => new RegExp(`(?<![.\\w])${name}\\b`).test(text)))
180
+ .sort(compareCodeUnits)
181
+ .map((namespace) => `using ${namespace};`);
182
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * C# records (Fb5, §4.5): a nominal `public sealed record` of `{ get; init; }` properties in code-unit order of the
3
+ * JSON key, each under its `[JsonPropertyName]`, with no initializer (R1). A required field is `required`, written
4
+ * even when null; an optional one is `T?`, skipped when null; an optional nullable one is `Opt<T?>`, so absent, null
5
+ * and a value stay three states; an open value is a bare `JsonElement`, already tri-state. A property spelling a
6
+ * member every record has, or the record's own name (CS0542), moves on to `…2`. An allOf is one record of its
7
+ * parts' fields, a key once, its first part's (Python's merge). An object that declares `additionalProperties`
8
+ * beside its fields keeps every other member in `[JsonExtensionData] Extra`, JsonElement-valued (honey-a8's ruling,
9
+ * Rust's flattened map), claimed after the fields: `{ get; set; }`, since an init-only one goes through the
10
+ * deserialization constructor, which extension data cannot bind to.
11
+ */
12
+ import type { IRField, IRSchema } from "../../ir/model.ts";
13
+ import type { CsTypeContext, Member } from "./types.ts";
14
+ export declare const RECORD_MEMBERS: readonly string[];
15
+ /** A record's members: its fields, and whether it keeps every other member (it declares `additionalProperties`). */
16
+ export type RecordShape = {
17
+ readonly fields: readonly IRField[];
18
+ readonly open: boolean;
19
+ };
20
+ /** `public sealed record <name>` of its fields in key order, a blank line between properties, then any extension data. */
21
+ export declare function recordDecl(name: string, { fields, open }: RecordShape, member: Member, at: CsTypeContext): string;
22
+ /** Whether an object, or any object part of an allOf (refs followed), declares `additionalProperties`. */
23
+ export declare function isOpen(schema: IRSchema, resolve: (schema: IRSchema) => IRSchema): boolean;
24
+ /** A schema's fields: an object's own, an allOf's merged (each ref followed, a key once, its first part's), else none. */
25
+ export declare function fieldsOf(schema: IRSchema, resolve: (schema: IRSchema) => IRSchema): IRField[];
@@ -0,0 +1,65 @@
1
+ import { csString } from "../shared/escape.js";
2
+ import { compareCodeUnits, csTypeName, NameScope } from "../shared/lang.js";
3
+ /* every member name a record property collides with (CS0102, CS0108, CS8859, CS8874), and the name its attributes spell in an expression */
4
+ export const RECORD_MEMBERS = [
5
+ "Clone",
6
+ "EqualityContract",
7
+ "Equals",
8
+ "GetHashCode",
9
+ "GetType",
10
+ "JsonIgnoreCondition",
11
+ "MemberwiseClone",
12
+ "PrintMembers",
13
+ "ToString",
14
+ ];
15
+ /* a required nullable member is written even when null; an unset tri-state or open value is not written */
16
+ const NEVER = "[JsonIgnore(Condition = JsonIgnoreCondition.Never)]";
17
+ const UNSET = "[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]";
18
+ /** One property's lines, unindented: its attributes, then `public <type> <name> { get; init; }`. */
19
+ function propertyLines(field, name, member, at) {
20
+ const type = member(field.schema, field.name);
21
+ const key = `[JsonPropertyName(${csString(field.name)})]`;
22
+ if (field.required)
23
+ return [key, ...(type.endsWith("?") ? [NEVER] : []), `public required ${type} ${name} { get; init; }`];
24
+ if (type === "JsonElement")
25
+ return [key, UNSET, `public ${type} ${name} { get; init; }`];
26
+ if (!type.endsWith("?"))
27
+ return [key, `public ${type}? ${name} { get; init; }`];
28
+ /* OptConverter reads T through the context: it must list T */
29
+ at.serialized.add(type);
30
+ return [key, `[JsonConverter(typeof(OptConverter<${type}>))]`, UNSET, `public Opt<${type}> ${name} { get; init; }`];
31
+ }
32
+ /** `public sealed record <name>` of its fields in key order, a blank line between properties, then any extension data. */
33
+ export function recordDecl(name, { fields, open }, member, at) {
34
+ const scope = new NameScope([...RECORD_MEMBERS, name]);
35
+ const properties = [...fields]
36
+ .sort((a, b) => compareCodeUnits(a.name, b.name))
37
+ .map((field) => propertyLines(field, scope.claim(csTypeName(field.name)), member, at));
38
+ if (open) {
39
+ properties.push([
40
+ "[JsonExtensionData]",
41
+ `public IDictionary<string, JsonElement>? ${scope.claim("Extra")} { get; set; }`,
42
+ ]);
43
+ }
44
+ return [
45
+ `public sealed record ${name}`,
46
+ "{",
47
+ ...properties.flatMap((lines, i) => [...(i > 0 ? [""] : []), ...lines.map((line) => ` ${line}`)]),
48
+ "}",
49
+ ].join("\n");
50
+ }
51
+ /** Whether an object, or any object part of an allOf (refs followed), declares `additionalProperties`. */
52
+ export function isOpen(schema, resolve) {
53
+ if (schema.kind === "object")
54
+ return schema.additional !== undefined && schema.additional !== false;
55
+ return schema.kind === "allOf" && schema.parts.some((part) => isOpen(resolve(part), resolve));
56
+ }
57
+ /** A schema's fields: an object's own, an allOf's merged (each ref followed, a key once, its first part's), else none. */
58
+ export function fieldsOf(schema, resolve) {
59
+ if (schema.kind === "object")
60
+ return schema.fields;
61
+ if (schema.kind !== "allOf")
62
+ return [];
63
+ const fields = schema.parts.flatMap((part) => fieldsOf(resolve(part), resolve));
64
+ return fields.filter((field, i) => fields.findIndex((first) => first.name === field.name) === i);
65
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * C# unions (Fb7, Go's shape): a union of const strings alone is a string enum; a discriminated one is a sealed
3
+ * record with one nullable property per ref or inline-object variant, in code-unit order of its first value, plus
4
+ * `JsonElement Raw`, the payload as received. Its emitted converter reads the discriminator, decodes the variant it
5
+ * selects through the context (AOT-safe), keeps any other payload whole in `Raw`, and writes the set variant or
6
+ * `Raw` verbatim. Every variant type is noted for the context: one a converter alone reaches is never generated.
7
+ */
8
+ import type { IRSchema } from "../../ir/model.ts";
9
+ import type { CsTypeContext, Member } from "./types.ts";
10
+ type Of<K extends IRSchema["kind"]> = Extract<IRSchema, {
11
+ kind: K;
12
+ }>;
13
+ /** Declares `schema` once under `names.hoist(key, base)`; its name. */
14
+ export type Declare = (schema: IRSchema, key: string, base: string) => string;
15
+ /** What a union's declaration reaches: the context, its members' types, and the hoist. */
16
+ export type UnionScope = {
17
+ at: CsTypeContext;
18
+ member: Member;
19
+ declare: Declare;
20
+ };
21
+ /** Whether a variant is a const string: a union of these alone is a string enum. */
22
+ export declare const isLiteral: (variant: IRSchema) => variant is Of<"const"> & {
23
+ value: string;
24
+ };
25
+ /** The declaration of a union `declares`: a string enum of its const strings, or a discriminated record. */
26
+ export declare function unionDecl(name: string, union: Of<"union">, scope: UnionScope): string;
27
+ export {};
@@ -0,0 +1,113 @@
1
+ import { csString } from "../shared/escape.js";
2
+ import { compareCodeUnits, csTypeName, NameScope } from "../shared/lang.js";
3
+ import { enumValues, stringEnumDecl } from "./types-enum.js";
4
+ import { fieldsOf, RECORD_MEMBERS } from "./types-record.js";
5
+ /** Whether a variant is a const string: a union of these alone is a string enum. */
6
+ export const isLiteral = (variant) => variant.kind === "const" && typeof variant.value === "string";
7
+ /** The values that select `variant`: its mapping keys, else its property's const or enum, else its ref's name. */
8
+ function selectors(variant, { mapping = {}, propertyName }, at) {
9
+ const mapped = Object.keys(mapping).filter((value) => variant.kind === "ref" && mapping[value] === variant.name);
10
+ if (mapped.length > 0)
11
+ return mapped;
12
+ const fields = fieldsOf(at.names.resolve(variant), at.names.resolve);
13
+ const property = fields.find((field) => field.name === propertyName)?.schema;
14
+ if (property?.kind === "const")
15
+ return [String(property.value)];
16
+ if (property?.kind === "scalar")
17
+ return enumValues(property).map(String);
18
+ return variant.kind === "ref" ? [variant.name] : [];
19
+ }
20
+ /** One variant per ref or inline-object variant, named after its first value, in code-unit order of it. */
21
+ function variantsOf(name, union, scope) {
22
+ const properties = new NameScope([...RECORD_MEMBERS, "Raw", name]);
23
+ const seen = new Set();
24
+ const variants = union.variants.flatMap((schema, i) => {
25
+ if (schema.kind !== "ref" && schema.kind !== "object")
26
+ return [];
27
+ const values = selectors(schema, union.discriminator, scope.at).filter((value) => !seen.has(value));
28
+ for (const value of values)
29
+ seen.add(value);
30
+ const first = values[0] ?? `Variant${i}`;
31
+ const type = schema.kind === "ref"
32
+ ? scope.member(schema, first)
33
+ : scope.declare(schema, `${name}.variant${i}`, `${name}${csTypeName(first)}`);
34
+ scope.at.serialized.add(type);
35
+ return [{ property: csTypeName(first), type, values }];
36
+ });
37
+ return variants
38
+ .sort((a, b) => compareCodeUnits(a.values[0] ?? "", b.values[0] ?? ""))
39
+ .map((variant) => ({ ...variant, property: properties.claim(variant.property) }));
40
+ }
41
+ /** `JsonTypeInfo<T>` of `type` from the converter's options. */
42
+ const info = (type) => `(JsonTypeInfo<${type}>)options.GetTypeInfo(typeof(${type}))`;
43
+ /** The converter's `Read`: the discriminator's string value selects a variant, the payload kept as `Raw`. */
44
+ const readLines = (name, property, variants) => [
45
+ ` public override ${name} Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)`,
46
+ " {",
47
+ " var raw = JsonElement.ParseValue(ref reader);",
48
+ ` var kind = raw.ValueKind == JsonValueKind.Object && raw.TryGetProperty(${csString(property)}, out var at) && at.ValueKind == JsonValueKind.String ? at.GetString() : null;`,
49
+ " return kind switch",
50
+ " {",
51
+ ...variants.flatMap((v) => v.values.map((value) => ` ${csString(value)} => new ${name} { ${v.property} = raw.Deserialize(${info(v.type)}), Raw = raw },`)),
52
+ ` _ => new ${name} { Raw = raw },`,
53
+ " };",
54
+ " }",
55
+ ];
56
+ /** The converter's `Write`: the set variant through its own type, else `Raw` as received, else null. */
57
+ function writeLines(name, variants) {
58
+ const arms = [
59
+ ...variants.map((v, i) => [
60
+ `value.${v.property} is { } variant${i}`,
61
+ `JsonSerializer.Serialize(writer, variant${i}, ${info(v.type)});`,
62
+ ]),
63
+ ["value.Raw.ValueKind != JsonValueKind.Undefined", "value.Raw.WriteTo(writer);"],
64
+ ];
65
+ return [
66
+ ` public override void Write(Utf8JsonWriter writer, ${name} value, JsonSerializerOptions options)`,
67
+ " {",
68
+ ...arms.flatMap(([test, write], i) => [
69
+ ` ${i > 0 ? "else " : ""}if (${test})`,
70
+ " {",
71
+ ` ${write}`,
72
+ " }",
73
+ ]),
74
+ " else",
75
+ " {",
76
+ " writer.WriteNullValue();",
77
+ " }",
78
+ " }",
79
+ ];
80
+ }
81
+ /** The record of `union`'s variants and `Raw`, then its converter. */
82
+ function discriminatedDecl(name, union, scope) {
83
+ const variants = variantsOf(name, union, scope);
84
+ const converter = scope.at.names.claim(`${name}Converter`);
85
+ const members = [
86
+ ...variants.map((v) => [` public ${v.type}? ${v.property} { get; init; }`]),
87
+ [
88
+ " /// <summary>The payload as received; the only member set for a value no variant declares.</summary>",
89
+ " public JsonElement Raw { get; init; }",
90
+ ],
91
+ ];
92
+ return [
93
+ `[JsonConverter(typeof(${converter}))]`,
94
+ `public sealed record ${name}`,
95
+ "{",
96
+ ...members.flatMap((lines, i) => [...(i > 0 ? [""] : []), ...lines]),
97
+ "}",
98
+ "",
99
+ `public sealed class ${converter} : JsonConverter<${name}>`,
100
+ "{",
101
+ ...readLines(name, union.discriminator.propertyName, variants),
102
+ "",
103
+ ...writeLines(name, variants),
104
+ "}",
105
+ ].join("\n");
106
+ }
107
+ /** The declaration of a union `declares`: a string enum of its const strings, or a discriminated record. */
108
+ export function unionDecl(name, union, scope) {
109
+ if (union.variants.every(isLiteral)) {
110
+ return stringEnumDecl(name, [...new Set(union.variants.map((variant) => variant.value))], scope.at);
111
+ }
112
+ return discriminatedDecl(name, union, scope);
113
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * C# types from the IR alone (H2): the type at a use position, a component's top-level declaration, and what both
3
+ * hoist into the context (§4.5): a string or integer enum, and a record for every inline object. C# has no
4
+ * namespace-level alias, so a scalar, array, map, const or plain-union component declares nothing and a ref to one
5
+ * is its use type. The context also gathers what the JSON context needs beyond the declarations: each collection's
6
+ * item types (Fb6) and the types only a converter reads. Spec text reaches the source only through the escape layer.
7
+ */
8
+ import type { IR, IRSchema } from "../../ir/model.ts";
9
+ import { type CsTypeNames } from "./types-names.ts";
10
+ export type { CsTypeNames } from "./types-names.ts";
11
+ /** Where a type is being written, the declarations it hoists, the names, and what the JSON context gathers. */
12
+ export type CsTypeContext = {
13
+ parentName: string;
14
+ fieldName: string;
15
+ decls: Map<string, string>;
16
+ names: CsTypeNames;
17
+ /** the declared enums: value types, so `T?` of one is `Nullable<T>` */
18
+ enums: Set<string>;
19
+ /** each collection type used, its item as written: `IReadOnlyList<string?>` (Fb6) */
20
+ collections: Set<string>;
21
+ /** the types a converter reads by `GetTypeInfo` alone: union variants and `Opt<T>`'s `T` (Fb7) */
22
+ serialized: Set<string>;
23
+ /** the declarations the JSON context never lists: a multipart `<Op>Body`, an `<Op>Headers` holder */
24
+ unlisted: Set<string>;
25
+ };
26
+ /** The C# type of `schema` at the member `fieldName` of the declaration being written. */
27
+ export type Member = (schema: IRSchema, fieldName: string) => string;
28
+ export declare const JSON_ELEMENT = "JsonElement";
29
+ /** A context over `ir`'s components (none without it), with `taken` reserved besides. */
30
+ export declare function csTypeContext(ir?: IR, taken?: readonly string[]): CsTypeContext;
31
+ /** Whether C# declares a type for a component of `ir`: an enum, a record, a discriminated or const-string union. */
32
+ export declare function declares(ir: IRSchema): boolean;
33
+ /** The C# type of `ir` in use position; what it hoists lands in `at.decls`. */
34
+ export declare function csTypeOf(ir: IRSchema, at: CsTypeContext): string;
35
+ /** The top-level declaration of the type `name` (a C# name already) for `ir`, which `declares`. */
36
+ export declare function csTopLevel(name: string, ir: IRSchema, at: CsTypeContext): string;