ts-procedures 7.2.0 → 8.0.0

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 (325) hide show
  1. package/README.md +65 -3
  2. package/agent_config/claude-code/agents/ts-procedures-architect.md +6 -8
  3. package/agent_config/claude-code/skills/ts-procedures/SKILL.md +30 -33
  4. package/agent_config/claude-code/skills/ts-procedures/anti-patterns.md +139 -53
  5. package/agent_config/claude-code/skills/ts-procedures/api-reference.md +208 -231
  6. package/agent_config/claude-code/skills/ts-procedures/patterns.md +80 -153
  7. package/agent_config/claude-code/skills/ts-procedures-review/SKILL.md +1 -1
  8. package/agent_config/claude-code/skills/ts-procedures-review/checklist.md +4 -5
  9. package/agent_config/claude-code/skills/ts-procedures-scaffold/SKILL.md +4 -7
  10. package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono.md +223 -0
  11. package/agent_config/copilot/copilot-instructions.md +36 -48
  12. package/agent_config/cursor/cursorrules +36 -48
  13. package/build/client/call.js +4 -1
  14. package/build/client/call.js.map +1 -1
  15. package/build/client/call.test.js +23 -0
  16. package/build/client/call.test.js.map +1 -1
  17. package/build/client/fetch-adapter.js +3 -1
  18. package/build/client/fetch-adapter.js.map +1 -1
  19. package/build/client/fetch-adapter.test.js +11 -1
  20. package/build/client/fetch-adapter.test.js.map +1 -1
  21. package/build/client/index.test.js +7 -7
  22. package/build/client/index.test.js.map +1 -1
  23. package/build/client/request-builder.d.ts +1 -1
  24. package/build/client/request-builder.js +2 -2
  25. package/build/client/request-builder.js.map +1 -1
  26. package/build/client/stream.js +13 -2
  27. package/build/client/stream.js.map +1 -1
  28. package/build/client/stream.test.js +32 -7
  29. package/build/client/stream.test.js.map +1 -1
  30. package/build/client/typed-error-dispatch.test.js +8 -92
  31. package/build/client/typed-error-dispatch.test.js.map +1 -1
  32. package/build/client/types.d.ts +21 -3
  33. package/build/codegen/bin/cli.js +0 -0
  34. package/build/codegen/e2e.test.js +87 -23
  35. package/build/codegen/e2e.test.js.map +1 -1
  36. package/build/codegen/emit-errors.integration.test.js +1 -1
  37. package/build/codegen/emit-errors.integration.test.js.map +1 -1
  38. package/build/codegen/emit-scope.js +308 -47
  39. package/build/codegen/emit-scope.js.map +1 -1
  40. package/build/codegen/emit-scope.test.js +363 -110
  41. package/build/codegen/emit-scope.test.js.map +1 -1
  42. package/build/codegen/pipeline.test.js +7 -7
  43. package/build/codegen/pipeline.test.js.map +1 -1
  44. package/build/codegen/resolve-envelope.js +1 -1
  45. package/build/codegen/resolve-envelope.js.map +1 -1
  46. package/build/codegen/resolve-envelope.test.js +5 -5
  47. package/build/codegen/resolve-envelope.test.js.map +1 -1
  48. package/build/codegen/targets/_shared/route-slots.d.ts +8 -3
  49. package/build/codegen/targets/_shared/route-slots.js +49 -8
  50. package/build/codegen/targets/_shared/route-slots.js.map +1 -1
  51. package/build/codegen/targets/_shared/route-slots.test.js +99 -26
  52. package/build/codegen/targets/_shared/route-slots.test.js.map +1 -1
  53. package/build/codegen/targets/kotlin/emit-route-kotlin.test.js +88 -17
  54. package/build/codegen/targets/kotlin/emit-route-kotlin.test.js.map +1 -1
  55. package/build/codegen/targets/kotlin/emit-scope-kotlin.test.js +9 -6
  56. package/build/codegen/targets/kotlin/emit-scope-kotlin.test.js.map +1 -1
  57. package/build/codegen/targets/kotlin/integration.test.js +6 -0
  58. package/build/codegen/targets/kotlin/integration.test.js.map +1 -1
  59. package/build/codegen/targets/swift/access-level.test.js +8 -11
  60. package/build/codegen/targets/swift/access-level.test.js.map +1 -1
  61. package/build/codegen/targets/swift/emit-route-swift.test.js +91 -20
  62. package/build/codegen/targets/swift/emit-route-swift.test.js.map +1 -1
  63. package/build/codegen/targets/swift/emit-scope-swift.test.js +12 -9
  64. package/build/codegen/targets/swift/emit-scope-swift.test.js.map +1 -1
  65. package/build/codegen/targets/swift/integration.test.js +6 -0
  66. package/build/codegen/targets/swift/integration.test.js.map +1 -1
  67. package/build/create-http-stream.d.ts +58 -0
  68. package/build/create-http-stream.js +122 -0
  69. package/build/create-http-stream.js.map +1 -0
  70. package/build/create-http-stream.test.js +88 -0
  71. package/build/create-http-stream.test.js.map +1 -0
  72. package/build/create-http.d.ts +49 -0
  73. package/build/create-http.js +108 -0
  74. package/build/create-http.js.map +1 -0
  75. package/build/create-http.test.js +137 -0
  76. package/build/create-http.test.js.map +1 -0
  77. package/build/create-stream.d.ts +35 -0
  78. package/build/create-stream.js +123 -0
  79. package/build/create-stream.js.map +1 -0
  80. package/build/create-stream.test.js +428 -0
  81. package/build/create-stream.test.js.map +1 -0
  82. package/build/create.d.ts +28 -0
  83. package/build/create.js +82 -0
  84. package/build/create.js.map +1 -0
  85. package/build/create.test.js +483 -0
  86. package/build/create.test.js.map +1 -0
  87. package/build/exports.d.ts +2 -0
  88. package/build/implementations/http/astro/index.test.js +20 -12
  89. package/build/implementations/http/astro/index.test.js.map +1 -1
  90. package/build/implementations/http/doc-registry.js +1 -1
  91. package/build/implementations/http/doc-registry.js.map +1 -1
  92. package/build/implementations/http/doc-registry.test.js +36 -5
  93. package/build/implementations/http/doc-registry.test.js.map +1 -1
  94. package/build/implementations/http/error-dispatch.d.ts +76 -0
  95. package/build/implementations/http/error-dispatch.js +77 -0
  96. package/build/implementations/http/error-dispatch.js.map +1 -0
  97. package/build/implementations/http/error-dispatch.test.js +254 -0
  98. package/build/implementations/http/error-dispatch.test.js.map +1 -0
  99. package/build/implementations/http/error-taxonomy.d.ts +5 -5
  100. package/build/implementations/http/hono/docs/http-doc.d.ts +6 -0
  101. package/build/implementations/http/hono/docs/http-doc.js +42 -0
  102. package/build/implementations/http/hono/docs/http-doc.js.map +1 -0
  103. package/build/implementations/http/hono/docs/http-stream-doc.d.ts +6 -0
  104. package/build/implementations/http/hono/docs/http-stream-doc.js +40 -0
  105. package/build/implementations/http/hono/docs/http-stream-doc.js.map +1 -0
  106. package/build/implementations/http/hono/docs/rpc-doc.d.ts +6 -0
  107. package/build/implementations/http/hono/docs/rpc-doc.js +24 -0
  108. package/build/implementations/http/hono/docs/rpc-doc.js.map +1 -0
  109. package/build/implementations/http/hono/docs/stream-doc.d.ts +6 -0
  110. package/build/implementations/http/hono/docs/stream-doc.js +42 -0
  111. package/build/implementations/http/hono/docs/stream-doc.js.map +1 -0
  112. package/build/implementations/http/hono/handlers/http-stream.d.ts +10 -0
  113. package/build/implementations/http/hono/handlers/http-stream.js +123 -0
  114. package/build/implementations/http/hono/handlers/http-stream.js.map +1 -0
  115. package/build/implementations/http/hono/handlers/http-stream.test.js +128 -0
  116. package/build/implementations/http/hono/handlers/http-stream.test.js.map +1 -0
  117. package/build/implementations/http/hono/handlers/http.d.ts +10 -0
  118. package/build/implementations/http/hono/handlers/http.js +115 -0
  119. package/build/implementations/http/hono/handlers/http.js.map +1 -0
  120. package/build/implementations/http/hono/handlers/http.test.js +118 -0
  121. package/build/implementations/http/hono/handlers/http.test.js.map +1 -0
  122. package/build/implementations/http/hono/handlers/rpc.d.ts +11 -0
  123. package/build/implementations/http/hono/handlers/rpc.js +32 -0
  124. package/build/implementations/http/hono/handlers/rpc.js.map +1 -0
  125. package/build/implementations/http/hono/handlers/rpc.test.js +73 -0
  126. package/build/implementations/http/hono/handlers/rpc.test.js.map +1 -0
  127. package/build/implementations/http/hono/handlers/stream.d.ts +23 -0
  128. package/build/implementations/http/hono/handlers/stream.js +147 -0
  129. package/build/implementations/http/hono/handlers/stream.js.map +1 -0
  130. package/build/implementations/http/hono/handlers/stream.test.d.ts +1 -0
  131. package/build/implementations/http/hono/handlers/stream.test.js +177 -0
  132. package/build/implementations/http/hono/handlers/stream.test.js.map +1 -0
  133. package/build/implementations/http/hono/index.d.ts +57 -0
  134. package/build/implementations/http/hono/index.js +149 -0
  135. package/build/implementations/http/hono/index.js.map +1 -0
  136. package/build/implementations/http/hono/index.test.d.ts +1 -0
  137. package/build/implementations/http/hono/index.test.js +274 -0
  138. package/build/implementations/http/hono/index.test.js.map +1 -0
  139. package/build/implementations/http/hono/path.d.ts +17 -0
  140. package/build/implementations/http/hono/path.js +39 -0
  141. package/build/implementations/http/hono/path.js.map +1 -0
  142. package/build/implementations/http/hono/path.test.d.ts +1 -0
  143. package/build/implementations/http/hono/path.test.js +83 -0
  144. package/build/implementations/http/hono/path.test.js.map +1 -0
  145. package/build/implementations/http/hono/types.d.ts +51 -0
  146. package/build/implementations/http/hono/types.js.map +1 -0
  147. package/build/implementations/http/on-request-error.test.js +6 -96
  148. package/build/implementations/http/on-request-error.test.js.map +1 -1
  149. package/build/implementations/http/route-errors.test.js +11 -59
  150. package/build/implementations/http/route-errors.test.js.map +1 -1
  151. package/build/implementations/types.d.ts +43 -9
  152. package/build/index.d.ts +125 -115
  153. package/build/index.js +10 -222
  154. package/build/index.js.map +1 -1
  155. package/build/index.test.js +30 -822
  156. package/build/index.test.js.map +1 -1
  157. package/build/migration.test.d.ts +1 -0
  158. package/build/migration.test.js +34 -0
  159. package/build/migration.test.js.map +1 -0
  160. package/build/schema/compute-schema.d.ts +11 -3
  161. package/build/schema/compute-schema.js +13 -7
  162. package/build/schema/compute-schema.js.map +1 -1
  163. package/build/schema/parser.d.ts +11 -3
  164. package/build/schema/parser.js +49 -9
  165. package/build/schema/parser.js.map +1 -1
  166. package/build/stack-utils.js +8 -0
  167. package/build/stack-utils.js.map +1 -1
  168. package/build/types.d.ts +142 -0
  169. package/build/types.js.map +1 -0
  170. package/docs/astro-adapter.md +5 -5
  171. package/docs/core.md +34 -17
  172. package/docs/http-integrations.md +83 -170
  173. package/docs/streaming.md +3 -60
  174. package/docs/superpowers/plans/2026-05-07-astro-adapter.md +2 -7
  175. package/docs/superpowers/plans/2026-05-08-create-http.md +3355 -0
  176. package/docs/superpowers/plans/2026-05-08-hono-app-builder-convergence.md +3365 -0
  177. package/docs/superpowers/specs/2026-05-07-astro-adapter-design.md +1 -3
  178. package/docs/superpowers/specs/2026-05-08-create-http-design.md +409 -0
  179. package/docs/superpowers/specs/2026-05-08-hono-app-builder-convergence-design.md +411 -0
  180. package/package.json +4 -22
  181. package/src/client/call.test.ts +26 -0
  182. package/src/client/call.ts +4 -1
  183. package/src/client/fetch-adapter.test.ts +14 -1
  184. package/src/client/fetch-adapter.ts +3 -1
  185. package/src/client/index.test.ts +7 -7
  186. package/src/client/request-builder.ts +2 -2
  187. package/src/client/stream.test.ts +39 -7
  188. package/src/client/stream.ts +16 -2
  189. package/src/client/typed-error-dispatch.test.ts +7 -97
  190. package/src/client/types.ts +21 -3
  191. package/src/codegen/__fixtures__/users-envelope.json +119 -38
  192. package/src/codegen/e2e.test.ts +98 -24
  193. package/src/codegen/emit-errors.integration.test.ts +1 -1
  194. package/src/codegen/emit-scope.test.ts +395 -110
  195. package/src/codegen/emit-scope.ts +350 -55
  196. package/src/codegen/pipeline.test.ts +7 -7
  197. package/src/codegen/resolve-envelope.test.ts +5 -5
  198. package/src/codegen/resolve-envelope.ts +1 -1
  199. package/src/codegen/targets/_shared/route-slots.test.ts +109 -26
  200. package/src/codegen/targets/_shared/route-slots.ts +48 -11
  201. package/src/codegen/targets/kotlin/__fixtures__/users-golden.kt +73 -0
  202. package/src/codegen/targets/kotlin/emit-route-kotlin.test.ts +100 -17
  203. package/src/codegen/targets/kotlin/emit-scope-kotlin.test.ts +9 -6
  204. package/src/codegen/targets/kotlin/integration.test.ts +19 -0
  205. package/src/codegen/targets/swift/__fixtures__/users-golden.swift +79 -0
  206. package/src/codegen/targets/swift/access-level.test.ts +8 -11
  207. package/src/codegen/targets/swift/emit-route-swift.test.ts +103 -20
  208. package/src/codegen/targets/swift/emit-scope-swift.test.ts +12 -9
  209. package/src/codegen/targets/swift/integration.test.ts +17 -0
  210. package/src/create-http-stream.test.ts +97 -0
  211. package/src/create-http-stream.ts +191 -0
  212. package/src/create-http.test.ts +163 -0
  213. package/src/create-http.ts +211 -0
  214. package/src/create-stream.test.ts +565 -0
  215. package/src/create-stream.ts +228 -0
  216. package/src/create.test.ts +658 -0
  217. package/src/create.ts +172 -0
  218. package/src/exports.ts +2 -0
  219. package/src/implementations/http/README.md +135 -95
  220. package/src/implementations/http/astro/README.md +4 -5
  221. package/src/implementations/http/astro/index.test.ts +25 -18
  222. package/src/implementations/http/doc-registry.test.ts +42 -5
  223. package/src/implementations/http/doc-registry.ts +1 -1
  224. package/src/implementations/http/error-dispatch.test.ts +283 -0
  225. package/src/implementations/http/error-dispatch.ts +176 -0
  226. package/src/implementations/http/error-taxonomy.ts +5 -5
  227. package/src/implementations/http/hono/docs/http-doc.ts +43 -0
  228. package/src/implementations/http/hono/docs/http-stream-doc.ts +44 -0
  229. package/src/implementations/http/hono/docs/rpc-doc.ts +34 -0
  230. package/src/implementations/http/hono/docs/stream-doc.ts +53 -0
  231. package/src/implementations/http/hono/handlers/http-stream.test.ts +150 -0
  232. package/src/implementations/http/hono/handlers/http-stream.ts +152 -0
  233. package/src/implementations/http/hono/handlers/http.test.ts +130 -0
  234. package/src/implementations/http/hono/handlers/http.ts +147 -0
  235. package/src/implementations/http/hono/handlers/rpc.test.ts +81 -0
  236. package/src/implementations/http/hono/handlers/rpc.ts +54 -0
  237. package/src/implementations/http/hono/handlers/stream.test.ts +198 -0
  238. package/src/implementations/http/hono/handlers/stream.ts +208 -0
  239. package/src/implementations/http/hono/index.test.ts +329 -0
  240. package/src/implementations/http/hono/index.ts +204 -0
  241. package/src/implementations/http/hono/path.test.ts +96 -0
  242. package/src/implementations/http/hono/path.ts +59 -0
  243. package/src/implementations/http/hono/types.ts +93 -0
  244. package/src/implementations/http/on-request-error.test.ts +10 -116
  245. package/src/implementations/http/route-errors.test.ts +11 -77
  246. package/src/implementations/types.ts +44 -9
  247. package/src/index.test.ts +35 -1091
  248. package/src/index.ts +50 -474
  249. package/src/migration.test.ts +48 -0
  250. package/src/schema/compute-schema.ts +26 -12
  251. package/src/schema/parser.ts +62 -12
  252. package/src/stack-utils.ts +8 -0
  253. package/src/types.ts +133 -0
  254. package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/express-rpc.md +0 -137
  255. package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono-api.md +0 -173
  256. package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono-rpc.md +0 -142
  257. package/agent_config/claude-code/skills/ts-procedures-scaffold/templates/hono-stream.md +0 -147
  258. package/build/implementations/http/express-rpc/error-taxonomy.test.js +0 -83
  259. package/build/implementations/http/express-rpc/error-taxonomy.test.js.map +0 -1
  260. package/build/implementations/http/express-rpc/index.d.ts +0 -125
  261. package/build/implementations/http/express-rpc/index.js +0 -216
  262. package/build/implementations/http/express-rpc/index.js.map +0 -1
  263. package/build/implementations/http/express-rpc/index.test.js +0 -684
  264. package/build/implementations/http/express-rpc/index.test.js.map +0 -1
  265. package/build/implementations/http/express-rpc/types.d.ts +0 -11
  266. package/build/implementations/http/express-rpc/types.js.map +0 -1
  267. package/build/implementations/http/hono-api/error-taxonomy.test.js +0 -137
  268. package/build/implementations/http/hono-api/error-taxonomy.test.js.map +0 -1
  269. package/build/implementations/http/hono-api/index.d.ts +0 -151
  270. package/build/implementations/http/hono-api/index.js +0 -344
  271. package/build/implementations/http/hono-api/index.js.map +0 -1
  272. package/build/implementations/http/hono-api/index.test.js +0 -992
  273. package/build/implementations/http/hono-api/index.test.js.map +0 -1
  274. package/build/implementations/http/hono-api/types.d.ts +0 -13
  275. package/build/implementations/http/hono-api/types.js.map +0 -1
  276. package/build/implementations/http/hono-rpc/error-taxonomy.test.js +0 -64
  277. package/build/implementations/http/hono-rpc/error-taxonomy.test.js.map +0 -1
  278. package/build/implementations/http/hono-rpc/index.d.ts +0 -130
  279. package/build/implementations/http/hono-rpc/index.js +0 -209
  280. package/build/implementations/http/hono-rpc/index.js.map +0 -1
  281. package/build/implementations/http/hono-rpc/index.test.js +0 -828
  282. package/build/implementations/http/hono-rpc/index.test.js.map +0 -1
  283. package/build/implementations/http/hono-rpc/types.d.ts +0 -11
  284. package/build/implementations/http/hono-rpc/types.js +0 -2
  285. package/build/implementations/http/hono-rpc/types.js.map +0 -1
  286. package/build/implementations/http/hono-stream/error-taxonomy.test.js +0 -159
  287. package/build/implementations/http/hono-stream/error-taxonomy.test.js.map +0 -1
  288. package/build/implementations/http/hono-stream/index.d.ts +0 -171
  289. package/build/implementations/http/hono-stream/index.js +0 -415
  290. package/build/implementations/http/hono-stream/index.js.map +0 -1
  291. package/build/implementations/http/hono-stream/index.test.js +0 -1383
  292. package/build/implementations/http/hono-stream/index.test.js.map +0 -1
  293. package/build/implementations/http/hono-stream/types.d.ts +0 -15
  294. package/build/implementations/http/hono-stream/types.js +0 -2
  295. package/build/implementations/http/hono-stream/types.js.map +0 -1
  296. package/src/implementations/http/express-rpc/README.md +0 -280
  297. package/src/implementations/http/express-rpc/error-taxonomy.test.ts +0 -103
  298. package/src/implementations/http/express-rpc/index.test.ts +0 -957
  299. package/src/implementations/http/express-rpc/index.ts +0 -327
  300. package/src/implementations/http/express-rpc/types.ts +0 -16
  301. package/src/implementations/http/hono-api/README.md +0 -284
  302. package/src/implementations/http/hono-api/error-taxonomy.test.ts +0 -179
  303. package/src/implementations/http/hono-api/index.test.ts +0 -1341
  304. package/src/implementations/http/hono-api/index.ts +0 -519
  305. package/src/implementations/http/hono-api/types.ts +0 -16
  306. package/src/implementations/http/hono-rpc/README.md +0 -357
  307. package/src/implementations/http/hono-rpc/error-taxonomy.test.ts +0 -82
  308. package/src/implementations/http/hono-rpc/index.test.ts +0 -1107
  309. package/src/implementations/http/hono-rpc/index.ts +0 -320
  310. package/src/implementations/http/hono-rpc/types.ts +0 -16
  311. package/src/implementations/http/hono-stream/README.md +0 -559
  312. package/src/implementations/http/hono-stream/error-taxonomy.test.ts +0 -178
  313. package/src/implementations/http/hono-stream/index.test.ts +0 -1804
  314. package/src/implementations/http/hono-stream/index.ts +0 -622
  315. package/src/implementations/http/hono-stream/types.ts +0 -20
  316. /package/build/{implementations/http/express-rpc/error-taxonomy.test.d.ts → create-http-stream.test.d.ts} +0 -0
  317. /package/build/{implementations/http/express-rpc/index.test.d.ts → create-http.test.d.ts} +0 -0
  318. /package/build/{implementations/http/hono-api/error-taxonomy.test.d.ts → create-stream.test.d.ts} +0 -0
  319. /package/build/{implementations/http/hono-api/index.test.d.ts → create.test.d.ts} +0 -0
  320. /package/build/implementations/http/{hono-rpc/error-taxonomy.test.d.ts → error-dispatch.test.d.ts} +0 -0
  321. /package/build/implementations/http/{hono-rpc/index.test.d.ts → hono/handlers/http-stream.test.d.ts} +0 -0
  322. /package/build/implementations/http/{hono-stream/error-taxonomy.test.d.ts → hono/handlers/http.test.d.ts} +0 -0
  323. /package/build/implementations/http/{hono-stream/index.test.d.ts → hono/handlers/rpc.test.d.ts} +0 -0
  324. /package/build/implementations/http/{express-rpc → hono}/types.js +0 -0
  325. /package/build/{implementations/http/hono-api/types.js → types.js} +0 -0
