alchemy 0.24.1 → 0.26.0

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 (500) hide show
  1. package/README.md +7 -0
  2. package/lib/ai/astro-file.d.ts.map +1 -1
  3. package/lib/ai/astro-file.js +2 -1
  4. package/lib/ai/astro-file.js.map +1 -1
  5. package/lib/ai/client.d.ts.map +1 -1
  6. package/lib/ai/client.js +3 -2
  7. package/lib/ai/client.js.map +1 -1
  8. package/lib/alchemy.d.ts +7 -0
  9. package/lib/alchemy.d.ts.map +1 -1
  10. package/lib/alchemy.js +19 -3
  11. package/lib/alchemy.js.map +1 -1
  12. package/lib/apply.d.ts.map +1 -1
  13. package/lib/apply.js +63 -5
  14. package/lib/apply.js.map +1 -1
  15. package/lib/aws/control/client.js +5 -4
  16. package/lib/aws/control/client.js.map +1 -1
  17. package/lib/aws/control/properties.d.ts +6 -0
  18. package/lib/aws/control/properties.d.ts.map +1 -1
  19. package/lib/aws/control/properties.js +48 -0
  20. package/lib/aws/control/properties.js.map +1 -1
  21. package/lib/aws/control/resource.d.ts.map +1 -1
  22. package/lib/aws/control/resource.js +5 -3
  23. package/lib/aws/control/resource.js.map +1 -1
  24. package/lib/aws/control/types.d.ts +3969 -4862
  25. package/lib/aws/control/types.d.ts.map +1 -1
  26. package/lib/aws/control/types.js.map +1 -1
  27. package/lib/aws/function.d.ts.map +1 -1
  28. package/lib/aws/function.js +9 -8
  29. package/lib/aws/function.js.map +1 -1
  30. package/lib/aws/oidc/oidc-provider.d.ts.map +1 -1
  31. package/lib/aws/oidc/oidc-provider.js +3 -2
  32. package/lib/aws/oidc/oidc-provider.js.map +1 -1
  33. package/lib/aws/queue.d.ts.map +1 -1
  34. package/lib/aws/queue.js +3 -2
  35. package/lib/aws/queue.js.map +1 -1
  36. package/lib/aws/role.d.ts.map +1 -1
  37. package/lib/aws/role.js +3 -1
  38. package/lib/aws/role.js.map +1 -1
  39. package/lib/aws/ssm-parameter.d.ts.map +1 -1
  40. package/lib/aws/ssm-parameter.js +2 -1
  41. package/lib/aws/ssm-parameter.js.map +1 -1
  42. package/lib/cloudflare/account-api-token.d.ts.map +1 -1
  43. package/lib/cloudflare/account-api-token.js +3 -2
  44. package/lib/cloudflare/account-api-token.js.map +1 -1
  45. package/lib/cloudflare/ai-gateway.d.ts.map +1 -1
  46. package/lib/cloudflare/ai-gateway.js +4 -3
  47. package/lib/cloudflare/ai-gateway.js.map +1 -1
  48. package/lib/cloudflare/ai.d.ts +21 -0
  49. package/lib/cloudflare/ai.d.ts.map +1 -1
  50. package/lib/cloudflare/ai.js +21 -0
  51. package/lib/cloudflare/ai.js.map +1 -1
  52. package/lib/cloudflare/api-error.d.ts +0 -9
  53. package/lib/cloudflare/api-error.d.ts.map +1 -1
  54. package/lib/cloudflare/api-error.js +24 -0
  55. package/lib/cloudflare/api-error.js.map +1 -1
  56. package/lib/cloudflare/api.d.ts.map +1 -1
  57. package/lib/cloudflare/api.js +5 -4
  58. package/lib/cloudflare/api.js.map +1 -1
  59. package/lib/cloudflare/assets.d.ts.map +1 -1
  60. package/lib/cloudflare/assets.js +26 -6
  61. package/lib/cloudflare/assets.js.map +1 -1
  62. package/lib/cloudflare/astro.d.ts +63 -0
  63. package/lib/cloudflare/astro.d.ts.map +1 -0
  64. package/lib/cloudflare/astro.js +133 -0
  65. package/lib/cloudflare/astro.js.map +1 -0
  66. package/lib/cloudflare/auth.d.ts.map +1 -1
  67. package/lib/cloudflare/auth.js +3 -2
  68. package/lib/cloudflare/auth.js.map +1 -1
  69. package/lib/cloudflare/bindings.d.ts +23 -2
  70. package/lib/cloudflare/bindings.d.ts.map +1 -1
  71. package/lib/cloudflare/bindings.js.map +1 -1
  72. package/lib/cloudflare/bound.d.ts +7 -1
  73. package/lib/cloudflare/bound.d.ts.map +1 -1
  74. package/lib/cloudflare/bucket.d.ts.map +1 -1
  75. package/lib/cloudflare/bucket.js +12 -8
  76. package/lib/cloudflare/bucket.js.map +1 -1
  77. package/lib/cloudflare/bundle/bundle-worker.d.ts.map +1 -1
  78. package/lib/cloudflare/bundle/bundle-worker.js +2 -1
  79. package/lib/cloudflare/bundle/bundle-worker.js.map +1 -1
  80. package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts.map +1 -1
  81. package/lib/cloudflare/bundle/nodejs-compat-mode.js +2 -1
  82. package/lib/cloudflare/bundle/nodejs-compat-mode.js.map +1 -1
  83. package/lib/cloudflare/custom-domain.d.ts.map +1 -1
  84. package/lib/cloudflare/custom-domain.js +10 -9
  85. package/lib/cloudflare/custom-domain.js.map +1 -1
  86. package/lib/cloudflare/d1-database.d.ts.map +1 -1
  87. package/lib/cloudflare/d1-database.js +11 -10
  88. package/lib/cloudflare/d1-database.js.map +1 -1
  89. package/lib/cloudflare/d1-export.d.ts.map +1 -1
  90. package/lib/cloudflare/d1-export.js +2 -1
  91. package/lib/cloudflare/d1-export.js.map +1 -1
  92. package/lib/cloudflare/d1-import.d.ts.map +1 -1
  93. package/lib/cloudflare/d1-import.js +2 -1
  94. package/lib/cloudflare/d1-import.js.map +1 -1
  95. package/lib/cloudflare/d1-migrations.d.ts.map +1 -1
  96. package/lib/cloudflare/d1-migrations.js +2 -1
  97. package/lib/cloudflare/d1-migrations.js.map +1 -1
  98. package/lib/cloudflare/dns-records.d.ts.map +1 -1
  99. package/lib/cloudflare/dns-records.js +5 -4
  100. package/lib/cloudflare/dns-records.js.map +1 -1
  101. package/lib/cloudflare/do-state-store/worker.d.ts.map +1 -1
  102. package/lib/cloudflare/do-state-store/worker.js +4 -0
  103. package/lib/cloudflare/do-state-store/worker.js.map +1 -1
  104. package/lib/cloudflare/email-address.d.ts +79 -0
  105. package/lib/cloudflare/email-address.d.ts.map +1 -0
  106. package/lib/cloudflare/email-address.js +112 -0
  107. package/lib/cloudflare/email-address.js.map +1 -0
  108. package/lib/cloudflare/email-catch-all.d.ts +123 -0
  109. package/lib/cloudflare/email-catch-all.d.ts.map +1 -0
  110. package/lib/cloudflare/email-catch-all.js +124 -0
  111. package/lib/cloudflare/email-catch-all.js.map +1 -0
  112. package/lib/cloudflare/email-routing.d.ts +89 -0
  113. package/lib/cloudflare/email-routing.d.ts.map +1 -0
  114. package/lib/cloudflare/email-routing.js +120 -0
  115. package/lib/cloudflare/email-routing.js.map +1 -0
  116. package/lib/cloudflare/email-rule.d.ts +196 -0
  117. package/lib/cloudflare/email-rule.d.ts.map +1 -0
  118. package/lib/cloudflare/email-rule.js +153 -0
  119. package/lib/cloudflare/email-rule.js.map +1 -0
  120. package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
  121. package/lib/cloudflare/hyperdrive.js +5 -4
  122. package/lib/cloudflare/hyperdrive.js.map +1 -1
  123. package/lib/cloudflare/images.d.ts +60 -0
  124. package/lib/cloudflare/images.d.ts.map +1 -0
  125. package/lib/cloudflare/images.js +60 -0
  126. package/lib/cloudflare/images.js.map +1 -0
  127. package/lib/cloudflare/index.d.ts +9 -0
  128. package/lib/cloudflare/index.d.ts.map +1 -1
  129. package/lib/cloudflare/index.js +9 -0
  130. package/lib/cloudflare/index.js.map +1 -1
  131. package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
  132. package/lib/cloudflare/kv-namespace.js +2 -1
  133. package/lib/cloudflare/kv-namespace.js.map +1 -1
  134. package/lib/cloudflare/pipeline.d.ts +7 -0
  135. package/lib/cloudflare/pipeline.d.ts.map +1 -1
  136. package/lib/cloudflare/pipeline.js +28 -2
  137. package/lib/cloudflare/pipeline.js.map +1 -1
  138. package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
  139. package/lib/cloudflare/queue-consumer.js +2 -1
  140. package/lib/cloudflare/queue-consumer.js.map +1 -1
  141. package/lib/cloudflare/queue.d.ts.map +1 -1
  142. package/lib/cloudflare/queue.js +0 -8
  143. package/lib/cloudflare/queue.js.map +1 -1
  144. package/lib/cloudflare/route.d.ts +26 -1
  145. package/lib/cloudflare/route.d.ts.map +1 -1
  146. package/lib/cloudflare/route.js +84 -16
  147. package/lib/cloudflare/route.js.map +1 -1
  148. package/lib/cloudflare/secret.d.ts +137 -0
  149. package/lib/cloudflare/secret.d.ts.map +1 -0
  150. package/lib/cloudflare/secret.js +122 -0
  151. package/lib/cloudflare/secret.js.map +1 -0
  152. package/lib/cloudflare/secrets-store.d.ts +145 -0
  153. package/lib/cloudflare/secrets-store.d.ts.map +1 -0
  154. package/lib/cloudflare/secrets-store.js +213 -0
  155. package/lib/cloudflare/secrets-store.js.map +1 -0
  156. package/lib/cloudflare/sveltekit.d.ts +49 -0
  157. package/lib/cloudflare/sveltekit.d.ts.map +1 -0
  158. package/lib/cloudflare/sveltekit.js +56 -0
  159. package/lib/cloudflare/sveltekit.js.map +1 -0
  160. package/lib/cloudflare/user.d.ts.map +1 -1
  161. package/lib/cloudflare/user.js +2 -1
  162. package/lib/cloudflare/user.js.map +1 -1
  163. package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
  164. package/lib/cloudflare/vectorize-index.js +6 -5
  165. package/lib/cloudflare/vectorize-index.js.map +1 -1
  166. package/lib/cloudflare/vectorize-metadata-index.d.ts.map +1 -1
  167. package/lib/cloudflare/vectorize-metadata-index.js +2 -1
  168. package/lib/cloudflare/vectorize-metadata-index.js.map +1 -1
  169. package/lib/cloudflare/website.d.ts.map +1 -1
  170. package/lib/cloudflare/website.js +7 -2
  171. package/lib/cloudflare/website.js.map +1 -1
  172. package/lib/cloudflare/worker-assets.d.ts +18 -0
  173. package/lib/cloudflare/worker-assets.d.ts.map +1 -1
  174. package/lib/cloudflare/worker-assets.js +61 -57
  175. package/lib/cloudflare/worker-assets.js.map +1 -1
  176. package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
  177. package/lib/cloudflare/worker-metadata.js +16 -1
  178. package/lib/cloudflare/worker-metadata.js.map +1 -1
  179. package/lib/cloudflare/worker.d.ts +31 -1
  180. package/lib/cloudflare/worker.d.ts.map +1 -1
  181. package/lib/cloudflare/worker.js +34 -8
  182. package/lib/cloudflare/worker.js.map +1 -1
  183. package/lib/cloudflare/wrangler.json.d.ts +14 -0
  184. package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
  185. package/lib/cloudflare/wrangler.json.js +23 -0
  186. package/lib/cloudflare/wrangler.json.js.map +1 -1
  187. package/lib/cloudflare/zone.d.ts +30 -2
  188. package/lib/cloudflare/zone.d.ts.map +1 -1
  189. package/lib/cloudflare/zone.js +57 -3
  190. package/lib/cloudflare/zone.js.map +1 -1
  191. package/lib/destroy.d.ts.map +1 -1
  192. package/lib/destroy.js +30 -13
  193. package/lib/destroy.js.map +1 -1
  194. package/lib/dns/godaddy.d.ts.map +1 -1
  195. package/lib/dns/godaddy.js +3 -2
  196. package/lib/dns/godaddy.js.map +1 -1
  197. package/lib/dns/import-dns.d.ts.map +1 -1
  198. package/lib/dns/import-dns.js +2 -1
  199. package/lib/dns/import-dns.js.map +1 -1
  200. package/lib/esbuild/bundle.d.ts +1 -1
  201. package/lib/esbuild/bundle.d.ts.map +1 -1
  202. package/lib/esbuild/bundle.js +2 -1
  203. package/lib/esbuild/bundle.js.map +1 -1
  204. package/lib/fs/copy-file.d.ts.map +1 -1
  205. package/lib/fs/copy-file.js +2 -1
  206. package/lib/fs/copy-file.js.map +1 -1
  207. package/lib/fs/file.d.ts.map +1 -1
  208. package/lib/fs/file.js +2 -1
  209. package/lib/fs/file.js.map +1 -1
  210. package/lib/github/client.d.ts.map +1 -1
  211. package/lib/github/client.js +11 -10
  212. package/lib/github/client.js.map +1 -1
  213. package/lib/github/repository-environment.d.ts.map +1 -1
  214. package/lib/github/repository-environment.js +5 -4
  215. package/lib/github/repository-environment.js.map +1 -1
  216. package/lib/github/secret.d.ts.map +1 -1
  217. package/lib/github/secret.js +7 -6
  218. package/lib/github/secret.js.map +1 -1
  219. package/lib/index.d.ts +2 -1
  220. package/lib/index.d.ts.map +1 -1
  221. package/lib/index.js +1 -0
  222. package/lib/index.js.map +1 -1
  223. package/lib/neon/project.d.ts.map +1 -1
  224. package/lib/neon/project.js +3 -2
  225. package/lib/neon/project.js.map +1 -1
  226. package/lib/planetscale/api.d.ts +53 -0
  227. package/lib/planetscale/api.d.ts.map +1 -0
  228. package/lib/planetscale/api.js +84 -0
  229. package/lib/planetscale/api.js.map +1 -0
  230. package/lib/planetscale/branch.d.ts +129 -0
  231. package/lib/planetscale/branch.d.ts.map +1 -0
  232. package/lib/planetscale/branch.js +161 -0
  233. package/lib/planetscale/branch.js.map +1 -0
  234. package/lib/planetscale/database.d.ts +143 -0
  235. package/lib/planetscale/database.d.ts.map +1 -0
  236. package/lib/planetscale/database.js +184 -0
  237. package/lib/planetscale/database.js.map +1 -0
  238. package/lib/planetscale/index.d.ts +5 -0
  239. package/lib/planetscale/index.d.ts.map +1 -0
  240. package/lib/planetscale/index.js +5 -0
  241. package/lib/planetscale/index.js.map +1 -0
  242. package/lib/planetscale/utils.d.ts +15 -0
  243. package/lib/planetscale/utils.d.ts.map +1 -0
  244. package/lib/planetscale/utils.js +95 -0
  245. package/lib/planetscale/utils.js.map +1 -0
  246. package/lib/resource.js +7 -1
  247. package/lib/resource.js.map +1 -1
  248. package/lib/runtime/plugin.d.ts.map +1 -1
  249. package/lib/runtime/plugin.js +2 -1
  250. package/lib/runtime/plugin.js.map +1 -1
  251. package/lib/scope.d.ts +13 -2
  252. package/lib/scope.d.ts.map +1 -1
  253. package/lib/scope.js +53 -10
  254. package/lib/scope.js.map +1 -1
  255. package/lib/sentry/client-key.d.ts.map +1 -1
  256. package/lib/sentry/client-key.js +5 -4
  257. package/lib/sentry/client-key.js.map +1 -1
  258. package/lib/sentry/project.d.ts.map +1 -1
  259. package/lib/sentry/project.js +5 -4
  260. package/lib/sentry/project.js.map +1 -1
  261. package/lib/sentry/team.d.ts.map +1 -1
  262. package/lib/sentry/team.js +5 -4
  263. package/lib/sentry/team.js.map +1 -1
  264. package/lib/stripe/card.d.ts.map +1 -1
  265. package/lib/stripe/card.js +2 -1
  266. package/lib/stripe/card.js.map +1 -1
  267. package/lib/stripe/client.d.ts.map +1 -1
  268. package/lib/stripe/client.js +3 -2
  269. package/lib/stripe/client.js.map +1 -1
  270. package/lib/stripe/coupon.d.ts.map +1 -1
  271. package/lib/stripe/coupon.js +2 -1
  272. package/lib/stripe/coupon.js.map +1 -1
  273. package/lib/stripe/customer.d.ts.map +1 -1
  274. package/lib/stripe/customer.js +2 -1
  275. package/lib/stripe/customer.js.map +1 -1
  276. package/lib/stripe/entitlements-feature.d.ts.map +1 -1
  277. package/lib/stripe/entitlements-feature.js +2 -1
  278. package/lib/stripe/entitlements-feature.js.map +1 -1
  279. package/lib/stripe/file.d.ts.map +1 -1
  280. package/lib/stripe/file.js +2 -1
  281. package/lib/stripe/file.js.map +1 -1
  282. package/lib/stripe/meter.d.ts.map +1 -1
  283. package/lib/stripe/meter.js +4 -2
  284. package/lib/stripe/meter.js.map +1 -1
  285. package/lib/stripe/portal-configuration.d.ts.map +1 -1
  286. package/lib/stripe/portal-configuration.js +2 -1
  287. package/lib/stripe/portal-configuration.js.map +1 -1
  288. package/lib/stripe/price.d.ts.map +1 -1
  289. package/lib/stripe/price.js +2 -1
  290. package/lib/stripe/price.js.map +1 -1
  291. package/lib/stripe/product-feature.d.ts.map +1 -1
  292. package/lib/stripe/product-feature.js +2 -1
  293. package/lib/stripe/product-feature.js.map +1 -1
  294. package/lib/stripe/product.d.ts.map +1 -1
  295. package/lib/stripe/product.js +2 -1
  296. package/lib/stripe/product.js.map +1 -1
  297. package/lib/stripe/promotion-code.d.ts.map +1 -1
  298. package/lib/stripe/promotion-code.js +2 -1
  299. package/lib/stripe/promotion-code.js.map +1 -1
  300. package/lib/stripe/shipping-rate.d.ts.map +1 -1
  301. package/lib/stripe/shipping-rate.js +2 -1
  302. package/lib/stripe/shipping-rate.js.map +1 -1
  303. package/lib/stripe/tax-rate.d.ts.map +1 -1
  304. package/lib/stripe/tax-rate.js +2 -1
  305. package/lib/stripe/tax-rate.js.map +1 -1
  306. package/lib/stripe/webhook.d.ts.map +1 -1
  307. package/lib/stripe/webhook.js +3 -2
  308. package/lib/stripe/webhook.js.map +1 -1
  309. package/lib/test/bun.d.ts.map +1 -1
  310. package/lib/test/bun.js +6 -1
  311. package/lib/test/bun.js.map +1 -1
  312. package/lib/test/prune.js +7 -1
  313. package/lib/test/prune.js.map +1 -1
  314. package/lib/test/vitest.d.ts.map +1 -1
  315. package/lib/test/vitest.js +2 -0
  316. package/lib/test/vitest.js.map +1 -1
  317. package/lib/upstash/redis.d.ts.map +1 -1
  318. package/lib/upstash/redis.js +2 -1
  319. package/lib/upstash/redis.js.map +1 -1
  320. package/lib/util/async-queue.d.ts +35 -0
  321. package/lib/util/async-queue.d.ts.map +1 -0
  322. package/lib/util/async-queue.js +87 -0
  323. package/lib/util/async-queue.js.map +1 -0
  324. package/lib/util/cli.d.ts +37 -0
  325. package/lib/util/cli.d.ts.map +1 -0
  326. package/lib/util/cli.js +90 -0
  327. package/lib/util/cli.js.map +1 -0
  328. package/lib/util/ignore-matcher.d.ts +94 -0
  329. package/lib/util/ignore-matcher.d.ts.map +1 -0
  330. package/lib/util/ignore-matcher.js +616 -0
  331. package/lib/util/ignore-matcher.js.map +1 -0
  332. package/lib/util/logger.d.ts +3 -0
  333. package/lib/util/logger.d.ts.map +1 -0
  334. package/lib/util/logger.js +15 -0
  335. package/lib/util/logger.js.map +1 -0
  336. package/lib/util/retry.d.ts.map +1 -1
  337. package/lib/util/retry.js +0 -1
  338. package/lib/util/retry.js.map +1 -1
  339. package/lib/util/safe-fetch.d.ts.map +1 -1
  340. package/lib/util/safe-fetch.js +2 -1
  341. package/lib/util/safe-fetch.js.map +1 -1
  342. package/lib/util/telemetry/client.d.ts +32 -0
  343. package/lib/util/telemetry/client.d.ts.map +1 -0
  344. package/lib/util/telemetry/client.js +94 -0
  345. package/lib/util/telemetry/client.js.map +1 -0
  346. package/lib/util/telemetry/constants.d.ts +4 -0
  347. package/lib/util/telemetry/constants.d.ts.map +1 -0
  348. package/lib/util/telemetry/constants.js +8 -0
  349. package/lib/util/telemetry/constants.js.map +1 -0
  350. package/lib/util/telemetry/context.d.ts +15 -0
  351. package/lib/util/telemetry/context.d.ts.map +1 -0
  352. package/lib/util/telemetry/context.js +128 -0
  353. package/lib/util/telemetry/context.js.map +1 -0
  354. package/lib/util/telemetry/index.d.ts +3 -0
  355. package/lib/util/telemetry/index.d.ts.map +1 -0
  356. package/lib/util/telemetry/index.js +3 -0
  357. package/lib/util/telemetry/index.js.map +1 -0
  358. package/lib/util/telemetry/types.d.ts +59 -0
  359. package/lib/util/telemetry/types.d.ts.map +1 -0
  360. package/lib/util/telemetry/types.js +1 -0
  361. package/lib/util/telemetry/types.js.map +1 -0
  362. package/lib/util/xdg-paths.d.ts +9 -0
  363. package/lib/util/xdg-paths.d.ts.map +1 -0
  364. package/lib/util/xdg-paths.js +41 -0
  365. package/lib/util/xdg-paths.js.map +1 -0
  366. package/lib/vercel/project.d.ts.map +1 -1
  367. package/lib/vercel/project.js +2 -1
  368. package/lib/vercel/project.js.map +1 -1
  369. package/lib/web/astro.d.ts.map +1 -1
  370. package/lib/web/astro.js +2 -1
  371. package/lib/web/astro.js.map +1 -1
  372. package/lib/web/shadcn.d.ts.map +1 -1
  373. package/lib/web/shadcn.js +2 -1
  374. package/lib/web/shadcn.js.map +1 -1
  375. package/lib/web/vite.d.ts.map +1 -1
  376. package/lib/web/vite.js +3 -2
  377. package/lib/web/vite.js.map +1 -1
  378. package/lib/web/vitepress/dependencies.d.ts.map +1 -1
  379. package/lib/web/vitepress/dependencies.js +2 -1
  380. package/lib/web/vitepress/dependencies.js.map +1 -1
  381. package/lib/web/vitepress/vitepress.d.ts.map +1 -1
  382. package/lib/web/vitepress/vitepress.js +2 -1
  383. package/lib/web/vitepress/vitepress.js.map +1 -1
  384. package/package.json +7 -5
  385. package/src/ai/astro-file.ts +2 -1
  386. package/src/ai/client.ts +3 -2
  387. package/src/alchemy.ts +28 -3
  388. package/src/apply.ts +66 -5
  389. package/src/aws/control/client.ts +5 -5
  390. package/src/aws/control/properties.ts +48 -0
  391. package/src/aws/control/resource.ts +5 -3
  392. package/src/aws/control/types.ts +3988 -6301
  393. package/src/aws/function.ts +9 -8
  394. package/src/aws/oidc/oidc-provider.ts +3 -2
  395. package/src/aws/queue.ts +3 -2
  396. package/src/aws/role.ts +3 -1
  397. package/src/aws/ssm-parameter.ts +2 -1
  398. package/src/cloudflare/account-api-token.ts +3 -2
  399. package/src/cloudflare/ai-gateway.ts +4 -3
  400. package/src/cloudflare/ai.ts +21 -0
  401. package/src/cloudflare/api-error.ts +36 -0
  402. package/src/cloudflare/api.ts +9 -4
  403. package/src/cloudflare/assets.ts +30 -6
  404. package/src/cloudflare/astro.ts +176 -0
  405. package/src/cloudflare/auth.ts +3 -2
  406. package/src/cloudflare/bindings.ts +27 -0
  407. package/src/cloudflare/bound.ts +31 -17
  408. package/src/cloudflare/bucket.ts +15 -8
  409. package/src/cloudflare/bundle/bundle-worker.ts +2 -1
  410. package/src/cloudflare/bundle/nodejs-compat-mode.ts +2 -1
  411. package/src/cloudflare/custom-domain.ts +10 -9
  412. package/src/cloudflare/d1-database.ts +11 -10
  413. package/src/cloudflare/d1-export.ts +2 -1
  414. package/src/cloudflare/d1-import.ts +2 -1
  415. package/src/cloudflare/d1-migrations.ts +2 -1
  416. package/src/cloudflare/dns-records.ts +5 -4
  417. package/src/cloudflare/do-state-store/worker.ts +4 -0
  418. package/src/cloudflare/email-address.ts +203 -0
  419. package/src/cloudflare/email-catch-all.ts +248 -0
  420. package/src/cloudflare/email-routing.ts +230 -0
  421. package/src/cloudflare/email-rule.ts +322 -0
  422. package/src/cloudflare/hyperdrive.ts +5 -4
  423. package/src/cloudflare/images.ts +59 -0
  424. package/src/cloudflare/index.ts +9 -0
  425. package/src/cloudflare/kv-namespace.ts +2 -1
  426. package/src/cloudflare/pipeline.ts +38 -2
  427. package/src/cloudflare/queue-consumer.ts +2 -1
  428. package/src/cloudflare/queue.ts +0 -12
  429. package/src/cloudflare/route.ts +118 -18
  430. package/src/cloudflare/secret.ts +253 -0
  431. package/src/cloudflare/secrets-store.ts +420 -0
  432. package/src/cloudflare/sveltekit.ts +72 -0
  433. package/src/cloudflare/user.ts +2 -1
  434. package/src/cloudflare/vectorize-index.ts +6 -5
  435. package/src/cloudflare/vectorize-metadata-index.ts +2 -1
  436. package/src/cloudflare/website.ts +76 -66
  437. package/src/cloudflare/worker-assets.ts +95 -77
  438. package/src/cloudflare/worker-metadata.ts +14 -1
  439. package/src/cloudflare/worker.ts +76 -9
  440. package/src/cloudflare/wrangler.json.ts +42 -0
  441. package/src/cloudflare/zone.ts +79 -5
  442. package/src/destroy.ts +35 -17
  443. package/src/dns/godaddy.ts +3 -2
  444. package/src/dns/import-dns.ts +2 -1
  445. package/src/esbuild/bundle.ts +2 -1
  446. package/src/fs/copy-file.ts +2 -1
  447. package/src/fs/file.ts +3 -1
  448. package/src/github/client.ts +11 -10
  449. package/src/github/repository-environment.ts +5 -4
  450. package/src/github/secret.ts +7 -6
  451. package/src/index.ts +2 -1
  452. package/src/neon/project.ts +3 -2
  453. package/src/planetscale/api.ts +115 -0
  454. package/src/planetscale/branch.ts +352 -0
  455. package/src/planetscale/database.ts +394 -0
  456. package/src/planetscale/index.ts +4 -0
  457. package/src/planetscale/utils.ts +189 -0
  458. package/src/resource.ts +7 -1
  459. package/src/runtime/plugin.ts +2 -1
  460. package/src/scope.ts +64 -13
  461. package/src/sentry/client-key.ts +5 -4
  462. package/src/sentry/project.ts +5 -4
  463. package/src/sentry/team.ts +5 -4
  464. package/src/stripe/card.ts +2 -1
  465. package/src/stripe/client.ts +3 -2
  466. package/src/stripe/coupon.ts +2 -1
  467. package/src/stripe/customer.ts +2 -1
  468. package/src/stripe/entitlements-feature.ts +2 -1
  469. package/src/stripe/file.ts +2 -1
  470. package/src/stripe/meter.ts +4 -2
  471. package/src/stripe/portal-configuration.ts +2 -1
  472. package/src/stripe/price.ts +2 -1
  473. package/src/stripe/product-feature.ts +2 -1
  474. package/src/stripe/product.ts +2 -1
  475. package/src/stripe/promotion-code.ts +2 -1
  476. package/src/stripe/shipping-rate.ts +2 -1
  477. package/src/stripe/tax-rate.ts +2 -1
  478. package/src/stripe/webhook.ts +3 -2
  479. package/src/test/bun.ts +6 -1
  480. package/src/test/prune.ts +7 -1
  481. package/src/test/vitest.ts +2 -0
  482. package/src/upstash/redis.ts +2 -1
  483. package/src/util/async-queue.ts +97 -0
  484. package/src/util/cli.tsx +221 -0
  485. package/src/util/ignore-matcher.ts +873 -0
  486. package/src/util/logger.ts +17 -0
  487. package/src/util/retry.ts +0 -1
  488. package/src/util/safe-fetch.ts +2 -1
  489. package/src/util/telemetry/client.ts +127 -0
  490. package/src/util/telemetry/constants.ts +13 -0
  491. package/src/util/telemetry/context.ts +154 -0
  492. package/src/util/telemetry/index.ts +2 -0
  493. package/src/util/telemetry/types.ts +83 -0
  494. package/src/util/xdg-paths.ts +48 -0
  495. package/src/vercel/project.ts +2 -1
  496. package/src/web/astro.ts +2 -1
  497. package/src/web/shadcn.ts +2 -1
  498. package/src/web/vite.ts +3 -2
  499. package/src/web/vitepress/dependencies.ts +2 -1
  500. package/src/web/vitepress/vitepress.ts +2 -1
