void 1.11.0 → 1.12.1

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 (361) hide show
  1. package/dist/{account-cmd-Bbr5cHjm.mjs → account-cmd-BU1Fy_Bf.mjs} +6 -6
  2. package/dist/{agents-DRo8gzni.mjs → agents-64FnLwxP.mjs} +6 -5
  3. package/dist/{application-analysis-XyUuNqYA.mjs → application-analysis-DVeN8yoi.mjs} +48 -22
  4. package/dist/{application-routing-DATqynKH.mjs → application-routing-KKw4Y84h.mjs} +1 -1
  5. package/dist/{assets-DZBd7yqh.mjs → assets-Br6_BeFJ.mjs} +34 -27
  6. package/dist/{ast-Cv0JwXqb.mjs → ast-BkPQu7A0.mjs} +5 -1
  7. package/dist/{auth-BN0NU9dz.mjs → auth-A7cZ8aXA.mjs} +1 -1
  8. package/dist/{auth-CCk9Seol.mjs → auth-CqwJwItO.mjs} +24 -12
  9. package/dist/{auth-link-CVxoyU81.mjs → auth-link-Duu2NvN5.mjs} +6 -6
  10. package/dist/{auth-router-ChXKduRM.mjs → auth-router-vgtOdb9j.mjs} +5 -5
  11. package/dist/{better-auth-shared-B8W8tZxP.d.mts → better-auth-shared-BS3pDQbT.d.mts} +6 -6
  12. package/dist/{better-auth-shared-DRHo5FoG.mjs → better-auth-shared-BcqDt-37.mjs} +7 -2
  13. package/dist/{build-cmd-C3b13rRf.mjs → build-cmd-B7OJ0U5R.mjs} +13 -12
  14. package/dist/build-id-4IV4hC1-.mjs +13 -0
  15. package/dist/{cache-B1WzZV60.mjs → cache-wSpi3aeM.mjs} +6 -6
  16. package/dist/{cancel-deploy-BggXixU_.mjs → cancel-deploy-DMWzkAlb.mjs} +5 -5
  17. package/dist/{cf-access-Dnyw8KFY.mjs → cf-access-DHklo7Rg.mjs} +41 -23
  18. package/dist/{cf-access-pejlJmuy.mjs → cf-access-DmkKPcAI.mjs} +0 -8
  19. package/dist/{cf-build-output-bBx1gDll.mjs → cf-build-output-Cso7Vh-t.mjs} +31 -27
  20. package/dist/cf-build-output-Wpk_e5CI.mjs +1 -0
  21. package/dist/{cf-command-values-Ccl-zRhl.mjs → cf-command-values-5BPBRc9Z.mjs} +1 -1
  22. package/dist/cf-config-migrate-D271BTiw.mjs +1664 -0
  23. package/dist/{cf-worker-settings-CARs4Wy9.mjs → cf-worker-settings-BBdlhm9U.mjs} +1 -1
  24. package/dist/cli/cli.mjs +1 -1
  25. package/dist/cli/cloudflare-operation-process.mjs +17 -14
  26. package/dist/cli/db-execute-process.d.mts +2 -0
  27. package/dist/cli/db-execute-process.mjs +57 -0
  28. package/dist/cli/env-schema-probe.d.mts +3 -1
  29. package/dist/cli/env-schema-probe.mjs +7 -8
  30. package/dist/{cli-main-DW09sVsT.mjs → cli-main-BrChcpE3.mjs} +152 -405
  31. package/dist/{client-DF6U7KLP.mjs → client-DE2m2ldh.mjs} +186 -17
  32. package/dist/{client-DGfZTE4V.mjs → client-eLZwqkPH.mjs} +1 -1
  33. package/dist/{cloudflare-auth-pNvmT6kL.mjs → cloudflare-auth-eWfhdZCk.mjs} +1 -1
  34. package/dist/{cloudflare-cmd-BOhToob3.mjs → cloudflare-cmd-SsFlJe2B.mjs} +7 -8
  35. package/dist/{cloudflare-config-D1dMHbvz.mjs → cloudflare-config-D9UFH_A5.mjs} +2 -2
  36. package/dist/{cloudflare-connect-DTrsIBAa.mjs → cloudflare-connect-BgpHcSg3.mjs} +3 -3
  37. package/dist/{cloudflare-operations-DmqtzoX4.mjs → cloudflare-operations-BIRQkYwL.mjs} +26 -28
  38. package/dist/cloudflare-operations-ByjFGats.mjs +1 -0
  39. package/dist/cloudflare-process-60r4Z2Zf.mjs +671 -0
  40. package/dist/cloudflare-user-output-CCR99eQY.mjs +19 -0
  41. package/dist/collect-B6nlSnsb.mjs +1 -0
  42. package/dist/{collect-C6Blu9yw.mjs → collect-rNLybAnF.mjs} +3 -3
  43. package/dist/{config-Do7gJI3T.mjs → config-BFX5ZB1J.mjs} +5 -4
  44. package/dist/{config-CeZd67L0.mjs → config-BSoW3QCB.mjs} +5 -5
  45. package/dist/{config-DYW2TBgz.d.mts → config-DA6ZbLXO.d.mts} +1 -1
  46. package/dist/{config-dMSpL-ml.mjs → config-DtjrUtPo.mjs} +1 -1
  47. package/dist/{config-BmvqLnbi.mjs → config-Dv5jri1-.mjs} +4 -4
  48. package/dist/config-entry.d.mts +1 -1
  49. package/dist/{connect-B3bKxRzX.mjs → connect-D0V0o40j.mjs} +9 -9
  50. package/dist/{create-project-DLUlxmf5.mjs → create-project-8FdN6D2i.mjs} +7 -6
  51. package/dist/{create-project-By7ymK7F.mjs → create-project-CbuDH5Hv.mjs} +1 -1
  52. package/dist/{db-3qsP21pH.mjs → db-BNPIjLkK.mjs} +1450 -154
  53. package/dist/db-args-BvMwAber.mjs +1 -0
  54. package/dist/db-args-CiQVg8SJ.mjs +321 -0
  55. package/dist/db-seed-loader-Bcz_SutQ.mjs +253 -0
  56. package/dist/{db-types-DC7KJLx2.mjs → db-types-B4Cf9dzR.mjs} +1 -1
  57. package/dist/{delete-HbFqgEFC.mjs → delete-WtLEfap2.mjs} +6 -6
  58. package/dist/{deploy-2QjsBEGw.mjs → deploy-BgSbagIP.mjs} +218 -553
  59. package/dist/deploy-Do6FWqon.mjs +2 -0
  60. package/dist/{deploy-managed-static-JoNP3cec.mjs → deploy-managed-static-BWBsxOww.mjs} +115 -194
  61. package/dist/deploy-security-notice-IRGy6Edf.mjs +192 -0
  62. package/dist/{deploy-transport-QAkhJYRI.mjs → deploy-transport-BKP_oV9q.mjs} +4 -4
  63. package/dist/deploy.mjs +9 -9
  64. package/dist/{dev-inbox-BiamQEAa.mjs → dev-inbox-ClVjKEHy.mjs} +1 -1
  65. package/dist/direct-r2-upload-DFXLWfXV.mjs +204 -0
  66. package/dist/discover-D2KGP3cR.mjs +1 -0
  67. package/dist/{discover-Vd18lHsj.mjs → discover-IcspacCg.mjs} +1 -1
  68. package/dist/{dispatch-BlOYh1Vc.mjs → dispatch-DIhDA3NI.mjs} +11 -10
  69. package/dist/{dist-Cp4b1_T9.mjs → dist-C47zy_kJ.mjs} +1 -1
  70. package/dist/{dist-STQXl8ck.mjs → dist-Cr_xGE_K.mjs} +73 -38
  71. package/dist/{domain-COkVSfII.mjs → domain-mweyYXSw.mjs} +8 -10
  72. package/dist/{dotenv-CEI8hapP.mjs → dotenv-BG6RQavH.mjs} +2 -2
  73. package/dist/{drizzle-BXVOa6Jg.mjs → drizzle-BJDMPrj7.mjs} +3 -4
  74. package/dist/{drizzle-CvSGrvdl.mjs → drizzle-CQ5jWuDL.mjs} +1 -1
  75. package/dist/{email-Dj02fLgQ.mjs → email-DcQNP40O.mjs} +33 -30
  76. package/dist/{email-cloudflare-DDknDAgp.mjs → email-cloudflare-DeYH3Ke7.mjs} +29 -38
  77. package/dist/{email-pattern-BYr-EFq5.mjs → email-pattern-bRna9MOJ.mjs} +2 -2
  78. package/dist/{entry-DMgR7XOf.mjs → entry-Bwb9ev8K.mjs} +13 -10
  79. package/dist/{env-BA7e5yzp.mjs → env-DaAoYR2-.mjs} +8 -8
  80. package/dist/{env-UqS-21xi.mjs → env-EjHqc7m9.mjs} +1 -1
  81. package/dist/{env-types-WEZw5D-r.mjs → env-types-D2hBodXP.mjs} +2 -19
  82. package/dist/{env-validation-DfJ9Fzfa.mjs → env-validation-D-v5_CWL.mjs} +13 -13
  83. package/dist/{env-validation-ly_Q9Kgd.mjs → env-validation-j9pjCDfA.mjs} +1 -1
  84. package/dist/{error-pages-QNeBXiRR.mjs → error-pages-GORL6F_e.mjs} +1 -1
  85. package/dist/{fetch-CbI6lNnk.d.mts → fetch-CczQyIed.d.mts} +1 -1
  86. package/dist/{fetch-DdK9eGin.mjs → fetch-CiEsvjpP.mjs} +1 -1
  87. package/dist/{fetch-stream-DQAavFdm.mjs → fetch-stream-BIG5lHW6.mjs} +3 -4
  88. package/dist/{fetch-stream-DoED9atq.d.mts → fetch-stream-DRX8-83b.d.mts} +2 -2
  89. package/dist/{gen-EMpnzNGz.mjs → gen-aOtHhZLD.mjs} +21 -18
  90. package/dist/gen-vhBDHs3q.mjs +1 -0
  91. package/dist/{generate-BOp1g1H_.mjs → generate-C3ZAqCy-.mjs} +1 -1
  92. package/dist/{generate-CWb8aOsm.mjs → generate-Dq2Bgw75.mjs} +6 -6
  93. package/dist/{git-metadata-Cukp5kV5.mjs → git-metadata-BEokJ6US.mjs} +1 -1
  94. package/dist/{github-cmd-8bXgJNAQ.mjs → github-cmd-BR19Ffdz.mjs} +14 -9
  95. package/dist/{handler-w_FAiIRu.mjs → handler-DCrDLzw2.mjs} +3 -3
  96. package/dist/has-own-key-D9QEnAkF.mjs +5 -0
  97. package/dist/{head-0o0QoREY.mjs → head-BwQ5kgqt.mjs} +5 -4
  98. package/dist/{head-CVO92KEx.d.mts → head-fUp8n_QJ.d.mts} +9 -4
  99. package/dist/{headers-BjgvlY29.mjs → headers-DqBsjDxg.mjs} +7 -7
  100. package/dist/{help-DCQKp3Kp.mjs → help-DvClCzqL.mjs} +138 -60
  101. package/dist/help-fKPzcTJv.mjs +1 -0
  102. package/dist/{inbound-BHt4dIlL.d.mts → inbound-CwgZSqFI.d.mts} +9 -3
  103. package/dist/{inbound--OF7zkwX.mjs → inbound-feMn1Rxx.mjs} +7 -7
  104. package/dist/{index-CmqHYj2R.d.mts → index-8cAgNdb6.d.mts} +1 -1
  105. package/dist/{index-BTmhCDbw.d.mts → index-BQ5qYiAw.d.mts} +2 -2
  106. package/dist/{index-BESZTC1z.d.mts → index-BYcWajVp.d.mts} +2 -1
  107. package/dist/{index-BXdP39qx.d.mts → index-Dn2mkPr2.d.mts} +24 -23
  108. package/dist/index.d.mts +2 -2
  109. package/dist/index.mjs +344 -637
  110. package/dist/{info--jdAIsJN.mjs → info-P6MBiVJi.mjs} +4 -4
  111. package/dist/{init-BLZvktk_.mjs → init-C8YpkGIP.mjs} +124 -345
  112. package/dist/installed-packages-tfmYd-cC.mjs +198 -0
  113. package/dist/{isr-config-Czzb4mIq.mjs → isr-config-DiTnL9Tb.mjs} +5 -5
  114. package/dist/{link-DPJ4jN7y.mjs → link-Dyz9IGcM.mjs} +7 -7
  115. package/dist/{list-B-au6xJt.mjs → list-VGYBMjmx.mjs} +11 -7
  116. package/dist/{live-DvtxTUhW.mjs → live-dvGThbwy.mjs} +14 -17
  117. package/dist/{load-user-env-BltIJLtl.mjs → load-user-env-B8qC0Q2Y.mjs} +1 -1
  118. package/dist/{local-d1-C6xn26Nl.mjs → local-d1-CYOYkVwO.mjs} +3 -3
  119. package/dist/{login-p1_BMgXg.mjs → login-CWFr-G2I.mjs} +8 -6
  120. package/dist/login-DECm3e9b.mjs +1 -0
  121. package/dist/{logs-UNH3vQeX.mjs → logs-kS1wuR4b.mjs} +9 -9
  122. package/dist/{migrate-9dlt6Mxu.mjs → migrate-BNZL1hee.mjs} +9 -10
  123. package/dist/migrate-C9aoWLvY.mjs +1 -0
  124. package/dist/{migrations-Cbns2RAm.mjs → migrations-CUHhX65Y.mjs} +5 -5
  125. package/dist/{mime-BGoZ8ZLL.mjs → mime-Btw9R3CC.mjs} +26 -12
  126. package/dist/module-references-DWQmO6TW.mjs +27 -0
  127. package/dist/mysql-lock-D8xtnI-D.mjs +145 -0
  128. package/dist/mysql-sql-BIE7bc4Z.mjs +124 -0
  129. package/dist/nitro.d.mts +3 -0
  130. package/dist/nitro.mjs +14 -5
  131. package/dist/{node-DqkiQujF.mjs → node-DVJWfV6s.mjs} +6 -6
  132. package/dist/{operator-ai-logging-BQ6mOgQs.mjs → operator-ai-logging-DD0n6zc2.mjs} +11 -10
  133. package/dist/operator-args-nvetCWuz.mjs +1499 -0
  134. package/dist/{operator-auth-CD3pap65.mjs → operator-auth-DMvn-y9X.mjs} +2 -2
  135. package/dist/{operator-client-XvXTkea6.mjs → operator-client-dFNnXfyB.mjs} +6 -5
  136. package/dist/operator-cmd-CVfK5U0B.mjs +1 -0
  137. package/dist/{operator-cmd-CKbZbNKn.mjs → operator-cmd-a7yOf2tH.mjs} +33 -13
  138. package/dist/operator-security-D5MToU0p.mjs +263 -0
  139. package/dist/{output-Bc8ixgPF.mjs → output-BZLnu0z8.mjs} +13 -3
  140. package/dist/output-D7K9TWIA.mjs +1 -0
  141. package/dist/{package-json-DvS6IFRv.mjs → package-json-4xUI3xLz.mjs} +1 -1
  142. package/dist/pages/client.d.mts +53 -30
  143. package/dist/pages/client.mjs +168 -38
  144. package/dist/pages/head.d.mts +1 -1
  145. package/dist/pages/head.mjs +1 -1
  146. package/dist/pages/index.d.mts +8 -2
  147. package/dist/pages/index.mjs +283 -13
  148. package/dist/pages/islands-plugin.d.mts +26 -8
  149. package/dist/pages/islands-plugin.mjs +61 -22
  150. package/dist/pages/protocol.d.mts +2 -2
  151. package/dist/pages/protocol.mjs +1 -1
  152. package/dist/pages/serialize.mjs +1 -1
  153. package/dist/{pgpass-CEtnBOZO.mjs → pgpass-BLPoYN9_.mjs} +3 -2
  154. package/dist/platform-args-CMwMoiLp.mjs +1 -0
  155. package/dist/{platform-args-DQSMW4EP.mjs → platform-args-CvZSuhYS.mjs} +37 -9
  156. package/dist/{platform-auth-config-D80AKe72.mjs → platform-auth-config-CpszX-Ne.mjs} +26 -23
  157. package/dist/{platform-auth-protection-k1Ox-u9T.mjs → platform-auth-protection-DA6Tw8Og.mjs} +10 -10
  158. package/dist/{platform-auth-recovery-D-hKehPy.mjs → platform-auth-recovery-Cztrb1JC.mjs} +11 -9
  159. package/dist/{platform-cmd-DQ0Wi61H.mjs → platform-cmd-m6Asj6nO.mjs} +11 -11
  160. package/dist/{platform-cmd-Dtz5lw7R.mjs → platform-cmd-u1j88ggF.mjs} +1 -1
  161. package/dist/{platform-discovery-B0eZjZ3B.mjs → platform-discovery-CLxtixHJ.mjs} +1 -1
  162. package/dist/{platform-domain-BMGS4l74.mjs → platform-domain-DJSznNTA.mjs} +14 -10
  163. package/dist/{platform-lifecycle-y4AfmC7M.mjs → platform-lifecycle-BC-9p58d.mjs} +1 -1
  164. package/dist/{platform-lifecycle-BCkNQNsQ.mjs → platform-lifecycle-GFeXv3NC.mjs} +802 -207
  165. package/dist/platform-management-BwHkz46V.mjs +1 -0
  166. package/dist/{platform-management-Cj2aXFqD.mjs → platform-management-DX1zINou.mjs} +227 -58
  167. package/dist/{platform-plans-config-CrUUzEl9.mjs → platform-plans-config-DiydtNKY.mjs} +112 -35
  168. package/dist/{platform-recovery-DKZnALHI.mjs → platform-recovery-CnzBbudV.mjs} +5 -5
  169. package/dist/{platform-registry-DZ_2Xuqd.mjs → platform-registry-DHH6fivm.mjs} +6 -5
  170. package/dist/{platform-setup-CKmSEb1J.mjs → platform-setup-Lph9i-rh.mjs} +26 -12
  171. package/dist/{plugin-inference-B_urWd5Z.mjs → plugin-inference-COlq96WJ.mjs} +28 -53
  172. package/dist/prepare-DcwigRUS.mjs +1 -0
  173. package/dist/{prepare-CU7SZieQ.mjs → prepare-WvijE289.mjs} +3 -3
  174. package/dist/{prepare-vCdm5moJ.mjs → prepare-co1o1FFd.mjs} +12 -12
  175. package/dist/{project-cmd-B4cgPSi4.mjs → project-cmd-BWJTplpc.mjs} +30 -24
  176. package/dist/{project-CLwxcEdq.mjs → project-dh9431bN.mjs} +2 -2
  177. package/dist/{project-paths-CUhCPMpK.mjs → project-paths-2ENfCCih.mjs} +4 -3
  178. package/dist/project-security-BV1xfj1K.mjs +1 -0
  179. package/dist/project-security-CY_aahvW.mjs +1340 -0
  180. package/dist/{project-team-BdX6anO3.mjs → project-team-BlIFXlmT.mjs} +8 -8
  181. package/dist/{project-token-C1rcq8Xb.mjs → project-token-CMsB7I1-.mjs} +6 -6
  182. package/dist/{project-tsconfig-MyRJgufB.mjs → project-tsconfig-BOA4ym99.mjs} +25 -5
  183. package/dist/{project-DVsTAWFh.mjs → project-uXKua1it.mjs} +1 -1
  184. package/dist/project-zero-trust-BI6pdpx4.mjs +210 -0
  185. package/dist/{protocol-W5EQcIzN.mjs → protocol-4rEnumif.mjs} +15 -8
  186. package/dist/{protocol-BlAiF-hc.d.mts → protocol-ERy-n3jf.d.mts} +7 -4
  187. package/dist/{provision-DWnnKdT-.mjs → provision-Bh44omGA.mjs} +30 -22
  188. package/dist/{provision-CGI-T0mq.mjs → provision-DFv7SJDn.mjs} +1 -1
  189. package/dist/{public-B80SwOFp.d.mts → public-DB9C2Cy_.d.mts} +5 -2
  190. package/dist/{raw-7pQirZpQ.mjs → raw-5rak34QN.mjs} +2 -1
  191. package/dist/{redirect-Dqb4fEc5.mjs → redirect-Dyvuil0Q.mjs} +6 -3
  192. package/dist/{requests-D6MaLS_Y.mjs → requests-CfmJxNYg.mjs} +6 -6
  193. package/dist/{resolve-project-Da3OgCU1.mjs → resolve-project-8WZ3iVmr.mjs} +3 -3
  194. package/dist/resolve-project-YsTH-U9I.mjs +1 -0
  195. package/dist/{rollback-Bs8I8PF8.mjs → rollback-DL5HuAsM.mjs} +16 -7
  196. package/dist/route-types-CSed9-Dp.mjs +435 -0
  197. package/dist/{route-url-BBdkU7rb.mjs → route-url-B41eQ8QI.mjs} +1 -1
  198. package/dist/{route-url-Di1kB8D_.d.mts → route-url-Bd6IX-JZ.d.mts} +2 -1
  199. package/dist/routes-stub.d.mts +1 -1
  200. package/dist/routes-stub.mjs +1 -1
  201. package/dist/{runner-CTk21HrO.mjs → runner-Bf94YVJK.mjs} +1 -1
  202. package/dist/{runner-CMZb7jNU.mjs → runner-CeguHWJx.mjs} +3 -2
  203. package/dist/{runner-mysql-CJ-HyqxV.mjs → runner-mysql-D549vGGm.mjs} +14 -9
  204. package/dist/{runner-mysql-C_PrAUTm.mjs → runner-mysql-DOjbj-N1.mjs} +1 -1
  205. package/dist/{runner-pg-mYc75KfH.mjs → runner-pg-Buzw17hl.mjs} +1 -1
  206. package/dist/{runner-pg-2pjltt0t.mjs → runner-pg-DMJquR3d.mjs} +1 -1
  207. package/dist/runtime/ai/index.mjs +2 -2
  208. package/dist/runtime/auth/better-auth-d1.d.mts +1 -1
  209. package/dist/runtime/auth/better-auth-d1.mjs +2 -2
  210. package/dist/runtime/auth/better-auth-mysql.d.mts +1 -1
  211. package/dist/runtime/auth/better-auth-mysql.mjs +2 -2
  212. package/dist/runtime/auth/better-auth-postgres.d.mts +1 -1
  213. package/dist/runtime/auth/better-auth-postgres.mjs +3 -3
  214. package/dist/runtime/client/fetch-server.d.mts +1 -1
  215. package/dist/runtime/client/fetch-server.mjs +2 -2
  216. package/dist/runtime/client/fetch-stream.d.mts +2 -2
  217. package/dist/runtime/client/fetch-stream.mjs +1 -1
  218. package/dist/runtime/client/fetch.d.mts +1 -1
  219. package/dist/runtime/client/fetch.mjs +1 -1
  220. package/dist/runtime/client/index.d.mts +2 -2
  221. package/dist/runtime/client/index.mjs +2 -2
  222. package/dist/runtime/client/react.d.mts +2 -2
  223. package/dist/runtime/client/react.mjs +2 -2
  224. package/dist/runtime/client/solid.d.mts +2 -2
  225. package/dist/runtime/client/solid.mjs +2 -2
  226. package/dist/runtime/client/svelte.d.mts +2 -2
  227. package/dist/runtime/client/svelte.mjs +2 -2
  228. package/dist/runtime/client/vue.d.mts +2 -2
  229. package/dist/runtime/client/vue.mjs +2 -2
  230. package/dist/runtime/db/index.d.mts +1 -1
  231. package/dist/runtime/db/index.mjs +3 -3
  232. package/dist/runtime/db/migrations/mysql-handler.mjs +2 -1
  233. package/dist/runtime/db/migrations/postgres-handler.mjs +1 -1
  234. package/dist/runtime/db/session.d.mts +1 -1
  235. package/dist/runtime/db/session.mjs +1 -1
  236. package/dist/runtime/durable/index.mjs +7 -5
  237. package/dist/runtime/email/index.d.mts +1 -1
  238. package/dist/runtime/email/index.mjs +14 -11
  239. package/dist/runtime/email/testing.d.mts +1 -1
  240. package/dist/runtime/email/testing.mjs +4 -4
  241. package/dist/runtime/env/public-client.d.mts +4 -1
  242. package/dist/runtime/env/public.d.mts +1 -1
  243. package/dist/runtime/env/public.mjs +2 -2
  244. package/dist/runtime/env/runtime.mjs +1 -1
  245. package/dist/runtime/handler/index.d.mts +1 -1
  246. package/dist/runtime/handler/index.mjs +1 -1
  247. package/dist/runtime/handler/validator.d.mts +1 -1
  248. package/dist/runtime/handler/validator.mjs +1 -1
  249. package/dist/runtime/isr/index.mjs +1 -1
  250. package/dist/runtime/kv/index.mjs +1 -1
  251. package/dist/runtime/live/client.d.mts +2 -2
  252. package/dist/runtime/live/client.mjs +7 -7
  253. package/dist/runtime/live/index.d.mts +1 -1
  254. package/dist/runtime/live/index.mjs +1 -1
  255. package/dist/runtime/live/server.mjs +3 -3
  256. package/dist/runtime/queues/index.mjs +2 -2
  257. package/dist/runtime/remote/index.d.mts +5 -1
  258. package/dist/runtime/remote/index.mjs +10 -9
  259. package/dist/runtime/routing/index.d.mts +11 -12
  260. package/dist/runtime/routing/index.mjs +69 -65
  261. package/dist/runtime/routing/route-url.d.mts +1 -1
  262. package/dist/runtime/routing/route-url.mjs +1 -1
  263. package/dist/runtime/sandbox/index.d.mts +1 -1
  264. package/dist/runtime/sandbox/index.mjs +2 -2
  265. package/dist/runtime/sse/client.d.mts +1 -1
  266. package/dist/runtime/sse/index.mjs +1 -1
  267. package/dist/runtime/storage/index.mjs +1 -1
  268. package/dist/runtime/ws/index.d.mts +1 -1
  269. package/dist/runtime/ws/index.mjs +3 -2
  270. package/dist/runtime/ws/room.d.mts +1 -1
  271. package/dist/runtime/ws/room.mjs +2 -2
  272. package/dist/runtime/ws/server.d.mts +2 -2
  273. package/dist/runtime/ws/server.mjs +1 -1
  274. package/dist/{runtime-zDDinDI5.mjs → runtime-C_VPIJBF.mjs} +1 -1
  275. package/dist/{scan-LjuG3vfA.mjs → scan-Ct_SEzH4.mjs} +36 -29
  276. package/dist/{secret-DdUs8AuR.mjs → secret-C-WBaUSS.mjs} +11 -10
  277. package/dist/security-api-types-CU7zQtr_.mjs +9 -0
  278. package/dist/security-sarif-ClyYwtAW.mjs +123 -0
  279. package/dist/{serialize-Pf-CIQK_.mjs → serialize-BmB4BfKu.mjs} +1 -1
  280. package/dist/{server-CfUbeOjx.mjs → server-T-4mn8zy.mjs} +5 -4
  281. package/dist/{session-Cw8-b8Um.mjs → session-BT8XDkvL.mjs} +1 -1
  282. package/dist/{session-DgNrdNh_.d.mts → session-ouZYD7zb.d.mts} +1 -1
  283. package/dist/{skills-B40svMBE.mjs → skills-C-csz78e.mjs} +3 -3
  284. package/dist/{sse-BXnTfcf3.mjs → sse-D3ab0YQT.mjs} +16 -13
  285. package/dist/{static-exports-DFkzL-NX.mjs → static-exports-s7P86Ngp.mjs} +3 -3
  286. package/dist/{subcommand-prompt-D-m3Umap.mjs → subcommand-prompt-B4LOLosl.mjs} +31 -21
  287. package/dist/sveltekit.mjs +1 -1
  288. package/dist/{terminal-log-text-DNsWJREL.mjs → terminal-log-text-CfS2JKM6.mjs} +1 -1
  289. package/dist/{url-DaehRGKR.mjs → url-DBQluotE.mjs} +4 -1
  290. package/dist/validate-CZYUIfR-.mjs +1 -0
  291. package/dist/{validate-Ddzl-IwT.mjs → validate-CtBWCzez.mjs} +7 -4
  292. package/dist/{validator-Duafcnh7.mjs → validator-Dfh9kCDm.mjs} +5 -5
  293. package/dist/{version-metadata-k6KFiyWt.mjs → version-metadata-DqgLa6gc.mjs} +1 -1
  294. package/dist/{wrangler-v2BmVchV.mjs → wrangler-DVe5KV5G.mjs} +49 -46
  295. package/dist/wrangler-Dq269bjx.mjs +1 -0
  296. package/dist/{wrapper-eh6MpBZA.mjs → wrapper-CcMYpOS8.mjs} +45 -171
  297. package/docs/guide/app-types.md +1 -1
  298. package/docs/guide/auth.md +2 -16
  299. package/docs/guide/database.md +2 -0
  300. package/docs/guide/email/domains.md +1 -1
  301. package/docs/guide/email/sending.md +18 -1
  302. package/docs/guide/jobs.md +1 -1
  303. package/docs/guide/pages-routing/actions-and-forms.md +40 -19
  304. package/docs/guide/pages-routing/errors.md +3 -1
  305. package/docs/guide/pages-routing/head.md +20 -2
  306. package/docs/guide/pages-routing/overview.md +20 -0
  307. package/docs/guide/platform/administration/plans.md +13 -0
  308. package/docs/guide/platform/administration/security-audits.md +213 -0
  309. package/docs/guide/platform/administration/zero-trust.md +7 -1
  310. package/docs/guide/platform/installation/ci.md +1 -1
  311. package/docs/guide/platform/installation/credentials.md +23 -20
  312. package/docs/guide/platform/installation/maintenance.md +11 -5
  313. package/docs/guide/platform/installation/prerequisites.md +1 -1
  314. package/docs/guide/platform/installation/uninstall.md +2 -0
  315. package/docs/guide/platform-administration.md +1 -0
  316. package/docs/guide/queues.md +1 -1
  317. package/docs/guide/self-hosted-platform.md +14 -13
  318. package/docs/guide/type-safety.md +1 -1
  319. package/docs/integrations/cloudflare.md +3 -1
  320. package/docs/integrations/frameworks/sveltekit.md +1 -1
  321. package/docs/reference/api/handlers.md +3 -3
  322. package/docs/reference/api/pages.md +4 -0
  323. package/docs/reference/api/types.md +11 -1
  324. package/docs/reference/cli/database.md +42 -6
  325. package/docs/reference/cli/deploy.md +5 -1
  326. package/docs/reference/cli/domains.md +1 -1
  327. package/docs/reference/cli/platform-config.md +5 -3
  328. package/docs/reference/cli/platform-installation.md +29 -28
  329. package/docs/reference/cli/platform-security.md +98 -0
  330. package/docs/reference/cli/platform-zero-trust.md +6 -3
  331. package/docs/reference/cli/platform.md +1 -0
  332. package/docs/reference/cli/project.md +57 -0
  333. package/docs/reference/cli/setup.md +4 -0
  334. package/docs/reference/cli.md +3 -1
  335. package/docs/reference/config.md +2 -2
  336. package/package.json +30 -27
  337. package/skills/void/SKILL.md +7 -0
  338. package/dist/cf-build-output-D3_x71H6.mjs +0 -1
  339. package/dist/cf-config-migrate-CHtnM3_C.mjs +0 -348
  340. package/dist/cloudflare-operations-BditDbcd.mjs +0 -1
  341. package/dist/cloudflare-process-wcnaQ5JG.mjs +0 -392
  342. package/dist/cloudflare-user-output-zEwuGrEJ.mjs +0 -19
  343. package/dist/collect-8i0wU63d.mjs +0 -1
  344. package/dist/deploy-DiFfBu8g.mjs +0 -2
  345. package/dist/discover-Diq0l6TZ.mjs +0 -1
  346. package/dist/gen-CuANrEzy.mjs +0 -1
  347. package/dist/help-7EzLA1qP.mjs +0 -1
  348. package/dist/login-apwve7WD.mjs +0 -1
  349. package/dist/migrate-BzRplq7m.mjs +0 -1
  350. package/dist/mysql-sql-SlpS6OMg.mjs +0 -239
  351. package/dist/operator-args-BCCohcz3.mjs +0 -722
  352. package/dist/operator-cmd-D42knxMz.mjs +0 -1
  353. package/dist/output-D4UOUifX.mjs +0 -1
  354. package/dist/platform-args-Rgp86xa7.mjs +0 -1
  355. package/dist/platform-management-CRzeC70H.mjs +0 -1
  356. package/dist/prepare-C2MTqfFv.mjs +0 -1
  357. package/dist/project-zero-trust-CS02LrlK.mjs +0 -64
  358. package/dist/resolve-project-C5wC-Hoi.mjs +0 -1
  359. package/dist/route-types-CrODgORq.mjs +0 -655
  360. package/dist/validate-DY1U9rET.mjs +0 -1
  361. package/dist/wrangler-BPIAJdxA.mjs +0 -1
