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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alchemy",
3
- "version": "2.0.0-beta.43",
3
+ "version": "2.0.0-beta.45",
4
4
  "homepage": "https://alchemy.run",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Sam Goodwin <sam@alchemy.run>",
@@ -288,19 +288,19 @@
288
288
  "access": "public"
289
289
  },
290
290
  "dependencies": {
291
- "@alchemy.run/node-utils": "0.0.2",
291
+ "@alchemy.run/node-utils": "0.0.4",
292
292
  "@aws-sdk/credential-providers": "^3.0.0",
293
293
  "@clack/prompts": "^0.11.0",
294
- "@distilled.cloud/aws": "^0.21.3",
295
- "@distilled.cloud/axiom": "^0.21.3",
296
- "@distilled.cloud/cloudflare": "^0.21.3",
297
- "@distilled.cloud/cloudflare-rolldown-plugin": "0.5.4",
298
- "@distilled.cloud/cloudflare-runtime": "0.5.4",
299
- "@distilled.cloud/cloudflare-vite-plugin": "0.5.4",
300
- "@distilled.cloud/core": "^0.21.3",
301
- "@distilled.cloud/planetscale": "^0.21.3",
302
- "@distilled.cloud/neon": "^0.21.3",
303
- "@effect/vitest": ">=4.0.0-beta.66 || >=4.0.0",
294
+ "@distilled.cloud/aws": "^0.22.1",
295
+ "@distilled.cloud/axiom": "^0.22.1",
296
+ "@distilled.cloud/cloudflare": "^0.22.1",
297
+ "@distilled.cloud/cloudflare-rolldown-plugin": "0.10.1",
298
+ "@distilled.cloud/cloudflare-runtime": "0.10.1",
299
+ "@distilled.cloud/cloudflare-vite-plugin": "0.10.1",
300
+ "@distilled.cloud/core": "^0.22.1",
301
+ "@distilled.cloud/neon": "^0.22.1",
302
+ "@distilled.cloud/planetscale": "^0.22.1",
303
+ "@effect/vitest": ">=4.0.0-beta.74 || >=4.0.0",
304
304
  "@libsql/client": "^0.17.0",
305
305
  "@octokit/rest": "^22.0.1",
306
306
  "@smithy/node-config-provider": "^4.0.0",
@@ -311,7 +311,6 @@
311
311
  "capnweb": "^0.6.1",
312
312
  "fast-glob": "^3.3.2",
313
313
  "fast-xml-parser": "^5.3.4",
314
- "foreground-child": "^4.0.3",
315
314
  "ink": "^6.3.1",
316
315
  "jszip": "^3.10.1",
317
316
  "libsodium-wrappers": "^0.8.3",
@@ -321,17 +320,17 @@
321
320
  "pg": "^8.13.0",
322
321
  "picomatch": "^4.0.4",
323
322
  "react": "^19.2.0",
324
- "rolldown": "1.0.0-rc.17",
325
- "sonda": "^0.11.1",
323
+ "rolldown": "1.0.1",
326
324
  "undici": "^7.16.0",
327
325
  "yaml": "^2.0.0"
328
326
  },
