devflare 1.0.0-next.19 → 1.0.0-next.20

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 (360) hide show
  1. package/LLM.md +6807 -888
  2. package/README.md +375 -957
  3. package/dist/account-05zgta47.js +475 -0
  4. package/dist/account-b2ag1esh.js +475 -0
  5. package/dist/account-bxtcz61a.js +475 -0
  6. package/dist/account-gyfqg964.js +475 -0
  7. package/dist/account-q6pvs9d9.js +475 -0
  8. package/dist/account-rp4zbvw1.js +475 -0
  9. package/dist/bridge/client.d.ts +5 -0
  10. package/dist/bridge/client.d.ts.map +1 -1
  11. package/dist/bridge/gateway-runtime.d.ts +1 -1
  12. package/dist/bridge/gateway-runtime.d.ts.map +1 -1
  13. package/dist/bridge/miniflare.d.ts +67 -0
  14. package/dist/bridge/miniflare.d.ts.map +1 -1
  15. package/dist/bridge/proxy.d.ts +2 -1
  16. package/dist/bridge/proxy.d.ts.map +1 -1
  17. package/dist/bridge/server.d.ts.map +1 -1
  18. package/dist/browser.d.ts +2520 -40
  19. package/dist/browser.d.ts.map +1 -1
  20. package/dist/browser.js +3 -3
  21. package/dist/build-2s5paw5p.js +54 -0
  22. package/dist/build-4c350cp7.js +54 -0
  23. package/dist/build-e7wym63t.js +54 -0
  24. package/dist/build-ge6qp3t4.js +54 -0
  25. package/dist/build-ta8c6t11.js +54 -0
  26. package/dist/build-wvjj8f28.js +54 -0
  27. package/dist/build-ypg6f2kw.js +54 -0
  28. package/dist/build-yts8wwgf.js +54 -0
  29. package/dist/build-yzkdqexs.js +54 -0
  30. package/dist/cli/build-manifest.d.ts +12 -0
  31. package/dist/cli/build-manifest.d.ts.map +1 -1
  32. package/dist/cli/commands/deploy/metadata.d.ts +18 -0
  33. package/dist/cli/commands/deploy/metadata.d.ts.map +1 -0
  34. package/dist/cli/commands/deploy/prepare.d.ts +23 -0
  35. package/dist/cli/commands/deploy/prepare.d.ts.map +1 -0
  36. package/dist/cli/commands/deploy/runtime.d.ts +4 -0
  37. package/dist/cli/commands/deploy/runtime.d.ts.map +1 -0
  38. package/dist/cli/commands/deploy/verification.d.ts +36 -0
  39. package/dist/cli/commands/deploy/verification.d.ts.map +1 -0
  40. package/dist/cli/commands/deploy.d.ts +2 -2
  41. package/dist/cli/commands/deploy.d.ts.map +1 -1
  42. package/dist/cli/commands/secrets.d.ts +4 -0
  43. package/dist/cli/commands/secrets.d.ts.map +1 -0
  44. package/dist/cli/commands/type-generation/generator.d.ts +67 -1
  45. package/dist/cli/commands/type-generation/generator.d.ts.map +1 -1
  46. package/dist/cli/help-pages/pages/core.d.ts +1 -1
  47. package/dist/cli/help-pages/pages/core.d.ts.map +1 -1
  48. package/dist/cli/help-pages/shared.d.ts +1 -1
  49. package/dist/cli/help-pages/shared.d.ts.map +1 -1
  50. package/dist/cli/index.d.ts.map +1 -1
  51. package/dist/cli/index.js +2 -2
  52. package/dist/cli/package-metadata.d.ts.map +1 -1
  53. package/dist/cli/preview-bindings.d.ts.map +1 -1
  54. package/dist/cloudflare/index.js +2 -2
  55. package/dist/cloudflare/preview-registry-store.d.ts +1 -1
  56. package/dist/cloudflare/preview-registry-store.d.ts.map +1 -1
  57. package/dist/cloudflare/types.d.ts +1 -1
  58. package/dist/cloudflare/types.d.ts.map +1 -1
  59. package/dist/config/binding-resolution-helpers.d.ts +5 -0
  60. package/dist/config/binding-resolution-helpers.d.ts.map +1 -1
  61. package/dist/config/compiler/bindings.d.ts +14 -0
  62. package/dist/config/compiler/bindings.d.ts.map +1 -0
  63. package/dist/config/compiler/core-helpers.d.ts +6 -0
  64. package/dist/config/compiler/core-helpers.d.ts.map +1 -0
  65. package/dist/config/compiler/do-workers.d.ts +34 -0
  66. package/dist/config/compiler/do-workers.d.ts.map +1 -0
  67. package/dist/config/compiler/paths.d.ts +18 -0
  68. package/dist/config/compiler/paths.d.ts.map +1 -0
  69. package/dist/config/compiler/types.d.ts +267 -0
  70. package/dist/config/compiler/types.d.ts.map +1 -0
  71. package/dist/config/compiler.d.ts +11 -175
  72. package/dist/config/compiler.d.ts.map +1 -1
  73. package/dist/config/deploy-resources.d.ts.map +1 -1
  74. package/dist/config/index.d.ts +1 -1
  75. package/dist/config/index.d.ts.map +1 -1
  76. package/dist/config/local-dev-vars.d.ts +15 -0
  77. package/dist/config/local-dev-vars.d.ts.map +1 -0
  78. package/dist/config/preview-resources.d.ts.map +1 -1
  79. package/dist/config/preview.d.ts.map +1 -1
  80. package/dist/config/resolve.d.ts.map +1 -1
  81. package/dist/config/resource-resolution.d.ts.map +1 -1
  82. package/dist/config/schema-bindings.d.ts +559 -19
  83. package/dist/config/schema-bindings.d.ts.map +1 -1
  84. package/dist/config/schema-env.d.ts +1306 -34
  85. package/dist/config/schema-env.d.ts.map +1 -1
  86. package/dist/config/schema-normalization.d.ts +97 -1
  87. package/dist/config/schema-normalization.d.ts.map +1 -1
  88. package/dist/config/schema-runtime.d.ts +245 -7
  89. package/dist/config/schema-runtime.d.ts.map +1 -1
  90. package/dist/config/schema.d.ts +2976 -57
  91. package/dist/config/schema.d.ts.map +1 -1
  92. package/dist/config-6m0n7d84.js +59 -0
  93. package/dist/config-7cf004ag.js +59 -0
  94. package/dist/config-b98dp58n.js +59 -0
  95. package/dist/config-cf3djhqy.js +59 -0
  96. package/dist/config-entry.js +1 -1
  97. package/dist/config-wa7hm0w9.js +59 -0
  98. package/dist/deploy-1jfagtn9.js +1055 -0
  99. package/dist/deploy-2afw0jfg.js +1055 -0
  100. package/dist/deploy-2fzj68kq.js +1055 -0
  101. package/dist/deploy-57nzn9wj.js +1045 -0
  102. package/dist/deploy-asyryrvm.js +1055 -0
  103. package/dist/deploy-hc927rw6.js +1045 -0
  104. package/dist/deploy-pnnf8tgy.js +1045 -0
  105. package/dist/deploy-q33bw715.js +1055 -0
  106. package/dist/deploy-tmdgecs3.js +1055 -0
  107. package/dist/deploy-v0y8kczr.js +1055 -0
  108. package/dist/deploy-xhj6zbcx.js +1055 -0
  109. package/dist/dev-1mvcts8w.js +2515 -0
  110. package/dist/dev-2a283xts.js +2515 -0
  111. package/dist/dev-62nhytf8.js +2505 -0
  112. package/dist/dev-75acm2xj.js +2478 -0
  113. package/dist/dev-802rg9dp.js +2515 -0
  114. package/dist/dev-d1bb2t0f.js +2515 -0
  115. package/dist/dev-dwry8494.js +2489 -0
  116. package/dist/dev-g6112y4w.js +2515 -0
  117. package/dist/dev-h2kneh95.js +2496 -0
  118. package/dist/dev-kybq3mwr.js +2489 -0
  119. package/dist/dev-n8qndkyg.js +2512 -0
  120. package/dist/dev-p32fkbwf.js +2489 -0
  121. package/dist/dev-qm9d4mfh.js +2478 -0
  122. package/dist/dev-rcthnse5.js +2473 -0
  123. package/dist/dev-server/dev-server-state.d.ts +1 -0
  124. package/dist/dev-server/dev-server-state.d.ts.map +1 -1
  125. package/dist/dev-server/miniflare-bindings.d.ts +44 -1
  126. package/dist/dev-server/miniflare-bindings.d.ts.map +1 -1
  127. package/dist/dev-server/miniflare-dev-config.d.ts +1 -0
  128. package/dist/dev-server/miniflare-dev-config.d.ts.map +1 -1
  129. package/dist/dev-server/miniflare-log.d.ts +8 -0
  130. package/dist/dev-server/miniflare-log.d.ts.map +1 -1
  131. package/dist/dev-server/miniflare-worker-config.d.ts +31 -1
  132. package/dist/dev-server/miniflare-worker-config.d.ts.map +1 -1
  133. package/dist/dev-server/server.d.ts.map +1 -1
  134. package/dist/dev-server/vite-process.d.ts +1 -0
  135. package/dist/dev-server/vite-process.d.ts.map +1 -1
  136. package/dist/dev-tgwja5mz.js +2496 -0
  137. package/dist/doctor-2shhdak6.js +245 -0
  138. package/dist/doctor-5g73w40j.js +245 -0
  139. package/dist/doctor-gamefzcs.js +245 -0
  140. package/dist/doctor-rn53ctfs.js +245 -0
  141. package/dist/index-01kehw41.js +348 -0
  142. package/dist/index-06bg0z9y.js +185 -0
  143. package/dist/index-0d7tw5r4.js +136 -0
  144. package/dist/index-0m6e4mxz.js +133 -0
  145. package/dist/index-0vah20er.js +1410 -0
  146. package/dist/index-0wa0ebm1.js +68 -0
  147. package/dist/index-1714y3cz.js +1410 -0
  148. package/dist/index-1qs5gcm7.js +895 -0
  149. package/dist/index-29k04v43.js +574 -0
  150. package/dist/index-2jywf4pz.js +1372 -0
  151. package/dist/index-2qhk9nbx.js +1372 -0
  152. package/dist/index-2vq6bveq.js +574 -0
  153. package/dist/index-36h8gkhb.js +1088 -0
  154. package/dist/index-38fq7pww.js +560 -0
  155. package/dist/index-3bxqn033.js +1410 -0
  156. package/dist/index-3jme4hgw.js +1234 -0
  157. package/dist/index-3p7s9mk9.js +360 -0
  158. package/dist/index-47w35sft.js +244 -0
  159. package/dist/index-4by4c7rm.js +52 -0
  160. package/dist/index-4phjwd6h.js +412 -0
  161. package/dist/index-4z5jrw0j.js +594 -0
  162. package/dist/index-51mzqy0d.js +895 -0
  163. package/dist/index-53pqqpq9.js +74 -0
  164. package/dist/index-5enq8ntr.js +1766 -0
  165. package/dist/index-5fnq9r9m.js +1410 -0
  166. package/dist/index-5w9f2b17.js +695 -0
  167. package/dist/index-627srx16.js +45 -0
  168. package/dist/index-6bqgf5x8.js +227 -0
  169. package/dist/index-6xknvbyk.js +1088 -0
  170. package/dist/index-7ef3ktz5.js +1372 -0
  171. package/dist/index-7hpjfdzh.js +185 -0
  172. package/dist/index-8052df4m.js +627 -0
  173. package/dist/index-82epjzrr.js +1410 -0
  174. package/dist/index-82z7rvz6.js +1238 -0
  175. package/dist/index-8atc1yb9.js +68 -0
  176. package/dist/index-8tj0awnv.js +476 -0
  177. package/dist/index-8x745h59.js +1069 -0
  178. package/dist/index-9bawzcny.js +574 -0
  179. package/dist/index-9bjjqdfc.js +236 -0
  180. package/dist/index-9d7x3vfr.js +236 -0
  181. package/dist/index-9nf8zs4p.js +1069 -0
  182. package/dist/index-acwbmagz.js +412 -0
  183. package/dist/index-aqjdaem7.js +74 -0
  184. package/dist/index-b6448fd0.js +133 -0
  185. package/dist/index-b9j55r7q.js +240 -0
  186. package/dist/index-bdatd1za.js +1372 -0
  187. package/dist/index-c3nxftnp.js +699 -0
  188. package/dist/index-c643s0gv.js +488 -0
  189. package/dist/index-d2md1j3d.js +185 -0
  190. package/dist/index-dbr6bfz6.js +528 -0
  191. package/dist/index-dd1g0g7e.js +360 -0
  192. package/dist/index-dktb9az5.js +1372 -0
  193. package/dist/index-dm9q84c7.js +360 -0
  194. package/dist/index-f51mkh13.js +1088 -0
  195. package/dist/index-f86n1fpd.js +55 -0
  196. package/dist/index-fnk0tkw7.js +412 -0
  197. package/dist/index-g5aq66bj.js +1534 -0
  198. package/dist/index-gj5qh491.js +54 -0
  199. package/dist/index-gq39t0rx.js +895 -0
  200. package/dist/index-h5dqna7q.js +1410 -0
  201. package/dist/index-hjs9j2g9.js +895 -0
  202. package/dist/index-hn5nbxbt.js +147 -0
  203. package/dist/index-hpjh0qjx.js +1723 -0
  204. package/dist/index-hs6ekcfs.js +412 -0
  205. package/dist/index-jdzrvnfj.js +52 -0
  206. package/dist/index-jg720mq7.js +476 -0
  207. package/dist/index-jrzddxvt.js +2167 -0
  208. package/dist/index-kgstnk6g.js +239 -0
  209. package/dist/index-khnw972v.js +117 -0
  210. package/dist/index-kwqff3ba.js +1410 -0
  211. package/dist/index-m2v0fj08.js +74 -0
  212. package/dist/index-mjve6tqn.js +447 -0
  213. package/dist/index-mkxzgn0q.js +1372 -0
  214. package/dist/index-mzmq3v0d.js +1088 -0
  215. package/dist/index-ng9n3znd.js +1372 -0
  216. package/dist/index-nhbkm2ba.js +467 -0
  217. package/dist/index-nrfhk0k5.js +1088 -0
  218. package/dist/index-p0zppqxm.js +467 -0
  219. package/dist/index-pkxf6h87.js +895 -0
  220. package/dist/index-pqp4312v.js +52 -0
  221. package/dist/index-pw9jn6kz.js +574 -0
  222. package/dist/index-q31ne0xa.js +412 -0
  223. package/dist/index-qf2dkqxh.js +249 -0
  224. package/dist/index-qmtdf7k5.js +639 -0
  225. package/dist/index-qwgr4q7s.js +37 -0
  226. package/dist/index-rab2dfh3.js +494 -0
  227. package/dist/index-rz7rx80s.js +1410 -0
  228. package/dist/index-s37h3jgk.js +572 -0
  229. package/dist/index-sb705m7d.js +52 -0
  230. package/dist/index-syscwrjp.js +1576 -0
  231. package/dist/index-t14zr0ys.js +1063 -0
  232. package/dist/index-tjc99447.js +68 -0
  233. package/dist/index-v35460hf.js +574 -0
  234. package/dist/index-v7q00d1e.js +1410 -0
  235. package/dist/index-vkkmx4xe.js +1372 -0
  236. package/dist/index-vrps1gky.js +2202 -0
  237. package/dist/index-w4c9vmvg.js +1517 -0
  238. package/dist/index-wqd8n2qk.js +574 -0
  239. package/dist/index-x12e6fzy.js +476 -0
  240. package/dist/index-xagpz645.js +2199 -0
  241. package/dist/index-xbth1r6e.js +572 -0
  242. package/dist/index-xm9fqhcb.js +447 -0
  243. package/dist/index-y59hnmd0.js +132 -0
  244. package/dist/index-y7mkb00x.js +133 -0
  245. package/dist/index-z40mjts9.js +212 -0
  246. package/dist/index-z5k5bjc7.js +1218 -0
  247. package/dist/index-z73sytma.js +895 -0
  248. package/dist/index-zjv6apef.js +1410 -0
  249. package/dist/index.js +8 -8
  250. package/dist/init-cwpergap.js +180 -0
  251. package/dist/login-83bjfhvz.js +77 -0
  252. package/dist/login-ddw888xb.js +77 -0
  253. package/dist/login-e7pytkdc.js +77 -0
  254. package/dist/login-fe0brfcr.js +77 -0
  255. package/dist/login-h7sm5trm.js +77 -0
  256. package/dist/login-vd0m3xr4.js +77 -0
  257. package/dist/previews-2wfvsjfy.js +1337 -0
  258. package/dist/previews-31feb8r3.js +1337 -0
  259. package/dist/previews-3w4pxqby.js +1337 -0
  260. package/dist/previews-93ttrf5f.js +1337 -0
  261. package/dist/previews-bdrefjzx.js +1337 -0
  262. package/dist/previews-cfcn56b4.js +1337 -0
  263. package/dist/previews-mssq1hrm.js +1337 -0
  264. package/dist/previews-tcaz1gt8.js +1337 -0
  265. package/dist/productions-4h80j2c7.js +505 -0
  266. package/dist/productions-86jaqt7m.js +505 -0
  267. package/dist/productions-bn2q31my.js +505 -0
  268. package/dist/productions-dv8g7f6g.js +505 -0
  269. package/dist/productions-e2m9s4tr.js +505 -0
  270. package/dist/productions-fgshs1m7.js +505 -0
  271. package/dist/productions-hphmt68n.js +505 -0
  272. package/dist/productions-vhq7yx86.js +505 -0
  273. package/dist/runtime/index.js +8 -8
  274. package/dist/secrets/local-secrets.d.ts +46 -0
  275. package/dist/secrets/local-secrets.d.ts.map +1 -0
  276. package/dist/secrets-8wcj47nh.js +91 -0
  277. package/dist/secrets-b2ww34ta.js +91 -0
  278. package/dist/secrets-b7g4z621.js +91 -0
  279. package/dist/shims/local-media-bindings.d.ts +19 -0
  280. package/dist/shims/local-media-bindings.d.ts.map +1 -0
  281. package/dist/shims/local-worker-loader.d.ts +3 -0
  282. package/dist/shims/local-worker-loader.d.ts.map +1 -0
  283. package/dist/sveltekit/index.js +163 -26
  284. package/dist/sveltekit/local-bindings.d.ts +4 -0
  285. package/dist/sveltekit/local-bindings.d.ts.map +1 -0
  286. package/dist/sveltekit/platform.d.ts +8 -0
  287. package/dist/sveltekit/platform.d.ts.map +1 -1
  288. package/dist/test/ai-search.d.ts +39 -0
  289. package/dist/test/ai-search.d.ts.map +1 -0
  290. package/dist/test/binding-hints.d.ts.map +1 -1
  291. package/dist/test/cf.d.ts +3 -3
  292. package/dist/test/containers.d.ts +87 -0
  293. package/dist/test/containers.d.ts.map +1 -0
  294. package/dist/test/index.d.ts +4 -1
  295. package/dist/test/index.d.ts.map +1 -1
  296. package/dist/test/index.js +2833 -543
  297. package/dist/test/local-worker-loader.d.ts +3 -0
  298. package/dist/test/local-worker-loader.d.ts.map +1 -0
  299. package/dist/test/offline-bindings.d.ts +65 -0
  300. package/dist/test/offline-bindings.d.ts.map +1 -0
  301. package/dist/test/queue.d.ts.map +1 -1
  302. package/dist/test/remote-ai.d.ts.map +1 -1
  303. package/dist/test/should-skip.d.ts +14 -0
  304. package/dist/test/should-skip.d.ts.map +1 -1
  305. package/dist/test/simple-context-bindings.d.ts.map +1 -1
  306. package/dist/test/simple-context-durable-objects.d.ts.map +1 -1
  307. package/dist/test/simple-context-gateway-script.d.ts +1 -1
  308. package/dist/test/simple-context-gateway-script.d.ts.map +1 -1
  309. package/dist/test/simple-context-lifecycle.d.ts.map +1 -1
  310. package/dist/test/simple-context-mfconfig.d.ts +4 -1
  311. package/dist/test/simple-context-mfconfig.d.ts.map +1 -1
  312. package/dist/test/simple-context-multi-worker.d.ts.map +1 -1
  313. package/dist/test/simple-context-startup.d.ts.map +1 -1
  314. package/dist/test/tail.d.ts.map +1 -1
  315. package/dist/test/utilities/artifacts.d.ts +11 -0
  316. package/dist/test/utilities/artifacts.d.ts.map +1 -0
  317. package/dist/test/utilities/context.d.ts +39 -0
  318. package/dist/test/utilities/context.d.ts.map +1 -0
  319. package/dist/test/utilities/d1.d.ts +21 -0
  320. package/dist/test/utilities/d1.d.ts.map +1 -0
  321. package/dist/test/utilities/env.d.ts +40 -0
  322. package/dist/test/utilities/env.d.ts.map +1 -0
  323. package/dist/test/utilities/kv.d.ts +11 -0
  324. package/dist/test/utilities/kv.d.ts.map +1 -0
  325. package/dist/test/utilities/media.d.ts +16 -0
  326. package/dist/test/utilities/media.d.ts.map +1 -0
  327. package/dist/test/utilities/platform.d.ts +38 -0
  328. package/dist/test/utilities/platform.d.ts.map +1 -0
  329. package/dist/test/utilities/queue.d.ts +5 -0
  330. package/dist/test/utilities/queue.d.ts.map +1 -0
  331. package/dist/test/utilities/r2.d.ts +12 -0
  332. package/dist/test/utilities/r2.d.ts.map +1 -0
  333. package/dist/test/utilities/workflows.d.ts +26 -0
  334. package/dist/test/utilities/workflows.d.ts.map +1 -0
  335. package/dist/test/utilities.d.ts +10 -106
  336. package/dist/test/utilities.d.ts.map +1 -1
  337. package/dist/types-2ejrbba1.js +695 -0
  338. package/dist/types-7jkbm95a.js +695 -0
  339. package/dist/types-a2fk9yns.js +695 -0
  340. package/dist/types-dyb3c6zw.js +695 -0
  341. package/dist/types-e2n9f3pd.js +695 -0
  342. package/dist/types-j4s6qcrc.js +695 -0
  343. package/dist/utils/send-email.d.ts.map +1 -1
  344. package/dist/utils/send-email.js +1 -1
  345. package/dist/vite/index.js +6 -6
  346. package/dist/vite/plugin-context.d.ts.map +1 -1
  347. package/dist/worker-663em30d.js +513 -0
  348. package/dist/worker-argxc7fb.js +513 -0
  349. package/dist/worker-entry/composed-worker.d.ts.map +1 -1
  350. package/dist/worker-entry/surface-paths.d.ts +2 -0
  351. package/dist/worker-entry/surface-paths.d.ts.map +1 -1
  352. package/dist/worker-fcdsnj14.js +513 -0
  353. package/dist/worker-fk42rzse.js +513 -0
  354. package/dist/worker-jkemk8d2.js +513 -0
  355. package/dist/worker-m4ze8djx.js +513 -0
  356. package/dist/worker-wnan5dca.js +513 -0
  357. package/dist/worker-yw3atfb1.js +513 -0
  358. package/dist/workflows/local-workflow-entrypoints.d.ts +7 -0
  359. package/dist/workflows/local-workflow-entrypoints.d.ts.map +1 -0
  360. package/package.json +13 -12
