@supatype/cli 0.7.0 → 0.9.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/CHANGELOG.md +314 -0
- package/bin/supatype.js +40 -4
- package/deno.d.ts +1 -1
- package/dist/admin-prompt-state.d.ts +13 -0
- package/dist/admin-prompt-state.d.ts.map +1 -0
- package/dist/admin-prompt-state.js +30 -0
- package/dist/admin-prompt-state.js.map +1 -0
- package/dist/adopt-columns.d.ts.map +1 -1
- package/dist/adopt-columns.js +13 -17
- package/dist/adopt-columns.js.map +1 -1
- package/dist/after-hooks-health.d.ts +19 -0
- package/dist/after-hooks-health.d.ts.map +1 -0
- package/dist/after-hooks-health.js +69 -0
- package/dist/after-hooks-health.js.map +1 -0
- package/dist/app-config.d.ts +1 -1
- package/dist/app-config.d.ts.map +1 -1
- package/dist/app-config.js +103 -144
- package/dist/app-config.js.map +1 -1
- package/dist/app-vite-env.d.ts +5 -1
- package/dist/app-vite-env.d.ts.map +1 -1
- package/dist/app-vite-env.js +9 -15
- package/dist/app-vite-env.js.map +1 -1
- package/dist/applied-ast-artifacts.d.ts +16 -0
- package/dist/applied-ast-artifacts.d.ts.map +1 -0
- package/dist/applied-ast-artifacts.js +37 -0
- package/dist/applied-ast-artifacts.js.map +1 -0
- package/dist/archive-extract.d.ts +3 -0
- package/dist/archive-extract.d.ts.map +1 -0
- package/dist/archive-extract.js +19 -0
- package/dist/archive-extract.js.map +1 -0
- package/dist/augmentation-generator.d.ts +5 -0
- package/dist/augmentation-generator.d.ts.map +1 -1
- package/dist/augmentation-generator.js +13 -4
- package/dist/augmentation-generator.js.map +1 -1
- package/dist/binary-cache.d.ts +27 -3
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +117 -85
- package/dist/binary-cache.js.map +1 -1
- package/dist/binary-download-lock.d.ts.map +1 -1
- package/dist/binary-download-lock.js +1 -3
- package/dist/binary-download-lock.js.map +1 -1
- package/dist/byo-preflight.d.ts.map +1 -1
- package/dist/byo-preflight.js +2 -10
- package/dist/byo-preflight.js.map +1 -1
- package/dist/byte-size.d.ts +9 -0
- package/dist/byte-size.d.ts.map +1 -0
- package/dist/byte-size.js +36 -0
- package/dist/byte-size.js.map +1 -0
- package/dist/cache-clean.d.ts +0 -2
- package/dist/cache-clean.d.ts.map +1 -1
- package/dist/cache-clean.js +1 -27
- package/dist/cache-clean.js.map +1 -1
- package/dist/cache-pins.d.ts.map +1 -1
- package/dist/cache-pins.js +3 -20
- package/dist/cache-pins.js.map +1 -1
- package/dist/cache-root.d.ts +7 -0
- package/dist/cache-root.d.ts.map +1 -0
- package/dist/cache-root.js +11 -0
- package/dist/cache-root.js.map +1 -0
- package/dist/cli-artifacts.d.ts.map +1 -1
- package/dist/cli-artifacts.js +2 -1
- package/dist/cli-artifacts.js.map +1 -1
- package/dist/cli-install-method.d.ts.map +1 -1
- package/dist/cli-install-method.js +7 -1
- package/dist/cli-install-method.js.map +1 -1
- package/dist/cli-launcher.d.ts +21 -0
- package/dist/cli-launcher.d.ts.map +1 -0
- package/dist/cli-launcher.js +112 -0
- package/dist/cli-launcher.js.map +1 -0
- package/dist/cli-old-versions.d.ts +44 -0
- package/dist/cli-old-versions.d.ts.map +1 -0
- package/dist/cli-old-versions.js +83 -0
- package/dist/cli-old-versions.js.map +1 -0
- package/dist/cli-program-path.d.ts +20 -0
- package/dist/cli-program-path.d.ts.map +1 -0
- package/dist/cli-program-path.js +41 -0
- package/dist/cli-program-path.js.map +1 -0
- package/dist/cli-standalone.d.ts +2 -3
- package/dist/cli-standalone.d.ts.map +1 -1
- package/dist/cli-standalone.js +51 -24
- package/dist/cli-standalone.js.map +1 -1
- package/dist/cli-version-embedded.js +1 -1
- package/dist/cloud-credentials.d.ts +6 -0
- package/dist/cloud-credentials.d.ts.map +1 -1
- package/dist/cloud-credentials.js +13 -0
- package/dist/cloud-credentials.js.map +1 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +18 -18
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +27 -8
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +37 -11
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/cloud.js +2 -4
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/db.d.ts.map +1 -1
- package/dist/commands/db.js +116 -106
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +3 -3
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +50 -4
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +276 -267
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts +32 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +66 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/functions.d.ts +30 -0
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +503 -507
- package/dist/commands/functions.js.map +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +11 -8
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/hooks.d.ts.map +1 -1
- package/dist/commands/hooks.js +46 -23
- package/dist/commands/hooks.js.map +1 -1
- package/dist/commands/init.d.ts +37 -4
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +509 -386
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/internal.d.ts.map +1 -1
- package/dist/commands/internal.js +2 -1
- package/dist/commands/internal.js.map +1 -1
- package/dist/commands/keys.d.ts +46 -20
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +196 -156
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/link-helpers.d.ts.map +1 -1
- package/dist/commands/link-helpers.js +30 -11
- package/dist/commands/link-helpers.js.map +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +5 -4
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/migrate.js +1 -1
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/pg.js +2 -0
- package/dist/commands/pg.js.map +1 -1
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +17 -7
- package/dist/commands/plugins.js.map +1 -1
- package/dist/commands/push.d.ts +39 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +221 -77
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/seed.d.ts +35 -0
- package/dist/commands/seed.d.ts.map +1 -1
- package/dist/commands/seed.js +72 -38
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/self-host.d.ts.map +1 -1
- package/dist/commands/self-host.js +71 -42
- package/dist/commands/self-host.js.map +1 -1
- package/dist/commands/self-update.d.ts.map +1 -1
- package/dist/commands/self-update.js +9 -3
- package/dist/commands/self-update.js.map +1 -1
- package/dist/commands/status.js +5 -5
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/types.js +2 -5
- package/dist/commands/types.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +212 -101
- package/dist/commands/update.js.map +1 -1
- package/dist/component-launch.d.ts +11 -0
- package/dist/component-launch.d.ts.map +1 -0
- package/dist/component-launch.js +35 -0
- package/dist/component-launch.js.map +1 -0
- package/dist/components.d.ts +7 -2
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +7 -2
- package/dist/components.js.map +1 -1
- package/dist/compose-db-roles.d.ts.map +1 -1
- package/dist/compose-db-roles.js +5 -14
- package/dist/compose-db-roles.js.map +1 -1
- package/dist/compose-engine-run.d.ts +6 -5
- package/dist/compose-engine-run.d.ts.map +1 -1
- package/dist/compose-engine-run.js +44 -37
- package/dist/compose-engine-run.js.map +1 -1
- package/dist/compose-engine-service.d.ts +10 -0
- package/dist/compose-engine-service.d.ts.map +1 -0
- package/dist/compose-engine-service.js +16 -0
- package/dist/compose-engine-service.js.map +1 -0
- package/dist/compose-host-path.d.ts +14 -0
- package/dist/compose-host-path.d.ts.map +1 -0
- package/dist/compose-host-path.js +18 -0
- package/dist/compose-host-path.js.map +1 -0
- package/dist/compose-image-pull.d.ts +43 -0
- package/dist/compose-image-pull.d.ts.map +1 -0
- package/dist/compose-image-pull.js +27 -0
- package/dist/compose-image-pull.js.map +1 -0
- package/dist/compose-kong.d.ts +4 -0
- package/dist/compose-kong.d.ts.map +1 -1
- package/dist/compose-kong.js +23 -9
- package/dist/compose-kong.js.map +1 -1
- package/dist/compose-local-server-image.d.ts.map +1 -1
- package/dist/compose-local-server-image.js +7 -3
- package/dist/compose-local-server-image.js.map +1 -1
- package/dist/compose-render-mode.d.ts.map +1 -1
- package/dist/compose-render-mode.js +7 -4
- package/dist/compose-render-mode.js.map +1 -1
- package/dist/compose-services.d.ts +12 -2
- package/dist/compose-services.d.ts.map +1 -1
- package/dist/compose-services.js +27 -12
- package/dist/compose-services.js.map +1 -1
- package/dist/config-snapshot.d.ts +6 -0
- package/dist/config-snapshot.d.ts.map +1 -0
- package/dist/config-snapshot.js +23 -0
- package/dist/config-snapshot.js.map +1 -0
- package/dist/config.d.ts +11 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +20 -3
- package/dist/config.js.map +1 -1
- package/dist/database-url-owner.d.ts +59 -0
- package/dist/database-url-owner.d.ts.map +1 -0
- package/dist/database-url-owner.js +133 -0
- package/dist/database-url-owner.js.map +1 -0
- package/dist/db-port-offer.d.ts +18 -0
- package/dist/db-port-offer.d.ts.map +1 -0
- package/dist/db-port-offer.js +68 -0
- package/dist/db-port-offer.js.map +1 -0
- package/dist/db-port.d.ts +42 -18
- package/dist/db-port.d.ts.map +1 -1
- package/dist/db-port.js +34 -32
- package/dist/db-port.js.map +1 -1
- package/dist/db-preflight.d.ts +37 -0
- package/dist/db-preflight.d.ts.map +1 -1
- package/dist/db-preflight.js +219 -77
- package/dist/db-preflight.js.map +1 -1
- package/dist/db-rows.d.ts +11 -0
- package/dist/db-rows.d.ts.map +1 -1
- package/dist/db-rows.js +27 -0
- package/dist/db-rows.js.map +1 -1
- package/dist/debounce.d.ts +11 -0
- package/dist/debounce.d.ts.map +1 -0
- package/dist/debounce.js +23 -0
- package/dist/debounce.js.map +1 -0
- package/dist/dev-api-keys.d.ts +12 -2
- package/dist/dev-api-keys.d.ts.map +1 -1
- package/dist/dev-api-keys.js +33 -17
- package/dist/dev-api-keys.js.map +1 -1
- package/dist/dev-compose.d.ts +10 -12
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +252 -288
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-db-ready.d.ts.map +1 -1
- package/dist/dev-db-ready.js +2 -1
- package/dist/dev-db-ready.js.map +1 -1
- package/dist/dev-db-reset.d.ts.map +1 -1
- package/dist/dev-db-reset.js +5 -4
- package/dist/dev-db-reset.js.map +1 -1
- package/dist/dev-functions-watch.d.ts.map +1 -1
- package/dist/dev-functions-watch.js +5 -16
- package/dist/dev-functions-watch.js.map +1 -1
- package/dist/dev-log-bus.d.ts +8 -0
- package/dist/dev-log-bus.d.ts.map +1 -1
- package/dist/dev-log-bus.js +13 -0
- package/dist/dev-log-bus.js.map +1 -1
- package/dist/dev-ports.d.ts +27 -7
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +68 -41
- package/dist/dev-ports.js.map +1 -1
- package/dist/dev-schema-watch.d.ts.map +1 -1
- package/dist/dev-schema-watch.js +7 -12
- package/dist/dev-schema-watch.js.map +1 -1
- package/dist/dev-session-lock.js +4 -3
- package/dist/dev-session-lock.js.map +1 -1
- package/dist/dev-session.d.ts +15 -0
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +27 -1
- package/dist/dev-session.js.map +1 -1
- package/dist/dev-shutdown.d.ts +45 -0
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +221 -33
- package/dist/dev-shutdown.js.map +1 -1
- package/dist/diff-output.d.ts +7 -1
- package/dist/diff-output.d.ts.map +1 -1
- package/dist/diff-output.js +91 -2
- package/dist/diff-output.js.map +1 -1
- package/dist/docker-address-pool.d.ts +23 -0
- package/dist/docker-address-pool.d.ts.map +1 -0
- package/dist/docker-address-pool.js +56 -0
- package/dist/docker-address-pool.js.map +1 -0
- package/dist/docker-exec.d.ts +92 -0
- package/dist/docker-exec.d.ts.map +1 -0
- package/dist/docker-exec.js +139 -0
- package/dist/docker-exec.js.map +1 -0
- package/dist/docker-postgres.d.ts +1 -6
- package/dist/docker-postgres.d.ts.map +1 -1
- package/dist/docker-postgres.js +67 -85
- package/dist/docker-postgres.js.map +1 -1
- package/dist/docker-runtime.d.ts +14 -1
- package/dist/docker-runtime.d.ts.map +1 -1
- package/dist/docker-runtime.js +55 -24
- package/dist/docker-runtime.js.map +1 -1
- package/dist/dotenv-parse.d.ts +22 -0
- package/dist/dotenv-parse.d.ts.map +1 -0
- package/dist/dotenv-parse.js +63 -0
- package/dist/dotenv-parse.js.map +1 -0
- package/dist/engine-answers.d.ts +0 -2
- package/dist/engine-answers.d.ts.map +1 -1
- package/dist/engine-answers.js +4 -3
- package/dist/engine-answers.js.map +1 -1
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +13 -12
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-floor.d.ts +29 -0
- package/dist/engine-floor.d.ts.map +1 -1
- package/dist/engine-floor.js +56 -0
- package/dist/engine-floor.js.map +1 -1
- package/dist/engine-ownership-gate.d.ts +13 -1
- package/dist/engine-ownership-gate.d.ts.map +1 -1
- package/dist/engine-ownership-gate.js +36 -6
- package/dist/engine-ownership-gate.js.map +1 -1
- package/dist/ensure-binary.d.ts +9 -0
- package/dist/ensure-binary.d.ts.map +1 -1
- package/dist/ensure-binary.js +38 -5
- package/dist/ensure-binary.js.map +1 -1
- package/dist/ensure-component-binaries.d.ts.map +1 -1
- package/dist/ensure-component-binaries.js +2 -1
- package/dist/ensure-component-binaries.js.map +1 -1
- package/dist/env-file.d.ts +30 -8
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +84 -57
- package/dist/env-file.js.map +1 -1
- package/dist/env-lines.d.ts +11 -0
- package/dist/env-lines.d.ts.map +1 -0
- package/dist/env-lines.js +36 -0
- package/dist/env-lines.js.map +1 -0
- package/dist/error-message.d.ts +34 -1
- package/dist/error-message.d.ts.map +1 -1
- package/dist/error-message.js +102 -2
- package/dist/error-message.js.map +1 -1
- package/dist/fetch-within.d.ts +10 -0
- package/dist/fetch-within.d.ts.map +1 -0
- package/dist/fetch-within.js +12 -0
- package/dist/fetch-within.js.map +1 -0
- package/dist/field-masking-tier.d.ts.map +1 -1
- package/dist/field-masking-tier.js +7 -5
- package/dist/field-masking-tier.js.map +1 -1
- package/dist/frontend-env.d.ts +43 -0
- package/dist/frontend-env.d.ts.map +1 -0
- package/dist/frontend-env.js +81 -0
- package/dist/frontend-env.js.map +1 -0
- package/dist/functions-context-refresh.d.ts +6 -2
- package/dist/functions-context-refresh.d.ts.map +1 -1
- package/dist/functions-context-refresh.js +11 -3
- package/dist/functions-context-refresh.js.map +1 -1
- package/dist/functions-deno-types.d.ts.map +1 -1
- package/dist/functions-deno-types.js +9 -2
- package/dist/functions-deno-types.js.map +1 -1
- package/dist/{functions-router-gen.d.ts → functions-discovery.d.ts} +8 -10
- package/dist/functions-discovery.d.ts.map +1 -0
- package/dist/functions-discovery.js +87 -0
- package/dist/functions-discovery.js.map +1 -0
- package/dist/functions-template.d.ts.map +1 -1
- package/dist/functions-template.js +20 -12
- package/dist/functions-template.js.map +1 -1
- package/dist/functions-worker-files.d.ts +55 -0
- package/dist/functions-worker-files.d.ts.map +1 -0
- package/dist/functions-worker-files.js +149 -0
- package/dist/functions-worker-files.js.map +1 -0
- package/dist/generated/functions-worker-source.d.ts +2 -0
- package/dist/generated/functions-worker-source.d.ts.map +1 -0
- package/dist/generated/functions-worker-source.js +12 -0
- package/dist/generated/functions-worker-source.js.map +1 -0
- package/dist/generated/release-images.d.ts +18 -0
- package/dist/generated/release-images.d.ts.map +1 -0
- package/dist/generated/release-images.js +8 -0
- package/dist/generated/release-images.js.map +1 -0
- package/dist/generated-files-engine.d.ts +33 -0
- package/dist/generated-files-engine.d.ts.map +1 -0
- package/dist/generated-files-engine.js +45 -0
- package/dist/generated-files-engine.js.map +1 -0
- package/dist/hook-actor.d.ts +17 -0
- package/dist/hook-actor.d.ts.map +1 -0
- package/dist/hook-actor.js +37 -0
- package/dist/hook-actor.js.map +1 -0
- package/dist/hook-columns.d.ts +30 -0
- package/dist/hook-columns.d.ts.map +1 -0
- package/dist/hook-columns.js +77 -0
- package/dist/hook-columns.js.map +1 -0
- package/dist/hook-events.d.ts +11 -0
- package/dist/hook-events.d.ts.map +1 -0
- package/dist/hook-events.js +11 -0
- package/dist/hook-events.js.map +1 -0
- package/dist/hook-upload.d.ts +29 -15
- package/dist/hook-upload.d.ts.map +1 -1
- package/dist/hook-upload.js +88 -59
- package/dist/hook-upload.js.map +1 -1
- package/dist/hooks-generator.d.ts +5 -0
- package/dist/hooks-generator.d.ts.map +1 -1
- package/dist/hooks-generator.js +92 -21
- package/dist/hooks-generator.js.map +1 -1
- package/dist/host-database.d.ts.map +1 -1
- package/dist/host-database.js +31 -4
- package/dist/host-database.js.map +1 -1
- package/dist/init-dependency-versions.d.ts +3 -1
- package/dist/init-dependency-versions.d.ts.map +1 -1
- package/dist/init-dependency-versions.js +32 -6
- package/dist/init-dependency-versions.js.map +1 -1
- package/dist/init-example.d.ts +48 -0
- package/dist/init-example.d.ts.map +1 -0
- package/dist/init-example.js +110 -0
- package/dist/init-example.js.map +1 -0
- package/dist/init-package-json.d.ts +38 -1
- package/dist/init-package-json.d.ts.map +1 -1
- package/dist/init-package-json.js +150 -37
- package/dist/init-package-json.js.map +1 -1
- package/dist/init-setup-steps.d.ts +37 -0
- package/dist/init-setup-steps.d.ts.map +1 -0
- package/dist/init-setup-steps.js +118 -0
- package/dist/init-setup-steps.js.map +1 -0
- package/dist/jwt-secret-length.d.ts +5 -13
- package/dist/jwt-secret-length.d.ts.map +1 -1
- package/dist/jwt-secret-length.js +7 -22
- package/dist/jwt-secret-length.js.map +1 -1
- package/dist/jwt-secret-rules.d.ts +24 -0
- package/dist/jwt-secret-rules.d.ts.map +1 -0
- package/dist/jwt-secret-rules.js +46 -0
- package/dist/jwt-secret-rules.js.map +1 -0
- package/dist/local-gateway.d.ts +3 -6
- package/dist/local-gateway.d.ts.map +1 -1
- package/dist/local-gateway.js +7 -9
- package/dist/local-gateway.js.map +1 -1
- package/dist/local-secrets.d.ts +95 -11
- package/dist/local-secrets.d.ts.map +1 -1
- package/dist/local-secrets.js +153 -18
- package/dist/local-secrets.js.map +1 -1
- package/dist/local-stack.d.ts.map +1 -1
- package/dist/local-stack.js +2 -7
- package/dist/local-stack.js.map +1 -1
- package/dist/local-storage.d.ts +7 -2
- package/dist/local-storage.d.ts.map +1 -1
- package/dist/local-storage.js +11 -3
- package/dist/local-storage.js.map +1 -1
- package/dist/mailer-env.d.ts +37 -0
- package/dist/mailer-env.d.ts.map +1 -0
- package/dist/mailer-env.js +98 -0
- package/dist/mailer-env.js.map +1 -0
- package/dist/model-cache.d.ts +4 -8
- package/dist/model-cache.d.ts.map +1 -1
- package/dist/model-cache.js.map +1 -1
- package/dist/model-hooks.d.ts +21 -7
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +62 -39
- package/dist/model-hooks.js.map +1 -1
- package/dist/native-dev-env.d.ts +37 -1
- package/dist/native-dev-env.d.ts.map +1 -1
- package/dist/native-dev-env.js +64 -2
- package/dist/native-dev-env.js.map +1 -1
- package/dist/native-functions-watch.d.ts +56 -5
- package/dist/native-functions-watch.d.ts.map +1 -1
- package/dist/native-functions-watch.js +119 -38
- package/dist/native-functions-watch.js.map +1 -1
- package/dist/native-keyspace.d.ts.map +1 -1
- package/dist/native-keyspace.js +2 -2
- package/dist/native-keyspace.js.map +1 -1
- package/dist/native-realtime.d.ts +11 -3
- package/dist/native-realtime.d.ts.map +1 -1
- package/dist/native-realtime.js +162 -10
- package/dist/native-realtime.js.map +1 -1
- package/dist/native-roles-sql.d.ts +14 -0
- package/dist/native-roles-sql.d.ts.map +1 -1
- package/dist/native-roles-sql.js +82 -1
- package/dist/native-roles-sql.js.map +1 -1
- package/dist/native-storage-import.d.ts +19 -0
- package/dist/native-storage-import.d.ts.map +1 -0
- package/dist/native-storage-import.js +327 -0
- package/dist/native-storage-import.js.map +1 -0
- package/dist/native-storage.d.ts +45 -0
- package/dist/native-storage.d.ts.map +1 -0
- package/dist/native-storage.js +140 -0
- package/dist/native-storage.js.map +1 -0
- package/dist/native-worker.d.ts +26 -0
- package/dist/native-worker.d.ts.map +1 -0
- package/dist/native-worker.js +63 -0
- package/dist/native-worker.js.map +1 -0
- package/dist/owner-default.d.ts +9 -1
- package/dist/owner-default.d.ts.map +1 -1
- package/dist/owner-default.js +17 -4
- package/dist/owner-default.js.map +1 -1
- package/dist/post-apply.d.ts +3 -0
- package/dist/post-apply.d.ts.map +1 -0
- package/dist/post-apply.js +17 -0
- package/dist/post-apply.js.map +1 -0
- package/dist/postgres-ctl.d.ts +98 -7
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +273 -40
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/postgres-image.d.ts +15 -3
- package/dist/postgres-image.d.ts.map +1 -1
- package/dist/postgres-image.js +18 -15
- package/dist/postgres-image.js.map +1 -1
- package/dist/postgrest-release.d.ts +9 -0
- package/dist/postgrest-release.d.ts.map +1 -1
- package/dist/postgrest-release.js +23 -0
- package/dist/postgrest-release.js.map +1 -1
- package/dist/process-manager.d.ts.map +1 -1
- package/dist/process-manager.js +3 -1
- package/dist/process-manager.js.map +1 -1
- package/dist/project-config.d.ts +44 -7
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +48 -4
- package/dist/project-config.js.map +1 -1
- package/dist/pull-utils.d.ts +15 -0
- package/dist/pull-utils.d.ts.map +1 -1
- package/dist/pull-utils.js +149 -23
- package/dist/pull-utils.js.map +1 -1
- package/dist/push-refusal.d.ts.map +1 -1
- package/dist/push-refusal.js +3 -2
- package/dist/push-refusal.js.map +1 -1
- package/dist/realtime-launch.d.ts +2 -5
- package/dist/realtime-launch.d.ts.map +1 -1
- package/dist/realtime-launch.js +6 -23
- package/dist/realtime-launch.js.map +1 -1
- package/dist/recorded-field-masking-tier.d.ts.map +1 -1
- package/dist/recorded-field-masking-tier.js +4 -3
- package/dist/recorded-field-masking-tier.js.map +1 -1
- package/dist/release-images.d.ts +31 -0
- package/dist/release-images.d.ts.map +1 -0
- package/dist/release-images.js +90 -0
- package/dist/release-images.js.map +1 -0
- package/dist/required-host-components.d.ts.map +1 -1
- package/dist/required-host-components.js +4 -0
- package/dist/required-host-components.js.map +1 -1
- package/dist/resolve-api-url.d.ts +17 -3
- package/dist/resolve-api-url.d.ts.map +1 -1
- package/dist/resolve-api-url.js +71 -30
- package/dist/resolve-api-url.js.map +1 -1
- package/dist/resolve-target.d.ts +64 -0
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +75 -27
- package/dist/resolve-target.js.map +1 -1
- package/dist/rest-ready.d.ts.map +1 -1
- package/dist/rest-ready.js +2 -1
- package/dist/rest-ready.js.map +1 -1
- package/dist/route-manifest.d.ts +25 -2
- package/dist/route-manifest.d.ts.map +1 -1
- package/dist/route-manifest.js +48 -4
- package/dist/route-manifest.js.map +1 -1
- package/dist/run-until-stopped.d.ts +12 -0
- package/dist/run-until-stopped.d.ts.map +1 -0
- package/dist/run-until-stopped.js +42 -0
- package/dist/run-until-stopped.js.map +1 -0
- package/dist/schema-ast-v2.d.ts +2 -1
- package/dist/schema-ast-v2.d.ts.map +1 -1
- package/dist/schema-ast-v2.js.map +1 -1
- package/dist/schema-push-lock.d.ts.map +1 -1
- package/dist/schema-push-lock.js +59 -46
- package/dist/schema-push-lock.js.map +1 -1
- package/dist/schema-sources.d.ts +19 -4
- package/dist/schema-sources.d.ts.map +1 -1
- package/dist/schema-sources.js +56 -35
- package/dist/schema-sources.js.map +1 -1
- package/dist/seed-auth-connect.d.ts +14 -0
- package/dist/seed-auth-connect.d.ts.map +1 -0
- package/dist/seed-auth-connect.js +97 -0
- package/dist/seed-auth-connect.js.map +1 -0
- package/dist/seed-runner.d.ts.map +1 -1
- package/dist/seed-runner.js +22 -1
- package/dist/seed-runner.js.map +1 -1
- package/dist/seed.d.ts +6 -3
- package/dist/seed.d.ts.map +1 -1
- package/dist/self-host-compose.d.ts +44 -29
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +311 -159
- package/dist/self-host-compose.js.map +1 -1
- package/dist/service-role-key-file.d.ts +32 -0
- package/dist/service-role-key-file.d.ts.map +1 -0
- package/dist/service-role-key-file.js +90 -0
- package/dist/service-role-key-file.js.map +1 -0
- package/dist/shell-ports.d.ts +13 -2
- package/dist/shell-ports.d.ts.map +1 -1
- package/dist/shell-ports.js +20 -15
- package/dist/shell-ports.js.map +1 -1
- package/dist/stop-signals.d.ts +7 -0
- package/dist/stop-signals.d.ts.map +1 -0
- package/dist/stop-signals.js +12 -0
- package/dist/stop-signals.js.map +1 -0
- package/dist/storage-launch.d.ts +11 -0
- package/dist/storage-launch.d.ts.map +1 -0
- package/dist/storage-launch.js +41 -0
- package/dist/storage-launch.js.map +1 -0
- package/dist/storage-provision.d.ts +50 -5
- package/dist/storage-provision.d.ts.map +1 -1
- package/dist/storage-provision.js +101 -33
- package/dist/storage-provision.js.map +1 -1
- package/dist/systemd.d.ts +1 -1
- package/dist/systemd.d.ts.map +1 -1
- package/dist/systemd.js +26 -11
- package/dist/systemd.js.map +1 -1
- package/dist/tar-reader.d.ts +29 -0
- package/dist/tar-reader.d.ts.map +1 -0
- package/dist/tar-reader.js +99 -0
- package/dist/tar-reader.js.map +1 -0
- package/dist/target-client.d.ts +14 -1
- package/dist/target-client.d.ts.map +1 -1
- package/dist/target-client.js +134 -23
- package/dist/target-client.js.map +1 -1
- package/dist/target-request.d.ts +25 -0
- package/dist/target-request.d.ts.map +1 -0
- package/dist/target-request.js +33 -0
- package/dist/target-request.js.map +1 -0
- package/dist/target-warning.d.ts +7 -0
- package/dist/target-warning.d.ts.map +1 -0
- package/dist/target-warning.js +12 -0
- package/dist/target-warning.js.map +1 -0
- package/dist/tsx-runner.d.ts.map +1 -1
- package/dist/tsx-runner.js +2 -1
- package/dist/tsx-runner.js.map +1 -1
- package/dist/type-extractor.d.ts +6 -0
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +138 -70
- package/dist/type-extractor.js.map +1 -1
- package/dist/ui/clack.d.ts.map +1 -1
- package/dist/ui/clack.js +11 -1
- package/dist/ui/clack.js.map +1 -1
- package/dist/ui/dev/DevDashboard.d.ts.map +1 -1
- package/dist/ui/dev/DevDashboard.js +13 -5
- package/dist/ui/dev/DevDashboard.js.map +1 -1
- package/dist/ui/fatal.d.ts.map +1 -1
- package/dist/ui/fatal.js +6 -7
- package/dist/ui/fatal.js.map +1 -1
- package/dist/ui/flows/FlowApp.d.ts.map +1 -1
- package/dist/ui/flows/FlowApp.js +16 -1
- package/dist/ui/flows/FlowApp.js.map +1 -1
- package/dist/ui/flows/prompt-fields.d.ts +16 -6
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
- package/dist/ui/flows/prompt-fields.js +19 -9
- package/dist/ui/flows/prompt-fields.js.map +1 -1
- package/dist/ui/messages.d.ts +6 -0
- package/dist/ui/messages.d.ts.map +1 -1
- package/dist/ui/messages.js +17 -0
- package/dist/ui/messages.js.map +1 -1
- package/dist/ui/progress.d.ts +7 -0
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +22 -8
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/runtime/command-chrome.d.ts.map +1 -1
- package/dist/ui/runtime/command-chrome.js +2 -0
- package/dist/ui/runtime/command-chrome.js.map +1 -1
- package/dist/ui/runtime/prompt-interrupt.d.ts +10 -0
- package/dist/ui/runtime/prompt-interrupt.d.ts.map +1 -0
- package/dist/ui/runtime/prompt-interrupt.js +24 -0
- package/dist/ui/runtime/prompt-interrupt.js.map +1 -0
- package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -1
- package/dist/ui/runtime/run-clack-flow.js +5 -2
- package/dist/ui/runtime/run-clack-flow.js.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts +14 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.js +44 -3
- package/dist/ui/runtime/stdin-after-ink.js.map +1 -1
- package/dist/url-safe-passwords.d.ts +25 -0
- package/dist/url-safe-passwords.d.ts.map +1 -0
- package/dist/url-safe-passwords.js +70 -0
- package/dist/url-safe-passwords.js.map +1 -0
- package/dist/valkey-sidecar.d.ts +33 -6
- package/dist/valkey-sidecar.d.ts.map +1 -1
- package/dist/valkey-sidecar.js +90 -61
- package/dist/valkey-sidecar.js.map +1 -1
- package/dist/worker-module-files.d.ts +3 -0
- package/dist/worker-module-files.d.ts.map +1 -0
- package/dist/worker-module-files.js +18 -0
- package/dist/worker-module-files.js.map +1 -0
- package/package.json +22 -16
- package/dist/functions-router-gen.d.ts.map +0 -1
- package/dist/functions-router-gen.js +0 -302
- package/dist/functions-router-gen.js.map +0 -1
package/dist/db-port.d.ts
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keep `DATABASE_URL` pointing at the port Postgres is actually published on.
|
|
3
|
+
*
|
|
4
|
+
* `SUPATYPE_DB_PORT` moves the host side of the compose port mapping, so a second project on one
|
|
5
|
+
* machine can avoid a clash. `DATABASE_URL` is what every host-side script uses: seeds, one-off
|
|
6
|
+
* psql, `supatype admin create-user --connection`. `init` writes the URL with 5432 in it and
|
|
7
|
+
* nothing has ever reconciled the two.
|
|
8
|
+
*
|
|
9
|
+
* The result is a project that starts cleanly, serves every request, and fails the first time
|
|
10
|
+
* someone runs `npm run seed`:
|
|
11
|
+
*
|
|
12
|
+
* AggregateError [ECONNREFUSED]: connect ECONNREFUSED 127.0.0.1:5432
|
|
13
|
+
*
|
|
14
|
+
* with the database listening on 5433 and nothing connecting the error to the port variable the
|
|
15
|
+
* person set half an hour earlier. The generated `.env` even carries a comment conceding the
|
|
16
|
+
* assumption: "Self-host compose uses the same DATABASE_URL when Postgres is published on
|
|
17
|
+
* localhost:5432."
|
|
18
|
+
*
|
|
19
|
+
* The variable compose binds for the stack's layout is the source of truth: `SUPATYPE_DB_PORT` for
|
|
20
|
+
* a self-host stack, `SUPATYPE_DEV_DB_PORT` for a dev one. The URL follows it, when the CLI wrote
|
|
21
|
+
* it: this file says where Postgres is published and reads connection strings, and the one writer
|
|
22
|
+
* of `.env`'s URL, which decides whose it is first, is database-url-owner.ts.
|
|
23
|
+
*/
|
|
1
24
|
/** The `.env` key that moves the published Postgres port for a self-host stack. */
|
|
2
25
|
export declare const DB_PORT_ENV = "SUPATYPE_DB_PORT";
|
|
3
26
|
/**
|
|
@@ -48,33 +71,34 @@ export interface ComposeDbPublish {
|
|
|
48
71
|
* `SUPATYPE_DEV_DB_PORT` on a production stack that publishes `SUPATYPE_DB_PORT`).
|
|
49
72
|
*/
|
|
50
73
|
export declare function composeDbPublish(devLocal: boolean): ComposeDbPublish;
|
|
51
|
-
/**
|
|
52
|
-
export declare
|
|
74
|
+
/** Hosts whose port is ours to correct. Anything else is somebody else's database. */
|
|
75
|
+
export declare const LOCAL_HOSTS: ReadonlySet<string>;
|
|
76
|
+
/** The port Postgres is published on for this project in one layout, from `.env` or the shell. */
|
|
77
|
+
export declare function publishedDbPort(env: Readonly<Record<string, string | undefined>>, devLocal: boolean): number;
|
|
53
78
|
/** What changed, for the caller to report. */
|
|
54
79
|
export interface DbPortSync {
|
|
55
80
|
from: string;
|
|
56
81
|
to: string;
|
|
57
82
|
/** The variable the new port was read from, which is what the report must name. */
|
|
58
83
|
envKey: ComposeDbPublish["envKey"];
|
|
84
|
+
/** The port came from the shell, so the URL changed for this run only and `.env` did not. */
|
|
85
|
+
runOnly?: true;
|
|
59
86
|
}
|
|
60
87
|
/** The line every caller prints for a {@link DbPortSync}, naming the variable it read. */
|
|
61
88
|
export declare function databaseUrlSyncMessage(sync: DbPortSync): string;
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
* `SUPATYPE_DEV_DB_PORT` there, and preferring it on a self-host push repointed every host-side
|
|
69
|
-
* command (seed, admin) at the dev database.
|
|
70
|
-
*
|
|
71
|
-
* Returns null when there is nothing to do, which is the common case.
|
|
72
|
-
*
|
|
73
|
-
* Only touches a URL pointing at this machine. A project whose `DATABASE_URL` names a managed
|
|
74
|
-
* Postgres elsewhere has a port that is nothing to do with our compose mapping, and rewriting it
|
|
75
|
-
* would repoint the whole project at a database that does not exist.
|
|
76
|
-
*/
|
|
77
|
-
export declare function syncDatabaseUrlPort(cwd: string, devLocal: boolean): DbPortSync | null;
|
|
89
|
+
/** `value` with its port set to `port`, when it names this machine on a different port. */
|
|
90
|
+
export declare function databaseUrlWithPort(value: string | undefined, port: number): {
|
|
91
|
+
url: string;
|
|
92
|
+
from: string;
|
|
93
|
+
to: string;
|
|
94
|
+
} | null;
|
|
78
95
|
/** True when `url` is a connection string to a database on this machine. */
|
|
79
96
|
export declare function isLocalDatabaseUrl(url: string): boolean;
|
|
97
|
+
/** `DATABASE_URL` parsed, when it names this machine; null when it is unset, malformed or remote. */
|
|
98
|
+
export declare function localDatabaseUrl(value: string | undefined): URL | null;
|
|
99
|
+
/** The host and port a Postgres URL names, the port defaulting to 5432; undefined when it does not parse. */
|
|
100
|
+
export declare function databaseUrlHostPort(value: string | undefined): {
|
|
101
|
+
host: string;
|
|
102
|
+
port: number;
|
|
103
|
+
} | undefined;
|
|
80
104
|
//# sourceMappingURL=db-port.d.ts.map
|
package/dist/db-port.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-port.d.ts","sourceRoot":"","sources":["../src/db-port.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"db-port.d.ts","sourceRoot":"","sources":["../src/db-port.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,mFAAmF;AACnF,eAAO,MAAM,WAAW,qBAAqB,CAAA;AAE7C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,yBAAyB,CAAA;AAErD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,4BAA4B,CAAA;AAE3D,4FAA4F;AAC5F,eAAO,MAAM,eAAe,OAAO,CAAA;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,6BAA6B,CAAA;AAE7D,oFAAoF;AACpF,eAAO,MAAM,cAAc,4CAA4C,CAAA;AAEvE,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,QAAQ,CAAA;AAExC,2EAA2E;AAC3E,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,MAAM,EAAE,OAAO,eAAe,GAAG,OAAO,WAAW,CAAA;IACnD,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAA;IACnB,iGAAiG;IACjG,WAAW,EAAE,YAAY,GAAG,OAAO,cAAc,CAAA;CAClD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CAIpE;AAED,sFAAsF;AACtF,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,MAAM,CAAuD,CAAA;AAEnG,kGAAkG;AAClG,wBAAgB,eAAe,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAO5G;AAED,8CAA8C;AAC9C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,mFAAmF;IACnF,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAClC,6FAA6F;IAC7F,OAAO,CAAC,EAAE,IAAI,CAAA;CACf;AAED,0FAA0F;AAC1F,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAI/D;AAED,2FAA2F;AAC3F,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,IAAI,EAAE,MAAM,GACX;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAQlD;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,qGAAqG;AACrG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,GAAG,IAAI,CAGtE;AAED,6GAA6G;AAC7G,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAGzG"}
|
package/dist/db-port.js
CHANGED
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
* localhost:5432."
|
|
18
18
|
*
|
|
19
19
|
* The variable compose binds for the stack's layout is the source of truth: `SUPATYPE_DB_PORT` for
|
|
20
|
-
* a self-host stack, `SUPATYPE_DEV_DB_PORT` for a dev one. The URL follows it
|
|
20
|
+
* a self-host stack, `SUPATYPE_DEV_DB_PORT` for a dev one. The URL follows it, when the CLI wrote
|
|
21
|
+
* it: this file says where Postgres is published and reads connection strings, and the one writer
|
|
22
|
+
* of `.env`'s URL, which decides whose it is first, is database-url-owner.ts.
|
|
21
23
|
*/
|
|
22
|
-
import { readEnvFile, upsertEnvFile } from "./env-file.js";
|
|
23
24
|
/** The `.env` key that moves the published Postgres port for a self-host stack. */
|
|
24
25
|
export const DB_PORT_ENV = "SUPATYPE_DB_PORT";
|
|
25
26
|
/**
|
|
@@ -66,8 +67,8 @@ export function composeDbPublish(devLocal) {
|
|
|
66
67
|
: { envKey: DB_PORT_ENV, defaultPort: DEFAULT_DB_PORT, bindAddress: SELF_HOST_BIND };
|
|
67
68
|
}
|
|
68
69
|
/** Hosts whose port is ours to correct. Anything else is somebody else's database. */
|
|
69
|
-
const LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
70
|
-
/** The port Postgres is published on for this project in one layout, from `.env
|
|
70
|
+
export const LOCAL_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
71
|
+
/** The port Postgres is published on for this project in one layout, from `.env` or the shell. */
|
|
71
72
|
export function publishedDbPort(env, devLocal) {
|
|
72
73
|
const { envKey, defaultPort } = composeDbPublish(devLocal);
|
|
73
74
|
const raw = (env[envKey] ?? "").trim();
|
|
@@ -78,52 +79,53 @@ export function publishedDbPort(env, devLocal) {
|
|
|
78
79
|
}
|
|
79
80
|
/** The line every caller prints for a {@link DbPortSync}, naming the variable it read. */
|
|
80
81
|
export function databaseUrlSyncMessage(sync) {
|
|
81
|
-
return
|
|
82
|
+
return sync.runOnly === true
|
|
83
|
+
? `DATABASE_URL port ${sync.from} -> ${sync.to} for this run, to match ${sync.envKey} in your shell. .env is unchanged.`
|
|
84
|
+
: `DATABASE_URL port ${sync.from} -> ${sync.to} in .env, to match ${sync.envKey}.`;
|
|
82
85
|
}
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*
|
|
87
|
-
* `devLocal` is the layout of the stack the caller is working with, never a guess from which
|
|
88
|
-
* variables happen to be in `.env`: a project that once ran `supatype dev` keeps
|
|
89
|
-
* `SUPATYPE_DEV_DB_PORT` there, and preferring it on a self-host push repointed every host-side
|
|
90
|
-
* command (seed, admin) at the dev database.
|
|
91
|
-
*
|
|
92
|
-
* Returns null when there is nothing to do, which is the common case.
|
|
93
|
-
*
|
|
94
|
-
* Only touches a URL pointing at this machine. A project whose `DATABASE_URL` names a managed
|
|
95
|
-
* Postgres elsewhere has a port that is nothing to do with our compose mapping, and rewriting it
|
|
96
|
-
* would repoint the whole project at a database that does not exist.
|
|
97
|
-
*/
|
|
98
|
-
export function syncDatabaseUrlPort(cwd, devLocal) {
|
|
99
|
-
const env = readEnvFile(cwd);
|
|
100
|
-
const url = localDatabaseUrl(env["DATABASE_URL"]);
|
|
86
|
+
/** `value` with its port set to `port`, when it names this machine on a different port. */
|
|
87
|
+
export function databaseUrlWithPort(value, port) {
|
|
88
|
+
const url = localDatabaseUrl(value);
|
|
101
89
|
if (url === null)
|
|
102
90
|
return null;
|
|
103
|
-
const wanted = String(
|
|
104
|
-
const current =
|
|
91
|
+
const wanted = String(port);
|
|
92
|
+
const current = String(urlPort(url));
|
|
105
93
|
if (current === wanted)
|
|
106
94
|
return null;
|
|
107
95
|
url.port = wanted;
|
|
108
|
-
|
|
109
|
-
return { from: current, to: wanted, envKey: composeDbPublish(devLocal).envKey };
|
|
96
|
+
return { url: url.toString(), from: current, to: wanted };
|
|
110
97
|
}
|
|
111
98
|
/** True when `url` is a connection string to a database on this machine. */
|
|
112
99
|
export function isLocalDatabaseUrl(url) {
|
|
113
100
|
return localDatabaseUrl(url) !== null;
|
|
114
101
|
}
|
|
115
102
|
/** `DATABASE_URL` parsed, when it names this machine; null when it is unset, malformed or remote. */
|
|
116
|
-
function localDatabaseUrl(value) {
|
|
103
|
+
export function localDatabaseUrl(value) {
|
|
104
|
+
const url = parsedDatabaseUrl(value);
|
|
105
|
+
return url !== null && LOCAL_HOSTS.has(url.hostname) ? url : null;
|
|
106
|
+
}
|
|
107
|
+
/** The host and port a Postgres URL names, the port defaulting to 5432; undefined when it does not parse. */
|
|
108
|
+
export function databaseUrlHostPort(value) {
|
|
109
|
+
const url = parsedDatabaseUrl(value);
|
|
110
|
+
return url === null ? undefined : { host: url.hostname.replace(/^\[|\]$/g, ""), port: urlPort(url) };
|
|
111
|
+
}
|
|
112
|
+
/** The port `url` names, or the one Postgres listens on when it names none. */
|
|
113
|
+
function urlPort(url) {
|
|
114
|
+
return url.port === "" ? DEFAULT_DB_PORT : Number(url.port);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A connection string parsed, or null when it is blank or malformed. Malformed is never ours to
|
|
118
|
+
* rewrite: a partial edit would turn a typo into a URL that parses and points somewhere wrong,
|
|
119
|
+
* which is harder to spot than the typo.
|
|
120
|
+
*/
|
|
121
|
+
function parsedDatabaseUrl(value) {
|
|
117
122
|
const raw = (value ?? "").trim();
|
|
118
123
|
if (raw === "")
|
|
119
124
|
return null;
|
|
120
125
|
try {
|
|
121
|
-
|
|
122
|
-
return LOCAL_HOSTS.has(url.hostname) ? url : null;
|
|
126
|
+
return new URL(raw);
|
|
123
127
|
}
|
|
124
128
|
catch {
|
|
125
|
-
// Malformed, so not ours to rewrite: a partial edit here would turn a typo into a URL that
|
|
126
|
-
// parses and points somewhere wrong, which is harder to spot than the typo.
|
|
127
129
|
return null;
|
|
128
130
|
}
|
|
129
131
|
}
|
package/dist/db-port.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-port.js","sourceRoot":"","sources":["../src/db-port.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"db-port.js","sourceRoot":"","sources":["../src/db-port.ts"],"names":[],"mappings":"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"}
|
package/dist/db-preflight.d.ts
CHANGED
|
@@ -47,6 +47,43 @@ type QueryFn = (sql: string, params?: unknown[]) => Promise<UnknownRow[]>;
|
|
|
47
47
|
* ledger is only read where it exists, since SQL cannot name a table that is not there.
|
|
48
48
|
*/
|
|
49
49
|
export declare function foreignTables(q: QueryFn, schema: string): Promise<string[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Why the database cannot give realtime logical decoding, or undefined when it can: the same checks
|
|
52
|
+
* `supatype db check` runs, so the two cannot disagree. For native dev to name the cause when
|
|
53
|
+
* realtime exits without a word, instead of guessing at it (local test round 3), and for doctor.
|
|
54
|
+
*/
|
|
55
|
+
export declare function decodingProblem(q: QueryFn): Promise<string | undefined>;
|
|
56
|
+
/** {@link decodingChecks} for the database at `databaseUrl`, on a connection of its own. */
|
|
57
|
+
export declare function logicalDecodingChecks(databaseUrl: string): Promise<CheckResult[]>;
|
|
58
|
+
/** {@link decodingProblem} for the database at `databaseUrl`, on a connection of its own. */
|
|
59
|
+
export declare function logicalDecodingProblem(databaseUrl: string): Promise<string | undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* Which path after-hooks take on this database, from {@link decodingChecks}. The change log sees
|
|
62
|
+
* every writer; the fallback is the server reading the written rows back after an API request,
|
|
63
|
+
* which cannot see a write that never went through the API.
|
|
64
|
+
*/
|
|
65
|
+
export declare function afterHooksSourceCheck(decoding: readonly CheckResult[]): CheckResult;
|
|
66
|
+
/** What after-hooks on the request path miss, said the same way by `db check` and `doctor`. */
|
|
67
|
+
export declare const REQUEST_PATH_IMPACT: string;
|
|
68
|
+
/**
|
|
69
|
+
* WAL a slot may hold before it is worth saying: a quarter of the `max_slot_wal_keep_size` the
|
|
70
|
+
* supatype/postgres image sets (4096 MB), past which Postgres gives up on the slot and its reader
|
|
71
|
+
* has to start again from now, losing what it had not read.
|
|
72
|
+
*/
|
|
73
|
+
export declare const RETAINED_WAL_WARN_BYTES: number;
|
|
74
|
+
/** Bytes as a reader would say them, in GiB to one place. */
|
|
75
|
+
export declare function gibibytes(bytes: number): string;
|
|
76
|
+
/** One of Supatype's slots and the WAL it holds, in bytes as Postgres prints them. */
|
|
77
|
+
export interface SlotRetention {
|
|
78
|
+
slot_name: string;
|
|
79
|
+
retained: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Whether a Supatype slot holds a lot of WAL. A reader that stopped (a stopped server, a listener
|
|
83
|
+
* stuck on a hook that never answers) keeps WAL on disk until it reads again, and on a small
|
|
84
|
+
* volume that is how the database fills its disk with nothing saying why.
|
|
85
|
+
*/
|
|
86
|
+
export declare function retainedWalCheck(slots: readonly SlotRetention[]): CheckResult;
|
|
50
87
|
/** One row per API role that exists, for the schema named in the query. */
|
|
51
88
|
export interface ClaimsSchemaUsageRow {
|
|
52
89
|
rolname: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db-preflight.d.ts","sourceRoot":"","sources":["../src/db-preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,OAAO,
|
|
1
|
+
{"version":3,"file":"db-preflight.d.ts","sourceRoot":"","sources":["../src/db-preflight.ts"],"names":[],"mappings":"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"}
|
package/dist/db-preflight.js
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
* should know something, and nothing is wrong.
|
|
17
17
|
*/
|
|
18
18
|
import { isBoolean, isShape, isString, nullable } from "@supatype/shared";
|
|
19
|
-
import { queryRows } from "./db-rows.js";
|
|
20
|
-
import { errorCode } from "./error-message.js";
|
|
19
|
+
import { queryRows, withDatabase } from "./db-rows.js";
|
|
20
|
+
import { errorCode, errorMessage } from "./error-message.js";
|
|
21
21
|
/** Slot name for the decoding probe. Dropped immediately; never left behind. */
|
|
22
22
|
const PROBE_SLOT = "supatype_preflight_probe";
|
|
23
23
|
/**
|
|
@@ -30,6 +30,13 @@ async function queryAs(q, guard, sql, params = []) {
|
|
|
30
30
|
throw new Error(`Preflight probe returned a row it cannot read: ${sql}`);
|
|
31
31
|
return rows;
|
|
32
32
|
}
|
|
33
|
+
/** The one row of a probe that always returns exactly one. */
|
|
34
|
+
async function queryOne(q, guard, sql, params = []) {
|
|
35
|
+
const [row] = await queryAs(q, guard, sql, params);
|
|
36
|
+
if (row === undefined)
|
|
37
|
+
throw new Error(`Preflight probe returned no rows: ${sql}`);
|
|
38
|
+
return row;
|
|
39
|
+
}
|
|
33
40
|
/**
|
|
34
41
|
* Tables in `schema` Supatype did not create: not in its ledger (`_supatype.managed_objects`), and
|
|
35
42
|
* not stamped `supatype:managed` by an engine from before the ledger. Since the engine stopped
|
|
@@ -51,43 +58,218 @@ export async function foreignTables(q, schema) {
|
|
|
51
58
|
ORDER BY c.relname`, [schema]);
|
|
52
59
|
return rows.map((t) => t.relname);
|
|
53
60
|
}
|
|
61
|
+
/** The first decoding check that rules decoding out, or undefined when none does. */
|
|
62
|
+
function decodingBlocker(decoding) {
|
|
63
|
+
return decoding.find((r) => r.severity === "degrade" || r.severity === "fail");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Why the database cannot give realtime logical decoding, or undefined when it can: the same checks
|
|
67
|
+
* `supatype db check` runs, so the two cannot disagree. For native dev to name the cause when
|
|
68
|
+
* realtime exits without a word, instead of guessing at it (local test round 3), and for doctor.
|
|
69
|
+
*/
|
|
70
|
+
export async function decodingProblem(q) {
|
|
71
|
+
return decodingBlocker(await decodingChecks(q))?.detail;
|
|
72
|
+
}
|
|
73
|
+
/** {@link decodingChecks} for the database at `databaseUrl`, on a connection of its own. */
|
|
74
|
+
export async function logicalDecodingChecks(databaseUrl) {
|
|
75
|
+
return withDatabase(databaseUrl, (client) => decodingChecks((sql, params = []) => queryRows(client, sql, params)));
|
|
76
|
+
}
|
|
77
|
+
/** {@link decodingProblem} for the database at `databaseUrl`, on a connection of its own. */
|
|
78
|
+
export async function logicalDecodingProblem(databaseUrl) {
|
|
79
|
+
return decodingBlocker(await logicalDecodingChecks(databaseUrl))?.detail;
|
|
80
|
+
}
|
|
81
|
+
/** What a database that cannot decode loses, said the same way by every check that finds it. */
|
|
82
|
+
const NO_DECODING_IMPACT = "Realtime subscriptions are unavailable, and after-hooks fall back to the request path; everything " +
|
|
83
|
+
"else is unaffected.";
|
|
84
|
+
/**
|
|
85
|
+
* What logical decoding needs, which realtime and the after-hook listener share: `wal_level`, a
|
|
86
|
+
* spare slot, and a wal2json slot the connected role may create.
|
|
87
|
+
*/
|
|
88
|
+
async function decodingChecks(q) {
|
|
89
|
+
const { wal_level } = await queryOne(q, isShape({ wal_level: isString }), "SHOW wal_level");
|
|
90
|
+
const slots = await queryOne(q, isShape({ used: isString, max: isString, existing: isString, role: isString }), `SELECT (SELECT count(*) FROM pg_replication_slots)::text AS used,
|
|
91
|
+
current_setting('max_replication_slots') AS max,
|
|
92
|
+
coalesce((SELECT string_agg(slot_name, ',') FROM pg_replication_slots
|
|
93
|
+
WHERE slot_name = ANY($1)), '') AS existing,
|
|
94
|
+
current_user::text AS role`, [[...SUPATYPE_SLOTS]]);
|
|
95
|
+
const existing = slots.existing === "" ? [] : slots.existing.split(",");
|
|
96
|
+
const results = [walLevelCheck(wal_level), slotsCheck(slots.used, slots.max, existing)];
|
|
97
|
+
// The definitive check: create the slot realtime would create, then drop it.
|
|
98
|
+
//
|
|
99
|
+
// There is no catalog to consult. `wal2json` is a shared library, not an extension, so it never
|
|
100
|
+
// appears in `pg_available_extensions`: the only way to know whether this database can decode is
|
|
101
|
+
// to ask it to. Cloud SQL does not ship the plugin at all; plenty of managed Postgres will not
|
|
102
|
+
// grant `REPLICATION`. Both produce a stack that looks healthy until the first subscription.
|
|
103
|
+
//
|
|
104
|
+
// Skipped when `wal_level` or the slot budget already rules it out, since the probe would fail for
|
|
105
|
+
// that reason and report it a second time under a less specific heading.
|
|
106
|
+
if (results.every((r) => r.severity === "pass"))
|
|
107
|
+
results.push(await probeLogicalDecoding(q, slots.role));
|
|
108
|
+
return results;
|
|
109
|
+
}
|
|
110
|
+
function walLevelCheck(walLevel) {
|
|
111
|
+
const logical = walLevel === "logical";
|
|
112
|
+
return {
|
|
113
|
+
id: "wal-level",
|
|
114
|
+
title: "wal_level = logical (realtime, after-hooks)",
|
|
115
|
+
severity: logical ? "pass" : "degrade",
|
|
116
|
+
detail: logical ? `wal_level is "${walLevel}"` : `wal_level is "${walLevel}", not logical`,
|
|
117
|
+
...(!logical && {
|
|
118
|
+
impact: NO_DECODING_IMPACT,
|
|
119
|
+
remedy: "-- Requires a server restart, and on managed Postgres a parameter-group change\n" +
|
|
120
|
+
"-- rather than SQL. Shown for a self-managed server:\n" +
|
|
121
|
+
"ALTER SYSTEM SET wal_level = 'logical';",
|
|
122
|
+
remedyNeedsOperator: true,
|
|
123
|
+
}),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Room for the slots Supatype has not created yet. Realtime and the after-hook listener each keep a
|
|
128
|
+
* slot of their own, so a database with one free slot has room for only one of them.
|
|
129
|
+
*/
|
|
130
|
+
function slotsCheck(used, max, existing) {
|
|
131
|
+
const free = Math.max(Number(max) - Number(used), 0);
|
|
132
|
+
const needed = SUPATYPE_SLOTS.filter((slot) => !existing.includes(slot));
|
|
133
|
+
const leftOut = needed.slice(free);
|
|
134
|
+
return {
|
|
135
|
+
id: "replication-slots",
|
|
136
|
+
title: "A replication slot each for realtime and after-hooks",
|
|
137
|
+
severity: leftOut.length === 0 ? "pass" : "degrade",
|
|
138
|
+
detail: `${used} of ${max} in use` +
|
|
139
|
+
(leftOut.length === 0 ? "" : `, no room for ${leftOut.join(" or ")} (${needed.length} needed, ${free} free)`),
|
|
140
|
+
...(leftOut.length > 0 && {
|
|
141
|
+
impact: "Realtime and the after-hook listener each need a slot of their own, and the ones named cannot create one.",
|
|
142
|
+
remedy: `ALTER SYSTEM SET max_replication_slots = ${Number(used) + needed.length + 5};`,
|
|
143
|
+
remedyNeedsOperator: true,
|
|
144
|
+
}),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Which path after-hooks take on this database, from {@link decodingChecks}. The change log sees
|
|
149
|
+
* every writer; the fallback is the server reading the written rows back after an API request,
|
|
150
|
+
* which cannot see a write that never went through the API.
|
|
151
|
+
*/
|
|
152
|
+
export function afterHooksSourceCheck(decoding) {
|
|
153
|
+
const base = { id: "after-hooks-source", title: "Where after-hooks read writes from" };
|
|
154
|
+
const blocker = decodingBlocker(decoding);
|
|
155
|
+
if (blocker === undefined) {
|
|
156
|
+
return { ...base, severity: "pass", detail: "the change log: afterChange and afterDelete see every writer" };
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
...base,
|
|
160
|
+
severity: "degrade",
|
|
161
|
+
detail: `the request path, because ${blocker.detail}`,
|
|
162
|
+
impact: `${REQUEST_PATH_IMPACT} Fix "${blocker.title}" above to move them to the change log.`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/** What after-hooks on the request path miss, said the same way by `db check` and `doctor`. */
|
|
166
|
+
export const REQUEST_PATH_IMPACT = "afterChange and afterDelete fire only for writes made through the API. A write made outside the " +
|
|
167
|
+
"API (SQL, a migration, a function's own database connection) does not reach them.";
|
|
168
|
+
/** The replication slots Supatype's own services read: realtime's and the after-hook listener's. */
|
|
169
|
+
const SUPATYPE_SLOTS = ["supatype_realtime", "supatype_hooks"];
|
|
170
|
+
/**
|
|
171
|
+
* WAL a slot may hold before it is worth saying: a quarter of the `max_slot_wal_keep_size` the
|
|
172
|
+
* supatype/postgres image sets (4096 MB), past which Postgres gives up on the slot and its reader
|
|
173
|
+
* has to start again from now, losing what it had not read.
|
|
174
|
+
*/
|
|
175
|
+
export const RETAINED_WAL_WARN_BYTES = 1024 ** 3;
|
|
176
|
+
/** Bytes as a reader would say them, in GiB to one place. */
|
|
177
|
+
export function gibibytes(bytes) {
|
|
178
|
+
return `${(bytes / 1024 ** 3).toFixed(1)} GiB`;
|
|
179
|
+
}
|
|
54
180
|
/**
|
|
55
|
-
*
|
|
181
|
+
* Whether a Supatype slot holds a lot of WAL. A reader that stopped (a stopped server, a listener
|
|
182
|
+
* stuck on a hook that never answers) keeps WAL on disk until it reads again, and on a small
|
|
183
|
+
* volume that is how the database fills its disk with nothing saying why.
|
|
184
|
+
*/
|
|
185
|
+
export function retainedWalCheck(slots) {
|
|
186
|
+
const base = { id: "slot-retained-wal", title: "WAL held by Supatype's replication slots" };
|
|
187
|
+
const heavy = slots.filter((slot) => Number(slot.retained) > RETAINED_WAL_WARN_BYTES);
|
|
188
|
+
if (heavy.length === 0) {
|
|
189
|
+
return { ...base, severity: "pass", detail: `none holds more than ${gibibytes(RETAINED_WAL_WARN_BYTES)}` };
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
...base,
|
|
193
|
+
severity: "warn",
|
|
194
|
+
detail: heavy.map((slot) => `${slot.slot_name} holds ${gibibytes(Number(slot.retained))}`).join(", "),
|
|
195
|
+
impact: "Its reader is behind or stopped. Start the stack so it catches up; one that stays behind is " +
|
|
196
|
+
"dropped by Postgres at max_slot_wal_keep_size, and its reader starts again from now.",
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** {@link retainedWalCheck} for the database `q` reaches. */
|
|
200
|
+
async function slotRetention(q) {
|
|
201
|
+
const slots = await queryAs(q, isShape({ slot_name: isString, retained: isString }), `SELECT slot_name, coalesce(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn), 0)::bigint::text AS retained
|
|
202
|
+
FROM pg_replication_slots WHERE slot_name = ANY($1)`, [[...SUPATYPE_SLOTS]]);
|
|
203
|
+
return retainedWalCheck(slots);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Who the answer is about. The probe runs as the role `db check` connected as, while the server's
|
|
207
|
+
* listener connects with SUPATYPE_SQL_DATABASE_URL, which a generated stack sets to its owner URL
|
|
208
|
+
* (POSTGRES_USER, or DATABASE_URL for an external database).
|
|
209
|
+
*/
|
|
210
|
+
const SERVER_ROLE_NOTE = "The server's after-hook listener connects with SUPATYPE_SQL_DATABASE_URL; check that role if it is not this one.";
|
|
211
|
+
/** Postgres's words when `output_plugin_libraries` does not name the plugin a slot asked for. */
|
|
212
|
+
const NOT_AN_ALLOWED_PLUGIN = "may not be used as an output plugin";
|
|
213
|
+
/**
|
|
214
|
+
* Why the probe slot was refused, and what fixes it. Both refusals that share `42501` are told
|
|
215
|
+
* apart by Postgres's message: the allowlist one has no SQLSTATE of its own.
|
|
216
|
+
*/
|
|
217
|
+
/** How to let a slot decode with wal2json when output_plugin_libraries leaves it out. */
|
|
218
|
+
const ALLOW_WAL2JSON_REMEDY = [
|
|
219
|
+
"-- This sets the whole list: name any plugin it already allows as well, as in",
|
|
220
|
+
"-- 'wal2json, other_plugin'. Then reload:",
|
|
221
|
+
"ALTER SYSTEM SET output_plugin_libraries = 'wal2json';",
|
|
222
|
+
"SELECT pg_reload_conf();",
|
|
223
|
+
].join("\n");
|
|
224
|
+
/** What to do when the server has no wal2json library. */
|
|
225
|
+
const INSTALL_WAL2JSON_REMEDY = [
|
|
226
|
+
"-- wal2json is a server library, not an extension: it must be installed on the host",
|
|
227
|
+
"-- (or offered by your provider) and cannot be added over SQL. Supatype's own image",
|
|
228
|
+
"-- ships it. Set database.external.realtime: false to stop starting the service.",
|
|
229
|
+
].join("\n");
|
|
230
|
+
function decodingRefusal(error, role) {
|
|
231
|
+
const code = errorCode(error);
|
|
232
|
+
const message = errorMessage(error);
|
|
233
|
+
if (code === "42501" && message.includes(NOT_AN_ALLOWED_PLUGIN)) {
|
|
234
|
+
return {
|
|
235
|
+
detail: "output_plugin_libraries does not name wal2json, so no slot may decode with it",
|
|
236
|
+
remedy: ALLOW_WAL2JSON_REMEDY,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
if (code === "42501") {
|
|
240
|
+
return {
|
|
241
|
+
detail: `role "${role}" may not use replication slots (no REPLICATION attribute)`,
|
|
242
|
+
remedy: [
|
|
243
|
+
`-- ${SERVER_ROLE_NOTE}`,
|
|
244
|
+
`ALTER ROLE ${ident(role)} WITH REPLICATION;`,
|
|
245
|
+
].join("\n"),
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
detail: code === "58P01" ? "the wal2json output plugin is not installed on this server" : message,
|
|
250
|
+
remedy: INSTALL_WAL2JSON_REMEDY,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Ask the database to do the one thing realtime and the after-hook listener need, then undo it.
|
|
56
255
|
*
|
|
57
256
|
* SQLSTATEs measured against `supatype/postgres` rather than recalled:
|
|
58
|
-
* `55000` wal_level too low, `58P01` the plugin's library is absent, `42501` the role may
|
|
59
|
-
* replication slots.
|
|
257
|
+
* `55000` wal_level too low, `58P01` the plugin's library is absent, `42501` either the role may
|
|
258
|
+
* not use replication slots or `output_plugin_libraries` does not name wal2json.
|
|
60
259
|
*/
|
|
61
|
-
async function probeLogicalDecoding(q) {
|
|
62
|
-
const base = { id: "logical-decoding", title: "wal2json logical decoding (realtime)" };
|
|
260
|
+
async function probeLogicalDecoding(q, role) {
|
|
261
|
+
const base = { id: "logical-decoding", title: "wal2json logical decoding (realtime, after-hooks)" };
|
|
63
262
|
try {
|
|
64
263
|
await q(`SELECT pg_create_logical_replication_slot($1, 'wal2json')`, [PROBE_SLOT]);
|
|
65
264
|
}
|
|
66
265
|
catch (error) {
|
|
67
|
-
const code = errorCode(error);
|
|
68
|
-
const detail = code === "58P01"
|
|
69
|
-
? "the wal2json output plugin is not installed on this server"
|
|
70
|
-
: code === "42501"
|
|
71
|
-
? "this role may not use replication slots (no REPLICATION attribute)"
|
|
72
|
-
: error instanceof Error
|
|
73
|
-
? error.message
|
|
74
|
-
: String(error);
|
|
75
266
|
return {
|
|
76
267
|
...base,
|
|
77
268
|
severity: "degrade",
|
|
78
|
-
|
|
79
|
-
impact:
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
? { remedy: `ALTER ROLE CURRENT_USER WITH REPLICATION;`, remedyNeedsOperator: true }
|
|
83
|
-
: {
|
|
84
|
-
remedy: [
|
|
85
|
-
"-- wal2json is a server library, not an extension: it must be installed on the host",
|
|
86
|
-
"-- (or offered by your provider) and cannot be added over SQL. Supatype's own image",
|
|
87
|
-
"-- ships it. Set database.external.realtime: false to stop starting the service.",
|
|
88
|
-
].join("\n"),
|
|
89
|
-
remedyNeedsOperator: true,
|
|
90
|
-
}),
|
|
269
|
+
...decodingRefusal(error, role),
|
|
270
|
+
impact: `${NO_DECODING_IMPACT} The realtime service still starts, reports this reason on ` +
|
|
271
|
+
"/health/ready, and serves nothing else differently.",
|
|
272
|
+
remedyNeedsOperator: true,
|
|
91
273
|
};
|
|
92
274
|
}
|
|
93
275
|
// Leave nothing behind. A slot that is never read holds WAL forever, which on a database Supatype
|
|
@@ -105,7 +287,11 @@ async function probeLogicalDecoding(q) {
|
|
|
105
287
|
remedy: `SELECT pg_drop_replication_slot('${PROBE_SLOT}');`,
|
|
106
288
|
};
|
|
107
289
|
}
|
|
108
|
-
return {
|
|
290
|
+
return {
|
|
291
|
+
...base,
|
|
292
|
+
severity: "pass",
|
|
293
|
+
detail: `role "${role}" can create and drop a wal2json slot. ${SERVER_ROLE_NOTE}`,
|
|
294
|
+
};
|
|
109
295
|
}
|
|
110
296
|
const REQUIRED_ROLES = ["anon", "authenticated", "service_role", "authenticator"];
|
|
111
297
|
/** The three roles PostgREST switches to per request. `authenticator` only connects and switches. */
|
|
@@ -144,12 +330,7 @@ export async function runPreflight(client, opts) {
|
|
|
144
330
|
const results = [];
|
|
145
331
|
const q = (sql, params = []) => queryRows(client, sql, params);
|
|
146
332
|
/** For probes that always return exactly one row. */
|
|
147
|
-
const one =
|
|
148
|
-
const [row] = await queryAs(q, guard, sql, params);
|
|
149
|
-
if (row === undefined)
|
|
150
|
-
throw new Error(`Preflight probe returned no rows: ${sql}`);
|
|
151
|
-
return row;
|
|
152
|
-
};
|
|
333
|
+
const one = (guard, sql, params = []) => queryOne(q, guard, sql, params);
|
|
153
334
|
// ── Server version ─────────────────────────────────────────────────────────
|
|
154
335
|
const { server_version_num } = await one(isShape({ server_version_num: isString }), "SHOW server_version_num");
|
|
155
336
|
const major = Math.floor(Number(server_version_num) / 10000);
|
|
@@ -327,48 +508,9 @@ export async function runPreflight(client, opts) {
|
|
|
327
508
|
}),
|
|
328
509
|
}),
|
|
329
510
|
});
|
|
330
|
-
// ── Realtime
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
results.push({
|
|
334
|
-
id: "wal-level",
|
|
335
|
-
title: "wal_level = logical (realtime)",
|
|
336
|
-
severity: walLogical ? "pass" : "degrade",
|
|
337
|
-
detail: `wal_level is "${wal_level}"`,
|
|
338
|
-
...(!walLogical && {
|
|
339
|
-
impact: "Realtime subscriptions are unavailable; everything else is unaffected.",
|
|
340
|
-
remedy: "-- Requires a server restart, and on managed Postgres a parameter-group change\n" +
|
|
341
|
-
"-- rather than SQL. Shown for a self-managed server:\n" +
|
|
342
|
-
"ALTER SYSTEM SET wal_level = 'logical';",
|
|
343
|
-
remedyNeedsOperator: true,
|
|
344
|
-
}),
|
|
345
|
-
});
|
|
346
|
-
const slots = await one(isShape({ used: isString, max: isString }), `SELECT (SELECT count(*) FROM pg_replication_slots)::text AS used,
|
|
347
|
-
current_setting('max_replication_slots') AS max`);
|
|
348
|
-
const slotsFree = Number(slots.max) - Number(slots.used);
|
|
349
|
-
results.push({
|
|
350
|
-
id: "replication-slots",
|
|
351
|
-
title: "A spare replication slot (realtime)",
|
|
352
|
-
severity: slotsFree > 0 ? "pass" : "degrade",
|
|
353
|
-
detail: `${slots.used} of ${slots.max} in use`,
|
|
354
|
-
...(slotsFree <= 0 && {
|
|
355
|
-
impact: "Realtime cannot create its slot.",
|
|
356
|
-
remedy: "ALTER SYSTEM SET max_replication_slots = 10;",
|
|
357
|
-
remedyNeedsOperator: true,
|
|
358
|
-
}),
|
|
359
|
-
});
|
|
360
|
-
// The definitive realtime check: create the slot realtime would create, then drop it.
|
|
361
|
-
//
|
|
362
|
-
// There is no catalog to consult. `wal2json` is a shared library, not an extension, so it never
|
|
363
|
-
// appears in `pg_available_extensions`: the only way to know whether this database can decode is
|
|
364
|
-
// to ask it to. Cloud SQL does not ship the plugin at all; plenty of managed Postgres will not
|
|
365
|
-
// grant `REPLICATION`. Both produce a stack that looks healthy until the first subscription.
|
|
366
|
-
//
|
|
367
|
-
// Skipped when `wal_level` or the slot budget already rules it out, since the probe would fail for
|
|
368
|
-
// that reason and report it a second time under a less specific heading.
|
|
369
|
-
if (walLogical && slotsFree > 0) {
|
|
370
|
-
results.push(await probeLogicalDecoding(q));
|
|
371
|
-
}
|
|
511
|
+
// ── Realtime and after-hooks ───────────────────────────────────────────────
|
|
512
|
+
const decoding = await decodingChecks(q);
|
|
513
|
+
results.push(...decoding, afterHooksSourceCheck(decoding), await slotRetention(q));
|
|
372
514
|
// ── Existing tables in the target schema ───────────────────────────────────
|
|
373
515
|
if (schemaExists) {
|
|
374
516
|
const names = await foreignTables(q, opts.schema);
|