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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (558) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +619 -2
  3. package/bin/honey-clients.js +94 -0
  4. package/dist/cli.d.ts +102 -0
  5. package/dist/cli.js +190 -0
  6. package/dist/emit/cli/channels.d.ts +73 -0
  7. package/dist/emit/cli/channels.js +197 -0
  8. package/dist/emit/cli/commands.d.ts +27 -0
  9. package/dist/emit/cli/commands.js +187 -0
  10. package/dist/emit/cli/discovery.d.ts +35 -0
  11. package/dist/emit/cli/discovery.js +202 -0
  12. package/dist/emit/cli/flags.d.ts +59 -0
  13. package/dist/emit/cli/flags.js +186 -0
  14. package/dist/emit/cli/index.d.ts +1 -0
  15. package/dist/emit/cli/index.js +1 -0
  16. package/dist/emit/cli/install.d.ts +37 -0
  17. package/dist/emit/cli/install.js +88 -0
  18. package/dist/emit/cli/layout.d.ts +23 -0
  19. package/dist/emit/cli/layout.js +118 -0
  20. package/dist/emit/cli/module.d.ts +30 -0
  21. package/dist/emit/cli/module.js +186 -0
  22. package/dist/emit/cli/release.d.ts +40 -0
  23. package/dist/emit/cli/release.js +183 -0
  24. package/dist/emit/cli/skills.d.ts +11 -0
  25. package/dist/emit/cli/skills.js +56 -0
  26. package/dist/emit/csharp/errors.d.ts +7 -0
  27. package/dist/emit/csharp/errors.js +69 -0
  28. package/dist/emit/csharp/index.d.ts +1 -0
  29. package/dist/emit/csharp/index.js +1 -0
  30. package/dist/emit/csharp/json.d.ts +13 -0
  31. package/dist/emit/csharp/json.js +113 -0
  32. package/dist/emit/csharp/realtime.d.ts +10 -0
  33. package/dist/emit/csharp/realtime.js +33 -0
  34. package/dist/emit/csharp/sdk-answer.d.ts +48 -0
  35. package/dist/emit/csharp/sdk-answer.js +85 -0
  36. package/dist/emit/csharp/sdk-body.d.ts +10 -0
  37. package/dist/emit/csharp/sdk-body.js +87 -0
  38. package/dist/emit/csharp/sdk-client.d.ts +32 -0
  39. package/dist/emit/csharp/sdk-client.js +177 -0
  40. package/dist/emit/csharp/sdk-csproj.d.ts +36 -0
  41. package/dist/emit/csharp/sdk-csproj.js +136 -0
  42. package/dist/emit/csharp/sdk-doc.d.ts +12 -0
  43. package/dist/emit/csharp/sdk-doc.js +35 -0
  44. package/dist/emit/csharp/sdk-method.d.ts +26 -0
  45. package/dist/emit/csharp/sdk-method.js +187 -0
  46. package/dist/emit/csharp/sdk-plan.d.ts +38 -0
  47. package/dist/emit/csharp/sdk-plan.js +1 -0
  48. package/dist/emit/csharp/sdk.d.ts +40 -0
  49. package/dist/emit/csharp/sdk.js +105 -0
  50. package/dist/emit/csharp/sse.d.ts +18 -0
  51. package/dist/emit/csharp/sse.js +29 -0
  52. package/dist/emit/csharp/transport.d.ts +11 -0
  53. package/dist/emit/csharp/transport.js +67 -0
  54. package/dist/emit/csharp/types-enum.d.ts +19 -0
  55. package/dist/emit/csharp/types-enum.js +63 -0
  56. package/dist/emit/csharp/types-names.d.ts +33 -0
  57. package/dist/emit/csharp/types-names.js +182 -0
  58. package/dist/emit/csharp/types-record.d.ts +25 -0
  59. package/dist/emit/csharp/types-record.js +65 -0
  60. package/dist/emit/csharp/types-union.d.ts +27 -0
  61. package/dist/emit/csharp/types-union.js +113 -0
  62. package/dist/emit/csharp/types.d.ts +36 -0
  63. package/dist/emit/csharp/types.js +126 -0
  64. package/dist/emit/csharp/ws.d.ts +20 -0
  65. package/dist/emit/csharp/ws.js +14 -0
  66. package/dist/emit/go/errors.d.ts +7 -0
  67. package/dist/emit/go/errors.js +44 -0
  68. package/dist/emit/go/http.d.ts +11 -0
  69. package/dist/emit/go/http.js +50 -0
  70. package/dist/emit/go/index.d.ts +1 -0
  71. package/dist/emit/go/index.js +1 -0
  72. package/dist/emit/go/module-path.d.ts +2 -0
  73. package/dist/emit/go/module-path.js +27 -0
  74. package/dist/emit/go/sdk-answer.d.ts +28 -0
  75. package/dist/emit/go/sdk-answer.js +41 -0
  76. package/dist/emit/go/sdk-body.d.ts +24 -0
  77. package/dist/emit/go/sdk-body.js +76 -0
  78. package/dist/emit/go/sdk-client.d.ts +29 -0
  79. package/dist/emit/go/sdk-client.js +141 -0
  80. package/dist/emit/go/sdk-method.d.ts +68 -0
  81. package/dist/emit/go/sdk-method.js +172 -0
  82. package/dist/emit/go/sdk-mirror.d.ts +23 -0
  83. package/dist/emit/go/sdk-mirror.js +97 -0
  84. package/dist/emit/go/sdk-opts.d.ts +55 -0
  85. package/dist/emit/go/sdk-opts.js +100 -0
  86. package/dist/emit/go/sdk.d.ts +26 -0
  87. package/dist/emit/go/sdk.js +111 -0
  88. package/dist/emit/go/sse.d.ts +16 -0
  89. package/dist/emit/go/sse.js +26 -0
  90. package/dist/emit/go/types-codec.d.ts +15 -0
  91. package/dist/emit/go/types-codec.js +171 -0
  92. package/dist/emit/go/types-names.d.ts +14 -0
  93. package/dist/emit/go/types-names.js +64 -0
  94. package/dist/emit/go/types-struct.d.ts +29 -0
  95. package/dist/emit/go/types-struct.js +65 -0
  96. package/dist/emit/go/types-union.d.ts +17 -0
  97. package/dist/emit/go/types-union.js +84 -0
  98. package/dist/emit/go/types.d.ts +32 -0
  99. package/dist/emit/go/types.js +177 -0
  100. package/dist/emit/go/ws.d.ts +12 -0
  101. package/dist/emit/go/ws.js +70 -0
  102. package/dist/emit/java/gradle.d.ts +57 -0
  103. package/dist/emit/java/gradle.js +221 -0
  104. package/dist/emit/java/index.d.ts +2 -0
  105. package/dist/emit/java/index.js +2 -0
  106. package/dist/emit/java/json.d.ts +13 -0
  107. package/dist/emit/java/json.js +84 -0
  108. package/dist/emit/java/layout-ast.d.ts +146 -0
  109. package/dist/emit/java/layout-ast.js +102 -0
  110. package/dist/emit/java/layout-decl.d.ts +20 -0
  111. package/dist/emit/java/layout-decl.js +155 -0
  112. package/dist/emit/java/layout-doc.d.ts +55 -0
  113. package/dist/emit/java/layout-doc.js +166 -0
  114. package/dist/emit/java/layout-dot.d.ts +18 -0
  115. package/dist/emit/java/layout-dot.js +127 -0
  116. package/dist/emit/java/layout-strings.d.ts +8 -0
  117. package/dist/emit/java/layout-strings.js +76 -0
  118. package/dist/emit/java/layout-types.d.ts +11 -0
  119. package/dist/emit/java/layout-types.js +95 -0
  120. package/dist/emit/java/layout-visitor.d.ts +38 -0
  121. package/dist/emit/java/layout-visitor.js +232 -0
  122. package/dist/emit/java/layout.d.ts +61 -0
  123. package/dist/emit/java/layout.js +121 -0
  124. package/dist/emit/java/models-enum.d.ts +17 -0
  125. package/dist/emit/java/models-enum.js +51 -0
  126. package/dist/emit/java/models-names.d.ts +29 -0
  127. package/dist/emit/java/models-names.js +97 -0
  128. package/dist/emit/java/models-record.d.ts +24 -0
  129. package/dist/emit/java/models-record.js +79 -0
  130. package/dist/emit/java/models-union.d.ts +27 -0
  131. package/dist/emit/java/models-union.js +86 -0
  132. package/dist/emit/java/models.d.ts +28 -0
  133. package/dist/emit/java/models.js +118 -0
  134. package/dist/emit/java/realtime.d.ts +50 -0
  135. package/dist/emit/java/realtime.js +69 -0
  136. package/dist/emit/java/sdk-client.d.ts +66 -0
  137. package/dist/emit/java/sdk-client.js +207 -0
  138. package/dist/emit/java/sdk-decl.d.ts +11 -0
  139. package/dist/emit/java/sdk-decl.js +63 -0
  140. package/dist/emit/java/sdk-errors.d.ts +13 -0
  141. package/dist/emit/java/sdk-errors.js +141 -0
  142. package/dist/emit/java/sdk-headers.d.ts +12 -0
  143. package/dist/emit/java/sdk-headers.js +74 -0
  144. package/dist/emit/java/sdk-mirror.d.ts +14 -0
  145. package/dist/emit/java/sdk-mirror.js +107 -0
  146. package/dist/emit/java/sdk-models.d.ts +16 -0
  147. package/dist/emit/java/sdk-models.js +68 -0
  148. package/dist/emit/java/sdk-op.d.ts +57 -0
  149. package/dist/emit/java/sdk-op.js +216 -0
  150. package/dist/emit/java/sdk-params.d.ts +38 -0
  151. package/dist/emit/java/sdk-params.js +133 -0
  152. package/dist/emit/java/sdk-plan.d.ts +52 -0
  153. package/dist/emit/java/sdk-plan.js +1 -0
  154. package/dist/emit/java/sdk-record.d.ts +16 -0
  155. package/dist/emit/java/sdk-record.js +99 -0
  156. package/dist/emit/java/sdk.d.ts +49 -0
  157. package/dist/emit/java/sdk.js +216 -0
  158. package/dist/emit/java/sse.d.ts +35 -0
  159. package/dist/emit/java/sse.js +57 -0
  160. package/dist/emit/java/ws.d.ts +27 -0
  161. package/dist/emit/java/ws.js +31 -0
  162. package/dist/emit/mcp/annotations.d.ts +15 -0
  163. package/dist/emit/mcp/annotations.js +15 -0
  164. package/dist/emit/mcp/files.d.ts +18 -0
  165. package/dist/emit/mcp/files.js +42 -0
  166. package/dist/emit/mcp/index.d.ts +3 -0
  167. package/dist/emit/mcp/index.js +3 -0
  168. package/dist/emit/mcp/literal.d.ts +2 -0
  169. package/dist/emit/mcp/literal.js +33 -0
  170. package/dist/emit/mcp/mounted.d.ts +21 -0
  171. package/dist/emit/mcp/mounted.js +89 -0
  172. package/dist/emit/mcp/output-schema.d.ts +18 -0
  173. package/dist/emit/mcp/output-schema.js +38 -0
  174. package/dist/emit/mcp/registry.d.ts +23 -0
  175. package/dist/emit/mcp/registry.js +83 -0
  176. package/dist/emit/mcp/runtime.d.ts +10 -0
  177. package/dist/emit/mcp/runtime.js +47 -0
  178. package/dist/emit/mcp/schema.d.ts +19 -0
  179. package/dist/emit/mcp/schema.js +88 -0
  180. package/dist/emit/mcp/server.d.ts +30 -0
  181. package/dist/emit/mcp/server.js +246 -0
  182. package/dist/emit/mcp/tools.d.ts +51 -0
  183. package/dist/emit/mcp/tools.js +153 -0
  184. package/dist/emit/python/errors.d.ts +8 -0
  185. package/dist/emit/python/errors.js +68 -0
  186. package/dist/emit/python/index.d.ts +1 -0
  187. package/dist/emit/python/index.js +1 -0
  188. package/dist/emit/python/realtime.d.ts +10 -0
  189. package/dist/emit/python/realtime.js +33 -0
  190. package/dist/emit/python/sdk-answer.d.ts +49 -0
  191. package/dist/emit/python/sdk-answer.js +89 -0
  192. package/dist/emit/python/sdk-body.d.ts +11 -0
  193. package/dist/emit/python/sdk-body.js +40 -0
  194. package/dist/emit/python/sdk-client.d.ts +36 -0
  195. package/dist/emit/python/sdk-client.js +163 -0
  196. package/dist/emit/python/sdk-doc.d.ts +9 -0
  197. package/dist/emit/python/sdk-doc.js +32 -0
  198. package/dist/emit/python/sdk-imports.d.ts +14 -0
  199. package/dist/emit/python/sdk-imports.js +38 -0
  200. package/dist/emit/python/sdk-method.d.ts +29 -0
  201. package/dist/emit/python/sdk-method.js +183 -0
  202. package/dist/emit/python/sdk-plan.d.ts +33 -0
  203. package/dist/emit/python/sdk-plan.js +1 -0
  204. package/dist/emit/python/sdk-pyproject.d.ts +27 -0
  205. package/dist/emit/python/sdk-pyproject.js +103 -0
  206. package/dist/emit/python/sdk.d.ts +22 -0
  207. package/dist/emit/python/sdk.js +154 -0
  208. package/dist/emit/python/sse.d.ts +12 -0
  209. package/dist/emit/python/sse.js +23 -0
  210. package/dist/emit/python/transport.d.ts +15 -0
  211. package/dist/emit/python/transport.js +60 -0
  212. package/dist/emit/python/types-dict.d.ts +31 -0
  213. package/dist/emit/python/types-dict.js +45 -0
  214. package/dist/emit/python/types-names.d.ts +16 -0
  215. package/dist/emit/python/types-names.js +52 -0
  216. package/dist/emit/python/types-union.d.ts +32 -0
  217. package/dist/emit/python/types-union.js +46 -0
  218. package/dist/emit/python/types.d.ts +36 -0
  219. package/dist/emit/python/types.js +128 -0
  220. package/dist/emit/python/ws.d.ts +14 -0
  221. package/dist/emit/python/ws.js +16 -0
  222. package/dist/emit/rust/errors.d.ts +7 -0
  223. package/dist/emit/rust/errors.js +107 -0
  224. package/dist/emit/rust/http.d.ts +13 -0
  225. package/dist/emit/rust/http.js +67 -0
  226. package/dist/emit/rust/index.d.ts +1 -0
  227. package/dist/emit/rust/index.js +1 -0
  228. package/dist/emit/rust/realtime.d.ts +11 -0
  229. package/dist/emit/rust/realtime.js +29 -0
  230. package/dist/emit/rust/sdk-body.d.ts +19 -0
  231. package/dist/emit/rust/sdk-body.js +53 -0
  232. package/dist/emit/rust/sdk-cargo.d.ts +43 -0
  233. package/dist/emit/rust/sdk-cargo.js +178 -0
  234. package/dist/emit/rust/sdk-client.d.ts +25 -0
  235. package/dist/emit/rust/sdk-client.js +108 -0
  236. package/dist/emit/rust/sdk-method.d.ts +15 -0
  237. package/dist/emit/rust/sdk-method.js +119 -0
  238. package/dist/emit/rust/sdk-opts.d.ts +58 -0
  239. package/dist/emit/rust/sdk-opts.js +117 -0
  240. package/dist/emit/rust/sdk-plan.d.ts +33 -0
  241. package/dist/emit/rust/sdk-plan.js +1 -0
  242. package/dist/emit/rust/sdk.d.ts +23 -0
  243. package/dist/emit/rust/sdk.js +111 -0
  244. package/dist/emit/rust/sse.d.ts +19 -0
  245. package/dist/emit/rust/sse.js +20 -0
  246. package/dist/emit/rust/types-enum.d.ts +13 -0
  247. package/dist/emit/rust/types-enum.js +62 -0
  248. package/dist/emit/rust/types-names.d.ts +19 -0
  249. package/dist/emit/rust/types-names.js +66 -0
  250. package/dist/emit/rust/types-struct.d.ts +21 -0
  251. package/dist/emit/rust/types-struct.js +59 -0
  252. package/dist/emit/rust/types-union.d.ts +24 -0
  253. package/dist/emit/rust/types-union.js +97 -0
  254. package/dist/emit/rust/types.d.ts +34 -0
  255. package/dist/emit/rust/types.js +105 -0
  256. package/dist/emit/rust/ws.d.ts +21 -0
  257. package/dist/emit/rust/ws.js +20 -0
  258. package/dist/emit/shared/escape.d.ts +55 -0
  259. package/dist/emit/shared/escape.js +144 -0
  260. package/dist/emit/shared/format.d.ts +24 -0
  261. package/dist/emit/shared/format.js +23 -0
  262. package/dist/emit/shared/gofmt.d.ts +3 -0
  263. package/dist/emit/shared/gofmt.js +26 -0
  264. package/dist/emit/shared/lang.d.ts +60 -0
  265. package/dist/emit/shared/lang.js +233 -0
  266. package/dist/emit/shared/literals.d.ts +4 -0
  267. package/dist/emit/shared/literals.js +31 -0
  268. package/dist/emit/shared/metadata.d.ts +106 -0
  269. package/dist/emit/shared/metadata.js +130 -0
  270. package/dist/emit/shared/mirror.d.ts +22 -0
  271. package/dist/emit/shared/mirror.js +26 -0
  272. package/dist/emit/shared/ruff.d.ts +3 -0
  273. package/dist/emit/shared/ruff.js +31 -0
  274. package/dist/emit/shared/rustfmt.d.ts +3 -0
  275. package/dist/emit/shared/rustfmt.js +32 -0
  276. package/dist/emit/shared/status-keys.d.ts +7 -0
  277. package/dist/emit/shared/status-keys.js +67 -0
  278. package/dist/emit/shared/type-emitter.d.ts +19 -0
  279. package/dist/emit/shared/type-emitter.js +100 -0
  280. package/dist/emit/ts/app-client.d.ts +4 -0
  281. package/dist/emit/ts/app-client.js +68 -0
  282. package/dist/emit/ts/http.d.ts +20 -0
  283. package/dist/emit/ts/http.js +74 -0
  284. package/dist/emit/ts/package.d.ts +36 -0
  285. package/dist/emit/ts/package.js +126 -0
  286. package/dist/emit/ts/route-tree.d.ts +68 -0
  287. package/dist/emit/ts/route-tree.js +240 -0
  288. package/dist/emit/ts/sdk-types-preamble.d.ts +14 -0
  289. package/dist/emit/ts/sdk-types-preamble.js +123 -0
  290. package/dist/emit/ts/sdk-types.d.ts +13 -0
  291. package/dist/emit/ts/sdk-types.js +213 -0
  292. package/dist/emit/ts/sdk.d.ts +21 -0
  293. package/dist/emit/ts/sdk.js +173 -0
  294. package/dist/emit/ts/service-map.d.ts +40 -0
  295. package/dist/emit/ts/service-map.js +171 -0
  296. package/dist/emit/ts/tanstack-query.d.ts +12 -0
  297. package/dist/emit/ts/tanstack-query.js +156 -0
  298. package/dist/emit/ts/type-gen.d.ts +26 -0
  299. package/dist/emit/ts/type-gen.js +255 -0
  300. package/dist/emit/ts/webhooks.d.ts +19 -0
  301. package/dist/emit/ts/webhooks.js +81 -0
  302. package/dist/extract/chain.d.ts +34 -0
  303. package/dist/extract/chain.js +84 -0
  304. package/dist/extract/extract.d.ts +41 -0
  305. package/dist/extract/extract.js +191 -0
  306. package/dist/extract/serialize.d.ts +34 -0
  307. package/dist/extract/serialize.js +295 -0
  308. package/dist/extract/walk.d.ts +47 -0
  309. package/dist/extract/walk.js +109 -0
  310. package/dist/gen/args.d.ts +28 -0
  311. package/dist/gen/args.js +133 -0
  312. package/dist/gen/formatters.d.ts +62 -0
  313. package/dist/gen/formatters.js +146 -0
  314. package/dist/gen/process.d.ts +13 -0
  315. package/dist/gen/process.js +35 -0
  316. package/dist/gen/shipped.d.ts +17 -0
  317. package/dist/gen/shipped.js +55 -0
  318. package/dist/gen/targets.d.ts +93 -0
  319. package/dist/gen/targets.js +171 -0
  320. package/dist/gen/write.d.ts +33 -0
  321. package/dist/gen/write.js +118 -0
  322. package/dist/index.d.ts +13 -0
  323. package/dist/index.js +15 -0
  324. package/dist/ir/build.d.ts +37 -0
  325. package/dist/ir/build.js +152 -0
  326. package/dist/ir/load.d.ts +11 -0
  327. package/dist/ir/load.js +112 -0
  328. package/dist/ir/model.d.ts +206 -0
  329. package/dist/ir/model.js +5 -0
  330. package/dist/ir/resolve-refs.d.ts +11 -0
  331. package/dist/ir/resolve-refs.js +66 -0
  332. package/dist/ir/resource-tree.d.ts +9 -0
  333. package/dist/ir/resource-tree.js +53 -0
  334. package/dist/ir/route-tree-intern.d.ts +18 -0
  335. package/dist/ir/route-tree-intern.js +174 -0
  336. package/dist/ir/schema.d.ts +11 -0
  337. package/dist/ir/schema.js +192 -0
  338. package/dist/ir/sdk-model.d.ts +86 -0
  339. package/dist/ir/sdk-model.js +204 -0
  340. package/dist/ir/slots.d.ts +42 -0
  341. package/dist/ir/slots.js +245 -0
  342. package/dist/runtime/cli/body.go +176 -0
  343. package/dist/runtime/cli/config.go +243 -0
  344. package/dist/runtime/cli/discovery.go +147 -0
  345. package/dist/runtime/cli/format.go +174 -0
  346. package/dist/runtime/cli/log.go +117 -0
  347. package/dist/runtime/cli/output.go +247 -0
  348. package/dist/runtime/cli/params.go +197 -0
  349. package/dist/runtime/cli/run.go +226 -0
  350. package/dist/runtime/cli/socket.go +60 -0
  351. package/dist/runtime/cli/stream.go +217 -0
  352. package/dist/runtime/cli/target.go +117 -0
  353. package/dist/runtime/csharp/Adapters.cs +183 -0
  354. package/dist/runtime/csharp/Auth.cs +56 -0
  355. package/dist/runtime/csharp/Body.cs +135 -0
  356. package/dist/runtime/csharp/Config.cs +161 -0
  357. package/dist/runtime/csharp/Envelope.cs +149 -0
  358. package/dist/runtime/csharp/Errors.cs +194 -0
  359. package/dist/runtime/csharp/Events.cs +155 -0
  360. package/dist/runtime/csharp/Exchange.cs +247 -0
  361. package/dist/runtime/csharp/Handler.cs +103 -0
  362. package/dist/runtime/csharp/Hooks.cs +128 -0
  363. package/dist/runtime/csharp/Invalidation.cs +102 -0
  364. package/dist/runtime/csharp/Json.cs +144 -0
  365. package/dist/runtime/csharp/Log.cs +48 -0
  366. package/dist/runtime/csharp/Operation.cs +33 -0
  367. package/dist/runtime/csharp/Path.cs +65 -0
  368. package/dist/runtime/csharp/Query.cs +72 -0
  369. package/dist/runtime/csharp/Realtime.cs +118 -0
  370. package/dist/runtime/csharp/RealtimeLoop.cs +236 -0
  371. package/dist/runtime/csharp/Redirect.cs +53 -0
  372. package/dist/runtime/csharp/Result.cs +57 -0
  373. package/dist/runtime/csharp/Sse.cs +122 -0
  374. package/dist/runtime/csharp/Stale.cs +151 -0
  375. package/dist/runtime/csharp/Transport.cs +143 -0
  376. package/dist/runtime/csharp/TransportLongPoll.cs +63 -0
  377. package/dist/runtime/csharp/TransportSse.cs +54 -0
  378. package/dist/runtime/csharp/TransportWs.cs +40 -0
  379. package/dist/runtime/csharp/Wire.cs +109 -0
  380. package/dist/runtime/csharp/Ws.cs +300 -0
  381. package/dist/runtime/csharp/WsDial.cs +127 -0
  382. package/dist/runtime/go/auth.go +127 -0
  383. package/dist/runtime/go/body.go +129 -0
  384. package/dist/runtime/go/config.go +75 -0
  385. package/dist/runtime/go/errors.go +185 -0
  386. package/dist/runtime/go/export.go +37 -0
  387. package/dist/runtime/go/hooks.go +53 -0
  388. package/dist/runtime/go/invalidation.go +112 -0
  389. package/dist/runtime/go/log.go +92 -0
  390. package/dist/runtime/go/nullable.go +64 -0
  391. package/dist/runtime/go/options.go +118 -0
  392. package/dist/runtime/go/path.go +156 -0
  393. package/dist/runtime/go/query.go +147 -0
  394. package/dist/runtime/go/realtime.go +239 -0
  395. package/dist/runtime/go/realtime_loop.go +208 -0
  396. package/dist/runtime/go/redirect.go +124 -0
  397. package/dist/runtime/go/request.go +222 -0
  398. package/dist/runtime/go/result.go +86 -0
  399. package/dist/runtime/go/sse.go +186 -0
  400. package/dist/runtime/go/stale.go +229 -0
  401. package/dist/runtime/go/stream.go +105 -0
  402. package/dist/runtime/go/transport.go +242 -0
  403. package/dist/runtime/go/transport_longpoll.go +121 -0
  404. package/dist/runtime/go/transport_sse.go +175 -0
  405. package/dist/runtime/go/ws.go +205 -0
  406. package/dist/runtime/java/Answer.java +107 -0
  407. package/dist/runtime/java/ApiException.java +110 -0
  408. package/dist/runtime/java/BinaryBody.java +36 -0
  409. package/dist/runtime/java/Body.java +105 -0
  410. package/dist/runtime/java/Call.java +23 -0
  411. package/dist/runtime/java/CallLog.java +51 -0
  412. package/dist/runtime/java/ClientConfig.java +233 -0
  413. package/dist/runtime/java/ConnectionState.java +12 -0
  414. package/dist/runtime/java/Credential.java +58 -0
  415. package/dist/runtime/java/Deadline.java +38 -0
  416. package/dist/runtime/java/Decode.java +181 -0
  417. package/dist/runtime/java/Envelope.java +141 -0
  418. package/dist/runtime/java/ErrorEnvelope.java +23 -0
  419. package/dist/runtime/java/EventStream.java +129 -0
  420. package/dist/runtime/java/Exchange.java +62 -0
  421. package/dist/runtime/java/FilePart.java +5 -0
  422. package/dist/runtime/java/Flight.java +306 -0
  423. package/dist/runtime/java/HoneyException.java +14 -0
  424. package/dist/runtime/java/Hooks.java +47 -0
  425. package/dist/runtime/java/Hops.java +133 -0
  426. package/dist/runtime/java/InvalidationConfig.java +73 -0
  427. package/dist/runtime/java/Json.java +23 -0
  428. package/dist/runtime/java/Keepalive.java +60 -0
  429. package/dist/runtime/java/LogEntry.java +14 -0
  430. package/dist/runtime/java/LongPollAdapter.java +68 -0
  431. package/dist/runtime/java/Operation.java +21 -0
  432. package/dist/runtime/java/Opt.java +121 -0
  433. package/dist/runtime/java/Pump.java +160 -0
  434. package/dist/runtime/java/RawResponse.java +48 -0
  435. package/dist/runtime/java/Realtime.java +152 -0
  436. package/dist/runtime/java/RealtimeLoop.java +371 -0
  437. package/dist/runtime/java/RedirectPolicy.java +13 -0
  438. package/dist/runtime/java/Redirects.java +126 -0
  439. package/dist/runtime/java/RequestContext.java +78 -0
  440. package/dist/runtime/java/RequestHook.java +9 -0
  441. package/dist/runtime/java/RequestOptions.java +91 -0
  442. package/dist/runtime/java/ResponseContext.java +70 -0
  443. package/dist/runtime/java/ResponseHook.java +12 -0
  444. package/dist/runtime/java/Result.java +32 -0
  445. package/dist/runtime/java/ResumableConnection.java +165 -0
  446. package/dist/runtime/java/SdkException.java +11 -0
  447. package/dist/runtime/java/Socket.java +301 -0
  448. package/dist/runtime/java/Sse.java +171 -0
  449. package/dist/runtime/java/SseAdapter.java +61 -0
  450. package/dist/runtime/java/SseEvent.java +10 -0
  451. package/dist/runtime/java/StaleMeta.java +16 -0
  452. package/dist/runtime/java/StaleTracker.java +287 -0
  453. package/dist/runtime/java/Transport.java +16 -0
  454. package/dist/runtime/java/TransportAdapter.java +14 -0
  455. package/dist/runtime/java/TransportConnection.java +15 -0
  456. package/dist/runtime/java/TransportKind.java +12 -0
  457. package/dist/runtime/java/TransportMessage.java +9 -0
  458. package/dist/runtime/java/TransportOptions.java +138 -0
  459. package/dist/runtime/java/TypedWebSocket.java +83 -0
  460. package/dist/runtime/java/UrlPath.java +49 -0
  461. package/dist/runtime/java/UrlQuery.java +99 -0
  462. package/dist/runtime/java/WsAdapter.java +52 -0
  463. package/dist/runtime/java/WsClose.java +47 -0
  464. package/dist/runtime/java/WsDial.java +148 -0
  465. package/dist/runtime/java/WsMessage.java +18 -0
  466. package/dist/runtime/mcp/call.ts +167 -0
  467. package/dist/runtime/mcp/files.ts +183 -0
  468. package/dist/runtime/mcp/guard.ts +176 -0
  469. package/dist/runtime/mcp/http.ts +159 -0
  470. package/dist/runtime/mcp/jsonrpc.ts +50 -0
  471. package/dist/runtime/mcp/listen.ts +76 -0
  472. package/dist/runtime/mcp/mount.ts +123 -0
  473. package/dist/runtime/mcp/protocol.ts +219 -0
  474. package/dist/runtime/mcp/reader.ts +57 -0
  475. package/dist/runtime/mcp/result.ts +85 -0
  476. package/dist/runtime/mcp/stdio.ts +79 -0
  477. package/dist/runtime/mcp/stream.ts +62 -0
  478. package/dist/runtime/python/__init__.py +2 -0
  479. package/dist/runtime/python/auth.py +67 -0
  480. package/dist/runtime/python/body.py +83 -0
  481. package/dist/runtime/python/config.py +139 -0
  482. package/dist/runtime/python/errors.py +213 -0
  483. package/dist/runtime/python/events.py +152 -0
  484. package/dist/runtime/python/exchange.py +298 -0
  485. package/dist/runtime/python/hooks.py +86 -0
  486. package/dist/runtime/python/invalidation.py +57 -0
  487. package/dist/runtime/python/log.py +60 -0
  488. package/dist/runtime/python/operation.py +25 -0
  489. package/dist/runtime/python/path.py +41 -0
  490. package/dist/runtime/python/query.py +48 -0
  491. package/dist/runtime/python/realtime.py +244 -0
  492. package/dist/runtime/python/redirect.py +93 -0
  493. package/dist/runtime/python/result.py +58 -0
  494. package/dist/runtime/python/send_async.py +189 -0
  495. package/dist/runtime/python/send_sync.py +105 -0
  496. package/dist/runtime/python/sse.py +81 -0
  497. package/dist/runtime/python/stale.py +94 -0
  498. package/dist/runtime/python/transport.py +157 -0
  499. package/dist/runtime/python/transport_longpoll.py +60 -0
  500. package/dist/runtime/python/transport_sse.py +60 -0
  501. package/dist/runtime/python/transport_ws.py +57 -0
  502. package/dist/runtime/python/ws.py +276 -0
  503. package/dist/runtime/rust/Cargo.lock +1763 -0
  504. package/dist/runtime/rust/answer.rs +120 -0
  505. package/dist/runtime/rust/auth.rs +80 -0
  506. package/dist/runtime/rust/body.rs +150 -0
  507. package/dist/runtime/rust/call.rs +200 -0
  508. package/dist/runtime/rust/config.rs +254 -0
  509. package/dist/runtime/rust/envelope.rs +84 -0
  510. package/dist/runtime/rust/errors.rs +235 -0
  511. package/dist/runtime/rust/events.rs +177 -0
  512. package/dist/runtime/rust/exchange.rs +287 -0
  513. package/dist/runtime/rust/hooks.rs +63 -0
  514. package/dist/runtime/rust/invalidation.rs +84 -0
  515. package/dist/runtime/rust/log.rs +88 -0
  516. package/dist/runtime/rust/nullable.rs +13 -0
  517. package/dist/runtime/rust/path.rs +83 -0
  518. package/dist/runtime/rust/query.rs +84 -0
  519. package/dist/runtime/rust/realtime.rs +182 -0
  520. package/dist/runtime/rust/realtime_loop.rs +177 -0
  521. package/dist/runtime/rust/redirect.rs +121 -0
  522. package/dist/runtime/rust/request.rs +178 -0
  523. package/dist/runtime/rust/result.rs +101 -0
  524. package/dist/runtime/rust/sse.rs +104 -0
  525. package/dist/runtime/rust/stale.rs +209 -0
  526. package/dist/runtime/rust/transport.rs +221 -0
  527. package/dist/runtime/rust/transport_longpoll.rs +108 -0
  528. package/dist/runtime/rust/transport_sse.rs +91 -0
  529. package/dist/runtime/rust/transport_ws.rs +75 -0
  530. package/dist/runtime/rust/ws.rs +322 -0
  531. package/dist/runtime/ts/app-types.ts +200 -0
  532. package/dist/runtime/ts/app.ts +104 -0
  533. package/dist/runtime/ts/config.ts +124 -0
  534. package/dist/runtime/ts/defaults.ts +48 -0
  535. package/dist/runtime/ts/error.ts +113 -0
  536. package/dist/runtime/ts/hooks.ts +92 -0
  537. package/dist/runtime/ts/http.ts +228 -0
  538. package/dist/runtime/ts/media-type.ts +36 -0
  539. package/dist/runtime/ts/path.ts +152 -0
  540. package/dist/runtime/ts/realtime-connection.ts +296 -0
  541. package/dist/runtime/ts/realtime-transports.ts +149 -0
  542. package/dist/runtime/ts/realtime.ts +293 -0
  543. package/dist/runtime/ts/redirect-policy.ts +17 -0
  544. package/dist/runtime/ts/redirects.ts +74 -0
  545. package/dist/runtime/ts/request.ts +239 -0
  546. package/dist/runtime/ts/response.ts +219 -0
  547. package/dist/runtime/ts/sdk-realtime.ts +10 -0
  548. package/dist/runtime/ts/sdk-sse.ts +55 -0
  549. package/dist/runtime/ts/sdk-ws.ts +21 -0
  550. package/dist/runtime/ts/sdk.ts +242 -0
  551. package/dist/runtime/ts/sse.ts +175 -0
  552. package/dist/runtime/ts/stale.ts +137 -0
  553. package/dist/runtime/ts/stream.ts +87 -0
  554. package/dist/runtime/ts/webhook.ts +116 -0
  555. package/dist/runtime/ts/ws.ts +155 -0
  556. package/dist/runtime/ts-tanstack-query/invalidate.ts +152 -0
  557. package/dist/runtime/ts-tanstack-query/query.ts +261 -0
  558. package/package.json +84 -5
