alchemy 2.0.0-beta.46 → 2.0.0-beta.48

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.
Files changed (295) hide show
  1. package/bin/exec.js +18 -10
  2. package/bin/exec.js.map +1 -1
  3. package/lib/AWS/Lambda/BucketEventSource.d.ts +1 -1
  4. package/lib/AWS/Lambda/BucketEventSource.d.ts.map +1 -1
  5. package/lib/AWS/Lambda/EventBridgeEventSource.d.ts +1 -1
  6. package/lib/AWS/Lambda/EventBridgeEventSource.d.ts.map +1 -1
  7. package/lib/AWS/Lambda/QueueEventSource.d.ts +1 -1
  8. package/lib/AWS/Lambda/QueueEventSource.d.ts.map +1 -1
  9. package/lib/AWS/Lambda/StreamEventSource.d.ts +1 -1
  10. package/lib/AWS/Lambda/StreamEventSource.d.ts.map +1 -1
  11. package/lib/AWS/Lambda/TableEventSource.d.ts +1 -1
  12. package/lib/AWS/Lambda/TableEventSource.d.ts.map +1 -1
  13. package/lib/AWS/Lambda/TopicEventSource.d.ts +1 -1
  14. package/lib/AWS/Lambda/TopicEventSource.d.ts.map +1 -1
  15. package/lib/Apply.js +2 -2
  16. package/lib/Apply.js.map +1 -1
  17. package/lib/Cli/commands/_shared.d.ts +7 -1
  18. package/lib/Cli/commands/_shared.d.ts.map +1 -1
  19. package/lib/Cli/commands/_shared.js +1 -0
  20. package/lib/Cli/commands/_shared.js.map +1 -1
  21. package/lib/Cli/commands/cloudflare.d.ts +4 -1
  22. package/lib/Cli/commands/cloudflare.d.ts.map +1 -1
  23. package/lib/Cli/commands/cloudflare.js +274 -1
  24. package/lib/Cli/commands/cloudflare.js.map +1 -1
  25. package/lib/Cli/commands/login.d.ts +1 -1
  26. package/lib/Cli/commands/login.d.ts.map +1 -1
  27. package/lib/Cli/commands/login.js +45 -42
  28. package/lib/Cli/commands/login.js.map +1 -1
  29. package/lib/Cli/commands/logs.js +1 -1
  30. package/lib/Cli/commands/logs.js.map +1 -1
  31. package/lib/Cli/commands/state.js +1 -1
  32. package/lib/Cli/commands/state.js.map +1 -1
  33. package/lib/Cli/commands/tail.js +1 -1
  34. package/lib/Cli/commands/tail.js.map +1 -1
  35. package/lib/Cloudflare/AiGateway/AiGateway.d.ts +112 -1
  36. package/lib/Cloudflare/AiGateway/AiGateway.d.ts.map +1 -1
  37. package/lib/Cloudflare/AiGateway/AiGateway.js +114 -2
  38. package/lib/Cloudflare/AiGateway/AiGateway.js.map +1 -1
  39. package/lib/Cloudflare/AiGateway/AiGatewayBinding.d.ts +43 -10
  40. package/lib/Cloudflare/AiGateway/AiGatewayBinding.d.ts.map +1 -1
  41. package/lib/Cloudflare/AiGateway/AiGatewayBinding.js +38 -10
  42. package/lib/Cloudflare/AiGateway/AiGatewayBinding.js.map +1 -1
  43. package/lib/Cloudflare/AiGateway/LanguageModel.d.ts +35 -0
  44. package/lib/Cloudflare/AiGateway/LanguageModel.d.ts.map +1 -0
  45. package/lib/Cloudflare/AiGateway/LanguageModel.js +576 -0
  46. package/lib/Cloudflare/AiGateway/LanguageModel.js.map +1 -0
  47. package/lib/Cloudflare/AiGateway/index.d.ts +1 -0
  48. package/lib/Cloudflare/AiGateway/index.d.ts.map +1 -1
  49. package/lib/Cloudflare/AiGateway/index.js +1 -0
  50. package/lib/Cloudflare/AiGateway/index.js.map +1 -1
  51. package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts +40 -2
  52. package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts.map +1 -1
  53. package/lib/Cloudflare/ApiToken/AccountApiToken.js +49 -6
  54. package/lib/Cloudflare/ApiToken/AccountApiToken.js.map +1 -1
  55. package/lib/Cloudflare/ApiToken/Common.d.ts +26 -3
  56. package/lib/Cloudflare/ApiToken/Common.d.ts.map +1 -1
  57. package/lib/Cloudflare/ApiToken/Common.js +8 -0
  58. package/lib/Cloudflare/ApiToken/Common.js.map +1 -1
  59. package/lib/Cloudflare/ApiToken/UserApiToken.d.ts +38 -2
  60. package/lib/Cloudflare/ApiToken/UserApiToken.d.ts.map +1 -1
  61. package/lib/Cloudflare/ApiToken/UserApiToken.js +47 -6
  62. package/lib/Cloudflare/ApiToken/UserApiToken.js.map +1 -1
  63. package/lib/Cloudflare/Browser/Browser.d.ts +121 -0
  64. package/lib/Cloudflare/Browser/Browser.d.ts.map +1 -0
  65. package/lib/Cloudflare/{BrowserRendering/BrowserRendering.js → Browser/Browser.js} +19 -26
  66. package/lib/Cloudflare/Browser/Browser.js.map +1 -0
  67. package/lib/Cloudflare/Browser/BrowserBinding.d.ts +55 -0
  68. package/lib/Cloudflare/Browser/BrowserBinding.d.ts.map +1 -0
  69. package/lib/Cloudflare/{BrowserRendering/BrowserRenderingBinding.js → Browser/BrowserBinding.js} +11 -11
  70. package/lib/Cloudflare/Browser/BrowserBinding.js.map +1 -0
  71. package/lib/Cloudflare/Browser/index.d.ts +3 -0
  72. package/lib/Cloudflare/Browser/index.d.ts.map +1 -0
  73. package/lib/Cloudflare/Browser/index.js +3 -0
  74. package/lib/Cloudflare/Browser/index.js.map +1 -0
  75. package/lib/Cloudflare/Container/ContainerBinding.d.ts +2 -1
  76. package/lib/Cloudflare/Container/ContainerBinding.d.ts.map +1 -1
  77. package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
  78. package/lib/Cloudflare/D1/D1Database.js +2 -1
  79. package/lib/Cloudflare/D1/D1Database.js.map +1 -1
  80. package/lib/Cloudflare/Email/EmailRouting.d.ts +1 -1
  81. package/lib/Cloudflare/Email/EmailRouting.d.ts.map +1 -1
  82. package/lib/Cloudflare/Email/EmailRouting.js +1 -1
  83. package/lib/Cloudflare/Email/EmailRouting.js.map +1 -1
  84. package/lib/Cloudflare/Email/EmailRule.d.ts +1 -1
  85. package/lib/Cloudflare/Email/EmailRule.d.ts.map +1 -1
  86. package/lib/Cloudflare/Email/EmailRule.js +1 -1
  87. package/lib/Cloudflare/Email/EmailRule.js.map +1 -1
  88. package/lib/Cloudflare/Images/Images.d.ts +32 -23
  89. package/lib/Cloudflare/Images/Images.d.ts.map +1 -1
  90. package/lib/Cloudflare/Images/Images.js +10 -13
  91. package/lib/Cloudflare/Images/Images.js.map +1 -1
  92. package/lib/Cloudflare/Providers.d.ts.map +1 -1
  93. package/lib/Cloudflare/Providers.js +10 -3
  94. package/lib/Cloudflare/Providers.js.map +1 -1
  95. package/lib/Cloudflare/R2/R2Bucket.d.ts +1 -1
  96. package/lib/Cloudflare/R2/R2Bucket.d.ts.map +1 -1
  97. package/lib/Cloudflare/R2/R2Bucket.js +13 -7
  98. package/lib/Cloudflare/R2/R2Bucket.js.map +1 -1
  99. package/lib/Cloudflare/RateLimit/RateLimit.d.ts +132 -0
  100. package/lib/Cloudflare/RateLimit/RateLimit.d.ts.map +1 -0
  101. package/lib/Cloudflare/RateLimit/RateLimit.js +80 -0
  102. package/lib/Cloudflare/RateLimit/RateLimit.js.map +1 -0
  103. package/lib/Cloudflare/RateLimit/RateLimitBinding.d.ts +30 -0
  104. package/lib/Cloudflare/RateLimit/RateLimitBinding.d.ts.map +1 -0
  105. package/lib/Cloudflare/RateLimit/RateLimitBinding.js +50 -0
  106. package/lib/Cloudflare/RateLimit/RateLimitBinding.js.map +1 -0
  107. package/lib/Cloudflare/RateLimit/index.d.ts +3 -0
  108. package/lib/Cloudflare/RateLimit/index.d.ts.map +1 -0
  109. package/lib/Cloudflare/RateLimit/index.js +3 -0
  110. package/lib/Cloudflare/RateLimit/index.js.map +1 -0
  111. package/lib/Cloudflare/SecretsStore/Secret.d.ts +2 -1
  112. package/lib/Cloudflare/SecretsStore/Secret.d.ts.map +1 -1
  113. package/lib/Cloudflare/SecretsStore/Secret.js +7 -4
  114. package/lib/Cloudflare/SecretsStore/Secret.js.map +1 -1
  115. package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
  116. package/lib/Cloudflare/StateStore/State.js +82 -78
  117. package/lib/Cloudflare/StateStore/State.js.map +1 -1
  118. package/lib/Cloudflare/Tunnel/Tunnel.d.ts +27 -0
  119. package/lib/Cloudflare/Tunnel/Tunnel.d.ts.map +1 -1
  120. package/lib/Cloudflare/Tunnel/Tunnel.js +27 -0
  121. package/lib/Cloudflare/Tunnel/Tunnel.js.map +1 -1
  122. package/lib/Cloudflare/Tunnel/TunnelBinding.d.ts +48 -0
  123. package/lib/Cloudflare/Tunnel/TunnelBinding.d.ts.map +1 -0
  124. package/lib/Cloudflare/Tunnel/TunnelBinding.js +56 -0
  125. package/lib/Cloudflare/Tunnel/TunnelBinding.js.map +1 -0
  126. package/lib/Cloudflare/Tunnel/TunnelRead.d.ts +83 -0
  127. package/lib/Cloudflare/Tunnel/TunnelRead.d.ts.map +1 -0
  128. package/lib/Cloudflare/Tunnel/TunnelRead.js +79 -0
  129. package/lib/Cloudflare/Tunnel/TunnelRead.js.map +1 -0
  130. package/lib/Cloudflare/Tunnel/TunnelReadWrite.d.ts +70 -0
  131. package/lib/Cloudflare/Tunnel/TunnelReadWrite.d.ts.map +1 -0
  132. package/lib/Cloudflare/Tunnel/TunnelReadWrite.js +63 -0
  133. package/lib/Cloudflare/Tunnel/TunnelReadWrite.js.map +1 -0
  134. package/lib/Cloudflare/Tunnel/TunnelWrite.d.ts +92 -0
  135. package/lib/Cloudflare/Tunnel/TunnelWrite.d.ts.map +1 -0
  136. package/lib/Cloudflare/Tunnel/TunnelWrite.js +88 -0
  137. package/lib/Cloudflare/Tunnel/TunnelWrite.js.map +1 -0
  138. package/lib/Cloudflare/Tunnel/index.d.ts +4 -0
  139. package/lib/Cloudflare/Tunnel/index.d.ts.map +1 -1
  140. package/lib/Cloudflare/Tunnel/index.js +4 -0
  141. package/lib/Cloudflare/Tunnel/index.js.map +1 -1
  142. package/lib/Cloudflare/Vectorize/VectorizeIndex.js +1 -0
  143. package/lib/Cloudflare/Vectorize/VectorizeIndex.js.map +1 -1
  144. package/lib/Cloudflare/VpcService/VpcService.d.ts +1 -1
  145. package/lib/Cloudflare/VpcService/VpcService.d.ts.map +1 -1
  146. package/lib/Cloudflare/VpcService/VpcService.js.map +1 -1
  147. package/lib/Cloudflare/Workers/DurableObjectBridge.d.ts.map +1 -1
  148. package/lib/Cloudflare/Workers/DurableObjectBridge.js +10 -1
  149. package/lib/Cloudflare/Workers/DurableObjectBridge.js.map +1 -1
  150. package/lib/Cloudflare/Workers/DynamicWorkerLoader.d.ts +119 -11
  151. package/lib/Cloudflare/Workers/DynamicWorkerLoader.d.ts.map +1 -1
  152. package/lib/Cloudflare/Workers/DynamicWorkerLoader.js +88 -9
  153. package/lib/Cloudflare/Workers/DynamicWorkerLoader.js.map +1 -1
  154. package/lib/Cloudflare/Workers/InferEnv.d.ts +1 -1
  155. package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
  156. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
  157. package/lib/Cloudflare/Workers/LocalWorkerProvider.js +15 -1
  158. package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
  159. package/lib/Cloudflare/Workers/Rpc.d.ts.map +1 -1
  160. package/lib/Cloudflare/Workers/Rpc.js +20 -2
  161. package/lib/Cloudflare/Workers/Rpc.js.map +1 -1
  162. package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts.map +1 -1
  163. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js +18 -2
  164. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
  165. package/lib/Cloudflare/Workers/WorkerBinding.d.ts +5 -3
  166. package/lib/Cloudflare/Workers/WorkerBinding.d.ts.map +1 -1
  167. package/lib/Cloudflare/Workers/WorkerBinding.js +1 -1
  168. package/lib/Cloudflare/Workers/WorkerBinding.js.map +1 -1
  169. package/lib/Cloudflare/Workers/WorkerBridge.d.ts.map +1 -1
  170. package/lib/Cloudflare/Workers/WorkerBridge.js +20 -2
  171. package/lib/Cloudflare/Workers/WorkerBridge.js.map +1 -1
  172. package/lib/Cloudflare/Zaraz/ZarazConfig.d.ts +1 -1
  173. package/lib/Cloudflare/Zaraz/ZarazConfig.d.ts.map +1 -1
  174. package/lib/Cloudflare/Zaraz/ZarazConfig.js +1 -1
  175. package/lib/Cloudflare/Zaraz/ZarazConfig.js.map +1 -1
  176. package/lib/Cloudflare/Zone/Zone.d.ts +170 -0
  177. package/lib/Cloudflare/Zone/Zone.d.ts.map +1 -0
  178. package/lib/Cloudflare/Zone/Zone.js +180 -0
  179. package/lib/Cloudflare/Zone/Zone.js.map +1 -0
  180. package/lib/Cloudflare/Zone/index.d.ts +3 -0
  181. package/lib/Cloudflare/Zone/index.d.ts.map +1 -0
  182. package/lib/Cloudflare/Zone/index.js +3 -0
  183. package/lib/Cloudflare/Zone/index.js.map +1 -0
  184. package/lib/Cloudflare/Zone/lookup.d.ts +33 -0
  185. package/lib/Cloudflare/Zone/lookup.d.ts.map +1 -0
  186. package/lib/Cloudflare/{Zone.js → Zone/lookup.js} +2 -2
  187. package/lib/Cloudflare/Zone/lookup.js.map +1 -0
  188. package/lib/Cloudflare/index.d.ts +3 -1
  189. package/lib/Cloudflare/index.d.ts.map +1 -1
  190. package/lib/Cloudflare/index.js +3 -1
  191. package/lib/Cloudflare/index.js.map +1 -1
  192. package/lib/Output.js +2 -2
  193. package/lib/Output.js.map +1 -1
  194. package/lib/Plan.d.ts +2 -2
  195. package/lib/Plan.d.ts.map +1 -1
  196. package/lib/Plan.js +3 -3
  197. package/lib/Plan.js.map +1 -1
  198. package/lib/Platform.d.ts +5 -5
  199. package/lib/Platform.d.ts.map +1 -1
  200. package/lib/Platform.js.map +1 -1
  201. package/lib/RemovalPolicy.js +2 -2
  202. package/lib/RemovalPolicy.js.map +1 -1
  203. package/lib/Resource.d.ts +14 -1
  204. package/lib/Resource.d.ts.map +1 -1
  205. package/lib/Resource.js +3 -2
  206. package/lib/Resource.js.map +1 -1
  207. package/lib/Stack.d.ts.map +1 -1
  208. package/lib/Stack.js +6 -0
  209. package/lib/Stack.js.map +1 -1
  210. package/lib/State/InMemoryState.d.ts +2 -1
  211. package/lib/State/InMemoryState.d.ts.map +1 -1
  212. package/lib/State/InMemoryState.js +3 -3
  213. package/lib/State/InMemoryState.js.map +1 -1
  214. package/lib/State/LocalState.d.ts.map +1 -1
  215. package/lib/State/LocalState.js +5 -1
  216. package/lib/State/LocalState.js.map +1 -1
  217. package/lib/State/State.d.ts +2 -2
  218. package/lib/State/State.d.ts.map +1 -1
  219. package/lib/State/State.js.map +1 -1
  220. package/lib/tsconfig.test.tsbuildinfo +1 -1
  221. package/package.json +7 -7
  222. package/src/Apply.ts +2 -2
  223. package/src/Cli/commands/_shared.ts +7 -1
  224. package/src/Cli/commands/cloudflare.ts +394 -1
  225. package/src/Cli/commands/login.ts +69 -60
  226. package/src/Cli/commands/logs.ts +1 -1
  227. package/src/Cli/commands/state.ts +1 -1
  228. package/src/Cli/commands/tail.ts +1 -1
  229. package/src/Cloudflare/AiGateway/AiGateway.ts +114 -2
  230. package/src/Cloudflare/AiGateway/AiGatewayBinding.ts +52 -10
  231. package/src/Cloudflare/AiGateway/LanguageModel.ts +907 -0
  232. package/src/Cloudflare/AiGateway/index.ts +1 -0
  233. package/src/Cloudflare/ApiToken/AccountApiToken.ts +60 -7
  234. package/src/Cloudflare/ApiToken/Common.ts +32 -3
  235. package/src/Cloudflare/ApiToken/UserApiToken.ts +58 -7
  236. package/src/Cloudflare/Browser/Browser.ts +140 -0
  237. package/src/Cloudflare/Browser/BrowserBinding.ts +128 -0
  238. package/src/Cloudflare/Browser/index.ts +11 -0
  239. package/src/Cloudflare/D1/D1Database.ts +6 -2
  240. package/src/Cloudflare/Email/EmailRouting.ts +1 -1
  241. package/src/Cloudflare/Email/EmailRule.ts +6 -6
  242. package/src/Cloudflare/Images/Images.ts +40 -27
  243. package/src/Cloudflare/Providers.ts +15 -3
  244. package/src/Cloudflare/R2/R2Bucket.ts +17 -9
  245. package/src/Cloudflare/RateLimit/RateLimit.ts +160 -0
  246. package/src/Cloudflare/RateLimit/RateLimitBinding.ts +90 -0
  247. package/src/Cloudflare/RateLimit/index.ts +2 -0
  248. package/src/Cloudflare/SecretsStore/Secret.ts +12 -6
  249. package/src/Cloudflare/StateStore/State.ts +113 -107
  250. package/src/Cloudflare/Tunnel/Tunnel.ts +27 -0
  251. package/src/Cloudflare/Tunnel/TunnelBinding.ts +114 -0
  252. package/src/Cloudflare/Tunnel/TunnelRead.ts +168 -0
  253. package/src/Cloudflare/Tunnel/TunnelReadWrite.ts +88 -0
  254. package/src/Cloudflare/Tunnel/TunnelWrite.ts +194 -0
  255. package/src/Cloudflare/Tunnel/index.ts +4 -0
  256. package/src/Cloudflare/Vectorize/VectorizeIndex.ts +2 -1
  257. package/src/Cloudflare/VpcService/VpcService.ts +4 -2
  258. package/src/Cloudflare/Workers/DurableObjectBridge.ts +10 -1
  259. package/src/Cloudflare/Workers/DynamicWorkerLoader.ts +139 -13
  260. package/src/Cloudflare/Workers/InferEnv.ts +19 -15
  261. package/src/Cloudflare/Workers/LocalWorkerProvider.ts +26 -3
  262. package/src/Cloudflare/Workers/Rpc.ts +38 -9
  263. package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +16 -2
  264. package/src/Cloudflare/Workers/WorkerBinding.ts +6 -2
  265. package/src/Cloudflare/Workers/WorkerBridge.ts +20 -2
  266. package/src/Cloudflare/Zaraz/ZarazConfig.ts +1 -1
  267. package/src/Cloudflare/Zone/Zone.ts +349 -0
  268. package/src/Cloudflare/Zone/index.ts +2 -0
  269. package/src/Cloudflare/{Zone.ts → Zone/lookup.ts} +16 -3
  270. package/src/Cloudflare/index.ts +3 -1
  271. package/src/Output.ts +2 -2
  272. package/src/Plan.ts +4 -4
  273. package/src/Platform.ts +8 -12
  274. package/src/RemovalPolicy.ts +2 -2
  275. package/src/Resource.ts +18 -1
  276. package/src/Stack.ts +6 -0
  277. package/src/State/InMemoryState.ts +87 -85
  278. package/src/State/LocalState.ts +15 -1
  279. package/src/State/State.ts +5 -4
  280. package/lib/Cloudflare/BrowserRendering/BrowserRendering.d.ts +0 -116
  281. package/lib/Cloudflare/BrowserRendering/BrowserRendering.d.ts.map +0 -1
  282. package/lib/Cloudflare/BrowserRendering/BrowserRendering.js.map +0 -1
  283. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.d.ts +0 -55
  284. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.d.ts.map +0 -1
  285. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.js.map +0 -1
  286. package/lib/Cloudflare/BrowserRendering/index.d.ts +0 -3
  287. package/lib/Cloudflare/BrowserRendering/index.d.ts.map +0 -1
  288. package/lib/Cloudflare/BrowserRendering/index.js +0 -3
  289. package/lib/Cloudflare/BrowserRendering/index.js.map +0 -1
  290. package/lib/Cloudflare/Zone.d.ts +0 -14
  291. package/lib/Cloudflare/Zone.d.ts.map +0 -1
  292. package/lib/Cloudflare/Zone.js.map +0 -1
  293. package/src/Cloudflare/BrowserRendering/BrowserRendering.ts +0 -132
  294. package/src/Cloudflare/BrowserRendering/BrowserRenderingBinding.ts +0 -137
  295. package/src/Cloudflare/BrowserRendering/index.ts +0 -11
