@fuzdev/fuz_app 0.180.0 → 0.181.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 (358) hide show
  1. package/dist/actions/CLAUDE.md +14 -14
  2. package/dist/actions/action_rpc.d.ts +14 -5
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +53 -46
  5. package/dist/actions/action_types.d.ts +15 -12
  6. package/dist/actions/action_types.d.ts.map +1 -1
  7. package/dist/actions/perform_action.d.ts +4 -4
  8. package/dist/actions/perform_action.d.ts.map +1 -1
  9. package/dist/actions/perform_action.js +6 -6
  10. package/dist/actions/register_action_ws.d.ts +6 -2
  11. package/dist/actions/register_action_ws.d.ts.map +1 -1
  12. package/dist/actions/register_action_ws.js +14 -3
  13. package/dist/actions/ws_socket_session.js +1 -1
  14. package/dist/auth/CLAUDE.md +36 -30
  15. package/dist/auth/account_actions.d.ts.map +1 -1
  16. package/dist/auth/account_actions.js +18 -1
  17. package/dist/auth/account_queries.d.ts +69 -0
  18. package/dist/auth/account_queries.d.ts.map +1 -1
  19. package/dist/auth/account_queries.js +82 -0
  20. package/dist/auth/account_route_schema.d.ts +26 -16
  21. package/dist/auth/account_route_schema.d.ts.map +1 -1
  22. package/dist/auth/account_route_schema.js +10 -24
  23. package/dist/auth/account_routes.d.ts +4 -6
  24. package/dist/auth/account_routes.d.ts.map +1 -1
  25. package/dist/auth/account_routes.js +86 -66
  26. package/dist/auth/admin_actions.d.ts.map +1 -1
  27. package/dist/auth/admin_actions.js +63 -14
  28. package/dist/auth/api_token_queries.d.ts +16 -7
  29. package/dist/auth/api_token_queries.d.ts.map +1 -1
  30. package/dist/auth/api_token_queries.js +18 -18
  31. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  32. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  33. package/dist/auth/audit_log_routes.d.ts +1 -1
  34. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  35. package/dist/auth/audit_log_routes.js +10 -12
  36. package/dist/auth/audit_log_schema.js +4 -4
  37. package/dist/auth/bearer_auth.d.ts +4 -3
  38. package/dist/auth/bearer_auth.d.ts.map +1 -1
  39. package/dist/auth/bearer_auth.js +35 -31
  40. package/dist/auth/bootstrap_account.d.ts +65 -37
  41. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  42. package/dist/auth/bootstrap_account.js +115 -66
  43. package/dist/auth/bootstrap_route_schema.d.ts +6 -2
  44. package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_route_schema.js +7 -2
  46. package/dist/auth/bootstrap_routes.d.ts +50 -33
  47. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_routes.js +109 -87
  49. package/dist/auth/bootstrap_token_store.d.ts +60 -0
  50. package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
  51. package/dist/auth/bootstrap_token_store.js +39 -0
  52. package/dist/auth/credential_headers.d.ts +71 -0
  53. package/dist/auth/credential_headers.d.ts.map +1 -0
  54. package/dist/auth/credential_headers.js +100 -0
  55. package/dist/auth/daemon_token.d.ts +13 -1
  56. package/dist/auth/daemon_token.d.ts.map +1 -1
  57. package/dist/auth/daemon_token.js +14 -2
  58. package/dist/auth/daemon_token_middleware.d.ts +10 -11
  59. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  60. package/dist/auth/daemon_token_middleware.js +27 -29
  61. package/dist/auth/deps.d.ts +0 -11
  62. package/dist/auth/deps.d.ts.map +1 -1
  63. package/dist/auth/invite_queries.d.ts +18 -0
  64. package/dist/auth/invite_queries.d.ts.map +1 -1
  65. package/dist/auth/invite_queries.js +24 -0
  66. package/dist/auth/request_context.d.ts +26 -5
  67. package/dist/auth/request_context.d.ts.map +1 -1
  68. package/dist/auth/request_context.js +17 -10
  69. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  70. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  71. package/dist/auth/role_grant_offer_action_specs.js +3 -2
  72. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  73. package/dist/auth/role_grant_offer_actions.js +37 -14
  74. package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
  75. package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
  76. package/dist/auth/role_grant_offer_ddl.js +9 -2
  77. package/dist/auth/role_grant_offer_queries.d.ts +56 -3
  78. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  79. package/dist/auth/role_grant_offer_queries.js +93 -8
  80. package/dist/auth/role_grant_queries.d.ts +7 -0
  81. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  82. package/dist/auth/role_grant_queries.js +8 -0
  83. package/dist/auth/session_cookie.d.ts +105 -25
  84. package/dist/auth/session_cookie.d.ts.map +1 -1
  85. package/dist/auth/session_cookie.js +124 -15
  86. package/dist/auth/session_middleware.d.ts +83 -54
  87. package/dist/auth/session_middleware.d.ts.map +1 -1
  88. package/dist/auth/session_middleware.js +92 -66
  89. package/dist/auth/session_queries.d.ts +64 -4
  90. package/dist/auth/session_queries.d.ts.map +1 -1
  91. package/dist/auth/session_queries.js +53 -4
  92. package/dist/auth/signup_route_schema.d.ts +5 -5
  93. package/dist/auth/signup_route_schema.d.ts.map +1 -1
  94. package/dist/auth/signup_route_schema.js +4 -4
  95. package/dist/auth/signup_routes.d.ts.map +1 -1
  96. package/dist/auth/signup_routes.js +17 -14
  97. package/dist/auth/token_scope.d.ts +5 -7
  98. package/dist/auth/token_scope.d.ts.map +1 -1
  99. package/dist/auth/token_scope.js +5 -8
  100. package/dist/dev/setup.d.ts +6 -1
  101. package/dist/dev/setup.d.ts.map +1 -1
  102. package/dist/dev/setup.js +42 -34
  103. package/dist/hono_context.d.ts +21 -0
  104. package/dist/hono_context.d.ts.map +1 -1
  105. package/dist/hono_context.js +17 -0
  106. package/dist/http/CLAUDE.md +150 -43
  107. package/dist/http/auth_shape.d.ts +3 -3
  108. package/dist/http/common_routes.js +1 -1
  109. package/dist/http/db_routes.d.ts +4 -3
  110. package/dist/http/db_routes.d.ts.map +1 -1
  111. package/dist/http/db_routes.js +14 -14
  112. package/dist/http/dev_route_error_check.d.ts +6 -3
  113. package/dist/http/dev_route_error_check.d.ts.map +1 -1
  114. package/dist/http/dev_route_error_check.js +6 -3
  115. package/dist/http/dev_set_cookie_check.d.ts +53 -0
  116. package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
  117. package/dist/http/dev_set_cookie_check.js +80 -0
  118. package/dist/http/error_schemas.d.ts +36 -1
  119. package/dist/http/error_schemas.d.ts.map +1 -1
  120. package/dist/http/error_schemas.js +39 -2
  121. package/dist/http/header_lines.d.ts +42 -0
  122. package/dist/http/header_lines.d.ts.map +1 -0
  123. package/dist/http/header_lines.js +80 -0
  124. package/dist/http/host.d.ts +12 -9
  125. package/dist/http/host.d.ts.map +1 -1
  126. package/dist/http/host.js +25 -20
  127. package/dist/http/origin.d.ts +7 -22
  128. package/dist/http/origin.d.ts.map +1 -1
  129. package/dist/http/origin.js +11 -25
  130. package/dist/http/proxy.d.ts +1 -0
  131. package/dist/http/proxy.d.ts.map +1 -1
  132. package/dist/http/proxy.js +3 -0
  133. package/dist/http/request_headers.d.ts +95 -0
  134. package/dist/http/request_headers.d.ts.map +1 -0
  135. package/dist/http/request_headers.js +110 -0
  136. package/dist/http/request_target.d.ts +134 -0
  137. package/dist/http/request_target.d.ts.map +1 -0
  138. package/dist/http/request_target.js +193 -0
  139. package/dist/http/route_error_check.d.ts +4 -11
  140. package/dist/http/route_error_check.d.ts.map +1 -1
  141. package/dist/http/route_error_check.js +4 -21
  142. package/dist/http/route_result.d.ts +127 -23
  143. package/dist/http/route_result.d.ts.map +1 -1
  144. package/dist/http/route_result.js +97 -19
  145. package/dist/http/route_spec.d.ts +298 -82
  146. package/dist/http/route_spec.d.ts.map +1 -1
  147. package/dist/http/route_spec.js +548 -71
  148. package/dist/http/simple_request.d.ts +19 -14
  149. package/dist/http/simple_request.d.ts.map +1 -1
  150. package/dist/http/simple_request.js +17 -29
  151. package/dist/http/surface.d.ts +2 -0
  152. package/dist/http/surface.d.ts.map +1 -1
  153. package/dist/http/surface.js +4 -1
  154. package/dist/realtime/outbound_budget.d.ts +1 -2
  155. package/dist/realtime/outbound_budget.d.ts.map +1 -1
  156. package/dist/realtime/outbound_budget.js +1 -2
  157. package/dist/realtime/sse.d.ts +47 -17
  158. package/dist/realtime/sse.d.ts.map +1 -1
  159. package/dist/realtime/sse.js +115 -93
  160. package/dist/realtime/sse_constants.d.ts +7 -1
  161. package/dist/realtime/sse_constants.d.ts.map +1 -1
  162. package/dist/realtime/sse_constants.js +12 -1
  163. package/dist/realtime/sse_registry.d.ts +3 -3
  164. package/dist/realtime/sse_registry.js +3 -3
  165. package/dist/runtime/deps.d.ts +20 -4
  166. package/dist/runtime/deps.d.ts.map +1 -1
  167. package/dist/runtime/mock.d.ts +7 -1
  168. package/dist/runtime/mock.d.ts.map +1 -1
  169. package/dist/runtime/mock.js +33 -3
  170. package/dist/runtime/node.d.ts.map +1 -1
  171. package/dist/runtime/node.js +2 -1
  172. package/dist/runtime/secure_file.d.ts +71 -10
  173. package/dist/runtime/secure_file.d.ts.map +1 -1
  174. package/dist/runtime/secure_file.js +91 -11
  175. package/dist/server/app_backend.d.ts +0 -8
  176. package/dist/server/app_backend.d.ts.map +1 -1
  177. package/dist/server/app_backend.js +1 -3
  178. package/dist/server/app_server.d.ts +28 -17
  179. package/dist/server/app_server.d.ts.map +1 -1
  180. package/dist/server/app_server.js +52 -34
  181. package/dist/server/serve_fact_route.d.ts.map +1 -1
  182. package/dist/server/serve_fact_route.js +49 -45
  183. package/dist/server/static.d.ts +20 -0
  184. package/dist/server/static.d.ts.map +1 -1
  185. package/dist/server/static.js +56 -8
  186. package/dist/server/unmatched_route.d.ts +42 -0
  187. package/dist/server/unmatched_route.d.ts.map +1 -0
  188. package/dist/server/unmatched_route.js +64 -0
  189. package/dist/testing/CLAUDE.md +404 -1200
  190. package/dist/testing/app_server.d.ts +3 -1
  191. package/dist/testing/app_server.d.ts.map +1 -1
  192. package/dist/testing/app_server.js +4 -10
  193. package/dist/testing/auth_apps.d.ts.map +1 -1
  194. package/dist/testing/auth_apps.js +2 -1
  195. package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
  196. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/account_lifecycle.js +277 -6
  198. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
  199. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  200. package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
  201. package/dist/testing/cross_backend/capabilities.d.ts +68 -5
  202. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  203. package/dist/testing/cross_backend/capabilities.js +20 -4
  204. package/dist/testing/cross_backend/cell_gated_create.js +1 -1
  205. package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
  206. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  207. package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
  208. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  209. package/dist/testing/cross_backend/conformance_table.js +179 -23
  210. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  211. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
  212. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  213. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
  214. package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
  215. package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
  216. package/dist/testing/cross_backend/credential_conformance.js +296 -0
  217. package/dist/testing/cross_backend/credential_conformance.json +1284 -0
  218. package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
  219. package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
  220. package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
  221. package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
  222. package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
  224. package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
  225. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
  226. package/dist/testing/cross_backend/credential_wire.js +188 -0
  227. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  228. package/dist/testing/cross_backend/default_backend_configs.js +22 -2
  229. package/dist/testing/cross_backend/default_spine_surface.js +1 -1
  230. package/dist/testing/cross_backend/differential.d.ts +1 -1
  231. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  232. package/dist/testing/cross_backend/differential.js +3 -2
  233. package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
  234. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  235. package/dist/testing/cross_backend/differential_normalize.js +11 -5
  236. package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -0
  237. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  238. package/dist/testing/cross_backend/full_spine_mount.js +7 -0
  239. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  240. package/dist/testing/cross_backend/identity_parity.js +4 -0
  241. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  242. package/dist/testing/cross_backend/in_process_setup.js +78 -4
  243. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  244. package/dist/testing/cross_backend/login_security.js +13 -10
  245. package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
  246. package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
  247. package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
  248. package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
  249. package/dist/testing/cross_backend/request_header_conformance.js +196 -0
  250. package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
  251. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
  252. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
  253. package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
  254. package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
  255. package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
  256. package/dist/testing/cross_backend/request_target_conformance.js +186 -0
  257. package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
  258. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
  259. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
  260. package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
  261. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  262. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
  263. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  264. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +2 -1
  265. package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
  266. package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
  267. package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
  268. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
  269. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  270. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
  271. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  272. package/dist/testing/cross_backend/session_cap.js +56 -29
  273. package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
  274. package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
  275. package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
  276. package/dist/testing/cross_backend/session_login.d.ts +24 -0
  277. package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
  278. package/dist/testing/cross_backend/session_login.js +31 -0
  279. package/dist/testing/cross_backend/setup.d.ts +117 -0
  280. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  281. package/dist/testing/cross_backend/setup.js +193 -9
  282. package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
  283. package/dist/testing/cross_backend/simple_request.js +5 -0
  284. package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
  285. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  286. package/dist/testing/cross_backend/spine_suites.js +88 -5
  287. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  288. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  289. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  290. package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
  291. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  292. package/dist/testing/cross_backend/sse_round_trip.js +205 -64
  293. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  294. package/dist/testing/cross_backend/testing_backdoor.js +5 -2
  295. package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
  296. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
  297. package/dist/testing/cross_backend/testing_credential_read.js +175 -0
  298. package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
  299. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  300. package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
  301. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  302. package/dist/testing/cross_backend/token_lifetime.js +58 -2
  303. package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
  304. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  305. package/dist/testing/cross_backend/transport_composition.js +13 -10
  306. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  307. package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
  308. package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
  309. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  310. package/dist/testing/cross_backend/ws_endpoint.js +19 -2
  311. package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
  312. package/dist/testing/cross_backend/ws_role_gated.js +2 -3
  313. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  314. package/dist/testing/cross_backend/ws_round_trip.js +28 -12
  315. package/dist/testing/cross_backend/xfail.d.ts +44 -11
  316. package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
  317. package/dist/testing/cross_backend/xfail.js +68 -23
  318. package/dist/testing/data_exposure.d.ts.map +1 -1
  319. package/dist/testing/data_exposure.js +4 -3
  320. package/dist/testing/integration.d.ts +1 -2
  321. package/dist/testing/integration.d.ts.map +1 -1
  322. package/dist/testing/integration.js +14 -8
  323. package/dist/testing/integration_helpers.d.ts +50 -3
  324. package/dist/testing/integration_helpers.d.ts.map +1 -1
  325. package/dist/testing/integration_helpers.js +87 -9
  326. package/dist/testing/middleware.d.ts +2 -0
  327. package/dist/testing/middleware.d.ts.map +1 -1
  328. package/dist/testing/middleware.js +9 -2
  329. package/dist/testing/round_trip.d.ts +6 -2
  330. package/dist/testing/round_trip.d.ts.map +1 -1
  331. package/dist/testing/round_trip.js +17 -6
  332. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  333. package/dist/testing/rpc_envelope_cases.js +7 -0
  334. package/dist/testing/rpc_helpers.d.ts +4 -2
  335. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  336. package/dist/testing/rpc_helpers.js +6 -1
  337. package/dist/testing/rpc_round_trip.d.ts +13 -2
  338. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  339. package/dist/testing/rpc_round_trip.js +25 -6
  340. package/dist/testing/schema_generators.d.ts +2 -2
  341. package/dist/testing/schema_generators.d.ts.map +1 -1
  342. package/dist/testing/schema_generators.js +4 -4
  343. package/dist/testing/stubs.d.ts +2 -2
  344. package/dist/testing/stubs.d.ts.map +1 -1
  345. package/dist/testing/stubs.js +8 -8
  346. package/dist/testing/transports/fetch_transport.d.ts +6 -3
  347. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  348. package/dist/testing/transports/fetch_transport.js +31 -19
  349. package/dist/testing/transports/raw_http.d.ts +61 -1
  350. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  351. package/dist/testing/transports/raw_http.js +61 -1
  352. package/dist/testing/transports/ws_raw_client.d.ts +20 -0
  353. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  354. package/dist/testing/transports/ws_raw_client.js +10 -4
  355. package/dist/testing/transports/ws_transport.d.ts +21 -1
  356. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  357. package/dist/testing/transports/ws_transport.js +58 -20
  358. package/package.json +1 -1
