alchemy 0.16.10 → 0.17.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 (419) hide show
  1. package/lib/ai/astro-file.d.ts +1 -1
  2. package/lib/ai/astro-file.d.ts.map +1 -1
  3. package/lib/ai/astro-file.js +1 -1
  4. package/lib/ai/astro-file.js.map +1 -1
  5. package/lib/ai/client.js +2 -2
  6. package/lib/ai/client.js.map +1 -1
  7. package/lib/ai/css-file.d.ts +1 -1
  8. package/lib/ai/css-file.d.ts.map +1 -1
  9. package/lib/ai/css-file.js +1 -1
  10. package/lib/ai/css-file.js.map +1 -1
  11. package/lib/ai/data.d.ts +1 -1
  12. package/lib/ai/data.d.ts.map +1 -1
  13. package/lib/ai/data.js +1 -1
  14. package/lib/ai/data.js.map +1 -1
  15. package/lib/ai/html-file.d.ts +1 -1
  16. package/lib/ai/html-file.d.ts.map +1 -1
  17. package/lib/ai/html-file.js +1 -1
  18. package/lib/ai/html-file.js.map +1 -1
  19. package/lib/ai/json-file.d.ts +1 -1
  20. package/lib/ai/json-file.d.ts.map +1 -1
  21. package/lib/ai/json-file.js +1 -1
  22. package/lib/ai/json-file.js.map +1 -1
  23. package/lib/ai/typescript-file.d.ts +1 -1
  24. package/lib/ai/typescript-file.d.ts.map +1 -1
  25. package/lib/ai/typescript-file.js +1 -1
  26. package/lib/ai/typescript-file.js.map +1 -1
  27. package/lib/ai/vue-file.d.ts +1 -1
  28. package/lib/ai/vue-file.d.ts.map +1 -1
  29. package/lib/ai/vue-file.js +1 -1
  30. package/lib/ai/vue-file.js.map +1 -1
  31. package/lib/ai/yaml-file.d.ts +1 -1
  32. package/lib/ai/yaml-file.d.ts.map +1 -1
  33. package/lib/ai/yaml-file.js +2 -2
  34. package/lib/ai/yaml-file.js.map +1 -1
  35. package/lib/alchemy.d.ts +4 -0
  36. package/lib/alchemy.d.ts.map +1 -1
  37. package/lib/alchemy.js +14 -4
  38. package/lib/alchemy.js.map +1 -1
  39. package/lib/apply.d.ts +2 -0
  40. package/lib/apply.d.ts.map +1 -1
  41. package/lib/apply.js +17 -2
  42. package/lib/apply.js.map +1 -1
  43. package/lib/aws/bucket.d.ts +1 -1
  44. package/lib/aws/bucket.d.ts.map +1 -1
  45. package/lib/aws/bucket.js +1 -1
  46. package/lib/aws/bucket.js.map +1 -1
  47. package/lib/aws/function.d.ts +1 -1
  48. package/lib/aws/function.d.ts.map +1 -1
  49. package/lib/aws/function.js +2 -2
  50. package/lib/aws/function.js.map +1 -1
  51. package/lib/aws/oidc/oidc-provider.d.ts +1 -1
  52. package/lib/aws/oidc/oidc-provider.d.ts.map +1 -1
  53. package/lib/aws/oidc/oidc-provider.js +1 -1
  54. package/lib/aws/oidc/oidc-provider.js.map +1 -1
  55. package/lib/aws/policy-attachment.d.ts +1 -1
  56. package/lib/aws/policy-attachment.d.ts.map +1 -1
  57. package/lib/aws/policy-attachment.js +1 -1
  58. package/lib/aws/policy-attachment.js.map +1 -1
  59. package/lib/aws/policy.d.ts +1 -1
  60. package/lib/aws/policy.d.ts.map +1 -1
  61. package/lib/aws/policy.js +1 -1
  62. package/lib/aws/policy.js.map +1 -1
  63. package/lib/aws/queue.d.ts +1 -1
  64. package/lib/aws/queue.d.ts.map +1 -1
  65. package/lib/aws/queue.js +20 -25
  66. package/lib/aws/queue.js.map +1 -1
  67. package/lib/aws/role.d.ts +1 -1
  68. package/lib/aws/role.d.ts.map +1 -1
  69. package/lib/aws/role.js +1 -1
  70. package/lib/aws/role.js.map +1 -1
  71. package/lib/aws/ses.d.ts +1 -1
  72. package/lib/aws/ses.d.ts.map +1 -1
  73. package/lib/aws/ses.js +1 -1
  74. package/lib/aws/ses.js.map +1 -1
  75. package/lib/aws/table.d.ts +1 -1
  76. package/lib/aws/table.d.ts.map +1 -1
  77. package/lib/aws/table.js +1 -1
  78. package/lib/aws/table.js.map +1 -1
  79. package/lib/cloudflare/account-api-token.d.ts +1 -1
  80. package/lib/cloudflare/account-api-token.d.ts.map +1 -1
  81. package/lib/cloudflare/account-api-token.js +1 -1
  82. package/lib/cloudflare/account-api-token.js.map +1 -1
  83. package/lib/cloudflare/ai-gateway.d.ts +4 -3
  84. package/lib/cloudflare/ai-gateway.d.ts.map +1 -1
  85. package/lib/cloudflare/ai-gateway.js +13 -1
  86. package/lib/cloudflare/ai-gateway.js.map +1 -1
  87. package/lib/cloudflare/api-error.js +1 -1
  88. package/lib/cloudflare/api-error.js.map +1 -1
  89. package/lib/cloudflare/assets.js +2 -2
  90. package/lib/cloudflare/assets.js.map +1 -1
  91. package/lib/cloudflare/auth.js +1 -1
  92. package/lib/cloudflare/auth.js.map +1 -1
  93. package/lib/cloudflare/bindings.d.ts +17 -11
  94. package/lib/cloudflare/bindings.d.ts.map +1 -1
  95. package/lib/cloudflare/bindings.js +6 -0
  96. package/lib/cloudflare/bindings.js.map +1 -1
  97. package/lib/cloudflare/bound.d.ts +11 -10
  98. package/lib/cloudflare/bound.d.ts.map +1 -1
  99. package/lib/cloudflare/bucket.d.ts +6 -4
  100. package/lib/cloudflare/bucket.d.ts.map +1 -1
  101. package/lib/cloudflare/bucket.js +22 -2
  102. package/lib/cloudflare/bucket.js.map +1 -1
  103. package/lib/cloudflare/bundle/bundle-worker.d.ts +1 -0
  104. package/lib/cloudflare/bundle/bundle-worker.d.ts.map +1 -1
  105. package/lib/cloudflare/bundle/bundle-worker.js +4 -2
  106. package/lib/cloudflare/bundle/bundle-worker.js.map +1 -1
  107. package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts +1 -1
  108. package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts.map +1 -1
  109. package/lib/cloudflare/bundle/nodejs-compat-mode.js +2 -2
  110. package/lib/cloudflare/bundle/nodejs-compat-mode.js.map +1 -1
  111. package/lib/cloudflare/bundle/nodejs-compat.js +1 -1
  112. package/lib/cloudflare/bundle/nodejs-compat.js.map +1 -1
  113. package/lib/cloudflare/custom-domain.js +1 -1
  114. package/lib/cloudflare/custom-domain.js.map +1 -1
  115. package/lib/cloudflare/d1-database.d.ts +4 -62
  116. package/lib/cloudflare/d1-database.d.ts.map +1 -1
  117. package/lib/cloudflare/d1-database.js +27 -11
  118. package/lib/cloudflare/d1-database.js.map +1 -1
  119. package/lib/cloudflare/dns-records.d.ts +1 -1
  120. package/lib/cloudflare/dns-records.d.ts.map +1 -1
  121. package/lib/cloudflare/dns-records.js +2 -2
  122. package/lib/cloudflare/dns-records.js.map +1 -1
  123. package/lib/cloudflare/event-source.d.ts +3 -3
  124. package/lib/cloudflare/event-source.d.ts.map +1 -1
  125. package/lib/cloudflare/hyperdrive.d.ts +4 -3
  126. package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
  127. package/lib/cloudflare/hyperdrive.js +9 -1
  128. package/lib/cloudflare/hyperdrive.js.map +1 -1
  129. package/lib/cloudflare/kv-namespace.d.ts +9 -5
  130. package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
  131. package/lib/cloudflare/kv-namespace.js +26 -6
  132. package/lib/cloudflare/kv-namespace.js.map +1 -1
  133. package/lib/cloudflare/permission-groups.d.ts +1 -1
  134. package/lib/cloudflare/permission-groups.d.ts.map +1 -1
  135. package/lib/cloudflare/permission-groups.js +1 -1
  136. package/lib/cloudflare/permission-groups.js.map +1 -1
  137. package/lib/cloudflare/pipeline.d.ts +5 -3
  138. package/lib/cloudflare/pipeline.d.ts.map +1 -1
  139. package/lib/cloudflare/pipeline.js +16 -2
  140. package/lib/cloudflare/pipeline.js.map +1 -1
  141. package/lib/cloudflare/queue-consumer.d.ts +3 -3
  142. package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
  143. package/lib/cloudflare/queue-consumer.js +1 -1
  144. package/lib/cloudflare/queue-consumer.js.map +1 -1
  145. package/lib/cloudflare/queue.d.ts +34 -22
  146. package/lib/cloudflare/queue.d.ts.map +1 -1
  147. package/lib/cloudflare/queue.js +66 -4
  148. package/lib/cloudflare/queue.js.map +1 -1
  149. package/lib/cloudflare/route.d.ts +1 -1
  150. package/lib/cloudflare/route.d.ts.map +1 -1
  151. package/lib/cloudflare/route.js +1 -1
  152. package/lib/cloudflare/route.js.map +1 -1
  153. package/lib/cloudflare/types.js +1 -1
  154. package/lib/cloudflare/types.js.map +1 -1
  155. package/lib/cloudflare/vectorize-index.d.ts +6 -4
  156. package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
  157. package/lib/cloudflare/vectorize-index.js +20 -3
  158. package/lib/cloudflare/vectorize-index.js.map +1 -1
  159. package/lib/cloudflare/vectorize-metadata-index.d.ts +4 -3
  160. package/lib/cloudflare/vectorize-metadata-index.d.ts.map +1 -1
  161. package/lib/cloudflare/vectorize-metadata-index.js +5 -2
  162. package/lib/cloudflare/vectorize-metadata-index.js.map +1 -1
  163. package/lib/cloudflare/website.d.ts.map +1 -1
  164. package/lib/cloudflare/website.js +1 -0
  165. package/lib/cloudflare/website.js.map +1 -1
  166. package/lib/cloudflare/worker-assets.d.ts +32 -0
  167. package/lib/cloudflare/worker-assets.d.ts.map +1 -0
  168. package/lib/cloudflare/worker-assets.js +143 -0
  169. package/lib/cloudflare/worker-assets.js.map +1 -0
  170. package/lib/cloudflare/worker-metadata.d.ts +31 -0
  171. package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
  172. package/lib/cloudflare/worker-metadata.js +248 -0
  173. package/lib/cloudflare/worker-metadata.js.map +1 -1
  174. package/lib/cloudflare/worker-stub.d.ts +40 -0
  175. package/lib/cloudflare/worker-stub.d.ts.map +1 -0
  176. package/lib/cloudflare/worker-stub.js +86 -0
  177. package/lib/cloudflare/worker-stub.js.map +1 -0
  178. package/lib/cloudflare/worker.d.ts +57 -28
  179. package/lib/cloudflare/worker.d.ts.map +1 -1
  180. package/lib/cloudflare/worker.js +203 -479
  181. package/lib/cloudflare/worker.js.map +1 -1
  182. package/lib/cloudflare/wrangler.json.d.ts +1 -1
  183. package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
  184. package/lib/cloudflare/wrangler.json.js +5 -2
  185. package/lib/cloudflare/wrangler.json.js.map +1 -1
  186. package/lib/cloudflare/zone.d.ts +1 -1
  187. package/lib/cloudflare/zone.d.ts.map +1 -1
  188. package/lib/cloudflare/zone.js +1 -1
  189. package/lib/cloudflare/zone.js.map +1 -1
  190. package/lib/destroy.d.ts +1 -4
  191. package/lib/destroy.d.ts.map +1 -1
  192. package/lib/destroy.js +10 -21
  193. package/lib/destroy.js.map +1 -1
  194. package/lib/dns/import-dns.d.ts +1 -1
  195. package/lib/dns/import-dns.d.ts.map +1 -1
  196. package/lib/dns/import-dns.js +1 -1
  197. package/lib/dns/import-dns.js.map +1 -1
  198. package/lib/encrypt.d.ts.map +1 -1
  199. package/lib/encrypt.js +2 -1
  200. package/lib/encrypt.js.map +1 -1
  201. package/lib/env.js +14 -8
  202. package/lib/env.js.map +1 -1
  203. package/lib/esbuild/bundle.d.ts +2 -2
  204. package/lib/esbuild/bundle.d.ts.map +1 -1
  205. package/lib/esbuild/bundle.js +3 -3
  206. package/lib/esbuild/bundle.js.map +1 -1
  207. package/lib/fs/copy-file.d.ts +1 -1
  208. package/lib/fs/copy-file.d.ts.map +1 -1
  209. package/lib/fs/copy-file.js +1 -1
  210. package/lib/fs/copy-file.js.map +1 -1
  211. package/lib/github/client.js +1 -1
  212. package/lib/github/client.js.map +1 -1
  213. package/lib/github/repository-environment.d.ts +1 -1
  214. package/lib/github/repository-environment.d.ts.map +1 -1
  215. package/lib/github/repository-environment.js +2 -2
  216. package/lib/github/repository-environment.js.map +1 -1
  217. package/lib/github/secret.d.ts +1 -1
  218. package/lib/github/secret.d.ts.map +1 -1
  219. package/lib/github/secret.js +1 -1
  220. package/lib/github/secret.js.map +1 -1
  221. package/lib/internal/docs/providers.d.ts +1 -1
  222. package/lib/internal/docs/providers.d.ts.map +1 -1
  223. package/lib/internal/docs/providers.js +3 -1
  224. package/lib/internal/docs/providers.js.map +1 -1
  225. package/lib/neon/api-error.js +2 -2
  226. package/lib/neon/api-error.js.map +1 -1
  227. package/lib/os/exec.js +1 -1
  228. package/lib/os/exec.js.map +1 -1
  229. package/lib/resource.d.ts +13 -11
  230. package/lib/resource.d.ts.map +1 -1
  231. package/lib/resource.js +10 -5
  232. package/lib/resource.js.map +1 -1
  233. package/lib/runtime/bind.d.ts +25 -0
  234. package/lib/runtime/bind.d.ts.map +1 -0
  235. package/lib/runtime/bind.js +76 -0
  236. package/lib/runtime/bind.js.map +1 -0
  237. package/lib/runtime/global.d.ts +8 -0
  238. package/lib/runtime/global.d.ts.map +1 -0
  239. package/lib/runtime/global.js +3 -0
  240. package/lib/runtime/global.js.map +1 -0
  241. package/lib/runtime/plugin.d.ts +35 -0
  242. package/lib/runtime/plugin.d.ts.map +1 -0
  243. package/lib/runtime/plugin.js +133 -0
  244. package/lib/runtime/plugin.js.map +1 -0
  245. package/lib/runtime/shims.d.ts +6 -0
  246. package/lib/runtime/shims.d.ts.map +1 -0
  247. package/lib/runtime/shims.js +27 -0
  248. package/lib/runtime/shims.js.map +1 -0
  249. package/lib/runtime/state.d.ts +5 -0
  250. package/lib/runtime/state.d.ts.map +1 -0
  251. package/lib/runtime/state.js +4 -0
  252. package/lib/runtime/state.js.map +1 -0
  253. package/lib/scope.d.ts +16 -2
  254. package/lib/scope.d.ts.map +1 -1
  255. package/lib/scope.js +56 -9
  256. package/lib/scope.js.map +1 -1
  257. package/lib/secret.d.ts +7 -2
  258. package/lib/secret.d.ts.map +1 -1
  259. package/lib/secret.js +19 -4
  260. package/lib/secret.js.map +1 -1
  261. package/lib/sentry/client-key.d.ts +1 -1
  262. package/lib/sentry/client-key.d.ts.map +1 -1
  263. package/lib/sentry/client-key.js +1 -1
  264. package/lib/sentry/client-key.js.map +1 -1
  265. package/lib/sentry/project.d.ts +1 -1
  266. package/lib/sentry/project.d.ts.map +1 -1
  267. package/lib/sentry/project.js +1 -1
  268. package/lib/sentry/project.js.map +1 -1
  269. package/lib/sentry/team.d.ts +1 -1
  270. package/lib/sentry/team.d.ts.map +1 -1
  271. package/lib/sentry/team.js +1 -1
  272. package/lib/sentry/team.js.map +1 -1
  273. package/lib/serde.d.ts +26 -1
  274. package/lib/serde.d.ts.map +1 -1
  275. package/lib/serde.js +53 -8
  276. package/lib/serde.js.map +1 -1
  277. package/lib/stripe/meter.d.ts +1 -1
  278. package/lib/stripe/meter.d.ts.map +1 -1
  279. package/lib/stripe/meter.js +1 -1
  280. package/lib/stripe/meter.js.map +1 -1
  281. package/lib/stripe/price.d.ts +1 -1
  282. package/lib/stripe/price.d.ts.map +1 -1
  283. package/lib/stripe/price.js +1 -1
  284. package/lib/stripe/price.js.map +1 -1
  285. package/lib/stripe/product.d.ts +1 -1
  286. package/lib/stripe/product.d.ts.map +1 -1
  287. package/lib/stripe/product.js +1 -1
  288. package/lib/stripe/product.js.map +1 -1
  289. package/lib/stripe/webhook.d.ts +1 -1
  290. package/lib/stripe/webhook.d.ts.map +1 -1
  291. package/lib/stripe/webhook.js +1 -1
  292. package/lib/stripe/webhook.js.map +1 -1
  293. package/lib/test/bun.js +1 -1
  294. package/lib/test/bun.js.map +1 -1
  295. package/lib/test/prune.js +1 -1
  296. package/lib/test/prune.js.map +1 -1
  297. package/lib/upstash/redis.d.ts +1 -1
  298. package/lib/upstash/redis.d.ts.map +1 -1
  299. package/lib/upstash/redis.js +1 -1
  300. package/lib/upstash/redis.js.map +1 -1
  301. package/lib/util/content-type.d.ts +1 -1
  302. package/lib/util/content-type.d.ts.map +1 -1
  303. package/lib/util/content-type.js +1 -2
  304. package/lib/util/content-type.js.map +1 -1
  305. package/lib/util/retry.d.ts.map +1 -1
  306. package/lib/util/retry.js +1 -0
  307. package/lib/util/retry.js.map +1 -1
  308. package/lib/vercel/project-domain.d.ts +1 -1
  309. package/lib/vercel/project-domain.d.ts.map +1 -1
  310. package/lib/vercel/project-domain.js +1 -1
  311. package/lib/vercel/project-domain.js.map +1 -1
  312. package/lib/vercel/project.js +1 -1
  313. package/lib/vercel/project.js.map +1 -1
  314. package/lib/web/shadcn-component.d.ts +1 -1
  315. package/lib/web/shadcn-component.d.ts.map +1 -1
  316. package/lib/web/shadcn-component.js +1 -1
  317. package/lib/web/shadcn-component.js.map +1 -1
  318. package/lib/web/shadcn.d.ts +1 -1
  319. package/lib/web/shadcn.d.ts.map +1 -1
  320. package/lib/web/shadcn.js +1 -1
  321. package/lib/web/shadcn.js.map +1 -1
  322. package/lib/web/vitepress/dependencies.d.ts +1 -1
  323. package/lib/web/vitepress/dependencies.d.ts.map +1 -1
  324. package/lib/web/vitepress/dependencies.js +1 -1
  325. package/lib/web/vitepress/dependencies.js.map +1 -1
  326. package/lib/web/vitepress/vitepress.js +1 -1
  327. package/lib/web/vitepress/vitepress.js.map +1 -1
  328. package/package.json +2 -1
  329. package/src/ai/astro-file.ts +1 -1
  330. package/src/ai/client.ts +2 -2
  331. package/src/ai/css-file.ts +1 -1
  332. package/src/ai/data.ts +1 -1
  333. package/src/ai/html-file.ts +1 -1
  334. package/src/ai/json-file.ts +1 -1
  335. package/src/ai/typescript-file.ts +1 -1
  336. package/src/ai/vue-file.ts +1 -1
  337. package/src/ai/yaml-file.ts +2 -2
  338. package/src/alchemy.ts +18 -4
  339. package/src/apply.ts +27 -2
  340. package/src/aws/bucket.ts +1 -1
  341. package/src/aws/function.ts +2 -2
  342. package/src/aws/oidc/oidc-provider.ts +1 -1
  343. package/src/aws/policy-attachment.ts +1 -1
  344. package/src/aws/policy.ts +1 -1
  345. package/src/aws/queue.ts +28 -29
  346. package/src/aws/role.ts +1 -1
  347. package/src/aws/ses.ts +1 -1
  348. package/src/aws/table.ts +1 -1
  349. package/src/cloudflare/account-api-token.ts +1 -1
  350. package/src/cloudflare/ai-gateway.ts +23 -4
  351. package/src/cloudflare/api-error.ts +1 -1
  352. package/src/cloudflare/assets.ts +2 -2
  353. package/src/cloudflare/auth.ts +1 -1
  354. package/src/cloudflare/bindings.ts +33 -18
  355. package/src/cloudflare/bound.ts +18 -17
  356. package/src/cloudflare/bucket.ts +52 -24
  357. package/src/cloudflare/bundle/bundle-worker.ts +5 -2
  358. package/src/cloudflare/bundle/nodejs-compat-mode.ts +3 -3
  359. package/src/cloudflare/bundle/nodejs-compat.ts +1 -1
  360. package/src/cloudflare/custom-domain.ts +1 -1
  361. package/src/cloudflare/d1-database.ts +40 -19
  362. package/src/cloudflare/dns-records.ts +2 -2
  363. package/src/cloudflare/event-source.ts +3 -3
  364. package/src/cloudflare/hyperdrive.ts +19 -4
  365. package/src/cloudflare/kv-namespace.ts +46 -15
  366. package/src/cloudflare/permission-groups.ts +1 -1
  367. package/src/cloudflare/pipeline.ts +29 -6
  368. package/src/cloudflare/queue-consumer.ts +3 -3
  369. package/src/cloudflare/queue.ts +124 -23
  370. package/src/cloudflare/route.ts +1 -1
  371. package/src/cloudflare/types.ts +1 -1
  372. package/src/cloudflare/vectorize-index.ts +36 -8
  373. package/src/cloudflare/vectorize-metadata-index.ts +10 -4
  374. package/src/cloudflare/website.ts +4 -3
  375. package/src/cloudflare/worker-assets.ts +237 -0
  376. package/src/cloudflare/worker-metadata.ts +287 -0
  377. package/src/cloudflare/worker-stub.ts +153 -0
  378. package/src/cloudflare/worker.ts +386 -592
  379. package/src/cloudflare/wrangler.json.ts +4 -2
  380. package/src/cloudflare/zone.ts +1 -1
  381. package/src/destroy.ts +12 -23
  382. package/src/dns/import-dns.ts +1 -1
  383. package/src/encrypt.ts +2 -2
  384. package/src/env.ts +15 -8
  385. package/src/esbuild/bundle.ts +4 -3
  386. package/src/fs/copy-file.ts +1 -1
  387. package/src/github/client.ts +1 -1
  388. package/src/github/repository-environment.ts +2 -2
  389. package/src/github/secret.ts +1 -1
  390. package/src/internal/docs/providers.ts +1 -1
  391. package/src/neon/api-error.ts +2 -2
  392. package/src/os/exec.ts +1 -1
  393. package/src/resource.ts +22 -31
  394. package/src/runtime/bind.ts +95 -0
  395. package/src/runtime/global.ts +10 -0
  396. package/src/runtime/plugin.ts +162 -0
  397. package/src/runtime/shims.js +34 -0
  398. package/src/runtime/state.ts +9 -0
  399. package/src/scope.ts +72 -11
  400. package/src/secret.ts +29 -4
  401. package/src/sentry/client-key.ts +1 -1
  402. package/src/sentry/project.ts +1 -1
  403. package/src/sentry/team.ts +1 -1
  404. package/src/serde.ts +126 -10
  405. package/src/stripe/meter.ts +1 -1
  406. package/src/stripe/price.ts +1 -1
  407. package/src/stripe/product.ts +1 -1
  408. package/src/stripe/webhook.ts +1 -1
  409. package/src/test/bun.ts +1 -1
  410. package/src/test/prune.ts +1 -1
  411. package/src/upstash/redis.ts +1 -1
  412. package/src/util/content-type.ts +2 -3
  413. package/src/util/retry.ts +1 -0
  414. package/src/vercel/project-domain.ts +1 -1
  415. package/src/vercel/project.ts +1 -1
  416. package/src/web/shadcn-component.ts +1 -1
  417. package/src/web/shadcn.ts +1 -1
  418. package/src/web/vitepress/dependencies.ts +1 -1
  419. package/src/web/vitepress/vitepress.ts +1 -1
