@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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fetch` with a deadline, because the built-in has none.
|
|
3
|
+
*
|
|
4
|
+
* A poll loop bounded by `maxSec` iterations is only bounded if each attempt can end. Against a
|
|
5
|
+
* socket that accepts and never responds, an un-timed `fetch` never settles, the loop never reaches
|
|
6
|
+
* its second iteration, and a wait advertised as 120 seconds runs until someone kills it. That is
|
|
7
|
+
* how `supatype push` came to hang indefinitely after reporting the schema applied.
|
|
8
|
+
*/
|
|
9
|
+
export declare function fetchWithin(url: string, ms: number, init?: RequestInit): Promise<Response>;
|
|
10
|
+
//# sourceMappingURL=fetch-within.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-within.d.ts","sourceRoot":"","sources":["../src/fetch-within.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEhG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fetch` with a deadline, because the built-in has none.
|
|
3
|
+
*
|
|
4
|
+
* A poll loop bounded by `maxSec` iterations is only bounded if each attempt can end. Against a
|
|
5
|
+
* socket that accepts and never responds, an un-timed `fetch` never settles, the loop never reaches
|
|
6
|
+
* its second iteration, and a wait advertised as 120 seconds runs until someone kills it. That is
|
|
7
|
+
* how `supatype push` came to hang indefinitely after reporting the schema applied.
|
|
8
|
+
*/
|
|
9
|
+
export async function fetchWithin(url, ms, init) {
|
|
10
|
+
return await fetch(url, { ...init, signal: AbortSignal.timeout(ms) });
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=fetch-within.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-within.js","sourceRoot":"","sources":["../src/fetch-within.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW,EAAE,EAAU,EAAE,IAAkB;IAC3E,OAAO,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;AACvE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-masking-tier.d.ts","sourceRoot":"","sources":["../src/field-masking-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AASH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAE5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAOhE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,WAAW,GAAG,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"field-masking-tier.d.ts","sourceRoot":"","sources":["../src/field-masking-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AASH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAE5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAOhE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,WAAW,GAAG,OAAO,CAAA;AAW7D,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAK9E;AA4BD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIzD;AAED,kDAAkD;AAClD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,qBAAqB,EAC7B,GAAG,EAAE,OAAO;AACZ,mGAAmG;AACnG,kBAAkB,CAAC,EAAE,OAAO,GAC3B,gBAAgB,CAIlB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC3B,gBAAgB,CAQlB"}
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
* the extension themselves and points at it with `database.external`. They set `schema.api_schemas`
|
|
24
24
|
* explicitly; `supatype db check` reports the mismatch either way.
|
|
25
25
|
*/
|
|
26
|
-
import { spawnSync } from "node:child_process";
|
|
27
26
|
import { existsSync } from "node:fs";
|
|
27
|
+
import { askDockerSync, DOCKER_QUERY_TIMEOUT_MS, dockerHasImage } from "./docker-exec.js";
|
|
28
28
|
// Statically imported: these packages are ESM, where `require` does not exist. The first attempt used
|
|
29
29
|
// it for a lazy import and every command that generates compose would have thrown at runtime, caught
|
|
30
30
|
// by the tests that run the built binary rather than the source.
|
|
31
31
|
import { loadSchemaAst } from "./config.js";
|
|
32
32
|
import { astModels, isNonEmptyObject, objectAt } from "./ast-read.js";
|
|
33
33
|
export { nativeMaskLibraryPresent } from "./postgres-ctl.js";
|
|
34
|
-
import {
|
|
34
|
+
import { runningPostgresImage } from "./postgres-image.js";
|
|
35
35
|
import { resolveRuntimeProvider, schemaPathFromProject, usesExternalDatabase, } from "./project-config.js";
|
|
36
36
|
/** Postgres image this project would run, when it runs one at all. */
|
|
37
37
|
function postgresImage(config) {
|
|
@@ -40,7 +40,7 @@ function postgresImage(config) {
|
|
|
40
40
|
if (config.database.provider !== "docker" && resolveRuntimeProvider(config) !== "docker") {
|
|
41
41
|
return undefined;
|
|
42
42
|
}
|
|
43
|
-
return
|
|
43
|
+
return runningPostgresImage(config);
|
|
44
44
|
}
|
|
45
45
|
/** True when the Postgres this project runs is one that carries `supatype_mask`. */
|
|
46
46
|
export function imageShipsMaskExtension(config) {
|
|
@@ -64,9 +64,11 @@ function imageCarriesMaskLibrary(image) {
|
|
|
64
64
|
const known = maskLibraryIn.get(image);
|
|
65
65
|
if (known !== undefined)
|
|
66
66
|
return known;
|
|
67
|
-
if (
|
|
67
|
+
if (!dockerHasImage(image))
|
|
68
68
|
return undefined;
|
|
69
|
-
|
|
69
|
+
// Synchronous because the tier is decided while compose is rendered, which is synchronous. The
|
|
70
|
+
// image is already here, so the container needs no pull: a query's limit is enough.
|
|
71
|
+
const probe = askDockerSync(["run", "--rm", "--entrypoint", "sh", image, "-c", 'test -f "$(pg_config --pkglibdir)/supatype_mask.so"'], { stdio: "ignore", timeoutMs: DOCKER_QUERY_TIMEOUT_MS });
|
|
70
72
|
// 0 found, 1 not found; anything else is Docker failing, which says nothing about the image.
|
|
71
73
|
if (probe.status !== 0 && probe.status !== 1)
|
|
72
74
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-masking-tier.js","sourceRoot":"","sources":["../src/field-masking-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"field-masking-tier.js","sourceRoot":"","sources":["../src/field-masking-tier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACzF,sGAAsG;AACtG,qGAAqG;AACrG,iEAAiE;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,qBAAqB,CAAA;AAI5B,sEAAsE;AACtE,SAAS,aAAa,CAAC,MAA6B;IAClD,IAAI,oBAAoB,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IAClD,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,QAAQ,IAAI,sBAAsB,CAAC,MAAM,CAAC,KAAK,QAAQ,EAAE,CAA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,mBAAmB,CAAC,GAAY;IAC9C,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CACnC,gBAAgB,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CACnF,CAAA;AACH,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,gBAAgB,CAC9B,MAA6B,EAC7B,GAAY;AACZ,mGAAmG;AACnG,kBAA4B;IAE5B,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC;QAAE,OAAO,MAAM,CAAA;IAC5C,IAAI,kBAAkB,KAAK,IAAI;QAAE,OAAO,WAAW,CAAA;IACnD,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAA;AAChE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,GAAW,EACX,MAA6B,EAC7B,kBAA4B;IAE5B,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QACrD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,OAAO,MAAM,CAAA;QAC1C,OAAO,gBAAgB,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,kBAAkB,CAAC,CAAA;IACrF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAA;IACf,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type SupatypeProjectConfig } from "./project-config.js";
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Rewrite the context module. The path written, relative to `cwd` (`edge/_shared/context.ts` under
|
|
4
|
+
* `functions.path: "edge"`), when this project has functions and one was written; else undefined.
|
|
5
|
+
* Callers print it: they used to print `functions/_shared/context.ts` whatever the path was.
|
|
6
|
+
*/
|
|
7
|
+
export declare function refreshFunctionsContext(cwd: string, config: SupatypeProjectConfig): string | undefined;
|
|
4
8
|
//# sourceMappingURL=functions-context-refresh.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-context-refresh.d.ts","sourceRoot":"","sources":["../src/functions-context-refresh.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"functions-context-refresh.d.ts","sourceRoot":"","sources":["../src/functions-context-refresh.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAqC,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAEnG;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,GAAG,MAAM,GAAG,SAAS,CAKtG"}
|
|
@@ -14,13 +14,21 @@
|
|
|
14
14
|
* functions would create the thing it describes out of nothing.
|
|
15
15
|
*/
|
|
16
16
|
import { existsSync } from "node:fs";
|
|
17
|
+
import { join, relative } from "node:path";
|
|
18
|
+
import { toPosixPath } from "@supatype/shared";
|
|
17
19
|
import { ensureFunctionsDenoTypes } from "./functions-deno-types.js";
|
|
18
20
|
import { preferredFunctionsPathFromProject } from "./project-config.js";
|
|
19
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Rewrite the context module. The path written, relative to `cwd` (`edge/_shared/context.ts` under
|
|
23
|
+
* `functions.path: "edge"`), when this project has functions and one was written; else undefined.
|
|
24
|
+
* Callers print it: they used to print `functions/_shared/context.ts` whatever the path was.
|
|
25
|
+
*/
|
|
20
26
|
export function refreshFunctionsContext(cwd, config) {
|
|
21
27
|
const functionsDir = preferredFunctionsPathFromProject(config, cwd);
|
|
22
28
|
if (!existsSync(functionsDir))
|
|
23
|
-
return
|
|
24
|
-
|
|
29
|
+
return undefined;
|
|
30
|
+
if (!ensureFunctionsDenoTypes(cwd, functionsDir).wroteContextModule)
|
|
31
|
+
return undefined;
|
|
32
|
+
return toPosixPath(relative(cwd, join(functionsDir, "_shared", "context.ts")));
|
|
25
33
|
}
|
|
26
34
|
//# sourceMappingURL=functions-context-refresh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-context-refresh.js","sourceRoot":"","sources":["../src/functions-context-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,iCAAiC,EAA8B,MAAM,qBAAqB,CAAA;AAEnG
|
|
1
|
+
{"version":3,"file":"functions-context-refresh.js","sourceRoot":"","sources":["../src/functions-context-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,iCAAiC,EAA8B,MAAM,qBAAqB,CAAA;AAEnG;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAW,EAAE,MAA6B;IAChF,MAAM,YAAY,GAAG,iCAAiC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnE,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,SAAS,CAAA;IAC/C,IAAI,CAAC,wBAAwB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,kBAAkB;QAAE,OAAO,SAAS,CAAA;IACrF,OAAO,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;AAChF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-deno-types.d.ts","sourceRoot":"","sources":["../src/functions-deno-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH,6DAA6D;AAC7D,wBAAgB,0BAA0B,IAAI,MAAM,CAiEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAOpD;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"functions-deno-types.d.ts","sourceRoot":"","sources":["../src/functions-deno-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH,6DAA6D;AAC7D,wBAAgB,0BAA0B,IAAI,MAAM,CAiEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAOpD;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,IAAI,MAAM,CA0DrD;AAED,yFAAyF;AACzF,wBAAgB,uBAAuB,IAAI,MAAM,CAiBhD;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,OAAO,CAAA;IACrB,kBAAkB,EAAE,OAAO,CAAA;IAC3B,aAAa,EAAE,OAAO,CAAA;IACtB,WAAW,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAA;IACzD,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,wBAAwB,CAyC1B"}
|
|
@@ -67,7 +67,7 @@ declare namespace Deno {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
-
* The slice of Node's async_hooks
|
|
70
|
+
* The slice of Node's async_hooks a function may use. Deno provides the module at runtime;
|
|
71
71
|
* a functions tsconfig loads no Node types, so without it the import resolves to nothing.
|
|
72
72
|
*/
|
|
73
73
|
declare module "node:async_hooks" {
|
|
@@ -146,7 +146,14 @@ export interface FunctionContext {
|
|
|
146
146
|
*/
|
|
147
147
|
readonly dbUrl?: string
|
|
148
148
|
readonly region: string
|
|
149
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* Values from the functions directory's .env.local (or SUPATYPE_SHARED_ENV_FILE), then those
|
|
151
|
+
* "supatype functions env set" gave a self-hosted project, then .env.<function>.local, which
|
|
152
|
+
* wins. The project's own .env is not read for these. They are read again on every call.
|
|
153
|
+
*
|
|
154
|
+
* They are here, never in Deno.env: that is the worker's one process environment, shared by every
|
|
155
|
+
* call running at once, so a value put there for one function would reach every other.
|
|
156
|
+
*/
|
|
150
157
|
readonly env: Readonly<Record<string, string>>
|
|
151
158
|
}
|
|
152
159
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-deno-types.js","sourceRoot":"","sources":["../src/functions-deno-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAEhE,MAAM,MAAM,GAAG,0CAA0C,CAAA;AAEzD,6DAA6D;AAC7D,MAAM,UAAU,0BAA0B;IACxC,OAAO;KACJ,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DV,CAAA;AACD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,CACL,mBAAmB;QACnB,4EAA4E;QAC5E,mDAAmD;QACnD,8DAA8D,CAC/D,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B;IAC1C,OAAO
|
|
1
|
+
{"version":3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IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACzE,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,4FAA4F;IAC5F,IAAI,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAA;QACxE,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;YACjC,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAa;IAC5C,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACxD,OAAO,CAAC,KAAK,WAAW,IAAI,CAAC,KAAK,cAAc,IAAI,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;AAChF,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -17,17 +17,15 @@ export declare class InvalidFunctionNameError extends Error {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function functionNameProblem(name: string, entry?: string): string | undefined;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* The handlers in `dir` as the worker finds them: `{name}/index.ts` dirs and `*.ts` files, skipping
|
|
21
|
+
* `_shared` and dotfiles, sorted by name. Names are not checked: model hooks are not functions.
|
|
22
|
+
*/
|
|
23
|
+
export declare function discoverHandlersInDir(dir: string): DiscoveredFunctionRoute[];
|
|
24
|
+
/**
|
|
25
|
+
* {@link discoverHandlersInDir} for public functions. Throws {@link InvalidFunctionNameError}
|
|
26
|
+
* naming every one the control plane would refuse.
|
|
22
27
|
*/
|
|
23
28
|
export declare function discoverTsFunctionsInDir(functionsDir: string): DiscoveredFunctionRoute[];
|
|
24
29
|
/** {@link discoverTsFunctionsInDir}, ending the command with why when a name would be refused. */
|
|
25
30
|
export declare function discoverFunctionsOrExit(functionsDir: string): DiscoveredFunctionRoute[];
|
|
26
|
-
|
|
27
|
-
export declare function generateFunctionsRouterSource(routerFilePath: string, fns: ReadonlyArray<Pick<DiscoveredFunctionRoute, "name" | "entrypoint">>): string;
|
|
28
|
-
/**
|
|
29
|
-
* Writes `.supatype/functions-router.ts` under project cwd. Returns absolute path or null if no handlers.
|
|
30
|
-
* Pass `routes` when callers already scanned the dir to avoid duplicate I/O.
|
|
31
|
-
*/
|
|
32
|
-
export declare function writeDevFunctionsRouter(cwd: string, functionsDir: string, routes?: DiscoveredFunctionRoute[]): string | null;
|
|
33
|
-
//# sourceMappingURL=functions-router-gen.d.ts.map
|
|
31
|
+
//# sourceMappingURL=functions-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions-discovery.d.ts","sourceRoot":"","sources":["../src/functions-discovery.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,SAAkB,IAAI,8BAA6B;CACpD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,MAAa,GAAG,MAAM,GAAG,SAAS,CAK1F;AAwBD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAM5E;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAWxF;AAED,kGAAkG;AAClG,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAOvF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The functions a project's functions directory holds, found the way the functions worker finds
|
|
3
|
+
* them (`{name}/index.ts` folders and `{name}.ts` files, skipping `_shared` and dotfiles), and
|
|
4
|
+
* checked against the name rule the control plane enforces.
|
|
5
|
+
*/
|
|
6
|
+
import { basename, join } from "node:path";
|
|
7
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
8
|
+
import { FUNCTION_NAME_RULE, isFunctionName } from "@supatype/shared";
|
|
9
|
+
import { fatalError } from "./ui/fatal.js";
|
|
10
|
+
/**
|
|
11
|
+
* A function the control plane would refuse by its name. Named here, where the folder is found,
|
|
12
|
+
* so `dev`, `functions serve` and `functions deploy` say so before anything runs or is sent.
|
|
13
|
+
*/
|
|
14
|
+
export class InvalidFunctionNameError extends Error {
|
|
15
|
+
name = "InvalidFunctionNameError";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Why `name` is not a function name, or undefined when it is one. `entry` is what holds it in the
|
|
19
|
+
* functions directory (`sendEmail/`, `Webhook.ts`).
|
|
20
|
+
*/
|
|
21
|
+
export function functionNameProblem(name, entry = name) {
|
|
22
|
+
if (isFunctionName(name))
|
|
23
|
+
return undefined;
|
|
24
|
+
const suggestion = suggestedFunctionName(name);
|
|
25
|
+
const example = suggestion === undefined ? "" : ` (for example "${suggestion}")`;
|
|
26
|
+
return `"${entry}" is not a valid function name: ${FUNCTION_NAME_RULE}${example}.`;
|
|
27
|
+
}
|
|
28
|
+
/** `sendEmail` as `send-email`: what a name the rule refuses most likely meant, if anything. */
|
|
29
|
+
function suggestedFunctionName(name) {
|
|
30
|
+
const kebab = name
|
|
31
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1-$2")
|
|
32
|
+
.toLowerCase()
|
|
33
|
+
.replace(/[^a-z0-9_-]+/g, "-")
|
|
34
|
+
.replace(/^[-_]+/, "");
|
|
35
|
+
return isFunctionName(kebab) ? kebab : undefined;
|
|
36
|
+
}
|
|
37
|
+
/** The function `entry` in `functionsDir` holds, or undefined for anything that is not one. */
|
|
38
|
+
function functionAt(functionsDir, entry) {
|
|
39
|
+
if (entry.startsWith("_") || entry.startsWith("."))
|
|
40
|
+
return undefined;
|
|
41
|
+
const fullPath = join(functionsDir, entry);
|
|
42
|
+
if (statSync(fullPath).isDirectory()) {
|
|
43
|
+
const indexTs = join(fullPath, "index.ts");
|
|
44
|
+
return existsSync(indexTs) ? { name: entry, entrypoint: indexTs, path: fullPath } : undefined;
|
|
45
|
+
}
|
|
46
|
+
if (!entry.endsWith(".ts") || entry.endsWith(".d.ts"))
|
|
47
|
+
return undefined;
|
|
48
|
+
return { name: basename(entry, ".ts"), entrypoint: fullPath, path: fullPath };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The handlers in `dir` as the worker finds them: `{name}/index.ts` dirs and `*.ts` files, skipping
|
|
52
|
+
* `_shared` and dotfiles, sorted by name. Names are not checked: model hooks are not functions.
|
|
53
|
+
*/
|
|
54
|
+
export function discoverHandlersInDir(dir) {
|
|
55
|
+
if (!existsSync(dir))
|
|
56
|
+
return [];
|
|
57
|
+
return readdirSync(dir)
|
|
58
|
+
.map((entry) => functionAt(dir, entry))
|
|
59
|
+
.filter((fn) => fn !== undefined)
|
|
60
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* {@link discoverHandlersInDir} for public functions. Throws {@link InvalidFunctionNameError}
|
|
64
|
+
* naming every one the control plane would refuse.
|
|
65
|
+
*/
|
|
66
|
+
export function discoverTsFunctionsInDir(functionsDir) {
|
|
67
|
+
const found = discoverHandlersInDir(functionsDir);
|
|
68
|
+
const problems = found
|
|
69
|
+
.map((fn) => functionNameProblem(fn.name, fn.path === fn.entrypoint ? basename(fn.path) : `${fn.name}/`))
|
|
70
|
+
.filter((problem) => problem !== undefined);
|
|
71
|
+
if (problems.length > 0) {
|
|
72
|
+
throw new InvalidFunctionNameError([`The control plane would refuse ${problems.length} function(s) in ${functionsDir}:`, ...problems.map((p) => ` ${p}`)].join("\n"));
|
|
73
|
+
}
|
|
74
|
+
return found;
|
|
75
|
+
}
|
|
76
|
+
/** {@link discoverTsFunctionsInDir}, ending the command with why when a name would be refused. */
|
|
77
|
+
export function discoverFunctionsOrExit(functionsDir) {
|
|
78
|
+
try {
|
|
79
|
+
return discoverTsFunctionsInDir(functionsDir);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
if (err instanceof InvalidFunctionNameError)
|
|
83
|
+
fatalError(err.message);
|
|
84
|
+
throw err;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=functions-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions-discovery.js","sourceRoot":"","sources":["../src/functions-discovery.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAS1C;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAC/B,IAAI,GAAG,0BAA0B,CAAA;CACpD;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,QAAgB,IAAI;IACpE,IAAI,cAAc,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAA;IAC1C,MAAM,UAAU,GAA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CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACnI,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,uBAAuB,CAAC,YAAoB;IAC1D,IAAI,CAAC;QACH,OAAO,wBAAwB,CAAC,YAAY,CAAC,CAAA;IAC/C,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,IAAI,GAAG,YAAY,wBAAwB;YAAE,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACpE,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-template.d.ts","sourceRoot":"","sources":["../src/functions-template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"functions-template.d.ts","sourceRoot":"","sources":["../src/functions-template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqC3D"}
|
|
@@ -12,7 +12,6 @@ export function functionTemplateSource(name) {
|
|
|
12
12
|
import type { FunctionContext } from "../_shared/context.ts"
|
|
13
13
|
|
|
14
14
|
export default async function handler(req: Request, ctx: FunctionContext): Promise<Response> {
|
|
15
|
-
const { method } = req
|
|
16
15
|
// From the context, not the environment. Per-invocation values are passed in, which is what lets
|
|
17
16
|
// the worker run your functions concurrently instead of one at a time.
|
|
18
17
|
//
|
|
@@ -20,19 +19,28 @@ export default async function handler(req: Request, ctx: FunctionContext): Promi
|
|
|
20
19
|
// url, is for calling the API from inside this function, and under Docker no browser can open it.
|
|
21
20
|
const { publicUrl } = ctx
|
|
22
21
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
// A request may carry a JSON body. One with no body is answered as a GET is.
|
|
23
|
+
const body = await readBody(req)
|
|
24
|
+
if (body.kind === "invalid") return json({ error: "The request body is not valid JSON" }, 400)
|
|
25
|
+
if (body.kind === "none") return json({ message: "Hello from ${name}!", publicUrl })
|
|
26
|
+
return json({ message: "Hello from ${name}!", received: body.value, publicUrl })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type Body = { kind: "none" } | { kind: "json"; value: unknown } | { kind: "invalid" }
|
|
30
|
+
|
|
31
|
+
/** The request's body: none when it is empty, else its JSON, or invalid when it is not JSON. */
|
|
32
|
+
async function readBody(req: Request): Promise<Body> {
|
|
33
|
+
const text = await req.text()
|
|
34
|
+
if (text.trim() === "") return { kind: "none" }
|
|
35
|
+
try {
|
|
36
|
+
return { kind: "json", value: JSON.parse(text) }
|
|
37
|
+
} catch {
|
|
38
|
+
return { kind: "invalid" }
|
|
30
39
|
}
|
|
40
|
+
}
|
|
31
41
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
headers: { "Content-Type": "application/json" },
|
|
35
|
-
})
|
|
42
|
+
function json(value: unknown, status = 200): Response {
|
|
43
|
+
return new Response(JSON.stringify(value), { status, headers: { "Content-Type": "application/json" } })
|
|
36
44
|
}
|
|
37
45
|
`;
|
|
38
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-template.js","sourceRoot":"","sources":["../src/functions-template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,MAAM,IAAI
|
|
1
|
+
{"version":3,"file":"functions-template.js","sourceRoot":"","sources":["../src/functions-template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,MAAM,IAAI;;;;;;;;;;;;;;;iEAe8C,IAAI;uCAC9B,IAAI;;;;;;;;;;;;;;;;;;;CAmB1C,CAAA;AACD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type SupatypeProjectConfig } from "./project-config.js";
|
|
2
|
+
/** Writes the worker's files under `root` (the CLI's cache by default) and returns its main.ts. */
|
|
3
|
+
export declare function installFunctionsWorker(root?: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Every route a local worker serves: the functions in `functionsDir`, then the hooks in `hooksDir`.
|
|
6
|
+
* Throws when a function's name is one the control plane would refuse.
|
|
7
|
+
*/
|
|
8
|
+
export declare function localWorkerRoutes(functionsDir: string | undefined, hooksDir: string): string[];
|
|
9
|
+
/** {@link localWorkerRoutes}, ending the command with why when a function's name would be refused. */
|
|
10
|
+
export declare function localWorkerRoutesOrExit(functionsDir: string | undefined, hooksDir: string): string[];
|
|
11
|
+
/** Where native dev writes the entry its server runs Deno on. */
|
|
12
|
+
export declare function devFunctionsEntryPath(cwd: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* The entry native dev's server runs: an import of the worker, and the routes (functions and
|
|
15
|
+
* hooks) it found. The server runs Deno with a fixed `--watch` on this file, which reloads when a
|
|
16
|
+
* file the worker imported changes; a function or hook added later was imported by nothing, so the
|
|
17
|
+
* routes are rewritten when the set changes, and that change is what makes Deno reload and find it.
|
|
18
|
+
*
|
|
19
|
+
* It names the generated hooks adapter's content too ({@link hooksAdapterHash}): a hook made before
|
|
20
|
+
* any model named it failed to import the adapter, which only a push writes, and Deno does not
|
|
21
|
+
* watch a module that failed to import, so the push's adapter reloaded nothing (round 6c, N30).
|
|
22
|
+
*/
|
|
23
|
+
export declare function devFunctionsEntrySource(routes: readonly string[], workerMain: string, adapter?: string): string;
|
|
24
|
+
/** Writes {@link devFunctionsEntrySource} to {@link devFunctionsEntryPath} and returns that path. */
|
|
25
|
+
export declare function writeDevFunctionsEntry(cwd: string, routes: readonly string[], workerMain: string, hooksDir: string): string;
|
|
26
|
+
/** A short hash of `hooks/_supatype/hooks.ts` under `hooksDir`, or "none" when there is none. */
|
|
27
|
+
export declare function hooksAdapterHash(hooksDir: string): string;
|
|
28
|
+
/** The adapter hash the entry in `cwd` was written with: "none" when it names none or is not there. */
|
|
29
|
+
export declare function entryAdapterHash(cwd: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* `deno run` arguments for `functions serve`: the worker under `--watch`, which reloads when a file
|
|
32
|
+
* it imported changes, also watching `watchDirs`, so a function added while it serves is found.
|
|
33
|
+
*/
|
|
34
|
+
export declare function functionsServeDenoArgs(workerMain: string, watchDirs: readonly string[], envFileArgs: readonly string[]): string[];
|
|
35
|
+
/** The project a local worker serves: its config, its functions directory and its key file. */
|
|
36
|
+
export interface FunctionsWorkerProject {
|
|
37
|
+
cwd: string;
|
|
38
|
+
config: SupatypeProjectConfig;
|
|
39
|
+
functionsDir: string;
|
|
40
|
+
/** The service-role key file; without one no function is given the key. */
|
|
41
|
+
keyPath: string | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The worker's environment for `project`, as self-host compose gives it to the image: functions
|
|
45
|
+
* and hooks roots, the project ref its log lines carry, and the routes `functions.serviceRole`
|
|
46
|
+
* grants the key. The key file stands in for the key itself, which a `--watch` reload would
|
|
47
|
+
* otherwise not find again. The shared env file is left to the worker's own default,
|
|
48
|
+
* `<functions root>/.env.local`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function functionsWorkerEnv(project: FunctionsWorkerProject): Record<string, string>;
|
|
51
|
+
/** Where native dev keeps `functions.serviceRole` for its worker, which reads it on every reload. */
|
|
52
|
+
export declare function devServiceRoleRoutesPath(cwd: string): string;
|
|
53
|
+
/** Writes the routes `functions.serviceRole` grants the key, comma-separated, as the worker reads them. */
|
|
54
|
+
export declare function writeServiceRoleRoutesFile(path: string, routes: readonly string[]): void;
|
|
55
|
+
//# sourceMappingURL=functions-worker-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"funct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X,MAAM,EAAE,qBAAqB,CAAA;IAC7B,YAAY,EAAE,MAAM,CAAA;IACpB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAS1F;AAED,qGAAqG;AACrG,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,2GAA2G;AAC3G,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAGxF"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The functions worker native `dev` and `functions serve` run: packages/functions-worker itself,
|
|
3
|
+
* the code the deployed image runs, rather than a router generated to copy its rules. A copy
|
|
4
|
+
* drifted from the worker three times (which export it took, who got the service-role key, which
|
|
5
|
+
* env files it read), and every drift was a function that worked locally and failed once deployed.
|
|
6
|
+
*
|
|
7
|
+
* The CLI carries the worker's source (generated/functions-worker-source.ts) and writes it to the
|
|
8
|
+
* cache under a directory named for its content, so every project and every serve of one CLI
|
|
9
|
+
* version share one copy and nothing is left in a project when they stop.
|
|
10
|
+
*/
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { dirname, join, resolve } from "node:path";
|
|
14
|
+
import { pathToFileURL } from "node:url";
|
|
15
|
+
import { cacheRoot } from "./binary-cache.js";
|
|
16
|
+
import { discoverHandlersInDir, discoverTsFunctionsInDir, InvalidFunctionNameError } from "./functions-discovery.js";
|
|
17
|
+
import { fatalError } from "./ui/fatal.js";
|
|
18
|
+
import { FUNCTIONS_WORKER_SOURCE } from "./generated/functions-worker-source.js";
|
|
19
|
+
import { hooksPathFromProject, serviceRoleRoutes } from "./project-config.js";
|
|
20
|
+
import { uniqueFileToken } from "./unique-file-token.js";
|
|
21
|
+
/** Where this CLI's worker source lives under `root`: one directory per distinct source. */
|
|
22
|
+
function functionsWorkerDir(root = cacheRoot()) {
|
|
23
|
+
const files = Object.entries(FUNCTIONS_WORKER_SOURCE).sort(([a], [b]) => a.localeCompare(b));
|
|
24
|
+
const hash = createHash("sha256").update(JSON.stringify(files)).digest("hex").slice(0, 16);
|
|
25
|
+
return join(root, "functions-worker", hash);
|
|
26
|
+
}
|
|
27
|
+
/** Writes the worker's files under `root` (the CLI's cache by default) and returns its main.ts. */
|
|
28
|
+
export function installFunctionsWorker(root) {
|
|
29
|
+
const dir = functionsWorkerDir(root);
|
|
30
|
+
mkdirSync(dir, { recursive: true });
|
|
31
|
+
for (const [name, text] of Object.entries(FUNCTIONS_WORKER_SOURCE))
|
|
32
|
+
writeIfChanged(join(dir, name), text);
|
|
33
|
+
return join(dir, "main.ts");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Writes `text` to `path` unless it already holds it. Through a temporary file and a rename, so a
|
|
37
|
+
* Deno another serve has running never reads a half-written module.
|
|
38
|
+
*/
|
|
39
|
+
function writeIfChanged(path, text) {
|
|
40
|
+
if (existsSync(path) && readFileSync(path, "utf8") === text)
|
|
41
|
+
return;
|
|
42
|
+
const temporary = `${path}.${uniqueFileToken()}.tmp`;
|
|
43
|
+
writeFileSync(temporary, text, "utf8");
|
|
44
|
+
renameSync(temporary, path);
|
|
45
|
+
}
|
|
46
|
+
/** The routes the worker serves from `hooksDir`, each as `hooks/<name>`, as it routes them. */
|
|
47
|
+
function hookRoutes(hooksDir) {
|
|
48
|
+
return discoverHandlersInDir(hooksDir).map((hook) => `hooks/${hook.name}`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Every route a local worker serves: the functions in `functionsDir`, then the hooks in `hooksDir`.
|
|
52
|
+
* Throws when a function's name is one the control plane would refuse.
|
|
53
|
+
*/
|
|
54
|
+
export function localWorkerRoutes(functionsDir, hooksDir) {
|
|
55
|
+
const functions = functionsDir === undefined ? [] : discoverTsFunctionsInDir(functionsDir).map((fn) => fn.name);
|
|
56
|
+
return [...functions, ...hookRoutes(hooksDir)];
|
|
57
|
+
}
|
|
58
|
+
/** {@link localWorkerRoutes}, ending the command with why when a function's name would be refused. */
|
|
59
|
+
export function localWorkerRoutesOrExit(functionsDir, hooksDir) {
|
|
60
|
+
try {
|
|
61
|
+
return localWorkerRoutes(functionsDir, hooksDir);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
if (err instanceof InvalidFunctionNameError)
|
|
65
|
+
fatalError(err.message);
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Where native dev writes the entry its server runs Deno on. */
|
|
70
|
+
export function devFunctionsEntryPath(cwd) {
|
|
71
|
+
return join(resolve(cwd, ".supatype"), "functions-worker.ts");
|
|
72
|
+
}
|
|
73
|
+
const ADAPTER_LINE = "// Hooks adapter: ";
|
|
74
|
+
/**
|
|
75
|
+
* The entry native dev's server runs: an import of the worker, and the routes (functions and
|
|
76
|
+
* hooks) it found. The server runs Deno with a fixed `--watch` on this file, which reloads when a
|
|
77
|
+
* file the worker imported changes; a function or hook added later was imported by nothing, so the
|
|
78
|
+
* routes are rewritten when the set changes, and that change is what makes Deno reload and find it.
|
|
79
|
+
*
|
|
80
|
+
* It names the generated hooks adapter's content too ({@link hooksAdapterHash}): a hook made before
|
|
81
|
+
* any model named it failed to import the adapter, which only a push writes, and Deno does not
|
|
82
|
+
* watch a module that failed to import, so the push's adapter reloaded nothing (round 6c, N30).
|
|
83
|
+
*/
|
|
84
|
+
export function devFunctionsEntrySource(routes, workerMain, adapter = "none") {
|
|
85
|
+
return [
|
|
86
|
+
"// Written by supatype dev, do not edit. Runs packages/functions-worker, as the deployed image does.",
|
|
87
|
+
`// Routes: ${routes.join(", ")}`,
|
|
88
|
+
`${ADAPTER_LINE}${adapter}`,
|
|
89
|
+
`import ${JSON.stringify(pathToFileURL(workerMain).href)}`,
|
|
90
|
+
"",
|
|
91
|
+
].join("\n");
|
|
92
|
+
}
|
|
93
|
+
/** Writes {@link devFunctionsEntrySource} to {@link devFunctionsEntryPath} and returns that path. */
|
|
94
|
+
export function writeDevFunctionsEntry(cwd, routes, workerMain, hooksDir) {
|
|
95
|
+
const path = devFunctionsEntryPath(cwd);
|
|
96
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
97
|
+
writeFileSync(path, devFunctionsEntrySource(routes, workerMain, hooksAdapterHash(hooksDir)), "utf8");
|
|
98
|
+
return path;
|
|
99
|
+
}
|
|
100
|
+
/** A short hash of `hooks/_supatype/hooks.ts` under `hooksDir`, or "none" when there is none. */
|
|
101
|
+
export function hooksAdapterHash(hooksDir) {
|
|
102
|
+
const file = join(hooksDir, "_supatype", "hooks.ts");
|
|
103
|
+
if (!existsSync(file))
|
|
104
|
+
return "none";
|
|
105
|
+
return createHash("sha256").update(readFileSync(file)).digest("hex").slice(0, 16);
|
|
106
|
+
}
|
|
107
|
+
/** The adapter hash the entry in `cwd` was written with: "none" when it names none or is not there. */
|
|
108
|
+
export function entryAdapterHash(cwd) {
|
|
109
|
+
const path = devFunctionsEntryPath(cwd);
|
|
110
|
+
if (!existsSync(path))
|
|
111
|
+
return "none";
|
|
112
|
+
const line = readFileSync(path, "utf8").split(/\r?\n/).find((l) => l.startsWith(ADAPTER_LINE));
|
|
113
|
+
return line === undefined ? "none" : line.slice(ADAPTER_LINE.length).trim();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* `deno run` arguments for `functions serve`: the worker under `--watch`, which reloads when a file
|
|
117
|
+
* it imported changes, also watching `watchDirs`, so a function added while it serves is found.
|
|
118
|
+
*/
|
|
119
|
+
export function functionsServeDenoArgs(workerMain, watchDirs, envFileArgs) {
|
|
120
|
+
const watch = watchDirs.length > 0 ? `--watch=${watchDirs.join(",")}` : "--watch";
|
|
121
|
+
return ["run", "--allow-net", "--allow-env", "--allow-read", watch, ...envFileArgs, workerMain];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The worker's environment for `project`, as self-host compose gives it to the image: functions
|
|
125
|
+
* and hooks roots, the project ref its log lines carry, and the routes `functions.serviceRole`
|
|
126
|
+
* grants the key. The key file stands in for the key itself, which a `--watch` reload would
|
|
127
|
+
* otherwise not find again. The shared env file is left to the worker's own default,
|
|
128
|
+
* `<functions root>/.env.local`.
|
|
129
|
+
*/
|
|
130
|
+
export function functionsWorkerEnv(project) {
|
|
131
|
+
const { cwd, config, keyPath } = project;
|
|
132
|
+
return {
|
|
133
|
+
SUPATYPE_FUNCTIONS_ROOT: project.functionsDir,
|
|
134
|
+
SUPATYPE_HOOKS_ROOT: hooksPathFromProject(config, cwd),
|
|
135
|
+
SUPATYPE_PROJECT_REF: config.project.name,
|
|
136
|
+
SUPATYPE_SERVICE_ROLE_ROUTES: serviceRoleRoutes(config).join(","),
|
|
137
|
+
...(keyPath !== undefined && { SUPATYPE_SERVICE_ROLE_KEY_FILE: keyPath }),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/** Where native dev keeps `functions.serviceRole` for its worker, which reads it on every reload. */
|
|
141
|
+
export function devServiceRoleRoutesPath(cwd) {
|
|
142
|
+
return join(resolve(cwd, ".supatype"), "service-role-routes");
|
|
143
|
+
}
|
|
144
|
+
/** Writes the routes `functions.serviceRole` grants the key, comma-separated, as the worker reads them. */
|
|
145
|
+
export function writeServiceRoleRoutesFile(path, routes) {
|
|
146
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
147
|
+
writeFileSync(path, routes.join(","), "utf8");
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=functions-worker-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions-worker-files.js","sourceRoot":"","sources":["../src/functions-worker-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE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