alchemy 2.0.0-beta.43 → 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 (561) hide show
  1. package/bin/cli.js +18 -5
  2. package/bin/exec.js +381 -240
  3. package/bin/exec.js.map +1 -1
  4. package/lib/AWS/Lambda/Function.d.ts +17 -0
  5. package/lib/AWS/Lambda/Function.d.ts.map +1 -1
  6. package/lib/AWS/Lambda/Function.js +61 -16
  7. package/lib/AWS/Lambda/Function.js.map +1 -1
  8. package/lib/AWS/Providers.d.ts +2 -1
  9. package/lib/AWS/Providers.d.ts.map +1 -1
  10. package/lib/AWS/Providers.js +3 -1
  11. package/lib/AWS/Providers.js.map +1 -1
  12. package/lib/Apply.js +17 -1
  13. package/lib/Apply.js.map +1 -1
  14. package/lib/Auth/AuthProvider.d.ts.map +1 -1
  15. package/lib/Auth/AuthProvider.js +24 -6
  16. package/lib/Auth/AuthProvider.js.map +1 -1
  17. package/lib/Auth/Credentials.d.ts.map +1 -1
  18. package/lib/Auth/Credentials.js +3 -3
  19. package/lib/Auth/Credentials.js.map +1 -1
  20. package/lib/Auth/Lock.js +2 -2
  21. package/lib/Auth/Lock.js.map +1 -1
  22. package/lib/Bundle/Bundle.d.ts +11 -0
  23. package/lib/Bundle/Bundle.d.ts.map +1 -1
  24. package/lib/Bundle/Bundle.js +19 -12
  25. package/lib/Bundle/Bundle.js.map +1 -1
  26. package/lib/Bundle/BundleAnalyzerPlugin.d.ts +25 -0
  27. package/lib/Bundle/BundleAnalyzerPlugin.d.ts.map +1 -0
  28. package/lib/Bundle/BundleAnalyzerPlugin.js +16 -0
  29. package/lib/Bundle/BundleAnalyzerPlugin.js.map +1 -0
  30. package/lib/Bundle/RawPlugin.d.ts +36 -0
  31. package/lib/Bundle/RawPlugin.d.ts.map +1 -0
  32. package/lib/Bundle/RawPlugin.js +80 -0
  33. package/lib/Bundle/RawPlugin.js.map +1 -0
  34. package/lib/Bundle/index.d.ts +2 -0
  35. package/lib/Bundle/index.d.ts.map +1 -1
  36. package/lib/Bundle/index.js +2 -0
  37. package/lib/Bundle/index.js.map +1 -1
  38. package/lib/Cli/commands/_shared.d.ts +13 -1
  39. package/lib/Cli/commands/_shared.d.ts.map +1 -1
  40. package/lib/Cli/commands/_shared.js +33 -2
  41. package/lib/Cli/commands/_shared.js.map +1 -1
  42. package/lib/Cli/commands/dev.d.ts +3 -2
  43. package/lib/Cli/commands/dev.d.ts.map +1 -1
  44. package/lib/Cli/commands/dev.js +19 -2
  45. package/lib/Cli/commands/dev.js.map +1 -1
  46. package/lib/Cli/commands/login.d.ts.map +1 -1
  47. package/lib/Cli/commands/login.js +19 -5
  48. package/lib/Cli/commands/login.js.map +1 -1
  49. package/lib/Cli/commands/profile.d.ts.map +1 -1
  50. package/lib/Cli/commands/profile.js +7 -27
  51. package/lib/Cli/commands/profile.js.map +1 -1
  52. package/lib/Cli/exec.d.ts.map +1 -1
  53. package/lib/Cli/exec.js +2 -1
  54. package/lib/Cli/exec.js.map +1 -1
  55. package/lib/Cli/main.d.ts.map +1 -1
  56. package/lib/Cli/main.js +0 -2
  57. package/lib/Cli/main.js.map +1 -1
  58. package/lib/Cloudflare/AiGateway/AiGateway.d.ts +0 -2
  59. package/lib/Cloudflare/AiGateway/AiGateway.d.ts.map +1 -1
  60. package/lib/Cloudflare/AiGateway/AiGateway.js +2 -4
  61. package/lib/Cloudflare/AiGateway/AiGateway.js.map +1 -1
  62. package/lib/Cloudflare/BrowserRendering/BrowserRendering.d.ts +116 -0
  63. package/lib/Cloudflare/BrowserRendering/BrowserRendering.d.ts.map +1 -0
  64. package/lib/Cloudflare/BrowserRendering/BrowserRendering.js +92 -0
  65. package/lib/Cloudflare/BrowserRendering/BrowserRendering.js.map +1 -0
  66. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.d.ts +55 -0
  67. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.d.ts.map +1 -0
  68. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.js +55 -0
  69. package/lib/Cloudflare/BrowserRendering/BrowserRenderingBinding.js.map +1 -0
  70. package/lib/Cloudflare/BrowserRendering/index.d.ts +3 -0
  71. package/lib/Cloudflare/BrowserRendering/index.d.ts.map +1 -0
  72. package/lib/Cloudflare/BrowserRendering/index.js +3 -0
  73. package/lib/Cloudflare/BrowserRendering/index.js.map +1 -0
  74. package/lib/Cloudflare/Container/Container.d.ts +3 -3
  75. package/lib/Cloudflare/Container/Container.js +3 -3
  76. package/lib/Cloudflare/Container/StartContainer.d.ts.map +1 -1
  77. package/lib/Cloudflare/Container/StartContainer.js.map +1 -1
  78. package/lib/Cloudflare/D1/D1Database.d.ts +1 -0
  79. package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
  80. package/lib/Cloudflare/D1/D1Database.js +2 -1
  81. package/lib/Cloudflare/D1/D1Database.js.map +1 -1
  82. package/lib/Cloudflare/D1/D1DatabaseBinding.js +1 -1
  83. package/lib/Cloudflare/D1/D1DatabaseBinding.js.map +1 -1
  84. package/lib/Cloudflare/Fetcher.d.ts.map +1 -1
  85. package/lib/Cloudflare/Fetcher.js +0 -2
  86. package/lib/Cloudflare/Fetcher.js.map +1 -1
  87. package/lib/Cloudflare/Hyperdrive/Hyperdrive.d.ts +1 -0
  88. package/lib/Cloudflare/Hyperdrive/Hyperdrive.d.ts.map +1 -1
  89. package/lib/Cloudflare/Hyperdrive/Hyperdrive.js +3 -0
  90. package/lib/Cloudflare/Hyperdrive/Hyperdrive.js.map +1 -1
  91. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.d.ts +3 -2
  92. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.d.ts.map +1 -1
  93. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.js +32 -33
  94. package/lib/Cloudflare/Hyperdrive/HyperdriveBinding.js.map +1 -1
  95. package/lib/Cloudflare/KV/KVNamespace.d.ts +1 -0
  96. package/lib/Cloudflare/KV/KVNamespace.d.ts.map +1 -1
  97. package/lib/Cloudflare/KV/KVNamespace.js +2 -0
  98. package/lib/Cloudflare/KV/KVNamespace.js.map +1 -1
  99. package/lib/Cloudflare/Local.d.ts +2 -0
  100. package/lib/Cloudflare/Local.d.ts.map +1 -0
  101. package/lib/Cloudflare/Local.js +9 -0
  102. package/lib/Cloudflare/Local.js.map +1 -0
  103. package/lib/Cloudflare/Providers.d.ts +2 -1
  104. package/lib/Cloudflare/Providers.d.ts.map +1 -1
  105. package/lib/Cloudflare/Providers.js +23 -17
  106. package/lib/Cloudflare/Providers.js.map +1 -1
  107. package/lib/Cloudflare/Queue/Queue.d.ts +1 -0
  108. package/lib/Cloudflare/Queue/Queue.d.ts.map +1 -1
  109. package/lib/Cloudflare/Queue/Queue.js +1 -0
  110. package/lib/Cloudflare/Queue/Queue.js.map +1 -1
  111. package/lib/Cloudflare/Queue/QueueConsumer.d.ts +2 -1
  112. package/lib/Cloudflare/Queue/QueueConsumer.d.ts.map +1 -1
  113. package/lib/Cloudflare/Queue/QueueConsumer.js +11 -3
  114. package/lib/Cloudflare/Queue/QueueConsumer.js.map +1 -1
  115. package/lib/Cloudflare/Queue/QueueEventSource.d.ts +30 -4
  116. package/lib/Cloudflare/Queue/QueueEventSource.d.ts.map +1 -1
  117. package/lib/Cloudflare/Queue/QueueEventSource.js +22 -1
  118. package/lib/Cloudflare/Queue/QueueEventSource.js.map +1 -1
  119. package/lib/Cloudflare/R2/R2Bucket.d.ts +1 -0
  120. package/lib/Cloudflare/R2/R2Bucket.d.ts.map +1 -1
  121. package/lib/Cloudflare/R2/R2Bucket.js +18 -0
  122. package/lib/Cloudflare/R2/R2Bucket.js.map +1 -1
  123. package/lib/Cloudflare/SecretsStore/Secret.d.ts.map +1 -1
  124. package/lib/Cloudflare/SecretsStore/Secret.js +13 -34
  125. package/lib/Cloudflare/SecretsStore/Secret.js.map +1 -1
  126. package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts +3 -2
  127. package/lib/Cloudflare/SecretsStore/SecretBinding.d.ts.map +1 -1
  128. package/lib/Cloudflare/SecretsStore/SecretBinding.js +3 -2
  129. package/lib/Cloudflare/SecretsStore/SecretBinding.js.map +1 -1
  130. package/lib/Cloudflare/StateStore/Api.d.ts +5 -13
  131. package/lib/Cloudflare/StateStore/Api.d.ts.map +1 -1
  132. package/lib/Cloudflare/StateStore/Api.js +14 -8
  133. package/lib/Cloudflare/StateStore/Api.js.map +1 -1
  134. package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
  135. package/lib/Cloudflare/StateStore/State.js +45 -9
  136. package/lib/Cloudflare/StateStore/State.js.map +1 -1
  137. package/lib/Cloudflare/StateStore/Store.d.ts.map +1 -1
  138. package/lib/Cloudflare/StateStore/Store.js +5 -2
  139. package/lib/Cloudflare/StateStore/Store.js.map +1 -1
  140. package/lib/Cloudflare/VpcService/VpcService.d.ts +2 -2
  141. package/lib/Cloudflare/VpcService/VpcService.d.ts.map +1 -1
  142. package/lib/Cloudflare/Website/StaticSite.d.ts +5 -5
  143. package/lib/Cloudflare/Website/StaticSite.d.ts.map +1 -1
  144. package/lib/Cloudflare/Website/StaticSite.js +3 -0
  145. package/lib/Cloudflare/Website/StaticSite.js.map +1 -1
  146. package/lib/Cloudflare/Website/Vite.d.ts +5 -5
  147. package/lib/Cloudflare/Website/Vite.d.ts.map +1 -1
  148. package/lib/Cloudflare/Website/Vite.js.map +1 -1
  149. package/lib/Cloudflare/Workers/Assets.d.ts.map +1 -1
  150. package/lib/Cloudflare/Workers/Assets.js +1 -1
  151. package/lib/Cloudflare/Workers/Assets.js.map +1 -1
  152. package/lib/Cloudflare/Workers/DurableObjectBridge.d.ts.map +1 -1
  153. package/lib/Cloudflare/Workers/DurableObjectBridge.js +4 -3
  154. package/lib/Cloudflare/Workers/DurableObjectBridge.js.map +1 -1
  155. package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts +183 -6
  156. package/lib/Cloudflare/Workers/DurableObjectNamespace.d.ts.map +1 -1
  157. package/lib/Cloudflare/Workers/DurableObjectNamespace.js +279 -76
  158. package/lib/Cloudflare/Workers/DurableObjectNamespace.js.map +1 -1
  159. package/lib/Cloudflare/Workers/HttpServer.d.ts +6 -4
  160. package/lib/Cloudflare/Workers/HttpServer.d.ts.map +1 -1
  161. package/lib/Cloudflare/Workers/HttpServer.js +20 -15
  162. package/lib/Cloudflare/Workers/HttpServer.js.map +1 -1
  163. package/lib/Cloudflare/Workers/InferEnv.d.ts +3 -2
  164. package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
  165. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts +19 -3
  166. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
  167. package/lib/Cloudflare/Workers/LocalWorkerProvider.js +458 -21
  168. package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
  169. package/lib/Cloudflare/Workers/Rpc.d.ts +16 -0
  170. package/lib/Cloudflare/Workers/Rpc.d.ts.map +1 -1
  171. package/lib/Cloudflare/Workers/Rpc.js +22 -0
  172. package/lib/Cloudflare/Workers/Rpc.js.map +1 -1
  173. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.d.ts +285 -0
  174. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.d.ts.map +1 -0
  175. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.js +288 -0
  176. package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.js.map +1 -0
  177. package/lib/Cloudflare/Workers/RpcWorker.d.ts +305 -0
  178. package/lib/Cloudflare/Workers/RpcWorker.d.ts.map +1 -0
  179. package/lib/Cloudflare/Workers/RpcWorker.js +350 -0
  180. package/lib/Cloudflare/Workers/RpcWorker.js.map +1 -0
  181. package/lib/Cloudflare/Workers/Vite.d.ts +1 -1
  182. package/lib/Cloudflare/Workers/Vite.d.ts.map +1 -1
  183. package/lib/Cloudflare/Workers/Vite.js +2 -1
  184. package/lib/Cloudflare/Workers/Vite.js.map +1 -1
  185. package/lib/Cloudflare/Workers/Worker.d.ts +69 -37
  186. package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
  187. package/lib/Cloudflare/Workers/Worker.js +171 -51
  188. package/lib/Cloudflare/Workers/Worker.js.map +1 -1
  189. package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts +1 -1
  190. package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts.map +1 -1
  191. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js +158 -97
  192. package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
  193. package/lib/Cloudflare/Workers/WorkerBinding.d.ts +11 -23
  194. package/lib/Cloudflare/Workers/WorkerBinding.d.ts.map +1 -1
  195. package/lib/Cloudflare/Workers/WorkerBinding.js +3 -0
  196. package/lib/Cloudflare/Workers/WorkerBinding.js.map +1 -1
  197. package/lib/Cloudflare/Workers/WorkerBridge.d.ts.map +1 -1
  198. package/lib/Cloudflare/Workers/WorkerBridge.js +8 -7
  199. package/lib/Cloudflare/Workers/WorkerBridge.js.map +1 -1
  200. package/lib/Cloudflare/Workers/WorkerBundle.d.ts +1 -2
  201. package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
  202. package/lib/Cloudflare/Workers/WorkerBundle.js +7 -7
  203. package/lib/Cloudflare/Workers/WorkerBundle.js.map +1 -1
  204. package/lib/Cloudflare/Workers/WorkerRuntimeContext.d.ts.map +1 -1
  205. package/lib/Cloudflare/Workers/WorkerRuntimeContext.js +9 -10
  206. package/lib/Cloudflare/Workers/WorkerRuntimeContext.js.map +1 -1
  207. package/lib/Cloudflare/Workers/Workflow.d.ts +5 -3
  208. package/lib/Cloudflare/Workers/Workflow.d.ts.map +1 -1
  209. package/lib/Cloudflare/Workers/Workflow.js +19 -1
  210. package/lib/Cloudflare/Workers/Workflow.js.map +1 -1
  211. package/lib/Cloudflare/Workers/index.d.ts +2 -0
  212. package/lib/Cloudflare/Workers/index.d.ts.map +1 -1
  213. package/lib/Cloudflare/Workers/index.js +2 -0
  214. package/lib/Cloudflare/Workers/index.js.map +1 -1
  215. package/lib/Cloudflare/Zaraz/ZarazConfig.d.ts +184 -0
  216. package/lib/Cloudflare/Zaraz/ZarazConfig.d.ts.map +1 -0
  217. package/lib/Cloudflare/Zaraz/ZarazConfig.js +216 -0
  218. package/lib/Cloudflare/Zaraz/ZarazConfig.js.map +1 -0
  219. package/lib/Cloudflare/Zaraz/ZarazEventTypes.d.ts +188 -0
  220. package/lib/Cloudflare/Zaraz/ZarazEventTypes.d.ts.map +1 -0
  221. package/lib/Cloudflare/Zaraz/ZarazEventTypes.js +4 -0
  222. package/lib/Cloudflare/Zaraz/ZarazEventTypes.js.map +1 -0
  223. package/lib/Cloudflare/Zaraz/index.d.ts +3 -0
  224. package/lib/Cloudflare/Zaraz/index.d.ts.map +1 -0
  225. package/lib/Cloudflare/Zaraz/index.js +2 -0
  226. package/lib/Cloudflare/Zaraz/index.js.map +1 -0
  227. package/lib/Cloudflare/index.d.ts +2 -0
  228. package/lib/Cloudflare/index.d.ts.map +1 -1
  229. package/lib/Cloudflare/index.js +2 -0
  230. package/lib/Cloudflare/index.js.map +1 -1
  231. package/lib/Dependencies.d.ts +10 -0
  232. package/lib/Dependencies.d.ts.map +1 -0
  233. package/lib/Dependencies.js +1 -0
  234. package/lib/Dependencies.js.map +1 -0
  235. package/lib/Deploy.d.ts +2 -1
  236. package/lib/Deploy.d.ts.map +1 -1
  237. package/lib/Deploy.js +2 -2
  238. package/lib/Deploy.js.map +1 -1
  239. package/lib/Diff.d.ts +11 -0
  240. package/lib/Diff.d.ts.map +1 -1
  241. package/lib/Diff.js +11 -0
  242. package/lib/Diff.js.map +1 -1
  243. package/lib/Input.d.ts +2 -1
  244. package/lib/Input.d.ts.map +1 -1
  245. package/lib/KeyPair.d.ts +77 -0
  246. package/lib/KeyPair.d.ts.map +1 -0
  247. package/lib/KeyPair.js +102 -0
  248. package/lib/KeyPair.js.map +1 -0
  249. package/lib/Local/RpcProvider.d.ts +56 -0
  250. package/lib/Local/RpcProvider.d.ts.map +1 -0
  251. package/lib/Local/RpcProvider.js +83 -0
  252. package/lib/Local/RpcProvider.js.map +1 -0
  253. package/lib/Local/RpcProviderProxy.d.ts +19 -0
  254. package/lib/Local/RpcProviderProxy.d.ts.map +1 -0
  255. package/lib/Local/RpcProviderProxy.js +48 -0
  256. package/lib/Local/RpcProviderProxy.js.map +1 -0
  257. package/lib/Local/RpcSerialization.d.ts +34 -0
  258. package/lib/Local/RpcSerialization.d.ts.map +1 -0
  259. package/lib/Local/RpcSerialization.js +120 -0
  260. package/lib/Local/RpcSerialization.js.map +1 -0
  261. package/lib/Local/RpcServer.d.ts +63 -0
  262. package/lib/Local/RpcServer.d.ts.map +1 -0
  263. package/lib/Local/RpcServer.js +72 -0
  264. package/lib/Local/RpcServer.js.map +1 -0
  265. package/lib/Local/RpcServerBun.d.ts +3 -0
  266. package/lib/Local/RpcServerBun.d.ts.map +1 -0
  267. package/lib/Local/RpcServerBun.js +47 -0
  268. package/lib/Local/RpcServerBun.js.map +1 -0
  269. package/lib/Local/RpcServerEnvironment.d.ts +20 -0
  270. package/lib/Local/RpcServerEnvironment.d.ts.map +1 -0
  271. package/lib/Local/RpcServerEnvironment.js +22 -0
  272. package/lib/Local/RpcServerEnvironment.js.map +1 -0
  273. package/lib/Local/RpcServerNode.d.ts +3 -0
  274. package/lib/Local/RpcServerNode.d.ts.map +1 -0
  275. package/lib/Local/RpcServerNode.js +43 -0
  276. package/lib/Local/RpcServerNode.js.map +1 -0
  277. package/lib/Local/RpcServerSession.d.ts +27 -0
  278. package/lib/Local/RpcServerSession.d.ts.map +1 -0
  279. package/lib/Local/RpcServerSession.js +68 -0
  280. package/lib/Local/RpcServerSession.js.map +1 -0
  281. package/lib/Local/RpcSpawner.d.ts +21 -0
  282. package/lib/Local/RpcSpawner.d.ts.map +1 -0
  283. package/lib/Local/RpcSpawner.js +132 -0
  284. package/lib/Local/RpcSpawner.js.map +1 -0
  285. package/lib/Neon/Project.d.ts.map +1 -1
  286. package/lib/Neon/Project.js +14 -3
  287. package/lib/Neon/Project.js.map +1 -1
  288. package/lib/Output.d.ts.map +1 -1
  289. package/lib/Output.js +9 -2
  290. package/lib/Output.js.map +1 -1
  291. package/lib/Phase.d.ts +2 -1
  292. package/lib/Phase.d.ts.map +1 -1
  293. package/lib/Phase.js +6 -1
  294. package/lib/Phase.js.map +1 -1
  295. package/lib/Plan.d.ts.map +1 -1
  296. package/lib/Plan.js +14 -3
  297. package/lib/Plan.js.map +1 -1
  298. package/lib/Platform.d.ts +8 -6
  299. package/lib/Platform.d.ts.map +1 -1
  300. package/lib/Platform.js +33 -3
  301. package/lib/Platform.js.map +1 -1
  302. package/lib/Random.d.ts.map +1 -1
  303. package/lib/Random.js +9 -14
  304. package/lib/Random.js.map +1 -1
  305. package/lib/RuntimeContext.d.ts +21 -1
  306. package/lib/RuntimeContext.d.ts.map +1 -1
  307. package/lib/RuntimeContext.js +12 -0
  308. package/lib/RuntimeContext.js.map +1 -1
  309. package/lib/Stack.d.ts +3 -3
  310. package/lib/Stack.d.ts.map +1 -1
  311. package/lib/Stack.js.map +1 -1
  312. package/lib/State/HttpStateApi.d.ts +2 -2
  313. package/lib/State/StateEncoding.d.ts +8 -0
  314. package/lib/State/StateEncoding.d.ts.map +1 -1
  315. package/lib/State/StateEncoding.js +55 -5
  316. package/lib/State/StateEncoding.js.map +1 -1
  317. package/lib/Test/Bun.d.ts.map +1 -1
  318. package/lib/Test/Bun.js +0 -2
  319. package/lib/Test/Bun.js.map +1 -1
  320. package/lib/Test/Vitest.d.ts.map +1 -1
  321. package/lib/Test/Vitest.js +0 -2
  322. package/lib/Test/Vitest.js.map +1 -1
  323. package/lib/Util/Duration.d.ts +14 -0
  324. package/lib/Util/Duration.d.ts.map +1 -0
  325. package/lib/Util/Duration.js +18 -0
  326. package/lib/Util/Duration.js.map +1 -0
  327. package/lib/Util/PlatformServices.d.ts +7 -0
  328. package/lib/Util/PlatformServices.d.ts.map +1 -1
  329. package/lib/Util/PlatformServices.js +22 -11
  330. package/lib/Util/PlatformServices.js.map +1 -1
  331. package/lib/Util/camel.d.ts.map +1 -1
  332. package/lib/Util/camel.js +2 -3
  333. package/lib/Util/camel.js.map +1 -1
  334. package/lib/Util/data.d.ts +5 -0
  335. package/lib/Util/data.d.ts.map +1 -1
  336. package/lib/Util/data.js +29 -0
  337. package/lib/Util/data.js.map +1 -1
  338. package/lib/Util/index.d.ts +0 -6
  339. package/lib/Util/index.d.ts.map +1 -1
  340. package/lib/Util/index.js +0 -6
  341. package/lib/Util/index.js.map +1 -1
  342. package/lib/Util/stable.d.ts.map +1 -1
  343. package/lib/Util/stable.js +3 -6
  344. package/lib/Util/stable.js.map +1 -1
  345. package/lib/Util/types.d.ts +3 -1
  346. package/lib/Util/types.d.ts.map +1 -1
  347. package/lib/Util/types.js +5 -1
  348. package/lib/Util/types.js.map +1 -1
  349. package/lib/index.d.ts +2 -3
  350. package/lib/index.d.ts.map +1 -1
  351. package/lib/index.js +1 -3
  352. package/lib/index.js.map +1 -1
  353. package/lib/tsconfig.test.tsbuildinfo +1 -1
  354. package/package.json +22 -23
  355. package/src/AWS/Lambda/Function.ts +87 -34
  356. package/src/AWS/Providers.ts +3 -0
  357. package/src/Apply.ts +18 -1
  358. package/src/Auth/AuthProvider.ts +25 -5
  359. package/src/Auth/Credentials.ts +8 -7
  360. package/src/Auth/Lock.ts +2 -2
  361. package/src/Bundle/Bundle.ts +35 -13
  362. package/src/Bundle/BundleAnalyzerPlugin.ts +33 -0
  363. package/src/Bundle/RawPlugin.ts +82 -0
  364. package/src/Bundle/index.ts +2 -0
  365. package/src/Cli/commands/_shared.ts +47 -4
  366. package/src/Cli/commands/dev.ts +63 -37
  367. package/src/Cli/commands/login.ts +20 -4
  368. package/src/Cli/commands/profile.ts +24 -34
  369. package/src/Cli/exec.ts +12 -7
  370. package/src/Cli/main.ts +0 -3
  371. package/src/Cloudflare/AiGateway/AiGateway.ts +2 -6
  372. package/src/Cloudflare/BrowserRendering/BrowserRendering.ts +132 -0
  373. package/src/Cloudflare/BrowserRendering/BrowserRenderingBinding.ts +137 -0
  374. package/src/Cloudflare/BrowserRendering/index.ts +11 -0
  375. package/src/Cloudflare/Container/Container.ts +3 -3
  376. package/src/Cloudflare/Container/StartContainer.ts +1 -2
  377. package/src/Cloudflare/D1/D1Database.ts +4 -1
  378. package/src/Cloudflare/D1/D1DatabaseBinding.ts +1 -1
  379. package/src/Cloudflare/Fetcher.ts +0 -2
  380. package/src/Cloudflare/Hyperdrive/Hyperdrive.ts +5 -0
  381. package/src/Cloudflare/Hyperdrive/HyperdriveBinding.ts +41 -43
  382. package/src/Cloudflare/KV/KVNamespace.ts +4 -0
  383. package/src/Cloudflare/Local.ts +23 -0
  384. package/src/Cloudflare/Providers.ts +28 -16
  385. package/src/Cloudflare/Queue/Queue.ts +3 -0
  386. package/src/Cloudflare/Queue/QueueConsumer.ts +23 -8
  387. package/src/Cloudflare/Queue/QueueEventSource.ts +33 -5
  388. package/src/Cloudflare/R2/R2Bucket.ts +26 -0
  389. package/src/Cloudflare/SecretsStore/Secret.ts +14 -41
  390. package/src/Cloudflare/SecretsStore/SecretBinding.ts +11 -11
  391. package/src/Cloudflare/StateStore/Api.ts +15 -15
  392. package/src/Cloudflare/StateStore/State.ts +68 -6
  393. package/src/Cloudflare/StateStore/Store.ts +5 -2
  394. package/src/Cloudflare/VpcService/VpcService.ts +2 -2
  395. package/src/Cloudflare/Website/StaticSite.ts +8 -10
  396. package/src/Cloudflare/Website/Vite.ts +4 -7
  397. package/src/Cloudflare/Workers/Assets.ts +1 -1
  398. package/src/Cloudflare/Workers/DurableObjectBridge.ts +7 -5
  399. package/src/Cloudflare/Workers/DurableObjectNamespace.ts +380 -121
  400. package/src/Cloudflare/Workers/HttpServer.ts +31 -25
  401. package/src/Cloudflare/Workers/InferEnv.ts +15 -8
  402. package/src/Cloudflare/Workers/LocalWorkerProvider.ts +609 -22
  403. package/src/Cloudflare/Workers/Rpc.ts +50 -0
  404. package/src/Cloudflare/Workers/RpcDurableObjectNamespace.ts +502 -0
  405. package/src/Cloudflare/Workers/RpcWorker.ts +562 -0
  406. package/src/Cloudflare/Workers/Vite.ts +2 -0
  407. package/src/Cloudflare/Workers/Worker.ts +280 -110
  408. package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +158 -103
  409. package/src/Cloudflare/Workers/WorkerBinding.ts +10 -0
  410. package/src/Cloudflare/Workers/WorkerBridge.ts +10 -9
  411. package/src/Cloudflare/Workers/WorkerBundle.ts +8 -9
  412. package/src/Cloudflare/Workers/WorkerRuntimeContext.ts +8 -15
  413. package/src/Cloudflare/Workers/Workflow.ts +22 -3
  414. package/src/Cloudflare/Workers/index.ts +2 -0
  415. package/src/Cloudflare/Zaraz/ZarazConfig.ts +403 -0
  416. package/src/Cloudflare/Zaraz/ZarazEventTypes.ts +257 -0
  417. package/src/Cloudflare/Zaraz/index.ts +25 -0
  418. package/src/Cloudflare/index.ts +2 -0
  419. package/src/Dependencies.ts +10 -0
  420. package/src/Deploy.ts +3 -1
  421. package/src/Diff.ts +13 -0
  422. package/src/Input.ts +2 -0
  423. package/src/KeyPair.ts +146 -0
  424. package/src/Local/RpcProvider.ts +146 -0
  425. package/src/Local/RpcProviderProxy.ts +86 -0
  426. package/src/Local/RpcSerialization.ts +225 -0
  427. package/src/Local/RpcServer.ts +138 -0
  428. package/src/Local/RpcServerBun.ts +59 -0
  429. package/src/Local/RpcServerEnvironment.ts +55 -0
  430. package/src/Local/RpcServerNode.ts +58 -0
  431. package/src/Local/RpcServerSession.ts +87 -0
  432. package/src/Local/RpcSpawner.ts +196 -0
  433. package/src/Neon/Project.ts +16 -3
  434. package/src/Output.ts +8 -2
  435. package/src/Phase.ts +8 -0
  436. package/src/Plan.ts +16 -3
  437. package/src/Platform.ts +74 -27
  438. package/src/Random.ts +22 -27
  439. package/src/RuntimeContext.ts +23 -1
  440. package/src/Stack.ts +3 -3
  441. package/src/State/StateEncoding.ts +58 -7
  442. package/src/Test/Bun.ts +0 -3
  443. package/src/Test/Vitest.ts +0 -3
  444. package/src/Util/Duration.ts +21 -0
  445. package/src/Util/PlatformServices.ts +41 -27
  446. package/src/Util/camel.ts +3 -5
  447. package/src/Util/data.ts +38 -0
  448. package/src/Util/index.ts +0 -6
  449. package/src/Util/stable.ts +4 -10
  450. package/src/Util/types.ts +9 -2
  451. package/src/index.ts +2 -3
  452. package/lib/Cloudflare/Local/Sidecar.d.ts +0 -63
  453. package/lib/Cloudflare/Local/Sidecar.d.ts.map +0 -1
  454. package/lib/Cloudflare/Local/Sidecar.js +0 -50
  455. package/lib/Cloudflare/Local/Sidecar.js.map +0 -1
  456. package/lib/Cloudflare/Local/SidecarHandlers.d.ts +0 -8
  457. package/lib/Cloudflare/Local/SidecarHandlers.d.ts.map +0 -1
  458. package/lib/Cloudflare/Local/SidecarHandlers.js +0 -381
  459. package/lib/Cloudflare/Local/SidecarHandlers.js.map +0 -1
  460. package/lib/Cloudflare/Local/SidecarServer.d.ts +0 -2
  461. package/lib/Cloudflare/Local/SidecarServer.d.ts.map +0 -1
  462. package/lib/Cloudflare/Local/SidecarServer.js +0 -34
  463. package/lib/Cloudflare/Local/SidecarServer.js.map +0 -1
  464. package/lib/Secret.d.ts +0 -50
  465. package/lib/Secret.d.ts.map +0 -1
  466. package/lib/Secret.js +0 -23
  467. package/lib/Secret.js.map +0 -1
  468. package/lib/Sidecar/Lock.d.ts +0 -23
  469. package/lib/Sidecar/Lock.d.ts.map +0 -1
  470. package/lib/Sidecar/Lock.js +0 -39
  471. package/lib/Sidecar/Lock.js.map +0 -1
  472. package/lib/Sidecar/RpcClient.d.ts +0 -15
  473. package/lib/Sidecar/RpcClient.d.ts.map +0 -1
  474. package/lib/Sidecar/RpcClient.js +0 -78
  475. package/lib/Sidecar/RpcClient.js.map +0 -1
  476. package/lib/Sidecar/RpcHandler.d.ts +0 -51
  477. package/lib/Sidecar/RpcHandler.d.ts.map +0 -1
  478. package/lib/Sidecar/RpcHandler.js +0 -87
  479. package/lib/Sidecar/RpcHandler.js.map +0 -1
  480. package/lib/Sidecar/RpcPaths.d.ts +0 -19
  481. package/lib/Sidecar/RpcPaths.d.ts.map +0 -1
  482. package/lib/Sidecar/RpcPaths.js +0 -31
  483. package/lib/Sidecar/RpcPaths.js.map +0 -1
  484. package/lib/Sidecar/RpcServer.d.ts +0 -30
  485. package/lib/Sidecar/RpcServer.d.ts.map +0 -1
  486. package/lib/Sidecar/RpcServer.js +0 -105
  487. package/lib/Sidecar/RpcServer.js.map +0 -1
  488. package/lib/Sidecar/RpcServerBun.d.ts +0 -4
  489. package/lib/Sidecar/RpcServerBun.d.ts.map +0 -1
  490. package/lib/Sidecar/RpcServerBun.js +0 -28
  491. package/lib/Sidecar/RpcServerBun.js.map +0 -1
  492. package/lib/Sidecar/RpcServerNode.d.ts +0 -4
  493. package/lib/Sidecar/RpcServerNode.d.ts.map +0 -1
  494. package/lib/Sidecar/RpcServerNode.js +0 -39
  495. package/lib/Sidecar/RpcServerNode.js.map +0 -1
  496. package/lib/Sidecar/RpcServices.d.ts +0 -6
  497. package/lib/Sidecar/RpcServices.d.ts.map +0 -1
  498. package/lib/Sidecar/RpcServices.js +0 -29
  499. package/lib/Sidecar/RpcServices.js.map +0 -1
  500. package/lib/Trait.d.ts +0 -43
  501. package/lib/Trait.d.ts.map +0 -1
  502. package/lib/Trait.js +0 -17
  503. package/lib/Trait.js.map +0 -1
  504. package/lib/Util/LocalhostDns.d.ts +0 -23
  505. package/lib/Util/LocalhostDns.d.ts.map +0 -1
  506. package/lib/Util/LocalhostDns.js +0 -46
  507. package/lib/Util/LocalhostDns.js.map +0 -1
  508. package/lib/Util/assert-never.d.ts +0 -12
  509. package/lib/Util/assert-never.d.ts.map +0 -1
  510. package/lib/Util/assert-never.js +0 -11
  511. package/lib/Util/assert-never.js.map +0 -1
  512. package/lib/Util/class.d.ts +0 -3
  513. package/lib/Util/class.d.ts.map +0 -1
  514. package/lib/Util/class.js +0 -1
  515. package/lib/Util/class.js.map +0 -1
  516. package/lib/Util/ignore.d.ts +0 -40
  517. package/lib/Util/ignore.d.ts.map +0 -1
  518. package/lib/Util/ignore.js +0 -591
  519. package/lib/Util/ignore.js.map +0 -1
  520. package/lib/Util/instance.d.ts +0 -4
  521. package/lib/Util/instance.d.ts.map +0 -1
  522. package/lib/Util/instance.js +0 -1
  523. package/lib/Util/instance.js.map +0 -1
  524. package/lib/Util/pointer.d.ts +0 -5
  525. package/lib/Util/pointer.d.ts.map +0 -1
  526. package/lib/Util/pointer.js +0 -1
  527. package/lib/Util/pointer.js.map +0 -1
  528. package/lib/Util/schema-to-type.d.ts +0 -42
  529. package/lib/Util/schema-to-type.d.ts.map +0 -1
  530. package/lib/Util/schema-to-type.js +0 -364
  531. package/lib/Util/schema-to-type.js.map +0 -1
  532. package/lib/Util/todo.d.ts +0 -3
  533. package/lib/Util/todo.d.ts.map +0 -1
  534. package/lib/Util/todo.js +0 -3
  535. package/lib/Util/todo.js.map +0 -1
  536. package/lib/Variable.d.ts +0 -29
  537. package/lib/Variable.d.ts.map +0 -1
  538. package/lib/Variable.js +0 -9
  539. package/lib/Variable.js.map +0 -1
  540. package/src/Cloudflare/Local/Sidecar.ts +0 -81
  541. package/src/Cloudflare/Local/SidecarHandlers.ts +0 -491
  542. package/src/Cloudflare/Local/SidecarServer.ts +0 -70
  543. package/src/Secret.ts +0 -87
  544. package/src/Sidecar/Lock.ts +0 -66
  545. package/src/Sidecar/RpcClient.ts +0 -142
  546. package/src/Sidecar/RpcHandler.ts +0 -205
  547. package/src/Sidecar/RpcPaths.ts +0 -39
  548. package/src/Sidecar/RpcServer.ts +0 -153
  549. package/src/Sidecar/RpcServerBun.ts +0 -41
  550. package/src/Sidecar/RpcServerNode.ts +0 -51
  551. package/src/Sidecar/RpcServices.ts +0 -48
  552. package/src/Trait.ts +0 -105
  553. package/src/Util/LocalhostDns.ts +0 -52
  554. package/src/Util/assert-never.ts +0 -18
  555. package/src/Util/class.ts +0 -7
  556. package/src/Util/ignore.ts +0 -815
  557. package/src/Util/instance.ts +0 -9
  558. package/src/Util/pointer.ts +0 -5
  559. package/src/Util/schema-to-type.ts +0 -456
  560. package/src/Util/todo.ts +0 -4
  561. package/src/Variable.ts +0 -44
