alchemy 2.0.0-beta.10 → 2.0.0-beta.13
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.js +1122 -450
- package/bin/alchemy.js.map +1 -1
- package/bin/alchemy.sh +15 -0
- package/bin/alchemy.ts +22 -727
- package/bin/commands/_shared.ts +237 -0
- package/bin/commands/bootstrap.ts +117 -0
- package/bin/commands/deploy.ts +144 -0
- package/bin/commands/login.ts +93 -0
- package/bin/commands/logs.ts +157 -0
- package/bin/commands/tail.ts +138 -0
- package/lib/AWS/AuthProvider.d.ts +7 -71
- package/lib/AWS/AuthProvider.d.ts.map +1 -1
- package/lib/AWS/AuthProvider.js +27 -22
- package/lib/AWS/AuthProvider.js.map +1 -1
- package/lib/AWS/AutoScaling/LaunchTemplate.d.ts +3 -3
- package/lib/AWS/AutoScaling/LaunchTemplate.d.ts.map +1 -1
- package/lib/AWS/AutoScaling/LaunchTemplate.js +2 -2
- package/lib/AWS/AutoScaling/LaunchTemplate.js.map +1 -1
- package/lib/AWS/Bootstrap.d.ts +2 -1
- package/lib/AWS/Bootstrap.d.ts.map +1 -1
- package/lib/AWS/Bootstrap.js +27 -29
- package/lib/AWS/Bootstrap.js.map +1 -1
- package/lib/AWS/CloudWatch/Alarm.d.ts +2 -2
- package/lib/AWS/CloudWatch/Alarm.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/Alarm.js +2 -2
- package/lib/AWS/CloudWatch/Alarm.js.map +1 -1
- package/lib/AWS/CloudWatch/AlarmMuteRule.d.ts +2 -2
- package/lib/AWS/CloudWatch/AlarmMuteRule.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/AlarmMuteRule.js +2 -2
- package/lib/AWS/CloudWatch/AlarmMuteRule.js.map +1 -1
- package/lib/AWS/CloudWatch/CompositeAlarm.d.ts +2 -2
- package/lib/AWS/CloudWatch/CompositeAlarm.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/CompositeAlarm.js +2 -2
- package/lib/AWS/CloudWatch/CompositeAlarm.js.map +1 -1
- package/lib/AWS/CloudWatch/Dashboard.d.ts +2 -2
- package/lib/AWS/CloudWatch/Dashboard.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/Dashboard.js +2 -2
- package/lib/AWS/CloudWatch/Dashboard.js.map +1 -1
- package/lib/AWS/CloudWatch/InsightRule.d.ts +2 -2
- package/lib/AWS/CloudWatch/InsightRule.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/InsightRule.js +2 -2
- package/lib/AWS/CloudWatch/InsightRule.js.map +1 -1
- package/lib/AWS/CloudWatch/MetricStream.d.ts +2 -2
- package/lib/AWS/CloudWatch/MetricStream.d.ts.map +1 -1
- package/lib/AWS/CloudWatch/MetricStream.js +2 -2
- package/lib/AWS/CloudWatch/MetricStream.js.map +1 -1
- package/lib/AWS/Credentials.d.ts +5 -10
- package/lib/AWS/Credentials.d.ts.map +1 -1
- package/lib/AWS/Credentials.js +6 -30
- package/lib/AWS/Credentials.js.map +1 -1
- package/lib/AWS/DynamoDB/Table.d.ts +1 -1
- package/lib/AWS/DynamoDB/Table.d.ts.map +1 -1
- package/lib/AWS/EC2/EIP.d.ts +3 -3
- package/lib/AWS/EC2/EIP.d.ts.map +1 -1
- package/lib/AWS/EC2/EIP.js +2 -2
- package/lib/AWS/EC2/EIP.js.map +1 -1
- package/lib/AWS/EC2/EgressOnlyInternetGateway.d.ts +3 -3
- package/lib/AWS/EC2/EgressOnlyInternetGateway.d.ts.map +1 -1
- package/lib/AWS/EC2/EgressOnlyInternetGateway.js +2 -2
- package/lib/AWS/EC2/EgressOnlyInternetGateway.js.map +1 -1
- package/lib/AWS/EC2/Instance.d.ts +3 -3
- package/lib/AWS/EC2/Instance.d.ts.map +1 -1
- package/lib/AWS/EC2/Instance.js +2 -2
- package/lib/AWS/EC2/Instance.js.map +1 -1
- package/lib/AWS/EC2/InternetGateway.d.ts +3 -3
- package/lib/AWS/EC2/InternetGateway.d.ts.map +1 -1
- package/lib/AWS/EC2/InternetGateway.js +2 -2
- package/lib/AWS/EC2/InternetGateway.js.map +1 -1
- package/lib/AWS/EC2/NatGateway.d.ts +3 -3
- package/lib/AWS/EC2/NatGateway.d.ts.map +1 -1
- package/lib/AWS/EC2/NatGateway.js +2 -2
- package/lib/AWS/EC2/NatGateway.js.map +1 -1
- package/lib/AWS/EC2/Network.d.ts +1 -1
- package/lib/AWS/EC2/NetworkAcl.d.ts +3 -3
- package/lib/AWS/EC2/NetworkAcl.d.ts.map +1 -1
- package/lib/AWS/EC2/NetworkAcl.js +2 -2
- package/lib/AWS/EC2/NetworkAcl.js.map +1 -1
- package/lib/AWS/EC2/RouteTable.d.ts +3 -3
- package/lib/AWS/EC2/RouteTable.d.ts.map +1 -1
- package/lib/AWS/EC2/RouteTable.js +2 -2
- package/lib/AWS/EC2/RouteTable.js.map +1 -1
- package/lib/AWS/EC2/SecurityGroup.d.ts +3 -3
- package/lib/AWS/EC2/SecurityGroup.d.ts.map +1 -1
- package/lib/AWS/EC2/SecurityGroup.js +2 -2
- package/lib/AWS/EC2/SecurityGroup.js.map +1 -1
- package/lib/AWS/EC2/Subnet.d.ts +1 -1
- package/lib/AWS/EC2/Subnet.d.ts.map +1 -1
- package/lib/AWS/EC2/Vpc.d.ts +3 -3
- package/lib/AWS/EC2/Vpc.d.ts.map +1 -1
- package/lib/AWS/EC2/Vpc.js +2 -2
- package/lib/AWS/EC2/Vpc.js.map +1 -1
- package/lib/AWS/EC2/VpcEndpoint.d.ts +3 -3
- package/lib/AWS/EC2/VpcEndpoint.d.ts.map +1 -1
- package/lib/AWS/EC2/VpcEndpoint.js +2 -2
- package/lib/AWS/EC2/VpcEndpoint.js.map +1 -1
- package/lib/AWS/ECR/Repository.d.ts +1 -1
- package/lib/AWS/ECR/Repository.d.ts.map +1 -1
- package/lib/AWS/ECR/Repository.js +0 -1
- package/lib/AWS/ECR/Repository.js.map +1 -1
- package/lib/AWS/ECS/Cluster.d.ts +2 -2
- package/lib/AWS/ECS/Cluster.d.ts.map +1 -1
- package/lib/AWS/ECS/Cluster.js +2 -2
- package/lib/AWS/ECS/Cluster.js.map +1 -1
- package/lib/AWS/ECS/Service.d.ts +1 -1
- package/lib/AWS/ECS/Service.d.ts.map +1 -1
- package/lib/AWS/ECS/Task.d.ts +2 -2
- package/lib/AWS/ECS/Task.d.ts.map +1 -1
- package/lib/AWS/ECS/Task.js +2 -2
- package/lib/AWS/ECS/Task.js.map +1 -1
- package/lib/AWS/EKS/Cluster.d.ts +1 -1
- package/lib/AWS/EKS/Cluster.d.ts.map +1 -1
- package/lib/AWS/ELBv2/Listener.d.ts +1 -1
- package/lib/AWS/ELBv2/Listener.d.ts.map +1 -1
- package/lib/AWS/ELBv2/LoadBalancer.d.ts +1 -1
- package/lib/AWS/ELBv2/LoadBalancer.d.ts.map +1 -1
- package/lib/AWS/ELBv2/TargetGroup.d.ts +1 -1
- package/lib/AWS/ELBv2/TargetGroup.d.ts.map +1 -1
- package/lib/AWS/Endpoint.d.ts +7 -2
- package/lib/AWS/Endpoint.d.ts.map +1 -1
- package/lib/AWS/Endpoint.js +7 -2
- package/lib/AWS/Endpoint.js.map +1 -1
- package/lib/AWS/Environment.d.ts +68 -0
- package/lib/AWS/Environment.d.ts.map +1 -0
- package/lib/AWS/Environment.js +53 -0
- package/lib/AWS/Environment.js.map +1 -0
- package/lib/AWS/EventBridge/EventBus.d.ts +2 -2
- package/lib/AWS/EventBridge/EventBus.d.ts.map +1 -1
- package/lib/AWS/EventBridge/EventBus.js +2 -2
- package/lib/AWS/EventBridge/EventBus.js.map +1 -1
- package/lib/AWS/EventBridge/ListRules.d.ts +2 -2
- package/lib/AWS/EventBridge/ListRules.d.ts.map +1 -1
- package/lib/AWS/EventBridge/ListRules.js +2 -2
- package/lib/AWS/EventBridge/ListRules.js.map +1 -1
- package/lib/AWS/EventBridge/PutEvents.d.ts +2 -2
- package/lib/AWS/EventBridge/PutEvents.d.ts.map +1 -1
- package/lib/AWS/EventBridge/PutEvents.js +2 -2
- package/lib/AWS/EventBridge/PutEvents.js.map +1 -1
- package/lib/AWS/EventBridge/Rule.d.ts +2 -2
- package/lib/AWS/EventBridge/Rule.d.ts.map +1 -1
- package/lib/AWS/EventBridge/Rule.js +2 -2
- package/lib/AWS/EventBridge/Rule.js.map +1 -1
- package/lib/AWS/IAM/OpenIDConnectProvider.d.ts +2 -2
- package/lib/AWS/IAM/OpenIDConnectProvider.d.ts.map +1 -1
- package/lib/AWS/IAM/OpenIDConnectProvider.js +2 -2
- package/lib/AWS/IAM/OpenIDConnectProvider.js.map +1 -1
- package/lib/AWS/IAM/Policy.d.ts +3 -3
- package/lib/AWS/IAM/Policy.d.ts.map +1 -1
- package/lib/AWS/IAM/Policy.js +2 -2
- package/lib/AWS/IAM/Policy.js.map +1 -1
- package/lib/AWS/IAM/Role.d.ts +3 -3
- package/lib/AWS/IAM/Role.d.ts.map +1 -1
- package/lib/AWS/IAM/Role.js +3 -3
- package/lib/AWS/IAM/Role.js.map +1 -1
- package/lib/AWS/Kinesis/Stream.d.ts +2 -2
- package/lib/AWS/Kinesis/Stream.d.ts.map +1 -1
- package/lib/AWS/Kinesis/Stream.js +2 -2
- package/lib/AWS/Kinesis/Stream.js.map +1 -1
- package/lib/AWS/Lambda/BucketEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/BucketEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/EventBridgeEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/EventSourceMapping.d.ts +2 -2
- package/lib/AWS/Lambda/EventSourceMapping.d.ts.map +1 -1
- package/lib/AWS/Lambda/EventSourceMapping.js +2 -2
- package/lib/AWS/Lambda/EventSourceMapping.js.map +1 -1
- package/lib/AWS/Lambda/Function.d.ts +2 -2
- package/lib/AWS/Lambda/Function.d.ts.map +1 -1
- package/lib/AWS/Lambda/Function.js +2 -2
- package/lib/AWS/Lambda/Function.js.map +1 -1
- package/lib/AWS/Lambda/Permission.d.ts +1 -1
- package/lib/AWS/Lambda/Permission.js +1 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/QueueEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/StreamEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/TableEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts +1 -1
- package/lib/AWS/Lambda/TopicEventSource.d.ts.map +1 -1
- package/lib/AWS/Logs/LogGroup.d.ts +3 -3
- package/lib/AWS/Logs/LogGroup.d.ts.map +1 -1
- package/lib/AWS/Logs/LogGroup.js +2 -2
- package/lib/AWS/Logs/LogGroup.js.map +1 -1
- package/lib/AWS/Providers.d.ts +1 -2
- package/lib/AWS/Providers.d.ts.map +1 -1
- package/lib/AWS/Providers.js +3 -3
- package/lib/AWS/Providers.js.map +1 -1
- package/lib/AWS/Region.d.ts +6 -22
- package/lib/AWS/Region.d.ts.map +1 -1
- package/lib/AWS/Region.js +6 -39
- package/lib/AWS/Region.js.map +1 -1
- package/lib/AWS/S3/Bucket.d.ts +2 -2
- package/lib/AWS/S3/Bucket.d.ts.map +1 -1
- package/lib/AWS/S3/Bucket.js +2 -2
- package/lib/AWS/S3/Bucket.js.map +1 -1
- package/lib/AWS/SNS/Topic.d.ts +1 -1
- package/lib/AWS/SNS/Topic.d.ts.map +1 -1
- package/lib/AWS/SQS/Queue.d.ts +3 -3
- package/lib/AWS/SQS/Queue.d.ts.map +1 -1
- package/lib/AWS/SQS/Queue.js +2 -2
- package/lib/AWS/SQS/Queue.js.map +1 -1
- package/lib/AWS/index.d.ts +1 -3
- package/lib/AWS/index.d.ts.map +1 -1
- package/lib/AWS/index.js +1 -3
- package/lib/AWS/index.js.map +1 -1
- package/lib/Apply.d.ts.map +1 -1
- package/lib/Apply.js +2 -2
- package/lib/Apply.js.map +1 -1
- package/lib/Auth/AuthProvider.d.ts +51 -7
- package/lib/Auth/AuthProvider.d.ts.map +1 -1
- package/lib/Auth/AuthProvider.js +37 -0
- package/lib/Auth/AuthProvider.js.map +1 -1
- package/lib/Auth/Profile.d.ts +71 -10
- package/lib/Auth/Profile.d.ts.map +1 -1
- package/lib/Auth/Profile.js +47 -30
- package/lib/Auth/Profile.js.map +1 -1
- package/lib/Auth/index.d.ts +1 -1
- package/lib/Auth/index.d.ts.map +1 -1
- package/lib/Cloudflare/Auth/AuthProvider.d.ts +14 -31
- package/lib/Cloudflare/Auth/AuthProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Auth/AuthProvider.js +59 -38
- package/lib/Cloudflare/Auth/AuthProvider.js.map +1 -1
- package/lib/Cloudflare/CloudflareEnvironment.d.ts +11 -0
- package/lib/Cloudflare/CloudflareEnvironment.d.ts.map +1 -0
- package/lib/Cloudflare/CloudflareEnvironment.js +26 -0
- package/lib/Cloudflare/CloudflareEnvironment.js.map +1 -0
- package/lib/Cloudflare/Container/ContainerApplication.d.ts +70 -42
- package/lib/Cloudflare/Container/ContainerApplication.d.ts.map +1 -1
- package/lib/Cloudflare/Container/ContainerApplication.js +49 -24
- package/lib/Cloudflare/Container/ContainerApplication.js.map +1 -1
- package/lib/Cloudflare/Credentials.d.ts +11 -0
- package/lib/Cloudflare/Credentials.d.ts.map +1 -0
- package/lib/Cloudflare/Credentials.js +34 -0
- package/lib/Cloudflare/Credentials.js.map +1 -0
- package/lib/Cloudflare/D1/D1Database.d.ts +2 -2
- package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
- package/lib/Cloudflare/D1/D1Database.js +2 -2
- package/lib/Cloudflare/D1/D1Database.js.map +1 -1
- package/lib/Cloudflare/KV/KVNamespace.d.ts +2 -2
- package/lib/Cloudflare/KV/KVNamespace.d.ts.map +1 -1
- package/lib/Cloudflare/KV/KVNamespace.js +2 -2
- package/lib/Cloudflare/KV/KVNamespace.js.map +1 -1
- package/lib/Cloudflare/Providers.d.ts +2 -3
- package/lib/Cloudflare/Providers.d.ts.map +1 -1
- package/lib/Cloudflare/Providers.js +12 -4
- package/lib/Cloudflare/Providers.js.map +1 -1
- package/lib/Cloudflare/Queue/Queue.d.ts +52 -0
- package/lib/Cloudflare/Queue/Queue.d.ts.map +1 -0
- package/lib/Cloudflare/Queue/Queue.js +136 -0
- package/lib/Cloudflare/Queue/Queue.js.map +1 -0
- package/lib/Cloudflare/Queue/QueueBinding.d.ts +35 -0
- package/lib/Cloudflare/Queue/QueueBinding.d.ts.map +1 -0
- package/lib/Cloudflare/Queue/QueueBinding.js +51 -0
- package/lib/Cloudflare/Queue/QueueBinding.js.map +1 -0
- package/lib/Cloudflare/Queue/QueueConsumer.d.ts +86 -0
- package/lib/Cloudflare/Queue/QueueConsumer.d.ts.map +1 -0
- package/lib/Cloudflare/Queue/QueueConsumer.js +138 -0
- package/lib/Cloudflare/Queue/QueueConsumer.js.map +1 -0
- package/lib/Cloudflare/Queue/index.d.ts +4 -0
- package/lib/Cloudflare/Queue/index.d.ts.map +1 -0
- package/lib/Cloudflare/Queue/index.js +4 -0
- package/lib/Cloudflare/Queue/index.js.map +1 -0
- package/lib/Cloudflare/R2/R2Bucket.d.ts +2 -2
- package/lib/Cloudflare/R2/R2Bucket.d.ts.map +1 -1
- package/lib/Cloudflare/R2/R2Bucket.js +2 -2
- package/lib/Cloudflare/R2/R2Bucket.js.map +1 -1
- package/lib/Cloudflare/SecretsStore/Secret.d.ts +74 -0
- package/lib/Cloudflare/SecretsStore/Secret.d.ts.map +1 -0
- package/lib/Cloudflare/SecretsStore/Secret.js +161 -0
- package/lib/Cloudflare/SecretsStore/Secret.js.map +1 -0
- package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts +42 -0
- package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts.map +1 -0
- package/lib/Cloudflare/SecretsStore/SecretBinding.js +49 -0
- package/lib/Cloudflare/SecretsStore/SecretBinding.js.map +1 -0
- package/lib/Cloudflare/SecretsStore/SecretsStore.d.ts +37 -0
- package/lib/Cloudflare/SecretsStore/SecretsStore.d.ts.map +1 -0
- package/lib/Cloudflare/SecretsStore/SecretsStore.js +88 -0
- package/lib/Cloudflare/SecretsStore/SecretsStore.js.map +1 -0
- package/lib/Cloudflare/SecretsStore/index.d.ts +4 -0
- package/lib/Cloudflare/SecretsStore/index.d.ts.map +1 -0
- package/lib/Cloudflare/SecretsStore/index.js +4 -0
- package/lib/Cloudflare/SecretsStore/index.js.map +1 -0
- package/lib/Cloudflare/Workers/InferEnv.d.ts +1 -1
- package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +5 -3
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +61 -7
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Cloudflare/Workers/Workflow.d.ts +10 -4
- package/lib/Cloudflare/Workers/Workflow.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Workflow.js +3 -3
- package/lib/Cloudflare/Workers/Workflow.js.map +1 -1
- package/lib/Cloudflare/index.d.ts +3 -1
- package/lib/Cloudflare/index.d.ts.map +1 -1
- package/lib/Cloudflare/index.js +3 -1
- package/lib/Cloudflare/index.js.map +1 -1
- package/lib/Stack.d.ts +3 -2
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js +10 -7
- package/lib/Stack.js.map +1 -1
- package/lib/State/LocalState.d.ts.map +1 -1
- package/lib/State/LocalState.js +40 -12
- package/lib/State/LocalState.js.map +1 -1
- package/lib/Test/Bun.d.ts.map +1 -1
- package/lib/Test/Bun.js +3 -2
- package/lib/Test/Bun.js.map +1 -1
- package/lib/Test/Vitest.d.ts +3 -1
- package/lib/Test/Vitest.d.ts.map +1 -1
- package/lib/Test/Vitest.js +19 -16
- package/lib/Test/Vitest.js.map +1 -1
- package/lib/Util/PlatformServices.d.ts +14 -3
- package/lib/Util/PlatformServices.d.ts.map +1 -1
- package/lib/Util/PlatformServices.js +21 -3
- package/lib/Util/PlatformServices.js.map +1 -1
- package/package.json +5 -5
- package/src/AWS/AuthProvider.ts +67 -67
- package/src/AWS/AutoScaling/LaunchTemplate.ts +3 -3
- package/src/AWS/Bootstrap.ts +32 -37
- package/src/AWS/CloudWatch/Alarm.ts +2 -2
- package/src/AWS/CloudWatch/AlarmMuteRule.ts +2 -2
- package/src/AWS/CloudWatch/CompositeAlarm.ts +2 -2
- package/src/AWS/CloudWatch/Dashboard.ts +2 -2
- package/src/AWS/CloudWatch/InsightRule.ts +2 -2
- package/src/AWS/CloudWatch/MetricStream.ts +2 -2
- package/src/AWS/Credentials.ts +9 -44
- package/src/AWS/DynamoDB/Table.ts +1 -1
- package/src/AWS/EC2/EIP.ts +3 -3
- package/src/AWS/EC2/EgressOnlyInternetGateway.ts +3 -3
- package/src/AWS/EC2/Instance.ts +3 -3
- package/src/AWS/EC2/InternetGateway.ts +3 -3
- package/src/AWS/EC2/NatGateway.ts +3 -3
- package/src/AWS/EC2/NetworkAcl.ts +3 -3
- package/src/AWS/EC2/RouteTable.ts +3 -3
- package/src/AWS/EC2/SecurityGroup.ts +3 -3
- package/src/AWS/EC2/Subnet.ts +1 -1
- package/src/AWS/EC2/Vpc.ts +3 -3
- package/src/AWS/EC2/VpcEndpoint.ts +3 -3
- package/src/AWS/ECR/Repository.ts +1 -1
- package/src/AWS/ECS/Cluster.ts +2 -2
- package/src/AWS/ECS/Service.ts +1 -1
- package/src/AWS/ECS/Task.ts +2 -2
- package/src/AWS/EKS/Cluster.ts +1 -1
- package/src/AWS/ELBv2/Listener.ts +1 -1
- package/src/AWS/ELBv2/LoadBalancer.ts +1 -1
- package/src/AWS/ELBv2/TargetGroup.ts +1 -1
- package/src/AWS/Endpoint.ts +12 -8
- package/src/AWS/Environment.ts +123 -0
- package/src/AWS/EventBridge/EventBus.ts +2 -2
- package/src/AWS/EventBridge/ListRules.ts +2 -2
- package/src/AWS/EventBridge/PutEvents.ts +2 -2
- package/src/AWS/EventBridge/Rule.ts +2 -2
- package/src/AWS/IAM/OpenIDConnectProvider.ts +2 -2
- package/src/AWS/IAM/Policy.ts +3 -3
- package/src/AWS/IAM/Role.ts +4 -4
- package/src/AWS/Kinesis/Stream.ts +2 -2
- package/src/AWS/Lambda/EventSourceMapping.ts +2 -2
- package/src/AWS/Lambda/Function.ts +2 -2
- package/src/AWS/Lambda/Permission.ts +1 -1
- package/src/AWS/Logs/LogGroup.ts +3 -3
- package/src/AWS/Providers.ts +7 -7
- package/src/AWS/Region.ts +9 -66
- package/src/AWS/S3/Bucket.ts +2 -2
- package/src/AWS/SNS/Topic.ts +1 -1
- package/src/AWS/SQS/Queue.ts +3 -3
- package/src/AWS/index.ts +1 -3
- package/src/Apply.ts +55 -57
- package/src/Auth/AuthProvider.ts +188 -8
- package/src/Auth/Profile.ts +117 -54
- package/src/Auth/index.ts +1 -1
- package/src/Cloudflare/Auth/AuthProvider.ts +127 -98
- package/src/Cloudflare/CloudflareEnvironment.ts +49 -0
- package/src/Cloudflare/Container/ContainerApplication.ts +172 -94
- package/src/Cloudflare/Credentials.ts +75 -0
- package/src/Cloudflare/D1/D1Database.ts +2 -2
- package/src/Cloudflare/KV/KVNamespace.ts +2 -2
- package/src/Cloudflare/Providers.ts +20 -10
- package/src/Cloudflare/Queue/Queue.ts +174 -0
- package/src/Cloudflare/Queue/QueueBinding.ts +110 -0
- package/src/Cloudflare/Queue/QueueConsumer.ts +219 -0
- package/src/Cloudflare/Queue/index.ts +3 -0
- package/src/Cloudflare/R2/R2Bucket.ts +2 -2
- package/src/Cloudflare/SecretsStore/Secret.ts +229 -0
- package/src/Cloudflare/SecretsStore/SecretBinding.ts +107 -0
- package/src/Cloudflare/SecretsStore/SecretsStore.ts +106 -0
- package/src/Cloudflare/SecretsStore/index.ts +3 -0
- package/src/Cloudflare/Workers/InferEnv.ts +5 -3
- package/src/Cloudflare/Workers/Worker.ts +63 -7
- package/src/Cloudflare/Workers/Workflow.ts +19 -9
- package/src/Cloudflare/index.ts +3 -1
- package/src/Stack.ts +40 -29
- package/src/State/LocalState.ts +43 -16
- package/src/Test/Bun.ts +3 -0
- package/src/Test/Vitest.ts +31 -23
- package/src/Util/PlatformServices.ts +54 -13
- package/bin/process-manager.ts +0 -10
- package/lib/AWS/Account.d.ts +0 -26
- package/lib/AWS/Account.d.ts.map +0 -1
- package/lib/AWS/Account.js +0 -32
- package/lib/AWS/Account.js.map +0 -1
- package/lib/AWS/Profile.d.ts +0 -6
- package/lib/AWS/Profile.d.ts.map +0 -1
- package/lib/AWS/Profile.js +0 -4
- package/lib/AWS/Profile.js.map +0 -1
- package/lib/AWS/StageConfig.d.ts +0 -25
- package/lib/AWS/StageConfig.d.ts.map +0 -1
- package/lib/AWS/StageConfig.js +0 -23
- package/lib/AWS/StageConfig.js.map +0 -1
- package/lib/Cloudflare/Account.d.ts +0 -10
- package/lib/Cloudflare/Account.d.ts.map +0 -1
- package/lib/Cloudflare/Account.js +0 -24
- package/lib/Cloudflare/Account.js.map +0 -1
- package/lib/Cloudflare/StageConfig.d.ts +0 -8
- package/lib/Cloudflare/StageConfig.d.ts.map +0 -1
- package/lib/Cloudflare/StageConfig.js +0 -4
- package/lib/Cloudflare/StageConfig.js.map +0 -1
- package/src/AWS/Account.ts +0 -56
- package/src/AWS/Profile.ts +0 -5
- package/src/AWS/StageConfig.ts +0 -44
- package/src/Cloudflare/Account.ts +0 -38
- package/src/Cloudflare/StageConfig.ts +0 -8
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import * as Auth from "@distilled.cloud/cloudflare/Auth";
|
|
2
1
|
import * as Layer from "effect/Layer";
|
|
3
|
-
import * as Socket from "effect/unstable/socket/Socket";
|
|
4
2
|
import { Command } from "../Build/Command.ts";
|
|
5
3
|
import * as Build from "../Build/index.ts";
|
|
6
4
|
import * as Provider from "../Provider.ts";
|
|
7
5
|
import { Random, RandomProvider } from "../Random.ts";
|
|
8
|
-
import
|
|
6
|
+
import { CloudflareAuth } from "./Auth/AuthProvider.ts";
|
|
7
|
+
import * as CloudflareEnvironment from "./CloudflareEnvironment.ts";
|
|
9
8
|
import * as Containers from "./Container/index.ts";
|
|
9
|
+
import * as Credentials from "./Credentials.ts";
|
|
10
10
|
import * as D1 from "./D1/index.ts";
|
|
11
11
|
import * as KV from "./KV/index.ts";
|
|
12
|
+
import * as Queue from "./Queue/index.ts";
|
|
12
13
|
import * as R2 from "./R2/index.ts";
|
|
14
|
+
import * as SecretsStore from "./SecretsStore/index.ts";
|
|
13
15
|
import * as Workers from "./Workers/index.ts";
|
|
14
16
|
import * as Workflows from "./Workers/Workflow.ts";
|
|
15
17
|
|
|
@@ -34,8 +36,14 @@ export const providers = () =>
|
|
|
34
36
|
D1.D1Database,
|
|
35
37
|
KV.KVNamespace,
|
|
36
38
|
KV.KVNamespaceBindingPolicy,
|
|
39
|
+
Queue.Queue,
|
|
40
|
+
Queue.QueueBindingPolicy,
|
|
41
|
+
Queue.QueueConsumer,
|
|
37
42
|
R2.R2Bucket,
|
|
38
43
|
R2.R2BucketBindingPolicy,
|
|
44
|
+
SecretsStore.SecretBindingPolicy,
|
|
45
|
+
SecretsStore.SecretsStore,
|
|
46
|
+
SecretsStore.Secret,
|
|
39
47
|
Random,
|
|
40
48
|
Workers.BindWorkerPolicy,
|
|
41
49
|
Workers.FetchPolicy,
|
|
@@ -50,8 +58,14 @@ export const providers = () =>
|
|
|
50
58
|
D1.DatabaseProvider(),
|
|
51
59
|
KV.KVNamespaceBindingPolicyLive,
|
|
52
60
|
KV.KVNamespaceProvider(),
|
|
61
|
+
Queue.QueueBindingPolicyLive,
|
|
62
|
+
Queue.QueueProvider(),
|
|
63
|
+
Queue.QueueConsumerProvider(),
|
|
53
64
|
R2.R2BucketBindingPolicyLive,
|
|
54
65
|
R2.R2BucketProvider(),
|
|
66
|
+
SecretsStore.SecretBindingPolicyLive,
|
|
67
|
+
SecretsStore.SecretsStoreProvider(),
|
|
68
|
+
SecretsStore.StoreSecretProvider(),
|
|
55
69
|
Workers.BindWorkerPolicyLive,
|
|
56
70
|
Workers.FetchPolicyLive,
|
|
57
71
|
Workers.WorkerProvider(),
|
|
@@ -61,12 +75,8 @@ export const providers = () =>
|
|
|
61
75
|
Layer.provideMerge(
|
|
62
76
|
Layer.mergeAll(Build.CommandProvider(), RandomProvider()),
|
|
63
77
|
),
|
|
64
|
-
Layer.provideMerge(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
Auth.fromEnv(),
|
|
68
|
-
Socket.layerWebSocketConstructorGlobal,
|
|
69
|
-
),
|
|
70
|
-
),
|
|
78
|
+
Layer.provideMerge(Credentials.fromAuthProvider()),
|
|
79
|
+
Layer.provideMerge(CloudflareEnvironment.fromProfile()),
|
|
80
|
+
Layer.provideMerge(CloudflareAuth),
|
|
71
81
|
Layer.orDie,
|
|
72
82
|
);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import * as queues from "@distilled.cloud/cloudflare/queues";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { isResolved } from "../../Diff.ts";
|
|
4
|
+
import { createPhysicalName } from "../../PhysicalName.ts";
|
|
5
|
+
import * as Provider from "../../Provider.ts";
|
|
6
|
+
import { Resource } from "../../Resource.ts";
|
|
7
|
+
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
8
|
+
import type { Providers } from "../Providers.ts";
|
|
9
|
+
import { QueueBinding } from "./QueueBinding.ts";
|
|
10
|
+
|
|
11
|
+
export type QueueProps = {
|
|
12
|
+
/**
|
|
13
|
+
* Name of the queue. If omitted, a unique name will be generated.
|
|
14
|
+
* @default ${app}-${stage}-${id}
|
|
15
|
+
*/
|
|
16
|
+
name?: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type Queue = Resource<
|
|
20
|
+
"Cloudflare.Queue",
|
|
21
|
+
QueueProps,
|
|
22
|
+
{
|
|
23
|
+
queueId: string;
|
|
24
|
+
queueName: string;
|
|
25
|
+
accountId: string;
|
|
26
|
+
},
|
|
27
|
+
never,
|
|
28
|
+
Providers
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A Cloudflare Queue for reliable message passing between Workers.
|
|
33
|
+
*
|
|
34
|
+
* Queues enable you to send and receive messages with guaranteed delivery.
|
|
35
|
+
* Create a queue as a resource, then bind it to a Worker to send messages
|
|
36
|
+
* at runtime. Register a consumer to process messages.
|
|
37
|
+
*
|
|
38
|
+
* @section Creating a Queue
|
|
39
|
+
* @example Basic queue
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const queue = yield* Cloudflare.Queue("MyQueue");
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Queue with explicit name
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const queue = yield* Cloudflare.Queue("MyQueue", {
|
|
47
|
+
* name: "my-app-queue",
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @section Binding to a Worker
|
|
52
|
+
* @example Sending messages from a Worker
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // In your Worker definition, add the queue to bindings:
|
|
55
|
+
* const Worker = Cloudflare.Worker("Worker", {
|
|
56
|
+
* bindings: { MY_QUEUE: queue },
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export const Queue = Resource<Queue>("Cloudflare.Queue")({
|
|
61
|
+
bind: QueueBinding.bind,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const QueueProvider = () =>
|
|
65
|
+
Provider.effect(
|
|
66
|
+
Queue,
|
|
67
|
+
Effect.gen(function* () {
|
|
68
|
+
const { accountId } = yield* CloudflareEnvironment;
|
|
69
|
+
const createQueue = yield* queues.createQueue;
|
|
70
|
+
const getQueue = yield* queues.getQueue;
|
|
71
|
+
const updateQueue = yield* queues.updateQueue;
|
|
72
|
+
const deleteQueue = yield* queues.deleteQueue;
|
|
73
|
+
const listQueues = yield* queues.listQueues;
|
|
74
|
+
|
|
75
|
+
const createQueueName = (id: string, name: string | undefined) =>
|
|
76
|
+
Effect.gen(function* () {
|
|
77
|
+
if (name) return name;
|
|
78
|
+
return (yield* createPhysicalName({
|
|
79
|
+
id,
|
|
80
|
+
maxLength: 63,
|
|
81
|
+
})).toLowerCase();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
stables: ["queueId", "accountId"],
|
|
86
|
+
diff: Effect.fn(function* ({ id, olds = {}, news = {}, output }) {
|
|
87
|
+
if (!isResolved(news)) return undefined;
|
|
88
|
+
if ((output?.accountId ?? accountId) !== accountId) {
|
|
89
|
+
return { action: "replace" } as const;
|
|
90
|
+
}
|
|
91
|
+
const name = yield* createQueueName(id, news.name);
|
|
92
|
+
const oldName = output?.queueName
|
|
93
|
+
? output.queueName
|
|
94
|
+
: yield* createQueueName(id, olds.name);
|
|
95
|
+
if (name !== oldName) {
|
|
96
|
+
return { action: "replace" } as const;
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
create: Effect.fn(function* ({ id, news = {} }) {
|
|
100
|
+
const queueName = yield* createQueueName(id, news.name);
|
|
101
|
+
const queue = yield* createQueue({
|
|
102
|
+
accountId,
|
|
103
|
+
queueName,
|
|
104
|
+
}).pipe(
|
|
105
|
+
Effect.catch(() =>
|
|
106
|
+
Effect.gen(function* () {
|
|
107
|
+
// Queue may already exist -- look it up by name
|
|
108
|
+
const allQueues = yield* listQueues({ accountId });
|
|
109
|
+
const match = allQueues.result.find(
|
|
110
|
+
(q) => q.queueName === queueName,
|
|
111
|
+
);
|
|
112
|
+
if (match && match.queueId && match.queueName) {
|
|
113
|
+
return match as { queueId: string; queueName: string };
|
|
114
|
+
}
|
|
115
|
+
return yield* Effect.die(
|
|
116
|
+
`Queue "${queueName}" already exists but could not be found`,
|
|
117
|
+
);
|
|
118
|
+
}),
|
|
119
|
+
),
|
|
120
|
+
);
|
|
121
|
+
return {
|
|
122
|
+
queueId: queue.queueId!,
|
|
123
|
+
queueName: queue.queueName!,
|
|
124
|
+
accountId,
|
|
125
|
+
};
|
|
126
|
+
}),
|
|
127
|
+
update: Effect.fn(function* ({ id, news = {}, output }) {
|
|
128
|
+
const queueName = yield* createQueueName(id, news.name);
|
|
129
|
+
const queue = yield* updateQueue({
|
|
130
|
+
accountId: output.accountId,
|
|
131
|
+
queueId: output.queueId,
|
|
132
|
+
queueName,
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
queueId: queue.queueId!,
|
|
136
|
+
queueName: queue.queueName!,
|
|
137
|
+
accountId: output.accountId,
|
|
138
|
+
};
|
|
139
|
+
}),
|
|
140
|
+
delete: Effect.fn(function* ({ output }) {
|
|
141
|
+
yield* deleteQueue({
|
|
142
|
+
accountId: output.accountId,
|
|
143
|
+
queueId: output.queueId,
|
|
144
|
+
}).pipe(Effect.catch(() => Effect.void));
|
|
145
|
+
}),
|
|
146
|
+
read: Effect.fn(function* ({ id, output, olds }) {
|
|
147
|
+
if (output?.queueId) {
|
|
148
|
+
return yield* getQueue({
|
|
149
|
+
accountId: output.accountId,
|
|
150
|
+
queueId: output.queueId,
|
|
151
|
+
}).pipe(
|
|
152
|
+
Effect.map((queue) => ({
|
|
153
|
+
queueId: queue.queueId!,
|
|
154
|
+
queueName: queue.queueName!,
|
|
155
|
+
accountId: output.accountId,
|
|
156
|
+
})),
|
|
157
|
+
Effect.catch(() => Effect.succeed(undefined)),
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
const queueName = yield* createQueueName(id, olds?.name);
|
|
161
|
+
const allQueues = yield* listQueues({ accountId });
|
|
162
|
+
const match = allQueues.result.find((q) => q.queueName === queueName);
|
|
163
|
+
if (match && match.queueId && match.queueName) {
|
|
164
|
+
return {
|
|
165
|
+
queueId: match.queueId,
|
|
166
|
+
queueName: match.queueName,
|
|
167
|
+
accountId,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return undefined;
|
|
171
|
+
}),
|
|
172
|
+
};
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as Binding from "../../Binding.ts";
|
|
4
|
+
import type { ResourceLike } from "../../Resource.ts";
|
|
5
|
+
import { isWorker, WorkerEnvironment } from "../Workers/Worker.ts";
|
|
6
|
+
import type { Queue } from "./Queue.ts";
|
|
7
|
+
|
|
8
|
+
export interface QueueSender {
|
|
9
|
+
raw: Effect.Effect<any, never, WorkerEnvironment>;
|
|
10
|
+
send(
|
|
11
|
+
body: unknown,
|
|
12
|
+
options?: { contentType?: "json" | "text" },
|
|
13
|
+
): Effect.Effect<void, QueueSendError, WorkerEnvironment>;
|
|
14
|
+
sendBatch(
|
|
15
|
+
messages: ReadonlyArray<{
|
|
16
|
+
body: unknown;
|
|
17
|
+
contentType?: "json" | "text";
|
|
18
|
+
}>,
|
|
19
|
+
): Effect.Effect<void, QueueSendError, WorkerEnvironment>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
import * as Data from "effect/Data";
|
|
23
|
+
|
|
24
|
+
export class QueueSendError extends Data.TaggedError("QueueSendError")<{
|
|
25
|
+
message: string;
|
|
26
|
+
cause?: unknown;
|
|
27
|
+
}> {}
|
|
28
|
+
|
|
29
|
+
export class QueueBinding extends Binding.Service<
|
|
30
|
+
QueueBinding,
|
|
31
|
+
(queue: Queue) => Effect.Effect<QueueSender>
|
|
32
|
+
>()("Cloudflare.Queue") {}
|
|
33
|
+
|
|
34
|
+
export const QueueBindingLive = Layer.effect(
|
|
35
|
+
QueueBinding,
|
|
36
|
+
Effect.gen(function* () {
|
|
37
|
+
const bind = yield* QueueBindingPolicy;
|
|
38
|
+
|
|
39
|
+
return Effect.fn(function* (queue: Queue) {
|
|
40
|
+
yield* bind(queue);
|
|
41
|
+
const env = WorkerEnvironment.asEffect();
|
|
42
|
+
const raw = env.pipe(
|
|
43
|
+
Effect.map((env) => (env as Record<string, any>)[queue.LogicalId]),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const tryPromise = <T>(
|
|
47
|
+
fn: () => Promise<T>,
|
|
48
|
+
): Effect.Effect<T, QueueSendError> =>
|
|
49
|
+
Effect.tryPromise({
|
|
50
|
+
try: fn,
|
|
51
|
+
catch: (error: any) =>
|
|
52
|
+
new QueueSendError({
|
|
53
|
+
message: error?.message ?? "Unknown queue error",
|
|
54
|
+
cause: error,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
raw,
|
|
60
|
+
send: (body: unknown, options?: { contentType?: "json" | "text" }) =>
|
|
61
|
+
raw.pipe(
|
|
62
|
+
Effect.flatMap((q) => tryPromise(() => q.send(body, options))),
|
|
63
|
+
),
|
|
64
|
+
sendBatch: (
|
|
65
|
+
messages: ReadonlyArray<{
|
|
66
|
+
body: unknown;
|
|
67
|
+
contentType?: "json" | "text";
|
|
68
|
+
}>,
|
|
69
|
+
) =>
|
|
70
|
+
raw.pipe(
|
|
71
|
+
Effect.flatMap((q) =>
|
|
72
|
+
tryPromise(() =>
|
|
73
|
+
q.sendBatch(
|
|
74
|
+
messages.map((m) => ({
|
|
75
|
+
body: m.body,
|
|
76
|
+
...(m.contentType ? { contentType: m.contentType } : {}),
|
|
77
|
+
})),
|
|
78
|
+
),
|
|
79
|
+
),
|
|
80
|
+
),
|
|
81
|
+
),
|
|
82
|
+
} satisfies QueueSender;
|
|
83
|
+
});
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
export class QueueBindingPolicy extends Binding.Policy<
|
|
88
|
+
QueueBindingPolicy,
|
|
89
|
+
(queue: Queue) => Effect.Effect<void>
|
|
90
|
+
>()("Cloudflare.Queue") {}
|
|
91
|
+
|
|
92
|
+
export const QueueBindingPolicyLive = QueueBindingPolicy.layer.succeed(
|
|
93
|
+
Effect.fnUntraced(function* (host: ResourceLike, queue: Queue) {
|
|
94
|
+
if (isWorker(host)) {
|
|
95
|
+
yield* host.bind`${queue}`({
|
|
96
|
+
bindings: [
|
|
97
|
+
{
|
|
98
|
+
type: "queue",
|
|
99
|
+
name: queue.LogicalId,
|
|
100
|
+
queueName: queue.queueName,
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
return yield* Effect.die(
|
|
106
|
+
new Error(`QueueBinding does not support runtime '${host.Type}'`),
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
);
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import * as queues from "@distilled.cloud/cloudflare/queues";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { isResolved } from "../../Diff.ts";
|
|
4
|
+
import * as Provider from "../../Provider.ts";
|
|
5
|
+
import { Resource } from "../../Resource.ts";
|
|
6
|
+
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
7
|
+
import type { Providers } from "../Providers.ts";
|
|
8
|
+
|
|
9
|
+
export type QueueConsumerProps = {
|
|
10
|
+
/**
|
|
11
|
+
* The queue ID to attach the consumer to.
|
|
12
|
+
*/
|
|
13
|
+
queueId: string;
|
|
14
|
+
/**
|
|
15
|
+
* Name of the Worker script that will consume messages.
|
|
16
|
+
*/
|
|
17
|
+
scriptName: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional dead letter queue name for failed messages.
|
|
20
|
+
*/
|
|
21
|
+
deadLetterQueue?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Consumer settings.
|
|
24
|
+
*/
|
|
25
|
+
settings?: {
|
|
26
|
+
/**
|
|
27
|
+
* The maximum number of messages per batch.
|
|
28
|
+
* @default 10
|
|
29
|
+
*/
|
|
30
|
+
batchSize?: number;
|
|
31
|
+
/**
|
|
32
|
+
* The maximum number of concurrent consumer invocations.
|
|
33
|
+
*/
|
|
34
|
+
maxConcurrency?: number;
|
|
35
|
+
/**
|
|
36
|
+
* The maximum number of retries for a message.
|
|
37
|
+
* @default 3
|
|
38
|
+
*/
|
|
39
|
+
maxRetries?: number;
|
|
40
|
+
/**
|
|
41
|
+
* The maximum time to wait for a batch to fill, in milliseconds.
|
|
42
|
+
* @default 5000
|
|
43
|
+
*/
|
|
44
|
+
maxWaitTimeMs?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The number of seconds to wait before retrying a message.
|
|
47
|
+
*/
|
|
48
|
+
retryDelay?: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type QueueConsumer = Resource<
|
|
53
|
+
"Cloudflare.QueueConsumer",
|
|
54
|
+
QueueConsumerProps,
|
|
55
|
+
{
|
|
56
|
+
consumerId: string;
|
|
57
|
+
queueId: string;
|
|
58
|
+
scriptName: string;
|
|
59
|
+
accountId: string;
|
|
60
|
+
},
|
|
61
|
+
never,
|
|
62
|
+
Providers
|
|
63
|
+
>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A Cloudflare Queue Consumer that processes messages from a Queue.
|
|
67
|
+
*
|
|
68
|
+
* Register a Worker as a consumer of a Queue. The Worker's `queue()`
|
|
69
|
+
* handler will be invoked with batches of messages.
|
|
70
|
+
*
|
|
71
|
+
* @section Registering a Consumer
|
|
72
|
+
* @example Basic consumer
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const queue = yield* Cloudflare.Queue("MyQueue");
|
|
75
|
+
* const worker = yield* Cloudflare.Worker("Worker", { ... });
|
|
76
|
+
*
|
|
77
|
+
* yield* Cloudflare.QueueConsumer("MyConsumer", {
|
|
78
|
+
* queueId: queue.queueId,
|
|
79
|
+
* scriptName: "my-worker",
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @example Consumer with settings
|
|
84
|
+
* ```typescript
|
|
85
|
+
* yield* Cloudflare.QueueConsumer("MyConsumer", {
|
|
86
|
+
* queueId: queue.queueId,
|
|
87
|
+
* scriptName: "my-worker",
|
|
88
|
+
* settings: {
|
|
89
|
+
* batchSize: 50,
|
|
90
|
+
* maxRetries: 5,
|
|
91
|
+
* maxWaitTimeMs: 10000,
|
|
92
|
+
* },
|
|
93
|
+
* });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export const QueueConsumer = Resource<QueueConsumer>(
|
|
97
|
+
"Cloudflare.QueueConsumer",
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
export const QueueConsumerProvider = () =>
|
|
101
|
+
Provider.effect(
|
|
102
|
+
QueueConsumer,
|
|
103
|
+
Effect.gen(function* () {
|
|
104
|
+
const { accountId } = yield* CloudflareEnvironment;
|
|
105
|
+
const createConsumer = yield* queues.createConsumer;
|
|
106
|
+
const getConsumer = yield* queues.getConsumer;
|
|
107
|
+
const updateConsumer = yield* queues.updateConsumer;
|
|
108
|
+
const deleteConsumer = yield* queues.deleteConsumer;
|
|
109
|
+
const listConsumers = yield* queues.listConsumers;
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
stables: ["consumerId", "accountId"],
|
|
113
|
+
diff: Effect.fn(function* ({ olds, news, output }) {
|
|
114
|
+
if (!isResolved(news)) return undefined;
|
|
115
|
+
if ((output?.accountId ?? accountId) !== accountId) {
|
|
116
|
+
return { action: "replace" } as const;
|
|
117
|
+
}
|
|
118
|
+
// Queue change requires replacement
|
|
119
|
+
if (output?.queueId && news.queueId !== output.queueId) {
|
|
120
|
+
return { action: "replace" } as const;
|
|
121
|
+
}
|
|
122
|
+
// Script change requires replacement
|
|
123
|
+
if (output?.scriptName && news.scriptName !== output.scriptName) {
|
|
124
|
+
return { action: "replace" } as const;
|
|
125
|
+
}
|
|
126
|
+
// Settings change is an update
|
|
127
|
+
if (
|
|
128
|
+
JSON.stringify(olds.settings ?? {}) !==
|
|
129
|
+
JSON.stringify(news.settings ?? {})
|
|
130
|
+
) {
|
|
131
|
+
return { action: "update" } as const;
|
|
132
|
+
}
|
|
133
|
+
}),
|
|
134
|
+
create: Effect.fn(function* ({ news }) {
|
|
135
|
+
const consumer = yield* createConsumer({
|
|
136
|
+
accountId,
|
|
137
|
+
queueId: news.queueId!,
|
|
138
|
+
scriptName: news.scriptName,
|
|
139
|
+
type: "worker",
|
|
140
|
+
deadLetterQueue: news.deadLetterQueue,
|
|
141
|
+
settings: news.settings,
|
|
142
|
+
}).pipe(
|
|
143
|
+
Effect.catch(() =>
|
|
144
|
+
Effect.gen(function* () {
|
|
145
|
+
// Consumer may already exist -- look it up
|
|
146
|
+
const existing = yield* listConsumers({
|
|
147
|
+
accountId,
|
|
148
|
+
queueId: news.queueId!,
|
|
149
|
+
});
|
|
150
|
+
const match = existing.result.find(
|
|
151
|
+
(c) => "script" in c && c.script === news.scriptName,
|
|
152
|
+
);
|
|
153
|
+
if (match && match.consumerId) {
|
|
154
|
+
return match as {
|
|
155
|
+
consumerId: string;
|
|
156
|
+
queueId?: string | null;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return yield* Effect.die(
|
|
160
|
+
`Consumer for script "${news.scriptName}" on queue "${news.queueId}" already exists but could not be found`,
|
|
161
|
+
);
|
|
162
|
+
}),
|
|
163
|
+
),
|
|
164
|
+
);
|
|
165
|
+
return {
|
|
166
|
+
consumerId: consumer.consumerId!,
|
|
167
|
+
queueId: news.queueId!,
|
|
168
|
+
scriptName: news.scriptName!,
|
|
169
|
+
accountId,
|
|
170
|
+
};
|
|
171
|
+
}),
|
|
172
|
+
update: Effect.fn(function* ({ news, output }) {
|
|
173
|
+
yield* updateConsumer({
|
|
174
|
+
accountId: output.accountId,
|
|
175
|
+
queueId: output.queueId,
|
|
176
|
+
consumerId: output.consumerId,
|
|
177
|
+
scriptName: news.scriptName,
|
|
178
|
+
type: "worker",
|
|
179
|
+
settings: news.settings,
|
|
180
|
+
deadLetterQueue: news.deadLetterQueue,
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
consumerId: output.consumerId,
|
|
184
|
+
queueId: output.queueId,
|
|
185
|
+
scriptName: news.scriptName ?? output.scriptName,
|
|
186
|
+
accountId: output.accountId,
|
|
187
|
+
};
|
|
188
|
+
}),
|
|
189
|
+
delete: Effect.fn(function* ({ output }) {
|
|
190
|
+
yield* deleteConsumer({
|
|
191
|
+
accountId: output.accountId,
|
|
192
|
+
queueId: output.queueId,
|
|
193
|
+
consumerId: output.consumerId,
|
|
194
|
+
}).pipe(Effect.catch(() => Effect.void));
|
|
195
|
+
}),
|
|
196
|
+
read: Effect.fn(function* ({ output }) {
|
|
197
|
+
if (output?.consumerId) {
|
|
198
|
+
return yield* getConsumer({
|
|
199
|
+
accountId: output.accountId,
|
|
200
|
+
queueId: output.queueId,
|
|
201
|
+
consumerId: output.consumerId,
|
|
202
|
+
}).pipe(
|
|
203
|
+
Effect.map((consumer) => ({
|
|
204
|
+
consumerId: consumer.consumerId!,
|
|
205
|
+
queueId: output.queueId,
|
|
206
|
+
scriptName:
|
|
207
|
+
("script" in consumer
|
|
208
|
+
? (consumer.script as string)
|
|
209
|
+
: output.scriptName) ?? output.scriptName,
|
|
210
|
+
accountId: output.accountId,
|
|
211
|
+
})),
|
|
212
|
+
Effect.catch(() => Effect.succeed(undefined)),
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
return undefined;
|
|
216
|
+
}),
|
|
217
|
+
};
|
|
218
|
+
}),
|
|
219
|
+
);
|
|
@@ -5,7 +5,7 @@ import { isResolved } from "../../Diff.ts";
|
|
|
5
5
|
import { createPhysicalName } from "../../PhysicalName.ts";
|
|
6
6
|
import * as Provider from "../../Provider.ts";
|
|
7
7
|
import { Resource } from "../../Resource.ts";
|
|
8
|
-
import {
|
|
8
|
+
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
9
9
|
import type * as Cloudflare from "../Providers.ts";
|
|
10
10
|
import { R2BucketBinding } from "./R2BucketBinding.ts";
|
|
11
11
|
|
|
@@ -104,7 +104,7 @@ export const R2BucketProvider = () =>
|
|
|
104
104
|
Provider.effect(
|
|
105
105
|
R2Bucket,
|
|
106
106
|
Effect.gen(function* () {
|
|
107
|
-
const accountId = yield*
|
|
107
|
+
const { accountId } = yield* CloudflareEnvironment;
|
|
108
108
|
const createBucket = yield* r2.createBucket;
|
|
109
109
|
const patchBucket = yield* r2.patchBucket;
|
|
110
110
|
const deleteBucket = yield* r2.deleteBucket;
|