@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
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generic cell RPC action handlers.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The generic `request_response` actions bound to the specs in
|
|
5
5
|
* `auth/cell_action_specs.ts`:
|
|
6
6
|
*
|
|
7
|
-
* - Mutations: `cell_create`, `cell_update`, `cell_delete`, `cell_clone
|
|
7
|
+
* - Mutations: `cell_create`, `cell_update`, `cell_delete`, `cell_clone`,
|
|
8
|
+
* `cell_moderate`, `cell_policy_set`.
|
|
8
9
|
* - Reads: `cell_get`, `cell_list`.
|
|
9
10
|
*
|
|
10
11
|
* Authorization model:
|
|
@@ -20,6 +21,11 @@
|
|
|
20
21
|
* with per-row `can_edit_cell` enforcement. `path` writes on update
|
|
21
22
|
* are admin-only; `visibility` writes require the manage tier
|
|
22
23
|
* (`can_manage_cell`).
|
|
24
|
+
* - `cell_policy_set` is the one writer of a root's contribution `policy` past
|
|
25
|
+
* its create — manage-tier, root-only, and validated by the mounted
|
|
26
|
+
* `authorize_create` (the authorizer that interprets the policy is what
|
|
27
|
+
* accepts one; none mounted refuses every non-null policy). `cell_update`
|
|
28
|
+
* never touches it.
|
|
23
29
|
* - `cell_list` is `optional` auth at the spec level. The SQL-side
|
|
24
30
|
* visibility predicate in `query_cell_list` admits null auth to
|
|
25
31
|
* public-only rows and authed callers to owned + public + grant-admitted
|
|
@@ -46,13 +52,13 @@
|
|
|
46
52
|
* @module
|
|
47
53
|
*/
|
|
48
54
|
import { z } from 'zod';
|
|
49
|
-
import { rpc_action } from '../actions/
|
|
55
|
+
import { rpc_action } from '../actions/action_types.js';
|
|
50
56
|
import { jsonrpc_errors, dev_only } from '../http/jsonrpc_errors.js';
|
|
51
57
|
import { is_pg_unique_violation } from '../db/pg_error.js';
|
|
52
58
|
import { has_scoped_role } from './request_context.js';
|
|
53
59
|
import { ROLE_ADMIN } from './role_schema.js';
|
|
54
|
-
import { cell_create_action_spec, cell_get_action_spec, cell_update_action_spec, cell_delete_action_spec, cell_list_action_spec, cell_clone_action_spec, cell_moderate_action_spec,
|
|
55
|
-
import { query_cell_create, query_cell_get, query_cell_get_by_path, query_cell_update, query_cell_delete, query_cell_set_moderation, query_cell_list, query_cell_load_many } from '../db/cell_queries.js';
|
|
60
|
+
import { cell_create_action_spec, cell_get_action_spec, cell_update_action_spec, cell_delete_action_spec, cell_list_action_spec, cell_clone_action_spec, cell_moderate_action_spec, cell_policy_set_action_spec, ERROR_CELL_PATH_ADMIN_ONLY, ERROR_CELL_PATH_TAKEN, ERROR_CELL_VISIBILITY_MANAGE_ONLY, ERROR_CELL_GET_REQUIRES_ID_OR_PATH, ERROR_CELL_KIND_IN_DATA, ERROR_CELL_KIND_EMPTY, ERROR_CELL_CREATE_FORBIDDEN, ERROR_CELL_MODERATE_FORBIDDEN, ERROR_CELL_NOT_A_CONTRIBUTION, ERROR_CELL_NOT_PENDING, ERROR_CELL_POLICY_MANAGE_ONLY, ERROR_CELL_POLICY_ROOT_ONLY, ERROR_CELL_POLICY_UNSUPPORTED, ERROR_CELL_LIST_CREATED_BY_REQUIRES_AUTH, ERROR_CELL_LIST_SHARED_WITH_REQUIRES_AUTH, CELL_LIST_LIMIT_DEFAULT, CELL_RELATIONS_BUNDLE_LIMIT } from './cell_action_specs.js';
|
|
61
|
+
import { query_cell_create, query_cell_get, query_cell_get_by_path, query_cell_update, query_cell_delete, query_cell_set_moderation, query_cell_set_policy, query_cell_list, query_cell_load_many } from '../db/cell_queries.js';
|
|
56
62
|
import { query_cell_grant_list_for_cell, query_cell_grants_for_caller_in_cells } from '../db/cell_grant_queries.js';
|
|
57
63
|
import { query_cell_field_list_for_source, query_cell_field_set } from '../db/cell_field_queries.js';
|
|
58
64
|
import { query_cell_item_insert, query_cell_item_list_for_parent } from '../db/cell_item_queries.js';
|
|
@@ -60,6 +66,7 @@ import { can_view_cell, can_edit_cell, can_manage_cell, cell_viewer_from_auth }
|
|
|
60
66
|
import { filter_visible_target_ids } from './cell_relation_visibility.js';
|
|
61
67
|
import { CELL_VIEWER_UNRESTRICTED } from '../db/cell_view_sql.js';
|
|
62
68
|
import { cell_steward_admits } from './cell_steward.js';
|
|
69
|
+
import { cell_not_found_error, emit_cell_audit, require_editable_cell, require_viewable_cell } from './cell_action_helpers.js';
|
|
63
70
|
import { require_new_refs_held } from './cell_ref_admission.js';
|
|
64
71
|
import { to_grant_json } from './cell_grant_actions.js';
|
|
65
72
|
import { to_field_json } from './cell_field_actions.js';
|
|
@@ -71,6 +78,18 @@ import { to_item_json } from './cell_item_actions.js';
|
|
|
71
78
|
* write is unambiguously a path collision.
|
|
72
79
|
*/
|
|
73
80
|
const path_taken_error = () => jsonrpc_errors.conflict('cell.path is already taken', { reason: ERROR_CELL_PATH_TAKEN });
|
|
81
|
+
/** The refusal of a policy write nothing can interpret. */
|
|
82
|
+
const cell_policy_unsupported_error = () => jsonrpc_errors.invalid_params('cell.policy needs a create authorizer that accepts it', {
|
|
83
|
+
reason: ERROR_CELL_POLICY_UNSUPPORTED
|
|
84
|
+
});
|
|
85
|
+
/** The refusal of a policy write on a cell with a parent. */
|
|
86
|
+
const cell_policy_root_only_error = () => jsonrpc_errors.invalid_params('cell.policy is set only on a root (a cell without a parent)', {
|
|
87
|
+
reason: ERROR_CELL_POLICY_ROOT_ONLY
|
|
88
|
+
});
|
|
89
|
+
/** The `cell_moderate` refusal of a transition the contribution's state doesn't allow. */
|
|
90
|
+
const cell_not_pending_error = () => jsonrpc_errors.invalid_params('cell is not pending moderation', {
|
|
91
|
+
reason: ERROR_CELL_NOT_PENDING
|
|
92
|
+
});
|
|
74
93
|
/**
|
|
75
94
|
* Reject a `kind` key supplied inside `data`. `kind` is the top-level
|
|
76
95
|
* `cell.kind` column (write-once capability axis), so a copy inside the
|
|
@@ -95,6 +114,7 @@ export const to_cell_json = (row) => ({
|
|
|
95
114
|
parent_id: row.parent_id,
|
|
96
115
|
root_id: row.root_id,
|
|
97
116
|
moderation: row.moderation,
|
|
117
|
+
policy: row.policy,
|
|
98
118
|
created_by: row.created_by,
|
|
99
119
|
updated_by: row.updated_by,
|
|
100
120
|
created_at: row.created_at,
|
|
@@ -103,23 +123,16 @@ export const to_cell_json = (row) => ({
|
|
|
103
123
|
grant_count: row.grant_count
|
|
104
124
|
});
|
|
105
125
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
126
|
+
* The `{cell_id, kind?, path?}` envelope of the `cell_create` /
|
|
127
|
+
* `cell_update` / `cell_delete` audit rows, `kind` and `path` omitted when
|
|
128
|
+
* null. Relation-graph mutations are tracked independently via per-row
|
|
129
|
+
* `cell_item_*` / `cell_field_*` events.
|
|
109
130
|
*/
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
ip: ctx.client_ip,
|
|
116
|
-
metadata: {
|
|
117
|
-
cell_id: row.id,
|
|
118
|
-
kind: row.kind ?? undefined,
|
|
119
|
-
path: row.path
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
};
|
|
131
|
+
const cell_mutation_metadata = (row) => ({
|
|
132
|
+
cell_id: row.id,
|
|
133
|
+
...(row.kind !== null ? { kind: row.kind } : {}),
|
|
134
|
+
...(row.path !== null ? { path: row.path } : {})
|
|
135
|
+
});
|
|
123
136
|
/**
|
|
124
137
|
* Gate a loaded cell on `can_view_cell` or, when that denies, the steward arm
|
|
125
138
|
* (`cell_steward_admits` — the governing root's manager reading a pending or
|
|
@@ -137,9 +150,22 @@ const admit_viewable_or_stewarded_cell = async (deps, auth, row, grants) => {
|
|
|
137
150
|
return;
|
|
138
151
|
if (await cell_steward_admits(deps, auth, row))
|
|
139
152
|
return;
|
|
140
|
-
throw
|
|
153
|
+
throw cell_not_found_error();
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Load a cell and gate the caller through `admit_viewable_or_stewarded_cell`,
|
|
157
|
+
* 404-masking a miss and a denial alike. `cell_moderate`'s view step — it lets
|
|
158
|
+
* a non-admin root owner reach the root-authority check.
|
|
159
|
+
*/
|
|
160
|
+
const require_viewable_or_stewarded_cell = async (deps, auth, cell_id) => {
|
|
161
|
+
const row = await query_cell_get(deps, cell_id);
|
|
162
|
+
if (!row)
|
|
163
|
+
throw cell_not_found_error();
|
|
164
|
+
const grants = await query_cell_grant_list_for_cell(deps, row.id);
|
|
165
|
+
await admit_viewable_or_stewarded_cell(deps, auth, row, grants);
|
|
166
|
+
return row;
|
|
141
167
|
};
|
|
142
|
-
/** Create the
|
|
168
|
+
/** Create the generic cell RPC actions. */
|
|
143
169
|
export const create_cell_actions = (deps) => {
|
|
144
170
|
const { validate_data, authorize_create } = deps;
|
|
145
171
|
/**
|
|
@@ -149,11 +175,11 @@ export const create_cell_actions = (deps) => {
|
|
|
149
175
|
* -32603 / internal). The dispatcher only auto-converts ZodError for
|
|
150
176
|
* wire-level input schemas; sub-API validation runs inside the handler.
|
|
151
177
|
*/
|
|
152
|
-
const validate_data_or_throw = (data) => {
|
|
178
|
+
const validate_data_or_throw = (kind, data) => {
|
|
153
179
|
if (validate_data === undefined)
|
|
154
|
-
return
|
|
180
|
+
return;
|
|
155
181
|
try {
|
|
156
|
-
|
|
182
|
+
validate_data(kind, data);
|
|
157
183
|
}
|
|
158
184
|
catch (err) {
|
|
159
185
|
if (err instanceof z.ZodError) {
|
|
@@ -162,6 +188,25 @@ export const create_cell_actions = (deps) => {
|
|
|
162
188
|
throw err;
|
|
163
189
|
}
|
|
164
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* Validate a non-null policy write through the mounted authorizer's
|
|
193
|
+
* `validate_policy` — `ERROR_CELL_POLICY_UNSUPPORTED` when there is none
|
|
194
|
+
* (no authorizer, or one without the member). A thrown `ZodError` becomes
|
|
195
|
+
* `invalid_params`, as `validate_data_or_throw` does.
|
|
196
|
+
*/
|
|
197
|
+
const validate_policy_write = (policy) => {
|
|
198
|
+
if (authorize_create?.validate_policy === undefined)
|
|
199
|
+
throw cell_policy_unsupported_error();
|
|
200
|
+
try {
|
|
201
|
+
authorize_create.validate_policy(policy);
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
if (err instanceof z.ZodError) {
|
|
205
|
+
throw jsonrpc_errors.invalid_params('cell.policy validation failed', dev_only({ issues: err.issues }));
|
|
206
|
+
}
|
|
207
|
+
throw err;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
165
210
|
const create_handler = async (input, ctx) => {
|
|
166
211
|
const auth = ctx.auth;
|
|
167
212
|
// Path writes are admin-only. Reject before the insert so the audit
|
|
@@ -183,10 +228,20 @@ export const create_cell_actions = (deps) => {
|
|
|
183
228
|
}
|
|
184
229
|
// Per-kind shape validation (sub-API). Unknown kinds pass through;
|
|
185
230
|
// known kinds with malformed payloads surface as invalid_params.
|
|
186
|
-
const validated_data = validate_data_or_throw(input.data);
|
|
187
231
|
const kind = input.kind ?? null;
|
|
232
|
+
validate_data_or_throw(kind, input.data);
|
|
233
|
+
const parent_id = input.parent_id ?? null;
|
|
234
|
+
const policy = input.policy ?? null;
|
|
235
|
+
// A contribution policy is a root's alone, and the mounted authorizer —
|
|
236
|
+
// what interprets it — must accept it (none mounted refuses it). The
|
|
237
|
+
// authorizer does not gate it: a root's creator manages the root anyway.
|
|
238
|
+
if (policy !== null) {
|
|
239
|
+
if (parent_id !== null)
|
|
240
|
+
throw cell_policy_root_only_error();
|
|
241
|
+
validate_policy_write(policy);
|
|
242
|
+
}
|
|
188
243
|
// Directory tree: resolve the governing `root_id` from the parent (and
|
|
189
|
-
// the root's `
|
|
244
|
+
// the root's `policy` for the authorizer). Runs whether or
|
|
190
245
|
// not an authorizer is mounted — `root_id` is written regardless, and an
|
|
191
246
|
// unviewable parent 404-masks the attempt (the same IDOR mask the read
|
|
192
247
|
// path uses; never reveals a hidden container). A root creation
|
|
@@ -198,49 +253,41 @@ export const create_cell_actions = (deps) => {
|
|
|
198
253
|
// answers `cell_not_found` like a missing parent (soft delete doesn't
|
|
199
254
|
// cascade, so a live parent can sit under a tombstoned root): nothing is
|
|
200
255
|
// written pointing at the tombstone, and an authorizer never sees a root
|
|
201
|
-
// id
|
|
202
|
-
const parent_id = input.parent_id ?? null;
|
|
256
|
+
// id it can't read.
|
|
203
257
|
let root_id = null;
|
|
204
|
-
let
|
|
258
|
+
let root_policy = null;
|
|
259
|
+
let parent_kind = null;
|
|
205
260
|
if (parent_id !== null) {
|
|
206
|
-
const parent = await
|
|
207
|
-
|
|
208
|
-
throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
|
|
209
|
-
const parent_grants = await query_cell_grant_list_for_cell(ctx, parent.id);
|
|
210
|
-
if (!can_view_cell(auth, parent, parent_grants)) {
|
|
211
|
-
throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
|
|
212
|
-
}
|
|
261
|
+
const parent = await require_viewable_cell(ctx, auth, parent_id);
|
|
262
|
+
parent_kind = parent.kind;
|
|
213
263
|
root_id = parent.root_id ?? parent.id;
|
|
214
264
|
if (root_id === parent.id) {
|
|
215
|
-
|
|
265
|
+
root_policy = parent.policy;
|
|
216
266
|
}
|
|
217
267
|
else {
|
|
218
268
|
const root = await query_cell_get(ctx, root_id);
|
|
219
269
|
if (!root)
|
|
220
|
-
throw
|
|
221
|
-
|
|
270
|
+
throw cell_not_found_error();
|
|
271
|
+
root_policy = root.policy;
|
|
222
272
|
}
|
|
223
273
|
}
|
|
224
274
|
// Parent-aware creation authorizer (opt-in). Runs after shape validation
|
|
225
275
|
// and after the parent-resolve (a hidden parent already 404-masked).
|
|
226
276
|
// `{allow: false}` for a *viewable* parent / a root creation is a 403
|
|
227
277
|
// `forbidden` (not the 404 mask); an `{allow: true}` verdict folds the
|
|
228
|
-
// moderation outcome.
|
|
229
|
-
//
|
|
230
|
-
// with a transforming validator can't diverge TS↔Rust. `scope_id` is
|
|
231
|
-
// `null` in v1. Without an authorizer, create is open: `moderation` stays
|
|
232
|
-
// null and the author's visibility holds.
|
|
278
|
+
// moderation outcome. Without an authorizer, create is open: `moderation`
|
|
279
|
+
// stays null and the author's visibility holds.
|
|
233
280
|
let moderation = null;
|
|
234
281
|
let visibility = input.visibility;
|
|
235
282
|
if (authorize_create) {
|
|
236
|
-
const verdict = await authorize_create(auth, {
|
|
283
|
+
const verdict = await authorize_create.authorize(auth, {
|
|
237
284
|
kind,
|
|
238
285
|
data: input.data,
|
|
239
286
|
parent_id,
|
|
287
|
+
parent_kind,
|
|
240
288
|
root_id,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
});
|
|
289
|
+
root_policy
|
|
290
|
+
}, ctx);
|
|
244
291
|
if (!verdict.allow) {
|
|
245
292
|
throw jsonrpc_errors.forbidden('cell creation is not permitted here', {
|
|
246
293
|
reason: ERROR_CELL_CREATE_FORBIDDEN
|
|
@@ -263,10 +310,8 @@ export const create_cell_actions = (deps) => {
|
|
|
263
310
|
}
|
|
264
311
|
}
|
|
265
312
|
// Possession-gated ref admission, the last gate before the write — every
|
|
266
|
-
// ref is new on a create.
|
|
267
|
-
|
|
268
|
-
// `authorize_create` sees.
|
|
269
|
-
await require_new_refs_held(ctx, auth, null, validated_data);
|
|
313
|
+
// ref is new on a create.
|
|
314
|
+
await require_new_refs_held(ctx, auth, null, input.data);
|
|
270
315
|
let row;
|
|
271
316
|
try {
|
|
272
317
|
row = await query_cell_create(ctx, {
|
|
@@ -275,13 +320,14 @@ export const create_cell_actions = (deps) => {
|
|
|
275
320
|
// type carries `T | undefined` from `.optional()` which doesn't
|
|
276
321
|
// extend `Json`. The DB column is JSONB; the cast trusts the
|
|
277
322
|
// schema-validated runtime shape.
|
|
278
|
-
data:
|
|
323
|
+
data: input.data,
|
|
279
324
|
kind,
|
|
280
325
|
visibility,
|
|
281
326
|
path: input.path ?? null,
|
|
282
327
|
parent_id,
|
|
283
328
|
root_id,
|
|
284
329
|
moderation,
|
|
330
|
+
policy,
|
|
285
331
|
created_by: auth.actor.id
|
|
286
332
|
});
|
|
287
333
|
}
|
|
@@ -290,7 +336,7 @@ export const create_cell_actions = (deps) => {
|
|
|
290
336
|
throw path_taken_error();
|
|
291
337
|
throw err;
|
|
292
338
|
}
|
|
293
|
-
emit_cell_audit(ctx, 'cell_create', row
|
|
339
|
+
emit_cell_audit(ctx, deps.audit, auth, 'cell_create', cell_mutation_metadata(row));
|
|
294
340
|
return { cell: to_cell_json(row) };
|
|
295
341
|
};
|
|
296
342
|
const get_handler = async (input, ctx) => {
|
|
@@ -306,7 +352,7 @@ export const create_cell_actions = (deps) => {
|
|
|
306
352
|
? await query_cell_get(ctx, input.id)
|
|
307
353
|
: await query_cell_get_by_path(ctx, input.path);
|
|
308
354
|
if (!row) {
|
|
309
|
-
throw
|
|
355
|
+
throw cell_not_found_error();
|
|
310
356
|
}
|
|
311
357
|
// Run the three post-cell fetches in parallel — they share only
|
|
312
358
|
// `row.id` and have no inter-dependency. Bundle fetches one over the
|
|
@@ -369,15 +415,7 @@ export const create_cell_actions = (deps) => {
|
|
|
369
415
|
reason: ERROR_CELL_PATH_ADMIN_ONLY
|
|
370
416
|
});
|
|
371
417
|
}
|
|
372
|
-
const existing = await
|
|
373
|
-
if (!existing) {
|
|
374
|
-
throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
|
|
375
|
-
}
|
|
376
|
-
const grants = await query_cell_grant_list_for_cell(ctx, existing.id);
|
|
377
|
-
if (!can_edit_cell(auth, existing, grants)) {
|
|
378
|
-
// IDOR mask: 404, not 403 — same shape as cell_get.
|
|
379
|
-
throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
|
|
380
|
-
}
|
|
418
|
+
const existing = await require_editable_cell(ctx, auth, input.cell_id);
|
|
381
419
|
// Visibility writes are manage-tier only (admin / owner). An
|
|
382
420
|
// editor-grant holder may edit `data` but cannot flip the cell's
|
|
383
421
|
// visibility — that would let a delegated editor expose a private
|
|
@@ -390,26 +428,26 @@ export const create_cell_actions = (deps) => {
|
|
|
390
428
|
reason: ERROR_CELL_VISIBILITY_MANAGE_ONLY
|
|
391
429
|
});
|
|
392
430
|
}
|
|
393
|
-
// Per-kind shape validation when `data` is supplied
|
|
394
|
-
// we don't validate the existing
|
|
395
|
-
// is for incoming patches). `data`
|
|
396
|
-
// patch IS the post-update state. A stray
|
|
397
|
-
// (kind is the write-once top-level column —
|
|
398
|
-
// change it, structurally: it is not even a field on
|
|
399
|
-
|
|
431
|
+
// Per-kind shape validation when `data` is supplied, against the
|
|
432
|
+
// existing cell's `kind`. Patch-only — we don't validate the existing
|
|
433
|
+
// row's data on update (validation is for incoming patches). `data`
|
|
434
|
+
// writes fully replace, so the patch IS the post-update state. A stray
|
|
435
|
+
// `kind` inside it is rejected (kind is the write-once top-level column —
|
|
436
|
+
// `cell_update` cannot change it, structurally: it is not even a field on
|
|
437
|
+
// `CellUpdateInput`).
|
|
438
|
+
if (input.data !== undefined) {
|
|
400
439
|
reject_kind_in_data(input.data);
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
await require_new_refs_held(ctx, auth, existing.refs, validated_data);
|
|
440
|
+
validate_data_or_throw(existing.kind, input.data);
|
|
441
|
+
// Possession-gated ref admission against the cell's current refs: refs
|
|
442
|
+
// the cell already carries stay, whoever introduced them. A write with
|
|
443
|
+
// no `data` writes no refs and reads no holders.
|
|
444
|
+
await require_new_refs_held(ctx, auth, existing.refs, input.data);
|
|
407
445
|
}
|
|
408
446
|
let updated;
|
|
409
447
|
try {
|
|
410
448
|
updated = await query_cell_update(ctx, input.cell_id, {
|
|
411
449
|
// Boundary cast (see `create_handler`).
|
|
412
|
-
data:
|
|
450
|
+
data: input.data,
|
|
413
451
|
visibility: input.visibility,
|
|
414
452
|
path: path_provided ? (input.path ?? null) : undefined,
|
|
415
453
|
updated_by: auth.actor.id
|
|
@@ -423,43 +461,32 @@ export const create_cell_actions = (deps) => {
|
|
|
423
461
|
}
|
|
424
462
|
if (!updated) {
|
|
425
463
|
// Raced with a deleter between the visibility check and the UPDATE.
|
|
426
|
-
throw
|
|
464
|
+
throw cell_not_found_error();
|
|
427
465
|
}
|
|
428
|
-
emit_cell_audit(ctx, 'cell_update', updated
|
|
466
|
+
emit_cell_audit(ctx, deps.audit, auth, 'cell_update', cell_mutation_metadata(updated));
|
|
429
467
|
return { cell: to_cell_json(updated) };
|
|
430
468
|
};
|
|
431
469
|
const delete_handler = async (input, ctx) => {
|
|
432
470
|
const auth = ctx.auth;
|
|
433
471
|
// Fetch first so we can audit `kind` + `path` after the soft-delete
|
|
434
472
|
// flips `deleted_at`.
|
|
435
|
-
const existing = await
|
|
436
|
-
if (!existing) {
|
|
437
|
-
throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
|
|
438
|
-
}
|
|
439
|
-
const grants = await query_cell_grant_list_for_cell(ctx, existing.id);
|
|
440
|
-
if (!can_edit_cell(auth, existing, grants)) {
|
|
441
|
-
throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
|
|
442
|
-
}
|
|
473
|
+
const existing = await require_editable_cell(ctx, auth, input.cell_id);
|
|
443
474
|
const deleted = await query_cell_delete(ctx, input.cell_id, { deleted_by: auth.actor.id });
|
|
444
475
|
if (!deleted) {
|
|
445
476
|
// Raced with another deleter.
|
|
446
|
-
throw
|
|
477
|
+
throw cell_not_found_error();
|
|
447
478
|
}
|
|
448
|
-
emit_cell_audit(ctx, 'cell_delete', existing
|
|
479
|
+
emit_cell_audit(ctx, deps.audit, auth, 'cell_delete', cell_mutation_metadata(existing));
|
|
449
480
|
return { ok: true, deleted: true };
|
|
450
481
|
};
|
|
451
482
|
const moderate_handler = async (input, ctx) => {
|
|
452
483
|
const auth = ctx.auth;
|
|
453
|
-
const existing = await query_cell_get(ctx, input.cell_id);
|
|
454
484
|
// 404 covers miss + unviewable so a pending contribution doesn't leak
|
|
455
485
|
// existence to a non-viewer; the governing root's manager stewards it,
|
|
456
486
|
// which is how a non-admin root owner reaches the root check below. An
|
|
457
487
|
// approved contribution its author narrowed to private is not
|
|
458
488
|
// stewarded, so its root owner gets the 404 there.
|
|
459
|
-
|
|
460
|
-
throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
|
|
461
|
-
const grants = await query_cell_grant_list_for_cell(ctx, existing.id);
|
|
462
|
-
await admit_viewable_or_stewarded_cell(ctx, auth, existing, grants);
|
|
489
|
+
const existing = await require_viewable_or_stewarded_cell(ctx, auth, input.cell_id);
|
|
463
490
|
// Only a contribution (with a governing root) is moderatable.
|
|
464
491
|
if (existing.root_id === null) {
|
|
465
492
|
throw jsonrpc_errors.invalid_params('cell is not a contribution (no governing root to moderate under)', { reason: ERROR_CELL_NOT_A_CONTRIBUTION });
|
|
@@ -469,28 +496,66 @@ export const create_cell_actions = (deps) => {
|
|
|
469
496
|
// self-approve. A viewable-but-unauthorized caller (incl. the author) → 403.
|
|
470
497
|
const root = await query_cell_get(ctx, existing.root_id);
|
|
471
498
|
if (!root)
|
|
472
|
-
throw
|
|
499
|
+
throw cell_not_found_error();
|
|
473
500
|
if (!can_manage_cell(auth, root)) {
|
|
474
501
|
throw jsonrpc_errors.forbidden('cell_moderate requires moderation authority over the governing root', { reason: ERROR_CELL_MODERATE_FORBIDDEN });
|
|
475
502
|
}
|
|
503
|
+
// The UPDATE carries the allowed from-states: an approval moves only a
|
|
504
|
+
// pending contribution, a rejection a pending or approved one (the
|
|
505
|
+
// takedown); a rejected or unmoderated one never moves.
|
|
476
506
|
const approved = input.moderation === 'approved';
|
|
477
507
|
const updated = await query_cell_set_moderation(ctx, input.cell_id, input.moderation, {
|
|
478
508
|
set_visibility_public: approved,
|
|
479
509
|
updated_by: auth.actor.id
|
|
480
510
|
});
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
511
|
+
if (!updated) {
|
|
512
|
+
// No row in an allowed from-state: the transition is refused (or
|
|
513
|
+
// another moderator moved it first) — or a deleter won the race (404).
|
|
514
|
+
if (await query_cell_get(ctx, input.cell_id))
|
|
515
|
+
throw cell_not_pending_error();
|
|
516
|
+
throw cell_not_found_error();
|
|
517
|
+
}
|
|
518
|
+
emit_cell_audit(ctx, deps.audit, auth, 'cell_moderate', {
|
|
519
|
+
cell_id: updated.id,
|
|
520
|
+
root_id: existing.root_id,
|
|
521
|
+
moderation: input.moderation
|
|
522
|
+
});
|
|
523
|
+
return { cell: to_cell_json(updated) };
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* `cell_policy_set` — replace (or clear) a root's contribution policy,
|
|
527
|
+
* manage-tier on the root. Order: the 404 mask (a caller who can't view the
|
|
528
|
+
* cell), the manage check (403 `cell_policy_manage_only` — an editor grant
|
|
529
|
+
* edits `data` but never the policy that decides who may contribute),
|
|
530
|
+
* root-only (400 `cell_policy_root_only`), then a non-null policy's
|
|
531
|
+
* validation through the mounted authorizer. Audited with the policy written
|
|
532
|
+
* and the one it replaced.
|
|
533
|
+
*/
|
|
534
|
+
const policy_set_handler = async (input, ctx) => {
|
|
535
|
+
const auth = ctx.auth;
|
|
536
|
+
const existing = await require_viewable_cell(ctx, auth, input.cell_id);
|
|
537
|
+
if (!can_manage_cell(auth, existing)) {
|
|
538
|
+
throw jsonrpc_errors.forbidden('cell.policy is manage-tier only', {
|
|
539
|
+
reason: ERROR_CELL_POLICY_MANAGE_ONLY
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
if (existing.parent_id !== null)
|
|
543
|
+
throw cell_policy_root_only_error();
|
|
544
|
+
if (input.policy !== null)
|
|
545
|
+
validate_policy_write(input.policy);
|
|
546
|
+
const result = await query_cell_set_policy(ctx, input.cell_id, input.policy, {
|
|
547
|
+
updated_by: auth.actor.id
|
|
548
|
+
});
|
|
549
|
+
// Raced with a deleter between the gates and the UPDATE.
|
|
550
|
+
if (!result)
|
|
551
|
+
throw cell_not_found_error();
|
|
552
|
+
const updated = result.cell;
|
|
553
|
+
emit_cell_audit(ctx, deps.audit, auth, 'cell_policy_set', {
|
|
554
|
+
cell_id: updated.id,
|
|
555
|
+
policy: updated.policy,
|
|
556
|
+
// read under the UPDATE's row lock, not from `existing`, which a set
|
|
557
|
+
// racing past the gates may already have overwritten
|
|
558
|
+
previous_policy: result.previous_policy
|
|
494
559
|
});
|
|
495
560
|
return { cell: to_cell_json(updated) };
|
|
496
561
|
};
|
|
@@ -527,23 +592,23 @@ export const create_cell_actions = (deps) => {
|
|
|
527
592
|
// Both `source.data` and `options.patch_data` are CellData (loose
|
|
528
593
|
// objects). Patch-last shallow merge composes cleanly.
|
|
529
594
|
const merged_data = options.patch_data !== undefined ? { ...source.data, ...options.patch_data } : source.data;
|
|
530
|
-
// Per-kind shape validation runs on the merged result (sub-API)
|
|
531
|
-
//
|
|
532
|
-
// could violate the kind shape
|
|
533
|
-
|
|
595
|
+
// Per-kind shape validation runs on the merged result (sub-API), under
|
|
596
|
+
// the source's kind (the clone inherits it). Source rows are validated
|
|
597
|
+
// on their original create; the patch could violate the kind shape
|
|
598
|
+
// (e.g., remove a required field).
|
|
599
|
+
validate_data_or_throw(source.kind, merged_data);
|
|
534
600
|
// Creation-capability gate, after the shape check (the `cell_create`
|
|
535
|
-
// order). The clone is parentless, so no `
|
|
536
|
-
//
|
|
537
|
-
// hands it the raw input.
|
|
601
|
+
// order). The clone is parentless, so no `parent_kind` / `root_id` /
|
|
602
|
+
// `root_policy`.
|
|
538
603
|
if (authorize_create) {
|
|
539
|
-
const verdict = await authorize_create(auth, {
|
|
604
|
+
const verdict = await authorize_create.authorize(auth, {
|
|
540
605
|
kind: source.kind,
|
|
541
606
|
data: merged_data,
|
|
542
607
|
parent_id: null,
|
|
608
|
+
parent_kind: null,
|
|
543
609
|
root_id: null,
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
});
|
|
610
|
+
root_policy: null
|
|
611
|
+
}, ctx);
|
|
547
612
|
if (!verdict.allow) {
|
|
548
613
|
throw jsonrpc_errors.forbidden('cell creation is not permitted here', {
|
|
549
614
|
reason: ERROR_CELL_CREATE_FORBIDDEN
|
|
@@ -552,33 +617,26 @@ export const create_cell_actions = (deps) => {
|
|
|
552
617
|
}
|
|
553
618
|
// Possession-gated ref admission against the source row's refs: a clone
|
|
554
619
|
// carries what the source already serves to this viewer; a patch adding a
|
|
555
|
-
// ref needs the caller to hold it.
|
|
556
|
-
|
|
557
|
-
// merged data `authorize_create` sees.
|
|
558
|
-
await require_new_refs_held(ctx, auth, source.refs, validated_data);
|
|
620
|
+
// ref needs the caller to hold it.
|
|
621
|
+
await require_new_refs_held(ctx, auth, source.refs, merged_data);
|
|
559
622
|
return query_cell_create(ctx, {
|
|
560
623
|
// Boundary cast (see `create_handler`).
|
|
561
|
-
data:
|
|
624
|
+
data: merged_data,
|
|
562
625
|
// Clone inherits the source's kind verbatim — kind is fixed at
|
|
563
626
|
// birth and a `with_data_patch` can't reach the column.
|
|
564
627
|
kind: source.kind,
|
|
565
628
|
visibility: source.visibility,
|
|
566
629
|
path: null, // admin-only paths cannot auto-clone
|
|
630
|
+
// no `policy`: a clone is born without one, so cloning a root never
|
|
631
|
+
// copies its governance onto a cell the cloner owns
|
|
567
632
|
created_by: auth.actor.id
|
|
568
633
|
});
|
|
569
634
|
};
|
|
570
635
|
const clone_handler = async (input, ctx) => {
|
|
571
636
|
const auth = ctx.auth;
|
|
572
|
-
const source = await query_cell_get(ctx, input.source_id);
|
|
573
|
-
if (!source) {
|
|
574
|
-
throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
|
|
575
|
-
}
|
|
576
|
-
const source_grants = await query_cell_grant_list_for_cell(ctx, source.id);
|
|
577
637
|
// 404 covers both miss and unauthorized read — same shape as cell_get
|
|
578
638
|
// so the existence of private cells doesn't leak through clones.
|
|
579
|
-
|
|
580
|
-
throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
|
|
581
|
-
}
|
|
639
|
+
const source = await require_viewable_cell(ctx, auth, input.source_id);
|
|
582
640
|
const deep = input.deep === true;
|
|
583
641
|
// Pre-fetch source relations OUTSIDE the transaction so authz checks
|
|
584
642
|
// (per-child `can_view_cell`) on `query_cell_get`-fetched grants
|
|
@@ -685,24 +743,15 @@ export const create_cell_actions = (deps) => {
|
|
|
685
743
|
});
|
|
686
744
|
}
|
|
687
745
|
}
|
|
688
|
-
//
|
|
689
|
-
//
|
|
690
|
-
// `kind` is read from `source.data` (not the cloned row) so the
|
|
691
|
-
// audit trail attributes the clone to the source's shape.
|
|
692
|
-
const source_kind = source.kind ?? undefined;
|
|
746
|
+
// `kind` is the source's (not the cloned row's) so the audit trail
|
|
747
|
+
// attributes the clone to the source's shape.
|
|
693
748
|
const cloned_child_count = deep ? cloneable_items.length : 0;
|
|
694
|
-
deps.audit
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
source_id: source.id,
|
|
701
|
-
new_id: cloned_root.id,
|
|
702
|
-
deep,
|
|
703
|
-
item_count: cloned_child_count,
|
|
704
|
-
...(source_kind !== undefined ? { kind: source_kind } : {})
|
|
705
|
-
}
|
|
749
|
+
emit_cell_audit(ctx, deps.audit, auth, 'cell_clone', {
|
|
750
|
+
source_id: source.id,
|
|
751
|
+
new_id: cloned_root.id,
|
|
752
|
+
deep,
|
|
753
|
+
item_count: cloned_child_count,
|
|
754
|
+
...(source.kind !== null ? { kind: source.kind } : {})
|
|
706
755
|
});
|
|
707
756
|
return { cell: to_cell_json(cloned_root) };
|
|
708
757
|
};
|
|
@@ -727,7 +776,6 @@ export const create_cell_actions = (deps) => {
|
|
|
727
776
|
// `cell_grant` role-shaped EXISTS (NULL `scope_id`s pass through as
|
|
728
777
|
// global-scope role_grants).
|
|
729
778
|
const viewer = cell_viewer_from_auth(auth);
|
|
730
|
-
const caller_actor_id = viewer.actor_id;
|
|
731
779
|
const rows = await query_cell_list(ctx, {
|
|
732
780
|
ids: input.ids,
|
|
733
781
|
kind: input.kind,
|
|
@@ -737,11 +785,7 @@ export const create_cell_actions = (deps) => {
|
|
|
737
785
|
path_prefix: input.path_prefix,
|
|
738
786
|
root_id: input.root_id,
|
|
739
787
|
moderation: input.moderation,
|
|
740
|
-
|
|
741
|
-
viewer_is_admin: viewer.is_admin,
|
|
742
|
-
caller_actor_id,
|
|
743
|
-
caller_role_grant_roles: viewer.role_grant_roles,
|
|
744
|
-
caller_role_grant_scope_ids: viewer.role_grant_scope_ids,
|
|
788
|
+
viewer,
|
|
745
789
|
shared_with_caller_only: input.shared_with === 'me',
|
|
746
790
|
order_by: input.order_by,
|
|
747
791
|
order_direction: input.order_direction,
|
|
@@ -751,8 +795,8 @@ export const create_cell_actions = (deps) => {
|
|
|
751
795
|
offset: input.offset
|
|
752
796
|
});
|
|
753
797
|
let cell_grants;
|
|
754
|
-
if (input.shared_with === 'me' && rows.length > 0 &&
|
|
755
|
-
const grant_rows = await query_cell_grants_for_caller_in_cells(ctx, rows.map((r) => r.id),
|
|
798
|
+
if (input.shared_with === 'me' && rows.length > 0 && viewer.actor_id !== null) {
|
|
799
|
+
const grant_rows = await query_cell_grants_for_caller_in_cells(ctx, rows.map((r) => r.id), viewer);
|
|
756
800
|
cell_grants = {};
|
|
757
801
|
for (const g of grant_rows) {
|
|
758
802
|
(cell_grants[g.cell_id] ??= []).push(to_grant_json(g));
|
|
@@ -767,6 +811,7 @@ export const create_cell_actions = (deps) => {
|
|
|
767
811
|
rpc_action(cell_delete_action_spec, delete_handler),
|
|
768
812
|
rpc_action(cell_list_action_spec, list_handler),
|
|
769
813
|
rpc_action(cell_clone_action_spec, clone_handler),
|
|
770
|
-
rpc_action(cell_moderate_action_spec, moderate_handler)
|
|
814
|
+
rpc_action(cell_moderate_action_spec, moderate_handler),
|
|
815
|
+
rpc_action(cell_policy_set_action_spec, policy_set_handler)
|
|
771
816
|
];
|
|
772
817
|
};
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
|
-
import { type RpcAction } from '../actions/
|
|
16
|
+
import { type RpcAction } from '../actions/action_types.js';
|
|
17
17
|
export declare const create_cell_audit_actions: () => Array<RpcAction>;
|
|
18
18
|
//# sourceMappingURL=cell_audit_actions.d.ts.map
|