alchemy 0.62.3 → 0.63.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 (594) hide show
  1. package/bin/alchemy.js +1516 -1202
  2. package/bin/commands/deploy.ts +2 -0
  3. package/bin/commands/dev.ts +2 -0
  4. package/bin/services/execute-alchemy.ts +11 -0
  5. package/bin/services/template-manager.ts +2 -0
  6. package/bin/types.ts +2 -1
  7. package/lib/alchemy.d.ts +6 -22
  8. package/lib/alchemy.d.ts.map +1 -1
  9. package/lib/alchemy.js +65 -169
  10. package/lib/alchemy.js.map +1 -1
  11. package/lib/apply.d.ts +0 -2
  12. package/lib/apply.d.ts.map +1 -1
  13. package/lib/apply.js +2 -16
  14. package/lib/apply.js.map +1 -1
  15. package/lib/aws/account-id.d.ts.map +1 -1
  16. package/lib/aws/account-id.js +3 -2
  17. package/lib/aws/account-id.js.map +1 -1
  18. package/lib/aws/bucket.d.ts +8 -2
  19. package/lib/aws/bucket.d.ts.map +1 -1
  20. package/lib/aws/bucket.js +21 -14
  21. package/lib/aws/bucket.js.map +1 -1
  22. package/lib/aws/ec2/security-group.d.ts +8 -2
  23. package/lib/aws/ec2/security-group.d.ts.map +1 -1
  24. package/lib/aws/ec2/security-group.js +7 -2
  25. package/lib/aws/ec2/security-group.js.map +1 -1
  26. package/lib/aws/function.d.ts +9 -3
  27. package/lib/aws/function.d.ts.map +1 -1
  28. package/lib/aws/function.js +35 -26
  29. package/lib/aws/function.js.map +1 -1
  30. package/lib/aws/policy-attachment.d.ts.map +1 -1
  31. package/lib/aws/policy-attachment.js +2 -1
  32. package/lib/aws/policy-attachment.js.map +1 -1
  33. package/lib/aws/policy.d.ts +8 -2
  34. package/lib/aws/policy.d.ts.map +1 -1
  35. package/lib/aws/policy.js +13 -4
  36. package/lib/aws/policy.js.map +1 -1
  37. package/lib/aws/queue.d.ts +8 -2
  38. package/lib/aws/queue.d.ts.map +1 -1
  39. package/lib/aws/queue.js +22 -14
  40. package/lib/aws/queue.js.map +1 -1
  41. package/lib/aws/role.d.ts +8 -2
  42. package/lib/aws/role.d.ts.map +1 -1
  43. package/lib/aws/role.js +10 -3
  44. package/lib/aws/role.js.map +1 -1
  45. package/lib/aws/ses.d.ts +1 -1
  46. package/lib/aws/ses.d.ts.map +1 -1
  47. package/lib/aws/ses.js +2 -1
  48. package/lib/aws/ses.js.map +1 -1
  49. package/lib/aws/ssm-parameter.d.ts +8 -2
  50. package/lib/aws/ssm-parameter.d.ts.map +1 -1
  51. package/lib/aws/ssm-parameter.js +15 -10
  52. package/lib/aws/ssm-parameter.js.map +1 -1
  53. package/lib/aws/table.d.ts +8 -2
  54. package/lib/aws/table.d.ts.map +1 -1
  55. package/lib/aws/table.js +17 -9
  56. package/lib/aws/table.js.map +1 -1
  57. package/lib/cloudflare/account-api-token.d.ts +2 -2
  58. package/lib/cloudflare/account-api-token.d.ts.map +1 -1
  59. package/lib/cloudflare/account-api-token.js +7 -6
  60. package/lib/cloudflare/account-api-token.js.map +1 -1
  61. package/lib/cloudflare/ai-gateway.d.ts +9 -4
  62. package/lib/cloudflare/ai-gateway.d.ts.map +1 -1
  63. package/lib/cloudflare/ai-gateway.js +20 -24
  64. package/lib/cloudflare/ai-gateway.js.map +1 -1
  65. package/lib/cloudflare/api-schema.d.ts +2 -2
  66. package/lib/cloudflare/api-schema.d.ts.map +1 -1
  67. package/lib/cloudflare/api-schema.js +6 -2
  68. package/lib/cloudflare/api-schema.js.map +1 -1
  69. package/lib/cloudflare/api-shield.d.ts +5 -1
  70. package/lib/cloudflare/api-shield.d.ts.map +1 -1
  71. package/lib/cloudflare/api-shield.js +6 -1
  72. package/lib/cloudflare/api-shield.js.map +1 -1
  73. package/lib/cloudflare/assets.d.ts +1 -1
  74. package/lib/cloudflare/assets.d.ts.map +1 -1
  75. package/lib/cloudflare/astro/astro.d.ts.map +1 -1
  76. package/lib/cloudflare/astro/astro.js +3 -1
  77. package/lib/cloudflare/astro/astro.js.map +1 -1
  78. package/lib/cloudflare/astro/plugin.d.ts +2 -1
  79. package/lib/cloudflare/astro/plugin.d.ts.map +1 -1
  80. package/lib/cloudflare/astro/plugin.js.map +1 -1
  81. package/lib/cloudflare/bindings.d.ts +2 -2
  82. package/lib/cloudflare/bindings.d.ts.map +1 -1
  83. package/lib/cloudflare/bound.d.ts +1 -1
  84. package/lib/cloudflare/bound.d.ts.map +1 -1
  85. package/lib/cloudflare/bucket.d.ts +120 -1
  86. package/lib/cloudflare/bucket.d.ts.map +1 -1
  87. package/lib/cloudflare/bucket.js +80 -2
  88. package/lib/cloudflare/bucket.js.map +1 -1
  89. package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
  90. package/lib/cloudflare/compatibility-date.gen.js +1 -1
  91. package/lib/cloudflare/container.d.ts +10 -4
  92. package/lib/cloudflare/container.d.ts.map +1 -1
  93. package/lib/cloudflare/container.js +12 -9
  94. package/lib/cloudflare/container.js.map +1 -1
  95. package/lib/cloudflare/custom-domain.js +2 -1
  96. package/lib/cloudflare/custom-domain.js.map +1 -1
  97. package/lib/cloudflare/d1-database.d.ts +1 -1
  98. package/lib/cloudflare/d1-database.d.ts.map +1 -1
  99. package/lib/cloudflare/d1-database.js +6 -2
  100. package/lib/cloudflare/d1-database.js.map +1 -1
  101. package/lib/cloudflare/dispatch-namespace.d.ts +2 -0
  102. package/lib/cloudflare/dispatch-namespace.d.ts.map +1 -1
  103. package/lib/cloudflare/dispatch-namespace.js +7 -5
  104. package/lib/cloudflare/dispatch-namespace.js.map +1 -1
  105. package/lib/cloudflare/hyperdrive.d.ts +7 -1
  106. package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
  107. package/lib/cloudflare/hyperdrive.js +2 -1
  108. package/lib/cloudflare/hyperdrive.js.map +1 -1
  109. package/lib/cloudflare/kv-namespace.d.ts +3 -0
  110. package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
  111. package/lib/cloudflare/kv-namespace.js +11 -2
  112. package/lib/cloudflare/kv-namespace.js.map +1 -1
  113. package/lib/cloudflare/miniflare/miniflare-worker-proxy.js +3 -1
  114. package/lib/cloudflare/miniflare/miniflare-worker-proxy.js.map +1 -1
  115. package/lib/cloudflare/miniflare/paths.d.ts +4 -0
  116. package/lib/cloudflare/miniflare/paths.d.ts.map +1 -1
  117. package/lib/cloudflare/miniflare/paths.js +11 -0
  118. package/lib/cloudflare/miniflare/paths.js.map +1 -1
  119. package/lib/cloudflare/pipeline.d.ts +14 -3
  120. package/lib/cloudflare/pipeline.d.ts.map +1 -1
  121. package/lib/cloudflare/pipeline.js +31 -2
  122. package/lib/cloudflare/pipeline.js.map +1 -1
  123. package/lib/cloudflare/queue-consumer.js +1 -1
  124. package/lib/cloudflare/queue-consumer.js.map +1 -1
  125. package/lib/cloudflare/queue.d.ts +4 -2
  126. package/lib/cloudflare/queue.d.ts.map +1 -1
  127. package/lib/cloudflare/queue.js +13 -9
  128. package/lib/cloudflare/queue.js.map +1 -1
  129. package/lib/cloudflare/react-router/plugin.d.ts +1 -1
  130. package/lib/cloudflare/react-router/plugin.d.ts.map +1 -1
  131. package/lib/cloudflare/react-router/react-router.d.ts.map +1 -1
  132. package/lib/cloudflare/react-router/react-router.js +32 -2
  133. package/lib/cloudflare/react-router/react-router.js.map +1 -1
  134. package/lib/cloudflare/redwood/plugin.d.ts +2 -1
  135. package/lib/cloudflare/redwood/plugin.d.ts.map +1 -1
  136. package/lib/cloudflare/redwood/plugin.js.map +1 -1
  137. package/lib/cloudflare/route.js +1 -1
  138. package/lib/cloudflare/route.js.map +1 -1
  139. package/lib/cloudflare/ruleset.d.ts +3 -1
  140. package/lib/cloudflare/ruleset.d.ts.map +1 -1
  141. package/lib/cloudflare/ruleset.js +3 -2
  142. package/lib/cloudflare/ruleset.js.map +1 -1
  143. package/lib/cloudflare/secret.d.ts +6 -23
  144. package/lib/cloudflare/secret.d.ts.map +1 -1
  145. package/lib/cloudflare/secret.js +8 -4
  146. package/lib/cloudflare/secret.js.map +1 -1
  147. package/lib/cloudflare/secrets-store.d.ts +1 -1
  148. package/lib/cloudflare/secrets-store.d.ts.map +1 -1
  149. package/lib/cloudflare/secrets-store.js +5 -2
  150. package/lib/cloudflare/secrets-store.js.map +1 -1
  151. package/lib/cloudflare/tunnel.d.ts +5 -1
  152. package/lib/cloudflare/tunnel.d.ts.map +1 -1
  153. package/lib/cloudflare/tunnel.js +5 -1
  154. package/lib/cloudflare/tunnel.js.map +1 -1
  155. package/lib/cloudflare/vectorize-index.d.ts +7 -1
  156. package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
  157. package/lib/cloudflare/vectorize-index.js +5 -2
  158. package/lib/cloudflare/vectorize-index.js.map +1 -1
  159. package/lib/cloudflare/vite/plugin.d.ts +2 -1
  160. package/lib/cloudflare/vite/plugin.d.ts.map +1 -1
  161. package/lib/cloudflare/vite/plugin.js.map +1 -1
  162. package/lib/cloudflare/website.js +1 -1
  163. package/lib/cloudflare/website.js.map +1 -1
  164. package/lib/cloudflare/worker.d.ts +1 -1
  165. package/lib/cloudflare/worker.d.ts.map +1 -1
  166. package/lib/cloudflare/worker.js +12 -7
  167. package/lib/cloudflare/worker.js.map +1 -1
  168. package/lib/cloudflare/wrangler.json.d.ts +1 -1
  169. package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
  170. package/lib/cloudflare/wrangler.json.js +5 -3
  171. package/lib/cloudflare/wrangler.json.js.map +1 -1
  172. package/lib/docker/container.d.ts +6 -0
  173. package/lib/docker/container.d.ts.map +1 -1
  174. package/lib/docker/container.js +5 -1
  175. package/lib/docker/container.js.map +1 -1
  176. package/lib/docker/network.d.ts +8 -2
  177. package/lib/docker/network.d.ts.map +1 -1
  178. package/lib/docker/network.js +7 -2
  179. package/lib/docker/network.js.map +1 -1
  180. package/lib/docker/volume.d.ts +8 -2
  181. package/lib/docker/volume.d.ts.map +1 -1
  182. package/lib/docker/volume.js +6 -4
  183. package/lib/docker/volume.js.map +1 -1
  184. package/lib/esbuild/bundle.d.ts +1 -1
  185. package/lib/fs/index.d.ts +0 -8
  186. package/lib/fs/index.d.ts.map +1 -1
  187. package/lib/fs/index.js +0 -8
  188. package/lib/fs/index.js.map +1 -1
  189. package/lib/github/client.d.ts +1 -1
  190. package/lib/github/client.d.ts.map +1 -1
  191. package/lib/github/client.js +2 -1
  192. package/lib/github/client.js.map +1 -1
  193. package/lib/github/repository-environment.d.ts +8 -2
  194. package/lib/github/repository-environment.d.ts.map +1 -1
  195. package/lib/github/repository-environment.js +16 -12
  196. package/lib/github/repository-environment.js.map +1 -1
  197. package/lib/neon/project.d.ts +7 -1
  198. package/lib/neon/project.d.ts.map +1 -1
  199. package/lib/neon/project.js +10 -6
  200. package/lib/neon/project.js.map +1 -1
  201. package/lib/planetscale/branch.d.ts +4 -2
  202. package/lib/planetscale/branch.d.ts.map +1 -1
  203. package/lib/planetscale/branch.js +18 -12
  204. package/lib/planetscale/branch.js.map +1 -1
  205. package/lib/planetscale/database.d.ts +8 -2
  206. package/lib/planetscale/database.d.ts.map +1 -1
  207. package/lib/planetscale/database.js +24 -16
  208. package/lib/planetscale/database.js.map +1 -1
  209. package/lib/planetscale/password.d.ts +8 -2
  210. package/lib/planetscale/password.d.ts.map +1 -1
  211. package/lib/planetscale/password.js +2 -2
  212. package/lib/planetscale/password.js.map +1 -1
  213. package/lib/resource.d.ts +0 -2
  214. package/lib/resource.d.ts.map +1 -1
  215. package/lib/resource.js +1 -9
  216. package/lib/resource.js.map +1 -1
  217. package/lib/scope.d.ts +9 -3
  218. package/lib/scope.d.ts.map +1 -1
  219. package/lib/scope.js +21 -34
  220. package/lib/scope.js.map +1 -1
  221. package/lib/sentry/client-key.d.ts +7 -1
  222. package/lib/sentry/client-key.d.ts.map +1 -1
  223. package/lib/sentry/client-key.js +45 -6
  224. package/lib/sentry/client-key.js.map +1 -1
  225. package/lib/sentry/project.d.ts +8 -2
  226. package/lib/sentry/project.d.ts.map +1 -1
  227. package/lib/sentry/project.js +35 -5
  228. package/lib/sentry/project.js.map +1 -1
  229. package/lib/sentry/team.d.ts +8 -2
  230. package/lib/sentry/team.d.ts.map +1 -1
  231. package/lib/sentry/team.js +36 -6
  232. package/lib/sentry/team.js.map +1 -1
  233. package/lib/serde.d.ts +0 -5
  234. package/lib/serde.d.ts.map +1 -1
  235. package/lib/serde.js +0 -28
  236. package/lib/serde.js.map +1 -1
  237. package/lib/state/d1-state-store.d.ts +1 -1
  238. package/lib/state/d1-state-store.d.ts.map +1 -1
  239. package/lib/state/d1-state-store.js +5 -5
  240. package/lib/state/d1-state-store.js.map +1 -1
  241. package/lib/state/sqlite-state-store.d.ts.map +1 -1
  242. package/lib/state/sqlite-state-store.js +7 -11
  243. package/lib/state/sqlite-state-store.js.map +1 -1
  244. package/lib/stripe/card.d.ts.map +1 -1
  245. package/lib/stripe/card.js +3 -2
  246. package/lib/stripe/card.js.map +1 -1
  247. package/lib/stripe/client.d.ts +2 -2
  248. package/lib/stripe/client.d.ts.map +1 -1
  249. package/lib/stripe/client.js +4 -3
  250. package/lib/stripe/client.js.map +1 -1
  251. package/lib/stripe/coupon.d.ts.map +1 -1
  252. package/lib/stripe/coupon.js +4 -3
  253. package/lib/stripe/coupon.js.map +1 -1
  254. package/lib/stripe/customer.js +2 -2
  255. package/lib/stripe/customer.js.map +1 -1
  256. package/lib/stripe/entitlements-feature.d.ts.map +1 -1
  257. package/lib/stripe/entitlements-feature.js +3 -2
  258. package/lib/stripe/entitlements-feature.js.map +1 -1
  259. package/lib/stripe/file.d.ts.map +1 -1
  260. package/lib/stripe/file.js +3 -2
  261. package/lib/stripe/file.js.map +1 -1
  262. package/lib/stripe/meter.js +2 -2
  263. package/lib/stripe/meter.js.map +1 -1
  264. package/lib/stripe/portal-configuration.d.ts.map +1 -1
  265. package/lib/stripe/portal-configuration.js +3 -2
  266. package/lib/stripe/portal-configuration.js.map +1 -1
  267. package/lib/stripe/price.d.ts.map +1 -1
  268. package/lib/stripe/price.js +3 -2
  269. package/lib/stripe/price.js.map +1 -1
  270. package/lib/stripe/product-feature.d.ts.map +1 -1
  271. package/lib/stripe/product-feature.js +3 -2
  272. package/lib/stripe/product-feature.js.map +1 -1
  273. package/lib/stripe/product.d.ts.map +1 -1
  274. package/lib/stripe/product.js +3 -2
  275. package/lib/stripe/product.js.map +1 -1
  276. package/lib/stripe/promotion-code.d.ts.map +1 -1
  277. package/lib/stripe/promotion-code.js +3 -2
  278. package/lib/stripe/promotion-code.js.map +1 -1
  279. package/lib/stripe/shipping-rate.d.ts.map +1 -1
  280. package/lib/stripe/shipping-rate.js +4 -3
  281. package/lib/stripe/shipping-rate.js.map +1 -1
  282. package/lib/stripe/tax-rate.d.ts.map +1 -1
  283. package/lib/stripe/tax-rate.js +3 -2
  284. package/lib/stripe/tax-rate.js.map +1 -1
  285. package/lib/stripe/webhook.d.ts.map +1 -1
  286. package/lib/stripe/webhook.js +4 -3
  287. package/lib/stripe/webhook.js.map +1 -1
  288. package/lib/test/vitest.d.ts.map +1 -1
  289. package/lib/test/vitest.js +1 -0
  290. package/lib/test/vitest.js.map +1 -1
  291. package/lib/upstash/redis.d.ts +8 -2
  292. package/lib/upstash/redis.d.ts.map +1 -1
  293. package/lib/upstash/redis.js +5 -4
  294. package/lib/upstash/redis.js.map +1 -1
  295. package/lib/util/ignore-matcher.d.ts.map +1 -1
  296. package/lib/util/ignore-matcher.js +3 -1
  297. package/lib/util/ignore-matcher.js.map +1 -1
  298. package/lib/util/peer.d.ts +10 -0
  299. package/lib/util/peer.d.ts.map +1 -0
  300. package/lib/util/peer.js +42 -0
  301. package/lib/util/peer.js.map +1 -0
  302. package/lib/vercel/project.d.ts +7 -1
  303. package/lib/vercel/project.d.ts.map +1 -1
  304. package/lib/vercel/project.js +28 -0
  305. package/lib/vercel/project.js.map +1 -1
  306. package/package.json +88 -74
  307. package/src/alchemy.ts +76 -222
  308. package/src/apply.ts +6 -19
  309. package/src/aws/account-id.ts +6 -3
  310. package/src/aws/bucket.ts +43 -32
  311. package/src/aws/ec2/security-group.ts +15 -3
  312. package/src/aws/function.ts +65 -39
  313. package/src/aws/policy-attachment.ts +10 -6
  314. package/src/aws/policy.ts +33 -15
  315. package/src/aws/queue.ts +50 -29
  316. package/src/aws/role.ts +37 -20
  317. package/src/aws/ses.ts +24 -20
  318. package/src/aws/ssm-parameter.ts +40 -20
  319. package/src/aws/table.ts +35 -17
  320. package/src/cloudflare/account-api-token.ts +9 -7
  321. package/src/cloudflare/ai-gateway.ts +37 -34
  322. package/src/cloudflare/api-schema.ts +33 -26
  323. package/src/cloudflare/api-shield.ts +15 -2
  324. package/src/cloudflare/astro/astro.ts +5 -1
  325. package/src/cloudflare/astro/plugin.ts +2 -1
  326. package/src/cloudflare/bindings.ts +2 -2
  327. package/src/cloudflare/bound.ts +1 -1
  328. package/src/cloudflare/bucket.ts +242 -3
  329. package/src/cloudflare/compatibility-date.gen.ts +1 -1
  330. package/src/cloudflare/container.ts +23 -12
  331. package/src/cloudflare/custom-domain.ts +2 -2
  332. package/src/cloudflare/d1-database.ts +10 -3
  333. package/src/cloudflare/dispatch-namespace.ts +10 -7
  334. package/src/cloudflare/hyperdrive.ts +13 -3
  335. package/src/cloudflare/kv-namespace.ts +25 -2
  336. package/src/cloudflare/miniflare/miniflare-worker-proxy.ts +3 -1
  337. package/src/cloudflare/miniflare/paths.ts +13 -0
  338. package/src/cloudflare/pipeline.ts +76 -28
  339. package/src/cloudflare/queue-consumer.ts +1 -1
  340. package/src/cloudflare/queue.ts +26 -14
  341. package/src/cloudflare/react-router/react-router.ts +28 -2
  342. package/src/cloudflare/redwood/plugin.ts +3 -2
  343. package/src/cloudflare/route.ts +1 -1
  344. package/src/cloudflare/ruleset.ts +7 -2
  345. package/src/cloudflare/secret.ts +20 -31
  346. package/src/cloudflare/secrets-store.ts +7 -3
  347. package/src/cloudflare/tunnel.ts +13 -2
  348. package/src/cloudflare/vectorize-index.ts +14 -3
  349. package/src/cloudflare/vite/plugin.ts +3 -2
  350. package/src/cloudflare/website.ts +1 -1
  351. package/src/cloudflare/worker.ts +35 -23
  352. package/src/cloudflare/wrangler.json.ts +7 -4
  353. package/src/docker/container.ts +13 -1
  354. package/src/docker/network.ts +18 -3
  355. package/src/docker/volume.ts +17 -6
  356. package/src/fs/index.ts +0 -8
  357. package/src/github/client.ts +6 -2
  358. package/src/github/repository-environment.ts +27 -13
  359. package/src/neon/project.ts +20 -6
  360. package/src/planetscale/branch.ts +24 -13
  361. package/src/planetscale/database.ts +38 -17
  362. package/src/planetscale/password.ts +10 -3
  363. package/src/resource.ts +1 -10
  364. package/src/scope.ts +29 -38
  365. package/src/sentry/client-key.ts +74 -6
  366. package/src/sentry/project.ts +59 -6
  367. package/src/sentry/team.ts +55 -7
  368. package/src/serde.ts +0 -44
  369. package/src/state/d1-state-store.ts +13 -6
  370. package/src/state/sqlite-state-store.ts +16 -17
  371. package/src/stripe/card.ts +5 -2
  372. package/src/stripe/client.ts +10 -3
  373. package/src/stripe/coupon.ts +4 -3
  374. package/src/stripe/customer.ts +2 -2
  375. package/src/stripe/entitlements-feature.ts +5 -2
  376. package/src/stripe/file.ts +3 -2
  377. package/src/stripe/meter.ts +2 -2
  378. package/src/stripe/portal-configuration.ts +5 -2
  379. package/src/stripe/price.ts +3 -2
  380. package/src/stripe/product-feature.ts +5 -2
  381. package/src/stripe/product.ts +3 -2
  382. package/src/stripe/promotion-code.ts +3 -2
  383. package/src/stripe/shipping-rate.ts +4 -3
  384. package/src/stripe/tax-rate.ts +3 -2
  385. package/src/stripe/webhook.ts +4 -3
  386. package/src/test/vitest.ts +1 -0
  387. package/src/upstash/redis.ts +15 -5
  388. package/src/util/ignore-matcher.ts +3 -1
  389. package/src/util/peer.ts +53 -0
  390. package/src/vercel/project.ts +46 -1
  391. package/templates/hono/README.md +19 -0
  392. package/templates/hono/_env +1 -0
  393. package/templates/hono/_env.example +1 -0
  394. package/templates/hono/_gitignore +34 -0
  395. package/templates/hono/alchemy.run.ts +22 -0
  396. package/templates/hono/package.json +18 -0
  397. package/templates/hono/src/index.ts +17 -0
  398. package/templates/hono/tsconfig.json +13 -0
  399. package/templates/hono/types/env.d.ts +16 -0
  400. package/templates/react-router/vite.config.ts +5 -3
  401. package/workers/cloudflare-state-store.js +69 -74
  402. package/workers/dofs-state-store.js +1 -1
  403. package/bin/bootstrap-s3.ts +0 -255
  404. package/lib/ai/ark.d.ts +0 -12
  405. package/lib/ai/ark.d.ts.map +0 -1
  406. package/lib/ai/ark.js +0 -87
  407. package/lib/ai/ark.js.map +0 -1
  408. package/lib/ai/astro-file.d.ts +0 -138
  409. package/lib/ai/astro-file.d.ts.map +0 -1
  410. package/lib/ai/astro-file.js +0 -158
  411. package/lib/ai/astro-file.js.map +0 -1
  412. package/lib/ai/client.d.ts +0 -51
  413. package/lib/ai/client.d.ts.map +0 -1
  414. package/lib/ai/client.js +0 -58
  415. package/lib/ai/client.js.map +0 -1
  416. package/lib/ai/css-file.d.ts +0 -132
  417. package/lib/ai/css-file.d.ts.map +0 -1
  418. package/lib/ai/css-file.js +0 -142
  419. package/lib/ai/css-file.js.map +0 -1
  420. package/lib/ai/data.d.ts +0 -152
  421. package/lib/ai/data.d.ts.map +0 -1
  422. package/lib/ai/data.js +0 -120
  423. package/lib/ai/data.js.map +0 -1
  424. package/lib/ai/document.d.ts +0 -208
  425. package/lib/ai/document.d.ts.map +0 -1
  426. package/lib/ai/document.js +0 -206
  427. package/lib/ai/document.js.map +0 -1
  428. package/lib/ai/html-file.d.ts +0 -129
  429. package/lib/ai/html-file.d.ts.map +0 -1
  430. package/lib/ai/html-file.js +0 -139
  431. package/lib/ai/html-file.js.map +0 -1
  432. package/lib/ai/index.d.ts +0 -11
  433. package/lib/ai/index.d.ts.map +0 -1
  434. package/lib/ai/index.js +0 -11
  435. package/lib/ai/index.js.map +0 -1
  436. package/lib/ai/json-file.d.ts +0 -161
  437. package/lib/ai/json-file.d.ts.map +0 -1
  438. package/lib/ai/json-file.js +0 -188
  439. package/lib/ai/json-file.js.map +0 -1
  440. package/lib/ai/typescript-file.d.ts +0 -140
  441. package/lib/ai/typescript-file.d.ts.map +0 -1
  442. package/lib/ai/typescript-file.js +0 -146
  443. package/lib/ai/typescript-file.js.map +0 -1
  444. package/lib/ai/vue-file.d.ts +0 -127
  445. package/lib/ai/vue-file.d.ts.map +0 -1
  446. package/lib/ai/vue-file.js +0 -137
  447. package/lib/ai/vue-file.js.map +0 -1
  448. package/lib/ai/yaml-file.d.ts +0 -170
  449. package/lib/ai/yaml-file.d.ts.map +0 -1
  450. package/lib/ai/yaml-file.js +0 -201
  451. package/lib/ai/yaml-file.js.map +0 -1
  452. package/lib/fs/static-astro-file.d.ts +0 -35
  453. package/lib/fs/static-astro-file.d.ts.map +0 -1
  454. package/lib/fs/static-astro-file.js +0 -40
  455. package/lib/fs/static-astro-file.js.map +0 -1
  456. package/lib/fs/static-css-file.d.ts +0 -25
  457. package/lib/fs/static-css-file.d.ts.map +0 -1
  458. package/lib/fs/static-css-file.js +0 -30
  459. package/lib/fs/static-css-file.js.map +0 -1
  460. package/lib/fs/static-html-file.d.ts +0 -32
  461. package/lib/fs/static-html-file.d.ts.map +0 -1
  462. package/lib/fs/static-html-file.js +0 -37
  463. package/lib/fs/static-html-file.js.map +0 -1
  464. package/lib/fs/static-json-file.d.ts +0 -18
  465. package/lib/fs/static-json-file.d.ts.map +0 -1
  466. package/lib/fs/static-json-file.js +0 -19
  467. package/lib/fs/static-json-file.js.map +0 -1
  468. package/lib/fs/static-text-file.d.ts +0 -13
  469. package/lib/fs/static-text-file.d.ts.map +0 -1
  470. package/lib/fs/static-text-file.js +0 -9
  471. package/lib/fs/static-text-file.js.map +0 -1
  472. package/lib/fs/static-typescript-file.d.ts +0 -20
  473. package/lib/fs/static-typescript-file.d.ts.map +0 -1
  474. package/lib/fs/static-typescript-file.js +0 -16
  475. package/lib/fs/static-typescript-file.js.map +0 -1
  476. package/lib/fs/static-vue-file.d.ts +0 -29
  477. package/lib/fs/static-vue-file.d.ts.map +0 -1
  478. package/lib/fs/static-vue-file.js +0 -34
  479. package/lib/fs/static-vue-file.js.map +0 -1
  480. package/lib/fs/static-yaml-file.d.ts +0 -23
  481. package/lib/fs/static-yaml-file.d.ts.map +0 -1
  482. package/lib/fs/static-yaml-file.js +0 -10
  483. package/lib/fs/static-yaml-file.js.map +0 -1
  484. package/lib/internal/docs/providers.d.ts +0 -34
  485. package/lib/internal/docs/providers.d.ts.map +0 -1
  486. package/lib/internal/docs/providers.js +0 -200
  487. package/lib/internal/docs/providers.js.map +0 -1
  488. package/lib/runtime/bind.d.ts +0 -25
  489. package/lib/runtime/bind.d.ts.map +0 -1
  490. package/lib/runtime/bind.js +0 -76
  491. package/lib/runtime/bind.js.map +0 -1
  492. package/lib/runtime/global.d.ts +0 -8
  493. package/lib/runtime/global.d.ts.map +0 -1
  494. package/lib/runtime/global.js +0 -3
  495. package/lib/runtime/global.js.map +0 -1
  496. package/lib/runtime/plugin.d.ts +0 -35
  497. package/lib/runtime/plugin.d.ts.map +0 -1
  498. package/lib/runtime/plugin.js +0 -134
  499. package/lib/runtime/plugin.js.map +0 -1
  500. package/lib/runtime/shims.d.ts +0 -6
  501. package/lib/runtime/shims.d.ts.map +0 -1
  502. package/lib/runtime/shims.js +0 -27
  503. package/lib/runtime/shims.js.map +0 -1
  504. package/lib/runtime/state.d.ts +0 -5
  505. package/lib/runtime/state.d.ts.map +0 -1
  506. package/lib/runtime/state.js +0 -4
  507. package/lib/runtime/state.js.map +0 -1
  508. package/lib/web/astro.d.ts +0 -148
  509. package/lib/web/astro.d.ts.map +0 -1
  510. package/lib/web/astro.js +0 -419
  511. package/lib/web/astro.js.map +0 -1
  512. package/lib/web/shadcn-component.d.ts +0 -30
  513. package/lib/web/shadcn-component.d.ts.map +0 -1
  514. package/lib/web/shadcn-component.js +0 -25
  515. package/lib/web/shadcn-component.js.map +0 -1
  516. package/lib/web/shadcn.d.ts +0 -98
  517. package/lib/web/shadcn.d.ts.map +0 -1
  518. package/lib/web/shadcn.js +0 -102
  519. package/lib/web/shadcn.js.map +0 -1
  520. package/lib/web/tailwind.d.ts +0 -65
  521. package/lib/web/tailwind.d.ts.map +0 -1
  522. package/lib/web/tailwind.js +0 -98
  523. package/lib/web/tailwind.js.map +0 -1
  524. package/lib/web/vite.d.ts +0 -96
  525. package/lib/web/vite.d.ts.map +0 -1
  526. package/lib/web/vite.js +0 -232
  527. package/lib/web/vite.js.map +0 -1
  528. package/lib/web/vitepress/config.d.ts +0 -12
  529. package/lib/web/vitepress/config.d.ts.map +0 -1
  530. package/lib/web/vitepress/config.js +0 -33
  531. package/lib/web/vitepress/config.js.map +0 -1
  532. package/lib/web/vitepress/custom-theme.d.ts +0 -174
  533. package/lib/web/vitepress/custom-theme.d.ts.map +0 -1
  534. package/lib/web/vitepress/custom-theme.js +0 -337
  535. package/lib/web/vitepress/custom-theme.js.map +0 -1
  536. package/lib/web/vitepress/dependencies.d.ts +0 -13
  537. package/lib/web/vitepress/dependencies.d.ts.map +0 -1
  538. package/lib/web/vitepress/dependencies.js +0 -37
  539. package/lib/web/vitepress/dependencies.js.map +0 -1
  540. package/lib/web/vitepress/home-page.d.ts +0 -247
  541. package/lib/web/vitepress/home-page.d.ts.map +0 -1
  542. package/lib/web/vitepress/home-page.js +0 -146
  543. package/lib/web/vitepress/home-page.js.map +0 -1
  544. package/lib/web/vitepress/index.d.ts +0 -6
  545. package/lib/web/vitepress/index.d.ts.map +0 -1
  546. package/lib/web/vitepress/index.js +0 -6
  547. package/lib/web/vitepress/index.js.map +0 -1
  548. package/lib/web/vitepress/process-front-matter-files.d.ts +0 -19
  549. package/lib/web/vitepress/process-front-matter-files.d.ts.map +0 -1
  550. package/lib/web/vitepress/process-front-matter-files.js +0 -73
  551. package/lib/web/vitepress/process-front-matter-files.js.map +0 -1
  552. package/lib/web/vitepress/vitepress.d.ts +0 -75
  553. package/lib/web/vitepress/vitepress.d.ts.map +0 -1
  554. package/lib/web/vitepress/vitepress.js +0 -254
  555. package/lib/web/vitepress/vitepress.js.map +0 -1
  556. package/src/ai/ark.ts +0 -118
  557. package/src/ai/astro-file.ts +0 -270
  558. package/src/ai/client.ts +0 -117
  559. package/src/ai/css-file.ts +0 -247
  560. package/src/ai/data.ts +0 -221
  561. package/src/ai/document.ts +0 -367
  562. package/src/ai/html-file.ts +0 -244
  563. package/src/ai/index.ts +0 -10
  564. package/src/ai/json-file.ts +0 -325
  565. package/src/ai/typescript-file.ts +0 -259
  566. package/src/ai/vue-file.ts +0 -242
  567. package/src/ai/yaml-file.ts +0 -328
  568. package/src/fs/static-astro-file.ts +0 -45
  569. package/src/fs/static-css-file.ts +0 -35
  570. package/src/fs/static-html-file.ts +0 -42
  571. package/src/fs/static-json-file.ts +0 -38
  572. package/src/fs/static-text-file.ts +0 -23
  573. package/src/fs/static-typescript-file.ts +0 -37
  574. package/src/fs/static-vue-file.ts +0 -39
  575. package/src/fs/static-yaml-file.ts +0 -33
  576. package/src/internal/docs/providers.ts +0 -286
  577. package/src/runtime/bind.ts +0 -95
  578. package/src/runtime/global.ts +0 -10
  579. package/src/runtime/plugin.ts +0 -163
  580. package/src/runtime/shims.js +0 -34
  581. package/src/runtime/state.ts +0 -9
  582. package/src/web/astro.ts +0 -643
  583. package/src/web/shadcn-component.ts +0 -72
  584. package/src/web/shadcn.ts +0 -221
  585. package/src/web/tailwind.ts +0 -167
  586. package/src/web/vite.ts +0 -407
  587. package/src/web/vitepress/config.ts +0 -50
  588. package/src/web/vitepress/custom-theme.ts +0 -514
  589. package/src/web/vitepress/dependencies.ts +0 -69
  590. package/src/web/vitepress/home-page.ts +0 -378
  591. package/src/web/vitepress/index.ts +0 -5
  592. package/src/web/vitepress/process-front-matter-files.ts +0 -107
  593. package/src/web/vitepress/vitepress.ts +0 -372
  594. package/templates/sveltekit/bun.lock +0 -1099
