alchemy-effect 0.2.0 → 0.4.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/bin/alchemy-effect.js +55354 -8
- package/bin/alchemy-effect.js.map +1 -1
- package/bin/alchemy-effect.ts +266 -10
- package/lib/$.d.ts +5 -0
- package/lib/$.d.ts.map +1 -0
- package/lib/$.js +9 -0
- package/lib/$.js.map +1 -0
- package/lib/app.d.ts +4 -17
- package/lib/app.d.ts.map +1 -1
- package/lib/app.js +0 -20
- package/lib/app.js.map +1 -1
- package/lib/apply.d.ts +15 -75
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +439 -154
- package/lib/apply.js.map +1 -1
- package/lib/assert-never.d.ts +12 -0
- package/lib/assert-never.d.ts.map +1 -0
- package/lib/assert-never.js +11 -0
- package/lib/assert-never.js.map +1 -0
- package/lib/aws/account.d.ts +10 -1
- package/lib/aws/account.d.ts.map +1 -1
- package/lib/aws/account.js +18 -3
- package/lib/aws/account.js.map +1 -1
- package/lib/aws/client.d.ts.map +1 -1
- package/lib/aws/client.js +0 -1
- package/lib/aws/client.js.map +1 -1
- package/lib/aws/config.d.ts +15 -0
- package/lib/aws/config.d.ts.map +1 -0
- package/lib/aws/config.js +1 -0
- package/lib/aws/config.js.map +1 -0
- package/lib/aws/credentials.d.ts +10 -0
- package/lib/aws/credentials.d.ts.map +1 -1
- package/lib/aws/credentials.js +73 -47
- package/lib/aws/credentials.js.map +1 -1
- package/lib/aws/dynamodb/client.d.ts +1 -1
- package/lib/aws/dynamodb/client.d.ts.map +1 -1
- package/lib/aws/dynamodb/index.d.ts +2 -1
- package/lib/aws/dynamodb/index.d.ts.map +1 -1
- package/lib/aws/dynamodb/index.js +1 -2
- package/lib/aws/dynamodb/index.js.map +1 -1
- package/lib/aws/dynamodb/secondary-index.d.ts +5 -4
- package/lib/aws/dynamodb/secondary-index.d.ts.map +1 -1
- package/lib/aws/dynamodb/table.d.ts +23 -20
- package/lib/aws/dynamodb/table.d.ts.map +1 -1
- package/lib/aws/dynamodb/table.get-item.d.ts +8 -6
- package/lib/aws/dynamodb/table.get-item.d.ts.map +1 -1
- package/lib/aws/dynamodb/table.get-item.js +4 -2
- package/lib/aws/dynamodb/table.get-item.js.map +1 -1
- package/lib/aws/dynamodb/table.js.map +1 -1
- package/lib/aws/dynamodb/table.provider.d.ts +3 -4
- package/lib/aws/dynamodb/table.provider.d.ts.map +1 -1
- package/lib/aws/dynamodb/table.provider.js +18 -29
- package/lib/aws/dynamodb/table.provider.js.map +1 -1
- package/lib/aws/ec2/client.d.ts +1 -1
- package/lib/aws/ec2/client.d.ts.map +1 -1
- package/lib/aws/ec2/index.d.ts +11 -0
- package/lib/aws/ec2/index.d.ts.map +1 -1
- package/lib/aws/ec2/index.js +11 -0
- package/lib/aws/ec2/index.js.map +1 -1
- package/lib/aws/ec2/internet-gateway.d.ts +65 -0
- package/lib/aws/ec2/internet-gateway.d.ts.map +1 -0
- package/lib/aws/ec2/internet-gateway.js +4 -0
- package/lib/aws/ec2/internet-gateway.js.map +1 -0
- package/lib/aws/ec2/internet-gateway.provider.d.ts +6 -0
- package/lib/aws/ec2/internet-gateway.provider.d.ts.map +1 -0
- package/lib/aws/ec2/internet-gateway.provider.js +193 -0
- package/lib/aws/ec2/internet-gateway.provider.js.map +1 -0
- package/lib/aws/ec2/route-table-association.d.ts +63 -0
- package/lib/aws/ec2/route-table-association.d.ts.map +1 -0
- package/lib/aws/ec2/route-table-association.js +4 -0
- package/lib/aws/ec2/route-table-association.js.map +1 -0
- package/lib/aws/ec2/route-table-association.provider.d.ts +4 -0
- package/lib/aws/ec2/route-table-association.provider.d.ts.map +1 -0
- package/lib/aws/ec2/route-table-association.provider.js +121 -0
- package/lib/aws/ec2/route-table-association.provider.js.map +1 -0
- package/lib/aws/ec2/route-table.d.ts +159 -0
- package/lib/aws/ec2/route-table.d.ts.map +1 -0
- package/lib/aws/ec2/route-table.js +4 -0
- package/lib/aws/ec2/route-table.js.map +1 -0
- package/lib/aws/ec2/route-table.provider.d.ts +6 -0
- package/lib/aws/ec2/route-table.provider.d.ts.map +1 -0
- package/lib/aws/ec2/route-table.provider.js +213 -0
- package/lib/aws/ec2/route-table.provider.js.map +1 -0
- package/lib/aws/ec2/route.d.ts +155 -0
- package/lib/aws/ec2/route.d.ts.map +1 -0
- package/lib/aws/ec2/route.js +3 -0
- package/lib/aws/ec2/route.js.map +1 -0
- package/lib/aws/ec2/route.provider.d.ts +4 -0
- package/lib/aws/ec2/route.provider.d.ts.map +1 -0
- package/lib/aws/ec2/route.provider.js +166 -0
- package/lib/aws/ec2/route.provider.js.map +1 -0
- package/lib/aws/ec2/subnet.d.ts +175 -0
- package/lib/aws/ec2/subnet.d.ts.map +1 -0
- package/lib/aws/ec2/subnet.js +4 -0
- package/lib/aws/ec2/subnet.js.map +1 -0
- package/lib/aws/ec2/subnet.provider.d.ts +4 -0
- package/lib/aws/ec2/subnet.provider.d.ts.map +1 -0
- package/lib/aws/ec2/subnet.provider.js +250 -0
- package/lib/aws/ec2/subnet.provider.js.map +1 -0
- package/lib/aws/ec2/vpc.d.ts +13 -8
- package/lib/aws/ec2/vpc.d.ts.map +1 -1
- package/lib/aws/ec2/vpc.js +1 -0
- package/lib/aws/ec2/vpc.js.map +1 -1
- package/lib/aws/ec2/vpc.provider.d.ts +1 -2
- package/lib/aws/ec2/vpc.provider.d.ts.map +1 -1
- package/lib/aws/ec2/vpc.provider.js +45 -37
- package/lib/aws/ec2/vpc.provider.js.map +1 -1
- package/lib/aws/index.d.ts +15 -19
- package/lib/aws/index.d.ts.map +1 -1
- package/lib/aws/index.js +8 -10
- package/lib/aws/index.js.map +1 -1
- package/lib/aws/lambda/consume.d.ts +10 -11
- package/lib/aws/lambda/consume.d.ts.map +1 -1
- package/lib/aws/lambda/consume.js +3 -3
- package/lib/aws/lambda/consume.js.map +1 -1
- package/lib/aws/lambda/function.d.ts +7 -7
- package/lib/aws/lambda/function.d.ts.map +1 -1
- package/lib/aws/lambda/function.handler.d.ts +1 -1
- package/lib/aws/lambda/function.handler.d.ts.map +1 -1
- package/lib/aws/lambda/function.handler.js.map +1 -1
- package/lib/aws/lambda/function.invoke.d.ts +6 -4
- package/lib/aws/lambda/function.invoke.d.ts.map +1 -1
- package/lib/aws/lambda/function.invoke.js +3 -1
- package/lib/aws/lambda/function.invoke.js.map +1 -1
- package/lib/aws/lambda/function.js +1 -1
- package/lib/aws/lambda/function.js.map +1 -1
- package/lib/aws/lambda/function.provider.d.ts +3 -2
- package/lib/aws/lambda/function.provider.d.ts.map +1 -1
- package/lib/aws/lambda/function.provider.js +28 -25
- package/lib/aws/lambda/function.provider.js.map +1 -1
- package/lib/aws/lambda/index.d.ts +1 -0
- package/lib/aws/lambda/index.d.ts.map +1 -1
- package/lib/aws/lambda/index.js +1 -0
- package/lib/aws/lambda/index.js.map +1 -1
- package/lib/aws/lambda/serve.d.ts +2 -4
- package/lib/aws/lambda/serve.d.ts.map +1 -1
- package/lib/aws/profile.d.ts +2 -2
- package/lib/aws/profile.d.ts.map +1 -1
- package/lib/aws/profile.js +1 -1
- package/lib/aws/profile.js.map +1 -1
- package/lib/aws/region.d.ts +14 -2
- package/lib/aws/region.d.ts.map +1 -1
- package/lib/aws/region.js +26 -1
- package/lib/aws/region.js.map +1 -1
- package/lib/aws/sqs/client.d.ts +1 -1
- package/lib/aws/sqs/client.d.ts.map +1 -1
- package/lib/aws/sqs/index.d.ts +1 -0
- package/lib/aws/sqs/index.d.ts.map +1 -1
- package/lib/aws/sqs/index.js +1 -0
- package/lib/aws/sqs/index.js.map +1 -1
- package/lib/aws/sqs/queue.consume.d.ts +1 -1
- package/lib/aws/sqs/queue.consume.d.ts.map +1 -1
- package/lib/aws/sqs/queue.consume.js +0 -1
- package/lib/aws/sqs/queue.consume.js.map +1 -1
- package/lib/aws/sqs/queue.d.ts +6 -4
- package/lib/aws/sqs/queue.d.ts.map +1 -1
- package/lib/aws/sqs/queue.event-source.d.ts +8 -6
- package/lib/aws/sqs/queue.event-source.d.ts.map +1 -1
- package/lib/aws/sqs/queue.event-source.js +26 -44
- package/lib/aws/sqs/queue.event-source.js.map +1 -1
- package/lib/aws/sqs/queue.js +1 -1
- package/lib/aws/sqs/queue.js.map +1 -1
- package/lib/aws/sqs/queue.provider.d.ts +2 -2
- package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
- package/lib/aws/sqs/queue.provider.js +2 -1
- package/lib/aws/sqs/queue.provider.js.map +1 -1
- package/lib/aws/sqs/queue.send-message.d.ts +7 -5
- package/lib/aws/sqs/queue.send-message.d.ts.map +1 -1
- package/lib/aws/sqs/queue.send-message.js +4 -2
- package/lib/aws/sqs/queue.send-message.js.map +1 -1
- package/lib/binding.d.ts +12 -12
- package/lib/binding.d.ts.map +1 -1
- package/lib/binding.js.map +1 -1
- package/lib/cli/components/ApprovePlan.d.ts +2 -2
- package/lib/cli/components/ApprovePlan.d.ts.map +1 -1
- package/lib/cli/components/ApprovePlan.js.map +1 -1
- package/lib/cli/components/Plan.d.ts +2 -2
- package/lib/cli/components/Plan.d.ts.map +1 -1
- package/lib/cli/components/Plan.js.map +1 -1
- package/lib/cli/components/PlanProgress.d.ts +8 -4
- package/lib/cli/components/PlanProgress.d.ts.map +1 -1
- package/lib/cli/components/PlanProgress.js +11 -1
- package/lib/cli/components/PlanProgress.js.map +1 -1
- package/lib/cli/index.d.ts +384 -264
- package/lib/cli/index.d.ts.map +1 -1
- package/lib/cli/index.js +57 -65
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/ink-service.d.ts +4 -0
- package/lib/cli/ink-service.d.ts.map +1 -0
- package/lib/cli/ink-service.js +43 -0
- package/lib/cli/ink-service.js.map +1 -0
- package/lib/cli/service.d.ts +21 -0
- package/lib/cli/service.d.ts.map +1 -0
- package/lib/cli/service.js +5 -0
- package/lib/cli/service.js.map +1 -0
- package/lib/cloudflare/account.d.ts +10 -0
- package/lib/cloudflare/account.d.ts.map +1 -0
- package/lib/cloudflare/account.js +24 -0
- package/lib/cloudflare/account.js.map +1 -0
- package/lib/cloudflare/api.d.ts +7 -7
- package/lib/cloudflare/api.d.ts.map +1 -1
- package/lib/cloudflare/api.js +18 -17
- package/lib/cloudflare/api.js.map +1 -1
- package/lib/cloudflare/config.d.ts +9 -0
- package/lib/cloudflare/config.d.ts.map +1 -0
- package/lib/cloudflare/config.js +1 -0
- package/lib/cloudflare/config.js.map +1 -0
- package/lib/cloudflare/index.d.ts +3 -1
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +3 -0
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/kv/namespace.binding.d.ts +5 -3
- package/lib/cloudflare/kv/namespace.binding.d.ts.map +1 -1
- package/lib/cloudflare/kv/namespace.binding.js +1 -1
- package/lib/cloudflare/kv/namespace.binding.js.map +1 -1
- package/lib/cloudflare/kv/namespace.client.d.ts +1 -1
- package/lib/cloudflare/kv/namespace.d.ts +3 -2
- package/lib/cloudflare/kv/namespace.d.ts.map +1 -1
- package/lib/cloudflare/kv/namespace.js.map +1 -1
- package/lib/cloudflare/kv/namespace.provider.d.ts +3 -2
- package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -1
- package/lib/cloudflare/kv/namespace.provider.js +9 -7
- package/lib/cloudflare/kv/namespace.provider.js.map +1 -1
- package/lib/cloudflare/live.d.ts +5 -5
- package/lib/cloudflare/live.d.ts.map +1 -1
- package/lib/cloudflare/live.js +5 -8
- package/lib/cloudflare/live.js.map +1 -1
- package/lib/cloudflare/r2/bucket.binding.d.ts +5 -3
- package/lib/cloudflare/r2/bucket.binding.d.ts.map +1 -1
- package/lib/cloudflare/r2/bucket.binding.js +1 -1
- package/lib/cloudflare/r2/bucket.binding.js.map +1 -1
- package/lib/cloudflare/r2/bucket.d.ts +3 -2
- package/lib/cloudflare/r2/bucket.d.ts.map +1 -1
- package/lib/cloudflare/r2/bucket.js.map +1 -1
- package/lib/cloudflare/r2/bucket.provider.d.ts +3 -2
- package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -1
- package/lib/cloudflare/r2/bucket.provider.js +14 -8
- package/lib/cloudflare/r2/bucket.provider.js.map +1 -1
- package/lib/cloudflare/worker/assets.fetch.d.ts +3 -2
- package/lib/cloudflare/worker/assets.fetch.d.ts.map +1 -1
- package/lib/cloudflare/worker/assets.fetch.js +2 -1
- package/lib/cloudflare/worker/assets.fetch.js.map +1 -1
- package/lib/cloudflare/worker/assets.provider.d.ts +1 -1
- package/lib/cloudflare/worker/assets.provider.d.ts.map +1 -1
- package/lib/cloudflare/worker/index.d.ts +0 -1
- package/lib/cloudflare/worker/index.d.ts.map +1 -1
- package/lib/cloudflare/worker/worker.d.ts +5 -6
- package/lib/cloudflare/worker/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker/worker.handler.d.ts +1 -1
- package/lib/cloudflare/worker/worker.handler.d.ts.map +1 -1
- package/lib/cloudflare/worker/worker.handler.js.map +1 -1
- package/lib/cloudflare/worker/worker.js.map +1 -1
- package/lib/cloudflare/worker/worker.provider.d.ts +3 -2
- package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -1
- package/lib/cloudflare/worker/worker.provider.js +12 -7
- package/lib/cloudflare/worker/worker.provider.js.map +1 -1
- package/lib/cloudflare/worker/worker.serve.d.ts +7 -7
- package/lib/cloudflare/worker/worker.serve.d.ts.map +1 -1
- package/lib/cloudflare/worker/worker.serve.js.map +1 -1
- package/lib/data.d.ts +3 -0
- package/lib/data.d.ts.map +1 -0
- package/lib/data.js +8 -0
- package/lib/data.js.map +1 -0
- package/lib/destroy.d.ts +1 -1
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js +1 -4
- package/lib/destroy.js.map +1 -1
- package/lib/diff.d.ts +18 -0
- package/lib/diff.d.ts.map +1 -0
- package/lib/diff.js +22 -0
- package/lib/diff.js.map +1 -0
- package/lib/env.d.ts +5 -0
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +15 -29
- package/lib/env.js.map +1 -1
- package/lib/event.d.ts +1 -1
- package/lib/event.d.ts.map +1 -1
- package/lib/exports.d.ts +9 -0
- package/lib/exports.d.ts.map +1 -0
- package/lib/exports.js +13 -0
- package/lib/exports.js.map +1 -0
- package/lib/index.d.ts +10 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -5
- package/lib/index.js.map +1 -1
- package/lib/input.d.ts +32 -0
- package/lib/input.d.ts.map +1 -0
- package/lib/input.js +1 -0
- package/lib/input.js.map +1 -0
- package/lib/instance-id.d.ts +8 -0
- package/lib/instance-id.d.ts.map +1 -0
- package/lib/instance-id.js +12 -0
- package/lib/instance-id.js.map +1 -0
- package/lib/output.d.ts +145 -0
- package/lib/output.d.ts.map +1 -0
- package/lib/output.js +283 -0
- package/lib/output.js.map +1 -0
- package/lib/physical-name.d.ts +14 -1
- package/lib/physical-name.d.ts.map +1 -1
- package/lib/physical-name.js +41 -2
- package/lib/physical-name.js.map +1 -1
- package/lib/plan.d.ts +84 -58
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +504 -166
- package/lib/plan.js.map +1 -1
- package/lib/policy.d.ts +3 -4
- package/lib/policy.d.ts.map +1 -1
- package/lib/policy.js +0 -1
- package/lib/policy.js.map +1 -1
- package/lib/provider.d.ts +39 -24
- package/lib/provider.d.ts.map +1 -1
- package/lib/provider.js +9 -0
- package/lib/provider.js.map +1 -1
- package/lib/ref.d.ts +14 -0
- package/lib/ref.d.ts.map +1 -0
- package/lib/ref.js +21 -0
- package/lib/ref.js.map +1 -0
- package/lib/resource.d.ts +13 -8
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js.map +1 -1
- package/lib/runtime.d.ts +7 -6
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js.map +1 -1
- package/lib/service.d.ts +9 -6
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js.map +1 -1
- package/lib/stack.d.ts +60 -0
- package/lib/stack.d.ts.map +1 -0
- package/lib/stack.js +11 -0
- package/lib/stack.js.map +1 -0
- package/lib/stage.d.ts +39 -0
- package/lib/stage.d.ts.map +1 -0
- package/lib/stage.js +32 -0
- package/lib/stage.js.map +1 -0
- package/lib/state.d.ts +135 -17
- package/lib/state.d.ts.map +1 -1
- package/lib/state.js +34 -30
- package/lib/state.js.map +1 -1
- package/lib/tags.d.ts +15 -0
- package/lib/tags.d.ts.map +1 -1
- package/lib/tags.js +27 -0
- package/lib/tags.js.map +1 -1
- package/lib/test.d.ts +25 -4
- package/lib/test.d.ts.map +1 -1
- package/lib/test.js +54 -14
- package/lib/test.js.map +1 -1
- package/lib/todo.d.ts +3 -0
- package/lib/todo.d.ts.map +1 -0
- package/lib/todo.js +3 -0
- package/lib/todo.js.map +1 -0
- package/lib/tsconfig.test.tsbuildinfo +1 -1
- package/lib/type.d.ts +3 -0
- package/lib/type.d.ts.map +1 -1
- package/lib/unknown.d.ts +4 -0
- package/lib/unknown.d.ts.map +1 -0
- package/lib/unknown.js +4 -0
- package/lib/unknown.js.map +1 -0
- package/lib/user.d.ts +3 -0
- package/lib/user.d.ts.map +1 -0
- package/lib/user.js +3 -0
- package/lib/user.js.map +1 -0
- package/lib/util.d.ts +6 -0
- package/lib/util.d.ts.map +1 -0
- package/lib/util.js +9 -0
- package/lib/util.js.map +1 -0
- package/package.json +18 -12
- package/src/$.ts +17 -0
- package/src/app.ts +3 -32
- package/src/apply.ts +824 -452
- package/src/assert-never.ts +18 -0
- package/src/aws/account.ts +23 -3
- package/src/aws/client.ts +0 -1
- package/src/aws/config.ts +16 -0
- package/src/aws/credentials.ts +212 -177
- package/src/aws/dynamodb/index.ts +3 -3
- package/src/aws/dynamodb/table.get-item.ts +5 -9
- package/src/aws/dynamodb/table.provider.ts +36 -39
- package/src/aws/dynamodb/table.ts +29 -84
- package/src/aws/ec2/index.ts +12 -0
- package/src/aws/ec2/internet-gateway.provider.ts +316 -0
- package/src/aws/ec2/internet-gateway.ts +79 -0
- package/src/aws/ec2/route-table-association.provider.ts +214 -0
- package/src/aws/ec2/route-table-association.ts +82 -0
- package/src/aws/ec2/route-table.provider.ts +306 -0
- package/src/aws/ec2/route-table.ts +175 -0
- package/src/aws/ec2/route.provider.ts +213 -0
- package/src/aws/ec2/route.ts +192 -0
- package/src/aws/ec2/subnet.provider.ts +358 -0
- package/src/aws/ec2/subnet.ts +213 -0
- package/src/aws/ec2/vpc.provider.ts +58 -50
- package/src/aws/ec2/vpc.ts +21 -8
- package/src/aws/index.ts +49 -40
- package/src/aws/lambda/consume.ts +8 -7
- package/src/aws/lambda/function.handler.ts +1 -1
- package/src/aws/lambda/function.invoke.ts +6 -2
- package/src/aws/lambda/function.provider.ts +41 -32
- package/src/aws/lambda/function.ts +7 -4
- package/src/aws/lambda/index.ts +2 -0
- package/src/aws/profile.ts +1 -4
- package/src/aws/region.ts +42 -3
- package/src/aws/sqs/index.ts +2 -0
- package/src/aws/sqs/queue.consume.ts +1 -1
- package/src/aws/sqs/queue.event-source.ts +29 -55
- package/src/aws/sqs/queue.provider.ts +10 -2
- package/src/aws/sqs/queue.send-message.ts +5 -8
- package/src/aws/sqs/queue.ts +9 -4
- package/src/binding.ts +19 -19
- package/src/cli/components/ApprovePlan.tsx +2 -2
- package/src/cli/components/Plan.tsx +3 -2
- package/src/cli/components/PlanProgress.tsx +32 -14
- package/src/cli/index.ts +2 -6
- package/src/cli/ink-service.tsx +61 -0
- package/src/cli/service.ts +23 -0
- package/src/cloudflare/account.ts +37 -0
- package/src/cloudflare/api.ts +33 -29
- package/src/cloudflare/config.ts +7 -0
- package/src/cloudflare/index.ts +3 -1
- package/src/cloudflare/kv/namespace.binding.ts +3 -1
- package/src/cloudflare/kv/namespace.provider.ts +10 -8
- package/src/cloudflare/kv/namespace.ts +3 -2
- package/src/cloudflare/live.ts +11 -17
- package/src/cloudflare/r2/bucket.binding.ts +3 -1
- package/src/cloudflare/r2/bucket.provider.ts +16 -9
- package/src/cloudflare/r2/bucket.ts +8 -2
- package/src/cloudflare/worker/assets.fetch.ts +3 -1
- package/src/cloudflare/worker/assets.provider.ts +1 -1
- package/src/cloudflare/worker/index.ts +0 -2
- package/src/cloudflare/worker/worker.handler.ts +1 -1
- package/src/cloudflare/worker/worker.provider.ts +21 -14
- package/src/cloudflare/worker/worker.serve.ts +5 -2
- package/src/cloudflare/worker/worker.ts +4 -3
- package/src/data.ts +18 -0
- package/src/destroy.ts +1 -5
- package/src/diff.ts +48 -0
- package/src/env.ts +20 -32
- package/src/event.ts +6 -0
- package/src/exports.ts +21 -0
- package/src/index.ts +10 -5
- package/src/input.ts +81 -0
- package/src/instance-id.ts +16 -0
- package/src/output.ts +542 -0
- package/src/physical-name.ts +57 -2
- package/src/plan.ts +757 -278
- package/src/policy.ts +3 -5
- package/src/provider.ts +70 -31
- package/src/ref.ts +48 -0
- package/src/resource.ts +70 -10
- package/src/runtime.ts +15 -8
- package/src/service.ts +11 -7
- package/src/stack.ts +116 -0
- package/src/stage.ts +85 -0
- package/src/state.ts +269 -76
- package/src/tags.ts +31 -0
- package/src/test.ts +118 -17
- package/src/todo.ts +4 -0
- package/src/type.ts +4 -0
- package/src/unknown.ts +6 -0
- package/src/user.ts +4 -0
- package/src/util.ts +21 -0
- package/lib/approve.d.ts +0 -15
- package/lib/approve.d.ts.map +0 -1
- package/lib/approve.js +0 -7
- package/lib/approve.js.map +0 -1
- package/lib/cli/approve.d.ts +0 -4
- package/lib/cli/approve.d.ts.map +0 -1
- package/lib/cli/approve.js +0 -18
- package/lib/cli/approve.js.map +0 -1
- package/lib/cli/clack.d.ts +0 -14
- package/lib/cli/clack.d.ts.map +0 -1
- package/lib/cli/clack.js +0 -12
- package/lib/cli/clack.js.map +0 -1
- package/lib/cli/main.d.ts +0 -2
- package/lib/cli/main.d.ts.map +0 -1
- package/lib/cli/main.js +0 -1
- package/lib/cli/main.js.map +0 -1
- package/lib/cli/plan.d.ts +0 -13
- package/lib/cli/plan.d.ts.map +0 -1
- package/lib/cli/plan.js +0 -1
- package/lib/cli/plan.js.map +0 -1
- package/lib/cli/progress.d.ts +0 -7
- package/lib/cli/progress.d.ts.map +0 -1
- package/lib/cli/progress.js +0 -30
- package/lib/cli/progress.js.map +0 -1
- package/lib/cli/spinner.d.ts +0 -2
- package/lib/cli/spinner.d.ts.map +0 -1
- package/lib/cli/spinner.js +0 -13
- package/lib/cli/spinner.js.map +0 -1
- package/src/approve.ts +0 -13
- package/src/cli/approve.tsx +0 -30
- package/src/cli/clack.ts +0 -22
- package/src/cli/main.ts +0 -0
- package/src/cli/plan.ts +0 -16
- package/src/cli/progress.tsx +0 -46
- package/src/cli/spinner.ts +0 -14
package/src/policy.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
|
|
|
3
3
|
import * as S from "effect/Schema";
|
|
4
4
|
import { type AnyBinding, type Bind } from "./binding.ts";
|
|
5
5
|
import type { Capability } from "./capability.ts";
|
|
6
|
-
import type { Runtime } from "./runtime.ts";
|
|
6
|
+
import type { IRuntime, Runtime } from "./runtime.ts";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A Policy binds a set of Capbilities (e.g SQS.SendMessage, SQS.Consume, etc.) to a
|
|
@@ -15,10 +15,11 @@ import type { Runtime } from "./runtime.ts";
|
|
|
15
15
|
* A Policy is invariant over the set of Capabilities to ensure least-privilege.
|
|
16
16
|
*/
|
|
17
17
|
export interface Policy<
|
|
18
|
-
F extends
|
|
18
|
+
F extends IRuntime,
|
|
19
19
|
in out Capabilities,
|
|
20
20
|
Tags = unknown,
|
|
21
21
|
> {
|
|
22
|
+
readonly kind: "alchemy/Policy";
|
|
22
23
|
readonly runtime: F;
|
|
23
24
|
readonly tags: Tags[];
|
|
24
25
|
readonly capabilities: Capabilities[];
|
|
@@ -34,9 +35,6 @@ export interface Policy<
|
|
|
34
35
|
>;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
export type $<T> = Instance<T>;
|
|
38
|
-
export const $ = Policy;
|
|
39
|
-
|
|
40
38
|
type BindingTags<B extends AnyBinding> = B extends any
|
|
41
39
|
? Bind<B["runtime"], B["capability"], Extract<B["tag"], string>>
|
|
42
40
|
: never;
|
package/src/provider.ts
CHANGED
|
@@ -1,74 +1,113 @@
|
|
|
1
1
|
import * as Context from "effect/Context";
|
|
2
|
-
import
|
|
3
|
-
import type { ScopedPlanStatusSession } from "./
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import type { ScopedPlanStatusSession } from "./cli/service.ts";
|
|
4
|
+
import type { Diff } from "./diff.ts";
|
|
5
|
+
import type { Input } from "./input.ts";
|
|
4
6
|
import type { Resource } from "./resource.ts";
|
|
5
7
|
import type { Runtime } from "./runtime.ts";
|
|
8
|
+
import type { Service } from "./service.ts";
|
|
6
9
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
export interface Provider<R extends Resource | Service>
|
|
11
|
+
extends Context.TagClass<
|
|
12
|
+
Provider<R>,
|
|
13
|
+
R["type"],
|
|
14
|
+
ProviderService<any>
|
|
15
|
+
// TODO(sam): we are using any here because the R["type"] is enough and gaining access to the sub type (e.g. SQS.Queue)
|
|
16
|
+
// is currently not possible in the current approach
|
|
12
17
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
deleteFirst?: undefined;
|
|
17
|
-
}
|
|
18
|
-
| {
|
|
19
|
-
action: "replace";
|
|
20
|
-
deleteFirst?: boolean;
|
|
21
|
-
};
|
|
18
|
+
// preferred:
|
|
19
|
+
// ProviderService<R>
|
|
20
|
+
> {}
|
|
22
21
|
|
|
23
22
|
type BindingData<Res extends Resource> = [Res] extends [Runtime]
|
|
24
23
|
? Res["binding"][]
|
|
25
24
|
: any[];
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
type Props<Res extends Resource> = Input.ResolveOpaque<Res["props"]>;
|
|
27
|
+
|
|
28
|
+
export interface ProviderService<
|
|
29
|
+
Res extends Resource = Resource,
|
|
30
|
+
ReadReq = never,
|
|
31
|
+
DiffReq = never,
|
|
32
|
+
PrecreateReq = never,
|
|
33
|
+
CreateReq = never,
|
|
34
|
+
UpdateReq = never,
|
|
35
|
+
DeleteReq = never,
|
|
36
|
+
> {
|
|
37
|
+
/**
|
|
38
|
+
* The version of the provider.
|
|
39
|
+
*
|
|
40
|
+
* @default 0
|
|
41
|
+
*/
|
|
42
|
+
version?: number;
|
|
28
43
|
// tail();
|
|
29
44
|
// watch();
|
|
30
45
|
// replace(): Effect.Effect<void, never, never>;
|
|
31
|
-
|
|
32
46
|
// different interface that is persistent, watching, reloads
|
|
33
47
|
// run?() {}
|
|
34
48
|
read?(input: {
|
|
35
49
|
id: string;
|
|
36
|
-
|
|
50
|
+
instanceId: string;
|
|
51
|
+
olds: Props<Res> | undefined;
|
|
37
52
|
// what is the ARN?
|
|
38
53
|
output: Res["attr"] | undefined; // current state -> synced state
|
|
39
54
|
session: ScopedPlanStatusSession;
|
|
40
55
|
bindings: BindingData<Res>;
|
|
41
|
-
}): Effect.Effect<Res["attr"] | undefined, any,
|
|
56
|
+
}): Effect.Effect<Res["attr"] | undefined, any, ReadReq>;
|
|
57
|
+
/**
|
|
58
|
+
* Properties that are always stable across any update.
|
|
59
|
+
*/
|
|
60
|
+
stables?: Extract<keyof Res["attr"], string>[];
|
|
42
61
|
diff?(input: {
|
|
43
62
|
id: string;
|
|
44
|
-
olds: Res
|
|
63
|
+
olds: Props<Res>;
|
|
64
|
+
instanceId: string;
|
|
65
|
+
// Note: we do not resolve (Props<Res>) here because diff runs during plan
|
|
66
|
+
// -> we need a way for the diff handlers to work with Outputs
|
|
45
67
|
news: Res["props"];
|
|
46
68
|
output: Res["attr"];
|
|
47
|
-
}): Effect.Effect<Diff | void, never,
|
|
69
|
+
}): Effect.Effect<Diff | void, never, DiffReq>;
|
|
48
70
|
precreate?(input: {
|
|
49
71
|
id: string;
|
|
50
|
-
news: Res
|
|
72
|
+
news: Props<Res>;
|
|
73
|
+
instanceId: string;
|
|
51
74
|
session: ScopedPlanStatusSession;
|
|
52
|
-
}): Effect.Effect<Res["attr"], any,
|
|
75
|
+
}): Effect.Effect<Res["attr"], any, PrecreateReq>;
|
|
53
76
|
create(input: {
|
|
54
77
|
id: string;
|
|
55
|
-
|
|
78
|
+
instanceId: string;
|
|
79
|
+
news: Props<Res>;
|
|
56
80
|
session: ScopedPlanStatusSession;
|
|
57
81
|
bindings: BindingData<Res>;
|
|
58
|
-
}): Effect.Effect<Res["attr"], any,
|
|
82
|
+
}): Effect.Effect<Res["attr"], any, CreateReq>;
|
|
59
83
|
update(input: {
|
|
60
84
|
id: string;
|
|
61
|
-
|
|
62
|
-
|
|
85
|
+
instanceId: string;
|
|
86
|
+
news: Props<Res>;
|
|
87
|
+
olds: Props<Res>;
|
|
63
88
|
output: Res["attr"];
|
|
64
89
|
session: ScopedPlanStatusSession;
|
|
65
90
|
bindings: BindingData<Res>;
|
|
66
|
-
}): Effect.Effect<Res["attr"], any,
|
|
91
|
+
}): Effect.Effect<Res["attr"], any, UpdateReq>;
|
|
67
92
|
delete(input: {
|
|
68
93
|
id: string;
|
|
69
|
-
|
|
94
|
+
instanceId: string;
|
|
95
|
+
olds: Props<Res>;
|
|
70
96
|
output: Res["attr"];
|
|
71
97
|
session: ScopedPlanStatusSession;
|
|
72
98
|
bindings: BindingData<Res>;
|
|
73
|
-
}): Effect.Effect<void, any,
|
|
99
|
+
}): Effect.Effect<void, any, DeleteReq>;
|
|
74
100
|
}
|
|
101
|
+
|
|
102
|
+
export const getProviderByType = Effect.fnUntraced(function* (
|
|
103
|
+
resourceType: string,
|
|
104
|
+
) {
|
|
105
|
+
const context = yield* Effect.context<never>();
|
|
106
|
+
const provider: ProviderService = context.unsafeMap.get(resourceType);
|
|
107
|
+
if (!provider) {
|
|
108
|
+
return yield* Effect.die(
|
|
109
|
+
new Error(`Provider not found for ${resourceType}`),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
return provider;
|
|
113
|
+
});
|
package/src/ref.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Resource, AnyResource } from "./resource.ts";
|
|
2
|
+
import * as Output from "./output.ts";
|
|
3
|
+
|
|
4
|
+
// special runtime-only symbol for probing the Ref proxy for its metadata
|
|
5
|
+
const RefMetadata = Symbol.for("alchemy/RefMetadata");
|
|
6
|
+
|
|
7
|
+
export const isRef = (s: any): s is Ref<any> =>
|
|
8
|
+
s && s[RefMetadata] !== undefined;
|
|
9
|
+
|
|
10
|
+
export const getRefMetadata = <R extends Resource<string, string, any, any>>(
|
|
11
|
+
ref: Ref<R>,
|
|
12
|
+
): RefMetadata<R> => (ref as any)[RefMetadata];
|
|
13
|
+
|
|
14
|
+
export interface Ref<
|
|
15
|
+
R extends Resource<string, string, any, any> = AnyResource,
|
|
16
|
+
> {
|
|
17
|
+
/** @internal phantom */
|
|
18
|
+
Ref: R;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface RefMetadata<R extends Resource<string, string, any, any>> {
|
|
22
|
+
stack?: string;
|
|
23
|
+
stage?: string;
|
|
24
|
+
resourceId: R["id"];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const ref = <R extends Resource<string, string, any, any>>({
|
|
28
|
+
stack,
|
|
29
|
+
resourceId,
|
|
30
|
+
stage,
|
|
31
|
+
}: RefMetadata<R>): Ref<R> => {
|
|
32
|
+
const ref = new Proxy(
|
|
33
|
+
{},
|
|
34
|
+
{
|
|
35
|
+
get: (_, prop) => {
|
|
36
|
+
if (prop === RefMetadata) {
|
|
37
|
+
return {
|
|
38
|
+
stack,
|
|
39
|
+
stage,
|
|
40
|
+
resourceId,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return (Output.of(ref) as any)[prop];
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
) as Ref<R>;
|
|
47
|
+
return ref;
|
|
48
|
+
};
|
package/src/resource.ts
CHANGED
|
@@ -9,28 +9,87 @@ export const isResource = (r: any): r is Resource => {
|
|
|
9
9
|
);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export type AnyResource = Resource<string, string, any, any>;
|
|
13
|
+
|
|
14
|
+
export interface IResource<
|
|
13
15
|
Type extends string = string,
|
|
14
16
|
ID extends string = string,
|
|
15
17
|
Props = unknown,
|
|
16
18
|
Attrs = unknown,
|
|
19
|
+
Base = unknown,
|
|
17
20
|
> {
|
|
18
21
|
id: ID;
|
|
19
22
|
type: Type;
|
|
23
|
+
Props: unknown;
|
|
20
24
|
props: Props;
|
|
25
|
+
base: Base;
|
|
26
|
+
/** @internal phantom */
|
|
21
27
|
attr: Attrs;
|
|
22
|
-
parent: unknown;
|
|
23
|
-
// oxlint-disable-next-line no-misused-new
|
|
24
|
-
new (): Resource<Type, ID, Props, Attrs>;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
export interface
|
|
30
|
+
export interface Resource<
|
|
31
|
+
Type extends string = string,
|
|
32
|
+
ID extends string = string,
|
|
33
|
+
Props = unknown,
|
|
34
|
+
Attrs = unknown,
|
|
35
|
+
Base = unknown,
|
|
36
|
+
> extends IResource<Type, ID, Props, Attrs, Base> {
|
|
37
|
+
new (): Resource<Type, ID, Props, Attrs, Base>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ResourceTags<R extends Resource<string, string, any, any>> {
|
|
28
41
|
of<S extends ProviderService<R>>(service: S): S;
|
|
29
|
-
tag:
|
|
30
|
-
effect<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
tag: Provider<R>;
|
|
43
|
+
effect<
|
|
44
|
+
Err,
|
|
45
|
+
Req,
|
|
46
|
+
ReadReq = never,
|
|
47
|
+
DiffReq = never,
|
|
48
|
+
PrecreateReq = never,
|
|
49
|
+
CreateReq = never,
|
|
50
|
+
UpdateReq = never,
|
|
51
|
+
DeleteReq = never,
|
|
52
|
+
>(
|
|
53
|
+
eff: Effect<
|
|
54
|
+
ProviderService<
|
|
55
|
+
R,
|
|
56
|
+
ReadReq,
|
|
57
|
+
DiffReq,
|
|
58
|
+
PrecreateReq,
|
|
59
|
+
CreateReq,
|
|
60
|
+
UpdateReq,
|
|
61
|
+
DeleteReq
|
|
62
|
+
>,
|
|
63
|
+
Err,
|
|
64
|
+
Req
|
|
65
|
+
>,
|
|
66
|
+
): Layer.Layer<
|
|
67
|
+
Provider<R>,
|
|
68
|
+
Err,
|
|
69
|
+
Req | ReadReq | DiffReq | PrecreateReq | CreateReq | UpdateReq | DeleteReq
|
|
70
|
+
>;
|
|
71
|
+
succeed<
|
|
72
|
+
ReadReq = never,
|
|
73
|
+
DiffReq = never,
|
|
74
|
+
PrecreateReq = never,
|
|
75
|
+
CreateReq = never,
|
|
76
|
+
UpdateReq = never,
|
|
77
|
+
DeleteReq = never,
|
|
78
|
+
>(
|
|
79
|
+
service: ProviderService<
|
|
80
|
+
R,
|
|
81
|
+
ReadReq,
|
|
82
|
+
DiffReq,
|
|
83
|
+
PrecreateReq,
|
|
84
|
+
CreateReq,
|
|
85
|
+
UpdateReq,
|
|
86
|
+
DeleteReq
|
|
87
|
+
>,
|
|
88
|
+
): Layer.Layer<
|
|
89
|
+
Provider<R>,
|
|
90
|
+
never,
|
|
91
|
+
ReadReq | DiffReq | PrecreateReq | CreateReq | UpdateReq | DeleteReq
|
|
92
|
+
>;
|
|
34
93
|
}
|
|
35
94
|
|
|
36
95
|
export const Resource = <Ctor extends (id: string, props: any) => Resource>(
|
|
@@ -56,6 +115,7 @@ export const Resource = <Ctor extends (id: string, props: any) => Resource>(
|
|
|
56
115
|
};
|
|
57
116
|
} as unknown as Ctor & {
|
|
58
117
|
type: ReturnType<Ctor>["type"];
|
|
118
|
+
parent: ReturnType<Ctor>;
|
|
59
119
|
new (): ReturnType<Ctor> & {
|
|
60
120
|
parent: ReturnType<Ctor>;
|
|
61
121
|
};
|
package/src/runtime.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as Layer from "effect/Layer";
|
|
|
5
5
|
import type { Capability } from "./capability.ts";
|
|
6
6
|
import type { Policy } from "./policy.ts";
|
|
7
7
|
import type { ProviderService } from "./provider.ts";
|
|
8
|
-
import type { Resource, ResourceTags } from "./resource.ts";
|
|
8
|
+
import type { IResource, Resource, ResourceTags } from "./resource.ts";
|
|
9
9
|
import type { IService, Service } from "./service.ts";
|
|
10
10
|
|
|
11
11
|
export type RuntimeHandler<
|
|
@@ -37,21 +37,30 @@ export declare namespace Runtime {
|
|
|
37
37
|
|
|
38
38
|
export type AnyRuntime = Runtime<string>;
|
|
39
39
|
|
|
40
|
-
export interface RuntimeProps<Run extends
|
|
40
|
+
export interface RuntimeProps<Run extends IRuntime, Req> {
|
|
41
41
|
bindings: Policy<Run, Extract<Req, Capability>, unknown>;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export interface
|
|
44
|
+
export interface IRuntime<
|
|
45
45
|
Type extends string = string,
|
|
46
46
|
Handler = unknown,
|
|
47
47
|
Props = unknown,
|
|
48
|
-
> extends
|
|
48
|
+
> extends IResource<Type, string, Props> {
|
|
49
49
|
type: Type;
|
|
50
50
|
props: Props;
|
|
51
51
|
handler: Handler;
|
|
52
52
|
binding: unknown;
|
|
53
53
|
/** @internal phantom */
|
|
54
54
|
capability: unknown;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface Runtime<
|
|
58
|
+
Type extends string = string,
|
|
59
|
+
Handler = unknown,
|
|
60
|
+
Props = unknown,
|
|
61
|
+
> extends IRuntime<Type, Handler, Props>,
|
|
62
|
+
Resource<Type, string, Props> {
|
|
63
|
+
provider: ResourceTags<this>;
|
|
55
64
|
<
|
|
56
65
|
const ID extends string,
|
|
57
66
|
Inputs extends any[],
|
|
@@ -75,9 +84,7 @@ export interface Runtime<
|
|
|
75
84
|
|
|
76
85
|
export const Runtime =
|
|
77
86
|
<const Type extends string>(type: Type) =>
|
|
78
|
-
<Self extends Runtime>(): Self
|
|
79
|
-
provider: ResourceTags<Self>;
|
|
80
|
-
} => {
|
|
87
|
+
<Self extends Runtime>(): Self => {
|
|
81
88
|
const Tag = Context.Tag(type)();
|
|
82
89
|
const provider = {
|
|
83
90
|
tag: Tag,
|
|
@@ -122,7 +129,7 @@ export const Runtime =
|
|
|
122
129
|
parent: self,
|
|
123
130
|
// @ts-expect-error
|
|
124
131
|
provider,
|
|
125
|
-
} satisfies IService<string, Self, any, any>,
|
|
132
|
+
} satisfies IService<string, Self, any, any, Self>,
|
|
126
133
|
);
|
|
127
134
|
}
|
|
128
135
|
},
|
package/src/service.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { Effect } from "effect/Effect";
|
|
2
2
|
import type { Capability } from "./capability.ts";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { IResource } from "./resource.ts";
|
|
4
|
+
import type { IRuntime, RuntimeHandler, RuntimeProps } from "./runtime.ts";
|
|
5
5
|
|
|
6
6
|
export interface IService<
|
|
7
7
|
ID extends string = string,
|
|
8
|
-
F extends
|
|
8
|
+
F extends IRuntime = IRuntime,
|
|
9
9
|
Handler extends RuntimeHandler = RuntimeHandler,
|
|
10
10
|
Props extends RuntimeProps<F, any> = RuntimeProps<F, any>,
|
|
11
11
|
Attr = (F & { props: Props })["attr"],
|
|
12
|
-
|
|
12
|
+
Base = unknown,
|
|
13
|
+
> extends IResource<F["type"], ID, Props, Attr, F> {
|
|
13
14
|
kind: "Service";
|
|
14
15
|
type: F["type"];
|
|
15
16
|
id: ID;
|
|
@@ -39,16 +40,19 @@ export interface IService<
|
|
|
39
40
|
attr: Attr;
|
|
40
41
|
/** @internal phantom type of this resource's parent */
|
|
41
42
|
parent: unknown;
|
|
43
|
+
new (): Service<ID, F, Handler, Props, Attr, Base>;
|
|
42
44
|
}
|
|
43
45
|
|
|
46
|
+
export interface AnyService extends IService {}
|
|
47
|
+
|
|
44
48
|
export interface Service<
|
|
45
49
|
ID extends string = string,
|
|
46
|
-
F extends
|
|
50
|
+
F extends IRuntime = IRuntime,
|
|
47
51
|
Handler extends RuntimeHandler = RuntimeHandler,
|
|
48
52
|
Props extends RuntimeProps<F, any> = RuntimeProps<F, any>,
|
|
49
53
|
Attr = (F & { props: Props })["attr"],
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
Base = unknown,
|
|
55
|
+
> extends IService<ID, F, Handler, Props, Attr, Base> {}
|
|
52
56
|
|
|
53
57
|
export const isService = (resource: any): resource is IService => {
|
|
54
58
|
return resource && resource.kind === "Service";
|
package/src/stack.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { HttpClient } from "@effect/platform/HttpClient";
|
|
2
|
+
import { FileSystem } from "@effect/platform/FileSystem";
|
|
3
|
+
import { Path } from "@effect/platform/Path";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as App from "./app.ts";
|
|
7
|
+
import { type AppliedPlan } from "./apply.ts";
|
|
8
|
+
import { DotAlchemy } from "./dot-alchemy.ts";
|
|
9
|
+
import type { DerivePlan, Providers, TraverseResources } from "./plan.ts";
|
|
10
|
+
import type { Instance } from "./policy.ts";
|
|
11
|
+
import type { AnyResource } from "./resource.ts";
|
|
12
|
+
import type { AnyService } from "./service.ts";
|
|
13
|
+
import { type StageConfig, type Stages } from "./stage.ts";
|
|
14
|
+
import * as State from "./state.ts";
|
|
15
|
+
import type { Ref } from "./ref.ts";
|
|
16
|
+
import type { CLI } from "./cli/service.ts";
|
|
17
|
+
|
|
18
|
+
export const defineStack = <
|
|
19
|
+
const Name extends string,
|
|
20
|
+
Resources extends (AnyResource | AnyService)[],
|
|
21
|
+
Req = never,
|
|
22
|
+
Err = never,
|
|
23
|
+
>(
|
|
24
|
+
stack: StackConfig<Name, Resources, Req, Err>,
|
|
25
|
+
): Stack<Name, Instance<Resources[number]>, Req, Err> => stack as any;
|
|
26
|
+
|
|
27
|
+
export type StackConfig<
|
|
28
|
+
Name extends string,
|
|
29
|
+
Resources extends (AnyResource | AnyService)[] = (AnyResource | AnyService)[],
|
|
30
|
+
StagesReq = never,
|
|
31
|
+
StagesErr = never,
|
|
32
|
+
TapReq = never,
|
|
33
|
+
TapErr = never,
|
|
34
|
+
> = {
|
|
35
|
+
name: Name;
|
|
36
|
+
stages: Stages<StagesReq, StagesErr>;
|
|
37
|
+
resources: Resources;
|
|
38
|
+
providers: Layer.Layer<
|
|
39
|
+
Providers<Instance<Resources[number]>>,
|
|
40
|
+
any,
|
|
41
|
+
App.App | FileSystem | Path | DotAlchemy | HttpClient
|
|
42
|
+
>;
|
|
43
|
+
state?: Layer.Layer<State.State>;
|
|
44
|
+
tap?: (
|
|
45
|
+
output: StackOutput<Instance<Resources[number]>>,
|
|
46
|
+
) => Effect.Effect<any, TapErr, TapReq>;
|
|
47
|
+
} & (Exclude<NoInfer<StagesReq | TapReq>, BuiltInServices> extends never
|
|
48
|
+
? {
|
|
49
|
+
layers?: never;
|
|
50
|
+
}
|
|
51
|
+
: {
|
|
52
|
+
layers: Layer.Layer<
|
|
53
|
+
Exclude<StagesReq | TapReq, BuiltInServices>,
|
|
54
|
+
never,
|
|
55
|
+
never
|
|
56
|
+
>;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export type StackOutput<Resources extends AnyResource | AnyService> =
|
|
60
|
+
AppliedPlan<DerivePlan<Resources>>;
|
|
61
|
+
|
|
62
|
+
export type Stack<
|
|
63
|
+
Name extends string = string,
|
|
64
|
+
Resources extends AnyResource | AnyService = any,
|
|
65
|
+
StagesReq = any,
|
|
66
|
+
StagesErr = any,
|
|
67
|
+
TapReq = any,
|
|
68
|
+
TapErr = any,
|
|
69
|
+
> = {
|
|
70
|
+
name: Name;
|
|
71
|
+
stages: Stages<StagesReq, StagesErr>;
|
|
72
|
+
resources: Resources[];
|
|
73
|
+
providers: Layer.Layer<Providers<Resources>, any, BuiltInServices>;
|
|
74
|
+
state?: Layer.Layer<State.State>;
|
|
75
|
+
cli?: Layer.Layer<CLI>;
|
|
76
|
+
tap?: (output: StackOutput<Resources>) => Effect.Effect<void, TapErr, TapReq>;
|
|
77
|
+
} & (Exclude<StagesReq | TapReq, BuiltInServices> extends never
|
|
78
|
+
? {
|
|
79
|
+
layers?: never;
|
|
80
|
+
}
|
|
81
|
+
: {
|
|
82
|
+
layers: Layer.Layer<
|
|
83
|
+
Exclude<StagesReq | TapReq, BuiltInServices>,
|
|
84
|
+
never,
|
|
85
|
+
never
|
|
86
|
+
>;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export type StackName<S extends Stack> =
|
|
90
|
+
S extends Stack<infer Name, infer _> ? Name : never;
|
|
91
|
+
|
|
92
|
+
export type StackResources<S extends Stack> =
|
|
93
|
+
S extends Stack<infer _, infer Resources> ? Resources : never;
|
|
94
|
+
|
|
95
|
+
export type BuiltInServices =
|
|
96
|
+
| App.App
|
|
97
|
+
| FileSystem
|
|
98
|
+
| Path
|
|
99
|
+
| DotAlchemy
|
|
100
|
+
| HttpClient;
|
|
101
|
+
|
|
102
|
+
export interface StackRefConfig<S extends Stack> extends StageConfig {
|
|
103
|
+
stack: S extends Stack<infer Name, any> ? Name : never;
|
|
104
|
+
stage?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type StackRef<Resources extends AnyResource | AnyService> = {
|
|
108
|
+
[Id in keyof AsRecord<Resources>]: Ref<AsRecord<Resources>[Id]>;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type AsRecord<Resources extends AnyResource | AnyService> = {
|
|
112
|
+
[Id in TraverseResources<Resources>["id"]]: Extract<
|
|
113
|
+
TraverseResources<Resources>,
|
|
114
|
+
{ id: Id }
|
|
115
|
+
>;
|
|
116
|
+
};
|
package/src/stage.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import type { StackName, StackRef, Stack, StackResources } from "./stack.ts";
|
|
4
|
+
import { ref } from "./ref.ts";
|
|
5
|
+
|
|
6
|
+
export interface StageConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Whether to retain the stage when destroying the stack.
|
|
9
|
+
*
|
|
10
|
+
* @default - true if the current stage starts with "prod"
|
|
11
|
+
*/
|
|
12
|
+
retain?: boolean;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Whether to adopt resources that already exist during the created phase.
|
|
16
|
+
*
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
adopt?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class Stage extends Context.Tag("Stage")<Stage, string>() {}
|
|
23
|
+
|
|
24
|
+
export type Stages<Req = never, Err = never> = {
|
|
25
|
+
config: (stage: string) => StageConfig | Effect.Effect<StageConfig, Err, Req>;
|
|
26
|
+
ref<S extends Stack>(name: StackName<S>): StackRefs<S>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const defineStages = <Req = never, Err = never>(
|
|
30
|
+
config: (stage: string) => StageConfig | Effect.Effect<StageConfig, Err, Req>,
|
|
31
|
+
): Stages<Req, Err> => ({
|
|
32
|
+
config,
|
|
33
|
+
ref: <S extends Stack>(stack: StackName<NoInfer<S>>): StackRefs<S> => {
|
|
34
|
+
const proxy = (get: (id: string) => any) =>
|
|
35
|
+
new Proxy({}, { get: (_, id: string) => get(id) });
|
|
36
|
+
const proxyStage = (stage: string) =>
|
|
37
|
+
proxy((resourceId: string) =>
|
|
38
|
+
ref({
|
|
39
|
+
stack,
|
|
40
|
+
stage,
|
|
41
|
+
resourceId,
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
return proxy((stage) =>
|
|
45
|
+
stage == "as"
|
|
46
|
+
? (builders: StackRefBuilders) =>
|
|
47
|
+
proxy((stage: string) => {
|
|
48
|
+
if (stage in builders) {
|
|
49
|
+
const builder = builders[stage as keyof typeof builders];
|
|
50
|
+
return typeof builder === "string"
|
|
51
|
+
? proxyStage(stage)
|
|
52
|
+
: (...args: any[]) => proxyStage(builder(...args));
|
|
53
|
+
}
|
|
54
|
+
return proxyStage(stage);
|
|
55
|
+
})
|
|
56
|
+
: proxy((resourceId: string) =>
|
|
57
|
+
ref({
|
|
58
|
+
stack,
|
|
59
|
+
stage,
|
|
60
|
+
resourceId,
|
|
61
|
+
}),
|
|
62
|
+
),
|
|
63
|
+
) as StackRefs<S>;
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export interface StackRefBuilders {
|
|
68
|
+
[stage: string]: string | ((...args: any[]) => string);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type StackRefs<S extends Stack> = {
|
|
72
|
+
[stage in string]: StackRef<StackResources<S>>;
|
|
73
|
+
} & {
|
|
74
|
+
as<Builders extends StackRefBuilders>(
|
|
75
|
+
stages?: Builders,
|
|
76
|
+
): {
|
|
77
|
+
[stage in Exclude<string, keyof Builders>]: StackRef<StackResources<S>>;
|
|
78
|
+
} & {
|
|
79
|
+
[builder in keyof Builders]: Builders[builder] extends string
|
|
80
|
+
? StackRef<StackResources<S>>
|
|
81
|
+
: Builders[builder] extends (...args: infer Args) => any
|
|
82
|
+
? (...args: Args) => StackRef<StackResources<S>>
|
|
83
|
+
: never;
|
|
84
|
+
};
|
|
85
|
+
};
|