@@ -41,8 +41,8 @@ export declare const ALWAYS_ACCEPTED_ERRORS: ReadonlyArray<RestErrorDef>;
41
41
  export declare const is_error_status: (status: number) => boolean;
42
42
  /**
43
43
  * Whether a response is JSON by its `Content-Type`, the gate before any
44
- * error check: a non-JSON response (SSE, bytes, Hono's plain-text 404) is no
45
- * error body to check, whatever its text looks like.
44
+ * error check: a non-JSON response (SSE, bytes, the plain-text unrouted
45
+ * 404) is no error body to check, whatever its text looks like.
46
46
  *
47
47
  * @param response - the response
48
48
  */
@@ -116,19 +116,12 @@ export declare const split_route_template: (template: string) => Array<string>;
116
116
  * sets, anchors `^re$` and leaves a top-level alternation ungrouped, so
117
117
  * `^a|b$` takes `ab` where the grouped form refuses it. The grouped form is
118
118
  * the stricter of the two: a value it accepts both routers accept. Test it
119
- * against the value as Hono reads it (`decode_route_path`).
119
+ * against the value as the assembled server's router reads it: the raw,
120
+ * percent-encoded segment (`get_request_path`).
120
121
  *
121
122
  * @param pattern - the param's `re` (`RouteParam.pattern`)
