cf 0.1.0 → 0.2.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.
- package/dist/_meta/agent-context.json +88 -88
- package/dist/_meta/commands.json +5268 -5350
- package/dist/_meta/schemas.json +33572 -1148
- package/dist/abuse-reports-KtfZhi6j.mjs +8 -0
- package/dist/accounts-BopMfODC.mjs +21 -0
- package/dist/acm-BT4vlnEJ.mjs +3 -0
- package/dist/addressing-B3uFxHst.mjs +13 -0
- package/dist/ai-DWHqwMap.mjs +2 -0
- package/dist/ai-gateway-CbKEO-3o.mjs +8 -0
- package/dist/ai-search-VnOQ5n--.mjs +7 -0
- package/dist/alerting-BmmgIlIO.mjs +6 -0
- package/dist/analytics-isY03taL.mjs +20 -0
- package/dist/api-gateway-DXurEbA-.mjs +33 -0
- package/dist/argo-B02BL_hp.mjs +2 -0
- package/dist/audit-logs-DcgR9xUc.mjs +2 -0
- package/dist/auth-CQcAgnOy.mjs +135 -0
- package/dist/{auth-DQ8miey6.mjs → auth-DenWm_X0.mjs} +3 -3
- package/dist/autorag-CmrwnGVj.mjs +2 -0
- package/dist/{billing-lwBHNTXC.mjs → billing-CaW1ZAB1.mjs} +1 -1
- package/dist/bot-management-CeBsFx68.mjs +5 -0
- package/dist/botnet-feed-B396vQeQ.mjs +3 -0
- package/dist/brand-protection-D4V1v5Kl.mjs +3 -0
- package/dist/browser-rendering-GF7rNtKI.mjs +4 -0
- package/dist/build-5jmmOZhm.mjs +1054 -0
- package/dist/cache-DmXizSMi.mjs +5 -0
- package/dist/calls-x4KQpTB4.mjs +4 -0
- package/dist/certificate-authorities-hC0SG-Ga.mjs +2 -0
- package/dist/client-certificates-BGVsDyeJ.mjs +3 -0
- package/dist/cloud-connector-BClQpEzI.mjs +2 -0
- package/dist/cloudforce-one-BfhFrO6M.mjs +21 -0
- package/dist/{config-BIfdEY0E.mjs → config-DYzlVxcB.mjs} +1 -1
- package/dist/connectivity-G0NP6LtW.mjs +3 -0
- package/dist/content-scanning-DEtPJ7aF.mjs +4 -0
- package/dist/context-CC0Rhkhy.mjs +2 -0
- package/dist/custom-certificates-rJXFpUWu.mjs +5 -0
- package/dist/custom-hostnames-Be5mgLeF.mjs +5 -0
- package/dist/custom-nameservers-CoFdy6hD.mjs +3 -0
- package/dist/custom-pages-D-oErw57.mjs +4 -0
- package/dist/d1-C95ckPKI.mjs +3 -0
- package/dist/dcv-delegation-CWSkbGuc.mjs +2 -0
- package/dist/delegate.mjs +1 -1
- package/dist/deploy-DbkiIzUr.mjs +2 -0
- package/dist/{dev-BfKYB-R_.mjs → dev-C6iSuQZm.mjs} +1 -1
- package/dist/diagnostics-DEEhPnXj.mjs +3 -0
- package/dist/dispatch-namespaces-BzXeV7PH.mjs +7 -0
- package/dist/{dist-C_bu5HwZ.mjs → dist-CnSubA1Z.mjs} +1 -1
- package/dist/dist-DNBSHor6.mjs +301 -0
- package/dist/dns-firewall-BQXD_NxG.mjs +57 -0
- package/dist/dns-qW-3TZOT.mjs +29 -0
- package/dist/durable-objects-CgWFYEJJ.mjs +2 -0
- package/dist/email-routing-tdNJaCpJ.mjs +10 -0
- package/dist/email-security-DTVHNr2h.mjs +60 -0
- package/dist/email-sending-DsFTvE31.mjs +3 -0
- package/dist/filters-DO1Is_tI.mjs +4 -0
- package/dist/firewall-DbUhVTCg.mjs +11 -0
- package/dist/fraud-Bzr4njYb.mjs +8 -0
- package/dist/google-tag-gateway-BQxkA90M.mjs +2 -0
- package/dist/healthchecks-BBAs-lS_.mjs +4 -0
- package/dist/hostnames-Dz9PEUKS.mjs +3 -0
- package/dist/hyperdrive-B1iUJddG.mjs +18 -0
- package/dist/iam-CJM8gHpG.mjs +6 -0
- package/dist/images-DEoBmtFS.mjs +5 -0
- package/dist/index.mjs +1 -1
- package/dist/intel-BM6xkZ0C.mjs +3 -0
- package/dist/{ips-B0cK7D0_.mjs → ips-B8fwxKZD.mjs} +1 -1
- package/dist/keyless-certificates-DffYnd4b.mjs +3 -0
- package/dist/kv-BTceLtWZ.mjs +5 -0
- package/dist/leaked-credential-checks-CALfvoCo.mjs +3 -0
- package/dist/load-balancers-C1Ho1gCF.mjs +6 -0
- package/dist/logpush-CSYhgevA.mjs +4 -0
- package/dist/logs-DlIwmMpt.mjs +3 -0
- package/dist/magic-cloud-networking-Czu0pZ0a.mjs +5 -0
- package/dist/magic-network-monitoring-d7GJE5Yt.mjs +4 -0
- package/dist/magic-transit-qQmA-981.mjs +89 -0
- package/dist/managed-transforms-Dd6AnbWE.mjs +3 -0
- package/dist/mtls-certificates-C0rlCRGs.mjs +3 -0
- package/dist/network-interconnects-CxG2deY0.mjs +36 -0
- package/dist/organizations-DyEAiGiR.mjs +41 -0
- package/dist/origin-ca-certificates-S8RcoMF6.mjs +3 -0
- package/dist/origin-post-quantum-encryption-B8ZcpLu5.mjs +2 -0
- package/dist/origin-tls-client-auth-BlxMmQrE.mjs +5 -0
- package/dist/page-rules-DP-w6TAm.mjs +18 -0
- package/dist/page-shield-Bf7kFp8c.mjs +37 -0
- package/dist/pages-D0Y_XRqW.mjs +10 -0
- package/dist/pipelines-C-SPESAk.mjs +6 -0
- package/dist/{progress-DZfTxbrx.mjs → progress-CjcQ6ato.mjs} +1 -1
- package/dist/queues-wv6CZsi8.mjs +6 -0
- package/dist/r2-DuXjp9n5.mjs +21 -0
- package/dist/r2-data-catalog-DQCMrmNO.mjs +14 -0
- package/dist/radar-BW_ZHP8X.mjs +2 -0
- package/dist/rate-limits-DLTkIvwr.mjs +5 -0
- package/dist/raw-fetch-hRv-6P3D.mjs +2 -0
- package/dist/realtime-kit-Ch7Vg3vj.mjs +6 -0
- package/dist/{registrar-7Qy50zbW.mjs → registrar-DIIv6fWd.mjs} +6 -6
- package/dist/request-tracers-DMej0Drs.mjs +2 -0
- package/dist/resource-sharing-CYJ7cMWq.mjs +5 -0
- package/dist/resource-tagging-Dnz65MgH.mjs +16 -0
- package/dist/rules-DLJpOYbC.mjs +4 -0
- package/dist/rulesets-D9nqEJT5.mjs +8 -0
- package/dist/rum-DBVmdPkp.mjs +4 -0
- package/dist/schema-validation-MCd3xdtX.mjs +4 -0
- package/dist/scim-DZA3VXog.mjs +3 -0
- package/dist/secrets-store-BrvcZSOM.mjs +21 -0
- package/dist/security-center-BU6f3Cm1.mjs +2 -0
- package/dist/security-txt-BPIbP3dG.mjs +3 -0
- package/dist/{session-mW-s8ghP.mjs → session-H7IV2BrM.mjs} +1 -1
- package/dist/shared-DEzmTsEC.mjs +2 -0
- package/dist/smart-shield-e8XFBkiF.mjs +3 -0
- package/dist/snippets-B4M3MMb8.mjs +4 -0
- package/dist/{spawn-D_cjG87Z.mjs → spawn-13QQ0IwO.mjs} +1 -1
- package/dist/spectrum-B0adfSRI.mjs +59 -0
- package/dist/speed-BVcUtkAz.mjs +4 -0
- package/dist/{src-C5qivNKH.mjs → src-B9cKsgsg.mjs} +8 -8
- package/dist/ssl-BAa91gsc.mjs +15 -0
- package/dist/stream-D53sxKb3.mjs +14 -0
- package/dist/tenants-bH5pt3dJ.mjs +2 -0
- package/dist/token-validation-M61Vx_Tw.mjs +4 -0
- package/dist/turnstile-wAU0Gc2Z.mjs +23 -0
- package/dist/{ui-mP_arYIg.mjs → ui-BXjU1dX1.mjs} +1 -1
- package/dist/url-normalization-DZrWDgB5.mjs +3 -0
- package/dist/url-scanner-Zo49edNp.mjs +2 -0
- package/dist/user-DbXlVReB.mjs +10 -0
- package/dist/vectorize-CUnTM0DT.mjs +4 -0
- package/dist/versions-DzyrlUAi.mjs +2 -0
- package/dist/waiting-rooms-BZW0X69-.mjs +11 -0
- package/dist/web3-DueyOQtx.mjs +4 -0
- package/dist/workers-builds-BM_aoeUR.mjs +7 -0
- package/dist/workers-nV_vBCfV.mjs +16 -0
- package/dist/workflows-CQITmo-s.mjs +4 -0
- package/dist/zaraz-DIbpF5Op.mjs +2 -0
- package/dist/zero-trust-CKp8j512.mjs +119 -0
- package/dist/zones-BZ5tZDbH.mjs +28 -0
- package/package.json +4 -4
- package/dist/abuse-reports-ChV_yD7f.mjs +0 -8
- package/dist/accounts-BCYecXFh.mjs +0 -21
- package/dist/acm-DD8zSds2.mjs +0 -3
- package/dist/addressing-D4Eqw5Bi.mjs +0 -13
- package/dist/ai-DfXMOMx_.mjs +0 -2
- package/dist/ai-gateway-DdRFthMo.mjs +0 -8
- package/dist/ai-search-C_68CDj1.mjs +0 -7
- package/dist/alerting-DbhqhVCp.mjs +0 -6
- package/dist/analytics-BSBBc7ep.mjs +0 -20
- package/dist/api-gateway-CZ4swbkQ.mjs +0 -33
- package/dist/argo-tms9ZwHO.mjs +0 -2
- package/dist/audit-logs-24qyW8cl.mjs +0 -2
- package/dist/auth-BlSmtIKd.mjs +0 -112
- package/dist/autorag-kgNt06GD.mjs +0 -2
- package/dist/bot-management-LKf7BqUr.mjs +0 -5
- package/dist/botnet-feed-nQ-gErTS.mjs +0 -3
- package/dist/brand-protection-DOKv9GRr.mjs +0 -3
- package/dist/browser-rendering-CBExtgGt.mjs +0 -4
- package/dist/build-C_48VvoK.mjs +0 -1056
- package/dist/cache-BBiiNZHP.mjs +0 -5
- package/dist/calls-DA5Xzwev.mjs +0 -4
- package/dist/certificate-authorities-sXyR_yGp.mjs +0 -2
- package/dist/client-certificates-tV0aCLQJ.mjs +0 -3
- package/dist/cloud-connector-DZfHcSso.mjs +0 -2
- package/dist/cloudforce-one-y1PgQmI9.mjs +0 -21
- package/dist/connectivity-8SOqaFDn.mjs +0 -3
- package/dist/content-scanning-B9y6K_G5.mjs +0 -4
- package/dist/context-DTIbtQn5.mjs +0 -2
- package/dist/custom-certificates-sWksR8Ys.mjs +0 -5
- package/dist/custom-hostnames-91QZkdqN.mjs +0 -5
- package/dist/custom-nameservers-DajZaZvE.mjs +0 -3
- package/dist/custom-pages-Cu7gmwzT.mjs +0 -4
- package/dist/d1-H_VRsVmF.mjs +0 -3
- package/dist/dcv-delegation-C-qhEYEZ.mjs +0 -2
- package/dist/deploy--9wYOkHg.mjs +0 -2
- package/dist/diagnostics-D2B2LPZZ.mjs +0 -3
- package/dist/dispatch-namespaces-CyrXBU_w.mjs +0 -7
- package/dist/dist-DvKjT2TT.mjs +0 -303
- package/dist/dns-Bn9Uz_Nj.mjs +0 -29
- package/dist/dns-firewall-BslP4p-j.mjs +0 -57
- package/dist/durable-objects-BN1ZnHhm.mjs +0 -2
- package/dist/email-routing-n2TnTaRR.mjs +0 -10
- package/dist/email-security-C9SEx0kh.mjs +0 -60
- package/dist/email-sending-DayZ7u3I.mjs +0 -3
- package/dist/filters-CI_XTgfQ.mjs +0 -4
- package/dist/firewall-CcaayGig.mjs +0 -11
- package/dist/fraud-Cr7aPCV8.mjs +0 -8
- package/dist/google-tag-gateway-B3GpYgQ4.mjs +0 -2
- package/dist/healthchecks-CVTsR_OC.mjs +0 -4
- package/dist/hostnames-Bd_Wa5l6.mjs +0 -3
- package/dist/hyperdrive-BBJhEDZd.mjs +0 -18
- package/dist/iam-D_FN0pDF.mjs +0 -6
- package/dist/images-CAP2hAlZ.mjs +0 -5
- package/dist/intel-CkxfzqmJ.mjs +0 -3
- package/dist/keyless-certificates-LcLmHZsX.mjs +0 -3
- package/dist/kv-_TkUQ6fs.mjs +0 -5
- package/dist/leaked-credential-checks-Dhvaen22.mjs +0 -3
- package/dist/load-balancers-Ckr0UIpk.mjs +0 -6
- package/dist/logpush-Cj946hxT.mjs +0 -4
- package/dist/logs-DgC9hjvJ.mjs +0 -3
- package/dist/magic-cloud-networking-WbDvPzuG.mjs +0 -5
- package/dist/magic-network-monitoring-BcHShvGQ.mjs +0 -4
- package/dist/magic-transit-B8sCOkt_.mjs +0 -89
- package/dist/managed-transforms-BpOr-8HY.mjs +0 -3
- package/dist/mtls-certificates-fOul8D5g.mjs +0 -3
- package/dist/network-interconnects-BSW65xlh.mjs +0 -36
- package/dist/organizations-T4vKGFAb.mjs +0 -41
- package/dist/origin-ca-certificates-ChM0lZ64.mjs +0 -3
- package/dist/origin-post-quantum-encryption-C7o26ARh.mjs +0 -2
- package/dist/origin-tls-client-auth-D32dpZk_.mjs +0 -5
- package/dist/page-rules-RFoj8CjN.mjs +0 -18
- package/dist/page-shield-VTktzKDN.mjs +0 -37
- package/dist/pages-L1ITjXDZ.mjs +0 -10
- package/dist/pipelines-BPO0Lnil.mjs +0 -6
- package/dist/queues-B0C06L9r.mjs +0 -6
- package/dist/r2-DP020Tmq.mjs +0 -21
- package/dist/r2-data-catalog-Dmipvz5F.mjs +0 -14
- package/dist/radar-DR3VMknH.mjs +0 -2
- package/dist/rate-limits-DnHPBPgU.mjs +0 -5
- package/dist/raw-fetch-DlXYwVA8.mjs +0 -2
- package/dist/realtime-kit-C430aq2d.mjs +0 -6
- package/dist/request-tracers-sv99NDIl.mjs +0 -2
- package/dist/resource-sharing-uEjC7lnQ.mjs +0 -5
- package/dist/resource-tagging-CiODdP3N.mjs +0 -16
- package/dist/rules-FXAyTrwk.mjs +0 -4
- package/dist/rulesets-B6aUsFFB.mjs +0 -8
- package/dist/rum-CyyGJhp5.mjs +0 -4
- package/dist/schema-validation-ByU49h--.mjs +0 -4
- package/dist/scim-DdTS65_C.mjs +0 -3
- package/dist/secrets-store-ClOUVhBJ.mjs +0 -18
- package/dist/security-center-4iSBqTrf.mjs +0 -2
- package/dist/security-txt-kGxdkDY6.mjs +0 -3
- package/dist/smart-shield-B-SQd2Qp.mjs +0 -3
- package/dist/snippets-Aq58ojqw.mjs +0 -4
- package/dist/spectrum-0gFvGI6y.mjs +0 -59
- package/dist/speed-DAZU8w3T.mjs +0 -4
- package/dist/ssl-BRlXa-5w.mjs +0 -15
- package/dist/stream-BAxsVeBX.mjs +0 -14
- package/dist/tenants-Df6xDqoA.mjs +0 -2
- package/dist/token-validation-pO4dCjCy.mjs +0 -4
- package/dist/turnstile-B1dmO8wE.mjs +0 -23
- package/dist/url-normalization-sUDVmrUt.mjs +0 -3
- package/dist/url-scanner-CwOKRkYo.mjs +0 -2
- package/dist/user-D_UrIdNq.mjs +0 -10
- package/dist/vectorize-BEbBn9G9.mjs +0 -4
- package/dist/waiting-rooms-BQC-urV4.mjs +0 -11
- package/dist/web3-CIH2iQeX.mjs +0 -4
- package/dist/workers-B9EvrpH3.mjs +0 -16
- package/dist/workers-builds-DzWSiRd2.mjs +0 -7
- package/dist/workflows-aD81gA4k.mjs +0 -4
- package/dist/zaraz-Cg1dsvrZ.mjs +0 -2
- package/dist/zero-trust-D-xQXWcy.mjs +0 -119
- package/dist/zones-DQzucJDd.mjs +0 -28
- /package/dist/{schema-D0_cbcDt.mjs → schema-CHBfkARI.mjs} +0 -0
- /package/dist/{tools-CtKbk6VS.mjs → tools-B7QiNu-d.mjs} +0 -0
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as e,f as t,m as n,p as r,t as i,u as a}from"./auth-BlSmtIKd.mjs";import{n as o,t as s}from"./body-parser-Br-BoYk-.mjs";import{t as c}from"./output-D7_yAFVR.mjs";import{n as l,t as u}from"./progress-DZfTxbrx.mjs";import{n as d}from"./input-validation-zEO81MWN.mjs";import{t as f}from"./local-VJaJ3BZ1.mjs";function p(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const m={command:`list`,describe:`Gets a list of all alert types for which an account is eligible.`,builder:p,handler:async t=>{if(t.dryRun){l({command:`cf alerting available-alerts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/available_alerts`,pathParams:{},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Loading`,async()=>n.alerting.availableAlerts.list(r)),{successLabel:`Loaded`})}},h={command:`available-alerts`,describe:`List the alert types available for your account based on enabled products`,builder:e=>e.command(m).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ee(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`get`,describe:`Get a list of all delivery mechanism types for which an account is eligible.`,builder:ee,handler:async t=>{if(t.dryRun){l({command:`cf alerting destinations eligible get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/destinations/eligible`,pathParams:{},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Loading`,async()=>n.alerting.destinations.eligible.get(r)),{successLabel:`Loaded`})}},_={command:`eligible`,describe:`Delivery mechanisms for alerts — email, PagerDuty integrations, and webhook endpoints`,builder:e=>e.command(g).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function v(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`create`,describe:`Creates a new token for integrating with PagerDuty.`,builder:v,handler:async t=>{if(t.dryRun){l({command:`cf alerting destinations pagerduty create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/destinations/pagerduty/connect`,pathParams:{},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Creating`,async()=>n.alerting.destinations.pagerduty.create(r)),{successLabel:`Created`})}};function b(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 x={command:`delete`,describe:`Deletes all the PagerDuty Services connected to the account.`,builder:b,handler:async n=>{if(n.dryRun){l({command:`cf alerting destinations pagerduty delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/destinations/pagerduty`,pathParams:{},bodyKind:`none`});return}let r=await i(n),o=n.local?f:await e(r);if(n.accountId=o,!await t({force:!!n.force})){process.stderr.write(`Aborted.
|
|
3
|
-
`);return}c(await u(`Deleting`,async()=>r.alerting.destinations.pagerduty.delete(o)),{successLabel:`Deleted`})}};function S(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const C={command:`get`,describe:`Get a list of all configured PagerDuty services.`,builder:S,handler:async t=>{if(t.dryRun){l({command:`cf alerting destinations pagerduty get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/destinations/pagerduty`,pathParams:{},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Loading`,async()=>n.alerting.destinations.pagerduty.get(r)),{successLabel:`Loaded`})}};function w(e){return e.positional(`tokenId`,{type:`string`,description:`The token integration key`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`link <tokenId>`,describe:`Links PagerDuty with the account using the integration token.`,builder:w,handler:async t=>{if(t.dryRun){l({command:`cf alerting destinations pagerduty link`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/destinations/pagerduty/connect/${t.tokenId??`<tokenId>`}`,pathParams:{tokenId:String(t.tokenId??``)},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Loading`,async()=>n.alerting.destinations.pagerduty.link(r,t.tokenId)),{successLabel:`Loaded`})}},E={command:`pagerduty`,describe:`Delivery mechanisms for alerts — email, PagerDuty integrations, and webhook endpoints`,builder:e=>e.command(y).command(x).command(C).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`name`,{type:`string`,description:`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`}).option(`secret`,{type:`string`,description:"Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body."}).option(`url`,{type:`string`,description:`The POST endpoint to call when dispatching a notification.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const O={command:`create`,describe:`Creates a new webhook destination.`,builder:D,handler:async t=>{if(t.dryRun){l({command:`cf alerting destinations webhooks create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/destinations/webhooks`,pathParams:{},bodyKind:`json`,body:{name:t.name,secret:t.secret,url:t.url,body:t.body}});return}let r=await i(t),p=t.local?f:await e(r);if(t.accountId=p,t.body){let e=s(t.body);c(await u(`Creating`,async()=>r.post(`/accounts/${p}/alerting/v3/destinations/webhooks`,{body:e})),{successLabel:`Created`});return}t.name===void 0&&(t.name=await n(`name`,`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`)),t.url===void 0&&(t.url=await n(`url`,`The POST endpoint to call when dispatching a notification.`));let m={};t.name!==void 0&&o(m,[`name`],d(t.name,`name`,`text`)),t.secret!==void 0&&o(m,[`secret`],d(t.secret,`secret`,`text`)),t.url!==void 0&&o(m,[`url`],d(t.url,`url`,`text`)),c(await u(`Creating`,async()=>r.post(`/accounts/${p}/alerting/v3/destinations/webhooks`,{body:Object.keys(m).length>0?m:void 0})),{successLabel:`Created`})}};function k(e){return e.positional(`webhookId`,{type:`string`,description:`The unique identifier of a webhook`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const A={command:`delete <webhookId>`,describe:`Delete a configured webhook destination.`,builder:k,handler:async n=>{if(n.dryRun){l({command:`cf alerting destinations webhooks delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/destinations/webhooks/${n.webhookId??`<webhookId>`}`,pathParams:{webhookId:String(n.webhookId??``)},bodyKind:`none`});return}let r=await i(n),o=n.local?f:await e(r);if(n.accountId=o,!await t({force:!!n.force})){process.stderr.write(`Aborted.
|
|
4
|
-
`);return}c(await u(`Deleting`,async()=>r.alerting.destinations.webhooks.delete(n.webhookId,o)),{successLabel:`Deleted`})}};function j(e){return e.positional(`webhookId`,{type:`string`,description:`The unique identifier of a webhook`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`get <webhookId>`,describe:`Get details for a single webhooks destination.`,builder:j,handler:async t=>{if(t.dryRun){l({command:`cf alerting destinations webhooks get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/destinations/webhooks/${t.webhookId??`<webhookId>`}`,pathParams:{webhookId:String(t.webhookId??``)},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Loading`,async()=>n.alerting.destinations.webhooks.get(r,t.webhookId)),{successLabel:`Loaded`})}};function N(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`list`,describe:`Gets a list of all configured webhook destinations.`,builder:N,handler:async t=>{if(t.dryRun){l({command:`cf alerting destinations webhooks list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/destinations/webhooks`,pathParams:{},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Loading`,async()=>n.alerting.destinations.webhooks.list(r)),{successLabel:`Loaded`})}};function F(e){return e.positional(`webhookId`,{type:`string`,description:`The unique identifier of a webhook`,demandOption:!0}).option(`name`,{type:`string`,description:`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`}).option(`secret`,{type:`string`,description:"Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body."}).option(`url`,{type:`string`,description:`The POST endpoint to call when dispatching a notification.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const I={command:`update <webhookId>`,describe:`Update a webhook destination.`,builder:F,handler:async t=>{if(t.dryRun){l({command:`cf alerting destinations webhooks update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/destinations/webhooks/${t.webhookId??`<webhookId>`}`,pathParams:{webhookId:String(t.webhookId??``)},bodyKind:`json`,body:{name:t.name,secret:t.secret,url:t.url,body:t.body}});return}let r=await i(t),p=t.local?f:await e(r);if(t.accountId=p,t.body){let e=s(t.body);c(await u(`Updating`,async()=>r.put(`/accounts/${p}/alerting/v3/destinations/webhooks/${t.webhookId}`,{body:e})),{successLabel:`Updated`});return}t.name===void 0&&(t.name=await n(`name`,`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`)),t.url===void 0&&(t.url=await n(`url`,`The POST endpoint to call when dispatching a notification.`));let m={};t.name!==void 0&&o(m,[`name`],d(t.name,`name`,`text`)),t.secret!==void 0&&o(m,[`secret`],d(t.secret,`secret`,`text`)),t.url!==void 0&&o(m,[`url`],d(t.url,`url`,`text`)),c(await u(`Updating`,async()=>r.put(`/accounts/${p}/alerting/v3/destinations/webhooks/${t.webhookId}`,{body:Object.keys(m).length>0?m:void 0})),{successLabel:`Updated`})}},L={command:`webhooks`,describe:`Delivery mechanisms for alerts — email, PagerDuty integrations, and webhook endpoints`,builder:e=>e.command(O).command(A).command(M).command(P).command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},R={command:`destinations`,describe:`Operations for destinations`,builder:e=>e.command(_).command(E).command(L).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function z(e){return e.option(`per-page`,{type:`string`,description:`Number of items per page.`}).option(`before`,{type:`string`,description:`Limit the returned results to history records older than the specified date. This must be a timestamp that conforms to RFC3339.`}).option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`since`,{type:`string`,description:`Limit the returned results to history records newer than the specified date. This must be a timestamp that conforms to RFC3339.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const te={command:`list`,describe:"Gets a list of history records for notifications sent to an account. The records are displayed for last `x` number of days based on the zone plan (free = 30, pro = 30, biz = 30, ent = 90).",builder:z,handler:async t=>{let n={per_page:t.perPage,before:t.before,page:t.page,since:t.since};if(t.dryRun){l({command:`cf alerting history list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/history`,pathParams:{},query:n,bodyKind:`none`});return}let r=await i(t),o=t.local?f:await e(r);t.accountId=o,c(await u(`Loading`,async()=>r.alerting.history.list(o,n)),{successLabel:`Loaded`})}},B={command:`history`,describe:`Browse previously sent alert notifications and their delivery status`,builder:e=>e.command(te).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function V(e){return e.option(`alert-interval`,{type:`string`,description:`Optional specification of how often to re-alert from the same incident, not support on all alert types.`}).option(`alert-type`,{type:`string`,description:`Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values.`,choices:`abuse_report_alert.access_custom_certificate_expiration_type.advanced_ddos_attack_l4_alert.advanced_ddos_attack_l7_alert.advanced_http_alert_error.bgp_hijack_notification.billing_usage_alert.block_notification_block_removed.block_notification_new_block.block_notification_review_rejected.bot_traffic_basic_alert.brand_protection_alert.brand_protection_digest.clickhouse_alert_fw_anomaly.clickhouse_alert_fw_ent_anomaly.cloudforce_one_request_notification.cni_maintenance_notification.custom_analytics.custom_bot_detection_alert.custom_ssl_certificate_event_type.dedicated_ssl_certificate_event_type.device_connectivity_anomaly_alert.dos_attack_l4.dos_attack_l7.expiring_service_token_alert.failing_logpush_job_disabled_alert.fbm_auto_advertisement.fbm_dosd_attack.fbm_volumetric_attack.health_check_status_notification.hostname_aop_custom_certificate_expiration_type.http_alert_edge_error.http_alert_origin_error.image_notification.image_resizing_notification.incident_alert.load_balancing_health_alert.load_balancing_pool_enablement_alert.logo_match_alert.magic_tunnel_health_check_event.magic_wan_tunnel_health.maintenance_event_notification.mtls_certificate_store_certificate_expiration_type.pages_event_alert.radar_notification.real_origin_monitoring.scriptmonitor_alert_new_code_change_detections.scriptmonitor_alert_new_hosts.scriptmonitor_alert_new_malicious_hosts.scriptmonitor_alert_new_malicious_scripts.scriptmonitor_alert_new_malicious_url.scriptmonitor_alert_new_max_length_resource_url.scriptmonitor_alert_new_resources.secondary_dns_all_primaries_failing.secondary_dns_primaries_failing.secondary_dns_warning.secondary_dns_zone_successfully_updated.secondary_dns_zone_validation_warning.security_insights_alert.sentinel_alert.stream_live_notifications.synthetic_test_latency_alert.synthetic_test_low_availability_alert.traffic_anomalies_alert.tunnel_health_event.tunnel_update_event.universal_ssl_event_type.web_analytics_metrics_update.zone_aop_custom_certificate_expiration_type`.split(`.`)}).option(`description`,{type:`string`,description:`Optional description for the Notification policy.`}).option(`enabled`,{type:`boolean`,description:`Whether or not the Notification policy is enabled.`,default:!0}).option(`filters-actions`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-affected-asns`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-affected-components`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-affected-locations`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-airport-code`,{type:`string`,array:!0,description:`Used for configuring maintenance_event_notification`}).option(`filters-alert-trigger-preferences`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-alert-trigger-preferences-value`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-enabled`,{type:`string`,array:!0,description:`Used for configuring load_balancing_pool_enablement_alert`}).option(`filters-environment`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event-source`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-event-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-group-by`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-health-check-id`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-incident-impact`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-input-id`,{type:`string`,array:!0,description:`Used for configuring stream_live_notifications`}).option(`filters-insight-class`,{type:`string`,array:!0,description:`Used for configuring security_insights_alert`}).option(`filters-limit`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-logo-tag`,{type:`string`,array:!0,description:`Used for configuring logo_match_alert`}).option(`filters-megabits-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-new-health`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-new-status`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-packets-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-pool-id`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-pop-names`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-product`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-project-id`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-protocol`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-query-tag`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-requests-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-selectors`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-services`,{type:`string`,array:!0,description:`Used for configuring clickhouse_alert_fw_ent_anomaly`}).option(`filters-slo`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-status`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-target-hostname`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-target-ip`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-target-zone-name`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-traffic-exclusions`,{type:`string`,array:!0,description:`Used for configuring traffic_anomalies_alert`}).option(`filters-tunnel-id`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-tunnel-name`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-where`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-zones`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`name`,{type:`string`,description:`Name of the policy.`}).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:`Creates a new Notification policy.`,builder:V,handler:async t=>{if(t.dryRun){l({command:`cf alerting policies create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/policies`,pathParams:{},bodyKind:`json`,body:{alertInterval:t.alertInterval,alertType:t.alertType,description:t.description,enabled:t.enabled,filtersActions:t.filtersActions,filtersAffectedAsns:t.filtersAffectedAsns,filtersAffectedComponents:t.filtersAffectedComponents,filtersAffectedLocations:t.filtersAffectedLocations,filtersAirportCode:t.filtersAirportCode,filtersAlertTriggerPreferences:t.filtersAlertTriggerPreferences,filtersAlertTriggerPreferencesValue:t.filtersAlertTriggerPreferencesValue,filtersEnabled:t.filtersEnabled,filtersEnvironment:t.filtersEnvironment,filtersEvent:t.filtersEvent,filtersEventSource:t.filtersEventSource,filtersEventType:t.filtersEventType,filtersGroupBy:t.filtersGroupBy,filtersHealthCheckId:t.filtersHealthCheckId,filtersIncidentImpact:t.filtersIncidentImpact,filtersInputId:t.filtersInputId,filtersInsightClass:t.filtersInsightClass,filtersLimit:t.filtersLimit,filtersLogoTag:t.filtersLogoTag,filtersMegabitsPerSecond:t.filtersMegabitsPerSecond,filtersNewHealth:t.filtersNewHealth,filtersNewStatus:t.filtersNewStatus,filtersPacketsPerSecond:t.filtersPacketsPerSecond,filtersPoolId:t.filtersPoolId,filtersPopNames:t.filtersPopNames,filtersProduct:t.filtersProduct,filtersProjectId:t.filtersProjectId,filtersProtocol:t.filtersProtocol,filtersQueryTag:t.filtersQueryTag,filtersRequestsPerSecond:t.filtersRequestsPerSecond,filtersSelectors:t.filtersSelectors,filtersServices:t.filtersServices,filtersSlo:t.filtersSlo,filtersStatus:t.filtersStatus,filtersTargetHostname:t.filtersTargetHostname,filtersTargetIp:t.filtersTargetIp,filtersTargetZoneName:t.filtersTargetZoneName,filtersTrafficExclusions:t.filtersTrafficExclusions,filtersTunnelId:t.filtersTunnelId,filtersTunnelName:t.filtersTunnelName,filtersType:t.filtersType,filtersWhere:t.filtersWhere,filtersZones:t.filtersZones,name:t.name,body:t.body}});return}let p=await i(t),m=t.local?f:await e(p);if(t.accountId=m,t.body){let e=s(t.body);c(await u(`Creating`,async()=>p.post(`/accounts/${m}/alerting/v3/policies`,{body:e})),{successLabel:`Created`});return}if(t.alertType===void 0&&(t.alertType=await r(`alert-type`,`Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values.`,`abuse_report_alert.access_custom_certificate_expiration_type.advanced_ddos_attack_l4_alert.advanced_ddos_attack_l7_alert.advanced_http_alert_error.bgp_hijack_notification.billing_usage_alert.block_notification_block_removed.block_notification_new_block.block_notification_review_rejected.bot_traffic_basic_alert.brand_protection_alert.brand_protection_digest.clickhouse_alert_fw_anomaly.clickhouse_alert_fw_ent_anomaly.cloudforce_one_request_notification.cni_maintenance_notification.custom_analytics.custom_bot_detection_alert.custom_ssl_certificate_event_type.dedicated_ssl_certificate_event_type.device_connectivity_anomaly_alert.dos_attack_l4.dos_attack_l7.expiring_service_token_alert.failing_logpush_job_disabled_alert.fbm_auto_advertisement.fbm_dosd_attack.fbm_volumetric_attack.health_check_status_notification.hostname_aop_custom_certificate_expiration_type.http_alert_edge_error.http_alert_origin_error.image_notification.image_resizing_notification.incident_alert.load_balancing_health_alert.load_balancing_pool_enablement_alert.logo_match_alert.magic_tunnel_health_check_event.magic_wan_tunnel_health.maintenance_event_notification.mtls_certificate_store_certificate_expiration_type.pages_event_alert.radar_notification.real_origin_monitoring.scriptmonitor_alert_new_code_change_detections.scriptmonitor_alert_new_hosts.scriptmonitor_alert_new_malicious_hosts.scriptmonitor_alert_new_malicious_scripts.scriptmonitor_alert_new_malicious_url.scriptmonitor_alert_new_max_length_resource_url.scriptmonitor_alert_new_resources.secondary_dns_all_primaries_failing.secondary_dns_primaries_failing.secondary_dns_warning.secondary_dns_zone_successfully_updated.secondary_dns_zone_validation_warning.security_insights_alert.sentinel_alert.stream_live_notifications.synthetic_test_latency_alert.synthetic_test_low_availability_alert.traffic_anomalies_alert.tunnel_health_event.tunnel_update_event.universal_ssl_event_type.web_analytics_metrics_update.zone_aop_custom_certificate_expiration_type`.split(`.`))),t.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);t.name===void 0&&(t.name=await n(`name`,`Name of the policy.`));let h={};t.alertInterval!==void 0&&o(h,[`alert_interval`],d(t.alertInterval,`alertInterval`,`text`)),t.alertType!==void 0&&o(h,[`alert_type`],d(t.alertType,`alertType`,`text`)),t.description!==void 0&&o(h,[`description`],d(t.description,`description`,`text`)),t.enabled!==void 0&&o(h,[`enabled`],t.enabled),t.filtersActions!==void 0&&o(h,[`filters`,`actions`],t.filtersActions),t.filtersAffectedAsns!==void 0&&o(h,[`filters`,`affected_asns`],t.filtersAffectedAsns),t.filtersAffectedComponents!==void 0&&o(h,[`filters`,`affected_components`],t.filtersAffectedComponents),t.filtersAffectedLocations!==void 0&&o(h,[`filters`,`affected_locations`],t.filtersAffectedLocations),t.filtersAirportCode!==void 0&&o(h,[`filters`,`airport_code`],t.filtersAirportCode),t.filtersAlertTriggerPreferences!==void 0&&o(h,[`filters`,`alert_trigger_preferences`],t.filtersAlertTriggerPreferences),t.filtersAlertTriggerPreferencesValue!==void 0&&o(h,[`filters`,`alert_trigger_preferences_value`],t.filtersAlertTriggerPreferencesValue),t.filtersEnabled!==void 0&&o(h,[`filters`,`enabled`],t.filtersEnabled),t.filtersEnvironment!==void 0&&o(h,[`filters`,`environment`],t.filtersEnvironment),t.filtersEvent!==void 0&&o(h,[`filters`,`event`],t.filtersEvent),t.filtersEventSource!==void 0&&o(h,[`filters`,`event_source`],t.filtersEventSource),t.filtersEventType!==void 0&&o(h,[`filters`,`event_type`],t.filtersEventType),t.filtersGroupBy!==void 0&&o(h,[`filters`,`group_by`],t.filtersGroupBy),t.filtersHealthCheckId!==void 0&&o(h,[`filters`,`health_check_id`],t.filtersHealthCheckId),t.filtersIncidentImpact!==void 0&&o(h,[`filters`,`incident_impact`],t.filtersIncidentImpact),t.filtersInputId!==void 0&&o(h,[`filters`,`input_id`],t.filtersInputId),t.filtersInsightClass!==void 0&&o(h,[`filters`,`insight_class`],t.filtersInsightClass),t.filtersLimit!==void 0&&o(h,[`filters`,`limit`],t.filtersLimit),t.filtersLogoTag!==void 0&&o(h,[`filters`,`logo_tag`],t.filtersLogoTag),t.filtersMegabitsPerSecond!==void 0&&o(h,[`filters`,`megabits_per_second`],t.filtersMegabitsPerSecond),t.filtersNewHealth!==void 0&&o(h,[`filters`,`new_health`],t.filtersNewHealth),t.filtersNewStatus!==void 0&&o(h,[`filters`,`new_status`],t.filtersNewStatus),t.filtersPacketsPerSecond!==void 0&&o(h,[`filters`,`packets_per_second`],t.filtersPacketsPerSecond),t.filtersPoolId!==void 0&&o(h,[`filters`,`pool_id`],t.filtersPoolId),t.filtersPopNames!==void 0&&o(h,[`filters`,`pop_names`],t.filtersPopNames),t.filtersProduct!==void 0&&o(h,[`filters`,`product`],t.filtersProduct),t.filtersProjectId!==void 0&&o(h,[`filters`,`project_id`],t.filtersProjectId),t.filtersProtocol!==void 0&&o(h,[`filters`,`protocol`],t.filtersProtocol),t.filtersQueryTag!==void 0&&o(h,[`filters`,`query_tag`],t.filtersQueryTag),t.filtersRequestsPerSecond!==void 0&&o(h,[`filters`,`requests_per_second`],t.filtersRequestsPerSecond),t.filtersSelectors!==void 0&&o(h,[`filters`,`selectors`],t.filtersSelectors),t.filtersServices!==void 0&&o(h,[`filters`,`services`],t.filtersServices),t.filtersSlo!==void 0&&o(h,[`filters`,`slo`],t.filtersSlo),t.filtersStatus!==void 0&&o(h,[`filters`,`status`],t.filtersStatus),t.filtersTargetHostname!==void 0&&o(h,[`filters`,`target_hostname`],t.filtersTargetHostname),t.filtersTargetIp!==void 0&&o(h,[`filters`,`target_ip`],t.filtersTargetIp),t.filtersTargetZoneName!==void 0&&o(h,[`filters`,`target_zone_name`],t.filtersTargetZoneName),t.filtersTrafficExclusions!==void 0&&o(h,[`filters`,`traffic_exclusions`],t.filtersTrafficExclusions),t.filtersTunnelId!==void 0&&o(h,[`filters`,`tunnel_id`],t.filtersTunnelId),t.filtersTunnelName!==void 0&&o(h,[`filters`,`tunnel_name`],t.filtersTunnelName),t.filtersType!==void 0&&o(h,[`filters`,`type`],t.filtersType),t.filtersWhere!==void 0&&o(h,[`filters`,`where`],t.filtersWhere),t.filtersZones!==void 0&&o(h,[`filters`,`zones`],t.filtersZones),t.name!==void 0&&o(h,[`name`],d(t.name,`name`,`text`)),c(await u(`Creating`,async()=>p.post(`/accounts/${m}/alerting/v3/policies`,{body:Object.keys(h).length>0?h:void 0})),{successLabel:`Created`})}};function U(e){return e.positional(`policyId`,{type:`string`,description:`The unique identifier of a notification policy`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const W={command:`delete <policyId>`,describe:`Delete a Notification policy.`,builder:U,handler:async n=>{if(n.dryRun){l({command:`cf alerting policies delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/policies/${n.policyId??`<policyId>`}`,pathParams:{policyId:String(n.policyId??``)},bodyKind:`none`});return}let r=await i(n),o=n.local?f:await e(r);if(n.accountId=o,!await t({force:!!n.force})){process.stderr.write(`Aborted.
|
|
5
|
-
`);return}c(await u(`Deleting`,async()=>r.alerting.policies.delete(o,n.policyId)),{successLabel:`Deleted`})}};function G(e){return e.positional(`policyId`,{type:`string`,description:`The unique identifier of a notification policy`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const K={command:`get <policyId>`,describe:`Get details for a single policy.`,builder:G,handler:async t=>{if(t.dryRun){l({command:`cf alerting policies get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/policies/${t.policyId??`<policyId>`}`,pathParams:{policyId:String(t.policyId??``)},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Loading`,async()=>n.alerting.policies.get(r,t.policyId)),{successLabel:`Loaded`})}};function q(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const J={command:`list`,describe:`Get a list of all Notification policies.`,builder:q,handler:async t=>{if(t.dryRun){l({command:`cf alerting policies list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/policies`,pathParams:{},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Loading`,async()=>n.alerting.policies.list(r)),{successLabel:`Loaded`})}};function Y(e){return e.positional(`policyId`,{type:`string`,description:`The unique identifier of a notification policy`,demandOption:!0}).option(`alert-interval`,{type:`string`,description:`Optional specification of how often to re-alert from the same incident, not support on all alert types.`}).option(`alert-type`,{type:`string`,description:`Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values.`,choices:`abuse_report_alert.access_custom_certificate_expiration_type.advanced_ddos_attack_l4_alert.advanced_ddos_attack_l7_alert.advanced_http_alert_error.bgp_hijack_notification.billing_usage_alert.block_notification_block_removed.block_notification_new_block.block_notification_review_rejected.bot_traffic_basic_alert.brand_protection_alert.brand_protection_digest.clickhouse_alert_fw_anomaly.clickhouse_alert_fw_ent_anomaly.cloudforce_one_request_notification.cni_maintenance_notification.custom_analytics.custom_bot_detection_alert.custom_ssl_certificate_event_type.dedicated_ssl_certificate_event_type.device_connectivity_anomaly_alert.dos_attack_l4.dos_attack_l7.expiring_service_token_alert.failing_logpush_job_disabled_alert.fbm_auto_advertisement.fbm_dosd_attack.fbm_volumetric_attack.health_check_status_notification.hostname_aop_custom_certificate_expiration_type.http_alert_edge_error.http_alert_origin_error.image_notification.image_resizing_notification.incident_alert.load_balancing_health_alert.load_balancing_pool_enablement_alert.logo_match_alert.magic_tunnel_health_check_event.magic_wan_tunnel_health.maintenance_event_notification.mtls_certificate_store_certificate_expiration_type.pages_event_alert.radar_notification.real_origin_monitoring.scriptmonitor_alert_new_code_change_detections.scriptmonitor_alert_new_hosts.scriptmonitor_alert_new_malicious_hosts.scriptmonitor_alert_new_malicious_scripts.scriptmonitor_alert_new_malicious_url.scriptmonitor_alert_new_max_length_resource_url.scriptmonitor_alert_new_resources.secondary_dns_all_primaries_failing.secondary_dns_primaries_failing.secondary_dns_warning.secondary_dns_zone_successfully_updated.secondary_dns_zone_validation_warning.security_insights_alert.sentinel_alert.stream_live_notifications.synthetic_test_latency_alert.synthetic_test_low_availability_alert.traffic_anomalies_alert.tunnel_health_event.tunnel_update_event.universal_ssl_event_type.web_analytics_metrics_update.zone_aop_custom_certificate_expiration_type`.split(`.`)}).option(`description`,{type:`string`,description:`Optional description for the Notification policy.`}).option(`enabled`,{type:`boolean`,description:`Whether or not the Notification policy is enabled.`,default:!0}).option(`filters-actions`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-affected-asns`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-affected-components`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-affected-locations`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-airport-code`,{type:`string`,array:!0,description:`Used for configuring maintenance_event_notification`}).option(`filters-alert-trigger-preferences`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-alert-trigger-preferences-value`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-enabled`,{type:`string`,array:!0,description:`Used for configuring load_balancing_pool_enablement_alert`}).option(`filters-environment`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event-source`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-event-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-group-by`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-health-check-id`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-incident-impact`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-input-id`,{type:`string`,array:!0,description:`Used for configuring stream_live_notifications`}).option(`filters-insight-class`,{type:`string`,array:!0,description:`Used for configuring security_insights_alert`}).option(`filters-limit`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-logo-tag`,{type:`string`,array:!0,description:`Used for configuring logo_match_alert`}).option(`filters-megabits-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-new-health`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-new-status`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-packets-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-pool-id`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-pop-names`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-product`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-project-id`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-protocol`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-query-tag`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-requests-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-selectors`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-services`,{type:`string`,array:!0,description:`Used for configuring clickhouse_alert_fw_ent_anomaly`}).option(`filters-slo`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-status`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-target-hostname`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-target-ip`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-target-zone-name`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-traffic-exclusions`,{type:`string`,array:!0,description:`Used for configuring traffic_anomalies_alert`}).option(`filters-tunnel-id`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-tunnel-name`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-where`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-zones`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`name`,{type:`string`,description:`Name of the policy.`}).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 <policyId>`,describe:`Update a Notification policy.`,builder:Y,handler:async t=>{if(t.dryRun){l({command:`cf alerting policies update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/policies/${t.policyId??`<policyId>`}`,pathParams:{policyId:String(t.policyId??``)},bodyKind:`json`,body:{alertInterval:t.alertInterval,alertType:t.alertType,description:t.description,enabled:t.enabled,filtersActions:t.filtersActions,filtersAffectedAsns:t.filtersAffectedAsns,filtersAffectedComponents:t.filtersAffectedComponents,filtersAffectedLocations:t.filtersAffectedLocations,filtersAirportCode:t.filtersAirportCode,filtersAlertTriggerPreferences:t.filtersAlertTriggerPreferences,filtersAlertTriggerPreferencesValue:t.filtersAlertTriggerPreferencesValue,filtersEnabled:t.filtersEnabled,filtersEnvironment:t.filtersEnvironment,filtersEvent:t.filtersEvent,filtersEventSource:t.filtersEventSource,filtersEventType:t.filtersEventType,filtersGroupBy:t.filtersGroupBy,filtersHealthCheckId:t.filtersHealthCheckId,filtersIncidentImpact:t.filtersIncidentImpact,filtersInputId:t.filtersInputId,filtersInsightClass:t.filtersInsightClass,filtersLimit:t.filtersLimit,filtersLogoTag:t.filtersLogoTag,filtersMegabitsPerSecond:t.filtersMegabitsPerSecond,filtersNewHealth:t.filtersNewHealth,filtersNewStatus:t.filtersNewStatus,filtersPacketsPerSecond:t.filtersPacketsPerSecond,filtersPoolId:t.filtersPoolId,filtersPopNames:t.filtersPopNames,filtersProduct:t.filtersProduct,filtersProjectId:t.filtersProjectId,filtersProtocol:t.filtersProtocol,filtersQueryTag:t.filtersQueryTag,filtersRequestsPerSecond:t.filtersRequestsPerSecond,filtersSelectors:t.filtersSelectors,filtersServices:t.filtersServices,filtersSlo:t.filtersSlo,filtersStatus:t.filtersStatus,filtersTargetHostname:t.filtersTargetHostname,filtersTargetIp:t.filtersTargetIp,filtersTargetZoneName:t.filtersTargetZoneName,filtersTrafficExclusions:t.filtersTrafficExclusions,filtersTunnelId:t.filtersTunnelId,filtersTunnelName:t.filtersTunnelName,filtersType:t.filtersType,filtersWhere:t.filtersWhere,filtersZones:t.filtersZones,name:t.name,body:t.body}});return}let n=await i(t),r=t.local?f:await e(n);if(t.accountId=r,t.body){let e=s(t.body);c(await u(`Updating`,async()=>n.put(`/accounts/${r}/alerting/v3/policies/${t.policyId}`,{body:e})),{successLabel:`Updated`});return}let p={};t.alertInterval!==void 0&&o(p,[`alert_interval`],d(t.alertInterval,`alertInterval`,`text`)),t.alertType!==void 0&&o(p,[`alert_type`],d(t.alertType,`alertType`,`text`)),t.description!==void 0&&o(p,[`description`],d(t.description,`description`,`text`)),t.enabled!==void 0&&o(p,[`enabled`],t.enabled),t.filtersActions!==void 0&&o(p,[`filters`,`actions`],t.filtersActions),t.filtersAffectedAsns!==void 0&&o(p,[`filters`,`affected_asns`],t.filtersAffectedAsns),t.filtersAffectedComponents!==void 0&&o(p,[`filters`,`affected_components`],t.filtersAffectedComponents),t.filtersAffectedLocations!==void 0&&o(p,[`filters`,`affected_locations`],t.filtersAffectedLocations),t.filtersAirportCode!==void 0&&o(p,[`filters`,`airport_code`],t.filtersAirportCode),t.filtersAlertTriggerPreferences!==void 0&&o(p,[`filters`,`alert_trigger_preferences`],t.filtersAlertTriggerPreferences),t.filtersAlertTriggerPreferencesValue!==void 0&&o(p,[`filters`,`alert_trigger_preferences_value`],t.filtersAlertTriggerPreferencesValue),t.filtersEnabled!==void 0&&o(p,[`filters`,`enabled`],t.filtersEnabled),t.filtersEnvironment!==void 0&&o(p,[`filters`,`environment`],t.filtersEnvironment),t.filtersEvent!==void 0&&o(p,[`filters`,`event`],t.filtersEvent),t.filtersEventSource!==void 0&&o(p,[`filters`,`event_source`],t.filtersEventSource),t.filtersEventType!==void 0&&o(p,[`filters`,`event_type`],t.filtersEventType),t.filtersGroupBy!==void 0&&o(p,[`filters`,`group_by`],t.filtersGroupBy),t.filtersHealthCheckId!==void 0&&o(p,[`filters`,`health_check_id`],t.filtersHealthCheckId),t.filtersIncidentImpact!==void 0&&o(p,[`filters`,`incident_impact`],t.filtersIncidentImpact),t.filtersInputId!==void 0&&o(p,[`filters`,`input_id`],t.filtersInputId),t.filtersInsightClass!==void 0&&o(p,[`filters`,`insight_class`],t.filtersInsightClass),t.filtersLimit!==void 0&&o(p,[`filters`,`limit`],t.filtersLimit),t.filtersLogoTag!==void 0&&o(p,[`filters`,`logo_tag`],t.filtersLogoTag),t.filtersMegabitsPerSecond!==void 0&&o(p,[`filters`,`megabits_per_second`],t.filtersMegabitsPerSecond),t.filtersNewHealth!==void 0&&o(p,[`filters`,`new_health`],t.filtersNewHealth),t.filtersNewStatus!==void 0&&o(p,[`filters`,`new_status`],t.filtersNewStatus),t.filtersPacketsPerSecond!==void 0&&o(p,[`filters`,`packets_per_second`],t.filtersPacketsPerSecond),t.filtersPoolId!==void 0&&o(p,[`filters`,`pool_id`],t.filtersPoolId),t.filtersPopNames!==void 0&&o(p,[`filters`,`pop_names`],t.filtersPopNames),t.filtersProduct!==void 0&&o(p,[`filters`,`product`],t.filtersProduct),t.filtersProjectId!==void 0&&o(p,[`filters`,`project_id`],t.filtersProjectId),t.filtersProtocol!==void 0&&o(p,[`filters`,`protocol`],t.filtersProtocol),t.filtersQueryTag!==void 0&&o(p,[`filters`,`query_tag`],t.filtersQueryTag),t.filtersRequestsPerSecond!==void 0&&o(p,[`filters`,`requests_per_second`],t.filtersRequestsPerSecond),t.filtersSelectors!==void 0&&o(p,[`filters`,`selectors`],t.filtersSelectors),t.filtersServices!==void 0&&o(p,[`filters`,`services`],t.filtersServices),t.filtersSlo!==void 0&&o(p,[`filters`,`slo`],t.filtersSlo),t.filtersStatus!==void 0&&o(p,[`filters`,`status`],t.filtersStatus),t.filtersTargetHostname!==void 0&&o(p,[`filters`,`target_hostname`],t.filtersTargetHostname),t.filtersTargetIp!==void 0&&o(p,[`filters`,`target_ip`],t.filtersTargetIp),t.filtersTargetZoneName!==void 0&&o(p,[`filters`,`target_zone_name`],t.filtersTargetZoneName),t.filtersTrafficExclusions!==void 0&&o(p,[`filters`,`traffic_exclusions`],t.filtersTrafficExclusions),t.filtersTunnelId!==void 0&&o(p,[`filters`,`tunnel_id`],t.filtersTunnelId),t.filtersTunnelName!==void 0&&o(p,[`filters`,`tunnel_name`],t.filtersTunnelName),t.filtersType!==void 0&&o(p,[`filters`,`type`],t.filtersType),t.filtersWhere!==void 0&&o(p,[`filters`,`where`],t.filtersWhere),t.filtersZones!==void 0&&o(p,[`filters`,`zones`],t.filtersZones),t.name!==void 0&&o(p,[`name`],d(t.name,`name`,`text`)),c(await u(`Updating`,async()=>n.put(`/accounts/${r}/alerting/v3/policies/${t.policyId}`,{body:Object.keys(p).length>0?p:void 0})),{successLabel:`Updated`})}},Z={command:`policies`,describe:`Notification policies that define which events trigger alerts and where they are delivered`,builder:e=>e.command(H).command(W).command(K).command(J).command(X).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Q(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ne={command:`create`,describe:`Creates a new silence for an account.`,builder:Q,handler:async t=>{if(t.dryRun){l({command:`cf alerting silences create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/silences`,pathParams:{},bodyKind:`json`,body:{body:t.body}});return}let n=await i(t),r=t.local?f:await e(n);if(t.accountId=r,t.body){let e=s(t.body);c(await u(`Creating`,async()=>n.post(`/accounts/${r}/alerting/v3/silences`,{body:e})),{successLabel:`Created`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function re(e){return e.positional(`silenceId`,{type:`string`,description:`Silence ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const ie={command:`delete <silenceId>`,describe:`Deletes an existing silence for an account.`,builder:re,handler:async n=>{if(n.dryRun){l({command:`cf alerting silences delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/silences/${n.silenceId??`<silenceId>`}`,pathParams:{silenceId:String(n.silenceId??``)},bodyKind:`none`});return}let r=await i(n),o=n.local?f:await e(r);if(n.accountId=o,!await t({force:!!n.force})){process.stderr.write(`Aborted.
|
|
6
|
-
`);return}c(await u(`Deleting`,async()=>r.alerting.silences.delete(o,n.silenceId)),{successLabel:`Deleted`})}};function ae(e){return e.positional(`silenceId`,{type:`string`,description:`Silence ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const oe={command:`get <silenceId>`,describe:`Gets a specific silence for an account.`,builder:ae,handler:async t=>{if(t.dryRun){l({command:`cf alerting silences get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/silences/${t.silenceId??`<silenceId>`}`,pathParams:{silenceId:String(t.silenceId??``)},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Loading`,async()=>n.alerting.silences.get(r,t.silenceId)),{successLabel:`Loaded`})}};function $(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const se={command:`list`,describe:`Gets a list of silences for an account.`,builder:$,handler:async t=>{if(t.dryRun){l({command:`cf alerting silences list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/silences`,pathParams:{},bodyKind:`none`});return}let n=await i(t),r=t.local?f:await e(n);t.accountId=r,c(await u(`Loading`,async()=>n.alerting.silences.list(r)),{successLabel:`Loaded`})}};function ce(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const le={command:`update`,describe:`Updates existing silences for an account.`,builder:ce,handler:async t=>{if(t.dryRun){l({command:`cf alerting silences update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${a()??`<account-id>`}/alerting/v3/silences`,pathParams:{},bodyKind:`json`,body:{body:t.body}});return}let n=await i(t),r=t.local?f:await e(n);if(t.accountId=r,t.body){let e=s(t.body);c(await u(`Updating`,async()=>n.put(`/accounts/${r}/alerting/v3/silences`,{body:e})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},ue={command:`silences`,describe:`Silence windows that temporarily suppress alert notifications during maintenance`,builder:e=>e.command(ne).command(ie).command(oe).command(se).command(le).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},de={command:`alerting`,describe:`Notification policies, delivery destinations, silence windows, and alert history`,builder:e=>e.command(h).command(R).command(B).command(Z).command(ue).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{de as default};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{l as e,t}from"./auth-BlSmtIKd.mjs";import{t as n}from"./output-D7_yAFVR.mjs";import{n as r,t as i}from"./progress-DZfTxbrx.mjs";function a(e){return e.positional(`zoneIdentifier`,{type:`string`,description:`Identifier`,demandOption:!0}).option(`until`,{type:`string`,description:`The (exclusive) end of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made, or can be an absolute timestamp that conforms to RFC 3339. If omitted, the time of the request is used.`}).option(`since`,{type:`string`,description:`The (inclusive) beginning of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made, or can be an absolute timestamp that conforms to RFC 3339. At this point in time, it cannot exceed a time in the past greater than one year.
|
|
3
|
-
|
|
4
|
-
Ranges that the Cloudflare web application provides will provide the following period length for each point:
|
|
5
|
-
- Last 60 minutes (from -59 to -1): 1 minute resolution
|
|
6
|
-
- Last 7 hours (from -419 to -60): 15 minutes resolution
|
|
7
|
-
- Last 15 hours (from -899 to -420): 30 minutes resolution
|
|
8
|
-
- Last 72 hours (from -4320 to -900): 1 hour resolution
|
|
9
|
-
- Older than 3 days (-525600 to -4320): 1 day resolution.`}).option(`continuous`,{type:`boolean`,description:`When set to true, the API will move the requested time window backward, until it finds a region with completely aggregated data.
|
|
10
|
-
|
|
11
|
-
The API response _may not represent the requested time window_.`,default:!1}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const o={command:`get <zoneIdentifier>`,describe:`This view provides a breakdown of analytics data by datacenter. Note: This is available to Enterprise customers only.`,builder:a,handler:async a=>{let o={until:a.until,since:a.since,continuous:a.continuous};if(a.dryRun){r({command:`cf analytics colo get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${a.zoneIdentifier??`<zoneIdentifier>`}/analytics/colos`,pathParams:{zoneIdentifier:String(a.zoneIdentifier??``)},query:o,bodyKind:`none`});return}let s=await t(a),c=await e({zone:a.zone},s,{quiet:a.quiet});a.zoneId=c,n(await i(`Loading`,async()=>s.analytics.colo.get(c,o)),{successLabel:`Loaded`})}},s={command:`colo`,describe:`Per-data-center (colo) traffic analytics breakdown for the zone`,builder:e=>e.command(o).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function c(e){return e.positional(`zoneIdentifier`,{type:`string`,description:`Identifier`,demandOption:!0}).option(`until`,{type:`string`,description:`The (exclusive) end of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made, or can be an absolute timestamp that conforms to RFC 3339. If omitted, the time of the request is used.`}).option(`since`,{type:`string`,description:`The (inclusive) beginning of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made, or can be an absolute timestamp that conforms to RFC 3339. At this point in time, it cannot exceed a time in the past greater than one year.
|
|
12
|
-
|
|
13
|
-
Ranges that the Cloudflare web application provides will provide the following period length for each point:
|
|
14
|
-
- Last 60 minutes (from -59 to -1): 1 minute resolution
|
|
15
|
-
- Last 7 hours (from -419 to -60): 15 minutes resolution
|
|
16
|
-
- Last 15 hours (from -899 to -420): 30 minutes resolution
|
|
17
|
-
- Last 72 hours (from -4320 to -900): 1 hour resolution
|
|
18
|
-
- Older than 3 days (-525600 to -4320): 1 day resolution.`}).option(`continuous`,{type:`boolean`,description:`When set to true, the API will move the requested time window backward, until it finds a region with completely aggregated data.
|
|
19
|
-
|
|
20
|
-
The API response _may not represent the requested time window_.`,default:!1}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const l={command:`get <zoneIdentifier>`,describe:`The dashboard view provides both totals and timeseries data for the given zone and time period across the entire Cloudflare network.`,builder:c,handler:async a=>{let o={until:a.until,since:a.since,continuous:a.continuous};if(a.dryRun){r({command:`cf analytics dashboard get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${a.zoneIdentifier??`<zoneIdentifier>`}/analytics/dashboard`,pathParams:{zoneIdentifier:String(a.zoneIdentifier??``)},query:o,bodyKind:`none`});return}let s=await t(a),c=await e({zone:a.zone},s,{quiet:a.quiet});a.zoneId=c,n(await i(`Loading`,async()=>s.analytics.dashboard.get(c,o)),{successLabel:`Loaded`})}},u={command:`dashboard`,describe:`Aggregated zone dashboard analytics — requests, bandwidth, threats, and page views`,builder:e=>e.command(l).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function d(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const f={command:`get`,describe:`Retrieves Argo Smart Routing analytics broken down by geographic points of presence (PoPs). Shows latency improvements and routing efficiency per location.`,builder:d,handler:async a=>{if(a.dryRun){r({command:`cf analytics latency colos get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${a.zoneId??`<zoneId>`}/analytics/latency/colos`,pathParams:{zoneId:String(a.zoneId??``)},bodyKind:`none`});return}let o=await t(a),s=await e({zone:a.zone},o,{quiet:a.quiet});a.zoneId=s,n(await i(`Loading`,async()=>o.analytics.latency.colos.get(s)),{successLabel:`Loaded`})}},p={command:`colos`,describe:`Argo Smart Routing latency analytics showing time-to-first-byte improvements`,builder:e=>e.command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function m(e){return e.option(`bins`,{type:`string`,description:`Bins`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const h={command:`get`,describe:`Retrieves aggregate Argo Smart Routing analytics for a zone, including latency improvements, bandwidth savings, and routing statistics.`,builder:m,handler:async a=>{let o={bins:a.bins};if(a.dryRun){r({command:`cf analytics latency get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${a.zoneId??`<zoneId>`}/analytics/latency`,pathParams:{zoneId:String(a.zoneId??``)},query:o,bodyKind:`none`});return}let s=await t(a),c=await e({zone:a.zone},s,{quiet:a.quiet});a.zoneId=c,n(await i(`Loading`,async()=>s.analytics.latency.get(c,o)),{successLabel:`Loaded`})}},g={command:`latency`,describe:`Argo Smart Routing latency analytics showing time-to-first-byte improvements`,builder:e=>e.command(h).command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},_={command:`analytics`,describe:`Zone-level traffic analytics — dashboard summaries, per-colo breakdowns, and Argo latency metrics`,builder:e=>e.command(s).command(u).command(g).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{_ as default};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{f as e,l as t,m as n,p as r,t as i}from"./auth-BlSmtIKd.mjs";import{n as a,t as o}from"./body-parser-Br-BoYk-.mjs";import{t as s}from"./output-D7_yAFVR.mjs";import{n as c,t as l}from"./progress-DZfTxbrx.mjs";import{n as u,t as d}from"./input-validation-zEO81MWN.mjs";function f(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ee={command:`get`,describe:`Gets the current API Shield configuration settings for a zone, including validation behavior and enforcement mode.`,builder:f,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway configurations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/configuration`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`none`});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});e.zoneId=r,s(await l(`Loading`,async()=>n.apiGateway.configurations.get(r)),{successLabel:`Loaded`})}};function te(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const p={command:`update`,describe:`Updates API Shield configuration settings for a zone. Can modify validation strictness, enforcement mode, and other global settings.`,builder:te,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway configurations update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/configuration`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{body:e.body}});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});if(e.zoneId=r,e.body){let t=u(e.body,`body`,`binary`);s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/configuration`,{body:t,headers:{"Content-Type":`application/octet-stream`}})),{successLabel:`Updated`});return}s(await l(`Updating`,async()=>n.apiGateway.configurations.update(r)),{successLabel:`Updated`})}},m={command:`configurations`,describe:`API Shield configuration — authentication requirements and session identifiers`,builder:e=>e.command(ee).command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function h(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`get`,describe:`Retrieve the most up to date view of discovered operations, rendered as OpenAPI schemas`,builder:h,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway discovery get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/discovery`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`none`});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});e.zoneId=r,s(await l(`Loading`,async()=>n.apiGateway.discovery.get(r)),{successLabel:`Loaded`})}};function _(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const v={command:`bulk-edit`,describe:"Update the `state` on one or more discovered operations",builder:_,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway discovery operations bulk-edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/discovery/operations`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{body:e.body}});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});if(e.zoneId=r,e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.patch(`/zones/${e.zoneId}/api_gateway/discovery/operations`,{body:t})),{successLabel:`Updated`});return}s(await l(`Updating`,async()=>n.apiGateway.discovery.operations.bulkEdit(r)),{successLabel:`Updated`})}};function y(e){return e.positional(`operationId`,{type:`string`,description:`Operation ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const b={command:`edit <operationId>`,describe:"Update the `state` on a discovered operation",builder:y,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway discovery operations edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/discovery/operations/${e.operationId??`<operationId>`}`,pathParams:{zoneId:String(e.zoneId??``),operationId:String(e.operationId??``)},bodyKind:`json`,body:{body:e.body}});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});if(e.zoneId=r,e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.patch(`/zones/${e.zoneId}/api_gateway/discovery/operations/${e.operationId}`,{body:t})),{successLabel:`Updated`});return}s(await l(`Updating`,async()=>n.apiGateway.discovery.operations.edit(r,e.operationId)),{successLabel:`Updated`})}};function x(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`host`,{type:`string`,description:`Filter results to only include the specified hosts.`}).option(`method`,{type:`string`,description:`Filter results to only include the specified HTTP methods.`}).option(`endpoint`,{type:`string`,description:`Filter results to only include endpoints containing this pattern.`}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`host`,`method`,`endpoint`,`traffic_stats.requests`,`traffic_stats.last_updated`]}).option(`diff`,{type:`boolean`,description:"When `true`, only return API Discovery results that are not saved into API Shield Endpoint Management",default:!1}).option(`origin`,{type:`string`,description:"Filter results to only include discovery results sourced from a particular discovery engine\n * `ML` - Discovered operations that were sourced using ML API Discovery\n * `SessionIdentifier` - Discovered operations that were sourced using Session Identifier API Discovery",choices:[`ML`,`SessionIdentifier`,`LabelDiscovery`]}).option(`state`,{type:`string`,description:"Filter results to only include discovery results in a particular state. States are as follows\n * `review` - Discovered operations that are not saved into API Shield Endpoint Management\n * `saved` - Discovered operations that are already saved into API Shield Endpoint Management\n * `ignored` - Discovered operations that have been marked as ignored",choices:[`review`,`saved`,`ignored`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const S={command:`list`,describe:`Retrieve the most up to date view of discovered operations`,builder:x,handler:async e=>{let n={page:e.page,per_page:e.perPage,host:e.host,method:e.method,endpoint:e.endpoint,direction:e.direction,order:e.order,diff:e.diff,origin:e.origin,state:e.state};if(e.dryRun){c({command:`cf api-gateway discovery operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/discovery/operations`,pathParams:{zoneId:String(e.zoneId??``)},query:n,bodyKind:`none`});return}let r=await i(e),a=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a,s(await l(`Loading`,async()=>r.apiGateway.discovery.operations.list(a,n)),{successLabel:`Loaded`})}},C={command:`operations`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(v).command(b).command(S).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},w={command:`discovery`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(g).command(C).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function T(e){return e.option(`hosts`,{type:`string`,array:!0,description:`List of hosts to be targeted in the expression`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const E={command:`create`,describe:`Creates an expression template fallthrough rule for API Shield. Used for configuring default behavior when no other expression templates match.`,builder:T,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway expression-template fallthrough create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/expression-template/fallthrough`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{hosts:e.hosts,body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Creating`,async()=>n.post(`/zones/${e.zoneId}/api_gateway/expression-template/fallthrough`,{body:t})),{successLabel:`Created`});return}if(e.hosts===void 0)throw Error(`--hosts is required (or pass --body with this field set).`);let r={};e.hosts!==void 0&&a(r,[`hosts`],e.hosts),s(await l(`Creating`,async()=>n.post(`/zones/${e.zoneId}/api_gateway/expression-template/fallthrough`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Created`})}},D={command:`fallthrough`,describe:`Reusable expression templates for API Gateway rule configurations`,builder:e=>e.command(E).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},O={command:`expression-template`,describe:`Operations for expression-template`,builder:e=>e.command(D).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function k(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`name`,`description`,`created_at`,`last_updated`,`mapped_resources.operations`]}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`source`,{type:`string`,description:`Filter for labels with source`,choices:[`user`,`managed`]}).option(`filter`,{type:`string`,description:`Filter for labels where the name or description matches using substring match`}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label",default:!1}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`list`,describe:`Retrieve all labels`,builder:k,handler:async e=>{let n={page:e.page,per_page:e.perPage,order:e.order,direction:e.direction,source:e.source,filter:e.filter,with_mapped_resource_counts:e.withMappedResourceCounts};if(e.dryRun){c({command:`cf api-gateway labels list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/labels`,pathParams:{zoneId:String(e.zoneId??``)},query:n,bodyKind:`none`});return}let r=await i(e),a=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a,s(await l(`Loading`,async()=>r.apiGateway.labels.list(a,n)),{successLabel:`Loaded`})}};function j(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label",default:!1}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`get <name>`,describe:`Retrieve managed label`,builder:j,handler:async e=>{let n={with_mapped_resource_counts:e.withMappedResourceCounts};if(e.dryRun){c({command:`cf api-gateway labels managed get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/labels/managed/${e.name??`<name>`}`,pathParams:{zoneId:String(e.zoneId??``),name:String(e.name??``)},query:n,bodyKind:`none`});return}let r=await i(e),a=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a,s(await l(`Loading`,async()=>r.apiGateway.labels.managed.get(a,e.name,n)),{successLabel:`Loaded`})}};function N(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const P={command:`update <name>`,describe:`Replace all operations(s) attached to a managed label`,builder:N,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway labels managed resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/labels/managed/${e.name??`<name>`}/resources/operation`,pathParams:{zoneId:String(e.zoneId??``),name:String(e.name??``)},bodyKind:`json`,body:{body:e.body}});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});if(e.zoneId=r,e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/labels/managed/${e.name}/resources/operation`,{body:t})),{successLabel:`Updated`});return}s(await l(`Updating`,async()=>n.apiGateway.labels.managed.resources.operation.update(r,e.name)),{successLabel:`Updated`})}},F={command:`operation`,describe:`Labels operations`,builder:e=>e.command(P).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},I={command:`resources`,describe:`Operations for labels.managed.resources`,builder:e=>e.command(F).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},L={command:`managed`,describe:`Labels operations`,builder:e=>e.command(M).command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function R(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const z={command:`bulk-create`,describe:`Create user labels`,builder:R,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway labels user bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/labels/user`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Creating`,async()=>n.post(`/zones/${e.zoneId}/api_gateway/labels/user`,{body:t})),{successLabel:`Created`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function B(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const V={command:`bulk-delete`,describe:`Delete user labels`,builder:B,handler:async n=>{if(n.dryRun){c({command:`cf api-gateway labels user bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${n.zoneId??`<zoneId>`}/api_gateway/labels/user`,pathParams:{zoneId:String(n.zoneId??``)},bodyKind:`json`,body:{body:n.body}});return}let r=await i(n);if(n.zoneId=await t({zone:n.zone},r,{quiet:n.quiet}),!await e({force:!!n.force})){process.stderr.write(`Aborted.
|
|
3
|
-
`);return}if(n.body){let e=o(n.body);s(await l(`Deleting`,async()=>r.delete(`/zones/${n.zoneId}/api_gateway/labels/user`,{body:e})),{successLabel:`Deleted`});return}if(n.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function H(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const U={command:`delete <name>`,describe:`Delete user label`,builder:H,handler:async n=>{if(n.dryRun){c({command:`cf api-gateway labels user delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${n.zoneId??`<zoneId>`}/api_gateway/labels/user/${n.name??`<name>`}`,pathParams:{zoneId:String(n.zoneId??``),name:String(n.name??``)},bodyKind:`none`});return}let r=await i(n),a=await t({zone:n.zone},r,{quiet:n.quiet});if(n.zoneId=a,!await e({force:!!n.force})){process.stderr.write(`Aborted.
|
|
4
|
-
`);return}s(await l(`Deleting`,async()=>r.apiGateway.labels.user.delete(a,n.name)),{successLabel:`Deleted`})}};function W(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`description`,{type:`string`,description:`The description of the label`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const G={command:`edit <name>`,describe:`Update certain fields on a label`,builder:W,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway labels user edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/labels/user/${e.name??`<name>`}`,pathParams:{zoneId:String(e.zoneId??``),name:String(e.name??``)},bodyKind:`json`,body:{description:e.description,body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.patch(`/zones/${e.zoneId}/api_gateway/labels/user/${e.name}`,{body:t})),{successLabel:`Updated`});return}let r={};e.description!==void 0&&a(r,[`description`],u(e.description,`description`,`text`)),s(await l(`Updating`,async()=>n.patch(`/zones/${e.zoneId}/api_gateway/labels/user/${e.name}`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Updated`})}};function K(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label",default:!1}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const q={command:`get <name>`,describe:`Retrieve user label`,builder:K,handler:async e=>{let n={with_mapped_resource_counts:e.withMappedResourceCounts};if(e.dryRun){c({command:`cf api-gateway labels user get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/labels/user/${e.name??`<name>`}`,pathParams:{zoneId:String(e.zoneId??``),name:String(e.name??``)},query:n,bodyKind:`none`});return}let r=await i(e),a=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a,s(await l(`Loading`,async()=>r.apiGateway.labels.user.get(a,e.name,n)),{successLabel:`Loaded`})}};function J(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Y={command:`update <name>`,describe:`Replace all operations(s) attached to a user label`,builder:J,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway labels user resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/labels/user/${e.name??`<name>`}/resources/operation`,pathParams:{zoneId:String(e.zoneId??``),name:String(e.name??``)},bodyKind:`json`,body:{body:e.body}});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});if(e.zoneId=r,e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/labels/user/${e.name}/resources/operation`,{body:t})),{successLabel:`Updated`});return}s(await l(`Updating`,async()=>n.apiGateway.labels.user.resources.operation.update(r,e.name)),{successLabel:`Updated`})}},X={command:`operation`,describe:`Labels operations`,builder:e=>e.command(Y).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Z={command:`resources`,describe:`Operations for labels.user.resources`,builder:e=>e.command(X).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Q(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`description`,{type:`string`,description:`The description of the label`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ne={command:`update <name>`,describe:`Update all fields on a label`,builder:Q,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway labels user update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/labels/user/${e.name??`<name>`}`,pathParams:{zoneId:String(e.zoneId??``),name:String(e.name??``)},bodyKind:`json`,body:{description:e.description,body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/labels/user/${e.name}`,{body:t})),{successLabel:`Updated`});return}let r={};e.description!==void 0&&a(r,[`description`],u(e.description,`description`,`text`)),s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/labels/user/${e.name}`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Updated`})}},re={command:`user`,describe:`Labels operations`,builder:e=>e.command(z).command(V).command(U).command(G).command(q).command(ne).command(Z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ie={command:`labels`,describe:`Labels operations`,builder:e=>e.command(A).command(L).command(re).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ae(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const oe={command:`bulk-create`,describe:`Add one or more operations to a zone. Endpoints can contain path variables. Host, method, endpoint will be normalized to a canoncial form when creating an operation and must be unique on the zone. Inserting an operation that matches an existing one will return the record of the already existing operation and update its last_updated date.`,builder:ae,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway operations bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Creating`,async()=>n.post(`/zones/${e.zoneId}/api_gateway/operations`,{body:t})),{successLabel:`Created`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function se(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ce={command:`bulk-delete`,describe:`Bulk removes multiple API operations from API Shield endpoint management in a single request. Efficient for cleaning up unused endpoints.`,builder:se,handler:async n=>{if(n.dryRun){c({command:`cf api-gateway operations bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${n.zoneId??`<zoneId>`}/api_gateway/operations`,pathParams:{zoneId:String(n.zoneId??``)},bodyKind:`json`,body:{body:n.body}});return}let r=await i(n);if(n.zoneId=await t({zone:n.zone},r,{quiet:n.quiet}),!await e({force:!!n.force})){process.stderr.write(`Aborted.
|
|
5
|
-
`);return}if(n.body){let e=o(n.body);s(await l(`Deleting`,async()=>r.delete(`/zones/${n.zoneId}/api_gateway/operations`,{body:e})),{successLabel:`Deleted`});return}if(n.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function le(e){return e.option(`endpoint`,{type:`string`,description:`The endpoint which can contain path parameter templates in curly braces, each will be replaced from left to right with {varN}, starting with {var1}, during insertion. This will further be Cloudflare-normalized upon insertion. See: https://developers.cloudflare.com/rules/normalization/how-it-works/.`}).option(`host`,{type:`string`,description:`RFC3986-compliant host.`}).option(`method`,{type:`string`,description:`The HTTP method used to access the endpoint.`,choices:[`GET`,`POST`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`CONNECT`,`PATCH`,`TRACE`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ue={command:`create`,describe:`Add one operation to a zone. Endpoints can contain path variables. Host, method, endpoint will be normalized to a canoncial form when creating an operation and must be unique on the zone. Inserting an operation that matches an existing one will return the record of the already existing operation and update its last_updated date.`,builder:le,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway operations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations/item`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{endpoint:e.endpoint,host:e.host,method:e.method,body:e.body}});return}let d=await i(e);if(e.zoneId=await t({zone:e.zone},d,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Creating`,async()=>d.post(`/zones/${e.zoneId}/api_gateway/operations/item`,{body:t})),{successLabel:`Created`});return}e.endpoint===void 0&&(e.endpoint=await n(`endpoint`,`The endpoint which can contain path parameter templates in curly braces, each will be replaced from left to right with {varN}, starting with {var1}, during insertion. This will further be Cloudflare-normalized upon insertion. See: https://developers.cloudflare.com/rules/normalization/how-it-works/.`)),e.host===void 0&&(e.host=await n(`host`,`RFC3986-compliant host.`)),e.method===void 0&&(e.method=await r(`method`,`The HTTP method used to access the endpoint.`,[`GET`,`POST`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`CONNECT`,`PATCH`,`TRACE`]));let f={};e.endpoint!==void 0&&a(f,[`endpoint`],u(e.endpoint,`endpoint`,`text`)),e.host!==void 0&&a(f,[`host`],u(e.host,`host`,`text`)),e.method!==void 0&&a(f,[`method`],u(e.method,`method`,`text`)),s(await l(`Creating`,async()=>d.post(`/zones/${e.zoneId}/api_gateway/operations/item`,{body:Object.keys(f).length>0?f:void 0})),{successLabel:`Created`})}};function de(e){return e.positional(`operationId`,{type:`string`,description:`Operation ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const fe={command:`delete <operationId>`,describe:`Removes a single API operation from API Shield endpoint management. The operation will no longer be tracked or protected by API Shield rules.`,builder:de,handler:async n=>{if(n.dryRun){c({command:`cf api-gateway operations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${n.zoneId??`<zoneId>`}/api_gateway/operations/${n.operationId??`<operationId>`}`,pathParams:{zoneId:String(n.zoneId??``),operationId:String(n.operationId??``)},bodyKind:`none`});return}let r=await i(n),a=await t({zone:n.zone},r,{quiet:n.quiet});if(n.zoneId=a,!await e({force:!!n.force})){process.stderr.write(`Aborted.
|
|
6
|
-
`);return}s(await l(`Deleting`,async()=>r.apiGateway.operations.delete(a,n.operationId)),{successLabel:`Deleted`})}};function pe(e){return e.positional(`operationId`,{type:`string`,description:`Operation ID`,demandOption:!0}).option(`feature`,{type:`string`,description:`Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description for more details on the specific meaning.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const me={command:`get <operationId>`,describe:`Gets detailed information about a specific API operation in API Shield, including its schema validation settings and traffic statistics.`,builder:pe,handler:async e=>{let n={feature:e.feature};if(e.dryRun){c({command:`cf api-gateway operations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations/${e.operationId??`<operationId>`}`,pathParams:{zoneId:String(e.zoneId??``),operationId:String(e.operationId??``)},query:n,bodyKind:`none`});return}let r=await i(e),a=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a,s(await l(`Loading`,async()=>r.apiGateway.operations.get(a,e.operationId,n)),{successLabel:`Loaded`})}};function he(e){return e.option(`managed-labels`,{type:`string`,array:!0,description:`List of managed label names.`}).option(`user-labels`,{type:`string`,array:!0,description:`List of user label names.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ge={command:`bulk-create`,describe:`Bulk attach label(s) on operation(s) in endpoint management`,builder:he,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway operations labels bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations/labels`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{managedLabels:e.managedLabels,userLabels:e.userLabels,body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Creating`,async()=>n.post(`/zones/${e.zoneId}/api_gateway/operations/labels`,{body:t})),{successLabel:`Created`});return}let r={};e.managedLabels!==void 0&&a(r,[`managed`,`labels`],e.managedLabels),e.userLabels!==void 0&&a(r,[`user`,`labels`],e.userLabels),s(await l(`Creating`,async()=>n.post(`/zones/${e.zoneId}/api_gateway/operations/labels`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Created`})}};function _e(e){return e.option(`managed-labels`,{type:`string`,array:!0,description:`List of managed label names.`}).option(`user-labels`,{type:`string`,array:!0,description:`List of user label names.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ve={command:`bulk-delete`,describe:`Bulk remove label(s) on operation(s) in endpoint management`,builder:_e,handler:async n=>{if(n.dryRun){c({command:`cf api-gateway operations labels bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${n.zoneId??`<zoneId>`}/api_gateway/operations/labels`,pathParams:{zoneId:String(n.zoneId??``)},bodyKind:`json`,body:{managedLabels:n.managedLabels,userLabels:n.userLabels,body:n.body}});return}let r=await i(n);if(n.zoneId=await t({zone:n.zone},r,{quiet:n.quiet}),!await e({force:!!n.force})){process.stderr.write(`Aborted.
|
|
7
|
-
`);return}if(n.body){let e=o(n.body);s(await l(`Deleting`,async()=>r.delete(`/zones/${n.zoneId}/api_gateway/operations/labels`,{body:e})),{successLabel:`Deleted`});return}let u={};n.managedLabels!==void 0&&a(u,[`managed`,`labels`],n.managedLabels),n.userLabels!==void 0&&a(u,[`user`,`labels`],n.userLabels),s(await l(`Deleting`,async()=>r.delete(`/zones/${n.zoneId}/api_gateway/operations/labels`,{body:Object.keys(u).length>0?u:void 0})),{successLabel:`Deleted`})}};function ye(e){return e.option(`managed-labels`,{type:`string`,array:!0,description:`List of managed label names. Providing an empty array will result in all managed labels being removed from all affected operations`}).option(`user-labels`,{type:`string`,array:!0,description:`List of user label names. Providing an empty array will result in all user labels being removed from all affected operations`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const be={command:`bulk-update`,describe:`Bulk replace label(s) on operation(s) in endpoint management`,builder:ye,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway operations labels bulk-update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations/labels`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{managedLabels:e.managedLabels,userLabels:e.userLabels,body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/operations/labels`,{body:t})),{successLabel:`Updated`});return}if(e.managedLabels===void 0)throw Error(`--managed-labels is required (or pass --body with this field set).`);if(e.userLabels===void 0)throw Error(`--user-labels is required (or pass --body with this field set).`);let r={};e.managedLabels!==void 0&&a(r,[`managed`,`labels`],e.managedLabels),e.userLabels!==void 0&&a(r,[`user`,`labels`],e.userLabels),s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/operations/labels`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Updated`})}};function xe(e){return e.positional(`operationId`,{type:`string`,description:`Operation ID`,demandOption:!0}).option(`managed`,{type:`string`,array:!0,description:`List of managed label names.`}).option(`user`,{type:`string`,array:!0,description:`List of user label names.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Se={command:`create <operationId>`,describe:`Attach label(s) on an operation in endpoint management`,builder:xe,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway operations labels create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations/${e.operationId??`<operationId>`}/labels`,pathParams:{zoneId:String(e.zoneId??``),operationId:String(e.operationId??``)},bodyKind:`json`,body:{managed:e.managed,user:e.user,body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Creating`,async()=>n.post(`/zones/${e.zoneId}/api_gateway/operations/${e.operationId}/labels`,{body:t})),{successLabel:`Created`});return}let r={};e.managed!==void 0&&a(r,[`managed`],e.managed),e.user!==void 0&&a(r,[`user`],e.user),s(await l(`Creating`,async()=>n.post(`/zones/${e.zoneId}/api_gateway/operations/${e.operationId}/labels`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Created`})}};function Ce(e){return e.positional(`operationId`,{type:`string`,description:`Operation ID`,demandOption:!0}).option(`managed`,{type:`string`,array:!0,description:`List of managed label names.`}).option(`user`,{type:`string`,array:!0,description:`List of user label names.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const we={command:`delete <operationId>`,describe:`Remove label(s) on an operation in endpoint management`,builder:Ce,handler:async n=>{if(n.dryRun){c({command:`cf api-gateway operations labels delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${n.zoneId??`<zoneId>`}/api_gateway/operations/${n.operationId??`<operationId>`}/labels`,pathParams:{zoneId:String(n.zoneId??``),operationId:String(n.operationId??``)},bodyKind:`json`,body:{managed:n.managed,user:n.user,body:n.body}});return}let r=await i(n);if(n.zoneId=await t({zone:n.zone},r,{quiet:n.quiet}),!await e({force:!!n.force})){process.stderr.write(`Aborted.
|
|
8
|
-
`);return}if(n.body){let e=o(n.body);s(await l(`Deleting`,async()=>r.delete(`/zones/${n.zoneId}/api_gateway/operations/${n.operationId}/labels`,{body:e})),{successLabel:`Deleted`});return}let u={};n.managed!==void 0&&a(u,[`managed`],n.managed),n.user!==void 0&&a(u,[`user`],n.user),s(await l(`Deleting`,async()=>r.delete(`/zones/${n.zoneId}/api_gateway/operations/${n.operationId}/labels`,{body:Object.keys(u).length>0?u:void 0})),{successLabel:`Deleted`})}};function Te(e){return e.positional(`operationId`,{type:`string`,description:`Operation ID`,demandOption:!0}).option(`managed`,{type:`string`,array:!0,description:`List of managed label names. Omitting this property or passing an empty array will result in all managed labels being removed from the operation`}).option(`user`,{type:`string`,array:!0,description:`List of user label names. Omitting this property or passing an empty array will result in all user labels being removed from the operation`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Ee={command:`update <operationId>`,describe:`Replace label(s) on an operation in endpoint management`,builder:Te,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway operations labels update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations/${e.operationId??`<operationId>`}/labels`,pathParams:{zoneId:String(e.zoneId??``),operationId:String(e.operationId??``)},bodyKind:`json`,body:{managed:e.managed,user:e.user,body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/operations/${e.operationId}/labels`,{body:t})),{successLabel:`Updated`});return}let r={};e.managed!==void 0&&a(r,[`managed`],e.managed),e.user!==void 0&&a(r,[`user`],e.user),s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/operations/${e.operationId}/labels`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Updated`})}},De={command:`labels`,describe:`Manage labels on API Shield operations for classification and policy enforcement`,builder:e=>e.command(ge).command(ve).command(be).command(Se).command(we).command(Ee).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Oe(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`order`,{type:`string`,description:"Field to order by. When requesting a feature, the feature keys are available for ordering as well, e.g., `thresholds.suggested_threshold`.",choices:[`method`,`host`,`endpoint`,`thresholds.$key`]}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`host`,{type:`string`,description:`Filter results to only include the specified hosts.`}).option(`method`,{type:`string`,description:`Filter results to only include the specified HTTP methods.`}).option(`endpoint`,{type:`string`,description:`Filter results to only include endpoints containing this pattern.`}).option(`feature`,{type:`string`,description:`Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description for more details on the specific meaning.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ke={command:`list`,describe:`Lists all API operations tracked by API Shield for a zone with pagination. Returns operation details including method, path, and feature configurations.`,builder:Oe,handler:async e=>{let n={page:e.page,per_page:e.perPage,order:e.order,direction:e.direction,host:e.host,method:e.method,endpoint:e.endpoint,feature:e.feature};if(e.dryRun){c({command:`cf api-gateway operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations`,pathParams:{zoneId:String(e.zoneId??``)},query:n,bodyKind:`none`});return}let r=await i(e),a=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a,s(await l(`Loading`,async()=>r.apiGateway.operations.list(a,n)),{successLabel:`Loaded`})}};function Ae(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const je={command:`edit`,describe:`Updates multiple operation-level schema validation settings on the zone`,builder:Ae,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway operations schema-validation edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations/schema_validation`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{body:e.body}});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});if(e.zoneId=r,e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.patch(`/zones/${e.zoneId}/api_gateway/operations/schema_validation`,{body:t})),{successLabel:`Updated`});return}s(await l(`Updating`,async()=>n.apiGateway.operations.schemaValidation.edit(r)),{successLabel:`Updated`})}};function Me(e){return e.positional(`operationId`,{type:`string`,description:`Operation ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ne={command:`get <operationId>`,describe:`Retrieves operation-level schema validation settings on the zone`,builder:Me,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway operations schema-validation get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations/${e.operationId??`<operationId>`}/schema_validation`,pathParams:{zoneId:String(e.zoneId??``),operationId:String(e.operationId??``)},bodyKind:`none`});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});e.zoneId=r,s(await l(`Loading`,async()=>n.apiGateway.operations.schemaValidation.get(r,e.operationId)),{successLabel:`Loaded`})}};function Pe(e){return e.positional(`operationId`,{type:`string`,description:`Operation ID`,demandOption:!0}).option(`mitigation-action`,{type:`string`,description:"When set, this applies a mitigation action to this operation\n\n - `log` log request when request does not conform to schema for this operation\n - `block` deny access to the site when request does not conform to schema for this operation\n - `none` will skip mitigation for this operation\n - `null` indicates that no operation level mitigation is in place, see Zone Level Schema Validation Settings for mitigation action that will be applied\n",choices:[`log`,`block`,`none`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Fe={command:`update <operationId>`,describe:`Updates operation-level schema validation settings on the zone`,builder:Pe,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway operations schema-validation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/operations/${e.operationId??`<operationId>`}/schema_validation`,pathParams:{zoneId:String(e.zoneId??``),operationId:String(e.operationId??``)},bodyKind:`json`,body:{mitigationAction:e.mitigationAction,body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/operations/${e.operationId}/schema_validation`,{body:t})),{successLabel:`Updated`});return}let r={};e.mitigationAction!==void 0&&a(r,[`mitigation_action`],u(e.mitigationAction,`mitigationAction`,`text`)),s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/operations/${e.operationId}/schema_validation`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Updated`})}},Ie={command:`schema-validation`,describe:`Registered API operations (method + path) with traffic metrics and schema bindings`,builder:e=>e.command(je).command(Ne).command(Fe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Le={command:`operations`,describe:`Registered API operations (method + path) with traffic metrics and schema bindings`,builder:e=>e.command(oe).command(ce).command(ue).command(fe).command(me).command(ke).command(De).command(Ie).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Re(e){return e.option(`host`,{type:`string`,description:`Receive schema only for the given host(s).`}).option(`feature`,{type:`string`,description:`Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description for more details on the specific meaning.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ze={command:`list`,describe:`Retrieves API operations and their features exported as OpenAPI schemas.`,builder:Re,handler:async e=>{let n={host:e.host,feature:e.feature};if(e.dryRun){c({command:`cf api-gateway schemas list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/schemas`,pathParams:{zoneId:String(e.zoneId??``)},query:n,bodyKind:`none`});return}let r=await i(e),a=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a,s(await l(`Loading`,async()=>r.apiGateway.schemas.list(a,n)),{successLabel:`Loaded`})}},Be={command:`schemas`,describe:`OpenAPI schemas learned from traffic for API endpoint validation`,builder:e=>e.command(ze).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ve(e){return e.option(`validation-default-mitigation-action`,{type:`string`,description:`The default mitigation action used when there is no mitigation action defined on the operation
|
|
9
|
-
Mitigation actions are as follows:
|
|
10
|
-
|
|
11
|
-
* \`log\` - log request when request does not conform to schema
|
|
12
|
-
* \`block\` - deny access to the site when request does not conform to schema
|
|
13
|
-
|
|
14
|
-
A special value of of \`none\` will skip running schema validation entirely for the request when there is no mitigation action defined on the operation
|
|
15
|
-
|
|
16
|
-
\`null\` will have no effect.
|
|
17
|
-
`,choices:[`none`,`log`,`block`]}).option(`validation-override-mitigation-action`,{type:`string`,description:`When set, this overrides both zone level and operation level mitigation actions.
|
|
18
|
-
|
|
19
|
-
- \`none\` will skip running schema validation entirely for the request
|
|
20
|
-
|
|
21
|
-
To clear any override, use the special value \`disable_override\`
|
|
22
|
-
|
|
23
|
-
\`null\` will have no effect.
|
|
24
|
-
`,choices:[`none`,`disable_override`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const He={command:`edit`,describe:`Updates zone level schema validation settings on the zone`,builder:Ve,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway settings schema-validation edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/settings/schema_validation`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{validationDefaultMitigationAction:e.validationDefaultMitigationAction,validationOverrideMitigationAction:e.validationOverrideMitigationAction,body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.patch(`/zones/${e.zoneId}/api_gateway/settings/schema_validation`,{body:t})),{successLabel:`Updated`});return}let r={};e.validationDefaultMitigationAction!==void 0&&a(r,[`validation_default_mitigation_action`],u(e.validationDefaultMitigationAction,`validationDefaultMitigationAction`,`text`)),e.validationOverrideMitigationAction!==void 0&&a(r,[`validation_override_mitigation_action`],u(e.validationOverrideMitigationAction,`validationOverrideMitigationAction`,`text`)),s(await l(`Updating`,async()=>n.patch(`/zones/${e.zoneId}/api_gateway/settings/schema_validation`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Updated`})}};function Ue(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const We={command:`get`,describe:`Retrieves zone level schema validation settings currently set on the zone`,builder:Ue,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway settings schema-validation get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/settings/schema_validation`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`none`});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});e.zoneId=r,s(await l(`Loading`,async()=>n.apiGateway.settings.schemaValidation.get(r)),{successLabel:`Loaded`})}};function Ge(e){return e.option(`validation-default-mitigation-action`,{type:`string`,description:`The default mitigation action used when there is no mitigation action defined on the operation
|
|
25
|
-
|
|
26
|
-
Mitigation actions are as follows:
|
|
27
|
-
|
|
28
|
-
* \`log\` - log request when request does not conform to schema
|
|
29
|
-
* \`block\` - deny access to the site when request does not conform to schema
|
|
30
|
-
|
|
31
|
-
A special value of of \`none\` will skip running schema validation entirely for the request when there is no mitigation action defined on the operation
|
|
32
|
-
`,choices:[`none`,`log`,`block`]}).option(`validation-override-mitigation-action`,{type:`string`,description:"When set, this overrides both zone level and operation level mitigation actions.\n\n - `none` will skip running schema validation entirely for the request\n - `null` indicates that no override is in place\n\nTo clear any override, use the special value `disable_override` or `null`\n",choices:[`none`,`disable_override`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Ke={command:`update`,describe:`Updates zone level schema validation settings on the zone`,builder:Ge,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway settings schema-validation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/settings/schema_validation`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{validationDefaultMitigationAction:e.validationDefaultMitigationAction,validationOverrideMitigationAction:e.validationOverrideMitigationAction,body:e.body}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/settings/schema_validation`,{body:t})),{successLabel:`Updated`});return}e.validationDefaultMitigationAction===void 0&&(e.validationDefaultMitigationAction=await r(`validation-default-mitigation-action`,"The default mitigation action used when there is no mitigation action defined on the operation Mitigation actions are as follows: * `log` - log request when request does not conform to schema * `block` - deny access to the site when request does not conform to schema A special value of of `none` will skip running schema validation entirely for the request when there is no mitigation action defined on the operation ",[`none`,`log`,`block`]));let d={};e.validationDefaultMitigationAction!==void 0&&a(d,[`validation_default_mitigation_action`],u(e.validationDefaultMitigationAction,`validationDefaultMitigationAction`,`text`)),e.validationOverrideMitigationAction!==void 0&&a(d,[`validation_override_mitigation_action`],u(e.validationOverrideMitigationAction,`validationOverrideMitigationAction`,`text`)),s(await l(`Updating`,async()=>n.put(`/zones/${e.zoneId}/api_gateway/settings/schema_validation`,{body:Object.keys(d).length>0?d:void 0})),{successLabel:`Updated`})}},qe={command:`schema-validation`,describe:`Zone-level API Gateway settings including schema validation behavior`,builder:e=>e.command(He).command(We).command(Ke).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Je={command:`settings`,describe:`Operations for settings`,builder:e=>e.command(qe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ye(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}).option(`kind`,{type:`string`,description:`Kind of schema`}).option(`name`,{type:`string`,description:`Name of the schema`}).option(`validation-enabled`,{type:`string`,description:`Flag whether schema is enabled for validation.`})}const Xe={command:`create`,describe:`Uploads a new OpenAPI schema for API Shield schema validation. The schema defines expected request/response formats for API endpoints.`,builder:Ye,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway user-schemas create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/user_schemas`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`multipart`,body:{body:e.body,file:e.file,kind:e.kind,name:e.name,validationEnabled:e.validationEnabled}});return}let n=await i(e);if(e.zoneId=await t({zone:e.zone},n,{quiet:e.quiet}),e.file!==void 0||e.body!==void 0||e.kind!==void 0||e.name!==void 0||e.validationEnabled!==void 0){let t=new FormData;if(e.file){let n=d(e.file);t.append(`file`,new Blob([n]),e.file.split(`/`).pop())}else e.body!==void 0&&t.append(`file`,e.body);e.kind!==void 0&&t.append(`kind`,String(u(e.kind,`kind`,`text`)??``)),e.name!==void 0&&t.append(`name`,String(u(e.name,`name`,`text`)??``)),e.validationEnabled!==void 0&&t.append(`validation_enabled`,String(u(e.validationEnabled,`validationEnabled`,`text`)??``)),s(await l(`Creating`,async()=>n.post(`/zones/${e.zoneId}/api_gateway/user_schemas`,{body:t})),{successLabel:`Created`});return}if(e.body){let t=u(e.body,`body`,`binary`);s(await l(`Creating`,async()=>n.post(`/zones/${e.zoneId}/api_gateway/user_schemas`,{body:t,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function Ze(e){return e.positional(`schemaId`,{type:`string`,description:`Schema ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const Qe={command:`delete <schemaId>`,describe:`Permanently removes an uploaded OpenAPI schema from API Shield schema validation. Operations using this schema will lose their validation rules.`,builder:Ze,handler:async n=>{if(n.dryRun){c({command:`cf api-gateway user-schemas delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${n.zoneId??`<zoneId>`}/api_gateway/user_schemas/${n.schemaId??`<schemaId>`}`,pathParams:{zoneId:String(n.zoneId??``),schemaId:String(n.schemaId??``)},bodyKind:`none`});return}let r=await i(n),a=await t({zone:n.zone},r,{quiet:n.quiet});if(n.zoneId=a,!await e({force:!!n.force})){process.stderr.write(`Aborted.
|
|
33
|
-
`);return}s(await l(`Deleting`,async()=>r.apiGateway.userSchemas.delete(a,n.schemaId)),{successLabel:`Deleted`})}};function $e(e){return e.positional(`schemaId`,{type:`string`,description:`Schema ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const et={command:`edit <schemaId>`,describe:`Activates schema validation for an uploaded OpenAPI schema. Requests to matching endpoints will be validated against the schema definitions.`,builder:$e,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway user-schemas edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/user_schemas/${e.schemaId??`<schemaId>`}`,pathParams:{zoneId:String(e.zoneId??``),schemaId:String(e.schemaId??``)},bodyKind:`json`,body:{body:e.body}});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});if(e.zoneId=r,e.body){let t=o(e.body);s(await l(`Updating`,async()=>n.patch(`/zones/${e.zoneId}/api_gateway/user_schemas/${e.schemaId}`,{body:t})),{successLabel:`Updated`});return}s(await l(`Updating`,async()=>n.apiGateway.userSchemas.edit(r,e.schemaId)),{successLabel:`Updated`})}};function tt(e){return e.positional(`schemaId`,{type:`string`,description:`Schema ID`,demandOption:!0}).option(`omit-source`,{type:`boolean`,description:`Omit the source-files of schemas and only retrieve their meta-data.`,default:!1}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const $={command:`get <schemaId>`,describe:`Gets detailed information about a specific uploaded OpenAPI schema, including its contents and validation configuration.`,builder:tt,handler:async e=>{let n={omit_source:e.omitSource};if(e.dryRun){c({command:`cf api-gateway user-schemas get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/user_schemas/${e.schemaId??`<schemaId>`}`,pathParams:{zoneId:String(e.zoneId??``),schemaId:String(e.schemaId??``)},query:n,bodyKind:`none`});return}let r=await i(e),a=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a,s(await l(`Loading`,async()=>r.apiGateway.userSchemas.get(a,e.schemaId,n)),{successLabel:`Loaded`})}};function nt(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const rt={command:`list`,describe:`Lists all unique hosts found in uploaded OpenAPI schemas for the zone. Useful for understanding which domains have schema coverage.`,builder:nt,handler:async e=>{if(e.dryRun){c({command:`cf api-gateway user-schemas hosts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/user_schemas/hosts`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`none`});return}let n=await i(e),r=await t({zone:e.zone},n,{quiet:e.quiet});e.zoneId=r,s(await l(`Loading`,async()=>n.apiGateway.userSchemas.hosts.list(r)),{successLabel:`Loaded`})}},it={command:`hosts`,describe:`User-uploaded OpenAPI schemas for validating API request and response payloads`,builder:e=>e.command(rt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function at(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`omit-source`,{type:`boolean`,description:`Omit the source-files of schemas and only retrieve their meta-data.`,default:!1}).option(`validation-enabled`,{type:`string`,description:`Flag whether schema is enabled for validation.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ot={command:`list`,describe:`Lists all OpenAPI schemas uploaded to API Shield for the zone, including their validation status and associated operations.`,builder:at,handler:async e=>{let n={page:e.page,per_page:e.perPage,omit_source:e.omitSource,validation_enabled:e.validationEnabled};if(e.dryRun){c({command:`cf api-gateway user-schemas list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/user_schemas`,pathParams:{zoneId:String(e.zoneId??``)},query:n,bodyKind:`none`});return}let r=await i(e),a=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a,s(await l(`Loading`,async()=>r.apiGateway.userSchemas.list(a,n)),{successLabel:`Loaded`})}};function st(e){return e.option(`schema-id`,{type:`string`,description:`Schema ID`,demandOption:!0}).option(`feature`,{type:`string`,description:`Add feature(s) to the results. The feature name that is given here corresponds to the resulting feature object. Have a look at the top-level object description for more details on the specific meaning.`}).option(`host`,{type:`string`,description:`Filter results to only include the specified hosts.`}).option(`method`,{type:`string`,description:`Filter results to only include the specified HTTP methods.`}).option(`endpoint`,{type:`string`,description:`Filter results to only include endpoints containing this pattern.`}).option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`operation-status`,{type:`string`,description:"Filter results by whether operations exist in API Shield Endpoint Management or not. `new` will just return operations from the schema that do not exist in API Shield Endpoint Management. `existing` will just return operations from the schema that already exist in API Shield Endpoint Management.",choices:[`new`,`existing`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ct={command:`list`,describe:`Retrieves all operations from the schema. Operations that already exist in API Shield Endpoint Management will be returned as full operations.`,builder:st,handler:async e=>{let n={feature:e.feature,host:e.host,method:e.method,endpoint:e.endpoint,page:e.page,per_page:e.perPage,operation_status:e.operationStatus};if(e.dryRun){c({command:`cf api-gateway user-schemas operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/api_gateway/user_schemas/${e.schemaId??`<schemaId>`}/operations`,pathParams:{zoneId:String(e.zoneId??``),schemaId:String(e.schemaId??``)},query:n,bodyKind:`none`});return}let r=await i(e),a=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=a,s(await l(`Loading`,async()=>r.apiGateway.userSchemas.operations.list(a,e.schemaId,n)),{successLabel:`Loaded`})}},lt={command:`operations`,describe:`User-uploaded OpenAPI schemas for validating API request and response payloads`,builder:e=>e.command(ct).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ut={command:`user-schemas`,describe:`User-uploaded OpenAPI schemas for validating API request and response payloads`,builder:e=>e.command(Xe).command(Qe).command(et).command($).command(ot).command(it).command(lt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},dt={command:`api-gateway`,describe:`Discover, monitor, and protect your API endpoints with schema validation, abuse detection, and routing`,builder:e=>e.command(m).command(w).command(O).command(ie).command(Le).command(Be).command(Je).command(ut).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{dt as default};
|
package/dist/argo-tms9ZwHO.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{l as e,p as t,t as n}from"./auth-BlSmtIKd.mjs";import{n as r,t as i}from"./body-parser-Br-BoYk-.mjs";import{t as a}from"./output-D7_yAFVR.mjs";import{n as o,t as s}from"./progress-DZfTxbrx.mjs";import{n as c}from"./input-validation-zEO81MWN.mjs";function l(e){return e.option(`value`,{type:`string`,description:`Specifies the enablement value of Argo Smart Routing.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Configures the enablement of Argo Smart Routing.`})}const u={command:`edit`,describe:`Configures the value of the Argo Smart Routing enablement setting.`,builder:l,handler:async l=>{if(l.dryRun){o({command:`cf argo smart-routing edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${l.zoneId??`<zoneId>`}/argo/smart_routing`,pathParams:{zoneId:String(l.zoneId??``)},bodyKind:`json`,body:{value:l.value,body:l.body}});return}let u=await n(l);if(l.zoneId=await e({zone:l.zone},u,{quiet:l.quiet}),l.body){let e=i(l.body);a(await s(`Updating`,async()=>u.patch(`/zones/${l.zoneId}/argo/smart_routing`,{body:e})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await t(`value`,`Specifies the enablement value of Argo Smart Routing.`,[`on`,`off`]));let d={};l.value!==void 0&&r(d,[`value`],c(l.value,`value`,`text`)),a(await s(`Updating`,async()=>u.patch(`/zones/${l.zoneId}/argo/smart_routing`,{body:Object.keys(d).length>0?d:void 0})),{successLabel:`Updated`})}};function d(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const f={command:`get`,describe:`Retrieves the value of Argo Smart Routing enablement setting.`,builder:d,handler:async t=>{if(t.dryRun){o({command:`cf argo smart-routing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zoneId??`<zoneId>`}/argo/smart_routing`,pathParams:{zoneId:String(t.zoneId??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});t.zoneId=i,a(await s(`Loading`,async()=>r.argo.smartRouting.get(i)),{successLabel:`Loaded`})}},p={command:`smart-routing`,describe:`Route traffic through the fastest network paths to your origin using real-time latency data`,builder:e=>e.command(u).command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function m(e){return e.option(`value`,{type:`string`,description:`Enables Tiered Caching.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Update enablement of Tiered Caching.`})}const h={command:`edit`,describe:`Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of lower-tiers and upper-tiers. If content is not cached in lower-tier data centers (generally the ones closest to a visitor), the lower-tier must ask an upper-tier to see if it has the content. If the upper-tier does not have the content, only the upper-tier can ask the origin for content. This practice improves bandwidth efficiency by limiting the number of data centers that can ask the origin for content, which reduces origin load and makes websites more cost-effective to operate. Additionally, Tiered Cache concentrates connections to origin servers so they come from a small number of data centers rather than the full set of network locations. This results in fewer open connections using server resources.`,builder:m,handler:async l=>{if(l.dryRun){o({command:`cf argo tiered-caching edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${l.zoneId??`<zoneId>`}/argo/tiered_caching`,pathParams:{zoneId:String(l.zoneId??``)},bodyKind:`json`,body:{value:l.value,body:l.body}});return}let u=await n(l);if(l.zoneId=await e({zone:l.zone},u,{quiet:l.quiet}),l.body){let e=i(l.body);a(await s(`Updating`,async()=>u.patch(`/zones/${l.zoneId}/argo/tiered_caching`,{body:e})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await t(`value`,`Enables Tiered Caching.`,[`on`,`off`]));let d={};l.value!==void 0&&r(d,[`value`],c(l.value,`value`,`text`)),a(await s(`Updating`,async()=>u.patch(`/zones/${l.zoneId}/argo/tiered_caching`,{body:Object.keys(d).length>0?d:void 0})),{successLabel:`Updated`})}};function g(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get`,describe:`Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of lower-tiers and upper-tiers. If content is not cached in lower-tier data centers (generally the ones closest to a visitor), the lower-tier must ask an upper-tier to see if it has the content. If the upper-tier does not have the content, only the upper-tier can ask the origin for content. This practice improves bandwidth efficiency by limiting the number of data centers that can ask the origin for content, which reduces origin load and makes websites more cost-effective to operate. Additionally, Tiered Cache concentrates connections to origin servers so they come from a small number of data centers rather than the full set of network locations. This results in fewer open connections using server resources.`,builder:g,handler:async t=>{if(t.dryRun){o({command:`cf argo tiered-caching get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zoneId??`<zoneId>`}/argo/tiered_caching`,pathParams:{zoneId:String(t.zoneId??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});t.zoneId=i,a(await s(`Loading`,async()=>r.argo.tieredCaching.get(i)),{successLabel:`Loaded`})}},v={command:`tiered-caching`,describe:`Reduce origin load by having upper-tier data centers serve cache misses before reaching your origin`,builder:e=>e.command(h).command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},y={command:`argo`,describe:`Network optimization features that speed up and improve reliability of traffic to your origins`,builder:e=>e.command(p).command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as e,t,u as n}from"./auth-BlSmtIKd.mjs";import{t as r}from"./output-D7_yAFVR.mjs";import{n as i,t as a}from"./progress-DZfTxbrx.mjs";import{t as o}from"./local-VJaJ3BZ1.mjs";function s(e){return e.option(`id`,{type:`string`,description:`Finds a specific log by its ID.`}).option(`export`,{type:`boolean`,description:`Indicates that this request is an export of logs in CSV format.`,default:!1}).option(`action-type`,{type:`string`,description:`Filters by the action type.`}).option(`actor-ip`,{type:`string`,description:`Filters by the IP address of the request that made the change by specific IP address or valid CIDR Range.`}).option(`actor-email`,{type:`string`,description:`Filters by the email address of the actor that made the change.`}).option(`since`,{type:`string`,description:`Since`}).option(`before`,{type:`string`,description:`Before`}).option(`zone-name`,{type:`string`,description:`Filters by the name of the zone associated to the change.`}).option(`direction`,{type:`string`,description:`Changes the direction of the chronological sorting.`,choices:[`desc`,`asc`]}).option(`per-page`,{type:`number`,description:`Sets the number of results to return per page.`}).option(`page`,{type:`number`,description:`Defines which page of results to return.`}).option(`hide-user-logs`,{type:`boolean`,description:`Indicates whether or not to hide user level audit logs.`,default:!1}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const c={command:`list`,describe:`Gets a list of audit logs for an account. Can be filtered by who made the change, on which zone, and the timeframe of the change.`,builder:s,handler:async s=>{let c={id:s.id,export:s.export,"action.type":s.actionType,"actor.ip":s.actorIp,"actor.email":s.actorEmail,since:s.since,before:s.before,"zone.name":s.zoneName,direction:s.direction,per_page:s.perPage,page:s.page,hide_user_logs:s.hideUserLogs};if(s.dryRun){i({command:`cf audit-logs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/audit_logs`,pathParams:{},query:c,bodyKind:`none`});return}let l=await t(s),u=s.local?o:await e(l);s.accountId=u,r(await a(`Loading`,async()=>l.auditLogs.list(u,c)),{successLabel:`Loaded`})}},l={command:`audit-logs`,describe:`Immutable audit trail of actions taken by account members — who changed what and when`,builder:e=>e.command(c).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{l as default};
|
package/dist/auth-BlSmtIKd.mjs
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{o as e}from"./chunk-DH-VkVmc.mjs";import{i as t,r as n,t as r}from"./session-mW-s8ghP.mjs";import{D as i,H as a,P as o,V as s,_ as c,m as l,p as u,t as d,y as f,z as p}from"./dist-DvKjT2TT.mjs";import{n as m,t as h}from"./theme-BklJDrb2.mjs";import{c as ee,f as te,h as g,i as ne,m as _,o as re,r as ie,s as ae,t as oe}from"./dist-C_bu5HwZ.mjs";import{a as se,i as ce,n as le,r as ue}from"./config-BIfdEY0E.mjs";import{n as de,t as fe}from"./resolve-BuJRWSk0.mjs";import{chmodSync as pe,existsSync as v,mkdirSync as me,readFileSync as he,rmSync as ge,unlinkSync as _e,writeFileSync as ve}from"node:fs";import ye from"node:assert";import be,{dirname as y,join as b}from"node:path";import{platform as xe}from"node:os";import{exec as Se,spawnSync as Ce}from"node:child_process";import{webcrypto as we}from"node:crypto";import Te from"node:http";import{TextEncoder as Ee}from"node:util";import De from"node:url";import"node:process";import{execSync as Oe}from"child_process";import ke from"os";var Ae=Object.defineProperty,x=(e,t)=>Ae(e,`name`,{value:t,configurable:!0}),je=i();function Me(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}x(Me,`getLineColFromPtr`);function Ne(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
|
|
3
|
-
`,e===t&&(i+=` `.repeat(a+n+2),i+=`^
|
|
4
|
-
`))}return i}x(Ne,`makeCodeBlock`);var S=class extends Error{static{x(this,`TomlError`)}line;column;codeblock;constructor(e,t){let[n,r]=Me(t.toml,t.ptr),i=Ne(t.toml,n,r);super(`Invalid TOML document: ${e}
|
|
5
|
-
|
|
6
|
-
${i}`,t),this.line=n,this.column=r,this.codeblock=i}};function Pe(e,t){let n=0;for(;e[t-++n]===`\\`;);return--n&&n%2}x(Pe,`isEscaped`);function C(e,t=0,n=e.length){let r=e.indexOf(`
|
|
7
|
-
`,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}x(C,`indexOfNewline`);function w(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
|
|
8
|
-
`)return n;if(r===`\r`&&e[n+1]===`
|
|
9
|
-
`)return n+1;if(r<` `&&r!==` `||r===``)throw new S(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}x(w,`skipComment`);function T(e,t,n,r){let i;for(;(i=e[t])===` `||i===` `||!n&&(i===`
|
|
10
|
-
`||i===`\r`&&e[t+1]===`
|
|
11
|
-
`);)t++;return r||i!==`#`?t:T(e,w(e,t),n)}x(T,`skipVoid`);function Fe(e,t,n,r,i=!1){if(!r)return t=C(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=C(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
|
|
12
|
-
`||t===`\r`&&e[a+1]===`
|
|
13
|
-
`))return a}throw new S(`cannot find end of structure`,{toml:e,ptr:t})}x(Fe,`skipUntil`);function Ie(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=r.length-1;do t=e.indexOf(r,++t);while(t>-1&&n!==`'`&&Pe(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}x(Ie,`getStringEnd`);var Le=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i,Re=class e extends Date{static{x(this,`TomlDate`)}#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(Le);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}},ze=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,Be=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,Ve=/^[+-]?0[0-9_]/,He=/^[0-9a-f]{4,8}$/i,Ue={b:`\b`,t:` `,n:`
|
|
14
|
-
`,f:`\f`,r:`\r`,'"':`"`,"\\":`\\`};function E(e,t=0,n=e.length){let r=e[t]===`'`,i=e[t++]===e[t]&&e[t]===e[t+1];i&&(n-=2,e[t+=2]===`\r`&&t++,e[t]===`
|
|
15
|
-
`&&t++);let a=0,o,s=``,c=t;for(;t<n-1;){let n=e[t++];if(n===`
|
|
16
|
-
`||n===`\r`&&e[t]===`
|
|
17
|
-
`){if(!i)throw new S(`newlines are not allowed in strings`,{toml:e,ptr:t-1})}else if(n<` `&&n!==` `||n===``)throw new S(`control characters are not allowed in strings`,{toml:e,ptr:t-1});if(o){if(o=!1,n===`u`||n===`U`){let r=e.slice(t,t+=n===`u`?4:8);if(!He.test(r))throw new S(`invalid unicode escape`,{toml:e,ptr:a});try{s+=String.fromCodePoint(parseInt(r,16))}catch{throw new S(`invalid unicode escape`,{toml:e,ptr:a})}}else if(i&&(n===`
|
|
18
|
-
`||n===` `||n===` `||n===`\r`)){if(t=T(e,t-1,!0),e[t]!==`
|
|
19
|
-
`&&e[t]!==`\r`)throw new S(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:a});t=T(e,t)}else if(n in Ue)s+=Ue[n];else throw new S(`unrecognized escape sequence`,{toml:e,ptr:a});c=t}else !r&&n===`\\`&&(a=t-1,o=!0,s+=e.slice(c,a))}return s+e.slice(c,n-1)}x(E,`parseString`);function We(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=ze.test(e);if(i||Be.test(e)){if(Ve.test(e))throw new S(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new S(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new S(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new Re(e);if(!a.isValid())throw new S(`invalid value`,{toml:t,ptr:n});return a}x(We,`parseValue`);function Ge(e,t,n,r){let i=e.slice(t,n),a=i.indexOf(`#`);a>-1&&(w(e,a),i=i.slice(0,a));let o=i.trimEnd();if(!r){let n=i.indexOf(`
|
|
20
|
-
`,o.length);if(n>-1)throw new S(`newlines are not allowed in inline tables`,{toml:e,ptr:t+n})}return[o,a]}x(Ge,`sliceAndTrimEndOf`);function D(e,t,n,r,i){if(r===0)throw new S(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?Je(e,t,r,i):qe(e,t,r,i),c=n?Fe(e,s,`,`,n):s;if(s-c&&n===`}`){let t=C(e,s,c);if(t>-1)throw new S(`newlines are not allowed in inline tables`,{toml:e,ptr:t})}return[o,c]}let o;if(a===`"`||a===`'`){o=Ie(e,t);let r=E(e,t,o);if(n){if(o=T(e,o,n!==`]`),e[o]&&e[o]!==`,`&&e[o]!==n&&e[o]!==`
|
|
21
|
-
`&&e[o]!==`\r`)throw new S(`unexpected character encountered`,{toml:e,ptr:o});o+=+(e[o]===`,`)}return[r,o]}o=Fe(e,t,`,`,n);let s=Ge(e,t,o-+(e[o-1]===`,`),n===`]`);if(!s[0])throw new S(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=T(e,t+s[1]),o+=+(e[o]===`,`)),[We(s[0],e,t,i),o]}x(D,`extractValue`);var Ke=/^[a-zA-Z0-9-_]+[ \t]*$/;function O(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new S(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `)if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new S(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let s=Ie(e,t);if(s<0)throw new S(`unfinished string encountered`,{toml:e,ptr:t});r=e.indexOf(`.`,s);let c=e.slice(s,r<0||r>a?a:r),l=C(c);if(l>-1)throw new S(`newlines are not allowed in keys`,{toml:e,ptr:t+r+l});if(c.trimStart())throw new S(`found extra tokens after the string part`,{toml:e,ptr:s});if(a<s&&(a=e.indexOf(n,s),a<0))throw new S(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(E(e,t,s))}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!Ke.test(n))throw new S(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}while(r+1&&r<a);return[i,T(e,a+1,!0,!0)]}x(O,`parseKey`);function qe(e,t,n,r){let i={},a=new Set,o,s=0;for(t++;(o=e[t++])!==`}`&&o;){let c={toml:e,ptr:t-1};if(o===`
|
|
22
|
-
`)throw new S(`newlines are not allowed in inline tables`,c);if(o===`#`)throw new S(`inline tables cannot contain comments`,c);if(o===`,`)throw new S(`expected key-value, found comma`,c);if(o!==` `&&o!==` `){let o,c=i,l=!1,[u,d]=O(e,t-1);for(let n=0;n<u.length;n++){if(n&&(c=l?c[o]:c[o]={}),o=u[n],(l=Object.hasOwn(c,o))&&(typeof c[o]!=`object`||a.has(c[o])))throw new S(`trying to redefine an already defined value`,{toml:e,ptr:t});!l&&o===`__proto__`&&Object.defineProperty(c,o,{enumerable:!0,configurable:!0,writable:!0})}if(l)throw new S(`trying to redefine an already defined value`,{toml:e,ptr:t});let[f,p]=D(e,d,`}`,n-1,r);a.add(f),c[o]=f,t=p,s=e[t-1]===`,`?t-1:0}}if(s)throw new S(`trailing commas are not allowed in inline tables`,{toml:e,ptr:s});if(!o)throw new S(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}x(qe,`parseInlineTable`);function Je(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new S(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=w(e,t);else if(a!==` `&&a!==` `&&a!==`
|
|
23
|
-
`&&a!==`\r`){let a=D(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new S(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}x(Je,`parseArray`);function k(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}x(k,`peekTable`);function Ye(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=T(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=O(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new S(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=k(n[0],r,i,t?2:1);if(!c)throw new S(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=O(e,s),i=k(r[0],a,o,0);if(!i)throw new S(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=D(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=T(e,s,!0),e[s]&&e[s]!==`
|
|
24
|
-
`&&e[s]!==`\r`)throw new S(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=T(e,s)}return r}x(Ye,`parse`);var Xe=/^[a-z0-9-_]+$/i;function A(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}x(A,`extendedTypeOf`);function Ze(e){for(let t=0;t<e.length;t++)if(A(e[t])!==`object`)return!1;return e.length!=0}x(Ze,`isArrayOfTables`);function j(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}x(j,`formatString`);function M(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:r&&Number.isInteger(e)?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return j(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return Qe(e,n,r);if(t===`array`)return $e(e,n,r)}x(M,`stringifyValue`);function Qe(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=Xe.test(o)?o:j(o),i+=` = `,i+=M(e[o],A(e[o]),t-1,n)}return i+` }`}x(Qe,`stringifyInlineTable`);function $e(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=M(e[i],A(e[i]),t-1,n)}return r+` ]`}x($e,`stringifyArray`);function et(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
|
|
25
|
-
`}[[${t}]]
|
|
26
|
-
`,i+=N(0,e[a],t,n,r);return i}x(et,`stringifyArrayTable`);function N(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=A(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=Xe.test(c)?c:j(c);if(e===`array`&&Ze(t[c]))o+=(o&&`
|
|
27
|
-
`)+et(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
|
|
28
|
-
`)+N(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=M(t[c],e,r,i),a+=`
|
|
29
|
-
`}}return e&&(a||!o)&&(a=a?`[${e}]
|
|
30
|
-
${a}`:`[${e}]`),a&&o?`${a}
|
|
31
|
-
${o}`:a||o}x(N,`stringifyTable`);function tt(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(A(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=N(0,e,``,t,n);return r[r.length-1]===`
|
|
32
|
-
`?r:r+`
|
|
33
|
-
`}x(tt,`stringify`);var nt={parse:Ye,stringify:tt,TomlDate:Re,TomlError:S};function rt(){return{read:ot,write:at,clear:x(()=>ge(P()),`clear`),path:P}}x(rt,`defaultAuthConfigStorage`);var it=`config`;function P(){let e=u(),t=`${it}/${e===`production`?`default.toml`:`${e}.toml`}`;return be.join(f(),t)}x(P,`getAuthConfigFilePath`);function at(e){let t=P();me(be.dirname(t),{recursive:!0}),ve(t,nt.stringify(e),{encoding:`utf-8`,mode:384}),pe(t,384)}x(at,`writeAuthConfigFile`);function ot(){return s(a(P()))}x(ot,`readAuthConfigFile`);var st=!1;function F(e){let{configOverride:t,warningLogger:n}=e??{},r=e?.storage??rt(),i;try{i=t??r.read()}catch{return{}}let{oauth_token:a,refresh_token:o,expiration_time:s,scopes:c,api_token:l}=i;return a?{accessToken:{value:a,expiry:s??`2000-01-01:00:00:00+00:00`},refreshToken:{value:o??``},scopes:c}:l?(!st&&n&&(st=!0,n.warn(`It looks like you have used Wrangler v1's \`config\` command to login with an API token
|
|
34
|
-
from ${t===void 0?r.path():`in-memory config`}.
|
|
35
|
-
This is no longer supported in the current version of Wrangler.
|
|
36
|
-
If you wish to authenticate via an API token then please set the \`CLOUDFLARE_API_TOKEN\` environment variable.`)),{deprecatedApiToken:l}):{}}x(F,`readStoredAuthState`);var ct=c({variableName:`CLOUDFLARE_API_TOKEN`,deprecatedName:`CF_API_TOKEN`}),lt=c({variableName:`CLOUDFLARE_API_KEY`,deprecatedName:`CF_API_KEY`}),ut=c({variableName:`CLOUDFLARE_EMAIL`,deprecatedName:`CF_EMAIL`});function I(e){if(e?.allowGlobalAuthKey??!0){let e=lt(),t=ut();if(e&&t)return{authKey:e,authEmail:t}}let t=ct();if(t)return{apiToken:t}}x(I,`getAuthFromEnv`);function dt(e){let t=I(e);if(t)return t;let n=F({storage:e?.storage,warningLogger:e?.warningLogger});if(n.deprecatedApiToken)return{apiToken:n.deprecatedApiToken};if(n.accessToken?.value)return{apiToken:n.accessToken.value}}x(dt,`getAPIToken`);function ft(e){let t=dt(e);if(!t)throw new o(`No API token found.`,{telemetryMessage:`user auth missing api token`});return t}x(ft,`requireApiToken`);var pt=c({variableName:`WRANGLER_CLIENT_ID`,defaultValue:x(()=>u()===`staging`?`4b2ea6cc-9421-4761-874b-ce550e0e3def`:`54d11594-84e4-41aa-b438-e81b8fa78ee7`,`defaultValue`)}),L=c({variableName:`WRANGLER_AUTH_DOMAIN`,defaultValue:x(()=>u()===`staging`?`dash.staging.cloudflare.com`:`dash.cloudflare.com`,`defaultValue`)}),mt=c({variableName:`WRANGLER_AUTH_URL`,defaultValue:x(()=>`https://${L()}/oauth2/auth`,`defaultValue`)}),ht=c({variableName:`WRANGLER_TOKEN_URL`,defaultValue:x(()=>`https://${L()}/oauth2/token`,`defaultValue`)}),gt=c({variableName:`WRANGLER_REVOKE_URL`,defaultValue:x(()=>`https://${L()}/oauth2/revoke`,`defaultValue`)}),_t=c({variableName:`CLOUDFLARE_ACCESS_CLIENT_ID`}),vt=c({variableName:`CLOUDFLARE_ACCESS_CLIENT_SECRET`}),yt=c({variableName:`WRANGLER_CF_AUTHORIZATION_TOKEN`}),R={},z=new Map;function bt(){for(let e of Object.keys(R))delete R[e];z.clear()}x(bt,`clearAccessCaches`);async function xt(e,t){if(t.debug(`Checking if domain has Access enabled:`,e),z.has(e))return t.debug(`Using cached Access switch for:`,e,z.get(e)),z.get(e)??!1;t.debug(`Access switch not cached for:`,e);try{let n=new AbortController,r=setTimeout(()=>{n.abort()},1e3),i=await(0,je.fetch)(`https://${e}`,{redirect:`manual`,signal:n.signal});clearTimeout(r);let a=!!(i.status===302&&i.headers.get(`location`)?.includes(`cloudflareaccess.com`));return t.debug(`Caching access switch for:`,e),z.set(e,a),a}catch{return z.set(e,!1),!1}}x(xt,`domainUsesAccess`);async function St(e,t){let n=t.logger,r=t.isNonInteractiveOrCI,i=_t(),a=vt();if(i&&a){n.debug(`Using Access Service Token headers for domain:`,e);let t={"CF-Access-Client-Id":i,"CF-Access-Client-Secret":a};return R[e]=t,t}if((i!==void 0||a!==void 0)&&n.warn(`Both CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET must be set to use Access Service Token authentication. Only ${i===void 0?`CLOUDFLARE_ACCESS_CLIENT_SECRET`:`CLOUDFLARE_ACCESS_CLIENT_ID`} was found.`),!await xt(e,n))return{};if(n.debug(`Getting Access headers for domain:`,e),R[e])return n.debug(`Using cached Access headers for domain:`,e),R[e];if(r())throw new o(`The domain "${e}" is behind Cloudflare Access, but no Access Service Token credentials were found and the current environment is non-interactive.
|
|
37
|
-
Set the CLOUDFLARE_ACCESS_CLIENT_ID and CLOUDFLARE_ACCESS_CLIENT_SECRET environment variables to authenticate with an Access Service Token.
|
|
38
|
-
See https://developers.cloudflare.com/cloudflare-one/access-controls/service-credentials/service-tokens/`,{telemetryMessage:`user access missing service token non interactive`});n.debug(`Spawning cloudflared to get Access token for domain:`);let s=Ce(`cloudflared`,[`access`,`login`,e]);if(s.error)throw new o("To use Wrangler with Cloudflare Access, please install `cloudflared` from https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation",{telemetryMessage:`user access missing cloudflared`});let c=s.stdout.toString();n.debug(`cloudflared output:`,c);let l=c.match(/fetched your token:\n\n(.*)/m);if(l&&l.length>=2){let t={Cookie:`CF_Authorization=${l[1]}`};return R[e]=t,n.debug(`Caching Access headers for domain:`,e),t}throw Error(`Failed to authenticate with Cloudflare Access`)}x(St,`getAccessHeaders`);async function Ct(e){let t=yt();return t===void 0?St(L(),e):(e.logger.debug(`Using WRANGLER_CF_AUTHORIZATION_TOKEN from environment`),{Cookie:`CF_Authorization=${t}`})}x(Ct,`getCloudflareAccessHeaders`);var B=class extends o{static{x(this,`ErrorOAuth2`)}code;description;uri;toString(){return`ErrorOAuth2`}},wt=class extends B{static{x(this,`ErrorUnknown`)}toString(){return`ErrorUnknown`}},Tt=class extends B{static{x(this,`ErrorNoAuthCode`)}toString(){return`ErrorNoAuthCode`}},Et=class extends B{static{x(this,`ErrorInvalidReturnedStateParam`)}toString(){return`ErrorInvalidReturnedStateParam`}},Dt=class extends B{static{x(this,`ErrorInvalidJson`)}toString(){return`ErrorInvalidJson`}},Ot=class extends B{static{x(this,`ErrorInvalidScope`)}toString(){return`ErrorInvalidScope`}},kt=class extends B{static{x(this,`ErrorInvalidRequest`)}toString(){return`ErrorInvalidRequest`}},At=class extends B{static{x(this,`ErrorInvalidToken`)}toString(){return`ErrorInvalidToken`}},V=class extends B{static{x(this,`ErrorAuthenticationGrant`)}toString(){return`ErrorAuthenticationGrant`}},jt=class extends V{static{x(this,`ErrorUnauthorizedClient`)}toString(){return`ErrorUnauthorizedClient`}},Mt=class extends V{static{x(this,`ErrorAccessDenied`)}toString(){return`ErrorAccessDenied`}},Nt=class extends V{static{x(this,`ErrorUnsupportedResponseType`)}toString(){return`ErrorUnsupportedResponseType`}},Pt=class extends V{static{x(this,`ErrorServerError`)}toString(){return`ErrorServerError`}},Ft=class extends V{static{x(this,`ErrorTemporarilyUnavailable`)}toString(){return`ErrorTemporarilyUnavailable`}},H=class extends B{static{x(this,`ErrorAccessTokenResponse`)}toString(){return`ErrorAccessTokenResponse`}},It=class extends H{static{x(this,`ErrorInvalidClient`)}toString(){return`ErrorInvalidClient`}},Lt=class extends H{static{x(this,`ErrorInvalidGrant`)}toString(){return`ErrorInvalidGrant`}},Rt=class extends H{static{x(this,`ErrorUnsupportedGrantType`)}toString(){return`ErrorUnsupportedGrantType`}};function zt(e,t,n){let r=`OAuth error: ${e}`;return t&&(r+=`
|
|
39
|
-
${t}`),n&&(r+=`
|
|
40
|
-
See: ${n}`),r}x(zt,`formatOAuthErrorMessage`);function U(e,t,n){let r=zt(e,t,n),i;switch(e){case`invalid_request`:i=new kt(r,{telemetryMessage:`user oauth invalid request`});break;case`invalid_grant`:i=new Lt(r,{telemetryMessage:`user oauth invalid grant`});break;case`unauthorized_client`:i=new jt(r,{telemetryMessage:`user oauth unauthorized client`});break;case`access_denied`:i=new Mt(r,{telemetryMessage:`user oauth access denied`});break;case`unsupported_response_type`:i=new Nt(r,{telemetryMessage:`user oauth unsupported response type`});break;case`invalid_scope`:i=new Ot(r,{telemetryMessage:`user oauth invalid scope`});break;case`server_error`:i=new Pt(r,{telemetryMessage:`user oauth server error`});break;case`temporarily_unavailable`:i=new Ft(r,{telemetryMessage:`user oauth temporarily unavailable`});break;case`invalid_client`:i=new It(r,{telemetryMessage:`user oauth invalid client`});break;case`unsupported_grant_type`:i=new Rt(r,{telemetryMessage:`user oauth unsupported grant type`});break;case`invalid_json`:i=new Dt(r,{telemetryMessage:`user oauth invalid json`});break;case`invalid_token`:i=new At(r,{telemetryMessage:`user oauth invalid token`});break;default:i=new wt(r,{telemetryMessage:`user oauth unknown error`});break}return i.code=e,i.description=t,i.uri=n,i}x(U,`toErrorClass`);function Bt(e){var t=[...arguments].slice(1),n=Array.from(typeof e==`string`?[e]:e);n[n.length-1]=n[n.length-1].replace(/\r?\n([\t ]*)$/,``);var r=n.reduce(function(e,t){var n=t.match(/\n([\t ]+|(?!\s).)/g);return n?e.concat(n.map(function(e){return e.match(/[\t ]/g)?.length??0})):e},[]);if(r.length){var i=RegExp(`
|
|
41
|
-
[ ]{`+Math.min.apply(Math,r)+`}`,`g`);n=n.map(function(e){return e.replace(i,`
|
|
42
|
-
`)})}n[0]=n[0].replace(/^\r?\n/,``);var a=n[0];return t.forEach(function(e,t){var r=a.match(/(?:^|\n)( *)$/),i=r?r[1]:``,o=e;typeof e==`string`&&e.includes(`
|
|
43
|
-
`)&&(o=String(e).split(`
|
|
44
|
-
`).map(function(e,t){return t===0?e:``+i+e}).join(`
|
|
45
|
-
`)),a+=o+n[t+1]}),a}x(Bt,`dedent`);var Vt=Bt,Ht=`http://localhost:8976/oauth/callback`,Ut=x(({authUrl:e,clientId:t,scopes:n,stateQueryParam:r,codeChallenge:i,redirectUri:a=Ht})=>e+`?response_type=code&client_id=${encodeURIComponent(t)}&redirect_uri=${encodeURIComponent(a)}&scope=${encodeURIComponent([...n,`offline_access`].join(` `))}&state=${r}&code_challenge=${encodeURIComponent(i)}&code_challenge_method=S256`,`generateAuthUrl`),W=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~`;function Wt(e){let t=btoa(e);return t=t.replace(/\+/g,`-`),t=t.replace(/\//g,`_`),t=t.replace(/=/g,``),t}x(Wt,`base64urlEncode`);async function Gt(){let e=new Uint32Array(96);we.getRandomValues(e);let t=Wt(Array.from(e).map(e=>W[e%W.length]).join(``)),n=await we.subtle.digest(`SHA-256`,new Ee().encode(t)),r=new Uint8Array(n),i=``,a=r.byteLength;for(let e=0;e<a;e++)i+=String.fromCharCode(r[e]);return{codeChallenge:Wt(i),codeVerifier:t}}x(Gt,`generatePKCECodes`);function Kt(e,t,n){if(e.error)throw U(Array.isArray(e.error)?e.error[0]:e.error,Array.isArray(e.error_description)?e.error_description[0]:e.error_description,Array.isArray(e.error_uri)?e.error_uri[0]:e.error_uri);let r=e.code;if(!r)return!1;if(e.state!==t.stateQueryParam)throw n.warn(`Received query string parameter doesn't match the one sent! Possible malicious activity somewhere.`),new Et(``,{telemetryMessage:`user oauth invalid returned state`});return ye(!Array.isArray(r)),t.authorizationCode=r,t.hasAuthCodeBeenExchangedForAccessToken=!1,!0}x(Kt,`isReturningFromAuthServer`);async function qt(e,t,n,r,i){let{codeChallenge:a,codeVerifier:o}=await Gt(),s=i.generateRandomState(32);return Object.assign(r,{codeChallenge:a,codeVerifier:o,stateQueryParam:s}),i.generateAuthUrl({authUrl:mt(),clientId:t,scopes:e,stateQueryParam:s,codeChallenge:a,redirectUri:n})}x(qt,`getAuthURL`);async function Jt(e,t,n,r){let i=F({warningLogger:e,storage:r}).refreshToken;i||e.warn(`No refresh token is present.`);let a=await Xt(new URLSearchParams({grant_type:`refresh_token`,refresh_token:i?.value??``,client_id:n}),e,t);if(a.status>=400){let t;try{t=await G(a,e)}catch(t){e.error(t)}throw t===void 0?new wt(`Failed to parse Error from exchangeRefreshTokenForAccessToken`,{telemetryMessage:`user oauth refresh token exchange parse error`}):typeof t==`string`?Error(t):t}else try{let t=await G(a,e);if(`error`in t)throw t.error;let{access_token:n,expires_in:r,refresh_token:o,scope:s}=t;return{token:{value:n,expiry:new Date(Date.now()+r*1e3).toISOString()},scopes:s?s.split(` `):[],refreshToken:o?{value:o}:i}}catch(e){throw typeof e==`string`?U(e):e}}x(Jt,`exchangeRefreshTokenForAccessToken`);async function Yt(e,t,n,r,i=Ht){let{authorizationCode:a,codeVerifier:o=``}=e;o?a||t.warn(`No authorization grant code is being passed.`):t.warn(`No code verifier is being sent.`);let s=await Xt(new URLSearchParams({grant_type:`authorization_code`,code:a??``,redirect_uri:i,client_id:r,code_verifier:o}),t,n);if(!s.ok){let{error:e}=await G(s,t);throw e===`invalid_grant`&&t.log(`Expired! Auth code or refresh token needs to be renewed.`),U(e)}let c=await G(s,t);if(`error`in c)throw U(c.error);let{access_token:l,expires_in:u,refresh_token:d,scope:f}=c;return e.hasAuthCodeBeenExchangedForAccessToken=!0,{token:{value:l,expiry:new Date(Date.now()+u*1e3).toISOString()},scopes:f?f.split(` `):[],refreshToken:d?{value:d}:void 0}}x(Yt,`exchangeAuthCodeForAccessToken`);async function Xt(e,t,n){let r={"Content-Type":`application/x-www-form-urlencoded`};if(t.debug(`fetching auth token`,`grant_type=${e.get(`grant_type`)??`<unknown>`}`),await xt(L(),t)){t.debug(`Using Cloudflare Access to get an access token for the auth request`);let e=await Ct({logger:t,isNonInteractiveOrCI:n});Object.assign(r,e)}t.debug(`Fetching auth token from`,ht());try{let n=await(0,je.fetch)(ht(),{method:`POST`,body:e.toString(),headers:r});return n.ok||t.error(`Failed to fetch auth token:`,n.status,n.statusText),n}catch(e){throw t.error(`Failed to fetch auth token:`,e),e}}x(Xt,`fetchAuthToken`);async function G(e,t){let n=await e.text();try{return JSON.parse(n)}catch(r){throw n.match(/<!DOCTYPE html>/)&&(t.error(`The body of the response was HTML rather than JSON. Check the debug logs to see the full body of the response.`),n.match(/challenge-platform/)&&t.error(`It looks like you might have hit a bot challenge page. This may be transient but if not, please contact Cloudflare to find out what can be done. When you contact Cloudflare, please provide your Ray ID: ${e.headers.get(`cf-ray`)}`)),t.debug(`Full body of response
|
|
46
|
-
|
|
47
|
-
`,n),Error(`Invalid JSON in response: status: ${e.status} ${e.statusText}`,{cause:r})}}x(G,`getJSONFromResponse`);async function Zt(e,t,n,r){let i=await qt(e.scopes,e.clientId,e.redirectUri,t,r),a,s,c=new Promise((e,t)=>{s=setTimeout(()=>{a.close(),clearTimeout(s),t(new o(`Timed out waiting for authorization code, please try again.`,{telemetryMessage:`user oauth authorization timeout`}))},12e4)}),l=new Promise((r,i)=>{a=Te.createServer(async(c,l)=>{function u(e,t){clearTimeout(s),l.writableEnded||l.end(),a.close(n=>{t||n?i(t||n):(ye(e),r(e))})}x(u,`finish`);function d(e){let t=x(e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),`escape`),n=`<!doctype html>
|
|
48
|
-
<html lang="en">
|
|
49
|
-
<head>
|
|
50
|
-
<meta charset="utf-8" />
|
|
51
|
-
<title>Wrangler login failed</title>
|
|
52
|
-
<style>
|
|
53
|
-
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; max-width: 720px; margin: 4rem auto; padding: 0 1rem; color: #1f2933; line-height: 1.5; }
|
|
54
|
-
h1 { color: #c12d3f; }
|
|
55
|
-
code { background: #f5f7fa; padding: 0.15em 0.3em; border-radius: 3px; }
|
|
56
|
-
p.detail { background: #f5f7fa; padding: 1rem; border-radius: 4px; white-space: pre-wrap; }
|
|
57
|
-
</style>
|
|
58
|
-
</head>
|
|
59
|
-
<body>
|
|
60
|
-
<h1>Wrangler login failed</h1>
|
|
61
|
-
<p>The Cloudflare OAuth provider returned an error.</p>
|
|
62
|
-
${e.code?`<p>Code: <code>${t(e.code)}</code></p>`:``}
|
|
63
|
-
${e.description?`<p class="detail">${t(e.description)}</p>`:``}
|
|
64
|
-
<p>You can close this tab and return to your terminal for more details.</p>
|
|
65
|
-
</body>
|
|
66
|
-
</html>`;l.writeHead(400,{"Content-Type":`text/html; charset=utf-8`}),l.end(n)}x(d,`renderErrorPage`),ye(c.url,`This request doesn't have a URL`);let{pathname:f,query:p}=De.parse(c.url,!0);if(c.method!==`GET`)return l.end(`OK`);switch(f){case`/oauth/callback`:{let r=!1;try{r=Kt(p,t,n.logger)}catch(t){if(t instanceof Mt){l.writeHead(307,{Location:e.denied.url}),l.end(()=>{u(null,new o(e.denied.error,{telemetryMessage:`user oauth consent denied`}))});return}let n=t;d({code:n.code,description:n.description??n.message}),u(null,n);return}if(!r){let e=`The Cloudflare OAuth provider did not return an authorisation code.`;d({description:e}),u(null,new Tt(e,{telemetryMessage:`user oauth missing auth code`}));return}try{let r=await Yt(t,n.logger,n.isNonInteractiveOrCI,e.clientId,e.redirectUri);l.writeHead(307,{Location:e.granted.url}),l.end(()=>{u(r)})}catch(e){let t=e,n=t instanceof B;d({code:n?t.code:void 0,description:(n?t.description:void 0)??t.message??`Failed to exchange the authorisation code for an access token.`}),u(null,t)}return}}});let c=new URL(e.redirectUri),l=Number(c.port||(c.protocol===`https:`?443:80));(c.hostname!==e.callbackHost||l!==e.callbackPort)&&(n.logger.log(`Temporary login server listening on ${e.callbackHost}:${e.callbackPort}`),n.logger.log(`Note that the OAuth login page will always redirect to \`${e.redirectUri}\`.
|
|
67
|
-
If you have changed the callback host or port because you are running in a container, then ensure that you have port forwarding set up correctly.`)),a.once(`error`,t=>{clearTimeout(s),t.code===`EADDRINUSE`?i(new o(`The OAuth callback server could not bind to ${e.callbackHost}:${e.callbackPort} because the port is already in use. Stop the process using that port or pass a different \`--callback-port\`.`,{telemetryMessage:`user oauth callback port in use`})):i(t)}),a.listen(e.callbackPort,e.callbackHost)});return e.browser?(n.logger.log(`Opening a link in your default browser: ${i}`),await n.openInBrowser(i)):n.logger.log(`Visit this link to authenticate: ${i}`),Promise.race([c,l])}x(Zt,`getOauthToken`);function Qt(e){let t=new Uint32Array(e);return we.getRandomValues(t),Array.from(t).map(e=>W[e%W.length]).join(``)}x(Qt,`generateRandomState`);var $t={granted:{url:`https://welcome.developers.workers.dev/wrangler-oauth-consent-granted`},denied:{url:`https://welcome.developers.workers.dev/wrangler-oauth-consent-denied`,error:"Error: Consent denied. You must grant consent to Wrangler in order to login.\nIf you don't want to do this consider passing an API token via the `CLOUDFLARE_API_TOKEN` environment variable"}};function en(e){let t={},n={generateAuthUrl:e.generateAuthUrl??Ut,generateRandomState:e.generateRandomState??Qt},r=e.storage??rt(),i=x(()=>e.clientId??pt(),`getClientId`),a=e.consent??$t,s=e.callback?.redirectUri??`http://localhost:8976/oauth/callback`;async function c(c){if(e.hasEnvCredentials())return e.logger.error(`You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log in via OAuth.`),!1;let u=l(c.complianceConfig);if(u===`fedramp_high`)throw new o(Vt`
|
|
68
|
-
OAuth login is not supported in the \`${u}\` compliance region.
|
|
69
|
-
Please use a Cloudflare API token (\`CLOUDFLARE_API_TOKEN\` environment variable) or remove the ${c.complianceConfig?.compliance_region?"`compliance_region` configuration property":"`CLOUDFLARE_API_ENVIRONMENT` environment variable"}.
|
|
70
|
-
`,{telemetryMessage:`user login unsupported compliance region`});e.logger.log(`Attempting to login via OAuth...`);let d=await Zt({browser:c.browser??!0,scopes:c.scopes,clientId:i(),redirectUri:s,denied:a.denied,granted:a.granted,callbackHost:c.callbackHost??e.callback?.host??`localhost`,callbackPort:c.callbackPort??e.callback?.port??8976},t,e,n);return r.write({oauth_token:d.token?.value??``,expiration_time:d.token?.expiry,refresh_token:d.refreshToken?.value,scopes:d.scopes}),e.logger.log(`Successfully logged in.`),e.purgeOnLoginOrLogout?.(),!0}x(c,`login`);function u(){if(e.hasEnvCredentials())return!1;let{accessToken:t}=F({warningLogger:e.logger,storage:r});return!!(t&&new Date>=new Date(t.expiry))}x(u,`isRefreshNeeded`);async function d(){try{let{token:{value:t,expiry:n}={value:``,expiry:``},refreshToken:{value:a}={},scopes:o}=await Jt(e.logger,e.isNonInteractiveOrCI,i(),r);return r.write({oauth_token:t,expiration_time:n,refresh_token:a,scopes:o}),!0}catch(t){return e.logger.debug(`Token refresh failed: ${t instanceof Error?t.message:String(t)}`),!1}}x(d,`refreshToken`);async function f(t){if(e.hasEnvCredentials())return!0;let n=F({warningLogger:e.logger,storage:r});return!n.accessToken&&!n.deprecatedApiToken?!e.isNonInteractiveOrCI()&&await c(t):u()?await d()?!0:!e.isNonInteractiveOrCI()&&await c(t):!0}x(f,`loginOrRefreshIfRequired`);async function p(){if(e.hasEnvCredentials()){e.logger.log(`You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log out.`);return}let t=F({warningLogger:e.logger,storage:r}).refreshToken;if(!t){e.logger.log(`Not logged in, exiting...`);return}let n=`client_id=${encodeURIComponent(i())}&token_type_hint=refresh_token&token=${encodeURIComponent(t.value||``)}`;await(await(0,je.fetch)(gt(),{method:`POST`,body:n,headers:{"Content-Type":`application/x-www-form-urlencoded`}})).text(),r.clear(),e.logger.log(`Successfully logged out.`),e.purgeOnLoginOrLogout?.()}x(p,`logout`);async function m(){let t=F({warningLogger:e.logger,storage:r});if(t.accessToken){if(t.accessToken&&new Date>=new Date(t.accessToken.expiry)){if(!await d())return;t=F({warningLogger:e.logger,storage:r})}return t.accessToken?.value}}return x(m,`getOAuthTokenFromLocalState`),{login:c,logout:p,loginOrRefreshIfRequired:f,getOAuthTokenFromLocalState:m,isRefreshNeeded:u,refreshToken:d}}x(en,`createOAuthFlow`);const{white:tn,gray:nn,dim:rn,hidden:an,bold:on,cyanBright:sn,bgCyan:cn}=g;g.hex(`#BD5B08`);const K=g.hex(`#111`);g.hex(`#0E838F`);const ln=K.bgHex(`#0E838F`);g.hex(`#AB2526`);const un=K.bgHex(`#AB2526`);g.hex(`#218529`);const dn=K.bgHex(`#218529`);g.hex(`#7F7322`);const fn=K.bgHex(`#7F7322`),pn=process.stdout;process.stderr;var mn=e(ee(),1);const hn={diamond:`◇`,dash:`─`,radioInactive:`○`,radioActive:`●`,backActive:`◀`,backInactive:`◁`,bar:`│`,leftT:`├`,rigthT:`┤`,arrows:{left:`‹`,right:`›`},corners:{tl:`╭`,bl:`╰`,tr:`╮`,br:`╯`}};un(` ERROR `),fn(` WARNING `),ln(` INFO `),dn(` SUCCESS `),tn.bgRed(` X `),ae(pn),nn(hn.bar),nn(hn.corners.bl),nn(hn.leftT);function gn(){try{return!!(process.stdin.isTTY&&process.stdout.isTTY)}catch{return!1}}function q(){return!gn()||mn.isCI}const _n=mn.isCI,vn=`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(`.`);function J(){return b(le(),`auth.jsonc`)}function yn(){return{read(){let e=J();return p(he(e,`utf-8`),e)},write(e){let t=J();me(y(t),{recursive:!0,mode:448}),ve(t,JSON.stringify(e,null,2)+`
|
|
71
|
-
`,{encoding:`utf-8`,mode:384}),pe(t,384)},clear(){ge(J(),{force:!0})},path(){return J()}}}const bn=8877,xn=`localhost`,Sn=`http://${xn}:${bn}/oauth/callback`,Cn={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"}},Y=yn();function wn(){return I({allowGlobalAuthKey:!1})!==void 0}const Tn={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)};function En(e){return new Promise((t,n)=>{let r=xe(),i;switch(r){case`darwin`:i=`open "${e}"`;break;case`win32`:i=`start "" "${e}"`;break;default:i=`xdg-open "${e}"`}Se(i,e=>{e?n(Error(`Failed to open browser: ${e.message}`)):t()})})}const Dn=en({logger:Tn,isNonInteractiveOrCI:q,openInBrowser:En,hasEnvCredentials:wn,clientId:`cbca97e7-c331-4cdd-8fd8-e25a451b98bf`,consent:Cn,callback:{host:xn,port:bn,redirectUri:Sn},storage:Y});function On(e){return Dn.login({complianceConfig:d,scopes:[...vn],browser:e?.browser??!0})}function kn(){return Dn.logout()}function An(){return Dn.getOAuthTokenFromLocalState()}function jn(){return F({storage:Y}).accessToken!==void 0}function Mn(){return F({storage:Y})}function Nn(){return Y.path()}function Pn(e){try{let t=Oe(`ps -p ${e} -o pid=,ppid=,command=`,{encoding:`utf8`,timeout:5e3}).trim();if(!t)return null;let[n,r,...i]=t.split(/\s+/),a=n?parseInt(n,10):NaN,o=r?parseInt(r,10):NaN;return isNaN(a)||isNaN(o)?null:{pid:a,ppid:o,command:i.join(` `)||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function Fn(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=Pn(r);if(!e||e.ppid===0||e.ppid===1)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function In(e){try{let t=Oe(`wmic process where (ProcessId=${e}) get ProcessId,ParentProcessId,CommandLine /format:csv`,{encoding:`utf8`,timeout:1e4});if(!t)return null;let n=t.split(`
|
|
72
|
-
`).filter(e=>e.trim()&&!e.startsWith(`Node`)).pop()?.split(`,`);if(!n||n.length<4)return null;let[r,i,a,o]=n,s=o?parseInt(o.trim(),10):NaN,c=a?parseInt(a.trim(),10):NaN;return isNaN(s)||isNaN(c)?null:{pid:s,ppid:c,command:i?.trim()||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function Ln(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=In(r);if(!e||e.ppid===0||e.ppid===4)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function Rn(e=process.pid){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(`PID must be a positive integer`);return ke.platform()===`win32`?Ln(e):Fn(e)}const zn=[{id:`opencode`,name:`OpenCode`,type:`agent`,envVars:[{any:[`OPENCODE`,`OPENCODE_BIN_PATH`,`OPENCODE_SERVER`,`OPENCODE_APP_INFO`,`OPENCODE_MODES`]}]},{id:`jules`,name:`Jules`,type:`agent`,envVars:[{all:[[`HOME`,`/home/jules`],[`USER`,`swebot`]]}]},{id:`claude-code`,name:`Claude Code`,type:`agent`,envVars:[`CLAUDECODE`]},{id:`cursor-agent`,name:`Cursor Agent`,type:`agent`,envVars:[{all:[`CURSOR_TRACE_ID`,[`PAGER`,`head -n 10000 | cat`]]}]},{id:`cursor`,name:`Cursor`,type:`interactive`,envVars:[`CURSOR_TRACE_ID`]},{id:`gemini-agent`,name:`Gemini Agent`,type:`agent`,processChecks:[`gemini`]},{id:`codex`,name:`OpenAI Codex`,type:`agent`,processChecks:[`codex`]},{id:`replit`,name:`Replit`,type:`agent`,envVars:[`REPL_ID`]},{id:`aider`,name:`Aider`,type:`agent`,envVars:[`AIDER_API_KEY`],processChecks:[`aider`]},{id:`bolt-agent`,name:`Bolt.new Agent`,type:`agent`,envVars:[{all:[[`SHELL`,`/bin/jsh`],`npm_config_yes`]}]},{id:`bolt`,name:`Bolt.new`,type:`interactive`,envVars:[{all:[[`SHELL`,`/bin/jsh`]],none:[`npm_config_yes`]}]},{id:`zed-agent`,name:`Zed Agent`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`zed`],[`PAGER`,`cat`]]}]},{id:`zed`,name:`Zed`,type:`interactive`,envVars:[{all:[[`TERM_PROGRAM`,`zed`]],none:[[`PAGER`,`cat`]]}]},{id:`replit-assistant`,name:`Replit Assistant`,type:`agent`,envVars:[{all:[`REPL_ID`,[`REPLIT_MODE`,`assistant`]]}]},{id:`replit`,name:`Replit`,type:`interactive`,envVars:[{all:[`REPL_ID`],none:[[`REPLIT_MODE`,`assistant`]]}]},{id:`windsurf`,name:`Windsurf`,type:`agent`,envVars:[`CODEIUM_EDITOR_APP_ROOT`]},{id:`crush`,name:`Crush`,type:`agent`,processChecks:[`crush`]},{id:`vscode-copilot-agent`,name:`GitHub Copilot in VS Code`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`vscode`],[`GIT_PAGER`,`cat`]]}]},{id:`warp`,name:`Warp Terminal`,type:`hybrid`,envVars:[{all:[[`TERM_PROGRAM`,`WarpTerminal`]]}]},{id:`octofriend`,name:`Octofriend`,type:`agent`,processChecks:[`octofriend`]}];function X(e,t=process.env){let[n,r]=typeof e==`string`?[e,void 0]:e,i=t[n];return!!(i&&(!r||i===r))}function Bn(e,t){try{let n=t??Rn();for(let t of n)if(t.command?.includes(e))return!0}catch{}return!1}function Vn(e,t=process.env){if(typeof e==`string`||Array.isArray(e))return X(e,t);let{any:n,all:r,none:i}=e,a=!n?.length||n.some(e=>X(e,t)),o=!r?.length||r.every(e=>X(e,t)),s=!i?.length||!i.some(e=>X(e,t));return a&&o&&s}function Hn(e){return e.customDetectors?.some(e=>{try{return e()}catch{return!1}})??!1}function Un(e){return{isAgentic:!0,id:e.id,name:e.name,type:e.type}}function Wn(e=process.env,t){for(let t of zn)if(t.envVars?.some(t=>Vn(t,e)))return Un(t);let n=t,r=()=>{if(n===void 0)try{n=Rn()}catch{n=[]}return n};for(let e of zn)if(e.processChecks?.some(e=>Bn(e,r())))return Un(e);for(let e of zn)if(Hn(e))return Un(e);return{isAgentic:!1,id:null,name:null,type:null}}function Gn(){return _n?`ci`:gn()?`interactive`:`non-interactive`}function Kn(){let e=Wn(),t=e.isAgentic&&e.id!==null?{"X-CF-CLI-Agent":e.id}:{};return{"User-Agent":`cf/${n}`,"X-CF-CLI-Mode":Gn(),...t}}function qn(){r(n)}async function Jn(e){let t=m(),n=e.map(e=>({value:e,label:e.name})),r=await new te({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(h.muted)(`${i.id.slice(0,12)}...`);return r?` ${t.hex(h.orange)(`>`)} ${t.bold(i.name)} ${a}`:` ${t.dim(i.name)} ${a}`});return`${e} ${t.dim(`(use arrow keys, enter to confirm)`)}\n${n.join(`
|
|
73
|
-
`)}`}}).prompt();return _(r)||!r?null:r}async function Yn(){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(`
|
|
74
|
-
`)?t.slice(0,-1):t}async function Xn(e,t,n){let r=n?.kind??`text`;if(q()){if(r===`secret`){let t=await Yn();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;qn();let o=r===`secret`?await ie({message:a,mask:`•`,validate:e=>e&&e.length>0?void 0:`Value cannot be empty`}):await re({message:a,validate:e=>e&&e.length>0?void 0:`Value cannot be empty`});return(_(o)||typeof o!=`string`)&&process.exit(130),o}async function Zn(e,t,n){if(q())throw Error(`--${e} is required (one of: ${n.join(`, `)}). Pass --${e} <value> or run interactively.`);let r=`Select value for --${e}`,i=t||r;qn();let a=await ne({message:i,options:n.map(e=>({value:e,label:e}))});return(_(a)||typeof a!=`string`)&&process.exit(130),a}async function Qn(e={}){if(e.force===!0)return!0;let t=e.message?`${e.message} Continue?`:`This permanently deletes the resource. Continue?`;if(q()){let e=m();return process.stderr.write(`${e.hex(h.warning)(`?`)} ${t}\n ${e.dim(`(non-interactive; pass --force to confirm)`)}\n`),!1}qn();let n=await oe({message:t,initialValue:!1});return _(n)&&process.exit(130),n===!0}const Z=`.cfrc`;function Q(e){let t=e||process.cwd(),n=y(t);for(;t!==n;){let e=b(t,Z);if(v(e))try{let t=he(e,`utf-8`).replace(/^\s*\/\/.*$/gm,``);return{config:JSON.parse(t),path:e}}catch{}t=y(t)}let r=b(t,Z);if(v(r))try{let e=he(r,`utf-8`).replace(/^\s*\/\/.*$/gm,``);return{config:JSON.parse(e),path:r}}catch{}return null}function $n(e,t){ve(b(t||process.cwd(),Z),JSON.stringify(e,null,2)+`
|
|
75
|
-
`,{mode:384})}function er(e){let t=b(e||process.cwd(),Z);return v(t)?(_e(t),!0):!1}async function tr(e){let t={},n=$(`accountId`,`CLOUDFLARE_ACCOUNT_ID`);n&&(t.accountId=n);let r=$(`zone`,`CLOUDFLARE_ZONE_ID`,e?.zone);return r&&(t.zone=r),t}function $(e,t,n){if(n)return{value:n,source:`flag`};let r=process.env[t];if(r)return{value:r,source:`env`};let i=Q(),a=i?.config[e];if(a)return{value:a,source:`project`,path:i.path};let o=ce().defaults?.[e];if(o)return{value:o,source:`config`,path:ue()}}function nr(){return $(`accountId`,`CLOUDFLARE_ACCOUNT_ID`)?.value}async function rr(e){let t=$(`accountId`,`CLOUDFLARE_ACCOUNT_ID`);if(t)return ir(t.value,lr(t,`accountId`)),t.value;if(e){let t=await ar(e);if(t)return t}throw Error(`No account ID found.
|
|
76
|
-
|
|
77
|
-
Please provide one of the following:
|
|
78
|
-
1. CLOUDFLARE_ACCOUNT_ID environment variable
|
|
79
|
-
2. Run 'cf context set account-id <id>' to set a default
|
|
80
|
-
3. Create a .cfrc file in your project
|
|
81
|
-
|
|
82
|
-
You can find your account ID in the Cloudflare dashboard URL:
|
|
83
|
-
https://dash.cloudflare.com/<account-id>/...`)}function ir(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 ar(e){let t;try{t=await fr(e)}catch{return}if(t.length===0)return;if(t.length===1&&t[0]){let n=t[0],{displayName:r}=await ur(`accountId`,n.id,`user`,e);return ir(n.id,`auto-selected from token — ${r}`),n.id}if(q()){let e=t.map(e=>` ${e.id} ${e.name}`).join(`
|
|
84
|
-
`);throw Error(`Multiple accounts available but running non-interactively.
|
|
85
|
-
|
|
86
|
-
Available accounts:
|
|
87
|
-
${e}
|
|
88
|
-
|
|
89
|
-
Set one with CLOUDFLARE_ACCOUNT_ID or 'cf context set account-id'.`)}let n=await Jn(t);n||process.exit(130);let{displayName:r}=await ur(`accountId`,n.id,`user`,e);return ir(n.id,`selected interactively — ${r}`),n.id}async function or(e,t,n){if(e?.zoneId)return sr(e.zoneId,t);let r=$(`zone`,`CLOUDFLARE_ZONE_ID`,e?.zone);if(r){if(!n?.quiet&&r.source!==`flag`){let e=lr(r);console.error(`Using zone: ${r.value} (from ${e})`)}return sr(r.value,t)}throw Error(`No zone specified.
|
|
90
|
-
|
|
91
|
-
Please provide one of the following:
|
|
92
|
-
1. Zone as a positional argument: cf dns records list <zone>
|
|
93
|
-
2. --zone flag (or -z): cf dns records list --zone example.com
|
|
94
|
-
3. CLOUDFLARE_ZONE_ID environment variable
|
|
95
|
-
4. Run 'cf context set zone <zone>' to set a default
|
|
96
|
-
5. Create a .cfrc file in your project with {"zone": "example.com"}`)}async function sr(e,t){if(fe(e)||!t)return e;let{resolveZoneId:n}=await import(`./resolve-BuJRWSk0.mjs`).then(e=>e.r);return n(t,await rr(),e)}function cr(e){if(e?.scriptName)return e.scriptName;throw Error("Required Worker name missing. Please specify the Worker name with `--script-name <worker-name>`.")}function lr(e,t=`zone`){switch(e.source){case`flag`:return t===`accountId`?`(flag)`:`--zone flag`;case`env`:return t===`accountId`?`CLOUDFLARE_ACCOUNT_ID`:`CLOUDFLARE_ZONE_ID`;case`project`:return`.cfrc`;case`config`:return`~/.config/cf/config.json`}}async function ur(e,t,n,r){let i=t,a=t;if(e===`accountId`){let{id:e,name:n}=await pr(t,r);i=e,a=n?`${e.slice(0,12)}... (${n})`:e}else if(e===`zone`){let e=await mr(t,r);i=t,a=e.name}if(n===`project`){let t=Q()?.config||{};t[e]=i,$n(t)}else{let t=ce();t.defaults||={},t.defaults[e]=i,se(t)}return{resolvedValue:i,displayName:a}}function dr(e,t){if(t===`project`)if(e===`all`)er();else{let t=Q();t&&(delete t.config[e],Object.keys(t.config).length===0?er(y(t.path)):$n(t.config,y(t.path)))}else{let t=ce();t.defaults&&(e===`all`?delete t.defaults:(delete t.defaults[e],Object.keys(t.defaults).length===0&&delete t.defaults),se(t))}}async function fr(e){return await e.get(`/accounts`)}async function pr(e,t){let n=await fr(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(fe(e))return{id:e};throw Error(`Account not found: "${e}"
|
|
97
|
-
|
|
98
|
-
Available accounts:
|
|
99
|
-
${n.map(e=>` ${e.id.slice(0,12)}... ${e.name}`).join(`
|
|
100
|
-
`)}`)}async function mr(e,t){let n=await t.zones.list(),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 de(e)?Error(`Zone not found: "${e}"
|
|
101
|
-
|
|
102
|
-
This zone either doesn't exist or you don't have access to it.
|
|
103
|
-
Run 'cf zones list' to see available zones.`):Error(`Invalid zone: "${e}"
|
|
104
|
-
|
|
105
|
-
Please provide a zone ID or domain name.
|
|
106
|
-
Run 'cf zones list' to see available zones.`)}function hr(){return b(process.cwd(),Z)}async function gr(){let e=I({allowGlobalAuthKey:!1});if(e&&`apiToken`in e)return e.apiToken;let t=await An();if(t)return t;throw Error(`No authentication token found.
|
|
107
|
-
|
|
108
|
-
Please set one of the following:
|
|
109
|
-
1. Set the CLOUDFLARE_API_TOKEN environment variable
|
|
110
|
-
2. Run 'cf auth login' to authenticate via OAuth
|
|
111
|
-
|
|
112
|
-
For API tokens, visit: https://dash.cloudflare.com/profile/api-tokens`)}async function _r(e){if(e.local){if(!e.localEndpoint)throw Error(`--local requires --local-endpoint <url>; this should have been caught by the global middleware.`);let{createLocalFetch:n}=await import(`./local-VJaJ3BZ1.mjs`).then(e=>e.r);return new t({apiToken:`cf-local-mode-no-auth`,baseURL:process.env.CLOUDFLARE_BASE_URL,defaultHeaders:Kn(),fetch:n({endpoint:e.localEndpoint})})}return new t({apiToken:await gr(),baseURL:process.env.CLOUDFLARE_BASE_URL,defaultHeaders:Kn()})}export{q as S,An as _,rr as a,On as b,cr as c,ur as d,Qn as f,Nn as g,Kn as h,Q as i,or as l,Xn as m,gr as n,tr as o,Zn as p,dr as r,hr as s,_r as t,nr as u,jn as v,kn as x,Mn as y};
|