@@ -0,0 +1,627 @@
1
+ import {
2
+ browserBindingSchema,
3
+ getSingleBrowserBindingName,
4
+ normalizeArtifactsBinding,
5
+ normalizeCompatibilityFlags,
6
+ normalizeD1Binding,
7
+ normalizeDOBinding,
8
+ normalizeDispatchNamespaceBinding,
9
+ normalizeHyperdriveBinding,
10
+ normalizeImagesBinding,
11
+ normalizeKVBinding,
12
+ normalizeMediaBinding,
13
+ normalizeMtlsCertificateBinding,
14
+ normalizePipelineBinding,
15
+ normalizeWorkflowBinding,
16
+ resolveConfigForEnvironment
17
+ } from "./index-g5aq66bj.js";
18
+ import {
19
+ __require
20
+ } from "./index-37x76zdn.js";
21
+
22
+ // src/config/compiler.ts
23
+ import { basename, isAbsolute as isAbsolute2, relative, resolve as resolve2 } from "pathe";
24
+
25
+ // src/config/local-dev-vars.ts
26
+ import { isAbsolute, resolve } from "pathe";
27
+ function resolveConfigPath(cwd, configPath) {
28
+ if (!configPath) {
29
+ return resolve(cwd, "devflare.config.ts");
30
+ }
31
+ return isAbsolute(configPath) ? configPath : resolve(cwd, configPath);
32
+ }
33
+ function stringifyBindingValue(value) {
34
+ if (typeof value === "string") {
35
+ return value;
36
+ }
37
+ return JSON.stringify(value);
38
+ }
39
+ function toWranglerSecretsConfig(secrets) {
40
+ if (!secrets) {
41
+ return;
42
+ }
43
+ const required = Object.entries(secrets).filter(([, config]) => config.required !== false).map(([name]) => name).sort();
44
+ return required.length > 0 ? { required } : undefined;
45
+ }
46
+ async function loadLocalDevVars(options) {
47
+ const wrangler = await import("wrangler");
48
+ const configPath = resolveConfigPath(options.cwd, options.configPath);
49
+ const activeEnvironment = options.environment ?? process.env.CLOUDFLARE_ENV;
50
+ const bindings = wrangler.unstable_getVarsForDev(configPath, undefined, options.vars ?? {}, activeEnvironment, options.silent ?? true, toWranglerSecretsConfig(options.secrets));
51
+ return Object.fromEntries(Object.entries(bindings).map(([name, binding]) => [name, stringifyBindingValue(binding.value)]));
52
+ }
53
+ async function applyLocalDevVarsToConfig(config, options) {
54
+ const vars = await loadLocalDevVars({
55
+ ...options,
56
+ vars: config.vars,
57
+ secrets: config.secrets
58
+ });
59
+ if (Object.keys(vars).length === 0) {
60
+ return config;
61
+ }
62
+ return {
63
+ ...config,
64
+ vars
65
+ };
66
+ }
67
+
68
+ // src/config/compiler.ts
69
+ function getWranglerD1DatabaseBinding(bindingName, bindingConfig, options = {}) {
70
+ const normalized = normalizeD1Binding(bindingConfig);
71
+ if (normalized.databaseId) {
72
+ return {
73
+ binding: bindingName,
74
+ database_id: normalized.databaseId
75
+ };
76
+ }
77
+ if (options.preserveNamedBindings && normalized.name) {
78
+ return {
79
+ binding: bindingName,
80
+ database_name: normalized.name
81
+ };
82
+ }
83
+ throw new Error(`D1 binding "${bindingName}" is configured by name (${normalized.name}) and must be resolved before compiling Wrangler config. Use loadResolvedConfig() or resolveConfigResources() for build/deploy/automation flows.`);
84
+ }
85
+ function getWranglerKVNamespaceBinding(bindingName, bindingConfig, options = {}) {
86
+ const normalized = normalizeKVBinding(bindingConfig);
87
+ if (normalized.namespaceId) {
88
+ return {
89
+ binding: bindingName,
90
+ id: normalized.namespaceId
91
+ };
92
+ }
93
+ if (options.preserveNamedBindings && normalized.name) {
94
+ return {
95
+ binding: bindingName,
96
+ name: normalized.name
97
+ };
98
+ }
99
+ throw new Error(`KV binding "${bindingName}" is configured by name (${normalized.name}) and must be resolved before compiling Wrangler config. Use loadResolvedConfig() or resolveConfigResources() for build/deploy/automation flows.`);
100
+ }
101
+ function getWranglerHyperdriveBinding(bindingName, bindingConfig, options = {}) {
102
+ const normalized = normalizeHyperdriveBinding(bindingConfig);
103
+ if (normalized.configurationId) {
104
+ return {
105
+ binding: bindingName,
106
+ id: normalized.configurationId,
107
+ ...normalized.localConnectionString && { localConnectionString: normalized.localConnectionString }
108
+ };
109
+ }
110
+ if (options.preserveNamedBindings && normalized.name) {
111
+ return {
112
+ binding: bindingName,
113
+ name: normalized.name,
114
+ ...normalized.localConnectionString && { localConnectionString: normalized.localConnectionString }
115
+ };
116
+ }
117
+ throw new Error(`Hyperdrive binding "${bindingName}" is configured by name (${normalized.name}) and must be resolved before compiling Wrangler config. Use loadResolvedConfig() or resolveConfigResources() for build/deploy/automation flows.`);
118
+ }
119
+ function getWranglerBrowserBinding(browserBindings) {
120
+ if (!browserBindings) {
121
+ return;
122
+ }
123
+ const parsed = browserBindingSchema.parse(browserBindings);
124
+ const bindingName = getSingleBrowserBindingName(parsed);
125
+ if (!bindingName) {
126
+ return;
127
+ }
128
+ const bindingConfig = parsed[bindingName];
129
+ return {
130
+ binding: bindingName,
131
+ ...typeof bindingConfig === "object" && bindingConfig.remote !== undefined && {
132
+ remote: bindingConfig.remote
133
+ }
134
+ };
135
+ }
136
+ function compileWranglerMigrations(migrations) {
137
+ return migrations.map((migration) => ({
138
+ tag: migration.tag,
139
+ ...migration.new_classes && { new_classes: migration.new_classes },
140
+ ...migration.renamed_classes && {
141
+ renamed_classes: migration.renamed_classes.map((renamedClass) => ({
142
+ from: renamedClass.from,
143
+ to: renamedClass.to
144
+ }))
145
+ },
146
+ ...migration.deleted_classes && { deleted_classes: migration.deleted_classes },
147
+ ...migration.new_sqlite_classes && { new_sqlite_classes: migration.new_sqlite_classes }
148
+ }));
149
+ }
150
+ function compileModuleOptions(config, result) {
151
+ if (config.rules && config.rules.length > 0) {
152
+ result.rules = config.rules;
153
+ }
154
+ if (config.findAdditionalModules !== undefined) {
155
+ result.find_additional_modules = config.findAdditionalModules;
156
+ }
157
+ if (config.baseDir) {
158
+ result.base_dir = config.baseDir;
159
+ }
160
+ if (config.preserveFileNames !== undefined) {
161
+ result.preserve_file_names = config.preserveFileNames;
162
+ }
163
+ }
164
+ function compileContainers(config, result) {
165
+ if (!config.containers || config.containers.length === 0) {
166
+ return;
167
+ }
168
+ result.containers = config.containers.map((container) => ({
169
+ class_name: container.className,
170
+ image: container.image,
171
+ ...container.maxInstances !== undefined && { max_instances: container.maxInstances },
172
+ ...container.instanceType && { instance_type: container.instanceType },
173
+ ...container.name && { name: container.name },
174
+ ...container.imageBuildContext && { image_build_context: container.imageBuildContext },
175
+ ...container.imageVars && { image_vars: container.imageVars },
176
+ ...container.rolloutActiveGracePeriod !== undefined && {
177
+ rollout_active_grace_period: container.rolloutActiveGracePeriod
178
+ },
179
+ ...container.rolloutStepPercentage !== undefined && {
180
+ rollout_step_percentage: container.rolloutStepPercentage
181
+ }
182
+ }));
183
+ }
184
+ function compileConfig(config, environment) {
185
+ return compileConfigInternal(config, environment);
186
+ }
187
+ function compileBuildConfig(config, environment, options = {}) {
188
+ return compileConfigInternal(config, environment, {
189
+ preserveNamedBindings: true,
190
+ alreadyResolved: options.alreadyResolved
191
+ });
192
+ }
193
+ function compileConfigInternal(config, environment, options = {}) {
194
+ const resolvedConfig = options.alreadyResolved ? config : resolveConfigForEnvironment(config, environment);
195
+ const mergedConfig = {
196
+ ...resolvedConfig,
197
+ compatibilityFlags: normalizeCompatibilityFlags(resolvedConfig.compatibilityFlags)
198
+ };
199
+ const result = {
200
+ name: mergedConfig.name,
201
+ compatibility_date: mergedConfig.compatibilityDate,
202
+ preview_urls: true,
203
+ workers_dev: true
204
+ };
205
+ if (mergedConfig.accountId) {
206
+ result.account_id = mergedConfig.accountId;
207
+ }
208
+ const mainEntry = mergedConfig.files?.fetch;
209
+ if (typeof mainEntry === "string") {
210
+ result.main = mainEntry;
211
+ }
212
+ compileModuleOptions(mergedConfig, result);
213
+ if (mergedConfig.compatibilityFlags && mergedConfig.compatibilityFlags.length > 0) {
214
+ result.compatibility_flags = mergedConfig.compatibilityFlags;
215
+ }
216
+ if (mergedConfig.bindings) {
217
+ compileBindings(mergedConfig.bindings, result, options);
218
+ }
219
+ if (mergedConfig.triggers?.crons && mergedConfig.triggers.crons.length > 0) {
220
+ result.triggers = { crons: mergedConfig.triggers.crons };
221
+ }
222
+ if (mergedConfig.tailConsumers && mergedConfig.tailConsumers.length > 0) {
223
+ result.tail_consumers = mergedConfig.tailConsumers.map((consumer) => typeof consumer === "string" ? { service: consumer } : {
224
+ service: consumer.service,
225
+ ...consumer.environment && { environment: consumer.environment }
226
+ });
227
+ }
228
+ if (mergedConfig.vars && Object.keys(mergedConfig.vars).length > 0) {
229
+ result.vars = mergedConfig.vars;
230
+ }
231
+ const secrets = toWranglerSecretsConfig(mergedConfig.secrets);
232
+ if (secrets) {
233
+ result.secrets = secrets;
234
+ }
235
+ if (mergedConfig.routes && mergedConfig.routes.length > 0) {
236
+ result.routes = mergedConfig.routes.map((route) => ({
237
+ pattern: route.pattern,
238
+ ...route.zone_name && { zone_name: route.zone_name },
239
+ ...route.zone_id && { zone_id: route.zone_id },
240
+ ...route.custom_domain !== undefined && { custom_domain: route.custom_domain }
241
+ }));
242
+ }
243
+ if (mergedConfig.assets && mergedConfig.assets.directory) {
244
+ result.assets = {
245
+ directory: mergedConfig.assets.directory,
246
+ ...mergedConfig.assets.binding && { binding: mergedConfig.assets.binding },
247
+ ...mergedConfig.assets.html_handling && { html_handling: mergedConfig.assets.html_handling },
248
+ ...mergedConfig.assets.not_found_handling && {
249
+ not_found_handling: mergedConfig.assets.not_found_handling
250
+ },
251
+ ...mergedConfig.assets.run_worker_first !== undefined && {
252
+ run_worker_first: mergedConfig.assets.run_worker_first
253
+ }
254
+ };
255
+ }
256
+ if (mergedConfig.placement) {
257
+ result.placement = mergedConfig.placement;
258
+ }
259
+ if (mergedConfig.observability) {
260
+ result.observability = mergedConfig.observability;
261
+ }
262
+ if (mergedConfig.limits) {
263
+ result.limits = mergedConfig.limits;
264
+ }
265
+ compileContainers(mergedConfig, result);
266
+ if (mergedConfig.migrations && mergedConfig.migrations.length > 0) {
267
+ result.migrations = compileWranglerMigrations(mergedConfig.migrations);
268
+ }
269
+ if (mergedConfig.wrangler?.passthrough) {
270
+ Object.assign(result, mergedConfig.wrangler.passthrough);
271
+ }
272
+ return result;
273
+ }
274
+ function compileToProgrammaticConfig(config, environment, options = {}) {
275
+ return options.preserveNamedBindings ? compileBuildConfig(config, environment) : compileConfig(config, environment);
276
+ }
277
+ function compileBindings(bindings, result, options = {}) {
278
+ if (bindings.kv) {
279
+ result.kv_namespaces = Object.entries(bindings.kv).map(([binding, namespace]) => {
280
+ return getWranglerKVNamespaceBinding(binding, namespace, options);
281
+ });
282
+ }
283
+ if (bindings.d1) {
284
+ result.d1_databases = Object.entries(bindings.d1).map(([binding, database_id]) => {
285
+ return getWranglerD1DatabaseBinding(binding, database_id, options);
286
+ });
287
+ }
288
+ if (bindings.r2) {
289
+ result.r2_buckets = Object.entries(bindings.r2).map(([binding, bucket_name]) => ({
290
+ binding,
291
+ bucket_name
292
+ }));
293
+ }
294
+ if (bindings.durableObjects) {
295
+ result.durable_objects = {
296
+ bindings: Object.entries(bindings.durableObjects).map(([name, config]) => {
297
+ const normalized = normalizeDOBinding(config);
298
+ const binding = {
299
+ name,
300
+ class_name: normalized.className
301
+ };
302
+ if (normalized.kind === "cross-worker" && normalized.scriptName) {
303
+ binding.script_name = normalized.scriptName;
304
+ }
305
+ return binding;
306
+ })
307
+ };
308
+ }
309
+ if (bindings.queues) {
310
+ result.queues = {};
311
+ if (bindings.queues.producers) {
312
+ result.queues.producers = Object.entries(bindings.queues.producers).map(([binding, queue]) => ({ binding, queue }));
313
+ }
314
+ if (bindings.queues.consumers) {
315
+ result.queues.consumers = bindings.queues.consumers.map((consumer) => ({
316
+ queue: consumer.queue,
317
+ ...consumer.maxBatchSize && { max_batch_size: consumer.maxBatchSize },
318
+ ...consumer.maxBatchTimeout && { max_batch_timeout: consumer.maxBatchTimeout },
319
+ ...consumer.maxRetries && { max_retries: consumer.maxRetries },
320
+ ...consumer.deadLetterQueue && { dead_letter_queue: consumer.deadLetterQueue },
321
+ ...consumer.maxConcurrency && { max_concurrency: consumer.maxConcurrency },
322
+ ...consumer.retryDelay && { retry_delay: consumer.retryDelay }
323
+ }));
324
+ }
325
+ }
326
+ if (bindings.rateLimits) {
327
+ result.ratelimits = Object.entries(bindings.rateLimits).map(([name, config]) => ({
328
+ name,
329
+ namespace_id: config.namespaceId,
330
+ simple: {
331
+ limit: config.simple.limit,
332
+ period: config.simple.period
333
+ }
334
+ }));
335
+ }
336
+ if (bindings.versionMetadata) {
337
+ result.version_metadata = {
338
+ binding: bindings.versionMetadata.binding
339
+ };
340
+ }
341
+ if (bindings.workerLoaders) {
342
+ result.worker_loaders = Object.keys(bindings.workerLoaders).map((binding) => ({ binding }));
343
+ }
344
+ if (bindings.mtlsCertificates) {
345
+ result.mtls_certificates = Object.entries(bindings.mtlsCertificates).map(([binding, config]) => {
346
+ const normalized = normalizeMtlsCertificateBinding(config);
347
+ return {
348
+ binding,
349
+ certificate_id: normalized.certificateId,
350
+ ...normalized.remote !== undefined && { remote: normalized.remote }
351
+ };
352
+ });
353
+ }
354
+ if (bindings.dispatchNamespaces) {
355
+ result.dispatch_namespaces = Object.entries(bindings.dispatchNamespaces).map(([binding, config]) => {
356
+ const normalized = normalizeDispatchNamespaceBinding(config);
357
+ return {
358
+ binding,
359
+ namespace: normalized.namespace,
360
+ ...normalized.outbound && { outbound: normalized.outbound },
361
+ ...normalized.remote !== undefined && { remote: normalized.remote }
362
+ };
363
+ });
364
+ }
365
+ if (bindings.workflows) {
366
+ result.workflows = Object.entries(bindings.workflows).map(([binding, config]) => {
367
+ const normalized = normalizeWorkflowBinding(config);
368
+ return {
369
+ binding,
370
+ name: normalized.name,
371
+ class_name: normalized.className,
372
+ ...normalized.scriptName && { script_name: normalized.scriptName },
373
+ ...normalized.remote !== undefined && { remote: normalized.remote },
374
+ ...normalized.limits && { limits: normalized.limits }
375
+ };
376
+ });
377
+ }
378
+ if (bindings.pipelines) {
379
+ result.pipelines = Object.entries(bindings.pipelines).map(([binding, config]) => {
380
+ const normalized = normalizePipelineBinding(config);
381
+ return {
382
+ binding,
383
+ pipeline: normalized.pipeline,
384
+ ...normalized.remote !== undefined && { remote: normalized.remote }
385
+ };
386
+ });
387
+ }
388
+ if (bindings.images) {
389
+ const [entry] = Object.entries(bindings.images);
390
+ if (entry) {
391
+ const [binding, config] = entry;
392
+ const normalized = normalizeImagesBinding(binding, config);
393
+ result.images = {
394
+ binding: normalized.binding,
395
+ ...normalized.remote !== undefined && { remote: normalized.remote }
396
+ };
397
+ }
398
+ }
399
+ if (bindings.media) {
400
+ const [entry] = Object.entries(bindings.media);
401
+ if (entry) {
402
+ const [binding, config] = entry;
403
+ const normalized = normalizeMediaBinding(binding, config);
404
+ result.media = {
405
+ binding: normalized.binding,
406
+ ...normalized.remote !== undefined && { remote: normalized.remote }
407
+ };
408
+ }
409
+ }
410
+ if (bindings.artifacts) {
411
+ result.artifacts = Object.entries(bindings.artifacts).map(([binding, config]) => {
412
+ const normalized = normalizeArtifactsBinding(config);
413
+ return {
414
+ binding,
415
+ namespace: normalized.namespace,
416
+ ...normalized.remote !== undefined && { remote: normalized.remote }
417
+ };
418
+ });
419
+ }
420
+ if (bindings.secretsStore) {
421
+ result.secrets_store_secrets = Object.entries(bindings.secretsStore).map(([binding, config]) => ({
422
+ binding,
423
+ store_id: config.storeId,
424
+ secret_name: config.secretName
425
+ }));
426
+ }
427
+ if (bindings.services) {
428
+ result.services = Object.entries(bindings.services).map(([binding, config]) => ({
429
+ binding,
430
+ service: config.service,
431
+ ...config.entrypoint && { entrypoint: config.entrypoint },
432
+ ...config.environment && { environment: config.environment }
433
+ }));
434
+ }
435
+ if (bindings.ai && bindings.ai.binding) {
436
+ result.ai = {
437
+ binding: bindings.ai.binding,
438
+ ...bindings.ai.remote !== undefined && { remote: bindings.ai.remote },
439
+ ...bindings.ai.staging !== undefined && { staging: bindings.ai.staging }
440
+ };
441
+ }
442
+ if (bindings.aiSearchNamespaces) {
443
+ result.ai_search_namespaces = Object.entries(bindings.aiSearchNamespaces).map(([binding, config]) => ({
444
+ binding,
445
+ namespace: config.namespace,
446
+ ...config.remote !== undefined && { remote: config.remote }
447
+ }));
448
+ }
449
+ if (bindings.aiSearch) {
450
+ result.ai_search = Object.entries(bindings.aiSearch).map(([binding, config]) => ({
451
+ binding,
452
+ instance_name: config.instanceName,
453
+ ...config.remote !== undefined && { remote: config.remote }
454
+ }));
455
+ }
456
+ if (bindings.vectorize) {
457
+ result.vectorize = Object.entries(bindings.vectorize).map(([binding, config]) => ({
458
+ binding,
459
+ index_name: config.indexName,
460
+ ...config.remote !== undefined && { remote: config.remote }
461
+ }));
462
+ }
463
+ if (bindings.hyperdrive) {
464
+ result.hyperdrive = Object.entries(bindings.hyperdrive).map(([binding, config]) => {
465
+ return getWranglerHyperdriveBinding(binding, config, options);
466
+ });
467
+ }
468
+ const browserBinding = getWranglerBrowserBinding(bindings.browser);
469
+ if (browserBinding) {
470
+ result.browser = browserBinding;
471
+ }
472
+ if (bindings.analyticsEngine) {
473
+ result.analytics_engine_datasets = Object.entries(bindings.analyticsEngine).map(([binding, config]) => ({
474
+ binding,
475
+ dataset: config.dataset
476
+ }));
477
+ }
478
+ if (bindings.sendEmail) {
479
+ result.send_email = Object.entries(bindings.sendEmail).map(([name, config]) => ({
480
+ name,
481
+ ...config.destinationAddress && {
482
+ destination_address: config.destinationAddress
483
+ },
484
+ ...config.allowedDestinationAddresses && {
485
+ allowed_destination_addresses: config.allowedDestinationAddresses
486
+ },
487
+ ...config.allowedSenderAddresses && {
488
+ allowed_sender_addresses: config.allowedSenderAddresses
489
+ }
490
+ }));
491
+ }
492
+ }
493
+ function stringifyConfig(config) {
494
+ const header = `// Generated by devflare — Do not edit directly
495
+ // Edit devflare.config.ts instead
496
+
497
+ `;
498
+ return header + JSON.stringify(config, null, "\t");
499
+ }
500
+ function rebasePathForConfigDir(projectRoot, configDir, pathValue) {
501
+ const absolutePath = isAbsolute2(pathValue) ? pathValue : resolve2(projectRoot, pathValue);
502
+ return relative(configDir, absolutePath).replace(/\\/g, "/");
503
+ }
504
+ function isLocalContainerPath(pathValue) {
505
+ return pathValue === "Dockerfile" || pathValue.startsWith(".") || pathValue.startsWith("/") || pathValue.startsWith("\\") || isAbsolute2(pathValue) || pathValue.endsWith("/Dockerfile") || pathValue.endsWith("\\Dockerfile");
506
+ }
507
+ function pathIsInsideDirectory(directoryPath, candidatePath) {
508
+ const normalizedDirectoryPath = directoryPath.replace(/\\/g, "/");
509
+ const normalizedCandidatePath = candidatePath.replace(/\\/g, "/");
510
+ return normalizedCandidatePath === normalizedDirectoryPath || normalizedCandidatePath.startsWith(`${normalizedDirectoryPath}/`);
511
+ }
512
+ function isolateViteBuildOutputPaths(projectRoot, config) {
513
+ const assetsDirectory = config.assets?.directory;
514
+ if (!assetsDirectory) {
515
+ return config;
516
+ }
517
+ const isolatedAssetsDirectoryPath = resolve2(projectRoot, ".devflare", "vite-build-output", basename(assetsDirectory));
518
+ const isolatedAssetsDirectory = relative(projectRoot, isolatedAssetsDirectoryPath).replace(/\\/g, "/");
519
+ const isolatedConfig = {
520
+ ...config,
521
+ assets: config.assets ? {
522
+ ...config.assets,
523
+ directory: isolatedAssetsDirectory
524
+ } : config.assets
525
+ };
526
+ if (!config.main) {
527
+ return isolatedConfig;
528
+ }
529
+ const originalAssetsDirectoryPath = resolve2(projectRoot, assetsDirectory);
530
+ const originalMainEntryPath = resolve2(projectRoot, config.main);
531
+ if (!pathIsInsideDirectory(originalAssetsDirectoryPath, originalMainEntryPath)) {
532
+ return isolatedConfig;
533
+ }
534
+ const relativeMainEntryPath = relative(originalAssetsDirectoryPath, originalMainEntryPath);
535
+ const isolatedMainEntryPath = resolve2(isolatedAssetsDirectoryPath, relativeMainEntryPath);
536
+ return {
537
+ ...isolatedConfig,
538
+ main: relative(projectRoot, isolatedMainEntryPath).replace(/\\/g, "/")
539
+ };
540
+ }
541
+ function rebaseWranglerConfigPaths(projectRoot, configDir, config) {
542
+ return {
543
+ ...config,
544
+ ...config.main ? { main: rebasePathForConfigDir(projectRoot, configDir, config.main) } : {},
545
+ ...config.assets?.directory ? {
546
+ assets: {
547
+ ...config.assets,
548
+ directory: rebasePathForConfigDir(projectRoot, configDir, config.assets.directory)
549
+ }
550
+ } : {},
551
+ ...config.containers ? {
552
+ containers: config.containers.map((container) => ({
553
+ ...container,
554
+ image: isLocalContainerPath(container.image) ? rebasePathForConfigDir(projectRoot, configDir, container.image) : container.image,
555
+ ...container.image_build_context && {
556
+ image_build_context: rebasePathForConfigDir(projectRoot, configDir, container.image_build_context)
557
+ }
558
+ }))
559
+ } : {}
560
+ };
561
+ }
562
+ async function writeWranglerConfig(cwd, config, filename = "wrangler.jsonc") {
563
+ const { resolve: resolve3 } = await import("pathe");
564
+ const fs = await import("node:fs/promises");
565
+ try {
566
+ await fs.mkdir(cwd, { recursive: true });
567
+ } catch {}
568
+ const content = stringifyConfig(config);
569
+ const wranglerPath = resolve3(cwd, filename);
570
+ await fs.writeFile(wranglerPath, content, "utf-8");
571
+ return wranglerPath;
572
+ }
573
+ async function readWranglerConfig(filePath) {
574
+ const fs = await import("node:fs/promises");
575
+ const { parse } = await import("jsonc-parser");
576
+ const content = await fs.readFile(filePath, "utf-8");
577
+ const parsedConfig = parse(content);
578
+ if (!parsedConfig || typeof parsedConfig !== "object") {
579
+ throw new Error(`Could not parse Wrangler config at ${filePath}.`);
580
+ }
581
+ return parsedConfig;
582
+ }
583
+
584
+ // src/config/service-bindings-validation.ts
585
+ class ServiceBindingValidationError extends Error {
586
+ code = "SERVICE_BINDING_VALIDATION_ERROR";
587
+ missing;
588
+ constructor(missing, accountId) {
589
+ super(`Service binding(s) reference worker(s) that do not exist in Cloudflare account ${accountId}: ` + missing.join(", ") + `. Check the 'services' map in devflare.config.ts for typos or deploy the target worker(s) first.`);
590
+ this.name = "ServiceBindingValidationError";
591
+ this.missing = missing;
592
+ }
593
+ }
594
+ function collectReferencedServiceNames(config) {
595
+ const services = config.bindings?.services;
596
+ if (!services) {
597
+ return [];
598
+ }
599
+ const names = new Set;
600
+ for (const binding of Object.values(services)) {
601
+ if (binding && typeof binding === "object" && typeof binding.service === "string") {
602
+ const name = binding.service.trim();
603
+ if (name.length > 0) {
604
+ names.add(name);
605
+ }
606
+ }
607
+ }
608
+ return [...names];
609
+ }
610
+ async function validateServiceBindings(config, accountId, options) {
611
+ const referenced = collectReferencedServiceNames(config);
612
+ if (referenced.length === 0) {
613
+ return;
614
+ }
615
+ const selfName = options.selfWorkerName?.trim();
616
+ const toValidate = selfName ? referenced.filter((name) => name !== selfName) : referenced;
617
+ if (toValidate.length === 0) {
618
+ return;
619
+ }
620
+ const workers = await options.listWorkers(accountId);
621
+ const workerNames = new Set(workers.map((worker) => worker.name));
622
+ const missing = toValidate.filter((name) => !workerNames.has(name));
623
+ if (missing.length > 0) {
624
+ throw new ServiceBindingValidationError(missing, accountId);
625
+ }
626
+ }
627
+ export { applyLocalDevVarsToConfig, compileConfig, compileBuildConfig, compileToProgrammaticConfig, stringifyConfig, isolateViteBuildOutputPaths, rebaseWranglerConfigPaths, writeWranglerConfig, readWranglerConfig, ServiceBindingValidationError, validateServiceBindings };