122
123
  */
123
124
  export declare const compile_route_param_pattern: (pattern: string) => RegExp;
124
- /**
125
- * A request path, or a part of one, as Hono's router reads it: percent-decoded
126
- * by `decodeURI` with `%25` kept, so an encoded `/`, `#`, `?` or `%` stays
127
- * encoded, or the raw text when decoding fails.
128
- *
129
- * @param path - the request pathname, or a percent-encoded segment of one
130
- */
131
- export declare const decode_route_path: (path: string) => string;
132
125
  /**
133
126
  * Compile a Hono path template to a `RegExp` over request paths, reading it
134
127
  * as Hono 4's routers do: the template is split on `/` with each `{…}` group
@@ -1 +1 @@
1
- {"version":3,"file":"route_error_check.d.ts","sourceRoot":"","sources":["../../src/lib/http/route_error_check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3E,OAAO,EAGN,KAAK,YAAY,EACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,YAAY,CAG9D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,OAAwB,CAAC;AAE1E;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,UAAU,QAAQ,KAAG,OACsB,CAAC;AAE7E,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GACxB;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GACZ;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,GACxC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAEtE;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC7B,QAAQ,aAAa,EACrB,QAAQ,MAAM,EACd,MAAM,OAAO,EACb,SAAS,OAAO,KACd,eAWF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GACpC,OAAO,OAAO,CAAC,eAAe,EAAE;IAAE,EAAE,E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KpB,CAAC;AAEL;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EACnC,QAAQ,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EACtC,QAAQ,MAAM,EACd,MAAM,MAAM,KACV,CAAC,GAAG,SAMN,CAAC"}
@@ -44,8 +44,8 @@ export const ALWAYS_ACCEPTED_ERRORS = [
44
44
  export const is_error_status = (status) => status >= 400;
45
45
  /**
46
46
  * Whether a response is JSON by its `Content-Type`, the gate before any
47
- * error check: a non-JSON response (SSE, bytes, Hono's plain-text 404) is no
48
- * error body to check, whatever its text looks like.
47
+ * error check: a non-JSON response (SSE, bytes, the plain-text unrouted
48
+ * 404) is no error body to check, whatever its text looks like.
49
49
  *
50
50
  * @param response - the response
51
51
  */
