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,20 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import { DynamoDB } from "itty-aws/dynamodb";
|
|
4
|
+
|
|
5
|
+
import * as Credentials from "../credentials.ts";
|
|
6
|
+
import * as Region from "../region.ts";
|
|
7
|
+
import { createAWSServiceClientLayer } from "../client.ts";
|
|
8
|
+
|
|
9
|
+
export class DynamoDBClient extends Context.Tag("AWS::DynamoDB::Client")<
|
|
10
|
+
DynamoDBClient,
|
|
11
|
+
DynamoDB
|
|
12
|
+
>() {}
|
|
13
|
+
|
|
14
|
+
export const client = createAWSServiceClientLayer<
|
|
15
|
+
typeof DynamoDBClient,
|
|
16
|
+
DynamoDB
|
|
17
|
+
>(DynamoDBClient, DynamoDB);
|
|
18
|
+
|
|
19
|
+
export const clientFromEnv = () =>
|
|
20
|
+
Layer.provide(client(), Layer.merge(Credentials.fromEnv(), Region.fromEnv()));
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export type Expr =
|
|
2
|
+
| ArrayIndex
|
|
3
|
+
| Identifier
|
|
4
|
+
| NumberLiteral
|
|
5
|
+
| OperatorExpr
|
|
6
|
+
| NameRef
|
|
7
|
+
| PropRef
|
|
8
|
+
| ValueRef;
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
export interface NameRef<Name extends string = string> {
|
|
12
|
+
kind: "name-ref";
|
|
13
|
+
name: Name;
|
|
14
|
+
}
|
|
15
|
+
export interface ValueRef<Name extends string = string> {
|
|
16
|
+
kind: "value-ref";
|
|
17
|
+
name: Name;
|
|
18
|
+
}
|
|
19
|
+
export interface Identifier<I extends string = string> {
|
|
20
|
+
kind: "identifier";
|
|
21
|
+
name: I;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface NumberLiteral<N extends string = string> {
|
|
25
|
+
kind: "index";
|
|
26
|
+
number: N;
|
|
27
|
+
}
|
|
28
|
+
export interface PropRef<Ex extends Expr = any, Id extends Identifier = any> {
|
|
29
|
+
kind: "prop-ref";
|
|
30
|
+
expr: Ex;
|
|
31
|
+
name: Id;
|
|
32
|
+
}
|
|
33
|
+
export interface ArrayIndex<
|
|
34
|
+
List extends Expr = any,
|
|
35
|
+
Number extends NumberLiteral | ValueRef = NumberLiteral | ValueRef,
|
|
36
|
+
> {
|
|
37
|
+
kind: "array-index";
|
|
38
|
+
list: List;
|
|
39
|
+
number: Number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type Operator = "and" | "or" | "=" | "<" | "<=" | ">=" | ">";
|
|
43
|
+
export interface OperatorExpr<
|
|
44
|
+
Left extends Expr = any,
|
|
45
|
+
Op extends Operator = Operator,
|
|
46
|
+
Right extends Expr = any,
|
|
47
|
+
> {
|
|
48
|
+
kind: "op";
|
|
49
|
+
left: Left;
|
|
50
|
+
op: Op;
|
|
51
|
+
right: Right;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type LowercaseLetter =
|
|
55
|
+
| "a"
|
|
56
|
+
| "b"
|
|
57
|
+
| "c"
|
|
58
|
+
| "d"
|
|
59
|
+
| "e"
|
|
60
|
+
| "f"
|
|
61
|
+
| "g"
|
|
62
|
+
| "h"
|
|
63
|
+
| "i"
|
|
64
|
+
| "j"
|
|
65
|
+
| "k"
|
|
66
|
+
| "l"
|
|
67
|
+
| "m"
|
|
68
|
+
| "n"
|
|
69
|
+
| "o"
|
|
70
|
+
| "p"
|
|
71
|
+
| "q"
|
|
72
|
+
| "r"
|
|
73
|
+
| "s"
|
|
74
|
+
| "t"
|
|
75
|
+
| "u"
|
|
76
|
+
| "v"
|
|
77
|
+
| "w"
|
|
78
|
+
| "x"
|
|
79
|
+
| "y"
|
|
80
|
+
| "z";
|
|
81
|
+
|
|
82
|
+
export type UppercaseLetter = Uppercase<LowercaseLetter>;
|
|
83
|
+
|
|
84
|
+
export type Letter = LowercaseLetter | UppercaseLetter;
|
|
85
|
+
|
|
86
|
+
export type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
87
|
+
|
|
88
|
+
export type SpecialCharacter = "_";
|
|
89
|
+
|
|
90
|
+
export type Word = Digit | Letter | SpecialCharacter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./attribute-value.ts";
|
|
2
|
+
export * from "./client.ts";
|
|
3
|
+
export * from "./expr.ts";
|
|
4
|
+
export * from "./secondary-index.ts";
|
|
5
|
+
export * from "./table.get-item.ts";
|
|
6
|
+
export * from "./table.provider.ts";
|
|
7
|
+
export * from "./table.ts";
|
|
8
|
+
|
|
9
|
+
export type * as Alchemy from "../../index.ts";
|
|
10
|
+
|
|
11
|
+
// TODO(sam): figure out a better strategy to workaround non-portable types
|
|
12
|
+
// export type * as _ from "../../index.ts";
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ArrayIndex,
|
|
3
|
+
Expr,
|
|
4
|
+
Identifier,
|
|
5
|
+
NameRef,
|
|
6
|
+
NumberLiteral,
|
|
7
|
+
PropRef,
|
|
8
|
+
ValueRef,
|
|
9
|
+
Word,
|
|
10
|
+
} from "./expr.ts";
|
|
11
|
+
|
|
12
|
+
export type ParseProjectionExpression<Text extends string> = Parse<
|
|
13
|
+
Text,
|
|
14
|
+
[],
|
|
15
|
+
undefined
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
type AsExpr<T> = Extract<T, Expr>;
|
|
19
|
+
|
|
20
|
+
type Parse<
|
|
21
|
+
Text extends string,
|
|
22
|
+
Expressions extends Expr[],
|
|
23
|
+
Exp extends Expr | undefined,
|
|
24
|
+
> = Text extends `.${infer Rest}`
|
|
25
|
+
? Exp extends Expr
|
|
26
|
+
? Parse<Rest, Expressions, PropRef<Exp, Identifier<"">>>
|
|
27
|
+
: never
|
|
28
|
+
: Text extends `[:${infer Rest}`
|
|
29
|
+
? Parse<Rest, Expressions, ArrayIndex<AsExpr<Exp>, ValueRef<"">>>
|
|
30
|
+
: Text extends `[${infer Rest}`
|
|
31
|
+
? Parse<Rest, Expressions, ArrayIndex<AsExpr<Exp>, NumberLiteral<"">>>
|
|
32
|
+
: Text extends `]${infer Rest}`
|
|
33
|
+
? Parse<Rest, Expressions, Exp>
|
|
34
|
+
: Text extends `]`
|
|
35
|
+
? Concat<Expressions, Exp>
|
|
36
|
+
: Text extends `${"," | " "}${infer Rest}`
|
|
37
|
+
? Parse<Rest, Concat<Expressions, Exp>, undefined>
|
|
38
|
+
: Text extends `#${infer Rest}`
|
|
39
|
+
? Parse<Rest, Concat<Expressions, Exp>, NameRef<Rest>>
|
|
40
|
+
: Text extends `:${infer Rest}`
|
|
41
|
+
? Parse<Rest, Concat<Expressions, Exp>, ValueRef<Rest>>
|
|
42
|
+
: Text extends `${Word}${string}`
|
|
43
|
+
? Text extends `${infer char}${infer Rest}`
|
|
44
|
+
? Parse<Rest, Expressions, Append<Exp, char>>
|
|
45
|
+
: never
|
|
46
|
+
: Text extends `${Word}${string}`
|
|
47
|
+
? Text extends `${infer char}${infer Rest}`
|
|
48
|
+
? Parse<Rest, Expressions, Append<Exp, char>>
|
|
49
|
+
: never
|
|
50
|
+
: Concat<Expressions, Exp>;
|
|
51
|
+
|
|
52
|
+
type Concat<
|
|
53
|
+
Expressions extends Expr[],
|
|
54
|
+
CurrentExpr extends Expr | undefined,
|
|
55
|
+
> = undefined extends CurrentExpr
|
|
56
|
+
? Expressions
|
|
57
|
+
: [...Expressions, Extract<CurrentExpr, Expr>];
|
|
58
|
+
|
|
59
|
+
type Append<
|
|
60
|
+
Exp extends Expr | undefined,
|
|
61
|
+
char extends string,
|
|
62
|
+
> = Exp extends undefined
|
|
63
|
+
? Identifier<char>
|
|
64
|
+
: Exp extends Identifier<infer Name>
|
|
65
|
+
? Identifier<`${Name}${char}`>
|
|
66
|
+
: Exp extends NumberLiteral<infer Name>
|
|
67
|
+
? NumberLiteral<`${Name}${char}`>
|
|
68
|
+
: Exp extends NameRef<infer Name>
|
|
69
|
+
? NameRef<`${Name}${char}`>
|
|
70
|
+
: Exp extends ValueRef<infer Name>
|
|
71
|
+
? ValueRef<`${Name}${char}`>
|
|
72
|
+
: Exp extends PropRef<infer expr, infer name>
|
|
73
|
+
? PropRef<expr, Extract<Append<name, char>, Identifier>>
|
|
74
|
+
: Exp extends ArrayIndex<infer expr, infer idx>
|
|
75
|
+
? ArrayIndex<expr, Extract<Append<idx, char>, NumberLiteral>>
|
|
76
|
+
: never;
|
|
77
|
+
|
|
78
|
+
export type ApplyProjection<T, Expr extends string> = Flatten<
|
|
79
|
+
UnionToIntersection<
|
|
80
|
+
ApplyProjectionExpr<T, ParseProjectionExpression<Expr>[number]>
|
|
81
|
+
>
|
|
82
|
+
>;
|
|
83
|
+
|
|
84
|
+
type ApplyProjectionExpr<T, Exp extends Expr> = T extends undefined
|
|
85
|
+
? never
|
|
86
|
+
: Exp extends PropRef<infer expr, infer i>
|
|
87
|
+
? {
|
|
88
|
+
[p in keyof ApplyProjectionExpr<T, expr>]: ApplyProjectionExpr<
|
|
89
|
+
ApplyProjectionExpr<T, expr>[p],
|
|
90
|
+
i
|
|
91
|
+
>;
|
|
92
|
+
}
|
|
93
|
+
: Exp extends ArrayIndex<infer expr, infer i>
|
|
94
|
+
? {
|
|
95
|
+
[p in keyof ApplyProjectionExpr<T, expr>]: ApplyProjectionExpr<
|
|
96
|
+
ApplyProjectionExpr<T, expr>[keyof ApplyProjectionExpr<T, expr>],
|
|
97
|
+
i
|
|
98
|
+
>;
|
|
99
|
+
}
|
|
100
|
+
: Exp extends Identifier<infer I>
|
|
101
|
+
? I extends keyof T
|
|
102
|
+
? Pick<T, I>
|
|
103
|
+
: never
|
|
104
|
+
: Exp extends NumberLiteral<infer I>
|
|
105
|
+
? ParseInt<I> extends keyof T
|
|
106
|
+
? Pick<T, ParseInt<I>>
|
|
107
|
+
: never
|
|
108
|
+
: never;
|
|
109
|
+
|
|
110
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
111
|
+
k: infer I,
|
|
112
|
+
) => void
|
|
113
|
+
? I
|
|
114
|
+
: never;
|
|
115
|
+
|
|
116
|
+
type Flatten<T> = T extends object
|
|
117
|
+
? keyof T extends number
|
|
118
|
+
? FlattenArray<Extract<T, Record<number, any>>>
|
|
119
|
+
: {
|
|
120
|
+
[k in keyof T]: Flatten<T[k]>;
|
|
121
|
+
}
|
|
122
|
+
: T;
|
|
123
|
+
|
|
124
|
+
type FlattenArray<
|
|
125
|
+
T extends { [i in number]: any },
|
|
126
|
+
i extends number = 0,
|
|
127
|
+
> = i extends keyof T
|
|
128
|
+
? [T[i], ...FlattenArray<T, Inc<i>>]
|
|
129
|
+
: number extends i
|
|
130
|
+
? []
|
|
131
|
+
: FlattenArray<T, Inc<i>>;
|
|
132
|
+
|
|
133
|
+
type BuildTuple<N extends number, T extends any[] = []> = T["length"] extends N
|
|
134
|
+
? T
|
|
135
|
+
: BuildTuple<N, [...T, any]>;
|
|
136
|
+
|
|
137
|
+
type Inc<N extends number> = Extract<[...BuildTuple<N>, any]["length"], number>;
|
|
138
|
+
|
|
139
|
+
type ParseInt<N extends string> = N extends "0"
|
|
140
|
+
? 0
|
|
141
|
+
: N extends "1"
|
|
142
|
+
? 1
|
|
143
|
+
: N extends "2"
|
|
144
|
+
? 2
|
|
145
|
+
: N extends "3"
|
|
146
|
+
? 3
|
|
147
|
+
: N extends "4"
|
|
148
|
+
? 4
|
|
149
|
+
: N extends "5"
|
|
150
|
+
? 5
|
|
151
|
+
: N extends "6"
|
|
152
|
+
? 6
|
|
153
|
+
: N extends "7"
|
|
154
|
+
? 7
|
|
155
|
+
: N extends "8"
|
|
156
|
+
? 8
|
|
157
|
+
: N extends "9"
|
|
158
|
+
? 9
|
|
159
|
+
: number;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as S from "effect/Schema";
|
|
2
|
+
import { Resource } from "../../resource.ts";
|
|
3
|
+
import type { Table } from "./table.ts";
|
|
4
|
+
|
|
5
|
+
export const SecondaryIndex = Resource<{
|
|
6
|
+
<
|
|
7
|
+
const ID extends string,
|
|
8
|
+
const Source extends Table,
|
|
9
|
+
const Attributes extends S.Struct.Fields,
|
|
10
|
+
const PartitionKey extends keyof Attributes,
|
|
11
|
+
const SortKey extends keyof Attributes | undefined = undefined,
|
|
12
|
+
>(
|
|
13
|
+
id: ID,
|
|
14
|
+
props: SecondaryIndexProps<Source, Attributes, PartitionKey, SortKey>,
|
|
15
|
+
): SecondaryIndex<
|
|
16
|
+
ID,
|
|
17
|
+
SecondaryIndexProps<Source, Attributes, PartitionKey, SortKey>
|
|
18
|
+
>;
|
|
19
|
+
}>("AWS.DynamoDB.SecondaryIndex");
|
|
20
|
+
|
|
21
|
+
export interface SecondaryIndex<
|
|
22
|
+
ID extends string = string,
|
|
23
|
+
Props extends SecondaryIndexProps = SecondaryIndexProps,
|
|
24
|
+
> extends Resource<
|
|
25
|
+
"AWS.DynamoDB.SecondaryIndex",
|
|
26
|
+
ID,
|
|
27
|
+
Props,
|
|
28
|
+
SecondaryIndexAttrs<Props>
|
|
29
|
+
> {}
|
|
30
|
+
|
|
31
|
+
export interface SecondaryIndexProps<
|
|
32
|
+
Source extends Table = Table,
|
|
33
|
+
Attributes extends S.Struct.Fields = S.Struct.Fields,
|
|
34
|
+
PartitionKey extends keyof Attributes = keyof Attributes,
|
|
35
|
+
SortKey extends keyof Attributes | undefined = keyof Attributes | undefined,
|
|
36
|
+
> {
|
|
37
|
+
table: new () => Source;
|
|
38
|
+
indexName?: string;
|
|
39
|
+
partitionKey: PartitionKey;
|
|
40
|
+
sortKey?: SortKey;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type SecondaryIndexAttrs<Props extends SecondaryIndexProps> = {
|
|
44
|
+
indexName: Props["indexName"] extends string ? Props["indexName"] : string;
|
|
45
|
+
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Binding,
|
|
3
|
+
declare,
|
|
4
|
+
Policy,
|
|
5
|
+
toEnvKey,
|
|
6
|
+
type Capability,
|
|
7
|
+
type From,
|
|
8
|
+
} from "alchemy-effect";
|
|
9
|
+
import { Effect } from "effect";
|
|
10
|
+
import type { ReturnConsumedCapacity } from "itty-aws/dynamodb";
|
|
11
|
+
import { Function } from "../lambda/index.ts";
|
|
12
|
+
import { fromAttributeValue } from "./attribute-value.ts";
|
|
13
|
+
import { DynamoDBClient } from "./client.ts";
|
|
14
|
+
import type { Identifier } from "./expr.ts";
|
|
15
|
+
import type { ParseProjectionExpression } from "./projection.ts";
|
|
16
|
+
import { Table } from "./table.ts";
|
|
17
|
+
|
|
18
|
+
export interface GetItemConstraint<
|
|
19
|
+
LeadingKeys extends Policy.AnyOf<any> = Policy.AnyOf<any>,
|
|
20
|
+
Attributes extends Policy.AnyOf<any> = Policy.AnyOf<any>,
|
|
21
|
+
ReturnConsumedCapacity extends Policy.AnyOf<any> = Policy.AnyOf<any>,
|
|
22
|
+
> {
|
|
23
|
+
leadingKeys?: LeadingKeys;
|
|
24
|
+
attributes?: Attributes;
|
|
25
|
+
returnConsumedCapacity?: ReturnConsumedCapacity;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface GetItem<
|
|
29
|
+
T = unknown,
|
|
30
|
+
Constraint extends GetItemConstraint | unknown = unknown,
|
|
31
|
+
> extends Capability<"AWS.DynamoDB.GetItem", T, Constraint> {
|
|
32
|
+
Constructor: GetItem;
|
|
33
|
+
Reduce: GetItem<
|
|
34
|
+
this["resource"],
|
|
35
|
+
{
|
|
36
|
+
[k in keyof Capability.Constraint.Simplify<
|
|
37
|
+
this["constraint"]
|
|
38
|
+
>]: Capability.Constraint.Simplify<this["constraint"]>[k];
|
|
39
|
+
}
|
|
40
|
+
>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const GetItem = Binding<
|
|
44
|
+
<
|
|
45
|
+
T extends Table,
|
|
46
|
+
const LeadingKeys extends Policy.AnyOf<any> = Policy.AnyOf<string>,
|
|
47
|
+
const Attributes extends Policy.AnyOf<any> = never,
|
|
48
|
+
const ReturnConsumedCapacity extends Policy.AnyOf<any> = never,
|
|
49
|
+
>(
|
|
50
|
+
table: T,
|
|
51
|
+
constraint?: GetItemConstraint<
|
|
52
|
+
LeadingKeys,
|
|
53
|
+
Attributes,
|
|
54
|
+
ReturnConsumedCapacity
|
|
55
|
+
>,
|
|
56
|
+
) => Binding<
|
|
57
|
+
Function,
|
|
58
|
+
GetItem<
|
|
59
|
+
From<T>,
|
|
60
|
+
Policy.Constraint<{
|
|
61
|
+
leadingKeys: LeadingKeys;
|
|
62
|
+
attributes: Attributes;
|
|
63
|
+
returnConsumedCapacity: ReturnConsumedCapacity;
|
|
64
|
+
}>
|
|
65
|
+
>
|
|
66
|
+
>
|
|
67
|
+
>(Function, "AWS.DynamoDB.GetItem");
|
|
68
|
+
|
|
69
|
+
// see: https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazondynamodb.html
|
|
70
|
+
export const getItem = <
|
|
71
|
+
T extends Table<string, any>,
|
|
72
|
+
const Key extends Table.Key<T>,
|
|
73
|
+
const ProjectionExpression extends string = never,
|
|
74
|
+
const Capacity extends ReturnConsumedCapacity = never,
|
|
75
|
+
>({
|
|
76
|
+
table,
|
|
77
|
+
key,
|
|
78
|
+
projectionExpression,
|
|
79
|
+
returnConsumedCapacity,
|
|
80
|
+
}: {
|
|
81
|
+
table: T;
|
|
82
|
+
key: Key;
|
|
83
|
+
projectionExpression?: ProjectionExpression;
|
|
84
|
+
returnConsumedCapacity?: Capacity;
|
|
85
|
+
}) =>
|
|
86
|
+
Effect.gen(function* () {
|
|
87
|
+
type Parsed = ParseProjectionExpression<ProjectionExpression>;
|
|
88
|
+
type Attributes = Extract<Parsed[number], Identifier>["name"];
|
|
89
|
+
type LeadingKeys = Extract<Key[T["props"]["partitionKey"]], string>;
|
|
90
|
+
type Constraint = Policy.Constraint<{
|
|
91
|
+
leadingKeys: Policy.AnyOf<LeadingKeys>;
|
|
92
|
+
attributes: Policy.AnyOf<Attributes>;
|
|
93
|
+
returnConsumedCapacity: Policy.AnyOf<Capacity>;
|
|
94
|
+
}>;
|
|
95
|
+
yield* declare<
|
|
96
|
+
GetItem<
|
|
97
|
+
From<T>,
|
|
98
|
+
{
|
|
99
|
+
[k in keyof Constraint]: Constraint[k];
|
|
100
|
+
}
|
|
101
|
+
>
|
|
102
|
+
>();
|
|
103
|
+
const tableNameEnv = toEnvKey(table.id, "TABLE_NAME");
|
|
104
|
+
const tableName = process.env[tableNameEnv];
|
|
105
|
+
if (!tableName) {
|
|
106
|
+
return yield* Effect.die(new Error(`${tableNameEnv} is not set`));
|
|
107
|
+
}
|
|
108
|
+
const ddb = yield* DynamoDBClient;
|
|
109
|
+
const { Item, ...rest } = yield* ddb.getItem({
|
|
110
|
+
TableName: tableName,
|
|
111
|
+
Key: {
|
|
112
|
+
[table.props.partitionKey]: {
|
|
113
|
+
S: (key as any)[table.props.partitionKey] as string,
|
|
114
|
+
},
|
|
115
|
+
...(table.props.sortKey
|
|
116
|
+
? {
|
|
117
|
+
[table.props.sortKey]: {
|
|
118
|
+
S: (key as any)[table.props.sortKey] as string,
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
: {}),
|
|
122
|
+
},
|
|
123
|
+
ProjectionExpression: projectionExpression,
|
|
124
|
+
ReturnConsumedCapacity: returnConsumedCapacity,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
...rest,
|
|
129
|
+
Item: Item
|
|
130
|
+
? (Object.fromEntries(
|
|
131
|
+
yield* Effect.promise(() =>
|
|
132
|
+
Promise.all(
|
|
133
|
+
Object.entries(Item!).map(async ([key, value]) => [
|
|
134
|
+
key,
|
|
135
|
+
await fromAttributeValue(value),
|
|
136
|
+
]),
|
|
137
|
+
),
|
|
138
|
+
),
|
|
139
|
+
) as InstanceType<T["props"]["items"]> & Key)
|
|
140
|
+
: undefined,
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export const getItemFromLambdaFunction = () =>
|
|
145
|
+
GetItem.provider.succeed({
|
|
146
|
+
attach: ({ source: table, props }) => ({
|
|
147
|
+
env: {
|
|
148
|
+
[toEnvKey(table.id, "TABLE_NAME")]: table.attr.tableName,
|
|
149
|
+
[toEnvKey(table.id, "TABLE_ARN")]: table.attr.tableArn,
|
|
150
|
+
},
|
|
151
|
+
policyStatements: [
|
|
152
|
+
{
|
|
153
|
+
Sid: "GetItem",
|
|
154
|
+
Effect: "Allow",
|
|
155
|
+
Action: ["dynamodb:GetItem"],
|
|
156
|
+
Resource: [table.attr.tableArn],
|
|
157
|
+
Condition:
|
|
158
|
+
props?.leadingKeys ||
|
|
159
|
+
props?.attributes ||
|
|
160
|
+
props?.returnConsumedCapacity
|
|
161
|
+
? {
|
|
162
|
+
// https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazondynamodb.html#amazondynamodb-dynamodb_LeadingKeys
|
|
163
|
+
|
|
164
|
+
// TODO(sam): add StringLike for prefixes, templates, etc.
|
|
165
|
+
"ForAllValues:StringEquals": {
|
|
166
|
+
"dynamodb:LeadingKeys": props.leadingKeys
|
|
167
|
+
?.anyOf as string[],
|
|
168
|
+
"dynamodb:Attributes": props.attributes?.anyOf as string[],
|
|
169
|
+
"dynamodb:ReturnConsumedCapacity": props
|
|
170
|
+
.returnConsumedCapacity?.anyOf as string[],
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
: undefined,
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
}),
|
|
177
|
+
});
|