void 0.21.9 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/README.md +5 -1
  2. package/dist/{account-cmd-DZZGK80W.mjs → account-cmd-C84Ee8cO.mjs} +5 -5
  3. package/dist/{scan-ClYmX3sa.mjs → application-analysis-BVsVqc11.mjs} +135 -18
  4. package/dist/application-routing-B7QEjqSR.mjs +27 -0
  5. package/dist/{auth-CZuiVsFh.mjs → auth-CCjt0hcq.mjs} +1 -1
  6. package/dist/{auth-DLNN0D3Z.mjs → auth-CSkdO2Bb.mjs} +4 -47
  7. package/dist/{auth-link-B_CeugBw.mjs → auth-link-CioEg6uY.mjs} +5 -5
  8. package/dist/{auth-router-BgEFRuvZ.mjs → auth-router-BsR981d4.mjs} +5 -5
  9. package/dist/{better-auth-shared-rsBGBvWJ.mjs → better-auth-shared-hy6RPh9W.mjs} +13 -2
  10. package/dist/{build-cmd-Dpt0jd-x.mjs → build-cmd-LzvNJORH.mjs} +19 -7
  11. package/dist/{cache-7_UeZdTk.mjs → cache-C4MvnrMH.mjs} +4 -4
  12. package/dist/{cancel-deploy-D23R1RXT.mjs → cancel-deploy-abUxpP2n.mjs} +4 -4
  13. package/dist/{cf-build-output-CGT03qCD.mjs → cf-build-output-BPqOT964.mjs} +141 -63
  14. package/dist/cf-build-output-_0HNWysu.mjs +2 -0
  15. package/dist/cli/cli.mjs +114 -460
  16. package/dist/cli/cloudflare-operation-process.mjs +1103 -0
  17. package/dist/cli/env-schema-probe.d.mts +2 -1
  18. package/dist/cli/env-schema-probe.mjs +3 -3
  19. package/dist/client-Cu7jWiF1.mjs +2 -0
  20. package/dist/{client-QTl6ko_D.mjs → client-RV8NVeB8.mjs} +165 -21
  21. package/dist/{cloudflare-auth-C4_GPZr0.mjs → cloudflare-auth-Qdc7tw8F.mjs} +41 -43
  22. package/dist/{cloudflare-cmd-bSmZ1d5L.mjs → cloudflare-cmd-BcrVyTmJ.mjs} +9 -10
  23. package/dist/cloudflare-config-Bktvwtpf.mjs +182 -0
  24. package/dist/{cloudflare-connect-jAwacxxP.mjs → cloudflare-connect-B8uPZ4nx.mjs} +4 -4
  25. package/dist/{cloudflare-operations-BipGMJ5O.mjs → cloudflare-operations-AiWashgg.mjs} +1 -1
  26. package/dist/{cloudflare-operations-sMZXpk_S.mjs → cloudflare-operations-fxHb-byx.mjs} +118 -203
  27. package/dist/{preset-UHj9ARyP.mjs → cloudflare-process-B-wekeR6.mjs} +93 -6
  28. package/dist/{config-CF69HgXc.d.mts → config-BMHb8RCj.d.mts} +2 -2
  29. package/dist/{config-CafTW6Cz.mjs → config-Br_JZD6u.mjs} +2 -7
  30. package/dist/config-C_XRIPx2.mjs +89 -0
  31. package/dist/{config-s7Xj7tPb.mjs → config-CyQ-wVd7.mjs} +1 -1
  32. package/dist/config-entry.d.mts +1 -1
  33. package/dist/{config-write-BSduPMY8.mjs → config-write-B1f88wJA.mjs} +1 -1
  34. package/dist/{connect-BsUSRzln.mjs → connect-Bd4kJd9U.mjs} +6 -6
  35. package/dist/{create-project-BniEV0OW.mjs → create-project-Boczwj5r.mjs} +1 -1
  36. package/dist/{create-project-DBfFSZKY.mjs → create-project-bMf6ffLZ.mjs} +9 -5
  37. package/dist/{db-hRrvZaq_.mjs → db-8uG64XLl.mjs} +26 -26
  38. package/dist/{delete-D6dZ9B6B.mjs → delete-NvbiyeJf.mjs} +4 -4
  39. package/dist/{deploy-WaAQez1O.mjs → deploy-DzAIwqNU.mjs} +944 -607
  40. package/dist/{deploy-DDz7c8LK.mjs → deploy-bjXdFCtn.mjs} +1 -1
  41. package/dist/{dist-BR1quN_w.mjs → dist-AoCzRTJE.mjs} +226 -60
  42. package/dist/{dist-C5fND3R0.mjs → dist-BuDuKZJv.mjs} +1 -1
  43. package/dist/{dist-Dn6nn2IU.mjs → dist-CTBk70IR.mjs} +42 -42
  44. package/dist/{domain-Dmhvb2oU.mjs → domain-y5Tvydvo.mjs} +5 -5
  45. package/dist/{email-DFi-s2t4.mjs → email-B3umsW75.mjs} +15 -30
  46. package/dist/{env-Csi-tMbT.mjs → env-BS6qYHDb.mjs} +6 -6
  47. package/dist/{env-public-D_6u46fX.d.mts → env-public-BX_r8HR6.d.mts} +2 -1
  48. package/dist/{env-validation-BB4GkLxn.mjs → env-validation-BPn7vk-V.mjs} +18 -71
  49. package/dist/{env-validation-BXge7uyK.mjs → env-validation-DbTg7-ar.mjs} +1 -1
  50. package/dist/{fetch-CXDChK7B.mjs → fetch-BIZJh7vR.mjs} +2 -2
  51. package/dist/{fetch-stream-AOByI7Ki.mjs → fetch-stream-IvCYKyQL.mjs} +24 -4
  52. package/dist/{gen-Dz3X1Qab.mjs → gen-B580--vC.mjs} +5 -5
  53. package/dist/gen-BVaUUumi.mjs +2 -0
  54. package/dist/{github-cmd-BED3_9JD.mjs → github-cmd-v45BdfKX.mjs} +6 -8
  55. package/dist/{handler-BXJTXd02.d.mts → handler-CZ4nAylQ.d.mts} +2 -1
  56. package/dist/{headers-BOg_velo.mjs → headers-DWi2IXWx.mjs} +1 -1
  57. package/dist/help-DofyZuY7.mjs +2 -0
  58. package/dist/{help-DC7gdz7L.mjs → help-daGKjXGk.mjs} +268 -666
  59. package/dist/index.d.mts +1 -1
  60. package/dist/index.mjs +305 -1490
  61. package/dist/info-B97bTX9N.mjs +113 -0
  62. package/dist/{init-WO0JlPx8.mjs → init-Bvy7zrBo.mjs} +51 -20
  63. package/dist/limits-Bq5LG8Id.d.mts +27 -0
  64. package/dist/limits-Cjuk2VPm.mjs +68 -0
  65. package/dist/{link-CsHOinF7.mjs → link-CDqqCjFl.mjs} +5 -5
  66. package/dist/{list-CDb-4bZ1.mjs → list-CZj0dzKY.mjs} +5 -5
  67. package/dist/{live-CKiJilLr.d.mts → live-Chw1eIMv.d.mts} +1 -1
  68. package/dist/{local-d1-CC8sKFGu.mjs → local-d1-2CMnpuW_.mjs} +2 -2
  69. package/dist/login-DYt_An22.mjs +2 -0
  70. package/dist/{login-DvqXsfGs.mjs → login-UZKFM_u7.mjs} +5 -5
  71. package/dist/{logs-BdfiOezj.mjs → logs-CUZ6t9t3.mjs} +5 -5
  72. package/dist/migrate-8_2u55MD.mjs +2 -0
  73. package/dist/{migrate-B8KuoYsO.mjs → migrate-DHul7PRV.mjs} +5 -4
  74. package/dist/{node-BM43oz4G.mjs → node-BkyRWRx8.mjs} +2 -2
  75. package/dist/operator-args-CLgKGlwU.mjs +690 -0
  76. package/dist/{operator-cmd-03819ATr.mjs → operator-cmd-DBA6dl0m.mjs} +69 -23
  77. package/dist/output-Dm_A4Tbv.mjs +81 -0
  78. package/dist/pages/client.d.mts +34 -2
  79. package/dist/pages/client.mjs +59 -3
  80. package/dist/pages/index.d.mts +1 -1
  81. package/dist/pages/index.mjs +3 -3
  82. package/dist/pages/islands-plugin.d.mts +16 -6
  83. package/dist/pages/islands-plugin.mjs +2 -2
  84. package/dist/pages/protocol.d.mts +2 -2
  85. package/dist/pages/protocol.mjs +2 -308
  86. package/dist/{parse-filename-DioPHiR9.mjs → parse-filename-CUbj-1MP.mjs} +35 -1
  87. package/dist/{output-CCH48AMM.mjs → picocolors-BTps1_gs.mjs} +2 -76
  88. package/dist/plan-D1Q5rf-r.mjs +2 -0
  89. package/dist/plan-NPpwZ_kc.mjs +58 -0
  90. package/dist/platform-args-BJdRtlLq.mjs +506 -0
  91. package/dist/platform-args-D3RXyR6h.mjs +2 -0
  92. package/dist/{platform-auth-config-z92h63q5.mjs → platform-auth-config-B56E9YP1.mjs} +4 -4
  93. package/dist/{platform-auth-protection-DeE3yr2R.mjs → platform-auth-protection-BDWO_aER.mjs} +3 -3
  94. package/dist/{platform-auth-recovery-o_340Ixx.mjs → platform-auth-recovery-1gg4CSRe.mjs} +4 -4
  95. package/dist/{platform-cmd-C4ZV3Vpy.mjs → platform-cmd-Bt-1w6pY.mjs} +1 -1
  96. package/dist/{platform-cmd-DNl8WosH.mjs → platform-cmd-DMcQStSc.mjs} +26 -5
  97. package/dist/{platform-domain-CU1JtJkW.mjs → platform-domain-BNkcz0OB.mjs} +36 -9
  98. package/dist/{platform-lifecycle-Bc047IeT.mjs → platform-lifecycle-9OyBALhH.mjs} +850 -276
  99. package/dist/{platform-lifecycle-Bs2qx1E3.mjs → platform-lifecycle-BE6C_jxh.mjs} +1 -1
  100. package/dist/{platform-management-CVpGI9Y5.mjs → platform-management-CjwLVQwN.mjs} +59 -11
  101. package/dist/{platform-management-C8tt6D8h.mjs → platform-management-CnyTdcWX.mjs} +1 -1
  102. package/dist/platform-plans-config-BNGKGr4P.mjs +359 -0
  103. package/dist/{platform-recovery-dvUaptLr.mjs → platform-recovery-D6KSpuFm.mjs} +2 -2
  104. package/dist/{plugin-inference-BMfKRSqE.mjs → plugin-inference-CXWnn79A.mjs} +174 -64
  105. package/dist/{prepare-DyZ-Yok5.mjs → prepare-B5Mkic5u.mjs} +3 -3
  106. package/dist/{prepare-C3kt3Rst.mjs → prepare-DOsL0CC9.mjs} +4 -20
  107. package/dist/prepare-cgvDMtSb.mjs +2 -0
  108. package/dist/{project-cmd-B44I8J_W.mjs → project-cmd-CNzrqvBv.mjs} +30 -16
  109. package/dist/{project-team-BkbYIsXN.mjs → project-team-DQOWPfQT.mjs} +4 -4
  110. package/dist/{project-token-C8xEEQnB.mjs → project-token-CTDYU0Cc.mjs} +4 -4
  111. package/dist/project-zero-trust-BNAkW-_0.mjs +63 -0
  112. package/dist/{protocol-ZH3jP4a7.d.mts → protocol-CjF_iI9X.d.mts} +2 -2
  113. package/dist/protocol-U7bfjHmA.mjs +331 -0
  114. package/dist/{provision-DNtrtaVD.mjs → provision-C4ORE7G7.mjs} +1 -1
  115. package/dist/{provision-BhreDAOS.mjs → provision-CJFgTZY8.mjs} +111 -215
  116. package/dist/{requests-DFyhBMaf.mjs → requests-MhxYnau8.mjs} +4 -4
  117. package/dist/resource-name-C7LVpcRm.mjs +11 -0
  118. package/dist/{rollback-DHHxXZiS.mjs → rollback-CJ6iSDoU.mjs} +5 -5
  119. package/dist/route-url-CG7U-cRN.mjs +15 -0
  120. package/dist/{runner-B8wXwWlo.mjs → runner-CXA9Fh8h.mjs} +1 -1
  121. package/dist/{runner-p-dMs2UN.mjs → runner-Ol0TNjk6.mjs} +2 -2
  122. package/dist/runtime/ai.d.mts +12 -8
  123. package/dist/runtime/ai.mjs +84 -17
  124. package/dist/runtime/better-auth-mysql.mjs +1 -1
  125. package/dist/runtime/better-auth-pg.mjs +1 -1
  126. package/dist/runtime/better-auth.mjs +1 -1
  127. package/dist/runtime/client-react.mjs +2 -2
  128. package/dist/runtime/client-solid.mjs +2 -2
  129. package/dist/runtime/client-svelte.mjs +2 -2
  130. package/dist/runtime/client-vue.mjs +2 -2
  131. package/dist/runtime/client.mjs +2 -2
  132. package/dist/runtime/durable.d.mts +3 -1
  133. package/dist/runtime/durable.mjs +4 -1
  134. package/dist/runtime/email/testing.mjs +1 -1
  135. package/dist/runtime/env-public.d.mts +1 -1
  136. package/dist/runtime/fetch-stream.mjs +1 -1
  137. package/dist/runtime/fetch.mjs +1 -1
  138. package/dist/runtime/handler.d.mts +1 -1
  139. package/dist/runtime/kv.mjs +0 -1
  140. package/dist/runtime/limits.d.mts +2 -0
  141. package/dist/runtime/limits.mjs +2 -0
  142. package/dist/runtime/live-client.d.mts +1 -1
  143. package/dist/runtime/live-server.mjs +25 -16
  144. package/dist/runtime/live.d.mts +1 -1
  145. package/dist/runtime/migration-handler.mjs +62 -42
  146. package/dist/runtime/route-url.d.mts +4 -0
  147. package/dist/runtime/route-url.mjs +2 -0
  148. package/dist/runtime/routing.d.mts +180 -0
  149. package/dist/runtime/routing.mjs +1082 -0
  150. package/dist/runtime/sandbox-container.d.mts +3 -0
  151. package/dist/runtime/sandbox-container.mjs +2 -0
  152. package/dist/runtime/sandbox.d.mts +4 -32
  153. package/dist/runtime/sandbox.mjs +151 -75
  154. package/dist/runtime/sse.mjs +1 -1
  155. package/dist/runtime/validator.d.mts +1 -1
  156. package/dist/runtime/ws-server.d.mts +4 -2
  157. package/dist/runtime/ws-server.mjs +27 -2
  158. package/dist/runtime/ws.d.mts +2 -2
  159. package/dist/runtime/ws.mjs +8 -6
  160. package/dist/sandbox-XZAqzFlG.d.mts +52 -0
  161. package/dist/sandbox-container-Bo0eiFKz.d.mts +73 -0
  162. package/dist/sandbox-container-C6ItmVuN.mjs +281 -0
  163. package/dist/{scan-4tfN-PSn.mjs → scan-C7okrLyM.mjs} +4 -35
  164. package/dist/{secret-DN9sSNiV.mjs → secret-Dli5fP0B.mjs} +6 -6
  165. package/dist/{skills-O6FUaizK.mjs → skills-D1II1Juz.mjs} +1 -1
  166. package/dist/{sse-BaC1jXko.mjs → sse-CQNaDFFV.mjs} +6 -3
  167. package/dist/{subcommand-prompt-BuGYkAkC.mjs → subcommand-prompt-CY1C4fvl.mjs} +2 -2
  168. package/dist/validate-Dq_L3s0S.mjs +2 -0
  169. package/dist/{validate-CIUwFpjB.mjs → validate-ctOrgiS3.mjs} +2 -1
  170. package/dist/{wrangler-BymcxrRa.mjs → wrangler-7K-bW_DL.mjs} +14 -235
  171. package/dist/{ws-BwcqizuH.d.mts → ws-CL1w7GXU.d.mts} +13 -2
  172. package/package.json +48 -33
  173. package/sandbox.Dockerfile +4 -0
  174. package/schema.json +10 -22
  175. package/skills/migrate-vite-cloudflare-to-void/SKILL.md +34 -157
  176. package/skills/void/SKILL.md +50 -133
  177. package/skills/void/docs/guide/ai.md +94 -84
  178. package/skills/void/docs/guide/app-types.md +3 -32
  179. package/skills/void/docs/guide/auth.md +12 -116
  180. package/skills/void/docs/guide/database/d1.md +9 -54
  181. package/skills/void/docs/guide/database/mysql.md +1 -1
  182. package/skills/void/docs/guide/database/postgresql.md +5 -26
  183. package/skills/void/docs/guide/database.md +23 -75
  184. package/skills/void/docs/guide/deployment.md +27 -113
  185. package/skills/void/docs/guide/durable-state.md +43 -18
  186. package/skills/void/docs/guide/edge/headers.md +3 -47
  187. package/skills/void/docs/guide/edge/prerendering.md +5 -20
  188. package/skills/void/docs/guide/edge/redirects.md +11 -64
  189. package/skills/void/docs/guide/edge/revalidation.md +6 -19
  190. package/skills/void/docs/guide/edge/rewrites.md +56 -284
  191. package/skills/void/docs/guide/edge/static-assets.md +23 -72
  192. package/skills/void/docs/guide/email/domains.md +112 -0
  193. package/skills/void/docs/guide/email/receiving.md +139 -0
  194. package/skills/void/docs/guide/email/sending.md +231 -0
  195. package/skills/void/docs/guide/email.md +13 -619
  196. package/skills/void/docs/guide/env-migration.md +11 -11
  197. package/skills/void/docs/guide/env-vars.md +9 -29
  198. package/skills/void/docs/guide/index.md +0 -15
  199. package/skills/void/docs/guide/jobs.md +3 -18
  200. package/skills/void/docs/guide/kv.md +5 -11
  201. package/skills/void/docs/guide/live.md +5 -56
  202. package/skills/void/docs/guide/pages-routing/actions-and-forms.md +78 -125
  203. package/skills/void/docs/guide/pages-routing/head.md +10 -10
  204. package/skills/void/docs/guide/pages-routing/islands.md +6 -36
  205. package/skills/void/docs/guide/pages-routing/layouts.md +6 -128
  206. package/skills/void/docs/guide/pages-routing/loaders.md +3 -19
  207. package/skills/void/docs/guide/pages-routing/markdown.md +13 -171
  208. package/skills/void/docs/guide/pages-routing/overview.md +7 -17
  209. package/skills/void/docs/guide/pages-routing/view-transitions.md +1 -1
  210. package/skills/void/docs/guide/platform/administration/access.md +1 -4
  211. package/skills/void/docs/guide/platform/administration/email.md +35 -8
  212. package/skills/void/docs/guide/platform/administration/operations.md +26 -4
  213. package/skills/void/docs/guide/platform/administration/plans.md +126 -0
  214. package/skills/void/docs/guide/platform/administration/projects.md +5 -2
  215. package/skills/void/docs/guide/platform/administration/zero-trust.md +189 -0
  216. package/skills/void/docs/guide/platform/development/local.md +2 -2
  217. package/skills/void/docs/guide/platform/development/runtime.md +3 -13
  218. package/skills/void/docs/guide/platform/development/schema-ci.md +0 -58
  219. package/skills/void/docs/guide/platform/installation/credentials.md +6 -4
  220. package/skills/void/docs/guide/platform/installation/domains.md +31 -3
  221. package/skills/void/docs/guide/platform/installation/first-deployment.md +6 -0
  222. package/skills/void/docs/guide/platform/installation/maintenance.md +3 -1
  223. package/skills/void/docs/guide/platform/installation/prerequisites.md +21 -16
  224. package/skills/void/docs/guide/platform/installation/setup.md +9 -5
  225. package/skills/void/docs/guide/platform/installation/uninstall.md +17 -2
  226. package/skills/void/docs/guide/platform-administration.md +2 -0
  227. package/skills/void/docs/guide/queues.md +7 -9
  228. package/skills/void/docs/guide/quickstart.md +38 -37
  229. package/skills/void/docs/guide/remote-dev.md +4 -9
  230. package/skills/void/docs/guide/sandboxes.md +78 -41
  231. package/skills/void/docs/guide/server-routing.md +9 -72
  232. package/skills/void/docs/guide/sse.md +4 -18
  233. package/skills/void/docs/guide/ssg.md +3 -15
  234. package/skills/void/docs/guide/ssr.md +14 -62
  235. package/skills/void/docs/guide/storage.md +9 -4
  236. package/skills/void/docs/guide/type-safety.md +3 -14
  237. package/skills/void/docs/guide/typed-fetch.md +3 -7
  238. package/skills/void/docs/guide/websockets.md +68 -40
  239. package/skills/void/docs/integrations/agents.md +3 -3
  240. package/skills/void/docs/integrations/cloudflare.md +85 -316
  241. package/skills/void/docs/integrations/frameworks/analog.md +5 -64
  242. package/skills/void/docs/integrations/frameworks/astro.md +4 -73
  243. package/skills/void/docs/integrations/frameworks/nuxt.md +5 -62
  244. package/skills/void/docs/integrations/frameworks/overview.md +11 -54
  245. package/skills/void/docs/integrations/frameworks/react-router.md +5 -60
  246. package/skills/void/docs/integrations/frameworks/sveltekit.md +6 -65
  247. package/skills/void/docs/integrations/frameworks/tanstack-start.md +4 -62
  248. package/skills/void/docs/integrations/nodejs-bun-deno.md +5 -69
  249. package/skills/void/docs/reference/api/auth.md +156 -0
  250. package/skills/void/docs/reference/api/client.md +87 -0
  251. package/skills/void/docs/reference/api/database.md +95 -0
  252. package/skills/void/docs/reference/api/durable.md +46 -0
  253. package/skills/void/docs/reference/api/env.md +50 -0
  254. package/skills/void/docs/reference/api/handlers.md +254 -0
  255. package/skills/void/docs/reference/api/pages.md +241 -0
  256. package/skills/void/docs/reference/api/plugin.md +39 -0
  257. package/skills/void/docs/reference/api/resources.md +109 -0
  258. package/skills/void/docs/reference/api/rewrites.md +76 -0
  259. package/skills/void/docs/reference/api/types.md +92 -0
  260. package/skills/void/docs/reference/api.md +56 -1218
  261. package/skills/void/docs/reference/cli/auth.md +88 -0
  262. package/skills/void/docs/reference/cli/database.md +128 -0
  263. package/skills/void/docs/reference/cli/deploy.md +85 -0
  264. package/skills/void/docs/reference/cli/domains.md +41 -0
  265. package/skills/void/docs/reference/cli/email.md +129 -0
  266. package/skills/void/docs/reference/cli/generate.md +116 -0
  267. package/skills/void/docs/reference/cli/github.md +189 -0
  268. package/skills/void/docs/reference/cli/platform-config.md +92 -0
  269. package/skills/void/docs/reference/cli/platform-email.md +81 -0
  270. package/skills/void/docs/reference/cli/platform-installation.md +127 -0
  271. package/skills/void/docs/reference/cli/platform-operations.md +90 -0
  272. package/skills/void/docs/reference/cli/platform-users.md +89 -0
  273. package/skills/void/docs/reference/cli/platform-zero-trust.md +45 -0
  274. package/skills/void/docs/reference/cli/platform.md +70 -0
  275. package/skills/void/docs/reference/cli/project.md +214 -0
  276. package/skills/void/docs/reference/cli/secrets.md +76 -0
  277. package/skills/void/docs/reference/cli/setup.md +70 -0
  278. package/skills/void/docs/reference/cli.md +33 -1621
  279. package/skills/void/docs/reference/config.md +26 -32
  280. package/skills/void/docs/reference/resource-inference.md +3 -58
  281. package/skills/void/docs/reference/structure.md +14 -41
  282. package/dist/canonical-json-DuDiiUsQ.mjs +0 -13
  283. package/dist/cli/cf-compat.mjs +0 -968
  284. package/dist/client-4cDVv7BO.mjs +0 -2
  285. package/dist/gen-Vnv2f65C.mjs +0 -2
  286. package/dist/help-DQMfeKMz.mjs +0 -2
  287. package/dist/login-DFQk7rbW.mjs +0 -2
  288. package/dist/migrate-TsHGBnDA.mjs +0 -2
  289. package/dist/plan-BEZ8VJW0.mjs +0 -256
  290. package/dist/plan-DpuOr14e.mjs +0 -2
  291. package/dist/prepare-BZXkjdNe.mjs +0 -2
  292. package/dist/validate-EKmJWxmy.mjs +0 -2
  293. /package/dist/cli/{cf-compat.d.mts → cloudflare-operation-process.d.mts} +0 -0
