@fuzdev/fuz_app 0.50.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +16 -3
- package/dist/actions/action_bridge.d.ts +3 -1
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +3 -1
- package/dist/actions/action_codegen.d.ts +44 -13
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +58 -20
- package/dist/actions/action_event.d.ts +44 -1
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +44 -1
- package/dist/actions/action_event_helpers.d.ts +26 -0
- package/dist/actions/action_event_helpers.d.ts.map +1 -1
- package/dist/actions/action_event_helpers.js +26 -1
- package/dist/actions/action_peer.d.ts +17 -0
- package/dist/actions/action_peer.d.ts.map +1 -1
- package/dist/actions/action_peer.js +8 -0
- package/dist/actions/action_registry.d.ts +2 -2
- package/dist/actions/action_registry.js +2 -2
- package/dist/actions/action_rpc.d.ts +4 -0
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +4 -0
- package/dist/actions/action_spec.d.ts +23 -3
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +17 -3
- package/dist/actions/action_types.d.ts +2 -2
- package/dist/actions/action_types.js +2 -2
- package/dist/actions/cancel.d.ts +2 -2
- package/dist/actions/cancel.js +2 -2
- package/dist/actions/heartbeat.d.ts +2 -2
- package/dist/actions/heartbeat.js +2 -2
- package/dist/actions/protocol.d.ts +1 -1
- package/dist/actions/protocol.js +1 -1
- package/dist/actions/register_action_ws.d.ts +4 -1
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +4 -1
- package/dist/actions/register_ws_endpoint.d.ts +3 -0
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +3 -0
- package/dist/actions/request_tracker.svelte.d.ts +14 -1
- package/dist/actions/request_tracker.svelte.d.ts.map +1 -1
- package/dist/actions/request_tracker.svelte.js +14 -1
- package/dist/actions/socket.svelte.d.ts +35 -15
- package/dist/actions/socket.svelte.d.ts.map +1 -1
- package/dist/actions/socket.svelte.js +33 -13
- package/dist/actions/transports.d.ts +12 -3
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +16 -7
- package/dist/actions/transports_http.d.ts +7 -0
- package/dist/actions/transports_http.d.ts.map +1 -1
- package/dist/actions/transports_http.js +7 -0
- package/dist/actions/transports_ws.d.ts +13 -0
- package/dist/actions/transports_ws.d.ts.map +1 -1
- package/dist/actions/transports_ws.js +13 -0
- package/dist/actions/transports_ws_auth_guard.d.ts +6 -2
- package/dist/actions/transports_ws_auth_guard.d.ts.map +1 -1
- package/dist/actions/transports_ws_auth_guard.js +6 -2
- package/dist/actions/transports_ws_backend.d.ts +14 -1
- package/dist/actions/transports_ws_backend.d.ts.map +1 -1
- package/dist/actions/transports_ws_backend.js +14 -1
- package/dist/auth/CLAUDE.md +40 -4
- 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 +10 -0
- package/dist/auth/account_routes.d.ts +3 -3
- package/dist/auth/account_routes.js +3 -3
- package/dist/auth/account_schema.d.ts +1 -1
- package/dist/auth/account_schema.js +1 -1
- package/dist/auth/admin_actions.d.ts +1 -0
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +1 -0
- package/dist/auth/api_token.d.ts +1 -1
- package/dist/auth/api_token.js +1 -1
- package/dist/auth/api_token_queries.d.ts +7 -0
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +7 -0
- package/dist/auth/app_settings_queries.d.ts +4 -0
- package/dist/auth/app_settings_queries.d.ts.map +1 -1
- package/dist/auth/app_settings_queries.js +4 -0
- package/dist/auth/audit_log_queries.d.ts +6 -0
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +6 -0
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.js +1 -1
- package/dist/auth/audit_log_schema.d.ts +3 -1
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +134 -55
- package/dist/auth/bearer_auth.d.ts +2 -0
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +2 -0
- package/dist/auth/bootstrap_account.d.ts +3 -0
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +3 -0
- package/dist/auth/cleanup.d.ts +6 -0
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +6 -0
- package/dist/auth/daemon_token.d.ts +1 -1
- package/dist/auth/daemon_token.js +1 -1
- package/dist/auth/daemon_token_middleware.d.ts +5 -1
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +5 -1
- package/dist/auth/ddl.d.ts +1 -1
- package/dist/auth/ddl.js +1 -1
- package/dist/auth/invite_queries.d.ts +4 -0
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +4 -0
- package/dist/auth/password.d.ts +1 -1
- package/dist/auth/password.js +1 -1
- package/dist/auth/permit_offer_action_specs.d.ts +5 -0
- package/dist/auth/permit_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/permit_offer_action_specs.js +10 -0
- package/dist/auth/permit_offer_queries.d.ts +19 -0
- package/dist/auth/permit_offer_queries.d.ts.map +1 -1
- package/dist/auth/permit_offer_queries.js +19 -0
- package/dist/auth/permit_queries.d.ts +8 -0
- package/dist/auth/permit_queries.d.ts.map +1 -1
- package/dist/auth/permit_queries.js +8 -0
- package/dist/auth/request_context.d.ts +1 -0
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +1 -0
- package/dist/auth/role_schema.d.ts +2 -0
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +2 -0
- package/dist/auth/route_guards.d.ts +1 -1
- package/dist/auth/route_guards.js +1 -1
- package/dist/auth/self_service_role_action_specs.d.ts +1 -1
- package/dist/auth/self_service_role_action_specs.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +2 -1
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +2 -1
- package/dist/auth/session_lifecycle.d.ts +3 -0
- package/dist/auth/session_lifecycle.d.ts.map +1 -1
- package/dist/auth/session_lifecycle.js +3 -0
- package/dist/auth/session_middleware.d.ts +5 -0
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +5 -0
- package/dist/auth/session_queries.d.ts +10 -1
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +10 -1
- package/dist/auth/signup_routes.d.ts +1 -1
- package/dist/auth/signup_routes.js +1 -1
- package/dist/cli/config.d.ts +2 -0
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +2 -0
- package/dist/cli/daemon.d.ts +6 -1
- package/dist/cli/daemon.d.ts.map +1 -1
- package/dist/cli/daemon.js +6 -1
- package/dist/cli/util.d.ts +1 -1
- package/dist/cli/util.js +1 -1
- package/dist/db/assert_row.d.ts +2 -1
- package/dist/db/assert_row.d.ts.map +1 -1
- package/dist/db/assert_row.js +2 -1
- package/dist/db/create_db.d.ts +5 -2
- package/dist/db/create_db.d.ts.map +1 -1
- package/dist/db/create_db.js +5 -2
- package/dist/db/db.d.ts +22 -7
- package/dist/db/db.d.ts.map +1 -1
- package/dist/db/db.js +21 -6
- package/dist/db/db_pg.d.ts +2 -1
- package/dist/db/db_pg.d.ts.map +1 -1
- package/dist/db/db_pg.js +5 -3
- package/dist/db/db_pglite.d.ts +3 -2
- package/dist/db/db_pglite.d.ts.map +1 -1
- package/dist/db/db_pglite.js +3 -2
- package/dist/db/migrate.d.ts +8 -4
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +6 -2
- package/dist/db/sql_identifier.d.ts +2 -1
- package/dist/db/sql_identifier.d.ts.map +1 -1
- package/dist/db/sql_identifier.js +2 -1
- package/dist/db/status.d.ts +4 -1
- package/dist/db/status.d.ts.map +1 -1
- package/dist/db/status.js +5 -2
- package/dist/dev/setup.d.ts +18 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +18 -2
- package/dist/env/dotenv.d.ts +2 -1
- package/dist/env/dotenv.d.ts.map +1 -1
- package/dist/env/dotenv.js +2 -1
- package/dist/env/load.d.ts +1 -1
- package/dist/env/load.js +1 -1
- package/dist/env/resolve.d.ts +1 -1
- package/dist/env/resolve.js +1 -1
- package/dist/env/update_env_variable.d.ts +2 -0
- package/dist/env/update_env_variable.d.ts.map +1 -1
- package/dist/env/update_env_variable.js +2 -0
- package/dist/hono_context.d.ts +1 -1
- package/dist/hono_context.js +1 -1
- package/dist/http/jsonrpc_errors.d.ts +2 -2
- package/dist/http/jsonrpc_errors.js +2 -2
- package/dist/http/jsonrpc_helpers.d.ts +2 -2
- package/dist/http/jsonrpc_helpers.js +2 -2
- package/dist/http/middleware_spec.d.ts +1 -1
- package/dist/http/middleware_spec.js +1 -1
- package/dist/http/origin.d.ts +1 -1
- package/dist/http/origin.js +1 -1
- package/dist/http/pending_effects.d.ts +4 -0
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +4 -0
- package/dist/http/proxy.d.ts +3 -0
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +3 -0
- package/dist/http/route_spec.d.ts +1 -0
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +7 -0
- package/dist/http/schema_helpers.d.ts +1 -1
- package/dist/http/schema_helpers.js +1 -1
- package/dist/http/surface.d.ts +1 -1
- package/dist/http/surface.js +1 -1
- package/dist/rate_limiter.d.ts +14 -1
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +14 -1
- package/dist/realtime/sse.d.ts +7 -1
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +3 -1
- package/dist/realtime/sse_auth_guard.d.ts +21 -21
- package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
- package/dist/realtime/sse_auth_guard.js +24 -24
- package/dist/realtime/subscriber_registry.d.ts +4 -2
- package/dist/realtime/subscriber_registry.d.ts.map +1 -1
- package/dist/realtime/subscriber_registry.js +4 -2
- package/dist/runtime/deno.d.ts +1 -1
- package/dist/runtime/deno.js +1 -1
- package/dist/runtime/fs.d.ts +5 -0
- package/dist/runtime/fs.d.ts.map +1 -1
- package/dist/runtime/fs.js +5 -0
- package/dist/runtime/mock.d.ts +6 -0
- package/dist/runtime/mock.d.ts.map +1 -1
- package/dist/runtime/mock.js +6 -0
- package/dist/runtime/node.d.ts +1 -1
- package/dist/runtime/node.js +1 -1
- package/dist/server/app_backend.d.ts +1 -0
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +1 -0
- package/dist/server/app_server.d.ts +4 -0
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +4 -0
- package/dist/server/validate_nginx.d.ts +3 -0
- package/dist/server/validate_nginx.d.ts.map +1 -1
- package/dist/testing/admin_integration.d.ts +5 -0
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +5 -0
- package/dist/testing/adversarial_headers.d.ts +5 -3
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +5 -3
- package/dist/testing/adversarial_input.d.ts +4 -0
- package/dist/testing/adversarial_input.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +4 -0
- package/dist/testing/app_server.d.ts +3 -0
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +11 -0
- package/dist/testing/assertions.d.ts +23 -7
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +23 -7
- package/dist/testing/audit_completeness.d.ts +4 -0
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +4 -0
- package/dist/testing/auth_apps.d.ts +3 -0
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +3 -0
- package/dist/testing/db.d.ts +9 -1
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +9 -1
- package/dist/testing/error_coverage.d.ts +9 -0
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +9 -0
- package/dist/testing/integration.d.ts +4 -0
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +4 -0
- package/dist/testing/integration_helpers.d.ts +10 -4
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +10 -4
- package/dist/testing/middleware.d.ts +5 -0
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +5 -0
- package/dist/testing/rate_limiting.d.ts +3 -0
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +3 -0
- package/dist/testing/rpc_attack_surface.js +1 -1
- package/dist/testing/rpc_helpers.d.ts +21 -8
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +22 -9
- package/dist/testing/schema_generators.d.ts +7 -2
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +7 -2
- package/dist/testing/sse_round_trip.d.ts +3 -0
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +3 -0
- package/dist/testing/stubs.d.ts +7 -0
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +7 -0
- package/dist/testing/surface_invariants.d.ts +14 -0
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +14 -0
- package/dist/testing/ws_round_trip.d.ts +13 -1
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +1 -1
- package/dist/ui/AccountSessions.svelte +9 -0
- package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAccounts.svelte +10 -0
- package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAuditLog.svelte +10 -0
- package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
- package/dist/ui/AdminInvites.svelte +9 -0
- package/dist/ui/AdminInvites.svelte.d.ts.map +1 -1
- package/dist/ui/AdminOverview.svelte +10 -0
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/AdminPermitHistory.svelte +9 -0
- package/dist/ui/AdminPermitHistory.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSessions.svelte +10 -0
- package/dist/ui/AdminSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSettings.svelte +9 -0
- package/dist/ui/AdminSettings.svelte.d.ts.map +1 -1
- package/dist/ui/AdminSurface.svelte +9 -0
- package/dist/ui/AdminSurface.svelte.d.ts.map +1 -1
- package/dist/ui/AppShell.svelte +24 -0
- package/dist/ui/AppShell.svelte.d.ts +23 -0
- package/dist/ui/AppShell.svelte.d.ts.map +1 -1
- package/dist/ui/BootstrapForm.svelte +17 -0
- package/dist/ui/BootstrapForm.svelte.d.ts +4 -0
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/ColumnLayout.svelte +11 -0
- package/dist/ui/ColumnLayout.svelte.d.ts +10 -0
- package/dist/ui/ColumnLayout.svelte.d.ts.map +1 -1
- package/dist/ui/Datatable.svelte +18 -0
- package/dist/ui/Datatable.svelte.d.ts +17 -0
- package/dist/ui/Datatable.svelte.d.ts.map +1 -1
- package/dist/ui/LoginForm.svelte +18 -0
- package/dist/ui/LoginForm.svelte.d.ts +9 -0
- package/dist/ui/LoginForm.svelte.d.ts.map +1 -1
- package/dist/ui/LogoutButton.svelte +9 -0
- package/dist/ui/LogoutButton.svelte.d.ts +8 -0
- package/dist/ui/LogoutButton.svelte.d.ts.map +1 -1
- package/dist/ui/MenuLink.svelte +10 -0
- package/dist/ui/MenuLink.svelte.d.ts +9 -0
- package/dist/ui/MenuLink.svelte.d.ts.map +1 -1
- package/dist/ui/OpenSignupToggle.svelte +9 -0
- package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
- package/dist/ui/SignupForm.svelte +16 -0
- package/dist/ui/SignupForm.svelte.d.ts +4 -0
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- package/dist/ui/SurfaceExplorer.svelte +9 -0
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +2 -2
- package/dist/ui/account_sessions_state.svelte.js +1 -1
- package/dist/ui/admin_rpc_adapters.d.ts +1 -1
- package/dist/ui/admin_rpc_adapters.js +1 -1
- package/dist/ui/audit_log_state.svelte.d.ts +6 -1
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +6 -1
- package/dist/ui/auth_state.svelte.d.ts +16 -4
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +16 -4
- package/dist/ui/form_state.svelte.d.ts +9 -0
- package/dist/ui/form_state.svelte.d.ts.map +1 -1
- package/dist/ui/form_state.svelte.js +9 -0
- package/dist/ui/loadable.svelte.d.ts +6 -1
- package/dist/ui/loadable.svelte.d.ts.map +1 -1
- package/dist/ui/loadable.svelte.js +6 -1
- package/dist/ui/permit_offers_state.svelte.d.ts +2 -0
- package/dist/ui/permit_offers_state.svelte.d.ts.map +1 -1
- package/dist/ui/permit_offers_state.svelte.js +2 -0
- package/dist/ui/popover.svelte.d.ts +17 -4
- package/dist/ui/popover.svelte.d.ts.map +1 -1
- package/dist/ui/popover.svelte.js +17 -4
- package/dist/ui/position_helpers.d.ts +1 -0
- package/dist/ui/position_helpers.d.ts.map +1 -1
- package/dist/ui/position_helpers.js +1 -0
- package/dist/ui/sidebar_state.svelte.d.ts +22 -9
- package/dist/ui/sidebar_state.svelte.d.ts.map +1 -1
- package/dist/ui/sidebar_state.svelte.js +17 -2
- package/dist/ui/table_state.svelte.d.ts +14 -0
- package/dist/ui/table_state.svelte.d.ts.map +1 -1
- package/dist/ui/table_state.svelte.js +14 -0
- package/package.json +1 -1
package/dist/actions/CLAUDE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# actions/ — SAES (Symmetric Action Event System)
|
|
2
2
|
|
|
3
|
-
One declarative `ActionSpec` shape — `{method, kind, initiator, auth, side_effects, input, output, async, description}` — binds to three
|
|
3
|
+
One declarative `ActionSpec` shape — `{method, kind, initiator, auth, side_effects, input, output, async, description, streams?, error_reasons?}` — binds to three
|
|
4
4
|
transport surfaces (REST, JSON-RPC, WebSocket) with uniform DEV-only output
|
|
5
5
|
validation and symmetric send/receive. This directory holds the spec types,
|
|
6
6
|
registry, codegen helpers, both transport bridges, the single-endpoint RPC
|
|
@@ -47,6 +47,19 @@ Optional `streams?: string` names a companion `remote_notification` method
|
|
|
47
47
|
emitted as request-scoped progress. Transport-agnostic handshake —
|
|
48
48
|
registry-time validation that the named method exists is a consumer concern.
|
|
49
49
|
|
|
50
|
+
Optional `error_reasons?: ReadonlyArray<string>` declares the reason codes a
|
|
51
|
+
handler may surface via `error.data.reason`. Same precedent as `streams`:
|
|
52
|
+
declarative metadata for consumers (codegen, UI form-state matching, docs)
|
|
53
|
+
to read off the spec instead of scanning handler code. No runtime
|
|
54
|
+
enforcement — drift between declared reasons and what handlers actually
|
|
55
|
+
throw is caught per-module by source-scanning unit tests (see
|
|
56
|
+
`../../test/auth/permit_offer_actions.error_reasons.test.ts`). Reuses
|
|
57
|
+
the same `as const` string constants the handler throws (e.g.
|
|
58
|
+
`ERROR_OFFER_*` from `../auth/permit_offer_action_specs.ts`,
|
|
59
|
+
`ERROR_PERMIT_NOT_FOUND` from `../http/error_schemas.ts`) so call
|
|
60
|
+
sites can import either side. Standard transport errors (validation,
|
|
61
|
+
auth, rate-limit) stay implicit.
|
|
62
|
+
|
|
50
63
|
Canonical spec shape: module-scope declaration with `satisfies` +
|
|
51
64
|
`{method}_action_spec` naming, preserving the literal `method` type and
|
|
52
65
|
dropping per-spec `*_METHOD` constants (readers dereference `.method` at
|
|
@@ -116,8 +129,8 @@ not the runtime):
|
|
|
116
129
|
- `ImportBuilder` — tracks value / type / namespace imports; emits `import type` when every entry on a module is a type (tree-shaking). Namespace (`* as specs`) entries are emitted verbatim. Public surface: `add`, `add_type`, `add_many`, `add_types`, `build`, `preview`, `has_imports`, `import_count`, `clear`.
|
|
117
130
|
- `get_executor_phases(spec, executor)` — phases a given executor (`'frontend' | 'backend'`) participates in for the spec. Deduplicates via `Set` (handles `initiator: 'both'` overlap).
|
|
118
131
|
- `get_handler_return_type(spec, phase, imports, collections_path?)` — the TS type a phase handler must return; triggers the `ActionOutputs` import (sourced from `collections_path`, default `'./action_collections.js'`) as a side effect.
|
|
119
|
-
- `generate_phase_handlers(spec, executor, imports, {action_event_type?, collections_path?})` — emits the typed handler-map fragment for one action; consumers compose these into `ActionHandlers` types.
|
|
120
|
-
- `generate_actions_api_method_signature(spec, {sync_returns_value?})` — single source of truth for the typed `FrontendActionsApi` method shape. Threads `options?: RpcClientCallOptions` (`{signal?, transport_name?, queue?}`) onto every async method — `request_response`, `remote_notification`, and async `local_call` — and wraps the return in `Promise<Result<...>>`.
|
|
132
|
+
- `generate_phase_handlers(spec, executor, imports, {action_event_type?, collections_path?})` — emits the typed handler-map fragment for one action; consumers compose these into `ActionHandlers` types. Returns `''` when the spec contributes no phases on the given executor (e.g. a backend-only `local_call` asked for `'frontend'`) so wrappers' `.filter(Boolean)` drops the row entirely instead of emitting a useless `${method}?: never` for a method that doesn't belong on this side.
|
|
133
|
+
- `generate_actions_api_method_signature(spec, imports, {sync_returns_value?, collections_path?})` — single source of truth for the typed `FrontendActionsApi` method shape. Threads `options?: RpcClientCallOptions` (`{signal?, transport_name?, queue?}`) onto every async method — `request_response`, `remote_notification`, and async `local_call` — and wraps the return in `Promise<Result<...>>`. Registers exactly the imports the emitted line references on `imports` — `ActionInputs` only when the spec has input, `RpcClientCallOptions` only when async, `Result` / `JsonrpcErrorObject` only when the return wraps in `Result`. Mirrors the leaf-level pattern `get_handler_return_type` already follows so wrappers no longer pre-register imports a per-spec emit might not actually use.
|
|
121
134
|
- `create_banner(origin_path)` — gen banner comment.
|
|
122
135
|
- `to_action_spec_identifier(method)` / `to_action_spec_input_identifier` / `to_action_spec_output_identifier` — naming convention helpers (emit `foo_action_spec` / `foo_action_spec.input` / `foo_action_spec.output`).
|
|
123
136
|
- `PROTOCOL_ACTION_METHODS` (+ `ProtocolActionMethod` type) — readonly tuple `['heartbeat', 'cancel']`. Pairs with `protocol_actions` / `protocol_action_specs` in `actions/protocol.ts` (the runtime bundles). Consumers spread when filtering backend `request_response` methods so dispatcher-owned protocol actions don't leak into `BackendRequestResponseMethod` / handler maps.
|
|
@@ -49,7 +49,8 @@ export declare const derive_http_method: (side_effects: ActionSideEffects) => Ro
|
|
|
49
49
|
* @param spec - the action spec (must have non-null `auth`)
|
|
50
50
|
* @param options - HTTP-specific options (path, handler, optional overrides)
|
|
51
51
|
* @returns a `RouteSpec` ready for `apply_route_specs`
|
|
52
|
-
* @throws if `spec.auth` is null
|
|
52
|
+
* @throws Error if `spec.auth` is null (only `request_response` actions can
|
|
53
|
+
* become routes; notifications and local calls cannot)
|
|
53
54
|
*/
|
|
54
55
|
export declare const create_action_route_spec: (spec: ActionSpec, options: ActionRouteOptions) => RouteSpec;
|
|
55
56
|
/**
|
|
@@ -60,6 +61,7 @@ export declare const create_action_route_spec: (spec: ActionSpec, options: Actio
|
|
|
60
61
|
* @param spec - the action spec (must have `kind: 'remote_notification'`)
|
|
61
62
|
* @param options - optional event-specific options (channel)
|
|
62
63
|
* @returns an `EventSpec` ready for `create_validated_broadcaster`
|
|
64
|
+
* @throws Error if `spec.kind` is not `'remote_notification'`
|
|
63
65
|
*/
|
|
64
66
|
export declare const create_action_event_spec: (spec: ActionSpec, options?: ActionEventOptions) => EventSpec;
|
|
65
67
|
//# sourceMappingURL=action_bridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_bridge.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAC,UAAU,EAAE,UAAU,IAAI,cAAc,EAAE,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAClG,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAC3F,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAEhE,+DAA+D;AAC/D,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;IACtB,uGAAuG;IACvG,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;IACrB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;IACpB,mFAAmF;IACnF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,+IAA+I;IAC/I,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,8GAA8G;IAC9G,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC3B;AAED,gEAAgE;AAChE,MAAM,WAAW,kBAAkB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,kDAAkD;AAClD,eAAO,MAAM,eAAe,GAAI,MAAM,cAAc,KAAG,SAKtD,CAAC;AAEF,wDAAwD;AAC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B,GACpC,MAAM,UAAU,EAChB,SAAS,kBAAkB,KACzB,SAmBF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GACpC,MAAM,UAAU,EAChB,UAAU,kBAAkB,KAC1B,SAYF,CAAC"}
|
|
@@ -35,7 +35,8 @@ export const derive_http_method = (side_effects) => {
|
|
|
35
35
|
* @param spec - the action spec (must have non-null `auth`)
|
|
36
36
|
* @param options - HTTP-specific options (path, handler, optional overrides)
|
|
37
37
|
* @returns a `RouteSpec` ready for `apply_route_specs`
|
|
38
|
-
* @throws if `spec.auth` is null
|
|
38
|
+
* @throws Error if `spec.auth` is null (only `request_response` actions can
|
|
39
|
+
* become routes; notifications and local calls cannot)
|
|
39
40
|
*/
|
|
40
41
|
export const create_action_route_spec = (spec, options) => {
|
|
41
42
|
if (spec.auth === null) {
|
|
@@ -63,6 +64,7 @@ export const create_action_route_spec = (spec, options) => {
|
|
|
63
64
|
* @param spec - the action spec (must have `kind: 'remote_notification'`)
|
|
64
65
|
* @param options - optional event-specific options (channel)
|
|
65
66
|
* @returns an `EventSpec` ready for `create_validated_broadcaster`
|
|
67
|
+
* @throws Error if `spec.kind` is not `'remote_notification'`
|
|
66
68
|
*/
|
|
67
69
|
export const create_action_event_spec = (spec, options) => {
|
|
68
70
|
if (spec.kind !== 'remote_notification') {
|
|
@@ -59,12 +59,17 @@ export declare class ImportBuilder {
|
|
|
59
59
|
* Add a value import to be included in the generated code.
|
|
60
60
|
* @param from - the module to import from
|
|
61
61
|
* @param what - what to import (value)
|
|
62
|
+
* @returns `this` for chaining
|
|
63
|
+
* @mutates this - inserts into the internal `imports` map
|
|
62
64
|
*/
|
|
63
65
|
add(from: string, what: string): this;
|
|
64
66
|
/**
|
|
65
67
|
* Add a type import to be included in the generated code.
|
|
66
68
|
* @param from - the module to import from
|
|
67
69
|
* @param what - what to import (type)
|
|
70
|
+
* @returns `this` for chaining
|
|
71
|
+
* @mutates this - inserts into the internal `imports` map (downgrade to
|
|
72
|
+
* type is suppressed if already registered as a value)
|
|
68
73
|
*/
|
|
69
74
|
add_type(from: string, what: string): this;
|
|
70
75
|
/**
|
|
@@ -95,6 +100,9 @@ export declare class ImportBuilder {
|
|
|
95
100
|
preview(): Array<string>;
|
|
96
101
|
/**
|
|
97
102
|
* Clear all imports.
|
|
103
|
+
*
|
|
104
|
+
* @returns `this` for chaining
|
|
105
|
+
* @mutates this - empties the internal `imports` map
|
|
98
106
|
*/
|
|
99
107
|
clear(): this;
|
|
100
108
|
}
|
|
@@ -118,9 +126,18 @@ export declare const get_handler_return_type: (spec: ActionSpecUnion, phase: Act
|
|
|
118
126
|
* Generates the phase handlers for an action spec using the unified ActionEvent type
|
|
119
127
|
* with the new phase/step type parameters.
|
|
120
128
|
*
|
|
129
|
+
* Returns `''` when the spec contributes no phases on the given executor side
|
|
130
|
+
* (e.g. a backend-only `local_call` asked for `'frontend'`). Upstream wrappers
|
|
131
|
+
* compose blocks with `.filter(Boolean)` so empty entries are dropped from the
|
|
132
|
+
* generated handler map. The earlier shape was `${method}?: never`, which read
|
|
133
|
+
* as "calling this here is a type error" but in practice produced useless rows
|
|
134
|
+
* on `FrontendActionHandlers` for methods that don't belong on this side at
|
|
135
|
+
* all — drop the row instead so the typed surface only carries methods the
|
|
136
|
+
* executor actually handles.
|
|
137
|
+
*
|
|
121
138
|
* @param options.action_event_type - custom type name to use instead of `ActionEvent`
|
|
122
139
|
* (consumers can define a narrowed type that carries typed input/output via their codegen maps)
|
|
123
|
-
* @param options.collections_path -
|
|
140
|
+
* @param options.collections_path - Import path the side-effect `ActionOutputs` import
|
|
124
141
|
* resolves to. Defaults to `'./action_collections.js'`.
|
|
125
142
|
*/
|
|
126
143
|
export declare const generate_phase_handlers: (spec: ActionSpecUnion, executor: "frontend" | "backend", imports: ImportBuilder, options?: {
|
|
@@ -151,19 +168,28 @@ export declare const to_action_spec_output_identifier: (method: string) => strin
|
|
|
151
168
|
* failure). Earlier emit shapes declared notifications as `=> void` —
|
|
152
169
|
* regenerate consumer typed clients to pick up the corrected return.
|
|
153
170
|
*
|
|
154
|
-
*
|
|
155
|
-
* `
|
|
156
|
-
*
|
|
171
|
+
* Registers exactly the imports the emitted line references on `imports`:
|
|
172
|
+
* `ActionInputs` (when the spec has input), `ActionOutputs` (always),
|
|
173
|
+
* `RpcClientCallOptions` (async only), and `Result` + `JsonrpcErrorObject`
|
|
174
|
+
* (any return shape that wraps the value in `Result<{value}, {error}>` —
|
|
175
|
+
* every async method, plus sync `local_call` when `sync_returns_value:
|
|
176
|
+
* false`). Mirrors the leaf-level pattern `get_handler_return_type` already
|
|
177
|
+
* follows so wrappers no longer pre-register imports a per-spec emit might
|
|
178
|
+
* not actually use.
|
|
157
179
|
*
|
|
158
180
|
* @param spec - the action spec to emit
|
|
159
|
-
* @param
|
|
181
|
+
* @param imports - import builder to register references on
|
|
182
|
+
* @param options.sync_returns_value - When true (default), sync `local_call`
|
|
160
183
|
* methods return the output value directly; when false they're wrapped in
|
|
161
184
|
* `Result<{value, error}>` like async methods. Set to `false` if your
|
|
162
|
-
* FrontendActionsApi treats every method uniformly.
|
|
185
|
+
* `FrontendActionsApi` treats every method uniformly.
|
|
186
|
+
* @param options.collections_path - Import path that `ActionInputs` /
|
|
187
|
+
* `ActionOutputs` resolve to. Defaults to `'./action_collections.js'`.
|
|
163
188
|
* @returns one line like `foo: (input: ActionInputs['foo'], options?: RpcClientCallOptions) => Promise<Result<...>>;`
|
|
164
189
|
*/
|
|
165
|
-
export declare const generate_actions_api_method_signature: (spec: ActionSpecUnion, options?: {
|
|
190
|
+
export declare const generate_actions_api_method_signature: (spec: ActionSpecUnion, imports: ImportBuilder, options?: {
|
|
166
191
|
sync_returns_value?: boolean;
|
|
192
|
+
collections_path?: string;
|
|
167
193
|
}) => string;
|
|
168
194
|
/** Discriminator for `generate_action_method_enums` — which method-set enums to emit. */
|
|
169
195
|
export type ActionMethodEnumKind = 'all' | 'request_response' | 'remote_notification' | 'local_call' | 'frontend' | 'backend' | 'frontend_handled' | 'backend_handled' | 'broadcast';
|
|
@@ -300,8 +326,11 @@ export declare const generate_action_event_datas: (specs: ReadonlyArray<ActionSp
|
|
|
300
326
|
* (e.g. omit additional methods alongside the default protocol-action
|
|
301
327
|
* filter) via `method_filter`.
|
|
302
328
|
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
329
|
+
* Imports are registered by the leaf `generate_actions_api_method_signature`
|
|
330
|
+
* per emitted line — only what the spec set actually references shows up on
|
|
331
|
+
* `imports`. A spec set with no async methods skips `RpcClientCallOptions`;
|
|
332
|
+
* one with no inputs skips `ActionInputs`; sync `local_call` methods with
|
|
333
|
+
* `sync_returns_value: true` (the default) skip `Result` / `JsonrpcErrorObject`.
|
|
305
334
|
*
|
|
306
335
|
* The interface name is fixed at `FrontendActionsApi` — the symmetric counterpart
|
|
307
336
|
* of `BackendActionsApi`. Earlier consumer-named variants (`MyActionsApi`,
|
|
@@ -347,7 +376,7 @@ export declare const generate_frontend_action_handlers: (specs: ReadonlyArray<Ac
|
|
|
347
376
|
* Method signature shape today is `(input) => Promise<void>` — matches the
|
|
348
377
|
* fire-and-forget runtime of `create_broadcast_api`. Generalizing per-kind
|
|
349
378
|
* via `generate_actions_api_method_signature` is deferred until a second
|
|
350
|
-
* backend runtime constructor lands
|
|
379
|
+
* backend runtime constructor lands.
|
|
351
380
|
*
|
|
352
381
|
* @param options.qualify_spec - per-spec qualified identifier callback for
|
|
353
382
|
* multi-source consumers. When set, the helper emits the callback's return
|
|
@@ -413,6 +442,11 @@ export interface SpecSource {
|
|
|
413
442
|
* per-call callback wasn't enough; the import dance + dup-check was the
|
|
414
443
|
* real boilerplate.
|
|
415
444
|
*
|
|
445
|
+
* @throws Error if two sources contain the same method name (same-method
|
|
446
|
+
* detection is the consumer's primary debugging signal). Also throws if
|
|
447
|
+
* the returned `qualify_spec` is later called with a method not registered
|
|
448
|
+
* in any source.
|
|
449
|
+
*
|
|
416
450
|
* @example
|
|
417
451
|
* ```ts
|
|
418
452
|
* const sources = [
|
|
@@ -433,9 +467,6 @@ export interface SpecSource {
|
|
|
433
467
|
* });
|
|
434
468
|
* };
|
|
435
469
|
* ```
|
|
436
|
-
*
|
|
437
|
-
* @throws if two sources contain the same method name (same-method detection
|
|
438
|
-
* is the consumer's primary debugging signal).
|
|
439
470
|
*/
|
|
440
471
|
export declare const create_namespace_qualifier: (sources: ReadonlyArray<SpecSource>, imports: ImportBuilder) => {
|
|
441
472
|
qualify_spec: (spec: ActionSpecUnion) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_codegen.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_codegen.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAGxE;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,kCAAmC,CAAC;AAExE,8FAA8F;AAC9F,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAI5E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,KAAG,MAAM,IAAI,oBACrC,CAAC;AAEjC;;GAEG;AACH,UAAU,UAAU;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,aAAa;;IACzB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAa;IAE1D
|
|
1
|
+
{"version":3,"file":"action_codegen.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_codegen.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAGxE;;;;;;;GAOG;AACH,eAAO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ACjD,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACnC,KACC,MAwCF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oCAAoC,GAChD,SAAS,aAAa,EACtB,UAAU;IACT,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,KACC,MAqBF,CAAC;AAMF;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,0BAA0B,GACtC,SAAS,aAAa,CAAC,UAAU,CAAC,EAClC,SAAS,aAAa,KACpB;IACF,YAAY,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,MAAM,CAAC;IAChD,SAAS,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CA6B1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC9B,KAAG,MAYH,CAAC"}
|
|
@@ -52,6 +52,8 @@ export class ImportBuilder {
|
|
|
52
52
|
* Add a value import to be included in the generated code.
|
|
53
53
|
* @param from - the module to import from
|
|
54
54
|
* @param what - what to import (value)
|
|
55
|
+
* @returns `this` for chaining
|
|
56
|
+
* @mutates this - inserts into the internal `imports` map
|
|
55
57
|
*/
|
|
56
58
|
add(from, what) {
|
|
57
59
|
// Handle namespace imports specially
|
|
@@ -64,6 +66,9 @@ export class ImportBuilder {
|
|
|
64
66
|
* Add a type import to be included in the generated code.
|
|
65
67
|
* @param from - the module to import from
|
|
66
68
|
* @param what - what to import (type)
|
|
69
|
+
* @returns `this` for chaining
|
|
70
|
+
* @mutates this - inserts into the internal `imports` map (downgrade to
|
|
71
|
+
* type is suppressed if already registered as a value)
|
|
67
72
|
*/
|
|
68
73
|
add_type(from, what) {
|
|
69
74
|
return this.#add_import(from, what, 'type');
|
|
@@ -134,6 +139,9 @@ export class ImportBuilder {
|
|
|
134
139
|
}
|
|
135
140
|
/**
|
|
136
141
|
* Clear all imports.
|
|
142
|
+
*
|
|
143
|
+
* @returns `this` for chaining
|
|
144
|
+
* @mutates this - empties the internal `imports` map
|
|
137
145
|
*/
|
|
138
146
|
clear() {
|
|
139
147
|
this.imports.clear();
|
|
@@ -278,16 +286,25 @@ export const get_handler_return_type = (spec, phase, imports, collections_path =
|
|
|
278
286
|
* Generates the phase handlers for an action spec using the unified ActionEvent type
|
|
279
287
|
* with the new phase/step type parameters.
|
|
280
288
|
*
|
|
289
|
+
* Returns `''` when the spec contributes no phases on the given executor side
|
|
290
|
+
* (e.g. a backend-only `local_call` asked for `'frontend'`). Upstream wrappers
|
|
291
|
+
* compose blocks with `.filter(Boolean)` so empty entries are dropped from the
|
|
292
|
+
* generated handler map. The earlier shape was `${method}?: never`, which read
|
|
293
|
+
* as "calling this here is a type error" but in practice produced useless rows
|
|
294
|
+
* on `FrontendActionHandlers` for methods that don't belong on this side at
|
|
295
|
+
* all — drop the row instead so the typed surface only carries methods the
|
|
296
|
+
* executor actually handles.
|
|
297
|
+
*
|
|
281
298
|
* @param options.action_event_type - custom type name to use instead of `ActionEvent`
|
|
282
299
|
* (consumers can define a narrowed type that carries typed input/output via their codegen maps)
|
|
283
|
-
* @param options.collections_path -
|
|
300
|
+
* @param options.collections_path - Import path the side-effect `ActionOutputs` import
|
|
284
301
|
* resolves to. Defaults to `'./action_collections.js'`.
|
|
285
302
|
*/
|
|
286
303
|
export const generate_phase_handlers = (spec, executor, imports, options) => {
|
|
287
304
|
const { method } = spec;
|
|
288
305
|
const phases = get_executor_phases(spec, executor);
|
|
289
306
|
if (phases.length === 0) {
|
|
290
|
-
return
|
|
307
|
+
return '';
|
|
291
308
|
}
|
|
292
309
|
const action_event_type = options?.action_event_type ?? 'ActionEvent';
|
|
293
310
|
const collections_path = options?.collections_path ?? DEFAULT_COLLECTIONS_PATH;
|
|
@@ -331,32 +348,52 @@ export const to_action_spec_output_identifier = (method) => `${to_action_spec_id
|
|
|
331
348
|
* failure). Earlier emit shapes declared notifications as `=> void` —
|
|
332
349
|
* regenerate consumer typed clients to pick up the corrected return.
|
|
333
350
|
*
|
|
334
|
-
*
|
|
335
|
-
* `
|
|
336
|
-
*
|
|
351
|
+
* Registers exactly the imports the emitted line references on `imports`:
|
|
352
|
+
* `ActionInputs` (when the spec has input), `ActionOutputs` (always),
|
|
353
|
+
* `RpcClientCallOptions` (async only), and `Result` + `JsonrpcErrorObject`
|
|
354
|
+
* (any return shape that wraps the value in `Result<{value}, {error}>` —
|
|
355
|
+
* every async method, plus sync `local_call` when `sync_returns_value:
|
|
356
|
+
* false`). Mirrors the leaf-level pattern `get_handler_return_type` already
|
|
357
|
+
* follows so wrappers no longer pre-register imports a per-spec emit might
|
|
358
|
+
* not actually use.
|
|
337
359
|
*
|
|
338
360
|
* @param spec - the action spec to emit
|
|
339
|
-
* @param
|
|
361
|
+
* @param imports - import builder to register references on
|
|
362
|
+
* @param options.sync_returns_value - When true (default), sync `local_call`
|
|
340
363
|
* methods return the output value directly; when false they're wrapped in
|
|
341
364
|
* `Result<{value, error}>` like async methods. Set to `false` if your
|
|
342
|
-
* FrontendActionsApi treats every method uniformly.
|
|
365
|
+
* `FrontendActionsApi` treats every method uniformly.
|
|
366
|
+
* @param options.collections_path - Import path that `ActionInputs` /
|
|
367
|
+
* `ActionOutputs` resolve to. Defaults to `'./action_collections.js'`.
|
|
343
368
|
* @returns one line like `foo: (input: ActionInputs['foo'], options?: RpcClientCallOptions) => Promise<Result<...>>;`
|
|
344
369
|
*/
|
|
345
|
-
export const generate_actions_api_method_signature = (spec, options) => {
|
|
370
|
+
export const generate_actions_api_method_signature = (spec, imports, options) => {
|
|
346
371
|
const sync_returns_value = options?.sync_returns_value ?? true;
|
|
372
|
+
const collections_path = options?.collections_path ?? DEFAULT_COLLECTIONS_PATH;
|
|
347
373
|
const innermost_type_name = zod_get_base_type(spec.input);
|
|
348
374
|
const has_input = innermost_type_name !== 'null' && innermost_type_name !== 'void';
|
|
349
375
|
const input_param = has_input
|
|
350
376
|
? `input${spec.input.safeParse(undefined).success ? '?' : ''}: ActionInputs['${spec.method}']`
|
|
351
377
|
: 'input?: void';
|
|
378
|
+
if (has_input)
|
|
379
|
+
imports.add_type(collections_path, 'ActionInputs');
|
|
380
|
+
imports.add_type(collections_path, 'ActionOutputs');
|
|
352
381
|
const is_async = spec.kind === 'request_response' || spec.kind === 'remote_notification' || spec.async;
|
|
353
382
|
const options_param = is_async ? ', options?: RpcClientCallOptions' : '';
|
|
383
|
+
if (is_async) {
|
|
384
|
+
imports.add_type('@fuzdev/fuz_app/actions/rpc_client.js', 'RpcClientCallOptions');
|
|
385
|
+
}
|
|
354
386
|
const result_return = `Result<{value: ActionOutputs['${spec.method}']}, {error: JsonrpcErrorObject}>`;
|
|
355
387
|
const return_type = is_async
|
|
356
388
|
? `Promise<${result_return}>`
|
|
357
389
|
: sync_returns_value
|
|
358
390
|
? `ActionOutputs['${spec.method}']`
|
|
359
391
|
: result_return;
|
|
392
|
+
const wraps_in_result = is_async || !sync_returns_value;
|
|
393
|
+
if (wraps_in_result) {
|
|
394
|
+
imports.add_type('@fuzdev/fuz_util/result.js', 'Result');
|
|
395
|
+
imports.add_type('@fuzdev/fuz_app/http/jsonrpc.js', 'JsonrpcErrorObject');
|
|
396
|
+
}
|
|
360
397
|
return `${spec.method}: (${input_param}${options_param}) => ${return_type};`;
|
|
361
398
|
};
|
|
362
399
|
// --------------------------------------------------------------------------
|
|
@@ -711,8 +748,11 @@ ${lines.join('\n')}
|
|
|
711
748
|
* (e.g. omit additional methods alongside the default protocol-action
|
|
712
749
|
* filter) via `method_filter`.
|
|
713
750
|
*
|
|
714
|
-
*
|
|
715
|
-
*
|
|
751
|
+
* Imports are registered by the leaf `generate_actions_api_method_signature`
|
|
752
|
+
* per emitted line — only what the spec set actually references shows up on
|
|
753
|
+
* `imports`. A spec set with no async methods skips `RpcClientCallOptions`;
|
|
754
|
+
* one with no inputs skips `ActionInputs`; sync `local_call` methods with
|
|
755
|
+
* `sync_returns_value: true` (the default) skip `Result` / `JsonrpcErrorObject`.
|
|
716
756
|
*
|
|
717
757
|
* The interface name is fixed at `FrontendActionsApi` — the symmetric counterpart
|
|
718
758
|
* of `BackendActionsApi`. Earlier consumer-named variants (`MyActionsApi`,
|
|
@@ -738,14 +778,10 @@ export const generate_frontend_actions_api = (specs, imports, options) => {
|
|
|
738
778
|
return `${interface_doc}
|
|
739
779
|
export interface FrontendActionsApi {}`;
|
|
740
780
|
}
|
|
741
|
-
const collections_path = options?.collections_path ?? DEFAULT_COLLECTIONS_PATH;
|
|
742
|
-
imports.add_type('@fuzdev/fuz_util/result.js', 'Result');
|
|
743
|
-
imports.add_type('@fuzdev/fuz_app/http/jsonrpc.js', 'JsonrpcErrorObject');
|
|
744
|
-
imports.add_type('@fuzdev/fuz_app/actions/rpc_client.js', 'RpcClientCallOptions');
|
|
745
|
-
imports.add_types(collections_path, 'ActionInputs', 'ActionOutputs');
|
|
746
781
|
const lines = filtered
|
|
747
|
-
.map((spec) => generate_actions_api_method_signature(spec, {
|
|
782
|
+
.map((spec) => generate_actions_api_method_signature(spec, imports, {
|
|
748
783
|
sync_returns_value: options?.sync_returns_value,
|
|
784
|
+
collections_path: options?.collections_path,
|
|
749
785
|
}))
|
|
750
786
|
.map((line) => `\t${line}`)
|
|
751
787
|
.join('\n');
|
|
@@ -811,7 +847,7 @@ ${lines};
|
|
|
811
847
|
* Method signature shape today is `(input) => Promise<void>` — matches the
|
|
812
848
|
* fire-and-forget runtime of `create_broadcast_api`. Generalizing per-kind
|
|
813
849
|
* via `generate_actions_api_method_signature` is deferred until a second
|
|
814
|
-
* backend runtime constructor lands
|
|
850
|
+
* backend runtime constructor lands.
|
|
815
851
|
*
|
|
816
852
|
* @param options.qualify_spec - per-spec qualified identifier callback for
|
|
817
853
|
* multi-source consumers. When set, the helper emits the callback's return
|
|
@@ -908,6 +944,11 @@ export type ${type_name} = {
|
|
|
908
944
|
* per-call callback wasn't enough; the import dance + dup-check was the
|
|
909
945
|
* real boilerplate.
|
|
910
946
|
*
|
|
947
|
+
* @throws Error if two sources contain the same method name (same-method
|
|
948
|
+
* detection is the consumer's primary debugging signal). Also throws if
|
|
949
|
+
* the returned `qualify_spec` is later called with a method not registered
|
|
950
|
+
* in any source.
|
|
951
|
+
*
|
|
911
952
|
* @example
|
|
912
953
|
* ```ts
|
|
913
954
|
* const sources = [
|
|
@@ -928,9 +969,6 @@ export type ${type_name} = {
|
|
|
928
969
|
* });
|
|
929
970
|
* };
|
|
930
971
|
* ```
|
|
931
|
-
*
|
|
932
|
-
* @throws if two sources contain the same method name (same-method detection
|
|
933
|
-
* is the consumer's primary debugging signal).
|
|
934
972
|
*/
|
|
935
973
|
export const create_namespace_qualifier = (sources, imports) => {
|
|
936
974
|
const method_to_ns = new Map();
|
|
@@ -33,22 +33,60 @@ export declare class ActionEvent<TMethod extends string = string, TPhase extends
|
|
|
33
33
|
};
|
|
34
34
|
constructor(environment: ActionEventEnvironment, spec: ActionSpecUnion, data: ActionEventDataUnion<TMethod>);
|
|
35
35
|
toJSON(): ActionEventDataUnion<TMethod>;
|
|
36
|
+
/**
|
|
37
|
+
* Subscribe a listener fired on every `data` transition.
|
|
38
|
+
*
|
|
39
|
+
* @param listener - called with `(new_data, old_data, event)` after each mutation
|
|
40
|
+
* @returns unsubscribe function
|
|
41
|
+
* @mutates this - adds `listener` to the internal observer set
|
|
42
|
+
*/
|
|
36
43
|
observe(listener: ActionEventChangeObserver<TMethod>): () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Replace the event's `data` and notify observers.
|
|
46
|
+
*
|
|
47
|
+
* @mutates this - sets `data` and fires every registered observer in insertion order
|
|
48
|
+
*/
|
|
37
49
|
set_data(new_data: ActionEventDataUnion<TMethod>): void;
|
|
38
50
|
/**
|
|
39
51
|
* Parse input data according to the action's schema.
|
|
52
|
+
*
|
|
53
|
+
* @returns `this` for chaining with `handle_async` / `handle_sync`
|
|
54
|
+
* @mutates this - transitions step from `initial` to `parsed` (or to
|
|
55
|
+
* `failed` / `receive_error` on validation or response error)
|
|
56
|
+
* @throws Error if called from a step other than `initial`
|
|
40
57
|
*/
|
|
41
58
|
parse(): this;
|
|
42
59
|
/**
|
|
43
60
|
* Execute the handler for the current phase.
|
|
61
|
+
*
|
|
62
|
+
* @mutates this - transitions step `parsed → handling → handled`, or to
|
|
63
|
+
* `failed` / `send_error` / `receive_error` on handler throw. No-op
|
|
64
|
+
* when already `failed`.
|
|
65
|
+
* @throws Error if called from a step other than `parsed` (or `failed`,
|
|
66
|
+
* which no-ops). Handler-thrown `ThrownJsonrpcError` is caught and
|
|
67
|
+
* routed through error phases; other throws are wrapped as
|
|
68
|
+
* `internal_error`.
|
|
44
69
|
*/
|
|
45
70
|
handle_async(): Promise<void>;
|
|
46
71
|
/**
|
|
47
|
-
* Execute handler synchronously (only for sync local_call actions).
|
|
72
|
+
* Execute handler synchronously (only for sync `local_call` actions).
|
|
73
|
+
*
|
|
74
|
+
* @mutates this - transitions step `parsed → handling → handled`, or to
|
|
75
|
+
* `failed` on handler throw. No-op when already `failed`.
|
|
76
|
+
* @throws Error if the spec is not a sync `local_call`, or if called
|
|
77
|
+
* from a step other than `parsed` (or `failed`, which no-ops).
|
|
48
78
|
*/
|
|
49
79
|
handle_sync(): void;
|
|
50
80
|
/**
|
|
51
81
|
* Transition to a new phase.
|
|
82
|
+
*
|
|
83
|
+
* @param phase - the next phase to transition into
|
|
84
|
+
* @mutates this - replaces `data` with a fresh phase-initial record,
|
|
85
|
+
* carrying forward `request` / `response` / `error` / `output` as
|
|
86
|
+
* appropriate for the kind/phase pair
|
|
87
|
+
* @throws Error if called from a step other than `handled` (or
|
|
88
|
+
* `failed`, which no-ops), or if the phase transition is illegal for
|
|
89
|
+
* the current phase
|
|
52
90
|
*/
|
|
53
91
|
transition(phase: ActionEventPhase): void;
|
|
54
92
|
is_complete(): boolean;
|
|
@@ -59,10 +97,15 @@ export declare class ActionEvent<TMethod extends string = string, TPhase extends
|
|
|
59
97
|
}
|
|
60
98
|
/**
|
|
61
99
|
* Create an action event from a spec and initial input.
|
|
100
|
+
*
|
|
101
|
+
* @throws Error if `initial_phase` is omitted and the executor cannot
|
|
102
|
+
* initiate the action (per `spec.initiator`)
|
|
62
103
|
*/
|
|
63
104
|
export declare const create_action_event: <TMethod extends string = string>(environment: ActionEventEnvironment, spec: ActionSpecUnion, input: unknown, initial_phase?: ActionEventPhase) => ActionEvent<TMethod>;
|
|
64
105
|
/**
|
|
65
106
|
* Reconstruct an action event from serialized JSON data.
|
|
107
|
+
*
|
|
108
|
+
* @throws Error if the JSON's `method` field has no spec registered in `environment`
|
|
66
109
|
*/
|
|
67
110
|
export declare const create_action_event_from_json: <TMethod extends string = string>(json: ActionEventDataUnion<TMethod>, environment: ActionEventEnvironment) => ActionEvent<TMethod>;
|
|
68
111
|
export declare const parse_action_event: (raw_json: unknown, environment: ActionEventEnvironment) => ActionEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_event.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_event.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAC,gBAAgB,EAAc,eAAe,EAAC,MAAM,kBAAkB,CAAC;AAWpF,OAAO,KAAK,EACX,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EAEnB,MAAM,oBAAoB,CAAC;A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OAOG;IACH,KAAK,IAAI,IAAI;IA8Cb;;;;;;;;;;OAUG;IAGG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IA0CnC;;;;;;;OAOG;IACH,WAAW,IAAI,IAAI;IAkCnB;;;;;;;;;;OAUG;IACH,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAezC,WAAW,IAAI,OAAO;IAItB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAIxC,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAQ1C,YAAY,CAAC,QAAQ,EAAE,sBAAsB,GAAG,IAAI;IAUpD,gBAAgB,CAAC,YAAY,EAAE,mBAAmB,GAAG,IAAI;CAyKzD;AAGD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EAClE,aAAa,sBAAsB,EACnC,MAAM,eAAe,EACrB,OAAO,OAAO,EACd,gBAAgB,gBAAgB,KAC9B,WAAW,CAAC,OAAO,CAiBrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EAC5E,MAAM,oBAAoB,CAAC,OAAO,CAAC,EACnC,aAAa,sBAAsB,KACjC,WAAW,CAAC,OAAO,CAOrB,CAAC;AAIF,eAAO,MAAM,kBAAkB,GAC9B,UAAU,OAAO,EACjB,aAAa,sBAAsB,KACjC,WAGF,CAAC"}
|
|
@@ -40,10 +40,22 @@ export class ActionEvent {
|
|
|
40
40
|
}
|
|
41
41
|
// TODO rethink the reactivity of this class, maybe just use `$state` or `$state.raw`?
|
|
42
42
|
// does that have any negative implications when used on the backend?
|
|
43
|
+
/**
|
|
44
|
+
* Subscribe a listener fired on every `data` transition.
|
|
45
|
+
*
|
|
46
|
+
* @param listener - called with `(new_data, old_data, event)` after each mutation
|
|
47
|
+
* @returns unsubscribe function
|
|
48
|
+
* @mutates this - adds `listener` to the internal observer set
|
|
49
|
+
*/
|
|
43
50
|
observe(listener) {
|
|
44
51
|
this.#listeners.add(listener);
|
|
45
52
|
return () => this.#listeners.delete(listener);
|
|
46
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Replace the event's `data` and notify observers.
|
|
56
|
+
*
|
|
57
|
+
* @mutates this - sets `data` and fires every registered observer in insertion order
|
|
58
|
+
*/
|
|
47
59
|
set_data(new_data) {
|
|
48
60
|
const old_data = this.#data;
|
|
49
61
|
this.#data = new_data;
|
|
@@ -54,6 +66,11 @@ export class ActionEvent {
|
|
|
54
66
|
}
|
|
55
67
|
/**
|
|
56
68
|
* Parse input data according to the action's schema.
|
|
69
|
+
*
|
|
70
|
+
* @returns `this` for chaining with `handle_async` / `handle_sync`
|
|
71
|
+
* @mutates this - transitions step from `initial` to `parsed` (or to
|
|
72
|
+
* `failed` / `receive_error` on validation or response error)
|
|
73
|
+
* @throws Error if called from a step other than `initial`
|
|
57
74
|
*/
|
|
58
75
|
parse() {
|
|
59
76
|
if (this.#data.step !== 'initial') {
|
|
@@ -93,6 +110,14 @@ export class ActionEvent {
|
|
|
93
110
|
}
|
|
94
111
|
/**
|
|
95
112
|
* Execute the handler for the current phase.
|
|
113
|
+
*
|
|
114
|
+
* @mutates this - transitions step `parsed → handling → handled`, or to
|
|
115
|
+
* `failed` / `send_error` / `receive_error` on handler throw. No-op
|
|
116
|
+
* when already `failed`.
|
|
117
|
+
* @throws Error if called from a step other than `parsed` (or `failed`,
|
|
118
|
+
* which no-ops). Handler-thrown `ThrownJsonrpcError` is caught and
|
|
119
|
+
* routed through error phases; other throws are wrapped as
|
|
120
|
+
* `internal_error`.
|
|
96
121
|
*/
|
|
97
122
|
// TODO add timeout support
|
|
98
123
|
// TODO add cancellation support
|
|
@@ -136,7 +161,12 @@ export class ActionEvent {
|
|
|
136
161
|
}
|
|
137
162
|
}
|
|
138
163
|
/**
|
|
139
|
-
* Execute handler synchronously (only for sync local_call actions).
|
|
164
|
+
* Execute handler synchronously (only for sync `local_call` actions).
|
|
165
|
+
*
|
|
166
|
+
* @mutates this - transitions step `parsed → handling → handled`, or to
|
|
167
|
+
* `failed` on handler throw. No-op when already `failed`.
|
|
168
|
+
* @throws Error if the spec is not a sync `local_call`, or if called
|
|
169
|
+
* from a step other than `parsed` (or `failed`, which no-ops).
|
|
140
170
|
*/
|
|
141
171
|
handle_sync() {
|
|
142
172
|
if (this.spec.kind !== 'local_call' || this.spec.async) {
|
|
@@ -168,6 +198,14 @@ export class ActionEvent {
|
|
|
168
198
|
}
|
|
169
199
|
/**
|
|
170
200
|
* Transition to a new phase.
|
|
201
|
+
*
|
|
202
|
+
* @param phase - the next phase to transition into
|
|
203
|
+
* @mutates this - replaces `data` with a fresh phase-initial record,
|
|
204
|
+
* carrying forward `request` / `response` / `error` / `output` as
|
|
205
|
+
* appropriate for the kind/phase pair
|
|
206
|
+
* @throws Error if called from a step other than `handled` (or
|
|
207
|
+
* `failed`, which no-ops), or if the phase transition is illegal for
|
|
208
|
+
* the current phase
|
|
171
209
|
*/
|
|
172
210
|
transition(phase) {
|
|
173
211
|
if (this.#data.step === 'failed') {
|
|
@@ -340,6 +378,9 @@ export class ActionEvent {
|
|
|
340
378
|
// TODO not sure about this helper's design/location (should it be internal to the class constructor? a static method?)
|
|
341
379
|
/**
|
|
342
380
|
* Create an action event from a spec and initial input.
|
|
381
|
+
*
|
|
382
|
+
* @throws Error if `initial_phase` is omitted and the executor cannot
|
|
383
|
+
* initiate the action (per `spec.initiator`)
|
|
343
384
|
*/
|
|
344
385
|
export const create_action_event = (environment, spec, input, initial_phase) => {
|
|
345
386
|
const phase = initial_phase || get_initial_phase(spec.kind, spec.initiator, environment.executor);
|
|
@@ -351,6 +392,8 @@ export const create_action_event = (environment, spec, input, initial_phase) =>
|
|
|
351
392
|
};
|
|
352
393
|
/**
|
|
353
394
|
* Reconstruct an action event from serialized JSON data.
|
|
395
|
+
*
|
|
396
|
+
* @throws Error if the JSON's `method` field has no spec registered in `environment`
|
|
354
397
|
*/
|
|
355
398
|
export const create_action_event_from_json = (json, environment) => {
|
|
356
399
|
const spec = environment.lookup_action_spec(json.method);
|