alchemy 0.25.0 → 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 +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 +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 -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 +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.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 +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 +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 +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 -89
- 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 +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 +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
package/src/cloudflare/zone.ts
CHANGED
|
@@ -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 { createCloudflareApi, type CloudflareApiOptions } from "./api.ts";
|
|
5
6
|
import type {
|
|
@@ -329,7 +330,7 @@ export const Zone = Resource(
|
|
|
329
330
|
);
|
|
330
331
|
}
|
|
331
332
|
} else {
|
|
332
|
-
|
|
333
|
+
logger.warn(`Zone '${props.name}' not found, skipping delete`);
|
|
333
334
|
}
|
|
334
335
|
return this.destroy();
|
|
335
336
|
}
|
|
@@ -387,7 +388,7 @@ export const Zone = Resource(
|
|
|
387
388
|
if (!response.ok) {
|
|
388
389
|
if (response.status === 400 && body.includes("already exists")) {
|
|
389
390
|
// Zone already exists, fetch it instead
|
|
390
|
-
|
|
391
|
+
logger.warn(
|
|
391
392
|
`Zone '${props.name}' already exists during Zone create, adopting it...`,
|
|
392
393
|
);
|
|
393
394
|
const getResponse = await api.get(`/zones?name=${props.name}`);
|
|
@@ -488,7 +489,7 @@ async function updateZoneSettings(
|
|
|
488
489
|
if (!response.ok) {
|
|
489
490
|
const data = await response.text();
|
|
490
491
|
if (response.status === 400 && data.includes("already enabled")) {
|
|
491
|
-
|
|
492
|
+
logger.warn(`Warning: Setting '${key}' already enabled`);
|
|
492
493
|
return;
|
|
493
494
|
}
|
|
494
495
|
throw new Error(
|
package/src/destroy.ts
CHANGED
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
ResourceSeq,
|
|
11
11
|
} from "./resource.ts";
|
|
12
12
|
import { Scope } from "./scope.ts";
|
|
13
|
+
import { formatFQN } from "./util/cli.tsx";
|
|
14
|
+
import { logger } from "./util/logger.ts";
|
|
13
15
|
|
|
14
16
|
export class DestroyedSignal extends Error {}
|
|
15
17
|
|
|
@@ -37,18 +39,21 @@ export async function destroy<Type extends string>(
|
|
|
37
39
|
...(args[1] ?? {}),
|
|
38
40
|
} satisfies DestroyOptions;
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
await scope.run(async () => {
|
|
43
|
+
// destroy all active resources
|
|
44
|
+
await destroyAll(Array.from(scope.resources.values()), options);
|
|
45
|
+
|
|
46
|
+
// then detect orphans and destroy them
|
|
47
|
+
const orphans = await scope.state.all();
|
|
48
|
+
await destroyAll(
|
|
49
|
+
Object.values(orphans).map((orphan) => ({
|
|
50
|
+
...orphan.output,
|
|
51
|
+
Scope: scope,
|
|
52
|
+
})),
|
|
53
|
+
options,
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
52
57
|
// finally, destroy the scope container
|
|
53
58
|
await scope.deinit();
|
|
54
59
|
return;
|
|
@@ -65,7 +70,7 @@ export async function destroy<Type extends string>(
|
|
|
65
70
|
parent: instance[ResourceScope],
|
|
66
71
|
scopeName: instance[ResourceID],
|
|
67
72
|
});
|
|
68
|
-
|
|
73
|
+
logger.log("Destroying scope", scope.chain.join("/"));
|
|
69
74
|
return await destroy(scope, options);
|
|
70
75
|
}
|
|
71
76
|
|
|
@@ -78,13 +83,19 @@ export async function destroy<Type extends string>(
|
|
|
78
83
|
|
|
79
84
|
const scope = instance[ResourceScope];
|
|
80
85
|
if (!scope) {
|
|
81
|
-
|
|
86
|
+
logger.warn(`Resource "${instance[ResourceFQN]}" has no scope`);
|
|
82
87
|
}
|
|
83
88
|
const quiet = options?.quiet ?? scope.quiet;
|
|
84
89
|
|
|
85
90
|
try {
|
|
86
91
|
if (!quiet) {
|
|
87
|
-
|
|
92
|
+
logger.task(instance[ResourceFQN], {
|
|
93
|
+
prefix: "DELETING",
|
|
94
|
+
prefixColor: "magenta",
|
|
95
|
+
resource: formatFQN(instance[ResourceFQN]),
|
|
96
|
+
message: "Deleting Resource...",
|
|
97
|
+
});
|
|
98
|
+
logger.log(`Delete: "${instance[ResourceFQN]}"`);
|
|
88
99
|
}
|
|
89
100
|
|
|
90
101
|
const state = await scope.state.get(instance[ResourceID]);
|
|
@@ -140,10 +151,17 @@ export async function destroy<Type extends string>(
|
|
|
140
151
|
await scope.delete(instance[ResourceID]);
|
|
141
152
|
|
|
142
153
|
if (!quiet) {
|
|
143
|
-
|
|
154
|
+
logger.task(instance[ResourceFQN], {
|
|
155
|
+
prefix: "DELETED",
|
|
156
|
+
prefixColor: "greenBright",
|
|
157
|
+
resource: formatFQN(instance[ResourceFQN]),
|
|
158
|
+
message: "Deleted Resource",
|
|
159
|
+
status: "success",
|
|
160
|
+
});
|
|
161
|
+
logger.log(`Deleted: "${instance[ResourceFQN]}"`);
|
|
144
162
|
}
|
|
145
163
|
} catch (error) {
|
|
146
|
-
|
|
164
|
+
logger.error(error);
|
|
147
165
|
throw error;
|
|
148
166
|
}
|
|
149
167
|
}
|
package/src/dns/godaddy.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from "../util/logger.ts";
|
|
1
2
|
import { safeFetch } from "../util/safe-fetch.ts";
|
|
2
3
|
|
|
3
4
|
export type UpdateNameserversOptions = {
|
|
@@ -23,9 +24,9 @@ export async function updateNameservers(options: UpdateNameserversOptions) {
|
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
if (response.ok) {
|
|
26
|
-
|
|
27
|
+
logger.log(`✅ Nameservers updated for ${options.domain}`);
|
|
27
28
|
} else {
|
|
28
29
|
const error = await response.json();
|
|
29
|
-
|
|
30
|
+
logger.error("❌ Failed to update nameservers:", error);
|
|
30
31
|
}
|
|
31
32
|
}
|
package/src/dns/import-dns.ts
CHANGED
|
@@ -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 { DEFAULT_RECORD_TYPES, type DnsRecordType } from "./record.ts";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -195,7 +196,7 @@ export const ImportDnsRecords = Resource(
|
|
|
195
196
|
allRecords.push(...compatRecords);
|
|
196
197
|
}
|
|
197
198
|
} catch (error) {
|
|
198
|
-
|
|
199
|
+
logger.warn(
|
|
199
200
|
`Failed to fetch ${type} records for ${props.domain}:`,
|
|
200
201
|
error,
|
|
201
202
|
);
|
package/src/esbuild/bundle.ts
CHANGED
|
@@ -4,6 +4,7 @@ import fs from "node:fs/promises";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import type { Context } from "../context.ts";
|
|
6
6
|
import { Resource } from "../resource.ts";
|
|
7
|
+
import { logger } from "../util/logger.ts";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Properties for creating or updating an esbuild bundle
|
|
@@ -199,7 +200,7 @@ export async function bundle(props: BundleProps) {
|
|
|
199
200
|
metafile: true,
|
|
200
201
|
};
|
|
201
202
|
if (process.env.DEBUG) {
|
|
202
|
-
|
|
203
|
+
logger.log(options);
|
|
203
204
|
}
|
|
204
205
|
const esbuild = await import("esbuild");
|
|
205
206
|
return await esbuild.build(options);
|
package/src/fs/copy-file.ts
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import type { Context } from "../context.ts";
|
|
3
3
|
import { Resource } from "../resource.ts";
|
|
4
4
|
import { ignore } from "../util/ignore.ts";
|
|
5
|
+
import { logger } from "../util/logger.ts";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Properties for creating a CopyFile resource
|
|
@@ -107,7 +108,7 @@ export const CopyFile = Resource(
|
|
|
107
108
|
createdAt: Date.now(),
|
|
108
109
|
});
|
|
109
110
|
} catch (error) {
|
|
110
|
-
|
|
111
|
+
logger.error("Error copying file:", error);
|
|
111
112
|
throw error;
|
|
112
113
|
}
|
|
113
114
|
},
|
package/src/fs/file.ts
CHANGED
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import type { Context } from "../context.ts";
|
|
4
4
|
import { Resource } from "../resource.ts";
|
|
5
5
|
import { ignore } from "../util/ignore.ts";
|
|
6
|
+
import { logger } from "../util/logger.ts";
|
|
6
7
|
|
|
7
8
|
import { alchemy } from "../alchemy.ts";
|
|
8
9
|
import type { FileCollection } from "./file-collection.ts";
|
|
@@ -176,7 +177,7 @@ export const File = Resource(
|
|
|
176
177
|
this.output.path !== filePath
|
|
177
178
|
) {
|
|
178
179
|
// If path has changed, delete the old file
|
|
179
|
-
|
|
180
|
+
logger.log(
|
|
180
181
|
`File: Path changed from ${this.output.path} to ${filePath}, removing old file`,
|
|
181
182
|
);
|
|
182
183
|
await ignore("ENOENT", async () => fs.promises.unlink(this.output.path));
|
|
@@ -186,6 +187,7 @@ export const File = Resource(
|
|
|
186
187
|
await fs.promises.mkdir(path.dirname(filePath), {
|
|
187
188
|
recursive: true,
|
|
188
189
|
});
|
|
190
|
+
|
|
189
191
|
await fs.promises.writeFile(filePath, props.content);
|
|
190
192
|
|
|
191
193
|
return this({
|
package/src/github/client.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Octokit } from "@octokit/rest";
|
|
2
2
|
import { exec } from "node:child_process";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
|
+
import { logger } from "../util/logger.ts";
|
|
4
5
|
|
|
5
6
|
// Convert exec to promise-based
|
|
6
7
|
const execAsync = promisify(exec);
|
|
@@ -77,36 +78,36 @@ export async function verifyGitHubAuth(
|
|
|
77
78
|
});
|
|
78
79
|
} catch (error: any) {
|
|
79
80
|
if (error.status === 401) {
|
|
80
|
-
|
|
81
|
+
logger.error(
|
|
81
82
|
"\n⚠️ GitHub authentication failed. Please try one of the following:",
|
|
82
83
|
);
|
|
83
|
-
|
|
84
|
+
logger.error(
|
|
84
85
|
"1. Run 'gh auth login' to authenticate with the GitHub CLI",
|
|
85
86
|
);
|
|
86
|
-
|
|
87
|
+
logger.error(
|
|
87
88
|
"2. Set the GITHUB_TOKEN environment variable with a personal access token",
|
|
88
89
|
);
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
logger.error("3. Pass a token directly to the constructor");
|
|
91
|
+
logger.error(
|
|
91
92
|
"\nTo create a token, visit: https://github.com/settings/tokens",
|
|
92
93
|
);
|
|
93
|
-
|
|
94
|
+
logger.error(
|
|
94
95
|
"Required scopes: 'repo' for private repos or 'public_repo' for public repos\n",
|
|
95
96
|
);
|
|
96
97
|
throw new Error("GitHub authentication failed");
|
|
97
98
|
}
|
|
98
99
|
if (error.status === 403) {
|
|
99
|
-
|
|
100
|
+
logger.error(
|
|
100
101
|
"\n⚠️ Insufficient permissions. You need admin access to the repository.",
|
|
101
102
|
);
|
|
102
|
-
|
|
103
|
+
logger.error(
|
|
103
104
|
"Make sure your token has the 'repo' scope for private repos or 'public_repo' for public repos\n",
|
|
104
105
|
);
|
|
105
106
|
throw new Error("Insufficient GitHub permissions");
|
|
106
107
|
}
|
|
107
108
|
if (error.status === 404) {
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
logger.error(`\n⚠️ Repository not found: ${owner}/${repo}`);
|
|
110
|
+
logger.error(
|
|
110
111
|
"Make sure the repository exists and you have access to it\n",
|
|
111
112
|
);
|
|
112
113
|
throw new Error("GitHub repository not found");
|
|
@@ -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 { createGitHubClient, verifyGitHubAuth } from "./client.ts";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -198,7 +199,7 @@ export const RepositoryEnvironment = Resource(
|
|
|
198
199
|
} catch (error: any) {
|
|
199
200
|
// Ignore 404 errors (environment already deleted)
|
|
200
201
|
if (error.status === 404) {
|
|
201
|
-
|
|
202
|
+
logger.log("Environment doesn't exist, ignoring");
|
|
202
203
|
} else {
|
|
203
204
|
throw error;
|
|
204
205
|
}
|
|
@@ -447,14 +448,14 @@ export const RepositoryEnvironment = Resource(
|
|
|
447
448
|
error.status === 403 &&
|
|
448
449
|
error.message?.includes("Must have admin rights")
|
|
449
450
|
) {
|
|
450
|
-
|
|
451
|
+
logger.error(
|
|
451
452
|
"\n⚠️ Error creating/updating GitHub environment: You must have admin rights to the repository.",
|
|
452
453
|
);
|
|
453
|
-
|
|
454
|
+
logger.error(
|
|
454
455
|
"Make sure your GitHub token has the required permissions (repo scope for private repos).\n",
|
|
455
456
|
);
|
|
456
457
|
} else {
|
|
457
|
-
|
|
458
|
+
logger.error(
|
|
458
459
|
"Error creating/updating GitHub environment:",
|
|
459
460
|
error.message,
|
|
460
461
|
);
|
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
|
+
}
|