@@ -173,29 +173,12 @@ const to_route_param_source = (pattern) => `(?:${pattern})`;
173
173
  * sets, anchors `^re$` and leaves a top-level alternation ungrouped, so
174
174
  * `^a|b$` takes `ab` where the grouped form refuses it. The grouped form is
175
175
  * the stricter of the two: a value it accepts both routers accept. Test it
176
- * against the value as Hono reads it (`decode_route_path`).
176
+ * against the value as the assembled server's router reads it: the raw,
177
+ * percent-encoded segment (`get_request_path`).
177
178
  *
178
179
  * @param pattern - the param's `re` (`RouteParam.pattern`)
179
180
  */
180
181
  export const compile_route_param_pattern = (pattern) => new RegExp(`^${to_route_param_source(pattern)}$`);
181
- /**
182
- * A request path, or a part of one, as Hono's router reads it: percent-decoded
183
- * by `decodeURI` with `%25` kept, so an encoded `/`, `#`, `?` or `%` stays
184
- * encoded, or the raw text when decoding fails.
185
- *
186
- * @param path - the request pathname, or a percent-encoded segment of one
187
- */
188
- export const decode_route_path = (path) => {
189
- if (!path.includes('%'))
190
- return path;
191
- try {
192
- return decodeURI(path.replaceAll('%25', '%2525'));
193
- }
194
- catch {
195
- // a malformed escape: Hono matches the raw path
196
- return path;
197
- }
198
- };
199
182
  /** The regexp source of a template with no optional param. */