@@ -0,0 +1,194 @@
1
+ import type {
2
+ CreateTunnelCloudflaredError,
3
+ CreateTunnelCloudflaredRequest,
4
+ CreateTunnelCloudflaredResponse,
5
+ DeleteTunnelCloudflaredError,
6
+ DeleteTunnelCloudflaredResponse,
7
+ PatchTunnelCloudflaredError,
8
+ PatchTunnelCloudflaredRequest,
9
+ PatchTunnelCloudflaredResponse,
10
+ PutTunnelCloudflaredConfigurationError,
11
+ PutTunnelCloudflaredConfigurationRequest,
12
+ PutTunnelCloudflaredConfigurationResponse,
13
+ } from "@distilled.cloud/cloudflare/zero-trust";
14
+ import * as zeroTrust from "@distilled.cloud/cloudflare/zero-trust";
15
+ import * as Effect from "effect/Effect";
16
+ import * as Layer from "effect/Layer";
17
+ import * as Binding from "../../Binding.ts";
18
+ import type { RuntimeContext } from "../../RuntimeContext.ts";
19
+ import type { AccountApiToken } from "../ApiToken/AccountApiToken.ts";
20
+ import type { Worker } from "../Workers/Worker.ts";
21
+ import {
22
+ authorizeWith,
23
+ makeTunnelClient,
24
+ makeTunnelPolicyLive,
25
+ type TunnelToken,
26
+ } from "./TunnelBinding.ts";
27
+
28
+ /** Create-tunnel request, minus the account id (supplied by the binding). */
29
+ export type CreateTunnelRequest = Omit<
30
+ CreateTunnelCloudflaredRequest,
31
+ "accountId"
32
+ >;
33
+
34
+ /** Update-tunnel request, minus the account id and tunnel id (positional). */
35
+ export type UpdateTunnelRequest = Omit<
36
+ PatchTunnelCloudflaredRequest,
37
+ "accountId" | "tunnelId"
38
+ >;
39
+
40
+ /** Tunnel configuration body, minus the account id and tunnel id (positional). */
41
+ export type TunnelConfiguration = NonNullable<
42
+ PutTunnelCloudflaredConfigurationRequest["config"]
43
+ >;
44
+
45
+ /**
46
+ * Mutating tunnel operations. Backed by the `Cloudflare Tunnel Write`
47
+ * permission group.
48
+ */
49
+ export interface TunnelWriteClient {
50
+ /** Create a new tunnel. */
51
+ create(
52
+ request: CreateTunnelRequest,
53
+ ): Effect.Effect<
54
+ CreateTunnelCloudflaredResponse,
55
+ CreateTunnelCloudflaredError,
56
+ RuntimeContext
57
+ >;
58
+ /** Update a tunnel's mutable fields (name, secret). */
59
+ update(
60
+ tunnelId: string,
61
+ request: UpdateTunnelRequest,
62
+ ): Effect.Effect<
63
+ PatchTunnelCloudflaredResponse,
64
+ PatchTunnelCloudflaredError,
65
+ RuntimeContext
66
+ >;
67
+ /** Delete a tunnel by id. */
68
+ delete(
69
+ tunnelId: string,
70
+ ): Effect.Effect<
71
+ DeleteTunnelCloudflaredResponse,
72
+ DeleteTunnelCloudflaredError,
73
+ RuntimeContext
74
+ >;
75
+ /** Replace the remotely-managed configuration (ingress rules) for a tunnel. */
76
+ putConfiguration(
77
+ tunnelId: string,
78
+ config: TunnelConfiguration,
79
+ ): Effect.Effect<
80
+ PutTunnelCloudflaredConfigurationResponse,
81
+ PutTunnelCloudflaredConfigurationError,
82
+ RuntimeContext
83
+ >;
84
+ }
85
+
86
+ /** Build the write client over a bound token. */
87
+ export const writeClient = (token: TunnelToken): TunnelWriteClient => {
88
+ const authorize = authorizeWith(token);
89
+ return {
90
+ create: Effect.fn("Cloudflare.Tunnel.create")(function* (request) {
91
+ const accountId = yield* token.accountId;
92
+ return yield* authorize(
93
+ zeroTrust.createTunnelCloudflared({ accountId, ...request }),
94
+ );
95
+ }),
96
+ update: Effect.fn("Cloudflare.Tunnel.update")(
97
+ function* (tunnelId, request) {
98
+ const accountId = yield* token.accountId;
99
+ return yield* authorize(
100
+ zeroTrust.patchTunnelCloudflared({ accountId, tunnelId, ...request }),
101
+ );
102
+ },
103
+ ),
104
+ delete: Effect.fn("Cloudflare.Tunnel.delete")(function* (tunnelId) {
105
+ const accountId = yield* token.accountId;
106
+ return yield* authorize(
107
+ zeroTrust.deleteTunnelCloudflared({ accountId, tunnelId }),
108
+ );
109
+ }),
110
+ putConfiguration: Effect.fn("Cloudflare.Tunnel.putConfiguration")(
111
+ function* (tunnelId, config) {
112
+ const accountId = yield* token.accountId;
113
+ return yield* authorize(
114
+ zeroTrust.putTunnelCloudflaredConfiguration({
115
+ accountId,
116
+ tunnelId,
117
+ config,
118
+ }),
119
+ );
120
+ },
121
+ ),
122
+ };
123
+ };
124
+
125
+ /**
126
+ * Binding that lets a Worker create, update, and delete Cloudflare Tunnels at
127
+ * runtime.
128
+ *
129
+ * Creates a scoped {@link AccountApiToken} with only the `Cloudflare Tunnel
130
+ * Write` permission and binds its outputs into the Worker (the token value as a
131
+ * `secret_text` binding) so runtime code can authenticate.
132
+ *
133
+ * @binding
134
+ *
135
+ * @section Mutating tunnels at runtime
136
+ * @example Bind the write client
137
+ * Bind once in the Init phase; every method is available on the returned client.
138
+ * ```typescript
139
+ * const tunnels = yield* Cloudflare.TunnelWrite.bind();
140
+ * ```
141
+ *
142
+ * @example Create a tunnel
143
+ * ```typescript
144
+ * const tunnel = yield* tunnels.create({ name: "on-demand-tunnel" });
145
+ * ```
146
+ *
147
+ * @example Push ingress configuration
148
+ * ```typescript
149
+ * yield* tunnels.putConfiguration(tunnel.id!, {
150
+ * ingress: [
151
+ * { hostname: "app.example.com", service: "http://localhost:3000" },
152
+ * { service: "http_status:404" },
153
+ * ],
154
+ * });
155
+ * ```
156
+ *
157
+ * @example Rename and delete a tunnel
158
+ * ```typescript
159
+ * yield* tunnels.update(tunnel.id!, { name: "renamed-tunnel" });
160
+ * yield* tunnels.delete(tunnel.id!);
161
+ * ```
162
+ *
163
+ * @section Runtime Layer
164
+ * Provide {@link TunnelWriteLive} in the Worker's runtime layer.
165
+ * ```typescript
166
+ * Effect.provide(Cloudflare.TunnelWriteLive)
167
+ * ```
168
+ */
169
+ export class TunnelWrite extends Binding.Service<
170
+ TunnelWrite,
171
+ () => Effect.Effect<TunnelWriteClient, never, Worker>
172
+ >()("Cloudflare.TunnelWrite") {}
173
+
174
+ /**
175
+ * Deploy-time policy for {@link TunnelWrite}. Attaches the `Cloudflare Tunnel
176
+ * Write` permission to the token via its binding contract.
177
+ */
178
+ export class TunnelWritePolicy extends Binding.Policy<
179
+ TunnelWritePolicy,
180
+ (token: AccountApiToken) => Effect.Effect<void>
181
+ >()("Cloudflare.TunnelWrite") {}
182
+
183
+ /** Runtime layer for {@link TunnelWrite}. */
184
+ export const TunnelWriteLive = Layer.effect(
185
+ TunnelWrite,
186
+ makeTunnelClient(TunnelWritePolicy, writeClient),
187
+ );
188
+
189
+ /** Live deploy-time policy layer for {@link TunnelWritePolicy}. */
190
+ export const TunnelWritePolicyLive = makeTunnelPolicyLive(
191
+ TunnelWritePolicy,
192
+ "Cloudflare.TunnelWrite",
193
+ ["Cloudflare Tunnel Write"],
194
+ );
@@ -1 +1,5 @@
1
1
  export * from "./Tunnel.ts";