@@ -0,0 +1,1664 @@
1
+ import { isRecord } from "@void/deploy-core";
2
+ import { isDeepStrictEqual } from "node:util";
3
+ import { CloudflareConfigSchema, bindings, exports, triggers } from "@cloudflare/config";
4
+ // src/cli/cf-config-convert/converter-helpers.ts
5
+ function isRecord$1(value) {
6
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7
+ }
8
+ function hasOwn(record, key) {
9
+ return Object.hasOwn(record, key);
10
+ }
11
+ function getRecord(record, key) {
12
+ const value = record[key];
13
+ return isRecord$1(value) ? value : void 0;
14
+ }
15
+ function getRecords(record, key) {
16
+ const value = record[key];
17
+ return Array.isArray(value) ? value.filter(isRecord$1) : [];
18
+ }
19
+ function getStrings(record, key) {
20
+ const value = record[key];
21
+ return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
22
+ }
23
+ function toOutputValue(value) {
24
+ if (value === null || typeof value === "boolean" || typeof value === "number" || typeof value === "string") return value;
25
+ if (Array.isArray(value)) {
26
+ const entries = [];
27
+ for (const entry of value) {
28
+ const converted = toOutputValue(entry);
29
+ if (converted !== void 0) entries.push(converted);
30
+ }
31
+ return entries;
32
+ }
33
+ if (isRecord$1(value)) return objectFromRecord(value);
34
+ }
35
+ function objectFromRecord(record, transformKey = (key) => key) {
36
+ const properties = [];
37
+ for (const [key, value] of Object.entries(record)) {
38
+ const converted = toOutputValue(value);
39
+ if (converted !== void 0) properties.push({
40
+ key: transformKey(key),
41
+ value: converted
42
+ });
43
+ }
44
+ return {
45
+ kind: "object",
46
+ properties
47
+ };
48
+ }
49
+ function snakeToCamel(value) {
50
+ return value.replaceAll(/_([a-z])/g, (_, letter) => letter.toUpperCase());
51
+ }
52
+ function toCamelOutputValue(value) {
53
+ if (isRecord$1(value)) return camelObject(value);
54
+ if (Array.isArray(value)) return value.map(toCamelOutputValue).filter((entry) => entry !== void 0);
55
+ return toOutputValue(value);
56
+ }
57
+ function camelObject(record) {
58
+ const properties = [];
59
+ for (const [key, value] of Object.entries(record)) {
60
+ const converted = toCamelOutputValue(value);
61
+ if (converted !== void 0) properties.push({
62
+ key: snakeToCamel(key),
63
+ value: converted
64
+ });
65
+ }
66
+ return {
67
+ kind: "object",
68
+ properties
69
+ };
70
+ }
71
+ function call(callee, ...args) {
72
+ return {
73
+ args,
74
+ callee,
75
+ kind: "call"
76
+ };
77
+ }
78
+ function optionsFromRecord(record, mappings, includeRemote = false) {
79
+ const properties = [];
80
+ for (const [sourceKey, targetKey] of mappings) {
81
+ const value = toOutputValue(record[sourceKey]);
82
+ if (value !== void 0) properties.push({
83
+ key: targetKey,
84
+ value
85
+ });
86
+ }
87
+ if (includeRemote && typeof record.remote === "boolean") properties.push({
88
+ key: "dev",
89
+ value: {
90
+ kind: "object",
91
+ properties: [{
92
+ key: "remote",
93
+ value: record.remote
94
+ }]
95
+ }
96
+ });
97
+ return {
98
+ kind: "object",
99
+ properties
100
+ };
101
+ }
102
+ function addProperty(properties, source, sourceKey, targetKey = sourceKey, transform = toOutputValue) {
103
+ if (!hasOwn(source, sourceKey)) return;
104
+ const value = transform(source[sourceKey]);
105
+ if (value !== void 0) properties.push({
106
+ key: targetKey,
107
+ value
108
+ });
109
+ }
110
+ // src/cli/cf-config-convert/follow-ups.ts
111
+ const CONFIGURATION_DOCS_URL = `https://developers.cloudflare.com/workers/wrangler/configuration/`;
112
+ const DURABLE_OBJECT_EXPORTS_DOCS_URL = `https://developers.cloudflare.com/workers/runtime-apis/context/#exports`;
113
+ const ENVIRONMENTS_DOCS_URL = `https://developers.cloudflare.com/workers/wrangler/environments/`;
114
+ const PREVIEWS_DOCS_URL = `https://developers.cloudflare.com/workers/wrangler/configuration/#previews`;
115
+ const SECRETS_DOCS_URL = `https://developers.cloudflare.com/workers/configuration/secrets/`;
116
+ const SOURCE_MAPS_DOCS_URL = `https://developers.cloudflare.com/workers/observability/source-maps/`;
117
+ function createFollowUp(code, message, options = {}) {
118
+ return {
119
+ blocking: options.blocking ?? true,
120
+ code,
121
+ docsUrl: options.docsUrl,
122
+ message,
123
+ sourcePath: options.sourcePath
124
+ };
125
+ }
126
+ function followUpToComment(followUp) {
127
+ return {
128
+ docsUrl: followUp.docsUrl,
129
+ message: followUp.message
130
+ };
131
+ }
132
+ function deduplicateFollowUps(followUps) {
133
+ const seen = /* @__PURE__ */ new Set();
134
+ return followUps.filter((followUp) => {
135
+ const key = [
136
+ followUp.code,
137
+ followUp.sourcePath,
138
+ followUp.message
139
+ ].join("\0");
140
+ if (seen.has(key)) return false;
141
+ seen.add(key);
142
+ return true;
143
+ });
144
+ }
145
+ // src/cli/cf-config-convert/durable-object-exports.ts
146
+ /**
147
+ * Replays Wrangler migration history into declarative Durable Object exports.
148
+ * Explicit exports take precedence, and bindings to other Workers do not
149
+ * declare exports in this Worker.
150
+ *
151
+ * @param source Raw Worker configuration, with environment overrides applied.
152
+ * @param sourcePrefix The source environment's path for follow-up diagnostics.
153
+ * @param report Reports configuration that cannot be inferred automatically.
154
+ * @returns Inferred lifecycle declarations merged with explicit exports.
155
+ */
156
+ function inferDurableObjectExports(source, sourcePrefix, report) {
157
+ const prefix = sourcePrefix ? `${sourcePrefix}.` : "";
158
+ const { inferred, locations } = replayDurableObjectMigrations(source, prefix);
159
+ const configured = getRecord(source, "exports") ?? {};
160
+ const exports = {
161
+ ...Object.fromEntries(inferred),
162
+ ...configured
163
+ };
164
+ reportUnresolvedExports(exports, configured, locations, prefix, report);
165
+ reportMissingLocalExports(source, exports, prefix, report);
166
+ return exports;
167
+ }
168
+ function replayDurableObjectMigrations(source, prefix) {
169
+ const inferred = /* @__PURE__ */ new Map();
170
+ const locations = /* @__PURE__ */ new Map();
171
+ for (const [index, migration] of getRecords(source, "migrations").entries()) {
172
+ const sourcePath = `${prefix}migrations[${index}]`;
173
+ applyDeletedClasses(migration, inferred);
174
+ applyRenamedClasses(migration, sourcePath, inferred, locations);
175
+ applyCreatedClasses(migration, sourcePath, inferred, locations);
176
+ applyTransferredClasses(migration, sourcePath, inferred, locations);
177
+ }
178
+ return {
179
+ inferred,
180
+ locations
181
+ };
182
+ }
183
+ function applyCreatedClasses(migration, sourcePath, inferred, locations) {
184
+ for (const [field, storage] of [["new_classes", "legacy-kv"], ["new_sqlite_classes", "sqlite"]]) for (const name of getStrings(migration, field)) {
185
+ inferred.set(name, {
186
+ storage,
187
+ type: "durable-object"
188
+ });
189
+ locations.set(name, { sourcePath: `${sourcePath}.${field}` });
190
+ }
191
+ }
192
+ function applyRenamedClasses(migration, sourcePath, inferred, locations) {
193
+ for (const rename of getRecords(migration, "renamed_classes")) {
194
+ if (typeof rename.from !== "string" || typeof rename.to !== "string") continue;
195
+ const previous = inferred.get(rename.from);
196
+ const location = locations.get(rename.from);
197
+ for (const value of inferred.values()) if (value.state === "renamed" && value.renamed_to === rename.from) value.renamed_to = rename.to;
198
+ inferred.set(rename.from, {
199
+ renamed_to: rename.to,
200
+ state: "renamed",
201
+ type: "durable-object"
202
+ });
203
+ inferred.set(rename.to, {
204
+ storage: previous?.storage,
205
+ type: "durable-object"
206
+ });
207
+ locations.set(rename.to, location?.transfer ? location : { sourcePath: `${sourcePath}.renamed_classes` });
208
+ }
209
+ }
210
+ function applyTransferredClasses(migration, sourcePath, inferred, locations) {
211
+ for (const [index, transfer] of getRecords(migration, "transferred_classes").entries()) {
212
+ if (typeof transfer.to !== "string") continue;
213
+ inferred.set(transfer.to, { type: "durable-object" });
214
+ locations.set(transfer.to, {
215
+ sourcePath: `${sourcePath}.transferred_classes[${index}]`,
216
+ transfer
217
+ });
218
+ }
219
+ }
220
+ function applyDeletedClasses(migration, inferred) {
221
+ for (const name of getStrings(migration, "deleted_classes")) {
222
+ for (const value of inferred.values()) if (value.state === "renamed" && value.renamed_to === name) {
223
+ delete value.renamed_to;
224
+ value.state = "deleted";
225
+ }
226
+ inferred.set(name, {
227
+ state: "deleted",
228
+ type: "durable-object"
229
+ });
230
+ }
231
+ }
232
+ function reportUnresolvedExports(exports, configured, locations, prefix, report) {
233
+ for (const [name, value] of Object.entries(exports)) {
234
+ if (!isRecord$1(value) || value.type !== "durable-object" || value.state !== void 0 && value.state !== "created" && value.state !== "expecting-transfer") continue;
235
+ const location = locations.get(name);
236
+ if (location?.transfer && !hasOwn(configured, name)) {
237
+ reportUnresolvedTransfer(name, location.transfer, location.sourcePath, report);
238
+ continue;
239
+ }
240
+ if (value.storage === "sqlite" || value.storage === "legacy-kv") continue;
241
+ report(createFollowUp("durable-object-storage", `The storage backend for Durable Object \`${name}\` is missing or unsupported. Set \`storage\` to \`"sqlite"\` or \`"legacy-kv"\` in its export. Renames require the original class's creation migration.`, {
242
+ docsUrl: DURABLE_OBJECT_EXPORTS_DOCS_URL,
243
+ sourcePath: isRecord$1(configured[name]) ? `${prefix}exports.${name}` : location?.sourcePath
244
+ }));
245
+ }
246
+ }
247
+ function reportUnresolvedTransfer(name, transfer, sourcePath, report) {
248
+ report(createFollowUp("durable-object-transfer", `The migration transfers Durable Object \`${String(transfer.from)}\` from Worker \`${String(transfer.from_script)}\` to \`${String(transfer.to)}\` (current class: \`${name}\`). Whether it has been deployed cannot be determined from this config. If completed, keep a live export for \`${name}\` with its existing storage backend. If pending, coordinate a two-phase transfer with the source Worker using \`state: "expecting-transfer"\`, \`transferFrom: ${JSON.stringify(transfer.from_script)}\`, and matching storage. The transfer requires matching class names; perform any rename separately. Setting storage alone does not complete a pending transfer.`, {
249
+ docsUrl: "https://developers.cloudflare.com/durable-objects/reference/durable-objects-migrations/#transfer-a-durable-object-class-between-workers",
250
+ sourcePath
251
+ }));
252
+ }
253
+ function reportMissingLocalExports(source, exports, prefix, report) {
254
+ const durableObjects = getRecord(source, "durable_objects");
255
+ for (const [index, binding] of getRecords(durableObjects ?? {}, "bindings").entries()) {
256
+ let worker = typeof binding.script_name === "string" ? binding.script_name : source.name;
257
+ if (typeof binding.environment === "string") worker = `${String(worker)}-${binding.environment}`;
258
+ if (worker !== source.name || typeof binding.class_name !== "string" || binding.class_name.length === 0) continue;
259
+ const value = exports[binding.class_name];
260
+ if (isRecord$1(value) && value.type === "durable-object" && (value.state === void 0 || value.state === "created" || value.state === "expecting-transfer")) continue;
261
+ report(createFollowUp("durable-object-export", `The local Durable Object binding \`${String(binding.name)}\` references \`${binding.class_name}\`, but no live export could be inferred. Verify its \`class_name\`, then add its creation migration or declare a live export with the correct storage backend.`, {
262
+ docsUrl: DURABLE_OBJECT_EXPORTS_DOCS_URL,
263
+ sourcePath: `${prefix}durable_objects.bindings[${index}]`
264
+ }));
265
+ }
266
+ }
267
+ // src/cli/cf-config-convert/exports.ts
268
+ const WORKFLOW_SETTINGS = [
269
+ "limits",
270
+ "concurrency",
271
+ "schedules",
272
+ "default_retention",
273
+ "jurisdiction"
274
+ ];
275
+ /**
276
+ * Whether this Worker defines the Workflow a `workflows` entry binds to. This
277
+ * matches Wrangler's `isWorkflowDefinedInThisScript`: no `script_name`, or a
278
+ * `script_name` naming this Worker. `source.name` is already the effective
279
+ * name in a named environment (`<name>-<environment>`).
280
+ */
281
+ function isLocalWorkflow(entry, source) {
282
+ return typeof entry.script_name !== "string" || entry.script_name === source.name;
283
+ }
284
+ /**
285
+ * Options for `exports.workflow(...)`, from either a Wrangler `exports`
286
+ * entry of type "workflow" or a `workflows` binding entry. Both carry the
287
+ * same snake_case settings, and the new config spells the nested retention
288
+ * keys in camelCase (`defaultRetention.successRetention`).
289
+ */
290
+ function workflowExportOptions(record) {
291
+ const properties = [];
292
+ const name = toOutputValue(record.name);
293
+ if (name !== void 0) properties.push({
294
+ key: "name",
295
+ value: name
296
+ });
297
+ for (const key of ["limits", "concurrency"]) {
298
+ const value = getRecord(record, key);
299
+ if (value) properties.push({
300
+ key,
301
+ value: camelObject(value)
302
+ });
303
+ }
304
+ const events = getRecords(record, "events");
305
+ if (events.length > 0) properties.push({
306
+ key: "events",
307
+ value: events.map(camelObject)
308
+ });
309
+ const schedules = toOutputValue(record.schedules);
310
+ if (schedules !== void 0) properties.push({
311
+ key: "schedules",
312
+ value: schedules
313
+ });
314
+ const retention = getRecord(record, "default_retention");
315
+ if (retention) properties.push({
316
+ key: "defaultRetention",
317
+ value: camelObject(retention)
318
+ });
319
+ const jurisdiction = toOutputValue(record.jurisdiction);
320
+ if (jurisdiction !== void 0) properties.push({
321
+ key: "jurisdiction",
322
+ value: jurisdiction
323
+ });
324
+ return {
325
+ kind: "object",
326
+ properties
327
+ };
328
+ }
329
+ /** Attaches legacy targets to the exports that actually own the Workflows. */
330
+ function attachWorkflowEvents(source, sourcePrefix, exports, report) {
331
+ const events = getRecord(source, "triggers")?.events;
332
+ if (!Array.isArray(events)) return;
333
+ for (const [index, event] of events.entries()) {
334
+ const sourcePath = `${sourcePrefix ? sourcePrefix + "." : ""}triggers.events.${index}`;
335
+ if (!isRecord$1(event) || typeof event.type !== "string" || !Array.isArray(event.targets) || event.targets.length === 0 || event.filter !== void 0 && !isRecord$1(event.filter)) {
336
+ report(createFollowUp("invalid-workflow-event", "This event subscription could not be migrated. Review its type, filter, and Workflow targets.", { sourcePath }));
337
+ continue;
338
+ }
339
+ for (const [targetIndex, target] of event.targets.entries()) {
340
+ const owned = isRecord$1(target) && target.type === "workflow" ? [...exports.values()].filter((workflow) => workflow.name === target.workflow_name) : [];
341
+ if (owned.length !== 1) {
342
+ report(createFollowUp("workflow-event-target", "This event target does not identify one Workflow export owned by this Worker. Its subscription was not migrated.", { sourcePath: `${sourcePath}.targets.${targetIndex}` }));
343
+ continue;
344
+ }
345
+ const workflow = owned[0];
346
+ workflow.events = [...getRecords(workflow, "events"), {
347
+ type: event.type,
348
+ ...event.filter === void 0 ? {} : { filter: event.filter }
349
+ }];
350
+ }
351
+ }
352
+ }
353
+ function convertExports(source, sourcePrefix, imports, report) {
354
+ const configuredExports = inferDurableObjectExports(source, sourcePrefix, report);
355
+ const properties = [];
356
+ const workflowExports = /* @__PURE__ */ new Map();
357
+ const pendingWorkflows = [];
358
+ function addWorkflowExport(key, record) {
359
+ const property = {
360
+ key,
361
+ value: call("exports.workflow")
362
+ };
363
+ properties.push(property);
364
+ workflowExports.set(key, record);
365
+ pendingWorkflows.push([property, record]);
366
+ }
367
+ for (const [name, value] of Object.entries(configuredExports)) {
368
+ if (!isRecord$1(value)) continue;
369
+ const sourcePath = `${sourcePrefix ? `${sourcePrefix}.` : ""}exports.${name}`;
370
+ if (value.type === "worker") {
371
+ imports.add("exports");
372
+ const args = getRecord(value, "cache");
373
+ properties.push({
374
+ key: name,
375
+ value: args ? call("exports.worker", {
376
+ kind: "object",
377
+ properties: [{
378
+ key: "cache",
379
+ value: camelObject(args)
380
+ }]
381
+ }) : call("exports.worker")
382
+ });
383
+ continue;
384
+ }
385
+ if (value.type === "durable-object") {
386
+ imports.add("exports");
387
+ const options = optionsFromRecord(value, [
388
+ ["renamed_to", "renamedTo"],
389
+ ["state", "state"],
390
+ ["storage", "storage"],
391
+ ["transfer_from", "transferFrom"],
392
+ ["transferred_to", "transferredTo"]
393
+ ]);
394
+ properties.push({
395
+ key: name,
396
+ value: call("exports.durableObject", options)
397
+ });
398
+ if (hasOwn(value, "container")) report(createFollowUp("container-review", "A Durable Object export references a Container. Reconnect it manually after migrating the Container.", { sourcePath }));
399
+ continue;
400
+ }
401
+ if (value.type === "workflow") {
402
+ imports.add("exports");
403
+ addWorkflowExport(name, { ...value });
404
+ continue;
405
+ }
406
+ report(createFollowUp("unsupported-export", `The export \`${name}\` could not be migrated.`, { sourcePath }));
407
+ }
408
+ for (const [index, entry] of getRecords(source, "workflows").entries()) {
409
+ if (!isLocalWorkflow(entry, source) || typeof entry.class_name !== "string" || entry.class_name.length === 0) continue;
410
+ const existing = workflowExports.get(entry.class_name);
411
+ if (existing === void 0) {
412
+ imports.add("exports");
413
+ addWorkflowExport(entry.class_name, { ...entry });
414
+ continue;
415
+ }
416
+ if (existing.name === entry.name) {
417
+ for (const key of WORKFLOW_SETTINGS) if (hasOwn(entry, key)) existing[key] = entry[key];
418
+ continue;
419
+ }
420
+ const lost = WORKFLOW_SETTINGS.filter((key) => hasOwn(entry, key));
421
+ if (lost.length > 0) {
422
+ const sourcePath = `${sourcePrefix ? `${sourcePrefix}.` : ""}workflows.${index}`;
423
+ report(createFollowUp("workflow-shared-class", `The Workflow \`${String(entry.name)}\` at \`${sourcePath}\` uses the class \`${entry.class_name}\`, which already exports the Workflow \`${String(existing.name)}\`. The new config declares one Workflow per exported class, so its ${lost.map((key) => `\`${key}\``).join(", ")} were not migrated.`, { sourcePath }));
424
+ }
425
+ }
426
+ attachWorkflowEvents(source, sourcePrefix, workflowExports, report);
427
+ for (const [property, record] of pendingWorkflows) property.value = call("exports.workflow", workflowExportOptions(record));
428
+ return properties.length > 0 ? {
429
+ kind: "object",
430
+ properties
431
+ } : void 0;
432
+ }
433
+ // src/cli/cf-config-convert/bindings.ts
434
+ /** Written in place of a legacy pipeline name, which isn't a stream ID. */
435
+ const LEGACY_PIPELINE_STREAM_ID_PLACEHOLDER = "STREAM_ID";
436
+ function addBinding(bindings, name, value, sourcePath, report) {
437
+ if (typeof name !== "string" || name.length === 0) {
438
+ report(createFollowUp("invalid-binding", `A binding at \`${sourcePath}\` has no valid binding name and was not migrated.`, { sourcePath }));
439
+ return;
440
+ }
441
+ if (bindings.has(name)) {
442
+ report(createFollowUp("binding-name-collision", `Multiple Wrangler bindings use the name \`${name}\`. Resolve the collision manually.`, { sourcePath }));
443
+ return;
444
+ }
445
+ bindings.set(name, value);
446
+ }
447
+ function reportUnsupportedOptions(record, keys, sourcePath, report) {
448
+ const present = keys.filter((key) => hasOwn(record, key));
449
+ if (present.length === 0) return;
450
+ report(createFollowUp("unsupported-binding-options", `The options ${present.map((key) => `\`${key}\``).join(", ")} at \`${sourcePath}\` require manual migration.`, { sourcePath }));
451
+ }
452
+ function convertBindings(source, sourcePrefix, imports, report) {
453
+ const bindings = /* @__PURE__ */ new Map();
454
+ const pathFor = (field, index) => [
455
+ sourcePrefix,
456
+ field,
457
+ index
458
+ ].filter((part) => part !== void 0 && part !== "").join(".");
459
+ const vars = getRecord(source, "vars");
460
+ if (vars) for (const [name, value] of Object.entries(vars)) {
461
+ imports.add("bindings");
462
+ addBinding(bindings, name, typeof value === "string" ? call("bindings.text", value) : call("bindings.json", toOutputValue(value) ?? null), pathFor("vars"), report);
463
+ }
464
+ const secrets = getRecord(source, "secrets");
465
+ if (secrets) for (const name of getStrings(secrets, "required")) {
466
+ imports.add("bindings");
467
+ addBinding(bindings, name, call("bindings.secret"), pathFor("secrets.required"), report);
468
+ }
469
+ function convertArrayBindings(field, nameKey, callee, mappings, options = {}) {
470
+ for (const [index, entry] of getRecords(source, field).entries()) {
471
+ imports.add("bindings");
472
+ const sourcePath = pathFor(field, index);
473
+ addBinding(bindings, entry[nameKey], call(callee, optionsFromRecord(entry, mappings, options.remote)), sourcePath, report);
474
+ reportUnsupportedOptions(entry, options.unsupported ?? [], sourcePath, report);
475
+ }
476
+ }
477
+ convertArrayBindings("agent_memory", "binding", "bindings.agentMemory", [["namespace", "namespace"]], { remote: true });
478
+ convertArrayBindings("ai_search", "binding", "bindings.aiSearch", [["instance_name", "name"]], { remote: true });
479
+ convertArrayBindings("ai_search_namespaces", "binding", "bindings.aiSearchNamespace", [["namespace", "namespace"]], { remote: true });
480
+ convertArrayBindings("analytics_engine_datasets", "binding", "bindings.analyticsEngineDataset", [["dataset", "name"]], { remote: true });
481
+ convertArrayBindings("artifacts", "binding", "bindings.artifacts", [["namespace", "namespace"]], { remote: true });
482
+ convertArrayBindings("d1_databases", "binding", "bindings.d1", [["database_name", "name"], ["database_id", "id"]], {
483
+ remote: true,
484
+ unsupported: [
485
+ "database_internal_env",
486
+ "migrations_dir",
487
+ "migrations_pattern",
488
+ "migrations_table",
489
+ "preview_database_id"
490
+ ]
491
+ });
492
+ convertArrayBindings("flagship", "binding", "bindings.flagship", [["app_id", "id"]], { remote: true });
493
+ for (const [index, entry] of getRecords(source, "hyperdrive").entries()) {
494
+ const options = optionsFromRecord(entry, [["id", "id"]]);
495
+ const sourcePath = pathFor("hyperdrive", index);
496
+ const localConnectionString = entry.localConnectionString;
497
+ if (typeof localConnectionString === "string") options.properties.push({
498
+ key: "dev",
499
+ value: objectFromRecord({ connectionString: localConnectionString })
500
+ });
501
+ else reportUnsupportedOptions(entry, ["localConnectionString"], sourcePath, report);
502
+ imports.add("bindings");
503
+ addBinding(bindings, entry.binding, call("bindings.hyperdrive", options), sourcePath, report);
504
+ }
505
+ convertArrayBindings("k2", "binding", "bindings.k2", [["stream", "id"]], { remote: true });
506
+ convertArrayBindings("kv_namespaces", "binding", "bindings.kv", [["id", "id"]], {
507
+ remote: true,
508
+ unsupported: ["preview_id"]
509
+ });
510
+ convertArrayBindings("mtls_certificates", "binding", "bindings.mtlsCertificate", [["certificate_id", "id"]], { remote: true });
511
+ for (const [index, entry] of getRecords(source, "pipelines").entries()) {
512
+ const sourcePath = pathFor("pipelines", index);
513
+ const isLegacy = entry.stream === void 0 && entry.pipeline !== void 0;
514
+ const options = optionsFromRecord({
515
+ ...entry,
516
+ streamId: isLegacy ? LEGACY_PIPELINE_STREAM_ID_PLACEHOLDER : entry.stream
517
+ }, [["streamId", "streamId"]], true);
518
+ if (isLegacy) {
519
+ const followUp = createFollowUp("legacy-pipeline-binding", `The Pipelines binding at \`${sourcePath}\` used the deprecated \`pipeline\` field, which names a legacy pipeline. Set \`streamId\` to the ID of the stream to write to.`, { sourcePath });
520
+ report(followUp, { inline: true });
521
+ const streamId = options.properties.find((property) => property.key === "streamId");
522
+ if (streamId) streamId.comments = [followUpToComment(followUp)];
523
+ }
524
+ imports.add("bindings");
525
+ addBinding(bindings, entry.binding, call("bindings.pipeline", options), sourcePath, report);
526
+ }
527
+ for (const [index, entry] of getRecords(source, "r2_buckets").entries()) {
528
+ const options = optionsFromRecord(entry, [["bucket_name", "name"], ["jurisdiction", "jurisdiction"]]);
529
+ const sourcePath = pathFor("r2_buckets", index);
530
+ const dev = {};
531
+ if (typeof entry.remote === "boolean") dev.remote = entry.remote;
532
+ const localDev = getRecord(entry, "local_dev");
533
+ const credentials = localDev && getRecord(localDev, "experimental_s3_credentials");
534
+ const hasValidCredentials = credentials !== void 0 && typeof credentials.accessKeyId === "string" && typeof credentials.secretAccessKey === "string";
535
+ if (hasValidCredentials) dev.experimentalS3Credentials = {
536
+ accessKeyId: credentials.accessKeyId,
537
+ secretAccessKey: credentials.secretAccessKey
538
+ };
539
+ const hasUnsupportedLocalDevOptions = localDev !== void 0 && Object.keys(localDev).some((key) => key !== "experimental_s3_credentials");
540
+ if (hasOwn(entry, "local_dev") && (!localDev || hasUnsupportedLocalDevOptions || hasOwn(localDev, "experimental_s3_credentials") && !hasValidCredentials)) reportUnsupportedOptions(entry, ["local_dev"], sourcePath, report);
541
+ if (Object.keys(dev).length > 0) options.properties.push({
542
+ key: "dev",
543
+ value: objectFromRecord(dev)
544
+ });
545
+ imports.add("bindings");
546
+ addBinding(bindings, entry.binding, call("bindings.r2", options), sourcePath, report);
547
+ if (hasOwn(entry, "preview_bucket_name") && entry.preview_bucket_name !== entry.bucket_name) reportUnsupportedOptions(entry, ["preview_bucket_name"], sourcePath, report);
548
+ }
549
+ convertArrayBindings("secrets_store_secrets", "binding", "bindings.secretsStoreSecret", [["store_id", "storeId"], ["secret_name", "secretName"]]);
550
+ convertArrayBindings("vectorize", "binding", "bindings.vectorize", [["index_name", "name"]], { remote: true });
551
+ convertArrayBindings("vpc_services", "binding", "bindings.vpcService", [["service_id", "id"]], { remote: true });
552
+ convertArrayBindings("vpc_networks", "binding", "bindings.vpcNetwork", [["tunnel_id", "tunnelId"], ["network_id", "networkId"]], { remote: true });
553
+ for (const [index, entry] of getRecords(source, "dispatch_namespaces").entries()) {
554
+ const options = optionsFromRecord(entry, [["namespace", "namespace"]], true);
555
+ const outbound = getRecord(entry, "outbound");
556
+ if (outbound) {
557
+ const outboundTarget = { ...outbound };
558
+ if (typeof outbound.service === "string" && typeof outbound.environment === "string") outboundTarget.service = `${outbound.service}-${outbound.environment}`;
559
+ const outboundOptions = optionsFromRecord(outboundTarget, [["service", "worker"], ["parameters", "parameters"]]);
560
+ options.properties.push({
561
+ key: "outbound",
562
+ value: outboundOptions
563
+ });
564
+ if (hasOwn(outbound, "environment")) report(createFollowUp("service-environment", "A dispatch namespace uses a legacy service environment. Verify its target Worker name.", { sourcePath: pathFor("dispatch_namespaces", index) }));
565
+ }
566
+ imports.add("bindings");
567
+ addBinding(bindings, entry.binding, call("bindings.dispatchNamespace", options), pathFor("dispatch_namespaces", index), report);
568
+ }
569
+ for (const [index, entry] of getRecords(source, "send_email").entries()) {
570
+ imports.add("bindings");
571
+ addBinding(bindings, entry.name, call("bindings.sendEmail", optionsFromRecord(entry, [
572
+ ["destination_address", "destinationAddress"],
573
+ ["allowed_destination_addresses", "allowedDestinationAddresses"],
574
+ ["allowed_sender_addresses", "allowedSenderAddresses"]
575
+ ], true)), pathFor("send_email", index), report);
576
+ }
577
+ const queues = getRecord(source, "queues");
578
+ if (queues) for (const [index, entry] of getRecords(queues, "producers").entries()) {
579
+ imports.add("bindings");
580
+ addBinding(bindings, entry.binding, call("bindings.queue", optionsFromRecord(entry, [["queue", "name"], ["delivery_delay", "deliveryDelay"]], true)), pathFor("queues.producers", index), report);
581
+ }
582
+ for (const [index, entry] of getRecords(source, "services").entries()) {
583
+ let worker = entry.service;
584
+ if (typeof entry.environment === "string" && typeof worker === "string") {
585
+ worker = `${worker}-${entry.environment}`;
586
+ report(createFollowUp("service-environment", "A service binding used a legacy service environment. Verify the generated Worker name.", { sourcePath: pathFor("services", index) }));
587
+ }
588
+ const service = {
589
+ ...entry,
590
+ service: worker
591
+ };
592
+ imports.add("bindings");
593
+ addBinding(bindings, entry.binding, call("bindings.worker", optionsFromRecord(service, [
594
+ ["service", "worker"],
595
+ ["entrypoint", "exportName"],
596
+ ["props", "props"]
597
+ ], true)), pathFor("services", index), report);
598
+ }
599
+ const durableObjects = getRecord(source, "durable_objects");
600
+ if (durableObjects) {
601
+ reportUnsupportedOptions(durableObjects, ["code_update_strategy"], pathFor("durable_objects"), report);
602
+ for (const [index, entry] of getRecords(durableObjects, "bindings").entries()) {
603
+ let worker = typeof entry.script_name === "string" ? entry.script_name : typeof source.name === "string" ? source.name : "TODO";
604
+ if (typeof entry.environment === "string") worker = `${worker}-${entry.environment}`;
605
+ const sourcePath = pathFor(`durable_objects.bindings[${index}]`);
606
+ imports.add("bindings");
607
+ addBinding(bindings, entry.name, call("bindings.durableObject", optionsFromRecord({
608
+ export_name: entry.class_name,
609
+ worker
610
+ }, [["worker", "worker"], ["export_name", "exportName"]])), sourcePath, report);
611
+ if (typeof entry.class_name !== "string" || entry.class_name.length === 0) report(createFollowUp("durable-object-missing-class", `The Durable Object binding at \`${sourcePath}\` has no \`class_name\`. Set it to the class exported by the Worker.`, {
612
+ docsUrl: DURABLE_OBJECT_EXPORTS_DOCS_URL,
613
+ sourcePath
614
+ }));
615
+ }
616
+ }
617
+ const workflows = getRecords(source, "workflows");
618
+ if (workflows.length > 0) for (const [index, entry] of workflows.entries()) {
619
+ const sourcePath = pathFor("workflows", index);
620
+ if (typeof entry.class_name !== "string" || entry.class_name.length === 0) {
621
+ report(createFollowUp("workflow-missing-class", `The Workflow binding at \`${sourcePath}\` has no \`class_name\` and was not migrated.`, { sourcePath }));
622
+ continue;
623
+ }
624
+ const external = !isLocalWorkflow(entry, source);
625
+ const worker = external ? String(entry.script_name) : typeof source.name === "string" ? source.name : "TODO";
626
+ imports.add("bindings");
627
+ addBinding(bindings, entry.binding, call("bindings.workflow", optionsFromRecord({
628
+ name: entry.name,
629
+ worker,
630
+ export_name: entry.class_name
631
+ }, [
632
+ ["name", "name"],
633
+ ["worker", "worker"],
634
+ ["export_name", "exportName"]
635
+ ])), sourcePath, report);
636
+ if (external) reportUnsupportedOptions(entry, WORKFLOW_SETTINGS, sourcePath, report);
637
+ }
638
+ function convertSingletonBinding(field, nameKey, callee, unsupported = []) {
639
+ const entry = getRecord(source, field);
640
+ if (!entry) return;
641
+ imports.add("bindings");
642
+ addBinding(bindings, entry[nameKey], call(callee, optionsFromRecord(entry, [], true)), pathFor(field), report);
643
+ reportUnsupportedOptions(entry, unsupported, pathFor(field), report);
644
+ }
645
+ convertSingletonBinding("ai", "binding", "bindings.ai", ["staging"]);
646
+ convertSingletonBinding("analytics", "binding", "bindings.analyticsSql");
647
+ convertSingletonBinding("browser", "binding", "bindings.browser");
648
+ convertSingletonBinding("images", "binding", "bindings.images");
649
+ convertSingletonBinding("media", "binding", "bindings.media");
650
+ convertSingletonBinding("stream", "binding", "bindings.stream");
651
+ const versionMetadata = getRecord(source, "version_metadata");
652
+ if (versionMetadata) {
653
+ imports.add("bindings");
654
+ addBinding(bindings, versionMetadata.binding, call("bindings.versionMetadata"), pathFor("version_metadata"), report);
655
+ }
656
+ for (const [index, entry] of getRecords(source, "ratelimits").entries()) {
657
+ imports.add("bindings");
658
+ addBinding(bindings, entry.name, call("bindings.rateLimit", optionsFromRecord(entry, [["namespace_id", "namespace"], ["simple", "simple"]])), pathFor("ratelimits", index), report);
659
+ }
660
+ for (const [index, entry] of getRecords(source, "worker_loaders").entries()) {
661
+ imports.add("bindings");
662
+ addBinding(bindings, entry.binding, call("bindings.workerLoader"), pathFor("worker_loaders", index), report);
663
+ }
664
+ const logfwdr = getRecord(source, "logfwdr");
665
+ if (logfwdr) for (const [index, entry] of getRecords(logfwdr, "bindings").entries()) {
666
+ imports.add("bindings");
667
+ addBinding(bindings, entry.name, call("bindings.logfwdr", optionsFromRecord(entry, [["destination", "destination"]])), pathFor("logfwdr.bindings", index), report);
668
+ }
669
+ const unsafe = getRecord(source, "unsafe");
670
+ if (unsafe) for (const [index, entry] of getRecords(unsafe, "bindings").entries()) {
671
+ const type = entry.type;
672
+ const output = objectFromRecord({
673
+ ...entry,
674
+ type: `unsafe:${String(type)}`
675
+ });
676
+ output.properties = output.properties.filter(({ key }) => key !== "name");
677
+ addBinding(bindings, entry.name, output, pathFor("unsafe.bindings", index), report);
678
+ }
679
+ const assets = getRecord(source, "assets");
680
+ if (assets && typeof assets.binding === "string") {
681
+ imports.add("bindings");
682
+ addBinding(bindings, assets.binding, call("bindings.assets"), pathFor("assets.binding"), report);
683
+ }
684
+ if (bindings.size === 0) return;
685
+ return {
686
+ kind: "object",
687
+ properties: [...bindings].map(([key, value]) => ({
688
+ key,
689
+ value
690
+ }))
691
+ };
692
+ }
693
+ // src/cli/cf-config-convert/triggers.ts
694
+ function convertTriggers(source, sourcePrefix, imports, report) {
695
+ const domains = [];
696
+ const converted = [];
697
+ const routes = [...hasOwn(source, "route") ? [source.route] : [], ...Array.isArray(source.routes) ? source.routes : []];
698
+ for (const [index, route] of routes.entries()) {
699
+ if (typeof route === "string") {
700
+ imports.add("triggers");
701
+ converted.push(call("triggers.fetch", {
702
+ kind: "object",
703
+ properties: [{
704
+ key: "pattern",
705
+ value: route
706
+ }]
707
+ }));
708
+ continue;
709
+ }
710
+ if (!isRecord$1(route) || typeof route.pattern !== "string") {
711
+ report(createFollowUp("invalid-route", "A Wrangler route could not be migrated.", { sourcePath: `${sourcePrefix || "config"}.routes.${index}` }));
712
+ continue;
713
+ }
714
+ if (route.custom_domain === true) {
715
+ domains.push(route.pattern);
716
+ if (hasOwn(route, "enabled") || hasOwn(route, "previews_enabled") || hasOwn(route, "zone_id") || hasOwn(route, "zone_name")) report(createFollowUp("custom-domain-options", "Custom-domain route options require manual review.", { sourcePath: `${sourcePrefix || "config"}.routes.${index}` }));
717
+ continue;
718
+ }
719
+ imports.add("triggers");
720
+ const options = [{
721
+ key: "pattern",
722
+ value: route.pattern
723
+ }];
724
+ if (typeof route.zone_name === "string") options.push({
725
+ key: "zone",
726
+ value: route.zone_name
727
+ });
728
+ else if (typeof route.zone_id === "string") {
729
+ options.push({
730
+ key: "zone",
731
+ value: route.zone_id
732
+ });
733
+ report(createFollowUp("zone-id-route", "A route uses a zone ID. Verify the generated fetch trigger target.", { sourcePath: `${sourcePrefix || "config"}.routes.${index}` }));
734
+ }
735
+ converted.push(call("triggers.fetch", {
736
+ kind: "object",
737
+ properties: options
738
+ }));
739
+ }
740
+ const triggerConfig = getRecord(source, "triggers");
741
+ if (triggerConfig) for (const schedule of getStrings(triggerConfig, "crons")) {
742
+ imports.add("triggers");
743
+ converted.push(call("triggers.scheduled", {
744
+ kind: "object",
745
+ properties: [{
746
+ key: "schedule",
747
+ value: schedule
748
+ }]
749
+ }));
750
+ }
751
+ const queues = getRecord(source, "queues");
752
+ if (queues) for (const consumer of getRecords(queues, "consumers")) {
753
+ imports.add("triggers");
754
+ converted.push(call("triggers.queue", optionsFromRecord(consumer, [
755
+ ["dead_letter_queue", "deadLetterQueue"],
756
+ ["max_batch_size", "maxBatchSize"],
757
+ ["max_batch_timeout", "maxBatchTimeout"],
758
+ ["max_concurrency", "maxConcurrency"],
759
+ ["max_retries", "maxRetries"],
760
+ ["queue", "name"],
761
+ ["retry_delay", "retryDelay"],
762
+ ["visibility_timeout_ms", "visibilityTimeoutMs"]
763
+ ])));
764
+ }
765
+ for (const connection of getRecords(source, "connect")) {
766
+ imports.add("triggers");
767
+ converted.push(call("triggers.connect", camelObject(connection)));
768
+ }
769
+ const addresses = getStrings(source, "addresses");
770
+ if (Array.isArray(source.addresses)) {
771
+ imports.add("triggers");
772
+ converted.push(call("triggers.email", {
773
+ kind: "object",
774
+ properties: [{
775
+ key: "addresses",
776
+ value: addresses
777
+ }]
778
+ }));
779
+ }
780
+ return {
781
+ domains: domains.length > 0 ? domains : void 0,
782
+ triggers: converted.length > 0 ? converted : void 0
783
+ };
784
+ }
785
+ // src/cli/cf-config-convert/worker-config.ts
786
+ const DEPENDENCIES_INSTRUMENTATION_ENV_VAR = "CLOUDFLARE_DEPENDENCIES_INSTRUMENTATION";
787
+ function isDependenciesInstrumentationConfig(value) {
788
+ if (!isRecord$1(value)) return false;
789
+ return (value.enabled === void 0 || typeof value.enabled === "boolean") && (value.exclude_packages === void 0 || Array.isArray(value.exclude_packages) && value.exclude_packages.every((packageName) => typeof packageName === "string"));
790
+ }
791
+ function createDependenciesInstrumentationFollowUp(source, sourcePrefix) {
792
+ if (!hasOwn(source, "dependencies_instrumentation")) return;
793
+ const sourcePath = `${sourcePrefix ? `${sourcePrefix}.` : ""}dependencies_instrumentation`;
794
+ const instrumentation = source.dependencies_instrumentation;
795
+ if (!isDependenciesInstrumentationConfig(instrumentation)) return createFollowUp("unsupported-field", "The dependency instrumentation configuration is invalid and was not migrated.", { sourcePath });
796
+ const hasExcludedPackages = (instrumentation.exclude_packages?.length ?? 0) > 0;
797
+ if (instrumentation.enabled === false) return createFollowUp("dependencies-instrumentation-opt-out", `Set ${DEPENDENCIES_INSTRUMENTATION_ENV_VAR}=false before deploying to keep package dependency metadata disabled.${hasExcludedPackages ? " The package exclusion list was not migrated; if dependency metadata is later enabled, those packages will be included." : ""}`, { sourcePath });
798
+ if (hasExcludedPackages) return createFollowUp("dependencies-instrumentation-exclusions", `Package dependency exclusions cannot be migrated. ${DEPENDENCIES_INSTRUMENTATION_ENV_VAR} only enables or disables dependency metadata as a whole.`, { sourcePath });
799
+ }
800
+ function convertWorkerConfig(source, sourcePrefix, bundler, imports, followUps) {
801
+ const properties = [];
802
+ const comments = [];
803
+ const report = (followUp, options = {}) => {
804
+ followUps.push(followUp);
805
+ if (!options.inline) comments.push(followUpToComment(followUp));
806
+ };
807
+ if (typeof source.name === "string") properties.push({
808
+ key: "name",
809
+ value: source.name
810
+ });
811
+ else {
812
+ const followUp = createFollowUp("missing-name", "Wrangler config has no Worker name. Replace the generated placeholder.", { sourcePath: sourcePrefix ? `${sourcePrefix}.name` : "name" });
813
+ followUps.push(followUp);
814
+ properties.push({
815
+ comments: [followUpToComment(followUp)],
816
+ key: "name",
817
+ value: "TODO"
818
+ });
819
+ }
820
+ if (typeof source.compatibility_date === "string") properties.push({
821
+ key: "compatibilityDate",
822
+ value: source.compatibility_date
823
+ });
824
+ else {
825
+ const followUp = createFollowUp("missing-compatibility-date", "Wrangler config has no compatibility date. Replace the generated placeholder.", { sourcePath: sourcePrefix ? `${sourcePrefix}.compatibility_date` : "compatibility_date" });
826
+ followUps.push(followUp);
827
+ properties.push({
828
+ comments: [followUpToComment(followUp)],
829
+ key: "compatibilityDate",
830
+ value: "YYYY-MM-DD"
831
+ });
832
+ }
833
+ addProperty(properties, source, "compatibility_flags", "compatibilityFlags");
834
+ addProperty(properties, source, "main", "entrypoint");
835
+ addProperty(properties, source, "workers_dev", "workersDev");
836
+ addProperty(properties, source, "preview_urls", "previewUrls");
837
+ addProperty(properties, source, "logpush");
838
+ addProperty(properties, source, "placement", "placement", (value) => isRecord$1(value) ? camelObject(value) : void 0);
839
+ addProperty(properties, source, "limits", "limits", (value) => isRecord$1(value) ? camelObject(value) : void 0);
840
+ addProperty(properties, source, "cache", "cache", (value) => isRecord$1(value) ? camelObject(value) : void 0);
841
+ addProperty(properties, source, "observability", "observability", (value) => isRecord$1(value) ? camelObject(value) : void 0);
842
+ addProperty(properties, source, "access");
843
+ const assets = getRecord(source, "assets");
844
+ if (assets) {
845
+ const runtimeAssets = optionsFromRecord(assets, [
846
+ ["html_handling", "htmlHandling"],
847
+ ["not_found_handling", "notFoundHandling"],
848
+ ["run_worker_first", "runWorkerFirst"]
849
+ ]);
850
+ if (runtimeAssets.properties.length > 0) properties.push({
851
+ key: "assets",
852
+ value: runtimeAssets
853
+ });
854
+ if (bundler === "vite" && hasOwn(assets, "directory")) report(createFollowUp("vite-assets-directory", "The Wrangler assets directory was not migrated. Configure static assets in the Vite project.", {
855
+ docsUrl: CONFIGURATION_DOCS_URL,
856
+ sourcePath: `${sourcePrefix ? `${sourcePrefix}.` : ""}assets.directory`
857
+ }));
858
+ }
859
+ const convertedTriggers = convertTriggers(source, sourcePrefix, imports, report);
860
+ if (convertedTriggers.domains) properties.push({
861
+ key: "domains",
862
+ value: convertedTriggers.domains
863
+ });
864
+ if (convertedTriggers.triggers) properties.push({
865
+ key: "triggers",
866
+ value: convertedTriggers.triggers
867
+ });
868
+ const tailConsumers = [];
869
+ for (const [index, entry] of getRecords(source, "tail_consumers").entries()) {
870
+ let worker = entry.service;
871
+ if (typeof entry.environment === "string" && typeof worker === "string") {
872
+ worker = `${worker}-${entry.environment}`;
873
+ report(createFollowUp("service-environment", "A tail consumer used a legacy service environment. Verify the generated Worker name.", { sourcePath: `${sourcePrefix || "config"}.tail_consumers.${index}` }));
874
+ }
875
+ const value = toOutputValue(worker);
876
+ if (value !== void 0) tailConsumers.push({
877
+ kind: "object",
878
+ properties: [{
879
+ key: "worker",
880
+ value
881
+ }]
882
+ });
883
+ }
884
+ if (tailConsumers.length > 0) properties.push({
885
+ key: "tailConsumers",
886
+ value: tailConsumers
887
+ });
888
+ const streamingTailConsumers = [];
889
+ for (const entry of getRecords(source, "streaming_tail_consumers")) if (typeof entry.service === "string") streamingTailConsumers.push({
890
+ kind: "object",
891
+ properties: [{
892
+ key: "worker",
893
+ value: entry.service
894
+ }]
895
+ });
896
+ const experimental = [];
897
+ if (streamingTailConsumers.length > 0) experimental.push({
898
+ key: "streamingTailConsumers",
899
+ value: streamingTailConsumers
900
+ });
901
+ addProperty(experimental, source, "first_party_worker", "firstPartyWorker");
902
+ if (experimental.length > 0) properties.push({
903
+ key: "experimental",
904
+ value: {
905
+ kind: "object",
906
+ properties: experimental
907
+ }
908
+ });
909
+ const bindings = convertBindings(source, sourcePrefix, imports, report);
910
+ if (bindings) properties.push({
911
+ key: "env",
912
+ value: bindings
913
+ });
914
+ const configuredExports = convertExports(source, sourcePrefix, imports, report);
915
+ if (configuredExports) properties.push({
916
+ key: "exports",
917
+ value: configuredExports
918
+ });
919
+ const unsafe = getRecord(source, "unsafe");
920
+ if (unsafe) {
921
+ const runtimeUnsafe = [];
922
+ const metadata = getRecord(unsafe, "metadata");
923
+ if (metadata) runtimeUnsafe.push({
924
+ key: "metadata",
925
+ value: objectFromRecord(metadata)
926
+ });
927
+ const capnp = getRecord(unsafe, "capnp");
928
+ if (capnp) runtimeUnsafe.push({
929
+ key: "capnp",
930
+ value: camelObject(capnp)
931
+ });
932
+ if (runtimeUnsafe.length > 0) properties.push({
933
+ key: "unsafe",
934
+ value: {
935
+ kind: "object",
936
+ properties: runtimeUnsafe
937
+ }
938
+ });
939
+ }
940
+ if (Array.isArray(source.containers) && source.containers.length > 0) report(createFollowUp("container-review", "Containers require manual review and were not migrated.", { sourcePath: `${sourcePrefix ? `${sourcePrefix}.` : ""}containers` }));
941
+ const dependenciesInstrumentationFollowUp = createDependenciesInstrumentationFollowUp(source, sourcePrefix);
942
+ if (dependenciesInstrumentationFollowUp) report(dependenciesInstrumentationFollowUp);
943
+ for (const [field, label] of [
944
+ ["cloudchamber", "Cloudchamber configuration"],
945
+ ["keep_vars", "keep_vars"],
946
+ ["pages_build_output_dir", "Pages configuration"],
947
+ ["site", "Workers Sites configuration"],
948
+ ["unsafe_hello_world", "unsafe_hello_world bindings"]
949
+ ]) if (hasOwn(source, field)) report(createFollowUp("unsupported-field", `The ${label} is not supported by the new config and was not migrated.`, {
950
+ docsUrl: CONFIGURATION_DOCS_URL,
951
+ sourcePath: `${sourcePrefix ? `${sourcePrefix}.` : ""}${field}`
952
+ }));
953
+ return {
954
+ kind: "object",
955
+ properties,
956
+ trailingComments: comments.length > 0 ? comments : void 0
957
+ };
958
+ }
959
+ function convertRootConfig(source, sourcePrefix, bundler, imports, followUps) {
960
+ const properties = [];
961
+ if (typeof source.account_id === "string") properties.push({
962
+ key: "accountId",
963
+ value: source.account_id
964
+ });
965
+ if (source.compliance_region === "public") properties.push({
966
+ key: "complianceRegion",
967
+ value: "public"
968
+ });
969
+ else if (source.compliance_region === "fedramp_high") properties.push({
970
+ key: "complianceRegion",
971
+ value: "fedramp-high"
972
+ });
973
+ properties.push({
974
+ key: "worker",
975
+ value: convertWorkerConfig(source, sourcePrefix, bundler, imports, followUps)
976
+ });
977
+ return {
978
+ kind: "object",
979
+ properties
980
+ };
981
+ }
982
+ // src/cli/cf-config-convert/config-converter.ts
983
+ const VITE_DEFAULT_MODES = /* @__PURE__ */ new Set(["development", "production"]);
984
+ const NON_INHERITABLE_FIELDS = /* @__PURE__ */ new Set([
985
+ "agent_memory",
986
+ "ai_search_namespaces",
987
+ "ai_search",
988
+ "ai",
989
+ "analytics",
990
+ "analytics_engine_datasets",
991
+ "artifacts",
992
+ "browser",
993
+ "cloudchamber",
994
+ "connect",
995
+ "containers",
996
+ "d1_databases",
997
+ "define",
998
+ "dispatch_namespaces",
999
+ "durable_objects",
1000
+ "flagship",
1001
+ "hyperdrive",
1002
+ "images",
1003
+ "k2",
1004
+ "kv_namespaces",
1005
+ "media",
1006
+ "mtls_certificates",
1007
+ "pipelines",
1008
+ "queues",
1009
+ "r2_buckets",
1010
+ "ratelimits",
1011
+ "secrets_store_secrets",
1012
+ "secrets",
1013
+ "send_email",
1014
+ "services",
1015
+ "stream",
1016
+ "streaming_tail_consumers",
1017
+ "tail_consumers",
1018
+ "unsafe_hello_world",
1019
+ "unsafe",
1020
+ "vars",
1021
+ "vectorize",
1022
+ "version_metadata",
1023
+ "vpc_networks",
1024
+ "vpc_services",
1025
+ "worker_loaders",
1026
+ "workflows"
1027
+ ]);
1028
+ const TOOLING_FIELDS = /* @__PURE__ */ new Set([
1029
+ "alias",
1030
+ "base_dir",
1031
+ "build",
1032
+ "data_blobs",
1033
+ "define",
1034
+ "dev",
1035
+ "find_additional_modules",
1036
+ "jsx_factory",
1037
+ "jsx_fragment",
1038
+ "keep_names",
1039
+ "minify",
1040
+ "no_bundle",
1041
+ "preserve_file_names",
1042
+ "python_modules",
1043
+ "rules",
1044
+ "send_metrics",
1045
+ "text_blobs",
1046
+ "tsconfig",
1047
+ "wasm_modules"
1048
+ ]);
1049
+ const TOP_LEVEL_ONLY_TOOLING_FIELDS = /* @__PURE__ */ new Set([
1050
+ "alias",
1051
+ "data_blobs",
1052
+ "dev",
1053
+ "send_metrics",
1054
+ "text_blobs",
1055
+ "wasm_modules"
1056
+ ]);
1057
+ const KNOWN_FIELDS = /* @__PURE__ */ new Set([
1058
+ "$schema",
1059
+ "access",
1060
+ "account_id",
1061
+ "addresses",
1062
+ "agent_memory",
1063
+ "ai_search_namespaces",
1064
+ "ai_search",
1065
+ "ai",
1066
+ "alias",
1067
+ "analytics",
1068
+ "analytics_engine_datasets",
1069
+ "artifacts",
1070
+ "assets",
1071
+ "base_dir",
1072
+ "browser",
1073
+ "build",
1074
+ "cache",
1075
+ "cloudchamber",
1076
+ "compatibility_date",
1077
+ "compatibility_flags",
1078
+ "compliance_region",
1079
+ "connect",
1080
+ "containers",
1081
+ "d1_databases",
1082
+ "data_blobs",
1083
+ "define",
1084
+ "dependencies_instrumentation",
1085
+ "dev",
1086
+ "dispatch_namespaces",
1087
+ "durable_objects",
1088
+ "env",
1089
+ "exports",
1090
+ "find_additional_modules",
1091
+ "first_party_worker",
1092
+ "flagship",
1093
+ "hyperdrive",
1094
+ "images",
1095
+ "jsx_factory",
1096
+ "jsx_fragment",
1097
+ "keep_names",
1098
+ "keep_vars",
1099
+ "k2",
1100
+ "kv_namespaces",
1101
+ "limits",
1102
+ "logfwdr",
1103
+ "logpush",
1104
+ "main",
1105
+ "media",
1106
+ "migrations",
1107
+ "minify",
1108
+ "mtls_certificates",
1109
+ "name",
1110
+ "no_bundle",
1111
+ "observability",
1112
+ "pages_build_output_dir",
1113
+ "pipelines",
1114
+ "placement",
1115
+ "preserve_file_names",
1116
+ "preview_urls",
1117
+ "previews",
1118
+ "python_modules",
1119
+ "queues",
1120
+ "r2_buckets",
1121
+ "ratelimits",
1122
+ "route",
1123
+ "routes",
1124
+ "rules",
1125
+ "secrets_store_secrets",
1126
+ "secrets",
1127
+ "send_email",
1128
+ "send_metrics",
1129
+ "services",
1130
+ "site",
1131
+ "stream",
1132
+ "streaming_tail_consumers",
1133
+ "tail_consumers",
1134
+ "text_blobs",
1135
+ "triggers",
1136
+ "tsconfig",
1137
+ "unsafe_hello_world",
1138
+ "unsafe",
1139
+ "upload_source_maps",
1140
+ "vars",
1141
+ "vectorize",
1142
+ "version_metadata",
1143
+ "vpc_networks",
1144
+ "vpc_services",
1145
+ "wasm_modules",
1146
+ "worker_loaders",
1147
+ "workers_dev",
1148
+ "workflows"
1149
+ ]);
1150
+ function createBranchSource(base, overrides, environmentName) {
1151
+ const merged = { ...base };
1152
+ delete merged.env;
1153
+ if (environmentName !== void 0) for (const field of NON_INHERITABLE_FIELDS) delete merged[field];
1154
+ Object.assign(merged, overrides);
1155
+ if (environmentName !== void 0 && typeof overrides.name !== "string" && typeof base.name === "string") merged.name = `${base.name}-${environmentName}`;
1156
+ return merged;
1157
+ }
1158
+ function createPreviewSource(base, overrides) {
1159
+ const merged = createBranchSource(base, {});
1160
+ for (const field of NON_INHERITABLE_FIELDS) delete merged[field];
1161
+ delete merged.logfwdr;
1162
+ Object.assign(merged, overrides);
1163
+ delete merged.previews;
1164
+ return merged;
1165
+ }
1166
+ function createToolingEnvironmentSource(base, overrides, environmentName) {
1167
+ const environmentOverrides = { ...overrides };
1168
+ for (const field of TOP_LEVEL_ONLY_TOOLING_FIELDS) delete environmentOverrides[field];
1169
+ return createBranchSource(base, environmentOverrides, environmentName);
1170
+ }
1171
+ function addUnknownFieldFollowUps(record, sourcePrefix, followUps) {
1172
+ for (const field of Object.keys(record)) {
1173
+ if (KNOWN_FIELDS.has(field)) continue;
1174
+ followUps.push(createFollowUp("unsupported-field", `The Wrangler field \`${field}\` is not supported by the new config and was not migrated.`, {
1175
+ docsUrl: CONFIGURATION_DOCS_URL,
1176
+ sourcePath: sourcePrefix ? `${sourcePrefix}.${field}` : field
1177
+ }));
1178
+ }
1179
+ }
1180
+ function convertToolingObject(source) {
1181
+ const properties = [];
1182
+ for (const [sourceKey, targetKey] of [
1183
+ ["alias", "alias"],
1184
+ ["base_dir", "baseDir"],
1185
+ ["data_blobs", "dataBlobs"],
1186
+ ["define", "define"],
1187
+ ["find_additional_modules", "findAdditionalModules"],
1188
+ ["jsx_factory", "jsxFactory"],
1189
+ ["jsx_fragment", "jsxFragment"],
1190
+ ["keep_names", "keepNames"],
1191
+ ["minify", "minify"],
1192
+ ["no_bundle", "noBundle"],
1193
+ ["preserve_file_names", "preserveFileNames"],
1194
+ ["python_modules", "pythonModules"],
1195
+ ["rules", "rules"],
1196
+ ["send_metrics", "sendMetrics"],
1197
+ ["text_blobs", "textBlobs"],
1198
+ ["tsconfig", "tsconfig"],
1199
+ ["upload_source_maps", "uploadSourceMaps"],
1200
+ ["wasm_modules", "wasmModules"]
1201
+ ]) addProperty(properties, source, sourceKey, targetKey, (sourceValue) => sourceKey === "python_modules" && isRecord$1(sourceValue) ? camelObject(sourceValue) : toOutputValue(sourceValue));
1202
+ const build = getRecord(source, "build");
1203
+ if (build) properties.push({
1204
+ key: "build",
1205
+ value: camelObject(build)
1206
+ });
1207
+ const dev = getRecord(source, "dev");
1208
+ if (dev) {
1209
+ const devOptions = optionsFromRecord(dev, [
1210
+ ["enable_containers", "enableContainers"],
1211
+ ["host", "host"],
1212
+ ["inspector_ip", "inspectorIp"],
1213
+ ["inspector_port", "inspectorPort"],
1214
+ ["ip", "ip"],
1215
+ ["local_protocol", "localProtocol"],
1216
+ ["port", "port"],
1217
+ ["upstream_protocol", "upstreamProtocol"]
1218
+ ]);
1219
+ if (typeof dev.container_engine === "string") devOptions.properties.push({
1220
+ key: "containerEngine",
1221
+ value: dev.container_engine
1222
+ });
1223
+ if (devOptions.properties.length > 0) properties.push({
1224
+ key: "dev",
1225
+ value: devOptions
1226
+ });
1227
+ }
1228
+ if (dev?.generate_types === false) properties.push({
1229
+ key: "types",
1230
+ value: {
1231
+ kind: "object",
1232
+ properties: [{
1233
+ key: "generate",
1234
+ value: false
1235
+ }]
1236
+ }
1237
+ });
1238
+ const assets = getRecord(source, "assets");
1239
+ if (assets && typeof assets.directory === "string") properties.push({
1240
+ key: "assetsDirectory",
1241
+ value: assets.directory
1242
+ });
1243
+ return {
1244
+ kind: "object",
1245
+ properties
1246
+ };
1247
+ }
1248
+ function addViteToolingFollowUp(source, location, sourcePrefix, followUps) {
1249
+ const toolingFields = [...TOOLING_FIELDS].filter((field) => hasOwn(source, field));
1250
+ if (toolingFields.length > 0) followUps.push(createFollowUp("vite-tooling-config", `Wrangler-specific tooling fields${location ? ` in ${location}` : ""} were not migrated because the Vite bundler is selected: ${toolingFields.join(", ")}.`, { sourcePath: sourcePrefix ? `${sourcePrefix}.${toolingFields.join(",")}` : toolingFields.join(",") }));
1251
+ if (typeof source.upload_source_maps === "boolean") {
1252
+ const setting = `Wrangler \`upload_source_maps: ${source.upload_source_maps}\`${location ? ` in ${location}` : ""} was not migrated because the Vite bundler is selected.`;
1253
+ followUps.push(createFollowUp("vite-source-maps", source.upload_source_maps ? `${setting} To keep uploading Worker source maps, enable \`build.sourcemap\` for the Worker's Vite environment. \`cf deploy\` uploads source maps included in the build output.` : `${setting} \`cf deploy\` uploads every Worker source map included in the build output, so keep \`build.sourcemap\` disabled for the Worker's Vite environment to avoid uploading source maps.`, {
1254
+ blocking: false,
1255
+ docsUrl: SOURCE_MAPS_DOCS_URL,
1256
+ sourcePath: sourcePrefix ? `${sourcePrefix}.upload_source_maps` : "upload_source_maps"
1257
+ }));
1258
+ }
1259
+ }
1260
+ function convertBranch(source, sourcePrefix, bundler, imports, followUps) {
1261
+ const config = convertRootConfig(source, sourcePrefix, bundler, imports, followUps);
1262
+ const previews = getRecord(source, "previews");
1263
+ if (!previews) return { config };
1264
+ const previewPath = `${sourcePrefix ? `${sourcePrefix}.` : ""}previews`;
1265
+ const followUp = createFollowUp("preview-review", "Preview configuration was converted to `ctx.isPreview` handling. Review the generated Preview branch.", {
1266
+ docsUrl: PREVIEWS_DOCS_URL,
1267
+ sourcePath: previewPath
1268
+ });
1269
+ followUps.push(followUp);
1270
+ const worker = config.properties.find(({ key }) => key === "worker")?.value;
1271
+ if (worker && !Array.isArray(worker) && typeof worker === "object" && worker.kind === "object") worker.trailingComments = [...worker.trailingComments ?? [], followUpToComment(followUp)];
1272
+ return {
1273
+ config,
1274
+ previewConfig: convertRootConfig(createPreviewSource(source, previews), previewPath, bundler, imports, followUps)
1275
+ };
1276
+ }
1277
+ function convertToolingBranch(source) {
1278
+ const config = convertToolingObject(source);
1279
+ const previews = getRecord(source, "previews");
1280
+ const previewConfig = previews ? convertToolingObject(createPreviewSource(source, previews)) : void 0;
1281
+ if (config.properties.length === 0 && (previewConfig?.properties.length ?? 0) === 0) return;
1282
+ return {
1283
+ config,
1284
+ previewConfig
1285
+ };
1286
+ }
1287
+ function convertWranglerConfig(rawConfig, bundler, secretFiles) {
1288
+ const source = rawConfig;
1289
+ const imports = /* @__PURE__ */ new Set();
1290
+ const followUps = [];
1291
+ addUnknownFieldFollowUps(source, "", followUps);
1292
+ const sourcePreviews = getRecord(source, "previews");
1293
+ if (sourcePreviews) addUnknownFieldFollowUps(sourcePreviews, "previews", followUps);
1294
+ const environments = getRecord(source, "env") ?? {};
1295
+ for (const [name, environment] of Object.entries(environments)) {
1296
+ if (isRecord$1(environment)) {
1297
+ addUnknownFieldFollowUps(environment, `env.${name}`, followUps);
1298
+ const environmentPreviews = getRecord(environment, "previews");
1299
+ if (environmentPreviews) addUnknownFieldFollowUps(environmentPreviews, `env.${name}.previews`, followUps);
1300
+ if (bundler === "vite" && VITE_DEFAULT_MODES.has(name)) followUps.push(createFollowUp("vite-mode-environment-conflict", `The Wrangler environment \`${name}\` conflicts with Vite's default \`${name}\` mode. Rename or remap this environment before using the generated config so Vite does not select it implicitly.`, {
1301
+ docsUrl: ENVIRONMENTS_DOCS_URL,
1302
+ sourcePath: `env.${name}`
1303
+ }));
1304
+ continue;
1305
+ }
1306
+ followUps.push(createFollowUp("invalid-environment", `The Wrangler environment \`${name}\` is not an object and was not migrated.`, { sourcePath: `env.${name}` }));
1307
+ }
1308
+ if (secretFiles.length > 0) followUps.push(createFollowUp("secret-files-not-migrated", `Secret-like files were detected but not read or migrated: ${secretFiles.join(", ")}. Only \`secrets.required\` entries are migrated.`, {
1309
+ blocking: false,
1310
+ docsUrl: SECRETS_DOCS_URL
1311
+ }));
1312
+ if (bundler === "vite") {
1313
+ addViteToolingFollowUp(source, "", "", followUps);
1314
+ if (sourcePreviews) addViteToolingFollowUp(sourcePreviews, "previews", "previews", followUps);
1315
+ }
1316
+ const isWranglerBundle = bundler === "wrangler";
1317
+ if (isWranglerBundle) {
1318
+ const dev = getRecord(source, "dev");
1319
+ if (dev && isRecord$1(dev.container_engine)) followUps.push(createFollowUp("container-engine-config", "The structured Wrangler container engine setting is not supported by wrangler.config.ts and was not migrated.", { sourcePath: "dev.container_engine" }));
1320
+ }
1321
+ if (bundler === "vite") for (const [name, environment] of Object.entries(environments)) {
1322
+ if (!isRecord$1(environment)) continue;
1323
+ addViteToolingFollowUp(environment, `environment \`${name}\``, `env.${name}`, followUps);
1324
+ const environmentPreviews = getRecord(environment, "previews");
1325
+ if (environmentPreviews) addViteToolingFollowUp(environmentPreviews, `environment \`${name}\` previews`, `env.${name}.previews`, followUps);
1326
+ }
1327
+ const baseSource = createBranchSource(source, {});
1328
+ const base = convertBranch(baseSource, "", bundler, imports, followUps);
1329
+ const toolingBase = isWranglerBundle ? convertToolingBranch(baseSource) : void 0;
1330
+ const convertedEnvironments = /* @__PURE__ */ new Map();
1331
+ const toolingEnvironments = /* @__PURE__ */ new Map();
1332
+ for (const [name, value] of Object.entries(environments)) {
1333
+ if (!isRecord$1(value)) continue;
1334
+ const environmentSource = createBranchSource(source, value, name);
1335
+ convertedEnvironments.set(name, convertBranch(environmentSource, `env.${name}`, bundler, imports, followUps));
1336
+ if (isWranglerBundle) {
1337
+ const tooling = convertToolingBranch(createToolingEnvironmentSource(source, value, name));
1338
+ if (tooling || toolingBase) toolingEnvironments.set(name, tooling ?? { config: {
1339
+ kind: "object",
1340
+ properties: []
1341
+ } });
1342
+ }
1343
+ }
1344
+ if (convertedEnvironments.size > 0) followUps.push(createFollowUp("environments-migrated", "Wrangler environments were migrated to a `switch (ctx.mode)` statement. Select one with the `--mode` flag.", {
1345
+ blocking: false,
1346
+ docsUrl: ENVIRONMENTS_DOCS_URL,
1347
+ sourcePath: "env"
1348
+ }));
1349
+ return {
1350
+ base,
1351
+ environments: convertedEnvironments,
1352
+ followUps: deduplicateFollowUps(followUps),
1353
+ imports,
1354
+ toolingBase,
1355
+ toolingEnvironments
1356
+ };
1357
+ }
1358
+ // src/cli/cf-config-migrate.ts
1359
+ function record(value) {
1360
+ return isRecord(value) ? value : null;
1361
+ }
1362
+ function empty(value) {
1363
+ return value === void 0 || value === null || Array.isArray(value) && value.length === 0 || record(value) !== null && Object.keys(value).length === 0;
1364
+ }
1365
+ function normalizeQueueConcurrency(raw) {
1366
+ const result = { ...raw };
1367
+ const queues = record(result.queues);
1368
+ if (Array.isArray(queues?.consumers)) result.queues = {
1369
+ ...queues,
1370
+ consumers: queues.consumers.map((value) => {
1371
+ const consumer = record(value);
1372
+ if (consumer?.max_concurrency !== null) return value;
1373
+ const { max_concurrency: _automatic, ...rest } = consumer;
1374
+ return rest;
1375
+ })
1376
+ };
1377
+ return result;
1378
+ }
1379
+ /** Remove build-only fields and settings translated into cf's typed config below. */
1380
+ function migrationInput(raw) {
1381
+ const result = normalizeQueueConcurrency(raw);
1382
+ const environments = record(result.env);
1383
+ if (environments) result.env = Object.fromEntries(Object.entries(environments).map(([name, value]) => [name, record(value) ? normalizeQueueConcurrency(value) : value]));
1384
+ if (!empty(result.rules) && !isDeepStrictEqual(result.rules, [{
1385
+ type: "ESModule",
1386
+ globs: ["**/*.js", "**/*.mjs"]
1387
+ }])) throw new Error("cf cannot yet preserve custom Worker module rules in a prebuilt bundle.");
1388
+ if (empty(result.logfwdr) || isDeepStrictEqual(result.logfwdr, { bindings: [] })) delete result.logfwdr;
1389
+ for (const key of [
1390
+ "configPath",
1391
+ "userConfigPath",
1392
+ "topLevelName",
1393
+ "main",
1394
+ "jsx_factory",
1395
+ "jsx_fragment",
1396
+ "rules",
1397
+ "python_modules",
1398
+ "dev",
1399
+ "no_bundle",
1400
+ "build",
1401
+ "keep_vars",
1402
+ "keep_secrets",
1403
+ "keep_assets",
1404
+ "send_metrics",
1405
+ "workflows"
1406
+ ]) delete result[key];
1407
+ for (const [key, value] of Object.entries(result)) if (empty(value)) delete result[key];
1408
+ return result;
1409
+ }
1410
+ function applyPreservationFlags(raw, worker) {
1411
+ const keepBindings = raw.keep_vars === true || raw.keep_secrets === true ? [
1412
+ ...raw.keep_vars === true ? ["plain_text", "json"] : [],
1413
+ "secret_text",
1414
+ "secret_key"
1415
+ ] : [];
1416
+ if (keepBindings.length === 0 && raw.keep_assets !== true) return;
1417
+ const unsafe = record(worker.unsafe) ?? {};
1418
+ const metadata = record(unsafe.metadata) ?? {};
1419
+ const previous = metadata.keep_bindings;
1420
+ if (previous !== void 0 && (!Array.isArray(previous) || !previous.every((value) => typeof value === "string"))) throw new Error("Invalid keep_bindings in the built Cloudflare config.");
1421
+ worker.unsafe = {
1422
+ ...unsafe,
1423
+ metadata: {
1424
+ ...metadata,
1425
+ ...keepBindings.length > 0 ? { keep_bindings: [.../* @__PURE__ */ new Set([...previous ?? [], ...keepBindings])] } : {},
1426
+ ...raw.keep_assets === true ? { keep_assets: true } : {}
1427
+ }
1428
+ };
1429
+ }
1430
+ function applyWorkflows(raw, worker) {
1431
+ if (empty(raw.workflows)) return;
1432
+ if (!Array.isArray(raw.workflows)) throw new Error("Invalid Workflow bindings in the built Cloudflare config.");
1433
+ const env = record(worker.env) ?? {};
1434
+ const exports = record(worker.exports) ?? {};
1435
+ for (const item of raw.workflows) {
1436
+ const workflow = record(item);
1437
+ if (!workflow || typeof workflow.binding !== "string" || typeof workflow.name !== "string" || typeof workflow.class_name !== "string" || workflow.script_name !== void 0 && typeof workflow.script_name !== "string") throw new Error("Invalid Workflow binding in the built Cloudflare config.");
1438
+ const allowed = /* @__PURE__ */ new Set([
1439
+ "binding",
1440
+ "name",
1441
+ "class_name",
1442
+ "script_name",
1443
+ "limits",
1444
+ "concurrency",
1445
+ "schedules",
1446
+ "default_retention"
1447
+ ]);
1448
+ for (const key of Object.keys(workflow)) if (!allowed.has(key)) throw new Error(`cf cannot migrate Workflow setting ${key}.`);
1449
+ if (Object.hasOwn(env, workflow.binding)) throw new Error(`Duplicate Worker binding ${workflow.binding}.`);
1450
+ env[workflow.binding] = {
1451
+ type: "workflow",
1452
+ name: workflow.name,
1453
+ worker: workflow.script_name ?? worker.name,
1454
+ exportName: workflow.class_name
1455
+ };
1456
+ if (workflow.script_name !== void 0 && workflow.script_name !== worker.name) continue;
1457
+ const retention = record(workflow.default_retention);
1458
+ if (Object.hasOwn(exports, workflow.class_name)) throw new Error(`Duplicate Worker export ${workflow.class_name}.`);
1459
+ const schedules = Array.isArray(workflow.schedules) && workflow.schedules.length === 0 ? void 0 : workflow.schedules;
1460
+ exports[workflow.class_name] = {
1461
+ type: "workflow",
1462
+ name: workflow.name,
1463
+ ...workflow.limits !== void 0 ? { limits: workflow.limits } : {},
1464
+ ...workflow.concurrency !== void 0 ? { concurrency: workflow.concurrency } : {},
1465
+ ...schedules !== void 0 ? { schedules } : {},
1466
+ ...retention ? { defaultRetention: {
1467
+ ...retention.success_retention !== void 0 ? { successRetention: retention.success_retention } : {},
1468
+ ...retention.error_retention !== void 0 ? { errorRetention: retention.error_retention } : {}
1469
+ } } : {}
1470
+ };
1471
+ }
1472
+ worker.env = env;
1473
+ worker.exports = exports;
1474
+ }
1475
+ function assertHandledFollowUps(followUps) {
1476
+ for (const item of followUps) {
1477
+ if (!item.blocking) continue;
1478
+ if (item.code === "vite-plugin-install-disabled" && item.sourcePath === void 0) continue;
1479
+ const path = item.sourcePath ?? item.code;
1480
+ if (!((path === "assets.directory" || /^env\.[^.]+\.assets\.directory$/.test(path)) && item.message.includes("assets directory") || /^d1_databases\.\d+$/.test(path) && /`migrations_(?:dir|table)`/.test(item.message) || /^durable_objects\.bindings\.\d+$/.test(path) || path === "migrations" || path === "containers")) throw new Error(`cf cannot migrate Cloudflare setting ${path}: ${item.message}`);
1481
+ }
1482
+ }
1483
+ function durableObjectExports(raw) {
1484
+ const exports = {};
1485
+ const migrations = raw.migrations;
1486
+ if (migrations === void 0 || Array.isArray(migrations) && migrations.length === 0) return exports;
1487
+ if (!Array.isArray(migrations) || !migrations.every((entry) => record(entry))) throw new Error("Invalid Durable Object migrations in the built Cloudflare config.");
1488
+ for (const migration of migrations) {
1489
+ const known = /* @__PURE__ */ new Set([
1490
+ "tag",
1491
+ "new_classes",
1492
+ "new_sqlite_classes",
1493
+ "renamed_classes",
1494
+ "deleted_classes"
1495
+ ]);
1496
+ for (const key of Object.keys(migration)) if (!known.has(key)) throw new Error(`cf cannot migrate Durable Object migration setting ${key}.`);
1497
+ for (const [field, storage] of [["new_classes", "legacy-kv"], ["new_sqlite_classes", "sqlite"]]) {
1498
+ const classes = migration[field] ?? [];
1499
+ if (!Array.isArray(classes) || !classes.every((name) => typeof name === "string")) throw new Error(`Invalid ${field} in the built Cloudflare config.`);
1500
+ for (const name of classes) exports[name] = {
1501
+ type: "durable-object",
1502
+ storage
1503
+ };
1504
+ }
1505
+ const renamed = migration.renamed_classes ?? [];
1506
+ if (!Array.isArray(renamed) || !renamed.every((entry) => record(entry))) throw new Error("Invalid renamed_classes in the built Cloudflare config.");
1507
+ for (const item of renamed) {
1508
+ if (typeof item.from !== "string" || typeof item.to !== "string") throw new Error("Invalid Durable Object class rename in the built Cloudflare config.");
1509
+ const old = record(exports[item.from]);
1510
+ if (!old || old.storage !== "sqlite" && old.storage !== "legacy-kv") throw new Error(`Cannot determine the storage of renamed Durable Object ${item.from}.`);
1511
+ exports[item.from] = {
1512
+ type: "durable-object",
1513
+ state: "renamed",
1514
+ renamedTo: item.to
1515
+ };
1516
+ exports[item.to] = {
1517
+ type: "durable-object",
1518
+ storage: old.storage
1519
+ };
1520
+ }
1521
+ const deleted = migration.deleted_classes ?? [];
1522
+ if (!Array.isArray(deleted) || !deleted.every((name) => typeof name === "string")) throw new Error("Invalid deleted_classes in the built Cloudflare config.");
1523
+ for (const name of deleted) exports[name] = {
1524
+ type: "durable-object",
1525
+ state: "deleted"
1526
+ };
1527
+ }
1528
+ return exports;
1529
+ }
1530
+ function containersFromWrangler(raw, exports) {
1531
+ const values = raw.containers;
1532
+ if (values === void 0) return [];
1533
+ if (!Array.isArray(values) || !values.every((value) => record(value))) throw new Error("Invalid Containers in the built Cloudflare config.");
1534
+ return values.map((value) => {
1535
+ if (typeof value.name !== "string" || typeof value.class_name !== "string") throw new Error("cf requires a name and class_name for each Container.");
1536
+ const managed = value.scheduling_policy === "durable_object";
1537
+ const fields = new Set(managed ? [
1538
+ "name",
1539
+ "class_name",
1540
+ "scheduling_policy",
1541
+ "images"
1542
+ ] : [
1543
+ "name",
1544
+ "class_name",
1545
+ "image",
1546
+ "max_instances",
1547
+ "instance_type"
1548
+ ]);
1549
+ for (const key of Object.keys(value)) if (!fields.has(key)) throw new Error(`cf cannot migrate Container setting ${key}.`);
1550
+ const declaration = record(exports[value.class_name]);
1551
+ if (!declaration || declaration.storage !== "sqlite") throw new Error(`Container ${value.name} needs a SQLite Durable Object export.`);
1552
+ declaration.container = value.name;
1553
+ if (managed) {
1554
+ const images = record(value.images);
1555
+ if (!images) throw new Error("A Sandbox requires a named image.");
1556
+ return {
1557
+ name: value.name,
1558
+ schedulingPolicy: "durable-object",
1559
+ images: Object.fromEntries(Object.entries(images).map(([name, image]) => {
1560
+ const source = record(image);
1561
+ if (!source || Object.keys(source).some((key) => ![
1562
+ "dockerfile",
1563
+ "build_context",
1564
+ "image"
1565
+ ].includes(key)) || source.dockerfile !== void 0 && source.image !== void 0 || source.build_context !== void 0 && typeof source.build_context !== "string") throw new Error("Invalid Sandbox image.");
1566
+ if (typeof source.dockerfile === "string") return [name, {
1567
+ dockerfile: source.dockerfile,
1568
+ ...typeof source.build_context === "string" ? { buildContext: source.build_context } : {}
1569
+ }];
1570
+ if (typeof source.image === "string") return [name, { reference: source.image }];
1571
+ throw new Error("Invalid Sandbox image source.");
1572
+ }))
1573
+ };
1574
+ }
1575
+ if (typeof value.image !== "string") throw new Error("A Container requires an image.");
1576
+ return {
1577
+ name: value.name,
1578
+ image: { reference: value.image },
1579
+ ...typeof value.max_instances === "number" ? { maxInstances: value.max_instances } : {},
1580
+ ...typeof value.instance_type === "string" ? { instanceType: value.instance_type } : {}
1581
+ };
1582
+ });
1583
+ }
1584
+ const configHelpers = {
1585
+ bindings,
1586
+ exports,
1587
+ triggers
1588
+ };
1589
+ /** Build the value that the converter describes, calling cf's config helpers where it names one. */
1590
+ function outputValue(value) {
1591
+ if (value === null || typeof value !== "object") return value;
1592
+ if (Array.isArray(value)) return value.map(outputValue);
1593
+ if (value.kind === "call") {
1594
+ const [namespace, name] = value.callee.split(".");
1595
+ const helper = Object.hasOwn(configHelpers, namespace) ? configHelpers[namespace][name] : void 0;
1596
+ if (typeof helper !== "function") throw new Error(`cf has no configuration helper ${value.callee}.`);
1597
+ return helper(...value.args.map(outputValue));
1598
+ }
1599
+ return Object.fromEntries(value.properties.map(({ key, value: item }) => [key, outputValue(item)]));
1600
+ }
1601
+ /**
1602
+ * Translate Wrangler-format settings to a parsed cf configuration and the follow-ups that the
1603
+ * converter could not translate. `mode` selects a Wrangler environment by name.
1604
+ */
1605
+ function translateWranglerConfig(raw, mode) {
1606
+ const converted = convertWranglerConfig(JSON.parse(JSON.stringify(raw)), "vite", []);
1607
+ const input = record(outputValue((converted.environments.get(mode) ?? converted.base).config));
1608
+ const worker = record(input?.worker);
1609
+ const env = record(worker?.env);
1610
+ if (input && worker && env) input.worker = {
1611
+ ...worker,
1612
+ env: Object.fromEntries(Object.entries(env).filter(([, binding]) => binding !== false && binding !== null && binding !== void 0))
1613
+ };
1614
+ const parsed = CloudflareConfigSchema.safeParse(input);
1615
+ if (!parsed.success) throw new Error("cf could not translate the built Cloudflare configuration.");
1616
+ return {
1617
+ config: JSON.parse(JSON.stringify(parsed.data)),
1618
+ followUps: converted.followUps
1619
+ };
1620
+ }
1621
+ function migrateBuiltWranglerConfig(raw, mode = "production") {
1622
+ const environment = record(record(raw.env)?.[mode]);
1623
+ const effective = environment ? {
1624
+ ...raw,
1625
+ ...environment
1626
+ } : raw;
1627
+ if (environment) {
1628
+ for (const key of [
1629
+ "durable_objects",
1630
+ "workflows",
1631
+ "containers"
1632
+ ]) if (!(key in environment)) delete effective[key];
1633
+ }
1634
+ const migration = translateWranglerConfig(migrationInput(raw), mode);
1635
+ assertHandledFollowUps(migration.followUps);
1636
+ const result = record(migration.config);
1637
+ const worker = record(result?.worker);
1638
+ if (!result || !worker) throw new Error("cf did not generate a Worker configuration.");
1639
+ applyPreservationFlags(effective, worker);
1640
+ applyWorkflows(effective, worker);
1641
+ const exports = {
1642
+ ...record(worker.exports),
1643
+ ...durableObjectExports(effective)
1644
+ };
1645
+ const containers = containersFromWrangler(effective, exports);
1646
+ if (containers.length > 0) {
1647
+ const envBindings = record(worker.env);
1648
+ const durableBindings = record(effective.durable_objects)?.bindings;
1649
+ if (!envBindings || !Array.isArray(durableBindings)) throw new Error("A Container Durable Object binding was not found in the built config.");
1650
+ for (const container of containers) {
1651
+ const className = effective.containers.find((entry) => entry.name === container.name)?.class_name;
1652
+ const binding = record(durableBindings.find((entry) => record(entry)?.class_name === className));
1653
+ if (!binding || typeof binding.name !== "string" || binding.script_name !== void 0 && binding.script_name !== worker.name) throw new Error(`Container ${container.name} must use a local Durable Object binding.`);
1654
+ envBindings[binding.name] = {
1655
+ type: "unsafe:durable_object_namespace",
1656
+ class_name: className
1657
+ };
1658
+ }
1659
+ result.containers = containers;
1660
+ }
1661
+ if (Object.keys(exports).length > 0) worker.exports = exports;
1662
+ return CloudflareConfigSchema.parse(result);
1663
+ }
1664
+ export { record as n, migrateBuiltWranglerConfig as t };