@@ -0,0 +1,9 @@
1
+ import type { Resource } from "../resource.js";
2
+
3
+ export interface RuntimeState {
4
+ get(id: string): Resource;
5
+ }
6
+
7
+ // /**
8
+ // * Runtime state injected into the environment.
9
+ // */
package/src/scope.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import type { Phase } from "./alchemy.js";
3
- import { destroy } from "./destroy.js";
3
+ import { destroyAll } from "./destroy.js";
4
4
  import { FileSystemStateStore } from "./fs/file-system-state-store.js";
5
5
  import { ResourceID, type PendingResource } from "./resource.js";
6
6
  import type { StateStore, StateStoreType } from "./state.js";
7
7
 
8
- const scopeStorage = new AsyncLocalStorage<Scope>();
9
-
10
8
  export type ScopeOptions = {
11
9
  appName?: string;
12
10
  stage?: string;
@@ -24,19 +22,30 @@ const DEFAULT_STAGE = process.env.ALCHEMY_STAGE ?? process.env.USER ?? "dev";
24
22
  export class Scope {
25
23
  public static readonly KIND = "alchemy::Scope" as const;
26
24
 
25
+ public static storage = new AsyncLocalStorage<Scope>();
26
+ public static globals: Scope[] = [];
27
+
27
28
  public static get(): Scope | undefined {
28
- return scopeStorage.getStore();
29
+ return Scope.storage.getStore();
30
+ }
31
+
32
+ public static get root(): Scope {
33
+ return Scope.current.root;
29
34
  }
30
35
 
31
36
  public static get current(): Scope {
32
37
  const scope = Scope.get();
33
38
  if (!scope) {
39
+ if (Scope.globals.length > 0) {
40
+ return Scope.globals[Scope.globals.length - 1];
41
+ }
34
42
  throw new Error("Not running within an Alchemy Scope");
35
43
  }
36
44
  return scope;
37
45
  }
38
46
 
39
47
  public readonly resources = new Map<ResourceID, PendingResource>();
48
+ public readonly children: Map<ResourceID, Scope> = new Map();
40
49
  public readonly appName: string | undefined;
41
50
  public readonly stage: string;
42
51
  public readonly scopeName: string | null;
@@ -48,10 +57,12 @@ export class Scope {
48
57
  public readonly phase: Phase;
49
58
 
50
59
  private isErrored = false;
60
+ private finalized = false;
61
+
62
+ private deferred: (() => Promise<any>)[] = [];
51
63
 
52
64
  constructor(options: ScopeOptions) {
53
65
  this.appName = options.appName;
54
- this.stage = options?.stage ?? DEFAULT_STAGE;
55
66
  this.scopeName = options.scopeName ?? null;
56
67
  if (this.scopeName?.includes(":")) {
57
68
  throw new Error(
@@ -59,6 +70,8 @@ export class Scope {
59
70
  );
60
71
  }
61
72
  this.parent = options.parent ?? Scope.get();
73
+ this.stage = options?.stage ?? this.parent?.stage ?? DEFAULT_STAGE;
74
+ this.parent?.children.set(this.scopeName!, this);
62
75
  this.quiet = options.quiet ?? this.parent?.quiet ?? false;
63
76
  if (this.parent && !this.scopeName) {
64
77
  throw new Error("Scope name is required when creating a child scope");
@@ -77,6 +90,14 @@ export class Scope {
77
90
  this.state = this.stateStore(this);
78
91
  }
79
92
 
93
+ public get root(): Scope {
94
+ let root: Scope = this;
95
+ while (root.parent) {
96
+ root = root.parent;
97
+ }
98
+ return root;
99
+ }
100
+
80
101
  public async delete(resourceID: ResourceID) {
81
102
  await this.state.delete(resourceID);
82
103
  this.resources.delete(resourceID);
@@ -102,10 +123,6 @@ export class Scope {
102
123
  this.isErrored = true;
103
124
  }
104
125
 
105
- public enter() {
106
- scopeStorage.enterWith(this);
107
- }
108
-
109
126
  public async init() {
110
127
  await this.state.init?.();
111
128
  }
@@ -120,7 +137,7 @@ export class Scope {
120
137
  }
121
138
 
122
139
  public async run<T>(fn: (scope: Scope) => Promise<T>): Promise<T> {
123
- return scopeStorage.run(this, () => fn(this));
140
+ return Scope.storage.run(this, () => fn(this));
124
141
  }
125
142
 
126
143
  [Symbol.asyncDispose]() {
@@ -131,6 +148,20 @@ export class Scope {
131
148
  if (this.phase === "read") {
132
149
  return;
133
150
  }
151
+ if (this.finalized) {
152
+ return;
153
+ }
154
+ if (this.parent === undefined && Scope.globals.length > 0) {
155
+ const last = Scope.globals.pop();
156
+ if (last !== this) {
157
+ throw new Error(
158
+ "Running in AsyncLocaStorage.enterWith emultation mode and attempted to finalize a global Scope that wasn't top of the stack",
159
+ );
160
+ }
161
+ }
162
+ this.finalized = true;
163
+ // trigger and await all deferred promises
164
+ await Promise.all(this.deferred.map((fn) => fn()));
134
165
  if (!this.isErrored) {
135
166
  // TODO: need to detect if it is in error
136
167
  const resourceIds = await this.state.list();
@@ -141,7 +172,7 @@ export class Scope {
141
172
  const orphans = await Promise.all(
142
173
  orphanIds.map(async (id) => (await this.state.get(id))!.output),
143
174
  );
144
- await destroy.all(orphans, {
175
+ await destroyAll(orphans, {
145
176
  quiet: this.quiet,
146
177
  strategy: "sequential",
147
178
  });
@@ -150,6 +181,28 @@ export class Scope {
150
181
  }
151
182
  }
152
183
 
184
+ /**
185
+ * Defers execution of a function until the Alchemy application finalizes.
186
+ */
187
+ public defer<T>(fn: () => Promise<T>): Promise<T> {
188
+ let _resolve: (value: T) => void;
189
+ let _reject: (reason?: any) => void;
190
+ const promise = new Promise<T>((resolve, reject) => {
191
+ _resolve = resolve;
192
+ _reject = reject;
193
+ });
194
+ this.deferred.push(() => {
195
+ if (!this.finalized) {
196
+ throw new Error(
197
+ "Attempted to await a deferred Promise before finalization",
198
+ );
199
+ }
200
+ // lazily trigger the worker on first await
201
+ return this.run(() => fn()).then(_resolve, _reject);
202
+ });
203
+ return promise;
204
+ }
205
+
153
206
  /**
154
207
  * Returns a string representation of the scope.
155
208
  */
@@ -162,3 +215,11 @@ export class Scope {
162
215
  )`;
163
216
  }
164
217
  }
218
+
219
+ declare global {
220
+ // for runtime
221
+ // TODO(sam): maybe inject is a better way to achieve this
222
+ var __ALCHEMY_SCOPE__: typeof Scope;
223
+ }
224
+
225
+ globalThis.__ALCHEMY_SCOPE__ = Scope;
package/src/secret.ts CHANGED
@@ -1,5 +1,15 @@
1
1
  import { alchemy } from "./alchemy.js";
2
2
 
3
+ // a global registry of all secrets that we will use when serializing an application
4
+ const globalSecrets: {
5
+ [name: string]: Secret;
6
+ } = {};
7
+
8
+ let i = 0;
9
+ function nextName() {
10
+ return `alchemy:anonymous-secret-${i++}`;
11
+ }
12
+
3
13
  /**
4
14
  * Internal wrapper for sensitive values like API keys and credentials.
5
15
  * When stored in alchemy state files, the value is automatically encrypted
@@ -36,8 +46,20 @@ import { alchemy } from "./alchemy.js";
36
46
  * }
37
47
  */
38
48
  export class Secret {
49
+ /**
50
+ * @internal
51
+ */
52
+ public static all(): Secret[] {
53
+ return Object.values(globalSecrets);
54
+ }
55
+
39
56
  public readonly type = "secret";
40
- constructor(readonly unencrypted: string) {}
57
+ constructor(
58
+ readonly unencrypted: string,
59
+ readonly name: string = nextName(),
60
+ ) {
61
+ globalSecrets[name] = this;
62
+ }
41
63
  }
42
64
 
43
65
  /**
@@ -79,11 +101,14 @@ export function isSecret(binding: any): binding is Secret {
79
101
  * @throws {Error} If the value is undefined
80
102
  * @throws {Error} If no password is set in the alchemy application options or current scope
81
103
  */
82
- export function secret<S extends string | undefined>(unencrypted: S): Secret {
104
+ export function secret<S extends string | undefined>(
105
+ unencrypted: S,
106
+ name?: string,
107
+ ): Secret {
83
108
  if (unencrypted === undefined) {
84
109
  throw new Error("Secret cannot be undefined");
85
110
  }
86
- return new Secret(unencrypted);
111
+ return new Secret(unencrypted, name);
87
112
  }
88
113
 
89
114
  export namespace secret {
@@ -104,7 +129,7 @@ export namespace secret {
104
129
  ): Promise<Secret> {
105
130
  const result = await alchemy.env(name, value, error);
106
131
  if (typeof result === "string") {
107
- return secret(result);
132
+ return secret(result, name);
108
133
  }
109
134
  throw new Error(`Secret environment variable ${name} is not a string`);
110
135
  }
@@ -179,7 +179,7 @@ export const ClientKey = Resource(
179
179
  "sentry::ClientKey",
180
180
  async function (
181
181
  this: Context<ClientKey>,
182
- id: string,
182
+ _id: string,
183
183
  props: ClientKeyProps,
184
184
  ): Promise<ClientKey> {
185
185
  const api = new SentryApi({ authToken: props.authToken });
@@ -281,7 +281,7 @@ export const Project = Resource(
281
281
  "sentry::Project",
282
282
  async function (
283
283
  this: Context<Project>,
284
- id: string,
284
+ _id: string,
285
285
  props: ProjectProps,
286
286
  ): Promise<Project> {
287
287
  const api = new SentryApi({ authToken: props.authToken });
@@ -126,7 +126,7 @@ export const Team = Resource(
126
126
  "sentry::Team",
127
127
  async function (
128
128
  this: Context<Team>,
129
- id: string,
129
+ _id: string,
130
130
  props: TeamProps,
131
131
  ): Promise<Team> {
132
132
  const api = new SentryApi({ authToken: props.authToken });
package/src/serde.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  import { decryptWithKey, encrypt } from "./encrypt.js";
2
+ import {
3
+ InnerResourceScope,
4
+ ResourceFQN,
5
+ ResourceKind,
6
+ type Resource,
7
+ } from "./resource.js";
2
8
  import { Scope } from "./scope.js";
3
9
  import { Secret } from "./secret.js";
4
10
 
@@ -13,13 +19,96 @@ function isType(value: any): value is Type<any, any> {
13
19
  );
14
20
  }
15
21
 
22
+ export type Serialized<T> = T extends
23
+ | undefined
24
+ | null
25
+ | boolean
26
+ | number
27
+ | string
28
+ | bigint
29
+ ? T
30
+ : T extends Type<any, any>
31
+ ? {
32
+ "@schema": string;
33
+ }
34
+ : T extends Secret
35
+ ? {
36
+ "@secret": string;
37
+ }
38
+ : T extends Date
39
+ ? {
40
+ "@date": string;
41
+ }
42
+ : T extends Symbol
43
+ ? {
44
+ "@symbol": string;
45
+ }
46
+ : T extends Scope
47
+ ? {
48
+ "@scope": null;
49
+ }
50
+ : T extends Function
51
+ ? undefined
52
+ : T extends Array<infer U>
53
+ ? Array<Serialized<U>>
54
+ : T extends object
55
+ ? {
56
+ [K in keyof T as K extends symbol
57
+ ? string
58
+ : K]: Serialized<T[K]>;
59
+ }
60
+ : T;
61
+
62
+ export type SerializedScope = {
63
+ [fqn: ResourceFQN]: Serialized<Resource>;
64
+ };
65
+
66
+ export async function serializeScope(scope: Scope): Promise<SerializedScope> {
67
+ const map: SerializedScope = {};
68
+
69
+ return serializeScope(scope);
70
+
71
+ async function serializeScope(scope: Scope): Promise<SerializedScope> {
72
+ await Promise.all(
73
+ Array.from(scope.resources.values()).map(async (resource) => {
74
+ if (resource[ResourceKind] === Scope.KIND) {
75
+ return;
76
+ }
77
+ map[resource[ResourceFQN]] = await serialize(scope, await resource, {
78
+ transform: (value) => {
79
+ if (value instanceof Secret) {
80
+ return {
81
+ "@secret-env": value.name,
82
+ };
83
+ }
84
+ return value;
85
+ },
86
+ });
87
+ const innerScope = await resource[InnerResourceScope];
88
+ if (innerScope) {
89
+ await serializeScope(innerScope);
90
+ }
91
+ }),
92
+ );
93
+ await Promise.all(
94
+ Array.from(scope.children.values()).map((scope) => serializeScope(scope)),
95
+ );
96
+ return map;
97
+ }
98
+ }
99
+
16
100
  export async function serialize(
17
101
  scope: Scope,
18
102
  value: any,
19
103
  options?: {
20
104
  encrypt?: boolean;
105
+ transform?: (value: any) => any;
21
106
  },
22
107
  ): Promise<any> {
108
+ if (options?.transform) {
109
+ value = options.transform(value);
110
+ }
111
+
23
112
  if (Array.isArray(value)) {
24
113
  return Promise.all(value.map((value) => serialize(scope, value, options)));
25
114
  } else if (value instanceof Secret) {
@@ -49,17 +138,19 @@ export async function serialize(
49
138
  return {
50
139
  "@scope": null,
51
140
  };
141
+ } else if (isImportMeta(value)) {
142
+ // ImportMeta serialized as {}, so we are mapping it
143
+ // TODO(sam):
144
+ return Object.fromEntries(
145
+ Object.keys(Object.getPrototypeOf(value))
146
+ // exlcude import.meta.env
147
+ .filter((prop) => prop === "env")
148
+ .map((prop) => [prop, (value as any)[prop]]),
149
+ );
52
150
  } else if (value && typeof value === "object") {
53
151
  for (const symbol of Object.getOwnPropertySymbols(value)) {
54
152
  assertNotUniqueSymbol(symbol);
55
153
  }
56
- for (const key of Object.keys(value)) {
57
- if (parseSymbol(key)) {
58
- throw new Error(
59
- `Cannot serialize property '${key}' because it looks like a stringified symbol.`,
60
- );
61
- }
62
- }
63
154
  return Object.fromEntries(
64
155
  await Promise.all(
65
156
  [...Object.getOwnPropertySymbols(value), ...Object.keys(value)].map(
@@ -77,10 +168,35 @@ export async function serialize(
77
168
  return value;
78
169
  }
79
170
 
80
- export async function deserialize(scope: Scope, value: any): Promise<any> {
171
+ function isImportMeta(value: any): value is ImportMeta {
172
+ return (
173
+ value &&
174
+ typeof value === "object" &&
175
+ typeof value.dirname === "string" &&
176
+ typeof value.filename === "string" &&
177
+ typeof value.url === "string"
178
+ );
179
+ }
180
+
181
+ export async function deserialize(
182
+ scope: Scope,
183
+ value: any,
184
+ options?: {
185
+ transform?: (value: any) =>
186
+ | undefined
187
+ | {
188
+ value: any;
189
+ };
190
+ },
191
+ ): Promise<any> {
192
+ const replacement = options?.transform?.(value);
193
+ if (replacement) {
194
+ return replacement.value;
195
+ }
196
+
81
197
  if (Array.isArray(value)) {
82
198
  return await Promise.all(
83
- value.map(async (item) => await deserialize(scope, item)),
199
+ value.map(async (item) => await deserialize(scope, item, options)),
84
200
  );
85
201
  }
86
202
  if (value && typeof value === "object") {
@@ -103,7 +219,7 @@ export async function deserialize(scope: Scope, value: any): Promise<any> {
103
219
  await Promise.all(
104
220
  Object.entries(value).map(async ([key, value]) => [
105
221
  parseSymbol(key) ?? key,
106
- await deserialize(scope, value),
222
+ await deserialize(scope, value, options),
107
223
  ]),
108
224
  ),
109
225
  );
@@ -141,7 +141,7 @@ export const Meter = Resource(
141
141
  "stripe::Meter",
142
142
  async function (
143
143
  this: Context<Meter>,
144
- logicalId: string,
144
+ _logicalId: string,
145
145
  props: MeterProps,
146
146
  ): Promise<Meter> {
147
147
  const apiKey = process.env.STRIPE_API_KEY;
@@ -192,7 +192,7 @@ export const Price = Resource(
192
192
  "stripe::Price",
193
193
  async function (
194
194
  this: Context<Price>,
195
- id: string,
195
+ _id: string,
196
196
  props: PriceProps,
197
197
  ): Promise<Price> {
198
198
  // Get Stripe API key from context or environment
@@ -141,7 +141,7 @@ export const Product = Resource(
141
141
  "stripe::Product",
142
142
  async function (
143
143
  this: Context<Product>,
144
- id: string,
144
+ _id: string,
145
145
  props: ProductProps,
146
146
  ): Promise<Product> {
147
147
  // Get Stripe API key from context or environment
@@ -135,7 +135,7 @@ export const WebhookEndpoint = Resource(
135
135
  "stripe::WebhookEndpoint",
136
136
  async function (
137
137
  this: Context<WebhookEndpoint>,
138
- id: string,
138
+ _id: string,
139
139
  props: WebhookEndpointProps,
140
140
  ) {
141
141
  // Get Stripe API key from context or environment
package/src/test/bun.ts CHANGED
@@ -132,7 +132,7 @@ export function test(meta: ImportMeta, defaultOptions?: TestOptions): test {
132
132
  test.skipIf = (condition: boolean) => {
133
133
  if (condition) {
134
134
  // TODO: proxy through to bun:test.skipIf
135
- return (...args: any[]) => {};
135
+ return (..._args: any[]) => {};
136
136
  }
137
137
  return test;
138
138
  };
package/src/test/prune.ts CHANGED
@@ -129,7 +129,7 @@ async function getDependencies(testFile: string): Promise<Set<string>> {
129
129
  format: "esm",
130
130
  bundle: true,
131
131
  metafile: true,
132
- external: ["@cloudflare/workers-types", "bun:test"],
132
+ external: ["@cloudflare/workers-types", "bun:test", "@swc/*"],
133
133
  logLevel: "error",
134
134
  });
135
135
 
@@ -156,7 +156,7 @@ export const UpstashRedis = Resource(
156
156
  "upstash::Redis",
157
157
  async function (
158
158
  this: Context<UpstashRedis>,
159
- id: string,
159
+ _id: string,
160
160
  props: UpstashRedisProps,
161
161
  ): Promise<UpstashRedis> {
162
162
  const api = new UpstashApi({
@@ -36,7 +36,6 @@ const mimeTypes: Record<string, string> = {
36
36
  * @param filePath Path to the file
37
37
  * @returns The content type for the file
38
38
  */
39
- export function getContentType(filePath: string): string {
40
- const extension = path.extname(filePath).toLowerCase();
41
- return mimeTypes[extension] || "application/octet-stream";
39
+ export function getContentType(filePath: string): string | undefined {
40
+ return mimeTypes[path.extname(filePath).toLowerCase()];
42
41
  }
package/src/util/retry.ts CHANGED
@@ -22,6 +22,7 @@ export async function withExponentialBackoff<T>(
22
22
  try {
23
23
  return await operation();
24
24
  } catch (error) {
25
+ console.log("error", error);
25
26
  attempt++;
26
27
  if (attempt >= maxAttempts || !isRetryable(error)) {
27
28
  console.warn("Failed after ", attempt, " attempts");
@@ -122,7 +122,7 @@ export const ProjectDomain = Resource(
122
122
  "vercel::ProjectDomain",
123
123
  async function (
124
124
  this: Context<ProjectDomain>,
125
- id: string,
125
+ _id: string,
126
126
  { accessToken, ...props }: ProjectDomainProps & { accessToken?: Secret },
127
127
  ): Promise<ProjectDomain> {
128
128
  switch (this.phase) {
@@ -400,7 +400,7 @@ export const Project = Resource(
400
400
 
401
401
  // 409 Conflict: Can't update name, so remove it from the props
402
402
  // 400 Invalid Request: Should NOT have additional property `environmentVariables`
403
- const { name, environmentVariables, gitRepository, ...rest } = props;
403
+ const { environmentVariables, ...rest } = props;
404
404
  const response = await api.patch(`/projects/${this.output.id}`, rest);
405
405
  const data = (await response.json()) as Project;
406
406
 
@@ -43,7 +43,7 @@ export const ShadcnComponent = Resource(
43
43
  "project::ShadcnComponent",
44
44
  async function (
45
45
  this: Context<ShadcnComponent>,
46
- id: string,
46
+ _id: string,
47
47
  props: ShadcnComponentProps,
48
48
  ): Promise<ShadcnComponent> {
49
49
  if (this.phase === "delete") {
package/src/web/shadcn.ts CHANGED
@@ -120,7 +120,7 @@ export const ShadcnUI = Resource(
120
120
  "project::ShadcnUI",
121
121
  async function (
122
122
  this: Context<ShadcnUI>,
123
- id: string,
123
+ _id: string,
124
124
  props: ShadcnUIProps,
125
125
  ): Promise<ShadcnUI> {
126
126
  if (this.phase === "delete") {
@@ -14,7 +14,7 @@ export const InstallDependencies = Resource(
14
14
  },
15
15
  async function (
16
16
  this: Context<InstallDependencies>,
17
- id: string,
17
+ _id: string,
18
18
  {
19
19
  cwd,
20
20
  dependencies,
@@ -10,7 +10,7 @@ import { StaticTypeScriptFile } from "../../fs/static-typescript-file.js";
10
10
  import { Resource } from "../../resource.js";
11
11
  import { InstallDependencies, fixedDependencies } from "./dependencies.js";
12
12
 
13
- const execAsync = promisify(exec);
13
+ const _execAsync = promisify(exec);
14
14
 
15
15
  export interface VitePressProjectProps {
16
16
  /**