@supatype/cli 0.3.6 → 0.7.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 +174 -1
- package/deno.d.ts +11 -0
- package/dist/adopt-columns.d.ts +157 -0
- package/dist/adopt-columns.d.ts.map +1 -0
- package/dist/adopt-columns.js +789 -0
- package/dist/adopt-columns.js.map +1 -0
- package/dist/adopt-walkthrough.d.ts +50 -15
- package/dist/adopt-walkthrough.d.ts.map +1 -1
- package/dist/adopt-walkthrough.js +93 -61
- package/dist/adopt-walkthrough.js.map +1 -1
- package/dist/api-config-cache.d.ts +3 -3
- package/dist/api-config-cache.d.ts.map +1 -1
- package/dist/api-config-cache.js +14 -20
- package/dist/api-config-cache.js.map +1 -1
- package/dist/app/framework.d.ts.map +1 -1
- package/dist/app/framework.js +5 -5
- package/dist/app/framework.js.map +1 -1
- package/dist/app/proxy-dev-app.d.ts.map +1 -1
- package/dist/app/proxy-dev-app.js +3 -2
- package/dist/app/proxy-dev-app.js.map +1 -1
- package/dist/ast-read.d.ts +17 -0
- package/dist/ast-read.d.ts.map +1 -0
- package/dist/ast-read.js +32 -0
- package/dist/ast-read.js.map +1 -0
- package/dist/augmentation-generator.d.ts +14 -2
- package/dist/augmentation-generator.d.ts.map +1 -1
- package/dist/augmentation-generator.js +194 -61
- package/dist/augmentation-generator.js.map +1 -1
- package/dist/augmentation-relationships.d.ts +32 -0
- package/dist/augmentation-relationships.d.ts.map +1 -0
- package/dist/augmentation-relationships.js +122 -0
- package/dist/augmentation-relationships.js.map +1 -0
- package/dist/auth-answer.d.ts +16 -0
- package/dist/auth-answer.d.ts.map +1 -0
- package/dist/auth-answer.js +21 -0
- package/dist/auth-answer.js.map +1 -0
- package/dist/auth-providers.d.ts +89 -0
- package/dist/auth-providers.d.ts.map +1 -0
- package/dist/auth-providers.js +243 -0
- package/dist/auth-providers.js.map +1 -0
- package/dist/binary-cache.d.ts +9 -6
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +150 -46
- package/dist/binary-cache.js.map +1 -1
- package/dist/binary-download-lock.d.ts.map +1 -1
- package/dist/binary-download-lock.js +13 -10
- package/dist/binary-download-lock.js.map +1 -1
- package/dist/byo-preflight.d.ts +26 -0
- package/dist/byo-preflight.d.ts.map +1 -0
- package/dist/byo-preflight.js +69 -0
- package/dist/byo-preflight.js.map +1 -0
- package/dist/cache-identity-scope.d.ts +7 -3
- package/dist/cache-identity-scope.d.ts.map +1 -1
- package/dist/cache-identity-scope.js +20 -10
- package/dist/cache-identity-scope.js.map +1 -1
- package/dist/cache-provider.d.ts +17 -18
- package/dist/cache-provider.d.ts.map +1 -1
- package/dist/cache-provider.js +27 -25
- package/dist/cache-provider.js.map +1 -1
- package/dist/cli-package-version.d.ts.map +1 -1
- package/dist/cli-package-version.js +2 -2
- package/dist/cli-package-version.js.map +1 -1
- package/dist/cli-standalone.d.ts.map +1 -1
- package/dist/cli-standalone.js +2 -6
- package/dist/cli-standalone.js.map +1 -1
- package/dist/cli-version-embedded.js +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -0
- package/dist/cli.js.map +1 -1
- package/dist/client-generator.d.ts +5 -2
- package/dist/client-generator.d.ts.map +1 -1
- package/dist/client-generator.js +32 -22
- package/dist/client-generator.js.map +1 -1
- package/dist/cloud-credentials.d.ts.map +1 -1
- package/dist/cloud-credentials.js +32 -26
- package/dist/cloud-credentials.js.map +1 -1
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +3 -2
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/admin.d.ts +51 -16
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +162 -136
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/adopt.d.ts +23 -0
- package/dist/commands/adopt.d.ts.map +1 -1
- package/dist/commands/adopt.js +205 -42
- package/dist/commands/adopt.js.map +1 -1
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +4 -3
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +2 -1
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/cloud.d.ts +4 -1
- package/dist/commands/cloud.d.ts.map +1 -1
- package/dist/commands/cloud.js +47 -23
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/db.d.ts.map +1 -1
- package/dist/commands/db.js +9 -7
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts +6 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +65 -17
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +8 -2
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +385 -268
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/doctor.d.ts +56 -8
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +180 -61
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/engine.d.ts +1 -1
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +14 -13
- package/dist/commands/engine.js.map +1 -1
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +85 -96
- package/dist/commands/functions.js.map +1 -1
- package/dist/commands/generate.d.ts +6 -0
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +20 -20
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts +19 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +105 -82
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/internal.d.ts.map +1 -1
- package/dist/commands/internal.js +3 -2
- package/dist/commands/internal.js.map +1 -1
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/link-helpers.d.ts.map +1 -1
- package/dist/commands/link-helpers.js +16 -8
- package/dist/commands/link-helpers.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +2 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/migrate.d.ts +43 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +98 -47
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/pg.d.ts.map +1 -1
- package/dist/commands/pg.js +24 -23
- package/dist/commands/pg.js.map +1 -1
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +36 -27
- package/dist/commands/plugins.js.map +1 -1
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +6 -5
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/push.d.ts +23 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +249 -84
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/rename.d.ts +20 -0
- package/dist/commands/rename.d.ts.map +1 -0
- package/dist/commands/rename.js +74 -0
- package/dist/commands/rename.js.map +1 -0
- package/dist/commands/seed.d.ts +12 -0
- package/dist/commands/seed.d.ts.map +1 -1
- package/dist/commands/seed.js +65 -12
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/self-host.d.ts.map +1 -1
- package/dist/commands/self-host.js +93 -27
- 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 +2 -1
- package/dist/commands/self-update.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +16 -12
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js +9 -7
- package/dist/commands/types.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +8 -4
- package/dist/commands/update.js.map +1 -1
- package/dist/compose-db-psql.d.ts +20 -0
- package/dist/compose-db-psql.d.ts.map +1 -0
- package/dist/compose-db-psql.js +30 -0
- package/dist/compose-db-psql.js.map +1 -0
- package/dist/compose-db-roles.d.ts +41 -0
- package/dist/compose-db-roles.d.ts.map +1 -0
- package/dist/compose-db-roles.js +118 -0
- package/dist/compose-db-roles.js.map +1 -0
- package/dist/compose-engine-run.d.ts +27 -0
- package/dist/compose-engine-run.d.ts.map +1 -0
- package/dist/compose-engine-run.js +61 -0
- package/dist/compose-engine-run.js.map +1 -0
- package/dist/compose-kong.d.ts +31 -0
- package/dist/compose-kong.d.ts.map +1 -0
- package/dist/compose-kong.js +145 -0
- package/dist/compose-kong.js.map +1 -0
- package/dist/compose-rename.d.ts.map +1 -1
- package/dist/compose-rename.js +2 -2
- package/dist/compose-rename.js.map +1 -1
- package/dist/compose-render-mode.d.ts +41 -0
- package/dist/compose-render-mode.d.ts.map +1 -0
- package/dist/compose-render-mode.js +70 -0
- package/dist/compose-render-mode.js.map +1 -0
- package/dist/compose-services.d.ts.map +1 -1
- package/dist/compose-services.js +3 -2
- package/dist/compose-services.js.map +1 -1
- package/dist/config.d.ts +18 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +50 -13
- package/dist/config.js.map +1 -1
- package/dist/db-port.d.ts +57 -13
- package/dist/db-port.d.ts.map +1 -1
- package/dist/db-port.js +78 -38
- package/dist/db-port.js.map +1 -1
- package/dist/db-preflight.d.ts +22 -8
- package/dist/db-preflight.d.ts.map +1 -1
- package/dist/db-preflight.js +86 -46
- package/dist/db-preflight.js.map +1 -1
- package/dist/db-rows.d.ts +20 -0
- package/dist/db-rows.d.ts.map +1 -0
- package/dist/db-rows.js +20 -0
- package/dist/db-rows.js.map +1 -0
- package/dist/destructive-consent.d.ts +88 -0
- package/dist/destructive-consent.d.ts.map +1 -0
- package/dist/destructive-consent.js +184 -0
- package/dist/destructive-consent.js.map +1 -0
- package/dist/dev-api-keys.d.ts +26 -0
- package/dist/dev-api-keys.d.ts.map +1 -0
- package/dist/dev-api-keys.js +52 -0
- package/dist/dev-api-keys.js.map +1 -0
- package/dist/dev-compose.d.ts +92 -15
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +676 -465
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-db-ready.d.ts +20 -0
- package/dist/dev-db-ready.d.ts.map +1 -0
- package/dist/dev-db-ready.js +21 -0
- package/dist/dev-db-ready.js.map +1 -0
- package/dist/dev-functions-watch.d.ts +24 -0
- package/dist/dev-functions-watch.d.ts.map +1 -0
- package/dist/dev-functions-watch.js +82 -0
- package/dist/dev-functions-watch.js.map +1 -0
- package/dist/dev-initial-push.d.ts +41 -6
- package/dist/dev-initial-push.d.ts.map +1 -1
- package/dist/dev-initial-push.js +84 -31
- package/dist/dev-initial-push.js.map +1 -1
- package/dist/dev-ports.d.ts +58 -6
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +157 -49
- package/dist/dev-ports.js.map +1 -1
- package/dist/dev-ready-panel.d.ts +5 -0
- package/dist/dev-ready-panel.d.ts.map +1 -1
- package/dist/dev-ready-panel.js +13 -0
- package/dist/dev-ready-panel.js.map +1 -1
- package/dist/dev-schema-watch.d.ts +19 -0
- package/dist/dev-schema-watch.d.ts.map +1 -0
- package/dist/dev-schema-watch.js +49 -0
- package/dist/dev-schema-watch.js.map +1 -0
- package/dist/dev-session-lock.d.ts +30 -1
- package/dist/dev-session-lock.d.ts.map +1 -1
- package/dist/dev-session-lock.js +83 -10
- package/dist/dev-session-lock.js.map +1 -1
- package/dist/dev-shutdown.d.ts +17 -3
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +48 -4
- package/dist/dev-shutdown.js.map +1 -1
- package/dist/diff-output.d.ts +71 -3
- package/dist/diff-output.d.ts.map +1 -1
- package/dist/diff-output.js +173 -18
- package/dist/diff-output.js.map +1 -1
- package/dist/docker-env.d.ts +16 -0
- package/dist/docker-env.d.ts.map +1 -0
- package/dist/docker-env.js +16 -0
- package/dist/docker-env.js.map +1 -0
- package/dist/docker-postgres.d.ts.map +1 -1
- package/dist/docker-postgres.js +14 -9
- package/dist/docker-postgres.js.map +1 -1
- package/dist/drift-consent.d.ts +36 -0
- package/dist/drift-consent.d.ts.map +1 -0
- package/dist/drift-consent.js +78 -0
- package/dist/drift-consent.js.map +1 -0
- package/dist/engine-answers.d.ts +51 -0
- package/dist/engine-answers.d.ts.map +1 -0
- package/dist/engine-answers.js +183 -0
- package/dist/engine-answers.js.map +1 -0
- package/dist/engine-client.d.ts +156 -9
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +315 -129
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-floor.d.ts +10 -0
- package/dist/engine-floor.d.ts.map +1 -1
- package/dist/engine-floor.js +28 -0
- package/dist/engine-floor.js.map +1 -1
- package/dist/engine-json-line.d.ts +9 -0
- package/dist/engine-json-line.d.ts.map +1 -0
- package/dist/engine-json-line.js +23 -0
- package/dist/engine-json-line.js.map +1 -0
- package/dist/engine-ownership-gate.d.ts +79 -0
- package/dist/engine-ownership-gate.d.ts.map +1 -0
- package/dist/engine-ownership-gate.js +213 -0
- package/dist/engine-ownership-gate.js.map +1 -0
- package/dist/engine-push-output.d.ts +23 -2
- package/dist/engine-push-output.d.ts.map +1 -1
- package/dist/engine-push-output.js +22 -15
- package/dist/engine-push-output.js.map +1 -1
- package/dist/env-file.d.ts +15 -2
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +61 -22
- package/dist/env-file.js.map +1 -1
- package/dist/error-message.d.ts +5 -0
- package/dist/error-message.d.ts.map +1 -0
- package/dist/error-message.js +11 -0
- package/dist/error-message.js.map +1 -0
- package/dist/field-bounds.d.ts +8 -2
- package/dist/field-bounds.d.ts.map +1 -1
- package/dist/field-bounds.js +9 -15
- package/dist/field-bounds.js.map +1 -1
- package/dist/field-masking-tier.d.ts +4 -3
- package/dist/field-masking-tier.d.ts.map +1 -1
- package/dist/field-masking-tier.js +36 -13
- package/dist/field-masking-tier.js.map +1 -1
- package/dist/functions-deno-types.d.ts +8 -8
- package/dist/functions-deno-types.d.ts.map +1 -1
- package/dist/functions-deno-types.js +53 -25
- package/dist/functions-deno-types.js.map +1 -1
- package/dist/functions-router-gen.d.ts +21 -2
- package/dist/functions-router-gen.d.ts.map +1 -1
- package/dist/functions-router-gen.js +89 -18
- package/dist/functions-router-gen.js.map +1 -1
- package/dist/functions-template.d.ts +10 -0
- package/dist/functions-template.d.ts.map +1 -0
- package/dist/functions-template.js +39 -0
- package/dist/functions-template.js.map +1 -0
- package/dist/hooks-generator.d.ts.map +1 -1
- package/dist/hooks-generator.js +110 -83
- package/dist/hooks-generator.js.map +1 -1
- package/dist/host-database.d.ts +46 -5
- package/dist/host-database.d.ts.map +1 -1
- package/dist/host-database.js +72 -15
- package/dist/host-database.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init-dependency-versions.d.ts.map +1 -1
- package/dist/init-dependency-versions.js +8 -1
- package/dist/init-dependency-versions.js.map +1 -1
- package/dist/init-project-detect.d.ts.map +1 -1
- package/dist/init-project-detect.js +3 -2
- package/dist/init-project-detect.js.map +1 -1
- package/dist/json-file.d.ts +15 -0
- package/dist/json-file.d.ts.map +1 -0
- package/dist/json-file.js +38 -0
- package/dist/json-file.js.map +1 -0
- package/dist/json-type-text.d.ts +18 -0
- package/dist/json-type-text.d.ts.map +1 -0
- package/dist/json-type-text.js +112 -0
- package/dist/json-type-text.js.map +1 -0
- package/dist/jwt-secret-length.d.ts +22 -0
- package/dist/jwt-secret-length.d.ts.map +1 -0
- package/dist/jwt-secret-length.js +36 -0
- package/dist/jwt-secret-length.js.map +1 -0
- package/dist/jwt.d.ts +5 -0
- package/dist/jwt.d.ts.map +1 -1
- package/dist/jwt.js +25 -1
- package/dist/jwt.js.map +1 -1
- package/dist/link.d.ts +5 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +47 -5
- package/dist/link.js.map +1 -1
- package/dist/local-gateway.d.ts +9 -0
- package/dist/local-gateway.d.ts.map +1 -1
- package/dist/local-gateway.js +16 -0
- package/dist/local-gateway.js.map +1 -1
- package/dist/local-secrets.d.ts +84 -2
- package/dist/local-secrets.d.ts.map +1 -1
- package/dist/local-secrets.js +115 -5
- package/dist/local-secrets.js.map +1 -1
- package/dist/local-stack.d.ts +30 -0
- package/dist/local-stack.d.ts.map +1 -0
- package/dist/local-stack.js +81 -0
- package/dist/local-stack.js.map +1 -0
- package/dist/mailer-autoconfirm.d.ts +37 -0
- package/dist/mailer-autoconfirm.d.ts.map +1 -0
- package/dist/mailer-autoconfirm.js +69 -0
- package/dist/mailer-autoconfirm.js.map +1 -0
- package/dist/model-cache.d.ts +6 -2
- package/dist/model-cache.d.ts.map +1 -1
- package/dist/model-cache.js +33 -27
- package/dist/model-cache.js.map +1 -1
- package/dist/model-hooks.d.ts +7 -6
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +83 -138
- package/dist/model-hooks.js.map +1 -1
- package/dist/model-versioning.d.ts +7 -1
- package/dist/model-versioning.d.ts.map +1 -1
- package/dist/model-versioning.js +24 -27
- package/dist/model-versioning.js.map +1 -1
- package/dist/native-dev-env.d.ts +39 -0
- package/dist/native-dev-env.d.ts.map +1 -0
- package/dist/native-dev-env.js +50 -0
- package/dist/native-dev-env.js.map +1 -0
- package/dist/native-functions-watch.d.ts +11 -0
- package/dist/native-functions-watch.d.ts.map +1 -0
- package/dist/native-functions-watch.js +59 -0
- package/dist/native-functions-watch.js.map +1 -0
- package/dist/native-keyspace.d.ts +23 -0
- package/dist/native-keyspace.d.ts.map +1 -0
- package/dist/native-keyspace.js +53 -0
- package/dist/native-keyspace.js.map +1 -0
- package/dist/native-pg-auth.d.ts +46 -0
- package/dist/native-pg-auth.d.ts.map +1 -0
- package/dist/native-pg-auth.js +107 -0
- package/dist/native-pg-auth.js.map +1 -0
- package/dist/native-realtime.d.ts +26 -0
- package/dist/native-realtime.d.ts.map +1 -0
- package/dist/native-realtime.js +43 -0
- package/dist/native-realtime.js.map +1 -0
- package/dist/native-roles-sql.d.ts +27 -0
- package/dist/native-roles-sql.d.ts.map +1 -0
- package/dist/native-roles-sql.js +73 -0
- package/dist/native-roles-sql.js.map +1 -0
- package/dist/owner-default.d.ts +19 -0
- package/dist/owner-default.d.ts.map +1 -0
- package/dist/owner-default.js +42 -0
- package/dist/owner-default.js.map +1 -0
- package/dist/package-json.d.ts +20 -0
- package/dist/package-json.d.ts.map +1 -0
- package/dist/package-json.js +29 -0
- package/dist/package-json.js.map +1 -0
- package/dist/parent-watch.d.ts +40 -0
- package/dist/parent-watch.d.ts.map +1 -0
- package/dist/parent-watch.js +75 -0
- package/dist/parent-watch.js.map +1 -0
- package/dist/postgres-ctl.d.ts +29 -6
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +67 -17
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/postgres-image.d.ts +35 -0
- package/dist/postgres-image.d.ts.map +1 -0
- package/dist/postgres-image.js +127 -0
- package/dist/postgres-image.js.map +1 -0
- package/dist/postgrest-release.d.ts +25 -0
- package/dist/postgrest-release.d.ts.map +1 -0
- package/dist/postgrest-release.js +35 -0
- package/dist/postgrest-release.js.map +1 -0
- package/dist/project-config.d.ts +145 -17
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +271 -115
- package/dist/project-config.js.map +1 -1
- package/dist/project-name-override.d.ts +25 -0
- package/dist/project-name-override.d.ts.map +1 -0
- package/dist/project-name-override.js +52 -0
- package/dist/project-name-override.js.map +1 -0
- package/dist/pull-utils.d.ts +26 -3
- package/dist/pull-utils.d.ts.map +1 -1
- package/dist/pull-utils.js +44 -5
- package/dist/pull-utils.js.map +1 -1
- package/dist/push-audit.d.ts +39 -0
- package/dist/push-audit.d.ts.map +1 -0
- package/dist/push-audit.js +116 -0
- package/dist/push-audit.js.map +1 -0
- package/dist/push-refusal.d.ts +94 -0
- package/dist/push-refusal.d.ts.map +1 -0
- package/dist/push-refusal.js +275 -0
- package/dist/push-refusal.js.map +1 -0
- package/dist/recorded-field-masking-tier.d.ts +43 -0
- package/dist/recorded-field-masking-tier.d.ts.map +1 -0
- package/dist/recorded-field-masking-tier.js +88 -0
- package/dist/recorded-field-masking-tier.js.map +1 -0
- package/dist/rename-journal.d.ts +54 -0
- package/dist/rename-journal.d.ts.map +1 -0
- package/dist/rename-journal.js +150 -0
- package/dist/rename-journal.js.map +1 -0
- package/dist/resolve-api-url.d.ts.map +1 -1
- package/dist/resolve-api-url.js +4 -3
- package/dist/resolve-api-url.js.map +1 -1
- package/dist/resolve-target.d.ts +85 -26
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +214 -62
- package/dist/resolve-target.js.map +1 -1
- package/dist/rest-cache-admin.d.ts +9 -8
- package/dist/rest-cache-admin.d.ts.map +1 -1
- package/dist/rest-cache-admin.js +32 -9
- package/dist/rest-cache-admin.js.map +1 -1
- package/dist/rest-ready.d.ts +28 -0
- package/dist/rest-ready.d.ts.map +1 -0
- package/dist/rest-ready.js +53 -0
- package/dist/rest-ready.js.map +1 -0
- package/dist/restore-system-relation-targets.d.ts.map +1 -1
- package/dist/restore-system-relation-targets.js +49 -31
- package/dist/restore-system-relation-targets.js.map +1 -1
- package/dist/route-manifest.d.ts.map +1 -1
- package/dist/route-manifest.js +4 -10
- package/dist/route-manifest.js.map +1 -1
- package/dist/runtime-routes.d.ts.map +1 -1
- package/dist/runtime-routes.js +23 -28
- package/dist/runtime-routes.js.map +1 -1
- package/dist/schema-ast-v2.d.ts +35 -1
- package/dist/schema-ast-v2.d.ts.map +1 -1
- package/dist/schema-ast-v2.js +22 -7
- 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 +14 -37
- package/dist/schema-push-lock.js.map +1 -1
- package/dist/schema-sources.d.ts +7 -1
- package/dist/schema-sources.d.ts.map +1 -1
- package/dist/schema-sources.js +19 -8
- package/dist/schema-sources.js.map +1 -1
- package/dist/seed-ir.d.ts.map +1 -1
- package/dist/seed-ir.js +30 -9
- package/dist/seed-ir.js.map +1 -1
- package/dist/seed-runner.d.ts.map +1 -1
- package/dist/seed-runner.js +26 -3
- package/dist/seed-runner.js.map +1 -1
- package/dist/seed.d.ts +31 -4
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +3 -1
- package/dist/seed.js.map +1 -1
- package/dist/self-host-compose.d.ts +66 -4
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +326 -102
- package/dist/self-host-compose.js.map +1 -1
- package/dist/shell-ports.d.ts +26 -0
- package/dist/shell-ports.d.ts.map +1 -0
- package/dist/shell-ports.js +56 -0
- package/dist/shell-ports.js.map +1 -0
- package/dist/storage-provision.d.ts +21 -4
- package/dist/storage-provision.d.ts.map +1 -1
- package/dist/storage-provision.js +12 -0
- package/dist/storage-provision.js.map +1 -1
- package/dist/studio-admin-roles.d.ts.map +1 -1
- package/dist/studio-admin-roles.js +2 -1
- package/dist/studio-admin-roles.js.map +1 -1
- package/dist/studio-auth-config.d.ts +22 -0
- package/dist/studio-auth-config.d.ts.map +1 -0
- package/dist/studio-auth-config.js +45 -0
- package/dist/studio-auth-config.js.map +1 -0
- package/dist/studio-roles.d.ts +13 -0
- package/dist/studio-roles.d.ts.map +1 -0
- package/dist/studio-roles.js +12 -0
- package/dist/studio-roles.js.map +1 -0
- package/dist/target-client.d.ts +13 -2
- package/dist/target-client.d.ts.map +1 -1
- package/dist/target-client.js +56 -40
- package/dist/target-client.js.map +1 -1
- package/dist/tsx-runner.d.ts +13 -0
- package/dist/tsx-runner.d.ts.map +1 -1
- package/dist/tsx-runner.js +36 -19
- package/dist/tsx-runner.js.map +1 -1
- package/dist/type-extractor.d.ts +2 -0
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +400 -96
- package/dist/type-extractor.js.map +1 -1
- package/dist/type-generation.d.ts +35 -5
- package/dist/type-generation.d.ts.map +1 -1
- package/dist/type-generation.js +57 -27
- package/dist/type-generation.js.map +1 -1
- package/dist/type-resolver.d.ts.map +1 -1
- package/dist/type-resolver.js +8 -1
- package/dist/type-resolver.js.map +1 -1
- package/dist/ui/clack-api.d.ts +3 -0
- package/dist/ui/clack-api.d.ts.map +1 -1
- package/dist/ui/clack-api.js +14 -7
- package/dist/ui/clack-api.js.map +1 -1
- package/dist/ui/clack.d.ts.map +1 -1
- package/dist/ui/clack.js +9 -7
- package/dist/ui/clack.js.map +1 -1
- package/dist/ui/components/PromptPanel.d.ts +1 -0
- package/dist/ui/components/PromptPanel.d.ts.map +1 -1
- package/dist/ui/components/PromptPanel.js +2 -1
- package/dist/ui/components/PromptPanel.js.map +1 -1
- package/dist/ui/confirm.d.ts +8 -0
- package/dist/ui/confirm.d.ts.map +1 -1
- package/dist/ui/confirm.js +12 -0
- package/dist/ui/confirm.js.map +1 -1
- package/dist/ui/dev/DevDashboard.d.ts.map +1 -1
- package/dist/ui/dev/DevDashboard.js +19 -4
- package/dist/ui/dev/DevDashboard.js.map +1 -1
- package/dist/ui/flows/FlowApp.d.ts.map +1 -1
- package/dist/ui/flows/FlowApp.js +17 -1
- package/dist/ui/flows/FlowApp.js.map +1 -1
- package/dist/ui/flows/prompt-fields.d.ts +13 -0
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
- package/dist/ui/flows/prompt-fields.js +17 -4
- package/dist/ui/flows/prompt-fields.js.map +1 -1
- package/dist/ui/flows/types.d.ts +2 -1
- package/dist/ui/flows/types.d.ts.map +1 -1
- package/dist/ui/runtime/cancel.d.ts +5 -0
- package/dist/ui/runtime/cancel.d.ts.map +1 -1
- package/dist/ui/runtime/cancel.js +7 -0
- package/dist/ui/runtime/cancel.js.map +1 -1
- package/dist/ui/runtime/dev-prompt-queue.d.ts +5 -4
- package/dist/ui/runtime/dev-prompt-queue.d.ts.map +1 -1
- package/dist/ui/runtime/dev-prompt-queue.js +2 -5
- package/dist/ui/runtime/dev-prompt-queue.js.map +1 -1
- package/dist/ui/runtime/run-clack-flow.js.map +1 -1
- package/dist/unique-file-token.d.ts +10 -0
- package/dist/unique-file-token.d.ts.map +1 -0
- package/dist/unique-file-token.js +13 -0
- package/dist/unique-file-token.js.map +1 -0
- package/package.json +14 -4
- package/.turbo/turbo-build.log +0 -4
- package/.turbo/turbo-test.log +0 -583
- package/.turbo/turbo-typecheck.log +0 -4
- package/assets/supatype-logo-wordmark.ascii.txt +0 -6
- package/bin/dev-entry.ts +0 -3
- package/dist/supatype-eval-1781522769253.d.mts +0 -2
- package/dist/supatype-eval-1781522769253.d.mts.map +0 -1
- package/dist/supatype-eval-1781522769253.mjs +0 -3
- package/dist/supatype-eval-1781522769253.mjs.map +0 -1
- package/scripts/build-release-artifacts.sh +0 -112
- package/scripts/generate-homebrew-formula.mjs +0 -123
- package/scripts/mirror-deno-release.sh +0 -76
- package/src/TYPE-RESOLUTION.md +0 -294
- package/src/adopt-walkthrough.ts +0 -142
- package/src/api-config-cache.ts +0 -172
- package/src/app/framework.ts +0 -247
- package/src/app/proxy-dev-app.ts +0 -175
- package/src/app-config.ts +0 -208
- package/src/app-vite-env.ts +0 -27
- package/src/augmentation-generator.ts +0 -279
- package/src/binary-cache.ts +0 -998
- package/src/binary-download-lock.ts +0 -124
- package/src/cache-clean.ts +0 -81
- package/src/cache-identity-scope.ts +0 -92
- package/src/cache-pins.ts +0 -243
- package/src/cache-provider.ts +0 -61
- package/src/cli-artifacts.ts +0 -65
- package/src/cli-install-method.ts +0 -98
- package/src/cli-package-version.ts +0 -19
- package/src/cli-standalone.ts +0 -144
- package/src/cli-version-embedded.ts +0 -12
- package/src/cli.ts +0 -87
- package/src/client-generator.ts +0 -122
- package/src/cloud-credentials.ts +0 -183
- package/src/commands/add.ts +0 -105
- package/src/commands/admin.ts +0 -819
- package/src/commands/adopt.ts +0 -81
- package/src/commands/app.ts +0 -100
- package/src/commands/cache.ts +0 -233
- package/src/commands/cloud.ts +0 -299
- package/src/commands/db.ts +0 -301
- package/src/commands/deploy-types.ts +0 -49
- package/src/commands/deploy.ts +0 -464
- package/src/commands/dev.ts +0 -1217
- package/src/commands/diff.ts +0 -73
- package/src/commands/doctor.ts +0 -197
- package/src/commands/engine.ts +0 -31
- package/src/commands/functions.ts +0 -1010
- package/src/commands/generate.ts +0 -45
- package/src/commands/hooks.ts +0 -138
- package/src/commands/init.ts +0 -1537
- package/src/commands/internal.ts +0 -60
- package/src/commands/introspect.ts +0 -48
- package/src/commands/keys.ts +0 -269
- package/src/commands/link-helpers.ts +0 -281
- package/src/commands/login.ts +0 -127
- package/src/commands/logs.ts +0 -56
- package/src/commands/migrate-from-v1.ts +0 -132
- package/src/commands/migrate.ts +0 -231
- package/src/commands/pg.ts +0 -128
- package/src/commands/plugins.ts +0 -517
- package/src/commands/pull.ts +0 -46
- package/src/commands/push.ts +0 -427
- package/src/commands/seed.ts +0 -319
- package/src/commands/self-host.ts +0 -404
- package/src/commands/self-update.ts +0 -89
- package/src/commands/status.ts +0 -117
- package/src/commands/types.ts +0 -77
- package/src/commands/update.ts +0 -172
- package/src/components.ts +0 -6
- package/src/compose-local-server-image.ts +0 -85
- package/src/compose-rename.ts +0 -73
- package/src/compose-services.ts +0 -175
- package/src/config.ts +0 -276
- package/src/db-port.ts +0 -99
- package/src/db-preflight.ts +0 -663
- package/src/dev-compose.ts +0 -1650
- package/src/dev-db-reset.ts +0 -95
- package/src/dev-initial-push.ts +0 -134
- package/src/dev-log-bus.ts +0 -121
- package/src/dev-log-filter.ts +0 -74
- package/src/dev-logo.ts +0 -61
- package/src/dev-ports.ts +0 -271
- package/src/dev-ready-panel.ts +0 -80
- package/src/dev-session-lock.ts +0 -98
- package/src/dev-session.ts +0 -210
- package/src/dev-shutdown.ts +0 -159
- package/src/dev-task-colors.ts +0 -66
- package/src/diff-output.ts +0 -90
- package/src/docker-postgres.ts +0 -295
- package/src/docker-runtime.ts +0 -151
- package/src/engine-client.ts +0 -350
- package/src/engine-floor.ts +0 -261
- package/src/engine-push-output.ts +0 -98
- package/src/ensure-binary.ts +0 -68
- package/src/ensure-component-binaries.ts +0 -71
- package/src/ensure-dev-api-config.ts +0 -18
- package/src/env-file.ts +0 -183
- package/src/field-bounds.ts +0 -359
- package/src/field-masking-tier.ts +0 -107
- package/src/functions-context-refresh.ts +0 -25
- package/src/functions-deno-types.ts +0 -258
- package/src/functions-router-gen.ts +0 -256
- package/src/gitignore.ts +0 -76
- package/src/hook-upload.ts +0 -107
- package/src/hooks-generator.ts +0 -444
- package/src/host-database.ts +0 -176
- package/src/index.ts +0 -11
- package/src/init-dependency-versions.ts +0 -69
- package/src/init-package-json.ts +0 -63
- package/src/init-project-detect.ts +0 -99
- package/src/jwt.ts +0 -14
- package/src/kong-config.ts +0 -116
- package/src/link.ts +0 -250
- package/src/local-gateway.ts +0 -9
- package/src/local-secrets.ts +0 -104
- package/src/local-storage.ts +0 -14
- package/src/main.ts +0 -20
- package/src/model-cache.ts +0 -122
- package/src/model-hooks.ts +0 -430
- package/src/model-versioning.ts +0 -167
- package/src/pgbouncer-userlist.ts +0 -15
- package/src/postgres-ctl.ts +0 -333
- package/src/preview-config-check.ts +0 -52
- package/src/process-manager.ts +0 -224
- package/src/project-config.ts +0 -939
- package/src/prompts.ts +0 -2
- package/src/pull-utils.ts +0 -275
- package/src/realtime-launch.ts +0 -52
- package/src/release-pins.ts +0 -31
- package/src/release-public-key.ts +0 -12
- package/src/required-host-components.ts +0 -37
- package/src/resolve-api-url.ts +0 -44
- package/src/resolve-target.ts +0 -480
- package/src/rest-cache-admin.ts +0 -141
- package/src/restore-system-relation-targets.ts +0 -45
- package/src/retired-no-cache.ts +0 -27
- package/src/route-manifest.ts +0 -17
- package/src/runtime-routes.ts +0 -298
- package/src/schema-ast-v2.ts +0 -488
- package/src/schema-push-lock.ts +0 -170
- package/src/schema-sources.ts +0 -248
- package/src/scripts/postinstall.ts +0 -20
- package/src/seed-ir.ts +0 -311
- package/src/seed-runner.ts +0 -109
- package/src/seed.ts +0 -451
- package/src/self-host-compose.ts +0 -1246
- package/src/service-role-check.ts +0 -111
- package/src/storage-provision.ts +0 -90
- package/src/strict.ts +0 -40
- package/src/studio-admin-roles.ts +0 -30
- package/src/studio-dev-server.ts +0 -70
- package/src/supatype-eval-1781522769253.mts +0 -1
- package/src/systemd.ts +0 -137
- package/src/target-client.ts +0 -127
- package/src/tsx-runner.ts +0 -128
- package/src/type-extractor.ts +0 -3365
- package/src/type-generation.ts +0 -169
- package/src/type-resolver.ts +0 -457
- package/src/ui/README.md +0 -21
- package/src/ui/brand.ts +0 -6
- package/src/ui/clack-api.ts +0 -123
- package/src/ui/clack.ts +0 -153
- package/src/ui/components/FlowSpinner.tsx +0 -15
- package/src/ui/components/LogoWordmark.tsx +0 -36
- package/src/ui/components/PromptPanel.tsx +0 -17
- package/src/ui/components/SelectField.tsx +0 -58
- package/src/ui/confirm.ts +0 -39
- package/src/ui/dev/DevDashboard.tsx +0 -223
- package/src/ui/dev/DevReadyPanelView.tsx +0 -134
- package/src/ui/fatal.ts +0 -38
- package/src/ui/flows/FlowApp.tsx +0 -69
- package/src/ui/flows/prompt-fields.tsx +0 -198
- package/src/ui/flows/types.ts +0 -50
- package/src/ui/index.ts +0 -8
- package/src/ui/interactive.ts +0 -4
- package/src/ui/messages.ts +0 -85
- package/src/ui/next-steps.ts +0 -10
- package/src/ui/progress.ts +0 -39
- package/src/ui/prompts.ts +0 -48
- package/src/ui/runtime/cancel.ts +0 -6
- package/src/ui/runtime/command-chrome.ts +0 -147
- package/src/ui/runtime/dev-prompt-queue.ts +0 -84
- package/src/ui/runtime/flow-session.ts +0 -11
- package/src/ui/runtime/run-clack-flow.tsx +0 -65
- package/src/ui/runtime/stdin-after-ink.ts +0 -20
- package/src/ui/theme.ts +0 -41
- package/src/valkey-sidecar.ts +0 -126
- package/tests/access-composition.test.ts +0 -790
- package/tests/admin-ensure.test.ts +0 -139
- package/tests/admin-studio-membership.test.ts +0 -121
- package/tests/adopt-result.test.ts +0 -27
- package/tests/adopt-walkthrough.test.ts +0 -129
- package/tests/api-config-cache-seed.test.ts +0 -180
- package/tests/api-schemas.test.ts +0 -83
- package/tests/app-command.test.ts +0 -64
- package/tests/archive-name-alias.test.ts +0 -42
- package/tests/ast-derived-outputs.test.ts +0 -92
- package/tests/augmentation-generator.test.ts +0 -393
- package/tests/binary-cache-cloud-overrides.test.ts +0 -123
- package/tests/binary-download-lock.test.ts +0 -41
- package/tests/cache-clean.test.ts +0 -206
- package/tests/cache-identity-scope.test.ts +0 -61
- package/tests/cache-provider-config.test.ts +0 -132
- package/tests/cached-artifact-format.test.ts +0 -84
- package/tests/cli-help.test.ts +0 -170
- package/tests/cli-install-method.test.ts +0 -66
- package/tests/cli-package-version.test.ts +0 -15
- package/tests/client-generator.test.ts +0 -103
- package/tests/command-chrome-coverage.test.ts +0 -154
- package/tests/command-chrome-wrap.test.ts +0 -52
- package/tests/compose-parsable-defaults.test.ts +0 -60
- package/tests/compose-services.test.ts +0 -144
- package/tests/config-load-failure.test.ts +0 -44
- package/tests/config.test.ts +0 -301
- package/tests/db-port.test.ts +0 -128
- package/tests/db-preflight.test.ts +0 -152
- package/tests/db-published-and-addressable.test.ts +0 -69
- package/tests/dev-db-reset.test.ts +0 -162
- package/tests/dev-initial-push.test.ts +0 -142
- package/tests/dev-ports-owner.test.ts +0 -40
- package/tests/dev-ports.test.ts +0 -41
- package/tests/dev-ready-panel.test.ts +0 -37
- package/tests/dev-session-lock.test.ts +0 -54
- package/tests/dev-ui.test.ts +0 -202
- package/tests/docker-postgres.test.ts +0 -39
- package/tests/docker-runtime.test.ts +0 -225
- package/tests/doctor-render.test.ts +0 -62
- package/tests/doctor-service-role.test.ts +0 -55
- package/tests/engine-floor.test.ts +0 -238
- package/tests/engine-push-output.test.ts +0 -96
- package/tests/ensure-binary.test.ts +0 -59
- package/tests/ensure-dev-api-config.test.ts +0 -22
- package/tests/env-file.test.ts +0 -121
- package/tests/external-database-compose.test.ts +0 -262
- package/tests/external-database-config.test.ts +0 -154
- package/tests/field-bounds-matrix.test.ts +0 -163
- package/tests/field-bounds.test.ts +0 -139
- package/tests/field-masking-tier.test.ts +0 -184
- package/tests/field-validators.test.ts +0 -139
- package/tests/fixtures/identity-scope-corpus.json +0 -42
- package/tests/fixtures/seed_golden_ir.json +0 -186
- package/tests/functions-concurrency.test.ts +0 -71
- package/tests/functions-context-refresh.test.ts +0 -86
- package/tests/functions-deno-types.test.ts +0 -197
- package/tests/gitignore-secrets.test.ts +0 -90
- package/tests/homebrew-formula.test.ts +0 -100
- package/tests/hook-upload.test.ts +0 -125
- package/tests/hooks-generator.test.ts +0 -298
- package/tests/host-connection-targets.test.ts +0 -84
- package/tests/host-database.test.ts +0 -176
- package/tests/init-dependency-versions.test.ts +0 -62
- package/tests/init-package-json.test.ts +0 -18
- package/tests/init-project-detect.test.ts +0 -53
- package/tests/init.test.ts +0 -369
- package/tests/keys-write.test.ts +0 -148
- package/tests/keys.test.ts +0 -166
- package/tests/link.test.ts +0 -148
- package/tests/local-secrets.test.ts +0 -92
- package/tests/local-server-image-env.test.ts +0 -93
- package/tests/migrate-from-v1.test.ts +0 -29
- package/tests/minisign.test.ts +0 -102
- package/tests/model-cache-declaration.test.ts +0 -229
- package/tests/model-cache-manifest.test.ts +0 -99
- package/tests/model-constraints.test.ts +0 -293
- package/tests/model-hooks.test.ts +0 -433
- package/tests/model-versions.test.ts +0 -229
- package/tests/native-keyspace.test.ts +0 -130
- package/tests/normalize-admin-config.test.ts +0 -48
- package/tests/pg-spawn-env.test.ts +0 -18
- package/tests/port-in-use.test.ts +0 -58
- package/tests/postgres-archive-tag.test.ts +0 -9
- package/tests/preview-config-check.test.ts +0 -104
- package/tests/proxy-dev-app.test.ts +0 -77
- package/tests/pull-utils.test.ts +0 -151
- package/tests/readiness-poll.test.ts +0 -84
- package/tests/realtime-launch.test.ts +0 -25
- package/tests/release-pins.test.ts +0 -28
- package/tests/required-host-components.test.ts +0 -53
- package/tests/resolve-api-url.test.ts +0 -23
- package/tests/rest-cache-admin.test.ts +0 -64
- package/tests/retired-no-cache.test.ts +0 -46
- package/tests/route-manifest.test.ts +0 -29
- package/tests/runtime-contract.test.ts +0 -948
- package/tests/schema-sources.test.ts +0 -119
- package/tests/seed-discover.test.ts +0 -31
- package/tests/seed-ir.test.ts +0 -436
- package/tests/self-host-keys.test.ts +0 -92
- package/tests/service-role-check.test.ts +0 -109
- package/tests/service-role-routes.test.ts +0 -51
- package/tests/stdin-after-ink.test.ts +0 -8
- package/tests/storage-provision.test.ts +0 -100
- package/tests/strict.test.ts +0 -78
- package/tests/studio-admin-roles.test.ts +0 -59
- package/tests/target-client-refresh.test.ts +0 -94
- package/tests/tsconfig.json +0 -15
- package/tests/tsx-runner.test.ts +0 -66
- package/tests/type-extractor.test.ts +0 -1601
- package/tests/type-resolver.test.ts +0 -59
- package/tests/ui-confirm.test.ts +0 -45
- package/tests/ui-messages.test.ts +0 -52
- package/tsconfig.json +0 -11
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -21
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The roles and grants native `supatype dev` sets up in a new local database.
|
|
3
|
+
*
|
|
4
|
+
* Run through `psql -f -` with the script on stdin and `SUPATYPE_AUTHENTICATOR_PASSWORD` in psql's
|
|
5
|
+
* environment, read with `\getenv`. The password is never in the script text or on psql's command
|
|
6
|
+
* line, where any local user could read it from the process list.
|
|
7
|
+
*/
|
|
8
|
+
/** The environment variable the script reads the authenticator password from. */
|
|
9
|
+
export declare const AUTHENTICATOR_PASSWORD_ENV = "SUPATYPE_AUTHENTICATOR_PASSWORD";
|
|
10
|
+
/**
|
|
11
|
+
* Take `anon` and `authenticated` out of the default privileges on tables in `public`, for every
|
|
12
|
+
* role that has some (CL-N2). A table made by hand was otherwise readable by anyone with the anon
|
|
13
|
+
* key, as it no longer is on Cloud (CL1). A model table's grants are the engine's, written from the
|
|
14
|
+
* schema's access rules, so nothing a schema declares depends on these defaults. Idempotent, and
|
|
15
|
+
* run as a superuser, which may alter another role's defaults.
|
|
16
|
+
*/
|
|
17
|
+
export declare const PRIVATE_TABLE_DEFAULTS_SQL = "DO $$\nDECLARE owner_role text;\nBEGIN\n FOR owner_role IN\n SELECT DISTINCT pg_get_userbyid(defaclrole) FROM pg_default_acl\n WHERE defaclnamespace = 'public'::regnamespace AND defaclobjtype = 'r'\n LOOP\n EXECUTE format(\n 'ALTER DEFAULT PRIVILEGES FOR ROLE %I IN SCHEMA public REVOKE ALL ON TABLES FROM anon, authenticated',\n owner_role\n );\n END LOOP;\nEND $$;\n";
|
|
18
|
+
/**
|
|
19
|
+
* The script. `withMask` adds the `supatype_mask` extension, for a Postgres build that bundles it.
|
|
20
|
+
*
|
|
21
|
+
* `authenticator` is created outside the `DO` block because psql does not substitute its
|
|
22
|
+
* variables inside a dollar-quoted body; `\gexec` runs the `CREATE ROLE` only when the role is
|
|
23
|
+
* missing. Its password is then set from `.env` every time: the cluster checks passwords, and a
|
|
24
|
+
* role made before it did has whatever password it was given then.
|
|
25
|
+
*/
|
|
26
|
+
export declare function nativeRolesSql(withMask: boolean): string;
|
|
27
|
+
//# sourceMappingURL=native-roles-sql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-roles-sql.d.ts","sourceRoot":"","sources":["../src/native-roles-sql.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iFAAiF;AACjF,eAAO,MAAM,0BAA0B,oCAAoC,CAAA;AAE3E;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,8YAatC,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAiCxD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The roles and grants native `supatype dev` sets up in a new local database.
|
|
3
|
+
*
|
|
4
|
+
* Run through `psql -f -` with the script on stdin and `SUPATYPE_AUTHENTICATOR_PASSWORD` in psql's
|
|
5
|
+
* environment, read with `\getenv`. The password is never in the script text or on psql's command
|
|
6
|
+
* line, where any local user could read it from the process list.
|
|
7
|
+
*/
|
|
8
|
+
/** The environment variable the script reads the authenticator password from. */
|
|
9
|
+
export const AUTHENTICATOR_PASSWORD_ENV = "SUPATYPE_AUTHENTICATOR_PASSWORD";
|
|
10
|
+
/**
|
|
11
|
+
* Take `anon` and `authenticated` out of the default privileges on tables in `public`, for every
|
|
12
|
+
* role that has some (CL-N2). A table made by hand was otherwise readable by anyone with the anon
|
|
13
|
+
* key, as it no longer is on Cloud (CL1). A model table's grants are the engine's, written from the
|
|
14
|
+
* schema's access rules, so nothing a schema declares depends on these defaults. Idempotent, and
|
|
15
|
+
* run as a superuser, which may alter another role's defaults.
|
|
16
|
+
*/
|
|
17
|
+
export const PRIVATE_TABLE_DEFAULTS_SQL = `DO $$
|
|
18
|
+
DECLARE owner_role text;
|
|
19
|
+
BEGIN
|
|
20
|
+
FOR owner_role IN
|
|
21
|
+
SELECT DISTINCT pg_get_userbyid(defaclrole) FROM pg_default_acl
|
|
22
|
+
WHERE defaclnamespace = 'public'::regnamespace AND defaclobjtype = 'r'
|
|
23
|
+
LOOP
|
|
24
|
+
EXECUTE format(
|
|
25
|
+
'ALTER DEFAULT PRIVILEGES FOR ROLE %I IN SCHEMA public REVOKE ALL ON TABLES FROM anon, authenticated',
|
|
26
|
+
owner_role
|
|
27
|
+
);
|
|
28
|
+
END LOOP;
|
|
29
|
+
END $$;
|
|
30
|
+
`;
|
|
31
|
+
/**
|
|
32
|
+
* The script. `withMask` adds the `supatype_mask` extension, for a Postgres build that bundles it.
|
|
33
|
+
*
|
|
34
|
+
* `authenticator` is created outside the `DO` block because psql does not substitute its
|
|
35
|
+
* variables inside a dollar-quoted body; `\gexec` runs the `CREATE ROLE` only when the role is
|
|
36
|
+
* missing. Its password is then set from `.env` every time: the cluster checks passwords, and a
|
|
37
|
+
* role made before it did has whatever password it was given then.
|
|
38
|
+
*/
|
|
39
|
+
export function nativeRolesSql(withMask) {
|
|
40
|
+
return `${withMask ? "CREATE EXTENSION IF NOT EXISTS supatype_mask;\n" : ""}CREATE SCHEMA IF NOT EXISTS auth;
|
|
41
|
+
CREATE SCHEMA IF NOT EXISTS extensions;
|
|
42
|
+
-- PostgREST is told to serve graphql_public (STACK_API_SCHEMAS) and answers 503 on every request
|
|
43
|
+
-- when a schema in its list is missing. The image's pg_graphql migration creates it; a native
|
|
44
|
+
-- Postgres has no pg_graphql, so it is created here, empty, and /graphql/v1 finds no function.
|
|
45
|
+
CREATE SCHEMA IF NOT EXISTS graphql_public;
|
|
46
|
+
DO $$ BEGIN
|
|
47
|
+
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'anon')
|
|
48
|
+
THEN CREATE ROLE anon NOLOGIN; END IF;
|
|
49
|
+
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'authenticated')
|
|
50
|
+
THEN CREATE ROLE authenticated NOLOGIN; END IF;
|
|
51
|
+
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'service_role')
|
|
52
|
+
THEN CREATE ROLE service_role NOLOGIN BYPASSRLS; END IF;
|
|
53
|
+
END $$;
|
|
54
|
+
\\getenv authenticator_password ${AUTHENTICATOR_PASSWORD_ENV}
|
|
55
|
+
SELECT format('CREATE ROLE authenticator LOGIN NOINHERIT PASSWORD %L', :'authenticator_password')
|
|
56
|
+
WHERE NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'authenticator') \\gexec
|
|
57
|
+
SELECT format('ALTER ROLE authenticator PASSWORD %L', :'authenticator_password') \\gexec
|
|
58
|
+
GRANT anon, authenticated, service_role TO postgres;
|
|
59
|
+
GRANT anon, authenticated, service_role TO authenticator;
|
|
60
|
+
GRANT USAGE ON SCHEMA public TO anon, authenticated, service_role;
|
|
61
|
+
GRANT USAGE ON SCHEMA graphql_public TO anon, authenticated, service_role;
|
|
62
|
+
-- Where the engine installs PostGIS, pgvector and unaccent: a request resolves a column's type and
|
|
63
|
+
-- a filter's operator through it, and PostgREST's extra search path names it.
|
|
64
|
+
GRANT USAGE ON SCHEMA extensions TO anon, authenticated, service_role;
|
|
65
|
+
-- Tables are service_role's by default. anon and authenticated get a model table's grants from
|
|
66
|
+
-- the engine, as the schema's access rules say, and nothing on a table made by hand (CL-N2).
|
|
67
|
+
GRANT ALL ON ALL TABLES IN SCHEMA public TO service_role;
|
|
68
|
+
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO authenticated, service_role;
|
|
69
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO service_role;
|
|
70
|
+
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated, service_role;
|
|
71
|
+
${PRIVATE_TABLE_DEFAULTS_SQL}`;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=native-roles-sql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-roles-sql.js","sourceRoot":"","sources":["../src/native-roles-sql.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,iFAAiF;AACjF,MAAM,CAAC,MAAM,0BAA0B,GAAG,iCAAiC,CAAA;AAE3E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;;;;;;;CAazC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,QAAiB;IAC9C,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,iDAAiD,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;kCAc3C,0BAA0B;;;;;;;;;;;;;;;;;EAiB1D,0BAA0B,EAAE,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The owner columns the engine fills in itself.
|
|
3
|
+
*
|
|
4
|
+
* An auth user id that the model's `create` rule says must be the caller's (`Owner<"user_id">`,
|
|
5
|
+
* also inside `Any` or `All`) defaults to `_supatype.jwt_uid()` when it declares no default of its
|
|
6
|
+
* own. The rule refuses any other value, so the one a client could send is one the database
|
|
7
|
+
* already knows. This mirrors the engine's `default_owner_to_caller` (parser/normaliser.rs), so
|
|
8
|
+
* the CLI's generated `Insert` type agrees with the engine's and leaves the column optional.
|
|
9
|
+
*/
|
|
10
|
+
/** The engine's default for a caller-owned auth user id (`CALLER_ID_DEFAULT`). */
|
|
11
|
+
export declare const CALLER_ID_DEFAULT = "_supatype.jwt_uid()";
|
|
12
|
+
/**
|
|
13
|
+
* The model's fields with the caller default added where the engine adds it, for the write types.
|
|
14
|
+
* Fields that already declare a default, or are not auth user ids, are returned as they are.
|
|
15
|
+
*/
|
|
16
|
+
export declare function fieldsWithCallerDefaults(model: {
|
|
17
|
+
fields: Record<string, Record<string, unknown>>;
|
|
18
|
+
}): Record<string, Record<string, unknown>>;
|
|
19
|
+
//# sourceMappingURL=owner-default.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner-default.d.ts","sourceRoot":"","sources":["../src/owner-default.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,kFAAkF;AAClF,eAAO,MAAM,iBAAiB,wBAAwB,CAAA;AAgBtD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAChD,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAQ1C"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The owner columns the engine fills in itself.
|
|
3
|
+
*
|
|
4
|
+
* An auth user id that the model's `create` rule says must be the caller's (`Owner<"user_id">`,
|
|
5
|
+
* also inside `Any` or `All`) defaults to `_supatype.jwt_uid()` when it declares no default of its
|
|
6
|
+
* own. The rule refuses any other value, so the one a client could send is one the database
|
|
7
|
+
* already knows. This mirrors the engine's `default_owner_to_caller` (parser/normaliser.rs), so
|
|
8
|
+
* the CLI's generated `Insert` type agrees with the engine's and leaves the column optional.
|
|
9
|
+
*/
|
|
10
|
+
import { isJsonObject } from "@supatype/shared";
|
|
11
|
+
import { objectAt } from "./ast-read.js";
|
|
12
|
+
/** The engine's default for a caller-owned auth user id (`CALLER_ID_DEFAULT`). */
|
|
13
|
+
export const CALLER_ID_DEFAULT = "_supatype.jwt_uid()";
|
|
14
|
+
/** Every field an owner rule names in `rule`, looking inside `any` and `all`. */
|
|
15
|
+
function ownersInRule(rule) {
|
|
16
|
+
if (!isJsonObject(rule))
|
|
17
|
+
return [];
|
|
18
|
+
if (rule["type"] === "owner")
|
|
19
|
+
return typeof rule["field"] === "string" ? [rule["field"]] : [];
|
|
20
|
+
if ((rule["type"] === "any" || rule["type"] === "all") && Array.isArray(rule["rules"])) {
|
|
21
|
+
return rule["rules"].flatMap(ownersInRule);
|
|
22
|
+
}
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
function isAuthUserId(meta) {
|
|
26
|
+
return objectAt(meta, "annotations", "db")?.["authUserId"] === true;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The model's fields with the caller default added where the engine adds it, for the write types.
|
|
30
|
+
* Fields that already declare a default, or are not auth user ids, are returned as they are.
|
|
31
|
+
*/
|
|
32
|
+
export function fieldsWithCallerDefaults(model) {
|
|
33
|
+
const owners = new Set(ownersInRule(objectAt(model, "annotations", "platform", "access")?.["create"]));
|
|
34
|
+
if (owners.size === 0)
|
|
35
|
+
return model.fields;
|
|
36
|
+
const entries = Object.entries(model.fields).map(([name, meta]) => {
|
|
37
|
+
const defaulted = owners.has(name) && isAuthUserId(meta) && meta["default"] === undefined;
|
|
38
|
+
return [name, defaulted ? { ...meta, default: { expression: CALLER_ID_DEFAULT } } : meta];
|
|
39
|
+
});
|
|
40
|
+
return Object.fromEntries(entries);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=owner-default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"owner-default.js","sourceRoot":"","sources":["../src/owner-default.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,kFAAkF;AAClF,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAA;AAEtD,iFAAiF;AACjF,SAAS,YAAY,CAAC,IAAa;IACjC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAA;IAClC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,OAAO;QAAE,OAAO,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC7F,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QACvF,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;IAC5C,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC;AAED,SAAS,YAAY,CAAC,IAA6B;IACjD,OAAO,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,KAAK,IAAI,CAAA;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAExC;IACC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IACtG,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,MAAM,CAAA;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;QAChE,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,SAAS,CAAA;QACzF,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAU,CAAA;IACpG,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `package.json` the CLI reads: the project's, a plugin's, a dependency's. Each field is read with
|
|
3
|
+
* a check, and one of the wrong type reads as absent, so a hand-edited file degrades field by field
|
|
4
|
+
* instead of throwing a TypeError at whoever reads it next.
|
|
5
|
+
*/
|
|
6
|
+
export interface PackageJson {
|
|
7
|
+
name?: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
dependencies: Record<string, string>;
|
|
10
|
+
devDependencies: Record<string, string>;
|
|
11
|
+
scripts: Record<string, string>;
|
|
12
|
+
keywords: string[];
|
|
13
|
+
/** `bin`: one path, or paths by command name. */
|
|
14
|
+
bin?: string | Record<string, string>;
|
|
15
|
+
/** The whole object, for a field read only in one place (`supatype`, say). */
|
|
16
|
+
raw: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
/** `package.json` text read field by field. Throws when the text is not JSON, as `JSON.parse` does. */
|
|
19
|
+
export declare function parsePackageJson(text: string): PackageJson;
|
|
20
|
+
//# sourceMappingURL=package-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../src/package-json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7B;AAQD,uGAAuG;AACvG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAc1D"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `package.json` the CLI reads: the project's, a plugin's, a dependency's. Each field is read with
|
|
3
|
+
* a check, and one of the wrong type reads as absent, so a hand-edited file degrades field by field
|
|
4
|
+
* instead of throwing a TypeError at whoever reads it next.
|
|
5
|
+
*/
|
|
6
|
+
import { isJsonObject, isString } from "@supatype/shared";
|
|
7
|
+
/** The string-valued entries of `value` when it is an object; an empty record otherwise. */
|
|
8
|
+
function stringRecord(value) {
|
|
9
|
+
if (!isJsonObject(value))
|
|
10
|
+
return {};
|
|
11
|
+
return Object.fromEntries(Object.entries(value).filter((entry) => isString(entry[1])));
|
|
12
|
+
}
|
|
13
|
+
/** `package.json` text read field by field. Throws when the text is not JSON, as `JSON.parse` does. */
|
|
14
|
+
export function parsePackageJson(text) {
|
|
15
|
+
const parsed = JSON.parse(text);
|
|
16
|
+
const raw = isJsonObject(parsed) ? parsed : {};
|
|
17
|
+
const { name, version, bin, keywords } = raw;
|
|
18
|
+
return {
|
|
19
|
+
...(isString(name) && { name }),
|
|
20
|
+
...(isString(version) && { version }),
|
|
21
|
+
dependencies: stringRecord(raw["dependencies"]),
|
|
22
|
+
devDependencies: stringRecord(raw["devDependencies"]),
|
|
23
|
+
scripts: stringRecord(raw["scripts"]),
|
|
24
|
+
keywords: Array.isArray(keywords) ? keywords.filter(isString) : [],
|
|
25
|
+
...(isString(bin) ? { bin } : isJsonObject(bin) && { bin: stringRecord(bin) }),
|
|
26
|
+
raw,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=package-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.js","sourceRoot":"","sources":["../src/package-json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAezD,4FAA4F;AAC5F,SAAS,YAAY,CAAC,KAAc;IAClC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACnC,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAA6B,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACnH,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC/B,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;IAC9C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAA;IAC5C,OAAO;QACL,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QAC/B,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;QACrC,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC/C,eAAe,EAAE,YAAY,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACrD,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACrC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;QAClE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9E,GAAG;KACJ,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the process that started `supatype dev` is still there.
|
|
3
|
+
*
|
|
4
|
+
* A script that starts `dev` and is then killed outright (SIGKILL, a cancelled CI job, a tool
|
|
5
|
+
* timeout) runs no cleanup of its own, and `dev` ran on, holding the stack, its ports and its
|
|
6
|
+
* compose project until someone found it. `dev` now watches its parent and stops, the way Ctrl+C
|
|
7
|
+
* stops it, once the parent is gone.
|
|
8
|
+
*
|
|
9
|
+
* Two signs, for the two families of platform:
|
|
10
|
+
* - Linux and macOS hand an orphan to a new parent, so `process.ppid` changes.
|
|
11
|
+
* - Windows does not, so the parent's PID is checked for life.
|
|
12
|
+
* Git Bash adds one wrinkle: a script's `(cd dir && exec node ...)` leaves a bash stub between the
|
|
13
|
+
* script and node, and the stub outlives a killed script. On Windows the grandparent is therefore
|
|
14
|
+
* watched too (watchAlso), resolved once at start.
|
|
15
|
+
*/
|
|
16
|
+
export interface ProcessProbe {
|
|
17
|
+
ppid(): number;
|
|
18
|
+
alive(pid: number): boolean;
|
|
19
|
+
}
|
|
20
|
+
/** True when a process with this PID exists. EPERM means it exists and belongs to someone else. */
|
|
21
|
+
export declare function pidAlive(pid: number): boolean;
|
|
22
|
+
export declare const liveProbe: ProcessProbe;
|
|
23
|
+
export interface ParentWatch {
|
|
24
|
+
/** Watch one more ancestor; its death counts as the parent's. */
|
|
25
|
+
watchAlso(pid: number): void;
|
|
26
|
+
stop(): void;
|
|
27
|
+
}
|
|
28
|
+
export interface WatchParentOptions {
|
|
29
|
+
intervalMs?: number;
|
|
30
|
+
probe?: ProcessProbe;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Calls `onGone` once, within `intervalMs`, after the parent (or an ancestor added with
|
|
34
|
+
* `watchAlso`) exits. Started without a parent to lose (PID 0 or 1: already orphaned, or the
|
|
35
|
+
* container's init), it watches nothing. The timer does not keep the process alive.
|
|
36
|
+
*/
|
|
37
|
+
export declare function watchParent(onGone: () => void, opts?: WatchParentOptions): ParentWatch;
|
|
38
|
+
/** The parent of `pid` on Windows, or undefined when it cannot be read. */
|
|
39
|
+
export declare function windowsParentOf(pid: number): Promise<number | undefined>;
|
|
40
|
+
//# sourceMappingURL=parent-watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parent-watch.d.ts","sourceRoot":"","sources":["../src/parent-watch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,MAAM,WAAW,YAAY;IAC3B,IAAI,IAAI,MAAM,CAAA;IACd,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAC5B;AAED,mGAAmG;AACnG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO7C;AAED,eAAO,MAAM,SAAS,EAAE,YAGvB,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,IAAI,IAAI,CAAA;CACb;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,YAAY,CAAA;CACrB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,IAAI,GAAE,kBAAuB,GAAG,WAAW,CA0B1F;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAYxE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the process that started `supatype dev` is still there.
|
|
3
|
+
*
|
|
4
|
+
* A script that starts `dev` and is then killed outright (SIGKILL, a cancelled CI job, a tool
|
|
5
|
+
* timeout) runs no cleanup of its own, and `dev` ran on, holding the stack, its ports and its
|
|
6
|
+
* compose project until someone found it. `dev` now watches its parent and stops, the way Ctrl+C
|
|
7
|
+
* stops it, once the parent is gone.
|
|
8
|
+
*
|
|
9
|
+
* Two signs, for the two families of platform:
|
|
10
|
+
* - Linux and macOS hand an orphan to a new parent, so `process.ppid` changes.
|
|
11
|
+
* - Windows does not, so the parent's PID is checked for life.
|
|
12
|
+
* Git Bash adds one wrinkle: a script's `(cd dir && exec node ...)` leaves a bash stub between the
|
|
13
|
+
* script and node, and the stub outlives a killed script. On Windows the grandparent is therefore
|
|
14
|
+
* watched too (watchAlso), resolved once at start.
|
|
15
|
+
*/
|
|
16
|
+
import { execFile } from "node:child_process";
|
|
17
|
+
import { errorCode } from "./error-message.js";
|
|
18
|
+
/** True when a process with this PID exists. EPERM means it exists and belongs to someone else. */
|
|
19
|
+
export function pidAlive(pid) {
|
|
20
|
+
try {
|
|
21
|
+
process.kill(pid, 0);
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
return errorCode(err) === "EPERM";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export const liveProbe = {
|
|
29
|
+
ppid: () => process.ppid,
|
|
30
|
+
alive: pidAlive,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Calls `onGone` once, within `intervalMs`, after the parent (or an ancestor added with
|
|
34
|
+
* `watchAlso`) exits. Started without a parent to lose (PID 0 or 1: already orphaned, or the
|
|
35
|
+
* container's init), it watches nothing. The timer does not keep the process alive.
|
|
36
|
+
*/
|
|
37
|
+
export function watchParent(onGone, opts = {}) {
|
|
38
|
+
const probe = opts.probe ?? liveProbe;
|
|
39
|
+
const parent = probe.ppid();
|
|
40
|
+
const watched = new Set();
|
|
41
|
+
let timer;
|
|
42
|
+
const stop = () => {
|
|
43
|
+
if (timer !== undefined)
|
|
44
|
+
clearInterval(timer);
|
|
45
|
+
timer = undefined;
|
|
46
|
+
};
|
|
47
|
+
if (parent > 1) {
|
|
48
|
+
watched.add(parent);
|
|
49
|
+
timer = setInterval(() => {
|
|
50
|
+
const gone = probe.ppid() !== parent || [...watched].some((pid) => !probe.alive(pid));
|
|
51
|
+
if (!gone)
|
|
52
|
+
return;
|
|
53
|
+
stop();
|
|
54
|
+
onGone();
|
|
55
|
+
}, opts.intervalMs ?? 2000);
|
|
56
|
+
timer.unref?.();
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
watchAlso: (pid) => {
|
|
60
|
+
if (timer !== undefined && pid > 1)
|
|
61
|
+
watched.add(pid);
|
|
62
|
+
},
|
|
63
|
+
stop,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** The parent of `pid` on Windows, or undefined when it cannot be read. */
|
|
67
|
+
export function windowsParentOf(pid) {
|
|
68
|
+
return new Promise((resolve) => {
|
|
69
|
+
execFile("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", `(Get-CimInstance Win32_Process -Filter "ProcessId=${pid}").ParentProcessId`], { timeout: 15_000, windowsHide: true }, (err, stdout) => {
|
|
70
|
+
const parent = Number(stdout.trim());
|
|
71
|
+
resolve(err || !Number.isInteger(parent) || parent <= 0 ? undefined : parent);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=parent-watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parent-watch.js","sourceRoot":"","sources":["../src/parent-watch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAO9C,mGAAmG;AACnG,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;QACpB,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,SAAS,CAAC,GAAG,CAAC,KAAK,OAAO,CAAA;IACnC,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAiB;IACrC,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI;IACxB,KAAK,EAAE,QAAQ;CAChB,CAAA;AAaD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,MAAkB,EAAE,OAA2B,EAAE;IAC3E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,SAAS,CAAA;IACrC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;IAC3B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;IACjC,IAAI,KAAiD,CAAA;IAErD,MAAM,IAAI,GAAG,GAAS,EAAE;QACtB,IAAI,KAAK,KAAK,SAAS;YAAE,aAAa,CAAC,KAAK,CAAC,CAAA;QAC7C,KAAK,GAAG,SAAS,CAAA;IACnB,CAAC,CAAA;IACD,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACnB,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;YACvB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,KAAK,MAAM,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;YACrF,IAAI,CAAC,IAAI;gBAAE,OAAM;YACjB,IAAI,EAAE,CAAA;YACN,MAAM,EAAE,CAAA;QACV,CAAC,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,CAAA;QAC3B,KAAK,CAAC,KAAK,EAAE,EAAE,CAAA;IACjB,CAAC;IACD,OAAO;QACL,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE;YACjB,IAAI,KAAK,KAAK,SAAS,IAAI,GAAG,GAAG,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACtD,CAAC;QACD,IAAI;KACL,CAAA;AACH,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,QAAQ,CACN,gBAAgB,EAChB,CAAC,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,qDAAqD,GAAG,oBAAoB,CAAC,EAC3H,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,EACtC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACd,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;YACpC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QAC/E,CAAC,CACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/postgres-ctl.d.ts
CHANGED
|
@@ -26,11 +26,21 @@ export interface PgOptions {
|
|
|
26
26
|
* must load libpq and friends from the extracted lib/ next to bin/.
|
|
27
27
|
*/
|
|
28
28
|
export declare function pgSpawnEnv(pgBinDir: string, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
|
|
29
|
+
/** How every local and host connection to a native cluster authenticates. */
|
|
30
|
+
export declare const NATIVE_AUTH_METHOD = "scram-sha-256";
|
|
29
31
|
/**
|
|
30
|
-
*
|
|
32
|
+
* initdb's arguments: the superuser `postgres`, with the password in `pwfile`, and password
|
|
33
|
+
* authentication for every connection.
|
|
34
|
+
*
|
|
35
|
+
* This used to be `--auth trust`, which made the passwords the CLI generates decoration: any
|
|
36
|
+
* local process could connect as any role, the superuser included, with any password or none.
|
|
37
|
+
*/
|
|
38
|
+
export declare function initdbArgs(dataDir: string, pwfile: string): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Initialise a Postgres data directory, with `superuserPassword` for `postgres`.
|
|
31
41
|
* Does nothing if the data directory already contains a PG_VERSION file.
|
|
32
42
|
*/
|
|
33
|
-
export declare function initdb(opts: PgOptions): void;
|
|
43
|
+
export declare function initdb(opts: PgOptions, superuserPassword: string): void;
|
|
34
44
|
/**
|
|
35
45
|
* Start Postgres using pg_ctl.
|
|
36
46
|
* Returns immediately once pg_ctl has handed off to the server process.
|
|
@@ -51,11 +61,20 @@ export declare function nativeMaskLibraryPresent(pgBinDir: string | null | undef
|
|
|
51
61
|
*
|
|
52
62
|
* Asked of the filesystem for the same reason as the mask: an archive
|
|
53
63
|
* downloaded before pg_keyspace was bundled has a Postgres without it, and the
|
|
54
|
-
* Windows archive has none at all
|
|
64
|
+
* Windows archive has none at all, because pgrx has no Windows target. Naming it in
|
|
55
65
|
* `shared_preload_libraries` anyway would stop the server starting with "could
|
|
56
66
|
* not access file", which would turn a missing cache into no database.
|
|
57
67
|
*/
|
|
58
68
|
export declare function nativeKeyspaceLibraryPresent(pgBinDir: string | null | undefined): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* What supatype-server is told about GraphQL for a native Postgres install: switched off when the
|
|
71
|
+
* install has no pg_graphql, which no native archive carries (it is a pgrx extension, built only
|
|
72
|
+
* into the supatype/postgres image). The server then answers `/graphql/v1` with 501
|
|
73
|
+
* `graphql_unavailable` instead of PostgREST's "could not find the function
|
|
74
|
+
* graphql_public.graphql". Asked of the filesystem, like the mask, so an install that does carry
|
|
75
|
+
* the library keeps GraphQL.
|
|
76
|
+
*/
|
|
77
|
+
export declare function nativeGraphqlServerEnv(pgBinDir: string | null | undefined): Record<string, string>;
|
|
59
78
|
/**
|
|
60
79
|
* Where the native RESP keyspace looks for a free port, and how far it looks.
|
|
61
80
|
*
|
|
@@ -68,8 +87,8 @@ export declare const KEYSPACE_PORT_SPAN = 10;
|
|
|
68
87
|
* The first free port in [base, base + span), or null when they are all taken.
|
|
69
88
|
*
|
|
70
89
|
* Binding a port something else already holds would leave Postgres up and the
|
|
71
|
-
* keyspace silently dead
|
|
72
|
-
* a developer is looking
|
|
90
|
+
* keyspace silently dead. The failure lands in the postmaster log and nowhere
|
|
91
|
+
* a developer is looking, so the port is chosen before the server starts
|
|
73
92
|
* rather than fixed and hoped for.
|
|
74
93
|
*/
|
|
75
94
|
export declare function firstFreePort(base: number, span: number): Promise<number | null>;
|
|
@@ -82,7 +101,7 @@ export declare function firstFreePort(base: number, span: number): Promise<numbe
|
|
|
82
101
|
*
|
|
83
102
|
* Order in `shared_preload_libraries` is load-bearing: pg_keyspace first, then
|
|
84
103
|
* supatype_mask, so the mask stays outermost. pg_keyspace checks this itself
|
|
85
|
-
* and refuses to serve when the order is wrong
|
|
104
|
+
* and refuses to serve when the order is wrong, deliberately, since RESP
|
|
86
105
|
* would otherwise hand back rows the mask never rewrote.
|
|
87
106
|
*
|
|
88
107
|
* The sizing is the measured dev profile: ~60 MiB of shared memory, against
|
|
@@ -97,6 +116,8 @@ export declare function start(opts: PgOptions): void;
|
|
|
97
116
|
* Stop Postgres using pg_ctl (fast mode).
|
|
98
117
|
*/
|
|
99
118
|
export declare function stop(opts: PgOptions): void;
|
|
119
|
+
/** Ask the running server to re-read its configuration, pg_hba.conf included. */
|
|
120
|
+
export declare function reload(opts: PgOptions): void;
|
|
100
121
|
/**
|
|
101
122
|
* Wait until Postgres is accepting connections.
|
|
102
123
|
* Polls pg_isready every 200ms up to timeoutMs.
|
|
@@ -111,4 +132,6 @@ export declare function waitReady(opts: PgOptions, timeoutMs?: number): Promise<
|
|
|
111
132
|
* the failure this exists to prevent.
|
|
112
133
|
*/
|
|
113
134
|
export declare function isPortInUse(port: number): Promise<boolean>;
|
|
135
|
+
/** Returns the full path to a Postgres binary, appending .exe on Windows. */
|
|
136
|
+
export declare function pgBin(binDir: string, name: string): string;
|
|
114
137
|
//# sourceMappingURL=postgres-ctl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-ctl.d.ts","sourceRoot":"","sources":["../src/postgres-ctl.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"postgres-ctl.d.ts","sourceRoot":"","sources":["../src/postgres-ctl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,WAAW,SAAS;IACxB,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAA;IAChB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAA;IACf,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,CAAC,UAAU,CAWnB;AAMD,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AAEjD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAQpE;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAuBvE;AAMD;;;GAGG;AACH;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAErF;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEzF;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAElG;AAeD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,OAAO,CAAA;AACtC,eAAO,MAAM,kBAAkB,KAAK,CAAA;AAEpC;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKtF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAoBvD;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CA4B3C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAS1C;AAED,iFAAiF;AACjF,wBAAgB,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAS5C;AAMD;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBlF;AAoDD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGhE;AAUD,6EAA6E;AAC7E,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
package/dist/postgres-ctl.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* a native Postgres installation.
|
|
4
4
|
*/
|
|
5
5
|
import { spawnSync } from "node:child_process";
|
|
6
|
-
import { existsSync, mkdirSync } from "node:fs";
|
|
6
|
+
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { tmpdir } from "node:os";
|
|
7
8
|
import { dirname, join, resolve as resolvePath } from "node:path";
|
|
8
9
|
/**
|
|
9
10
|
* Native Postgres bundles are built with prefix /usr/local/supatype-pg; dyld/ld
|
|
@@ -25,23 +26,50 @@ export function pgSpawnEnv(pgBinDir, platform = process.platform) {
|
|
|
25
26
|
// ---------------------------------------------------------------------------
|
|
26
27
|
// initdb
|
|
27
28
|
// ---------------------------------------------------------------------------
|
|
29
|
+
/** How every local and host connection to a native cluster authenticates. */
|
|
30
|
+
export const NATIVE_AUTH_METHOD = "scram-sha-256";
|
|
28
31
|
/**
|
|
29
|
-
*
|
|
32
|
+
* initdb's arguments: the superuser `postgres`, with the password in `pwfile`, and password
|
|
33
|
+
* authentication for every connection.
|
|
34
|
+
*
|
|
35
|
+
* This used to be `--auth trust`, which made the passwords the CLI generates decoration: any
|
|
36
|
+
* local process could connect as any role, the superuser included, with any password or none.
|
|
37
|
+
*/
|
|
38
|
+
export function initdbArgs(dataDir, pwfile) {
|
|
39
|
+
return [
|
|
40
|
+
"-D", dataDir,
|
|
41
|
+
"--username", "postgres",
|
|
42
|
+
`--pwfile=${pwfile}`,
|
|
43
|
+
`--auth-local=${NATIVE_AUTH_METHOD}`,
|
|
44
|
+
`--auth-host=${NATIVE_AUTH_METHOD}`,
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Initialise a Postgres data directory, with `superuserPassword` for `postgres`.
|
|
30
49
|
* Does nothing if the data directory already contains a PG_VERSION file.
|
|
31
50
|
*/
|
|
32
|
-
export function initdb(opts) {
|
|
51
|
+
export function initdb(opts, superuserPassword) {
|
|
33
52
|
const pgVersionFile = join(opts.dataDir, "PG_VERSION");
|
|
34
53
|
if (existsSync(pgVersionFile))
|
|
35
54
|
return; // Already initialised.
|
|
36
55
|
mkdirSync(opts.dataDir, { recursive: true });
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
// initdb reads the password from a file, never an argument another process could see. The
|
|
57
|
+
// file lives in a directory of its own, readable by this user only, for the length of the call.
|
|
58
|
+
const pwDir = mkdtempSync(join(tmpdir(), "supatype-initdb-"));
|
|
59
|
+
const pwfile = join(pwDir, "pw");
|
|
60
|
+
try {
|
|
61
|
+
writeFileSync(pwfile, `${superuserPassword}\n`, { mode: 0o600 });
|
|
62
|
+
const result = spawnSync(pgBin(opts.pgBinDir, "initdb"), initdbArgs(opts.dataDir, pwfile), {
|
|
63
|
+
stdio: "inherit",
|
|
64
|
+
encoding: "utf8",
|
|
65
|
+
env: pgSpawnEnv(opts.pgBinDir),
|
|
66
|
+
});
|
|
67
|
+
if (result.status !== 0) {
|
|
68
|
+
throw new Error(`initdb failed (exit ${result.status})`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
rmSync(pwDir, { recursive: true, force: true });
|
|
45
73
|
}
|
|
46
74
|
}
|
|
47
75
|
// ---------------------------------------------------------------------------
|
|
@@ -69,13 +97,24 @@ export function nativeMaskLibraryPresent(pgBinDir) {
|
|
|
69
97
|
*
|
|
70
98
|
* Asked of the filesystem for the same reason as the mask: an archive
|
|
71
99
|
* downloaded before pg_keyspace was bundled has a Postgres without it, and the
|
|
72
|
-
* Windows archive has none at all
|
|
100
|
+
* Windows archive has none at all, because pgrx has no Windows target. Naming it in
|
|
73
101
|
* `shared_preload_libraries` anyway would stop the server starting with "could
|
|
74
102
|
* not access file", which would turn a missing cache into no database.
|
|
75
103
|
*/
|
|
76
104
|
export function nativeKeyspaceLibraryPresent(pgBinDir) {
|
|
77
105
|
return nativeLibraryPresent(pgBinDir, "pg_keyspace");
|
|
78
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* What supatype-server is told about GraphQL for a native Postgres install: switched off when the
|
|
109
|
+
* install has no pg_graphql, which no native archive carries (it is a pgrx extension, built only
|
|
110
|
+
* into the supatype/postgres image). The server then answers `/graphql/v1` with 501
|
|
111
|
+
* `graphql_unavailable` instead of PostgREST's "could not find the function
|
|
112
|
+
* graphql_public.graphql". Asked of the filesystem, like the mask, so an install that does carry
|
|
113
|
+
* the library keeps GraphQL.
|
|
114
|
+
*/
|
|
115
|
+
export function nativeGraphqlServerEnv(pgBinDir) {
|
|
116
|
+
return nativeLibraryPresent(pgBinDir, "pg_graphql") ? {} : { SUPATYPE_GRAPHQL_DISABLED: "true" };
|
|
117
|
+
}
|
|
79
118
|
/**
|
|
80
119
|
* Two layouts: Linux and macOS put extension libraries in `lib/`, the Windows
|
|
81
120
|
* archive in `lib/postgresql/`.
|
|
@@ -98,8 +137,8 @@ export const KEYSPACE_PORT_SPAN = 10;
|
|
|
98
137
|
* The first free port in [base, base + span), or null when they are all taken.
|
|
99
138
|
*
|
|
100
139
|
* Binding a port something else already holds would leave Postgres up and the
|
|
101
|
-
* keyspace silently dead
|
|
102
|
-
* a developer is looking
|
|
140
|
+
* keyspace silently dead. The failure lands in the postmaster log and nowhere
|
|
141
|
+
* a developer is looking, so the port is chosen before the server starts
|
|
103
142
|
* rather than fixed and hoped for.
|
|
104
143
|
*/
|
|
105
144
|
export async function firstFreePort(base, span) {
|
|
@@ -118,7 +157,7 @@ export async function firstFreePort(base, span) {
|
|
|
118
157
|
*
|
|
119
158
|
* Order in `shared_preload_libraries` is load-bearing: pg_keyspace first, then
|
|
120
159
|
* supatype_mask, so the mask stays outermost. pg_keyspace checks this itself
|
|
121
|
-
* and refuses to serve when the order is wrong
|
|
160
|
+
* and refuses to serve when the order is wrong, deliberately, since RESP
|
|
122
161
|
* would otherwise hand back rows the mask never rewrote.
|
|
123
162
|
*
|
|
124
163
|
* The sizing is the measured dev profile: ~60 MiB of shared memory, against
|
|
@@ -146,7 +185,7 @@ export function start(opts) {
|
|
|
146
185
|
const bin = pgBin(opts.pgBinDir, "pg_ctl");
|
|
147
186
|
const logPath = opts.logPath ?? join(opts.dataDir, "postgres.log");
|
|
148
187
|
// `supatype_mask` is a planner hook and pg_keyspace registers background
|
|
149
|
-
// workers and shared memory, so both have to be preloaded
|
|
188
|
+
// workers and shared memory, so both have to be preloaded: `CREATE
|
|
150
189
|
// EXTENSION` alone does nothing for either. Only when the archive actually
|
|
151
190
|
// carries them; see pgServerOptions.
|
|
152
191
|
//
|
|
@@ -182,6 +221,17 @@ export function stop(opts) {
|
|
|
182
221
|
// Ignore exit code: Postgres may already be stopped.
|
|
183
222
|
void result;
|
|
184
223
|
}
|
|
224
|
+
/** Ask the running server to re-read its configuration, pg_hba.conf included. */
|
|
225
|
+
export function reload(opts) {
|
|
226
|
+
const result = spawnSync(pgBin(opts.pgBinDir, "pg_ctl"), ["reload", "-D", opts.dataDir], {
|
|
227
|
+
stdio: "pipe",
|
|
228
|
+
encoding: "utf8",
|
|
229
|
+
env: pgSpawnEnv(opts.pgBinDir),
|
|
230
|
+
});
|
|
231
|
+
if (result.status !== 0) {
|
|
232
|
+
throw new Error(`pg_ctl reload failed (exit ${result.status}): ${(result.stderr ?? "").trim()}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
185
235
|
// ---------------------------------------------------------------------------
|
|
186
236
|
// waitReady
|
|
187
237
|
// ---------------------------------------------------------------------------
|
|
@@ -270,7 +320,7 @@ function sleep(ms) {
|
|
|
270
320
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
271
321
|
}
|
|
272
322
|
/** Returns the full path to a Postgres binary, appending .exe on Windows. */
|
|
273
|
-
function pgBin(binDir, name) {
|
|
323
|
+
export function pgBin(binDir, name) {
|
|
274
324
|
return join(binDir, process.platform === "win32" ? `${name}.exe` : name);
|
|
275
325
|
}
|
|
276
326
|
//# sourceMappingURL=postgres-ctl.js.map
|