2
+ export * from "./TunnelBinding.ts";
3
+ export * from "./TunnelRead.ts";
4
+ export * from "./TunnelReadWrite.ts";
5
+ export * from "./TunnelWrite.ts";
@@ -253,7 +253,8 @@ const toAttributes = (
253
253
  ): VectorizeIndexAttributes => ({
254
254
  indexName: index.name ?? name,
255
255
  dimensions: index.config?.dimensions,
256
- metric: index.config?.metric,
256
+ // Distilled widened generated string enums to open unions (`string & {}`).
257
+ metric: index.config?.metric as DistanceMetric | undefined,
257
258
  description: index.description ?? undefined,
258
259
  accountId,
259
260
  createdOn: index.createdOn ?? undefined,
@@ -262,7 +262,9 @@ export const formatVpcService = (
262
262
  service: {
263
263
  serviceId?: string | null;
264
264
  name: string;
265
- type: "http" | "tcp";
265
+ // Distilled widened generated string enums to open unions (`string & {}`);
266
+ // the API only ever returns the known variants here.
267
+ type: string;
266
268
  createdAt?: string | null;
267
269
  updatedAt?: string | null;
268
270
  httpPort?: number | null;
@@ -300,7 +302,7 @@ export const formatVpcService = (
300
302
  return {
301
303
  serviceId: service.serviceId!,
302
304
  serviceName: service.name,
303
- serviceType: service.type,
305
+ serviceType: service.type as "http" | "tcp",
304
306
  httpPort: service.httpPort ?? undefined,
305
307
  httpsPort: service.httpsPort ?? undefined,
306
308
  host,
@@ -6,6 +6,7 @@ import * as Effect from "effect/Effect";
6
6
  import * as Exit from "effect/Exit";
7
7
  import * as Layer from "effect/Layer";
8
8
  import * as Scope from "effect/Scope";
9
+ import * as Stream from "effect/Stream";
9
10
 
10
11
  import { HttpServerResponse } from "effect/unstable/http";
11
12
  import type {
@@ -89,7 +90,15 @@ export const makeDurableObjectBridge =
89
90
  this.#execute((instance) => {
90
91
  const method = instance[prop as keyof DurableObjectShape];
91
92
  if (typeof method === "function") {
92
- return (method as any)(...args);
93
+ const result = (method as any)(...args);
94
+ // A streaming RPC method returns a `Stream` directly rather
95
+ // than an `Effect`. Lift it into the success channel so the
96
+ // resulting `Exit.value` is the `Stream` and `handleRpcExit`
97
+ // can encode it as a stream envelope instead of trying to run
98
+ // it as an effect.
99
+ return Stream.isStream(result)
100
+ ? Effect.succeed(result)
101
+ : result;
93
102
  } else if (Effect.isEffect(method)) {
94
103
  return method;
95
104
  } else {
@@ -1,4 +1,5 @@
1
1
  import * as Effect from "effect/Effect";
2
+ import { SingleShotGen } from "effect/Utils";
2
3
  import { ALCHEMY_PHASE } from "../../Phase.ts";
3
4
  import { fromCloudflareFetcher, type Fetcher } from "../Fetcher.ts";
4
5
  import { makeRpcStub } from "./Rpc.ts";
@@ -56,10 +57,10 @@ export interface DynamicWorkerInstance extends Fetcher {
56
57
  }
57
58
 
58
59
  /**
59
- * The handle returned by `DynamicWorker(name)`. Provides a `.load()` method
60
- * for spinning up isolated dynamic workers at runtime.
60
+ * The runtime handle obtained by `yield* Cloudflare.DynamicWorkerLoader(name)`.
61
+ * Provides a `.load()` method for spinning up isolated dynamic workers.
61
62
  */
62
- export type DynamicWorkerLoader = {
63
+ export interface DynamicWorkerLoaderHandle {
63
64
  Type: DynamicWorkerTypeId;
64
65
  name: string;
65
66
  /**
@@ -67,7 +68,57 @@ export type DynamicWorkerLoader = {
67
68
  * exposes `.getEntrypoint()` and `.fetch()` for calling into the worker.
68
69
  */
69
70
  load(options: DynamicWorkerLoadOptions): DynamicWorkerInstance;
70
- };
71
+ }
72
+
73
+ /**
74
+ * The native `worker_loader` runtime binding shape, as seen by an async
75
+ * (non-Effect) Worker that declares the loader through `env`. `InferEnv` maps
76
+ * a `DynamicWorkerLoader` marker in `env` to this type.
77
+ */
78
+ export interface DynamicWorkerLoaderBinding {
79
+ load(options: DynamicWorkerLoadOptions): {
80
+ getEntrypoint(name?: string): {
81
+ fetch(request: Request): Promise<Response>;
82
+ [method: string]: unknown;
83
+ };
84
+ };
85
+ }
86
+
87
+ /**
88
+ * The Effect yielded when a `DynamicWorkerLoader` marker is used inside a
89
+ * Worker init phase: it registers the `worker_loader` binding on the
90
+ * surrounding Worker and resolves to a {@link DynamicWorkerLoaderHandle}.
91
+ */
92
+ type BindEffect = ReturnType<typeof bindLoader>;
93
+
94
+ /**
95
+ * Marker for a Cloudflare Worker Loader binding.
96
+ *
97
+ * It is a plain data structure (so it can be declared directly on a Worker's
98
+ * `env`) that is **also** yieldable inside an Effect-native Worker. Yielding it
99
+ * (`yield* Cloudflare.DynamicWorkerLoader(name)`) registers the binding on the
100
+ * surrounding Worker and returns a {@link DynamicWorkerLoaderHandle} with
101
+ * `.load()` — no separate `.bind(...)` step required.
102
+ *
103
+ * The divergence is achieved via `[Symbol.iterator]`: the object is not an
104
+ * `Effect` (so `InferEnv` resolves it to the native
105
+ * {@link DynamicWorkerLoaderBinding} in the `env` position), but it is iterable
106
+ * as one when `yield*`-ed.
107
+ */
108
+ export interface DynamicWorkerLoader {
109
+ kind: DynamicWorkerTypeId;
110
+ name: string;
111
+ asEffect(): BindEffect;
112
+ [Symbol.iterator](): SingleShotGen<BindEffect, DynamicWorkerLoaderHandle>;
113
+ }
114
+
115
+ export const isDynamicWorkerLoader = (
116
+ value: unknown,
117
+ ): value is DynamicWorkerLoader =>
118
+ typeof value === "object" &&
119
+ value !== null &&
120
+ "kind" in value &&
121
+ (value as DynamicWorkerLoader).kind === DynamicWorkerTypeId;
71
122
 
72
123
  /**
73
124
  * Load and run ephemeral Workers at runtime from inline JavaScript
@@ -86,14 +137,79 @@ export type DynamicWorkerLoader = {
86
137
  * @resource
87
138
  *
88
139
  * @section Creating a Loader
89
- * Yield `Cloudflare.DynamicWorkerLoader` in your Worker's init
90
- * phase to register the binding. The string argument becomes the
91
- * binding name on the deployed Worker.
140
+ * Yield `Cloudflare.DynamicWorkerLoader(name)` in your Worker's init
141
+ * phase to register the binding and get back a runtime handle. The
142
+ * string argument becomes the binding name on the deployed Worker.
92
143
  *
93
- * @example Registering a loader
144
+ * @example Registering a loader (effect-native Worker)
94
145
  * ```typescript
95
- * // init
96
- * const loader = yield* Cloudflare.DynamicWorkerLoader("Loader");
146
+ * import * as Cloudflare from "alchemy/Cloudflare";
147
+ * import * as Effect from "effect/Effect";
148
+ * import { HttpServerRequest } from "effect/unstable/http/HttpServerRequest";
149
+ * import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
150
+ * import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
151
+ *
152
+ * export default class EvalWorker extends Cloudflare.Worker<EvalWorker>()(
153
+ * "EvalWorker",
154
+ * { main: import.meta.filename },
155
+ * Effect.gen(function* () {
156
+ * // Registers the `worker_loader` binding on this Worker and returns the
157
+ * // runtime handle in one step — no separate `.bind(...)`.
158
+ * const loader = yield* Cloudflare.DynamicWorkerLoader("LOADER");
159
+ *
160
+ * return {
161
+ * fetch: Effect.gen(function* () {
162
+ * const request = yield* HttpServerRequest;
163
+ * const code = yield* request.text;
164
+ *
165
+ * // Spin up an isolated, sandboxed Worker from inline source.
166
+ * const worker = loader.load({
167
+ * compatibilityDate: "2026-01-28",
168
+ * mainModule: "worker.js",
169
+ * modules: {
170
+ * "worker.js": `export default {
171
+ * async fetch(req) {
172
+ * const result = (0, eval)(await req.text());
173
+ * return new Response(String(result));
174
+ * }
175
+ * }`,
176
+ * },
177
+ * globalOutbound: null, // block outbound network access
178
+ * });
179
+ *
180
+ * // Call the loaded Worker over Effect-native HTTP.
181
+ * const response = yield* worker.fetch(
182
+ * HttpClientRequest.post("https://worker/").pipe(
183
+ * HttpClientRequest.bodyText(code),
184
+ * ),
185
+ * );
186
+ * return HttpServerResponse.fromClientResponse(response);
187
+ * }),
188
+ * };
189
+ * }),
190
+ * ) {}
191
+ * ```
192
+ *
193
+ * @example Declaring on env (async Worker)
194
+ * ```typescript
195
+ * export const Worker = Cloudflare.Worker("Worker", {
196
+ * main: "./src/worker.ts",
197
+ * env: { LOADER: Cloudflare.DynamicWorkerLoader() },
198
+ * });
199
+ *
200
+ * export type WorkerEnv = Cloudflare.InferEnv<typeof Worker>;
201
+ *
202
+ * // worker.ts
203
+ * export default {
204
+ * async fetch(req: Request, env: WorkerEnv) {
205
+ * const worker = env.LOADER.load({
206
+ * compatibilityDate: "2026-01-28",
207
+ * mainModule: "worker.js",
208
+ * modules: { "worker.js": "export default { fetch: () => new Response('ok') }" },
209
+ * });
210
+ * return worker.getEntrypoint().fetch(req);
211
+ * },
212
+ * };
97
213
  * ```
98
214
  *
99
215
  * @section Loading a Worker
@@ -155,7 +271,17 @@ export type DynamicWorkerLoader = {
155
271
  * const greeting = yield* api.greet("world");
156
272
  * ```
157
273
  */
158
- export const DynamicWorkerLoader = Effect.fnUntraced(function* (name: string) {
274
+ export const DynamicWorkerLoader = (name = "LOADER"): DynamicWorkerLoader => {
275
+ const self: DynamicWorkerLoader = {
276
+ kind: DynamicWorkerTypeId,
277
+ name,
278
+ asEffect: () => bindLoader(name),
279
+ [Symbol.iterator]: () => new SingleShotGen(bindLoader(name)),
280
+ };
281
+ return self;
282
+ };
283
+
284
+ const bindLoader = Effect.fnUntraced(function* (name: string) {
159
285
  const worker = yield* Worker;
160
286
 
161
287
  yield* worker.bind`${name}`({
@@ -177,14 +303,14 @@ export const DynamicWorkerLoader = Effect.fnUntraced(function* (name: string) {
177
303
  }),
178
304
  );
179
305
 
180
- const self: DynamicWorkerLoader = {
306
+ const handle: DynamicWorkerLoaderHandle = {
181
307
  Type: DynamicWorkerTypeId,
182
308
  name,
183
309
  load: (options: DynamicWorkerLoadOptions): DynamicWorkerInstance =>
184
310
  wrapLoadedWorker(binding.load(options)),
185
311
  };
186
312
 
187
- return self;
313
+ return handle;
188
314
  });
189
315
 
190
316
  const wrapEntrypoint = <Shape>(raw: any): DynamicWorkerEntrypoint<Shape> =>
@@ -40,21 +40,25 @@ export type GetBindingType<T> =
40
40
  ? AnalyticsEngineDataset
41
41
  : T extends Cloudflare.Artifacts
42
42
  ? Artifacts
43
- : T extends Cloudflare.Images
44
- ? ImagesBinding
45
- : T extends Cloudflare.BrowserRendering
46
- ? Fetcher
47
- : T extends Cloudflare.Hyperdrive
48
- ? Hyperdrive
49
- : T extends Cloudflare.DurableObjectNamespaceLike
50
- ? DurableObjectNamespace<
51
- Exclude<T["Shape"], undefined>
52
- >
53
- : T extends Redacted<any>
54
- ? // redacteds are always stored as secret_text, so are always string
55
- // we JSON.stringify when not a Redacted<string>
56
- string
57
- : T;
43
+ : T extends Cloudflare.RateLimit
44
+ ? RateLimit
45
+ : T extends Cloudflare.Images
46
+ ? ImagesBinding
47
+ : T extends Cloudflare.Browser
48
+ ? Fetcher
49
+ : T extends Cloudflare.Hyperdrive
50
+ ? Hyperdrive
51
+ : T extends Cloudflare.DynamicWorkerLoader
52
+ ? Cloudflare.DynamicWorkerLoaderBinding
53
+ : T extends Cloudflare.DurableObjectNamespaceLike
54
+ ? DurableObjectNamespace<
55
+ Exclude<T["Shape"], undefined>
56
+ >
57
+ : T extends Redacted<any>
58
+ ? // redacteds are always stored as secret_text, so are always string
59
+ // we JSON.stringify when not a Redacted<string>
60
+ string
61
+ : T;
58
62
 
59
63
  /**
60
64
  * Cloudflare service-binding wire shape for an Effect-native Worker.
@@ -232,7 +232,19 @@ export const LocalWorkerProvider = () =>
232
232
  }) {
233
233
  const name = yield* createWorkerName(id, props.name);
234
234
  const compatibility = getCompatibility(props);
235
- const workerBindings: BindingHook<BindingServices>[] = [];
235
+ const workerBindings: BindingHook<BindingServices>[] = [
236
+ Text.local("ALCHEMY_PHASE", "runtime"),
237
+ Text.local("ALCHEMY_STACK_NAME", stack.name),
238
+ Text.local("ALCHEMY_STAGE", stack.stage),
239
+ ...Object.entries(props.env ?? {}).map(([key, value]) => {
240
+ const unredacted = Redacted.isRedacted(value)
241
+ ? Redacted.value(value)
242
+ : value;
243
+ return typeof unredacted === "string"
244
+ ? Text.local(key, unredacted)
245
+ : Json.local(key, unredacted);
246
+ }),
247
+ ];
236
248
  const durableObjectNamespaces: Record<string, string> = {};
237
249
  const hyperdrives: Record<string, Required<HyperdriveOrigin>> = {};
238
250
  for (const { data } of bindings) {
@@ -583,8 +595,19 @@ const toRuntimeAssets = (
583
595
  directory: "directory" in assets ? assets.directory : assets.path,
584
596
  headers: assets.config?.headers,
585
597
  redirects: assets.config?.redirects,
586
- htmlHandling: assets.config?.htmlHandling,
587
- notFoundHandling: assets.config?.notFoundHandling,
598
+ // Distilled widened generated string enums to open unions (`string & {}`);
599
+ // the API only ever returns the known variants here.
600
+ htmlHandling: assets.config?.htmlHandling as
601
+ | "none"
602
+ | "auto-trailing-slash"
603
+ | "force-trailing-slash"
604
+ | "drop-trailing-slash"
605
+ | undefined,
606
+ notFoundHandling: assets.config?.notFoundHandling as
607
+ | "none"
608
+ | "404-page"
609
+ | "single-page-application"
610
+ | undefined,
588
611
  runWorkerFirst: assets.config?.runWorkerFirst,
589
612
  serveDirectly: assets.config?.serveDirectly,
590
613
  };
@@ -223,19 +223,48 @@ export const makeRpcStub = <Shape>(
223
223
  return target[prop];
224
224
  }
225
225
  return (...args: any[]) =>
226
- Effect.gen(function* () {
227
- const stub = isLazy
228
- ? yield* stubSource as Effect.Effect<any>
229
- : stubSource;
230
- return yield* Effect.tryPromise({
231
- try: () => (stub as any)[prop](...args),
232
- catch: (cause) => new RpcCallError({ method: String(prop), cause }),
233
- }).pipe(Effect.flatMap(decodeRpcResult));
234
- });
226
+ asEffectOrStream(
227
+ Effect.gen(function* () {
228
+ const stub = isLazy
229
+ ? yield* stubSource as Effect.Effect<any>
230
+ : stubSource;
231
+ return yield* Effect.tryPromise({
232
+ try: () => (stub as any)[prop](...args),
233
+ catch: (cause) =>
234
+ new RpcCallError({ method: String(prop), cause }),
235
+ }).pipe(Effect.flatMap(decodeRpcResult));
236
+ }),
237
+ );
235
238
  },
236
239
  }) as Shape;
237
240
  };
238
241
 
242
+ // Effect's internal Stream brand. `Stream.isStream` recognises a value by
243
+ // this property and reads its `channel`. A `makeRpcStub` method can't know
244
+ // synchronously whether the remote method returns a value or a `Stream`
245
+ // (the call is async), yet its declared type mirrors the DO `Shape`
246
+ // verbatim — value methods are typed `Effect<A>`, streaming methods `Stream<A>`.
247
+ // We satisfy BOTH by handing back the call `Effect` augmented with the Stream
248
+ // brand + channel, so the single return value can be `yield*`-ed / `.pipe`d as
249
+ // an Effect (value methods, e.g. `stub.put(k, v).pipe(Effect.orDie)`) AND piped
250
+ // through `Stream.*` combinators (streaming methods, e.g.
251
+ // `stub.tick(n).pipe(Stream.map(...))`).
252
+ const StreamTypeId = "~effect/Stream";
253
+
254
+ const asEffectOrStream = (
255
+ call: Effect.Effect<unknown, unknown>,
256
+ ): Effect.Effect<unknown, unknown> => {
257
+ const streamForm = Stream.unwrap(
258
+ Effect.map(call, (value) =>
259
+ Stream.isStream(value) ? value : Stream.succeed(value),
260
+ ),
261
+ );
262
+ return Object.assign(call, {
263
+ [StreamTypeId]: streamForm[StreamTypeId],
264
+ channel: streamForm.channel,
265
+ });
266
+ };
267
+
239
268
  export const toRpcStream = (stream: Stream.Stream<any, any, any>) =>
240
269
  Effect.scoped(
241
270
  Effect.gen(function* () {
@@ -10,7 +10,7 @@ import { asEffect } from "../../Util/types.ts";
10
10
  import { isAiGateway } from "../AiGateway/AiGateway.ts";
11
11
  import { isAnalyticsEngineDataset } from "../AnalyticsEngine/AnalyticsEngineDataset.ts";
12
12
  import { isArtifacts } from "../Artifacts/Artifacts.ts";
13
- import { isBrowserRendering } from "../BrowserRendering/BrowserRendering.ts";
13
+ import { isBrowser } from "../Browser/Browser.ts";
14
14
  import { isD1Database } from "../D1/D1Database.ts";
15
15
  import { isSendEmail } from "../Email/SendEmail.ts";
16
16
  import { isHyperdrive } from "../Hyperdrive/Hyperdrive.ts";
@@ -19,9 +19,11 @@ import { isImages } from "../Images/Images.ts";
19
19
  import { isKVNamespace } from "../KV/KVNamespace.ts";
20
20
  import { isQueue } from "../Queue/Queue.ts";
21
21
  import { isR2Bucket } from "../R2/R2Bucket.ts";
22
+ import { isRateLimit } from "../RateLimit/RateLimit.ts";
22
23
  import { isVectorizeIndex } from "../Vectorize/VectorizeIndex.ts";
23
24
  import { isAssets } from "./Assets.ts";
24
25
  import { isDurableObjectNamespaceLike } from "./DurableObjectNamespace.ts";
26
+ import { isDynamicWorkerLoader } from "./DynamicWorkerLoader.ts";
25
27
  import type { WorkerBindingProps } from "./Worker.ts";
26
28
  import { isWorker, type Worker, type WorkerProps } from "./Worker.ts";
27
29
  import type { WorkerBinding, WorkerBindingResource } from "./WorkerBinding.ts";
@@ -119,7 +121,7 @@ const toBinding = (
119
121
  type: "images",
120
122
  name: bindingName,
121
123
  };
122
- } else if (isBrowserRendering(binding)) {
124
+ } else if (isBrowser(binding)) {
123
125
  return {
124
126
  type: "browser",
125
127
  name: bindingName,
@@ -130,6 +132,13 @@ const toBinding = (
130
132
  name: bindingName,
131
133
  dataset: binding.dataset,
132
134
  };
135
+ } else if (isRateLimit(binding)) {
136
+ return {
137
+ type: "ratelimit",
138
+ name: bindingName,
139
+ namespaceId: binding.namespaceId,
140
+ simple: binding.simple,
141
+ };
133
142
  } else if (isSendEmail(binding)) {
134
143
  return {
135
144
  type: "send_email",
@@ -197,6 +206,11 @@ const toBinding = (
197
206
  name: bindingName,
198
207
  indexName: binding.indexName,
199
208
  };
209
+ } else if (isDynamicWorkerLoader(binding)) {
210
+ return {
211
+ type: "worker_loader",
212
+ name: bindingName,
213
+ } as any;
200
214
  } else {
201
215
  return {
202
216
  type: "json",