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
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type * as cf from "@cloudflare/workers-types";
|
|
2
|
+
import * as flagship from "@distilled.cloud/cloudflare/flagship";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
5
|
+
import type { RuntimeContext } from "../../RuntimeContext.ts";
|
|
6
|
+
import type { Credentials } from "../Credentials.ts";
|
|
7
|
+
import {
|
|
8
|
+
type EvaluationContext,
|
|
9
|
+
type EvaluationDetails,
|
|
10
|
+
FlagshipError,
|
|
11
|
+
type ReadFlagsClient,
|
|
12
|
+
} from "./ReadFlags.ts";
|
|
13
|
+
|
|
14
|
+
// Shared HTTP scaffolding for the Flagship `ReadFlags` binding. NOT
|
|
15
|
+
// re-exported from `index.ts` — only the contract and the impl layers are
|
|
16
|
+
// public. A future token-scoped `ReadFlagsHttp` layer reuses this builder with
|
|
17
|
+
// an auth minted from an `AccountApiToken`; `ReadFlagsLocal` builds the auth
|
|
18
|
+
// from the ambient current-credentials context.
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Injectable auth shared by the Local (current-credentials) impl and a future
|
|
22
|
+
* Http (scoped-token) impl. `authorize` discharges the
|
|
23
|
+
* `Credentials | HttpClient` requirement of a distilled op; `accountId` is the
|
|
24
|
+
* Cloudflare account the ops run against.
|
|
25
|
+
*/
|
|
26
|
+
export interface FlagshipAuth {
|
|
27
|
+
authorize: <A, E>(
|
|
28
|
+
eff: Effect.Effect<A, E, Credentials | HttpClient.HttpClient>,
|
|
29
|
+
) => Effect.Effect<A, E>;
|
|
30
|
+
accountId: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The HTTP evaluate endpoint only supports a single `targetingKey` query
|
|
35
|
+
* param, not the full flat evaluation context the Worker binding accepts.
|
|
36
|
+
*/
|
|
37
|
+
const targetingKeyOf = (
|
|
38
|
+
context: EvaluationContext | undefined,
|
|
39
|
+
): string | undefined => {
|
|
40
|
+
const value = context?.["targetingKey"];
|
|
41
|
+
return value === undefined ? undefined : String(value);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Build a {@link ReadFlagsClient} over the Flagship HTTP evaluate endpoint
|
|
46
|
+
* (`GET .../flagship/apps/{appId}/evaluate`).
|
|
47
|
+
*
|
|
48
|
+
* `appId` is an Effect so the resolution stays deferred to each call — inside
|
|
49
|
+
* an Action it resolves through the apply-time RuntimeContext. Mirrors the
|
|
50
|
+
* Worker binding's fall-back-to-default semantics: evaluation never fails the
|
|
51
|
+
* effect — an HTTP error or a value whose type does not match the requested
|
|
52
|
+
* method resolves to `defaultValue` instead. The `raw` runtime binding has no
|
|
53
|
+
* HTTP equivalent and dies if used.
|
|
54
|
+
*/
|
|
55
|
+
export const makeHttpFlagshipClient = (
|
|
56
|
+
auth: FlagshipAuth,
|
|
57
|
+
appId: Effect.Effect<string>,
|
|
58
|
+
): ReadFlagsClient => {
|
|
59
|
+
const evaluate = (flagKey: string, context?: EvaluationContext) =>
|
|
60
|
+
appId.pipe(
|
|
61
|
+
Effect.flatMap((id) =>
|
|
62
|
+
auth.authorize(
|
|
63
|
+
flagship.getAppEvaluate({
|
|
64
|
+
accountId: auth.accountId,
|
|
65
|
+
appId: id,
|
|
66
|
+
flagKey,
|
|
67
|
+
targetingKey: targetingKeyOf(context),
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const details = <T>(
|
|
74
|
+
flagKey: string,
|
|
75
|
+
defaultValue: T,
|
|
76
|
+
match: (value: unknown) => value is T,
|
|
77
|
+
context?: EvaluationContext,
|
|
78
|
+
): Effect.Effect<EvaluationDetails<T>, FlagshipError, RuntimeContext> =>
|
|
79
|
+
evaluate(flagKey, context).pipe(
|
|
80
|
+
Effect.map(
|
|
81
|
+
(r): EvaluationDetails<T> =>
|
|
82
|
+
match(r.value)
|
|
83
|
+
? { flagKey, value: r.value, variant: r.variant, reason: r.reason }
|
|
84
|
+
: {
|
|
85
|
+
flagKey,
|
|
86
|
+
value: defaultValue,
|
|
87
|
+
variant: r.variant,
|
|
88
|
+
reason: r.reason,
|
|
89
|
+
errorCode: "TYPE_MISMATCH",
|
|
90
|
+
},
|
|
91
|
+
),
|
|
92
|
+
Effect.catch((error) =>
|
|
93
|
+
Effect.succeed<EvaluationDetails<T>>({
|
|
94
|
+
flagKey,
|
|
95
|
+
value: defaultValue,
|
|
96
|
+
reason: "ERROR",
|
|
97
|
+
errorCode: error._tag,
|
|
98
|
+
}),
|
|
99
|
+
),
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const value = <T>(
|
|
103
|
+
flagKey: string,
|
|
104
|
+
defaultValue: T,
|
|
105
|
+
match: (value: unknown) => value is T,
|
|
106
|
+
context?: EvaluationContext,
|
|
107
|
+
): Effect.Effect<T, FlagshipError, RuntimeContext> =>
|
|
108
|
+
evaluate(flagKey, context).pipe(
|
|
109
|
+
Effect.map((r) => (match(r.value) ? r.value : defaultValue)),
|
|
110
|
+
Effect.catch(() => Effect.succeed(defaultValue)),
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const isBoolean = (v: unknown): v is boolean => typeof v === "boolean";
|
|
114
|
+
const isString = (v: unknown): v is string => typeof v === "string";
|
|
115
|
+
const isNumber = (v: unknown): v is number => typeof v === "number";
|
|
116
|
+
const isObjectLike = (v: unknown): boolean =>
|
|
117
|
+
v !== null && typeof v === "object";
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
// The raw runtime binding is a workerd object with no HTTP surface.
|
|
121
|
+
raw: Effect.die(
|
|
122
|
+
new FlagshipError({
|
|
123
|
+
message:
|
|
124
|
+
"the raw Flagship runtime binding is unavailable over HTTP; use ReadFlagsBinding inside a Worker",
|
|
125
|
+
cause: undefined,
|
|
126
|
+
}),
|
|
127
|
+
) as Effect.Effect<cf.Flagship, never, RuntimeContext>,
|
|
128
|
+
get: (flagKey, defaultValue, context) =>
|
|
129
|
+
evaluate(flagKey, context).pipe(
|
|
130
|
+
Effect.map((r) => r.value ?? defaultValue),
|
|
131
|
+
Effect.catch(() => Effect.succeed(defaultValue)),
|
|
132
|
+
),
|
|
133
|
+
getBooleanValue: (flagKey, defaultValue, context) =>
|
|
134
|
+
value(flagKey, defaultValue, isBoolean, context),
|
|
135
|
+
getStringValue: (flagKey, defaultValue, context) =>
|
|
136
|
+
value(flagKey, defaultValue, isString, context),
|
|
137
|
+
getNumberValue: (flagKey, defaultValue, context) =>
|
|
138
|
+
value(flagKey, defaultValue, isNumber, context),
|
|
139
|
+
getObjectValue: (flagKey, defaultValue, context) =>
|
|
140
|
+
evaluate(flagKey, context).pipe(
|
|
141
|
+
Effect.map((r) =>
|
|
142
|
+
isObjectLike(r.value)
|
|
143
|
+
? (r.value as typeof defaultValue)
|
|
144
|
+
: defaultValue,
|
|
145
|
+
),
|
|
146
|
+
Effect.catch(() => Effect.succeed(defaultValue)),
|
|
147
|
+
),
|
|
148
|
+
getBooleanDetails: (flagKey, defaultValue, context) =>
|
|
149
|
+
details(flagKey, defaultValue, isBoolean, context),
|
|
150
|
+
getStringDetails: (flagKey, defaultValue, context) =>
|
|
151
|
+
details(flagKey, defaultValue, isString, context),
|
|
152
|
+
getNumberDetails: (flagKey, defaultValue, context) =>
|
|
153
|
+
details(flagKey, defaultValue, isNumber, context),
|
|
154
|
+
getObjectDetails: (flagKey, defaultValue, context) =>
|
|
155
|
+
evaluate(flagKey, context).pipe(
|
|
156
|
+
Effect.map(
|
|
157
|
+
(r): EvaluationDetails<typeof defaultValue> =>
|
|
158
|
+
isObjectLike(r.value)
|
|
159
|
+
? {
|
|
160
|
+
flagKey,
|
|
161
|
+
value: r.value as typeof defaultValue,
|
|
162
|
+
variant: r.variant,
|
|
163
|
+
reason: r.reason,
|
|
164
|
+
}
|
|
165
|
+
: {
|
|
166
|
+
flagKey,
|
|
167
|
+
value: defaultValue,
|
|
168
|
+
variant: r.variant,
|
|
169
|
+
reason: r.reason,
|
|
170
|
+
errorCode: "TYPE_MISMATCH",
|
|
171
|
+
},
|
|
172
|
+
),
|
|
173
|
+
Effect.catch((error) =>
|
|
174
|
+
Effect.succeed<EvaluationDetails<typeof defaultValue>>({
|
|
175
|
+
flagKey,
|
|
176
|
+
value: defaultValue,
|
|
177
|
+
reason: "ERROR",
|
|
178
|
+
errorCode: error._tag,
|
|
179
|
+
}),
|
|
180
|
+
),
|
|
181
|
+
),
|
|
182
|
+
} satisfies ReadFlagsClient;
|
|
183
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
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 { App } from "./App.ts";
|
|
7
|
+
import { ReadFlags } from "./ReadFlags.ts";
|
|
8
|
+
import {
|
|
9
|
+
type FlagshipAuth,
|
|
10
|
+
makeHttpFlagshipClient,
|
|
11
|
+
} from "./ReadFlagsHttpClient.ts";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Local implementation of the {@link ReadFlags} binding — evaluates Flagship
|
|
15
|
+
* feature flags over the Cloudflare HTTP API (`GET .../flagship/apps/{appId}/evaluate`)
|
|
16
|
+
* using the **current credentials** instead of a native Worker binding
|
|
17
|
+
* ({@link ReadFlagsBinding}).
|
|
18
|
+
*
|
|
19
|
+
* Provide it on an {@link Action} (or any deploy-time Effect) so you can read
|
|
20
|
+
* flag values with the same `getBooleanValue`/`getStringValue`/… client you'd
|
|
21
|
+
* use inside a Worker:
|
|
22
|
+
*
|
|
23
|
+
* @example Reading a flag from an Action
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const CheckFlag = Alchemy.Action(
|
|
26
|
+
* "CheckFlag",
|
|
27
|
+
* Effect.gen(function* () {
|
|
28
|
+
* const flags = yield* Cloudflare.Flagship.ReadFlags(app);
|
|
29
|
+
* return Effect.fn(function* () {
|
|
30
|
+
* return yield* flags.getBooleanValue("new-checkout", false);
|
|
31
|
+
* });
|
|
32
|
+
* }).pipe(Effect.provide(Cloudflare.Flagship.ReadFlagsLocal)),
|
|
33
|
+
* );
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* The app id is resolved at apply time through the ambient {@link RuntimeContext}
|
|
37
|
+
* (in an Action, that's the resolve context the engine provides around the
|
|
38
|
+
* body), so `ReadFlags(app)` works even though the app is created in the same
|
|
39
|
+
* deploy.
|
|
40
|
+
*
|
|
41
|
+
* Limitations vs. the Worker binding: the HTTP evaluate endpoint only accepts a
|
|
42
|
+
* single `targetingKey` (read from `context.targetingKey`), so attribute-based
|
|
43
|
+
* targeting rules that key off other context fields cannot be exercised locally.
|
|
44
|
+
* The `raw` runtime binding has no HTTP equivalent and dies if used — see
|
|
45
|
+
* {@link makeHttpFlagshipClient}.
|
|
46
|
+
*/
|
|
47
|
+
export const ReadFlagsLocal = Layer.effect(
|
|
48
|
+
ReadFlags,
|
|
49
|
+
Effect.gen(function* () {
|
|
50
|
+
// Account + credentials are ambient during stack-eval (the stack's
|
|
51
|
+
// providers layer). Capture the full context so the evaluate op can run
|
|
52
|
+
// with the current credentials — no `host.bind`, no minted token.
|
|
53
|
+
const { accountId } = yield* yield* CloudflareEnvironment;
|
|
54
|
+
const context = yield* Effect.context<
|
|
55
|
+
Credentials | HttpClient.HttpClient
|
|
56
|
+
>();
|
|
57
|
+
const auth: FlagshipAuth = {
|
|
58
|
+
authorize: (eff) => eff.pipe(Effect.provideContext(context)),
|
|
59
|
+
accountId,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return Effect.fn(function* (app: App) {
|
|
63
|
+
// Deferred accessor — resolves the appId against the tracker at apply
|
|
64
|
+
// time (in an Action, that's the engine's resolve context).
|
|
65
|
+
const appId = yield* app.appId;
|
|
66
|
+
return makeHttpFlagshipClient(auth, appId);
|
|
67
|
+
});
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
@@ -1,9 +1,13 @@
|
|
|
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 { Self } from "../../Self.ts";
|
|
4
6
|
import { AccountApiToken } from "../ApiToken/AccountApiToken.ts";
|
|
5
7
|
import type { PermissionGroupRef } from "../ApiToken/Common.ts";
|
|
6
8
|
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
9
|
+
import type { Credentials } from "../Credentials.ts";
|
|
10
|
+
import { authorizeWith } from "../HttpClientUtils.ts";
|
|
7
11
|
import type { Namespace } from "./Namespace.ts";
|
|
8
12
|
import { NamespaceError } from "./NamespaceTypes.ts";
|
|
9
13
|
|
|
@@ -58,6 +62,25 @@ export interface HttpScope {
|
|
|
58
62
|
namespaceId: string;
|
|
59
63
|
}
|
|
60
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Injectable auth for the KV HTTP client builders. Both the scoped-token
|
|
67
|
+
* (`*Http`) and current-credentials (`*Local`) variants supply an `authorize`
|
|
68
|
+
* (which provides `Credentials` + `HttpClient` to a raw SDK op) and an
|
|
69
|
+
* `accountId`, so the client builders are agnostic to how creds are obtained.
|
|
70
|
+
*/
|
|
71
|
+
export interface KVAuth {
|
|
72
|
+
authorize: <A, E>(
|
|
73
|
+
eff: Effect.Effect<A, E, Credentials | HttpClient.HttpClient>,
|
|
74
|
+
) => Effect.Effect<A, E, RuntimeContext>;
|
|
75
|
+
accountId: Effect.Effect<string>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Build a scoped-token {@link KVAuth} from a bound {@link HttpToken}. */
|
|
79
|
+
export const makeKVAuth = (token: HttpToken): KVAuth => ({
|
|
80
|
+
authorize: authorizeWith(token),
|
|
81
|
+
accountId: token.accountId,
|
|
82
|
+
});
|
|
83
|
+
|
|
61
84
|
const KV_HTTP_PERMISSION_GROUPS: PermissionGroupRef[] = [
|
|
62
85
|
"Workers KV Storage Read",
|
|
63
86
|
"Workers KV Storage Write",
|
|
@@ -67,11 +90,11 @@ type PermissionGroup = (typeof KV_HTTP_PERMISSION_GROUPS)[number];
|
|
|
67
90
|
|
|
68
91
|
/** Resolve the account and namespace id once per operation. */
|
|
69
92
|
export const makeKVHttpScope = (
|
|
70
|
-
|
|
93
|
+
auth: KVAuth,
|
|
71
94
|
namespaceId: Effect.Effect<string>,
|
|
72
95
|
): Effect.Effect<HttpScope> =>
|
|
73
96
|
Effect.gen(function* () {
|
|
74
|
-
const accountId = yield*
|
|
97
|
+
const accountId = yield* auth.accountId;
|
|
75
98
|
const id = yield* namespaceId;
|
|
76
99
|
return { accountId, namespaceId: id };
|
|
77
100
|
});
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { Namespace } from "./Namespace.ts";
|
|
6
|
+
import type { KVAuth } from "./NamespaceHttp.ts";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Shared scaffolding for the `*Local` KV services.
|
|
10
|
+
*
|
|
11
|
+
* Instead of minting a scoped {@link AccountApiToken} (the `*Http` path) or
|
|
12
|
+
* resolving a native Worker binding (the `*Binding` path), it captures the
|
|
13
|
+
* ambient current-credentials context available during stack-eval and builds
|
|
14
|
+
* a {@link KVAuth} that provides those credentials directly to the KV HTTP
|
|
15
|
+
* ops. It then delegates to the same client builders the `*Http` variant uses.
|
|
16
|
+
*
|
|
17
|
+
* NOT exported from `index.ts` — this is internal scaffolding shared by the
|
|
18
|
+
* three access-level Local layers.
|
|
19
|
+
*/
|
|
20
|
+
export const makeLocalKVNamespaceBinding = <Client>(options: {
|
|
21
|
+
makeClient: (auth: KVAuth, namespaceId: Effect.Effect<string>) => Client;
|
|
22
|
+
}) =>
|
|
23
|
+
Effect.gen(function* () {
|
|
24
|
+
// Account + credentials are ambient during stack-eval (the stack's
|
|
25
|
+
// providers layer). Capture the full context so KV HTTP ops can run with
|
|
26
|
+
// the current credentials — no `host.bind`, no minted token.
|
|
27
|
+
const { accountId } = yield* yield* CloudflareEnvironment;
|
|
28
|
+
const context = yield* Effect.context<
|
|
29
|
+
Credentials | HttpClient.HttpClient
|
|
30
|
+
>();
|
|
31
|
+
|
|
32
|
+
return Effect.fn(function* (namespace: Namespace) {
|
|
33
|
+
// Deferred accessor — resolves the namespaceId against the tracker at
|
|
34
|
+
// apply time (in an Action, that's the engine's resolve context).
|
|
35
|
+
const namespaceId = yield* namespace.namespaceId;
|
|
36
|
+
const auth: KVAuth = {
|
|
37
|
+
authorize: (eff) => eff.pipe(Effect.provideContext(context)),
|
|
38
|
+
accountId: Effect.succeed(accountId),
|
|
39
|
+
};
|
|
40
|
+
return options.makeClient(auth, namespaceId);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as kv from "@distilled.cloud/cloudflare/kv";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
|
-
import { authorizeWith } from "../HttpClientUtils.ts";
|
|
5
4
|
import {
|
|
6
5
|
makeHttpKVNamespaceBinding,
|
|
6
|
+
makeKVAuth,
|
|
7
7
|
makeKVHttpScope,
|
|
8
8
|
toKVNamespaceError,
|
|
9
|
-
type
|
|
9
|
+
type KVAuth,
|
|
10
10
|
} from "./NamespaceHttp.ts";
|
|
11
11
|
import { ReadNamespace, type ReadNamespaceClient } from "./ReadNamespace.ts";
|
|
12
12
|
|
|
@@ -21,17 +21,18 @@ export const ReadNamespaceHttp = Layer.effect(
|
|
|
21
21
|
Effect.suspend(() =>
|
|
22
22
|
makeHttpKVNamespaceBinding({
|
|
23
23
|
permissionGroups: ["Workers KV Storage Read"],
|
|
24
|
-
makeClient:
|
|
24
|
+
makeClient: (token, namespaceId) =>
|
|
25
|
+
makeReadKVHttpClient(makeKVAuth(token), namespaceId),
|
|
25
26
|
}),
|
|
26
27
|
),
|
|
27
28
|
);
|
|
28
29
|
|
|
29
30
|
export const makeReadKVHttpClient = (
|
|
30
|
-
|
|
31
|
+
auth: KVAuth,
|
|
31
32
|
namespaceId: Effect.Effect<string>,
|
|
32
33
|
): ReadNamespaceClient => {
|
|
33
|
-
const authorize =
|
|
34
|
-
const scope = makeKVHttpScope(
|
|
34
|
+
const { authorize } = auth;
|
|
35
|
+
const scope = makeKVHttpScope(auth, namespaceId);
|
|
35
36
|
|
|
36
37
|
const getOne = (key: string, type: string) =>
|
|
37
38
|
scope.pipe(
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import { makeLocalKVNamespaceBinding } from "./NamespaceLocal.ts";
|
|
4
|
+
import { ReadNamespace } from "./ReadNamespace.ts";
|
|
5
|
+
import { makeReadKVHttpClient } from "./ReadNamespaceHttp.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Local implementation of the {@link ReadNamespace} binding — reads KV values
|
|
9
|
+
* over the Cloudflare HTTP API using the **current credentials** instead of a
|
|
10
|
+
* native Worker binding (`ReadNamespaceBinding`) or a scoped API token
|
|
11
|
+
* (`ReadNamespaceHttp`).
|
|
12
|
+
*
|
|
13
|
+
* Provide it on an {@link Action} (or any deploy-time Effect) so you can read
|
|
14
|
+
* from a namespace with the same `get`/`getWithMetadata`/`list` client you'd
|
|
15
|
+
* use inside a Worker:
|
|
16
|
+
*
|
|
17
|
+
* @example Reading a value from an Action
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const Check = Alchemy.Action(
|
|
20
|
+
* "Check",
|
|
21
|
+
* Effect.gen(function* () {
|
|
22
|
+
* const kv = yield* Cloudflare.KV.ReadNamespace(namespace);
|
|
23
|
+
* return Effect.fn(function* () {
|
|
24
|
+
* return yield* kv.get("my-key");
|
|
25
|
+
* });
|
|
26
|
+
* }).pipe(Effect.provide(Cloudflare.KV.ReadNamespaceLocal)),
|
|
27
|
+
* );
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export const ReadNamespaceLocal = Layer.effect(
|
|
31
|
+
ReadNamespace,
|
|
32
|
+
Effect.suspend(() =>
|
|
33
|
+
makeLocalKVNamespaceBinding({ makeClient: makeReadKVHttpClient }),
|
|
34
|
+
),
|
|
35
|
+
);
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
makeHttpKVNamespaceBinding,
|
|
5
|
+
makeKVAuth,
|
|
6
|
+
type KVAuth,
|
|
7
|
+
} from "./NamespaceHttp.ts";
|
|
4
8
|
import { makeReadKVHttpClient } from "./ReadNamespaceHttp.ts";
|
|
5
9
|
import {
|
|
6
10
|
ReadWriteNamespace,
|
|
@@ -19,17 +23,18 @@ export const ReadWriteNamespaceHttp = Layer.effect(
|
|
|
19
23
|
Effect.suspend(() =>
|
|
20
24
|
makeHttpKVNamespaceBinding({
|
|
21
25
|
permissionGroups: ["Workers KV Storage Read", "Workers KV Storage Write"],
|
|
22
|
-
makeClient:
|
|
26
|
+
makeClient: (token, namespaceId) =>
|
|
27
|
+
makeReadWriteKVHttpClient(makeKVAuth(token), namespaceId),
|
|
23
28
|
}),
|
|
24
29
|
),
|
|
25
30
|
);
|
|
26
31
|
|
|
27
|
-
/** Build the HTTP-backed read-write client over
|
|
32
|
+
/** Build the HTTP-backed read-write client over an auth + namespace. */
|
|
28
33
|
export const makeReadWriteKVHttpClient = (
|
|
29
|
-
|
|
34
|
+
auth: KVAuth,
|
|
30
35
|
namespaceId: Effect.Effect<string>,
|
|
31
36
|
): ReadWriteNamespaceClient =>
|
|
32
37
|
({
|
|
33
|
-
...makeReadKVHttpClient(
|
|
34
|
-
...makeWriteKVHttpClient(
|
|
38
|
+
...makeReadKVHttpClient(auth, namespaceId),
|
|
39
|
+
...makeWriteKVHttpClient(auth, namespaceId),
|
|
35
40
|
}) as ReadWriteNamespaceClient;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import { makeLocalKVNamespaceBinding } from "./NamespaceLocal.ts";
|
|
4
|
+
import { ReadWriteNamespace } from "./ReadWriteNamespace.ts";
|
|
5
|
+
import { makeReadWriteKVHttpClient } from "./ReadWriteNamespaceHttp.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Local implementation of the {@link ReadWriteNamespace} binding — reads and
|
|
9
|
+
* writes KV values over the Cloudflare HTTP API using the **current
|
|
10
|
+
* credentials** instead of a native Worker binding
|
|
11
|
+
* (`ReadWriteNamespaceBinding`) or a scoped API token
|
|
12
|
+
* (`ReadWriteNamespaceHttp`).
|
|
13
|
+
*
|
|
14
|
+
* Provide it on an {@link Action} (or any deploy-time Effect) so you can talk
|
|
15
|
+
* to a namespace with the same `get`/`put`/`list`/`delete` client you'd use
|
|
16
|
+
* inside a Worker:
|
|
17
|
+
*
|
|
18
|
+
* @example Seeding a namespace from an Action
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const Seed = Alchemy.Action(
|
|
21
|
+
* "Seed",
|
|
22
|
+
* Effect.gen(function* () {
|
|
23
|
+
* const kv = yield* Cloudflare.KV.ReadWriteNamespace(namespace);
|
|
24
|
+
* return Effect.fn(function* () {
|
|
25
|
+
* yield* kv.put("greeting", "hello world");
|
|
26
|
+
* return yield* kv.get("greeting");
|
|
27
|
+
* });
|
|
28
|
+
* }).pipe(Effect.provide(Cloudflare.KV.ReadWriteNamespaceLocal)),
|
|
29
|
+
* );
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* The namespace id is resolved at apply time through the ambient
|
|
33
|
+
* {@link RuntimeContext} (in an Action, that's the resolve context the engine
|
|
34
|
+
* provides around the body), so `ReadWriteNamespace(namespace)` works even
|
|
35
|
+
* though the namespace is created in the same deploy.
|
|
36
|
+
*/
|
|
37
|
+
export const ReadWriteNamespaceLocal = Layer.effect(
|
|
38
|
+
ReadWriteNamespace,
|
|
39
|
+
Effect.suspend(() =>
|
|
40
|
+
makeLocalKVNamespaceBinding({ makeClient: makeReadWriteKVHttpClient }),
|
|
41
|
+
),
|
|
42
|
+
);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as kv from "@distilled.cloud/cloudflare/kv";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
|
-
import { authorizeWith } from "../HttpClientUtils.ts";
|
|
5
4
|
import {
|
|
6
5
|
makeHttpKVNamespaceBinding,
|
|
6
|
+
makeKVAuth,
|
|
7
7
|
makeKVHttpScope,
|
|
8
8
|
toKVNamespaceError,
|
|
9
|
-
type
|
|
9
|
+
type KVAuth,
|
|
10
10
|
} from "./NamespaceHttp.ts";
|
|
11
11
|
import { NamespaceError } from "./NamespaceTypes.ts";
|
|
12
12
|
import { WriteNamespace, type WriteNamespaceClient } from "./WriteNamespace.ts";
|
|
@@ -22,17 +22,18 @@ export const WriteNamespaceHttp = Layer.effect(
|
|
|
22
22
|
Effect.suspend(() =>
|
|
23
23
|
makeHttpKVNamespaceBinding({
|
|
24
24
|
permissionGroups: ["Workers KV Storage Write"],
|
|
25
|
-
makeClient:
|
|
25
|
+
makeClient: (token, namespaceId) =>
|
|
26
|
+
makeWriteKVHttpClient(makeKVAuth(token), namespaceId),
|
|
26
27
|
}),
|
|
27
28
|
),
|
|
28
29
|
);
|
|
29
30
|
|
|
30
31
|
export const makeWriteKVHttpClient = (
|
|
31
|
-
|
|
32
|
+
auth: KVAuth,
|
|
32
33
|
namespaceId: Effect.Effect<string>,
|
|
33
34
|
): WriteNamespaceClient => {
|
|
34
|
-
const authorize =
|
|
35
|
-
const scope = makeKVHttpScope(
|
|
35
|
+
const { authorize } = auth;
|
|
36
|
+
const scope = makeKVHttpScope(auth, namespaceId);
|
|
36
37
|
|
|
37
38
|
return {
|
|
38
39
|
put: ((
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Layer from "effect/Layer";
|
|
3
|
+
import { makeLocalKVNamespaceBinding } from "./NamespaceLocal.ts";
|
|
4
|
+
import { WriteNamespace } from "./WriteNamespace.ts";
|
|
5
|
+
import { makeWriteKVHttpClient } from "./WriteNamespaceHttp.ts";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Local implementation of the {@link WriteNamespace} binding — writes KV
|
|
9
|
+
* values over the Cloudflare HTTP API using the **current credentials**
|
|
10
|
+
* instead of a native Worker binding (`WriteNamespaceBinding`) or a scoped API
|
|
11
|
+
* token (`WriteNamespaceHttp`).
|
|
12
|
+
*
|
|
13
|
+
* Provide it on an {@link Action} (or any deploy-time Effect) so you can write
|
|
14
|
+
* to a namespace with the same `put`/`delete` client you'd use inside a
|
|
15
|
+
* Worker:
|
|
16
|
+
*
|
|
17
|
+
* @example Writing a value from an Action
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const Seed = Alchemy.Action(
|
|
20
|
+
* "Seed",
|
|
21
|
+
* Effect.gen(function* () {
|
|
22
|
+
* const kv = yield* Cloudflare.KV.WriteNamespace(namespace);
|
|
23
|
+
* return Effect.fn(function* () {
|
|
24
|
+
* yield* kv.put("my-key", "hello world");
|
|
25
|
+
* });
|
|
26
|
+
* }).pipe(Effect.provide(Cloudflare.KV.WriteNamespaceLocal)),
|
|
27
|
+
* );
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export const WriteNamespaceLocal = Layer.effect(
|
|
31
|
+
WriteNamespace,
|
|
32
|
+
Effect.suspend(() =>
|
|
33
|
+
makeLocalKVNamespaceBinding({ makeClient: makeWriteKVHttpClient }),
|
|
34
|
+
),
|
|
35
|
+
);
|
|
@@ -3,9 +3,12 @@ export * from "./NamespaceTypes.ts";
|
|
|
3
3
|
export * from "./ReadNamespace.ts";
|
|
4
4
|
export * from "./ReadNamespaceBinding.ts";
|
|
5
5
|
export * from "./ReadNamespaceHttp.ts";
|
|
6
|
+
export * from "./ReadNamespaceLocal.ts";
|
|
6
7
|
export * from "./ReadWriteNamespace.ts";
|
|
7
8
|
export * from "./ReadWriteNamespaceBinding.ts";
|
|
8
9
|
export * from "./ReadWriteNamespaceHttp.ts";
|
|
10
|
+
export * from "./ReadWriteNamespaceLocal.ts";
|
|
9
11
|
export * from "./WriteNamespace.ts";
|
|
10
12
|
export * from "./WriteNamespaceBinding.ts";
|
|
11
13
|
export * from "./WriteNamespaceHttp.ts";
|
|
14
|
+
export * from "./WriteNamespaceLocal.ts";
|
|
@@ -1,12 +1,34 @@
|
|
|
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 { Self } from "../../Self.ts";
|
|
4
6
|
import { AccountApiToken } from "../ApiToken/AccountApiToken.ts";
|
|
5
7
|
import type { PermissionGroupRef } from "../ApiToken/Common.ts";
|
|
6
8
|
import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
|
|
9
|
+
import type { Credentials } from "../Credentials.ts";
|
|
7
10
|
import type { Queue } from "./Queue.ts";
|
|
8
11
|
import { SendError } from "./QueueTypes.ts";
|
|
9
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Injectable auth used by the Queue HTTP client builder. Both the
|
|
15
|
+
* scoped-token HTTP variant ({@link makeWriteQueueHttpClient}) and the
|
|
16
|
+
* current-credentials Local variant build this so they share the exact
|
|
17
|
+
* same request path — only the way credentials reach the SDK op differs.
|
|
18
|
+
*
|
|
19
|
+
* - `authorize` runs a raw distilled op (which needs
|
|
20
|
+
* `Credentials | HttpClient`) and discharges those requirements down to
|
|
21
|
+
* {@link RuntimeContext}. The HTTP variant provides a minted token; the
|
|
22
|
+
* Local variant provides the ambient current-credentials context.
|
|
23
|
+
* - `accountId` resolves the Cloudflare account the queue lives in.
|
|
24
|
+
*/
|
|
25
|
+
export interface QueueAuth {
|
|
26
|
+
authorize: <A, E>(
|
|
27
|
+
eff: Effect.Effect<A, E, Credentials | HttpClient.HttpClient>,
|
|
28
|
+
) => Effect.Effect<A, E, RuntimeContext>;
|
|
29
|
+
accountId: Effect.Effect<string>;
|
|
30
|
+
}
|
|
31
|
+
|
|
10
32
|
/**
|
|
11
33
|
* Shared scaffolding for the HTTP-backed Queue services.
|
|
12
34
|
*
|
|
@@ -50,11 +72,11 @@ export const makeHttpQueueBinding = <Client>(options: {
|
|
|
50
72
|
|
|
51
73
|
/** Resolve the account and queue id once per operation. */
|
|
52
74
|
export const makeQueueHttpScope = (
|
|
53
|
-
|
|
75
|
+
auth: QueueAuth,
|
|
54
76
|
queueId: Effect.Effect<string>,
|
|
55
77
|
): Effect.Effect<HttpScope> =>
|
|
56
78
|
Effect.gen(function* () {
|
|
57
|
-
const accountId = yield*
|
|
79
|
+
const accountId = yield* auth.accountId;
|
|
58
80
|
const id = yield* queueId;
|
|
59
81
|
return { accountId, queueId: id };
|
|
60
82
|
});
|