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
@@ -1,26 +1,1226 @@
1
- import { A as confirm, H as outro, L as log, X as text, tt as isCancel } from "./dist-STQXl8ck.mjs";
1
+ import { A as confirm, H as outro, L as log, X as text, tt as isCancel } from "./dist-Cr_xGE_K.mjs";
2
2
  import { a as join, c as resolve, n as dirname, r as extname, s as relative, t as basename } from "./dist-DMYe8CZJ.mjs";
3
- import { c as getDatabaseCasing, l as getDatabaseDialect, m as resolveBindingNames, p as readConfig } from "./config-BmvqLnbi.mjs";
4
- import { t as resolveLocalD1Target } from "./local-d1-C6xn26Nl.mjs";
5
- import { i as writeJournal, n as readJournal, r as stripSqlExt, t as collectMigrations } from "./collect-C6Blu9yw.mjs";
6
- import { i as validateMigrations, t as assertJournalCoherence } from "./validate-Ddzl-IwT.mjs";
7
- import { r as detectFramework } from "./plugin-inference-B_urWd5Z.mjs";
8
- import { n as readProjectPaths } from "./project-paths-CUhCPMpK.mjs";
9
- import { t as cfAccessHeaders } from "./cf-access-pejlJmuy.mjs";
10
- import { c as loadLocalEnv } from "./env-UqS-21xi.mjs";
11
- import { c as getToken, o as getProxyUrl } from "./auth-CCk9Seol.mjs";
12
- import { n as ensurePlatformProxyAccess, r as isCloudflareAccessChallenge, t as ensurePlatformAccessToken } from "./cf-access-Dnyw8KFY.mjs";
13
- import { n as PlatformApiError, r as PlatformClient } from "./client-DF6U7KLP.mjs";
14
- import { n as formatTimestamp } from "./gen-EMpnzNGz.mjs";
3
+ import { c as getDatabaseCasing, l as getDatabaseDialect, m as resolveBindingNames, p as readConfig } from "./config-Dv5jri1-.mjs";
4
+ import { t as resolveLocalD1Target } from "./local-d1-CYOYkVwO.mjs";
5
+ import { i as writeJournal, n as readJournal, r as stripSqlExt, t as collectMigrations } from "./collect-rNLybAnF.mjs";
6
+ import { i as validateMigrations, t as assertJournalCoherence } from "./validate-CtBWCzez.mjs";
7
+ import { r as detectFramework } from "./plugin-inference-COlq96WJ.mjs";
8
+ import { n as readProjectPaths } from "./project-paths-2ENfCCih.mjs";
9
+ import { t as cfAccessHeaders } from "./cf-access-DmkKPcAI.mjs";
10
+ import { c as loadLocalEnv } from "./env-EjHqc7m9.mjs";
11
+ import { c as getToken, o as getProxyUrl } from "./auth-CqwJwItO.mjs";
12
+ import { n as ensurePlatformProxyAccess, r as isCloudflareAccessChallenge, t as ensurePlatformAccessToken } from "./cf-access-DHklo7Rg.mjs";
13
+ import { n as PlatformApiError, r as PlatformClient } from "./client-DE2m2ldh.mjs";
14
+ import { t as closeMySqlQuoted } from "./mysql-sql-BIE7bc4Z.mjs";
15
+ import { n as formatTimestamp } from "./gen-aOtHhZLD.mjs";
15
16
  import { t as Buffer } from "./node-buffer-D7kgjaDs.mjs";
16
- import { _ as printSuccess, d as getErrorMessage, i as dim, o as formatCount, p as import_picocolors, u as formatUrl } from "./output-Bc8ixgPF.mjs";
17
- import { n as readDeploymentPlatform, r as readProjectConfig } from "./project-CLwxcEdq.mjs";
17
+ import { c as formatCount, f as formatUrl, h as import_picocolors, o as dim, p as getErrorMessage, y as printSuccess } from "./output-BZLnu0z8.mjs";
18
+ import { n as readDeploymentPlatform, r as readProjectConfig } from "./project-dh9431bN.mjs";
18
19
  import { n as drizzleKitBin } from "./yarn-pnp-DgWbE7z5.mjs";
19
20
  import { createRequire } from "node:module";
20
21
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
21
22
  import { pathToFileURL } from "node:url";
22
- import { createJiti } from "jiti";
23
+ import { tokenizeSql } from "@void/deploy-core";
23
24
  import { execFileSync } from "node:child_process";