200
183
  const to_route_path_source = (template) => {
201
184
  const segments = split_route_template(template);
@@ -1,28 +1,54 @@
1
1
  /**
2
- * What a route handler returns: a success, a failure, or a response it built
3
- * itself. `apply_route_specs` turns the result into the `Response` — a success
4
- * is its JSON body at 200, a failure its definition's body at the definition's
5
- * status with the definition's headers (`Retry-After`), a raw result the
6
- * response as it is.
2
+ * What a route handler returns: a success, a failure, a raw answer described
3
+ * as data, or an SSE stream. A handler never builds a `Response`:
4
+ * `apply_route_specs` prepares the response from the result inside the
5
+ * route's transaction and builds it only after the commit, through the Hono
6
+ * context (`prepare_route_response`, `emit_route_response` in
7
+ * `http/route_spec.ts`). So every response a route spec answers carries what
8
+ * the middleware put on the context — the session middleware's clear of a
9
+ * stale cookie among it — and a `Set-Cookie` the handler returns rides only a
10
+ * success whose writes committed.
11
+ *
12
+ * - `route_ok(value, {set_cookie?})` — `value` as JSON at 200, the
13
+ * `Set-Cookie` lines after any the middleware put on the context
14
+ * - `route_fail(def, fields?)` — the definition's body at its status, with
15
+ * the headers it derives (`Retry-After`); never a cookie
16
+ * - `route_raw({status, headers?, body?})` — a status, headers, and a body
17
+ * written as given: an empty body, bytes, a stream, a JSON-RPC envelope
18
+ * - `route_sse(stream)` — the stream the route opened for this request
19
+ * (`RouteContext.open_sse`)
7
20
  *
8
21
  * A result is plain data, so domain code and shared helpers fail without the
9
- * Hono context (`return route_fail(REST_ROW_NOT_FOUND)`), and a handler
10
- * forwards a failure it was handed (`if (!result.ok) return result`). Headers
11
- * and cookies a handler sets on the context before it returns carry over onto
12
- * the response the framework builds.
22
+ * Hono context (`return route_fail(REST_ROW_NOT_FOUND)`), and a handler —
23
+ * which receives a `RouteContext`, never the Hono context — forwards a
24
+ * failure it was handed (`if (!result.ok) return result`).
13
25
  *
14
- * Hono-free: `hono` is imported for its types alone.
26
+ * Hono-free: nothing here imports `hono`.
15
27
  *
16
28
  * @module
17
29
  */
18
- import type { TypedResponse } from 'hono';
19
- import type { StatusCode } from 'hono/utils/http-status';
20
30
  import type { SchemaEntries, SchemaObjectInput } from '@fuzdev/fuz_schema/schema.ts';
21
31
  import type { RestErrorDef } from './error_schemas.js';
22
- /** A success: `value` is the response body, answered as JSON at 200. */
32
+ import type { SseStream } from '../realtime/sse.js';
33
+ /** Options for `route_ok`. */
34
+ export interface RouteOkOptions {
35
+ /**
36
+ * `Set-Cookie` header values, written in order after every `Set-Cookie`
37
+ * line the middleware put on the context — the session middleware's clear
38
+ * of a stale cookie first. Formatted by the caller
39
+ * (`session_cookie_header`, `clear_session_cookie_header`); the framework
40
+ * treats them as opaque lines.
41
+ */
42
+ readonly set_cookie?: ReadonlyArray<string>;
43
+ }
44
+ /**
45
+ * A success: `value` is the response body, answered as JSON at 200, with
46
+ * `set_cookie`'s lines (`[]` for none).
47
+ */
23
48
  export interface RouteOk<T> {
24
49
  readonly ok: true;
25
50
  readonly value: T;
51
+ readonly set_cookie: ReadonlyArray<string>;
26
52
  }
27
53
  /**
28
54
  * A failure, typed by what reaches the wire — its status, its code, and its
@@ -38,11 +64,42 @@ export interface RouteFail<TStatus extends number, TCode extends string, TBody>
38
64
  /** The definition the failure was made from, at the same status and code. */
39
65
  readonly def: RestErrorDef<TStatus, TCode>;
40
66
  }
41
- /** A response the handler built itself, answered as it is (`route_raw`). */
67
+ /** A raw answer's body, written as given: none, text, bytes, or a byte stream. */
68
+ export type RouteRawBody = null | string | Uint8Array | ReadableStream<Uint8Array>;
69
+ /** A raw answer's headers by name; a name a response repeats takes a list. */
70
+ export type RouteRawHeaders = Readonly<Record<string, string | ReadonlyArray<string>>>;
71
+ /** What `route_raw` takes. */
72
+ export interface RouteRawInit {
73
+ /** The status, 200 to 599. */
74
+ readonly status: number;
75
+ /** The headers, none of `ROUTE_RAW_REFUSED_HEADERS`; a body needs its `Content-Type`. */
76
+ readonly headers?: RouteRawHeaders;
77
+ /** The body, `null` (the default) for none. */
78
+ readonly body?: RouteRawBody;
79
+ }
80
+ /** A raw answer (`route_raw`): a status, headers, and a body, written as given. */
42
81
  export interface RouteRaw {
43
82
  readonly ok: 'raw';
44
- readonly response: Response;
83
+ readonly status: number;
84
+ readonly headers: RouteRawHeaders;
85
+ readonly body: RouteRawBody;
45
86
  }