@@ -1,6 +1,7 @@
1
1
  import type * as cf from "@cloudflare/workers-types";
2
2
  import * as workers from "@distilled.cloud/cloudflare/workers";
3
3
  import * as zones from "@distilled.cloud/cloudflare/zones";
4
+ import * as Config from "effect/Config";
4
5
  import * as Context from "effect/Context";
5
6
  import * as Data from "effect/Data";
6
7
  import * as Effect from "effect/Effect";
@@ -8,6 +9,7 @@ import * as Layer from "effect/Layer";
8
9
  import * as Path from "effect/Path";
9
10
  import * as Redacted from "effect/Redacted";
10
11
  import * as Schedule from "effect/Schedule";
12
+ import * as crypto from "node:crypto";
11
13
  import { Unowned } from "../../AdoptPolicy.ts";
12
14
  import { AlchemyContext } from "../../AlchemyContext.ts";
13
15
  import * as Artifacts from "../../Artifacts.ts";
@@ -22,7 +24,6 @@ import { Resource, type ResourceBinding } from "../../Resource.ts";
22
24
  import { Stack } from "../../Stack.ts";
23
25
  import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
24
26
  import type { HyperdriveDevOrigin } from "../Hyperdrive/Hyperdrive.ts";
25
- import { SidecarLive } from "../Local/Sidecar.ts";
26
27
  import { CloudflareLogs } from "../Logs.ts";
