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
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{w as e,x as t}from"./oauth-Bk-F-tIO.mjs";import{n}from"./auth-CSC4yhEJ.mjs";import{n as r}from"./body-parser-DWSy7uZ8.mjs";import{t as i}from"./output-B6fBFRqe.mjs";import{n as a,t as o}from"./progress-DrDErV9w.mjs";function s(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})}const c={command:`delete`,describe:`Disables all Managed Transforms.`,builder:s,handler:async r=>{if(r.dryRun){a({command:`cf managed-transforms delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${r.zone??r.zoneId??`<zone>`}/managed_headers`,pathParams:{"zone-id":String(r.zone??r[`zone-id`]??``)},bodyKind:`none`});return}let s=await n(r),c=await t({zone:r.zone},s,{quiet:r.quiet});if(r.zoneId=c,!await e({force:!!r.force})){process.stderr.write(`Aborted.
3
+ `);return}i(await o(`Deleting`,async()=>s.managedTransforms.delete({zone_id:c})),{successLabel:`Deleted`})}};function l(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`A Managed Transforms patch object. Both fields are optional; only the sections provided will be updated.`})}const u={command:`edit`,describe:`Updates the status of one or more Managed Transforms.`,builder:l,handler:async e=>{if(e.dryRun){a({command:`cf managed-transforms edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/managed_headers`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:r(e.body)});return}let s=await n(e),c=await t({zone:e.zone},s,{quiet:e.quiet});if(e.zoneId=c,e.body){let t=r(e.body);i(await o(`Updating`,async()=>s.managedTransforms.edit({...t,zone_id:c})),{successLabel:`Updated`});return}i(await o(`Updating`,async()=>s.managedTransforms.edit({zone_id:c})),{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:`list`,describe:`Fetches a list of all Managed Transforms.`,builder:d,handler:async e=>{if(e.dryRun){a({command:`cf managed-transforms list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/managed_headers`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),s=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=s,i(await o(`Loading`,async()=>r.managedTransforms.list({zone_id:s})),{successLabel:`Loaded`})}},p={command:`managed-transforms`,describe:`Cloudflare-managed HTTP header transforms — automatically add security headers, remove server info, etc.`,builder:e=>e.command(c).command(u).command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{p as default};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{E as e,S as t,g as n,w as r}from"./oauth-Bk-F-tIO.mjs";import{n as i}from"./auth-CSC4yhEJ.mjs";import{n as a,t as o}from"./body-parser-DWSy7uZ8.mjs";import{t as s}from"./output-B6fBFRqe.mjs";import{n as c,t as l}from"./progress-DrDErV9w.mjs";import{n as u}from"./input-validation-_fMCApaH.mjs";import{t as d}from"./local-CYc9q7l2.mjs";import{t as f}from"./cli-types-BeyOc81z.mjs";function p(e){return e.positional(`mtls-certificate-id`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const m={command:`get <mtls-certificate-id>`,describe:`Lists all active associations between the certificate and Cloudflare services.`,builder:p,handler:async e=>{if(e.dryRun){c({command:`cf mtls-certificates associations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/mtls_certificates/${e[`mtls-certificate-id`]==null?`<mtls-certificate-id>`:encodeURIComponent(String(e[`mtls-certificate-id`]))}/associations`,pathParams:{"mtls-certificate-id":String(e[`mtls-certificate-id`]??``)},bodyKind:`none`});return}let r=await i(e),a=e.local?d:await n(r);e.accountId=a,s(await l(`Loading`,async()=>r.mtlsCertificates.associations.get({account_id:a,mtls_certificate_id:e[`mtls-certificate-id`]})),{successLabel:`Loaded`})}},h={command:`associations`,describe:`Operations for associations`,builder:e=>e.command(m).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function g(e){return e.option(`ca`,{type:`boolean`,description:`Indicates whether the certificate is a CA or leaf certificate.`}).option(`certificates`,{type:`string`,description:`The uploaded root CA certificate.`}).option(`name`,{type:`string`,description:`Optional unique name for the certificate. Only used for human readability.`}).option(`private-key`,{type:`string`,description:`The private key for the certificate. This field is only needed for specific use cases such as using a custom certificate with Zero Trust's block page.`}).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:`create`,describe:`Upload a certificate that you want to use with mTLS-enabled Cloudflare services, such as Bring Your Own CA (BYO-CA) for mTLS. To create certificates issued by the Cloudflare managed CA, use the [Create Client Certificate endpoint](/api/resources/client_certificates/methods/create/).`,builder:g,handler:async r=>{if(r.dryRun){c({command:`cf mtls-certificates create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/mtls_certificates`,pathParams:{},bodyKind:`json`,body:r.body===void 0?o({ca:r.ca,certificates:u(r.certificates,`certificates`,`text`),name:u(r.name,`name`,`text`),private_key:u(r[`private-key`],`private-key`,`text`)}):a(r.body)});return}let f=await i(r),p=r.local?d:await n(f);if(r.accountId=p,r.body){let e=a(r.body);s(await l(`Creating`,async()=>f.mtlsCertificates.create({...e,account_id:p})),{successLabel:`Created`});return}if(r.ca===void 0)throw Error(`--ca is required (or pass --body with this field set).`);r.certificates===void 0&&(r.certificates=await e(`certificates`,`The uploaded root CA certificate.`));let m=o({ca:r.ca,certificates:u(r.certificates,`certificates`,`text`),name:u(r.name,`name`,`text`),private_key:u(r[`private-key`],`private-key`,`text`)});s(await l(`Creating`,async()=>f.mtlsCertificates.create({...m,account_id:p})),{successLabel:`Created`})}};function v(e){return e.positional(`mtls-certificate-id`,{type:`string`,description:`Identifier.`,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 y={command:`delete <mtls-certificate-id>`,describe:`Deletes the mTLS certificate unless the certificate is in use by one or more Cloudflare services.`,builder:v,handler:async e=>{if(e.dryRun){c({command:`cf mtls-certificates delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/mtls_certificates/${e[`mtls-certificate-id`]==null?`<mtls-certificate-id>`:encodeURIComponent(String(e[`mtls-certificate-id`]))}`,pathParams:{"mtls-certificate-id":String(e[`mtls-certificate-id`]??``)},bodyKind:`none`});return}let a=await i(e),o=e.local?d:await n(a);if(e.accountId=o,!await r({force:!!e.force})){process.stderr.write(`Aborted.
3
+ `);return}s(await l(`Deleting`,async()=>a.mtlsCertificates.delete({account_id:o,mtls_certificate_id:e[`mtls-certificate-id`]})),{successLabel:`Deleted`})}};function b(e){return e.positional(`mtls-certificate-id`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const x={command:`get <mtls-certificate-id>`,describe:`Fetches a single mTLS certificate uploaded to your account. To get a certificate issued by the Cloudflare managed CA, use the [Client Certificate Details endpoint](/api/resources/client_certificates/methods/get/).`,builder:b,handler:async e=>{if(e.dryRun){c({command:`cf mtls-certificates get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/mtls_certificates/${e[`mtls-certificate-id`]==null?`<mtls-certificate-id>`:encodeURIComponent(String(e[`mtls-certificate-id`]))}`,pathParams:{"mtls-certificate-id":String(e[`mtls-certificate-id`]??``)},bodyKind:`none`});return}let r=await i(e),a=e.local?d:await n(r);e.accountId=a,s(await l(`Loading`,async()=>r.mtlsCertificates.get({account_id:a,mtls_certificate_id:e[`mtls-certificate-id`]})),{successLabel:`Loaded`})}};function S(e){return e.option(`type`,{type:`string`,description:`Filters results by certificate type. Multiple types can be comma-separated.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const C={command:`list`,describe:`Lists all mTLS certificates uploaded to your account, such as Bring Your Own CA (BYO-CA) for mTLS. To list certificates issued by the Cloudflare managed CA, use the [List Client Certificates endpoint](/api/resources/client_certificates/methods/list/).`,builder:f(S),handler:async e=>{let r={type:e.type};if(e.dryRun){c({command:`cf mtls-certificates list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/mtls_certificates`,pathParams:{},query:r,bodyKind:`none`});return}let a=await i(e),o=e.local?d:await n(a);e.accountId=o,s(await l(`Loading`,async()=>a.mtlsCertificates.list({account_id:o,...r})),{successLabel:`Loaded`})}},w={command:`mtls-certificates`,describe:`Upload and manage mTLS certificates used by API Shield, Workers, and Gateway for client authentication`,builder:e=>e.command(_).command(y).command(x).command(C).command(h).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{w as default};
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{C as e,D as t,T as n,_ as r,n as i}from"./auth-ffdf9yR0.mjs";import{n as a,t as o}from"./body-parser-DKa8Ipg1.mjs";import{t as s}from"./output-BJFNwj7b.mjs";import{n as c,t as l}from"./progress-CrCGTq7N.mjs";import{n as u}from"./input-validation-zEO81MWN.mjs";import{t as d}from"./local-VJaJ3BZ1.mjs";function f(e){return e.option(`account`,{type:`string`,description:`Customer account tag`}).option(`bgp-customer-asn`,{type:`number`,description:`ASN used on the customer end of the BGP session`}).option(`bgp-extra-prefixes`,{type:`string`,array:!0,description:`Extra set of static prefixes to advertise to the customer's end of the session`}).option(`bgp-md5-key`,{type:`string`,description:`MD5 key to use for session authentication.
2
+ import{E as e,S as t,g as n,w as r}from"./oauth-Bk-F-tIO.mjs";import{n as i}from"./auth-CSC4yhEJ.mjs";import{n as a,t as o}from"./body-parser-DWSy7uZ8.mjs";import{t as s}from"./output-B6fBFRqe.mjs";import{n as c,t as l}from"./progress-DrDErV9w.mjs";import{n as u}from"./input-validation-_fMCApaH.mjs";import{t as d}from"./local-CYc9q7l2.mjs";function f(e){return e.option(`account`,{type:`string`,description:`Customer account tag`}).option(`bgp-customer-asn`,{type:`number`,description:`ASN used on the customer end of the BGP session`}).option(`bgp-extra-prefixes`,{type:`string`,array:!0,description:`Extra set of static prefixes to advertise to the customer's end of the session`}).option(`bgp-md5-key`,{type:`string`,description:`MD5 key to use for session authentication.
3
3
 
4
4
  Note that *this is not a security measure*. MD5 is not a valid security mechanism, and the
5
5
  key is not treated as a secret value. This is *only* supported for preventing
@@ -14,8 +14,8 @@ character:
14
14
  In other words, MD5 keys may contain any printable ASCII character aside from newline (0x0A),
15
15
  quotation mark (\`"\`), vertical tab (0x0B), carriage return (0x0D), tab (0x09), form feed
16
16
  (0x0C), and the question mark (\`?\`). Requests specifying an MD5 key with one or more of
17
- these disallowed characters will be rejected.`}).option(`interconnect`,{type:`string`,description:`The interconnect field`}).option(`magic-conduit-name`,{type:`string`,description:`The magic.conduit_name field`}).option(`magic-description`,{type:`string`,description:`The magic.description field`}).option(`magic-mtu`,{type:`number`,description:`The magic.mtu field`}).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)`}).check(e=>{if([`bgp-customer-asn`,`bgp-extra-prefixes`,`bgp-md5-key`].some(t=>e[t]!==void 0)){let t=[`bgp-customer-asn`,`bgp-extra-prefixes`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --bgp-* flag is set`)}return!0})}const p={command:`create`,describe:`Create a new CNI object`,builder:f,handler:async n=>{if(n.dryRun){c({command:`cf network-interconnects cnis create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/cnis`,pathParams:{},bodyKind:`json`,body:n.body===void 0?o({account:u(n.account,`account`,`text`),bgp:{customer_asn:n[`bgp-customer-asn`],extra_prefixes:n[`bgp-extra-prefixes`],md5_key:u(n[`bgp-md5-key`],`bgp-md5-key`,`text`)},interconnect:u(n.interconnect,`interconnect`,`text`),magic:{conduit_name:u(n[`magic-conduit-name`],`magic-conduit-name`,`text`),description:u(n[`magic-description`],`magic-description`,`text`),mtu:n[`magic-mtu`]}}):a(n.body)});return}let f=await i(n),p=n.local?d:await r(f);if(n.accountId=p,n.body){let e=a(n.body);s(await l(`Creating`,async()=>f.networkInterconnects.cnis.create({...e,account_id:p})),{successLabel:`Created`});return}if(n.account===void 0&&(n.account=await t(`account`,`Customer account tag`)),n.interconnect===void 0&&(n.interconnect=await t(`interconnect`,`The interconnect field`)),n[`magic-conduit-name`]===void 0&&(n[`magic-conduit-name`]=await t(`magic-conduit-name`,`The magic.conduit_name field`)),n[`magic-description`]===void 0&&(n[`magic-description`]=await t(`magic-description`,`The magic.description field`)),n[`magic-mtu`]===void 0)throw Error(`--magic-mtu is required (or pass --body with this field set).`);let m=o({account:u(n.account,`account`,`text`),bgp:{customer_asn:n[`bgp-customer-asn`],extra_prefixes:n[`bgp-extra-prefixes`],md5_key:u(n[`bgp-md5-key`],`bgp-md5-key`,`text`)},interconnect:u(n.interconnect,`interconnect`,`text`),magic:{conduit_name:u(n[`magic-conduit-name`],`magic-conduit-name`,`text`),description:u(n[`magic-description`],`magic-description`,`text`),mtu:n[`magic-mtu`]}});s(await l(`Creating`,async()=>f.networkInterconnects.cnis.create({...m,account_id:p})),{successLabel:`Created`})}};function m(e){return e.positional(`cni`,{type:`string`,description:`CNI ID to retrieve information about`,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 <cni>`,describe:`Delete a specified CNI object`,builder:m,handler:async t=>{if(t.dryRun){c({command:`cf network-interconnects cnis delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/cnis/${t.cni==null?`<cni>`:encodeURIComponent(String(t.cni))}`,pathParams:{cni:String(t.cni??``)},bodyKind:`none`});return}let a=await i(t),o=t.local?d:await r(a);if(t.accountId=o,!await n({force:!!t.force})){process.stderr.write(`Aborted.
18
- `);return}s(await l(`Deleting`,async()=>a.networkInterconnects.cnis.delete({account_id:o,cni:t.cni})),{successLabel:`Deleted`})}};function g(e){return e.positional(`cni`,{type:`string`,description:`CNI ID to retrieve information about`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get <cni>`,describe:`Get information about a CNI object`,builder:g,handler:async t=>{if(t.dryRun){c({command:`cf network-interconnects cnis get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/cnis/${t.cni==null?`<cni>`:encodeURIComponent(String(t.cni))}`,pathParams:{cni:String(t.cni??``)},bodyKind:`none`});return}let n=await i(t),a=t.local?d:await r(n);t.accountId=a,s(await l(`Loading`,async()=>n.networkInterconnects.cnis.get({account_id:a,cni:t.cni})),{successLabel:`Loaded`})}};function v(e){return e.option(`slot`,{type:`string`,description:`If specified, only show CNIs associated with the specified slot`}).option(`tunnel-id`,{type:`string`,description:`If specified, only show cnis associated with the specified tunnel id`}).option(`cursor`,{type:`number`,description:`Cursor`}).option(`limit`,{type:`number`,description:`Limit`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`list`,describe:`List existing CNI objects`,builder:v,handler:async t=>{let n={slot:t.slot,tunnel_id:t[`tunnel-id`],cursor:t.cursor,limit:t.limit};if(t.dryRun){c({command:`cf network-interconnects cnis list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/cnis`,pathParams:{},query:n,bodyKind:`none`});return}let a=await i(t),o=t.local?d:await r(a);t.accountId=o,s(await l(`Loading`,async()=>a.networkInterconnects.cnis.list({account_id:o,...n})),{successLabel:`Loaded`})}};function b(e){return e.positional(`cni`,{type:`string`,description:`CNI ID to retrieve information about`,demandOption:!0}).option(`account`,{type:`string`,description:`Customer account tag`}).option(`bgp-customer-asn`,{type:`number`,description:`ASN used on the customer end of the BGP session`}).option(`bgp-extra-prefixes`,{type:`string`,array:!0,description:`Extra set of static prefixes to advertise to the customer's end of the session`}).option(`bgp-md5-key`,{type:`string`,description:`MD5 key to use for session authentication.
17
+ these disallowed characters will be rejected.`}).option(`interconnect`,{type:`string`,description:`The interconnect field`}).option(`magic-conduit-name`,{type:`string`,description:`The magic.conduit_name field`}).option(`magic-description`,{type:`string`,description:`The magic.description field`}).option(`magic-mtu`,{type:`number`,description:`The magic.mtu field`}).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)`}).check(e=>{if([`bgp-customer-asn`,`bgp-extra-prefixes`,`bgp-md5-key`].some(t=>e[t]!==void 0)){let t=[`bgp-customer-asn`,`bgp-extra-prefixes`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --bgp-* flag is set`)}return!0})}const p={command:`create`,describe:`Create a new CNI object`,builder:f,handler:async r=>{if(r.dryRun){c({command:`cf network-interconnects cnis create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/cnis`,pathParams:{},bodyKind:`json`,body:r.body===void 0?o({account:u(r.account,`account`,`text`),bgp:{customer_asn:r[`bgp-customer-asn`],extra_prefixes:r[`bgp-extra-prefixes`],md5_key:u(r[`bgp-md5-key`],`bgp-md5-key`,`text`)},interconnect:u(r.interconnect,`interconnect`,`text`),magic:{conduit_name:u(r[`magic-conduit-name`],`magic-conduit-name`,`text`),description:u(r[`magic-description`],`magic-description`,`text`),mtu:r[`magic-mtu`]}}):a(r.body)});return}let f=await i(r),p=r.local?d:await n(f);if(r.accountId=p,r.body){let e=a(r.body);s(await l(`Creating`,async()=>f.networkInterconnects.cnis.create({...e,account_id:p})),{successLabel:`Created`});return}if(r.account===void 0&&(r.account=await e(`account`,`Customer account tag`)),r.interconnect===void 0&&(r.interconnect=await e(`interconnect`,`The interconnect field`)),r[`magic-conduit-name`]===void 0&&(r[`magic-conduit-name`]=await e(`magic-conduit-name`,`The magic.conduit_name field`)),r[`magic-description`]===void 0&&(r[`magic-description`]=await e(`magic-description`,`The magic.description field`)),r[`magic-mtu`]===void 0)throw Error(`--magic-mtu is required (or pass --body with this field set).`);let m=o({account:u(r.account,`account`,`text`),bgp:{customer_asn:r[`bgp-customer-asn`],extra_prefixes:r[`bgp-extra-prefixes`],md5_key:u(r[`bgp-md5-key`],`bgp-md5-key`,`text`)},interconnect:u(r.interconnect,`interconnect`,`text`),magic:{conduit_name:u(r[`magic-conduit-name`],`magic-conduit-name`,`text`),description:u(r[`magic-description`],`magic-description`,`text`),mtu:r[`magic-mtu`]}});s(await l(`Creating`,async()=>f.networkInterconnects.cnis.create({...m,account_id:p})),{successLabel:`Created`})}};function m(e){return e.positional(`cni`,{type:`string`,description:`CNI ID to retrieve information about`,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 <cni>`,describe:`Delete a specified CNI object`,builder:m,handler:async e=>{if(e.dryRun){c({command:`cf network-interconnects cnis delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/cnis/${e.cni==null?`<cni>`:encodeURIComponent(String(e.cni))}`,pathParams:{cni:String(e.cni??``)},bodyKind:`none`});return}let a=await i(e),o=e.local?d:await n(a);if(e.accountId=o,!await r({force:!!e.force})){process.stderr.write(`Aborted.
18
+ `);return}s(await l(`Deleting`,async()=>a.networkInterconnects.cnis.delete({account_id:o,cni:e.cni})),{successLabel:`Deleted`})}};function g(e){return e.positional(`cni`,{type:`string`,description:`CNI ID to retrieve information about`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get <cni>`,describe:`Get information about a CNI object`,builder:g,handler:async e=>{if(e.dryRun){c({command:`cf network-interconnects cnis get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/cnis/${e.cni==null?`<cni>`:encodeURIComponent(String(e.cni))}`,pathParams:{cni:String(e.cni??``)},bodyKind:`none`});return}let r=await i(e),a=e.local?d:await n(r);e.accountId=a,s(await l(`Loading`,async()=>r.networkInterconnects.cnis.get({account_id:a,cni:e.cni})),{successLabel:`Loaded`})}};function v(e){return e.option(`slot`,{type:`string`,description:`If specified, only show CNIs associated with the specified slot`}).option(`tunnel-id`,{type:`string`,description:`If specified, only show cnis associated with the specified tunnel id`}).option(`cursor`,{type:`number`,description:`Cursor`}).option(`limit`,{type:`number`,description:`Limit`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`list`,describe:`List existing CNI objects`,builder:v,handler:async e=>{let r={slot:e.slot,tunnel_id:e[`tunnel-id`],cursor:e.cursor,limit:e.limit};if(e.dryRun){c({command:`cf network-interconnects cnis list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/cnis`,pathParams:{},query:r,bodyKind:`none`});return}let a=await i(e),o=e.local?d:await n(a);e.accountId=o,s(await l(`Loading`,async()=>a.networkInterconnects.cnis.list({account_id:o,...r})),{successLabel:`Loaded`})}};function b(e){return e.positional(`cni`,{type:`string`,description:`CNI ID to retrieve information about`,demandOption:!0}).option(`account`,{type:`string`,description:`Customer account tag`}).option(`bgp-customer-asn`,{type:`number`,description:`ASN used on the customer end of the BGP session`}).option(`bgp-extra-prefixes`,{type:`string`,array:!0,description:`Extra set of static prefixes to advertise to the customer's end of the session`}).option(`bgp-md5-key`,{type:`string`,description:`MD5 key to use for session authentication.
19
19
 
20
20
  Note that *this is not a security measure*. MD5 is not a valid security mechanism, and the
21
21
  key is not treated as a secret value. This is *only* supported for preventing
@@ -32,5 +32,5 @@ quotation mark (\`"\`), vertical tab (0x0B), carriage return (0x0D), tab (0x09),
32
32
  (0x0C), and the question mark (\`?\`). Requests specifying an MD5 key with one or more of
33
33
  these disallowed characters will be rejected.`}).option(`cust-ip`,{type:`string`,description:`Customer end of the point-to-point link
34
34
 
35
- This should always be inside the same prefix as \`p2p_ip\`.`}).option(`id`,{type:`string`,description:`The id field`}).option(`interconnect`,{type:`string`,description:`Interconnect identifier hosting this CNI`}).option(`magic-conduit-name`,{type:`string`,description:`The magic.conduit_name field`}).option(`magic-description`,{type:`string`,description:`The magic.description field`}).option(`magic-mtu`,{type:`number`,description:`The magic.mtu field`}).option(`p2p-ip`,{type:`string`,description:`Cloudflare end of the point-to-point link`}).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)`}).check(e=>{if([`bgp-customer-asn`,`bgp-extra-prefixes`,`bgp-md5-key`].some(t=>e[t]!==void 0)){let t=[`bgp-customer-asn`,`bgp-extra-prefixes`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --bgp-* flag is set`)}return!0})}const x={command:`update <cni>`,describe:`Modify stored information about a CNI object`,builder:b,handler:async n=>{if(n.dryRun){c({command:`cf network-interconnects cnis update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/cnis/${n.cni==null?`<cni>`:encodeURIComponent(String(n.cni))}`,pathParams:{cni:String(n.cni??``)},bodyKind:`json`,body:n.body===void 0?o({account:u(n.account,`account`,`text`),bgp:{customer_asn:n[`bgp-customer-asn`],extra_prefixes:n[`bgp-extra-prefixes`],md5_key:u(n[`bgp-md5-key`],`bgp-md5-key`,`text`)},cust_ip:u(n[`cust-ip`],`cust-ip`,`text`),id:u(n.id,`id`,`text`),interconnect:u(n.interconnect,`interconnect`,`text`),magic:{conduit_name:u(n[`magic-conduit-name`],`magic-conduit-name`,`text`),description:u(n[`magic-description`],`magic-description`,`text`),mtu:n[`magic-mtu`]},p2p_ip:u(n[`p2p-ip`],`p2p-ip`,`text`)}):a(n.body)});return}let f=await i(n),p=n.local?d:await r(f);if(n.accountId=p,n.body){let e=a(n.body);s(await l(`Updating`,async()=>f.networkInterconnects.cnis.update({body:e,account_id:p,cni:n.cni})),{successLabel:`Updated`});return}if(n.account===void 0&&(n.account=await t(`account`,`Customer account tag`)),n[`cust-ip`]===void 0&&(n[`cust-ip`]=await t(`cust-ip`,"Customer end of the point-to-point link This should always be inside the same prefix as `p2p_ip`.")),n.id===void 0&&(n.id=await t(`id`,`The id field`)),n.interconnect===void 0&&(n.interconnect=await t(`interconnect`,`Interconnect identifier hosting this CNI`)),n[`magic-conduit-name`]===void 0&&(n[`magic-conduit-name`]=await t(`magic-conduit-name`,`The magic.conduit_name field`)),n[`magic-description`]===void 0&&(n[`magic-description`]=await t(`magic-description`,`The magic.description field`)),n[`magic-mtu`]===void 0)throw Error(`--magic-mtu is required (or pass --body with this field set).`);n[`p2p-ip`]===void 0&&(n[`p2p-ip`]=await t(`p2p-ip`,`Cloudflare end of the point-to-point link`));let m=o({account:u(n.account,`account`,`text`),bgp:{customer_asn:n[`bgp-customer-asn`],extra_prefixes:n[`bgp-extra-prefixes`],md5_key:u(n[`bgp-md5-key`],`bgp-md5-key`,`text`)},cust_ip:u(n[`cust-ip`],`cust-ip`,`text`),id:u(n.id,`id`,`text`),interconnect:u(n.interconnect,`interconnect`,`text`),magic:{conduit_name:u(n[`magic-conduit-name`],`magic-conduit-name`,`text`),description:u(n[`magic-description`],`magic-description`,`text`),mtu:n[`magic-mtu`]},p2p_ip:u(n[`p2p-ip`],`p2p-ip`,`text`)});s(await l(`Updating`,async()=>f.networkInterconnects.cnis.update({body:m,account_id:p,cni:n.cni})),{successLabel:`Updated`})}},S={command:`cnis`,describe:`Cloud Network Interconnect (CNI) connections — private links from cloud providers to Cloudflare`,builder:e=>e.command(p).command(h).command(_).command(y).command(x).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function C(e){return e.option(`account`,{type:`string`,description:`The account field`}).option(`type`,{type:`string`,description:`The type field`}).option(`slot-id`,{type:`string`,description:`The slot_id field`}).option(`speed`,{type:`string`,description:`The speed field`}).option(`bandwidth`,{type:`string`,description:`Bandwidth structure as visible through the customer-facing API.`,choices:[`50M`,`100M`,`200M`,`300M`,`400M`,`500M`,`1G`,`2G`,`5G`,`10G`,`20G`,`50G`]}).option(`pairing-key`,{type:`string`,description:`Pairing key provided by GCP`}).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)`}).conflicts(`slot-id`,[`bandwidth`,`pairing-key`]).conflicts(`speed`,[`bandwidth`,`pairing-key`]).conflicts(`bandwidth`,[`slot-id`,`speed`]).implies(`bandwidth`,[`pairing-key`]).conflicts(`pairing-key`,[`slot-id`,`speed`]).implies(`pairing-key`,[`bandwidth`])}const w={command:`create`,describe:`Create a new interconnect`,builder:C,handler:async n=>{if(n.dryRun){c({command:`cf network-interconnects interconnects create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/interconnects`,pathParams:{},bodyKind:`json`,body:n.body===void 0?o({account:u(n.account,`account`,`text`),type:u(n.type,`type`,`text`),slot_id:u(n[`slot-id`],`slot-id`,`text`),speed:u(n.speed,`speed`,`text`),bandwidth:u(n.bandwidth,`bandwidth`,`text`),pairing_key:u(n[`pairing-key`],`pairing-key`,`text`)}):a(n.body)});return}let f=await i(n),p=n.local?d:await r(f);if(n.accountId=p,n.body){let e=a(n.body);s(await l(`Creating`,async()=>f.networkInterconnects.interconnects.create({body:e,account_id:p})),{successLabel:`Created`});return}n.account===void 0&&(n.account=await t(`account`,`The account field`)),n.type===void 0&&(n.type=await t(`type`,`The type field`));let m=o({account:u(n.account,`account`,`text`),type:u(n.type,`type`,`text`),slot_id:u(n[`slot-id`],`slot-id`,`text`),speed:u(n.speed,`speed`,`text`),bandwidth:u(n.bandwidth,`bandwidth`,`text`),pairing_key:u(n[`pairing-key`],`pairing-key`,`text`)});s(await l(`Creating`,async()=>f.networkInterconnects.interconnects.create({body:m,account_id:p})),{successLabel:`Created`})}};function T(e){return e.positional(`icon`,{type:`string`,description:`Interconnect name to retrieve information about`,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 E={command:`delete <icon>`,describe:`Delete an interconnect object`,builder:T,handler:async t=>{if(t.dryRun){c({command:`cf network-interconnects interconnects delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/interconnects/${t.icon==null?`<icon>`:encodeURIComponent(String(t.icon))}`,pathParams:{icon:String(t.icon??``)},bodyKind:`none`});return}let a=await i(t),o=t.local?d:await r(a);if(t.accountId=o,!await n({force:!!t.force})){process.stderr.write(`Aborted.
36
- `);return}s(await l(`Deleting`,async()=>a.networkInterconnects.interconnects.delete({account_id:o,icon:t.icon})),{successLabel:`Deleted`})}};function D(e){return e.positional(`icon`,{type:`string`,description:`Interconnect name to retrieve information about`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`get <icon>`,describe:`Get information about an interconnect object`,builder:D,handler:async t=>{if(t.dryRun){c({command:`cf network-interconnects interconnects get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/interconnects/${t.icon==null?`<icon>`:encodeURIComponent(String(t.icon))}`,pathParams:{icon:String(t.icon??``)},bodyKind:`none`});return}let n=await i(t),a=t.local?d:await r(n);t.accountId=a,s(await l(`Loading`,async()=>n.networkInterconnects.interconnects.get({account_id:a,icon:t.icon})),{successLabel:`Loaded`})}};function k(e){return e.option(`site`,{type:`string`,description:`If specified, only show interconnects located at the given site`}).option(`type`,{type:`string`,description:`If specified, only show interconnects of the given type`}).option(`cursor`,{type:`number`,description:`Cursor`}).option(`limit`,{type:`number`,description:`Limit`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`list`,describe:`List existing interconnects`,builder:k,handler:async t=>{let n={site:t.site,type:t.type,cursor:t.cursor,limit:t.limit};if(t.dryRun){c({command:`cf network-interconnects interconnects list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/interconnects`,pathParams:{},query:n,bodyKind:`none`});return}let a=await i(t),o=t.local?d:await r(a);t.accountId=o,s(await l(`Loading`,async()=>a.networkInterconnects.interconnects.list({account_id:o,...n})),{successLabel:`Loaded`})}};function j(e){return e.positional(`icon`,{type:`string`,description:`Interconnect name to retrieve information about`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`loa <icon>`,describe:`Generate the Letter of Authorization (LOA) for a given interconnect`,builder:j,handler:async t=>{if(t.dryRun){c({command:`cf network-interconnects interconnects loa`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/interconnects/${t.icon==null?`<icon>`:encodeURIComponent(String(t.icon))}/loa`,pathParams:{icon:String(t.icon??``)},bodyKind:`none`});return}let n=await i(t),a=t.local?d:await r(n);t.accountId=a,s(await l(`Loading`,async()=>n.networkInterconnects.interconnects.loa({account_id:a,icon:t.icon})),{successLabel:`Loaded`})}};function N(e){return e.positional(`icon`,{type:`string`,description:`Interconnect name to retrieve information about`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`status <icon>`,describe:`Get the current status of an interconnect object`,builder:N,handler:async t=>{if(t.dryRun){c({command:`cf network-interconnects interconnects status`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/interconnects/${t.icon==null?`<icon>`:encodeURIComponent(String(t.icon))}/status`,pathParams:{icon:String(t.icon??``)},bodyKind:`none`});return}let n=await i(t),a=t.local?d:await r(n);t.accountId=a,s(await l(`Loading`,async()=>n.networkInterconnects.interconnects.status({account_id:a,icon:t.icon})),{successLabel:`Loaded`})}},F={command:`interconnects`,describe:`Physical cross-connect and partner interconnect sessions with LOA and status tracking`,builder:e=>e.command(w).command(E).command(O).command(A).command(M).command(P).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function I(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const L={command:`get`,describe:`Get the current settings for the active account`,builder:I,handler:async t=>{if(t.dryRun){c({command:`cf network-interconnects settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/settings`,pathParams:{},bodyKind:`none`});return}let n=await i(t),a=t.local?d:await r(n);t.accountId=a,s(await l(`Loading`,async()=>n.networkInterconnects.settings.get({account_id:a})),{successLabel:`Loaded`})}};function R(e){return e.option(`default-asn`,{type:`number`,description:`The default_asn field`}).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`,describe:`Update the current settings for the active account`,builder:R,handler:async t=>{if(t.dryRun){c({command:`cf network-interconnects settings update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/settings`,pathParams:{},bodyKind:`json`,body:t.body===void 0?o({default_asn:t[`default-asn`]}):a(t.body)});return}let n=await i(t),u=t.local?d:await r(n);if(t.accountId=u,t.body){let e=a(t.body);s(await l(`Updating`,async()=>n.networkInterconnects.settings.update({...e,account_id:u})),{successLabel:`Updated`});return}let f=o({default_asn:t[`default-asn`]});s(await l(`Updating`,async()=>n.networkInterconnects.settings.update({...f,account_id:u})),{successLabel:`Updated`})}},B={command:`settings`,describe:`Account-level interconnect settings and default configurations`,builder:e=>e.command(L).command(z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function V(e){return e.positional(`slot`,{type:`string`,description:`Slot`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const H={command:`get <slot>`,describe:`Get information about the specified slot`,builder:V,handler:async t=>{if(t.dryRun){c({command:`cf network-interconnects slots get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/slots/${t.slot==null?`<slot>`:encodeURIComponent(String(t.slot))}`,pathParams:{slot:String(t.slot??``)},bodyKind:`none`});return}let n=await i(t),a=t.local?d:await r(n);t.accountId=a,s(await l(`Loading`,async()=>n.networkInterconnects.slots.get({account_id:a,slot:t.slot})),{successLabel:`Loaded`})}};function U(e){return e.option(`address-contains`,{type:`string`,description:`If specified, only show slots with the given text in their address field`}).option(`site`,{type:`string`,description:`If specified, only show slots located at the given site`}).option(`speed`,{type:`string`,description:`If specified, only show slots that support the given speed`}).option(`occupied`,{type:`boolean`,description:`If specified, only show slots with a specific occupied/unoccupied state`}).option(`cursor`,{type:`number`,description:`Cursor`}).option(`limit`,{type:`number`,description:`Limit`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const W={command:`list`,describe:`Retrieve a list of all slots matching the specified parameters`,builder:U,handler:async t=>{let n={address_contains:t[`address-contains`],site:t.site,speed:t.speed,occupied:t.occupied,cursor:t.cursor,limit:t.limit};if(t.dryRun){c({command:`cf network-interconnects slots list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/cni/slots`,pathParams:{},query:n,bodyKind:`none`});return}let a=await i(t),o=t.local?d:await r(a);t.accountId=o,s(await l(`Loading`,async()=>a.networkInterconnects.slots.list({account_id:o,...n})),{successLabel:`Loaded`})}},G={command:`slots`,describe:`Available interconnect facility slots showing port capacity at Cloudflare data centers`,builder:e=>e.command(H).command(W).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},K={command:`network-interconnects`,describe:`Physical and virtual private interconnects between your infrastructure and Cloudflare's network`,builder:e=>e.command(S).command(F).command(B).command(G).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{K as default};
35
+ This should always be inside the same prefix as \`p2p_ip\`.`}).option(`id`,{type:`string`,description:`The id field`}).option(`interconnect`,{type:`string`,description:`Interconnect identifier hosting this CNI`}).option(`magic-conduit-name`,{type:`string`,description:`The magic.conduit_name field`}).option(`magic-description`,{type:`string`,description:`The magic.description field`}).option(`magic-mtu`,{type:`number`,description:`The magic.mtu field`}).option(`p2p-ip`,{type:`string`,description:`Cloudflare end of the point-to-point link`}).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)`}).check(e=>{if([`bgp-customer-asn`,`bgp-extra-prefixes`,`bgp-md5-key`].some(t=>e[t]!==void 0)){let t=[`bgp-customer-asn`,`bgp-extra-prefixes`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --bgp-* flag is set`)}return!0})}const x={command:`update <cni>`,describe:`Modify stored information about a CNI object`,builder:b,handler:async r=>{if(r.dryRun){c({command:`cf network-interconnects cnis update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/cnis/${r.cni==null?`<cni>`:encodeURIComponent(String(r.cni))}`,pathParams:{cni:String(r.cni??``)},bodyKind:`json`,body:r.body===void 0?o({account:u(r.account,`account`,`text`),bgp:{customer_asn:r[`bgp-customer-asn`],extra_prefixes:r[`bgp-extra-prefixes`],md5_key:u(r[`bgp-md5-key`],`bgp-md5-key`,`text`)},cust_ip:u(r[`cust-ip`],`cust-ip`,`text`),id:u(r.id,`id`,`text`),interconnect:u(r.interconnect,`interconnect`,`text`),magic:{conduit_name:u(r[`magic-conduit-name`],`magic-conduit-name`,`text`),description:u(r[`magic-description`],`magic-description`,`text`),mtu:r[`magic-mtu`]},p2p_ip:u(r[`p2p-ip`],`p2p-ip`,`text`)}):a(r.body)});return}let f=await i(r),p=r.local?d:await n(f);if(r.accountId=p,r.body){let e=a(r.body);s(await l(`Updating`,async()=>f.networkInterconnects.cnis.update({body:e,account_id:p,cni:r.cni})),{successLabel:`Updated`});return}if(r.account===void 0&&(r.account=await e(`account`,`Customer account tag`)),r[`cust-ip`]===void 0&&(r[`cust-ip`]=await e(`cust-ip`,"Customer end of the point-to-point link This should always be inside the same prefix as `p2p_ip`.")),r.id===void 0&&(r.id=await e(`id`,`The id field`)),r.interconnect===void 0&&(r.interconnect=await e(`interconnect`,`Interconnect identifier hosting this CNI`)),r[`magic-conduit-name`]===void 0&&(r[`magic-conduit-name`]=await e(`magic-conduit-name`,`The magic.conduit_name field`)),r[`magic-description`]===void 0&&(r[`magic-description`]=await e(`magic-description`,`The magic.description field`)),r[`magic-mtu`]===void 0)throw Error(`--magic-mtu is required (or pass --body with this field set).`);r[`p2p-ip`]===void 0&&(r[`p2p-ip`]=await e(`p2p-ip`,`Cloudflare end of the point-to-point link`));let m=o({account:u(r.account,`account`,`text`),bgp:{customer_asn:r[`bgp-customer-asn`],extra_prefixes:r[`bgp-extra-prefixes`],md5_key:u(r[`bgp-md5-key`],`bgp-md5-key`,`text`)},cust_ip:u(r[`cust-ip`],`cust-ip`,`text`),id:u(r.id,`id`,`text`),interconnect:u(r.interconnect,`interconnect`,`text`),magic:{conduit_name:u(r[`magic-conduit-name`],`magic-conduit-name`,`text`),description:u(r[`magic-description`],`magic-description`,`text`),mtu:r[`magic-mtu`]},p2p_ip:u(r[`p2p-ip`],`p2p-ip`,`text`)});s(await l(`Updating`,async()=>f.networkInterconnects.cnis.update({body:m,account_id:p,cni:r.cni})),{successLabel:`Updated`})}},S={command:`cnis`,describe:`Cloud Network Interconnect (CNI) connections — private links from cloud providers to Cloudflare`,builder:e=>e.command(p).command(h).command(_).command(y).command(x).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function C(e){return e.option(`account`,{type:`string`,description:`The account field`}).option(`type`,{type:`string`,description:`The type field`}).option(`slot-id`,{type:`string`,description:`The slot_id field`}).option(`speed`,{type:`string`,description:`The speed field`}).option(`bandwidth`,{type:`string`,description:`Bandwidth structure as visible through the customer-facing API.`,choices:[`50M`,`100M`,`200M`,`300M`,`400M`,`500M`,`1G`,`2G`,`5G`,`10G`,`20G`,`50G`]}).option(`pairing-key`,{type:`string`,description:`Pairing key provided by GCP`}).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)`}).conflicts(`slot-id`,[`bandwidth`,`pairing-key`]).conflicts(`speed`,[`bandwidth`,`pairing-key`]).conflicts(`bandwidth`,[`slot-id`,`speed`]).implies(`bandwidth`,[`pairing-key`]).conflicts(`pairing-key`,[`slot-id`,`speed`]).implies(`pairing-key`,[`bandwidth`])}const w={command:`create`,describe:`Create a new interconnect`,builder:C,handler:async r=>{if(r.dryRun){c({command:`cf network-interconnects interconnects create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/interconnects`,pathParams:{},bodyKind:`json`,body:r.body===void 0?o({account:u(r.account,`account`,`text`),type:u(r.type,`type`,`text`),slot_id:u(r[`slot-id`],`slot-id`,`text`),speed:u(r.speed,`speed`,`text`),bandwidth:u(r.bandwidth,`bandwidth`,`text`),pairing_key:u(r[`pairing-key`],`pairing-key`,`text`)}):a(r.body)});return}let f=await i(r),p=r.local?d:await n(f);if(r.accountId=p,r.body){let e=a(r.body);s(await l(`Creating`,async()=>f.networkInterconnects.interconnects.create({body:e,account_id:p})),{successLabel:`Created`});return}r.account===void 0&&(r.account=await e(`account`,`The account field`)),r.type===void 0&&(r.type=await e(`type`,`The type field`));let m=o({account:u(r.account,`account`,`text`),type:u(r.type,`type`,`text`),slot_id:u(r[`slot-id`],`slot-id`,`text`),speed:u(r.speed,`speed`,`text`),bandwidth:u(r.bandwidth,`bandwidth`,`text`),pairing_key:u(r[`pairing-key`],`pairing-key`,`text`)});s(await l(`Creating`,async()=>f.networkInterconnects.interconnects.create({body:m,account_id:p})),{successLabel:`Created`})}};function T(e){return e.positional(`icon`,{type:`string`,description:`Interconnect name to retrieve information about`,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 E={command:`delete <icon>`,describe:`Delete an interconnect object`,builder:T,handler:async e=>{if(e.dryRun){c({command:`cf network-interconnects interconnects delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/interconnects/${e.icon==null?`<icon>`:encodeURIComponent(String(e.icon))}`,pathParams:{icon:String(e.icon??``)},bodyKind:`none`});return}let a=await i(e),o=e.local?d:await n(a);if(e.accountId=o,!await r({force:!!e.force})){process.stderr.write(`Aborted.
36
+ `);return}s(await l(`Deleting`,async()=>a.networkInterconnects.interconnects.delete({account_id:o,icon:e.icon})),{successLabel:`Deleted`})}};function D(e){return e.positional(`icon`,{type:`string`,description:`Interconnect name to retrieve information about`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`get <icon>`,describe:`Get information about an interconnect object`,builder:D,handler:async e=>{if(e.dryRun){c({command:`cf network-interconnects interconnects get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/interconnects/${e.icon==null?`<icon>`:encodeURIComponent(String(e.icon))}`,pathParams:{icon:String(e.icon??``)},bodyKind:`none`});return}let r=await i(e),a=e.local?d:await n(r);e.accountId=a,s(await l(`Loading`,async()=>r.networkInterconnects.interconnects.get({account_id:a,icon:e.icon})),{successLabel:`Loaded`})}};function k(e){return e.option(`site`,{type:`string`,description:`If specified, only show interconnects located at the given site`}).option(`type`,{type:`string`,description:`If specified, only show interconnects of the given type`}).option(`cursor`,{type:`number`,description:`Cursor`}).option(`limit`,{type:`number`,description:`Limit`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`list`,describe:`List existing interconnects`,builder:k,handler:async e=>{let r={site:e.site,type:e.type,cursor:e.cursor,limit:e.limit};if(e.dryRun){c({command:`cf network-interconnects interconnects list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/interconnects`,pathParams:{},query:r,bodyKind:`none`});return}let a=await i(e),o=e.local?d:await n(a);e.accountId=o,s(await l(`Loading`,async()=>a.networkInterconnects.interconnects.list({account_id:o,...r})),{successLabel:`Loaded`})}};function j(e){return e.positional(`icon`,{type:`string`,description:`Interconnect name to retrieve information about`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`loa <icon>`,describe:`Generate the Letter of Authorization (LOA) for a given interconnect`,builder:j,handler:async e=>{if(e.dryRun){c({command:`cf network-interconnects interconnects loa`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/interconnects/${e.icon==null?`<icon>`:encodeURIComponent(String(e.icon))}/loa`,pathParams:{icon:String(e.icon??``)},bodyKind:`none`});return}let r=await i(e),a=e.local?d:await n(r);e.accountId=a,s(await l(`Loading`,async()=>r.networkInterconnects.interconnects.loa({account_id:a,icon:e.icon})),{successLabel:`Loaded`})}};function N(e){return e.positional(`icon`,{type:`string`,description:`Interconnect name to retrieve information about`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`status <icon>`,describe:`Get the current status of an interconnect object`,builder:N,handler:async e=>{if(e.dryRun){c({command:`cf network-interconnects interconnects status`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/interconnects/${e.icon==null?`<icon>`:encodeURIComponent(String(e.icon))}/status`,pathParams:{icon:String(e.icon??``)},bodyKind:`none`});return}let r=await i(e),a=e.local?d:await n(r);e.accountId=a,s(await l(`Loading`,async()=>r.networkInterconnects.interconnects.status({account_id:a,icon:e.icon})),{successLabel:`Loaded`})}},F={command:`interconnects`,describe:`Physical cross-connect and partner interconnect sessions with LOA and status tracking`,builder:e=>e.command(w).command(E).command(O).command(A).command(M).command(P).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function I(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const L={command:`get`,describe:`Get the current settings for the active account`,builder:I,handler:async e=>{if(e.dryRun){c({command:`cf network-interconnects settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/settings`,pathParams:{},bodyKind:`none`});return}let r=await i(e),a=e.local?d:await n(r);e.accountId=a,s(await l(`Loading`,async()=>r.networkInterconnects.settings.get({account_id:a})),{successLabel:`Loaded`})}};function R(e){return e.option(`default-asn`,{type:`number`,description:`The default_asn field`}).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`,describe:`Update the current settings for the active account`,builder:R,handler:async e=>{if(e.dryRun){c({command:`cf network-interconnects settings update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/settings`,pathParams:{},bodyKind:`json`,body:e.body===void 0?o({default_asn:e[`default-asn`]}):a(e.body)});return}let r=await i(e),u=e.local?d:await n(r);if(e.accountId=u,e.body){let t=a(e.body);s(await l(`Updating`,async()=>r.networkInterconnects.settings.update({...t,account_id:u})),{successLabel:`Updated`});return}let f=o({default_asn:e[`default-asn`]});s(await l(`Updating`,async()=>r.networkInterconnects.settings.update({...f,account_id:u})),{successLabel:`Updated`})}},B={command:`settings`,describe:`Account-level interconnect settings and default configurations`,builder:e=>e.command(L).command(z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function V(e){return e.positional(`slot`,{type:`string`,description:`Slot`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const H={command:`get <slot>`,describe:`Get information about the specified slot`,builder:V,handler:async e=>{if(e.dryRun){c({command:`cf network-interconnects slots get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/slots/${e.slot==null?`<slot>`:encodeURIComponent(String(e.slot))}`,pathParams:{slot:String(e.slot??``)},bodyKind:`none`});return}let r=await i(e),a=e.local?d:await n(r);e.accountId=a,s(await l(`Loading`,async()=>r.networkInterconnects.slots.get({account_id:a,slot:e.slot})),{successLabel:`Loaded`})}};function U(e){return e.option(`address-contains`,{type:`string`,description:`If specified, only show slots with the given text in their address field`}).option(`site`,{type:`string`,description:`If specified, only show slots located at the given site`}).option(`speed`,{type:`string`,description:`If specified, only show slots that support the given speed`}).option(`occupied`,{type:`boolean`,description:`If specified, only show slots with a specific occupied/unoccupied state`}).option(`cursor`,{type:`number`,description:`Cursor`}).option(`limit`,{type:`number`,description:`Limit`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const W={command:`list`,describe:`Retrieve a list of all slots matching the specified parameters`,builder:U,handler:async e=>{let r={address_contains:e[`address-contains`],site:e.site,speed:e.speed,occupied:e.occupied,cursor:e.cursor,limit:e.limit};if(e.dryRun){c({command:`cf network-interconnects slots list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/cni/slots`,pathParams:{},query:r,bodyKind:`none`});return}let a=await i(e),o=e.local?d:await n(a);e.accountId=o,s(await l(`Loading`,async()=>a.networkInterconnects.slots.list({account_id:o,...r})),{successLabel:`Loaded`})}},G={command:`slots`,describe:`Available interconnect facility slots showing port capacity at Cloudflare data centers`,builder:e=>e.command(H).command(W).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},K={command:`network-interconnects`,describe:`Physical and virtual private interconnects between your infrastructure and Cloudflare's network`,builder:e=>e.command(S).command(F).command(B).command(G).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{K as default};
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ import{o as e,r as t}from"./chunk-DH-VkVmc.mjs";import{_ as n,a as r,c as i,d as a,f as o,g as s,h as c,i as l,l as u,m as d,o as f,p,s as m,t as h,u as ee,v as g,y as _}from"./session-DHYCE-PM.mjs";import{$ as te,A as ne,I as re,M as ie,P as ae,S as v,W as y,_ as b,a as oe,et as x,j as se,s as ce,v as le}from"./dist-C6zxsVdY.mjs";import{n as S,t as C}from"./theme-DbNbIY4d.mjs";import{i as w,n as ue,r as T}from"./config-B5k-XbwS.mjs";import{c as E,f as de,h as D,i as O,m as k,o as A,r as j,s as M,t as N}from"./dist-t_YrL25p.mjs";import{n as fe,t as pe}from"./resolve-C3h-mwp7.mjs";import{chmodSync as me,existsSync as P,mkdirSync as he,readFileSync as F,readdirSync as ge,rmSync as _e,unlinkSync as ve,writeFileSync as I}from"node:fs";import"node:os";import L,{dirname as R,join as z}from"node:path";import{URLSearchParams as ye}from"node:url";import"node:process";const{white:be,gray:xe,dim:Se,hidden:Ce,bold:we,cyanBright:Te,bgCyan:Ee}=D;D.hex(`#BD5B08`);const B=D.hex(`#111`);D.hex(`#0E838F`);const De=B.bgHex(`#0E838F`);D.hex(`#AB2526`);const Oe=B.bgHex(`#AB2526`);D.hex(`#218529`);const ke=B.bgHex(`#218529`);D.hex(`#7F7322`);const Ae=B.bgHex(`#7F7322`),je=process.stdout;process.stderr;var Me=e(E(),1);const Ne={diamond:`◇`,dash:`─`,radioInactive:`○`,radioActive:`●`,backActive:`◀`,backInactive:`◁`,bar:`│`,leftT:`├`,rigthT:`┤`,arrows:{left:`‹`,right:`›`},corners:{tl:`╭`,bl:`╰`,tr:`╮`,br:`╯`}};Oe(` ERROR `),Ae(` WARNING `),De(` INFO `),ke(` SUCCESS `),be.bgRed(` X `),M(je),xe(Ne.bar),xe(Ne.corners.bl),xe(Ne.leftT);function Pe(){try{return!!(process.stdin.isTTY&&process.stdout.isTTY)}catch{return!1}}function V(){return!Pe()||Me.isCI}const Fe=Me.isCI;function Ie(){h(_)}async function Le(e){let t=S(),n=e.map(e=>({value:e,label:e.name})),r=await new de({options:n,initialValue:n[0]?.value,render(){let e=t.bold(`Select an account`),n=this.options.map((e,n)=>{let r=n===this.cursor,i=e.value,a=t.hex(C.muted)(`${i.id.slice(0,12)}...`);return r?` ${t.hex(C.orange)(`>`)} ${t.bold(i.name)} ${a}`:` ${t.dim(i.name)} ${a}`});return`${e} ${t.dim(`(use arrow keys, enter to confirm)`)}\n${n.join(`
3
+ `)}`}}).prompt();return k(r)||!r?null:r}async function Re(){let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));let t=Buffer.concat(e).toString(`utf-8`);return t.endsWith(`
4
+ `)?t.slice(0,-1):t}async function ze(e,t,n){let r=n?.kind??`text`;if(V()){if(r===`secret`){let t=await Re();if(t.length>0)return t;throw Error(`--${e} is required. Pipe the value via stdin, pass --${e} <value>, or run interactively.`)}throw Error(`--${e} is required. Pass --${e} <value> or run interactively.`)}let i=`Enter value for --${e}`,a=t||n?.question||i;Ie();let o=r===`secret`?await j({message:a,mask:`•`,validate:e=>e&&e.length>0?void 0:`Value cannot be empty`}):await A({message:a,validate:e=>e&&e.length>0?void 0:`Value cannot be empty`});return(k(o)||typeof o!=`string`)&&process.exit(130),o}async function Be(e,t,n){if(V())throw Error(`--${e} is required (one of: ${n.join(`, `)}). Pass --${e} <value> or run interactively.`);let r=`Select value for --${e}`,i=t||r;Ie();let a=await O({message:i,options:n.map(e=>({value:e,label:e}))});return(k(a)||typeof a!=`string`)&&process.exit(130),a}async function Ve(e={}){if(e.force===!0)return!0;let t=e.message?`${e.message} Continue?`:`This permanently deletes the resource. Continue?`;if(V()){let e=S();return process.stderr.write(`${e.hex(C.warning)(`?`)} ${t}\n ${e.dim(`(non-interactive; pass --force to confirm)`)}\n`),!1}Ie();let n=await N({message:t,initialValue:!1});return k(n)&&process.exit(130),n===!0}const H=`.cfrc`;function U(e){let t=e||process.cwd(),n=R(t);for(;t!==n;){let e=z(t,H);if(P(e))try{let t=F(e,`utf-8`).replace(/^\s*\/\/.*$/gm,``);return{config:JSON.parse(t),path:e}}catch{}t=R(t)}let r=z(t,H);if(P(r))try{let e=F(r,`utf-8`).replace(/^\s*\/\/.*$/gm,``);return{config:JSON.parse(e),path:r}}catch{}return null}function He(e,t){I(z(t||process.cwd(),H),JSON.stringify(e,null,2)+`
5
+ `,{mode:384})}function Ue(e){let t=z(e||process.cwd(),H);return P(t)?(ve(t),!0):!1}async function We(e){let t={},n=W(`accountId`,`CLOUDFLARE_ACCOUNT_ID`);n&&(t.accountId=n);let r=W(`zone`,`CLOUDFLARE_ZONE_ID`,e?.zone);r&&(t.zone=r);let i=W(`complianceRegion`,`CLOUDFLARE_COMPLIANCE_REGION`);return i&&(t.complianceRegion=i),t}function W(e,t,n){if(n)return{value:n,source:`flag`};let r=process.env[t];if(r)return{value:r,source:`env`};let i=U(),a=i?.config[e];if(a)return{value:a,source:`project`,path:i.path};let o=T().defaults?.[e];if(o)return{value:o,source:`config`,path:ue()}}function Ge(){return W(`accountId`,`CLOUDFLARE_ACCOUNT_ID`)?.value}async function Ke(e){let t=W(`accountId`,`CLOUDFLARE_ACCOUNT_ID`);if(t)return qe(t.value,rt(t,`accountId`)),t.value;if(e){let t=await Je(e);if(t)return t}throw Error(`No account ID found.
6
+
7
+ Please provide one of the following:
8
+ 1. CLOUDFLARE_ACCOUNT_ID environment variable
9
+ 2. Run 'cf context set account-id <id>' to set a default
10
+ 3. Create a .cfrc file in your project
11
+
12
+ You can find your account ID in the Cloudflare dashboard URL:
13
+ https://dash.cloudflare.com/<account-id>/...`)}function qe(e,t){if(!process.env.DEBUG)return;let n=e.length>12?e.slice(0,12)+`…`:e;process.stderr.write(`Using account: ${n} (${t})\n`)}async function Je(e){let t;try{t=await ot(e)}catch{return}if(t.length===0)return;if(t.length===1&&t[0]){let n=t[0],{displayName:r}=await it(`accountId`,n.id,`user`,e);return qe(n.id,`auto-selected from token — ${r}`),n.id}if(V()){let e=t.map(e=>` ${e.id} ${e.name}`).join(`
14
+ `);throw Error(`Multiple accounts available but running non-interactively.
15
+
16
+ Available accounts:
17
+ ${e}
18
+
19
+ Set one with CLOUDFLARE_ACCOUNT_ID or 'cf context set account-id'.`)}let n=await Le(t);n||process.exit(130);let{displayName:r}=await it(`accountId`,n.id,`user`,e);return qe(n.id,`selected interactively — ${r}`),n.id}async function Ye(e,t,n){if(e?.zoneId)return Xe(e.zoneId,t);let r=W(`zone`,`CLOUDFLARE_ZONE_ID`,e?.zone);if(r){if(!n?.quiet&&r.source!==`flag`){let e=rt(r);console.error(`Using zone: ${r.value} (from ${e})`)}return Xe(r.value,t)}throw Error(`No zone specified.
20
+
21
+ Please provide one of the following:
22
+ 1. Zone as a positional argument: cf dns records list <zone>
23
+ 2. --zone flag (or -z): cf dns records list --zone example.com
24
+ 3. CLOUDFLARE_ZONE_ID environment variable
25
+ 4. Run 'cf context set zone <zone>' to set a default
26
+ 5. Create a .cfrc file in your project with {"zone": "example.com"}`)}async function Xe(e,t){if(pe(e)||!t)return e;let{resolveZoneId:n}=await import(`./resolve-C3h-mwp7.mjs`).then(e=>e.r);return n(t,await Ke(),e)}function Ze(e){if(e?.scriptName)return e.scriptName;throw Error("Required Worker name missing. Please specify the Worker name with `--worker <name>`.")}const Qe=[`public`,`fedramp_high`],$e={"account-id":`accountId`,zone:`zone`,"compliance-region":`complianceRegion`},et=Object.keys($e);function tt(e){return Qe.includes(e)}function nt(){let e=W(`complianceRegion`,`CLOUDFLARE_COMPLIANCE_REGION`);if(!e)return`public`;if(!tt(e.value))throw Error(`Invalid compliance region "${e.value}". Must be one of: ${Qe.join(`, `)}`);return e.value}function rt(e,t=`zone`){switch(e.source){case`flag`:return t===`zone`?`--zone flag`:`(flag)`;case`env`:return{accountId:`CLOUDFLARE_ACCOUNT_ID`,zone:`CLOUDFLARE_ZONE_ID`,complianceRegion:`CLOUDFLARE_COMPLIANCE_REGION`}[t];case`project`:return`.cfrc`;case`config`:return`~/.config/cf/config.json`}}async function it(e,t,n,r){let i=t,a=t;if(e===`accountId`){if(!r)throw Error(`Authentication required to validate account ID`);let{id:e,name:n}=await st(t,r);i=e,a=n?`${e.slice(0,12)}... (${n})`:e}else if(e===`zone`){if(!r)throw Error(`Authentication required to validate zone`);let e=await ct(t,r);i=t,a=e.name}else e===`complianceRegion`&&(i=t,a=t);if(n===`project`){let t=U()?.config||{};t[e]=i,He(t)}else{let t=T();t.defaults||={},t.defaults[e]=i,w(t)}return{resolvedValue:i,displayName:a}}function at(e,t){if(t===`project`)if(e===`all`)Ue();else{let t=U();t&&(delete t.config[e],Object.keys(t.config).length===0?Ue(R(t.path)):He(t.config,R(t.path)))}else{let t=T();t.defaults&&(e===`all`?delete t.defaults:(delete t.defaults[e],Object.keys(t.defaults).length===0&&delete t.defaults),w(t))}}async function ot(e){return(await e.accounts.list({})).result}async function st(e,t){let n=await ot(t),r=n.find(t=>t.id===e);if(r)return{id:r.id,name:r.name};let i=n.find(t=>t.name.toLowerCase()===e.toLowerCase());if(i)return{id:i.id,name:i.name};if(pe(e))return{id:e};throw Error(`Account not found: "${e}"
27
+
28
+ Available accounts:
29
+ ${n.map(e=>` ${e.id.slice(0,12)}... ${e.name}`).join(`
30
+ `)}`)}async function ct(e,t){let n=(await t.zones.list({})).result,r=n.find(t=>t.id===e);if(r)return{id:r.id,name:r.name};let i=n.find(t=>t.name.toLowerCase()===e.toLowerCase());if(i)return{id:i.id,name:i.name};throw fe(e)?Error(`Zone not found: "${e}"
31
+
32
+ This zone either doesn't exist or you don't have access to it.
33
+ Run 'cf zones list' to see available zones.`):Error(`Invalid zone: "${e}"
34
+
35
+ Please provide a zone ID or domain name.
36
+ Run 'cf zones list' to see available zones.`)}function lt(){return z(process.cwd(),H)}function ut(e){function t(){return L.resolve(e(),`preferences.json`)}n(t,`getUserPreferencesPath`);function r(){try{let e=F(t(),`utf8`),n=JSON.parse(e);return typeof n==`object`&&n?n:{}}catch{return{}}}n(r,`readUserPreferences`);function i(e){let n={...r(),...e},i=t();he(L.dirname(i),{recursive:!0}),I(i,JSON.stringify(n,null,` `),{encoding:`utf-8`})}return n(i,`updateUserPreferences`),{readUserPreferences:r,updateUserPreferences:i}}n(ut,`createPreferences`);var dt=6e4,ft=525600,pt=43200,mt=1440,ht=Symbol.for(`constructDateFrom`);function G(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&ht in e?e[ht](t):e instanceof Date?new e.constructor(t):new Date(t)}n(G,`constructFrom`);function K(e,t){return G(t||e,e)}n(K,`toDate`);var gt={};function _t(){return gt}n(_t,`getDefaultOptions`);function vt(e){let t=K(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}n(vt,`getTimezoneOffsetInMilliseconds`);function yt(e,...t){let n=G.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}n(yt,`normalizeDates`);function bt(e,t){let n=K(e)-+K(t);return n<0?-1:n>0?1:n}n(bt,`compareAsc`);function xt(e){return G(e,Date.now())}n(xt,`constructNow`);function St(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}n(St,`getRoundingMethod`);var Ct={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},wt=n((e,t,n)=>{let r,i=Ct[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r},`formatDistance`);function q(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}n(q,`buildFormatLongFn`);var Tt={date:q({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:q({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:q({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},Et={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},Dt=n((e,t,n,r)=>Et[e],`formatRelative`);function J(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}n(J,`buildLocalizeFn`);var Ot={ordinalNumber:n((e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},`ordinalNumber`),era:J({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:J({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:n(e=>e-1,`argumentCallback`)}),month:J({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:J({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:J({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function Y(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?At(s,e=>e.test(o)):kt(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}n(Y,`buildMatchFn`);function kt(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}n(kt,`findKey`);function At(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}n(At,`findIndex`);function jt(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}n(jt,`buildMatchPatternFn`);var Mt={code:`en-US`,formatDistance:wt,formatLong:Tt,formatRelative:Dt,localize:Ot,match:{ordinalNumber:jt({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:n(e=>parseInt(e,10),`valueCallback`)}),era:Y({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:Y({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:n(e=>e+1,`valueCallback`)}),month:Y({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:Y({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:Y({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function Nt(e,t,n){let r=_t(),i=n?.locale??r.locale??Mt,a=bt(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),[s,c]=yt(n?.in,...a>0?[t,e]:[e,t]),l=St(n?.roundingMethod??`round`),u=c.getTime()-s.getTime(),d=u/dt,f=(u-(vt(c)-vt(s)))/dt,p=n?.unit,m;if(m=p||(d<1?`second`:d<60?`minute`:d<mt?`hour`:f<pt?`day`:f<ft?`month`:`year`),m===`second`){let e=l(u/1e3);return i.formatDistance(`xSeconds`,e,o)}else if(m===`minute`){let e=l(d);return i.formatDistance(`xMinutes`,e,o)}else if(m===`hour`){let e=l(d/60);return i.formatDistance(`xHours`,e,o)}else if(m===`day`){let e=l(f/mt);return i.formatDistance(`xDays`,e,o)}else if(m===`month`){let e=l(f/pt);return e===12&&p!==`month`?i.formatDistance(`xYears`,1,o):i.formatDistance(`xMonths`,e,o)}else{let e=l(f/ft);return i.formatDistance(`xYears`,e,o)}}n(Nt,`formatDistanceStrict`);function Pt(e,t){return Nt(e,xt(e),t)}n(Pt,`formatDistanceToNowStrict`);function X(e,t){return{read:n(()=>{let n=t();if(!P(n))return;let r=te(n);try{return p(e,r)}catch{return}},`read`),write(n){let r=t();he(L.dirname(r),{recursive:!0}),I(r,c(e,n),{encoding:`utf-8`,mode:384}),me(r,384)},clear(){let e=t(),n=P(e);return _e(e,{force:!0}),n},path:t}}n(X,`createFileStorage`);function Ft(e){let{logger:t,prompt:r}=e;return n(async function(e,n){if(ie())return t.log(n),!0;let i=await r(e);return typeof i==`string`&&i.trim().toLowerCase()===`yes`},`ensureTemporaryTermsAccepted`)}n(Ft,`createTemporaryTermsPrompt`);var It=[9106,1e4];function Lt(e){return e?.code}n(Lt,`getErrorCode`);function Rt(e){let t=Lt(e);return t!==void 0&&It.includes(t)}n(Rt,`isMembershipsInaccessible`);function zt(e){return{"no-credentials-non-interactive":`Could not authenticate because no credentials were found and the environment is non-interactive. Set a CLOUDFLARE_API_TOKEN environment variable or run \`${e}\` in an interactive terminal first.`,"no-credentials-login-failed":`No credentials were found and the login attempt was unsuccessful. Run \`${e}\` to try again.`,"token-expired-non-interactive":`Your auth token has expired and could not be refreshed, and the environment is non-interactive. Run \`${e}\` in an interactive terminal or set a CLOUDFLARE_API_TOKEN.`,"token-expired-login-failed":`Your auth token has expired and could not be refreshed, and the login attempt was unsuccessful. Run \`${e}\` to try again.`}}n(zt,`notLoggedInErrorBodies`);function Bt(e,t,n){let r=new Date(t.claim.expiresAt);e.log(m`
37
+ Temporary account ready:
38
+ Account: ${t.account.name} (${n?`reused`:`created`})
39
+ Claim within: ${Pt(r)}
40
+ Claim URL: ${t.claim.url}
41
+ `)}n(Bt,`logTemporaryPreviewAccount`);function Vt(e,t){let{logger:i}=t,a=e.cliName,o=zt(e.commands.login),s=`
42
+ Run \`${e.commands.whoami}\` to check your current authentication status.`,c=ut(e.getConfigPath),d=oe(i,e.cacheNamespace?{namespace:e.cacheNamespace}:void 0),f=l({serviceName:e.keyringServiceName,getConfigPath:e.getConfigPath,isKeyringEnabled:n(()=>c.readUserPreferences().keyring_enabled===!0,`isKeyringEnabled`),logger:i,isNonInteractiveOrCI:ie,loginCommand:e.commands.login,format:e.fileFormat}),p=e.allowGlobalAuthKey??!0,m=r({logger:i,isNonInteractiveOrCI:ie,openInBrowser:n(e=>ae(e,i),`openInBrowser`),hasEnvCredentials:n(()=>u({allowGlobalAuthKey:p})!==void 0,`hasEnvCredentials`),purgeOnLoginOrLogout:d.purgeConfigCaches,clientId:e.clientId,consent:e.consent,redirectUri:e.redirectUri,storageFactory:f.storageFactory,allowGlobalAuthKey:p,temporary:{storage:X(e.fileFormat,e.getTemporaryAccountConfigPath),prompt:Ft({logger:i,prompt:t.prompt})}});function h(e){m.setProfile(e)}n(h,`setProfile`);function g(){return m.getActiveProfile()}n(g,`getActiveProfile`);function _(){return f.getActiveStore(m.getActiveProfile())}n(_,`getCredentialStore`);function te(e){m.setTemporaryAllowed(e)}n(te,`setTemporaryAllowed`);function v(){return m.getAPIToken()}n(v,`getAPIToken`);function b(){return m.requireApiToken()}n(b,`requireApiToken`);function x(t,n){return{complianceConfig:t,scopes:n?.scopes??e.getDefaultScopeKeys(),browser:n?.browser??!0,callbackHost:n?.callbackHost,callbackPort:n?.callbackPort,profile:n?.profile}}n(x,`withDefaultScopes`);async function S(e,t){return m.login(x(e,t))}n(S,`login`);async function C(e){return m.logout(e)}n(C,`logout`);async function w(e,t){return m.getActiveTemporaryAccount()?{loggedIn:!0}:m.loginOrRefreshIfRequired(x(e,t))}n(w,`loginOrRefreshIfRequired`);async function ue(){return m.getOAuthTokenFromLocalState()}n(ue,`getOAuthTokenFromLocalState`);function T(){return m.getScopes()}n(T,`getScopes`);function E(){return f.storageFactory(g()).read()}n(E,`readAuthCredentials`);function de(e){f.storageFactory(g()).write(e)}n(de,`writeAuthCredentials`);function D(){let t=m.getActiveProfile();return t===`default`?`${e.accountCachePrefix}.json`:`${e.accountCachePrefix}-${t}.json`}n(D,`getAccountCacheFileName`);function O(e){d.saveToConfigCache(D(),{account:e})}n(O,`saveAccountToCache`);function k(){return d.getConfigCache(D()).account}n(k,`getAccountFromCache`);async function A(e,n){let r=await w(e);if(!r.loggedIn)throw new y(`Not logged in. ${o[r.reason]}${s}`,{telemetryMessage:`cfetch auth login required`});let a=b(),c=[],l=!0,u=1,d;for(;l;){d=new ye(d),d.set(`page`,String(u));let{response:r,status:o}=await ce(e,n,{},t.userAgent,i,d,void 0,a);r.success?(c.push(...r.result),ne(r.result_info)?u+=1:l=!1):re(n,r,o)}return c}n(A,`fetchAccountsPaged`);async function j(t,n={}){let{throwOnEmpty:r=!0}=n,[i,a]=await Promise.allSettled([A(t,`/accounts`),A(t,`/memberships`)]);if(i.status===`rejected`)throw i.reason;if(a.status===`rejected`)if(Rt(a.reason)){if(i.status===`fulfilled`&&i.value.length>0)return i.value;throw Lt(a.reason)===9106?new y(`Failed to automatically retrieve account IDs for the logged in user.
43
+ You may have incorrect permissions on your API token, or an environment variable such as CLOUDFLARE_API_TOKEN, CLOUDFLARE_API_KEY, or CLOUDFLARE_EMAIL may be set to an invalid value.
44
+ Check your environment and unset or correct any Cloudflare credential variables, or run \`${e.commands.login}\` to re-authenticate.
45
+ You can also skip this account check by adding an \`account_id\` in your ${e.getConfigFileLabel()} file, or by setting the value of CLOUDFLARE_ACCOUNT_ID`,{telemetryMessage:`user account fetch permission denied`}):new y(`Failed to automatically retrieve account IDs for the logged in user.
46
+ You may have incorrect permissions on your API token, or your authentication may have expired. Try running \`${e.commands.login}\` to re-authenticate. You can also skip this account check by adding an \`account_id\` in your ${e.getConfigFileLabel()} file, or by setting the value of CLOUDFLARE_ACCOUNT_ID`,{telemetryMessage:`user account fetch permission denied`})}else throw a.reason;let o=new Set(a.value.map(e=>e.account.id)),s=i.value.filter(e=>o.has(e.id));if(s.length===0&&r)throw new y(`Failed to automatically retrieve account IDs for the logged in user.
47
+ In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or as \`account_id\` in your ${e.getConfigFileLabel()} file.
48
+ Alternatively, try running \`${e.commands.login}\` to re-authenticate.`,{telemetryMessage:`user account fetch empty`});return s}n(j,`fetchAllAccounts`);function M(e){let t=m.getActiveTemporaryAccount();return t?t.account.id:e.account_id?e.account_id:ee()||k()?.id}n(M,`getActiveAccountId`);async function N(n){let r=M(n);if(r)return r;let i=await j(n);if(i.length===1)return O({id:i[0].id,name:i[0].name}),i[0].id;try{let e=await t.select(`Select an account`,{choices:i.map(e=>({title:e.name,value:e.id}))}),n=i.find(t=>t.id===e);if(!n)throw Error(`Selected account not found in accounts list`);return O({id:n.id,name:n.name}),e}catch(n){if(t.isNoDefaultValueProvidedError(n)){let t=se();throw new y(`More than one account available but unable to select one in non-interactive mode.
49
+ Please set the appropriate \`account_id\` in your ${e.getConfigFileLabel()} file or assign it to the \`CLOUDFLARE_ACCOUNT_ID\` environment variable.
50
+ Available accounts are (\`<name>\`: \`<account_id>\`):
51
+ ${i.map(e=>` \`${t?`(redacted)`:e.name}\`: \`${e.id}\``).join(`
52
+ `)}`,{telemetryMessage:`user account selection unavailable`})}throw n}}n(N,`getOrSelectAccountId`);async function fe(e){if(m.isTemporaryAllowed()){if(le(e)!==`public`)throw new y(`Temporary accounts aren't available when the compliance region is not set to public.`,{telemetryMessage:`user temporary account unavailable in compliance region`});if(v())throw new y("You're already authenticated with Cloudflare, so `--temporary` can't be used. Temporary preview accounts are only for unauthenticated use. Either remove `--temporary` to use your existing account, or log out (and unset CLOUDFLARE_API_TOKEN) first.",{telemetryMessage:`user temporary account already authenticated`});let{account:t,cached:n}=await m.activateTemporaryAccount();return Bt(i,t,n),t.account.id}let t=await w(e);if(!t.loggedIn)throw t.reason===`no-credentials-non-interactive`||t.reason===`token-expired-non-interactive`?new y(`In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for ${a} to work. Please go to https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN.`,{telemetryMessage:`user auth missing api token non interactive`}):new y(`Did not login, quitting...`,{telemetryMessage:`user login cancelled`});let n=await N(e);if(!n)throw new y(`No account id found, quitting...`,{telemetryMessage:`user auth missing account id`});return n}return n(fe,`requireAuth`),{setProfile:h,getActiveProfile:g,getCredentialStore:_,setTemporaryAllowed:te,getAPIToken:v,requireApiToken:b,login:S,logout:C,loginOrRefreshIfRequired:w,getOAuthTokenFromLocalState:ue,getScopes:T,readAuthCredentials:E,writeAuthCredentials:de,getActiveAccountId:M,getOrSelectAccountId:N,getAccountFromCache:k,fetchAllAccounts:j,requireAuth:fe}}n(Vt,`createCloudflareAuth`);var Ht=`profiles/directory-bindings.json`,Ut=`.enc`;function Wt(e){let{logger:t,getConfigPath:r,keyringServiceName:a,format:s}=e,c=`.${s}`;function l(e){return i(r(),e,s)}n(l,`plaintextPath`);function u(e){return o(r(),e)}n(u,`encryptedPath`);function p(){return L.dirname(l(`default`))}n(p,`getProfileConfigDirectory`);let m={exists(e){return P(l(e))||P(u(e))},list(){let e=p();if(!P(e))return[];let t=new Set;for(let n of ge(e))n.endsWith(c)?t.add(n.slice(0,-c.length)):n.endsWith(Ut)&&t.add(n.slice(0,-Ut.length));return[...t]},delete(e){let{backendAvailable:n,encryptedFileExisted:i}=d({serviceName:a,configPath:r(),profile:e,format:s});X(s,()=>l(e)).clear(),i&&!n&&t.warn(`Removed the credential files for profile "${e}", but the keyring backend was not reachable on this host so its keyring entry could not be cleared. Clear it manually if it persists.`)}};function h(){return L.join(r(),Ht)}return n(h,`getDirectoryBindingsPath`),f({configs:m,bindings:{read(){try{let e=F(h(),`utf-8`);return JSON.parse(e)}catch{return{}}},write(e){let t=h();he(L.dirname(t),{recursive:!0}),I(t,JSON.stringify(e,null,` `),`utf-8`)}}})}n(Wt,`createCloudflareProfileStore`);function Gt(e){let{loginCommand:t,createProfileCommand:r,keyringServiceName:i,getConfigPath:c,format:l,preferences:u}=e,{readUserPreferences:f,updateUserPreferences:p}=u;function m(e){return e??`default`}n(m,`describeProfile`);function h(e){let t=[];P(o(c()))&&t.push(void 0);let n=Wt({logger:e,getConfigPath:c,keyringServiceName:i,format:l});for(let e of n.configs.list()){try{s(e)}catch{continue}P(o(c(),e))&&t.push(e)}return t}n(h,`listEncryptedProfiles`);function ee(e){let n=h(e);if(n.length===0)return;let a=[],o=[];for(let t of n)try{let{backendAvailable:e}=d({serviceName:i,configPath:c(),profile:t,format:l});a.push(m(t)),e||o.push(m(t))}catch(n){e.warn(`Failed to remove encrypted credentials for profile "${m(t)}": ${n instanceof Error?n.message:String(n)}. You may need to clear them manually.`)}if(a.length>0){let n=r?`Re-authenticate with \`${t}\` (default profile) or \`${r} <name>\` (named profiles).`:`Re-authenticate with \`${t}\`.`;e.log(`Removed encrypted credentials for ${a.map(e=>`"${e}"`).join(`, `)}. ${n}`)}o.length>0&&e.warn(`The keyring backend was not reachable on this host, so the keyring entry for ${o.map(e=>`"${e}"`).join(`, `)} could not be cleared. Clear it manually if it persists.`)}n(ee,`scrubAllEncryptedProfiles`);function g(e,t){let{logger:n,getCredentialStore:r}=t,i=f().keyring_enabled===!0,o=a();if(o!==void 0&&o!==e&&n.warn(`CLOUDFLARE_AUTH_USE_KEYRING=${o} overrides ${e?`enabling`:`disabling`} keyring storage for this command.`),!e&&o!==!0&&ee(n),p({keyring_enabled:e}),e&&o!==!1)try{r().kind!==`encrypted-file`&&(p({keyring_enabled:i}),n.warn(`Keyring storage isn't available on this host (see warning above), so it was not enabled. Try again once the keyring backend is reachable.`))}catch(e){throw p({keyring_enabled:i}),e}return{enabled:f().keyring_enabled===!0}}return n(g,`setKeyringPreference`),{setKeyringPreference:g}}n(Gt,`createKeyringPreference`);function Kt(e){let{getConfigPath:t,format:r}=e;function a(e){return i(t(),e,r)}n(a,`getAuthConfigFilePath`);function s(e){return o(t(),e)}n(s,`getEncryptedAuthConfigFilePath`);function c(e){return X(r,()=>a(e))}n(c,`defaultAuthConfigStorage`);function l(e,t){c(t).write(e)}n(l,`writeAuthConfigFile`);function u(e){return c(e).read()}return n(u,`readAuthConfigFile`),{getAuthConfigFilePath:a,getEncryptedAuthConfigFilePath:s,defaultAuthConfigStorage:c,readAuthConfigFile:u,writeAuthConfigFile:l}}n(Kt,`createAuthConfigFileHelpers`);var qt=`cloudflare`,Jt=`cf`,Yt=`http://localhost:8877/oauth/callback`,Xt={granted:{url:`https://welcome.developers.workers.dev/cf-oauth-consent-granted`},denied:{url:`https://welcome.developers.workers.dev/cf-oauth-consent-denied`,error:"Error: Consent denied. You must grant consent to cf in order to login.\nIf you don't want to do this consider passing an API token via the `CLOUDFLARE_API_TOKEN` environment variable"}},Zt=v({variableName:`CLOUDFLARE_CLIENT_ID`,defaultValue:n(()=>`cbca97e7-c331-4cdd-8fd8-e25a451b98bf`,`defaultValue`)});function Z(){return x({appName:`cloudflare`,leadingDot:!1,useLegacyHomeDir:!1})}n(Z,`getCfConfigPath`);var Qt=`openid.offline.user:read.account:read.access:read.access:write.agw:read.agw:run.agw:write.ai:read.ai:write.ai-search:read.ai-search:run.ai-search:write.aiaudit:read.aiaudit:write.aig:read.aig:write.auditlogs:read.browser:read.browser:write.cfone:read.cfone:write.cloudchamber:write.connectivity:admin.connectivity:bind.connectivity:read.constellation:write.containers:write.d1:write.dex:read.dex:write.dns_analytics:read.dns_records:edit.dns_records:read.dns_settings:read.firstpartytags:write.images:read.images:write.lb:edit.lb:read.logpush:read.logpush:write.mcp_portals:read.mcp_portals:write.notebook-examples:read.notification:read.notification:write.pages:read.pages:write.pipelines:read.pipelines:setup.pipelines:write.query_cache:write.queues:write.r2_catalog:write.radar:read.rag:read.rag:write.registrar:read.registrar:write.secrets_store:read.secrets_store:write.sso-connector:read.sso-connector:write.ssl_certs:write.teams:pii.teams:read.teams:secure_location.teams:write.url_scanner:read.url_scanner:write.vectorize:write.workers:read.workers:write.workers_builds:read.workers_builds:write.workers_deployments:read.workers_kv:write.workers_observability:read.workers_observability:write.workers_observability_telemetry:write.workers_routes:write.workers_scripts:write.workers_tail:read.zone:read`.split(`.`),$t=[...Qt];function en(e){$t=e}n(en,`setLoginScopeKeys`);var tn=new Set(Qt);function nn(e){return e.every(e=>tn.has(e))}n(nn,`validateScopeKeys`);function rn(){let e=b();return e===`production`?`cloudflare-temporary-account.json`:`cloudflare-temporary-account.${e}.json`}n(rn,`getTemporaryAccountConfigFile`);function an(){return L.join(Z(),rn())}n(an,`getCfTemporaryAccountConfigPath`);function on(e){return X(`json`,e)}n(on,`createJsonFileStorage`);var{getAuthConfigFilePath:sn,getEncryptedAuthConfigFilePath:cn,defaultAuthConfigStorage:ln,readAuthConfigFile:un,writeAuthConfigFile:dn}=Kt({getConfigPath:Z,format:`json`}),Q={cliName:Jt,commands:{login:`cf auth login`,whoami:`cf auth whoami`},keyringServiceName:qt,clientId:Zt,consent:Xt,redirectUri:Yt,allowGlobalAuthKey:!1,getConfigPath:Z,getTemporaryAccountConfigPath:an,fileFormat:`json`,accountCachePrefix:`cloudflare-account`,cacheNamespace:`cloudflare`,getConfigFileLabel:n(()=>`cf config`,`getConfigFileLabel`),getDefaultScopeKeys:n(()=>$t,`getDefaultScopeKeys`)},fn=ut(Z),{readUserPreferences:pn,updateUserPreferences:mn}=fn;function hn(e){return Vt(Q,e)}n(hn,`createCfAuth`);function gn(e){return Wt({logger:e.logger,getConfigPath:Z,keyringServiceName:qt,format:`json`})}n(gn,`createCfProfileStore`);var _n=Gt({loginCommand:Q.commands.login,createProfileCommand:Q.commands.createProfile,keyringServiceName:qt,getConfigPath:Z,format:`json`,preferences:fn});function vn(e,t){return _n.setKeyringPreference(e,t)}n(vn,`setKeyringPreference`);var yn=t({getActiveProfile:()=>Dn,getConfigPath:()=>Nn,getProfileStore:()=>On,getValidToken:()=>An,isOAuthLoggedIn:()=>jn,login:()=>wn,logout:()=>Tn,readAuthCredentials:()=>Mn,resolveProfile:()=>kn,setProfile:()=>En});const bn={debug:(...e)=>{process.env.DEBUG&&console.error(...e)},info:(...e)=>console.error(...e),log:(...e)=>console.error(...e),warn:(...e)=>console.error(...e),error:(...e)=>console.error(...e)};var xn=class extends Error{};async function Sn(e){if(V())throw new xn;h(_);let t=await A({message:e});return(k(t)||typeof t!=`string`)&&process.exit(130),t}async function Cn(e,t){if(V())throw new xn;h(_);let n=await O({message:e,options:t.choices.map(({title:e,value:t})=>({label:e,value:t}))});return(k(n)||typeof n!=`string`)&&process.exit(130),n}const $=hn({logger:bn,userAgent:g,prompt:Sn,select:Cn,isNoDefaultValueProvidedError:e=>e instanceof xn});function wn(e){if(e?.scopes&&!nn(e.scopes))throw Error(`One or more of the requested scopes are not valid cf OAuth scopes.`);return $.login({compliance_region:nt()},{browser:e?.browser??!0,...e?.scopes&&{scopes:e.scopes},...e?.profile&&{profile:e.profile}})}function Tn(e){return $.logout(e)}function En(e){$.setProfile(e)}function Dn(){return $.getActiveProfile()}function On(){return gn({logger:bn})}function kn(e,t=process.cwd()){let n=On().resolve({profile:e,cwd:t});return En(n),n}function An(){return $.getOAuthTokenFromLocalState()}function jn(){return $.readAuthCredentials()?.oauth_token!==void 0}function Mn(){return $.readAuthCredentials()}function Nn(){return $.getCredentialStore().path()}export{it as C,Fe as D,ze as E,V as O,Ge as S,Be as T,nt as _,jn as a,Ze as b,yn as c,et as d,$e as f,Ke as g,U as h,An as i,Pe as k,Mn as l,at as m,Nn as n,wn as o,Qe as p,On as r,Tn as s,Dn as t,En as u,We as v,Ve as w,Ye as x,lt as y};
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import{C as e,D as t,E as n,T as r,_ as 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}from"./input-validation-zEO81MWN.mjs";import{t as f}from"./local-VJaJ3BZ1.mjs";import{t as p}from"./cli-types-CRIDdDw3.mjs";function m(e){return e.option(`configuration-type`,{type:`string`,description:`The configuration.type field`,choices:[`logpush`]}).option(`configuration-url`,{type:`string`,description:`The configuration.url field`}).option(`enabled`,{type:`boolean`,description:`The enabled field`}).option(`name`,{type:`string`,description:`The name field`}).option(`skip-preflight-check`,{type:`boolean`,description:`The skipPreflightCheck field`}).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:`create`,describe:`Create a new Workers Observability Telemetry Destination.`,builder:m,handler:async r=>{if(r.dryRun){l({command:`cf observability destinations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/destinations`,pathParams:{},bodyKind:`json`,body:r.body===void 0?s({configuration:{type:d(r[`configuration-type`],`configuration-type`,`text`),url:d(r[`configuration-url`],`configuration-url`,`text`)},enabled:r.enabled,name:d(r.name,`name`,`text`),skipPreflightCheck:r[`skip-preflight-check`]}):o(r.body)});return}let p=await a(r),m=r.local?f:await i(p);if(r.accountId=m,r.body){let e=o(r.body);c(await u(`Creating`,async()=>p.observability.destinations.create({...e,account_id:m})),{successLabel:`Created`});return}if(r[`configuration-type`]===void 0&&(r[`configuration-type`]=await n(`configuration-type`,`The configuration.type field`,[`logpush`])),r[`configuration-url`]===void 0&&(r[`configuration-url`]=await t(`configuration-url`,`The configuration.url field`)),r.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);r.name===void 0&&(r.name=await t(`name`,`The name field`));let h=s({configuration:{type:d(r[`configuration-type`],`configuration-type`,`text`),url:d(r[`configuration-url`],`configuration-url`,`text`)},enabled:r.enabled,name:d(r.name,`name`,`text`),skipPreflightCheck:r[`skip-preflight-check`]});c(await u(`Creating`,async()=>p.observability.destinations.create({...h,account_id:m})),{successLabel:`Created`})}};function g(e){return e.positional(`slug`,{type:`string`,description:`Slug`,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 _={command:`delete <slug>`,describe:`Delete a Workers Observability Telemetry Destination.`,builder:g,handler:async t=>{if(t.dryRun){l({command:`cf observability destinations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/destinations/${t.slug==null?`<slug>`:encodeURIComponent(String(t.slug))}`,pathParams:{slug:String(t.slug??``)},bodyKind:`none`});return}let n=await a(t),o=t.local?f:await i(n);if(t.accountId=o,!await r({force:!!t.force})){process.stderr.write(`Aborted.
3
- `);return}c(await u(`Deleting`,async()=>n.observability.destinations.delete({account_id:o,slug:t.slug})),{successLabel:`Deleted`})}};function v(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`PerPage`}).option(`order`,{type:`string`,description:`Order`,choices:[`asc`,`desc`]}).option(`order-by`,{type:`string`,description:`OrderBy`,choices:[`created`,`updated`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`list`,describe:`List your Workers Observability Telemetry Destinations.`,builder:p(v),handler:async t=>{let n={page:t.page,perPage:t[`per-page`],order:t.order,orderBy:t[`order-by`]};if(t.dryRun){l({command:`cf observability destinations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/destinations`,pathParams:{},query:n,bodyKind:`none`});return}let r=await a(t),o=t.local?f:await i(r);t.accountId=o,c(await u(`Loading`,async()=>r.observability.destinations.list({account_id:o,...n})),{successLabel:`Loaded`})}};function b(e){return e.positional(`slug`,{type:`string`,description:`Slug`,demandOption:!0}).option(`configuration-type`,{type:`string`,description:`The configuration.type field`,choices:[`logpush`]}).option(`configuration-url`,{type:`string`,description:`The configuration.url field`}).option(`enabled`,{type:`boolean`,description:`The enabled field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const x={command:`update <slug>`,describe:`Update an existing Workers Observability Telemetry Destination.`,builder:b,handler:async r=>{if(r.dryRun){l({command:`cf observability destinations update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/destinations/${r.slug==null?`<slug>`:encodeURIComponent(String(r.slug))}`,pathParams:{slug:String(r.slug??``)},bodyKind:`json`,body:r.body===void 0?s({configuration:{type:d(r[`configuration-type`],`configuration-type`,`text`),url:d(r[`configuration-url`],`configuration-url`,`text`)},enabled:r.enabled}):o(r.body)});return}let p=await a(r),m=r.local?f:await i(p);if(r.accountId=m,r.body){let e=o(r.body);c(await u(`Updating`,async()=>p.observability.destinations.update({...e,account_id:m,slug:r.slug})),{successLabel:`Updated`});return}if(r[`configuration-type`]===void 0&&(r[`configuration-type`]=await n(`configuration-type`,`The configuration.type field`,[`logpush`])),r[`configuration-url`]===void 0&&(r[`configuration-url`]=await t(`configuration-url`,`The configuration.url field`)),r.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);let h=s({configuration:{type:d(r[`configuration-type`],`configuration-type`,`text`),url:d(r[`configuration-url`],`configuration-url`,`text`)},enabled:r.enabled});c(await u(`Updating`,async()=>p.observability.destinations.update({...h,account_id:m,slug:r.slug})),{successLabel:`Updated`})}},S={command:`destinations`,describe:`Operations for destinations`,builder:e=>e.command(h).command(_).command(y).command(x).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function C(e){return e.option(`description`,{type:`string`,description:`The description field`}).option(`name`,{type:`string`,description:`Query name`}).option(`parameters-datasets`,{type:`string`,array:!0,description:`Set the Datasets to query. Leave it empty to query all the datasets.`}).option(`parameters-filter-combination`,{type:`string`,description:`Set a Flag to describe how to combine the filters on the query.`,choices:[`and`,`or`,`AND`,`OR`]}).option(`parameters-limit`,{type:`number`,description:`Set a limit on the number of results / records returned by the query`}).option(`parameters-needle-is-regex`,{type:`boolean`,description:`The parameters.needle.isRegex field`}).option(`parameters-needle-match-case`,{type:`boolean`,description:`The parameters.needle.matchCase field`}).option(`parameters-order-by-order`,{type:`string`,description:`Set the order of the results`,choices:[`asc`,`desc`]}).option(`parameters-order-by-value`,{type:`string`,description:`Configure which Calculation to order the results by.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Specify the new contents of the query.`})}const w={command:`create`,describe:`Persist query for later use.`,builder:C,handler:async n=>{if(n.dryRun){l({command:`cf observability queries create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/queries`,pathParams:{},bodyKind:`json`,body:n.body===void 0?s({description:d(n.description,`description`,`text`),name:d(n.name,`name`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}}}):o(n.body)});return}let r=await a(n),p=n.local?f:await i(r);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Creating`,async()=>r.observability.queries.create({...e,account_id:p})),{successLabel:`Created`});return}n.description===void 0&&(n.description=await t(`description`,`The description field`)),n.name===void 0&&(n.name=await t(`name`,`Query name`)),n[`parameters-order-by-value`]===void 0&&(n[`parameters-order-by-value`]=await t(`parameters-order-by-value`,`Configure which Calculation to order the results by.`));let m=s({description:d(n.description,`description`,`text`),name:d(n.name,`name`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}}});c(await u(`Creating`,async()=>r.observability.queries.create({...m,account_id:p})),{successLabel:`Created`})}};function T(e){return e.positional(`query-id`,{type:`string`,description:`QueryId`,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 E={command:`delete <queryId>`,describe:`Delete a saved query.`,builder:T,handler:async t=>{if(t.dryRun){l({command:`cf observability queries delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/queries/${t[`query-id`]==null?`<query-id>`:encodeURIComponent(String(t[`query-id`]))}`,pathParams:{"query-id":String(t[`query-id`]??``)},bodyKind:`none`});return}let n=await a(t),o=t.local?f:await i(n);if(t.accountId=o,!await r({force:!!t.force})){process.stderr.write(`Aborted.
4
- `);return}c(await u(`Deleting`,async()=>n.observability.queries.delete({account_id:o,queryId:t[`query-id`]})),{successLabel:`Deleted`})}};function D(e){return e.positional(`query-id`,{type:`string`,description:`QueryId`,demandOption:!0}).option(`description`,{type:`string`,description:`The description field`}).option(`name`,{type:`string`,description:`Query name`}).option(`parameters-datasets`,{type:`string`,array:!0,description:`Set the Datasets to query. Leave it empty to query all the datasets.`}).option(`parameters-filter-combination`,{type:`string`,description:`Set a Flag to describe how to combine the filters on the query.`,choices:[`and`,`or`,`AND`,`OR`]}).option(`parameters-limit`,{type:`number`,description:`Set a limit on the number of results / records returned by the query`}).option(`parameters-needle-is-regex`,{type:`boolean`,description:`The parameters.needle.isRegex field`}).option(`parameters-needle-match-case`,{type:`boolean`,description:`The parameters.needle.matchCase field`}).option(`parameters-order-by-order`,{type:`string`,description:`Set the order of the results`,choices:[`asc`,`desc`]}).option(`parameters-order-by-value`,{type:`string`,description:`Configure which Calculation to order the results by.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Specify the new contents of the query.`})}const O={command:`edit <queryId>`,describe:`Update saved query.`,builder:D,handler:async n=>{if(n.dryRun){l({command:`cf observability queries edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/queries/${n[`query-id`]==null?`<query-id>`:encodeURIComponent(String(n[`query-id`]))}`,pathParams:{"query-id":String(n[`query-id`]??``)},bodyKind:`json`,body:n.body===void 0?s({description:d(n.description,`description`,`text`),name:d(n.name,`name`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}}}):o(n.body)});return}let r=await a(n),p=n.local?f:await i(r);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Updating`,async()=>r.observability.queries.edit({...e,account_id:p,queryId:n[`query-id`]})),{successLabel:`Updated`});return}n.description===void 0&&(n.description=await t(`description`,`The description field`)),n.name===void 0&&(n.name=await t(`name`,`Query name`)),n[`parameters-order-by-value`]===void 0&&(n[`parameters-order-by-value`]=await t(`parameters-order-by-value`,`Configure which Calculation to order the results by.`));let m=s({description:d(n.description,`description`,`text`),name:d(n.name,`name`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}}});c(await u(`Updating`,async()=>r.observability.queries.edit({...m,account_id:p,queryId:n[`query-id`]})),{successLabel:`Updated`})}};function k(e){return e.positional(`query-id`,{type:`string`,description:`QueryId`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`get <queryId>`,describe:`Retrieve a saved query.`,builder:k,handler:async t=>{if(t.dryRun){l({command:`cf observability queries get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/queries/${t[`query-id`]==null?`<query-id>`:encodeURIComponent(String(t[`query-id`]))}`,pathParams:{"query-id":String(t[`query-id`]??``)},bodyKind:`none`});return}let n=await a(t),r=t.local?f:await i(n);t.accountId=r,c(await u(`Loading`,async()=>n.observability.queries.get({account_id:r,queryId:t[`query-id`]})),{successLabel:`Loaded`})}};function j(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`PerPage`}).option(`order`,{type:`string`,description:`Order`,choices:[`asc`,`desc`]}).option(`order-by`,{type:`string`,description:`OrderBy`,choices:[`created`,`updated`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`list`,describe:`List saved queries.`,builder:p(j),handler:async t=>{let n={page:t.page,perPage:t[`per-page`],order:t.order,orderBy:t[`order-by`]};if(t.dryRun){l({command:`cf observability queries list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/queries`,pathParams:{},query:n,bodyKind:`none`});return}let r=await a(t),o=t.local?f:await i(r);t.accountId=o,c(await u(`Loading`,async()=>r.observability.queries.list({account_id:o,...n})),{successLabel:`Loaded`})}},N={command:`queries`,describe:`Operations for queries`,builder:e=>e.command(w).command(E).command(O).command(A).command(M).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function P(e){return e.option(`datasets`,{type:`string`,array:!0,description:`Leave this empty to use the default datasets`}).option(`from`,{type:`number`,description:`The from field`}).option(`key-needle-is-regex`,{type:`boolean`,description:`When true, treats the value as a regular expression (RE2 syntax).`}).option(`key-needle-match-case`,{type:`boolean`,description:`When true, performs a case-sensitive search. Defaults to case-insensitive.`}).option(`limit`,{type:`number`,description:`Advanced usage: set limit=1000+ to retrieve comprehensive key options without needing additional filtering.`}).option(`needle-is-regex`,{type:`boolean`,description:`When true, treats the value as a regular expression (RE2 syntax).`}).option(`needle-match-case`,{type:`boolean`,description:`When true, performs a case-sensitive search. Defaults to case-insensitive.`}).option(`to`,{type:`number`,description:`The to field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Find keys in your telemetry events matching a specific filter or needle.`})}const F={command:`keys`,describe:`List all the keys in your telemetry events.`,builder:P,handler:async t=>{if(t.dryRun){l({command:`cf observability telemetry keys`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/telemetry/keys`,pathParams:{},bodyKind:`json`,body:t.body===void 0?s({datasets:t.datasets,from:t.from,keyNeedle:{isRegex:t[`key-needle-is-regex`],matchCase:t[`key-needle-match-case`]},limit:t.limit,needle:{isRegex:t[`needle-is-regex`],matchCase:t[`needle-match-case`]},to:t.to}):o(t.body)});return}let n=await a(t),r=t.local?f:await i(n);if(t.accountId=r,t.body){let e=o(t.body);c(await u(`Creating`,async()=>n.observability.telemetry.keys({...e,account_id:r})),{successLabel:`Created`});return}let d=s({datasets:t.datasets,from:t.from,keyNeedle:{isRegex:t[`key-needle-is-regex`],matchCase:t[`key-needle-match-case`]},limit:t.limit,needle:{isRegex:t[`needle-is-regex`],matchCase:t[`needle-match-case`]},to:t.to});c(await u(`Creating`,async()=>n.observability.telemetry.keys({...d,account_id:r})),{successLabel:`Created`})}};function I(e){return e.option(`chart`,{type:`boolean`,description:`When true, includes time-series data in the response.`}).option(`compare`,{type:`boolean`,description:`When true, includes a comparison dataset from the previous time period of equal length.`}).option(`dry`,{type:`boolean`,description:`When true, executes the query without persisting the results. Useful for validation or previewing.`,default:!1}).option(`granularity`,{type:`number`,description:`Number of time-series buckets. Only used when view is 'calculations'. Omit to let the system auto-detect an appropriate granularity.`}).option(`ignore-series`,{type:`boolean`,description:`When true, omits time-series data from the response and returns only aggregated values. Reduces response size when series are not needed.`,default:!1}).option(`limit`,{type:`number`,description:`Maximum number of events to return when view is 'events'. Also controls the number of group-by rows when view is 'calculations'.`,default:50}).option(`offset`,{type:`string`,description:`Cursor for pagination in event, trace, and invocation views. Pass the $metadata.id of the last returned item to fetch the next page.`}).option(`offset-by`,{type:`number`,description:`Numeric offset for paginating grouped/pattern results (top-N lists). Use together with limit. Not used by cursor-based pagination.`}).option(`offset-direction`,{type:`string`,description:`Pagination direction: 'next' for forward, 'prev' for backward.`}).option(`parameters-datasets`,{type:`string`,array:!0,description:`Datasets to query. Leave empty to query all available datasets.`}).option(`parameters-filter-combination`,{type:`string`,description:`Logical operator for combining top-level filters: 'and' (all must match) or 'or' (any must match). Defaults to 'and'.`,choices:[`and`,`or`,`AND`,`OR`]}).option(`parameters-limit`,{type:`number`,description:`Maximum number of group-by rows to return in calculation results. A value of 10 is a sensible default for most use cases.`}).option(`parameters-needle-is-regex`,{type:`boolean`,description:`When true, treats the value as a regular expression (RE2 syntax).`}).option(`parameters-needle-match-case`,{type:`boolean`,description:`When true, performs a case-sensitive search. Defaults to case-insensitive.`}).option(`parameters-order-by-order`,{type:`string`,description:`Sort direction: 'asc' for ascending, 'desc' for descending.`,choices:[`asc`,`desc`]}).option(`parameters-order-by-value`,{type:`string`,description:`Alias of the calculation to order results by. Must match the alias (or operator) of a calculation in the query.`}).option(`query-id`,{type:`string`,description:`Identifier for the query. When parameters are omitted, this ID is used to load a previously saved query's parameters. When providing parameters inline, pass any identifier (e.g. an ad-hoc ID).`}).option(`timeframe-from`,{type:`number`,description:`Start timestamp for the query timeframe (Unix timestamp in milliseconds)`}).option(`timeframe-to`,{type:`number`,description:`End timestamp for the query timeframe (Unix timestamp in milliseconds)`}).option(`view`,{type:`string`,description:`Controls the shape of the response. 'events': individual log lines matching the query. 'calculations': aggregated metrics (count, avg, p99, etc.) with optional group-by breakdowns and time-series. 'invocations': events grouped by request ID. 'traces': distributed trace summaries. 'agents': Durable Object agent summaries.`,choices:[`traces`,`events`,`calculations`,`invocations`,`requests`,`agents`],default:`calculations`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Query your observability events, requests, and traces to build visualizations and identify insights.`}).check(e=>{if([`parameters-datasets`,`parameters-filter-combination`,`parameters-limit`,`parameters-needle-is-regex`,`parameters-needle-match-case`,`parameters-order-by-order`,`parameters-order-by-value`].some(t=>e[t]!==void 0)){let t=[`parameters-order-by-value`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --parameters-* flag is set`)}return!0})}const L={command:`query`,describe:`Run a temporary or saved query.`,builder:I,handler:async n=>{if(n.dryRun){l({command:`cf observability telemetry query`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/telemetry/query`,pathParams:{},bodyKind:`json`,body:n.body===void 0?s({chart:n.chart,compare:n.compare,dry:n.dry,granularity:n.granularity,ignoreSeries:n[`ignore-series`],limit:n.limit,offset:d(n.offset,`offset`,`text`),offsetBy:n[`offset-by`],offsetDirection:d(n[`offset-direction`],`offset-direction`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}},queryId:d(n[`query-id`],`query-id`,`text`),timeframe:{from:n[`timeframe-from`],to:n[`timeframe-to`]},view:d(n.view,`view`,`text`)}):o(n.body)});return}let r=await a(n),p=n.local?f:await i(r);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Loading`,async()=>r.observability.telemetry.query({...e,account_id:p})),{successLabel:`Loaded`});return}if(n[`query-id`]===void 0&&(n[`query-id`]=await t(`query-id`,`Identifier for the query. When parameters are omitted, this ID is used to load a previously saved query's parameters. When providing parameters inline, pass any identifier (e.g. an ad-hoc ID).`)),n[`timeframe-from`]===void 0)throw Error(`--timeframe-from is required (or pass --body with this field set).`);if(n[`timeframe-to`]===void 0)throw Error(`--timeframe-to is required (or pass --body with this field set).`);let m=s({chart:n.chart,compare:n.compare,dry:n.dry,granularity:n.granularity,ignoreSeries:n[`ignore-series`],limit:n.limit,offset:d(n.offset,`offset`,`text`),offsetBy:n[`offset-by`],offsetDirection:d(n[`offset-direction`],`offset-direction`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}},queryId:d(n[`query-id`],`query-id`,`text`),timeframe:{from:n[`timeframe-from`],to:n[`timeframe-to`]},view:d(n.view,`view`,`text`)});c(await u(`Loading`,async()=>r.observability.telemetry.query({...m,account_id:p})),{successLabel:`Loaded`})}};function R(e){return e.option(`datasets`,{type:`string`,array:!0,description:`Leave this empty to use the default datasets`}).option(`key`,{type:`string`,description:`The key field`}).option(`limit`,{type:`number`,description:`The limit field`,default:50}).option(`needle-is-regex`,{type:`boolean`,description:`When true, treats the value as a regular expression (RE2 syntax).`}).option(`needle-match-case`,{type:`boolean`,description:`When true, performs a case-sensitive search. Defaults to case-insensitive.`}).option(`timeframe-from`,{type:`number`,description:`The timeframe.from field`}).option(`timeframe-to`,{type:`number`,description:`The timeframe.to field`}).option(`type`,{type:`string`,description:`The type field`,choices:[`string`,`boolean`,`number`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Retrieve values from your telemetry events.`})}const z={command:`values`,describe:`List unique values found in your events.`,builder:R,handler:async r=>{if(r.dryRun){l({command:`cf observability telemetry values`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/observability/telemetry/values`,pathParams:{},bodyKind:`json`,body:r.body===void 0?s({datasets:r.datasets,key:d(r.key,`key`,`text`),limit:r.limit,needle:{isRegex:r[`needle-is-regex`],matchCase:r[`needle-match-case`]},timeframe:{from:r[`timeframe-from`],to:r[`timeframe-to`]},type:d(r.type,`type`,`text`)}):o(r.body)});return}let p=await a(r),m=r.local?f:await i(p);if(r.accountId=m,r.body){let e=o(r.body);c(await u(`Creating`,async()=>p.observability.telemetry.values({...e,account_id:m})),{successLabel:`Created`});return}if(r.datasets===void 0)throw Error(`--datasets is required (or pass --body with this field set).`);if(r.key===void 0&&(r.key=await t(`key`,`The key field`)),r[`timeframe-from`]===void 0)throw Error(`--timeframe-from is required (or pass --body with this field set).`);if(r[`timeframe-to`]===void 0)throw Error(`--timeframe-to is required (or pass --body with this field set).`);r.type===void 0&&(r.type=await n(`type`,`The type field`,[`string`,`boolean`,`number`]));let h=s({datasets:r.datasets,key:d(r.key,`key`,`text`),limit:r.limit,needle:{isRegex:r[`needle-is-regex`],matchCase:r[`needle-match-case`]},timeframe:{from:r[`timeframe-from`],to:r[`timeframe-to`]},type:d(r.type,`type`,`text`)});c(await u(`Creating`,async()=>p.observability.telemetry.values({...h,account_id:m})),{successLabel:`Created`})}},B={command:`telemetry`,describe:`Operations for telemetry`,builder:e=>e.command(F).command(L).command(z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},V={command:`observability`,describe:`observability`,builder:e=>e.command(S).command(N).command(B).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{V as default};
2
+ import{E as e,S as t,T as n,g as r,w as i}from"./oauth-Bk-F-tIO.mjs";import{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}from"./input-validation-_fMCApaH.mjs";import{t as f}from"./local-CYc9q7l2.mjs";import{t as p}from"./cli-types-BeyOc81z.mjs";function m(e){return e.option(`configuration-type`,{type:`string`,description:`The configuration.type field`,choices:[`logpush`]}).option(`configuration-url`,{type:`string`,description:`The configuration.url field`}).option(`enabled`,{type:`boolean`,description:`The enabled field`}).option(`name`,{type:`string`,description:`The name field`}).option(`skip-preflight-check`,{type:`boolean`,description:`The skipPreflightCheck field`}).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:`create`,describe:`Create a new Workers Observability Telemetry Destination.`,builder:m,handler:async i=>{if(i.dryRun){l({command:`cf observability destinations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/destinations`,pathParams:{},bodyKind:`json`,body:i.body===void 0?s({configuration:{type:d(i[`configuration-type`],`configuration-type`,`text`),url:d(i[`configuration-url`],`configuration-url`,`text`)},enabled:i.enabled,name:d(i.name,`name`,`text`),skipPreflightCheck:i[`skip-preflight-check`]}):o(i.body)});return}let p=await a(i),m=i.local?f:await r(p);if(i.accountId=m,i.body){let e=o(i.body);c(await u(`Creating`,async()=>p.observability.destinations.create({...e,account_id:m})),{successLabel:`Created`});return}if(i[`configuration-type`]===void 0&&(i[`configuration-type`]=await n(`configuration-type`,`The configuration.type field`,[`logpush`])),i[`configuration-url`]===void 0&&(i[`configuration-url`]=await e(`configuration-url`,`The configuration.url field`)),i.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);i.name===void 0&&(i.name=await e(`name`,`The name field`));let h=s({configuration:{type:d(i[`configuration-type`],`configuration-type`,`text`),url:d(i[`configuration-url`],`configuration-url`,`text`)},enabled:i.enabled,name:d(i.name,`name`,`text`),skipPreflightCheck:i[`skip-preflight-check`]});c(await u(`Creating`,async()=>p.observability.destinations.create({...h,account_id:m})),{successLabel:`Created`})}};function g(e){return e.positional(`slug`,{type:`string`,description:`Slug`,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 _={command:`delete <slug>`,describe:`Delete a Workers Observability Telemetry Destination.`,builder:g,handler:async e=>{if(e.dryRun){l({command:`cf observability destinations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/destinations/${e.slug==null?`<slug>`:encodeURIComponent(String(e.slug))}`,pathParams:{slug:String(e.slug??``)},bodyKind:`none`});return}let n=await a(e),o=e.local?f:await r(n);if(e.accountId=o,!await i({force:!!e.force})){process.stderr.write(`Aborted.
3
+ `);return}c(await u(`Deleting`,async()=>n.observability.destinations.delete({account_id:o,slug:e.slug})),{successLabel:`Deleted`})}};function v(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`PerPage`}).option(`order`,{type:`string`,description:`Order`,choices:[`asc`,`desc`]}).option(`order-by`,{type:`string`,description:`OrderBy`,choices:[`created`,`updated`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`list`,describe:`List your Workers Observability Telemetry Destinations.`,builder:p(v),handler:async e=>{let n={page:e.page,perPage:e[`per-page`],order:e.order,orderBy:e[`order-by`]};if(e.dryRun){l({command:`cf observability destinations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/destinations`,pathParams:{},query:n,bodyKind:`none`});return}let i=await a(e),o=e.local?f:await r(i);e.accountId=o,c(await u(`Loading`,async()=>i.observability.destinations.list({account_id:o,...n})),{successLabel:`Loaded`})}};function b(e){return e.positional(`slug`,{type:`string`,description:`Slug`,demandOption:!0}).option(`configuration-type`,{type:`string`,description:`The configuration.type field`,choices:[`logpush`]}).option(`configuration-url`,{type:`string`,description:`The configuration.url field`}).option(`enabled`,{type:`boolean`,description:`The enabled field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const x={command:`update <slug>`,describe:`Update an existing Workers Observability Telemetry Destination.`,builder:b,handler:async i=>{if(i.dryRun){l({command:`cf observability destinations update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/destinations/${i.slug==null?`<slug>`:encodeURIComponent(String(i.slug))}`,pathParams:{slug:String(i.slug??``)},bodyKind:`json`,body:i.body===void 0?s({configuration:{type:d(i[`configuration-type`],`configuration-type`,`text`),url:d(i[`configuration-url`],`configuration-url`,`text`)},enabled:i.enabled}):o(i.body)});return}let p=await a(i),m=i.local?f:await r(p);if(i.accountId=m,i.body){let e=o(i.body);c(await u(`Updating`,async()=>p.observability.destinations.update({...e,account_id:m,slug:i.slug})),{successLabel:`Updated`});return}if(i[`configuration-type`]===void 0&&(i[`configuration-type`]=await n(`configuration-type`,`The configuration.type field`,[`logpush`])),i[`configuration-url`]===void 0&&(i[`configuration-url`]=await e(`configuration-url`,`The configuration.url field`)),i.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);let h=s({configuration:{type:d(i[`configuration-type`],`configuration-type`,`text`),url:d(i[`configuration-url`],`configuration-url`,`text`)},enabled:i.enabled});c(await u(`Updating`,async()=>p.observability.destinations.update({...h,account_id:m,slug:i.slug})),{successLabel:`Updated`})}},S={command:`destinations`,describe:`Operations for destinations`,builder:e=>e.command(h).command(_).command(y).command(x).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function C(e){return e.option(`description`,{type:`string`,description:`The description field`}).option(`name`,{type:`string`,description:`Query name`}).option(`parameters-datasets`,{type:`string`,array:!0,description:`Set the Datasets to query. Leave it empty to query all the datasets.`}).option(`parameters-filter-combination`,{type:`string`,description:`Set a Flag to describe how to combine the filters on the query.`,choices:[`and`,`or`,`AND`,`OR`]}).option(`parameters-limit`,{type:`number`,description:`Set a limit on the number of results / records returned by the query`}).option(`parameters-needle-is-regex`,{type:`boolean`,description:`The parameters.needle.isRegex field`}).option(`parameters-needle-match-case`,{type:`boolean`,description:`The parameters.needle.matchCase field`}).option(`parameters-order-by-order`,{type:`string`,description:`Set the order of the results`,choices:[`asc`,`desc`]}).option(`parameters-order-by-value`,{type:`string`,description:`Configure which Calculation to order the results by.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Specify the new contents of the query.`})}const w={command:`create`,describe:`Persist query for later use.`,builder:C,handler:async n=>{if(n.dryRun){l({command:`cf observability queries create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/queries`,pathParams:{},bodyKind:`json`,body:n.body===void 0?s({description:d(n.description,`description`,`text`),name:d(n.name,`name`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}}}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Creating`,async()=>i.observability.queries.create({...e,account_id:p})),{successLabel:`Created`});return}n.description===void 0&&(n.description=await e(`description`,`The description field`)),n.name===void 0&&(n.name=await e(`name`,`Query name`)),n[`parameters-order-by-value`]===void 0&&(n[`parameters-order-by-value`]=await e(`parameters-order-by-value`,`Configure which Calculation to order the results by.`));let m=s({description:d(n.description,`description`,`text`),name:d(n.name,`name`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}}});c(await u(`Creating`,async()=>i.observability.queries.create({...m,account_id:p})),{successLabel:`Created`})}};function T(e){return e.positional(`query-id`,{type:`string`,description:`QueryId`,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 E={command:`delete <queryId>`,describe:`Delete a saved query.`,builder:T,handler:async e=>{if(e.dryRun){l({command:`cf observability queries delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/queries/${e[`query-id`]==null?`<query-id>`:encodeURIComponent(String(e[`query-id`]))}`,pathParams:{"query-id":String(e[`query-id`]??``)},bodyKind:`none`});return}let n=await a(e),o=e.local?f:await r(n);if(e.accountId=o,!await i({force:!!e.force})){process.stderr.write(`Aborted.
4
+ `);return}c(await u(`Deleting`,async()=>n.observability.queries.delete({account_id:o,queryId:e[`query-id`]})),{successLabel:`Deleted`})}};function D(e){return e.positional(`query-id`,{type:`string`,description:`QueryId`,demandOption:!0}).option(`description`,{type:`string`,description:`The description field`}).option(`name`,{type:`string`,description:`Query name`}).option(`parameters-datasets`,{type:`string`,array:!0,description:`Set the Datasets to query. Leave it empty to query all the datasets.`}).option(`parameters-filter-combination`,{type:`string`,description:`Set a Flag to describe how to combine the filters on the query.`,choices:[`and`,`or`,`AND`,`OR`]}).option(`parameters-limit`,{type:`number`,description:`Set a limit on the number of results / records returned by the query`}).option(`parameters-needle-is-regex`,{type:`boolean`,description:`The parameters.needle.isRegex field`}).option(`parameters-needle-match-case`,{type:`boolean`,description:`The parameters.needle.matchCase field`}).option(`parameters-order-by-order`,{type:`string`,description:`Set the order of the results`,choices:[`asc`,`desc`]}).option(`parameters-order-by-value`,{type:`string`,description:`Configure which Calculation to order the results by.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Specify the new contents of the query.`})}const O={command:`edit <queryId>`,describe:`Update saved query.`,builder:D,handler:async n=>{if(n.dryRun){l({command:`cf observability queries edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/queries/${n[`query-id`]==null?`<query-id>`:encodeURIComponent(String(n[`query-id`]))}`,pathParams:{"query-id":String(n[`query-id`]??``)},bodyKind:`json`,body:n.body===void 0?s({description:d(n.description,`description`,`text`),name:d(n.name,`name`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}}}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Updating`,async()=>i.observability.queries.edit({...e,account_id:p,queryId:n[`query-id`]})),{successLabel:`Updated`});return}n.description===void 0&&(n.description=await e(`description`,`The description field`)),n.name===void 0&&(n.name=await e(`name`,`Query name`)),n[`parameters-order-by-value`]===void 0&&(n[`parameters-order-by-value`]=await e(`parameters-order-by-value`,`Configure which Calculation to order the results by.`));let m=s({description:d(n.description,`description`,`text`),name:d(n.name,`name`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}}});c(await u(`Updating`,async()=>i.observability.queries.edit({...m,account_id:p,queryId:n[`query-id`]})),{successLabel:`Updated`})}};function k(e){return e.positional(`query-id`,{type:`string`,description:`QueryId`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`get <queryId>`,describe:`Retrieve a saved query.`,builder:k,handler:async e=>{if(e.dryRun){l({command:`cf observability queries get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/queries/${e[`query-id`]==null?`<query-id>`:encodeURIComponent(String(e[`query-id`]))}`,pathParams:{"query-id":String(e[`query-id`]??``)},bodyKind:`none`});return}let n=await a(e),i=e.local?f:await r(n);e.accountId=i,c(await u(`Loading`,async()=>n.observability.queries.get({account_id:i,queryId:e[`query-id`]})),{successLabel:`Loaded`})}};function j(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`PerPage`}).option(`order`,{type:`string`,description:`Order`,choices:[`asc`,`desc`]}).option(`order-by`,{type:`string`,description:`OrderBy`,choices:[`created`,`updated`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`list`,describe:`List saved queries.`,builder:p(j),handler:async e=>{let n={page:e.page,perPage:e[`per-page`],order:e.order,orderBy:e[`order-by`]};if(e.dryRun){l({command:`cf observability queries list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/queries`,pathParams:{},query:n,bodyKind:`none`});return}let i=await a(e),o=e.local?f:await r(i);e.accountId=o,c(await u(`Loading`,async()=>i.observability.queries.list({account_id:o,...n})),{successLabel:`Loaded`})}},N={command:`queries`,describe:`Operations for queries`,builder:e=>e.command(w).command(E).command(O).command(A).command(M).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function P(e){return e.option(`datasets`,{type:`string`,array:!0,description:`Leave this empty to use the default datasets`}).option(`from`,{type:`number`,description:`The from field`}).option(`key-needle-is-regex`,{type:`boolean`,description:`When true, treats the value as a regular expression (RE2 syntax).`}).option(`key-needle-match-case`,{type:`boolean`,description:`When true, performs a case-sensitive search. Defaults to case-insensitive.`}).option(`limit`,{type:`number`,description:`Advanced usage: set limit=1000+ to retrieve comprehensive key options without needing additional filtering.`}).option(`needle-is-regex`,{type:`boolean`,description:`When true, treats the value as a regular expression (RE2 syntax).`}).option(`needle-match-case`,{type:`boolean`,description:`When true, performs a case-sensitive search. Defaults to case-insensitive.`}).option(`to`,{type:`number`,description:`The to field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Find keys in your telemetry events matching a specific filter or needle.`})}const F={command:`keys`,describe:`List all the keys in your telemetry events.`,builder:P,handler:async e=>{if(e.dryRun){l({command:`cf observability telemetry keys`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/telemetry/keys`,pathParams:{},bodyKind:`json`,body:e.body===void 0?s({datasets:e.datasets,from:e.from,keyNeedle:{isRegex:e[`key-needle-is-regex`],matchCase:e[`key-needle-match-case`]},limit:e.limit,needle:{isRegex:e[`needle-is-regex`],matchCase:e[`needle-match-case`]},to:e.to}):o(e.body)});return}let n=await a(e),i=e.local?f:await r(n);if(e.accountId=i,e.body){let t=o(e.body);c(await u(`Creating`,async()=>n.observability.telemetry.keys({...t,account_id:i})),{successLabel:`Created`});return}let d=s({datasets:e.datasets,from:e.from,keyNeedle:{isRegex:e[`key-needle-is-regex`],matchCase:e[`key-needle-match-case`]},limit:e.limit,needle:{isRegex:e[`needle-is-regex`],matchCase:e[`needle-match-case`]},to:e.to});c(await u(`Creating`,async()=>n.observability.telemetry.keys({...d,account_id:i})),{successLabel:`Created`})}};function I(e){return e.option(`chart`,{type:`boolean`,description:`When true, includes time-series data in the response.`}).option(`compare`,{type:`boolean`,description:`When true, includes a comparison dataset from the previous time period of equal length.`}).option(`dry`,{type:`boolean`,description:`When true, executes the query without persisting the results. Useful for validation or previewing.`,default:!1}).option(`granularity`,{type:`number`,description:`Number of time-series buckets. Only used when view is 'calculations'. Omit to let the system auto-detect an appropriate granularity.`}).option(`ignore-series`,{type:`boolean`,description:`When true, omits time-series data from the response and returns only aggregated values. Reduces response size when series are not needed.`,default:!1}).option(`limit`,{type:`number`,description:`Maximum number of events to return when view is 'events'. Also controls the number of group-by rows when view is 'calculations'.`,default:50}).option(`offset`,{type:`string`,description:`Cursor for pagination in event, trace, and invocation views. Pass the $metadata.id of the last returned item to fetch the next page.`}).option(`offset-by`,{type:`number`,description:`Numeric offset for paginating grouped/pattern results (top-N lists). Use together with limit. Not used by cursor-based pagination.`}).option(`offset-direction`,{type:`string`,description:`Pagination direction: 'next' for forward, 'prev' for backward.`}).option(`parameters-datasets`,{type:`string`,array:!0,description:`Datasets to query. Leave empty to query all available datasets.`}).option(`parameters-filter-combination`,{type:`string`,description:`Logical operator for combining top-level filters: 'and' (all must match) or 'or' (any must match). Defaults to 'and'.`,choices:[`and`,`or`,`AND`,`OR`]}).option(`parameters-limit`,{type:`number`,description:`Maximum number of group-by rows to return in calculation results. A value of 10 is a sensible default for most use cases.`}).option(`parameters-needle-is-regex`,{type:`boolean`,description:`When true, treats the value as a regular expression (RE2 syntax).`}).option(`parameters-needle-match-case`,{type:`boolean`,description:`When true, performs a case-sensitive search. Defaults to case-insensitive.`}).option(`parameters-order-by-order`,{type:`string`,description:`Sort direction: 'asc' for ascending, 'desc' for descending.`,choices:[`asc`,`desc`]}).option(`parameters-order-by-value`,{type:`string`,description:`Alias of the calculation to order results by. Must match the alias (or operator) of a calculation in the query.`}).option(`query-id`,{type:`string`,description:`Identifier for the query. When parameters are omitted, this ID is used to load a previously saved query's parameters. When providing parameters inline, pass any identifier (e.g. an ad-hoc ID).`}).option(`timeframe-from`,{type:`number`,description:`Start timestamp for the query timeframe (Unix timestamp in milliseconds)`}).option(`timeframe-to`,{type:`number`,description:`End timestamp for the query timeframe (Unix timestamp in milliseconds)`}).option(`view`,{type:`string`,description:`Controls the shape of the response. 'events': individual log lines matching the query. 'calculations': aggregated metrics (count, avg, p99, etc.) with optional group-by breakdowns and time-series. 'invocations': events grouped by request ID. 'traces': distributed trace summaries. 'agents': Durable Object agent summaries.`,choices:[`traces`,`events`,`calculations`,`invocations`,`requests`,`agents`],default:`calculations`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Query your observability events, requests, and traces to build visualizations and identify insights.`}).check(e=>{if([`parameters-datasets`,`parameters-filter-combination`,`parameters-limit`,`parameters-needle-is-regex`,`parameters-needle-match-case`,`parameters-order-by-order`,`parameters-order-by-value`].some(t=>e[t]!==void 0)){let t=[`parameters-order-by-value`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --parameters-* flag is set`)}return!0})}const L={command:`query`,describe:`Run a temporary or saved query.`,builder:I,handler:async n=>{if(n.dryRun){l({command:`cf observability telemetry query`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/telemetry/query`,pathParams:{},bodyKind:`json`,body:n.body===void 0?s({chart:n.chart,compare:n.compare,dry:n.dry,granularity:n.granularity,ignoreSeries:n[`ignore-series`],limit:n.limit,offset:d(n.offset,`offset`,`text`),offsetBy:n[`offset-by`],offsetDirection:d(n[`offset-direction`],`offset-direction`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}},queryId:d(n[`query-id`],`query-id`,`text`),timeframe:{from:n[`timeframe-from`],to:n[`timeframe-to`]},view:d(n.view,`view`,`text`)}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Loading`,async()=>i.observability.telemetry.query({...e,account_id:p})),{successLabel:`Loaded`});return}if(n[`query-id`]===void 0&&(n[`query-id`]=await e(`query-id`,`Identifier for the query. When parameters are omitted, this ID is used to load a previously saved query's parameters. When providing parameters inline, pass any identifier (e.g. an ad-hoc ID).`)),n[`timeframe-from`]===void 0)throw Error(`--timeframe-from is required (or pass --body with this field set).`);if(n[`timeframe-to`]===void 0)throw Error(`--timeframe-to is required (or pass --body with this field set).`);let m=s({chart:n.chart,compare:n.compare,dry:n.dry,granularity:n.granularity,ignoreSeries:n[`ignore-series`],limit:n.limit,offset:d(n.offset,`offset`,`text`),offsetBy:n[`offset-by`],offsetDirection:d(n[`offset-direction`],`offset-direction`,`text`),parameters:{datasets:n[`parameters-datasets`],filterCombination:d(n[`parameters-filter-combination`],`parameters-filter-combination`,`text`),limit:n[`parameters-limit`],needle:{isRegex:n[`parameters-needle-is-regex`],matchCase:n[`parameters-needle-match-case`]},orderBy:{order:d(n[`parameters-order-by-order`],`parameters-order-by-order`,`text`),value:d(n[`parameters-order-by-value`],`parameters-order-by-value`,`text`)}},queryId:d(n[`query-id`],`query-id`,`text`),timeframe:{from:n[`timeframe-from`],to:n[`timeframe-to`]},view:d(n.view,`view`,`text`)});c(await u(`Loading`,async()=>i.observability.telemetry.query({...m,account_id:p})),{successLabel:`Loaded`})}};function R(e){return e.option(`datasets`,{type:`string`,array:!0,description:`Leave this empty to use the default datasets`}).option(`key`,{type:`string`,description:`The key field`}).option(`limit`,{type:`number`,description:`The limit field`,default:50}).option(`needle-is-regex`,{type:`boolean`,description:`When true, treats the value as a regular expression (RE2 syntax).`}).option(`needle-match-case`,{type:`boolean`,description:`When true, performs a case-sensitive search. Defaults to case-insensitive.`}).option(`timeframe-from`,{type:`number`,description:`The timeframe.from field`}).option(`timeframe-to`,{type:`number`,description:`The timeframe.to field`}).option(`type`,{type:`string`,description:`The type field`,choices:[`string`,`boolean`,`number`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Retrieve values from your telemetry events.`})}const z={command:`values`,describe:`List unique values found in your events.`,builder:R,handler:async i=>{if(i.dryRun){l({command:`cf observability telemetry values`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/observability/telemetry/values`,pathParams:{},bodyKind:`json`,body:i.body===void 0?s({datasets:i.datasets,key:d(i.key,`key`,`text`),limit:i.limit,needle:{isRegex:i[`needle-is-regex`],matchCase:i[`needle-match-case`]},timeframe:{from:i[`timeframe-from`],to:i[`timeframe-to`]},type:d(i.type,`type`,`text`)}):o(i.body)});return}let p=await a(i),m=i.local?f:await r(p);if(i.accountId=m,i.body){let e=o(i.body);c(await u(`Creating`,async()=>p.observability.telemetry.values({...e,account_id:m})),{successLabel:`Created`});return}if(i.datasets===void 0)throw Error(`--datasets is required (or pass --body with this field set).`);if(i.key===void 0&&(i.key=await e(`key`,`The key field`)),i[`timeframe-from`]===void 0)throw Error(`--timeframe-from is required (or pass --body with this field set).`);if(i[`timeframe-to`]===void 0)throw Error(`--timeframe-to is required (or pass --body with this field set).`);i.type===void 0&&(i.type=await n(`type`,`The type field`,[`string`,`boolean`,`number`]));let h=s({datasets:i.datasets,key:d(i.key,`key`,`text`),limit:i.limit,needle:{isRegex:i[`needle-is-regex`],matchCase:i[`needle-match-case`]},timeframe:{from:i[`timeframe-from`],to:i[`timeframe-to`]},type:d(i.type,`type`,`text`)});c(await u(`Creating`,async()=>p.observability.telemetry.values({...h,account_id:m})),{successLabel:`Created`})}},B={command:`telemetry`,describe:`Operations for telemetry`,builder:e=>e.command(F).command(L).command(z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},V={command:`observability`,describe:`observability`,builder:e=>e.command(S).command(N).command(B).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{V as default};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import{n as e}from"./chunk-6IEM75FG-BEjRFMGh.mjs";import t from"node:fs";import n from"node:os";import r from"node:path";import i,{execFile as a}from"node:child_process";import{promisify as o}from"node:util";import{Buffer as s}from"node:buffer";import{fileURLToPath as c}from"node:url";import l,{constants as u}from"node:fs/promises";import d from"node:process";var f;function p(){try{return t.statSync(`/.dockerenv`),!0}catch{return!1}}e(p,`hasDockerEnv`);function m(){try{return t.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}}e(m,`hasDockerCGroup`);function h(){return f===void 0&&(f=p()||m()),f}e(h,`isDocker`);var g,_=e(()=>{try{return t.statSync(`/run/.containerenv`),!0}catch{return!1}},`hasContainerEnv`);function v(){return g===void 0&&(g=_()||h()),g}e(v,`isInsideContainer`);var y=e(()=>{if(d.platform!==`linux`)return!1;if(n.release().toLowerCase().includes(`microsoft`))return!v();try{return t.readFileSync(`/proc/version`,`utf8`).toLowerCase().includes(`microsoft`)?!v():!1}catch{return!1}},`isWsl`),b=d.env.__IS_WSL_TEST__?y:y(),ee=o(i.execFile),x=e(()=>`${d.env.SYSTEMROOT||d.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`,`powerShellPath`),S=e(async(e,t={})=>{let{powerShellPath:n,...r}=t,i=S.encodeCommand(e);return ee(n??x(),[...S.argumentsPrefix,i],{encoding:`utf8`,...r})},`executePowerShell`);S.argumentsPrefix=[`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`],S.encodeCommand=e=>s.from(e,`utf16le`).toString(`base64`),S.escapeArgument=e=>`'${String(e).replaceAll(`'`,`''`)}'`;function C(e){for(let t of e.split(`
3
+ `)){if(/^\s*#/.test(t))continue;let e=/^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(t);if(e)return e.groups.mountPoint.trim().replaceAll(/^["']|["']$/g,``)}}e(C,`parseMountPointFromConfig`);var te=o(i.execFile),ne=(()=>{let e=`/mnt/`,t;return async function(){if(t)return t;let n=`/etc/wsl.conf`,r=!1;try{await l.access(n,u.F_OK),r=!0}catch{}if(!r)return e;let i=C(await l.readFile(n,{encoding:`utf8`}));return i===void 0?e:(t=i,t=t.endsWith(`/`)?t:`${t}/`,t)}})(),w=b?e(async()=>`${await ne()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,`powerShellPathFromWsl`):x,T,E=e(async()=>(T??=(async()=>{try{let e=await w();return await l.access(e,u.X_OK),!0}catch{return!1}})(),T),`canAccessPowerShell`),D=e(async()=>{let e=await w(),{stdout:t}=await S(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,{powerShellPath:e});return t.trim()},`wslDefaultBrowser`),O=e(async e=>{if(/^[a-z]+:\/\//i.test(e))return e;try{let{stdout:t}=await te(`wslpath`,[`-aw`,e],{encoding:`utf8`});return t.trim()}catch{return e}},`convertWslPathToWindows`);function k(t,n,r){let i=e(e=>Object.defineProperty(t,n,{value:e,enumerable:!0,writable:!0}),`define`);return Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){let e=r();return i(e),e},set(e){i(e)}}),t}e(k,`defineLazyProperty`);var A=o(a);async function j(){if(d.platform!==`darwin`)throw Error(`macOS only`);let{stdout:e}=await A(`defaults`,[`read`,`com.apple.LaunchServices/com.apple.launchservices.secure`,`LSHandlers`]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??`com.apple.Safari`;return t===`com.apple.safari`?`com.apple.Safari`:t}e(j,`defaultBrowserId`);var M=o(a);async function N(e,{humanReadableOutput:t=!0,signal:n}={}){if(d.platform!==`darwin`)throw Error(`macOS only`);let r=t?[]:[`-ss`],i={};n&&(i.signal=n);let{stdout:a}=await M(`osascript`,[`-e`,e,r],i);return a.trim()}e(N,`runAppleScript`);async function P(e){return N(`tell application "Finder" to set app_path to application file id "${e}" as string
4
+ tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}e(P,`bundleName`);var F=o(a),I={MSEdgeHTM:{name:`Edge`,id:`com.microsoft.edge`},MSEdgeBHTML:{name:`Edge Beta`,id:`com.microsoft.edge.beta`},MSEdgeDHTML:{name:`Edge Dev`,id:`com.microsoft.edge.dev`},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:`Edge`,id:`com.microsoft.edge.old`},ChromeHTML:{name:`Chrome`,id:`com.google.chrome`},ChromeBHTML:{name:`Chrome Beta`,id:`com.google.chrome.beta`},ChromeDHTML:{name:`Chrome Dev`,id:`com.google.chrome.dev`},ChromiumHTM:{name:`Chromium`,id:`org.chromium.Chromium`},BraveHTML:{name:`Brave`,id:`com.brave.Browser`},BraveBHTML:{name:`Brave Beta`,id:`com.brave.Browser.beta`},BraveDHTML:{name:`Brave Dev`,id:`com.brave.Browser.dev`},BraveSSHTM:{name:`Brave Nightly`,id:`com.brave.Browser.nightly`},FirefoxURL:{name:`Firefox`,id:`org.mozilla.firefox`},OperaStable:{name:`Opera`,id:`com.operasoftware.Opera`},VivaldiHTM:{name:`Vivaldi`,id:`com.vivaldi.Vivaldi`},"IE.HTTP":{name:`Internet Explorer`,id:`com.microsoft.ie`}},L=new Map(Object.entries(I)),R=class extends Error{static{e(this,`UnknownBrowserError`)}};async function z(e=F){let{stdout:t}=await e(`reg`,[`QUERY`,` HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice`,`/v`,`ProgId`]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!n)throw new R(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:r}=n.groups,i=I[r];if(!i)throw new R(`Unknown browser ID: ${r}`);return i}e(z,`defaultBrowser`);var B=o(a),V=e(e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase()),`titleize`);async function H(){if(d.platform===`darwin`){let e=await j();return{name:await P(e),id:e}}if(d.platform===`linux`){let{stdout:e}=await B(`xdg-mime`,[`query`,`default`,`x-scheme-handler/http`]),t=e.trim();return{name:V(t.replace(/.desktop$/,``).replace(`-`,` `)),id:t}}if(d.platform===`win32`)return z();throw Error(`Only macOS, Linux, and Windows are supported`)}e(H,`defaultBrowser`);var U=!!(d.env.SSH_CONNECTION||d.env.SSH_CLIENT||d.env.SSH_TTY),W=Symbol(`fallbackAttempt`),G=import.meta.url?r.dirname(c(import.meta.url)):``,K=r.join(G,`xdg-open`),{platform:q,arch:J}=d,Y=e(async(e,t)=>{if(e.length===0)return;let n=[];for(let r of e)try{return await t(r)}catch(e){n.push(e)}throw AggregateError(n,`Failed to open in all supported apps`)},`tryEachApp`),X=e(async e=>{e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e};let t=e[W]===!0;if(delete e[W],Array.isArray(e.app))return Y(e.app,t=>X({...e,app:t,[W]:!0}));let{name:n,arguments:r=[]}=e.app??{};if(r=[...r],Array.isArray(n))return Y(n,t=>X({...e,app:{name:t,arguments:r},[W]:!0}));if(n===`browser`||n===`browserPrivate`){let t={"com.google.chrome":`chrome`,"google-chrome.desktop":`chrome`,"com.brave.browser":`brave`,"org.mozilla.firefox":`firefox`,"firefox.desktop":`firefox`,"com.microsoft.msedge":`edge`,"com.microsoft.edge":`edge`,"com.microsoft.edgemac":`edge`,"microsoft-edge.desktop":`edge`,"com.apple.safari":`safari`},i={chrome:`--incognito`,brave:`--incognito`,firefox:`--private-window`,edge:`--inPrivate`},a;if(b){let e=await D();a=L.get(e)??{}}else a=await H();if(a.id in t){let o=t[a.id.toLowerCase()];if(n===`browserPrivate`){if(o===`safari`)throw Error(`Safari doesn't support opening in private mode via command line`);r.push(i[o])}return X({...e,app:{name:$[o],arguments:r}})}throw Error(`${a.name} is not supported as a default browser`)}let a,o=[],s={},c=!1;if(b&&!v()&&!U&&!n&&(c=await E()),q===`darwin`)a=`open`,e.wait&&o.push(`--wait-apps`),e.background&&o.push(`--background`),e.newInstance&&o.push(`--new`),n&&o.push(`-a`,n);else if(q===`win32`||c){a=await w(),o.push(...S.argumentsPrefix),b||(s.windowsVerbatimArguments=!0),b&&e.target&&(e.target=await O(e.target));let t=[`$ProgressPreference = 'SilentlyContinue';`,`Start`];e.wait&&t.push(`-Wait`),n?(t.push(S.escapeArgument(n)),e.target&&r.push(e.target)):e.target&&t.push(S.escapeArgument(e.target)),r.length>0&&(r=r.map(e=>S.escapeArgument(e)),t.push(`-ArgumentList`,r.join(`,`))),e.target=S.encodeCommand(t.join(` `)),e.wait||(s.stdio=`ignore`)}else{if(n)a=n;else{let e=!G||G===`/`,t=!1;try{await l.access(K,u.X_OK),t=!0}catch{}a=d.versions.electron??(q===`android`||e||!t)?`xdg-open`:K}r.length>0&&o.push(...r),e.wait||(s.stdio=`ignore`,s.detached=!0)}q===`darwin`&&r.length>0&&o.push(`--args`,...r),e.target&&o.push(e.target);let f=i.spawn(a,o,s);return e.wait?new Promise((t,n)=>{f.once(`error`,n),f.once(`close`,r=>{if(!e.allowNonzeroExitCode&&r!==0){n(Error(`Exited with code ${r}`));return}t(f)})}):t?new Promise((e,t)=>{f.once(`error`,t),f.once(`spawn`,()=>{f.once(`close`,n=>{if(f.off(`error`,t),n!==0){t(Error(`Exited with code ${n}`));return}f.unref(),e(f)})})}):(f.unref(),new Promise((e,t)=>{f.once(`error`,t),f.once(`spawn`,()=>{f.off(`error`,t),e(f)})}))},`baseOpen`),re=e((e,t)=>{if(typeof e!=`string`)throw TypeError("Expected a `target`");return X({...t,target:e})},`open`);function Z(e){if(typeof e==`string`||Array.isArray(e))return e;let{[J]:t}=e;if(!t)throw Error(`${J} is not supported`);return t}e(Z,`detectArchBinary`);function Q({[q]:e},{wsl:t}={}){if(t&&b)return Z(t);if(!e)throw Error(`${q} is not supported`);return Z(e)}e(Q,`detectPlatformBinary`);var $={browser:`browser`,browserPrivate:`browserPrivate`};k($,`chrome`,()=>Q({darwin:`google chrome`,win32:`chrome`,linux:[`google-chrome`,`google-chrome-stable`,`chromium`,`chromium-browser`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`,x64:[`/mnt/c/Program Files/Google/Chrome/Application/chrome.exe`,`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`]}})),k($,`brave`,()=>Q({darwin:`brave browser`,win32:`brave`,linux:[`brave-browser`,`brave`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`,x64:[`/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe`,`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`]}})),k($,`firefox`,()=>Q({darwin:`firefox`,win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:`firefox`},{wsl:`/mnt/c/Program Files/Mozilla Firefox/firefox.exe`})),k($,`edge`,()=>Q({darwin:`microsoft edge`,win32:`msedge`,linux:[`microsoft-edge`,`microsoft-edge-dev`]},{wsl:`/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`})),k($,`safari`,()=>Q({darwin:`Safari`}));var ie=re;export{ie as default};