alchemy 2.0.0-beta.34 → 2.0.0-beta.36

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 (390) hide show
  1. package/bin/cli.js +8 -7
  2. package/bin/exec.js +253 -52
  3. package/bin/exec.js.map +1 -1
  4. package/lib/AWS/AuthProvider.d.ts +7 -6
  5. package/lib/AWS/AuthProvider.d.ts.map +1 -1
  6. package/lib/AWS/AuthProvider.js +143 -134
  7. package/lib/AWS/AuthProvider.js.map +1 -1
  8. package/lib/AWS/Bootstrap.d.ts +2 -2
  9. package/lib/AWS/Bootstrap.d.ts.map +1 -1
  10. package/lib/AWS/EC2/hosted.d.ts +1 -1
  11. package/lib/AWS/Environment.d.ts +25 -3
  12. package/lib/AWS/Environment.d.ts.map +1 -1
  13. package/lib/AWS/Environment.js +47 -3
  14. package/lib/AWS/Environment.js.map +1 -1
  15. package/lib/AWS/IAM/OpenIDConnectProvider.d.ts +14 -6
  16. package/lib/AWS/IAM/OpenIDConnectProvider.d.ts.map +1 -1
  17. package/lib/AWS/IAM/OpenIDConnectProvider.js +6 -3
  18. package/lib/AWS/IAM/OpenIDConnectProvider.js.map +1 -1
  19. package/lib/AWS/IAM/Policy.d.ts +1 -1
  20. package/lib/AWS/IAM/Policy.d.ts.map +1 -1
  21. package/lib/AWS/IAM/Policy.js.map +1 -1
  22. package/lib/AWS/Lambda/BucketEventSource.d.ts +1 -1
  23. package/lib/AWS/Lambda/BucketEventSource.d.ts.map +1 -1
  24. package/lib/AWS/Lambda/EventBridgeEventSource.d.ts +1 -1
  25. package/lib/AWS/Lambda/EventBridgeEventSource.d.ts.map +1 -1
  26. package/lib/AWS/Lambda/QueueEventSource.d.ts +1 -1
  27. package/lib/AWS/Lambda/QueueEventSource.d.ts.map +1 -1
  28. package/lib/AWS/Lambda/StreamEventSource.d.ts +1 -1
  29. package/lib/AWS/Lambda/StreamEventSource.d.ts.map +1 -1
  30. package/lib/AWS/Lambda/TableEventSource.d.ts +1 -1
  31. package/lib/AWS/Lambda/TableEventSource.d.ts.map +1 -1
  32. package/lib/AWS/Lambda/TopicEventSource.d.ts +1 -1
  33. package/lib/AWS/Lambda/TopicEventSource.d.ts.map +1 -1
  34. package/lib/AWS/Providers.d.ts +1 -1
  35. package/lib/AWS/Providers.d.ts.map +1 -1
  36. package/lib/AWS/Providers.js +2 -1
  37. package/lib/AWS/Providers.js.map +1 -1
  38. package/lib/Auth/Credentials.d.ts +21 -6
  39. package/lib/Auth/Credentials.d.ts.map +1 -1
  40. package/lib/Auth/Credentials.js +30 -31
  41. package/lib/Auth/Credentials.js.map +1 -1
  42. package/lib/Auth/Profile.d.ts +31 -34
  43. package/lib/Auth/Profile.d.ts.map +1 -1
  44. package/lib/Auth/Profile.js +46 -31
  45. package/lib/Auth/Profile.js.map +1 -1
  46. package/lib/Axiom/AuthProvider.d.ts +2 -1
  47. package/lib/Axiom/AuthProvider.d.ts.map +1 -1
  48. package/lib/Axiom/AuthProvider.js +149 -143
  49. package/lib/Axiom/AuthProvider.js.map +1 -1
  50. package/lib/Axiom/Credentials.d.ts +2 -1
  51. package/lib/Axiom/Credentials.d.ts.map +1 -1
  52. package/lib/Axiom/Credentials.js +4 -4
  53. package/lib/Axiom/Credentials.js.map +1 -1
  54. package/lib/Axiom/Providers.d.ts +1 -1
  55. package/lib/Axiom/Providers.d.ts.map +1 -1
  56. package/lib/Axiom/Providers.js +3 -1
  57. package/lib/Axiom/Providers.js.map +1 -1
  58. package/lib/Cli/LoggingCli.d.ts.map +1 -1
  59. package/lib/Cli/LoggingCli.js +105 -7
  60. package/lib/Cli/LoggingCli.js.map +1 -1
  61. package/lib/Cli/checkVersion.d.ts +13 -0
  62. package/lib/Cli/checkVersion.d.ts.map +1 -0
  63. package/lib/Cli/checkVersion.js +47 -0
  64. package/lib/Cli/checkVersion.js.map +1 -0
  65. package/lib/Cli/commands/_shared.d.ts +2 -2
  66. package/lib/Cli/commands/_shared.d.ts.map +1 -1
  67. package/lib/Cli/commands/_shared.js +3 -3
  68. package/lib/Cli/commands/_shared.js.map +1 -1
  69. package/lib/Cli/commands/aws.d.ts +6 -0
  70. package/lib/Cli/commands/aws.d.ts.map +1 -0
  71. package/lib/Cli/commands/aws.js +63 -0
  72. package/lib/Cli/commands/aws.js.map +1 -0
  73. package/lib/Cli/commands/cloudflare.d.ts +17 -0
  74. package/lib/Cli/commands/cloudflare.d.ts.map +1 -0
  75. package/lib/Cli/commands/cloudflare.js +111 -0
  76. package/lib/Cli/commands/cloudflare.js.map +1 -0
  77. package/lib/Cli/commands/deploy.d.ts +6 -5
  78. package/lib/Cli/commands/deploy.d.ts.map +1 -1
  79. package/lib/Cli/commands/deploy.js +10 -10
  80. package/lib/Cli/commands/deploy.js.map +1 -1
  81. package/lib/Cli/commands/dev.d.ts.map +1 -1
  82. package/lib/Cli/commands/dev.js +16 -16
  83. package/lib/Cli/commands/dev.js.map +1 -1
  84. package/lib/Cli/commands/login.d.ts +2 -1
  85. package/lib/Cli/commands/login.d.ts.map +1 -1
  86. package/lib/Cli/commands/login.js +9 -8
  87. package/lib/Cli/commands/login.js.map +1 -1
  88. package/lib/Cli/commands/logs.d.ts +1 -1
  89. package/lib/Cli/commands/logs.d.ts.map +1 -1
  90. package/lib/Cli/commands/logs.js +7 -7
  91. package/lib/Cli/commands/logs.js.map +1 -1
  92. package/lib/Cli/commands/profile.d.ts +3 -1
  93. package/lib/Cli/commands/profile.d.ts.map +1 -1
  94. package/lib/Cli/commands/profile.js +14 -11
  95. package/lib/Cli/commands/profile.js.map +1 -1
  96. package/lib/Cli/commands/state.d.ts +1 -1
  97. package/lib/Cli/commands/state.d.ts.map +1 -1
  98. package/lib/Cli/commands/state.js +8 -8
  99. package/lib/Cli/commands/state.js.map +1 -1
  100. package/lib/Cli/commands/tail.d.ts +1 -1
  101. package/lib/Cli/commands/tail.d.ts.map +1 -1
  102. package/lib/Cli/commands/tail.js +7 -7
  103. package/lib/Cli/commands/tail.js.map +1 -1
  104. package/lib/Cli/exec.d.ts.map +1 -1
  105. package/lib/Cli/exec.js +5 -3
  106. package/lib/Cli/exec.js.map +1 -1
  107. package/lib/Cli/main.d.ts.map +1 -1
  108. package/lib/Cli/main.js +19 -5
  109. package/lib/Cli/main.js.map +1 -1
  110. package/lib/Cli/selectCli.d.ts +12 -0
  111. package/lib/Cli/selectCli.d.ts.map +1 -0
  112. package/lib/Cli/selectCli.js +32 -0
  113. package/lib/Cli/selectCli.js.map +1 -0
  114. package/lib/Cloudflare/Auth/AuthProvider.d.ts +2 -1
  115. package/lib/Cloudflare/Auth/AuthProvider.d.ts.map +1 -1
  116. package/lib/Cloudflare/Auth/AuthProvider.js +235 -214
  117. package/lib/Cloudflare/Auth/AuthProvider.js.map +1 -1
  118. package/lib/Cloudflare/CloudflareEnvironment.d.ts +2 -1
  119. package/lib/Cloudflare/CloudflareEnvironment.d.ts.map +1 -1
  120. package/lib/Cloudflare/CloudflareEnvironment.js +3 -2
  121. package/lib/Cloudflare/CloudflareEnvironment.js.map +1 -1
  122. package/lib/Cloudflare/Credentials.d.ts +2 -1
  123. package/lib/Cloudflare/Credentials.d.ts.map +1 -1
  124. package/lib/Cloudflare/Credentials.js +4 -4
  125. package/lib/Cloudflare/Credentials.js.map +1 -1
  126. package/lib/Cloudflare/D1/D1Clone.d.ts +2 -1
  127. package/lib/Cloudflare/D1/D1Clone.d.ts.map +1 -1
  128. package/lib/Cloudflare/D1/D1Database.d.ts +2 -1
  129. package/lib/Cloudflare/D1/D1Database.d.ts.map +1 -1
  130. package/lib/Cloudflare/D1/D1Import.d.ts +3 -1
  131. package/lib/Cloudflare/D1/D1Import.d.ts.map +1 -1
  132. package/lib/Cloudflare/Images/Images.d.ts +103 -0
  133. package/lib/Cloudflare/Images/Images.d.ts.map +1 -0
  134. package/lib/Cloudflare/Images/Images.js +82 -0
  135. package/lib/Cloudflare/Images/Images.js.map +1 -0
  136. package/lib/Cloudflare/Images/ImagesBinding.d.ts +73 -0
  137. package/lib/Cloudflare/Images/ImagesBinding.d.ts.map +1 -0
  138. package/lib/Cloudflare/Images/ImagesBinding.js +83 -0
  139. package/lib/Cloudflare/Images/ImagesBinding.js.map +1 -0
  140. package/lib/Cloudflare/Images/index.d.ts +3 -0
  141. package/lib/Cloudflare/Images/index.d.ts.map +1 -0
  142. package/lib/Cloudflare/Images/index.js +3 -0
  143. package/lib/Cloudflare/Images/index.js.map +1 -0
  144. package/lib/Cloudflare/Local/Sidecar.d.ts +11 -4
  145. package/lib/Cloudflare/Local/Sidecar.d.ts.map +1 -1
  146. package/lib/Cloudflare/Local/Sidecar.js +8 -6
  147. package/lib/Cloudflare/Local/Sidecar.js.map +1 -1
  148. package/lib/Cloudflare/Local/SidecarHandlers.d.ts.map +1 -1
  149. package/lib/Cloudflare/Local/SidecarHandlers.js +1 -5
  150. package/lib/Cloudflare/Local/SidecarHandlers.js.map +1 -1
  151. package/lib/Cloudflare/Local/SidecarServer.js +5 -2
  152. package/lib/Cloudflare/Local/SidecarServer.js.map +1 -1
  153. package/lib/Cloudflare/Logs.d.ts +5 -0
  154. package/lib/Cloudflare/Logs.d.ts.map +1 -1
  155. package/lib/Cloudflare/Logs.js +70 -1
  156. package/lib/Cloudflare/Logs.js.map +1 -1
  157. package/lib/Cloudflare/Providers.d.ts +1 -1
  158. package/lib/Cloudflare/Providers.d.ts.map +1 -1
  159. package/lib/Cloudflare/Providers.js +6 -1
  160. package/lib/Cloudflare/Providers.js.map +1 -1
  161. package/lib/Cloudflare/Queue/Queue.d.ts +1 -1
  162. package/lib/Cloudflare/Queue/Queue.js +1 -1
  163. package/lib/Cloudflare/Queue/QueueConsumer.d.ts +6 -2
  164. package/lib/Cloudflare/Queue/QueueConsumer.d.ts.map +1 -1
  165. package/lib/Cloudflare/Queue/QueueConsumer.js +194 -53
  166. package/lib/Cloudflare/Queue/QueueConsumer.js.map +1 -1
  167. package/lib/Cloudflare/Queue/QueueEventSource.d.ts +106 -0
  168. package/lib/Cloudflare/Queue/QueueEventSource.d.ts.map +1 -0
  169. package/lib/Cloudflare/Queue/QueueEventSource.js +145 -0
  170. package/lib/Cloudflare/Queue/QueueEventSource.js.map +1 -0
  171. package/lib/Cloudflare/Queue/index.d.ts +1 -0
  172. package/lib/Cloudflare/Queue/index.d.ts.map +1 -1
  173. package/lib/Cloudflare/Queue/index.js +1 -0
  174. package/lib/Cloudflare/Queue/index.js.map +1 -1
  175. package/lib/Cloudflare/R2/R2Bucket.d.ts +229 -0
  176. package/lib/Cloudflare/R2/R2Bucket.d.ts.map +1 -1
  177. package/lib/Cloudflare/R2/R2Bucket.js +309 -2
  178. package/lib/Cloudflare/R2/R2Bucket.js.map +1 -1
  179. package/lib/Cloudflare/StateStore/State.d.ts +4 -3
  180. package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
  181. package/lib/Cloudflare/StateStore/State.js +16 -8
  182. package/lib/Cloudflare/StateStore/State.js.map +1 -1
  183. package/lib/Cloudflare/VpcService/VpcServiceRef.d.ts +1 -1
  184. package/lib/Cloudflare/VpcService/VpcServiceRef.d.ts.map +1 -1
  185. package/lib/Cloudflare/Website/StaticSite.d.ts.map +1 -1
  186. package/lib/Cloudflare/Website/StaticSite.js +10 -1
  187. package/lib/Cloudflare/Website/StaticSite.js.map +1 -1
  188. package/lib/Cloudflare/Workers/Assets.d.ts +1 -1
  189. package/lib/Cloudflare/Workers/Assets.d.ts.map +1 -1
  190. package/lib/Cloudflare/Workers/InferEnv.d.ts +1 -1
  191. package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
  192. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
  193. package/lib/Cloudflare/Workers/LocalWorkerProvider.js +11 -1
  194. package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
  195. package/lib/Cloudflare/Workers/Worker.d.ts +14 -12
  196. package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
  197. package/lib/Cloudflare/Workers/Worker.js +96 -165
  198. package/lib/Cloudflare/Workers/Worker.js.map +1 -1
  199. package/lib/Cloudflare/Workers/WorkerBundle.d.ts +2 -0
  200. package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
  201. package/lib/Cloudflare/Workers/WorkerBundle.js +21 -7
  202. package/lib/Cloudflare/Workers/WorkerBundle.js.map +1 -1
  203. package/lib/Cloudflare/Zone.d.ts +14 -0
  204. package/lib/Cloudflare/Zone.d.ts.map +1 -0
  205. package/lib/Cloudflare/Zone.js +44 -0
  206. package/lib/Cloudflare/Zone.js.map +1 -0
  207. package/lib/Cloudflare/index.d.ts +1 -0
  208. package/lib/Cloudflare/index.d.ts.map +1 -1
  209. package/lib/Cloudflare/index.js +1 -0
  210. package/lib/Cloudflare/index.js.map +1 -1
  211. package/lib/Drizzle/Schema.d.ts.map +1 -1
  212. package/lib/Drizzle/Schema.js +20 -5
  213. package/lib/Drizzle/Schema.js.map +1 -1
  214. package/lib/GitHub/AuthProvider.d.ts +3 -1
  215. package/lib/GitHub/AuthProvider.d.ts.map +1 -1
  216. package/lib/GitHub/AuthProvider.js +114 -108
  217. package/lib/GitHub/AuthProvider.js.map +1 -1
  218. package/lib/GitHub/Credentials.d.ts +2 -1
  219. package/lib/GitHub/Credentials.d.ts.map +1 -1
  220. package/lib/GitHub/Credentials.js +4 -4
  221. package/lib/GitHub/Credentials.js.map +1 -1
  222. package/lib/GitHub/Providers.d.ts +1 -1
  223. package/lib/GitHub/Providers.d.ts.map +1 -1
  224. package/lib/GitHub/Providers.js +3 -1
  225. package/lib/GitHub/Providers.js.map +1 -1
  226. package/lib/GitHub/Secrets.d.ts.map +1 -1
  227. package/lib/GitHub/Secrets.js +14 -1
  228. package/lib/GitHub/Secrets.js.map +1 -1
  229. package/lib/GitHub/Variables.d.ts +40 -0
  230. package/lib/GitHub/Variables.d.ts.map +1 -0
  231. package/lib/GitHub/Variables.js +28 -0
  232. package/lib/GitHub/Variables.js.map +1 -0
  233. package/lib/GitHub/index.d.ts +1 -0
  234. package/lib/GitHub/index.d.ts.map +1 -1
  235. package/lib/GitHub/index.js +1 -0
  236. package/lib/GitHub/index.js.map +1 -1
  237. package/lib/Neon/AuthProvider.d.ts +3 -1
  238. package/lib/Neon/AuthProvider.d.ts.map +1 -1
  239. package/lib/Neon/AuthProvider.js +87 -80
  240. package/lib/Neon/AuthProvider.js.map +1 -1
  241. package/lib/Neon/Credentials.d.ts +2 -1
  242. package/lib/Neon/Credentials.d.ts.map +1 -1
  243. package/lib/Neon/Credentials.js +4 -4
  244. package/lib/Neon/Credentials.js.map +1 -1
  245. package/lib/Neon/NeonEnvironment.d.ts +2 -1
  246. package/lib/Neon/NeonEnvironment.d.ts.map +1 -1
  247. package/lib/Neon/NeonEnvironment.js +3 -2
  248. package/lib/Neon/NeonEnvironment.js.map +1 -1
  249. package/lib/Neon/Project.d.ts +16 -0
  250. package/lib/Neon/Project.d.ts.map +1 -1
  251. package/lib/Neon/Project.js +25 -0
  252. package/lib/Neon/Project.js.map +1 -1
  253. package/lib/Neon/Providers.d.ts +1 -1
  254. package/lib/Neon/Providers.d.ts.map +1 -1
  255. package/lib/Neon/Providers.js +3 -1
  256. package/lib/Neon/Providers.js.map +1 -1
  257. package/lib/Neon/api.d.ts +1 -0
  258. package/lib/Neon/api.d.ts.map +1 -1
  259. package/lib/Neon/api.js +1 -0
  260. package/lib/Neon/api.js.map +1 -1
  261. package/lib/Sidecar/RpcClient.d.ts.map +1 -1
  262. package/lib/Sidecar/RpcClient.js +8 -5
  263. package/lib/Sidecar/RpcClient.js.map +1 -1
  264. package/lib/Sidecar/RpcPaths.d.ts +5 -0
  265. package/lib/Sidecar/RpcPaths.d.ts.map +1 -1
  266. package/lib/Sidecar/RpcPaths.js +10 -1
  267. package/lib/Sidecar/RpcPaths.js.map +1 -1
  268. package/lib/Sidecar/RpcServer.d.ts +24 -4
  269. package/lib/Sidecar/RpcServer.d.ts.map +1 -1
  270. package/lib/Sidecar/RpcServer.js +70 -15
  271. package/lib/Sidecar/RpcServer.js.map +1 -1
  272. package/lib/Sidecar/RpcServerBun.d.ts +4 -0
  273. package/lib/Sidecar/RpcServerBun.d.ts.map +1 -0
  274. package/lib/Sidecar/RpcServerBun.js +28 -0
  275. package/lib/Sidecar/RpcServerBun.js.map +1 -0
  276. package/lib/Sidecar/RpcServerNode.d.ts +4 -0
  277. package/lib/Sidecar/RpcServerNode.d.ts.map +1 -0
  278. package/lib/Sidecar/RpcServerNode.js +39 -0
  279. package/lib/Sidecar/RpcServerNode.js.map +1 -0
  280. package/lib/Sidecar/RpcServices.d.ts +6 -0
  281. package/lib/Sidecar/RpcServices.d.ts.map +1 -0
  282. package/lib/Sidecar/RpcServices.js +29 -0
  283. package/lib/Sidecar/RpcServices.js.map +1 -0
  284. package/lib/Stack.d.ts +5 -3
  285. package/lib/Stack.d.ts.map +1 -1
  286. package/lib/Stack.js +3 -1
  287. package/lib/Stack.js.map +1 -1
  288. package/lib/Test/Core.d.ts.map +1 -1
  289. package/lib/Test/Core.js +5 -4
  290. package/lib/Test/Core.js.map +1 -1
  291. package/lib/Test/Vitest.d.ts.map +1 -1
  292. package/lib/Test/Vitest.js +2 -0
  293. package/lib/Test/Vitest.js.map +1 -1
  294. package/lib/Util/LocalhostDns.d.ts +19 -0
  295. package/lib/Util/LocalhostDns.d.ts.map +1 -0
  296. package/lib/Util/LocalhostDns.js +55 -0
  297. package/lib/Util/LocalhostDns.js.map +1 -0
  298. package/lib/Util/PlatformServices.d.ts.map +1 -1
  299. package/lib/Util/PlatformServices.js +3 -1
  300. package/lib/Util/PlatformServices.js.map +1 -1
  301. package/lib/tsconfig.test.tsbuildinfo +1 -1
  302. package/package.json +16 -12
  303. package/src/AWS/AuthProvider.ts +269 -259
  304. package/src/AWS/Environment.ts +57 -3
  305. package/src/AWS/IAM/OpenIDConnectProvider.ts +19 -8
  306. package/src/AWS/IAM/Policy.ts +1 -1
  307. package/src/AWS/Providers.ts +2 -0
  308. package/src/Auth/Credentials.ts +82 -46
  309. package/src/Auth/Profile.ts +123 -69
  310. package/src/Axiom/AuthProvider.ts +263 -255
  311. package/src/Axiom/Credentials.ts +3 -4
  312. package/src/Axiom/Providers.ts +4 -0
  313. package/src/Cli/LoggingCli.ts +127 -11
  314. package/src/Cli/checkVersion.ts +57 -0
  315. package/src/Cli/commands/_shared.ts +4 -4
  316. package/src/Cli/commands/aws.ts +127 -0
  317. package/src/Cli/commands/cloudflare.ts +222 -0
  318. package/src/Cli/commands/deploy.ts +11 -10
  319. package/src/Cli/commands/dev.ts +28 -33
  320. package/src/Cli/commands/login.ts +9 -12
  321. package/src/Cli/commands/logs.ts +8 -8
  322. package/src/Cli/commands/profile.ts +14 -16
  323. package/src/Cli/commands/state.ts +8 -8
  324. package/src/Cli/commands/tail.ts +8 -8
  325. package/src/Cli/exec.ts +7 -3
  326. package/src/Cli/main.ts +23 -5
  327. package/src/Cli/selectCli.ts +33 -0
  328. package/src/Cloudflare/Auth/AuthProvider.ts +445 -430
  329. package/src/Cloudflare/CloudflareEnvironment.ts +3 -2
  330. package/src/Cloudflare/Credentials.ts +3 -4
  331. package/src/Cloudflare/Images/Images.ts +121 -0
  332. package/src/Cloudflare/Images/ImagesBinding.ts +192 -0
  333. package/src/Cloudflare/Images/index.ts +2 -0
  334. package/src/Cloudflare/Local/Sidecar.ts +13 -10
  335. package/src/Cloudflare/Local/SidecarHandlers.ts +8 -13
  336. package/src/Cloudflare/Local/SidecarServer.ts +6 -1
  337. package/src/Cloudflare/Logs.ts +115 -1
  338. package/src/Cloudflare/Providers.ts +9 -0
  339. package/src/Cloudflare/Queue/Queue.ts +1 -1
  340. package/src/Cloudflare/Queue/QueueConsumer.ts +262 -60
  341. package/src/Cloudflare/Queue/QueueEventSource.ts +234 -0
  342. package/src/Cloudflare/Queue/index.ts +1 -0
  343. package/src/Cloudflare/R2/R2Bucket.ts +570 -2
  344. package/src/Cloudflare/StateStore/State.ts +25 -16
  345. package/src/Cloudflare/Website/StaticSite.ts +11 -1
  346. package/src/Cloudflare/Workers/InferEnv.ts +7 -3
  347. package/src/Cloudflare/Workers/LocalWorkerProvider.ts +9 -1
  348. package/src/Cloudflare/Workers/Worker.ts +130 -231
  349. package/src/Cloudflare/Workers/WorkerBundle.ts +38 -12
  350. package/src/Cloudflare/Zone.ts +88 -0
  351. package/src/Cloudflare/index.ts +1 -0
  352. package/src/Drizzle/Schema.ts +21 -5
  353. package/src/GitHub/AuthProvider.ts +221 -217
  354. package/src/GitHub/Credentials.ts +3 -4
  355. package/src/GitHub/Providers.ts +4 -0
  356. package/src/GitHub/Secrets.ts +25 -1
  357. package/src/GitHub/Variables.ts +54 -0
  358. package/src/GitHub/index.ts +1 -0
  359. package/src/Neon/AuthProvider.ts +160 -154
  360. package/src/Neon/Credentials.ts +3 -4
  361. package/src/Neon/NeonEnvironment.ts +3 -2
  362. package/src/Neon/Project.ts +42 -0
  363. package/src/Neon/Providers.ts +4 -0
  364. package/src/Neon/api.ts +2 -0
  365. package/src/Sidecar/RpcClient.ts +8 -7
  366. package/src/Sidecar/RpcPaths.ts +11 -1
  367. package/src/Sidecar/RpcServer.ts +97 -24
  368. package/src/Sidecar/RpcServerBun.ts +41 -0
  369. package/src/Sidecar/RpcServerNode.ts +51 -0
  370. package/src/Sidecar/RpcServices.ts +48 -0
  371. package/src/Stack.ts +8 -0
  372. package/src/Test/Core.ts +10 -4
  373. package/src/Test/Vitest.ts +3 -0
  374. package/src/Util/LocalhostDns.ts +58 -0
  375. package/src/Util/PlatformServices.ts +3 -1
  376. package/lib/Cli/commands/bootstrap.d.ts +0 -20
  377. package/lib/Cli/commands/bootstrap.d.ts.map +0 -1
  378. package/lib/Cli/commands/bootstrap.js +0 -107
  379. package/lib/Cli/commands/bootstrap.js.map +0 -1
  380. package/lib/Sidecar/RpcTransport.d.ts +0 -22
  381. package/lib/Sidecar/RpcTransport.d.ts.map +0 -1
  382. package/lib/Sidecar/RpcTransport.js +0 -81
  383. package/lib/Sidecar/RpcTransport.js.map +0 -1
  384. package/lib/Test/TestCli.d.ts +0 -19
  385. package/lib/Test/TestCli.d.ts.map +0 -1
  386. package/lib/Test/TestCli.js +0 -175
  387. package/lib/Test/TestCli.js.map +0 -1
  388. package/src/Cli/commands/bootstrap.ts +0 -216
  389. package/src/Sidecar/RpcTransport.ts +0 -85
  390. package/src/Test/TestCli.ts +0 -221
