@schema-weaver/pg-connector 0.0.0-stage → 2.0.1
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/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +457 -2
- package/dist/cjs/audit/chain.d.ts +365 -0
- package/dist/cjs/audit/chain.d.ts.map +1 -0
- package/dist/cjs/audit/chain.js +959 -0
- package/dist/cjs/audit/chain.js.map +1 -0
- package/dist/cjs/audit/cloud-client.d.ts +142 -0
- package/dist/cjs/audit/cloud-client.d.ts.map +1 -0
- package/dist/cjs/audit/cloud-client.js +364 -0
- package/dist/cjs/audit/cloud-client.js.map +1 -0
- package/dist/cjs/audit/cloud-writer.d.ts +57 -0
- package/dist/cjs/audit/cloud-writer.d.ts.map +1 -0
- package/dist/cjs/audit/cloud-writer.js +95 -0
- package/dist/cjs/audit/cloud-writer.js.map +1 -0
- package/dist/cjs/audit/context.d.ts +51 -0
- package/dist/cjs/audit/context.d.ts.map +1 -0
- package/dist/cjs/audit/context.js +75 -0
- package/dist/cjs/audit/context.js.map +1 -0
- package/dist/cjs/audit/files.d.ts +111 -0
- package/dist/cjs/audit/files.d.ts.map +1 -0
- package/dist/cjs/audit/files.js +406 -0
- package/dist/cjs/audit/files.js.map +1 -0
- package/dist/cjs/audit/index.d.ts +9 -0
- package/dist/cjs/audit/index.d.ts.map +1 -0
- package/dist/cjs/audit/index.js +68 -0
- package/dist/cjs/audit/index.js.map +1 -0
- package/dist/cjs/audit/local-writer.d.ts +255 -0
- package/dist/cjs/audit/local-writer.d.ts.map +1 -0
- package/dist/cjs/audit/local-writer.js +829 -0
- package/dist/cjs/audit/local-writer.js.map +1 -0
- package/dist/cjs/audit/redact.d.ts +151 -0
- package/dist/cjs/audit/redact.d.ts.map +1 -0
- package/dist/cjs/audit/redact.js +549 -0
- package/dist/cjs/audit/redact.js.map +1 -0
- package/dist/cjs/audit/sanitize.d.ts +78 -0
- package/dist/cjs/audit/sanitize.d.ts.map +1 -0
- package/dist/cjs/audit/sanitize.js +315 -0
- package/dist/cjs/audit/sanitize.js.map +1 -0
- package/dist/cjs/audit/sink.d.ts +278 -0
- package/dist/cjs/audit/sink.d.ts.map +1 -0
- package/dist/cjs/audit/sink.js +819 -0
- package/dist/cjs/audit/sink.js.map +1 -0
- package/dist/cjs/audit/types.d.ts +226 -0
- package/dist/cjs/audit/types.d.ts.map +1 -0
- package/dist/cjs/audit/types.js +3 -0
- package/dist/cjs/audit/types.js.map +1 -0
- package/dist/cjs/audit/verify-cache.d.ts +127 -0
- package/dist/cjs/audit/verify-cache.d.ts.map +1 -0
- package/dist/cjs/audit/verify-cache.js +668 -0
- package/dist/cjs/audit/verify-cache.js.map +1 -0
- package/dist/cjs/channels/agent-session.d.ts +228 -0
- package/dist/cjs/channels/agent-session.d.ts.map +1 -0
- package/dist/cjs/channels/agent-session.js +604 -0
- package/dist/cjs/channels/agent-session.js.map +1 -0
- package/dist/cjs/channels/data-channel.d.ts +181 -0
- package/dist/cjs/channels/data-channel.d.ts.map +1 -0
- package/dist/cjs/channels/data-channel.js +607 -0
- package/dist/cjs/channels/data-channel.js.map +1 -0
- package/dist/cjs/channels/reconnect.d.ts +142 -0
- package/dist/cjs/channels/reconnect.d.ts.map +1 -0
- package/dist/cjs/channels/reconnect.js +247 -0
- package/dist/cjs/channels/reconnect.js.map +1 -0
- package/dist/cjs/channels/types.d.ts +112 -0
- package/dist/cjs/channels/types.d.ts.map +1 -0
- package/dist/cjs/channels/types.js +3 -0
- package/dist/cjs/channels/types.js.map +1 -0
- package/dist/cjs/channels/wake-channel.d.ts +232 -0
- package/dist/cjs/channels/wake-channel.d.ts.map +1 -0
- package/dist/cjs/channels/wake-channel.js +752 -0
- package/dist/cjs/channels/wake-channel.js.map +1 -0
- package/dist/cjs/cli/banner.d.ts +2 -0
- package/dist/cjs/cli/banner.d.ts.map +1 -0
- package/dist/cjs/cli/banner.js +150 -0
- package/dist/cjs/cli/banner.js.map +1 -0
- package/dist/cjs/cli/commands/agent.d.ts +30 -0
- package/dist/cjs/cli/commands/agent.d.ts.map +1 -0
- package/dist/cjs/cli/commands/agent.js +214 -0
- package/dist/cjs/cli/commands/agent.js.map +1 -0
- package/dist/cjs/cli/commands/audit-verify.d.ts +19 -0
- package/dist/cjs/cli/commands/audit-verify.d.ts.map +1 -0
- package/dist/cjs/cli/commands/audit-verify.js +382 -0
- package/dist/cjs/cli/commands/audit-verify.js.map +1 -0
- package/dist/cjs/cli/commands/clean.d.ts +23 -0
- package/dist/cjs/cli/commands/clean.d.ts.map +1 -0
- package/dist/cjs/cli/commands/clean.js +272 -0
- package/dist/cjs/cli/commands/clean.js.map +1 -0
- package/dist/cjs/cli/commands/config-show.d.ts +2 -0
- package/dist/cjs/cli/commands/config-show.d.ts.map +1 -0
- package/dist/cjs/cli/commands/config-show.js +10 -0
- package/dist/cjs/cli/commands/config-show.js.map +1 -0
- package/dist/cjs/cli/commands/config.d.ts +6 -0
- package/dist/cjs/cli/commands/config.d.ts.map +1 -0
- package/dist/cjs/cli/commands/config.js +266 -0
- package/dist/cjs/cli/commands/config.js.map +1 -0
- package/dist/cjs/cli/commands/db-add.d.ts +16 -0
- package/dist/cjs/cli/commands/db-add.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-add.js +613 -0
- package/dist/cjs/cli/commands/db-add.js.map +1 -0
- package/dist/cjs/cli/commands/db-edit.d.ts +2 -0
- package/dist/cjs/cli/commands/db-edit.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-edit.js +388 -0
- package/dist/cjs/cli/commands/db-edit.js.map +1 -0
- package/dist/cjs/cli/commands/db-logs.d.ts +3 -0
- package/dist/cjs/cli/commands/db-logs.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-logs.js +67 -0
- package/dist/cjs/cli/commands/db-logs.js.map +1 -0
- package/dist/cjs/cli/commands/db-ls.d.ts +2 -0
- package/dist/cjs/cli/commands/db-ls.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-ls.js +118 -0
- package/dist/cjs/cli/commands/db-ls.js.map +1 -0
- package/dist/cjs/cli/commands/db-query.d.ts +121 -0
- package/dist/cjs/cli/commands/db-query.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-query.js +802 -0
- package/dist/cjs/cli/commands/db-query.js.map +1 -0
- package/dist/cjs/cli/commands/db-remove.d.ts +2 -0
- package/dist/cjs/cli/commands/db-remove.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-remove.js +51 -0
- package/dist/cjs/cli/commands/db-remove.js.map +1 -0
- package/dist/cjs/cli/commands/db-show.d.ts +2 -0
- package/dist/cjs/cli/commands/db-show.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-show.js +134 -0
- package/dist/cjs/cli/commands/db-show.js.map +1 -0
- package/dist/cjs/cli/commands/db-test.d.ts +3 -0
- package/dist/cjs/cli/commands/db-test.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db-test.js +311 -0
- package/dist/cjs/cli/commands/db-test.js.map +1 -0
- package/dist/cjs/cli/commands/db.d.ts +11 -0
- package/dist/cjs/cli/commands/db.d.ts.map +1 -0
- package/dist/cjs/cli/commands/db.js +90 -0
- package/dist/cjs/cli/commands/db.js.map +1 -0
- package/dist/cjs/cli/commands/debug.d.ts +2 -0
- package/dist/cjs/cli/commands/debug.d.ts.map +1 -0
- package/dist/cjs/cli/commands/debug.js +241 -0
- package/dist/cjs/cli/commands/debug.js.map +1 -0
- package/dist/cjs/cli/commands/doctor.d.ts +5 -0
- package/dist/cjs/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cjs/cli/commands/doctor.js +117 -0
- package/dist/cjs/cli/commands/doctor.js.map +1 -0
- package/dist/cjs/cli/commands/index.d.ts +10 -0
- package/dist/cjs/cli/commands/index.d.ts.map +1 -0
- package/dist/cjs/cli/commands/index.js +30 -0
- package/dist/cjs/cli/commands/index.js.map +1 -0
- package/dist/cjs/cli/commands/init.d.ts +2 -0
- package/dist/cjs/cli/commands/init.d.ts.map +1 -0
- package/dist/cjs/cli/commands/init.js +199 -0
- package/dist/cjs/cli/commands/init.js.map +1 -0
- package/dist/cjs/cli/commands/link.d.ts +5 -0
- package/dist/cjs/cli/commands/link.d.ts.map +1 -0
- package/dist/cjs/cli/commands/link.js +44 -0
- package/dist/cjs/cli/commands/link.js.map +1 -0
- package/dist/cjs/cli/commands/logs.d.ts +17 -0
- package/dist/cjs/cli/commands/logs.d.ts.map +1 -0
- package/dist/cjs/cli/commands/logs.js +314 -0
- package/dist/cjs/cli/commands/logs.js.map +1 -0
- package/dist/cjs/cli/commands/project-show.d.ts +2 -0
- package/dist/cjs/cli/commands/project-show.d.ts.map +1 -0
- package/dist/cjs/cli/commands/project-show.js +105 -0
- package/dist/cjs/cli/commands/project-show.js.map +1 -0
- package/dist/cjs/cli/commands/project.d.ts +3 -0
- package/dist/cjs/cli/commands/project.d.ts.map +1 -0
- package/dist/cjs/cli/commands/project.js +64 -0
- package/dist/cjs/cli/commands/project.js.map +1 -0
- package/dist/cjs/cli/commands/service.d.ts +123 -0
- package/dist/cjs/cli/commands/service.d.ts.map +1 -0
- package/dist/cjs/cli/commands/service.js +554 -0
- package/dist/cjs/cli/commands/service.js.map +1 -0
- package/dist/cjs/cli/commands/start.d.ts +6 -0
- package/dist/cjs/cli/commands/start.d.ts.map +1 -0
- package/dist/cjs/cli/commands/start.js +308 -0
- package/dist/cjs/cli/commands/start.js.map +1 -0
- package/dist/cjs/cli/commands/status.d.ts +2 -0
- package/dist/cjs/cli/commands/status.d.ts.map +1 -0
- package/dist/cjs/cli/commands/status.js +225 -0
- package/dist/cjs/cli/commands/status.js.map +1 -0
- package/dist/cjs/cli/commands/stop.d.ts +6 -0
- package/dist/cjs/cli/commands/stop.d.ts.map +1 -0
- package/dist/cjs/cli/commands/stop.js +99 -0
- package/dist/cjs/cli/commands/stop.js.map +1 -0
- package/dist/cjs/cli/daemon/error-tracker.d.ts +119 -0
- package/dist/cjs/cli/daemon/error-tracker.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/error-tracker.js +500 -0
- package/dist/cjs/cli/daemon/error-tracker.js.map +1 -0
- package/dist/cjs/cli/daemon/fault-shutdown.d.ts +144 -0
- package/dist/cjs/cli/daemon/fault-shutdown.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/fault-shutdown.js +312 -0
- package/dist/cjs/cli/daemon/fault-shutdown.js.map +1 -0
- package/dist/cjs/cli/daemon/index.d.ts +12 -0
- package/dist/cjs/cli/daemon/index.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/index.js +23 -0
- package/dist/cjs/cli/daemon/index.js.map +1 -0
- package/dist/cjs/cli/daemon/pid-file.d.ts +13 -0
- package/dist/cjs/cli/daemon/pid-file.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/pid-file.js +90 -0
- package/dist/cjs/cli/daemon/pid-file.js.map +1 -0
- package/dist/cjs/cli/daemon/readiness.d.ts +30 -0
- package/dist/cjs/cli/daemon/readiness.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/readiness.js +74 -0
- package/dist/cjs/cli/daemon/readiness.js.map +1 -0
- package/dist/cjs/cli/daemon/runtime.d.ts +366 -0
- package/dist/cjs/cli/daemon/runtime.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/runtime.js +1343 -0
- package/dist/cjs/cli/daemon/runtime.js.map +1 -0
- package/dist/cjs/cli/daemon/shutdown.d.ts +7 -0
- package/dist/cjs/cli/daemon/shutdown.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/shutdown.js +66 -0
- package/dist/cjs/cli/daemon/shutdown.js.map +1 -0
- package/dist/cjs/cli/daemon/signal-handlers.d.ts +3 -0
- package/dist/cjs/cli/daemon/signal-handlers.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/signal-handlers.js +27 -0
- package/dist/cjs/cli/daemon/signal-handlers.js.map +1 -0
- package/dist/cjs/cli/daemon/state.d.ts +157 -0
- package/dist/cjs/cli/daemon/state.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/state.js +397 -0
- package/dist/cjs/cli/daemon/state.js.map +1 -0
- package/dist/cjs/cli/daemon/status-file.d.ts +139 -0
- package/dist/cjs/cli/daemon/status-file.d.ts.map +1 -0
- package/dist/cjs/cli/daemon/status-file.js +88 -0
- package/dist/cjs/cli/daemon/status-file.js.map +1 -0
- package/dist/cjs/cli/doctor/checks.d.ts +133 -0
- package/dist/cjs/cli/doctor/checks.d.ts.map +1 -0
- package/dist/cjs/cli/doctor/checks.js +677 -0
- package/dist/cjs/cli/doctor/checks.js.map +1 -0
- package/dist/cjs/cli/doctor/fixes.d.ts +9 -0
- package/dist/cjs/cli/doctor/fixes.d.ts.map +1 -0
- package/dist/cjs/cli/doctor/fixes.js +199 -0
- package/dist/cjs/cli/doctor/fixes.js.map +1 -0
- package/dist/cjs/cli/doctor/index.d.ts +7 -0
- package/dist/cjs/cli/doctor/index.d.ts.map +1 -0
- package/dist/cjs/cli/doctor/index.js +27 -0
- package/dist/cjs/cli/doctor/index.js.map +1 -0
- package/dist/cjs/cli/index.d.ts +3 -0
- package/dist/cjs/cli/index.d.ts.map +1 -0
- package/dist/cjs/cli/index.js +336 -0
- package/dist/cjs/cli/index.js.map +1 -0
- package/dist/cjs/cli/interactive.d.ts +8 -0
- package/dist/cjs/cli/interactive.d.ts.map +1 -0
- package/dist/cjs/cli/interactive.js +670 -0
- package/dist/cjs/cli/interactive.js.map +1 -0
- package/dist/cjs/cli/logs/format.d.ts +13 -0
- package/dist/cjs/cli/logs/format.d.ts.map +1 -0
- package/dist/cjs/cli/logs/format.js +178 -0
- package/dist/cjs/cli/logs/format.js.map +1 -0
- package/dist/cjs/cli/logs/index.d.ts +3 -0
- package/dist/cjs/cli/logs/index.d.ts.map +1 -0
- package/dist/cjs/cli/logs/index.js +13 -0
- package/dist/cjs/cli/logs/index.js.map +1 -0
- package/dist/cjs/cli/logs/viewer.d.ts +41 -0
- package/dist/cjs/cli/logs/viewer.d.ts.map +1 -0
- package/dist/cjs/cli/logs/viewer.js +417 -0
- package/dist/cjs/cli/logs/viewer.js.map +1 -0
- package/dist/cjs/cli/ops/operation-logger.d.ts +63 -0
- package/dist/cjs/cli/ops/operation-logger.d.ts.map +1 -0
- package/dist/cjs/cli/ops/operation-logger.js +183 -0
- package/dist/cjs/cli/ops/operation-logger.js.map +1 -0
- package/dist/cjs/cli/palette.d.ts +11 -0
- package/dist/cjs/cli/palette.d.ts.map +1 -0
- package/dist/cjs/cli/palette.js +243 -0
- package/dist/cjs/cli/palette.js.map +1 -0
- package/dist/cjs/cli/prompt.d.ts +186 -0
- package/dist/cjs/cli/prompt.d.ts.map +1 -0
- package/dist/cjs/cli/prompt.js +541 -0
- package/dist/cjs/cli/prompt.js.map +1 -0
- package/dist/cjs/cli/ui/box.d.ts +21 -0
- package/dist/cjs/cli/ui/box.d.ts.map +1 -0
- package/dist/cjs/cli/ui/box.js +72 -0
- package/dist/cjs/cli/ui/box.js.map +1 -0
- package/dist/cjs/cli/ui/clipboard.d.ts +6 -0
- package/dist/cjs/cli/ui/clipboard.d.ts.map +1 -0
- package/dist/cjs/cli/ui/clipboard.js +78 -0
- package/dist/cjs/cli/ui/clipboard.js.map +1 -0
- package/dist/cjs/cli/ui/colors.d.ts +57 -0
- package/dist/cjs/cli/ui/colors.d.ts.map +1 -0
- package/dist/cjs/cli/ui/colors.js +151 -0
- package/dist/cjs/cli/ui/colors.js.map +1 -0
- package/dist/cjs/cli/ui/index.d.ts +9 -0
- package/dist/cjs/cli/ui/index.d.ts.map +1 -0
- package/dist/cjs/cli/ui/index.js +55 -0
- package/dist/cjs/cli/ui/index.js.map +1 -0
- package/dist/cjs/cli/ui/spinner.d.ts +12 -0
- package/dist/cjs/cli/ui/spinner.d.ts.map +1 -0
- package/dist/cjs/cli/ui/spinner.js +82 -0
- package/dist/cjs/cli/ui/spinner.js.map +1 -0
- package/dist/cjs/cli/ui/symbols.d.ts +47 -0
- package/dist/cjs/cli/ui/symbols.d.ts.map +1 -0
- package/dist/cjs/cli/ui/symbols.js +112 -0
- package/dist/cjs/cli/ui/symbols.js.map +1 -0
- package/dist/cjs/cli/ui/table.d.ts +23 -0
- package/dist/cjs/cli/ui/table.d.ts.map +1 -0
- package/dist/cjs/cli/ui/table.js +160 -0
- package/dist/cjs/cli/ui/table.js.map +1 -0
- package/dist/cjs/cli/ui/terminal.d.ts +7 -0
- package/dist/cjs/cli/ui/terminal.d.ts.map +1 -0
- package/dist/cjs/cli/ui/terminal.js +40 -0
- package/dist/cjs/cli/ui/terminal.js.map +1 -0
- package/dist/cjs/config/atomic-write.d.ts +69 -0
- package/dist/cjs/config/atomic-write.d.ts.map +1 -0
- package/dist/cjs/config/atomic-write.js +289 -0
- package/dist/cjs/config/atomic-write.js.map +1 -0
- package/dist/cjs/config/db-config.d.ts +134 -0
- package/dist/cjs/config/db-config.d.ts.map +1 -0
- package/dist/cjs/config/db-config.js +594 -0
- package/dist/cjs/config/db-config.js.map +1 -0
- package/dist/cjs/config/machine-config.d.ts +85 -0
- package/dist/cjs/config/machine-config.d.ts.map +1 -0
- package/dist/cjs/config/machine-config.js +232 -0
- package/dist/cjs/config/machine-config.js.map +1 -0
- package/dist/cjs/config/paths.d.ts +64 -0
- package/dist/cjs/config/paths.d.ts.map +1 -0
- package/dist/cjs/config/paths.js +155 -0
- package/dist/cjs/config/paths.js.map +1 -0
- package/dist/cjs/config/schema.d.ts +72 -0
- package/dist/cjs/config/schema.d.ts.map +1 -0
- package/dist/cjs/config/schema.js +197 -0
- package/dist/cjs/config/schema.js.map +1 -0
- package/dist/cjs/config/token.d.ts +63 -0
- package/dist/cjs/config/token.d.ts.map +1 -0
- package/dist/cjs/config/token.js +146 -0
- package/dist/cjs/config/token.js.map +1 -0
- package/dist/cjs/execution/canceller.d.ts +41 -0
- package/dist/cjs/execution/canceller.d.ts.map +1 -0
- package/dist/cjs/execution/canceller.js +209 -0
- package/dist/cjs/execution/canceller.js.map +1 -0
- package/dist/cjs/execution/database-lookup.d.ts +56 -0
- package/dist/cjs/execution/database-lookup.d.ts.map +1 -0
- package/dist/cjs/execution/database-lookup.js +43 -0
- package/dist/cjs/execution/database-lookup.js.map +1 -0
- package/dist/cjs/execution/dispatcher.d.ts +181 -0
- package/dist/cjs/execution/dispatcher.d.ts.map +1 -0
- package/dist/cjs/execution/dispatcher.js +1296 -0
- package/dist/cjs/execution/dispatcher.js.map +1 -0
- package/dist/cjs/execution/function-effects.d.ts +209 -0
- package/dist/cjs/execution/function-effects.d.ts.map +1 -0
- package/dist/cjs/execution/function-effects.js +596 -0
- package/dist/cjs/execution/function-effects.js.map +1 -0
- package/dist/cjs/execution/introspection.d.ts +76 -0
- package/dist/cjs/execution/introspection.d.ts.map +1 -0
- package/dist/cjs/execution/introspection.js +448 -0
- package/dist/cjs/execution/introspection.js.map +1 -0
- package/dist/cjs/execution/migration-runner.d.ts +128 -0
- package/dist/cjs/execution/migration-runner.d.ts.map +1 -0
- package/dist/cjs/execution/migration-runner.js +798 -0
- package/dist/cjs/execution/migration-runner.js.map +1 -0
- package/dist/cjs/execution/non-tx-detector.d.ts +23 -0
- package/dist/cjs/execution/non-tx-detector.d.ts.map +1 -0
- package/dist/cjs/execution/non-tx-detector.js +218 -0
- package/dist/cjs/execution/non-tx-detector.js.map +1 -0
- package/dist/cjs/execution/pool.d.ts +229 -0
- package/dist/cjs/execution/pool.d.ts.map +1 -0
- package/dist/cjs/execution/pool.js +738 -0
- package/dist/cjs/execution/pool.js.map +1 -0
- package/dist/cjs/execution/query-runner.d.ts +88 -0
- package/dist/cjs/execution/query-runner.d.ts.map +1 -0
- package/dist/cjs/execution/query-runner.js +751 -0
- package/dist/cjs/execution/query-runner.js.map +1 -0
- package/dist/cjs/execution/rate-limiter.d.ts +120 -0
- package/dist/cjs/execution/rate-limiter.d.ts.map +1 -0
- package/dist/cjs/execution/rate-limiter.js +273 -0
- package/dist/cjs/execution/rate-limiter.js.map +1 -0
- package/dist/cjs/execution/search-path.d.ts +161 -0
- package/dist/cjs/execution/search-path.d.ts.map +1 -0
- package/dist/cjs/execution/search-path.js +279 -0
- package/dist/cjs/execution/search-path.js.map +1 -0
- package/dist/cjs/execution/sql-parser.d.ts +195 -0
- package/dist/cjs/execution/sql-parser.d.ts.map +1 -0
- package/dist/cjs/execution/sql-parser.js +704 -0
- package/dist/cjs/execution/sql-parser.js.map +1 -0
- package/dist/cjs/execution/statement-classifier.d.ts +103 -0
- package/dist/cjs/execution/statement-classifier.d.ts.map +1 -0
- package/dist/cjs/execution/statement-classifier.js +535 -0
- package/dist/cjs/execution/statement-classifier.js.map +1 -0
- package/dist/cjs/execution/types.d.ts +189 -0
- package/dist/cjs/execution/types.d.ts.map +1 -0
- package/dist/cjs/execution/types.js +28 -0
- package/dist/cjs/execution/types.js.map +1 -0
- package/dist/cjs/index.d.ts +34 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +98 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/permissions/auto-upgrade.d.ts +40 -0
- package/dist/cjs/permissions/auto-upgrade.d.ts.map +1 -0
- package/dist/cjs/permissions/auto-upgrade.js +168 -0
- package/dist/cjs/permissions/auto-upgrade.js.map +1 -0
- package/dist/cjs/permissions/checker.d.ts +53 -0
- package/dist/cjs/permissions/checker.d.ts.map +1 -0
- package/dist/cjs/permissions/checker.js +326 -0
- package/dist/cjs/permissions/checker.js.map +1 -0
- package/dist/cjs/permissions/manual-approval.d.ts +213 -0
- package/dist/cjs/permissions/manual-approval.d.ts.map +1 -0
- package/dist/cjs/permissions/manual-approval.js +541 -0
- package/dist/cjs/permissions/manual-approval.js.map +1 -0
- package/dist/cjs/permissions/plan-registry.d.ts +274 -0
- package/dist/cjs/permissions/plan-registry.d.ts.map +1 -0
- package/dist/cjs/permissions/plan-registry.js +454 -0
- package/dist/cjs/permissions/plan-registry.js.map +1 -0
- package/dist/cjs/permissions/role-policy.d.ts +217 -0
- package/dist/cjs/permissions/role-policy.d.ts.map +1 -0
- package/dist/cjs/permissions/role-policy.js +584 -0
- package/dist/cjs/permissions/role-policy.js.map +1 -0
- package/dist/cjs/permissions/types.d.ts +126 -0
- package/dist/cjs/permissions/types.d.ts.map +1 -0
- package/dist/cjs/permissions/types.js +3 -0
- package/dist/cjs/permissions/types.js.map +1 -0
- package/dist/cjs/protocol/constants.d.ts +72 -0
- package/dist/cjs/protocol/constants.d.ts.map +1 -0
- package/dist/cjs/protocol/constants.js +107 -0
- package/dist/cjs/protocol/constants.js.map +1 -0
- package/dist/cjs/protocol/envelope.d.ts +165 -0
- package/dist/cjs/protocol/envelope.d.ts.map +1 -0
- package/dist/cjs/protocol/envelope.js +309 -0
- package/dist/cjs/protocol/envelope.js.map +1 -0
- package/dist/cjs/protocol/errors.d.ts +33 -0
- package/dist/cjs/protocol/errors.d.ts.map +1 -0
- package/dist/cjs/protocol/errors.js +391 -0
- package/dist/cjs/protocol/errors.js.map +1 -0
- package/dist/cjs/protocol/messages.d.ts +327 -0
- package/dist/cjs/protocol/messages.d.ts.map +1 -0
- package/dist/cjs/protocol/messages.js +3 -0
- package/dist/cjs/protocol/messages.js.map +1 -0
- package/dist/cjs/protocol/serialize.d.ts +26 -0
- package/dist/cjs/protocol/serialize.d.ts.map +1 -0
- package/dist/cjs/protocol/serialize.js +71 -0
- package/dist/cjs/protocol/serialize.js.map +1 -0
- package/dist/cjs/protocol/validate.d.ts +135 -0
- package/dist/cjs/protocol/validate.d.ts.map +1 -0
- package/dist/cjs/protocol/validate.js +852 -0
- package/dist/cjs/protocol/validate.js.map +1 -0
- package/dist/esm/audit/chain.d.ts +365 -0
- package/dist/esm/audit/chain.d.ts.map +1 -0
- package/dist/esm/audit/chain.js +895 -0
- package/dist/esm/audit/chain.js.map +1 -0
- package/dist/esm/audit/cloud-client.d.ts +142 -0
- package/dist/esm/audit/cloud-client.d.ts.map +1 -0
- package/dist/esm/audit/cloud-client.js +326 -0
- package/dist/esm/audit/cloud-client.js.map +1 -0
- package/dist/esm/audit/cloud-writer.d.ts +57 -0
- package/dist/esm/audit/cloud-writer.d.ts.map +1 -0
- package/dist/esm/audit/cloud-writer.js +91 -0
- package/dist/esm/audit/cloud-writer.js.map +1 -0
- package/dist/esm/audit/context.d.ts +51 -0
- package/dist/esm/audit/context.d.ts.map +1 -0
- package/dist/esm/audit/context.js +69 -0
- package/dist/esm/audit/context.js.map +1 -0
- package/dist/esm/audit/files.d.ts +111 -0
- package/dist/esm/audit/files.d.ts.map +1 -0
- package/dist/esm/audit/files.js +361 -0
- package/dist/esm/audit/files.js.map +1 -0
- package/dist/esm/audit/index.d.ts +9 -0
- package/dist/esm/audit/index.d.ts.map +1 -0
- package/dist/esm/audit/index.js +8 -0
- package/dist/esm/audit/index.js.map +1 -0
- package/dist/esm/audit/local-writer.d.ts +255 -0
- package/dist/esm/audit/local-writer.d.ts.map +1 -0
- package/dist/esm/audit/local-writer.js +785 -0
- package/dist/esm/audit/local-writer.js.map +1 -0
- package/dist/esm/audit/redact.d.ts +151 -0
- package/dist/esm/audit/redact.d.ts.map +1 -0
- package/dist/esm/audit/redact.js +506 -0
- package/dist/esm/audit/redact.js.map +1 -0
- package/dist/esm/audit/sanitize.d.ts +78 -0
- package/dist/esm/audit/sanitize.d.ts.map +1 -0
- package/dist/esm/audit/sanitize.js +307 -0
- package/dist/esm/audit/sanitize.js.map +1 -0
- package/dist/esm/audit/sink.d.ts +278 -0
- package/dist/esm/audit/sink.d.ts.map +1 -0
- package/dist/esm/audit/sink.js +782 -0
- package/dist/esm/audit/sink.js.map +1 -0
- package/dist/esm/audit/types.d.ts +226 -0
- package/dist/esm/audit/types.d.ts.map +1 -0
- package/dist/esm/audit/types.js +2 -0
- package/dist/esm/audit/types.js.map +1 -0
- package/dist/esm/audit/verify-cache.d.ts +127 -0
- package/dist/esm/audit/verify-cache.d.ts.map +1 -0
- package/dist/esm/audit/verify-cache.js +628 -0
- package/dist/esm/audit/verify-cache.js.map +1 -0
- package/dist/esm/channels/agent-session.d.ts +228 -0
- package/dist/esm/channels/agent-session.d.ts.map +1 -0
- package/dist/esm/channels/agent-session.js +566 -0
- package/dist/esm/channels/agent-session.js.map +1 -0
- package/dist/esm/channels/data-channel.d.ts +181 -0
- package/dist/esm/channels/data-channel.d.ts.map +1 -0
- package/dist/esm/channels/data-channel.js +567 -0
- package/dist/esm/channels/data-channel.js.map +1 -0
- package/dist/esm/channels/reconnect.d.ts +142 -0
- package/dist/esm/channels/reconnect.d.ts.map +1 -0
- package/dist/esm/channels/reconnect.js +234 -0
- package/dist/esm/channels/reconnect.js.map +1 -0
- package/dist/esm/channels/types.d.ts +112 -0
- package/dist/esm/channels/types.d.ts.map +1 -0
- package/dist/esm/channels/types.js +2 -0
- package/dist/esm/channels/types.js.map +1 -0
- package/dist/esm/channels/wake-channel.d.ts +232 -0
- package/dist/esm/channels/wake-channel.d.ts.map +1 -0
- package/dist/esm/channels/wake-channel.js +715 -0
- package/dist/esm/channels/wake-channel.js.map +1 -0
- package/dist/esm/cli/banner.d.ts +2 -0
- package/dist/esm/cli/banner.d.ts.map +1 -0
- package/dist/esm/cli/banner.js +114 -0
- package/dist/esm/cli/banner.js.map +1 -0
- package/dist/esm/cli/commands/agent.d.ts +30 -0
- package/dist/esm/cli/commands/agent.d.ts.map +1 -0
- package/dist/esm/cli/commands/agent.js +204 -0
- package/dist/esm/cli/commands/agent.js.map +1 -0
- package/dist/esm/cli/commands/audit-verify.d.ts +19 -0
- package/dist/esm/cli/commands/audit-verify.d.ts.map +1 -0
- package/dist/esm/cli/commands/audit-verify.js +345 -0
- package/dist/esm/cli/commands/audit-verify.js.map +1 -0
- package/dist/esm/cli/commands/clean.d.ts +23 -0
- package/dist/esm/cli/commands/clean.d.ts.map +1 -0
- package/dist/esm/cli/commands/clean.js +235 -0
- package/dist/esm/cli/commands/clean.js.map +1 -0
- package/dist/esm/cli/commands/config-show.d.ts +2 -0
- package/dist/esm/cli/commands/config-show.d.ts.map +1 -0
- package/dist/esm/cli/commands/config-show.js +2 -0
- package/dist/esm/cli/commands/config-show.js.map +1 -0
- package/dist/esm/cli/commands/config.d.ts +6 -0
- package/dist/esm/cli/commands/config.d.ts.map +1 -0
- package/dist/esm/cli/commands/config.js +259 -0
- package/dist/esm/cli/commands/config.js.map +1 -0
- package/dist/esm/cli/commands/db-add.d.ts +16 -0
- package/dist/esm/cli/commands/db-add.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-add.js +576 -0
- package/dist/esm/cli/commands/db-add.js.map +1 -0
- package/dist/esm/cli/commands/db-edit.d.ts +2 -0
- package/dist/esm/cli/commands/db-edit.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-edit.js +352 -0
- package/dist/esm/cli/commands/db-edit.js.map +1 -0
- package/dist/esm/cli/commands/db-logs.d.ts +3 -0
- package/dist/esm/cli/commands/db-logs.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-logs.js +64 -0
- package/dist/esm/cli/commands/db-logs.js.map +1 -0
- package/dist/esm/cli/commands/db-ls.d.ts +2 -0
- package/dist/esm/cli/commands/db-ls.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-ls.js +115 -0
- package/dist/esm/cli/commands/db-ls.js.map +1 -0
- package/dist/esm/cli/commands/db-query.d.ts +121 -0
- package/dist/esm/cli/commands/db-query.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-query.js +754 -0
- package/dist/esm/cli/commands/db-query.js.map +1 -0
- package/dist/esm/cli/commands/db-remove.d.ts +2 -0
- package/dist/esm/cli/commands/db-remove.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-remove.js +48 -0
- package/dist/esm/cli/commands/db-remove.js.map +1 -0
- package/dist/esm/cli/commands/db-show.d.ts +2 -0
- package/dist/esm/cli/commands/db-show.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-show.js +131 -0
- package/dist/esm/cli/commands/db-show.js.map +1 -0
- package/dist/esm/cli/commands/db-test.d.ts +3 -0
- package/dist/esm/cli/commands/db-test.d.ts.map +1 -0
- package/dist/esm/cli/commands/db-test.js +307 -0
- package/dist/esm/cli/commands/db-test.js.map +1 -0
- package/dist/esm/cli/commands/db.d.ts +11 -0
- package/dist/esm/cli/commands/db.d.ts.map +1 -0
- package/dist/esm/cli/commands/db.js +76 -0
- package/dist/esm/cli/commands/db.js.map +1 -0
- package/dist/esm/cli/commands/debug.d.ts +2 -0
- package/dist/esm/cli/commands/debug.d.ts.map +1 -0
- package/dist/esm/cli/commands/debug.js +205 -0
- package/dist/esm/cli/commands/debug.js.map +1 -0
- package/dist/esm/cli/commands/doctor.d.ts +5 -0
- package/dist/esm/cli/commands/doctor.d.ts.map +1 -0
- package/dist/esm/cli/commands/doctor.js +114 -0
- package/dist/esm/cli/commands/doctor.js.map +1 -0
- package/dist/esm/cli/commands/index.d.ts +10 -0
- package/dist/esm/cli/commands/index.d.ts.map +1 -0
- package/dist/esm/cli/commands/index.js +10 -0
- package/dist/esm/cli/commands/index.js.map +1 -0
- package/dist/esm/cli/commands/init.d.ts +2 -0
- package/dist/esm/cli/commands/init.d.ts.map +1 -0
- package/dist/esm/cli/commands/init.js +163 -0
- package/dist/esm/cli/commands/init.js.map +1 -0
- package/dist/esm/cli/commands/link.d.ts +5 -0
- package/dist/esm/cli/commands/link.d.ts.map +1 -0
- package/dist/esm/cli/commands/link.js +41 -0
- package/dist/esm/cli/commands/link.js.map +1 -0
- package/dist/esm/cli/commands/logs.d.ts +17 -0
- package/dist/esm/cli/commands/logs.d.ts.map +1 -0
- package/dist/esm/cli/commands/logs.js +278 -0
- package/dist/esm/cli/commands/logs.js.map +1 -0
- package/dist/esm/cli/commands/project-show.d.ts +2 -0
- package/dist/esm/cli/commands/project-show.d.ts.map +1 -0
- package/dist/esm/cli/commands/project-show.js +69 -0
- package/dist/esm/cli/commands/project-show.js.map +1 -0
- package/dist/esm/cli/commands/project.d.ts +3 -0
- package/dist/esm/cli/commands/project.d.ts.map +1 -0
- package/dist/esm/cli/commands/project.js +60 -0
- package/dist/esm/cli/commands/project.js.map +1 -0
- package/dist/esm/cli/commands/service.d.ts +123 -0
- package/dist/esm/cli/commands/service.d.ts.map +1 -0
- package/dist/esm/cli/commands/service.js +505 -0
- package/dist/esm/cli/commands/service.js.map +1 -0
- package/dist/esm/cli/commands/start.d.ts +6 -0
- package/dist/esm/cli/commands/start.d.ts.map +1 -0
- package/dist/esm/cli/commands/start.js +272 -0
- package/dist/esm/cli/commands/start.js.map +1 -0
- package/dist/esm/cli/commands/status.d.ts +2 -0
- package/dist/esm/cli/commands/status.d.ts.map +1 -0
- package/dist/esm/cli/commands/status.js +222 -0
- package/dist/esm/cli/commands/status.js.map +1 -0
- package/dist/esm/cli/commands/stop.d.ts +6 -0
- package/dist/esm/cli/commands/stop.d.ts.map +1 -0
- package/dist/esm/cli/commands/stop.js +96 -0
- package/dist/esm/cli/commands/stop.js.map +1 -0
- package/dist/esm/cli/daemon/error-tracker.d.ts +119 -0
- package/dist/esm/cli/daemon/error-tracker.d.ts.map +1 -0
- package/dist/esm/cli/daemon/error-tracker.js +451 -0
- package/dist/esm/cli/daemon/error-tracker.js.map +1 -0
- package/dist/esm/cli/daemon/fault-shutdown.d.ts +144 -0
- package/dist/esm/cli/daemon/fault-shutdown.d.ts.map +1 -0
- package/dist/esm/cli/daemon/fault-shutdown.js +273 -0
- package/dist/esm/cli/daemon/fault-shutdown.js.map +1 -0
- package/dist/esm/cli/daemon/index.d.ts +12 -0
- package/dist/esm/cli/daemon/index.d.ts.map +1 -0
- package/dist/esm/cli/daemon/index.js +7 -0
- package/dist/esm/cli/daemon/index.js.map +1 -0
- package/dist/esm/cli/daemon/pid-file.d.ts +13 -0
- package/dist/esm/cli/daemon/pid-file.d.ts.map +1 -0
- package/dist/esm/cli/daemon/pid-file.js +51 -0
- package/dist/esm/cli/daemon/pid-file.js.map +1 -0
- package/dist/esm/cli/daemon/readiness.d.ts +30 -0
- package/dist/esm/cli/daemon/readiness.d.ts.map +1 -0
- package/dist/esm/cli/daemon/readiness.js +70 -0
- package/dist/esm/cli/daemon/readiness.js.map +1 -0
- package/dist/esm/cli/daemon/runtime.d.ts +366 -0
- package/dist/esm/cli/daemon/runtime.d.ts.map +1 -0
- package/dist/esm/cli/daemon/runtime.js +1284 -0
- package/dist/esm/cli/daemon/runtime.js.map +1 -0
- package/dist/esm/cli/daemon/shutdown.d.ts +7 -0
- package/dist/esm/cli/daemon/shutdown.d.ts.map +1 -0
- package/dist/esm/cli/daemon/shutdown.js +63 -0
- package/dist/esm/cli/daemon/shutdown.js.map +1 -0
- package/dist/esm/cli/daemon/signal-handlers.d.ts +3 -0
- package/dist/esm/cli/daemon/signal-handlers.d.ts.map +1 -0
- package/dist/esm/cli/daemon/signal-handlers.js +24 -0
- package/dist/esm/cli/daemon/signal-handlers.js.map +1 -0
- package/dist/esm/cli/daemon/state.d.ts +157 -0
- package/dist/esm/cli/daemon/state.d.ts.map +1 -0
- package/dist/esm/cli/daemon/state.js +352 -0
- package/dist/esm/cli/daemon/state.js.map +1 -0
- package/dist/esm/cli/daemon/status-file.d.ts +139 -0
- package/dist/esm/cli/daemon/status-file.d.ts.map +1 -0
- package/dist/esm/cli/daemon/status-file.js +50 -0
- package/dist/esm/cli/daemon/status-file.js.map +1 -0
- package/dist/esm/cli/doctor/checks.d.ts +133 -0
- package/dist/esm/cli/doctor/checks.d.ts.map +1 -0
- package/dist/esm/cli/doctor/checks.js +624 -0
- package/dist/esm/cli/doctor/checks.js.map +1 -0
- package/dist/esm/cli/doctor/fixes.d.ts +9 -0
- package/dist/esm/cli/doctor/fixes.d.ts.map +1 -0
- package/dist/esm/cli/doctor/fixes.js +163 -0
- package/dist/esm/cli/doctor/fixes.js.map +1 -0
- package/dist/esm/cli/doctor/index.d.ts +7 -0
- package/dist/esm/cli/doctor/index.d.ts.map +1 -0
- package/dist/esm/cli/doctor/index.js +5 -0
- package/dist/esm/cli/doctor/index.js.map +1 -0
- package/dist/esm/cli/index.d.ts +3 -0
- package/dist/esm/cli/index.d.ts.map +1 -0
- package/dist/esm/cli/index.js +333 -0
- package/dist/esm/cli/index.js.map +1 -0
- package/dist/esm/cli/interactive.d.ts +8 -0
- package/dist/esm/cli/interactive.d.ts.map +1 -0
- package/dist/esm/cli/interactive.js +665 -0
- package/dist/esm/cli/interactive.js.map +1 -0
- package/dist/esm/cli/logs/format.d.ts +13 -0
- package/dist/esm/cli/logs/format.d.ts.map +1 -0
- package/dist/esm/cli/logs/format.js +169 -0
- package/dist/esm/cli/logs/format.js.map +1 -0
- package/dist/esm/cli/logs/index.d.ts +3 -0
- package/dist/esm/cli/logs/index.d.ts.map +1 -0
- package/dist/esm/cli/logs/index.js +3 -0
- package/dist/esm/cli/logs/index.js.map +1 -0
- package/dist/esm/cli/logs/viewer.d.ts +41 -0
- package/dist/esm/cli/logs/viewer.d.ts.map +1 -0
- package/dist/esm/cli/logs/viewer.js +412 -0
- package/dist/esm/cli/logs/viewer.js.map +1 -0
- package/dist/esm/cli/ops/operation-logger.d.ts +63 -0
- package/dist/esm/cli/ops/operation-logger.d.ts.map +1 -0
- package/dist/esm/cli/ops/operation-logger.js +142 -0
- package/dist/esm/cli/ops/operation-logger.js.map +1 -0
- package/dist/esm/cli/palette.d.ts +11 -0
- package/dist/esm/cli/palette.d.ts.map +1 -0
- package/dist/esm/cli/palette.js +240 -0
- package/dist/esm/cli/palette.js.map +1 -0
- package/dist/esm/cli/prompt.d.ts +186 -0
- package/dist/esm/cli/prompt.d.ts.map +1 -0
- package/dist/esm/cli/prompt.js +483 -0
- package/dist/esm/cli/prompt.js.map +1 -0
- package/dist/esm/cli/ui/box.d.ts +21 -0
- package/dist/esm/cli/ui/box.d.ts.map +1 -0
- package/dist/esm/cli/ui/box.js +60 -0
- package/dist/esm/cli/ui/box.js.map +1 -0
- package/dist/esm/cli/ui/clipboard.d.ts +6 -0
- package/dist/esm/cli/ui/clipboard.d.ts.map +1 -0
- package/dist/esm/cli/ui/clipboard.js +42 -0
- package/dist/esm/cli/ui/clipboard.js.map +1 -0
- package/dist/esm/cli/ui/colors.d.ts +57 -0
- package/dist/esm/cli/ui/colors.d.ts.map +1 -0
- package/dist/esm/cli/ui/colors.js +126 -0
- package/dist/esm/cli/ui/colors.js.map +1 -0
- package/dist/esm/cli/ui/index.d.ts +9 -0
- package/dist/esm/cli/ui/index.d.ts.map +1 -0
- package/dist/esm/cli/ui/index.js +7 -0
- package/dist/esm/cli/ui/index.js.map +1 -0
- package/dist/esm/cli/ui/spinner.d.ts +12 -0
- package/dist/esm/cli/ui/spinner.d.ts.map +1 -0
- package/dist/esm/cli/ui/spinner.js +78 -0
- package/dist/esm/cli/ui/spinner.js.map +1 -0
- package/dist/esm/cli/ui/symbols.d.ts +47 -0
- package/dist/esm/cli/ui/symbols.d.ts.map +1 -0
- package/dist/esm/cli/ui/symbols.js +109 -0
- package/dist/esm/cli/ui/symbols.js.map +1 -0
- package/dist/esm/cli/ui/table.d.ts +23 -0
- package/dist/esm/cli/ui/table.d.ts.map +1 -0
- package/dist/esm/cli/ui/table.js +156 -0
- package/dist/esm/cli/ui/table.js.map +1 -0
- package/dist/esm/cli/ui/terminal.d.ts +7 -0
- package/dist/esm/cli/ui/terminal.d.ts.map +1 -0
- package/dist/esm/cli/ui/terminal.js +32 -0
- package/dist/esm/cli/ui/terminal.js.map +1 -0
- package/dist/esm/config/atomic-write.d.ts +69 -0
- package/dist/esm/config/atomic-write.d.ts.map +1 -0
- package/dist/esm/config/atomic-write.js +246 -0
- package/dist/esm/config/atomic-write.js.map +1 -0
- package/dist/esm/config/db-config.d.ts +134 -0
- package/dist/esm/config/db-config.d.ts.map +1 -0
- package/dist/esm/config/db-config.js +542 -0
- package/dist/esm/config/db-config.js.map +1 -0
- package/dist/esm/config/machine-config.d.ts +85 -0
- package/dist/esm/config/machine-config.d.ts.map +1 -0
- package/dist/esm/config/machine-config.js +190 -0
- package/dist/esm/config/machine-config.js.map +1 -0
- package/dist/esm/config/paths.d.ts +64 -0
- package/dist/esm/config/paths.d.ts.map +1 -0
- package/dist/esm/config/paths.js +108 -0
- package/dist/esm/config/paths.js.map +1 -0
- package/dist/esm/config/schema.d.ts +72 -0
- package/dist/esm/config/schema.d.ts.map +1 -0
- package/dist/esm/config/schema.js +180 -0
- package/dist/esm/config/schema.js.map +1 -0
- package/dist/esm/config/token.d.ts +63 -0
- package/dist/esm/config/token.d.ts.map +1 -0
- package/dist/esm/config/token.js +104 -0
- package/dist/esm/config/token.js.map +1 -0
- package/dist/esm/execution/canceller.d.ts +41 -0
- package/dist/esm/execution/canceller.d.ts.map +1 -0
- package/dist/esm/execution/canceller.js +205 -0
- package/dist/esm/execution/canceller.js.map +1 -0
- package/dist/esm/execution/database-lookup.d.ts +56 -0
- package/dist/esm/execution/database-lookup.d.ts.map +1 -0
- package/dist/esm/execution/database-lookup.js +38 -0
- package/dist/esm/execution/database-lookup.js.map +1 -0
- package/dist/esm/execution/dispatcher.d.ts +181 -0
- package/dist/esm/execution/dispatcher.d.ts.map +1 -0
- package/dist/esm/execution/dispatcher.js +1258 -0
- package/dist/esm/execution/dispatcher.js.map +1 -0
- package/dist/esm/execution/function-effects.d.ts +209 -0
- package/dist/esm/execution/function-effects.d.ts.map +1 -0
- package/dist/esm/execution/function-effects.js +586 -0
- package/dist/esm/execution/function-effects.js.map +1 -0
- package/dist/esm/execution/introspection.d.ts +76 -0
- package/dist/esm/execution/introspection.d.ts.map +1 -0
- package/dist/esm/execution/introspection.js +442 -0
- package/dist/esm/execution/introspection.js.map +1 -0
- package/dist/esm/execution/migration-runner.d.ts +128 -0
- package/dist/esm/execution/migration-runner.d.ts.map +1 -0
- package/dist/esm/execution/migration-runner.js +754 -0
- package/dist/esm/execution/migration-runner.js.map +1 -0
- package/dist/esm/execution/non-tx-detector.d.ts +23 -0
- package/dist/esm/execution/non-tx-detector.d.ts.map +1 -0
- package/dist/esm/execution/non-tx-detector.js +215 -0
- package/dist/esm/execution/non-tx-detector.js.map +1 -0
- package/dist/esm/execution/pool.d.ts +229 -0
- package/dist/esm/execution/pool.d.ts.map +1 -0
- package/dist/esm/execution/pool.js +685 -0
- package/dist/esm/execution/pool.js.map +1 -0
- package/dist/esm/execution/query-runner.d.ts +88 -0
- package/dist/esm/execution/query-runner.d.ts.map +1 -0
- package/dist/esm/execution/query-runner.js +743 -0
- package/dist/esm/execution/query-runner.js.map +1 -0
- package/dist/esm/execution/rate-limiter.d.ts +120 -0
- package/dist/esm/execution/rate-limiter.d.ts.map +1 -0
- package/dist/esm/execution/rate-limiter.js +269 -0
- package/dist/esm/execution/rate-limiter.js.map +1 -0
- package/dist/esm/execution/search-path.d.ts +161 -0
- package/dist/esm/execution/search-path.d.ts.map +1 -0
- package/dist/esm/execution/search-path.js +270 -0
- package/dist/esm/execution/search-path.js.map +1 -0
- package/dist/esm/execution/sql-parser.d.ts +195 -0
- package/dist/esm/execution/sql-parser.d.ts.map +1 -0
- package/dist/esm/execution/sql-parser.js +683 -0
- package/dist/esm/execution/sql-parser.js.map +1 -0
- package/dist/esm/execution/statement-classifier.d.ts +103 -0
- package/dist/esm/execution/statement-classifier.d.ts.map +1 -0
- package/dist/esm/execution/statement-classifier.js +526 -0
- package/dist/esm/execution/statement-classifier.js.map +1 -0
- package/dist/esm/execution/types.d.ts +189 -0
- package/dist/esm/execution/types.d.ts.map +1 -0
- package/dist/esm/execution/types.js +22 -0
- package/dist/esm/execution/types.js.map +1 -0
- package/dist/esm/index.d.ts +34 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +38 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/permissions/auto-upgrade.d.ts +40 -0
- package/dist/esm/permissions/auto-upgrade.d.ts.map +1 -0
- package/dist/esm/permissions/auto-upgrade.js +164 -0
- package/dist/esm/permissions/auto-upgrade.js.map +1 -0
- package/dist/esm/permissions/checker.d.ts +53 -0
- package/dist/esm/permissions/checker.d.ts.map +1 -0
- package/dist/esm/permissions/checker.js +322 -0
- package/dist/esm/permissions/checker.js.map +1 -0
- package/dist/esm/permissions/manual-approval.d.ts +213 -0
- package/dist/esm/permissions/manual-approval.d.ts.map +1 -0
- package/dist/esm/permissions/manual-approval.js +503 -0
- package/dist/esm/permissions/manual-approval.js.map +1 -0
- package/dist/esm/permissions/plan-registry.d.ts +274 -0
- package/dist/esm/permissions/plan-registry.d.ts.map +1 -0
- package/dist/esm/permissions/plan-registry.js +450 -0
- package/dist/esm/permissions/plan-registry.js.map +1 -0
- package/dist/esm/permissions/role-policy.d.ts +217 -0
- package/dist/esm/permissions/role-policy.d.ts.map +1 -0
- package/dist/esm/permissions/role-policy.js +570 -0
- package/dist/esm/permissions/role-policy.js.map +1 -0
- package/dist/esm/permissions/types.d.ts +126 -0
- package/dist/esm/permissions/types.d.ts.map +1 -0
- package/dist/esm/permissions/types.js +2 -0
- package/dist/esm/permissions/types.js.map +1 -0
- package/dist/esm/protocol/constants.d.ts +72 -0
- package/dist/esm/protocol/constants.d.ts.map +1 -0
- package/dist/esm/protocol/constants.js +104 -0
- package/dist/esm/protocol/constants.js.map +1 -0
- package/dist/esm/protocol/envelope.d.ts +165 -0
- package/dist/esm/protocol/envelope.d.ts.map +1 -0
- package/dist/esm/protocol/envelope.js +263 -0
- package/dist/esm/protocol/envelope.js.map +1 -0
- package/dist/esm/protocol/errors.d.ts +33 -0
- package/dist/esm/protocol/errors.d.ts.map +1 -0
- package/dist/esm/protocol/errors.js +384 -0
- package/dist/esm/protocol/errors.js.map +1 -0
- package/dist/esm/protocol/messages.d.ts +327 -0
- package/dist/esm/protocol/messages.d.ts.map +1 -0
- package/dist/esm/protocol/messages.js +2 -0
- package/dist/esm/protocol/messages.js.map +1 -0
- package/dist/esm/protocol/serialize.d.ts +26 -0
- package/dist/esm/protocol/serialize.d.ts.map +1 -0
- package/dist/esm/protocol/serialize.js +63 -0
- package/dist/esm/protocol/serialize.js.map +1 -0
- package/dist/esm/protocol/validate.d.ts +135 -0
- package/dist/esm/protocol/validate.d.ts.map +1 -0
- package/dist/esm/protocol/validate.js +830 -0
- package/dist/esm/protocol/validate.js.map +1 -0
- package/dist/types/audit/chain.d.ts +365 -0
- package/dist/types/audit/chain.d.ts.map +1 -0
- package/dist/types/audit/cloud-client.d.ts +142 -0
- package/dist/types/audit/cloud-client.d.ts.map +1 -0
- package/dist/types/audit/cloud-writer.d.ts +57 -0
- package/dist/types/audit/cloud-writer.d.ts.map +1 -0
- package/dist/types/audit/context.d.ts +51 -0
- package/dist/types/audit/context.d.ts.map +1 -0
- package/dist/types/audit/files.d.ts +111 -0
- package/dist/types/audit/files.d.ts.map +1 -0
- package/dist/types/audit/index.d.ts +9 -0
- package/dist/types/audit/index.d.ts.map +1 -0
- package/dist/types/audit/local-writer.d.ts +255 -0
- package/dist/types/audit/local-writer.d.ts.map +1 -0
- package/dist/types/audit/redact.d.ts +151 -0
- package/dist/types/audit/redact.d.ts.map +1 -0
- package/dist/types/audit/sanitize.d.ts +78 -0
- package/dist/types/audit/sanitize.d.ts.map +1 -0
- package/dist/types/audit/sink.d.ts +278 -0
- package/dist/types/audit/sink.d.ts.map +1 -0
- package/dist/types/audit/types.d.ts +226 -0
- package/dist/types/audit/types.d.ts.map +1 -0
- package/dist/types/audit/verify-cache.d.ts +127 -0
- package/dist/types/audit/verify-cache.d.ts.map +1 -0
- package/dist/types/channels/agent-session.d.ts +228 -0
- package/dist/types/channels/agent-session.d.ts.map +1 -0
- package/dist/types/channels/data-channel.d.ts +181 -0
- package/dist/types/channels/data-channel.d.ts.map +1 -0
- package/dist/types/channels/reconnect.d.ts +142 -0
- package/dist/types/channels/reconnect.d.ts.map +1 -0
- package/dist/types/channels/types.d.ts +112 -0
- package/dist/types/channels/types.d.ts.map +1 -0
- package/dist/types/channels/wake-channel.d.ts +232 -0
- package/dist/types/channels/wake-channel.d.ts.map +1 -0
- package/dist/types/cli/banner.d.ts +2 -0
- package/dist/types/cli/banner.d.ts.map +1 -0
- package/dist/types/cli/commands/agent.d.ts +30 -0
- package/dist/types/cli/commands/agent.d.ts.map +1 -0
- package/dist/types/cli/commands/audit-verify.d.ts +19 -0
- package/dist/types/cli/commands/audit-verify.d.ts.map +1 -0
- package/dist/types/cli/commands/clean.d.ts +23 -0
- package/dist/types/cli/commands/clean.d.ts.map +1 -0
- package/dist/types/cli/commands/config-show.d.ts +2 -0
- package/dist/types/cli/commands/config-show.d.ts.map +1 -0
- package/dist/types/cli/commands/config.d.ts +6 -0
- package/dist/types/cli/commands/config.d.ts.map +1 -0
- package/dist/types/cli/commands/db-add.d.ts +16 -0
- package/dist/types/cli/commands/db-add.d.ts.map +1 -0
- package/dist/types/cli/commands/db-edit.d.ts +2 -0
- package/dist/types/cli/commands/db-edit.d.ts.map +1 -0
- package/dist/types/cli/commands/db-logs.d.ts +3 -0
- package/dist/types/cli/commands/db-logs.d.ts.map +1 -0
- package/dist/types/cli/commands/db-ls.d.ts +2 -0
- package/dist/types/cli/commands/db-ls.d.ts.map +1 -0
- package/dist/types/cli/commands/db-query.d.ts +121 -0
- package/dist/types/cli/commands/db-query.d.ts.map +1 -0
- package/dist/types/cli/commands/db-remove.d.ts +2 -0
- package/dist/types/cli/commands/db-remove.d.ts.map +1 -0
- package/dist/types/cli/commands/db-show.d.ts +2 -0
- package/dist/types/cli/commands/db-show.d.ts.map +1 -0
- package/dist/types/cli/commands/db-test.d.ts +3 -0
- package/dist/types/cli/commands/db-test.d.ts.map +1 -0
- package/dist/types/cli/commands/db.d.ts +11 -0
- package/dist/types/cli/commands/db.d.ts.map +1 -0
- package/dist/types/cli/commands/debug.d.ts +2 -0
- package/dist/types/cli/commands/debug.d.ts.map +1 -0
- package/dist/types/cli/commands/doctor.d.ts +5 -0
- package/dist/types/cli/commands/doctor.d.ts.map +1 -0
- package/dist/types/cli/commands/index.d.ts +10 -0
- package/dist/types/cli/commands/index.d.ts.map +1 -0
- package/dist/types/cli/commands/init.d.ts +2 -0
- package/dist/types/cli/commands/init.d.ts.map +1 -0
- package/dist/types/cli/commands/link.d.ts +5 -0
- package/dist/types/cli/commands/link.d.ts.map +1 -0
- package/dist/types/cli/commands/logs.d.ts +17 -0
- package/dist/types/cli/commands/logs.d.ts.map +1 -0
- package/dist/types/cli/commands/project-show.d.ts +2 -0
- package/dist/types/cli/commands/project-show.d.ts.map +1 -0
- package/dist/types/cli/commands/project.d.ts +3 -0
- package/dist/types/cli/commands/project.d.ts.map +1 -0
- package/dist/types/cli/commands/service.d.ts +123 -0
- package/dist/types/cli/commands/service.d.ts.map +1 -0
- package/dist/types/cli/commands/start.d.ts +6 -0
- package/dist/types/cli/commands/start.d.ts.map +1 -0
- package/dist/types/cli/commands/status.d.ts +2 -0
- package/dist/types/cli/commands/status.d.ts.map +1 -0
- package/dist/types/cli/commands/stop.d.ts +6 -0
- package/dist/types/cli/commands/stop.d.ts.map +1 -0
- package/dist/types/cli/daemon/error-tracker.d.ts +119 -0
- package/dist/types/cli/daemon/error-tracker.d.ts.map +1 -0
- package/dist/types/cli/daemon/fault-shutdown.d.ts +144 -0
- package/dist/types/cli/daemon/fault-shutdown.d.ts.map +1 -0
- package/dist/types/cli/daemon/index.d.ts +12 -0
- package/dist/types/cli/daemon/index.d.ts.map +1 -0
- package/dist/types/cli/daemon/pid-file.d.ts +13 -0
- package/dist/types/cli/daemon/pid-file.d.ts.map +1 -0
- package/dist/types/cli/daemon/readiness.d.ts +30 -0
- package/dist/types/cli/daemon/readiness.d.ts.map +1 -0
- package/dist/types/cli/daemon/runtime.d.ts +366 -0
- package/dist/types/cli/daemon/runtime.d.ts.map +1 -0
- package/dist/types/cli/daemon/shutdown.d.ts +7 -0
- package/dist/types/cli/daemon/shutdown.d.ts.map +1 -0
- package/dist/types/cli/daemon/signal-handlers.d.ts +3 -0
- package/dist/types/cli/daemon/signal-handlers.d.ts.map +1 -0
- package/dist/types/cli/daemon/state.d.ts +157 -0
- package/dist/types/cli/daemon/state.d.ts.map +1 -0
- package/dist/types/cli/daemon/status-file.d.ts +139 -0
- package/dist/types/cli/daemon/status-file.d.ts.map +1 -0
- package/dist/types/cli/doctor/checks.d.ts +133 -0
- package/dist/types/cli/doctor/checks.d.ts.map +1 -0
- package/dist/types/cli/doctor/fixes.d.ts +9 -0
- package/dist/types/cli/doctor/fixes.d.ts.map +1 -0
- package/dist/types/cli/doctor/index.d.ts +7 -0
- package/dist/types/cli/doctor/index.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +3 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/cli/interactive.d.ts +8 -0
- package/dist/types/cli/interactive.d.ts.map +1 -0
- package/dist/types/cli/logs/format.d.ts +13 -0
- package/dist/types/cli/logs/format.d.ts.map +1 -0
- package/dist/types/cli/logs/index.d.ts +3 -0
- package/dist/types/cli/logs/index.d.ts.map +1 -0
- package/dist/types/cli/logs/viewer.d.ts +41 -0
- package/dist/types/cli/logs/viewer.d.ts.map +1 -0
- package/dist/types/cli/ops/operation-logger.d.ts +63 -0
- package/dist/types/cli/ops/operation-logger.d.ts.map +1 -0
- package/dist/types/cli/palette.d.ts +11 -0
- package/dist/types/cli/palette.d.ts.map +1 -0
- package/dist/types/cli/prompt.d.ts +186 -0
- package/dist/types/cli/prompt.d.ts.map +1 -0
- package/dist/types/cli/ui/box.d.ts +21 -0
- package/dist/types/cli/ui/box.d.ts.map +1 -0
- package/dist/types/cli/ui/clipboard.d.ts +6 -0
- package/dist/types/cli/ui/clipboard.d.ts.map +1 -0
- package/dist/types/cli/ui/colors.d.ts +57 -0
- package/dist/types/cli/ui/colors.d.ts.map +1 -0
- package/dist/types/cli/ui/index.d.ts +9 -0
- package/dist/types/cli/ui/index.d.ts.map +1 -0
- package/dist/types/cli/ui/spinner.d.ts +12 -0
- package/dist/types/cli/ui/spinner.d.ts.map +1 -0
- package/dist/types/cli/ui/symbols.d.ts +47 -0
- package/dist/types/cli/ui/symbols.d.ts.map +1 -0
- package/dist/types/cli/ui/table.d.ts +23 -0
- package/dist/types/cli/ui/table.d.ts.map +1 -0
- package/dist/types/cli/ui/terminal.d.ts +7 -0
- package/dist/types/cli/ui/terminal.d.ts.map +1 -0
- package/dist/types/config/atomic-write.d.ts +69 -0
- package/dist/types/config/atomic-write.d.ts.map +1 -0
- package/dist/types/config/db-config.d.ts +134 -0
- package/dist/types/config/db-config.d.ts.map +1 -0
- package/dist/types/config/machine-config.d.ts +85 -0
- package/dist/types/config/machine-config.d.ts.map +1 -0
- package/dist/types/config/paths.d.ts +64 -0
- package/dist/types/config/paths.d.ts.map +1 -0
- package/dist/types/config/schema.d.ts +72 -0
- package/dist/types/config/schema.d.ts.map +1 -0
- package/dist/types/config/token.d.ts +63 -0
- package/dist/types/config/token.d.ts.map +1 -0
- package/dist/types/execution/canceller.d.ts +41 -0
- package/dist/types/execution/canceller.d.ts.map +1 -0
- package/dist/types/execution/database-lookup.d.ts +56 -0
- package/dist/types/execution/database-lookup.d.ts.map +1 -0
- package/dist/types/execution/dispatcher.d.ts +181 -0
- package/dist/types/execution/dispatcher.d.ts.map +1 -0
- package/dist/types/execution/function-effects.d.ts +209 -0
- package/dist/types/execution/function-effects.d.ts.map +1 -0
- package/dist/types/execution/introspection.d.ts +76 -0
- package/dist/types/execution/introspection.d.ts.map +1 -0
- package/dist/types/execution/migration-runner.d.ts +128 -0
- package/dist/types/execution/migration-runner.d.ts.map +1 -0
- package/dist/types/execution/non-tx-detector.d.ts +23 -0
- package/dist/types/execution/non-tx-detector.d.ts.map +1 -0
- package/dist/types/execution/pool.d.ts +229 -0
- package/dist/types/execution/pool.d.ts.map +1 -0
- package/dist/types/execution/query-runner.d.ts +88 -0
- package/dist/types/execution/query-runner.d.ts.map +1 -0
- package/dist/types/execution/rate-limiter.d.ts +120 -0
- package/dist/types/execution/rate-limiter.d.ts.map +1 -0
- package/dist/types/execution/search-path.d.ts +161 -0
- package/dist/types/execution/search-path.d.ts.map +1 -0
- package/dist/types/execution/sql-parser.d.ts +195 -0
- package/dist/types/execution/sql-parser.d.ts.map +1 -0
- package/dist/types/execution/statement-classifier.d.ts +103 -0
- package/dist/types/execution/statement-classifier.d.ts.map +1 -0
- package/dist/types/execution/types.d.ts +189 -0
- package/dist/types/execution/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/permissions/auto-upgrade.d.ts +40 -0
- package/dist/types/permissions/auto-upgrade.d.ts.map +1 -0
- package/dist/types/permissions/checker.d.ts +53 -0
- package/dist/types/permissions/checker.d.ts.map +1 -0
- package/dist/types/permissions/manual-approval.d.ts +213 -0
- package/dist/types/permissions/manual-approval.d.ts.map +1 -0
- package/dist/types/permissions/plan-registry.d.ts +274 -0
- package/dist/types/permissions/plan-registry.d.ts.map +1 -0
- package/dist/types/permissions/role-policy.d.ts +217 -0
- package/dist/types/permissions/role-policy.d.ts.map +1 -0
- package/dist/types/permissions/types.d.ts +126 -0
- package/dist/types/permissions/types.d.ts.map +1 -0
- package/dist/types/protocol/constants.d.ts +72 -0
- package/dist/types/protocol/constants.d.ts.map +1 -0
- package/dist/types/protocol/envelope.d.ts +165 -0
- package/dist/types/protocol/envelope.d.ts.map +1 -0
- package/dist/types/protocol/errors.d.ts +33 -0
- package/dist/types/protocol/errors.d.ts.map +1 -0
- package/dist/types/protocol/messages.d.ts +327 -0
- package/dist/types/protocol/messages.d.ts.map +1 -0
- package/dist/types/protocol/serialize.d.ts +26 -0
- package/dist/types/protocol/serialize.d.ts.map +1 -0
- package/dist/types/protocol/validate.d.ts +135 -0
- package/dist/types/protocol/validate.d.ts.map +1 -0
- package/package.json +116 -4
- package/scripts/generate-systemd-service.mjs +117 -0
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
import { Pool } from 'pg';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as net from 'node:net';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import { runExtended } from './types';
|
|
6
|
+
import { DEFAULTS, LIMITS } from '../protocol/constants';
|
|
7
|
+
import { describeSearchPathSetting, renderSearchPathSet, resolveSearchPathComponents, searchPathMatches, } from './search-path';
|
|
8
|
+
/**
|
|
9
|
+
* The search_path helpers live in `./search-path` so the pure composition and
|
|
10
|
+
* verification logic can be tested without a pool or a database. They are
|
|
11
|
+
* re-exported here because `./execution/pool` is the module the rest of the
|
|
12
|
+
* codebase (and the tests) have always imported them from, and moving that
|
|
13
|
+
* would be a change with no security value.
|
|
14
|
+
*/
|
|
15
|
+
export { DEFAULT_SEARCH_PATH, PG_CATALOG_SCHEMA, PG_TEMP_SCHEMA, isBareSchemaIdentifier, parseSearchPathSetting, renderSearchPathSet, searchPathMatches, } from './search-path';
|
|
16
|
+
/**
|
|
17
|
+
* Absolute hard ceiling on `statement_timeout`, in milliseconds.
|
|
18
|
+
*
|
|
19
|
+
* Nothing can raise this: not a `timeout_ms` in a cloud request, not the
|
|
20
|
+
* `SW_MAX_STATEMENT_TIMEOUT_MS` environment variable, and not the
|
|
21
|
+
* `PoolManager` option. It exists so that "hard-capped" is a property of the
|
|
22
|
+
* build rather than of whatever number is configured next.
|
|
23
|
+
*/
|
|
24
|
+
export const MAX_STATEMENT_TIMEOUT_MS = 900_000;
|
|
25
|
+
/**
|
|
26
|
+
* How long a statement may wait for a lock before it is cancelled. Without
|
|
27
|
+
* this, `SELECT ... FOR UPDATE` or a migration waiting on a DDL lock pins a
|
|
28
|
+
* pooled backend (and its transaction snapshot) until the client's own
|
|
29
|
+
* statement_timeout, which is per-statement and can be very large.
|
|
30
|
+
*/
|
|
31
|
+
export const LOCK_TIMEOUT_MS = 10_000;
|
|
32
|
+
/**
|
|
33
|
+
* How long a connection may sit idle inside an open transaction. An idle
|
|
34
|
+
* transaction holds a snapshot, blocks vacuum cleanup and pins a pool slot;
|
|
35
|
+
* this terminates the backend instead of letting it linger.
|
|
36
|
+
*/
|
|
37
|
+
export const IDLE_IN_TRANSACTION_TIMEOUT_MS = DEFAULTS.MIGRATION_TIMEOUT_MS;
|
|
38
|
+
/** Bounds for the per-pool connection count. */
|
|
39
|
+
export const MIN_POOL_SIZE = 1;
|
|
40
|
+
export const MAX_POOL_SIZE = 100;
|
|
41
|
+
export const DEFAULT_POOL_SIZE = 15;
|
|
42
|
+
export class PoolError extends Error {
|
|
43
|
+
code;
|
|
44
|
+
cause;
|
|
45
|
+
constructor(code, message, cause) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.code = code;
|
|
48
|
+
this.cause = cause;
|
|
49
|
+
this.name = 'PoolError';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Collapse anything that is not an identifier character. Applied to every
|
|
54
|
+
* operator-controlled value that is embedded in a user-facing message.
|
|
55
|
+
*/
|
|
56
|
+
function safeToken(value) {
|
|
57
|
+
return value.replace(/[^A-Za-z0-9_.:@-]/g, '_').slice(0, 64);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The only connection identifier that may appear in an outbound message.
|
|
61
|
+
* Host, port, user and database are connection secrets/topology: an auth
|
|
62
|
+
* failure or an unreachable host used to disclose all four verbatim.
|
|
63
|
+
*/
|
|
64
|
+
function safeTarget(dbEntry) {
|
|
65
|
+
return `database "${safeToken(dbEntry.db_alias)}"`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Last-resort scrub of a PostgreSQL or driver message: replace anything that
|
|
69
|
+
* looks like this entry's host, port, user, database or password with an opaque
|
|
70
|
+
* placeholder before it is allowed into a message that will be forwarded to the
|
|
71
|
+
* cloud and the browser.
|
|
72
|
+
*
|
|
73
|
+
* The curated messages in {@link PoolManager.mapConnectError} never contain
|
|
74
|
+
* these values at all; this exists for the driver text that reaches the
|
|
75
|
+
* unrecognised-error branch, which can quote the connection string verbatim.
|
|
76
|
+
*/
|
|
77
|
+
function scrubKnownSecrets(dbEntry, message) {
|
|
78
|
+
let out = message;
|
|
79
|
+
const secrets = [
|
|
80
|
+
[dbEntry.password_stored ?? '', 'password'],
|
|
81
|
+
[dbEntry.host ?? '', 'host'],
|
|
82
|
+
[dbEntry.user ?? '', 'user'],
|
|
83
|
+
[dbEntry.database ?? '', 'database'],
|
|
84
|
+
[String(dbEntry.port ?? ''), 'port'],
|
|
85
|
+
];
|
|
86
|
+
for (const [secret, label] of secrets) {
|
|
87
|
+
if (secret.length >= 2 && out.includes(secret)) {
|
|
88
|
+
out = out.split(secret).join(`[${label}]`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
/** Bound the length of any driver text that reaches a user-facing message. */
|
|
94
|
+
function truncateMessage(message, max = 200) {
|
|
95
|
+
const flat = message.replace(/\s+/g, ' ').trim();
|
|
96
|
+
return flat.length > max ? `${flat.slice(0, max)}...` : flat;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Connections whose session state could not be proven clean. They are
|
|
100
|
+
* destroyed on release rather than handed to the next request, because
|
|
101
|
+
* `release()` is synchronous and cannot run the `RESET ALL` that would be
|
|
102
|
+
* needed to make them safe again.
|
|
103
|
+
*/
|
|
104
|
+
const dirtySessions = new WeakSet();
|
|
105
|
+
/**
|
|
106
|
+
* Declare that a pooled connection has been used for a stateful sequence — an
|
|
107
|
+
* open transaction, a cursor, or any statement that may have changed session
|
|
108
|
+
* GUCs — and can no longer be proven to hold nothing but the posture
|
|
109
|
+
* {@link PoolManager.acquire} established.
|
|
110
|
+
*
|
|
111
|
+
* Call this as soon as such a sequence starts. The connection is destroyed on
|
|
112
|
+
* release, which costs one reconnect; forgetting to call it costs a session
|
|
113
|
+
* GUC leak into the next request.
|
|
114
|
+
*/
|
|
115
|
+
export function markSessionDirty(client) {
|
|
116
|
+
dirtySessions.add(client);
|
|
117
|
+
}
|
|
118
|
+
/** True when `host` is an IPv4/IPv6 literal rather than a DNS name. */
|
|
119
|
+
export function isIpLiteral(host) {
|
|
120
|
+
if (typeof host !== 'string' || host.length === 0)
|
|
121
|
+
return false;
|
|
122
|
+
return net.isIP(host) !== 0;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Warning text for a `verify-full` entry whose host is an IP literal, or `null`
|
|
126
|
+
* when no warning applies.
|
|
127
|
+
*
|
|
128
|
+
* node-postgres only sets the TLS `servername` for DNS names
|
|
129
|
+
* (`pg/lib/connection.js`: `if (net.isIP(host) === 0) options.servername = host`),
|
|
130
|
+
* so an IP-literal host such as `10.0.1.20` gets no `servername` and Node
|
|
131
|
+
* performs no hostname check at all — `verify-full` silently becomes
|
|
132
|
+
* `verify-ca`. An on-path attacker with any certificate from the same CA can
|
|
133
|
+
* therefore impersonate the server unless the certificate also carries an IP
|
|
134
|
+
* SAN that Node checks, which is rare.
|
|
135
|
+
*/
|
|
136
|
+
export function hostnameVerificationWarning(mode, host) {
|
|
137
|
+
if (mode !== 'verify-full' || !isIpLiteral(host))
|
|
138
|
+
return null;
|
|
139
|
+
return (`ssl_mode 'verify-full' with IP-literal host '${String(host)}' does not verify the ` +
|
|
140
|
+
'server hostname: PostgreSQL drivers send no TLS servername for IP literals, so the ' +
|
|
141
|
+
'certificate chain is checked but the identity is not. This is equivalent to ' +
|
|
142
|
+
"'verify-ca'. Use the database's DNS name, or give the certificate an IP SAN, to " +
|
|
143
|
+
'get real hostname verification.');
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The two non-verifying ssl modes are silent today, which is how a
|
|
147
|
+
* cleartext-password or MITM-able posture goes unnoticed. `require` is the
|
|
148
|
+
* default in `db add`, so this is the warning most users actually need.
|
|
149
|
+
*/
|
|
150
|
+
export function unauthenticatedTlsWarning(mode) {
|
|
151
|
+
if (mode === 'require') {
|
|
152
|
+
return (`ssl_mode is 'require' (the default): the tunnel is encrypted but the server ` +
|
|
153
|
+
'certificate is NOT verified, so an on-path attacker can impersonate your ' +
|
|
154
|
+
'PostgreSQL server. Upgrade with: sw-agent db edit <alias> --ssl verify-full ' +
|
|
155
|
+
'--ssl-cert <ca.pem>');
|
|
156
|
+
}
|
|
157
|
+
if (mode === 'disable') {
|
|
158
|
+
return ("ssl_mode is 'disable': the connection is unencrypted and the database " +
|
|
159
|
+
'password travels in cleartext. Upgrade with: sw-agent db edit <alias> ' +
|
|
160
|
+
'--ssl verify-full --ssl-cert <ca.pem>');
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Build node-postgres SSL options from a DbEntry's ssl settings.
|
|
166
|
+
*
|
|
167
|
+
* `verify-ca` and `verify-full` are genuinely different here: `verify-ca`
|
|
168
|
+
* pins the CA and deliberately skips the hostname comparison, `verify-full`
|
|
169
|
+
* lets Node perform it. An unknown mode throws rather than falling back to
|
|
170
|
+
* plaintext.
|
|
171
|
+
*
|
|
172
|
+
* `host` is optional and only used to warn about the IP-literal case; it never
|
|
173
|
+
* changes the returned object.
|
|
174
|
+
*/
|
|
175
|
+
export function buildSslConfig(mode, rootCert, host) {
|
|
176
|
+
const warnings = [
|
|
177
|
+
hostnameVerificationWarning(mode, host),
|
|
178
|
+
unauthenticatedTlsWarning(mode),
|
|
179
|
+
].filter((w) => typeof w === 'string' && w.length > 0);
|
|
180
|
+
if (warnings.length > 0) {
|
|
181
|
+
console.warn(`[sw-agent] WARNING: ${warnings.join(' ')}`);
|
|
182
|
+
}
|
|
183
|
+
switch (mode) {
|
|
184
|
+
case 'disable':
|
|
185
|
+
return false;
|
|
186
|
+
case 'require':
|
|
187
|
+
// TLS, but no verification. Documented as such.
|
|
188
|
+
return { rejectUnauthorized: false };
|
|
189
|
+
case 'verify-ca': {
|
|
190
|
+
if (!rootCert)
|
|
191
|
+
throw new Error('ssl_root_cert required for verify-ca');
|
|
192
|
+
return {
|
|
193
|
+
ca: fs.readFileSync(rootCert),
|
|
194
|
+
rejectUnauthorized: true,
|
|
195
|
+
checkServerIdentity: () => undefined,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
case 'verify-full': {
|
|
199
|
+
if (!rootCert)
|
|
200
|
+
throw new Error('ssl_root_cert required for verify-full');
|
|
201
|
+
return { ca: fs.readFileSync(rootCert), rejectUnauthorized: true };
|
|
202
|
+
}
|
|
203
|
+
default:
|
|
204
|
+
// Fail closed. The previous implementation returned `false` (plaintext)
|
|
205
|
+
// for any unrecognised mode.
|
|
206
|
+
throw new Error(`Unsupported ssl_mode '${mode}'. Expected one of: disable, require, verify-ca, verify-full.`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Stable fingerprint of every parameter that affects the connection or the
|
|
211
|
+
* session posture. The password is hashed, never included verbatim.
|
|
212
|
+
*
|
|
213
|
+
* `password_env` is part of the fingerprint in addition to the resolved
|
|
214
|
+
* secret: switching the entry from `password_stored` to an env var that happens
|
|
215
|
+
* to hold the same string still changes where the credential comes from, and a
|
|
216
|
+
* pool opened for one must not serve the other.
|
|
217
|
+
*
|
|
218
|
+
* The `search_path` contribution is the resolved component list joined with `,`.
|
|
219
|
+
* Components are validated bare identifiers, so they cannot contain `,` or a
|
|
220
|
+
* quote and the join is unambiguous — unlike a joined-then-resplit round-trip,
|
|
221
|
+
* which is exactly the defect was.
|
|
222
|
+
*/
|
|
223
|
+
export function connectionFingerprint(entry, password) {
|
|
224
|
+
return [
|
|
225
|
+
entry.host,
|
|
226
|
+
entry.port,
|
|
227
|
+
entry.database,
|
|
228
|
+
entry.user,
|
|
229
|
+
entry.ssl_mode,
|
|
230
|
+
entry.ssl_root_cert ?? '',
|
|
231
|
+
entry.permission_override ?? '',
|
|
232
|
+
entry.password_env ?? '',
|
|
233
|
+
resolveSearchPathComponents(entry).join(','),
|
|
234
|
+
hashSecret(password),
|
|
235
|
+
].join('\u0000');
|
|
236
|
+
}
|
|
237
|
+
function hashSecret(secret) {
|
|
238
|
+
// Never put the password itself in a string that might be logged.
|
|
239
|
+
return createHash('sha256').update(secret).digest('hex').slice(0, 16);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Clamp a caller-supplied timeout to a server-controlled ceiling.
|
|
243
|
+
*
|
|
244
|
+
* `requested <= 0` means "no timeout" in the PostgreSQL world and is never
|
|
245
|
+
* honoured: a remote caller must not be able to remove the ceiling by asking
|
|
246
|
+
* for zero, so it falls back to the default instead.
|
|
247
|
+
*/
|
|
248
|
+
export function clampStatementTimeout(requested, ceilingMs) {
|
|
249
|
+
const ceiling = Math.min(Math.max(1, Math.floor(ceilingMs)), MAX_STATEMENT_TIMEOUT_MS);
|
|
250
|
+
const fallback = Math.min(DEFAULTS.QUERY_TIMEOUT_MS, ceiling);
|
|
251
|
+
if (requested === undefined || !Number.isFinite(requested))
|
|
252
|
+
return fallback;
|
|
253
|
+
if (requested <= 0)
|
|
254
|
+
return fallback;
|
|
255
|
+
return Math.min(Math.floor(requested), ceiling);
|
|
256
|
+
}
|
|
257
|
+
export class PoolManager {
|
|
258
|
+
pools = new Map();
|
|
259
|
+
activeClientsCount = new Map();
|
|
260
|
+
opts;
|
|
261
|
+
constructor(opts = {}) {
|
|
262
|
+
this.opts = opts;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Ceiling for `statement_timeout`, in milliseconds. Configurable by the
|
|
266
|
+
* operator, never by a request, and never above {@link MAX_STATEMENT_TIMEOUT_MS}.
|
|
267
|
+
*/
|
|
268
|
+
get maxStatementTimeoutMs() {
|
|
269
|
+
const envCeiling = process.env.SW_MAX_STATEMENT_TIMEOUT_MS
|
|
270
|
+
? parseInt(process.env.SW_MAX_STATEMENT_TIMEOUT_MS, 10)
|
|
271
|
+
: NaN;
|
|
272
|
+
if (Number.isFinite(envCeiling) && envCeiling > 0) {
|
|
273
|
+
return Math.min(envCeiling, MAX_STATEMENT_TIMEOUT_MS);
|
|
274
|
+
}
|
|
275
|
+
const configured = this.opts.maxStatementTimeoutMs;
|
|
276
|
+
if (typeof configured === 'number' && Number.isFinite(configured) && configured > 0) {
|
|
277
|
+
return Math.min(Math.floor(configured), MAX_STATEMENT_TIMEOUT_MS);
|
|
278
|
+
}
|
|
279
|
+
return Math.min(DEFAULTS.QUERY_TIMEOUT_MS, MAX_STATEMENT_TIMEOUT_MS);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Connections per pool. `SW_PG_POOL_MAX` is operator-controlled but must not
|
|
283
|
+
* be able to set an arbitrary number: an unbounded value exhausts the
|
|
284
|
+
* database's `max_connections`, and a NaN/negative value makes node-postgres
|
|
285
|
+
* behave unpredictably. Garbage falls back to the default of 15.
|
|
286
|
+
*/
|
|
287
|
+
get maxPoolSize() {
|
|
288
|
+
const envRaw = process.env.SW_PG_POOL_MAX;
|
|
289
|
+
if (envRaw !== undefined && envRaw.trim() !== '') {
|
|
290
|
+
const parsed = Number(envRaw.trim());
|
|
291
|
+
if (Number.isInteger(parsed) && parsed >= MIN_POOL_SIZE) {
|
|
292
|
+
if (parsed > MAX_POOL_SIZE) {
|
|
293
|
+
console.warn(`[sw-agent] WARNING: SW_PG_POOL_MAX=${parsed} exceeds the ${MAX_POOL_SIZE} connection ` +
|
|
294
|
+
`ceiling; using ${MAX_POOL_SIZE}.`);
|
|
295
|
+
return MAX_POOL_SIZE;
|
|
296
|
+
}
|
|
297
|
+
return parsed;
|
|
298
|
+
}
|
|
299
|
+
console.warn(`[sw-agent] WARNING: ignoring invalid SW_PG_POOL_MAX '${envRaw}'. Expected an integer ` +
|
|
300
|
+
`between ${MIN_POOL_SIZE} and ${MAX_POOL_SIZE}; using ${DEFAULT_POOL_SIZE}.`);
|
|
301
|
+
return DEFAULT_POOL_SIZE;
|
|
302
|
+
}
|
|
303
|
+
const configured = this.opts.maxPoolSize;
|
|
304
|
+
if (typeof configured === 'number' && Number.isInteger(configured)) {
|
|
305
|
+
return Math.min(Math.max(configured, MIN_POOL_SIZE), MAX_POOL_SIZE);
|
|
306
|
+
}
|
|
307
|
+
return DEFAULT_POOL_SIZE;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Get a pool client for the given DB entry.
|
|
311
|
+
* Opens the pool if it does not exist, or if the entry's connection
|
|
312
|
+
* parameters changed since the pool was created (so a rotated password or a
|
|
313
|
+
* changed TLS mode takes effect immediately instead of after the idle timer).
|
|
314
|
+
*/
|
|
315
|
+
async acquire(dbEntry) {
|
|
316
|
+
const dbAlias = dbEntry.db_alias;
|
|
317
|
+
const password = dbEntry.password_stored ||
|
|
318
|
+
(dbEntry.password_env ? process.env[dbEntry.password_env] : undefined);
|
|
319
|
+
if (!password) {
|
|
320
|
+
// The variable *name* is credential location information; the host, user
|
|
321
|
+
// and database are topology. Neither belongs in a message that travels to
|
|
322
|
+
// the cloud and the browser.
|
|
323
|
+
const hint = dbEntry.password_env
|
|
324
|
+
? 'Check that the password environment variable is set in the agent environment.'
|
|
325
|
+
: 'No password is configured for this database.';
|
|
326
|
+
throw new PoolError('env_var_missing', `Password unavailable for ${safeTarget(dbEntry)}. ${hint}`);
|
|
327
|
+
}
|
|
328
|
+
const fingerprint = connectionFingerprint(dbEntry, password);
|
|
329
|
+
let poolRecord = this.pools.get(dbAlias);
|
|
330
|
+
if (poolRecord && poolRecord.fingerprint !== fingerprint) {
|
|
331
|
+
// Connection parameters changed under us. Retire the old pool so the new
|
|
332
|
+
// credentials / TLS settings actually take effect.
|
|
333
|
+
await this.closePool(dbAlias, 'error');
|
|
334
|
+
poolRecord = undefined;
|
|
335
|
+
}
|
|
336
|
+
if (!poolRecord) {
|
|
337
|
+
let sslConfig;
|
|
338
|
+
try {
|
|
339
|
+
sslConfig = buildSslConfig(dbEntry.ssl_mode, dbEntry.ssl_root_cert, dbEntry.host);
|
|
340
|
+
}
|
|
341
|
+
catch (err) {
|
|
342
|
+
throw new PoolError('ssl_error', `Failed to load the SSL configuration for ${safeTarget(dbEntry)}: ` +
|
|
343
|
+
scrubKnownSecrets(dbEntry, err instanceof Error ? err.message : String(err)), err instanceof Error ? err : undefined);
|
|
344
|
+
}
|
|
345
|
+
const pool = new Pool({
|
|
346
|
+
host: dbEntry.host,
|
|
347
|
+
port: dbEntry.port,
|
|
348
|
+
database: dbEntry.database,
|
|
349
|
+
user: dbEntry.user,
|
|
350
|
+
password,
|
|
351
|
+
ssl: sslConfig,
|
|
352
|
+
max: this.maxPoolSize,
|
|
353
|
+
idleTimeoutMillis: 30_000,
|
|
354
|
+
connectionTimeoutMillis: 5_000,
|
|
355
|
+
application_name: 'schema-weaver-pg-connector',
|
|
356
|
+
});
|
|
357
|
+
poolRecord = { pool, idleSince: Date.now(), fingerprint };
|
|
358
|
+
this.pools.set(dbAlias, poolRecord);
|
|
359
|
+
this.activeClientsCount.set(dbAlias, 0);
|
|
360
|
+
if (this.opts.events?.onPoolOpen) {
|
|
361
|
+
this.opts.events.onPoolOpen(dbAlias);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
// Cancel idle timer if it's active
|
|
365
|
+
if (poolRecord.idleTimer) {
|
|
366
|
+
clearTimeout(poolRecord.idleTimer);
|
|
367
|
+
poolRecord.idleTimer = undefined;
|
|
368
|
+
}
|
|
369
|
+
let client;
|
|
370
|
+
try {
|
|
371
|
+
client = await poolRecord.pool.connect();
|
|
372
|
+
}
|
|
373
|
+
catch (err) {
|
|
374
|
+
throw this.mapConnectError(err, dbEntry);
|
|
375
|
+
}
|
|
376
|
+
// Enforce the session posture we promised, on every connection, before any
|
|
377
|
+
// caller-supplied SQL runs. This is defence in depth behind the permission
|
|
378
|
+
// checker: even if a classification bug lets a write through, PostgreSQL
|
|
379
|
+
// itself refuses it for a read_only database. If the posture cannot be
|
|
380
|
+
// established the request is refused rather than served unprotected.
|
|
381
|
+
try {
|
|
382
|
+
await this.hardenSession(client, dbEntry);
|
|
383
|
+
}
|
|
384
|
+
catch (err) {
|
|
385
|
+
// The posture is unknown: destroy this connection rather than recycle it.
|
|
386
|
+
client.release(new Error('session hardening failed'));
|
|
387
|
+
throw err;
|
|
388
|
+
}
|
|
389
|
+
let pid = 0;
|
|
390
|
+
try {
|
|
391
|
+
const pidRes = await runExtended(client, 'SELECT pg_backend_pid() AS pid');
|
|
392
|
+
pid = Number(pidRes.rows[0]?.pid ?? 0);
|
|
393
|
+
}
|
|
394
|
+
catch (err) {
|
|
395
|
+
client.release(new Error('session state unconfirmed'));
|
|
396
|
+
throw new PoolError('connection_failed', `Lost the connection to ${safeTarget(dbEntry)} while confirming its session state.`, err instanceof Error ? err : undefined);
|
|
397
|
+
}
|
|
398
|
+
const currentCount = this.activeClientsCount.get(dbAlias) || 0;
|
|
399
|
+
this.activeClientsCount.set(dbAlias, currentCount + 1);
|
|
400
|
+
if (this.opts.events?.onConnectionAcquired) {
|
|
401
|
+
this.opts.events.onConnectionAcquired(dbAlias);
|
|
402
|
+
}
|
|
403
|
+
let released = false;
|
|
404
|
+
const release = () => {
|
|
405
|
+
if (!released) {
|
|
406
|
+
released = true;
|
|
407
|
+
this.release(dbAlias, client);
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
return { client, release, pid };
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Put a freshly-checked-out connection into the posture this database entry
|
|
414
|
+
* is configured for, and clear anything a previous request left behind.
|
|
415
|
+
*
|
|
416
|
+
* This is the enforcement point that makes `read_only` physical rather than
|
|
417
|
+
* advisory: a `read_only` entry gets `default_transaction_read_only = on`, so
|
|
418
|
+
* PostgreSQL itself raises `25006` for a write — including a write smuggled
|
|
419
|
+
* in after a `SELECT` that every lexical layer agreed was a read. The value
|
|
420
|
+
* is read back and verified, and any failure here aborts the request.
|
|
421
|
+
*/
|
|
422
|
+
async hardenSession(client, dbEntry) {
|
|
423
|
+
const readOnly = effectivePermission(dbEntry) === 'read_only';
|
|
424
|
+
const expected = readOnly ? 'on' : 'off';
|
|
425
|
+
try {
|
|
426
|
+
// RESET ALL clears every session GUC a previous request may have set
|
|
427
|
+
// (search_path, statement_timeout, application_name, …).
|
|
428
|
+
//
|
|
429
|
+
// It does NOT clear `role` or `session_authorization` — PostgreSQL
|
|
430
|
+
// excludes both. Verified against a live PostgreSQL 18:
|
|
431
|
+
//
|
|
432
|
+
// SET ROLE jane; RESET ALL; -> current_user is STILL jane
|
|
433
|
+
// RESET ROLE; -> back to the authenticated user
|
|
434
|
+
//
|
|
435
|
+
// SET SESSION AUTHORIZATION jane; RESET ALL;
|
|
436
|
+
// -> still jane, and session_user has been rewritten too
|
|
437
|
+
// RESET SESSION AUTHORIZATION; -> back to the login role
|
|
438
|
+
//
|
|
439
|
+
// Without the two extra resets, a request at `permission_level: full`
|
|
440
|
+
// that runs `SET ROLE someuser` leaves the pooled backend impersonating
|
|
441
|
+
// that role for every later request the pool hands it to. That is a
|
|
442
|
+
// privilege leak between requests, not a cosmetic leak.
|
|
443
|
+
await runExtended(client, 'RESET ALL');
|
|
444
|
+
await runExtended(client, 'RESET ROLE');
|
|
445
|
+
await runExtended(client, 'RESET SESSION AUTHORIZATION');
|
|
446
|
+
await runExtended(client, `SET default_transaction_read_only = ${readOnly ? 'on' : 'off'}`);
|
|
447
|
+
// Session-level, not SET LOCAL: SET LOCAL outside a transaction block is a
|
|
448
|
+
// silent no-op, which is why queries used to run with no timeout at all.
|
|
449
|
+
await runExtended(client, `SET statement_timeout = ${this.maxStatementTimeoutMs}`);
|
|
450
|
+
await runExtended(client, `SET idle_in_transaction_session_timeout = ${IDLE_IN_TRANSACTION_TIMEOUT_MS}`);
|
|
451
|
+
await runExtended(client, `SET lock_timeout = ${LOCK_TIMEOUT_MS}`);
|
|
452
|
+
// RESET ALL also cleared search_path back to the role default, and a
|
|
453
|
+
// pooled session would otherwise resolve unqualified names against
|
|
454
|
+
// whatever the previous request left behind.
|
|
455
|
+
//
|
|
456
|
+
// the resolved components are rendered into the *whole statement*
|
|
457
|
+
// in one step from a `string[]`. There is no join-then-split here any
|
|
458
|
+
// more, so a component cannot pick up or lose a space between what we
|
|
459
|
+
// validated and what the server was told — which is how `"analytics,
|
|
460
|
+
// public"` used to become `"analytics", " public"` and silently deleted
|
|
461
|
+
// `public` from the path.
|
|
462
|
+
//
|
|
463
|
+
// `SET` (not `SET LOCAL`) is required: a session-level value must survive
|
|
464
|
+
// until the connection is released.
|
|
465
|
+
const searchPath = resolveSearchPathComponents(dbEntry);
|
|
466
|
+
const searchPathSet = renderSearchPathSet(searchPath);
|
|
467
|
+
await runExtended(client, searchPathSet);
|
|
468
|
+
// Never assume the SET took: confirm it, and refuse the request if not.
|
|
469
|
+
// A non-read_only entry must be confirmed `off` too, so one entry can
|
|
470
|
+
// never leave another entry's connection stuck read-only.
|
|
471
|
+
const check = await runExtended(client, 'SHOW default_transaction_read_only');
|
|
472
|
+
const actual = String(check.rows[0]
|
|
473
|
+
?.default_transaction_read_only ?? '').toLowerCase();
|
|
474
|
+
if (actual !== expected) {
|
|
475
|
+
throw new Error(`default_transaction_read_only is '${actual}', expected '${expected}'`);
|
|
476
|
+
}
|
|
477
|
+
// post-condition. The old check was
|
|
478
|
+
// `actualPath.toLowerCase().includes(DEFAULT_SEARCH_PATH)`, which the
|
|
479
|
+
// server's own report of `analytics, " public"` satisfied — the control
|
|
480
|
+
// was defeated by exactly the corruption it existed to detect. This
|
|
481
|
+
// compares the reported path against the same array that was rendered,
|
|
482
|
+
// component for component and in order, so a component that is `" public"`
|
|
483
|
+
// instead of `public` fails and the connection is destroyed.
|
|
484
|
+
const pathCheck = await runExtended(client, 'SHOW search_path');
|
|
485
|
+
const actualPath = String(pathCheck.rows[0]?.search_path ?? '');
|
|
486
|
+
if (!searchPathMatches(actualPath, searchPath)) {
|
|
487
|
+
throw new Error(`search_path is '${describeSearchPathSetting(actualPath)}', which is not the pinned ` +
|
|
488
|
+
`list [${searchPath.join(', ')}]`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
catch (err) {
|
|
492
|
+
// The underlying text can contain the host/user/database (libpq and pg
|
|
493
|
+
// both interpolate them), so it is scrubbed rather than forwarded raw.
|
|
494
|
+
throw new PoolError('unsafe_session_setting', `Refusing to serve ${safeTarget(dbEntry)}: the read-only session posture could not be ` +
|
|
495
|
+
`established (${scrubKnownSecrets(dbEntry, err instanceof Error ? err.message : String(err))}).`, err instanceof Error ? err : undefined);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Translate a driver/pg connection failure into a PoolError with a stable
|
|
500
|
+
* machine code and a message that names the database only by its alias.
|
|
501
|
+
*
|
|
502
|
+
* These messages are forwarded to the cloud and the browser, so host, port,
|
|
503
|
+
* username and database name must never appear in them: an authentication
|
|
504
|
+
* failure used to disclose the username and the `pg_hba.conf` verdict, and a
|
|
505
|
+
* refused connection disclosed the host and port of a production database.
|
|
506
|
+
* `cause` is retained for the local error log only and is never sent.
|
|
507
|
+
*/
|
|
508
|
+
mapConnectError(err, dbEntry) {
|
|
509
|
+
const errorObj = err;
|
|
510
|
+
const code = errorObj.code || '';
|
|
511
|
+
const rawMessage = errorObj.message || 'Unknown connection error';
|
|
512
|
+
let errorType = 'connection_failed';
|
|
513
|
+
let message = scrubKnownSecrets(dbEntry, rawMessage);
|
|
514
|
+
if (/timeout exceeded when trying to connect/i.test(rawMessage)) {
|
|
515
|
+
// node-postgres raised this because every pool slot was checked out when
|
|
516
|
+
// `connectionTimeoutMillis` elapsed. Distinct from a network timeout: the
|
|
517
|
+
// server was reachable, the connector was saturated.
|
|
518
|
+
errorType = 'pool_exhausted';
|
|
519
|
+
message =
|
|
520
|
+
`All connections for ${safeTarget(dbEntry)} were in use and none became free within ` +
|
|
521
|
+
'the connection timeout. Lower the concurrency, or raise SW_PG_POOL_MAX.';
|
|
522
|
+
}
|
|
523
|
+
else if (code === 'ECONNREFUSED' || code === 'ENOTFOUND' || code === 'ETIMEDOUT') {
|
|
524
|
+
errorType = 'connection_failed';
|
|
525
|
+
message =
|
|
526
|
+
`Cannot reach PostgreSQL for ${safeTarget(dbEntry)}. Check that the database is ` +
|
|
527
|
+
'running and that the agent host can route to it.';
|
|
528
|
+
}
|
|
529
|
+
else if (code === '28P01') {
|
|
530
|
+
errorType = 'auth_failed';
|
|
531
|
+
message = `PostgreSQL rejected the credentials configured for ${safeTarget(dbEntry)}.`;
|
|
532
|
+
}
|
|
533
|
+
else if (code === '28000') {
|
|
534
|
+
errorType = 'auth_failed';
|
|
535
|
+
message = `The PostgreSQL role configured for ${safeTarget(dbEntry)} has no login permission.`;
|
|
536
|
+
}
|
|
537
|
+
else if (code === '3D000') {
|
|
538
|
+
errorType = 'db_not_found';
|
|
539
|
+
message = `The database configured for ${safeTarget(dbEntry)} does not exist on the server.`;
|
|
540
|
+
}
|
|
541
|
+
else if (code === '28040' || /no pg_hba\.conf entry/i.test(rawMessage)) {
|
|
542
|
+
errorType = 'auth_failed';
|
|
543
|
+
message =
|
|
544
|
+
`pg_hba.conf denied the connection for ${safeTarget(dbEntry)}. The agent host, role, ` +
|
|
545
|
+
'database and network must all be allowed by the server.';
|
|
546
|
+
}
|
|
547
|
+
else if (/ssl|tls|certificate|handshake|self.signed/i.test(rawMessage)) {
|
|
548
|
+
errorType = 'ssl_error';
|
|
549
|
+
message =
|
|
550
|
+
`TLS negotiation with ${safeTarget(dbEntry)} failed. Check the CA certificate and the ` +
|
|
551
|
+
'configured ssl_mode.';
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
message = `Could not connect to ${safeTarget(dbEntry)} (${truncateMessage(message)}).`;
|
|
555
|
+
}
|
|
556
|
+
return new PoolError(errorType, message, err instanceof Error ? err : undefined);
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Release a client back to the pool. Resets idle timer.
|
|
560
|
+
*
|
|
561
|
+
* A connection marked dirty could not be proven to be back in the posture
|
|
562
|
+
* this entry requires, so it is destroyed instead of recycled: the next
|
|
563
|
+
* request must not inherit an open transaction or a session GUC that the
|
|
564
|
+
* previous request left behind.
|
|
565
|
+
*/
|
|
566
|
+
release(dbAlias, client) {
|
|
567
|
+
const dirty = dirtySessions.has(client);
|
|
568
|
+
dirtySessions.delete(client);
|
|
569
|
+
if (dirty) {
|
|
570
|
+
client.release(new Error('connection discarded: session state could not be verified'));
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
client.release();
|
|
574
|
+
}
|
|
575
|
+
if (this.opts.events?.onConnectionReleased) {
|
|
576
|
+
this.opts.events.onConnectionReleased(dbAlias);
|
|
577
|
+
}
|
|
578
|
+
const currentCount = this.activeClientsCount.get(dbAlias) || 0;
|
|
579
|
+
const newCount = Math.max(0, currentCount - 1);
|
|
580
|
+
this.activeClientsCount.set(dbAlias, newCount);
|
|
581
|
+
const poolRecord = this.pools.get(dbAlias);
|
|
582
|
+
if (poolRecord && newCount === 0) {
|
|
583
|
+
poolRecord.idleSince = Date.now();
|
|
584
|
+
if (poolRecord.idleTimer) {
|
|
585
|
+
clearTimeout(poolRecord.idleTimer);
|
|
586
|
+
}
|
|
587
|
+
const timeout = this.opts.idleTimeoutMs ?? DEFAULTS.IDLE_WSS_TIMEOUT_MS;
|
|
588
|
+
if (timeout > 0) {
|
|
589
|
+
poolRecord.idleTimer = setTimeout(() => {
|
|
590
|
+
this.closePool(dbAlias, 'idle').catch((err) => {
|
|
591
|
+
console.error(`Error closing idle pool for "${dbAlias}":`, err);
|
|
592
|
+
});
|
|
593
|
+
}, timeout);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
/** Close a specific pool. */
|
|
598
|
+
async closePool(dbAlias, reason = 'explicit') {
|
|
599
|
+
const poolRecord = this.pools.get(dbAlias);
|
|
600
|
+
if (poolRecord) {
|
|
601
|
+
if (poolRecord.idleTimer) {
|
|
602
|
+
clearTimeout(poolRecord.idleTimer);
|
|
603
|
+
}
|
|
604
|
+
this.pools.delete(dbAlias);
|
|
605
|
+
this.activeClientsCount.delete(dbAlias);
|
|
606
|
+
try {
|
|
607
|
+
await poolRecord.pool.end();
|
|
608
|
+
}
|
|
609
|
+
catch {
|
|
610
|
+
// ignore errors during end
|
|
611
|
+
}
|
|
612
|
+
if (this.opts.events?.onPoolClose) {
|
|
613
|
+
this.opts.events.onPoolClose(dbAlias, reason);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Close any pool whose connection parameters no longer match the config.
|
|
619
|
+
* Called after the databases config file is reloaded so that a rotated
|
|
620
|
+
* password or a changed TLS mode takes effect immediately.
|
|
621
|
+
*/
|
|
622
|
+
async reconcile(databases) {
|
|
623
|
+
const closed = [];
|
|
624
|
+
for (const [alias, record] of this.pools.entries()) {
|
|
625
|
+
const entry = databases.find((d) => d.db_alias === alias);
|
|
626
|
+
if (!entry) {
|
|
627
|
+
await this.closePool(alias, 'explicit');
|
|
628
|
+
closed.push(alias);
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
const password = entry.password_stored ||
|
|
632
|
+
(entry.password_env ? process.env[entry.password_env] : undefined) ||
|
|
633
|
+
'';
|
|
634
|
+
if (connectionFingerprint(entry, password) !== record.fingerprint) {
|
|
635
|
+
await this.closePool(alias, 'error');
|
|
636
|
+
closed.push(alias);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return closed;
|
|
640
|
+
}
|
|
641
|
+
/** Close all pools. Used during shutdown. */
|
|
642
|
+
async closeAll() {
|
|
643
|
+
const aliases = Array.from(this.pools.keys());
|
|
644
|
+
await Promise.all(aliases.map((alias) => this.closePool(alias, 'explicit')));
|
|
645
|
+
}
|
|
646
|
+
/** Check if a pool is currently open for this DB. */
|
|
647
|
+
hasPool(dbAlias) {
|
|
648
|
+
return this.pools.has(dbAlias);
|
|
649
|
+
}
|
|
650
|
+
/** Get stats for monitoring. */
|
|
651
|
+
getStats() {
|
|
652
|
+
return Array.from(this.pools.entries()).map(([dbAlias, record]) => {
|
|
653
|
+
return {
|
|
654
|
+
db_alias: dbAlias,
|
|
655
|
+
total_count: record.pool.totalCount,
|
|
656
|
+
idle_count: record.pool.idleCount,
|
|
657
|
+
waiting_count: record.pool.waitingCount,
|
|
658
|
+
};
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
/** Max bytes an inbound protocol message may occupy. Re-exported for the channel layer. */
|
|
662
|
+
static get maxMessageBytes() {
|
|
663
|
+
return LIMITS.MAX_PAYLOAD_BYTES;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* The permission level that actually applies to a database entry. Mirrors the
|
|
668
|
+
* dispatcher's resolution so the session posture can never disagree with the
|
|
669
|
+
* permission decision.
|
|
670
|
+
*/
|
|
671
|
+
export function effectivePermission(dbEntry, machineDefault) {
|
|
672
|
+
return dbEntry.permission_override ?? machineDefault ?? 'read_only';
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* The `search_path` to pin for this entry, as an ordered list of schema names.
|
|
676
|
+
*
|
|
677
|
+
* renamed this function's contract from `string` to `string[]` and moved
|
|
678
|
+
* it to `./search-path`, together with {@link renderSearchPathSet} (which turns
|
|
679
|
+
* the list into the full `SET search_path = ...` statement) and
|
|
680
|
+
* {@link searchPathMatches} (which verifies the server reported exactly that
|
|
681
|
+
* list back). The list is the only representation now: joining it into a string
|
|
682
|
+
* and re-splitting it on `,` is what turned `public` into `" public"`.
|
|
683
|
+
*/
|
|
684
|
+
export const resolveSearchPath = resolveSearchPathComponents;
|
|
685
|
+
//# sourceMappingURL=pool.js.map
|