alchemy 0.24.1 → 0.26.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/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 +5 -4
- 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 +5 -3
- 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/ai.d.ts +21 -0
- package/lib/cloudflare/ai.d.ts.map +1 -1
- package/lib/cloudflare/ai.js +21 -0
- package/lib/cloudflare/ai.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 +23 -2
- package/lib/cloudflare/bindings.d.ts.map +1 -1
- package/lib/cloudflare/bindings.js.map +1 -1
- package/lib/cloudflare/bound.d.ts +7 -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/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 +9 -0
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +9 -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 -57
- 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 +16 -1
- package/lib/cloudflare/worker-metadata.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +31 -1
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +34 -8
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.d.ts +14 -0
- package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
- package/lib/cloudflare/wrangler.json.js +23 -0
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/cloudflare/zone.d.ts +30 -2
- package/lib/cloudflare/zone.d.ts.map +1 -1
- package/lib/cloudflare/zone.js +57 -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 +2 -0
- 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 +7 -5
- 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 +5 -5
- package/src/aws/control/properties.ts +48 -0
- package/src/aws/control/resource.ts +5 -3
- 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/ai.ts +21 -0
- 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 +27 -0
- package/src/cloudflare/bound.ts +31 -17
- 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/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 +9 -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 -77
- package/src/cloudflare/worker-metadata.ts +14 -1
- package/src/cloudflare/worker.ts +76 -9
- package/src/cloudflare/wrangler.json.ts +42 -0
- package/src/cloudflare/zone.ts +79 -5
- 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 +2 -0
- 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
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import type { Context } from "../context.ts";
|
|
2
|
+
import { Resource } from "../resource.ts";
|
|
3
|
+
import type { Secret } from "../secret.ts";
|
|
4
|
+
import { PlanetScaleApi } from "./api.ts";
|
|
5
|
+
import {
|
|
6
|
+
fixClusterSize,
|
|
7
|
+
type PlanetScaleClusterSize,
|
|
8
|
+
waitForDatabaseReady,
|
|
9
|
+
} from "./utils.ts";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Properties for creating or updating a PlanetScale Database
|
|
13
|
+
*/
|
|
14
|
+
export interface DatabaseProps {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the database
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The organization ID where the database will be created
|
|
22
|
+
*/
|
|
23
|
+
organizationId: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* PlanetScale API token (overrides environment variable)
|
|
27
|
+
*/
|
|
28
|
+
apiKey?: Secret;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Whether to adopt the database if it already exists in Planetscale
|
|
32
|
+
*/
|
|
33
|
+
adopt?: boolean;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The region where the database will be created (create only)
|
|
37
|
+
*/
|
|
38
|
+
region?: {
|
|
39
|
+
/**
|
|
40
|
+
* The slug identifier of the region
|
|
41
|
+
*/
|
|
42
|
+
slug: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether to require approval for deployments
|
|
47
|
+
*/
|
|
48
|
+
requireApprovalForDeploy?: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Whether to allow data branching
|
|
52
|
+
*/
|
|
53
|
+
allowDataBranching?: boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether to enable automatic migrations
|
|
57
|
+
*/
|
|
58
|
+
automaticMigrations?: boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Whether to restrict branch creation to the same region as database
|
|
62
|
+
*/
|
|
63
|
+
restrictBranchRegion?: boolean;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Whether to collect full queries from the database
|
|
67
|
+
*/
|
|
68
|
+
insightsRawQueries?: boolean;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Whether web console can be used on production branch
|
|
72
|
+
*/
|
|
73
|
+
productionBranchWebConsole?: boolean;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The default branch of the database
|
|
77
|
+
*/
|
|
78
|
+
defaultBranch?: string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Migration framework to use on the database
|
|
82
|
+
*/
|
|
83
|
+
migrationFramework?: string;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Name of table to use as migration table
|
|
87
|
+
*/
|
|
88
|
+
migrationTableName?: string;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The database cluster size (required)
|
|
92
|
+
*/
|
|
93
|
+
clusterSize: PlanetScaleClusterSize;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Represents a PlanetScale Database
|
|
98
|
+
*/
|
|
99
|
+
export interface Database
|
|
100
|
+
extends Resource<"planetscale::Database">,
|
|
101
|
+
DatabaseProps {
|
|
102
|
+
/**
|
|
103
|
+
* The unique identifier of the database
|
|
104
|
+
*/
|
|
105
|
+
id: string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The current state of the database
|
|
109
|
+
*/
|
|
110
|
+
state: string;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The default branch name
|
|
114
|
+
*/
|
|
115
|
+
defaultBranch: string;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The plan type
|
|
119
|
+
*/
|
|
120
|
+
plan: string;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Time at which the database was created
|
|
124
|
+
*/
|
|
125
|
+
createdAt: string;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Time at which the database was last updated
|
|
129
|
+
*/
|
|
130
|
+
updatedAt: string;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* HTML URL to access the database
|
|
134
|
+
*/
|
|
135
|
+
htmlUrl: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Create, manage and delete PlanetScale databases
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* // Create a basic database in a specific organization
|
|
143
|
+
* const db = await Database("my-app-db", {
|
|
144
|
+
* name: "my-app-db",
|
|
145
|
+
* organizationId: "my-org",
|
|
146
|
+
* clusterSize: "PS_10"
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* // Create a database with specific region and settings
|
|
151
|
+
* const db = await Database("my-app-db", {
|
|
152
|
+
* name: "my-app-db",
|
|
153
|
+
* organizationId: "my-org",
|
|
154
|
+
* region: {
|
|
155
|
+
* slug: "us-east"
|
|
156
|
+
* },
|
|
157
|
+
* clusterSize: "PS_10",
|
|
158
|
+
* requireApprovalForDeploy: true,
|
|
159
|
+
* allowDataBranching: true,
|
|
160
|
+
* automaticMigrations: true
|
|
161
|
+
* });
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* // Create a database with custom API key
|
|
165
|
+
* const db = await Database("my-app-db", {
|
|
166
|
+
* name: "my-app-db",
|
|
167
|
+
* organizationId: "my-org",
|
|
168
|
+
* apiKey: alchemy.secret(process.env.CUSTOM_PLANETSCALE_TOKEN),
|
|
169
|
+
* clusterSize: "PS_10"
|
|
170
|
+
* });
|
|
171
|
+
*/
|
|
172
|
+
export const Database = Resource(
|
|
173
|
+
"planetscale::Database",
|
|
174
|
+
async function (
|
|
175
|
+
this: Context<Database>,
|
|
176
|
+
_id: string,
|
|
177
|
+
props: DatabaseProps,
|
|
178
|
+
): Promise<Database> {
|
|
179
|
+
const apiKey =
|
|
180
|
+
props.apiKey?.unencrypted || process.env.PLANETSCALE_API_TOKEN;
|
|
181
|
+
if (!apiKey) {
|
|
182
|
+
throw new Error("PLANETSCALE_API_TOKEN environment variable is required");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const api = new PlanetScaleApi({ apiKey });
|
|
186
|
+
|
|
187
|
+
if (this.phase === "delete") {
|
|
188
|
+
try {
|
|
189
|
+
if (this.output?.name) {
|
|
190
|
+
const response = await api.delete(
|
|
191
|
+
`/organizations/${props.organizationId}/databases/${this.output.name}`,
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
if (!response.ok && response.status !== 404) {
|
|
195
|
+
throw new Error(
|
|
196
|
+
`Failed to delete database: ${response.statusText} ${await response.text()}`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error("Error deleting database:", error);
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
return this.destroy();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
// Check if database exists
|
|
209
|
+
const getResponse = await api.get(
|
|
210
|
+
`/organizations/${props.organizationId}/databases/${props.name}`,
|
|
211
|
+
);
|
|
212
|
+
const getData = await getResponse.json<any>();
|
|
213
|
+
if (this.phase === "update" || (props.adopt && getResponse.ok)) {
|
|
214
|
+
if (!getResponse.ok) {
|
|
215
|
+
throw new Error(`Database ${props.name} not found`);
|
|
216
|
+
}
|
|
217
|
+
// Update database settings
|
|
218
|
+
// If updating to a non-'main' default branch, create it first
|
|
219
|
+
if (props.defaultBranch && props.defaultBranch !== "main") {
|
|
220
|
+
const branchResponse = await api.get(
|
|
221
|
+
`/organizations/${props.organizationId}/databases/${props.name}/branches/${props.defaultBranch}`,
|
|
222
|
+
);
|
|
223
|
+
if (!getData.ready) {
|
|
224
|
+
await waitForDatabaseReady(api, props.organizationId, props.name);
|
|
225
|
+
}
|
|
226
|
+
if (!branchResponse.ok && branchResponse.status === 404) {
|
|
227
|
+
// Create the branch
|
|
228
|
+
const createBranchResponse = await api.post(
|
|
229
|
+
`/organizations/${props.organizationId}/databases/${props.name}/branches`,
|
|
230
|
+
{
|
|
231
|
+
name: props.defaultBranch,
|
|
232
|
+
parent_branch: "main",
|
|
233
|
+
},
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
if (!createBranchResponse.ok) {
|
|
237
|
+
throw new Error(
|
|
238
|
+
`Failed to create default branch: ${createBranchResponse.statusText} ${await createBranchResponse.text()}`,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const updateResponse = await api.patch(
|
|
245
|
+
`/organizations/${props.organizationId}/databases/${props.name}`,
|
|
246
|
+
{
|
|
247
|
+
automatic_migrations: props.automaticMigrations,
|
|
248
|
+
migration_framework: props.migrationFramework,
|
|
249
|
+
migration_table_name: props.migrationTableName,
|
|
250
|
+
require_approval_for_deploy: props.requireApprovalForDeploy,
|
|
251
|
+
restrict_branch_region: props.restrictBranchRegion,
|
|
252
|
+
allow_data_branching: props.allowDataBranching,
|
|
253
|
+
insights_raw_queries: props.insightsRawQueries,
|
|
254
|
+
production_branch_web_console: props.productionBranchWebConsole,
|
|
255
|
+
default_branch: props.defaultBranch,
|
|
256
|
+
},
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
if (!updateResponse.ok) {
|
|
260
|
+
throw new Error(
|
|
261
|
+
`Failed to update database: ${updateResponse.statusText} ${await updateResponse.text()}`,
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
await fixClusterSize(
|
|
266
|
+
api,
|
|
267
|
+
props.organizationId,
|
|
268
|
+
props.name,
|
|
269
|
+
props.defaultBranch || "main",
|
|
270
|
+
props.clusterSize,
|
|
271
|
+
getData.ready,
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
const data = await updateResponse.json<any>();
|
|
275
|
+
return this({
|
|
276
|
+
...props,
|
|
277
|
+
id: data.id,
|
|
278
|
+
state: data.state,
|
|
279
|
+
defaultBranch: data.default_branch,
|
|
280
|
+
plan: data.plan,
|
|
281
|
+
createdAt: data.created_at,
|
|
282
|
+
updatedAt: data.updated_at,
|
|
283
|
+
htmlUrl: data.html_url,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (getResponse.ok) {
|
|
288
|
+
throw new Error(`Database with name ${props.name} already exists`);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Create new database
|
|
292
|
+
const createResponse = await api.post(
|
|
293
|
+
`/organizations/${props.organizationId}/databases`,
|
|
294
|
+
{
|
|
295
|
+
name: props.name,
|
|
296
|
+
region_slug: props.region?.slug,
|
|
297
|
+
require_approval_for_deploy: props.requireApprovalForDeploy,
|
|
298
|
+
allow_data_branching: props.allowDataBranching,
|
|
299
|
+
automatic_migrations: props.automaticMigrations,
|
|
300
|
+
restrict_branch_region: props.restrictBranchRegion,
|
|
301
|
+
insights_raw_queries: props.insightsRawQueries,
|
|
302
|
+
production_branch_web_console: props.productionBranchWebConsole,
|
|
303
|
+
migration_framework: props.migrationFramework,
|
|
304
|
+
migration_table_name: props.migrationTableName,
|
|
305
|
+
cluster_size: props.clusterSize,
|
|
306
|
+
},
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
if (!createResponse.ok) {
|
|
310
|
+
throw new Error(
|
|
311
|
+
`Failed to create database: ${createResponse.statusText} ${await createResponse.text()}`,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const data = await createResponse.json<any>();
|
|
316
|
+
|
|
317
|
+
// If a non-'main' default branch is specified, create it
|
|
318
|
+
if (props.defaultBranch && props.defaultBranch !== "main") {
|
|
319
|
+
await waitForDatabaseReady(api, props.organizationId, props.name);
|
|
320
|
+
|
|
321
|
+
// Check if branch exists
|
|
322
|
+
const branchResponse = await api.get(
|
|
323
|
+
`/organizations/${props.organizationId}/databases/${props.name}/branches/${props.defaultBranch}`,
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
if (!branchResponse.ok && branchResponse.status === 404) {
|
|
327
|
+
// Create the branch
|
|
328
|
+
const createBranchResponse = await api.post(
|
|
329
|
+
`/organizations/${props.organizationId}/databases/${props.name}/branches`,
|
|
330
|
+
{
|
|
331
|
+
name: props.defaultBranch,
|
|
332
|
+
parent_branch: "main",
|
|
333
|
+
},
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
if (!createBranchResponse.ok) {
|
|
337
|
+
throw new Error(
|
|
338
|
+
`Failed to create default branch: ${createBranchResponse.statusText} ${await createBranchResponse.text()}`,
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
await fixClusterSize(
|
|
343
|
+
api,
|
|
344
|
+
props.organizationId,
|
|
345
|
+
props.name,
|
|
346
|
+
props.defaultBranch || "main",
|
|
347
|
+
props.clusterSize,
|
|
348
|
+
false,
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
// Update database to use new branch as default
|
|
352
|
+
const updateResponse = await api.patch(
|
|
353
|
+
`/organizations/${props.organizationId}/databases/${props.name}`,
|
|
354
|
+
{
|
|
355
|
+
default_branch: props.defaultBranch,
|
|
356
|
+
},
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
if (!updateResponse.ok) {
|
|
360
|
+
throw new Error(
|
|
361
|
+
`Failed to set default branch: ${updateResponse.statusText} ${await updateResponse.text()}`,
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const updatedData = await updateResponse.json<any>();
|
|
366
|
+
return this({
|
|
367
|
+
...props,
|
|
368
|
+
id: data.id,
|
|
369
|
+
state: updatedData.state,
|
|
370
|
+
defaultBranch: updatedData.default_branch,
|
|
371
|
+
plan: updatedData.plan,
|
|
372
|
+
createdAt: updatedData.created_at,
|
|
373
|
+
updatedAt: updatedData.updated_at,
|
|
374
|
+
htmlUrl: updatedData.html_url,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return this({
|
|
380
|
+
...props,
|
|
381
|
+
id: data.id,
|
|
382
|
+
state: data.state,
|
|
383
|
+
defaultBranch: data.default_branch || "main",
|
|
384
|
+
plan: data.plan,
|
|
385
|
+
createdAt: data.created_at,
|
|
386
|
+
updatedAt: data.updated_at,
|
|
387
|
+
htmlUrl: data.html_url,
|
|
388
|
+
});
|
|
389
|
+
} catch (error) {
|
|
390
|
+
console.error("Error managing database:", error);
|
|
391
|
+
throw error;
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
);
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { PlanetScaleApi } from "./api.ts";
|
|
2
|
+
|
|
3
|
+
export type PlanetScaleClusterSize =
|
|
4
|
+
| "PS_DEV"
|
|
5
|
+
| "PS_10"
|
|
6
|
+
| "PS_20"
|
|
7
|
+
| "PS_40"
|
|
8
|
+
| "PS_80"
|
|
9
|
+
| "PS_160"
|
|
10
|
+
| "PS_320"
|
|
11
|
+
| "PS_400"
|
|
12
|
+
| "PS_640"
|
|
13
|
+
| "PS_700"
|
|
14
|
+
| "PS_900"
|
|
15
|
+
| "PS_1280"
|
|
16
|
+
| "PS_1400"
|
|
17
|
+
| "PS_1800"
|
|
18
|
+
| "PS_2100"
|
|
19
|
+
| "PS_2560"
|
|
20
|
+
| "PS_2700"
|
|
21
|
+
| "PS_2800"
|
|
22
|
+
| (string & {});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Wait for a database to be ready with exponential backoff
|
|
26
|
+
*/
|
|
27
|
+
export async function waitForDatabaseReady(
|
|
28
|
+
api: PlanetScaleApi,
|
|
29
|
+
organizationId: string,
|
|
30
|
+
databaseName: string,
|
|
31
|
+
branchName?: string,
|
|
32
|
+
): Promise<void> {
|
|
33
|
+
const startTime = Date.now();
|
|
34
|
+
let waitMs = 100;
|
|
35
|
+
const branchSuffix = branchName ? `/branches/${branchName}` : "";
|
|
36
|
+
while (true) {
|
|
37
|
+
const response = await api.get(
|
|
38
|
+
`/organizations/${organizationId}/databases/${databaseName}${branchSuffix}`,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
throw new Error(`Failed to check database state: ${response.statusText}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const data = await response.json<any>();
|
|
46
|
+
if (data.ready === true) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (Date.now() - startTime >= 60000) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`Timeout waiting for database ${databaseName} to be ready`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
await new Promise((resolve) => setTimeout(resolve, waitMs));
|
|
57
|
+
waitMs = Math.min(waitMs * 2, 1000); // Cap at 1s intervals
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Wait for a keyspace to be ready
|
|
63
|
+
*/
|
|
64
|
+
export async function waitForKeyspaceReady(
|
|
65
|
+
api: PlanetScaleApi,
|
|
66
|
+
org: string,
|
|
67
|
+
db: string,
|
|
68
|
+
branch: string,
|
|
69
|
+
keyspace: string,
|
|
70
|
+
): Promise<void> {
|
|
71
|
+
const start = Date.now();
|
|
72
|
+
let delay = 100;
|
|
73
|
+
|
|
74
|
+
while (true) {
|
|
75
|
+
const res = await api.get(
|
|
76
|
+
`/organizations/${org}/databases/${db}/branches/${branch}/keyspaces/${keyspace}/resizes`,
|
|
77
|
+
);
|
|
78
|
+
if (!res.ok) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`Error fetching keyspace "${keyspace}": ${res.statusText}`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const ks = await res.json<{
|
|
85
|
+
data: [
|
|
86
|
+
{
|
|
87
|
+
state: string;
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
}>();
|
|
91
|
+
// once it's fully ready, we can proceed
|
|
92
|
+
if (ks.data.every((item) => item.state !== "resizing")) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (Date.now() - start > 600_000) {
|
|
97
|
+
throw new Error(`Timeout waiting for keyspace "${keyspace}" to be ready`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
101
|
+
delay = Math.min(delay * 2, 1_000);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Fix cluster size for a branch
|
|
107
|
+
*/
|
|
108
|
+
export async function fixClusterSize(
|
|
109
|
+
api: PlanetScaleApi,
|
|
110
|
+
organizationId: string,
|
|
111
|
+
databaseName: string,
|
|
112
|
+
branchName: string,
|
|
113
|
+
expectedClusterSize: PlanetScaleClusterSize,
|
|
114
|
+
isDBReady: boolean,
|
|
115
|
+
): Promise<void> {
|
|
116
|
+
if (!isDBReady) {
|
|
117
|
+
await waitForDatabaseReady(api, organizationId, databaseName);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 1. Ensure branch is production
|
|
121
|
+
let branchRes = await api.get(
|
|
122
|
+
`/organizations/${organizationId}/databases/${databaseName}/branches/${branchName}`,
|
|
123
|
+
);
|
|
124
|
+
if (!branchRes.ok) {
|
|
125
|
+
throw new Error(`Unable to get branch data: ${branchRes.statusText}`);
|
|
126
|
+
}
|
|
127
|
+
let branchData = await branchRes.json<any>();
|
|
128
|
+
if (!branchData.production) {
|
|
129
|
+
if (!branchData.ready) {
|
|
130
|
+
await waitForDatabaseReady(api, organizationId, databaseName, branchName);
|
|
131
|
+
}
|
|
132
|
+
const promoteRes = await api.post(
|
|
133
|
+
`/organizations/${organizationId}/databases/${databaseName}/branches/${branchName}/promote`,
|
|
134
|
+
);
|
|
135
|
+
if (!promoteRes.ok) {
|
|
136
|
+
throw new Error(`Unable to promote branch: ${promoteRes.statusText}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// 2. Load default keyspace
|
|
140
|
+
const ksListRes = await api.get(
|
|
141
|
+
`/organizations/${organizationId}/databases/${databaseName}/branches/${branchName}/keyspaces`,
|
|
142
|
+
);
|
|
143
|
+
if (!ksListRes.ok) {
|
|
144
|
+
throw new Error(`Failed to list keyspaces: ${ksListRes.statusText}`);
|
|
145
|
+
}
|
|
146
|
+
const ksList = (await ksListRes.json<any>()).data as Array<{
|
|
147
|
+
name: string;
|
|
148
|
+
cluster_name: string;
|
|
149
|
+
}>;
|
|
150
|
+
const defaultKsData = ksList.find((x) => x.name === databaseName); // Default keypsace is always the same name as the database
|
|
151
|
+
if (ksList.length === 0 || !defaultKsData) {
|
|
152
|
+
throw new Error(`No default keyspace found for branch ${branchName}`);
|
|
153
|
+
}
|
|
154
|
+
const defaultKs = defaultKsData.name;
|
|
155
|
+
let currentSize = defaultKsData.cluster_name as PlanetScaleClusterSize;
|
|
156
|
+
|
|
157
|
+
// 3. Wait until any in-flight resize is done
|
|
158
|
+
await waitForKeyspaceReady(
|
|
159
|
+
api,
|
|
160
|
+
organizationId,
|
|
161
|
+
databaseName,
|
|
162
|
+
branchName,
|
|
163
|
+
defaultKs,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
// 4. If size mismatch, trigger resize and wait again
|
|
167
|
+
// Ideally this would use the undocumented Keyspaces API, but there seems to be a missing oauth scope that we cannot add via the console yet
|
|
168
|
+
if (currentSize !== expectedClusterSize) {
|
|
169
|
+
const resizeRes = await api.patch(
|
|
170
|
+
`/organizations/${organizationId}/databases/${databaseName}/branches/${branchName}/cluster`,
|
|
171
|
+
{ cluster_size: expectedClusterSize },
|
|
172
|
+
);
|
|
173
|
+
if (!resizeRes.ok) {
|
|
174
|
+
const text = await resizeRes.text();
|
|
175
|
+
throw new Error(
|
|
176
|
+
`Failed to start resize: ${resizeRes.statusText} ${text}`,
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Poll until the resize completes
|
|
181
|
+
await waitForKeyspaceReady(
|
|
182
|
+
api,
|
|
183
|
+
organizationId,
|
|
184
|
+
databaseName,
|
|
185
|
+
branchName,
|
|
186
|
+
defaultKs,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
}
|
package/src/resource.ts
CHANGED
|
@@ -137,9 +137,15 @@ export function Resource<
|
|
|
137
137
|
const otherResource = scope.resources.get(resourceID);
|
|
138
138
|
if (otherResource?.[ResourceKind] !== type) {
|
|
139
139
|
scope.fail();
|
|
140
|
-
|
|
140
|
+
const error = new Error(
|
|
141
141
|
`Resource ${resourceID} already exists in the stack and is of a different type: '${otherResource?.[ResourceKind]}' !== '${type}'`,
|
|
142
142
|
);
|
|
143
|
+
scope.telemetryClient.record({
|
|
144
|
+
event: "resource.error",
|
|
145
|
+
resource: type,
|
|
146
|
+
error,
|
|
147
|
+
});
|
|
148
|
+
throw error;
|
|
143
149
|
}
|
|
144
150
|
}
|
|
145
151
|
|
package/src/runtime/plugin.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
} from "@swc/core";
|
|
9
9
|
import type { Plugin } from "esbuild";
|
|
10
10
|
import fs from "node:fs/promises";
|
|
11
|
+
import { logger } from "../util/logger.ts";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Bundles a single Worker function entrypoint by:
|
|
@@ -146,7 +147,7 @@ export const bootstrapPlugin: Plugin = {
|
|
|
146
147
|
|
|
147
148
|
return transformed(code);
|
|
148
149
|
} catch (error: unknown) {
|
|
149
|
-
|
|
150
|
+
logger.error(`Error transforming ${args.path}:`, error);
|
|
150
151
|
return {
|
|
151
152
|
errors: [
|
|
152
153
|
{
|