@@ -4,7 +4,7 @@ import * as Effect from "effect/Effect";
4
4
  import * as Layer from "effect/Layer";
5
5
  import * as Option from "effect/Option";
6
6
  import { getAuthProvider } from "../Auth/AuthProvider.ts";
7
- import { ALCHEMY_PROFILE, loadOrConfigure } from "../Auth/Profile.ts";
7
+ import { ALCHEMY_PROFILE, Profile } from "../Auth/Profile.ts";
8
8
  import {
9
9
  CLOUDFLARE_AUTH_PROVIDER_NAME,
10
10
  type CloudflareAuthConfig,
@@ -34,6 +34,7 @@ export const fromProfile = () =>
34
34
  Layer.effect(
35
35
  CloudflareEnvironment,
36
36
  Effect.gen(function* () {
37
+ const profile = yield* Profile;
37
38
  const auth = yield* getAuthProvider<
38
39
  CloudflareAuthConfig,
39
40
  CloudflareResolvedCredentials
@@ -43,7 +44,7 @@ export const fromProfile = () =>
43
44
  // `loadOrConfigure` reads the persisted config under the canonical
44
45
  // provider name (`Cloudflare`); only runs `configure` (and persists the
45
46
  // result) if no stored config exists.
46
- const config = yield* loadOrConfigure(auth, profileName, { ci });
47
+ const config = yield* profile.loadOrConfigure(auth, profileName, { ci });
47
48
  return yield* auth.read(profileName, config as CloudflareAuthConfig);
48
49
  }),
49
50
  );
@@ -11,7 +11,7 @@ import * as Layer from "effect/Layer";
11
11
  import * as Match from "effect/Match";
12
12
  import * as Redacted from "effect/Redacted";
13
13
  import { getAuthProvider } from "../Auth/AuthProvider.ts";
14
- import { ALCHEMY_PROFILE, loadOrConfigure } from "../Auth/Profile.ts";
14
+ import { ALCHEMY_PROFILE, Profile } from "../Auth/Profile.ts";
15
15
  import {
16
16
  CLOUDFLARE_AUTH_PROVIDER_NAME,
17
17
  type CloudflareAuthConfig,
@@ -29,15 +29,15 @@ export const fromAuthProvider = () =>
29
29
  Layer.effect(
30
30
  Credentials,
31
31
  Effect.gen(function* () {
32
+ const profile = yield* Profile;
32
33
  const auth = yield* getAuthProvider<
33
34
  CloudflareAuthConfig,
34
35
  CloudflareResolvedCredentials
35
36
  >(CLOUDFLARE_AUTH_PROVIDER_NAME);
36
37
  const profileName = yield* ALCHEMY_PROFILE;
37
38
  const ci = yield* Config.boolean("CI").pipe(Config.withDefault(false));
38
- const ctx = yield* Effect.context<never>();
39
39
 
40
- return loadOrConfigure(auth, profileName, { ci }).pipe(
40
+ return profile.loadOrConfigure(auth, profileName, { ci }).pipe(
41
41
  Effect.flatMap((config) =>
42
42
  auth.read(profileName, config as CloudflareAuthConfig),
43
43
  ),
@@ -69,7 +69,6 @@ export const fromAuthProvider = () =>
69
69
  message: `Failed to resolve Cloudflare credentials for profile '${profileName}': ${(e as { message?: string }).message ?? String(e)}`,
70
70
  }),
71
71
  ),
72
- Effect.provide(ctx),
73
72
  );
74
73
  }),
75
74
  );
