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
@@ -1,11 +1,13 @@
1
1
  import type { Context } from "../context.js";
2
- import { Resource } from "../resource.js";
2
+ import { Resource, ResourceKind } from "../resource.js";
3
+ import { bind } from "../runtime/bind.js";
3
4
  import { CloudflareApiError, handleApiError } from "./api-error.js";
4
5
  import {
5
6
  createCloudflareApi,
6
7
  type CloudflareApi,
7
8
  type CloudflareApiOptions,
8
9
  } from "./api.js";
10
+ import type { Bound } from "./bound.js";
9
11
 
10
12
  /**
11
13
  * Properties for creating or updating a Vectorize Index
@@ -48,10 +50,16 @@ export interface VectorizeIndexProps extends CloudflareApiOptions {
48
50
  adopt?: boolean;
49
51
  }
50
52
 
53
+ export function isVectorizeIndex(
54
+ resource: Resource,
55
+ ): resource is VectorizeIndexResource {
56
+ return resource[ResourceKind] === "cloudflare::VectorizeIndex";
57
+ }
58
+
51
59
  /**
52
60
  * Output returned after Vectorize Index creation/update
53
61
  */
54
- export interface VectorizeIndex
62
+ export interface VectorizeIndexResource
55
63
  extends Resource<"cloudflare::VectorizeIndex">,
56
64
  VectorizeIndexProps {
57
65
  type: "vectorize";
@@ -67,6 +75,9 @@ export interface VectorizeIndex
67
75
  createdAt?: number;
68
76
  }
69
77
 
78
+ export type VectorizeIndex = VectorizeIndexResource &
79
+ Bound<VectorizeIndexResource>;
80
+
70
81
  /**
71
82
  * Creates and manages Cloudflare Vectorize Indexes.
72
83
  *
@@ -106,13 +117,30 @@ export interface VectorizeIndex
106
117
  *
107
118
  * @see https://developers.cloudflare.com/vectorize/
108
119
  */
