alchemy 0.16.10 → 0.17.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/lib/ai/astro-file.d.ts +1 -1
- package/lib/ai/astro-file.d.ts.map +1 -1
- package/lib/ai/astro-file.js +1 -1
- package/lib/ai/astro-file.js.map +1 -1
- package/lib/ai/client.js +2 -2
- package/lib/ai/client.js.map +1 -1
- package/lib/ai/css-file.d.ts +1 -1
- package/lib/ai/css-file.d.ts.map +1 -1
- package/lib/ai/css-file.js +1 -1
- package/lib/ai/css-file.js.map +1 -1
- package/lib/ai/data.d.ts +1 -1
- package/lib/ai/data.d.ts.map +1 -1
- package/lib/ai/data.js +1 -1
- package/lib/ai/data.js.map +1 -1
- package/lib/ai/html-file.d.ts +1 -1
- package/lib/ai/html-file.d.ts.map +1 -1
- package/lib/ai/html-file.js +1 -1
- package/lib/ai/html-file.js.map +1 -1
- package/lib/ai/json-file.d.ts +1 -1
- package/lib/ai/json-file.d.ts.map +1 -1
- package/lib/ai/json-file.js +1 -1
- package/lib/ai/json-file.js.map +1 -1
- package/lib/ai/typescript-file.d.ts +1 -1
- package/lib/ai/typescript-file.d.ts.map +1 -1
- package/lib/ai/typescript-file.js +1 -1
- package/lib/ai/typescript-file.js.map +1 -1
- package/lib/ai/vue-file.d.ts +1 -1
- package/lib/ai/vue-file.d.ts.map +1 -1
- package/lib/ai/vue-file.js +1 -1
- package/lib/ai/vue-file.js.map +1 -1
- package/lib/ai/yaml-file.d.ts +1 -1
- package/lib/ai/yaml-file.d.ts.map +1 -1
- package/lib/ai/yaml-file.js +2 -2
- package/lib/ai/yaml-file.js.map +1 -1
- package/lib/alchemy.d.ts +4 -0
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +14 -4
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.d.ts +2 -0
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +17 -2
- package/lib/apply.js.map +1 -1
- package/lib/aws/bucket.d.ts +1 -1
- package/lib/aws/bucket.d.ts.map +1 -1
- package/lib/aws/bucket.js +1 -1
- package/lib/aws/bucket.js.map +1 -1
- package/lib/aws/function.d.ts +1 -1
- package/lib/aws/function.d.ts.map +1 -1
- package/lib/aws/function.js +2 -2
- package/lib/aws/function.js.map +1 -1
- package/lib/aws/oidc/oidc-provider.d.ts +1 -1
- package/lib/aws/oidc/oidc-provider.d.ts.map +1 -1
- package/lib/aws/oidc/oidc-provider.js +1 -1
- package/lib/aws/oidc/oidc-provider.js.map +1 -1
- package/lib/aws/policy-attachment.d.ts +1 -1
- package/lib/aws/policy-attachment.d.ts.map +1 -1
- package/lib/aws/policy-attachment.js +1 -1
- package/lib/aws/policy-attachment.js.map +1 -1
- package/lib/aws/policy.d.ts +1 -1
- package/lib/aws/policy.d.ts.map +1 -1
- package/lib/aws/policy.js +1 -1
- package/lib/aws/policy.js.map +1 -1
- package/lib/aws/queue.d.ts +1 -1
- package/lib/aws/queue.d.ts.map +1 -1
- package/lib/aws/queue.js +20 -25
- package/lib/aws/queue.js.map +1 -1
- package/lib/aws/role.d.ts +1 -1
- package/lib/aws/role.d.ts.map +1 -1
- package/lib/aws/role.js +1 -1
- package/lib/aws/role.js.map +1 -1
- package/lib/aws/ses.d.ts +1 -1
- package/lib/aws/ses.d.ts.map +1 -1
- package/lib/aws/ses.js +1 -1
- package/lib/aws/ses.js.map +1 -1
- package/lib/aws/table.d.ts +1 -1
- package/lib/aws/table.d.ts.map +1 -1
- package/lib/aws/table.js +1 -1
- package/lib/aws/table.js.map +1 -1
- package/lib/cloudflare/account-api-token.d.ts +1 -1
- package/lib/cloudflare/account-api-token.d.ts.map +1 -1
- package/lib/cloudflare/account-api-token.js +1 -1
- package/lib/cloudflare/account-api-token.js.map +1 -1
- package/lib/cloudflare/ai-gateway.d.ts +4 -3
- package/lib/cloudflare/ai-gateway.d.ts.map +1 -1
- package/lib/cloudflare/ai-gateway.js +13 -1
- package/lib/cloudflare/ai-gateway.js.map +1 -1
- package/lib/cloudflare/api-error.js +1 -1
- package/lib/cloudflare/api-error.js.map +1 -1
- package/lib/cloudflare/assets.js +2 -2
- package/lib/cloudflare/assets.js.map +1 -1
- package/lib/cloudflare/auth.js +1 -1
- package/lib/cloudflare/auth.js.map +1 -1
- package/lib/cloudflare/bindings.d.ts +17 -11
- package/lib/cloudflare/bindings.d.ts.map +1 -1
- package/lib/cloudflare/bindings.js +6 -0
- package/lib/cloudflare/bindings.js.map +1 -1
- package/lib/cloudflare/bound.d.ts +11 -10
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/bucket.d.ts +6 -4
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +22 -2
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/bundle/bundle-worker.d.ts +1 -0
- package/lib/cloudflare/bundle/bundle-worker.d.ts.map +1 -1
- package/lib/cloudflare/bundle/bundle-worker.js +4 -2
- package/lib/cloudflare/bundle/bundle-worker.js.map +1 -1
- package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts +1 -1
- package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts.map +1 -1
- package/lib/cloudflare/bundle/nodejs-compat-mode.js +2 -2
- package/lib/cloudflare/bundle/nodejs-compat-mode.js.map +1 -1
- package/lib/cloudflare/bundle/nodejs-compat.js +1 -1
- package/lib/cloudflare/bundle/nodejs-compat.js.map +1 -1
- package/lib/cloudflare/custom-domain.js +1 -1
- package/lib/cloudflare/custom-domain.js.map +1 -1
- package/lib/cloudflare/d1-database.d.ts +4 -62
- package/lib/cloudflare/d1-database.d.ts.map +1 -1
- package/lib/cloudflare/d1-database.js +27 -11
- package/lib/cloudflare/d1-database.js.map +1 -1
- package/lib/cloudflare/dns-records.d.ts +1 -1
- package/lib/cloudflare/dns-records.d.ts.map +1 -1
- package/lib/cloudflare/dns-records.js +2 -2
- package/lib/cloudflare/dns-records.js.map +1 -1
- package/lib/cloudflare/event-source.d.ts +3 -3
- package/lib/cloudflare/event-source.d.ts.map +1 -1
- package/lib/cloudflare/hyperdrive.d.ts +4 -3
- package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
- package/lib/cloudflare/hyperdrive.js +9 -1
- package/lib/cloudflare/hyperdrive.js.map +1 -1
- package/lib/cloudflare/kv-namespace.d.ts +9 -5
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
- package/lib/cloudflare/kv-namespace.js +26 -6
- package/lib/cloudflare/kv-namespace.js.map +1 -1
- package/lib/cloudflare/permission-groups.d.ts +1 -1
- package/lib/cloudflare/permission-groups.d.ts.map +1 -1
- package/lib/cloudflare/permission-groups.js +1 -1
- package/lib/cloudflare/permission-groups.js.map +1 -1
- package/lib/cloudflare/pipeline.d.ts +5 -3
- package/lib/cloudflare/pipeline.d.ts.map +1 -1
- package/lib/cloudflare/pipeline.js +16 -2
- package/lib/cloudflare/pipeline.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts +3 -3
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +1 -1
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/queue.d.ts +34 -22
- package/lib/cloudflare/queue.d.ts.map +1 -1
- package/lib/cloudflare/queue.js +66 -4
- package/lib/cloudflare/queue.js.map +1 -1
- package/lib/cloudflare/route.d.ts +1 -1
- package/lib/cloudflare/route.d.ts.map +1 -1
- package/lib/cloudflare/route.js +1 -1
- package/lib/cloudflare/route.js.map +1 -1
- package/lib/cloudflare/types.js +1 -1
- package/lib/cloudflare/types.js.map +1 -1
- package/lib/cloudflare/vectorize-index.d.ts +6 -4
- package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-index.js +20 -3
- package/lib/cloudflare/vectorize-index.js.map +1 -1
- package/lib/cloudflare/vectorize-metadata-index.d.ts +4 -3
- package/lib/cloudflare/vectorize-metadata-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-metadata-index.js +5 -2
- package/lib/cloudflare/vectorize-metadata-index.js.map +1 -1
- package/lib/cloudflare/website.d.ts.map +1 -1
- package/lib/cloudflare/website.js +1 -0
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-assets.d.ts +32 -0
- package/lib/cloudflare/worker-assets.d.ts.map +1 -0
- package/lib/cloudflare/worker-assets.js +143 -0
- package/lib/cloudflare/worker-assets.js.map +1 -0
- package/lib/cloudflare/worker-metadata.d.ts +31 -0
- package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
- package/lib/cloudflare/worker-metadata.js +248 -0
- package/lib/cloudflare/worker-metadata.js.map +1 -1
- package/lib/cloudflare/worker-stub.d.ts +40 -0
- package/lib/cloudflare/worker-stub.d.ts.map +1 -0
- package/lib/cloudflare/worker-stub.js +86 -0
- package/lib/cloudflare/worker-stub.js.map +1 -0
- package/lib/cloudflare/worker.d.ts +57 -28
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +203 -479
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.d.ts +1 -1
- package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
- package/lib/cloudflare/wrangler.json.js +5 -2
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/cloudflare/zone.d.ts +1 -1
- package/lib/cloudflare/zone.d.ts.map +1 -1
- package/lib/cloudflare/zone.js +1 -1
- package/lib/cloudflare/zone.js.map +1 -1
- package/lib/destroy.d.ts +1 -4
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js +10 -21
- package/lib/destroy.js.map +1 -1
- package/lib/dns/import-dns.d.ts +1 -1
- package/lib/dns/import-dns.d.ts.map +1 -1
- package/lib/dns/import-dns.js +1 -1
- package/lib/dns/import-dns.js.map +1 -1
- package/lib/encrypt.d.ts.map +1 -1
- package/lib/encrypt.js +2 -1
- package/lib/encrypt.js.map +1 -1
- package/lib/env.js +14 -8
- package/lib/env.js.map +1 -1
- package/lib/esbuild/bundle.d.ts +2 -2
- package/lib/esbuild/bundle.d.ts.map +1 -1
- package/lib/esbuild/bundle.js +3 -3
- package/lib/esbuild/bundle.js.map +1 -1
- package/lib/fs/copy-file.d.ts +1 -1
- package/lib/fs/copy-file.d.ts.map +1 -1
- package/lib/fs/copy-file.js +1 -1
- package/lib/fs/copy-file.js.map +1 -1
- package/lib/github/client.js +1 -1
- package/lib/github/client.js.map +1 -1
- package/lib/github/repository-environment.d.ts +1 -1
- package/lib/github/repository-environment.d.ts.map +1 -1
- package/lib/github/repository-environment.js +2 -2
- package/lib/github/repository-environment.js.map +1 -1
- package/lib/github/secret.d.ts +1 -1
- package/lib/github/secret.d.ts.map +1 -1
- package/lib/github/secret.js +1 -1
- package/lib/github/secret.js.map +1 -1
- package/lib/internal/docs/providers.d.ts +1 -1
- package/lib/internal/docs/providers.d.ts.map +1 -1
- package/lib/internal/docs/providers.js +3 -1
- package/lib/internal/docs/providers.js.map +1 -1
- package/lib/neon/api-error.js +2 -2
- package/lib/neon/api-error.js.map +1 -1
- package/lib/os/exec.js +1 -1
- package/lib/os/exec.js.map +1 -1
- package/lib/resource.d.ts +13 -11
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js +10 -5
- package/lib/resource.js.map +1 -1
- package/lib/runtime/bind.d.ts +25 -0
- package/lib/runtime/bind.d.ts.map +1 -0
- package/lib/runtime/bind.js +76 -0
- package/lib/runtime/bind.js.map +1 -0
- package/lib/runtime/global.d.ts +8 -0
- package/lib/runtime/global.d.ts.map +1 -0
- package/lib/runtime/global.js +3 -0
- package/lib/runtime/global.js.map +1 -0
- package/lib/runtime/plugin.d.ts +35 -0
- package/lib/runtime/plugin.d.ts.map +1 -0
- package/lib/runtime/plugin.js +133 -0
- package/lib/runtime/plugin.js.map +1 -0
- package/lib/runtime/shims.d.ts +6 -0
- package/lib/runtime/shims.d.ts.map +1 -0
- package/lib/runtime/shims.js +27 -0
- package/lib/runtime/shims.js.map +1 -0
- package/lib/runtime/state.d.ts +5 -0
- package/lib/runtime/state.d.ts.map +1 -0
- package/lib/runtime/state.js +4 -0
- package/lib/runtime/state.js.map +1 -0
- package/lib/scope.d.ts +16 -2
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +56 -9
- package/lib/scope.js.map +1 -1
- package/lib/secret.d.ts +7 -2
- package/lib/secret.d.ts.map +1 -1
- package/lib/secret.js +19 -4
- package/lib/secret.js.map +1 -1
- package/lib/sentry/client-key.d.ts +1 -1
- package/lib/sentry/client-key.d.ts.map +1 -1
- package/lib/sentry/client-key.js +1 -1
- package/lib/sentry/client-key.js.map +1 -1
- package/lib/sentry/project.d.ts +1 -1
- package/lib/sentry/project.d.ts.map +1 -1
- package/lib/sentry/project.js +1 -1
- package/lib/sentry/project.js.map +1 -1
- package/lib/sentry/team.d.ts +1 -1
- package/lib/sentry/team.d.ts.map +1 -1
- package/lib/sentry/team.js +1 -1
- package/lib/sentry/team.js.map +1 -1
- package/lib/serde.d.ts +26 -1
- package/lib/serde.d.ts.map +1 -1
- package/lib/serde.js +53 -8
- package/lib/serde.js.map +1 -1
- package/lib/stripe/meter.d.ts +1 -1
- package/lib/stripe/meter.d.ts.map +1 -1
- package/lib/stripe/meter.js +1 -1
- package/lib/stripe/meter.js.map +1 -1
- package/lib/stripe/price.d.ts +1 -1
- package/lib/stripe/price.d.ts.map +1 -1
- package/lib/stripe/price.js +1 -1
- package/lib/stripe/price.js.map +1 -1
- package/lib/stripe/product.d.ts +1 -1
- package/lib/stripe/product.d.ts.map +1 -1
- package/lib/stripe/product.js +1 -1
- package/lib/stripe/product.js.map +1 -1
- package/lib/stripe/webhook.d.ts +1 -1
- package/lib/stripe/webhook.d.ts.map +1 -1
- package/lib/stripe/webhook.js +1 -1
- package/lib/stripe/webhook.js.map +1 -1
- package/lib/test/bun.js +1 -1
- package/lib/test/bun.js.map +1 -1
- package/lib/test/prune.js +1 -1
- package/lib/test/prune.js.map +1 -1
- package/lib/upstash/redis.d.ts +1 -1
- package/lib/upstash/redis.d.ts.map +1 -1
- package/lib/upstash/redis.js +1 -1
- package/lib/upstash/redis.js.map +1 -1
- package/lib/util/content-type.d.ts +1 -1
- package/lib/util/content-type.d.ts.map +1 -1
- package/lib/util/content-type.js +1 -2
- package/lib/util/content-type.js.map +1 -1
- package/lib/util/retry.d.ts.map +1 -1
- package/lib/util/retry.js +1 -0
- package/lib/util/retry.js.map +1 -1
- package/lib/vercel/project-domain.d.ts +1 -1
- package/lib/vercel/project-domain.d.ts.map +1 -1
- package/lib/vercel/project-domain.js +1 -1
- package/lib/vercel/project-domain.js.map +1 -1
- package/lib/vercel/project.js +1 -1
- package/lib/vercel/project.js.map +1 -1
- package/lib/web/shadcn-component.d.ts +1 -1
- package/lib/web/shadcn-component.d.ts.map +1 -1
- package/lib/web/shadcn-component.js +1 -1
- package/lib/web/shadcn-component.js.map +1 -1
- package/lib/web/shadcn.d.ts +1 -1
- package/lib/web/shadcn.d.ts.map +1 -1
- package/lib/web/shadcn.js +1 -1
- package/lib/web/shadcn.js.map +1 -1
- package/lib/web/vitepress/dependencies.d.ts +1 -1
- package/lib/web/vitepress/dependencies.d.ts.map +1 -1
- package/lib/web/vitepress/dependencies.js +1 -1
- package/lib/web/vitepress/dependencies.js.map +1 -1
- package/lib/web/vitepress/vitepress.js +1 -1
- package/lib/web/vitepress/vitepress.js.map +1 -1
- package/package.json +2 -1
- package/src/ai/astro-file.ts +1 -1
- package/src/ai/client.ts +2 -2
- package/src/ai/css-file.ts +1 -1
- package/src/ai/data.ts +1 -1
- package/src/ai/html-file.ts +1 -1
- package/src/ai/json-file.ts +1 -1
- package/src/ai/typescript-file.ts +1 -1
- package/src/ai/vue-file.ts +1 -1
- package/src/ai/yaml-file.ts +2 -2
- package/src/alchemy.ts +18 -4
- package/src/apply.ts +27 -2
- package/src/aws/bucket.ts +1 -1
- package/src/aws/function.ts +2 -2
- package/src/aws/oidc/oidc-provider.ts +1 -1
- package/src/aws/policy-attachment.ts +1 -1
- package/src/aws/policy.ts +1 -1
- package/src/aws/queue.ts +28 -29
- package/src/aws/role.ts +1 -1
- package/src/aws/ses.ts +1 -1
- package/src/aws/table.ts +1 -1
- package/src/cloudflare/account-api-token.ts +1 -1
- package/src/cloudflare/ai-gateway.ts +23 -4
- package/src/cloudflare/api-error.ts +1 -1
- package/src/cloudflare/assets.ts +2 -2
- package/src/cloudflare/auth.ts +1 -1
- package/src/cloudflare/bindings.ts +33 -18
- package/src/cloudflare/bound.ts +18 -17
- package/src/cloudflare/bucket.ts +52 -24
- package/src/cloudflare/bundle/bundle-worker.ts +5 -2
- package/src/cloudflare/bundle/nodejs-compat-mode.ts +3 -3
- package/src/cloudflare/bundle/nodejs-compat.ts +1 -1
- package/src/cloudflare/custom-domain.ts +1 -1
- package/src/cloudflare/d1-database.ts +40 -19
- package/src/cloudflare/dns-records.ts +2 -2
- package/src/cloudflare/event-source.ts +3 -3
- package/src/cloudflare/hyperdrive.ts +19 -4
- package/src/cloudflare/kv-namespace.ts +46 -15
- package/src/cloudflare/permission-groups.ts +1 -1
- package/src/cloudflare/pipeline.ts +29 -6
- package/src/cloudflare/queue-consumer.ts +3 -3
- package/src/cloudflare/queue.ts +124 -23
- package/src/cloudflare/route.ts +1 -1
- package/src/cloudflare/types.ts +1 -1
- package/src/cloudflare/vectorize-index.ts +36 -8
- package/src/cloudflare/vectorize-metadata-index.ts +10 -4
- package/src/cloudflare/website.ts +4 -3
- package/src/cloudflare/worker-assets.ts +237 -0
- package/src/cloudflare/worker-metadata.ts +287 -0
- package/src/cloudflare/worker-stub.ts +153 -0
- package/src/cloudflare/worker.ts +386 -592
- package/src/cloudflare/wrangler.json.ts +4 -2
- package/src/cloudflare/zone.ts +1 -1
- package/src/destroy.ts +12 -23
- package/src/dns/import-dns.ts +1 -1
- package/src/encrypt.ts +2 -2
- package/src/env.ts +15 -8
- package/src/esbuild/bundle.ts +4 -3
- package/src/fs/copy-file.ts +1 -1
- package/src/github/client.ts +1 -1
- package/src/github/repository-environment.ts +2 -2
- package/src/github/secret.ts +1 -1
- package/src/internal/docs/providers.ts +1 -1
- package/src/neon/api-error.ts +2 -2
- package/src/os/exec.ts +1 -1
- package/src/resource.ts +22 -31
- package/src/runtime/bind.ts +95 -0
- package/src/runtime/global.ts +10 -0
- package/src/runtime/plugin.ts +162 -0
- package/src/runtime/shims.js +34 -0
- package/src/runtime/state.ts +9 -0
- package/src/scope.ts +72 -11
- package/src/secret.ts +29 -4
- package/src/sentry/client-key.ts +1 -1
- package/src/sentry/project.ts +1 -1
- package/src/sentry/team.ts +1 -1
- package/src/serde.ts +126 -10
- package/src/stripe/meter.ts +1 -1
- package/src/stripe/price.ts +1 -1
- package/src/stripe/product.ts +1 -1
- package/src/stripe/webhook.ts +1 -1
- package/src/test/bun.ts +1 -1
- package/src/test/prune.ts +1 -1
- package/src/upstash/redis.ts +1 -1
- package/src/util/content-type.ts +2 -3
- package/src/util/retry.ts +1 -0
- package/src/vercel/project-domain.ts +1 -1
- package/src/vercel/project.ts +1 -1
- package/src/web/shadcn-component.ts +1 -1
- package/src/web/shadcn.ts +1 -1
- package/src/web/vitepress/dependencies.ts +1 -1
- package/src/web/vitepress/vitepress.ts +1 -1
package/src/scope.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import type { Phase } from "./alchemy.js";
|
|
3
|
-
import {
|
|
3
|
+
import { destroyAll } from "./destroy.js";
|
|
4
4
|
import { FileSystemStateStore } from "./fs/file-system-state-store.js";
|
|
5
5
|
import { ResourceID, type PendingResource } from "./resource.js";
|
|
6
6
|
import type { StateStore, StateStoreType } from "./state.js";
|
|
7
7
|
|
|
8
|
-
const scopeStorage = new AsyncLocalStorage<Scope>();
|
|
9
|
-
|
|
10
8
|
export type ScopeOptions = {
|
|
11
9
|
appName?: string;
|
|
12
10
|
stage?: string;
|
|
@@ -24,19 +22,30 @@ const DEFAULT_STAGE = process.env.ALCHEMY_STAGE ?? process.env.USER ?? "dev";
|
|
|
24
22
|
export class Scope {
|
|
25
23
|
public static readonly KIND = "alchemy::Scope" as const;
|
|
26
24
|
|
|
25
|
+
public static storage = new AsyncLocalStorage<Scope>();
|
|
26
|
+
public static globals: Scope[] = [];
|
|
27
|
+
|
|
27
28
|
public static get(): Scope | undefined {
|
|
28
|
-
return
|
|
29
|
+
return Scope.storage.getStore();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static get root(): Scope {
|
|
33
|
+
return Scope.current.root;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
public static get current(): Scope {
|
|
32
37
|
const scope = Scope.get();
|
|
33
38
|
if (!scope) {
|
|
39
|
+
if (Scope.globals.length > 0) {
|
|
40
|
+
return Scope.globals[Scope.globals.length - 1];
|
|
41
|
+
}
|
|
34
42
|
throw new Error("Not running within an Alchemy Scope");
|
|
35
43
|
}
|
|
36
44
|
return scope;
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
public readonly resources = new Map<ResourceID, PendingResource>();
|
|
48
|
+
public readonly children: Map<ResourceID, Scope> = new Map();
|
|
40
49
|
public readonly appName: string | undefined;
|
|
41
50
|
public readonly stage: string;
|
|
42
51
|
public readonly scopeName: string | null;
|
|
@@ -48,10 +57,12 @@ export class Scope {
|
|
|
48
57
|
public readonly phase: Phase;
|
|
49
58
|
|
|
50
59
|
private isErrored = false;
|
|
60
|
+
private finalized = false;
|
|
61
|
+
|
|
62
|
+
private deferred: (() => Promise<any>)[] = [];
|
|
51
63
|
|
|
52
64
|
constructor(options: ScopeOptions) {
|
|
53
65
|
this.appName = options.appName;
|
|
54
|
-
this.stage = options?.stage ?? DEFAULT_STAGE;
|
|
55
66
|
this.scopeName = options.scopeName ?? null;
|
|
56
67
|
if (this.scopeName?.includes(":")) {
|
|
57
68
|
throw new Error(
|
|
@@ -59,6 +70,8 @@ export class Scope {
|
|
|
59
70
|
);
|
|
60
71
|
}
|
|
61
72
|
this.parent = options.parent ?? Scope.get();
|
|
73
|
+
this.stage = options?.stage ?? this.parent?.stage ?? DEFAULT_STAGE;
|
|
74
|
+
this.parent?.children.set(this.scopeName!, this);
|
|
62
75
|
this.quiet = options.quiet ?? this.parent?.quiet ?? false;
|
|
63
76
|
if (this.parent && !this.scopeName) {
|
|
64
77
|
throw new Error("Scope name is required when creating a child scope");
|
|
@@ -77,6 +90,14 @@ export class Scope {
|
|
|
77
90
|
this.state = this.stateStore(this);
|
|
78
91
|
}
|
|
79
92
|
|
|
93
|
+
public get root(): Scope {
|
|
94
|
+
let root: Scope = this;
|
|
95
|
+
while (root.parent) {
|
|
96
|
+
root = root.parent;
|
|
97
|
+
}
|
|
98
|
+
return root;
|
|
99
|
+
}
|
|
100
|
+
|
|
80
101
|
public async delete(resourceID: ResourceID) {
|
|
81
102
|
await this.state.delete(resourceID);
|
|
82
103
|
this.resources.delete(resourceID);
|
|
@@ -102,10 +123,6 @@ export class Scope {
|
|
|
102
123
|
this.isErrored = true;
|
|
103
124
|
}
|
|
104
125
|
|
|
105
|
-
public enter() {
|
|
106
|
-
scopeStorage.enterWith(this);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
126
|
public async init() {
|
|
110
127
|
await this.state.init?.();
|
|
111
128
|
}
|
|
@@ -120,7 +137,7 @@ export class Scope {
|
|
|
120
137
|
}
|
|
121
138
|
|
|
122
139
|
public async run<T>(fn: (scope: Scope) => Promise<T>): Promise<T> {
|
|
123
|
-
return
|
|
140
|
+
return Scope.storage.run(this, () => fn(this));
|
|
124
141
|
}
|
|
125
142
|
|
|
126
143
|
[Symbol.asyncDispose]() {
|
|
@@ -131,6 +148,20 @@ export class Scope {
|
|
|
131
148
|
if (this.phase === "read") {
|
|
132
149
|
return;
|
|
133
150
|
}
|
|
151
|
+
if (this.finalized) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (this.parent === undefined && Scope.globals.length > 0) {
|
|
155
|
+
const last = Scope.globals.pop();
|
|
156
|
+
if (last !== this) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
"Running in AsyncLocaStorage.enterWith emultation mode and attempted to finalize a global Scope that wasn't top of the stack",
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
this.finalized = true;
|
|
163
|
+
// trigger and await all deferred promises
|
|
164
|
+
await Promise.all(this.deferred.map((fn) => fn()));
|
|
134
165
|
if (!this.isErrored) {
|
|
135
166
|
// TODO: need to detect if it is in error
|
|
136
167
|
const resourceIds = await this.state.list();
|
|
@@ -141,7 +172,7 @@ export class Scope {
|
|
|
141
172
|
const orphans = await Promise.all(
|
|
142
173
|
orphanIds.map(async (id) => (await this.state.get(id))!.output),
|
|
143
174
|
);
|
|
144
|
-
await
|
|
175
|
+
await destroyAll(orphans, {
|
|
145
176
|
quiet: this.quiet,
|
|
146
177
|
strategy: "sequential",
|
|
147
178
|
});
|
|
@@ -150,6 +181,28 @@ export class Scope {
|
|
|
150
181
|
}
|
|
151
182
|
}
|
|
152
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Defers execution of a function until the Alchemy application finalizes.
|
|
186
|
+
*/
|
|
187
|
+
public defer<T>(fn: () => Promise<T>): Promise<T> {
|
|
188
|
+
let _resolve: (value: T) => void;
|
|
189
|
+
let _reject: (reason?: any) => void;
|
|
190
|
+
const promise = new Promise<T>((resolve, reject) => {
|
|
191
|
+
_resolve = resolve;
|
|
192
|
+
_reject = reject;
|
|
193
|
+
});
|
|
194
|
+
this.deferred.push(() => {
|
|
195
|
+
if (!this.finalized) {
|
|
196
|
+
throw new Error(
|
|
197
|
+
"Attempted to await a deferred Promise before finalization",
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
// lazily trigger the worker on first await
|
|
201
|
+
return this.run(() => fn()).then(_resolve, _reject);
|
|
202
|
+
});
|
|
203
|
+
return promise;
|
|
204
|
+
}
|
|
205
|
+
|
|
153
206
|
/**
|
|
154
207
|
* Returns a string representation of the scope.
|
|
155
208
|
*/
|
|
@@ -162,3 +215,11 @@ export class Scope {
|
|
|
162
215
|
)`;
|
|
163
216
|
}
|
|
164
217
|
}
|
|
218
|
+
|
|
219
|
+
declare global {
|
|
220
|
+
// for runtime
|
|
221
|
+
// TODO(sam): maybe inject is a better way to achieve this
|
|
222
|
+
var __ALCHEMY_SCOPE__: typeof Scope;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
globalThis.__ALCHEMY_SCOPE__ = Scope;
|
package/src/secret.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { alchemy } from "./alchemy.js";
|
|
2
2
|
|
|
3
|
+
// a global registry of all secrets that we will use when serializing an application
|
|
4
|
+
const globalSecrets: {
|
|
5
|
+
[name: string]: Secret;
|
|
6
|
+
} = {};
|
|
7
|
+
|
|
8
|
+
let i = 0;
|
|
9
|
+
function nextName() {
|
|
10
|
+
return `alchemy:anonymous-secret-${i++}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
/**
|
|
4
14
|
* Internal wrapper for sensitive values like API keys and credentials.
|
|
5
15
|
* When stored in alchemy state files, the value is automatically encrypted
|
|
@@ -36,8 +46,20 @@ import { alchemy } from "./alchemy.js";
|
|
|
36
46
|
* }
|
|
37
47
|
*/
|
|
38
48
|
export class Secret {
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
public static all(): Secret[] {
|
|
53
|
+
return Object.values(globalSecrets);
|
|
54
|
+
}
|
|
55
|
+
|
|
39
56
|
public readonly type = "secret";
|
|
40
|
-
constructor(
|
|
57
|
+
constructor(
|
|
58
|
+
readonly unencrypted: string,
|
|
59
|
+
readonly name: string = nextName(),
|
|
60
|
+
) {
|
|
61
|
+
globalSecrets[name] = this;
|
|
62
|
+
}
|
|
41
63
|
}
|
|
42
64
|
|
|
43
65
|
/**
|
|
@@ -79,11 +101,14 @@ export function isSecret(binding: any): binding is Secret {
|
|
|
79
101
|
* @throws {Error} If the value is undefined
|
|
80
102
|
* @throws {Error} If no password is set in the alchemy application options or current scope
|
|
81
103
|
*/
|
|
82
|
-
export function secret<S extends string | undefined>(
|
|
104
|
+
export function secret<S extends string | undefined>(
|
|
105
|
+
unencrypted: S,
|
|
106
|
+
name?: string,
|
|
107
|
+
): Secret {
|
|
83
108
|
if (unencrypted === undefined) {
|
|
84
109
|
throw new Error("Secret cannot be undefined");
|
|
85
110
|
}
|
|
86
|
-
return new Secret(unencrypted);
|
|
111
|
+
return new Secret(unencrypted, name);
|
|
87
112
|
}
|
|
88
113
|
|
|
89
114
|
export namespace secret {
|
|
@@ -104,7 +129,7 @@ export namespace secret {
|
|
|
104
129
|
): Promise<Secret> {
|
|
105
130
|
const result = await alchemy.env(name, value, error);
|
|
106
131
|
if (typeof result === "string") {
|
|
107
|
-
return secret(result);
|
|
132
|
+
return secret(result, name);
|
|
108
133
|
}
|
|
109
134
|
throw new Error(`Secret environment variable ${name} is not a string`);
|
|
110
135
|
}
|
package/src/sentry/client-key.ts
CHANGED
|
@@ -179,7 +179,7 @@ export const ClientKey = Resource(
|
|
|
179
179
|
"sentry::ClientKey",
|
|
180
180
|
async function (
|
|
181
181
|
this: Context<ClientKey>,
|
|
182
|
-
|
|
182
|
+
_id: string,
|
|
183
183
|
props: ClientKeyProps,
|
|
184
184
|
): Promise<ClientKey> {
|
|
185
185
|
const api = new SentryApi({ authToken: props.authToken });
|
package/src/sentry/project.ts
CHANGED
package/src/sentry/team.ts
CHANGED
package/src/serde.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { decryptWithKey, encrypt } from "./encrypt.js";
|
|
2
|
+
import {
|
|
3
|
+
InnerResourceScope,
|
|
4
|
+
ResourceFQN,
|
|
5
|
+
ResourceKind,
|
|
6
|
+
type Resource,
|
|
7
|
+
} from "./resource.js";
|
|
2
8
|
import { Scope } from "./scope.js";
|
|
3
9
|
import { Secret } from "./secret.js";
|
|
4
10
|
|
|
@@ -13,13 +19,96 @@ function isType(value: any): value is Type<any, any> {
|
|
|
13
19
|
);
|
|
14
20
|
}
|
|
15
21
|
|
|
22
|
+
export type Serialized<T> = T extends
|
|
23
|
+
| undefined
|
|
24
|
+
| null
|
|
25
|
+
| boolean
|
|
26
|
+
| number
|
|
27
|
+
| string
|
|
28
|
+
| bigint
|
|
29
|
+
? T
|
|
30
|
+
: T extends Type<any, any>
|
|
31
|
+
? {
|
|
32
|
+
"@schema": string;
|
|
33
|
+
}
|
|
34
|
+
: T extends Secret
|
|
35
|
+
? {
|
|
36
|
+
"@secret": string;
|
|
37
|
+
}
|
|
38
|
+
: T extends Date
|
|
39
|
+
? {
|
|
40
|
+
"@date": string;
|
|
41
|
+
}
|
|
42
|
+
: T extends Symbol
|
|
43
|
+
? {
|
|
44
|
+
"@symbol": string;
|
|
45
|
+
}
|
|
46
|
+
: T extends Scope
|
|
47
|
+
? {
|
|
48
|
+
"@scope": null;
|
|
49
|
+
}
|
|
50
|
+
: T extends Function
|
|
51
|
+
? undefined
|
|
52
|
+
: T extends Array<infer U>
|
|
53
|
+
? Array<Serialized<U>>
|
|
54
|
+
: T extends object
|
|
55
|
+
? {
|
|
56
|
+
[K in keyof T as K extends symbol
|
|
57
|
+
? string
|
|
58
|
+
: K]: Serialized<T[K]>;
|
|
59
|
+
}
|
|
60
|
+
: T;
|
|
61
|
+
|
|
62
|
+
export type SerializedScope = {
|
|
63
|
+
[fqn: ResourceFQN]: Serialized<Resource>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export async function serializeScope(scope: Scope): Promise<SerializedScope> {
|
|
67
|
+
const map: SerializedScope = {};
|
|
68
|
+
|
|
69
|
+
return serializeScope(scope);
|
|
70
|
+
|
|
71
|
+
async function serializeScope(scope: Scope): Promise<SerializedScope> {
|
|
72
|
+
await Promise.all(
|
|
73
|
+
Array.from(scope.resources.values()).map(async (resource) => {
|
|
74
|
+
if (resource[ResourceKind] === Scope.KIND) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
map[resource[ResourceFQN]] = await serialize(scope, await resource, {
|
|
78
|
+
transform: (value) => {
|
|
79
|
+
if (value instanceof Secret) {
|
|
80
|
+
return {
|
|
81
|
+
"@secret-env": value.name,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
const innerScope = await resource[InnerResourceScope];
|
|
88
|
+
if (innerScope) {
|
|
89
|
+
await serializeScope(innerScope);
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
await Promise.all(
|
|
94
|
+
Array.from(scope.children.values()).map((scope) => serializeScope(scope)),
|
|
95
|
+
);
|
|
96
|
+
return map;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
16
100
|
export async function serialize(
|
|
17
101
|
scope: Scope,
|
|
18
102
|
value: any,
|
|
19
103
|
options?: {
|
|
20
104
|
encrypt?: boolean;
|
|
105
|
+
transform?: (value: any) => any;
|
|
21
106
|
},
|
|
22
107
|
): Promise<any> {
|
|
108
|
+
if (options?.transform) {
|
|
109
|
+
value = options.transform(value);
|
|
110
|
+
}
|
|
111
|
+
|
|
23
112
|
if (Array.isArray(value)) {
|
|
24
113
|
return Promise.all(value.map((value) => serialize(scope, value, options)));
|
|
25
114
|
} else if (value instanceof Secret) {
|
|
@@ -49,17 +138,19 @@ export async function serialize(
|
|
|
49
138
|
return {
|
|
50
139
|
"@scope": null,
|
|
51
140
|
};
|
|
141
|
+
} else if (isImportMeta(value)) {
|
|
142
|
+
// ImportMeta serialized as {}, so we are mapping it
|
|
143
|
+
// TODO(sam):
|
|
144
|
+
return Object.fromEntries(
|
|
145
|
+
Object.keys(Object.getPrototypeOf(value))
|
|
146
|
+
// exlcude import.meta.env
|
|
147
|
+
.filter((prop) => prop === "env")
|
|
148
|
+
.map((prop) => [prop, (value as any)[prop]]),
|
|
149
|
+
);
|
|
52
150
|
} else if (value && typeof value === "object") {
|
|
53
151
|
for (const symbol of Object.getOwnPropertySymbols(value)) {
|
|
54
152
|
assertNotUniqueSymbol(symbol);
|
|
55
153
|
}
|
|
56
|
-
for (const key of Object.keys(value)) {
|
|
57
|
-
if (parseSymbol(key)) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
`Cannot serialize property '${key}' because it looks like a stringified symbol.`,
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
154
|
return Object.fromEntries(
|
|
64
155
|
await Promise.all(
|
|
65
156
|
[...Object.getOwnPropertySymbols(value), ...Object.keys(value)].map(
|
|
@@ -77,10 +168,35 @@ export async function serialize(
|
|
|
77
168
|
return value;
|
|
78
169
|
}
|
|
79
170
|
|
|
80
|
-
|
|
171
|
+
function isImportMeta(value: any): value is ImportMeta {
|
|
172
|
+
return (
|
|
173
|
+
value &&
|
|
174
|
+
typeof value === "object" &&
|
|
175
|
+
typeof value.dirname === "string" &&
|
|
176
|
+
typeof value.filename === "string" &&
|
|
177
|
+
typeof value.url === "string"
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export async function deserialize(
|
|
182
|
+
scope: Scope,
|
|
183
|
+
value: any,
|
|
184
|
+
options?: {
|
|
185
|
+
transform?: (value: any) =>
|
|
186
|
+
| undefined
|
|
187
|
+
| {
|
|
188
|
+
value: any;
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
): Promise<any> {
|
|
192
|
+
const replacement = options?.transform?.(value);
|
|
193
|
+
if (replacement) {
|
|
194
|
+
return replacement.value;
|
|
195
|
+
}
|
|
196
|
+
|
|
81
197
|
if (Array.isArray(value)) {
|
|
82
198
|
return await Promise.all(
|
|
83
|
-
value.map(async (item) => await deserialize(scope, item)),
|
|
199
|
+
value.map(async (item) => await deserialize(scope, item, options)),
|
|
84
200
|
);
|
|
85
201
|
}
|
|
86
202
|
if (value && typeof value === "object") {
|
|
@@ -103,7 +219,7 @@ export async function deserialize(scope: Scope, value: any): Promise<any> {
|
|
|
103
219
|
await Promise.all(
|
|
104
220
|
Object.entries(value).map(async ([key, value]) => [
|
|
105
221
|
parseSymbol(key) ?? key,
|
|
106
|
-
await deserialize(scope, value),
|
|
222
|
+
await deserialize(scope, value, options),
|
|
107
223
|
]),
|
|
108
224
|
),
|
|
109
225
|
);
|
package/src/stripe/meter.ts
CHANGED
package/src/stripe/price.ts
CHANGED
package/src/stripe/product.ts
CHANGED
package/src/stripe/webhook.ts
CHANGED
|
@@ -135,7 +135,7 @@ export const WebhookEndpoint = Resource(
|
|
|
135
135
|
"stripe::WebhookEndpoint",
|
|
136
136
|
async function (
|
|
137
137
|
this: Context<WebhookEndpoint>,
|
|
138
|
-
|
|
138
|
+
_id: string,
|
|
139
139
|
props: WebhookEndpointProps,
|
|
140
140
|
) {
|
|
141
141
|
// Get Stripe API key from context or environment
|
package/src/test/bun.ts
CHANGED
|
@@ -132,7 +132,7 @@ export function test(meta: ImportMeta, defaultOptions?: TestOptions): test {
|
|
|
132
132
|
test.skipIf = (condition: boolean) => {
|
|
133
133
|
if (condition) {
|
|
134
134
|
// TODO: proxy through to bun:test.skipIf
|
|
135
|
-
return (...
|
|
135
|
+
return (..._args: any[]) => {};
|
|
136
136
|
}
|
|
137
137
|
return test;
|
|
138
138
|
};
|
package/src/test/prune.ts
CHANGED
|
@@ -129,7 +129,7 @@ async function getDependencies(testFile: string): Promise<Set<string>> {
|
|
|
129
129
|
format: "esm",
|
|
130
130
|
bundle: true,
|
|
131
131
|
metafile: true,
|
|
132
|
-
external: ["@cloudflare/workers-types", "bun:test"],
|
|
132
|
+
external: ["@cloudflare/workers-types", "bun:test", "@swc/*"],
|
|
133
133
|
logLevel: "error",
|
|
134
134
|
});
|
|
135
135
|
|
package/src/upstash/redis.ts
CHANGED
package/src/util/content-type.ts
CHANGED
|
@@ -36,7 +36,6 @@ const mimeTypes: Record<string, string> = {
|
|
|
36
36
|
* @param filePath Path to the file
|
|
37
37
|
* @returns The content type for the file
|
|
38
38
|
*/
|
|
39
|
-
export function getContentType(filePath: string): string {
|
|
40
|
-
|
|
41
|
-
return mimeTypes[extension] || "application/octet-stream";
|
|
39
|
+
export function getContentType(filePath: string): string | undefined {
|
|
40
|
+
return mimeTypes[path.extname(filePath).toLowerCase()];
|
|
42
41
|
}
|
package/src/util/retry.ts
CHANGED
|
@@ -22,6 +22,7 @@ export async function withExponentialBackoff<T>(
|
|
|
22
22
|
try {
|
|
23
23
|
return await operation();
|
|
24
24
|
} catch (error) {
|
|
25
|
+
console.log("error", error);
|
|
25
26
|
attempt++;
|
|
26
27
|
if (attempt >= maxAttempts || !isRetryable(error)) {
|
|
27
28
|
console.warn("Failed after ", attempt, " attempts");
|
|
@@ -122,7 +122,7 @@ export const ProjectDomain = Resource(
|
|
|
122
122
|
"vercel::ProjectDomain",
|
|
123
123
|
async function (
|
|
124
124
|
this: Context<ProjectDomain>,
|
|
125
|
-
|
|
125
|
+
_id: string,
|
|
126
126
|
{ accessToken, ...props }: ProjectDomainProps & { accessToken?: Secret },
|
|
127
127
|
): Promise<ProjectDomain> {
|
|
128
128
|
switch (this.phase) {
|
package/src/vercel/project.ts
CHANGED
|
@@ -400,7 +400,7 @@ export const Project = Resource(
|
|
|
400
400
|
|
|
401
401
|
// 409 Conflict: Can't update name, so remove it from the props
|
|
402
402
|
// 400 Invalid Request: Should NOT have additional property `environmentVariables`
|
|
403
|
-
const {
|
|
403
|
+
const { environmentVariables, ...rest } = props;
|
|
404
404
|
const response = await api.patch(`/projects/${this.output.id}`, rest);
|
|
405
405
|
const data = (await response.json()) as Project;
|
|
406
406
|
|
package/src/web/shadcn.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { StaticTypeScriptFile } from "../../fs/static-typescript-file.js";
|
|
|
10
10
|
import { Resource } from "../../resource.js";
|
|
11
11
|
import { InstallDependencies, fixedDependencies } from "./dependencies.js";
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const _execAsync = promisify(exec);
|
|
14
14
|
|
|
15
15
|
export interface VitePressProjectProps {
|
|
16
16
|
/**
|