329
327
  "devDependencies": {
330
328
  "@clack/prompts": "^0.11.0",
331
329
  "@cloudflare/workers-types": "^4.20250805.0",
332
- "@effect/platform-bun": ">=4.0.0-beta.66 || >=4.0.0",
333
- "@effect/platform-node": ">=4.0.0-beta.66 || >=4.0.0",
334
- "@effect/platform-node-shared": ">=4.0.0-beta.66 || >=4.0.0",
330
+ "@cloudflare/puppeteer": "^1.1.0",
331
+ "@effect/platform-bun": ">=4.0.0-beta.74 || >=4.0.0",
332
+ "@effect/platform-node": ">=4.0.0-beta.74 || >=4.0.0",
333
+ "@effect/platform-node-shared": ">=4.0.0-beta.74 || >=4.0.0",
335
334
  "@oxc-project/types": "^0.127.0",
336
335
  "@types/pg": "^8.11.0",
337
336
  "@types/aws-lambda": "^8.10.152",
@@ -341,7 +340,7 @@
341
340
  "@types/react": "^19.2.2",
342
341
  "@types/ws": "^8.18.1",
343
342
  "better-auth": "^1.6.2",
344
- "effect": ">=4.0.0-beta.66 || >=4.0.0",
343
+ "effect": ">=4.0.0-beta.74 || >=4.0.0",
345
344
  "react-devtools-core": "^7.0.1",
346
345
  "solid-js": "latest",
347
346
  "tsconfig-paths": "^4.2.0",
@@ -351,12 +350,12 @@
351
350
  "ws": "^8.20.0"
352
351
  },
353
352
  "peerDependencies": {
354
- "@effect/platform-bun": ">=4.0.0-beta.66 || >=4.0.0",
355
- "@effect/platform-node": ">=4.0.0-beta.66 || >=4.0.0",
356
- "@effect/sql-pg": ">=4.0.0-beta.66 || >=4.0.0",
353
+ "@effect/platform-bun": ">=4.0.0-beta.74 || >=4.0.0",
354
+ "@effect/platform-node": ">=4.0.0-beta.74 || >=4.0.0",
355
+ "@effect/sql-pg": ">=4.0.0-beta.74 || >=4.0.0",
357
356
  "drizzle-kit": ">=1.0.0-rc.1",
358
357
  "drizzle-orm": ">=1.0.0-rc.1",
359
- "effect": ">=4.0.0-beta.66 || >=4.0.0",
358
+ "effect": ">=4.0.0-beta.74 || >=4.0.0",
360
359
  "vite": "^8.0.7",
361
360
  "ws": "^8.20.0"
362
361
  },
@@ -5,8 +5,8 @@ import type { CreateFunctionRequest } from "@distilled.cloud/aws/lambda";
5
5
  import * as Lambda from "@distilled.cloud/aws/lambda";
6
6
  import { Region } from "@distilled.cloud/aws/Region";
7
7
  import type * as lambda from "aws-lambda";
8
- import * as Config from "effect/Config";
9
8
  import * as Context from "effect/Context";
9
+ import * as Duration from "effect/Duration";
10
10
  import * as Effect from "effect/Effect";
11
11
  import * as FileSystem from "effect/FileSystem";
12
12
  import * as Option from "effect/Option";
@@ -94,8 +94,45 @@ export interface FunctionProps extends PlatformProps {
94
94
  subnetIds: string[];
95
95
  securityGroupIds: string[];
96
96
  };
97
+ /**
98
+ * Maximum execution time before the function is forcibly terminated.
99
+ * Rounded up to whole seconds.
100
+ *
101
+ * @default 3 seconds (AWS Lambda default)
102
+ */
103
+ timeout?: Duration.Duration;
97
104
  }
98
105
 
106
+ /**
107
+ * Normalize a {@link FunctionProps.timeout} to whole seconds.
108
+ *
109
+ * State JSON round-trips flatten a `Duration` to its `toJSON` shape
110
+ * (`{_id:"Duration",_tag:"Millis"|"Nanos"|"Infinity",...}`), which is not a
111
+ * valid `Duration.Input`. Reconstruct an input that `Duration.toSeconds`
112
+ * accepts before delegating.
113
+ */
114
+ export const toTimeoutSeconds = (
115
+ timeout: Duration.Duration | undefined,
116
+ ): number | undefined => {
117
+ if (timeout === undefined) return undefined;
118
+ const json = timeout as {
119
+ _id?: unknown;
120
+ _tag?: "Millis" | "Nanos" | "Infinity" | "NegativeInfinity";
121
+ millis?: number;
122
+ nanos?: string;
123
+ };
124
+ const input: Duration.Input =
125
+ json._id === "Duration"
126
+ ? json._tag === "Millis"
127
+ ? json.millis!
128
+ : json._tag === "Nanos"
129
+ ? BigInt(json.nanos!)
130
+ : "Infinity"
131
+ : timeout;
132
+ const seconds = Duration.toSeconds(input);
133
+ return Number.isFinite(seconds) ? Math.max(1, Math.ceil(seconds)) : undefined;
134
+ };
135
+
99
136
  export interface Function extends Resource<
