alchemy 2.0.0-beta.62 → 2.0.0-beta.63
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/README.md +12 -12
- package/bin/exec.js +1959 -70
- package/bin/exec.js.map +1 -1
- package/lib/AWS/AuthProvider.js +1 -1
- package/lib/AWS/AuthProvider.js.map +1 -1
- package/lib/AWS/EC2/hosted.d.ts.map +1 -1
- package/lib/AWS/EC2/hosted.js +2 -1
- package/lib/AWS/EC2/hosted.js.map +1 -1
- package/lib/AWS/ECS/Task.d.ts.map +1 -1
- package/lib/AWS/ECS/Task.js +2 -1
- package/lib/AWS/ECS/Task.js.map +1 -1
- package/lib/AWS/Lambda/Function.d.ts.map +1 -1
- package/lib/AWS/Lambda/Function.js +13 -40
- package/lib/AWS/Lambda/Function.js.map +1 -1
- package/lib/AWS/Lambda/MicrovmRuntimeContext.d.ts.map +1 -1
- package/lib/AWS/Lambda/MicrovmRuntimeContext.js +9 -21
- package/lib/AWS/Lambda/MicrovmRuntimeContext.js.map +1 -1
- package/lib/Action.d.ts +8 -0
- package/lib/Action.d.ts.map +1 -1
- package/lib/Action.js +16 -5
- package/lib/Action.js.map +1 -1
- package/lib/ActionRuntimeContext.d.ts +14 -0
- package/lib/ActionRuntimeContext.d.ts.map +1 -0
- package/lib/ActionRuntimeContext.js +56 -0
- package/lib/ActionRuntimeContext.js.map +1 -0
- package/lib/Apply.d.ts.map +1 -1
- package/lib/Apply.js +40 -6
- package/lib/Apply.js.map +1 -1
- package/lib/Auth/AuthProvider.d.ts +3 -3
- package/lib/Auth/AuthProvider.d.ts.map +1 -1
- package/lib/Auth/AuthProvider.js +1 -1
- package/lib/Auth/AuthProvider.js.map +1 -1
- package/lib/Auth/Lock.d.ts.map +1 -1
- package/lib/Auth/Lock.js +5 -2
- package/lib/Auth/Lock.js.map +1 -1
- package/lib/Bundle/PurePlugin.d.ts.map +1 -1
- package/lib/Bundle/PurePlugin.js +26 -1
- package/lib/Bundle/PurePlugin.js.map +1 -1
- package/lib/Bundle/Vite.d.ts +2 -0
- package/lib/Bundle/Vite.d.ts.map +1 -1
- package/lib/Bundle/Vite.js +24 -1
- package/lib/Bundle/Vite.js.map +1 -1
- package/lib/Cli/LoggingCli.d.ts.map +1 -1
- package/lib/Cli/LoggingCli.js +7 -4
- package/lib/Cli/LoggingCli.js.map +1 -1
- package/lib/Cli/commands/_shared.d.ts +19 -0
- package/lib/Cli/commands/_shared.d.ts.map +1 -1
- package/lib/Cli/commands/_shared.js +22 -0
- package/lib/Cli/commands/_shared.js.map +1 -1
- package/lib/Cli/commands/login.d.ts +7 -3
- package/lib/Cli/commands/login.d.ts.map +1 -1
- package/lib/Cli/commands/login.js +70 -12
- package/lib/Cli/commands/login.js.map +1 -1
- package/lib/Cli/commands/profile.d.ts.map +1 -1
- package/lib/Cli/commands/profile.js +7 -20
- package/lib/Cli/commands/profile.js.map +1 -1
- package/lib/Cloudflare/AI/LanguageModel.js +21 -4
- package/lib/Cloudflare/AI/LanguageModel.js.map +1 -1
- package/lib/Cloudflare/AI/QuerySearchLocal.d.ts +37 -0
- package/lib/Cloudflare/AI/QuerySearchLocal.d.ts.map +1 -0
- package/lib/Cloudflare/AI/QuerySearchLocal.js +53 -0
- package/lib/Cloudflare/AI/QuerySearchLocal.js.map +1 -0
- package/lib/Cloudflare/AI/QuerySearchNamespaceLocal.d.ts +35 -0
- package/lib/Cloudflare/AI/QuerySearchNamespaceLocal.d.ts.map +1 -0
- package/lib/Cloudflare/AI/QuerySearchNamespaceLocal.js +47 -0
- package/lib/Cloudflare/AI/QuerySearchNamespaceLocal.js.map +1 -0
- package/lib/Cloudflare/AI/SearchHttpClient.d.ts +34 -0
- package/lib/Cloudflare/AI/SearchHttpClient.d.ts.map +1 -0
- package/lib/Cloudflare/AI/SearchHttpClient.js +262 -0
- package/lib/Cloudflare/AI/SearchHttpClient.js.map +1 -0
- package/lib/Cloudflare/AI/index.d.ts +2 -0
- package/lib/Cloudflare/AI/index.d.ts.map +1 -1
- package/lib/Cloudflare/AI/index.js +2 -0
- package/lib/Cloudflare/AI/index.js.map +1 -1
- package/lib/Cloudflare/Auth/AuthProvider.js +1 -1
- package/lib/Cloudflare/Auth/AuthProvider.js.map +1 -1
- package/lib/Cloudflare/Containers/ContainerBundle.d.ts.map +1 -1
- package/lib/Cloudflare/Containers/ContainerBundle.js +11 -1
- package/lib/Cloudflare/Containers/ContainerBundle.js.map +1 -1
- package/lib/Cloudflare/Containers/ContainerPlatform.d.ts.map +1 -1
- package/lib/Cloudflare/Containers/ContainerPlatform.js +12 -33
- package/lib/Cloudflare/Containers/ContainerPlatform.js.map +1 -1
- package/lib/Cloudflare/D1/QueryDatabaseHttpClient.d.ts +24 -0
- package/lib/Cloudflare/D1/QueryDatabaseHttpClient.d.ts.map +1 -0
- package/lib/Cloudflare/D1/QueryDatabaseHttpClient.js +106 -0
- package/lib/Cloudflare/D1/QueryDatabaseHttpClient.js.map +1 -0
- package/lib/Cloudflare/D1/QueryDatabaseLocal.d.ts +38 -0
- package/lib/Cloudflare/D1/QueryDatabaseLocal.d.ts.map +1 -0
- package/lib/Cloudflare/D1/QueryDatabaseLocal.js +54 -0
- package/lib/Cloudflare/D1/QueryDatabaseLocal.js.map +1 -0
- package/lib/Cloudflare/D1/index.d.ts +1 -0
- package/lib/Cloudflare/D1/index.d.ts.map +1 -1
- package/lib/Cloudflare/D1/index.js +1 -0
- package/lib/Cloudflare/D1/index.js.map +1 -1
- package/lib/Cloudflare/DNS/DnsHttp.d.ts +16 -1
- package/lib/Cloudflare/DNS/DnsHttp.d.ts.map +1 -1
- package/lib/Cloudflare/DNS/DnsHttp.js +6 -1
- package/lib/Cloudflare/DNS/DnsHttp.js.map +1 -1
- package/lib/Cloudflare/DNS/DnsLocal.d.ts +22 -0
- package/lib/Cloudflare/DNS/DnsLocal.d.ts.map +1 -0
- package/lib/Cloudflare/DNS/DnsLocal.js +31 -0
- package/lib/Cloudflare/DNS/DnsLocal.js.map +1 -0
- package/lib/Cloudflare/DNS/ReadDnsHttp.d.ts +3 -3
- package/lib/Cloudflare/DNS/ReadDnsHttp.d.ts.map +1 -1
- package/lib/Cloudflare/DNS/ReadDnsHttp.js +3 -4
- package/lib/Cloudflare/DNS/ReadDnsHttp.js.map +1 -1
- package/lib/Cloudflare/DNS/ReadDnsLocal.d.ts +32 -0
- package/lib/Cloudflare/DNS/ReadDnsLocal.d.ts.map +1 -0
- package/lib/Cloudflare/DNS/ReadDnsLocal.js +35 -0
- package/lib/Cloudflare/DNS/ReadDnsLocal.js.map +1 -0
- package/lib/Cloudflare/DNS/ReadWriteDnsHttp.d.ts +3 -3
- package/lib/Cloudflare/DNS/ReadWriteDnsHttp.d.ts.map +1 -1
- package/lib/Cloudflare/DNS/ReadWriteDnsHttp.js +4 -4
- package/lib/Cloudflare/DNS/ReadWriteDnsHttp.js.map +1 -1
- package/lib/Cloudflare/DNS/ReadWriteDnsLocal.d.ts +40 -0
- package/lib/Cloudflare/DNS/ReadWriteDnsLocal.d.ts.map +1 -0
- package/lib/Cloudflare/DNS/ReadWriteDnsLocal.js +43 -0
- package/lib/Cloudflare/DNS/ReadWriteDnsLocal.js.map +1 -0
- package/lib/Cloudflare/DNS/WriteDnsHttp.d.ts +3 -3
- package/lib/Cloudflare/DNS/WriteDnsHttp.d.ts.map +1 -1
- package/lib/Cloudflare/DNS/WriteDnsHttp.js +3 -4
- package/lib/Cloudflare/DNS/WriteDnsHttp.js.map +1 -1
- package/lib/Cloudflare/DNS/WriteDnsLocal.d.ts +38 -0
- package/lib/Cloudflare/DNS/WriteDnsLocal.d.ts.map +1 -0
- package/lib/Cloudflare/DNS/WriteDnsLocal.js +41 -0
- package/lib/Cloudflare/DNS/WriteDnsLocal.js.map +1 -0
- package/lib/Cloudflare/DNS/index.d.ts +3 -0
- package/lib/Cloudflare/DNS/index.d.ts.map +1 -1
- package/lib/Cloudflare/DNS/index.js +3 -0
- package/lib/Cloudflare/DNS/index.js.map +1 -1
- package/lib/Cloudflare/Flagship/ReadFlagsHttpClient.d.ts +27 -0
- package/lib/Cloudflare/Flagship/ReadFlagsHttpClient.d.ts.map +1 -0
- package/lib/Cloudflare/Flagship/ReadFlagsHttpClient.js +86 -0
- package/lib/Cloudflare/Flagship/ReadFlagsHttpClient.js.map +1 -0
- package/lib/Cloudflare/Flagship/ReadFlagsLocal.d.ts +41 -0
- package/lib/Cloudflare/Flagship/ReadFlagsLocal.d.ts.map +1 -0
- package/lib/Cloudflare/Flagship/ReadFlagsLocal.js +57 -0
- package/lib/Cloudflare/Flagship/ReadFlagsLocal.js.map +1 -0
- package/lib/Cloudflare/Flagship/index.d.ts +1 -0
- package/lib/Cloudflare/Flagship/index.d.ts.map +1 -1
- package/lib/Cloudflare/Flagship/index.js +1 -0
- package/lib/Cloudflare/Flagship/index.js.map +1 -1
- package/lib/Cloudflare/KV/NamespaceHttp.d.ts +16 -1
- package/lib/Cloudflare/KV/NamespaceHttp.d.ts.map +1 -1
- package/lib/Cloudflare/KV/NamespaceHttp.js +8 -2
- package/lib/Cloudflare/KV/NamespaceHttp.js.map +1 -1
- package/lib/Cloudflare/KV/NamespaceLocal.d.ts +22 -0
- package/lib/Cloudflare/KV/NamespaceLocal.d.ts.map +1 -0
- package/lib/Cloudflare/KV/NamespaceLocal.js +32 -0
- package/lib/Cloudflare/KV/NamespaceLocal.js.map +1 -0
- package/lib/Cloudflare/KV/ReadNamespaceHttp.d.ts +2 -2
- package/lib/Cloudflare/KV/ReadNamespaceHttp.d.ts.map +1 -1
- package/lib/Cloudflare/KV/ReadNamespaceHttp.js +5 -6
- package/lib/Cloudflare/KV/ReadNamespaceHttp.js.map +1 -1
- package/lib/Cloudflare/KV/ReadNamespaceLocal.d.ts +27 -0
- package/lib/Cloudflare/KV/ReadNamespaceLocal.d.ts.map +1 -0
- package/lib/Cloudflare/KV/ReadNamespaceLocal.js +30 -0
- package/lib/Cloudflare/KV/ReadNamespaceLocal.js.map +1 -0
- package/lib/Cloudflare/KV/ReadWriteNamespaceHttp.d.ts +3 -3
- package/lib/Cloudflare/KV/ReadWriteNamespaceHttp.d.ts.map +1 -1
- package/lib/Cloudflare/KV/ReadWriteNamespaceHttp.js +6 -6
- package/lib/Cloudflare/KV/ReadWriteNamespaceHttp.js.map +1 -1
- package/lib/Cloudflare/KV/ReadWriteNamespaceLocal.d.ts +34 -0
- package/lib/Cloudflare/KV/ReadWriteNamespaceLocal.d.ts.map +1 -0
- package/lib/Cloudflare/KV/ReadWriteNamespaceLocal.js +37 -0
- package/lib/Cloudflare/KV/ReadWriteNamespaceLocal.js.map +1 -0
- package/lib/Cloudflare/KV/WriteNamespaceHttp.d.ts +2 -2
- package/lib/Cloudflare/KV/WriteNamespaceHttp.d.ts.map +1 -1
- package/lib/Cloudflare/KV/WriteNamespaceHttp.js +5 -6
- package/lib/Cloudflare/KV/WriteNamespaceHttp.js.map +1 -1
- package/lib/Cloudflare/KV/WriteNamespaceLocal.d.ts +27 -0
- package/lib/Cloudflare/KV/WriteNamespaceLocal.d.ts.map +1 -0
- package/lib/Cloudflare/KV/WriteNamespaceLocal.js +30 -0
- package/lib/Cloudflare/KV/WriteNamespaceLocal.js.map +1 -0
- package/lib/Cloudflare/KV/index.d.ts +3 -0
- package/lib/Cloudflare/KV/index.d.ts.map +1 -1
- package/lib/Cloudflare/KV/index.js +3 -0
- package/lib/Cloudflare/KV/index.js.map +1 -1
- package/lib/Cloudflare/Queues/QueueHttp.d.ts +20 -1
- package/lib/Cloudflare/Queues/QueueHttp.d.ts.map +1 -1
- package/lib/Cloudflare/Queues/QueueHttp.js +2 -2
- package/lib/Cloudflare/Queues/QueueHttp.js.map +1 -1
- package/lib/Cloudflare/Queues/WriteQueueHttp.d.ts +9 -3
- package/lib/Cloudflare/Queues/WriteQueueHttp.d.ts.map +1 -1
- package/lib/Cloudflare/Queues/WriteQueueHttp.js +11 -6
- package/lib/Cloudflare/Queues/WriteQueueHttp.js.map +1 -1
- package/lib/Cloudflare/Queues/WriteQueueLocal.d.ts +36 -0
- package/lib/Cloudflare/Queues/WriteQueueLocal.d.ts.map +1 -0
- package/lib/Cloudflare/Queues/WriteQueueLocal.js +51 -0
- package/lib/Cloudflare/Queues/WriteQueueLocal.js.map +1 -0
- package/lib/Cloudflare/Queues/index.d.ts +1 -0
- package/lib/Cloudflare/Queues/index.d.ts.map +1 -1
- package/lib/Cloudflare/Queues/index.js +1 -0
- package/lib/Cloudflare/Queues/index.js.map +1 -1
- package/lib/Cloudflare/R2/BucketHttp.d.ts +15 -1
- package/lib/Cloudflare/R2/BucketHttp.d.ts.map +1 -1
- package/lib/Cloudflare/R2/BucketHttp.js +3 -3
- package/lib/Cloudflare/R2/BucketHttp.js.map +1 -1
- package/lib/Cloudflare/R2/BucketLocal.d.ts +21 -0
- package/lib/Cloudflare/R2/BucketLocal.d.ts.map +1 -0
- package/lib/Cloudflare/R2/BucketLocal.js +32 -0
- package/lib/Cloudflare/R2/BucketLocal.js.map +1 -0
- package/lib/Cloudflare/R2/ReadBucketHttp.d.ts +2 -2
- package/lib/Cloudflare/R2/ReadBucketHttp.d.ts.map +1 -1
- package/lib/Cloudflare/R2/ReadBucketHttp.js +4 -4
- package/lib/Cloudflare/R2/ReadBucketHttp.js.map +1 -1
- package/lib/Cloudflare/R2/ReadBucketLocal.d.ts +27 -0
- package/lib/Cloudflare/R2/ReadBucketLocal.d.ts.map +1 -0
- package/lib/Cloudflare/R2/ReadBucketLocal.js +30 -0
- package/lib/Cloudflare/R2/ReadBucketLocal.js.map +1 -0
- package/lib/Cloudflare/R2/ReadWriteBucketHttp.d.ts +2 -2
- package/lib/Cloudflare/R2/ReadWriteBucketHttp.d.ts.map +1 -1
- package/lib/Cloudflare/R2/ReadWriteBucketHttp.js +5 -4
- package/lib/Cloudflare/R2/ReadWriteBucketHttp.js.map +1 -1
- package/lib/Cloudflare/R2/ReadWriteBucketLocal.d.ts +30 -0
- package/lib/Cloudflare/R2/ReadWriteBucketLocal.d.ts.map +1 -0
- package/lib/Cloudflare/R2/ReadWriteBucketLocal.js +33 -0
- package/lib/Cloudflare/R2/ReadWriteBucketLocal.js.map +1 -0
- package/lib/Cloudflare/R2/WriteBucketHttp.d.ts +2 -2
- package/lib/Cloudflare/R2/WriteBucketHttp.d.ts.map +1 -1
- package/lib/Cloudflare/R2/WriteBucketHttp.js +4 -4
- package/lib/Cloudflare/R2/WriteBucketHttp.js.map +1 -1
- package/lib/Cloudflare/R2/WriteBucketLocal.d.ts +27 -0
- package/lib/Cloudflare/R2/WriteBucketLocal.d.ts.map +1 -0
- package/lib/Cloudflare/R2/WriteBucketLocal.js +30 -0
- package/lib/Cloudflare/R2/WriteBucketLocal.js.map +1 -0
- package/lib/Cloudflare/R2/index.d.ts +3 -0
- package/lib/Cloudflare/R2/index.d.ts.map +1 -1
- package/lib/Cloudflare/R2/index.js +3 -0
- package/lib/Cloudflare/R2/index.js.map +1 -1
- package/lib/Cloudflare/StateStore/Api.d.ts +2 -0
- package/lib/Cloudflare/Tunnel/ReadTunnel.d.ts +3 -3
- package/lib/Cloudflare/Tunnel/ReadTunnel.d.ts.map +1 -1
- package/lib/Cloudflare/Tunnel/ReadTunnel.js +7 -8
- package/lib/Cloudflare/Tunnel/ReadTunnel.js.map +1 -1
- package/lib/Cloudflare/Tunnel/ReadTunnelLocal.d.ts +29 -0
- package/lib/Cloudflare/Tunnel/ReadTunnelLocal.d.ts.map +1 -0
- package/lib/Cloudflare/Tunnel/ReadTunnelLocal.js +30 -0
- package/lib/Cloudflare/Tunnel/ReadTunnelLocal.js.map +1 -0
- package/lib/Cloudflare/Tunnel/ReadWriteTunnel.d.ts +3 -3
- package/lib/Cloudflare/Tunnel/ReadWriteTunnel.d.ts.map +1 -1
- package/lib/Cloudflare/Tunnel/ReadWriteTunnel.js +4 -4
- package/lib/Cloudflare/Tunnel/ReadWriteTunnel.js.map +1 -1
- package/lib/Cloudflare/Tunnel/ReadWriteTunnelLocal.d.ts +35 -0
- package/lib/Cloudflare/Tunnel/ReadWriteTunnelLocal.d.ts.map +1 -0
- package/lib/Cloudflare/Tunnel/ReadWriteTunnelLocal.js +36 -0
- package/lib/Cloudflare/Tunnel/ReadWriteTunnelLocal.js.map +1 -0
- package/lib/Cloudflare/Tunnel/TunnelBinding.d.ts +17 -1
- package/lib/Cloudflare/Tunnel/TunnelBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Tunnel/TunnelBinding.js +7 -1
- package/lib/Cloudflare/Tunnel/TunnelBinding.js.map +1 -1
- package/lib/Cloudflare/Tunnel/TunnelLocalBinding.d.ts +19 -0
- package/lib/Cloudflare/Tunnel/TunnelLocalBinding.d.ts.map +1 -0
- package/lib/Cloudflare/Tunnel/TunnelLocalBinding.js +29 -0
- package/lib/Cloudflare/Tunnel/TunnelLocalBinding.js.map +1 -0
- package/lib/Cloudflare/Tunnel/WarpConnector.d.ts +3 -3
- package/lib/Cloudflare/Tunnel/WarpConnector.d.ts.map +1 -1
- package/lib/Cloudflare/Tunnel/WarpConnector.js +7 -4
- package/lib/Cloudflare/Tunnel/WarpConnector.js.map +1 -1
- package/lib/Cloudflare/Tunnel/WriteTunnel.d.ts +3 -3
- package/lib/Cloudflare/Tunnel/WriteTunnel.d.ts.map +1 -1
- package/lib/Cloudflare/Tunnel/WriteTunnel.js +7 -8
- package/lib/Cloudflare/Tunnel/WriteTunnel.js.map +1 -1
- package/lib/Cloudflare/Tunnel/WriteTunnelLocal.d.ts +29 -0
- package/lib/Cloudflare/Tunnel/WriteTunnelLocal.d.ts.map +1 -0
- package/lib/Cloudflare/Tunnel/WriteTunnelLocal.js +30 -0
- package/lib/Cloudflare/Tunnel/WriteTunnelLocal.js.map +1 -0
- package/lib/Cloudflare/Tunnel/index.d.ts +3 -0
- package/lib/Cloudflare/Tunnel/index.d.ts.map +1 -1
- package/lib/Cloudflare/Tunnel/index.js +3 -0
- package/lib/Cloudflare/Tunnel/index.js.map +1 -1
- package/lib/Cloudflare/Vectorize/SearchIndexHttpClient.d.ts +30 -0
- package/lib/Cloudflare/Vectorize/SearchIndexHttpClient.d.ts.map +1 -0
- package/lib/Cloudflare/Vectorize/SearchIndexHttpClient.js +100 -0
- package/lib/Cloudflare/Vectorize/SearchIndexHttpClient.js.map +1 -0
- package/lib/Cloudflare/Vectorize/SearchIndexLocal.d.ts +42 -0
- package/lib/Cloudflare/Vectorize/SearchIndexLocal.d.ts.map +1 -0
- package/lib/Cloudflare/Vectorize/SearchIndexLocal.js +58 -0
- package/lib/Cloudflare/Vectorize/SearchIndexLocal.js.map +1 -0
- package/lib/Cloudflare/Vectorize/index.d.ts +1 -0
- package/lib/Cloudflare/Vectorize/index.d.ts.map +1 -1
- package/lib/Cloudflare/Vectorize/index.js +1 -0
- package/lib/Cloudflare/Vectorize/index.js.map +1 -1
- package/lib/Cloudflare/Workers/BrowserHttpClient.d.ts +32 -0
- package/lib/Cloudflare/Workers/BrowserHttpClient.d.ts.map +1 -0
- package/lib/Cloudflare/Workers/BrowserHttpClient.js +100 -0
- package/lib/Cloudflare/Workers/BrowserHttpClient.js.map +1 -0
- package/lib/Cloudflare/Workers/BrowserLocal.d.ts +37 -0
- package/lib/Cloudflare/Workers/BrowserLocal.d.ts.map +1 -0
- package/lib/Cloudflare/Workers/BrowserLocal.js +53 -0
- package/lib/Cloudflare/Workers/BrowserLocal.js.map +1 -0
- package/lib/Cloudflare/Workers/ConfigProvider.d.ts +8 -0
- package/lib/Cloudflare/Workers/ConfigProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/ConfigProvider.js +10 -1
- package/lib/Cloudflare/Workers/ConfigProvider.js.map +1 -1
- package/lib/Cloudflare/Workers/DurableObject.d.ts +137 -3
- package/lib/Cloudflare/Workers/DurableObject.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/DurableObject.js +141 -6
- package/lib/Cloudflare/Workers/DurableObject.js.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts +2 -185
- package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Vite.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Vite.js +81 -2
- package/lib/Cloudflare/Workers/Vite.js.map +1 -1
- package/lib/Cloudflare/Workers/Worker.d.ts +15 -1
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.js +2 -1
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBinding.d.ts +22 -1
- package/lib/Cloudflare/Workers/WorkerBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBinding.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBridge.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBridge.js +7 -2
- package/lib/Cloudflare/Workers/WorkerBridge.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerProvider.d.ts +81 -0
- package/lib/Cloudflare/Workers/WorkerProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerProvider.js +450 -61
- package/lib/Cloudflare/Workers/WorkerProvider.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerRuntimeContext.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerRuntimeContext.js +11 -37
- package/lib/Cloudflare/Workers/WorkerRuntimeContext.js.map +1 -1
- package/lib/Cloudflare/Workers/index.d.ts +1 -0
- package/lib/Cloudflare/Workers/index.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/index.js +1 -0
- package/lib/Cloudflare/Workers/index.js.map +1 -1
- package/lib/Diff.d.ts +16 -0
- package/lib/Diff.d.ts.map +1 -1
- package/lib/Diff.js +33 -0
- package/lib/Diff.js.map +1 -1
- package/lib/GitHub/Secrets.d.ts +1 -1
- package/lib/GitHub/Secrets.js +1 -1
- package/lib/GitHub/Variables.d.ts +1 -1
- package/lib/GitHub/Variables.js +1 -1
- package/lib/Local/RpcSerialization.d.ts.map +1 -1
- package/lib/Local/RpcSerialization.js +6 -2
- package/lib/Local/RpcSerialization.js.map +1 -1
- package/lib/Local/RpcSpawner.d.ts.map +1 -1
- package/lib/Local/RpcSpawner.js +14 -8
- package/lib/Local/RpcSpawner.js.map +1 -1
- package/lib/Neon/AuthProvider.js +1 -1
- package/lib/Neon/AuthProvider.js.map +1 -1
- package/lib/Plan.d.ts.map +1 -1
- package/lib/Plan.js +11 -4
- package/lib/Plan.js.map +1 -1
- package/lib/Planetscale/Database.d.ts +2 -1
- package/lib/Planetscale/Database.d.ts.map +1 -1
- package/lib/Planetscale/MySQL/MySQLClusterSize.d.ts +41 -3
- package/lib/Planetscale/MySQL/MySQLClusterSize.d.ts.map +1 -1
- package/lib/Planetscale/MySQL/MySQLClusterSize.js +88 -11
- package/lib/Planetscale/MySQL/MySQLClusterSize.js.map +1 -1
- package/lib/Planetscale/MySQL/MySQLDatabase.d.ts +14 -0
- package/lib/Planetscale/MySQL/MySQLDatabase.d.ts.map +1 -1
- package/lib/Planetscale/MySQL/MySQLDatabase.js +24 -11
- package/lib/Planetscale/MySQL/MySQLDatabase.js.map +1 -1
- package/lib/Platform.d.ts.map +1 -1
- package/lib/Platform.js +11 -1
- package/lib/Platform.js.map +1 -1
- package/lib/Runtime.d.ts +23 -0
- package/lib/Runtime.d.ts.map +1 -1
- package/lib/Runtime.js +83 -0
- package/lib/Runtime.js.map +1 -1
- package/lib/RuntimeContext.d.ts +46 -0
- package/lib/RuntimeContext.d.ts.map +1 -1
- package/lib/RuntimeContext.js +60 -0
- package/lib/RuntimeContext.js.map +1 -1
- package/lib/Server/Process.d.ts +1 -1
- package/lib/Server/Process.d.ts.map +1 -1
- package/lib/Server/Process.js +8 -8
- package/lib/Server/Process.js.map +1 -1
- package/lib/Stack.js +1 -1
- package/lib/Stack.js.map +1 -1
- package/lib/State/HttpStateApi.d.ts +10 -10
- package/lib/Test/Alchemy.d.ts +74 -0
- package/lib/Test/Alchemy.d.ts.map +1 -0
- package/lib/Test/Alchemy.js +143 -0
- package/lib/Test/Alchemy.js.map +1 -0
- package/lib/Util/cached-function.d.ts +1 -1
- package/lib/Util/cached-function.d.ts.map +1 -1
- package/lib/Util/cached-function.js +2 -2
- package/lib/Util/cached-function.js.map +1 -1
- package/lib/Util/proxy-chain.js +3 -0
- package/lib/Util/proxy-chain.js.map +1 -1
- package/package.json +10 -10
- package/src/AWS/AuthProvider.ts +1 -1
- package/src/AWS/EC2/hosted.ts +2 -1
- package/src/AWS/ECS/Task.ts +2 -1
- package/src/AWS/Lambda/Function.ts +13 -47
- package/src/AWS/Lambda/MicrovmRuntimeContext.ts +11 -38
- package/src/Action.ts +39 -6
- package/src/ActionRuntimeContext.ts +68 -0
- package/src/Apply.ts +46 -8
- package/src/Auth/AuthProvider.ts +1 -1
- package/src/Auth/Lock.ts +5 -2
- package/src/Bundle/PurePlugin.ts +34 -1
- package/src/Bundle/Vite.ts +51 -1
- package/src/Cli/LoggingCli.ts +7 -4
- package/src/Cli/commands/_shared.ts +52 -0
- package/src/Cli/commands/login.ts +90 -14
- package/src/Cli/commands/profile.ts +7 -41
- package/src/Cloudflare/AI/LanguageModel.ts +25 -5
- package/src/Cloudflare/AI/QuerySearchLocal.ts +66 -0
- package/src/Cloudflare/AI/QuerySearchNamespaceLocal.ts +60 -0
- package/src/Cloudflare/AI/SearchHttpClient.ts +423 -0
- package/src/Cloudflare/AI/index.ts +2 -0
- package/src/Cloudflare/Auth/AuthProvider.ts +1 -1
- package/src/Cloudflare/Containers/ContainerBundle.ts +11 -1
- package/src/Cloudflare/Containers/ContainerPlatform.ts +14 -52
- package/src/Cloudflare/D1/QueryDatabaseHttpClient.ts +176 -0
- package/src/Cloudflare/D1/QueryDatabaseLocal.ts +66 -0
- package/src/Cloudflare/D1/index.ts +1 -0
- package/src/Cloudflare/DNS/DnsHttp.ts +24 -2
- package/src/Cloudflare/DNS/DnsLocal.ts +41 -0
- package/src/Cloudflare/DNS/ReadDnsHttp.ts +4 -5
- package/src/Cloudflare/DNS/ReadDnsLocal.ts +38 -0
- package/src/Cloudflare/DNS/ReadWriteDnsHttp.ts +5 -5
- package/src/Cloudflare/DNS/ReadWriteDnsLocal.ts +46 -0
- package/src/Cloudflare/DNS/WriteDnsHttp.ts +4 -5
- package/src/Cloudflare/DNS/WriteDnsLocal.ts +44 -0
- package/src/Cloudflare/DNS/index.ts +3 -0
- package/src/Cloudflare/Flagship/ReadFlagsHttpClient.ts +183 -0
- package/src/Cloudflare/Flagship/ReadFlagsLocal.ts +69 -0
- package/src/Cloudflare/Flagship/index.ts +1 -0
- package/src/Cloudflare/KV/NamespaceHttp.ts +25 -2
- package/src/Cloudflare/KV/NamespaceLocal.ts +42 -0
- package/src/Cloudflare/KV/ReadNamespaceHttp.ts +7 -6
- package/src/Cloudflare/KV/ReadNamespaceLocal.ts +35 -0
- package/src/Cloudflare/KV/ReadWriteNamespaceHttp.ts +11 -6
- package/src/Cloudflare/KV/ReadWriteNamespaceLocal.ts +42 -0
- package/src/Cloudflare/KV/WriteNamespaceHttp.ts +7 -6
- package/src/Cloudflare/KV/WriteNamespaceLocal.ts +35 -0
- package/src/Cloudflare/KV/index.ts +3 -0
- package/src/Cloudflare/Queues/QueueHttp.ts +24 -2
- package/src/Cloudflare/Queues/WriteQueueHttp.ts +16 -7
- package/src/Cloudflare/Queues/WriteQueueLocal.ts +64 -0
- package/src/Cloudflare/Queues/index.ts +1 -0
- package/src/Cloudflare/R2/BucketHttp.ts +20 -3
- package/src/Cloudflare/R2/BucketLocal.ts +47 -0
- package/src/Cloudflare/R2/ReadBucketHttp.ts +10 -5
- package/src/Cloudflare/R2/ReadBucketLocal.ts +33 -0
- package/src/Cloudflare/R2/ReadWriteBucketHttp.ts +11 -5
- package/src/Cloudflare/R2/ReadWriteBucketLocal.ts +36 -0
- package/src/Cloudflare/R2/WriteBucketHttp.ts +10 -5
- package/src/Cloudflare/R2/WriteBucketLocal.ts +33 -0
- package/src/Cloudflare/R2/index.ts +3 -0
- package/src/Cloudflare/Tunnel/ReadTunnel.ts +8 -9
- package/src/Cloudflare/Tunnel/ReadTunnelLocal.ts +33 -0
- package/src/Cloudflare/Tunnel/ReadWriteTunnel.ts +5 -5
- package/src/Cloudflare/Tunnel/ReadWriteTunnelLocal.ts +39 -0
- package/src/Cloudflare/Tunnel/TunnelBinding.ts +26 -2
- package/src/Cloudflare/Tunnel/TunnelLocalBinding.ts +38 -0
- package/src/Cloudflare/Tunnel/WarpConnector.ts +8 -5
- package/src/Cloudflare/Tunnel/WriteTunnel.ts +8 -9
- package/src/Cloudflare/Tunnel/WriteTunnelLocal.ts +33 -0
- package/src/Cloudflare/Tunnel/index.ts +3 -0
- package/src/Cloudflare/Vectorize/SearchIndexHttpClient.ts +183 -0
- package/src/Cloudflare/Vectorize/SearchIndexLocal.ts +70 -0
- package/src/Cloudflare/Vectorize/index.ts +1 -0
- package/src/Cloudflare/Workers/BrowserHttpClient.ts +201 -0
- package/src/Cloudflare/Workers/BrowserLocal.ts +65 -0
- package/src/Cloudflare/Workers/ConfigProvider.ts +15 -1
- package/src/Cloudflare/Workers/DurableObject.ts +227 -6
- package/src/Cloudflare/Workers/Vite.ts +93 -11
- package/src/Cloudflare/Workers/Worker.ts +19 -1
- package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +6 -5
- package/src/Cloudflare/Workers/WorkerBinding.ts +20 -1
- package/src/Cloudflare/Workers/WorkerBridge.ts +12 -2
- package/src/Cloudflare/Workers/WorkerProvider.ts +664 -117
- package/src/Cloudflare/Workers/WorkerRuntimeContext.ts +14 -45
- package/src/Cloudflare/Workers/index.ts +1 -0
- package/src/Diff.ts +33 -0
- package/src/GitHub/Secrets.ts +1 -1
- package/src/GitHub/Variables.ts +1 -1
- package/src/Local/RpcSerialization.ts +6 -2
- package/src/Local/RpcSpawner.ts +21 -8
- package/src/Neon/AuthProvider.ts +1 -1
- package/src/Plan.ts +17 -4
- package/src/Planetscale/Database.ts +2 -1
- package/src/Planetscale/MySQL/MySQLClusterSize.ts +120 -21
- package/src/Planetscale/MySQL/MySQLDatabase.ts +84 -44
- package/src/Platform.ts +12 -3
- package/src/Runtime.ts +92 -0
- package/src/RuntimeContext.ts +79 -0
- package/src/Server/Process.ts +11 -18
- package/src/Stack.ts +1 -1
- package/src/Test/Alchemy.ts +282 -0
- package/src/Util/cached-function.ts +5 -5
- package/src/Util/proxy-chain.ts +3 -0
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
makeHttpQueueBinding,
|
|
7
7
|
makeQueueHttpScope,
|
|
8
8
|
toQueueSendError,
|
|
9
|
-
type
|
|
9
|
+
type QueueAuth,
|
|
10
10
|
} from "./QueueHttp.ts";
|
|
11
11
|
import { SendError, type SendMessage } from "./QueueTypes.ts";
|
|
12
12
|
import { WriteQueue, type WriteQueueClient } from "./WriteQueue.ts";
|
|
@@ -27,7 +27,11 @@ export const WriteQueueHttp = Layer.effect(
|
|
|
27
27
|
Effect.suspend(() =>
|
|
28
28
|
makeHttpQueueBinding({
|
|
29
29
|
permissionGroups: ["Queues Write"],
|
|
30
|
-
makeClient:
|
|
30
|
+
makeClient: (token, queueId) =>
|
|
31
|
+
makeWriteQueueHttpClient(
|
|
32
|
+
{ authorize: authorizeWith(token), accountId: token.accountId },
|
|
33
|
+
queueId,
|
|
34
|
+
),
|
|
31
35
|
}),
|
|
32
36
|
),
|
|
33
37
|
);
|
|
@@ -44,18 +48,23 @@ const toMessage = (message: SendMessage) =>
|
|
|
44
48
|
}
|
|
45
49
|
: { body: message.body, contentType: "json" as const };
|
|
46
50
|
|
|
47
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Build the producer client over the Queues bulk-push HTTP API.
|
|
53
|
+
*
|
|
54
|
+
* Shared by {@link WriteQueueHttp} (scoped token auth) and
|
|
55
|
+
* `WriteQueueLocal` (current-credentials auth) — they differ only in the
|
|
56
|
+
* {@link QueueAuth} they inject.
|
|
57
|
+
*/
|
|
48
58
|
export const makeWriteQueueHttpClient = (
|
|
49
|
-
|
|
59
|
+
auth: QueueAuth,
|
|
50
60
|
queueId: Effect.Effect<string>,
|
|
51
61
|
): WriteQueueClient => {
|
|
52
|
-
const
|
|
53
|
-
const scope = makeQueueHttpScope(token, queueId);
|
|
62
|
+
const scope = makeQueueHttpScope(auth, queueId);
|
|
54
63
|
|
|
55
64
|
const push = (messages: ReadonlyArray<SendMessage>) =>
|
|
56
65
|
scope.pipe(
|
|
57
66
|
Effect.flatMap(({ accountId, queueId }) =>
|
|
58
|
-
authorize(
|
|
67
|
+
auth.authorize(
|
|
59
68
|
queues.bulkPushMessages({
|
|
60
69
|
accountId,
|
|
61
70
|
queueId,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
4
|
+
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
5
|
+
import type { Credentials } from "../Credentials.ts";
|
|
6
|
+
import type { Queue } from "./Queue.ts";
|
|
7
|
+
import { makeWriteQueueHttpClient } from "./WriteQueueHttp.ts";
|
|
8
|
+
import { WriteQueue } from "./WriteQueue.ts";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Local implementation of the {@link WriteQueue} binding — pushes messages
|
|
12
|
+
* to a Cloudflare Queue over the bulk-push HTTP API using the **current
|
|
13
|
+
* credentials** instead of a native Worker binding
|
|
14
|
+
* ({@link WriteQueueBinding}) or a scoped API token ({@link WriteQueueHttp}).
|
|
15
|
+
*
|
|
16
|
+
* Provide it on an {@link Action} (or any deploy-time Effect) so you can send
|
|
17
|
+
* messages to a queue with the same `send`/`sendBatch` client you'd use inside
|
|
18
|
+
* a Worker — no Worker host and no minted token.
|
|
19
|
+
*
|
|
20
|
+
* @example Seeding a queue from an Action
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const Seed = Alchemy.Action(
|
|
23
|
+
* "Seed",
|
|
24
|
+
* Effect.gen(function* () {
|
|
25
|
+
* const q = yield* Cloudflare.Queues.WriteQueue(queue);
|
|
26
|
+
* return Effect.fn(function* () {
|
|
27
|
+
* yield* q.send({ text: "hi", sentAt: Date.now() });
|
|
28
|
+
* yield* q.sendBatch([{ body: { event: "click", id: 1 } }]);
|
|
29
|
+
* });
|
|
30
|
+
* }).pipe(Effect.provide(Cloudflare.Queues.WriteQueueLocal)),
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* The queue id is resolved at apply time through the ambient
|
|
35
|
+
* {@link RuntimeContext} (in an Action, that's the resolve context the engine
|
|
36
|
+
* provides around the body), so `WriteQueue(queue)` works even though the
|
|
37
|
+
* queue is created in the same deploy.
|
|
38
|
+
*/
|
|
39
|
+
export const WriteQueueLocal = Layer.effect(
|
|
40
|
+
WriteQueue,
|
|
41
|
+
Effect.gen(function* () {
|
|
42
|
+
// Account + credentials are ambient during stack-eval (the stack's
|
|
43
|
+
// providers layer). Capture the full context so the bulk-push effect can
|
|
44
|
+
// run with the current credentials instead of a scoped token.
|
|
45
|
+
const { accountId } = yield* yield* CloudflareEnvironment;
|
|
46
|
+
const context = yield* Effect.context<
|
|
47
|
+
Credentials | HttpClient.HttpClient
|
|
48
|
+
>();
|
|
49
|
+
|
|
50
|
+
return Effect.fn(function* (queue: Queue) {
|
|
51
|
+
// Deferred accessor — resolves the queueId against the tracker at apply
|
|
52
|
+
// time. No `host.bind`: the local variant registers no binding.
|
|
53
|
+
const queueId = yield* queue.queueId;
|
|
54
|
+
|
|
55
|
+
return makeWriteQueueHttpClient(
|
|
56
|
+
{
|
|
57
|
+
authorize: (eff) => eff.pipe(Effect.provideContext(context)),
|
|
58
|
+
accountId: Effect.succeed(accountId),
|
|
59
|
+
},
|
|
60
|
+
queueId,
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import type * as Redacted from "effect/Redacted";
|
|
3
3
|
import * as Stream from "effect/Stream";
|
|
4
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
4
5
|
import { Self } from "../../Self.ts";
|
|
6
|
+
import type { RuntimeContext } from "../../RuntimeContext.ts";
|
|
5
7
|
import { AccountApiToken } from "../ApiToken/AccountApiToken.ts";
|
|
6
8
|
import type { PermissionGroupRef } from "../ApiToken/Common.ts";
|
|
7
9
|
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
10
|
+
import type { Credentials } from "../Credentials.ts";
|
|
8
11
|
import type { Bucket } from "./Bucket.ts";
|
|
9
12
|
import { R2Error, type R2Object } from "./BucketTypes.ts";
|
|
10
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Injectable auth used by the R2 HTTP client builders. Both the token-scoped
|
|
16
|
+
* `*Http` layers and the current-credentials `*Local` layers build one of
|
|
17
|
+
* these so they can share the exact same client implementation.
|
|
18
|
+
*/
|
|
19
|
+
export interface R2Auth {
|
|
20
|
+
/** Provide credentials + HTTP client to a raw distilled R2 op. */
|
|
21
|
+
authorize: <A, E>(
|
|
22
|
+
eff: Effect.Effect<A, E, Credentials | HttpClient.HttpClient>,
|
|
23
|
+
) => Effect.Effect<A, E, RuntimeContext>;
|
|
24
|
+
/** Resolve the Cloudflare account id. */
|
|
25
|
+
accountId: Effect.Effect<string>;
|
|
26
|
+
}
|
|
27
|
+
|
|
11
28
|
export const makeHttpBucketBinding = <Client>(options: {
|
|
12
29
|
permissionGroups: PermissionGroup[];
|
|
13
30
|
makeClient: (
|
|
@@ -66,16 +83,16 @@ type PermissionGroup = (typeof R2_HTTP_PERMISSION_GROUPS)[number];
|
|
|
66
83
|
|
|
67
84
|
/** Resolve the account, bucket, and jurisdiction once per operation. */
|
|
68
85
|
export const makeR2HttpScope = (
|
|
69
|
-
|
|
86
|
+
accountId: Effect.Effect<string>,
|
|
70
87
|
bucketName: Effect.Effect<string>,
|
|
71
88
|
jurisdiction: Effect.Effect<string>,
|
|
72
89
|
): Effect.Effect<HttpScope> =>
|
|
73
90
|
Effect.gen(function* () {
|
|
74
|
-
const
|
|
91
|
+
const accountId_ = yield* accountId;
|
|
75
92
|
const bucket = yield* bucketName;
|
|
76
93
|
const j = yield* jurisdiction;
|
|
77
94
|
return {
|
|
78
|
-
accountId,
|
|
95
|
+
accountId: accountId_,
|
|
79
96
|
bucketName: bucket,
|
|
80
97
|
cfR2Jurisdiction: j === "default" ? undefined : j,
|
|
81
98
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
3
|
+
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
4
|
+
import type { Credentials } from "../Credentials.ts";
|
|
5
|
+
import type { Bucket } from "./Bucket.ts";
|
|
6
|
+
import type { R2Auth } from "./BucketHttp.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Shared scaffolding for the R2 `*Local` binding layers.
|
|
10
|
+
*
|
|
11
|
+
* Resolves the account + captures the ambient current-credentials context at
|
|
12
|
+
* layer construction, then returns the deferred binding callable. The callable
|
|
13
|
+
* reads the bucket name/jurisdiction as deferred accessors (resolved at apply
|
|
14
|
+
* time) and builds the same HTTP-backed client the `*Http` variant uses, but
|
|
15
|
+
* authorized with the current CLI credentials instead of a minted token.
|
|
16
|
+
*
|
|
17
|
+
* NOT exported from `index.ts`.
|
|
18
|
+
*/
|
|
19
|
+
export const makeLocalBucketBinding = <Client>(makeClient: {
|
|
20
|
+
(
|
|
21
|
+
auth: R2Auth,
|
|
22
|
+
bucketName: Effect.Effect<string>,
|
|
23
|
+
jurisdiction: Effect.Effect<string>,
|
|
24
|
+
): Client;
|
|
25
|
+
}) =>
|
|
26
|
+
Effect.gen(function* () {
|
|
27
|
+
// Account + credentials are ambient during stack-eval (the stack's
|
|
28
|
+
// providers layer). Capture the full context so each op can be run with the
|
|
29
|
+
// current credentials.
|
|
30
|
+
const { accountId } = yield* yield* CloudflareEnvironment;
|
|
31
|
+
const context = yield* Effect.context<
|
|
32
|
+
Credentials | HttpClient.HttpClient
|
|
33
|
+
>();
|
|
34
|
+
|
|
35
|
+
const auth: R2Auth = {
|
|
36
|
+
authorize: (eff) => eff.pipe(Effect.provideContext(context)),
|
|
37
|
+
accountId: Effect.succeed(accountId),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return Effect.fn(function* (bucket: Bucket) {
|
|
41
|
+
// Deferred accessors — resolved against the tracker at apply time. No
|
|
42
|
+
// `host.bind`: the local variant registers no binding.
|
|
43
|
+
const bucketName = yield* bucket.bucketName;
|
|
44
|
+
const jurisdiction = yield* bucket.jurisdiction;
|
|
45
|
+
return makeClient(auth, bucketName, jurisdiction);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
makeR2HttpScope,
|
|
10
10
|
toR2Error,
|
|
11
11
|
type HttpMetadata,
|
|
12
|
-
type
|
|
12
|
+
type R2Auth,
|
|
13
13
|
} from "./BucketHttp.ts";
|
|
14
14
|
import { ReadBucket, type ReadBucketClient } from "./ReadBucket.ts";
|
|
15
15
|
import {
|
|
@@ -29,18 +29,23 @@ export const ReadBucketHttp = Layer.effect(
|
|
|
29
29
|
Effect.suspend(() =>
|
|
30
30
|
makeHttpBucketBinding({
|
|
31
31
|
permissionGroups: ["Workers R2 Storage Read"],
|
|
32
|
-
makeClient:
|
|
32
|
+
makeClient: (token, bucketName, jurisdiction) =>
|
|
33
|
+
makeReadR2HttpClient(
|
|
34
|
+
{ authorize: authorizeWith(token), accountId: token.accountId },
|
|
35
|
+
bucketName,
|
|
36
|
+
jurisdiction,
|
|
37
|
+
),
|
|
33
38
|
}),
|
|
34
39
|
),
|
|
35
40
|
);
|
|
36
41
|
|
|
37
42
|
export const makeReadR2HttpClient = (
|
|
38
|
-
|
|
43
|
+
auth: R2Auth,
|
|
39
44
|
bucketName: Effect.Effect<string>,
|
|
40
45
|
jurisdiction: Effect.Effect<string>,
|
|
41
46
|
): ReadBucketClient => {
|
|
42
|
-
const authorize =
|
|
43
|
-
const scope = makeR2HttpScope(
|
|
47
|
+
const authorize = auth.authorize;
|
|
48
|
+
const scope = makeR2HttpScope(auth.accountId, bucketName, jurisdiction);
|
|
44
49
|
|
|
45
50
|
return {
|
|
46
51
|
raw: Effect.die(
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import { makeLocalBucketBinding } from "./BucketLocal.ts";
|
|
4
|
+
import { ReadBucket } from "./ReadBucket.ts";
|
|
5
|
+
import { makeReadR2HttpClient } from "./ReadBucketHttp.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Local implementation of the {@link ReadBucket} binding — reads R2 objects
|
|
9
|
+
* over the Cloudflare HTTP API using the **current credentials** instead of a
|
|
10
|
+
* native Worker binding (`ReadBucketBinding`) or a scoped API token
|
|
11
|
+
* (`ReadBucketHttp`).
|
|
12
|
+
*
|
|
13
|
+
* Provide it on an {@link Action} (or any deploy-time Effect) to read a bucket
|
|
14
|
+
* with the same `head`/`get`/`list` client you'd use inside a Worker.
|
|
15
|
+
*
|
|
16
|
+
* @example Reading an object from an Action
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const Read = Alchemy.Action(
|
|
19
|
+
* "Read",
|
|
20
|
+
* Effect.gen(function* () {
|
|
21
|
+
* const r2 = yield* Cloudflare.R2.ReadBucket(bucket);
|
|
22
|
+
* return Effect.fn(function* () {
|
|
23
|
+
* const object = yield* r2.get("hello.txt");
|
|
24
|
+
* return object ? yield* object.text() : null;
|
|
25
|
+
* });
|
|
26
|
+
* }).pipe(Effect.provide(Cloudflare.R2.ReadBucketLocal)),
|
|
27
|
+
* );
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export const ReadBucketLocal = Layer.effect(
|
|
31
|
+
ReadBucket,
|
|
32
|
+
Effect.suspend(() => makeLocalBucketBinding(makeReadR2HttpClient)),
|
|
33
|
+
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
|
-
import {
|
|
3
|
+
import { authorizeWith } from "../HttpClientUtils.ts";
|
|
4
|
+
import { makeHttpBucketBinding, type R2Auth } from "./BucketHttp.ts";
|
|
4
5
|
import { makeReadR2HttpClient } from "./ReadBucketHttp.ts";
|
|
5
6
|
import {
|
|
6
7
|
ReadWriteBucket,
|
|
@@ -18,18 +19,23 @@ export const ReadWriteBucketHttp = Layer.effect(
|
|
|
18
19
|
Effect.suspend(() =>
|
|
19
20
|
makeHttpBucketBinding({
|
|
20
21
|
permissionGroups: ["Workers R2 Storage Read", "Workers R2 Storage Write"],
|
|
21
|
-
makeClient:
|
|
22
|
+
makeClient: (token, bucketName, jurisdiction) =>
|
|
23
|
+
makeReadWriteR2HttpClient(
|
|
24
|
+
{ authorize: authorizeWith(token), accountId: token.accountId },
|
|
25
|
+
bucketName,
|
|
26
|
+
jurisdiction,
|
|
27
|
+
),
|
|
22
28
|
}),
|
|
23
29
|
),
|
|
24
30
|
);
|
|
25
31
|
|
|
26
32
|
/** Build the HTTP-backed {@link ReadWrite} over a bound token + bucket. */
|
|
27
33
|
export const makeReadWriteR2HttpClient = (
|
|
28
|
-
|
|
34
|
+
auth: R2Auth,
|
|
29
35
|
bucketName: Effect.Effect<string>,
|
|
30
36
|
jurisdiction: Effect.Effect<string>,
|
|
31
37
|
): ReadWriteBucketClient =>
|
|
32
38
|
({
|
|
33
|
-
...makeReadR2HttpClient(
|
|
34
|
-
...makeWriteR2HttpClient(
|
|
39
|
+
...makeReadR2HttpClient(auth, bucketName, jurisdiction),
|
|
40
|
+
...makeWriteR2HttpClient(auth, bucketName, jurisdiction),
|
|
35
41
|
}) satisfies ReadWriteBucketClient;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import { makeLocalBucketBinding } from "./BucketLocal.ts";
|
|
4
|
+
import { ReadWriteBucket } from "./ReadWriteBucket.ts";
|
|
5
|
+
import { makeReadWriteR2HttpClient } from "./ReadWriteBucketHttp.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Local implementation of the {@link ReadWriteBucket} binding — reads and
|
|
9
|
+
* writes R2 objects over the Cloudflare HTTP API using the **current
|
|
10
|
+
* credentials** instead of a native Worker binding (`ReadWriteBucketBinding`)
|
|
11
|
+
* or a scoped API token (`ReadWriteBucketHttp`).
|
|
12
|
+
*
|
|
13
|
+
* Provide it on an {@link Action} (or any deploy-time Effect) to use the same
|
|
14
|
+
* `head`/`get`/`list`/`put`/`delete` client you'd use inside a Worker.
|
|
15
|
+
* Multipart uploads are unsupported over the HTTP API (mirrors
|
|
16
|
+
* `ReadWriteBucketHttp`).
|
|
17
|
+
*
|
|
18
|
+
* @example Seeding then reading a bucket from an Action
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const Seed = Alchemy.Action(
|
|
21
|
+
* "Seed",
|
|
22
|
+
* Effect.gen(function* () {
|
|
23
|
+
* const r2 = yield* Cloudflare.R2.ReadWriteBucket(bucket);
|
|
24
|
+
* return Effect.fn(function* () {
|
|
25
|
+
* yield* r2.put("hello.txt", "Hello, World!");
|
|
26
|
+
* const object = yield* r2.get("hello.txt");
|
|
27
|
+
* return object ? yield* object.text() : null;
|
|
28
|
+
* });
|
|
29
|
+
* }).pipe(Effect.provide(Cloudflare.R2.ReadWriteBucketLocal)),
|
|
30
|
+
* );
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const ReadWriteBucketLocal = Layer.effect(
|
|
34
|
+
ReadWriteBucket,
|
|
35
|
+
Effect.suspend(() => makeLocalBucketBinding(makeReadWriteR2HttpClient)),
|
|
36
|
+
);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
readHttpMetadata,
|
|
11
11
|
toBody,
|
|
12
12
|
toR2Error,
|
|
13
|
-
type
|
|
13
|
+
type R2Auth,
|
|
14
14
|
} from "./BucketHttp.ts";
|
|
15
15
|
import { R2Error, type PutOptions } from "./BucketTypes.ts";
|
|
16
16
|
import { WriteBucket, type WriteBucketClient } from "./WriteBucket.ts";
|
|
@@ -25,19 +25,24 @@ export const WriteBucketHttp = Layer.effect(
|
|
|
25
25
|
Effect.suspend(() =>
|
|
26
26
|
makeHttpBucketBinding({
|
|
27
27
|
permissionGroups: ["Workers R2 Storage Write"],
|
|
28
|
-
makeClient:
|
|
28
|
+
makeClient: (token, bucketName, jurisdiction) =>
|
|
29
|
+
makeWriteR2HttpClient(
|
|
30
|
+
{ authorize: authorizeWith(token), accountId: token.accountId },
|
|
31
|
+
bucketName,
|
|
32
|
+
jurisdiction,
|
|
33
|
+
),
|
|
29
34
|
}),
|
|
30
35
|
),
|
|
31
36
|
);
|
|
32
37
|
|
|
33
38
|
/** Build the write half of the HTTP-backed {@link ReadWrite} client. */
|
|
34
39
|
export const makeWriteR2HttpClient = (
|
|
35
|
-
|
|
40
|
+
auth: R2Auth,
|
|
36
41
|
bucketName: Effect.Effect<string>,
|
|
37
42
|
jurisdiction: Effect.Effect<string>,
|
|
38
43
|
): WriteBucketClient => {
|
|
39
|
-
const authorize =
|
|
40
|
-
const scope = makeR2HttpScope(
|
|
44
|
+
const authorize = auth.authorize;
|
|
45
|
+
const scope = makeR2HttpScope(auth.accountId, bucketName, jurisdiction);
|
|
41
46
|
|
|
42
47
|
return {
|
|
43
48
|
put: ((
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import { makeLocalBucketBinding } from "./BucketLocal.ts";
|
|
4
|
+
import { WriteBucket } from "./WriteBucket.ts";
|
|
5
|
+
import { makeWriteR2HttpClient } from "./WriteBucketHttp.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Local implementation of the {@link WriteBucket} binding — writes R2 objects
|
|
9
|
+
* over the Cloudflare HTTP API using the **current credentials** instead of a
|
|
10
|
+
* native Worker binding (`WriteBucketBinding`) or a scoped API token
|
|
11
|
+
* (`WriteBucketHttp`).
|
|
12
|
+
*
|
|
13
|
+
* Provide it on an {@link Action} (or any deploy-time Effect) to write a bucket
|
|
14
|
+
* with the same `put`/`delete` client you'd use inside a Worker. Multipart
|
|
15
|
+
* uploads are unsupported over the HTTP API (mirrors `WriteBucketHttp`).
|
|
16
|
+
*
|
|
17
|
+
* @example Seeding a bucket from an Action
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const Seed = Alchemy.Action(
|
|
20
|
+
* "Seed",
|
|
21
|
+
* Effect.gen(function* () {
|
|
22
|
+
* const r2 = yield* Cloudflare.R2.WriteBucket(bucket);
|
|
23
|
+
* return Effect.fn(function* () {
|
|
24
|
+
* yield* r2.put("hello.txt", "Hello, World!");
|
|
25
|
+
* });
|
|
26
|
+
* }).pipe(Effect.provide(Cloudflare.R2.WriteBucketLocal)),
|
|
27
|
+
* );
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export const WriteBucketLocal = Layer.effect(
|
|
31
|
+
WriteBucket,
|
|
32
|
+
Effect.suspend(() => makeLocalBucketBinding(makeWriteR2HttpClient)),
|
|
33
|
+
);
|
|
@@ -5,9 +5,12 @@ export * from "./DataCatalog.ts";
|
|
|
5
5
|
export * from "./ReadBucket.ts";
|
|
6
6
|
export * from "./ReadBucketBinding.ts";
|
|
7
7
|
export * from "./ReadBucketHttp.ts";
|
|
8
|
+
export * from "./ReadBucketLocal.ts";
|
|
8
9
|
export * from "./ReadWriteBucket.ts";
|
|
9
10
|
export * from "./ReadWriteBucketBinding.ts";
|
|
10
11
|
export * from "./ReadWriteBucketHttp.ts";
|
|
12
|
+
export * from "./ReadWriteBucketLocal.ts";
|
|
11
13
|
export * from "./WriteBucket.ts";
|
|
12
14
|
export * from "./WriteBucketBinding.ts";
|
|
13
15
|
export * from "./WriteBucketHttp.ts";
|
|
16
|
+
export * from "./WriteBucketLocal.ts";
|
|
@@ -15,8 +15,7 @@ import * as Binding from "../../Binding.ts";
|
|
|
15
15
|
import type { Worker } from "../Workers/Worker.ts";
|
|
16
16
|
import type { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
17
17
|
import type { RuntimeContext } from "../../RuntimeContext.ts";
|
|
18
|
-
import { type
|
|
19
|
-
import { authorizeWith } from "../HttpClientUtils.ts";
|
|
18
|
+
import { type TunnelAuth } from "./TunnelBinding.ts";
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Binding that lets a Worker read Cloudflare Tunnels at runtime.
|
|
@@ -117,31 +116,31 @@ export interface ReadTunnelClient {
|
|
|
117
116
|
>;
|
|
118
117
|
}
|
|
119
118
|
|
|
120
|
-
/** Build the read-only client over
|
|
121
|
-
export const readClient = (
|
|
122
|
-
const authorize =
|
|
119
|
+
/** Build the read-only client over an injectable {@link TunnelAuth}. */
|
|
120
|
+
export const readClient = (auth: TunnelAuth): ReadTunnelClient => {
|
|
121
|
+
const { authorize } = auth;
|
|
123
122
|
return {
|
|
124
123
|
get: Effect.fn("Cloudflare.Tunnel.get")(function* (tunnelId) {
|
|
125
|
-
const accountId = yield*
|
|
124
|
+
const accountId = yield* auth.accountId;
|
|
126
125
|
return yield* authorize(
|
|
127
126
|
zeroTrust.getTunnelCloudflared({ accountId, tunnelId }),
|
|
128
127
|
);
|
|
129
128
|
}),
|
|
130
129
|
list: Effect.fn("Cloudflare.Tunnel.list")(function* (request) {
|
|
131
|
-
const accountId = yield*
|
|
130
|
+
const accountId = yield* auth.accountId;
|
|
132
131
|
return yield* authorize(
|
|
133
132
|
zeroTrust.listTunnelCloudflareds({ accountId, ...request }),
|
|
134
133
|
);
|
|
135
134
|
}),
|
|
136
135
|
getToken: Effect.fn("Cloudflare.Tunnel.getToken")(function* (tunnelId) {
|
|
137
|
-
const accountId = yield*
|
|
136
|
+
const accountId = yield* auth.accountId;
|
|
138
137
|
return yield* authorize(
|
|
139
138
|
zeroTrust.getTunnelCloudflaredToken({ accountId, tunnelId }),
|
|
140
139
|
);
|
|
141
140
|
}),
|
|
142
141
|
getConfiguration: Effect.fn("Cloudflare.Tunnel.getConfiguration")(
|
|
143
142
|
function* (tunnelId) {
|
|
144
|
-
const accountId = yield*
|
|
143
|
+
const accountId = yield* auth.accountId;
|
|
145
144
|
return yield* authorize(
|
|
146
145
|
zeroTrust.getTunnelCloudflaredConfiguration({ accountId, tunnelId }),
|
|
147
146
|
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
import { readClient, ReadTunnel } from "./ReadTunnel.ts";
|
|
3
|
+
import { makeLocalTunnelClient } from "./TunnelLocalBinding.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Local implementation of the {@link ReadTunnel} binding — reads Cloudflare
|
|
7
|
+
* Tunnels over the cfd_tunnel HTTP API using the **current credentials**
|
|
8
|
+
* instead of a native Worker binding (`ReadTunnelBinding`) or a scoped API
|
|
9
|
+
* token. No `host.bind`, no minted token, no Worker host.
|
|
10
|
+
*
|
|
11
|
+
* Provide it on an {@link Action} (or any deploy-time Effect) so you can read
|
|
12
|
+
* tunnels with the same `get`/`list`/`getToken`/`getConfiguration` client you'd
|
|
13
|
+
* use inside a Worker.
|
|
14
|
+
*
|
|
15
|
+
* @example Read a tunnel's connector token from an Action
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const Inspect = Alchemy.Action(
|
|
18
|
+
* "Inspect",
|
|
19
|
+
* Effect.gen(function* () {
|
|
20
|
+
* const tunnels = yield* Cloudflare.Tunnel.ReadTunnel();
|
|
21
|
+
* const tunnelId = yield* tunnel.tunnelId;
|
|
22
|
+
* return Effect.fn(function* () {
|
|
23
|
+
* const t = yield* tunnels.get(yield* tunnelId);
|
|
24
|
+
* return t.result?.name;
|
|
25
|
+
* });
|
|
26
|
+
* }).pipe(Effect.provide(Cloudflare.Tunnel.ReadTunnelLocal)),
|
|
27
|
+
* );
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export const ReadTunnelLocal = Layer.effect(
|
|
31
|
+
ReadTunnel,
|
|
32
|
+
makeLocalTunnelClient(readClient),
|
|
33
|
+
);
|
|
@@ -2,7 +2,7 @@ import * as Effect from "effect/Effect";
|
|
|
2
2
|
import * as Binding from "../../Binding.ts";
|
|
3
3
|
import type { Worker } from "../Workers/Worker.ts";
|
|
4
4
|
import type { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
5
|
-
import { type
|
|
5
|
+
import { type TunnelAuth } from "./TunnelBinding.ts";
|
|
6
6
|
import { readClient, type ReadTunnelClient } from "./ReadTunnel.ts";
|
|
7
7
|
import { writeClient, type WriteTunnelClient } from "./WriteTunnel.ts";
|
|
8
8
|
|
|
@@ -68,8 +68,8 @@ export const ReadWriteTunnel = Binding.Service<ReadWriteTunnel>(
|
|
|
68
68
|
export interface ReadWriteTunnelClient
|
|
69
69
|
extends ReadTunnelClient, WriteTunnelClient {}
|
|
70
70
|
|
|
71
|
-
/** Build the combined read + write client over
|
|
72
|
-
export const readWriteClient = (
|
|
73
|
-
...readClient(
|
|
74
|
-
...writeClient(
|
|
71
|
+
/** Build the combined read + write client over an injectable {@link TunnelAuth}. */
|
|
72
|
+
export const readWriteClient = (auth: TunnelAuth): ReadWriteTunnelClient => ({
|
|
73
|
+
...readClient(auth),
|
|
74
|
+
...writeClient(auth),
|
|
75
75
|
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as Layer from "effect/Layer";
|
|
2
|
+
import { readWriteClient, ReadWriteTunnel } from "./ReadWriteTunnel.ts";
|
|
3
|
+
import { makeLocalTunnelClient } from "./TunnelLocalBinding.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Local implementation of the {@link ReadWriteTunnel} binding — performs the
|
|
7
|
+
* full cfd_tunnel CRUD surface over the HTTP API using the **current
|
|
8
|
+
* credentials** instead of a native Worker binding (`ReadWriteTunnelBinding`)
|
|
9
|
+
* or a scoped API token. No `host.bind`, no minted token, no Worker host.
|
|
10
|
+
*
|
|
11
|
+
* Provide it on an {@link Action} (or any deploy-time Effect) so you can manage
|
|
12
|
+
* tunnels with the same combined read + write client you'd use inside a Worker.
|
|
13
|
+
*
|
|
14
|
+
* @example Configure a deployed tunnel from an Action
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const Configure = Alchemy.Action(
|
|
17
|
+
* "Configure",
|
|
18
|
+
* Effect.gen(function* () {
|
|
19
|
+
* const tunnels = yield* Cloudflare.Tunnel.ReadWriteTunnel();
|
|
20
|
+
* const tunnelId = yield* tunnel.tunnelId;
|
|
21
|
+
* return Effect.fn(function* () {
|
|
22
|
+
* const id = yield* tunnelId;
|
|
23
|
+
* yield* tunnels.putConfiguration(id, {
|
|
24
|
+
* ingress: [
|
|
25
|
+
* { hostname: "app.example.com", service: "http://localhost:3000" },
|
|
26
|
+
* { service: "http_status:404" },
|
|
27
|
+
* ],
|
|
28
|
+
* });
|
|
29
|
+
* const { config } = yield* tunnels.getConfiguration(id);
|
|
30
|
+
* return config;
|
|
31
|
+
* });
|
|
32
|
+
* }).pipe(Effect.provide(Cloudflare.Tunnel.ReadWriteTunnelLocal)),
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export const ReadWriteTunnelLocal = Layer.effect(
|
|
37
|
+
ReadWriteTunnel,
|
|
38
|
+
makeLocalTunnelClient(readWriteClient),
|
|
39
|
+
);
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import type * as Redacted from "effect/Redacted";
|
|
3
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
4
|
+
import type { RuntimeContext } from "../../RuntimeContext.ts";
|
|
3
5
|
import { AccountApiToken } from "../ApiToken/AccountApiToken.ts";
|
|
4
6
|
import type { PermissionGroupRef } from "../ApiToken/Common.ts";
|
|
5
7
|
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
8
|
+
import type { Credentials } from "../Credentials.ts";
|
|
9
|
+
import { authorizeWith } from "../HttpClientUtils.ts";
|
|
6
10
|
import { Worker } from "../Workers/Worker.ts";
|
|
7
11
|
|
|
8
12
|
/**
|
|
@@ -16,7 +20,7 @@ import { Worker } from "../Workers/Worker.ts";
|
|
|
16
20
|
export const makeTunnelClient = <C>(
|
|
17
21
|
sid: string,
|
|
18
22
|
permissionGroups: PermissionGroupRef[],
|
|
19
|
-
makeClient: (
|
|
23
|
+
makeClient: (auth: TunnelAuth) => C,
|
|
20
24
|
) =>
|
|
21
25
|
Effect.gen(function* () {
|
|
22
26
|
const Token = yield* AccountApiToken;
|
|
@@ -39,10 +43,30 @@ export const makeTunnelClient = <C>(
|
|
|
39
43
|
],
|
|
40
44
|
});
|
|
41
45
|
}
|
|
42
|
-
return makeClient(yield* bindTunnelToken(token));
|
|
46
|
+
return makeClient(makeTunnelAuth(yield* bindTunnelToken(token)));
|
|
43
47
|
});
|
|
44
48
|
});
|
|
45
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Injectable auth for the tunnel client builders. Both the scoped-token
|
|
52
|
+
* (`*Binding`) and current-credentials (`*Local`) variants supply an
|
|
53
|
+
* `authorize` (which provides `Credentials` + `HttpClient` to a raw SDK op)
|
|
54
|
+
* and an `accountId`, so the client builders are agnostic to how creds are
|
|
55
|
+
* obtained.
|
|
56
|
+
*/
|
|
57
|
+
export interface TunnelAuth {
|
|
58
|
+
authorize: <A, E>(
|
|
59
|
+
eff: Effect.Effect<A, E, Credentials | HttpClient.HttpClient>,
|
|
60
|
+
) => Effect.Effect<A, E, RuntimeContext>;
|
|
61
|
+
accountId: Effect.Effect<string>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Build a scoped-token {@link TunnelAuth} from a bound {@link Token}. */
|
|
65
|
+
export const makeTunnelAuth = (token: Token): TunnelAuth => ({
|
|
66
|
+
authorize: authorizeWith(token),
|
|
67
|
+
accountId: token.accountId,
|
|
68
|
+
});
|
|
69
|
+
|
|
46
70
|
/**
|
|
47
71
|
* Runtime accessors for a tunnel binding's token, obtained by binding the
|
|
48
72
|
* {@link AccountApiToken}'s outputs in the Worker's Init phase. Each accessor
|