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/github/secret.ts
CHANGED
|
@@ -2,6 +2,7 @@ import sodium from "libsodium-wrappers";
|
|
|
2
2
|
import type { Context } from "../context.ts";
|
|
3
3
|
import { Resource } from "../resource.ts";
|
|
4
4
|
import type { Secret } from "../secret.ts";
|
|
5
|
+
import { logger } from "../util/logger.ts";
|
|
5
6
|
import { createGitHubClient, verifyGitHubAuth } from "./client.ts";
|
|
6
7
|
/**
|
|
7
8
|
* Properties for creating or updating a GitHub Secret
|
|
@@ -172,7 +173,7 @@ export const GitHubSecret = Resource(
|
|
|
172
173
|
} catch (error: any) {
|
|
173
174
|
// Ignore 404 errors (secret already deleted)
|
|
174
175
|
if (error.status === 404) {
|
|
175
|
-
|
|
176
|
+
logger.log("Secret doesn't exist, ignoring");
|
|
176
177
|
} else {
|
|
177
178
|
throw error;
|
|
178
179
|
}
|
|
@@ -190,7 +191,7 @@ export const GitHubSecret = Resource(
|
|
|
190
191
|
|
|
191
192
|
// If secret type changed, we need to delete the old one first
|
|
192
193
|
if (secretTypeChanged) {
|
|
193
|
-
|
|
194
|
+
logger.log(
|
|
194
195
|
`Secret type changed from ${wasEnvironmentSecret ? "environment" : "repository"} to ${isEnvironmentSecret ? "environment" : "repository"} secret. Deleting the old secret first.`,
|
|
195
196
|
);
|
|
196
197
|
|
|
@@ -214,7 +215,7 @@ export const GitHubSecret = Resource(
|
|
|
214
215
|
} catch (error: any) {
|
|
215
216
|
// Log but don't fail if the old secret doesn't exist or can't be deleted
|
|
216
217
|
if (error.status === 404) {
|
|
217
|
-
|
|
218
|
+
logger.log(
|
|
218
219
|
"Old secret not found, continuing with creation of new secret",
|
|
219
220
|
);
|
|
220
221
|
} else {
|
|
@@ -293,14 +294,14 @@ export const GitHubSecret = Resource(
|
|
|
293
294
|
error.status === 403 &&
|
|
294
295
|
error.message?.includes("Must have admin rights")
|
|
295
296
|
) {
|
|
296
|
-
|
|
297
|
+
logger.error(
|
|
297
298
|
"\n⚠️ Error creating/updating GitHub secret: You must have admin rights to the repository.",
|
|
298
299
|
);
|
|
299
|
-
|
|
300
|
+
logger.error(
|
|
300
301
|
"Make sure your GitHub token has the required permissions (repo scope for private repos).\n",
|
|
301
302
|
);
|
|
302
303
|
} else {
|
|
303
|
-
|
|
304
|
+
logger.error("Error creating/updating GitHub secret:", error.message);
|
|
304
305
|
}
|
|
305
306
|
throw error;
|
|
306
307
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { AlchemyOptions } from "./alchemy.ts";
|
|
1
|
+
export type { AlchemyOptions, Phase } from "./alchemy.ts";
|
|
2
2
|
export type * from "./context.ts";
|
|
3
3
|
export * from "./resource.ts";
|
|
4
4
|
export type * from "./scope.ts";
|
|
@@ -7,6 +7,7 @@ export * from "./serde.ts";
|
|
|
7
7
|
export * from "./state.ts";
|
|
8
8
|
export * from "./type.ts";
|
|
9
9
|
export * from "./util/ignore.ts";
|
|
10
|
+
export * from "./util/logger.ts";
|
|
10
11
|
|
|
11
12
|
import { alchemy } from "./alchemy.ts";
|
|
12
13
|
export default alchemy;
|
package/src/neon/project.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { alchemy } from "../alchemy.ts";
|
|
|
2
2
|
import type { Context } from "../context.ts";
|
|
3
3
|
import { Resource } from "../resource.ts";
|
|
4
4
|
import type { Secret } from "../secret.ts";
|
|
5
|
+
import { logger } from "../util/logger.ts";
|
|
5
6
|
import { handleApiError } from "./api-error.ts";
|
|
6
7
|
import { createNeonApi, type NeonApiOptions } from "./api.ts";
|
|
7
8
|
|
|
@@ -525,7 +526,7 @@ export const NeonProject = Resource(
|
|
|
525
526
|
}
|
|
526
527
|
}
|
|
527
528
|
} catch (error) {
|
|
528
|
-
|
|
529
|
+
logger.error(`Error deleting Neon project ${id}:`, error);
|
|
529
530
|
throw error;
|
|
530
531
|
}
|
|
531
532
|
return this.destroy();
|
|
@@ -628,7 +629,7 @@ export const NeonProject = Resource(
|
|
|
628
629
|
endpoints: response.endpoints,
|
|
629
630
|
});
|
|
630
631
|
} catch (error) {
|
|
631
|
-
|
|
632
|
+
logger.error(`Error ${this.phase} Neon project '${id}':`, error);
|
|
632
633
|
throw error;
|
|
633
634
|
}
|
|
634
635
|
},
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for PlanetScale API requests
|
|
3
|
+
*/
|
|
4
|
+
export interface PlanetScaleApiOptions {
|
|
5
|
+
/**
|
|
6
|
+
* PlanetScale API token (overrides environment variable)
|
|
7
|
+
*/
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Minimal API client for PlanetScale using raw fetch
|
|
13
|
+
*/
|
|
14
|
+
export class PlanetScaleApi {
|
|
15
|
+
/** Base URL for API */
|
|
16
|
+
readonly baseUrl: string;
|
|
17
|
+
|
|
18
|
+
/** API token */
|
|
19
|
+
readonly apiToken: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Create a new API client
|
|
23
|
+
*
|
|
24
|
+
* @param options API options
|
|
25
|
+
*/
|
|
26
|
+
constructor(options: PlanetScaleApiOptions = {}) {
|
|
27
|
+
this.baseUrl = "https://api.planetscale.com/v1";
|
|
28
|
+
this.apiToken = options.apiKey || process.env.PLANETSCALE_API_TOKEN || "";
|
|
29
|
+
if (!this.apiToken) {
|
|
30
|
+
throw new Error("PLANETSCALE_API_TOKEN environment variable is required");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Make a request to the API
|
|
36
|
+
*
|
|
37
|
+
* @param path API path (without base URL)
|
|
38
|
+
* @param init Fetch init options
|
|
39
|
+
* @returns Raw Response object from fetch
|
|
40
|
+
*/
|
|
41
|
+
private async fetch(path: string, init: RequestInit = {}): Promise<Response> {
|
|
42
|
+
const headers: Record<string, string> = {
|
|
43
|
+
Authorization: `${this.apiToken}`,
|
|
44
|
+
"Content-Type": "application/json",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if (init.headers) {
|
|
48
|
+
Object.assign(headers, init.headers);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return fetch(`${this.baseUrl}${path}`, {
|
|
52
|
+
...init,
|
|
53
|
+
headers,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Helper for GET requests
|
|
59
|
+
*/
|
|
60
|
+
async get(path: string, init: RequestInit = {}): Promise<Response> {
|
|
61
|
+
return this.fetch(path, { ...init, method: "GET" });
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Helper for POST requests
|
|
66
|
+
*/
|
|
67
|
+
async post(
|
|
68
|
+
path: string,
|
|
69
|
+
body?: any,
|
|
70
|
+
init: RequestInit = {},
|
|
71
|
+
): Promise<Response> {
|
|
72
|
+
return this.fetch(path, {
|
|
73
|
+
...init,
|
|
74
|
+
method: "POST",
|
|
75
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Helper for PUT requests
|
|
81
|
+
*/
|
|
82
|
+
async put(
|
|
83
|
+
path: string,
|
|
84
|
+
body?: any,
|
|
85
|
+
init: RequestInit = {},
|
|
86
|
+
): Promise<Response> {
|
|
87
|
+
return this.fetch(path, {
|
|
88
|
+
...init,
|
|
89
|
+
method: "PUT",
|
|
90
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Helper for PATCH requests
|
|
96
|
+
*/
|
|
97
|
+
async patch(
|
|
98
|
+
path: string,
|
|
99
|
+
body?: any,
|
|
100
|
+
init: RequestInit = {},
|
|
101
|
+
): Promise<Response> {
|
|
102
|
+
return this.fetch(path, {
|
|
103
|
+
...init,
|
|
104
|
+
method: "PATCH",
|
|
105
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Helper for DELETE requests
|
|
111
|
+
*/
|
|
112
|
+
async delete(path: string, init: RequestInit = {}): Promise<Response> {
|
|
113
|
+
return this.fetch(path, { ...init, method: "DELETE" });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,352 @@
|
|
|
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
|
+
waitForDatabaseReady,
|
|
8
|
+
type PlanetScaleClusterSize,
|
|
9
|
+
} from "./utils.ts";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Properties for creating or updating a PlanetScale Branch
|
|
13
|
+
*/
|
|
14
|
+
export interface BranchProps {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the branch
|
|
17
|
+
*/
|
|
18
|
+
name: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The organization ID
|
|
22
|
+
*/
|
|
23
|
+
organizationId: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The database name
|
|
27
|
+
*/
|
|
28
|
+
databaseName: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* PlanetScale API token (overrides environment variable)
|
|
32
|
+
*/
|
|
33
|
+
apiKey?: Secret;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Whether or not the branch should be set to a production branch or not.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
isProduction: boolean;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Whether to adopt an existing branch if it exists.
|
|
43
|
+
* If false and the branch exists, an error will be thrown.
|
|
44
|
+
* If true and the branch exists, it will be updated with the provided properties.
|
|
45
|
+
*/
|
|
46
|
+
adopt?: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The parent branch name or Branch object
|
|
50
|
+
*/
|
|
51
|
+
parentBranch?: string | Branch;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* If provided, restores the backup's schema and data to the new branch.
|
|
55
|
+
* Must have restore_production_branch_backup(s) or restore_backup(s) access.
|
|
56
|
+
*
|
|
57
|
+
* Ignored if the branch already exists.
|
|
58
|
+
*/
|
|
59
|
+
backupId?: string;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* If provided, restores the last successful backup's schema and data to the new branch.
|
|
63
|
+
* Must have restore_production_branch_backup(s) or restore_backup(s) access,
|
|
64
|
+
* in addition to Data Branching being enabled for the branch.
|
|
65
|
+
* Use 'last_successful_backup' or empty string.
|
|
66
|
+
*
|
|
67
|
+
* Ignored if the branch already exists.
|
|
68
|
+
*/
|
|
69
|
+
seedData?: string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The database cluster size is required if a backup_id is provided. If the branch is not a production branch, the cluster size MUST be "PS_DEV".
|
|
73
|
+
*/
|
|
74
|
+
clusterSize?: PlanetScaleClusterSize;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Enable or disable safe migrations on this branch
|
|
78
|
+
*/
|
|
79
|
+
safeMigrations?: boolean;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Represents a PlanetScale Branch
|
|
84
|
+
*/
|
|
85
|
+
export interface Branch extends Resource<"planetscale::Branch">, BranchProps {
|
|
86
|
+
/**
|
|
87
|
+
* The name of the branch
|
|
88
|
+
*/
|
|
89
|
+
name: string;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The name of the parent branch
|
|
93
|
+
*/
|
|
94
|
+
parentBranch: string;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Time at which the branch was created
|
|
98
|
+
*/
|
|
99
|
+
createdAt: string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Time at which the branch was last updated
|
|
103
|
+
*/
|
|
104
|
+
updatedAt: string;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* HTML URL to access the branch
|
|
108
|
+
*/
|
|
109
|
+
htmlUrl: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Create or manage a PlanetScale database branch
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* // Create a branch from 'main'
|
|
117
|
+
* const branch = await Branch("feature-123", {
|
|
118
|
+
* name: "feature-123",
|
|
119
|
+
* organizationId: "my-org",
|
|
120
|
+
* databaseName: "my-database",
|
|
121
|
+
* parentBranch: "main"
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* // Create a branch from another branch object
|
|
126
|
+
* const parentBranch = await Branch("staging", {
|
|
127
|
+
* name: "staging",
|
|
128
|
+
* organizationId: "my-org",
|
|
129
|
+
* databaseName: "my-database",
|
|
130
|
+
* parentBranch: "main"
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
133
|
+
* const featureBranch = await Branch("feature-456", {
|
|
134
|
+
* name: "feature-456",
|
|
135
|
+
* organizationId: "my-org",
|
|
136
|
+
* databaseName: "my-database",
|
|
137
|
+
* parentBranch: parentBranch // Using Branch object instead of string
|
|
138
|
+
* });
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* // Create a branch from a backup
|
|
142
|
+
* const branch = await Branch("restored-branch", {
|
|
143
|
+
* name: "restored-branch",
|
|
144
|
+
* organizationId: "my-org",
|
|
145
|
+
* databaseName: "my-database",
|
|
146
|
+
* parentBranch: "main",
|
|
147
|
+
* backupId: "backup-123",
|
|
148
|
+
* clusterSize: "PS_10"
|
|
149
|
+
* });
|
|
150
|
+
*/
|
|
151
|
+
export const Branch = Resource(
|
|
152
|
+
"planetscale::Branch",
|
|
153
|
+
async function (
|
|
154
|
+
this: Context<Branch>,
|
|
155
|
+
_id: string,
|
|
156
|
+
props: BranchProps,
|
|
157
|
+
): Promise<Branch> {
|
|
158
|
+
const apiKey =
|
|
159
|
+
props.apiKey?.unencrypted || process.env.PLANETSCALE_API_TOKEN;
|
|
160
|
+
if (!apiKey) {
|
|
161
|
+
throw new Error("PLANETSCALE_API_TOKEN environment variable is required");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const api = new PlanetScaleApi({ apiKey });
|
|
165
|
+
|
|
166
|
+
if (this.phase === "delete") {
|
|
167
|
+
try {
|
|
168
|
+
if (this.output?.name) {
|
|
169
|
+
const response = await api.delete(
|
|
170
|
+
`/organizations/${props.organizationId}/databases/${props.databaseName}/branches/${this.output.name}`,
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
if (!response.ok && response.status !== 404) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`Failed to delete branch: ${response.statusText} ${await response.text()}`,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.error("Error deleting branch:", error);
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
return this.destroy();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
const parentBranchName = !props.parentBranch
|
|
188
|
+
? "main"
|
|
189
|
+
: typeof props.parentBranch === "string"
|
|
190
|
+
? props.parentBranch
|
|
191
|
+
: props.parentBranch.name;
|
|
192
|
+
|
|
193
|
+
if (typeof props.parentBranch !== "string" && props.parentBranch) {
|
|
194
|
+
await waitForDatabaseReady(
|
|
195
|
+
api,
|
|
196
|
+
props.organizationId,
|
|
197
|
+
props.databaseName,
|
|
198
|
+
props.parentBranch.name,
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Check if branch exists
|
|
203
|
+
const getResponse = await api.get(
|
|
204
|
+
`/organizations/${props.organizationId}/databases/${props.databaseName}/branches/${props.name}`,
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
if (!getResponse.ok && getResponse.status !== 404) {
|
|
208
|
+
// Error getting branch
|
|
209
|
+
throw new Error(
|
|
210
|
+
`Failed to get branch: ${getResponse.statusText} ${await getResponse.text()}`,
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (getResponse.ok) {
|
|
215
|
+
// Branch exists
|
|
216
|
+
if (!props.adopt) {
|
|
217
|
+
throw new Error(
|
|
218
|
+
`Branch ${props.name} already exists and adopt is false`,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const data = await getResponse.json<any>();
|
|
223
|
+
const currentParentBranch = data.parent_branch || "main";
|
|
224
|
+
|
|
225
|
+
// Check immutable properties
|
|
226
|
+
if (props.parentBranch && parentBranchName !== currentParentBranch) {
|
|
227
|
+
throw new Error(
|
|
228
|
+
`Cannot change parent branch from ${currentParentBranch} to ${parentBranchName}`,
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
if (this.output?.backupId) {
|
|
232
|
+
console.warn(
|
|
233
|
+
"BackupID is set, but branch already exists, so it will be ignored",
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (this.output?.seedData) {
|
|
238
|
+
console.warn(
|
|
239
|
+
"SeedData is set, but branch already exists, so it will be ignored",
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Update mutable properties if they've changed
|
|
244
|
+
if (props.safeMigrations !== undefined) {
|
|
245
|
+
const safeMigrationsResponse = await api[
|
|
246
|
+
props.safeMigrations ? "post" : "delete"
|
|
247
|
+
](
|
|
248
|
+
`/organizations/${props.organizationId}/databases/${props.databaseName}/branches/${props.name}/safe-migrations`,
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
if (!safeMigrationsResponse.ok) {
|
|
252
|
+
throw new Error(
|
|
253
|
+
`Failed to ${props.safeMigrations ? "enable" : "disable"} safe migrations: ${safeMigrationsResponse.statusText}`,
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (props.clusterSize && data.cluster_size !== props.clusterSize) {
|
|
259
|
+
const clusterResponse = await api.patch(
|
|
260
|
+
`/organizations/${props.organizationId}/databases/${props.databaseName}/branches/${props.name}/cluster`,
|
|
261
|
+
{
|
|
262
|
+
cluster_size: props.clusterSize,
|
|
263
|
+
},
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
if (!clusterResponse.ok) {
|
|
267
|
+
throw new Error(
|
|
268
|
+
`Failed to update cluster size: ${clusterResponse.statusText}`,
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return this({
|
|
274
|
+
...props,
|
|
275
|
+
name: props.name,
|
|
276
|
+
parentBranch: currentParentBranch,
|
|
277
|
+
createdAt: data.created_at,
|
|
278
|
+
updatedAt: data.updated_at,
|
|
279
|
+
htmlUrl: data.html_url,
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
await waitForDatabaseReady(api, props.organizationId, props.databaseName);
|
|
283
|
+
|
|
284
|
+
// Branch doesn't exist, create it
|
|
285
|
+
const createResponse = await api.post(
|
|
286
|
+
`/organizations/${props.organizationId}/databases/${props.databaseName}/branches`,
|
|
287
|
+
{
|
|
288
|
+
name: props.name,
|
|
289
|
+
parent_branch: parentBranchName,
|
|
290
|
+
backup_id: props.backupId,
|
|
291
|
+
seed_data: props.seedData,
|
|
292
|
+
cluster_size: props.clusterSize,
|
|
293
|
+
},
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
if (!createResponse.ok) {
|
|
297
|
+
throw new Error(
|
|
298
|
+
`Failed to create branch: ${createResponse.statusText} ${await createResponse.text()}`,
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const data = await createResponse.json<any>();
|
|
303
|
+
|
|
304
|
+
// Handle safe migrations if specified
|
|
305
|
+
if (props.safeMigrations !== undefined) {
|
|
306
|
+
// We can't change the migrations mode if the database is not ready
|
|
307
|
+
await waitForDatabaseReady(
|
|
308
|
+
api,
|
|
309
|
+
props.organizationId,
|
|
310
|
+
props.databaseName,
|
|
311
|
+
props.name,
|
|
312
|
+
);
|
|
313
|
+
const safeMigrationsResponse = await api[
|
|
314
|
+
props.safeMigrations ? "post" : "delete"
|
|
315
|
+
](
|
|
316
|
+
`/organizations/${props.organizationId}/databases/${props.databaseName}/branches/${props.name}/safe-migrations`,
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
if (!safeMigrationsResponse.ok) {
|
|
320
|
+
throw new Error(
|
|
321
|
+
`Failed to ${props.safeMigrations ? "enable" : "disable"} safe migrations: ${safeMigrationsResponse.statusText} : ${await safeMigrationsResponse.text()}`,
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Handle cluster size update if specified
|
|
327
|
+
if (props.clusterSize) {
|
|
328
|
+
// Wait for database to be ready before modifying cluster size
|
|
329
|
+
await fixClusterSize(
|
|
330
|
+
api,
|
|
331
|
+
props.organizationId,
|
|
332
|
+
props.databaseName,
|
|
333
|
+
props.name,
|
|
334
|
+
props.clusterSize,
|
|
335
|
+
true,
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return this({
|
|
340
|
+
...props,
|
|
341
|
+
name: props.name,
|
|
342
|
+
parentBranch: data.parent_branch,
|
|
343
|
+
createdAt: data.created_at,
|
|
344
|
+
updatedAt: data.updated_at,
|
|
345
|
+
htmlUrl: data.html_url,
|
|
346
|
+
});
|
|
347
|
+
} catch (error) {
|
|
348
|
+
console.error("Error managing branch:", error);
|
|
349
|
+
throw error;
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
);
|