100
137
  FunctionTypeId,
101
138
  FunctionProps,
@@ -368,7 +405,9 @@ export const Function: Platform<
368
405
  env,
369
406
  set: (id: string, output: Output.Output) =>
370
407
  Effect.sync(() => {
371
- const key = id.replaceAll(/[^a-zA-Z0-9]/g, "_");
408
+ // Key is already canonical (see RuntimeContext.sanitizeKey); store it
409
+ // verbatim.
410
+ const key = id;
372
411
  // Preserve `Redacted`-ness across the Output → Lambda env var
373
412
  // round-trip. `JSON.stringify(Redacted)` would emit the literal
374
413
  // string `"<redacted>"` and lose the value, so secrets are
@@ -387,34 +426,35 @@ export const Function: Platform<
387
426
  return key;
388
427
  }),
389
428
  get: <T>(key: string) =>
390
- Config.string(key).pipe(
391
- Effect.flatMap((val) =>
392
- Effect.try({
393
- try: () => {
394
- const value = JSON.parse(val);
395
- if (
396
- value !== null &&
397
- typeof value === "object" &&
398
- (value as { _tag?: unknown })._tag === "Redacted" &&
399
- "value" in (value as object)
400
- ) {
401
- return Redacted.make(
402
- (value as { value: unknown }).value,
403
- ) as unknown as T;
404
- }
405
- return value as T;
406
- },
407
- catch: () => val, // assume it's just a string
408
- }),
409
- ),
410
- Effect.catch((cause) =>
411
- Effect.die(
412
- new Error(`Failed to get environment variable: ${key}`, {
413
- cause,
414
- }),
415
- ),
416
- ),
417
- ),
429
+ // Read the captured value straight from `process.env`. We must NOT
430
+ // resolve through `Config.string` here: at runtime the ambient
431
+ // `ConfigProvider` is the interceptor installed in `Platform.ts`,
432
+ // whose runtime branch calls back into `ctx.get(key)`. Going through
433
+ // `Config` would re-enter that interceptor for the same key and
434
+ // recurse forever, allocating until the Lambda init OOMs. The Worker
435
+ // runtime reads from `WorkerEnvironment` for the same reason.
436
+ Effect.sync(() => {
437
+ // Key is already canonical (see RuntimeContext.sanitizeKey).
438
+ const val = process.env[key];
439
+ if (val === undefined) {
440
+ return undefined;
441
+ }
442
+ try {
443
+ const value = JSON.parse(val);
444
+ if (
445
+ typeof value === "object" &&
446
+ value?._tag === "Redacted" &&
447
+ "value" in value
448
+ ) {
449
+ return Redacted.make(
450
+ (value as { value: unknown }).value,
451
+ ) as unknown as T;
452
+ }
453
+ return value as T;
454
+ } catch {
455
+ return val as unknown as T; // assume it's just a string
456
+ }
457
+ }),
418
458
  serve: (handler: HttpEffect) =>
419
459
  ctx.listen(makeFunctionHttpHandler(handler)),