27
28
  import type { Providers } from "../Providers.ts";
28
29
  import {
@@ -34,7 +35,10 @@ import {
34
35
  } from "./Assets.ts";
35
36
  import { getCompatibility } from "./Compatibility.ts";
36
37
  import { isDurableObjectExport } from "./DurableObjectNamespace.ts";
37
- import { LocalWorkerProvider } from "./LocalWorkerProvider.ts";
38
+ import {
39
+ LocalWorkerProvider,
40
+ localRuntimeServices,
41
+ } from "./LocalWorkerProvider.ts";
38
42
  import { Request } from "./Request.ts";
39
43
  import * as Vite from "./Vite.ts";
40
44
  import {
@@ -170,7 +174,9 @@ type NormalizedBindings<
170
174
  any,
171
175
  any
172
176
  >
173
- ? T
177
+ ? T extends Redacted.Redacted<infer T> | Config.Config<infer T>
178
+ ? T
179
+ : T
174
180
  : Extract<Bindings[B], WorkerBindingResource>;
175
181
  } & (undefined extends AssetsConfig ? {} : { ASSETS: Assets });
176
182
 
@@ -178,7 +184,6 @@ export type WorkerAssetsConfig = string | AssetsProps | AssetsWithHash;
178
184
 
179
185
  export interface WorkerProps<
180
186
  Bindings extends WorkerBindingProps = any,
181
- Env extends WorkerEnv = WorkerEnv,
182
187
  Assets extends WorkerAssetsConfig | undefined =
183
188
  | WorkerAssetsConfig
184
189
  | undefined,
@@ -221,16 +226,46 @@ export interface WorkerProps<
221
226
  */
222
227
  observability?: WorkerObservability;
223
228
  tags?: string[];
224
- main: string;
229
+ /**
230
+ * Path to the Worker's entry module. Bundled with rolldown before
231
+ * upload. Mutually exclusive with {@link script} — provide exactly one.
232
+ */
233
+ main?: string;
234
+ /**
235
+ * Raw module source for the Worker. When provided, bundling is bypassed
236
+ * entirely and this string is uploaded as a single ESM module
237
+ * (`main.js`). Useful for tiny inline workers (tests, fixtures,
238
+ * one-offs) and any case where you've already produced the final
239
+ * bundle elsewhere. Mutually exclusive with {@link main}.
240
+ */
241
+ script?: string;
225
242
  compatibility?: {
226
243
  date?: string;
227
244
  flags?: ("nodejs_compat" | "nodejs_als" | (string & {}))[];
228
245
  };
229
246
  limits?: WorkerLimits;
230
247
  placement?: WorkerPlacement;
231
- env?: Env;
232
248
  exports?: string[];
233
- bindings?: Bindings;
249
+ /**
250
+ * Environment variables and native Cloudflare Bindings to bind to
251
+ * the Worker. Accepts:
252
+ *
253
+ * - Resource references (R2 bucket, KV namespace, D1 database,
254
+ * another Worker, Durable Object, etc.) — emitted as the
255
+ * corresponding native binding.
256
+ * - `effect/Config` values (`Config.redacted`, `Config.string`,
257
+ * `Config.number`, …) — resolved at deploy time and bound as
258
+ * `secret_text` on Cloudflare regardless of the `Config`
259
+ * constructor used. See
260
+ * {@link https://v2.alchemy.run/concepts/secrets | Concepts › Secrets and Variables}.
261
+ * - Literal values — routed by shape: `Redacted<string>` →
262
+ * `secret_text`, `string` → `plain_text`, anything else → `json`.
263
+ *
264
+ * In Effect-native Workers you can alternatively `yield*` a
265
+ * `Config` in the Init phase to register the binding implicitly;
266
+ * `env` is the only option for async (non-Effect) Workers.
267
+ */
268
+ env?: Bindings;
234
269
  /**
235
270
  * Cron expressions that trigger the Worker's scheduled handler.
236
271
  *
@@ -243,23 +278,33 @@ export interface WorkerProps<
243
278
  * already exist in the account.
244
279
  */
245
280
  domain?: string | string[];
246
- build?: {
281
+ /**
282
+ * Extra bundler options applied on top of the standard rolldown input/output
283
+ * options used to build this Worker. See {@link Bundle.BundleExtraOptions}.
284
+ */
285
+ build?: Bundle.BundleExtraOptions;
286
+ /**
287
+ * Options for the local dev server that runs this Worker under `alchemy dev`.
288
+ * Each Worker is served on its own port.
289
+ */
290
+ dev?: {
247
291
  /**
248
- * Whether to generate a metafile for the worker bundle.
249
- * @default false
292
+ * Host the local dev server binds to.
293
+ * @default "localhost"
250
294
  */
251
- metafile?: boolean;
295
+ host?: string;
252
296
  /**
253
- * Configures the {@link Bundle.purePlugin} which annotates top-level
254
- * call/new expressions in matching packages with `/*#__PURE__*\/`
255
- * so rolldown can tree-shake them.
256
- *
257
- * - `undefined` (default): plugin is enabled with default packages
258
- * (`effect`, `@effect/*`).
259
- * - `PurePluginOptions`: plugin is enabled with the provided options.
260
- * - `false`: plugin is disabled.
297
+ * Port the local dev server listens on. If the port is unavailable, the
298
+ * next free port is used unless {@link strictPort} is `true`.
299
+ * @default 1337
261
300
  */
262
- pure?: Bundle.BundleExtraOptions["pure"];
301
+ port?: number;
302
+ /**
303
+ * When `true`, fail instead of falling back to another port if {@link port}
304
+ * is already in use.
305
+ * @default false
306
+ */
307
+ strictPort?: boolean;
263
308
  };
264
309
  }
265
310
 
@@ -274,7 +319,7 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
274
319
  tags: string[] | undefined;
275
320
  durableObjectNamespaces: Record<string, string>;
276
321
  accountId: string;
277
- domains: { hostname: string; id: string; zoneId: string }[];
322
+ domains: string[];
278
323
  crons: string[];
279
324
  hash?: {
280
325
  assets: string | undefined;
@@ -330,9 +375,10 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
330
375
  * as-is. Your handler is a plain `async fetch` — no Effect runtime
331
376
  * is included in the bundle.
332
377
  *
333
- * Use the `bindings` prop to declare which resources are available
334
- * at runtime, and `Cloudflare.InferEnv` to extract a fully typed
335
- * `env` object from those bindings.
378
+ * Use the `env` prop to declare which resources, `Config` values,
379
+ * and literal env vars are available at runtime, and
380
+ * `Cloudflare.InferEnv` to extract a fully typed `env` object from
381
+ * them.
336
382
  *
337
383
  * See the {@link https://alchemy.run/guides/async-worker | Async Workers Guide}
338
384
  * for a comprehensive walkthrough of all binding types (R2, D1,
@@ -348,7 +394,7 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
348
394
  *
349
395
  * export const Worker = Cloudflare.Worker("Worker", {
350
396
  * main: "./src/worker.ts",
351
- * bindings: { db, bucket },
397
+ * env: { db, bucket },
352
398
  * });
353
399
  * ```
354
400
  *
@@ -605,7 +651,7 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
605
651
  * const sandbox = yield* Cloudflare.Container.bind(Sandbox);
606
652
  *
607
653
  * return Effect.gen(function* () {
608
- * const container = yield* Cloudflare.start(sandbox);
654
+ * const container = yield* Cloudflare.start(sandbox, { enableInternet: true });
609
655
  *
610
656
  * return {
611
657
  * exec: (cmd: string) => container.exec(cmd),
@@ -656,31 +702,20 @@ export const Worker: Platform<
656
702
  > & {
657
703
  <
658
704
  const Bindings extends WorkerBindingProps = {},
659
- const Env extends WorkerEnv = {},
660
705
  const Assets extends WorkerAssetsConfig | undefined = undefined,
661
706
  Req = never,
662
707
  >(
663
708
  id: string,
664
709
  props:
665
- | InputProps<WorkerProps<Bindings, Env, Assets>>
666
- | Effect.Effect<
667
- InputProps<WorkerProps<Bindings, Env, Assets>>,
668
- never,
669
- Req
670
- >,
710
+ | InputProps<WorkerProps<Bindings, Assets>>
711
+ | Effect.Effect<InputProps<WorkerProps<Bindings, Assets>>, never, Req>,
671
712
  ): Effect.Effect<
672
- Worker<
673
- {
674
- [binding in keyof NormalizedBindings<
675
- Bindings,
676
- Assets
677
- >]: NormalizedBindings<Bindings, Assets>[binding];
678
- } & {
679
- [K in keyof Env]: Env[K] extends Redacted.Redacted<infer T>
680
- ? T
681
- : Env[K];
682
- }
683
- >,
713
+ Worker<{
714
+ [binding in keyof NormalizedBindings<
715
+ Bindings,
716
+ Assets
717
+ >]: NormalizedBindings<Bindings, Assets>[binding];
718
+ }>,
684
719
  never,
685
720
  Req | Providers
686
721
  >;
@@ -724,7 +759,7 @@ const selectLayer = <
724
759
  export const WorkerProvider = () =>
725
760
  selectLayer({
726
761
  live: LiveWorkerProvider,
727
- dev: () => Layer.provide(LocalWorkerProvider(), SidecarLive),
762
+ dev: () => Layer.provide(LocalWorkerProvider(), localRuntimeServices()),
728
763
  });
729
764
 
730
765
  export const LiveWorkerProvider = () =>
@@ -881,11 +916,7 @@ export const LiveWorkerProvider = () =>
881
916
  );
882
917
  });
883
918
 
884
- const reconcileDomains = (
885
- scriptName: string,
886
- desired: string[],
887
- _previous: Worker["Attributes"]["domains"],
888
- ) =>
919
+ const reconcileDomains = (scriptName: string, desired: string[]) =>
889
920
  Effect.gen(function* () {
890
921
  // Always query the live state of domains attached to *this*
891
922
  // Worker rather than trusting `_previous` from local state.
@@ -1035,11 +1066,15 @@ export const LiveWorkerProvider = () =>
1035
1066
 
1036
1067
  const getExpectedDurableObjectClassNames = (
1037
1068
  bindings: readonly WorkerBinding[] | undefined,
1069
+ workerName: string,
1038
1070
  ) =>
1039
1071
  Array.from(
1040
1072
  new Set(
1041
1073
  bindings?.flatMap((binding) =>
1042
- binding.type === "durable_object_namespace" && binding.className
1074
+ binding.type === "durable_object_namespace" &&
1075
+ binding.className &&
1076
+ (binding.scriptName === undefined ||
1077
+ binding.scriptName === workerName)
1043
1078
  ? [binding.className]
1044
1079
  : [],
1045
1080
  ) ?? [],
@@ -1110,7 +1145,7 @@ export const LiveWorkerProvider = () =>
1110
1145
  bundler
1111
1146
  .build({
1112
1147
  id,
1113
- main: props.main,
1148
+ main: props.main!,
1114
1149
  compatibility: getCompatibility(props),
1115
1150
  entry: props.isExternal
1116
1151
  ? {
@@ -1121,15 +1156,38 @@ export const LiveWorkerProvider = () =>
1121
1156
  exports: (props.exports ?? {}) as any,
1122
1157
  },
1123
1158
  stack: { name: stack.name, stage: stack.stage },
1124
- userOptions: props.build,
1159
+ extraOptions: props.build,
1125
1160
  })
1126
1161
  .pipe(Artifacts.cached("build"));
1127
1162
 
1163
+ const hashScript = (script: string) =>
1164
+ Effect.sync(() =>
1165
+ crypto.createHash("sha256").update(script).digest("hex"),
1166
+ );
1167
+
1128
1168
  const viteBuild = Effect.fnUntraced(function* (props: WorkerProps) {
1129
1169
  const compatibility = getCompatibility(props);
1130
1170
  const { assetsDirectory, serverBundle } = yield* Vite.viteBuild(
1131
1171
  props.vite?.rootDir,
1132
- props.env ?? {},
1172
+ Object.fromEntries(
1173
+ (yield* Effect.all(
1174
+ Object.entries(props.env ?? {}).map(
1175
+ Effect.fnUntraced(function* ([key, value]) {
1176
+ return [
1177
+ key,
1178
+ typeof value === "string"
1179
+ ? value
1180
+ : Redacted.isRedacted(value) &&
1181
+ typeof Redacted.value(value) === "string"
1182
+ ? Redacted.value(value)
1183
+ : Config.isConfig(value) || Effect.isEffect(value)
1184
+ ? yield* value
1185
+ : undefined,
1186
+ ];
1187
+ }),
1188
+ ),
1189
+ )).filter(([_, value]) => value !== undefined),
1190
+ ),
1133
1191
  {
1134
1192
  compatibilityDate: compatibility.date,
1135
1193
  compatibilityFlags: compatibility.flags,
@@ -1167,6 +1225,24 @@ export const LiveWorkerProvider = () =>
1167
1225
  opts: { skipAssetsRead?: boolean } = {},
1168
1226
  ) =>
1169
1227
  Effect.gen(function* () {
1228
+ if (props.script !== undefined) {
1229
+ const [assets, bundleHash] = yield* Effect.all(
1230
+ [
1231
+ opts.skipAssetsRead
1232
+ ? Effect.succeed(undefined)
1233
+ : prepareAssets(props.assets),
1234
+ hashScript(props.script),
1235
+ ],
1236
+ { concurrency: "unbounded" },
1237
+ );
1238
+ return {
1239
+ assets,
1240
+ bundle: {
1241
+ files: [{ path: "main.js", content: props.script }],
1242
+ hash: bundleHash,
1243
+ },
1244
+ };
1245
+ }
1170
1246
  if (props.vite) {
1171
1247
  const [{ assets, bundle }, input] = yield* Effect.all(
1172
1248
  [
@@ -1269,7 +1345,7 @@ export const LiveWorkerProvider = () =>
1269
1345
  } satisfies Worker["Attributes"]["hash"];
1270
1346
  const metadataBindings = bindings.flatMap((b) => b.data.bindings ?? []);
1271
1347
  const expectedDurableObjectClassNames =
1272
- getExpectedDurableObjectClassNames(metadataBindings);
1348
+ getExpectedDurableObjectClassNames(metadataBindings, name);
1273
1349
  let metadataAssets:
1274
1350
  | workers.PutScriptRequest["metadata"]["assets"]
1275
1351
  | undefined;
@@ -1323,6 +1399,11 @@ export const LiveWorkerProvider = () =>
1323
1399
  });
1324
1400
  }
1325
1401
  metadataBindings.push(
1402
+ {
1403
+ type: "plain_text",
1404
+ name: "ALCHEMY_PHASE",
1405
+ text: "runtime",
1406
+ },
1326
1407
  {
1327
1408
  type: "plain_text",
1328
1409
  name: "ALCHEMY_STACK_NAME",
@@ -1338,11 +1419,16 @@ export const LiveWorkerProvider = () =>
1338
1419
  if (news.env) {
1339
1420
  for (const [key, value] of Object.entries(news.env)) {
1340
1421
  if (value === undefined) continue;
1422
+ if (metadataBindings.some((b) => b.name === key)) continue;
1341
1423
  if (Redacted.isRedacted(value)) {
1424
+ const unredacted = Redacted.value(value);
1342
1425
  metadataBindings.push({
1343
1426
  type: "secret_text",
1344
1427
  name: key,
1345
- text: Redacted.value(value),
1428
+ text:
1429
+ typeof unredacted === "string"
1430
+ ? unredacted
1431
+ : JSON.stringify(unredacted),
1346
1432
  });
1347
1433
  } else if (typeof value === "string") {
1348
1434
  metadataBindings.push({
@@ -1414,16 +1500,19 @@ export const LiveWorkerProvider = () =>
1414
1500
  }
1415
1501
 
1416
1502
  // Backward compatibility for old workers that have DO bindings but no
1417
- // alchemy:do tags yet.
1503
+ // alchemy:do tags yet. Cross-script bindings (`scriptName` set to
1504
+ // anything other than this worker) are NEVER candidates for
1505
+ // delete-class migrations — the class lives on the foreign script
1506
+ // and we don't own its lifecycle.
1418
1507
  if (Object.keys(oldDoClassNameByLogicalId).length === 0) {
1419
1508
  for (const oldBinding of oldBindings) {
1509
+ const ownedLocally =
1510
+ !("scriptName" in oldBinding) || oldBinding.scriptName === name;
1420
1511
  if (
1421
1512
  oldBinding.type === "durable_object_namespace" &&
1422
1513
  "className" in oldBinding &&
1423
1514
  oldBinding.className &&
1424
- (!("scriptName" in oldBinding) ||
1425
- !oldBinding.scriptName ||
1426
- oldBinding.scriptName === name) &&
1515
+ ownedLocally &&
1427
1516
  !currentDoBindings.some(
1428
1517
  (binding) => binding.bindingName === oldBinding.name,
1429
1518
  )
@@ -1585,27 +1674,36 @@ export const LiveWorkerProvider = () =>
1585
1674
  // Cloudflare currently has it (disabled by default, or whatever
1586
1675
  // a previous failed/external action left it as).
1587
1676
  const desiredSubdomainEnabled = news.url !== false;
1588
- const observedSubdomainEnabled = yield* getScriptSubdomain({
1677
+ const observedSubdomain = yield* getScriptSubdomain({
1589
1678
  accountId,
1590
1679
  scriptName: name,
1591
1680
  }).pipe(
1592
- Effect.map((s) => s.enabled === true),
1593
- Effect.catch(() => Effect.succeed(false)),
1681
+ Effect.orElseSucceed<workers.GetScriptSubdomainResponse>(() => ({
1682
+ enabled: false,
1683
+ previewsEnabled: false,
1684
+ })),
1594
1685
  );
1595
- if (desiredSubdomainEnabled !== observedSubdomainEnabled) {
1686
+ if (
1687
+ desiredSubdomainEnabled !== observedSubdomain.enabled ||
1688
+ desiredSubdomainEnabled !== observedSubdomain.previewsEnabled
1689
+ ) {
1596
1690
  yield* session.note(
1597
1691
  `${desiredSubdomainEnabled ? "Enabling" : "Disabling"} workers.dev subdomain...`,
1598
1692
  );
1599
1693
  // Cloudflare's script registry is eventually consistent — for the
1600
1694
  // first few hundred ms after `putScript` returns, POST /subdomain
1601
1695
  // can still get back `WorkerNotFound` (a generic "unknown error"
1602
- // body). Bigger uploads race harder. Retry the subdomain toggle on
1603
- // that specific tag with a short exponential backoff; same pattern
1604
- // we use elsewhere in this provider for DO-namespace propagation.
1696
+ // body), or a bare 500 surfaced as `InternalServerError` /
1697
+ // `UnknownCloudflareError` (code 10013). Bigger uploads race harder.
1698
+ // Retry the subdomain toggle on those transient tags with a short
1699
+ // exponential backoff; same pattern we use elsewhere in this
1700
+ // provider for DO-namespace propagation and for `putScript` itself.
1605
1701
  yield* setWorkerSubdomain(name, desiredSubdomainEnabled).pipe(
1606
1702
  Effect.retry({
1607
1703
  while: (error: { _tag?: string }) =>
1608
- error?._tag === "WorkerNotFound",
1704
+ error?._tag === "WorkerNotFound" ||
1705
+ error?._tag === "InternalServerError" ||
1706
+ error?._tag === "UnknownCloudflareError",
1609
1707
  schedule: Schedule.exponential(200).pipe(
1610
1708
  Schedule.both(Schedule.recurs(15)),
1611
1709
  ),
@@ -1619,11 +1717,15 @@ export const LiveWorkerProvider = () =>
1619
1717
  `Reconciling custom domains (${desiredDomains.length}) ...`,
1620
1718
  );
1621
1719
  }
1622
- const domains = yield* reconcileDomains(
1623
- name,
1624
- desiredDomains,
1625
- previousDomains,
1626
- );
1720
+ const reconciled = yield* reconcileDomains(name, desiredDomains);
1721
+ const workersDevUrl =
1722
+ news.url !== false
1723
+ ? `https://${name}.${yield* getAccountSubdomain(accountId)}.workers.dev`
1724
+ : undefined;
1725
+ const domains = [
1726
+ ...reconciled.map((d) => `https://${d.hostname}`),
1727
+ ...(workersDevUrl ? [workersDevUrl] : []),
1728
+ ];
1627
1729
  const crons = yield* reconcileCrons(
1628
1730
  name,
1629
1731
  normalizeCrons([...getCronBindings(bindings), ...(news.crons ?? [])]),
@@ -1634,10 +1736,7 @@ export const LiveWorkerProvider = () =>
1634
1736
  workerId: worker.id ?? name,
1635
1737
  workerName: name,
1636
1738
  logpush: worker.logpush ?? undefined,
1637
- url:
1638
- news.url !== false
1639
- ? `https://${name}.${yield* getAccountSubdomain(accountId)}.workers.dev`
1640
- : undefined,
1739
+ url: domains[0],
1641
1740
  tags: settings.tags ?? metadata.tags,
1642
1741
  durableObjectNamespaces,
1643
1742
  accountId,
@@ -1652,6 +1751,25 @@ export const LiveWorkerProvider = () =>
1652
1751
  props: WorkerProps,
1653
1752
  output: Worker["Attributes"],
1654
1753
  ) {
1754
+ if (props.script !== undefined) {
1755
+ const scriptHash = yield* hashScript(props.script);
1756
+ if (scriptHash !== output.hash?.bundle) {
1757
+ return true;
1758
+ }
1759
+ if (!props.assets) {
1760
+ return false;
1761
+ }
1762
+ const assetsHash =
1763
+ typeof props.assets === "object" &&
1764
+ "path" in props.assets &&
1765
+ "hash" in props.assets
1766
+ ? (props.assets.hash as string)
1767
+ : undefined;
1768
+ if (assetsHash === undefined) {
1769
+ return true;
1770
+ }
1771
+ return assetsHash !== output.hash?.assets;
1772
+ }
1655
1773
  if (props.vite) {
1656
1774
  const input = yield* hashDirectory({
1657
1775
  cwd: props.vite.rootDir,
@@ -1719,9 +1837,11 @@ export const LiveWorkerProvider = () =>
1719
1837
  if (!output) {
1720
1838
  return;
1721
1839
  }
1722
- const newDomains = normalizeDomains(news.domain).sort();
1840
+ const newDomains = normalizeDomains(news.domain)
1841
+ .map((h) => `https://${h}`)
1842
+ .sort();
1723
1843
  const oldDomains = (output?.domains ?? [])
1724
- .map((d) => d.hostname)
1844
+ .filter((u) => !u.endsWith(".workers.dev"))
1725
1845
  .sort();
1726
1846
  const domainsChanged =
1727
1847
  newDomains.length !== oldDomains.length ||
@@ -1916,6 +2036,30 @@ export const LiveWorkerProvider = () =>
1916
2036
  service: workerName,
1917
2037
  }).pipe(Effect.map((r) => r.result ?? [])),
1918
2038
  ]);
2039
+ // Preserve the order the user provided in `olds.domain`. The
2040
+ // Cloudflare API returns domains in non-deterministic order,
2041
+ // which would cause downstream `worker.domains[0]` reads to flip
2042
+ // between deploys. Drift (domains we don't know about) is
2043
+ // appended after the user-ordered ones.
2044
+ const userOrder = normalizeDomains(olds?.domain);
2045
+ const orderedHostnames = [
2046
+ ...userOrder.flatMap(
2047
+ (h) =>
2048
+ domainsList.find((d) => d.hostname === h)?.hostname ?? [],
2049
+ ),
2050
+ ...domainsList.flatMap((d) =>
2051
+ d.hostname && !userOrder.includes(d.hostname)
2052
+ ? [d.hostname]
2053
+ : [],
2054
+ ),
2055
+ ];
2056
+ const workersDevUrl = subdomain.enabled
2057
+ ? `https://${workerName}.${yield* getAccountSubdomain(accountId)}.workers.dev`
2058
+ : undefined;
2059
+ const domains = [
2060
+ ...orderedHostnames.map((h) => `https://${h}`),
2061
+ ...(workersDevUrl ? [workersDevUrl] : []),
2062
+ ];
1919
2063
  const crons = yield* getWorkerCrons(workerName);
1920
2064
  yield* Effect.logInfo(
1921
2065
  `Cloudflare Worker read: found ${workerName}`,
@@ -1925,18 +2069,12 @@ export const LiveWorkerProvider = () =>
1925
2069
  workerId: workerName,
1926
2070
  workerName,
1927
2071
  logpush: settings.logpush ?? undefined,
1928
- url: subdomain.enabled
1929
- ? `https://${workerName}.${yield* getAccountSubdomain(accountId)}.workers.dev`
1930
- : undefined,
2072
+ url: domains[0],
1931
2073
  tags: settings.tags ?? undefined,
1932
2074
  durableObjectNamespaces: getDurableObjectNamespaces(
1933
2075
  settings.bindings,
1934
2076
  ),
1935
- domains: domainsList.flatMap((d) =>
1936
- d.id && d.hostname && d.zoneId
1937
- ? [{ id: d.id, hostname: d.hostname, zoneId: d.zoneId }]
1938
- : [],
1939
- ),
2077
+ domains,
1940
2078
  crons,
1941
2079
  } satisfies Worker["Attributes"];
1942
2080
 
@@ -2021,13 +2159,30 @@ export const LiveWorkerProvider = () =>
2021
2159
  yield* Effect.logInfo(
2022
2160
  `Cloudflare Worker delete: deleting ${output.workerName}`,
2023
2161
  );
2024
- if (output.domains?.length) {
2162
+ // Look up live domain IDs rather than trusting persisted state.
2163
+ // We no longer track `{ id, zoneId }` on the output; fetching
2164
+ // straight from Cloudflare handles both the normal case and
2165
+ // adopted workers whose domains we never recorded.
2166
+ const liveDomains = yield* listDomains({
2167
+ accountId: output.accountId,
2168
+ service: output.workerName,
2169
+ }).pipe(
2170
+ Effect.map((r) => r.result ?? []),
2171
+ Effect.catch(() => Effect.succeed([])),
2172
+ );
2173
+ if (liveDomains.length) {
2025
2174
  yield* Effect.all(
2026
- output.domains.map((d) =>
2027
- deleteDomain({
2028
- accountId: output.accountId,
2029
- domainId: d.id,
2030
- }).pipe(Effect.catchTag("DomainNotFound", () => Effect.void)),
2175
+ liveDomains.flatMap((d) =>
2176
+ d.id
2177
+ ? [
2178
+ deleteDomain({
2179
+ accountId: output.accountId,
2180
+ domainId: d.id,
2181
+ }).pipe(
2182
+ Effect.catchTag("DomainNotFound", () => Effect.void),
2183
+ ),
2184
+ ]
2185
+ : [],
2031
2186
  ),
2032
2187
  { concurrency: "unbounded" },
2033
2188
  );
@@ -2101,23 +2256,38 @@ function getDurableObjectBindings(
2101
2256
  bindings: ReadonlyArray<ResourceBinding>,
2102
2257
  workerName: string,
2103
2258
  ) {
2259
+ // Resource authors (and the `make`/`yield* Tag`/plan-vs-apply machinery)
2260
+ // can register the same DO binding multiple times under the same logical
2261
+ // id — `binding()` is a plain `worker.bind` and intentionally has no
2262
+ // dedup. Collapse duplicates here so each `(logicalId, bindingName,
2263
+ // className)` tuple appears at most once. We also exclude cross-script
2264
+ // references: a `scriptName` pointing to *another* worker means this
2265
+ // worker just references a foreign class — ship the binding to
2266
+ // Cloudflare, but don't drive class migrations for it.
2267
+ const seen = new Set<string>();
2104
2268
  return bindings.flatMap((binding) =>
2105
- (binding.data.bindings ?? []).flatMap((item: WorkerBinding) =>
2106
- item.type === "durable_object_namespace" &&
2107
- "className" in item &&
2108
- item.className &&
2109
- (!("scriptName" in item) ||
2110
- !item.scriptName ||
2111
- item.scriptName === workerName)
2112
- ? [
2113
- {
2114
- logicalId: binding.sid,
2115
- bindingName: item.name,
2116
- className: item.className,
2117
- },
2118
- ]
2119
- : [],
2120
- ),
2269
+ (binding.data.bindings ?? []).flatMap((item: WorkerBinding) => {
2270
+ if (
2271
+ item.type !== "durable_object_namespace" ||
2272
+ !("className" in item) ||
2273
+ !item.className
2274
+ ) {
2275
+ return [];
2276
+ }
2277
+ if (item.scriptName !== undefined && item.scriptName !== workerName) {
2278
+ return [];
2279
+ }
2280
+ const dedupKey = `${binding.sid}::${item.name}::${item.className}`;
2281
+ if (seen.has(dedupKey)) return [];
2282
+ seen.add(dedupKey);
2283
+ return [
2284
+ {
2285
+ logicalId: binding.sid,
2286
+ bindingName: item.name,
2287
+ className: item.className,
2288
+ },
2289
+ ];
2290
+ }),
2121
2291
  );
2122
2292
  }
2123
2293