alchemy-effect 0.2.0 → 0.3.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 +55038 -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 +14 -74
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +62 -57
- 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 +17 -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 +3 -0
- package/lib/aws/ec2/index.d.ts.map +1 -1
- package/lib/aws/ec2/index.js +3 -0
- package/lib/aws/ec2/index.js.map +1 -1
- 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 +12 -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 +3 -4
- package/lib/aws/ec2/vpc.provider.d.ts.map +1 -1
- package/lib/aws/ec2/vpc.provider.js +11 -26
- package/lib/aws/ec2/vpc.provider.js.map +1 -1
- package/lib/aws/index.d.ts +16 -19
- package/lib/aws/index.d.ts.map +1 -1
- package/lib/aws/index.js +7 -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 +5 -4
- package/lib/aws/lambda/function.provider.d.ts.map +1 -1
- package/lib/aws/lambda/function.provider.js +16 -14
- 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 +4 -4
- package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
- package/lib/aws/sqs/queue.provider.js +3 -3
- 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 +265 -224
- 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.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 +8 -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 +8 -7
- 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 +7 -6
- 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 +16 -0
- package/lib/diff.d.ts.map +1 -0
- package/lib/diff.js +9 -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/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/output.d.ts +143 -0
- package/lib/output.d.ts.map +1 -0
- package/lib/output.js +269 -0
- package/lib/output.js.map +1 -0
- package/lib/plan.d.ts +47 -28
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +257 -151
- 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 +14 -16
- package/lib/provider.d.ts.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 +11 -6
- 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 +51 -10
- package/lib/state.d.ts.map +1 -1
- package/lib/state.js +30 -29
- package/lib/state.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/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 +429 -441
- 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 +35 -39
- package/src/aws/dynamodb/table.ts +29 -84
- package/src/aws/ec2/index.ts +4 -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 +20 -36
- package/src/aws/ec2/vpc.ts +19 -8
- package/src/aws/index.ts +46 -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 +28 -21
- 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 +11 -4
- 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 +9 -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 +9 -8
- 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 +16 -13
- 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 +30 -0
- package/src/env.ts +20 -32
- package/src/exports.ts +21 -0
- package/src/index.ts +10 -5
- package/src/input.ts +81 -0
- package/src/output.ts +518 -0
- package/src/plan.ts +380 -192
- package/src/policy.ts +3 -5
- package/src/provider.ts +25 -23
- package/src/ref.ts +48 -0
- package/src/resource.ts +20 -6
- 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 +138 -60
- package/src/test.ts +117 -16
- 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/plan.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Context from "effect/Context";
|
|
2
|
+
import { App } from "./app.ts";
|
|
2
3
|
import * as Data from "effect/Data";
|
|
3
4
|
import * as Effect from "effect/Effect";
|
|
4
5
|
import { omit } from "effect/Struct";
|
|
@@ -8,10 +9,12 @@ import type {
|
|
|
8
9
|
BindingService,
|
|
9
10
|
} from "./binding.ts";
|
|
10
11
|
import type { Capability } from "./capability.ts";
|
|
11
|
-
import type {
|
|
12
|
+
import type { Diff } from "./diff.ts";
|
|
13
|
+
import * as Output from "./output.ts";
|
|
12
14
|
import type { Instance } from "./policy.ts";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
+
import type { Provider } from "./provider.ts";
|
|
16
|
+
import { type ProviderService } from "./provider.ts";
|
|
17
|
+
import type { AnyResource, Resource, ResourceTags } from "./resource.ts";
|
|
15
18
|
import { isService, type IService, type Service } from "./service.ts";
|
|
16
19
|
import { State, StateStoreError, type ResourceState } from "./state.ts";
|
|
17
20
|
|
|
@@ -76,14 +79,14 @@ export const isCRUD = (node: any): node is CRUD => {
|
|
|
76
79
|
/**
|
|
77
80
|
* A node in the plan that represents a resource CRUD operation.
|
|
78
81
|
*/
|
|
79
|
-
export type CRUD<R extends Resource =
|
|
82
|
+
export type CRUD<R extends Resource = AnyResource> =
|
|
80
83
|
| Create<R>
|
|
81
84
|
| Update<R>
|
|
82
85
|
| Delete<R>
|
|
83
86
|
| Replace<R>
|
|
84
87
|
| NoopUpdate<R>;
|
|
85
88
|
|
|
86
|
-
export type Apply<R extends Resource =
|
|
89
|
+
export type Apply<R extends Resource = AnyResource> =
|
|
87
90
|
| Create<R>
|
|
88
91
|
| Update<R>
|
|
89
92
|
| Replace<R>
|
|
@@ -99,109 +102,170 @@ const Node = <T extends Apply>(node: T) => ({
|
|
|
99
102
|
},
|
|
100
103
|
});
|
|
101
104
|
|
|
102
|
-
export type Create<R extends Resource> = {
|
|
105
|
+
export type Create<R extends Resource = AnyResource> = {
|
|
103
106
|
action: "create";
|
|
104
107
|
resource: R;
|
|
105
108
|
news: any;
|
|
106
|
-
provider: ProviderService
|
|
109
|
+
provider: ProviderService<R>;
|
|
107
110
|
attributes: R["attr"];
|
|
108
111
|
bindings: BindNode[];
|
|
109
112
|
};
|
|
110
113
|
|
|
111
|
-
export type Update<R extends Resource> = {
|
|
114
|
+
export type Update<R extends Resource = AnyResource> = {
|
|
112
115
|
action: "update";
|
|
113
116
|
resource: R;
|
|
114
117
|
olds: any;
|
|
115
118
|
news: any;
|
|
116
119
|
output: any;
|
|
117
|
-
provider: ProviderService
|
|
120
|
+
provider: ProviderService<R>;
|
|
118
121
|
attributes: R["attr"];
|
|
119
122
|
bindings: BindNode[];
|
|
120
123
|
};
|
|
121
124
|
|
|
122
|
-
export type Delete<R extends Resource> = {
|
|
125
|
+
export type Delete<R extends Resource = AnyResource> = {
|
|
123
126
|
action: "delete";
|
|
124
127
|
resource: R;
|
|
125
128
|
olds: any;
|
|
126
129
|
output: any;
|
|
127
|
-
provider: ProviderService
|
|
130
|
+
provider: ProviderService<R>;
|
|
128
131
|
bindings: BindNode[];
|
|
129
132
|
attributes: R["attr"];
|
|
130
133
|
downstream: string[];
|
|
131
134
|
};
|
|
132
135
|
|
|
133
|
-
export type NoopUpdate<R extends Resource> = {
|
|
136
|
+
export type NoopUpdate<R extends Resource = AnyResource> = {
|
|
134
137
|
action: "noop";
|
|
135
138
|
resource: R;
|
|
136
139
|
attributes: R["attr"];
|
|
137
140
|
bindings: BindNode[];
|
|
138
141
|
};
|
|
139
142
|
|
|
140
|
-
export type Replace<R extends Resource> = {
|
|
143
|
+
export type Replace<R extends Resource = AnyResource> = {
|
|
141
144
|
action: "replace";
|
|
142
145
|
resource: R;
|
|
143
146
|
olds: any;
|
|
144
147
|
news: any;
|
|
145
148
|
output: any;
|
|
146
|
-
provider: ProviderService
|
|
149
|
+
provider: ProviderService<R>;
|
|
147
150
|
bindings: BindNode[];
|
|
148
151
|
attributes: R["attr"];
|
|
149
152
|
deleteFirst?: boolean;
|
|
150
153
|
};
|
|
151
154
|
|
|
152
|
-
export type
|
|
153
|
-
|
|
155
|
+
export type ResourceGraph<Resources extends Service | Resource> = ToGraph<
|
|
156
|
+
TraverseResources<Resources>
|
|
157
|
+
>;
|
|
158
|
+
|
|
159
|
+
export type TraverseResources<Resources extends Service | Resource> =
|
|
160
|
+
| Resources
|
|
161
|
+
| BoundResources<Resources>
|
|
162
|
+
| TransitiveResources<Resources>;
|
|
163
|
+
|
|
164
|
+
type ToGraph<Resources extends Service | Resource> = {
|
|
165
|
+
[ID in Resources["id"]]: Apply<Extract<Resources, { id: ID }>>;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export type BoundResources<Resources extends Service | Resource> = NeverUnknown<
|
|
169
|
+
Extract<
|
|
170
|
+
Resources,
|
|
171
|
+
IService
|
|
172
|
+
>["props"]["bindings"]["capabilities"][number]["resource"]
|
|
173
|
+
>;
|
|
174
|
+
|
|
175
|
+
// finds transitive dependencies at most two levels deep
|
|
176
|
+
// TODO(sam): figure out an efficient way to do arbitrary depth
|
|
177
|
+
export type TransitiveResources<
|
|
178
|
+
Resources extends Service | Resource,
|
|
179
|
+
Found extends Service | Resource = never,
|
|
180
|
+
> = Extract<
|
|
181
|
+
| Found
|
|
182
|
+
| {
|
|
183
|
+
[prop in keyof Resources["props"]]: IsAny<
|
|
184
|
+
Resources["props"][prop]
|
|
185
|
+
> extends true
|
|
186
|
+
? Found
|
|
187
|
+
: Resources["props"][prop] extends { kind: "alchemy/Policy" }
|
|
188
|
+
? Found
|
|
189
|
+
: Resources["props"][prop] extends Output.Output<any, infer Src, any>
|
|
190
|
+
? Src extends Found
|
|
191
|
+
? Found
|
|
192
|
+
: TransitiveResources<Src, Src | Found>
|
|
193
|
+
: {
|
|
194
|
+
[p in keyof Resources["props"][prop]]: IsAny<
|
|
195
|
+
Resources["props"][prop][p]
|
|
196
|
+
> extends true
|
|
197
|
+
? Found
|
|
198
|
+
: Resources["props"][prop][p] extends Output.Output<
|
|
199
|
+
any,
|
|
200
|
+
infer Src,
|
|
201
|
+
any
|
|
202
|
+
>
|
|
203
|
+
? Src extends Found
|
|
204
|
+
? Found
|
|
205
|
+
: TransitiveResources<Src, Src | Found>
|
|
206
|
+
: Found;
|
|
207
|
+
}[keyof Resources["props"][prop]];
|
|
208
|
+
}[keyof Resources["props"]],
|
|
209
|
+
Service | Resource
|
|
210
|
+
>;
|
|
211
|
+
|
|
212
|
+
export type Providers<Resources extends Service | Resource> =
|
|
213
|
+
| ResourceProviders<Resources>
|
|
214
|
+
| BindingTags<Resources>;
|
|
215
|
+
|
|
216
|
+
export type ResourceProviders<Res extends Service | Resource> = Res extends any
|
|
217
|
+
? Provider<Extract<Res["base"], Service | Resource>>
|
|
218
|
+
: never;
|
|
219
|
+
|
|
220
|
+
export type BindingTags<Resources extends Service | Resource> = NeverUnknown<
|
|
221
|
+
Extract<Resources, Service>["props"]["bindings"]["tags"][number]
|
|
222
|
+
>;
|
|
223
|
+
|
|
224
|
+
type NeverUnknown<T> = unknown extends T ? never : T;
|
|
225
|
+
|
|
226
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
227
|
+
|
|
228
|
+
export type DerivePlan<Resources extends Service | Resource> = {
|
|
154
229
|
resources: {
|
|
155
|
-
[
|
|
230
|
+
[ID in keyof ResourceGraph<Resources>]: ResourceGraph<Resources>[ID];
|
|
156
231
|
};
|
|
157
232
|
deletions: {
|
|
158
|
-
[
|
|
233
|
+
[ID in string]: Delete<AnyResource>;
|
|
159
234
|
};
|
|
160
235
|
};
|
|
161
236
|
|
|
162
|
-
export
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
>({
|
|
166
|
-
phase,
|
|
167
|
-
resources,
|
|
168
|
-
}: {
|
|
169
|
-
phase: Phase;
|
|
170
|
-
resources: Resources;
|
|
171
|
-
}) => {
|
|
172
|
-
type Services = Extract<Resources[number], IService>[];
|
|
173
|
-
type ServiceIDs = Services[number]["id"];
|
|
174
|
-
type ServiceHosts = {
|
|
175
|
-
[ID in ServiceIDs]: Extract<Services[number], Service<Extract<ID, string>>>;
|
|
237
|
+
export type IPlan = {
|
|
238
|
+
resources: {
|
|
239
|
+
[id in string]: CRUD<any>;
|
|
176
240
|
};
|
|
177
|
-
|
|
178
|
-
[
|
|
179
|
-
}[ServiceIDs];
|
|
180
|
-
type UpstreamResources = {
|
|
181
|
-
[ID in ServiceIDs]: Extract<
|
|
182
|
-
ServiceHosts[ID]["props"]["bindings"]["capabilities"][number]["resource"],
|
|
183
|
-
Resource
|
|
184
|
-
>;
|
|
185
|
-
}[ServiceIDs];
|
|
186
|
-
type ExplicitResources = Resources[number];
|
|
187
|
-
type ResourceGraph = {
|
|
188
|
-
[ID in ServiceIDs]: Apply<Extract<Instance<ServiceHosts[ID]>, Resource>>;
|
|
189
|
-
} & {
|
|
190
|
-
[ID in UpstreamResources["id"]]: Apply<
|
|
191
|
-
Extract<UpstreamResources, { id: ID }>
|
|
192
|
-
>;
|
|
193
|
-
} & {
|
|
194
|
-
[ID in ExplicitResources["id"]]: Apply<
|
|
195
|
-
Extract<ExplicitResources, { id: ID }>
|
|
196
|
-
>;
|
|
241
|
+
deletions: {
|
|
242
|
+
[id in string]?: Delete<Resource>;
|
|
197
243
|
};
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export type Plan<Resources extends Service | Resource> = Effect.Effect<
|
|
247
|
+
DerivePlan<Resources>,
|
|
248
|
+
never,
|
|
249
|
+
Providers<Resources> | State
|
|
250
|
+
>;
|
|
198
251
|
|
|
199
|
-
|
|
252
|
+
export const plan = <const Resources extends (Service | Resource)[]>(
|
|
253
|
+
...resources: Resources
|
|
254
|
+
): Plan<Instance<Resources[number]>> =>
|
|
255
|
+
Effect.gen(function* () {
|
|
200
256
|
const state = yield* State;
|
|
201
257
|
|
|
202
|
-
|
|
258
|
+
// TODO(sam): rename terminology to Stack
|
|
259
|
+
const app = yield* App;
|
|
260
|
+
|
|
261
|
+
const resourceIds = yield* state.list({
|
|
262
|
+
stack: app.name,
|
|
263
|
+
stage: app.stage,
|
|
264
|
+
});
|
|
203
265
|
const resourcesState = yield* Effect.all(
|
|
204
|
-
resourceIds.map((id) =>
|
|
266
|
+
resourceIds.map((id) =>
|
|
267
|
+
state.get({ stack: app.name, stage: app.stage, resourceId: id }),
|
|
268
|
+
),
|
|
205
269
|
);
|
|
206
270
|
// map of resource ID -> its downstream dependencies (resources that depend on it)
|
|
207
271
|
const downstream = resourcesState
|
|
@@ -225,134 +289,273 @@ export const plan = <
|
|
|
225
289
|
{} as Record<string, string[]>,
|
|
226
290
|
);
|
|
227
291
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
292
|
+
type ResolveEffect<T> = Effect.Effect<T, ResolveErr, ResolveReq>;
|
|
293
|
+
type ResolveErr = StateStoreError;
|
|
294
|
+
type ResolveReq =
|
|
295
|
+
| Context.TagClass<
|
|
296
|
+
Provider<Resource<string, string, any, any>>,
|
|
297
|
+
string,
|
|
298
|
+
ProviderService<Resource<string, string, any, any>>
|
|
299
|
+
>
|
|
300
|
+
| State;
|
|
301
|
+
|
|
302
|
+
const resolvedResources: Record<
|
|
303
|
+
string,
|
|
304
|
+
ResolveEffect<{
|
|
305
|
+
[attr in string]: any;
|
|
306
|
+
}>
|
|
307
|
+
> = {};
|
|
308
|
+
|
|
309
|
+
const resolveResource = (
|
|
310
|
+
resourceExpr: Output.ResourceExpr<any, any, any>,
|
|
311
|
+
) =>
|
|
312
|
+
Effect.gen(function* () {
|
|
313
|
+
return yield* (resolvedResources[resourceExpr.src.id] ??=
|
|
314
|
+
yield* Effect.cached(
|
|
315
|
+
Effect.gen(function* () {
|
|
316
|
+
const resource = resourceExpr.src as Resource & {
|
|
317
|
+
provider: ResourceTags<Resource<string, string, any, any>>;
|
|
318
|
+
};
|
|
319
|
+
const provider = yield* resource.provider.tag;
|
|
320
|
+
const props = yield* resolveInput(resource.props);
|
|
321
|
+
const oldState = yield* state.get({
|
|
322
|
+
stack: app.name,
|
|
323
|
+
stage: app.stage,
|
|
324
|
+
resourceId: resource.id,
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
if (!oldState) {
|
|
328
|
+
return resourceExpr;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const diff = yield* provider.diff
|
|
332
|
+
? provider.diff({
|
|
333
|
+
id: resource.id,
|
|
334
|
+
olds: oldState.props,
|
|
335
|
+
news: props,
|
|
336
|
+
output: oldState.output,
|
|
337
|
+
})
|
|
338
|
+
: Effect.succeed(undefined);
|
|
339
|
+
|
|
340
|
+
if (diff == null) {
|
|
341
|
+
if (arePropsChanged(oldState, props)) {
|
|
342
|
+
// the props have changed but the provider did not provide any hints as to what is stable
|
|
343
|
+
// so we must assume everything has changed
|
|
344
|
+
return resourceExpr;
|
|
345
|
+
}
|
|
346
|
+
} else if (diff.action === "update") {
|
|
347
|
+
const output = oldState?.output;
|
|
348
|
+
if (diff.stables) {
|
|
349
|
+
return new Output.ResourceExpr(
|
|
350
|
+
resourceExpr.src,
|
|
351
|
+
Object.fromEntries(
|
|
352
|
+
diff.stables.map((stable) => [stable, output?.[stable]]),
|
|
353
|
+
),
|
|
354
|
+
);
|
|
355
|
+
} else {
|
|
356
|
+
// if there are no stable properties, treat every property as changed
|
|
357
|
+
return resourceExpr;
|
|
358
|
+
}
|
|
359
|
+
} else if (diff.action === "replace") {
|
|
360
|
+
}
|
|
361
|
+
return oldState?.output;
|
|
362
|
+
}),
|
|
363
|
+
));
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
const resolveInput = (input: any): ResolveEffect<any> =>
|
|
367
|
+
Effect.gen(function* () {
|
|
368
|
+
if (!input) {
|
|
369
|
+
return input;
|
|
370
|
+
} else if (Output.isExpr(input)) {
|
|
371
|
+
return yield* resolveOutput(input);
|
|
372
|
+
} else if (Array.isArray(input)) {
|
|
373
|
+
return yield* Effect.all(input.map(resolveInput));
|
|
374
|
+
} else if (typeof input === "object") {
|
|
375
|
+
return Object.fromEntries(
|
|
376
|
+
yield* Effect.all(
|
|
377
|
+
Object.entries(input).map(([key, value]) =>
|
|
378
|
+
resolveInput(value).pipe(Effect.map((value) => [key, value])),
|
|
379
|
+
),
|
|
380
|
+
),
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
return input;
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
const resolveOutput = (expr: Output.Expr<any>): ResolveEffect<any> =>
|
|
387
|
+
Effect.gen(function* () {
|
|
388
|
+
if (Output.isResourceExpr(expr)) {
|
|
389
|
+
return yield* resolveResource(expr);
|
|
390
|
+
} else if (Output.isPropExpr(expr)) {
|
|
391
|
+
const upstream = yield* resolveOutput(expr.expr);
|
|
392
|
+
return upstream?.[expr.identifier];
|
|
393
|
+
} else if (Output.isApplyExpr(expr)) {
|
|
394
|
+
const upstream = yield* resolveOutput(expr.expr);
|
|
395
|
+
return Output.isOutput(upstream) ? expr : expr.f(upstream);
|
|
396
|
+
} else if (Output.isEffectExpr(expr)) {
|
|
397
|
+
const upstream = yield* resolveOutput(expr.expr);
|
|
398
|
+
return Output.isOutput(upstream) ? expr : yield* expr.f(upstream);
|
|
399
|
+
} else if (Output.isAllExpr(expr)) {
|
|
400
|
+
return yield* Effect.all(expr.outs.map(resolveOutput));
|
|
401
|
+
}
|
|
402
|
+
return yield* Effect.die(new Error("Not implemented yet"));
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
const resolveUpstream = (
|
|
406
|
+
value: any,
|
|
407
|
+
): {
|
|
408
|
+
[ID in string]: Resource;
|
|
409
|
+
} => {
|
|
410
|
+
if (Output.isExpr(value)) {
|
|
411
|
+
return Output.upstream(value);
|
|
412
|
+
} else if (Array.isArray(value)) {
|
|
413
|
+
return Object.assign({}, ...value.map(resolveUpstream));
|
|
414
|
+
} else if (
|
|
415
|
+
value &&
|
|
416
|
+
(typeof value === "object" || typeof value === "function")
|
|
417
|
+
) {
|
|
418
|
+
return Object.assign(
|
|
419
|
+
{},
|
|
420
|
+
...Object.values(value).map((value) => resolveUpstream(value)),
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
return {};
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const resourceGraph = Object.fromEntries(
|
|
427
|
+
(yield* Effect.all(
|
|
428
|
+
resources
|
|
429
|
+
.flatMap((resource) => [
|
|
430
|
+
...(isService(resource)
|
|
431
|
+
? resource.props.bindings.capabilities.map(
|
|
432
|
+
(cap: Capability) => cap.resource as Resource,
|
|
244
433
|
)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
434
|
+
: []),
|
|
435
|
+
...Object.values(resolveUpstream(resource.props)),
|
|
436
|
+
resource,
|
|
437
|
+
])
|
|
438
|
+
.filter(
|
|
439
|
+
(node, i, arr) => arr.findIndex((n) => n.id === node.id) === i,
|
|
440
|
+
)
|
|
441
|
+
.map(
|
|
442
|
+
Effect.fn(function* (node) {
|
|
443
|
+
const id = node.id;
|
|
444
|
+
const resource = node as Resource & {
|
|
445
|
+
provider: ResourceTags<Resource<string, string, any, any>>;
|
|
446
|
+
};
|
|
447
|
+
const news = yield* resolveInput(resource.props);
|
|
448
|
+
|
|
449
|
+
const oldState = yield* state.get({
|
|
450
|
+
stack: app.name,
|
|
451
|
+
stage: app.stage,
|
|
452
|
+
resourceId: id,
|
|
453
|
+
});
|
|
454
|
+
const provider = yield* resource.provider.tag;
|
|
455
|
+
|
|
456
|
+
const bindings = isService(node)
|
|
457
|
+
? yield* diffBindings({
|
|
458
|
+
oldState,
|
|
459
|
+
bindings: (
|
|
460
|
+
node.props.bindings as unknown as {
|
|
461
|
+
bindings: AnyBinding[];
|
|
462
|
+
}
|
|
463
|
+
).bindings,
|
|
464
|
+
target: {
|
|
465
|
+
id: node.id,
|
|
466
|
+
props: node.props,
|
|
467
|
+
oldAttr: oldState?.output,
|
|
468
|
+
oldProps: oldState?.props,
|
|
469
|
+
},
|
|
470
|
+
})
|
|
471
|
+
: []; // TODO(sam): return undefined instead of empty array
|
|
472
|
+
|
|
473
|
+
if (oldState === undefined || oldState.status === "creating") {
|
|
474
|
+
return Node<Create<Resource>>({
|
|
475
|
+
action: "create",
|
|
476
|
+
news,
|
|
477
|
+
provider,
|
|
478
|
+
resource,
|
|
479
|
+
bindings,
|
|
480
|
+
// phantom
|
|
481
|
+
attributes: undefined!,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
const diff = provider.diff
|
|
486
|
+
? yield* (() => {
|
|
487
|
+
const diff = provider.diff({
|
|
488
|
+
id,
|
|
489
|
+
olds: oldState.props,
|
|
490
|
+
news,
|
|
491
|
+
output: oldState.output,
|
|
492
|
+
});
|
|
493
|
+
return Effect.isEffect(diff) ? diff : Effect.succeed(diff);
|
|
494
|
+
})()
|
|
495
|
+
: undefined;
|
|
496
|
+
|
|
497
|
+
if (!diff && arePropsChanged(oldState, news)) {
|
|
498
|
+
return Node<Update<Resource>>({
|
|
499
|
+
action: "update",
|
|
500
|
+
olds: oldState.props,
|
|
501
|
+
news,
|
|
502
|
+
output: oldState.output,
|
|
503
|
+
provider,
|
|
504
|
+
resource,
|
|
505
|
+
bindings,
|
|
506
|
+
// phantom
|
|
507
|
+
attributes: undefined!,
|
|
508
|
+
});
|
|
509
|
+
} else if (diff?.action === "replace") {
|
|
510
|
+
return Node<Replace<Resource>>({
|
|
511
|
+
action: "replace",
|
|
512
|
+
olds: oldState.props,
|
|
513
|
+
news,
|
|
514
|
+
output: oldState.output,
|
|
515
|
+
provider,
|
|
516
|
+
resource,
|
|
517
|
+
bindings,
|
|
518
|
+
// phantom
|
|
519
|
+
attributes: undefined!,
|
|
520
|
+
});
|
|
521
|
+
} else if (diff?.action === "update") {
|
|
522
|
+
return Node<Update<Resource>>({
|
|
523
|
+
action: "update",
|
|
524
|
+
olds: oldState.props,
|
|
525
|
+
news,
|
|
526
|
+
output: oldState.output,
|
|
527
|
+
provider,
|
|
528
|
+
resource,
|
|
529
|
+
bindings,
|
|
530
|
+
// phantom
|
|
531
|
+
attributes: undefined!,
|
|
532
|
+
});
|
|
533
|
+
} else {
|
|
534
|
+
return Node<NoopUpdate<Resource>>({
|
|
535
|
+
action: "noop",
|
|
536
|
+
resource,
|
|
537
|
+
bindings,
|
|
538
|
+
// phantom
|
|
539
|
+
attributes: undefined!,
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}),
|
|
543
|
+
),
|
|
544
|
+
)).map((update) => [update.resource.id, update]),
|
|
545
|
+
) as IPlan["resources"];
|
|
347
546
|
|
|
348
547
|
const deletions = Object.fromEntries(
|
|
349
548
|
(yield* Effect.all(
|
|
350
|
-
(yield* state.list()).map(
|
|
549
|
+
(yield* state.list({ stack: app.name, stage: app.stage })).map(
|
|
351
550
|
Effect.fn(function* (id) {
|
|
352
551
|
if (id in resourceGraph) {
|
|
353
552
|
return;
|
|
354
553
|
}
|
|
355
|
-
const oldState = yield* state.get(
|
|
554
|
+
const oldState = yield* state.get({
|
|
555
|
+
stack: app.name,
|
|
556
|
+
stage: app.stage,
|
|
557
|
+
resourceId: id,
|
|
558
|
+
});
|
|
356
559
|
const context = yield* Effect.context<never>();
|
|
357
560
|
if (oldState) {
|
|
358
561
|
const provider: ProviderService = context.unsafeMap.get(
|
|
@@ -375,7 +578,6 @@ export const plan = <
|
|
|
375
578
|
bindings: [],
|
|
376
579
|
resource: {
|
|
377
580
|
id: id,
|
|
378
|
-
parent: undefined,
|
|
379
581
|
type: oldState.type,
|
|
380
582
|
attr: oldState.output,
|
|
381
583
|
props: oldState.props,
|
|
@@ -405,24 +607,10 @@ export const plan = <
|
|
|
405
607
|
}
|
|
406
608
|
|
|
407
609
|
return {
|
|
408
|
-
phase,
|
|
409
610
|
resources: resourceGraph,
|
|
410
611
|
deletions,
|
|
411
|
-
} satisfies
|
|
412
|
-
}) as
|
|
413
|
-
{
|
|
414
|
-
phase: Phase;
|
|
415
|
-
resources: {
|
|
416
|
-
[ID in keyof ResourceGraph]: ResourceGraph[ID];
|
|
417
|
-
};
|
|
418
|
-
deletions: {
|
|
419
|
-
[id in Exclude<string, keyof ResourceGraph>]?: Delete<Resource>;
|
|
420
|
-
};
|
|
421
|
-
},
|
|
422
|
-
never,
|
|
423
|
-
UpstreamTags | State
|
|
424
|
-
>;
|
|
425
|
-
};
|
|
612
|
+
} satisfies IPlan as IPlan;
|
|
613
|
+
}) as any;
|
|
426
614
|
|
|
427
615
|
class DeleteResourceHasDownstreamDependencies extends Data.TaggedError(
|
|
428
616
|
"DeleteResourceHasDownstreamDependencies",
|