420
460
  listen: ((
@@ -872,6 +912,7 @@ export default await Effect.runPromise(handlerEffect)
872
912
  }
873
913
  : undefined,
874
914
  Tags: tags,
915
+ Timeout: toTimeoutSeconds(news.timeout),
875
916
  VpcConfig: news.vpc
876
917
  ? {
877
918
  SubnetIds: news.vpc.subnetIds,
@@ -1121,6 +1162,11 @@ export default await Effect.runPromise(handlerEffect)
1121
1162
  // code changed
1122
1163
  return { action: "update" };
1123
1164
  }
1165
+ if (
1166
+ toTimeoutSeconds(olds.timeout) !== toTimeoutSeconds(news.timeout)
1167
+ ) {
1168
+ return { action: "update" };
1169
+ }
1124
1170
  }),
1125
1171
  read: Effect.fnUntraced(function* ({ id, olds, output }) {
1126
1172
  const functionName =
@@ -1161,7 +1207,7 @@ export default await Effect.runPromise(handlerEffect)
1161
1207
  // Reuse the persisted output where we have it (e.g. code hash) so
1162
1208
  // diff doesn't see drift it can't reconstruct from the API.
1163
1209
  const attrs = {
1164
- ...(output ?? {}),
1210
+ ...output,
1165
1211
  functionArn: fn.FunctionArn,
1166
1212
  functionName: fn.FunctionName,
1167
1213
  functionUrl,
@@ -1185,8 +1231,15 @@ export default await Effect.runPromise(handlerEffect)
1185
1231
  vpc: news.vpc,
1186
1232
  });
1187
1233
 
1188
- // mock code
1189
- const code = new TextEncoder().encode("export default () => {}");
1234
+ // Mock code for the pre-created stub. It responds 503 (rather than a
1235
+ // bare 200) so that, during the brief window where the real
1236
+ // code/config update is still `InProgress`, a Function URL hit serves
1237
+ // an honest "not ready" signal instead of a successful-but-empty 200.
1238
+ // Downstream readiness probes already retry on non-200, so they wait
1239
+ // for the real handler to go live without the provider blocking.
1240
+ const code = new TextEncoder().encode(
1241
+ `export default () => ({ statusCode: 503, headers: { "content-type": "application/json" }, body: JSON.stringify({ error: "function initializing" }) })`,
1242
+ );
1190
1243
  const archive = yield* zipCode(code);
1191
1244
  const hash = yield* hashBundle(code);
1192
1245
  yield* createOrUpdateFunction({
@@ -1261,7 +1314,7 @@ export default await Effect.runPromise(handlerEffect)
1261
1314
  yield* session.note(summary({ code }));
1262
1315
 
1263
1316
  return {
1264
- ...(output ?? {}),
1317
+ ...output,
1265
1318
  functionArn,
1266
1319
  functionName,
1267
1320
  functionUrl: functionUrl as any,
@@ -19,6 +19,7 @@ import * as HttpClientError from "effect/unstable/http/HttpClientError";
19
19
  import { CredentialsStoreLive } from "../Auth/Credentials.ts";
20
20
  import { Command, CommandProvider } from "../Build/Command.ts";
21
21
  import * as Provider from "../Provider.ts";
22
+ import { KeyPair, KeyPairProvider } from "../KeyPair.ts";
22
23
  import { Random, RandomProvider } from "../Random.ts";
23
24
  import * as ACM from "./ACM/index.ts";
24
25
  import * as ApiGateway from "./ApiGateway/index.ts";
@@ -63,6 +64,7 @@ export const providers = () =>
63
64
  Providers,
64
65
  Provider.collection([
65
66
  Command,
67
+ KeyPair,
66
68
  Random,
67
69
  ACM.Certificate,
68
70
  ApiGateway.Account,
@@ -571,6 +573,7 @@ export const providers = () =>
571
573
  Layer.provideMerge(
572
574
  Layer.mergeAll(
573
575
  CommandProvider(),
576
+ KeyPairProvider(),
574
577
  RandomProvider(),
575
578
  Assets.AssetsProvider(),
576
579
  ),
package/src/Apply.ts CHANGED
@@ -280,7 +280,24 @@ const executePlan = Effect.fnUntraced(function* (
280
280
  Effect.all(
281
281
  fqns
282
282
  .filter((fqn) => fqn in ready)
283
- .map((fqn) => Deferred.await(ready[fqn])),
283
+ .map((fqn) =>
284
+ // Non-cycle upstreams must be observed at their TERMINAL output
285
+ // (`readyStable`), not their early precreate signal (`ready`). This
286
+ // is what makes a failed upstream actually interrupt its downstream:
287
+ // a resource with `precreate` resolves `ready` before its real
288
+ // `reconcile` runs, so a downstream waiting on `ready` would proceed
289
+ // (and even finish) even though the upstream's reconcile later
290
+ // failed. Waiting on `readyStable` means the downstream's
291
+ // `waitForDeps` short-circuits with the upstream's failure cause.
292
+ //
293
+ // Cycle members are the exception: peers in an SCC depend on each
294
+ // other, so they must rendezvous on the early `ready`/precreate
295
+ // signal to break the deadlock. Phase 3 (`converge`) re-runs them
296
+ // against final outputs once the cycle settles.
297
+ plan.cycleMembers.has(fqn)
298
+ ? Deferred.await(ready[fqn])
299
+ : Deferred.await(readyStable[fqn]),
300
+ ),
284
301
  { concurrency: "unbounded" },
285
302
  );
286
303
 
@@ -2,6 +2,7 @@ import * as Context from "effect/Context";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Layer from "effect/Layer";
4
4
  import * as Schema from "effect/Schema";
5
+ import * as Semaphore from "effect/Semaphore";
5
6
  import { withLock } from "./Lock.ts";
6
7
 
7
8
  /**
@@ -14,6 +15,20 @@ import { withLock } from "./Lock.ts";
14
15
  */
15
16
  const LOCKED_METHODS = new Set(["read", "login", "logout", "configure"]);
16
17
 
18
+ /**
19
+ * Methods that may drive an interactive flow (prompts, browser-based
20
+ * OAuth, etc.). A process-wide mutex serializes these across providers
21
+ * so that, e.g., Cloudflare's `configure` finishes its prompt sequence
22
+ * before Planetscale's begins — even when the two auth provider Layers
23
+ * are built in parallel as part of a single `providers()` Layer.
24
+ *
25
+ * The clack prompt wrapper in `Util/Clank.ts` enforces per-prompt
26
+ * serialization; this mutex enforces per-flow serialization so the user
27
+ * sees one provider's prompts grouped together rather than interleaved.
28
+ */
29
+ const INTERACTIVE_METHODS = new Set(["login", "configure"]);
30
+ const interactiveMutex = Semaphore.makeUnsafe(1);
31
+
17
32
  export class AuthError extends Schema.TaggedErrorClass<AuthError>()(
18
33
  "AuthError",
19
34
  {
@@ -143,13 +158,18 @@ export const AuthProvider =
143
158
  Object.entries(service).map(([methodName, fn]) => [
144
159
  methodName,
145
160
  (...args: Parameters<typeof fn>) => {
146
- const eff = (fn as any)(...args).pipe(
161
+ let eff = (fn as any)(...args).pipe(
147
162
  Effect.provideContext(ctx),
148
163
  );
149
- if (!LOCKED_METHODS.has(methodName)) return eff;
150
- // First positional arg is always `profileName`.
151
- const profileName = args[0] as string;
152
- return withLock(`${profileName}-${name}`, eff);
164
+ if (LOCKED_METHODS.has(methodName)) {
165
+ // First positional arg is always `profileName`.
166
+ const profileName = args[0] as string;
167
+ eff = withLock(`${profileName}-${name}`, eff);
168
+ }
169
+ if (INTERACTIVE_METHODS.has(methodName)) {
170
+ eff = Semaphore.withPermits(interactiveMutex, 1)(eff);
171
+ }
172
+ return eff;
153
173
  },
154
174
  ]),
155
175
  ),
@@ -70,13 +70,14 @@ export const CredentialsStoreLive = Layer.effect(
70
70
  credentials: T,
71
71
  ): Effect.Effect<void, PlatformError> => {
72
72
  const filePath = credentialsFilePath(profile, provider);
73
- return fs
74
- .makeDirectory(path.dirname(filePath), { recursive: true })
75
- .pipe(
76
- Effect.flatMap(() =>
77
- fs.writeFileString(filePath, JSON.stringify(credentials, null, 2)),
78
- ),
79
- );
73
+ return fs.makeDirectory(path.dirname(filePath), { recursive: true }).pipe(
74
+ Effect.flatMap(() => {
75
+ return fs.writeFileString(
76
+ filePath,
77
+ JSON.stringify(credentials, null, 2),
78
+ );
79
+ }),
80
+ );
80
81
  };
81
82
 
82
83
  const remove_ = (profile: string, provider: string): Effect.Effect<void> =>
package/src/Auth/Lock.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as lockfile from "@alchemy.run/node-utils";
1
+ import { lock } from "@alchemy.run/node-utils/lockfile";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as fs from "node:fs/promises";
4
4
  import * as path from "pathe";
@@ -24,7 +24,7 @@ export const withLock = <A, E, R>(
24
24
  return Effect.acquireUseRelease(
25
25
  Effect.promise(async () => {
26
26
  await fs.mkdir(lockDir, { recursive: true });
27
- return await lockfile.lock(lockPath, {
27
+ return await lock(lockPath, {
28
28
  retries: { retries: 600, minTimeout: 50, maxTimeout: 50 },
29
29
  stale: 5_000,
30
30
  realpath: false,
@@ -6,7 +6,12 @@ import * as Stream from "effect/Stream";
6
6
  import assert from "node:assert";
7
7
  import * as rolldown from "rolldown";
8
8
  import { sha256, sha256Object } from "../Util/sha256.ts";
9
+ import {
10
+ bundleAnalyzerPlugin,
11
+ type BundleAnalyzerPluginOptions,
12
+ } from "./BundleAnalyzerPlugin.ts";
9
13
  import { purePlugin, type PurePluginOptions } from "./PurePlugin.ts";
14
+ import { rawPlugin } from "./RawPlugin.ts";
10
15
 
11
16
  /**
12
17
  * Extra options accepted by {@link build} / {@link watch} on top of the
@@ -24,6 +29,16 @@ export interface BundleExtraOptions {
24
29
  * - `false`: plugin is disabled.
25
30
  */
26
31
  readonly pure?: PurePluginOptions | false;
32
+ /**
33
+ * Configures the {@link bundleAnalyzerPlugin} which emits a bundle analysis
34
+ * report alongside the bundle output, describing chunks, modules, and the
35
+ * import graph reachable from each entry point.
36
+ *
37
+ * - `undefined` / `false` (default): plugin is disabled.
38
+ * - `true`: plugin is enabled with default options.
39
+ * - `BundleAnalyzerPluginOptions`: plugin is enabled with the provided options.
40
+ */
41
+ readonly bundleAnalyzer?: BundleAnalyzerPluginOptions | boolean;
27
42
  }
28
43
 
29
44
  export interface BundleOutput {
@@ -86,7 +101,7 @@ export const build = (
86
101
  try: async () => {
87
102
  const bundle = await rolldown.rolldown({
88
103
  ...inputOptions,
89
- plugins: withPurePlugin(inputOptions.plugins, extra?.pure),
104
+ plugins: [inputOptions.plugins, builtInPlugins(extra)],
90
105
  optimization: inputOptions.optimization ?? {
91
106
  inlineConst: {
92
107
  mode: "smart",
@@ -94,7 +109,7 @@ export const build = (
94
109
  },
95
110
  },
96
111
  });
97
- const result = await bundle.generate(outputOptions);
112
+ const result = await bundle.write(outputOptions);
98
113
  await bundle.close();
99
114
  return result.output;
100
115
  },
@@ -128,7 +143,8 @@ export const watch = (
128
143
  const watcher = rolldown.watch({
129
144
  ...inputOptions,
130
145
  plugins: [
131
- withPurePlugin(inputOptions.plugins, extra?.pure),
146
+ inputOptions.plugins,
147
+ builtInPlugins(extra),
132
148
  // The watcher event listener does not receive the bundle output, so we grab it using a plugin.
133
149
  {
134
150
  name: "alchemy:watch-bundle",
@@ -266,19 +282,25 @@ export function bundleOutputFromRolldownOutputBundle(
266
282
  }
267
283
 
268
284
  /**
269
- * Composes the user-provided plugin chain with the default
270
- * {@link purePlugin} according to the `pure` option.
285
+ * Returns the built-in plugins appended after the user-provided plugin chain,
286
+ * configured by {@link BundleExtraOptions}.
271
287
  *
272
- * The pure plugin is appended LAST so it sees module ids that have already
273
- * been resolved into `node_modules/<pkg>/...` by upstream resolver plugins
274
- * such as `@distilled.cloud/cloudflare-rolldown-plugin`.
288
+ * These run LAST so they see module ids that have already been resolved into
289
+ * `node_modules/<pkg>/...` by upstream resolver plugins such as
290
+ * `@distilled.cloud/cloudflare-rolldown-plugin`.
275
291
  */
276
- function withPurePlugin(
277
- plugins: rolldown.RolldownPluginOption,
278
- pure: PurePluginOptions | false | undefined,
292
+ function builtInPlugins(
293
+ extra?: BundleExtraOptions,
279
294
  ): rolldown.RolldownPluginOption {
280
- if (pure === false) return plugins;
281
- return [plugins, purePlugin(pure ?? {})];
295
+ return [
296
+ extra?.bundleAnalyzer
297
+ ? bundleAnalyzerPlugin(
298
+ extra.bundleAnalyzer === true ? {} : extra.bundleAnalyzer,
299
+ )
300
+ : undefined,
301
+ extra?.pure !== false ? purePlugin(extra?.pure ?? {}) : undefined,
302
+ rawPlugin(),
303
+ ];
282
304
  }
283
305
 
284
306
  function bundleErrorFromUnknown(error: unknown): BundleError {
@@ -0,0 +1,33 @@
1
+ import type { Plugin } from "rolldown";
2
+ import { bundleAnalyzerPlugin as rolldownBundleAnalyzerPlugin } from "rolldown/experimental";
3
+
4
+ export interface BundleAnalyzerPluginOptions {
5
+ /**
6
+ * The filename of the bundle analysis data.
7
+ * @default "analyze-data.md"
8
+ */
9
+ readonly fileName?: string;
10
+ /**
11
+ * The format of the bundle analysis data.
12
+ * @default "md"
13
+ */
14
+ readonly format?: "json" | "md";
15
+ }
16
+
17
+ /**
18
+ * Wraps rolldown's experimental bundle analyzer plugin, which emits a report
19
+ * describing the composition of the bundle.
20
+ *
21
+ * The report includes:
22
+ * - all chunks and their relationships
23
+ * - the modules bundled into each chunk
24
+ * - import dependencies between chunks
25
+ * - the modules reachable from each entry point
26
+ */
27
+ export const bundleAnalyzerPlugin = (
28
+ options: BundleAnalyzerPluginOptions = {},
29
+ ): Plugin =>
30
+ rolldownBundleAnalyzerPlugin({
31
+ fileName: options.fileName,
32
+ format: options.format ?? "md",
33
+ });
@@ -0,0 +1,82 @@
1
+ import type * as rolldown from "rolldown";
2
+
3
+ /**
4
+ * Matches `?raw` or `&raw` query suffixes, mirroring Vite's `rawRE`
5
+ * (see `vite/src/node/utils.ts`). Used to gate both `resolveId` and
6
+ * `load` so the plugin only inspects ids that opt in.
7
+ */
8
+ export const RAW_RE: RegExp = /(\?|&)raw(?:&|$)/;
9
+
10
+ /**
11
+ * Rolldown plugin that adds Vite-style `?raw` import support to the
12
+ * Alchemy bundler.
13
+ *
14
+ * Importing a file with the `?raw` suffix inlines its contents as the
15
+ * default export of a JS module:
16
+ *
17
+ * ```ts
18
+ * import sql from "./schema.sql?raw";
19
+ * // ^ string — the file contents read as UTF-8
20
+ * ```
21
+ *
22
+ * This plugin only implements `?raw`. Vite's `?url` and `?inline`
23
+ * variants both rely on a browser asset pipeline (URL serving / `data:`
24
+ * fallback) that has no analogue in the server-side bundles produced
25
+ * here (Cloudflare Workers, AWS Lambda), so they are intentionally
26
+ * omitted.
27
+ */
28
+ export const rawPlugin = (): rolldown.Plugin => ({
29
+ name: "alchemy:raw",
30
+ resolveId: {
31
+ filter: { id: RAW_RE },
32
+ async handler(source, importer) {
33
+ const [base, query] = splitFileAndPostfix(source);
34
+ const resolved = await this.resolve(base, importer, { skipSelf: true });
35
+ if (!resolved || resolved.external) return null;
36
+ return { id: resolved.id + query, moduleSideEffects: false };
37
+ },
38
+ },
39
+ load: {
40
+ filter: { id: RAW_RE },
41
+ async handler(id) {
42
+ const file = id.replace(/[?#].*$/, "");
43
+ const contents = await this.fs.readFile(file, { encoding: "utf8" });
44
+ return {
45
+ code: `export default ${JSON.stringify(contents)};`,
46
+ // Empty mappings = "this module has no meaningful source map".
47
+ // The generated code is a synthetic `export default "..."` that
48
+ // doesn't correspond line-for-line to any source file (the
49
+ // underlying file isn't JS), so there's nothing to map. Supplying
50
+ // `{ mappings: "" }` (rather than omitting `map`) opts the module
51
+ // out of source-map generation without making rolldown synthesize
52
+ // a default one from the loaded code.
53
+ map: { mappings: "" },
54
+ // NOTE: matches Vite — avoids a double `export default` if the
55
+ // file extension would otherwise be picked up by another loader
56
+ // (e.g. `?raw&.json`).
57
+ moduleType: "js",
58
+ };
59
+ },
60
+ },
61
+ });
62
+
63
+ /**
64
+ * Splits an id into its file portion and the query/hash postfix (kept
65
+ * with the leading `?` / `#`). Matches Vite's `splitFileAndPostfix`.
66
+ *
67
+ * @example
68
+ * splitFileAndPostfix("./foo.txt?raw") // => ["./foo.txt", "?raw"]
69
+ * splitFileAndPostfix("./foo.txt") // => ["./foo.txt", ""]
70
+ */
71
+ export function splitFileAndPostfix(id: string): [string, string] {
72
+ const queryIdx = id.indexOf("?");
73
+ const hashIdx = id.indexOf("#");
74
+ const idx =
75
+ queryIdx === -1
76
+ ? hashIdx
77
+ : hashIdx === -1
78
+ ? queryIdx
79
+ : Math.min(queryIdx, hashIdx);
80
+ if (idx === -1) return [id, ""];
81
+ return [id.slice(0, idx), id.slice(idx)];
82
+ }
@@ -1,4 +1,6 @@
1
1
  export * from "./Bundle.ts";
2
+ export * from "./BundleAnalyzerPlugin.ts";
2
3
  export * from "./Docker.ts";
3
4
  export * from "./PurePlugin.ts";
5
+ export * from "./RawPlugin.ts";
4
6
  export * from "./TempRoot.ts";