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/cloudflare/api.ts
CHANGED
|
@@ -5,46 +5,50 @@ import {
|
|
|
5
5
|
type RequestOptions,
|
|
6
6
|
} from "cloudflare/core";
|
|
7
7
|
import type { ErrorData } from "cloudflare/resources";
|
|
8
|
-
import { Layer } from "effect";
|
|
9
|
-
import * as Context from "effect/Context";
|
|
10
8
|
import * as Data from "effect/Data";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
11
10
|
import * as Effect from "effect/Effect";
|
|
11
|
+
import { Config } from "effect";
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}),
|
|
26
|
-
);
|
|
27
|
-
}
|
|
13
|
+
export const CLOUDFLARE_BASE_URL = Config.string("CLOUDFLARE_BASE_URL").pipe(
|
|
14
|
+
Config.option,
|
|
15
|
+
);
|
|
16
|
+
export const CLOUDFLARE_API_TOKEN = Config.string("CLOUDFLARE_API_TOKEN").pipe(
|
|
17
|
+
Config.option,
|
|
18
|
+
);
|
|
19
|
+
export const CLOUDFLARE_API_KEY = Config.string("CLOUDFLARE_API_KEY").pipe(
|
|
20
|
+
Config.option,
|
|
21
|
+
);
|
|
22
|
+
export const CLOUDFLARE_API_EMAIL = Config.string("CLOUDFLARE_API_EMAIL").pipe(
|
|
23
|
+
Config.option,
|
|
24
|
+
);
|
|
28
25
|
|
|
29
26
|
export class CloudflareApi extends Effect.Service<CloudflareApi>()(
|
|
30
27
|
"cloudflare/api",
|
|
31
28
|
{
|
|
32
|
-
effect: (options?: {
|
|
29
|
+
effect: Effect.fn(function* (options?: {
|
|
33
30
|
baseUrl?: string;
|
|
34
31
|
apiToken?: string;
|
|
35
32
|
apiKey?: string;
|
|
36
33
|
apiEmail?: string;
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
}) {
|
|
35
|
+
return createRecursiveProxy(
|
|
36
|
+
new Cloudflare({
|
|
37
|
+
baseURL:
|
|
38
|
+
options?.baseUrl ??
|
|
39
|
+
(yield* CLOUDFLARE_BASE_URL).pipe(Option.getOrUndefined),
|
|
40
|
+
apiToken:
|
|
41
|
+
options?.apiToken ??
|
|
42
|
+
(yield* CLOUDFLARE_API_TOKEN).pipe(Option.getOrUndefined),
|
|
43
|
+
apiKey:
|
|
44
|
+
options?.apiKey ??
|
|
45
|
+
(yield* CLOUDFLARE_API_KEY).pipe(Option.getOrUndefined),
|
|
46
|
+
apiEmail:
|
|
47
|
+
options?.apiEmail ??
|
|
48
|
+
(yield* CLOUDFLARE_API_EMAIL).pipe(Option.getOrUndefined),
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
}),
|
|
48
52
|
},
|
|
49
53
|
) {}
|
|
50
54
|
|
package/src/cloudflare/index.ts
CHANGED
|
@@ -2,5 +2,7 @@ export * as KV from "./kv/index.ts";
|
|
|
2
2
|
export * as R2 from "./r2/index.ts";
|
|
3
3
|
export * as Assets from "./worker/assets.fetch.ts";
|
|
4
4
|
export * as Worker from "./worker/index.ts";
|
|
5
|
+
export * from "./account.ts";
|
|
6
|
+
export * from "./live.ts";
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
import "./config.ts";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Binding
|
|
1
|
+
import { Binding } from "../../binding.ts";
|
|
2
|
+
import type { Capability } from "../../capability.ts";
|
|
3
|
+
import type { To } from "../../policy.ts";
|
|
2
4
|
import { Worker } from "../worker/worker.ts";
|
|
3
5
|
import type { Namespace, NamespaceProps } from "./namespace.ts";
|
|
4
6
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { KV } from "cloudflare/resources";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import { App } from "../../app.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { Account } from "../account.ts";
|
|
5
|
+
import { CloudflareApi } from "../api.ts";
|
|
5
6
|
import {
|
|
6
7
|
Namespace,
|
|
7
8
|
type NamespaceAttr,
|
|
@@ -13,10 +14,10 @@ export const namespaceProvider = () =>
|
|
|
13
14
|
Effect.gen(function* () {
|
|
14
15
|
const app = yield* App;
|
|
15
16
|
const api = yield* CloudflareApi;
|
|
16
|
-
const accountId = yield*
|
|
17
|
+
const accountId = yield* Account;
|
|
17
18
|
|
|
18
|
-
const createTitle = (id: string,
|
|
19
|
-
|
|
19
|
+
const createTitle = (id: string, title: string | undefined) =>
|
|
20
|
+
title ?? `${app.name}-${id}-${app.stage}`;
|
|
20
21
|
|
|
21
22
|
const mapResult = <Props extends NamespaceProps>(
|
|
22
23
|
result: KV.Namespace,
|
|
@@ -28,12 +29,13 @@ export const namespaceProvider = () =>
|
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
return {
|
|
32
|
+
stables: ["namespaceId", "accountId"],
|
|
31
33
|
diff: ({ id, news, output }) =>
|
|
32
34
|
Effect.sync(() => {
|
|
33
35
|
if (output.accountId !== accountId) {
|
|
34
36
|
return { action: "replace" };
|
|
35
37
|
}
|
|
36
|
-
const title = createTitle(id, news);
|
|
38
|
+
const title = createTitle(id, news.title);
|
|
37
39
|
if (title !== output.title) {
|
|
38
40
|
return { action: "update" };
|
|
39
41
|
}
|
|
@@ -42,7 +44,7 @@ export const namespaceProvider = () =>
|
|
|
42
44
|
return yield* api.kv.namespaces
|
|
43
45
|
.create({
|
|
44
46
|
account_id: accountId,
|
|
45
|
-
title: createTitle(id, news),
|
|
47
|
+
title: createTitle(id, news.title),
|
|
46
48
|
})
|
|
47
49
|
.pipe(Effect.map(mapResult<NamespaceProps>));
|
|
48
50
|
}),
|
|
@@ -50,7 +52,7 @@ export const namespaceProvider = () =>
|
|
|
50
52
|
return yield* api.kv.namespaces
|
|
51
53
|
.update(output.namespaceId, {
|
|
52
54
|
account_id: accountId,
|
|
53
|
-
title: createTitle(id, news),
|
|
55
|
+
title: createTitle(id, news.title),
|
|
54
56
|
})
|
|
55
57
|
.pipe(Effect.map(mapResult<NamespaceProps>));
|
|
56
58
|
}),
|
|
@@ -72,7 +74,7 @@ export const namespaceProvider = () =>
|
|
|
72
74
|
Effect.catchTag("NotFound", () => Effect.succeed(undefined)),
|
|
73
75
|
);
|
|
74
76
|
}
|
|
75
|
-
const title = createTitle(id, olds
|
|
77
|
+
const title = createTitle(id, olds?.title); // why is olds optional? because read can be called before the resource exists (sync)
|
|
76
78
|
let page = 1;
|
|
77
79
|
while (true) {
|
|
78
80
|
// todo: abstract pagination
|
|
@@ -18,12 +18,13 @@ export interface Namespace<
|
|
|
18
18
|
"Cloudflare.KV.Namespace",
|
|
19
19
|
ID,
|
|
20
20
|
Props,
|
|
21
|
-
NamespaceAttr<Props
|
|
21
|
+
NamespaceAttr<Props>,
|
|
22
|
+
Namespace
|
|
22
23
|
> {}
|
|
23
24
|
|
|
24
25
|
export const Namespace = Resource<{
|
|
25
26
|
<const ID extends string, const Props extends NamespaceProps>(
|
|
26
27
|
id: ID,
|
|
27
|
-
props
|
|
28
|
+
props?: Props,
|
|
28
29
|
): Namespace<ID, Props>;
|
|
29
30
|
}>("Cloudflare.KV.Namespace");
|
package/src/cloudflare/live.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
2
|
import * as ESBuild from "../esbuild.ts";
|
|
3
|
-
import {
|
|
3
|
+
import { CloudflareApi } from "./api.ts";
|
|
4
|
+
import * as Account from "./account.ts";
|
|
4
5
|
import * as KV from "./kv/index.ts";
|
|
5
6
|
import { namespaceProvider } from "./kv/namespace.provider.ts";
|
|
6
7
|
import { bucketProvider } from "./r2/bucket.provider.ts";
|
|
@@ -8,7 +9,12 @@ import * as R2 from "./r2/index.ts";
|
|
|
8
9
|
import { assetsProvider } from "./worker/assets.provider.ts";
|
|
9
10
|
import { workerProvider } from "./worker/worker.provider.ts";
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
import "./config.ts";
|
|
13
|
+
|
|
14
|
+
export const bindings = () =>
|
|
15
|
+
Layer.mergeAll(KV.bindFromWorker(), R2.bindFromWorker());
|
|
16
|
+
|
|
17
|
+
export const defaultProviders = () =>
|
|
12
18
|
Layer.mergeAll(
|
|
13
19
|
Layer.provideMerge(
|
|
14
20
|
workerProvider(),
|
|
@@ -16,23 +22,11 @@ export const providers = () =>
|
|
|
16
22
|
),
|
|
17
23
|
namespaceProvider(),
|
|
18
24
|
bucketProvider(),
|
|
19
|
-
);
|
|
25
|
+
).pipe(Layer.provideMerge(bindings()));
|
|
20
26
|
|
|
21
|
-
export const
|
|
22
|
-
Layer.mergeAll(KV.bindFromWorker(), R2.bindFromWorker());
|
|
23
|
-
|
|
24
|
-
export const defaultProviders = () =>
|
|
25
|
-
providers().pipe(Layer.provideMerge(bindings()));
|
|
26
|
-
|
|
27
|
-
export const live = () =>
|
|
27
|
+
export const providers = () =>
|
|
28
28
|
defaultProviders().pipe(
|
|
29
29
|
Layer.provideMerge(
|
|
30
|
-
Layer.mergeAll(
|
|
30
|
+
Layer.mergeAll(Account.fromStageConfig(), CloudflareApi.Default()),
|
|
31
31
|
),
|
|
32
32
|
);
|
|
33
|
-
|
|
34
|
-
export default live;
|
|
35
|
-
|
|
36
|
-
// Layer.mergeAll
|
|
37
|
-
// Layer.provide
|
|
38
|
-
// Layer.provideMerge
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Binding
|
|
1
|
+
import { Binding } from "../../binding.ts";
|
|
2
|
+
import type { Capability } from "../../capability.ts";
|
|
3
|
+
import type { To } from "../../policy.ts";
|
|
2
4
|
import { Worker } from "../worker/worker.ts";
|
|
3
5
|
import type { Bucket } from "./bucket.ts";
|
|
4
6
|
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { R2 } from "cloudflare/resources";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import { App } from "../../app";
|
|
4
|
-
import {
|
|
4
|
+
import { Account } from "../account.ts";
|
|
5
|
+
import { CloudflareApi } from "../api";
|
|
5
6
|
import { Bucket, type BucketAttr, type BucketProps } from "./bucket";
|
|
6
7
|
|
|
7
8
|
export const bucketProvider = () =>
|
|
8
9
|
Bucket.provider.effect(
|
|
9
10
|
Effect.gen(function* () {
|
|
10
11
|
const api = yield* CloudflareApi;
|
|
11
|
-
const accountId = yield*
|
|
12
|
+
const accountId = yield* Account;
|
|
12
13
|
const app = yield* App;
|
|
13
14
|
|
|
14
|
-
const createName = (id: string,
|
|
15
|
-
|
|
15
|
+
const createName = (id: string, name: string | undefined) =>
|
|
16
|
+
name ?? `${app.name}-${id}-${app.stage}`.toLowerCase();
|
|
16
17
|
|
|
17
18
|
const mapResult = <Props extends BucketProps>(
|
|
18
19
|
bucket: R2.Bucket,
|
|
@@ -30,28 +31,34 @@ export const bucketProvider = () =>
|
|
|
30
31
|
Effect.sync(() => {
|
|
31
32
|
if (
|
|
32
33
|
output.accountId !== accountId ||
|
|
33
|
-
output.name !== createName(id, news) ||
|
|
34
|
+
output.name !== createName(id, news.name) ||
|
|
34
35
|
output.jurisdiction !== (news.jurisdiction ?? "default") ||
|
|
35
36
|
olds.locationHint !== news.locationHint
|
|
36
37
|
) {
|
|
37
38
|
return { action: "replace" };
|
|
38
39
|
}
|
|
39
40
|
if (output.storageClass !== (news.storageClass ?? "Standard")) {
|
|
40
|
-
return {
|
|
41
|
+
return {
|
|
42
|
+
action: "update",
|
|
43
|
+
stables:
|
|
44
|
+
output.name === createName(id, news.name)
|
|
45
|
+
? ["name"]
|
|
46
|
+
: undefined,
|
|
47
|
+
};
|
|
41
48
|
}
|
|
42
49
|
return { action: "noop" };
|
|
43
50
|
}),
|
|
44
51
|
create: Effect.fnUntraced(function* ({ id, news }) {
|
|
45
52
|
const bucket = yield* api.r2.buckets.create({
|
|
46
53
|
account_id: accountId,
|
|
47
|
-
name: createName(id, news),
|
|
54
|
+
name: createName(id, news.name),
|
|
48
55
|
storageClass: news.storageClass,
|
|
49
56
|
jurisdiction: news.jurisdiction,
|
|
50
57
|
locationHint: news.locationHint,
|
|
51
58
|
});
|
|
52
59
|
return mapResult<BucketProps>(bucket);
|
|
53
60
|
}),
|
|
54
|
-
update: Effect.fnUntraced(function* ({
|
|
61
|
+
update: Effect.fnUntraced(function* ({ news, output }) {
|
|
55
62
|
const bucket = yield* api.r2.buckets.edit(output.name, {
|
|
56
63
|
account_id: output.accountId,
|
|
57
64
|
storage_class: news.storageClass ?? output.storageClass,
|
|
@@ -69,7 +76,7 @@ export const bucketProvider = () =>
|
|
|
69
76
|
read: Effect.fnUntraced(function* ({ id, output, olds }) {
|
|
70
77
|
const params = {
|
|
71
78
|
account_id: output?.accountId ?? accountId,
|
|
72
|
-
name: output?.name ?? createName(id, olds
|
|
79
|
+
name: output?.name ?? createName(id, olds?.name),
|
|
73
80
|
};
|
|
74
81
|
return yield* api.r2.buckets
|
|
75
82
|
.get(params.name, { account_id: params.account_id })
|
|
@@ -22,12 +22,18 @@ export type BucketAttr<Props extends BucketProps> = {
|
|
|
22
22
|
export interface Bucket<
|
|
23
23
|
ID extends string = string,
|
|
24
24
|
Props extends BucketProps = BucketProps,
|
|
25
|
-
> extends Resource<
|
|
25
|
+
> extends Resource<
|
|
26
|
+
"Cloudflare.R2.Bucket",
|
|
27
|
+
ID,
|
|
28
|
+
Props,
|
|
29
|
+
BucketAttr<Props>,
|
|
30
|
+
Bucket
|
|
31
|
+
> {}
|
|
26
32
|
|
|
27
33
|
export const Bucket = Resource<{
|
|
28
34
|
<const ID extends string, const Props extends BucketProps>(
|
|
29
35
|
id: ID,
|
|
30
|
-
props
|
|
36
|
+
props?: Props,
|
|
31
37
|
): Bucket<ID, Props>;
|
|
32
38
|
}>("Cloudflare.R2.Bucket");
|
|
33
39
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type * as runtime from "@cloudflare/workers-types";
|
|
2
|
-
import { Binding, declare, type Capability } from "alchemy-effect";
|
|
3
2
|
import * as Effect from "effect/Effect";
|
|
3
|
+
import { Binding } from "../../binding.ts";
|
|
4
|
+
import type { Capability } from "../../capability.ts";
|
|
5
|
+
import { declare } from "../../policy.ts";
|
|
4
6
|
import { getCloudflareEnvKey } from "../context.ts";
|
|
5
7
|
import { Worker } from "./worker.ts";
|
|
6
8
|
|
|
@@ -2,7 +2,7 @@ import { FileSystem, Path } from "@effect/platform";
|
|
|
2
2
|
import type { PlatformError } from "@effect/platform/Error";
|
|
3
3
|
import { Context, Data, Layer } from "effect";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
|
-
import type { ScopedPlanStatusSession } from "../../
|
|
5
|
+
import type { ScopedPlanStatusSession } from "../../cli/service.ts";
|
|
6
6
|
import { sha256 } from "../../sha256.ts";
|
|
7
7
|
import { CloudflareApi, CloudflareApiError } from "../api.ts";
|
|
8
8
|
import type { Worker } from "./worker.ts";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as runtime from "@cloudflare/workers-types";
|
|
2
|
-
import type { Capability } from "alchemy-effect";
|
|
3
2
|
import * as Effect from "effect/Effect";
|
|
4
3
|
import * as Layer from "effect/Layer";
|
|
4
|
+
import type { Capability } from "../../capability.ts";
|
|
5
5
|
import { CloudflareContext } from "../context.ts";
|
|
6
6
|
|
|
7
7
|
type Handler = (
|
|
@@ -3,11 +3,12 @@ import * as Path from "@effect/platform/Path";
|
|
|
3
3
|
import type { Workers } from "cloudflare/resources.mjs";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import { App } from "../../app.ts";
|
|
6
|
-
import type { ScopedPlanStatusSession } from "../../
|
|
6
|
+
import type { ScopedPlanStatusSession } from "../../cli/service.ts";
|
|
7
7
|
import { DotAlchemy } from "../../dot-alchemy.ts";
|
|
8
8
|
import { ESBuild } from "../../esbuild.ts";
|
|
9
9
|
import { sha256 } from "../../sha256.ts";
|
|
10
|
-
import {
|
|
10
|
+
import { Account } from "../account.ts";
|
|
11
|
+
import { CloudflareApi } from "../api.ts";
|
|
11
12
|
import { Assets } from "./assets.provider.ts";
|
|
12
13
|
import { Worker, type WorkerAttr, type WorkerProps } from "./worker.ts";
|
|
13
14
|
|
|
@@ -16,7 +17,7 @@ export const workerProvider = () =>
|
|
|
16
17
|
Effect.gen(function* () {
|
|
17
18
|
const app = yield* App;
|
|
18
19
|
const api = yield* CloudflareApi;
|
|
19
|
-
const accountId = yield*
|
|
20
|
+
const accountId = yield* Account;
|
|
20
21
|
const { read, upload } = yield* Assets;
|
|
21
22
|
const { build } = yield* ESBuild;
|
|
22
23
|
const fs = yield* FileSystem.FileSystem;
|
|
@@ -46,8 +47,8 @@ export const workerProvider = () =>
|
|
|
46
47
|
yield* Effect.logDebug("setWorkerSubdomain", subdomain);
|
|
47
48
|
});
|
|
48
49
|
|
|
49
|
-
const createWorkerName = (id: string,
|
|
50
|
-
|
|
50
|
+
const createWorkerName = (id: string, name: string | undefined) =>
|
|
51
|
+
name ?? `${app.name}-${id}-${app.stage}`.toLowerCase();
|
|
51
52
|
|
|
52
53
|
const prepareAssets = Effect.fnUntraced(function* (
|
|
53
54
|
assets: WorkerProps["assets"],
|
|
@@ -83,7 +84,9 @@ export const workerProvider = () =>
|
|
|
83
84
|
};
|
|
84
85
|
});
|
|
85
86
|
|
|
86
|
-
const prepareMetadata = Effect.fnUntraced(function* (
|
|
87
|
+
const prepareMetadata = Effect.fnUntraced(function* (
|
|
88
|
+
props: WorkerProps<any>,
|
|
89
|
+
) {
|
|
87
90
|
const metadata: Workers.ScriptUpdateParams.Metadata = {
|
|
88
91
|
assets: undefined,
|
|
89
92
|
bindings: [],
|
|
@@ -113,13 +116,13 @@ export const workerProvider = () =>
|
|
|
113
116
|
|
|
114
117
|
const putWorker = Effect.fnUntraced(function* (
|
|
115
118
|
id: string,
|
|
116
|
-
news: WorkerProps
|
|
119
|
+
news: WorkerProps<any>,
|
|
117
120
|
bindings: Worker["binding"][],
|
|
118
|
-
olds: WorkerProps | undefined,
|
|
119
|
-
output: WorkerAttr<WorkerProps
|
|
121
|
+
olds: WorkerProps<any> | undefined,
|
|
122
|
+
output: WorkerAttr<WorkerProps<any>> | undefined,
|
|
120
123
|
session: ScopedPlanStatusSession,
|
|
121
124
|
) {
|
|
122
|
-
const name = createWorkerName(id, news);
|
|
125
|
+
const name = createWorkerName(id, news.name);
|
|
123
126
|
const [assets, bundle, metadata] = yield* Effect.all([
|
|
124
127
|
prepareAssets(news.assets),
|
|
125
128
|
prepareBundle(id, news.main),
|
|
@@ -180,15 +183,16 @@ export const workerProvider = () =>
|
|
|
180
183
|
assets: assets?.hash,
|
|
181
184
|
bundle: bundle.hash,
|
|
182
185
|
},
|
|
183
|
-
} as WorkerAttr<WorkerProps
|
|
186
|
+
} as WorkerAttr<WorkerProps<any>>;
|
|
184
187
|
});
|
|
185
188
|
|
|
186
189
|
return {
|
|
190
|
+
stables: ["id"],
|
|
187
191
|
diff: Effect.fnUntraced(function* ({ id, olds, news, output }) {
|
|
188
192
|
if (output.accountId !== accountId) {
|
|
189
193
|
return { action: "replace" };
|
|
190
194
|
}
|
|
191
|
-
const workerName = createWorkerName(id, news);
|
|
195
|
+
const workerName = createWorkerName(id, news.name);
|
|
192
196
|
if (workerName !== output.name) {
|
|
193
197
|
return { action: "replace" };
|
|
194
198
|
}
|
|
@@ -200,11 +204,14 @@ export const workerProvider = () =>
|
|
|
200
204
|
assets?.hash !== output.hash.assets ||
|
|
201
205
|
bundle.hash !== output.hash.bundle
|
|
202
206
|
) {
|
|
203
|
-
return {
|
|
207
|
+
return {
|
|
208
|
+
action: "update",
|
|
209
|
+
stables: output.name === workerName ? ["name"] : undefined,
|
|
210
|
+
};
|
|
204
211
|
}
|
|
205
212
|
}),
|
|
206
213
|
create: Effect.fnUntraced(function* ({ id, news, bindings, session }) {
|
|
207
|
-
const name = createWorkerName(id, news);
|
|
214
|
+
const name = createWorkerName(id, news.name);
|
|
208
215
|
const existing = yield* api.workers.beta.workers
|
|
209
216
|
.get(name, {
|
|
210
217
|
account_id: accountId,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { ExecutionContext } from "@cloudflare/workers-types";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Worker from "./worker.ts";
|
|
4
4
|
|
|
5
|
+
export type { ExecutionContext };
|
|
6
|
+
export type * from "../../exports.ts";
|
|
7
|
+
|
|
5
8
|
export const serve =
|
|
6
9
|
<const ID extends string, Req>(
|
|
7
10
|
id: ID,
|
|
@@ -11,7 +14,7 @@ export const serve =
|
|
|
11
14
|
fetch: (
|
|
12
15
|
request: Request,
|
|
13
16
|
env: unknown,
|
|
14
|
-
ctx:
|
|
17
|
+
ctx: ExecutionContext,
|
|
15
18
|
) => Effect.Effect<Response, never, Req>;
|
|
16
19
|
},
|
|
17
20
|
) =>
|
|
@@ -29,7 +29,7 @@ export type WorkerProps<Req = any> = RuntimeProps<
|
|
|
29
29
|
assets: string | Worker.AssetsProps;
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
export type WorkerAttr<Props extends WorkerProps
|
|
32
|
+
export type WorkerAttr<Props extends WorkerProps<any>> = {
|
|
33
33
|
id: string;
|
|
34
34
|
name: Props["name"] extends string ? Props["name"] : string;
|
|
35
35
|
logpush: Props["logpush"] extends boolean ? Props["logpush"] : boolean;
|
|
@@ -48,8 +48,9 @@ export type WorkerAttr<Props extends WorkerProps> = {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
export interface Worker extends Runtime<WorkerType> {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
base: Worker;
|
|
52
|
+
props: WorkerProps<any>;
|
|
53
|
+
attr: WorkerAttr<Extract<this["props"], WorkerProps<any>>>;
|
|
53
54
|
binding: {
|
|
54
55
|
bindings: Worker.Binding[];
|
|
55
56
|
};
|
package/src/data.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type Primitive =
|
|
2
|
+
| never
|
|
3
|
+
| undefined
|
|
4
|
+
| null
|
|
5
|
+
| boolean
|
|
6
|
+
| number
|
|
7
|
+
| string
|
|
8
|
+
| bigint
|
|
9
|
+
| symbol;
|
|
10
|
+
|
|
11
|
+
export const isPrimitive = (value: any): value is Primitive =>
|
|
12
|
+
value === undefined ||
|
|
13
|
+
value === null ||
|
|
14
|
+
typeof value === "boolean" ||
|
|
15
|
+
typeof value === "number" ||
|
|
16
|
+
typeof value === "string" ||
|
|
17
|
+
typeof value === "symbol" ||
|
|
18
|
+
typeof value === "bigint";
|
package/src/destroy.ts
CHANGED
package/src/diff.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type Diff = NoopDiff | UpdateDiff | ReplaceDiff;
|
|
2
|
+
|
|
3
|
+
export interface NoopDiff {
|
|
4
|
+
action: "noop";
|
|
5
|
+
stables?: undefined;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface UpdateDiff {
|
|
9
|
+
action: "update";
|
|
10
|
+
/** properties that won't change as part of this update */
|
|
11
|
+
stables?: string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ReplaceDiff {
|
|
15
|
+
action: "replace";
|
|
16
|
+
deleteFirst?: boolean;
|
|
17
|
+
stables?: undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const somePropsAreDifferent = <Props extends Record<string, any>>(
|
|
21
|
+
olds: Props,
|
|
22
|
+
news: Props,
|
|
23
|
+
props: (keyof Props)[],
|
|
24
|
+
) => {
|
|
25
|
+
for (const prop of props) {
|
|
26
|
+
if (olds[prop] !== news[prop]) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const anyPropsAreDifferent = <Props extends Record<string, any>>(
|
|
34
|
+
olds: Props,
|
|
35
|
+
news: Props,
|
|
36
|
+
) => {
|
|
37
|
+
for (const prop in olds) {
|
|
38
|
+
if (olds[prop] !== news[prop]) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const prop in news) {
|
|
43
|
+
if (!(prop in olds)) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
};
|
package/src/env.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
|
+
let _env;
|
|
2
|
+
try {
|
|
3
|
+
// @ts-expect-error
|
|
4
|
+
const { env } = await import("cloudflare:workers");
|
|
5
|
+
_env = env;
|
|
6
|
+
} catch {
|
|
7
|
+
if (typeof process !== "undefined") {
|
|
8
|
+
_env = process.env;
|
|
9
|
+
} else {
|
|
10
|
+
_env = import.meta.env;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Env {
|
|
15
|
+
[key: string]: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const env: Env = _env;
|
|
19
|
+
|
|
1
20
|
export const toEnvKey = <const ID extends string, const Suffix extends string>(
|
|
2
21
|
id: ID,
|
|
3
22
|
suffix: Suffix,
|
|
4
23
|
) => `${replace(toUpper(id))}_${replace(toUpper(suffix))}` as const;
|
|
5
24
|
|
|
6
|
-
const toUpper = <const S extends string>(str: S) =>
|
|
25
|
+
export const toUpper = <const S extends string>(str: S) =>
|
|
7
26
|
str.toUpperCase() as string extends S ? S : Uppercase<S>;
|
|
8
27
|
|
|
9
28
|
const replace = <const S extends string>(str: S) =>
|
|
@@ -18,34 +37,3 @@ type Replace<S extends string, Accum extends string = ""> = string extends S
|
|
|
18
37
|
? Replace<Rest, `${Accum}_`>
|
|
19
38
|
: Replace<Rest, `${Accum}${S}`>
|
|
20
39
|
: Accum;
|
|
21
|
-
|
|
22
|
-
function _test_both_literals() {
|
|
23
|
-
const key = toEnvKey("my-id", "my-suffix");
|
|
24
|
-
const _: typeof key = "MY_ID_MY_SUFFIX";
|
|
25
|
-
// @ts-expect-error
|
|
26
|
-
const _err: typeof key = "MY_ID_MY_SUFFIX2";
|
|
27
|
-
}
|
|
28
|
-
function _test_replace_wide_string() {
|
|
29
|
-
const ___ = toUpper(undefined! as string);
|
|
30
|
-
const id: string = "my-id";
|
|
31
|
-
const key = toEnvKey(id, "my-suffix");
|
|
32
|
-
const _: typeof key = "MY_ID_MY_SUFFIX";
|
|
33
|
-
const _2: typeof key = `${id}_MY_SUFFIX` as const;
|
|
34
|
-
// @ts-expect-error
|
|
35
|
-
const _err: typeof key = "MY_ID_MY_SUFFIX2";
|
|
36
|
-
// @ts-expect-error
|
|
37
|
-
const _err2: typeof key = `${id}_MY_SUFFIX2` as const;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _test_replace_wide_suffix() {
|
|
41
|
-
const ___ = toUpper(undefined! as string);
|
|
42
|
-
const id = "my-id";
|
|
43
|
-
const suffix = "my-suffix" as string;
|
|
44
|
-
const key = toEnvKey(id, suffix);
|
|
45
|
-
const _: typeof key = "MY_ID_MY_SUFFIX";
|
|
46
|
-
const _2: typeof key = `MY_ID_${suffix}` as const;
|
|
47
|
-
// @ts-expect-error
|
|
48
|
-
const _err: typeof key = "WRONG_PREFIX_MY_SUFFIX";
|
|
49
|
-
// @ts-expect-error
|
|
50
|
-
const _err2: typeof key = `WRONG_PREFIX_${suffix}`;
|
|
51
|
-
}
|