@fuzdev/fuz_app 0.180.0 → 0.182.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.
- package/dist/actions/CLAUDE.md +38 -20
- package/dist/actions/action_rpc.d.ts +25 -6
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +56 -48
- package/dist/actions/action_types.d.ts +31 -13
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +1 -1
- package/dist/actions/notification_sender.d.ts +83 -0
- package/dist/actions/notification_sender.d.ts.map +1 -0
- package/dist/actions/notification_sender.js +85 -0
- package/dist/actions/perform_action.d.ts +13 -4
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +27 -18
- package/dist/actions/register_action_ws.d.ts +20 -2
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +17 -5
- package/dist/actions/ws_socket_session.d.ts +3 -0
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +3 -2
- package/dist/auth/CLAUDE.md +84 -59
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +30 -3
- package/dist/auth/account_queries.d.ts +213 -2
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +255 -2
- package/dist/auth/account_route_schema.d.ts +26 -16
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +10 -24
- package/dist/auth/account_routes.d.ts +5 -7
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +110 -89
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +117 -25
- package/dist/auth/api_token_queries.d.ts +29 -12
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +42 -27
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +10 -12
- package/dist/auth/audit_log_schema.js +4 -4
- package/dist/auth/bearer_auth.d.ts +4 -3
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +37 -32
- package/dist/auth/bootstrap_account.d.ts +65 -37
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +115 -66
- package/dist/auth/bootstrap_route_schema.d.ts +6 -2
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +7 -2
- package/dist/auth/bootstrap_routes.d.ts +50 -33
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +109 -87
- package/dist/auth/bootstrap_token_store.d.ts +60 -0
- package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
- package/dist/auth/bootstrap_token_store.js +39 -0
- package/dist/auth/credential_headers.d.ts +71 -0
- package/dist/auth/credential_headers.d.ts.map +1 -0
- package/dist/auth/credential_headers.js +100 -0
- package/dist/auth/daemon_token.d.ts +13 -1
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token.js +14 -2
- package/dist/auth/daemon_token_middleware.d.ts +10 -11
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +39 -30
- package/dist/auth/deps.d.ts +10 -11
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/invite_queries.d.ts +18 -0
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +24 -0
- package/dist/auth/request_context.d.ts +97 -76
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +93 -104
- package/dist/auth/resolved_auth.d.ts +10 -5
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +2 -2
- package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +5 -3
- package/dist/auth/role_grant_offer_actions.d.ts +7 -11
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +97 -106
- package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
- package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_ddl.js +9 -2
- package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +75 -22
- package/dist/auth/role_grant_offer_queries.d.ts +143 -9
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +266 -66
- package/dist/auth/role_grant_offer_schema.js +1 -1
- package/dist/auth/role_grant_queries.d.ts +57 -10
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +81 -22
- package/dist/auth/role_grant_sql.d.ts +21 -0
- package/dist/auth/role_grant_sql.d.ts.map +1 -1
- package/dist/auth/role_grant_sql.js +21 -0
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +9 -2
- package/dist/auth/session_cookie.d.ts +105 -25
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +124 -15
- package/dist/auth/session_middleware.d.ts +83 -54
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +92 -66
- package/dist/auth/session_queries.d.ts +95 -14
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +98 -19
- package/dist/auth/signup_route_schema.d.ts +5 -5
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +4 -4
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +17 -14
- package/dist/auth/standard_rpc_actions.d.ts +6 -19
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +5 -6
- package/dist/auth/token_scope.d.ts +6 -8
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +6 -9
- package/dist/dev/setup.d.ts +6 -1
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +42 -34
- package/dist/hono_context.d.ts +21 -0
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +17 -0
- package/dist/http/CLAUDE.md +156 -48
- package/dist/http/auth_shape.d.ts +4 -4
- package/dist/http/common_routes.js +1 -1
- package/dist/http/db_routes.d.ts +4 -3
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +14 -14
- package/dist/http/dev_route_error_check.d.ts +6 -3
- package/dist/http/dev_route_error_check.d.ts.map +1 -1
- package/dist/http/dev_route_error_check.js +6 -3
- package/dist/http/dev_set_cookie_check.d.ts +53 -0
- package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
- package/dist/http/dev_set_cookie_check.js +80 -0
- package/dist/http/error_schemas.d.ts +45 -22
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +53 -26
- package/dist/http/header_lines.d.ts +42 -0
- package/dist/http/header_lines.d.ts.map +1 -0
- package/dist/http/header_lines.js +80 -0
- package/dist/http/host.d.ts +12 -9
- package/dist/http/host.d.ts.map +1 -1
- package/dist/http/host.js +25 -20
- package/dist/http/origin.d.ts +7 -22
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +11 -25
- package/dist/http/proxy.d.ts +1 -0
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +3 -0
- package/dist/http/request_headers.d.ts +95 -0
- package/dist/http/request_headers.d.ts.map +1 -0
- package/dist/http/request_headers.js +110 -0
- package/dist/http/request_target.d.ts +134 -0
- package/dist/http/request_target.d.ts.map +1 -0
- package/dist/http/request_target.js +193 -0
- package/dist/http/route_error_check.d.ts +4 -11
- package/dist/http/route_error_check.d.ts.map +1 -1
- package/dist/http/route_error_check.js +4 -21
- package/dist/http/route_result.d.ts +127 -23
- package/dist/http/route_result.d.ts.map +1 -1
- package/dist/http/route_result.js +97 -19
- package/dist/http/route_spec.d.ts +299 -83
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +548 -71
- package/dist/http/simple_request.d.ts +19 -14
- package/dist/http/simple_request.d.ts.map +1 -1
- package/dist/http/simple_request.js +17 -29
- package/dist/http/surface.d.ts +2 -0
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +4 -1
- package/dist/realtime/outbound_budget.d.ts +1 -2
- package/dist/realtime/outbound_budget.d.ts.map +1 -1
- package/dist/realtime/outbound_budget.js +1 -2
- package/dist/realtime/sse.d.ts +47 -17
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +115 -93
- package/dist/realtime/sse_constants.d.ts +7 -1
- package/dist/realtime/sse_constants.d.ts.map +1 -1
- package/dist/realtime/sse_constants.js +12 -1
- package/dist/realtime/sse_registry.d.ts +3 -3
- package/dist/realtime/sse_registry.js +3 -3
- package/dist/runtime/deps.d.ts +20 -4
- package/dist/runtime/deps.d.ts.map +1 -1
- package/dist/runtime/mock.d.ts +7 -1
- package/dist/runtime/mock.d.ts.map +1 -1
- package/dist/runtime/mock.js +33 -3
- package/dist/runtime/node.d.ts.map +1 -1
- package/dist/runtime/node.js +2 -1
- package/dist/runtime/secure_file.d.ts +71 -10
- package/dist/runtime/secure_file.d.ts.map +1 -1
- package/dist/runtime/secure_file.js +91 -11
- package/dist/server/app_backend.d.ts +0 -8
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +4 -4
- package/dist/server/app_server.d.ts +54 -33
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +69 -41
- package/dist/server/serve_fact_route.d.ts +3 -3
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +59 -55
- package/dist/server/static.d.ts +20 -0
- package/dist/server/static.d.ts.map +1 -1
- package/dist/server/static.js +56 -8
- package/dist/server/unmatched_route.d.ts +42 -0
- package/dist/server/unmatched_route.d.ts.map +1 -0
- package/dist/server/unmatched_route.js +64 -0
- package/dist/testing/CLAUDE.md +406 -1202
- package/dist/testing/app_server.d.ts +3 -1
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +5 -9
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +3 -2
- package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
- package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/account_lifecycle.js +320 -6
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
- package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
- package/dist/testing/cross_backend/capabilities.d.ts +68 -5
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +20 -4
- package/dist/testing/cross_backend/cell_gated_create.js +1 -1
- package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +179 -23
- package/dist/testing/cross_backend/cookie_attributes.js +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
- package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
- package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_conformance.js +296 -0
- package/dist/testing/cross_backend/credential_conformance.json +1284 -0
- package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
- package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
- package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
- package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
- package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
- package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
- package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_wire.js +188 -0
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +22 -2
- package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +3 -7
- package/dist/testing/cross_backend/differential.d.ts +1 -1
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +3 -2
- package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
- package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential_normalize.js +11 -5
- package/dist/testing/cross_backend/full_spine_mount.d.ts +4 -10
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +11 -4
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +4 -0
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +78 -4
- package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
- package/dist/testing/cross_backend/login_security.js +13 -10
- package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
- package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
- package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_header_conformance.js +196 -0
- package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
- package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
- package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_target_conformance.js +186 -0
- package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +185 -31
- package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
- package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
- package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +82 -34
- package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
- package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
- package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
- package/dist/testing/cross_backend/session_login.d.ts +24 -0
- package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
- package/dist/testing/cross_backend/session_login.js +31 -0
- package/dist/testing/cross_backend/setup.d.ts +117 -0
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +193 -9
- package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
- package/dist/testing/cross_backend/simple_request.js +5 -0
- package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +88 -5
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
- package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +205 -64
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +5 -2
- package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
- package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
- package/dist/testing/cross_backend/testing_credential_read.js +175 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +58 -2
- package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +13 -10
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
- package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
- package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_endpoint.js +19 -2
- package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_role_gated.js +2 -3
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +28 -12
- package/dist/testing/cross_backend/xfail.d.ts +44 -11
- package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
- package/dist/testing/cross_backend/xfail.js +68 -23
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +4 -3
- package/dist/testing/integration.d.ts +1 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +14 -8
- package/dist/testing/integration_helpers.d.ts +50 -3
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +87 -9
- package/dist/testing/middleware.d.ts +3 -1
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +14 -7
- package/dist/testing/resolved_auth.d.ts +3 -1
- package/dist/testing/resolved_auth.d.ts.map +1 -1
- package/dist/testing/resolved_auth.js +4 -4
- package/dist/testing/round_trip.d.ts +6 -2
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +17 -6
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +7 -0
- package/dist/testing/rpc_helpers.d.ts +4 -2
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +6 -1
- package/dist/testing/rpc_round_trip.d.ts +13 -2
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +25 -6
- package/dist/testing/schema_generators.d.ts +2 -2
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +4 -4
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +13 -10
- package/dist/testing/transports/fetch_transport.d.ts +6 -3
- package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
- package/dist/testing/transports/fetch_transport.js +31 -19
- package/dist/testing/transports/raw_http.d.ts +61 -1
- package/dist/testing/transports/raw_http.d.ts.map +1 -1
- package/dist/testing/transports/raw_http.js +61 -1
- package/dist/testing/transports/ws_raw_client.d.ts +20 -0
- package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
- package/dist/testing/transports/ws_raw_client.js +10 -4
- package/dist/testing/transports/ws_transport.d.ts +21 -1
- package/dist/testing/transports/ws_transport.d.ts.map +1 -1
- package/dist/testing/transports/ws_transport.js +58 -20
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +8 -4
- package/package.json +1 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The strict readers of the request target: the query string to its pairs,
|
|
3
|
+
* and one path segment to its text — each percent-decoded, or refused.
|
|
4
|
+
*
|
|
5
|
+
* An escape that doesn't decode is refused, never left literal and never
|
|
6
|
+
* replaced with U+FFFD: a `%` not followed by two hex digits is a
|
|
7
|
+
* `malformed_escape`, and decoded bytes that are not UTF-8 are
|
|
8
|
+
* `invalid_utf8`. A literal spelling would make `%FF` and `%25FF` one value,
|
|
9
|
+
* and a lossy one would make every invalid sequence the same U+FFFD — either
|
|
10
|
+
* way a handler reads a value the client never sent. The Rust spine's
|
|
11
|
+
* `fuz_http::request_target` reads by the same rule, and the shared table
|
|
12
|
+
* `testing/cross_backend/request_target_conformance.json` holds both to the
|
|
13
|
+
* same rows.
|
|
14
|
+
*
|
|
15
|
+
* The pure readers take text and are Hono-free. `read_request_query_pairs`
|
|
16
|
+
* and `read_request_route_params` apply them to a request (a type-only import
|
|
17
|
+
* of the Hono context): every read of the query or the path params in the
|
|
18
|
+
* spine goes through one of the two.
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
import type { Context } from 'hono';
|
|
23
|
+
import type { Result } from '@fuzdev/fuz_util/result.ts';
|
|
24
|
+
/** Why a query string or a path segment doesn't decode. */
|
|
25
|
+
export declare const PERCENT_DECODE_ERRORS: readonly ["malformed_escape", "invalid_utf8"];
|
|
26
|
+
/**
|
|
27
|
+
* Why a query string or a path segment doesn't decode: a `%` not followed by
|
|
28
|
+
* two hex digits, or decoded bytes that are not UTF-8. Twin of the Rust
|
|
29
|
+
* `fuz_http::PercentDecodeError`.
|
|
30
|
+
*/
|
|
31
|
+
export type PercentDecodeError = (typeof PERCENT_DECODE_ERRORS)[number];
|
|
32
|
+
/** One query pair, decoded: its name and its value. */
|
|
33
|
+
export type QueryPair = readonly [name: string, value: string];
|
|
34
|
+
/** A decoded query string, or why it doesn't decode. */
|
|
35
|
+
export type QueryPairsRead = Result<{
|
|
36
|
+
readonly value: ReadonlyArray<QueryPair>;
|
|
37
|
+
}, {
|
|
38
|
+
readonly error: PercentDecodeError;
|
|
39
|
+
}>;
|
|
40
|
+
/** A decoded path segment, or why it doesn't decode. */
|
|
41
|
+
export type PathSegmentRead = Result<{
|
|
42
|
+
readonly value: string;
|
|
43
|
+
}, {
|
|
44
|
+
readonly error: PercentDecodeError;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Read one raw path segment to its text: percent-decoded strictly, `+` left a
|
|
48
|
+
* plus (a path is no form encoding).
|
|
49
|
+
*
|
|
50
|
+
* @param segment - a segment of the raw request path, between two `/`
|
|
51
|
+
*/
|
|
52
|
+
export declare const read_path_segment: (segment: string) => PathSegmentRead;
|
|
53
|
+
/**
|
|
54
|
+
* Read a raw query string to its pairs, in order: split on `&` (an empty
|
|
55
|
+
* piece is no pair), each piece split at its first `=` (none reads an empty
|
|
56
|
+
* value), `+` read as a space, then name and value percent-decoded strictly.
|
|
57
|
+
* Every pair is read, a repeated key's and a nameless one's included, and the
|
|
58
|
+
* first component that doesn't decode refuses the whole string — a key no
|
|
59
|
+
* handler reads included, so no reader of one key sees a query another reader
|
|
60
|
+
* would refuse.
|
|
61
|
+
*
|
|
62
|
+
* What a pair means is the caller's: `query_first` takes a key's first
|
|
63
|
+
* occurrence, and `to_query_record` builds the record a route's query schema
|
|
64
|
+
* parses.
|
|
65
|
+
*
|
|
66
|
+
* @param query - the text after `?`, or `null` for a target with none
|
|
67
|
+
*/
|
|
68
|
+
export declare const read_query_pairs: (query: string | null) => QueryPairsRead;
|
|
69
|
+
/**
|
|
70
|
+
* The first value of `key` among `pairs` — a repeated key's later values are
|
|
71
|
+
* ignored. Twin of the Rust `fuz_http::query_first`.
|
|
72
|
+
*
|
|
73
|
+
* @returns the value, `''` for a key with no value, `undefined` when absent
|
|
74
|
+
*/
|
|
75
|
+
export declare const query_first: (pairs: ReadonlyArray<QueryPair>, key: string) => string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* The record a route's query schema parses: each name's first value, a
|
|
78
|
+
* nameless pair skipped — what Hono's `c.req.query()` builds, on a
|
|
79
|
+
* null-prototype object.
|
|
80
|
+
*/
|
|
81
|
+
export declare const to_query_record: (pairs: ReadonlyArray<QueryPair>) => Record<string, string>;
|
|
82
|
+
/**
|
|
83
|
+
* The path and the query of an absolute request URL, both as sent: the path
|
|
84
|
+
* from the first `/` after the authority, the query the text after the first
|
|
85
|
+
* `?` (`null` without one), a fragment dropped.
|
|
86
|
+
*
|
|
87
|
+
* @param url - the request URL, as the runtime serialized it
|
|
88
|
+
*/
|
|
89
|
+
export declare const split_request_url: (url: string) => {
|
|
90
|
+
path: string;
|
|
91
|
+
query: string | null;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* A request's path as sent — nothing percent-decoded — which the assembled
|
|
95
|
+
* server routes on (`new Hono({getPath})`), as the Rust spine's router
|
|
96
|
+
* matches the raw `Uri::path`. So `/%61pi/x` is its own path, not `/api/x`,
|
|
97
|
+
* on both spines, and every path-keyed layer (the auth and origin scopes,
|
|
98
|
+
* the origin carve-outs, the session-cookie clear, the unmatched-route
|
|
99
|
+
* handler) reads the spelling the router matched. Dot segments are the
|
|
100
|
+
* runtime's: Node and Bun resolve them while building the request's URL,
|
|
101
|
+
* before this runs.
|
|
102
|
+
*
|
|
103
|
+
* @param request - the request, its `url` as the runtime serialized it
|
|
104
|
+
*/
|
|
105
|
+
export declare const get_request_path: (request: Request) => string;
|
|
106
|
+
/**
|
|
107
|
+
* Read a request's query string strictly (`read_query_pairs`) — the one read
|
|
108
|
+
* of the query in the spine: the route context's `query_pairs`, a route's
|
|
109
|
+
* query schema, and the WebSocket upgrade's `acting`.
|
|
110
|
+
*
|
|
111
|
+
* @param c - the Hono context
|
|
112
|
+
*/
|
|
113
|
+
export declare const read_request_query_pairs: (c: Context) => QueryPairsRead;
|
|
114
|
+
/**
|
|
115
|
+
* Read the matched route's path params, every escape in the request path
|
|
116
|
+
* decoded strictly first — the one read of the path params in the spine.
|
|
117
|
+
*
|
|
118
|
+
* The whole path is read rather than each param's own segments: the router
|
|
119
|
+
* matches the raw path (`get_request_path`), so a literal segment matches
|
|
120
|
+
* only as the template spells it — no escape at all — and on a matched route
|
|
121
|
+
* every escape is inside a param. Once every segment decodes, Hono's own
|
|
122
|
+
* reading of each param — the raw matched text by `decodeURIComponent` — is
|
|
123
|
+
* exactly its strict decoding, so the values are taken from Hono's match,
|
|
124
|
+
* which knows which segments each param spans.
|
|
125
|
+
*
|
|
126
|
+
* @param c - the Hono context
|
|
127
|
+
* @returns the params by name, or why the path doesn't decode
|
|
128
|
+
*/
|
|
129
|
+
export declare const read_request_route_params: (c: Context) => Result<{
|
|
130
|
+
readonly value: Record<string, string>;
|
|
131
|
+
}, {
|
|
132
|
+
readonly error: PercentDecodeError;
|
|
133
|
+
}>;
|
|
134
|
+
//# sourceMappingURL=request_target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AAC,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAOtF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAWnF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,KAAG,MAA6C,CAAC;AAElG;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,GAAG,OAAO,KAAG,cACD,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,GACrC,GAAG,OAAO,KACR,MAAM,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAM3F,CAAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The strict readers of the request target: the query string to its pairs,
|
|
3
|
+
* and one path segment to its text — each percent-decoded, or refused.
|
|
4
|
+
*
|
|
5
|
+
* An escape that doesn't decode is refused, never left literal and never
|
|
6
|
+
* replaced with U+FFFD: a `%` not followed by two hex digits is a
|
|
7
|
+
* `malformed_escape`, and decoded bytes that are not UTF-8 are
|
|
8
|
+
* `invalid_utf8`. A literal spelling would make `%FF` and `%25FF` one value,
|
|
9
|
+
* and a lossy one would make every invalid sequence the same U+FFFD — either
|
|
10
|
+
* way a handler reads a value the client never sent. The Rust spine's
|
|
11
|
+
* `fuz_http::request_target` reads by the same rule, and the shared table
|
|
12
|
+
* `testing/cross_backend/request_target_conformance.json` holds both to the
|
|
13
|
+
* same rows.
|
|
14
|
+
*
|
|
15
|
+
* The pure readers take text and are Hono-free. `read_request_query_pairs`
|
|
16
|
+
* and `read_request_route_params` apply them to a request (a type-only import
|
|
17
|
+
* of the Hono context): every read of the query or the path params in the
|
|
18
|
+
* spine goes through one of the two.
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
21
|
+
*/
|
|
22
|
+
/** Why a query string or a path segment doesn't decode. */
|
|
23
|
+
export const PERCENT_DECODE_ERRORS = ['malformed_escape', 'invalid_utf8'];
|
|
24
|
+
const HEX_DIGIT = /^[0-9A-Fa-f]$/;
|
|
25
|
+
const UTF8 = new TextEncoder();
|
|
26
|
+
const UTF8_STRICT = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
|
|
27
|
+
/**
|
|
28
|
+
* Percent-decode `text` strictly: every `%` must start an escape of two hex
|
|
29
|
+
* digits, and the decoded bytes must be UTF-8. A malformed escape anywhere is
|
|
30
|
+
* reported ahead of invalid bytes, since it is found in the scan and the bytes
|
|
31
|
+
* are judged after it.
|
|
32
|
+
*/
|
|
33
|
+
const percent_decode_strict = (text) => {
|
|
34
|
+
if (!text.includes('%'))
|
|
35
|
+
return { ok: true, value: text };
|
|
36
|
+
const bytes = [];
|
|
37
|
+
for (let i = 0; i < text.length;) {
|
|
38
|
+
const char = text[i];
|
|
39
|
+
if (char === '%') {
|
|
40
|
+
const high = text[i + 1];
|
|
41
|
+
const low = text[i + 2];
|
|
42
|
+
if (high === undefined ||
|
|
43
|
+
low === undefined ||
|
|
44
|
+
!HEX_DIGIT.test(high) ||
|
|
45
|
+
!HEX_DIGIT.test(low)) {
|
|
46
|
+
return { ok: false, error: 'malformed_escape' };
|
|
47
|
+
}
|
|
48
|
+
bytes.push(Number.parseInt(high + low, 16));
|
|
49
|
+
i += 3;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// a run of literal text, as its UTF-8 bytes
|
|
53
|
+
const next = text.indexOf('%', i);
|
|
54
|
+
const end = next === -1 ? text.length : next;
|
|
55
|
+
for (const byte of UTF8.encode(text.slice(i, end)))
|
|
56
|
+
bytes.push(byte);
|
|
57
|
+
i = end;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return { ok: true, value: UTF8_STRICT.decode(new Uint8Array(bytes)) };
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return { ok: false, error: 'invalid_utf8' };
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Read one raw path segment to its text: percent-decoded strictly, `+` left a
|
|
69
|
+
* plus (a path is no form encoding).
|
|
70
|
+
*
|
|
71
|
+
* @param segment - a segment of the raw request path, between two `/`
|
|
72
|
+
*/
|
|
73
|
+
export const read_path_segment = (segment) => percent_decode_strict(segment);
|
|
74
|
+
/**
|
|
75
|
+
* Read a raw query string to its pairs, in order: split on `&` (an empty
|
|
76
|
+
* piece is no pair), each piece split at its first `=` (none reads an empty
|
|
77
|
+
* value), `+` read as a space, then name and value percent-decoded strictly.
|
|
78
|
+
* Every pair is read, a repeated key's and a nameless one's included, and the
|
|
79
|
+
* first component that doesn't decode refuses the whole string — a key no
|
|
80
|
+
* handler reads included, so no reader of one key sees a query another reader
|
|
81
|
+
* would refuse.
|
|
82
|
+
*
|
|
83
|
+
* What a pair means is the caller's: `query_first` takes a key's first
|
|
84
|
+
* occurrence, and `to_query_record` builds the record a route's query schema
|
|
85
|
+
* parses.
|
|
86
|
+
*
|
|
87
|
+
* @param query - the text after `?`, or `null` for a target with none
|
|
88
|
+
*/
|
|
89
|
+
export const read_query_pairs = (query) => {
|
|
90
|
+
const pairs = [];
|
|
91
|
+
if (query === null || query === '')
|
|
92
|
+
return { ok: true, value: pairs };
|
|
93
|
+
for (const piece of query.split('&')) {
|
|
94
|
+
if (piece === '')
|
|
95
|
+
continue;
|
|
96
|
+
const equals = piece.indexOf('=');
|
|
97
|
+
const raw_name = equals === -1 ? piece : piece.slice(0, equals);
|
|
98
|
+
const raw_value = equals === -1 ? '' : piece.slice(equals + 1);
|
|
99
|
+
const name = percent_decode_strict(raw_name.replaceAll('+', ' '));
|
|
100
|
+
if (!name.ok)
|
|
101
|
+
return name;
|
|
102
|
+
const value = percent_decode_strict(raw_value.replaceAll('+', ' '));
|
|
103
|
+
if (!value.ok)
|
|
104
|
+
return value;
|
|
105
|
+
pairs.push([name.value, value.value]);
|
|
106
|
+
}
|
|
107
|
+
return { ok: true, value: pairs };
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* The first value of `key` among `pairs` — a repeated key's later values are
|
|
111
|
+
* ignored. Twin of the Rust `fuz_http::query_first`.
|
|
112
|
+
*
|
|
113
|
+
* @returns the value, `''` for a key with no value, `undefined` when absent
|
|
114
|
+
*/
|
|
115
|
+
export const query_first = (pairs, key) => pairs.find(([name]) => name === key)?.[1];
|
|
116
|
+
/**
|
|
117
|
+
* The record a route's query schema parses: each name's first value, a
|
|
118
|
+
* nameless pair skipped — what Hono's `c.req.query()` builds, on a
|
|
119
|
+
* null-prototype object.
|
|
120
|
+
*/
|
|
121
|
+
export const to_query_record = (pairs) => {
|
|
122
|
+
const record = Object.create(null);
|
|
123
|
+
for (const [name, value] of pairs) {
|
|
124
|
+
if (name === '' || Object.hasOwn(record, name))
|
|
125
|
+
continue;
|
|
126
|
+
record[name] = value;
|
|
127
|
+
}
|
|
128
|
+
return record;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The path and the query of an absolute request URL, both as sent: the path
|
|
132
|
+
* from the first `/` after the authority, the query the text after the first
|
|
133
|
+
* `?` (`null` without one), a fragment dropped.
|
|
134
|
+
*
|
|
135
|
+
* @param url - the request URL, as the runtime serialized it
|
|
136
|
+
*/
|
|
137
|
+
export const split_request_url = (url) => {
|
|
138
|
+
const hash = url.indexOf('#');
|
|
139
|
+
const without_fragment = hash === -1 ? url : url.slice(0, hash);
|
|
140
|
+
const scheme_end = without_fragment.indexOf('://');
|
|
141
|
+
const path_start = without_fragment.indexOf('/', scheme_end === -1 ? 0 : scheme_end + 3);
|
|
142
|
+
if (path_start === -1)
|
|
143
|
+
return { path: '/', query: null };
|
|
144
|
+
const rest = without_fragment.slice(path_start);
|
|
145
|
+
const question = rest.indexOf('?');
|
|
146
|
+
return question === -1
|
|
147
|
+
? { path: rest, query: null }
|
|
148
|
+
: { path: rest.slice(0, question), query: rest.slice(question + 1) };
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* A request's path as sent — nothing percent-decoded — which the assembled
|
|
152
|
+
* server routes on (`new Hono({getPath})`), as the Rust spine's router
|
|
153
|
+
* matches the raw `Uri::path`. So `/%61pi/x` is its own path, not `/api/x`,
|
|
154
|
+
* on both spines, and every path-keyed layer (the auth and origin scopes,
|
|
155
|
+
* the origin carve-outs, the session-cookie clear, the unmatched-route
|
|
156
|
+
* handler) reads the spelling the router matched. Dot segments are the
|
|
157
|
+
* runtime's: Node and Bun resolve them while building the request's URL,
|
|
158
|
+
* before this runs.
|
|
159
|
+
*
|
|
160
|
+
* @param request - the request, its `url` as the runtime serialized it
|
|
161
|
+
*/
|
|
162
|
+
export const get_request_path = (request) => split_request_url(request.url).path;
|
|
163
|
+
/**
|
|
164
|
+
* Read a request's query string strictly (`read_query_pairs`) — the one read
|
|
165
|
+
* of the query in the spine: the route context's `query_pairs`, a route's
|
|
166
|
+
* query schema, and the WebSocket upgrade's `acting`.
|
|
167
|
+
*
|
|
168
|
+
* @param c - the Hono context
|
|
169
|
+
*/
|
|
170
|
+
export const read_request_query_pairs = (c) => read_query_pairs(split_request_url(c.req.url).query);
|
|
171
|
+
/**
|
|
172
|
+
* Read the matched route's path params, every escape in the request path
|
|
173
|
+
* decoded strictly first — the one read of the path params in the spine.
|
|
174
|
+
*
|
|
175
|
+
* The whole path is read rather than each param's own segments: the router
|
|
176
|
+
* matches the raw path (`get_request_path`), so a literal segment matches
|
|
177
|
+
* only as the template spells it — no escape at all — and on a matched route
|
|
178
|
+
* every escape is inside a param. Once every segment decodes, Hono's own
|
|
179
|
+
* reading of each param — the raw matched text by `decodeURIComponent` — is
|
|
180
|
+
* exactly its strict decoding, so the values are taken from Hono's match,
|
|
181
|
+
* which knows which segments each param spans.
|
|
182
|
+
*
|
|
183
|
+
* @param c - the Hono context
|
|
184
|
+
* @returns the params by name, or why the path doesn't decode
|
|
185
|
+
*/
|
|
186
|
+
export const read_request_route_params = (c) => {
|
|
187
|
+
for (const segment of split_request_url(c.req.url).path.split('/')) {
|
|
188
|
+
const read = read_path_segment(segment);
|
|
189
|
+
if (!read.ok)
|
|
190
|
+
return read;
|
|
191
|
+
}
|
|
192
|
+
return { ok: true, value: c.req.param() };
|
|
193
|
+
};
|
|
@@ -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,
|
|
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
|
|
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;;;;;;;;;;G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,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CAClB;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC7B,MAAM,SAAS;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACjE,CAAC,EAED,QAAQ,aAAa,CAAC,MAAM,CAAC,EAC7B,UAAU,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,KAC5B,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAKpB,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,
|
|
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
|
|
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,
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
*
|
|
11
|
-
*
|
|
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:
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
97
|
-
*
|
|
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
|
|
203
|
+
* @param stream - the stream, as `open_sse` returned it
|
|
100
204
|
*/
|
|
101
|
-
export declare const
|
|
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","sourceRoot":"","sources":["../../src/lib/http/route_result.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"route_result.d.ts","sourceRoot":"","sources":["../../src/lib/http/route_result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAErF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,8BAA8B;AAC9B,MAAM,WAAW,cAAc;IAC9B;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC5C;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC;IACzB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC3C;AA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