alchemy 0.25.0 → 0.26.1
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/README.md +7 -0
- package/lib/ai/astro-file.d.ts.map +1 -1
- package/lib/ai/astro-file.js +2 -1
- package/lib/ai/astro-file.js.map +1 -1
- package/lib/ai/client.d.ts.map +1 -1
- package/lib/ai/client.js +3 -2
- package/lib/ai/client.js.map +1 -1
- package/lib/alchemy.d.ts +7 -0
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +19 -3
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +63 -5
- package/lib/apply.js.map +1 -1
- package/lib/aws/control/client.js +4 -3
- package/lib/aws/control/client.js.map +1 -1
- package/lib/aws/control/properties.d.ts +6 -0
- package/lib/aws/control/properties.d.ts.map +1 -1
- package/lib/aws/control/properties.js +48 -0
- package/lib/aws/control/properties.js.map +1 -1
- package/lib/aws/control/resource.d.ts.map +1 -1
- package/lib/aws/control/resource.js +3 -2
- package/lib/aws/control/resource.js.map +1 -1
- package/lib/aws/control/types.d.ts +3969 -4862
- package/lib/aws/control/types.d.ts.map +1 -1
- package/lib/aws/control/types.js.map +1 -1
- package/lib/aws/function.d.ts.map +1 -1
- package/lib/aws/function.js +9 -8
- package/lib/aws/function.js.map +1 -1
- package/lib/aws/oidc/oidc-provider.d.ts.map +1 -1
- package/lib/aws/oidc/oidc-provider.js +3 -2
- package/lib/aws/oidc/oidc-provider.js.map +1 -1
- package/lib/aws/queue.d.ts.map +1 -1
- package/lib/aws/queue.js +3 -2
- package/lib/aws/queue.js.map +1 -1
- package/lib/aws/role.d.ts.map +1 -1
- package/lib/aws/role.js +3 -1
- package/lib/aws/role.js.map +1 -1
- package/lib/aws/ssm-parameter.d.ts.map +1 -1
- package/lib/aws/ssm-parameter.js +2 -1
- package/lib/aws/ssm-parameter.js.map +1 -1
- package/lib/cloudflare/account-api-token.d.ts.map +1 -1
- package/lib/cloudflare/account-api-token.js +3 -2
- package/lib/cloudflare/account-api-token.js.map +1 -1
- package/lib/cloudflare/ai-gateway.d.ts.map +1 -1
- package/lib/cloudflare/ai-gateway.js +4 -3
- package/lib/cloudflare/ai-gateway.js.map +1 -1
- package/lib/cloudflare/api-error.d.ts +0 -9
- package/lib/cloudflare/api-error.d.ts.map +1 -1
- package/lib/cloudflare/api-error.js +24 -0
- package/lib/cloudflare/api-error.js.map +1 -1
- package/lib/cloudflare/api.d.ts.map +1 -1
- package/lib/cloudflare/api.js +5 -4
- package/lib/cloudflare/api.js.map +1 -1
- package/lib/cloudflare/assets.d.ts.map +1 -1
- package/lib/cloudflare/assets.js +26 -6
- package/lib/cloudflare/assets.js.map +1 -1
- package/lib/cloudflare/astro.d.ts +63 -0
- package/lib/cloudflare/astro.d.ts.map +1 -0
- package/lib/cloudflare/astro.js +133 -0
- package/lib/cloudflare/astro.js.map +1 -0
- package/lib/cloudflare/auth.d.ts.map +1 -1
- package/lib/cloudflare/auth.js +3 -2
- package/lib/cloudflare/auth.js.map +1 -1
- package/lib/cloudflare/bindings.d.ts +24 -2
- package/lib/cloudflare/bindings.d.ts.map +1 -1
- package/lib/cloudflare/bindings.js.map +1 -1
- package/lib/cloudflare/bound.d.ts +10 -1
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +12 -8
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/bundle/bundle-worker.d.ts.map +1 -1
- package/lib/cloudflare/bundle/bundle-worker.js +2 -1
- package/lib/cloudflare/bundle/bundle-worker.js.map +1 -1
- package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts.map +1 -1
- package/lib/cloudflare/bundle/nodejs-compat-mode.js +2 -1
- package/lib/cloudflare/bundle/nodejs-compat-mode.js.map +1 -1
- package/lib/cloudflare/custom-domain.d.ts.map +1 -1
- package/lib/cloudflare/custom-domain.js +10 -9
- package/lib/cloudflare/custom-domain.js.map +1 -1
- package/lib/cloudflare/d1-database.d.ts.map +1 -1
- package/lib/cloudflare/d1-database.js +11 -10
- package/lib/cloudflare/d1-database.js.map +1 -1
- package/lib/cloudflare/d1-export.d.ts.map +1 -1
- package/lib/cloudflare/d1-export.js +2 -1
- package/lib/cloudflare/d1-export.js.map +1 -1
- package/lib/cloudflare/d1-import.d.ts.map +1 -1
- package/lib/cloudflare/d1-import.js +2 -1
- package/lib/cloudflare/d1-import.js.map +1 -1
- package/lib/cloudflare/d1-migrations.d.ts.map +1 -1
- package/lib/cloudflare/d1-migrations.js +2 -1
- package/lib/cloudflare/d1-migrations.js.map +1 -1
- package/lib/cloudflare/dispatch-namespace.d.ts +94 -0
- package/lib/cloudflare/dispatch-namespace.d.ts.map +1 -0
- package/lib/cloudflare/dispatch-namespace.js +143 -0
- package/lib/cloudflare/dispatch-namespace.js.map +1 -0
- package/lib/cloudflare/dns-records.d.ts.map +1 -1
- package/lib/cloudflare/dns-records.js +5 -4
- package/lib/cloudflare/dns-records.js.map +1 -1
- package/lib/cloudflare/do-state-store/worker.d.ts.map +1 -1
- package/lib/cloudflare/do-state-store/worker.js +4 -0
- package/lib/cloudflare/do-state-store/worker.js.map +1 -1
- package/lib/cloudflare/email-address.d.ts +79 -0
- package/lib/cloudflare/email-address.d.ts.map +1 -0
- package/lib/cloudflare/email-address.js +112 -0
- package/lib/cloudflare/email-address.js.map +1 -0
- package/lib/cloudflare/email-catch-all.d.ts +123 -0
- package/lib/cloudflare/email-catch-all.d.ts.map +1 -0
- package/lib/cloudflare/email-catch-all.js +124 -0
- package/lib/cloudflare/email-catch-all.js.map +1 -0
- package/lib/cloudflare/email-routing.d.ts +89 -0
- package/lib/cloudflare/email-routing.d.ts.map +1 -0
- package/lib/cloudflare/email-routing.js +120 -0
- package/lib/cloudflare/email-routing.js.map +1 -0
- package/lib/cloudflare/email-rule.d.ts +196 -0
- package/lib/cloudflare/email-rule.d.ts.map +1 -0
- package/lib/cloudflare/email-rule.js +153 -0
- package/lib/cloudflare/email-rule.js.map +1 -0
- package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
- package/lib/cloudflare/hyperdrive.js +5 -4
- package/lib/cloudflare/hyperdrive.js.map +1 -1
- package/lib/cloudflare/images.d.ts +60 -0
- package/lib/cloudflare/images.d.ts.map +1 -0
- package/lib/cloudflare/images.js +60 -0
- package/lib/cloudflare/images.js.map +1 -0
- package/lib/cloudflare/index.d.ts +10 -0
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +10 -0
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
- package/lib/cloudflare/kv-namespace.js +2 -1
- package/lib/cloudflare/kv-namespace.js.map +1 -1
- package/lib/cloudflare/pipeline.d.ts +7 -0
- package/lib/cloudflare/pipeline.d.ts.map +1 -1
- package/lib/cloudflare/pipeline.js +28 -2
- package/lib/cloudflare/pipeline.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +2 -1
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/queue.d.ts.map +1 -1
- package/lib/cloudflare/queue.js +0 -8
- package/lib/cloudflare/queue.js.map +1 -1
- package/lib/cloudflare/route.d.ts +26 -1
- package/lib/cloudflare/route.d.ts.map +1 -1
- package/lib/cloudflare/route.js +84 -16
- package/lib/cloudflare/route.js.map +1 -1
- package/lib/cloudflare/secret.d.ts +137 -0
- package/lib/cloudflare/secret.d.ts.map +1 -0
- package/lib/cloudflare/secret.js +122 -0
- package/lib/cloudflare/secret.js.map +1 -0
- package/lib/cloudflare/secrets-store.d.ts +145 -0
- package/lib/cloudflare/secrets-store.d.ts.map +1 -0
- package/lib/cloudflare/secrets-store.js +213 -0
- package/lib/cloudflare/secrets-store.js.map +1 -0
- package/lib/cloudflare/sveltekit.d.ts +49 -0
- package/lib/cloudflare/sveltekit.d.ts.map +1 -0
- package/lib/cloudflare/sveltekit.js +56 -0
- package/lib/cloudflare/sveltekit.js.map +1 -0
- package/lib/cloudflare/user.d.ts.map +1 -1
- package/lib/cloudflare/user.js +2 -1
- package/lib/cloudflare/user.js.map +1 -1
- package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-index.js +6 -5
- package/lib/cloudflare/vectorize-index.js.map +1 -1
- package/lib/cloudflare/vectorize-metadata-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-metadata-index.js +2 -1
- package/lib/cloudflare/vectorize-metadata-index.js.map +1 -1
- package/lib/cloudflare/website.d.ts.map +1 -1
- package/lib/cloudflare/website.js +7 -2
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-assets.d.ts +18 -0
- package/lib/cloudflare/worker-assets.d.ts.map +1 -1
- package/lib/cloudflare/worker-assets.js +61 -67
- package/lib/cloudflare/worker-assets.js.map +1 -1
- package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
- package/lib/cloudflare/worker-metadata.js +23 -1
- package/lib/cloudflare/worker-metadata.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +43 -2
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +50 -11
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.d.ts +21 -0
- package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
- package/lib/cloudflare/wrangler.json.js +33 -0
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/cloudflare/zone.d.ts.map +1 -1
- package/lib/cloudflare/zone.js +4 -3
- package/lib/cloudflare/zone.js.map +1 -1
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js +30 -13
- package/lib/destroy.js.map +1 -1
- package/lib/dns/godaddy.d.ts.map +1 -1
- package/lib/dns/godaddy.js +3 -2
- package/lib/dns/godaddy.js.map +1 -1
- package/lib/dns/import-dns.d.ts.map +1 -1
- package/lib/dns/import-dns.js +2 -1
- package/lib/dns/import-dns.js.map +1 -1
- package/lib/esbuild/bundle.d.ts +1 -1
- package/lib/esbuild/bundle.d.ts.map +1 -1
- package/lib/esbuild/bundle.js +2 -1
- package/lib/esbuild/bundle.js.map +1 -1
- package/lib/fs/copy-file.d.ts.map +1 -1
- package/lib/fs/copy-file.js +2 -1
- package/lib/fs/copy-file.js.map +1 -1
- package/lib/fs/file.d.ts.map +1 -1
- package/lib/fs/file.js +2 -1
- package/lib/fs/file.js.map +1 -1
- package/lib/github/client.d.ts.map +1 -1
- package/lib/github/client.js +11 -10
- package/lib/github/client.js.map +1 -1
- package/lib/github/repository-environment.d.ts.map +1 -1
- package/lib/github/repository-environment.js +5 -4
- package/lib/github/repository-environment.js.map +1 -1
- package/lib/github/secret.d.ts.map +1 -1
- package/lib/github/secret.js +7 -6
- package/lib/github/secret.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/neon/project.d.ts.map +1 -1
- package/lib/neon/project.js +3 -2
- package/lib/neon/project.js.map +1 -1
- package/lib/planetscale/api.d.ts +53 -0
- package/lib/planetscale/api.d.ts.map +1 -0
- package/lib/planetscale/api.js +84 -0
- package/lib/planetscale/api.js.map +1 -0
- package/lib/planetscale/branch.d.ts +129 -0
- package/lib/planetscale/branch.d.ts.map +1 -0
- package/lib/planetscale/branch.js +161 -0
- package/lib/planetscale/branch.js.map +1 -0
- package/lib/planetscale/database.d.ts +143 -0
- package/lib/planetscale/database.d.ts.map +1 -0
- package/lib/planetscale/database.js +184 -0
- package/lib/planetscale/database.js.map +1 -0
- package/lib/planetscale/index.d.ts +5 -0
- package/lib/planetscale/index.d.ts.map +1 -0
- package/lib/planetscale/index.js +5 -0
- package/lib/planetscale/index.js.map +1 -0
- package/lib/planetscale/utils.d.ts +15 -0
- package/lib/planetscale/utils.d.ts.map +1 -0
- package/lib/planetscale/utils.js +95 -0
- package/lib/planetscale/utils.js.map +1 -0
- package/lib/resource.js +7 -1
- package/lib/resource.js.map +1 -1
- package/lib/runtime/plugin.d.ts.map +1 -1
- package/lib/runtime/plugin.js +2 -1
- package/lib/runtime/plugin.js.map +1 -1
- package/lib/scope.d.ts +13 -2
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +53 -10
- package/lib/scope.js.map +1 -1
- package/lib/sentry/client-key.d.ts.map +1 -1
- package/lib/sentry/client-key.js +5 -4
- package/lib/sentry/client-key.js.map +1 -1
- package/lib/sentry/project.d.ts.map +1 -1
- package/lib/sentry/project.js +5 -4
- package/lib/sentry/project.js.map +1 -1
- package/lib/sentry/team.d.ts.map +1 -1
- package/lib/sentry/team.js +5 -4
- package/lib/sentry/team.js.map +1 -1
- package/lib/stripe/card.d.ts.map +1 -1
- package/lib/stripe/card.js +2 -1
- package/lib/stripe/card.js.map +1 -1
- package/lib/stripe/client.d.ts.map +1 -1
- package/lib/stripe/client.js +3 -2
- package/lib/stripe/client.js.map +1 -1
- package/lib/stripe/coupon.d.ts.map +1 -1
- package/lib/stripe/coupon.js +2 -1
- package/lib/stripe/coupon.js.map +1 -1
- package/lib/stripe/customer.d.ts.map +1 -1
- package/lib/stripe/customer.js +2 -1
- package/lib/stripe/customer.js.map +1 -1
- package/lib/stripe/entitlements-feature.d.ts.map +1 -1
- package/lib/stripe/entitlements-feature.js +2 -1
- package/lib/stripe/entitlements-feature.js.map +1 -1
- package/lib/stripe/file.d.ts.map +1 -1
- package/lib/stripe/file.js +2 -1
- package/lib/stripe/file.js.map +1 -1
- package/lib/stripe/meter.d.ts.map +1 -1
- package/lib/stripe/meter.js +4 -2
- package/lib/stripe/meter.js.map +1 -1
- package/lib/stripe/portal-configuration.d.ts.map +1 -1
- package/lib/stripe/portal-configuration.js +2 -1
- package/lib/stripe/portal-configuration.js.map +1 -1
- package/lib/stripe/price.d.ts.map +1 -1
- package/lib/stripe/price.js +2 -1
- package/lib/stripe/price.js.map +1 -1
- package/lib/stripe/product-feature.d.ts.map +1 -1
- package/lib/stripe/product-feature.js +2 -1
- package/lib/stripe/product-feature.js.map +1 -1
- package/lib/stripe/product.d.ts.map +1 -1
- package/lib/stripe/product.js +2 -1
- package/lib/stripe/product.js.map +1 -1
- package/lib/stripe/promotion-code.d.ts.map +1 -1
- package/lib/stripe/promotion-code.js +2 -1
- package/lib/stripe/promotion-code.js.map +1 -1
- package/lib/stripe/shipping-rate.d.ts.map +1 -1
- package/lib/stripe/shipping-rate.js +2 -1
- package/lib/stripe/shipping-rate.js.map +1 -1
- package/lib/stripe/tax-rate.d.ts.map +1 -1
- package/lib/stripe/tax-rate.js +2 -1
- package/lib/stripe/tax-rate.js.map +1 -1
- package/lib/stripe/webhook.d.ts.map +1 -1
- package/lib/stripe/webhook.js +3 -2
- package/lib/stripe/webhook.js.map +1 -1
- package/lib/test/bun.d.ts.map +1 -1
- package/lib/test/bun.js +6 -1
- package/lib/test/bun.js.map +1 -1
- package/lib/test/prune.js +7 -1
- package/lib/test/prune.js.map +1 -1
- package/lib/test/vitest.d.ts.map +1 -1
- package/lib/test/vitest.js +10 -3
- package/lib/test/vitest.js.map +1 -1
- package/lib/upstash/redis.d.ts.map +1 -1
- package/lib/upstash/redis.js +2 -1
- package/lib/upstash/redis.js.map +1 -1
- package/lib/util/async-queue.d.ts +35 -0
- package/lib/util/async-queue.d.ts.map +1 -0
- package/lib/util/async-queue.js +87 -0
- package/lib/util/async-queue.js.map +1 -0
- package/lib/util/cli.d.ts +37 -0
- package/lib/util/cli.d.ts.map +1 -0
- package/lib/util/cli.js +90 -0
- package/lib/util/cli.js.map +1 -0
- package/lib/util/ignore-matcher.d.ts +94 -0
- package/lib/util/ignore-matcher.d.ts.map +1 -0
- package/lib/util/ignore-matcher.js +616 -0
- package/lib/util/ignore-matcher.js.map +1 -0
- package/lib/util/logger.d.ts +3 -0
- package/lib/util/logger.d.ts.map +1 -0
- package/lib/util/logger.js +15 -0
- package/lib/util/logger.js.map +1 -0
- package/lib/util/retry.d.ts.map +1 -1
- package/lib/util/retry.js +0 -1
- package/lib/util/retry.js.map +1 -1
- package/lib/util/safe-fetch.d.ts.map +1 -1
- package/lib/util/safe-fetch.js +2 -1
- package/lib/util/safe-fetch.js.map +1 -1
- package/lib/util/telemetry/client.d.ts +32 -0
- package/lib/util/telemetry/client.d.ts.map +1 -0
- package/lib/util/telemetry/client.js +94 -0
- package/lib/util/telemetry/client.js.map +1 -0
- package/lib/util/telemetry/constants.d.ts +4 -0
- package/lib/util/telemetry/constants.d.ts.map +1 -0
- package/lib/util/telemetry/constants.js +8 -0
- package/lib/util/telemetry/constants.js.map +1 -0
- package/lib/util/telemetry/context.d.ts +15 -0
- package/lib/util/telemetry/context.d.ts.map +1 -0
- package/lib/util/telemetry/context.js +128 -0
- package/lib/util/telemetry/context.js.map +1 -0
- package/lib/util/telemetry/index.d.ts +3 -0
- package/lib/util/telemetry/index.d.ts.map +1 -0
- package/lib/util/telemetry/index.js +3 -0
- package/lib/util/telemetry/index.js.map +1 -0
- package/lib/util/telemetry/types.d.ts +59 -0
- package/lib/util/telemetry/types.d.ts.map +1 -0
- package/lib/util/telemetry/types.js +1 -0
- package/lib/util/telemetry/types.js.map +1 -0
- package/lib/util/xdg-paths.d.ts +9 -0
- package/lib/util/xdg-paths.d.ts.map +1 -0
- package/lib/util/xdg-paths.js +41 -0
- package/lib/util/xdg-paths.js.map +1 -0
- package/lib/vercel/project.d.ts.map +1 -1
- package/lib/vercel/project.js +2 -1
- package/lib/vercel/project.js.map +1 -1
- package/lib/web/astro.d.ts.map +1 -1
- package/lib/web/astro.js +2 -1
- package/lib/web/astro.js.map +1 -1
- package/lib/web/shadcn.d.ts.map +1 -1
- package/lib/web/shadcn.js +2 -1
- package/lib/web/shadcn.js.map +1 -1
- package/lib/web/vite.d.ts.map +1 -1
- package/lib/web/vite.js +3 -2
- package/lib/web/vite.js.map +1 -1
- package/lib/web/vitepress/dependencies.d.ts.map +1 -1
- package/lib/web/vitepress/dependencies.js +2 -1
- package/lib/web/vitepress/dependencies.js.map +1 -1
- package/lib/web/vitepress/vitepress.d.ts.map +1 -1
- package/lib/web/vitepress/vitepress.js +2 -1
- package/lib/web/vitepress/vitepress.js.map +1 -1
- package/package.json +6 -4
- package/src/ai/astro-file.ts +2 -1
- package/src/ai/client.ts +3 -2
- package/src/alchemy.ts +28 -3
- package/src/apply.ts +66 -5
- package/src/aws/control/client.ts +4 -4
- package/src/aws/control/properties.ts +48 -0
- package/src/aws/control/resource.ts +3 -2
- package/src/aws/control/types.ts +3988 -6301
- package/src/aws/function.ts +9 -8
- package/src/aws/oidc/oidc-provider.ts +3 -2
- package/src/aws/queue.ts +3 -2
- package/src/aws/role.ts +3 -1
- package/src/aws/ssm-parameter.ts +2 -1
- package/src/cloudflare/account-api-token.ts +3 -2
- package/src/cloudflare/ai-gateway.ts +4 -3
- package/src/cloudflare/api-error.ts +36 -0
- package/src/cloudflare/api.ts +9 -4
- package/src/cloudflare/assets.ts +30 -6
- package/src/cloudflare/astro.ts +176 -0
- package/src/cloudflare/auth.ts +3 -2
- package/src/cloudflare/bindings.ts +29 -0
- package/src/cloudflare/bound.ts +38 -21
- package/src/cloudflare/bucket.ts +15 -8
- package/src/cloudflare/bundle/bundle-worker.ts +2 -1
- package/src/cloudflare/bundle/nodejs-compat-mode.ts +2 -1
- package/src/cloudflare/custom-domain.ts +10 -9
- package/src/cloudflare/d1-database.ts +11 -10
- package/src/cloudflare/d1-export.ts +2 -1
- package/src/cloudflare/d1-import.ts +2 -1
- package/src/cloudflare/d1-migrations.ts +2 -1
- package/src/cloudflare/dispatch-namespace.ts +281 -0
- package/src/cloudflare/dns-records.ts +5 -4
- package/src/cloudflare/do-state-store/worker.ts +4 -0
- package/src/cloudflare/email-address.ts +203 -0
- package/src/cloudflare/email-catch-all.ts +248 -0
- package/src/cloudflare/email-routing.ts +230 -0
- package/src/cloudflare/email-rule.ts +322 -0
- package/src/cloudflare/hyperdrive.ts +5 -4
- package/src/cloudflare/images.ts +59 -0
- package/src/cloudflare/index.ts +10 -0
- package/src/cloudflare/kv-namespace.ts +2 -1
- package/src/cloudflare/pipeline.ts +38 -2
- package/src/cloudflare/queue-consumer.ts +2 -1
- package/src/cloudflare/queue.ts +0 -12
- package/src/cloudflare/route.ts +118 -18
- package/src/cloudflare/secret.ts +253 -0
- package/src/cloudflare/secrets-store.ts +420 -0
- package/src/cloudflare/sveltekit.ts +72 -0
- package/src/cloudflare/user.ts +2 -1
- package/src/cloudflare/vectorize-index.ts +6 -5
- package/src/cloudflare/vectorize-metadata-index.ts +2 -1
- package/src/cloudflare/website.ts +76 -66
- package/src/cloudflare/worker-assets.ts +95 -89
- package/src/cloudflare/worker-metadata.ts +20 -1
- package/src/cloudflare/worker.ts +116 -18
- package/src/cloudflare/wrangler.json.ts +63 -0
- package/src/cloudflare/zone.ts +4 -3
- package/src/destroy.ts +35 -17
- package/src/dns/godaddy.ts +3 -2
- package/src/dns/import-dns.ts +2 -1
- package/src/esbuild/bundle.ts +2 -1
- package/src/fs/copy-file.ts +2 -1
- package/src/fs/file.ts +3 -1
- package/src/github/client.ts +11 -10
- package/src/github/repository-environment.ts +5 -4
- package/src/github/secret.ts +7 -6
- package/src/index.ts +2 -1
- package/src/neon/project.ts +3 -2
- package/src/planetscale/api.ts +115 -0
- package/src/planetscale/branch.ts +352 -0
- package/src/planetscale/database.ts +394 -0
- package/src/planetscale/index.ts +4 -0
- package/src/planetscale/utils.ts +189 -0
- package/src/resource.ts +7 -1
- package/src/runtime/plugin.ts +2 -1
- package/src/scope.ts +64 -13
- package/src/sentry/client-key.ts +5 -4
- package/src/sentry/project.ts +5 -4
- package/src/sentry/team.ts +5 -4
- package/src/stripe/card.ts +2 -1
- package/src/stripe/client.ts +3 -2
- package/src/stripe/coupon.ts +2 -1
- package/src/stripe/customer.ts +2 -1
- package/src/stripe/entitlements-feature.ts +2 -1
- package/src/stripe/file.ts +2 -1
- package/src/stripe/meter.ts +4 -2
- package/src/stripe/portal-configuration.ts +2 -1
- package/src/stripe/price.ts +2 -1
- package/src/stripe/product-feature.ts +2 -1
- package/src/stripe/product.ts +2 -1
- package/src/stripe/promotion-code.ts +2 -1
- package/src/stripe/shipping-rate.ts +2 -1
- package/src/stripe/tax-rate.ts +2 -1
- package/src/stripe/webhook.ts +3 -2
- package/src/test/bun.ts +6 -1
- package/src/test/prune.ts +7 -1
- package/src/test/vitest.ts +14 -3
- package/src/upstash/redis.ts +2 -1
- package/src/util/async-queue.ts +97 -0
- package/src/util/cli.tsx +221 -0
- package/src/util/ignore-matcher.ts +873 -0
- package/src/util/logger.ts +17 -0
- package/src/util/retry.ts +0 -1
- package/src/util/safe-fetch.ts +2 -1
- package/src/util/telemetry/client.ts +127 -0
- package/src/util/telemetry/constants.ts +13 -0
- package/src/util/telemetry/context.ts +154 -0
- package/src/util/telemetry/index.ts +2 -0
- package/src/util/telemetry/types.ts +83 -0
- package/src/util/xdg-paths.ts +48 -0
- package/src/vercel/project.ts +2 -1
- package/src/web/astro.ts +2 -1
- package/src/web/shadcn.ts +2 -1
- package/src/web/vite.ts +3 -2
- package/src/web/vitepress/dependencies.ts +2 -1
- package/src/web/vitepress/vitepress.ts +2 -1
package/src/cloudflare/bound.ts
CHANGED
|
@@ -8,10 +8,13 @@ import type { Binding, Json, Self } from "./bindings.ts";
|
|
|
8
8
|
import type { BrowserRendering } from "./browser-rendering.ts";
|
|
9
9
|
import type { R2BucketResource as _R2Bucket } from "./bucket.ts";
|
|
10
10
|
import type { D1DatabaseResource } from "./d1-database.ts";
|
|
11
|
+
import type { DispatchNamespaceResource } from "./dispatch-namespace.ts";
|
|
11
12
|
import type { DurableObjectNamespace as _DurableObjectNamespace } from "./durable-object-namespace.ts";
|
|
12
13
|
import type { HyperdriveResource as _Hyperdrive } from "./hyperdrive.ts";
|
|
14
|
+
import type { Images as _Images } from "./images.ts";
|
|
13
15
|
import type { PipelineResource as _Pipeline } from "./pipeline.ts";
|
|
14
16
|
import type { QueueResource as _Queue } from "./queue.ts";
|
|
17
|
+
import type { SecretsStore as _SecretsStore } from "./secrets-store.ts";
|
|
15
18
|
import type { VectorizeIndexResource as _VectorizeIndex } from "./vectorize-index.ts";
|
|
16
19
|
import type { VersionMetadata as _VersionMetadata } from "./version-metadata.ts";
|
|
17
20
|
import type { Worker as _Worker, WorkerRef } from "./worker.ts";
|
|
@@ -48,24 +51,38 @@ export type Bound<T extends Binding> = T extends _DurableObjectNamespace<
|
|
|
48
51
|
? Workflow<P>
|
|
49
52
|
: T extends D1DatabaseResource
|
|
50
53
|
? D1Database
|
|
51
|
-
: T extends
|
|
52
|
-
?
|
|
53
|
-
: T extends
|
|
54
|
-
?
|
|
55
|
-
: T extends
|
|
56
|
-
?
|
|
57
|
-
: T extends
|
|
58
|
-
?
|
|
59
|
-
: T extends
|
|
60
|
-
?
|
|
61
|
-
: T extends
|
|
62
|
-
?
|
|
63
|
-
: T extends
|
|
64
|
-
?
|
|
65
|
-
: T extends
|
|
66
|
-
?
|
|
67
|
-
: T extends
|
|
68
|
-
?
|
|
69
|
-
: T extends
|
|
70
|
-
?
|
|
71
|
-
:
|
|
54
|
+
: T extends DispatchNamespaceResource
|
|
55
|
+
? { get(name: string): Fetcher }
|
|
56
|
+
: T extends _VectorizeIndex
|
|
57
|
+
? VectorizeIndex
|
|
58
|
+
: T extends _Queue<infer Body>
|
|
59
|
+
? Queue<Body>
|
|
60
|
+
: T extends _SecretsStore<infer S>
|
|
61
|
+
? SecretsStoreBinding<S>
|
|
62
|
+
: T extends _AnalyticsEngineDataset
|
|
63
|
+
? AnalyticsEngineDataset
|
|
64
|
+
: T extends _Pipeline<infer R>
|
|
65
|
+
? Pipeline<R>
|
|
66
|
+
: T extends string
|
|
67
|
+
? string
|
|
68
|
+
: T extends BrowserRendering
|
|
69
|
+
? Fetcher
|
|
70
|
+
: T extends _Ai<infer M>
|
|
71
|
+
? Ai<M>
|
|
72
|
+
: T extends _Images
|
|
73
|
+
? ImagesBinding
|
|
74
|
+
: T extends _VersionMetadata
|
|
75
|
+
? WorkerVersionMetadata
|
|
76
|
+
: T extends Self
|
|
77
|
+
? Service
|
|
78
|
+
: T extends Json<infer T>
|
|
79
|
+
? T
|
|
80
|
+
: Service;
|
|
81
|
+
|
|
82
|
+
interface SecretsStoreBinding<
|
|
83
|
+
S extends Record<string, Secret> | undefined = undefined,
|
|
84
|
+
> {
|
|
85
|
+
get(
|
|
86
|
+
key: (S extends Record<string, any> ? keyof S : never) | (string & {}),
|
|
87
|
+
): Promise<string>;
|
|
88
|
+
}
|
package/src/cloudflare/bucket.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Context } from "../context.ts";
|
|
|
3
3
|
import { Resource, ResourceKind } from "../resource.ts";
|
|
4
4
|
import { bind } from "../runtime/bind.ts";
|
|
5
5
|
import type { Secret } from "../secret.ts";
|
|
6
|
+
import { logger } from "../util/logger.ts";
|
|
6
7
|
import { CloudflareApiError, handleApiError } from "./api-error.ts";
|
|
7
8
|
import { type CloudflareApi, createCloudflareApi } from "./api.ts";
|
|
8
9
|
import type { Bound } from "./bound.ts";
|
|
@@ -195,7 +196,7 @@ const R2BucketResource = Resource(
|
|
|
195
196
|
if (this.phase === "delete") {
|
|
196
197
|
if (props.delete !== false) {
|
|
197
198
|
if (props.empty) {
|
|
198
|
-
|
|
199
|
+
logger.log("Emptying R2 bucket:", bucketName);
|
|
199
200
|
const r2Client = await createR2Client({
|
|
200
201
|
...props,
|
|
201
202
|
accountId: api.accountId,
|
|
@@ -227,6 +228,12 @@ const R2BucketResource = Resource(
|
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
|
|
231
|
+
if (this.phase === "update" && bucketName !== this.output.name) {
|
|
232
|
+
throw new Error(
|
|
233
|
+
`Cannot update R2Bucket name after creation. Bucket name is immutable. Before: ${this.output.name}, After: ${bucketName}`,
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
230
237
|
await updatePublicAccess(
|
|
231
238
|
api,
|
|
232
239
|
bucketName,
|
|
@@ -497,7 +504,7 @@ export async function emptyBucket(
|
|
|
497
504
|
|
|
498
505
|
try {
|
|
499
506
|
do {
|
|
500
|
-
|
|
507
|
+
logger.log(`Listing objects in bucket ${bucketName}`);
|
|
501
508
|
// List objects in the bucket
|
|
502
509
|
const { objects, continuationToken: nextToken } = await listObjects(
|
|
503
510
|
r2,
|
|
@@ -508,7 +515,7 @@ export async function emptyBucket(
|
|
|
508
515
|
|
|
509
516
|
continuationToken = nextToken;
|
|
510
517
|
|
|
511
|
-
|
|
518
|
+
logger.log(`Found ${objects.length} objects in bucket ${bucketName}`);
|
|
512
519
|
|
|
513
520
|
// Delete objects in batches
|
|
514
521
|
if (objects.length > 0) {
|
|
@@ -527,7 +534,7 @@ export async function emptyBucket(
|
|
|
527
534
|
`https://${r2.accountId}.r2.cloudflarestorage.com/${bucketName}?delete`,
|
|
528
535
|
);
|
|
529
536
|
|
|
530
|
-
|
|
537
|
+
logger.log(
|
|
531
538
|
`Deleting ${batch.length} objects from bucket ${bucketName}`,
|
|
532
539
|
);
|
|
533
540
|
|
|
@@ -554,7 +561,7 @@ export async function emptyBucket(
|
|
|
554
561
|
}
|
|
555
562
|
} while (continuationToken);
|
|
556
563
|
|
|
557
|
-
|
|
564
|
+
logger.log(
|
|
558
565
|
`Successfully emptied bucket ${bucketName}, deleted ${totalDeleted} objects total`,
|
|
559
566
|
);
|
|
560
567
|
} catch (error) {
|
|
@@ -562,7 +569,7 @@ export async function emptyBucket(
|
|
|
562
569
|
// the bucket was not found
|
|
563
570
|
return;
|
|
564
571
|
}
|
|
565
|
-
|
|
572
|
+
logger.error(`Failed to empty bucket ${bucketName}:`, error);
|
|
566
573
|
throw error;
|
|
567
574
|
}
|
|
568
575
|
}
|
|
@@ -647,9 +654,9 @@ export async function setCorsConfiguration(
|
|
|
647
654
|
);
|
|
648
655
|
}
|
|
649
656
|
|
|
650
|
-
|
|
657
|
+
logger.log(`Successfully set CORS configuration for bucket ${bucketName}`);
|
|
651
658
|
} catch (error) {
|
|
652
|
-
|
|
659
|
+
logger.error(
|
|
653
660
|
`Failed to set CORS configuration for bucket ${bucketName}:`,
|
|
654
661
|
error,
|
|
655
662
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Bundle } from "../../esbuild/bundle.ts";
|
|
4
|
+
import { logger } from "../../util/logger.ts";
|
|
4
5
|
import type { Bindings } from "../bindings.ts";
|
|
5
6
|
import type { WorkerProps } from "../worker.ts";
|
|
6
7
|
import { createAliasPlugin } from "./alias-plugin.ts";
|
|
@@ -124,7 +125,7 @@ export async function bundleWorkerScript<B extends Bindings>(
|
|
|
124
125
|
rewriteNodeCompatBuildFailure(e.errors, nodeJsCompatMode);
|
|
125
126
|
throw e;
|
|
126
127
|
}
|
|
127
|
-
|
|
128
|
+
logger.error("Error reading bundle:", e);
|
|
128
129
|
throw new Error("Error reading bundle");
|
|
129
130
|
}
|
|
130
131
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NodeJSCompatMode } from "miniflare";
|
|
2
|
+
import { logger } from "../../util/logger.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Computes and validates the Node.js compatibility mode we are running.
|
|
@@ -40,7 +41,7 @@ export async function getNodeJSCompatMode(
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
if (props?.noBundle && hasNodejsCompatV2Flag) {
|
|
43
|
-
|
|
44
|
+
logger.warn(
|
|
44
45
|
"`nodejs_compat_v2` compatibility flag and `--no-bundle` can't be used together. If you want to polyfill Node.js built-ins and disable Wrangler's bundling, please polyfill as part of your own bundling process.",
|
|
45
46
|
);
|
|
46
47
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context } from "../context.ts";
|
|
2
2
|
import { Resource } from "../resource.ts";
|
|
3
|
+
import { logger } from "../util/logger.ts";
|
|
3
4
|
import { handleApiError } from "./api-error.ts";
|
|
4
5
|
import {
|
|
5
6
|
createCloudflareApi,
|
|
@@ -127,20 +128,20 @@ async function deleteCustomDomain(
|
|
|
127
128
|
const domainIdToDelete = context.output?.id;
|
|
128
129
|
|
|
129
130
|
if (!domainIdToDelete) {
|
|
130
|
-
|
|
131
|
+
logger.warn(
|
|
131
132
|
`Cannot delete CustomDomain ${logicalId} (${domainHostname}): Missing domain ID in state. Assuming already deleted.`,
|
|
132
133
|
);
|
|
133
134
|
return; // Exit early if no ID
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
|
|
137
|
+
logger.log(
|
|
137
138
|
`Deleting CustomDomain binding ${domainIdToDelete} for ${domainHostname}`,
|
|
138
139
|
);
|
|
139
140
|
const response = await api.delete(
|
|
140
141
|
`/accounts/${api.accountId}/workers/domains/${domainIdToDelete}`,
|
|
141
142
|
);
|
|
142
143
|
|
|
143
|
-
|
|
144
|
+
logger.log(
|
|
144
145
|
`Delete result for ${domainIdToDelete} (${domainHostname}):`,
|
|
145
146
|
response.status,
|
|
146
147
|
response.statusText,
|
|
@@ -172,7 +173,7 @@ async function ensureCustomDomain(
|
|
|
172
173
|
const domainHostname = props.name;
|
|
173
174
|
|
|
174
175
|
// Check if domain binding already exists for this account
|
|
175
|
-
|
|
176
|
+
logger.log(`Checking existing domain bindings for account ${api.accountId}`);
|
|
176
177
|
const listResponse = await api.get(
|
|
177
178
|
`/accounts/${api.accountId}/workers/domains`,
|
|
178
179
|
);
|
|
@@ -210,7 +211,7 @@ async function ensureCustomDomain(
|
|
|
210
211
|
let currentDomainId = existingBinding?.id;
|
|
211
212
|
const bindingExists = !!existingBinding;
|
|
212
213
|
|
|
213
|
-
|
|
214
|
+
logger.log(
|
|
214
215
|
`Domain binding status for ${domainHostname} (Zone: ${props.zoneId}):`,
|
|
215
216
|
bindingExists
|
|
216
217
|
? `Found (ID: ${currentDomainId}, Worker: ${existingBinding.service}, Env: ${existingBinding.environment})`
|
|
@@ -230,7 +231,7 @@ async function ensureCustomDomain(
|
|
|
230
231
|
// Cloudflare's PUT /accounts/{account_id}/workers/domains acts as an upsert
|
|
231
232
|
if (!bindingExists || needsUpdate) {
|
|
232
233
|
operationPerformed = bindingExists ? "update" : "create";
|
|
233
|
-
|
|
234
|
+
logger.log(
|
|
234
235
|
`${operationPerformed === "update" ? "Updating" : "Creating"} domain binding: ${domainHostname} (Zone: ${props.zoneId}) → ${props.workerName}:${environment}`,
|
|
235
236
|
);
|
|
236
237
|
|
|
@@ -272,11 +273,11 @@ async function ensureCustomDomain(
|
|
|
272
273
|
|
|
273
274
|
resultantBinding = putResult.result;
|
|
274
275
|
currentDomainId = resultantBinding.id; // Update ID from the PUT response
|
|
275
|
-
|
|
276
|
+
logger.log(
|
|
276
277
|
`Successfully ${operationPerformed}d binding, new ID: ${currentDomainId}`,
|
|
277
278
|
);
|
|
278
279
|
} else {
|
|
279
|
-
|
|
280
|
+
logger.log(
|
|
280
281
|
`Domain binding already exists and is up to date: ${domainHostname} (ID: ${currentDomainId}) → ${props.workerName}:${environment}`,
|
|
281
282
|
);
|
|
282
283
|
}
|
|
@@ -284,7 +285,7 @@ async function ensureCustomDomain(
|
|
|
284
285
|
// Ensure we have the final binding details
|
|
285
286
|
if (!resultantBinding || !currentDomainId) {
|
|
286
287
|
// This case should ideally not happen if API calls succeed
|
|
287
|
-
|
|
288
|
+
logger.error("Error: Could not determine final domain binding state.", {
|
|
288
289
|
existingBinding,
|
|
289
290
|
resultantBinding,
|
|
290
291
|
currentDomainId,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Context } from "../context.ts";
|
|
2
2
|
import { Resource, ResourceKind } from "../resource.ts";
|
|
3
3
|
import { bind, type Bound } from "../runtime/bind.ts";
|
|
4
|
+
import { logger } from "../util/logger.ts";
|
|
4
5
|
import { CloudflareApiError, handleApiError } from "./api-error.ts";
|
|
5
6
|
import {
|
|
6
7
|
createCloudflareApi,
|
|
@@ -240,10 +241,10 @@ const D1DatabaseResource = Resource(
|
|
|
240
241
|
const databaseName = props.name ?? id;
|
|
241
242
|
|
|
242
243
|
if (this.phase === "delete") {
|
|
243
|
-
|
|
244
|
+
logger.log("Deleting D1 database:", databaseName);
|
|
244
245
|
if (props.delete !== false) {
|
|
245
246
|
// Delete D1 database
|
|
246
|
-
|
|
247
|
+
logger.log("Deleting D1 database:", databaseName);
|
|
247
248
|
await deleteDatabase(api, this.output?.id);
|
|
248
249
|
}
|
|
249
250
|
|
|
@@ -253,7 +254,7 @@ const D1DatabaseResource = Resource(
|
|
|
253
254
|
let dbData: CloudflareD1Response;
|
|
254
255
|
|
|
255
256
|
if (this.phase === "create") {
|
|
256
|
-
|
|
257
|
+
logger.log("Creating D1 database:", databaseName);
|
|
257
258
|
try {
|
|
258
259
|
dbData = await createDatabase(api, databaseName, props);
|
|
259
260
|
|
|
@@ -273,7 +274,7 @@ const D1DatabaseResource = Resource(
|
|
|
273
274
|
error instanceof CloudflareApiError &&
|
|
274
275
|
error.message.includes("already exists")
|
|
275
276
|
) {
|
|
276
|
-
|
|
277
|
+
logger.log(`Database ${databaseName} already exists, adopting it`);
|
|
277
278
|
// Find the existing database by name
|
|
278
279
|
const databases = await listDatabases(api, databaseName);
|
|
279
280
|
const existingDb = databases.find((db) => db.name === databaseName);
|
|
@@ -289,7 +290,7 @@ const D1DatabaseResource = Resource(
|
|
|
289
290
|
|
|
290
291
|
// Update the database with the provided properties
|
|
291
292
|
if (props.readReplication) {
|
|
292
|
-
|
|
293
|
+
logger.log(
|
|
293
294
|
`Updating adopted database ${databaseName} with new properties`,
|
|
294
295
|
);
|
|
295
296
|
dbData = await updateDatabase(api, existingDb.id, props);
|
|
@@ -311,12 +312,12 @@ const D1DatabaseResource = Resource(
|
|
|
311
312
|
`Cannot update primaryLocationHint from '${this.output.primaryLocationHint}' to '${props.primaryLocationHint}' after database creation.`,
|
|
312
313
|
);
|
|
313
314
|
}
|
|
314
|
-
|
|
315
|
+
logger.log("Updating D1 database:", databaseName);
|
|
315
316
|
// Update the database with new properties
|
|
316
317
|
dbData = await updateDatabase(api, this.output.id, props);
|
|
317
318
|
} else {
|
|
318
319
|
// If no ID exists, fall back to creating a new database
|
|
319
|
-
|
|
320
|
+
logger.log(
|
|
320
321
|
"No existing database ID found, creating new D1 database:",
|
|
321
322
|
databaseName,
|
|
322
323
|
);
|
|
@@ -342,7 +343,7 @@ const D1DatabaseResource = Resource(
|
|
|
342
343
|
api,
|
|
343
344
|
});
|
|
344
345
|
} catch (migrationErr) {
|
|
345
|
-
|
|
346
|
+
logger.error("Failed to apply D1 migrations:", migrationErr);
|
|
346
347
|
throw migrationErr;
|
|
347
348
|
}
|
|
348
349
|
}
|
|
@@ -443,7 +444,7 @@ export async function deleteDatabase(
|
|
|
443
444
|
databaseId?: string,
|
|
444
445
|
): Promise<void> {
|
|
445
446
|
if (!databaseId) {
|
|
446
|
-
|
|
447
|
+
logger.log("No database ID provided, skipping delete");
|
|
447
448
|
return;
|
|
448
449
|
}
|
|
449
450
|
|
|
@@ -580,7 +581,7 @@ async function cloneDb(
|
|
|
580
581
|
}
|
|
581
582
|
|
|
582
583
|
// Perform the cloning
|
|
583
|
-
|
|
584
|
+
logger.log(`Cloning data from database ${sourceId} to ${targetDbId}`);
|
|
584
585
|
await cloneD1Database(api, {
|
|
585
586
|
sourceDatabaseId: sourceId,
|
|
586
587
|
targetDatabaseId: targetDbId,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from "../util/logger.ts";
|
|
1
2
|
import type { CloudflareApi } from "./api.ts"; // Ensure CloudflareApi is exported if not already
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -153,7 +154,7 @@ export async function exportD1Database(
|
|
|
153
154
|
// Log messages for visibility
|
|
154
155
|
if (data.messages && data.messages.length > 0) {
|
|
155
156
|
for (const message of data.messages) {
|
|
156
|
-
|
|
157
|
+
logger.log(`D1 Export: ${message}`);
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { logger } from "../util/logger.ts";
|
|
2
3
|
import type { CloudflareApi } from "./api.ts";
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -386,7 +387,7 @@ async function pollImportStatus(
|
|
|
386
387
|
// Log messages for visibility
|
|
387
388
|
if (data.messages && data.messages.length > 0) {
|
|
388
389
|
for (const message of data.messages) {
|
|
389
|
-
|
|
390
|
+
logger.log(`D1 Import: ${message}`);
|
|
390
391
|
}
|
|
391
392
|
}
|
|
392
393
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as fs from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
+
import { logger } from "../util/logger.ts";
|
|
3
4
|
import { handleApiError } from "./api-error.ts";
|
|
4
5
|
import type { CloudflareApi } from "./api.ts";
|
|
5
6
|
|
|
@@ -132,6 +133,6 @@ export async function applyMigrations(
|
|
|
132
133
|
const insertSQL = `INSERT INTO ${options.migrationsTable} (id, applied_at) VALUES ('${migrationId.replace("'", "''")}', datetime('now'));`;
|
|
133
134
|
await executeD1SQL(options, insertSQL);
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
logger.log(`Applied migration: ${migrationId}`);
|
|
136
137
|
}
|
|
137
138
|
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import type { Context } from "../context.ts";
|
|
2
|
+
import { Resource, ResourceKind } from "../resource.ts";
|
|
3
|
+
import { bind } from "../runtime/bind.ts";
|
|
4
|
+
import { logger } from "../util/logger.ts";
|
|
5
|
+
import { CloudflareApiError, handleApiError } from "./api-error.ts";
|
|
6
|
+
import {
|
|
7
|
+
createCloudflareApi,
|
|
8
|
+
type CloudflareApi,
|
|
9
|
+
type CloudflareApiOptions,
|
|
10
|
+
} from "./api.ts";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Properties for creating or updating a Dispatch Namespace
|
|
14
|
+
*/
|
|
15
|
+
export interface DispatchNamespaceProps extends CloudflareApiOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Name of the namespace
|
|
18
|
+
*/
|
|
19
|
+
namespace?: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Whether to adopt an existing namespace with the same name if it exists
|
|
23
|
+
* If true and a namespace with the same name exists, it will be adopted rather than creating a new one
|
|
24
|
+
*
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
adopt?: boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether to delete the namespace.
|
|
31
|
+
* If set to false, the namespace will remain but the resource will be removed from state
|
|
32
|
+
*
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
delete?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function isDispatchNamespace(
|
|
39
|
+
resource: Resource,
|
|
40
|
+
): resource is DispatchNamespaceResource {
|
|
41
|
+
return resource[ResourceKind] === "cloudflare::DispatchNamespace";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Output returned after Dispatch Namespace creation/update
|
|
46
|
+
*/
|
|
47
|
+
export interface DispatchNamespaceResource
|
|
48
|
+
extends Resource<"cloudflare::DispatchNamespace">,
|
|
49
|
+
Omit<DispatchNamespaceProps, "delete"> {
|
|
50
|
+
type: "dispatch_namespace";
|
|
51
|
+
/**
|
|
52
|
+
* The name of the namespace
|
|
53
|
+
*/
|
|
54
|
+
namespace: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The namespace name from Cloudflare API
|
|
58
|
+
*/
|
|
59
|
+
namespaceName: string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The namespace ID from Cloudflare API
|
|
63
|
+
*/
|
|
64
|
+
namespaceId: string;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Time at which the namespace was created
|
|
68
|
+
*/
|
|
69
|
+
createdAt: number;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Time at which the namespace was last modified
|
|
73
|
+
*/
|
|
74
|
+
modifiedAt: number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type DispatchNamespace = DispatchNamespaceResource & {
|
|
78
|
+
get(name: string): Fetcher;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A Cloudflare Dispatch Namespace enables routing worker requests to different scripts based on patterns.
|
|
83
|
+
*
|
|
84
|
+
* @see https://developers.cloudflare.com/workers/configuration/routing/dispatch-namespace/
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Create a basic dispatch namespace
|
|
88
|
+
* const myNamespace = await DispatchNamespace("my-namespace", {
|
|
89
|
+
* namespace: "my-namespace"
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // Create dispatch namespace with default name from id
|
|
94
|
+
* const dispatchNS = await DispatchNamespace("api-dispatch");
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* // Adopt an existing namespace if it already exists instead of failing
|
|
98
|
+
* const existingNamespace = await DispatchNamespace("existing-ns", {
|
|
99
|
+
* namespace: "existing-namespace",
|
|
100
|
+
* adopt: true
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* // When removing from Alchemy state, keep the namespace in Cloudflare
|
|
105
|
+
* const preservedNamespace = await DispatchNamespace("preserve-ns", {
|
|
106
|
+
* namespace: "preserved-namespace",
|
|
107
|
+
* delete: false
|
|
108
|
+
* });
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
export async function DispatchNamespace(
|
|
112
|
+
name: string,
|
|
113
|
+
props: DispatchNamespaceProps = {},
|
|
114
|
+
): Promise<DispatchNamespace> {
|
|
115
|
+
const dispatchNamespace = await _DispatchNamespace(name, props);
|
|
116
|
+
const binding = await bind(dispatchNamespace);
|
|
117
|
+
return {
|
|
118
|
+
...dispatchNamespace,
|
|
119
|
+
// Add runtime methods that dispatch namespaces have
|
|
120
|
+
get: binding.get,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const _DispatchNamespace = Resource(
|
|
125
|
+
"cloudflare::DispatchNamespace",
|
|
126
|
+
async function (
|
|
127
|
+
this: Context<DispatchNamespaceResource>,
|
|
128
|
+
id: string,
|
|
129
|
+
props: DispatchNamespaceProps,
|
|
130
|
+
): Promise<DispatchNamespaceResource> {
|
|
131
|
+
// Create Cloudflare API client with automatic account discovery
|
|
132
|
+
const api = await createCloudflareApi(props);
|
|
133
|
+
|
|
134
|
+
const namespace = props.namespace ?? id;
|
|
135
|
+
|
|
136
|
+
if (this.phase === "delete") {
|
|
137
|
+
// For delete operations, we need to check if the namespace exists in the output
|
|
138
|
+
const namespaceName = this.output?.namespace;
|
|
139
|
+
if (namespaceName && props.delete !== false) {
|
|
140
|
+
await deleteDispatchNamespace(api, namespaceName);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Return minimal output for deleted state
|
|
144
|
+
return this.destroy();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// For create or update operations
|
|
148
|
+
let createdAt =
|
|
149
|
+
this.phase === "update"
|
|
150
|
+
? this.output?.createdAt || Date.now()
|
|
151
|
+
: Date.now();
|
|
152
|
+
|
|
153
|
+
if (this.phase === "update") {
|
|
154
|
+
// Check that the namespace name hasn't changed
|
|
155
|
+
if (this.output?.namespace && this.output.namespace !== namespace) {
|
|
156
|
+
throw new Error(
|
|
157
|
+
`Cannot update dispatch namespace name after creation. Namespace name is immutable. Before: ${this.output.namespace}, After: ${namespace}`,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
// For updates, just refresh metadata
|
|
161
|
+
} else {
|
|
162
|
+
try {
|
|
163
|
+
// Try to create the dispatch namespace
|
|
164
|
+
await createDispatchNamespace(api, {
|
|
165
|
+
...props,
|
|
166
|
+
namespace,
|
|
167
|
+
});
|
|
168
|
+
createdAt = Date.now();
|
|
169
|
+
} catch (error) {
|
|
170
|
+
// Check if this is a "namespace already exists" error and adopt is enabled
|
|
171
|
+
if (
|
|
172
|
+
props.adopt &&
|
|
173
|
+
error instanceof CloudflareApiError &&
|
|
174
|
+
error.status === 400 &&
|
|
175
|
+
(error.message.includes("already exists") ||
|
|
176
|
+
error.message.includes("Ensure it does not already exist"))
|
|
177
|
+
) {
|
|
178
|
+
logger.log(
|
|
179
|
+
`Dispatch namespace '${namespace}' already exists, adopting it`,
|
|
180
|
+
);
|
|
181
|
+
// Get the namespace to retrieve ID and validate it exists
|
|
182
|
+
const existingNamespace = await getDispatchNamespace(api, namespace);
|
|
183
|
+
if (!existingNamespace) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`Failed to find existing dispatch namespace '${namespace}'`,
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
// Re-throw the error if adopt is false or it's not a "namespace already exists" error
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Get the namespace information after creation/adoption
|
|
196
|
+
const namespaceInfo = await getDispatchNamespace(api, namespace);
|
|
197
|
+
if (!namespaceInfo) {
|
|
198
|
+
throw new Error(`Failed to get namespace information for '${namespace}'`);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return this({
|
|
202
|
+
type: "dispatch_namespace",
|
|
203
|
+
namespace,
|
|
204
|
+
namespaceName: namespaceInfo.namespaceName,
|
|
205
|
+
namespaceId: namespaceInfo.namespaceId,
|
|
206
|
+
createdAt: createdAt,
|
|
207
|
+
modifiedAt: Date.now(),
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
export async function createDispatchNamespace(
|
|
213
|
+
api: CloudflareApi,
|
|
214
|
+
props: DispatchNamespaceProps & {
|
|
215
|
+
namespace: string;
|
|
216
|
+
},
|
|
217
|
+
): Promise<void> {
|
|
218
|
+
const createResponse = await api.post(
|
|
219
|
+
`/accounts/${api.accountId}/workers/dispatch/namespaces`,
|
|
220
|
+
{
|
|
221
|
+
name: props.namespace,
|
|
222
|
+
},
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
if (!createResponse.ok) {
|
|
226
|
+
await handleApiError(
|
|
227
|
+
createResponse,
|
|
228
|
+
"create",
|
|
229
|
+
"dispatch_namespace",
|
|
230
|
+
props.namespace,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export async function getDispatchNamespace(
|
|
236
|
+
api: CloudflareApi,
|
|
237
|
+
namespace: string,
|
|
238
|
+
): Promise<{ namespaceName: string; namespaceId: string } | undefined> {
|
|
239
|
+
const getResponse = await api.get(
|
|
240
|
+
`/accounts/${api.accountId}/workers/dispatch/namespaces/${namespace}`,
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
if (getResponse.status === 404) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (!getResponse.ok) {
|
|
248
|
+
await handleApiError(getResponse, "get", "dispatch_namespace", namespace);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const result = (await getResponse.json()) as {
|
|
252
|
+
result: {
|
|
253
|
+
namespace_name: string;
|
|
254
|
+
namespace_id: string;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
return {
|
|
259
|
+
namespaceName: result.result.namespace_name,
|
|
260
|
+
namespaceId: result.result.namespace_id,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export async function deleteDispatchNamespace(
|
|
265
|
+
api: CloudflareApi,
|
|
266
|
+
namespace: string,
|
|
267
|
+
) {
|
|
268
|
+
// Delete dispatch namespace
|
|
269
|
+
const deleteResponse = await api.delete(
|
|
270
|
+
`/accounts/${api.accountId}/workers/dispatch/namespaces/${namespace}`,
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
if (!deleteResponse.ok && deleteResponse.status !== 404) {
|
|
274
|
+
await handleApiError(
|
|
275
|
+
deleteResponse,
|
|
276
|
+
"delete",
|
|
277
|
+
"dispatch_namespace",
|
|
278
|
+
namespace,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}
|