alchemy 2.0.0-beta.44 → 2.0.0-beta.45

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 (404) hide show
  1. package/bin/exec.js +67 -8
  2. package/bin/exec.js.map +1 -1
  3. package/lib/AWS/Lambda/Function.d.ts +17 -0
  4. package/lib/AWS/Lambda/Function.d.ts.map +1 -1
  5. package/lib/AWS/Lambda/Function.js +61 -16
  6. package/lib/AWS/Lambda/Function.js.map +1 -1
  7. package/lib/AWS/Providers.d.ts +2 -1
  8. package/lib/AWS/Providers.d.ts.map +1 -1
  9. package/lib/AWS/Providers.js +3 -1
  10. package/lib/AWS/Providers.js.map +1 -1
  11. package/lib/Apply.js +17 -1
  12. package/lib/Apply.js.map +1 -1
  13. package/lib/Auth/AuthProvider.d.ts.map +1 -1
  14. package/lib/Auth/AuthProvider.js +24 -6
  15. package/lib/Auth/AuthProvider.js.map +1 -1
  16. package/lib/Auth/Credentials.d.ts.map +1 -1
  17. package/lib/Auth/Credentials.js +3 -3
  18. package/lib/Auth/Credentials.js.map +1 -1
  19. package/lib/Cli/commands/_shared.d.ts +13 -1
  20. package/lib/Cli/commands/_shared.d.ts.map +1 -1
  21. package/lib/Cli/commands/_shared.js +33 -2
  22. package/lib/Cli/commands/_shared.js.map +1 -1
  23. package/lib/Cli/commands/dev.d.ts.map +1 -1
  24. package/lib/Cli/commands/dev.js +10 -1
  25. package/lib/Cli/commands/dev.js.map +1 -1
  26. package/lib/Cli/commands/login.d.ts.map +1 -1
  27. package/lib/Cli/commands/login.js +19 -5
  28. package/lib/Cli/commands/login.js.map +1 -1
  29. package/lib/Cli/commands/profile.d.ts.map +1 -1
  30. package/lib/Cli/commands/profile.js +7 -27
  31. package/lib/Cli/commands/profile.js.map +1 -1
  32. package/lib/Cli/main.d.ts.map +1 -1
  33. package/lib/Cli/main.js +0 -2
  34. package/lib/Cli/main.js.map +1 -1
  35. package/lib/Cloudflare/AiGateway/AiGateway.d.ts +0 -2
  36. package/lib/Cloudflare/AiGateway/AiGateway.d.ts.map +1 -1
  37. package/lib/Cloudflare/AiGateway/AiGateway.js +2 -4
  38. package/lib/Cloudflare/AiGateway/AiGateway.js.map +1 -1
  39. package/lib/Cloudflare/BrowserRendering/BrowserRendering.d.ts +116 -0
  40. package/lib/Cloudflare/BrowserRendering/BrowserRendering.d.ts.map +1 -0
  41. package/lib/Cloudflare/BrowserRendering/BrowserRendering.js +92 -0
  42. package/lib/Cloudflare/BrowserRendering/BrowserRendering.js.map +1 -0
  43. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.d.ts +55 -0
  44. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.d.ts.map +1 -0
  45. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.js +55 -0
  46. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.js.map +1 -0
  47. package/lib/Cloudflare/BrowserRendering/index.d.ts +3 -0
  48. package/lib/Cloudflare/BrowserRendering/index.d.ts.map +1 -0
  49. package/lib/Cloudflare/BrowserRendering/index.js +3 -0
  50. package/lib/Cloudflare/BrowserRendering/index.js.map +1 -0
  51. package/lib/Cloudflare/Container/Container.d.ts +3 -3
  52. package/lib/Cloudflare/Container/Container.js +3 -3
  53. package/lib/Cloudflare/Container/StartContainer.d.ts.map +1 -1
  54. package/lib/Cloudflare/Container/StartContainer.js.map +1 -1
  55. package/lib/Cloudflare/D1/D1Database.d.ts +1 -0
  56. package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
  57. package/lib/Cloudflare/D1/D1Database.js +2 -1
  58. package/lib/Cloudflare/D1/D1Database.js.map +1 -1
  59. package/lib/Cloudflare/D1/D1DatabaseBinding.js +1 -1
  60. package/lib/Cloudflare/D1/D1DatabaseBinding.js.map +1 -1
  61. package/lib/Cloudflare/Fetcher.d.ts.map +1 -1
  62. package/lib/Cloudflare/Fetcher.js +0 -2
  63. package/lib/Cloudflare/Fetcher.js.map +1 -1
  64. package/lib/Cloudflare/Hyperdrive/Hyperdrive.d.ts +1 -0
  65. package/lib/Cloudflare/Hyperdrive/Hyperdrive.d.ts.map +1 -1
  66. package/lib/Cloudflare/Hyperdrive/Hyperdrive.js +3 -0
  67. package/lib/Cloudflare/Hyperdrive/Hyperdrive.js.map +1 -1
  68. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.d.ts +3 -2
  69. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.d.ts.map +1 -1
  70. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.js +32 -33
  71. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.js.map +1 -1
  72. package/lib/Cloudflare/KV/KVNamespace.d.ts +1 -0
  73. package/lib/Cloudflare/KV/KVNamespace.d.ts.map +1 -1
  74. package/lib/Cloudflare/KV/KVNamespace.js +2 -0
  75. package/lib/Cloudflare/KV/KVNamespace.js.map +1 -1
  76. package/lib/Cloudflare/Local.js +1 -1
  77. package/lib/Cloudflare/Local.js.map +1 -1
  78. package/lib/Cloudflare/Providers.d.ts +2 -1
  79. package/lib/Cloudflare/Providers.d.ts.map +1 -1
  80. package/lib/Cloudflare/Providers.js +21 -17
  81. package/lib/Cloudflare/Providers.js.map +1 -1
  82. package/lib/Cloudflare/Queue/Queue.d.ts +1 -0
  83. package/lib/Cloudflare/Queue/Queue.d.ts.map +1 -1
  84. package/lib/Cloudflare/Queue/Queue.js +1 -0
  85. package/lib/Cloudflare/Queue/Queue.js.map +1 -1
  86. package/lib/Cloudflare/Queue/QueueConsumer.d.ts +2 -1
  87. package/lib/Cloudflare/Queue/QueueConsumer.d.ts.map +1 -1
  88. package/lib/Cloudflare/Queue/QueueConsumer.js +11 -3
  89. package/lib/Cloudflare/Queue/QueueConsumer.js.map +1 -1
  90. package/lib/Cloudflare/Queue/QueueEventSource.d.ts +30 -4
  91. package/lib/Cloudflare/Queue/QueueEventSource.d.ts.map +1 -1
  92. package/lib/Cloudflare/Queue/QueueEventSource.js +22 -1
  93. package/lib/Cloudflare/Queue/QueueEventSource.js.map +1 -1
  94. package/lib/Cloudflare/R2/R2Bucket.d.ts +1 -0
  95. package/lib/Cloudflare/R2/R2Bucket.d.ts.map +1 -1
  96. package/lib/Cloudflare/R2/R2Bucket.js +18 -0
  97. package/lib/Cloudflare/R2/R2Bucket.js.map +1 -1
  98. package/lib/Cloudflare/SecretsStore/Secret.d.ts.map +1 -1
  99. package/lib/Cloudflare/SecretsStore/Secret.js +13 -34
  100. package/lib/Cloudflare/SecretsStore/Secret.js.map +1 -1
  101. package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts +3 -2
  102. package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts.map +1 -1
  103. package/lib/Cloudflare/SecretsStore/SecretBinding.js +3 -2
  104. package/lib/Cloudflare/SecretsStore/SecretBinding.js.map +1 -1
  105. package/lib/Cloudflare/StateStore/Api.d.ts +5 -13
  106. package/lib/Cloudflare/StateStore/Api.d.ts.map +1 -1
  107. package/lib/Cloudflare/StateStore/Api.js +14 -8
  108. package/lib/Cloudflare/StateStore/Api.js.map +1 -1
  109. package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
  110. package/lib/Cloudflare/StateStore/State.js +45 -9
  111. package/lib/Cloudflare/StateStore/State.js.map +1 -1
  112. package/lib/Cloudflare/StateStore/Store.d.ts.map +1 -1
  113. package/lib/Cloudflare/StateStore/Store.js +5 -2
  114. package/lib/Cloudflare/StateStore/Store.js.map +1 -1
  115. package/lib/Cloudflare/VpcService/VpcService.d.ts +2 -2
  116. package/lib/Cloudflare/VpcService/VpcService.d.ts.map +1 -1
  117. package/lib/Cloudflare/Website/StaticSite.d.ts +5 -5
  118. package/lib/Cloudflare/Website/StaticSite.d.ts.map +1 -1
  119. package/lib/Cloudflare/Website/StaticSite.js +3 -0
  120. package/lib/Cloudflare/Website/StaticSite.js.map +1 -1
  121. package/lib/Cloudflare/Website/Vite.d.ts +5 -5
  122. package/lib/Cloudflare/Website/Vite.d.ts.map +1 -1
  123. package/lib/Cloudflare/Website/Vite.js.map +1 -1
  124. package/lib/Cloudflare/Workers/Assets.d.ts.map +1 -1
  125. package/lib/Cloudflare/Workers/Assets.js +1 -1
  126. package/lib/Cloudflare/Workers/Assets.js.map +1 -1
  127. package/lib/Cloudflare/Workers/DurableObjectBridge.d.ts.map +1 -1
  128. package/lib/Cloudflare/Workers/DurableObjectBridge.js +4 -2
  129. package/lib/Cloudflare/Workers/DurableObjectBridge.js.map +1 -1
  130. package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts +183 -6
  131. package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts.map +1 -1
  132. package/lib/Cloudflare/Workers/DurableObjectNamespace.js +279 -76
  133. package/lib/Cloudflare/Workers/DurableObjectNamespace.js.map +1 -1
  134. package/lib/Cloudflare/Workers/HttpServer.d.ts +6 -4
  135. package/lib/Cloudflare/Workers/HttpServer.d.ts.map +1 -1
  136. package/lib/Cloudflare/Workers/HttpServer.js +20 -15
  137. package/lib/Cloudflare/Workers/HttpServer.js.map +1 -1
  138. package/lib/Cloudflare/Workers/InferEnv.d.ts +3 -2
  139. package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
  140. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts +4 -7
  141. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
  142. package/lib/Cloudflare/Workers/LocalWorkerProvider.js +111 -66
  143. package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
  144. package/lib/Cloudflare/Workers/Rpc.d.ts +16 -0
  145. package/lib/Cloudflare/Workers/Rpc.d.ts.map +1 -1
  146. package/lib/Cloudflare/Workers/Rpc.js +22 -0
  147. package/lib/Cloudflare/Workers/Rpc.js.map +1 -1
  148. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.d.ts +285 -0
  149. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.d.ts.map +1 -0
  150. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.js +288 -0
  151. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.js.map +1 -0
  152. package/lib/Cloudflare/Workers/RpcWorker.d.ts +305 -0
  153. package/lib/Cloudflare/Workers/RpcWorker.d.ts.map +1 -0
  154. package/lib/Cloudflare/Workers/RpcWorker.js +350 -0
  155. package/lib/Cloudflare/Workers/RpcWorker.js.map +1 -0
  156. package/lib/Cloudflare/Workers/Vite.d.ts +1 -1
  157. package/lib/Cloudflare/Workers/Vite.d.ts.map +1 -1
  158. package/lib/Cloudflare/Workers/Vite.js +2 -1
  159. package/lib/Cloudflare/Workers/Vite.js.map +1 -1
  160. package/lib/Cloudflare/Workers/Worker.d.ts +69 -24
  161. package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
  162. package/lib/Cloudflare/Workers/Worker.js +168 -47
  163. package/lib/Cloudflare/Workers/Worker.js.map +1 -1
  164. package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts +1 -1
  165. package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts.map +1 -1
  166. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js +158 -97
  167. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
  168. package/lib/Cloudflare/Workers/WorkerBinding.d.ts +11 -23
  169. package/lib/Cloudflare/Workers/WorkerBinding.d.ts.map +1 -1
  170. package/lib/Cloudflare/Workers/WorkerBinding.js +3 -0
  171. package/lib/Cloudflare/Workers/WorkerBinding.js.map +1 -1
  172. package/lib/Cloudflare/Workers/WorkerBridge.d.ts.map +1 -1
  173. package/lib/Cloudflare/Workers/WorkerBridge.js +5 -2
  174. package/lib/Cloudflare/Workers/WorkerBridge.js.map +1 -1
  175. package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
  176. package/lib/Cloudflare/Workers/WorkerBundle.js +4 -1
  177. package/lib/Cloudflare/Workers/WorkerBundle.js.map +1 -1
  178. package/lib/Cloudflare/Workers/WorkerRuntimeContext.d.ts.map +1 -1
  179. package/lib/Cloudflare/Workers/WorkerRuntimeContext.js +9 -10
  180. package/lib/Cloudflare/Workers/WorkerRuntimeContext.js.map +1 -1
  181. package/lib/Cloudflare/Workers/Workflow.d.ts +5 -3
  182. package/lib/Cloudflare/Workers/Workflow.d.ts.map +1 -1
  183. package/lib/Cloudflare/Workers/Workflow.js +19 -1
  184. package/lib/Cloudflare/Workers/Workflow.js.map +1 -1
  185. package/lib/Cloudflare/Workers/index.d.ts +2 -0
  186. package/lib/Cloudflare/Workers/index.d.ts.map +1 -1
  187. package/lib/Cloudflare/Workers/index.js +2 -0
  188. package/lib/Cloudflare/Workers/index.js.map +1 -1
  189. package/lib/Cloudflare/index.d.ts +1 -0
  190. package/lib/Cloudflare/index.d.ts.map +1 -1
  191. package/lib/Cloudflare/index.js +1 -0
  192. package/lib/Cloudflare/index.js.map +1 -1
  193. package/lib/Dependencies.d.ts +10 -0
  194. package/lib/Dependencies.d.ts.map +1 -0
  195. package/lib/Dependencies.js +1 -0
  196. package/lib/Dependencies.js.map +1 -0
  197. package/lib/Deploy.d.ts +2 -1
  198. package/lib/Deploy.d.ts.map +1 -1
  199. package/lib/Deploy.js +2 -2
  200. package/lib/Deploy.js.map +1 -1
  201. package/lib/Diff.d.ts +11 -0
  202. package/lib/Diff.d.ts.map +1 -1
  203. package/lib/Diff.js +11 -0
  204. package/lib/Diff.js.map +1 -1
  205. package/lib/Input.d.ts +2 -1
  206. package/lib/Input.d.ts.map +1 -1
  207. package/lib/KeyPair.d.ts +77 -0
  208. package/lib/KeyPair.d.ts.map +1 -0
  209. package/lib/KeyPair.js +102 -0
  210. package/lib/KeyPair.js.map +1 -0
  211. package/lib/Local/RpcProvider.d.ts +3 -1
  212. package/lib/Local/RpcProvider.d.ts.map +1 -1
  213. package/lib/Local/RpcProvider.js +28 -2
  214. package/lib/Local/RpcProvider.js.map +1 -1
  215. package/lib/Local/RpcServerEnvironment.js +1 -1
  216. package/lib/Local/RpcServerEnvironment.js.map +1 -1
  217. package/lib/Neon/Project.d.ts.map +1 -1
  218. package/lib/Neon/Project.js +14 -3
  219. package/lib/Neon/Project.js.map +1 -1
  220. package/lib/Output.d.ts.map +1 -1
  221. package/lib/Output.js +9 -2
  222. package/lib/Output.js.map +1 -1
  223. package/lib/Phase.d.ts +2 -1
  224. package/lib/Phase.d.ts.map +1 -1
  225. package/lib/Phase.js +6 -1
  226. package/lib/Phase.js.map +1 -1
  227. package/lib/Plan.d.ts.map +1 -1
  228. package/lib/Plan.js +14 -3
  229. package/lib/Plan.js.map +1 -1
  230. package/lib/Platform.d.ts +8 -6
  231. package/lib/Platform.d.ts.map +1 -1
  232. package/lib/Platform.js +33 -3
  233. package/lib/Platform.js.map +1 -1
  234. package/lib/Random.d.ts.map +1 -1
  235. package/lib/Random.js +9 -14
  236. package/lib/Random.js.map +1 -1
  237. package/lib/RuntimeContext.d.ts +21 -1
  238. package/lib/RuntimeContext.d.ts.map +1 -1
  239. package/lib/RuntimeContext.js +12 -0
  240. package/lib/RuntimeContext.js.map +1 -1
  241. package/lib/Stack.d.ts +3 -3
  242. package/lib/Stack.d.ts.map +1 -1
  243. package/lib/Stack.js.map +1 -1
  244. package/lib/State/HttpStateApi.d.ts +2 -2
  245. package/lib/State/StateEncoding.d.ts +8 -0
  246. package/lib/State/StateEncoding.d.ts.map +1 -1
  247. package/lib/State/StateEncoding.js +55 -5
  248. package/lib/State/StateEncoding.js.map +1 -1
  249. package/lib/Test/Bun.d.ts.map +1 -1
  250. package/lib/Test/Bun.js +0 -2
  251. package/lib/Test/Bun.js.map +1 -1
  252. package/lib/Test/Vitest.d.ts.map +1 -1
  253. package/lib/Test/Vitest.js +0 -2
  254. package/lib/Test/Vitest.js.map +1 -1
  255. package/lib/Util/Duration.d.ts +14 -0
  256. package/lib/Util/Duration.d.ts.map +1 -0
  257. package/lib/Util/Duration.js +18 -0
  258. package/lib/Util/Duration.js.map +1 -0
  259. package/lib/Util/index.d.ts +0 -6
  260. package/lib/Util/index.d.ts.map +1 -1
  261. package/lib/Util/index.js +0 -6
  262. package/lib/Util/index.js.map +1 -1
  263. package/lib/Util/types.d.ts +3 -1
  264. package/lib/Util/types.d.ts.map +1 -1
  265. package/lib/Util/types.js +5 -1
  266. package/lib/Util/types.js.map +1 -1
  267. package/lib/index.d.ts +2 -3
  268. package/lib/index.d.ts.map +1 -1
  269. package/lib/index.js +1 -3
  270. package/lib/index.js.map +1 -1
  271. package/lib/tsconfig.test.tsbuildinfo +1 -1
  272. package/package.json +20 -19
  273. package/src/AWS/Lambda/Function.ts +87 -34
  274. package/src/AWS/Providers.ts +3 -0
  275. package/src/Apply.ts +18 -1
  276. package/src/Auth/AuthProvider.ts +25 -5
  277. package/src/Auth/Credentials.ts +8 -7
  278. package/src/Cli/commands/_shared.ts +47 -4
  279. package/src/Cli/commands/dev.ts +13 -1
  280. package/src/Cli/commands/login.ts +20 -4
  281. package/src/Cli/commands/profile.ts +24 -34
  282. package/src/Cli/main.ts +0 -3
  283. package/src/Cloudflare/AiGateway/AiGateway.ts +2 -6
  284. package/src/Cloudflare/BrowserRendering/BrowserRendering.ts +132 -0
  285. package/src/Cloudflare/BrowserRendering/BrowserRenderingBinding.ts +137 -0
  286. package/src/Cloudflare/BrowserRendering/index.ts +11 -0
  287. package/src/Cloudflare/Container/Container.ts +3 -3
  288. package/src/Cloudflare/Container/StartContainer.ts +1 -2
  289. package/src/Cloudflare/D1/D1Database.ts +4 -1
  290. package/src/Cloudflare/D1/D1DatabaseBinding.ts +1 -1
  291. package/src/Cloudflare/Fetcher.ts +0 -2
  292. package/src/Cloudflare/Hyperdrive/Hyperdrive.ts +5 -0
  293. package/src/Cloudflare/Hyperdrive/HyperdriveBinding.ts +41 -43
  294. package/src/Cloudflare/KV/KVNamespace.ts +4 -0
  295. package/src/Cloudflare/Local.ts +1 -1
  296. package/src/Cloudflare/Providers.ts +25 -16
  297. package/src/Cloudflare/Queue/Queue.ts +3 -0
  298. package/src/Cloudflare/Queue/QueueConsumer.ts +23 -8
  299. package/src/Cloudflare/Queue/QueueEventSource.ts +33 -5
  300. package/src/Cloudflare/R2/R2Bucket.ts +26 -0
  301. package/src/Cloudflare/SecretsStore/Secret.ts +14 -41
  302. package/src/Cloudflare/SecretsStore/SecretBinding.ts +11 -11
  303. package/src/Cloudflare/StateStore/Api.ts +15 -15
  304. package/src/Cloudflare/StateStore/State.ts +68 -6
  305. package/src/Cloudflare/StateStore/Store.ts +5 -2
  306. package/src/Cloudflare/VpcService/VpcService.ts +2 -2
  307. package/src/Cloudflare/Website/StaticSite.ts +8 -10
  308. package/src/Cloudflare/Website/Vite.ts +4 -7
  309. package/src/Cloudflare/Workers/Assets.ts +1 -1
  310. package/src/Cloudflare/Workers/DurableObjectBridge.ts +7 -4
  311. package/src/Cloudflare/Workers/DurableObjectNamespace.ts +380 -121
  312. package/src/Cloudflare/Workers/HttpServer.ts +31 -25
  313. package/src/Cloudflare/Workers/InferEnv.ts +15 -8
  314. package/src/Cloudflare/Workers/LocalWorkerProvider.ts +139 -78
  315. package/src/Cloudflare/Workers/Rpc.ts +50 -0
  316. package/src/Cloudflare/Workers/RpcDurableObjectNamespace.ts +502 -0
  317. package/src/Cloudflare/Workers/RpcWorker.ts +562 -0
  318. package/src/Cloudflare/Workers/Vite.ts +2 -0
  319. package/src/Cloudflare/Workers/Worker.ts +274 -93
  320. package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +158 -103
  321. package/src/Cloudflare/Workers/WorkerBinding.ts +10 -0
  322. package/src/Cloudflare/Workers/WorkerBridge.ts +7 -4
  323. package/src/Cloudflare/Workers/WorkerBundle.ts +4 -1
  324. package/src/Cloudflare/Workers/WorkerRuntimeContext.ts +8 -15
  325. package/src/Cloudflare/Workers/Workflow.ts +22 -3
  326. package/src/Cloudflare/Workers/index.ts +2 -0
  327. package/src/Cloudflare/index.ts +1 -0
  328. package/src/Dependencies.ts +10 -0
  329. package/src/Deploy.ts +3 -1
  330. package/src/Diff.ts +13 -0
  331. package/src/Input.ts +2 -0
  332. package/src/KeyPair.ts +146 -0
  333. package/src/Local/RpcProvider.ts +45 -1
  334. package/src/Local/RpcServerEnvironment.ts +1 -1
  335. package/src/Neon/Project.ts +16 -3
  336. package/src/Output.ts +8 -2
  337. package/src/Phase.ts +8 -0
  338. package/src/Plan.ts +16 -3
  339. package/src/Platform.ts +74 -27
  340. package/src/Random.ts +22 -27
  341. package/src/RuntimeContext.ts +23 -1
  342. package/src/Stack.ts +3 -3
  343. package/src/State/StateEncoding.ts +58 -7
  344. package/src/Test/Bun.ts +0 -3
  345. package/src/Test/Vitest.ts +0 -3
  346. package/src/Util/Duration.ts +21 -0
  347. package/src/Util/index.ts +0 -6
  348. package/src/Util/types.ts +9 -2
  349. package/src/index.ts +2 -3
  350. package/lib/Secret.d.ts +0 -50
  351. package/lib/Secret.d.ts.map +0 -1
  352. package/lib/Secret.js +0 -23
  353. package/lib/Secret.js.map +0 -1
  354. package/lib/Trait.d.ts +0 -43
  355. package/lib/Trait.d.ts.map +0 -1
  356. package/lib/Trait.js +0 -17
  357. package/lib/Trait.js.map +0 -1
  358. package/lib/Util/LocalhostDns.d.ts +0 -23
  359. package/lib/Util/LocalhostDns.d.ts.map +0 -1
  360. package/lib/Util/LocalhostDns.js +0 -46
  361. package/lib/Util/LocalhostDns.js.map +0 -1
  362. package/lib/Util/assert-never.d.ts +0 -12
  363. package/lib/Util/assert-never.d.ts.map +0 -1
  364. package/lib/Util/assert-never.js +0 -11
  365. package/lib/Util/assert-never.js.map +0 -1
  366. package/lib/Util/class.d.ts +0 -3
  367. package/lib/Util/class.d.ts.map +0 -1
  368. package/lib/Util/class.js +0 -1
  369. package/lib/Util/class.js.map +0 -1
  370. package/lib/Util/ignore.d.ts +0 -40
  371. package/lib/Util/ignore.d.ts.map +0 -1
  372. package/lib/Util/ignore.js +0 -591
  373. package/lib/Util/ignore.js.map +0 -1
  374. package/lib/Util/instance.d.ts +0 -4
  375. package/lib/Util/instance.d.ts.map +0 -1
  376. package/lib/Util/instance.js +0 -1
  377. package/lib/Util/instance.js.map +0 -1
  378. package/lib/Util/pointer.d.ts +0 -5
  379. package/lib/Util/pointer.d.ts.map +0 -1
  380. package/lib/Util/pointer.js +0 -1
  381. package/lib/Util/pointer.js.map +0 -1
  382. package/lib/Util/schema-to-type.d.ts +0 -42
  383. package/lib/Util/schema-to-type.d.ts.map +0 -1
  384. package/lib/Util/schema-to-type.js +0 -364
  385. package/lib/Util/schema-to-type.js.map +0 -1
  386. package/lib/Util/todo.d.ts +0 -3
  387. package/lib/Util/todo.d.ts.map +0 -1
  388. package/lib/Util/todo.js +0 -3
  389. package/lib/Util/todo.js.map +0 -1
  390. package/lib/Variable.d.ts +0 -29
  391. package/lib/Variable.d.ts.map +0 -1
  392. package/lib/Variable.js +0 -9
  393. package/lib/Variable.js.map +0 -1
  394. package/src/Secret.ts +0 -87
  395. package/src/Trait.ts +0 -105
  396. package/src/Util/LocalhostDns.ts +0 -52
  397. package/src/Util/assert-never.ts +0 -18
  398. package/src/Util/class.ts +0 -7
  399. package/src/Util/ignore.ts +0 -815
  400. package/src/Util/instance.ts +0 -9
  401. package/src/Util/pointer.ts +0 -5
  402. package/src/Util/schema-to-type.ts +0 -456
  403. package/src/Util/todo.ts +0 -4
  404. package/src/Variable.ts +0 -44
