@supatype/cli 0.3.6 → 0.8.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 +432 -0
- package/bin/supatype.js +25 -4
- package/deno.d.ts +11 -0
- package/dist/admin-prompt-state.d.ts +13 -0
- package/dist/admin-prompt-state.d.ts.map +1 -0
- package/dist/admin-prompt-state.js +30 -0
- package/dist/admin-prompt-state.js.map +1 -0
- package/dist/adopt-columns.d.ts +157 -0
- package/dist/adopt-columns.d.ts.map +1 -0
- package/dist/adopt-columns.js +785 -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/app-config.d.ts +1 -1
- package/dist/app-config.d.ts.map +1 -1
- package/dist/app-config.js +103 -144
- package/dist/app-config.js.map +1 -1
- package/dist/applied-ast-artifacts.d.ts +16 -0
- package/dist/applied-ast-artifacts.d.ts.map +1 -0
- package/dist/applied-ast-artifacts.js +37 -0
- package/dist/applied-ast-artifacts.js.map +1 -0
- package/dist/archive-extract.d.ts +3 -0
- package/dist/archive-extract.d.ts.map +1 -0
- package/dist/archive-extract.js +19 -0
- package/dist/archive-extract.js.map +1 -0
- package/dist/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 +34 -8
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +253 -115
- package/dist/binary-cache.js.map +1 -1
- package/dist/binary-download-lock.d.ts.map +1 -1
- package/dist/binary-download-lock.js +14 -13
- 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 +61 -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-pins.d.ts.map +1 -1
- package/dist/cache-pins.js +2 -2
- package/dist/cache-pins.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 +6 -0
- package/dist/cloud-credentials.d.ts.map +1 -1
- package/dist/cloud-credentials.js +45 -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 +174 -148
- 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 +31 -11
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +7 -5
- 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 +49 -27
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/db.d.ts.map +1 -1
- package/dist/commands/db.js +122 -110
- 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 +67 -19
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +54 -2
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +582 -469
- 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 +30 -0
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +530 -545
- 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 +25 -22
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/hooks.js +26 -11
- package/dist/commands/hooks.js.map +1 -1
- package/dist/commands/init.d.ts +33 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +330 -213
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/internal.d.ts.map +1 -1
- package/dist/commands/internal.js +5 -3
- package/dist/commands/internal.js.map +1 -1
- package/dist/commands/keys.d.ts +36 -10
- package/dist/commands/keys.d.ts.map +1 -1
- package/dist/commands/keys.js +168 -128
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/link-helpers.d.ts.map +1 -1
- package/dist/commands/link-helpers.js +46 -17
- 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/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +5 -4
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/migrate.d.ts +43 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +99 -48
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/pg.d.ts.map +1 -1
- package/dist/commands/pg.js +26 -23
- package/dist/commands/pg.js.map +1 -1
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +53 -34
- 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 +60 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +411 -131
- 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 +47 -0
- package/dist/commands/seed.d.ts.map +1 -1
- package/dist/commands/seed.js +123 -36
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/self-host.d.ts.map +1 -1
- package/dist/commands/self-host.js +136 -38
- 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 +21 -17
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js +10 -11
- package/dist/commands/types.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +213 -98
- package/dist/commands/update.js.map +1 -1
- package/dist/component-launch.d.ts +11 -0
- package/dist/component-launch.d.ts.map +1 -0
- package/dist/component-launch.js +35 -0
- package/dist/component-launch.js.map +1 -0
- package/dist/components.d.ts +7 -2
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +7 -2
- package/dist/components.js.map +1 -1
- package/dist/compose-db-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 +109 -0
- package/dist/compose-db-roles.js.map +1 -0
- package/dist/compose-engine-run.d.ts +28 -0
- package/dist/compose-engine-run.d.ts.map +1 -0
- package/dist/compose-engine-run.js +68 -0
- package/dist/compose-engine-run.js.map +1 -0
- package/dist/compose-engine-service.d.ts +10 -0
- package/dist/compose-engine-service.d.ts.map +1 -0
- package/dist/compose-engine-service.js +16 -0
- package/dist/compose-engine-service.js.map +1 -0
- package/dist/compose-host-path.d.ts +14 -0
- package/dist/compose-host-path.d.ts.map +1 -0
- package/dist/compose-host-path.js +18 -0
- package/dist/compose-host-path.js.map +1 -0
- package/dist/compose-image-pull.d.ts +43 -0
- package/dist/compose-image-pull.d.ts.map +1 -0
- package/dist/compose-image-pull.js +27 -0
- package/dist/compose-image-pull.js.map +1 -0
- package/dist/compose-kong.d.ts +31 -0
- package/dist/compose-kong.d.ts.map +1 -0
- package/dist/compose-kong.js +149 -0
- package/dist/compose-kong.js.map +1 -0
- package/dist/compose-local-server-image.d.ts.map +1 -1
- package/dist/compose-local-server-image.js +7 -3
- package/dist/compose-local-server-image.js.map +1 -1
- package/dist/compose-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 +73 -0
- package/dist/compose-render-mode.js.map +1 -0
- package/dist/compose-services.d.ts +12 -2
- package/dist/compose-services.d.ts.map +1 -1
- package/dist/compose-services.js +29 -13
- package/dist/compose-services.js.map +1 -1
- package/dist/config-snapshot.d.ts +6 -0
- package/dist/config-snapshot.d.ts.map +1 -0
- package/dist/config-snapshot.js +23 -0
- package/dist/config-snapshot.js.map +1 -0
- package/dist/config.d.ts +20 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +52 -13
- package/dist/config.js.map +1 -1
- package/dist/database-url-owner.d.ts +57 -0
- package/dist/database-url-owner.d.ts.map +1 -0
- package/dist/database-url-owner.js +130 -0
- package/dist/database-url-owner.js.map +1 -0
- package/dist/db-port-offer.d.ts +18 -0
- package/dist/db-port-offer.d.ts.map +1 -0
- package/dist/db-port-offer.js +68 -0
- package/dist/db-port-offer.js.map +1 -0
- package/dist/db-port.d.ts +87 -21
- package/dist/db-port.d.ts.map +1 -1
- package/dist/db-port.js +90 -48
- package/dist/db-port.js.map +1 -1
- package/dist/db-preflight.d.ts +30 -8
- package/dist/db-preflight.d.ts.map +1 -1
- package/dist/db-preflight.js +103 -46
- package/dist/db-preflight.js.map +1 -1
- package/dist/db-rows.d.ts +31 -0
- package/dist/db-rows.d.ts.map +1 -0
- package/dist/db-rows.js +47 -0
- package/dist/db-rows.js.map +1 -0
- package/dist/debounce.d.ts +11 -0
- package/dist/debounce.d.ts.map +1 -0
- package/dist/debounce.js +23 -0
- package/dist/debounce.js.map +1 -0
- package/dist/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 +36 -0
- package/dist/dev-api-keys.d.ts.map +1 -0
- package/dist/dev-api-keys.js +68 -0
- package/dist/dev-api-keys.js.map +1 -0
- package/dist/dev-compose.d.ts +96 -26
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +739 -620
- 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 +22 -0
- package/dist/dev-db-ready.js.map +1 -0
- package/dist/dev-db-reset.d.ts.map +1 -1
- package/dist/dev-db-reset.js +5 -4
- package/dist/dev-db-reset.js.map +1 -1
- package/dist/dev-functions-watch.d.ts +24 -0
- package/dist/dev-functions-watch.d.ts.map +1 -0
- package/dist/dev-functions-watch.js +71 -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 +73 -6
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +185 -54
- 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 +44 -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 +87 -13
- package/dist/dev-session-lock.js.map +1 -1
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +3 -0
- package/dist/dev-session.js.map +1 -1
- package/dist/dev-shutdown.d.ts +62 -3
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +251 -32
- 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-address-pool.d.ts +23 -0
- package/dist/docker-address-pool.d.ts.map +1 -0
- package/dist/docker-address-pool.js +56 -0
- package/dist/docker-address-pool.js.map +1 -0
- package/dist/docker-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-exec.d.ts +92 -0
- package/dist/docker-exec.d.ts.map +1 -0
- package/dist/docker-exec.js +139 -0
- package/dist/docker-exec.js.map +1 -0
- package/dist/docker-postgres.d.ts +1 -6
- package/dist/docker-postgres.d.ts.map +1 -1
- package/dist/docker-postgres.js +75 -88
- package/dist/docker-postgres.js.map +1 -1
- package/dist/docker-runtime.d.ts +12 -1
- package/dist/docker-runtime.d.ts.map +1 -1
- package/dist/docker-runtime.js +48 -23
- package/dist/docker-runtime.js.map +1 -1
- package/dist/dotenv-parse.d.ts +22 -0
- package/dist/dotenv-parse.d.ts.map +1 -0
- package/dist/dotenv-parse.js +63 -0
- package/dist/dotenv-parse.js.map +1 -0
- package/dist/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 +49 -0
- package/dist/engine-answers.d.ts.map +1 -0
- package/dist/engine-answers.js +184 -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 +313 -129
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-floor.d.ts +39 -0
- package/dist/engine-floor.d.ts.map +1 -1
- package/dist/engine-floor.js +84 -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 +89 -0
- package/dist/engine-ownership-gate.d.ts.map +1 -0
- package/dist/engine-ownership-gate.js +238 -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/ensure-binary.d.ts +9 -0
- package/dist/ensure-binary.d.ts.map +1 -1
- package/dist/ensure-binary.js +38 -5
- package/dist/ensure-binary.js.map +1 -1
- package/dist/ensure-component-binaries.d.ts.map +1 -1
- package/dist/ensure-component-binaries.js +2 -1
- package/dist/ensure-component-binaries.js.map +1 -1
- package/dist/env-file.d.ts +41 -8
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +123 -57
- package/dist/env-file.js.map +1 -1
- package/dist/env-lines.d.ts +11 -0
- package/dist/env-lines.d.ts.map +1 -0
- package/dist/env-lines.js +36 -0
- package/dist/env-lines.js.map +1 -0
- package/dist/error-message.d.ts +38 -0
- package/dist/error-message.d.ts.map +1 -0
- package/dist/error-message.js +111 -0
- package/dist/error-message.js.map +1 -0
- package/dist/fetch-within.d.ts +10 -0
- package/dist/fetch-within.d.ts.map +1 -0
- package/dist/fetch-within.js +12 -0
- package/dist/fetch-within.js.map +1 -0
- package/dist/field-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 +38 -13
- package/dist/field-masking-tier.js.map +1 -1
- package/dist/functions-context-refresh.d.ts +6 -2
- package/dist/functions-context-refresh.d.ts.map +1 -1
- package/dist/functions-context-refresh.js +11 -3
- package/dist/functions-context-refresh.js.map +1 -1
- package/dist/functions-deno-types.d.ts +8 -8
- package/dist/functions-deno-types.d.ts.map +1 -1
- package/dist/functions-deno-types.js +61 -26
- package/dist/functions-deno-types.js.map +1 -1
- package/dist/functions-discovery.d.ts +31 -0
- package/dist/functions-discovery.d.ts.map +1 -0
- package/dist/functions-discovery.js +87 -0
- package/dist/functions-discovery.js.map +1 -0
- package/dist/functions-template.d.ts +10 -0
- package/dist/functions-template.d.ts.map +1 -0
- package/dist/functions-template.js +47 -0
- package/dist/functions-template.js.map +1 -0
- package/dist/functions-worker-files.d.ts +55 -0
- package/dist/functions-worker-files.d.ts.map +1 -0
- package/dist/functions-worker-files.js +149 -0
- package/dist/functions-worker-files.js.map +1 -0
- package/dist/generated/functions-worker-source.d.ts +2 -0
- package/dist/generated/functions-worker-source.d.ts.map +1 -0
- package/dist/generated/functions-worker-source.js +12 -0
- package/dist/generated/functions-worker-source.js.map +1 -0
- package/dist/generated/release-images.d.ts +18 -0
- package/dist/generated/release-images.d.ts.map +1 -0
- package/dist/generated/release-images.js +8 -0
- package/dist/generated/release-images.js.map +1 -0
- package/dist/generated-files-engine.d.ts +33 -0
- package/dist/generated-files-engine.d.ts.map +1 -0
- package/dist/generated-files-engine.js +45 -0
- package/dist/generated-files-engine.js.map +1 -0
- package/dist/hook-upload.d.ts +29 -15
- package/dist/hook-upload.d.ts.map +1 -1
- package/dist/hook-upload.js +88 -59
- package/dist/hook-upload.js.map +1 -1
- package/dist/hooks-generator.d.ts +5 -0
- package/dist/hooks-generator.d.ts.map +1 -1
- package/dist/hooks-generator.js +117 -85
- 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 +102 -18
- 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 +3 -1
- package/dist/init-dependency-versions.d.ts.map +1 -1
- package/dist/init-dependency-versions.js +30 -7
- package/dist/init-dependency-versions.js.map +1 -1
- package/dist/init-example.d.ts +48 -0
- package/dist/init-example.d.ts.map +1 -0
- package/dist/init-example.js +110 -0
- package/dist/init-example.js.map +1 -0
- package/dist/init-package-json.d.ts.map +1 -1
- package/dist/init-package-json.js +2 -0
- package/dist/init-package-json.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/init-setup-steps.d.ts +37 -0
- package/dist/init-setup-steps.d.ts.map +1 -0
- package/dist/init-setup-steps.js +118 -0
- package/dist/init-setup-steps.js.map +1 -0
- package/dist/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 +14 -0
- package/dist/jwt-secret-length.d.ts.map +1 -0
- package/dist/jwt-secret-length.js +21 -0
- package/dist/jwt-secret-length.js.map +1 -0
- package/dist/jwt-secret-rules.d.ts +24 -0
- package/dist/jwt-secret-rules.d.ts.map +1 -0
- package/dist/jwt-secret-rules.js +46 -0
- package/dist/jwt-secret-rules.js.map +1 -0
- package/dist/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 +10 -4
- package/dist/local-gateway.d.ts.map +1 -1
- package/dist/local-gateway.js +19 -5
- package/dist/local-gateway.js.map +1 -1
- package/dist/local-secrets.d.ts +176 -10
- package/dist/local-secrets.d.ts.map +1 -1
- package/dist/local-secrets.js +261 -16
- 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 +76 -0
- package/dist/local-stack.js.map +1 -0
- package/dist/local-storage.d.ts +7 -2
- package/dist/local-storage.d.ts.map +1 -1
- package/dist/local-storage.js +11 -3
- package/dist/local-storage.js.map +1 -1
- package/dist/mailer-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/mailer-env.d.ts +37 -0
- package/dist/mailer-env.d.ts.map +1 -0
- package/dist/mailer-env.js +98 -0
- package/dist/mailer-env.js.map +1 -0
- package/dist/model-cache.d.ts +10 -10
- 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 +24 -13
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +133 -175
- 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 +75 -0
- package/dist/native-dev-env.d.ts.map +1 -0
- package/dist/native-dev-env.js +112 -0
- package/dist/native-dev-env.js.map +1 -0
- package/dist/native-functions-watch.d.ts +62 -0
- package/dist/native-functions-watch.d.ts.map +1 -0
- package/dist/native-functions-watch.js +140 -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 +34 -0
- package/dist/native-realtime.d.ts.map +1 -0
- package/dist/native-realtime.js +195 -0
- package/dist/native-realtime.js.map +1 -0
- package/dist/native-roles-sql.d.ts +41 -0
- package/dist/native-roles-sql.d.ts.map +1 -0
- package/dist/native-roles-sql.js +154 -0
- package/dist/native-roles-sql.js.map +1 -0
- package/dist/native-storage-import.d.ts +19 -0
- package/dist/native-storage-import.d.ts.map +1 -0
- package/dist/native-storage-import.js +327 -0
- package/dist/native-storage-import.js.map +1 -0
- package/dist/native-storage.d.ts +45 -0
- package/dist/native-storage.d.ts.map +1 -0
- package/dist/native-storage.js +140 -0
- package/dist/native-storage.js.map +1 -0
- package/dist/native-worker.d.ts +26 -0
- package/dist/native-worker.d.ts.map +1 -0
- package/dist/native-worker.js +63 -0
- package/dist/native-worker.js.map +1 -0
- package/dist/owner-default.d.ts +27 -0
- package/dist/owner-default.d.ts.map +1 -0
- package/dist/owner-default.js +55 -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/post-apply.d.ts +3 -0
- package/dist/post-apply.d.ts.map +1 -0
- package/dist/post-apply.js +17 -0
- package/dist/post-apply.js.map +1 -0
- package/dist/postgres-ctl.d.ts +125 -11
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +336 -53
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/postgres-image.d.ts +47 -0
- package/dist/postgres-image.d.ts.map +1 -0
- package/dist/postgres-image.js +130 -0
- package/dist/postgres-image.js.map +1 -0
- package/dist/postgrest-release.d.ts +34 -0
- package/dist/postgrest-release.d.ts.map +1 -0
- package/dist/postgrest-release.js +58 -0
- package/dist/postgrest-release.js.map +1 -0
- package/dist/process-manager.d.ts.map +1 -1
- package/dist/process-manager.js +3 -1
- package/dist/process-manager.js.map +1 -1
- package/dist/project-config.d.ts +185 -24
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +310 -116
- 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 +41 -3
- package/dist/pull-utils.d.ts.map +1 -1
- package/dist/pull-utils.js +182 -17
- 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 +276 -0
- package/dist/push-refusal.js.map +1 -0
- package/dist/realtime-launch.d.ts +2 -5
- package/dist/realtime-launch.d.ts.map +1 -1
- package/dist/realtime-launch.js +6 -23
- package/dist/realtime-launch.js.map +1 -1
- package/dist/recorded-field-masking-tier.d.ts +43 -0
- package/dist/recorded-field-masking-tier.d.ts.map +1 -0
- package/dist/recorded-field-masking-tier.js +89 -0
- package/dist/recorded-field-masking-tier.js.map +1 -0
- package/dist/release-images.d.ts +31 -0
- package/dist/release-images.d.ts.map +1 -0
- package/dist/release-images.js +90 -0
- package/dist/release-images.js.map +1 -0
- package/dist/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/required-host-components.d.ts.map +1 -1
- package/dist/required-host-components.js +4 -0
- package/dist/required-host-components.js.map +1 -1
- package/dist/resolve-api-url.d.ts +17 -3
- package/dist/resolve-api-url.d.ts.map +1 -1
- package/dist/resolve-api-url.js +72 -30
- package/dist/resolve-api-url.js.map +1 -1
- package/dist/resolve-target.d.ts +147 -26
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +279 -82
- 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 +54 -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 +25 -2
- package/dist/route-manifest.d.ts.map +1 -1
- package/dist/route-manifest.js +51 -13
- package/dist/route-manifest.js.map +1 -1
- package/dist/run-until-stopped.d.ts +12 -0
- package/dist/run-until-stopped.d.ts.map +1 -0
- package/dist/run-until-stopped.js +42 -0
- package/dist/run-until-stopped.js.map +1 -0
- package/dist/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 +37 -2
- 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 +70 -80
- package/dist/schema-push-lock.js.map +1 -1
- package/dist/schema-sources.d.ts +26 -5
- package/dist/schema-sources.d.ts.map +1 -1
- package/dist/schema-sources.js +73 -41
- package/dist/schema-sources.js.map +1 -1
- package/dist/seed-auth-connect.d.ts +14 -0
- package/dist/seed-auth-connect.d.ts.map +1 -0
- package/dist/seed-auth-connect.js +97 -0
- package/dist/seed-auth-connect.js.map +1 -0
- package/dist/seed-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 +47 -3
- package/dist/seed-runner.js.map +1 -1
- package/dist/seed.d.ts +37 -7
- 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 +83 -19
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +541 -217
- package/dist/self-host-compose.js.map +1 -1
- package/dist/service-role-key-file.d.ts +32 -0
- package/dist/service-role-key-file.d.ts.map +1 -0
- package/dist/service-role-key-file.js +90 -0
- package/dist/service-role-key-file.js.map +1 -0
- package/dist/shell-ports.d.ts +37 -0
- package/dist/shell-ports.d.ts.map +1 -0
- package/dist/shell-ports.js +67 -0
- package/dist/shell-ports.js.map +1 -0
- package/dist/stop-signals.d.ts +7 -0
- package/dist/stop-signals.d.ts.map +1 -0
- package/dist/stop-signals.js +12 -0
- package/dist/stop-signals.js.map +1 -0
- package/dist/storage-launch.d.ts +11 -0
- package/dist/storage-launch.d.ts.map +1 -0
- package/dist/storage-launch.js +41 -0
- package/dist/storage-launch.js.map +1 -0
- package/dist/storage-provision.d.ts +69 -7
- package/dist/storage-provision.d.ts.map +1 -1
- package/dist/storage-provision.js +112 -32
- 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/systemd.d.ts +1 -1
- package/dist/systemd.d.ts.map +1 -1
- package/dist/systemd.js +26 -11
- package/dist/systemd.js.map +1 -1
- package/dist/tar-reader.d.ts +29 -0
- package/dist/tar-reader.d.ts.map +1 -0
- package/dist/tar-reader.js +99 -0
- package/dist/tar-reader.js.map +1 -0
- package/dist/target-client.d.ts +27 -3
- package/dist/target-client.d.ts.map +1 -1
- package/dist/target-client.js +173 -46
- package/dist/target-client.js.map +1 -1
- package/dist/target-request.d.ts +25 -0
- package/dist/target-request.d.ts.map +1 -0
- package/dist/target-request.js +33 -0
- package/dist/target-request.js.map +1 -0
- package/dist/target-warning.d.ts +7 -0
- package/dist/target-warning.d.ts.map +1 -0
- package/dist/target-warning.js +12 -0
- package/dist/target-warning.js.map +1 -0
- package/dist/tsx-runner.d.ts +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 +8 -0
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +518 -155
- 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 +19 -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 +23 -6
- package/dist/ui/dev/DevDashboard.js.map +1 -1
- package/dist/ui/fatal.d.ts.map +1 -1
- package/dist/ui/fatal.js +6 -7
- package/dist/ui/fatal.js.map +1 -1
- package/dist/ui/flows/FlowApp.d.ts.map +1 -1
- package/dist/ui/flows/FlowApp.js +32 -1
- package/dist/ui/flows/FlowApp.js.map +1 -1
- package/dist/ui/flows/prompt-fields.d.ts +18 -0
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
- package/dist/ui/flows/prompt-fields.js +25 -5
- 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/messages.d.ts +6 -0
- package/dist/ui/messages.d.ts.map +1 -1
- package/dist/ui/messages.js +17 -0
- package/dist/ui/messages.js.map +1 -1
- package/dist/ui/progress.d.ts +7 -0
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +22 -8
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/runtime/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/command-chrome.d.ts.map +1 -1
- package/dist/ui/runtime/command-chrome.js +2 -0
- package/dist/ui/runtime/command-chrome.js.map +1 -1
- package/dist/ui/runtime/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/prompt-interrupt.d.ts +10 -0
- package/dist/ui/runtime/prompt-interrupt.d.ts.map +1 -0
- package/dist/ui/runtime/prompt-interrupt.js +24 -0
- package/dist/ui/runtime/prompt-interrupt.js.map +1 -0
- package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -1
- package/dist/ui/runtime/run-clack-flow.js +5 -2
- package/dist/ui/runtime/run-clack-flow.js.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts +14 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.js +44 -3
- package/dist/ui/runtime/stdin-after-ink.js.map +1 -1
- package/dist/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/dist/url-safe-passwords.d.ts +25 -0
- package/dist/url-safe-passwords.d.ts.map +1 -0
- package/dist/url-safe-passwords.js +70 -0
- package/dist/url-safe-passwords.js.map +1 -0
- package/dist/valkey-sidecar.d.ts +33 -6
- package/dist/valkey-sidecar.d.ts.map +1 -1
- package/dist/valkey-sidecar.js +90 -61
- package/dist/valkey-sidecar.js.map +1 -1
- package/dist/worker-module-files.d.ts +3 -0
- package/dist/worker-module-files.d.ts.map +1 -0
- package/dist/worker-module-files.js +18 -0
- package/dist/worker-module-files.js.map +1 -0
- package/package.json +20 -7
- 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/functions-router-gen.d.ts +0 -14
- package/dist/functions-router-gen.d.ts.map +0 -1
- package/dist/functions-router-gen.js +0 -231
- package/dist/functions-router-gen.js.map +0 -1
- 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/commands/dev.js
CHANGED
|
@@ -2,98 +2,143 @@
|
|
|
2
2
|
* supatype dev: start local Postgres, apply schema, run supatype-server.
|
|
3
3
|
*
|
|
4
4
|
* Runtime provider (top-level `provider` or legacy `database.provider`):
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* docker: full self-host Compose stack (Kong on SUPATYPE_KONG_PORT); see dev-compose.ts (default)
|
|
6
|
+
* native: host Postgres + host server + host engine
|
|
7
7
|
*
|
|
8
8
|
* Edge functions (when a functions/ dir exists): Deno is resolved from the CDN cache
|
|
9
9
|
* (auto-download on miss). Self-host/cloud Docker stacks use supatype-server in-container;
|
|
10
10
|
* Deno is not provisioned by the CLI on those paths.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { reportAppliedPush } from "../engine-push-output.js";
|
|
13
|
+
import { errorMessage } from "../error-message.js";
|
|
14
|
+
import { isDiffResult, isEnginePushResult } from "../engine-answers.js";
|
|
15
|
+
import { reportDevPushFailure } from "../push-refusal.js";
|
|
14
16
|
import { spawnSync } from "node:child_process";
|
|
15
|
-
import { existsSync, mkdirSync,
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
17
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
18
|
+
import { join, resolve } from "node:path";
|
|
19
|
+
import { hasEnvValue, readDotEnvFiles } from "../env-file.js";
|
|
20
|
+
import { requireUrlSafeComposePasswords } from "../url-safe-passwords.js";
|
|
21
|
+
import { loadConfig, PROJECT_CONFIG_FILES } from "../config.js";
|
|
22
|
+
import { bucketSpecsFromAst, isParsedBuckets, nativeBucketRow, provisionBuckets, withPublicFromMode, } from "../storage-provision.js";
|
|
23
|
+
import { readJsonFile } from "../json-file.js";
|
|
24
|
+
import { isArrayOf, isJsonObject } from "@supatype/shared";
|
|
25
|
+
import { pgSchema, localDSN, nativeDataDir, nativeDbPort, nativeRealtimePort, nativeDenoPort, nativeStoragePort, STORAGE_PORT_ENV, DENO_PORT_ENV, nativeStateRoot, nativeServerPort, REALTIME_PORT_ENV, resolveRuntimeProvider, schemaPathFromProject, serviceRoleRoutes, } from "../project-config.js";
|
|
26
|
+
import { DEV_DB_PORT_ENV } from "../db-port.js";
|
|
27
|
+
import { devServiceRoleRoutesPath, functionsWorkerEnv, writeServiceRoleRoutesFile } from "../functions-worker-files.js";
|
|
28
|
+
import { devServiceRoleKeyPath } from "../service-role-key-file.js";
|
|
29
|
+
import { requireUsableJwtSecret } from "../jwt-secret-length.js";
|
|
30
|
+
import { ensureNativeAuthenticatorPassword, devJwtSecret, ensureNativeSuperuserPassword, givenJwtSecret, ignoredJwtSecretWarning, secretFingerprint, } from "../local-secrets.js";
|
|
25
31
|
import { normalisePlatformPath, cachePath, currentPlatform, hasMeaningfulOverrides, describeActiveOverrides, postgresArchiveTag, } from "../binary-cache.js";
|
|
26
32
|
import { ensureBinary } from "../ensure-binary.js";
|
|
33
|
+
import { assertSupported, binaryCapabilities, EngineProbeFailed, OVERWRITE_DRIFT_NEED, OwnershipUnsupportedError, requireEngineFeatures, } from "../engine-ownership-gate.js";
|
|
27
34
|
import { startProxyDevApp } from "../app/proxy-dev-app.js";
|
|
28
35
|
import { ProcessManager } from "../process-manager.js";
|
|
36
|
+
import { markPostgrestUnpacked, POSTGREST_VERSION, postgrestArchiveName, postgrestArchiveUrl, postgrestRuntimeRepairDue, } from "../postgrest-release.js";
|
|
29
37
|
import { STUDIO_DEV_PORT, startStudioViteDevServer } from "../studio-dev-server.js";
|
|
30
38
|
import { restoreSystemRelationTargets } from "../restore-system-relation-targets.js";
|
|
31
|
-
import { localStorageEnv } from "../local-storage.js";
|
|
32
39
|
import { beginDevSession, resolveDevUiMode } from "../dev-session.js";
|
|
33
40
|
import { publishDevReady } from "../dev-ready-panel.js";
|
|
34
41
|
import { probeDockerDaemon, reportDockerUnavailable } from "../docker-runtime.js";
|
|
35
42
|
import { fatalError } from "../ui/fatal.js";
|
|
36
|
-
import { registerDevShutdown } from "../dev-shutdown.js";
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
43
|
+
import { haltIfStopping, pushStartUndo, pushStartUndoLast, registerDevShutdown, reportUnlessStopping, stopQuietlyDuringStart, waitForDevShutdown, } from "../dev-shutdown.js";
|
|
44
|
+
import { startNativeRealtime } from "../native-realtime.js";
|
|
45
|
+
import { nativeWorkerDenoEnv, prepareNativeWorker } from "../native-worker.js";
|
|
46
|
+
import { configSnapshot } from "../config-snapshot.js";
|
|
47
|
+
import { patchRouteManifest, recordNativeRoutes } from "../route-manifest.js";
|
|
48
|
+
import { reconcileNativeDevDatabaseUrl } from "../db-port-offer.js";
|
|
49
|
+
import { extractArchive } from "../archive-extract.js";
|
|
50
|
+
import { serverStorageEnv, startNativeStorage } from "../native-storage.js";
|
|
51
|
+
import { keepsObjectsLocally, serverStoreRoot } from "../local-storage.js";
|
|
52
|
+
import { writeAppliedAstArtifacts } from "../applied-ast-artifacts.js";
|
|
39
53
|
import { writeAppViteEnv } from "../app-vite-env.js";
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const out = {};
|
|
48
|
-
const host = s.host?.trim();
|
|
49
|
-
if (host)
|
|
50
|
-
out.SUPATYPE_SMTP_HOST = host;
|
|
51
|
-
if (s.port !== undefined)
|
|
52
|
-
out.SUPATYPE_SMTP_PORT = String(s.port);
|
|
53
|
-
const user = s.user?.trim();
|
|
54
|
-
if (user)
|
|
55
|
-
out.SUPATYPE_SMTP_USER = user;
|
|
56
|
-
if (s.pass !== undefined && s.pass !== "")
|
|
57
|
-
out.SUPATYPE_SMTP_PASS = s.pass;
|
|
58
|
-
const admin = s.admin_email?.trim();
|
|
59
|
-
if (admin)
|
|
60
|
-
out.SUPATYPE_SMTP_ADMIN_EMAIL = admin;
|
|
61
|
-
const sender = s.sender_name?.trim();
|
|
62
|
-
if (sender)
|
|
63
|
-
out.SUPATYPE_SMTP_SENDER_NAME = sender;
|
|
64
|
-
return out;
|
|
65
|
-
}
|
|
66
|
-
const NATIVE_PG_PORT = 5432;
|
|
67
|
-
const REALTIME_PORT = "4000";
|
|
54
|
+
import { nativeAuthProviderEnv, warnMissingAuthProviderSecrets } from "../auth-providers.js";
|
|
55
|
+
import { AUTHENTICATOR_PASSWORD_ENV } from "../native-roles-sql.js";
|
|
56
|
+
import { nativeAuthMailerEnv, nativeDevApiKeys, nativeDevRolesSql, nativePostgrestSchemaEnv, nativeServerCoreEnv, nativeServerDotEnvLayer, } from "../native-dev-env.js";
|
|
57
|
+
import { ensureValkeySidecar, externalValkey } from "../valkey-sidecar.js";
|
|
58
|
+
import { nativeKeyspaceAddr as nativeKeyspaceAddrFor, nativeKeyspacePort } from "../native-keyspace.js";
|
|
59
|
+
import { ensureCluster, createdbArgs, databaseEncoding, nonUtf8DatabaseWarning, pgBuild, start as pgStart, stop as pgStop, waitReady as pgWaitReady, isPortInUse, } from "../postgres-ctl.js";
|
|
60
|
+
import { isPasswordRejected, pgClientEnv, requirePasswordAuth, requireSuperuserPassword, superuserPasswordMissingMessage, } from "../native-pg-auth.js";
|
|
68
61
|
function portCheckCommand(port) {
|
|
69
62
|
return process.platform === "win32"
|
|
70
63
|
? `netstat -ano | findstr :${port}`
|
|
71
64
|
: `lsof -i :${port}`;
|
|
72
65
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
const NATIVE_SERVICES = ["postgres", "server", "postgrest", "realtime", "deno", "storage"];
|
|
67
|
+
export const NATIVE_PORT_HINTS = {
|
|
68
|
+
postgres: {
|
|
69
|
+
holder: "Another Postgres instance may be running.",
|
|
70
|
+
move: `Move this project's database port with ${DEV_DB_PORT_ENV} in .env, or database.port in supatype.config.ts.`,
|
|
71
|
+
},
|
|
72
|
+
server: {
|
|
73
|
+
holder: "Another supatype-server may be running.",
|
|
74
|
+
move: "Move this project's API server port with server.port in supatype.config.ts, or `supatype dev --port`.",
|
|
75
|
+
},
|
|
76
|
+
postgrest: {
|
|
77
|
+
holder: "Another service may be running.",
|
|
78
|
+
move: "Move this project's PostgREST port with server.postgrestPort in supatype.config.ts.",
|
|
79
|
+
},
|
|
80
|
+
realtime: {
|
|
81
|
+
holder: "Another realtime service, or any app on this port, may be running.",
|
|
82
|
+
move: `Move this project's realtime port with ${REALTIME_PORT_ENV} in .env, or server.realtimePort in supatype.config.ts.`,
|
|
83
|
+
},
|
|
84
|
+
deno: {
|
|
85
|
+
holder: "Another Deno process, or any app on this port, may be running.",
|
|
86
|
+
move: `Move this project's functions port with ${DENO_PORT_ENV} in .env.`,
|
|
87
|
+
},
|
|
88
|
+
storage: {
|
|
89
|
+
holder: "Another storage service, or any app on this port, may be running.",
|
|
90
|
+
move: `Move this project's storage port with ${STORAGE_PORT_ENV} in .env.`,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
/** Stop before anything starts when a port native dev binds is taken. Exported for tests. */
|
|
94
|
+
export async function assertNativeDevPortsFree(ports) {
|
|
95
|
+
for (const service of NATIVE_SERVICES) {
|
|
96
|
+
const port = ports[service];
|
|
97
|
+
if (port === undefined || !(await isPortInUse(port)))
|
|
98
|
+
continue;
|
|
99
|
+
const { holder, move } = NATIVE_PORT_HINTS[service];
|
|
100
|
+
fatalError(`Port ${port} is already in use.`, [holder, `Check: ${portCheckCommand(port)}`, move], {
|
|
101
|
+
brand: { intro: "Local development" },
|
|
102
|
+
});
|
|
77
103
|
}
|
|
78
|
-
|
|
79
|
-
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* `dev --overwrite-drift` only where the engine that will push can honour it: the compose
|
|
107
|
+
* schema-engine (or `overrides.engine`) for docker, the engine binary otherwise.
|
|
108
|
+
*/
|
|
109
|
+
async function requireDevEngineSupports(cwd, config, docker) {
|
|
110
|
+
const need = [OVERWRITE_DRIFT_NEED];
|
|
111
|
+
try {
|
|
112
|
+
if (docker) {
|
|
113
|
+
const { requireDockerFeatures } = await import("../dev-compose.js");
|
|
114
|
+
await requireDockerFeatures(cwd, config, need);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
assertSupported(binaryCapabilities(await ensureBinary("engine", config)), need);
|
|
118
|
+
}
|
|
80
119
|
}
|
|
81
|
-
|
|
82
|
-
|
|
120
|
+
catch (err) {
|
|
121
|
+
if (err instanceof OwnershipUnsupportedError || err instanceof EngineProbeFailed)
|
|
122
|
+
fatalError(err.message);
|
|
123
|
+
throw err;
|
|
83
124
|
}
|
|
84
125
|
}
|
|
85
126
|
export function registerDev(program) {
|
|
86
127
|
program
|
|
87
128
|
.command("dev")
|
|
88
129
|
.description("Start local Postgres, apply schema, and run supatype-server")
|
|
89
|
-
.option("--no-watch", "Start services but do not watch for schema changes")
|
|
130
|
+
.option("--no-watch", "Start services but do not watch for schema changes, or (Docker) for function changes")
|
|
90
131
|
.option("--stream", "Print interleaved logs instead of the interactive TUI")
|
|
91
132
|
.option("--port <port>", "Port for supatype-server (overrides config)", String)
|
|
92
133
|
.option("--reset-db", "Remove the local Postgres data volume before starting (asks first; storage is kept)")
|
|
93
134
|
.option("--yes", "Skip the --reset-db confirmation")
|
|
94
|
-
.
|
|
135
|
+
.option("--overwrite-drift", "Every push of this session puts back policies, grants, labels and RLS changed outside Supatype")
|
|
136
|
+
// Ctrl+C during the start reaches its children too: it ends with one line, not their failure.
|
|
137
|
+
.action(stopQuietlyDuringStart(async (opts) => {
|
|
95
138
|
const cwd = process.cwd();
|
|
96
139
|
// ── 1. Load project config (before TUI, fatal errors must hit real stderr) ──
|
|
140
|
+
// Its bytes first: the functions.serviceRole watch, started much later, applies any edit since.
|
|
141
|
+
const configBaseline = configSnapshot(cwd, PROJECT_CONFIG_FILES);
|
|
97
142
|
const config = loadConfig(cwd);
|
|
98
143
|
const provider = resolveRuntimeProvider(config);
|
|
99
144
|
// The native provider keeps Postgres in a data directory, not a compose volume, and has
|
|
@@ -111,11 +156,35 @@ export function registerDev(program) {
|
|
|
111
156
|
}
|
|
112
157
|
}
|
|
113
158
|
const projectName = config.project.name;
|
|
114
|
-
const serverPort = opts.port ?? String(config
|
|
159
|
+
const serverPort = opts.port ?? String(nativeServerPort(config));
|
|
115
160
|
const postgrestPort = String(config.server.postgrestPort ?? 3001);
|
|
161
|
+
const pgPort = nativeDbPort(config, cwd);
|
|
162
|
+
const realtimePort = String(nativeRealtimePort(config, cwd));
|
|
163
|
+
const denoPort = nativeDenoPort(cwd);
|
|
164
|
+
const storagePort = nativeStoragePort(cwd);
|
|
116
165
|
if (provider !== "docker") {
|
|
117
|
-
|
|
166
|
+
// The functions worker runs on every native dev (native-worker.ts), so Deno's port is checked too.
|
|
167
|
+
await assertNativeDevPortsFree({
|
|
168
|
+
postgres: pgPort,
|
|
169
|
+
server: Number(serverPort),
|
|
170
|
+
postgrest: Number(postgrestPort),
|
|
171
|
+
realtime: Number(realtimePort),
|
|
172
|
+
deno: denoPort,
|
|
173
|
+
...(keepsObjectsLocally(config) && { storage: storagePort }),
|
|
174
|
+
});
|
|
175
|
+
// Before anything is generated: a missing password would otherwise be replaced in .env
|
|
176
|
+
// with a new one the existing cluster has never heard of.
|
|
177
|
+
requireSuperuserPassword(cwd, nativeDataDir(config));
|
|
118
178
|
}
|
|
179
|
+
// Before the session takes the terminal, so a refusal reaches it.
|
|
180
|
+
const overwriteDrift = opts.overwriteDrift === true;
|
|
181
|
+
if (overwriteDrift)
|
|
182
|
+
await requireDevEngineSupports(cwd, config, provider === "docker");
|
|
183
|
+
// The compose file puts the database passwords into URLs as `${VAR}`, unencoded. Checked
|
|
184
|
+
// here, before the session takes the terminal, and only here: the watcher rewrites the compose
|
|
185
|
+
// file mid-session, where a refusal would end the session.
|
|
186
|
+
if (provider === "docker")
|
|
187
|
+
requireUrlSafeComposePasswords(cwd, config);
|
|
119
188
|
beginDevSession(resolveDevUiMode(opts.stream === true));
|
|
120
189
|
if (hasMeaningfulOverrides(config)) {
|
|
121
190
|
console.warn("[supatype] Local binary overrides active:");
|
|
@@ -124,12 +193,24 @@ export function registerDev(program) {
|
|
|
124
193
|
}
|
|
125
194
|
console.warn("");
|
|
126
195
|
}
|
|
196
|
+
// Both providers, before anything starts. A project without one gets one in .env here (the
|
|
197
|
+
// shell's when usable, else generated), which every later step signs and validates with.
|
|
198
|
+
// Compose is run without a shell JWT_SECRET that differs from it (self-host-compose.ts), so
|
|
199
|
+
// that one is only warned about, and only when .env already had a secret: one written just
|
|
200
|
+
// now was the shell's, or devJwtSecret has already said why it was not.
|
|
201
|
+
const hadJwtSecret = hasEnvValue(cwd, "JWT_SECRET");
|
|
202
|
+
const jwtSecret = devJwtSecret(cwd);
|
|
203
|
+
requireUsableJwtSecret(jwtSecret);
|
|
204
|
+
const ignored = hadJwtSecret ? ignoredJwtSecretWarning(jwtSecret, givenJwtSecret()) : undefined;
|
|
205
|
+
if (ignored !== undefined)
|
|
206
|
+
console.warn(`[supatype] ${ignored}`);
|
|
127
207
|
if (provider === "docker") {
|
|
128
208
|
const { runDevCompose } = await import("../dev-compose.js");
|
|
129
209
|
await runDevCompose(cwd, config, {
|
|
130
210
|
watch: opts.watch !== false,
|
|
131
211
|
resetDb: opts.resetDb === true,
|
|
132
212
|
yes: opts.yes === true,
|
|
213
|
+
overwriteDrift,
|
|
133
214
|
});
|
|
134
215
|
return;
|
|
135
216
|
}
|
|
@@ -140,7 +221,7 @@ export function registerDev(program) {
|
|
|
140
221
|
ensureBinary("server", config),
|
|
141
222
|
]);
|
|
142
223
|
// ── 3. Per-project state directories ─────────────────────────────────
|
|
143
|
-
const stateRoot =
|
|
224
|
+
const stateRoot = nativeStateRoot(config);
|
|
144
225
|
const pidDir = join(stateRoot, "pid");
|
|
145
226
|
const logsDir = join(stateRoot, "logs");
|
|
146
227
|
const tmpDir = join(stateRoot, "tmp");
|
|
@@ -151,13 +232,12 @@ export function registerDev(program) {
|
|
|
151
232
|
let dbURL;
|
|
152
233
|
/** What PostgREST connects as, deliberately not `dbURL`, which is a superuser. */
|
|
153
234
|
let postgrestDbURL;
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
const pgPassword = devPostgresPassword(cwd);
|
|
235
|
+
// Checked by the cluster (native-pg-auth.ts): .env's, or generated and written there.
|
|
236
|
+
const pgPassword = ensureNativeSuperuserPassword(cwd);
|
|
157
237
|
// Distinct from pgPassword even locally, so the split the other paths enforce is the
|
|
158
238
|
// one developers see. Read from .env when present so it matches a stack the user has
|
|
159
|
-
// already provisioned.
|
|
160
|
-
const authenticatorPassword =
|
|
239
|
+
// already provisioned, generated otherwise.
|
|
240
|
+
const authenticatorPassword = ensureNativeAuthenticatorPassword(cwd);
|
|
161
241
|
// pgBinDir is set on the native path and used to add DLL search path for
|
|
162
242
|
// PostgREST on Windows (PostgREST links against libpq + SSL from MinGW).
|
|
163
243
|
let pgBinDir = null;
|
|
@@ -167,60 +247,47 @@ export function registerDev(program) {
|
|
|
167
247
|
{
|
|
168
248
|
// native: resolve pg bin dir and manage with pg_ctl
|
|
169
249
|
pgBinDir = await resolvePgBinDir(config);
|
|
170
|
-
const dataDir = config
|
|
250
|
+
const dataDir = nativeDataDir(config);
|
|
171
251
|
mkdirSync(dataDir, { recursive: true });
|
|
172
252
|
// The RESP keyspace, when this archive carries it: one process instead
|
|
173
253
|
// of a Postgres and a Valkey container. The port is chosen rather than
|
|
174
254
|
// fixed because 6379 is the first thing a developer's own Redis or a
|
|
175
255
|
// leftover sidecar takes, and a keyspace that cannot bind its port
|
|
176
256
|
// fails inside the postmaster log where nobody is looking.
|
|
177
|
-
|
|
178
|
-
// `cache.provider: "valkey"` is honoured here too, and this is the only place it could
|
|
179
|
-
// be: the native path asks the archive what it carries rather than the config what it
|
|
180
|
-
// wants, so a project that deliberately kept the sidecar would otherwise find Postgres
|
|
181
|
-
// serving RESP anyway and the sidecar never started.
|
|
182
|
-
const wantsPgKeyspace = keyspaceInPostgres(config);
|
|
183
|
-
keyspacePort =
|
|
184
|
-
wantsPgKeyspace && nativeKeyspaceLibraryPresent(pgBinDir)
|
|
185
|
-
? await firstFreePort(KEYSPACE_PORT_BASE, KEYSPACE_PORT_SPAN)
|
|
186
|
-
: null;
|
|
187
|
-
if (wantsPgKeyspace && nativeKeyspaceLibraryPresent(pgBinDir) && keyspacePort === null) {
|
|
188
|
-
console.warn(`[supatype] ⚠ No free port in ${KEYSPACE_PORT_BASE}-${KEYSPACE_PORT_BASE + KEYSPACE_PORT_SPAN - 1} ` +
|
|
189
|
-
"for the Postgres keyspace, starting without it.");
|
|
190
|
-
}
|
|
257
|
+
keyspacePort = await nativeKeyspacePort(config, pgBinDir);
|
|
191
258
|
const pgOpts = {
|
|
192
259
|
pgBinDir,
|
|
193
260
|
dataDir,
|
|
194
261
|
port: pgPort,
|
|
195
262
|
logPath: join(logsDir, "postgres.log"),
|
|
263
|
+
database: projectName,
|
|
196
264
|
...(keyspacePort !== null
|
|
197
265
|
? { keyspacePort, keyspaceDatabase: projectName }
|
|
198
266
|
: {}),
|
|
199
267
|
};
|
|
200
|
-
|
|
201
|
-
|
|
268
|
+
// initdb, and createdb on a first start, need the archive's version and ICU support; asked once.
|
|
269
|
+
let build;
|
|
270
|
+
const buildOnce = () => (build ??= pgBuild(pgBinDir));
|
|
271
|
+
ensureCluster(pgOpts, pgPassword, buildOnce);
|
|
202
272
|
console.log("[supatype] Starting Postgres...");
|
|
203
273
|
pgStart(pgOpts);
|
|
274
|
+
pushStartUndoLast(() => pgStop(pgOpts, { quiet: true }));
|
|
204
275
|
await pgWaitReady(pgOpts, 15_000);
|
|
205
276
|
console.log("[supatype] Postgres is ready.");
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
277
|
+
// Between start steps: once a Ctrl+C has begun the shutdown, nothing more is started.
|
|
278
|
+
await haltIfStopping();
|
|
279
|
+
if (requirePasswordAuth(pgOpts, pgPassword)) {
|
|
280
|
+
console.log("[supatype] This Postgres trusted every local connection; it now checks passwords.");
|
|
281
|
+
}
|
|
282
|
+
dbURL = localDSN(config, pgPassword, cwd);
|
|
283
|
+
// A port only the shell gives is offered to .env (B1), then a DATABASE_URL the CLI wrote,
|
|
284
|
+
// for Docker perhaps, names this database (N1).
|
|
285
|
+
await reconcileNativeDevDatabaseUrl(cwd, dbURL);
|
|
286
|
+
postgrestDbURL = `postgres://authenticator:${encodeURIComponent(authenticatorPassword)}@127.0.0.1:${pgPort}/${projectName}?sslmode=disable`;
|
|
210
287
|
const psqlBin = join(pgBinDir, process.platform === "win32" ? "psql.exe" : "psql");
|
|
211
|
-
const createdbBin = join(pgBinDir, process.platform === "win32" ? "createdb.exe" : "createdb");
|
|
212
288
|
const pgConnArgs = ["-h", "127.0.0.1", "-p", String(pgPort), "-U", "postgres"];
|
|
213
|
-
const pgEnv =
|
|
214
|
-
|
|
215
|
-
if (createDbResult.status !== 0) {
|
|
216
|
-
const stderr = createDbResult.stderr ?? "";
|
|
217
|
-
if (!stderr.includes("already exists")) {
|
|
218
|
-
throw new Error(`Failed to create database "${projectName}": ${stderr}`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
console.log(`[supatype] Created database "${projectName}".`);
|
|
223
|
-
}
|
|
289
|
+
const pgEnv = pgClientEnv(pgBinDir, pgPassword);
|
|
290
|
+
ensureProjectDatabase({ binDir: pgBinDir, connArgs: pgConnArgs, env: pgEnv, dataDir, name: projectName, build: buildOnce });
|
|
224
291
|
// Create roles required by PostgREST and grant them to postgres so
|
|
225
292
|
// PostgREST can SET ROLE when processing requests.
|
|
226
293
|
// anon – unauthenticated requests (RLS enforced)
|
|
@@ -240,36 +307,17 @@ export function registerDev(program) {
|
|
|
240
307
|
//
|
|
241
308
|
// Conditional on the library being bundled: an archive downloaded before it was would fail
|
|
242
309
|
// the CREATE, and there is nothing the developer could do about it from here.
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
: ""
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
THEN CREATE ROLE service_role NOLOGIN BYPASSRLS; END IF;
|
|
255
|
-
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'authenticator')
|
|
256
|
-
THEN CREATE ROLE authenticator LOGIN NOINHERIT PASSWORD '${authenticatorPassword}'; END IF;
|
|
257
|
-
END $$;
|
|
258
|
-
GRANT anon, authenticated, service_role TO postgres;
|
|
259
|
-
GRANT anon, authenticated, service_role TO authenticator;
|
|
260
|
-
GRANT USAGE ON SCHEMA public TO anon, authenticated, service_role;
|
|
261
|
-
-- Table-level privileges (RLS restricts rows; roles still need table access)
|
|
262
|
-
GRANT SELECT ON ALL TABLES IN SCHEMA public TO anon;
|
|
263
|
-
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO authenticated;
|
|
264
|
-
GRANT ALL ON ALL TABLES IN SCHEMA public TO service_role;
|
|
265
|
-
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO authenticated, service_role;
|
|
266
|
-
-- Default privileges so tables created by the engine push inherit these grants
|
|
267
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO anon;
|
|
268
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO authenticated;
|
|
269
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO service_role;
|
|
270
|
-
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated, service_role;
|
|
271
|
-
`;
|
|
272
|
-
spawnSync(psqlBin, [...pgConnArgs, "-d", projectName, "-c", rolesSql], { stdio: "pipe", encoding: "utf8", env: pgEnv });
|
|
310
|
+
const rolesResult = spawnSync(psqlBin, [...pgConnArgs, "-d", projectName, "-X", "-v", "ON_ERROR_STOP=1", "-f", "-"], {
|
|
311
|
+
stdio: "pipe",
|
|
312
|
+
encoding: "utf8",
|
|
313
|
+
input: nativeDevRolesSql(pgBinDir),
|
|
314
|
+
env: { ...pgEnv, [AUTHENTICATOR_PASSWORD_ENV]: authenticatorPassword },
|
|
315
|
+
});
|
|
316
|
+
// Unchecked, a failure here surfaced much later as PostgREST refusing to connect or
|
|
317
|
+
// answering 503, with nothing pointing back at the roles or schemas it needed.
|
|
318
|
+
if (rolesResult.status !== 0) {
|
|
319
|
+
throw new Error(`Failed to set up the API roles and schemas: ${(rolesResult.stderr ?? "").trim()}`);
|
|
320
|
+
}
|
|
273
321
|
}
|
|
274
322
|
const LOCAL_JWT_SECRET = devJwtSecret(cwd);
|
|
275
323
|
const authDbURL = dbURL.includes("?")
|
|
@@ -279,126 +327,83 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticate
|
|
|
279
327
|
console.log("[supatype] Running auth migrations...");
|
|
280
328
|
const migrateEnv = authMigrateEnv(serverPort, dbURL, LOCAL_JWT_SECRET);
|
|
281
329
|
runAuthMigrations(serverBin, migrateEnv);
|
|
330
|
+
await haltIfStopping();
|
|
282
331
|
// ── 9. Engine: apply schema ───────────────────────────────────────────
|
|
283
332
|
const schemaPath = schemaPathFromProject(config, cwd);
|
|
284
333
|
const supatypeDir = join(cwd, ".supatype");
|
|
285
334
|
const manifestPath = join(supatypeDir, "manifest.json");
|
|
286
335
|
const adminConfigPath = join(supatypeDir, "admin-config.json");
|
|
287
336
|
mkdirSync(supatypeDir, { recursive: true });
|
|
288
|
-
const localStoragePath = config
|
|
337
|
+
const localStoragePath = keepsObjectsLocally(config) ? serverStoreRoot(stateRoot) : undefined;
|
|
289
338
|
// Native Postgres builds don't include PostGIS, skip geo fields rather than failing.
|
|
290
339
|
const skipFieldKinds = new Set(["geo", "vector"]);
|
|
291
|
-
|
|
340
|
+
// The first push and every one the schema watch makes.
|
|
341
|
+
const schemaPush = {
|
|
342
|
+
cwd, engineBin, schemaPath, dbURL, adminConfigPath, storagePath: localStoragePath, skipFieldKinds, config, overwriteDrift,
|
|
343
|
+
};
|
|
344
|
+
await runSchemaPush(schemaPush).catch(reportUnlessStopping(reportDevPushFailure));
|
|
345
|
+
await haltIfStopping();
|
|
292
346
|
const { ensureFirstAdminUser } = await import("./admin.js");
|
|
293
347
|
await ensureFirstAdminUser(dbURL, { cwd });
|
|
294
348
|
// ── 10. Spawn supatype-server ─────────────────────────────────────────
|
|
295
|
-
//
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
: [];
|
|
303
|
-
const denoServeScriptAbs = hasFunctionsDir && functionsDir !== undefined
|
|
304
|
-
? (writeDevFunctionsRouter(cwd, functionsDir, functionRoutes) ?? "")
|
|
305
|
-
: "";
|
|
306
|
-
let denoBinPath;
|
|
307
|
-
if (hasFunctionsDir) {
|
|
308
|
-
console.log(`[supatype] Edge functions enabled (${functionsDir})`);
|
|
309
|
-
try {
|
|
310
|
-
denoBinPath = await ensureBinary("deno", config);
|
|
311
|
-
const denoVersion = await (await import("../binary-cache.js")).resolveVersionFor("deno", config);
|
|
312
|
-
console.log(`[supatype] Deno runtime: ${denoBinPath} (v${denoVersion})`);
|
|
313
|
-
if (functionRoutes.length > 0) {
|
|
314
|
-
console.log(`[supatype] Edge functions router: ${relative(cwd, denoServeScriptAbs) || ".supatype/functions-router.ts"} ` +
|
|
315
|
-
`(${functionRoutes.length} function(s): ${functionRoutes.map(fn => fn.name).join(", ")})`);
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
console.log("[supatype] Edge functions router not generated (no handler files discovered yet)");
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
catch (err) {
|
|
322
|
-
console.warn(`[supatype] ⚠ Found ${functionsDir} but could not provision Deno, edge functions will not run.\n` +
|
|
323
|
-
` ${err.message}\n` +
|
|
324
|
-
" (Functions still appear in Studio; invocations need Deno.)");
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
// Matches SUPATYPE_HOOK_SEND_EMAIL_SECRETS symmetric format (dev only). Override via .env.
|
|
328
|
-
const LOCAL_SEND_EMAIL_HOOK_SECRETS = "v1,whsec_abcdefghijklmnopqrstuvwxyz01234567";
|
|
329
|
-
const now = Math.floor(Date.now() / 1000);
|
|
330
|
-
const jwtBase = { iss: "supatype", iat: now, exp: now + 315_360_000 };
|
|
331
|
-
const anonKey = signJwt({ ...jwtBase, role: "anon" }, LOCAL_JWT_SECRET);
|
|
332
|
-
const serviceRoleKey = signJwt({ ...jwtBase, role: "service_role" }, LOCAL_JWT_SECRET);
|
|
333
|
-
const realtimeUrl = `http://127.0.0.1:${REALTIME_PORT}`;
|
|
334
|
-
patchRouteManifest(manifestPath, {
|
|
335
|
-
realtime_enabled: true,
|
|
336
|
-
realtime_url: realtimeUrl,
|
|
337
|
-
});
|
|
349
|
+
// The functions worker the image runs, from the CLI's copy, on every start (native-worker.ts).
|
|
350
|
+
const worker = await prepareNativeWorker(cwd, config);
|
|
351
|
+
// The server passes its environment, the key included, on to Deno, but the functions worker
|
|
352
|
+
// reads the key from a file: a --watch reload evaluates it again in an environment an
|
|
353
|
+
// earlier evaluation already took the key out of.
|
|
354
|
+
const { anonKey, serviceRoleKey } = nativeDevApiKeys(cwd);
|
|
355
|
+
const realtimeUrl = `http://127.0.0.1:${realtimePort}`;
|
|
338
356
|
writeAppViteEnv(cwd, config, `http://localhost:${serverPort}`, anonKey);
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
PUBLICATION_NAME: "supatype_realtime",
|
|
352
|
-
},
|
|
353
|
-
});
|
|
354
|
-
realtimeProc.start();
|
|
355
|
-
console.log(`[supatype] Realtime service: ${realtimeUrl}`);
|
|
356
|
-
}
|
|
357
|
-
catch (err) {
|
|
358
|
-
console.warn(`[supatype] ⚠ Realtime unavailable, WebSocket subscriptions will not work.\n` +
|
|
359
|
-
` ${err.message}`);
|
|
360
|
-
}
|
|
361
|
-
const emailProvider = config.email?.provider ?? "console";
|
|
362
|
-
const authMailerProvider = emailProvider === "console"
|
|
363
|
-
? "console"
|
|
364
|
-
: emailProvider === "resend"
|
|
365
|
-
? "resend"
|
|
366
|
-
: emailProvider === "ses"
|
|
367
|
-
? "ses"
|
|
368
|
-
: "smtp";
|
|
369
|
-
// Postgres serves RESP itself when the archive had pg_keyspace and the
|
|
370
|
-
// port came up. The probe is not ceremony: shared memory limits, a
|
|
371
|
-
// preload ordering mistake or a port taken between the check and the
|
|
372
|
-
// start all leave a Postgres that is running and a keyspace that is not,
|
|
373
|
-
// and the difference is a cache that silently never hits.
|
|
374
|
-
const nativeKeyspaceAddr = keyspacePort !== null && (await probeTcp("127.0.0.1", keyspacePort))
|
|
375
|
-
? `127.0.0.1:${keyspacePort}`
|
|
357
|
+
// After the push, failed or not: init's manifest names the compose stack's services.
|
|
358
|
+
recordNativeRoutes(manifestPath, worker.denoBin !== undefined);
|
|
359
|
+
// Valkey, or the keyspace Postgres serves, alongside realtime and storage: none needs another.
|
|
360
|
+
const valkeyStart = nativeValkey(keyspacePort, projectName);
|
|
361
|
+
const realtimeProc = await startNativeRealtime({
|
|
362
|
+
config, cwd, manifestPath, pidDir, url: realtimeUrl, port: realtimePort,
|
|
363
|
+
databaseUrl: dbURL, jwtSecret: LOCAL_JWT_SECRET,
|
|
364
|
+
});
|
|
365
|
+
const nativeStorage = keepsObjectsLocally(config)
|
|
366
|
+
? await startNativeStorage({
|
|
367
|
+
config, cwd, manifestPath, pidDir, stateRoot, port: storagePort, databaseUrl: dbURL, jwtSecret: LOCAL_JWT_SECRET,
|
|
368
|
+
})
|
|
376
369
|
: null;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
370
|
+
// Later pushes create the buckets a schema declares in the service as well as in buckets.json.
|
|
371
|
+
if (nativeStorage !== null)
|
|
372
|
+
schemaPush.storageApi = { url: nativeStorage.url, serviceRoleKey };
|
|
373
|
+
const valkeySidecar = await valkeyStart;
|
|
374
|
+
// `.env` and `.env.local`, read once for everything the server's environment takes from them.
|
|
375
|
+
const dotEnv = readDotEnvFiles(cwd);
|
|
376
|
+
// What an env("NAME") in auth.providers resolves against: the shell over .env, as for the config.
|
|
377
|
+
const providerEnvironment = { ...dotEnv, ...process.env };
|
|
378
|
+
warnMissingAuthProviderSecrets(config, providerEnvironment);
|
|
379
|
+
// functions.serviceRole as the worker starts with it; the config watch below keeps it current.
|
|
380
|
+
const serviceRole = { routesPath: devServiceRoleRoutesPath(cwd), initial: serviceRoleRoutes(config) };
|
|
381
|
+
writeServiceRoleRoutesFile(serviceRole.routesPath, serviceRole.initial);
|
|
387
382
|
const serverEnv = {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
383
|
+
...nativeServerCoreEnv({
|
|
384
|
+
mode: config.server.mode ?? "dev",
|
|
385
|
+
valkeyAddr: valkeySidecar.addr,
|
|
386
|
+
projectRef: projectName,
|
|
387
|
+
manifestPath,
|
|
388
|
+
adminConfigPath,
|
|
389
|
+
postgrestPort,
|
|
390
|
+
pgBinDir,
|
|
391
|
+
databaseUrl: dbURL,
|
|
392
|
+
}),
|
|
393
|
+
SUPATYPE_DENO_FUNCTIONS_DIR: worker.functionsDir,
|
|
394
|
+
...nativeWorkerDenoEnv(worker),
|
|
395
|
+
SUPATYPE_DENO_SERVE_SCRIPT: worker.entry,
|
|
396
|
+
// The server passes its environment on to Deno: the worker's, as compose gives the image,
|
|
397
|
+
// functions.serviceRole included, so a function relying on the key unlisted fails here first.
|
|
398
|
+
...functionsWorkerEnv({ cwd, config, functionsDir: worker.functionsDir, keyPath: devServiceRoleKeyPath(cwd) }),
|
|
399
|
+
// The server reaches the worker on 127.0.0.1; nothing else on the network should.
|
|
400
|
+
SUPATYPE_FUNCTIONS_HOST: "127.0.0.1",
|
|
401
|
+
// Read again on every reload, so a functions.serviceRole change applies without a restart.
|
|
402
|
+
SUPATYPE_SERVICE_ROLE_ROUTES_FILE: serviceRole.routesPath,
|
|
401
403
|
SUPATYPE_URL: `http://localhost:${serverPort}`,
|
|
404
|
+
// Natively the server is the gateway, so the address functions call is the one a browser
|
|
405
|
+
// opens. The server passes its environment on to the Deno child that runs them.
|
|
406
|
+
SUPATYPE_PUBLIC_URL: `http://localhost:${serverPort}`,
|
|
402
407
|
SUPATYPE_REALTIME_URL: realtimeUrl,
|
|
403
408
|
SUPATYPE_ANON_KEY: anonKey,
|
|
404
409
|
SUPATYPE_SERVICE_ROLE_KEY: serviceRoleKey,
|
|
@@ -424,43 +429,18 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticate
|
|
|
424
429
|
SUPATYPE_JWT_EXP: "3600",
|
|
425
430
|
SUPATYPE_JWT_AUD: "authenticated",
|
|
426
431
|
SUPATYPE_JWT_ADMIN_ROLES: "supatype_admin,service_role",
|
|
427
|
-
SUPATYPE_API_EXTERNAL_URL: `http://localhost:${serverPort}/auth/v1`,
|
|
428
432
|
SUPATYPE_API_HOST: "localhost",
|
|
429
433
|
SUPATYPE_SITE_URL: `http://localhost:${serverPort}`,
|
|
430
|
-
|
|
431
|
-
|
|
434
|
+
// External URL, mailer provider, emailed-link paths and the send-email hook.
|
|
435
|
+
...nativeAuthMailerEnv(config.email, serverPort),
|
|
432
436
|
SUPATYPE_LOG_LEVEL: "info",
|
|
433
437
|
SUPATYPE_DISABLE_SIGNUP: "false",
|
|
434
|
-
...(
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
...(
|
|
438
|
-
config.email?.resend_from !== undefined &&
|
|
439
|
-
config.email.resend_from.trim() !== ""
|
|
440
|
-
? { RESEND_FROM: config.email.resend_from.trim() }
|
|
441
|
-
: {}),
|
|
442
|
-
...(authMailerProvider === "ses" &&
|
|
443
|
-
config.email?.ses_from !== undefined &&
|
|
444
|
-
config.email.ses_from.trim() !== ""
|
|
445
|
-
? { SES_FROM: config.email.ses_from.trim() }
|
|
446
|
-
: {}),
|
|
447
|
-
...(authMailerProvider === "smtp" ? authSMTPFromEmailConfig(config.email) : {}),
|
|
448
|
-
...(config.email?.send_email_hook === true
|
|
449
|
-
? {
|
|
450
|
-
SUPATYPE_HOOK_SEND_EMAIL_ENABLED: "true",
|
|
451
|
-
SUPATYPE_HOOK_SEND_EMAIL_URI: config.email?.send_email_hook_uri !== undefined &&
|
|
452
|
-
config.email.send_email_hook_uri.trim() !== ""
|
|
453
|
-
? config.email.send_email_hook_uri.trim()
|
|
454
|
-
: `http://127.0.0.1:${serverPort}/internal/v0hooks/send-email`,
|
|
455
|
-
SUPATYPE_HOOK_SEND_EMAIL_SECRETS: config.email?.send_email_hook_secrets !== undefined &&
|
|
456
|
-
config.email.send_email_hook_secrets.trim() !== ""
|
|
457
|
-
? config.email.send_email_hook_secrets.trim()
|
|
458
|
-
: LOCAL_SEND_EMAIL_HOOK_SECRETS,
|
|
459
|
-
}
|
|
460
|
-
: {}),
|
|
461
|
-
...(config.storage?.provider !== "s3" ? localStorageEnv(stateRoot) : {}),
|
|
462
|
-
...loadDotEnv(cwd),
|
|
438
|
+
...serverStorageEnv(nativeStorage, config, stateRoot),
|
|
439
|
+
// .env last, so a SUPATYPE_EXTERNAL_* value there wins over auth.providers in the config.
|
|
440
|
+
...nativeAuthProviderEnv(config, `http://localhost:${serverPort}`, providerEnvironment),
|
|
441
|
+
...nativeServerDotEnvLayer({ dotEnv, config, cwd, denoPort }),
|
|
463
442
|
};
|
|
443
|
+
await haltIfStopping();
|
|
464
444
|
const serverProc = new ProcessManager(serverBin, [], {
|
|
465
445
|
label: "server",
|
|
466
446
|
pidDir,
|
|
@@ -468,8 +448,10 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticate
|
|
|
468
448
|
env: serverEnv,
|
|
469
449
|
});
|
|
470
450
|
serverProc.start();
|
|
451
|
+
pushStartUndo(() => serverProc.stop());
|
|
471
452
|
// ── 9b. PostgREST ────────────────────────────────────────────────────
|
|
472
453
|
let postgrestProc = null;
|
|
454
|
+
await haltIfStopping();
|
|
473
455
|
const postgrestBin = await resolvePostgrestBin(config.overrides?.postgrest);
|
|
474
456
|
if (postgrestBin) {
|
|
475
457
|
// Windows PostgREST builds are dynamically linked and require libpq/OpenSSL
|
|
@@ -480,7 +462,7 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticate
|
|
|
480
462
|
postgrestRuntimeBinDir = await resolvePgBinDir(config);
|
|
481
463
|
}
|
|
482
464
|
catch (error) {
|
|
483
|
-
console.warn(`[supatype] ⚠ Could not resolve Postgres runtime DLL directory for PostgREST: ${error
|
|
465
|
+
console.warn(`[supatype] ⚠ Could not resolve Postgres runtime DLL directory for PostgREST: ${errorMessage(error)}\n` +
|
|
484
466
|
" PostgREST may fail to start on Windows until Postgres binaries are available locally.");
|
|
485
467
|
}
|
|
486
468
|
}
|
|
@@ -489,19 +471,10 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticate
|
|
|
489
471
|
// Derived from schema.pg_schema (or schema.api_schemas), a hardcoded "public" here meant
|
|
490
472
|
// a non-default pg_schema pushed correctly and then answered PGRST106 on every request.
|
|
491
473
|
// Native dev has no masking extension either, so a schema with field rules is served from
|
|
492
|
-
// `api` here too: the case an "is the database external" rule would have got wrong.
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
tier: fieldMaskingTierFromProject(cwd, config, nativeMaskLibraryPresent(pgBinDir)),
|
|
497
|
-
// A versioned model adds the generated `draft` schema, or `.draft()` would answer
|
|
498
|
-
// PGRST106 against a stack that had migrated the views into place.
|
|
499
|
-
drafts: projectHasVersionedModels(cwd, config),
|
|
500
|
-
}),
|
|
501
|
-
// Parity with self-host, which has always set this. Unqualified names in column defaults
|
|
502
|
-
// (`uuid_generate_v4()`) resolve here, and with a non-public pg_schema the request schema
|
|
503
|
-
// alone does not reach them.
|
|
504
|
-
PGRST_DB_EXTRA_SEARCH_PATH: "public,extensions",
|
|
474
|
+
// `api` here too: the case an "is the database external" rule would have got wrong. The
|
|
475
|
+
// same tier picks the extra search path, which is what pg_graphql reflects: `api` under
|
|
476
|
+
// tier 2, `public` otherwise. Parity with self-host, which writes both from one call.
|
|
477
|
+
...nativePostgrestSchemaEnv(cwd, config, pgBinDir),
|
|
505
478
|
PGRST_DB_ANON_ROLE: "anon",
|
|
506
479
|
PGRST_SERVER_PORT: postgrestPort,
|
|
507
480
|
PGRST_SERVER_HOST: "127.0.0.1",
|
|
@@ -531,11 +504,13 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticate
|
|
|
531
504
|
env: postgrestEnv,
|
|
532
505
|
});
|
|
533
506
|
postgrestProc.start();
|
|
507
|
+
pushStartUndo(() => postgrestProc?.stop());
|
|
534
508
|
}
|
|
535
509
|
}
|
|
536
510
|
// ── 9d. Studio (optional) ─────────────────────────────────────────────
|
|
537
511
|
const studioPort = STUDIO_DEV_PORT;
|
|
538
512
|
let studioProc = null;
|
|
513
|
+
await haltIfStopping();
|
|
539
514
|
const studioOverride = config.overrides?.studio;
|
|
540
515
|
if (studioOverride) {
|
|
541
516
|
studioProc = startStudioViteDevServer({
|
|
@@ -547,15 +522,21 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticate
|
|
|
547
522
|
viteSupatypeUrl: `http://localhost:${studioPort}`,
|
|
548
523
|
});
|
|
549
524
|
studioProc?.start();
|
|
525
|
+
pushStartUndo(() => studioProc?.stop());
|
|
550
526
|
}
|
|
527
|
+
await haltIfStopping();
|
|
551
528
|
const appProc = startProxyDevApp(cwd, config, pidDir);
|
|
529
|
+
if (appProc)
|
|
530
|
+
pushStartUndo(() => appProc.stop());
|
|
552
531
|
const links = [
|
|
553
532
|
{ label: "API", url: `http://localhost:${serverPort}` },
|
|
554
533
|
{ label: "REST", url: `http://localhost:${serverPort}/rest/v1/` },
|
|
555
534
|
{ label: "Auth", url: `http://localhost:${serverPort}/auth/v1/` },
|
|
556
535
|
{ label: "Storage", url: `http://localhost:${serverPort}/storage/v1/` },
|
|
557
|
-
{ label: "Realtime", url: `ws://localhost:${serverPort}/realtime/v1/` },
|
|
558
536
|
];
|
|
537
|
+
if (realtimeProc) {
|
|
538
|
+
links.push({ label: "Realtime", url: `ws://localhost:${serverPort}/realtime/v1/` });
|
|
539
|
+
}
|
|
559
540
|
if (studioProc) {
|
|
560
541
|
links.push({ label: "Studio", url: `http://localhost:${studioPort}` });
|
|
561
542
|
}
|
|
@@ -567,41 +548,39 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticate
|
|
|
567
548
|
hints: [`Postgres ${dbURL}`, `JWT secret: #${secretFingerprint(LOCAL_JWT_SECRET)} (in .env)`],
|
|
568
549
|
});
|
|
569
550
|
// ── Shutdown handler ──────────────────────────────────────────────────
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
serverProc.stop(),
|
|
574
|
-
realtimeProc?.stop(),
|
|
575
|
-
postgrestProc?.stop(),
|
|
576
|
-
studioProc?.stop(),
|
|
577
|
-
appProc?.stop(),
|
|
578
|
-
]);
|
|
579
|
-
stopValkeySidecar(valkeySidecar.containerName);
|
|
580
|
-
await stopPostgres();
|
|
581
|
-
});
|
|
551
|
+
// Everything the start began is undone after it, the services together and then Postgres
|
|
552
|
+
// (pushStartUndo, pushStartUndoLast), so the shutdown has nothing of its own to stop.
|
|
553
|
+
registerDevShutdown(async () => undefined);
|
|
582
554
|
// ── 10. Schema watch ──────────────────────────────────────────────────
|
|
583
555
|
if (opts.watch) {
|
|
584
556
|
const schemaDir = resolve(cwd, schemaPath, "..");
|
|
585
557
|
console.log(`[supatype] Watching ${schemaDir} for changes...`);
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
558
|
+
// Deno reloads the worker when a file it imported changes, but not for a function added later.
|
|
559
|
+
const { watchNativeFunctions, watchServiceRoleRoutes } = await import("../native-functions-watch.js");
|
|
560
|
+
const { functionsDir, hooksDir, workerMain, routes } = worker;
|
|
561
|
+
const functionsWatch = watchNativeFunctions({ cwd, functionsDir, hooksDir, workerMain }, routes);
|
|
562
|
+
watchServiceRoleRoutes({
|
|
563
|
+
...serviceRole,
|
|
564
|
+
dir: cwd,
|
|
565
|
+
configFiles: PROJECT_CONFIG_FILES,
|
|
566
|
+
baseline: configBaseline,
|
|
567
|
+
readRoutes: () => serviceRoleRoutes(loadConfig(cwd)),
|
|
568
|
+
reload: functionsWatch.reload,
|
|
569
|
+
});
|
|
570
|
+
const { watchDevSchema } = await import("../dev-schema-watch.js");
|
|
571
|
+
watchDevSchema({
|
|
572
|
+
dir: schemaDir,
|
|
573
|
+
changedSinceLastPush: async () => JSON.stringify((await buildNativeAst(cwd, schemaPath, config, skipFieldKinds)).ast) !== _lastReadAst,
|
|
574
|
+
push: (why) => {
|
|
575
|
+
console.log(`\n[supatype] ${why}, checking schema...`);
|
|
576
|
+
// A hook the push declares is served once the worker's routes name it.
|
|
577
|
+
runSchemaPush(schemaPush).then(() => functionsWatch.refresh()).catch(reportUnlessStopping(reportDevPushFailure));
|
|
578
|
+
},
|
|
600
579
|
});
|
|
601
580
|
}
|
|
602
581
|
// Block until killed.
|
|
603
|
-
await
|
|
604
|
-
});
|
|
582
|
+
await waitForDevShutdown();
|
|
583
|
+
}));
|
|
605
584
|
}
|
|
606
585
|
// ---------------------------------------------------------------------------
|
|
607
586
|
// Schema push (engine subprocess)
|
|
@@ -610,131 +589,250 @@ ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticate
|
|
|
610
589
|
let _lastPushedAst = null;
|
|
611
590
|
// AST that failed on its last attempt, always retried even if content is unchanged.
|
|
612
591
|
let _lastFailedAst = null;
|
|
613
|
-
|
|
614
|
-
|
|
592
|
+
// The schema the last push read, whether it applied or not: the watch catches up on a save made
|
|
593
|
+
// after it, while the rest of dev was starting.
|
|
594
|
+
let _lastReadAst = null;
|
|
595
|
+
/**
|
|
596
|
+
* One push of a native dev session. Never forced: a change that would drop data, or one that would
|
|
597
|
+
* put back access changed outside Supatype, is asked about in a terminal as `push` asks it and
|
|
598
|
+
* refused anywhere else, and the caller logs the refusal (or the no) while dev keeps watching.
|
|
599
|
+
*
|
|
600
|
+
* The schema is built again only after a rename confirmed at the prompt was recorded in the journal,
|
|
601
|
+
* which the next attempt has to carry. Returns the schema that applied.
|
|
602
|
+
*/
|
|
603
|
+
async function pushNativeSchema(cwd, schema, target) {
|
|
604
|
+
const { ensureEngine, enginePush, engineRequest } = await import("../engine-client.js");
|
|
605
|
+
const { writeSchemaSourcePushArtifacts } = await import("../schema-sources.js");
|
|
606
|
+
const { DEV_DESTRUCTIVE_POLICY, consentDepsFromDiff, pushConsentingToDestructive } = await import("../destructive-consent.js");
|
|
607
|
+
const { devPushConsentingToDrift } = await import("../drift-consent.js");
|
|
608
|
+
await ensureEngine();
|
|
609
|
+
const sources = writeSchemaSourcePushArtifacts(cwd, true);
|
|
610
|
+
let ast = schema.ast;
|
|
611
|
+
let stale = false;
|
|
612
|
+
const request = async () => {
|
|
613
|
+
if (stale)
|
|
614
|
+
[ast, stale] = [await schema.rebuild(), false];
|
|
615
|
+
return { ast, database_url: target.dbURL, schema: target.pgSchema };
|
|
616
|
+
};
|
|
617
|
+
const diff = async () => engineRequest("/diff", await request(), isDiffResult);
|
|
618
|
+
const deps = rebuildingAfterRename(consentDepsFromDiff(cwd, diff), () => {
|
|
619
|
+
stale = true;
|
|
620
|
+
});
|
|
621
|
+
const once = async (overwrite) => {
|
|
622
|
+
const result = await pushConsentingToDestructive(async (force) => enginePush(cwd, {
|
|
623
|
+
...(await request()),
|
|
624
|
+
force,
|
|
625
|
+
...(overwrite && { overwrite_drift: true }),
|
|
626
|
+
...(sources && {
|
|
627
|
+
schema_sources_gz_base64: sources.payload.dataBase64,
|
|
628
|
+
schema_sources_manifest: sources.payload.manifest,
|
|
629
|
+
}),
|
|
630
|
+
}, isEnginePushResult), DEV_DESTRUCTIVE_POLICY, deps);
|
|
631
|
+
reportAppliedPush(result);
|
|
632
|
+
};
|
|
633
|
+
await devPushConsentingToDrift(once, target.overwriteDrift, {
|
|
634
|
+
beforeOverwrite: () => requireEngineFeatures([OVERWRITE_DRIFT_NEED]),
|
|
635
|
+
});
|
|
636
|
+
return { ast };
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* `deps` with a rename journal writer that also calls `recorded`, so the attempt after a confirmed
|
|
640
|
+
* rename builds the schema again and carries the journal entry it wrote.
|
|
641
|
+
*/
|
|
642
|
+
function rebuildingAfterRename(deps, recorded) {
|
|
643
|
+
const journal = deps.renameWriter;
|
|
644
|
+
if (journal === undefined)
|
|
645
|
+
return deps;
|
|
646
|
+
return {
|
|
647
|
+
...deps,
|
|
648
|
+
renameWriter: {
|
|
649
|
+
write: async (candidate) => {
|
|
650
|
+
recorded();
|
|
651
|
+
await journal.write(candidate);
|
|
652
|
+
},
|
|
653
|
+
},
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* The AST native dev pushes, built from the schema file with its rename journal: with the
|
|
658
|
+
* publishing config, as `supatype push` sends it (the engine refuses a versioned schema without
|
|
659
|
+
* one), and with each field whose kind needs a missing Postgres extension replaced by JSONB, which
|
|
660
|
+
* `adapted` names.
|
|
661
|
+
*/
|
|
662
|
+
async function buildNativeAst(cwd, schemaPath, config, skipFieldKinds) {
|
|
615
663
|
const { loadSchemaAst } = await import("../config.js");
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
ast
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
664
|
+
const { withPublishing } = await import("../model-versioning.js");
|
|
665
|
+
const loaded = loadSchemaAst(schemaPath, cwd);
|
|
666
|
+
const ast = config ? withPublishing(loaded, config) : loaded;
|
|
667
|
+
if (!skipFieldKinds || skipFieldKinds.size === 0)
|
|
668
|
+
return { ast, adapted: [] };
|
|
669
|
+
const { filtered, adapted } = adaptUnsupportedKinds(ast, skipFieldKinds);
|
|
670
|
+
return { ast: filtered, adapted };
|
|
671
|
+
}
|
|
672
|
+
/** One push of native dev (provider `native`): the schema on disk, then what describes it. Exported for tests. */
|
|
673
|
+
export async function runSchemaPush(push) {
|
|
674
|
+
const { cwd, engineBin, schemaPath, dbURL, adminConfigPath, storagePath, skipFieldKinds, config, storageApi } = push;
|
|
675
|
+
const overwriteDrift = push.overwriteDrift ?? false;
|
|
676
|
+
const read = await readNativeSchema(cwd, schemaPath, config, skipFieldKinds);
|
|
677
|
+
const astJson = JSON.stringify(read);
|
|
678
|
+
_lastReadAst = astJson;
|
|
679
|
+
// Skip only when this exact AST applied and nothing has failed since. Saving a failed schema
|
|
680
|
+
// again retries it, and putting a refused change back pushes the applied schema again, which is
|
|
681
|
+
// what marks the refusal superseded and clears Studio's notice. Said out loud, since a save that
|
|
682
|
+
// pushes nothing otherwise ends on "checking schema..." and looks like a hang.
|
|
683
|
+
if (astJson === _lastPushedAst && _lastFailedAst === null) {
|
|
684
|
+
console.log("[supatype] Schema unchanged since the last push, nothing to apply.");
|
|
631
685
|
return;
|
|
632
686
|
}
|
|
633
687
|
const astPath = join(cwd, ".supatype", "schema.ast.json");
|
|
634
688
|
writeFileSync(astPath, astJson);
|
|
635
|
-
// Push schema.
|
|
636
689
|
console.log("[supatype] Applying schema...");
|
|
637
|
-
const
|
|
638
|
-
const
|
|
639
|
-
await
|
|
640
|
-
|
|
641
|
-
|
|
690
|
+
const rebuild = async () => (await buildNativeAst(cwd, schemaPath, config, skipFieldKinds)).ast;
|
|
691
|
+
const pgSchemaName = config ? pgSchema(config) : "public";
|
|
692
|
+
const ast = await applyNativeSchema(cwd, { ast: read, rebuild }, { dbURL, pgSchema: pgSchemaName, overwriteDrift });
|
|
693
|
+
writeFileSync(astPath, JSON.stringify(ast));
|
|
694
|
+
await writeNativeSchemaArtifacts({ cwd, engineBin, astPath, adminConfigPath, storagePath, storageApi }, ast, config);
|
|
695
|
+
}
|
|
696
|
+
/** The schema on disk as native dev pushes it, saying which fields were stood in for by JSONB. */
|
|
697
|
+
async function readNativeSchema(cwd, schemaPath, config, skipFieldKinds) {
|
|
698
|
+
const built = await buildNativeAst(cwd, schemaPath, config, skipFieldKinds);
|
|
699
|
+
if (built.adapted.length > 0) {
|
|
700
|
+
console.warn(`[supatype] ${built.adapted.length} field(s) replaced with JSONB, required extensions not available:\n` +
|
|
701
|
+
built.adapted.map((s) => ` ${s}`).join("\n"));
|
|
702
|
+
}
|
|
703
|
+
return built.ast;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Push, remembering the outcome for the next save's skip. Returns what applied, which is the schema
|
|
707
|
+
* with any rename confirmed at the prompt declared on it.
|
|
708
|
+
*/
|
|
709
|
+
async function applyNativeSchema(cwd, schema, target) {
|
|
642
710
|
try {
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
...(sources
|
|
649
|
-
? {
|
|
650
|
-
schema_sources_gz_base64: sources.payload.dataBase64,
|
|
651
|
-
schema_sources_manifest: sources.payload.manifest,
|
|
652
|
-
}
|
|
653
|
-
: {}),
|
|
654
|
-
});
|
|
655
|
-
printPushWarnings(result);
|
|
711
|
+
const { ast } = await pushNativeSchema(cwd, schema, target);
|
|
712
|
+
_lastPushedAst = JSON.stringify(ast);
|
|
713
|
+
_lastFailedAst = null;
|
|
714
|
+
_lastReadAst = _lastPushedAst;
|
|
715
|
+
return ast;
|
|
656
716
|
}
|
|
657
717
|
catch (err) {
|
|
658
|
-
_lastFailedAst =
|
|
718
|
+
_lastFailedAst = JSON.stringify(schema.ast);
|
|
659
719
|
throw err;
|
|
660
720
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* The buckets, Studio's admin config, the types, and the hook maps and handler types, from the AST
|
|
724
|
+
* applied. The rest of the server's route manifest names where each service is, nothing from the
|
|
725
|
+
* schema, and native dev writes it as it starts them (native-realtime.ts, recordNativeRoutes).
|
|
726
|
+
*/
|
|
727
|
+
async function writeNativeSchemaArtifacts(paths, ast, config) {
|
|
728
|
+
const { cwd, engineBin, astPath } = paths;
|
|
729
|
+
if (paths.storagePath)
|
|
730
|
+
await provisionDeclaredBuckets(engineBin, cwd, astPath, paths);
|
|
731
|
+
if (paths.adminConfigPath)
|
|
732
|
+
await writeNativeAdminConfig(paths, paths.adminConfigPath, ast, config);
|
|
733
|
+
if (config)
|
|
734
|
+
writeNativeAppliedAst(cwd, config, ast);
|
|
735
|
+
await writeNativeTypes(cwd, ast, config);
|
|
736
|
+
}
|
|
737
|
+
/** The storage buckets the schema declares, as the engine resolves them; none when it cannot say. */
|
|
738
|
+
function declaredBuckets(engineBin, cwd, astPath) {
|
|
739
|
+
const parseResult = spawnSync(engineBin, ["parse", "-i", astPath], { cwd, stdio: "pipe", encoding: "utf8" });
|
|
740
|
+
if (parseResult.status !== 0 || !parseResult.stdout)
|
|
741
|
+
return [];
|
|
742
|
+
try {
|
|
743
|
+
const resolvedAst = JSON.parse(parseResult.stdout);
|
|
744
|
+
return isParsedBuckets(resolvedAst) ? resolvedAst.storageBuckets ?? [] : [];
|
|
675
745
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (genResult.status !== 0) {
|
|
679
|
-
console.warn("[supatype] Manifest generation failed, server routing may be stale.");
|
|
746
|
+
catch {
|
|
747
|
+
return [];
|
|
680
748
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Create the storage buckets the schema declares: in buckets.json, which the server's store reads
|
|
752
|
+
* and the storage service imports when it starts, and in the service itself once it runs.
|
|
753
|
+
*/
|
|
754
|
+
async function provisionDeclaredBuckets(engineBin, cwd, astPath, paths) {
|
|
755
|
+
const buckets = declaredBuckets(engineBin, cwd, astPath);
|
|
756
|
+
if (buckets.length === 0 || paths.storagePath === undefined)
|
|
757
|
+
return;
|
|
758
|
+
await provisionNativeBuckets(buckets, { storagePath: paths.storagePath, storageApi: paths.storageApi });
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* `buckets` in buckets.json, and in the storage service while it runs, saying how many new ones
|
|
762
|
+
* are ready: a bucket the service did not take is not, though buckets.json has it. Exported for tests.
|
|
763
|
+
*/
|
|
764
|
+
export async function provisionNativeBuckets(buckets, paths) {
|
|
765
|
+
const added = provisionStorageBuckets(buckets, paths.storagePath);
|
|
766
|
+
const failed = paths.storageApi
|
|
767
|
+
? await provisionBuckets(paths.storageApi.url, paths.storageApi.serviceRoleKey, bucketSpecsFromAst({ storageBuckets: buckets }))
|
|
768
|
+
: [];
|
|
769
|
+
const ready = added.filter((id) => !failed.includes(id)).length;
|
|
770
|
+
if (ready > 0)
|
|
771
|
+
console.log(`[supatype] Storage: provisioned ${ready} bucket(s).`);
|
|
772
|
+
}
|
|
773
|
+
/** Studio's admin config, which the engine writes to stdout, with the project's roles merged in. */
|
|
774
|
+
async function writeNativeAdminConfig(paths, adminConfigPath, ast, config) {
|
|
775
|
+
const adminResult = spawnSync(paths.engineBin, ["admin", "-i", paths.astPath], {
|
|
776
|
+
cwd: paths.cwd,
|
|
777
|
+
stdio: "pipe",
|
|
778
|
+
encoding: "utf8",
|
|
779
|
+
});
|
|
780
|
+
if (adminResult.status !== 0 || !adminResult.stdout)
|
|
781
|
+
return;
|
|
782
|
+
const { withAdminRoles } = await import("../studio-admin-roles.js");
|
|
783
|
+
let admin;
|
|
784
|
+
try {
|
|
785
|
+
admin = JSON.parse(adminResult.stdout);
|
|
786
|
+
}
|
|
787
|
+
catch {
|
|
788
|
+
admin = adminResult.stdout;
|
|
789
|
+
}
|
|
790
|
+
restoreSystemRelationTargets(admin, ast);
|
|
791
|
+
const merged = config ? withAdminRoles(admin, config) : admin;
|
|
792
|
+
writeFileSync(adminConfigPath, `${JSON.stringify(merged, null, 2)}\n`);
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* The generated types and client, as `push` writes them, at the default paths when `output` is not
|
|
796
|
+
* set. Native dev never wrote them, so a renamed field left the app compiling against the old name.
|
|
797
|
+
* A failure is a warning: the schema is applied and dev keeps watching.
|
|
798
|
+
*/
|
|
799
|
+
async function writeNativeTypes(cwd, ast, config) {
|
|
800
|
+
const { projectOutputPaths, writeGeneratedTypes } = await import("../type-generation.js");
|
|
801
|
+
try {
|
|
802
|
+
for (const message of await writeGeneratedTypes({ cwd, ast, ...projectOutputPaths(config?.output) })) {
|
|
803
|
+
console.log(`[supatype] ${message}`);
|
|
696
804
|
}
|
|
697
805
|
}
|
|
698
|
-
|
|
806
|
+
catch (err) {
|
|
807
|
+
console.warn(`[supatype] Type generation failed: ${errorMessage(err)}`);
|
|
808
|
+
}
|
|
699
809
|
}
|
|
810
|
+
/** Writes the declared buckets buckets.json lacks to it, and returns their ids. */
|
|
700
811
|
function provisionStorageBuckets(declared, storagePath) {
|
|
701
812
|
const bucketsDir = join(storagePath, ".supatype");
|
|
702
813
|
const bucketsFile = join(bucketsDir, "buckets.json");
|
|
703
814
|
mkdirSync(bucketsDir, { recursive: true });
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
catch { /* file doesn't exist yet */ }
|
|
815
|
+
// Absent until the first bucket, and anything that is not a list of buckets reads as none.
|
|
816
|
+
const stored = readJsonFile(bucketsFile, isArrayOf(isJsonObject)) ?? [];
|
|
817
|
+
const existing = stored.map(withPublicFromMode);
|
|
818
|
+
const corrected = existing.filter((row, i) => row["public"] !== stored[i]?.["public"]).length;
|
|
709
819
|
const existingIds = new Set(existing.map((b) => b["id"]));
|
|
710
|
-
|
|
820
|
+
const added = [];
|
|
711
821
|
for (const bucket of declared) {
|
|
712
822
|
if (existingIds.has(bucket.id))
|
|
713
823
|
continue;
|
|
714
|
-
|
|
715
|
-
existing.push({
|
|
716
|
-
id: bucket.id,
|
|
717
|
-
name: bucket.id,
|
|
718
|
-
public: bucket.public,
|
|
719
|
-
file_size_limit: bucket.fileSizeLimit ?? null,
|
|
720
|
-
allowed_mime_types: bucket.allowedMimeTypes ?? null,
|
|
721
|
-
access_mode: bucket.accessMode ?? (bucket.public ? "public" : "private"),
|
|
722
|
-
s3_bucket_policy: bucket.s3BucketPolicy ?? null,
|
|
723
|
-
created_at: now,
|
|
724
|
-
updated_at: now,
|
|
725
|
-
});
|
|
824
|
+
existing.push(nativeBucketRow(bucket, new Date().toISOString()));
|
|
726
825
|
mkdirSync(join(storagePath, bucket.id), { recursive: true });
|
|
727
|
-
added
|
|
826
|
+
added.push(bucket.id);
|
|
728
827
|
}
|
|
729
|
-
if (added > 0)
|
|
828
|
+
if (added.length > 0 || corrected > 0)
|
|
730
829
|
writeFileSync(bucketsFile, JSON.stringify(existing, null, 2));
|
|
731
|
-
|
|
732
|
-
}
|
|
830
|
+
return added;
|
|
733
831
|
}
|
|
734
832
|
// ---------------------------------------------------------------------------
|
|
735
833
|
// Resolve Postgres bin dir
|
|
736
834
|
// ---------------------------------------------------------------------------
|
|
737
|
-
async function resolvePgBinDir(config) {
|
|
835
|
+
export async function resolvePgBinDir(config) {
|
|
738
836
|
const override = config.overrides?.postgres_dir;
|
|
739
837
|
if (override) {
|
|
740
838
|
// Normalize Git Bash (/c/Users/...) paths to Win32 form (C:\Users\...) on Windows.
|
|
@@ -767,22 +865,11 @@ async function extractPostgresArchive(pgCacheDir, version, platform, extractDir)
|
|
|
767
865
|
if (!existsSync(archivePath)) {
|
|
768
866
|
throw new Error(`Postgres ${version} archive not found. Run: supatype update`);
|
|
769
867
|
}
|
|
770
|
-
|
|
771
|
-
// On Windows, Git Bash tar is typically first in PATH and chokes on drive-letter
|
|
772
|
-
// paths (C:\...). Use PowerShell's Expand-Archive instead, which handles Windows
|
|
773
|
-
// paths natively. On Linux/macOS, use tar as normal.
|
|
774
|
-
const result = platform.os === "windows"
|
|
775
|
-
? spawnSync("powershell.exe", ["-NoProfile", "-Command", `Expand-Archive -Path '${archivePath}' -DestinationPath '${extractDir}' -Force`], { stdio: "inherit" })
|
|
776
|
-
: spawnSync("tar", ["-xzf", archivePath, "-C", extractDir], { stdio: "inherit" });
|
|
777
|
-
if (result.status !== 0) {
|
|
778
|
-
throw new Error(`Failed to extract Postgres archive: ${archivePath}`);
|
|
779
|
-
}
|
|
868
|
+
extractArchive(archivePath, extractDir);
|
|
780
869
|
}
|
|
781
870
|
// ---------------------------------------------------------------------------
|
|
782
871
|
// PostgREST resolver: downloads from GitHub releases if not cached
|
|
783
872
|
// ---------------------------------------------------------------------------
|
|
784
|
-
const POSTGREST_DEFAULT_VERSION = "12.2.3";
|
|
785
|
-
const POSTGREST_GITHUB = "https://github.com/PostgREST/postgrest/releases/download";
|
|
786
873
|
async function resolvePostgrestBin(overridePath) {
|
|
787
874
|
// Honour local override (same pattern as engine/server).
|
|
788
875
|
if (overridePath) {
|
|
@@ -797,31 +884,25 @@ async function resolvePostgrestBin(overridePath) {
|
|
|
797
884
|
console.warn(`[supatype] ⚠ PostgREST override not found at ${p}`);
|
|
798
885
|
return null;
|
|
799
886
|
}
|
|
800
|
-
const version =
|
|
887
|
+
const version = POSTGREST_VERSION;
|
|
801
888
|
const platform = currentPlatform();
|
|
802
|
-
const arch = platform.arch === "arm64" ? "aarch64" : "x86_64";
|
|
803
889
|
const binName = platform.os === "windows" ? "postgrest.exe" : "postgrest";
|
|
804
890
|
const cacheDir = cachePath("postgres", version).replace(/postgres/, "postgrest");
|
|
805
891
|
const binPath = join(cacheDir, binName);
|
|
806
|
-
const
|
|
807
|
-
? `postgrest-v${version}-windows-x64.zip`
|
|
808
|
-
: platform.os === "darwin"
|
|
809
|
-
? `postgrest-v${version}-macos-${arch}.tar.xz`
|
|
810
|
-
: `postgrest-v${version}-linux-static-${arch}.tar.xz`;
|
|
811
|
-
const archivePath = join(cacheDir, archiveName);
|
|
892
|
+
const archivePath = join(cacheDir, postgrestArchiveName(platform, version));
|
|
812
893
|
if (existsSync(binPath)) {
|
|
813
894
|
// Backfill DLLs for older cached Windows installs where only postgrest.exe
|
|
814
895
|
// was copied from the release archive.
|
|
815
|
-
if (platform.os === "windows" &&
|
|
816
|
-
|
|
817
|
-
|
|
896
|
+
if (platform.os === "windows" && postgrestRuntimeRepairDue(cacheDir, archivePath)) {
|
|
897
|
+
if (repairWindowsPostgrestRuntime(cacheDir, archivePath, binPath))
|
|
898
|
+
markPostgrestUnpacked(cacheDir);
|
|
899
|
+
else
|
|
818
900
|
console.warn("[supatype] ⚠ PostgREST runtime DLL repair failed; REST API may be unavailable.");
|
|
819
|
-
}
|
|
820
901
|
}
|
|
821
902
|
return binPath;
|
|
822
903
|
}
|
|
823
904
|
// Download from GitHub releases.
|
|
824
|
-
const url =
|
|
905
|
+
const url = postgrestArchiveUrl(platform, version);
|
|
825
906
|
console.log(`[supatype] Downloading PostgREST v${version}...`);
|
|
826
907
|
mkdirSync(cacheDir, { recursive: true });
|
|
827
908
|
let resp;
|
|
@@ -829,7 +910,7 @@ async function resolvePostgrestBin(overridePath) {
|
|
|
829
910
|
resp = await fetch(url);
|
|
830
911
|
}
|
|
831
912
|
catch (e) {
|
|
832
|
-
console.warn(`[supatype] ⚠ Could not download PostgREST (${e
|
|
913
|
+
console.warn(`[supatype] ⚠ Could not download PostgREST (${errorMessage(e)}).\n` +
|
|
833
914
|
` REST API (/rest/v1/) will be unavailable until the download succeeds.\n` +
|
|
834
915
|
` Re-run 'supatype dev' once network access to github.com:443 is restored.`);
|
|
835
916
|
return null;
|
|
@@ -873,16 +954,10 @@ async function resolvePostgrestBin(overridePath) {
|
|
|
873
954
|
const { chmod } = await import("node:fs/promises");
|
|
874
955
|
await chmod(binPath, 0o755);
|
|
875
956
|
}
|
|
957
|
+
markPostgrestUnpacked(cacheDir);
|
|
876
958
|
console.log(`[supatype] PostgREST v${version} ready.`);
|
|
877
959
|
return binPath;
|
|
878
960
|
}
|
|
879
|
-
function hasLikelyWindowsRuntimeDlls(dir) {
|
|
880
|
-
if (process.platform !== "win32")
|
|
881
|
-
return true;
|
|
882
|
-
return (existsSync(join(dir, "libpq.dll")) ||
|
|
883
|
-
existsSync(join(dir, "libpq-5.dll")) ||
|
|
884
|
-
existsSync(join(dir, "libssl-3-x64.dll")));
|
|
885
|
-
}
|
|
886
961
|
function repairWindowsPostgrestRuntime(cacheDir, archivePath, binPath) {
|
|
887
962
|
const r = spawnSync("powershell.exe", [
|
|
888
963
|
"-NoProfile",
|
|
@@ -897,6 +972,12 @@ function repairWindowsPostgrestRuntime(cacheDir, archivePath, binPath) {
|
|
|
897
972
|
], { stdio: "pipe", encoding: "utf8" });
|
|
898
973
|
return r.status === 0;
|
|
899
974
|
}
|
|
975
|
+
// ---------------------------------------------------------------------------
|
|
976
|
+
// Local-dev JWT generator (no external dep, pure crypto)
|
|
977
|
+
// ---------------------------------------------------------------------------
|
|
978
|
+
// ---------------------------------------------------------------------------
|
|
979
|
+
// AST adaptation: replace extension-dependent fields with JSONB fallbacks
|
|
980
|
+
// ---------------------------------------------------------------------------
|
|
900
981
|
// Field kinds that require Postgres extensions not available in all builds.
|
|
901
982
|
// Maps kind → { extension name, JSONB fallback AST }
|
|
902
983
|
const EXTENSION_FIELDS = {
|
|
@@ -905,26 +986,23 @@ const EXTENSION_FIELDS = {
|
|
|
905
986
|
};
|
|
906
987
|
function adaptUnsupportedKinds(ast, skipKinds) {
|
|
907
988
|
const adapted = [];
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
adapted.push(`${model.name}.${name} (${info.ext} → JSONB)`);
|
|
920
|
-
}
|
|
921
|
-
else {
|
|
922
|
-
fields[name] = field;
|
|
923
|
-
}
|
|
989
|
+
const models = ast.models.map((model) => ({ ...model, fields: adaptFields(model, skipKinds, adapted) }));
|
|
990
|
+
return { filtered: { ...ast, models }, adapted };
|
|
991
|
+
}
|
|
992
|
+
/** `model`'s fields, each of a kind in `skipKinds` replaced by its JSONB fallback and named in `adapted`. */
|
|
993
|
+
function adaptFields(model, skipKinds, adapted) {
|
|
994
|
+
const fields = {};
|
|
995
|
+
for (const [name, field] of Object.entries(model.fields)) {
|
|
996
|
+
const info = skipKinds.has(field.kind) ? EXTENSION_FIELDS[field.kind] : undefined;
|
|
997
|
+
if (info) {
|
|
998
|
+
fields[name] = { ...info.fallback, required: field["required"] ?? false };
|
|
999
|
+
adapted.push(`${model.name}.${name} (${info.ext} → JSONB)`);
|
|
924
1000
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
1001
|
+
else {
|
|
1002
|
+
fields[name] = field;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
return fields;
|
|
928
1006
|
}
|
|
929
1007
|
// ---------------------------------------------------------------------------
|
|
930
1008
|
// .env loader
|
|
@@ -962,22 +1040,57 @@ function runAuthMigrations(serverBin, migrateEnv) {
|
|
|
962
1040
|
(detail ? `:\n${detail}` : ""));
|
|
963
1041
|
}
|
|
964
1042
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1043
|
+
/**
|
|
1044
|
+
* The keyspace native Postgres serves, when it answers RESP, else Valkey: one already running, or
|
|
1045
|
+
* the sidecar container.
|
|
1046
|
+
*/
|
|
1047
|
+
async function nativeValkey(keyspacePort, projectName) {
|
|
1048
|
+
const keyspace = await nativeKeyspaceAddrFor(keyspacePort);
|
|
1049
|
+
if (keyspace === null)
|
|
1050
|
+
return ensureValkeySidecar(projectName);
|
|
1051
|
+
console.log(`[supatype] Keyspace served by Postgres (${keyspace}).`);
|
|
1052
|
+
return externalValkey(keyspace);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* The project database: left as it is when psql can report its encoding (with a warning when an
|
|
1056
|
+
* older CLI made it in another encoding than UTF8), else created, UTF8 as the cluster. One psql
|
|
1057
|
+
* call on every start after the first, where it took createdb, a psql and two version probes.
|
|
1058
|
+
*/
|
|
1059
|
+
function ensureProjectDatabase(db) {
|
|
1060
|
+
const psqlBin = join(db.binDir, process.platform === "win32" ? "psql.exe" : "psql");
|
|
1061
|
+
const encoding = databaseEncoding(psqlBin, [...db.connArgs, "-d", db.name], db.env);
|
|
1062
|
+
if (encoding !== null) {
|
|
1063
|
+
const warning = nonUtf8DatabaseWarning(encoding, db.name, db.dataDir);
|
|
1064
|
+
if (warning !== null)
|
|
1065
|
+
console.warn(warning);
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
const createdbBin = join(db.binDir, process.platform === "win32" ? "createdb.exe" : "createdb");
|
|
1069
|
+
const created = spawnSync(createdbBin, createdbArgs(db.connArgs, db.name, db.build()), { stdio: "pipe", encoding: "utf8", env: db.env });
|
|
1070
|
+
if (created.status === 0) {
|
|
1071
|
+
console.log(`[supatype] Created database "${db.name}".`);
|
|
1072
|
+
return;
|
|
980
1073
|
}
|
|
981
|
-
|
|
1074
|
+
const stderr = created.stderr ?? "";
|
|
1075
|
+
// A POSTGRES_PASSWORD changed by hand reaches here; a deleted one was stopped earlier.
|
|
1076
|
+
if (isPasswordRejected(stderr)) {
|
|
1077
|
+
const { title, hints } = superuserPasswordMissingMessage(db.dataDir);
|
|
1078
|
+
throw new Error([title, ...hints].join("\n "));
|
|
1079
|
+
}
|
|
1080
|
+
if (!stderr.includes("already exists"))
|
|
1081
|
+
throw new Error(`Failed to create database "${db.name}": ${stderr}`);
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* What push and Docker dev write from an applied AST (applied-ast-artifacts.ts), for native dev,
|
|
1085
|
+
* which has no row-cache container. The manifest is made first when there is none: the hook maps
|
|
1086
|
+
* only go into one that exists, and the first push runs before native dev records its functions,
|
|
1087
|
+
* which sets `functions_enabled` before the server reads it.
|
|
1088
|
+
*/
|
|
1089
|
+
function writeNativeAppliedAst(cwd, config, ast) {
|
|
1090
|
+
const manifestPath = join(cwd, ".supatype", "manifest.json");
|
|
1091
|
+
if (!existsSync(manifestPath))
|
|
1092
|
+
patchRouteManifest(manifestPath, {});
|
|
1093
|
+
for (const line of writeAppliedAstArtifacts(cwd, config, ast, { rowCacheEnv: false }).lines)
|
|
1094
|
+
console.log(`[supatype] ${line}`);
|
|
982
1095
|
}
|
|
983
1096
|
//# sourceMappingURL=dev.js.map
|