@@ -1,23 +0,0 @@
1
- import { File } from "./file.ts";
2
- /**
3
- * Creates a YAML file with formatted content
4
- *
5
- * @example
6
- * // Create a YAML configuration file
7
- * const config = await StaticYamlFile("config.yaml", {
8
- * server: {
9
- * host: "localhost",
10
- * port: 3000
11
- * },
12
- * database: {
13
- * url: "postgresql://localhost:5432/db",
14
- * pool: {
15
- * min: 1,
16
- * max: 10
17
- * }
18
- * }
19
- * });
20
- */
21
- export type StaticYamlFile = File;
22
- export declare function StaticYamlFile(id: string, ...args: [content: any] | [path: string, content: any]): Promise<StaticYamlFile>;
23
- //# sourceMappingURL=static-yaml-file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"static-yaml-file.d.ts","sourceRoot":"","sources":["../../src/fs/static-yaml-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC;AAElC,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,GAAG,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,GACrD,OAAO,CAAC,cAAc,CAAC,CAOzB"}
@@ -1,10 +0,0 @@
1
- import { File } from "./file.js";
2
- export async function StaticYamlFile(id, ...args) {
3
- const [path, content] = args.length === 1 ? [id, args[0]] : args;
4
- const yaml = await import("yaml");
5
- return File(id, {
6
- path,
7
- content: yaml.stringify(content),
8
- });
9
- }
10
- //# sourceMappingURL=static-yaml-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"static-yaml-file.js","sourceRoot":"","sources":["../../src/fs/static-yaml-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAsBjC,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,EAAU,EACV,GAAG,IAAmD;IAEtD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC,EAAE,EAAE;QACd,IAAI;QACJ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KACjC,CAAC,CAAC;AACL,CAAC"}
@@ -1,34 +0,0 @@
1
- import { Document } from "../../ai/document.ts";
2
- import { Folder } from "../../fs/folder.ts";
3
- export interface DocsProps {
4
- /**
5
- * The output directory for the docs.
6
- */
7
- outDir: string | Folder;
8
- /**
9
- * The source directory for the docs.
10
- */
11
- srcDir: string;
12
- /**
13
- * Whether to filter the docs.
14
- * If true, include all docs.
15
- * If false, include none.
16
- * If a number, include that many providers.
17
- *
18
- * @default true (all docs)
19
- */
20
- filter?: boolean | number;
21
- /**
22
- * Whether to run in parallel.
23
- *
24
- * @default true
25
- */
26
- parallel?: boolean;
27
- }
28
- export type Providers = {
29
- dir: string;
30
- provider: string;
31
- documents: Document[];
32
- }[];
33
- export declare function Providers({ srcDir, outDir, parallel, }: DocsProps): Promise<Providers>;
34
- //# sourceMappingURL=providers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../src/internal/docs/providers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAU5C,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB,EAAE,CAAC;AAEJ,wBAAsB,SAAS,CAAC,EAC9B,MAAM,EACN,MAAM,EAEN,QAAe,GAChB,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAoChC"}
@@ -1,200 +0,0 @@
1
- import { type } from "arktype";
2
- import fs from "node:fs/promises";
3
- import path from "node:path";
4
- import { Data } from "../../ai/data.js";
5
- import { Document } from "../../ai/document.js";
6
- import { alchemy } from "../../alchemy.js";
7
- import { Folder } from "../../fs/folder.js";
8
- function getArg(arg) {
9
- const idx = process.argv.findIndex((a) => a === arg);
10
- return idx > -1 ? process.argv[idx + 1] : undefined;
11
- }
12
- const onlyProviderName = getArg("--provider");
13
- const onlyResourceName = getArg("--resource");
14
- export async function Providers({ srcDir, outDir,
15
- // filter,
16
- parallel = true, }) {
17
- outDir = typeof outDir === "string" ? outDir : outDir.path;
18
- const exclude = [
19
- "util",
20
- "test",
21
- "vitepress",
22
- "vite",
23
- "shadcn",
24
- "internal",
25
- "web",
26
- ];
27
- // Get all folders in the alchemy/src directory
28
- const providers = (await fs.readdir(srcDir, {
29
- withFileTypes: true,
30
- }))
31
- .filter((dirent) => dirent.isDirectory() && !exclude.includes(dirent.name))
32
- .map((dirent) => path.join(dirent.parentPath, dirent.name));
33
- if (parallel) {
34
- return await Promise.all(providers.map((provider) => generateProviderDocs({ provider, outDir, parallel })));
35
- }
36
- const generatedProviders = [];
37
- for (const provider of providers) {
38
- generatedProviders.push(await generateProviderDocs({ provider, outDir, parallel }));
39
- }
40
- return generatedProviders;
41
- }
42
- async function generateProviderDocs({ provider, outDir, parallel, }) {
43
- const providerName = path.basename(provider);
44
- const files = (await fs.readdir(path.resolve(provider), {
45
- withFileTypes: true,
46
- }))
47
- .filter((dirent) => dirent.isFile())
48
- .map((dirent) => path.relative(process.cwd(), path.resolve(provider, dirent.name)))
49
- .filter((file) => file.endsWith(".ts") && !file.endsWith("index.ts"));
50
- const { object: { groups }, } = await Data(`docs/${providerName}`, {
51
- model: {
52
- id: "o3-mini",
53
- provider: "openai",
54
- options: {
55
- reasoningEffort: "high",
56
- },
57
- },
58
- freeze: onlyProviderName === undefined || onlyProviderName !== providerName,
59
- temperature: 0.1,
60
- schema: type({
61
- groups: type({
62
- identifier: type("string").describe("The identifier of the file's primary exported Resource/Function/Type, e.g. Bucket or StaticSite, AstroFile, TypeScriptFile"),
63
- filename: type("string").describe("The filename of the Resource's Document, e.g. bucket.md or static-site.md"),
64
- category: type("'Resource'|'Client'|'Utility'|'Types'").describe("The classification of the Resource's Document, one of: Resource, Client, Utility, or Types."),
65
- }).array(),
66
- }),
67
- system: await alchemy `
68
- You are a technical writer tasked with identifying the distinct documents that need to be written for a document group (folder) in a documentation site.
69
- You will be provided with a list of documents and instructions on how to classify them.
70
- Each document has a title, file name, and category.
71
- `,
72
- prompt: await alchemy `
73
- Identify and classify the documents that need to be written for the '${provider}' Service's Alchemy Resources.
74
- For background knowledge on Alchemy, see ${alchemy.file("./README.md")}.
75
- For background knowledge on the structure of an Alchemy Resource, see ${alchemy.file("./.cursorrules")}.
76
-
77
- The ${provider} Service has the following resources:
78
- ${alchemy.files(files)}
79
-
80
- A file is considered a "Resource" if it contains a const <ResourceName> = Resource(...) call or if it is a function that calls a Resource function, e.g. const TypeScriptFile = () => File(...), or it is the Workflow or DurableObject classes.
81
- A file is considered a "Client" if it exposes a wrapper around creating a SDK client or fetch.
82
- A file is considered a "Utility" if it contains utility functions that are not resources or clients.
83
- A file is considered a "Types" if it contains just type definitions and maybe helpers around working with those types.
84
-
85
- The title should be simply the name of the resource's const in code (with spaces added in between each word), e.g. "Bucket" or "Function", except with spaces, e.g. "StaticSite" for "const StaticSite". Maintain all other casing.
86
-
87
- // "Resource Name"
88
- const ResourceName = Resource(...)
89
- `,
90
- });
91
- const providerDocsDir = (await Folder(path.join(outDir, providerName))).path;
92
- let documents = [];
93
- if (parallel) {
94
- documents = await Promise.all(groups.filter((g) => g.category === "Resource").map(generateDocument));
95
- }
96
- else {
97
- for (const g of groups.filter((g) => g.category === "Resource")) {
98
- documents.push(await generateDocument(g));
99
- }
100
- }
101
- async function generateDocument(g) {
102
- return Document(`docs/${providerName}/${g.identifier}`, {
103
- title: g.identifier,
104
- path: path.join(providerDocsDir, `${g.filename.replace(".ts", "").replace(".md", "")}.md`),
105
- freeze: onlyResourceName !== undefined && onlyResourceName !== g.identifier,
106
- model: {
107
- id: "claude-3-5-sonnet-latest",
108
- provider: "anthropic",
109
- // options: {
110
- // reasoningEffort: "high",
111
- // },
112
- },
113
- prompt: await alchemy `
114
- You are a technical writer writing API documentation for an Alchemy IaC Resource.
115
- See ${alchemy.file("./README.md")} to understand the overview of Alchemy.
116
- See ${alchemy.file("./.cursorrules")} to better understand the structure and convention of an Alchemy Resource.
117
-
118
- Documentation should be written in the mdx format for an Astro Starlight documentation site.
119
-
120
- Relevant files for the ${providerName} Service:
121
- ${alchemy.files(files)}
122
-
123
- Write concise documentation for the "${g.identifier}" Resource.
124
-
125
- > [!CAUTION]
126
- > Avoid the temptation to over explain or over describe. Focus on concise, simple, high value snippets. One heading and 0-1 descriptions per snippet.
127
-
128
- > [!TIP]
129
- > Make sure the examples follow a natural progression from the minimal example to logical next steps of how the Resource might be used.
130
-
131
- Each document must follow the following format:
132
-
133
- # ${g.identifier}
134
-
135
- (simple description with an external link to the provider's website)
136
- e.g.
137
- The Efs component lets you add [Amazon Elastic File System (EFS)](https://docs.aws.amazon.com/efs/latest/ug/whatisefs.html) to your app.
138
-
139
- # Minimal Example
140
-
141
- (brief 1-2 sentences of what it does)
142
-
143
- \`\`\`ts
144
- import { ${g.identifier.replaceAll(" ", "")} } from "alchemy/${providerName}";
145
-
146
- (example)
147
- \`\`\`
148
-
149
- # (one heading per variation)
150
-
151
- (brief 1-2 sentences of what it does)
152
-
153
- \`\`\`ts
154
- import { ${g.identifier.replaceAll(" ", "")} } from "alchemy/${providerName}";
155
-
156
- (example)
157
- \`\`\`
158
-
159
- Before writing the document, think through:
160
- 1. What is the minimal, most common example use case for this resource?
161
- 2. What are the variations (e.g. combination of different options) that are also commonly used, e.g. specifying the memory size of a lambda function.
162
- 3. Make sure to draw from the examples and your understanding of Alchemy.
163
-
164
- Refer to alchemy docs to understand the context of how this documentation is consumed:
165
- - ${alchemy.file("./alchemy-web/docs/what-is-alchemy.md")}
166
- - ${alchemy.file("./alchemy-web/docs/getting-started.md")}
167
- - ${alchemy.folder("./alchemy-web/docs/concepts/")}
168
-
169
- ${providerName === "cloudflare"
170
- ? await alchemy `# Bind to a Worker
171
- (if it is a Cloudflare Resource)
172
-
173
- (brief 1-2 sentences of what it does)
174
-
175
- \`\`\`ts
176
- import { Worker, ${g.identifier.replaceAll(" ", "")} } from "alchemy/${providerName}";
177
-
178
- const myResource = await ${g.identifier.replaceAll(" ", "")}("my-resource", {
179
- // ...
180
- });
181
-
182
- await Worker("my-worker", {
183
- name: "my-worker",
184
- script: "console.log('Hello, world!')",
185
- bindings: {
186
- myResource,
187
- },
188
- });
189
- \`\`\``
190
- : ""}
191
- `,
192
- });
193
- }
194
- return {
195
- dir: providerDocsDir,
196
- provider: providerName,
197
- documents,
198
- };
199
- }
200
- //# sourceMappingURL=providers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/internal/docs/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,SAAS,MAAM,CAAC,GAAW;IACzB,MAAM,GAAG,GAAG,OAAO,CAA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AC3B,CAAC,CAAC,MAAM,OAAO,CAAA;;;;;;2BAMA,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,YAAY;;mCAExD,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;;;;;;;;;;;eAWpD;gBACH,CAAC,CAAC,EACN;OACD;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,GAAG,EAAE,eAAe;QACpB,QAAQ,EAAE,YAAY;QACtB,SAAS;KACV,CAAC;AACJ,CAAC"}
@@ -1,25 +0,0 @@
1
- import type { Binding as CloudflareBinding } from "../cloudflare/bindings.ts";
2
- import type { Bound as CloudflareBound } from "../cloudflare/bound.ts";
3
- import { type Resource } from "../resource.ts";
4
- /**
5
- * Get a Resource's Binding from the Environment.
6
- */
7
- export declare function getBinding<T extends Resource>(resource: T): Bound<T>;
8
- export declare function tryGetBinding<T extends Resource>(resource: T): Promise<Bound<T>> | undefined;
9
- /**
10
- * Compute a unique key for where to store a Resource's Binding.
11
- */
12
- export declare function getBindKey(resource: Resource): string;
13
- export type Bound<T> = T extends CloudflareBinding ? CloudflareBound<T> : T;
14
- /**
15
- * Create a lazy binding of a Resource to an environment that exposes the Resource's methods
16
- * throw a Proxy that delays initialization of the binding until the Resource's methods are accessed.
17
- *
18
- * This allows us to run the same code during build time and runtime.
19
- */
20
- export declare function bind<T extends Resource>(resource: T | Promise<T>, options?: {
21
- reify?: (value: T, key: string) => Promise<Bound<T>>;
22
- /** @default true */
23
- bindThis?: boolean;
24
- }): Promise<Bound<T>>;
25
- //# sourceMappingURL=bind.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../src/runtime/bind.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,KAAK,EAAE,KAAK,IAAI,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAIvE,OAAO,EAA8B,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG3E;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAEpE;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,QAAQ,EAC9C,QAAQ,EAAE,CAAC,GACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAK/B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CASrD;AAED,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,iBAAiB,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,CAAC,SAAS,QAAQ,EAC3C,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACxB,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,oBAAoB;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GACA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAwCnB"}
@@ -1,76 +0,0 @@
1
- import { isPromise } from "node:util/types";
2
- import { isWorkerStub } from "../cloudflare/worker-stub.js";
3
- import { isWorker } from "../cloudflare/worker.js";
4
- import { env } from "../env.js";
5
- import { ResourceFQN, ResourceScope } from "../resource.js";
6
- import { isRuntime } from "./global.js";
7
- /**
8
- * Get a Resource's Binding from the Environment.
9
- */
10
- export function getBinding(resource) {
11
- return env[getBindKey(resource)];
12
- }
13
- export function tryGetBinding(resource) {
14
- if (isRuntime) {
15
- return getBinding(resource);
16
- }
17
- return undefined;
18
- }
19
- /**
20
- * Compute a unique key for where to store a Resource's Binding.
21
- */
22
- export function getBindKey(resource) {
23
- if (isWorker(resource) || isWorkerStub(resource)) {
24
- return `worker:${resource.name}`;
25
- }
26
- const fqn = resource[ResourceFQN];
27
- const scope = resource[ResourceScope];
28
- const prefix = `${scope.appName}/${scope.stage}`;
29
- const key = fqn.slice(prefix.length + 1).replace(/[^a-zA-Z0-9-_]/g, "_");
30
- return key;
31
- }
32
- /**
33
- * Create a lazy binding of a Resource to an environment that exposes the Resource's methods
34
- * throw a Proxy that delays initialization of the binding until the Resource's methods are accessed.
35
- *
36
- * This allows us to run the same code during build time and runtime.
37
- */
38
- export async function bind(resource, options) {
39
- if (isPromise(resource)) {
40
- return resource.then((r) => bind(r, options));
41
- }
42
- let _runtime;
43
- const runtime = async () => (_runtime ??= [
44
- await (options?.reify
45
- ? options.reify(resource, getBindKey(resource))
46
- : getBinding(resource)),
47
- ])[0];
48
- return new Proxy(() => { }, {
49
- get: (target, prop) => {
50
- if (prop in target) {
51
- return resource[prop];
52
- }
53
- else if (prop === "then" || prop === "catch" || prop === "finally") {
54
- return target[prop];
55
- }
56
- return async (...args) => {
57
- const rt = await runtime();
58
- if (rt === undefined) {
59
- throw new Error(`Resource ${resource[ResourceFQN]} is not bound`);
60
- }
61
- const method = rt[prop];
62
- if (typeof method !== "function") {
63
- throw new Error(`Method ${prop} on '${resource[ResourceFQN]}' is not a function`);
64
- }
65
- if (options?.bindThis !== false) {
66
- return method.bind(rt)(...args);
67
- }
68
- return method(...args);
69
- };
70
- },
71
- // apply: (target, thisArg, argArray) => {
72
- // return target(thisArg, ...argArray);
73
- // },
74
- });
75
- }
76
- //# sourceMappingURL=bind.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bind.js","sourceRoot":"","sources":["../../src/runtime/bind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EAAE,YAAY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AE,QAAQ,KAAK,KAAK,EAAE,CAAC;oBAChC,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBAClC,CAAC;gBACD,OAAO,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;YACzB,CAAC,CAAC;QACJ,CAAC;QACD,0CAA0C;QAC1C,yCAAyC;QACzC,KAAK;KACN,CAAiB,CAAC;AACrB,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { SerializedScope } from "../serde.ts";
2
- declare global {
3
- const __ALCHEMY_WORKER_NAME__: string;
4
- const __ALCHEMY_RUNTIME__: true;
5
- const __ALCHEMY_SERIALIZED_SCOPE__: SerializedScope;
6
- }
7
- export declare const isRuntime: boolean;
8
- //# sourceMappingURL=global.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../src/runtime/global.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,uBAAuB,EAAE,MAAM,CAAC;IACtC,MAAM,mBAAmB,EAAE,IAAI,CAAC;IAChC,MAAM,4BAA4B,EAAE,eAAe,CAAC;CACrD;AAGD,eAAO,MAAM,SAAS,SAA6C,CAAC"}
@@ -1,3 +0,0 @@
1
- // __ALCHEMY_SERIALIZED_SCOPE__ is injected by esbuild when bundling a Worker
2
- export const isRuntime = typeof __ALCHEMY_RUNTIME__ !== "undefined";
3
- //# sourceMappingURL=global.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/runtime/global.ts"],"names":[],"mappings":"AAQA,6EAA6E;AAC7E,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,mBAAmB,KAAK,WAAW,CAAC"}
@@ -1,35 +0,0 @@
1
- import type { Plugin } from "esbuild";
2
- /**
3
- * Bundles a single Worker function entrypoint by:
4
- * 1. Evaluate the script and detect which resources are included in its bundle.
5
- * 2. Create a static map of Resource ID -> State
6
- * 3. Apply esbuild with {@link bootstrapPlugin} to erase Resource lifecycle operations
7
- * 4. The final bundle should then tree-shake away all infrastructure-code, leaving only runtime code.
8
- *
9
- * TODO(sam): should we inline the state map in the bundle or bind to a Cloudflare Worker with a blob?
10
- * TODO(sam): what should we do with secrets? Seems like we could auto-bind them and resolve without requiring encryption logic.
11
- *
12
- * @param file the `.ts` file containing an `export default function`
13
- */
14
- export declare function bundleEntrypoint(_file: string): void;
15
- /**
16
- * This is a plugin that bootstraps Alchemy Infrastructure into Runtime by replacing Resources
17
- * with a stub that loads from a statically bundled state.
18
- *
19
- * Take the following table for example:
20
- * ```ts
21
- * const Table = Resource(
22
- * "dynamodb::Table",
23
- * async function(this, id, props) {
24
- * // lifecycle logic in here
25
- * }
26
- * );
27
- * ```
28
- *
29
- * The plugin replaces the Resource with a stub:
30
- * ```ts
31
- * const Table = (id, props) => STATE.get(id)
32
- * ```
33
- */
34
- export declare const bootstrapPlugin: Plugin;
35
- //# sourceMappingURL=plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/runtime/plugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAItC;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,QAAI;AAElD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,EAAE,MAqH7B,CAAC"}
@@ -1,134 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import { logger } from "../util/logger.js";
3
- /**
4
- * Bundles a single Worker function entrypoint by:
5
- * 1. Evaluate the script and detect which resources are included in its bundle.
6
- * 2. Create a static map of Resource ID -> State
7
- * 3. Apply esbuild with {@link bootstrapPlugin} to erase Resource lifecycle operations
8
- * 4. The final bundle should then tree-shake away all infrastructure-code, leaving only runtime code.
9
- *
10
- * TODO(sam): should we inline the state map in the bundle or bind to a Cloudflare Worker with a blob?
11
- * TODO(sam): what should we do with secrets? Seems like we could auto-bind them and resolve without requiring encryption logic.
12
- *
13
- * @param file the `.ts` file containing an `export default function`
14
- */
15
- export function bundleEntrypoint(_file) { }
16
- /**
17
- * This is a plugin that bootstraps Alchemy Infrastructure into Runtime by replacing Resources
18
- * with a stub that loads from a statically bundled state.
19
- *
20
- * Take the following table for example:
21
- * ```ts
22
- * const Table = Resource(
23
- * "dynamodb::Table",
24
- * async function(this, id, props) {
25
- * // lifecycle logic in here
26
- * }
27
- * );
28
- * ```
29
- *
30
- * The plugin replaces the Resource with a stub:
31
- * ```ts
32
- * const Table = (id, props) => STATE.get(id)
33
- * ```
34
- */
35
- export const bootstrapPlugin = {
36
- name: "alchemy-bootstrap",
37
- async setup(build) {
38
- const { parse, print } = await import("@swc/core");
39
- const { Visitor } = await import("@swc/core/Visitor.js");
40
- async function expr(expr) {
41
- return (await parse(`const __temp__ = ${expr}`)).body[0].declarations[0].init;
42
- }
43
- async function decl(decl) {
44
- return (await parse(decl)).body[0];
45
- }
46
- const Provider = await decl("async function Resource() {}");
47
- const Resource = await expr("(id) => STATE.get(id)");
48
- // const alchemy = await expr("(async () => {})");
49
- // Add a global STATE object to bundle for resource lookup
50
- build.onLoad({
51
- filter: /.*\.(ts|js)x?/,
52
- }, async (args) => {
53
- try {
54
- const source = await fs.readFile(args.path, "utf-8");
55
- function transformed(code) {
56
- return {
57
- contents: code,
58
- loader: args.path.endsWith(".ts")
59
- ? args.path.endsWith(".tsx")
60
- ? "tsx"
61
- : "ts"
62
- : args.path.endsWith(".jsx")
63
- ? "jsx"
64
- : "js",
65
- };
66
- }
67
- // Parse the source code using SWC
68
- const ast = await parse(source, {
69
- syntax: "typescript",
70
- tsx: args.path.endsWith(".tsx"),
71
- decorators: true,
72
- dynamicImport: true,
73
- });
74
- // function text({ span }: HasSpan) {
75
- // return source.slice(
76
- // span.start - ast.span.start,
77
- // span.end - ast.span.start,
78
- // );
79
- // }
80
- // Create visitor to transform Resource calls
81
- class ResourceTransformer extends Visitor {
82
- visitTsType(n) {
83
- return n;
84
- }
85
- visitFunctionDeclaration(decl) {
86
- const param = decl.params[0];
87
- if (decl.identifier.value === "Resource" &&
88
- param?.pat.type === "Identifier" &&
89
- param.pat.value === "type" &&
90
- decl.body) {
91
- return Provider;
92
- }
93
- return decl;
94
- }
95
- visitCallExpression(expr) {
96
- // Check if this is a Resource call
97
- if (expr.callee.type === "Identifier" &&
98
- expr.callee.value === "Resource" &&
99
- expr.arguments.length >= 2) {
100
- return Resource;
101
- // } else if (
102
- // expr.callee.type === "Identifier" &&
103
- // expr.callee.value === "alchemy"
104
- // ) {
105
- // return alchemy;
106
- }
107
- return super.visitCallExpression(expr);
108
- }
109
- }
110
- // Apply the transformation
111
- const visitor = new ResourceTransformer();
112
- const program = visitor.visitProgram(ast);
113
- // Print the transformed AST back to code
114
- const { code } = await print(program, {
115
- sourceMaps: true,
116
- minify: false,
117
- });
118
- return transformed(code);
119
- }
120
- catch (error) {
121
- logger.error(`Error transforming ${args.path}:`, error);
122
- return {
123
- errors: [
124
- {
125
- text: `Failed to transform: ${error instanceof Error ? error.message : String(error)}`,
126
- location: { file: args.path },
127
- },
128
- ],
129
- };
130
- }
131
- });
132
- },
133
- };
134
- //# sourceMappingURL=plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/runtime/plugin.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa,IAAG,CAAC;AAElD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAW;IACrC,IAAI,EAAE,mBAAmB;IACzB,KAAK,CAAC,KAAK,CAAC,KAAK;QACf,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gBAC3B,MAAM,OAAO,GAAG,IAAI,mBAAmB,EAAE,CAAC;gBAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;gBAE1C,yCAAyC;gBACzC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,OAAO,EAAE;oBACpC,UAAU,EAAE,IAAI;oBAChB,MAAM,EAAE,KAAK;iBACd,CAAC,CAAC;gBAEH,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;YAC3B,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACxB,MAAM,CAAC,KAAK,CAAC,sBAAsB,IAAI,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;gBACxD,OAAO;oBACL,MAAM,EAAE;wBACN;4BACE,IAAI,EAAE,wBAAwB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;4BACtF,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE;yBAC9B;qBACF;iBACF,CAAC;YACJ,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -1,6 +0,0 @@
1
- export const __ALCHEMY_RUNTIME__: true;
2
- export const __ALCHEMY_SERIALIZED_SCOPE__: any;
3
- export namespace STATE {
4
- function get(id: any): Promise<any>;
5
- }
6
- //# sourceMappingURL=shims.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shims.d.ts","sourceRoot":"","sources":["../../src/runtime/shims.js"],"names":[],"mappings":"AAOA,kCAAmC,IAAI,CAAC;AAExC,+CAEE;;IAGA,oCAiBC"}
@@ -1,27 +0,0 @@
1
- import { env } from "cloudflare:workers";
2
- import { Scope } from "../scope.js";
3
- import { Secret } from "../secret.js";
4
- import { deserialize } from "../serde.js";
5
- globalThis.process.env = env;
6
- export const __ALCHEMY_RUNTIME__ = true;
7
- export var __ALCHEMY_SERIALIZED_SCOPE__ = JSON.parse(env.__ALCHEMY_SERIALIZED_SCOPE__);
8
- export const STATE = {
9
- async get(id) {
10
- const fqn = globalThis.__ALCHEMY_SCOPE__.current.fqn(id);
11
- const state = __ALCHEMY_SERIALIZED_SCOPE__[fqn];
12
- if (!state) {
13
- throw new Error(`Resource ${fqn} not found in __ALCHEMY_SERIALIZED_SCOPE__\n${JSON.stringify(__ALCHEMY_SERIALIZED_SCOPE__, null, 2)}`);
14
- }
15
- return await deserialize(Scope.current, state, {
16
- transform: (value) => {
17
- if (value && typeof value === "object" && value["@secret-env"]) {
18
- return {
19
- value: new Secret(env[value["@secret-env"]]),
20
- };
21
- }
22
- },
23
- });
24
- },
25
- };
26
- // export const process = { env };
27
- //# sourceMappingURL=shims.js.map