25
+ // src/cli/db-execute-results.ts
26
+ const MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
27
+ const MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
28
+ /**
29
+ * Write values JSON cannot hold as-is without changing them. `this[key]` is the value before
30
+ * `toJSON()`, so a Buffer is still a Buffer here, at any depth (a `bytea[]` element too).
31
+ */
32
+ function jsonValue(key, value) {
33
+ const raw = this[key];
34
+ if (raw instanceof Uint8Array) return Array.from(raw);
35
+ if (typeof raw === "bigint") return raw >= MIN_SAFE && raw <= MAX_SAFE ? Number(raw) : raw.toString();
36
+ if (typeof raw === "number" && !Number.isFinite(raw)) return String(raw);
37
+ return value;
38
+ }
39
+ /** Serialize results for stdout. */
40
+ function formatStatementResults(results) {
41
+ return JSON.stringify(results, jsonValue, 2);
42
+ }
43
+ /**
44
+ * Find each statement in SQLite SQL the way `sqlite3_complete()` does: a statement ends at a
45
+ * top-level `;`, except that `CREATE [TEMP] TRIGGER` runs until `; END ;`, since its body holds
46
+ * semicolons of its own. Ranges hold no statement when they are only whitespace and comments,
47
+ * and those are left out. The last range may lack its `;`; SQLite decides whether it is complete.
48
+ */
49
+ function sqliteStatementRanges(sql) {
50
+ const START = 1;
51
+ const transitions = [
52
+ [
53
+ 1,
54
+ 2,
55
+ 3,
56
+ 4,
57
+ 2,
58
+ 2,
59
+ 2
60
+ ],
61
+ [
62
+ 1,
63
+ 2,
64
+ 3,
65
+ 4,
66
+ 2,
67
+ 2,
68
+ 2
69
+ ],
70
+ [
71
+ 1,
72
+ 2,
73
+ 2,
74
+ 2,
75
+ 2,
76
+ 2,
77
+ 2
78
+ ],
79
+ [
80
+ 1,
81
+ 3,
82
+ 2,
83
+ 4,
84
+ 2,
85
+ 2,
86
+ 2
87
+ ],
88
+ [
89
+ 1,
90
+ 2,
91
+ 2,
92
+ 2,
93
+ 4,
94
+ 5,
95
+ 2
96
+ ],
97
+ [
98
+ 6,
99
+ 5,
100
+ 5,
101
+ 5,
102
+ 5,
103
+ 5,
104
+ 5
105
+ ],
106
+ [
107
+ 6,
108
+ 5,
109
+ 5,
110
+ 5,
111
+ 5,
112
+ 5,
113
+ 7
114
+ ],
115
+ [
116
+ 1,
117
+ 5,
118
+ 5,
119
+ 5,
120
+ 5,
121
+ 5,
122
+ 5
123
+ ]
124
+ ];
125
+ const keywords = /* @__PURE__ */ new Map([
126
+ ["explain", 2],
127
+ ["create", 3],
128
+ ["temp", 4],
129
+ ["temporary", 4],
130
+ ["trigger", 5],
131
+ ["end", 6]
132
+ ]);
133
+ const ranges = [];
134
+ let state = 0;
135
+ let start = 0;
136
+ let hasStatement = false;
137
+ const advance = (token, index) => {
138
+ const next = transitions[state][token];
139
+ if (token === 0 && next === START) {
140
+ if (hasStatement) ranges.push({
141
+ start,
142
+ end: index + 1
143
+ });
144
+ start = index + 1;
145
+ hasStatement = false;
146
+ } else if (token !== 0) hasStatement = true;
147
+ state = next;
148
+ };
149
+ for (const segment of tokenizeSql(sql)) {
150
+ const bareOpen = segment.kind === "block-comment" && segment.end - segment.start === 2;
151
+ if (segment.kind === "line-comment" || segment.kind === "block-comment" && !bareOpen) continue;
152
+ if (segment.kind !== "sql") {
153
+ advance(1, segment.start);
154
+ continue;
155
+ }
156
+ const text = sql.slice(segment.start, segment.end);
157
+ for (const match of text.matchAll(/;|[ \t\n\f\r\uFEFF]+|[\w$\u0080-￿]+|./gu)) {
158
+ const [token] = match;
159
+ if (token === ";") advance(0, segment.start + match.index);
160
+ else if (!/^[ \t\n\f\r\uFEFF]/u.test(token)) advance(keywords.get(token.toLowerCase()) ?? 1, segment.start + match.index);
161
+ }
162
+ }
163
+ if (hasStatement) ranges.push({
164
+ start,
165
+ end: sql.length
166
+ });
167
+ return ranges;
168
+ }
169
+ /** Split SQLite SQL into its statements. See `sqliteStatementRanges`. */
170
+ function splitSqliteStatements(sql) {
171
+ return sqliteStatementRanges(sql).map(({ start, end }) => sql.slice(start, end));
172
+ }
173
+ /**
174
+ * Run SQL statement by statement and keep each one's rows. Like `exec()`, every statement
175
+ * commits on its own unless the SQL opens a transaction, and a failing statement stops the run
176
+ * after the ones before it took effect. Integers are read exactly, as BigInt.
177
+ */
178
+ function runSqliteStatements(db, sql) {
179
+ const counters = db.prepare("SELECT last_insert_rowid() AS last_row_id, total_changes() AS total").safeIntegers(true);
180
+ const readCounters = () => counters.get() ?? {
181
+ last_row_id: 0n,
182
+ total: 0n
183
+ };
184
+ const results = [];
185
+ for (const statementSql of splitSqliteStatements(sql)) {
186
+ const statement = db.prepare(statementSql).safeIntegers(true);
187
+ const before = readCounters().total;
188
+ const started = performance.now();
189
+ let rows = [];
190
+ if (statement.reader) {
191
+ const columns = statement.columns().map((column) => column.name);
192
+ rows = statement.raw(true).all().map((values) => Object.fromEntries(columns.map((name, index) => [name, values[index]])));
193
+ } else statement.run();
194
+ const duration = performance.now() - started;
195
+ const after = readCounters();
196
+ results.push({
197
+ results: rows,
198
+ success: true,
199
+ meta: {
200
+ changes: after.total - before,
201
+ last_row_id: after.last_row_id,
202
+ duration
203
+ }
204
+ });
205
+ }
206
+ return results;
207
+ }
208
+ /** Parse JSON keeping each number's digits, which `JSON.stringify` then writes back unchanged. */
209
+ function parseExactJson(text) {
210
+ return JSON.parse(text, (_key, value, context) => typeof value === "number" ? JSON.rawJSON(context.source ?? String(value)) : value);
211
+ }
212
+ function parseExactJsonElements(values) {
213
+ return values.map((value) => Array.isArray(value) ? parseExactJsonElements(value) : value === null ? null : parseExactJson(value));
214
+ }
215
+ const PG_TEXT_ARRAY = 1009;
216
+ const PG_NUMERIC_ARRAY = 1231;
217
+ const PG_JSON = 114;
218
+ const PG_JSONB = 3802;
219
+ const PG_JSON_ARRAY = 199;
220
+ const PG_JSONB_ARRAY = 3807;
221
+ const PG_DATE = 1082;
222
+ const PG_TIMESTAMP = 1114;
223
+ const PG_TIMESTAMPTZ = 1184;
224
+ const PG_DATE_ARRAY = 1182;
225
+ const PG_TIMESTAMP_ARRAY = 1115;
226
+ const PG_TIMESTAMPTZ_ARRAY = 1185;
227
+ /**
228
+ * Type parsers for `void db execute --json` on PostgreSQL. node-postgres reads `numeric[]`
229
+ * elements as numbers and JSON with `JSON.parse`, which round what a double cannot hold. Here a
230
+ * `numeric[]` element stays a string, like a `numeric`, and a JSON number keeps its digits.
231
+ * Dates and timestamps stay the text PostgreSQL sends: node-postgres reads a `date` or a
232
+ * `timestamp` in the machine's time zone and rounds to milliseconds, so the same row would
233
+ * print differently on each machine.
234
+ */
235
+ function pgJsonTypes(types) {
236
+ const parseTextArray = types.getTypeParser(PG_TEXT_ARRAY, "text");
237
+ const parsers = /* @__PURE__ */ new Map([
238
+ [PG_NUMERIC_ARRAY, parseTextArray],
239
+ [PG_JSON, parseExactJson],
240
+ [PG_JSONB, parseExactJson],
241
+ [PG_JSON_ARRAY, (value) => parseExactJsonElements(parseTextArray(value))],
242
+ [PG_JSONB_ARRAY, (value) => parseExactJsonElements(parseTextArray(value))],
243
+ [PG_DATE, (value) => value],
244
+ [PG_TIMESTAMP, (value) => value],
245
+ [PG_TIMESTAMPTZ, (value) => value],
246
+ [PG_DATE_ARRAY, parseTextArray],
247
+ [PG_TIMESTAMP_ARRAY, parseTextArray],
248
+ [PG_TIMESTAMPTZ_ARRAY, parseTextArray]
249
+ ]);
250
+ return { getTypeParser(oid, format = "text") {
251
+ return (format === "text" ? parsers.get(oid) : void 0) ?? types.getTypeParser(oid, format);
252
+ } };
253
+ }
254
+ /**
255
+ * mysql2's `typeCast` for `void db execute --json`. mysql2 reads JSON with `JSON.parse`, which
256
+ * rounds what a double cannot hold, so a JSON number keeps its digits here, as on PostgreSQL.
257
+ * MySQL sends JSON as binary, which is UTF-8 text; MariaDB sends it as text and marks it as JSON
258
+ * only in its extended metadata.
259
+ */
260
+ function mySqlJsonTypeCast(field, next) {
261
+ const isJson = field.type === "JSON";
262
+ if (!isJson && field.extendedFormat !== "json") return next();
263
+ const text = isJson ? field.string("utf8") : field.string();
264
+ return text === null ? null : parseExactJson(text);
265
+ }
266
+ /**
267
+ * node-postgres returns one result for one statement and an array for several. SQL without a
268
+ * statement returns an empty-query result with no command, which is left out.
269
+ */
270
+ function pgStatementResults(result) {
271
+ return (Array.isArray(result) ? result : [result]).filter((item) => item.command !== null && item.command !== void 0).map((item) => ({
272
+ results: item.rows ?? [],
273
+ success: true,
274
+ meta: {
275
+ command: item.command,
276
+ rowCount: item.rowCount ?? null
277
+ }
278
+ }));
279
+ }
280
+ function mySqlCount(field) {
281
+ return typeof field === "number" || typeof field === "string" ? field : 0;
282
+ }
283
+ const UINT64_RANGE = 2n ** 64n;
284
+ /**
285
+ * The insert ID of a result header. MySQL sends it as an unsigned 64-bit integer, which mysql2
286
+ * reads as a signed one, so an ID of 2^63 or more, from a BIGINT UNSIGNED column, arrives
287
+ * negative.
288
+ */
289
+ function mySqlInsertId(field) {
290
+ const id = mySqlCount(field);
291
+ return (typeof id === "number" ? id < 0 : id.startsWith("-")) ? (BigInt(id) + UINT64_RANGE).toString() : id;
292
+ }
293
+ function mySqlHeaderMeta(value) {
294
+ const header = typeof value === "object" && value !== null ? value : {};
295
+ return {
296
+ affectedRows: mySqlCount(header.affectedRows),
297
+ insertId: mySqlInsertId(header.insertId)
298
+ };
299
+ }
300
+ function mySqlStatementResult(value) {
301
+ return Array.isArray(value) ? {
302
+ results: value,
303
+ success: true,
304
+ meta: {}
305
+ } : {
306
+ results: [],
307
+ success: true,
308
+ meta: mySqlHeaderMeta(value)
309
+ };
310
+ }
311
+ /** Reads what `mySqlServerMode()` needs. It only matters for SQL that `needsMySqlServerMode` finds. */
312
+ const MYSQL_SERVER_MODE_QUERY = "SELECT @@SESSION.sql_mode AS sql_mode, VERSION() AS version";
313
+ /**
314
+ * Whether the SQL holds a backslash, a double quote, a `[` or an executable comment, which read
315
+ * differently per server. A double quote opens a string, or in `ANSI_QUOTES` mode a name, such
316
+ * as the name of a prepared statement.
317
+ */
318
+ function needsMySqlServerMode(sql) {
319
+ return /[\\"[]|\/\*M?!/u.test(sql);
320
+ }
321
+ /** Read the row `MYSQL_SERVER_MODE_QUERY` returns. */
322
+ function mySqlServerMode(rows) {
323
+ const row = Array.isArray(rows) ? rows[0] : void 0;
324
+ const fields = typeof row === "object" && row !== null ? row : {};
325
+ const modes = typeof fields.sql_mode === "string" ? fields.sql_mode.split(",") : [];
326
+ const versionText = String(fields.version ?? "");
327
+ const version = /^(\d+)\.(\d+)\.(\d+)/.exec(versionText);
328
+ const mariaDb = /mariadb/iu.test(versionText);
329
+ return {
330
+ version: version ? Number(version[1]) * 1e4 + Number(version[2]) * 100 + Number(version[3]) : Number.POSITIVE_INFINITY,
331
+ backslashEscapes: !modes.includes("NO_BACKSLASH_ESCAPES"),
332
+ ansiQuotes: modes.includes("ANSI_QUOTES"),
333
+ brackets: mariaDb && modes.includes("MSSQL"),
334
+ mariaDb
335
+ };
336
+ }
337
+ /** Whether the character after `--` (`NaN` at the end of the input) makes it a comment. */
338
+ function startsMySqlDashComment(code) {
339
+ return Number.isNaN(code) || code <= 32 || code === 127;
340
+ }
341
+ /**
342
+ * The index after the comment whose text starts at `index`, or `undefined` when it does not
343
+ * close. A skipped version comment may hold one nested comment (`nesting` 1); any other comment
344
+ * ends at its first closing marker.
345
+ */
346
+ function skipMySqlComment(sql, index, nesting) {
347
+ while (index < sql.length) {
348
+ const character = sql[index++];
349
+ if (nesting > 0 && character === "/" && sql[index] === "*") {
350
+ const end = skipMySqlComment(sql, index + 1, nesting - 1);
351
+ if (end === void 0) return;
352
+ index = end;
353
+ } else if (character === "*" && sql[index] === "/") return index + 1;
354
+ }
355
+ }
356
+ const MYSQL_VERSION_COMMENT = /!(?:(\d{6})(?=\s)|(\d{5}))?/y;
357
+ const MARIADB_VERSION_COMMENT = /(M?)!(?:(\d{6})|(\d{5}))?/y;
358
+ /** The index after the marker of an executable comment the server runs at `index`, if any. */
359
+ function runsMySqlComment(sql, index, mode) {
360
+ const marker = mode.mariaDb ? MARIADB_VERSION_COMMENT : MYSQL_VERSION_COMMENT;
361
+ marker.lastIndex = index;
362
+ const match = marker.exec(sql);
363
+ if (!match) return;
364
+ const digits = mode.mariaDb ? match[2] ?? match[3] : match[1] ?? match[2];
365
+ if (digits === void 0) return marker.lastIndex;
366
+ const required = Number(digits);
367
+ const mySqlOnly = mode.mariaDb && match[1] !== "M" && required >= 50700 && required <= 99999;
368
+ return required <= mode.version && !mySqlOnly ? marker.lastIndex : void 0;
369
+ }
370
+ const MYSQL_DEFAULT_MODE = {
371
+ version: Number.POSITIVE_INFINITY,
372
+ backslashEscapes: true,
373
+ ansiQuotes: false,
374
+ brackets: false,
375
+ mariaDb: false
376
+ };
377
+ function newMySqlLexer() {
378
+ return {
379
+ index: 0,
380
+ start: 0,
381
+ inVersionComment: false,
382
+ modal: false,
383
+ rejected: false,
384
+ comment: false
385
+ };
386
+ }
387
+ /** The index after the `[name]` that opens at `open`, where `]]` stands for `]`. */
388
+ function closeMySqlBracket(sql, open) {
389
+ let index = open + 1;
390
+ for (;;) {
391
+ const close = sql.indexOf("]", index);
392
+ if (close === -1) return;
393
+ if (sql[close + 1] !== "]") return close + 1;
394
+ index = close + 2;
395
+ }
396
+ }
397
+ const MYSQL_WORD = /[\w$\u0080-￿]+/uy;
398
+ /**
399
+ * The next word, semicolon or other character of MySQL SQL after any whitespace and comments,
400
+ * lowercased, or `undefined` at the end. A quoted string or name is one word, as written with
401
+ * its quotes. The SQL in an executable comment (`/*!`, and `/*M!` on MariaDB) counts when the
402
+ * server runs it.
403
+ */
404
+ function readMySqlWord(sql, lexer, mode) {
405
+ while (lexer.index < sql.length) {
406
+ const index = lexer.index;
407
+ const character = sql[index];
408
+ const next = sql[index + 1];
409
+ lexer.start = index;
410
+ if (character === "'" || character === "\"" || character === "`") {
411
+ const name = character === "`" || character === "\"" && mode.ansiQuotes;
412
+ const end = closeMySqlQuoted(sql, index, character, mode.backslashEscapes && !name);
413
+ lexer.rejected ||= end === void 0;
414
+ lexer.index = end ?? sql.length;
415
+ const word = sql.slice(index, lexer.index);
416
+ lexer.modal ||= character !== "`" && word.includes("\\");
417
+ return word;
418
+ }
419
+ if (character === "[") {
420
+ lexer.modal ||= mode.mariaDb;
421
+ if (!mode.brackets) lexer.rejected = true;
422
+ else {
423
+ const end = closeMySqlBracket(sql, index);
424
+ lexer.rejected ||= end === void 0;
425
+ lexer.index = end ?? sql.length;
426
+ return sql.slice(index, lexer.index);
427
+ }
428
+ }
429
+ if (character === "#" || character === "-" && next === "-" && startsMySqlDashComment(sql.charCodeAt(index + 2))) {
430
+ const newline = sql.indexOf("\n", index);
431
+ lexer.index = newline === -1 ? sql.length : newline;
432
+ lexer.comment = true;
433
+ } else if (lexer.inVersionComment && character === "*" && next === "/") {
434
+ lexer.inVersionComment = false;
435
+ lexer.index += 2;
436
+ } else if (character === "/" && next === "*") {
437
+ const executable = /^M?!/u.test(sql.slice(index + 2, index + 4));
438
+ const runsFrom = executable ? runsMySqlComment(sql, index + 2, mode) : void 0;
439
+ lexer.comment = true;
440
+ if (runsFrom !== void 0) {
441
+ lexer.inVersionComment = true;
442
+ lexer.index = runsFrom;
443
+ } else {
444
+ const end = skipMySqlComment(sql, index + 2, executable ? 1 : 0);
445
+ lexer.rejected ||= end === void 0;
446
+ lexer.index = end ?? sql.length;
447
+ }
448
+ } else if (/[ \t\n\v\f\r]/u.test(character)) lexer.index++;
449
+ else {
450
+ MYSQL_WORD.lastIndex = index;
451
+ const token = MYSQL_WORD.exec(sql)?.[0] ?? character;
452
+ lexer.index += token.length;
453
+ return token.toLowerCase();
454
+ }
455
+ }
456
+ }
457
+ const MYSQL_STORED_PROGRAMS = /* @__PURE__ */ new Set([
458
+ "procedure",
459
+ "function",
460
+ "trigger",
461
+ "event"
462
+ ]);
463
+ const MYSQL_OTHER_OBJECTS = /* @__PURE__ */ new Set([
464
+ "database",
465
+ "fulltext",
466
+ "index",
467
+ "instance",
468
+ "logfile",
469
+ "resource",
470
+ "role",
471
+ "schema",
472
+ "sequence",
473
+ "server",
474
+ "spatial",
475
+ "table",
476
+ "tablespace",
477
+ "temporary",
478
+ "undo",
479
+ "unique",
480
+ "user",
481
+ "view"
482
+ ]);
483
+ const MYSQL_CONTROL_BLOCKS = /* @__PURE__ */ new Set([
484
+ "if",
485
+ "loop",
486
+ "while",
487
+ "repeat",
488
+ "for"
489
+ ]);
490
+ const MYSQL_PROCEDURE_CHARACTERISTICS = /* @__PURE__ */ new Set([
491
+ "comment",
492
+ "contains",
493
+ "data",
494
+ "definer",
495
+ "deterministic",
496
+ "invoker",
497
+ "language",
498
+ "modifies",
499
+ "no",
500
+ "not",
501
+ "reads",
502
+ "security",
503
+ "sql"
504
+ ]);
505
+ const MYSQL_BODY_BLOCKS = /* @__PURE__ */ new Set([
506
+ "begin",
507
+ "case",
508
+ ...MYSQL_CONTROL_BLOCKS
509
+ ]);
510
+ const MYSQL_OPERAND_BEFORE = /* @__PURE__ */ new Set([
511
+ "and",
512
+ "between",
513
+ "binary",
514
+ "case",
515
+ "div",
516
+ "else",
517
+ "elseif",
518
+ "if",
519
+ "in",
520
+ "interval",
521
+ "is",
522
+ "like",
523
+ "mod",
524
+ "not",
525
+ "of",
526
+ "or",
527
+ "regexp",
528
+ "return",
529
+ "rlike",
530
+ "then",
531
+ "until",
532
+ "when",
533
+ "while",
534
+ "xor"
535
+ ]);
536
+ /** Whether an operand follows `previous`, the word before it in an expression. */
537
+ function expectsMySqlOperand(previous) {
538
+ return previous === void 0 || MYSQL_OPERAND_BEFORE.has(previous) || previous.length === 1 && !/[\w$)?}\u0080-￿]/u.test(previous);
539
+ }
540
+ const MYSQL_HANDLER_ACTIONS = /* @__PURE__ */ new Set([
541
+ "continue",
542
+ "exit",
543
+ "undo"
544
+ ]);
545
+ /** Where a handler's conditions are after `word`, or `'statement'` when its statement starts. */
546
+ function nextMySqlHandlerPart(part, word) {
547
+ switch (part) {
548
+ case "for": return word === "for" ? "condition" : void 0;
549
+ case "condition": return word === "sqlstate" ? "sqlstate" : word === "not" ? "last" : "after";
550
+ case "sqlstate": return word === "value" ? "last" : "after";
551
+ case "last": return "after";
552
+ default: return word === "," ? "condition" : "statement";
553
+ }
554
+ }
555
+ /**
556
+ * Close the innermost block at an END. `next` is the word after it, which names the block for
557
+ * END IF, END LOOP, END WHILE, END REPEAT, END FOR and END CASE. Returns whether `next` belongs
558
+ * to the END.
559
+ */
560
+ function closeMySqlBlock(blocks, next) {
561
+ const top = blocks.at(-1)?.kind;
562
+ if (top === "caseExpression") {
563
+ blocks.pop();
564
+ return next === "case";
565
+ }
566
+ if (next !== void 0 && MYSQL_CONTROL_BLOCKS.has(next)) {
567
+ if (top === next || next === "loop" && (top === "while" || top === "for")) blocks.pop();
568
+ return true;
569
+ }
570
+ if (next === "case") {
571
+ if (top === "case") blocks.pop();
572
+ return true;
573
+ }
574
+ for (let index = blocks.length - 1; index >= 0; index--) if (blocks[index].kind === "begin" || blocks[index].kind === "case") {
575
+ blocks.length = index;
576
+ break;
577
+ }
578
+ return false;
579
+ }
580
+ /**
581
+ * Read one top-level statement of MySQL SQL the way a server in `mode` does, from where `lexer`
582
+ * is to its `;` or the end of the SQL.
583
+ *
584
+ * A statement ends at a semicolon outside any block. A stored program's body (`CREATE
585
+ * PROCEDURE`, `FUNCTION`, `TRIGGER` or `EVENT`, and `ALTER EVENT`) holds statements of its own:
586
+ * a BEGIN block, or an IF, CASE, LOOP, WHILE, REPEAT or MariaDB FOR statement, which may also
587
+ * stand alone as the body. MariaDB also runs these, and BEGIN NOT ATOMIC blocks, outside stored
588
+ * programs. Each opens a block only where a statement starts, a handler's statement among them,
589
+ * so the IF() function and DROP TABLE IF EXISTS do not, and BEGIN elsewhere starts a transaction
590
+ * or is a name. END closes a block where a statement starts too, and ends a CASE expression or
591
+ * a REPEAT's UNTIL condition after an operand; elsewhere it is a name, as `begin` and `end`
592
+ * columns are. A CASE expression nests anywhere. A word after a dot or right after an `@` is a
593
+ * name, such as the column in `t.case` or the variable `@case`, as is the account in
594
+ * `DEFINER = account`, but the dot in a number such as `1.` is its decimal point.
595
+ */
596
+ function readMySqlStatement(sql, lexer, mode) {
597
+ lexer.modal = false;
598
+ lexer.rejected = false;
599
+ lexer.comment = false;
600
+ const words = [];
601
+ const blocks = [];
602
+ let program;
603
+ let otherObject = false;
604
+ let head = "name";
605
+ let parentheses = 0;
606
+ let returns = false;
607
+ let depth = 0;
608
+ let handler;
609
+ let startsNext = true;
610
+ let startedLast = false;
611
+ let namesBlock = false;
612
+ let wordEnd = -1;
613
+ let named = false;
614
+ let decimalPoint = false;
615
+ const result = (terminated) => ({
616
+ words,
617
+ end: lexer.index,
618
+ inVersionComment: lexer.inVersionComment,
619
+ terminated,
620
+ modal: lexer.modal,
621
+ rejected: lexer.rejected,
622
+ comment: lexer.comment
623
+ });
624
+ const ahead = (count) => {
625
+ const copy = { ...lexer };
626
+ return Array.from({ length: count }, () => readMySqlWord(sql, copy, mode));
627
+ };
628
+ for (let word = readMySqlWord(sql, lexer, mode); word !== void 0; word = readMySqlWord(sql, lexer, mode)) {
629
+ const touches = lexer.start === wordEnd;
630
+ wordEnd = lexer.index;
631
+ if (word === ";") {
632
+ if (blocks.length === 0) return result(true);
633
+ words.push(word);
634
+ startsNext = true;
635
+ startedLast = false;
636
+ namesBlock = false;
637
+ named = false;
638
+ decimalPoint = false;
639
+ handler = void 0;
640
+ continue;
641
+ }
642
+ const previous = words.at(-1);
643
+ const afterDecimalPoint = decimalPoint;
644
+ const operandBefore = !named && !afterDecimalPoint && expectsMySqlOperand(previous);
645
+ decimalPoint = word === "." && touches && /^\d+$/u.test(previous ?? "") && !named;
646
+ named = false;
647
+ words.push(word);
648
+ let starts = startsNext;
649
+ startsNext = false;
650
+ const afterLabel = word === ":" && startedLast;
651
+ startedLast = false;
652
+ const closing = namesBlock;
653
+ namesBlock = false;
654
+ if (word === "(") depth++;
655
+ else if (word === ")") depth--;
656
+ if (previous === "." && !afterDecimalPoint || previous === "@" && touches) {
657
+ named = true;
658
+ continue;
659
+ }
660
+ if ((words[0] === "create" || words[0] === "alter") && program === void 0 && !otherObject) {
661
+ if (previous === "=" && words.at(-3) === "definer") continue;
662
+ if (MYSQL_STORED_PROGRAMS.has(word)) {
663
+ program = word;
664
+ continue;
665
+ }
666
+ otherObject = MYSQL_OTHER_OBJECTS.has(word);
667
+ } else if (program !== void 0 && head !== "body") {
668
+ const routine = program === "procedure" || program === "function";
669
+ if (head === "name") {
670
+ if (word === "(" && routine) {
671
+ head = "parameters";
672
+ parentheses = 1;
673
+ } else if (program === "trigger" && word === "row" && previous === "each") head = "triggerOrder";
674
+ else if (program === "event" && word === "do" && ![
675
+ "event",
676
+ "exists",
677
+ "to"
678
+ ].includes(previous ?? "") || routine && (word === "as" || word === "is")) {
679
+ head = "body";
680
+ startsNext = true;
681
+ }
682
+ } else if (head === "parameters") {
683
+ if (word === "(") parentheses++;
684
+ else if (word === ")" && --parentheses === 0) head = "characteristics";
685
+ } else if (head === "characteristics") {
686
+ if (word === ":" || word === "as" || word === "is") {
687
+ head = "body";
688
+ startsNext = true;
689
+ } else if (program === "procedure") {
690
+ if (!MYSQL_PROCEDURE_CHARACTERISTICS.has(word) && !/^['"]/u.test(word)) {
691
+ head = "body";
692
+ starts = true;
693
+ }
694
+ } else if (word === "return" || MYSQL_BODY_BLOCKS.has(word)) {
695
+ head = "body";
696
+ starts = true;
697
+ returns = word === "return";
698
+ }
699
+ } else if (head === "triggerOrder") {
700
+ if (word === "follows" || word === "precedes") head = "triggerOrderName";
701
+ else {
702
+ head = "body";
703
+ starts = true;
704
+ }
705
+ } else {
706
+ head = "body";
707
+ startsNext = true;
708
+ }
709
+ }
710
+ if (handler !== void 0) {
711
+ const part = nextMySqlHandlerPart(handler, word);
712
+ handler = part === "statement" ? void 0 : part;
713
+ starts ||= part === "statement";
714
+ } else if (word === "handler" && blocks.length > 0 && MYSQL_HANDLER_ACTIONS.has(previous ?? "") && words.at(-3) === "declare") handler = "for";
715
+ const top = blocks.at(-1);
716
+ if (closing && (MYSQL_CONTROL_BLOCKS.has(word) || word === "case")) {} else if (starts && MYSQL_CONTROL_BLOCKS.has(word)) {
717
+ blocks.push({
718
+ kind: word,
719
+ depth,
720
+ past: false
721
+ });
722
+ startsNext = word === "loop" || word === "repeat";
723
+ } else if (word === "case") blocks.push({
724
+ kind: starts ? "case" : "caseExpression",
725
+ depth,
726
+ past: false
727
+ });
728
+ else if (word === "begin" && starts && (program !== void 0 || blocks.length > 0 || ahead(2).join(" ") === "not atomic")) {
729
+ blocks.push({
730
+ kind: "begin",
731
+ depth,
732
+ past: false
733
+ });
734
+ startsNext = true;
735
+ } else if (word === "end" && top !== void 0 && (starts || (top.kind === "caseExpression" || top.kind === "repeat" && top.past) && top.depth === depth && !operandBefore)) namesBlock = closeMySqlBlock(blocks, ahead(1)[0]);
736
+ else if (word === "until" && starts && top?.kind === "repeat") top.past = true;
737
+ else if (word === "do" && (top?.kind === "while" || top?.kind === "for") && !top.past && top.depth === depth && !operandBefore) {
738
+ top.past = true;
739
+ startsNext = true;
740
+ } else if ((word === "then" || word === "else") && top?.kind !== "caseExpression" || word === "loop" || afterLabel || word === "atomic" && previous === "not" && words.at(-3) === "begin" || returns && blocks.length === 0 && depth === 0 && (word === "as" || word === "is")) startsNext = true;
741
+ startedLast = starts;
742
+ }
743
+ return result(false);
744
+ }
745
+ const MYSQL_ANSI_QUOTES_MODES = /* @__PURE__ */ new Set([
746
+ "ANSI",
747
+ "ANSI_QUOTES",
748
+ "DB2",
749
+ "MAXDB",
750
+ "MSSQL",
751
+ "ORACLE",
752
+ "POSTGRESQL"
753
+ ]);
754
+ const MYSQL_GLOBAL_SCOPES = /* @__PURE__ */ new Set([
755
+ "global",
756
+ "persist",
757
+ "persist_only"
758
+ ]);
759
+ const MYSQL_SESSION_SCOPES = /* @__PURE__ */ new Set(["session", "local"]);
760
+ /** Whether a word is a quoted name. */
761
+ function isMySqlQuotedName(word, mode) {
762
+ const quote = word?.[0];
763
+ return quote === "`" || quote === "\"" && mode.ansiQuotes || quote === "[" && mode.brackets;
764
+ }
765
+ /** The name a word gives, unquoted and lowercased. */
766
+ function mySqlName(word, mode) {
767
+ if (isMySqlQuotedName(word, mode)) {
768
+ const close = word[0] === "[" ? "]" : word[0];
769
+ return word.slice(1, -1).replaceAll(`${close}${close}`, close).toLowerCase();
770
+ }
771
+ return word;
772
+ }
773
+ /** Whether a word is a quoted string, not a name. */
774
+ function isMySqlString(word, mode) {
775
+ const quote = word?.[0];
776
+ return word !== void 0 && (quote === "'" || quote === "\"" && !mode.ansiQuotes) && word.length >= 2 && word.endsWith(quote);
777
+ }
778
+ const MYSQL_ESCAPES = /* @__PURE__ */ new Map([
779
+ ["0", "\0"],
780
+ ["b", "\b"],
781
+ ["n", "\n"],
782
+ ["r", "\r"],
783
+ ["t", " "],
784
+ ["Z", ""],
785
+ ["%", String.raw`\%`],
786
+ ["_", String.raw`\_`]
787
+ ]);
788
+ /** The text of a quoted string. */
789
+ function mySqlStringText(word, mode) {
790
+ const quote = word[0];
791
+ let text = "";
792
+ for (let index = 1; index < word.length - 1; index++) {
793
+ const character = word[index];
794
+ if (character === "\\" && mode.backslashEscapes) {
795
+ const escaped = word[++index];
796
+ text += MYSQL_ESCAPES.get(escaped) ?? escaped;
797
+ } else {
798
+ text += character;
799
+ if (character === quote) index++;
800
+ }
801
+ }
802
+ return text;
803
+ }
804
+ /** The quoting rules a quoted list of modes, such as `'ANSI,NO_BACKSLASH_ESCAPES'`, sets. */
805
+ function mySqlModeList(value, mode) {
806
+ const [word] = value;
807
+ if (value.length !== 1 || !isMySqlString(word, mode)) return "unclear";
808
+ const text = word.slice(1, -1);
809
+ if (!/^[A-Za-z_,]*$/u.test(text)) return "unclear";
810
+ const modes = text.toUpperCase().split(",");
811
+ return {
812
+ backslashEscapes: !modes.includes("NO_BACKSLASH_ESCAPES"),
813
+ ansiQuotes: modes.some((name) => MYSQL_ANSI_QUOTES_MODES.has(name)),
814
+ brackets: mode.mariaDb && modes.includes("MSSQL")
815
+ };
816
+ }
817
+ /** Split words at top-level commas, or at the first top-level word `at` when one is given. */
818
+ function splitMySqlWords(words, at = ",") {
819
+ let current = [];
820
+ const parts = [current];
821
+ let parentheses = 0;
822
+ for (const word of words) {
823
+ if (word === at && parentheses === 0 && (at === "," || parts.length === 1)) {
824
+ current = [];
825
+ parts.push(current);
826
+ continue;
827
+ }
828
+ if (word === "(") parentheses++;
829
+ else if (word === ")") parentheses--;
830
+ current.push(word);
831
+ }
832
+ return parts;
833
+ }
834
+ /**
835
+ * How a SET statement changes the session's quoting rules. `SET GLOBAL` leaves them alone, as
836
+ * does a SET of a user variable.
837
+ */
838
+ function mySqlSetChange(words, mode) {
839
+ const assignments = splitMySqlWords(words.slice(1));
840
+ let change;
841
+ let global = false;
842
+ for (const assignment of assignments) {
843
+ let index = 0;
844
+ if (MYSQL_GLOBAL_SCOPES.has(assignment[index])) {
845
+ global = true;
846
+ index++;
847
+ } else if (MYSQL_SESSION_SCOPES.has(assignment[index])) {
848
+ global = false;
849
+ index++;
850
+ }
851
+ let targetsGlobal = global;
852
+ if (assignment[index] === "@") {
853
+ if (assignment[index + 1] !== "@") continue;
854
+ index += 2;
855
+ targetsGlobal = false;
856
+ if (assignment[index + 1] === ".") {
857
+ targetsGlobal = MYSQL_GLOBAL_SCOPES.has(assignment[index]);
858
+ index += 2;
859
+ }
860
+ }
861
+ if (targetsGlobal || mySqlName(assignment[index], mode) !== "sql_mode") continue;
862
+ index++;
863
+ if (assignment[index] === ":") index++;
864
+ change = assignment[index] === "=" ? mySqlModeList(assignment.slice(index + 1), mode) : "unclear";
865
+ }
866
+ return change;
867
+ }
868
+ const MYSQL_SINGLE = {
869
+ kind: "single",
870
+ change: void 0
871
+ };
872
+ const MYSQL_REJECTED = {
873
+ ...MYSQL_SINGLE,
874
+ rejected: true
875
+ };
876
+ /**
877
+ * Whether the server rejects the text a PREPARE or EXECUTE IMMEDIATE is given: a quoted name
878
+ * there, such as a double-quoted text in `ANSI_QUOTES` mode, names no statement.
879
+ */
880
+ function rejectsMySqlSource(source, mode) {
881
+ return source.length === 1 && isMySqlQuotedName(source[0], mode);
882
+ }
883
+ /** The statement in a PREPARE's or EXECUTE IMMEDIATE's text, when it is a quoted string. */
884
+ function mySqlPreparedStatement(source, mode) {
885
+ const [word] = source;
886
+ if (source.length !== 1 || !isMySqlString(word, mode)) return;
887
+ const { words } = readMySqlStatement(mySqlStringText(word, mode), newMySqlLexer(), mode);
888
+ const { kind, change } = mySqlStatementEffect(words, mode, /* @__PURE__ */ new Map());
889
+ return {
890
+ kind,
891
+ change
892
+ };
893
+ }
894
+ /**
895
+ * What a top-level statement does. A CALL, and a compound statement that MariaDB runs outside
896
+ * a stored program (a BEGIN NOT ATOMIC block, IF, CASE, LOOP, WHILE, REPEAT or FOR), return
897
+ * their results like a CALL. So does an EXECUTE, or MariaDB's EXECUTE IMMEDIATE, of a CALL.
898
+ * MariaDB's SET STATEMENT ... FOR returns what the statement after FOR does, and keeps what it
899
+ * changes unless it sets sql_mode itself, which it then restores. A stored program, and a
900
+ * compound statement, run with a sql_mode of their own and restore the session's.
901
+ */
902
+ function mySqlStatementEffect(words, mode, prepared) {
903
+ const [first, second] = words;
904
+ if (first === "call" || first === "case" || MYSQL_CONTROL_BLOCKS.has(first) || first === "begin" && second === "not" && words[2] === "atomic") return {
905
+ kind: "call",
906
+ change: void 0
907
+ };
908
+ if (first === "execute") {
909
+ if (second === "immediate" && words.length > 2 && words[2] !== "using") {
910
+ const [source] = splitMySqlWords(words.slice(2), "using");
911
+ return {
912
+ ...mySqlPreparedStatement(source, mode) ?? {
913
+ kind: "unknown",
914
+ change: "unclear"
915
+ },
916
+ rejected: rejectsMySqlSource(source, mode)
917
+ };
918
+ }
919
+ if (isMySqlString(second, mode)) return MYSQL_REJECTED;
920
+ const name = mySqlName(second, mode) ?? "";
921
+ return {
922
+ ...prepared.get(name) ?? {
923
+ kind: "unknown",
924
+ change: "unclear"
925
+ },
926
+ executes: name
927
+ };
928
+ }
929
+ if (first === "prepare" && words[2] === "from") {
930
+ if (isMySqlString(second, mode)) return MYSQL_REJECTED;
931
+ const source = words.slice(3);
932
+ return {
933
+ ...MYSQL_SINGLE,
934
+ prepares: {
935
+ name: mySqlName(second, mode),
936
+ statement: mySqlPreparedStatement(source, mode)
937
+ },
938
+ rejected: rejectsMySqlSource(source, mode)
939
+ };
940
+ }
941
+ if ((first === "deallocate" || first === "drop") && second === "prepare") {
942
+ if (isMySqlString(words[2], mode)) return MYSQL_REJECTED;
943
+ return {
944
+ ...MYSQL_SINGLE,
945
+ prepares: {
946
+ name: mySqlName(words[2], mode),
947
+ statement: void 0,
948
+ deallocates: true
949
+ }
950
+ };
951
+ }
952
+ if (first === "set" && second === "statement") {
953
+ const [settings, statement] = splitMySqlWords(words.slice(2), "for");
954
+ if (statement === void 0) return MYSQL_SINGLE;
955
+ const effect = mySqlStatementEffect(statement, mode, prepared);
956
+ return settings.some((word) => mySqlName(word, mode) === "sql_mode") ? {
957
+ ...effect,
958
+ change: void 0
959
+ } : effect;
960
+ }
961
+ if (first === "set") return {
962
+ kind: "single",
963
+ change: mySqlSetChange(words, mode)
964
+ };
965
+ return MYSQL_SINGLE;
966
+ }
967
+ /**
968
+ * Each quoting mode a server of `mode`'s version and family may be in. Only MariaDB reads
969
+ * square brackets as quotes, in its MSSQL mode.
970
+ */
971
+ function mySqlQuotingModes(mode) {
972
+ return [true, false].flatMap((backslashEscapes) => [false, true].flatMap((ansiQuotes) => (mode.mariaDb ? [false, true] : [false]).map((brackets) => ({
973
+ ...mode,
974
+ backslashEscapes,
975
+ ansiQuotes,
976
+ brackets
977
+ }))));
978
+ }
979
+ /** Whether two modes read quoted text the same. */
980
+ function sameMySqlQuoting(a, b) {
981
+ return a.backslashEscapes === b.backslashEscapes && a.ansiQuotes === b.ansiQuotes && a.brackets === b.brackets;
982
+ }
983
+ /** The modes a server in `mode` may be in after a statement that makes `change`. */
984
+ function nextMySqlModes(mode, change) {
985
+ if (change === "unclear") return mySqlQuotingModes(mode);
986
+ return [change === void 0 ? mode : {
987
+ ...mode,
988
+ ...change
989
+ }];
990
+ }
991
+ /** Record what a PREPARE or DEALLOCATE does, the same in every mode the server may be in. */
992
+ function applyMySqlPrepares(prepared, effects) {
993
+ if (effects[0].kind === "call") {
994
+ const { executes } = effects[0];
995
+ for (const name of prepared.keys()) if (name !== executes) prepared.delete(name);
996
+ return;
997
+ }
998
+ const [{ prepares }] = effects;
999
+ if (prepares === void 0) return;
1000
+ const agree = effects.every((effect) => JSON.stringify(effect.prepares) === JSON.stringify(prepares));
1001
+ for (const effect of effects) {
1002
+ const name = effect.prepares?.name;
1003
+ if (name !== void 0) prepared.delete(name);
1004
+ }
1005
+ if (agree && prepares.name !== void 0 && prepares.statement !== void 0) prepared.set(prepares.name, prepares.statement);
1006
+ }
1007
+ const MYSQL_UNKNOWN_EXECUTE = "db: `void db execute --json` cannot tell whether an EXECUTE in this MySQL SQL runs a CALL, which returns several results, so it cannot group them. It reads the statement that a PREPARE or EXECUTE IMMEDIATE in the same SQL takes as a quoted string, such as PREPARE s FROM 'CALL p()', but a procedure may prepare a statement again, so it forgets the others after a CALL. Prepare the statement again after the CALL, or run SQL that prepares a statement from a variable or an expression without --json.";
1008
+ /** The error for SQL whose statements this scan cannot tell apart, which says what it cannot do. */
1009
+ function unclearMySqlStatements(consequence, remedy) {
1010
+ return /* @__PURE__ */ new Error(`db: \`void db execute --json\` cannot tell where the statements of this MySQL SQL end, so it ${consequence}. A statement in it changes sql_mode in a way the command cannot read, such as SET sql_mode = @saved, and the mode decides how quoted text reads, such as what a backslash in a string means. Set sql_mode to a quoted list of modes, such as SET sql_mode = 'ANSI_QUOTES', or ${remedy}.`);
1011
+ }
1012
+ const MYSQL_UNCLEAR_CALL = () => unclearMySqlStatements("cannot group the results of a statement after it that returns several, such as a CALL", "run that statement in a separate command");
1013
+ /**
1014
+ * Find MySQL's statements (see `readMySqlStatement`) and tell which return their results like a
1015
+ * CALL (see `mySqlStatementEffect`), reading the SQL the way a server in `mode` does.
1016
+ *
1017
+ * The server reads each statement with the `sql_mode` the statements before it left, so a
1018
+ * `SET sql_mode` to a quoted list of modes changes how the SQL after it reads. After a statement
1019
+ * that changes it in a way this scan cannot read, the SQL is read in each quoting mode the
1020
+ * server may be in, leaving out a reading that leaves a quoted string open, or finds a `[` that
1021
+ * quotes no name, which the server rejects. Where they read different statements, the statements are `uncounted` when none of
1022
+ * them can return results like a CALL, and otherwise this throws before the SQL runs, since
1023
+ * their results could not be grouped. It also throws for an EXECUTE of a statement it cannot
1024
+ * see, which may be a CALL.
1025
+ */
1026
+ function mySqlStatements(sql, initialMode = MYSQL_DEFAULT_MODE) {
1027
+ const lexer = newMySqlLexer();
1028
+ let modes = [initialMode];
1029
+ const prepared = /* @__PURE__ */ new Map();
1030
+ const calls = [];
1031
+ let cut;
1032
+ let trailingComment = false;
1033
+ let read;
1034
+ do {
1035
+ const from = { ...lexer };
1036
+ read = readMySqlStatement(sql, lexer, modes[0]);
1037
+ let readings = modes.map((mode, index) => ({
1038
+ mode,
1039
+ read: index === 0 || !read.modal ? read : readMySqlStatement(sql, { ...from }, mode)
1040
+ }));
1041
+ const accepted = readings.filter((reading) => !reading.read.rejected);
1042
+ if (accepted.length > 0) readings = accepted;
1043
+ const [{ read: chosen }] = readings;
1044
+ read = chosen;
1045
+ if (readings.some((reading) => !sameMySqlStatement(reading.read, chosen))) return divergedMySqlStatements(sql, from, readings.map((reading) => reading.mode), {
1046
+ calls,
1047
+ prepared
1048
+ });
1049
+ lexer.index = read.end;
1050
+ lexer.inVersionComment = read.inVersionComment;
1051
+ if (read.words.length === 0) {
1052
+ trailingComment ||= read.comment;
1053
+ cut = mySqlCut(cut, read);
1054
+ continue;
1055
+ }
1056
+ let effects = readings.map((reading) => mySqlStatementEffect(read.words, reading.mode, prepared));
1057
+ if (effects.some((effect) => !effect.rejected)) {
1058
+ readings = readings.filter((_, index) => !effects[index].rejected);
1059
+ effects = effects.filter((effect) => !effect.rejected);
1060
+ }
1061
+ if (effects.some((effect) => effect.kind === "unknown")) throw new Error(MYSQL_UNKNOWN_EXECUTE);
1062
+ if (effects.some((effect) => effect.kind !== effects[0].kind)) throw MYSQL_UNCLEAR_CALL();
1063
+ calls.push(effects[0].kind === "call");
1064
+ applyMySqlPrepares(prepared, effects);
1065
+ const next = readings.flatMap((reading, index) => nextMySqlModes(reading.mode, effects[index].change));
1066
+ modes = next.filter((mode, index) => next.findIndex((other) => sameMySqlQuoting(other, mode)) === index);
1067
+ cut = mySqlCut(void 0, read);
1068
+ trailingComment = false;
1069
+ } while (read.terminated);
1070
+ return {
1071
+ calls,
1072
+ uncounted: false,
1073
+ sql: trailingComment && cut !== void 0 ? sql.slice(0, cut) : sql
1074
+ };
1075
+ }
1076
+ /**
1077
+ * Where the SQL may be cut to leave out what follows a statement, after reading `read`: at the
1078
+ * end of a statement, unless an executable comment is still open there, and not where comments
1079
+ * that follow leave one open, which the server rejects.
1080
+ */
1081
+ function mySqlCut(cut, read) {
1082
+ if (read.words.length > 0) return read.inVersionComment ? void 0 : read.end;
1083
+ return read.rejected ? void 0 : cut;
1084
+ }
1085
+ /** Whether two readings of a statement find the same words and end in the same place. */
1086
+ function sameMySqlStatement(a, b) {
1087
+ return a === b || a.end === b.end && a.inVersionComment === b.inVersionComment && a.words.length === b.words.length && a.words.every((word, index) => word === b.words[index]);
1088
+ }
1089
+ /**
1090
+ * Record a PREPARE that one way of reading diverged SQL finds, in the statements all the ways
1091
+ * share. Returns 1 when that forgets a statement some way may have read an EXECUTE with.
1092
+ *
1093
+ * A name keeps a statement while every way that prepares it prepares the same one as before,
1094
+ * or the first time. A way that does not prepare it then reads the statement prepared before,
1095
+ * which is the same, or none, and the server rejects its EXECUTE. Otherwise the name is
1096
+ * forgotten for every way. A DEALLOCATE changes nothing here: its own way then fails on the
1097
+ * server at any EXECUTE of the name, and the others still read the statement.
1098
+ */
1099
+ function prepareDivergedMySql(effect, before, prepared, conflicts) {
1100
+ const { name, statement, deallocates } = effect.prepares ?? {};
1101
+ if (name === void 0 || deallocates || conflicts.has(name)) return 0;
1102
+ const same = (other) => other === void 0 || JSON.stringify(other) === JSON.stringify(statement);
1103
+ if (statement !== void 0 && same(prepared.get(name)) && same(before.get(name))) {
1104
+ prepared.set(name, statement);
1105
+ return 0;
1106
+ }
1107
+ conflicts.add(name);
1108
+ return prepared.delete(name) ? 1 : 0;
1109
+ }
1110
+ /**
1111
+ * The statements of SQL whose quoting modes read the statement at `from` differently. Every way
1112
+ * the server may read the rest is followed to the end. They are counted only where they hold
1113
+ * no statement that returns results like a CALL, and comments after the last statement are left
1114
+ * out only where every way agrees on where they start.
1115
+ *
1116
+ * The ways share their prepared statements (see `prepareDivergedMySql`), which tells less than
1117
+ * each way knows, never more, and keeps the walk short.
1118
+ */
1119
+ function divergedMySqlStatements(sql, from, modes, before) {
1120
+ const prepared = new Map(before.prepared);
1121
+ const conflicts = /* @__PURE__ */ new Set();
1122
+ let forgotten = 0;
1123
+ const ends = /* @__PURE__ */ new Set();
1124
+ const seen = /* @__PURE__ */ new Set();
1125
+ const readings = modes.map((mode) => ({
1126
+ lexer: { ...from },
1127
+ mode,
1128
+ cut: void 0
1129
+ }));
1130
+ for (let reading = readings.pop(); reading !== void 0; reading = readings.pop()) {
1131
+ const { lexer } = reading;
1132
+ const key = JSON.stringify([
1133
+ lexer.index,
1134
+ lexer.inVersionComment,
1135
+ reading.mode.backslashEscapes,
1136
+ reading.mode.ansiQuotes,
1137
+ reading.mode.brackets,
1138
+ reading.cut,
1139
+ forgotten
1140
+ ]);
1141
+ if (seen.has(key)) continue;
1142
+ seen.add(key);
1143
+ let trailingComment = false;
1144
+ let finished = true;
1145
+ let read;
1146
+ do {
1147
+ read = readMySqlStatement(sql, lexer, reading.mode);
1148
+ if (read.rejected) {
1149
+ finished = false;
1150
+ break;
1151
+ }
1152
+ if (read.words.length === 0) {
1153
+ trailingComment ||= read.comment;
1154
+ continue;
1155
+ }
1156
+ const effect = mySqlStatementEffect(read.words, reading.mode, prepared);
1157
+ if (effect.rejected) {
1158
+ finished = false;
1159
+ break;
1160
+ }
1161
+ if (effect.kind === "unknown") throw new Error(MYSQL_UNKNOWN_EXECUTE);
1162
+ if (effect.kind === "call") throw MYSQL_UNCLEAR_CALL();
1163
+ forgotten += prepareDivergedMySql(effect, before.prepared, prepared, conflicts);
1164
+ reading.cut = mySqlCut(void 0, read);
1165
+ trailingComment = false;
1166
+ if (effect.change === "unclear") {
1167
+ for (const next of mySqlQuotingModes(reading.mode)) readings.push({
1168
+ lexer: { ...lexer },
1169
+ mode: next,
1170
+ cut: reading.cut
1171
+ });
1172
+ finished = false;
1173
+ break;
1174
+ }
1175
+ [reading.mode] = nextMySqlModes(reading.mode, effect.change);
1176
+ } while (read.terminated);
1177
+ if (finished) ends.add(trailingComment && reading.cut !== void 0 ? reading.cut : sql.length);
1178
+ }
1179
+ if (ends.size > 1) throw unclearMySqlStatements("cannot tell whether the comments after its last statement return a result of their own", "remove those comments");
1180
+ const [end = sql.length] = ends;
1181
+ return {
1182
+ calls: before.calls,
1183
+ uncounted: true,
1184
+ sql: sql.slice(0, end)
1185
+ };
1186
+ }
1187
+ /**
1188
+ * mysql2 returns `[rows, fields]`. With several result sets, `rows` holds one entry per result
1189
+ * (rows, or a result header for a write) and `fields` holds each one's column list, or
1190
+ * `undefined` for a header. A `CALL` returns each result set of the procedure and then its own
1191
+ * header, so those entries are grouped under the `CALL`, its rows in order. `statements` is what
1192
+ * `mySqlStatements` found in the SQL. SQL without a statement returns no entry, though the
1193
+ * server answers comments alone with a result header.
1194
+ */
1195
+ function mySqlStatementResults(rows, fields, statements) {
1196
+ if (statements.calls.length === 0 && !statements.uncounted) return [];
1197
+ if (!(Array.isArray(rows) && Array.isArray(fields) && fields.some((entry) => entry === void 0 || Array.isArray(entry)))) return [mySqlStatementResult(rows)];
1198
+ const entries = rows;
1199
+ const grouped = [];
1200
+ let index = 0;
1201
+ let matched = true;
1202
+ for (const isCall of statements.calls) {
1203
+ if (!isCall) {
1204
+ matched &&= index < entries.length;
1205
+ grouped.push(mySqlStatementResult(entries[index++]));
1206
+ continue;
1207
+ }
1208
+ const sets = [];
1209
+ while (index < entries.length && Array.isArray(entries[index])) sets.push(entries[index++]);
1210
+ matched &&= index < entries.length;
1211
+ grouped.push({
1212
+ results: sets.flat(),
1213
+ success: true,
1214
+ meta: mySqlHeaderMeta(entries[index++])
1215
+ });
1216
+ }
1217
+ if (statements.uncounted) {
1218
+ matched &&= index < entries.length;
1219
+ grouped.push(...entries.slice(index).map(mySqlStatementResult));
1220
+ index = entries.length;
1221
+ }
1222
+ return matched && index === entries.length ? grouped : entries.map(mySqlStatementResult);
1223
+ }
24
1224
  // src/cli/db-export-sequences.ts
25
1225
  function quoteSqlIdentifier(value) {
26
1226
  return `"${value.replaceAll("\"", "\"\"")}"`;
@@ -156,7 +1356,7 @@ function runDrizzleKit(root, args) {
156
1356
  * already printed its own error.
157
1357
  */
158
1358
  async function runDrizzleKitWithDatabaseUrl(root, url, dialect, command) {
159
- const { withPrivateDrizzleConfig } = await import("./config-dMSpL-ml.mjs");
1359
+ const { withPrivateDrizzleConfig } = await import("./config-DtjrUtPo.mjs");
160
1360
  if (!withPrivateDrizzleConfig(root, url, dialect, (configPath) => {
161
1361
  try {
162
1362
  runDrizzleKit(root, [
@@ -187,7 +1387,7 @@ async function withPgClient(root, fn) {
187
1387
  }
188
1388
  }
189
1389
  async function withMySqlClient(root, fn, options = {}) {
190
- const { toMySqlClient } = await import("./runner-mysql-C_PrAUTm.mjs");
1390
+ const { toMySqlClient } = await import("./runner-mysql-DOjbj-N1.mjs");
191
1391
  const { createConnection } = await import("mysql2/promise");
192
1392
  const connection = await createConnection({
193
1393
  uri: getLocalDatabaseUrl(root, "mysql"),
@@ -210,7 +1410,14 @@ function validatePendingMigrations(migrations, appliedNames) {
210
1410
  if (pending.length === 0) return;
211
1411
  validateMigrations(pending);
212
1412
  }
213
- async function runDbCommand(root, args) {
1413
+ async function runDbCommand(root, args, writeResults = (text) => process.stdout.write(text)) {
1414
+ if (args.action === "execute" && args.json) {
1415
+ const printResults = (results) => {
1416
+ writeResults(`${formatStatementResults(results)}\n`);
1417
+ };
1418
+ await runExecute(root, args, getDatabaseDialect(readConfig(root)), printResults);
1419
+ return;
1420
+ }
214
1421
  if (!(args.action === "export" && !args.output)) console.log();
215
1422
  const dialect = getDatabaseDialect(readConfig(root));
216
1423
  if (args.action === "push") await runPush(root, dialect);
@@ -218,7 +1425,7 @@ async function runDbCommand(root, args) {
218
1425
  else if (args.action === "status") await runStatus(root, dialect);
219
1426
  else if (args.action === "reset") await runReset(root, dialect, args.yes);
220
1427
  else if (args.action === "seed") await runSeed(root, args.file, dialect, args.yes);
221
- else if (args.action === "execute") await runExecute(root, args.command, args.file, dialect, args.remote, args.yes);
1428
+ else if (args.action === "execute") await runExecute(root, args, dialect, void 0);
222
1429
  else if (args.action === "migrate") await runMigrate(root, dialect, args.remote);
223
1430
  else if (args.action === "studio") await runStudio(root, dialect, args.remote);
224
1431
  else if (args.action === "set-url") await runSetUrl(root, dialect);
@@ -229,8 +1436,8 @@ async function runDbCommand(root, args) {
229
1436
  }
230
1437
  function writeLocalDatabaseUrl(root, connectionString) {
231
1438
  const envPath = join(root, ".env");
232
- const original = existsSync(envPath) ? readFileSync(envPath, "utf-8") : "";
233
- const lines = original ? original.replace(/\r\n/g, "\n").split("\n") : [];
1439
+ const original = existsSync(envPath) ? readFileSync(envPath, "utf8") : "";
1440
+ const lines = original ? original.replaceAll("\r\n", "\n").split("\n") : [];
234
1441
  const assignment = `DATABASE_URL=${JSON.stringify(connectionString)}`;
235
1442
  const index = lines.findIndex((line) => /^\s*(?:export\s+)?DATABASE_URL\s*=/.test(line));
236
1443
  if (index === -1) {
@@ -312,7 +1519,7 @@ async function runPush(root, dialect) {
312
1519
  printSuccess("Database schema pushed.");
313
1520
  return;
314
1521
  }
315
- const { writeDrizzleConfig } = await import("./config-dMSpL-ml.mjs");
1522
+ const { writeDrizzleConfig } = await import("./config-DtjrUtPo.mjs");
316
1523
  const { databasePath: dbPath } = getLocalD1Target(root);
317
1524
  mkdirSync(dirname(dbPath), { recursive: true });
318
1525
  const configPath = writeDrizzleConfig(root, dbPath);
@@ -328,15 +1535,15 @@ async function runPush(root, dialect) {
328
1535
  printSuccess("Database schema pushed.");
329
1536
  }
330
1537
  async function runGenerate(root, dialect) {
331
- const { prepareProject } = await import("./prepare-C2MTqfFv.mjs");
332
- const { PLACEHOLDER_DB_URL, writeDrizzleConfig } = await import("./config-dMSpL-ml.mjs");
1538
+ const { prepareProject } = await import("./prepare-DcwigRUS.mjs");
1539
+ const { PLACEHOLDER_DB_URL, writeDrizzleConfig } = await import("./config-DtjrUtPo.mjs");
333
1540
  await prepareProject(root);
334
1541
  const authSchemaPath = join(root, ".void", "better-auth-schema.ts");
335
1542
  const additionalSchemas = existsSync(authSchemaPath) ? [authSchemaPath] : void 0;
336
1543
  const configPath = writeDrizzleConfig(root, PLACEHOLDER_DB_URL[dialect], dialect, { additionalSchemas });
337
1544
  try {
338
1545
  if (dialect === "sqlite") {
339
- const { generateValidatedSqliteMigrations } = await import("./generate-BOp1g1H_.mjs");
1546
+ const { generateValidatedSqliteMigrations } = await import("./generate-C3ZAqCy-.mjs");
340
1547
  await generateValidatedSqliteMigrations(readProjectPaths(root).migrationsDir, () => {
341
1548
  runDrizzleKit(root, [
342
1549
  "generate",
@@ -372,19 +1579,19 @@ async function runStatus(root, dialect) {
372
1579
  let localApplied;
373
1580
  let localError;
374
1581
  if (dialect === "postgresql") try {
375
- const { readPgAppliedMigrations } = await import("./runner-pg-2pjltt0t.mjs");
1582
+ const { readPgAppliedMigrations } = await import("./runner-pg-DMJquR3d.mjs");
376
1583
  localApplied = await withPgClient(root, readPgAppliedMigrations);
377
1584
  } catch (error) {
378
1585
  localError = error;
379
1586
  }
380
1587
  else if (dialect === "mysql") try {
381
- const { readMySqlAppliedMigrations } = await import("./runner-mysql-C_PrAUTm.mjs");
1588
+ const { readMySqlAppliedMigrations } = await import("./runner-mysql-DOjbj-N1.mjs");
382
1589
  localApplied = await withMySqlClient(root, readMySqlAppliedMigrations);
383
1590
  } catch (error) {
384
1591
  localError = error;
385
1592
  }
386
1593
  else {
387
- const { getAppliedMigrations } = await import("./runner-CTk21HrO.mjs");
1594
+ const { getAppliedMigrations } = await import("./runner-Bf94YVJK.mjs");
388
1595
  const { databasePath: dbPath } = getLocalD1Target(root);
389
1596
  localApplied = (await getAppliedMigrations(dbPath)).map((m) => m.name);
390
1597
  }
@@ -394,12 +1601,12 @@ async function runStatus(root, dialect) {
394
1601
  if (dialect !== "sqlite") {
395
1602
  const databaseUrl = process.env.DATABASE_URL;
396
1603
  if (!databaseUrl) throw new Error("DATABASE_URL is not available.");
397
- remoteApplied = (dialect === "postgresql" ? await (await import("./runner-pg-2pjltt0t.mjs")).getPgAppliedMigrations(databaseUrl) : await (await import("./runner-mysql-C_PrAUTm.mjs")).getMySqlAppliedMigrations(databaseUrl)).map((name) => ({
1604
+ remoteApplied = (dialect === "postgresql" ? await (await import("./runner-pg-DMJquR3d.mjs")).getPgAppliedMigrations(databaseUrl) : await (await import("./runner-mysql-DOjbj-N1.mjs")).getMySqlAppliedMigrations(databaseUrl)).map((name) => ({
398
1605
  name,
399
1606
  applied_at: ""
400
1607
  }));
401
1608
  } else {
402
- const { readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-BditDbcd.mjs");
1609
+ const { readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-ByjFGats.mjs");
403
1610
  remoteApplied = (await readCloudflareD1Migrations(resolveCloudflareD1Context(root, configuredD1Binding(root)))).map((name) => ({
404
1611
  name,
405
1612
  applied_at: ""
@@ -549,7 +1756,7 @@ async function resetDatabase(root, dialect, yes) {
549
1756
  }
550
1757
  await confirmReset(root, dialect, yes);
551
1758
  if (dialect === "postgresql") {
552
- const { applyPgMigrations } = await import("./runner-pg-2pjltt0t.mjs");
1759
+ const { applyPgMigrations } = await import("./runner-pg-DMJquR3d.mjs");
553
1760
  await withPgClient(root, async (client) => {
554
1761
  const objects = await client.query(PG_RESET_OBJECTS);
555
1762
  const names = (kind) => objects.rows.filter((row) => row.kind === kind).map((row) => row.name);
@@ -567,7 +1774,7 @@ async function resetDatabase(root, dialect, yes) {
567
1774
  return migrations.length;
568
1775
  }
569
1776
  if (dialect === "mysql") {
570
- const { applyPendingMySqlMigrations, withMySqlMigrationLock } = await import("./runner-mysql-C_PrAUTm.mjs");
1777
+ const { applyPendingMySqlMigrations, withMySqlMigrationLock } = await import("./runner-mysql-DOjbj-N1.mjs");
571
1778
  await withMySqlClient(root, (client) => withMySqlMigrationLock(client, async () => {
572
1779
  const tables = await client.query("SELECT table_name AS table_name, table_type AS table_type FROM information_schema.tables WHERE table_schema = DATABASE() AND table_type IN ('BASE TABLE', 'VIEW')");
573
1780
  await client.query("SET FOREIGN_KEY_CHECKS = 0");
@@ -585,7 +1792,7 @@ async function resetDatabase(root, dialect, yes) {
585
1792
  }));
586
1793
  return migrations.length;
587
1794
  }
588
- const { runMigrations } = await import("./runner-CTk21HrO.mjs");
1795
+ const { runMigrations } = await import("./runner-Bf94YVJK.mjs");
589
1796
  const { databasePath: dbPath } = getLocalD1Target(root);
590
1797
  rmSync(dbPath, { force: true });
591
1798
  rmSync(dbPath + "-wal", { force: true });
@@ -599,38 +1806,54 @@ async function runReset(root, dialect, yes) {
599
1806
  }
600
1807
  async function runSeed(root, file, dialect, yes) {
601
1808
  const seed = resolveSeedTarget(root, file);
602
- const sql = seed.kind === "sql" ? readFileSync(seed.path, "utf-8") : void 0;
1809
+ const seedSql = seed.kind === "sql" ? readFileSync(seed.path, "utf8") : void 0;
603
1810
  await confirmReset(root, dialect, yes);
604
- const seedFn = sql === void 0 ? await loadSeedFunction(seed.path) : void 0;
605
- const migrationCount = await resetDatabase(root, dialect, true);
606
- log.step(`Reset database. Applied ${formatCount(migrationCount, "migration")}.`);
607
- if (sql !== void 0) {
608
- if (dialect === "postgresql") {
609
- await withPgClient(root, async (client) => {
610
- await client.query(sql);
611
- });
612
- printSuccess(`Seeded from ${seed.displayPath}.`);
613
- return;
614
- }
615
- if (dialect === "mysql") {
616
- await withMySqlClient(root, async (client) => {
617
- await client.query(sql);
618
- });
619
- printSuccess(`Seeded from ${seed.displayPath}.`);
620
- return;
621
- }
622
- const { openSqliteDatabase } = await import("./runner-CTk21HrO.mjs");
623
- const { databasePath: dbPath } = getLocalD1Target(root);
624
- const db = await openSqliteDatabase(dbPath);
625
- try {
626
- db.exec(sql);
627
- } finally {
628
- db.close();
629
- }
630
- } else await runSeedModule(root, seedFn, dialect);
1811
+ if (seedSql !== void 0) {
1812
+ await resetBeforeSeed(root, dialect);
1813
+ await runSqlSeed(root, dialect, seedSql);
1814
+ if (dialect === "sqlite") log.info(dim("Restart your dev server if it's running."));
1815
+ printSuccess(`Seeded from ${seed.displayPath}.`);
1816
+ return;
1817
+ }
1818
+ const { createSeedModuleLoader } = await import("./db-seed-loader-Bcz_SutQ.mjs");
1819
+ const loader = createSeedModuleLoader(root, seed.path);
1820
+ try {
1821
+ const run = await loadSeedFunction(seed.path, loader.importModule);
1822
+ await resetBeforeSeed(root, dialect);
1823
+ await runSeedModule(root, run, dialect, loader.importModule);
1824
+ } finally {
1825
+ loader.close();
1826
+ }
631
1827
  log.info(dim("Restart your dev server if it's running."));
632
1828
  printSuccess(`Seeded from ${seed.displayPath}.`);
633
1829
  }
1830
+ /** Drop and re-run migrations before a seed. The drop is already confirmed, so do not ask again. */
1831
+ async function resetBeforeSeed(root, dialect) {
1832
+ const migrationCount = await resetDatabase(root, dialect, true);
1833
+ log.step(`Reset database. Applied ${formatCount(migrationCount, "migration")}.`);
1834
+ }
1835
+ async function runSqlSeed(root, dialect, sql) {
1836
+ if (dialect === "postgresql") {
1837
+ await withPgClient(root, async (client) => {
1838
+ await client.query(sql);
1839
+ });
1840
+ return;
1841
+ }
1842
+ if (dialect === "mysql") {
1843
+ await withMySqlClient(root, async (client) => {
1844
+ await client.query(sql);
1845
+ });
1846
+ return;
1847
+ }
1848
+ const { openSqliteDatabase } = await import("./runner-Bf94YVJK.mjs");
1849
+ const { databasePath: dbPath } = getLocalD1Target(root);
1850
+ const db = await openSqliteDatabase(dbPath);
1851
+ try {
1852
+ db.exec(sql);
1853
+ } finally {
1854
+ db.close();
1855
+ }
1856
+ }
634
1857
  /**
635
1858
  * Fail-closed check for read-only SQL (SELECT or plain EXPLAIN), which skips the remote
636
1859
  * confirmation prompt. A semicolon anywhere but the end means a script, and it is read from the
@@ -641,7 +1864,7 @@ async function runSeed(root, file, dialect, yes) {
641
1864
  */
642
1865
  function isSafeStatement(sql) {
643
1866
  if (sql.replace(/;\s*$/, "").includes(";")) return false;
644
- const stripped = sql.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/--[^\n]*/g, " ").replace(/;\s*$/, "");
1867
+ const stripped = sql.replaceAll(/\/\*[\s\S]*?\*\//g, " ").replaceAll(/--[^\n]*/g, " ").replace(/;\s*$/, "");
645
1868
  if (/^\s*SELECT\b/i.test(stripped)) return true;
646
1869
  if (/^\s*EXPLAIN\b/i.test(stripped)) {
647
1870
  if (/^\s*EXPLAIN\s+ANALYZE\b/i.test(stripped)) return false;
@@ -671,73 +1894,148 @@ function prepareSingleStatement(db, sql) {
671
1894
  * Exits with a friendly message when the URL has never been stored (404);
672
1895
  * other errors propagate so the caller's top-level handler can report them.
673
1896
  */
674
- async function fetchRemoteDatabaseUrl(client, projectId) {
1897
+ async function fetchRemoteDatabaseUrl(client, projectId, messages = {}) {
675
1898
  try {
676
1899
  return (await client.getDatabaseUrl(projectId)).url;
677
1900
  } catch (err) {
678
1901
  if (err instanceof PlatformApiError && err.status === 404) {
679
- log.error("This project's database URL isn't stored on the platform yet. Run `void db set-url` once to populate it, then retry.");
1902
+ log.error("This project's database URL isn't stored on the platform yet. Run `void db set-url` once to populate it, then retry.", messages);
680
1903
  process.exit(1);
681
1904
  }
682
1905
  throw err;
683
1906
  }
684
1907
  }
685
- async function executeExternalRemoteSql(dialect, dbUrl, sql) {
1908
+ /**
1909
+ * Run SQL on a PostgreSQL or MySQL database. Both drivers return one result per statement, so
1910
+ * `--json` prints every statement with `printResults`; the table prints only a single
1911
+ * statement's rows.
1912
+ */
1913
+ async function executeExternalSql(dialect, dbUrl, sql, printResults) {
1914
+ const json = printResults !== void 0;
686
1915
  if (dialect === "postgresql") {
687
- const { Client } = await import("pg");
688
- const pgClient = new Client({ connectionString: dbUrl });
1916
+ const { Client, types } = await import("pg");
1917
+ const pgClient = new Client({
1918
+ connectionString: dbUrl,
1919
+ ...json ? { types: pgJsonTypes(types) } : {}
1920
+ });
689
1921
  await pgClient.connect();
690
1922
  try {
691
1923
  const result = await pgClient.query(sql);
692
- if (result.rows && result.rows.length > 0) printTable(result.rows);
1924
+ if (json) printResults(pgStatementResults(result));
1925
+ else if (!Array.isArray(result) && result.rows.length > 0) printTable(result.rows);
693
1926
  } finally {
694
1927
  await pgClient.end();
695
1928
  }
696
1929
  return;
697
1930
  }
698
1931
  const { createConnection } = await import("mysql2/promise");
1932
+ const uri = json ? mySqlJsonUri(dbUrl) : dbUrl;
1933
+ let statements;
1934
+ if (json) {
1935
+ let mode;
1936
+ if (needsMySqlServerMode(sql)) {
1937
+ const modeClient = await createConnection({ uri });
1938
+ try {
1939
+ mode = mySqlServerMode((await modeClient.query(MYSQL_SERVER_MODE_QUERY))[0]);
1940
+ } finally {
1941
+ await modeClient.end();
1942
+ }
1943
+ }
1944
+ statements = mySqlStatements(sql, mode);
1945
+ }
699
1946
  const mySqlClient = await createConnection({
700
- uri: dbUrl,
701
- multipleStatements: true
1947
+ uri,
1948
+ multipleStatements: true,
1949
+ ...json ? {
1950
+ supportBigNumbers: true,
1951
+ bigNumberStrings: false,
1952
+ dateStrings: true,
1953
+ typeCast: mySqlJsonTypeCast
1954
+ } : {}
702
1955
  });
703
1956
  try {
704
- const [rows] = await mySqlClient.query(sql);
705
- if (Array.isArray(rows) && rows.length > 0) printTable(rows);
1957
+ const [rows, fields] = await mySqlClient.query(statements?.sql ?? sql);
1958
+ if (json && statements) printResults(mySqlStatementResults(rows, fields, statements));
1959
+ else if (Array.isArray(rows) && rows.length > 0) printTable(rows);
706
1960
  } finally {
707
1961
  await mySqlClient.end();
708
1962
  }
709
1963
  }
1964
+ const MYSQL_JSON_URL_OPTIONS = [
1965
+ "debug",
1966
+ "bigNumberStrings",
1967
+ "dateStrings",
1968
+ "decimalNumbers",
1969
+ "jsonStrings",
1970
+ "nestTables",
1971
+ "rowsAsArray",
1972
+ "supportBigNumbers",
1973
+ "typeCast"
1974
+ ];
1975
+ /**
1976
+ * The URL without options that would change --json output. mysql2 reads options from the URL,
1977
+ * and an option passed as false does not override one the URL sets.
1978
+ */
1979
+ function mySqlJsonUri(dbUrl) {
1980
+ let url;
1981
+ try {
1982
+ url = new URL(dbUrl);
1983
+ } catch {
1984
+ return dbUrl;
1985
+ }
1986
+ const options = MYSQL_JSON_URL_OPTIONS.filter((option) => url.searchParams.has(option));
1987
+ if (options.length === 0) return dbUrl;
1988
+ for (const option of options) url.searchParams.delete(option);
1989
+ return url.toString();
1990
+ }
710
1991
  /**
711
1992
  * Prompt the user to confirm a destructive remote query when running in a TTY.
712
1993
  * `always` asks even for read-only SQL, and `yes` (`--yes`) never asks. Returns true if
713
1994
  * execution should proceed, false if it was cancelled.
714
1995
  */
715
- async function confirmDestructiveRemote(sql, { always = false, yes = false } = {}) {
1996
+ async function confirmDestructiveRemote(sql, { always = false, yes = false, output } = {}) {
716
1997
  if (yes || !always && isSafeStatement(sql)) return true;
717
1998
  if (!process.stdin.isTTY) return true;
718
- const ok = await confirm({ message: "This will run against your deployed database. Continue?" });
1999
+ const ok = await confirm({
2000
+ message: "This will run against your deployed database. Continue?",
2001
+ output
2002
+ });
719
2003
  if (isCancel(ok) || !ok) return false;
720
2004
  return true;
721
2005
  }
722
2006
  const D1_MAX_SQL_STATEMENT_BYTES = 1e5;
723
- async function runExecute(root, command, file, dialect, remote, yes) {
2007
+ /** Run `void db execute`. `printResults` prints the results with --json, and is undefined without. */
2008
+ async function runExecute(root, { command, file, remote, yes }, dialect, printResults) {
2009
+ const json = printResults !== void 0;
2010
+ const messages = json ? { output: process.stderr } : {};
2011
+ const finish = () => {
2012
+ if (!json) printSuccess("SQL executed successfully.");
2013
+ };
2014
+ const readSql = () => {
2015
+ if (file) return readFileSync(resolve(root, file), "utf8");
2016
+ if (command === void 0) throw new Error("db execute requires a SQL command or file.");
2017
+ return command;
2018
+ };
724
2019
  if (remote) {
725
2020
  const directCloudflare = readDeploymentPlatform(root) === "cloudflare";
726
- const sql = file ? readFileSync(resolve(root, file), "utf-8") : command;
2021
+ const sql = readSql();
727
2022
  if (directCloudflare) {
728
2023
  const bulkImport = dialect === "sqlite" && file !== void 0 && Buffer.byteLength(sql) > D1_MAX_SQL_STATEMENT_BYTES;
2024
+ if (bulkImport && json) throw new Error(`db: ${file} is larger than 100 KB, so Void would run it as a D1 import, which returns no results. Run it without --json.`);
729
2025
  if (bulkImport) log.warn(`${file} is larger than 100 KB, so Void runs it as a D1 import. The database cannot serve queries until the import finishes, and query rows are not printed.`);
730
2026
  if (!await confirmDestructiveRemote(sql, {
731
2027
  always: bulkImport,
732
- yes
2028
+ yes,
2029
+ ...messages
733
2030
  })) {
734
- log.info("Cancelled.");
2031
+ log.info("Cancelled.", messages);
735
2032
  process.exit(0);
736
2033
  }
737
2034
  if (dialect === "sqlite") {
738
- const { executeCloudflareD1Sql, importCloudflareD1Sql, resolveCloudflareD1Context } = await import("./cloudflare-operations-BditDbcd.mjs");
2035
+ const { executeCloudflareD1Sql, executeCloudflareD1Statements, importCloudflareD1Sql, resolveCloudflareD1Context } = await import("./cloudflare-operations-ByjFGats.mjs");
739
2036
  const context = resolveCloudflareD1Context(root, configuredD1Binding(root));
740
2037
  if (bulkImport) await importCloudflareD1Sql(context, sql);
2038
+ else if (json) printResults(await executeCloudflareD1Statements(context, sql));
741
2039
  else {
742
2040
  const rows = await executeCloudflareD1Sql(context, sql);
743
2041
  if (rows.length > 0) printTable(rows);
@@ -745,31 +2043,35 @@ async function runExecute(root, command, file, dialect, remote, yes) {
745
2043
  } else {
746
2044
  const dbUrl = process.env.DATABASE_URL;
747
2045
  if (!dbUrl) {
748
- log.error("DATABASE_URL is required in the shell for a direct Cloudflare remote database command.");
2046
+ log.error("DATABASE_URL is required in the shell for a direct Cloudflare remote database command.", messages);
749
2047
  process.exit(1);
750
2048
  }
751
- await executeExternalRemoteSql(dialect, dbUrl, sql);
2049
+ await executeExternalSql(dialect, dbUrl, sql, printResults);
752
2050
  }
753
- printSuccess("SQL executed successfully.");
2051
+ finish();
754
2052
  return;
755
2053
  }
756
2054
  const token = getToken(root);
757
2055
  if (!token) {
758
- log.error("Not logged in. Run `void account login` first.");
2056
+ log.error("Not logged in. Run `void account login` first.", messages);
759
2057
  process.exit(1);
760
2058
  }
761
2059
  const projectConfig = readProjectConfig(root);
762
2060
  if (!projectConfig) {
763
- log.error("No project linked. Run `void deploy` first or link a project.");
2061
+ log.error("No project linked. Run `void deploy` first or link a project.", messages);
764
2062
  process.exit(1);
765
2063
  }
766
- if (!await confirmDestructiveRemote(sql, { yes })) {
767
- log.info("Cancelled.");
2064
+ if (json && dialect === "sqlite" && splitSqliteStatements(sql).length > 1) throw new Error("db: `void db execute --remote --json` runs one statement at a time on a Void platform D1 database. Run each statement separately.");
2065
+ if (!await confirmDestructiveRemote(sql, {
2066
+ yes,
2067
+ ...messages
2068
+ })) {
2069
+ log.info("Cancelled.", messages);
768
2070
  process.exit(0);
769
2071
  }
770
2072
  if (dialect !== "sqlite") {
771
- await executeExternalRemoteSql(dialect, await fetchRemoteDatabaseUrl(new PlatformClient(token, { root }), projectConfig.projectId), sql);
772
- printSuccess("SQL executed successfully.");
2073
+ await executeExternalSql(dialect, await fetchRemoteDatabaseUrl(new PlatformClient(token, { root }), projectConfig.projectId, messages), sql, printResults);
2074
+ finish();
773
2075
  return;
774
2076
  }
775
2077
  const platformClient = new PlatformClient(token, { root });
@@ -814,50 +2116,47 @@ async function runExecute(root, command, file, dialect, remote, yes) {
814
2116
  }
815
2117
  if (!res.ok) {
816
2118
  const text = await res.text().catch(() => res.statusText);
817
- log.error(`db: Proxy request failed with ${res.status}: '${text}'.`);
2119
+ log.error(`db: Proxy request failed with ${res.status}: '${text}'.`, messages);
818
2120
  process.exit(1);
819
2121
  }
820
- const rows = (await res.json()).results ?? [];
821
- if (rows.length > 0) printTable(rows);
822
- printSuccess("SQL executed successfully.");
2122
+ const data = await res.json();
2123
+ const rows = data.results ?? [];
2124
+ if (json) printResults([{
2125
+ results: rows,
2126
+ success: data.success !== false,
2127
+ meta: data.meta ?? {}
2128
+ }]);
2129
+ else if (rows.length > 0) printTable(rows);
2130
+ finish();
823
2131
  return;
824
2132
  }
825
- if (dialect === "postgresql") {
826
- const sql = file ? readFileSync(resolve(root, file), "utf-8") : command;
827
- await withPgClient(root, async (client) => {
828
- const result = await client.query(sql);
829
- if (result.rows && result.rows.length > 0) printTable(result.rows);
830
- });
831
- printSuccess("SQL executed successfully.");
832
- return;
833
- }
834
- if (dialect === "mysql") {
835
- const sql = file ? readFileSync(resolve(root, file), "utf-8") : command;
836
- await withMySqlClient(root, async (client) => {
837
- const rows = await client.query(sql);
838
- if (rows.length > 0) printTable(rows);
839
- });
840
- printSuccess("SQL executed successfully.");
2133
+ if (dialect !== "sqlite") {
2134
+ const sql = readSql();
2135
+ await executeExternalSql(dialect, getLocalDatabaseUrl(root, dialect), sql, printResults);
2136
+ finish();
841
2137
  return;
842
2138
  }
843
- const { openSqliteDatabase } = await import("./runner-CTk21HrO.mjs");
2139
+ const { openSqliteDatabase } = await import("./runner-Bf94YVJK.mjs");
844
2140
  const { databasePath: dbPath } = getLocalD1Target(root);
845
2141
  if (!existsSync(dbPath)) {
846
- log.error("No local database found. Start the dev server first.");
2142
+ log.error("No local database found. Start the dev server first.", messages);
847
2143
  process.exit(1);
848
2144
  }
849
- const sql = file ? readFileSync(resolve(root, file), "utf-8") : command;
2145
+ const sql = readSql();
850
2146
  const db = await openSqliteDatabase(dbPath);
851
2147
  try {
852
- const statement = prepareSingleStatement(db, sql);
853
- if (statement?.reader) {
854
- const rows = statement.all();
855
- if (rows.length > 0) printTable(rows);
856
- } else db.exec(sql);
2148
+ if (json) printResults(runSqliteStatements(db, sql));
2149
+ else {
2150
+ const statement = prepareSingleStatement(db, sql);
2151
+ if (statement?.reader) {
2152
+ const rows = statement.all();
2153
+ if (rows.length > 0) printTable(rows);
2154
+ } else db.exec(sql);
2155
+ }
857
2156
  } finally {
858
2157
  db.close();
859
2158
  }
860
- printSuccess("SQL executed successfully.");
2159
+ finish();
861
2160
  }
862
2161
  function printTable(rows) {
863
2162
  const cols = Object.keys(rows[0]);
@@ -903,11 +2202,11 @@ async function runMigrate(root, dialect, remote) {
903
2202
  let appliedNames;
904
2203
  let applyMigrations;
905
2204
  if (dialect === "postgresql") {
906
- const { getPgAppliedMigrations, runPgMigrations } = await import("./runner-pg-2pjltt0t.mjs");
2205
+ const { getPgAppliedMigrations, runPgMigrations } = await import("./runner-pg-DMJquR3d.mjs");
907
2206
  appliedNames = await getPgAppliedMigrations(databaseUrl);
908
2207
  applyMigrations = () => runPgMigrations(migrationsDir, databaseUrl);
909
2208
  } else {
910
- const { getMySqlAppliedMigrations, runMySqlMigrations } = await import("./runner-mysql-C_PrAUTm.mjs");
2209
+ const { getMySqlAppliedMigrations, runMySqlMigrations } = await import("./runner-mysql-DOjbj-N1.mjs");
911
2210
  appliedNames = await getMySqlAppliedMigrations(databaseUrl);
912
2211
  applyMigrations = () => runMySqlMigrations(migrationsDir, databaseUrl);
913
2212
  }
@@ -932,7 +2231,7 @@ async function runMigrate(root, dialect, remote) {
932
2231
  log.info(`No migration files found in ${paths.sourceRelative("db/migrations")}/`);
933
2232
  return;
934
2233
  }
935
- const { applyCloudflareD1Migrations, readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-BditDbcd.mjs");
2234
+ const { applyCloudflareD1Migrations, readCloudflareD1Migrations, resolveCloudflareD1Context } = await import("./cloudflare-operations-ByjFGats.mjs");
936
2235
  const binding = configuredD1Binding(root);
937
2236
  const context = resolveCloudflareD1Context(root, binding);
938
2237
  const remoteBefore = new Set(await readCloudflareD1Migrations(context));
@@ -952,7 +2251,7 @@ async function runMigrate(root, dialect, remote) {
952
2251
  log.error(`db: D1 binding ${binding} has no "migrations_dir", so Cloudflare would apply ./migrations instead of ${dir}/. Add "migrations_dir": "./${dir}" to that D1 binding in your Cloudflare config, then run the command again.`);
953
2252
  process.exit(1);
954
2253
  }
955
- const { checkWranglerMigrationApplySet, parseRootWranglerConfig } = await import("./deploy-DiFfBu8g.mjs");
2254
+ const { checkWranglerMigrationApplySet, parseRootWranglerConfig } = await import("./deploy-Do6FWqon.mjs");
956
2255
  const applySet = await checkWranglerMigrationApplySet(context.operation.configPath, parseRootWranglerConfig(context.operation.configPath), binding, context.migrationsDir, rawMigrations, paths.sourceRelative("db/migrations"));
957
2256
  if (!applySet.ok) {
958
2257
  log.error(applySet.reason);
@@ -1014,7 +2313,7 @@ async function runMigrate(root, dialect, remote) {
1014
2313
  return;
1015
2314
  }
1016
2315
  if (dialect === "postgresql") {
1017
- const { applyPgMigrations, readPgAppliedMigrations } = await import("./runner-pg-2pjltt0t.mjs");
2316
+ const { applyPgMigrations, readPgAppliedMigrations } = await import("./runner-pg-DMJquR3d.mjs");
1018
2317
  const applied = await withPgClient(root, async (client) => {
1019
2318
  const appliedNames = await readPgAppliedMigrations(client).catch(() => []);
1020
2319
  try {
@@ -1033,7 +2332,7 @@ async function runMigrate(root, dialect, remote) {
1033
2332
  return;
1034
2333
  }
1035
2334
  if (dialect === "mysql") {
1036
- const { applyMySqlMigrations, readMySqlAppliedMigrations } = await import("./runner-mysql-C_PrAUTm.mjs");
2335
+ const { applyMySqlMigrations, readMySqlAppliedMigrations } = await import("./runner-mysql-DOjbj-N1.mjs");
1037
2336
  const applied = await withMySqlClient(root, async (client) => {
1038
2337
  const appliedNames = await readMySqlAppliedMigrations(client).catch(() => []);
1039
2338
  try {
@@ -1051,7 +2350,7 @@ async function runMigrate(root, dialect, remote) {
1051
2350
  }
1052
2351
  return;
1053
2352
  }
1054
- const { getAppliedMigrations, runMigrations } = await import("./runner-CTk21HrO.mjs");
2353
+ const { getAppliedMigrations, runMigrations } = await import("./runner-Bf94YVJK.mjs");
1055
2354
  const { databasePath: dbPath } = getLocalD1Target(root);
1056
2355
  try {
1057
2356
  const existingRows = await getAppliedMigrations(dbPath);
@@ -1079,7 +2378,7 @@ async function runRestore(root, dialect, { target, platform: explicitPlatform, y
1079
2378
  log.error("db: `void db restore` restores the D1 database of a direct Cloudflare deploy. After a one-off `void deploy --platform cloudflare`, run it with `--platform cloudflare`.");
1080
2379
  process.exit(1);
1081
2380
  }
1082
- const { readCloudflareD1Migrations, resolveCloudflareD1Context, restoreCloudflareD1Database } = await import("./cloudflare-operations-BditDbcd.mjs");
2381
+ const { readCloudflareD1Migrations, resolveCloudflareD1Context, restoreCloudflareD1Database } = await import("./cloudflare-operations-ByjFGats.mjs");
1083
2382
  const binding = configuredD1Binding(root);
1084
2383
  const context = resolveCloudflareD1Context(root, binding);
1085
2384
  const database = `D1 database ${context.migrateToken} (${binding})`;
@@ -1153,7 +2452,7 @@ async function runStudio(root, dialect, remote) {
1153
2452
  await runDrizzleKitWithDatabaseUrl(root, url, dialect, "studio");
1154
2453
  return;
1155
2454
  }
1156
- const { writeDrizzleConfig } = await import("./config-dMSpL-ml.mjs");
2455
+ const { writeDrizzleConfig } = await import("./config-DtjrUtPo.mjs");
1157
2456
  const { databasePath: dbPath } = getLocalD1Target(root);
1158
2457
  if (!existsSync(dbPath)) {
1159
2458
  log.error("No local database found. Start the dev server first.");
@@ -1173,8 +2472,8 @@ async function runStudio(root, dialect, remote) {
1173
2472
  }
1174
2473
  /** A direct Cloudflare deploy records its D1 or Hyperdrive id in the checked-in Cloudflare config. */
1175
2474
  async function hasDeployedCloudflareDatabase(root) {
1176
- const { readRootWranglerConfig } = await import("./wrangler-BPIAJdxA.mjs");
1177
- const { isRealD1Id, isRealHyperdriveId } = await import("./provision-CGI-T0mq.mjs");
2475
+ const { readRootWranglerConfig } = await import("./wrangler-Dq269bjx.mjs");
2476
+ const { isRealD1Id, isRealHyperdriveId } = await import("./provision-DFv7SJDn.mjs");
1178
2477
  const config = readRootWranglerConfig(root)?.config;
1179
2478
  const entries = (key) => {
1180
2479
  const value = config?.[key];
@@ -1182,6 +2481,7 @@ async function hasDeployedCloudflareDatabase(root) {
1182
2481
  };
1183
2482
  return entries("d1_databases").some((entry) => isRealD1Id(entry.database_id)) || entries("hyperdrive").some((entry) => isRealHyperdriveId(entry.id));
1184
2483
  }
2484
+ const snapshotPrefix = (tag) => tag.split("_")[0];
1185
2485
  async function runRenameMigrations(root, dialect) {
1186
2486
  const paths = readProjectPaths(root);
1187
2487
  const migrationsDir = paths.migrationsDir;
@@ -1247,7 +2547,6 @@ Delete ${dir}/migrations.js and re-run \`void db generate\` to migrate away\nfro
1247
2547
  const journalPath = join(metaDir, "_journal.json");
1248
2548
  const originalJournalBytes = existsSync(journalPath) ? readFileSync(journalPath) : null;
1249
2549
  const journal = readJournal(migrationsDir, paths.sourceRelative);
1250
- const snapshotPrefix = (tag) => tag.split("_")[0];
1251
2550
  const snapshotPathFor = (tag) => join(metaDir, `${snapshotPrefix(tag)}_snapshot.json`);
1252
2551
  if (journal && journal.entries.length > 0) {
1253
2552
  const missingSnapshots = [];
@@ -1385,7 +2684,7 @@ Regenerate it with \`void db generate\`, or restore it from version control.`);
1385
2684
  await rollback("db: Failed to update MySQL tracking table. File renames have been reverted.\nFix the database connection and run `void db rename-migrations` again.", err);
1386
2685
  }
1387
2686
  else {
1388
- const { openSqliteDatabase } = await import("./runner-CTk21HrO.mjs");
2687
+ const { openSqliteDatabase } = await import("./runner-Bf94YVJK.mjs");
1389
2688
  const { databasePath: dbPath } = getLocalD1Target(root);
1390
2689
  if (existsSync(dbPath)) try {
1391
2690
  const db = await openSqliteDatabase(dbPath);
@@ -1424,7 +2723,7 @@ function formatMySqlExportValue(value) {
1424
2723
  if (typeof value === "number" || typeof value === "bigint") return String(value);
1425
2724
  if (typeof value === "boolean") return value ? "1" : "0";
1426
2725
  if (value instanceof Uint8Array) return `X'${Array.from(value, (byte) => byte.toString(16).padStart(2, "0")).join("")}'`;
1427
- return `'${String(value).replaceAll("\\", "\\\\").replaceAll("'", "''")}'`;
2726
+ return `'${String(value).replaceAll("\\", String.raw`\\`).replaceAll("'", "''")}'`;
1428
2727
  }
1429
2728
  function formatSqliteExportValue(value) {
1430
2729
  if (value === null) return "NULL";
@@ -1484,7 +2783,7 @@ async function runExport(root, args, dialect) {
1484
2783
  const value = row[column];
1485
2784
  if (value === null) return "NULL";
1486
2785
  if (typeof value === "number") return String(value);
1487
- return `'${String(value).replace(/'/g, "''")}'`;
2786
+ return `'${String(value).replaceAll("'", "''")}'`;
1488
2787
  });
1489
2788
  parts.push(`INSERT INTO ${tableName} (${cols.map(quoteSqlIdentifier).join(", ")})${overriding} VALUES (${vals.join(", ")});`);
1490
2789
  }
@@ -1541,7 +2840,7 @@ async function runExport(root, args, dialect) {
1541
2840
  } else process.stdout.write(output);
1542
2841
  return;
1543
2842
  }
1544
- const { openSqliteDatabase } = await import("./runner-CTk21HrO.mjs");
2843
+ const { openSqliteDatabase } = await import("./runner-Bf94YVJK.mjs");
1545
2844
  const { databasePath: dbPath } = getLocalD1Target(root);
1546
2845
  if (!existsSync(dbPath)) {
1547
2846
  log.error("No local database found. Start the dev server first.", errOut);
@@ -1578,8 +2877,7 @@ async function runExport(root, args, dialect) {
1578
2877
  const sequences = db.prepare("SELECT name, seq FROM sqlite_sequence").all();
1579
2878
  for (const sequence of sequences) if (tables.includes(sequence.name)) {
1580
2879
  const name = quoteSqlString(sequence.name);
1581
- parts.push(`DELETE FROM sqlite_sequence WHERE name = ${name};`);
1582
- parts.push(`INSERT INTO sqlite_sequence (name, seq) VALUES (${name}, ${sequence.seq});`);
2880
+ parts.push(`DELETE FROM sqlite_sequence WHERE name = ${name};`, `INSERT INTO sqlite_sequence (name, seq) VALUES (${name}, ${sequence.seq});`);
1583
2881
  }
1584
2882
  }
1585
2883
  if (!args.noSchema) {
@@ -1636,7 +2934,10 @@ async function runSetUrl(root, dialect) {
1636
2934
  function resolveSeedTarget(root, file) {
1637
2935
  if (file) return toSeedTarget(root, resolve(root, file), file);
1638
2936
  const paths = readProjectPaths(root);
1639
- const defaults = DEFAULT_SEED_FILES.map((candidate) => paths.sourceRelative(candidate)).filter((candidate) => existsSync(join(root, candidate)));
2937
+ const defaults = DEFAULT_SEED_FILES.flatMap((candidate) => {
2938
+ const mappedCandidate = paths.sourceRelative(candidate);
2939
+ return existsSync(join(root, mappedCandidate)) ? [mappedCandidate] : [];
2940
+ });
1640
2941
  if (defaults.length === 0) {
1641
2942
  log.error(`db: No seed file found. Create one of: ${DEFAULT_SEED_FILES.map((candidate) => paths.sourceRelative(candidate)).join(", ")} or pass --file <path>.`);
1642
2943
  process.exit(1);
@@ -1668,8 +2969,8 @@ function toSeedTarget(root, seedPath, displayPath) {
1668
2969
  log.error(`db: Unsupported seed file '${normalizedDisplay}'. Use .sql, .ts, .mts, .js, or .mjs.`);
1669
2970
  process.exit(1);
1670
2971
  }
1671
- async function runSeedModule(root, seed, dialect) {
1672
- const schema = await loadSeedSchema(root);
2972
+ async function runSeedModule(root, seed, dialect, importModule) {
2973
+ const schema = await loadSeedSchema(root, importModule);
1673
2974
  const casing = getDatabaseCasing(readConfig(root));
1674
2975
  if (dialect === "postgresql") {
1675
2976
  const { drizzle } = await import("drizzle-orm/node-postgres");
@@ -1704,7 +3005,7 @@ async function runSeedModule(root, seed, dialect) {
1704
3005
  return;
1705
3006
  }
1706
3007
  const { drizzle } = await import("drizzle-orm/better-sqlite3");
1707
- const { openSqliteDatabase } = await import("./runner-CTk21HrO.mjs");
3008
+ const { openSqliteDatabase } = await import("./runner-Bf94YVJK.mjs");
1708
3009
  const { databasePath: dbPath } = getLocalD1Target(root);
1709
3010
  const sqlite = await openSqliteDatabase(dbPath);
1710
3011
  try {
@@ -1718,23 +3019,25 @@ async function runSeedModule(root, seed, dialect) {
1718
3019
  sqlite.close();
1719
3020
  }
1720
3021
  }
1721
- async function loadSeedFunction(seedPath) {
1722
- const mod = await importLocalModule(seedPath);
3022
+ async function loadSeedFunction(seedPath, importModule) {
3023
+ const mod = await importModule(seedPath);
1723
3024
  const seed = typeof mod.default === "function" ? mod.default : typeof mod.seed === "function" ? mod.seed : void 0;
1724
3025
  if (!seed) throw new Error(`db: Seed module '${seedPath}' must export a default function or a named "seed" function.`);
1725
3026
  return seed;
1726
3027
  }
1727
- async function loadSeedSchema(root) {
1728
- const { discoverSchema } = await import("./discover-Diq0l6TZ.mjs");
3028
+ async function loadSeedSchema(root, importModule) {
3029
+ const { discoverSchema } = await import("./discover-D2KGP3cR.mjs");
1729
3030
  const location = discoverSchema(root, readProjectPaths(root));
1730
3031
  if (!location) return {};
1731
3032
  if (location.type === "file") {
1732
- const mod = await importLocalModule(location.path);
3033
+ const mod = await importModule(location.path);
1733
3034
  return Object.fromEntries(Object.entries(mod).filter(([name]) => name !== "default" && name !== "__esModule"));
1734
3035
  }
1735
3036
  const files = collectSchemaModuleFiles(location.path);
1736
- const parts = await Promise.all(files.map((file) => importLocalModule(file)));
1737
- return Object.assign({}, ...parts.map((mod) => Object.fromEntries(Object.entries(mod).filter(([name]) => name !== "default"))));
3037
+ const parts = await Promise.all(files.map((file) => importModule(file)));
3038
+ const schema = {};
3039
+ Object.assign(schema, ...parts.map((mod) => Object.fromEntries(Object.entries(mod).filter(([name]) => name !== "default"))));
3040
+ return schema;
1738
3041
  }
1739
3042
  function collectSchemaModuleFiles(dir) {
1740
3043
  const files = [];
@@ -1748,13 +3051,6 @@ function collectSchemaModuleFiles(dir) {
1748
3051
  }
1749
3052
  return files.sort();
1750
3053
  }
1751
- async function importLocalModule(modulePath) {
1752
- return createJiti(import.meta.url, {
1753
- fsCache: false,
1754
- moduleCache: false,
1755
- interopDefault: false
1756
- }).import(modulePath);
1757
- }
1758
3054
  /** The schema and casing that `void/db` gives drizzle, or undefined when neither is set. */
1759
3055
  function getDrizzleSchemaOptions(schema, casing) {
1760
3056
  const options = {