@@ -19,6 +19,7 @@ import type { Context } from "../context.ts";
19
19
  import type { Bundle } from "../esbuild/bundle.ts";
20
20
  import { Resource } from "../resource.ts";
21
21
  import { ignore } from "../util/ignore.ts";
22
+ import { logger } from "../util/logger.ts";
22
23
  import { retry } from "./retry.ts";
23
24
 
24
25
  /**
@@ -325,7 +326,7 @@ export const Function = Resource(
325
326
  );
326
327
  } catch (error: any) {
327
328
  if (error.name !== "ResourceNotFoundException") {
328
- console.warn("Failed to delete function URL:", error);
329
+ logger.warn("Failed to delete function URL:", error);
329
330
  }
330
331
  }
331
332
  }
@@ -446,7 +447,7 @@ export const Function = Resource(
446
447
  );
447
448
  } catch (permError: any) {
448
449
  if (!permError.message?.includes("already exists")) {
449
- console.warn("Error adding URL permission:", permError);
450
+ logger.warn("Error adding URL permission:", permError);
450
451
  }
451
452
  }
452
453
  }
@@ -489,7 +490,7 @@ export const Function = Resource(
489
490
  );
490
491
  } catch (permError: any) {
491
492
  if (!permError.message?.includes("already exists")) {
492
- console.warn("Error adding URL permission:", permError);
493
+ logger.warn("Error adding URL permission:", permError);
493
494
  }
494
495
  }
495
496
  }
@@ -534,7 +535,7 @@ export const Function = Resource(
534
535
  );
535
536
  } catch (permError: any) {
536
537
  if (!permError.message?.includes("already exists")) {
537
- console.warn("Error adding URL permission:", permError);
538
+ logger.warn("Error adding URL permission:", permError);
538
539
  }
539
540
  }
540
541
  }
@@ -555,7 +556,7 @@ export const Function = Resource(
555
556
  functionUrl = undefined;
556
557
  } catch (error: any) {
557
558
  if (error.name !== "ResourceNotFoundException") {
558
- console.warn("Failed to delete function URL:", error);
559
+ logger.warn("Failed to delete function URL:", error);
559
560
  }
560
561
  }
561
562
  }
@@ -673,12 +674,12 @@ export const Function = Resource(
673
674
  );
674
675
  } catch (permError: any) {
675
676
  if (!permError.message?.includes("already exists")) {
676
- console.warn("Error adding URL permission:", permError);
677
+ logger.warn("Error adding URL permission:", permError);
677
678
  }
678
679
  }
679
680
  }
680
681
  } catch (error) {
681
- console.warn("Failed to create function URL:", error);
682
+ logger.warn("Failed to create function URL:", error);
682
683
  }
683
684
  }
684
685
  } else {
@@ -717,7 +718,7 @@ export const Function = Resource(
717
718
  functionUrl = urlConfig.FunctionUrl;
718
719
  } catch (error: any) {
719
720
  if (error.name !== "ResourceNotFoundException") {
720
- console.warn("Failed to get function URL:", error);
721
+ logger.warn("Failed to get function URL:", error);
721
722
  }
722
723
  }
723
724
  }
@@ -9,6 +9,7 @@ import {
9
9
  } from "@aws-sdk/client-iam";
10
10
  import type { Context } from "../../context.ts";
11
11
  import { Resource } from "../../resource.ts";
12
+ import { logger } from "../../util/logger.ts";
12
13
  import { AccountId } from "../account-id.ts";
13
14
 
14
15
  /**
@@ -173,7 +174,7 @@ export const OIDCProvider = Resource(
173
174
  }
174
175
  } catch (error) {
175
176
  // Log but don't throw on cleanup errors
176
- console.error("Error during cleanup:", error);
177
+ logger.error("Error during cleanup:", error);
177
178
  }
178
179
  }
179
180
  return this.destroy();
@@ -285,7 +286,7 @@ export const OIDCProvider = Resource(
285
286
  createdAt: Date.now(),
286
287
  });
287
288
  } catch (error) {
288
- console.error("Error configuring OIDC provider:", error);
289
+ logger.error("Error configuring OIDC provider:", error);
289
290
  throw error;
290
291
  }
291
292
  },
package/src/aws/queue.ts CHANGED
@@ -9,6 +9,7 @@ import {
9
9
  } from "@aws-sdk/client-sqs";
10
10
  import type { Context } from "../context.ts";
11
11
  import { Resource } from "../resource.ts";
12
+ import { logger } from "../util/logger.ts";
12
13
  import { retry } from "./retry.ts";
13
14
 
14
15
  /**
@@ -193,7 +194,7 @@ export const Queue = Resource(
193
194
  }
194
195
  }
195
196
  } catch (error: any) {
196
- console.log(error.message);
197
+ logger.log(error.message);
197
198
  if (!isQueueDoesNotExist(error)) {
198
199
  throw error;
199
200
  }
@@ -274,7 +275,7 @@ export const Queue = Resource(
274
275
  });
275
276
  } catch (error: any) {
276
277
  if (isQueueDeletedRecently(error)) {
277
- console.log(
278
+ logger.log(
278
279
  `Queue "${queueName}" was recently deleted and can't be re-created. Waiting and retrying...`,
279
280
  );
280
281
  // Queue was recently deleted, wait and retry
package/src/aws/role.ts CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  import type { Context } from "../context.ts";
19
19
  import { Resource } from "../resource.ts";
20
20
  import { ignore } from "../util/ignore.ts";
21
+ import { logger } from "../util/logger.ts";
21
22
  import type { PolicyDocument } from "./policy.ts";
22
23
  import { retry } from "./retry.ts";
23
24
 
@@ -289,7 +290,7 @@ export const Role = Resource(
289
290
  // If we get any other error besides NoSuchEntityException, log it but don't fail
290
291
  // This ensures the resource is still marked as destroyed
291
292
  if (error.name !== NoSuchEntityException.name) {
292
- console.error(`Error deleting role ${props.roleName}:`, error);
293
+ logger.error(`Error deleting role ${props.roleName}:`, error);
293
294
  }
294
295
  }
295
296
 
@@ -359,6 +360,7 @@ export const Role = Resource(
359
360
  throw error;
360
361
  }
361
362
  } else if (error.name !== NoSuchEntityException.name) {
363
+ logger.error("Error creating/updating role:", error);
362
364
  throw error;
363
365
  }
364
366
  }
@@ -12,6 +12,7 @@ import type { Context } from "../context.ts";
12
12
  import { Resource } from "../resource.ts";
13
13
  import { type Secret, isSecret } from "../secret.ts";
14
14
  import { ignore } from "../util/ignore.ts";
15
+ import { logger } from "../util/logger.ts";
15
16
 
16
17
  /**
17
18
  * Base properties shared by all SSM Parameter types
@@ -308,7 +309,7 @@ export const SSMParameter = Resource(
308
309
  type: (parameter.Parameter.Type as any) ?? parameterType,
309
310
  } as SSMParameter);
310
311
  } catch (error: any) {
311
- console.error(`Error creating/updating parameter ${props.name}:`, error);
312
+ logger.error(`Error creating/updating parameter ${props.name}:`, error);
312
313
  throw error;
313
314
  }
314
315
  },
@@ -2,6 +2,7 @@ import { alchemy } from "../alchemy.ts";
2
2
  import type { Context } from "../context.ts";
3
3
  import { Resource } from "../resource.ts";
4
4
  import type { Secret } from "../secret.ts";
5
+ import { logger } from "../util/logger.ts";
5
6
  import { sha256 } from "../util/sha256.ts";
6
7
  import { createCloudflareApi, type CloudflareApiOptions } from "./api.ts";
7
8
  import {
@@ -269,10 +270,10 @@ export const AccountApiToken = Resource(
269
270
  const errorData: any = await deleteResponse.json().catch(() => ({
270
271
  errors: [{ message: deleteResponse.statusText }],
271
272
  }));
272
- console.error(`Error deleting token '${props.name}':`, errorData);
273
+ logger.error(`Error deleting token '${props.name}':`, errorData);
273
274
  }
274
275
  } catch (error) {
275
- console.error(`Error deleting token '${props.name}':`, error);
276
+ logger.error(`Error deleting token '${props.name}':`, error);
276
277
  }
277
278
  }
278
279
 
@@ -1,6 +1,7 @@
1
1
  import type { Context } from "../context.ts";
2
2
  import { Resource } from "../resource.ts";
3
3
  import { bind } from "../runtime/bind.ts";
4
+ import { logger } from "../util/logger.ts";
4
5
  import { handleApiError } from "./api-error.ts";
5
6
  import { createCloudflareApi, type CloudflareApiOptions } from "./api.ts";
6
7
  import type { Bound } from "./bound.ts";
@@ -187,7 +188,7 @@ const AiGatewayResource = Resource(
187
188
  await handleApiError(deleteResponse, "delete", "ai gateway", id);
188
189
  }
189
190
  } catch (error) {
190
- console.error(`Error deleting AI Gateway ${id}:`, error);
191
+ logger.error(`Error deleting AI Gateway ${id}:`, error);
191
192
  throw error;
192
193
  }
193
194
  return this.destroy();
@@ -217,7 +218,7 @@ const AiGatewayResource = Resource(
217
218
  const getResponse = await api.get(gatewayPath);
218
219
  if (getResponse.status === 200) {
219
220
  // Gateway exists, treat as update (PUT)
220
- console.log(
221
+ logger.log(
221
222
  `AI Gateway '${id}' already exists. Updating existing resource.`,
222
223
  );
223
224
  const requestBody = mapPropsToApi(id, mergedProps, false);
@@ -240,7 +241,7 @@ const AiGatewayResource = Resource(
240
241
  const data: { result: Record<string, any> } = await response!.json();
241
242
  apiResource = data.result;
242
243
  } catch (error) {
243
- console.error(`Error ${this.phase} AI Gateway '${id}':`, error);
244
+ logger.error(`Error ${this.phase} AI Gateway '${id}':`, error);
244
245
  throw error; // Re-throw the error to fail the deployment
245
246
  }
246
247
 
@@ -1,4 +1,25 @@
1
1
  /**
2
+ * Cloudflare Workers AI binding for running machine learning models.
3
+ *
4
+ * The AI binding provides access to Cloudflare's Workers AI platform, allowing you to run
5
+ * inference on various AI models including text generation, image classification, embeddings,
6
+ * and more directly from your Workers.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { Worker, Ai } from "alchemy/cloudflare";
11
+ *
12
+ * const ai = new Ai();
13
+ *
14
+ * await Worker("my-worker", {
15
+ * name: "my-worker",
16
+ * entrypoint: "./src/worker.ts",
17
+ * bindings: {
18
+ * AI: ai
19
+ * }
20
+ * });
21
+ * ```
22
+ *
2
23
  * @see https://developers.cloudflare.com/workers-ai/
3
24
  */