@@ -0,0 +1,109 @@
1
+ /**
2
+ * The program an app is read from: its tsconfig, the exported app, and every route registration in
3
+ * the program's own files. A registration is a `.handler()` call on a route builder, recognized by
4
+ * the type-only `$ctx`, `$method` and `$path` it carries, whatever method or helper started it.
5
+ */
6
+ import { existsSync } from "node:fs";
7
+ import { dirname, resolve } from "node:path";
8
+ import { compareCodeUnits } from "../emit/shared/lang.js";
9
+ /* the type-only members every route builder carries */
10
+ const BUILDER_MEMBERS = ["$ctx", "$method", "$path"];
11
+ /**
12
+ * The tsconfig that governs `fromPath`: the nearest one walking up, but never past the project root
13
+ * (the nearest directory with a package.json); a stray tsconfig above it is not this project's.
14
+ */
15
+ export function findTsConfig(fromPath) {
16
+ for (let dir = dirname(resolve(fromPath)), prev = ""; dir !== prev; prev = dir, dir = dirname(dir)) {
17
+ if (existsSync(resolve(dir, "tsconfig.json")))
18
+ return resolve(dir, "tsconfig.json");
19
+ if (existsSync(resolve(dir, "package.json")))
20
+ return undefined;
21
+ }
22
+ return undefined;
23
+ }
24
+ /**
25
+ * Load the entry and its app: `export const app`, an export list, an unexported declaration of the name, or `export default`.
26
+ * The program is the entry, what it imports, and the tsconfig's own declaration files: an ambient one that only
27
+ * `include` names (wrangler's `worker-configuration.d.ts`) declares globals the app's types use, as under `tsc -p`.
28
+ */
29
+ export function loadEntry(tsMorph, options) {
30
+ const tsConfigFilePath = options.tsconfigPath ?? findTsConfig(options.entryPath);
31
+ const project = new tsMorph.Project({ skipAddingFilesFromTsConfig: true, tsConfigFilePath });
32
+ project.addSourceFilesAtPaths(options.entryPath);
33
+ if (tsConfigFilePath !== undefined) {
34
+ const { ts } = tsMorph;
35
+ const { config } = ts.readConfigFile(tsConfigFilePath, ts.sys.readFile);
36
+ const { fileNames } = ts.parseJsonConfigFileContent(config, ts.sys, dirname(tsConfigFilePath));
37
+ for (const name of fileNames)
38
+ if (name.endsWith(".d.ts"))
39
+ project.addSourceFileAtPath(name);
40
+ }
41
+ project.resolveSourceFileDependencies();
42
+ const file = project.getSourceFileOrThrow(options.entryPath);
43
+ const decl = file.getExportedDeclarations().get(options.exportName)?.[0] ?? file.getVariableDeclaration(options.exportName);
44
+ if (decl === undefined)
45
+ throw new Error(`Export "${options.exportName}" not found in ${options.entryPath}`);
46
+ const checker = project.getTypeChecker().compilerObject;
47
+ /* for `export default <expr>` the declaration is the expression itself */
48
+ return { appType: checker.getTypeAtLocation(decl.compilerNode), checker, compiler: tsMorph.ts, project };
49
+ }
50
+ /** The string literal values among `type` (itself, or a union's members). */
51
+ function literals(type) {
52
+ return (type.isUnion() ? type.types : [type]).filter((t) => t.isStringLiteral()).map((t) => t.value);
53
+ }
54
+ /** The registration a call is, if it is `<route builder>.handler(…)`. */
55
+ function registrationOf(entry, call) {
56
+ const { checker, compiler } = entry;
57
+ if (!compiler.isPropertyAccessExpression(call.expression) || call.expression.name.text !== "handler")
58
+ return null;
59
+ const receiver = call.expression.expression;
60
+ const builder = checker.getTypeAtLocation(receiver);
61
+ const phantoms = BUILDER_MEMBERS.map((name) => {
62
+ const sym = builder.getProperty(name);
63
+ return sym === undefined ? undefined : checker.getTypeOfSymbol(sym);
64
+ });
65
+ if (phantoms.includes(undefined))
66
+ return null;
67
+ const [ctx, method, path] = phantoms;
68
+ /* the handler callback's ctx parameter carries `input`, which the builder's `$ctx` phantom leaves out */
69
+ const handler = checker.getResolvedSignature(call)?.parameters[0];
70
+ const param = handler && checker.getTypeOfSymbol(handler).getCallSignatures()[0]?.parameters[0];
71
+ const input = param && checker.getTypeOfSymbol(param).getProperty("input");
72
+ const params = param && checker.getTypeOfSymbol(param).getProperty("params");
73
+ const paramsType = params && checker.getTypeOfSymbol(params);
74
+ /* a param schema shows as a key that is not a string: only then does the path's own typing fall short */
75
+ const typed = paramsType
76
+ ?.getProperties()
77
+ .some((key) => !(checker.getTypeOfSymbol(key).flags & compiler.TypeFlags.String));
78
+ const file = call.getSourceFile();
79
+ const line = file.getLineAndCharacterOfPosition(call.getStart(file)).line + 1;
80
+ const paths = literals(path);
81
+ return {
82
+ at: `${file.fileName}:${line}`,
83
+ ctx: ctx,
84
+ input: input ? checker.getTypeOfSymbol(input) : null,
85
+ params: typed === true ? paramsType : null,
86
+ /* `.on()`'s methods are literals by its signature; a path is one only as a single literal */
87
+ methods: literals(method),
88
+ path: paths.length === 1 && !path.isUnion() ? paths[0] : null,
89
+ };
90
+ }
91
+ /** Every route the program's own files register (not declaration files, not packages), in file order then source order. */
92
+ export function registrations(entry) {
93
+ const { compiler } = entry;
94
+ const out = [];
95
+ const visit = (node) => {
96
+ const found = compiler.isCallExpression(node) ? registrationOf(entry, node) : null;
97
+ if (found !== null)
98
+ out.push(found);
99
+ compiler.forEachChild(node, visit);
100
+ };
101
+ const files = entry.project
102
+ .getSourceFiles()
103
+ .map((file) => file.compilerNode)
104
+ .filter((file) => !file.isDeclarationFile && !/[\\/]node_modules[\\/]/.test(file.fileName))
105
+ .sort((a, b) => compareCodeUnits(a.fileName, b.fileName));
106
+ for (const file of files)
107
+ visit(file);
108
+ return out;
109
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The generate CLI's arguments (bit 17 phase h): `generate --spec <file>|--app <module>[#export] --target <name>...
3
+ * --out <dir> [--watch]` (`--app`, bit 19 h2) and
4
+ * each target's options as `--<target>-<option>`, named after its generate function's options and passed through
5
+ * untouched (each generator validates its own). Strict: an unknown flag, a missing value, a stray argument, an unknown
6
+ * target or an option for a target not asked for is a usage error.
7
+ */
8
+ import { type Metadata } from "../emit/shared/metadata.ts";
9
+ import { type Target, type TargetOptions } from "./targets.ts";
10
+ /** What one `generate` run asks for: a spec file or an app module (one, never both). */
11
+ export type Generate = {
12
+ readonly app: string;
13
+ readonly spec: string;
14
+ readonly out: string;
15
+ readonly targets: readonly Target[];
16
+ readonly options: {
17
+ readonly [T in Target]: TargetOptions<T>;
18
+ };
19
+ readonly metadata: Metadata;
20
+ readonly watch: boolean;
21
+ };
22
+ /** The usage text, the options listed by target. */
23
+ export declare function usage(): string;
24
+ /** A mistake in how the CLI was called: printed with the usage text. */
25
+ export declare class UsageError extends Error {
26
+ }
27
+ /** `argv` after `generate` as a run, or a usage error. */
28
+ export declare function parseGenerate(argv: readonly string[]): Generate;
@@ -0,0 +1,133 @@
1
+ /**
2
+ * The generate CLI's arguments (bit 17 phase h): `generate --spec <file>|--app <module>[#export] --target <name>...
3
+ * --out <dir> [--watch]` (`--app`, bit 19 h2) and
4
+ * each target's options as `--<target>-<option>`, named after its generate function's options and passed through
5
+ * untouched (each generator validates its own). Strict: an unknown flag, a missing value, a stray argument, an unknown
6
+ * target or an option for a target not asked for is a usage error.
7
+ */
8
+ import { isListField, METADATA_FIELDS } from "../emit/shared/metadata.js";
9
+ import { isBooleanOption, TARGET_OPTIONS, TARGETS } from "./targets.js";
10
+ /** The usage text, the options listed by target. */
11
+ export function usage() {
12
+ return `usage: honey-clients generate (--spec <openapi.json> | --app <module>[#export]) --target <name>... --out <dir>
13
+ [--watch] [options]
14
+
15
+ --spec <file> the OpenAPI document (JSON) to generate from
16
+ --app <module> a honey app module instead: its export (#name, else app, else default) is the app, and its
17
+ openApi export, if any, the document's options (core's generateOpenApi); the module
18
+ exports the app and serves nothing: one that calls serve() as it loads is outside --app
19
+ --target <name> ${TARGETS.join(", ")}; repeat for more than one
20
+ --out <dir> each target's files go under <dir>/<target>
21
+ --watch generate again on each change of the spec or the app module
22
+ -h, --help this text
23
+
24
+ The package metadata every publishing target reads, given once as --metadata-<field> <value> (a target's own
25
+ option of the same meaning wins; authors and keywords comma separated):
26
+ ${METADATA_FIELDS.map((field) => `--metadata-${kebab(field)}`).join(" ")}
27
+
28
+ A target's options are its generator's, as --<target>-<option> <value>:
29
+ ${Object.entries(TARGET_OPTIONS)
30
+ .map(([target, options]) => ` ${target}: ${options.map((key) => `--${target}-${kebab(key)}`).join(" ")}`)
31
+ .join("\n")}
32
+
33
+ Each <out>/<target> keeps .honey-generated.json: the package it makes on each registry (registry, name, version),
34
+ and every file it wrote with its sha256. A regeneration deletes a file the last run wrote and this one does not,
35
+ unless it was edited since: that one is kept and named on stderr.
36
+ Nothing outside <out>/<target> is written or deleted, and no symlink is followed.
37
+ `;
38
+ }
39
+ /** A mistake in how the CLI was called: printed with the usage text. */
40
+ export class UsageError extends Error {
41
+ }
42
+ function kebab(key) {
43
+ return key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
44
+ }
45
+ /** The `--<target>-<option>` flag `flag` names: its target and its option's name; none for another flag. */
46
+ function optionFlag(flag) {
47
+ for (const [target, options] of Object.entries(TARGET_OPTIONS))
48
+ for (const key of options)
49
+ if (flag === `${target}-${kebab(key)}`)
50
+ return { key, target: target };
51
+ return undefined;
52
+ }
53
+ /** A flag's value: inline after `=`, else the next argument, which may not be another flag. */
54
+ function valueOf(flag, inline, rest) {
55
+ const value = inline ?? rest.shift();
56
+ if (value === undefined || value === "" || (inline === undefined && value.startsWith("--")))
57
+ throw new UsageError(`--${flag} requires a value`);
58
+ return value;
59
+ }
60
+ /** A boolean flag's value: bare is true; inline `true` or `false`, else a usage error. */
61
+ function booleanOf(flag, inline) {
62
+ if (inline === undefined || inline === "true")
63
+ return true;
64
+ if (inline === "false")
65
+ return false;
66
+ throw new UsageError(`--${flag} takes true or false, not ${JSON.stringify(inline)}`);
67
+ }
68
+ /** One flag of `generate` into `into`. */
69
+ function takeFlag(arg, rest, into) {
70
+ const [flag, inline] = arg.slice(2).split(/=(.*)/s, 2);
71
+ if (flag === "spec")
72
+ into.spec = valueOf(flag, inline, rest);
73
+ else if (flag === "app")
74
+ into.app = valueOf(flag, inline, rest);
75
+ else if (flag === "out")
76
+ into.out = valueOf(flag, inline, rest);
77
+ else if (flag === "watch")
78
+ into.watch = booleanOf(flag, inline);
79
+ else if (flag === "target") {
80
+ const target = valueOf(flag, inline, rest);
81
+ if (!TARGETS.includes(target))
82
+ throw new UsageError(`--target ${JSON.stringify(target)}: want one of ${TARGETS.join(", ")}`);
83
+ if (!into.targets.includes(target))
84
+ into.targets.push(target);
85
+ }
86
+ else if (flag.startsWith("metadata-")) {
87
+ const field = METADATA_FIELDS.find((name) => flag === `metadata-${kebab(name)}`);
88
+ if (field === undefined)
89
+ throw new UsageError(`unknown option --${flag}`);
90
+ const value = valueOf(flag, inline, rest);
91
+ const metadata = into.metadata;
92
+ metadata[field] = isListField(field) ? value.split(",").map((entry) => entry.trim()) : value;
93
+ }
94
+ else {
95
+ const option = optionFlag(flag);
96
+ if (option === undefined)
97
+ throw new UsageError(`unknown option --${flag}`);
98
+ into.options[option.target][option.key] = isBooleanOption(option.target, option.key)
99
+ ? String(booleanOf(flag, inline))
100
+ : valueOf(flag, inline, rest);
101
+ }
102
+ }
103
+ /** `argv` after `generate` as a run, or a usage error. */
104
+ export function parseGenerate(argv) {
105
+ const rest = [...argv];
106
+ const into = {
107
+ app: "",
108
+ metadata: {},
109
+ options: Object.fromEntries(TARGETS.map((target) => [target, {}])),
110
+ out: "",
111
+ spec: "",
112
+ targets: [],
113
+ watch: false,
114
+ };
115
+ while (rest.length > 0) {
116
+ const arg = rest.shift();
117
+ if (!arg.startsWith("--") || arg === "--")
118
+ throw new UsageError(`unexpected argument ${JSON.stringify(arg)}`);
119
+ takeFlag(arg, rest, into);
120
+ }
121
+ if (into.spec !== "" && into.app !== "")
122
+ throw new UsageError("--spec and --app each name the document: give one");
123
+ if (into.spec === "" && into.app === "")
124
+ throw new UsageError("--spec or --app is required");
125
+ if (into.out === "")
126
+ throw new UsageError("--out is required");
127
+ if (into.targets.length === 0)
128
+ throw new UsageError("--target is required");
129
+ const unasked = Object.entries(into.options).filter(([target, options]) => Object.keys(options).length > 0 && !into.targets.includes(target));
130
+ if (unasked.length > 0)
131
+ throw new UsageError(`options for ${unasked.map(([target]) => target).join(", ")}, which no --target names`);
132
+ return into;
133
+ }
@@ -0,0 +1,62 @@
1
+ import type { Formatter } from "../emit/shared/format.ts";
2
+ import type { Target } from "./targets.ts";
3
+ /**
4
+ * The gofmt the go and cli targets are formatted with: `$GOFMT`, else `$GOROOT/bin/gofmt`, else gofmt on PATH, else
5
+ * the gofmt beside the real `go` on PATH (where every Go install keeps it); none when no Go is installed. Found by
6
+ * looking, never by running Go.
7
+ */
8
+ export declare function findGofmt(env?: NodeJS.ProcessEnv): string | undefined;
9
+ /**
10
+ * The pinned ruff, or none: `RUFF` names it, else PATH. A named path that is not there counts as none, so a
11
+ * stale override is a skip with its own line rather than a spawn failure deep in the post-pass, which
12
+ * `formatFiles` would raise as though honey had emitted unparseable Python.
13
+ */
14
+ export declare function findRuff(env?: NodeJS.ProcessEnv): string | undefined;
15
+ /**
16
+ * The pinned rustfmt, or none: `RUSTFMT` names it, else PATH, else the active toolchain's own binary beside
17
+ * rustc. The rustup proxy on PATH would pick a toolchain by cwd, so a sysroot binary is preferred over it.
18
+ */
19
+ export declare function findRustfmt(env?: NodeJS.ProcessEnv): string | undefined;
20
+ /** oxfmt's `format`, the optional peer, when installed; else undefined (TS then goes out as emitted). */
21
+ export declare function loadOxfmt(specifier?: string): Promise<Formatter | undefined>;
22
+ /** What one target's formatting is: the extension the post-pass dispatches on, and what to say about the tool. */
23
+ export type FormatPass = {
24
+ readonly extension: string;
25
+ readonly install: string;
26
+ /**
27
+ * Say nothing when this one is absent. Only `ts`: oxfmt is honey's own choice of TS formatter and a
28
+ * declared optional peer, so a consumer is not expected to have it and "TS goes out as emitted" is the
29
+ * documented rule (Q12, `blueprint/00-rules.md`). ruff, rustfmt and gofmt are the language's own standard
30
+ * tools, which a developer of that language has — honey simply never called them, and silence there is
31
+ * what let unformatted Python ship.
32
+ */
33
+ readonly quiet?: true;
34
+ readonly tool: string;
35
+ };
36
+ /**
37
+ * Every target that has a formatter, one row each (F4). A target absent from this table has none in this
38
+ * repository and its files go out as the emitter wrote them, which is visible here rather than implied by a
39
+ * missing branch: `csharp` and `java` are absent because `dotnet format` and google-java-format work over a
40
+ * project rather than stdin and need a formatter `formatFiles` does not have yet.
41
+ */
42
+ export declare const FORMATTERS: Partial<Record<Target, FormatPass>>;
43
+ /**
44
+ * The formatter for `target`, or none when its binary is not there. Each factory is named here rather than
45
+ * held in the table's rows: `honey/spawn-timeout` proves which exports reach a spawn by walking named calls
46
+ * (`packages/core/lint/spawners.js`), and a closure in a table is opaque to that walk — which would leave a
47
+ * test calling `generated()` free of the bound it needs, since the spawn is real either way.
48
+ */
49
+ export declare function formatterFor(target: Target, where: {
50
+ env: NodeJS.ProcessEnv;
51
+ oxfmt?: string | undefined;
52
+ }): Promise<Formatter | undefined>;
53
+ /**
54
+ * A formatter that is not there: the files go out as emitted and the skip is named, so unformatted output is
55
+ * never silent. A consumer generating a Python SDK should not need ruff to get valid Python.
56
+ *
57
+ * `HONEY_REQUIRE_FORMATTERS=1` makes it fail instead, for a pipeline that would rather stop than ship
58
+ * unformatted code. Deliberately NOT `HONEY_REQUIRE_TOOLCHAINS`, which this repository's CI sets on six jobs
59
+ * to mean "these TESTS need their toolchain, do not skip" — reading it here turned every incidental
60
+ * generation in CI without oxfmt into a hard failure, which is how rc.10's release run died.
61
+ */
62
+ export declare function missingFormatter(target: Target, pass: FormatPass, env: NodeJS.ProcessEnv, report: (line: string) => void): void;
@@ -0,0 +1,146 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ /**
10
+ * How each target's files are formatted (F4): one row per target, the binary each row finds, and what a run
11
+ * says when it cannot find one. The pipeline reads this table and nothing else, so adding a language is a row
12
+ * rather than another branch, and a language with no row is visibly unformatted here instead of unformatted
13
+ * by omission.
14
+ */
15
+ import { existsSync, realpathSync, statSync } from "node:fs";
16
+ import { delimiter, dirname, join } from "node:path";
17
+ import { gofmtFormatter } from "../emit/shared/gofmt.js";
18
+ import { ruffFormatter } from "../emit/shared/ruff.js";
19
+ import { rustfmtFormatter } from "../emit/shared/rustfmt.js";
20
+ /**
21
+ * The binary a caller named through an environment variable, checked here at the edge. An override that
22
+ * points at nothing is a mistake in how the run was configured, so it is a named error: falling back to some
23
+ * other binary would ignore an explicit instruction, and spawning it would surface inside the post-pass,
24
+ * which raises a failure there as though honey had emitted source the formatter could not parse.
25
+ */
26
+ function named(variable, path) {
27
+ if (path === undefined || path === "")
28
+ return undefined;
29
+ if (!existsSync(path))
30
+ throw new Error(`${variable}=${path} is not there`);
31
+ return path;
32
+ }
33
+ /** An executable named `name` on PATH, or none. */
34
+ function onPath(name, env) {
35
+ return (env.PATH ?? "")
36
+ .split(delimiter)
37
+ .filter(Boolean)
38
+ .map((dir) => join(dir, name))
39
+ .find((path) => existsSync(path) && statSync(path).isFile());
40
+ }
41
+ /**
42
+ * The gofmt the go and cli targets are formatted with: `$GOFMT`, else `$GOROOT/bin/gofmt`, else gofmt on PATH, else
43
+ * the gofmt beside the real `go` on PATH (where every Go install keeps it); none when no Go is installed. Found by
44
+ * looking, never by running Go.
45
+ */
46
+ export function findGofmt(env = process.env) {
47
+ const override = named("GOFMT", env.GOFMT);
48
+ if (override !== undefined)
49
+ return override;
50
+ const fromRoot = env.GOROOT ? join(env.GOROOT, "bin", "gofmt") : undefined;
51
+ if (fromRoot !== undefined && existsSync(fromRoot))
52
+ return fromRoot;
53
+ const go = onPath("go", env);
54
+ const beside = go === undefined ? undefined : join(dirname(realpathSync(go)), "gofmt");
55
+ return onPath("gofmt", env) ?? (beside !== undefined && existsSync(beside) ? beside : undefined);
56
+ }
57
+ /**
58
+ * The pinned ruff, or none: `RUFF` names it, else PATH. A named path that is not there counts as none, so a
59
+ * stale override is a skip with its own line rather than a spawn failure deep in the post-pass, which
60
+ * `formatFiles` would raise as though honey had emitted unparseable Python.
61
+ */
62
+ export function findRuff(env = process.env) {
63
+ return named("RUFF", env.RUFF) ?? onPath("ruff", env);
64
+ }
65
+ /**
66
+ * The pinned rustfmt, or none: `RUSTFMT` names it, else PATH, else the active toolchain's own binary beside
67
+ * rustc. The rustup proxy on PATH would pick a toolchain by cwd, so a sysroot binary is preferred over it.
68
+ */
69
+ export function findRustfmt(env = process.env) {
70
+ const override = named("RUSTFMT", env.RUSTFMT);
71
+ if (override !== undefined)
72
+ return override;
73
+ const rustc = onPath("rustc", env);
74
+ const beside = rustc === undefined ? undefined : join(dirname(realpathSync(rustc)), "rustfmt");
75
+ return (beside !== undefined && existsSync(beside) ? beside : undefined) ?? onPath("rustfmt", env);
76
+ }
77
+ /** oxfmt's `format`, the optional peer, when installed; else undefined (TS then goes out as emitted). */
78
+ export async function loadOxfmt(specifier = "oxfmt") {
79
+ try {
80
+ return (await import(__rewriteRelativeImportExtension(specifier))).format;
81
+ }
82
+ catch (error) {
83
+ if (error.code === "ERR_MODULE_NOT_FOUND")
84
+ return undefined;
85
+ throw error;
86
+ }
87
+ }
88
+ const GO_PASS = { extension: "go", install: "install Go, or set GOFMT", tool: "gofmt" };
89
+ /**
90
+ * Every target that has a formatter, one row each (F4). A target absent from this table has none in this
91
+ * repository and its files go out as the emitter wrote them, which is visible here rather than implied by a
92
+ * missing branch: `csharp` and `java` are absent because `dotnet format` and google-java-format work over a
93
+ * project rather than stdin and need a formatter `formatFiles` does not have yet.
94
+ */
95
+ export const FORMATTERS = {
96
+ cli: GO_PASS,
97
+ go: GO_PASS,
98
+ python: { extension: "py", install: "install ruff, or set RUFF", tool: "ruff" },
99
+ rust: { extension: "rs", install: "install rustfmt, or set RUSTFMT", tool: "rustfmt" },
100
+ ts: { extension: "ts", install: "install oxfmt", quiet: true, tool: "oxfmt" },
101
+ };
102
+ /**
103
+ * The formatter for `target`, or none when its binary is not there. Each factory is named here rather than
104
+ * held in the table's rows: `honey/spawn-timeout` proves which exports reach a spawn by walking named calls
105
+ * (`packages/core/lint/spawners.js`), and a closure in a table is opaque to that walk — which would leave a
106
+ * test calling `generated()` free of the bound it needs, since the spawn is real either way.
107
+ */
108
+ export async function formatterFor(target, where) {
109
+ const { env, oxfmt } = where;
110
+ switch (target) {
111
+ case "cli":
112
+ case "go": {
113
+ const gofmt = findGofmt(env);
114
+ return gofmt === undefined ? undefined : gofmtFormatter(gofmt);
115
+ }
116
+ case "python": {
117
+ const ruff = findRuff(env);
118
+ return ruff === undefined ? undefined : ruffFormatter(ruff);
119
+ }
120
+ case "rust": {
121
+ const rustfmt = findRustfmt(env);
122
+ return rustfmt === undefined ? undefined : rustfmtFormatter(rustfmt);
123
+ }
124
+ case "ts":
125
+ return await loadOxfmt(oxfmt);
126
+ default:
127
+ return undefined;
128
+ }
129
+ }
130
+ /**
131
+ * A formatter that is not there: the files go out as emitted and the skip is named, so unformatted output is
132
+ * never silent. A consumer generating a Python SDK should not need ruff to get valid Python.
133
+ *
134
+ * `HONEY_REQUIRE_FORMATTERS=1` makes it fail instead, for a pipeline that would rather stop than ship
135
+ * unformatted code. Deliberately NOT `HONEY_REQUIRE_TOOLCHAINS`, which this repository's CI sets on six jobs
136
+ * to mean "these TESTS need their toolchain, do not skip" — reading it here turned every incidental
137
+ * generation in CI without oxfmt into a hard failure, which is how rc.10's release run died.
138
+ */
139
+ export function missingFormatter(target, pass, env, report) {
140
+ const said = `${pass.tool} was not found, so the ${target} output is not formatted (${pass.install})`;
141
+ /* an explicit demand is honoured for every target, quiet or not: the caller asked to be stopped */
142
+ if (env.HONEY_REQUIRE_FORMATTERS === "1")
143
+ throw new Error(said);
144
+ if (pass.quiet !== true)
145
+ report(`honey-clients: ${said}\n`);
146
+ }
@@ -0,0 +1,13 @@
1
+ /** argv that starts the package's `honey-clients` bin on the current runtime. */
2
+ export declare function cliInvocation(): [string, string];
3
+ /** How a child ended, as a failure names it: its signal, else its exit code. */
4
+ export declare const endOf: (code: number | null, signal: NodeJS.Signals | null) => string;
5
+ /**
6
+ * Runs `honey-clients <args>` in `cwd` with its output inherited, and resolves when it exits 0; any other end rejects
7
+ * with how it ended. A Bun handoff is never repeated in the child, and the child is marked HONEY_CODEGEN_CHILD, over
8
+ * any `env`, so it refuses `--watch`.
9
+ */
10
+ export declare function runCli(args: readonly string[], options: {
11
+ cwd: string;
12
+ env?: NodeJS.ProcessEnv;
13
+ }): Promise<void>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The generate CLI's child process (bit 17 phase h): watch mode runs each generation as a fresh `honey-clients`, so
3
+ * nothing one run loads outlives it. The child is the package's own bin on this runtime, which picks the entry as it
4
+ * does for a user (Bun the TypeScript source, a checkout the source through jiti, an install the compiled one).
5
+ */
6
+ import { spawn } from "node:child_process";
7
+ import { fileURLToPath } from "node:url";
8
+ /** argv that starts the package's `honey-clients` bin on the current runtime. */
9
+ export function cliInvocation() {
10
+ return [process.execPath, fileURLToPath(new URL("../../bin/honey-clients.js", import.meta.url))];
11
+ }
12
+ /** How a child ended, as a failure names it: its signal, else its exit code. */
13
+ export const endOf = (code, signal) => signal ?? `exit ${code}`;
14
+ /**
15
+ * Runs `honey-clients <args>` in `cwd` with its output inherited, and resolves when it exits 0; any other end rejects
16
+ * with how it ended. A Bun handoff is never repeated in the child, and the child is marked HONEY_CODEGEN_CHILD, over
17
+ * any `env`, so it refuses `--watch`.
18
+ */
19
+ export function runCli(args, options) {
20
+ const [command, bin] = cliInvocation();
21
+ return new Promise((resolve, reject) => {
22
+ const child = spawn(command, [bin, ...args], {
23
+ cwd: options.cwd,
24
+ env: { ...process.env, HONEY_NO_BUN_HANDOFF: "1", ...options.env, HONEY_CODEGEN_CHILD: "1" },
25
+ stdio: ["ignore", "inherit", "inherit"],
26
+ });
27
+ child.on("error", reject);
28
+ child.on("exit", (code, signal) => {
29
+ if (code === 0)
30
+ resolve();
31
+ else
32
+ reject(new Error(`honey-clients ${args[0] ?? ""} failed (${endOf(code, signal)})`));
33
+ });
34
+ });
35
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The files a package ships beside its code (plan 39 8.7): the README and the license file the run's metadata block
3
+ * names, read once per run and written into every target's root as `README.md` and `LICENSE`, the names each registry
4
+ * and forge reads. Each is UTF-8 text; one that cannot be read, or is not UTF-8, is refused naming its field. The icon
5
+ * ships only into the C# package, NuGet being the one registry that shows one: a PNG or JPEG of at most 1 MB, its
6
+ * bytes as given, refused when they are not the image its extension names.
7
+ */
8
+ import { type Metadata } from "../emit/shared/metadata.ts";
9
+ /** Reads a file the metadata block names, by its path as given: its bytes. */
10
+ export type ReadFile = (path: string) => Uint8Array;
11
+ /** What a run ships beside the code, by the name each file takes in a package's root: every package's, and the icon. */
12
+ export type ShippedFiles = {
13
+ readonly files: Readonly<Record<string, string>>;
14
+ readonly icon: Readonly<Record<string, Uint8Array>>;
15
+ };
16
+ /** The README, license file and icon `metadata` names. */
17
+ export declare function shippedFiles(metadata: Metadata, read: ReadFile): ShippedFiles;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The files a package ships beside its code (plan 39 8.7): the README and the license file the run's metadata block
3
+ * names, read once per run and written into every target's root as `README.md` and `LICENSE`, the names each registry
4
+ * and forge reads. Each is UTF-8 text; one that cannot be read, or is not UTF-8, is refused naming its field. The icon
5
+ * ships only into the C# package, NuGet being the one registry that shows one: a PNG or JPEG of at most 1 MB, its
6
+ * bytes as given, refused when they are not the image its extension names.
7
+ */
8
+ import { iconName, LICENSE, README } from "../emit/shared/metadata.js";
9
+ // per-process-constant: text-codec
10
+ const UTF8 = /* @__PURE__ */ new TextDecoder("utf-8", { fatal: true });
11
+ /* NuGet's cap on a package icon */
12
+ const ICON_BYTES = 1024 * 1024;
13
+ /* the signature each image format opens with, by the extensions that name it */
14
+ const PNG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
15
+ const JPEG = [0xff, 0xd8, 0xff];
16
+ /** The bytes of the file `metadata[field]` names, or a refusal naming the field. */
17
+ function bytesOf(field, path, read) {
18
+ try {
19
+ return read(path);
20
+ }
21
+ catch (error) {
22
+ const why = error.code ?? error.message;
23
+ throw new Error(`Invalid metadata.${field}: ${JSON.stringify(path)} cannot be read (${why})`, { cause: error });
24
+ }
25
+ }
26
+ /** The icon at `path`: a PNG or a JPEG as its extension names it, of at most 1 MB. */
27
+ function iconOf(path, read) {
28
+ const bytes = bytesOf("icon", path, read);
29
+ const signature = /\.png$/i.test(path) ? PNG : JPEG;
30
+ if (!signature.every((byte, i) => bytes[i] === byte))
31
+ throw new Error(`Invalid metadata.icon: ${JSON.stringify(path)} is not the image its extension names`);
32
+ if (bytes.length > ICON_BYTES)
33
+ throw new Error(`Invalid metadata.icon: ${JSON.stringify(path)} is over NuGet's 1 MB`);
34
+ return bytes;
35
+ }
36
+ /** The text of the file `metadata[field]` names, or a refusal naming the field. */
37
+ function textOf(field, path, read) {
38
+ const bytes = bytesOf(field, path, read);
39
+ try {
40
+ return UTF8.decode(bytes);
41
+ }
42
+ catch (error) {
43
+ throw new Error(`Invalid metadata.${field}: ${JSON.stringify(path)} is not UTF-8 text`, { cause: error });
44
+ }
45
+ }
46
+ /** The README, license file and icon `metadata` names. */
47
+ export function shippedFiles(metadata, read) {
48
+ const files = {};
49
+ if (metadata.readme !== undefined)
50
+ files[README] = textOf("readme", metadata.readme, read);
51
+ if (metadata.licenseFile !== undefined)
52
+ files[LICENSE] = textOf("licenseFile", metadata.licenseFile, read);
53
+ const { icon } = metadata;
54
+ return { files, icon: icon === undefined ? {} : { [iconName(icon)]: iconOf(icon, read) } };
55
+ }