87
+ /**
88
+ * An SSE answer (`route_sse`): the stream `RouteContext.open_sse` opened for
89
+ * this request, whose response the framework answers with.
90
+ */
91
+ export interface RouteSse {
92
+ readonly ok: 'sse';
93
+ /** Typed to admit a stream of any event type — `SseStream` is contravariant in it. */
94
+ readonly stream: SseStream<never>;
95
+ }
96
+ /**
97
+ * The header names a raw answer may not carry, lowercase (compared
98
+ * case-insensitively): `Set-Cookie`, which only a success carries
99
+ * (`RouteOkOptions.set_cookie`), and the hop-by-hop names, which are the
100
+ * server's to write — framing, the connection, an upgrade.
101
+ */
102
+ export declare const ROUTE_RAW_REFUSED_HEADERS: ReadonlyArray<string>;
46
103
  /**
47
104
  * A JSON value's type made readonly at every depth: what a handler's
48
105
  * `route_ok` value is checked against. `route_ok` infers its value as written
@@ -56,7 +113,7 @@ export type ReadonlyJson<T> = unknown extends T ? T : T extends string | number
56
113
  readonly [K in keyof T as string extends K ? (unknown extends T[K] ? never : K) : K]: ReadonlyJson<T[K]>;
57
114
  };
58
115
  /** Any result a route handler returns. */
59
- export type RouteResult = RouteOk<unknown> | RouteFail<number, string, unknown> | RouteRaw;
116
+ export type RouteResult = RouteOk<unknown> | RouteFail<number, string, unknown> | RouteRaw | RouteSse;
60
117
  /** The input side of a definition's body: what `route_fail` builds from it. */
