alchemy-effect 0.0.0 → 0.2.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 +179 -0
- package/bin/alchemy-effect.js +15 -0
- package/bin/alchemy-effect.js.map +1 -0
- package/bin/alchemy-effect.ts +10 -0
- package/lib/app.d.ts +7 -2
- package/lib/app.d.ts.map +1 -1
- package/lib/app.js +1 -0
- package/lib/app.js.map +1 -1
- package/lib/apply.d.ts +57 -1
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +141 -55
- package/lib/apply.js.map +1 -1
- package/lib/aws/account.d.ts +18 -0
- package/lib/aws/account.d.ts.map +1 -0
- package/lib/aws/account.js +18 -0
- package/lib/aws/account.js.map +1 -0
- package/lib/aws/arn.d.ts +2 -0
- package/lib/aws/arn.d.ts.map +1 -0
- package/lib/aws/arn.js +1 -0
- package/lib/aws/arn.js.map +1 -0
- package/lib/aws/assets.d.ts +8 -0
- package/lib/aws/assets.d.ts.map +1 -0
- package/lib/aws/assets.js +4 -0
- package/lib/aws/assets.js.map +1 -0
- package/lib/aws/bundle.d.ts +4 -0
- package/lib/aws/bundle.d.ts.map +1 -0
- package/lib/aws/bundle.js +4 -0
- package/lib/aws/bundle.js.map +1 -0
- package/lib/aws/client.d.ts +8 -0
- package/lib/aws/client.d.ts.map +1 -0
- package/lib/aws/client.js +28 -0
- package/lib/aws/client.js.map +1 -0
- package/lib/aws/credentials.d.ts +146 -0
- package/lib/aws/credentials.d.ts.map +1 -0
- package/lib/aws/credentials.js +170 -0
- package/lib/aws/credentials.js.map +1 -0
- package/lib/aws/dynamodb/attribute-value.d.ts +20 -0
- package/lib/aws/dynamodb/attribute-value.d.ts.map +1 -0
- package/lib/aws/dynamodb/attribute-value.js +217 -0
- package/lib/aws/dynamodb/attribute-value.js.map +1 -0
- package/lib/aws/dynamodb/client.d.ts +12 -0
- package/lib/aws/dynamodb/client.d.ts.map +1 -0
- package/lib/aws/dynamodb/client.js +11 -0
- package/lib/aws/dynamodb/client.js.map +1 -0
- package/lib/aws/dynamodb/expr.d.ts +41 -0
- package/lib/aws/dynamodb/expr.d.ts.map +1 -0
- package/lib/aws/dynamodb/expr.js +1 -0
- package/lib/aws/dynamodb/expr.js.map +1 -0
- package/lib/aws/dynamodb/index.d.ts +9 -0
- package/lib/aws/dynamodb/index.d.ts.map +1 -0
- package/lib/aws/dynamodb/index.js +10 -0
- package/lib/aws/dynamodb/index.js.map +1 -0
- package/lib/aws/dynamodb/projection.d.ts +25 -0
- package/lib/aws/dynamodb/projection.d.ts.map +1 -0
- package/lib/aws/dynamodb/projection.js +1 -0
- package/lib/aws/dynamodb/projection.js.map +1 -0
- package/lib/aws/dynamodb/secondary-index.d.ts +25 -0
- package/lib/aws/dynamodb/secondary-index.d.ts.map +1 -0
- package/lib/aws/dynamodb/secondary-index.js +4 -0
- package/lib/aws/dynamodb/secondary-index.js.map +1 -0
- package/lib/aws/dynamodb/table.d.ts +56 -0
- package/lib/aws/dynamodb/table.d.ts.map +1 -0
- package/lib/aws/dynamodb/table.get-item.d.ts +55 -0
- package/lib/aws/dynamodb/table.get-item.d.ts.map +1 -0
- package/lib/aws/dynamodb/table.get-item.js +75 -0
- package/lib/aws/dynamodb/table.get-item.js.map +1 -0
- package/lib/aws/dynamodb/table.js +4 -0
- package/lib/aws/dynamodb/table.js.map +1 -0
- package/lib/aws/dynamodb/table.provider.d.ts +8 -0
- package/lib/aws/dynamodb/table.provider.d.ts.map +1 -0
- package/lib/aws/dynamodb/table.provider.js +199 -0
- package/lib/aws/dynamodb/table.provider.js.map +1 -0
- package/lib/aws/ec2/client.d.ts +12 -0
- package/lib/aws/ec2/client.d.ts.map +1 -0
- package/lib/aws/ec2/client.js +11 -0
- package/lib/aws/ec2/client.js.map +1 -0
- package/lib/aws/ec2/index.d.ts +4 -0
- package/lib/aws/ec2/index.d.ts.map +1 -0
- package/lib/aws/ec2/index.js +4 -0
- package/lib/aws/ec2/index.js.map +1 -0
- package/lib/aws/ec2/vpc.d.ts +131 -0
- package/lib/aws/ec2/vpc.d.ts.map +1 -0
- package/lib/aws/ec2/vpc.js +3 -0
- package/lib/aws/ec2/vpc.js.map +1 -0
- package/lib/aws/ec2/vpc.provider.d.ts +7 -0
- package/lib/aws/ec2/vpc.provider.d.ts.map +1 -0
- package/lib/aws/ec2/vpc.provider.js +198 -0
- package/lib/aws/ec2/vpc.provider.js.map +1 -0
- package/lib/aws/iam.d.ts +23 -0
- package/lib/aws/iam.d.ts.map +1 -0
- package/lib/aws/iam.js +7 -0
- package/lib/aws/iam.js.map +1 -0
- package/lib/aws/index.d.ts +32 -0
- package/lib/aws/index.d.ts.map +1 -0
- package/lib/aws/index.js +23 -0
- package/lib/aws/index.js.map +1 -0
- package/lib/aws/lambda/client.d.ts +8 -0
- package/lib/aws/lambda/client.d.ts.map +1 -0
- package/lib/aws/lambda/client.js +7 -0
- package/lib/aws/lambda/client.js.map +1 -0
- package/lib/aws/lambda/consume.d.ts +17 -0
- package/lib/aws/lambda/consume.d.ts.map +1 -0
- package/lib/aws/lambda/consume.js +30 -0
- package/lib/aws/lambda/consume.js.map +1 -0
- package/lib/aws/lambda/function.d.ts +41 -0
- package/lib/aws/lambda/function.d.ts.map +1 -0
- package/lib/aws/lambda/function.handler.d.ts +7 -0
- package/lib/aws/lambda/function.handler.d.ts.map +1 -0
- package/lib/aws/lambda/function.handler.js +8 -0
- package/lib/aws/lambda/function.handler.js.map +1 -0
- package/lib/aws/lambda/function.invoke.d.ts +10 -0
- package/lib/aws/lambda/function.invoke.d.ts.map +1 -0
- package/lib/aws/lambda/function.invoke.js +31 -0
- package/lib/aws/lambda/function.invoke.js.map +1 -0
- package/lib/aws/lambda/function.js +3 -0
- package/lib/aws/lambda/function.js.map +1 -0
- package/lib/aws/lambda/function.provider.d.ts +9 -0
- package/lib/aws/lambda/function.provider.d.ts.map +1 -0
- package/lib/aws/lambda/function.provider.js +465 -0
- package/lib/aws/lambda/function.provider.js.map +1 -0
- package/lib/aws/lambda/index.d.ts +8 -0
- package/lib/aws/lambda/index.d.ts.map +1 -0
- package/lib/aws/lambda/index.js +9 -0
- package/lib/aws/lambda/index.js.map +1 -0
- package/lib/aws/lambda/serve.d.ts +14 -0
- package/lib/aws/lambda/serve.d.ts.map +1 -0
- package/lib/aws/lambda/serve.js +7 -0
- package/lib/aws/lambda/serve.js.map +1 -0
- package/lib/aws/parse-ini.d.ts +4 -0
- package/lib/aws/parse-ini.d.ts.map +1 -0
- package/lib/aws/parse-ini.js +67 -0
- package/lib/aws/parse-ini.js.map +1 -0
- package/lib/aws/profile.d.ts +6 -0
- package/lib/aws/profile.d.ts.map +1 -0
- package/lib/aws/profile.js +4 -0
- package/lib/aws/profile.js.map +1 -0
- package/lib/aws/region.d.ts +19 -0
- package/lib/aws/region.d.ts.map +1 -0
- package/lib/aws/region.js +21 -0
- package/lib/aws/region.js.map +1 -0
- package/lib/aws/s3.d.ts +8 -0
- package/lib/aws/s3.d.ts.map +1 -0
- package/lib/aws/s3.js +7 -0
- package/lib/aws/s3.js.map +1 -0
- package/lib/aws/sqs/client.d.ts +12 -0
- package/lib/aws/sqs/client.d.ts.map +1 -0
- package/lib/aws/sqs/client.js +11 -0
- package/lib/aws/sqs/client.js.map +1 -0
- package/lib/aws/sqs/index.d.ts +7 -0
- package/lib/aws/sqs/index.d.ts.map +1 -0
- package/lib/aws/sqs/index.js +7 -0
- package/lib/aws/sqs/index.js.map +1 -0
- package/lib/aws/sqs/queue.consume.d.ts +12 -0
- package/lib/aws/sqs/queue.consume.d.ts.map +1 -0
- package/lib/aws/sqs/queue.consume.js +3 -0
- package/lib/aws/sqs/queue.consume.js.map +1 -0
- package/lib/aws/sqs/queue.d.ts +79 -0
- package/lib/aws/sqs/queue.d.ts.map +1 -0
- package/lib/aws/sqs/queue.event-source.d.ts +20 -0
- package/lib/aws/sqs/queue.event-source.d.ts.map +1 -0
- package/lib/aws/sqs/queue.event-source.js +148 -0
- package/lib/aws/sqs/queue.event-source.js.map +1 -0
- package/lib/aws/sqs/queue.js +3 -0
- package/lib/aws/sqs/queue.js.map +1 -0
- package/lib/aws/sqs/queue.provider.d.ts +7 -0
- package/lib/aws/sqs/queue.provider.d.ts.map +1 -0
- package/lib/aws/sqs/queue.provider.js +79 -0
- package/lib/aws/sqs/queue.provider.js.map +1 -0
- package/lib/aws/sqs/queue.send-message.d.ts +11 -0
- package/lib/aws/sqs/queue.send-message.d.ts.map +1 -0
- package/lib/aws/sqs/queue.send-message.js +32 -0
- package/lib/aws/sqs/queue.send-message.js.map +1 -0
- package/lib/aws/sts.d.ts +8 -0
- package/lib/aws/sts.d.ts.map +1 -0
- package/lib/aws/sts.js +7 -0
- package/lib/aws/sts.js.map +1 -0
- package/lib/aws/zip.d.ts +3 -0
- package/lib/aws/zip.d.ts.map +1 -0
- package/lib/aws/zip.js +12 -0
- package/lib/aws/zip.js.map +1 -0
- package/lib/binding.d.ts +70 -22
- package/lib/binding.d.ts.map +1 -1
- package/lib/binding.js.map +1 -1
- package/lib/capability.d.ts +38 -0
- package/lib/capability.d.ts.map +1 -1
- package/lib/cli/approve.d.ts +4 -0
- package/lib/cli/approve.d.ts.map +1 -0
- package/lib/cli/approve.js +18 -0
- package/lib/cli/approve.js.map +1 -0
- package/lib/cli/clack.d.ts +14 -0
- package/lib/cli/clack.d.ts.map +1 -0
- package/lib/cli/clack.js +12 -0
- package/lib/cli/clack.js.map +1 -0
- package/lib/cli/components/ApprovePlan.d.ts +8 -0
- package/lib/cli/components/ApprovePlan.d.ts.map +1 -0
- package/lib/cli/components/ApprovePlan.js +30 -0
- package/lib/cli/components/ApprovePlan.js.map +1 -0
- package/lib/cli/components/Plan.d.ts +7 -0
- package/lib/cli/components/Plan.d.ts.map +1 -0
- package/lib/cli/components/Plan.js +100 -0
- package/lib/cli/components/Plan.js.map +1 -0
- package/lib/cli/components/PlanProgress.d.ts +9 -0
- package/lib/cli/components/PlanProgress.d.ts.map +1 -0
- package/lib/cli/components/PlanProgress.js +166 -0
- package/lib/cli/components/PlanProgress.js.map +1 -0
- package/lib/cli/index.d.ts +449 -0
- package/lib/cli/index.d.ts.map +1 -0
- package/lib/cli/index.js +39912 -0
- package/lib/cli/index.js.map +1 -0
- package/lib/cli/main.d.ts +2 -0
- package/lib/cli/main.d.ts.map +1 -0
- package/lib/cli/main.js +1 -0
- package/lib/cli/main.js.map +1 -0
- package/lib/cli/plan.d.ts +13 -0
- package/lib/cli/plan.d.ts.map +1 -0
- package/lib/cli/plan.js +1 -0
- package/lib/cli/plan.js.map +1 -0
- package/lib/cli/progress.d.ts +7 -0
- package/lib/cli/progress.d.ts.map +1 -0
- package/lib/cli/progress.js +30 -0
- package/lib/cli/progress.js.map +1 -0
- package/lib/cli/spinner.d.ts +2 -0
- package/lib/cli/spinner.d.ts.map +1 -0
- package/lib/cli/spinner.js +13 -0
- package/lib/cli/spinner.js.map +1 -0
- package/lib/cloudflare/api.d.ts +36 -0
- package/lib/cloudflare/api.d.ts.map +1 -0
- package/lib/cloudflare/api.js +99 -0
- package/lib/cloudflare/api.js.map +1 -0
- package/lib/cloudflare/context.d.ts +27 -0
- package/lib/cloudflare/context.d.ts.map +1 -0
- package/lib/cloudflare/context.js +24 -0
- package/lib/cloudflare/context.js.map +1 -0
- package/lib/cloudflare/index.d.ts +6 -0
- package/lib/cloudflare/index.d.ts.map +1 -0
- package/lib/cloudflare/index.js +5 -0
- package/lib/cloudflare/index.js.map +1 -0
- package/lib/cloudflare/kv/index.d.ts +4 -0
- package/lib/cloudflare/kv/index.d.ts.map +1 -0
- package/lib/cloudflare/kv/index.js +4 -0
- package/lib/cloudflare/kv/index.js.map +1 -0
- package/lib/cloudflare/kv/namespace.binding.d.ts +8 -0
- package/lib/cloudflare/kv/namespace.binding.d.ts.map +1 -0
- package/lib/cloudflare/kv/namespace.binding.js +15 -0
- package/lib/cloudflare/kv/namespace.binding.js.map +1 -0
- package/lib/cloudflare/kv/namespace.client.d.ts +11 -0
- package/lib/cloudflare/kv/namespace.client.d.ts.map +1 -0
- package/lib/cloudflare/kv/namespace.client.js +31 -0
- package/lib/cloudflare/kv/namespace.client.js.map +1 -0
- package/lib/cloudflare/kv/namespace.d.ts +23 -0
- package/lib/cloudflare/kv/namespace.d.ts.map +1 -0
- package/lib/cloudflare/kv/namespace.js +3 -0
- package/lib/cloudflare/kv/namespace.js.map +1 -0
- package/lib/cloudflare/kv/namespace.provider.d.ts +5 -0
- package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -0
- package/lib/cloudflare/kv/namespace.provider.js +80 -0
- package/lib/cloudflare/kv/namespace.provider.js.map +1 -0
- package/lib/cloudflare/live.d.ts +11 -0
- package/lib/cloudflare/live.d.ts.map +1 -0
- package/lib/cloudflare/live.js +18 -0
- package/lib/cloudflare/live.js.map +1 -0
- package/lib/cloudflare/r2/bucket.binding.d.ts +8 -0
- package/lib/cloudflare/r2/bucket.binding.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.binding.js +18 -0
- package/lib/cloudflare/r2/bucket.binding.js.map +1 -0
- package/lib/cloudflare/r2/bucket.client.d.ts +8 -0
- package/lib/cloudflare/r2/bucket.client.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.client.js +9 -0
- package/lib/cloudflare/r2/bucket.client.js.map +1 -0
- package/lib/cloudflare/r2/bucket.d.ts +32 -0
- package/lib/cloudflare/r2/bucket.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.del.d.ts +4 -0
- package/lib/cloudflare/r2/bucket.del.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.del.js +7 -0
- package/lib/cloudflare/r2/bucket.del.js.map +1 -0
- package/lib/cloudflare/r2/bucket.get.d.ts +5 -0
- package/lib/cloudflare/r2/bucket.get.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.get.js +7 -0
- package/lib/cloudflare/r2/bucket.get.js.map +1 -0
- package/lib/cloudflare/r2/bucket.head.d.ts +4 -0
- package/lib/cloudflare/r2/bucket.head.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.head.js +7 -0
- package/lib/cloudflare/r2/bucket.head.js.map +1 -0
- package/lib/cloudflare/r2/bucket.js +3 -0
- package/lib/cloudflare/r2/bucket.js.map +1 -0
- package/lib/cloudflare/r2/bucket.list.d.ts +5 -0
- package/lib/cloudflare/r2/bucket.list.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.list.js +7 -0
- package/lib/cloudflare/r2/bucket.list.js.map +1 -0
- package/lib/cloudflare/r2/bucket.multipart.d.ts +19 -0
- package/lib/cloudflare/r2/bucket.multipart.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.multipart.js +25 -0
- package/lib/cloudflare/r2/bucket.multipart.js.map +1 -0
- package/lib/cloudflare/r2/bucket.provider.d.ts +5 -0
- package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.provider.js +66 -0
- package/lib/cloudflare/r2/bucket.provider.js.map +1 -0
- package/lib/cloudflare/r2/bucket.put.d.ts +6 -0
- package/lib/cloudflare/r2/bucket.put.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.put.js +8 -0
- package/lib/cloudflare/r2/bucket.put.js.map +1 -0
- package/lib/cloudflare/r2/index.d.ts +10 -0
- package/lib/cloudflare/r2/index.d.ts.map +1 -0
- package/lib/cloudflare/r2/index.js +10 -0
- package/lib/cloudflare/r2/index.js.map +1 -0
- package/lib/cloudflare/stream.d.ts +10 -0
- package/lib/cloudflare/stream.d.ts.map +1 -0
- package/lib/cloudflare/stream.js +16 -0
- package/lib/cloudflare/stream.js.map +1 -0
- package/lib/cloudflare/worker/assets.fetch.d.ts +8 -0
- package/lib/cloudflare/worker/assets.fetch.d.ts.map +1 -0
- package/lib/cloudflare/worker/assets.fetch.js +11 -0
- package/lib/cloudflare/worker/assets.fetch.js.map +1 -0
- package/lib/cloudflare/worker/assets.provider.d.ts +66 -0
- package/lib/cloudflare/worker/assets.provider.d.ts.map +1 -0
- package/lib/cloudflare/worker/assets.provider.js +145 -0
- package/lib/cloudflare/worker/assets.provider.js.map +1 -0
- package/lib/cloudflare/worker/index.d.ts +6 -0
- package/lib/cloudflare/worker/index.d.ts.map +1 -0
- package/lib/cloudflare/worker/index.js +5 -0
- package/lib/cloudflare/worker/index.js.map +1 -0
- package/lib/cloudflare/worker/worker.d.ts +67 -0
- package/lib/cloudflare/worker/worker.d.ts.map +1 -0
- package/lib/cloudflare/worker/worker.handler.d.ts +11 -0
- package/lib/cloudflare/worker/worker.handler.d.ts.map +1 -0
- package/lib/cloudflare/worker/worker.handler.js +15 -0
- package/lib/cloudflare/worker/worker.handler.js.map +1 -0
- package/lib/cloudflare/worker/worker.js +4 -0
- package/lib/cloudflare/worker/worker.js.map +1 -0
- package/lib/cloudflare/worker/worker.provider.d.ts +10 -0
- package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -0
- package/lib/cloudflare/worker/worker.provider.js +193 -0
- package/lib/cloudflare/worker/worker.provider.js.map +1 -0
- package/lib/cloudflare/worker/worker.serve.d.ts +39 -0
- package/lib/cloudflare/worker/worker.serve.d.ts.map +1 -0
- package/lib/cloudflare/worker/worker.serve.js +4 -0
- package/lib/cloudflare/worker/worker.serve.js.map +1 -0
- package/lib/destroy.d.ts +1 -3
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js +5 -0
- package/lib/destroy.js.map +1 -1
- package/lib/dot-alchemy.d.ts +3 -2
- package/lib/dot-alchemy.d.ts.map +1 -1
- package/lib/dot-alchemy.js +3 -2
- package/lib/dot-alchemy.js.map +1 -1
- package/lib/esbuild.d.ts +28 -0
- package/lib/esbuild.d.ts.map +1 -0
- package/lib/esbuild.js +63 -0
- package/lib/esbuild.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/plan.d.ts +19 -8
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +144 -72
- package/lib/plan.js.map +1 -1
- package/lib/policy.d.ts +19 -1
- package/lib/policy.d.ts.map +1 -1
- package/lib/policy.js +10 -1
- package/lib/policy.js.map +1 -1
- package/lib/provider.d.ts +2 -2
- package/lib/provider.d.ts.map +1 -1
- package/lib/resource.d.ts +2 -10
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js +1 -0
- package/lib/resource.js.map +1 -1
- package/lib/runtime.d.ts +1 -1
- package/lib/runtime.d.ts.map +1 -1
- package/lib/schema.d.ts +37 -0
- package/lib/schema.d.ts.map +1 -0
- package/lib/schema.js +61 -0
- package/lib/schema.js.map +1 -0
- package/lib/sha256.d.ts +5 -0
- package/lib/sha256.d.ts.map +1 -0
- package/lib/sha256.js +16 -0
- package/lib/sha256.js.map +1 -0
- package/lib/state.d.ts +3 -2
- package/lib/state.d.ts.map +1 -1
- package/lib/state.js +3 -2
- package/lib/state.js.map +1 -1
- package/lib/tags.d.ts +17 -0
- package/lib/tags.d.ts.map +1 -0
- package/lib/tags.js +22 -0
- package/lib/tags.js.map +1 -0
- package/lib/test.d.ts +14 -0
- package/lib/test.d.ts.map +1 -0
- package/lib/test.js +28 -0
- package/lib/test.js.map +1 -0
- package/lib/tsconfig.test.tsbuildinfo +1 -0
- package/lib/type.d.ts +3 -0
- package/lib/type.d.ts.map +1 -0
- package/lib/type.js +3 -0
- package/lib/type.js.map +1 -0
- package/package.json +115 -3
- package/src/app.ts +8 -7
- package/src/apply.ts +251 -93
- package/src/aws/account.ts +37 -0
- package/src/aws/arn.ts +1 -0
- package/src/aws/assets.ts +8 -0
- package/src/aws/bundle.ts +5 -0
- package/src/aws/client.ts +47 -0
- package/src/aws/credentials.ts +409 -0
- package/src/aws/dynamodb/attribute-value.ts +240 -0
- package/src/aws/dynamodb/client.ts +20 -0
- package/src/aws/dynamodb/expr.ts +90 -0
- package/src/aws/dynamodb/index.ts +12 -0
- package/src/aws/dynamodb/projection.ts +159 -0
- package/src/aws/dynamodb/secondary-index.ts +45 -0
- package/src/aws/dynamodb/table.get-item.ts +177 -0
- package/src/aws/dynamodb/table.provider.ts +280 -0
- package/src/aws/dynamodb/table.ts +156 -0
- package/src/aws/ec2/client.ts +20 -0
- package/src/aws/ec2/index.ts +3 -0
- package/src/aws/ec2/vpc.provider.ts +285 -0
- package/src/aws/ec2/vpc.ts +152 -0
- package/src/aws/iam.ts +30 -0
- package/src/aws/index.ts +54 -0
- package/src/aws/lambda/client.ts +14 -0
- package/src/aws/lambda/consume.ts +63 -0
- package/src/aws/lambda/function.handler.ts +30 -0
- package/src/aws/lambda/function.invoke.ts +40 -0
- package/src/aws/lambda/function.provider.ts +655 -0
- package/src/aws/lambda/function.ts +45 -0
- package/src/aws/lambda/index.ts +9 -0
- package/src/aws/lambda/serve.ts +29 -0
- package/src/aws/parse-ini.ts +80 -0
- package/src/aws/profile.ts +6 -0
- package/src/aws/region.ts +37 -0
- package/src/aws/s3.ts +10 -0
- package/src/aws/sqs/client.ts +20 -0
- package/src/aws/sqs/index.ts +6 -0
- package/src/aws/sqs/queue.consume.ts +13 -0
- package/src/aws/sqs/queue.event-source.ts +253 -0
- package/src/aws/sqs/queue.provider.ts +94 -0
- package/src/aws/sqs/queue.send-message.ts +51 -0
- package/src/aws/sqs/queue.ts +86 -0
- package/src/aws/sts.ts +13 -0
- package/src/aws/zip.ts +17 -0
- package/src/binding.ts +121 -25
- package/src/capability.ts +44 -0
- package/src/cli/approve.tsx +30 -0
- package/src/cli/clack.ts +22 -0
- package/src/cli/components/ApprovePlan.tsx +44 -0
- package/src/cli/components/Plan.tsx +154 -0
- package/src/cli/components/PlanProgress.tsx +206 -0
- package/src/cli/index.ts +6 -0
- package/src/cli/main.ts +0 -0
- package/src/cli/plan.ts +16 -0
- package/src/cli/progress.tsx +46 -0
- package/src/cli/spinner.ts +14 -0
- package/src/cloudflare/api.ts +152 -0
- package/src/cloudflare/context.ts +49 -0
- package/src/cloudflare/index.ts +6 -0
- package/src/cloudflare/kv/index.ts +3 -0
- package/src/cloudflare/kv/namespace.binding.ts +25 -0
- package/src/cloudflare/kv/namespace.client.ts +70 -0
- package/src/cloudflare/kv/namespace.provider.ts +99 -0
- package/src/cloudflare/kv/namespace.ts +29 -0
- package/src/cloudflare/live.ts +38 -0
- package/src/cloudflare/r2/bucket.binding.ts +27 -0
- package/src/cloudflare/r2/bucket.client.ts +22 -0
- package/src/cloudflare/r2/bucket.del.ts +11 -0
- package/src/cloudflare/r2/bucket.get.ts +13 -0
- package/src/cloudflare/r2/bucket.head.ts +11 -0
- package/src/cloudflare/r2/bucket.list.ts +12 -0
- package/src/cloudflare/r2/bucket.multipart.ts +55 -0
- package/src/cloudflare/r2/bucket.provider.ts +83 -0
- package/src/cloudflare/r2/bucket.put.ts +17 -0
- package/src/cloudflare/r2/bucket.ts +38 -0
- package/src/cloudflare/r2/index.ts +9 -0
- package/src/cloudflare/stream.ts +21 -0
- package/src/cloudflare/worker/assets.fetch.ts +27 -0
- package/src/cloudflare/worker/assets.provider.ts +249 -0
- package/src/cloudflare/worker/index.ts +6 -0
- package/src/cloudflare/worker/worker.handler.ts +39 -0
- package/src/cloudflare/worker/worker.provider.ts +246 -0
- package/src/cloudflare/worker/worker.serve.ts +19 -0
- package/src/cloudflare/worker/worker.ts +76 -0
- package/src/destroy.ts +6 -3
- package/src/dot-alchemy.ts +3 -2
- package/src/esbuild.ts +98 -0
- package/src/index.ts +5 -0
- package/src/plan.ts +233 -120
- package/src/policy.ts +55 -2
- package/src/provider.ts +2 -2
- package/src/resource.ts +3 -2
- package/src/runtime.ts +1 -1
- package/src/schema.ts +102 -0
- package/src/sha256.ts +23 -0
- package/src/state.ts +3 -2
- package/src/tags.ts +38 -0
- package/src/test.ts +71 -0
- package/src/type.ts +2 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// biome-ignore lint/style/useImportType: UMD global
|
|
2
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import type * as Alchemy from "alchemy-effect";
|
|
5
|
+
import { Box, Text } from "ink";
|
|
6
|
+
import type { ProgressEventSource } from "../progress.tsx";
|
|
7
|
+
import { useGlobalSpinner } from "../spinner.ts";
|
|
8
|
+
|
|
9
|
+
interface PlanTask
|
|
10
|
+
extends Required<Pick<Alchemy.StatusChangeEvent, "id" | "type" | "status">> {
|
|
11
|
+
message?: string;
|
|
12
|
+
updatedAt: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface PlanProgressProps {
|
|
16
|
+
source: ProgressEventSource;
|
|
17
|
+
plan: Alchemy.Plan;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function PlanProgress(props: PlanProgressProps): React.JSX.Element {
|
|
21
|
+
const { source, plan } = props;
|
|
22
|
+
const spinner = useGlobalSpinner();
|
|
23
|
+
const [tasks, setTasks] = useState<Map<string, PlanTask>>(() => {
|
|
24
|
+
// Initialize tasks from the plan with appropriate starting status
|
|
25
|
+
const initialTasks = new Map<string, PlanTask>();
|
|
26
|
+
const nodes = [
|
|
27
|
+
...Object.entries(plan.resources),
|
|
28
|
+
...Object.entries(plan.deletions),
|
|
29
|
+
];
|
|
30
|
+
for (const [id, item] of nodes) {
|
|
31
|
+
const planItem = item!;
|
|
32
|
+
const status: Alchemy.ApplyStatus =
|
|
33
|
+
planItem.action === "noop" ? "success" : "pending";
|
|
34
|
+
initialTasks.set(id, {
|
|
35
|
+
id,
|
|
36
|
+
type: planItem.resource.type,
|
|
37
|
+
status,
|
|
38
|
+
updatedAt: Date.now(),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return initialTasks;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const unsubscribeRef = useRef<null | (() => void)>(null);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
unsubscribeRef.current?.();
|
|
48
|
+
unsubscribeRef.current = source.subscribe((event) => {
|
|
49
|
+
setTasks((prev) => {
|
|
50
|
+
const next = new Map(prev);
|
|
51
|
+
const current = next.get(event.id);
|
|
52
|
+
|
|
53
|
+
if (event.kind === "status-change") {
|
|
54
|
+
if (!event.bindingId) {
|
|
55
|
+
// Only handle resource-level events, ignore binding events
|
|
56
|
+
const updated: PlanTask = {
|
|
57
|
+
id: event.id,
|
|
58
|
+
type: event.type,
|
|
59
|
+
status: event.status,
|
|
60
|
+
message: event.message ?? current?.message,
|
|
61
|
+
updatedAt: Date.now(),
|
|
62
|
+
};
|
|
63
|
+
next.set(event.id, updated);
|
|
64
|
+
}
|
|
65
|
+
} else if (event.kind === "annotate" && current) {
|
|
66
|
+
next.set(event.id, {
|
|
67
|
+
...current,
|
|
68
|
+
message: event.message,
|
|
69
|
+
updatedAt: Date.now(),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return next;
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
return () => {
|
|
77
|
+
unsubscribeRef.current?.();
|
|
78
|
+
unsubscribeRef.current = null;
|
|
79
|
+
};
|
|
80
|
+
}, [source]);
|
|
81
|
+
|
|
82
|
+
// Reinitialize tasks when plan changes
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
setTasks(() => {
|
|
85
|
+
const initialTasks = new Map<string, PlanTask>();
|
|
86
|
+
const nodes = [
|
|
87
|
+
...Object.entries(plan.resources),
|
|
88
|
+
...Object.entries(plan.deletions),
|
|
89
|
+
];
|
|
90
|
+
for (const [id, item] of nodes) {
|
|
91
|
+
const planItem = item!;
|
|
92
|
+
const status: Alchemy.ApplyStatus =
|
|
93
|
+
planItem.action === "noop" ? "success" : "pending";
|
|
94
|
+
initialTasks.set(id, {
|
|
95
|
+
id,
|
|
96
|
+
type: planItem.resource.type,
|
|
97
|
+
status,
|
|
98
|
+
updatedAt: Date.now(),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return initialTasks;
|
|
102
|
+
});
|
|
103
|
+
}, [plan]);
|
|
104
|
+
|
|
105
|
+
const rows = useMemo(
|
|
106
|
+
() =>
|
|
107
|
+
Array.from(tasks.values()).sort((a, b) => {
|
|
108
|
+
// First sort by status priority
|
|
109
|
+
const priorityDiff =
|
|
110
|
+
statusPriority(a.status) - statusPriority(b.status);
|
|
111
|
+
if (priorityDiff !== 0) return priorityDiff;
|
|
112
|
+
|
|
113
|
+
// Then sort by ID for consistent ordering within same priority
|
|
114
|
+
return a.id.localeCompare(b.id);
|
|
115
|
+
}),
|
|
116
|
+
[tasks],
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<Box flexDirection="column">
|
|
121
|
+
{rows.map((task) => {
|
|
122
|
+
const color = statusColor(task.status);
|
|
123
|
+
const icon = statusIcon(task.status, spinner);
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<Box key={task.id} flexDirection="row">
|
|
127
|
+
<Box width={2}>
|
|
128
|
+
<Text color={color}>{icon} </Text>
|
|
129
|
+
</Box>
|
|
130
|
+
<Box width={12}>
|
|
131
|
+
<Text bold>{task.id}</Text>
|
|
132
|
+
</Box>
|
|
133
|
+
<Box width={25}>
|
|
134
|
+
<Text dimColor>({task.type})</Text>
|
|
135
|
+
</Box>
|
|
136
|
+
<Box width={12}>
|
|
137
|
+
<Text color={color}>{task.status}</Text>
|
|
138
|
+
</Box>
|
|
139
|
+
<Box>
|
|
140
|
+
{task.message ? <Text dimColor>• {task.message}</Text> : null}
|
|
141
|
+
</Box>
|
|
142
|
+
</Box>
|
|
143
|
+
);
|
|
144
|
+
})}
|
|
145
|
+
</Box>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function statusPriority(status: Alchemy.ApplyStatus): number {
|
|
150
|
+
switch (status) {
|
|
151
|
+
case "success":
|
|
152
|
+
case "created":
|
|
153
|
+
case "updated":
|
|
154
|
+
case "deleted":
|
|
155
|
+
return 0; // highest priority (success)
|
|
156
|
+
case "fail":
|
|
157
|
+
return 1;
|
|
158
|
+
case "creating":
|
|
159
|
+
case "updating":
|
|
160
|
+
case "deleting":
|
|
161
|
+
return 2; // in progress
|
|
162
|
+
case "pending":
|
|
163
|
+
return 3; // lowest priority (pending)
|
|
164
|
+
default:
|
|
165
|
+
return 4;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function statusColor(
|
|
170
|
+
status: Alchemy.ApplyStatus,
|
|
171
|
+
): Parameters<typeof Text>[0]["color"] {
|
|
172
|
+
switch (status) {
|
|
173
|
+
case "pending":
|
|
174
|
+
return "gray";
|
|
175
|
+
case "creating":
|
|
176
|
+
case "created":
|
|
177
|
+
return "green";
|
|
178
|
+
case "updating":
|
|
179
|
+
case "updated":
|
|
180
|
+
return "yellow";
|
|
181
|
+
case "deleting":
|
|
182
|
+
case "deleted":
|
|
183
|
+
return "red";
|
|
184
|
+
case "success":
|
|
185
|
+
return "green";
|
|
186
|
+
case "fail":
|
|
187
|
+
return "redBright";
|
|
188
|
+
default:
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function statusIcon(status: Alchemy.ApplyStatus, spinnerChar: string): string {
|
|
194
|
+
if (isInProgress(status)) return spinnerChar;
|
|
195
|
+
if (status === "fail") return "✗";
|
|
196
|
+
return "✓"; // created/updated/deleted/success
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function isInProgress(status: Alchemy.ApplyStatus): boolean {
|
|
200
|
+
return (
|
|
201
|
+
status === "pending" ||
|
|
202
|
+
status === "creating" ||
|
|
203
|
+
status === "updating" ||
|
|
204
|
+
status === "deleting"
|
|
205
|
+
);
|
|
206
|
+
}
|
package/src/cli/index.ts
ADDED
package/src/cli/main.ts
ADDED
|
File without changes
|
package/src/cli/plan.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type PlanAction = "create" | "update" | "delete" | "noop";
|
|
2
|
+
|
|
3
|
+
export interface PlanBinding {
|
|
4
|
+
// Single label including target, eg: "Lambda.InvokeFunction(api)"
|
|
5
|
+
id: string;
|
|
6
|
+
action: PlanAction;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PlanItem {
|
|
10
|
+
id: string;
|
|
11
|
+
type: string;
|
|
12
|
+
action: PlanAction;
|
|
13
|
+
bindings?: PlanBinding[]; // optional bindings
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type PlanSummary = Map<string, PlanItem>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// biome-ignore lint/correctness/noUnusedImports: UMD global
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
import { render } from "ink";
|
|
5
|
+
|
|
6
|
+
import * as Alchemy from "alchemy-effect";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Layer from "effect/Layer";
|
|
9
|
+
|
|
10
|
+
import { PlanProgress } from "./components/PlanProgress.tsx";
|
|
11
|
+
|
|
12
|
+
export interface ProgressEventSource {
|
|
13
|
+
subscribe(listener: (event: Alchemy.ApplyEvent) => void): () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const reportProgress = Layer.succeed(
|
|
17
|
+
Alchemy.PlanStatusReporter,
|
|
18
|
+
Alchemy.PlanStatusReporter.of({
|
|
19
|
+
// oxlint-disable-next-line require-yield
|
|
20
|
+
start: Effect.fn(function* (plan) {
|
|
21
|
+
const listeners = new Set<(event: Alchemy.ApplyEvent) => void>();
|
|
22
|
+
const { unmount } = render(
|
|
23
|
+
<PlanProgress
|
|
24
|
+
plan={plan}
|
|
25
|
+
source={{
|
|
26
|
+
subscribe(listener) {
|
|
27
|
+
listeners.add(listener);
|
|
28
|
+
return () => listeners.delete(listener);
|
|
29
|
+
},
|
|
30
|
+
}}
|
|
31
|
+
/>,
|
|
32
|
+
);
|
|
33
|
+
return {
|
|
34
|
+
done: () =>
|
|
35
|
+
Effect.gen(function* () {
|
|
36
|
+
yield* Effect.sleep(10); // give the react event loop time to re-render
|
|
37
|
+
yield* Effect.sync(() => unmount());
|
|
38
|
+
}),
|
|
39
|
+
emit: (event) =>
|
|
40
|
+
Effect.sync(() => {
|
|
41
|
+
for (const listener of listeners) listener(event);
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
44
|
+
}),
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
const spinnerFrames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
4
|
+
|
|
5
|
+
export function useGlobalSpinner(intervalMs = 80): string {
|
|
6
|
+
const [index, setIndex] = useState(0);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const timer = setInterval(() => {
|
|
9
|
+
setIndex((i) => (i + 1) % spinnerFrames.length);
|
|
10
|
+
}, intervalMs);
|
|
11
|
+
return () => clearInterval(timer);
|
|
12
|
+
}, [intervalMs]);
|
|
13
|
+
return spinnerFrames[index];
|
|
14
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { APIConnectionError, Cloudflare, type APIError } from "cloudflare";
|
|
2
|
+
import {
|
|
3
|
+
isRequestOptions,
|
|
4
|
+
type APIPromise,
|
|
5
|
+
type RequestOptions,
|
|
6
|
+
} from "cloudflare/core";
|
|
7
|
+
import type { ErrorData } from "cloudflare/resources";
|
|
8
|
+
import { Layer } from "effect";
|
|
9
|
+
import * as Context from "effect/Context";
|
|
10
|
+
import * as Data from "effect/Data";
|
|
11
|
+
import * as Effect from "effect/Effect";
|
|
12
|
+
|
|
13
|
+
export class CloudflareAccountId extends Context.Tag("cloudflare/account-id")<
|
|
14
|
+
CloudflareAccountId,
|
|
15
|
+
string
|
|
16
|
+
>() {
|
|
17
|
+
static readonly fromEnv = Layer.effect(
|
|
18
|
+
CloudflareAccountId,
|
|
19
|
+
Effect.gen(function* () {
|
|
20
|
+
const accountId = process.env.CLOUDFLARE_ACCOUNT_ID;
|
|
21
|
+
if (!accountId) {
|
|
22
|
+
return yield* Effect.die("CLOUDFLARE_ACCOUNT_ID is not set");
|
|
23
|
+
}
|
|
24
|
+
return accountId;
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class CloudflareApi extends Effect.Service<CloudflareApi>()(
|
|
30
|
+
"cloudflare/api",
|
|
31
|
+
{
|
|
32
|
+
effect: (options?: {
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
apiToken?: string;
|
|
35
|
+
apiKey?: string;
|
|
36
|
+
apiEmail?: string;
|
|
37
|
+
}) =>
|
|
38
|
+
Effect.succeed(
|
|
39
|
+
createRecursiveProxy(
|
|
40
|
+
new Cloudflare({
|
|
41
|
+
baseURL: options?.baseUrl ?? import.meta.env.CLOUDFLARE_BASE_URL,
|
|
42
|
+
apiToken: options?.apiToken ?? import.meta.env.CLOUDFLARE_API_TOKEN,
|
|
43
|
+
apiKey: options?.apiKey ?? import.meta.env.CLOUDFLARE_API_KEY,
|
|
44
|
+
apiEmail: options?.apiEmail ?? import.meta.env.CLOUDFLARE_API_EMAIL,
|
|
45
|
+
}),
|
|
46
|
+
),
|
|
47
|
+
),
|
|
48
|
+
},
|
|
49
|
+
) {}
|
|
50
|
+
|
|
51
|
+
export class CloudflareApiError extends Data.Error<{
|
|
52
|
+
_tag:
|
|
53
|
+
| "Connection"
|
|
54
|
+
| "BadRequest"
|
|
55
|
+
| "Authentication"
|
|
56
|
+
| "PermissionDenied"
|
|
57
|
+
| "NotFound"
|
|
58
|
+
| "Conflict"
|
|
59
|
+
| "UnprocessableEntity"
|
|
60
|
+
| "RateLimit"
|
|
61
|
+
| "InternalServerError"
|
|
62
|
+
| "Unknown";
|
|
63
|
+
message: string;
|
|
64
|
+
errors: ErrorData[];
|
|
65
|
+
cause: APIError;
|
|
66
|
+
}> {
|
|
67
|
+
static from(cause: APIError): CloudflareApiError {
|
|
68
|
+
const error = new CloudflareApiError({
|
|
69
|
+
_tag: CloudflareApiError.getTag(cause),
|
|
70
|
+
message: cause.message,
|
|
71
|
+
errors: cause.errors,
|
|
72
|
+
cause: cause,
|
|
73
|
+
});
|
|
74
|
+
return error;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private static getTag(error: APIError): CloudflareApiError["_tag"] {
|
|
78
|
+
if (error instanceof APIConnectionError) {
|
|
79
|
+
return "Connection";
|
|
80
|
+
}
|
|
81
|
+
switch (error.status) {
|
|
82
|
+
case 400:
|
|
83
|
+
return "BadRequest";
|
|
84
|
+
case 401:
|
|
85
|
+
return "Authentication";
|
|
86
|
+
case 403:
|
|
87
|
+
return "PermissionDenied";
|
|
88
|
+
case 404:
|
|
89
|
+
return "NotFound";
|
|
90
|
+
case 409:
|
|
91
|
+
return "Conflict";
|
|
92
|
+
case 422:
|
|
93
|
+
return "UnprocessableEntity";
|
|
94
|
+
case 429:
|
|
95
|
+
return "RateLimit";
|
|
96
|
+
case 500:
|
|
97
|
+
return "InternalServerError";
|
|
98
|
+
default:
|
|
99
|
+
return "Unknown";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type ToEffect<T> = {
|
|
105
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any
|
|
106
|
+
? (
|
|
107
|
+
...args: Parameters<T[K]>
|
|
108
|
+
) => Effect.Effect<UnwrapAPIPromise<ReturnType<T[K]>>, CloudflareApiError>
|
|
109
|
+
: T[K] extends Record<string, any>
|
|
110
|
+
? ToEffect<T[K]>
|
|
111
|
+
: T[K];
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
type UnwrapAPIPromise<T> = T extends APIPromise<infer U> ? U : never;
|
|
115
|
+
|
|
116
|
+
const createRecursiveProxy = <T extends object>(target: T): ToEffect<T> => {
|
|
117
|
+
return new Proxy(target as any, {
|
|
118
|
+
get(target, prop, receiver) {
|
|
119
|
+
const value = Reflect.get(target, prop, receiver);
|
|
120
|
+
if (typeof value === "function") {
|
|
121
|
+
return Effect.fnUntraced(function* (...args: any[]) {
|
|
122
|
+
return yield* Effect.tryPromise({
|
|
123
|
+
try: async (signal) => {
|
|
124
|
+
let modifiedArgs: any[];
|
|
125
|
+
if (isRequestOptions(args[args.length - 1])) {
|
|
126
|
+
const options = args[args.length - 1] as RequestOptions;
|
|
127
|
+
modifiedArgs = [
|
|
128
|
+
...args.slice(0, -1),
|
|
129
|
+
{
|
|
130
|
+
...options,
|
|
131
|
+
signal: options?.signal
|
|
132
|
+
? AbortSignal.any([signal, options.signal])
|
|
133
|
+
: signal,
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
} else {
|
|
137
|
+
modifiedArgs = [...args, { signal }];
|
|
138
|
+
}
|
|
139
|
+
const result = await value.apply(target, modifiedArgs);
|
|
140
|
+
return result;
|
|
141
|
+
},
|
|
142
|
+
catch: (cause) => {
|
|
143
|
+
const error = CloudflareApiError.from(cause as APIError);
|
|
144
|
+
return error;
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return createRecursiveProxy(value);
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ExecutionContext } from "@cloudflare/workers-types";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Data from "effect/Data";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
|
|
6
|
+
export class CloudflareContext extends Context.Tag("Cloudflare.Context")<
|
|
7
|
+
CloudflareContext,
|
|
8
|
+
{
|
|
9
|
+
env: unknown;
|
|
10
|
+
ctx: ExecutionContext;
|
|
11
|
+
}
|
|
12
|
+
>() {}
|
|
13
|
+
|
|
14
|
+
export const getCloudflareEnvKey = Effect.fnUntraced(function* <T>(
|
|
15
|
+
key: string,
|
|
16
|
+
) {
|
|
17
|
+
return yield* Effect.serviceOptional(CloudflareContext).pipe(
|
|
18
|
+
Effect.mapError(
|
|
19
|
+
() =>
|
|
20
|
+
new CloudflareContextNotFound({
|
|
21
|
+
message: "Cloudflare context not found",
|
|
22
|
+
}),
|
|
23
|
+
),
|
|
24
|
+
Effect.flatMap((context) => {
|
|
25
|
+
const env = context.env as Record<string, unknown>;
|
|
26
|
+
if (!(key in env)) {
|
|
27
|
+
return new CloudflareContextKeyNotFound({
|
|
28
|
+
message: `${key} is not set in cloudflare context (found ${Object.keys(env).join(", ")})`,
|
|
29
|
+
key,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return Effect.succeed(env[key] as T);
|
|
33
|
+
}),
|
|
34
|
+
Effect.orDie,
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export class CloudflareContextNotFound extends Data.TaggedError(
|
|
39
|
+
"Cloudflare.Context.NotFound",
|
|
40
|
+
)<{
|
|
41
|
+
message: string;
|
|
42
|
+
}> {}
|
|
43
|
+
|
|
44
|
+
export class CloudflareContextKeyNotFound extends Data.TaggedError(
|
|
45
|
+
"Cloudflare.Context.KeyNotFound",
|
|
46
|
+
)<{
|
|
47
|
+
message: string;
|
|
48
|
+
key: string;
|
|
49
|
+
}> {}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Binding, type Capability, type To } from "alchemy-effect";
|
|
2
|
+
import { Worker } from "../worker/worker.ts";
|
|
3
|
+
import type { Namespace, NamespaceProps } from "./namespace.ts";
|
|
4
|
+
|
|
5
|
+
export interface Bind<B = Namespace<string, NamespaceProps>>
|
|
6
|
+
extends Capability<"Cloudflare.KV.Namespace.Bind", B> {}
|
|
7
|
+
|
|
8
|
+
export const Bind = Binding<
|
|
9
|
+
<B extends Namespace<string, NamespaceProps>>(
|
|
10
|
+
namespace: B,
|
|
11
|
+
) => Binding<Worker, Bind<To<B>>>
|
|
12
|
+
>(Worker, "Cloudflare.KV.Namespace.Bind");
|
|
13
|
+
|
|
14
|
+
export const bindFromWorker = () =>
|
|
15
|
+
Bind.provider.succeed({
|
|
16
|
+
attach: ({ source }) => ({
|
|
17
|
+
bindings: [
|
|
18
|
+
{
|
|
19
|
+
type: "kv_namespace",
|
|
20
|
+
name: source.id,
|
|
21
|
+
namespace_id: source.attr.namespaceId,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type * as runtime from "@cloudflare/workers-types";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Stream from "effect/Stream";
|
|
4
|
+
import { declare, type To } from "../../policy.ts";
|
|
5
|
+
import { getCloudflareEnvKey } from "../context.ts";
|
|
6
|
+
import { replaceEffectStream } from "../stream.ts";
|
|
7
|
+
import { Bind } from "./namespace.binding.ts";
|
|
8
|
+
import type * as KV from "./namespace.ts";
|
|
9
|
+
|
|
10
|
+
export const get = Effect.fnUntraced(function* <KV extends KV.Namespace>(
|
|
11
|
+
namespace: KV,
|
|
12
|
+
key: string,
|
|
13
|
+
) {
|
|
14
|
+
const client = yield* getKvNamespaceFromEnv(namespace);
|
|
15
|
+
return yield* Effect.promise(() => client.get(key));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const getWithMetadata = Effect.fnUntraced(function* <
|
|
19
|
+
KV extends KV.Namespace,
|
|
20
|
+
Metadata = unknown,
|
|
21
|
+
>(
|
|
22
|
+
namespace: KV,
|
|
23
|
+
key: string,
|
|
24
|
+
options?: runtime.KVNamespaceGetOptions<undefined>,
|
|
25
|
+
) {
|
|
26
|
+
const client = yield* getKvNamespaceFromEnv(namespace);
|
|
27
|
+
return yield* Effect.promise(() =>
|
|
28
|
+
client.getWithMetadata<Metadata>(key, options),
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const put = Effect.fnUntraced(function* <KV extends KV.Namespace>(
|
|
33
|
+
namespace: KV,
|
|
34
|
+
key: string,
|
|
35
|
+
value:
|
|
36
|
+
| string
|
|
37
|
+
| ArrayBuffer
|
|
38
|
+
| ArrayBufferView
|
|
39
|
+
| runtime.ReadableStream
|
|
40
|
+
| Stream.Stream<any>,
|
|
41
|
+
options?: runtime.KVNamespacePutOptions,
|
|
42
|
+
) {
|
|
43
|
+
const client = yield* getKvNamespaceFromEnv(namespace);
|
|
44
|
+
return yield* Effect.promise(() =>
|
|
45
|
+
client.put(key, replaceEffectStream(value), options),
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const del = Effect.fnUntraced(function* <KV extends KV.Namespace>(
|
|
50
|
+
namespace: KV,
|
|
51
|
+
key: string,
|
|
52
|
+
) {
|
|
53
|
+
const client = yield* getKvNamespaceFromEnv(namespace);
|
|
54
|
+
return yield* Effect.promise(() => client.delete(key));
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const list = Effect.fnUntraced(function* <
|
|
58
|
+
KV extends KV.Namespace,
|
|
59
|
+
Metadata = unknown,
|
|
60
|
+
>(namespace: KV, options?: runtime.KVNamespaceListOptions) {
|
|
61
|
+
const client = yield* getKvNamespaceFromEnv(namespace);
|
|
62
|
+
return yield* Effect.promise(() => client.list<Metadata>(options));
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const getKvNamespaceFromEnv = Effect.fnUntraced(function* <
|
|
66
|
+
KV extends KV.Namespace,
|
|
67
|
+
>(namespace: KV) {
|
|
68
|
+
yield* declare<Bind<To<KV>>>();
|
|
69
|
+
return yield* getCloudflareEnvKey<runtime.KVNamespace>(namespace.id);
|
|
70
|
+
});
|