@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
package/dist/model-versioning.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { existsSync } from "node:fs";
|
|
13
13
|
import { loadSchemaAst } from "./config.js";
|
|
14
|
+
import { isJsonObject } from "@supatype/shared";
|
|
15
|
+
import { astModels, isNonEmptyObject, objectAt } from "./ast-read.js";
|
|
14
16
|
import { draftVisibilityRoles, previewLimits, schemaPathFromProject } from "./project-config.js";
|
|
15
17
|
/** Versions kept per record when the model states no retention. */
|
|
16
18
|
export const DEFAULT_VERSIONS_KEPT = 20;
|
|
@@ -24,29 +26,31 @@ export const DEFAULT_VERSIONS_KEPT = 20;
|
|
|
24
26
|
export function resolveVersionsOptions(raw) {
|
|
25
27
|
if (raw === true)
|
|
26
28
|
return { drafts: true, keep: DEFAULT_VERSIONS_KEPT };
|
|
27
|
-
if (
|
|
29
|
+
if (!isJsonObject(raw))
|
|
28
30
|
return undefined;
|
|
29
|
-
const
|
|
30
|
-
const keep = typeof
|
|
31
|
-
? Math.floor(
|
|
31
|
+
const { keep: declared, drafts } = raw;
|
|
32
|
+
const keep = typeof declared === "number" && Number.isFinite(declared) && declared >= 1
|
|
33
|
+
? Math.floor(declared)
|
|
32
34
|
: DEFAULT_VERSIONS_KEPT;
|
|
33
|
-
return { drafts:
|
|
35
|
+
return { drafts: drafts !== false, keep };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether `model` keeps drafts: it declares `versions` without `drafts: false`. Where the client
|
|
39
|
+
* routes an insert or an update through the publishing functions, and where `update` takes
|
|
40
|
+
* `{ publish: true }`.
|
|
41
|
+
*/
|
|
42
|
+
export function keepsDrafts(model) {
|
|
43
|
+
return resolveVersionsOptions(objectAt(model, "options")?.["versions"])?.drafts === true;
|
|
34
44
|
}
|
|
35
45
|
/** Every model in the schema that declares `versions`, in declaration order. */
|
|
36
46
|
export function versionedModels(ast) {
|
|
37
|
-
const models = ast?.models;
|
|
38
|
-
if (!Array.isArray(models))
|
|
39
|
-
return [];
|
|
40
47
|
const out = [];
|
|
41
|
-
for (const
|
|
42
|
-
const
|
|
43
|
-
if (model === null || typeof model !== "object")
|
|
44
|
-
continue;
|
|
45
|
-
const options = resolveVersionsOptions(model.options?.["versions"]);
|
|
48
|
+
for (const model of astModels(ast)) {
|
|
49
|
+
const options = resolveVersionsOptions(objectAt(model, "options")?.["versions"]);
|
|
46
50
|
if (options === undefined)
|
|
47
51
|
continue;
|
|
48
|
-
const name = typeof model
|
|
49
|
-
const tableName = model
|
|
52
|
+
const name = typeof model["name"] === "string" ? model["name"] : "";
|
|
53
|
+
const tableName = objectAt(model, "annotations", "db")?.["tableName"];
|
|
50
54
|
out.push({
|
|
51
55
|
name,
|
|
52
56
|
tableName: typeof tableName === "string" ? tableName : name,
|
|
@@ -70,24 +74,17 @@ export function schemaHasVersionedModels(ast) {
|
|
|
70
74
|
*
|
|
71
75
|
* Per model, and that matters: under the view tier the managed schema comes off the exposed list but
|
|
72
76
|
* the API roles keep their privileges on the base tables, so a `security_invoker` view in an exposed
|
|
73
|
-
* schema
|
|
77
|
+
* schema (which is exactly what `draft.<table>` is) reaches past the `api` layer. A project may
|
|
74
78
|
* hold a masked model and a versioned model at once; one model may not be both.
|
|
75
79
|
*/
|
|
76
80
|
export function modelsWithVersionsAndFieldRules(ast) {
|
|
77
|
-
const models = ast?.models;
|
|
78
|
-
if (!Array.isArray(models))
|
|
79
|
-
return [];
|
|
80
81
|
const out = [];
|
|
81
|
-
for (const
|
|
82
|
-
|
|
83
|
-
if (model === null || typeof model !== "object")
|
|
84
|
-
continue;
|
|
85
|
-
if (resolveVersionsOptions(model.options?.["versions"]) === undefined)
|
|
82
|
+
for (const model of astModels(ast)) {
|
|
83
|
+
if (resolveVersionsOptions(objectAt(model, "options")?.["versions"]) === undefined)
|
|
86
84
|
continue;
|
|
87
|
-
|
|
88
|
-
if (typeof fields !== "object" || fields === null || Object.keys(fields).length === 0)
|
|
85
|
+
if (!isNonEmptyObject(objectAt(model, "annotations", "platform", "access")?.["fields"]))
|
|
89
86
|
continue;
|
|
90
|
-
out.push(typeof model
|
|
87
|
+
out.push(typeof model["name"] === "string" ? model["name"] : "(unnamed model)");
|
|
91
88
|
}
|
|
92
89
|
return out;
|
|
93
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-versioning.js","sourceRoot":"","sources":["../src/model-versioning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAG3C,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAEhG,mEAAmE;AACnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"model-versioning.js","sourceRoot":"","sources":["../src/model-versioning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,E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CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAA;IACjF,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,GAAW,EAAE,MAA6B;IAClF,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QACrD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,OAAO,KAAK,CAAA;QACzC,OAAO,wBAAwB,CAAC,aAAa,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAA;IACjE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAyB,EACzB,MAA6B;IAE7B,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAA;IAE9C,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;IACpC,OAAO;QACL,GAAG,GAAG;QACN,UAAU,EAAE;YACV,eAAe,EAAE,oBAAoB,CAAC,MAAM,CAAC;YAC7C,iBAAiB,EAAE,MAAM,CAAC,UAAU;YACpC,mBAAmB,EAAE,MAAM,CAAC,YAAY;YACxC,oBAAoB,EAAE,MAAM,CAAC,aAAa;YAC1C,wBAAwB,EAAE,MAAM,CAAC,iBAAiB;SACnD;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the native Postgres install decides about the services `supatype dev` starts beside it.
|
|
3
|
+
*
|
|
4
|
+
* Kept out of the dev action so the decisions are testable. Each one is asked of the install's
|
|
5
|
+
* filesystem (see `postgres-ctl.ts`), and a wiring line dropped from a 600-line action would
|
|
6
|
+
* otherwise go unnoticed: the server would forward `/graphql/v1` to a PostgREST that cannot answer
|
|
7
|
+
* it, or PostgREST would be pointed at the wrong schemas for the tier the push will use.
|
|
8
|
+
*/
|
|
9
|
+
import { postgrestSchemaEnv, type SupatypeProjectConfig } from "./project-config.js";
|
|
10
|
+
/** Inputs to the outer layer of supatype-server's environment on the native path. */
|
|
11
|
+
export interface NativeServerCoreInput {
|
|
12
|
+
mode: string;
|
|
13
|
+
/** Empty when no keyspace or Valkey sidecar is reachable. */
|
|
14
|
+
valkeyAddr: string;
|
|
15
|
+
projectRef: string;
|
|
16
|
+
manifestPath: string;
|
|
17
|
+
adminConfigPath: string;
|
|
18
|
+
postgrestPort: string;
|
|
19
|
+
pgBinDir: string | null;
|
|
20
|
+
/** The project database on this machine, which is where the native server reaches it too. */
|
|
21
|
+
databaseUrl: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* supatype-server's outer layer: mode, cache, manifest paths, PostgREST and GraphQL, and the
|
|
25
|
+
* database as this machine reaches it, without its password, for Studio's connection strings.
|
|
26
|
+
*/
|
|
27
|
+
export declare function nativeServerCoreEnv(input: NativeServerCoreInput): Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* The schema half of PostgREST's environment on the native path.
|
|
30
|
+
*
|
|
31
|
+
* The installed archive decides the tier: one downloaded before the masking library was bundled
|
|
32
|
+
* has no extension, so its field rules are enforced by views instead. A versioned model adds the
|
|
33
|
+
* generated `draft` schema, or `.draft()` would answer PGRST106 against a stack that had migrated
|
|
34
|
+
* the views into place.
|
|
35
|
+
*/
|
|
36
|
+
export declare function nativePostgrestSchemaEnv(cwd: string, config: SupatypeProjectConfig, pgBinDir: string | null): ReturnType<typeof postgrestSchemaEnv>;
|
|
37
|
+
/** The roles script for a new native database, with the mask extension only when the install has it. */
|
|
38
|
+
export declare function nativeDevRolesSql(pgBinDir: string | null): string;
|
|
39
|
+
//# sourceMappingURL=native-dev-env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-dev-env.d.ts","sourceRoot":"","sources":["../src/native-dev-env.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAEpF,qFAAqF;AACrF,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,6FAA6F;IAC7F,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYxF;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAKvC;AAED,wGAAwG;AACxG,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAEjE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the native Postgres install decides about the services `supatype dev` starts beside it.
|
|
3
|
+
*
|
|
4
|
+
* Kept out of the dev action so the decisions are testable. Each one is asked of the install's
|
|
5
|
+
* filesystem (see `postgres-ctl.ts`), and a wiring line dropped from a 600-line action would
|
|
6
|
+
* otherwise go unnoticed: the server would forward `/graphql/v1` to a PostgREST that cannot answer
|
|
7
|
+
* it, or PostgREST would be pointed at the wrong schemas for the tier the push will use.
|
|
8
|
+
*/
|
|
9
|
+
import { fieldMaskingTierFromProject } from "./field-masking-tier.js";
|
|
10
|
+
import { splitPassword } from "./host-database.js";
|
|
11
|
+
import { projectHasVersionedModels } from "./model-versioning.js";
|
|
12
|
+
import { nativeRolesSql } from "./native-roles-sql.js";
|
|
13
|
+
import { nativeGraphqlServerEnv, nativeMaskLibraryPresent } from "./postgres-ctl.js";
|
|
14
|
+
import { postgrestSchemaEnv } from "./project-config.js";
|
|
15
|
+
/**
|
|
16
|
+
* supatype-server's outer layer: mode, cache, manifest paths, PostgREST and GraphQL, and the
|
|
17
|
+
* database as this machine reaches it, without its password, for Studio's connection strings.
|
|
18
|
+
*/
|
|
19
|
+
export function nativeServerCoreEnv(input) {
|
|
20
|
+
return {
|
|
21
|
+
SUPATYPE_MODE: input.mode,
|
|
22
|
+
...(input.valkeyAddr ? { SUPATYPE_VALKEY_ADDR: input.valkeyAddr } : {}),
|
|
23
|
+
SUPATYPE_MANAGED_PROJECT_REF: input.projectRef,
|
|
24
|
+
SUPATYPE_MANIFEST_PATH: input.manifestPath,
|
|
25
|
+
SUPATYPE_ADMIN_CONFIG_PATH: input.adminConfigPath,
|
|
26
|
+
SUPATYPE_POSTGREST_URL: `http://127.0.0.1:${input.postgrestPort}`,
|
|
27
|
+
SUPATYPE_DB_PUBLIC_URL: splitPassword(input.databaseUrl).dsn,
|
|
28
|
+
// A clear 501 on /graphql/v1 rather than "function not found" from PostgREST.
|
|
29
|
+
...nativeGraphqlServerEnv(input.pgBinDir),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The schema half of PostgREST's environment on the native path.
|
|
34
|
+
*
|
|
35
|
+
* The installed archive decides the tier: one downloaded before the masking library was bundled
|
|
36
|
+
* has no extension, so its field rules are enforced by views instead. A versioned model adds the
|
|
37
|
+
* generated `draft` schema, or `.draft()` would answer PGRST106 against a stack that had migrated
|
|
38
|
+
* the views into place.
|
|
39
|
+
*/
|
|
40
|
+
export function nativePostgrestSchemaEnv(cwd, config, pgBinDir) {
|
|
41
|
+
return postgrestSchemaEnv(config, {
|
|
42
|
+
tier: fieldMaskingTierFromProject(cwd, config, nativeMaskLibraryPresent(pgBinDir)),
|
|
43
|
+
drafts: projectHasVersionedModels(cwd, config),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** The roles script for a new native database, with the mask extension only when the install has it. */
|
|
47
|
+
export function nativeDevRolesSql(pgBinDir) {
|
|
48
|
+
return nativeRolesSql(nativeMaskLibraryPresent(pgBinDir));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=native-dev-env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-dev-env.js","sourceRoot":"","sources":["../src/native-dev-env.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AACpF,OAAO,EAAE,kBAAkB,EAA8B,MAAM,qBAAqB,CAAA;AAgBpF;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA4B;IAC9D,OAAO;QACL,aAAa,EAAE,KAAK,CAAC,IAAI;QACzB,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,4BAA4B,EAAE,KAAK,CAAC,UAAU;QAC9C,sBAAsB,EAAE,KAAK,CAAC,YAAY;QAC1C,0BAA0B,EAAE,KAAK,CAAC,eAAe;QACjD,sBAAsB,EAAE,oBAAoB,KAAK,CAAC,aAAa,EAAE;QACjE,sBAAsB,EAAE,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG;QAC5D,8EAA8E;QAC9E,GAAG,sBAAsB,CAAC,KAAK,CAAC,QAAQ,CAAC;KAC1C,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAAW,EACX,MAA6B,EAC7B,QAAuB;IAEvB,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,2BAA2B,CAAC,GAAG,EAAE,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAClF,MAAM,EAAE,yBAAyB,CAAC,GAAG,EAAE,MAAM,CAAC;KAC/C,CAAC,CAAA;AACJ,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,iBAAiB,CAAC,QAAuB;IACvD,OAAO,cAAc,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAA;AAC3D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WatchFn } from "./dev-functions-watch.js";
|
|
2
|
+
/**
|
|
3
|
+
* Rewrite the router when the functions on disk differ from `known`. Returns the new sorted names
|
|
4
|
+
* when it rewrote, and null when nothing changed or the directory could not be read as functions.
|
|
5
|
+
*/
|
|
6
|
+
export declare function refreshNativeFunctionsRouter(cwd: string, functionsDir: string, known: readonly string[]): string[] | null;
|
|
7
|
+
/** Watch `functionsDir` and regenerate the router whenever the set of functions changes. */
|
|
8
|
+
export declare function watchNativeFunctions(cwd: string, functionsDir: string, initial: readonly string[], watch?: WatchFn): {
|
|
9
|
+
close: () => void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=native-functions-watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-functions-watch.d.ts","sourceRoot":"","sources":["../src/native-functions-watch.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAKvD;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,MAAM,EAAE,GAAG,IAAI,CAajB;AAED,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,KAAK,GAAE,OAAiB,GACvB;IAAE,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAgBvB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keep native dev's functions router listing every function, so a function added while dev runs is
|
|
3
|
+
* served.
|
|
4
|
+
*
|
|
5
|
+
* Native dev's server runs Deno with `--watch` on `.supatype/functions-router.ts`, which the CLI
|
|
6
|
+
* writes at start from the functions it finds then. Deno reloads when a listed function's file
|
|
7
|
+
* changes, but a function added afterwards is imported by nothing, so it was never served. This
|
|
8
|
+
* rewrites the router when the set of functions changes, and Deno's watch reloads it.
|
|
9
|
+
*
|
|
10
|
+
* What it cannot do: a project with no functions/ directory, or no function in it, when dev
|
|
11
|
+
* started has a server started with no Deno router at all (its environment is fixed at spawn), so
|
|
12
|
+
* the first function in such a project still needs `supatype dev` restarted.
|
|
13
|
+
*/
|
|
14
|
+
import { watch as fsWatch } from "node:fs";
|
|
15
|
+
import { errorMessage } from "./error-message.js";
|
|
16
|
+
import { discoverTsFunctionsInDir, writeDevFunctionsRouter } from "./functions-router-gen.js";
|
|
17
|
+
/** Windows fires several events per save; one rewrite covers them all. */
|
|
18
|
+
const DEBOUNCE_MS = 300;
|
|
19
|
+
/**
|
|
20
|
+
* Rewrite the router when the functions on disk differ from `known`. Returns the new sorted names
|
|
21
|
+
* when it rewrote, and null when nothing changed or the directory could not be read as functions.
|
|
22
|
+
*/
|
|
23
|
+
export function refreshNativeFunctionsRouter(cwd, functionsDir, known) {
|
|
24
|
+
let names;
|
|
25
|
+
try {
|
|
26
|
+
const routes = discoverTsFunctionsInDir(functionsDir);
|
|
27
|
+
names = routes.map((route) => route.name).sort();
|
|
28
|
+
if (names.join("\n") === [...known].sort().join("\n"))
|
|
29
|
+
return null;
|
|
30
|
+
writeDevFunctionsRouter(cwd, functionsDir, routes);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
console.warn(`[supatype] Could not regenerate the functions router: ${errorMessage(err)}`);
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
console.log(`[supatype] Functions router regenerated (${names.join(", ")}); Deno reloads it.`);
|
|
37
|
+
return names;
|
|
38
|
+
}
|
|
39
|
+
/** Watch `functionsDir` and regenerate the router whenever the set of functions changes. */
|
|
40
|
+
export function watchNativeFunctions(cwd, functionsDir, initial, watch = fsWatch) {
|
|
41
|
+
let known = [...initial];
|
|
42
|
+
let timer = null;
|
|
43
|
+
const watcher = watch(functionsDir, { recursive: true }, () => {
|
|
44
|
+
if (timer)
|
|
45
|
+
clearTimeout(timer);
|
|
46
|
+
timer = setTimeout(() => {
|
|
47
|
+
timer = null;
|
|
48
|
+
known = refreshNativeFunctionsRouter(cwd, functionsDir, known) ?? known;
|
|
49
|
+
}, DEBOUNCE_MS);
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
close: () => {
|
|
53
|
+
if (timer)
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
watcher.close();
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=native-functions-watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-functions-watch.js","sourceRoot":"","sources":["../src/native-functions-watch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,wBAAwB,EAAE,uBA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AAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,KAAK,GAAG,IAAI,CAAA;YACZ,KAAK,GAAG,4BAA4B,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,CAAC,IAAI,KAAK,CAAA;QACzE,CAAC,EAAE,WAAW,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;IACF,OAAO;QACL,KAAK,EAAE,GAAG,EAAE;YACV,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAA;YAC9B,OAAO,CAAC,KAAK,EAAE,CAAA;QACjB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SupatypeProjectConfig } from "./project-config.js";
|
|
2
|
+
/** What the native keyspace decision asks of the machine before Postgres starts. */
|
|
3
|
+
export interface NativeKeyspaceChecks {
|
|
4
|
+
libraryPresent: (pgBinDir: string | null) => boolean;
|
|
5
|
+
freePort: () => Promise<number | null>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The port native Postgres should serve RESP on, or null for the Valkey sidecar.
|
|
9
|
+
*
|
|
10
|
+
* `cache.provider: "valkey"` is honoured here, and this is the only place it could be: without
|
|
11
|
+
* asking the config, an archive that carries the library would serve RESP anyway and a project
|
|
12
|
+
* that deliberately kept the sidecar would never get it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function nativeKeyspacePort(config: SupatypeProjectConfig, pgBinDir: string | null, checks?: NativeKeyspaceChecks): Promise<number | null>;
|
|
15
|
+
/**
|
|
16
|
+
* The address the cache should talk to when Postgres serves RESP, or null for the Valkey sidecar.
|
|
17
|
+
*
|
|
18
|
+
* The probe is not ceremony: shared memory limits, a preload ordering mistake or a port taken
|
|
19
|
+
* between the check and the start all leave a Postgres that is running and a keyspace that is
|
|
20
|
+
* not, and the difference is a cache that silently never hits.
|
|
21
|
+
*/
|
|
22
|
+
export declare function nativeKeyspaceAddr(keyspacePort: number | null, respAnswers?: (port: number) => Promise<boolean>): Promise<string | null>;
|
|
23
|
+
//# sourceMappingURL=native-keyspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-keyspace.d.ts","sourceRoot":"","sources":["../src/native-keyspace.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAGhE,oFAAoF;AACpF,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAA;IACpD,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;CACvC;AAOD;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,qBAAqB,EAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,GAAE,oBAAoC,GAC3C,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUxB;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,WAAW,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAyC,GACtF,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether native `supatype dev` serves the RESP keyspace from its own Postgres, or leaves the
|
|
3
|
+
* cache to the Valkey sidecar.
|
|
4
|
+
*
|
|
5
|
+
* Two questions, asked at two moments. Before Postgres starts: does the project want the
|
|
6
|
+
* keyspace, does the archive carry the library, and is there a port for it. After it starts: does
|
|
7
|
+
* that port answer. A no to any of them is the Valkey sidecar, never an error, because a missing
|
|
8
|
+
* cache must not become a missing database.
|
|
9
|
+
*
|
|
10
|
+
* The filesystem, port and RESP checks are parameters so the decision can be tested against an
|
|
11
|
+
* archive that carries the library and one that does not, without starting anything.
|
|
12
|
+
*/
|
|
13
|
+
import { nativeKeyspaceWanted } from "./cache-provider.js";
|
|
14
|
+
import { firstFreePort, KEYSPACE_PORT_BASE, KEYSPACE_PORT_SPAN, nativeKeyspaceLibraryPresent, } from "./postgres-ctl.js";
|
|
15
|
+
import { probeTcp } from "./valkey-sidecar.js";
|
|
16
|
+
const machineChecks = {
|
|
17
|
+
libraryPresent: nativeKeyspaceLibraryPresent,
|
|
18
|
+
freePort: () => firstFreePort(KEYSPACE_PORT_BASE, KEYSPACE_PORT_SPAN),
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The port native Postgres should serve RESP on, or null for the Valkey sidecar.
|
|
22
|
+
*
|
|
23
|
+
* `cache.provider: "valkey"` is honoured here, and this is the only place it could be: without
|
|
24
|
+
* asking the config, an archive that carries the library would serve RESP anyway and a project
|
|
25
|
+
* that deliberately kept the sidecar would never get it.
|
|
26
|
+
*/
|
|
27
|
+
export async function nativeKeyspacePort(config, pgBinDir, checks = machineChecks) {
|
|
28
|
+
if (!nativeKeyspaceWanted(config) || !checks.libraryPresent(pgBinDir))
|
|
29
|
+
return null;
|
|
30
|
+
const port = await checks.freePort();
|
|
31
|
+
if (port === null) {
|
|
32
|
+
console.warn(`[supatype] ⚠ No free port in ${KEYSPACE_PORT_BASE}-${KEYSPACE_PORT_BASE + KEYSPACE_PORT_SPAN - 1} ` +
|
|
33
|
+
"for the Postgres keyspace, starting without it.");
|
|
34
|
+
}
|
|
35
|
+
return port;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The address the cache should talk to when Postgres serves RESP, or null for the Valkey sidecar.
|
|
39
|
+
*
|
|
40
|
+
* The probe is not ceremony: shared memory limits, a preload ordering mistake or a port taken
|
|
41
|
+
* between the check and the start all leave a Postgres that is running and a keyspace that is
|
|
42
|
+
* not, and the difference is a cache that silently never hits.
|
|
43
|
+
*/
|
|
44
|
+
export async function nativeKeyspaceAddr(keyspacePort, respAnswers = (port) => probeTcp("127.0.0.1", port)) {
|
|
45
|
+
if (keyspacePort === null)
|
|
46
|
+
return null;
|
|
47
|
+
if (await respAnswers(keyspacePort))
|
|
48
|
+
return `127.0.0.1:${keyspacePort}`;
|
|
49
|
+
console.warn(`[supatype] ⚠ Postgres has pg_keyspace but is not serving RESP on :${keyspacePort}. ` +
|
|
50
|
+
"See logs/postgres.log. Falling back to the Valkey sidecar.");
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=native-keyspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-keyspace.js","sourceRoot":"","sources":["../src/native-keyspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,GAC7B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAQ9C,MAAM,aAAa,GAAyB;IAC1C,cAAc,EAAE,4BAA4B;IAC5C,QAAQ,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;CACtE,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAA6B,EAC7B,QAAuB,EACvB,SAA+B,aAAa;IAE5C,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAA;IAClF,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;IACpC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,CACV,iCAAiC,kBAAkB,IAAI,kBAAkB,GAAG,kBAAkB,GAAG,CAAC,GAAG;YACnG,iDAAiD,CACpD,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,YAA2B,EAC3B,cAAkD,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;IAEvF,IAAI,YAAY,KAAK,IAAI;QAAE,OAAO,IAAI,CAAA;IACtC,IAAI,MAAM,WAAW,CAAC,YAAY,CAAC;QAAE,OAAO,aAAa,YAAY,EAAE,CAAA;IACvE,OAAO,CAAC,IAAI,CACV,sEAAsE,YAAY,IAAI;QACpF,4DAA4D,CAC/D,CAAA;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Password authentication for the native Postgres `supatype dev` runs.
|
|
3
|
+
*
|
|
4
|
+
* Clusters used to be initialised with `--auth trust`, so the passwords the CLI generates were
|
|
5
|
+
* never checked: any local process could connect as any role, the superuser included, with any
|
|
6
|
+
* password or none. New clusters are initialised with scram-sha-256 (postgres-ctl `initdb`).
|
|
7
|
+
* A cluster made before that is converted the first time `dev` or `supatype pg start` starts it:
|
|
8
|
+
* the superuser is given the project's password while trust still lets the CLI in, and then
|
|
9
|
+
* pg_hba.conf stops trusting anyone.
|
|
10
|
+
*/
|
|
11
|
+
import { type PgOptions } from "./postgres-ctl.js";
|
|
12
|
+
/**
|
|
13
|
+
* pg_hba.conf with every entry that grants `trust` switched to scram-sha-256, or null when none
|
|
14
|
+
* does. Comments and every other entry are kept as they are.
|
|
15
|
+
*/
|
|
16
|
+
export declare function hbaWithoutTrust(text: string): string | null;
|
|
17
|
+
/** True when the cluster's pg_hba.conf lets any connection in without a password. */
|
|
18
|
+
export declare function clusterGrantsTrust(dataDir: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* True when `.env` has no POSTGRES_PASSWORD but the data directory holds a cluster that checks
|
|
21
|
+
* passwords. That cluster's superuser still has the password `.env` used to carry; generating a
|
|
22
|
+
* new one, as a missing key otherwise does, only moves the failure to the first connection, where
|
|
23
|
+
* it reads as a bare "password authentication failed".
|
|
24
|
+
*
|
|
25
|
+
* A cluster that still trusts is fine: its next start gives the superuser the new password.
|
|
26
|
+
*/
|
|
27
|
+
export declare function superuserPasswordMissing(cwd: string, dataDir: string): boolean;
|
|
28
|
+
/** What to say when the superuser's password is missing from `.env`, or refused by the cluster. */
|
|
29
|
+
export declare function superuserPasswordMissingMessage(dataDir: string): {
|
|
30
|
+
title: string;
|
|
31
|
+
hints: string[];
|
|
32
|
+
};
|
|
33
|
+
/** Stop with {@link superuserPasswordMissingMessage} when the password is missing; otherwise do nothing. */
|
|
34
|
+
export declare function requireSuperuserPassword(cwd: string, dataDir: string): void;
|
|
35
|
+
/** True when a client's error output is Postgres refusing its password. */
|
|
36
|
+
export declare function isPasswordRejected(stderr: string): boolean;
|
|
37
|
+
/** The environment for a client of the native cluster, as `user` with `password`. */
|
|
38
|
+
export declare function pgClientEnv(pgBinDir: string, password: string): NodeJS.ProcessEnv;
|
|
39
|
+
/**
|
|
40
|
+
* Make a running cluster check passwords, if it does not yet. Returns true when it converted one.
|
|
41
|
+
*
|
|
42
|
+
* The superuser gets `superuserPassword` first, through the trust that is about to go, so the
|
|
43
|
+
* CLI can still connect afterwards. Then pg_hba.conf is rewritten and the server reloads it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function requirePasswordAuth(opts: PgOptions, superuserPassword: string): boolean;
|
|
46
|
+
//# sourceMappingURL=native-pg-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-pg-auth.d.ts","sourceRoot":"","sources":["../src/native-pg-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EAAiD,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AASjG;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS3D;AAED,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAG3D;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAG9E;AAED,mGAAmG;AACnG,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAUnG;AAED,4GAA4G;AAC5G,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI3E;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,qFAAqF;AACrF,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAOvF"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Password authentication for the native Postgres `supatype dev` runs.
|
|
3
|
+
*
|
|
4
|
+
* Clusters used to be initialised with `--auth trust`, so the passwords the CLI generates were
|
|
5
|
+
* never checked: any local process could connect as any role, the superuser included, with any
|
|
6
|
+
* password or none. New clusters are initialised with scram-sha-256 (postgres-ctl `initdb`).
|
|
7
|
+
* A cluster made before that is converted the first time `dev` or `supatype pg start` starts it:
|
|
8
|
+
* the superuser is given the project's password while trust still lets the CLI in, and then
|
|
9
|
+
* pg_hba.conf stops trusting anyone.
|
|
10
|
+
*/
|
|
11
|
+
import { spawnSync } from "node:child_process";
|
|
12
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { NATIVE_AUTH_METHOD, pgBin, pgSpawnEnv, reload } from "./postgres-ctl.js";
|
|
15
|
+
import { hasEnvValue } from "./env-file.js";
|
|
16
|
+
import { fatalError } from "./ui/fatal.js";
|
|
17
|
+
const SUPERUSER_PASSWORD_ENV = "SUPATYPE_SUPERUSER_PASSWORD";
|
|
18
|
+
/** The `.env` key holding the native superuser's password. */
|
|
19
|
+
const SUPERUSER_PASSWORD_KEY = "POSTGRES_PASSWORD";
|
|
20
|
+
/**
|
|
21
|
+
* pg_hba.conf with every entry that grants `trust` switched to scram-sha-256, or null when none
|
|
22
|
+
* does. Comments and every other entry are kept as they are.
|
|
23
|
+
*/
|
|
24
|
+
export function hbaWithoutTrust(text) {
|
|
25
|
+
let changed = false;
|
|
26
|
+
const lines = text.split("\n").map((line) => {
|
|
27
|
+
if (line.trimStart().startsWith("#"))
|
|
28
|
+
return line;
|
|
29
|
+
const rewritten = line.replace(/(\s)trust(\s*)$/, `$1${NATIVE_AUTH_METHOD}$2`);
|
|
30
|
+
if (rewritten !== line)
|
|
31
|
+
changed = true;
|
|
32
|
+
return rewritten;
|
|
33
|
+
});
|
|
34
|
+
return changed ? lines.join("\n") : null;
|
|
35
|
+
}
|
|
36
|
+
/** True when the cluster's pg_hba.conf lets any connection in without a password. */
|
|
37
|
+
export function clusterGrantsTrust(dataDir) {
|
|
38
|
+
const hba = join(dataDir, "pg_hba.conf");
|
|
39
|
+
return existsSync(hba) && hbaWithoutTrust(readFileSync(hba, "utf8")) !== null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* True when `.env` has no POSTGRES_PASSWORD but the data directory holds a cluster that checks
|
|
43
|
+
* passwords. That cluster's superuser still has the password `.env` used to carry; generating a
|
|
44
|
+
* new one, as a missing key otherwise does, only moves the failure to the first connection, where
|
|
45
|
+
* it reads as a bare "password authentication failed".
|
|
46
|
+
*
|
|
47
|
+
* A cluster that still trusts is fine: its next start gives the superuser the new password.
|
|
48
|
+
*/
|
|
49
|
+
export function superuserPasswordMissing(cwd, dataDir) {
|
|
50
|
+
if (hasEnvValue(cwd, SUPERUSER_PASSWORD_KEY))
|
|
51
|
+
return false;
|
|
52
|
+
return existsSync(join(dataDir, "PG_VERSION")) && !clusterGrantsTrust(dataDir);
|
|
53
|
+
}
|
|
54
|
+
/** What to say when the superuser's password is missing from `.env`, or refused by the cluster. */
|
|
55
|
+
export function superuserPasswordMissingMessage(dataDir) {
|
|
56
|
+
return {
|
|
57
|
+
title: `The Postgres data directory ${dataDir} checks the superuser's password, ` +
|
|
58
|
+
`and .env has no ${SUPERUSER_PASSWORD_KEY} it accepts.`,
|
|
59
|
+
hints: [
|
|
60
|
+
`Restore ${SUPERUSER_PASSWORD_KEY} in .env to the value this data directory was created with.`,
|
|
61
|
+
"Or start over with an empty database: `supatype pg reset` deletes the data directory and creates a new one with a new password.",
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** Stop with {@link superuserPasswordMissingMessage} when the password is missing; otherwise do nothing. */
|
|
66
|
+
export function requireSuperuserPassword(cwd, dataDir) {
|
|
67
|
+
if (!superuserPasswordMissing(cwd, dataDir))
|
|
68
|
+
return;
|
|
69
|
+
const { title, hints } = superuserPasswordMissingMessage(dataDir);
|
|
70
|
+
fatalError(title, hints);
|
|
71
|
+
}
|
|
72
|
+
/** True when a client's error output is Postgres refusing its password. */
|
|
73
|
+
export function isPasswordRejected(stderr) {
|
|
74
|
+
return /password authentication failed/i.test(stderr);
|
|
75
|
+
}
|
|
76
|
+
/** The environment for a client of the native cluster, as `user` with `password`. */
|
|
77
|
+
export function pgClientEnv(pgBinDir, password) {
|
|
78
|
+
return { ...pgSpawnEnv(pgBinDir), PGPASSWORD: password };
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Make a running cluster check passwords, if it does not yet. Returns true when it converted one.
|
|
82
|
+
*
|
|
83
|
+
* The superuser gets `superuserPassword` first, through the trust that is about to go, so the
|
|
84
|
+
* CLI can still connect afterwards. Then pg_hba.conf is rewritten and the server reloads it.
|
|
85
|
+
*/
|
|
86
|
+
export function requirePasswordAuth(opts, superuserPassword) {
|
|
87
|
+
if (!clusterGrantsTrust(opts.dataDir))
|
|
88
|
+
return false;
|
|
89
|
+
setSuperuserPassword(opts, superuserPassword);
|
|
90
|
+
const hbaPath = join(opts.dataDir, "pg_hba.conf");
|
|
91
|
+
writeFileSync(hbaPath, hbaWithoutTrust(readFileSync(hbaPath, "utf8")) ?? "", "utf8");
|
|
92
|
+
reload(opts);
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
function setSuperuserPassword(opts, password) {
|
|
96
|
+
// Through psql's environment, never its arguments, so the password is not on a command line.
|
|
97
|
+
const sql = `\\getenv pw ${SUPERUSER_PASSWORD_ENV}\nALTER ROLE postgres PASSWORD :'pw';\n`;
|
|
98
|
+
const result = spawnSync(pgBin(opts.pgBinDir, "psql"), ["-h", "127.0.0.1", "-p", String(opts.port), "-U", "postgres", "-d", "postgres", "-X", "-q", "-v", "ON_ERROR_STOP=1", "-f", "-"], {
|
|
99
|
+
input: sql,
|
|
100
|
+
encoding: "utf8",
|
|
101
|
+
env: { ...pgSpawnEnv(opts.pgBinDir), [SUPERUSER_PASSWORD_ENV]: password },
|
|
102
|
+
});
|
|
103
|
+
if (result.status !== 0) {
|
|
104
|
+
throw new Error(`Could not set the superuser's password: ${(result.stderr ?? "").trim()}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=native-pg-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-pg-auth.js","sourceRoot":"","sources":["../src/native-pg-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,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,CAAA;IACjD,aAAa,CAAC,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAA;IACpF,MAAM,CAAC,IAAI,CAAC,CAAA;IACZ,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAe,EAAE,QAAgB;IAC7D,6FAA6F;IAC7F,MAAM,GAAG,GAAG,eAAe,sBAAsB,yCAAyC,CAAA;IAC1F,MAAM,MAAM,GAAG,SAAS,CACtB,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,EAC5B,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,CAAC,EAChI;QACE,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,MAAM;QAChB,GAAG,EAAE,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,sBAAsB,CAAC,EAAE,QAAQ,EAAE;KAC1E,CACF,CAAA;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IAC5F,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ProcessManager } from "./process-manager.js";
|
|
2
|
+
import type { SupatypeProjectConfig } from "./project-config.js";
|
|
3
|
+
import { type RealtimeLaunchSpec } from "./realtime-launch.js";
|
|
4
|
+
export interface NativeRealtimeOptions {
|
|
5
|
+
config: SupatypeProjectConfig;
|
|
6
|
+
cwd: string;
|
|
7
|
+
manifestPath: string;
|
|
8
|
+
pidDir: string;
|
|
9
|
+
/** Where realtime listens, as the gateway reaches it. */
|
|
10
|
+
url: string;
|
|
11
|
+
port: string;
|
|
12
|
+
databaseUrl: string;
|
|
13
|
+
jwtSecret: string;
|
|
14
|
+
}
|
|
15
|
+
type ResolveLaunch = (config: SupatypeProjectConfig, cwd: string) => Promise<RealtimeLaunchSpec>;
|
|
16
|
+
/**
|
|
17
|
+
* Start realtime for native dev, and record in the route manifest whether it is running.
|
|
18
|
+
*
|
|
19
|
+
* The manifest is what the gateway routes /realtime/v1 by. Enabled with nothing listening, it
|
|
20
|
+
* proxies every subscription to a dead port and answers a bare 502, and its /health reports the
|
|
21
|
+
* whole stack not ready. Disabled, it answers "realtime disabled" and health leaves realtime out.
|
|
22
|
+
* `realtime_url` is dropped too, so a URL from an earlier run is not left pointing at nothing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function startNativeRealtime(opts: NativeRealtimeOptions, resolveLaunch?: ResolveLaunch): Promise<ProcessManager | null>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=native-realtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-realtime.d.ts","sourceRoot":"","sources":["../src/native-realtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAGrF,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,qBAAqB,CAAA;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,yDAAyD;IACzD,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,KAAK,aAAa,GAAG,CAAC,MAAM,EAAE,qBAAqB,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAA;AAmBhG;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,qBAAqB,EAC3B,aAAa,GAAE,aAAqC,GACnD,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAchC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ProcessManager } from "./process-manager.js";
|
|
2
|
+
import { errorMessage } from "./error-message.js";
|
|
3
|
+
import { resolveRealtimeLaunch } from "./realtime-launch.js";
|
|
4
|
+
import { patchRouteManifest } from "./route-manifest.js";
|
|
5
|
+
function spawnRealtime(launch, opts) {
|
|
6
|
+
const proc = new ProcessManager(launch.bin, launch.args, {
|
|
7
|
+
label: "realtime",
|
|
8
|
+
pidDir: opts.pidDir,
|
|
9
|
+
colour: "\x1b[35m",
|
|
10
|
+
env: {
|
|
11
|
+
DATABASE_URL: opts.databaseUrl,
|
|
12
|
+
JWT_SECRET: opts.jwtSecret,
|
|
13
|
+
PORT: opts.port,
|
|
14
|
+
SLOT_NAME: "supatype_realtime",
|
|
15
|
+
PUBLICATION_NAME: "supatype_realtime",
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
proc.start();
|
|
19
|
+
return proc;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Start realtime for native dev, and record in the route manifest whether it is running.
|
|
23
|
+
*
|
|
24
|
+
* The manifest is what the gateway routes /realtime/v1 by. Enabled with nothing listening, it
|
|
25
|
+
* proxies every subscription to a dead port and answers a bare 502, and its /health reports the
|
|
26
|
+
* whole stack not ready. Disabled, it answers "realtime disabled" and health leaves realtime out.
|
|
27
|
+
* `realtime_url` is dropped too, so a URL from an earlier run is not left pointing at nothing.
|
|
28
|
+
*/
|
|
29
|
+
export async function startNativeRealtime(opts, resolveLaunch = resolveRealtimeLaunch) {
|
|
30
|
+
try {
|
|
31
|
+
const proc = spawnRealtime(await resolveLaunch(opts.config, opts.cwd), opts);
|
|
32
|
+
patchRouteManifest(opts.manifestPath, { realtime_enabled: true, realtime_url: opts.url });
|
|
33
|
+
console.log(`[supatype] Realtime service: ${opts.url}`);
|
|
34
|
+
return proc;
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
patchRouteManifest(opts.manifestPath, { realtime_enabled: false, realtime_url: undefined });
|
|
38
|
+
console.warn("[supatype] ⚠ Realtime unavailable, so the gateway will answer realtime requests with " +
|
|
39
|
+
`"realtime disabled" and WebSocket subscriptions will not work.\n ${errorMessage(err)}`);
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=native-realtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-realtime.js","sourceRoot":"","sources":["../src/native-realtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,qBAAqB,EAA2B,MAAM,sBAAsB,CAAA;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAgBxD,SAAS,aAAa,CAAC,MAA0B,EAAE,IAA2B;IAC5E,MAAM,IAAI,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE;QACvD,KAAK,EAAE,UAAU;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,MAAM,EAAE,UAAU;QAClB,GAAG,EAAE;YACH,YAAY,EAAE,IAAI,CAAC,WAAW;YAC9B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,mBAAmB;YAC9B,gBAAgB,EAAE,mBAAmB;SAC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