cf 0.3.0 → 0.5.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 (228) hide show
  1. package/README.md +7 -1
  2. package/dist/_meta/agent-context.json +26 -21
  3. package/dist/_meta/commands.json +7696 -18100
  4. package/dist/_meta/schemas.json +6411 -13925
  5. package/dist/{abuse-reports-dMIfUJ8v.mjs → abuse-reports-Ina5TlsU.mjs} +2 -2
  6. package/dist/{accounts-Kx1epdA1.mjs → accounts-B_joQcMi.mjs} +9 -9
  7. package/dist/{acm-Utu252kC.mjs → acm-_kIHqYME.mjs} +2 -2
  8. package/dist/{addressing-CBq7Z7Vq.mjs → addressing-CaFlw8y1.mjs} +10 -10
  9. package/dist/{agent-context-BGTU299M.mjs → agent-context-DMPfi54f.mjs} +1 -1
  10. package/dist/ai-CqnhNb_c.mjs +2 -0
  11. package/dist/ai-gateway-pgYGI519.mjs +8 -0
  12. package/dist/ai-search-eqQMPQol.mjs +7 -0
  13. package/dist/ai_gateway--vuVLnOm.mjs +4 -0
  14. package/dist/{alerting-CqmEIaKn.mjs → alerting-CPxHiYHb.mjs} +5 -5
  15. package/dist/{analytics-Dv-X8x7D.mjs → analytics-DSSRDZz8.mjs} +1 -1
  16. package/dist/analytics_engine-gWyfnsCs.mjs +2 -0
  17. package/dist/{api-gateway-CNv0IHTU.mjs → api-gateway-BXXGFCVR.mjs} +10 -10
  18. package/dist/argo-aC6A3JyX.mjs +2 -0
  19. package/dist/artifacts-HD4V2xpK.mjs +4 -0
  20. package/dist/audit-logs-BuExU_nz.mjs +2 -0
  21. package/dist/auth-CSC4yhEJ.mjs +9 -0
  22. package/dist/auth-D5hNsOFq.mjs +5 -0
  23. package/dist/billing-COaghyxl.mjs +2 -0
  24. package/dist/bot-management-DmEzeV1Y.mjs +5 -0
  25. package/dist/botnet-feed-ByEAXAkw.mjs +3 -0
  26. package/dist/brand-protection-dPrGe8sL.mjs +3 -0
  27. package/dist/browser-rendering-BiSGnpBf.mjs +4 -0
  28. package/dist/{build-DYkGW4dh.mjs → build-HuS9-R0V.mjs} +131 -131
  29. package/dist/{cache-DsoW6Xwv.mjs → cache-CY-7Lt71.mjs} +4 -4
  30. package/dist/calls-wOQGDWPl.mjs +4 -0
  31. package/dist/certificate-authorities-CtqzAtxQ.mjs +2 -0
  32. package/dist/chunk-6IEM75FG-BEjRFMGh.mjs +2 -0
  33. package/dist/client-certificates-CRf41xLe.mjs +3 -0
  34. package/dist/cloud-connector-BA5IRZUP.mjs +2 -0
  35. package/dist/{cloudforce-one-2Bhz8YdW.mjs → cloudforce-one-Bq_qPAWs.mjs} +20 -20
  36. package/dist/{completions-BwRpZQVn.mjs → completions-DOeHPdCG.mjs} +2 -2
  37. package/dist/config-B5k-XbwS.mjs +2 -0
  38. package/dist/connectivity-Bx3MgTHX.mjs +3 -0
  39. package/dist/connector-interrupts-D7ylweJZ.mjs +2 -0
  40. package/dist/connector-telemetry-events-6izV1kbP.mjs +2 -0
  41. package/dist/connector-telemetry-snapshots-BnjKbyxX.mjs +2 -0
  42. package/dist/connectors-DRt4e6d_.mjs +3 -0
  43. package/dist/content-scanning-Cd2vy5Sz.mjs +4 -0
  44. package/dist/context-jpewmual.mjs +2 -0
  45. package/dist/{custom-certificates-aAiEguR7.mjs → custom-certificates-DYE-9epx.mjs} +3 -3
  46. package/dist/{custom-hostnames-AG5yBHIi.mjs → custom-hostnames-CtuTdFcX.mjs} +4 -4
  47. package/dist/custom-nameservers-CWqA51in.mjs +3 -0
  48. package/dist/custom-pages-DeUKEFGe.mjs +4 -0
  49. package/dist/d1-DvWY9Gp4.mjs +4 -0
  50. package/dist/data-security-BPo6dIWu.mjs +6 -0
  51. package/dist/dcv-delegation-Bgf86J-r.mjs +2 -0
  52. package/dist/{deploy-CQial3kN.mjs → deploy-dVrgDUOp.mjs} +1 -1
  53. package/dist/{dev-B38LfCTl.mjs → dev-C01_Lby6.mjs} +1 -1
  54. package/dist/diagnostics-6nKPmVgz.mjs +3 -0
  55. package/dist/{dispatch-namespaces-DmHvoBOg.mjs → dispatch-namespaces-64lXx2WJ.mjs} +6 -6
  56. package/dist/dist-C6zxsVdY.mjs +306 -0
  57. package/dist/{dist-AIcZFk0U.mjs → dist-t_YrL25p.mjs} +7 -7
  58. package/dist/{dns-VMhQSr5n.mjs → dns-ClciFGxx.mjs} +13 -13
  59. package/dist/dns-firewall-DfUmXDCe.mjs +57 -0
  60. package/dist/durable-objects-CMaYZ-YU.mjs +2 -0
  61. package/dist/{email-routing-tIR2SFu-.mjs → email-routing-CGXhFqF5.mjs} +9 -9
  62. package/dist/{email-security-Ca1id3rZ.mjs → email-security-D5viPq8S.mjs} +7 -7
  63. package/dist/email-sending-C2jpc3gh.mjs +3 -0
  64. package/dist/{filters-A4dg_a68.mjs → filters-bzsFcWt0.mjs} +3 -3
  65. package/dist/{firewall-DWPQgYd9.mjs → firewall-DYZcTtIC.mjs} +10 -10
  66. package/dist/{fraud-BMkSsJGU.mjs → fraud-C03MtdZb.mjs} +1 -1
  67. package/dist/google-tag-gateway-Dfy887yA.mjs +2 -0
  68. package/dist/{healthchecks-CtIfrFql.mjs → healthchecks-DRoAlWgr.mjs} +3 -3
  69. package/dist/hostnames-CFgIVI3s.mjs +3 -0
  70. package/dist/hyperdrive-C7-gwTSV.mjs +18 -0
  71. package/dist/iam-DqVPzGrb.mjs +6 -0
  72. package/dist/images-BYfl4YgR.mjs +7 -0
  73. package/dist/index.mjs +1 -1
  74. package/dist/intel-duTEPIHc.mjs +3 -0
  75. package/dist/{ips-K4bzaGqd.mjs → ips-nv9INuWZ.mjs} +1 -1
  76. package/dist/keyless-certificates-CRCDVd3g.mjs +3 -0
  77. package/dist/{kv-8o27w_pY.mjs → kv-CZoV4tiv.mjs} +4 -4
  78. package/dist/leaked-credential-checks-DNIBg7Pe.mjs +3 -0
  79. package/dist/{load-balancers-DtG8nj25.mjs → load-balancers--OMg0HNt.mjs} +5 -5
  80. package/dist/{logpush-4L0njy1d.mjs → logpush-C0_lZTyY.mjs} +3 -3
  81. package/dist/{logs-B_Yp95hv.mjs → logs-BtpWZQfV.mjs} +2 -2
  82. package/dist/magic-cloud-networking-u6rwYbGg.mjs +5 -0
  83. package/dist/{magic-network-monitoring-BnwvM4-I.mjs → magic-network-monitoring-CKgQyRj4.mjs} +3 -3
  84. package/dist/{magic-transit-CXDyvhxq.mjs → magic-transit-CLhMcJ_-.mjs} +32 -33
  85. package/dist/managed-transforms-D0Z2mlth.mjs +3 -0
  86. package/dist/mtls-certificates-BL65NK5T.mjs +3 -0
  87. package/dist/{network-interconnects-rrr7red3.mjs → network-interconnects-Bgu9gmaG.mjs} +5 -5
  88. package/dist/oauth-Bk-F-tIO.mjs +52 -0
  89. package/dist/{observability-DWvpqnQJ.mjs → observability-BynRbTF4.mjs} +3 -3
  90. package/dist/open-YWOUIZ5Y-3jqSKAB1.mjs +4 -0
  91. package/dist/{organizations-T77D50Sq.mjs → organizations-BqJHyvMK.mjs} +3 -3
  92. package/dist/origin-ca-certificates-BGvYwm3C.mjs +3 -0
  93. package/dist/origin-post-quantum-encryption-9KOE8YPI.mjs +2 -0
  94. package/dist/{origin-tls-client-auth-CaVW1Ztp.mjs → origin-tls-client-auth-d3snC3vr.mjs} +3 -3
  95. package/dist/{output-BJFNwj7b.mjs → output-B6fBFRqe.mjs} +1 -1
  96. package/dist/{page-rules-CjZPTMQX.mjs → page-rules-EZHJePmn.mjs} +4 -4
  97. package/dist/{page-shield-D5RRNJCY.mjs → page-shield-CXJioWPs.mjs} +5 -5
  98. package/dist/{pages-CWJtJnL0.mjs → pages-D4aYteKk.mjs} +8 -8
  99. package/dist/{pipelines-B0L_7j9e.mjs → pipelines-G8Iusxq-.mjs} +5 -5
  100. package/dist/progress-DrDErV9w.mjs +2 -0
  101. package/dist/queues-DEkbKqZX.mjs +6 -0
  102. package/dist/{r2-DQIcyRtA.mjs → r2-CV0IkCAW.mjs} +9 -9
  103. package/dist/r2-data-catalog-NtqGC_a_.mjs +14 -0
  104. package/dist/radar-D986zPJr.mjs +2 -0
  105. package/dist/{rate-limits-DcrQV6Ar.mjs → rate-limits-B2wRsUX1.mjs} +3 -3
  106. package/dist/raw-fetch-_n0lMAnD.mjs +2 -0
  107. package/dist/{realtime-kit-CaquuVOE.mjs → realtime-kit-Ld3c5eU6.mjs} +9 -9
  108. package/dist/{registrar-Ko-xZemf.mjs → registrar-CDIwTz3G.mjs} +6 -6
  109. package/dist/request-tracers-D7SFMDik.mjs +2 -0
  110. package/dist/resource-sharing-YIQ04jXE.mjs +5 -0
  111. package/dist/{resource-tagging-C3qtLzCz.mjs → resource-tagging-Bd6Y03sg.mjs} +7 -7
  112. package/dist/rules-DHjLP5Kx.mjs +4 -0
  113. package/dist/{rulesets-CBgpeSvJ.mjs → rulesets-q4QABpKs.mjs} +7 -7
  114. package/dist/rum-SmT4HZmM.mjs +4 -0
  115. package/dist/{schema-D16TgWBg.mjs → schema-BR31o4P6.mjs} +1 -1
  116. package/dist/{schema-validation-Dgv_opM3.mjs → schema-validation-vVetgC_P.mjs} +5 -5
  117. package/dist/{scim-DdSEr4kZ.mjs → scim-ChOkZpNx.mjs} +2 -2
  118. package/dist/{session-COHHdS7A.mjs → sdk-DhIhH6GB.mjs} +4 -4
  119. package/dist/{secrets-store-7BfyvJLb.mjs → secrets-store-BAK9G12O.mjs} +12 -12
  120. package/dist/security-center-eScuYDKP.mjs +2 -0
  121. package/dist/security-txt-x7R4gmQu.mjs +3 -0
  122. package/dist/session-DHYCE-PM.mjs +93 -0
  123. package/dist/shared-BAjo72Lz.mjs +2 -0
  124. package/dist/{smart-shield-TeWZFnH2.mjs → smart-shield-CWlSsNi8.mjs} +2 -2
  125. package/dist/snippets-DrlgYJYp.mjs +4 -0
  126. package/dist/{spawn-DcppKGI5.mjs → spawn-CCGzKlC4.mjs} +1 -1
  127. package/dist/{spectrum-CTTZID8u.mjs → spectrum-pVGxb7u5.mjs} +6 -6
  128. package/dist/speed-ZFrMWDgd.mjs +4 -0
  129. package/dist/src-DU7FBCOX.mjs +108 -0
  130. package/dist/ssl-9JY05sYt.mjs +15 -0
  131. package/dist/stream-tRU39b8K.mjs +14 -0
  132. package/dist/{tenants-Bd7NGQ_m.mjs → tenants-HLGUazms.mjs} +1 -1
  133. package/dist/{token-validation-DAgtFOvs.mjs → token-validation-_VdamKpz.mjs} +4 -4
  134. package/dist/{tools-DXQmfFuE.mjs → tools-D_hfUU_Z.mjs} +1 -1
  135. package/dist/{turnstile-cfdaO4ca.mjs → turnstile-BRzXd28B.mjs} +4 -4
  136. package/dist/{ui-D4KtlMh9.mjs → ui-erjBdVKL.mjs} +1 -1
  137. package/dist/url-normalization-D-NxuLtN.mjs +3 -0
  138. package/dist/url-scanner-BzzR6iDx.mjs +2 -0
  139. package/dist/{user-CAo-yCJA.mjs → user-C4omq__w.mjs} +2 -2
  140. package/dist/vectorize-By6EqcNR.mjs +4 -0
  141. package/dist/{versions-CUwWJWmy.mjs → versions-CBHwWPAM.mjs} +1 -1
  142. package/dist/{waiting-rooms-Dln5ICg5.mjs → waiting-rooms-u6KwrzWd.mjs} +6 -6
  143. package/dist/{web3-HQJRm38W.mjs → web3-DQ5dmE9W.mjs} +3 -3
  144. package/dist/{workers-Dg7ddG2Q.mjs → workers-D8Be7_as.mjs} +14 -14
  145. package/dist/workers-builds-BE3W3qNk.mjs +7 -0
  146. package/dist/{workflows-VquuSh2J.mjs → workflows-BWWufqFA.mjs} +3 -3
  147. package/dist/zaraz-Bsa9AvVL.mjs +2 -0
  148. package/dist/{zero-trust-CP96wnSh.mjs → zero-trust-UNVZFnKu.mjs} +87 -87
  149. package/dist/zero_trust-B0_Rk4p2.mjs +3 -0
  150. package/dist/zones-BXtdwt6E.mjs +21 -0
  151. package/package.json +4 -4
  152. package/dist/ai-DOOKLPkG.mjs +0 -2
  153. package/dist/ai-gateway-Cj1T3avF.mjs +0 -8
  154. package/dist/ai-search-CQF_Sn7d.mjs +0 -7
  155. package/dist/ai_gateway-C3fH22C0.mjs +0 -4
  156. package/dist/analytics_engine-DdXVR8z2.mjs +0 -2
  157. package/dist/argo-CX_A4kcn.mjs +0 -2
  158. package/dist/audit-logs-BfBf3oo-.mjs +0 -2
  159. package/dist/auth-SyWhMmPu.mjs +0 -6
  160. package/dist/auth-ffdf9yR0.mjs +0 -135
  161. package/dist/autorag-BuGhGTeZ.mjs +0 -2
  162. package/dist/billing-PoG81XaQ.mjs +0 -2
  163. package/dist/bot-management-CFvtVx62.mjs +0 -5
  164. package/dist/botnet-feed-B-M4Yu0W.mjs +0 -3
  165. package/dist/brand-protection-D05Eg-_6.mjs +0 -3
  166. package/dist/browser-rendering-xu8F_Rrv.mjs +0 -4
  167. package/dist/calls-CZbO7TyR.mjs +0 -4
  168. package/dist/certificate-authorities-D2yr7_3t.mjs +0 -2
  169. package/dist/client-certificates-MJcDsTId.mjs +0 -3
  170. package/dist/cloud-connector-DWOrN2eM.mjs +0 -2
  171. package/dist/config-DYzlVxcB.mjs +0 -2
  172. package/dist/connectivity-BX8C7tvK.mjs +0 -3
  173. package/dist/content-scanning-r6uzMO1r.mjs +0 -4
  174. package/dist/context-DGlHRGWM.mjs +0 -2
  175. package/dist/custom-nameservers-D1DtlRue.mjs +0 -3
  176. package/dist/custom-pages-DQCi2plU.mjs +0 -4
  177. package/dist/d1-DbnYhw45.mjs +0 -4
  178. package/dist/data-security-D_EtYBfo.mjs +0 -6
  179. package/dist/dcv-delegation-CHspSzTI.mjs +0 -2
  180. package/dist/diagnostics-BJQGjVJn.mjs +0 -3
  181. package/dist/dist-DNBSHor6.mjs +0 -301
  182. package/dist/dns-firewall-B4DVXFBQ.mjs +0 -57
  183. package/dist/durable-objects-CTboySEo.mjs +0 -2
  184. package/dist/email-sending-DwWKc5jC.mjs +0 -3
  185. package/dist/google-tag-gateway-BGD49nRC.mjs +0 -2
  186. package/dist/hostnames-BiomxukN.mjs +0 -3
  187. package/dist/hyperdrive-Da104VaQ.mjs +0 -18
  188. package/dist/iam-BIGKo0WW.mjs +0 -6
  189. package/dist/images-BO8FbDAa.mjs +0 -5
  190. package/dist/intel-CY6_79v8.mjs +0 -3
  191. package/dist/keyless-certificates-CZC-L8gM.mjs +0 -3
  192. package/dist/leaked-credential-checks-qLzRyu85.mjs +0 -3
  193. package/dist/magic-cloud-networking-CSOM3EM-.mjs +0 -5
  194. package/dist/managed-transforms-D15yVbZx.mjs +0 -3
  195. package/dist/mtls-certificates-D8k0AXWK.mjs +0 -3
  196. package/dist/origin-ca-certificates-DXIvD8H5.mjs +0 -3
  197. package/dist/origin-post-quantum-encryption-C8oOczyV.mjs +0 -2
  198. package/dist/progress-CrCGTq7N.mjs +0 -2
  199. package/dist/queues-CN6DPhRR.mjs +0 -6
  200. package/dist/r2-data-catalog-Bbo93TJx.mjs +0 -14
  201. package/dist/radar-Bxb0WX8V.mjs +0 -2
  202. package/dist/raw-fetch-Dlccg0Tr.mjs +0 -2
  203. package/dist/request-tracers-DOW_reTJ.mjs +0 -2
  204. package/dist/resource-sharing-D7TX0JV0.mjs +0 -5
  205. package/dist/rules-BXRADHL5.mjs +0 -4
  206. package/dist/rum-BjPptTUP.mjs +0 -4
  207. package/dist/security-center-DAy6AKtT.mjs +0 -2
  208. package/dist/security-txt-xAMb7K6Y.mjs +0 -3
  209. package/dist/shared-AGtpXwwL.mjs +0 -2
  210. package/dist/snippets-CCSsCXVs.mjs +0 -4
  211. package/dist/speed-CuzTE0AL.mjs +0 -4
  212. package/dist/src-BW6vfAwE.mjs +0 -108
  213. package/dist/ssl-BWA2LdwC.mjs +0 -15
  214. package/dist/stream-GFsIZ-pP.mjs +0 -14
  215. package/dist/url-normalization-B5RN4nLD.mjs +0 -3
  216. package/dist/url-scanner-BrZ1L9OC.mjs +0 -2
  217. package/dist/vectorize-C7_oQlaI.mjs +0 -4
  218. package/dist/workers-builds-AVfx8IyL.mjs +0 -7
  219. package/dist/zaraz-xYSWIV4P.mjs +0 -2
  220. package/dist/zones-BSgmZ9WC.mjs +0 -21
  221. /package/dist/{body-parser-DKa8Ipg1.mjs → body-parser-DWSy7uZ8.mjs} +0 -0
  222. /package/dist/{cli-types-CRIDdDw3.mjs → cli-types-BeyOc81z.mjs} +0 -0
  223. /package/dist/{input-validation-zEO81MWN.mjs → input-validation-_fMCApaH.mjs} +0 -0
  224. /package/dist/{lib-Eu1wXxuh.mjs → lib-4PQI6yRW.mjs} +0 -0
  225. /package/dist/{local-VJaJ3BZ1.mjs → local-CYc9q7l2.mjs} +0 -0
  226. /package/dist/{metadata-5VwHPW6C.mjs → metadata-OOwvpR8m.mjs} +0 -0
  227. /package/dist/{resolve-4-OSeHlK.mjs → resolve-C3h-mwp7.mjs} +0 -0
  228. /package/dist/{theme-BklJDrb2.mjs → theme-DbNbIY4d.mjs} +0 -0
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import{D as e,E as t,S as n,T as r,i,n as a}from"./auth-ffdf9yR0.mjs";import{n as o,t as s}from"./body-parser-DKa8Ipg1.mjs";import{t as c}from"./output-BJFNwj7b.mjs";import{n as l,t as u}from"./progress-CrCGTq7N.mjs";import{n as d,t as f}from"./input-validation-zEO81MWN.mjs";import{t as p}from"./cli-types-CRIDdDw3.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 e=>{let t={normalize:e.normalize};if(e.dryRun){l({command:`cf api-gateway configurations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.configurations.get({zone_id:i,...t})),{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 e=>{let t={normalize:e.normalize};if(e.dryRun){l({command:`cf api-gateway configurations update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});if(e.zoneId=i,e.body){let n=o(e.body);new URLSearchParams(Object.entries(t).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),c(await u(`Updating`,async()=>r.apiGateway.configurations.update({body:n,zone_id:i,...t})),{successLabel:`Updated`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway discovery get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});e.zoneId=r,c(await u(`Loading`,async()=>t.apiGateway.discovery.get({zone_id:r})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway discovery operations bulk-edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.bulkEdit({body:n,zone_id:r})),{successLabel:`Updated`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway discovery operations edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations/${e[`discovery-id`]==null?`<discovery-id>`:encodeURIComponent(String(e[`discovery-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"discovery-id":String(e[`discovery-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.edit({...n,zone_id:r,discovery_id:e[`discovery-id`]})),{successLabel:`Updated`});return}c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.edit({zone_id:r,discovery_id:e[`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 e=>{let t={page:e.page,per_page:e[`per-page`],host:e.host,method:e.method,endpoint:e.endpoint,direction:e.direction,order:e.order,diff:e.diff,origin:e.origin,state:e.state};if(e.dryRun){l({command:`cf api-gateway discovery operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.discovery.operations.list({zone_id:i,...t})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway expression-template fallthrough create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/expression-template/fallthrough`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({hosts:e.hosts}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.expressionTemplate.fallthrough.create({...n,zone_id:r})),{successLabel:`Created`});return}if(e.hosts===void 0)throw Error(`--hosts is required (or pass --body with this field set).`);let i=s({hosts:e.hosts});c(await u(`Creating`,async()=>t.apiGateway.expressionTemplate.fallthrough.create({...i,zone_id:r})),{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 e=>{let t={page:e.page,per_page:e[`per-page`],order:e.order,direction:e.direction,source:e.source,filter:e.filter,with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.labels.list({zone_id:i,...t})),{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 e=>{let t={with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels managed get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/managed/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.labels.managed.get({zone_id:i,name:e.name,...t})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway labels managed resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/managed/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}/resources/operation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.managed.resources.operation.update({body:n,zone_id:r,name:e.name})),{successLabel:`Updated`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.labels.user.bulkCreate({body:n,zone_id:r})),{successLabel:`Created`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
3
- `);return}if(e.body){let n=o(e.body);c(await u(`Deleting`,async()=>t.apiGateway.labels.user.bulkDelete({body:n,zone_id:i})),{successLabel:`Deleted`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`none`});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
4
- `);return}c(await u(`Deleting`,async()=>t.apiGateway.labels.user.delete({zone_id:i,name:e.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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?s({description:d(e.description,`description`,`text`)}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.user.edit({...n,zone_id:r,name:e.name})),{successLabel:`Updated`});return}let i=s({description:d(e.description,`description`,`text`)});c(await u(`Updating`,async()=>t.apiGateway.labels.user.edit({...i,zone_id:r,name:e.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 e=>{let t={with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels user get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.labels.user.get({zone_id:i,name:e.name,...t})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}/resources/operation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.user.resources.operation.update({body:n,zone_id:r,name:e.name})),{successLabel:`Updated`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?s({description:d(e.description,`description`,`text`)}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.user.update({...n,zone_id:r,name:e.name})),{successLabel:`Updated`});return}let i=s({description:d(e.description,`description`,`text`)});c(await u(`Updating`,async()=>t.apiGateway.labels.user.update({...i,zone_id:r,name:e.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 e=>{if(e.dryRun){l({command:`cf api-gateway operations bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.operations.bulkCreate({body:n,zone_id:r})),{successLabel:`Created`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway operations bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
5
- `);return}if(e.body){let n=o(e.body);c(await u(`Deleting`,async()=>t.apiGateway.operations.bulkDelete({body:n,zone_id:i})),{successLabel:`Deleted`});return}if(e.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 r=>{if(r.dryRun){l({command:`cf api-gateway operations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${r.zone??r.zoneId??`<zone>`}/api_gateway/operations/item`,pathParams:{"zone-id":String(r.zone??r[`zone-id`]??``)},bodyKind:`json`,body:r.body===void 0?s({endpoint:d(r.endpoint,`endpoint`,`text`),host:d(r.host,`host`,`text`),method:d(r.method,`method`,`text`)}):o(r.body)});return}let i=await a(r),f=await n({zone:r.zone},i,{quiet:r.quiet});if(r.zoneId=f,r.body){let e=o(r.body);c(await u(`Creating`,async()=>i.apiGateway.operations.create({body:e,zone_id:f})),{successLabel:`Created`});return}r.endpoint===void 0&&(r.endpoint=await e(`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/.`)),r.host===void 0&&(r.host=await e(`host`,`RFC3986-compliant host.`)),r.method===void 0&&(r.method=await t(`method`,`The HTTP method used to access the endpoint.`,[`GET`,`POST`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`CONNECT`,`PATCH`,`TRACE`]));let p=s({endpoint:d(r.endpoint,`endpoint`,`text`),host:d(r.host,`host`,`text`),method:d(r.method,`method`,`text`)});c(await u(`Creating`,async()=>i.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 e=>{if(e.dryRun){l({command:`cf api-gateway operations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`none`});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
6
- `);return}c(await u(`Deleting`,async()=>t.apiGateway.operations.delete({zone_id:i,operation_id:e[`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 e=>{let t={feature:e.feature,with_schemas:e[`with-schemas`]};if(e.dryRun){l({command:`cf api-gateway operations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.operations.get({zone_id:i,operation_id:e[`operation-id`],...t})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.operations.labels.bulkCreate({...n,zone_id:r})),{successLabel:`Created`});return}let i=s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}});c(await u(`Creating`,async()=>t.apiGateway.operations.labels.bulkCreate({...i,zone_id:r})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}}):o(e.body)});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
7
- `);return}if(e.body){let n=o(e.body);c(await u(`Deleting`,async()=>t.apiGateway.operations.labels.bulkDelete({...n,zone_id:i})),{successLabel:`Deleted`});return}let d=s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}});c(await u(`Deleting`,async()=>t.apiGateway.operations.labels.bulkDelete({...d,zone_id:i})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels bulk-update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.operations.labels.bulkUpdate({...n,zone_id:r})),{successLabel:`Updated`});return}if(e[`managed-labels`]===void 0)throw Error(`--managed-labels is required (or pass --body with this field set).`);if(e[`user-labels`]===void 0)throw Error(`--user-labels is required (or pass --body with this field set).`);let i=s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}});c(await u(`Updating`,async()=>t.apiGateway.operations.labels.bulkUpdate({...i,zone_id:r})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:e.managed,user:e.user}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.operations.labels.create({...n,zone_id:r,operation_id:e[`operation-id`]})),{successLabel:`Created`});return}let i=s({managed:e.managed,user:e.user});c(await u(`Creating`,async()=>t.apiGateway.operations.labels.create({...i,zone_id:r,operation_id:e[`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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:e.managed,user:e.user}):o(e.body)});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
8
- `);return}if(e.body){let n=o(e.body);c(await u(`Deleting`,async()=>t.apiGateway.operations.labels.delete({...n,zone_id:i,operation_id:e[`operation-id`]})),{successLabel:`Deleted`});return}let d=s({managed:e.managed,user:e.user});c(await u(`Deleting`,async()=>t.apiGateway.operations.labels.delete({...d,zone_id:i,operation_id:e[`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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:e.managed,user:e.user}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.operations.labels.update({...n,zone_id:r,operation_id:e[`operation-id`]})),{successLabel:`Updated`});return}let i=s({managed:e.managed,user:e.user});c(await u(`Updating`,async()=>t.apiGateway.operations.labels.update({...i,zone_id:r,operation_id:e[`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 e=>{let t={page:e.page,per_page:e[`per-page`],order:e.order,direction:e.direction,host:e.host,method:e.method,endpoint:e.endpoint,feature:e.feature};if(e.dryRun){l({command:`cf api-gateway operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.operations.list({zone_id:i,...t})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway operations schema-validation edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.operations.schemaValidation.edit({body:n,zone_id:r})),{successLabel:`Updated`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway operations schema-validation get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`none`});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});e.zoneId=r,c(await u(`Loading`,async()=>t.apiGateway.operations.schemaValidation.get({zone_id:r,operation_id:e[`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 e=>{if(e.dryRun){l({command:`cf api-gateway operations schema-validation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({mitigation_action:d(e[`mitigation-action`],`mitigation-action`,`text`)}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.operations.schemaValidation.update({...n,zone_id:r,operation_id:e[`operation-id`]})),{successLabel:`Updated`});return}let i=s({mitigation_action:d(e[`mitigation-action`],`mitigation-action`,`text`)});c(await u(`Updating`,async()=>t.apiGateway.operations.schemaValidation.update({...i,zone_id:r,operation_id:e[`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 e=>{let t={host:e.host,feature:e.feature};if(e.dryRun){l({command:`cf api-gateway schemas list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/schemas`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.schemas.list({zone_id:i,...t})),{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
2
+ import{E as e,T as t,w as n,x as r}from"./oauth-Bk-F-tIO.mjs";import{i,n as a}from"./auth-CSC4yhEJ.mjs";import{n as o,t as s}from"./body-parser-DWSy7uZ8.mjs";import{t as c}from"./output-B6fBFRqe.mjs";import{n as l,t as u}from"./progress-DrDErV9w.mjs";import{n as d,t as f}from"./input-validation-_fMCApaH.mjs";import{t as p}from"./cli-types-BeyOc81z.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 e=>{let t={normalize:e.normalize};if(e.dryRun){l({command:`cf api-gateway configurations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.configurations.get({zone_id:i,...t})),{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 e=>{let t={normalize:e.normalize};if(e.dryRun){l({command:`cf api-gateway configurations update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});if(e.zoneId=i,e.body){let r=o(e.body);new URLSearchParams(Object.entries(t).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),c(await u(`Updating`,async()=>n.apiGateway.configurations.update({body:r,zone_id:i,...t})),{successLabel:`Updated`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway discovery get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,c(await u(`Loading`,async()=>t.apiGateway.discovery.get({zone_id:n})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway discovery operations bulk-edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.bulkEdit({body:r,zone_id:n})),{successLabel:`Updated`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway discovery operations edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations/${e[`discovery-id`]==null?`<discovery-id>`:encodeURIComponent(String(e[`discovery-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"discovery-id":String(e[`discovery-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.edit({...r,zone_id:n,discovery_id:e[`discovery-id`]})),{successLabel:`Updated`});return}c(await u(`Updating`,async()=>t.apiGateway.discovery.operations.edit({zone_id:n,discovery_id:e[`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 e=>{let t={page:e.page,per_page:e[`per-page`],host:e.host,method:e.method,endpoint:e.endpoint,direction:e.direction,order:e.order,diff:e.diff,origin:e.origin,state:e.state};if(e.dryRun){l({command:`cf api-gateway discovery operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.discovery.operations.list({zone_id:i,...t})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway expression-template fallthrough create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/expression-template/fallthrough`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({hosts:e.hosts}):o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.expressionTemplate.fallthrough.create({...r,zone_id:n})),{successLabel:`Created`});return}if(e.hosts===void 0)throw Error(`--hosts is required (or pass --body with this field set).`);let i=s({hosts:e.hosts});c(await u(`Creating`,async()=>t.apiGateway.expressionTemplate.fallthrough.create({...i,zone_id:n})),{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 e=>{let t={page:e.page,per_page:e[`per-page`],order:e.order,direction:e.direction,source:e.source,filter:e.filter,with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.labels.list({zone_id:i,...t})),{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 e=>{let t={with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels managed get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/managed/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.labels.managed.get({zone_id:i,name:e.name,...t})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway labels managed resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/managed/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}/resources/operation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.managed.resources.operation.update({body:r,zone_id:n,name:e.name})),{successLabel:`Updated`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.labels.user.bulkCreate({body:r,zone_id:n})),{successLabel:`Created`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),i=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await n({force:!!e.force})){process.stderr.write(`Aborted.
3
+ `);return}if(e.body){let n=o(e.body);c(await u(`Deleting`,async()=>t.apiGateway.labels.user.bulkDelete({body:n,zone_id:i})),{successLabel:`Deleted`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`none`});return}let t=await a(e),i=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await n({force:!!e.force})){process.stderr.write(`Aborted.
4
+ `);return}c(await u(`Deleting`,async()=>t.apiGateway.labels.user.delete({zone_id:i,name:e.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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?s({description:d(e.description,`description`,`text`)}):o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.user.edit({...r,zone_id:n,name:e.name})),{successLabel:`Updated`});return}let i=s({description:d(e.description,`description`,`text`)});c(await u(`Updating`,async()=>t.apiGateway.labels.user.edit({...i,zone_id:n,name:e.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 e=>{let t={with_mapped_resource_counts:e[`with-mapped-resource-counts`]};if(e.dryRun){l({command:`cf api-gateway labels user get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.labels.user.get({zone_id:i,name:e.name,...t})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}/resources/operation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.user.resources.operation.update({body:r,zone_id:n,name:e.name})),{successLabel:`Updated`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway labels user update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/labels/user/${e.name==null?`<name>`:encodeURIComponent(String(e.name))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),name:String(e.name??``)},bodyKind:`json`,body:e.body===void 0?s({description:d(e.description,`description`,`text`)}):o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.labels.user.update({...r,zone_id:n,name:e.name})),{successLabel:`Updated`});return}let i=s({description:d(e.description,`description`,`text`)});c(await u(`Updating`,async()=>t.apiGateway.labels.user.update({...i,zone_id:n,name:e.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 e=>{if(e.dryRun){l({command:`cf api-gateway operations bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.operations.bulkCreate({body:r,zone_id:n})),{successLabel:`Created`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway operations bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),i=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await n({force:!!e.force})){process.stderr.write(`Aborted.
5
+ `);return}if(e.body){let n=o(e.body);c(await u(`Deleting`,async()=>t.apiGateway.operations.bulkDelete({body:n,zone_id:i})),{successLabel:`Deleted`});return}if(e.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 n=>{if(n.dryRun){l({command:`cf api-gateway operations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${n.zone??n.zoneId??`<zone>`}/api_gateway/operations/item`,pathParams:{"zone-id":String(n.zone??n[`zone-id`]??``)},bodyKind:`json`,body:n.body===void 0?s({endpoint:d(n.endpoint,`endpoint`,`text`),host:d(n.host,`host`,`text`),method:d(n.method,`method`,`text`)}):o(n.body)});return}let i=await a(n),f=await r({zone:n.zone},i,{quiet:n.quiet});if(n.zoneId=f,n.body){let e=o(n.body);c(await u(`Creating`,async()=>i.apiGateway.operations.create({body:e,zone_id:f})),{successLabel:`Created`});return}n.endpoint===void 0&&(n.endpoint=await e(`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/.`)),n.host===void 0&&(n.host=await e(`host`,`RFC3986-compliant host.`)),n.method===void 0&&(n.method=await t(`method`,`The HTTP method used to access the endpoint.`,[`GET`,`POST`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`CONNECT`,`PATCH`,`TRACE`]));let p=s({endpoint:d(n.endpoint,`endpoint`,`text`),host:d(n.host,`host`,`text`),method:d(n.method,`method`,`text`)});c(await u(`Creating`,async()=>i.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 e=>{if(e.dryRun){l({command:`cf api-gateway operations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`none`});return}let t=await a(e),i=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await n({force:!!e.force})){process.stderr.write(`Aborted.
6
+ `);return}c(await u(`Deleting`,async()=>t.apiGateway.operations.delete({zone_id:i,operation_id:e[`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 e=>{let t={feature:e.feature,with_schemas:e[`with-schemas`]};if(e.dryRun){l({command:`cf api-gateway operations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.operations.get({zone_id:i,operation_id:e[`operation-id`],...t})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}}):o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.operations.labels.bulkCreate({...r,zone_id:n})),{successLabel:`Created`});return}let i=s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}});c(await u(`Creating`,async()=>t.apiGateway.operations.labels.bulkCreate({...i,zone_id:n})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}}):o(e.body)});return}let t=await a(e),i=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await n({force:!!e.force})){process.stderr.write(`Aborted.
7
+ `);return}if(e.body){let n=o(e.body);c(await u(`Deleting`,async()=>t.apiGateway.operations.labels.bulkDelete({...n,zone_id:i})),{successLabel:`Deleted`});return}let d=s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}});c(await u(`Deleting`,async()=>t.apiGateway.operations.labels.bulkDelete({...d,zone_id:i})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels bulk-update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}}):o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.operations.labels.bulkUpdate({...r,zone_id:n})),{successLabel:`Updated`});return}if(e[`managed-labels`]===void 0)throw Error(`--managed-labels is required (or pass --body with this field set).`);if(e[`user-labels`]===void 0)throw Error(`--user-labels is required (or pass --body with this field set).`);let i=s({managed:{labels:e[`managed-labels`]},user:{labels:e[`user-labels`]}});c(await u(`Updating`,async()=>t.apiGateway.operations.labels.bulkUpdate({...i,zone_id:n})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:e.managed,user:e.user}):o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Creating`,async()=>t.apiGateway.operations.labels.create({...r,zone_id:n,operation_id:e[`operation-id`]})),{successLabel:`Created`});return}let i=s({managed:e.managed,user:e.user});c(await u(`Creating`,async()=>t.apiGateway.operations.labels.create({...i,zone_id:n,operation_id:e[`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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:e.managed,user:e.user}):o(e.body)});return}let t=await a(e),i=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await n({force:!!e.force})){process.stderr.write(`Aborted.
8
+ `);return}if(e.body){let n=o(e.body);c(await u(`Deleting`,async()=>t.apiGateway.operations.labels.delete({...n,zone_id:i,operation_id:e[`operation-id`]})),{successLabel:`Deleted`});return}let d=s({managed:e.managed,user:e.user});c(await u(`Deleting`,async()=>t.apiGateway.operations.labels.delete({...d,zone_id:i,operation_id:e[`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 e=>{if(e.dryRun){l({command:`cf api-gateway operations labels update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}/labels`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({managed:e.managed,user:e.user}):o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.operations.labels.update({...r,zone_id:n,operation_id:e[`operation-id`]})),{successLabel:`Updated`});return}let i=s({managed:e.managed,user:e.user});c(await u(`Updating`,async()=>t.apiGateway.operations.labels.update({...i,zone_id:n,operation_id:e[`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 e=>{let t={page:e.page,per_page:e[`per-page`],order:e.order,direction:e.direction,host:e.host,method:e.method,endpoint:e.endpoint,feature:e.feature};if(e.dryRun){l({command:`cf api-gateway operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.operations.list({zone_id:i,...t})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway operations schema-validation edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.operations.schemaValidation.edit({body:r,zone_id:n})),{successLabel:`Updated`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway operations schema-validation get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`none`});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,c(await u(`Loading`,async()=>t.apiGateway.operations.schemaValidation.get({zone_id:n,operation_id:e[`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 e=>{if(e.dryRun){l({command:`cf api-gateway operations schema-validation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/operations/${e[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(e[`operation-id`]))}/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"operation-id":String(e[`operation-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({mitigation_action:d(e[`mitigation-action`],`mitigation-action`,`text`)}):o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.operations.schemaValidation.update({...r,zone_id:n,operation_id:e[`operation-id`]})),{successLabel:`Updated`});return}let i=s({mitigation_action:d(e[`mitigation-action`],`mitigation-action`,`text`)});c(await u(`Updating`,async()=>t.apiGateway.operations.schemaValidation.update({...i,zone_id:n,operation_id:e[`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 e=>{let t={host:e.host,feature:e.feature};if(e.dryRun){l({command:`cf api-gateway schemas list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/schemas`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.schemas.list({zone_id:i,...t})),{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
9
  Mitigation actions are as follows:
10
10
 
11
11
  * \`log\` - log request when request does not conform to schema
@@ -21,7 +21,7 @@ A special value of of \`none\` will skip running schema validation entirely for
21
21
  To clear any override, use the special value \`disable_override\`
22
22
 
23
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 e=>{if(e.dryRun){l({command:`cf api-gateway settings schema-validation edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/settings/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({validation_default_mitigation_action:d(e[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:d(e[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)}):o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.settings.schemaValidation.edit({...n,zone_id:r})),{successLabel:`Updated`});return}let i=s({validation_default_mitigation_action:d(e[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:d(e[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)});c(await u(`Updating`,async()=>t.apiGateway.settings.schemaValidation.edit({...i,zone_id:r})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway settings schema-validation get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/settings/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});e.zoneId=r,c(await u(`Loading`,async()=>t.apiGateway.settings.schemaValidation.get({zone_id:r})),{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
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 e=>{if(e.dryRun){l({command:`cf api-gateway settings schema-validation edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/settings/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({validation_default_mitigation_action:d(e[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:d(e[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)}):o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.settings.schemaValidation.edit({...r,zone_id:n})),{successLabel:`Updated`});return}let i=s({validation_default_mitigation_action:d(e[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:d(e[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)});c(await u(`Updating`,async()=>t.apiGateway.settings.schemaValidation.edit({...i,zone_id:n})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway settings schema-validation get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/settings/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,c(await u(`Loading`,async()=>t.apiGateway.settings.schemaValidation.get({zone_id:n})),{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
25
 
26
26
  Mitigation actions are as follows:
27
27
 
@@ -29,5 +29,5 @@ Mitigation actions are as follows:
29
29
  * \`block\` - deny access to the site when request does not conform to schema
30
30
 
31
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 e=>{if(e.dryRun){l({command:`cf api-gateway settings schema-validation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/settings/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({validation_default_mitigation_action:d(e[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:d(e[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)}):o(e.body)});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});if(e.zoneId=i,e.body){let t=o(e.body);c(await u(`Updating`,async()=>r.apiGateway.settings.schemaValidation.update({...t,zone_id:i})),{successLabel:`Updated`});return}e[`validation-default-mitigation-action`]===void 0&&(e[`validation-default-mitigation-action`]=await t(`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=s({validation_default_mitigation_action:d(e[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:d(e[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)});c(await u(`Updating`,async()=>r.apiGateway.settings.schemaValidation.update({...f,zone_id:i})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway user-schemas create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`multipart`,body:{body:e.body,file:e.file,kind:e.kind,name:e.name,"validation-enabled":e[`validation-enabled`]}});return}let t=await a(e);if(e.zoneId=await n({zone:e.zone},t,{quiet:e.quiet}),e.file!==void 0||e.body!==void 0||e.kind!==void 0||e.name!==void 0||e[`validation-enabled`]!==void 0){let n=new FormData;if(e.file){let t=f(e.file);n.append(`file`,new Blob([t]),e.file.split(/[\\/]/).filter(Boolean).pop())}else e.body!==void 0&&n.append(`file`,e.body);e.kind!==void 0&&n.append(`kind`,String(d(e.kind,`kind`,`text`)??``)),e.name!==void 0&&n.append(`name`,String(d(e.name,`name`,`text`)??``)),e[`validation-enabled`]!==void 0&&n.append(`validation_enabled`,String(d(e[`validation-enabled`],`validation-enabled`,`text`)??``)),c(await u(`Creating`,async()=>i(t,`POST`,`/zones/${e.zoneId}/api_gateway/user_schemas`,{body:n})),{successLabel:`Created`});return}if(e.body){let n=d(e.body,`body`,`binary`);c(await u(`Creating`,async()=>i(t,`POST`,`/zones/${e.zoneId}/api_gateway/user_schemas`,{body:n,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway user-schemas delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas/${e[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(e[`schema-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"schema-id":String(e[`schema-id`]??``)},bodyKind:`none`});return}let t=await a(e),i=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await r({force:!!e.force})){process.stderr.write(`Aborted.
33
- `);return}c(await u(`Deleting`,async()=>t.apiGateway.userSchemas.delete({zone_id:i,schema_id:e[`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 e=>{if(e.dryRun){l({command:`cf api-gateway user-schemas edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas/${e[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(e[`schema-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"schema-id":String(e[`schema-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),r=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=r,e.body){let n=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.userSchemas.edit({...n,zone_id:r,schema_id:e[`schema-id`]})),{successLabel:`Updated`});return}c(await u(`Updating`,async()=>t.apiGateway.userSchemas.edit({zone_id:r,schema_id:e[`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 e=>{let t={omit_source:e[`omit-source`]};if(e.dryRun){l({command:`cf api-gateway user-schemas get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas/${e[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(e[`schema-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"schema-id":String(e[`schema-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.userSchemas.get({zone_id:i,schema_id:e[`schema-id`],...t})),{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 e=>{let t={page:e.page,per_page:e[`per-page`]};if(e.dryRun){l({command:`cf api-gateway user-schemas hosts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas/hosts`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.userSchemas.hosts.list({zone_id:i,...t})),{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 e=>{let t={page:e.page,per_page:e[`per-page`],omit_source:e[`omit-source`],validation_enabled:e[`validation-enabled`]};if(e.dryRun){l({command:`cf api-gateway user-schemas list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.userSchemas.list({zone_id:i,...t})),{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 e=>{let t={feature:e.feature,host:e.host,method:e.method,endpoint:e.endpoint,page:e.page,per_page:e[`per-page`],operation_status:e[`operation-status`]};if(e.dryRun){l({command:`cf api-gateway user-schemas operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas/${e[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(e[`schema-id`]))}/operations`,pathParams:{"schema-id":String(e[`schema-id`]??``),"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let r=await a(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>r.apiGateway.userSchemas.operations.list({zone_id:i,schema_id:e[`schema-id`],...t})),{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};
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 e=>{if(e.dryRun){l({command:`cf api-gateway settings schema-validation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/settings/schema_validation`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?s({validation_default_mitigation_action:d(e[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:d(e[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)}):o(e.body)});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});if(e.zoneId=i,e.body){let t=o(e.body);c(await u(`Updating`,async()=>n.apiGateway.settings.schemaValidation.update({...t,zone_id:i})),{successLabel:`Updated`});return}e[`validation-default-mitigation-action`]===void 0&&(e[`validation-default-mitigation-action`]=await t(`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=s({validation_default_mitigation_action:d(e[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:d(e[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)});c(await u(`Updating`,async()=>n.apiGateway.settings.schemaValidation.update({...f,zone_id:i})),{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 e=>{if(e.dryRun){l({command:`cf api-gateway user-schemas create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`multipart`,body:{body:e.body,file:e.file,kind:e.kind,name:e.name,"validation-enabled":e[`validation-enabled`]}});return}let t=await a(e);if(e.zoneId=await r({zone:e.zone},t,{quiet:e.quiet}),e.file!==void 0||e.body!==void 0||e.kind!==void 0||e.name!==void 0||e[`validation-enabled`]!==void 0){let n=new FormData;if(e.file){let t=f(e.file);n.append(`file`,new Blob([t]),e.file.split(/[\\/]/).filter(Boolean).pop())}else e.body!==void 0&&n.append(`file`,e.body);e.kind!==void 0&&n.append(`kind`,String(d(e.kind,`kind`,`text`)??``)),e.name!==void 0&&n.append(`name`,String(d(e.name,`name`,`text`)??``)),e[`validation-enabled`]!==void 0&&n.append(`validation_enabled`,String(d(e[`validation-enabled`],`validation-enabled`,`text`)??``)),c(await u(`Creating`,async()=>i(t,`POST`,`/zones/${e.zoneId}/api_gateway/user_schemas`,{body:n})),{successLabel:`Created`});return}if(e.body){let n=d(e.body,`body`,`binary`);c(await u(`Creating`,async()=>i(t,`POST`,`/zones/${e.zoneId}/api_gateway/user_schemas`,{body:n,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(e.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 e=>{if(e.dryRun){l({command:`cf api-gateway user-schemas delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas/${e[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(e[`schema-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"schema-id":String(e[`schema-id`]??``)},bodyKind:`none`});return}let t=await a(e),i=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=i,!await n({force:!!e.force})){process.stderr.write(`Aborted.
33
+ `);return}c(await u(`Deleting`,async()=>t.apiGateway.userSchemas.delete({zone_id:i,schema_id:e[`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 e=>{if(e.dryRun){l({command:`cf api-gateway user-schemas edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas/${e[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(e[`schema-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"schema-id":String(e[`schema-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:o(e.body)});return}let t=await a(e),n=await r({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=o(e.body);c(await u(`Updating`,async()=>t.apiGateway.userSchemas.edit({...r,zone_id:n,schema_id:e[`schema-id`]})),{successLabel:`Updated`});return}c(await u(`Updating`,async()=>t.apiGateway.userSchemas.edit({zone_id:n,schema_id:e[`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 e=>{let t={omit_source:e[`omit-source`]};if(e.dryRun){l({command:`cf api-gateway user-schemas get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas/${e[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(e[`schema-id`]))}`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``),"schema-id":String(e[`schema-id`]??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.userSchemas.get({zone_id:i,schema_id:e[`schema-id`],...t})),{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 e=>{let t={page:e.page,per_page:e[`per-page`]};if(e.dryRun){l({command:`cf api-gateway user-schemas hosts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas/hosts`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.userSchemas.hosts.list({zone_id:i,...t})),{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 e=>{let t={page:e.page,per_page:e[`per-page`],omit_source:e[`omit-source`],validation_enabled:e[`validation-enabled`]};if(e.dryRun){l({command:`cf api-gateway user-schemas list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.userSchemas.list({zone_id:i,...t})),{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 e=>{let t={feature:e.feature,host:e.host,method:e.method,endpoint:e.endpoint,page:e.page,per_page:e[`per-page`],operation_status:e[`operation-status`]};if(e.dryRun){l({command:`cf api-gateway user-schemas operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/api_gateway/user_schemas/${e[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(e[`schema-id`]))}/operations`,pathParams:{"schema-id":String(e[`schema-id`]??``),"zone-id":String(e.zone??e[`zone-id`]??``)},query:t,bodyKind:`none`});return}let n=await a(e),i=await r({zone:e.zone},n,{quiet:e.quiet});e.zoneId=i,c(await u(`Loading`,async()=>n.apiGateway.userSchemas.operations.list({zone_id:i,schema_id:e[`schema-id`],...t})),{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{T as e,x as t}from"./oauth-Bk-F-tIO.mjs";import{n}from"./auth-CSC4yhEJ.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-DrDErV9w.mjs";import{n as c}from"./input-validation-_fMCApaH.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){o({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?i({value:c(l.value,`value`,`text`)}):r(l.body)});return}let u=await n(l),d=await t({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,l.body){let e=r(l.body);a(await s(`Updating`,async()=>u.argo.smartRouting.edit({...e,zone_id:d})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await e(`value`,`Specifies the enablement value of Argo Smart Routing.`,[`on`,`off`]));let f=i({value:c(l.value,`value`,`text`)});a(await s(`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 e=>{if(e.dryRun){o({command:`cf argo smart-routing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/argo/smart_routing`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,a(await s(`Loading`,async()=>r.argo.smartRouting.get({zone_id:i})),{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){o({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?i({value:c(l.value,`value`,`text`)}):r(l.body)});return}let u=await n(l),d=await t({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,l.body){let e=r(l.body);a(await s(`Updating`,async()=>u.argo.tieredCaching.edit({...e,zone_id:d})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await e(`value`,`Enables Tiered Caching.`,[`on`,`off`]));let f=i({value:c(l.value,`value`,`text`)});a(await s(`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 e=>{if(e.dryRun){o({command:`cf argo tiered-caching get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/argo/tiered_caching`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,a(await s(`Loading`,async()=>r.argo.tieredCaching.get({zone_id:i})),{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{S as e,g as t,w as n}from"./oauth-Bk-F-tIO.mjs";import{n as r}from"./auth-CSC4yhEJ.mjs";import{t as i}from"./output-B6fBFRqe.mjs";import{n as a,t as o}from"./progress-DrDErV9w.mjs";import{t as s}from"./local-CYc9q7l2.mjs";import{t as c}from"./cli-types-BeyOc81z.mjs";import{n as l,t as u}from"./raw-fetch-_n0lMAnD.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 n=>{if(n.dryRun){a({command:`cf artifacts namespaces artifactsNamespacesGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}`,pathParams:{namespace:String(n.namespace??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t(c);n.accountId=l,i(await o(`Loading`,async()=>c.artifacts.namespaces.artifactsNamespacesGet({account_id:l,namespace:n.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 n=>{let c={limit:n.limit,cursor:n.cursor};if(n.dryRun){a({command:`cf artifacts namespaces artifactsNamespacesList`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t(l);n.accountId=u,i(await o(`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 n=>{if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposBlobGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/blob/${n.hash==null?`<hash>`:encodeURIComponent(String(n.hash))}`,pathParams:{namespace:String(n.namespace??``),name:String(n.name??``),hash:String(n.hash??``)},bodyKind:`none`});return}let i=await r(n),c=n.local?s:await t(i);n.accountId=c;let d=await o(`Loading`,async()=>u(`/accounts/${c}/artifacts/namespaces/${encodeURIComponent(String(n.namespace))}/repos/${encodeURIComponent(String(n.name))}/blob/${encodeURIComponent(String(n.hash))}`,{method:`GET`,localEndpoint:n.local?n.localEndpoint:void 0}));l(n.text===!0?d.toString(`utf-8`):d)}};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 n=>{if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposCommitGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/commit/${n.hash==null?`<hash>`:encodeURIComponent(String(n.hash))}`,pathParams:{namespace:String(n.namespace??``),name:String(n.name??``),hash:String(n.hash??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t(c);n.accountId=l,i(await o(`Loading`,async()=>c.artifacts.namespaces.artifactsReposCommitGet({account_id:l,namespace:n.namespace,name:n.name,hash:n.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 n=>{if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposCreate`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos`,pathParams:{namespace:String(n.namespace??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t(c);n.accountId=l,i(await o(`Creating`,async()=>c.artifacts.namespaces.artifactsReposCreate({account_id:l,namespace:n.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){a({command:`cf artifacts namespaces artifactsReposDelete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<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 r(c),u=c.local?s:await t(l);if(c.accountId=u,!await n({force:!!c.force})){process.stderr.write(`Aborted.
3
+ `);return}i(await o(`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 n=>{let i={ref:n.ref,path:n.path};if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposFileGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/file`,pathParams:{namespace:String(n.namespace??``),name:String(n.name??``)},query:i,bodyKind:`none`});return}let c=await r(n),d=n.local?s:await t(c);n.accountId=d;let f=new URLSearchParams(Object.entries(i).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),p=await o(`Loading`,async()=>u(`/accounts/${d}/artifacts/namespaces/${encodeURIComponent(String(n.namespace))}/repos/${encodeURIComponent(String(n.name))}/file${f?`?`+f:``}`,{method:`GET`,localEndpoint:n.local?n.localEndpoint:void 0}));l(n.text===!0?p.toString(`utf-8`):p)}};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 n=>{if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposFork`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/fork`,pathParams:{namespace:String(n.namespace??``),name:String(n.name??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t(c);n.accountId=l,i(await o(`Creating`,async()=>c.artifacts.namespaces.artifactsReposFork({account_id:l,namespace:n.namespace,name:n.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 n=>{if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}`,pathParams:{namespace:String(n.namespace??``),name:String(n.name??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t(c);n.accountId=l,i(await o(`Loading`,async()=>c.artifacts.namespaces.artifactsReposGet({account_id:l,namespace:n.namespace,name:n.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 n=>{if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposImport`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/import`,pathParams:{namespace:String(n.namespace??``),name:String(n.name??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t(c);n.accountId=l,i(await o(`Creating`,async()=>c.artifacts.namespaces.artifactsReposImport({account_id:l,namespace:n.namespace,name:n.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 n=>{let c={limit:n.limit,cursor:n.cursor,search:n.search,sort:n.sort,direction:n.direction};if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposList`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos`,pathParams:{namespace:String(n.namespace??``)},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t(l);n.accountId=u,i(await o(`Loading`,async()=>l.artifacts.namespaces.artifactsReposList({account_id:u,namespace:n.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 n=>{let c={ref:n.ref,limit:n.limit,offset:n.offset};if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposLogGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/log`,pathParams:{namespace:String(n.namespace??``),name:String(n.name??``)},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t(l);n.accountId=u,i(await o(`Loading`,async()=>l.artifacts.namespaces.artifactsReposLogGet({account_id:u,namespace:n.namespace,name:n.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 n=>{if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposRawGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/raw/${n.ref==null?`<ref>`:encodeURIComponent(String(n.ref))}/${n.path==null?`<path>`:encodeURIComponent(String(n.path))}`,pathParams:{namespace:String(n.namespace??``),name:String(n.name??``),ref:String(n.ref??``),path:String(n.path??``)},bodyKind:`none`});return}let i=await r(n),c=n.local?s:await t(i);n.accountId=c;let d=await o(`Loading`,async()=>u(`/accounts/${c}/artifacts/namespaces/${encodeURIComponent(String(n.namespace))}/repos/${encodeURIComponent(String(n.name))}/raw/${encodeURIComponent(String(n.ref))}/${encodeURIComponent(String(n.path))}`,{method:`GET`,localEndpoint:n.local?n.localEndpoint:void 0}));l(n.text===!0?d.toString(`utf-8`):d)}};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 n=>{if(n.dryRun){a({command:`cf artifacts namespaces artifactsReposTreeGet`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/tree/${n.hash==null?`<hash>`:encodeURIComponent(String(n.hash))}`,pathParams:{namespace:String(n.namespace??``),name:String(n.name??``),hash:String(n.hash??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t(c);n.accountId=l,i(await o(`Loading`,async()=>c.artifacts.namespaces.artifactsReposTreeGet({account_id:l,namespace:n.namespace,name:n.name,hash:n.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 n=>{let c={state:n.state,page:n.page,per_page:n[`per-page`]};if(n.dryRun){a({command:`cf artifacts namespaces artifactsRepoTokensList`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/repos/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/tokens`,pathParams:{namespace:String(n.namespace??``),name:String(n.name??``)},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t(l);n.accountId=u,i(await o(`Loading`,async()=>l.artifacts.namespaces.artifactsRepoTokensList({account_id:u,namespace:n.namespace,name:n.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 n=>{if(n.dryRun){a({command:`cf artifacts namespaces artifactsTokensCreate`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/artifacts/namespaces/${n.namespace==null?`<namespace>`:encodeURIComponent(String(n.namespace))}/tokens`,pathParams:{namespace:String(n.namespace??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t(c);n.accountId=l,i(await o(`Creating`,async()=>c.artifacts.namespaces.artifactsTokensCreate({account_id:l,namespace:n.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){a({command:`cf artifacts namespaces artifactsTokensRevoke`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<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 r(c),u=c.local?s:await t(l);if(c.accountId=u,!await n({force:!!c.force})){process.stderr.write(`Aborted.
4
+ `);return}i(await o(`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};
@@ -0,0 +1,2 @@
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};
@@ -0,0 +1,9 @@
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.
4
+
5
+ Please set one of the following:
6
+ 1. Set the CLOUDFLARE_API_TOKEN environment variable
7
+ 2. Run 'cf auth login' to authenticate via OAuth
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};
@@ -0,0 +1,5 @@
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...
3
+ `))}else e.force&&o()&&console.log(i(`Re-authenticating...
4
+ `));if(console.log(i(`Starting OAuth login flow...
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{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";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/${e()??`<account-id>`}/billing/profile`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t(c);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/${e()??`<account-id>`}/paygo-usage`,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.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/${e()??`<account-id>`}/paygo-usage-info`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t(c);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{E as e,T as t,x as n}from"./oauth-Bk-F-tIO.mjs";import{n as r}from"./auth-CSC4yhEJ.mjs";import{n as i,t as a}from"./body-parser-DWSy7uZ8.mjs";import{t as o}from"./output-B6fBFRqe.mjs";import{n as s,t as c}from"./progress-DrDErV9w.mjs";import{n as l}from"./input-validation-_fMCApaH.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){s({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?a({description:l(u.description,`description`,`text`),expression:l(u.expression,`expression`,`text`),first_request_seen_at:l(u[`first-request-seen-at`],`first-request-seen-at`,`text`),last_request_seen_at:l(u[`last-request-seen-at`],`last-request-seen-at`,`text`),requests:u.requests,subtype:l(u.subtype,`subtype`,`text`),type:l(u.type,`type`,`text`)}):i(u.body)});return}let d=await r(u),f=await n({zone:u.zone},d,{quiet:u.quiet});if(u.zoneId=f,u.body){let e=i(u.body);o(await c(`Creating`,async()=>d.botManagement.feedback.create({body:e,zone_id:f})),{successLabel:`Created`});return}if(u.description===void 0&&(u.description=await e(`description`,`The description field`)),u.expression===void 0&&(u.expression=await e(`expression`,`Wirefilter expression describing the traffic being reported.`)),u[`first-request-seen-at`]===void 0&&(u[`first-request-seen-at`]=await e(`first-request-seen-at`,`The first_request_seen_at field`)),u[`last-request-seen-at`]===void 0&&(u[`last-request-seen-at`]=await e(`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 t(`type`,`Type of feedback report.`,[`false_positive`,`false_negative`]));let p=a({description:l(u.description,`description`,`text`),expression:l(u.expression,`expression`,`text`),first_request_seen_at:l(u[`first-request-seen-at`],`first-request-seen-at`,`text`),last_request_seen_at:l(u[`last-request-seen-at`],`last-request-seen-at`,`text`),requests:u.requests,subtype:l(u.subtype,`subtype`,`text`),type:l(u.type,`type`,`text`)});o(await c(`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 e=>{if(e.dryRun){s({command:`cf bot-management feedback list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/bot_management/feedback`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await r(e),i=await n({zone:e.zone},t,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading`,async()=>t.botManagement.feedback.list({zone_id:i})),{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 e=>{if(e.dryRun){s({command:`cf bot-management get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/bot_management`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await r(e),i=await n({zone:e.zone},t,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading`,async()=>t.botManagement.get({zone_id:i})),{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 e=>{if(e.dryRun){s({command:`cf bot-management update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/bot_management`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?a({ai_bots_protection:l(e[`ai-bots-protection`],`ai-bots-protection`,`text`),cf_robots_variant:l(e[`cf-robots-variant`],`cf-robots-variant`,`text`),content_bots_protection:l(e[`content-bots-protection`],`content-bots-protection`,`text`),crawler_protection:l(e[`crawler-protection`],`crawler-protection`,`text`),enable_js:e[`enable-js`],is_robots_txt_managed:e[`is-robots-txt-managed`],fight_mode:e[`fight-mode`],stale_zone_configuration:{optimize_wordpress:e[`stale-zone-configuration-optimize-wordpress`],sbfm_definitely_automated:l(e[`stale-zone-configuration-sbfm-definitely-automated`],`stale-zone-configuration-sbfm-definitely-automated`,`text`),sbfm_likely_automated:l(e[`stale-zone-configuration-sbfm-likely-automated`],`stale-zone-configuration-sbfm-likely-automated`,`text`),sbfm_static_resource_protection:l(e[`stale-zone-configuration-sbfm-static-resource-protection`],`stale-zone-configuration-sbfm-static-resource-protection`,`text`),sbfm_verified_bots:l(e[`stale-zone-configuration-sbfm-verified-bots`],`stale-zone-configuration-sbfm-verified-bots`,`text`),suppress_session_score:e[`stale-zone-configuration-suppress-session-score`],fight_mode:e[`stale-zone-configuration-fight-mode`]},optimize_wordpress:e[`optimize-wordpress`],sbfm_definitely_automated:l(e[`sbfm-definitely-automated`],`sbfm-definitely-automated`,`text`),sbfm_static_resource_protection:e[`sbfm-static-resource-protection`],sbfm_verified_bots:l(e[`sbfm-verified-bots`],`sbfm-verified-bots`,`text`),sbfm_likely_automated:l(e[`sbfm-likely-automated`],`sbfm-likely-automated`,`text`),auto_update_model:e[`auto-update-model`],bm_cookie_enabled:e[`bm-cookie-enabled`],suppress_session_score:e[`suppress-session-score`]}):i(e.body)});return}let t=await r(e),u=await n({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=u,e.body){let n=i(e.body);o(await c(`Updating`,async()=>t.botManagement.update({body:n,zone_id:u})),{successLabel:`Updated`});return}let d=a({ai_bots_protection:l(e[`ai-bots-protection`],`ai-bots-protection`,`text`),cf_robots_variant:l(e[`cf-robots-variant`],`cf-robots-variant`,`text`),content_bots_protection:l(e[`content-bots-protection`],`content-bots-protection`,`text`),crawler_protection:l(e[`crawler-protection`],`crawler-protection`,`text`),enable_js:e[`enable-js`],is_robots_txt_managed:e[`is-robots-txt-managed`],fight_mode:e[`fight-mode`],stale_zone_configuration:{optimize_wordpress:e[`stale-zone-configuration-optimize-wordpress`],sbfm_definitely_automated:l(e[`stale-zone-configuration-sbfm-definitely-automated`],`stale-zone-configuration-sbfm-definitely-automated`,`text`),sbfm_likely_automated:l(e[`stale-zone-configuration-sbfm-likely-automated`],`stale-zone-configuration-sbfm-likely-automated`,`text`),sbfm_static_resource_protection:l(e[`stale-zone-configuration-sbfm-static-resource-protection`],`stale-zone-configuration-sbfm-static-resource-protection`,`text`),sbfm_verified_bots:l(e[`stale-zone-configuration-sbfm-verified-bots`],`stale-zone-configuration-sbfm-verified-bots`,`text`),suppress_session_score:e[`stale-zone-configuration-suppress-session-score`],fight_mode:e[`stale-zone-configuration-fight-mode`]},optimize_wordpress:e[`optimize-wordpress`],sbfm_definitely_automated:l(e[`sbfm-definitely-automated`],`sbfm-definitely-automated`,`text`),sbfm_static_resource_protection:e[`sbfm-static-resource-protection`],sbfm_verified_bots:l(e[`sbfm-verified-bots`],`sbfm-verified-bots`,`text`),sbfm_likely_automated:l(e[`sbfm-likely-automated`],`sbfm-likely-automated`,`text`),auto_update_model:e[`auto-update-model`],bm_cookie_enabled:e[`bm-cookie-enabled`],suppress_session_score:e[`suppress-session-score`]});o(await c(`Updating`,async()=>t.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{S as e,g as t,w as n}from"./oauth-Bk-F-tIO.mjs";import{n as r}from"./auth-CSC4yhEJ.mjs";import{t as i}from"./output-B6fBFRqe.mjs";import{n as a,t as o}from"./progress-DrDErV9w.mjs";import{t as s}from"./local-CYc9q7l2.mjs";import{t as c}from"./cli-types-BeyOc81z.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 n=>{let c={date:n.date};if(n.dryRun){a({command:`cf botnet-feed asn day-report`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/botnet_feed/asn/${n[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(n[`asn-id`]))}/day_report`,pathParams:{"asn-id":String(n[`asn-id`]??``)},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t(l);n.accountId=u,i(await o(`Loading`,async()=>l.botnetFeed.asn.dayReport({account_id:u,asn_id:n[`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 n=>{if(n.dryRun){a({command:`cf botnet-feed asn full-report`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/botnet_feed/asn/${n[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(n[`asn-id`]))}/full_report`,pathParams:{"asn-id":String(n[`asn-id`]??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t(c);n.accountId=l,i(await o(`Loading`,async()=>c.botnetFeed.asn.fullReport({account_id:l,asn_id:n[`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){a({command:`cf botnet-feed configs asn delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<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 r(c),u=c.local?s:await t(l);if(c.accountId=u,!await n({force:!!c.force})){process.stderr.write(`Aborted.
3
+ `);return}i(await o(`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 n=>{if(n.dryRun){a({command:`cf botnet-feed configs asn get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/botnet_feed/configs/asn`,pathParams:{},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t(c);n.accountId=l,i(await o(`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};