@@ -1,968 +0,0 @@
1
- #!/usr/bin/env node
2
- import { a as join, n as dirname, u as resolve } from "../dist-BVqXeR_h.mjs";
3
- import { t as prepareCfBuildOutput } from "../cf-build-output-CGT03qCD.mjs";
4
- import { copyFileSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
5
- import { fileURLToPath, pathToFileURL } from "node:url";
6
- import { tmpdir } from "node:os";
7
- import { spawnSync } from "node:child_process";
8
- import { parse } from "jsonc-parser";
9
- import { readBuildOutput } from "@cloudflare/build-output-utils";
10
- import { EnvHttpProxyAgent, fetch as fetch$1 } from "undici";
11
- //#region src/cli/cf-compat.ts
12
- /**
13
- * Private transport for the existing Void Cloudflare command seams. The
14
- * orchestrators still use their established argument/result contracts; this
15
- * process translates them to the pinned cf CLI. It never invokes Wrangler.
16
- */
17
- const cf = join(dirname(fileURLToPath(import.meta.resolve("cf/package.json"))), "bin", "cf");
18
- const args = process.argv.slice(2);
19
- function cfEnvironment() {
20
- const env = {
21
- ...process.env,
22
- CF_DELEGATION: "1",
23
- CF_SEND_TELEMETRY: "false",
24
- CF_NO_OSC_PROGRESS: "1",
25
- CLOUDFLARE_AUTH_USE_KEYRING: process.env.CLOUDFLARE_AUTH_USE_KEYRING ?? "true"
26
- };
27
- if (env.HTTP_PROXY || env.HTTPS_PROXY || env.http_proxy || env.https_proxy) env.NODE_USE_ENV_PROXY = "1";
28
- for (const [canonical, alias] of [
29
- ["CLOUDFLARE_API_TOKEN", "CF_API_TOKEN"],
30
- ["CLOUDFLARE_API_KEY", "CF_API_KEY"],
31
- ["CLOUDFLARE_EMAIL", "CF_EMAIL"],
32
- ["CLOUDFLARE_ACCOUNT_ID", "CF_ACCOUNT_ID"]
33
- ]) if (!env[canonical] && env[alias]) env[canonical] = env[alias];
34
- return env;
35
- }
36
- function result(status, stdout = "", stderr = "") {
37
- return {
38
- status,
39
- stdout,
40
- stderr
41
- };
42
- }
43
- function runCf(command, cwd = process.cwd()) {
44
- const env = cfEnvironment();
45
- env.CF_QUIET = "1";
46
- const child = spawnSync(process.execPath, [cf, ...command], {
47
- cwd,
48
- env,
49
- encoding: "utf8",
50
- shell: false,
51
- windowsHide: true,
52
- maxBuffer: 33554432,
53
- stdio: [
54
- "ignore",
55
- "pipe",
56
- "pipe"
57
- ]
58
- });
59
- const stderr = [
60
- child.stderr || "",
61
- child.error?.message || "",
62
- child.signal ? `Cloudflare CLI terminated by ${child.signal}.` : ""
63
- ].filter(Boolean).join("\n").replace(/\[(\d{4,})\]/g, "[code: $1]");
64
- return result(child.status ?? 1, child.stdout ?? "", stderr);
65
- }
66
- function runInteractiveCf(command) {
67
- const child = spawnSync(process.execPath, [
68
- cf,
69
- ...command,
70
- "--quiet"
71
- ], {
72
- cwd: process.cwd(),
73
- env: {
74
- ...cfEnvironment(),
75
- CF_QUIET: "1"
76
- },
77
- shell: false,
78
- stdio: "inherit",
79
- windowsHide: true
80
- });
81
- return result(child.status ?? 1, "", child.error?.message ?? "");
82
- }
83
- async function withBuildOutput(raw, sourceMain, action) {
84
- const scratch = mkdtempSync(join(tmpdir(), "void-cf-command-"));
85
- try {
86
- const main = "index.js";
87
- if (sourceMain) copyFileSync(sourceMain, join(scratch, main));
88
- else writeFileSync(join(scratch, main), "export default { fetch() { return new Response(\"\"); } };\n");
89
- writeFileSync(join(scratch, "wrangler.json"), JSON.stringify({
90
- ...raw,
91
- main,
92
- compatibility_date: raw.compatibility_date ?? "2025-01-01"
93
- }), { mode: 384 });
94
- const accountId = process.env.CLOUDFLARE_ACCOUNT_ID ?? raw.account_id;
95
- if (typeof accountId !== "string" || !accountId) throw new Error("Cloudflare account is not pinned for Worker deployment.");
96
- const output = await prepareCfBuildOutput(scratch, accountId);
97
- if (!output) throw new Error("Could not prepare the Cloudflare Worker build output.");
98
- try {
99
- await assertExistingProvisionableResources(output.directory, accountId);
100
- return action(output.directory);
101
- } finally {
102
- output.dispose();
103
- }
104
- } finally {
105
- rmSync(scratch, {
106
- recursive: true,
107
- force: true
108
- });
109
- }
110
- }
111
- function parsedJson(value) {
112
- return JSON.parse(value);
113
- }
114
- function object(value) {
115
- if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Cloudflare returned an unexpected response.");
116
- return value;
117
- }
118
- function field(name) {
119
- const index = args.indexOf(name);
120
- return index >= 0 ? args[index + 1] : void 0;
121
- }
122
- function configPath() {
123
- return field("-c") ?? field("--config");
124
- }
125
- function config() {
126
- const path = configPath();
127
- if (!path) throw new Error("Cloudflare config path is required for this operation.");
128
- return object(parse(readFileSync(path, "utf8")));
129
- }
130
- function workerName() {
131
- const name = field("--name") ?? config().name;
132
- if (typeof name !== "string" || !name) throw new Error("Cloudflare Worker name is missing from the generated config.");
133
- return name;
134
- }
135
- function updateBinding(section, binding, values) {
136
- const path = configPath();
137
- if (!path || !binding) throw new Error("Cloudflare resource binding and config are required.");
138
- const current = config();
139
- const previous = Array.isArray(current[section]) ? current[section] : [];
140
- const existing = previous.map(object).find((entry) => entry.binding === binding);
141
- current[section] = [...previous.filter((entry) => object(entry).binding !== binding), {
142
- ...existing,
143
- binding,
144
- ...values
145
- }];
146
- writeFileSync(path, `${JSON.stringify(current, null, 2)}\n`);
147
- }
148
- function d1Database(token) {
149
- const entries = config().d1_databases;
150
- if (!Array.isArray(entries)) throw new Error("D1 database binding is unavailable.");
151
- const selected = entries.map(object).find((entry) => entry.database_id === token || entry.database_name === token || entry.binding === token);
152
- if (!selected || typeof selected.database_id !== "string") throw new Error("D1 database binding is unavailable.");
153
- return {
154
- id: selected.database_id,
155
- dir: typeof selected.migrations_dir === "string" ? selected.migrations_dir : "./migrations",
156
- ...typeof selected.migrations_pattern === "string" ? { pattern: selected.migrations_pattern } : {},
157
- table: typeof selected.migrations_table === "string" ? selected.migrations_table : "d1_migrations"
158
- };
159
- }
160
- function cleanJson(command, transform) {
161
- const called = runCf(command);
162
- if (called.status !== 0 || !transform) return called;
163
- return result(0, `${JSON.stringify(transform(parsedJson(called.stdout)))}\n`, called.stderr);
164
- }
165
- function accountId() {
166
- const accountId = process.env.CLOUDFLARE_ACCOUNT_ID ?? config().account_id;
167
- if (typeof accountId !== "string" || !accountId) throw new Error("Cloudflare account is not pinned for API inspection.");
168
- return accountId;
169
- }
170
- async function cloudflareApiGet(path, failure, extraHeaders = {}) {
171
- const url = `${(process.env.CLOUDFLARE_API_BASE_URL ?? "https://api.cloudflare.com/client/v4").replace(/\/$/, "")}${path}`;
172
- const proxy = process.env.HTTP_PROXY || process.env.HTTPS_PROXY || process.env.http_proxy || process.env.https_proxy ? new EnvHttpProxyAgent() : null;
173
- try {
174
- const response = await fetch$1(url, {
175
- headers: {
176
- ...await apiHeaders(),
177
- ...extraHeaders
178
- },
179
- redirect: "error",
180
- signal: AbortSignal.timeout(3e4),
181
- ...proxy ? { dispatcher: proxy } : {}
182
- });
183
- const body = object(await response.json());
184
- if (!response.ok || body.success !== true) throw new Error(failure);
185
- return body;
186
- } finally {
187
- await proxy?.close();
188
- }
189
- }
190
- async function clearWorkerCronSchedules(worker) {
191
- const endpoint = `${(process.env.CLOUDFLARE_API_BASE_URL ?? "https://api.cloudflare.com/client/v4").replace(/\/$/, "")}/accounts/${encodeURIComponent(accountId())}/workers/scripts/${encodeURIComponent(worker)}/schedules`;
192
- const proxy = process.env.HTTP_PROXY || process.env.HTTPS_PROXY || process.env.http_proxy || process.env.https_proxy ? new EnvHttpProxyAgent() : null;
193
- try {
194
- const response = await fetch$1(endpoint, {
195
- method: "PUT",
196
- headers: {
197
- ...await apiHeaders(),
198
- "Content-Type": "application/json"
199
- },
200
- body: "[]",
201
- redirect: "error",
202
- signal: AbortSignal.timeout(3e4),
203
- ...proxy ? { dispatcher: proxy } : {}
204
- });
205
- const body = object(await response.json());
206
- const schedules = object(body.result).schedules;
207
- if (!response.ok || body.success !== true || !Array.isArray(schedules) || schedules.length !== 0) throw new Error(`Cloudflare did not clear the Worker Cron Triggers (HTTP ${response.status}).`);
208
- return result(0);
209
- } finally {
210
- await proxy?.close();
211
- }
212
- }
213
- async function assertExistingProvisionableResources(directory, account) {
214
- const bindings = (await readBuildOutput(directory)).workers.default.config.env ?? {};
215
- const queueNames = /* @__PURE__ */ new Set();
216
- const accountPath = `/accounts/${encodeURIComponent(account)}`;
217
- for (const [bindingName, value] of Object.entries(bindings)) {
218
- const binding = object(value);
219
- const identifier = (key) => {
220
- const id = binding[key];
221
- if (typeof id !== "string" || !id) throw new Error(`Cloudflare binding ${bindingName} has no ${key}; refusing automatic provisioning.`);
222
- return id;
223
- };
224
- if (binding.type === "kv" || binding.type === "d1") identifier("id");
225
- else if (binding.type === "r2") {
226
- const name = identifier("name");
227
- const jurisdiction = binding.jurisdiction;
228
- if (jurisdiction !== void 0 && typeof jurisdiction !== "string") throw new Error(`Cloudflare R2 binding ${bindingName} has an invalid jurisdiction.`);
229
- await cloudflareApiGet(`${accountPath}/r2/buckets/${encodeURIComponent(name)}`, `Cloudflare R2 bucket ${name} is unavailable; refusing automatic provisioning.`, jurisdiction ? { "cf-r2-jurisdiction": jurisdiction } : {});
230
- } else if (binding.type === "queue") queueNames.add(identifier("name"));
231
- else if (binding.type === "dispatch-namespace") {
232
- const name = identifier("namespace");
233
- await cloudflareApiGet(`${accountPath}/workers/dispatch/namespaces/${encodeURIComponent(name)}`, `Cloudflare dispatch namespace ${name} is unavailable; refusing automatic provisioning.`);
234
- } else if (binding.type === "ai-search-namespace") {
235
- const name = identifier("namespace");
236
- await cloudflareApiGet(`${accountPath}/ai-search/namespaces/${encodeURIComponent(name)}`, `Cloudflare AI Search namespace ${name} is unavailable; refusing automatic provisioning.`);
237
- } else if (binding.type === "agent-memory") {
238
- const name = identifier("namespace");
239
- await cloudflareApiGet(`${accountPath}/agent-memory/namespaces/${encodeURIComponent(name)}`, `Cloudflare Agent Memory namespace ${name} is unavailable; refusing automatic provisioning.`);
240
- } else if (binding.type === "flagship") identifier("id");
241
- }
242
- if (queueNames.size > 0) {
243
- const existing = new Set((await readAllQueues()).map((queue) => queue.queue_name));
244
- for (const name of queueNames) if (!existing.has(name)) throw new Error(`Cloudflare Queue ${name} is unavailable; refusing automatic provisioning.`);
245
- }
246
- }
247
- async function readVersionResources(worker, versionId) {
248
- const resources = object(object((await cloudflareApiGet(`/accounts/${encodeURIComponent(accountId())}/workers/scripts/${encodeURIComponent(worker)}/versions/${encodeURIComponent(versionId)}`, "Cloudflare did not return Worker version resources.")).result).resources);
249
- if (!Array.isArray(resources.bindings) || !resources.script || !resources.script_runtime) throw new Error("Cloudflare Worker version resources were incomplete.");
250
- return resources;
251
- }
252
- async function apiHeaders() {
253
- const key = process.env.CLOUDFLARE_API_KEY ?? process.env.CF_API_KEY;
254
- const email = process.env.CLOUDFLARE_EMAIL ?? process.env.CF_EMAIL;
255
- if (key && email) return {
256
- "X-Auth-Key": key,
257
- "X-Auth-Email": email
258
- };
259
- const credential = await sessionCredential();
260
- if (!credential) throw new Error("Cloudflare session bearer is unavailable.");
261
- return { Authorization: `Bearer ${credential.token}` };
262
- }
263
- async function withSecretFile(content, action) {
264
- const directory = mkdtempSync(join(tmpdir(), "void-cf-secret-"));
265
- try {
266
- const path = join(directory, "body.json");
267
- writeFileSync(path, content, { mode: 384 });
268
- return await action(path);
269
- } finally {
270
- rmSync(directory, {
271
- recursive: true,
272
- force: true
273
- });
274
- }
275
- }
276
- async function sessionCredential() {
277
- const token = process.env.CLOUDFLARE_API_TOKEN || process.env.CF_API_TOKEN;
278
- if (token) return {
279
- type: "api_token",
280
- token
281
- };
282
- const identity = runCf(["auth", "whoami"]);
283
- if (identity.status !== 0) return null;
284
- const state = object(parsedJson(identity.stdout));
285
- if (state.authenticated !== true || state.tokenValid !== true) return null;
286
- if (typeof state.authSource !== "string" || !state.authSource.startsWith("OAuth token")) return null;
287
- const dist = join(dirname(fileURLToPath(import.meta.resolve("cf/package.json"))), "dist");
288
- const entry = readdirSync(dist).find((name) => /^cf-[^/]+\.mjs$/.test(name));
289
- if (!entry) throw new Error("The bundled Cloudflare credential reader is unavailable.");
290
- const previousKeyringSetting = process.env.CLOUDFLARE_AUTH_USE_KEYRING;
291
- process.env.CLOUDFLARE_AUTH_USE_KEYRING = previousKeyringSetting ?? "true";
292
- let stored;
293
- try {
294
- const module = await import(pathToFileURL(join(dist, entry)).href);
295
- if (typeof module.t !== "function") throw new Error("The bundled Cloudflare credential reader is unavailable.");
296
- const noop = () => {};
297
- stored = module.t({ logger: {
298
- debug: noop,
299
- info: noop,
300
- log: noop,
301
- warn: noop,
302
- error: noop
303
- } }).readAuthCredentials();
304
- } finally {
305
- if (previousKeyringSetting === void 0) delete process.env.CLOUDFLARE_AUTH_USE_KEYRING;
306
- else process.env.CLOUDFLARE_AUTH_USE_KEYRING = previousKeyringSetting;
307
- }
308
- const credential = stored && typeof stored === "object" ? stored : null;
309
- return credential && typeof credential.oauth_token === "string" && credential.oauth_token ? {
310
- type: "oauth",
311
- token: credential.oauth_token
312
- } : null;
313
- }
314
- async function auth() {
315
- if (args[0] === "login") return runInteractiveCf([
316
- "auth",
317
- "login",
318
- "--force"
319
- ]);
320
- if (args[0] === "logout") return runCf(["auth", "logout"]);
321
- if (args[0] === "whoami") {
322
- const called = runCf(["auth", "whoami"]);
323
- if (called.status !== 0) return called;
324
- const identity = object(parsedJson(called.stdout));
325
- if (identity.authenticated !== true || identity.tokenValid !== true) return result(1, JSON.stringify({ loggedIn: false }), "Cloudflare authentication is required.");
326
- return result(0, JSON.stringify({
327
- loggedIn: true,
328
- accounts: identity.accounts,
329
- email: identity.email,
330
- tokenPermissions: identity.scopes,
331
- authType: process.env.CLOUDFLARE_API_KEY || process.env.CF_API_KEY ? "Global API Key" : String(identity.authSource).startsWith("OAuth token") ? "OAuth Token" : "API Token"
332
- }), called.stderr);
333
- }
334
- if (args[0] === "auth" && args[1] === "token") {
335
- const credential = await sessionCredential();
336
- return credential ? result(0, `${JSON.stringify(credential)}\n`) : result(1, "", "Cloudflare session has no OAuth bearer.");
337
- }
338
- return result(1, "", "Unsupported Cloudflare authentication operation.");
339
- }
340
- function listAllResourcePages(command, extraFlags = []) {
341
- const pageSize = 100;
342
- const entries = [];
343
- for (let page = 1; page <= 100; page++) {
344
- const listed = runCf([
345
- ...command,
346
- "--page",
347
- String(page),
348
- "--per-page",
349
- String(pageSize),
350
- ...extraFlags
351
- ]);
352
- if (listed.status !== 0) return listed;
353
- const items = parsedJson(listed.stdout);
354
- if (!Array.isArray(items) || items.length > pageSize) throw new Error(`Cloudflare returned an invalid ${command.join(" ")} page.`);
355
- entries.push(...items);
356
- if (items.length < pageSize) return result(0, `${JSON.stringify(entries)}\n`);
357
- }
358
- throw new Error(`Cloudflare ${command.join(" ")} exceeded the supported page limit.`);
359
- }
360
- async function readAllQueues() {
361
- const queues = [];
362
- const seen = /* @__PURE__ */ new Set();
363
- for (let page = 1; page <= 1e3; page++) {
364
- const body = await cloudflareApiGet(`/accounts/${encodeURIComponent(accountId())}/queues?page=${page}`, "Cloudflare did not return the Queue list.");
365
- const entries = body.result;
366
- const info = object(body.result_info);
367
- if (!Array.isArray(entries) || !Number.isSafeInteger(info.page) || info.page !== page || !Number.isSafeInteger(info.total_pages) || info.total_pages < 0 || info.total_pages > 1e3) throw new Error("Cloudflare returned incomplete Queue pagination.");
368
- for (const entry of entries) {
369
- const queue = object(entry);
370
- if (typeof queue.queue_id !== "string" || typeof queue.queue_name !== "string" || seen.has(queue.queue_id)) throw new Error("Cloudflare returned an invalid Queue list.");
371
- seen.add(queue.queue_id);
372
- queues.push(queue);
373
- }
374
- if (page >= info.total_pages) return queues;
375
- }
376
- throw new Error("Cloudflare Queue list exceeded the supported page limit.");
377
- }
378
- async function resources() {
379
- const [group, verb, third] = args;
380
- if (group === "d1" && verb === "execute" && third) {
381
- const database = d1Database(third);
382
- const sql = field("--command");
383
- if (!sql) throw new Error("D1 SQL command is missing.");
384
- return runCf([
385
- "d1",
386
- "query",
387
- database.id,
388
- "--sql",
389
- sql
390
- ]);
391
- }
392
- if (group === "d1" && verb === "migrations" && (third === "list" || third === "apply")) {
393
- const token = args[3];
394
- if (!token) throw new Error("D1 migration target is missing.");
395
- const database = d1Database(token);
396
- const called = runCf([
397
- "d1",
398
- "migrations",
399
- third,
400
- database.id,
401
- "--dir",
402
- database.dir,
403
- ...database.pattern ? ["--pattern", database.pattern] : [],
404
- "--table",
405
- database.table
406
- ]);
407
- if (called.status !== 0 || third !== "list") return called;
408
- const pending = parsedJson(called.stdout);
409
- if (!Array.isArray(pending)) throw new Error("D1 migration list was malformed.");
410
- return result(0, pending.length ? `Migrations to be applied:\n${pending.map((item) => object(item).Name).join("\n")}\n` : "No migrations to apply!\n");
411
- }
412
- if (group === "containers" && verb === "list") return runCf([
413
- "containers",
414
- "applications",
415
- "list"
416
- ]);
417
- if (group === "d1" && verb === "list") return listAllResourcePages(["d1", "list"]);
418
- if (group === "d1" && verb === "info" && third) {
419
- const listed = listAllResourcePages(["d1", "list"]);
420
- if (listed.status !== 0) return listed;
421
- const value = parsedJson(listed.stdout);
422
- if (!Array.isArray(value)) throw new Error("D1 list was malformed.");
423
- const selected = value.find((item) => object(item).name === third) ?? null;
424
- return selected === null ? result(1, "", `D1 database ${JSON.stringify(third)} does not exist.`) : result(0, `${JSON.stringify(selected)}\n`);
425
- }
426
- if (group === "d1" && verb === "create" && third) {
427
- const created = runCf([
428
- "d1",
429
- "create",
430
- "--name",
431
- third
432
- ]);
433
- if (created.status !== 0) return created;
434
- const database = object(parsedJson(created.stdout));
435
- if (typeof database.uuid !== "string") throw new Error("D1 creation returned no database ID.");
436
- updateBinding("d1_databases", field("--binding") ?? "", {
437
- database_name: third,
438
- database_id: database.uuid
439
- });
440
- return created;
441
- }
442
- if (group === "kv" && verb === "namespace" && third === "list") return listAllResourcePages([
443
- "kv",
444
- "namespaces",
445
- "list"
446
- ], [
447
- "--order",
448
- "id",
449
- "--direction",
450
- "asc"
451
- ]);
452
- if (group === "kv" && verb === "namespace" && third === "create" && args[3]) {
453
- const created = runCf([
454
- "kv",
455
- "namespaces",
456
- "create",
457
- "--title",
458
- args[3]
459
- ]);
460
- if (created.status !== 0) return created;
461
- const namespace = object(parsedJson(created.stdout));
462
- if (typeof namespace.id !== "string") throw new Error("KV creation returned no namespace ID.");
463
- updateBinding("kv_namespaces", field("--binding") ?? "", { id: namespace.id });
464
- return created;
465
- }
466
- if (group === "r2" && verb === "bucket" && third === "info" && args[3]) {
467
- const read = runCf([
468
- "r2",
469
- "buckets",
470
- "get",
471
- args[3]
472
- ]);
473
- return read.status !== 0 && /\[code:\s*10006\]/.test(read.stderr) ? result(1, "", "[code: 10006] The specified bucket does not exist.") : read;
474
- }
475
- if (group === "r2" && verb === "bucket" && third === "create" && args[3]) {
476
- const created = runCf([
477
- "r2",
478
- "buckets",
479
- "create",
480
- "--name",
481
- args[3]
482
- ]);
483
- if (created.status === 0) updateBinding("r2_buckets", field("--binding") ?? "", { bucket_name: args[3] });
484
- return created;
485
- }
486
- if (group === "hyperdrive" && verb === "create" && third) {
487
- const connection = args.find((part) => part.startsWith("--connection-string="))?.slice(20);
488
- if (!connection) throw new Error("Hyperdrive connection string is missing.");
489
- const url = new URL(connection);
490
- const created = await withSecretFile(JSON.stringify({
491
- name: third,
492
- origin: {
493
- host: url.hostname,
494
- port: Number(url.port || (url.protocol.startsWith("mysql") ? 3306 : 5432)),
495
- database: decodeURIComponent(url.pathname.replace(/^\//, "")),
496
- scheme: url.protocol.replace(":", ""),
497
- user: decodeURIComponent(url.username),
498
- password: decodeURIComponent(url.password)
499
- }
500
- }), (path) => runCf([
501
- "hyperdrive",
502
- "create",
503
- "--body",
504
- `@${path}`
505
- ]));
506
- if (created.status !== 0) return result(created.status, "", "Hyperdrive creation failed.");
507
- const hyperdrive = object(parsedJson(created.stdout));
508
- if (typeof hyperdrive.id !== "string") throw new Error("Hyperdrive creation returned no ID.");
509
- updateBinding("hyperdrive", field("--binding") ?? "", { id: hyperdrive.id });
510
- return result(0, `${JSON.stringify({
511
- id: hyperdrive.id,
512
- name: third
513
- })}\n`);
514
- }
515
- if (group === "queues" && (verb === "info" || verb === "create") && third) {
516
- if (verb === "create") return runCf([
517
- "queues",
518
- "create",
519
- "--queue-name",
520
- third
521
- ]);
522
- return (await readAllQueues()).find((item) => item.queue_name === third) ? result(0, `Queue Name: ${third}\n`) : result(1, "", `Queue "${third}" does not exist`);
523
- }
524
- return result(1, "", `Unsupported Cloudflare resource operation: ${group} ${verb}.`);
525
- }
526
- function emailZone(domain) {
527
- const labels = domain.split(".");
528
- for (let offset = 0; offset <= labels.length - 2; offset++) {
529
- const candidate = labels.slice(offset).join(".");
530
- const read = runCf([
531
- "email-routing",
532
- "settings",
533
- "get",
534
- "--zone",
535
- candidate
536
- ]);
537
- if (read.status === 0) return candidate;
538
- if (!/Zone not found:/.test(read.stderr)) throw new Error("Cloudflare could not resolve the Email zone.");
539
- }
540
- throw new Error(`Cloudflare Email zone for ${domain} was not found.`);
541
- }
542
- function email() {
543
- const [group, product, operation, candidate] = args;
544
- if (group !== "email" || !candidate) return result(1, "", "Unsupported Cloudflare email operation.");
545
- if (product === "routing" && operation === "settings") {
546
- const read = runCf([
547
- "email-routing",
548
- "settings",
549
- "get",
550
- "--zone",
551
- candidate
552
- ]);
553
- if (read.status !== 0) return /Zone not found:/.test(read.stderr) ? result(1, "", `Could not find a zone for \`${candidate}\`.`) : read;
554
- const settings = object(parsedJson(read.stdout));
555
- if (typeof settings.tag !== "string" || typeof settings.name !== "string") throw new Error("Email Routing settings were incomplete.");
556
- return result(0, `Email Routing for ${settings.name}:\n Enabled: ${settings.enabled === true}\n Status: ${settings.status}\n Tag: ${settings.tag}\n`);
557
- }
558
- if (product === "routing" && operation === "enable") return runCf([
559
- "email-routing",
560
- "enable",
561
- "--zone",
562
- candidate,
563
- "--name",
564
- candidate
565
- ]);
566
- if (product === "routing" && operation === "rules" && args[3] === "list" && args[4]) {
567
- const zone = args[4];
568
- const lines = [];
569
- for (let page = 1; page <= 100; page++) {
570
- const listed = runCf([
571
- "email-routing",
572
- "rules",
573
- "list-account",
574
- "--zone",
575
- zone,
576
- "--page",
577
- String(page),
578
- "--per-page",
579
- "100"
580
- ]);
581
- if (listed.status !== 0) return listed;
582
- const items = parsedJson(listed.stdout);
583
- if (!Array.isArray(items)) throw new Error("Email Routing rules were malformed.");
584
- for (const entry of items.map(object)) {
585
- const actions = Array.isArray(entry.actions) ? entry.actions.map((action) => {
586
- const item = object(action);
587
- return item.type === "worker" ? `worker:${item.value}` : item.type === "forward" && Array.isArray(item.value) ? `forward:${item.value.join(",")}` : String(item.type);
588
- }) : [];
589
- const matchers = Array.isArray(entry.matchers) ? entry.matchers.map(object) : [];
590
- if (matchers.some((item) => item.type === "all")) lines.push(`Catch-all rule: ${entry.enabled === true ? "enabled" : "disabled"}, action: ${actions.join(", ")}`);
591
- else {
592
- if (typeof entry.id !== "string") throw new Error("Email Routing rule ID was missing.");
593
- const recipients = matchers.filter((item) => item.type === "literal" || item.type === "to").map((item) => `to:${item.value}`);
594
- lines.push(`Rule: ${entry.id}\n Name: ${entry.name || "(none)"}\n Enabled: ${entry.enabled === true}\n Matchers: ${recipients.join(", ")}\n Actions: ${actions.join(", ")}\n Priority: ${entry.priority ?? 0}`);
595
- }
596
- }
597
- if (items.length < 100) return result(0, lines.length ? `${lines.join("\n")}\n` : "No routing rules found.\n");
598
- }
599
- throw new Error("Email Routing rules exceeded the supported page limit.");
600
- }
601
- if (product === "sending" && operation === "settings") {
602
- const listed = runCf([
603
- "email-sending",
604
- "subdomains",
605
- "list",
606
- "--zone",
607
- emailZone(candidate)
608
- ]);
609
- if (listed.status !== 0) return listed;
610
- const values = parsedJson(listed.stdout);
611
- if (!Array.isArray(values)) throw new Error("Email Sending subdomains were malformed.");
612
- const match = values.map(object).find((item) => item.name === candidate);
613
- if (!match) return result(1, "", `No sending subdomain found for \`${candidate}\`.`);
614
- const tag = match.tag ?? match.id;
615
- if (typeof tag !== "string") throw new Error("Email Sending subdomain ID was missing.");
616
- return result(0, `Email Sending for ${candidate}:\n Enabled: ${match.enabled === true}\n Tag: ${tag}\n`);
617
- }
618
- if (product === "sending" && operation === "enable") return runCf([
619
- "email-sending",
620
- "subdomains",
621
- "create",
622
- "--zone",
623
- emailZone(candidate),
624
- "--name",
625
- candidate
626
- ]);
627
- return result(1, "", `Unsupported Cloudflare email operation: ${product} ${operation}.`);
628
- }
629
- async function secrets() {
630
- const worker = workerName();
631
- const verb = args[1];
632
- const apply = async (action) => {
633
- const first = action();
634
- if (first.status === 0 || !/\[code:\s*10007\]/.test(first.stderr)) return first;
635
- const draft = await withBuildOutput({
636
- name: worker,
637
- account_id: process.env.CLOUDFLARE_ACCOUNT_ID ?? config().account_id,
638
- compatibility_date: config().compatibility_date ?? "2025-01-01",
639
- workers_dev: false,
640
- preview_urls: false
641
- }, null, (directory) => runCf([
642
- "deploy",
643
- "--prebuilt",
644
- "--message",
645
- "void:secret-draft"
646
- ], directory));
647
- return draft.status === 0 ? action() : draft;
648
- };
649
- if (verb === "list") {
650
- const listed = runCf([
651
- "workers",
652
- "secrets",
653
- "list",
654
- "--worker",
655
- worker
656
- ]);
657
- if (listed.status !== 0 && /\[code:\s*(?:10007|10090)\]/.test(listed.stderr)) return result(1, "", `Worker "${worker}" not found. [code: 10007]`);
658
- return listed;
659
- }
660
- if (verb === "put" && args[2]) {
661
- const value = readFileSync(0, "utf8").replace(/\n$/, "");
662
- return await withSecretFile(JSON.stringify({
663
- name: args[2],
664
- text: value,
665
- type: "secret_text"
666
- }), (path) => apply(() => runCf([
667
- "workers",
668
- "secrets",
669
- "update",
670
- args[2],
671
- "--worker",
672
- worker,
673
- "--body",
674
- `@${path}`
675
- ])));
676
- }
677
- if (verb === "bulk") {
678
- const input = object(parsedJson(readFileSync(0, "utf8")));
679
- const patch = Object.fromEntries(Object.entries(input).map(([name, text]) => [name, {
680
- type: "secret_text",
681
- text
682
- }]));
683
- return await withSecretFile(JSON.stringify(patch), (path) => apply(() => runCf([
684
- "workers",
685
- "secrets",
686
- "bulk",
687
- "--worker",
688
- worker,
689
- "--file",
690
- path
691
- ])));
692
- }
693
- if (verb === "delete" && args[2]) return runCf([
694
- "workers",
695
- "secrets",
696
- "delete",
697
- args[2],
698
- "--worker",
699
- worker,
700
- "--force"
701
- ]);
702
- return result(1, "", `Unsupported Cloudflare secret operation: ${verb}.`);
703
- }
704
- async function workerHistory() {
705
- const worker = workerName();
706
- const [group, verb, third] = args;
707
- if (group === "deployments" && (verb === "status" || verb === "list")) {
708
- const called = runCf([
709
- "workers",
710
- "deployments",
711
- "list",
712
- "--worker",
713
- worker
714
- ]);
715
- if (called.status !== 0) return called;
716
- const deployments = object(parsedJson(called.stdout)).deployments;
717
- if (!Array.isArray(deployments)) throw new Error("Worker deployments were malformed.");
718
- if (verb === "status") return deployments[0] ? result(0, `${JSON.stringify(deployments[0])}\n`) : result(1, "", "Worker has no active deployment.");
719
- return result(0, `${JSON.stringify(deployments)}\n`);
720
- }
721
- if (group === "versions" && verb === "list") return cleanJson([
722
- "workers",
723
- "versions",
724
- "list",
725
- "--worker-id",
726
- worker
727
- ], (value) => {
728
- if (!Array.isArray(value)) throw new Error("Worker versions were malformed.");
729
- return value.map((entry) => {
730
- const version = object(entry);
731
- return {
732
- ...version,
733
- metadata: { created_on: version.created_on }
734
- };
735
- });
736
- });
737
- if (group === "versions" && verb === "view" && third) {
738
- const called = runCf([
739
- "workers",
740
- "versions",
741
- "get",
742
- third,
743
- "--worker-id",
744
- worker
745
- ]);
746
- if (called.status !== 0) return called;
747
- const version = object(parsedJson(called.stdout));
748
- if (version.id !== third || !Array.isArray(version.bindings)) throw new Error("Worker version bindings were malformed.");
749
- const resources = await readVersionResources(worker, third);
750
- return result(0, `${JSON.stringify({
751
- ...version,
752
- resources
753
- })}\n`);
754
- }
755
- if (group === "versions" && verb === "deploy") {
756
- const firstFlag = args.findIndex((part, index) => index >= 2 && part.startsWith("-"));
757
- const versions = args.slice(2, firstFlag === -1 ? void 0 : firstFlag).map((part) => {
758
- const [version_id, fraction] = part.split("@");
759
- const percentage = Number(fraction);
760
- if (!/^[0-9a-f-]{36}$/i.test(version_id ?? "") || !Number.isFinite(percentage)) throw new Error("Cloudflare deployment version was malformed.");
761
- return {
762
- version_id,
763
- percentage
764
- };
765
- });
766
- if (!versions.length || Math.abs(versions.reduce((sum, entry) => sum + entry.percentage, 0) - 100) > .001) throw new Error("Cloudflare deployment percentages must total 100.");
767
- const message = field("--message");
768
- return runCf([
769
- "workers",
770
- "deployments",
771
- "create",
772
- "--worker",
773
- worker,
774
- "--body",
775
- JSON.stringify({
776
- strategy: "percentage",
777
- versions,
778
- ...message ? { annotations: { "workers/message": message } } : {}
779
- })
780
- ]);
781
- }
782
- return result(1, "", `Unsupported Cloudflare Worker history operation: ${group} ${verb}.`);
783
- }
784
- async function workerChanges() {
785
- if (args[0] === "queues" && args[1] === "consumer" && args[2] === "remove") {
786
- const queueName = args[3];
787
- const worker = args[4];
788
- if (!queueName || !worker) throw new Error("Queue consumer target is missing.");
789
- const queue = (await readAllQueues()).find((item) => item.queue_name === queueName);
790
- if (!queue || typeof queue.queue_id !== "string") return result(1, "", `Queue "${queueName}" does not exist`);
791
- const consumers = runCf([
792
- "queues",
793
- "consumers",
794
- "list",
795
- "--queue-id",
796
- queue.queue_id
797
- ]);
798
- if (consumers.status !== 0) return consumers;
799
- const members = parsedJson(consumers.stdout);
800
- if (!Array.isArray(members)) throw new Error("Queue consumer list was malformed.");
801
- for (const item of members.map(object).filter((entry) => entry.script === worker)) {
802
- if (typeof item.consumer_id !== "string") throw new Error("Queue consumer ID is missing.");
803
- const deleted = runCf([
804
- "queues",
805
- "consumers",
806
- "delete",
807
- item.consumer_id,
808
- "--queue-id",
809
- queue.queue_id,
810
- "--force"
811
- ]);
812
- if (deleted.status !== 0) return deleted;
813
- }
814
- return result(0);
815
- }
816
- if (args[0] === "triggers" && args[1] === "deploy") {
817
- const raw = config();
818
- const name = workerName();
819
- if (raw.name !== name) throw new Error("Cloudflare trigger Worker name changed.");
820
- return await withBuildOutput(raw, null, (directory) => runCf([
821
- "workers",
822
- "triggers",
823
- "deploy",
824
- "--prebuilt",
825
- ...args.includes("--dry-run") ? ["--dry-run"] : []
826
- ], directory));
827
- }
828
- if (args[0] === "triggers" && args[1] === "clear-crons") {
829
- const raw = config();
830
- const name = workerName();
831
- if (raw.name !== name || raw.account_id !== void 0 && raw.account_id !== accountId()) throw new Error("Cloudflare trigger target changed.");
832
- return await clearWorkerCronSchedules(name);
833
- }
834
- if (args[0] === "versions" && args[1] === "upload" || args[0] === "deploy") {
835
- const raw = config();
836
- const path = configPath();
837
- if (typeof raw.main !== "string" || !raw.main || raw.no_bundle !== true) throw new Error("Cloudflare Worker upload requires a prebuilt platform Worker.");
838
- const source = resolve(dirname(path), raw.main);
839
- const message = field("--message");
840
- const secrets = field("--secrets-file");
841
- return await withBuildOutput(raw, source, (directory) => runCf([
842
- ...args[0] === "deploy" ? ["deploy"] : [
843
- "workers",
844
- "versions",
845
- "create"
846
- ],
847
- "--prebuilt",
848
- ...message ? ["--message", message] : [],
849
- ...secrets ? ["--secrets-file", secrets] : [],
850
- ...args.includes("--dry-run") ? ["--dry-run"] : []
851
- ], directory));
852
- }
853
- return result(1, "", `Unsupported Cloudflare Worker operation: ${args.slice(0, 2).join(" ")}.`);
854
- }
855
- async function tail() {
856
- const worker = args[1];
857
- const accountId = process.env.CLOUDFLARE_ACCOUNT_ID ?? config().account_id;
858
- if (!worker || typeof accountId !== "string" || !accountId || worker !== workerName()) throw new Error("Cloudflare tail target is not pinned.");
859
- const filters = [];
860
- if (field("--search")) filters.push({ query: field("--search") });
861
- if (field("--version-id")) filters.push({ scriptVersion: field("--version-id") });
862
- if (field("--status") === "error") filters.push({ outcome: [
863
- "exception",
864
- "exceededCpu",
865
- "exceededMemory",
866
- "unknown"
867
- ] });
868
- const endpoint = `${(process.env.CLOUDFLARE_API_BASE_URL ?? "https://api.cloudflare.com/client/v4").replace(/\/$/, "")}/accounts/${encodeURIComponent(accountId)}/workers/scripts/${encodeURIComponent(worker)}/tails`;
869
- const headers = {
870
- ...await apiHeaders(),
871
- "Content-Type": "application/json"
872
- };
873
- const stopped = new AbortController();
874
- let socket;
875
- let finish;
876
- const stop = () => {
877
- stopped.abort();
878
- socket?.close();
879
- finish?.();
880
- };
881
- process.once("SIGINT", stop);
882
- process.once("SIGTERM", stop);
883
- let record;
884
- try {
885
- const created = await fetch(endpoint, {
886
- method: "POST",
887
- headers,
888
- body: JSON.stringify({ filters }),
889
- signal: AbortSignal.any([stopped.signal, AbortSignal.timeout(3e4)])
890
- });
891
- const body = object(await created.json());
892
- if (!created.ok || body.success !== true) return result(1, "", "Could not start the Cloudflare Worker tail.");
893
- record = object(body.result);
894
- if (typeof record.id !== "string" || typeof record.url !== "string") throw new Error("Cloudflare Worker tail response was incomplete.");
895
- const tailUrl = record.url;
896
- if (stopped.signal.aborted) return result(0);
897
- await new Promise((resolve, reject) => {
898
- finish = resolve;
899
- socket = new WebSocket(tailUrl, "trace-v1");
900
- socket.addEventListener("open", () => {
901
- socket.send(JSON.stringify({ debug: false }));
902
- });
903
- socket.addEventListener("message", (event) => {
904
- try {
905
- const log = object(parsedJson(String(event.data)));
906
- const detail = object(log.event ?? {});
907
- const request = object(detail.request ?? {});
908
- const prefix = typeof request.url === "string" ? `${request.method ?? "GET"} ${request.url}` : typeof detail.queue === "string" ? `Queue ${detail.queue}` : typeof detail.mailFrom === "string" ? `Email from ${detail.mailFrom}` : "Worker event";
909
- process.stdout.write(`${prefix} - ${log.outcome ?? "unknown"} @ ${new Date(Number(log.eventTimestamp)).toLocaleString()}\n`);
910
- if (Array.isArray(log.logs)) for (const line of log.logs.map(object)) process.stdout.write(` (${line.level ?? "log"}) ${Array.isArray(line.message) ? line.message.join(" ") : ""}\n`);
911
- if (Array.isArray(log.exceptions)) for (const exception of log.exceptions.map(object)) process.stderr.write(` ${exception.name ?? "Error"}: ${exception.message ?? ""}\n`);
912
- } catch {
913
- process.stderr.write("Cloudflare returned a malformed tail event.\n");
914
- }
915
- });
916
- socket.addEventListener("error", () => reject(/* @__PURE__ */ new Error("Cloudflare Worker tail connection failed.")));
917
- socket.addEventListener("close", () => resolve());
918
- if (stopped.signal.aborted) resolve();
919
- });
920
- } catch (error) {
921
- if (stopped.signal.aborted) return result(0);
922
- throw error;
923
- } finally {
924
- process.off("SIGINT", stop);
925
- process.off("SIGTERM", stop);
926
- socket?.close();
927
- if (record && typeof record.id === "string") await fetch(`${endpoint}/${encodeURIComponent(record.id)}`, {
928
- method: "DELETE",
929
- headers,
930
- signal: AbortSignal.timeout(5e3)
931
- }).catch(() => {});
932
- if (stopped.signal.aborted) process.exit(0);
933
- }
934
- return result(0);
935
- }
936
- async function main() {
937
- if ([
938
- "whoami",
939
- "login",
940
- "logout",
941
- "auth"
942
- ].includes(args[0] ?? "")) return auth();
943
- if (args[0] === "secret") return await secrets();
944
- if (args[0] === "tail") return await tail();
945
- if (args[0] === "email") return email();
946
- if (args[0] === "deployments" || args[0] === "versions" && args[1] !== "upload") return await workerHistory();
947
- if (args[0] === "triggers" || args[0] === "deploy" || args[0] === "versions" && args[1] === "upload" || args[0] === "queues" && args[1] === "consumer") return await workerChanges();
948
- if ([
949
- "d1",
950
- "kv",
951
- "r2",
952
- "hyperdrive",
953
- "queues",
954
- "containers"
955
- ].includes(args[0] ?? "")) return await resources();
956
- return result(1, "", `Unsupported Cloudflare operation: ${args.slice(0, 2).join(" ")}.`);
957
- }
958
- try {
959
- const output = await main();
960
- if (output.stdout) process.stdout.write(output.stdout);
961
- if (output.stderr) process.stderr.write(output.stderr);
962
- process.exitCode = output.status;
963
- } catch (error) {
964
- process.stderr.write(error instanceof Error ? error.message : "Cloudflare command failed.");
965
- process.exitCode = 1;
966
- }
967
- //#endregion
968
- export {};