@@ -0,0 +1,305 @@
1
+ import * as Context from "effect/Context";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import { type Rpc, RpcClient, type RpcGroup } from "effect/unstable/rpc";
5
+ import type * as RpcClientError from "effect/unstable/rpc/RpcClientError";
6
+ import type { Dependencies } from "../../Dependencies.ts";
7
+ import type { HttpEffect } from "../../Http.ts";
8
+ import type { Rpc as RpcShape } from "../../Rpc.ts";
9
+ import type { Worker, WorkerProps } from "./Worker.ts";
10
+ /**
11
+ * Props for {@link RpcWorker}. Same shape as {@link WorkerProps} with
12
+ * an additional `schema` field carrying the rpc group definition.
13
+ */
14
+ export type RpcWorkerProps<Rpcs extends Rpc.Any> = Omit<WorkerProps, "schema"> & {
15
+ /**
16
+ * The {@link RpcGroup.RpcGroup} served on this worker's `fetch`
17
+ * handler. The same value should be importable by any consumer of
18
+ * the worker (other workers or scripts using `RpcClient.make`).
19
+ */
20
+ readonly schema: RpcGroup.RpcGroup<Rpcs>;
21
+ };
22
+ declare const RpcWorkerScope_base: Context.ServiceClass<RpcWorkerScope, "Cloudflare.RpcWorker", Worker>;
23
+ export declare class RpcWorkerScope extends RpcWorkerScope_base {
24
+ }
25
+ declare const SchemaSymbol: unique symbol;
26
+ export interface RpcWorkerYieldable<Self, Rpcs extends Rpc.Any, Deps = never> extends Effect.Effect<Worker<{}> & RpcShape<Self> & Dependencies<Deps>, never, any> {
27
+ /** @internal */
28
+ readonly [SchemaSymbol]: RpcGroup.RpcGroup<Rpcs>;
29
+ }
30
+ /**
31
+ * Type of the {@link RpcWorker} constructor. Mirrors the class-form
32
+ * signature of {@link Worker} so `class X extends RpcWorker<X>()(...)`
33
+ * works identically and the resulting worker is `Rpc<Self>`-typed for
34
+ * binding consumers.
35
+ */
36
+ export interface RpcWorkerClass extends Effect.Effect<Worker, never, RpcWorkerScope> {
37
+ /**
38
+ * Class-based form: `class X extends RpcWorker<X>()(name, props, impl)`.
39
+ *
40
+ * The optional second type argument `Deps` mirrors
41
+ * `Cloudflare.Worker<Self, Bindings, Deps>` — it declares the DOs
42
+ * this Worker publishes for cross-script binding so consumers can
43
+ * write `Counter.from(WorkerA)` and have it type-check. `Rpcs` is
44
+ * always inferred from `props.schema`.
45
+ *
46
+ * Yielding the class in a Stack returns the {@link Worker} resource
47
+ * (so `worker.url`, `worker.workerName`, etc. work as usual). To get
48
+ * a typed `RpcClient` for *this* worker's rpc group from inside
49
+ * another worker's init, call {@link RpcWorker.bind}.
50
+ */
51
+ <Self, Deps = never>(): {
52
+ /**
53
+ * Modular form (no impl). Mirrors `Cloudflare.Worker<Self>()(id, props)`.
54
+ * Use `WorkerClass.make(impl)` to provide the runtime as a
55
+ * `Layer.Layer<Self>` so consumers that don't host the worker can
56
+ * import the class without pulling its runtime into their bundle.
57
+ */
58
+ <Rpcs extends Rpc.Any>(id: string, props: RpcWorkerProps<Rpcs>): RpcWorkerYieldable<Self, Rpcs, Deps> & {
59
+ new (_: never): {};
60
+ make<InnerR = never, InitReq = never>(impl: Effect.Effect<Effect.Effect<HttpEffect<InnerR>, never, InnerR>, never, InitReq>): Layer.Layer<Self, never, Exclude<InitReq | InnerR, never>>;
61
+ };
62
+ /** Inline-impl form. */
63
+ <Rpcs extends Rpc.Any, InnerR = never, InitReq = never>(id: string, props: RpcWorkerProps<Rpcs>, impl: Effect.Effect<Effect.Effect<HttpEffect<InnerR>, never, InnerR>, never, InitReq>): RpcWorkerYieldable<Self, Rpcs, Deps> & {
64
+ new (_: never): {};
65
+ };
66
+ };
67
+ /**
68
+ * Bind a typed Effect rpc client to a worker resource, using the
69
+ * worker's declared rpc {@link RpcGroup.RpcGroup} schema. Mirrors
70
+ * `Cloudflare.R2Bucket.bind(MyBucket)` and friends.
71
+ *
72
+ * Yield once at **init** — the result is a normal `RpcClient` you
73
+ * can call directly from any per-request handler. Internally each
74
+ * method invocation builds a fresh underlying `RpcClient` (through
75
+ * a Proxy) because Cloudflare rejects I/O objects created on a
76
+ * previous request; this is hidden from the consumer.
77
+ *
78
+ * Pair with {@link RpcWorker} on the server side; both ends share
79
+ * the same schema so values round-trip through one `Schema` codec.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * // INIT: register the binding once and get the typed client
84
+ * const tasks = yield* Cloudflare.RpcWorker.bind(TaskWorker);
85
+ *
86
+ * // PER-REQUEST: call methods directly
87
+ * proxyGetTask: ({ id }) => tasks.getTask({ id }),
88
+ * ```
89
+ */
90
+ readonly bind: <Self, Rpcs extends Rpc.Any>(workerEff: RpcWorkerYieldable<Self, Rpcs>) => Effect.Effect<RpcClient.RpcClient<Rpcs, RpcClientError.RpcClientError> & RpcShape<Self>, never, Worker>;
91
+ }
92
+ /**
93
+ * `RpcWorker` is a thin sugar over {@link Worker} for the common case
94
+ * where a worker's entire `fetch` surface is a typed Effect `RpcGroup`.
95
+ * It takes the rpc `schema` directly in props alongside `main`, and
96
+ * accepts an init Effect that returns the already-piped
97
+ * `RpcServer.toHttpEffect(...)`-producing Effect (no `{ fetch }`
98
+ * wrapper) — the wrapper plugs it into the worker's `fetch` for you.
99
+ *
100
+ * Functionally identical to writing `Cloudflare.Worker(...)` with
101
+ * `return { fetch: RpcServer.toHttpEffect(schema).pipe(...) }`; use
102
+ * whichever style you prefer.
103
+ *
104
+ * The class form (`class X extends Cloudflare.RpcWorker<X>()(...)`)
105
+ * carries `Self` through the result type as `Rpc<Self>`, so other
106
+ * workers binding to this one see the rpc shape pinned to `Self`.
107
+ *
108
+ * @resource
109
+ *
110
+ * @section Defining the rpc group
111
+ * @example Pure schema description
112
+ * The rpc group and its schemas live outside any worker so both the
113
+ * server (`RpcWorker`) and any consumers (`RpcClient.make` /
114
+ * `RpcDurableObjectNamespace`) import the same value.
115
+ * ```typescript
116
+ * import * as Schema from "effect/Schema";
117
+ * import { Rpc, RpcGroup } from "effect/unstable/rpc";
118
+ *
119
+ * export class TaskNotFound extends Schema.TaggedClass<TaskNotFound>()(
120
+ * "TaskNotFound",
121
+ * { id: Schema.String },
122
+ * ) {}
123
+ *
124
+ * const getTask = Rpc.make("getTask", {
125
+ * payload: { id: Schema.String },
126
+ * success: Schema.String,
127
+ * error: TaskNotFound,
128
+ * });
129
+ *
130
+ * export class TaskRpcs extends RpcGroup.make(getTask) {}
131
+ * ```
132
+ *
133
+ * @section Implementing the worker
134
+ * @example Class form (recommended)
135
+ * Mirrors `Cloudflare.Worker<Self>()(...)` — `class X extends ...`
136
+ * works the same. The init Effect builds a handlers `Layer` from the
137
+ * group and returns the `RpcServer.toHttpEffect(schema)`-piped Effect
138
+ * directly.
139
+ * ```typescript
140
+ * import * as Cloudflare from "alchemy/Cloudflare";
141
+ * import * as Effect from "effect/Effect";
142
+ * import * as Layer from "effect/Layer";
143
+ * import { RpcSerialization, RpcServer } from "effect/unstable/rpc";
144
+ * import { TaskRpcs } from "./rpcs.ts";
145
+ *
146
+ * export default class Worker extends Cloudflare.RpcWorker<Worker>()(
147
+ * "Worker",
148
+ * { main: import.meta.filename, schema: TaskRpcs },
149
+ * Effect.gen(function* () {
150
+ * const handlers = TaskRpcs.toLayer({
151
+ * getTask: ({ id }) => Effect.succeed(`task-${id}`),
152
+ * });
153
+ * return RpcServer.toHttpEffect(TaskRpcs).pipe(
154
+ * Effect.provide(Layer.mergeAll(handlers, RpcSerialization.layerJson)),
155
+ * );
156
+ * }),
157
+ * ) {}
158
+ * ```
159
+ *
160
+ * @example NDJSON for streaming rpcs
161
+ * If any rpc in the group is a streaming rpc, the wire serialization
162
+ * must be `RpcSerialization.layerNdjson` — streaming rpcs need
163
+ * newline framing on the wire.
164
+ * ```typescript
165
+ * return RpcServer.toHttpEffect(ChatRpcs).pipe(
166
+ * Effect.provide(handlers),
167
+ * Effect.provide(RpcSerialization.layerNdjson),
168
+ * );
169
+ * ```
170
+ *
171
+ * @section Modular form: separate the class from its runtime
172
+ * @example Class declaration with no impl + `static make(impl)`
173
+ * The inline class form above bundles the runtime into the class
174
+ * declaration. The two-arg form `(id, props)` declares the class
175
+ * as a pure tagged identifier; provide the runtime separately via
176
+ * `WorkerClass.make(impl)` so consumers can import the class for
177
+ * binding without pulling the host's runtime into their bundle.
178
+ * ```typescript
179
+ * export class TaskWorker extends Cloudflare.RpcWorker<TaskWorker>()(
180
+ * "TaskWorker",
181
+ * { main: import.meta.filename, schema: TaskRpcs },
182
+ * ) {}
183
+ *
184
+ * // Only the host script imports this default export; consumers
185
+ * // import the class above for `RpcWorker.bind(TaskWorker)`.
186
+ * export default TaskWorker.make(
187
+ * Effect.gen(function* () {
188
+ * const handlers = TaskRpcs.toLayer({
189
+ * getTask: ({ id }) => Effect.succeed(`task-${id}`),
190
+ * });
191
+ * return RpcServer.toHttpEffect(TaskRpcs).pipe(
192
+ * Effect.provide(Layer.mergeAll(handlers, RpcSerialization.layerJson)),
193
+ * );
194
+ * }),
195
+ * );
196
+ * ```
197
+ *
198
+ * @section Hosting a Durable Object for cross-script binding
199
+ * @example `RpcWorker<Self, Deps>()` declares published DOs
200
+ * The optional second type argument `Deps` mirrors
201
+ * `Cloudflare.Worker<Self, Bindings, Deps>` — it declares the DOs
202
+ * this Worker publishes for cross-script binding. With `Counter`
203
+ * named in `Deps`, any other Worker can write
204
+ * `Counter.from(TaskWorker)` and have it type-check.
205
+ * ```typescript
206
+ * import { Counter } from "./counter.ts";
207
+ *
208
+ * export class TaskWorker extends Cloudflare.RpcWorker<TaskWorker, Counter>()(
209
+ * "TaskWorker",
210
+ * { main: import.meta.filename, schema: TaskRpcs },
211
+ * ) {}
212
+ * ```
213
+ * See {@link RpcDurableObjectNamespace} for the consumer side
214
+ * (`Counter.from(TaskWorker)`).
215
+ *
216
+ * @section Binding it from another worker
217
+ * @example `Cloudflare.RpcWorker.bind(WorkerClass)`
218
+ * Inside another worker's init, `RpcWorker.bind(WorkerClass)`
219
+ * registers the service binding on the surrounding worker and returns
220
+ * a typed `RpcClient` you can call directly from any per-request
221
+ * handler. Internally each method invocation builds a fresh underlying
222
+ * client (because Cloudflare rejects cross-request reuse of the
223
+ * stub I/O), but that's hidden behind a Proxy so the consumer sees a
224
+ * normal `RpcClient`.
225
+ * ```typescript
226
+ * import TaskWorker from "./task-worker.ts";
227
+ *
228
+ * export default class Caller extends Cloudflare.RpcWorker<Caller>()(
229
+ * "Caller",
230
+ * { main: import.meta.filename, schema: CallerRpcs },
231
+ * Effect.gen(function* () {
232
+ * // INIT: register binding, get the typed client
233
+ * const tasks = yield* Cloudflare.RpcWorker.bind(TaskWorker);
234
+ *
235
+ * const handlers = CallerRpcs.toLayer({
236
+ * // PER-REQUEST: just call methods directly
237
+ * proxyGetTask: ({ id }) => tasks.getTask({ id }),
238
+ * });
239
+ * return RpcServer.toHttpEffect(CallerRpcs).pipe(
240
+ * Effect.provide(Layer.mergeAll(handlers, RpcSerialization.layerJson)),
241
+ * );
242
+ * }),
243
+ * ) {}
244
+ * ```
245
+ *
246
+ * @section Driving it from a test
247
+ * @example `Test.make` + `RpcClient.make`
248
+ * The same `RpcGroup` drives a typed client. `Test.make` deploys the
249
+ * stack once for the file; each test yields the deploy handle for its
250
+ * URL and calls procedures directly.
251
+ * ```typescript
252
+ * import { expect } from "@effect/vitest";
253
+ * import * as Cloudflare from "alchemy/Cloudflare";
254
+ * import * as Test from "alchemy/Test/Vitest";
255
+ * import * as Effect from "effect/Effect";
256
+ * import * as Layer from "effect/Layer";
257
+ * import * as Schedule from "effect/Schedule";
258
+ * import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
259
+ * import * as RpcClient from "effect/unstable/rpc/RpcClient";
260
+ * import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
261
+ * import Stack from "../alchemy.run.ts";
262
+ * import { TaskRpcs } from "../src/rpcs.ts";
263
+ *
264
+ * const { test, beforeAll, afterAll, deploy, destroy } = Test.make({
265
+ * providers: Cloudflare.providers(),
266
+ * });
267
+ * const stack = beforeAll(deploy(Stack));
268
+ * afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack));
269
+ *
270
+ * const layer = (url: string) =>
271
+ * RpcClient.layerProtocolHttp({ url }).pipe(
272
+ * Layer.provide(FetchHttpClient.layer),
273
+ * Layer.provide(
274
+ * Layer.succeed(RpcSerialization.RpcSerialization, RpcSerialization.json),
275
+ * ),
276
+ * );
277
+ *
278
+ * test(
279
+ * "getTask",
280
+ * Effect.gen(function* () {
281
+ * const { url } = yield* stack;
282
+ * yield* Effect.gen(function* () {
283
+ * const client = yield* RpcClient.make(TaskRpcs);
284
+ * const result = yield* client
285
+ * .getTask({ id: "abc" })
286
+ * .pipe(Effect.retry({ schedule: Schedule.exponential("500 millis"), times: 5 }));
287
+ * expect(result).toBe("task-abc");
288
+ * }).pipe(Effect.scoped, Effect.provide(layer(url)));
289
+ * }),
290
+ * );
291
+ * ```
292
+ *
293
+ * @section Yielding the surrounding worker from inside the impl
294
+ * @example `yield* RpcWorker` inside the init effect
295
+ * Mirrors `yield* DurableObjectNamespace` — yield the tag to access
296
+ * the surrounding worker.
297
+ * ```typescript
298
+ * Effect.gen(function* () {
299
+ * const self = yield* Cloudflare.RpcWorker;
300
+ * });
301
+ * ```
302
+ */
303
+ export declare const RpcWorker: RpcWorkerClass;
304
+ export {};
305
+ //# sourceMappingURL=RpcWorker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RpcWorker.d.ts","sourceRoot":"","sources":["../../../src/Cloudflare/Workers/RpcWorker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EACL,KAAK,GAAG,EACR,SAAS,EACT,KAAK,QAAQ,EAEd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,cAAc,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,GAAG,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGvD;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,IAAI,SAAS,GAAG,CAAC,GAAG,IAAI,IAAI,CACrD,WAAW,EACX,QAAQ,CACT,GAAG;IACF;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;CAC1C,CAAC;;AAMF,qBAAa,cAAe,SAAQ,mBAEnC;CAAG;AAKJ,QAAA,MAAM,YAAY,eAAyC,CAAC;AAU5D,MAAM,WAAW,kBAAkB,CACjC,IAAI,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AC3B,IAAI,EAAE,MAAM,CAAC,MAAM,CACjB,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAChD,KAAK,EACL,OAAO,CACR,GACA,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG;YAKxC,KAAK,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC;SACpB,CAAC;KACH,CAAC;IAEF;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,SAAS,GAAG,CAAC,GAAG,EACxC,SAAS,EAAE,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,KACtC,MAAM,CAAC,MAAM,CAChB,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,EACzE,KAAK,EACL,MAAM,CACP,CAAC;CACH;AAmGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkNG;AACH,eAAO,MAAM,SAAS,EAAE,cA+Bb,CAAC"}
@@ -0,0 +1,350 @@
1
+ import * as Context from "effect/Context";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Layer from "effect/Layer";
4
+ import * as HttpClient from "effect/unstable/http/HttpClient";
5
+ import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse";
6
+ import { RpcClient, RpcSerialization, } from "effect/unstable/rpc";
7
+ import { effectClass, taggedFunction } from "../../Util/effect.js";
8
+ import { Worker as WorkerCtor, WorkerEnvironment } from "./Worker.js";
9
+ // Context tag carrying the surrounding `RpcWorker` value, so
10
+ // `yield* RpcWorker` inside the impl resolves to the worker itself
11
+ // (mirrors `yield* Worker` semantics inside `Cloudflare.Worker`).
12
+ // Documented as part of the main `RpcWorker` JSDoc below.
13
+ export class RpcWorkerScope extends Context.Service()("Cloudflare.RpcWorker") {
14
+ }
15
+ // Symbol used internally to stash the rpc `RpcGroup` schema on the
16
+ // `effectClass` that `RpcWorker(...)` returns, so `RpcWorker.bind`
17
+ // can recover it when handed the class later.
18
+ const SchemaSymbol = Symbol.for("alchemy.RpcWorker.schema");
19
+ /** @internal helper — exposed as `RpcWorker.bind` below. */
20
+ const bind = (workerEff) => Effect.gen(function* () {
21
+ const schema = workerEff[SchemaSymbol];
22
+ if (!schema) {
23
+ return yield* Effect.die(new Error("RpcWorker.bind: passed value isn't an RpcWorker class — no schema attached."));
24
+ }
25
+ const worker = (yield* workerEff);
26
+ // Register the service binding on the surrounding worker at INIT.
27
+ // Mirrors `Cloudflare.bindWorker` — yielding the class is *not*
28
+ // enough; we need an explicit `self.bind\`${worker}\`(...)` so
29
+ // workerd surfaces the stub on `env` at request time.
30
+ const self = yield* WorkerCtor;
31
+ yield* self.bind `${worker}`({
32
+ bindings: [
33
+ {
34
+ type: "service",
35
+ name: worker.LogicalId,
36
+ service: worker.workerName,
37
+ },
38
+ ],
39
+ });
40
+ // Build a per-call factory that wraps the Cloudflare service-
41
+ // binding stub (Promise-based fetch) into an Effect `HttpClient`,
42
+ // then `RpcClient.make` over that transport. Each call gets its
43
+ // own `RpcClient` because Cloudflare rejects I/O objects (the
44
+ // stub.fetch body) that were created on a previous request.
45
+ const makeFreshClient = Effect.gen(function* () {
46
+ const env = yield* WorkerEnvironment;
47
+ const stub = env[worker.LogicalId];
48
+ const httpClient = HttpClient.make((req) => Effect.promise((signal) => stub.fetch(new Request(req.url, {
49
+ method: req.method,
50
+ headers: new Headers(req.headers),
51
+ body: req.body?.body ?? undefined,
52
+ signal,
53
+ }))).pipe(Effect.map((res) => HttpClientResponse.fromWeb(req, res))));
54
+ const protocol = RpcClient.layerProtocolHttp({
55
+ url: "http://alchemy-rpc-worker/",
56
+ }).pipe(Layer.provide(RpcSerialization.layerNdjson), Layer.provide(Layer.succeed(HttpClient.HttpClient, httpClient)));
57
+ return yield* RpcClient.make(schema).pipe(Effect.provide(protocol));
58
+ });
59
+ // Return a Proxy that LOOKS like an `RpcClient<Rpcs>` but defers
60
+ // the actual `RpcClient` construction to call time. Mirrors
61
+ // `makeRpcStub` from `./Rpc.ts`: each method invocation builds a
62
+ // fresh client, runs the call inside `Effect.scoped`, and tears
63
+ // the client's scope down with the call. From the consumer's
64
+ // perspective this is a normal `RpcClient`:
65
+ //
66
+ // const tasks = yield* Cloudflare.RpcWorker.bind(TaskWorker);
67
+ // yield* tasks.getTask({ id: "abc" });
68
+ return new Proxy({}, {
69
+ get: (_target, method) => {
70
+ if (typeof method !== "string")
71
+ return undefined;
72
+ return (...args) => Effect.gen(function* () {
73
+ const client = yield* makeFreshClient;
74
+ const fn = client[method];
75
+ return yield* fn(...args);
76
+ }).pipe(Effect.scoped);
77
+ },
78
+ });
79
+ });
80
+ /**
81
+ * `RpcWorker` is a thin sugar over {@link Worker} for the common case
82
+ * where a worker's entire `fetch` surface is a typed Effect `RpcGroup`.
83
+ * It takes the rpc `schema` directly in props alongside `main`, and
84
+ * accepts an init Effect that returns the already-piped
85
+ * `RpcServer.toHttpEffect(...)`-producing Effect (no `{ fetch }`
86
+ * wrapper) — the wrapper plugs it into the worker's `fetch` for you.
87
+ *
88
+ * Functionally identical to writing `Cloudflare.Worker(...)` with
89
+ * `return { fetch: RpcServer.toHttpEffect(schema).pipe(...) }`; use
90
+ * whichever style you prefer.
91
+ *
92
+ * The class form (`class X extends Cloudflare.RpcWorker<X>()(...)`)
93
+ * carries `Self` through the result type as `Rpc<Self>`, so other
94
+ * workers binding to this one see the rpc shape pinned to `Self`.
95
+ *
96
+ * @resource
97
+ *
98
+ * @section Defining the rpc group
99
+ * @example Pure schema description
100
+ * The rpc group and its schemas live outside any worker so both the
101
+ * server (`RpcWorker`) and any consumers (`RpcClient.make` /
102
+ * `RpcDurableObjectNamespace`) import the same value.
103
+ * ```typescript
104
+ * import * as Schema from "effect/Schema";
105
+ * import { Rpc, RpcGroup } from "effect/unstable/rpc";
106
+ *
107
+ * export class TaskNotFound extends Schema.TaggedClass<TaskNotFound>()(
108
+ * "TaskNotFound",
109
+ * { id: Schema.String },
110
+ * ) {}
111
+ *
112
+ * const getTask = Rpc.make("getTask", {
113
+ * payload: { id: Schema.String },
114
+ * success: Schema.String,
115
+ * error: TaskNotFound,
116
+ * });
117
+ *
118
+ * export class TaskRpcs extends RpcGroup.make(getTask) {}
119
+ * ```
120
+ *
121
+ * @section Implementing the worker
122
+ * @example Class form (recommended)
123
+ * Mirrors `Cloudflare.Worker<Self>()(...)` — `class X extends ...`
124
+ * works the same. The init Effect builds a handlers `Layer` from the
125
+ * group and returns the `RpcServer.toHttpEffect(schema)`-piped Effect
126
+ * directly.
127
+ * ```typescript
128
+ * import * as Cloudflare from "alchemy/Cloudflare";
129
+ * import * as Effect from "effect/Effect";
130
+ * import * as Layer from "effect/Layer";
131
+ * import { RpcSerialization, RpcServer } from "effect/unstable/rpc";
132
+ * import { TaskRpcs } from "./rpcs.ts";
133
+ *
134
+ * export default class Worker extends Cloudflare.RpcWorker<Worker>()(
135
+ * "Worker",
136
+ * { main: import.meta.filename, schema: TaskRpcs },
137
+ * Effect.gen(function* () {
138
+ * const handlers = TaskRpcs.toLayer({
139
+ * getTask: ({ id }) => Effect.succeed(`task-${id}`),
140
+ * });
141
+ * return RpcServer.toHttpEffect(TaskRpcs).pipe(
142
+ * Effect.provide(Layer.mergeAll(handlers, RpcSerialization.layerJson)),
143
+ * );
144
+ * }),
145
+ * ) {}
146
+ * ```
147
+ *
148
+ * @example NDJSON for streaming rpcs
149
+ * If any rpc in the group is a streaming rpc, the wire serialization
150
+ * must be `RpcSerialization.layerNdjson` — streaming rpcs need
151
+ * newline framing on the wire.
152
+ * ```typescript
153
+ * return RpcServer.toHttpEffect(ChatRpcs).pipe(
154
+ * Effect.provide(handlers),
155
+ * Effect.provide(RpcSerialization.layerNdjson),
156
+ * );
157
+ * ```
158
+ *
159
+ * @section Modular form: separate the class from its runtime
160
+ * @example Class declaration with no impl + `static make(impl)`
161
+ * The inline class form above bundles the runtime into the class
162
+ * declaration. The two-arg form `(id, props)` declares the class
163
+ * as a pure tagged identifier; provide the runtime separately via
164
+ * `WorkerClass.make(impl)` so consumers can import the class for
165
+ * binding without pulling the host's runtime into their bundle.
166
+ * ```typescript
167
+ * export class TaskWorker extends Cloudflare.RpcWorker<TaskWorker>()(
168
+ * "TaskWorker",
169
+ * { main: import.meta.filename, schema: TaskRpcs },
170
+ * ) {}
171
+ *
172
+ * // Only the host script imports this default export; consumers
173
+ * // import the class above for `RpcWorker.bind(TaskWorker)`.
174
+ * export default TaskWorker.make(
175
+ * Effect.gen(function* () {
176
+ * const handlers = TaskRpcs.toLayer({
177
+ * getTask: ({ id }) => Effect.succeed(`task-${id}`),
178
+ * });
179
+ * return RpcServer.toHttpEffect(TaskRpcs).pipe(
180
+ * Effect.provide(Layer.mergeAll(handlers, RpcSerialization.layerJson)),
181
+ * );
182
+ * }),
183
+ * );
184
+ * ```
185
+ *
186
+ * @section Hosting a Durable Object for cross-script binding
187
+ * @example `RpcWorker<Self, Deps>()` declares published DOs
188
+ * The optional second type argument `Deps` mirrors
189
+ * `Cloudflare.Worker<Self, Bindings, Deps>` — it declares the DOs
190
+ * this Worker publishes for cross-script binding. With `Counter`
191
+ * named in `Deps`, any other Worker can write
192
+ * `Counter.from(TaskWorker)` and have it type-check.
193
+ * ```typescript
194
+ * import { Counter } from "./counter.ts";
195
+ *
196
+ * export class TaskWorker extends Cloudflare.RpcWorker<TaskWorker, Counter>()(
197
+ * "TaskWorker",
198
+ * { main: import.meta.filename, schema: TaskRpcs },
199
+ * ) {}
200
+ * ```
201
+ * See {@link RpcDurableObjectNamespace} for the consumer side
202
+ * (`Counter.from(TaskWorker)`).
203
+ *
204
+ * @section Binding it from another worker
205
+ * @example `Cloudflare.RpcWorker.bind(WorkerClass)`
206
+ * Inside another worker's init, `RpcWorker.bind(WorkerClass)`
207
+ * registers the service binding on the surrounding worker and returns
208
+ * a typed `RpcClient` you can call directly from any per-request
209
+ * handler. Internally each method invocation builds a fresh underlying
210
+ * client (because Cloudflare rejects cross-request reuse of the
211
+ * stub I/O), but that's hidden behind a Proxy so the consumer sees a
212
+ * normal `RpcClient`.
213
+ * ```typescript
214
+ * import TaskWorker from "./task-worker.ts";
215
+ *
216
+ * export default class Caller extends Cloudflare.RpcWorker<Caller>()(
217
+ * "Caller",
218
+ * { main: import.meta.filename, schema: CallerRpcs },
219
+ * Effect.gen(function* () {
220
+ * // INIT: register binding, get the typed client
221
+ * const tasks = yield* Cloudflare.RpcWorker.bind(TaskWorker);
222
+ *
223
+ * const handlers = CallerRpcs.toLayer({
224
+ * // PER-REQUEST: just call methods directly
225
+ * proxyGetTask: ({ id }) => tasks.getTask({ id }),
226
+ * });
227
+ * return RpcServer.toHttpEffect(CallerRpcs).pipe(
228
+ * Effect.provide(Layer.mergeAll(handlers, RpcSerialization.layerJson)),
229
+ * );
230
+ * }),
231
+ * ) {}
232
+ * ```
233
+ *
234
+ * @section Driving it from a test
235
+ * @example `Test.make` + `RpcClient.make`
236
+ * The same `RpcGroup` drives a typed client. `Test.make` deploys the
237
+ * stack once for the file; each test yields the deploy handle for its
238
+ * URL and calls procedures directly.
239
+ * ```typescript
240
+ * import { expect } from "@effect/vitest";
241
+ * import * as Cloudflare from "alchemy/Cloudflare";
242
+ * import * as Test from "alchemy/Test/Vitest";
243
+ * import * as Effect from "effect/Effect";
244
+ * import * as Layer from "effect/Layer";
245
+ * import * as Schedule from "effect/Schedule";
246
+ * import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
247
+ * import * as RpcClient from "effect/unstable/rpc/RpcClient";
248
+ * import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization";
249
+ * import Stack from "../alchemy.run.ts";
250
+ * import { TaskRpcs } from "../src/rpcs.ts";
251
+ *
252
+ * const { test, beforeAll, afterAll, deploy, destroy } = Test.make({
253
+ * providers: Cloudflare.providers(),
254
+ * });
255
+ * const stack = beforeAll(deploy(Stack));
256
+ * afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack));
257
+ *
258
+ * const layer = (url: string) =>
259
+ * RpcClient.layerProtocolHttp({ url }).pipe(
260
+ * Layer.provide(FetchHttpClient.layer),
261
+ * Layer.provide(
262
+ * Layer.succeed(RpcSerialization.RpcSerialization, RpcSerialization.json),
263
+ * ),
264
+ * );
265
+ *
266
+ * test(
267
+ * "getTask",
268
+ * Effect.gen(function* () {
269
+ * const { url } = yield* stack;
270
+ * yield* Effect.gen(function* () {
271
+ * const client = yield* RpcClient.make(TaskRpcs);
272
+ * const result = yield* client
273
+ * .getTask({ id: "abc" })
274
+ * .pipe(Effect.retry({ schedule: Schedule.exponential("500 millis"), times: 5 }));
275
+ * expect(result).toBe("task-abc");
276
+ * }).pipe(Effect.scoped, Effect.provide(layer(url)));
277
+ * }),
278
+ * );
279
+ * ```
280
+ *
281
+ * @section Yielding the surrounding worker from inside the impl
282
+ * @example `yield* RpcWorker` inside the init effect
283
+ * Mirrors `yield* DurableObjectNamespace` — yield the tag to access
284
+ * the surrounding worker.
285
+ * ```typescript
286
+ * Effect.gen(function* () {
287
+ * const self = yield* Cloudflare.RpcWorker;
288
+ * });
289
+ * ```
290
+ */
291
+ export const RpcWorker = (() => {
292
+ const fn = (...args) => {
293
+ // Class-form: zero args returns the inner builder. Inner-arg arity
294
+ // distinguishes modular (`(id, props)`, no impl — `static make(impl)`
295
+ // provides the runtime) from inline-impl (`(id, props, impl)`).
296
+ if (args.length === 0) {
297
+ return (...inner) => {
298
+ if (inner.length === 2) {
299
+ const [id, props] = inner;
300
+ return buildModular(id, props);
301
+ }
302
+ const [id, props, impl] = inner;
303
+ return build(id, props, impl);
304
+ };
305
+ }
306
+ // Bare form: `(name, props, impl)`.
307
+ const [id, props, impl] = args;
308
+ return build(id, props, impl);
309
+ };
310
+ const tagged = taggedFunction(RpcWorkerScope, fn);
311
+ tagged.bind = bind;
312
+ return tagged;
313
+ })();
314
+ const wrapImpl = (impl) =>
315
+ // The user's inner Effect resolves to `HttpEffect`; the underlying
316
+ // `Cloudflare.Worker` expects `{ fetch: HttpEffect }`. Box it.
317
+ Effect.map(impl, (fetch) => ({ fetch }));
318
+ const buildModular = (id, props) => {
319
+ const { schema, ...workerProps } = props;
320
+ // Delegate to `Cloudflare.Worker<Self>()(id, props)` (modular form)
321
+ // so we inherit its `static make(impl)` plumbing for free. We just
322
+ // wrap the user's HttpEffect-returning impl into the `{ fetch }`
323
+ // shape `Cloudflare.Worker` expects, and stash the rpc schema on
324
+ // the class so `RpcWorker.bind(WorkerClass)` can recover it.
325
+ const Underlying = WorkerCtor()(id, workerProps);
326
+ const klass = class extends effectClass(Underlying.asEffect()) {
327
+ static make = (impl) => Underlying.make(wrapImpl(impl));
328
+ };
329
+ klass[SchemaSymbol] = schema;
330
+ return klass;
331
+ };
332
+ const build = (id, props, impl) => {
333
+ const { schema, ...workerProps } = props;
334
+ // Wrap the user's HttpEffect-returning Effect into the `{ fetch }`
335
+ // shape `Cloudflare.Worker` expects.
336
+ const wrappedImpl = Effect.map(impl, (fetch) => ({ fetch }));
337
+ // Delegate registration / binding metadata to the underlying
338
+ // `Cloudflare.Worker`. The returned `effectClass`, when yielded,
339
+ // produces the standard `Worker` resource (so `worker.url`,
340
+ // `worker.workerName`, etc. all work as usual).
341
+ const underlying = WorkerCtor()(id, workerProps, wrappedImpl);
342
+ // Re-wrap as our own `effectClass` so we can stash the rpc schema
343
+ // on the class for `RpcWorker.bind` to recover later. (Re-using
344
+ // `effectClass` here means `class X extends RpcWorker<X>()(...)`
345
+ // still works.)
346
+ const klass = effectClass(underlying.asEffect());
347
+ klass[SchemaSymbol] = schema;
348
+ return klass;
349
+ };
350
+ //# source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