@fuzdev/fuz_app 0.150.0 → 0.152.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/README.md +1 -1
- package/dist/actions/CLAUDE.md +324 -299
- package/dist/actions/action_bridge.d.ts +5 -86
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +4 -84
- package/dist/actions/action_codegen.d.ts +8 -166
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +19 -95
- package/dist/actions/action_dispatcher.d.ts +10 -0
- package/dist/actions/action_dispatcher.d.ts.map +1 -1
- package/dist/actions/action_dispatcher.js +9 -6
- package/dist/actions/action_event.d.ts +1 -2
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +7 -13
- package/dist/actions/action_event_helpers.d.ts +1 -40
- package/dist/actions/action_event_helpers.d.ts.map +1 -1
- package/dist/actions/action_event_helpers.js +1 -25
- package/dist/actions/action_rpc.d.ts +10 -215
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +56 -111
- package/dist/actions/action_spec.d.ts +2 -2
- package/dist/actions/action_spec.js +2 -2
- package/dist/actions/action_types.d.ts +229 -8
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +56 -5
- package/dist/actions/broadcast_api.d.ts +22 -17
- package/dist/actions/broadcast_api.d.ts.map +1 -1
- package/dist/actions/broadcast_api.js +16 -27
- package/dist/actions/cancel.d.ts +4 -13
- package/dist/actions/cancel.d.ts.map +1 -1
- package/dist/actions/cancel.js +5 -17
- package/dist/actions/compile_action_registry.d.ts +1 -2
- package/dist/actions/compile_action_registry.d.ts.map +1 -1
- package/dist/actions/connection_closer.d.ts +120 -50
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +139 -31
- package/dist/actions/{transports_ws_backend.d.ts → connection_registry.d.ts} +120 -132
- package/dist/actions/connection_registry.d.ts.map +1 -0
- package/dist/actions/{transports_ws_backend.js → connection_registry.js} +149 -152
- package/dist/actions/frontend_rpc_client.d.ts +52 -2
- package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
- package/dist/actions/frontend_rpc_client.js +42 -4
- package/dist/actions/peer_ping.d.ts +7 -9
- package/dist/actions/peer_ping.d.ts.map +1 -1
- package/dist/actions/peer_ping.js +6 -8
- package/dist/actions/peer_request.d.ts +6 -5
- package/dist/actions/peer_request.d.ts.map +1 -1
- package/dist/actions/peer_request.js +6 -5
- package/dist/actions/perform_action.d.ts +36 -28
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +60 -34
- package/dist/actions/protocol.d.ts +14 -0
- package/dist/actions/protocol.d.ts.map +1 -1
- package/dist/actions/protocol.js +18 -0
- package/dist/actions/register_action_ws.d.ts +137 -298
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +155 -923
- package/dist/actions/socket.svelte.d.ts +9 -0
- package/dist/actions/socket.svelte.d.ts.map +1 -1
- package/dist/actions/socket.svelte.js +16 -5
- package/dist/actions/transports.d.ts +88 -34
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +76 -76
- package/dist/actions/transports_http.d.ts +48 -12
- package/dist/actions/transports_http.d.ts.map +1 -1
- package/dist/actions/transports_http.js +75 -44
- package/dist/actions/transports_ws.d.ts +29 -0
- package/dist/actions/transports_ws.d.ts.map +1 -1
- package/dist/actions/transports_ws.js +34 -8
- package/dist/actions/ws_endpoint_spec.d.ts +52 -75
- package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
- package/dist/actions/ws_endpoint_spec.js +27 -10
- package/dist/actions/ws_outbound_writer.d.ts +3 -3
- package/dist/actions/ws_outbound_writer.js +3 -3
- package/dist/actions/ws_socket_session.d.ts +321 -0
- package/dist/actions/ws_socket_session.d.ts.map +1 -0
- package/dist/actions/ws_socket_session.js +783 -0
- package/dist/auth/CLAUDE.md +70 -44
- package/dist/auth/account_action_specs.d.ts +2 -0
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_actions.d.ts +1 -1
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +9 -3
- package/dist/auth/account_queries.d.ts +10 -0
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +27 -17
- package/dist/auth/account_routes.d.ts +2 -1
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +14 -17
- package/dist/auth/account_schema.d.ts +5 -5
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +5 -2
- package/dist/auth/actor_lookup_actions.d.ts +1 -1
- package/dist/auth/actor_lookup_actions.d.ts.map +1 -1
- package/dist/auth/actor_lookup_actions.js +1 -1
- package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
- package/dist/auth/actor_search_action_specs.js +2 -1
- package/dist/auth/actor_search_actions.d.ts +1 -1
- package/dist/auth/actor_search_actions.d.ts.map +1 -1
- package/dist/auth/actor_search_actions.js +1 -1
- package/dist/auth/actor_search_queries.d.ts +5 -5
- package/dist/auth/actor_search_queries.d.ts.map +1 -1
- package/dist/auth/actor_search_queries.js +7 -7
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +3 -1
- package/dist/auth/admin_actions.d.ts +1 -1
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +12 -42
- package/dist/auth/all_cell_actions.d.ts +6 -4
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +1 -1
- package/dist/auth/api_token_queries.d.ts +1 -0
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +1 -0
- package/dist/auth/audit_emitter.d.ts +3 -3
- package/dist/auth/audit_emitter.js +2 -2
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_route_schema.js +3 -2
- package/dist/auth/audit_log_routes.d.ts +20 -11
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +49 -29
- package/dist/auth/audit_log_schema.d.ts +13 -21
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +10 -18
- package/dist/auth/bearer_auth.d.ts +7 -4
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +21 -15
- package/dist/auth/cell_action_helpers.d.ts +89 -0
- package/dist/auth/cell_action_helpers.d.ts.map +1 -0
- package/dist/auth/cell_action_helpers.js +113 -0
- package/dist/auth/cell_actions.d.ts +22 -13
- package/dist/auth/cell_actions.d.ts.map +1 -1
- package/dist/auth/cell_actions.js +105 -167
- package/dist/auth/cell_audit_actions.d.ts +1 -1
- package/dist/auth/cell_audit_actions.d.ts.map +1 -1
- package/dist/auth/cell_audit_actions.js +3 -12
- package/dist/auth/cell_audit_metadata.d.ts +1 -1
- package/dist/auth/cell_audit_metadata.js +1 -1
- package/dist/auth/cell_field_actions.d.ts +1 -1
- package/dist/auth/cell_field_actions.d.ts.map +1 -1
- package/dist/auth/cell_field_actions.js +16 -66
- package/dist/auth/cell_grant_action_specs.d.ts +2 -2
- package/dist/auth/cell_grant_action_specs.js +3 -3
- package/dist/auth/cell_grant_actions.d.ts +73 -11
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +63 -55
- package/dist/auth/cell_grant_audit_metadata.d.ts +6 -3
- package/dist/auth/cell_grant_audit_metadata.d.ts.map +1 -1
- package/dist/auth/cell_grant_audit_metadata.js +7 -4
- package/dist/auth/cell_item_actions.d.ts +1 -1
- package/dist/auth/cell_item_actions.d.ts.map +1 -1
- package/dist/auth/cell_item_actions.js +21 -82
- package/dist/auth/cleanup.d.ts +1 -1
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +6 -3
- package/dist/auth/credential_deadline.d.ts +3 -3
- package/dist/auth/credential_deadline.js +3 -3
- package/dist/auth/credential_type_schema.d.ts +5 -5
- package/dist/auth/credential_type_schema.js +5 -5
- package/dist/auth/daemon_token_middleware.d.ts +12 -6
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +28 -17
- package/dist/auth/deps.d.ts +4 -4
- package/dist/auth/fail_floor.d.ts +55 -0
- package/dist/auth/fail_floor.d.ts.map +1 -0
- package/dist/auth/fail_floor.js +63 -0
- package/dist/auth/invite_queries.d.ts +3 -15
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +3 -21
- package/dist/auth/middleware.d.ts +12 -7
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +42 -29
- package/dist/auth/migrations.d.ts +5 -33
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +9 -16
- package/dist/auth/request_context.d.ts +101 -71
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +137 -140
- package/dist/auth/resolved_auth.d.ts +122 -36
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +89 -38
- package/dist/auth/role_grant_offer_action_specs.d.ts +99 -14
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +26 -13
- package/dist/auth/role_grant_offer_actions.d.ts +13 -7
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +14 -12
- package/dist/auth/role_grant_offer_notifications.d.ts +3 -3
- package/dist/auth/role_grant_offer_notifications.js +1 -1
- package/dist/auth/role_grant_offer_queries.d.ts +0 -5
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +9 -41
- package/dist/auth/role_grant_queries.d.ts +17 -67
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +34 -106
- package/dist/auth/role_grant_sql.d.ts +42 -0
- package/dist/auth/role_grant_sql.d.ts.map +1 -0
- package/dist/auth/role_grant_sql.js +54 -0
- package/dist/auth/scope_kind_schema.d.ts +1 -1
- package/dist/auth/scope_kind_schema.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +1 -1
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +1 -1
- package/dist/auth/session_queries.d.ts +2 -1
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +2 -1
- package/dist/auth/signup_routes.d.ts +2 -1
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +14 -13
- package/dist/auth/standard_rpc_actions.d.ts +1 -1
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/token_scope.d.ts +19 -46
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +23 -41
- package/dist/db/CLAUDE.md +9 -4
- package/dist/db/cell_ddl.d.ts +5 -142
- package/dist/db/cell_ddl.d.ts.map +1 -1
- package/dist/db/cell_ddl.js +17 -16
- package/dist/db/cell_field_queries.d.ts +0 -13
- package/dist/db/cell_field_queries.d.ts.map +1 -1
- package/dist/db/cell_field_queries.js +0 -16
- package/dist/db/cell_grant_queries.d.ts +10 -5
- package/dist/db/cell_grant_queries.d.ts.map +1 -1
- package/dist/db/cell_grant_queries.js +13 -7
- package/dist/db/cell_item_queries.d.ts +0 -7
- package/dist/db/cell_item_queries.d.ts.map +1 -1
- package/dist/db/cell_item_queries.js +0 -10
- package/dist/db/cell_queries.d.ts +12 -48
- package/dist/db/cell_queries.d.ts.map +1 -1
- package/dist/db/cell_queries.js +24 -55
- package/dist/db/cell_view_sql.d.ts +1 -6
- package/dist/db/cell_view_sql.d.ts.map +1 -1
- package/dist/db/cell_view_sql.js +1 -2
- package/dist/db/fact_ddl.d.ts +5 -30
- package/dist/db/fact_ddl.d.ts.map +1 -1
- package/dist/db/fact_ddl.js +14 -13
- package/dist/db/fact_store.d.ts +11 -0
- package/dist/db/fact_store.d.ts.map +1 -1
- package/dist/db/fact_store.js +4 -1
- package/dist/db/migrate.d.ts +44 -6
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +63 -4
- package/dist/dev/setup.d.ts +18 -14
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +42 -39
- package/dist/env/dotenv.d.ts +2 -2
- package/dist/env/dotenv.js +2 -2
- package/dist/env/update_env_variable.d.ts +33 -21
- package/dist/env/update_env_variable.d.ts.map +1 -1
- package/dist/env/update_env_variable.js +54 -35
- package/dist/hono_context.d.ts +15 -90
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +9 -56
- package/dist/http/CLAUDE.md +35 -20
- package/dist/http/auth_shape.d.ts +1 -8
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +6 -12
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +3 -2
- package/dist/http/db_routes.d.ts +3 -3
- package/dist/http/db_routes.js +3 -3
- package/dist/http/error_schemas.d.ts +1 -2
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +1 -2
- package/dist/http/health_schema.d.ts +16 -0
- package/dist/http/health_schema.d.ts.map +1 -0
- package/dist/http/health_schema.js +12 -0
- package/dist/http/jsonrpc_errors.d.ts +22 -2
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +41 -3
- package/dist/http/jsonrpc_helpers.d.ts +60 -17
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +67 -25
- package/dist/http/origin.d.ts +30 -1
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +46 -9
- package/dist/http/origin_wildcard.d.ts +97 -0
- package/dist/http/origin_wildcard.d.ts.map +1 -0
- package/dist/http/origin_wildcard.js +142 -0
- package/dist/http/pending_effects.d.ts +28 -0
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +32 -1
- package/dist/http/route_spec.d.ts +4 -3
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +54 -45
- package/dist/http/surface.d.ts +1 -1
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface_query.d.ts +9 -50
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +48 -94
- package/dist/realtime/audit_log_sse.d.ts +180 -0
- package/dist/realtime/audit_log_sse.d.ts.map +1 -0
- package/dist/realtime/audit_log_sse.js +154 -0
- package/dist/realtime/sse.d.ts +21 -6
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +33 -10
- package/dist/realtime/sse_constants.d.ts +29 -2
- package/dist/realtime/sse_constants.d.ts.map +1 -1
- package/dist/realtime/sse_constants.js +35 -2
- package/dist/realtime/{subscriber_registry.d.ts → sse_registry.d.ts} +12 -12
- package/dist/realtime/sse_registry.d.ts.map +1 -0
- package/dist/realtime/{subscriber_registry.js → sse_registry.js} +4 -4
- package/dist/schema_meta.d.ts +30 -10
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +85 -21
- package/dist/sensitivity.d.ts +9 -3
- package/dist/sensitivity.d.ts.map +1 -1
- package/dist/sensitivity.js +3 -2
- package/dist/server/app_backend.d.ts +8 -5
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +6 -12
- package/dist/server/app_server.d.ts +62 -51
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +84 -71
- package/dist/server/app_server_context.d.ts +1 -1
- package/dist/server/app_server_context.d.ts.map +1 -1
- package/dist/server/env.d.ts +24 -20
- package/dist/server/env.d.ts.map +1 -1
- package/dist/server/env.js +24 -34
- package/dist/server/serve_fact_route.d.ts +12 -16
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +59 -34
- package/dist/server/static.d.ts.map +1 -1
- package/dist/server/static.js +2 -2
- package/dist/testing/CLAUDE.md +179 -158
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +10 -19
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +8 -0
- package/dist/testing/app_server.d.ts +9 -77
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +31 -112
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +3 -4
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +4 -5
- package/dist/testing/auth_apps.d.ts +3 -3
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +9 -6
- package/dist/testing/connection_closer_helpers.d.ts +8 -16
- package/dist/testing/connection_closer_helpers.d.ts.map +1 -1
- package/dist/testing/connection_closer_helpers.js +7 -20
- package/dist/testing/cross_backend/action_manifest.d.ts +15 -4
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +13 -3
- package/dist/testing/cross_backend/action_manifest_parity.d.ts +15 -7
- package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest_parity.js +8 -1
- package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
- package/dist/testing/cross_backend/body_size.js +25 -22
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts +22 -3
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
- package/dist/testing/cross_backend/build_test_backend_paths.js +34 -11
- package/dist/testing/cross_backend/capabilities.d.ts +13 -7
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_grant_role.js +2 -2
- package/dist/testing/cross_backend/cell_grant_steward.d.ts +4 -0
- package/dist/testing/cross_backend/cell_grant_steward.d.ts.map +1 -0
- package/dist/testing/cross_backend/cell_grant_steward.js +120 -0
- package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_relations.js +21 -0
- package/dist/testing/cross_backend/conformance_table.d.ts +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.d.ts +18 -4
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +29 -9
- package/dist/testing/cross_backend/default_spine_surface.d.ts +7 -7
- package/dist/testing/cross_backend/default_spine_surface.js +2 -2
- package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
- package/dist/testing/cross_backend/fact_serving.js +48 -0
- package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -4
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +9 -2
- package/dist/testing/cross_backend/origin_scope.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin_scope.js +5 -13
- package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.js +29 -4
- package/dist/testing/cross_backend/postgres_database.d.ts +32 -0
- package/dist/testing/cross_backend/postgres_database.d.ts.map +1 -1
- package/dist/testing/cross_backend/postgres_database.js +56 -1
- package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
- package/dist/testing/cross_backend/query_shape.js +18 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +23 -1
- package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -2
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +17 -5
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +5 -4
- package/dist/testing/cross_backend/session_cap.d.ts +8 -0
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +66 -2
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +5 -4
- package/dist/testing/cross_backend/spine_suites.d.ts +4 -1
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +21 -0
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +22 -7
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +22 -7
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +4 -3
- package/dist/testing/cross_backend/standard.d.ts +6 -12
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts +8 -0
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts.map +1 -0
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.js +22 -0
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +4 -6
- package/dist/testing/cross_backend/testing_origin_check.d.ts +1 -1
- package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.js +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +10 -5
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +7 -6
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_bun.js +5 -4
- package/dist/testing/cross_backend/testing_server_core.d.ts +6 -7
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +1 -1
- package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_node.js +13 -2
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +68 -0
- package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +45 -3
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +16 -2
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +11 -8
- package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_action_rate_limit.js +30 -12
- package/dist/testing/cross_backend/ws_connection_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_connection_cap.js +5 -7
- package/dist/testing/cross_backend/ws_endpoint.d.ts +2 -3
- package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_envelope.d.ts +17 -0
- package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -0
- package/dist/testing/cross_backend/ws_envelope.js +172 -0
- package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts +16 -0
- package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_inbound_dispatch.js +8 -4
- package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_outbound_overflow.js +5 -8
- package/dist/testing/cross_backend/ws_role_gated.js +2 -2
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +6 -4
- package/dist/{cli/daemon.d.ts → testing/daemon_info.d.ts} +15 -47
- package/dist/testing/daemon_info.d.ts.map +1 -0
- package/dist/testing/daemon_info.js +108 -0
- package/dist/testing/daemon_token_rotation.js +1 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +3 -4
- package/dist/testing/db.js +2 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +35 -65
- package/dist/testing/integration_helpers.d.ts +0 -15
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +2 -42
- package/dist/testing/middleware.d.ts +20 -12
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +49 -40
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +13 -22
- package/dist/testing/resolved_auth.d.ts +30 -0
- package/dist/testing/resolved_auth.d.ts.map +1 -0
- package/dist/testing/resolved_auth.js +41 -0
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +3 -0
- package/dist/testing/rpc_helpers.d.ts +1 -1
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +2 -1
- package/dist/testing/sse_round_trip.d.ts +5 -4
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +24 -21
- package/dist/testing/test_origin.d.ts +25 -0
- package/dist/testing/test_origin.d.ts.map +1 -0
- package/dist/testing/test_origin.js +28 -0
- package/dist/testing/transports/raw_http.d.ts +54 -0
- package/dist/testing/transports/raw_http.d.ts.map +1 -1
- package/dist/testing/transports/raw_http.js +58 -0
- package/dist/testing/transports/ws_raw_client.d.ts +8 -0
- package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
- package/dist/testing/transports/ws_raw_client.js +13 -0
- package/dist/testing/transports/ws_transport.d.ts +15 -2
- package/dist/testing/transports/ws_transport.d.ts.map +1 -1
- package/dist/testing/transports/ws_transport.js +4 -2
- package/dist/testing/ws_round_trip.d.ts +27 -25
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +34 -26
- package/dist/ui/AccountSessions.svelte +48 -19
- package/dist/ui/AccountSessions.svelte.d.ts +2 -17
- package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAccounts.svelte +6 -1
- package/dist/ui/AdminAuditLog.svelte +61 -22
- package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
- package/dist/ui/AdminInvites.svelte +1 -1
- package/dist/ui/AdminOverview.svelte +76 -37
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/AdminRoleGrantHistory.svelte +6 -1
- package/dist/ui/AdminSessions.svelte +1 -1
- package/dist/ui/AppShell.svelte +3 -2
- package/dist/ui/AppShell.svelte.d.ts +3 -2
- package/dist/ui/AppShell.svelte.d.ts.map +1 -1
- package/dist/ui/CLAUDE.md +121 -35
- package/dist/ui/Datatable.svelte +33 -18
- package/dist/ui/Datatable.svelte.d.ts +2 -14
- package/dist/ui/Datatable.svelte.d.ts.map +1 -1
- package/dist/ui/OpenSignupToggle.svelte +10 -1
- package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
- package/dist/ui/PopoverButton.svelte +13 -8
- package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
- package/dist/ui/RoleGrantOfferForm.svelte +3 -2
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts +3 -2
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
- package/dist/ui/RoleGrantOfferHistory.svelte +3 -3
- package/dist/ui/RoleGrantOfferInbox.svelte +19 -15
- package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
- package/dist/ui/SurfaceExplorer.svelte +66 -27
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +7 -14
- package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.d.ts +14 -9
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.js +6 -4
- package/dist/ui/admin_invites_state.svelte.d.ts +2 -2
- package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.d.ts +9 -9
- package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.js +9 -9
- package/dist/ui/app_settings_state.svelte.d.ts +2 -2
- package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.d.ts +70 -13
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +239 -47
- package/dist/ui/backend_probe.svelte.d.ts +93 -0
- package/dist/ui/backend_probe.svelte.d.ts.map +1 -0
- package/dist/ui/backend_probe.svelte.js +140 -0
- package/dist/ui/format_scope.d.ts +7 -7
- package/dist/ui/format_scope.d.ts.map +1 -1
- package/dist/ui/format_scope.js +4 -4
- package/dist/ui/keyed_async_slot.svelte.d.ts +2 -2
- package/dist/ui/keyed_async_slot.svelte.js +2 -2
- package/dist/ui/popover.svelte.d.ts +18 -19
- package/dist/ui/popover.svelte.d.ts.map +1 -1
- package/dist/ui/popover.svelte.js +103 -16
- package/dist/ui/role_grant_offers_state.svelte.d.ts +41 -46
- package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
- package/dist/ui/role_grant_offers_state.svelte.js +37 -19
- package/dist/ui/ui_format.d.ts +17 -0
- package/dist/ui/ui_format.d.ts.map +1 -1
- package/dist/ui/ui_format.js +20 -0
- package/package.json +9 -8
- package/dist/actions/register_ws_endpoint.d.ts +0 -79
- package/dist/actions/register_ws_endpoint.d.ts.map +0 -1
- package/dist/actions/register_ws_endpoint.js +0 -109
- package/dist/actions/transports_ws_auth_guard.d.ts +0 -96
- package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
- package/dist/actions/transports_ws_auth_guard.js +0 -141
- package/dist/actions/transports_ws_backend.d.ts.map +0 -1
- package/dist/cli/args.d.ts +0 -55
- package/dist/cli/args.d.ts.map +0 -1
- package/dist/cli/args.js +0 -100
- package/dist/cli/config.d.ts +0 -47
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js +0 -77
- package/dist/cli/daemon.d.ts.map +0 -1
- package/dist/cli/daemon.js +0 -181
- package/dist/cli/help.d.ts +0 -124
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/help.js +0 -215
- package/dist/cli/logger.d.ts +0 -46
- package/dist/cli/logger.d.ts.map +0 -1
- package/dist/cli/logger.js +0 -48
- package/dist/cli/util.d.ts +0 -36
- package/dist/cli/util.d.ts.map +0 -1
- package/dist/cli/util.js +0 -50
- package/dist/realtime/sse_auth_guard.d.ts +0 -197
- package/dist/realtime/sse_auth_guard.d.ts.map +0 -1
- package/dist/realtime/sse_auth_guard.js +0 -239
- package/dist/realtime/subscriber_registry.d.ts.map +0 -1
- package/dist/testing/bootstrap_success.d.ts +0 -29
- package/dist/testing/bootstrap_success.d.ts.map +0 -1
- package/dist/testing/bootstrap_success.js +0 -144
- package/dist/testing/mock_fs.d.ts +0 -20
- package/dist/testing/mock_fs.d.ts.map +0 -1
- package/dist/testing/mock_fs.js +0 -28
- package/dist/testing/standard.d.ts +0 -122
- package/dist/testing/standard.d.ts.map +0 -1
- package/dist/testing/standard.js +0 -73
- package/dist/testing/testing_rate_limiter.d.ts +0 -65
- package/dist/testing/testing_rate_limiter.d.ts.map +0 -1
- package/dist/testing/testing_rate_limiter.js +0 -80
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared type surface for the action system — `Action` (the composable
|
|
3
|
-
* `{spec, handler?}` tuple)
|
|
4
|
-
*
|
|
3
|
+
* `{spec, handler?}` tuple), the handler context `ActionContext` and its
|
|
4
|
+
* narrowed tiers, the handler signatures, `RpcAction`, and the `rpc_action`
|
|
5
|
+
* binder.
|
|
5
6
|
*
|
|
6
7
|
* Sits above `actions/action_spec.ts` (pure Zod schemas) and below the
|
|
7
8
|
* dispatchers (`actions/register_action_ws.ts`, `actions/action_rpc.ts`,
|
|
8
9
|
* `actions/perform_action.ts`). Extracted so the shared protocol actions
|
|
9
|
-
* (e.g. `heartbeat_action`) can name them without
|
|
10
|
-
* modules
|
|
10
|
+
* (e.g. `heartbeat_action`) and every action factory can name them without
|
|
11
|
+
* pulling in server-only modules — everything here is type-only but the
|
|
12
|
+
* identity-function binder.
|
|
11
13
|
*
|
|
12
14
|
* HTTP RPC and WebSocket dispatchers both call into `perform_action`,
|
|
13
15
|
* and both pass the same `ActionContext` to the handler. Consumers
|
|
@@ -16,8 +18,15 @@
|
|
|
16
18
|
*
|
|
17
19
|
* @module
|
|
18
20
|
*/
|
|
19
|
-
import type {
|
|
20
|
-
import type {
|
|
21
|
+
import type { z } from 'zod';
|
|
22
|
+
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
23
|
+
import type { ActionSpecUnion, RequestResponseActionSpec } from './action_spec.js';
|
|
24
|
+
import type { Uuid } from '../primitive_schemas.js';
|
|
25
|
+
import type { RequestActorContext, RequestContext } from '../auth/request_context.js';
|
|
26
|
+
import type { BuiltinCredentialType } from '../auth/credential_type_schema.js';
|
|
27
|
+
import type { Db } from '../db/db.js';
|
|
28
|
+
import type { JsonrpcRequestId } from '../http/jsonrpc.js';
|
|
29
|
+
import type { RequestClient } from './peer_request.js';
|
|
21
30
|
/**
|
|
22
31
|
* A spec paired with its optional handler — the composable unit passed to
|
|
23
32
|
* `register_action_ws` and `create_rpc_client`. The server uses both
|
|
@@ -27,8 +36,8 @@ import type { ActionHandler } from './action_rpc.js';
|
|
|
27
36
|
* arrays without inventing per-repo ping plumbing.
|
|
28
37
|
*
|
|
29
38
|
* Polymorphic on `kind`: `request_response` specs require a handler for
|
|
30
|
-
* dispatch; `remote_notification` specs
|
|
31
|
-
*
|
|
39
|
+
* dispatch; `remote_notification` specs are dispatcher-handled (e.g.
|
|
40
|
+
* `cancel`, which has no handler); `local_call` specs
|
|
32
41
|
* never reach a network dispatcher. The WS dispatcher only invokes
|
|
33
42
|
* handlers on `request_response` actions; everything else is registry-only.
|
|
34
43
|
*/
|
|
@@ -37,4 +46,216 @@ export interface Action<TSpec extends ActionSpecUnion = ActionSpecUnion> {
|
|
|
37
46
|
/** Server-side handler — invoked by dispatchers on `request_response` actions. Ignored for client-only specs and dispatcher-handled notifications. */
|
|
38
47
|
handler?: ActionHandler;
|
|
39
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Per-request context provided to action handlers across every transport
|
|
51
|
+
* (HTTP RPC and WebSocket). Built once per dispatched action by
|
|
52
|
+
* `perform_action` and threaded into the handler.
|
|
53
|
+
*
|
|
54
|
+
* `auth` is `RequestContext | null` — handlers for authenticated actions
|
|
55
|
+
* can narrow via the dispatcher's authorization-phase guarantee.
|
|
56
|
+
*
|
|
57
|
+
* Single handler context shape across every transport. Consumers inject
|
|
58
|
+
* domain deps via factory closures the same way HTTP RPC factories do.
|
|
59
|
+
*/
|
|
60
|
+
export interface ActionContext {
|
|
61
|
+
/** The authenticated identity, or `null` for public routes. */
|
|
62
|
+
auth: RequestContext | null;
|
|
63
|
+
/** The JSON-RPC request ID from the envelope. */
|
|
64
|
+
request_id: JsonrpcRequestId;
|
|
65
|
+
/**
|
|
66
|
+
* Stable per-socket connection id on WebSocket transport; `undefined`
|
|
67
|
+
* on HTTP RPC. Consumers key per-connection domain state on this
|
|
68
|
+
* directly; HTTP handlers ignore it.
|
|
69
|
+
*/
|
|
70
|
+
connection_id?: Uuid;
|
|
71
|
+
/**
|
|
72
|
+
* Initiate a JSON-RPC request to the originating client and await its typed
|
|
73
|
+
* reply — the server→client direction of ActionPeer. Present only on the
|
|
74
|
+
* WebSocket transport (it targets the originating socket); `undefined` on
|
|
75
|
+
* HTTP RPC, where there is no return socket. Handlers that depend on it
|
|
76
|
+
* must handle its absence — e.g. `peer/ping` surfaces `peer_no_transport`.
|
|
77
|
+
*/
|
|
78
|
+
request_client?: RequestClient;
|
|
79
|
+
/**
|
|
80
|
+
* Transaction-scoped when `spec.side_effects` is true (the dispatcher
|
|
81
|
+
* wraps in `db.transaction`); pool-level otherwise. Handlers that
|
|
82
|
+
* need rollback-resilient writes call `deps.audit.emit(ctx, input)`,
|
|
83
|
+
* which captures the pool inside its closure.
|
|
84
|
+
*/
|
|
85
|
+
db: Db;
|
|
86
|
+
/**
|
|
87
|
+
* Eager fire-and-forget queue — push the in-flight `Promise<void>` for
|
|
88
|
+
* pool writes already running (audit emits, api-token usage
|
|
89
|
+
* tracking). Drained via `flush_pending_effects` after the
|
|
90
|
+
* handler returns.
|
|
91
|
+
*/
|
|
92
|
+
pending_effects: Array<Promise<void>>;
|
|
93
|
+
/**
|
|
94
|
+
* Deferred post-commit thunks — do not push directly; reach for
|
|
95
|
+
* `emit_after_commit(ctx, fn)` from `http/pending_effects.ts`. The flush
|
|
96
|
+
* site invokes each thunk after the handler (and any wrapping
|
|
97
|
+
* `db.transaction`) returns.
|
|
98
|
+
*/
|
|
99
|
+
post_commit_effects: Array<() => void | Promise<void>>;
|
|
100
|
+
/**
|
|
101
|
+
* Resolved client IP from the trusted-proxy middleware — `'unknown'` if the
|
|
102
|
+
* middleware wasn't in the stack (e.g. WS dispatch) or couldn't resolve.
|
|
103
|
+
* Thread into `deps.audit.emit` as `ip: ctx.client_ip` for every
|
|
104
|
+
* user-initiated action so RPC audit rows match the REST convention. Pass
|
|
105
|
+
* `null` only for rows written outside a request (e.g. the
|
|
106
|
+
* `role_grant_offer_expire` cleanup sweep in `auth/cleanup.ts`).
|
|
107
|
+
*/
|
|
108
|
+
client_ip: string;
|
|
109
|
+
/**
|
|
110
|
+
* Credential channel the request arrived on (`'session'` | `'api_token'` |
|
|
111
|
+
* `'daemon_token'`), or `null` for anonymous requests. Same value the
|
|
112
|
+
* dispatcher's `credential_types` gate consumed at step 3 — exposed here
|
|
113
|
+
* so handlers can record it in audit metadata (defense in depth: the
|
|
114
|
+
* gate may be loosened or bypassed in a future refactor, but the audit
|
|
115
|
+
* row preserves what actually authenticated the request).
|
|
116
|
+
*/
|
|
117
|
+
credential_type: BuiltinCredentialType | null;
|
|
118
|
+
/**
|
|
119
|
+
* Blake3 hash of the session token the request authenticated with — the
|
|
120
|
+
* `auth_session.id` of the caller's own session — or `null` for any other
|
|
121
|
+
* credential and for anonymous requests.
|
|
122
|
+
*/
|
|
123
|
+
session_hash: string | null;
|
|
124
|
+
/** Logger instance. */
|
|
125
|
+
log: Logger;
|
|
126
|
+
/**
|
|
127
|
+
* Send a request-scoped JSON-RPC notification to the originator.
|
|
128
|
+
*
|
|
129
|
+
* On streaming transports (WebSocket) this routes to the originating
|
|
130
|
+
* connection only. On the HTTP RPC transport this is a no-op with a
|
|
131
|
+
* DEV-mode warn — non-streaming transports have no channel for mid-
|
|
132
|
+
* request notifications. The `streams` field on an `ActionSpec` names
|
|
133
|
+
* the notification method this handler is expected to emit.
|
|
134
|
+
*/
|
|
135
|
+
notify: (method: string, params: unknown) => void;
|
|
136
|
+
/**
|
|
137
|
+
* AbortSignal that fires when the originating request is cancelled
|
|
138
|
+
* (client disconnect on HTTP, socket close or per-request cancel
|
|
139
|
+
* notification on WebSocket). Streaming handlers should check this
|
|
140
|
+
* for early termination.
|
|
141
|
+
*/
|
|
142
|
+
signal: AbortSignal;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Handler function for an RPC action.
|
|
146
|
+
*
|
|
147
|
+
* Receives validated input and an `ActionContext` with per-request deps.
|
|
148
|
+
* Returns the output value (serialized to JSON by the wrapper).
|
|
149
|
+
*/
|
|
150
|
+
export type ActionHandler<TInput = any, TOutput = any> = (input: TInput, ctx: ActionContext) => TOutput | Promise<TOutput>;
|
|
151
|
+
/**
|
|
152
|
+
* `ActionContext` narrowed to a non-null `RequestContext`.
|
|
153
|
+
*
|
|
154
|
+
* Used by handlers whose spec declares `auth.account === 'required'`
|
|
155
|
+
* (with `auth.actor === 'none'`) — the dispatcher's pre-authorization 401
|
|
156
|
+
* gate guarantees `request_context` is populated before the handler
|
|
157
|
+
* runs, but the actor slot stays null because no `acting` resolution
|
|
158
|
+
* happened. Selected automatically by `rpc_action`'s conditional return
|
|
159
|
+
* type for the account-grain tier.
|
|
160
|
+
*/
|
|
161
|
+
export interface ActionAuthContext extends Omit<ActionContext, 'auth'> {
|
|
162
|
+
auth: RequestContext;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Handler signature for an account-grain RPC action — `auth.account === 'required'`
|
|
166
|
+
* and `auth.actor === 'none'`. Mirrors `ActionHandler` but tightens the
|
|
167
|
+
* `ctx.auth` slot to the non-null `RequestContext` (with `actor: null`).
|
|
168
|
+
*/
|
|
169
|
+
export type AuthActionHandler<TInput = any, TOutput = any> = (input: TInput, ctx: ActionAuthContext) => TOutput | Promise<TOutput>;
|
|
170
|
+
/**
|
|
171
|
+
* `ActionContext` narrowed to a resolved acting actor.
|
|
172
|
+
*
|
|
173
|
+
* Used by handlers whose spec declares `auth.actor === 'required'` —
|
|
174
|
+
* the dispatcher's authorization phase resolves an actor (per
|
|
175
|
+
* registry-time invariant 2 the input declares `acting?: ActingActor`),
|
|
176
|
+
* so `ctx.auth.actor` is non-null. Selected automatically by
|
|
177
|
+
* `rpc_action`'s conditional return type for the actor-implying tier.
|
|
178
|
+
*/
|
|
179
|
+
export interface ActionActorContext extends Omit<ActionContext, 'auth'> {
|
|
180
|
+
auth: RequestActorContext;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Handler signature for an actor-implying RPC action — `auth.actor === 'required'`.
|
|
184
|
+
* Mirrors `ActionHandler` but tightens the `ctx.auth` slot to the
|
|
185
|
+
* non-null `RequestActorContext` (with non-null `actor`).
|
|
186
|
+
*/
|
|
187
|
+
export type ActorActionHandler<TInput = any, TOutput = any> = (input: TInput, ctx: ActionActorContext) => TOutput | Promise<TOutput>;
|
|
188
|
+
/**
|
|
189
|
+
* An RPC action — combines an action spec with its handler.
|
|
190
|
+
*
|
|
191
|
+
* The spec defines the contract (method, auth, schemas, side effects).
|
|
192
|
+
* The handler implements the behavior.
|
|
193
|
+
*/
|
|
194
|
+
export interface RpcAction {
|
|
195
|
+
spec: RequestResponseActionSpec;
|
|
196
|
+
handler: ActionHandler;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Conditional handler shape for `rpc_action` — picks the narrowest
|
|
200
|
+
* `ctx.auth` type the dispatcher's runtime guarantee allows:
|
|
201
|
+
*
|
|
202
|
+
* - `auth.actor === 'required'` → `ActorActionHandler` (`ctx.auth: RequestActorContext`).
|
|
203
|
+
* - `auth.account === 'required' && auth.actor === 'none'` → `AuthActionHandler` (`ctx.auth: RequestContext`).
|
|
204
|
+
* - else (public, optional axes) → `ActionHandler` (`ctx.auth: RequestContext | null`).
|
|
205
|
+
*
|
|
206
|
+
* The bracketed form `[T] extends ['required']` defeats distributive
|
|
207
|
+
* conditionals so a degraded `AuthAxisState` union (when the spec was
|
|
208
|
+
* typed without preserving its literal) falls through to the loosest
|
|
209
|
+
* tier instead of collapsing to the narrowest.
|
|
210
|
+
*/
|
|
211
|
+
export type HandlerForSpec<TSpec extends RequestResponseActionSpec> = [
|
|
212
|
+
TSpec['auth']['actor']
|
|
213
|
+
] extends ['required'] ? ActorActionHandler<z.infer<TSpec['input']>, z.infer<TSpec['output']>> : [TSpec['auth']['account']] extends ['required'] ? AuthActionHandler<z.infer<TSpec['input']>, z.infer<TSpec['output']>> : ActionHandler<z.infer<TSpec['input']>, z.infer<TSpec['output']>>;
|
|
214
|
+
/**
|
|
215
|
+
* Pair a spec with a handler while preserving per-method input/output types
|
|
216
|
+
* and selecting the narrowest `ctx.auth` shape the spec literal admits.
|
|
217
|
+
*
|
|
218
|
+
* Constructing `{spec, handler}` literals widens `handler` to
|
|
219
|
+
* `ActionHandler<any, any>`, so spec/handler drift (renamed Zod schema,
|
|
220
|
+
* output field removal, input shape change) slips past the typechecker.
|
|
221
|
+
* `rpc_action(spec, handler)` binds the handler signature to
|
|
222
|
+
* `(input: z.infer<spec.input>, ctx) => z.infer<spec.output>` via the
|
|
223
|
+
* generic spec parameter — drift surfaces at the call site.
|
|
224
|
+
*
|
|
225
|
+
* The `ctx.auth` narrowing follows the spec's `auth.account` /
|
|
226
|
+
* `auth.actor` literals (see `HandlerForSpec`): an actor-implying spec
|
|
227
|
+
* gets `ctx.auth: RequestActorContext`; an account-grain spec gets
|
|
228
|
+
* `ctx.auth: RequestContext`; everything else stays `ctx.auth:
|
|
229
|
+
* RequestContext | null`. Handlers can rely on the dispatcher's
|
|
230
|
+
* runtime guarantee without a manual narrowing call.
|
|
231
|
+
*
|
|
232
|
+
* Fits fuz_app's factory-closure pattern (handlers close over
|
|
233
|
+
* `grantable_roles`, `app_settings` ref, `notification_sender`, etc.).
|
|
234
|
+
* zzz uses a different shape — a codegen-keyed `Record<Method, Handler>`
|
|
235
|
+
* map typed via generated `ActionInputs`/`ActionOutputs` — which works when
|
|
236
|
+
* handlers are pure (no closure state) and specs are codegen-enumerated.
|
|
237
|
+
* fuz_app's admin + role-grant-offer actions have neither, so per-pair typing
|
|
238
|
+
* at the registration site is the right fit.
|
|
239
|
+
*
|
|
240
|
+
* Spec-literal preservation is load-bearing: declare specs with
|
|
241
|
+
* `satisfies RequestResponseActionSpec` (canonical) so `auth.actor`
|
|
242
|
+
* keeps its `'required'` / `'none'` literal type. A spec typed
|
|
243
|
+
* directly as `RequestResponseActionSpec` widens the axes to
|
|
244
|
+
* `AuthAxisState` and the handler defaults to the loosest tier — sound,
|
|
245
|
+
* but loses the ergonomic narrowing.
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```ts
|
|
249
|
+
* // actor-implying spec → ctx.auth: RequestActorContext
|
|
250
|
+
* rpc_action(role_grant_revoke_action_spec, async (input, ctx) => {
|
|
251
|
+
* const revoker_id = ctx.auth.actor.id; // no narrowing needed
|
|
252
|
+
* });
|
|
253
|
+
*
|
|
254
|
+
* // account-grain spec → ctx.auth: RequestContext (actor: null)
|
|
255
|
+
* rpc_action(account_verify_action_spec, (_input, ctx) => {
|
|
256
|
+
* return to_session_account(ctx.auth.account); // no narrowing needed
|
|
257
|
+
* });
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
export declare const rpc_action: <TSpec extends RequestResponseActionSpec>(spec: TSpec, handler: HandlerForSpec<TSpec>) => RpcAction;
|
|
40
261
|
//# sourceMappingURL=action_types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_types.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"action_types.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared type surface for the action system — `Action` (the composable
|
|
3
|
-
* `{spec, handler?}` tuple)
|
|
4
|
-
*
|
|
3
|
+
* `{spec, handler?}` tuple), the handler context `ActionContext` and its
|
|
4
|
+
* narrowed tiers, the handler signatures, `RpcAction`, and the `rpc_action`
|
|
5
|
+
* binder.
|
|
5
6
|
*
|
|
6
7
|
* Sits above `actions/action_spec.ts` (pure Zod schemas) and below the
|
|
7
8
|
* dispatchers (`actions/register_action_ws.ts`, `actions/action_rpc.ts`,
|
|
8
9
|
* `actions/perform_action.ts`). Extracted so the shared protocol actions
|
|
9
|
-
* (e.g. `heartbeat_action`) can name them without
|
|
10
|
-
* modules
|
|
10
|
+
* (e.g. `heartbeat_action`) and every action factory can name them without
|
|
11
|
+
* pulling in server-only modules — everything here is type-only but the
|
|
12
|
+
* identity-function binder.
|
|
11
13
|
*
|
|
12
14
|
* HTTP RPC and WebSocket dispatchers both call into `perform_action`,
|
|
13
15
|
* and both pass the same `ActionContext` to the handler. Consumers
|
|
@@ -16,4 +18,53 @@
|
|
|
16
18
|
*
|
|
17
19
|
* @module
|
|
18
20
|
*/
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Pair a spec with a handler while preserving per-method input/output types
|
|
23
|
+
* and selecting the narrowest `ctx.auth` shape the spec literal admits.
|
|
24
|
+
*
|
|
25
|
+
* Constructing `{spec, handler}` literals widens `handler` to
|
|
26
|
+
* `ActionHandler<any, any>`, so spec/handler drift (renamed Zod schema,
|
|
27
|
+
* output field removal, input shape change) slips past the typechecker.
|
|
28
|
+
* `rpc_action(spec, handler)` binds the handler signature to
|
|
29
|
+
* `(input: z.infer<spec.input>, ctx) => z.infer<spec.output>` via the
|
|
30
|
+
* generic spec parameter — drift surfaces at the call site.
|
|
31
|
+
*
|
|
32
|
+
* The `ctx.auth` narrowing follows the spec's `auth.account` /
|
|
33
|
+
* `auth.actor` literals (see `HandlerForSpec`): an actor-implying spec
|
|
34
|
+
* gets `ctx.auth: RequestActorContext`; an account-grain spec gets
|
|
35
|
+
* `ctx.auth: RequestContext`; everything else stays `ctx.auth:
|
|
36
|
+
* RequestContext | null`. Handlers can rely on the dispatcher's
|
|
37
|
+
* runtime guarantee without a manual narrowing call.
|
|
38
|
+
*
|
|
39
|
+
* Fits fuz_app's factory-closure pattern (handlers close over
|
|
40
|
+
* `grantable_roles`, `app_settings` ref, `notification_sender`, etc.).
|
|
41
|
+
* zzz uses a different shape — a codegen-keyed `Record<Method, Handler>`
|
|
42
|
+
* map typed via generated `ActionInputs`/`ActionOutputs` — which works when
|
|
43
|
+
* handlers are pure (no closure state) and specs are codegen-enumerated.
|
|
44
|
+
* fuz_app's admin + role-grant-offer actions have neither, so per-pair typing
|
|
45
|
+
* at the registration site is the right fit.
|
|
46
|
+
*
|
|
47
|
+
* Spec-literal preservation is load-bearing: declare specs with
|
|
48
|
+
* `satisfies RequestResponseActionSpec` (canonical) so `auth.actor`
|
|
49
|
+
* keeps its `'required'` / `'none'` literal type. A spec typed
|
|
50
|
+
* directly as `RequestResponseActionSpec` widens the axes to
|
|
51
|
+
* `AuthAxisState` and the handler defaults to the loosest tier — sound,
|
|
52
|
+
* but loses the ergonomic narrowing.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* // actor-implying spec → ctx.auth: RequestActorContext
|
|
57
|
+
* rpc_action(role_grant_revoke_action_spec, async (input, ctx) => {
|
|
58
|
+
* const revoker_id = ctx.auth.actor.id; // no narrowing needed
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // account-grain spec → ctx.auth: RequestContext (actor: null)
|
|
62
|
+
* rpc_action(account_verify_action_spec, (_input, ctx) => {
|
|
63
|
+
* return to_session_account(ctx.auth.account); // no narrowing needed
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export const rpc_action = (spec, handler) => ({
|
|
68
|
+
spec,
|
|
69
|
+
handler: handler
|
|
70
|
+
});
|
|
@@ -18,9 +18,14 @@
|
|
|
18
18
|
* @module
|
|
19
19
|
*/
|
|
20
20
|
import { type Logger as LoggerType } from '@fuzdev/fuz_util/log.ts';
|
|
21
|
-
import type { ActionDispatcher } from './action_dispatcher.js';
|
|
22
21
|
import type { ActionSpecUnion } from './action_spec.js';
|
|
23
|
-
import {
|
|
22
|
+
import type { ConnectionRegistry, ConnectionIdentity } from './connection_registry.js';
|
|
23
|
+
/**
|
|
24
|
+
* What a broadcast is sent through — the fan-out half of
|
|
25
|
+
* `ConnectionRegistry`. A structural `Pick`, so a test or another
|
|
26
|
+
* registry can stand in.
|
|
27
|
+
*/
|
|
28
|
+
export type BroadcastTarget = Pick<ConnectionRegistry, 'broadcast' | 'broadcast_filtered'>;
|
|
24
29
|
/**
|
|
25
30
|
* Per-connection delivery predicate for subscription ACLs.
|
|
26
31
|
*
|
|
@@ -30,11 +35,15 @@ import { type ConnectionIdentity } from './transports_ws_backend.js';
|
|
|
30
35
|
* `input` is the already-validated payload (matches the spec's input schema);
|
|
31
36
|
* `method` is the action method name.
|
|
32
37
|
*/
|
|
33
|
-
export type ShouldDeliverFn = (connection: ConnectionIdentity
|
|
38
|
+
export type ShouldDeliverFn = (connection: Readonly<ConnectionIdentity>, method: string, input: unknown) => boolean;
|
|
34
39
|
/** Options for `create_broadcast_api`. */
|
|
35
40
|
export interface CreateBroadcastApiOptions {
|
|
36
|
-
/**
|
|
37
|
-
|
|
41
|
+
/**
|
|
42
|
+
* The connection registry broadcasts go out on — typically the WS endpoint's
|
|
43
|
+
* `ConnectionRegistry` (`AppServer.ws_endpoints[path]`, or the one a
|
|
44
|
+
* `WsEndpointSpec.registry` supplies).
|
|
45
|
+
*/
|
|
46
|
+
registry: BroadcastTarget;
|
|
38
47
|
/**
|
|
39
48
|
* Notification specs to expose as broadcast methods. Typically the
|
|
40
49
|
* `remote_notification` specs whose initiator is `backend` (or `both`).
|
|
@@ -46,13 +55,9 @@ export interface CreateBroadcastApiOptions {
|
|
|
46
55
|
log?: LoggerType | null;
|
|
47
56
|
/**
|
|
48
57
|
* Optional per-connection ACL predicate. When set, the broadcast fans out
|
|
49
|
-
* via the
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* Requires a transport that implements `FilterableBroadcastTransport`
|
|
54
|
-
* (today: only `BackendWebsocketTransport`). If set and the active
|
|
55
|
-
* transport is not filterable, the send is skipped and an error logged.
|
|
58
|
+
* via the registry's `broadcast_filtered` — each connection's identity is
|
|
59
|
+
* checked before the message is sent. When unset, the registry broadcasts
|
|
60
|
+
* unfiltered via `registry.broadcast`.
|
|
56
61
|
*/
|
|
57
62
|
should_deliver?: ShouldDeliverFn;
|
|
58
63
|
}
|
|
@@ -68,11 +73,11 @@ export type BroadcastApi = Record<string, (input: never) => Promise<void>>;
|
|
|
68
73
|
* For each spec, adds a method keyed by `spec.method` that:
|
|
69
74
|
* - Validates `input` against the spec's Zod schema (logs and returns on failure)
|
|
70
75
|
* - Creates a JSON-RPC notification from the validated input
|
|
71
|
-
* - Broadcasts
|
|
76
|
+
* - Broadcasts on the registry (filtered by `should_deliver` when supplied)
|
|
72
77
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
78
|
+
* A broadcast with no connections reaches nobody and is not an error. Errors
|
|
79
|
+
* during send are logged but never thrown — broadcasts are fire-and-forget from
|
|
80
|
+
* the handler's perspective.
|
|
76
81
|
*
|
|
77
82
|
* ## Typed consumer surface
|
|
78
83
|
*
|
|
@@ -85,7 +90,7 @@ export type BroadcastApi = Record<string, (input: never) => Promise<void>>;
|
|
|
85
90
|
* }
|
|
86
91
|
*
|
|
87
92
|
* const api = create_broadcast_api<BackendActionsApi>({
|
|
88
|
-
*
|
|
93
|
+
* registry: app_server.ws_endpoints['/api/ws']!,
|
|
89
94
|
* specs: [filer_change_action_spec, workspace_changed_action_spec],
|
|
90
95
|
* });
|
|
91
96
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast_api.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/broadcast_api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAU,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG5E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"broadcast_api.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/broadcast_api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAU,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEvF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,WAAW,GAAG,oBAAoB,CAAC,CAAC;AAE3F;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG,CAC7B,UAAU,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACxC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,KACV,OAAO,CAAC;AAEb,0CAA0C;AAC1C,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,QAAQ,EAAE,eAAe,CAAC;IAC1B;;;;;OAKG;IACH,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IACtC,gFAAgF;IAChF,GAAG,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,eAAe,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,oBAAoB,GAAI,IAAI,SAAS,MAAM,EACvD,SAAS,yBAAyB,KAChC,IAsCF,CAAC"}
|
|
@@ -19,18 +19,17 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
21
21
|
import { create_jsonrpc_notification, to_jsonrpc_params } from '../http/jsonrpc_helpers.js';
|
|
22
|
-
import { is_filterable_broadcast_transport } from './transports_ws_backend.js';
|
|
23
22
|
/**
|
|
24
23
|
* Builds a typed broadcast API from a set of action specs.
|
|
25
24
|
*
|
|
26
25
|
* For each spec, adds a method keyed by `spec.method` that:
|
|
27
26
|
* - Validates `input` against the spec's Zod schema (logs and returns on failure)
|
|
28
27
|
* - Creates a JSON-RPC notification from the validated input
|
|
29
|
-
* - Broadcasts
|
|
28
|
+
* - Broadcasts on the registry (filtered by `should_deliver` when supplied)
|
|
30
29
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* A broadcast with no connections reaches nobody and is not an error. Errors
|
|
31
|
+
* during send are logged but never thrown — broadcasts are fire-and-forget from
|
|
32
|
+
* the handler's perspective.
|
|
34
33
|
*
|
|
35
34
|
* ## Typed consumer surface
|
|
36
35
|
*
|
|
@@ -43,7 +42,7 @@ import { is_filterable_broadcast_transport } from './transports_ws_backend.js';
|
|
|
43
42
|
* }
|
|
44
43
|
*
|
|
45
44
|
* const api = create_broadcast_api<BackendActionsApi>({
|
|
46
|
-
*
|
|
45
|
+
* registry: app_server.ws_endpoints['/api/ws']!,
|
|
47
46
|
* specs: [filer_change_action_spec, workspace_changed_action_spec],
|
|
48
47
|
* });
|
|
49
48
|
* ```
|
|
@@ -53,46 +52,36 @@ import { is_filterable_broadcast_transport } from './transports_ws_backend.js';
|
|
|
53
52
|
* if the consumer already generates per-method type maps.
|
|
54
53
|
*/
|
|
55
54
|
export const create_broadcast_api = (options) => {
|
|
56
|
-
const {
|
|
55
|
+
const { registry, specs, should_deliver } = options;
|
|
57
56
|
const log = options.log === undefined ? new Logger('[broadcast]') : options.log;
|
|
58
57
|
const api = {};
|
|
59
58
|
for (const spec of specs) {
|
|
60
59
|
const { method } = spec;
|
|
61
|
-
|
|
60
|
+
const send = (input) => {
|
|
62
61
|
const parsed = spec.input.safeParse(input);
|
|
63
62
|
if (!parsed.success) {
|
|
64
63
|
log?.error(`[${method}] input validation failed:`, parsed.error.issues);
|
|
65
64
|
return;
|
|
66
65
|
}
|
|
67
|
-
// Resolve the broadcast target deterministically — no fallback.
|
|
68
|
-
// Broadcast is 1→N over a specific primary transport; falling through
|
|
69
|
-
// to "any ready transport" would send to an unexpected audience.
|
|
70
|
-
// Silent skip when no ready transport (e.g. before any clients connect).
|
|
71
|
-
const transport_name = peer.default_send_options.transport_name;
|
|
72
|
-
const transport = transport_name
|
|
73
|
-
? peer.transports.get_transport_by_name(transport_name)
|
|
74
|
-
: peer.transports.get_current_transport();
|
|
75
|
-
if (!transport?.is_ready())
|
|
76
|
-
return;
|
|
77
66
|
const notification = create_jsonrpc_notification(method, to_jsonrpc_params(parsed.data));
|
|
78
67
|
try {
|
|
79
68
|
if (should_deliver) {
|
|
80
|
-
|
|
81
|
-
log?.error(`[${method}] should_deliver set but transport ${transport.transport_name} does not support per-connection filtering`);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
transport.broadcast_filtered(notification, (identity) => should_deliver(identity, method, parsed.data));
|
|
85
|
-
return;
|
|
69
|
+
registry.broadcast_filtered(notification, (identity) => should_deliver(identity, method, parsed.data));
|
|
86
70
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
log?.error(`[${method}] failed to send notification:`, result.error);
|
|
71
|
+
else {
|
|
72
|
+
registry.broadcast(notification);
|
|
90
73
|
}
|
|
91
74
|
}
|
|
92
75
|
catch (error) {
|
|
93
76
|
log?.error(`[${method}] unexpected error:`, error);
|
|
94
77
|
}
|
|
95
78
|
};
|
|
79
|
+
// the broadcast is synchronous; the method stays `Promise<void>`, the
|
|
80
|
+
// shape `BackendActionsApi` declares
|
|
81
|
+
api[method] = (input) => {
|
|
82
|
+
send(input);
|
|
83
|
+
return Promise.resolve();
|
|
84
|
+
};
|
|
96
85
|
}
|
|
97
86
|
return api;
|
|
98
87
|
};
|
package/dist/actions/cancel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared cancel action — a fuz_app protocol action
|
|
3
|
-
*
|
|
2
|
+
* Shared cancel action — a fuz_app protocol action whose behavior the
|
|
3
|
+
* dispatcher owns, so it is a spec with no handler.
|
|
4
4
|
*
|
|
5
5
|
* Semantics: the client sends `{jsonrpc, method: 'cancel', params:
|
|
6
6
|
* {request_id}}` to abort an in-flight request on the same socket.
|
|
@@ -9,10 +9,8 @@
|
|
|
9
9
|
* races between response arrival and cancel delivery are safe without extra
|
|
10
10
|
* coordination.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* handler). The handler exists for symmetry with other protocol actions
|
|
15
|
-
* like `heartbeat_action`; the dispatcher never calls it. Consumers
|
|
12
|
+
* There is no handler: cancel semantics are dispatcher-owned (the dispatcher
|
|
13
|
+
* has the `{request_id → AbortController}` map, not a handler). Consumers
|
|
16
14
|
* spread `cancel_action` (or the `protocol_actions` bundle from
|
|
17
15
|
* `actions/protocol.ts`) into their server's `actions` array so `spec_by_method`
|
|
18
16
|
* knows about it (enabling input validation on incoming cancels) and so
|
|
@@ -60,13 +58,6 @@ export declare const cancel_action_spec: {
|
|
|
60
58
|
async: true;
|
|
61
59
|
description: string;
|
|
62
60
|
};
|
|
63
|
-
/**
|
|
64
|
-
* Placeholder handler — cancel semantics are owned by `register_action_ws`,
|
|
65
|
-
* not invoked per-handler. Exported for symmetry with the `Action`
|
|
66
|
-
* tuple shape; the dispatcher short-circuits cancel notifications before any
|
|
67
|
-
* handler lookup happens.
|
|
68
|
-
*/
|
|
69
|
-
export declare const cancel_handler: () => void;
|
|
70
61
|
/**
|
|
71
62
|
* Protocol-action tuple — spread into the server's `actions` array (or via
|
|
72
63
|
* `protocol_actions` from `actions/protocol.ts`) so the dispatcher registers the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/cancel.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cancel.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/cancel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;kBAEnC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;CAWS,CAAC;AAEzC;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,MAAqC,CAAC"}
|
package/dist/actions/cancel.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared cancel action — a fuz_app protocol action
|
|
3
|
-
*
|
|
2
|
+
* Shared cancel action — a fuz_app protocol action whose behavior the
|
|
3
|
+
* dispatcher owns, so it is a spec with no handler.
|
|
4
4
|
*
|
|
5
5
|
* Semantics: the client sends `{jsonrpc, method: 'cancel', params:
|
|
6
6
|
* {request_id}}` to abort an in-flight request on the same socket.
|
|
@@ -9,10 +9,8 @@
|
|
|
9
9
|
* races between response arrival and cancel delivery are safe without extra
|
|
10
10
|
* coordination.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* handler). The handler exists for symmetry with other protocol actions
|
|
15
|
-
* like `heartbeat_action`; the dispatcher never calls it. Consumers
|
|
12
|
+
* There is no handler: cancel semantics are dispatcher-owned (the dispatcher
|
|
13
|
+
* has the `{request_id → AbortController}` map, not a handler). Consumers
|
|
16
14
|
* spread `cancel_action` (or the `protocol_actions` bundle from
|
|
17
15
|
* `actions/protocol.ts`) into their server's `actions` array so `spec_by_method`
|
|
18
16
|
* knows about it (enabling input validation on incoming cancels) and so
|
|
@@ -57,13 +55,6 @@ export const cancel_action_spec = {
|
|
|
57
55
|
async: true,
|
|
58
56
|
description: 'Client-initiated cancellation of an in-flight request by id. Dispatcher-handled: aborts the ctx.signal of the matching pending request on the same socket. Unknown or completed ids no-op.'
|
|
59
57
|
};
|
|
60
|
-
/**
|
|
61
|
-
* Placeholder handler — cancel semantics are owned by `register_action_ws`,
|
|
62
|
-
* not invoked per-handler. Exported for symmetry with the `Action`
|
|
63
|
-
* tuple shape; the dispatcher short-circuits cancel notifications before any
|
|
64
|
-
* handler lookup happens.
|
|
65
|
-
*/
|
|
66
|
-
export const cancel_handler = () => { };
|
|
67
58
|
/**
|
|
68
59
|
* Protocol-action tuple — spread into the server's `actions` array (or via
|
|
69
60
|
* `protocol_actions` from `actions/protocol.ts`) so the dispatcher registers the
|
|
@@ -72,7 +63,4 @@ export const cancel_handler = () => { };
|
|
|
72
63
|
* `FrontendWebsocketClient.request({signal})` sends the cancel notification
|
|
73
64
|
* automatically when the signal fires.
|
|
74
65
|
*/
|
|
75
|
-
export const cancel_action = {
|
|
76
|
-
spec: cancel_action_spec,
|
|
77
|
-
handler: cancel_handler
|
|
78
|
-
};
|
|
66
|
+
export const cancel_action = { spec: cancel_action_spec };
|
|
@@ -40,8 +40,7 @@
|
|
|
40
40
|
*
|
|
41
41
|
* @module
|
|
42
42
|
*/
|
|
43
|
-
import type { Action } from './action_types.js';
|
|
44
|
-
import type { RpcAction } from './action_rpc.js';
|
|
43
|
+
import type { Action, RpcAction } from './action_types.js';
|
|
45
44
|
/** Result returned by `compile_action_registry`. */
|
|
46
45
|
export interface ActionRegistryCompileResult {
|
|
47
46
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile_action_registry.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/compile_action_registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"compile_action_registry.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/compile_action_registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI3D,oDAAoD;AACpD,MAAM,WAAW,2BAA2B;IAC3C;;;;;OAKG;IACH,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GACnC,SAAS,aAAa,CAAC,MAAM,CAAC,EAC9B,WAAW,MAAM,KACf,2BAoDF,CAAC"}
|