alchemy-effect 0.1.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 +7 -15
- package/lib/app.d.ts.map +1 -1
- package/lib/app.js +1 -20
- package/lib/app.js.map +1 -1
- package/lib/apply.d.ts +15 -19
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +173 -82
- 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 +13 -3
- package/lib/aws/account.d.ts.map +1 -1
- package/lib/aws/account.js +19 -4
- package/lib/aws/account.js.map +1 -1
- package/lib/aws/arn.d.ts +1 -5
- package/lib/aws/arn.d.ts.map +1 -1
- package/lib/aws/client.d.ts.map +1 -1
- package/lib/aws/client.js +8 -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 +11 -1
- 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/attribute-value.d.ts +20 -0
- package/lib/aws/dynamodb/attribute-value.d.ts.map +1 -0
- package/lib/aws/dynamodb/attribute-value.js +217 -0
- package/lib/aws/dynamodb/attribute-value.js.map +1 -0
- package/lib/aws/dynamodb/client.d.ts +12 -0
- package/lib/aws/dynamodb/client.d.ts.map +1 -0
- package/lib/aws/{sqs/queue.client.js → dynamodb/client.js} +6 -6
- package/lib/aws/dynamodb/client.js.map +1 -0
- package/lib/aws/dynamodb/expr.d.ts +41 -0
- package/lib/aws/dynamodb/expr.d.ts.map +1 -0
- package/lib/aws/dynamodb/expr.js +1 -0
- package/lib/aws/dynamodb/expr.js.map +1 -0
- package/lib/aws/dynamodb/index.d.ts +10 -0
- package/lib/aws/dynamodb/index.d.ts.map +1 -0
- package/lib/aws/dynamodb/index.js +9 -0
- package/lib/aws/dynamodb/index.js.map +1 -0
- package/lib/aws/dynamodb/projection.d.ts +25 -0
- package/lib/aws/dynamodb/projection.d.ts.map +1 -0
- package/lib/aws/dynamodb/projection.js +1 -0
- package/lib/aws/dynamodb/projection.js.map +1 -0
- package/lib/aws/dynamodb/secondary-index.d.ts +26 -0
- package/lib/aws/dynamodb/secondary-index.d.ts.map +1 -0
- package/lib/aws/dynamodb/secondary-index.js +4 -0
- package/lib/aws/dynamodb/secondary-index.js.map +1 -0
- package/lib/aws/dynamodb/table.d.ts +59 -0
- package/lib/aws/dynamodb/table.d.ts.map +1 -0
- package/lib/aws/dynamodb/table.get-item.d.ts +57 -0
- package/lib/aws/dynamodb/table.get-item.d.ts.map +1 -0
- package/lib/aws/dynamodb/table.get-item.js +77 -0
- package/lib/aws/dynamodb/table.get-item.js.map +1 -0
- package/lib/aws/dynamodb/table.js +4 -0
- package/lib/aws/dynamodb/table.js.map +1 -0
- package/lib/aws/dynamodb/table.provider.d.ts +7 -0
- package/lib/aws/dynamodb/table.provider.d.ts.map +1 -0
- package/lib/aws/dynamodb/table.provider.js +187 -0
- package/lib/aws/dynamodb/table.provider.js.map +1 -0
- package/lib/aws/ec2/client.d.ts +12 -0
- package/lib/aws/ec2/client.d.ts.map +1 -0
- package/lib/aws/ec2/client.js +11 -0
- package/lib/aws/ec2/client.js.map +1 -0
- package/lib/aws/ec2/index.d.ts +7 -0
- package/lib/aws/ec2/index.d.ts.map +1 -0
- package/lib/aws/ec2/index.js +7 -0
- package/lib/aws/ec2/index.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 +135 -0
- package/lib/aws/ec2/vpc.d.ts.map +1 -0
- package/lib/aws/ec2/vpc.js +4 -0
- package/lib/aws/ec2/vpc.js.map +1 -0
- package/lib/aws/ec2/vpc.provider.d.ts +6 -0
- package/lib/aws/ec2/vpc.provider.d.ts.map +1 -0
- package/lib/aws/ec2/vpc.provider.js +183 -0
- package/lib/aws/ec2/vpc.provider.js.map +1 -0
- package/lib/aws/index.d.ts +23 -16
- package/lib/aws/index.d.ts.map +1 -1
- package/lib/aws/index.js +10 -18
- package/lib/aws/index.js.map +1 -1
- package/lib/aws/lambda/client.d.ts +8 -0
- package/lib/aws/lambda/client.d.ts.map +1 -0
- package/lib/aws/lambda/client.js +7 -0
- package/lib/aws/lambda/client.js.map +1 -0
- package/lib/aws/lambda/consume.d.ts +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 +18 -15
- 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 +7 -5
- package/lib/aws/lambda/function.invoke.d.ts.map +1 -1
- package/lib/aws/lambda/function.invoke.js +5 -3
- 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 +6 -5
- package/lib/aws/lambda/function.provider.d.ts.map +1 -1
- package/lib/aws/lambda/function.provider.js +150 -58
- package/lib/aws/lambda/function.provider.js.map +1 -1
- package/lib/aws/lambda/index.d.ts +2 -2
- package/lib/aws/lambda/index.d.ts.map +1 -1
- package/lib/aws/lambda/index.js +2 -1
- 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/lambda/serve.js.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 -1
- 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 +12 -0
- package/lib/aws/sqs/client.d.ts.map +1 -0
- package/lib/aws/sqs/client.js +11 -0
- package/lib/aws/sqs/client.js.map +1 -0
- package/lib/aws/sqs/index.d.ts +3 -1
- package/lib/aws/sqs/index.d.ts.map +1 -1
- package/lib/aws/sqs/index.js +3 -1
- package/lib/aws/sqs/index.js.map +1 -1
- package/lib/aws/sqs/queue.consume.d.ts +1 -10
- package/lib/aws/sqs/queue.consume.d.ts.map +1 -1
- package/lib/aws/sqs/queue.consume.js +0 -19
- package/lib/aws/sqs/queue.consume.js.map +1 -1
- package/lib/aws/sqs/queue.d.ts +6 -12
- package/lib/aws/sqs/queue.d.ts.map +1 -1
- package/lib/aws/sqs/queue.event-source.d.ts +22 -0
- package/lib/aws/sqs/queue.event-source.d.ts.map +1 -0
- package/lib/aws/sqs/queue.event-source.js +130 -0
- package/lib/aws/sqs/queue.event-source.js.map +1 -0
- 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 +5 -4
- package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
- package/lib/aws/sqs/queue.provider.js +6 -6
- package/lib/aws/sqs/queue.provider.js.map +1 -1
- package/lib/aws/sqs/queue.send-message.d.ts +8 -6
- package/lib/aws/sqs/queue.send-message.d.ts.map +1 -1
- package/lib/aws/sqs/queue.send-message.js +6 -4
- package/lib/aws/sqs/queue.send-message.js.map +1 -1
- package/lib/binding.d.ts +74 -26
- package/lib/binding.d.ts.map +1 -1
- package/lib/binding.js.map +1 -1
- package/lib/capability.d.ts +38 -0
- package/lib/capability.d.ts.map +1 -1
- package/lib/cli/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 +3 -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 +342 -213
- package/lib/cli/index.d.ts.map +1 -1
- package/lib/cli/index.js +26047 -11403
- 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 +31 -19
- package/lib/cloudflare/api.d.ts.map +1 -1
- package/lib/cloudflare/api.js +95 -29
- 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/context.d.ts +27 -0
- package/lib/cloudflare/context.d.ts.map +1 -0
- package/lib/cloudflare/context.js +24 -0
- package/lib/cloudflare/context.js.map +1 -0
- package/lib/cloudflare/index.d.ts +7 -4
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +7 -4
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/kv/index.d.ts +4 -0
- package/lib/cloudflare/kv/index.d.ts.map +1 -0
- package/lib/cloudflare/kv/index.js +4 -0
- package/lib/cloudflare/kv/index.js.map +1 -0
- package/lib/cloudflare/kv/namespace.binding.d.ts +10 -0
- package/lib/cloudflare/kv/namespace.binding.d.ts.map +1 -0
- package/lib/cloudflare/kv/namespace.binding.js +15 -0
- package/lib/cloudflare/kv/namespace.binding.js.map +1 -0
- package/lib/cloudflare/kv/namespace.client.d.ts +11 -0
- package/lib/cloudflare/kv/namespace.client.d.ts.map +1 -0
- package/lib/cloudflare/kv/namespace.client.js +31 -0
- package/lib/cloudflare/kv/namespace.client.js.map +1 -0
- package/lib/cloudflare/kv/namespace.d.ts +24 -0
- package/lib/cloudflare/kv/namespace.d.ts.map +1 -0
- package/lib/cloudflare/kv/namespace.js +3 -0
- package/lib/cloudflare/kv/namespace.js.map +1 -0
- package/lib/cloudflare/kv/namespace.provider.d.ts +6 -0
- package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -0
- package/lib/cloudflare/kv/namespace.provider.js +81 -0
- package/lib/cloudflare/kv/namespace.provider.js.map +1 -0
- package/lib/cloudflare/live.d.ts +11 -0
- package/lib/cloudflare/live.d.ts.map +1 -0
- package/lib/cloudflare/live.js +15 -0
- package/lib/cloudflare/live.js.map +1 -0
- package/lib/cloudflare/r2/bucket.binding.d.ts +10 -0
- package/lib/cloudflare/r2/bucket.binding.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.binding.js +18 -0
- package/lib/cloudflare/r2/bucket.binding.js.map +1 -0
- package/lib/cloudflare/r2/bucket.client.d.ts +8 -0
- package/lib/cloudflare/r2/bucket.client.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.client.js +9 -0
- package/lib/cloudflare/r2/bucket.client.js.map +1 -0
- package/lib/cloudflare/r2/bucket.d.ts +33 -0
- package/lib/cloudflare/r2/bucket.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.del.d.ts +4 -0
- package/lib/cloudflare/r2/bucket.del.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.del.js +7 -0
- package/lib/cloudflare/r2/bucket.del.js.map +1 -0
- package/lib/cloudflare/r2/bucket.get.d.ts +5 -0
- package/lib/cloudflare/r2/bucket.get.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.get.js +7 -0
- package/lib/cloudflare/r2/bucket.get.js.map +1 -0
- package/lib/cloudflare/r2/bucket.head.d.ts +4 -0
- package/lib/cloudflare/r2/bucket.head.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.head.js +7 -0
- package/lib/cloudflare/r2/bucket.head.js.map +1 -0
- package/lib/cloudflare/r2/bucket.js +3 -0
- package/lib/cloudflare/r2/bucket.js.map +1 -0
- package/lib/cloudflare/r2/bucket.list.d.ts +5 -0
- package/lib/cloudflare/r2/bucket.list.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.list.js +7 -0
- package/lib/cloudflare/r2/bucket.list.js.map +1 -0
- package/lib/cloudflare/r2/bucket.multipart.d.ts +19 -0
- package/lib/cloudflare/r2/bucket.multipart.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.multipart.js +25 -0
- package/lib/cloudflare/r2/bucket.multipart.js.map +1 -0
- package/lib/cloudflare/r2/bucket.provider.d.ts +6 -0
- package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.provider.js +67 -0
- package/lib/cloudflare/r2/bucket.provider.js.map +1 -0
- package/lib/cloudflare/r2/bucket.put.d.ts +6 -0
- package/lib/cloudflare/r2/bucket.put.d.ts.map +1 -0
- package/lib/cloudflare/r2/bucket.put.js +8 -0
- package/lib/cloudflare/r2/bucket.put.js.map +1 -0
- package/lib/cloudflare/r2/index.d.ts +10 -0
- package/lib/cloudflare/r2/index.d.ts.map +1 -0
- package/lib/cloudflare/r2/index.js +10 -0
- package/lib/cloudflare/r2/index.js.map +1 -0
- package/lib/cloudflare/stream.d.ts +10 -0
- package/lib/cloudflare/stream.d.ts.map +1 -0
- package/lib/cloudflare/stream.js +16 -0
- package/lib/cloudflare/stream.js.map +1 -0
- package/lib/cloudflare/worker/assets.fetch.d.ts +9 -0
- package/lib/cloudflare/worker/assets.fetch.d.ts.map +1 -0
- package/lib/cloudflare/worker/assets.fetch.js +12 -0
- package/lib/cloudflare/worker/assets.fetch.js.map +1 -0
- package/lib/cloudflare/worker/assets.provider.d.ts +66 -0
- package/lib/cloudflare/worker/assets.provider.d.ts.map +1 -0
- package/lib/cloudflare/worker/assets.provider.js +145 -0
- package/lib/cloudflare/worker/assets.provider.js.map +1 -0
- package/lib/cloudflare/worker/index.d.ts +5 -0
- package/lib/cloudflare/worker/index.d.ts.map +1 -0
- package/lib/cloudflare/worker/index.js +5 -0
- package/lib/cloudflare/worker/index.js.map +1 -0
- package/lib/cloudflare/worker/worker.d.ts +66 -0
- package/lib/cloudflare/worker/worker.d.ts.map +1 -0
- package/lib/cloudflare/worker/worker.handler.d.ts +11 -0
- package/lib/cloudflare/worker/worker.handler.d.ts.map +1 -0
- package/lib/cloudflare/worker/worker.handler.js +15 -0
- package/lib/cloudflare/worker/worker.handler.js.map +1 -0
- package/lib/cloudflare/worker/worker.js +4 -0
- package/lib/cloudflare/worker/worker.js.map +1 -0
- package/lib/cloudflare/worker/worker.provider.d.ts +11 -0
- package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -0
- package/lib/cloudflare/worker/worker.provider.js +194 -0
- package/lib/cloudflare/worker/worker.provider.js.map +1 -0
- package/lib/cloudflare/worker/worker.serve.d.ts +39 -0
- package/lib/cloudflare/worker/worker.serve.d.ts.map +1 -0
- package/lib/cloudflare/worker/worker.serve.js +4 -0
- package/lib/cloudflare/worker/worker.serve.js.map +1 -0
- package/lib/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 -3
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js +2 -0
- 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/dot-alchemy.d.ts +3 -2
- package/lib/dot-alchemy.d.ts.map +1 -1
- package/lib/dot-alchemy.js +3 -2
- package/lib/dot-alchemy.js.map +1 -1
- package/lib/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/esbuild.d.ts +28 -0
- package/lib/esbuild.d.ts.map +1 -0
- package/lib/esbuild.js +63 -0
- package/lib/esbuild.js.map +1 -0
- package/lib/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 +11 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +11 -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 +59 -29
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +347 -169
- package/lib/plan.js.map +1 -1
- package/lib/policy.d.ts +22 -5
- package/lib/policy.d.ts.map +1 -1
- package/lib/policy.js +10 -2
- package/lib/policy.js.map +1 -1
- package/lib/provider.d.ts +16 -18
- 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 +13 -16
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js +1 -0
- package/lib/resource.js.map +1 -1
- package/lib/runtime.d.ts +8 -7
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js.map +1 -1
- package/lib/schema.d.ts +37 -0
- package/lib/schema.d.ts.map +1 -0
- package/lib/schema.js +61 -0
- package/lib/schema.js.map +1 -0
- package/lib/service.d.ts +9 -6
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js.map +1 -1
- package/lib/sha256.d.ts +5 -0
- package/lib/sha256.d.ts.map +1 -0
- package/lib/sha256.js +16 -0
- package/lib/sha256.js.map +1 -0
- package/lib/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 +53 -11
- package/lib/state.d.ts.map +1 -1
- package/lib/state.js +33 -31
- package/lib/state.js.map +1 -1
- package/lib/tags.d.ts +17 -0
- package/lib/tags.d.ts.map +1 -0
- package/lib/tags.js +22 -0
- package/lib/tags.js.map +1 -0
- package/lib/test.d.ts +35 -0
- package/lib/test.d.ts.map +1 -0
- package/lib/test.js +68 -0
- package/lib/test.js.map +1 -0
- package/lib/tsconfig.test.tsbuildinfo +1 -0
- package/lib/type.d.ts +6 -0
- package/lib/type.d.ts.map +1 -0
- package/lib/type.js +3 -0
- package/lib/type.js.map +1 -0
- 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 +58 -7
- package/src/$.ts +17 -0
- package/src/app.ts +9 -37
- package/src/apply.ts +435 -289
- package/src/assert-never.ts +18 -0
- package/src/aws/account.ts +29 -7
- package/src/aws/arn.ts +1 -7
- package/src/aws/client.ts +14 -1
- package/src/aws/config.ts +16 -0
- package/src/aws/credentials.ts +213 -177
- package/src/aws/dynamodb/attribute-value.ts +240 -0
- package/src/aws/{sqs/queue.client.ts → dynamodb/client.ts} +9 -9
- package/src/aws/dynamodb/expr.ts +90 -0
- package/src/aws/dynamodb/index.ts +12 -0
- package/src/aws/dynamodb/projection.ts +159 -0
- package/src/aws/dynamodb/secondary-index.ts +45 -0
- package/src/aws/dynamodb/table.get-item.ts +173 -0
- package/src/aws/dynamodb/table.provider.ts +276 -0
- package/src/aws/dynamodb/table.ts +101 -0
- package/src/aws/ec2/client.ts +20 -0
- package/src/aws/ec2/index.ts +7 -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 +269 -0
- package/src/aws/ec2/vpc.ts +163 -0
- package/src/aws/index.ts +50 -45
- package/src/aws/lambda/client.ts +14 -0
- package/src/aws/lambda/consume.ts +8 -8
- package/src/aws/lambda/function.handler.ts +1 -1
- package/src/aws/lambda/function.invoke.ts +8 -4
- package/src/aws/lambda/function.provider.ts +208 -109
- package/src/aws/lambda/function.ts +21 -12
- package/src/aws/lambda/index.ts +3 -4
- package/src/aws/lambda/serve.ts +1 -1
- package/src/aws/profile.ts +1 -4
- package/src/aws/region.ts +43 -2
- package/src/aws/sqs/client.ts +20 -0
- package/src/aws/sqs/index.ts +4 -1
- package/src/aws/sqs/queue.consume.ts +1 -34
- package/src/aws/sqs/queue.event-source.ts +227 -0
- package/src/aws/sqs/queue.provider.ts +14 -7
- package/src/aws/sqs/queue.send-message.ts +7 -10
- package/src/aws/sqs/queue.ts +9 -4
- package/src/binding.ts +130 -34
- package/src/capability.ts +44 -0
- package/src/cli/components/ApprovePlan.tsx +2 -2
- package/src/cli/components/Plan.tsx +6 -3
- 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 +147 -63
- package/src/cloudflare/config.ts +7 -0
- package/src/cloudflare/context.ts +49 -0
- package/src/cloudflare/index.ts +8 -4
- package/src/cloudflare/kv/index.ts +3 -0
- package/src/cloudflare/kv/namespace.binding.ts +27 -0
- package/src/cloudflare/kv/namespace.client.ts +70 -0
- package/src/cloudflare/kv/namespace.provider.ts +100 -0
- package/src/cloudflare/kv/namespace.ts +30 -0
- package/src/cloudflare/live.ts +32 -0
- package/src/cloudflare/r2/bucket.binding.ts +29 -0
- package/src/cloudflare/r2/bucket.client.ts +22 -0
- package/src/cloudflare/r2/bucket.del.ts +11 -0
- package/src/cloudflare/r2/bucket.get.ts +13 -0
- package/src/cloudflare/r2/bucket.head.ts +11 -0
- package/src/cloudflare/r2/bucket.list.ts +12 -0
- package/src/cloudflare/r2/bucket.multipart.ts +55 -0
- package/src/cloudflare/r2/bucket.provider.ts +84 -0
- package/src/cloudflare/r2/bucket.put.ts +17 -0
- package/src/cloudflare/r2/bucket.ts +44 -0
- package/src/cloudflare/r2/index.ts +9 -0
- package/src/cloudflare/stream.ts +21 -0
- package/src/cloudflare/worker/assets.fetch.ts +29 -0
- package/src/cloudflare/worker/assets.provider.ts +249 -0
- package/src/cloudflare/worker/index.ts +4 -0
- package/src/cloudflare/worker/worker.handler.ts +39 -0
- package/src/cloudflare/worker/worker.provider.ts +249 -0
- package/src/cloudflare/worker/worker.serve.ts +22 -0
- package/src/cloudflare/worker/worker.ts +77 -0
- package/src/data.ts +18 -0
- package/src/destroy.ts +2 -3
- package/src/diff.ts +30 -0
- package/src/dot-alchemy.ts +3 -2
- package/src/env.ts +20 -32
- package/src/esbuild.ts +98 -0
- package/src/exports.ts +21 -0
- package/src/index.ts +12 -6
- package/src/input.ts +81 -0
- package/src/output.ts +518 -0
- package/src/plan.ts +544 -243
- package/src/policy.ts +58 -7
- package/src/provider.ts +27 -25
- package/src/ref.ts +48 -0
- package/src/resource.ts +23 -8
- package/src/runtime.ts +16 -9
- package/src/schema.ts +102 -0
- package/src/service.ts +11 -7
- package/src/sha256.ts +23 -0
- package/src/stack.ts +116 -0
- package/src/stage.ts +85 -0
- package/src/state.ts +141 -62
- package/src/tags.ts +38 -0
- package/src/test.ts +172 -0
- package/src/type.ts +6 -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/aws/lambda/function.client.d.ts +0 -8
- package/lib/aws/lambda/function.client.d.ts.map +0 -1
- package/lib/aws/lambda/function.client.js +0 -7
- package/lib/aws/lambda/function.client.js.map +0 -1
- package/lib/aws/sqs/queue.client.d.ts +0 -12
- package/lib/aws/sqs/queue.client.d.ts.map +0 -1
- package/lib/aws/sqs/queue.client.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 -29
- 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/lib/cloudflare/kv.d.ts +0 -29
- package/lib/cloudflare/kv.d.ts.map +0 -1
- package/lib/cloudflare/kv.js +0 -3
- package/lib/cloudflare/kv.js.map +0 -1
- package/lib/cloudflare/kv.provider.d.ts +0 -4
- package/lib/cloudflare/kv.provider.d.ts.map +0 -1
- package/lib/cloudflare/kv.provider.js +0 -39
- package/lib/cloudflare/kv.provider.js.map +0 -1
- package/lib/cloudflare/worker.d.ts +0 -33
- package/lib/cloudflare/worker.d.ts.map +0 -1
- package/lib/cloudflare/worker.js +0 -4
- package/lib/cloudflare/worker.js.map +0 -1
- package/src/approve.ts +0 -13
- package/src/aws/lambda/function.client.ts +0 -14
- 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 -45
- package/src/cli/spinner.ts +0 -14
- package/src/cloudflare/kv.provider.ts +0 -51
- package/src/cloudflare/kv.ts +0 -20
- package/src/cloudflare/worker.ts +0 -34
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { FileSystem, Path } from "@effect/platform";
|
|
2
|
+
import type { PlatformError } from "@effect/platform/Error";
|
|
3
|
+
import { Context, Data, Layer } from "effect";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import type { ScopedPlanStatusSession } from "../../cli/service.ts";
|
|
6
|
+
import { sha256 } from "../../sha256.ts";
|
|
7
|
+
import { CloudflareApi, CloudflareApiError } from "../api.ts";
|
|
8
|
+
import type { Worker } from "./worker.ts";
|
|
9
|
+
|
|
10
|
+
const MAX_ASSET_SIZE = 1024 * 1024 * 25; // 25MB
|
|
11
|
+
const MAX_ASSET_COUNT = 20_000;
|
|
12
|
+
|
|
13
|
+
export declare namespace Assets {
|
|
14
|
+
export interface ReadResult {
|
|
15
|
+
directory: string;
|
|
16
|
+
config: Worker.AssetsConfig | undefined;
|
|
17
|
+
manifest: Record<string, { hash: string; size: number }>;
|
|
18
|
+
_headers: string | undefined;
|
|
19
|
+
_redirects: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class Assets extends Context.Tag("Assets")<
|
|
24
|
+
Assets,
|
|
25
|
+
{
|
|
26
|
+
read(
|
|
27
|
+
directory: Worker.AssetsProps,
|
|
28
|
+
): Effect.Effect<Assets.ReadResult, PlatformError | ValidationError>;
|
|
29
|
+
upload(
|
|
30
|
+
accountId: string,
|
|
31
|
+
workerName: string,
|
|
32
|
+
assets: Assets.ReadResult,
|
|
33
|
+
session: ScopedPlanStatusSession,
|
|
34
|
+
): Effect.Effect<
|
|
35
|
+
{ jwt: string | undefined },
|
|
36
|
+
PlatformError | ValidationError | CloudflareApiError
|
|
37
|
+
>;
|
|
38
|
+
}
|
|
39
|
+
>() {}
|
|
40
|
+
|
|
41
|
+
export class AssetTooLargeError extends Data.TaggedError("AssetTooLargeError")<{
|
|
42
|
+
message: string;
|
|
43
|
+
name: string;
|
|
44
|
+
size: number;
|
|
45
|
+
}> {}
|
|
46
|
+
|
|
47
|
+
export class TooManyAssetsError extends Data.TaggedError("TooManyAssetsError")<{
|
|
48
|
+
message: string;
|
|
49
|
+
directory: string;
|
|
50
|
+
count: number;
|
|
51
|
+
}> {}
|
|
52
|
+
|
|
53
|
+
export class AssetNotFoundError extends Data.TaggedError("AssetNotFoundError")<{
|
|
54
|
+
message: string;
|
|
55
|
+
hash: string;
|
|
56
|
+
}> {}
|
|
57
|
+
|
|
58
|
+
export class FailedToReadAssetError extends Data.TaggedError(
|
|
59
|
+
"FailedToReadAssetError",
|
|
60
|
+
)<{
|
|
61
|
+
message: string;
|
|
62
|
+
name: string;
|
|
63
|
+
cause: PlatformError;
|
|
64
|
+
}> {}
|
|
65
|
+
|
|
66
|
+
export type ValidationError =
|
|
67
|
+
| AssetTooLargeError
|
|
68
|
+
| TooManyAssetsError
|
|
69
|
+
| AssetNotFoundError
|
|
70
|
+
| FailedToReadAssetError;
|
|
71
|
+
|
|
72
|
+
export const assetsProvider = () =>
|
|
73
|
+
Layer.effect(
|
|
74
|
+
Assets,
|
|
75
|
+
Effect.gen(function* () {
|
|
76
|
+
const fs = yield* FileSystem.FileSystem;
|
|
77
|
+
const path = yield* Path.Path;
|
|
78
|
+
const api = yield* CloudflareApi;
|
|
79
|
+
|
|
80
|
+
const maybeReadString = Effect.fnUntraced(function* (file: string) {
|
|
81
|
+
return yield* fs.readFileString(file).pipe(
|
|
82
|
+
Effect.catchIf(
|
|
83
|
+
(error) =>
|
|
84
|
+
error._tag === "SystemError" && error.reason === "NotFound",
|
|
85
|
+
() => Effect.succeed(undefined),
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const createIgnoreMatcher = Effect.fnUntraced(function* (
|
|
91
|
+
patterns: string[],
|
|
92
|
+
) {
|
|
93
|
+
const matcher = yield* Effect.promise(() =>
|
|
94
|
+
import("ignore").then(({ default: ignore }) =>
|
|
95
|
+
ignore().add(patterns),
|
|
96
|
+
),
|
|
97
|
+
);
|
|
98
|
+
return (file: string) => matcher.ignores(file);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
read: Effect.fnUntraced(function* (props: Worker.AssetsProps) {
|
|
103
|
+
const resolvedDirectory = path.resolve(props.directory);
|
|
104
|
+
const [files, ignore, _headers, _redirects] = yield* Effect.all([
|
|
105
|
+
fs.readDirectory(resolvedDirectory, { recursive: true }),
|
|
106
|
+
maybeReadString(path.join(resolvedDirectory, ".assetsignore")),
|
|
107
|
+
maybeReadString(path.join(resolvedDirectory, "_headers")),
|
|
108
|
+
maybeReadString(path.join(resolvedDirectory, "_redirects")),
|
|
109
|
+
]);
|
|
110
|
+
const ignores = yield* createIgnoreMatcher([
|
|
111
|
+
".assetsignore",
|
|
112
|
+
"_headers",
|
|
113
|
+
"_redirects",
|
|
114
|
+
...(ignore
|
|
115
|
+
?.split("\n")
|
|
116
|
+
.map((line) => line.trim())
|
|
117
|
+
.filter((line) => line.length > 0 && !line.startsWith("#")) ??
|
|
118
|
+
[]),
|
|
119
|
+
]);
|
|
120
|
+
const manifest = new Map<string, { hash: string; size: number }>();
|
|
121
|
+
let count = 0;
|
|
122
|
+
yield* Effect.forEach(
|
|
123
|
+
files,
|
|
124
|
+
Effect.fnUntraced(function* (name) {
|
|
125
|
+
if (ignores(name)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const file = path.join(resolvedDirectory, name);
|
|
129
|
+
const stat = yield* fs.stat(file);
|
|
130
|
+
if (stat.type !== "File") {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const size = Number(stat.size);
|
|
134
|
+
if (size > MAX_ASSET_SIZE) {
|
|
135
|
+
return yield* new AssetTooLargeError({
|
|
136
|
+
message: `Asset ${name} is too large (the maximum size is ${MAX_ASSET_SIZE / 1024 / 1024} MB; this asset is ${size / 1024 / 1024} MB)`,
|
|
137
|
+
name,
|
|
138
|
+
size,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const hash = yield* fs.readFile(file).pipe(
|
|
142
|
+
Effect.flatMap(sha256),
|
|
143
|
+
Effect.map((hash) => hash.slice(0, 32)),
|
|
144
|
+
);
|
|
145
|
+
count++;
|
|
146
|
+
if (count > MAX_ASSET_COUNT) {
|
|
147
|
+
return yield* new TooManyAssetsError({
|
|
148
|
+
message: `Too many assets (the maximum count is ${MAX_ASSET_COUNT}; this directory has ${count} assets)`,
|
|
149
|
+
directory: props.directory,
|
|
150
|
+
count,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
manifest.set(name.startsWith("/") ? name : `/${name}`, {
|
|
154
|
+
hash,
|
|
155
|
+
size,
|
|
156
|
+
});
|
|
157
|
+
}),
|
|
158
|
+
);
|
|
159
|
+
return {
|
|
160
|
+
directory: props.directory,
|
|
161
|
+
config: props.config,
|
|
162
|
+
manifest: Object.fromEntries(
|
|
163
|
+
Array.from(manifest.entries()).sort((a, b) =>
|
|
164
|
+
a[0].localeCompare(b[0]),
|
|
165
|
+
),
|
|
166
|
+
),
|
|
167
|
+
_headers,
|
|
168
|
+
_redirects,
|
|
169
|
+
};
|
|
170
|
+
}),
|
|
171
|
+
upload: Effect.fnUntraced(function* (
|
|
172
|
+
accountId: string,
|
|
173
|
+
workerName: string,
|
|
174
|
+
assets: Assets.ReadResult,
|
|
175
|
+
{ note }: ScopedPlanStatusSession,
|
|
176
|
+
) {
|
|
177
|
+
yield* note("Checking assets...");
|
|
178
|
+
const session = yield* api.workers.scripts.assets.upload.create(
|
|
179
|
+
workerName,
|
|
180
|
+
{
|
|
181
|
+
account_id: accountId,
|
|
182
|
+
manifest: assets.manifest,
|
|
183
|
+
},
|
|
184
|
+
);
|
|
185
|
+
if (!session.buckets?.length) {
|
|
186
|
+
return { jwt: session.jwt };
|
|
187
|
+
}
|
|
188
|
+
let uploaded = 0;
|
|
189
|
+
const total = session.buckets.flat().length;
|
|
190
|
+
yield* note(`Uploaded ${uploaded} of ${total} assets...`);
|
|
191
|
+
const assetsByHash = new Map<string, string>();
|
|
192
|
+
for (const [name, { hash }] of Object.entries(assets.manifest)) {
|
|
193
|
+
assetsByHash.set(hash, name);
|
|
194
|
+
}
|
|
195
|
+
let jwt: string | undefined;
|
|
196
|
+
const directory = path.resolve(assets.directory);
|
|
197
|
+
yield* Effect.forEach(
|
|
198
|
+
session.buckets,
|
|
199
|
+
Effect.fnUntraced(function* (bucket) {
|
|
200
|
+
const body: Record<string, string> = {};
|
|
201
|
+
yield* Effect.forEach(
|
|
202
|
+
bucket,
|
|
203
|
+
Effect.fnUntraced(function* (hash) {
|
|
204
|
+
const name = assetsByHash.get(hash);
|
|
205
|
+
if (!name) {
|
|
206
|
+
return yield* new AssetNotFoundError({
|
|
207
|
+
message: `Asset ${hash} not found in manifest`,
|
|
208
|
+
hash,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
const file = yield* fs
|
|
212
|
+
.readFile(path.join(directory, name))
|
|
213
|
+
.pipe(
|
|
214
|
+
Effect.mapError(
|
|
215
|
+
(error) =>
|
|
216
|
+
new FailedToReadAssetError({
|
|
217
|
+
message: `Failed to read asset ${name}: ${error.message}`,
|
|
218
|
+
name,
|
|
219
|
+
cause: error,
|
|
220
|
+
}),
|
|
221
|
+
),
|
|
222
|
+
);
|
|
223
|
+
body[hash] = Buffer.from(file).toString("base64");
|
|
224
|
+
}),
|
|
225
|
+
);
|
|
226
|
+
const result = yield* api.workers.assets.upload.create(
|
|
227
|
+
{
|
|
228
|
+
account_id: accountId,
|
|
229
|
+
base64: true,
|
|
230
|
+
body,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
headers: {
|
|
234
|
+
Authorization: `Bearer ${session.jwt}`,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
);
|
|
238
|
+
uploaded += bucket.length;
|
|
239
|
+
yield* note(`Uploaded ${uploaded} of ${total} assets...`);
|
|
240
|
+
if (result.jwt) {
|
|
241
|
+
jwt = result.jwt;
|
|
242
|
+
}
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
return { jwt };
|
|
246
|
+
}),
|
|
247
|
+
};
|
|
248
|
+
}),
|
|
249
|
+
);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type * as runtime from "@cloudflare/workers-types";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import type { Capability } from "../../capability.ts";
|
|
5
|
+
import { CloudflareContext } from "../context.ts";
|
|
6
|
+
|
|
7
|
+
type Handler = (
|
|
8
|
+
request: Request,
|
|
9
|
+
env: unknown,
|
|
10
|
+
ctx: runtime.ExecutionContext,
|
|
11
|
+
) => Effect.Effect<Response, any, CloudflareContext>;
|
|
12
|
+
type HandlerFactory<H extends Handler, Req = Capability> = Effect.Effect<
|
|
13
|
+
H,
|
|
14
|
+
any,
|
|
15
|
+
Req
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
export const toHandler = <H extends Handler>(
|
|
19
|
+
factory: HandlerFactory<H, Capability>,
|
|
20
|
+
) => {
|
|
21
|
+
return {
|
|
22
|
+
fetch: async (
|
|
23
|
+
request: Request,
|
|
24
|
+
env: unknown,
|
|
25
|
+
ctx: runtime.ExecutionContext,
|
|
26
|
+
) => {
|
|
27
|
+
const exit = await Effect.runPromiseExit(
|
|
28
|
+
(factory as HandlerFactory<H, never>).pipe(
|
|
29
|
+
Effect.flatMap((handler) => handler(request, env, ctx)),
|
|
30
|
+
Effect.provide(Layer.succeed(CloudflareContext, { env, ctx })),
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
if (exit._tag === "Success") {
|
|
34
|
+
return exit.value;
|
|
35
|
+
}
|
|
36
|
+
return Response.json(exit, { status: 500 });
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import * as FileSystem from "@effect/platform/FileSystem";
|
|
2
|
+
import * as Path from "@effect/platform/Path";
|
|
3
|
+
import type { Workers } from "cloudflare/resources.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { App } from "../../app.ts";
|
|
6
|
+
import type { ScopedPlanStatusSession } from "../../cli/service.ts";
|
|
7
|
+
import { DotAlchemy } from "../../dot-alchemy.ts";
|
|
8
|
+
import { ESBuild } from "../../esbuild.ts";
|
|
9
|
+
import { sha256 } from "../../sha256.ts";
|
|
10
|
+
import { CloudflareApi } from "../api.ts";
|
|
11
|
+
import { Account } from "../account.ts";
|
|
12
|
+
import { Assets } from "./assets.provider.ts";
|
|
13
|
+
import { Worker, type WorkerAttr, type WorkerProps } from "./worker.ts";
|
|
14
|
+
|
|
15
|
+
export const workerProvider = () =>
|
|
16
|
+
Worker.provider.effect(
|
|
17
|
+
Effect.gen(function* () {
|
|
18
|
+
const app = yield* App;
|
|
19
|
+
const api = yield* CloudflareApi;
|
|
20
|
+
const accountId = yield* Account;
|
|
21
|
+
const { read, upload } = yield* Assets;
|
|
22
|
+
const { build } = yield* ESBuild;
|
|
23
|
+
const fs = yield* FileSystem.FileSystem;
|
|
24
|
+
const path = yield* Path.Path;
|
|
25
|
+
const dotAlchemy = yield* DotAlchemy;
|
|
26
|
+
|
|
27
|
+
const getAccountSubdomain = yield* Effect.cachedFunction(
|
|
28
|
+
Effect.fnUntraced(function* (accountId: string) {
|
|
29
|
+
const { subdomain } = yield* api.workers.subdomains.get({
|
|
30
|
+
account_id: accountId,
|
|
31
|
+
});
|
|
32
|
+
return subdomain;
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// pre-fetch subdomain in background
|
|
37
|
+
yield* Effect.forkDaemon(getAccountSubdomain(accountId));
|
|
38
|
+
|
|
39
|
+
const setWorkerSubdomain = Effect.fnUntraced(function* (
|
|
40
|
+
name: string,
|
|
41
|
+
enabled: boolean,
|
|
42
|
+
) {
|
|
43
|
+
const subdomain = yield* api.workers.scripts.subdomain.create(name, {
|
|
44
|
+
account_id: accountId,
|
|
45
|
+
enabled,
|
|
46
|
+
});
|
|
47
|
+
yield* Effect.logDebug("setWorkerSubdomain", subdomain);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const createWorkerName = (id: string, name: string | undefined) =>
|
|
51
|
+
name ?? `${app.name}-${id}-${app.stage}`.toLowerCase();
|
|
52
|
+
|
|
53
|
+
const prepareAssets = Effect.fnUntraced(function* (
|
|
54
|
+
assets: WorkerProps["assets"],
|
|
55
|
+
) {
|
|
56
|
+
if (!assets) return undefined;
|
|
57
|
+
const result = yield* read(
|
|
58
|
+
typeof assets === "string" ? { directory: assets } : assets,
|
|
59
|
+
);
|
|
60
|
+
return {
|
|
61
|
+
...result,
|
|
62
|
+
hash: yield* sha256(JSON.stringify(result)),
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const prepareBundle = Effect.fnUntraced(function* (
|
|
67
|
+
id: string,
|
|
68
|
+
main: string,
|
|
69
|
+
) {
|
|
70
|
+
const outfile = path.join(dotAlchemy, "out", `${id}.js`);
|
|
71
|
+
yield* build({
|
|
72
|
+
entryPoints: [path.relative(process.cwd(), main)],
|
|
73
|
+
outfile,
|
|
74
|
+
write: true,
|
|
75
|
+
bundle: true,
|
|
76
|
+
format: "esm",
|
|
77
|
+
sourcemap: false,
|
|
78
|
+
treeShaking: true,
|
|
79
|
+
});
|
|
80
|
+
const code = yield* fs.readFileString(outfile);
|
|
81
|
+
return {
|
|
82
|
+
code,
|
|
83
|
+
hash: yield* sha256(code),
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const prepareMetadata = Effect.fnUntraced(function* (
|
|
88
|
+
props: WorkerProps<any>,
|
|
89
|
+
) {
|
|
90
|
+
const metadata: Workers.ScriptUpdateParams.Metadata = {
|
|
91
|
+
assets: undefined,
|
|
92
|
+
bindings: [],
|
|
93
|
+
body_part: undefined,
|
|
94
|
+
compatibility_date: props.compatibility?.date,
|
|
95
|
+
compatibility_flags: props.compatibility?.flags,
|
|
96
|
+
keep_assets: undefined,
|
|
97
|
+
keep_bindings: undefined,
|
|
98
|
+
limits: props.limits,
|
|
99
|
+
logpush: props.logpush,
|
|
100
|
+
main_module: "worker.js",
|
|
101
|
+
migrations: undefined,
|
|
102
|
+
observability: props.observability ?? {
|
|
103
|
+
enabled: true,
|
|
104
|
+
logs: {
|
|
105
|
+
enabled: true,
|
|
106
|
+
invocation_logs: true,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
placement: props.placement,
|
|
110
|
+
tags: props.tags,
|
|
111
|
+
tail_consumers: undefined,
|
|
112
|
+
usage_model: undefined,
|
|
113
|
+
};
|
|
114
|
+
return metadata;
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const putWorker = Effect.fnUntraced(function* (
|
|
118
|
+
id: string,
|
|
119
|
+
news: WorkerProps<any>,
|
|
120
|
+
bindings: Worker["binding"][],
|
|
121
|
+
olds: WorkerProps<any> | undefined,
|
|
122
|
+
output: WorkerAttr<WorkerProps<any>> | undefined,
|
|
123
|
+
session: ScopedPlanStatusSession,
|
|
124
|
+
) {
|
|
125
|
+
const name = createWorkerName(id, news.name);
|
|
126
|
+
const [assets, bundle, metadata] = yield* Effect.all([
|
|
127
|
+
prepareAssets(news.assets),
|
|
128
|
+
prepareBundle(id, news.main),
|
|
129
|
+
prepareMetadata(news),
|
|
130
|
+
]).pipe(Effect.orDie);
|
|
131
|
+
metadata.bindings = bindings.flatMap((binding) => binding.bindings);
|
|
132
|
+
if (assets) {
|
|
133
|
+
if (output?.hash.assets !== assets.hash) {
|
|
134
|
+
const { jwt } = yield* upload(accountId, name, assets, session);
|
|
135
|
+
metadata.assets = {
|
|
136
|
+
jwt,
|
|
137
|
+
config: assets.config,
|
|
138
|
+
};
|
|
139
|
+
} else {
|
|
140
|
+
metadata.assets = {
|
|
141
|
+
config: assets.config,
|
|
142
|
+
};
|
|
143
|
+
metadata.keep_assets = true;
|
|
144
|
+
}
|
|
145
|
+
metadata.bindings.push({
|
|
146
|
+
type: "assets",
|
|
147
|
+
name: "ASSETS",
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
yield* session.note("Uploading worker...");
|
|
151
|
+
const worker = yield* api.workers.scripts.update(name, {
|
|
152
|
+
account_id: accountId,
|
|
153
|
+
metadata: metadata,
|
|
154
|
+
files: [
|
|
155
|
+
new File([bundle.code], "worker.js", {
|
|
156
|
+
type: "application/javascript+module",
|
|
157
|
+
}),
|
|
158
|
+
],
|
|
159
|
+
});
|
|
160
|
+
if (!olds || news.subdomain?.enabled !== olds.subdomain?.enabled) {
|
|
161
|
+
const enable = news.subdomain?.enabled !== false;
|
|
162
|
+
yield* session.note(
|
|
163
|
+
`${enable ? "Enabling" : "Disabling"} workers.dev subdomain...`,
|
|
164
|
+
);
|
|
165
|
+
yield* setWorkerSubdomain(name, enable);
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
id: worker.id,
|
|
169
|
+
name,
|
|
170
|
+
logpush: worker.logpush,
|
|
171
|
+
observability: metadata.observability,
|
|
172
|
+
subdomain: news.subdomain ?? {
|
|
173
|
+
enabled: true,
|
|
174
|
+
previews_enabled: true,
|
|
175
|
+
},
|
|
176
|
+
url:
|
|
177
|
+
news.subdomain?.enabled !== false
|
|
178
|
+
? `https://${name}.${yield* getAccountSubdomain(accountId)}.workers.dev`
|
|
179
|
+
: undefined,
|
|
180
|
+
tags: metadata.tags,
|
|
181
|
+
accountId,
|
|
182
|
+
hash: {
|
|
183
|
+
assets: assets?.hash,
|
|
184
|
+
bundle: bundle.hash,
|
|
185
|
+
},
|
|
186
|
+
} as WorkerAttr<WorkerProps<any>>;
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
diff: Effect.fnUntraced(function* ({ id, olds, news, output }) {
|
|
191
|
+
if (output.accountId !== accountId) {
|
|
192
|
+
return { action: "replace" };
|
|
193
|
+
}
|
|
194
|
+
const workerName = createWorkerName(id, news.name);
|
|
195
|
+
if (workerName !== output.name) {
|
|
196
|
+
return { action: "replace" };
|
|
197
|
+
}
|
|
198
|
+
const [assets, bundle] = yield* Effect.all([
|
|
199
|
+
prepareAssets(news.assets),
|
|
200
|
+
prepareBundle(id, news.main),
|
|
201
|
+
]).pipe(Effect.orDie);
|
|
202
|
+
if (
|
|
203
|
+
assets?.hash !== output.hash.assets ||
|
|
204
|
+
bundle.hash !== output.hash.bundle
|
|
205
|
+
) {
|
|
206
|
+
return { action: "update" };
|
|
207
|
+
}
|
|
208
|
+
}),
|
|
209
|
+
create: Effect.fnUntraced(function* ({ id, news, bindings, session }) {
|
|
210
|
+
const name = createWorkerName(id, news.name);
|
|
211
|
+
const existing = yield* api.workers.beta.workers
|
|
212
|
+
.get(name, {
|
|
213
|
+
account_id: accountId,
|
|
214
|
+
})
|
|
215
|
+
.pipe(Effect.catchTag("NotFound", () => Effect.void));
|
|
216
|
+
if (existing) {
|
|
217
|
+
return yield* Effect.fail(
|
|
218
|
+
new Error(`Worker "${name}" already exists`),
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
return yield* putWorker(
|
|
222
|
+
id,
|
|
223
|
+
news,
|
|
224
|
+
bindings,
|
|
225
|
+
undefined,
|
|
226
|
+
undefined,
|
|
227
|
+
session,
|
|
228
|
+
);
|
|
229
|
+
}),
|
|
230
|
+
update: Effect.fnUntraced(function* ({
|
|
231
|
+
id,
|
|
232
|
+
olds,
|
|
233
|
+
news,
|
|
234
|
+
output,
|
|
235
|
+
bindings,
|
|
236
|
+
session,
|
|
237
|
+
}) {
|
|
238
|
+
return yield* putWorker(id, news, bindings, olds, output, session);
|
|
239
|
+
}),
|
|
240
|
+
delete: Effect.fnUntraced(function* ({ output }) {
|
|
241
|
+
yield* api.workers.scripts
|
|
242
|
+
.delete(output.id, {
|
|
243
|
+
account_id: output.accountId,
|
|
244
|
+
})
|
|
245
|
+
.pipe(Effect.catchTag("NotFound", () => Effect.void));
|
|
246
|
+
}),
|
|
247
|
+
};
|
|
248
|
+
}),
|
|
249
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ExecutionContext } from "@cloudflare/workers-types";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Worker from "./worker.ts";
|
|
4
|
+
|
|
5
|
+
export type { ExecutionContext };
|
|
6
|
+
export type * from "../../exports.ts";
|
|
7
|
+
|
|
8
|
+
export const serve =
|
|
9
|
+
<const ID extends string, Req>(
|
|
10
|
+
id: ID,
|
|
11
|
+
{
|
|
12
|
+
fetch,
|
|
13
|
+
}: {
|
|
14
|
+
fetch: (
|
|
15
|
+
request: Request,
|
|
16
|
+
env: unknown,
|
|
17
|
+
ctx: ExecutionContext,
|
|
18
|
+
) => Effect.Effect<Response, never, Req>;
|
|
19
|
+
},
|
|
20
|
+
) =>
|
|
21
|
+
<const Props extends Worker.WorkerProps<Req>>(props: Props) =>
|
|
22
|
+
Worker.Worker(id, { handle: fetch })(props);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Workers } from "cloudflare/resources";
|
|
2
|
+
import { Runtime, type RuntimeProps } from "../../runtime.ts";
|
|
3
|
+
import type * as Assets from "./assets.fetch.ts";
|
|
4
|
+
|
|
5
|
+
export const WorkerType = "Cloudflare.Worker" as const;
|
|
6
|
+
export type WorkerType = typeof WorkerType;
|
|
7
|
+
|
|
8
|
+
export type WorkerProps<Req = any> = RuntimeProps<
|
|
9
|
+
Worker,
|
|
10
|
+
Exclude<Req, Assets.Fetch>
|
|
11
|
+
> & {
|
|
12
|
+
name?: string;
|
|
13
|
+
logpush?: boolean;
|
|
14
|
+
observability?: Worker.Observability;
|
|
15
|
+
subdomain?: Worker.Subdomain;
|
|
16
|
+
tags?: string[];
|
|
17
|
+
main: string;
|
|
18
|
+
compatibility?: {
|
|
19
|
+
date?: string;
|
|
20
|
+
flags?: string[];
|
|
21
|
+
};
|
|
22
|
+
limits?: Worker.Limits;
|
|
23
|
+
placement?: Worker.Placement;
|
|
24
|
+
} & (Extract<Req, Assets.Fetch> extends never
|
|
25
|
+
? {
|
|
26
|
+
assets?: string | Worker.AssetsProps;
|
|
27
|
+
}
|
|
28
|
+
: {
|
|
29
|
+
assets: string | Worker.AssetsProps;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export type WorkerAttr<Props extends WorkerProps<any>> = {
|
|
33
|
+
id: string;
|
|
34
|
+
name: Props["name"] extends string ? Props["name"] : string;
|
|
35
|
+
logpush: Props["logpush"] extends boolean ? Props["logpush"] : boolean;
|
|
36
|
+
observability: Props["observability"] extends Worker.Observability
|
|
37
|
+
? Props["observability"]
|
|
38
|
+
: {
|
|
39
|
+
// whatever cloudflare's (or our, probably ours) default is
|
|
40
|
+
};
|
|
41
|
+
url: Props["subdomain"] extends { enabled: false } ? undefined : string;
|
|
42
|
+
subdomain: Props["subdomain"] extends Worker.Subdomain
|
|
43
|
+
? Props["subdomain"]
|
|
44
|
+
: { enabled: true; previews_enabled: true };
|
|
45
|
+
tags: Props["tags"] extends string[] ? Props["tags"] : string[];
|
|
46
|
+
accountId: string;
|
|
47
|
+
hash: { assets: string | undefined; bundle: string };
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export interface Worker extends Runtime<WorkerType> {
|
|
51
|
+
base: Worker;
|
|
52
|
+
props: WorkerProps<any>;
|
|
53
|
+
attr: WorkerAttr<Extract<this["props"], WorkerProps<any>>>;
|
|
54
|
+
binding: {
|
|
55
|
+
bindings: Worker.Binding[];
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const Worker = Runtime(WorkerType)<Worker>();
|
|
60
|
+
|
|
61
|
+
export declare namespace Worker {
|
|
62
|
+
export type Observability = Workers.ScriptUpdateParams.Metadata.Observability;
|
|
63
|
+
export type Subdomain = Workers.Beta.Worker.Subdomain;
|
|
64
|
+
export type Binding = NonNullable<
|
|
65
|
+
Workers.Beta.Workers.VersionCreateParams["bindings"]
|
|
66
|
+
>[number];
|
|
67
|
+
export type Limits = Workers.Beta.Workers.Version.Limits;
|
|
68
|
+
export type Placement = Workers.Beta.Workers.Version.Placement;
|
|
69
|
+
export type Assets = Workers.Beta.Workers.Version.Assets;
|
|
70
|
+
export type AssetsConfig = Workers.Beta.Workers.Version.Assets.Config;
|
|
71
|
+
export type Module = Workers.Beta.Workers.Version.Module;
|
|
72
|
+
|
|
73
|
+
export interface AssetsProps {
|
|
74
|
+
directory: string;
|
|
75
|
+
config?: AssetsConfig;
|
|
76
|
+
}
|
|
77
|
+
}
|
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,30 @@
|
|
|
1
|
+
export type Diff =
|
|
2
|
+
| {
|
|
3
|
+
action: "noop";
|
|
4
|
+
deleteFirst?: undefined;
|
|
5
|
+
stables?: undefined;
|
|
6
|
+
}
|
|
7
|
+
| {
|
|
8
|
+
action: "update";
|
|
9
|
+
deleteFirst?: undefined;
|
|
10
|
+
/** properties that won't change as part of this update */
|
|
11
|
+
stables?: string[];
|
|
12
|
+
}
|
|
13
|
+
| {
|
|
14
|
+
action: "replace";
|
|
15
|
+
deleteFirst?: boolean;
|
|
16
|
+
stables?: undefined;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const somePropsAreDifferent = <Props extends Record<string, any>>(
|
|
20
|
+
olds: Props,
|
|
21
|
+
news: Props,
|
|
22
|
+
props: (keyof Props)[],
|
|
23
|
+
) => {
|
|
24
|
+
for (const prop of props) {
|
|
25
|
+
if (olds[prop] !== news[prop]) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
};
|