@fuzdev/fuz_app 0.149.0 → 0.151.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 +327 -300
- package/dist/actions/action_bridge.d.ts +5 -79
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +4 -74
- 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_event_types.d.ts +1 -1
- package/dist/actions/action_event_types.d.ts.map +1 -1
- 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 -31
- 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 -292
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +155 -903
- 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 +53 -76
- 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 +132 -68
- 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_lookup_queries.d.ts +3 -2
- package/dist/auth/actor_lookup_queries.d.ts.map +1 -1
- package/dist/auth/actor_lookup_queries.js +6 -3
- 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 +10 -7
- package/dist/auth/actor_search_queries.d.ts.map +1 -1
- package/dist/auth/actor_search_queries.js +18 -11
- package/dist/auth/admin_action_specs.d.ts +4 -4
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +7 -5
- 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 +47 -48
- package/dist/auth/all_cell_actions.d.ts +14 -3
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +2 -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 +12 -6
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +11 -5
- 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 +14 -21
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +19 -23
- 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/bootstrap_account.d.ts +25 -1
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +37 -4
- package/dist/auth/bootstrap_routes.d.ts +3 -2
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +5 -4
- 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_action_specs.d.ts +215 -15
- package/dist/auth/cell_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_action_specs.js +103 -16
- package/dist/auth/cell_actions.d.ts +58 -27
- package/dist/auth/cell_actions.d.ts.map +1 -1
- package/dist/auth/cell_actions.js +206 -161
- 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_events.d.ts +1 -1
- package/dist/auth/cell_audit_events.d.ts.map +1 -1
- package/dist/auth/cell_audit_events.js +3 -2
- package/dist/auth/cell_audit_metadata.d.ts +12 -1
- package/dist/auth/cell_audit_metadata.d.ts.map +1 -1
- package/dist/auth/cell_audit_metadata.js +11 -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 +9 -2
- package/dist/auth/cell_grant_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_grant_action_specs.js +10 -3
- package/dist/auth/cell_grant_actions.d.ts +105 -11
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +81 -56
- 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 +8 -7
- package/dist/auth/credential_type_schema.d.ts.map +1 -1
- package/dist/auth/credential_type_schema.js +8 -7
- 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 +117 -16
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +51 -16
- package/dist/auth/role_grant_offer_actions.d.ts +22 -11
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +72 -19
- package/dist/auth/role_grant_offer_notifications.d.ts +6 -5
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +4 -3
- package/dist/auth/role_grant_offer_queries.d.ts +20 -5
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +40 -37
- package/dist/auth/role_grant_queries.d.ts +44 -76
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +73 -118
- 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/role_schema.d.ts +14 -8
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +6 -3
- 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 +21 -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 +18 -6
- package/dist/db/cell_ddl.d.ts +5 -134
- package/dist/db/cell_ddl.d.ts.map +1 -1
- package/dist/db/cell_ddl.js +28 -17
- 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 +65 -55
- package/dist/db/cell_queries.d.ts.map +1 -1
- package/dist/db/cell_queries.js +85 -62
- 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/body_limit.d.ts +3 -1
- package/dist/http/body_limit.d.ts.map +1 -1
- package/dist/http/body_limit.js +6 -1
- 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.d.ts +9 -0
- package/dist/http/jsonrpc.d.ts.map +1 -1
- package/dist/http/jsonrpc.js +17 -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 +70 -23
- 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/proxy.d.ts +4 -2
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +7 -2
- 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 +4 -2
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +7 -4
- 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 +52 -1
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +123 -6
- 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 +73 -54
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +115 -78
- 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 +213 -179
- 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 -75
- 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/actor_lookup.d.ts.map +1 -1
- package/dist/testing/cross_backend/actor_lookup.js +27 -0
- 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 +15 -8
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_gated_create.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_gated_create.js +109 -13
- 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_moderate.d.ts +7 -1
- package/dist/testing/cross_backend/cell_moderate.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_moderate.js +68 -4
- package/dist/testing/cross_backend/cell_ref_admission.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_ref_admission.js +18 -9
- 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 +6 -1
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +12 -10
- 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/differential.d.ts +7 -0
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +17 -0
- package/dist/testing/cross_backend/expected_schema.json +1 -0
- 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 +13 -5
- 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 +96 -2
- 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_gated_create_authorize.d.ts +18 -19
- package/dist/testing/cross_backend/test_cell_gated_create_authorize.d.ts.map +1 -1
- package/dist/testing/cross_backend/test_cell_gated_create_authorize.js +66 -42
- 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 +48 -6
- 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 +2 -1
- 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 -94
- package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
- package/dist/actions/transports_ws_auth_guard.js +0 -138
- 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 -238
- 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
|
@@ -6,15 +6,17 @@
|
|
|
6
6
|
* stream continues to use `EventSource` directly — streams aren't an RPC
|
|
7
7
|
* concern.
|
|
8
8
|
*
|
|
9
|
-
* Holds
|
|
10
|
-
* `role_grant_history` (the dedicated role-grant history endpoint)
|
|
11
|
-
*
|
|
9
|
+
* Holds `AsyncSlot`s for `list` (the main event list),
|
|
10
|
+
* `role_grant_history` (the dedicated role-grant history endpoint), and
|
|
11
|
+
* `gap_fill` (the catch-up fetch run each time the stream opens). Data lives
|
|
12
|
+
* on the class so SSE pushes and gap-fill calls update it directly; both merge
|
|
13
|
+
* by `seq`, so `events` stays newest-first however they interleave.
|
|
12
14
|
*
|
|
13
15
|
* @module
|
|
14
16
|
*/
|
|
15
17
|
import { AsyncSlot } from './async_slot.svelte.js';
|
|
16
|
-
import type { AuditLogEventWithUsernamesJson, RoleGrantHistoryEventJson } from '../auth/audit_log_schema.js';
|
|
17
|
-
import type
|
|
18
|
+
import type { AuditLogEventJson, AuditLogEventWithUsernamesJson, RoleGrantHistoryEventJson } from '../auth/audit_log_schema.js';
|
|
19
|
+
import { type AuditLogListInput, type AuditLogListOutput, type AuditLogRoleGrantHistoryInput, type AuditLogRoleGrantHistoryOutput } from '../auth/admin_action_specs.js';
|
|
18
20
|
/**
|
|
19
21
|
* Narrow RPC surface consumed by `AuditLogState`. Consumers adapt their typed
|
|
20
22
|
* RPC client to this shape. Mirrors `AdminAccountsRpc` / `AdminInvitesRpc`.
|
|
@@ -22,8 +24,8 @@ import type { AuditLogListInput, AuditLogListOutput, AuditLogRoleGrantHistoryInp
|
|
|
22
24
|
* adapter needs no casts.
|
|
23
25
|
*/
|
|
24
26
|
export interface AuditLogRpc {
|
|
25
|
-
list: (
|
|
26
|
-
role_grant_history: (
|
|
27
|
+
list: (params?: AuditLogListInput) => Promise<AuditLogListOutput>;
|
|
28
|
+
role_grant_history: (params?: AuditLogRoleGrantHistoryInput) => Promise<AuditLogRoleGrantHistoryOutput>;
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
31
|
* Svelte context carrying the reactive `AuditLogRpc` accessor. Mirrors
|
|
@@ -35,6 +37,32 @@ export declare const audit_log_rpc_context: {
|
|
|
35
37
|
get_maybe: () => (() => AuditLogRpc) | undefined;
|
|
36
38
|
set: (value: () => AuditLogRpc) => () => AuditLogRpc;
|
|
37
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* The filter fields of `AuditLogListInput` — what `AuditLogState.subscribe`
|
|
42
|
+
* applies to live events and to its gap fill, matching what a `fetch` with the
|
|
43
|
+
* same fields returns. `account_id` matches either side of an event
|
|
44
|
+
* (`account_id` or `target_account_id`), as the list query does.
|
|
45
|
+
*/
|
|
46
|
+
export type AuditLogFilter = Pick<AuditLogListInput, 'event_type' | 'outcome' | 'account_id'>;
|
|
47
|
+
/**
|
|
48
|
+
* Whether an event passes an `AuditLogFilter` — the client-side twin of the
|
|
49
|
+
* list query's filter conditions, applied to live stream events.
|
|
50
|
+
*
|
|
51
|
+
* @param event - the event to test
|
|
52
|
+
* @param filter - the filter; absent or empty fields match everything
|
|
53
|
+
*/
|
|
54
|
+
export declare const audit_log_filter_matches: (event: AuditLogEventJson, filter: AuditLogFilter | undefined) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Lifecycle of the audit SSE stream.
|
|
57
|
+
*
|
|
58
|
+
* - `'off'` — not subscribed (initial, or after `disconnect`)
|
|
59
|
+
* - `'connecting'` — opening, or `EventSource` is retrying after a transient error
|
|
60
|
+
* - `'open'` — connected and receiving events
|
|
61
|
+
* - `'closed'` — the stream gave up: the server refused the reconnect (a revoked
|
|
62
|
+
* credential or a lost role answers it with 401/403), so `EventSource` stopped
|
|
63
|
+
* retrying; call `subscribe` again to retry
|
|
64
|
+
*/
|
|
65
|
+
export type AuditLogStreamStatus = 'off' | 'connecting' | 'open' | 'closed';
|
|
38
66
|
export interface AuditLogStateOptions {
|
|
39
67
|
/**
|
|
40
68
|
* Reactive accessor for the RPC adapter. Matches the `get_rpc` pattern on
|
|
@@ -49,26 +77,55 @@ export declare class AuditLogState {
|
|
|
49
77
|
#private;
|
|
50
78
|
readonly list: AsyncSlot<void, string>;
|
|
51
79
|
readonly role_grant_history: AsyncSlot<void, string>;
|
|
80
|
+
/** The catch-up fetch run each time the stream opens; its `error` surfaces a failed fill. */
|
|
81
|
+
readonly gap_fill: AsyncSlot<void, string>;
|
|
52
82
|
events: Array<AuditLogEventWithUsernamesJson>;
|
|
53
83
|
role_grant_history_events: Array<RoleGrantHistoryEventJson>;
|
|
54
84
|
readonly count: number;
|
|
55
|
-
/**
|
|
56
|
-
|
|
85
|
+
/** Lifecycle of the SSE stream — see `AuditLogStreamStatus`. */
|
|
86
|
+
stream_status: AuditLogStreamStatus;
|
|
87
|
+
/**
|
|
88
|
+
* Whether a gap fill hit its row limit, so events between the last one seen
|
|
89
|
+
* and the stream's reopening may be missing. Cleared by `fetch`, which
|
|
90
|
+
* replaces the list (as is a failed `gap_fill`).
|
|
91
|
+
*/
|
|
92
|
+
gap_truncated: boolean;
|
|
57
93
|
constructor(options: AuditLogStateOptions);
|
|
94
|
+
/**
|
|
95
|
+
* Load a page of events, replacing `events`.
|
|
96
|
+
*
|
|
97
|
+
* While the stream is live, events it delivered after the page's newest one
|
|
98
|
+
* that match the fetch's filter are kept, so a fetch answering mid-stream
|
|
99
|
+
* doesn't drop them. A newest-page fetch aborts an in-flight gap fill, which
|
|
100
|
+
* its own query covers, and when the stream opened before the list matched
|
|
101
|
+
* its filter or while the fetch was in flight, runs that open's gap fill
|
|
102
|
+
* from the fetched page.
|
|
103
|
+
*
|
|
104
|
+
* @param options - the list input; its filter fields become the list's filter
|
|
105
|
+
* @mutates `this`
|
|
106
|
+
*/
|
|
58
107
|
fetch(options?: AuditLogListInput): Promise<void>;
|
|
59
108
|
fetch_role_grant_history(limit?: number, offset?: number): Promise<void>;
|
|
60
109
|
/**
|
|
61
110
|
* Connect to the SSE stream for realtime audit events.
|
|
62
111
|
*
|
|
63
|
-
*
|
|
64
|
-
* transient errors
|
|
112
|
+
* Live events matching `filter` merge into `events` by `seq`. `EventSource`
|
|
113
|
+
* reconnects on transient errors (`stream_status` reads `'connecting'`);
|
|
114
|
+
* each open runs a gap fill from the last `seq` seen, with the same filter.
|
|
115
|
+
* A refused reconnect ends the stream (`'closed'`) — call `subscribe` again
|
|
116
|
+
* to retry. Gap fills run only while `events` was fetched with the same
|
|
117
|
+
* filter: an open the list doesn't match yet defers its fill to the `fetch`
|
|
118
|
+
* with the stream's filter, and live events under another filter than the
|
|
119
|
+
* list's merge only when they match the list's filter too, without advancing
|
|
120
|
+
* the anchor.
|
|
65
121
|
*
|
|
122
|
+
* @param filter - which events to keep; omit for all
|
|
66
123
|
* @returns cleanup function that closes the connection
|
|
67
124
|
* @mutates `this`
|
|
68
125
|
*/
|
|
69
|
-
subscribe(): () => void;
|
|
126
|
+
subscribe(filter?: AuditLogFilter): () => void;
|
|
70
127
|
/**
|
|
71
|
-
* Close the SSE connection.
|
|
128
|
+
* Close the SSE connection and abort an in-flight gap fill.
|
|
72
129
|
*
|
|
73
130
|
* @mutates `this`
|
|
74
131
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_state.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/audit_log_state.svelte.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"audit_log_state.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/audit_log_state.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,EACX,iBAAiB,EACjB,8BAA8B,EAC9B,yBAAyB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,MAAM,+BAA+B,CAAC;AAGvC;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAClE,kBAAkB,EAAE,CACnB,MAAM,CAAC,EAAE,6BAA6B,KAClC,OAAO,CAAC,8BAA8B,CAAC,CAAC;CAC7C;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;2CAAwB,WAAW;4BAAX,WAAW;uBAAX,WAAW,WAAX,WAAW;CAAG,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,SAAS,GAAG,YAAY,CAAC,CAAC;AAE9F;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GACpC,OAAO,iBAAiB,EACxB,QAAQ,cAAc,GAAG,SAAS,KAChC,OAYF,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE5E,MAAM,WAAW,oBAAoB;IACpC;;;;OAIG;IACH,OAAO,EAAE,MAAM,WAAW,CAAC;IAC3B,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,aAAa;;IAGzB,QAAQ,CAAC,IAAI,0BAAyB;IACtC,QAAQ,CAAC,kBAAkB,0BAAyB;IACpD,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,0BAAyB;IAE1C,MAAM,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAkB;IAC/D,yBAAyB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAkB;IAE7E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAgC;IAEtD,gEAAgE;IAChE,aAAa,EAAE,oBAAoB,CAAqB;IAExD;;;;OAIG;IACH,aAAa,UAAqB;gBA6CtB,OAAO,EAAE,oBAAoB;IAKzC;;;;;;;;;;;;OAYG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CjD,wBAAwB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9E;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,IAAI;IA8D9C;;;;OAIG;IACH,UAAU,IAAI,IAAI;CA4DlB"}
|
|
@@ -6,32 +6,93 @@
|
|
|
6
6
|
* stream continues to use `EventSource` directly — streams aren't an RPC
|
|
7
7
|
* concern.
|
|
8
8
|
*
|
|
9
|
-
* Holds
|
|
10
|
-
* `role_grant_history` (the dedicated role-grant history endpoint)
|
|
11
|
-
*
|
|
9
|
+
* Holds `AsyncSlot`s for `list` (the main event list),
|
|
10
|
+
* `role_grant_history` (the dedicated role-grant history endpoint), and
|
|
11
|
+
* `gap_fill` (the catch-up fetch run each time the stream opens). Data lives
|
|
12
|
+
* on the class so SSE pushes and gap-fill calls update it directly; both merge
|
|
13
|
+
* by `seq`, so `events` stays newest-first however they interleave.
|
|
12
14
|
*
|
|
13
15
|
* @module
|
|
14
16
|
*/
|
|
15
17
|
import { DEV } from 'esm-env';
|
|
16
18
|
import { create_context } from '@fuzdev/fuz_ui/context_helpers.ts';
|
|
17
19
|
import { AsyncSlot } from './async_slot.svelte.js';
|
|
20
|
+
import { AUDIT_LOG_LIST_LIMIT_MAX } from '../auth/admin_action_specs.js';
|
|
18
21
|
/**
|
|
19
22
|
* Svelte context carrying the reactive `AuditLogRpc` accessor. Mirrors
|
|
20
23
|
* `admin_accounts_rpc_context`. `get()` throws when no provisioner ran above
|
|
21
24
|
* the component — the adapter is required.
|
|
22
25
|
*/
|
|
23
26
|
export const audit_log_rpc_context = create_context();
|
|
27
|
+
/**
|
|
28
|
+
* Whether an event passes an `AuditLogFilter` — the client-side twin of the
|
|
29
|
+
* list query's filter conditions, applied to live stream events.
|
|
30
|
+
*
|
|
31
|
+
* @param event - the event to test
|
|
32
|
+
* @param filter - the filter; absent or empty fields match everything
|
|
33
|
+
*/
|
|
34
|
+
export const audit_log_filter_matches = (event, filter) => {
|
|
35
|
+
if (!filter)
|
|
36
|
+
return true;
|
|
37
|
+
if (filter.event_type && event.event_type !== filter.event_type)
|
|
38
|
+
return false;
|
|
39
|
+
if (filter.outcome && event.outcome !== filter.outcome)
|
|
40
|
+
return false;
|
|
41
|
+
if (filter.account_id &&
|
|
42
|
+
event.account_id !== filter.account_id &&
|
|
43
|
+
event.target_account_id !== filter.account_id) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
24
48
|
export class AuditLogState {
|
|
25
49
|
#get_rpc;
|
|
26
50
|
list = new AsyncSlot();
|
|
27
51
|
role_grant_history = new AsyncSlot();
|
|
52
|
+
/** The catch-up fetch run each time the stream opens; its `error` surfaces a failed fill. */
|
|
53
|
+
gap_fill = new AsyncSlot();
|
|
28
54
|
events = $state.raw([]);
|
|
29
55
|
role_grant_history_events = $state.raw([]);
|
|
30
56
|
count = $derived(this.events.length);
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
/**
|
|
57
|
+
/** Lifecycle of the SSE stream — see `AuditLogStreamStatus`. */
|
|
58
|
+
stream_status = $state.raw('off');
|
|
59
|
+
/**
|
|
60
|
+
* Whether a gap fill hit its row limit, so events between the last one seen
|
|
61
|
+
* and the stream's reopening may be missing. Cleared by `fetch`, which
|
|
62
|
+
* replaces the list (as is a failed `gap_fill`).
|
|
63
|
+
*/
|
|
64
|
+
gap_truncated = $state.raw(false);
|
|
65
|
+
/**
|
|
66
|
+
* The highest `seq` the list covers — the gap-fill anchor. `fetch` sets it
|
|
67
|
+
* from its result (`0` for an empty first page, which covers everything up
|
|
68
|
+
* to then), and gap-filled events and live events while the stream's filter
|
|
69
|
+
* is the list's advance it.
|
|
70
|
+
*/
|
|
34
71
|
#last_seq = null;
|
|
72
|
+
/**
|
|
73
|
+
* The oldest `seq` a gap fill owes from — set when a fill starts, or when an
|
|
74
|
+
* open defers its fill to an in-flight newest-page fetch, and cleared when a
|
|
75
|
+
* fill commits or a fetch replaces the list. A fill aborted by a reopen or a
|
|
76
|
+
* retry, one that failed, or a deferring fetch that failed leaves it, so the
|
|
77
|
+
* next fill starts from there instead of past the live rows that arrived
|
|
78
|
+
* meanwhile. Never above `#last_seq`, which only rises while it is set.
|
|
79
|
+
*/
|
|
80
|
+
#fill_since = null;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the latest `fetch` is for the newest page — with `list.loading`,
|
|
83
|
+
* whether a newest-page fetch is in flight.
|
|
84
|
+
*/
|
|
85
|
+
#fetching_newest = false;
|
|
86
|
+
/**
|
|
87
|
+
* Whether the stream's last open skipped its gap fill (the list had no
|
|
88
|
+
* anchor or another filter, or a newest-page fetch was in flight), so the
|
|
89
|
+
* `fetch` that anchors the list under the stream's filter runs it.
|
|
90
|
+
*/
|
|
91
|
+
#fill_deferred = false;
|
|
92
|
+
/** The filter of the `fetch` that loaded `events`. */
|
|
93
|
+
#list_filter;
|
|
94
|
+
/** The filter the stream applies, set by `subscribe`. */
|
|
95
|
+
#stream_filter;
|
|
35
96
|
/** Active EventSource instance. */
|
|
36
97
|
#event_source = null;
|
|
37
98
|
/** Path to the SSE stream endpoint. */
|
|
@@ -40,11 +101,62 @@ export class AuditLogState {
|
|
|
40
101
|
this.#get_rpc = options.get_rpc;
|
|
41
102
|
this.#stream_url = options.stream_url ?? '/api/admin/audit/stream';
|
|
42
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Load a page of events, replacing `events`.
|
|
106
|
+
*
|
|
107
|
+
* While the stream is live, events it delivered after the page's newest one
|
|
108
|
+
* that match the fetch's filter are kept, so a fetch answering mid-stream
|
|
109
|
+
* doesn't drop them. A newest-page fetch aborts an in-flight gap fill, which
|
|
110
|
+
* its own query covers, and when the stream opened before the list matched
|
|
111
|
+
* its filter or while the fetch was in flight, runs that open's gap fill
|
|
112
|
+
* from the fetched page.
|
|
113
|
+
*
|
|
114
|
+
* @param options - the list input; its filter fields become the list's filter
|
|
115
|
+
* @mutates `this`
|
|
116
|
+
*/
|
|
43
117
|
async fetch(options) {
|
|
44
|
-
|
|
118
|
+
// a later page (`offset > 0`) doesn't cover the newest events
|
|
119
|
+
const newest_page = !options?.offset;
|
|
120
|
+
// the fill covers up to the stream's open, which this newer query covers too
|
|
121
|
+
if (newest_page)
|
|
122
|
+
this.gap_fill.abort();
|
|
123
|
+
this.#fetching_newest = newest_page;
|
|
124
|
+
await this.list.run(async (signal) => {
|
|
45
125
|
const { events } = await this.#get_rpc().list(options);
|
|
46
|
-
|
|
47
|
-
|
|
126
|
+
// a superseded fetch must not overwrite a newer one's list
|
|
127
|
+
if (signal.aborted)
|
|
128
|
+
return;
|
|
129
|
+
const filter = to_audit_log_filter(options);
|
|
130
|
+
const fetched_seq = events.length > 0 ? max_seq(events) : 0;
|
|
131
|
+
const live = newest_page && this.#event_source
|
|
132
|
+
? this.events.filter((e) => e.seq > fetched_seq && audit_log_filter_matches(e, filter))
|
|
133
|
+
: [];
|
|
134
|
+
this.events = live.length > 0 ? [...live, ...events] : events;
|
|
135
|
+
this.#list_filter = filter;
|
|
136
|
+
// a fresh list supersedes what an earlier gap fill missed
|
|
137
|
+
this.gap_truncated = false;
|
|
138
|
+
if (this.gap_fill.failed)
|
|
139
|
+
this.gap_fill.reset();
|
|
140
|
+
this.#fill_since = null;
|
|
141
|
+
const stream_matches = this.#event_source !== null && filters_equal(filter, this.#stream_filter);
|
|
142
|
+
// the stream opened before this list matched it, so events between this
|
|
143
|
+
// query and that open may be missing — fill from the fetched page
|
|
144
|
+
const fill_deferred = newest_page && stream_matches && this.#fill_deferred;
|
|
145
|
+
// live rows anchor the list only when the stream covers its filter since
|
|
146
|
+
// before the query
|
|
147
|
+
this.#last_seq = newest_page
|
|
148
|
+
? stream_matches && !fill_deferred
|
|
149
|
+
? Math.max(fetched_seq, live.length > 0 ? max_seq(live) : 0)
|
|
150
|
+
: fetched_seq
|
|
151
|
+
: events.length > 0
|
|
152
|
+
? fetched_seq
|
|
153
|
+
: null;
|
|
154
|
+
if (fill_deferred) {
|
|
155
|
+
this.#fill_deferred = false;
|
|
156
|
+
// while reconnecting, the next open fills from the anchor
|
|
157
|
+
if (this.stream_status === 'open')
|
|
158
|
+
void this.#fill_gap(fetched_seq);
|
|
159
|
+
}
|
|
48
160
|
});
|
|
49
161
|
}
|
|
50
162
|
async fetch_role_grant_history(limit, offset) {
|
|
@@ -56,86 +168,166 @@ export class AuditLogState {
|
|
|
56
168
|
/**
|
|
57
169
|
* Connect to the SSE stream for realtime audit events.
|
|
58
170
|
*
|
|
59
|
-
*
|
|
60
|
-
* transient errors
|
|
171
|
+
* Live events matching `filter` merge into `events` by `seq`. `EventSource`
|
|
172
|
+
* reconnects on transient errors (`stream_status` reads `'connecting'`);
|
|
173
|
+
* each open runs a gap fill from the last `seq` seen, with the same filter.
|
|
174
|
+
* A refused reconnect ends the stream (`'closed'`) — call `subscribe` again
|
|
175
|
+
* to retry. Gap fills run only while `events` was fetched with the same
|
|
176
|
+
* filter: an open the list doesn't match yet defers its fill to the `fetch`
|
|
177
|
+
* with the stream's filter, and live events under another filter than the
|
|
178
|
+
* list's merge only when they match the list's filter too, without advancing
|
|
179
|
+
* the anchor.
|
|
61
180
|
*
|
|
181
|
+
* @param filter - which events to keep; omit for all
|
|
62
182
|
* @returns cleanup function that closes the connection
|
|
63
183
|
* @mutates `this`
|
|
64
184
|
*/
|
|
65
|
-
subscribe() {
|
|
185
|
+
subscribe(filter) {
|
|
66
186
|
this.disconnect();
|
|
187
|
+
this.#stream_filter = filter;
|
|
67
188
|
const source = new EventSource(this.#stream_url);
|
|
68
189
|
this.#event_source = source;
|
|
190
|
+
this.stream_status = 'connecting';
|
|
69
191
|
source.onopen = () => {
|
|
70
192
|
if (DEV)
|
|
71
193
|
console.log('[audit_log_sse] connected');
|
|
72
|
-
this.
|
|
73
|
-
// fill any gap from
|
|
74
|
-
|
|
194
|
+
this.stream_status = 'open';
|
|
195
|
+
// fill any gap from before this open, or leave it to the fetch that
|
|
196
|
+
// anchors the list under the stream's filter — an in-flight newest-page
|
|
197
|
+
// fetch included, whose page may predate live rows already merged
|
|
198
|
+
const anchored = this.#last_seq !== null && filters_equal(this.#list_filter, this.#stream_filter);
|
|
199
|
+
const fill = anchored && !(this.#fetching_newest && this.list.loading);
|
|
200
|
+
this.#fill_deferred = !fill;
|
|
201
|
+
if (fill) {
|
|
75
202
|
void this.#fill_gap(this.#last_seq);
|
|
76
203
|
}
|
|
204
|
+
else if (anchored) {
|
|
205
|
+
// the fetch fills from its page when it commits; if it fails, the next
|
|
206
|
+
// fill still owes this open's range
|
|
207
|
+
this.#fill_since ??= this.#last_seq;
|
|
208
|
+
}
|
|
77
209
|
};
|
|
78
210
|
source.onmessage = (e) => {
|
|
211
|
+
let raw;
|
|
79
212
|
try {
|
|
80
213
|
const notification = JSON.parse(e.data);
|
|
81
|
-
|
|
214
|
+
raw = notification.params;
|
|
82
215
|
if (DEV)
|
|
83
216
|
console.log('[audit_log_sse]', notification.method, raw);
|
|
84
|
-
// normalize SSE events to include username fields
|
|
85
|
-
const event = {
|
|
86
|
-
...raw,
|
|
87
|
-
username: null,
|
|
88
|
-
target_username: null
|
|
89
|
-
};
|
|
90
|
-
// prepend — newest first, matching the fetch sort order
|
|
91
|
-
this.events = [event, ...this.events];
|
|
92
|
-
this.#last_seq = Math.max(this.#last_seq ?? 0, event.seq);
|
|
93
217
|
}
|
|
94
218
|
catch {
|
|
95
219
|
// ignore malformed messages
|
|
220
|
+
return;
|
|
96
221
|
}
|
|
222
|
+
if (!audit_log_filter_matches(raw, this.#stream_filter))
|
|
223
|
+
return;
|
|
224
|
+
// a stream filter other than the list's lets through events the list
|
|
225
|
+
// excludes, and what it streams doesn't cover the list's filter
|
|
226
|
+
if (!audit_log_filter_matches(raw, this.#list_filter))
|
|
227
|
+
return;
|
|
228
|
+
const anchors = filters_equal(this.#list_filter, this.#stream_filter);
|
|
229
|
+
// normalize SSE events to include username fields
|
|
230
|
+
this.#merge([{ ...raw, username: null, target_username: null }], false, anchors);
|
|
97
231
|
};
|
|
98
232
|
source.onerror = () => {
|
|
99
233
|
if (DEV)
|
|
100
234
|
console.log('[audit_log_sse] error, readyState:', source.readyState);
|
|
101
|
-
|
|
235
|
+
if (source !== this.#event_source)
|
|
236
|
+
return;
|
|
237
|
+
if (source.readyState === EventSource.CLOSED) {
|
|
238
|
+
// `EventSource` gave up (a refused reconnect) and won't retry
|
|
239
|
+
source.close();
|
|
240
|
+
this.#event_source = null;
|
|
241
|
+
this.stream_status = 'closed';
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
this.stream_status = 'connecting';
|
|
245
|
+
}
|
|
102
246
|
};
|
|
103
247
|
return () => this.disconnect();
|
|
104
248
|
}
|
|
105
249
|
/**
|
|
106
|
-
* Close the SSE connection.
|
|
250
|
+
* Close the SSE connection and abort an in-flight gap fill.
|
|
107
251
|
*
|
|
108
252
|
* @mutates `this`
|
|
109
253
|
*/
|
|
110
254
|
disconnect() {
|
|
255
|
+
this.gap_fill.abort();
|
|
111
256
|
if (this.#event_source) {
|
|
112
257
|
this.#event_source.close();
|
|
113
258
|
this.#event_source = null;
|
|
114
259
|
}
|
|
115
|
-
this.
|
|
260
|
+
this.stream_status = 'off';
|
|
116
261
|
}
|
|
117
|
-
/**
|
|
262
|
+
/**
|
|
263
|
+
* Fetch the events missed before the stream (re)opened, with the stream's
|
|
264
|
+
* filter, from the start a fill still owes (`#fill_since`) or `since_seq`. A
|
|
265
|
+
* full page means the gap may hold more than the limit returns.
|
|
266
|
+
*/
|
|
118
267
|
async #fill_gap(since_seq) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
268
|
+
const filter = this.#stream_filter;
|
|
269
|
+
const from = this.#fill_since ?? since_seq;
|
|
270
|
+
this.#fill_since = from;
|
|
271
|
+
await this.gap_fill.run(async (signal) => {
|
|
272
|
+
const limit = AUDIT_LOG_LIST_LIMIT_MAX;
|
|
273
|
+
const { events } = await this.#get_rpc().list({ ...filter, since_seq: from, limit });
|
|
274
|
+
// a disconnect or a newer fill aborted this one, maybe under another filter
|
|
275
|
+
if (signal.aborted)
|
|
122
276
|
return;
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
catch {
|
|
132
|
-
// gap fill is best-effort
|
|
133
|
-
}
|
|
277
|
+
// a later-page fetch under another filter replaced the list meanwhile
|
|
278
|
+
if (!filters_equal(this.#list_filter, filter))
|
|
279
|
+
return;
|
|
280
|
+
this.#fill_since = null;
|
|
281
|
+
if (events.length >= limit)
|
|
282
|
+
this.gap_truncated = true;
|
|
283
|
+
this.#merge(events, true, true);
|
|
284
|
+
});
|
|
134
285
|
}
|
|
135
|
-
/**
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Merge events into the newest-first list by `seq`, deduplicating by `id`.
|
|
288
|
+
*
|
|
289
|
+
* @param incoming - events to merge, any order
|
|
290
|
+
* @param replace - whether an incoming event replaces a listed one with the
|
|
291
|
+
* same `id` (gap-fill rows carry resolved usernames; live rows don't)
|
|
292
|
+
* @param anchors - whether the events advance the gap-fill anchor (live rows
|
|
293
|
+
* under another filter than the list's don't)
|
|
294
|
+
*/
|
|
295
|
+
#merge(incoming, replace, anchors) {
|
|
296
|
+
if (incoming.length === 0)
|
|
297
|
+
return;
|
|
298
|
+
if (anchors)
|
|
299
|
+
this.#last_seq = Math.max(this.#last_seq ?? 0, max_seq(incoming));
|
|
300
|
+
const head = this.events[0];
|
|
301
|
+
// fast path: one live event newer than everything listed
|
|
302
|
+
if (incoming.length === 1 && (!head || incoming[0].seq > head.seq)) {
|
|
303
|
+
this.events = [incoming[0], ...this.events];
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const by_id = new Map();
|
|
307
|
+
for (const event of this.events)
|
|
308
|
+
by_id.set(event.id, event);
|
|
309
|
+
for (const event of incoming) {
|
|
310
|
+
if (replace || !by_id.has(event.id))
|
|
311
|
+
by_id.set(event.id, event);
|
|
139
312
|
}
|
|
313
|
+
this.events = Array.from(by_id.values()).sort((a, b) => b.seq - a.seq);
|
|
140
314
|
}
|
|
141
315
|
}
|
|
316
|
+
/** The filter fields of a list input. */
|
|
317
|
+
const to_audit_log_filter = (input) => {
|
|
318
|
+
if (!input)
|
|
319
|
+
return undefined;
|
|
320
|
+
const { event_type, outcome, account_id } = input;
|
|
321
|
+
return { event_type, outcome, account_id };
|
|
322
|
+
};
|
|
323
|
+
/** Whether two filters select the same events — absent and empty fields are equal. */
|
|
324
|
+
const filters_equal = (a, b) => (a?.event_type || undefined) === (b?.event_type || undefined) &&
|
|
325
|
+
(a?.outcome || undefined) === (b?.outcome || undefined) &&
|
|
326
|
+
(a?.account_id || undefined) === (b?.account_id || undefined);
|
|
327
|
+
const max_seq = (events) => {
|
|
328
|
+
let max = 0;
|
|
329
|
+
for (const event of events)
|
|
330
|
+
if (event.seq > max)
|
|
331
|
+
max = event.seq;
|
|
332
|
+
return max;
|
|
333
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend liveness probe — whether the app's backend is serving, read from
|
|
3
|
+
* its `/health` route.
|
|
4
|
+
*
|
|
5
|
+
* `AuthState.check_session` can't tell a backend that's down from a
|
|
6
|
+
* logged-out caller, so a login gate probes `/health` to say the backend is
|
|
7
|
+
* needed instead of showing a login form that can't work. Only the health
|
|
8
|
+
* reply counts: a static server or an SPA fallback answering every path with
|
|
9
|
+
* a `200` HTML page is not a backend, and neither is a network error.
|
|
10
|
+
* Browser-safe — no server imports.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type { Result } from '@fuzdev/fuz_util/result.ts';
|
|
15
|
+
import type { OmitStrict } from '@fuzdev/fuz_util/types.ts';
|
|
16
|
+
/** `probe_backend`'s answer: live, or why not. */
|
|
17
|
+
export type BackendProbeResult = Result<object, {
|
|
18
|
+
error: string;
|
|
19
|
+
}>;
|
|
20
|
+
/** The refusal for a `2xx` whose body isn't the health reply. */
|
|
21
|
+
export declare const BACKEND_PROBE_NOT_HEALTH = "not a health response";
|
|
22
|
+
/** The refusal for a probe its caller's `signal` aborted — a cancel, not a timeout. */
|
|
23
|
+
export declare const BACKEND_PROBE_ABORTED = "aborted";
|
|
24
|
+
/** How long the default fetch waits for the health reply before the probe reads as down. */
|
|
25
|
+
export declare const BACKEND_PROBE_TIMEOUT_MS = 10000;
|
|
26
|
+
/** Options for `probe_backend`; `BackendProbe` takes all but `signal`. */
|
|
27
|
+
export interface BackendProbeOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Fetches the health route — defaults to `fetch(HEALTH_PATH)` with a
|
|
30
|
+
* `timeout_ms` signal, combined with `signal` when given. An injected
|
|
31
|
+
* fetch owns its own signal.
|
|
32
|
+
*/
|
|
33
|
+
fetch_health?: () => Promise<Response>;
|
|
34
|
+
/**
|
|
35
|
+
* How long the default fetch waits for the reply and its body — defaults
|
|
36
|
+
* to `BACKEND_PROBE_TIMEOUT_MS`; unused when `fetch_health` is injected.
|
|
37
|
+
*/
|
|
38
|
+
timeout_ms?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Cancels the default fetch, alongside its timeout; unused when
|
|
41
|
+
* `fetch_health` is injected. A probe that fails once it is aborted reports
|
|
42
|
+
* `BACKEND_PROBE_ABORTED` — whatever the signal's reason, so a deadline
|
|
43
|
+
* belongs in `timeout_ms`.
|
|
44
|
+
*/
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Probe whether the backend is serving: its health route must answer `2xx`
|
|
49
|
+
* with a body that parses as `HealthResponse`. A timeout while the reply or its
|
|
50
|
+
* body is read reads as down — naming `timeout_ms` only when the default fetch
|
|
51
|
+
* timed out, since an injected `fetch_health` owns its own signal. A failure
|
|
52
|
+
* once the caller's `signal` aborted reports `BACKEND_PROBE_ABORTED`, not a
|
|
53
|
+
* timeout or a down backend. A body that isn't JSON is
|
|
54
|
+
* `BACKEND_PROBE_NOT_HEALTH`; any other failure reading it reports the error.
|
|
55
|
+
*
|
|
56
|
+
* @param options - the health fetch, the default fetch's timeout, and a signal to cancel it
|
|
57
|
+
* @returns `{ok: true}` when the backend answered, else the reason it didn't
|
|
58
|
+
*/
|
|
59
|
+
export declare const probe_backend: (options?: BackendProbeOptions) => Promise<BackendProbeResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Reactive `probe_backend` state for a login gate. `reachable` stays `null`
|
|
62
|
+
* until a probe settles — through SSR and prerender too, so a gate that waits
|
|
63
|
+
* on it renders its pending notice there.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* const backend = new BackendProbe();
|
|
68
|
+
* if (BROWSER) void backend.probe();
|
|
69
|
+
* // in markup: `backend.reachable === null` → checking; `!backend.reachable` → down
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare class BackendProbe {
|
|
73
|
+
#private;
|
|
74
|
+
/** Whether a probe is in flight. */
|
|
75
|
+
probing: boolean;
|
|
76
|
+
/** Whether the backend answered the last settled probe — `null` before one settles. */
|
|
77
|
+
reachable: boolean | null;
|
|
78
|
+
/** Why the last settled probe failed — `null` when it succeeded or none has settled. */
|
|
79
|
+
error: string | null;
|
|
80
|
+
/**
|
|
81
|
+
* @param options - the health fetch and the default fetch's timeout; no `signal`, since one
|
|
82
|
+
* that aborted would fail every later probe as `BACKEND_PROBE_ABORTED`
|
|
83
|
+
*/
|
|
84
|
+
constructor(options?: OmitStrict<BackendProbeOptions, 'signal'>);
|
|
85
|
+
/**
|
|
86
|
+
* Probe the backend and record the answer. A probe started while another
|
|
87
|
+
* is in flight supersedes it: only the latest one's answer is recorded.
|
|
88
|
+
*
|
|
89
|
+
* @returns whether the backend answered this probe
|
|
90
|
+
*/
|
|
91
|
+
probe(): Promise<boolean>;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=backend_probe.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend_probe.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/ui/backend_probe.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,kDAAkD;AAClD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEnE,iEAAiE;AACjE,eAAO,MAAM,wBAAwB,0BAA0B,CAAC;AAEhE,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C,4FAA4F;AAC5F,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAQ/C,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;AAKD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAU,UAAU,mBAAmB,KAAG,OAAO,CAAC,kBAAkB,CAwC7F,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,qBAAa,YAAY;;IACxB,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAqB;IAErC,uFAAuF;IACvF,SAAS,EAAE,OAAO,GAAG,IAAI,CAAoB;IAE7C,wFAAwF;IACxF,KAAK,EAAE,MAAM,GAAG,IAAI,CAAoB;IAKxC;;;OAGG;gBACS,OAAO,CAAC,EAAE,UAAU,CAAC,mBAAmB,EAAE,QAAQ,CAAC;IAW/D;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;CAW/B"}
|