109
- export const VectorizeIndex = Resource(
120
+ export async function VectorizeIndex(
121
+ name: string,
122
+ props: VectorizeIndexProps,
123
+ ): Promise<VectorizeIndex> {
124
+ const index = await _VectorizeIndex(name, props);
125
+ const binding = await bind(index);
126
+ return {
127
+ ...index,
128
+ describe: binding.describe,
129
+ query: binding.query,
130
+ insert: binding.insert,
131
+ upsert: binding.upsert,
132
+ deleteByIds: binding.deleteByIds,
133
+ getByIds: binding.getByIds,
134
+ };
135
+ }
136
+
137
+ const _VectorizeIndex = Resource(
110
138
  "cloudflare::VectorizeIndex",
111
139
  async function (
112
- this: Context<VectorizeIndex>,
140
+ this: Context<VectorizeIndexResource>,
113
141
  id: string,
114
142
  props: VectorizeIndexProps,
115
- ): Promise<VectorizeIndex> {
143
+ ): Promise<VectorizeIndexResource> {
116
144
  const api = await createCloudflareApi(props);
117
145
  const indexName = props.name || id;
118
146
 
@@ -348,9 +376,9 @@ export async function listIndexes(
348
376
  * This function will always throw an error.
349
377
  */
350
378
  export async function updateIndex(
351
- api: CloudflareApi,
352
- indexName: string,
353
- props: VectorizeIndexProps,
379
+ _api: CloudflareApi,
380
+ _indexName: string,
381
+ _props: VectorizeIndexProps,
354
382
  ): Promise<CloudflareVectorizeResponse> {
355
383
  throw new Error(
356
384
  "Updating Vectorize indexes is not supported by the Cloudflare API. To change an index, delete it and create a new one.",
@@ -1,12 +1,12 @@
1
1
  import type { Context } from "../context.js";
2
- import { Resource } from "../resource.js";
2
+ import { Resource, ResourceKind } from "../resource.js";
3
3
  import { CloudflareApiError, handleApiError } from "./api-error.js";
4
4
  import {
5
5
  createCloudflareApi,
6
6
  type CloudflareApi,
7
7
  type CloudflareApiOptions,
8
8
  } from "./api.js";
9
- import type { VectorizeIndex } from "./vectorize-index.js";
9
+ import type { VectorizeIndexResource } from "./vectorize-index.js";
10
10
 
11
11
  /**
12
12
  * Properties for creating or deleting a Vectorize Metadata Index
@@ -15,7 +15,7 @@ export interface VectorizeMetadataIndexProps extends CloudflareApiOptions {
15
15
  /**
16
16
  * Parent Vectorize Index
17
17
  */
18
- index: VectorizeIndex;
18
+ index: VectorizeIndexResource;
19
19
 
20
20
  /**
21
21
  * Name of the property in the metadata to create an index for
@@ -28,6 +28,12 @@ export interface VectorizeMetadataIndexProps extends CloudflareApiOptions {
28
28
  indexType: "string" | "number" | "boolean";
29
29
  }
30
30
 
31
+ export function isVectorizeMetadataIndex(
32
+ resource: Resource,
33
+ ): resource is VectorizeMetadataIndex {
34
+ return resource[ResourceKind] === "cloudflare::VectorizeMetadataIndex";
35
+ }
36
+
31
37
  /**
32
38
  * Output returned after Vectorize Metadata Index creation/deletion
33
39
  */
@@ -82,7 +88,7 @@ export const VectorizeMetadataIndex = Resource(
82
88
  "cloudflare::VectorizeMetadataIndex",
83
89
  async function (
84
90
  this: Context<VectorizeMetadataIndex>,
85
- id: string,
91
+ _id: string,
86
92
  props: VectorizeMetadataIndexProps,
87
93
  ): Promise<VectorizeMetadataIndex> {
88
94
  const api = await createCloudflareApi(props);
@@ -61,7 +61,7 @@ export type Website<B extends Bindings> = B extends { ASSETS: any }
61
61
 
62
62
  export async function Website<B extends Bindings>(
63
63
  id: string,
64
- props: WebsiteProps<B>
64
+ props: WebsiteProps<B>,
65
65
  ): Promise<Website<B>> {
66
66
  if (props.bindings?.ASSETS) {
67
67
  throw new Error("ASSETS binding is reserved for internal use");
@@ -99,8 +99,8 @@ export async function Website<B extends Bindings>(
99
99
  compatibility_flags: props.compatibilityFlags ?? [],
100
100
  },
101
101
  null,
102
- 2
103
- )
102
+ 2,
103
+ ),
104
104
  );
105
105
  }
106
106
  }
@@ -110,6 +110,7 @@ export async function Website<B extends Bindings>(
110
110
  command: props.command,
111
111
  });
112
112
 
113
+ // @ts-expect-error - the WorkerProps union type not happy
113
114
  const worker = await Worker("worker", {
114
115
  ...props,
115
116
  name: props.name ?? id,
@@ -0,0 +1,237 @@
1
+ import crypto from "node:crypto";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { getContentType } from "../util/content-type.js";
5
+ import type { CloudflareApi } from "./api.js";
6
+ import type { Assets } from "./assets.js";
7
+ import type { AssetsConfig, WorkerProps } from "./worker.js";
8
+
9
+ export interface AssetUploadResult {
10
+ completionToken: string;
11
+ assetConfig?: AssetsConfig;
12
+ }
13
+
14
+ /**
15
+ * Interface for a file's metadata to be uploaded
16
+ */
17
+ interface FileMetadata {
18
+ hash: string;
19
+ size: number;
20
+ }
21
+
22
+ /**
23
+ * Response from the assets upload session API
24
+ */
25
+ interface UploadSessionResponse {
26
+ result: {
27
+ jwt: string;
28
+ buckets: string[][];
29
+ };
30
+ success: boolean;
31
+ errors: any[];
32
+ messages: any[];
33
+ }
34
+
35
+ /**
36
+ * Response from the file upload API
37
+ */
38
+ interface UploadResponse {
39
+ result: {
40
+ jwt: string;
41
+ buckets?: string[][];
42
+ };
43
+ success: boolean;
44
+ errors: any[];
45
+ messages: any[];
46
+ }
47
+
48
+ /**
49
+ * Uploads assets to Cloudflare and returns a completion token
50
+ *
51
+ * @param api CloudflareApi instance
52
+ * @param workerName Name of the worker
53
+ * @param assets Assets resource containing files to upload
54
+ * @param assetConfig Configuration for the assets
55
+ * @returns Completion token for the assets upload
56
+ */
57
+ export async function uploadAssets(
58
+ api: CloudflareApi,
59
+ workerName: string,
60
+ assets: Assets,
61
+ assetConfig?: WorkerProps["assets"],
62
+ ): Promise<AssetUploadResult> {
63
+ // Process the assets configuration once at the beginning
64
+ const processedConfig = createAssetConfig(assetConfig);
65
+
66
+ // Generate the file manifest
67
+ const fileMetadata: Record<string, FileMetadata> = {};
68
+
69
+ // Process each file in the assets
70
+ for (const file of assets.files) {
71
+ const { hash, size } = await calculateFileMetadata(file.filePath);
72
+ // Use the relative path as the key, ensuring it starts with a slash
73
+ const key = file.path.startsWith("/") ? file.path : `/${file.path}`;
74
+ fileMetadata[key] = { hash, size };
75
+ }
76
+
77
+ // Start the upload session
78
+ const uploadSessionUrl = `/accounts/${api.accountId}/workers/scripts/${workerName}/assets-upload-session`;
79
+ const uploadSessionResponse = await api.post(
80
+ uploadSessionUrl,
81
+ JSON.stringify({ manifest: fileMetadata }),
82
+ {
83
+ headers: { "Content-Type": "application/json" },
84
+ },
85
+ );
86
+
87
+ if (!uploadSessionResponse.ok) {
88
+ throw new Error(
89
+ `Failed to start assets upload session: ${uploadSessionResponse.status} ${uploadSessionResponse.statusText}`,
90
+ );
91
+ }
92
+
93
+ const sessionData =
94
+ (await uploadSessionResponse.json()) as UploadSessionResponse;
95
+
96
+ // If there are no buckets, assets are already uploaded or empty
97
+ if (!sessionData.result.buckets || sessionData.result.buckets.length === 0) {
98
+ return {
99
+ completionToken: sessionData.result.jwt,
100
+ assetConfig: processedConfig,
101
+ };
102
+ }
103
+
104
+ // Upload the files in batches as specified by the API
105
+ let completionToken = sessionData.result.jwt;
106
+ const buckets = sessionData.result.buckets;
107
+
108
+ // Process each bucket of files
109
+ for (const bucket of buckets) {
110
+ const formData = new FormData();
111
+
112
+ // Add each file in the bucket to the form
113
+ for (const fileHash of bucket) {
114
+ // Find the file with this hash
115
+ const file = assets.files.find((f) => {
116
+ const filePath = f.path.startsWith("/") ? f.path : `/${f.path}`;
117
+ return fileMetadata[filePath]?.hash === fileHash;
118
+ });
119
+
120
+ if (!file) {
121
+ throw new Error(`Could not find file with hash ${fileHash}`);
122
+ }
123
+
124
+ // Read the file content
125
+ const fileContent = await fs.readFile(file.filePath);
126
+
127
+ // Convert to base64 as required by the API when using base64=true
128
+ const base64Content = fileContent.toString("base64");
129
+
130
+ // Add the file to the form with the hash as the key and set the correct content type
131
+ const blob = new Blob([base64Content], {
132
+ // if you set application/octet-stream, you get weird `-1` errors with a message to contact support
133
+ type: getContentType(file.filePath) ?? "application/null",
134
+ });
135
+ formData.append(fileHash, blob, fileHash);
136
+ }
137
+
138
+ // Upload this batch of files
139
+ const uploadResponse = await api.post(
140
+ `/accounts/${api.accountId}/workers/assets/upload?base64=true`,
141
+ formData,
142
+ {
143
+ headers: {
144
+ Authorization: `Bearer ${completionToken}`,
145
+ "Content-Type": "multipart/form-data",
146
+ },
147
+ },
148
+ );
149
+
150
+ if (!uploadResponse.ok) {
151
+ throw new Error(
152
+ `Failed to upload asset files: ${uploadResponse.status} ${uploadResponse.statusText}`,
153
+ );
154
+ }
155
+
156
+ const uploadData = (await uploadResponse.json()) as UploadResponse;
157
+ if (!uploadData.success) {
158
+ const error = uploadData.errors[0];
159
+ const message = error.message;
160
+ const code = error.code;
161
+ throw new Error(
162
+ `Failed to upload asset files: ${message} (Code: ${code})`,
163
+ );
164
+ }
165
+
166
+ // Update the completion token for the next batch
167
+ if (uploadData.result.jwt) {
168
+ completionToken = uploadData.result.jwt;
169
+ }
170
+ }
171
+
172
+ // Return the final completion token with asset configuration
173
+ return {
174
+ completionToken,
175
+ assetConfig: processedConfig,
176
+ };
177
+ }
178
+
179
+ /**
180
+ * Creates asset configuration object from provided config or defaults
181
+ */
182
+ export function createAssetConfig(config?: AssetsConfig): AssetsConfig {
183
+ const assetConfig: AssetsConfig = {
184
+ html_handling: "auto-trailing-slash",
185
+ };
186
+
187
+ if (config) {
188
+ if (config._headers !== undefined) {
189
+ assetConfig._headers = config._headers;
190
+ }
191
+
192
+ if (config._redirects !== undefined) {
193
+ assetConfig._redirects = config._redirects;
194
+ }
195
+
196
+ if (config.html_handling !== undefined) {
197
+ assetConfig.html_handling = config.html_handling;
198
+ }
199
+
200
+ if (config.not_found_handling !== undefined) {
201
+ assetConfig.not_found_handling = config.not_found_handling;
202
+ }
203
+
204
+ if (config.run_worker_first !== undefined) {
205
+ assetConfig.run_worker_first = config.run_worker_first;
206
+ }
207
+
208
+ if (config.serve_directly !== undefined) {
209
+ assetConfig.serve_directly = config.serve_directly;
210
+ }
211
+ }
212
+
213
+ return assetConfig;
214
+ }
215
+
216
+ /**
217
+ * Calculate the SHA-256 hash and size of a file
218
+ *
219
+ * @param filePath Path to the file
220
+ * @returns Hash (first 32 chars of SHA-256) and size of the file
221
+ */
222
+ export async function calculateFileMetadata(
223
+ filePath: string,
224
+ ): Promise<{ hash: string; size: number }> {
225
+ const contents = await fs.readFile(filePath);
226
+
227
+ const hash = crypto.createHash("sha256");
228
+ hash.update(contents);
229
+
230
+ const extension = path.extname(filePath).substring(1);
231
+ hash.update(extension);
232
+
233
+ return {
234
+ hash: hash.digest("hex").slice(0, 32),
235
+ size: contents.length,
236
+ };
237
+ }
@@ -1,3 +1,12 @@
1
+ import type { Context } from "../context.js";
2
+ import { slugify } from "../util/slugify.js";
3
+ import { Self, type Bindings, type WorkerBindingSpec } from "./bindings.js";
4
+ import type { DurableObjectNamespace } from "./durable-object-namespace.js";
5
+ import { createAssetConfig, type AssetUploadResult } from "./worker-assets.js";
6
+ import type { SingleStepMigration } from "./worker-migration.js";
7
+ import type { AssetsConfig, Worker, WorkerProps } from "./worker.js";
8
+ import type { Workflow } from "./workflow.js";
9
+
1
10
  /**
2
11
  * Metadata returned by Cloudflare API for a worker script
3
12
  */
@@ -152,3 +161,281 @@ export interface WorkerDefaultEnvironment extends WorkerEnvironment {
152
161
  */
153
162
  script: WorkerScriptInfo;
154
163
  }
164
+
165
+ export interface WorkerMetadata {
166
+ compatibility_date: string;
167
+ compatibility_flags?: string[];
168
+ bindings: WorkerBindingSpec[];
169
+ observability: {
170
+ enabled: boolean;
171
+ };
172
+ migrations?: SingleStepMigration;
173
+ main_module?: string;
174
+ body_part?: string;
175
+ tags?: string[];
176
+ assets?: {
177
+ jwt?: string;
178
+ keep_assets?: boolean;
179
+ config?: AssetsConfig;
180
+ };
181
+ cron_triggers?: {
182
+ cron: string;
183
+ suspended: boolean;
184
+ }[];
185
+ }
186
+
187
+ export async function prepareWorkerMetadata<B extends Bindings>(
188
+ ctx: Context<Worker<B>>,
189
+ oldBindings: Bindings | undefined,
190
+ props: WorkerProps & {
191
+ compatibilityDate: string;
192
+ compatibilityFlags: string[];
193
+ workerName: string;
194
+ },
195
+ assetUploadResult?: AssetUploadResult,
196
+ ): Promise<WorkerMetadata> {
197
+ const deletedClasses = Object.entries(oldBindings ?? {})
198
+ .filter(([key]) => !props.bindings?.[key])
199
+ .flatMap(([_, binding]) => {
200
+ if (
201
+ binding &&
202
+ typeof binding === "object" &&
203
+ binding.type === "durable_object_namespace"
204
+ ) {
205
+ return [binding.className];
206
+ }
207
+ return [];
208
+ });
209
+
210
+ // Prepare metadata with bindings
211
+ const meta: WorkerMetadata = {
212
+ compatibility_date: props.compatibilityDate,
213
+ compatibility_flags: props.compatibilityFlags,
214
+ bindings: [],
215
+ observability: {
216
+ enabled: props.observability?.enabled !== false,
217
+ },
218
+ // TODO(sam): base64 encode instead? 0 collision risk vs readability.
219
+ tags: [`alchemy:id:${slugify(ctx.fqn)}`],
220
+ migrations: {
221
+ new_classes: props.migrations?.new_classes ?? [],
222
+ deleted_classes: [
223
+ ...deletedClasses,
224
+ ...(props.migrations?.deleted_classes ?? []),
225
+ ],
226
+ renamed_classes: props.migrations?.renamed_classes ?? [],
227
+ transferred_classes: props.migrations?.transferred_classes ?? [],
228
+ new_sqlite_classes: props.migrations?.new_sqlite_classes ?? [],
229
+ },
230
+ };
231
+
232
+ // If we have asset upload results, add them to the metadata
233
+ if (assetUploadResult) {
234
+ meta.assets = {
235
+ jwt: assetUploadResult.completionToken,
236
+ };
237
+
238
+ // Initialize config from assetUploadResult if it exists
239
+ if (assetUploadResult.assetConfig) {
240
+ meta.assets.config = {
241
+ ...assetUploadResult.assetConfig,
242
+ };
243
+ }
244
+
245
+ // If there's no config from assetUploadResult but we have props.assets,
246
+ // we need to create the config ourselves (this handles the case when no assets were uploaded)
247
+ if (!meta.assets.config && props.assets) {
248
+ meta.assets.config = createAssetConfig(props.assets);
249
+ }
250
+ }
251
+
252
+ const bindings = (props.bindings ?? {}) as Bindings;
253
+
254
+ // Convert bindings to the format expected by the API
255
+ for (const [bindingName, binding] of Object.entries(bindings)) {
256
+ // Create a copy of the binding to avoid modifying the original
257
+
258
+ if (typeof binding === "string") {
259
+ meta.bindings.push({
260
+ type: "plain_text",
261
+ name: bindingName,
262
+ text: binding,
263
+ });
264
+ } else if (binding === Self) {
265
+ meta.bindings.push({
266
+ type: "service",
267
+ name: bindingName,
268
+ service: props.workerName,
269
+ });
270
+ } else if (binding.type === "d1") {
271
+ meta.bindings.push({
272
+ type: "d1",
273
+ name: bindingName,
274
+ id: binding.id,
275
+ });
276
+ } else if (binding.type === "kv_namespace") {
277
+ meta.bindings.push({
278
+ type: "kv_namespace",
279
+ name: bindingName,
280
+ namespace_id:
281
+ "namespaceId" in binding ? binding.namespaceId : binding.id,
282
+ });
283
+ } else if (binding.type === "service") {
284
+ meta.bindings.push({
285
+ type: "service",
286
+ name: bindingName,
287
+ service: binding.name,
288
+ });
289
+ } else if (binding.type === "durable_object_namespace") {
290
+ meta.bindings.push({
291
+ type: "durable_object_namespace",
292
+ name: bindingName,
293
+ class_name: binding.className,
294
+ script_name: binding.scriptName,
295
+ environment: binding.environment,
296
+ namespace_id: binding.namespaceId,
297
+ });
298
+ configureClassMigration(binding, binding.id, binding.className);
299
+ } else if (binding.type === "r2_bucket") {
300
+ meta.bindings.push({
301
+ type: "r2_bucket",
302
+ name: bindingName,
303
+ bucket_name: binding.name,
304
+ });
305
+ } else if (binding.type === "assets") {
306
+ meta.bindings.push({
307
+ type: "assets",
308
+ name: bindingName,
309
+ });
310
+ } else if (binding.type === "secret") {
311
+ meta.bindings.push({
312
+ type: "secret_text",
313
+ name: bindingName,
314
+ text: binding.unencrypted,
315
+ });
316
+ } else if (binding.type === "workflow") {
317
+ meta.bindings.push({
318
+ type: "workflow",
319
+ name: bindingName,
320
+ workflow_name: binding.workflowName,
321
+ class_name: binding.className,
322
+ // this should be set if the Workflow is in another script ...
323
+ // script_name: ??,
324
+ });
325
+ // it's unclear whether this is needed, but it works both ways
326
+ // configureClassMigration(binding, binding.id, binding.className);
327
+ } else if (binding.type === "queue") {
328
+ meta.bindings.push({
329
+ type: "queue",
330
+ name: bindingName,
331
+ queue_name: binding.name,
332
+ });
333
+ } else if (binding.type === "pipeline") {
334
+ meta.bindings.push({
335
+ type: "pipelines",
336
+ name: bindingName,
337
+ pipeline: binding.name,
338
+ });
339
+ } else if (binding.type === "vectorize") {
340
+ meta.bindings.push({
341
+ type: "vectorize",
342
+ name: bindingName,
343
+ index_name: binding.name,
344
+ });
345
+ } else if (binding.type === "ai_gateway") {
346
+ // AI Gateway binding - just needs the name property
347
+ meta.bindings.push({
348
+ type: "ai",
349
+ name: bindingName,
350
+ });
351
+ } else if (binding.type === "hyperdrive") {
352
+ // Hyperdrive binding
353
+ meta.bindings.push({
354
+ type: "hyperdrive",
355
+ name: bindingName,
356
+ id: binding.hyperdriveId,
357
+ });
358
+ } else if (binding.type === "browser") {
359
+ meta.bindings.push({
360
+ type: "browser",
361
+ name: bindingName,
362
+ });
363
+ } else if (binding.type === "ai") {
364
+ meta.bindings.push({
365
+ type: "ai",
366
+ name: bindingName,
367
+ });
368
+ } else if (binding.type === "json") {
369
+ meta.bindings.push({
370
+ type: "json",
371
+ name: bindingName,
372
+ json: JSON.stringify(binding.json),
373
+ });
374
+ } else if (binding.type === "analytics_engine") {
375
+ meta.bindings.push({
376
+ type: "analytics_engine",
377
+ name: bindingName,
378
+ dataset: binding.dataset,
379
+ });
380
+ } else {
381
+ // @ts-expect-error - we should never reach here
382
+ throw new Error(`Unsupported binding type: ${binding.type}`);
383
+ }
384
+ }
385
+
386
+ function configureClassMigration(
387
+ binding: DurableObjectNamespace | Workflow,
388
+ stableId: string,
389
+ className: string,
390
+ ) {
391
+ const oldBinding: DurableObjectNamespace | Workflow | undefined =
392
+ Object.values(oldBindings ?? {})
393
+ ?.filter(
394
+ (b) =>
395
+ typeof b === "object" &&
396
+ (b.type === "durable_object_namespace" || b.type === "workflow"),
397
+ )
398
+ ?.find((b) => b.id === stableId);
399
+
400
+ if (!oldBinding) {
401
+ if (binding.type === "durable_object_namespace" && binding.sqlite) {
402
+ meta.migrations!.new_sqlite_classes!.push(className);
403
+ } else {
404
+ meta.migrations!.new_classes!.push(className);
405
+ }
406
+ } else if (oldBinding.className !== className) {
407
+ meta.migrations!.renamed_classes!.push({
408
+ from: oldBinding.className,
409
+ to: className,
410
+ });
411
+ }
412
+ }
413
+
414
+ // Convert env variables to plain_text bindings
415
+ // TODO(sam): remove Worker.env in favor of always bindings
416
+ if (props.env) {
417
+ for (const [key, value] of Object.entries(props.env)) {
418
+ meta.bindings.push({
419
+ name: key,
420
+ type: "plain_text",
421
+ text: value,
422
+ });
423
+ }
424
+ }
425
+
426
+ // Determine if we're using ESM or service worker format
427
+ const isEsModule = props.format !== "cjs"; // Default to ESM unless CJS is specified
428
+ const scriptName = isEsModule ? "worker.js" : "script";
429
+
430
+ if (isEsModule) {
431
+ // For ES modules format
432
+ meta.main_module = scriptName;
433
+ } else {
434
+ // For service worker format (CJS)
435
+ meta.body_part = scriptName;
436
+ }
437
+ if (process.env.DEBUG) {
438
+ console.log(meta);
439
+ }
440
+ return meta;
441
+ }