@@ -1,415 +0,0 @@
1
- import { Hono } from 'hono';
2
- import { streamSSE, streamText } from 'hono/streaming';
3
- import { kebabCase } from 'es-toolkit/string';
4
- import { castArray } from 'es-toolkit/compat';
5
- import { ProcedureValidationError } from '../../../errors.js';
6
- import { defineErrorTaxonomy, resolveErrorResponse, } from '../error-taxonomy.js';
7
- export { defineErrorTaxonomy };
8
- const sseMetadata = new WeakMap();
9
- export function sse(data, options) {
10
- sseMetadata.set(data, options ?? {});
11
- return data;
12
- }
13
- function getSSEMeta(value) {
14
- if (typeof value === 'object' && value !== null) {
15
- return sseMetadata.get(value);
16
- }
17
- return undefined;
18
- }
19
- /**
20
- * Builder class for creating a Hono application with streaming RPC routes.
21
- *
22
- * Usage:
23
- * const StreamRPC = Procedures<StreamContext, RPCConfig>()
24
- *
25
- * const streamApp = new HonoStreamAppBuilder()
26
- * .register(StreamRPC, (c): Promise<StreamContext> => { /* context resolution logic * / })
27
- * .build();
28
- *
29
- * const app = streamApp.app; // Hono application
30
- * const docs = streamApp.docs; // Stream route documentation
31
- */
32
- export class HonoStreamAppBuilder {
33
- config;
34
- /**
35
- * Constructor for HonoStreamAppBuilder.
36
- */
37
- constructor(config) {
38
- this.config = config;
39
- if (config?.app) {
40
- this._app = config.app;
41
- }
42
- if (config?.onRequestStart) {
43
- this._app.use('*', async (c, next) => {
44
- config.onRequestStart(c);
45
- await next();
46
- });
47
- }
48
- }
49
- /**
50
- * Generates the stream route path based on the RPC configuration.
51
- */
52
- static makeStreamHttpRoutePath({ name, config, prefix, }) {
53
- const normalizedPrefix = prefix ? (prefix.startsWith('/') ? prefix : `/${prefix}`) : '';
54
- return `${normalizedPrefix}/${castArray(config.scope).map(kebabCase).join('/')}/${kebabCase(name)}/${String(config.version).trim()}`;
55
- }
56
- /**
57
- * Instance method wrapper for makeStreamHttpRoutePath that uses the builder's pathPrefix.
58
- */
59
- makeStreamHttpRoutePath(name, config) {
60
- return HonoStreamAppBuilder.makeStreamHttpRoutePath({
61
- name,
62
- config,
63
- prefix: this.config?.pathPrefix,
64
- });
65
- }
66
- factories = [];
67
- _app = new Hono();
68
- _docs = [];
69
- _skipped = [];
70
- get app() {
71
- return this._app;
72
- }
73
- get docs() {
74
- return this._docs;
75
- }
76
- /**
77
- * Procedures that were skipped at `build()` time because they don't fit
78
- * this builder (e.g. non-streaming procedures registered against the
79
- * stream builder). Surfaced via `DocSource.skippedProcedures` so
80
- * DocRegistry can warn about coverage gaps.
81
- */
82
- get skippedProcedures() {
83
- return this._skipped;
84
- }
85
- /**
86
- * Registers a procedure factory with its context.
87
- * Only streaming procedures (created with CreateStream) will be registered.
88
- */
89
- register(factory, factoryContext, options) {
90
- this.factories.push({
91
- factory,
92
- factoryContext,
93
- streamMode: options?.streamMode,
94
- extendProcedureDoc: options?.extendProcedureDoc,
95
- });
96
- return this;
97
- }
98
- /**
99
- * Creates a route handler for streaming procedures.
100
- */
101
- createStreamHandler(procedure, factoryContext, streamMode) {
102
- return async (c) => {
103
- try {
104
- const context = typeof factoryContext === 'function' ? await factoryContext(c) : factoryContext;
105
- // GET: query params, POST: JSON body
106
- const params = c.req.method === 'GET'
107
- ? Object.fromEntries(new URL(c.req.url).searchParams)
108
- : await c.req.json().catch(() => ({}));
109
- // Validate params BEFORE starting the stream. Throw so both the
110
- // validation path and the outer-catch (context resolution) path flow
111
- // through one dispatch site.
112
- if (procedure.config.validation?.params) {
113
- const { errors } = procedure.config.validation.params(params);
114
- if (errors) {
115
- throw new ProcedureValidationError(procedure.name, `Validation error for ${procedure.name}`, errors);
116
- }
117
- }
118
- if (this.config?.onStreamStart) {
119
- this.config.onStreamStart(procedure, c, streamMode);
120
- }
121
- if (streamMode === 'sse') {
122
- return this.handleSSEStream(procedure, context, params, c);
123
- }
124
- else {
125
- return this.handleTextStream(procedure, context, params, c);
126
- }
127
- }
128
- catch (error) {
129
- // Observer fires first — cross-cutting, cannot alter dispatch or the
130
- // response. Swallow any throw from the observer so the primary flow
131
- // never breaks because of instrumentation.
132
- if (this.config?.onRequestError) {
133
- try {
134
- await this.config.onRequestError({ err: error, procedure, raw: c });
135
- }
136
- catch (observerErr) {
137
- console.error('[ts-procedures hono-stream] onRequestError threw — swallowed:', observerErr);
138
- }
139
- }
140
- // Dispatch: taxonomy → onError → hard default. The two modes are
141
- // peers; developers configure whichever fits their app.
142
- if (this.config?.errors || this.config?.unknownError) {
143
- const resolved = resolveErrorResponse({
144
- err: error,
145
- userTaxonomy: this.config.errors,
146
- unknownError: this.config.unknownError,
147
- procedure,
148
- raw: c,
149
- });
150
- if (resolved) {
151
- await resolved.runOnCatch();
152
- return c.json(resolved.body, resolved.statusCode);
153
- }
154
- }
155
- if (this.config?.onError) {
156
- return this.config.onError(procedure, c, error);
157
- }
158
- return c.json({ error: error.message }, 500);
159
- }
160
- };
161
- }
162
- /**
163
- * Handles SSE streaming mode.
164
- */
165
- handleSSEStream(procedure, context, params, c) {
166
- return streamSSE(c, async (stream) => {
167
- // Pass isPrevalidated: true since we already validated params in createStreamHandler
168
- const generator = procedure.handler({ ...context, signal: c.req.raw.signal, isPrevalidated: true }, params);
169
- stream.onAbort(async () => {
170
- await generator.return(undefined);
171
- });
172
- let eventId = 0;
173
- try {
174
- const iterator = generator[Symbol.asyncIterator]();
175
- let iterResult = await iterator.next();
176
- while (!iterResult.done) {
177
- const value = iterResult.value;
178
- const currentId = eventId++;
179
- const meta = getSSEMeta(value);
180
- const data = typeof value === 'string'
181
- ? value
182
- : value != null
183
- ? JSON.stringify(value)
184
- : '';
185
- await stream.writeSSE({
186
- data,
187
- event: meta?.event ?? procedure.name,
188
- id: meta?.id ?? String(currentId),
189
- ...(meta?.retry !== undefined && { retry: meta.retry }),
190
- });
191
- iterResult = await iterator.next();
192
- }
193
- // Send return value as a special 'return' event (if present)
194
- if (iterResult.value !== undefined) {
195
- const returnData = typeof iterResult.value === 'string'
196
- ? iterResult.value
197
- : JSON.stringify(iterResult.value);
198
- await stream.writeSSE({
199
- data: returnData,
200
- event: 'return',
201
- id: String(eventId++),
202
- });
203
- }
204
- }
205
- catch (error) {
206
- // Dispatch order mirrors hono-rpc: taxonomy → onMidStreamError → default.
207
- // The HTTP status is already committed (200 OK headers were sent the
208
- // moment streaming started), so the taxonomy here only drives the
209
- // wire-protocol body shape — clients dispatch through the same error
210
- // registry as RPC/API responses by reading `data.name`.
211
- let errorData;
212
- let sseEventOverride;
213
- let sseIdOverride;
214
- let sseRetryOverride;
215
- let runOnCatch;
216
- if (this.config?.errors || this.config?.unknownError) {
217
- const resolved = resolveErrorResponse({
218
- err: error,
219
- userTaxonomy: this.config.errors,
220
- unknownError: this.config.unknownError,
221
- procedure,
222
- raw: c,
223
- });
224
- if (resolved) {
225
- errorData = resolved.body;
226
- sseEventOverride = 'error';
227
- runOnCatch = resolved.runOnCatch;
228
- }
229
- }
230
- if (errorData === undefined && this.config?.onMidStreamError) {
231
- const errorResult = this.config.onMidStreamError(procedure, c, error);
232
- if (errorResult?.data !== undefined) {
233
- errorData = errorResult.data;
234
- sseEventOverride = procedure.name;
235
- }
236
- }
237
- if (errorData === undefined) {
238
- errorData = { error: error.message };
239
- sseEventOverride = 'error';
240
- }
241
- const sseMeta = getSSEMeta(errorData);
242
- await stream.writeSSE({
243
- data: typeof errorData === 'string' ? errorData : JSON.stringify(errorData),
244
- event: sseMeta?.event ?? sseEventOverride ?? 'error',
245
- id: sseMeta?.id ?? sseIdOverride ?? String(eventId++),
246
- ...((sseMeta?.retry ?? sseRetryOverride) !== undefined && {
247
- retry: (sseMeta?.retry ?? sseRetryOverride),
248
- }),
249
- });
250
- if (runOnCatch) {
251
- await runOnCatch();
252
- }
253
- // closeStream defaults to true if not specified
254
- // (stream closes naturally after this handler completes)
255
- }
256
- finally {
257
- if (this.config?.onStreamEnd) {
258
- this.config.onStreamEnd(procedure, c, 'sse');
259
- }
260
- if (this.config?.onRequestEnd) {
261
- this.config.onRequestEnd(c);
262
- }
263
- }
264
- });
265
- }
266
- /**
267
- * Handles text streaming mode.
268
- */
269
- handleTextStream(procedure, context, params, c) {
270
- return streamText(c, async (stream) => {
271
- // Pass isPrevalidated: true since we already validated params in createStreamHandler
272
- const generator = procedure.handler({ ...context, signal: c.req.raw.signal, isPrevalidated: true }, params);
273
- stream.onAbort(async () => {
274
- await generator.return(undefined);
275
- });
276
- try {
277
- for await (const value of generator) {
278
- await stream.writeln(JSON.stringify(value));
279
- }
280
- }
281
- catch (error) {
282
- // Same dispatch order as SSE — taxonomy first, onMidStreamError next,
283
- // hard default last. Text streams have no event/id metadata, so we
284
- // only forward the body bytes.
285
- let errorData;
286
- let runOnCatch;
287
- if (this.config?.errors || this.config?.unknownError) {
288
- const resolved = resolveErrorResponse({
289
- err: error,
290
- userTaxonomy: this.config.errors,
291
- unknownError: this.config.unknownError,
292
- procedure,
293
- raw: c,
294
- });
295
- if (resolved) {
296
- errorData = resolved.body;
297
- runOnCatch = resolved.runOnCatch;
298
- }
299
- }
300
- if (errorData === undefined && this.config?.onMidStreamError) {
301
- const errorResult = this.config.onMidStreamError(procedure, c, error);
302
- if (errorResult?.data !== undefined) {
303
- errorData = errorResult.data;
304
- }
305
- }
306
- if (errorData === undefined) {
307
- errorData = { error: error.message };
308
- }
309
- await stream.writeln(JSON.stringify(errorData));
310
- if (runOnCatch) {
311
- await runOnCatch();
312
- }
313
- }
314
- finally {
315
- if (this.config?.onStreamEnd) {
316
- this.config.onStreamEnd(procedure, c, 'text');
317
- }
318
- if (this.config?.onRequestEnd) {
319
- this.config.onRequestEnd(c);
320
- }
321
- }
322
- });
323
- }
324
- /**
325
- * Builds and returns the Hono application with registered streaming routes.
326
- */
327
- build() {
328
- this.factories.forEach(({ factory, factoryContext, streamMode, extendProcedureDoc }) => {
329
- const mode = streamMode ?? this.config?.defaultStreamMode ?? 'sse';
330
- const procedures = factory.getProcedures();
331
- // Track non-streaming procedures so DocRegistry can warn about coverage
332
- // gaps (e.g. a regular procedure registered with this builder will get
333
- // dropped here and needs to be registered with HonoRPCAppBuilder).
334
- for (const p of procedures) {
335
- if (p.isStream !== true) {
336
- const reason = 'Non-streaming procedure registered with HonoStreamAppBuilder — register it with HonoRPCAppBuilder (or HonoApiAppBuilder) instead.';
337
- this._skipped.push({ name: p.name, reason });
338
- console.warn(`[ts-procedures hono-stream] Skipping procedure "${p.name}": ${reason}`);
339
- }
340
- }
341
- procedures
342
- .filter((p) => p.isStream === true)
343
- .forEach((procedure) => {
344
- const route = this.buildStreamHttpRouteDoc(procedure, mode, extendProcedureDoc);
345
- this._docs.push(route);
346
- const handler = this.createStreamHandler(procedure, factoryContext, mode);
347
- // Register both GET and POST handlers
348
- this._app.get(route.path, handler);
349
- this._app.post(route.path, handler);
350
- });
351
- });
352
- return this._app;
353
- }
354
- /**
355
- * Generates the Stream HTTP route documentation for the given procedure.
356
- */
357
- buildStreamHttpRouteDoc(procedure, streamMode, extendProcedureDoc) {
358
- const { config } = procedure;
359
- const path = HonoStreamAppBuilder.makeStreamHttpRoutePath({
360
- name: procedure.name,
361
- config,
362
- prefix: this.config?.pathPrefix,
363
- });
364
- // POST first so codegen (which uses `methods[0]`) defaults to POST. POST is
365
- // the canonical method for streaming procedures because it can carry a body
366
- // for params; GET is the supplementary method for query-string callers.
367
- const methods = ['post', 'get'];
368
- const jsonSchema = {};
369
- if (config.schema?.params) {
370
- jsonSchema.params = config.schema.params;
371
- }
372
- if (streamMode === 'sse') {
373
- jsonSchema.yieldType = {
374
- type: 'object',
375
- description: 'SSE message envelope. The data field contains the procedure yield value.',
376
- required: ['data', 'event', 'id'],
377
- properties: {
378
- data: config.schema?.yieldType ?? {},
379
- event: { type: 'string' },
380
- id: { type: 'string' },
381
- retry: { type: 'number' },
382
- },
383
- };
384
- }
385
- else if (config.schema?.yieldType) {
386
- // Text mode: pass through as-is
387
- jsonSchema.yieldType = config.schema.yieldType;
388
- }
389
- if (config.schema?.returnType) {
390
- jsonSchema.returnType = config.schema.returnType;
391
- }
392
- const base = {
393
- kind: 'stream',
394
- name: procedure.name,
395
- version: config.version,
396
- scope: config.scope,
397
- path,
398
- methods: [...methods],
399
- streamMode,
400
- jsonSchema,
401
- };
402
- if (config.errors && config.errors.length > 0) {
403
- base.errors = [...config.errors];
404
- }
405
- let extendedDoc = {};
406
- if (extendProcedureDoc) {
407
- extendedDoc = extendProcedureDoc({ base, procedure });
408
- }
409
- return {
410
- ...extendedDoc,
411
- ...base,
412
- };
413
- }
414
- }
415
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/implementations/http/hono-stream/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAW,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAI7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAIL,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAAE,mBAAmB,EAAE,CAAA;AAoB9B,MAAM,WAAW,GAAG,IAAI,OAAO,EAAsB,CAAA;AAErD,MAAM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