@supatype/cli 0.7.0 → 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 +259 -0
- package/bin/supatype.js +25 -4
- package/deno.d.ts +1 -1
- package/dist/admin-prompt-state.d.ts +13 -0
- package/dist/admin-prompt-state.d.ts.map +1 -0
- package/dist/admin-prompt-state.js +30 -0
- package/dist/admin-prompt-state.js.map +1 -0
- package/dist/adopt-columns.d.ts.map +1 -1
- package/dist/adopt-columns.js +13 -17
- package/dist/adopt-columns.js.map +1 -1
- package/dist/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/binary-cache.d.ts +25 -2
- package/dist/binary-cache.d.ts.map +1 -1
- package/dist/binary-cache.js +115 -81
- package/dist/binary-cache.js.map +1 -1
- package/dist/binary-download-lock.d.ts.map +1 -1
- package/dist/binary-download-lock.js +1 -3
- package/dist/binary-download-lock.js.map +1 -1
- package/dist/byo-preflight.d.ts.map +1 -1
- package/dist/byo-preflight.js +2 -10
- package/dist/byo-preflight.js.map +1 -1
- package/dist/cache-pins.d.ts.map +1 -1
- package/dist/cache-pins.js +2 -2
- package/dist/cache-pins.js.map +1 -1
- package/dist/cli-version-embedded.js +1 -1
- package/dist/cloud-credentials.d.ts +6 -0
- package/dist/cloud-credentials.d.ts.map +1 -1
- package/dist/cloud-credentials.js +13 -0
- package/dist/cloud-credentials.js.map +1 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +18 -18
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +27 -8
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/cache.d.ts.map +1 -1
- package/dist/commands/cache.js +5 -4
- package/dist/commands/cache.js.map +1 -1
- package/dist/commands/cloud.js +2 -4
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/db.d.ts.map +1 -1
- package/dist/commands/db.js +116 -106
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +2 -2
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.d.ts +50 -4
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +262 -266
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/functions.d.ts +30 -0
- package/dist/commands/functions.d.ts.map +1 -1
- package/dist/commands/functions.js +503 -507
- package/dist/commands/functions.js.map +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +11 -8
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/hooks.js +26 -11
- package/dist/commands/hooks.js.map +1 -1
- package/dist/commands/init.d.ts +16 -2
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +237 -143
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/internal.d.ts.map +1 -1
- package/dist/commands/internal.js +2 -1
- package/dist/commands/internal.js.map +1 -1
- package/dist/commands/keys.d.ts +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 +30 -9
- package/dist/commands/link-helpers.js.map +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +5 -4
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/migrate.js +1 -1
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/pg.js +2 -0
- package/dist/commands/pg.js.map +1 -1
- package/dist/commands/plugins.d.ts.map +1 -1
- package/dist/commands/plugins.js +17 -7
- package/dist/commands/plugins.js.map +1 -1
- package/dist/commands/push.d.ts +37 -0
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +188 -73
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/seed.d.ts +35 -0
- package/dist/commands/seed.d.ts.map +1 -1
- package/dist/commands/seed.js +72 -38
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/self-host.d.ts.map +1 -1
- package/dist/commands/self-host.js +61 -29
- package/dist/commands/self-host.js.map +1 -1
- package/dist/commands/status.js +5 -5
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/types.js +2 -5
- package/dist/commands/types.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +212 -101
- package/dist/commands/update.js.map +1 -1
- package/dist/component-launch.d.ts +11 -0
- package/dist/component-launch.d.ts.map +1 -0
- package/dist/component-launch.js +35 -0
- package/dist/component-launch.js.map +1 -0
- package/dist/components.d.ts +7 -2
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +7 -2
- package/dist/components.js.map +1 -1
- package/dist/compose-db-roles.d.ts.map +1 -1
- package/dist/compose-db-roles.js +5 -14
- package/dist/compose-db-roles.js.map +1 -1
- package/dist/compose-engine-run.d.ts +6 -5
- package/dist/compose-engine-run.d.ts.map +1 -1
- package/dist/compose-engine-run.js +44 -37
- package/dist/compose-engine-run.js.map +1 -1
- package/dist/compose-engine-service.d.ts +10 -0
- package/dist/compose-engine-service.d.ts.map +1 -0
- package/dist/compose-engine-service.js +16 -0
- package/dist/compose-engine-service.js.map +1 -0
- package/dist/compose-host-path.d.ts +14 -0
- package/dist/compose-host-path.d.ts.map +1 -0
- package/dist/compose-host-path.js +18 -0
- package/dist/compose-host-path.js.map +1 -0
- package/dist/compose-image-pull.d.ts +43 -0
- package/dist/compose-image-pull.d.ts.map +1 -0
- package/dist/compose-image-pull.js +27 -0
- package/dist/compose-image-pull.js.map +1 -0
- package/dist/compose-kong.d.ts.map +1 -1
- package/dist/compose-kong.js +10 -6
- package/dist/compose-kong.js.map +1 -1
- package/dist/compose-local-server-image.d.ts.map +1 -1
- package/dist/compose-local-server-image.js +7 -3
- package/dist/compose-local-server-image.js.map +1 -1
- package/dist/compose-render-mode.d.ts.map +1 -1
- package/dist/compose-render-mode.js +7 -4
- package/dist/compose-render-mode.js.map +1 -1
- package/dist/compose-services.d.ts +12 -2
- package/dist/compose-services.d.ts.map +1 -1
- package/dist/compose-services.js +27 -12
- package/dist/compose-services.js.map +1 -1
- package/dist/config-snapshot.d.ts +6 -0
- package/dist/config-snapshot.d.ts.map +1 -0
- package/dist/config-snapshot.js +23 -0
- package/dist/config-snapshot.js.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -0
- 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 +40 -18
- package/dist/db-port.d.ts.map +1 -1
- package/dist/db-port.js +33 -31
- package/dist/db-port.js.map +1 -1
- package/dist/db-preflight.d.ts +8 -0
- package/dist/db-preflight.d.ts.map +1 -1
- package/dist/db-preflight.js +18 -1
- package/dist/db-preflight.js.map +1 -1
- package/dist/db-rows.d.ts +11 -0
- package/dist/db-rows.d.ts.map +1 -1
- package/dist/db-rows.js +27 -0
- package/dist/db-rows.js.map +1 -1
- package/dist/debounce.d.ts +11 -0
- package/dist/debounce.d.ts.map +1 -0
- package/dist/debounce.js +23 -0
- package/dist/debounce.js.map +1 -0
- package/dist/dev-api-keys.d.ts +12 -2
- package/dist/dev-api-keys.d.ts.map +1 -1
- package/dist/dev-api-keys.js +33 -17
- package/dist/dev-api-keys.js.map +1 -1
- package/dist/dev-compose.d.ts +5 -12
- package/dist/dev-compose.d.ts.map +1 -1
- package/dist/dev-compose.js +153 -245
- package/dist/dev-compose.js.map +1 -1
- package/dist/dev-db-ready.d.ts.map +1 -1
- package/dist/dev-db-ready.js +2 -1
- package/dist/dev-db-ready.js.map +1 -1
- package/dist/dev-db-reset.d.ts.map +1 -1
- package/dist/dev-db-reset.js +5 -4
- package/dist/dev-db-reset.js.map +1 -1
- package/dist/dev-functions-watch.d.ts.map +1 -1
- package/dist/dev-functions-watch.js +5 -16
- package/dist/dev-functions-watch.js.map +1 -1
- package/dist/dev-ports.d.ts +22 -7
- package/dist/dev-ports.d.ts.map +1 -1
- package/dist/dev-ports.js +61 -38
- package/dist/dev-ports.js.map +1 -1
- package/dist/dev-schema-watch.d.ts.map +1 -1
- package/dist/dev-schema-watch.js +7 -12
- package/dist/dev-schema-watch.js.map +1 -1
- package/dist/dev-session-lock.js +4 -3
- package/dist/dev-session-lock.js.map +1 -1
- package/dist/dev-session.d.ts.map +1 -1
- package/dist/dev-session.js +3 -0
- package/dist/dev-session.js.map +1 -1
- package/dist/dev-shutdown.d.ts +45 -0
- package/dist/dev-shutdown.d.ts.map +1 -1
- package/dist/dev-shutdown.js +206 -31
- package/dist/dev-shutdown.js.map +1 -1
- package/dist/docker-address-pool.d.ts +23 -0
- package/dist/docker-address-pool.d.ts.map +1 -0
- package/dist/docker-address-pool.js +56 -0
- package/dist/docker-address-pool.js.map +1 -0
- package/dist/docker-exec.d.ts +92 -0
- package/dist/docker-exec.d.ts.map +1 -0
- package/dist/docker-exec.js +139 -0
- package/dist/docker-exec.js.map +1 -0
- package/dist/docker-postgres.d.ts +1 -6
- package/dist/docker-postgres.d.ts.map +1 -1
- package/dist/docker-postgres.js +67 -85
- package/dist/docker-postgres.js.map +1 -1
- package/dist/docker-runtime.d.ts +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/engine-answers.d.ts +0 -2
- package/dist/engine-answers.d.ts.map +1 -1
- package/dist/engine-answers.js +4 -3
- package/dist/engine-answers.js.map +1 -1
- package/dist/engine-client.d.ts.map +1 -1
- package/dist/engine-client.js +10 -12
- package/dist/engine-client.js.map +1 -1
- package/dist/engine-floor.d.ts +29 -0
- package/dist/engine-floor.d.ts.map +1 -1
- package/dist/engine-floor.js +56 -0
- package/dist/engine-floor.js.map +1 -1
- package/dist/engine-ownership-gate.d.ts +10 -0
- package/dist/engine-ownership-gate.d.ts.map +1 -1
- package/dist/engine-ownership-gate.js +31 -6
- package/dist/engine-ownership-gate.js.map +1 -1
- package/dist/ensure-binary.d.ts +9 -0
- package/dist/ensure-binary.d.ts.map +1 -1
- package/dist/ensure-binary.js +38 -5
- package/dist/ensure-binary.js.map +1 -1
- package/dist/ensure-component-binaries.d.ts.map +1 -1
- package/dist/ensure-component-binaries.js +2 -1
- package/dist/ensure-component-binaries.js.map +1 -1
- package/dist/env-file.d.ts +28 -8
- package/dist/env-file.d.ts.map +1 -1
- package/dist/env-file.js +80 -53
- package/dist/env-file.js.map +1 -1
- package/dist/env-lines.d.ts +11 -0
- package/dist/env-lines.d.ts.map +1 -0
- package/dist/env-lines.js +36 -0
- package/dist/env-lines.js.map +1 -0
- package/dist/error-message.d.ts +34 -1
- package/dist/error-message.d.ts.map +1 -1
- package/dist/error-message.js +102 -2
- package/dist/error-message.js.map +1 -1
- package/dist/fetch-within.d.ts +10 -0
- package/dist/fetch-within.d.ts.map +1 -0
- package/dist/fetch-within.js +12 -0
- package/dist/fetch-within.js.map +1 -0
- package/dist/field-masking-tier.d.ts.map +1 -1
- package/dist/field-masking-tier.js +7 -5
- package/dist/field-masking-tier.js.map +1 -1
- package/dist/functions-context-refresh.d.ts +6 -2
- package/dist/functions-context-refresh.d.ts.map +1 -1
- package/dist/functions-context-refresh.js +11 -3
- package/dist/functions-context-refresh.js.map +1 -1
- package/dist/functions-deno-types.d.ts.map +1 -1
- package/dist/functions-deno-types.js +9 -2
- package/dist/functions-deno-types.js.map +1 -1
- package/dist/{functions-router-gen.d.ts → functions-discovery.d.ts} +8 -10
- package/dist/functions-discovery.d.ts.map +1 -0
- package/dist/functions-discovery.js +87 -0
- package/dist/functions-discovery.js.map +1 -0
- package/dist/functions-template.d.ts.map +1 -1
- package/dist/functions-template.js +20 -12
- package/dist/functions-template.js.map +1 -1
- package/dist/functions-worker-files.d.ts +55 -0
- package/dist/functions-worker-files.d.ts.map +1 -0
- package/dist/functions-worker-files.js +149 -0
- package/dist/functions-worker-files.js.map +1 -0
- package/dist/generated/functions-worker-source.d.ts +2 -0
- package/dist/generated/functions-worker-source.d.ts.map +1 -0
- package/dist/generated/functions-worker-source.js +12 -0
- package/dist/generated/functions-worker-source.js.map +1 -0
- package/dist/generated/release-images.d.ts +18 -0
- package/dist/generated/release-images.d.ts.map +1 -0
- package/dist/generated/release-images.js +8 -0
- package/dist/generated/release-images.js.map +1 -0
- package/dist/generated-files-engine.d.ts +33 -0
- package/dist/generated-files-engine.d.ts.map +1 -0
- package/dist/generated-files-engine.js +45 -0
- package/dist/generated-files-engine.js.map +1 -0
- package/dist/hook-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 +7 -2
- package/dist/hooks-generator.js.map +1 -1
- package/dist/host-database.d.ts.map +1 -1
- package/dist/host-database.js +31 -4
- package/dist/host-database.js.map +1 -1
- package/dist/init-dependency-versions.d.ts +3 -1
- package/dist/init-dependency-versions.d.ts.map +1 -1
- package/dist/init-dependency-versions.js +22 -6
- package/dist/init-dependency-versions.js.map +1 -1
- package/dist/init-example.d.ts +48 -0
- package/dist/init-example.d.ts.map +1 -0
- package/dist/init-example.js +110 -0
- package/dist/init-example.js.map +1 -0
- package/dist/init-package-json.d.ts.map +1 -1
- package/dist/init-package-json.js +2 -0
- package/dist/init-package-json.js.map +1 -1
- package/dist/init-setup-steps.d.ts +37 -0
- package/dist/init-setup-steps.d.ts.map +1 -0
- package/dist/init-setup-steps.js +118 -0
- package/dist/init-setup-steps.js.map +1 -0
- package/dist/jwt-secret-length.d.ts +5 -13
- package/dist/jwt-secret-length.d.ts.map +1 -1
- package/dist/jwt-secret-length.js +7 -22
- package/dist/jwt-secret-length.js.map +1 -1
- package/dist/jwt-secret-rules.d.ts +24 -0
- package/dist/jwt-secret-rules.d.ts.map +1 -0
- package/dist/jwt-secret-rules.js +46 -0
- package/dist/jwt-secret-rules.js.map +1 -0
- package/dist/local-gateway.d.ts +3 -6
- package/dist/local-gateway.d.ts.map +1 -1
- package/dist/local-gateway.js +7 -9
- package/dist/local-gateway.js.map +1 -1
- package/dist/local-secrets.d.ts +95 -11
- package/dist/local-secrets.d.ts.map +1 -1
- package/dist/local-secrets.js +153 -18
- package/dist/local-secrets.js.map +1 -1
- package/dist/local-stack.d.ts.map +1 -1
- package/dist/local-stack.js +2 -7
- package/dist/local-stack.js.map +1 -1
- package/dist/local-storage.d.ts +7 -2
- package/dist/local-storage.d.ts.map +1 -1
- package/dist/local-storage.js +11 -3
- package/dist/local-storage.js.map +1 -1
- package/dist/mailer-env.d.ts +37 -0
- package/dist/mailer-env.d.ts.map +1 -0
- package/dist/mailer-env.js +98 -0
- package/dist/mailer-env.js.map +1 -0
- package/dist/model-cache.d.ts +4 -8
- package/dist/model-cache.d.ts.map +1 -1
- package/dist/model-cache.js.map +1 -1
- package/dist/model-hooks.d.ts +17 -7
- package/dist/model-hooks.d.ts.map +1 -1
- package/dist/model-hooks.js +52 -39
- package/dist/model-hooks.js.map +1 -1
- package/dist/native-dev-env.d.ts +37 -1
- package/dist/native-dev-env.d.ts.map +1 -1
- package/dist/native-dev-env.js +64 -2
- package/dist/native-dev-env.js.map +1 -1
- package/dist/native-functions-watch.d.ts +56 -5
- package/dist/native-functions-watch.d.ts.map +1 -1
- package/dist/native-functions-watch.js +119 -38
- package/dist/native-functions-watch.js.map +1 -1
- package/dist/native-keyspace.d.ts.map +1 -1
- package/dist/native-keyspace.js +2 -2
- package/dist/native-keyspace.js.map +1 -1
- package/dist/native-realtime.d.ts +11 -3
- package/dist/native-realtime.d.ts.map +1 -1
- package/dist/native-realtime.js +162 -10
- package/dist/native-realtime.js.map +1 -1
- package/dist/native-roles-sql.d.ts +14 -0
- package/dist/native-roles-sql.d.ts.map +1 -1
- package/dist/native-roles-sql.js +82 -1
- package/dist/native-roles-sql.js.map +1 -1
- package/dist/native-storage-import.d.ts +19 -0
- package/dist/native-storage-import.d.ts.map +1 -0
- package/dist/native-storage-import.js +327 -0
- package/dist/native-storage-import.js.map +1 -0
- package/dist/native-storage.d.ts +45 -0
- package/dist/native-storage.d.ts.map +1 -0
- package/dist/native-storage.js +140 -0
- package/dist/native-storage.js.map +1 -0
- package/dist/native-worker.d.ts +26 -0
- package/dist/native-worker.d.ts.map +1 -0
- package/dist/native-worker.js +63 -0
- package/dist/native-worker.js.map +1 -0
- package/dist/owner-default.d.ts +9 -1
- package/dist/owner-default.d.ts.map +1 -1
- package/dist/owner-default.js +17 -4
- package/dist/owner-default.js.map +1 -1
- package/dist/post-apply.d.ts +3 -0
- package/dist/post-apply.d.ts.map +1 -0
- package/dist/post-apply.js +17 -0
- package/dist/post-apply.js.map +1 -0
- package/dist/postgres-ctl.d.ts +98 -7
- package/dist/postgres-ctl.d.ts.map +1 -1
- package/dist/postgres-ctl.js +273 -40
- package/dist/postgres-ctl.js.map +1 -1
- package/dist/postgres-image.d.ts +15 -3
- package/dist/postgres-image.d.ts.map +1 -1
- package/dist/postgres-image.js +18 -15
- package/dist/postgres-image.js.map +1 -1
- package/dist/postgrest-release.d.ts +9 -0
- package/dist/postgrest-release.d.ts.map +1 -1
- package/dist/postgrest-release.js +23 -0
- package/dist/postgrest-release.js.map +1 -1
- package/dist/process-manager.d.ts.map +1 -1
- package/dist/process-manager.js +3 -1
- package/dist/process-manager.js.map +1 -1
- package/dist/project-config.d.ts +40 -7
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +42 -4
- package/dist/project-config.js.map +1 -1
- package/dist/pull-utils.d.ts +15 -0
- package/dist/pull-utils.d.ts.map +1 -1
- package/dist/pull-utils.js +149 -23
- package/dist/pull-utils.js.map +1 -1
- package/dist/push-refusal.d.ts.map +1 -1
- package/dist/push-refusal.js +3 -2
- package/dist/push-refusal.js.map +1 -1
- package/dist/realtime-launch.d.ts +2 -5
- package/dist/realtime-launch.d.ts.map +1 -1
- package/dist/realtime-launch.js +6 -23
- package/dist/realtime-launch.js.map +1 -1
- package/dist/recorded-field-masking-tier.d.ts.map +1 -1
- package/dist/recorded-field-masking-tier.js +4 -3
- package/dist/recorded-field-masking-tier.js.map +1 -1
- package/dist/release-images.d.ts +31 -0
- package/dist/release-images.d.ts.map +1 -0
- package/dist/release-images.js +90 -0
- package/dist/release-images.js.map +1 -0
- package/dist/required-host-components.d.ts.map +1 -1
- package/dist/required-host-components.js +4 -0
- package/dist/required-host-components.js.map +1 -1
- package/dist/resolve-api-url.d.ts +17 -3
- package/dist/resolve-api-url.d.ts.map +1 -1
- package/dist/resolve-api-url.js +71 -30
- package/dist/resolve-api-url.js.map +1 -1
- package/dist/resolve-target.d.ts +62 -0
- package/dist/resolve-target.d.ts.map +1 -1
- package/dist/resolve-target.js +68 -23
- package/dist/resolve-target.js.map +1 -1
- package/dist/rest-ready.d.ts.map +1 -1
- package/dist/rest-ready.js +2 -1
- package/dist/rest-ready.js.map +1 -1
- package/dist/route-manifest.d.ts +25 -2
- package/dist/route-manifest.d.ts.map +1 -1
- package/dist/route-manifest.js +48 -4
- package/dist/route-manifest.js.map +1 -1
- package/dist/run-until-stopped.d.ts +12 -0
- package/dist/run-until-stopped.d.ts.map +1 -0
- package/dist/run-until-stopped.js +42 -0
- package/dist/run-until-stopped.js.map +1 -0
- package/dist/schema-ast-v2.d.ts +2 -1
- package/dist/schema-ast-v2.d.ts.map +1 -1
- package/dist/schema-ast-v2.js.map +1 -1
- package/dist/schema-push-lock.d.ts.map +1 -1
- package/dist/schema-push-lock.js +59 -46
- package/dist/schema-push-lock.js.map +1 -1
- package/dist/schema-sources.d.ts +19 -4
- package/dist/schema-sources.d.ts.map +1 -1
- package/dist/schema-sources.js +56 -35
- package/dist/schema-sources.js.map +1 -1
- package/dist/seed-auth-connect.d.ts +14 -0
- package/dist/seed-auth-connect.d.ts.map +1 -0
- package/dist/seed-auth-connect.js +97 -0
- package/dist/seed-auth-connect.js.map +1 -0
- package/dist/seed-runner.d.ts.map +1 -1
- package/dist/seed-runner.js +22 -1
- package/dist/seed-runner.js.map +1 -1
- package/dist/seed.d.ts +6 -3
- package/dist/seed.d.ts.map +1 -1
- package/dist/self-host-compose.d.ts +32 -30
- package/dist/self-host-compose.d.ts.map +1 -1
- package/dist/self-host-compose.js +252 -152
- package/dist/self-host-compose.js.map +1 -1
- package/dist/service-role-key-file.d.ts +32 -0
- package/dist/service-role-key-file.d.ts.map +1 -0
- package/dist/service-role-key-file.js +90 -0
- package/dist/service-role-key-file.js.map +1 -0
- package/dist/shell-ports.d.ts +13 -2
- package/dist/shell-ports.d.ts.map +1 -1
- package/dist/shell-ports.js +18 -7
- package/dist/shell-ports.js.map +1 -1
- package/dist/stop-signals.d.ts +7 -0
- package/dist/stop-signals.d.ts.map +1 -0
- package/dist/stop-signals.js +12 -0
- package/dist/stop-signals.js.map +1 -0
- package/dist/storage-launch.d.ts +11 -0
- package/dist/storage-launch.d.ts.map +1 -0
- package/dist/storage-launch.js +41 -0
- package/dist/storage-launch.js.map +1 -0
- package/dist/storage-provision.d.ts +50 -5
- package/dist/storage-provision.d.ts.map +1 -1
- package/dist/storage-provision.js +101 -33
- package/dist/storage-provision.js.map +1 -1
- package/dist/systemd.d.ts +1 -1
- package/dist/systemd.d.ts.map +1 -1
- package/dist/systemd.js +26 -11
- package/dist/systemd.js.map +1 -1
- package/dist/tar-reader.d.ts +29 -0
- package/dist/tar-reader.d.ts.map +1 -0
- package/dist/tar-reader.js +99 -0
- package/dist/tar-reader.js.map +1 -0
- package/dist/target-client.d.ts +14 -1
- package/dist/target-client.d.ts.map +1 -1
- package/dist/target-client.js +134 -23
- package/dist/target-client.js.map +1 -1
- package/dist/target-request.d.ts +25 -0
- package/dist/target-request.d.ts.map +1 -0
- package/dist/target-request.js +33 -0
- package/dist/target-request.js.map +1 -0
- package/dist/target-warning.d.ts +7 -0
- package/dist/target-warning.d.ts.map +1 -0
- package/dist/target-warning.js +12 -0
- package/dist/target-warning.js.map +1 -0
- package/dist/type-extractor.d.ts +6 -0
- package/dist/type-extractor.d.ts.map +1 -1
- package/dist/type-extractor.js +118 -59
- package/dist/type-extractor.js.map +1 -1
- package/dist/ui/clack.d.ts.map +1 -1
- package/dist/ui/clack.js +11 -1
- package/dist/ui/clack.js.map +1 -1
- package/dist/ui/dev/DevDashboard.d.ts.map +1 -1
- package/dist/ui/dev/DevDashboard.js +4 -2
- package/dist/ui/dev/DevDashboard.js.map +1 -1
- package/dist/ui/fatal.d.ts.map +1 -1
- package/dist/ui/fatal.js +6 -7
- package/dist/ui/fatal.js.map +1 -1
- package/dist/ui/flows/FlowApp.d.ts.map +1 -1
- package/dist/ui/flows/FlowApp.js +16 -1
- package/dist/ui/flows/FlowApp.js.map +1 -1
- package/dist/ui/flows/prompt-fields.d.ts +5 -0
- package/dist/ui/flows/prompt-fields.d.ts.map +1 -1
- package/dist/ui/flows/prompt-fields.js +8 -1
- package/dist/ui/flows/prompt-fields.js.map +1 -1
- package/dist/ui/messages.d.ts +6 -0
- package/dist/ui/messages.d.ts.map +1 -1
- package/dist/ui/messages.js +17 -0
- package/dist/ui/messages.js.map +1 -1
- package/dist/ui/progress.d.ts +7 -0
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +22 -8
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/runtime/command-chrome.d.ts.map +1 -1
- package/dist/ui/runtime/command-chrome.js +2 -0
- package/dist/ui/runtime/command-chrome.js.map +1 -1
- package/dist/ui/runtime/prompt-interrupt.d.ts +10 -0
- package/dist/ui/runtime/prompt-interrupt.d.ts.map +1 -0
- package/dist/ui/runtime/prompt-interrupt.js +24 -0
- package/dist/ui/runtime/prompt-interrupt.js.map +1 -0
- package/dist/ui/runtime/run-clack-flow.d.ts.map +1 -1
- package/dist/ui/runtime/run-clack-flow.js +5 -2
- package/dist/ui/runtime/run-clack-flow.js.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts +14 -1
- package/dist/ui/runtime/stdin-after-ink.d.ts.map +1 -1
- package/dist/ui/runtime/stdin-after-ink.js +44 -3
- package/dist/ui/runtime/stdin-after-ink.js.map +1 -1
- package/dist/url-safe-passwords.d.ts +25 -0
- package/dist/url-safe-passwords.d.ts.map +1 -0
- package/dist/url-safe-passwords.js +70 -0
- package/dist/url-safe-passwords.js.map +1 -0
- package/dist/valkey-sidecar.d.ts +33 -6
- package/dist/valkey-sidecar.d.ts.map +1 -1
- package/dist/valkey-sidecar.js +90 -61
- package/dist/valkey-sidecar.js.map +1 -1
- package/dist/worker-module-files.d.ts +3 -0
- package/dist/worker-module-files.d.ts.map +1 -0
- package/dist/worker-module-files.js +18 -0
- package/dist/worker-module-files.js.map +1 -0
- package/package.json +9 -6
- package/dist/functions-router-gen.d.ts.map +0 -1
- package/dist/functions-router-gen.js +0 -302
- package/dist/functions-router-gen.js.map +0 -1
package/dist/commands/dev.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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
|
-
* docker: full self-host Compose stack (Kong
|
|
5
|
+
* docker: full self-host Compose stack (Kong on SUPATYPE_KONG_PORT); see dev-compose.ts (default)
|
|
6
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
|
|
@@ -14,94 +14,87 @@ import { errorMessage } from "../error-message.js";
|
|
|
14
14
|
import { isDiffResult, isEnginePushResult } from "../engine-answers.js";
|
|
15
15
|
import { reportDevPushFailure } from "../push-refusal.js";
|
|
16
16
|
import { spawnSync } from "node:child_process";
|
|
17
|
-
import { existsSync, mkdirSync,
|
|
18
|
-
import { join,
|
|
19
|
-
import {
|
|
20
|
-
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";
|
|
21
23
|
import { readJsonFile } from "../json-file.js";
|
|
22
24
|
import { isArrayOf, isJsonObject } from "@supatype/shared";
|
|
23
|
-
import { pgSchema,
|
|
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";
|
|
24
26
|
import { DEV_DB_PORT_ENV } from "../db-port.js";
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
+
import { devServiceRoleRoutesPath, functionsWorkerEnv, writeServiceRoleRoutesFile } from "../functions-worker-files.js";
|
|
28
|
+
import { devServiceRoleKeyPath } from "../service-role-key-file.js";
|
|
27
29
|
import { requireUsableJwtSecret } from "../jwt-secret-length.js";
|
|
28
|
-
import { ensureNativeAuthenticatorPassword, devJwtSecret, ensureNativeSuperuserPassword, secretFingerprint, } from "../local-secrets.js";
|
|
30
|
+
import { ensureNativeAuthenticatorPassword, devJwtSecret, ensureNativeSuperuserPassword, givenJwtSecret, ignoredJwtSecretWarning, secretFingerprint, } from "../local-secrets.js";
|
|
29
31
|
import { normalisePlatformPath, cachePath, currentPlatform, hasMeaningfulOverrides, describeActiveOverrides, postgresArchiveTag, } from "../binary-cache.js";
|
|
30
32
|
import { ensureBinary } from "../ensure-binary.js";
|
|
31
33
|
import { assertSupported, binaryCapabilities, EngineProbeFailed, OVERWRITE_DRIFT_NEED, OwnershipUnsupportedError, requireEngineFeatures, } from "../engine-ownership-gate.js";
|
|
32
34
|
import { startProxyDevApp } from "../app/proxy-dev-app.js";
|
|
33
35
|
import { ProcessManager } from "../process-manager.js";
|
|
34
|
-
import { POSTGREST_VERSION, postgrestArchiveName, postgrestArchiveUrl } from "../postgrest-release.js";
|
|
36
|
+
import { markPostgrestUnpacked, POSTGREST_VERSION, postgrestArchiveName, postgrestArchiveUrl, postgrestRuntimeRepairDue, } from "../postgrest-release.js";
|
|
35
37
|
import { STUDIO_DEV_PORT, startStudioViteDevServer } from "../studio-dev-server.js";
|
|
36
38
|
import { restoreSystemRelationTargets } from "../restore-system-relation-targets.js";
|
|
37
|
-
import { localStorageEnv } from "../local-storage.js";
|
|
38
39
|
import { beginDevSession, resolveDevUiMode } from "../dev-session.js";
|
|
39
40
|
import { publishDevReady } from "../dev-ready-panel.js";
|
|
40
41
|
import { probeDockerDaemon, reportDockerUnavailable } from "../docker-runtime.js";
|
|
41
42
|
import { fatalError } from "../ui/fatal.js";
|
|
42
|
-
import { registerDevShutdown, waitForDevShutdown } from "../dev-shutdown.js";
|
|
43
|
+
import { haltIfStopping, pushStartUndo, pushStartUndoLast, registerDevShutdown, reportUnlessStopping, stopQuietlyDuringStart, waitForDevShutdown, } from "../dev-shutdown.js";
|
|
43
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";
|
|
44
53
|
import { writeAppViteEnv } from "../app-vite-env.js";
|
|
45
54
|
import { nativeAuthProviderEnv, warnMissingAuthProviderSecrets } from "../auth-providers.js";
|
|
46
|
-
import { nativeMailerAutoconfirmEnv } from "../mailer-autoconfirm.js";
|
|
47
55
|
import { AUTHENTICATOR_PASSWORD_ENV } from "../native-roles-sql.js";
|
|
48
|
-
import { nativeDevRolesSql, nativePostgrestSchemaEnv, nativeServerCoreEnv } from "../native-dev-env.js";
|
|
49
|
-
import { ensureValkeySidecar,
|
|
56
|
+
import { nativeAuthMailerEnv, nativeDevApiKeys, nativeDevRolesSql, nativePostgrestSchemaEnv, nativeServerCoreEnv, nativeServerDotEnvLayer, } from "../native-dev-env.js";
|
|
57
|
+
import { ensureValkeySidecar, externalValkey } from "../valkey-sidecar.js";
|
|
50
58
|
import { nativeKeyspaceAddr as nativeKeyspaceAddrFor, nativeKeyspacePort } from "../native-keyspace.js";
|
|
51
|
-
import {
|
|
59
|
+
import { ensureCluster, createdbArgs, databaseEncoding, nonUtf8DatabaseWarning, pgBuild, start as pgStart, stop as pgStop, waitReady as pgWaitReady, isPortInUse, } from "../postgres-ctl.js";
|
|
52
60
|
import { isPasswordRejected, pgClientEnv, requirePasswordAuth, requireSuperuserPassword, superuserPasswordMissingMessage, } from "../native-pg-auth.js";
|
|
53
|
-
/** Map `email.smtp` from supatype.config.ts into SUPATYPE_SMTP_* for the embedded auth service. */
|
|
54
|
-
function authSMTPFromEmailConfig(email) {
|
|
55
|
-
const s = email?.smtp;
|
|
56
|
-
if (!s)
|
|
57
|
-
return {};
|
|
58
|
-
const out = {};
|
|
59
|
-
const host = s.host?.trim();
|
|
60
|
-
if (host)
|
|
61
|
-
out.SUPATYPE_SMTP_HOST = host;
|
|
62
|
-
if (s.port !== undefined)
|
|
63
|
-
out.SUPATYPE_SMTP_PORT = String(s.port);
|
|
64
|
-
const user = s.user?.trim();
|
|
65
|
-
if (user)
|
|
66
|
-
out.SUPATYPE_SMTP_USER = user;
|
|
67
|
-
if (s.pass !== undefined && s.pass !== "")
|
|
68
|
-
out.SUPATYPE_SMTP_PASS = s.pass;
|
|
69
|
-
const admin = s.admin_email?.trim();
|
|
70
|
-
if (admin)
|
|
71
|
-
out.SUPATYPE_SMTP_ADMIN_EMAIL = admin;
|
|
72
|
-
const sender = s.sender_name?.trim();
|
|
73
|
-
if (sender)
|
|
74
|
-
out.SUPATYPE_SMTP_SENDER_NAME = sender;
|
|
75
|
-
return out;
|
|
76
|
-
}
|
|
77
61
|
function portCheckCommand(port) {
|
|
78
62
|
return process.platform === "win32"
|
|
79
63
|
? `netstat -ano | findstr :${port}`
|
|
80
64
|
: `lsof -i :${port}`;
|
|
81
65
|
}
|
|
82
|
-
const NATIVE_SERVICES = ["postgres", "server", "postgrest", "realtime"];
|
|
83
|
-
const NATIVE_PORT_HINTS = {
|
|
66
|
+
const NATIVE_SERVICES = ["postgres", "server", "postgrest", "realtime", "deno", "storage"];
|
|
67
|
+
export const NATIVE_PORT_HINTS = {
|
|
84
68
|
postgres: {
|
|
85
69
|
holder: "Another Postgres instance may be running.",
|
|
86
|
-
move: `Move this project's with ${DEV_DB_PORT_ENV} in .env, or database.port in supatype.config.ts.`,
|
|
70
|
+
move: `Move this project's database port with ${DEV_DB_PORT_ENV} in .env, or database.port in supatype.config.ts.`,
|
|
87
71
|
},
|
|
88
72
|
server: {
|
|
89
73
|
holder: "Another supatype-server may be running.",
|
|
90
|
-
move: "Move this project's with server.port in supatype.config.ts, or `supatype dev --port`.",
|
|
74
|
+
move: "Move this project's API server port with server.port in supatype.config.ts, or `supatype dev --port`.",
|
|
91
75
|
},
|
|
92
76
|
postgrest: {
|
|
93
77
|
holder: "Another service may be running.",
|
|
94
|
-
move: "Move this project's with server.postgrestPort in supatype.config.ts.",
|
|
78
|
+
move: "Move this project's PostgREST port with server.postgrestPort in supatype.config.ts.",
|
|
95
79
|
},
|
|
96
80
|
realtime: {
|
|
97
81
|
holder: "Another realtime service, or any app on this port, may be running.",
|
|
98
|
-
move: `Move this project's with ${REALTIME_PORT_ENV} in .env, or server.realtimePort in supatype.config.ts.`,
|
|
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.`,
|
|
99
91
|
},
|
|
100
92
|
};
|
|
101
|
-
|
|
93
|
+
/** Stop before anything starts when a port native dev binds is taken. Exported for tests. */
|
|
94
|
+
export async function assertNativeDevPortsFree(ports) {
|
|
102
95
|
for (const service of NATIVE_SERVICES) {
|
|
103
96
|
const port = ports[service];
|
|
104
|
-
if (!(await isPortInUse(port)))
|
|
97
|
+
if (port === undefined || !(await isPortInUse(port)))
|
|
105
98
|
continue;
|
|
106
99
|
const { holder, move } = NATIVE_PORT_HINTS[service];
|
|
107
100
|
fatalError(`Port ${port} is already in use.`, [holder, `Check: ${portCheckCommand(port)}`, move], {
|
|
@@ -140,9 +133,12 @@ export function registerDev(program) {
|
|
|
140
133
|
.option("--reset-db", "Remove the local Postgres data volume before starting (asks first; storage is kept)")
|
|
141
134
|
.option("--yes", "Skip the --reset-db confirmation")
|
|
142
135
|
.option("--overwrite-drift", "Every push of this session puts back policies, grants, labels and RLS changed outside Supatype")
|
|
143
|
-
|
|
136
|
+
// Ctrl+C during the start reaches its children too: it ends with one line, not their failure.
|
|
137
|
+
.action(stopQuietlyDuringStart(async (opts) => {
|
|
144
138
|
const cwd = process.cwd();
|
|
145
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);
|
|
146
142
|
const config = loadConfig(cwd);
|
|
147
143
|
const provider = resolveRuntimeProvider(config);
|
|
148
144
|
// The native provider keeps Postgres in a data directory, not a compose volume, and has
|
|
@@ -160,16 +156,21 @@ export function registerDev(program) {
|
|
|
160
156
|
}
|
|
161
157
|
}
|
|
162
158
|
const projectName = config.project.name;
|
|
163
|
-
const serverPort = opts.port ?? String(config
|
|
159
|
+
const serverPort = opts.port ?? String(nativeServerPort(config));
|
|
164
160
|
const postgrestPort = String(config.server.postgrestPort ?? 3001);
|
|
165
161
|
const pgPort = nativeDbPort(config, cwd);
|
|
166
162
|
const realtimePort = String(nativeRealtimePort(config, cwd));
|
|
163
|
+
const denoPort = nativeDenoPort(cwd);
|
|
164
|
+
const storagePort = nativeStoragePort(cwd);
|
|
167
165
|
if (provider !== "docker") {
|
|
166
|
+
// The functions worker runs on every native dev (native-worker.ts), so Deno's port is checked too.
|
|
168
167
|
await assertNativeDevPortsFree({
|
|
169
168
|
postgres: pgPort,
|
|
170
169
|
server: Number(serverPort),
|
|
171
170
|
postgrest: Number(postgrestPort),
|
|
172
171
|
realtime: Number(realtimePort),
|
|
172
|
+
deno: denoPort,
|
|
173
|
+
...(keepsObjectsLocally(config) && { storage: storagePort }),
|
|
173
174
|
});
|
|
174
175
|
// Before anything is generated: a missing password would otherwise be replaced in .env
|
|
175
176
|
// with a new one the existing cluster has never heard of.
|
|
@@ -179,6 +180,11 @@ export function registerDev(program) {
|
|
|
179
180
|
const overwriteDrift = opts.overwriteDrift === true;
|
|
180
181
|
if (overwriteDrift)
|
|
181
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);
|
|
182
188
|
beginDevSession(resolveDevUiMode(opts.stream === true));
|
|
183
189
|
if (hasMeaningfulOverrides(config)) {
|
|
184
190
|
console.warn("[supatype] Local binary overrides active:");
|
|
@@ -187,9 +193,17 @@ export function registerDev(program) {
|
|
|
187
193
|
}
|
|
188
194
|
console.warn("");
|
|
189
195
|
}
|
|
190
|
-
// Both providers, before anything starts
|
|
191
|
-
//
|
|
192
|
-
|
|
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}`);
|
|
193
207
|
if (provider === "docker") {
|
|
194
208
|
const { runDevCompose } = await import("../dev-compose.js");
|
|
195
209
|
await runDevCompose(cwd, config, {
|
|
@@ -218,7 +232,6 @@ export function registerDev(program) {
|
|
|
218
232
|
let dbURL;
|
|
219
233
|
/** What PostgREST connects as, deliberately not `dbURL`, which is a superuser. */
|
|
220
234
|
let postgrestDbURL;
|
|
221
|
-
let stopPostgres;
|
|
222
235
|
// Checked by the cluster (native-pg-auth.ts): .env's, or generated and written there.
|
|
223
236
|
const pgPassword = ensureNativeSuperuserPassword(cwd);
|
|
224
237
|
// Distinct from pgPassword even locally, so the split the other paths enforce is the
|
|
@@ -247,42 +260,34 @@ export function registerDev(program) {
|
|
|
247
260
|
dataDir,
|
|
248
261
|
port: pgPort,
|
|
249
262
|
logPath: join(logsDir, "postgres.log"),
|
|
263
|
+
database: projectName,
|
|
250
264
|
...(keyspacePort !== null
|
|
251
265
|
? { keyspacePort, keyspaceDatabase: projectName }
|
|
252
266
|
: {}),
|
|
253
267
|
};
|
|
254
|
-
|
|
255
|
-
|
|
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);
|
|
256
272
|
console.log("[supatype] Starting Postgres...");
|
|
257
273
|
pgStart(pgOpts);
|
|
274
|
+
pushStartUndoLast(() => pgStop(pgOpts, { quiet: true }));
|
|
258
275
|
await pgWaitReady(pgOpts, 15_000);
|
|
259
276
|
console.log("[supatype] Postgres is ready.");
|
|
277
|
+
// Between start steps: once a Ctrl+C has begun the shutdown, nothing more is started.
|
|
278
|
+
await haltIfStopping();
|
|
260
279
|
if (requirePasswordAuth(pgOpts, pgPassword)) {
|
|
261
280
|
console.log("[supatype] This Postgres trusted every local connection; it now checks passwords.");
|
|
262
281
|
}
|
|
263
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);
|
|
264
286
|
postgrestDbURL = `postgres://authenticator:${encodeURIComponent(authenticatorPassword)}@127.0.0.1:${pgPort}/${projectName}?sslmode=disable`;
|
|
265
|
-
stopPostgres = () => pgStop(pgOpts);
|
|
266
|
-
// Create project database if it doesn't exist (native only).
|
|
267
287
|
const psqlBin = join(pgBinDir, process.platform === "win32" ? "psql.exe" : "psql");
|
|
268
|
-
const createdbBin = join(pgBinDir, process.platform === "win32" ? "createdb.exe" : "createdb");
|
|
269
288
|
const pgConnArgs = ["-h", "127.0.0.1", "-p", String(pgPort), "-U", "postgres"];
|
|
270
289
|
const pgEnv = pgClientEnv(pgBinDir, pgPassword);
|
|
271
|
-
|
|
272
|
-
if (createDbResult.status !== 0) {
|
|
273
|
-
const stderr = createDbResult.stderr ?? "";
|
|
274
|
-
// A POSTGRES_PASSWORD changed by hand reaches here; a deleted one was stopped earlier.
|
|
275
|
-
if (isPasswordRejected(stderr)) {
|
|
276
|
-
const { title, hints } = superuserPasswordMissingMessage(dataDir);
|
|
277
|
-
throw new Error([title, ...hints].join("\n "));
|
|
278
|
-
}
|
|
279
|
-
if (!stderr.includes("already exists")) {
|
|
280
|
-
throw new Error(`Failed to create database "${projectName}": ${stderr}`);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
console.log(`[supatype] Created database "${projectName}".`);
|
|
285
|
-
}
|
|
290
|
+
ensureProjectDatabase({ binDir: pgBinDir, connArgs: pgConnArgs, env: pgEnv, dataDir, name: projectName, build: buildOnce });
|
|
286
291
|
// Create roles required by PostgREST and grant them to postgres so
|
|
287
292
|
// PostgREST can SET ROLE when processing requests.
|
|
288
293
|
// anon – unauthenticated requests (RLS enforced)
|
|
@@ -322,82 +327,58 @@ export function registerDev(program) {
|
|
|
322
327
|
console.log("[supatype] Running auth migrations...");
|
|
323
328
|
const migrateEnv = authMigrateEnv(serverPort, dbURL, LOCAL_JWT_SECRET);
|
|
324
329
|
runAuthMigrations(serverBin, migrateEnv);
|
|
330
|
+
await haltIfStopping();
|
|
325
331
|
// ── 9. Engine: apply schema ───────────────────────────────────────────
|
|
326
332
|
const schemaPath = schemaPathFromProject(config, cwd);
|
|
327
333
|
const supatypeDir = join(cwd, ".supatype");
|
|
328
334
|
const manifestPath = join(supatypeDir, "manifest.json");
|
|
329
335
|
const adminConfigPath = join(supatypeDir, "admin-config.json");
|
|
330
336
|
mkdirSync(supatypeDir, { recursive: true });
|
|
331
|
-
const localStoragePath = config
|
|
337
|
+
const localStoragePath = keepsObjectsLocally(config) ? serverStoreRoot(stateRoot) : undefined;
|
|
332
338
|
// Native Postgres builds don't include PostGIS, skip geo fields rather than failing.
|
|
333
339
|
const skipFieldKinds = new Set(["geo", "vector"]);
|
|
334
|
-
|
|
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();
|
|
335
346
|
const { ensureFirstAdminUser } = await import("./admin.js");
|
|
336
347
|
await ensureFirstAdminUser(dbURL, { cwd });
|
|
337
348
|
// ── 10. Spawn supatype-server ─────────────────────────────────────────
|
|
338
|
-
//
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
? discoverFunctionsOrExit(functionsDir)
|
|
345
|
-
: [];
|
|
346
|
-
const denoServeScriptAbs = hasFunctionsDir && functionsDir !== undefined
|
|
347
|
-
? (writeDevFunctionsRouter(cwd, functionsDir, functionRoutes) ?? "")
|
|
348
|
-
: "";
|
|
349
|
-
let denoBinPath;
|
|
350
|
-
if (hasFunctionsDir) {
|
|
351
|
-
console.log(`[supatype] Edge functions enabled (${functionsDir})`);
|
|
352
|
-
try {
|
|
353
|
-
denoBinPath = await ensureBinary("deno", config);
|
|
354
|
-
const denoVersion = await (await import("../binary-cache.js")).resolveVersionFor("deno", config);
|
|
355
|
-
console.log(`[supatype] Deno runtime: ${denoBinPath} (v${denoVersion})`);
|
|
356
|
-
if (functionRoutes.length > 0) {
|
|
357
|
-
console.log(`[supatype] Edge functions router: ${relative(cwd, denoServeScriptAbs) || ".supatype/functions-router.ts"} ` +
|
|
358
|
-
`(${functionRoutes.length} function(s): ${functionRoutes.map(fn => fn.name).join(", ")})`);
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
console.log("[supatype] Edge functions router not generated (no handler files discovered yet)");
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
catch (err) {
|
|
365
|
-
console.warn(`[supatype] ⚠ Found ${functionsDir} but could not provision Deno, edge functions will not run.\n` +
|
|
366
|
-
` ${errorMessage(err)}\n` +
|
|
367
|
-
" (Functions still appear in Studio; invocations need Deno.)");
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
// Matches SUPATYPE_HOOK_SEND_EMAIL_SECRETS symmetric format (dev only). Override via .env.
|
|
371
|
-
const LOCAL_SEND_EMAIL_HOOK_SECRETS = "v1,whsec_abcdefghijklmnopqrstuvwxyz01234567";
|
|
372
|
-
const now = Math.floor(Date.now() / 1000);
|
|
373
|
-
const jwtBase = { iss: "supatype", iat: now, exp: now + 315_360_000 };
|
|
374
|
-
const anonKey = signJwt({ ...jwtBase, role: "anon" }, LOCAL_JWT_SECRET);
|
|
375
|
-
const serviceRoleKey = signJwt({ ...jwtBase, role: "service_role" }, LOCAL_JWT_SECRET);
|
|
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);
|
|
376
355
|
const realtimeUrl = `http://127.0.0.1:${realtimePort}`;
|
|
377
356
|
writeAppViteEnv(cwd, config, `http://localhost:${serverPort}`, anonKey);
|
|
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);
|
|
378
361
|
const realtimeProc = await startNativeRealtime({
|
|
379
362
|
config, cwd, manifestPath, pidDir, url: realtimeUrl, port: realtimePort,
|
|
380
363
|
databaseUrl: dbURL, jwtSecret: LOCAL_JWT_SECRET,
|
|
381
364
|
});
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
console.log(`[supatype] Keyspace served by Postgres (${nativeKeyspaceAddr}).`);
|
|
394
|
-
}
|
|
395
|
-
const valkeySidecar = nativeKeyspaceAddr
|
|
396
|
-
? { addr: nativeKeyspaceAddr, containerName: null, started: false }
|
|
397
|
-
: ensureValkeySidecar(projectName);
|
|
365
|
+
const nativeStorage = keepsObjectsLocally(config)
|
|
366
|
+
? await startNativeStorage({
|
|
367
|
+
config, cwd, manifestPath, pidDir, stateRoot, port: storagePort, databaseUrl: dbURL, jwtSecret: LOCAL_JWT_SECRET,
|
|
368
|
+
})
|
|
369
|
+
: null;
|
|
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);
|
|
398
376
|
// What an env("NAME") in auth.providers resolves against: the shell over .env, as for the config.
|
|
399
|
-
const providerEnvironment = { ...
|
|
377
|
+
const providerEnvironment = { ...dotEnv, ...process.env };
|
|
400
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);
|
|
401
382
|
const serverEnv = {
|
|
402
383
|
...nativeServerCoreEnv({
|
|
403
384
|
mode: config.server.mode ?? "dev",
|
|
@@ -409,12 +390,16 @@ export function registerDev(program) {
|
|
|
409
390
|
pgBinDir,
|
|
410
391
|
databaseUrl: dbURL,
|
|
411
392
|
}),
|
|
412
|
-
SUPATYPE_DENO_FUNCTIONS_DIR:
|
|
413
|
-
...(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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,
|
|
418
403
|
SUPATYPE_URL: `http://localhost:${serverPort}`,
|
|
419
404
|
// Natively the server is the gateway, so the address functions call is the one a browser
|
|
420
405
|
// opens. The server passes its environment on to the Deno child that runs them.
|
|
@@ -444,46 +429,18 @@ export function registerDev(program) {
|
|
|
444
429
|
SUPATYPE_JWT_EXP: "3600",
|
|
445
430
|
SUPATYPE_JWT_AUD: "authenticated",
|
|
446
431
|
SUPATYPE_JWT_ADMIN_ROLES: "supatype_admin,service_role",
|
|
447
|
-
SUPATYPE_API_EXTERNAL_URL: `http://localhost:${serverPort}/auth/v1`,
|
|
448
432
|
SUPATYPE_API_HOST: "localhost",
|
|
449
433
|
SUPATYPE_SITE_URL: `http://localhost:${serverPort}`,
|
|
450
|
-
|
|
434
|
+
// External URL, mailer provider, emailed-link paths and the send-email hook.
|
|
435
|
+
...nativeAuthMailerEnv(config.email, serverPort),
|
|
451
436
|
SUPATYPE_LOG_LEVEL: "info",
|
|
452
437
|
SUPATYPE_DISABLE_SIGNUP: "false",
|
|
453
|
-
...(
|
|
454
|
-
? { RESEND_API_KEY: config.email.resend_api_key }
|
|
455
|
-
: {}),
|
|
456
|
-
...(authMailerProvider === "resend" &&
|
|
457
|
-
config.email?.resend_from !== undefined &&
|
|
458
|
-
config.email.resend_from.trim() !== ""
|
|
459
|
-
? { RESEND_FROM: config.email.resend_from.trim() }
|
|
460
|
-
: {}),
|
|
461
|
-
...(authMailerProvider === "ses" &&
|
|
462
|
-
config.email?.ses_from !== undefined &&
|
|
463
|
-
config.email.ses_from.trim() !== ""
|
|
464
|
-
? { SES_FROM: config.email.ses_from.trim() }
|
|
465
|
-
: {}),
|
|
466
|
-
...(authMailerProvider === "smtp" ? authSMTPFromEmailConfig(config.email) : {}),
|
|
467
|
-
...(config.email?.send_email_hook === true
|
|
468
|
-
? {
|
|
469
|
-
SUPATYPE_HOOK_SEND_EMAIL_ENABLED: "true",
|
|
470
|
-
SUPATYPE_HOOK_SEND_EMAIL_URI: config.email?.send_email_hook_uri !== undefined &&
|
|
471
|
-
config.email.send_email_hook_uri.trim() !== ""
|
|
472
|
-
? config.email.send_email_hook_uri.trim()
|
|
473
|
-
: `http://127.0.0.1:${serverPort}/internal/v0hooks/send-email`,
|
|
474
|
-
SUPATYPE_HOOK_SEND_EMAIL_SECRETS: config.email?.send_email_hook_secrets !== undefined &&
|
|
475
|
-
config.email.send_email_hook_secrets.trim() !== ""
|
|
476
|
-
? config.email.send_email_hook_secrets.trim()
|
|
477
|
-
: LOCAL_SEND_EMAIL_HOOK_SECRETS,
|
|
478
|
-
}
|
|
479
|
-
: {}),
|
|
480
|
-
...(config.storage?.provider !== "s3" ? localStorageEnv(stateRoot) : {}),
|
|
438
|
+
...serverStorageEnv(nativeStorage, config, stateRoot),
|
|
481
439
|
// .env last, so a SUPATYPE_EXTERNAL_* value there wins over auth.providers in the config.
|
|
482
440
|
...nativeAuthProviderEnv(config, `http://localhost:${serverPort}`, providerEnvironment),
|
|
483
|
-
...
|
|
484
|
-
// After .env: auth.email.enableConfirmations, unless the developer set their own value.
|
|
485
|
-
...nativeMailerAutoconfirmEnv(cwd, config),
|
|
441
|
+
...nativeServerDotEnvLayer({ dotEnv, config, cwd, denoPort }),
|
|
486
442
|
};
|
|
443
|
+
await haltIfStopping();
|
|
487
444
|
const serverProc = new ProcessManager(serverBin, [], {
|
|
488
445
|
label: "server",
|
|
489
446
|
pidDir,
|
|
@@ -491,8 +448,10 @@ export function registerDev(program) {
|
|
|
491
448
|
env: serverEnv,
|
|
492
449
|
});
|
|
493
450
|
serverProc.start();
|
|
451
|
+
pushStartUndo(() => serverProc.stop());
|
|
494
452
|
// ── 9b. PostgREST ────────────────────────────────────────────────────
|
|
495
453
|
let postgrestProc = null;
|
|
454
|
+
await haltIfStopping();
|
|
496
455
|
const postgrestBin = await resolvePostgrestBin(config.overrides?.postgrest);
|
|
497
456
|
if (postgrestBin) {
|
|
498
457
|
// Windows PostgREST builds are dynamically linked and require libpq/OpenSSL
|
|
@@ -545,11 +504,13 @@ export function registerDev(program) {
|
|
|
545
504
|
env: postgrestEnv,
|
|
546
505
|
});
|
|
547
506
|
postgrestProc.start();
|
|
507
|
+
pushStartUndo(() => postgrestProc?.stop());
|
|
548
508
|
}
|
|
549
509
|
}
|
|
550
510
|
// ── 9d. Studio (optional) ─────────────────────────────────────────────
|
|
551
511
|
const studioPort = STUDIO_DEV_PORT;
|
|
552
512
|
let studioProc = null;
|
|
513
|
+
await haltIfStopping();
|
|
553
514
|
const studioOverride = config.overrides?.studio;
|
|
554
515
|
if (studioOverride) {
|
|
555
516
|
studioProc = startStudioViteDevServer({
|
|
@@ -561,8 +522,12 @@ export function registerDev(program) {
|
|
|
561
522
|
viteSupatypeUrl: `http://localhost:${studioPort}`,
|
|
562
523
|
});
|
|
563
524
|
studioProc?.start();
|
|
525
|
+
pushStartUndo(() => studioProc?.stop());
|
|
564
526
|
}
|
|
527
|
+
await haltIfStopping();
|
|
565
528
|
const appProc = startProxyDevApp(cwd, config, pidDir);
|
|
529
|
+
if (appProc)
|
|
530
|
+
pushStartUndo(() => appProc.stop());
|
|
566
531
|
const links = [
|
|
567
532
|
{ label: "API", url: `http://localhost:${serverPort}` },
|
|
568
533
|
{ label: "REST", url: `http://localhost:${serverPort}/rest/v1/` },
|
|
@@ -583,40 +548,39 @@ export function registerDev(program) {
|
|
|
583
548
|
hints: [`Postgres ${dbURL}`, `JWT secret: #${secretFingerprint(LOCAL_JWT_SECRET)} (in .env)`],
|
|
584
549
|
});
|
|
585
550
|
// ── Shutdown handler ──────────────────────────────────────────────────
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
serverProc.stop(),
|
|
590
|
-
realtimeProc?.stop(),
|
|
591
|
-
postgrestProc?.stop(),
|
|
592
|
-
studioProc?.stop(),
|
|
593
|
-
appProc?.stop(),
|
|
594
|
-
]);
|
|
595
|
-
stopValkeySidecar(valkeySidecar.containerName);
|
|
596
|
-
await stopPostgres();
|
|
597
|
-
});
|
|
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);
|
|
598
554
|
// ── 10. Schema watch ──────────────────────────────────────────────────
|
|
599
555
|
if (opts.watch) {
|
|
600
556
|
const schemaDir = resolve(cwd, schemaPath, "..");
|
|
601
557
|
console.log(`[supatype] Watching ${schemaDir} for changes...`);
|
|
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
|
+
});
|
|
602
570
|
const { watchDevSchema } = await import("../dev-schema-watch.js");
|
|
603
571
|
watchDevSchema({
|
|
604
572
|
dir: schemaDir,
|
|
605
573
|
changedSinceLastPush: async () => JSON.stringify((await buildNativeAst(cwd, schemaPath, config, skipFieldKinds)).ast) !== _lastReadAst,
|
|
606
574
|
push: (why) => {
|
|
607
575
|
console.log(`\n[supatype] ${why}, checking schema...`);
|
|
608
|
-
|
|
576
|
+
// A hook the push declares is served once the worker's routes name it.
|
|
577
|
+
runSchemaPush(schemaPush).then(() => functionsWatch.refresh()).catch(reportUnlessStopping(reportDevPushFailure));
|
|
609
578
|
},
|
|
610
579
|
});
|
|
611
|
-
// Deno reloads the router on change, but only lists the functions found at start.
|
|
612
|
-
if (functionsDir !== undefined && denoServeScriptAbs !== "") {
|
|
613
|
-
const { watchNativeFunctions } = await import("../native-functions-watch.js");
|
|
614
|
-
watchNativeFunctions(cwd, functionsDir, functionRoutes.map((route) => route.name));
|
|
615
|
-
}
|
|
616
580
|
}
|
|
617
581
|
// Block until killed.
|
|
618
582
|
await waitForDevShutdown();
|
|
619
|
-
});
|
|
583
|
+
}));
|
|
620
584
|
}
|
|
621
585
|
// ---------------------------------------------------------------------------
|
|
622
586
|
// Schema push (engine subprocess)
|
|
@@ -642,7 +606,7 @@ async function pushNativeSchema(cwd, schema, target) {
|
|
|
642
606
|
const { DEV_DESTRUCTIVE_POLICY, consentDepsFromDiff, pushConsentingToDestructive } = await import("../destructive-consent.js");
|
|
643
607
|
const { devPushConsentingToDrift } = await import("../drift-consent.js");
|
|
644
608
|
await ensureEngine();
|
|
645
|
-
const sources = writeSchemaSourcePushArtifacts(cwd);
|
|
609
|
+
const sources = writeSchemaSourcePushArtifacts(cwd, true);
|
|
646
610
|
let ast = schema.ast;
|
|
647
611
|
let stale = false;
|
|
648
612
|
const request = async () => {
|
|
@@ -706,9 +670,9 @@ async function buildNativeAst(cwd, schemaPath, config, skipFieldKinds) {
|
|
|
706
670
|
return { ast: filtered, adapted };
|
|
707
671
|
}
|
|
708
672
|
/** One push of native dev (provider `native`): the schema on disk, then what describes it. Exported for tests. */
|
|
709
|
-
export async function runSchemaPush(
|
|
710
|
-
|
|
711
|
-
overwriteDrift = false
|
|
673
|
+
export async function runSchemaPush(push) {
|
|
674
|
+
const { cwd, engineBin, schemaPath, dbURL, adminConfigPath, storagePath, skipFieldKinds, config, storageApi } = push;
|
|
675
|
+
const overwriteDrift = push.overwriteDrift ?? false;
|
|
712
676
|
const read = await readNativeSchema(cwd, schemaPath, config, skipFieldKinds);
|
|
713
677
|
const astJson = JSON.stringify(read);
|
|
714
678
|
_lastReadAst = astJson;
|
|
@@ -727,7 +691,7 @@ overwriteDrift = false) {
|
|
|
727
691
|
const pgSchemaName = config ? pgSchema(config) : "public";
|
|
728
692
|
const ast = await applyNativeSchema(cwd, { ast: read, rebuild }, { dbURL, pgSchema: pgSchemaName, overwriteDrift });
|
|
729
693
|
writeFileSync(astPath, JSON.stringify(ast));
|
|
730
|
-
await writeNativeSchemaArtifacts({ cwd, engineBin, astPath,
|
|
694
|
+
await writeNativeSchemaArtifacts({ cwd, engineBin, astPath, adminConfigPath, storagePath, storageApi }, ast, config);
|
|
731
695
|
}
|
|
732
696
|
/** The schema on disk as native dev pushes it, saying which fields were stood in for by JSONB. */
|
|
733
697
|
async function readNativeSchema(cwd, schemaPath, config, skipFieldKinds) {
|
|
@@ -755,35 +719,56 @@ async function applyNativeSchema(cwd, schema, target) {
|
|
|
755
719
|
throw err;
|
|
756
720
|
}
|
|
757
721
|
}
|
|
758
|
-
/**
|
|
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
|
+
*/
|
|
759
727
|
async function writeNativeSchemaArtifacts(paths, ast, config) {
|
|
760
728
|
const { cwd, engineBin, astPath } = paths;
|
|
761
729
|
if (paths.storagePath)
|
|
762
|
-
provisionDeclaredBuckets(engineBin, cwd, astPath, paths
|
|
763
|
-
const genResult = spawnSync(engineBin, ["generate", "-i", astPath, "-o", paths.manifestPath], {
|
|
764
|
-
cwd,
|
|
765
|
-
stdio: "pipe",
|
|
766
|
-
encoding: "utf8",
|
|
767
|
-
});
|
|
768
|
-
if (genResult.status !== 0) {
|
|
769
|
-
console.warn("[supatype] Manifest generation failed, server routing may be stale.");
|
|
770
|
-
}
|
|
730
|
+
await provisionDeclaredBuckets(engineBin, cwd, astPath, paths);
|
|
771
731
|
if (paths.adminConfigPath)
|
|
772
732
|
await writeNativeAdminConfig(paths, paths.adminConfigPath, ast, config);
|
|
733
|
+
if (config)
|
|
734
|
+
writeNativeAppliedAst(cwd, config, ast);
|
|
773
735
|
await writeNativeTypes(cwd, ast, config);
|
|
774
736
|
}
|
|
775
|
-
/**
|
|
776
|
-
function
|
|
737
|
+
/** The storage buckets the schema declares, as the engine resolves them; none when it cannot say. */
|
|
738
|
+
function declaredBuckets(engineBin, cwd, astPath) {
|
|
777
739
|
const parseResult = spawnSync(engineBin, ["parse", "-i", astPath], { cwd, stdio: "pipe", encoding: "utf8" });
|
|
778
740
|
if (parseResult.status !== 0 || !parseResult.stdout)
|
|
779
|
-
return;
|
|
741
|
+
return [];
|
|
780
742
|
try {
|
|
781
743
|
const resolvedAst = JSON.parse(parseResult.stdout);
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
744
|
+
return isParsedBuckets(resolvedAst) ? resolvedAst.storageBuckets ?? [] : [];
|
|
745
|
+
}
|
|
746
|
+
catch {
|
|
747
|
+
return [];
|
|
785
748
|
}
|
|
786
|
-
|
|
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).`);
|
|
787
772
|
}
|
|
788
773
|
/** Studio's admin config, which the engine writes to stdout, with the project's roles merged in. */
|
|
789
774
|
async function writeNativeAdminConfig(paths, adminConfigPath, ast, config) {
|
|
@@ -822,36 +807,27 @@ async function writeNativeTypes(cwd, ast, config) {
|
|
|
822
807
|
console.warn(`[supatype] Type generation failed: ${errorMessage(err)}`);
|
|
823
808
|
}
|
|
824
809
|
}
|
|
810
|
+
/** Writes the declared buckets buckets.json lacks to it, and returns their ids. */
|
|
825
811
|
function provisionStorageBuckets(declared, storagePath) {
|
|
826
812
|
const bucketsDir = join(storagePath, ".supatype");
|
|
827
813
|
const bucketsFile = join(bucketsDir, "buckets.json");
|
|
828
814
|
mkdirSync(bucketsDir, { recursive: true });
|
|
829
815
|
// Absent until the first bucket, and anything that is not a list of buckets reads as none.
|
|
830
|
-
const
|
|
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;
|
|
831
819
|
const existingIds = new Set(existing.map((b) => b["id"]));
|
|
832
|
-
|
|
820
|
+
const added = [];
|
|
833
821
|
for (const bucket of declared) {
|
|
834
822
|
if (existingIds.has(bucket.id))
|
|
835
823
|
continue;
|
|
836
|
-
|
|
837
|
-
existing.push({
|
|
838
|
-
id: bucket.id,
|
|
839
|
-
name: bucket.id,
|
|
840
|
-
public: bucket.public,
|
|
841
|
-
file_size_limit: bucket.fileSizeLimit ?? null,
|
|
842
|
-
allowed_mime_types: bucket.allowedMimeTypes ?? null,
|
|
843
|
-
access_mode: bucket.accessMode ?? (bucket.public ? "public" : "private"),
|
|
844
|
-
s3_bucket_policy: bucket.s3BucketPolicy ?? null,
|
|
845
|
-
created_at: now,
|
|
846
|
-
updated_at: now,
|
|
847
|
-
});
|
|
824
|
+
existing.push(nativeBucketRow(bucket, new Date().toISOString()));
|
|
848
825
|
mkdirSync(join(storagePath, bucket.id), { recursive: true });
|
|
849
|
-
added
|
|
826
|
+
added.push(bucket.id);
|
|
850
827
|
}
|
|
851
|
-
if (added > 0)
|
|
828
|
+
if (added.length > 0 || corrected > 0)
|
|
852
829
|
writeFileSync(bucketsFile, JSON.stringify(existing, null, 2));
|
|
853
|
-
|
|
854
|
-
}
|
|
830
|
+
return added;
|
|
855
831
|
}
|
|
856
832
|
// ---------------------------------------------------------------------------
|
|
857
833
|
// Resolve Postgres bin dir
|
|
@@ -889,16 +865,7 @@ async function extractPostgresArchive(pgCacheDir, version, platform, extractDir)
|
|
|
889
865
|
if (!existsSync(archivePath)) {
|
|
890
866
|
throw new Error(`Postgres ${version} archive not found. Run: supatype update`);
|
|
891
867
|
}
|
|
892
|
-
|
|
893
|
-
// On Windows, Git Bash tar is typically first in PATH and chokes on drive-letter
|
|
894
|
-
// paths (C:\...). Use PowerShell's Expand-Archive instead, which handles Windows
|
|
895
|
-
// paths natively. On Linux/macOS, use tar as normal.
|
|
896
|
-
const result = platform.os === "windows"
|
|
897
|
-
? spawnSync("powershell.exe", ["-NoProfile", "-Command", `Expand-Archive -Path '${archivePath}' -DestinationPath '${extractDir}' -Force`], { stdio: "inherit" })
|
|
898
|
-
: spawnSync("tar", ["-xzf", archivePath, "-C", extractDir], { stdio: "inherit" });
|
|
899
|
-
if (result.status !== 0) {
|
|
900
|
-
throw new Error(`Failed to extract Postgres archive: ${archivePath}`);
|
|
901
|
-
}
|
|
868
|
+
extractArchive(archivePath, extractDir);
|
|
902
869
|
}
|
|
903
870
|
// ---------------------------------------------------------------------------
|
|
904
871
|
// PostgREST resolver: downloads from GitHub releases if not cached
|
|
@@ -926,11 +893,11 @@ async function resolvePostgrestBin(overridePath) {
|
|
|
926
893
|
if (existsSync(binPath)) {
|
|
927
894
|
// Backfill DLLs for older cached Windows installs where only postgrest.exe
|
|
928
895
|
// was copied from the release archive.
|
|
929
|
-
if (platform.os === "windows" &&
|
|
930
|
-
|
|
931
|
-
|
|
896
|
+
if (platform.os === "windows" && postgrestRuntimeRepairDue(cacheDir, archivePath)) {
|
|
897
|
+
if (repairWindowsPostgrestRuntime(cacheDir, archivePath, binPath))
|
|
898
|
+
markPostgrestUnpacked(cacheDir);
|
|
899
|
+
else
|
|
932
900
|
console.warn("[supatype] ⚠ PostgREST runtime DLL repair failed; REST API may be unavailable.");
|
|
933
|
-
}
|
|
934
901
|
}
|
|
935
902
|
return binPath;
|
|
936
903
|
}
|
|
@@ -987,16 +954,10 @@ async function resolvePostgrestBin(overridePath) {
|
|
|
987
954
|
const { chmod } = await import("node:fs/promises");
|
|
988
955
|
await chmod(binPath, 0o755);
|
|
989
956
|
}
|
|
957
|
+
markPostgrestUnpacked(cacheDir);
|
|
990
958
|
console.log(`[supatype] PostgREST v${version} ready.`);
|
|
991
959
|
return binPath;
|
|
992
960
|
}
|
|
993
|
-
function hasLikelyWindowsRuntimeDlls(dir) {
|
|
994
|
-
if (process.platform !== "win32")
|
|
995
|
-
return true;
|
|
996
|
-
return (existsSync(join(dir, "libpq.dll")) ||
|
|
997
|
-
existsSync(join(dir, "libpq-5.dll")) ||
|
|
998
|
-
existsSync(join(dir, "libssl-3-x64.dll")));
|
|
999
|
-
}
|
|
1000
961
|
function repairWindowsPostgrestRuntime(cacheDir, archivePath, binPath) {
|
|
1001
962
|
const r = spawnSync("powershell.exe", [
|
|
1002
963
|
"-NoProfile",
|
|
@@ -1079,22 +1040,57 @@ function runAuthMigrations(serverBin, migrateEnv) {
|
|
|
1079
1040
|
(detail ? `:\n${detail}` : ""));
|
|
1080
1041
|
}
|
|
1081
1042
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
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;
|
|
1073
|
+
}
|
|
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 "));
|
|
1097
1079
|
}
|
|
1098
|
-
|
|
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}`);
|
|
1099
1095
|
}
|
|
1100
1096
|
//# sourceMappingURL=dev.js.map
|