61
118
  export type RestErrorBodyInput<TDef extends RestErrorDef> = TDef extends RestErrorDef<number, infer TCode, infer TFields> ? {
62
119
  error: TCode;
@@ -69,14 +126,16 @@ export type RouteFailOf<TDef extends RestErrorDef> = TDef extends RestErrorDef ?
69
126
  */
70
127
  export type RouteFailFields<TDef extends RestErrorDef> = TDef extends RestErrorDef<number, string, infer TFields extends SchemaEntries> ? keyof TFields extends never ? [] : Record<never, never> extends SchemaObjectInput<TFields> ? [fields?: SchemaObjectInput<TFields>] : [fields: SchemaObjectInput<TFields>] : never;
71
128
  /**
72
- * A success: the route answers `value` as JSON at 200.
129
+ * A success: the route answers `value` as JSON at 200, with the `Set-Cookie`
130
+ * lines of `options.set_cookie` after any the middleware wrote.
73
131
  *
74
132
  * Typed in a handler by the input side of the route's `output` schema
75
133
  * (`ReadonlyJson`). The value is inferred as written, its literals kept.
76
134
  *
77
135
  * @param value - the response body, never `undefined`
136
+ * @param options - the `Set-Cookie` lines the success carries
78
137
  */
79
- export declare const route_ok: <const T extends {} | null>(value: T) => RouteOk<T>;
138
+ export declare const route_ok: <const T extends {} | null>(value: T, options?: RouteOkOptions) => RouteOk<T>;
80
139
  /**
81
140
  * A failure: the route answers `{error: def.code, ...fields}` at `def.status`,
82
141
  * with the headers `def` derives from that body.
@@ -91,12 +150,57 @@ export declare const route_ok: <const T extends {} | null>(value: T) => RouteOk<
91
150
  */
92
151
  export declare const route_fail: <TDef extends RestErrorDef>(def: TDef, ...fields: RouteFailFields<TDef>) => RouteFailOf<TDef>;
93
152
  /**
94
- * A response the handler built itself, at any status: an empty body, bytes, a
153
+ * A raw answer at any status, described as data: an empty body, bytes, a
95
154
  * stream, a JSON-RPC envelope. A JSON answer of the route's own goes through
96
- * `route_ok` or `route_fail`, so a `Response` typed as Hono's `c.json` return
97
- * is refused.
155
+ * `route_ok` or `route_fail`.
156
+ *
157
+ * The framework checks it when it prepares the response, inside the route's
158
+ * transaction, so a raw answer it refuses throws and rolls back:
159
+ *
160
+ * - a status outside 200 to 599
161
+ * - a header of `ROUTE_RAW_REFUSED_HEADERS`, a name or value a `Headers`
162
+ * refuses, an empty value or an empty list (a runtime writes one its own
163
+ * way), one name twice in any case
164
+ * - a non-null body without a `Content-Type` (a runtime would derive one,
165
+ * each its own way), and a body on a null-body status (204, 205, 304)
166
+ * - a `Content-Length` that is not a decimal integer without a leading zero
167
+ * (`0` or `[1-9][0-9]*`), a list included, one past the safe integer range,
168
+ * one on a 204 or 205 (no content to measure, RFC 9110 §8.6 and §15.3.6; a
169
+ * 304 may name the size of the representation it stands for, §15.4.5), and
170
+ * one a text or bytes body doesn't have — the UTF-8 bytes of a string, the
171
+ * `byteLength` of a `Uint8Array`. `@hono/node-server` sends any of these as
172
+ * written while Bun rewrites them to the body it sends, so the two runtimes
173
+ * would answer differently. With a null or stream body the size is the
174
+ * route's to declare: an `X-Accel-Redirect` answer sends one with no body
175
+ * - a body that is none of `RouteRawBody` (a `Response` included), a stream
176
+ * that is locked, bytes whose buffer is detached, and bytes whose resizable
177
+ * buffer shrank below the view — read as empty, they would answer as zero
178
+ * bytes on every runtime
179
+ *
180
+ * A stream that was read and released is unlocked yet can't be answered with,
181
+ * and nothing shows it before a `Response` is built from it: that fails after
182
+ * the commit, answering the error catch's 500 with an error naming the route
183
+ * (or, on `@hono/node-server`, whose own `Response` reads the stream only as
184
+ * it writes, an empty body). A view whose resizable buffer shrinks after the
185
+ * result is prepared is past what the prepare can see.
186
+ *
187
+ * A stream body's `cancel` must release its source — close the file, end the
188
+ * child process: it is the one hook the spine calls for a stream it does not
189
+ * send. A stream body the route does not end up answering with — refused
190
+ * here, or rolled back by a failed commit — is cancelled, and so is one
191
+ * answering a `HEAD`, which gets the status and headers alone. A source opened
192
+ * before the status is known (a file opened to choose 200 or 404) is released
193
+ * the same way whichever answer it ends up behind.
194
+ *
195
+ * @param init - the status, headers, and body
196
+ */
197
+ export declare const route_raw: (init: RouteRawInit) => RouteRaw;
198
+ /**
199
+ * An SSE answer: the stream `RouteContext.open_sse` opened for this request.
200
+ * The framework answers with that stream's response, and refuses (throws) a
201
+ * stream this request did not open.
98
202
  *
99
- * @param response - the response, answered as it is
203
+ * @param stream - the stream, as `open_sse` returned it
100
204
  */
101
- export declare const route_raw: <TResponse extends Response>(response: TResponse & (TResponse extends TypedResponse<unknown, StatusCode, "json"> ? never : unknown)) => RouteRaw;
205
+ export declare const route_sse: (stream: SseStream<never>) => RouteSse;
102
206
  //# sourceMappingURL=route_result.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route_result.d.ts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AS,YAAY,IACpD,IAAI,SAAS,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,SAAS,aAAa,CAAC,GAC3E,MAAM,OAAO,SAAS,KAAK,GAC1B,EAAE,GAGH,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,iBAAiB,CAAC,OAAO,CAAC,GACrD,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,GACrC,CAAC,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,GACtC,KAAK,CAAC;AAEV;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,GAGpB,KAAK,CAAC,CAAC,SAAS,EAAE,GAAG,IAAI,EAEzB,OAAO,CAAC,EACR,UAAU,cAAc,KACtB,OAAO,CAAC,CAAC,CAAiE,CAAC;AAE9E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GAAI,IAAI,SAAS,YAAY,EACnD,KAAK,IAAI,EACT,GAAG,QAAQ,eAAe,CAAC,IAAI,CAAC,KAC9B,WAAW,CAAC,IAAI,CAOgB,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,YAAY,KAAG,QAK7C,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,QAAQ,SAAS,CAAC,KAAK,CAAC,KAAG,QAAmC,CAAC"}
@@ -1,31 +1,59 @@
1
1
  /**
2
- * What a route handler returns: a success, a failure, or a response it built
3
- * itself. `apply_route_specs` turns the result into the `Response` — a success
4
- * is its JSON body at 200, a failure its definition's body at the definition's
5
- * status with the definition's headers (`Retry-After`), a raw result the
6
- * response as it is.
2
+ * What a route handler returns: a success, a failure, a raw answer described
3
+ * as data, or an SSE stream. A handler never builds a `Response`:
4
+ * `apply_route_specs` prepares the response from the result inside the
5
+ * route's transaction and builds it only after the commit, through the Hono
6
+ * context (`prepare_route_response`, `emit_route_response` in
7
+ * `http/route_spec.ts`). So every response a route spec answers carries what
8
+ * the middleware put on the context — the session middleware's clear of a
9
+ * stale cookie among it — and a `Set-Cookie` the handler returns rides only a
10
+ * success whose writes committed.
11
+ *
12
+ * - `route_ok(value, {set_cookie?})` — `value` as JSON at 200, the
13
+ * `Set-Cookie` lines after any the middleware put on the context
14
+ * - `route_fail(def, fields?)` — the definition's body at its status, with
15
+ * the headers it derives (`Retry-After`); never a cookie
16
+ * - `route_raw({status, headers?, body?})` — a status, headers, and a body
17
+ * written as given: an empty body, bytes, a stream, a JSON-RPC envelope
18
+ * - `route_sse(stream)` — the stream the route opened for this request
19
+ * (`RouteContext.open_sse`)
7
20
  *
8
21
  * A result is plain data, so domain code and shared helpers fail without the
9
- * Hono context (`return route_fail(REST_ROW_NOT_FOUND)`), and a handler
10
- * forwards a failure it was handed (`if (!result.ok) return result`). Headers
11
- * and cookies a handler sets on the context before it returns carry over onto
12
- * the response the framework builds.
22
+ * Hono context (`return route_fail(REST_ROW_NOT_FOUND)`), and a handler —
23
+ * which receives a `RouteContext`, never the Hono context — forwards a
24
+ * failure it was handed (`if (!result.ok) return result`).
13
25
  *
14
- * Hono-free: `hono` is imported for its types alone.
26
+ * Hono-free: nothing here imports `hono`.
15
27
  *
16
28
  * @module
17
29
  */
18
30
  /**
19
- * A success: the route answers `value` as JSON at 200.
31
+ * The header names a raw answer may not carry, lowercase (compared
32
+ * case-insensitively): `Set-Cookie`, which only a success carries
33
+ * (`RouteOkOptions.set_cookie`), and the hop-by-hop names, which are the
34
+ * server's to write — framing, the connection, an upgrade.
35
+ */
36
+ export const ROUTE_RAW_REFUSED_HEADERS = Object.freeze([
37
+ 'set-cookie',
38
+ 'connection',
39
+ 'keep-alive',
40
+ 'proxy-connection',
41
+ 'transfer-encoding',
42
+ 'te',
43
+ 'trailer',
44
+ 'upgrade'
45
+ ]);
46
+ /**
47
+ * A success: the route answers `value` as JSON at 200, with the `Set-Cookie`
48
+ * lines of `options.set_cookie` after any the middleware wrote.
20
49
  *
21
50
  * Typed in a handler by the input side of the route's `output` schema
22
51
  * (`ReadonlyJson`). The value is inferred as written, its literals kept.
23
52
  *
24
53
  * @param value - the response body, never `undefined`
54
+ * @param options - the `Set-Cookie` lines the success carries
25
55
  */
26
- // `{} | null` is every value but `undefined`, which is no JSON body
27
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
28
- export const route_ok = (value) => ({ ok: true, value });
56
+ export const route_ok = (value, options) => ({ ok: true, value, set_cookie: options?.set_cookie ?? [] });
29
57
  /**
30
58
  * A failure: the route answers `{error: def.code, ...fields}` at `def.status`,
31
59
  * with the headers `def` derives from that body.
@@ -46,11 +74,61 @@ export const route_fail = (def, ...fields) => ({
46
74
  def
47
75
  });
48
76
  /**
49
- * A response the handler built itself, at any status: an empty body, bytes, a
77
+ * A raw answer at any status, described as data: an empty body, bytes, a
50
78
  * stream, a JSON-RPC envelope. A JSON answer of the route's own goes through
51
- * `route_ok` or `route_fail`, so a `Response` typed as Hono's `c.json` return
52
- * is refused.
79
+ * `route_ok` or `route_fail`.
80
+ *
81
+ * The framework checks it when it prepares the response, inside the route's
82
+ * transaction, so a raw answer it refuses throws and rolls back:
83
+ *
84
+ * - a status outside 200 to 599
85
+ * - a header of `ROUTE_RAW_REFUSED_HEADERS`, a name or value a `Headers`
86
+ * refuses, an empty value or an empty list (a runtime writes one its own
87
+ * way), one name twice in any case
88
+ * - a non-null body without a `Content-Type` (a runtime would derive one,
89
+ * each its own way), and a body on a null-body status (204, 205, 304)
90
+ * - a `Content-Length` that is not a decimal integer without a leading zero
91
+ * (`0` or `[1-9][0-9]*`), a list included, one past the safe integer range,
92
+ * one on a 204 or 205 (no content to measure, RFC 9110 §8.6 and §15.3.6; a
93
+ * 304 may name the size of the representation it stands for, §15.4.5), and
94
+ * one a text or bytes body doesn't have — the UTF-8 bytes of a string, the
95
+ * `byteLength` of a `Uint8Array`. `@hono/node-server` sends any of these as
96
+ * written while Bun rewrites them to the body it sends, so the two runtimes
97
+ * would answer differently. With a null or stream body the size is the
98
+ * route's to declare: an `X-Accel-Redirect` answer sends one with no body
99
+ * - a body that is none of `RouteRawBody` (a `Response` included), a stream
100
+ * that is locked, bytes whose buffer is detached, and bytes whose resizable
101
+ * buffer shrank below the view — read as empty, they would answer as zero
102
+ * bytes on every runtime
103
+ *
104
+ * A stream that was read and released is unlocked yet can't be answered with,
105
+ * and nothing shows it before a `Response` is built from it: that fails after
106
+ * the commit, answering the error catch's 500 with an error naming the route
107
+ * (or, on `@hono/node-server`, whose own `Response` reads the stream only as
108
+ * it writes, an empty body). A view whose resizable buffer shrinks after the
109
+ * result is prepared is past what the prepare can see.
110
+ *
111
+ * A stream body's `cancel` must release its source — close the file, end the
112
+ * child process: it is the one hook the spine calls for a stream it does not
113
+ * send. A stream body the route does not end up answering with — refused
114
+ * here, or rolled back by a failed commit — is cancelled, and so is one
115
+ * answering a `HEAD`, which gets the status and headers alone. A source opened
116
+ * before the status is known (a file opened to choose 200 or 404) is released
117
+ * the same way whichever answer it ends up behind.
118
+ *
119
+ * @param init - the status, headers, and body
120
+ */
121
+ export const route_raw = (init) => ({
122
+ ok: 'raw',
123
+ status: init.status,
124
+ headers: init.headers ?? {},
125
+ body: init.body ?? null
126
+ });
127
+ /**
128
+ * An SSE answer: the stream `RouteContext.open_sse` opened for this request.
129
+ * The framework answers with that stream's response, and refuses (throws) a
130
+ * stream this request did not open.
53
131
  *
54
- * @param response - the response, answered as it is
132
+ * @param stream - the stream, as `open_sse` returned it
55
133
  */
56
- export const route_raw = (response) => ({ ok: 'raw', response });
134
+ export const route_sse = (stream) => ({ ok: 'sse', stream });