@@ -0,0 +1,121 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { ImagesBinding } from "./ImagesBinding.ts";
3
+
4
+ type ImagesTypeId = typeof ImagesTypeId;
5
+ const ImagesTypeId = "Cloudflare.Images" as const;
6
+
7
+ export type ImagesProps = {
8
+ /**
9
+ * Binding name used when `Cloudflare.Images.bind(images)` attaches Images
10
+ * from inside a Worker init phase. When Images is passed through
11
+ * `Worker({ bindings: { ... } })`, the object key remains the binding name.
12
+ *
13
+ * @default "IMAGES"
14
+ */
15
+ name?: string;
16
+ };
17
+
18
+ /**
19
+ * Marker for a Cloudflare Images binding.
20
+ *
21
+ * Images bindings are configured directly on Workers and do not have a
22
+ * standalone provisioning API. The Worker provider sees this object in
23
+ * `bindings: { ... }` and emits the corresponding `{ type: "images" }`
24
+ * metadata binding to the script.
25
+ */
26
+ export type Images = {
27
+ kind: ImagesTypeId;
28
+ name: string;
29
+ };
30
+
31
+ export const isImages = (value: unknown): value is Images =>
32
+ typeof value === "object" &&
33
+ value !== null &&
34
+ "kind" in value &&
35
+ (value as Images).kind === ImagesTypeId;
36
+
37
+ /**
38
+ * A Cloudflare Images binding for image transformation and manipulation inside
39
+ * Workers.
40
+ *
41
+ * The Effect-native interface (`Cloudflare.Images.bind(...)`) returns an
42
+ * `ImagesClient` whose methods take Effect `Stream.Stream<Uint8Array>`
43
+ * inputs and return `Effect`s — `info`, `input(...).transform(...)
44
+ * .draw(...).output(...)`. The runtime conversion to Cloudflare's
45
+ * `ReadableStream` is handled internally.
46
+ *
47
+ * @section Declaring Images
48
+ * @example
49
+ * ```typescript
50
+ * const Pipeline = yield* Cloudflare.Images({ name: "PIPELINE" });
51
+ * ```
52
+ *
53
+ * @section Effect-style Worker (recommended)
54
+ * @example Read image format and dimensions from the request body
55
+ * ```typescript
56
+ * import { HttpServerRequest } from "effect/unstable/http/HttpServerRequest";
57
+ *
58
+ * Cloudflare.Worker("ImageWorker", { main: import.meta.filename },
59
+ * Effect.gen(function* () {
60
+ * const pipeline = yield* Pipeline;
61
+ * const images = yield* Cloudflare.Images.bind(pipeline);
62
+ * return {
63
+ * fetch: Effect.gen(function* () {
64
+ * const request = yield* HttpServerRequest;
65
+ * // request.stream is Stream.Stream<Uint8Array>
66
+ * const info = yield* images.info(request.stream);
67
+ * return yield* HttpServerResponse.json(info);
68
+ * }),
69
+ * };
70
+ * }).pipe(Effect.provide(Cloudflare.ImagesBindingLive)),
71
+ * );
72
+ * ```
73
+ *
74
+ * @example Transform an image — chainable pipeline, single Effect at the end
75
+ * ```typescript
76
+ * const result = yield* (yield* images.input(request.stream))
77
+ * .transform({ width: 128 })
78
+ * .output({ format: "image/jpeg" });
79
+ *
80
+ * const response = yield* result.response;
81
+ * ```
82
+ *
83
+ * @section Binding to a Worker (declarative)
84
+ * @example
85
+ * ```typescript
86
+ * export const Worker = Cloudflare.Worker("Worker", {
87
+ * main: "./src/worker.ts",
88
+ * bindings: { MEDIA: Pipeline },
89
+ * });
90
+ *
91
+ * export type WorkerEnv = Cloudflare.InferEnv<typeof Worker>;
92
+ * // { MEDIA: ImagesBinding }
93
+ * ```
94
+ *
95
+ * Inside the Worker, the raw Cloudflare runtime binding is reachable via
96
+ * `client.raw` if you need to call `info()` / `input()` directly with
97
+ * `async`/`await`. The Effect-native interface is preferred — it returns
98
+ * tagged `ImagesError`s, threads `WorkerEnvironment`, and lets you stream
99
+ * Effect `Stream<Uint8Array>` sources without manual conversion.
100
+ *
101
+ * @see https://developers.cloudflare.com/images/transform-images/bindings/
102
+ */
103
+ export const Images: {
104
+ (props?: ImagesProps): Effect.Effect<Images>;
105
+ /**
106
+ * Bind Cloudflare Images to the surrounding Worker, returning an
107
+ * Effect-native client with access to the native Workers runtime binding.
108
+ */
109
+ bind: typeof ImagesBinding.bind;
110
+ } = Object.assign(
111
+ Effect.fn(function* (props?: ImagesProps) {
112
+ return {
113
+ kind: ImagesTypeId,
114
+ name: props?.name ?? "IMAGES",
115
+ } satisfies Images;
116
+ }),
117
+ {
118
+ bind: (...args: Parameters<typeof ImagesBinding.bind>) =>
119
+ ImagesBinding.bind(...args),
120
+ },
121
+ );
@@ -0,0 +1,192 @@
1
+ import type * as cf from "@cloudflare/workers-types";
2
+ import * as Data from "effect/Data";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Layer from "effect/Layer";
5
+ import * as Stream from "effect/Stream";
6
+ import * as Binding from "../../Binding.ts";
7
+ import type { ResourceLike } from "../../Resource.ts";
8
+ import { isWorker, WorkerEnvironment } from "../Workers/Worker.ts";
9
+ import { type Images as ImagesLike } from "./Images.ts";
10
+
11
+ export class ImagesError extends Data.TaggedError("ImagesError")<{
12
+ message: string;
13
+ code?: number;
14
+ cause: unknown;
15
+ }> {}
16
+
17
+ /**
18
+ * Effect-native handle to the result of `input(...).output(...)`.
19
+ * Mirrors the runtime `ImageTransformationResult` but exposes side
20
+ * effects (response/image/contentType reads) as plain sync effects.
21
+ */
22
+ export interface ImageTransformationResultClient {
23
+ raw: cf.ImageTransformationResult;
24
+ response: Effect.Effect<cf.Response>;
25
+ contentType: Effect.Effect<string>;
26
+ image(
27
+ options?: cf.ImageTransformationOutputOptions,
28
+ ): Effect.Effect<cf.ReadableStream<Uint8Array>>;
29
+ }
30
+
31
+ /**
32
+ * Effect-native chainable transformer. `transform`/`draw` are pure
33
+ * (return a new client wrapping the next runtime transformer);
34
+ * `output` is the only step that crosses into Cloudflare's runtime
35
+ * and therefore returns an Effect.
36
+ */
37
+ export interface ImageTransformerClient {
38
+ raw: cf.ImageTransformer;
39
+ transform(transform: cf.ImageTransform): ImageTransformerClient;
40
+ draw<E = never, R = never>(
41
+ image: Stream.Stream<Uint8Array, E, R> | ImageTransformerClient,
42
+ options?: cf.ImageDrawOptions,
43
+ ): Effect.Effect<ImageTransformerClient, never, R>;
44
+ output(
45
+ options: cf.ImageOutputOptions,
46
+ ): Effect.Effect<ImageTransformationResultClient, ImagesError>;
47
+ }
48
+
49
+ /**
50
+ * Effect-native client for a Cloudflare Images binding.
51
+ *
52
+ * Wraps the runtime {@link cf.ImagesBinding} so each method returns
53
+ * an Effect tagged with {@link ImagesError}. Use
54
+ * `Cloudflare.Images.bind(images)` inside a Worker's init phase.
55
+ */
56
+ export interface ImagesClient {
57
+ /** Effect resolving to the raw Cloudflare runtime binding. */
58
+ raw: Effect.Effect<cf.ImagesBinding, never, WorkerEnvironment>;
59
+ /**
60
+ * Read image format and dimensions from a stream of bytes.
61
+ * Fails with {@link ImagesError} (code 9412) if the input is not
62
+ * a recognized image.
63
+ */
64
+ info<E = never, R = never>(
65
+ stream: Stream.Stream<Uint8Array, E, R>,
66
+ options?: cf.ImageInputOptions,
67
+ ): Effect.Effect<cf.ImageInfoResponse, ImagesError, WorkerEnvironment | R>;
68
+ /**
69
+ * Begin a transformation pipeline. Subsequent `.transform()` /
70
+ * `.draw()` calls are pure; `.output(opts)` runs the pipeline.
71
+ */
72
+ input<E = never, R = never>(
73
+ stream: Stream.Stream<Uint8Array, E, R>,
74
+ options?: cf.ImageInputOptions,
75
+ ): Effect.Effect<ImageTransformerClient, never, WorkerEnvironment | R>;
76
+ }
77
+
78
+ export class ImagesBinding extends Binding.Service<
79
+ ImagesBinding,
80
+ (images: ImagesLike) => Effect.Effect<ImagesClient>
81
+ >()("Cloudflare.Images.Binding") {}
82
+
83
+ export const ImagesBindingLive = Layer.effect(
84
+ ImagesBinding,
85
+ Effect.gen(function* () {
86
+ const Policy = yield* ImagesBindingPolicy;
87
+
88
+ return Effect.fn(function* (images: ImagesLike) {
89
+ yield* Policy(images);
90
+ const env = WorkerEnvironment.asEffect();
91
+ const raw = env.pipe(
92
+ Effect.map(
93
+ (env) => (env as Record<string, cf.ImagesBinding>)[images.name]!,
94
+ ),
95
+ );
96
+
97
+ return {
98
+ raw,
99
+ info: (stream, options) =>
100
+ Effect.gen(function* () {
101
+ const binding = yield* raw;
102
+ const readable = yield* toCfReadable(stream);
103
+ return yield* tryPromise(() => binding.info(readable, options));
104
+ }),
105
+ input: (stream, options) =>
106
+ Effect.gen(function* () {
107
+ const binding = yield* raw;
108
+ const readable = yield* toCfReadable(stream);
109
+ return wrapTransformer(binding.input(readable, options));
110
+ }),
111
+ } satisfies ImagesClient;
112
+ });
113
+ }),
114
+ );
115
+
116
+ export class ImagesBindingPolicy extends Binding.Policy<
117
+ ImagesBindingPolicy,
118
+ (images: ImagesLike) => Effect.Effect<void>
119
+ >()("Cloudflare.Images.Binding") {}
120
+
121
+ export const ImagesBindingPolicyLive = ImagesBindingPolicy.layer.succeed(
122
+ Effect.fn(function* (host: ResourceLike, images: ImagesLike) {
123
+ if (isWorker(host)) {
124
+ yield* host.bind(images.name, {
125
+ bindings: [
126
+ {
127
+ type: "images",
128
+ name: images.name,
129
+ },
130
+ ],
131
+ });
132
+ } else {
133
+ return yield* Effect.die(
134
+ new Error(`ImagesBinding does not support runtime '${host.Type}'`),
135
+ );
136
+ }
137
+ }),
138
+ );
139
+
140
+ const tryPromise = <T>(fn: () => Promise<T>): Effect.Effect<T, ImagesError> =>
141
+ Effect.tryPromise({
142
+ try: fn,
143
+ catch: (error: any) =>
144
+ new ImagesError({
145
+ message: error?.message ?? "Unknown error",
146
+ code: typeof error?.code === "number" ? error.code : undefined,
147
+ cause: error,
148
+ }),
149
+ });
150
+
151
+ /**
152
+ * Convert an Effect `Stream<Uint8Array>` into the `cf.ReadableStream<Uint8Array>`
153
+ * shape that the Cloudflare Images runtime binding expects. The two
154
+ * `ReadableStream` types only differ at the type level; at runtime they
155
+ * are the same Web Streams API.
156
+ */
157
+ const toCfReadable = <E, R>(
158
+ stream: Stream.Stream<Uint8Array, E, R>,
159
+ ): Effect.Effect<cf.ReadableStream<Uint8Array>, never, R> =>
160
+ Stream.toReadableStreamEffect(stream).pipe(
161
+ Effect.map((s) => s as unknown as cf.ReadableStream<Uint8Array>),
162
+ );
163
+
164
+ const isTransformerClient = (image: unknown): image is ImageTransformerClient =>
165
+ typeof image === "object" && image !== null && "raw" in image;
166
+
167
+ const wrapTransformer = (raw: cf.ImageTransformer): ImageTransformerClient => ({
168
+ raw,
169
+ transform: (transform) => wrapTransformer(raw.transform(transform)),
170
+ draw: <E, R>(
171
+ image: Stream.Stream<Uint8Array, E, R> | ImageTransformerClient,
172
+ options?: cf.ImageDrawOptions,
173
+ ): Effect.Effect<ImageTransformerClient, never, R> => {
174
+ if (isTransformerClient(image)) {
175
+ return Effect.succeed(wrapTransformer(raw.draw(image.raw, options)));
176
+ }
177
+ return toCfReadable(image).pipe(
178
+ Effect.map((readable) => wrapTransformer(raw.draw(readable, options))),
179
+ );
180
+ },
181
+ output: (options) =>
182
+ tryPromise(() => raw.output(options)).pipe(Effect.map(wrapResult)),
183
+ });
184
+
185
+ const wrapResult = (
186
+ raw: cf.ImageTransformationResult,
187
+ ): ImageTransformationResultClient => ({
188
+ raw,
189
+ response: Effect.sync(() => raw.response()),
190
+ contentType: Effect.sync(() => raw.contentType()),
191
+ image: (options) => Effect.sync(() => raw.image(options)),
192
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./Images.ts";
2
+ export * from "./ImagesBinding.ts";
@@ -1,7 +1,4 @@
1
- import {
2
- ServeError,
3
- type ServeResult,
4
- } from "@distilled.cloud/cloudflare-runtime/Server";
1
+ import { RuntimeError } from "@distilled.cloud/cloudflare-runtime/RuntimeError";
5
2
  import * as Worker from "@distilled.cloud/cloudflare-runtime/Worker";
6
3
  import * as Effect from "effect/Effect";
7
4
  import * as Schema from "effect/Schema";
@@ -22,13 +19,19 @@ export interface ServeOptions extends WorkerBundleOptions {
22
19
  durableObjectNamespaces: Worker.DurableObjectNamespace[];
23
20
  }
24
21
 
22
+ export const ServeResult = Schema.Struct({
23
+ name: Schema.String,
24
+ address: Schema.String,
25
+ });
26
+ export type ServeResult = typeof ServeResult.Type;
27
+
28
+ export const ServeError = Schema.Union([RuntimeError, BundleError]);
29
+ export type ServeError = typeof ServeError.Type;
30
+
25
31
  export const SidecarSchema = defineSchema<Sidecar["Service"]>({
26
32
  serve: {
27
- success: Schema.Struct({
28
- name: Schema.String,
29
- address: Schema.String,
30
- }),
31
- error: Schema.Union([ServeError, BundleError]),
33
+ success: ServeResult,
34
+ error: ServeError,
32
35
  },
33
36
  stop: { success: Schema.Void, error: Schema.Never },
34
37
  });
@@ -38,7 +41,7 @@ export class Sidecar extends RpcClient.RpcClientService<
38
41
  {
39
42
  readonly serve: (
40
43
  options: ServeOptions,
41
- ) => Effect.Effect<ServeResult, ServeError | BundleError>;
44
+ ) => Effect.Effect<ServeResult, ServeError>;
42
45
  readonly stop: (name: string) => Effect.Effect<void>;
43
46
  }
44
47
  >()("Sidecar") {}
@@ -12,7 +12,12 @@ import * as Scope from "effect/Scope";
12
12
  import * as Stream from "effect/Stream";
13
13
  import * as Bundle from "../../Bundle/Bundle.ts";
14
14
  import { WorkerBundle } from "../Workers/WorkerBundle.ts";
15
- import { Sidecar, type ServeOptions } from "./Sidecar.ts";
15
+ import {
16
+ Sidecar,
17
+ type ServeError,
18
+ type ServeOptions,
19
+ type ServeResult,
20
+ } from "./Sidecar.ts";
16
21
 
17
22
  export const SidecarHandlers = Layer.effect(
18
23
  Sidecar,
@@ -29,10 +34,6 @@ export const SidecarHandlers = Layer.effect(
29
34
  ) {
30
35
  const scope = yield* Effect.flatMap(Effect.scope, Scope.fork);
31
36
  const result = yield* server
32
- // The published @distilled.cloud/cloudflare-runtime types don't yet
33
- // declare `hyperdrives` on the serve options, but the runtime
34
- // accepts it. Cast through any so dev-mode local DB wiring works
35
- // until the type is shipped upstream.
36
37
  .serve({
37
38
  name: worker.id.toLowerCase(),
38
39
  compatibilityDate: worker.compatibility.date,
@@ -55,19 +56,13 @@ export const SidecarHandlers = Layer.effect(
55
56
  string,
56
57
  {
57
58
  hash: number;
58
- fiber: Fiber.Fiber<
59
- Server.ServeResult,
60
- Server.ServeError | Bundle.BundleError
61
- >;
59
+ fiber: Fiber.Fiber<ServeResult, ServeError>;
62
60
  scope: Scope.Closeable;
63
61
  }
64
62
  >();
65
63
 
66
64
  const serveFiber = Effect.fnUntraced(function* (worker: ServeOptions) {
67
- const result = yield* Deferred.make<
68
- Server.ServeResult,
69
- Server.ServeError | Bundle.BundleError
70
- >();
65
+ const result = yield* Deferred.make<ServeResult, ServeError>();
71
66
  let start = Date.now();
72
67
  yield* bundle.watch(worker).pipe(
73
68
  Stream.mapEffect((event) =>
@@ -5,7 +5,10 @@ import * as Path from "effect/Path";
5
5
  import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
6
6
  import * as AlchemyContext from "../../AlchemyContext.ts";
7
7
  import { AuthProviders } from "../../Auth/AuthProvider.ts";
8
+ import { CredentialsStoreLive } from "../../Auth/Credentials.ts";
9
+ import { ProfileLive } from "../../Auth/Profile.ts";
8
10
  import * as RpcServer from "../../Sidecar/RpcServer.ts";
11
+ import * as RpcServices from "../../Sidecar/RpcServices.ts";
9
12
  import {
10
13
  httpServer,
11
14
  PlatformServices,
@@ -23,6 +26,8 @@ const apiServices = Layer.merge(
23
26
  ).pipe(
24
27
  Layer.provide(CloudflareAuth),
25
28
  Layer.provide(Layer.succeed(AuthProviders, {})),
29
+ Layer.provide(ProfileLive),
30
+ Layer.provide(CredentialsStoreLive),
26
31
  );
27
32
 
28
33
  const runtimeServices = SidecarHandlers.pipe(
@@ -46,7 +51,7 @@ const runtimeServices = SidecarHandlers.pipe(
46
51
  );
47
52
 
48
53
  const services = Layer.provideMerge(
49
- Layer.provideMerge(runtimeServices, RpcServer.layerServices(import.meta.url)),
54
+ Layer.provideMerge(runtimeServices, RpcServices.layer(import.meta.url)),
50
55
  PlatformServices,
51
56
  );
52
57
 
@@ -1,6 +1,10 @@
1
1
  import * as workers from "@distilled.cloud/cloudflare/workers";
2
+ import type * as Cause from "effect/Cause";
2
3
  import * as Effect from "effect/Effect";
4
+ import * as Queue from "effect/Queue";
5
+ import * as Schedule from "effect/Schedule";
3
6
  import * as Stream from "effect/Stream";
7
+ import * as Socket from "effect/unstable/socket/Socket";
4
8
  import type { LogLine, LogsInput } from "../Provider.ts";
5
9
 
6
10
  const DEFAULT_LOOKBACK_MS = 1 * 60 * 60 * 1000;
@@ -23,6 +27,33 @@ export interface TelemetryFilter {
23
27
  value?: string | number | boolean;
24
28
  }
25
29
 
30
+ interface TailEventMessage {
31
+ eventTimestamp?: number;
32
+ wallTime: number;
33
+ cpuTime: number;
34
+ truncated: boolean;
35
+ outcome: string;
36
+ scriptName: string;
37
+ exceptions: {
38
+ name: string;
39
+ message: string;
40
+ stack: string;
41
+ timestamp: string;
42
+ }[];
43
+ logs: {
44
+ message: string[];
45
+ level: string;
46
+ timestamp: string;
47
+ }[];
48
+ event:
49
+ | {
50
+ request: { method: string; url: string };
51
+ response?: { status: number };
52
+ }
53
+ | null
54
+ | undefined;
55
+ }
56
+
26
57
  const parseEvents = (
27
58
  response: workers.QueryObservabilityTelemetryResponse,
28
59
  ): LogLine[] => {
@@ -44,6 +75,8 @@ const parseEvents = (
44
75
 
45
76
  export const CloudflareLogs = Effect.gen(function* () {
46
77
  const queryTelemetry = yield* workers.queryObservabilityTelemetry;
78
+ const createScriptTail = yield* workers.createScriptTail;
79
+ const deleteScriptTail = yield* workers.deleteScriptTail;
47
80
 
48
81
  const queryLogs = (opts: {
49
82
  accountId: string;
@@ -83,6 +116,87 @@ export const CloudflareLogs = Effect.gen(function* () {
83
116
  return parseEvents(response);
84
117
  });
85
118
 
119
+ /**
120
+ * Open a real-time Workers tail session against `scriptName` and
121
+ * surface its messages as a {@link LogLine} stream. The websocket is
122
+ * automatically reconnected (with `Stream.repeat`) when Cloudflare
123
+ * closes it after its idle window.
124
+ */
125
+ const tailScript = (opts: { accountId: string; scriptName: string }) => {
126
+ const runTailSession = Effect.gen(function* () {
127
+ const { id: tailId, url } = yield* createScriptTail({
128
+ scriptName: opts.scriptName,
129
+ accountId: opts.accountId,
130
+ body: { filters: [] },
131
+ });
132
+
133
+ const socket = yield* Socket.makeWebSocket(url, {
134
+ protocols: ["trace-v1"],
135
+ });
136
+
137
+ const queue = yield* Queue.make<LogLine, Cause.Done>();
138
+
139
+ yield* socket
140
+ .runRaw((raw) => {
141
+ const text =
142
+ typeof raw === "string" ? raw : new TextDecoder().decode(raw);
143
+ const data: TailEventMessage = JSON.parse(text);
144
+ const eventTs = new Date(data.eventTimestamp ?? Date.now());
145
+
146
+ if (data.event && "request" in data.event) {
147
+ const reqEvent = data.event;
148
+ const pathname = (() => {
149
+ try {
150
+ return new URL(reqEvent.request.url).pathname;
151
+ } catch {
152
+ return reqEvent.request.url;
153
+ }
154
+ })();
155
+ const status = reqEvent.response?.status ?? 500;
156
+ Queue.offerUnsafe(queue, {
157
+ timestamp: eventTs,
158
+ message: `${reqEvent.request.method} ${pathname} > ${status} (cpu: ${Math.round(data.cpuTime)}ms, wall: ${Math.round(data.wallTime)}ms)`,
159
+ });
160
+ }
161
+
162
+ for (const log of data.logs) {
163
+ const msg = log.message.join(" ");
164
+ Queue.offerUnsafe(queue, {
165
+ timestamp: new Date(log.timestamp),
166
+ message: log.level === "log" ? msg : `${log.level}: ${msg}`,
167
+ });
168
+ }
169
+
170
+ for (const exception of data.exceptions) {
171
+ Queue.offerUnsafe(queue, {
172
+ timestamp: new Date(exception.timestamp),
173
+ message: `${exception.name} ${exception.message}\n${exception.stack}`,
174
+ });
175
+ }
176
+ })
177
+ .pipe(
178
+ Effect.ensuring(
179
+ Effect.all([
180
+ deleteScriptTail({
181
+ scriptName: opts.scriptName,
182
+ id: tailId,
183
+ accountId: opts.accountId,
184
+ }).pipe(Effect.ignore),
185
+ Queue.end(queue),
186
+ ]),
187
+ ),
188
+ Effect.ignore,
189
+ Effect.forkChild(),
190
+ );
191
+
192
+ return Stream.fromQueue(queue);
193
+ });
194
+
195
+ return Stream.unwrap(runTailSession).pipe(
196
+ Stream.repeat(Schedule.spaced("1 second")),
197
+ );
198
+ };
199
+
86
200
  const tailStream = (opts: {
87
201
  accountId: string;
88
202
  filters: TelemetryFilter[];
@@ -118,5 +232,5 @@ export const CloudflareLogs = Effect.gen(function* () {
118
232
  return poll(Date.now());
119
233
  };
120
234
 
121
- return { queryLogs, tailStream };
235
+ return { queryLogs, tailScript, tailStream };
122
236
  });
@@ -8,6 +8,8 @@ import * as Schedule from "effect/Schedule";
8
8
  import { Command } from "../Build/Command.ts";
9
9
  import * as Build from "../Build/index.ts";
10
10
  import * as Provider from "../Provider.ts";
11
+ import { CredentialsStoreLive } from "../Auth/Credentials.ts";
12
+ import { ProfileLive } from "../Auth/Profile.ts";
11
13
  import { Random, RandomProvider } from "../Random.ts";
12
14
  import * as Access from "./Access.ts";
13
15
  import * as AiGateway from "./AiGateway/index.ts";
@@ -19,6 +21,7 @@ import * as Containers from "./Container/index.ts";
19
21
  import * as Credentials from "./Credentials.ts";
20
22
  import * as D1 from "./D1/index.ts";
21
23
  import * as Hyperdrive from "./Hyperdrive/index.ts";
24
+ import * as Images from "./Images/index.ts";
22
25
  import * as KV from "./KV/index.ts";
23
26
  import * as Queue from "./Queue/index.ts";
24
27
  import * as R2 from "./R2/index.ts";
@@ -54,11 +57,13 @@ export const providers = () =>
54
57
  D1.D1Database,
55
58
  Hyperdrive.Hyperdrive,
56
59
  Hyperdrive.HyperdriveBindingPolicy,
60
+ Images.ImagesBindingPolicy,
57
61
  KV.KVNamespace,
58
62
  KV.KVNamespaceBindingPolicy,
59
63
  Queue.Queue,
60
64
  Queue.QueueBindingPolicy,
61
65
  Queue.QueueConsumer,
66
+ Queue.QueueEventSourcePolicy,
62
67
  R2.R2Bucket,
63
68
  R2.R2BucketBindingPolicy,
64
69
  SecretsStore.SecretBindingPolicy,
@@ -85,9 +90,11 @@ export const providers = () =>
85
90
  D1.DatabaseProvider(),
86
91
  Hyperdrive.HyperdriveBindingPolicyLive,
87
92
  Hyperdrive.HyperdriveProvider(),
93
+ Images.ImagesBindingPolicyLive,
88
94
  KV.KVNamespaceBindingPolicyLive,
89
95
  KV.KVNamespaceProvider(),
90
96
  Queue.QueueBindingPolicyLive,
97
+ Queue.QueueEventSourcePolicyLive,
91
98
  Queue.QueueProvider(),
92
99
  Queue.QueueConsumerProvider(),
93
100
  R2.R2BucketBindingPolicyLive,
@@ -110,6 +117,8 @@ export const providers = () =>
110
117
  Layer.provideMerge(CloudflareEnvironment.fromProfile()),
111
118
  Layer.provideMerge(CloudflareAuth),
112
119
  Layer.provideMerge(Access.AccessLive),
120
+ Layer.provideMerge(ProfileLive),
121
+ Layer.provideMerge(CredentialsStoreLive),
113
122
  // Apply a blanket retry policy to every Cloudflare API call. Extends
114
123
  // `Retry.makeDefault`'s transient detection (throttling / 5xx /
115
124
  // network) with one Cloudflare-specific misleadingly-tagged