cf 0.5.0 → 0.6.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 (247) hide show
  1. package/dist/{abuse-reports-Ina5TlsU.mjs → abuse-reports-DUs4SKVx.mjs} +2 -2
  2. package/dist/accounts-BIY8wNGA.mjs +22 -0
  3. package/dist/acm-SqcV8o5o.mjs +3 -0
  4. package/dist/addressing-CygRm0pN.mjs +12 -0
  5. package/dist/{agent-context-DMPfi54f.mjs → agent-context-CKb6w43K.mjs} +1 -1
  6. package/dist/ai-BAmEAjN3.mjs +2 -0
  7. package/dist/ai-gateway-BENwPvvB.mjs +8 -0
  8. package/dist/ai-search-Bv_Whw3E.mjs +7 -0
  9. package/dist/ai_gateway-C6WP9oBH.mjs +4 -0
  10. package/dist/alerting-D_qWrsoY.mjs +6 -0
  11. package/dist/{analytics-DSSRDZz8.mjs → analytics-CwFrx-Dr.mjs} +1 -1
  12. package/dist/analytics_engine-BjV6XLyG.mjs +2 -0
  13. package/dist/api-gateway-D9PMVVqL.mjs +33 -0
  14. package/dist/argo-DwYGbyld.mjs +2 -0
  15. package/dist/artifacts-DKAjY_n4.mjs +4 -0
  16. package/dist/{audit-logs-BuExU_nz.mjs → audit-logs-BvQ9uwuy.mjs} +1 -1
  17. package/dist/{auth-CSC4yhEJ.mjs → auth-DX9KnJ0P.mjs} +3 -3
  18. package/dist/{auth-D5hNsOFq.mjs → auth-TYwGydWg.mjs} +1 -1
  19. package/dist/billing-CRTlRU88.mjs +2 -0
  20. package/dist/bot-management-DgW--8wM.mjs +5 -0
  21. package/dist/botnet-feed-CIX6ZORT.mjs +3 -0
  22. package/dist/brand-protection-ZikBtl0y.mjs +3 -0
  23. package/dist/browser-rendering-D_ZQVWn8.mjs +4 -0
  24. package/dist/build-Bgw8TV1p.mjs +134 -0
  25. package/dist/cache-CeN5t6_W.mjs +5 -0
  26. package/dist/calls-Cv0ieVg4.mjs +4 -0
  27. package/dist/{certificate-authorities-CtqzAtxQ.mjs → certificate-authorities-BzZnWCac.mjs} +1 -1
  28. package/dist/client-certificates-BFuzeBrj.mjs +3 -0
  29. package/dist/{cloud-connector-BA5IRZUP.mjs → cloud-connector-D5h8Dzzg.mjs} +1 -1
  30. package/dist/cloudforce-one-aqDCIBMp.mjs +21 -0
  31. package/dist/{completions-DOeHPdCG.mjs → completions-Bvzav4Mj.mjs} +1 -1
  32. package/dist/connectivity-CjkXmEhO.mjs +3 -0
  33. package/dist/connector-interrupts-B7eSface.mjs +2 -0
  34. package/dist/connector-telemetry-events-F3Co8HUf.mjs +2 -0
  35. package/dist/connector-telemetry-snapshots-CQY8XMUg.mjs +2 -0
  36. package/dist/connectors-YYu_Vx3H.mjs +3 -0
  37. package/dist/content-scanning-BorfRGKT.mjs +4 -0
  38. package/dist/{context-jpewmual.mjs → context-C-WbewL6.mjs} +1 -1
  39. package/dist/custom-certificates-CfRj7QZb.mjs +5 -0
  40. package/dist/{custom-hostnames-CtuTdFcX.mjs → custom-hostnames-CcK7_17e.mjs} +4 -4
  41. package/dist/custom-nameservers-BkKx0THn.mjs +3 -0
  42. package/dist/custom-pages-DamGVA75.mjs +4 -0
  43. package/dist/d1-sK0O5THv.mjs +4 -0
  44. package/dist/data-security-DsWpoWiS.mjs +6 -0
  45. package/dist/{dcv-delegation-Bgf86J-r.mjs → dcv-delegation-BYsNl3qc.mjs} +1 -1
  46. package/dist/{deploy-dVrgDUOp.mjs → deploy-BzlPv3ro.mjs} +1 -1
  47. package/dist/{dev-C01_Lby6.mjs → dev-IOg-_s5_.mjs} +1 -1
  48. package/dist/diagnostics-CH7T2WR3.mjs +3 -0
  49. package/dist/dispatch-namespaces-Bgj9XCRx.mjs +7 -0
  50. package/dist/dist-B7hsuvbF.mjs +57 -0
  51. package/dist/dns-firewall-VmQf3UVP.mjs +57 -0
  52. package/dist/dns-o7hUPMCG.mjs +29 -0
  53. package/dist/durable-objects-DgrTbvoF.mjs +2 -0
  54. package/dist/email-routing-owCvAEpf.mjs +10 -0
  55. package/dist/email-security-Dng3DVuf.mjs +8 -0
  56. package/dist/email-sending-bExMH4lu.mjs +3 -0
  57. package/dist/filters-DKs-wEzt.mjs +4 -0
  58. package/dist/{firewall-DYZcTtIC.mjs → firewall-BLaTtX3r.mjs} +10 -10
  59. package/dist/{fraud-C03MtdZb.mjs → fraud-D8WmLKyH.mjs} +1 -1
  60. package/dist/google-tag-gateway-DyCY43k0.mjs +2 -0
  61. package/dist/healthchecks-BBtW8vRh.mjs +4 -0
  62. package/dist/hostnames-Bh2IFxIw.mjs +3 -0
  63. package/dist/hyperdrive-DJm1eD-M.mjs +18 -0
  64. package/dist/iam-apCCcy7R.mjs +6 -0
  65. package/dist/images-Cxe45OHm.mjs +7 -0
  66. package/dist/index.mjs +1 -1
  67. package/dist/intel-8V4h6H46.mjs +3 -0
  68. package/dist/{ips-nv9INuWZ.mjs → ips-BE7JbAnc.mjs} +1 -1
  69. package/dist/keyless-certificates-CfJmXccT.mjs +3 -0
  70. package/dist/kv-Dz6then8.mjs +5 -0
  71. package/dist/leaked-credential-checks-BJ-zQMlx.mjs +3 -0
  72. package/dist/load-balancers-ilsGgudX.mjs +6 -0
  73. package/dist/logpush-BH14TtuA.mjs +4 -0
  74. package/dist/logs-B8-mkf_I.mjs +3 -0
  75. package/dist/magic-cloud-networking-DylCXoG4.mjs +5 -0
  76. package/dist/magic-network-monitoring-DnyrZy77.mjs +4 -0
  77. package/dist/magic-transit-B-kU5e3s.mjs +89 -0
  78. package/dist/managed-transforms-GC9Pq5dg.mjs +3 -0
  79. package/dist/mtls-certificates-BRlhWw_G.mjs +3 -0
  80. package/dist/network-interconnects-DuyoFD9_.mjs +36 -0
  81. package/dist/oauth-B5k80sip.mjs +61 -0
  82. package/dist/observability-9APhqFHo.mjs +4 -0
  83. package/dist/{organizations-BqJHyvMK.mjs → organizations-Dy3kiV_z.mjs} +6 -6
  84. package/dist/origin-ca-certificates-2rwPoQdG.mjs +3 -0
  85. package/dist/origin-post-quantum-encryption-BnBLTvEO.mjs +2 -0
  86. package/dist/origin-tls-client-auth-B30_2_dO.mjs +4 -0
  87. package/dist/{page-rules-EZHJePmn.mjs → page-rules-zQJGmTCd.mjs} +5 -5
  88. package/dist/{page-shield-CXJioWPs.mjs → page-shield-CxQk5k9X.mjs} +5 -5
  89. package/dist/pages-5DKLs7CQ.mjs +11 -0
  90. package/dist/pipelines-DfGE44xo.mjs +6 -0
  91. package/dist/{progress-DrDErV9w.mjs → progress-CL8I-7YK.mjs} +1 -1
  92. package/dist/prompt-q3B7sM2A.mjs +3 -0
  93. package/dist/queues-BoenUGIw.mjs +6 -0
  94. package/dist/r2-Cq_JCjK0.mjs +21 -0
  95. package/dist/r2-data-catalog-eLxltWdO.mjs +14 -0
  96. package/dist/{radar-D986zPJr.mjs → radar-YNOCio6T.mjs} +1 -1
  97. package/dist/rate-limits-CcAF3tMl.mjs +5 -0
  98. package/dist/{raw-fetch-_n0lMAnD.mjs → raw-fetch-bIXC9D1m.mjs} +1 -1
  99. package/dist/realtime-kit-4bCGviO5.mjs +18 -0
  100. package/dist/{registrar-CDIwTz3G.mjs → registrar-CfHlaOOf.mjs} +6 -6
  101. package/dist/request-tracers-DlHawg5l.mjs +2 -0
  102. package/dist/resource-sharing-7FhuboJE.mjs +5 -0
  103. package/dist/resource-tagging-divcugVb.mjs +16 -0
  104. package/dist/rules-CAXkege8.mjs +4 -0
  105. package/dist/rulesets-CBsdc8IV.mjs +8 -0
  106. package/dist/rum-D0hHPNl9.mjs +4 -0
  107. package/dist/{schema-BR31o4P6.mjs → schema-D8o6HcCr.mjs} +1 -1
  108. package/dist/schema-validation-BWNDnnIT.mjs +24 -0
  109. package/dist/scim-CWLli4fi.mjs +3 -0
  110. package/dist/{secrets-store-BAK9G12O.mjs → secrets-store-B7_HkE8I.mjs} +19 -19
  111. package/dist/security-center-BQT21oiM.mjs +2 -0
  112. package/dist/security-txt-CVpmJo29.mjs +3 -0
  113. package/dist/{session-DHYCE-PM.mjs → session-B8r8LNQN.mjs} +1 -1
  114. package/dist/{build-HuS9-R0V.mjs → shared-DQI8NGja.mjs} +324 -388
  115. package/dist/smart-shield-BreBC1Ap.mjs +3 -0
  116. package/dist/snippets-BAJoWMSJ.mjs +4 -0
  117. package/dist/{spawn-CCGzKlC4.mjs → spawn-pmGERpdB.mjs} +1 -1
  118. package/dist/{spectrum-pVGxb7u5.mjs → spectrum-DnIRLY95.mjs} +6 -6
  119. package/dist/speed-UYEVue28.mjs +4 -0
  120. package/dist/{src-DU7FBCOX.mjs → src-BQ1dr9xR.mjs} +4 -4
  121. package/dist/ssl-D3Pixs8M.mjs +15 -0
  122. package/dist/stream-BUsuOfQh.mjs +14 -0
  123. package/dist/{tenants-HLGUazms.mjs → tenants-BdWJTtcg.mjs} +1 -1
  124. package/dist/token-validation-DUvtXWur.mjs +10 -0
  125. package/dist/{tools-D_hfUU_Z.mjs → tools-CQtA5-cr.mjs} +1 -1
  126. package/dist/turnstile-CAKVnS1L.mjs +23 -0
  127. package/dist/{ui-erjBdVKL.mjs → ui-BrNwNHX9.mjs} +1 -1
  128. package/dist/url-normalization-DA-RAxs4.mjs +3 -0
  129. package/dist/url-scanner-DmYu43f7.mjs +2 -0
  130. package/dist/user-Bah4wGGN.mjs +10 -0
  131. package/dist/vectorize-DhvVG2By.mjs +4 -0
  132. package/dist/{versions-CBHwWPAM.mjs → versions-NUXxCr0s.mjs} +1 -1
  133. package/dist/{waiting-rooms-u6KwrzWd.mjs → waiting-rooms-DoOkT4Mu.mjs} +6 -6
  134. package/dist/web3-n3GW50u-.mjs +4 -0
  135. package/dist/workers-D6IaQ_F0.mjs +18 -0
  136. package/dist/workers-builds-DYi0OMMU.mjs +7 -0
  137. package/dist/workflows-DrdXUQ2g.mjs +4 -0
  138. package/dist/zaraz-9l7KuLqh.mjs +2 -0
  139. package/dist/zero-trust-D6V9GH2W.mjs +118 -0
  140. package/dist/zero_trust-BzXKAX_x.mjs +3 -0
  141. package/dist/{zones-BXtdwt6E.mjs → zones-0MTkuaFk.mjs} +8 -8
  142. package/package.json +3 -1
  143. package/dist/accounts-B_joQcMi.mjs +0 -22
  144. package/dist/acm-_kIHqYME.mjs +0 -3
  145. package/dist/addressing-CaFlw8y1.mjs +0 -12
  146. package/dist/ai-CqnhNb_c.mjs +0 -2
  147. package/dist/ai-gateway-pgYGI519.mjs +0 -8
  148. package/dist/ai-search-eqQMPQol.mjs +0 -7
  149. package/dist/ai_gateway--vuVLnOm.mjs +0 -4
  150. package/dist/alerting-CPxHiYHb.mjs +0 -6
  151. package/dist/analytics_engine-gWyfnsCs.mjs +0 -2
  152. package/dist/api-gateway-BXXGFCVR.mjs +0 -33
  153. package/dist/argo-aC6A3JyX.mjs +0 -2
  154. package/dist/artifacts-HD4V2xpK.mjs +0 -4
  155. package/dist/billing-COaghyxl.mjs +0 -2
  156. package/dist/bot-management-DmEzeV1Y.mjs +0 -5
  157. package/dist/botnet-feed-ByEAXAkw.mjs +0 -3
  158. package/dist/brand-protection-dPrGe8sL.mjs +0 -3
  159. package/dist/browser-rendering-BiSGnpBf.mjs +0 -4
  160. package/dist/cache-CY-7Lt71.mjs +0 -5
  161. package/dist/calls-wOQGDWPl.mjs +0 -4
  162. package/dist/client-certificates-CRf41xLe.mjs +0 -3
  163. package/dist/cloudforce-one-Bq_qPAWs.mjs +0 -21
  164. package/dist/connectivity-Bx3MgTHX.mjs +0 -3
  165. package/dist/connector-interrupts-D7ylweJZ.mjs +0 -2
  166. package/dist/connector-telemetry-events-6izV1kbP.mjs +0 -2
  167. package/dist/connector-telemetry-snapshots-BnjKbyxX.mjs +0 -2
  168. package/dist/connectors-DRt4e6d_.mjs +0 -3
  169. package/dist/content-scanning-Cd2vy5Sz.mjs +0 -4
  170. package/dist/custom-certificates-DYE-9epx.mjs +0 -5
  171. package/dist/custom-nameservers-CWqA51in.mjs +0 -3
  172. package/dist/custom-pages-DeUKEFGe.mjs +0 -4
  173. package/dist/d1-DvWY9Gp4.mjs +0 -4
  174. package/dist/data-security-BPo6dIWu.mjs +0 -6
  175. package/dist/diagnostics-6nKPmVgz.mjs +0 -3
  176. package/dist/dispatch-namespaces-64lXx2WJ.mjs +0 -7
  177. package/dist/dist-t_YrL25p.mjs +0 -82
  178. package/dist/dns-ClciFGxx.mjs +0 -29
  179. package/dist/dns-firewall-DfUmXDCe.mjs +0 -57
  180. package/dist/durable-objects-CMaYZ-YU.mjs +0 -2
  181. package/dist/email-routing-CGXhFqF5.mjs +0 -10
  182. package/dist/email-security-D5viPq8S.mjs +0 -8
  183. package/dist/email-sending-C2jpc3gh.mjs +0 -3
  184. package/dist/filters-bzsFcWt0.mjs +0 -4
  185. package/dist/google-tag-gateway-Dfy887yA.mjs +0 -2
  186. package/dist/healthchecks-DRoAlWgr.mjs +0 -4
  187. package/dist/hostnames-CFgIVI3s.mjs +0 -3
  188. package/dist/hyperdrive-C7-gwTSV.mjs +0 -18
  189. package/dist/iam-DqVPzGrb.mjs +0 -6
  190. package/dist/images-BYfl4YgR.mjs +0 -7
  191. package/dist/intel-duTEPIHc.mjs +0 -3
  192. package/dist/keyless-certificates-CRCDVd3g.mjs +0 -3
  193. package/dist/kv-CZoV4tiv.mjs +0 -5
  194. package/dist/leaked-credential-checks-DNIBg7Pe.mjs +0 -3
  195. package/dist/load-balancers--OMg0HNt.mjs +0 -6
  196. package/dist/logpush-C0_lZTyY.mjs +0 -4
  197. package/dist/logs-BtpWZQfV.mjs +0 -3
  198. package/dist/magic-cloud-networking-u6rwYbGg.mjs +0 -5
  199. package/dist/magic-network-monitoring-CKgQyRj4.mjs +0 -4
  200. package/dist/magic-transit-CLhMcJ_-.mjs +0 -89
  201. package/dist/managed-transforms-D0Z2mlth.mjs +0 -3
  202. package/dist/mtls-certificates-BL65NK5T.mjs +0 -3
  203. package/dist/network-interconnects-Bgu9gmaG.mjs +0 -36
  204. package/dist/oauth-Bk-F-tIO.mjs +0 -52
  205. package/dist/observability-BynRbTF4.mjs +0 -4
  206. package/dist/origin-ca-certificates-BGvYwm3C.mjs +0 -3
  207. package/dist/origin-post-quantum-encryption-9KOE8YPI.mjs +0 -2
  208. package/dist/origin-tls-client-auth-d3snC3vr.mjs +0 -4
  209. package/dist/pages-D4aYteKk.mjs +0 -11
  210. package/dist/pipelines-G8Iusxq-.mjs +0 -6
  211. package/dist/queues-DEkbKqZX.mjs +0 -6
  212. package/dist/r2-CV0IkCAW.mjs +0 -21
  213. package/dist/r2-data-catalog-NtqGC_a_.mjs +0 -14
  214. package/dist/rate-limits-B2wRsUX1.mjs +0 -5
  215. package/dist/realtime-kit-Ld3c5eU6.mjs +0 -18
  216. package/dist/request-tracers-D7SFMDik.mjs +0 -2
  217. package/dist/resource-sharing-YIQ04jXE.mjs +0 -5
  218. package/dist/resource-tagging-Bd6Y03sg.mjs +0 -16
  219. package/dist/rules-DHjLP5Kx.mjs +0 -4
  220. package/dist/rulesets-q4QABpKs.mjs +0 -8
  221. package/dist/rum-SmT4HZmM.mjs +0 -4
  222. package/dist/schema-validation-vVetgC_P.mjs +0 -24
  223. package/dist/scim-ChOkZpNx.mjs +0 -3
  224. package/dist/security-center-eScuYDKP.mjs +0 -2
  225. package/dist/security-txt-x7R4gmQu.mjs +0 -3
  226. package/dist/shared-BAjo72Lz.mjs +0 -2
  227. package/dist/smart-shield-CWlSsNi8.mjs +0 -3
  228. package/dist/snippets-DrlgYJYp.mjs +0 -4
  229. package/dist/speed-ZFrMWDgd.mjs +0 -4
  230. package/dist/ssl-9JY05sYt.mjs +0 -15
  231. package/dist/stream-tRU39b8K.mjs +0 -14
  232. package/dist/token-validation-_VdamKpz.mjs +0 -10
  233. package/dist/turnstile-BRzXd28B.mjs +0 -23
  234. package/dist/url-normalization-D-NxuLtN.mjs +0 -3
  235. package/dist/url-scanner-BzzR6iDx.mjs +0 -2
  236. package/dist/user-C4omq__w.mjs +0 -10
  237. package/dist/vectorize-By6EqcNR.mjs +0 -4
  238. package/dist/web3-DQ5dmE9W.mjs +0 -4
  239. package/dist/workers-D8Be7_as.mjs +0 -18
  240. package/dist/workers-builds-BE3W3qNk.mjs +0 -7
  241. package/dist/workflows-BWWufqFA.mjs +0 -4
  242. package/dist/zaraz-Bsa9AvVL.mjs +0 -2
  243. package/dist/zero-trust-UNVZFnKu.mjs +0 -118
  244. package/dist/zero_trust-B0_Rk4p2.mjs +0 -3
  245. /package/dist/{cli-types-BeyOc81z.mjs → cli-types-DGgEbf8K.mjs} +0 -0
  246. /package/dist/{metadata-OOwvpR8m.mjs → metadata-MPDDi08e.mjs} +0 -0
  247. /package/dist/{resolve-C3h-mwp7.mjs → resolve-DGD57PFH.mjs} +0 -0
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{i as n,n as r}from"./auth-DX9KnJ0P.mjs";import{t as i}from"./output-B6fBFRqe.mjs";import{n as a,t as o}from"./progress-CL8I-7YK.mjs";import{n as s,t as c}from"./input-validation-_fMCApaH.mjs";import{t as l}from"./local-CYc9q7l2.mjs";function u(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`})}const d={command:`query`,describe:`Executes a SQL query against Workers Analytics Engine data. Pass the SQL query in the request body as plain text. The response uses newline-delimited JSON (NDJSON) by default, or a single JSON object when the query includes a FORMAT JSON clause. Prefer this method for longer queries that may exceed URL length limits.`,builder:u,handler:async u=>{if(u.dryRun){a({command:`cf analytics_engine sql query`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/analytics_engine/sql`,pathParams:{},bodyKind:`octet-stream`,body:u.body});return}let d=await r(u),f=u.local?l:await e();if(u.accountId=f,u.file){let e=c(u.file);i(await o(`Loading`,async()=>n(d,`POST`,`/accounts/${f}/analytics_engine/sql`,{body:e,headers:{"Content-Type":`text/plain`}})),{successLabel:`Loaded`});return}if(u.body){let e=s(u.body,`body`,`binary`);i(await o(`Loading`,async()=>n(d,`POST`,`/accounts/${f}/analytics_engine/sql`,{body:e,headers:{"Content-Type":`text/plain`}})),{successLabel:`Loaded`});return}i(await o(`Loading`,async()=>d.analyticsEngine.sql.query({account_id:f})),{successLabel:`Loaded`})}},f={command:`sql`,describe:`Operations for sql`,builder:e=>e.command(d).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},p={command:`analytics_engine`,describe:`analytics_engine`,builder:e=>e.command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{p as default};
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env node
2
+ import{N as e}from"./oauth-B5k80sip.mjs";import{i as t,n}from"./auth-DX9KnJ0P.mjs";import{n as r,t as i}from"./body-parser-DWSy7uZ8.mjs";import{t as a}from"./output-B6fBFRqe.mjs";import{n as o,t as s}from"./progress-CL8I-7YK.mjs";import{n as c,t as l}from"./input-validation-_fMCApaH.mjs";import{n as u,r as d,t as f}from"./prompt-q3B7sM2A.mjs";import{t as p}from"./cli-types-DGgEbf8K.mjs";function ee(e){return e.option(`normalize`,{type:`boolean`,description:`Ensures that the configuration is written or retrieved in normalized fashion`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const te={command:`get`,describe:`Gets the current API Shield configuration settings for a zone, including validation behavior and enforcement mode.`,builder:ee,handler:async t=>{let r={normalize:t.normalize};if(t.dryRun){o({command:`cf api-gateway configurations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.configurations.get({zone_id:c,...r})),{successLabel:`Loaded`})}};function m(e){return e.option(`normalize`,{type:`boolean`,description:`Ensures that the configuration is written or retrieved in normalized fashion`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const h={command:`update`,describe:`Updates API Shield configuration settings for a zone. Can modify validation strictness, enforcement mode, and other global settings.`,builder:m,handler:async t=>{let i={normalize:t.normalize};if(t.dryRun){o({command:`cf api-gateway configurations update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:i,bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let c=await n(t),l=await e({zone:t.zone},c,{quiet:t.quiet});if(t.zoneId=l,t.body){let e=r(t.body);new URLSearchParams(Object.entries(i).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Updating`,async()=>c.apiGateway.configurations.update({body:e,zone_id:l,...i})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},g={command:`configurations`,describe:`API Shield configuration — authentication requirements and session identifiers`,builder:e=>e.command(te).command(h).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function _(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`get`,describe:`Retrieve the most up to date view of discovered operations, rendered as OpenAPI schemas`,builder:_,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway discovery get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});t.zoneId=i,a(await s(`Loading`,async()=>r.apiGateway.discovery.get({zone_id:i})),{successLabel:`Loaded`})}};function y(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const b={command:`bulk-edit`,describe:"Update the `state` on one or more discovered operations",builder:y,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway discovery operations bulk-edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=r(t.body);a(await s(`Updating`,async()=>i.apiGateway.discovery.operations.bulkEdit({body:e,zone_id:c})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function x(e){return e.positional(`discovery-id`,{type:`string`,description:`Discovery ID of a discovered operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const S={command:`edit <discovery-id>`,describe:"Update the `state` on a discovered operation",builder:x,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway discovery operations edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery/operations/${t[`discovery-id`]==null?`<discovery-id>`:encodeURIComponent(String(t[`discovery-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"discovery-id":String(t[`discovery-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=r(t.body);a(await s(`Updating`,async()=>i.apiGateway.discovery.operations.edit({...e,zone_id:c,discovery_id:t[`discovery-id`]})),{successLabel:`Updated`});return}a(await s(`Updating`,async()=>i.apiGateway.discovery.operations.edit({zone_id:c,discovery_id:t[`discovery-id`]})),{successLabel:`Updated`})}};function C(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`host`,{type:`string`,description:`Filter results to only include the specified hosts.`}).option(`method`,{type:`string`,description:`Filter results to only include the specified HTTP methods.`}).option(`endpoint`,{type:`string`,description:`Filter results to only include endpoints containing this pattern.`}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`host`,`method`,`endpoint`,`traffic_stats.requests`,`traffic_stats.last_updated`]}).option(`diff`,{type:`boolean`,description:"When `true`, only return API Discovery results that are not saved into API Shield Endpoint Management"}).option(`origin`,{type:`string`,description:"Filter results to only include discovery results sourced from a particular discovery engine\n * `ML` - Discovered operations that were sourced using ML API Discovery\n * `SessionIdentifier` - Discovered operations that were sourced using Session Identifier API Discovery",choices:[`ML`,`SessionIdentifier`,`LabelDiscovery`]}).option(`state`,{type:`string`,description:"Filter results to only include discovery results in a particular state. States are as follows\n * `review` - Discovered operations that are not saved into API Shield Endpoint Management\n * `saved` - Discovered operations that are already saved into API Shield Endpoint Management\n * `ignored` - Discovered operations that have been marked as ignored",choices:[`review`,`saved`,`ignored`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const w={command:`list`,describe:`Retrieve the most up to date view of discovered operations`,builder:p(C),handler:async t=>{let r={page:t.page,per_page:t[`per-page`],host:t.host,method:t.method,endpoint:t.endpoint,direction:t.direction,order:t.order,diff:t.diff,origin:t.origin,state:t.state};if(t.dryRun){o({command:`cf api-gateway discovery operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.discovery.operations.list({zone_id:c,...r})),{successLabel:`Loaded`})}},T={command:`operations`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(b).command(S).command(w).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},E={command:`discovery`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(v).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`hosts`,{type:`string`,array:!0,description:`List of hosts to be targeted in the expression`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const O={command:`create`,describe:`Creates an expression template fallthrough rule for API Shield. Used for configuring default behavior when no other expression templates match.`,builder:D,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway expression-template fallthrough create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/expression-template/fallthrough`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({hosts:t.hosts}):r(t.body)});return}let c=await n(t),l=await e({zone:t.zone},c,{quiet:t.quiet});if(t.zoneId=l,t.body){let e=r(t.body);a(await s(`Creating`,async()=>c.apiGateway.expressionTemplate.fallthrough.create({...e,zone_id:l})),{successLabel:`Created`});return}if(t.hosts===void 0)throw Error(`--hosts is required (or pass --body with this field set).`);let u=i({hosts:t.hosts});a(await s(`Creating`,async()=>c.apiGateway.expressionTemplate.fallthrough.create({...u,zone_id:l})),{successLabel:`Created`})}},k={command:`fallthrough`,describe:`Reusable expression templates for API Gateway rule configurations`,builder:e=>e.command(O).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},A={command:`expression-template`,describe:`Operations for expression-template`,builder:e=>e.command(k).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function j(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`name`,`description`,`created_at`,`last_updated`,`mapped_resources.operations`]}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`source`,{type:`string`,description:`Filter for labels with source`,choices:[`user`,`managed`]}).option(`filter`,{type:`string`,description:`Filter for labels where the name or description matches using substring match`}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`list`,describe:`Retrieve all labels`,builder:p(j),handler:async t=>{let r={page:t.page,per_page:t[`per-page`],order:t.order,direction:t.direction,source:t.source,filter:t.filter,with_mapped_resource_counts:t[`with-mapped-resource-counts`]};if(t.dryRun){o({command:`cf api-gateway labels list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.labels.list({zone_id:c,...r})),{successLabel:`Loaded`})}};function N(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`get <name>`,describe:`Retrieve managed label`,builder:N,handler:async t=>{let r={with_mapped_resource_counts:t[`with-mapped-resource-counts`]};if(t.dryRun){o({command:`cf api-gateway labels managed get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/managed/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.labels.managed.get({zone_id:c,name:t.name,...r})),{successLabel:`Loaded`})}};function F(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const I={command:`update <name>`,describe:`Replace all operations(s) attached to a managed label`,builder:F,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway labels managed resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/managed/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/resources/operation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=r(t.body);a(await s(`Updating`,async()=>i.apiGateway.labels.managed.resources.operation.update({body:e,zone_id:c,name:t.name})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},L={command:`operation`,describe:`Labels operations`,builder:e=>e.command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},R={command:`resources`,describe:`Operations for labels.managed.resources`,builder:e=>e.command(L).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},z={command:`managed`,describe:`Labels operations`,builder:e=>e.command(P).command(R).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function B(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const V={command:`bulk-create`,describe:`Create user labels`,builder:B,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway labels user bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=r(t.body);a(await s(`Creating`,async()=>i.apiGateway.labels.user.bulkCreate({body:e,zone_id:c})),{successLabel:`Created`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function H(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const U={command:`bulk-delete`,describe:`Delete user labels`,builder:H,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway labels user bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});if(t.zoneId=c,!await f({force:!!t.force})){process.stderr.write(`Aborted.
3
+ `);return}if(t.body){let e=r(t.body);a(await s(`Deleting`,async()=>i.apiGateway.labels.user.bulkDelete({body:e,zone_id:c})),{successLabel:`Deleted`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function W(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const G={command:`delete <name>`,describe:`Delete user label`,builder:W,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway labels user delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});if(t.zoneId=i,!await f({force:!!t.force})){process.stderr.write(`Aborted.
4
+ `);return}a(await s(`Deleting`,async()=>r.apiGateway.labels.user.delete({zone_id:i,name:t.name})),{successLabel:`Deleted`})}};function K(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`description`,{type:`string`,description:`The description of the label`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const q={command:`edit <name>`,describe:`Update certain fields on a label`,builder:K,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway labels user edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?i({description:c(t.description,`description`,`text`)}):r(t.body)});return}let l=await n(t),u=await e({zone:t.zone},l,{quiet:t.quiet});if(t.zoneId=u,t.body){let e=r(t.body);a(await s(`Updating`,async()=>l.apiGateway.labels.user.edit({...e,zone_id:u,name:t.name})),{successLabel:`Updated`});return}let d=i({description:c(t.description,`description`,`text`)});a(await s(`Updating`,async()=>l.apiGateway.labels.user.edit({...d,zone_id:u,name:t.name})),{successLabel:`Updated`})}};function J(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Y={command:`get <name>`,describe:`Retrieve user label`,builder:J,handler:async t=>{let r={with_mapped_resource_counts:t[`with-mapped-resource-counts`]};if(t.dryRun){o({command:`cf api-gateway labels user get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.labels.user.get({zone_id:c,name:t.name,...r})),{successLabel:`Loaded`})}};function X(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Z={command:`update <name>`,describe:`Replace all operations(s) attached to a user label`,builder:X,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway labels user resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/resources/operation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=r(t.body);a(await s(`Updating`,async()=>i.apiGateway.labels.user.resources.operation.update({body:e,zone_id:c,name:t.name})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Q={command:`operation`,describe:`Labels operations`,builder:e=>e.command(Z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ne={command:`resources`,describe:`Operations for labels.user.resources`,builder:e=>e.command(Q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function re(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`description`,{type:`string`,description:`The description of the label`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ie={command:`update <name>`,describe:`Update all fields on a label`,builder:re,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway labels user update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?i({description:c(t.description,`description`,`text`)}):r(t.body)});return}let l=await n(t),u=await e({zone:t.zone},l,{quiet:t.quiet});if(t.zoneId=u,t.body){let e=r(t.body);a(await s(`Updating`,async()=>l.apiGateway.labels.user.update({...e,zone_id:u,name:t.name})),{successLabel:`Updated`});return}let d=i({description:c(t.description,`description`,`text`)});a(await s(`Updating`,async()=>l.apiGateway.labels.user.update({...d,zone_id:u,name:t.name})),{successLabel:`Updated`})}},ae={command:`user`,describe:`Labels operations`,builder:e=>e.command(V).command(U).command(G).command(q).command(Y).command(ie).command(ne).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},oe={command:`labels`,describe:`Labels operations`,builder:e=>e.command(M).command(z).command(ae).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function se(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ce={command:`bulk-create`,describe:`Add one or more operations to a zone. Endpoints can contain path variables. Host, method, endpoint will be normalized to a canoncial form when creating an operation and must be unique on the zone. Inserting an operation that matches an existing one will return the record of the already existing operation and update its last_updated date.`,builder:se,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=r(t.body);a(await s(`Creating`,async()=>i.apiGateway.operations.bulkCreate({body:e,zone_id:c})),{successLabel:`Created`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function le(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ue={command:`bulk-delete`,describe:`Bulk removes multiple API operations from API Shield endpoint management in a single request. Efficient for cleaning up unused endpoints.`,builder:le,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});if(t.zoneId=c,!await f({force:!!t.force})){process.stderr.write(`Aborted.
5
+ `);return}if(t.body){let e=r(t.body);a(await s(`Deleting`,async()=>i.apiGateway.operations.bulkDelete({body:e,zone_id:c})),{successLabel:`Deleted`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function de(e){return e.option(`endpoint`,{type:`string`,description:`The endpoint which can contain path parameter templates in curly braces, each will be replaced from left to right with {varN}, starting with {var1}, during insertion. This will further be Cloudflare-normalized upon insertion. See: https://developers.cloudflare.com/rules/normalization/how-it-works/.`}).option(`host`,{type:`string`,description:`RFC3986-compliant host.`}).option(`method`,{type:`string`,description:`The HTTP method used to access the endpoint.`,choices:[`GET`,`POST`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`CONNECT`,`PATCH`,`TRACE`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const fe={command:`create`,describe:`Add one operation to a zone. Endpoints can contain path variables. Host, method, endpoint will be normalized to a canoncial form when creating an operation and must be unique on the zone. Inserting an operation that matches an existing one will return the record of the already existing operation and update its last_updated date.`,builder:de,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/item`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({endpoint:c(t.endpoint,`endpoint`,`text`),host:c(t.host,`host`,`text`),method:c(t.method,`method`,`text`)}):r(t.body)});return}let l=await n(t),f=await e({zone:t.zone},l,{quiet:t.quiet});if(t.zoneId=f,t.body){let e=r(t.body);a(await s(`Creating`,async()=>l.apiGateway.operations.create({body:e,zone_id:f})),{successLabel:`Created`});return}t.endpoint===void 0&&(t.endpoint=await d(`endpoint`,`The endpoint which can contain path parameter templates in curly braces, each will be replaced from left to right with {varN}, starting with {var1}, during insertion. This will further be Cloudflare-normalized upon insertion. See: https://developers.cloudflare.com/rules/normalization/how-it-works/.`)),t.host===void 0&&(t.host=await d(`host`,`RFC3986-compliant host.`)),t.method===void 0&&(t.method=await u(`method`,`The HTTP method used to access the endpoint.`,[`GET`,`POST`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`CONNECT`,`PATCH`,`TRACE`]));let p=i({endpoint:c(t.endpoint,`endpoint`,`text`),host:c(t.host,`host`,`text`),method:c(t.method,`method`,`text`)});a(await s(`Creating`,async()=>l.apiGateway.operations.create({body:p,zone_id:f})),{successLabel:`Created`})}};function pe(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const me={command:`delete <operation-id>`,describe:`Removes a single API operation from API Shield endpoint management. The operation will no longer be tracked or protected by API Shield rules.`,builder:pe,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});if(t.zoneId=i,!await f({force:!!t.force})){process.stderr.write(`Aborted.
6
+ `);return}a(await s(`Deleting`,async()=>r.apiGateway.operations.delete({zone_id:i,operation_id:t[`operation-id`]})),{successLabel:`Deleted`})}};function he(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`feature`,{type:`string`,description:`Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description for more details on the specific meaning.`}).option(`with-schemas`,{type:`boolean`,description:`When true, includes OpenAPI schemas (both uploaded and learned) for the operation in the response. Due to the conversion overhead, this parameter is only supported on single-operation retrieval.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ge={command:`get <operation-id>`,describe:`Gets detailed information about a specific API operation in API Shield, including its schema validation settings and traffic statistics.`,builder:p(he),handler:async t=>{let r={feature:t.feature,with_schemas:t[`with-schemas`]};if(t.dryRun){o({command:`cf api-gateway operations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.operations.get({zone_id:c,operation_id:t[`operation-id`],...r})),{successLabel:`Loaded`})}};function _e(e){return e.option(`managed-labels`,{type:`string`,array:!0,description:`List of managed label names.`}).option(`user-labels`,{type:`string`,array:!0,description:`List of user label names.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ve={command:`bulk-create`,describe:`Bulk attach label(s) on operation(s) in endpoint management`,builder:_e,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations labels bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/labels`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({managed:{labels:t[`managed-labels`]},user:{labels:t[`user-labels`]}}):r(t.body)});return}let c=await n(t),l=await e({zone:t.zone},c,{quiet:t.quiet});if(t.zoneId=l,t.body){let e=r(t.body);a(await s(`Creating`,async()=>c.apiGateway.operations.labels.bulkCreate({...e,zone_id:l})),{successLabel:`Created`});return}let u=i({managed:{labels:t[`managed-labels`]},user:{labels:t[`user-labels`]}});a(await s(`Creating`,async()=>c.apiGateway.operations.labels.bulkCreate({...u,zone_id:l})),{successLabel:`Created`})}};function ye(e){return e.option(`managed-labels`,{type:`string`,array:!0,description:`List of managed label names.`}).option(`user-labels`,{type:`string`,array:!0,description:`List of user label names.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const be={command:`bulk-delete`,describe:`Bulk remove label(s) on operation(s) in endpoint management`,builder:ye,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations labels bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/labels`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({managed:{labels:t[`managed-labels`]},user:{labels:t[`user-labels`]}}):r(t.body)});return}let c=await n(t),l=await e({zone:t.zone},c,{quiet:t.quiet});if(t.zoneId=l,!await f({force:!!t.force})){process.stderr.write(`Aborted.
7
+ `);return}if(t.body){let e=r(t.body);a(await s(`Deleting`,async()=>c.apiGateway.operations.labels.bulkDelete({...e,zone_id:l})),{successLabel:`Deleted`});return}let u=i({managed:{labels:t[`managed-labels`]},user:{labels:t[`user-labels`]}});a(await s(`Deleting`,async()=>c.apiGateway.operations.labels.bulkDelete({...u,zone_id:l})),{successLabel:`Deleted`})}};function xe(e){return e.option(`managed-labels`,{type:`string`,array:!0,description:`List of managed label names. Providing an empty array will result in all managed labels being removed from all affected operations`}).option(`user-labels`,{type:`string`,array:!0,description:`List of user label names. Providing an empty array will result in all user labels being removed from all affected operations`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Se={command:`bulk-update`,describe:`Bulk replace label(s) on operation(s) in endpoint management`,builder:xe,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations labels bulk-update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/labels`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({managed:{labels:t[`managed-labels`]},user:{labels:t[`user-labels`]}}):r(t.body)});return}let c=await n(t),l=await e({zone:t.zone},c,{quiet:t.quiet});if(t.zoneId=l,t.body){let e=r(t.body);a(await s(`Updating`,async()=>c.apiGateway.operations.labels.bulkUpdate({...e,zone_id:l})),{successLabel:`Updated`});return}if(t[`managed-labels`]===void 0)throw Error(`--managed-labels is required (or pass --body with this field set).`);if(t[`user-labels`]===void 0)throw Error(`--user-labels is required (or pass --body with this field set).`);let u=i({managed:{labels:t[`managed-labels`]},user:{labels:t[`user-labels`]}});a(await s(`Updating`,async()=>c.apiGateway.operations.labels.bulkUpdate({...u,zone_id:l})),{successLabel:`Updated`})}};function Ce(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`managed`,{type:`string`,array:!0,description:`List of managed label names.`}).option(`user`,{type:`string`,array:!0,description:`List of user label names.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const we={command:`create <operation-id>`,describe:`Attach label(s) on an operation in endpoint management`,builder:Ce,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations labels create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}/labels`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({managed:t.managed,user:t.user}):r(t.body)});return}let c=await n(t),l=await e({zone:t.zone},c,{quiet:t.quiet});if(t.zoneId=l,t.body){let e=r(t.body);a(await s(`Creating`,async()=>c.apiGateway.operations.labels.create({...e,zone_id:l,operation_id:t[`operation-id`]})),{successLabel:`Created`});return}let u=i({managed:t.managed,user:t.user});a(await s(`Creating`,async()=>c.apiGateway.operations.labels.create({...u,zone_id:l,operation_id:t[`operation-id`]})),{successLabel:`Created`})}};function Te(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`managed`,{type:`string`,array:!0,description:`List of managed label names.`}).option(`user`,{type:`string`,array:!0,description:`List of user label names.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Ee={command:`delete <operation-id>`,describe:`Remove label(s) on an operation in endpoint management`,builder:Te,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations labels delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}/labels`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({managed:t.managed,user:t.user}):r(t.body)});return}let c=await n(t),l=await e({zone:t.zone},c,{quiet:t.quiet});if(t.zoneId=l,!await f({force:!!t.force})){process.stderr.write(`Aborted.
8
+ `);return}if(t.body){let e=r(t.body);a(await s(`Deleting`,async()=>c.apiGateway.operations.labels.delete({...e,zone_id:l,operation_id:t[`operation-id`]})),{successLabel:`Deleted`});return}let u=i({managed:t.managed,user:t.user});a(await s(`Deleting`,async()=>c.apiGateway.operations.labels.delete({...u,zone_id:l,operation_id:t[`operation-id`]})),{successLabel:`Deleted`})}};function De(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`managed`,{type:`string`,array:!0,description:`List of managed label names. Omitting this property or passing an empty array will result in all managed labels being removed from the operation`}).option(`user`,{type:`string`,array:!0,description:`List of user label names. Omitting this property or passing an empty array will result in all user labels being removed from the operation`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Oe={command:`update <operation-id>`,describe:`Replace label(s) on an operation in endpoint management`,builder:De,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations labels update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}/labels`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({managed:t.managed,user:t.user}):r(t.body)});return}let c=await n(t),l=await e({zone:t.zone},c,{quiet:t.quiet});if(t.zoneId=l,t.body){let e=r(t.body);a(await s(`Updating`,async()=>c.apiGateway.operations.labels.update({...e,zone_id:l,operation_id:t[`operation-id`]})),{successLabel:`Updated`});return}let u=i({managed:t.managed,user:t.user});a(await s(`Updating`,async()=>c.apiGateway.operations.labels.update({...u,zone_id:l,operation_id:t[`operation-id`]})),{successLabel:`Updated`})}},ke={command:`labels`,describe:`Manage labels on API Shield operations for classification and policy enforcement`,builder:e=>e.command(ve).command(be).command(Se).command(we).command(Ee).command(Oe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ae(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`order`,{type:`string`,description:"Field to order by. When requesting a feature, the feature keys are available for ordering as well, e.g., `thresholds.suggested_threshold`.",choices:[`method`,`host`,`endpoint`,`thresholds.$key`]}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`host`,{type:`string`,description:`Filter results to only include the specified hosts.`}).option(`method`,{type:`string`,description:`Filter results to only include the specified HTTP methods.`}).option(`endpoint`,{type:`string`,description:`Filter results to only include endpoints containing this pattern.`}).option(`feature`,{type:`string`,description:`Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description for more details on the specific meaning.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const je={command:`list`,describe:`Lists all API operations tracked by API Shield for a zone with pagination. Returns operation details including method, path, and feature configurations.`,builder:p(Ae),handler:async t=>{let r={page:t.page,per_page:t[`per-page`],order:t.order,direction:t.direction,host:t.host,method:t.method,endpoint:t.endpoint,feature:t.feature};if(t.dryRun){o({command:`cf api-gateway operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.operations.list({zone_id:c,...r})),{successLabel:`Loaded`})}};function Me(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Ne={command:`edit`,describe:`Updates multiple operation-level schema validation settings on the zone`,builder:Me,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations schema-validation edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/schema_validation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=r(t.body);a(await s(`Updating`,async()=>i.apiGateway.operations.schemaValidation.edit({body:e,zone_id:c})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function Pe(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Fe={command:`get <operation-id>`,describe:`Retrieves operation-level schema validation settings on the zone`,builder:Pe,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations schema-validation get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}/schema_validation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});t.zoneId=i,a(await s(`Loading`,async()=>r.apiGateway.operations.schemaValidation.get({zone_id:i,operation_id:t[`operation-id`]})),{successLabel:`Loaded`})}};function Ie(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`mitigation-action`,{type:`string`,description:"When set, this applies a mitigation action to this operation\n\n - `log` log request when request does not conform to schema for this operation\n - `block` deny access to the site when request does not conform to schema for this operation\n - `none` will skip mitigation for this operation\n - `null` indicates that no operation level mitigation is in place, see Zone Level Schema Validation Settings for mitigation action that will be applied\n",choices:[`log`,`block`,`none`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Le={command:`update <operation-id>`,describe:`Updates operation-level schema validation settings on the zone`,builder:Ie,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway operations schema-validation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}/schema_validation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({mitigation_action:c(t[`mitigation-action`],`mitigation-action`,`text`)}):r(t.body)});return}let l=await n(t),u=await e({zone:t.zone},l,{quiet:t.quiet});if(t.zoneId=u,t.body){let e=r(t.body);a(await s(`Updating`,async()=>l.apiGateway.operations.schemaValidation.update({...e,zone_id:u,operation_id:t[`operation-id`]})),{successLabel:`Updated`});return}let d=i({mitigation_action:c(t[`mitigation-action`],`mitigation-action`,`text`)});a(await s(`Updating`,async()=>l.apiGateway.operations.schemaValidation.update({...d,zone_id:u,operation_id:t[`operation-id`]})),{successLabel:`Updated`})}},Re={command:`schema-validation`,describe:`Registered API operations (method + path) with traffic metrics and schema bindings`,builder:e=>e.command(Ne).command(Fe).command(Le).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ze={command:`operations`,describe:`Registered API operations (method + path) with traffic metrics and schema bindings`,builder:e=>e.command(ce).command(ue).command(fe).command(me).command(ge).command(je).command(ke).command(Re).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Be(e){return e.option(`host`,{type:`string`,description:`Receive schema only for the given host(s).`}).option(`feature`,{type:`string`,description:`Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description for more details on the specific meaning.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ve={command:`list`,describe:`Retrieves API operations and their features exported as OpenAPI schemas.`,builder:p(Be),handler:async t=>{let r={host:t.host,feature:t.feature};if(t.dryRun){o({command:`cf api-gateway schemas list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/schemas`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.schemas.list({zone_id:c,...r})),{successLabel:`Loaded`})}},He={command:`schemas`,describe:`OpenAPI schemas learned from traffic for API endpoint validation`,builder:e=>e.command(Ve).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ue(e){return e.option(`validation-default-mitigation-action`,{type:`string`,description:`The default mitigation action used when there is no mitigation action defined on the operation
9
+ Mitigation actions are as follows:
10
+
11
+ * \`log\` - log request when request does not conform to schema
12
+ * \`block\` - deny access to the site when request does not conform to schema
13
+
14
+ A special value of of \`none\` will skip running schema validation entirely for the request when there is no mitigation action defined on the operation
15
+
16
+ \`null\` will have no effect.
17
+ `,choices:[`none`,`log`,`block`]}).option(`validation-override-mitigation-action`,{type:`string`,description:`When set, this overrides both zone level and operation level mitigation actions.
18
+
19
+ - \`none\` will skip running schema validation entirely for the request
20
+
21
+ To clear any override, use the special value \`disable_override\`
22
+
23
+ \`null\` will have no effect.
24
+ `,choices:[`none`,`disable_override`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const We={command:`edit`,describe:`Updates zone level schema validation settings on the zone`,builder:Ue,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway settings schema-validation edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/settings/schema_validation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({validation_default_mitigation_action:c(t[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:c(t[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)}):r(t.body)});return}let l=await n(t),u=await e({zone:t.zone},l,{quiet:t.quiet});if(t.zoneId=u,t.body){let e=r(t.body);a(await s(`Updating`,async()=>l.apiGateway.settings.schemaValidation.edit({...e,zone_id:u})),{successLabel:`Updated`});return}let d=i({validation_default_mitigation_action:c(t[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:c(t[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)});a(await s(`Updating`,async()=>l.apiGateway.settings.schemaValidation.edit({...d,zone_id:u})),{successLabel:`Updated`})}};function Ge(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ke={command:`get`,describe:`Retrieves zone level schema validation settings currently set on the zone`,builder:Ge,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway settings schema-validation get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/settings/schema_validation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});t.zoneId=i,a(await s(`Loading`,async()=>r.apiGateway.settings.schemaValidation.get({zone_id:i})),{successLabel:`Loaded`})}};function qe(e){return e.option(`validation-default-mitigation-action`,{type:`string`,description:`The default mitigation action used when there is no mitigation action defined on the operation
25
+
26
+ Mitigation actions are as follows:
27
+
28
+ * \`log\` - log request when request does not conform to schema
29
+ * \`block\` - deny access to the site when request does not conform to schema
30
+
31
+ A special value of of \`none\` will skip running schema validation entirely for the request when there is no mitigation action defined on the operation
32
+ `,choices:[`none`,`log`,`block`]}).option(`validation-override-mitigation-action`,{type:`string`,description:"When set, this overrides both zone level and operation level mitigation actions.\n\n - `none` will skip running schema validation entirely for the request\n - `null` indicates that no override is in place\n\nTo clear any override, use the special value `disable_override` or `null`\n",choices:[`none`,`disable_override`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Je={command:`update`,describe:`Updates zone level schema validation settings on the zone`,builder:qe,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway settings schema-validation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/settings/schema_validation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({validation_default_mitigation_action:c(t[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:c(t[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)}):r(t.body)});return}let l=await n(t),d=await e({zone:t.zone},l,{quiet:t.quiet});if(t.zoneId=d,t.body){let e=r(t.body);a(await s(`Updating`,async()=>l.apiGateway.settings.schemaValidation.update({...e,zone_id:d})),{successLabel:`Updated`});return}t[`validation-default-mitigation-action`]===void 0&&(t[`validation-default-mitigation-action`]=await u(`validation-default-mitigation-action`,"The default mitigation action used when there is no mitigation action defined on the operation Mitigation actions are as follows: * `log` - log request when request does not conform to schema * `block` - deny access to the site when request does not conform to schema A special value of of `none` will skip running schema validation entirely for the request when there is no mitigation action defined on the operation ",[`none`,`log`,`block`]));let f=i({validation_default_mitigation_action:c(t[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:c(t[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)});a(await s(`Updating`,async()=>l.apiGateway.settings.schemaValidation.update({...f,zone_id:d})),{successLabel:`Updated`})}},Ye={command:`schema-validation`,describe:`Zone-level API Gateway settings including schema validation behavior`,builder:e=>e.command(We).command(Ke).command(Je).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Xe={command:`settings`,describe:`Operations for settings`,builder:e=>e.command(Ye).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ze(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}).option(`kind`,{type:`string`,description:`Kind of schema`}).option(`name`,{type:`string`,description:`Name of the schema`}).option(`validation-enabled`,{type:`string`,description:`Flag whether schema is enabled for validation.`})}const Qe={command:`create`,describe:`Uploads a new OpenAPI schema for API Shield schema validation. The schema defines expected request/response formats for API endpoints.`,builder:Ze,handler:async r=>{if(r.dryRun){o({command:`cf api-gateway user-schemas create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${r.zone??r.zoneId??`<zone>`}/api_gateway/user_schemas`,pathParams:{"zone-id":String(r.zone??r[`zone-id`]??``)},bodyKind:`multipart`,body:{body:r.body,file:r.file,kind:r.kind,name:r.name,"validation-enabled":r[`validation-enabled`]}});return}let i=await n(r);if(r.zoneId=await e({zone:r.zone},i,{quiet:r.quiet}),r.file!==void 0||r.body!==void 0||r.kind!==void 0||r.name!==void 0||r[`validation-enabled`]!==void 0){let e=new FormData;if(r.file){let t=l(r.file);e.append(`file`,new Blob([t]),r.file.split(/[\\/]/).filter(Boolean).pop())}else r.body!==void 0&&e.append(`file`,r.body);r.kind!==void 0&&e.append(`kind`,String(c(r.kind,`kind`,`text`)??``)),r.name!==void 0&&e.append(`name`,String(c(r.name,`name`,`text`)??``)),r[`validation-enabled`]!==void 0&&e.append(`validation_enabled`,String(c(r[`validation-enabled`],`validation-enabled`,`text`)??``)),a(await s(`Creating`,async()=>t(i,`POST`,`/zones/${r.zoneId}/api_gateway/user_schemas`,{body:e})),{successLabel:`Created`});return}if(r.body){let e=c(r.body,`body`,`binary`);a(await s(`Creating`,async()=>t(i,`POST`,`/zones/${r.zoneId}/api_gateway/user_schemas`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(r.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function $e(e){return e.positional(`schema-id`,{type:`string`,description:`Identifier for the schema-ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const et={command:`delete <schema-id>`,describe:`Permanently removes an uploaded OpenAPI schema from API Shield schema validation. Operations using this schema will lose their validation rules.`,builder:$e,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway user-schemas delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/user_schemas/${t[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(t[`schema-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"schema-id":String(t[`schema-id`]??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});if(t.zoneId=i,!await f({force:!!t.force})){process.stderr.write(`Aborted.
33
+ `);return}a(await s(`Deleting`,async()=>r.apiGateway.userSchemas.delete({zone_id:i,schema_id:t[`schema-id`]})),{successLabel:`Deleted`})}};function tt(e){return e.positional(`schema-id`,{type:`string`,description:`Identifier for the schema-ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const $={command:`edit <schema-id>`,describe:`Activates schema validation for an uploaded OpenAPI schema. Requests to matching endpoints will be validated against the schema definitions.`,builder:tt,handler:async t=>{if(t.dryRun){o({command:`cf api-gateway user-schemas edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/user_schemas/${t[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(t[`schema-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"schema-id":String(t[`schema-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:r(t.body)});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=r(t.body);a(await s(`Updating`,async()=>i.apiGateway.userSchemas.edit({...e,zone_id:c,schema_id:t[`schema-id`]})),{successLabel:`Updated`});return}a(await s(`Updating`,async()=>i.apiGateway.userSchemas.edit({zone_id:c,schema_id:t[`schema-id`]})),{successLabel:`Updated`})}};function nt(e){return e.positional(`schema-id`,{type:`string`,description:`Identifier for the schema-ID`,demandOption:!0}).option(`omit-source`,{type:`boolean`,description:`Omit the source-files of schemas and only retrieve their meta-data.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const rt={command:`get <schema-id>`,describe:`Gets detailed information about a specific uploaded OpenAPI schema, including its contents and validation configuration.`,builder:nt,handler:async t=>{let r={omit_source:t[`omit-source`]};if(t.dryRun){o({command:`cf api-gateway user-schemas get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/user_schemas/${t[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(t[`schema-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"schema-id":String(t[`schema-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.userSchemas.get({zone_id:c,schema_id:t[`schema-id`],...r})),{successLabel:`Loaded`})}};function it(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const at={command:`list`,describe:`Lists all unique hosts found in uploaded OpenAPI schemas for the zone. Useful for understanding which domains have schema coverage.`,builder:it,handler:async t=>{let r={page:t.page,per_page:t[`per-page`]};if(t.dryRun){o({command:`cf api-gateway user-schemas hosts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/user_schemas/hosts`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.userSchemas.hosts.list({zone_id:c,...r})),{successLabel:`Loaded`})}},ot={command:`hosts`,describe:`User-uploaded OpenAPI schemas for validating API request and response payloads`,builder:e=>e.command(at).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function st(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`omit-source`,{type:`boolean`,description:`Omit the source-files of schemas and only retrieve their meta-data.`}).option(`validation-enabled`,{type:`boolean`,description:`Flag whether schema is enabled for validation.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ct={command:`list`,describe:`Lists all OpenAPI schemas uploaded to API Shield for the zone, including their validation status and associated operations.`,builder:st,handler:async t=>{let r={page:t.page,per_page:t[`per-page`],omit_source:t[`omit-source`],validation_enabled:t[`validation-enabled`]};if(t.dryRun){o({command:`cf api-gateway user-schemas list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/user_schemas`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.userSchemas.list({zone_id:c,...r})),{successLabel:`Loaded`})}};function lt(e){return e.option(`schema-id`,{type:`string`,description:`Identifier for the schema-ID`,demandOption:!0}).option(`feature`,{type:`string`,description:`Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description for more details on the specific meaning.`}).option(`host`,{type:`string`,description:`Filter results to only include the specified hosts.`}).option(`method`,{type:`string`,description:`Filter results to only include the specified HTTP methods.`}).option(`endpoint`,{type:`string`,description:`Filter results to only include endpoints containing this pattern.`}).option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`operation-status`,{type:`string`,description:"Filter results by whether operations exist in API Shield Endpoint Management or not. `new` will just return operations from the schema that do not exist in API Shield Endpoint Management. `existing` will just return operations from the schema that already exist in API Shield Endpoint Management.",choices:[`new`,`existing`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ut={command:`list`,describe:`Retrieves all operations from the schema. Operations that already exist in API Shield Endpoint Management will be returned as full operations.`,builder:p(lt),handler:async t=>{let r={feature:t.feature,host:t.host,method:t.method,endpoint:t.endpoint,page:t.page,per_page:t[`per-page`],operation_status:t[`operation-status`]};if(t.dryRun){o({command:`cf api-gateway user-schemas operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/user_schemas/${t[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(t[`schema-id`]))}/operations`,pathParams:{"schema-id":String(t[`schema-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.apiGateway.userSchemas.operations.list({zone_id:c,schema_id:t[`schema-id`],...r})),{successLabel:`Loaded`})}},dt={command:`operations`,describe:`User-uploaded OpenAPI schemas for validating API request and response payloads`,builder:e=>e.command(ut).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ft={command:`user-schemas`,describe:`User-uploaded OpenAPI schemas for validating API request and response payloads`,builder:e=>e.command(Qe).command(et).command($).command(rt).command(ct).command(ot).command(dt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},pt={command:`api-gateway`,describe:`Discover, monitor, and protect your API endpoints with schema validation, abuse detection, and routing`,builder:e=>e.command(g).command(E).command(A).command(oe).command(ze).command(He).command(Xe).command(ft).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{pt as default};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{N as e}from"./oauth-B5k80sip.mjs";import{n as t}from"./auth-DX9KnJ0P.mjs";import{n,t as r}from"./body-parser-DWSy7uZ8.mjs";import{t as i}from"./output-B6fBFRqe.mjs";import{n as a,t as o}from"./progress-CL8I-7YK.mjs";import{n as s}from"./input-validation-_fMCApaH.mjs";import{n as c}from"./prompt-q3B7sM2A.mjs";function l(e){return e.option(`value`,{type:`string`,description:`Specifies the enablement value of Argo Smart Routing.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Configures the enablement of Argo Smart Routing.`})}const u={command:`edit`,describe:`Configures the value of the Argo Smart Routing enablement setting.`,builder:l,handler:async l=>{if(l.dryRun){a({command:`cf argo smart-routing edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${l.zone??l.zoneId??`<zone>`}/argo/smart_routing`,pathParams:{"zone-id":String(l.zone??l[`zone-id`]??``)},bodyKind:`json`,body:l.body===void 0?r({value:s(l.value,`value`,`text`)}):n(l.body)});return}let u=await t(l),d=await e({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,l.body){let e=n(l.body);i(await o(`Updating`,async()=>u.argo.smartRouting.edit({...e,zone_id:d})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await c(`value`,`Specifies the enablement value of Argo Smart Routing.`,[`on`,`off`]));let f=r({value:s(l.value,`value`,`text`)});i(await o(`Updating`,async()=>u.argo.smartRouting.edit({...f,zone_id:d})),{successLabel:`Updated`})}};function d(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const f={command:`get`,describe:`Retrieves the value of Argo Smart Routing enablement setting.`,builder:d,handler:async n=>{if(n.dryRun){a({command:`cf argo smart-routing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${n.zone??n.zoneId??`<zone>`}/argo/smart_routing`,pathParams:{"zone-id":String(n.zone??n[`zone-id`]??``)},bodyKind:`none`});return}let r=await t(n),s=await e({zone:n.zone},r,{quiet:n.quiet});n.zoneId=s,i(await o(`Loading`,async()=>r.argo.smartRouting.get({zone_id:s})),{successLabel:`Loaded`})}},p={command:`smart-routing`,describe:`Route traffic through the fastest network paths to your origin using real-time latency data`,builder:e=>e.command(u).command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function m(e){return e.option(`value`,{type:`string`,description:`Enables Tiered Caching.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Update enablement of Tiered Caching.`})}const h={command:`edit`,describe:`Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of lower-tiers and upper-tiers. If content is not cached in lower-tier data centers (generally the ones closest to a visitor), the lower-tier must ask an upper-tier to see if it has the content. If the upper-tier does not have the content, only the upper-tier can ask the origin for content. This practice improves bandwidth efficiency by limiting the number of data centers that can ask the origin for content, which reduces origin load and makes websites more cost-effective to operate. Additionally, Tiered Cache concentrates connections to origin servers so they come from a small number of data centers rather than the full set of network locations. This results in fewer open connections using server resources.`,builder:m,handler:async l=>{if(l.dryRun){a({command:`cf argo tiered-caching edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${l.zone??l.zoneId??`<zone>`}/argo/tiered_caching`,pathParams:{"zone-id":String(l.zone??l[`zone-id`]??``)},bodyKind:`json`,body:l.body===void 0?r({value:s(l.value,`value`,`text`)}):n(l.body)});return}let u=await t(l),d=await e({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,l.body){let e=n(l.body);i(await o(`Updating`,async()=>u.argo.tieredCaching.edit({...e,zone_id:d})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await c(`value`,`Enables Tiered Caching.`,[`on`,`off`]));let f=r({value:s(l.value,`value`,`text`)});i(await o(`Updating`,async()=>u.argo.tieredCaching.edit({...f,zone_id:d})),{successLabel:`Updated`})}};function g(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get`,describe:`Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of lower-tiers and upper-tiers. If content is not cached in lower-tier data centers (generally the ones closest to a visitor), the lower-tier must ask an upper-tier to see if it has the content. If the upper-tier does not have the content, only the upper-tier can ask the origin for content. This practice improves bandwidth efficiency by limiting the number of data centers that can ask the origin for content, which reduces origin load and makes websites more cost-effective to operate. Additionally, Tiered Cache concentrates connections to origin servers so they come from a small number of data centers rather than the full set of network locations. This results in fewer open connections using server resources.`,builder:g,handler:async n=>{if(n.dryRun){a({command:`cf argo tiered-caching get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${n.zone??n.zoneId??`<zone>`}/argo/tiered_caching`,pathParams:{"zone-id":String(n.zone??n[`zone-id`]??``)},bodyKind:`none`});return}let r=await t(n),s=await e({zone:n.zone},r,{quiet:n.quiet});n.zoneId=s,i(await o(`Loading`,async()=>r.argo.tieredCaching.get({zone_id:s})),{successLabel:`Loaded`})}},v={command:`tiered-caching`,describe:`Reduce origin load by having upper-tier data centers serve cache misses before reaching your origin`,builder:e=>e.command(h).command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},y={command:`argo`,describe:`Network optimization features that speed up and improve reliability of traffic to your origins`,builder:e=>e.command(p).command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{t as r}from"./output-B6fBFRqe.mjs";import{n as i,t as a}from"./progress-CL8I-7YK.mjs";import{t as o}from"./local-CYc9q7l2.mjs";import{t as s}from"./prompt-q3B7sM2A.mjs";import{t as c}from"./cli-types-DGgEbf8K.mjs";import{n as l,t as u}from"./raw-fetch-bIXC9D1m.mjs";function d(e){return e.positional(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const f={command:`artifactsNamespacesGet <namespace>`,describe:`Returns an Artifacts namespace summary.`,builder:d,handler:async s=>{if(s.dryRun){i({command:`cf artifacts namespaces artifactsNamespacesGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}`,pathParams:{namespace:String(s.namespace??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Loading`,async()=>c.artifacts.namespaces.artifactsNamespacesGet({account_id:l,namespace:s.namespace})),{successLabel:`Loaded`})}};function p(e){return e.option(`limit`,{type:`number`,description:`Limit`}).option(`cursor`,{type:`string`,description:`Cursor`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const m={command:`artifactsNamespacesList`,describe:`Lists Artifacts namespaces for an account.`,builder:p,handler:async s=>{let c={limit:s.limit,cursor:s.cursor};if(s.dryRun){i({command:`cf artifacts namespaces artifactsNamespacesList`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces`,pathParams:{},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await e();s.accountId=u,r(await a(`Loading`,async()=>l.artifacts.namespaces.artifactsNamespacesList({account_id:u,...c})),{successLabel:`Loaded`})}};function h(e){return e.positional(`hash`,{type:`string`,description:`40-character lowercase hexadecimal Git object hash.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const g={command:`artifactsReposBlobGet <hash>`,describe:`Returns raw bytes for an immutable Git blob object. Blob responses are cacheable forever by hash.`,builder:h,handler:async r=>{if(r.dryRun){i({command:`cf artifacts namespaces artifactsReposBlobGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${r.namespace==null?`<namespace>`:encodeURIComponent(String(r.namespace))}/repos/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/blob/${r.hash==null?`<hash>`:encodeURIComponent(String(r.hash))}`,pathParams:{namespace:String(r.namespace??``),name:String(r.name??``),hash:String(r.hash??``)},bodyKind:`none`});return}await n(r);let s=r.local?o:await e();r.accountId=s;let c=await a(`Loading`,async()=>u(`/accounts/${s}/artifacts/namespaces/${encodeURIComponent(String(r.namespace))}/repos/${encodeURIComponent(String(r.name))}/blob/${encodeURIComponent(String(r.hash))}`,{method:`GET`,localEndpoint:r.local?r.localEndpoint:void 0}));l(r.text===!0?c.toString(`utf-8`):c)}};function _(e){return e.positional(`hash`,{type:`string`,description:`40-character lowercase hexadecimal Git object hash.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`artifactsReposCommitGet <hash>`,describe:`Returns decoded metadata for an immutable Git commit object. Commit responses are cacheable forever by hash.`,builder:_,handler:async s=>{if(s.dryRun){i({command:`cf artifacts namespaces artifactsReposCommitGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}/repos/${s.name==null?`<name>`:encodeURIComponent(String(s.name))}/commit/${s.hash==null?`<hash>`:encodeURIComponent(String(s.hash))}`,pathParams:{namespace:String(s.namespace??``),name:String(s.name??``),hash:String(s.hash??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Loading`,async()=>c.artifacts.namespaces.artifactsReposCommitGet({account_id:l,namespace:s.namespace,name:s.name,hash:s.hash})),{successLabel:`Loaded`})}};function y(e){return e.positional(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`artifactsReposCreate <namespace>`,describe:`Creates a Git-compatible Artifacts repository in a namespace.`,builder:y,handler:async s=>{if(s.dryRun){i({command:`cf artifacts namespaces artifactsReposCreate`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}/repos`,pathParams:{namespace:String(s.namespace??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Creating`,async()=>c.artifacts.namespaces.artifactsReposCreate({account_id:l,namespace:s.namespace})),{successLabel:`Created`})}};function x(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const S={command:`artifactsReposDelete <name>`,describe:`Deletes a repository and schedules cleanup of its backing data.`,builder:x,handler:async c=>{if(c.dryRun){i({command:`cf artifacts namespaces artifactsReposDelete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${c.namespace==null?`<namespace>`:encodeURIComponent(String(c.namespace))}/repos/${c.name==null?`<name>`:encodeURIComponent(String(c.name))}`,pathParams:{namespace:String(c.namespace??``),name:String(c.name??``)},bodyKind:`none`});return}let l=await n(c),u=c.local?o:await e();if(c.accountId=u,!await s({force:!!c.force})){process.stderr.write(`Aborted.
3
+ `);return}r(await a(`Deleting`,async()=>l.artifacts.namespaces.artifactsReposDelete({account_id:u,namespace:c.namespace,name:c.name})),{successLabel:`Deleted`})}};function C(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`ref`,{type:`string`,description:`Git ref, branch, tag, or commit hash.`,demandOption:!0}).option(`path`,{type:`string`,description:`File path.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const w={command:`artifactsReposFileGet <name>`,describe:`Returns raw bytes for a file resolved by ref and path.`,builder:C,handler:async r=>{let s={ref:r.ref,path:r.path};if(r.dryRun){i({command:`cf artifacts namespaces artifactsReposFileGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${r.namespace==null?`<namespace>`:encodeURIComponent(String(r.namespace))}/repos/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/file`,pathParams:{namespace:String(r.namespace??``),name:String(r.name??``)},query:s,bodyKind:`none`});return}await n(r);let c=r.local?o:await e();r.accountId=c;let d=new URLSearchParams(Object.entries(s).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),f=await a(`Loading`,async()=>u(`/accounts/${c}/artifacts/namespaces/${encodeURIComponent(String(r.namespace))}/repos/${encodeURIComponent(String(r.name))}/file${d?`?`+d:``}`,{method:`GET`,localEndpoint:r.local?r.localEndpoint:void 0}));l(r.text===!0?f.toString(`utf-8`):f)}};function T(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const E={command:`artifactsReposFork <name>`,describe:`Forks a source repository into a new repository.`,builder:T,handler:async s=>{if(s.dryRun){i({command:`cf artifacts namespaces artifactsReposFork`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}/repos/${s.name==null?`<name>`:encodeURIComponent(String(s.name))}/fork`,pathParams:{namespace:String(s.namespace??``),name:String(s.name??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Creating`,async()=>c.artifacts.namespaces.artifactsReposFork({account_id:l,namespace:s.namespace,name:s.name})),{successLabel:`Created`})}};function D(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`artifactsReposGet <name>`,describe:`Returns repository metadata.`,builder:D,handler:async s=>{if(s.dryRun){i({command:`cf artifacts namespaces artifactsReposGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}/repos/${s.name==null?`<name>`:encodeURIComponent(String(s.name))}`,pathParams:{namespace:String(s.namespace??``),name:String(s.name??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Loading`,async()=>c.artifacts.namespaces.artifactsReposGet({account_id:l,namespace:s.namespace,name:s.name})),{successLabel:`Loaded`})}};function k(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`artifactsReposImport <name>`,describe:`Imports an HTTPS Git repository into an Artifacts repository.`,builder:k,handler:async s=>{if(s.dryRun){i({command:`cf artifacts namespaces artifactsReposImport`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}/repos/${s.name==null?`<name>`:encodeURIComponent(String(s.name))}/import`,pathParams:{namespace:String(s.namespace??``),name:String(s.name??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Creating`,async()=>c.artifacts.namespaces.artifactsReposImport({account_id:l,namespace:s.namespace,name:s.name})),{successLabel:`Created`})}};function j(e){return e.positional(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`limit`,{type:`number`,description:`Limit`}).option(`cursor`,{type:`string`,description:`Cursor`}).option(`search`,{type:`string`,description:`Search`}).option(`sort`,{type:`string`,description:`Sort`,choices:[`created_at`,`updated_at`,`last_push_at`,`name`]}).option(`direction`,{type:`string`,description:`Direction`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`artifactsReposList <namespace>`,describe:`Lists repositories in a namespace.`,builder:c(j),handler:async s=>{let c={limit:s.limit,cursor:s.cursor,search:s.search,sort:s.sort,direction:s.direction};if(s.dryRun){i({command:`cf artifacts namespaces artifactsReposList`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}/repos`,pathParams:{namespace:String(s.namespace??``)},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await e();s.accountId=u,r(await a(`Loading`,async()=>l.artifacts.namespaces.artifactsReposList({account_id:u,namespace:s.namespace,...c})),{successLabel:`Loaded`})}};function N(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`ref`,{type:`string`,description:`Git ref, branch, tag, or commit hash. Defaults to HEAD.`}).option(`limit`,{type:`number`,description:`Limit`}).option(`offset`,{type:`number`,description:`Offset`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`artifactsReposLogGet <name>`,describe:`Returns commit metadata walking backwards from a ref, branch, tag, or HEAD.`,builder:N,handler:async s=>{let c={ref:s.ref,limit:s.limit,offset:s.offset};if(s.dryRun){i({command:`cf artifacts namespaces artifactsReposLogGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}/repos/${s.name==null?`<name>`:encodeURIComponent(String(s.name))}/log`,pathParams:{namespace:String(s.namespace??``),name:String(s.name??``)},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await e();s.accountId=u,r(await a(`Loading`,async()=>l.artifacts.namespaces.artifactsReposLogGet({account_id:u,namespace:s.namespace,name:s.name,...c})),{successLabel:`Loaded`})}};function F(e){return e.positional(`path`,{type:`string`,description:`File path. May contain slashes.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`ref`,{type:`string`,description:`Git ref, branch, tag, or 40-character commit hash.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const I={command:`artifactsReposRawGet <path>`,describe:`Returns file bytes resolved by ref and path, with a sniffed content type and browser-safe response headers.`,builder:F,handler:async r=>{if(r.dryRun){i({command:`cf artifacts namespaces artifactsReposRawGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${r.namespace==null?`<namespace>`:encodeURIComponent(String(r.namespace))}/repos/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/raw/${r.ref==null?`<ref>`:encodeURIComponent(String(r.ref))}/${r.path==null?`<path>`:encodeURIComponent(String(r.path))}`,pathParams:{namespace:String(r.namespace??``),name:String(r.name??``),ref:String(r.ref??``),path:String(r.path??``)},bodyKind:`none`});return}await n(r);let s=r.local?o:await e();r.accountId=s;let c=await a(`Loading`,async()=>u(`/accounts/${s}/artifacts/namespaces/${encodeURIComponent(String(r.namespace))}/repos/${encodeURIComponent(String(r.name))}/raw/${encodeURIComponent(String(r.ref))}/${encodeURIComponent(String(r.path))}`,{method:`GET`,localEndpoint:r.local?r.localEndpoint:void 0}));l(r.text===!0?c.toString(`utf-8`):c)}};function L(e){return e.positional(`hash`,{type:`string`,description:`40-character lowercase hexadecimal Git object hash.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const R={command:`artifactsReposTreeGet <hash>`,describe:`Returns decoded entries for an immutable Git tree object. Tree responses are cacheable forever by hash.`,builder:L,handler:async s=>{if(s.dryRun){i({command:`cf artifacts namespaces artifactsReposTreeGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}/repos/${s.name==null?`<name>`:encodeURIComponent(String(s.name))}/tree/${s.hash==null?`<hash>`:encodeURIComponent(String(s.hash))}`,pathParams:{namespace:String(s.namespace??``),name:String(s.name??``),hash:String(s.hash??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Loading`,async()=>c.artifacts.namespaces.artifactsReposTreeGet({account_id:l,namespace:s.namespace,name:s.name,hash:s.hash})),{successLabel:`Loaded`})}};function z(e){return e.positional(`name`,{type:`string`,description:`Repository name.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`state`,{type:`string`,description:`State`,choices:[`active`,`expired`,`revoked`,`all`]}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const B={command:`artifactsRepoTokensList <name>`,describe:`Lists tokens for a repository.`,builder:c(z),handler:async s=>{let c={state:s.state,page:s.page,per_page:s[`per-page`]};if(s.dryRun){i({command:`cf artifacts namespaces artifactsRepoTokensList`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}/repos/${s.name==null?`<name>`:encodeURIComponent(String(s.name))}/tokens`,pathParams:{namespace:String(s.namespace??``),name:String(s.name??``)},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await e();s.accountId=u,r(await a(`Loading`,async()=>l.artifacts.namespaces.artifactsRepoTokensList({account_id:u,namespace:s.namespace,name:s.name,...c})),{successLabel:`Loaded`})}};function V(e){return e.positional(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const H={command:`artifactsTokensCreate <namespace>`,describe:`Creates a scoped Git token for a repository.`,builder:V,handler:async s=>{if(s.dryRun){i({command:`cf artifacts namespaces artifactsTokensCreate`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${s.namespace==null?`<namespace>`:encodeURIComponent(String(s.namespace))}/tokens`,pathParams:{namespace:String(s.namespace??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Creating`,async()=>c.artifacts.namespaces.artifactsTokensCreate({account_id:l,namespace:s.namespace})),{successLabel:`Created`})}};function U(e){return e.positional(`id`,{type:`string`,description:`Token ID. Must match /^[0-9a-z]{16}$/.`,demandOption:!0}).option(`namespace`,{type:`string`,description:`Artifacts namespace name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const W={command:`artifactsTokensRevoke <id>`,describe:`Revokes an Artifacts repository token.`,builder:U,handler:async c=>{if(c.dryRun){i({command:`cf artifacts namespaces artifactsTokensRevoke`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/artifacts/namespaces/${c.namespace==null?`<namespace>`:encodeURIComponent(String(c.namespace))}/tokens/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{namespace:String(c.namespace??``),id:String(c.id??``)},bodyKind:`none`});return}let l=await n(c),u=c.local?o:await e();if(c.accountId=u,!await s({force:!!c.force})){process.stderr.write(`Aborted.
4
+ `);return}r(await a(`Deleting`,async()=>l.artifacts.namespaces.artifactsTokensRevoke({account_id:u,namespace:c.namespace,id:c.id})),{successLabel:`Deleted`})}},G={command:`namespaces`,describe:`Operations for namespaces`,builder:e=>e.command(f).command(m).command(B).command(g).command(v).command(b).command(S).command(w).command(E).command(O).command(A).command(M).command(P).command(I).command(R).command(H).command(W).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},K={command:`artifacts`,describe:`artifacts`,builder:e=>e.command(G).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{K as default};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{S as e,g as t}from"./oauth-Bk-F-tIO.mjs";import{n}from"./auth-CSC4yhEJ.mjs";import{t as r}from"./output-B6fBFRqe.mjs";import{n as i,t as a}from"./progress-DrDErV9w.mjs";import{t as o}from"./local-CYc9q7l2.mjs";import{t as s}from"./cli-types-BeyOc81z.mjs";function c(e){return e.option(`id`,{type:`string`,description:`Finds a specific log by its ID.`}).option(`export`,{type:`boolean`,description:`Indicates that this request is an export of logs in CSV format.`}).option(`action-type`,{type:`string`,description:`Filters by the action type.`}).option(`actor-ip`,{type:`string`,description:`Filters by the IP address of the request that made the change by specific IP address or valid CIDR Range.`}).option(`actor-email`,{type:`string`,description:`Filters by the email address of the actor that made the change.`}).option(`since`,{type:`string`,description:"Limits the returned results to logs newer than the specified date. A `full-date` that conforms to RFC3339."}).option(`before`,{type:`string`,description:"Limits the returned results to logs older than the specified date. A `full-date` that conforms to RFC3339."}).option(`zone-name`,{type:`string`,description:`Filters by the name of the zone associated to the change.`}).option(`direction`,{type:`string`,description:`Changes the direction of the chronological sorting.`,choices:[`desc`,`asc`]}).option(`per-page`,{type:`number`,description:`Sets the number of results to return per page.`}).option(`page`,{type:`number`,description:`Defines which page of results to return.`}).option(`hide-user-logs`,{type:`boolean`,description:`Indicates whether or not to hide user level audit logs.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const l={command:`list`,describe:`Gets a list of audit logs for an account. Can be filtered by who made the change, on which zone, and the timeframe of the change.`,builder:s(c),handler:async s=>{let c={id:s.id,export:s.export,"action.type":s[`action-type`],"actor.ip":s[`actor-ip`],"actor.email":s[`actor-email`],since:s.since,before:s.before,"zone.name":s[`zone-name`],direction:s.direction,per_page:s[`per-page`],page:s.page,hide_user_logs:s[`hide-user-logs`]};if(s.dryRun){i({command:`cf audit-logs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/audit_logs`,pathParams:{},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await t(l);s.accountId=u,r(await a(`Loading`,async()=>l.auditLogs.list({account_id:u,...c})),{successLabel:`Loaded`})}},u={command:`audit-logs`,describe:`Immutable audit trail of actions taken by account members — who changed what and when`,builder:e=>e.command(l).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{u as default};
2
+ import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{t as r}from"./output-B6fBFRqe.mjs";import{n as i,t as a}from"./progress-CL8I-7YK.mjs";import{t as o}from"./local-CYc9q7l2.mjs";import{t as s}from"./cli-types-DGgEbf8K.mjs";function c(e){return e.option(`id`,{type:`string`,description:`Finds a specific log by its ID.`}).option(`export`,{type:`boolean`,description:`Indicates that this request is an export of logs in CSV format.`}).option(`action-type`,{type:`string`,description:`Filters by the action type.`}).option(`actor-ip`,{type:`string`,description:`Filters by the IP address of the request that made the change by specific IP address or valid CIDR Range.`}).option(`actor-email`,{type:`string`,description:`Filters by the email address of the actor that made the change.`}).option(`since`,{type:`string`,description:"Limits the returned results to logs newer than the specified date. A `full-date` that conforms to RFC3339."}).option(`before`,{type:`string`,description:"Limits the returned results to logs older than the specified date. A `full-date` that conforms to RFC3339."}).option(`zone-name`,{type:`string`,description:`Filters by the name of the zone associated to the change.`}).option(`direction`,{type:`string`,description:`Changes the direction of the chronological sorting.`,choices:[`desc`,`asc`]}).option(`per-page`,{type:`number`,description:`Sets the number of results to return per page.`}).option(`page`,{type:`number`,description:`Defines which page of results to return.`}).option(`hide-user-logs`,{type:`boolean`,description:`Indicates whether or not to hide user level audit logs.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const l={command:`list`,describe:`Gets a list of audit logs for an account. Can be filtered by who made the change, on which zone, and the timeframe of the change.`,builder:s(c),handler:async s=>{let c={id:s.id,export:s.export,"action.type":s[`action-type`],"actor.ip":s[`actor-ip`],"actor.email":s[`actor-email`],since:s.since,before:s.before,"zone.name":s[`zone-name`],direction:s.direction,per_page:s[`per-page`],page:s.page,hide_user_logs:s[`hide-user-logs`]};if(s.dryRun){i({command:`cf audit-logs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/audit_logs`,pathParams:{},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await e();s.accountId=u,r(await a(`Loading`,async()=>l.auditLogs.list({account_id:u,...c})),{successLabel:`Loaded`})}},u={command:`audit-logs`,describe:`Immutable audit trail of actions taken by account members — who changed what and when`,builder:e=>e.command(l).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{u as default};
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import{l as e,v as t}from"./session-DHYCE-PM.mjs";import{n,r,t as i}from"./sdk-DhIhH6GB.mjs";import{g as a}from"./dist-C6zxsVdY.mjs";import{D as o,_ as s,i as c,k as l}from"./oauth-Bk-F-tIO.mjs";import{execSync as u}from"child_process";import d from"os";function f(e){try{let t=u(`ps -p ${e} -o pid=,ppid=,command=`,{encoding:`utf8`,timeout:5e3}).trim();if(!t)return null;let[n,r,...i]=t.split(/\s+/),a=n?parseInt(n,10):NaN,o=r?parseInt(r,10):NaN;return isNaN(a)||isNaN(o)?null:{pid:a,ppid:o,command:i.join(` `)||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function p(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=f(r);if(!e||e.ppid===0||e.ppid===1)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function m(e){try{let t=u(`wmic process where (ProcessId=${e}) get ProcessId,ParentProcessId,CommandLine /format:csv`,{encoding:`utf8`,timeout:1e4});if(!t)return null;let n=t.split(`
3
- `).filter(e=>e.trim()&&!e.startsWith(`Node`)).pop()?.split(`,`);if(!n||n.length<4)return null;let[r,i,a,o]=n,s=o?parseInt(o.trim(),10):NaN,c=a?parseInt(a.trim(),10):NaN;return isNaN(s)||isNaN(c)?null:{pid:s,ppid:c,command:i?.trim()||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function h(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=m(r);if(!e||e.ppid===0||e.ppid===4)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function g(e=process.pid){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(`PID must be a positive integer`);return d.platform()===`win32`?h(e):p(e)}const _=[{id:`opencode`,name:`OpenCode`,type:`agent`,envVars:[{any:[`OPENCODE`,`OPENCODE_BIN_PATH`,`OPENCODE_SERVER`,`OPENCODE_APP_INFO`,`OPENCODE_MODES`]}]},{id:`jules`,name:`Jules`,type:`agent`,envVars:[{all:[[`HOME`,`/home/jules`],[`USER`,`swebot`]]}]},{id:`claude-code`,name:`Claude Code`,type:`agent`,envVars:[`CLAUDECODE`]},{id:`cursor-agent`,name:`Cursor Agent`,type:`agent`,envVars:[{all:[`CURSOR_TRACE_ID`,[`PAGER`,`head -n 10000 | cat`]]}]},{id:`cursor`,name:`Cursor`,type:`interactive`,envVars:[`CURSOR_TRACE_ID`]},{id:`gemini-agent`,name:`Gemini Agent`,type:`agent`,processChecks:[`gemini`]},{id:`codex`,name:`OpenAI Codex`,type:`agent`,processChecks:[`codex`]},{id:`replit`,name:`Replit`,type:`agent`,envVars:[`REPL_ID`]},{id:`aider`,name:`Aider`,type:`agent`,envVars:[`AIDER_API_KEY`],processChecks:[`aider`]},{id:`bolt-agent`,name:`Bolt.new Agent`,type:`agent`,envVars:[{all:[[`SHELL`,`/bin/jsh`],`npm_config_yes`]}]},{id:`bolt`,name:`Bolt.new`,type:`interactive`,envVars:[{all:[[`SHELL`,`/bin/jsh`]],none:[`npm_config_yes`]}]},{id:`zed-agent`,name:`Zed Agent`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`zed`],[`PAGER`,`cat`]]}]},{id:`zed`,name:`Zed`,type:`interactive`,envVars:[{all:[[`TERM_PROGRAM`,`zed`]],none:[[`PAGER`,`cat`]]}]},{id:`replit-assistant`,name:`Replit Assistant`,type:`agent`,envVars:[{all:[`REPL_ID`,[`REPLIT_MODE`,`assistant`]]}]},{id:`replit`,name:`Replit`,type:`interactive`,envVars:[{all:[`REPL_ID`],none:[[`REPLIT_MODE`,`assistant`]]}]},{id:`windsurf`,name:`Windsurf`,type:`agent`,envVars:[`CODEIUM_EDITOR_APP_ROOT`]},{id:`crush`,name:`Crush`,type:`agent`,processChecks:[`crush`]},{id:`vscode-copilot-agent`,name:`GitHub Copilot in VS Code`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`vscode`],[`GIT_PAGER`,`cat`]]}]},{id:`warp`,name:`Warp Terminal`,type:`hybrid`,envVars:[{all:[[`TERM_PROGRAM`,`WarpTerminal`]]}]},{id:`octofriend`,name:`Octofriend`,type:`agent`,processChecks:[`octofriend`]}];function v(e,t=process.env){let[n,r]=typeof e==`string`?[e,void 0]:e,i=t[n];return!!(i&&(!r||i===r))}function y(e,t){try{let n=t??g();for(let t of n)if(t.command?.includes(e))return!0}catch{}return!1}function b(e,t=process.env){if(typeof e==`string`||Array.isArray(e))return v(e,t);let{any:n,all:r,none:i}=e,a=!n?.length||n.some(e=>v(e,t)),o=!r?.length||r.every(e=>v(e,t)),s=!i?.length||!i.some(e=>v(e,t));return a&&o&&s}function x(e){return e.customDetectors?.some(e=>{try{return e()}catch{return!1}})??!1}function S(e){return{isAgentic:!0,id:e.id,name:e.name,type:e.type}}function C(e=process.env,t){for(let t of _)if(t.envVars?.some(t=>b(t,e)))return S(t);let n=t,r=()=>{if(n===void 0)try{n=g()}catch{n=[]}return n};for(let e of _)if(e.processChecks?.some(e=>y(e,r())))return S(e);for(let e of _)if(x(e))return S(e);return{isAgentic:!1,id:null,name:null,type:null}}function w(){return o?`ci`:l()?`interactive`:`non-interactive`}function T(){let e=C(),n=e.isAgentic&&e.id!==null?{"X-CF-CLI-Agent":e.id}:{};return{"User-Agent":t,"X-CF-CLI-Mode":w(),...n}}const E=3e4,D=n.Default;function O(e){return e instanceof FormData||e instanceof Blob||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||e instanceof ReadableStream||e instanceof URLSearchParams}function k(e){return Object.keys(e).some(e=>e.toLowerCase()===`content-type`)}async function A(e){let t=e.headers.get(`content-type`)??``;try{return t.includes(`application/json`)?await e.json():await e.text()}catch{return null}}function j(e,t,n){if(!(n==null||n===``)){if(Array.isArray(n)){for(let r of n)j(e,t,r);return}e.append(t,String(n))}}function M(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))j(t,n,r);return t.toString()}function N(e,t,n){let r=new URL(t.endsWith(`/`)?t:`${t}/`),i=new URL(e.startsWith(`/`)?e.slice(1):e,r);if(i.origin!==r.origin)throw Error(`Refusing to send an authenticated request to ${i.origin} (expected ${r.origin})`);let a=M(n??{});return a&&(i.search=a),i.toString()}const P=new WeakMap;async function F(e,t,n,i={}){let a=N(n,P.get(e)??D,i.query),o={...i.headers},s;i.body!==void 0&&(O(i.body)||typeof i.body==`string`&&k(o)?s=i.body:(o[`Content-Type`]??=`application/json`,s=JSON.stringify(i.body)));let c;try{c=await e.fetch(a,{method:t,headers:o,body:s,signal:i.signal},{timeoutInSeconds:i.timeout?i.timeout/1e3:void 0,abortSignal:i.signal})}catch(e){throw i.signal?.aborted?Error(`Request aborted`):e instanceof Error&&e.name===`AbortError`?Error(`Request timed out after ${i.timeout??E}ms`):e instanceof Error?Error(`Request failed: ${e.message}`):e}if(!c.ok)throw new r({statusCode:c.status,body:await A(c),rawResponse:{status:c.status,statusText:c.statusText,url:c.url||a,headers:c.headers,redirected:c.redirected,type:c.type}});if(c.status===204)return null;let l=await c.text();if(l===``)return null;if(!(c.headers.get(`content-type`)??``).includes(`application/json`))return l;let u=JSON.parse(l);if(u.success===!1)throw new r({message:`API error: ${u.errors?.map(e=>e.message).filter(Boolean).join(`, `)||`unknown error`}`,statusCode:c.status,body:u});return`result`in u?u.result:u}function I(e){let t=e.baseURL??D,n=new i({baseUrl:t,auth:async()=>({headers:{Authorization:`Bearer ${e.apiToken}`}}),headers:e.defaultHeaders,timeoutInSeconds:(e.timeout??E)/1e3,maxRetries:0,fetch:e.fetch??globalThis.fetch});return P.set(n,t),n}async function L(){let t=e({allowGlobalAuthKey:!1});if(t&&`apiToken`in t)return t.apiToken;let n=await c();if(n)return n;throw Error(`No authentication token found.
2
+ import{l as e,v as t}from"./session-B8r8LNQN.mjs";import{n,r,t as i}from"./sdk-DhIhH6GB.mjs";import{g as a}from"./dist-C6zxsVdY.mjs";import{d as o,i as s,k as c,p as l}from"./oauth-B5k80sip.mjs";import{execSync as u}from"child_process";import d from"os";function f(e){try{let t=u(`ps -p ${e} -o pid=,ppid=,command=`,{encoding:`utf8`,timeout:5e3}).trim();if(!t)return null;let[n,r,...i]=t.split(/\s+/),a=n?parseInt(n,10):NaN,o=r?parseInt(r,10):NaN;return isNaN(a)||isNaN(o)?null:{pid:a,ppid:o,command:i.join(` `)||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function p(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=f(r);if(!e||e.ppid===0||e.ppid===1)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function m(e){try{let t=u(`wmic process where (ProcessId=${e}) get ProcessId,ParentProcessId,CommandLine /format:csv`,{encoding:`utf8`,timeout:1e4});if(!t)return null;let n=t.split(`
3
+ `).filter(e=>e.trim()&&!e.startsWith(`Node`)).pop()?.split(`,`);if(!n||n.length<4)return null;let[r,i,a,o]=n,s=o?parseInt(o.trim(),10):NaN,c=a?parseInt(a.trim(),10):NaN;return isNaN(s)||isNaN(c)?null:{pid:s,ppid:c,command:i?.trim()||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function h(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=m(r);if(!e||e.ppid===0||e.ppid===4)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function g(e=process.pid){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(`PID must be a positive integer`);return d.platform()===`win32`?h(e):p(e)}const _=[{id:`opencode`,name:`OpenCode`,type:`agent`,envVars:[{any:[`OPENCODE`,`OPENCODE_BIN_PATH`,`OPENCODE_SERVER`,`OPENCODE_APP_INFO`,`OPENCODE_MODES`]}]},{id:`jules`,name:`Jules`,type:`agent`,envVars:[{all:[[`HOME`,`/home/jules`],[`USER`,`swebot`]]}]},{id:`claude-code`,name:`Claude Code`,type:`agent`,envVars:[`CLAUDECODE`]},{id:`cursor-agent`,name:`Cursor Agent`,type:`agent`,envVars:[{all:[`CURSOR_TRACE_ID`,[`PAGER`,`head -n 10000 | cat`]]}]},{id:`cursor`,name:`Cursor`,type:`interactive`,envVars:[`CURSOR_TRACE_ID`]},{id:`gemini-agent`,name:`Gemini Agent`,type:`agent`,processChecks:[`gemini`]},{id:`codex`,name:`OpenAI Codex`,type:`agent`,processChecks:[`codex`]},{id:`replit`,name:`Replit`,type:`agent`,envVars:[`REPL_ID`]},{id:`aider`,name:`Aider`,type:`agent`,envVars:[`AIDER_API_KEY`],processChecks:[`aider`]},{id:`bolt-agent`,name:`Bolt.new Agent`,type:`agent`,envVars:[{all:[[`SHELL`,`/bin/jsh`],`npm_config_yes`]}]},{id:`bolt`,name:`Bolt.new`,type:`interactive`,envVars:[{all:[[`SHELL`,`/bin/jsh`]],none:[`npm_config_yes`]}]},{id:`zed-agent`,name:`Zed Agent`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`zed`],[`PAGER`,`cat`]]}]},{id:`zed`,name:`Zed`,type:`interactive`,envVars:[{all:[[`TERM_PROGRAM`,`zed`]],none:[[`PAGER`,`cat`]]}]},{id:`replit-assistant`,name:`Replit Assistant`,type:`agent`,envVars:[{all:[`REPL_ID`,[`REPLIT_MODE`,`assistant`]]}]},{id:`replit`,name:`Replit`,type:`interactive`,envVars:[{all:[`REPL_ID`],none:[[`REPLIT_MODE`,`assistant`]]}]},{id:`windsurf`,name:`Windsurf`,type:`agent`,envVars:[`CODEIUM_EDITOR_APP_ROOT`]},{id:`crush`,name:`Crush`,type:`agent`,processChecks:[`crush`]},{id:`vscode-copilot-agent`,name:`GitHub Copilot in VS Code`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`vscode`],[`GIT_PAGER`,`cat`]]}]},{id:`warp`,name:`Warp Terminal`,type:`hybrid`,envVars:[{all:[[`TERM_PROGRAM`,`WarpTerminal`]]}]},{id:`octofriend`,name:`Octofriend`,type:`agent`,processChecks:[`octofriend`]}];function v(e,t=process.env){let[n,r]=typeof e==`string`?[e,void 0]:e,i=t[n];return!!(i&&(!r||i===r))}function y(e,t){try{let n=t??g();for(let t of n)if(t.command?.includes(e))return!0}catch{}return!1}function b(e,t=process.env){if(typeof e==`string`||Array.isArray(e))return v(e,t);let{any:n,all:r,none:i}=e,a=!n?.length||n.some(e=>v(e,t)),o=!r?.length||r.every(e=>v(e,t)),s=!i?.length||!i.some(e=>v(e,t));return a&&o&&s}function x(e){return e.customDetectors?.some(e=>{try{return e()}catch{return!1}})??!1}function S(e){return{isAgentic:!0,id:e.id,name:e.name,type:e.type}}function C(e=process.env,t){for(let t of _)if(t.envVars?.some(t=>b(t,e)))return S(t);let n=t,r=()=>{if(n===void 0)try{n=g()}catch{n=[]}return n};for(let e of _)if(e.processChecks?.some(e=>y(e,r())))return S(e);for(let e of _)if(x(e))return S(e);return{isAgentic:!1,id:null,name:null,type:null}}function w(){return o?`ci`:l()?`interactive`:`non-interactive`}function T(){let e=C(),n=e.isAgentic&&e.id!==null?{"X-CF-CLI-Agent":e.id}:{};return{"User-Agent":t,"X-CF-CLI-Mode":w(),...n}}const E=3e4,D=n.Default;function O(e){return e instanceof FormData||e instanceof Blob||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||e instanceof ReadableStream||e instanceof URLSearchParams}function k(e){return Object.keys(e).some(e=>e.toLowerCase()===`content-type`)}async function A(e){let t=e.headers.get(`content-type`)??``;try{return t.includes(`application/json`)?await e.json():await e.text()}catch{return null}}function j(e,t,n){if(!(n==null||n===``)){if(Array.isArray(n)){for(let r of n)j(e,t,r);return}e.append(t,String(n))}}function M(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))j(t,n,r);return t.toString()}function N(e,t,n){let r=new URL(t.endsWith(`/`)?t:`${t}/`),i=new URL(e.startsWith(`/`)?e.slice(1):e,r);if(i.origin!==r.origin)throw Error(`Refusing to send an authenticated request to ${i.origin} (expected ${r.origin})`);let a=M(n??{});return a&&(i.search=a),i.toString()}const P=new WeakMap;async function F(e,t,n,i={}){let a=N(n,P.get(e)??D,i.query),o={...i.headers},s;i.body!==void 0&&(O(i.body)||typeof i.body==`string`&&k(o)?s=i.body:(o[`Content-Type`]??=`application/json`,s=JSON.stringify(i.body)));let c;try{c=await e.fetch(a,{method:t,headers:o,body:s,signal:i.signal},{timeoutInSeconds:i.timeout?i.timeout/1e3:void 0,abortSignal:i.signal})}catch(e){throw i.signal?.aborted?Error(`Request aborted`):e instanceof Error&&e.name===`AbortError`?Error(`Request timed out after ${i.timeout??E}ms`):e instanceof Error?Error(`Request failed: ${e.message}`):e}if(!c.ok)throw new r({statusCode:c.status,body:await A(c),rawResponse:{status:c.status,statusText:c.statusText,url:c.url||a,headers:c.headers,redirected:c.redirected,type:c.type}});if(c.status===204)return null;let l=await c.text();if(l===``)return null;if(!(c.headers.get(`content-type`)??``).includes(`application/json`))return l;let u=JSON.parse(l);if(u.success===!1)throw new r({message:`API error: ${u.errors?.map(e=>e.message).filter(Boolean).join(`, `)||`unknown error`}`,statusCode:c.status,body:u});return`result`in u?u.result:u}function I(e){let t=e.baseURL??D,n=new i({baseUrl:t,auth:async()=>({headers:{Authorization:`Bearer ${e.apiToken}`}}),headers:e.defaultHeaders,timeoutInSeconds:(e.timeout??E)/1e3,maxRetries:0,fetch:e.fetch??globalThis.fetch});return P.set(n,t),n}async function L(){let t=e({allowGlobalAuthKey:!1});if(t&&`apiToken`in t)return t.apiToken;let n=await s();if(n)return n;throw Error(`No authentication token found.
4
4
 
5
5
  Please set one of the following:
6
6
  1. Set the CLOUDFLARE_API_TOKEN environment variable
7
7
  2. Run 'cf auth login' to authenticate via OAuth
8
8
 
9
- For API tokens, visit: https://dash.cloudflare.com/profile/api-tokens`)}async function R(e){let t=a({compliance_region:s()});if(e.local){if(!e.localEndpoint)throw Error(`--local requires --local-endpoint <url>; this should have been caught by the global middleware.`);let{createLocalFetch:n}=await import(`./local-CYc9q7l2.mjs`).then(e=>e.r);return I({apiToken:`cf-local-mode-no-auth`,baseURL:t,defaultHeaders:T(),fetch:n({endpoint:e.localEndpoint})})}return I({apiToken:await L(),baseURL:t,defaultHeaders:T()})}export{T as a,F as i,R as n,L as r,I as t};
9
+ For API tokens, visit: https://dash.cloudflare.com/profile/api-tokens`)}async function R(e){let t=a({compliance_region:c()});if(e.local){if(!e.localEndpoint)throw Error(`--local requires --local-endpoint <url>; this should have been caught by the global middleware.`);let{createLocalFetch:n}=await import(`./local-CYc9q7l2.mjs`).then(e=>e.r);return I({apiToken:`cf-local-mode-no-auth`,baseURL:t,defaultHeaders:T(),fetch:n({endpoint:e.localEndpoint})})}return I({apiToken:await L(),baseURL:t,defaultHeaders:T()})}export{T as a,F as i,R as n,L as r,I as t};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{g as e,l as t}from"./session-DHYCE-PM.mjs";import{a as n}from"./theme-DbNbIY4d.mjs";import{i as r,n as i,t as a}from"./ui-erjBdVKL.mjs";import{a as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p,u as m}from"./oauth-Bk-F-tIO.mjs";import{r as h,t as g}from"./auth-CSC4yhEJ.mjs";import{t as _}from"./output-B6fBFRqe.mjs";import v from"node:path";function y(e,t,n){if(!e.profile)return;let r=n?` ${n}`:``;throw Error(`The --profile flag cannot be used with \`cf auth ${t}\`.${r}`)}function b(){if(t({allowGlobalAuthKey:!1})!==void 0)throw Error(`Cannot manage auth profiles while CLOUDFLARE_API_TOKEN is set. Unset CLOUDFLARE_API_TOKEN and try again.`)}const x={command:`create <name>`,describe:`Create or re-authenticate a named auth profile`,builder:e=>e.positional(`name`,{type:`string`,description:`Name for the auth profile`,demandOption:!0}).option(`browser`,{type:`boolean`,description:`Open a browser to complete login (use --no-browser to print the URL instead)`,default:!0}).option(`scopes`,{type:`string`,array:!0,description:`The set of OAuth scopes to request`}),handler:async t=>{y(t,`create`,"Pass the profile name as the command argument: `cf auth create <name>`."),b(),e(t.name);let r=d().configs.exists(t.name);await u({browser:t.browser,scopes:t.scopes,profile:t.name}),console.log(i(r?`Profile "${t.name}" re-authenticated.`:`Profile "${t.name}" created.`)),console.log(a(`Run ${n.code(`cf auth activate ${t.name}`)} to use this profile in a directory.`))}},S={command:`delete <name>`,describe:`Delete a named auth profile`,builder:e=>e.positional(`name`,{type:`string`,description:`Name of the auth profile to delete`,demandOption:!0}),handler:async t=>{y(t,`delete`),b(),e(t.name);let r=d();if(!r.configs.exists(t.name))throw Error(`Profile "${t.name}" does not exist.`);let o=r.bindings.removeAllBindingsForProfile(t.name);if(o.length>0){console.log(i(`Removed directory bindings:`));for(let e of o)console.log(` ${e}`)}await f(t.name),r.configs.delete(t.name),console.log(i(`Profile "${t.name}" deleted.`));let s=r.bindings.getProfileForDirectory(process.cwd());s?console.log(i(`Active profile for this directory: ${s}.`)):r.configs.exists(`default`)?console.log(i(`This directory now uses the default profile.`)):console.log(a(`No active profile for this directory. Run ${n.code(`cf auth login`)} to set up the default profile, or ${n.code(`cf auth create <name>`)} to create a named profile.`))}},C={command:`activate <name> [dir]`,describe:`Bind a named auth profile to a directory`,builder:e=>e.positional(`name`,{type:`string`,description:`Name of the auth profile to activate`,demandOption:!0}).positional(`dir`,{type:`string`,description:`Directory to bind the profile to (defaults to current directory)`}),handler:t=>{y(t,`activate`,"Pass the profile name as the command argument: `cf auth activate <name>`."),b(),e(t.name);let n=d();if(!n.configs.exists(t.name))throw Error(`Profile "${t.name}" does not exist. Run \`cf auth create ${t.name}\` first.`);let r=t.dir??process.cwd();n.bindings.activate(t.name,r),console.log(i(`Profile "${t.name}" activated for "${v.resolve(r)}".`))}},w={command:`deactivate [dir]`,describe:`Remove the auth profile binding from a directory`,builder:e=>e.positional(`dir`,{type:`string`,description:`Directory to unbind (defaults to current directory). Must be the exact directory the profile was bound to.`}),handler:e=>{y(e,`deactivate`),b();let t=d(),r=e.dir??process.cwd(),{removedProfile:o,newResolution:s}=t.bindings.deactivate(r);console.log(i(`Profile "${o}" deactivated from "${v.resolve(r)}".`)),s.profile===void 0?console.log(a(`Run ${n.code(`cf auth login`)} to set up the default profile, or ${n.code(`cf auth create <name>`)} to create a named profile.`)):s.profile===`default`?console.log(i(`This directory now uses the default profile.`)):console.log(i(`Now using: ${s.profile} (${s.source}).`))}},T={command:`list`,describe:`List all auth profiles`,handler:e=>{y(e,`list`);let t=d(),n=t.bindings.read(),r={};for(let[e,t]of Object.entries(n))(r[t]??=[]).push(e);_(t.configs.list().map(e=>({name:e,boundDirectories:r[e]??[]})))}},E={command:`login`,describe:`Authenticate with Cloudflare`,builder:e=>e.option(`force`,{type:`boolean`,alias:`f`,description:`Force re-authentication even if already logged in`,default:!1}).option(`browser`,{type:`boolean`,description:`Open a browser to complete login (use --no-browser to print the URL instead)`,default:!0}).option(`scopes`,{type:`string`,array:!0,description:`The set of OAuth scopes to request`}),handler:async e=>{y(e,`login`,"Run `cf auth create <name>` to authenticate a named profile.");let t=p();if(t!==`default`&&console.log(r(`This directory has profile "${t}" active. \`cf auth login\` updates the default profile, not "${t}".\nTo re-authenticate "${t}", run \`cf auth create ${t}\`.`)),m(`default`),!e.force&&o()){if(await s()){let e=c();console.log(i(`You are already logged in.`)),console.log(`${n.info(`Config file:`)} ${n.muted(l())}`),e?.expiration_time&&console.log(`${n.info(`Token expires:`)} ${new Date(e.expiration_time).toLocaleString()}`),console.log(a(`Run ${n.code(`cf auth login --force`)} to re-authenticate, or ${n.code(`cf auth logout`)} to log out.`));return}console.log(r(`Existing tokens are invalid or expired. Starting fresh login...
2
+ import{g as e,l as t}from"./session-B8r8LNQN.mjs";import{a as n}from"./theme-DbNbIY4d.mjs";import{i as r,n as i,t as a}from"./ui-BrNwNHX9.mjs";import{a as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p,u as m}from"./oauth-B5k80sip.mjs";import{r as h,t as g}from"./auth-DX9KnJ0P.mjs";import{t as _}from"./output-B6fBFRqe.mjs";import v from"node:path";function y(e,t,n){if(!e.profile)return;let r=n?` ${n}`:``;throw Error(`The --profile flag cannot be used with \`cf auth ${t}\`.${r}`)}function b(){if(t({allowGlobalAuthKey:!1})!==void 0)throw Error(`Cannot manage auth profiles while CLOUDFLARE_API_TOKEN is set. Unset CLOUDFLARE_API_TOKEN and try again.`)}const x={command:`create <name>`,describe:`Create or re-authenticate a named auth profile`,builder:e=>e.positional(`name`,{type:`string`,description:`Name for the auth profile`,demandOption:!0}).option(`browser`,{type:`boolean`,description:`Open a browser to complete login (use --no-browser to print the URL instead)`,default:!0}).option(`scopes`,{type:`string`,array:!0,description:`The set of OAuth scopes to request`}),handler:async t=>{y(t,`create`,"Pass the profile name as the command argument: `cf auth create <name>`."),b(),e(t.name);let r=d().configs.exists(t.name);await u({browser:t.browser,scopes:t.scopes,profile:t.name}),console.log(i(r?`Profile "${t.name}" re-authenticated.`:`Profile "${t.name}" created.`)),console.log(a(`Run ${n.code(`cf auth activate ${t.name}`)} to use this profile in a directory.`))}},S={command:`delete <name>`,describe:`Delete a named auth profile`,builder:e=>e.positional(`name`,{type:`string`,description:`Name of the auth profile to delete`,demandOption:!0}),handler:async t=>{y(t,`delete`),b(),e(t.name);let r=d();if(!r.configs.exists(t.name))throw Error(`Profile "${t.name}" does not exist.`);let o=r.bindings.removeAllBindingsForProfile(t.name);if(o.length>0){console.log(i(`Removed directory bindings:`));for(let e of o)console.log(` ${e}`)}await f(t.name),r.configs.delete(t.name),console.log(i(`Profile "${t.name}" deleted.`));let s=r.bindings.getProfileForDirectory(process.cwd());s?console.log(i(`Active profile for this directory: ${s}.`)):r.configs.exists(`default`)?console.log(i(`This directory now uses the default profile.`)):console.log(a(`No active profile for this directory. Run ${n.code(`cf auth login`)} to set up the default profile, or ${n.code(`cf auth create <name>`)} to create a named profile.`))}},C={command:`activate <name> [dir]`,describe:`Bind a named auth profile to a directory`,builder:e=>e.positional(`name`,{type:`string`,description:`Name of the auth profile to activate`,demandOption:!0}).positional(`dir`,{type:`string`,description:`Directory to bind the profile to (defaults to current directory)`}),handler:t=>{y(t,`activate`,"Pass the profile name as the command argument: `cf auth activate <name>`."),b(),e(t.name);let n=d();if(!n.configs.exists(t.name))throw Error(`Profile "${t.name}" does not exist. Run \`cf auth create ${t.name}\` first.`);let r=t.dir??process.cwd();n.bindings.activate(t.name,r),console.log(i(`Profile "${t.name}" activated for "${v.resolve(r)}".`))}},w={command:`deactivate [dir]`,describe:`Remove the auth profile binding from a directory`,builder:e=>e.positional(`dir`,{type:`string`,description:`Directory to unbind (defaults to current directory). Must be the exact directory the profile was bound to.`}),handler:e=>{y(e,`deactivate`),b();let t=d(),r=e.dir??process.cwd(),{removedProfile:o,newResolution:s}=t.bindings.deactivate(r);console.log(i(`Profile "${o}" deactivated from "${v.resolve(r)}".`)),s.profile===void 0?console.log(a(`Run ${n.code(`cf auth login`)} to set up the default profile, or ${n.code(`cf auth create <name>`)} to create a named profile.`)):s.profile===`default`?console.log(i(`This directory now uses the default profile.`)):console.log(i(`Now using: ${s.profile} (${s.source}).`))}},T={command:`list`,describe:`List all auth profiles`,handler:e=>{y(e,`list`);let t=d(),n=t.bindings.read(),r={};for(let[e,t]of Object.entries(n))(r[t]??=[]).push(e);_(t.configs.list().map(e=>({name:e,boundDirectories:r[e]??[]})))}},E={command:`login`,describe:`Authenticate with Cloudflare`,builder:e=>e.option(`force`,{type:`boolean`,alias:`f`,description:`Force re-authentication even if already logged in`,default:!1}).option(`browser`,{type:`boolean`,description:`Open a browser to complete login (use --no-browser to print the URL instead)`,default:!0}).option(`scopes`,{type:`string`,array:!0,description:`The set of OAuth scopes to request`}),handler:async e=>{y(e,`login`,"Run `cf auth create <name>` to authenticate a named profile.");let t=p();if(t!==`default`&&console.log(r(`This directory has profile "${t}" active. \`cf auth login\` updates the default profile, not "${t}".\nTo re-authenticate "${t}", run \`cf auth create ${t}\`.`)),m(`default`),!e.force&&o()){if(await s()){let e=c();console.log(i(`You are already logged in.`)),console.log(`${n.info(`Config file:`)} ${n.muted(l())}`),e?.expiration_time&&console.log(`${n.info(`Token expires:`)} ${new Date(e.expiration_time).toLocaleString()}`),console.log(a(`Run ${n.code(`cf auth login --force`)} to re-authenticate, or ${n.code(`cf auth logout`)} to log out.`));return}console.log(r(`Existing tokens are invalid or expired. Starting fresh login...
3
3
  `))}else e.force&&o()&&console.log(i(`Re-authenticating...
4
4
  `));if(console.log(i(`Starting OAuth login flow...
5
5
  `)),!await u({browser:e.browser,scopes:e.scopes,profile:`default`})){console.log(r(`CLOUDFLARE_API_TOKEN is set and takes precedence. Unset it to log in via OAuth.`));return}let d=c();console.log(`${n.info(`Config file:`)} ${n.muted(l())}`),d?.scopes&&console.log(`${n.info(`Scopes:`)} ${d.scopes.join(`, `)}`),d?.expiration_time&&console.log(`${n.info(`Token expires:`)} ${new Date(d.expiration_time).toLocaleString()}`)}},D={command:`logout`,describe:`Log out and remove stored credentials`,handler:async e=>{y(e,`logout`,"Run `cf auth delete <name>` to remove a named profile.");let t=p();t!==`default`&&console.log(r(`This directory has profile "${t}" active. \`cf auth logout\` removes the default profile's token, not "${t}".\nTo delete "${t}", run \`cf auth delete ${t}\`.`)),m(`default`);let s=o(),c=!!process.env.CLOUDFLARE_API_TOKEN;if(!s){c?(console.log(i(`No cf OAuth credentials found, but CLOUDFLARE_API_TOKEN environment variable is set.`)),console.log(i(`Unset it with: unset CLOUDFLARE_API_TOKEN`))):(console.log(i(`You are not currently logged in.`)),console.log(a(`Run ${n.code(`cf auth login`)} to authenticate.`)));return}console.log(i(`Logging out...`)),await f(`default`),console.log(`${n.info(`Removed:`)} OAuth tokens from ${n.muted(l())}`),c&&(console.log(``),console.log(r(`CLOUDFLARE_API_TOKEN environment variable is still set.`)),console.log(i(`You will remain authenticated via the env var. Unset it with: unset CLOUDFLARE_API_TOKEN`)))}},O={command:`whoami`,describe:`Show current user and authentication status`,builder:e=>e,handler:async e=>{let t=process.env.CLOUDFLARE_API_TOKEN,n=c(),r;r=t?`CLOUDFLARE_API_TOKEN environment variable`:n?.oauth_token?`OAuth token from ${l()}`:`none`;let i;try{i=await h()}catch{_({authenticated:!1,error:`Not logged in`});return}let a=g({apiToken:i}),o=!1,s;try{let e=await a.user.get();o=!0,e&&`email`in e&&typeof e.email==`string`&&(s=e.email)}catch(e){o=!1,process.env.DEBUG&&console.error(`Token verification error:`,e)}let u={authenticated:!0,authSource:r,tokenValid:o,...s&&{email:s}};n?.oauth_token&&(u.scopes=n.scopes,u.expiresAt=n.expiration_time),_(u)}},k={command:`auth`,describe:`Manage authentication and profiles`,builder:e=>e.command(E).command(D).command(O).command(x).command(S).command(C).command(w).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{k as default};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{t as r}from"./output-B6fBFRqe.mjs";import{n as i,t as a}from"./progress-CL8I-7YK.mjs";import{t as o}from"./local-CYc9q7l2.mjs";function s(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const c={command:`get`,describe:`Gets the current billing profile for the account.`,builder:s,handler:async s=>{if(s.dryRun){i({command:`cf billing profiles get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/billing/profile`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Loading`,async()=>c.billing.profiles.get({account_id:l})),{successLabel:`Loaded`})}},l={command:`profiles`,describe:`Billing profile with payment method, address, and invoice preferences`,builder:e=>e.command(c).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function u(e){return e.option(`from`,{type:`string`,description:`Start date for the usage query (ISO 8601).`}).option(`to`,{type:`string`,description:`End date for the usage query (ISO 8601).`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const d={command:`paygo`,describe:`Returns billable usage data for PayGo (self-serve) accounts. When no query parameters are provided, returns usage for the current billing period.`,builder:u,handler:async s=>{let c={from:s.from,to:s.to};if(s.dryRun){i({command:`cf billing usage paygo`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/paygo-usage`,pathParams:{},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await e();s.accountId=u,r(await a(`Loading`,async()=>l.billing.usage.paygo({account_id:u,...c})),{successLabel:`Loaded`})}};function f(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const p={command:`paygo_info`,describe:`Returns high-level usage information for the account, including coverage, and subscription metadata.`,builder:f,handler:async s=>{if(s.dryRun){i({command:`cf billing usage paygo_info`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/paygo-usage-info`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Loading`,async()=>c.billing.usage.paygoInfo({account_id:l})),{successLabel:`Loaded`})}},m={command:`usage`,describe:`Operations for usage`,builder:e=>e.command(d).command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},h={command:`billing`,describe:`Account billing profiles and usage data for Cloudflare subscriptions and add-on services`,builder:e=>e.command(l).command(m).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{h as default};
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import{N as e}from"./oauth-B5k80sip.mjs";import{n as t}from"./auth-DX9KnJ0P.mjs";import{n,t as r}from"./body-parser-DWSy7uZ8.mjs";import{t as i}from"./output-B6fBFRqe.mjs";import{n as a,t as o}from"./progress-CL8I-7YK.mjs";import{n as s}from"./input-validation-_fMCApaH.mjs";import{n as c,r as l}from"./prompt-q3B7sM2A.mjs";function u(e){return e.option(`description`,{type:`string`,description:`The description field`}).option(`expression`,{type:`string`,description:`Wirefilter expression describing the traffic being reported.`}).option(`first-request-seen-at`,{type:`string`,description:`The first_request_seen_at field`}).option(`last-request-seen-at`,{type:`string`,description:`The last_request_seen_at field`}).option(`requests`,{type:`number`,description:`The requests field`}).option(`subtype`,{type:`string`,description:`The subtype field`}).option(`type`,{type:`string`,description:`Type of feedback report.`,choices:[`false_positive`,`false_negative`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const d={command:`create`,describe:"Submit a feedback report for the specified zone. Use `type` to indicate whether the report is a false positive (good traffic flagged as bot) or a false negative (bot traffic missed). Furthermore, you can also use `expression` as a wirefilter to identify the affected traffic sample. See more accepted API fields and expression types at https://developers.cloudflare.com/bots/concepts/feedback-loop/#api-fields and https://developers.cloudflare.com/bots/concepts/feedback-loop/#expression-fields, respectively.",builder:u,handler:async u=>{if(u.dryRun){a({command:`cf bot-management feedback create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${u.zone??u.zoneId??`<zone>`}/bot_management/feedback`,pathParams:{"zone-id":String(u.zone??u[`zone-id`]??``)},bodyKind:`json`,body:u.body===void 0?r({description:s(u.description,`description`,`text`),expression:s(u.expression,`expression`,`text`),first_request_seen_at:s(u[`first-request-seen-at`],`first-request-seen-at`,`text`),last_request_seen_at:s(u[`last-request-seen-at`],`last-request-seen-at`,`text`),requests:u.requests,subtype:s(u.subtype,`subtype`,`text`),type:s(u.type,`type`,`text`)}):n(u.body)});return}let d=await t(u),f=await e({zone:u.zone},d,{quiet:u.quiet});if(u.zoneId=f,u.body){let e=n(u.body);i(await o(`Creating`,async()=>d.botManagement.feedback.create({body:e,zone_id:f})),{successLabel:`Created`});return}if(u.description===void 0&&(u.description=await l(`description`,`The description field`)),u.expression===void 0&&(u.expression=await l(`expression`,`Wirefilter expression describing the traffic being reported.`)),u[`first-request-seen-at`]===void 0&&(u[`first-request-seen-at`]=await l(`first-request-seen-at`,`The first_request_seen_at field`)),u[`last-request-seen-at`]===void 0&&(u[`last-request-seen-at`]=await l(`last-request-seen-at`,`The last_request_seen_at field`)),u.requests===void 0)throw Error(`--requests is required (or pass --body with this field set).`);u.type===void 0&&(u.type=await c(`type`,`Type of feedback report.`,[`false_positive`,`false_negative`]));let p=r({description:s(u.description,`description`,`text`),expression:s(u.expression,`expression`,`text`),first_request_seen_at:s(u[`first-request-seen-at`],`first-request-seen-at`,`text`),last_request_seen_at:s(u[`last-request-seen-at`],`last-request-seen-at`,`text`),requests:u.requests,subtype:s(u.subtype,`subtype`,`text`),type:s(u.type,`type`,`text`)});i(await o(`Creating`,async()=>d.botManagement.feedback.create({body:p,zone_id:f})),{successLabel:`Created`})}};function f(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const p={command:`list`,describe:`Returns all feedback reports previously submitted for the specified zone. Feedback reports help improve detection by sharing samples of traffic that were misclassified as bots or humans.`,builder:f,handler:async n=>{if(n.dryRun){a({command:`cf bot-management feedback list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${n.zone??n.zoneId??`<zone>`}/bot_management/feedback`,pathParams:{"zone-id":String(n.zone??n[`zone-id`]??``)},bodyKind:`none`});return}let r=await t(n),s=await e({zone:n.zone},r,{quiet:n.quiet});n.zoneId=s,i(await o(`Loading`,async()=>r.botManagement.feedback.list({zone_id:s})),{successLabel:`Loaded`})}},m={command:`feedback`,describe:`Feedback operations`,builder:e=>e.command(d).command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function h(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`get`,describe:`Retrieve a zone's Bot Management Config`,builder:h,handler:async n=>{if(n.dryRun){a({command:`cf bot-management get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${n.zone??n.zoneId??`<zone>`}/bot_management`,pathParams:{"zone-id":String(n.zone??n[`zone-id`]??``)},bodyKind:`none`});return}let r=await t(n),s=await e({zone:n.zone},r,{quiet:n.quiet});n.zoneId=s,i(await o(`Loading`,async()=>r.botManagement.get({zone_id:s})),{successLabel:`Loaded`})}};function _(e){return e.option(`ai-bots-protection`,{type:`string`,description:`Enable rule to block AI Scrapers and Crawlers.`,choices:[`block`,`disabled`,`only_on_ad_pages`]}).option(`cf-robots-variant`,{type:`string`,description:`Specifies the Robots Access Control License variant to use.`,choices:[`off`,`policy_only`]}).option(`content-bots-protection`,{type:`string`,description:`Enable rule to block content bots. When enabled, blocks automated traffic with low bot scores, excluding safe verified bot categories. Exceptions should be managed via skip rules.`,choices:[`block`,`disabled`]}).option(`crawler-protection`,{type:`string`,description:`Enable rule to punish AI Scrapers and Crawlers via a link maze.`,choices:[`enabled`,`disabled`]}).option(`enable-js`,{type:`boolean`,description:`Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/).`}).option(`is-robots-txt-managed`,{type:`boolean`,description:`Enable cloudflare managed robots.txt. If an existing robots.txt is detected, then managed robots.txt will be prepended to the existing robots.txt.`}).option(`fight-mode`,{type:`boolean`,description:`Whether to enable Bot Fight Mode.`}).option(`stale-zone-configuration-optimize-wordpress`,{type:`boolean`,description:`Indicates that the zone's wordpress optimization for SBFM is turned on.`}).option(`stale-zone-configuration-sbfm-definitely-automated`,{type:`string`,description:`Indicates that the zone's definitely automated requests are being blocked or challenged.`}).option(`stale-zone-configuration-sbfm-likely-automated`,{type:`string`,description:`Indicates that the zone's likely automated requests are being blocked or challenged.`}).option(`stale-zone-configuration-sbfm-static-resource-protection`,{type:`string`,description:`Indicates that the zone's static resource protection is turned on.`}).option(`stale-zone-configuration-sbfm-verified-bots`,{type:`string`,description:`Indicates that the zone's verified bot requests are being blocked.`}).option(`stale-zone-configuration-suppress-session-score`,{type:`boolean`,description:`Indicates that the zone's session score tracking is disabled.`}).option(`stale-zone-configuration-fight-mode`,{type:`boolean`,description:`Indicates that the zone's Bot Fight Mode is turned on.`}).option(`optimize-wordpress`,{type:`boolean`,description:`Whether to optimize Super Bot Fight Mode protections for Wordpress.`}).option(`sbfm-definitely-automated`,{type:`string`,description:`Super Bot Fight Mode (SBFM) action to take on definitely automated requests.`,choices:[`allow`,`block`,`managed_challenge`]}).option(`sbfm-static-resource-protection`,{type:`boolean`,description:`Super Bot Fight Mode (SBFM) to enable static resource protection.
3
+ Enable if static resources on your application need bot protection.
4
+ Note: Static resource protection can also result in legitimate traffic being blocked.
5
+ `}).option(`sbfm-verified-bots`,{type:`string`,description:`Super Bot Fight Mode (SBFM) action to take on verified bots requests.`,choices:[`allow`,`block`]}).option(`sbfm-likely-automated`,{type:`string`,description:`Super Bot Fight Mode (SBFM) action to take on likely automated requests.`,choices:[`allow`,`block`,`managed_challenge`]}).option(`auto-update-model`,{type:`boolean`,description:`Automatically update to the newest bot detection models created by Cloudflare as they are released. [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes)`}).option(`bm-cookie-enabled`,{type:`boolean`,description:`Indicates that the bot management cookie can be placed on end user devices accessing the site. Defaults to true`}).option(`suppress-session-score`,{type:`boolean`,description:`Whether to disable tracking the highest bot score for a session in the Bot Management cookie.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const v={command:`update`,describe:'Updates the Bot Management configuration for a zone. This API is used to update: - **Bot Fight Mode** - **Super Bot Fight Mode** - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more information on the different plans \\ If you recently upgraded or downgraded your plan, refer to the following examples to clean up old configurations. Copy and paste the example body to remove old zone configurations based on your current plan. #### Clean up configuration for Bot Fight Mode plan ```json { "sbfm_likely_automated": "allow", "sbfm_definitely_automated": "allow", "sbfm_verified_bots": "allow", "sbfm_static_resource_protection": false, "optimize_wordpress": false, "suppress_session_score": false } ``` #### Clean up configuration for SBFM Pro plan ```json { "sbfm_likely_automated": "allow", "fight_mode": false } ``` #### Clean up configuration for SBFM Biz plan ```json { "fight_mode": false } ``` #### Clean up configuration for BM Enterprise Subscription plan It is strongly recommended that you ensure you have [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to protect your zone before disabling the SBFM rules. Without these protections, your zone is vulnerable to attacks. ```json { "sbfm_likely_automated": "allow", "sbfm_definitely_automated": "allow", "sbfm_verified_bots": "allow", "sbfm_static_resource_protection": false, "optimize_wordpress": false, "fight_mode": false } ```',builder:_,handler:async c=>{if(c.dryRun){a({command:`cf bot-management update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${c.zone??c.zoneId??`<zone>`}/bot_management`,pathParams:{"zone-id":String(c.zone??c[`zone-id`]??``)},bodyKind:`json`,body:c.body===void 0?r({ai_bots_protection:s(c[`ai-bots-protection`],`ai-bots-protection`,`text`),cf_robots_variant:s(c[`cf-robots-variant`],`cf-robots-variant`,`text`),content_bots_protection:s(c[`content-bots-protection`],`content-bots-protection`,`text`),crawler_protection:s(c[`crawler-protection`],`crawler-protection`,`text`),enable_js:c[`enable-js`],is_robots_txt_managed:c[`is-robots-txt-managed`],fight_mode:c[`fight-mode`],stale_zone_configuration:{optimize_wordpress:c[`stale-zone-configuration-optimize-wordpress`],sbfm_definitely_automated:s(c[`stale-zone-configuration-sbfm-definitely-automated`],`stale-zone-configuration-sbfm-definitely-automated`,`text`),sbfm_likely_automated:s(c[`stale-zone-configuration-sbfm-likely-automated`],`stale-zone-configuration-sbfm-likely-automated`,`text`),sbfm_static_resource_protection:s(c[`stale-zone-configuration-sbfm-static-resource-protection`],`stale-zone-configuration-sbfm-static-resource-protection`,`text`),sbfm_verified_bots:s(c[`stale-zone-configuration-sbfm-verified-bots`],`stale-zone-configuration-sbfm-verified-bots`,`text`),suppress_session_score:c[`stale-zone-configuration-suppress-session-score`],fight_mode:c[`stale-zone-configuration-fight-mode`]},optimize_wordpress:c[`optimize-wordpress`],sbfm_definitely_automated:s(c[`sbfm-definitely-automated`],`sbfm-definitely-automated`,`text`),sbfm_static_resource_protection:c[`sbfm-static-resource-protection`],sbfm_verified_bots:s(c[`sbfm-verified-bots`],`sbfm-verified-bots`,`text`),sbfm_likely_automated:s(c[`sbfm-likely-automated`],`sbfm-likely-automated`,`text`),auto_update_model:c[`auto-update-model`],bm_cookie_enabled:c[`bm-cookie-enabled`],suppress_session_score:c[`suppress-session-score`]}):n(c.body)});return}let l=await t(c),u=await e({zone:c.zone},l,{quiet:c.quiet});if(c.zoneId=u,c.body){let e=n(c.body);i(await o(`Updating`,async()=>l.botManagement.update({body:e,zone_id:u})),{successLabel:`Updated`});return}let d=r({ai_bots_protection:s(c[`ai-bots-protection`],`ai-bots-protection`,`text`),cf_robots_variant:s(c[`cf-robots-variant`],`cf-robots-variant`,`text`),content_bots_protection:s(c[`content-bots-protection`],`content-bots-protection`,`text`),crawler_protection:s(c[`crawler-protection`],`crawler-protection`,`text`),enable_js:c[`enable-js`],is_robots_txt_managed:c[`is-robots-txt-managed`],fight_mode:c[`fight-mode`],stale_zone_configuration:{optimize_wordpress:c[`stale-zone-configuration-optimize-wordpress`],sbfm_definitely_automated:s(c[`stale-zone-configuration-sbfm-definitely-automated`],`stale-zone-configuration-sbfm-definitely-automated`,`text`),sbfm_likely_automated:s(c[`stale-zone-configuration-sbfm-likely-automated`],`stale-zone-configuration-sbfm-likely-automated`,`text`),sbfm_static_resource_protection:s(c[`stale-zone-configuration-sbfm-static-resource-protection`],`stale-zone-configuration-sbfm-static-resource-protection`,`text`),sbfm_verified_bots:s(c[`stale-zone-configuration-sbfm-verified-bots`],`stale-zone-configuration-sbfm-verified-bots`,`text`),suppress_session_score:c[`stale-zone-configuration-suppress-session-score`],fight_mode:c[`stale-zone-configuration-fight-mode`]},optimize_wordpress:c[`optimize-wordpress`],sbfm_definitely_automated:s(c[`sbfm-definitely-automated`],`sbfm-definitely-automated`,`text`),sbfm_static_resource_protection:c[`sbfm-static-resource-protection`],sbfm_verified_bots:s(c[`sbfm-verified-bots`],`sbfm-verified-bots`,`text`),sbfm_likely_automated:s(c[`sbfm-likely-automated`],`sbfm-likely-automated`,`text`),auto_update_model:c[`auto-update-model`],bm_cookie_enabled:c[`bm-cookie-enabled`],suppress_session_score:c[`suppress-session-score`]});i(await o(`Updating`,async()=>l.botManagement.update({body:d,zone_id:u})),{successLabel:`Updated`})}},y={command:`bot-management`,describe:`Bot detection and mitigation settings — configure bot scores, JavaScript detections, and challenge behavior`,builder:e=>e.command(g).command(v).command(m).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{t as r}from"./output-B6fBFRqe.mjs";import{n as i,t as a}from"./progress-CL8I-7YK.mjs";import{t as o}from"./local-CYc9q7l2.mjs";import{t as s}from"./prompt-q3B7sM2A.mjs";import{t as c}from"./cli-types-DGgEbf8K.mjs";function l(e){return e.positional(`asn-id`,{type:`string`,description:`Asn ID`,demandOption:!0}).option(`date`,{type:`string`,description:`Date`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const u={command:`day-report <asn-id>`,describe:`Gets all the data the botnet tracking database has for a given ASN registered to user account for given date. If no date is given, it will return results for the previous day.`,builder:c(l),handler:async s=>{let c={date:s.date};if(s.dryRun){i({command:`cf botnet-feed asn day-report`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/botnet_feed/asn/${s[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(s[`asn-id`]))}/day_report`,pathParams:{"asn-id":String(s[`asn-id`]??``)},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await e();s.accountId=u,r(await a(`Loading`,async()=>l.botnetFeed.asn.dayReport({account_id:u,asn_id:s[`asn-id`],...c})),{successLabel:`Loaded`})}};function d(e){return e.positional(`asn-id`,{type:`string`,description:`Asn ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const f={command:`full-report <asn-id>`,describe:`Gets all the data the botnet threat feed tracking database has for a given ASN registered to user account.`,builder:c(d),handler:async s=>{if(s.dryRun){i({command:`cf botnet-feed asn full-report`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/botnet_feed/asn/${s[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(s[`asn-id`]))}/full_report`,pathParams:{"asn-id":String(s[`asn-id`]??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Loading`,async()=>c.botnetFeed.asn.fullReport({account_id:l,asn_id:s[`asn-id`]})),{successLabel:`Loaded`})}},p={command:`asn`,describe:`ASN-level botnet activity data showing networks with known C2 infrastructure`,builder:e=>e.command(u).command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function m(e){return e.positional(`asn-id`,{type:`string`,description:`Asn ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const h={command:`delete <asn-id>`,describe:`Delete an ASN from botnet threat feed for a given user.`,builder:c(m),handler:async c=>{if(c.dryRun){i({command:`cf botnet-feed configs asn delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/botnet_feed/configs/asn/${c[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(c[`asn-id`]))}`,pathParams:{"asn-id":String(c[`asn-id`]??``)},bodyKind:`none`});return}let l=await n(c),u=c.local?o:await e();if(c.accountId=u,!await s({force:!!c.force})){process.stderr.write(`Aborted.
3
+ `);return}r(await a(`Deleting`,async()=>l.botnetFeed.configs.asn.delete({account_id:u,asn_id:c[`asn-id`]})),{successLabel:`Deleted`})}};function g(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get`,describe:`Gets a list of all ASNs registered for a user for the DDoS Botnet Feed API.`,builder:g,handler:async s=>{if(s.dryRun){i({command:`cf botnet-feed configs asn get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/botnet_feed/configs/asn`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await e();s.accountId=l,r(await a(`Loading`,async()=>c.botnetFeed.configs.asn.get({account_id:l})),{successLabel:`Loaded`})}},v={command:`asn`,describe:`Botnet feed subscription configuration and notification preferences`,builder:e=>e.command(h).command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},y={command:`configs`,describe:`Operations for configs`,builder:e=>e.command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},b={command:`botnet-feed`,describe:`Botnet threat intelligence feeds — IP and ASN-level data on known command-and-control infrastructure`,builder:e=>e.command(p).command(y).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{b as default};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{n as r,t as i}from"./body-parser-DWSy7uZ8.mjs";import{t as a}from"./output-B6fBFRqe.mjs";import{n as o,t as s}from"./progress-CL8I-7YK.mjs";import{n as c}from"./input-validation-_fMCApaH.mjs";import{t as l}from"./local-CYc9q7l2.mjs";import{r as u,t as d}from"./prompt-q3B7sM2A.mjs";import{t as f}from"./cli-types-DGgEbf8K.mjs";function p(e){return e.option(`show-historic`,{type:`string`,description:`Include scanned images without domain metadata (historic data). Default: false (only show images with domain)`}).option(`download`,{type:`string`,description:`If true, include base64-encoded image data in the response`}).option(`image-data`,{type:`string`,description:`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`}).option(`score-threshold`,{type:`number`,description:`Minimum similarity score threshold for matches (0-1, default: 0)`,default:0}).option(`top-k`,{type:`number`,description:`Number of closest matches to return (1-100, default: 10)`,default:10}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const m={command:`submit`,describe:`Submit an image and find the n closest matches from the scanned images index without creating any match records. Returns similarity scores and metadata for each match.`,builder:p,handler:async d=>{let f={showHistoric:d[`show-historic`],download:d.download};if(d.dryRun){o({command:`cf brand-protection submit`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/search`,pathParams:{},query:f,bodyKind:`json`,body:d.body===void 0?i({image_data:c(d[`image-data`],`image-data`,`text`),score_threshold:d[`score-threshold`],top_k:d[`top-k`]}):r(d.body)});return}let p=await n(d),m=d.local?l:await e();if(d.accountId=m,d.body){let e=r(d.body);new URLSearchParams(Object.entries(f).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.brandProtection.submit({...e,account_id:m,...f})),{successLabel:`Created`});return}d[`image-data`]===void 0&&(d[`image-data`]=await u(`image-data`,`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`));let h=i({image_data:c(d[`image-data`],`image-data`,`text`),score_threshold:d[`score-threshold`],top_k:d[`top-k`]});new URLSearchParams(Object.entries(f).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.brandProtection.submit({...h,account_id:m,...f})),{successLabel:`Created`})}};function h(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`url-info`,describe:`Get the total number of saved brand protection queries (domain + logo) for an account`,builder:h,handler:async r=>{if(r.dryRun){o({command:`cf brand-protection url-info`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cloudforce-one/v2/brand-protection/total-queries`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.brandProtection.urlInfo({account_id:c})),{successLabel:`Loaded`})}};function _(e){return e.option(`offset`,{type:`string`,description:`Offset`}).option(`limit`,{type:`string`,description:`Limit`}).option(`query-id`,{type:`string`,description:`Query ID`,demandOption:!0}).option(`download`,{type:`string`,description:`Download`}).option(`order-by`,{type:`string`,description:`Column to sort by. Options: 'matchedAt', 'domain', 'similarityScore', or 'registrar'`,choices:[`matchedAt`,`domain`,`similarityScore`,`registrar`]}).option(`order`,{type:`string`,description:`Sort order. Options: 'asc' (ascending) or 'desc' (descending)`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`get`,describe:`Get paginated list of logo matches for a specific brand protection logo query`,builder:f(_),handler:async r=>{let i={offset:r.offset,limit:r.limit,query_id:r[`query-id`],download:r.download,orderBy:r[`order-by`],order:r.order};if(r.dryRun){o({command:`cf brand-protection v2 logo-matches get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/matches`,pathParams:{},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.brandProtection.v2.logoMatches.get({account_id:u,...i})),{successLabel:`Loaded`})}},y={command:`logo-matches`,describe:`Detected visual logo matches found on potentially infringing websites`,builder:e=>e.command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function b(e){return e.option(`image-data`,{type:`string`,description:`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`}).option(`search-lookback`,{type:`boolean`,description:`If true, search historic scanned images for matches above the similarity threshold`,default:!0}).option(`similarity-threshold`,{type:`number`,description:`Minimum similarity score (0-1) required for visual matches`}).option(`tag`,{type:`string`,description:`Unique identifier for the logo query`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const x={command:`create`,describe:`Create a new saved brand protection logo query for visual similarity matching`,builder:b,handler:async d=>{if(d.dryRun){o({command:`cf brand-protection v2 logos create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/queries`,pathParams:{},bodyKind:`json`,body:d.body===void 0?i({image_data:c(d[`image-data`],`image-data`,`text`),search_lookback:d[`search-lookback`],similarity_threshold:d[`similarity-threshold`],tag:c(d.tag,`tag`,`text`)}):r(d.body)});return}let f=await n(d),p=d.local?l:await e();if(d.accountId=p,d.body){let e=r(d.body);a(await s(`Creating`,async()=>f.brandProtection.v2.logos.create({...e,account_id:p})),{successLabel:`Created`});return}if(d[`image-data`]===void 0&&(d[`image-data`]=await u(`image-data`,`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`)),d[`similarity-threshold`]===void 0)throw Error(`--similarity-threshold is required (or pass --body with this field set).`);d.tag===void 0&&(d.tag=await u(`tag`,`Unique identifier for the logo query`));let m=i({image_data:c(d[`image-data`],`image-data`,`text`),search_lookback:d[`search-lookback`],similarity_threshold:d[`similarity-threshold`],tag:c(d.tag,`tag`,`text`)});a(await s(`Creating`,async()=>f.brandProtection.v2.logos.create({...m,account_id:p})),{successLabel:`Created`})}};function S(e){return e.positional(`query-id`,{type:`string`,description:`Query ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const C={command:`delete <query-id>`,describe:`Delete a saved brand protection logo query. Returns 404 if the query ID doesn't exist.`,builder:S,handler:async r=>{if(r.dryRun){o({command:`cf brand-protection v2 logos delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/queries/${r[`query-id`]==null?`<query-id>`:encodeURIComponent(String(r[`query-id`]))}`,pathParams:{"query-id":String(r[`query-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await d({force:!!r.force})){process.stderr.write(`Aborted.
3
+ `);return}a(await s(`Deleting`,async()=>i.brandProtection.v2.logos.delete({account_id:c,query_id:r[`query-id`]})),{successLabel:`Deleted`})}};function w(e){return e.option(`id`,{type:`string`,description:`Optional query ID to retrieve a specific logo query`}).option(`download`,{type:`string`,description:`If true, include base64-encoded image data in the response`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`get`,describe:`Get all saved brand protection logo queries for an account. Optionally specify id to get a single query. Set download=true to include base64-encoded image data.`,builder:w,handler:async r=>{let i={id:r.id,download:r.download};if(r.dryRun){o({command:`cf brand-protection v2 logos get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/queries`,pathParams:{},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.brandProtection.v2.logos.get({account_id:u,...i})),{successLabel:`Loaded`})}},E={command:`logos`,describe:`Brand monitoring queries that define search patterns for detecting brand abuse`,builder:e=>e.command(x).command(C).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`offset`,{type:`string`,description:`Offset`}).option(`limit`,{type:`string`,description:`Limit`}).option(`query-id`,{type:`string`,description:`Query ID or comma-separated list of Query IDs. When multiple IDs are provided, matches are deduplicated across queries and each match includes a match_details array with per-match query metadata and dismissed state.`,demandOption:!0}).option(`include-domain-id`,{type:`string`,description:`Include domain ID`}).option(`include-dismissed`,{type:`string`,description:`Include dismissed`}).option(`domain-search`,{type:`string`,description:`Filter matches by domain name (substring match)`}).option(`order-by`,{type:`string`,description:`Column to sort by. Options: 'domain', 'first_seen', or 'registrar'`,choices:[`domain`,`first_seen`,`registrar`]}).option(`order`,{type:`string`,description:`Sort order. Options: 'asc' (ascending) or 'desc' (descending)`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`get`,describe:`Get paginated list of domain matches for one or more brand protection queries. When multiple query_ids are provided (comma-separated), matches are deduplicated across queries and each match includes a match_details array with per-match query metadata and individual dismissed state.`,builder:f(D),handler:async r=>{let i={offset:r.offset,limit:r.limit,query_id:r[`query-id`],include_domain_id:r[`include-domain-id`],include_dismissed:r[`include-dismissed`],domain_search:r[`domain-search`],orderBy:r[`order-by`],order:r.order};if(r.dryRun){o({command:`cf brand-protection v2 matches get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cloudforce-one/v2/brand-protection/domain/matches`,pathParams:{},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.brandProtection.v2.matches.get({account_id:u,...i})),{successLabel:`Loaded`})}},k={command:`matches`,describe:`Detected brand abuse matches from monitoring queries with evidence downloads`,builder:e=>e.command(O).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function A(e){return e.option(`id`,{type:`string`,description:`ID`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const j={command:`get`,describe:`Get all saved brand protection queries for an account`,builder:A,handler:async r=>{let i={id:r.id};if(r.dryRun){o({command:`cf brand-protection v2 queries get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cloudforce-one/v2/brand-protection/domain/queries`,pathParams:{},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.brandProtection.v2.queries.get({account_id:u,...i})),{successLabel:`Loaded`})}},M={command:`queries`,describe:`Brand monitoring queries that define search patterns for detecting brand abuse`,builder:e=>e.command(j).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},N={command:`v2`,describe:`Operations for v2`,builder:e=>e.command(y).command(E).command(k).command(M).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},P={command:`brand-protection`,describe:`Monitor the Internet for phishing sites, lookalike domains, and unauthorized use of your brand assets`,builder:e=>e.command(m).command(g).command(N).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{P as default};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{i as n,n as r}from"./auth-DX9KnJ0P.mjs";import{n as i}from"./body-parser-DWSy7uZ8.mjs";import{t as a}from"./output-B6fBFRqe.mjs";import{n as o,t as s}from"./progress-CL8I-7YK.mjs";import{t as c}from"./local-CYc9q7l2.mjs";import{t as l}from"./prompt-q3B7sM2A.mjs";import{t as u}from"./cli-types-DGgEbf8K.mjs";import{n as d,t as f}from"./raw-fetch-bIXC9D1m.mjs";function p(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ee={command:`create`,describe:"Returns the page's accessibility tree. Use `interestingOnly` to only return semantically meaningful nodes; use `root` to scope the tree to a CSS-selector-anchored subtree. Control page loading with `gotoOptions` and `waitFor*` options.",builder:p,handler:async l=>{let u={cacheTTL:l[`cache-ttl`]};if(l.dryRun){o({command:`cf browser-rendering accessibilityTree create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/accessibilityTree`,pathParams:{},query:u,bodyKind:`json`,body:l.body===void 0?void 0:i(l.body)});return}let d=await r(l),f=l.local?c:await e();if(l.accountId=f,l.body){let e=i(l.body);new URLSearchParams(Object.entries(u).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>d.browserRendering.accessibilityTree.create({body:e,account_id:f,...u})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>n(d,`POST`,`/accounts/${f}/browser-rendering/accessibilityTree`,{query:u})),{successLabel:`Created`})}},m={command:`accessibilityTree`,describe:`Operations for accessibilityTree`,builder:e=>e.command(ee).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function h(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const g={command:`create`,describe:"Fetches rendered HTML content from provided URL or HTML. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.",builder:h,handler:async l=>{let u={cacheTTL:l[`cache-ttl`]};if(l.dryRun){o({command:`cf browser-rendering content create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/content`,pathParams:{},query:u,bodyKind:`json`,body:l.body===void 0?void 0:i(l.body)});return}let d=await r(l),f=l.local?c:await e();if(l.accountId=f,l.body){let e=i(l.body);new URLSearchParams(Object.entries(u).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>d.browserRendering.content.create({body:e,account_id:f,...u})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>n(d,`POST`,`/accounts/${f}/browser-rendering/content`,{query:u})),{successLabel:`Created`})}},_={command:`content`,describe:`Operations for content`,builder:e=>e.command(g).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function v(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const y={command:`create`,describe:"Starts a crawl job for the provided URL and its children. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.",builder:v,handler:async l=>{let u={cacheTTL:l[`cache-ttl`]};if(l.dryRun){o({command:`cf browser-rendering crawl create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/crawl`,pathParams:{},query:u,bodyKind:`json`,body:l.body===void 0?void 0:i(l.body)});return}let d=await r(l),f=l.local?c:await e();if(l.accountId=f,l.body){let e=i(l.body);new URLSearchParams(Object.entries(u).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>d.browserRendering.crawl.create({body:e,account_id:f,...u})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>n(d,`POST`,`/accounts/${f}/browser-rendering/crawl`,{query:u})),{successLabel:`Created`})}};function b(e){return e.positional(`job-id`,{type:`string`,description:`The ID of the crawl job to cancel.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const x={command:`delete <job-id>`,describe:`Cancels an ongoing crawl job by setting its status to cancelled and stopping all queued URLs.`,builder:b,handler:async n=>{if(n.dryRun){o({command:`cf browser-rendering crawl delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/crawl/${n[`job-id`]==null?`<job-id>`:encodeURIComponent(String(n[`job-id`]))}`,pathParams:{"job-id":String(n[`job-id`]??``)},bodyKind:`none`});return}let i=await r(n),u=n.local?c:await e();if(n.accountId=u,!await l({force:!!n.force})){process.stderr.write(`Aborted.
3
+ `);return}a(await s(`Deleting`,async()=>i.browserRendering.crawl.delete({account_id:u,job_id:n[`job-id`]})),{successLabel:`Deleted`})}};function S(e){return e.positional(`job-id`,{type:`string`,description:`Crawl job ID.`,demandOption:!0}).option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`status`,{type:`string`,description:`Filter by URL status.`,choices:[`queued`,`errored`,`completed`,`disallowed`,`skipped`,`cancelled`]}).option(`cursor`,{type:`number`,description:`Cursor for pagination.`}).option(`limit`,{type:`number`,description:`Limit for pagination.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const C={command:`get <job-id>`,describe:`Returns the result of a crawl job.`,builder:u(S),handler:async n=>{let i={cacheTTL:n[`cache-ttl`],status:n.status,cursor:n.cursor,limit:n.limit};if(n.dryRun){o({command:`cf browser-rendering crawl get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/crawl/${n[`job-id`]==null?`<job-id>`:encodeURIComponent(String(n[`job-id`]))}`,pathParams:{"job-id":String(n[`job-id`]??``)},query:i,bodyKind:`none`});return}let l=await r(n),u=n.local?c:await e();n.accountId=u,a(await s(`Loading`,async()=>l.browserRendering.crawl.get({account_id:u,job_id:n[`job-id`],...i})),{successLabel:`Loaded`})}},w={command:`crawl`,describe:`Operations for crawl`,builder:e=>e.command(y).command(x).command(C).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function T(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID to connect to.`,demandOption:!0}).option(`keep-alive`,{type:`number`,description:`Keep-alive time in ms (only valid when acquiring new session).`}).option(`lab`,{type:`boolean`,description:`Use experimental browser.`}).option(`recording`,{type:`boolean`,description:`Recording`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const E={command:`connect <session-id>`,describe:`Establishes a WebSocket connection to an existing browser session.`,builder:T,handler:async n=>{let i={keep_alive:n[`keep-alive`],lab:n.lab,recording:n.recording};if(n.dryRun){o({command:`cf browser-rendering devtools browser connect`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}`,pathParams:{"session-id":String(n[`session-id`]??``)},query:i,bodyKind:`none`});return}let l=await r(n),u=n.local?c:await e();n.accountId=u,a(await s(`Loading`,async()=>l.browserRendering.devtools.browser.connect({account_id:u,session_id:n[`session-id`],...i})),{successLabel:`Loaded`})}};function D(e){return e.option(`keep-alive`,{type:`number`,description:`Keep-alive time in milliseconds.`}).option(`lab`,{type:`boolean`,description:`Use experimental browser.`}).option(`targets`,{type:`boolean`,description:`Include browser targets in response.`}).option(`live-view-url-expires-in-ms`,{type:`number`,description:`How long the live view URL remains valid, in milliseconds (max 60 minutes). Only used when targets is true.`}).option(`recording`,{type:`boolean`,description:`Recording`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`create`,describe:`Acquires a browser and returns its session ID and websocket URL.`,builder:D,handler:async n=>{let i={keep_alive:n[`keep-alive`],lab:n.lab,targets:n.targets,liveViewUrlExpiresInMs:n[`live-view-url-expires-in-ms`],recording:n.recording};if(n.dryRun){o({command:`cf browser-rendering devtools browser create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser`,pathParams:{},query:i,bodyKind:`none`});return}let l=await r(n),u=n.local?c:await e();n.accountId=u,a(await s(`Creating`,async()=>l.browserRendering.devtools.browser.create({account_id:u,...i})),{successLabel:`Created`})}};function k(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID to close.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const A={command:`delete <session-id>`,describe:`Closes an existing browser session.`,builder:k,handler:async n=>{if(n.dryRun){o({command:`cf browser-rendering devtools browser delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}`,pathParams:{"session-id":String(n[`session-id`]??``)},bodyKind:`none`});return}let i=await r(n),u=n.local?c:await e();if(n.accountId=u,!await l({force:!!n.force})){process.stderr.write(`Aborted.
4
+ `);return}a(await s(`Deleting`,async()=>i.browserRendering.devtools.browser.delete({account_id:u,session_id:n[`session-id`]})),{successLabel:`Deleted`})}};function j(e){return e.option(`keep-alive`,{type:`number`,description:`Keep-alive time in ms (only valid when acquiring new session).`}).option(`lab`,{type:`boolean`,description:`Use experimental browser.`}).option(`recording`,{type:`boolean`,description:`Recording`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`launch`,describe:`Acquires and establishes a WebSocket connection to a browser session.`,builder:j,handler:async n=>{let i={keep_alive:n[`keep-alive`],lab:n.lab,recording:n.recording};if(n.dryRun){o({command:`cf browser-rendering devtools browser launch`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser`,pathParams:{},query:i,bodyKind:`none`});return}let l=await r(n),u=n.local?c:await e();n.accountId=u,a(await s(`Loading`,async()=>l.browserRendering.devtools.browser.launch({account_id:u,...i})),{successLabel:`Loaded`})}};function N(e){return e.positional(`target-id`,{type:`string`,description:`Target ID, e.g. page ID.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`get <target-id>`,describe:`Establishes a WebSocket connection to a specific Chrome DevTools target or page.`,builder:N,handler:async n=>{if(n.dryRun){o({command:`cf browser-rendering devtools browser page get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}/page/${n[`target-id`]==null?`<target-id>`:encodeURIComponent(String(n[`target-id`]))}`,pathParams:{"session-id":String(n[`session-id`]??``),"target-id":String(n[`target-id`]??``)},bodyKind:`none`});return}let i=await r(n),l=n.local?c:await e();n.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.page.get({account_id:l,session_id:n[`session-id`],target_id:n[`target-id`]})),{successLabel:`Loaded`})}},F={command:`page`,describe:`Operations for devtools.browser.page`,builder:e=>e.command(P).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function I(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const L={command:`protocol <session-id>`,describe:`Returns the complete Chrome DevTools Protocol schema including all domains, commands, events, and types. This schema describes the entire CDP API surface.`,builder:I,handler:async n=>{if(n.dryRun){o({command:`cf browser-rendering devtools browser protocol`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}/json/protocol`,pathParams:{"session-id":String(n[`session-id`]??``)},bodyKind:`none`});return}let i=await r(n),l=n.local?c:await e();n.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.protocol({account_id:l,session_id:n[`session-id`]})),{successLabel:`Loaded`})}};function R(e){return e.positional(`target-id`,{type:`string`,description:`Target ID to activate.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const z={command:`activate <target-id>`,describe:`Activates (brings to front) a specific browser target by its ID.`,builder:R,handler:async n=>{if(n.dryRun){o({command:`cf browser-rendering devtools browser targets activate`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}/json/activate/${n[`target-id`]==null?`<target-id>`:encodeURIComponent(String(n[`target-id`]))}`,pathParams:{"session-id":String(n[`session-id`]??``),"target-id":String(n[`target-id`]??``)},bodyKind:`none`});return}let i=await r(n),l=n.local?c:await e();n.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.targets.activate({account_id:l,session_id:n[`session-id`],target_id:n[`target-id`]})),{successLabel:`Loaded`})}};function B(e){return e.positional(`target-id`,{type:`string`,description:`Target ID to close.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const V={command:`close <target-id>`,describe:`Closes a specific browser target (tab, page, etc.) by its ID. Returns 'Target is closing' on success or an error if the target is not found.`,builder:B,handler:async n=>{if(n.dryRun){o({command:`cf browser-rendering devtools browser targets close`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}/json/close/${n[`target-id`]==null?`<target-id>`:encodeURIComponent(String(n[`target-id`]))}`,pathParams:{"session-id":String(n[`session-id`]??``),"target-id":String(n[`target-id`]??``)},bodyKind:`none`});return}let i=await r(n),l=n.local?c:await e();n.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.targets.close({account_id:l,session_id:n[`session-id`],target_id:n[`target-id`]})),{successLabel:`Loaded`})}};function H(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`url`,{type:`string`,description:`Url`}).option(`live-view-url-expires-in-ms`,{type:`number`,description:`How long the live view URL remains valid, in milliseconds (max 60 minutes)`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const U={command:`create <session-id>`,describe:`Opens a new tab in the browser. Optionally specify a URL to navigate to.`,builder:H,handler:async n=>{let i={url:n.url,liveViewUrlExpiresInMs:n[`live-view-url-expires-in-ms`]};if(n.dryRun){o({command:`cf browser-rendering devtools browser targets create`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}/json/new`,pathParams:{"session-id":String(n[`session-id`]??``)},query:i,bodyKind:`none`});return}let l=await r(n),u=n.local?c:await e();n.accountId=u,a(await s(`Updating`,async()=>l.browserRendering.devtools.browser.targets.create({account_id:u,session_id:n[`session-id`],...i})),{successLabel:`Updated`})}};function W(e){return e.positional(`target-id`,{type:`string`,description:`Target ID.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const G={command:`get <target-id>`,describe:`Returns the debuggable target with the given ID.`,builder:W,handler:async n=>{if(n.dryRun){o({command:`cf browser-rendering devtools browser targets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}/json/list/${n[`target-id`]==null?`<target-id>`:encodeURIComponent(String(n[`target-id`]))}`,pathParams:{"session-id":String(n[`session-id`]??``),"target-id":String(n[`target-id`]??``)},bodyKind:`none`});return}let i=await r(n),l=n.local?c:await e();n.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.targets.get({account_id:l,session_id:n[`session-id`],target_id:n[`target-id`]})),{successLabel:`Loaded`})}};function K(e){return e.option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`live-view-url-expires-in-ms`,{type:`number`,description:`How long the live view URLs remain valid, in milliseconds (max 60 minutes)`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const q={command:`list`,describe:`Returns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts.`,builder:K,handler:async n=>{let i={liveViewUrlExpiresInMs:n[`live-view-url-expires-in-ms`]};if(n.dryRun){o({command:`cf browser-rendering devtools browser targets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}/json/list`,pathParams:{"session-id":String(n[`session-id`]??``)},query:i,bodyKind:`none`});return}let l=await r(n),u=n.local?c:await e();n.accountId=u,a(await s(`Loading`,async()=>l.browserRendering.devtools.browser.targets.list({account_id:u,session_id:n[`session-id`],...i})),{successLabel:`Loaded`})}},J={command:`targets`,describe:`Operations for devtools.browser.targets`,builder:e=>e.command(z).command(V).command(U).command(G).command(q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Y(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const te={command:`version <session-id>`,describe:`Get browser version metadata.`,builder:Y,handler:async n=>{if(n.dryRun){o({command:`cf browser-rendering devtools browser version`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}/json/version`,pathParams:{"session-id":String(n[`session-id`]??``)},bodyKind:`none`});return}let i=await r(n),l=n.local?c:await e();n.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.browser.version({account_id:l,session_id:n[`session-id`]})),{successLabel:`Loaded`})}},X={command:`browser`,describe:`Operations for devtools.browser`,builder:e=>e.command(E).command(O).command(A).command(M).command(L).command(te).command(F).command(J).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Z(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`live-view-url-expires-in-ms`,{type:`number`,description:`How long the live view URLs remain valid, in milliseconds (max 60 minutes)`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Q={command:`get <session-id>`,describe:`Returns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts.`,builder:Z,handler:async n=>{let i={liveViewUrlExpiresInMs:n[`live-view-url-expires-in-ms`]};if(n.dryRun){o({command:`cf browser-rendering devtools json get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/browser/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}/json`,pathParams:{"session-id":String(n[`session-id`]??``)},query:i,bodyKind:`none`});return}let l=await r(n),u=n.local?c:await e();n.accountId=u,a(await s(`Loading`,async()=>l.browserRendering.devtools.json.get({account_id:u,session_id:n[`session-id`],...i})),{successLabel:`Loaded`})}},ne={command:`json`,describe:`Operations for devtools.json`,builder:e=>e.command(Q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function re(e){return e.positional(`session-id`,{type:`string`,description:`Session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ie={command:`get <session-id>`,describe:`Get details for a specific browser session.`,builder:re,handler:async n=>{if(n.dryRun){o({command:`cf browser-rendering devtools session get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/session/${n[`session-id`]==null?`<session-id>`:encodeURIComponent(String(n[`session-id`]))}`,pathParams:{"session-id":String(n[`session-id`]??``)},bodyKind:`none`});return}let i=await r(n),l=n.local?c:await e();n.accountId=l,a(await s(`Loading`,async()=>i.browserRendering.devtools.session.get({account_id:l,session_id:n[`session-id`]})),{successLabel:`Loaded`})}};function ae(e){return e.option(`limit`,{type:`number`,description:`Limit`}).option(`offset`,{type:`number`,description:`Offset`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const oe={command:`list`,describe:`List active browser sessions.`,builder:ae,handler:async n=>{let i={limit:n.limit,offset:n.offset};if(n.dryRun){o({command:`cf browser-rendering devtools session list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/devtools/session`,pathParams:{},query:i,bodyKind:`none`});return}let l=await r(n),u=n.local?c:await e();n.accountId=u,a(await s(`Loading`,async()=>l.browserRendering.devtools.session.list({account_id:u,...i})),{successLabel:`Loaded`})}},se={command:`session`,describe:`Operations for devtools.session`,builder:e=>e.command(ie).command(oe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ce={command:`devtools`,describe:`Operations for devtools`,builder:e=>e.command(X).command(ne).command(se).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function le(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ue={command:`create`,describe:"Gets json from a webpage from a provided URL or HTML. Pass `prompt` or `schema` in the body. Control page loading with `gotoOptions` and `waitFor*` options.",builder:le,handler:async l=>{let u={cacheTTL:l[`cache-ttl`]};if(l.dryRun){o({command:`cf browser-rendering json create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/json`,pathParams:{},query:u,bodyKind:`json`,body:l.body===void 0?void 0:i(l.body)});return}let d=await r(l),f=l.local?c:await e();if(l.accountId=f,l.body){let e=i(l.body);new URLSearchParams(Object.entries(u).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>d.browserRendering.json.create({body:e,account_id:f,...u})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>n(d,`POST`,`/accounts/${f}/browser-rendering/json`,{query:u})),{successLabel:`Created`})}},de={command:`json`,describe:`Operations for json`,builder:e=>e.command(ue).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function fe(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const pe={command:`create`,describe:`Get links from a web page.`,builder:fe,handler:async l=>{let u={cacheTTL:l[`cache-ttl`]};if(l.dryRun){o({command:`cf browser-rendering links create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/links`,pathParams:{},query:u,bodyKind:`json`,body:l.body===void 0?void 0:i(l.body)});return}let d=await r(l),f=l.local?c:await e();if(l.accountId=f,l.body){let e=i(l.body);new URLSearchParams(Object.entries(u).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>d.browserRendering.links.create({body:e,account_id:f,...u})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>n(d,`POST`,`/accounts/${f}/browser-rendering/links`,{query:u})),{successLabel:`Created`})}},me={command:`links`,describe:`Operations for links`,builder:e=>e.command(pe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function he(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ge={command:`create`,describe:"Gets markdown of a webpage from provided URL or HTML. Control page loading with `gotoOptions` and `waitFor*` options.",builder:he,handler:async l=>{let u={cacheTTL:l[`cache-ttl`]};if(l.dryRun){o({command:`cf browser-rendering markdown create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/markdown`,pathParams:{},query:u,bodyKind:`json`,body:l.body===void 0?void 0:i(l.body)});return}let d=await r(l),f=l.local?c:await e();if(l.accountId=f,l.body){let e=i(l.body);new URLSearchParams(Object.entries(u).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>d.browserRendering.markdown.create({body:e,account_id:f,...u})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>n(d,`POST`,`/accounts/${f}/browser-rendering/markdown`,{query:u})),{successLabel:`Created`})}},_e={command:`markdown`,describe:`Operations for markdown`,builder:e=>e.command(ge).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ve(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const ye={command:`create`,describe:"Fetches rendered PDF from provided URL or HTML. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.",builder:ve,handler:async n=>{let a={cacheTTL:n[`cache-ttl`]};if(n.dryRun){o({command:`cf browser-rendering pdf create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/pdf`,pathParams:{},query:a,bodyKind:`json`,body:n.body===void 0?void 0:i(n.body)});return}await r(n);let l=n.local?c:await e();if(n.accountId=l,n.body){let e=i(n.body),t=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),r=await s(`Creating`,async()=>f(`/accounts/${l}/browser-rendering/pdf${t?`?`+t:``}`,{method:`POST`,localEndpoint:n.local?n.localEndpoint:void 0,body:JSON.stringify(e),contentType:`application/json`}));d(n.text===!0?r.toString(`utf-8`):r);return}let u=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),p=await s(`Creating`,async()=>f(`/accounts/${l}/browser-rendering/pdf${u?`?`+u:``}`,{method:`POST`,localEndpoint:n.local?n.localEndpoint:void 0}));d(n.text===!0?p.toString(`utf-8`):p)}},be={command:`pdf`,describe:`Operations for pdf`,builder:e=>e.command(ye).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function $(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const xe={command:`create`,describe:`Get meta attributes like height, width, text and others of selected elements.`,builder:$,handler:async l=>{let u={cacheTTL:l[`cache-ttl`]};if(l.dryRun){o({command:`cf browser-rendering scrape create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/scrape`,pathParams:{},query:u,bodyKind:`json`,body:l.body===void 0?void 0:i(l.body)});return}let d=await r(l),f=l.local?c:await e();if(l.accountId=f,l.body){let e=i(l.body);new URLSearchParams(Object.entries(u).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>d.browserRendering.scrape.create({body:e,account_id:f,...u})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>n(d,`POST`,`/accounts/${f}/browser-rendering/scrape`,{query:u})),{successLabel:`Created`})}},Se={command:`scrape`,describe:`Operations for scrape`,builder:e=>e.command(xe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ce(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const we={command:`create`,describe:"Takes a screenshot of a webpage from provided URL or HTML. Control page loading with `gotoOptions` and `waitFor*` options. Customize screenshots with `viewport`, `fullPage`, `clip` and others.",builder:Ce,handler:async n=>{let a={cacheTTL:n[`cache-ttl`]};if(n.dryRun){o({command:`cf browser-rendering screenshot create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/screenshot`,pathParams:{},query:a,bodyKind:`json`,body:n.body===void 0?void 0:i(n.body)});return}await r(n);let l=n.local?c:await e();if(n.accountId=l,n.body){let e=i(n.body),t=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),r=await s(`Creating`,async()=>f(`/accounts/${l}/browser-rendering/screenshot${t?`?`+t:``}`,{method:`POST`,localEndpoint:n.local?n.localEndpoint:void 0,body:JSON.stringify(e),contentType:`application/json`}));d(n.text===!0?r.toString(`utf-8`):r);return}let u=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),p=await s(`Creating`,async()=>f(`/accounts/${l}/browser-rendering/screenshot${u?`?`+u:``}`,{method:`POST`,localEndpoint:n.local?n.localEndpoint:void 0}));d(n.text===!0?p.toString(`utf-8`):p)}},Te={command:`screenshot`,describe:`Operations for screenshot`,builder:e=>e.command(we).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ee(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const De={command:`create`,describe:"Returns the page's HTML content and screenshot. Control page loading with `gotoOptions` and `waitFor*` options. Customize screenshots with `viewport`, `fullPage`, `clip` and others.",builder:Ee,handler:async l=>{let u={cacheTTL:l[`cache-ttl`]};if(l.dryRun){o({command:`cf browser-rendering snapshot create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/browser-rendering/snapshot`,pathParams:{},query:u,bodyKind:`json`,body:l.body===void 0?void 0:i(l.body)});return}let d=await r(l),f=l.local?c:await e();if(l.accountId=f,l.body){let e=i(l.body);new URLSearchParams(Object.entries(u).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>d.browserRendering.snapshot.create({body:e,account_id:f,...u})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>n(d,`POST`,`/accounts/${f}/browser-rendering/snapshot`,{query:u})),{successLabel:`Created`})}},Oe={command:`snapshot`,describe:`Operations for snapshot`,builder:e=>e.command(De).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ke={command:`browser-rendering`,describe:`browser-rendering`,builder:e=>e.command(m).command(_).command(w).command(ce).command(de).command(me).command(_e).command(be).command(Se).command(Te).command(Oe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{ke as default};