cf 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{abuse-reports-Ina5TlsU.mjs → abuse-reports-DUs4SKVx.mjs} +2 -2
- package/dist/accounts-BIY8wNGA.mjs +22 -0
- package/dist/acm-SqcV8o5o.mjs +3 -0
- package/dist/addressing-CygRm0pN.mjs +12 -0
- package/dist/{agent-context-DMPfi54f.mjs → agent-context-CKb6w43K.mjs} +1 -1
- package/dist/ai-BAmEAjN3.mjs +2 -0
- package/dist/ai-gateway-BENwPvvB.mjs +8 -0
- package/dist/ai-search-Bv_Whw3E.mjs +7 -0
- package/dist/ai_gateway-C6WP9oBH.mjs +4 -0
- package/dist/alerting-D_qWrsoY.mjs +6 -0
- package/dist/{analytics-DSSRDZz8.mjs → analytics-CwFrx-Dr.mjs} +1 -1
- package/dist/analytics_engine-BjV6XLyG.mjs +2 -0
- package/dist/api-gateway-D9PMVVqL.mjs +33 -0
- package/dist/argo-DwYGbyld.mjs +2 -0
- package/dist/artifacts-DKAjY_n4.mjs +4 -0
- package/dist/{audit-logs-BuExU_nz.mjs → audit-logs-BvQ9uwuy.mjs} +1 -1
- package/dist/{auth-CSC4yhEJ.mjs → auth-DX9KnJ0P.mjs} +3 -3
- package/dist/{auth-D5hNsOFq.mjs → auth-TYwGydWg.mjs} +1 -1
- package/dist/billing-CRTlRU88.mjs +2 -0
- package/dist/bot-management-DgW--8wM.mjs +5 -0
- package/dist/botnet-feed-CIX6ZORT.mjs +3 -0
- package/dist/brand-protection-ZikBtl0y.mjs +3 -0
- package/dist/browser-rendering-D_ZQVWn8.mjs +4 -0
- package/dist/build-Bgw8TV1p.mjs +134 -0
- package/dist/cache-CeN5t6_W.mjs +5 -0
- package/dist/calls-Cv0ieVg4.mjs +4 -0
- package/dist/{certificate-authorities-CtqzAtxQ.mjs → certificate-authorities-BzZnWCac.mjs} +1 -1
- package/dist/client-certificates-BFuzeBrj.mjs +3 -0
- package/dist/{cloud-connector-BA5IRZUP.mjs → cloud-connector-D5h8Dzzg.mjs} +1 -1
- package/dist/cloudforce-one-aqDCIBMp.mjs +21 -0
- package/dist/{completions-DOeHPdCG.mjs → completions-Bvzav4Mj.mjs} +1 -1
- package/dist/connectivity-CjkXmEhO.mjs +3 -0
- package/dist/connector-interrupts-B7eSface.mjs +2 -0
- package/dist/connector-telemetry-events-F3Co8HUf.mjs +2 -0
- package/dist/connector-telemetry-snapshots-CQY8XMUg.mjs +2 -0
- package/dist/connectors-YYu_Vx3H.mjs +3 -0
- package/dist/content-scanning-BorfRGKT.mjs +4 -0
- package/dist/{context-jpewmual.mjs → context-C-WbewL6.mjs} +1 -1
- package/dist/custom-certificates-CfRj7QZb.mjs +5 -0
- package/dist/{custom-hostnames-CtuTdFcX.mjs → custom-hostnames-CcK7_17e.mjs} +4 -4
- package/dist/custom-nameservers-BkKx0THn.mjs +3 -0
- package/dist/custom-pages-DamGVA75.mjs +4 -0
- package/dist/d1-sK0O5THv.mjs +4 -0
- package/dist/data-security-DsWpoWiS.mjs +6 -0
- package/dist/{dcv-delegation-Bgf86J-r.mjs → dcv-delegation-BYsNl3qc.mjs} +1 -1
- package/dist/{deploy-dVrgDUOp.mjs → deploy-BzlPv3ro.mjs} +1 -1
- package/dist/{dev-C01_Lby6.mjs → dev-IOg-_s5_.mjs} +1 -1
- package/dist/diagnostics-CH7T2WR3.mjs +3 -0
- package/dist/dispatch-namespaces-Bgj9XCRx.mjs +7 -0
- package/dist/dist-B7hsuvbF.mjs +57 -0
- package/dist/dns-firewall-VmQf3UVP.mjs +57 -0
- package/dist/dns-o7hUPMCG.mjs +29 -0
- package/dist/durable-objects-DgrTbvoF.mjs +2 -0
- package/dist/email-routing-owCvAEpf.mjs +10 -0
- package/dist/email-security-Dng3DVuf.mjs +8 -0
- package/dist/email-sending-bExMH4lu.mjs +3 -0
- package/dist/filters-DKs-wEzt.mjs +4 -0
- package/dist/{firewall-DYZcTtIC.mjs → firewall-BLaTtX3r.mjs} +10 -10
- package/dist/{fraud-C03MtdZb.mjs → fraud-D8WmLKyH.mjs} +1 -1
- package/dist/google-tag-gateway-DyCY43k0.mjs +2 -0
- package/dist/healthchecks-BBtW8vRh.mjs +4 -0
- package/dist/hostnames-Bh2IFxIw.mjs +3 -0
- package/dist/hyperdrive-DJm1eD-M.mjs +18 -0
- package/dist/iam-apCCcy7R.mjs +6 -0
- package/dist/images-Cxe45OHm.mjs +7 -0
- package/dist/index.mjs +1 -1
- package/dist/intel-8V4h6H46.mjs +3 -0
- package/dist/{ips-nv9INuWZ.mjs → ips-BE7JbAnc.mjs} +1 -1
- package/dist/keyless-certificates-CfJmXccT.mjs +3 -0
- package/dist/kv-Dz6then8.mjs +5 -0
- package/dist/leaked-credential-checks-BJ-zQMlx.mjs +3 -0
- package/dist/load-balancers-ilsGgudX.mjs +6 -0
- package/dist/logpush-BH14TtuA.mjs +4 -0
- package/dist/logs-B8-mkf_I.mjs +3 -0
- package/dist/magic-cloud-networking-DylCXoG4.mjs +5 -0
- package/dist/magic-network-monitoring-DnyrZy77.mjs +4 -0
- package/dist/magic-transit-B-kU5e3s.mjs +89 -0
- package/dist/managed-transforms-GC9Pq5dg.mjs +3 -0
- package/dist/mtls-certificates-BRlhWw_G.mjs +3 -0
- package/dist/network-interconnects-DuyoFD9_.mjs +36 -0
- package/dist/oauth-B5k80sip.mjs +61 -0
- package/dist/observability-9APhqFHo.mjs +4 -0
- package/dist/{organizations-BqJHyvMK.mjs → organizations-Dy3kiV_z.mjs} +6 -6
- package/dist/origin-ca-certificates-2rwPoQdG.mjs +3 -0
- package/dist/origin-post-quantum-encryption-BnBLTvEO.mjs +2 -0
- package/dist/origin-tls-client-auth-B30_2_dO.mjs +4 -0
- package/dist/{page-rules-EZHJePmn.mjs → page-rules-zQJGmTCd.mjs} +5 -5
- package/dist/{page-shield-CXJioWPs.mjs → page-shield-CxQk5k9X.mjs} +5 -5
- package/dist/pages-5DKLs7CQ.mjs +11 -0
- package/dist/pipelines-DfGE44xo.mjs +6 -0
- package/dist/{progress-DrDErV9w.mjs → progress-CL8I-7YK.mjs} +1 -1
- package/dist/prompt-q3B7sM2A.mjs +3 -0
- package/dist/queues-BoenUGIw.mjs +6 -0
- package/dist/r2-Cq_JCjK0.mjs +21 -0
- package/dist/r2-data-catalog-eLxltWdO.mjs +14 -0
- package/dist/{radar-D986zPJr.mjs → radar-YNOCio6T.mjs} +1 -1
- package/dist/rate-limits-CcAF3tMl.mjs +5 -0
- package/dist/{raw-fetch-_n0lMAnD.mjs → raw-fetch-bIXC9D1m.mjs} +1 -1
- package/dist/realtime-kit-4bCGviO5.mjs +18 -0
- package/dist/{registrar-CDIwTz3G.mjs → registrar-CfHlaOOf.mjs} +6 -6
- package/dist/request-tracers-DlHawg5l.mjs +2 -0
- package/dist/resource-sharing-7FhuboJE.mjs +5 -0
- package/dist/resource-tagging-divcugVb.mjs +16 -0
- package/dist/rules-CAXkege8.mjs +4 -0
- package/dist/rulesets-CBsdc8IV.mjs +8 -0
- package/dist/rum-D0hHPNl9.mjs +4 -0
- package/dist/{schema-BR31o4P6.mjs → schema-D8o6HcCr.mjs} +1 -1
- package/dist/schema-validation-BWNDnnIT.mjs +24 -0
- package/dist/scim-CWLli4fi.mjs +3 -0
- package/dist/{secrets-store-BAK9G12O.mjs → secrets-store-B7_HkE8I.mjs} +19 -19
- package/dist/security-center-BQT21oiM.mjs +2 -0
- package/dist/security-txt-CVpmJo29.mjs +3 -0
- package/dist/{session-DHYCE-PM.mjs → session-B8r8LNQN.mjs} +1 -1
- package/dist/{build-HuS9-R0V.mjs → shared-DQI8NGja.mjs} +324 -388
- package/dist/smart-shield-BreBC1Ap.mjs +3 -0
- package/dist/snippets-BAJoWMSJ.mjs +4 -0
- package/dist/{spawn-CCGzKlC4.mjs → spawn-pmGERpdB.mjs} +1 -1
- package/dist/{spectrum-pVGxb7u5.mjs → spectrum-DnIRLY95.mjs} +6 -6
- package/dist/speed-UYEVue28.mjs +4 -0
- package/dist/{src-DU7FBCOX.mjs → src-BQ1dr9xR.mjs} +4 -4
- package/dist/ssl-D3Pixs8M.mjs +15 -0
- package/dist/stream-BUsuOfQh.mjs +14 -0
- package/dist/{tenants-HLGUazms.mjs → tenants-BdWJTtcg.mjs} +1 -1
- package/dist/token-validation-DUvtXWur.mjs +10 -0
- package/dist/{tools-D_hfUU_Z.mjs → tools-CQtA5-cr.mjs} +1 -1
- package/dist/turnstile-CAKVnS1L.mjs +23 -0
- package/dist/{ui-erjBdVKL.mjs → ui-BrNwNHX9.mjs} +1 -1
- package/dist/url-normalization-DA-RAxs4.mjs +3 -0
- package/dist/url-scanner-DmYu43f7.mjs +2 -0
- package/dist/user-Bah4wGGN.mjs +10 -0
- package/dist/vectorize-DhvVG2By.mjs +4 -0
- package/dist/{versions-CBHwWPAM.mjs → versions-NUXxCr0s.mjs} +1 -1
- package/dist/{waiting-rooms-u6KwrzWd.mjs → waiting-rooms-DoOkT4Mu.mjs} +6 -6
- package/dist/web3-n3GW50u-.mjs +4 -0
- package/dist/workers-D6IaQ_F0.mjs +18 -0
- package/dist/workers-builds-DYi0OMMU.mjs +7 -0
- package/dist/workflows-DrdXUQ2g.mjs +4 -0
- package/dist/zaraz-9l7KuLqh.mjs +2 -0
- package/dist/zero-trust-D6V9GH2W.mjs +118 -0
- package/dist/zero_trust-BzXKAX_x.mjs +3 -0
- package/dist/{zones-BXtdwt6E.mjs → zones-0MTkuaFk.mjs} +8 -8
- package/package.json +3 -1
- package/dist/accounts-B_joQcMi.mjs +0 -22
- package/dist/acm-_kIHqYME.mjs +0 -3
- package/dist/addressing-CaFlw8y1.mjs +0 -12
- package/dist/ai-CqnhNb_c.mjs +0 -2
- package/dist/ai-gateway-pgYGI519.mjs +0 -8
- package/dist/ai-search-eqQMPQol.mjs +0 -7
- package/dist/ai_gateway--vuVLnOm.mjs +0 -4
- package/dist/alerting-CPxHiYHb.mjs +0 -6
- package/dist/analytics_engine-gWyfnsCs.mjs +0 -2
- package/dist/api-gateway-BXXGFCVR.mjs +0 -33
- package/dist/argo-aC6A3JyX.mjs +0 -2
- package/dist/artifacts-HD4V2xpK.mjs +0 -4
- package/dist/billing-COaghyxl.mjs +0 -2
- package/dist/bot-management-DmEzeV1Y.mjs +0 -5
- package/dist/botnet-feed-ByEAXAkw.mjs +0 -3
- package/dist/brand-protection-dPrGe8sL.mjs +0 -3
- package/dist/browser-rendering-BiSGnpBf.mjs +0 -4
- package/dist/cache-CY-7Lt71.mjs +0 -5
- package/dist/calls-wOQGDWPl.mjs +0 -4
- package/dist/client-certificates-CRf41xLe.mjs +0 -3
- package/dist/cloudforce-one-Bq_qPAWs.mjs +0 -21
- package/dist/connectivity-Bx3MgTHX.mjs +0 -3
- package/dist/connector-interrupts-D7ylweJZ.mjs +0 -2
- package/dist/connector-telemetry-events-6izV1kbP.mjs +0 -2
- package/dist/connector-telemetry-snapshots-BnjKbyxX.mjs +0 -2
- package/dist/connectors-DRt4e6d_.mjs +0 -3
- package/dist/content-scanning-Cd2vy5Sz.mjs +0 -4
- package/dist/custom-certificates-DYE-9epx.mjs +0 -5
- package/dist/custom-nameservers-CWqA51in.mjs +0 -3
- package/dist/custom-pages-DeUKEFGe.mjs +0 -4
- package/dist/d1-DvWY9Gp4.mjs +0 -4
- package/dist/data-security-BPo6dIWu.mjs +0 -6
- package/dist/diagnostics-6nKPmVgz.mjs +0 -3
- package/dist/dispatch-namespaces-64lXx2WJ.mjs +0 -7
- package/dist/dist-t_YrL25p.mjs +0 -82
- package/dist/dns-ClciFGxx.mjs +0 -29
- package/dist/dns-firewall-DfUmXDCe.mjs +0 -57
- package/dist/durable-objects-CMaYZ-YU.mjs +0 -2
- package/dist/email-routing-CGXhFqF5.mjs +0 -10
- package/dist/email-security-D5viPq8S.mjs +0 -8
- package/dist/email-sending-C2jpc3gh.mjs +0 -3
- package/dist/filters-bzsFcWt0.mjs +0 -4
- package/dist/google-tag-gateway-Dfy887yA.mjs +0 -2
- package/dist/healthchecks-DRoAlWgr.mjs +0 -4
- package/dist/hostnames-CFgIVI3s.mjs +0 -3
- package/dist/hyperdrive-C7-gwTSV.mjs +0 -18
- package/dist/iam-DqVPzGrb.mjs +0 -6
- package/dist/images-BYfl4YgR.mjs +0 -7
- package/dist/intel-duTEPIHc.mjs +0 -3
- package/dist/keyless-certificates-CRCDVd3g.mjs +0 -3
- package/dist/kv-CZoV4tiv.mjs +0 -5
- package/dist/leaked-credential-checks-DNIBg7Pe.mjs +0 -3
- package/dist/load-balancers--OMg0HNt.mjs +0 -6
- package/dist/logpush-C0_lZTyY.mjs +0 -4
- package/dist/logs-BtpWZQfV.mjs +0 -3
- package/dist/magic-cloud-networking-u6rwYbGg.mjs +0 -5
- package/dist/magic-network-monitoring-CKgQyRj4.mjs +0 -4
- package/dist/magic-transit-CLhMcJ_-.mjs +0 -89
- package/dist/managed-transforms-D0Z2mlth.mjs +0 -3
- package/dist/mtls-certificates-BL65NK5T.mjs +0 -3
- package/dist/network-interconnects-Bgu9gmaG.mjs +0 -36
- package/dist/oauth-Bk-F-tIO.mjs +0 -52
- package/dist/observability-BynRbTF4.mjs +0 -4
- package/dist/origin-ca-certificates-BGvYwm3C.mjs +0 -3
- package/dist/origin-post-quantum-encryption-9KOE8YPI.mjs +0 -2
- package/dist/origin-tls-client-auth-d3snC3vr.mjs +0 -4
- package/dist/pages-D4aYteKk.mjs +0 -11
- package/dist/pipelines-G8Iusxq-.mjs +0 -6
- package/dist/queues-DEkbKqZX.mjs +0 -6
- package/dist/r2-CV0IkCAW.mjs +0 -21
- package/dist/r2-data-catalog-NtqGC_a_.mjs +0 -14
- package/dist/rate-limits-B2wRsUX1.mjs +0 -5
- package/dist/realtime-kit-Ld3c5eU6.mjs +0 -18
- package/dist/request-tracers-D7SFMDik.mjs +0 -2
- package/dist/resource-sharing-YIQ04jXE.mjs +0 -5
- package/dist/resource-tagging-Bd6Y03sg.mjs +0 -16
- package/dist/rules-DHjLP5Kx.mjs +0 -4
- package/dist/rulesets-q4QABpKs.mjs +0 -8
- package/dist/rum-SmT4HZmM.mjs +0 -4
- package/dist/schema-validation-vVetgC_P.mjs +0 -24
- package/dist/scim-ChOkZpNx.mjs +0 -3
- package/dist/security-center-eScuYDKP.mjs +0 -2
- package/dist/security-txt-x7R4gmQu.mjs +0 -3
- package/dist/shared-BAjo72Lz.mjs +0 -2
- package/dist/smart-shield-CWlSsNi8.mjs +0 -3
- package/dist/snippets-DrlgYJYp.mjs +0 -4
- package/dist/speed-ZFrMWDgd.mjs +0 -4
- package/dist/ssl-9JY05sYt.mjs +0 -15
- package/dist/stream-tRU39b8K.mjs +0 -14
- package/dist/token-validation-_VdamKpz.mjs +0 -10
- package/dist/turnstile-BRzXd28B.mjs +0 -23
- package/dist/url-normalization-D-NxuLtN.mjs +0 -3
- package/dist/url-scanner-BzzR6iDx.mjs +0 -2
- package/dist/user-C4omq__w.mjs +0 -10
- package/dist/vectorize-By6EqcNR.mjs +0 -4
- package/dist/web3-DQ5dmE9W.mjs +0 -4
- package/dist/workers-D8Be7_as.mjs +0 -18
- package/dist/workers-builds-BE3W3qNk.mjs +0 -7
- package/dist/workflows-BWWufqFA.mjs +0 -4
- package/dist/zaraz-Bsa9AvVL.mjs +0 -2
- package/dist/zero-trust-UNVZFnKu.mjs +0 -118
- package/dist/zero_trust-B0_Rk4p2.mjs +0 -3
- /package/dist/{cli-types-BeyOc81z.mjs → cli-types-DGgEbf8K.mjs} +0 -0
- /package/dist/{metadata-OOwvpR8m.mjs → metadata-MPDDi08e.mjs} +0 -0
- /package/dist/{resolve-C3h-mwp7.mjs → resolve-DGD57PFH.mjs} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{i as n,n as r}from"./auth-DX9KnJ0P.mjs";import{n as i,r as a,t as o}from"./body-parser-DWSy7uZ8.mjs";import{t as s}from"./output-B6fBFRqe.mjs";import{n as c,t as l}from"./progress-CL8I-7YK.mjs";import{n as u}from"./input-validation-_fMCApaH.mjs";import{t as d}from"./local-CYc9q7l2.mjs";import{r as f}from"./prompt-q3B7sM2A.mjs";import{t as p}from"./cli-types-DGgEbf8K.mjs";function m(e){return e.option(`domains`,{type:`string`,array:!0,description:`List of fully qualified domain names (FQDNs) to check for availability. Each domain must include the extension.
|
|
3
3
|
- Minimum: 1 domain
|
|
4
4
|
- Maximum: 20 domains per request
|
|
5
5
|
- Domains on unsupported extensions are returned with \`registrable: false\` and a \`reason\` field
|
|
6
6
|
- Malformed domain names (e.g., missing extension) may be omitted from the response
|
|
7
|
-
`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`List of fully qualified domain names (FQDNs) to check. Each domain must include the extension (e.g., "example.com", not "example").`})}const h={command:`domain-check`,describe:"Performs real-time, authoritative availability checks directly against domain registries. Use this endpoint to verify a domain is available before attempting registration via `POST /registrations`. **Important:** Unlike the Search endpoint, these results are authoritative and reflect current registry status. Always check availability immediately before registration as domain status can change rapidly. **Note:** This endpoint uses POST to accept a list of domains in the request body. It is a read-only operation — it does not create, modify, or reserve any domains. ### Extension support Only domains on extensions supported for programmatic registration by this API can be registered. If you check a domain on an unsupported extension, the response will include `registrable: false` with a `reason` field explaining why: - `extension_not_supported_via_api` — Cloudflare Registrar supports this extension in the dashboard, but it is not yet available for programmatic registration via this API. Register via `https://dash.cloudflare.com/{account_id}/domains/registrations` instead. - `extension_not_supported` — This extension is not supported by Cloudflare Registrar. - `extension_disallows_registration` — The extension's registry has temporarily or permanently frozen new registrations. No registrar can register domains on this extension at this time. - `domain_premium` — The domain is premium priced. Premium registration is not currently supported by this API. - `domain_unavailable` — The domain is already registered, reserved, or otherwise not available for registration on a supported extension. The `reason` field is only present when `registrable` is `false`. ### Behavior - Maximum 20 domains per request - Pricing is only returned for domains where `registrable: true` - Results are not cached; each request queries the registry ### Workflow 1. Call this endpoint with domains the user wants to register. 2. For each domain where `registrable: true`, present pricing to the user. 3. If `tier: premium`, note that premium registration is not currently supported by this API and do not proceed to `POST /registrations`. 4. Proceed to `POST /registrations` only for supported non-premium domains.",builder:m,handler:async
|
|
7
|
+
`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`List of fully qualified domain names (FQDNs) to check. Each domain must include the extension (e.g., "example.com", not "example").`})}const h={command:`domain-check`,describe:"Performs real-time, authoritative availability checks directly against domain registries. Use this endpoint to verify a domain is available before attempting registration via `POST /registrations`. **Important:** Unlike the Search endpoint, these results are authoritative and reflect current registry status. Always check availability immediately before registration as domain status can change rapidly. **Note:** This endpoint uses POST to accept a list of domains in the request body. It is a read-only operation — it does not create, modify, or reserve any domains. ### Extension support Only domains on extensions supported for programmatic registration by this API can be registered. If you check a domain on an unsupported extension, the response will include `registrable: false` with a `reason` field explaining why: - `extension_not_supported_via_api` — Cloudflare Registrar supports this extension in the dashboard, but it is not yet available for programmatic registration via this API. Register via `https://dash.cloudflare.com/{account_id}/domains/registrations` instead. - `extension_not_supported` — This extension is not supported by Cloudflare Registrar. - `extension_disallows_registration` — The extension's registry has temporarily or permanently frozen new registrations. No registrar can register domains on this extension at this time. - `domain_premium` — The domain is premium priced. Premium registration is not currently supported by this API. - `domain_unavailable` — The domain is already registered, reserved, or otherwise not available for registration on a supported extension. The `reason` field is only present when `registrable` is `false`. ### Behavior - Maximum 20 domains per request - Pricing is only returned for domains where `registrable: true` - Results are not cached; each request queries the registry ### Workflow 1. Call this endpoint with domains the user wants to register. 2. For each domain where `registrable: true`, present pricing to the user. 3. If `tier: premium`, note that premium registration is not currently supported by this API and do not proceed to `POST /registrations`. 4. Proceed to `POST /registrations` only for supported non-premium domains.",builder:m,handler:async n=>{if(n.dryRun){c({command:`cf registrar domain-check`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/domain-check`,pathParams:{},bodyKind:`json`,body:n.body===void 0?o({domains:n.domains}):i(n.body)});return}let a=await r(n),u=n.local?d:await e();if(n.accountId=u,n.body){let e=i(n.body);s(await l(`Creating`,async()=>a.registrar.domainCheck({...e,account_id:u})),{successLabel:`Created`});return}if(n.domains===void 0)throw Error(`--domains is required (or pass --body with this field set).`);let f=o({domains:n.domains});s(await l(`Creating`,async()=>a.registrar.domainCheck({...f,account_id:u})),{successLabel:`Created`})}};function g(e){return e.option(`q`,{type:`string`,description:`The search term to find domain suggestions. Accepts keywords, phrases, or full domain names.
|
|
8
8
|
- Phrases: "coffee shop" returns coffeeshop.com, mycoffeeshop.net, etc.
|
|
9
9
|
- Domain names: "example.com" returns example.com and variations across extensions`,demandOption:!0}).option(`extensions`,{type:`string`,description:`Limits results to specific domain extensions from the supported set. If not specified,
|
|
10
10
|
returns results across all supported extensions. Extensions not in the supported
|
|
11
|
-
set are silently ignored.`}).option(`limit`,{type:`number`,description:`Maximum number of domain suggestions to return. Defaults to 20 if not specified.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`domain-search`,describe:'Searches for domain name suggestions based on a keyword, phrase, or partial domain name. Returns a list of potentially available domains with pricing information. **Important:** Results are non-authoritative and based on cached data. Always use the `/domain-check` endpoint to verify real-time availability before attempting registration. Suggestions are scoped to extensions supported for programmatic registration via this API (`POST /registrations`). Domains on unsupported extensions will not appear in results, even if they are available at the registry level. ### Use cases - Brand name discovery (e.g., "acme corp" → acmecorp.com, acmecorp.dev) - Keyword-based suggestions (e.g., "coffee shop" → coffeeshop.com, mycoffeeshop.net) - Alternative extension discovery (e.g., "example.com" → example.com, example.app, example.xyz) ### Workflow 1. Call this endpoint with a keyword or domain name. 2. Present suggestions to the user. 3. Call `/domain-check` with the user\'s chosen domains to confirm real-time availability and pricing. 4. Proceed to `POST /registrations` only for supported non-premium domains where the Check response returns `registrable: true`. **Note:** Searching with just a domain extension (e.g., "com" or ".app") is not supported. Provide a keyword or domain name.',builder:g,handler:async
|
|
11
|
+
set are silently ignored.`}).option(`limit`,{type:`number`,description:`Maximum number of domain suggestions to return. Defaults to 20 if not specified.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`domain-search`,describe:'Searches for domain name suggestions based on a keyword, phrase, or partial domain name. Returns a list of potentially available domains with pricing information. **Important:** Results are non-authoritative and based on cached data. Always use the `/domain-check` endpoint to verify real-time availability before attempting registration. Suggestions are scoped to extensions supported for programmatic registration via this API (`POST /registrations`). Domains on unsupported extensions will not appear in results, even if they are available at the registry level. ### Use cases - Brand name discovery (e.g., "acme corp" → acmecorp.com, acmecorp.dev) - Keyword-based suggestions (e.g., "coffee shop" → coffeeshop.com, mycoffeeshop.net) - Alternative extension discovery (e.g., "example.com" → example.com, example.app, example.xyz) ### Workflow 1. Call this endpoint with a keyword or domain name. 2. Present suggestions to the user. 3. Call `/domain-check` with the user\'s chosen domains to confirm real-time availability and pricing. 4. Proceed to `POST /registrations` only for supported non-premium domains where the Check response returns `registrable: true`. **Note:** Searching with just a domain extension (e.g., "com" or ".app") is not supported. Provide a keyword or domain name.',builder:g,handler:async n=>{let i={q:n.q,extensions:n.extensions,limit:n.limit};if(n.dryRun){c({command:`cf registrar domain-search`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/domain-search`,pathParams:{},query:i,bodyKind:`none`});return}let a=await r(n),o=n.local?d:await e();n.accountId=o,s(await l(`Loading`,async()=>a.registrar.domainSearch({account_id:o,...i})),{successLabel:`Loaded`})}};function v(e){return e.option(`prefer`,{type:`string`,description:`Set to \`respond-async\` to receive an immediate \`202 Accepted\` without
|
|
12
12
|
waiting for the operation to complete (RFC 7240).
|
|
13
13
|
|
|
14
14
|
The header may be combined with other preferences using standard
|
|
@@ -36,11 +36,11 @@ The registry for each extension may also enforce its own maximum
|
|
|
36
36
|
registration term. If the requested value exceeds the registry's
|
|
37
37
|
maximum, the registration will be rejected. When in doubt, use the
|
|
38
38
|
default by omitting this field.
|
|
39
|
-
`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`contacts-registrant-email`,`contacts-registrant-fax`,`contacts-registrant-phone`,`contacts-registrant-postal-info-name`,`contacts-registrant-postal-info-organization`].some(t=>e[t]!==void 0)){let t=[`contacts-registrant-email`,`contacts-registrant-phone`,`contacts-registrant-postal-info-name`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --contacts-* flag is set`)}return!0})}const y={command:`create`,describe:"Starts a domain registration workflow. This is a billable operation — successful registration charges the account's default payment method. All successful domain registrations are non-refundable — once the workflow completes with `state: succeeded`, the charge cannot be reversed. ### Prerequisites - The account must have a billing profile with a valid default payment method. Set this up at `https://dash.cloudflare.com/{account_id}/billing/payment-info`. - The account must not already be at the maximum supported domain limit. A single account may own up to 100 domains in total across registrations created through either the dashboard or this API. - The domain must be on a supported extension for programmatic registration. - Use `POST /domain-check` immediately before calling this endpoint to confirm real-time availability and pricing. ### Express mode The only required field is `domain_name`. If `contacts` is omitted, the system uses the account's default address book entry as the registrant. If no default exists and no contact is provided, the request fails. Set up a default address book entry and accept the required agreement at `https://dash.cloudflare.com/{account_id}/domains/registrations`. ### Defaults - `years`: defaults to the extension's minimum registration period (1 year for most extensions, but varies — for example, `.ai` (if supported) requires a minimum of 2 years). - `auto_renew`: defaults to `false`. Setting it to `true` is an explicit opt-in authorizing Cloudflare to charge the account's default payment method up to 30 days before domain expiry to renew the registration. Renewal pricing may change over time based on registry pricing. - `privacy_mode`: defaults to `redaction`. ### Premium domains Premium domain registration is not currently supported by this API. If `POST /domain-check` returns `tier: premium`, do not call this endpoint for that domain. ### Response behavior By default, the server holds the connection for a bounded, server-defined amount of time while the registration completes. Most registrations finish within this window and return `201 Created` with a completed workflow status. If the registration is still processing after this synchronous wait window, the server returns `202 Accepted`. Poll the URL in `links.self` to track progress. To skip the wait and receive an immediate `202`, send `Prefer: respond-async`.",builder:v,handler:async p=>{let m={};if(p.prefer!==void 0&&(m.Prefer=String(p.prefer)),p.dryRun){l({command:`cf registrar registrations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/registrations`,pathParams:{},bodyKind:`json`,body:p.body===void 0?s({auto_renew:p[`auto-renew`],contacts:{registrant:{email:d(p[`contacts-registrant-email`],`contacts-registrant-email`,`text`),fax:d(p[`contacts-registrant-fax`],`contacts-registrant-fax`,`text`),phone:d(p[`contacts-registrant-phone`],`contacts-registrant-phone`,`text`),postal_info:{name:d(p[`contacts-registrant-postal-info-name`],`contacts-registrant-postal-info-name`,`text`),organization:d(p[`contacts-registrant-postal-info-organization`],`contacts-registrant-postal-info-organization`,`text`)}}},domain_name:d(p[`domain-name`],`domain-name`,`text`),privacy_mode:d(p[`privacy-mode`],`privacy-mode`,`text`),years:p.years}):a(p.body)});return}let h=await i(p),g=p.local?f:await n(h);if(p.accountId=g,p.body){let e=a(p.body);c(await u(`Creating`,async()=>r(h,`POST`,`/accounts/${g}/registrar/registrations`,{body:e,headers:Object.keys(m).length>0?m:void 0})),{successLabel:`Created`});return}p[`domain-name`]===void 0&&(p[`domain-name`]=await e(`domain-name`,"Fully qualified domain name (FQDN) including the extension (e.g., `example.com`, `mybrand.app`). The domain name uniquely identifies a registration — the same domain cannot be registered twice, making it a natural idempotency key for registration requests. "));let _={};p[`auto-renew`]!==void 0&&o(_,[`auto_renew`],p[`auto-renew`]),p[`contacts-registrant-email`]!==void 0&&o(_,[`contacts`,`registrant`,`email`],d(p[`contacts-registrant-email`],`contacts-registrant-email`,`text`)),p[`contacts-registrant-fax`]!==void 0&&o(_,[`contacts`,`registrant`,`fax`],d(p[`contacts-registrant-fax`],`contacts-registrant-fax`,`text`)),p[`contacts-registrant-phone`]!==void 0&&o(_,[`contacts`,`registrant`,`phone`],d(p[`contacts-registrant-phone`],`contacts-registrant-phone`,`text`)),p[`contacts-registrant-postal-info-name`]!==void 0&&o(_,[`contacts`,`registrant`,`postal_info`,`name`],d(p[`contacts-registrant-postal-info-name`],`contacts-registrant-postal-info-name`,`text`)),p[`contacts-registrant-postal-info-organization`]!==void 0&&o(_,[`contacts`,`registrant`,`postal_info`,`organization`],d(p[`contacts-registrant-postal-info-organization`],`contacts-registrant-postal-info-organization`,`text`)),p[`domain-name`]!==void 0&&o(_,[`domain_name`],d(p[`domain-name`],`domain-name`,`text`)),p[`privacy-mode`]!==void 0&&o(_,[`privacy_mode`],d(p[`privacy-mode`],`privacy-mode`,`text`)),p.years!==void 0&&o(_,[`years`],p.years),c(await u(`Creating`,async()=>r(h,`POST`,`/accounts/${g}/registrar/registrations`,{body:Object.keys(_).length>0?_:void 0,headers:Object.keys(m).length>0?m:void 0})),{successLabel:`Created`})}};function b(e){return e.positional(`domain-name`,{type:`string`,description:"Fully qualified domain name (FQDN) including the extension (e.g., `example.com`, `mybrand.app`). The domain name uniquely identifies a registration — the same domain cannot be registered twice, making it a natural idempotency key for registration requests.",demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const x={command:`get-status <domain-name>`,describe:"Returns the current status of a domain registration workflow. Use this endpoint to poll for completion when the POST response returned `202 Accepted`. The URL is provided in the `links.self` field of the workflow status response. Poll this endpoint until the workflow reaches a terminal state or a state that requires user attention. **Terminal states:** `succeeded` and `failed` are terminal and always have `completed: true`. **Non-terminal states:** - `action_required` has `completed: false` and will not resolve on its own. The workflow is paused pending user intervention. - `blocked` has `completed: false` and indicates the workflow is waiting on a third party such as the extension registry or losing registrar. Continue polling while informing the user of the delay. Use increasing backoff between polls. When `state: blocked`, use a longer polling interval and do not poll indefinitely. A naive polling loop that only checks `completed` can run indefinitely when `state: action_required`. Break explicitly on `action_required`: ```js let status; do { await new Promise(r => setTimeout(r, 2000)); status = await cloudflare.request({ method: 'GET', path: reg.result.links.self, }); } while ( !status.result.completed && status.result.state !== 'action_required' ); if (status.result.state === 'action_required') { // Surface context.action and context.confirmation_sent_to to the user. // Do not re-submit the registration request. } ```",builder:b,handler:async e=>{if(e.dryRun){l({command:`cf registrar registrations get-status`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/registrations/${e[`domain-name`]==null?`<domain-name>`:encodeURIComponent(String(e[`domain-name`]))}/registration-status`,pathParams:{"domain-name":String(e[`domain-name`]??``)},bodyKind:`none`});return}let r=await i(e),a=e.local?f:await n(r);e.accountId=a,c(await u(`Loading`,async()=>r.registrar.registrations.getStatus({account_id:a,domain_name:e[`domain-name`]})),{successLabel:`Loaded`})}};function S(e){return e.positional(`domain-name`,{type:`string`,description:"Fully qualified domain name (FQDN) including the extension (e.g., `example.com`, `mybrand.app`). The domain name uniquely identifies a registration — the same domain cannot be registered twice, making it a natural idempotency key for registration requests.",demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const C={command:`get-update-status <domain-name>`,describe:"Returns the current status of a domain update workflow. Use this endpoint to poll for completion when the PATCH response returned `202 Accepted`. The URL is provided in the `links.self` field of the workflow status response. Poll this endpoint until the workflow reaches a terminal state or a state that requires user attention. Use increasing backoff between polls. When the workflow remains blocked on a third party, use a longer polling interval and do not poll indefinitely.",builder:S,handler:async e=>{if(e.dryRun){l({command:`cf registrar registrations get-update-status`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/registrations/${e[`domain-name`]==null?`<domain-name>`:encodeURIComponent(String(e[`domain-name`]))}/update-status`,pathParams:{"domain-name":String(e[`domain-name`]??``)},bodyKind:`none`});return}let r=await i(e),a=e.local?f:await n(r);e.accountId=a,c(await u(`Loading`,async()=>r.registrar.registrations.getUpdateStatus({account_id:a,domain_name:e[`domain-name`]})),{successLabel:`Loaded`})}};function w(e){return e.positional(`domain-name`,{type:`string`,description:`Domain name to retrieve.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`get <domain-name>`,describe:"Returns the current state of a domain registration. This is the canonical read endpoint for a domain you own. It returns the full registration resource including current settings and expiration. When the registration resource is ready, both `created_at` and `expires_at` are present in the response.",builder:w,handler:async e=>{if(e.dryRun){l({command:`cf registrar registrations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/registrations/${e[`domain-name`]==null?`<domain-name>`:encodeURIComponent(String(e[`domain-name`]))}`,pathParams:{"domain-name":String(e[`domain-name`]??``)},bodyKind:`none`});return}let r=await i(e),a=e.local?f:await n(r);e.accountId=a,c(await u(`Loading`,async()=>r.registrar.registrations.get({account_id:a,domain_name:e[`domain-name`]})),{successLabel:`Loaded`})}};function E(e){return e.option(`cursor`,{type:`string`,description:`Opaque token from a previous response's \`result_info.cursor\`.
|
|
39
|
+
`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`contacts-registrant-email`,`contacts-registrant-fax`,`contacts-registrant-phone`,`contacts-registrant-postal-info-name`,`contacts-registrant-postal-info-organization`].some(t=>e[t]!==void 0)){let t=[`contacts-registrant-email`,`contacts-registrant-phone`,`contacts-registrant-postal-info-name`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --contacts-* flag is set`)}return!0})}const y={command:`create`,describe:"Starts a domain registration workflow. This is a billable operation — successful registration charges the account's default payment method. All successful domain registrations are non-refundable — once the workflow completes with `state: succeeded`, the charge cannot be reversed. ### Prerequisites - The account must have a billing profile with a valid default payment method. Set this up at `https://dash.cloudflare.com/{account_id}/billing/payment-info`. - The account must not already be at the maximum supported domain limit. A single account may own up to 100 domains in total across registrations created through either the dashboard or this API. - The domain must be on a supported extension for programmatic registration. - Use `POST /domain-check` immediately before calling this endpoint to confirm real-time availability and pricing. ### Express mode The only required field is `domain_name`. If `contacts` is omitted, the system uses the account's default address book entry as the registrant. If no default exists and no contact is provided, the request fails. Set up a default address book entry and accept the required agreement at `https://dash.cloudflare.com/{account_id}/domains/registrations`. ### Defaults - `years`: defaults to the extension's minimum registration period (1 year for most extensions, but varies — for example, `.ai` (if supported) requires a minimum of 2 years). - `auto_renew`: defaults to `false`. Setting it to `true` is an explicit opt-in authorizing Cloudflare to charge the account's default payment method up to 30 days before domain expiry to renew the registration. Renewal pricing may change over time based on registry pricing. - `privacy_mode`: defaults to `redaction`. ### Premium domains Premium domain registration is not currently supported by this API. If `POST /domain-check` returns `tier: premium`, do not call this endpoint for that domain. ### Response behavior By default, the server holds the connection for a bounded, server-defined amount of time while the registration completes. Most registrations finish within this window and return `201 Created` with a completed workflow status. If the registration is still processing after this synchronous wait window, the server returns `202 Accepted`. Poll the URL in `links.self` to track progress. To skip the wait and receive an immediate `202`, send `Prefer: respond-async`.",builder:v,handler:async p=>{let m={};if(p.prefer!==void 0&&(m.Prefer=String(p.prefer)),p.dryRun){c({command:`cf registrar registrations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/registrations`,pathParams:{},bodyKind:`json`,body:p.body===void 0?o({auto_renew:p[`auto-renew`],contacts:{registrant:{email:u(p[`contacts-registrant-email`],`contacts-registrant-email`,`text`),fax:u(p[`contacts-registrant-fax`],`contacts-registrant-fax`,`text`),phone:u(p[`contacts-registrant-phone`],`contacts-registrant-phone`,`text`),postal_info:{name:u(p[`contacts-registrant-postal-info-name`],`contacts-registrant-postal-info-name`,`text`),organization:u(p[`contacts-registrant-postal-info-organization`],`contacts-registrant-postal-info-organization`,`text`)}}},domain_name:u(p[`domain-name`],`domain-name`,`text`),privacy_mode:u(p[`privacy-mode`],`privacy-mode`,`text`),years:p.years}):i(p.body)});return}let h=await r(p),g=p.local?d:await e();if(p.accountId=g,p.body){let e=i(p.body);s(await l(`Creating`,async()=>n(h,`POST`,`/accounts/${g}/registrar/registrations`,{body:e,headers:Object.keys(m).length>0?m:void 0})),{successLabel:`Created`});return}p[`domain-name`]===void 0&&(p[`domain-name`]=await f(`domain-name`,"Fully qualified domain name (FQDN) including the extension (e.g., `example.com`, `mybrand.app`). The domain name uniquely identifies a registration — the same domain cannot be registered twice, making it a natural idempotency key for registration requests. "));let _={};p[`auto-renew`]!==void 0&&a(_,[`auto_renew`],p[`auto-renew`]),p[`contacts-registrant-email`]!==void 0&&a(_,[`contacts`,`registrant`,`email`],u(p[`contacts-registrant-email`],`contacts-registrant-email`,`text`)),p[`contacts-registrant-fax`]!==void 0&&a(_,[`contacts`,`registrant`,`fax`],u(p[`contacts-registrant-fax`],`contacts-registrant-fax`,`text`)),p[`contacts-registrant-phone`]!==void 0&&a(_,[`contacts`,`registrant`,`phone`],u(p[`contacts-registrant-phone`],`contacts-registrant-phone`,`text`)),p[`contacts-registrant-postal-info-name`]!==void 0&&a(_,[`contacts`,`registrant`,`postal_info`,`name`],u(p[`contacts-registrant-postal-info-name`],`contacts-registrant-postal-info-name`,`text`)),p[`contacts-registrant-postal-info-organization`]!==void 0&&a(_,[`contacts`,`registrant`,`postal_info`,`organization`],u(p[`contacts-registrant-postal-info-organization`],`contacts-registrant-postal-info-organization`,`text`)),p[`domain-name`]!==void 0&&a(_,[`domain_name`],u(p[`domain-name`],`domain-name`,`text`)),p[`privacy-mode`]!==void 0&&a(_,[`privacy_mode`],u(p[`privacy-mode`],`privacy-mode`,`text`)),p.years!==void 0&&a(_,[`years`],p.years),s(await l(`Creating`,async()=>n(h,`POST`,`/accounts/${g}/registrar/registrations`,{body:Object.keys(_).length>0?_:void 0,headers:Object.keys(m).length>0?m:void 0})),{successLabel:`Created`})}};function b(e){return e.positional(`domain-name`,{type:`string`,description:"Fully qualified domain name (FQDN) including the extension (e.g., `example.com`, `mybrand.app`). The domain name uniquely identifies a registration — the same domain cannot be registered twice, making it a natural idempotency key for registration requests.",demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const x={command:`get-status <domain-name>`,describe:"Returns the current status of a domain registration workflow. Use this endpoint to poll for completion when the POST response returned `202 Accepted`. The URL is provided in the `links.self` field of the workflow status response. Poll this endpoint until the workflow reaches a terminal state or a state that requires user attention. **Terminal states:** `succeeded` and `failed` are terminal and always have `completed: true`. **Non-terminal states:** - `action_required` has `completed: false` and will not resolve on its own. The workflow is paused pending user intervention. - `blocked` has `completed: false` and indicates the workflow is waiting on a third party such as the extension registry or losing registrar. Continue polling while informing the user of the delay. Use increasing backoff between polls. When `state: blocked`, use a longer polling interval and do not poll indefinitely. A naive polling loop that only checks `completed` can run indefinitely when `state: action_required`. Break explicitly on `action_required`: ```js let status; do { await new Promise(r => setTimeout(r, 2000)); status = await cloudflare.request({ method: 'GET', path: reg.result.links.self, }); } while ( !status.result.completed && status.result.state !== 'action_required' ); if (status.result.state === 'action_required') { // Surface context.action and context.confirmation_sent_to to the user. // Do not re-submit the registration request. } ```",builder:b,handler:async n=>{if(n.dryRun){c({command:`cf registrar registrations get-status`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/registrations/${n[`domain-name`]==null?`<domain-name>`:encodeURIComponent(String(n[`domain-name`]))}/registration-status`,pathParams:{"domain-name":String(n[`domain-name`]??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();n.accountId=a,s(await l(`Loading`,async()=>i.registrar.registrations.getStatus({account_id:a,domain_name:n[`domain-name`]})),{successLabel:`Loaded`})}};function S(e){return e.positional(`domain-name`,{type:`string`,description:"Fully qualified domain name (FQDN) including the extension (e.g., `example.com`, `mybrand.app`). The domain name uniquely identifies a registration — the same domain cannot be registered twice, making it a natural idempotency key for registration requests.",demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const C={command:`get-update-status <domain-name>`,describe:"Returns the current status of a domain update workflow. Use this endpoint to poll for completion when the PATCH response returned `202 Accepted`. The URL is provided in the `links.self` field of the workflow status response. Poll this endpoint until the workflow reaches a terminal state or a state that requires user attention. Use increasing backoff between polls. When the workflow remains blocked on a third party, use a longer polling interval and do not poll indefinitely.",builder:S,handler:async n=>{if(n.dryRun){c({command:`cf registrar registrations get-update-status`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/registrations/${n[`domain-name`]==null?`<domain-name>`:encodeURIComponent(String(n[`domain-name`]))}/update-status`,pathParams:{"domain-name":String(n[`domain-name`]??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();n.accountId=a,s(await l(`Loading`,async()=>i.registrar.registrations.getUpdateStatus({account_id:a,domain_name:n[`domain-name`]})),{successLabel:`Loaded`})}};function w(e){return e.positional(`domain-name`,{type:`string`,description:`Domain name to retrieve.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`get <domain-name>`,describe:"Returns the current state of a domain registration. This is the canonical read endpoint for a domain you own. It returns the full registration resource including current settings and expiration. When the registration resource is ready, both `created_at` and `expires_at` are present in the response.",builder:w,handler:async n=>{if(n.dryRun){c({command:`cf registrar registrations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/registrations/${n[`domain-name`]==null?`<domain-name>`:encodeURIComponent(String(n[`domain-name`]))}`,pathParams:{"domain-name":String(n[`domain-name`]??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();n.accountId=a,s(await l(`Loading`,async()=>i.registrar.registrations.get({account_id:a,domain_name:n[`domain-name`]})),{successLabel:`Loaded`})}};function E(e){return e.option(`cursor`,{type:`string`,description:`Opaque token from a previous response's \`result_info.cursor\`.
|
|
40
40
|
Pass this value to fetch the next page of results. Omit (or
|
|
41
|
-
pass an empty string) for the first page.`}).option(`per-page`,{type:`number`,description:`Number of items to return per page.`}).option(`direction`,{type:`string`,description:`Sort direction for results. Defaults to ascending order.`,choices:[`asc`,`desc`]}).option(`sort-by`,{type:`string`,description:"Column to sort results by. Defaults to registration date\n(`registry_created_at`) when omitted.",choices:[`registry_created_at`,`registry_expires_at`,`name`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const D={command:`list`,describe:"Returns a paginated list of domain registrations owned by the account. This endpoint uses cursor-based pagination. Results are ordered by registration date by default. To fetch the next page, pass the `cursor` value from the `result_info` object in the response as the `cursor` query parameter in your next request. An empty `cursor` string indicates there are no more pages.",builder:p(E),handler:async
|
|
41
|
+
pass an empty string) for the first page.`}).option(`per-page`,{type:`number`,description:`Number of items to return per page.`}).option(`direction`,{type:`string`,description:`Sort direction for results. Defaults to ascending order.`,choices:[`asc`,`desc`]}).option(`sort-by`,{type:`string`,description:"Column to sort results by. Defaults to registration date\n(`registry_created_at`) when omitted.",choices:[`registry_created_at`,`registry_expires_at`,`name`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const D={command:`list`,describe:"Returns a paginated list of domain registrations owned by the account. This endpoint uses cursor-based pagination. Results are ordered by registration date by default. To fetch the next page, pass the `cursor` value from the `result_info` object in the response as the `cursor` query parameter in your next request. An empty `cursor` string indicates there are no more pages.",builder:p(E),handler:async n=>{let i={cursor:n.cursor,per_page:n[`per-page`],direction:n.direction,sort_by:n[`sort-by`]};if(n.dryRun){c({command:`cf registrar registrations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/registrations`,pathParams:{},query:i,bodyKind:`none`});return}let a=await r(n),o=n.local?d:await e();n.accountId=o,s(await l(`Loading`,async()=>a.registrar.registrations.list({account_id:o,...i})),{successLabel:`Loaded`})}};function O(e){return e.positional(`domain-name`,{type:`string`,description:`Domain name to update.`,demandOption:!0}).option(`prefer`,{type:`string`,description:"Set to `respond-async` to receive an immediate `202 Accepted` without\nwaiting for the operation to complete (RFC 7240)."}).option(`auto-renew`,{type:`boolean`,description:`Enable or disable automatic renewal.
|
|
42
42
|
Setting this field to \`true\` authorizes Cloudflare to charge the
|
|
43
43
|
account's default payment method up to 30 days before domain expiry
|
|
44
44
|
to renew the domain automatically. Renewal pricing may change over
|
|
45
45
|
time based on registry pricing.
|
|
46
|
-
`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:"Request to update an existing domain registration. This endpoint currently supports updating `auto_renew` only. "})}const k={command:`update <domain-name>`,describe:"Updates an existing domain registration. By default, the server holds the connection for a bounded, server-defined amount of time while the update completes. Most updates finish within this window and return `200 OK` with a completed workflow status. If the update is still processing after this synchronous wait window, the server returns `202 Accepted`. Poll the URL in `links.self` to track progress. To skip the wait and receive an immediate `202`, send `Prefer: respond-async`. This endpoint currently supports updating `auto_renew` only.",builder:O,handler:async
|
|
46
|
+
`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:"Request to update an existing domain registration. This endpoint currently supports updating `auto_renew` only. "})}const k={command:`update <domain-name>`,describe:"Updates an existing domain registration. By default, the server holds the connection for a bounded, server-defined amount of time while the update completes. Most updates finish within this window and return `200 OK` with a completed workflow status. If the update is still processing after this synchronous wait window, the server returns `202 Accepted`. Poll the URL in `links.self` to track progress. To skip the wait and receive an immediate `202`, send `Prefer: respond-async`. This endpoint currently supports updating `auto_renew` only.",builder:O,handler:async u=>{let f={};if(u.prefer!==void 0&&(f.Prefer=String(u.prefer)),u.dryRun){c({command:`cf registrar registrations update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/registrar/registrations/${u[`domain-name`]==null?`<domain-name>`:encodeURIComponent(String(u[`domain-name`]))}`,pathParams:{"domain-name":String(u[`domain-name`]??``)},bodyKind:`json`,body:u.body===void 0?o({auto_renew:u[`auto-renew`]}):i(u.body)});return}let p=await r(u),m=u.local?d:await e();if(u.accountId=m,u.body){let e=i(u.body);s(await l(`Updating`,async()=>n(p,`PATCH`,`/accounts/${m}/registrar/registrations/${encodeURIComponent(String(u[`domain-name`]))}`,{body:e,headers:Object.keys(f).length>0?f:void 0})),{successLabel:`Updated`});return}let h={};u[`auto-renew`]!==void 0&&a(h,[`auto_renew`],u[`auto-renew`]),s(await l(`Updating`,async()=>n(p,`PATCH`,`/accounts/${m}/registrar/registrations/${encodeURIComponent(String(u[`domain-name`]))}`,{body:Object.keys(h).length>0?h:void 0,headers:Object.keys(f).length>0?f:void 0})),{successLabel:`Updated`})}},A={command:`registrations`,describe:`Domain registrations — purchase, view, update, and inspect registration status`,builder:e=>e.command(y).command(T).command(x).command(C).command(D).command(k).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},j={command:`registrar`,describe:`Domain registration and transfer management through Cloudflare Registrar`,builder:e=>e.command(h).command(_).command(A).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{j as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{n as r,t as i}from"./body-parser-DWSy7uZ8.mjs";import{t as a}from"./output-B6fBFRqe.mjs";import{n as o,t as s}from"./progress-CL8I-7YK.mjs";import{n as c}from"./input-validation-_fMCApaH.mjs";import{t as l}from"./local-CYc9q7l2.mjs";import{r as u}from"./prompt-q3B7sM2A.mjs";function d(e){return e.option(`body-base64`,{type:`string`,description:`Base64 encoded request body`}).option(`body-plain-text`,{type:`string`,description:`Request body as plain text`}).option(`context-bot-score`,{type:`number`,description:`Bot score used for evaluating tracing request processing`}).option(`context-geoloc-city`,{type:`string`,description:`The context.geoloc.city field`}).option(`context-geoloc-continent`,{type:`string`,description:`The context.geoloc.continent field`}).option(`context-geoloc-is-eu-country`,{type:`boolean`,description:`The context.geoloc.is_eu_country field`}).option(`context-geoloc-iso-code`,{type:`string`,description:`The context.geoloc.iso_code field`}).option(`context-geoloc-latitude`,{type:`number`,description:`The context.geoloc.latitude field`}).option(`context-geoloc-longitude`,{type:`number`,description:`The context.geoloc.longitude field`}).option(`context-geoloc-postal-code`,{type:`string`,description:`The context.geoloc.postal_code field`}).option(`context-geoloc-region-code`,{type:`string`,description:`The context.geoloc.region_code field`}).option(`context-geoloc-subdivision-2-iso-code`,{type:`string`,description:`The context.geoloc.subdivision_2_iso_code field`}).option(`context-geoloc-timezone`,{type:`string`,description:`The context.geoloc.timezone field`}).option(`context-skip-challenge`,{type:`boolean`,description:`Whether to skip any challenges for tracing request (e.g.: captcha)`}).option(`context-threat-score`,{type:`number`,description:`Threat score used for evaluating tracing request processing`}).option(`method`,{type:`string`,description:`HTTP Method of tracing request`}).option(`protocol`,{type:`string`,description:`HTTP Protocol of tracing request`}).option(`skip-response`,{type:`boolean`,description:`Skip sending the request to the Origin server after all rules evaluation`}).option(`url`,{type:`string`,description:`URL to which perform tracing request`}).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 f={command:`create`,describe:`Traces a simulated HTTP request through Cloudflare's edge to analyze how rules, settings, and configurations would process the request. Useful for debugging firewall rules, page rules, and other request transformations without sending actual traffic. Supports custom headers, cookies, body content, and geolocation context.`,builder:d,handler:async d=>{if(d.dryRun){o({command:`cf request-tracers traces create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/request-tracer/trace`,pathParams:{},bodyKind:`json`,body:d.body===void 0?i({body:{base64:c(d[`body-base64`],`body-base64`,`text`),plain_text:c(d[`body-plain-text`],`body-plain-text`,`text`)},context:{bot_score:d[`context-bot-score`],geoloc:{city:c(d[`context-geoloc-city`],`context-geoloc-city`,`text`),continent:c(d[`context-geoloc-continent`],`context-geoloc-continent`,`text`),is_eu_country:d[`context-geoloc-is-eu-country`],iso_code:c(d[`context-geoloc-iso-code`],`context-geoloc-iso-code`,`text`),latitude:d[`context-geoloc-latitude`],longitude:d[`context-geoloc-longitude`],postal_code:c(d[`context-geoloc-postal-code`],`context-geoloc-postal-code`,`text`),region_code:c(d[`context-geoloc-region-code`],`context-geoloc-region-code`,`text`),subdivision_2_iso_code:c(d[`context-geoloc-subdivision-2-iso-code`],`context-geoloc-subdivision-2-iso-code`,`text`),timezone:c(d[`context-geoloc-timezone`],`context-geoloc-timezone`,`text`)},skip_challenge:d[`context-skip-challenge`],threat_score:d[`context-threat-score`]},method:c(d.method,`method`,`text`),protocol:c(d.protocol,`protocol`,`text`),skip_response:d[`skip-response`],url:c(d.url,`url`,`text`)}):r(d.body)});return}let f=await n(d),p=d.local?l:await e();if(d.accountId=p,d.body){let e=r(d.body);a(await s(`Creating`,async()=>f.requestTracers.traces.create({...e,account_id:p})),{successLabel:`Created`});return}d.method===void 0&&(d.method=await u(`method`,`HTTP Method of tracing request`)),d.url===void 0&&(d.url=await u(`url`,`URL to which perform tracing request`));let m=i({body:{base64:c(d[`body-base64`],`body-base64`,`text`),plain_text:c(d[`body-plain-text`],`body-plain-text`,`text`)},context:{bot_score:d[`context-bot-score`],geoloc:{city:c(d[`context-geoloc-city`],`context-geoloc-city`,`text`),continent:c(d[`context-geoloc-continent`],`context-geoloc-continent`,`text`),is_eu_country:d[`context-geoloc-is-eu-country`],iso_code:c(d[`context-geoloc-iso-code`],`context-geoloc-iso-code`,`text`),latitude:d[`context-geoloc-latitude`],longitude:d[`context-geoloc-longitude`],postal_code:c(d[`context-geoloc-postal-code`],`context-geoloc-postal-code`,`text`),region_code:c(d[`context-geoloc-region-code`],`context-geoloc-region-code`,`text`),subdivision_2_iso_code:c(d[`context-geoloc-subdivision-2-iso-code`],`context-geoloc-subdivision-2-iso-code`,`text`),timezone:c(d[`context-geoloc-timezone`],`context-geoloc-timezone`,`text`)},skip_challenge:d[`context-skip-challenge`],threat_score:d[`context-threat-score`]},method:c(d.method,`method`,`text`),protocol:c(d.protocol,`protocol`,`text`),skip_response:d[`skip-response`],url:c(d.url,`url`,`text`)});a(await s(`Creating`,async()=>f.requestTracers.traces.create({...m,account_id:p})),{successLabel:`Created`})}},p={command:`traces`,describe:`Operations for traces`,builder:e=>e.command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},m={command:`request-tracers`,describe:`request-tracers`,builder:e=>e.command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{m as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{n as r,t as i}from"./body-parser-DWSy7uZ8.mjs";import{t as a}from"./output-B6fBFRqe.mjs";import{n as o,t as s}from"./progress-CL8I-7YK.mjs";import{n as c}from"./input-validation-_fMCApaH.mjs";import{t as l}from"./local-CYc9q7l2.mjs";import{n as u,r as d,t as f}from"./prompt-q3B7sM2A.mjs";import{t as p}from"./cli-types-DGgEbf8K.mjs";function m(e){return e.option(`name`,{type:`string`,description:`The name of the share.`}).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 resource share for sharing Cloudflare resources with other accounts or organizations.`,builder:m,handler:async u=>{if(u.dryRun){o({command:`cf resource-sharing create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares`,pathParams:{},bodyKind:`json`,body:u.body===void 0?i({name:c(u.name,`name`,`text`)}):r(u.body)});return}let f=await n(u),p=u.local?l:await e();if(u.accountId=p,u.body){let e=r(u.body);a(await s(`Creating`,async()=>f.resourceSharing.create({...e,account_id:p})),{successLabel:`Created`});return}u.name===void 0&&(u.name=await d(`name`,`The name of the share.`));let m=i({name:c(u.name,`name`,`text`)});a(await s(`Creating`,async()=>f.resourceSharing.create({...m,account_id:p})),{successLabel:`Created`})}};function g(e){return e.positional(`share-id`,{type:`string`,description:`Share identifier tag.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const _={command:`delete <share-id>`,describe:`Deletion is not immediate, an updated share object with a new status will be returned.`,builder:g,handler:async r=>{if(r.dryRun){o({command:`cf resource-sharing delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${r[`share-id`]==null?`<share-id>`:encodeURIComponent(String(r[`share-id`]))}`,pathParams:{"share-id":String(r[`share-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await f({force:!!r.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}a(await s(`Deleting`,async()=>i.resourceSharing.delete({account_id:c,share_id:r[`share-id`]})),{successLabel:`Deleted`})}};function v(e){return e.positional(`share-id`,{type:`string`,description:`Share identifier tag.`,demandOption:!0}).option(`include-resources`,{type:`boolean`,description:`Include resources in the response.`}).option(`include-recipient-counts`,{type:`boolean`,description:`Include recipient counts in the response.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`get <share-id>`,describe:`Fetches share by ID.`,builder:v,handler:async r=>{let i={include_resources:r[`include-resources`],include_recipient_counts:r[`include-recipient-counts`]};if(r.dryRun){o({command:`cf resource-sharing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${r[`share-id`]==null?`<share-id>`:encodeURIComponent(String(r[`share-id`]))}`,pathParams:{"share-id":String(r[`share-id`]??``)},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.resourceSharing.get({account_id:u,share_id:r[`share-id`],...i})),{successLabel:`Loaded`})}};function b(e){return e.option(`status`,{type:`string`,description:`Filter shares by status.`,choices:[`active`,`deleting`,`deleted`]}).option(`kind`,{type:`string`,description:`Filter shares by kind.`,choices:[`sent`,`received`]}).option(`target-type`,{type:`string`,description:`Filter shares by target_type.`,choices:[`account`,`organization`]}).option(`resource-types`,{type:`string`,description:`Filter share resources by resource_types.`}).option(`order`,{type:`string`,description:`Order shares by values in the given field.`,choices:[`name`,`created`]}).option(`direction`,{type:`string`,description:`Direction to sort objects.`,choices:[`asc`,`desc`]}).option(`page`,{type:`number`,description:"Page number. Defaults to `1` when `per_page` is supplied without\n`page`. May be omitted entirely along with `per_page` to receive a\nnon-paginated response."}).option(`per-page`,{type:`number`,description:"Number of objects to return per page. Defaults to `20` when `page`\nis supplied without `per_page`. May be omitted entirely along with\n`page` to receive a non-paginated response."}).option(`include-resources`,{type:`boolean`,description:`Include resources in the response.`}).option(`include-recipient-counts`,{type:`boolean`,description:`Include recipient counts in the response.`}).option(`tag`,{type:`string`,description:"Filter shares by tag. Each value is either `key=value` (matches shares whose tags contain that key/value pair) or `key` alone (matches shares that have any value for that key). May be repeated; multiple `tag` parameters are ANDed together. Maximum 20 `tag` parameters per request."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const x={command:`list`,describe:`Lists all account shares.`,builder:p(b),handler:async r=>{let i={status:r.status,kind:r.kind,target_type:r[`target-type`],resource_types:r[`resource-types`],order:r.order,direction:r.direction,page:r.page,per_page:r[`per-page`],include_resources:r[`include-resources`],include_recipient_counts:r[`include-recipient-counts`],tag:r.tag};if(r.dryRun){o({command:`cf resource-sharing list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares`,pathParams:{},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.resourceSharing.list({account_id:u,...i})),{successLabel:`Loaded`})}};function S(e){return e.positional(`share-id`,{type:`string`,description:`Share identifier tag.`,demandOption:!0}).option(`organization-id`,{type:`string`,description:`Organization identifier.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:"Optionally specify `recipient_account_id` to target a specific account, or `organization_id` to target the caller's whole organization. If neither is provided, the caller's organization is used. The legacy field `account_id` is accepted as a synonym for `recipient_account_id` during the deprecation period (see `x-sunset` on that field). "})}const C={command:`create <share-id>`,describe:`Adds a recipient to a resource share, granting them access to the shared resources.`,builder:S,handler:async u=>{if(u.dryRun){o({command:`cf resource-sharing recipients create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${u[`share-id`]==null?`<share-id>`:encodeURIComponent(String(u[`share-id`]))}/recipients`,pathParams:{"share-id":String(u[`share-id`]??``)},bodyKind:`json`,body:u.body===void 0?i({organization_id:c(u[`organization-id`],`organization-id`,`text`)}):r(u.body)});return}let d=await n(u),f=u.local?l:await e();if(u.accountId=f,u.body){let e=r(u.body);a(await s(`Creating`,async()=>d.resourceSharing.recipients.create({body:e,account_id:f,share_id:u[`share-id`]})),{successLabel:`Created`});return}let p=i({organization_id:c(u[`organization-id`],`organization-id`,`text`)});a(await s(`Creating`,async()=>d.resourceSharing.recipients.create({body:p,account_id:f,share_id:u[`share-id`]})),{successLabel:`Created`})}};function w(e){return e.positional(`recipient-id`,{type:`string`,description:`Share Recipient identifier tag.`,demandOption:!0}).option(`share-id`,{type:`string`,description:`Share identifier tag.`,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 T={command:`delete <recipient-id>`,describe:`Deletion is not immediate, an updated share recipient object with a new status will be returned.`,builder:w,handler:async r=>{if(r.dryRun){o({command:`cf resource-sharing recipients delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${r[`share-id`]==null?`<share-id>`:encodeURIComponent(String(r[`share-id`]))}/recipients/${r[`recipient-id`]==null?`<recipient-id>`:encodeURIComponent(String(r[`recipient-id`]))}`,pathParams:{"share-id":String(r[`share-id`]??``),"recipient-id":String(r[`recipient-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await f({force:!!r.force})){process.stderr.write(`Aborted.
|
|
4
|
+
`);return}a(await s(`Deleting`,async()=>i.resourceSharing.recipients.delete({account_id:c,share_id:r[`share-id`],recipient_id:r[`recipient-id`]})),{successLabel:`Deleted`})}};function E(e){return e.positional(`recipient-id`,{type:`string`,description:`Share Recipient identifier tag.`,demandOption:!0}).option(`share-id`,{type:`string`,description:`Share identifier tag.`,demandOption:!0}).option(`include-resources`,{type:`boolean`,description:`Include resources in the response.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const D={command:`get <recipient-id>`,describe:`Get share recipient by ID.`,builder:E,handler:async r=>{let i={include_resources:r[`include-resources`]};if(r.dryRun){o({command:`cf resource-sharing recipients get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${r[`share-id`]==null?`<share-id>`:encodeURIComponent(String(r[`share-id`]))}/recipients/${r[`recipient-id`]==null?`<recipient-id>`:encodeURIComponent(String(r[`recipient-id`]))}`,pathParams:{"share-id":String(r[`share-id`]??``),"recipient-id":String(r[`recipient-id`]??``)},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.resourceSharing.recipients.get({account_id:u,share_id:r[`share-id`],recipient_id:r[`recipient-id`],...i})),{successLabel:`Loaded`})}};function O(e){return e.option(`share-id`,{type:`string`,description:`Share identifier tag.`,demandOption:!0}).option(`include-resources`,{type:`boolean`,description:`Include resources in the response.`}).option(`page`,{type:`number`,description:"Page number. Defaults to `1` when `per_page` is supplied without\n`page`. May be omitted entirely along with `per_page` to receive a\nnon-paginated response."}).option(`per-page`,{type:`number`,description:"Number of objects to return per page. Defaults to `20` when `page`\nis supplied without `per_page`. May be omitted entirely along with\n`page` to receive a non-paginated response."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const k={command:`list`,describe:`List share recipients by share ID.`,builder:O,handler:async r=>{let i={include_resources:r[`include-resources`],page:r.page,per_page:r[`per-page`]};if(r.dryRun){o({command:`cf resource-sharing recipients list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${r[`share-id`]==null?`<share-id>`:encodeURIComponent(String(r[`share-id`]))}/recipients`,pathParams:{"share-id":String(r[`share-id`]??``)},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.resourceSharing.recipients.list({account_id:u,share_id:r[`share-id`],...i})),{successLabel:`Loaded`})}};function A(e){return e.positional(`share-id`,{type:`string`,description:`Share identifier tag.`,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 j={command:`update <share-id>`,describe:`Changes a share's recipients to match the given list. Returns an error if the share targets an organization.`,builder:A,handler:async i=>{if(i.dryRun){o({command:`cf resource-sharing recipients update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${i[`share-id`]==null?`<share-id>`:encodeURIComponent(String(i[`share-id`]))}/recipients`,pathParams:{"share-id":String(i[`share-id`]??``)},bodyKind:`json`,body:i.body===void 0?void 0:r(i.body)});return}let c=await n(i),u=i.local?l:await e();if(i.accountId=u,i.body){let e=r(i.body);a(await s(`Updating`,async()=>c.resourceSharing.recipients.update({body:e,account_id:u,share_id:i[`share-id`]})),{successLabel:`Updated`});return}if(i.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},M={command:`recipients`,describe:`Operations for recipients`,builder:e=>e.command(C).command(T).command(D).command(k).command(j).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function N(e){return e.positional(`share-id`,{type:`string`,description:`Share identifier tag.`,demandOption:!0}).option(`resource-account-id`,{type:`string`,description:`Account identifier.`}).option(`resource-id`,{type:`string`,description:`Share Resource identifier.`}).option(`resource-type`,{type:`string`,description:`Resource Type.`,choices:[`custom-ruleset`,`gateway-policy`,`gateway-destination-ip`,`gateway-block-page-settings`,`gateway-extended-email-matching`,`idp-federation-grant`]}).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:`create <share-id>`,describe:`Adds a resource to an existing share, making it available to share recipients.`,builder:N,handler:async f=>{if(f.dryRun){o({command:`cf resource-sharing resources create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${f[`share-id`]==null?`<share-id>`:encodeURIComponent(String(f[`share-id`]))}/resources`,pathParams:{"share-id":String(f[`share-id`]??``)},bodyKind:`json`,body:f.body===void 0?i({resource_account_id:c(f[`resource-account-id`],`resource-account-id`,`text`),resource_id:c(f[`resource-id`],`resource-id`,`text`),resource_type:c(f[`resource-type`],`resource-type`,`text`)}):r(f.body)});return}let p=await n(f),m=f.local?l:await e();if(f.accountId=m,f.body){let e=r(f.body);a(await s(`Creating`,async()=>p.resourceSharing.resources.create({body:e,account_id:m,share_id:f[`share-id`]})),{successLabel:`Created`});return}f[`resource-account-id`]===void 0&&(f[`resource-account-id`]=await d(`resource-account-id`,`Account identifier.`)),f[`resource-id`]===void 0&&(f[`resource-id`]=await d(`resource-id`,`Share Resource identifier.`)),f[`resource-type`]===void 0&&(f[`resource-type`]=await u(`resource-type`,`Resource Type.`,[`custom-ruleset`,`gateway-policy`,`gateway-destination-ip`,`gateway-block-page-settings`,`gateway-extended-email-matching`,`idp-federation-grant`]));let h=i({resource_account_id:c(f[`resource-account-id`],`resource-account-id`,`text`),resource_id:c(f[`resource-id`],`resource-id`,`text`),resource_type:c(f[`resource-type`],`resource-type`,`text`)});a(await s(`Creating`,async()=>p.resourceSharing.resources.create({body:h,account_id:m,share_id:f[`share-id`]})),{successLabel:`Created`})}};function F(e){return e.positional(`share-resource-id`,{type:`string`,description:`Share Resource identifier.`,demandOption:!0}).option(`share-id`,{type:`string`,description:`Share identifier tag.`,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 I={command:`delete <share-resource-id>`,describe:`Deletion is not immediate, an updated share resource object with a new status will be returned.`,builder:F,handler:async r=>{if(r.dryRun){o({command:`cf resource-sharing resources delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${r[`share-id`]==null?`<share-id>`:encodeURIComponent(String(r[`share-id`]))}/resources/${r[`share-resource-id`]==null?`<share-resource-id>`:encodeURIComponent(String(r[`share-resource-id`]))}`,pathParams:{"share-id":String(r[`share-id`]??``),"share-resource-id":String(r[`share-resource-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await f({force:!!r.force})){process.stderr.write(`Aborted.
|
|
5
|
+
`);return}a(await s(`Deleting`,async()=>i.resourceSharing.resources.delete({account_id:c,share_id:r[`share-id`],share_resource_id:r[`share-resource-id`]})),{successLabel:`Deleted`})}};function L(e){return e.positional(`share-resource-id`,{type:`string`,description:`Share Resource identifier.`,demandOption:!0}).option(`share-id`,{type:`string`,description:`Share identifier tag.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const R={command:`get <share-resource-id>`,describe:`Get share resource by ID.`,builder:L,handler:async r=>{if(r.dryRun){o({command:`cf resource-sharing resources get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${r[`share-id`]==null?`<share-id>`:encodeURIComponent(String(r[`share-id`]))}/resources/${r[`share-resource-id`]==null?`<share-resource-id>`:encodeURIComponent(String(r[`share-resource-id`]))}`,pathParams:{"share-id":String(r[`share-id`]??``),"share-resource-id":String(r[`share-resource-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.resourceSharing.resources.get({account_id:c,share_id:r[`share-id`],share_resource_id:r[`share-resource-id`]})),{successLabel:`Loaded`})}};function z(e){return e.option(`share-id`,{type:`string`,description:`Share identifier tag.`,demandOption:!0}).option(`status`,{type:`string`,description:`Filter share resources by status.`,choices:[`active`,`deleting`,`deleted`]}).option(`resource-type`,{type:`string`,description:`Filter share resources by resource_type.`,choices:[`custom-ruleset`,`gateway-policy`,`gateway-destination-ip`,`gateway-block-page-settings`,`gateway-extended-email-matching`,`idp-federation-grant`]}).option(`page`,{type:`number`,description:"Page number. Defaults to `1` when `per_page` is supplied without\n`page`. May be omitted entirely along with `per_page` to receive a\nnon-paginated response."}).option(`per-page`,{type:`number`,description:"Number of objects to return per page. Defaults to `20` when `page`\nis supplied without `per_page`. May be omitted entirely along with\n`page` to receive a non-paginated response."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const B={command:`list`,describe:`List share resources by share ID.`,builder:p(z),handler:async r=>{let i={status:r.status,resource_type:r[`resource-type`],page:r.page,per_page:r[`per-page`]};if(r.dryRun){o({command:`cf resource-sharing resources list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${r[`share-id`]==null?`<share-id>`:encodeURIComponent(String(r[`share-id`]))}/resources`,pathParams:{"share-id":String(r[`share-id`]??``)},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.resourceSharing.resources.list({account_id:u,share_id:r[`share-id`],...i})),{successLabel:`Loaded`})}};function V(e){return e.positional(`share-resource-id`,{type:`string`,description:`Share Resource identifier.`,demandOption:!0}).option(`share-id`,{type:`string`,description:`Share identifier tag.`,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 H={command:`update <share-resource-id>`,describe:`Update is not immediate, an updated share resource object with a new status will be returned.`,builder:V,handler:async i=>{if(i.dryRun){o({command:`cf resource-sharing resources update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${i[`share-id`]==null?`<share-id>`:encodeURIComponent(String(i[`share-id`]))}/resources/${i[`share-resource-id`]==null?`<share-resource-id>`:encodeURIComponent(String(i[`share-resource-id`]))}`,pathParams:{"share-id":String(i[`share-id`]??``),"share-resource-id":String(i[`share-resource-id`]??``)},bodyKind:`json`,body:i.body===void 0?void 0:r(i.body)});return}let c=await n(i),u=i.local?l:await e();if(i.accountId=u,i.body){let e=r(i.body);a(await s(`Updating`,async()=>c.resourceSharing.resources.update({...e,account_id:u,share_id:i[`share-id`],share_resource_id:i[`share-resource-id`]})),{successLabel:`Updated`});return}if(i.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},U={command:`resources`,describe:`Operations for resources`,builder:e=>e.command(P).command(I).command(R).command(B).command(H).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function W(e){return e.positional(`share-id`,{type:`string`,description:`Share identifier tag.`,demandOption:!0}).option(`name`,{type:`string`,description:`The name of the share.`}).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:`update <share-id>`,describe:`Updating is not immediate, an updated share object with a new status will be returned.`,builder:W,handler:async u=>{if(u.dryRun){o({command:`cf resource-sharing update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/shares/${u[`share-id`]==null?`<share-id>`:encodeURIComponent(String(u[`share-id`]))}`,pathParams:{"share-id":String(u[`share-id`]??``)},bodyKind:`json`,body:u.body===void 0?i({name:c(u.name,`name`,`text`)}):r(u.body)});return}let f=await n(u),p=u.local?l:await e();if(u.accountId=p,u.body){let e=r(u.body);a(await s(`Updating`,async()=>f.resourceSharing.update({...e,account_id:p,share_id:u[`share-id`]})),{successLabel:`Updated`});return}u.name===void 0&&(u.name=await d(`name`,`The name of the share.`));let m=i({name:c(u.name,`name`,`text`)});a(await s(`Updating`,async()=>f.resourceSharing.update({...m,account_id:p,share_id:u[`share-id`]})),{successLabel:`Updated`})}},K={command:`resource-sharing`,describe:`resource-sharing`,builder:e=>e.command(h).command(_).command(y).command(x).command(G).command(M).command(U).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{K as default};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{N as e,O as t,P as n}from"./oauth-B5k80sip.mjs";import{i as r,n as i}from"./auth-DX9KnJ0P.mjs";import{n as a,r as o,t as s}from"./body-parser-DWSy7uZ8.mjs";import{t as c}from"./output-B6fBFRqe.mjs";import{n as l,t as u}from"./progress-CL8I-7YK.mjs";import{n as d}from"./input-validation-_fMCApaH.mjs";import{t as f}from"./local-CYc9q7l2.mjs";import{n as p,r as m,t as h}from"./prompt-q3B7sM2A.mjs";import{t as g}from"./cli-types-DGgEbf8K.mjs";function _(e){return e.option(`if-match`,{type:`string`,description:`ETag value for optimistic concurrency control. When provided, the server will
|
|
3
|
+
verify the current resource ETag matches before applying the write. Returns
|
|
4
|
+
412 Precondition Failed if the resource has been modified since the ETag was
|
|
5
|
+
obtained. Omit this header for unconditional writes.`}).option(`resource-id`,{type:`string`,description:`Identifies the unique resource.`}).option(`resource-type`,{type:`string`,description:`Enum for worker_version resource type.`,choices:[`worker_version`]}).option(`worker-id`,{type:`string`,description:`Worker ID is required only for worker_version resources`}).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:`Request body schema for deleting tags from account-level resources. Use /zones/{zone_id}/tags for zone-level resources.`})}const v={command:`delete`,describe:`Removes all tags from a specific account-level resource.`,builder:_,handler:async e=>{let g={};if(e[`if-match`]!==void 0&&(g[`If-Match`]=String(e[`if-match`])),e.dryRun){l({command:`cf resource-tagging account-tags delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/tags`,pathParams:{},bodyKind:`json`,body:e.body===void 0?s({resource_id:d(e[`resource-id`],`resource-id`,`text`),resource_type:d(e[`resource-type`],`resource-type`,`text`),worker_id:d(e[`worker-id`],`worker-id`,`text`)}):a(e.body)});return}let _=await i(e),v=e.local?f:await t();if(e.accountId=v,!await h({force:!!e.force})){process.stderr.write(`Aborted.
|
|
6
|
+
`);return}if(e.body){let t=a(e.body);c(await u(`Deleting`,async()=>r(_,`DELETE`,`/accounts/${v}/tags`,{body:t,headers:Object.keys(g).length>0?g:void 0})),{successLabel:`Deleted`});return}e[`resource-id`]===void 0&&(e[`resource-id`]=await m(`resource-id`,`Identifies the unique resource.`)),e[`resource-type`]===void 0&&(e[`resource-type`]=await p(`resource-type`,`Enum for worker_version resource type.`,[`worker_version`]));let y={};e[`resource-id`]!==void 0&&o(y,[`resource_id`],d(e[`resource-id`],`resource-id`,`text`)),e[`resource-type`]!==void 0&&o(y,[`resource_type`],d(e[`resource-type`],`resource-type`,`text`)),e[`worker-id`]!==void 0&&o(y,[`worker_id`],d(e[`worker-id`],`worker-id`,`text`)),c(await u(`Deleting`,async()=>r(_,`DELETE`,`/accounts/${v}/tags`,{body:Object.keys(y).length>0?y:void 0,headers:Object.keys(g).length>0?g:void 0})),{successLabel:`Deleted`})}};function y(e){return e.option(`resource-id`,{type:`string`,description:`The ID of the resource to retrieve tags for.`,demandOption:!0}).option(`resource-type`,{type:`string`,description:`The type of the resource.`,choices:[`access_application`,`access_group`,`account`,`ai_gateway`,`alerting_policy`,`alerting_webhook`,`cloudflared_tunnel`,`d1_database`,`durable_object_namespace`,`gateway_list`,`gateway_rule`,`image`,`kv_namespace`,`queue`,`r2_bucket`,`resource_share`,`stream_live_input`,`stream_video`,`worker`,`worker_version`],demandOption:!0}).option(`worker-id`,{type:`string`,description:`Worker identifier. Required for worker_version resources.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`get`,describe:`Retrieves tags for a specific account-level resource.`,builder:g(y),handler:async e=>{let r={resource_id:e[`resource-id`],resource_type:e[`resource-type`],worker_id:e[`worker-id`]};if(e.dryRun){l({command:`cf resource-tagging account-tags get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/tags`,pathParams:{},query:r,bodyKind:`none`});return}let a=await i(e),o=e.local?f:await t();e.accountId=o,c(await u(`Loading`,async()=>a.resourceTagging.accountTags.get({account_id:o,...r})),{successLabel:`Loaded`})}};function x(e){return e.option(`if-match`,{type:`string`,description:`ETag value for optimistic concurrency control. When provided, the server will
|
|
7
|
+
verify the current resource ETag matches before applying the write. Returns
|
|
8
|
+
412 Precondition Failed if the resource has been modified since the ETag was
|
|
9
|
+
obtained. Omit this header for unconditional writes.`}).option(`resource-id`,{type:`string`,description:`Identifies the unique resource.`}).option(`resource-type`,{type:`string`,description:`Enum for worker_version resource type.`,choices:[`worker_version`]}).option(`worker-id`,{type:`string`,description:`Worker ID is required only for worker_version resources`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Request body schema for setting tags on account-level resources.`})}const S={command:`update`,describe:`Creates or updates tags for a specific account-level resource.`,builder:x,handler:async e=>{let h={};if(e[`if-match`]!==void 0&&(h[`If-Match`]=String(e[`if-match`])),e.dryRun){l({command:`cf resource-tagging account-tags update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/tags`,pathParams:{},bodyKind:`json`,body:e.body===void 0?s({resource_id:d(e[`resource-id`],`resource-id`,`text`),resource_type:d(e[`resource-type`],`resource-type`,`text`),worker_id:d(e[`worker-id`],`worker-id`,`text`)}):a(e.body)});return}let g=await i(e),_=e.local?f:await t();if(e.accountId=_,e.body){let t=a(e.body);c(await u(`Updating`,async()=>r(g,`PUT`,`/accounts/${_}/tags`,{body:t,headers:Object.keys(h).length>0?h:void 0})),{successLabel:`Updated`});return}e[`resource-id`]===void 0&&(e[`resource-id`]=await m(`resource-id`,`Identifies the unique resource.`)),e[`resource-type`]===void 0&&(e[`resource-type`]=await p(`resource-type`,`Enum for worker_version resource type.`,[`worker_version`]));let v={};e[`resource-id`]!==void 0&&o(v,[`resource_id`],d(e[`resource-id`],`resource-id`,`text`)),e[`resource-type`]!==void 0&&o(v,[`resource_type`],d(e[`resource-type`],`resource-type`,`text`)),e[`worker-id`]!==void 0&&o(v,[`worker_id`],d(e[`worker-id`],`worker-id`,`text`)),c(await u(`Updating`,async()=>r(g,`PUT`,`/accounts/${_}/tags`,{body:Object.keys(v).length>0?v:void 0,headers:Object.keys(h).length>0?h:void 0})),{successLabel:`Updated`})}},C={command:`account-tags`,describe:`Tags applied to the account for organizational grouping and policy targeting`,builder:e=>e.command(v).command(b).command(S).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function w(e){return e.option(`cursor`,{type:`string`,description:`Cursor for pagination.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`list`,describe:`Lists all distinct tag keys used across resources in an account.`,builder:w,handler:async e=>{let r={cursor:e.cursor};if(e.dryRun){l({command:`cf resource-tagging keys list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/tags/keys`,pathParams:{},query:r,bodyKind:`none`});return}let a=await i(e),o=e.local?f:await t();e.accountId=o,c(await u(`Loading`,async()=>a.resourceTagging.keys.list({account_id:o,...r})),{successLabel:`Loaded`})}},E={command:`keys`,describe:`Tag key definitions that establish the vocabulary for tagging resources`,builder:e=>e.command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`type`,{type:`string`,description:`Filter by resource type. Can be repeated to filter by multiple types (OR logic). Example: ?type=zone&type=worker`}).option(`tag`,{type:`string`,description:"Filter resources by tag criteria. This parameter can be repeated multiple times, with AND logic between parameters.\n\nSupported syntax:\n- **Key-only**: `tag=<key>` - Resource must have the tag key (e.g., `tag=production`)\n- **Key-value**: `tag=<key>=<value>` - Resource must have the tag with specific value (e.g., `tag=env=prod`)\n- **Multiple values (OR)**: `tag=<key>=<v1>,<v2>` - Resource must have tag with any of the values (e.g., `tag=env=prod,staging`)\n- **Negate key-only**: `tag=!<key>` - Resource must not have the tag key (e.g., `tag=!archived`)\n- **Negate key-value**: `tag=<key>!=<value>` - Resource must not have the tag with specific value (e.g., `tag=region!=us-west-1`)\n\nMultiple tag parameters are combined with AND logic."}).option(`cursor`,{type:`string`,description:`Cursor for pagination.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`list`,describe:`Lists all tagged resources for an account.`,builder:g(D),handler:async e=>{let r={type:e.type,tag:e.tag,cursor:e.cursor};if(e.dryRun){l({command:`cf resource-tagging list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/tags/resources`,pathParams:{},query:r,bodyKind:`none`});return}let a=await i(e),o=e.local?f:await t();e.accountId=o,c(await u(`Loading`,async()=>a.resourceTagging.list({account_id:o,...r})),{successLabel:`Loaded`})}};function k(e){return e.option(`tag-key`,{type:`string`,description:`The tag key to retrieve values for.`,demandOption:!0}).option(`type`,{type:`string`,description:`Filter by resource type.`,choices:`access_application.access_application_policy.access_group.account.ai_gateway.alerting_policy.alerting_webhook.api_gateway_operation.cloudflared_tunnel.custom_certificate.custom_hostname.d1_database.dns_record.durable_object_namespace.gateway_list.gateway_rule.image.kv_namespace.managed_client_certificate.queue.r2_bucket.resource_share.stream_live_input.stream_video.worker.worker_version.zone`.split(`.`)}).option(`cursor`,{type:`string`,description:`Cursor for pagination.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`list`,describe:`Lists all distinct values for a given tag key, optionally filtered by resource type.`,builder:g(k),handler:async e=>{let r={type:e.type,cursor:e.cursor};if(e.dryRun){l({command:`cf resource-tagging values list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/tags/values/${e[`tag-key`]==null?`<tag-key>`:encodeURIComponent(String(e[`tag-key`]))}`,pathParams:{"tag-key":String(e[`tag-key`]??``)},query:r,bodyKind:`none`});return}let a=await i(e),o=e.local?f:await t();e.accountId=o,c(await u(`Loading`,async()=>a.resourceTagging.values.list({account_id:o,tag_key:e[`tag-key`],...r})),{successLabel:`Loaded`})}},j={command:`values`,describe:`Allowed values for tag keys — constrain tagging to a defined set of options`,builder:e=>e.command(A).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function M(e){return e.option(`if-match`,{type:`string`,description:`ETag value for optimistic concurrency control. When provided, the server will
|
|
10
|
+
verify the current resource ETag matches before applying the write. Returns
|
|
11
|
+
412 Precondition Failed if the resource has been modified since the ETag was
|
|
12
|
+
obtained. Omit this header for unconditional writes.`}).option(`resource-id`,{type:`string`,description:`Identifies the unique resource.`}).option(`resource-type`,{type:`string`,description:`Enum for base zone-level resource types (those with no extra required fields).`,choices:[`api_gateway_operation`,`custom_certificate`,`custom_hostname`,`dns_record`,`managed_client_certificate`,`zone`]}).option(`access-application-id`,{type:`string`,description:`Access application ID is required only for access_application_policy resources`}).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:`Request body schema for deleting tags from zone-level resources.`})}const N={command:`delete`,describe:`Removes all tags from a specific zone-level resource.`,builder:M,handler:async t=>{let n={};if(t[`if-match`]!==void 0&&(n[`If-Match`]=String(t[`if-match`])),t.dryRun){l({command:`cf resource-tagging zone-tags delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/tags`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?s({resource_id:d(t[`resource-id`],`resource-id`,`text`),resource_type:d(t[`resource-type`],`resource-type`,`text`),access_application_id:d(t[`access-application-id`],`access-application-id`,`text`)}):a(t.body)});return}let f=await i(t);if(t.zoneId=await e({zone:t.zone},f,{quiet:t.quiet}),!await h({force:!!t.force})){process.stderr.write(`Aborted.
|
|
13
|
+
`);return}if(t.body){let e=a(t.body);c(await u(`Deleting`,async()=>r(f,`DELETE`,`/zones/${t.zoneId}/tags`,{body:e,headers:Object.keys(n).length>0?n:void 0})),{successLabel:`Deleted`});return}t[`resource-id`]===void 0&&(t[`resource-id`]=await m(`resource-id`,`Identifies the unique resource.`)),t[`resource-type`]===void 0&&(t[`resource-type`]=await p(`resource-type`,`Enum for base zone-level resource types (those with no extra required fields).`,[`api_gateway_operation`,`custom_certificate`,`custom_hostname`,`dns_record`,`managed_client_certificate`,`zone`]));let g={};t[`resource-id`]!==void 0&&o(g,[`resource_id`],d(t[`resource-id`],`resource-id`,`text`)),t[`resource-type`]!==void 0&&o(g,[`resource_type`],d(t[`resource-type`],`resource-type`,`text`)),t[`access-application-id`]!==void 0&&o(g,[`access_application_id`],d(t[`access-application-id`],`access-application-id`,`text`)),c(await u(`Deleting`,async()=>r(f,`DELETE`,`/zones/${t.zoneId}/tags`,{body:Object.keys(g).length>0?g:void 0,headers:Object.keys(n).length>0?n:void 0})),{successLabel:`Deleted`})}};function P(e){return e.option(`resource-id`,{type:`string`,description:`The ID of the resource to retrieve tags for.`,demandOption:!0}).option(`resource-type`,{type:`string`,description:`The type of the resource.`,choices:[`access_application_policy`,`api_gateway_operation`,`custom_certificate`,`custom_hostname`,`dns_record`,`managed_client_certificate`,`zone`],demandOption:!0}).option(`access-application-id`,{type:`string`,description:`Access application ID identifier. Required for access_application_policy resources.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const F={command:`get`,describe:`Retrieves tags for a specific zone-level resource.`,builder:g(P),handler:async t=>{let n={resource_id:t[`resource-id`],resource_type:t[`resource-type`],access_application_id:t[`access-application-id`]};if(t.dryRun){l({command:`cf resource-tagging zone-tags get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/tags`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:n,bodyKind:`none`});return}let r=await i(t),a=await e({zone:t.zone},r,{quiet:t.quiet});t.zoneId=a,c(await u(`Loading`,async()=>r.resourceTagging.zoneTags.get({zone_id:a,...n})),{successLabel:`Loaded`})}};function I(e){return e.option(`if-match`,{type:`string`,description:`ETag value for optimistic concurrency control. When provided, the server will
|
|
14
|
+
verify the current resource ETag matches before applying the write. Returns
|
|
15
|
+
412 Precondition Failed if the resource has been modified since the ETag was
|
|
16
|
+
obtained. Omit this header for unconditional writes.`}).option(`resource-id`,{type:`string`,description:`Identifies the unique resource.`}).option(`resource-type`,{type:`string`,description:`Enum for base zone-level resource types (those with no extra required fields).`,choices:[`api_gateway_operation`,`custom_certificate`,`custom_hostname`,`dns_record`,`managed_client_certificate`,`zone`]}).option(`access-application-id`,{type:`string`,description:`Access application ID is required only for access_application_policy resources`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Request body schema for setting tags on zone-level resources.`})}const L={command:`update`,describe:`Creates or updates tags for a specific zone-level resource. Replaces all existing tags for the resource.`,builder:I,handler:async t=>{let n={};if(t[`if-match`]!==void 0&&(n[`If-Match`]=String(t[`if-match`])),t.dryRun){l({command:`cf resource-tagging zone-tags update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/tags`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?s({resource_id:d(t[`resource-id`],`resource-id`,`text`),resource_type:d(t[`resource-type`],`resource-type`,`text`),access_application_id:d(t[`access-application-id`],`access-application-id`,`text`)}):a(t.body)});return}let f=await i(t);if(t.zoneId=await e({zone:t.zone},f,{quiet:t.quiet}),t.body){let e=a(t.body);c(await u(`Updating`,async()=>r(f,`PUT`,`/zones/${t.zoneId}/tags`,{body:e,headers:Object.keys(n).length>0?n:void 0})),{successLabel:`Updated`});return}t[`resource-id`]===void 0&&(t[`resource-id`]=await m(`resource-id`,`Identifies the unique resource.`)),t[`resource-type`]===void 0&&(t[`resource-type`]=await p(`resource-type`,`Enum for base zone-level resource types (those with no extra required fields).`,[`api_gateway_operation`,`custom_certificate`,`custom_hostname`,`dns_record`,`managed_client_certificate`,`zone`]));let h={};t[`resource-id`]!==void 0&&o(h,[`resource_id`],d(t[`resource-id`],`resource-id`,`text`)),t[`resource-type`]!==void 0&&o(h,[`resource_type`],d(t[`resource-type`],`resource-type`,`text`)),t[`access-application-id`]!==void 0&&o(h,[`access_application_id`],d(t[`access-application-id`],`access-application-id`,`text`)),c(await u(`Updating`,async()=>r(f,`PUT`,`/zones/${t.zoneId}/tags`,{body:Object.keys(h).length>0?h:void 0,headers:Object.keys(n).length>0?n:void 0})),{successLabel:`Updated`})}},R={command:`zone-tags`,describe:`Tags applied to individual zones for categorization and bulk management`,builder:e=>e.command(N).command(F).command(L).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},z={command:`resource-tagging`,describe:`Tag accounts and zones with key-value metadata for organization, filtering, and policy targeting`,builder:e=>e.command(O).command(C).command(E).command(j).command(R).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{z as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{n as r,t as i}from"./body-parser-DWSy7uZ8.mjs";import{t as a}from"./output-B6fBFRqe.mjs";import{n as o,t as s}from"./progress-CL8I-7YK.mjs";import{n as c}from"./input-validation-_fMCApaH.mjs";import{t as l}from"./local-CYc9q7l2.mjs";import{r as u,t as d}from"./prompt-q3B7sM2A.mjs";function f(e){return e.positional(`operation-id`,{type:`string`,description:`The unique operation ID of the asynchronous action.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const p={command:`get <operation-id>`,describe:"Gets the current status of an asynchronous operation on a list. The `status` property can have one of the following values: `pending`, `running`, `completed`, or `failed`. If the status is `failed`, the `error` property will contain a message describing the error.",builder:f,handler:async r=>{if(r.dryRun){o({command:`cf rules lists bulk-operations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists/bulk_operations/${r[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(r[`operation-id`]))}`,pathParams:{"operation-id":String(r[`operation-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.rules.lists.bulkOperations.get({account_id:c,operation_id:r[`operation-id`]})),{successLabel:`Loaded`})}},m={command:`bulk-operations`,describe:`Named lists of IPs, hostnames, ASNs, or redirects that can be referenced in rule expressions`,builder:e=>e.command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function h(e){return e.option(`description`,{type:`string`,description:`An informative summary of the list.`}).option(`name`,{type:`string`,description:`An informative name for the list. Use this name in filter and rule expressions.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const g={command:`create`,describe:`Creates a new list of the specified kind.`,builder:h,handler:async d=>{if(d.dryRun){o({command:`cf rules lists create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists`,pathParams:{},bodyKind:`json`,body:d.body===void 0?i({description:c(d.description,`description`,`text`),name:c(d.name,`name`,`text`)}):r(d.body)});return}let f=await n(d),p=d.local?l:await e();if(d.accountId=p,d.body){let e=r(d.body);a(await s(`Creating`,async()=>f.rules.lists.create({...e,account_id:p})),{successLabel:`Created`});return}d.name===void 0&&(d.name=await u(`name`,`An informative name for the list. Use this name in filter and rule expressions.`));let m=i({description:c(d.description,`description`,`text`),name:c(d.name,`name`,`text`)});a(await s(`Creating`,async()=>f.rules.lists.create({...m,account_id:p})),{successLabel:`Created`})}};function _(e){return e.positional(`list-id`,{type:`string`,description:`The unique ID of the list.`,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 v={command:`delete <list-id>`,describe:`Deletes a specific list and all its items.`,builder:_,handler:async r=>{if(r.dryRun){o({command:`cf rules lists delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists/${r[`list-id`]==null?`<list-id>`:encodeURIComponent(String(r[`list-id`]))}`,pathParams:{"list-id":String(r[`list-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await d({force:!!r.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}a(await s(`Deleting`,async()=>i.rules.lists.delete({account_id:c,list_id:r[`list-id`]})),{successLabel:`Deleted`})}};function y(e){return e.positional(`list-id`,{type:`string`,description:`The unique ID of the list.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`get <list-id>`,describe:`Fetches the details of a list.`,builder:y,handler:async r=>{if(r.dryRun){o({command:`cf rules lists get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists/${r[`list-id`]==null?`<list-id>`:encodeURIComponent(String(r[`list-id`]))}`,pathParams:{"list-id":String(r[`list-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.rules.lists.get({account_id:c,list_id:r[`list-id`]})),{successLabel:`Loaded`})}};function x(e){return e.positional(`list-id`,{type:`string`,description:`The unique ID of the list.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const S={command:`create <list-id>`,describe:"Appends new items to the list. This operation is asynchronous. To get current the operation status, invoke the `Get bulk operation status` endpoint with the returned `operation_id`. There is a limit of 1 pending bulk operation per account. If an outstanding bulk operation is in progress, the request will be rejected.",builder:x,handler:async i=>{if(i.dryRun){o({command:`cf rules lists items create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists/${i[`list-id`]==null?`<list-id>`:encodeURIComponent(String(i[`list-id`]))}/items`,pathParams:{"list-id":String(i[`list-id`]??``)},bodyKind:`json`,body:i.body===void 0?void 0:r(i.body)});return}let c=await n(i),u=i.local?l:await e();if(i.accountId=u,i.body){let e=r(i.body);a(await s(`Creating`,async()=>c.rules.lists.items.create({body:e,account_id:u,list_id:i[`list-id`]})),{successLabel:`Created`});return}if(i.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function C(e){return e.positional(`list-id`,{type:`string`,description:`The unique ID of the list.`,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}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const w={command:`delete <list-id>`,describe:"Removes one or more items from a list. This operation is asynchronous. To get current the operation status, invoke the `Get bulk operation status` endpoint with the returned `operation_id`. There is a limit of 1 pending bulk operation per account. If an outstanding bulk operation is in progress, the request will be rejected.",builder:C,handler:async i=>{if(i.dryRun){o({command:`cf rules lists items delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists/${i[`list-id`]==null?`<list-id>`:encodeURIComponent(String(i[`list-id`]))}/items`,pathParams:{"list-id":String(i[`list-id`]??``)},bodyKind:`json`,body:i.body===void 0?void 0:r(i.body)});return}let c=await n(i),u=i.local?l:await e();if(i.accountId=u,!await d({force:!!i.force})){process.stderr.write(`Aborted.
|
|
4
|
+
`);return}if(i.body){let e=r(i.body);a(await s(`Deleting`,async()=>c.rules.lists.items.delete({...e,account_id:u,list_id:i[`list-id`]})),{successLabel:`Deleted`});return}a(await s(`Deleting`,async()=>c.rules.lists.items.delete({account_id:u,list_id:i[`list-id`]})),{successLabel:`Deleted`})}};function T(e){return e.positional(`item-id`,{type:`string`,description:`Defines the unique ID of the item in the List.`,demandOption:!0}).option(`list-id`,{type:`string`,description:`The unique ID of the list.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const E={command:`get <item-id>`,describe:`Fetches a list item in the list.`,builder:T,handler:async r=>{if(r.dryRun){o({command:`cf rules lists items get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists/${r[`list-id`]==null?`<list-id>`:encodeURIComponent(String(r[`list-id`]))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}`,pathParams:{"item-id":String(r[`item-id`]??``),"list-id":String(r[`list-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.rules.lists.items.get({account_id:c,list_id:r[`list-id`],item_id:r[`item-id`]})),{successLabel:`Loaded`})}};function D(e){return e.option(`list-id`,{type:`string`,description:`The unique ID of the list.`,demandOption:!0}).option(`cursor`,{type:`string`,description:"The pagination cursor. An opaque string token indicating the position from which to continue when requesting the next/previous set of records. Cursor values are provided under `result_info.cursors` in the response. You should make no assumptions about a cursor's content or length."}).option(`per-page`,{type:`number`,description:`Amount of results to include in each paginated response. A non-negative 32 bit integer.`}).option(`search`,{type:`string`,description:`A search query to filter returned items. Its meaning depends on the list type: IP addresses must start with the provided string, hostnames and bulk redirects must contain the string, and ASNs must match the string exactly.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`list`,describe:`Fetches all the items in the list.`,builder:D,handler:async r=>{let i={cursor:r.cursor,per_page:r[`per-page`],search:r.search};if(r.dryRun){o({command:`cf rules lists items list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists/${r[`list-id`]==null?`<list-id>`:encodeURIComponent(String(r[`list-id`]))}/items`,pathParams:{"list-id":String(r[`list-id`]??``)},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.rules.lists.items.list({account_id:u,list_id:r[`list-id`],...i})),{successLabel:`Loaded`})}};function k(e){return e.positional(`list-id`,{type:`string`,description:`The unique ID of the list.`,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 A={command:`update <list-id>`,describe:"Removes all existing items from the list and adds the provided items to the list. This operation is asynchronous. To get current the operation status, invoke the `Get bulk operation status` endpoint with the returned `operation_id`. There is a limit of 1 pending bulk operation per account. If an outstanding bulk operation is in progress, the request will be rejected.",builder:k,handler:async i=>{if(i.dryRun){o({command:`cf rules lists items update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists/${i[`list-id`]==null?`<list-id>`:encodeURIComponent(String(i[`list-id`]))}/items`,pathParams:{"list-id":String(i[`list-id`]??``)},bodyKind:`json`,body:i.body===void 0?void 0:r(i.body)});return}let c=await n(i),u=i.local?l:await e();if(i.accountId=u,i.body){let e=r(i.body);a(await s(`Updating`,async()=>c.rules.lists.items.update({body:e,account_id:u,list_id:i[`list-id`]})),{successLabel:`Updated`});return}if(i.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},j={command:`items`,describe:`Named lists of IPs, hostnames, ASNs, or redirects that can be referenced in rule expressions`,builder:e=>e.command(S).command(w).command(E).command(O).command(A).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function M(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const N={command:`list`,describe:`Fetches all lists in the account.`,builder:M,handler:async r=>{if(r.dryRun){o({command:`cf rules lists list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.rules.lists.list({account_id:c})),{successLabel:`Loaded`})}};function P(e){return e.positional(`list-id`,{type:`string`,description:`The unique ID of the list.`,demandOption:!0}).option(`description`,{type:`string`,description:`An informative summary of the list.`}).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 F={command:`update <list-id>`,describe:`Updates the description of a list.`,builder:P,handler:async u=>{if(u.dryRun){o({command:`cf rules lists update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rules/lists/${u[`list-id`]==null?`<list-id>`:encodeURIComponent(String(u[`list-id`]))}`,pathParams:{"list-id":String(u[`list-id`]??``)},bodyKind:`json`,body:u.body===void 0?i({description:c(u.description,`description`,`text`)}):r(u.body)});return}let d=await n(u),f=u.local?l:await e();if(u.accountId=f,u.body){let e=r(u.body);a(await s(`Updating`,async()=>d.rules.lists.update({...e,account_id:f,list_id:u[`list-id`]})),{successLabel:`Updated`});return}let p=i({description:c(u.description,`description`,`text`)});a(await s(`Updating`,async()=>d.rules.lists.update({...p,account_id:f,list_id:u[`list-id`]})),{successLabel:`Updated`})}},I={command:`lists`,describe:`Named lists of IPs, hostnames, ASNs, or redirects that can be referenced in rule expressions`,builder:e=>e.command(g).command(v).command(b).command(N).command(F).command(m).command(j).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},L={command:`rules`,describe:`Account-level IP lists, hostname lists, and other reusable lists referenced by firewall rules and rulesets`,builder:e=>e.command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{L as default};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{N as e,O as t,P as n}from"./oauth-B5k80sip.mjs";import{n as r}from"./auth-DX9KnJ0P.mjs";import{n as i,t as a}from"./body-parser-DWSy7uZ8.mjs";import{t as o}from"./output-B6fBFRqe.mjs";import{n as s,t as c}from"./progress-CL8I-7YK.mjs";import{n as l}from"./input-validation-_fMCApaH.mjs";import{t as u}from"./local-CYc9q7l2.mjs";import{n as d,r as f,t as p}from"./prompt-q3B7sM2A.mjs";import{t as m}from"./cli-types-DGgEbf8K.mjs";function h(e){return e.option(`description`,{type:`string`,description:`An informative description of the ruleset.`,default:``}).option(`name`,{type:`string`,description:`The human-readable name of the ruleset.`}).option(`kind`,{type:`string`,description:`The kind of the ruleset.`,choices:[`managed`,`custom`,`root`,`zone`]}).option(`phase`,{type:`string`,description:`The phase of the ruleset.`,choices:[`ddos_l4`,`ddos_l7`,`http_config_settings`,`http_custom_errors`,`http_log_custom_fields`,`http_ratelimit`,`http_request_cache_settings`,`http_request_dynamic_redirect`,`http_request_firewall_custom`,`http_request_firewall_managed`,`http_request_late_transform`,`http_request_origin`,`http_request_redirect`,`http_request_sanitize`,`http_request_sbfm`,`http_request_transform`,`http_response_cache_settings`,`http_response_compression`,`http_response_firewall_managed`,`http_response_headers_transform`,`magic_transit`,`magic_transit_ids_managed`,`magic_transit_managed`,`magic_transit_ratelimit`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ee={command:`create`,describe:`Creates a ruleset at the account level.`,builder:h,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets`,pathParams:{},bodyKind:`json`,body:e.body===void 0?a({description:l(e.description,`description`,`text`),name:l(e.name,`name`,`text`),kind:l(e.kind,`kind`,`text`),phase:l(e.phase,`phase`,`text`)}):i(e.body)});return}let p=await r(e),m=e.local?u:await t();if(e.accountId=m,e.body){let t=i(e.body);o(await c(`Creating`,async()=>p.rulesets.accountRulesets.create({...t,account_id:m})),{successLabel:`Created`});return}e.name===void 0&&(e.name=await f(`name`,`The human-readable name of the ruleset.`)),e.kind===void 0&&(e.kind=await d(`kind`,`The kind of the ruleset.`,[`managed`,`custom`,`root`,`zone`])),e.phase===void 0&&(e.phase=await d(`phase`,`The phase of the ruleset.`,[`ddos_l4`,`ddos_l7`,`http_config_settings`,`http_custom_errors`,`http_log_custom_fields`,`http_ratelimit`,`http_request_cache_settings`,`http_request_dynamic_redirect`,`http_request_firewall_custom`,`http_request_firewall_managed`,`http_request_late_transform`,`http_request_origin`,`http_request_redirect`,`http_request_sanitize`,`http_request_sbfm`,`http_request_transform`,`http_response_cache_settings`,`http_response_compression`,`http_response_firewall_managed`,`http_response_headers_transform`,`magic_transit`,`magic_transit_ids_managed`,`magic_transit_managed`,`magic_transit_ratelimit`]));let h=a({description:l(e.description,`description`,`text`),name:l(e.name,`name`,`text`),kind:l(e.kind,`kind`,`text`),phase:l(e.phase,`phase`,`text`)});o(await c(`Creating`,async()=>p.rulesets.accountRulesets.create({...h,account_id:m})),{successLabel:`Created`})}};function te(e){return e.positional(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const g={command:`delete <ruleset-id>`,describe:`Deletes all versions of an existing account ruleset.`,builder:te,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/${e[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(e[`ruleset-id`]))}`,pathParams:{"ruleset-id":String(e[`ruleset-id`]??``)},bodyKind:`none`});return}let i=await r(e),a=e.local?u:await t();if(e.accountId=a,!await p({force:!!e.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}o(await c(`Deleting`,async()=>i.rulesets.accountRulesets.delete({account_id:a,ruleset_id:e[`ruleset-id`]})),{successLabel:`Deleted`})}};function _(e){return e.positional(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`get <ruleset-id>`,describe:`Fetches the latest version of an account ruleset.`,builder:_,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/${e[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(e[`ruleset-id`]))}`,pathParams:{"ruleset-id":String(e[`ruleset-id`]??``)},bodyKind:`none`});return}let i=await r(e),a=e.local?u:await t();e.accountId=a,o(await c(`Loading`,async()=>i.rulesets.accountRulesets.get({account_id:a,ruleset_id:e[`ruleset-id`]})),{successLabel:`Loaded`})}};function y(e){return e.option(`cursor`,{type:`string`,description:`The cursor to use for the next page.`}).option(`per-page`,{type:`number`,description:`The number of rulesets to return per page.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`list`,describe:`Fetches all rulesets at the account level.`,builder:y,handler:async e=>{let i={cursor:e.cursor,per_page:e[`per-page`]};if(e.dryRun){s({command:`cf rulesets account-rulesets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets`,pathParams:{},query:i,bodyKind:`none`});return}let a=await r(e),l=e.local?u:await t();e.accountId=l,o(await c(`Loading`,async()=>a.rulesets.accountRulesets.list({account_id:l,...i})),{successLabel:`Loaded`})}};function x(e){return e.positional(`ruleset-phase`,{type:`string`,description:`The phase of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const S={command:`get <ruleset-phase>`,describe:`Fetches the latest version of the account entry point ruleset for a given phase.`,builder:m(x),handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets phases get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/phases/${e[`ruleset-phase`]==null?`<ruleset-phase>`:encodeURIComponent(String(e[`ruleset-phase`]))}/entrypoint`,pathParams:{"ruleset-phase":String(e[`ruleset-phase`]??``)},bodyKind:`none`});return}let i=await r(e),a=e.local?u:await t();e.accountId=a,o(await c(`Loading`,async()=>i.rulesets.accountRulesets.phases.get({account_id:a,ruleset_phase:e[`ruleset-phase`]})),{successLabel:`Loaded`})}};function C(e){return e.positional(`ruleset-phase`,{type:`string`,description:`The phase of the ruleset.`,demandOption:!0}).option(`description`,{type:`string`,description:`An informative description of the ruleset.`}).option(`name`,{type:`string`,description:`The human-readable name of the ruleset.`}).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 w={command:`update <ruleset-phase>`,describe:`Updates an account entry point ruleset, creating a new version.`,builder:m(C),handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets phases update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/phases/${e[`ruleset-phase`]==null?`<ruleset-phase>`:encodeURIComponent(String(e[`ruleset-phase`]))}/entrypoint`,pathParams:{"ruleset-phase":String(e[`ruleset-phase`]??``)},bodyKind:`json`,body:e.body===void 0?a({description:l(e.description,`description`,`text`),name:l(e.name,`name`,`text`)}):i(e.body)});return}let d=await r(e),f=e.local?u:await t();if(e.accountId=f,e.body){let t=i(e.body);o(await c(`Updating`,async()=>d.rulesets.accountRulesets.phases.update({...t,account_id:f,ruleset_phase:e[`ruleset-phase`]})),{successLabel:`Updated`});return}let p=a({description:l(e.description,`description`,`text`),name:l(e.name,`name`,`text`)});o(await c(`Updating`,async()=>d.rulesets.accountRulesets.phases.update({...p,account_id:f,ruleset_phase:e[`ruleset-phase`]})),{successLabel:`Updated`})}};function T(e){return e.positional(`ruleset-version`,{type:`string`,description:`The version of the ruleset.`,demandOption:!0}).option(`ruleset-phase`,{type:`string`,description:`The phase of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const E={command:`get <ruleset-version>`,describe:`Fetches a specific version of an account entry point ruleset.`,builder:m(T),handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets phases versions get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/phases/${e[`ruleset-phase`]==null?`<ruleset-phase>`:encodeURIComponent(String(e[`ruleset-phase`]))}/entrypoint/versions/${e[`ruleset-version`]==null?`<ruleset-version>`:encodeURIComponent(String(e[`ruleset-version`]))}`,pathParams:{"ruleset-version":String(e[`ruleset-version`]??``),"ruleset-phase":String(e[`ruleset-phase`]??``)},bodyKind:`none`});return}let i=await r(e),a=e.local?u:await t();e.accountId=a,o(await c(`Loading`,async()=>i.rulesets.accountRulesets.phases.versions.get({account_id:a,ruleset_phase:e[`ruleset-phase`],ruleset_version:e[`ruleset-version`]})),{successLabel:`Loaded`})}};function D(e){return e.option(`ruleset-phase`,{type:`string`,description:`The phase of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`list`,describe:`Fetches the versions of an account entry point ruleset.`,builder:m(D),handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets phases versions list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/phases/${e[`ruleset-phase`]==null?`<ruleset-phase>`:encodeURIComponent(String(e[`ruleset-phase`]))}/entrypoint/versions`,pathParams:{"ruleset-phase":String(e[`ruleset-phase`]??``)},bodyKind:`none`});return}let i=await r(e),a=e.local?u:await t();e.accountId=a,o(await c(`Loading`,async()=>i.rulesets.accountRulesets.phases.versions.list({account_id:a,ruleset_phase:e[`ruleset-phase`]})),{successLabel:`Loaded`})}},k={command:`versions`,describe:`Account-scoped rulesets — same operations as zone-level but scoped to the account`,builder:e=>e.command(E).command(O).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},A={command:`phases`,describe:`Account-scoped rulesets — same operations as zone-level but scoped to the account`,builder:e=>e.command(S).command(w).command(k).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function j(e){return e.positional(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`position-before`,{type:`string`,description:`The ID of another rule to place the rule before. An empty value causes the rule to be placed at the top.`}).option(`position-after`,{type:`string`,description:`The ID of another rule to place the rule after. An empty value causes the rule to be placed at the bottom.`}).option(`position-index`,{type:`number`,description:`An index at which to place the rule, where index 1 is the first rule.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).conflicts(`position-before`,[`position-after`,`position-index`]).conflicts(`position-after`,[`position-before`,`position-index`]).conflicts(`position-index`,[`position-before`,`position-after`])}const M={command:`create <ruleset-id>`,describe:`Adds a new rule to an account ruleset. The rule will be added to the end of the existing list of rules in the ruleset by default.`,builder:j,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets rules create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/${e[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(e[`ruleset-id`]))}/rules`,pathParams:{"ruleset-id":String(e[`ruleset-id`]??``)},bodyKind:`json`,body:e.body===void 0?a({position:{before:l(e[`position-before`],`position-before`,`text`),after:l(e[`position-after`],`position-after`,`text`),index:e[`position-index`]}}):i(e.body)});return}let d=await r(e),f=e.local?u:await t();if(e.accountId=f,e.body){let t=i(e.body);o(await c(`Creating`,async()=>d.rulesets.accountRulesets.rules.create({...t,account_id:f,ruleset_id:e[`ruleset-id`]})),{successLabel:`Created`});return}let p=a({position:{before:l(e[`position-before`],`position-before`,`text`),after:l(e[`position-after`],`position-after`,`text`),index:e[`position-index`]}});o(await c(`Creating`,async()=>d.rulesets.accountRulesets.rules.create({...p,account_id:f,ruleset_id:e[`ruleset-id`]})),{successLabel:`Created`})}};function N(e){return e.positional(`rule-id`,{type:`string`,description:`The unique ID of the rule.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,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 P={command:`delete <rule-id>`,describe:`Deletes an existing rule from an account ruleset.`,builder:N,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets rules delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/${e[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(e[`ruleset-id`]))}/rules/${e[`rule-id`]==null?`<rule-id>`:encodeURIComponent(String(e[`rule-id`]))}`,pathParams:{"rule-id":String(e[`rule-id`]??``),"ruleset-id":String(e[`ruleset-id`]??``)},bodyKind:`none`});return}let i=await r(e),a=e.local?u:await t();if(e.accountId=a,!await p({force:!!e.force})){process.stderr.write(`Aborted.
|
|
4
|
+
`);return}o(await c(`Deleting`,async()=>i.rulesets.accountRulesets.rules.delete({account_id:a,ruleset_id:e[`ruleset-id`],rule_id:e[`rule-id`]})),{successLabel:`Deleted`})}};function F(e){return e.positional(`rule-id`,{type:`string`,description:`The unique ID of the rule.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`position-before`,{type:`string`,description:`The ID of another rule to place the rule before. An empty value causes the rule to be placed at the top.`}).option(`position-after`,{type:`string`,description:`The ID of another rule to place the rule after. An empty value causes the rule to be placed at the bottom.`}).option(`position-index`,{type:`number`,description:`An index at which to place the rule, where index 1 is the first rule.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).conflicts(`position-before`,[`position-after`,`position-index`]).conflicts(`position-after`,[`position-before`,`position-index`]).conflicts(`position-index`,[`position-before`,`position-after`])}const I={command:`update <rule-id>`,describe:`Updates an existing rule in an account ruleset.`,builder:F,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets rules update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/${e[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(e[`ruleset-id`]))}/rules/${e[`rule-id`]==null?`<rule-id>`:encodeURIComponent(String(e[`rule-id`]))}`,pathParams:{"rule-id":String(e[`rule-id`]??``),"ruleset-id":String(e[`ruleset-id`]??``)},bodyKind:`json`,body:e.body===void 0?a({position:{before:l(e[`position-before`],`position-before`,`text`),after:l(e[`position-after`],`position-after`,`text`),index:e[`position-index`]}}):i(e.body)});return}let d=await r(e),f=e.local?u:await t();if(e.accountId=f,e.body){let t=i(e.body);o(await c(`Updating`,async()=>d.rulesets.accountRulesets.rules.update({...t,account_id:f,ruleset_id:e[`ruleset-id`],rule_id:e[`rule-id`]})),{successLabel:`Updated`});return}let p=a({position:{before:l(e[`position-before`],`position-before`,`text`),after:l(e[`position-after`],`position-after`,`text`),index:e[`position-index`]}});o(await c(`Updating`,async()=>d.rulesets.accountRulesets.rules.update({...p,account_id:f,ruleset_id:e[`ruleset-id`],rule_id:e[`rule-id`]})),{successLabel:`Updated`})}},L={command:`rules`,describe:`Operations for account-rulesets.rules`,builder:e=>e.command(M).command(P).command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function R(e){return e.positional(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`description`,{type:`string`,description:`An informative description of the ruleset.`}).option(`name`,{type:`string`,description:`The human-readable name of the ruleset.`}).option(`kind`,{type:`string`,description:`The kind of the ruleset.`,choices:[`managed`,`custom`,`root`,`zone`]}).option(`phase`,{type:`string`,description:`The phase of the ruleset.`,choices:[`ddos_l4`,`ddos_l7`,`http_config_settings`,`http_custom_errors`,`http_log_custom_fields`,`http_ratelimit`,`http_request_cache_settings`,`http_request_dynamic_redirect`,`http_request_firewall_custom`,`http_request_firewall_managed`,`http_request_late_transform`,`http_request_origin`,`http_request_redirect`,`http_request_sanitize`,`http_request_sbfm`,`http_request_transform`,`http_response_cache_settings`,`http_response_compression`,`http_response_firewall_managed`,`http_response_headers_transform`,`magic_transit`,`magic_transit_ids_managed`,`magic_transit_managed`,`magic_transit_ratelimit`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const z={command:`update <ruleset-id>`,describe:`Updates an account ruleset, creating a new version.`,builder:R,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/${e[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(e[`ruleset-id`]))}`,pathParams:{"ruleset-id":String(e[`ruleset-id`]??``)},bodyKind:`json`,body:e.body===void 0?a({description:l(e.description,`description`,`text`),name:l(e.name,`name`,`text`),kind:l(e.kind,`kind`,`text`),phase:l(e.phase,`phase`,`text`)}):i(e.body)});return}let d=await r(e),f=e.local?u:await t();if(e.accountId=f,e.body){let t=i(e.body);o(await c(`Updating`,async()=>d.rulesets.accountRulesets.update({...t,account_id:f,ruleset_id:e[`ruleset-id`]})),{successLabel:`Updated`});return}let p=a({description:l(e.description,`description`,`text`),name:l(e.name,`name`,`text`),kind:l(e.kind,`kind`,`text`),phase:l(e.phase,`phase`,`text`)});o(await c(`Updating`,async()=>d.rulesets.accountRulesets.update({...p,account_id:f,ruleset_id:e[`ruleset-id`]})),{successLabel:`Updated`})}};function B(e){return e.positional(`rule-tag`,{type:`string`,description:`The category of a rule.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`ruleset-version`,{type:`string`,description:`The version of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const V={command:`tag <rule-tag>`,describe:`Fetches the rules of a managed account ruleset version for a given tag.`,builder:B,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets versions by-tag tag`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/${e[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(e[`ruleset-id`]))}/versions/${e[`ruleset-version`]==null?`<ruleset-version>`:encodeURIComponent(String(e[`ruleset-version`]))}/by_tag/${e[`rule-tag`]==null?`<rule-tag>`:encodeURIComponent(String(e[`rule-tag`]))}`,pathParams:{"rule-tag":String(e[`rule-tag`]??``),"ruleset-version":String(e[`ruleset-version`]??``),"ruleset-id":String(e[`ruleset-id`]??``)},bodyKind:`none`});return}let i=await r(e),a=e.local?u:await t();e.accountId=a,o(await c(`Loading`,async()=>i.rulesets.accountRulesets.versions.byTag.tag({account_id:a,ruleset_id:e[`ruleset-id`],ruleset_version:e[`ruleset-version`],rule_tag:e[`rule-tag`]})),{successLabel:`Loaded`})}},H={command:`by-tag`,describe:`Account-scoped rulesets — same operations as zone-level but scoped to the account`,builder:e=>e.command(V).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function U(e){return e.positional(`ruleset-version`,{type:`string`,description:`The version of the ruleset.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,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 <ruleset-version>`,describe:`Deletes an existing version of an account ruleset.`,builder:U,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets versions delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/${e[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(e[`ruleset-id`]))}/versions/${e[`ruleset-version`]==null?`<ruleset-version>`:encodeURIComponent(String(e[`ruleset-version`]))}`,pathParams:{"ruleset-version":String(e[`ruleset-version`]??``),"ruleset-id":String(e[`ruleset-id`]??``)},bodyKind:`none`});return}let i=await r(e),a=e.local?u:await t();if(e.accountId=a,!await p({force:!!e.force})){process.stderr.write(`Aborted.
|
|
5
|
+
`);return}o(await c(`Deleting`,async()=>i.rulesets.accountRulesets.versions.delete({account_id:a,ruleset_id:e[`ruleset-id`],ruleset_version:e[`ruleset-version`]})),{successLabel:`Deleted`})}};function G(e){return e.positional(`ruleset-version`,{type:`string`,description:`The version of the ruleset.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const K={command:`get <ruleset-version>`,describe:`Fetches a specific version of an account ruleset.`,builder:G,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets versions get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/${e[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(e[`ruleset-id`]))}/versions/${e[`ruleset-version`]==null?`<ruleset-version>`:encodeURIComponent(String(e[`ruleset-version`]))}`,pathParams:{"ruleset-version":String(e[`ruleset-version`]??``),"ruleset-id":String(e[`ruleset-id`]??``)},bodyKind:`none`});return}let i=await r(e),a=e.local?u:await t();e.accountId=a,o(await c(`Loading`,async()=>i.rulesets.accountRulesets.versions.get({account_id:a,ruleset_id:e[`ruleset-id`],ruleset_version:e[`ruleset-version`]})),{successLabel:`Loaded`})}};function q(e){return e.option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const J={command:`list`,describe:`Fetches the versions of an account ruleset.`,builder:q,handler:async e=>{if(e.dryRun){s({command:`cf rulesets account-rulesets versions list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${n()??`<account-id>`}/rulesets/${e[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(e[`ruleset-id`]))}/versions`,pathParams:{"ruleset-id":String(e[`ruleset-id`]??``)},bodyKind:`none`});return}let i=await r(e),a=e.local?u:await t();e.accountId=a,o(await c(`Loading`,async()=>i.rulesets.accountRulesets.versions.list({account_id:a,ruleset_id:e[`ruleset-id`]})),{successLabel:`Loaded`})}};function Y(e){return e.positional(`rule-tag`,{type:`string`,description:`The category of a rule.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`ruleset-version`,{type:`string`,description:`The version of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const X={command:`tag <rule-tag>`,describe:`Fetches the rules of a managed zone ruleset version for a given tag.`,builder:Y,handler:async t=>{if(t.dryRun){s({command:`cf rulesets account-rulesets versions zone-by-tag tag`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/${t[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(t[`ruleset-id`]))}/versions/${t[`ruleset-version`]==null?`<ruleset-version>`:encodeURIComponent(String(t[`ruleset-version`]))}/by_tag/${t[`rule-tag`]==null?`<rule-tag>`:encodeURIComponent(String(t[`rule-tag`]))}`,pathParams:{"rule-tag":String(t[`rule-tag`]??``),"ruleset-version":String(t[`ruleset-version`]??``),"ruleset-id":String(t[`ruleset-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let n=await r(t),i=await e({zone:t.zone},n,{quiet:t.quiet});t.zoneId=i,o(await c(`Loading`,async()=>n.rulesets.accountRulesets.versions.zoneByTag.tag({zone_id:i,ruleset_id:t[`ruleset-id`],ruleset_version:t[`ruleset-version`],rule_tag:t[`rule-tag`]})),{successLabel:`Loaded`})}},Z={command:`zone-by-tag`,describe:`Operations for account-rulesets.versions.zone-by-tag`,builder:e=>e.command(X).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Q={command:`versions`,describe:`Account-scoped rulesets — same operations as zone-level but scoped to the account`,builder:e=>e.command(W).command(K).command(J).command(H).command(Z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ne={command:`account-rulesets`,describe:`Account-scoped rulesets — same operations as zone-level but scoped to the account`,builder:e=>e.command(ee).command(g).command(v).command(b).command(z).command(A).command(L).command(Q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function re(e){return e.option(`description`,{type:`string`,description:`An informative description of the ruleset.`,default:``}).option(`name`,{type:`string`,description:`The human-readable name of the ruleset.`}).option(`kind`,{type:`string`,description:`The kind of the ruleset.`,choices:[`managed`,`custom`,`root`,`zone`]}).option(`phase`,{type:`string`,description:`The phase of the ruleset.`,choices:[`ddos_l4`,`ddos_l7`,`http_config_settings`,`http_custom_errors`,`http_log_custom_fields`,`http_ratelimit`,`http_request_cache_settings`,`http_request_dynamic_redirect`,`http_request_firewall_custom`,`http_request_firewall_managed`,`http_request_late_transform`,`http_request_origin`,`http_request_redirect`,`http_request_sanitize`,`http_request_sbfm`,`http_request_transform`,`http_response_cache_settings`,`http_response_compression`,`http_response_firewall_managed`,`http_response_headers_transform`,`magic_transit`,`magic_transit_ids_managed`,`magic_transit_managed`,`magic_transit_ratelimit`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ie={command:`create`,describe:`Creates a ruleset at the zone level.`,builder:re,handler:async t=>{if(t.dryRun){s({command:`cf rulesets create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?a({description:l(t.description,`description`,`text`),name:l(t.name,`name`,`text`),kind:l(t.kind,`kind`,`text`),phase:l(t.phase,`phase`,`text`)}):i(t.body)});return}let n=await r(t),u=await e({zone:t.zone},n,{quiet:t.quiet});if(t.zoneId=u,t.body){let e=i(t.body);o(await c(`Creating`,async()=>n.rulesets.create({...e,zone_id:u})),{successLabel:`Created`});return}t.name===void 0&&(t.name=await f(`name`,`The human-readable name of the ruleset.`)),t.kind===void 0&&(t.kind=await d(`kind`,`The kind of the ruleset.`,[`managed`,`custom`,`root`,`zone`])),t.phase===void 0&&(t.phase=await d(`phase`,`The phase of the ruleset.`,[`ddos_l4`,`ddos_l7`,`http_config_settings`,`http_custom_errors`,`http_log_custom_fields`,`http_ratelimit`,`http_request_cache_settings`,`http_request_dynamic_redirect`,`http_request_firewall_custom`,`http_request_firewall_managed`,`http_request_late_transform`,`http_request_origin`,`http_request_redirect`,`http_request_sanitize`,`http_request_sbfm`,`http_request_transform`,`http_response_cache_settings`,`http_response_compression`,`http_response_firewall_managed`,`http_response_headers_transform`,`magic_transit`,`magic_transit_ids_managed`,`magic_transit_managed`,`magic_transit_ratelimit`]));let p=a({description:l(t.description,`description`,`text`),name:l(t.name,`name`,`text`),kind:l(t.kind,`kind`,`text`),phase:l(t.phase,`phase`,`text`)});o(await c(`Creating`,async()=>n.rulesets.create({...p,zone_id:u})),{successLabel:`Created`})}};function ae(e){return e.positional(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,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 oe={command:`delete <ruleset-id>`,describe:`Deletes all versions of an existing zone ruleset.`,builder:ae,handler:async t=>{if(t.dryRun){s({command:`cf rulesets delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/${t[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(t[`ruleset-id`]))}`,pathParams:{"ruleset-id":String(t[`ruleset-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let n=await r(t),i=await e({zone:t.zone},n,{quiet:t.quiet});if(t.zoneId=i,!await p({force:!!t.force})){process.stderr.write(`Aborted.
|
|
6
|
+
`);return}o(await c(`Deleting`,async()=>n.rulesets.delete({zone_id:i,ruleset_id:t[`ruleset-id`]})),{successLabel:`Deleted`})}};function se(e){return e.positional(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ce={command:`get <ruleset-id>`,describe:`Fetches the latest version of a zone ruleset.`,builder:se,handler:async t=>{if(t.dryRun){s({command:`cf rulesets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/${t[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(t[`ruleset-id`]))}`,pathParams:{"ruleset-id":String(t[`ruleset-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let n=await r(t),i=await e({zone:t.zone},n,{quiet:t.quiet});t.zoneId=i,o(await c(`Loading`,async()=>n.rulesets.get({zone_id:i,ruleset_id:t[`ruleset-id`]})),{successLabel:`Loaded`})}};function le(e){return e.option(`cursor`,{type:`string`,description:`The cursor to use for the next page.`}).option(`per-page`,{type:`number`,description:`The number of rulesets to return per page.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ue={command:`list`,describe:`Fetches all rulesets at the zone level.`,builder:le,handler:async t=>{let n={cursor:t.cursor,per_page:t[`per-page`]};if(t.dryRun){s({command:`cf rulesets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:n,bodyKind:`none`});return}let i=await r(t),a=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=a,o(await c(`Loading`,async()=>i.rulesets.list({zone_id:a,...n})),{successLabel:`Loaded`})}};function de(e){return e.positional(`ruleset-phase`,{type:`string`,description:`The phase of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const fe={command:`get <ruleset-phase>`,describe:`Fetches the latest version of the zone entry point ruleset for a given phase.`,builder:m(de),handler:async t=>{if(t.dryRun){s({command:`cf rulesets phases get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/phases/${t[`ruleset-phase`]==null?`<ruleset-phase>`:encodeURIComponent(String(t[`ruleset-phase`]))}/entrypoint`,pathParams:{"ruleset-phase":String(t[`ruleset-phase`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let n=await r(t),i=await e({zone:t.zone},n,{quiet:t.quiet});t.zoneId=i,o(await c(`Loading`,async()=>n.rulesets.phases.get({zone_id:i,ruleset_phase:t[`ruleset-phase`]})),{successLabel:`Loaded`})}};function pe(e){return e.positional(`ruleset-phase`,{type:`string`,description:`The phase of the ruleset.`,demandOption:!0}).option(`description`,{type:`string`,description:`An informative description of the ruleset.`}).option(`name`,{type:`string`,description:`The human-readable name of the ruleset.`}).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 me={command:`update <ruleset-phase>`,describe:`Updates a zone entry point ruleset, creating a new version.`,builder:m(pe),handler:async t=>{if(t.dryRun){s({command:`cf rulesets phases update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/phases/${t[`ruleset-phase`]==null?`<ruleset-phase>`:encodeURIComponent(String(t[`ruleset-phase`]))}/entrypoint`,pathParams:{"ruleset-phase":String(t[`ruleset-phase`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?a({description:l(t.description,`description`,`text`),name:l(t.name,`name`,`text`)}):i(t.body)});return}let n=await r(t),u=await e({zone:t.zone},n,{quiet:t.quiet});if(t.zoneId=u,t.body){let e=i(t.body);o(await c(`Updating`,async()=>n.rulesets.phases.update({...e,zone_id:u,ruleset_phase:t[`ruleset-phase`]})),{successLabel:`Updated`});return}let d=a({description:l(t.description,`description`,`text`),name:l(t.name,`name`,`text`)});o(await c(`Updating`,async()=>n.rulesets.phases.update({...d,zone_id:u,ruleset_phase:t[`ruleset-phase`]})),{successLabel:`Updated`})}};function he(e){return e.positional(`ruleset-version`,{type:`string`,description:`The version of the ruleset.`,demandOption:!0}).option(`ruleset-phase`,{type:`string`,description:`The phase of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ge={command:`get <ruleset-version>`,describe:`Fetches a specific version of a zone entry point ruleset.`,builder:m(he),handler:async t=>{if(t.dryRun){s({command:`cf rulesets phases versions get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/phases/${t[`ruleset-phase`]==null?`<ruleset-phase>`:encodeURIComponent(String(t[`ruleset-phase`]))}/entrypoint/versions/${t[`ruleset-version`]==null?`<ruleset-version>`:encodeURIComponent(String(t[`ruleset-version`]))}`,pathParams:{"ruleset-version":String(t[`ruleset-version`]??``),"ruleset-phase":String(t[`ruleset-phase`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let n=await r(t),i=await e({zone:t.zone},n,{quiet:t.quiet});t.zoneId=i,o(await c(`Loading`,async()=>n.rulesets.phases.versions.get({zone_id:i,ruleset_phase:t[`ruleset-phase`],ruleset_version:t[`ruleset-version`]})),{successLabel:`Loaded`})}};function _e(e){return e.option(`ruleset-phase`,{type:`string`,description:`The phase of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ve={command:`list`,describe:`Fetches the versions of a zone entry point ruleset.`,builder:m(_e),handler:async t=>{if(t.dryRun){s({command:`cf rulesets phases versions list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/phases/${t[`ruleset-phase`]==null?`<ruleset-phase>`:encodeURIComponent(String(t[`ruleset-phase`]))}/entrypoint/versions`,pathParams:{"ruleset-phase":String(t[`ruleset-phase`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let n=await r(t),i=await e({zone:t.zone},n,{quiet:t.quiet});t.zoneId=i,o(await c(`Loading`,async()=>n.rulesets.phases.versions.list({zone_id:i,ruleset_phase:t[`ruleset-phase`]})),{successLabel:`Loaded`})}},ye={command:`versions`,describe:`Execution phases that determine when rulesets run in the request lifecycle (e.g. http_request_firewall_custom)`,builder:e=>e.command(ge).command(ve).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},be={command:`phases`,describe:`Execution phases that determine when rulesets run in the request lifecycle (e.g. http_request_firewall_custom)`,builder:e=>e.command(fe).command(me).command(ye).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function xe(e){return e.positional(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`position-before`,{type:`string`,description:`The ID of another rule to place the rule before. An empty value causes the rule to be placed at the top.`}).option(`position-after`,{type:`string`,description:`The ID of another rule to place the rule after. An empty value causes the rule to be placed at the bottom.`}).option(`position-index`,{type:`number`,description:`An index at which to place the rule, where index 1 is the first rule.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).conflicts(`position-before`,[`position-after`,`position-index`]).conflicts(`position-after`,[`position-before`,`position-index`]).conflicts(`position-index`,[`position-before`,`position-after`])}const Se={command:`create <ruleset-id>`,describe:`Adds a new rule to a zone ruleset. The rule will be added to the end of the existing list of rules in the ruleset by default.`,builder:xe,handler:async t=>{if(t.dryRun){s({command:`cf rulesets rules create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/${t[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(t[`ruleset-id`]))}/rules`,pathParams:{"ruleset-id":String(t[`ruleset-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?a({position:{before:l(t[`position-before`],`position-before`,`text`),after:l(t[`position-after`],`position-after`,`text`),index:t[`position-index`]}}):i(t.body)});return}let n=await r(t),u=await e({zone:t.zone},n,{quiet:t.quiet});if(t.zoneId=u,t.body){let e=i(t.body);o(await c(`Creating`,async()=>n.rulesets.rules.create({...e,zone_id:u,ruleset_id:t[`ruleset-id`]})),{successLabel:`Created`});return}let d=a({position:{before:l(t[`position-before`],`position-before`,`text`),after:l(t[`position-after`],`position-after`,`text`),index:t[`position-index`]}});o(await c(`Creating`,async()=>n.rulesets.rules.create({...d,zone_id:u,ruleset_id:t[`ruleset-id`]})),{successLabel:`Created`})}};function Ce(e){return e.positional(`rule-id`,{type:`string`,description:`The unique ID of the rule.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,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 we={command:`delete <rule-id>`,describe:`Deletes an existing rule from a zone ruleset.`,builder:Ce,handler:async t=>{if(t.dryRun){s({command:`cf rulesets rules delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/${t[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(t[`ruleset-id`]))}/rules/${t[`rule-id`]==null?`<rule-id>`:encodeURIComponent(String(t[`rule-id`]))}`,pathParams:{"rule-id":String(t[`rule-id`]??``),"ruleset-id":String(t[`ruleset-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let n=await r(t),i=await e({zone:t.zone},n,{quiet:t.quiet});if(t.zoneId=i,!await p({force:!!t.force})){process.stderr.write(`Aborted.
|
|
7
|
+
`);return}o(await c(`Deleting`,async()=>n.rulesets.rules.delete({zone_id:i,ruleset_id:t[`ruleset-id`],rule_id:t[`rule-id`]})),{successLabel:`Deleted`})}};function Te(e){return e.positional(`rule-id`,{type:`string`,description:`The unique ID of the rule.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`position-before`,{type:`string`,description:`The ID of another rule to place the rule before. An empty value causes the rule to be placed at the top.`}).option(`position-after`,{type:`string`,description:`The ID of another rule to place the rule after. An empty value causes the rule to be placed at the bottom.`}).option(`position-index`,{type:`number`,description:`An index at which to place the rule, where index 1 is the first rule.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).conflicts(`position-before`,[`position-after`,`position-index`]).conflicts(`position-after`,[`position-before`,`position-index`]).conflicts(`position-index`,[`position-before`,`position-after`])}const Ee={command:`edit <rule-id>`,describe:`Updates an existing rule in a zone ruleset.`,builder:Te,handler:async t=>{if(t.dryRun){s({command:`cf rulesets rules edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/${t[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(t[`ruleset-id`]))}/rules/${t[`rule-id`]==null?`<rule-id>`:encodeURIComponent(String(t[`rule-id`]))}`,pathParams:{"rule-id":String(t[`rule-id`]??``),"ruleset-id":String(t[`ruleset-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?a({position:{before:l(t[`position-before`],`position-before`,`text`),after:l(t[`position-after`],`position-after`,`text`),index:t[`position-index`]}}):i(t.body)});return}let n=await r(t),u=await e({zone:t.zone},n,{quiet:t.quiet});if(t.zoneId=u,t.body){let e=i(t.body);o(await c(`Updating`,async()=>n.rulesets.rules.edit({...e,zone_id:u,ruleset_id:t[`ruleset-id`],rule_id:t[`rule-id`]})),{successLabel:`Updated`});return}let d=a({position:{before:l(t[`position-before`],`position-before`,`text`),after:l(t[`position-after`],`position-after`,`text`),index:t[`position-index`]}});o(await c(`Updating`,async()=>n.rulesets.rules.edit({...d,zone_id:u,ruleset_id:t[`ruleset-id`],rule_id:t[`rule-id`]})),{successLabel:`Updated`})}},De={command:`rules`,describe:`Individual rules within a ruleset — each with an expression, action, and priority`,builder:e=>e.command(Se).command(we).command(Ee).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function $(e){return e.positional(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`description`,{type:`string`,description:`An informative description of the ruleset.`}).option(`name`,{type:`string`,description:`The human-readable name of the ruleset.`}).option(`kind`,{type:`string`,description:`The kind of the ruleset.`,choices:[`managed`,`custom`,`root`,`zone`]}).option(`phase`,{type:`string`,description:`The phase of the ruleset.`,choices:[`ddos_l4`,`ddos_l7`,`http_config_settings`,`http_custom_errors`,`http_log_custom_fields`,`http_ratelimit`,`http_request_cache_settings`,`http_request_dynamic_redirect`,`http_request_firewall_custom`,`http_request_firewall_managed`,`http_request_late_transform`,`http_request_origin`,`http_request_redirect`,`http_request_sanitize`,`http_request_sbfm`,`http_request_transform`,`http_response_cache_settings`,`http_response_compression`,`http_response_firewall_managed`,`http_response_headers_transform`,`magic_transit`,`magic_transit_ids_managed`,`magic_transit_managed`,`magic_transit_ratelimit`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Oe={command:`update <ruleset-id>`,describe:`Updates a zone ruleset, creating a new version.`,builder:$,handler:async t=>{if(t.dryRun){s({command:`cf rulesets update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/${t[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(t[`ruleset-id`]))}`,pathParams:{"ruleset-id":String(t[`ruleset-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?a({description:l(t.description,`description`,`text`),name:l(t.name,`name`,`text`),kind:l(t.kind,`kind`,`text`),phase:l(t.phase,`phase`,`text`)}):i(t.body)});return}let n=await r(t),u=await e({zone:t.zone},n,{quiet:t.quiet});if(t.zoneId=u,t.body){let e=i(t.body);o(await c(`Updating`,async()=>n.rulesets.update({...e,zone_id:u,ruleset_id:t[`ruleset-id`]})),{successLabel:`Updated`});return}let d=a({description:l(t.description,`description`,`text`),name:l(t.name,`name`,`text`),kind:l(t.kind,`kind`,`text`),phase:l(t.phase,`phase`,`text`)});o(await c(`Updating`,async()=>n.rulesets.update({...d,zone_id:u,ruleset_id:t[`ruleset-id`]})),{successLabel:`Updated`})}};function ke(e){return e.positional(`ruleset-version`,{type:`string`,description:`The version of the ruleset.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,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 Ae={command:`delete <ruleset-version>`,describe:`Deletes an existing version of a zone ruleset.`,builder:ke,handler:async t=>{if(t.dryRun){s({command:`cf rulesets versions delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/${t[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(t[`ruleset-id`]))}/versions/${t[`ruleset-version`]==null?`<ruleset-version>`:encodeURIComponent(String(t[`ruleset-version`]))}`,pathParams:{"ruleset-version":String(t[`ruleset-version`]??``),"ruleset-id":String(t[`ruleset-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let n=await r(t),i=await e({zone:t.zone},n,{quiet:t.quiet});if(t.zoneId=i,!await p({force:!!t.force})){process.stderr.write(`Aborted.
|
|
8
|
+
`);return}o(await c(`Deleting`,async()=>n.rulesets.versions.delete({zone_id:i,ruleset_id:t[`ruleset-id`],ruleset_version:t[`ruleset-version`]})),{successLabel:`Deleted`})}};function je(e){return e.positional(`ruleset-version`,{type:`string`,description:`The version of the ruleset.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Me={command:`get <ruleset-version>`,describe:`Fetches a specific version of a zone ruleset.`,builder:je,handler:async t=>{if(t.dryRun){s({command:`cf rulesets versions get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/${t[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(t[`ruleset-id`]))}/versions/${t[`ruleset-version`]==null?`<ruleset-version>`:encodeURIComponent(String(t[`ruleset-version`]))}`,pathParams:{"ruleset-version":String(t[`ruleset-version`]??``),"ruleset-id":String(t[`ruleset-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let n=await r(t),i=await e({zone:t.zone},n,{quiet:t.quiet});t.zoneId=i,o(await c(`Loading`,async()=>n.rulesets.versions.get({zone_id:i,ruleset_id:t[`ruleset-id`],ruleset_version:t[`ruleset-version`]})),{successLabel:`Loaded`})}};function Ne(e){return e.option(`ruleset-id`,{type:`string`,description:`The unique ID of the ruleset.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Pe={command:`list`,describe:`Fetches the versions of a zone ruleset.`,builder:Ne,handler:async t=>{if(t.dryRun){s({command:`cf rulesets versions list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/rulesets/${t[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(t[`ruleset-id`]))}/versions`,pathParams:{"ruleset-id":String(t[`ruleset-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let n=await r(t),i=await e({zone:t.zone},n,{quiet:t.quiet});t.zoneId=i,o(await c(`Loading`,async()=>n.rulesets.versions.list({zone_id:i,ruleset_id:t[`ruleset-id`]})),{successLabel:`Loaded`})}},Fe={command:`versions`,describe:`Immutable snapshots of a ruleset, allowing rollback and audit of rule changes`,builder:e=>e.command(Ae).command(Me).command(Pe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Ie={command:`rulesets`,describe:`Versioned collections of rules that control how Cloudflare processes traffic — WAF, transform, redirect, and more`,builder:e=>e.command(ie).command(oe).command(ce).command(ue).command(Oe).command(ne).command(be).command(De).command(Fe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{Ie as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{n as r,t as i}from"./body-parser-DWSy7uZ8.mjs";import{t as a}from"./output-B6fBFRqe.mjs";import{n as o,t as s}from"./progress-CL8I-7YK.mjs";import{n as c}from"./input-validation-_fMCApaH.mjs";import{t as l}from"./local-CYc9q7l2.mjs";import{t as u}from"./prompt-q3B7sM2A.mjs";import{t as d}from"./cli-types-DGgEbf8K.mjs";function f(e){return e.option(`ruleset-id`,{type:`string`,description:`The Web Analytics ruleset identifier.`,demandOption:!0}).option(`delete-rules`,{type:`string`,array:!0,description:`A list of rule identifiers to delete.`}).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:`bulk-create`,describe:`Modifies one or more rules in a Web Analytics ruleset with a single request.`,builder:f,handler:async c=>{if(c.dryRun){o({command:`cf rum rules bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rum/v2/${c[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(c[`ruleset-id`]))}/rules`,pathParams:{"ruleset-id":String(c[`ruleset-id`]??``)},bodyKind:`json`,body:c.body===void 0?i({delete_rules:c[`delete-rules`]}):r(c.body)});return}let u=await n(c),d=c.local?l:await e();if(c.accountId=d,c.body){let e=r(c.body);a(await s(`Creating`,async()=>u.rum.rules.bulkCreate({...e,account_id:d,ruleset_id:c[`ruleset-id`]})),{successLabel:`Created`});return}let f=i({delete_rules:c[`delete-rules`]});a(await s(`Creating`,async()=>u.rum.rules.bulkCreate({...f,account_id:d,ruleset_id:c[`ruleset-id`]})),{successLabel:`Created`})}};function m(e){return e.positional(`ruleset-id`,{type:`string`,description:`The Web Analytics ruleset identifier.`,demandOption:!0}).option(`host`,{type:`string`,description:`The host field`}).option(`inclusive`,{type:`boolean`,description:`Whether the rule includes or excludes traffic from being measured.`}).option(`is-paused`,{type:`boolean`,description:`Whether the rule is paused or not.`}).option(`paths`,{type:`string`,array:!0,description:`The paths field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const h={command:`create <ruleset-id>`,describe:`Creates a new rule in a Web Analytics ruleset.`,builder:m,handler:async u=>{if(u.dryRun){o({command:`cf rum rules create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rum/v2/${u[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(u[`ruleset-id`]))}/rule`,pathParams:{"ruleset-id":String(u[`ruleset-id`]??``)},bodyKind:`json`,body:u.body===void 0?i({host:c(u.host,`host`,`text`),inclusive:u.inclusive,is_paused:u[`is-paused`],paths:u.paths}):r(u.body)});return}let d=await n(u),f=u.local?l:await e();if(u.accountId=f,u.body){let e=r(u.body);a(await s(`Creating`,async()=>d.rum.rules.create({body:e,account_id:f,ruleset_id:u[`ruleset-id`]})),{successLabel:`Created`});return}let p=i({host:c(u.host,`host`,`text`),inclusive:u.inclusive,is_paused:u[`is-paused`],paths:u.paths});a(await s(`Creating`,async()=>d.rum.rules.create({body:p,account_id:f,ruleset_id:u[`ruleset-id`]})),{successLabel:`Created`})}};function g(e){return e.positional(`rule-id`,{type:`string`,description:`The Web Analytics rule identifier.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The Web Analytics ruleset identifier.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const _={command:`delete <rule-id>`,describe:`Deletes an existing rule from a Web Analytics ruleset.`,builder:g,handler:async r=>{if(r.dryRun){o({command:`cf rum rules delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rum/v2/${r[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(r[`ruleset-id`]))}/rule/${r[`rule-id`]==null?`<rule-id>`:encodeURIComponent(String(r[`rule-id`]))}`,pathParams:{"ruleset-id":String(r[`ruleset-id`]??``),"rule-id":String(r[`rule-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await u({force:!!r.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}a(await s(`Deleting`,async()=>i.rum.rules.delete({account_id:c,ruleset_id:r[`ruleset-id`],rule_id:r[`rule-id`]})),{successLabel:`Deleted`})}};function v(e){return e.option(`ruleset-id`,{type:`string`,description:`The Web Analytics ruleset identifier.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`list`,describe:`Lists all the rules in a Web Analytics ruleset.`,builder:v,handler:async r=>{if(r.dryRun){o({command:`cf rum rules list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rum/v2/${r[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(r[`ruleset-id`]))}/rules`,pathParams:{"ruleset-id":String(r[`ruleset-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.rum.rules.list({account_id:c,ruleset_id:r[`ruleset-id`]})),{successLabel:`Loaded`})}};function b(e){return e.positional(`rule-id`,{type:`string`,description:`The Web Analytics rule identifier.`,demandOption:!0}).option(`ruleset-id`,{type:`string`,description:`The Web Analytics ruleset identifier.`,demandOption:!0}).option(`host`,{type:`string`,description:`The host field`}).option(`inclusive`,{type:`boolean`,description:`Whether the rule includes or excludes traffic from being measured.`}).option(`is-paused`,{type:`boolean`,description:`Whether the rule is paused or not.`}).option(`paths`,{type:`string`,array:!0,description:`The paths field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const x={command:`update <rule-id>`,describe:`Updates a rule in a Web Analytics ruleset.`,builder:b,handler:async u=>{if(u.dryRun){o({command:`cf rum rules update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rum/v2/${u[`ruleset-id`]==null?`<ruleset-id>`:encodeURIComponent(String(u[`ruleset-id`]))}/rule/${u[`rule-id`]==null?`<rule-id>`:encodeURIComponent(String(u[`rule-id`]))}`,pathParams:{"ruleset-id":String(u[`ruleset-id`]??``),"rule-id":String(u[`rule-id`]??``)},bodyKind:`json`,body:u.body===void 0?i({host:c(u.host,`host`,`text`),inclusive:u.inclusive,is_paused:u[`is-paused`],paths:u.paths}):r(u.body)});return}let d=await n(u),f=u.local?l:await e();if(u.accountId=f,u.body){let e=r(u.body);a(await s(`Updating`,async()=>d.rum.rules.update({body:e,account_id:f,ruleset_id:u[`ruleset-id`],rule_id:u[`rule-id`]})),{successLabel:`Updated`});return}let p=i({host:c(u.host,`host`,`text`),inclusive:u.inclusive,is_paused:u[`is-paused`],paths:u.paths});a(await s(`Updating`,async()=>d.rum.rules.update({body:p,account_id:f,ruleset_id:u[`ruleset-id`],rule_id:u[`rule-id`]})),{successLabel:`Updated`})}},S={command:`rules`,describe:`Operations for rules`,builder:e=>e.command(p).command(h).command(_).command(y).command(x).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function C(e){return e.option(`auto-install`,{type:`boolean`,description:`If enabled, the JavaScript snippet is automatically injected for orange-clouded sites.`}).option(`host`,{type:`string`,description:`The hostname to use for gray-clouded sites.`}).option(`zone-tag`,{type:`string`,description:`The zone identifier.`}).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 w={command:`create`,describe:`Creates a new Web Analytics site.`,builder:C,handler:async u=>{if(u.dryRun){o({command:`cf rum site-info create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rum/site_info`,pathParams:{},bodyKind:`json`,body:u.body===void 0?i({auto_install:u[`auto-install`],host:c(u.host,`host`,`text`),zone_tag:c(u[`zone-tag`],`zone-tag`,`text`)}):r(u.body)});return}let d=await n(u),f=u.local?l:await e();if(u.accountId=f,u.body){let e=r(u.body);a(await s(`Creating`,async()=>d.rum.siteInfo.create({...e,account_id:f})),{successLabel:`Created`});return}let p=i({auto_install:u[`auto-install`],host:c(u.host,`host`,`text`),zone_tag:c(u[`zone-tag`],`zone-tag`,`text`)});a(await s(`Creating`,async()=>d.rum.siteInfo.create({...p,account_id:f})),{successLabel:`Created`})}};function T(e){return e.positional(`site-id`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const E={command:`delete <site-id>`,describe:`Deletes an existing Web Analytics site.`,builder:T,handler:async r=>{if(r.dryRun){o({command:`cf rum site-info delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rum/site_info/${r[`site-id`]==null?`<site-id>`:encodeURIComponent(String(r[`site-id`]))}`,pathParams:{"site-id":String(r[`site-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await u({force:!!r.force})){process.stderr.write(`Aborted.
|
|
4
|
+
`);return}a(await s(`Deleting`,async()=>i.rum.siteInfo.delete({account_id:c,site_id:r[`site-id`]})),{successLabel:`Deleted`})}};function D(e){return e.positional(`site-id`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`get <site-id>`,describe:`Retrieves a Web Analytics site.`,builder:D,handler:async r=>{if(r.dryRun){o({command:`cf rum site-info get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rum/site_info/${r[`site-id`]==null?`<site-id>`:encodeURIComponent(String(r[`site-id`]))}`,pathParams:{"site-id":String(r[`site-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.rum.siteInfo.get({account_id:c,site_id:r[`site-id`]})),{successLabel:`Loaded`})}};function k(e){return e.option(`per-page`,{type:`number`,description:`Number of items to return per page of results.`}).option(`page`,{type:`number`,description:`Current page within the paginated list of results.`}).option(`order-by`,{type:`string`,description:`The property used to sort the list of results.`,choices:[`host`,`created`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`list`,describe:`Lists all Web Analytics sites of an account.`,builder:d(k),handler:async r=>{let i={per_page:r[`per-page`],page:r.page,order_by:r[`order-by`]};if(r.dryRun){o({command:`cf rum site-info list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rum/site_info/list`,pathParams:{},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.rum.siteInfo.list({account_id:u,...i})),{successLabel:`Loaded`})}};function j(e){return e.positional(`site-id`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`auto-install`,{type:`boolean`,description:`If enabled, the JavaScript snippet is automatically injected for orange-clouded sites.`}).option(`enabled`,{type:`boolean`,description:`Enables or disables RUM. This option can be used only when auto_install is set to true.`}).option(`host`,{type:`string`,description:`The hostname to use for gray-clouded sites.`}).option(`lite`,{type:`boolean`,description:`If enabled, the JavaScript snippet will not be injected for visitors from the EU.`}).option(`zone-tag`,{type:`string`,description:`The zone identifier.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const M={command:`update <site-id>`,describe:`Updates an existing Web Analytics site.`,builder:j,handler:async u=>{if(u.dryRun){o({command:`cf rum site-info update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/rum/site_info/${u[`site-id`]==null?`<site-id>`:encodeURIComponent(String(u[`site-id`]))}`,pathParams:{"site-id":String(u[`site-id`]??``)},bodyKind:`json`,body:u.body===void 0?i({auto_install:u[`auto-install`],enabled:u.enabled,host:c(u.host,`host`,`text`),lite:u.lite,zone_tag:c(u[`zone-tag`],`zone-tag`,`text`)}):r(u.body)});return}let d=await n(u),f=u.local?l:await e();if(u.accountId=f,u.body){let e=r(u.body);a(await s(`Updating`,async()=>d.rum.siteInfo.update({...e,account_id:f,site_id:u[`site-id`]})),{successLabel:`Updated`});return}let p=i({auto_install:u[`auto-install`],enabled:u.enabled,host:c(u.host,`host`,`text`),lite:u.lite,zone_tag:c(u[`zone-tag`],`zone-tag`,`text`)});a(await s(`Updating`,async()=>d.rum.siteInfo.update({...p,account_id:f,site_id:u[`site-id`]})),{successLabel:`Updated`})}},N={command:`site-info`,describe:`Operations for site-info`,builder:e=>e.command(w).command(E).command(O).command(A).command(M).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},P={command:`rum`,describe:`rum`,builder:e=>e.command(S).command(N).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{P as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{t as e}from"./output-B6fBFRqe.mjs";import{n as t}from"./metadata-
|
|
2
|
+
import{t as e}from"./output-B6fBFRqe.mjs";import{n as t}from"./metadata-MPDDi08e.mjs";function n(e){return typeof e==`object`&&!!e&&`version`in e&&`schemas`in e&&typeof e.version==`string`&&typeof e.schemas==`object`}const r={command:`schema [command..]`,describe:`Show API schema details for a command`,builder:e=>e.positional(`command`,{describe:`Command path segments (e.g., dns records create)`,type:`string`,array:!0,default:[]}).option(`list`,{type:`boolean`,describe:`List all available schemas`,default:!1}),handler:async r=>{let i=t(import.meta.url,`schemas.json`,n);if(i||(console.error("Error: Could not load schemas.json. Run `pnpm generate` first."),process.exit(1)),r.list){e(Object.entries(i.schemas).map(([e,t])=>({command:`cf ${e}`,httpMethod:t.httpMethod,apiPath:t.path,operationId:t.operationId})));return}r.command.length===0&&(console.error(`Usage: cf schema <command...> or cf schema --list`),console.error(`Example: cf schema dns records create`),process.exit(1));let a=r.command.join(` `),o=i.schemas[a];if(!o){let e=Object.keys(i.schemas).filter(e=>e.includes(a)||a.includes(e));if(e.length>0){console.error(`Schema not found for "${a}". Did you mean:`);for(let t of e)console.error(` cf schema ${t}`)}else console.error(`Schema not found for "${a}". Use --list to see available schemas.`);process.exit(1)}e(o)}};export{r as default};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{N as e}from"./oauth-B5k80sip.mjs";import{i as t,n}from"./auth-DX9KnJ0P.mjs";import{n as r,t as i}from"./body-parser-DWSy7uZ8.mjs";import{t as a}from"./output-B6fBFRqe.mjs";import{n as o,t as s}from"./progress-CL8I-7YK.mjs";import{n as c}from"./input-validation-_fMCApaH.mjs";import{n as l,r as u,t as d}from"./prompt-q3B7sM2A.mjs";import{t as f}from"./cli-types-DGgEbf8K.mjs";function p(e){return e.option(`kind`,{type:`string`,description:`The kind of the schema`,choices:[`openapi_v3`]}).option(`name`,{type:`string`,description:`A human-readable name for the schema`}).option(`source`,{type:`string`,description:`The raw schema, e.g., the OpenAPI schema, either as JSON or YAML`}).option(`validation-enabled`,{type:`boolean`,description:`An indicator if this schema is enabled`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const m={command:`create`,describe:`Uploads a new OpenAPI schema for API Shield schema validation. The schema defines expected request/response formats for API endpoints.`,builder:p,handler:async t=>{if(t.dryRun){o({command:`cf schema-validation schemas create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/schemas`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({kind:c(t.kind,`kind`,`text`),name:c(t.name,`name`,`text`),source:c(t.source,`source`,`text`),validation_enabled:t[`validation-enabled`]}):r(t.body)});return}let d=await n(t),f=await e({zone:t.zone},d,{quiet:t.quiet});if(t.zoneId=f,t.body){let e=r(t.body);a(await s(`Creating`,async()=>d.schemaValidation.schemas.create({...e,zone_id:f})),{successLabel:`Created`});return}if(t.kind===void 0&&(t.kind=await l(`kind`,`The kind of the schema`,[`openapi_v3`])),t.name===void 0&&(t.name=await u(`name`,`A human-readable name for the schema`)),t.source===void 0&&(t.source=await u(`source`,`The raw schema, e.g., the OpenAPI schema, either as JSON or YAML`)),t[`validation-enabled`]===void 0)throw Error(`--validation-enabled is required (or pass --body with this field set).`);let p=i({kind:c(t.kind,`kind`,`text`),name:c(t.name,`name`,`text`),source:c(t.source,`source`,`text`),validation_enabled:t[`validation-enabled`]});a(await s(`Creating`,async()=>d.schemaValidation.schemas.create({...p,zone_id:f})),{successLabel:`Created`})}};function h(e){return e.positional(`schema-id`,{type:`string`,description:`The unique identifier of the schema`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const g={command:`delete <schema-id>`,describe:`Permanently removes an uploaded OpenAPI schema from API Shield. Operations using this schema will lose their validation rules.`,builder:h,handler:async t=>{if(t.dryRun){o({command:`cf schema-validation schemas delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/schemas/${t[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(t[`schema-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"schema-id":String(t[`schema-id`]??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});if(t.zoneId=i,!await d({force:!!t.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}a(await s(`Deleting`,async()=>r.schemaValidation.schemas.delete({zone_id:i,schema_id:t[`schema-id`]})),{successLabel:`Deleted`})}};function _(e){return e.positional(`schema-id`,{type:`string`,description:`The unique identifier of the schema`,demandOption:!0}).option(`validation-enabled`,{type:`boolean`,description:`Flag whether schema is enabled for validation.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const v={command:`edit <schema-id>`,describe:`Modifies an existing OpenAPI schema in API Shield, updating the validation rules for associated API operations.`,builder:_,handler:async t=>{if(t.dryRun){o({command:`cf schema-validation schemas edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/schemas/${t[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(t[`schema-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"schema-id":String(t[`schema-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({validation_enabled:t[`validation-enabled`]}):r(t.body)});return}let c=await n(t),l=await e({zone:t.zone},c,{quiet:t.quiet});if(t.zoneId=l,t.body){let e=r(t.body);a(await s(`Updating`,async()=>c.schemaValidation.schemas.edit({...e,zone_id:l,schema_id:t[`schema-id`]})),{successLabel:`Updated`});return}let u=i({validation_enabled:t[`validation-enabled`]});a(await s(`Updating`,async()=>c.schemaValidation.schemas.edit({...u,zone_id:l,schema_id:t[`schema-id`]})),{successLabel:`Updated`})}};function y(e){return e.positional(`schema-id`,{type:`string`,description:`The unique identifier of the schema`,demandOption:!0}).option(`omit-source`,{type:`boolean`,description:`Omit the source-files of schemas and only retrieve their meta-data.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`get <schema-id>`,describe:`Gets the contents and metadata of a specific OpenAPI schema uploaded to API Shield.`,builder:y,handler:async t=>{let r={omit_source:t[`omit-source`]};if(t.dryRun){o({command:`cf schema-validation schemas get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/schemas/${t[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(t[`schema-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"schema-id":String(t[`schema-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.schemaValidation.schemas.get({zone_id:c,schema_id:t[`schema-id`],...r})),{successLabel:`Loaded`})}};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(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const S={command:`list`,describe:`Lists all unique hosts found in uploaded OpenAPI schemas for the zone.`,builder:x,handler:async t=>{let r={page:t.page,per_page:t[`per-page`]};if(t.dryRun){o({command:`cf schema-validation schemas hosts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/schemas/hosts`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.schemaValidation.schemas.hosts.list({zone_id:c,...r})),{successLabel:`Loaded`})}},C={command:`hosts`,describe:`List schema hosts and extract operations from uploaded schemas`,builder:e=>e.command(S).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function w(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`omit-source`,{type:`boolean`,description:`Omit the source-files of schemas and only retrieve their meta-data.`}).option(`validation-enabled`,{type:`boolean`,description:`Filter for enabled schemas`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`list`,describe:`Lists all OpenAPI schemas uploaded to API Shield with pagination support.`,builder:w,handler:async t=>{let r={page:t.page,per_page:t[`per-page`],omit_source:t[`omit-source`],validation_enabled:t[`validation-enabled`]};if(t.dryRun){o({command:`cf schema-validation schemas list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/schemas`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.schemaValidation.schemas.list({zone_id:c,...r})),{successLabel:`Loaded`})}};function E(e){return e.positional(`schema-id`,{type:`string`,description:`The unique identifier of the schema`,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 Web Asset Management or not. `new` will just return operations from the schema that do not exist otherwise. `existing` will just return operations from the schema that already exist.",choices:[`new`,`existing`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const D={command:`get <schema-id>`,describe:`Retrieves all operations from the schema. Operations that already exist in API Shield Endpoint Management will be returned as full operations.`,builder:f(E),handler:async t=>{let r={feature:t.feature,host:t.host,method:t.method,endpoint:t.endpoint,page:t.page,per_page:t[`per-page`],operation_status:t[`operation-status`]};if(t.dryRun){o({command:`cf schema-validation schemas operations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/schemas/${t[`schema-id`]==null?`<schema-id>`:encodeURIComponent(String(t[`schema-id`]))}/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"schema-id":String(t[`schema-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.schemaValidation.schemas.operations.get({zone_id:c,schema_id:t[`schema-id`],...r})),{successLabel:`Loaded`})}},O={command:`operations`,describe:`List schema hosts and extract operations from uploaded schemas`,builder:e=>e.command(D).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},k={command:`schemas`,describe:`Uploaded API schemas used to validate incoming requests against expected formats`,builder:e=>e.command(m).command(g).command(v).command(b).command(T).command(C).command(O).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function A(e){return e.option(`validation-default-mitigation-action`,{type:`string`,description:`The default mitigation action used
|
|
4
|
+
Mitigation actions are as follows:
|
|
5
|
+
|
|
6
|
+
- \`"log"\` - log request when request does not conform to schema
|
|
7
|
+
- \`"block"\` - deny access to the site when request does not conform to schema
|
|
8
|
+
- \`"none"\` - skip running schema validation
|
|
9
|
+
`,choices:[`none`,`log`,`block`]}).option(`validation-override-mitigation-action`,{type:`string`,description:`When set, this overrides both zone level and operation level mitigation actions.
|
|
10
|
+
|
|
11
|
+
- \`"none"\` - skip running schema validation entirely for the request
|
|
12
|
+
- \`null\` - clears any existing override
|
|
13
|
+
`,choices:[`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 j={command:`edit`,describe:`Partially updates global schema validation settings for a zone using PATCH semantics.`,builder:A,handler:async t=>{if(t.dryRun){o({command:`cf schema-validation settings edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/settings`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({validation_default_mitigation_action:c(t[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:c(t[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)}):r(t.body)});return}let l=await n(t),u=await e({zone:t.zone},l,{quiet:t.quiet});if(t.zoneId=u,t.body){let e=r(t.body);a(await s(`Updating`,async()=>l.schemaValidation.settings.edit({body:e,zone_id:u})),{successLabel:`Updated`});return}let d=i({validation_default_mitigation_action:c(t[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:c(t[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)});a(await s(`Updating`,async()=>l.schemaValidation.settings.edit({body:d,zone_id:u})),{successLabel:`Updated`})}};function M(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const N={command:`get`,describe:`Retrieves the current global schema validation settings for a zone.`,builder:M,handler:async t=>{if(t.dryRun){o({command:`cf schema-validation settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/settings`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});t.zoneId=i,a(await s(`Loading`,async()=>r.schemaValidation.settings.get({zone_id:i})),{successLabel:`Loaded`})}};function P(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 F={command:`bulk-edit`,describe:`Updates schema validation settings for multiple API operations in a single request. Efficient for applying consistent validation rules across endpoints.`,builder:P,handler:async i=>{if(i.dryRun){o({command:`cf schema-validation settings operations bulk-edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${i.zone??i.zoneId??`<zone>`}/schema_validation/settings/operations`,pathParams:{"zone-id":String(i.zone??i[`zone-id`]??``)},bodyKind:`json`,body:i.body===void 0?void 0:r(i.body)});return}let c=await n(i),l=await e({zone:i.zone},c,{quiet:i.quiet});if(i.zoneId=l,i.body){let e=r(i.body);a(await s(`Updating`,async()=>c.schemaValidation.settings.operations.bulkEdit({body:e,zone_id:l})),{successLabel:`Updated`});return}a(await s(`Updating`,async()=>t(c,`PATCH`,`/zones/${i.zoneId}/schema_validation/settings/operations`)),{successLabel:`Updated`})}};function I(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const L={command:`delete <operation-id>`,describe:`Removes custom schema validation settings for a specific API operation, reverting to zone-level defaults.`,builder:I,handler:async t=>{if(t.dryRun){o({command:`cf schema-validation settings operations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/settings/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});if(t.zoneId=i,!await d({force:!!t.force})){process.stderr.write(`Aborted.
|
|
14
|
+
`);return}a(await s(`Deleting`,async()=>r.schemaValidation.settings.operations.delete({zone_id:i,operation_id:t[`operation-id`]})),{successLabel:`Deleted`})}};function R(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const z={command:`get <operation-id>`,describe:`Retrieves the schema validation settings configured for a specific API operation.`,builder:R,handler:async t=>{if(t.dryRun){o({command:`cf schema-validation settings operations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/settings/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},bodyKind:`none`});return}let r=await n(t),i=await e({zone:t.zone},r,{quiet:t.quiet});t.zoneId=i,a(await s(`Loading`,async()=>r.schemaValidation.settings.operations.get({zone_id:i,operation_id:t[`operation-id`]})),{successLabel:`Loaded`})}};function B(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const V={command:`list`,describe:`Lists all per-operation schema validation settings configured for the zone.`,builder:B,handler:async t=>{let r={page:t.page,per_page:t[`per-page`]};if(t.dryRun){o({command:`cf schema-validation settings operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/settings/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:r,bodyKind:`none`});return}let i=await n(t),c=await e({zone:t.zone},i,{quiet:t.quiet});t.zoneId=c,a(await s(`Loading`,async()=>i.schemaValidation.settings.operations.list({zone_id:c,...r})),{successLabel:`Loaded`})}};function H(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`mitigation-action`,{type:`string`,description:'When set, this applies a mitigation action to this operation\n\n - `"log"` - log request when request does not conform to schema for this operation\n - `"block"` - deny access to the site when request does not conform to schema for this operation\n - `"none"` - will skip mitigation for this operation\n - `null` - clears any mitigation action\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 U={command:`update <operation-id>`,describe:`Fully updates schema validation settings for a specific API operation.`,builder:H,handler:async t=>{if(t.dryRun){o({command:`cf schema-validation settings operations update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/settings/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({mitigation_action:c(t[`mitigation-action`],`mitigation-action`,`text`)}):r(t.body)});return}let u=await n(t),d=await e({zone:t.zone},u,{quiet:t.quiet});if(t.zoneId=d,t.body){let e=r(t.body);a(await s(`Updating`,async()=>u.schemaValidation.settings.operations.update({...e,zone_id:d,operation_id:t[`operation-id`]})),{successLabel:`Updated`});return}t[`mitigation-action`]===void 0&&(t[`mitigation-action`]=await l(`mitigation-action`,'When set, this applies a mitigation action to this operation - `"log"` - log request when request does not conform to schema for this operation - `"block"` - deny access to the site when request does not conform to schema for this operation - `"none"` - will skip mitigation for this operation - `null` - clears any mitigation action ',[`log`,`block`,`none`]));let f=i({mitigation_action:c(t[`mitigation-action`],`mitigation-action`,`text`)});a(await s(`Updating`,async()=>u.schemaValidation.settings.operations.update({...f,zone_id:d,operation_id:t[`operation-id`]})),{successLabel:`Updated`})}},W={command:`operations`,describe:`Zone-level schema validation settings including default actions for unmatched requests`,builder:e=>e.command(F).command(L).command(z).command(V).command(U).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function G(e){return e.option(`validation-default-mitigation-action`,{type:`string`,description:`The default mitigation action used
|
|
15
|
+
Mitigation actions are as follows:
|
|
16
|
+
|
|
17
|
+
- \`"log"\` - log request when request does not conform to schema
|
|
18
|
+
- \`"block"\` - deny access to the site when request does not conform to schema
|
|
19
|
+
- \`"none"\` - skip running schema validation
|
|
20
|
+
`,choices:[`none`,`log`,`block`]}).option(`validation-override-mitigation-action`,{type:`string`,description:`When set, this overrides both zone level and operation level mitigation actions.
|
|
21
|
+
|
|
22
|
+
- \`"none"\` - skip running schema validation entirely for the request
|
|
23
|
+
- \`null\` - clears any existing override
|
|
24
|
+
`,choices:[`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 K={command:`update`,describe:`Fully updates global schema validation settings for a zone, replacing existing configuration.`,builder:G,handler:async t=>{if(t.dryRun){o({command:`cf schema-validation settings update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/schema_validation/settings`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?i({validation_default_mitigation_action:c(t[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:c(t[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)}):r(t.body)});return}let u=await n(t),d=await e({zone:t.zone},u,{quiet:t.quiet});if(t.zoneId=d,t.body){let e=r(t.body);a(await s(`Updating`,async()=>u.schemaValidation.settings.update({...e,zone_id:d})),{successLabel:`Updated`});return}t[`validation-default-mitigation-action`]===void 0&&(t[`validation-default-mitigation-action`]=await l(`validation-default-mitigation-action`,'The default mitigation action used 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 - `"none"` - skip running schema validation ',[`none`,`log`,`block`]));let f=i({validation_default_mitigation_action:c(t[`validation-default-mitigation-action`],`validation-default-mitigation-action`,`text`),validation_override_mitigation_action:c(t[`validation-override-mitigation-action`],`validation-override-mitigation-action`,`text`)});a(await s(`Updating`,async()=>u.schemaValidation.settings.update({...f,zone_id:d})),{successLabel:`Updated`})}},q={command:`settings`,describe:`Zone-level schema validation settings including default actions for unmatched requests`,builder:e=>e.command(j).command(N).command(K).command(W).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},J={command:`schema-validation`,describe:`API schema validation settings — enforce request/response schemas and configure validation behavior`,builder:e=>e.command(k).command(q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{J as default};
|