4
25
  export class Ai<Models extends AiModelListType = AiModelListType> {
@@ -42,12 +42,36 @@ export class CloudflareApiError extends Error {
42
42
  * @param resourceName The name/identifier of the specific resource
43
43
  * @returns Never returns - always throws an error
44
44
  */
45
+ /**
46
+ * Helper function to detect OAuth token authentication limitations
47
+ * Does not consume the response - uses the provided parsed JSON data
48
+ *
49
+ * @param json The parsed JSON response data
50
+ * @param action The action being performed (e.g., "creating", "deleting")
51
+ * @param resourceType The type of resource being acted upon (e.g., "email routing")
52
+ * @returns true if it's an OAuth error, false otherwise
53
+ */
54
+ function isOAuthError(
55
+ json: any,
56
+ _action: string,
57
+ _resourceType: string,
58
+ ): boolean {
59
+ const errors: { message: string; code?: number }[] = json?.errors || [];
60
+ return errors.some(
61
+ (error) =>
62
+ error.message?.includes("oauth_token authentication scheme") ||
63
+ error.message?.includes("POST method not allowed") ||
64
+ error.code === 10000,
65
+ );
66
+ }
67
+
45
68
  export async function handleApiError(
46
69
  response: Response,
47
70
  action: string,
48
71
  resourceType: string,
49
72
  resourceName?: string,
50
73
  ): Promise<never> {
74
+ // Read response body once and parse it
51
75
  const text = await response.text();
52
76
  let json: any;
53
77
  try {
@@ -55,6 +79,18 @@ export async function handleApiError(
55
79
  } catch {
56
80
  json = { errors: [{ message: text }] };
57
81
  }
82
+
83
+ // Check for OAuth-specific errors first
84
+ if (isOAuthError(json, action, resourceType)) {
85
+ throw new Error(
86
+ `${resourceType} ${action} requires API token authentication. ` +
87
+ `OAuth tokens from 'wrangler login' don't support this operation. ` +
88
+ "Please set CLOUDFLARE_API_TOKEN environment variable or pass apiToken option. " +
89
+ "You can create an API token at https://dash.cloudflare.com/profile/api-tokens",
90
+ );
91
+ }
92
+
93
+ // Handle general API errors
58
94
  const errors: { message: string }[] = json?.errors || [
59
95
  { message: response.statusText },
60
96
  ];
@@ -176,7 +176,7 @@ export class CloudflareApi {
176
176
  headers,
177
177
  });
178
178
  if (response.status.toString().startsWith("5")) {
179
- throw new InternalError("5xx error");
179
+ throw new InternalError(response.statusText);
180
180
  }
181
181
  if (response.status === 403 && !forbidden) {
182
182
  // we occasionally get 403s from Cloudflare tha tare actually transient
@@ -185,7 +185,10 @@ export class CloudflareApi {
185
185
  throw new ForbiddenError();
186
186
  }
187
187
  if (response.status === 429) {
188
- throw new TooManyRequestsError();
188
+ const data: any = await response.json();
189
+ throw new TooManyRequestsError(
190
+ data.errors[0].message ?? response.statusText,
191
+ );
189
192
  }
190
193
  return response;
191
194
  },
@@ -267,8 +270,10 @@ export class CloudflareApi {
267
270
  class InternalError extends Error {}
268
271
 
269
272
  class TooManyRequestsError extends Error {
270
- constructor() {
271
- super(`Cloudflare Rate Limit Exceeded at ${new Date().toISOString()}`);
273
+ constructor(message: string) {
274
+ super(
275
+ `Cloudflare Rate Limit Exceeded at ${new Date().toISOString()}: ${message}`,
276
+ );
272
277
  }
273
278
  }
274
279
 
@@ -3,6 +3,7 @@ import * as path from "node:path";
3
3
  import type { Context } from "../context.ts";
4
4
  import { Resource } from "../resource.ts";
5
5
  import { getContentType } from "../util/content-type.ts";
6
+ import ignore from "../util/ignore-matcher.js";
6
7
 
7
8
  /**
8
9
  * Properties for creating or updating Assets
@@ -111,7 +112,8 @@ export const Assets = Resource(
111
112
  }
112
113
 
113
114
  // Recursively get all files in the assets directory
114
- const filesList = await getFilesRecursively(props.path);
115
+ const ignoreMatcher = await createIgnoreMatcher(props.path);
116
+ const filesList = await getFilesRecursively(props.path, ignoreMatcher);
115
117
 
116
118
  // Create asset file objects
117
119
  const files: AssetFile[] = filesList.map((filePath) => {
@@ -140,19 +142,41 @@ export const Assets = Resource(
140
142
  },
141
143
  );
142
144
 
145
+ async function createIgnoreMatcher(
146
+ dir: string,
147
+ ): Promise<{ ignores: (path: string) => boolean }> {
148
+ const ignoreMatcher = ignore().add(".assetsignore");
149
+ const ignorePath = path.join(dir, ".assetsignore");
150
+ try {
151
+ const content = await fs.readFile(ignorePath, "utf-8");
152
+ ignoreMatcher.add(content.split("\n"));
153
+ } catch {
154
+ // ignore
155
+ }
156
+ return ignoreMatcher;
157
+ }
158
+
143
159
  // Helper functions for file operations
144
- async function getFilesRecursively(dir: string): Promise<string[]> {
160
+ async function getFilesRecursively(
161
+ dir: string,
162
+ ignoreMatcher: { ignores: (path: string) => boolean },
163
+ ): Promise<string[]> {
145
164
  const files = await fs.readdir(dir, { withFileTypes: true });
165
+ const result: string[] = [];
146
166
 
147
- const allFiles = await Promise.all(
167
+ await Promise.all(
148
168
  files.map(async (file) => {
149
169
  const path = `${dir}/${file.name}`;
170
+ if (ignoreMatcher.ignores(file.name)) {
171
+ return;
172
+ }
150
173
  if (file.isDirectory()) {
151
- return getFilesRecursively(path);
174
+ result.push(...(await getFilesRecursively(path, ignoreMatcher)));
175
+ } else {
176
+ result.push(path);
152
177
  }
153
- return path;
154
178
  }),
155
179
  );
156
180
 
157
- return allFiles.flat();
181
+ return result;
158
182
  }
@@ -0,0 +1,176 @@
1
+ import { writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { alchemy } from "../alchemy.ts";
4
+ import { Exec } from "../os/exec.ts";
5
+ import { Scope } from "../scope.ts";
6
+ import { Assets } from "./assets.ts";
7
+ import type { Bindings } from "./bindings.ts";
8
+ import type { Website, WebsiteProps } from "./website.ts";
9
+ import {
10
+ DEFAULT_COMPATIBILITY_DATE,
11
+ Worker,
12
+ type WorkerProps,
13
+ } from "./worker.ts";
14
+ import { WranglerJson } from "./wrangler.json.ts";
15
+
16
+ /**
17
+ * Properties for creating an Astro resource.
18
+ * Extends WebsiteProps, allowing customization of the underlying Website.
19
+ */
20
+ export interface AstroProps<B extends Bindings> extends WebsiteProps<B> {}
21
+
22
+ /**
23
+ * Represents the output of an Astro resource deployment.
24
+ * It resolves to the underlying Cloudflare Worker type, ensuring type safety.
25
+ * Prevents overriding the internal ASSETS binding.
26
+ */
27
+ export type Astro<B extends Bindings> = B extends { ASSETS: any }
28
+ ? never
29
+ : Worker<B & { ASSETS: Assets }>;
30
+
31
+ /**
32
+ * Creates and deploys an Astro application using the Cloudflare adapter.
33
+ *
34
+ * This resource simplifies deploying Astro applications by providing sensible
35
+ * defaults for the build command, main entrypoint, and assets directory
36
+ * based on the `@astrojs/cloudflare` adapter output.
37
+ *
38
+ * It wraps the underlying `Website` resource.
39
+ *
40
+ * @param id A unique identifier for the resource.
41
+ * @param props Configuration options for the Astro deployment, overriding defaults.
42
+ * @returns A promise that resolves to the deployed Cloudflare Worker details.
43
+ *
44
+ * @example
45
+ * ## Deploy a basic Astro site with default settings
46
+ *
47
+ * Deploy an Astro application with minimal configuration using default build settings.
48
+ *
49
+ * ```ts
50
+ * import { Astro } from "alchemy/cloudflare";
51
+ *
52
+ * const astroSite = await Astro("my-astro-app");
53
+ * ```
54
+ *
55
+ * @example
56
+ * ## Deploy with custom bindings and build command
57
+ *
58
+ * Deploy an Astro application with custom Cloudflare bindings and build configuration.
59
+ *
60
+ * ```ts
61
+ * import { Astro, D1Database } from "alchemy/cloudflare";
62
+ *
63
+ * const db = await D1Database("my-db");
64
+ * const astroSiteWithDb = await Astro("my-astro-app-with-db", {
65
+ * command: "npm run build", // Specify a custom build command
66
+ * bindings: {
67
+ * DB: db, // Add custom bindings
68
+ * },
69
+ * });
70
+ * ```
71
+ */
72
+ export async function Astro<B extends Bindings>(
73
+ id: string,
74
+ props?: Partial<AstroProps<B>>,
75
+ ): Promise<Astro<B>> {
76
+ if (props?.bindings?.ASSETS) {
77
+ throw new Error("ASSETS binding is reserved for internal use");
78
+ }
79
+ const wrangler = props?.wrangler ?? true;
80
+ const main = props?.main ?? path.join("dist", "_worker.js/index.js");
81
+ const assetsDir =
82
+ typeof props?.assets === "string"
83
+ ? props?.assets
84
+ : (props?.assets?.dist ?? "dist");
85
+
86
+ return alchemy.run(
87
+ id,
88
+ {
89
+ parent: Scope.current,
90
+ },
91
+ async () => {
92
+ const cwd = path.resolve(props?.cwd || process.cwd());
93
+ const fileName =
94
+ typeof wrangler === "boolean"
95
+ ? "wrangler.jsonc"
96
+ : typeof wrangler === "string"
97
+ ? wrangler
98
+ : (wrangler?.path ?? "wrangler.jsonc");
99
+ const wranglerPath =
100
+ fileName && path.relative(cwd, path.join(cwd, fileName));
101
+ const wranglerMain =
102
+ typeof wrangler === "object"
103
+ ? (wrangler.main ?? props?.main)
104
+ : props?.main;
105
+
106
+ const workerName = props?.name ?? id;
107
+
108
+ const workerProps = {
109
+ ...props,
110
+ compatibilityDate:
111
+ props?.compatibilityDate ?? DEFAULT_COMPATIBILITY_DATE,
112
+ compatibilityFlags: [
113
+ "nodejs_compat",
114
+ ...(props?.compatibilityFlags ?? []),
115
+ ],
116
+ name: workerName,
117
+ entrypoint: main,
118
+ assets: {
119
+ html_handling: "auto-trailing-slash",
120
+ not_found_handling: "single-page-application",
121
+ run_worker_first: false,
122
+ ...(typeof props?.assets === "string" ? {} : props?.assets),
123
+ },
124
+ script: props?.main
125
+ ? undefined
126
+ : `
127
+ export default {
128
+ async fetch(request, env) {
129
+ return new Response("Not Found", { status: 404 });
130
+ },
131
+ };`,
132
+ url: true,
133
+ adopt: true,
134
+ } as WorkerProps<any> & { name: string };
135
+
136
+ if (wrangler) {
137
+ await WranglerJson("wrangler.jsonc", {
138
+ path: wranglerPath,
139
+ worker: workerProps,
140
+ main: wranglerMain,
141
+ // hard-code the assets directory because we haven't yet included the assets binding
142
+ assets: {
143
+ binding: "ASSETS",
144
+ directory: assetsDir,
145
+ },
146
+ });
147
+ }
148
+
149
+ if (props?.command) {
150
+ await Exec("build", {
151
+ cwd,
152
+ command: props?.command,
153
+ env: props?.env,
154
+ memoize: props?.memoize,
155
+ });
156
+ }
157
+
158
+ await writeFile(
159
+ path.join(cwd, assetsDir, ".assetsignore"),
160
+ ["_worker.js", "_routes.json"].join("\n"),
161
+ );
162
+
163
+ return (await Worker("worker", {
164
+ ...workerProps,
165
+ bindings: {
166
+ ...workerProps.bindings,
167
+ // we don't include the Assets binding until after build to make sure the asset manifest is correct
168
+ // we generate the wrangler.json using all the bind
169
+ ASSETS: await Assets("assets", {
170
+ path: assetsDir,
171
+ }),
172
+ },
173
+ } as WorkerProps<any> & { name: string })) as Website<B>;
174
+ },
175
+ );
176
+ }
@@ -2,6 +2,7 @@ import fs from "node:fs/promises";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import type { Secret } from "../secret.ts";
5
+ import { createXdgAppPaths } from "../util/xdg-paths.ts";
5
6
  /**
6
7
  * Authentication options for Cloudflare API
7
8
  */
@@ -195,9 +196,9 @@ async function findWranglerConfig(): Promise<string> {
195
196
  `${environment === "production" ? "default.toml" : `${environment}.toml`}`,
196
197
  );
197
198
 
198
- const xdgAppPaths = (await import("xdg-app-paths")).default;
199
+ const xdgAppPaths = createXdgAppPaths(".wrangler");
199
200
  //TODO: We should implement a custom path --global-config and/or the WRANGLER_HOME type environment variable
200
- const configDir = xdgAppPaths(".wrangler").config(); // New XDG compliant config path
201
+ const configDir = xdgAppPaths.config(); // New XDG compliant config path
201
202
  const legacyConfigDir = path.join(os.homedir(), ".wrangler"); // Legacy config in user's home directory
202
203
 
203
204
  // Check for the .wrangler directory in root if it is not there then use the XDG compliant path.
@@ -17,11 +17,13 @@ import type { HyperdriveResource } from "./hyperdrive.ts";
17
17
  import type { KVNamespaceResource } from "./kv-namespace.ts";
18
18
  import type { PipelineResource } from "./pipeline.ts";
19
19
  import type { QueueResource } from "./queue.ts";
20
+ import type { SecretsStore } from "./secrets-store.ts";
20
21
  import type { VectorizeIndexResource } from "./vectorize-index.ts";
21
22
  import type { VersionMetadata } from "./version-metadata.ts";
22
23
  import type { WorkerStub } from "./worker-stub.ts";
23
24
  import type { Worker, WorkerRef } from "./worker.ts";
24
25
  import type { Workflow } from "./workflow.ts";
26
+ import type { Images } from "./images.ts";
25
27
 
26
28
  export type Bindings = {
27
29
  [bindingName: string]: Binding;
@@ -44,10 +46,12 @@ export type Binding =
44
46
  | AnalyticsEngineDataset
45
47
  | DurableObjectNamespace<Rpc.DurableObjectBranded | undefined>
46
48
  | HyperdriveResource
49
+ | Images
47
50
  | KVNamespaceResource
48
51
  | PipelineResource
49
52
  | QueueResource
50
53
  | R2BucketResource
54
+ | SecretsStore<any>
51
55
  | {
52
56
  type: "kv_namespace";
53
57
  id: string;
@@ -91,6 +95,7 @@ export type WorkerBindingSpec =
91
95
  | WorkerBindingDispatchNamespace
92
96
  | WorkerBindingDurableObjectNamespace
93
97
  | WorkerBindingHyperdrive
98
+ | WorkerBindingImages
94
99
  | WorkerBindingJson
95
100
  | WorkerBindingKVNamespace
96
101
  | WorkerBindingMTLSCertificate
@@ -99,6 +104,7 @@ export type WorkerBindingSpec =
99
104
  | WorkerBindingQueue
100
105
  | WorkerBindingR2Bucket
101
106
  | WorkerBindingSecretText
107
+ | WorkerBindingSecretsStore
102
108
  | WorkerBindingService
103
109
  | WorkerBindingStaticContent
104
110
  | WorkerBindingTailConsumer
@@ -294,6 +300,17 @@ export interface WorkerBindingSecretText {
294
300
  text: string;
295
301
  }
296
302
 
303
+ export interface WorkerBindingSecretsStore {
304
+ /** The name of the binding */
305
+ name: string;
306
+ /** Type identifier for Secrets Store binding */
307
+ type: "secrets_store";
308
+ /** Store ID */
309
+ store_id: string;
310
+ /** Secret name */
311
+ secret_name: string;
312
+ }
313
+
297
314
  /**
298
315
  * Service binding type
299
316
  */
@@ -384,6 +401,16 @@ export interface WorkerBindingWorkflow {
384
401
  script_name?: string;
385
402
  }
386
403
 
404
+ /**
405
+ * Images binding type
406
+ */
407
+ export interface WorkerBindingImages {
408
+ /** The name of the binding */
409
+ name: string;
410
+ /** Type identifier for Images binding */
411
+ type: "images";
412
+ }
413
+
387
414
  /**
388
415
  * Pipeline binding type
389
416
  */