@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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Public endpoint that creates an account. When `open_signup` is disabled
|
|
5
5
|
* (default), a matching unclaimed invite is required. When enabled, anyone
|
|
6
|
-
* can sign up without an invite. Follows the `bootstrap_routes.ts` pattern.
|
|
6
|
+
* can sign up without an invite. Follows the `auth/bootstrap_routes.ts` pattern.
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export declare const load_config: <T>(runtime: Pick<FsReadDeps, "stat" | "read_t
|
|
|
43
43
|
* @param path - path to the config JSON file
|
|
44
44
|
* @param dir - directory containing the config file (created if missing)
|
|
45
45
|
* @param config - configuration to save
|
|
46
|
+
* @mutates filesystem - creates `dir` (recursive) and writes JSON to `path`
|
|
47
|
+
* @throws Error if `mkdir` or `write_text_file` fails
|
|
46
48
|
*/
|
|
47
49
|
export declare const save_config: <T>(runtime: Pick<FsWriteDeps, "mkdir" | "write_text_file">, path: string, dir: string, config: T) => Promise<void>;
|
|
48
50
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/cli/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/cli/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAC,OAAO,EAAE,UAAU,EAAE,WAAW,E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C9D,MAAM,MAAM,EACZ,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAClB,OAAO,CAAC,CAAC,GAAG,IAAI,CAoBlB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW,GAAU,CAAC,EAClC,SAAS,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,iBAAiB,CAAC,EACvD,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,QAAQ,CAAC,KACP,OAAO,CAAC,IAAI,CAOd,CAAC"}
|
package/dist/cli/config.js
CHANGED
|
@@ -67,6 +67,8 @@ export const load_config = async (runtime, path, schema) => {
|
|
|
67
67
|
* @param path - path to the config JSON file
|
|
68
68
|
* @param dir - directory containing the config file (created if missing)
|
|
69
69
|
* @param config - configuration to save
|
|
70
|
+
* @mutates filesystem - creates `dir` (recursive) and writes JSON to `path`
|
|
71
|
+
* @throws Error if `mkdir` or `write_text_file` fails
|
|
70
72
|
*/
|
|
71
73
|
export const save_config = async (runtime, path, dir, config) => {
|
|
72
74
|
// ensure directory exists
|
package/dist/cli/daemon.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export declare const get_daemon_info_path: (runtime: Pick<EnvDeps, "env_get">, n
|
|
|
39
39
|
* @param runtime - runtime with file write and env capabilities
|
|
40
40
|
* @param name - application name
|
|
41
41
|
* @param info - daemon info to write
|
|
42
|
+
* @mutates filesystem - creates `~/.{name}/run/` and atomically writes `daemon.json`
|
|
43
|
+
* @throws Error if `$HOME` is not set, or if directory creation / atomic write fails
|
|
42
44
|
*/
|
|
43
45
|
export declare const write_daemon_info: (runtime: Pick<EnvDeps, "env_get"> & Pick<FsWriteDeps, "mkdir" | "write_text_file" | "rename">, name: string, info: DaemonInfo) => Promise<void>;
|
|
44
46
|
/**
|
|
@@ -85,11 +87,14 @@ export interface StopDaemonResult {
|
|
|
85
87
|
* Stop a running daemon by sending SIGTERM and cleaning up the PID file.
|
|
86
88
|
*
|
|
87
89
|
* Returns a result object instead of logging directly, separating
|
|
88
|
-
* lifecycle from presentation.
|
|
90
|
+
* lifecycle from presentation. Errors removing the PID file are swallowed
|
|
91
|
+
* (the daemon's own shutdown handler may have removed it concurrently).
|
|
89
92
|
*
|
|
90
93
|
* @param runtime - runtime with command, file, and env capabilities
|
|
91
94
|
* @param name - application name
|
|
92
95
|
* @returns result describing the outcome
|
|
96
|
+
* @mutates filesystem - removes `~/.{name}/run/daemon.json` on success or when corrupt
|
|
97
|
+
* @mutates external process - sends `SIGTERM` to the daemon process via `kill`
|
|
93
98
|
*/
|
|
94
99
|
export declare const stop_daemon: (runtime: Pick<EnvDeps, "env_get"> & Pick<FsReadDeps, "stat" | "read_text_file"> & FsRemoveDeps & CommandDeps & LogDeps, name: string) => Promise<StopDaemonResult>;
|
|
95
100
|
//# sourceMappingURL=daemon.d.ts.map
|
package/dist/cli/daemon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/cli/daemon.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,MAAM,oBAAoB,CAAC;AAI5B;;GAEG;AACH,eAAO,MAAM,UAAU;IACtB,sBAAsB;;IAEtB,yBAAyB;;IAEzB,uCAAuC;;IAEvC,yCAAyC;;IAEzC,0CAA0C;;kBAEzC,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAChC,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EACjC,MAAM,MAAM,KACV,MAAM,GAAG,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MAAM,KAAG,OAAO,CAAC,OAAO,CAG1F,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,SAAS,EACf,MAAM,MAAM,EACZ,aAAkB,EAClB,mBAAiB,KACf,OAAO,CAAC,OAAO,CAYjB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GACvB,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAChC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAAC,GAC3C,YAAY,GACZ,WAAW,GACX,OAAO,EACR,MAAM,MAAM,KACV,OAAO,CAAC,gBAAgB,CA2C1B,CAAC"}
|
package/dist/cli/daemon.js
CHANGED
|
@@ -43,6 +43,8 @@ export const get_daemon_info_path = (runtime, name) => {
|
|
|
43
43
|
* @param runtime - runtime with file write and env capabilities
|
|
44
44
|
* @param name - application name
|
|
45
45
|
* @param info - daemon info to write
|
|
46
|
+
* @mutates filesystem - creates `~/.{name}/run/` and atomically writes `daemon.json`
|
|
47
|
+
* @throws Error if `$HOME` is not set, or if directory creation / atomic write fails
|
|
46
48
|
*/
|
|
47
49
|
export const write_daemon_info = async (runtime, name, info) => {
|
|
48
50
|
const app_dir = get_app_dir(runtime, name);
|
|
@@ -126,11 +128,14 @@ export const check_daemon_health = async (deps, port, host = 'localhost', timeou
|
|
|
126
128
|
* Stop a running daemon by sending SIGTERM and cleaning up the PID file.
|
|
127
129
|
*
|
|
128
130
|
* Returns a result object instead of logging directly, separating
|
|
129
|
-
* lifecycle from presentation.
|
|
131
|
+
* lifecycle from presentation. Errors removing the PID file are swallowed
|
|
132
|
+
* (the daemon's own shutdown handler may have removed it concurrently).
|
|
130
133
|
*
|
|
131
134
|
* @param runtime - runtime with command, file, and env capabilities
|
|
132
135
|
* @param name - application name
|
|
133
136
|
* @returns result describing the outcome
|
|
137
|
+
* @mutates filesystem - removes `~/.{name}/run/daemon.json` on success or when corrupt
|
|
138
|
+
* @mutates external process - sends `SIGTERM` to the daemon process via `kill`
|
|
134
139
|
*/
|
|
135
140
|
export const stop_daemon = async (runtime, name) => {
|
|
136
141
|
const daemon_path = get_daemon_info_path(runtime, name);
|
package/dist/cli/util.d.ts
CHANGED
package/dist/cli/util.js
CHANGED
package/dist/db/assert_row.d.ts
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @param row - the row from `query_one` (`T | undefined`) or `rows[0]` (`T | undefined`)
|
|
14
14
|
* @param context - optional context for the error message (e.g. table or operation name)
|
|
15
|
-
* @returns the row, guaranteed non
|
|
15
|
+
* @returns the row, guaranteed non-`undefined`
|
|
16
|
+
* @throws Error if `row` is `undefined`
|
|
16
17
|
*/
|
|
17
18
|
export declare const assert_row: <T>(row: T | undefined, context?: string) => T;
|
|
18
19
|
//# sourceMappingURL=assert_row.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert_row.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/assert_row.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"assert_row.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/assert_row.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,KAAK,CAAC,GAAG,SAAS,EAAE,UAAU,MAAM,KAAG,CASpE,CAAC"}
|
package/dist/db/assert_row.js
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @param row - the row from `query_one` (`T | undefined`) or `rows[0]` (`T | undefined`)
|
|
14
14
|
* @param context - optional context for the error message (e.g. table or operation name)
|
|
15
|
-
* @returns the row, guaranteed non
|
|
15
|
+
* @returns the row, guaranteed non-`undefined`
|
|
16
|
+
* @throws Error if `row` is `undefined`
|
|
16
17
|
*/
|
|
17
18
|
export const assert_row = (row, context) => {
|
|
18
19
|
if (row === undefined) {
|
package/dist/db/create_db.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Both `pg` and `@electric-sql/pglite` are optional peer dependencies,
|
|
10
10
|
* dynamically imported only when needed. For direct driver construction
|
|
11
|
-
* without auto-detection, use `db_pg.ts` or `db_pglite.ts`.
|
|
11
|
+
* without auto-detection, use `db/db_pg.ts` or `db/db_pglite.ts`.
|
|
12
12
|
*
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
@@ -29,10 +29,13 @@ export interface CreateDbResult {
|
|
|
29
29
|
* know which driver is in use.
|
|
30
30
|
*
|
|
31
31
|
* For direct driver construction without URL routing, import
|
|
32
|
-
* `create_pg_db` from `db_pg.ts` or `create_pglite_db` from `db_pglite.ts`.
|
|
32
|
+
* `create_pg_db` from `db/db_pg.ts` or `create_pglite_db` from `db/db_pglite.ts`.
|
|
33
33
|
*
|
|
34
34
|
* @param database_url - connection URL (`postgres://`, `postgresql://`, `file://`, or `memory://`)
|
|
35
35
|
* @returns database instance, close callback, type, and display name
|
|
36
|
+
* @throws Error if `database_url` uses an unsupported scheme. Driver
|
|
37
|
+
* construction (`pg.Pool` or `PGlite`) may also throw on bad connection
|
|
38
|
+
* parameters or missing peer-dependency packages.
|
|
36
39
|
*/
|
|
37
40
|
export declare const create_db: (database_url: string) => Promise<CreateDbResult>;
|
|
38
41
|
//# sourceMappingURL=create_db.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_db.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/create_db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAC,EAAE,EAAE,MAAM,EAAC,MAAM,SAAS,CAAC;AAIxC,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,EAAE,CAAC;IACP,iFAAiF;IACjF,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED
|
|
1
|
+
{"version":3,"file":"create_db.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/create_db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAC,EAAE,EAAE,MAAM,EAAC,MAAM,SAAS,CAAC;AAIxC,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,EAAE,CAAC;IACP,iFAAiF;IACjF,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,SAAS,GAAU,cAAc,MAAM,KAAG,OAAO,CAAC,cAAc,CAgC5E,CAAC"}
|
package/dist/db/create_db.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Both `pg` and `@electric-sql/pglite` are optional peer dependencies,
|
|
10
10
|
* dynamically imported only when needed. For direct driver construction
|
|
11
|
-
* without auto-detection, use `db_pg.ts` or `db_pglite.ts`.
|
|
11
|
+
* without auto-detection, use `db/db_pg.ts` or `db/db_pglite.ts`.
|
|
12
12
|
*
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
@@ -22,10 +22,13 @@ import { create_pglite_db } from './db_pglite.js';
|
|
|
22
22
|
* know which driver is in use.
|
|
23
23
|
*
|
|
24
24
|
* For direct driver construction without URL routing, import
|
|
25
|
-
* `create_pg_db` from `db_pg.ts` or `create_pglite_db` from `db_pglite.ts`.
|
|
25
|
+
* `create_pg_db` from `db/db_pg.ts` or `create_pglite_db` from `db/db_pglite.ts`.
|
|
26
26
|
*
|
|
27
27
|
* @param database_url - connection URL (`postgres://`, `postgresql://`, `file://`, or `memory://`)
|
|
28
28
|
* @returns database instance, close callback, type, and display name
|
|
29
|
+
* @throws Error if `database_url` uses an unsupported scheme. Driver
|
|
30
|
+
* construction (`pg.Pool` or `PGlite`) may also throw on bad connection
|
|
31
|
+
* parameters or missing peer-dependency packages.
|
|
29
32
|
*/
|
|
30
33
|
export const create_db = async (database_url) => {
|
|
31
34
|
if (database_url.startsWith('postgres://') || database_url.startsWith('postgresql://')) {
|
package/dist/db/db.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Both `pg.Pool` and `@electric-sql/pglite` satisfy this interface.
|
|
6
6
|
*
|
|
7
7
|
* Transaction safety is provided by an injected `transaction` callback —
|
|
8
|
-
* the driver adapters (`db_pg.ts`, `db_pglite.ts`) supply the driver-appropriate
|
|
9
|
-
* implementation. Close is handled externally (returned alongside the Db
|
|
8
|
+
* the driver adapters (`db/db_pg.ts`, `db/db_pglite.ts`) supply the driver-appropriate
|
|
9
|
+
* implementation. Close is handled externally (returned alongside the `Db`
|
|
10
10
|
* as `DbDriverResult`), not as a method on this class.
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
@@ -23,7 +23,7 @@ export interface DbClient {
|
|
|
23
23
|
* Configuration for constructing a `Db` with transaction support.
|
|
24
24
|
*
|
|
25
25
|
* `transaction` is injected by `create_db` which knows the driver.
|
|
26
|
-
* For pg
|
|
26
|
+
* For `pg`: acquires a dedicated pool client per transaction.
|
|
27
27
|
* For PGlite: delegates to `pglite.transaction()`.
|
|
28
28
|
*/
|
|
29
29
|
export interface DbDeps {
|
|
@@ -47,16 +47,17 @@ export type DbType = 'postgres' | 'pglite-file' | 'pglite-memory';
|
|
|
47
47
|
/**
|
|
48
48
|
* Sentinel transaction function for transaction-scoped `Db` instances.
|
|
49
49
|
*
|
|
50
|
-
* Throws immediately — nested transactions are not supported.
|
|
51
50
|
* Used by driver adapters when constructing the inner `Db` passed
|
|
52
51
|
* to transaction callbacks.
|
|
52
|
+
*
|
|
53
|
+
* @throws Error always — nested transactions are not supported
|
|
53
54
|
*/
|
|
54
55
|
export declare const no_nested_transaction: DbDeps['transaction'];
|
|
55
56
|
/**
|
|
56
57
|
* Database wrapper providing a consistent query and transaction interface.
|
|
57
58
|
*
|
|
58
|
-
* Construct via `create_pg_db()` from `db_pg.ts` or `create_pglite_db()` from
|
|
59
|
-
* `db_pglite.ts` for proper transaction support, or via `create_db()` for
|
|
59
|
+
* Construct via `create_pg_db()` from `db/db_pg.ts` or `create_pglite_db()` from
|
|
60
|
+
* `db/db_pglite.ts` for proper transaction support, or via `create_db()` for
|
|
60
61
|
* URL-based auto-detection.
|
|
61
62
|
*
|
|
62
63
|
* @example
|
|
@@ -76,10 +77,22 @@ export declare class Db {
|
|
|
76
77
|
constructor(options: DbDeps);
|
|
77
78
|
/**
|
|
78
79
|
* Execute a query and return all rows.
|
|
80
|
+
*
|
|
81
|
+
* @param text - SQL text with `$1`, `$2`, ... parameter placeholders
|
|
82
|
+
* @param values - parameter values bound to the placeholders in `text`
|
|
83
|
+
* @returns the result rows, typed as `T`
|
|
84
|
+
* @throws Error propagated from the underlying driver on syntax errors,
|
|
85
|
+
* constraint violations, or connection failures
|
|
79
86
|
*/
|
|
80
87
|
query<T>(text: string, values?: Array<unknown>): Promise<Array<T>>;
|
|
81
88
|
/**
|
|
82
|
-
* Execute a query and return the first row, or undefined if no rows.
|
|
89
|
+
* Execute a query and return the first row, or `undefined` if no rows.
|
|
90
|
+
*
|
|
91
|
+
* @param text - SQL text with `$1`, `$2`, ... parameter placeholders
|
|
92
|
+
* @param values - parameter values bound to the placeholders in `text`
|
|
93
|
+
* @returns the first row, or `undefined` when the result set is empty
|
|
94
|
+
* @throws Error propagated from the underlying driver on syntax errors,
|
|
95
|
+
* constraint violations, or connection failures
|
|
83
96
|
*/
|
|
84
97
|
query_one<T>(text: string, values?: Array<unknown>): Promise<T | undefined>;
|
|
85
98
|
/**
|
|
@@ -91,6 +104,8 @@ export declare class Db {
|
|
|
91
104
|
*
|
|
92
105
|
* @param fn - async function receiving a transaction-scoped `Db`
|
|
93
106
|
* @returns the value returned by `fn`
|
|
107
|
+
* @throws Error propagated from `fn` after `ROLLBACK`, or from the driver
|
|
108
|
+
* if `BEGIN` / `COMMIT` / `ROLLBACK` itself fails
|
|
94
109
|
*/
|
|
95
110
|
transaction<T>(fn: (tx_db: Db) => Promise<T>): Promise<T>;
|
|
96
111
|
}
|
package/dist/db/db.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,KAAK,EAAE,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC;QAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;KAAC,CAAC,CAAC;CACzF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,MAAM;IACtB,MAAM,EAAE,QAAQ,CAAC;IACjB,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CAC9D;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,EAAE,CAAC;IACP,iFAAiF;IACjF,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED,4BAA4B;AAC5B,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG,aAAa,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AAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAKjF;;;;;;;;;;;OAWG;IACG,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAG/D"}
|
package/dist/db/db.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Both `pg.Pool` and `@electric-sql/pglite` satisfy this interface.
|
|
6
6
|
*
|
|
7
7
|
* Transaction safety is provided by an injected `transaction` callback —
|
|
8
|
-
* the driver adapters (`db_pg.ts`, `db_pglite.ts`) supply the driver-appropriate
|
|
9
|
-
* implementation. Close is handled externally (returned alongside the Db
|
|
8
|
+
* the driver adapters (`db/db_pg.ts`, `db/db_pglite.ts`) supply the driver-appropriate
|
|
9
|
+
* implementation. Close is handled externally (returned alongside the `Db`
|
|
10
10
|
* as `DbDriverResult`), not as a method on this class.
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
/**
|
|
15
15
|
* Sentinel transaction function for transaction-scoped `Db` instances.
|
|
16
16
|
*
|
|
17
|
-
* Throws immediately — nested transactions are not supported.
|
|
18
17
|
* Used by driver adapters when constructing the inner `Db` passed
|
|
19
18
|
* to transaction callbacks.
|
|
19
|
+
*
|
|
20
|
+
* @throws Error always — nested transactions are not supported
|
|
20
21
|
*/
|
|
21
22
|
export const no_nested_transaction = () => {
|
|
22
23
|
throw new Error('Nested transactions are not supported');
|
|
@@ -24,8 +25,8 @@ export const no_nested_transaction = () => {
|
|
|
24
25
|
/**
|
|
25
26
|
* Database wrapper providing a consistent query and transaction interface.
|
|
26
27
|
*
|
|
27
|
-
* Construct via `create_pg_db()` from `db_pg.ts` or `create_pglite_db()` from
|
|
28
|
-
* `db_pglite.ts` for proper transaction support, or via `create_db()` for
|
|
28
|
+
* Construct via `create_pg_db()` from `db/db_pg.ts` or `create_pglite_db()` from
|
|
29
|
+
* `db/db_pglite.ts` for proper transaction support, or via `create_db()` for
|
|
29
30
|
* URL-based auto-detection.
|
|
30
31
|
*
|
|
31
32
|
* @example
|
|
@@ -48,13 +49,25 @@ export class Db {
|
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
* Execute a query and return all rows.
|
|
52
|
+
*
|
|
53
|
+
* @param text - SQL text with `$1`, `$2`, ... parameter placeholders
|
|
54
|
+
* @param values - parameter values bound to the placeholders in `text`
|
|
55
|
+
* @returns the result rows, typed as `T`
|
|
56
|
+
* @throws Error propagated from the underlying driver on syntax errors,
|
|
57
|
+
* constraint violations, or connection failures
|
|
51
58
|
*/
|
|
52
59
|
async query(text, values) {
|
|
53
60
|
const result = await this.client.query(text, values);
|
|
54
61
|
return result.rows;
|
|
55
62
|
}
|
|
56
63
|
/**
|
|
57
|
-
* Execute a query and return the first row, or undefined if no rows.
|
|
64
|
+
* Execute a query and return the first row, or `undefined` if no rows.
|
|
65
|
+
*
|
|
66
|
+
* @param text - SQL text with `$1`, `$2`, ... parameter placeholders
|
|
67
|
+
* @param values - parameter values bound to the placeholders in `text`
|
|
68
|
+
* @returns the first row, or `undefined` when the result set is empty
|
|
69
|
+
* @throws Error propagated from the underlying driver on syntax errors,
|
|
70
|
+
* constraint violations, or connection failures
|
|
58
71
|
*/
|
|
59
72
|
async query_one(text, values) {
|
|
60
73
|
const rows = await this.query(text, values);
|
|
@@ -69,6 +82,8 @@ export class Db {
|
|
|
69
82
|
*
|
|
70
83
|
* @param fn - async function receiving a transaction-scoped `Db`
|
|
71
84
|
* @returns the value returned by `fn`
|
|
85
|
+
* @throws Error propagated from `fn` after `ROLLBACK`, or from the driver
|
|
86
|
+
* if `BEGIN` / `COMMIT` / `ROLLBACK` itself fails
|
|
72
87
|
*/
|
|
73
88
|
async transaction(fn) {
|
|
74
89
|
return this.#transaction(fn);
|
package/dist/db/db_pg.d.ts
CHANGED
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
import type { Pool } from 'pg';
|
|
11
11
|
import { type DbDriverResult } from './db.js';
|
|
12
12
|
/**
|
|
13
|
-
* Create a `Db` backed by a pg
|
|
13
|
+
* Create a `Db` backed by a `pg.Pool`.
|
|
14
14
|
*
|
|
15
15
|
* Owns the transaction implementation (acquires a dedicated pool client
|
|
16
16
|
* per transaction) and returns a `close` callback bound to `pool.end()`.
|
|
17
17
|
*
|
|
18
18
|
* @param pool - an already-constructed `pg.Pool`
|
|
19
|
+
* @returns the `Db` instance and a `close` callback bound to `pool.end()`
|
|
19
20
|
*/
|
|
20
21
|
export declare const create_pg_db: (pool: Pool) => DbDriverResult;
|
|
21
22
|
//# sourceMappingURL=db_pg.d.ts.map
|
package/dist/db/db_pg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db_pg.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/db_pg.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,IAAI,CAAC;AAE7B,OAAO,EAA4B,KAAK,cAAc,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"db_pg.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/db_pg.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,IAAI,CAAC;AAE7B,OAAO,EAA4B,KAAK,cAAc,EAAC,MAAM,SAAS,CAAC;AA2BvE;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,IAAI,KAAG,cAGxC,CAAC"}
|
package/dist/db/db_pg.js
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { Db, no_nested_transaction } from './db.js';
|
|
11
11
|
/**
|
|
12
|
-
* Create a transaction implementation for a pg
|
|
12
|
+
* Create a transaction implementation for a `pg.Pool`.
|
|
13
13
|
*
|
|
14
14
|
* Acquires a dedicated client from the pool for each transaction,
|
|
15
|
-
* ensuring BEGIN/COMMIT/ROLLBACK all hit the same connection.
|
|
15
|
+
* ensuring `BEGIN` / `COMMIT` / `ROLLBACK` all hit the same connection.
|
|
16
|
+
* Releases the client in `finally` regardless of outcome.
|
|
16
17
|
*/
|
|
17
18
|
const create_pg_transaction = (pool) => async (fn) => {
|
|
18
19
|
const client = await pool.connect();
|
|
@@ -32,12 +33,13 @@ const create_pg_transaction = (pool) => async (fn) => {
|
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
35
|
-
* Create a `Db` backed by a pg
|
|
36
|
+
* Create a `Db` backed by a `pg.Pool`.
|
|
36
37
|
*
|
|
37
38
|
* Owns the transaction implementation (acquires a dedicated pool client
|
|
38
39
|
* per transaction) and returns a `close` callback bound to `pool.end()`.
|
|
39
40
|
*
|
|
40
41
|
* @param pool - an already-constructed `pg.Pool`
|
|
42
|
+
* @returns the `Db` instance and a `close` callback bound to `pool.end()`
|
|
41
43
|
*/
|
|
42
44
|
export const create_pg_db = (pool) => ({
|
|
43
45
|
db: new Db({ client: pool, transaction: create_pg_transaction(pool) }),
|
package/dist/db/db_pglite.d.ts
CHANGED
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
import type { PGlite } from '@electric-sql/pglite';
|
|
11
11
|
import { type DbDriverResult } from './db.js';
|
|
12
12
|
/**
|
|
13
|
-
* Create a `Db` backed by a PGlite instance.
|
|
13
|
+
* Create a `Db` backed by a `PGlite` instance.
|
|
14
14
|
*
|
|
15
15
|
* Delegates transactions to PGlite's native `transaction()` method
|
|
16
16
|
* and returns a `close` callback bound to `pglite.close()`.
|
|
17
17
|
*
|
|
18
|
-
* @param pglite - an already-constructed PGlite instance
|
|
18
|
+
* @param pglite - an already-constructed `PGlite` instance
|
|
19
|
+
* @returns the `Db` instance and a `close` callback bound to `pglite.close()`
|
|
19
20
|
*/
|
|
20
21
|
export declare const create_pglite_db: (pglite: PGlite) => DbDriverResult;
|
|
21
22
|
//# sourceMappingURL=db_pglite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db_pglite.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/db_pglite.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAA4B,KAAK,cAAc,EAAC,MAAM,SAAS,CAAC;AAYvE
|
|
1
|
+
{"version":3,"file":"db_pglite.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/db_pglite.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAA4B,KAAK,cAAc,EAAC,MAAM,SAAS,CAAC;AAYvE;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,cAGhD,CAAC"}
|
package/dist/db/db_pglite.js
CHANGED
|
@@ -15,12 +15,13 @@ import { Db, no_nested_transaction } from './db.js';
|
|
|
15
15
|
*/
|
|
16
16
|
const create_pglite_transaction = (pglite) => async (fn) => pglite.transaction(async (tx) => fn(new Db({ client: tx, transaction: no_nested_transaction })));
|
|
17
17
|
/**
|
|
18
|
-
* Create a `Db` backed by a PGlite instance.
|
|
18
|
+
* Create a `Db` backed by a `PGlite` instance.
|
|
19
19
|
*
|
|
20
20
|
* Delegates transactions to PGlite's native `transaction()` method
|
|
21
21
|
* and returns a `close` callback bound to `pglite.close()`.
|
|
22
22
|
*
|
|
23
|
-
* @param pglite - an already-constructed PGlite instance
|
|
23
|
+
* @param pglite - an already-constructed `PGlite` instance
|
|
24
|
+
* @returns the `Db` instance and a `close` callback bound to `pglite.close()`
|
|
24
25
|
*/
|
|
25
26
|
export const create_pglite_db = (pglite) => ({
|
|
26
27
|
db: new Db({ client: pglite, transaction: create_pglite_transaction(pglite) }),
|
package/dist/db/migrate.d.ts
CHANGED
|
@@ -66,13 +66,13 @@ export interface MigrationResult {
|
|
|
66
66
|
applied_names: Array<string>;
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Tagged error vocabulary for
|
|
69
|
+
* Tagged error vocabulary for `run_migrations` and `baseline`.
|
|
70
70
|
*
|
|
71
71
|
* Callers branch on `.kind` rather than matching error messages — message
|
|
72
72
|
* text is for operators, not control flow.
|
|
73
73
|
*/
|
|
74
74
|
export type MigrationErrorKind = 'binary-older-than-db' | 'name-divergence-at-N' | 'old-tracker-shape' | 'migration-failed' | 'baseline-name-not-in-code' | 'baseline-name-out-of-order' | 'baseline-namespace-already-populated';
|
|
75
|
-
/** Structured context passed alongside a
|
|
75
|
+
/** Structured context passed alongside a `MigrationError`. */
|
|
76
76
|
export interface MigrationErrorContext {
|
|
77
77
|
namespace?: string;
|
|
78
78
|
at_index?: number;
|
|
@@ -80,7 +80,7 @@ export interface MigrationErrorContext {
|
|
|
80
80
|
cause?: unknown;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* Tagged error thrown by
|
|
83
|
+
* Tagged error thrown by `run_migrations` and `baseline`.
|
|
84
84
|
*
|
|
85
85
|
* Branch on `.kind`; the message carries an operator-facing remediation hint.
|
|
86
86
|
*/
|
|
@@ -111,7 +111,7 @@ export declare class MigrationError extends Error {
|
|
|
111
111
|
*
|
|
112
112
|
* **Concurrency**: per-namespace advisory locks reduce contention in
|
|
113
113
|
* multi-instance deployments but are best-effort on pool drivers (see
|
|
114
|
-
* module docstring
|
|
114
|
+
* the module docstring's "Advisory locking" notes). Correctness on concurrent boots
|
|
115
115
|
* falls out of chain-tx atomicity + the `(namespace, name)` PK — the
|
|
116
116
|
* loser's INSERT triggers PK violation and rollback; subsequent boots
|
|
117
117
|
* see the committed state.
|
|
@@ -120,6 +120,8 @@ export declare class MigrationError extends Error {
|
|
|
120
120
|
* @param namespaces - migration namespaces, processed in the order passed
|
|
121
121
|
* @returns one result per namespace where work happened (already-up-to-date
|
|
122
122
|
* namespaces are omitted)
|
|
123
|
+
* @mutates schema_version - inserts one row per applied migration
|
|
124
|
+
* @mutates db - applies pending migrations' DDL/DML to the schema
|
|
123
125
|
* @throws MigrationError with `kind` of `binary-older-than-db`,
|
|
124
126
|
* `name-divergence-at-N`, `old-tracker-shape`, or `migration-failed`
|
|
125
127
|
*/
|
|
@@ -154,6 +156,8 @@ export declare const run_migrations: (db: Db, namespaces: Array<MigrationNamespa
|
|
|
154
156
|
* @param db - the database instance
|
|
155
157
|
* @param ns - the namespace whose migrations are being baselined
|
|
156
158
|
* @param names - prefix of `ns.migrations[].name` to record as already-applied
|
|
159
|
+
* @mutates schema_version - inserts tracker rows for `names` without running
|
|
160
|
+
* the corresponding migration bodies
|
|
157
161
|
* @throws MigrationError with `kind` of `old-tracker-shape`,
|
|
158
162
|
* `baseline-name-not-in-code`, `baseline-name-out-of-order`, or
|
|
159
163
|
* `baseline-namespace-already-populated`
|
package/dist/db/migrate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,SAAS,CAAC;AAEhC;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC7B;AAED,2DAA2D;AAC3D,MAA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KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;gBAEnC,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;CAQtF;AA6ED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,cAAc,GAC1B,IAAI,EAAE,EACN,YAAY,KAAK,CAAC,kBAAkB,CAAC,KACnC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAuFhC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,QAAQ,GACpB,IAAI,EAAE,EACN,IAAI,kBAAkB,EACtB,OAAO,aAAa,CAAC,MAAM,CAAC,KAC1B,OAAO,CAAC,IAAI,CA+Dd,CAAC"}
|
package/dist/db/migrate.js
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* @module
|
|
42
42
|
*/
|
|
43
43
|
/**
|
|
44
|
-
* Tagged error thrown by
|
|
44
|
+
* Tagged error thrown by `run_migrations` and `baseline`.
|
|
45
45
|
*
|
|
46
46
|
* Branch on `.kind`; the message carries an operator-facing remediation hint.
|
|
47
47
|
*/
|
|
@@ -145,7 +145,7 @@ const with_namespace_lock = async (db, namespace, fn) => {
|
|
|
145
145
|
*
|
|
146
146
|
* **Concurrency**: per-namespace advisory locks reduce contention in
|
|
147
147
|
* multi-instance deployments but are best-effort on pool drivers (see
|
|
148
|
-
* module docstring
|
|
148
|
+
* the module docstring's "Advisory locking" notes). Correctness on concurrent boots
|
|
149
149
|
* falls out of chain-tx atomicity + the `(namespace, name)` PK — the
|
|
150
150
|
* loser's INSERT triggers PK violation and rollback; subsequent boots
|
|
151
151
|
* see the committed state.
|
|
@@ -154,6 +154,8 @@ const with_namespace_lock = async (db, namespace, fn) => {
|
|
|
154
154
|
* @param namespaces - migration namespaces, processed in the order passed
|
|
155
155
|
* @returns one result per namespace where work happened (already-up-to-date
|
|
156
156
|
* namespaces are omitted)
|
|
157
|
+
* @mutates schema_version - inserts one row per applied migration
|
|
158
|
+
* @mutates db - applies pending migrations' DDL/DML to the schema
|
|
157
159
|
* @throws MigrationError with `kind` of `binary-older-than-db`,
|
|
158
160
|
* `name-divergence-at-N`, `old-tracker-shape`, or `migration-failed`
|
|
159
161
|
*/
|
|
@@ -250,6 +252,8 @@ export const run_migrations = async (db, namespaces) => {
|
|
|
250
252
|
* @param db - the database instance
|
|
251
253
|
* @param ns - the namespace whose migrations are being baselined
|
|
252
254
|
* @param names - prefix of `ns.migrations[].name` to record as already-applied
|
|
255
|
+
* @mutates schema_version - inserts tracker rows for `names` without running
|
|
256
|
+
* the corresponding migration bodies
|
|
253
257
|
* @throws MigrationError with `kind` of `old-tracker-shape`,
|
|
254
258
|
* `baseline-name-not-in-code`, `baseline-name-out-of-order`, or
|
|
255
259
|
* `baseline-namespace-already-populated`
|
|
@@ -21,7 +21,8 @@ export declare const VALID_SQL_IDENTIFIER: RegExp;
|
|
|
21
21
|
*
|
|
22
22
|
* @param name - the identifier to validate
|
|
23
23
|
* @returns the validated identifier
|
|
24
|
-
* @throws if the identifier contains
|
|
24
|
+
* @throws Error if the identifier contains characters outside `[a-zA-Z0-9_]`
|
|
25
|
+
* or starts with a digit
|
|
25
26
|
*/
|
|
26
27
|
export declare const assert_valid_sql_identifier: (name: string) => string;
|
|
27
28
|
//# sourceMappingURL=sql_identifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql_identifier.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/sql_identifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAA6B,CAAC;AAE/D
|
|
1
|
+
{"version":3,"file":"sql_identifier.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/sql_identifier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,QAA6B,CAAC;AAE/D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,GAAI,MAAM,MAAM,KAAG,MAK1D,CAAC"}
|
|
@@ -21,7 +21,8 @@ export const VALID_SQL_IDENTIFIER = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
|
21
21
|
*
|
|
22
22
|
* @param name - the identifier to validate
|
|
23
23
|
* @returns the validated identifier
|
|
24
|
-
* @throws if the identifier contains
|
|
24
|
+
* @throws Error if the identifier contains characters outside `[a-zA-Z0-9_]`
|
|
25
|
+
* or starts with a digit
|
|
25
26
|
*/
|
|
26
27
|
export const assert_valid_sql_identifier = (name) => {
|
|
27
28
|
if (!VALID_SQL_IDENTIFIER.test(name)) {
|
package/dist/db/status.d.ts
CHANGED
|
@@ -55,7 +55,10 @@ export interface DbStatus {
|
|
|
55
55
|
*
|
|
56
56
|
* @param db - the database instance
|
|
57
57
|
* @param namespaces - migration namespaces to check status for
|
|
58
|
-
* @returns a snapshot of database status
|
|
58
|
+
* @returns a snapshot of database status; `connected: false` with `error`
|
|
59
|
+
* set when the initial connectivity probe fails
|
|
60
|
+
* @throws Error propagated from the driver if a query fails after the
|
|
61
|
+
* connectivity probe (e.g. a table is dropped mid-scan)
|
|
59
62
|
*/
|
|
60
63
|
export declare const query_db_status: (db: Db, namespaces?: Array<MigrationNamespace>) => Promise<DbStatus>;
|
|
61
64
|
/**
|
package/dist/db/status.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/status.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,2EAA2E;IAC3E,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,wEAAwE;IACxE,UAAU,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,yCAAyC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3B,sCAAsC;IACtC,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACnC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC5B;AA8BD
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/status.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,2EAA2E;IAC3E,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,wEAAwE;IACxE,UAAU,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,yCAAyC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3B,sCAAsC;IACtC,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IACnC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC5B;AA8BD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAC3B,IAAI,EAAE,EACN,aAAa,KAAK,CAAC,kBAAkB,CAAC,KACpC,OAAO,CAAC,QAAQ,CAmFlB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,QAAQ,KAAG,MA4CnD,CAAC"}
|
package/dist/db/status.js
CHANGED
|
@@ -29,7 +29,10 @@ const has_table = async (db, table_name) => {
|
|
|
29
29
|
*
|
|
30
30
|
* @param db - the database instance
|
|
31
31
|
* @param namespaces - migration namespaces to check status for
|
|
32
|
-
* @returns a snapshot of database status
|
|
32
|
+
* @returns a snapshot of database status; `connected: false` with `error`
|
|
33
|
+
* set when the initial connectivity probe fails
|
|
34
|
+
* @throws Error propagated from the driver if a query fails after the
|
|
35
|
+
* connectivity probe (e.g. a table is dropped mid-scan)
|
|
33
36
|
*/
|
|
34
37
|
export const query_db_status = async (db, namespaces) => {
|
|
35
38
|
// check connectivity
|
|
@@ -51,7 +54,7 @@ export const query_db_status = async (db, namespaces) => {
|
|
|
51
54
|
ORDER BY table_name`);
|
|
52
55
|
const tables = [];
|
|
53
56
|
for (const { table_name } of table_rows) {
|
|
54
|
-
// table_name from information_schema is trusted
|
|
57
|
+
// table_name from information_schema is trusted (no parameterized DDL)
|
|
55
58
|
const result = await db.query_one(`SELECT COUNT(*) as count FROM "${table_name}"`);
|
|
56
59
|
tables.push({
|
|
57
60
|
name: table_name,
|