cf 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_meta/agent-context.json +1 -1
- package/dist/_meta/commands.json +9 -112
- package/dist/{abuse-reports-BsF9JZPW.mjs → abuse-reports-C6GFnuYE.mjs} +1 -1
- package/dist/{account-D8mYiWxQ.mjs → account-DxzpnGA8.mjs} +1 -1
- package/dist/{accounts-CJci1Oez.mjs → accounts-6RFDuFLF.mjs} +1 -1
- package/dist/{acm-CmCd985Q.mjs → acm-Bndi5Jqo.mjs} +1 -1
- package/dist/{addressing-R7p6TRBe.mjs → addressing-C8HB4n_n.mjs} +1 -1
- package/dist/ai-B4La9Oqk.mjs +8 -0
- package/dist/{ai-audit-B0vJNOZG.mjs → ai-audit-B9kKFhoY.mjs} +1 -1
- package/dist/{ai-gateway-D3vJR3My.mjs → ai-gateway-Bx9MzNxL.mjs} +1 -1
- package/dist/{ai-search-CNg7W7U4.mjs → ai-search-BgIOIgXd.mjs} +1 -1
- package/dist/{alerting-_sdM0B0S.mjs → alerting-DVI-v6mE.mjs} +1 -1
- package/dist/{analytics-BFBJhDrP.mjs → analytics-B98epmDb.mjs} +1 -1
- package/dist/{analytics_engine-CWhFvyeK.mjs → analytics_engine-DwDePA2c.mjs} +1 -1
- package/dist/{api-gateway-D4AIEtUq.mjs → api-gateway-DW2GX64w.mjs} +1 -1
- package/dist/{argo-Bjk6nFfs.mjs → argo-DKEx-B66.mjs} +1 -1
- package/dist/{artifacts-Ba4b3iOa.mjs → artifacts-BEU8fBqt.mjs} +1 -1
- package/dist/{audit-logs-BE0T5All.mjs → audit-logs-DZiEPYL0.mjs} +1 -1
- package/dist/{auth-D_zyQbDR.mjs → auth-009DISzb.mjs} +1 -1
- package/dist/{auth-CZ0E51rF.mjs → auth-B1CY5zpC.mjs} +2 -2
- package/dist/{billing-Dz6Zj8Eq.mjs → billing-10B4_1qb.mjs} +1 -1
- package/dist/{bot-management-pFwIbFi-.mjs → bot-management-D51WzJBO.mjs} +1 -1
- package/dist/{botnet-feed-BY9uGChY.mjs → botnet-feed-Dw-leAwX.mjs} +1 -1
- package/dist/{brand-protection-DkPAk2Cz.mjs → brand-protection-BTYkTsER.mjs} +1 -1
- package/dist/{browser-extension-D9P6Yv8i.mjs → browser-extension-BFa5Ky8u.mjs} +1 -1
- package/dist/{browser-run-DhHtz4y3.mjs → browser-run-BMA8Z_hI.mjs} +1 -1
- package/dist/build-C1FOoThn.mjs +70 -0
- package/dist/{cache-DVhkiIGK.mjs → cache-DrX4gWvg.mjs} +1 -1
- package/dist/{calls-95zjvIcO.mjs → calls-m4WyL1Rb.mjs} +1 -1
- package/dist/{certificate-authorities-BowBqbVq.mjs → certificate-authorities-BA-S8NE-.mjs} +1 -1
- package/dist/{cf-BLT7uKJF.mjs → cf-BhDnTcDR.mjs} +7 -7
- package/dist/chunk-2SIGYDH3-_JSHaszR.mjs +473 -0
- package/dist/{chunk-6IEM75FG-BEjRFMGh.mjs → chunk-Q72B4Q5Z-B-N_eqrM.mjs} +1 -1
- package/dist/{client-certificates-D6mE4vJu.mjs → client-certificates-5h-fXoNq.mjs} +1 -1
- package/dist/{cloud-connector-DmwsjeFN.mjs → cloud-connector-ywFQuqtV.mjs} +1 -1
- package/dist/{cloudforce-one-CG3TT7IN.mjs → cloudforce-one-CPx4C-r3.mjs} +1 -1
- package/dist/{completions-DMc_PlIw.mjs → completions-CCRu-jvY.mjs} +1 -1
- package/dist/{connectivity-DJkE3crz.mjs → connectivity-y-Gav-Ge.mjs} +1 -1
- package/dist/{connector-interrupts-DTgQ7onV.mjs → connector-interrupts-Bs-jfuh8.mjs} +1 -1
- package/dist/{connector-telemetry-events-D0rTHDou.mjs → connector-telemetry-events-Bc6f3xpx.mjs} +1 -1
- package/dist/{connector-telemetry-snapshots--0QmD3z6.mjs → connector-telemetry-snapshots-Bl54XZ3h.mjs} +1 -1
- package/dist/{connectors-zWaZTi2A.mjs → connectors-BnQq_R19.mjs} +1 -1
- package/dist/{content-scanning-CGvGf04y.mjs → content-scanning-Bxk-WkSL.mjs} +1 -1
- package/dist/{ct-alerting-ebSPSWNC.mjs → ct-alerting-BSn2Jqou.mjs} +1 -1
- package/dist/{custom-certificates-CWUrPYLP.mjs → custom-certificates-BBqr4S9W.mjs} +1 -1
- package/dist/{custom-csrs-CRtdrF9R.mjs → custom-csrs-CXeBzLUy.mjs} +1 -1
- package/dist/{custom-hostnames-CVQSksqq.mjs → custom-hostnames-CfCOedoN.mjs} +1 -1
- package/dist/{custom-nameservers-BRwbIdsX.mjs → custom-nameservers-RPXeu7f_.mjs} +1 -1
- package/dist/{custom-pages-Ci8sTQX7.mjs → custom-pages-xGG1xo88.mjs} +1 -1
- package/dist/{d1-78Ym1P6D.mjs → d1-CRIOfBsJ.mjs} +1 -1
- package/dist/{data-security-zmFoMwRU.mjs → data-security-D5Sw5rwj.mjs} +1 -1
- package/dist/{dcv-delegation-Dd4FZ2IG.mjs → dcv-delegation-BBnlgr6F.mjs} +1 -1
- package/dist/deploy-D0_KIUpW.mjs +2 -0
- package/dist/deploy-input-CdWrpzPA.mjs +1178 -0
- package/dist/{dev-DSslyDXx.mjs → dev-Bz87BeKt.mjs} +1 -1
- package/dist/{diagnostics-B8Ev5m_o.mjs → diagnostics-C1qryRf4.mjs} +1 -1
- package/dist/{dispatch-namespaces-Dm5vGeEP.mjs → dispatch-namespaces-DbosPgPV.mjs} +1 -1
- package/dist/{dist-BH-4NQOV.mjs → dist-C-6VkMPZ.mjs} +35 -35
- package/dist/dist-CnaLMpVH.mjs +18 -0
- package/dist/{dns-D7VAaCyO.mjs → dns-ByufYrJH.mjs} +1 -1
- package/dist/{dns-firewall-ByLCsf0q.mjs → dns-firewall-CiokCKRr.mjs} +1 -1
- package/dist/{durable-objects-BIpvyu9m.mjs → durable-objects-DjF-WAD3.mjs} +1 -1
- package/dist/{email-auth-Cx--s8W4.mjs → email-auth-B4BIYMb-.mjs} +1 -1
- package/dist/{email-routing-CiDbivcN.mjs → email-routing-BbbtpVyS.mjs} +1 -1
- package/dist/{email-security-BYeAuSc6.mjs → email-security-DuBVypAO.mjs} +1 -1
- package/dist/{email-sending-Dg2rSmHH.mjs → email-sending-5g-k05Lv.mjs} +1 -1
- package/dist/{filters-DZ8YnQ90.mjs → filters-CzJmLFcS.mjs} +1 -1
- package/dist/{firewall-DEd1hs_I.mjs → firewall-CjmeWA2M.mjs} +1 -1
- package/dist/{flagship-DVw7xGoP.mjs → flagship-BfyVrWP-.mjs} +1 -1
- package/dist/{fraud-BbGS3FZs.mjs → fraud-reRvxNg-.mjs} +1 -1
- package/dist/{google-tag-gateway-CBnRGYQR.mjs → google-tag-gateway-CGwzMZU1.mjs} +1 -1
- package/dist/{healthchecks-Da9N3ix4.mjs → healthchecks-BhCsPWcG.mjs} +1 -1
- package/dist/{hostnames-mimZu2tB.mjs → hostnames-JpgQW4kn.mjs} +1 -1
- package/dist/{hyperdrive-BNdvxOos.mjs → hyperdrive-iwYttuwV.mjs} +1 -1
- package/dist/{iam-DGQ-OgRl.mjs → iam-ffI98_4v.mjs} +1 -1
- package/dist/{images-CI6Iy9ho.mjs → images-Bgb9DGlr.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{intel-BDB-aRtU.mjs → intel-DVRjKpyU.mjs} +1 -1
- package/dist/{ips-B9UuPvsY.mjs → ips-BtLRO19r.mjs} +1 -1
- package/dist/{keyless-certificates-Ua9uJgPt.mjs → keyless-certificates-13w8KOcC.mjs} +1 -1
- package/dist/{kv-BHerx4dZ.mjs → kv-CvQyF_NB.mjs} +1 -1
- package/dist/{leaked-credential-checks-B8Vunj9h.mjs → leaked-credential-checks-DvY8VReW.mjs} +1 -1
- package/dist/{load-balancers-DSjS5WKw.mjs → load-balancers-6lgExyS7.mjs} +1 -1
- package/dist/{logexplorer-DBIfTlRP.mjs → logexplorer-DBfrK1hn.mjs} +1 -1
- package/dist/{logo-matches-C00iGpzW.mjs → logo-matches-XS2RaxQu.mjs} +1 -1
- package/dist/{logos-CJLhx1go.mjs → logos-COtlpbRq.mjs} +1 -1
- package/dist/{logpush-Cr1U-eK-.mjs → logpush-CIpiK3Xl.mjs} +1 -1
- package/dist/{logs-DMvtchc6.mjs → logs-0KjIf_3g.mjs} +1 -1
- package/dist/{magic-cloud-networking-FQfO8QWH.mjs → magic-cloud-networking-q_d9-he-.mjs} +1 -1
- package/dist/{magic-network-monitoring-CDd70fJQ.mjs → magic-network-monitoring-DLNCrUsn.mjs} +1 -1
- package/dist/{magic-transit-DiKiPUax.mjs → magic-transit-sIwSlzoK.mjs} +1 -1
- package/dist/{managed-transforms-fPVUTrAv.mjs → managed-transforms-BKRjmzJS.mjs} +1 -1
- package/dist/{matches-B0yHbQ2I.mjs → matches-DZLS60M2.mjs} +1 -1
- package/dist/{moq-UgBawOXe.mjs → moq-Dbb9QhC1.mjs} +1 -1
- package/dist/{mtls-certificates-xKUbC5EL.mjs → mtls-certificates-BpIqoWpc.mjs} +1 -1
- package/dist/{network-interconnects-BJzOE2ny.mjs → network-interconnects-DZwGJFYT.mjs} +1 -1
- package/dist/{oauth-DBJ5GSFk.mjs → oauth-DC9g9uK_.mjs} +1 -1
- package/dist/{observability-B-1y36QS.mjs → observability-CVLjPAir.mjs} +1 -1
- package/dist/{open-YWOUIZ5Y-CFRcYALi.mjs → open-PBXRGS4R-D5C2-7de.mjs} +1 -1
- package/dist/{organization-Dq3PClZ7.mjs → organization-BGF8N1QQ.mjs} +1 -1
- package/dist/{organizations-AhsQkHyX.mjs → organizations-BInE8nlx.mjs} +1 -1
- package/dist/{origin-ca-certificates-CRgF0UyU.mjs → origin-ca-certificates-wPzWcEa0.mjs} +1 -1
- package/dist/{origin-post-quantum-encryption-BXTx7DPa.mjs → origin-post-quantum-encryption-t1Cl9hiy.mjs} +1 -1
- package/dist/{origin-tls-client-auth-BDw5q-6G.mjs → origin-tls-client-auth-Cvr9D8eq.mjs} +1 -1
- package/dist/{page-rules-DqYQ23eg.mjs → page-rules-CMo73oVb.mjs} +1 -1
- package/dist/{page-shield-DKdlZOLO.mjs → page-shield-Z23iqabu.mjs} +1 -1
- package/dist/{pages-BsXF11Kv.mjs → pages-ByaZvYjA.mjs} +1 -1
- package/dist/{pay-per-crawl-BGAwuAP3.mjs → pay-per-crawl-BXTenh_d.mjs} +1 -1
- package/dist/{pipelines-D_QhSnGW.mjs → pipelines-7KWm5BYN.mjs} +1 -1
- package/dist/{progress-O88q63Bk.mjs → progress-BLQ2xXwD.mjs} +1 -1
- package/dist/{prompt-DTAWiEm2.mjs → prompt-DcfYBioA.mjs} +1 -1
- package/dist/{queries-CAE95-OH.mjs → queries-Cgx1lQbn.mjs} +1 -1
- package/dist/{queues-BBz35Mqd.mjs → queues-jnugmCYI.mjs} +1 -1
- package/dist/{r2-Zp99S5xF.mjs → r2-Dllx7F7a.mjs} +1 -1
- package/dist/{r2-data-catalog-BeVLZwrE.mjs → r2-data-catalog-CaAAPwKp.mjs} +1 -1
- package/dist/{radar-Cij-XVQJ.mjs → radar-DLSHX2_1.mjs} +1 -1
- package/dist/{rate-limits-DSdToIWv.mjs → rate-limits-DlVTd6QY.mjs} +1 -1
- package/dist/{raw-fetch-DgezeshQ.mjs → raw-fetch-CeW1mW_u.mjs} +1 -1
- package/dist/{realtime-kit-9rJcapfM.mjs → realtime-kit-ct8Fu2kO.mjs} +1 -1
- package/dist/{registrar-CXViZlah.mjs → registrar-CKTB7QTM.mjs} +1 -1
- package/dist/{registrar-sandbox-CvQyjXLJ.mjs → registrar-sandbox-1-nNk6Uy.mjs} +1 -1
- package/dist/{request-tracers-DATfBnE9.mjs → request-tracers-DO6lno0x.mjs} +1 -1
- package/dist/{resource-sharing-Cmhn6ghR.mjs → resource-sharing-DYhXJw44.mjs} +1 -1
- package/dist/{resource-tagging-BTn05AOj.mjs → resource-tagging-CcKWMF9l.mjs} +1 -1
- package/dist/{rules-ens3OHme.mjs → rules-DQKR3qb7.mjs} +1 -1
- package/dist/{rulesets-bkreZRao.mjs → rulesets-B9fZb_JY.mjs} +1 -1
- package/dist/{rum-CpgXFcwl.mjs → rum-BaJio_GD.mjs} +1 -1
- package/dist/{schema-validation-Ca6o94ts.mjs → schema-validation-Cqv8KT1B.mjs} +1 -1
- package/dist/{scim-C4oT8TMc.mjs → scim-DkYH1dep.mjs} +1 -1
- package/dist/{secrets-store-CWEuiDNo.mjs → secrets-store-CMR_pA1t.mjs} +1 -1
- package/dist/{security-center-BOvm7xy6.mjs → security-center-DCHfgCq6.mjs} +1 -1
- package/dist/{security-txt-BCAUBctN.mjs → security-txt-D19uTyaf.mjs} +1 -1
- package/dist/{session-B1ARgLG7.mjs → session-CQpgz61H.mjs} +1 -1
- package/dist/{share-DhmVspmL.mjs → share-CfJbt0WU.mjs} +1 -1
- package/dist/shared-D0xvDsDl.mjs +2 -0
- package/dist/{smart-shield-DZm4fn6z.mjs → smart-shield-BG5WOmi1.mjs} +1 -1
- package/dist/{snippets-oQ0u26-z.mjs → snippets-CYiSdx7R.mjs} +1 -1
- package/dist/{spawn-ChG5Xi9Z.mjs → spawn-j3dn7A69.mjs} +1 -1
- package/dist/{spectrum-Cnkee5Ww.mjs → spectrum-Qvq3yJax.mjs} +1 -1
- package/dist/{speed-DqNnvLBD.mjs → speed-vpoB9msm.mjs} +1 -1
- package/dist/{src-By-zTCHz.mjs → src-Bn0FyQIp.mjs} +5 -5
- package/dist/{ssl-tS3CYZsZ.mjs → ssl-Qw8eVAiS.mjs} +1 -1
- package/dist/{state-OsdDJvdj.mjs → state-C2cBU9iK.mjs} +1 -1
- package/dist/{stream-Bud9Os5V.mjs → stream-BNbkY3zI.mjs} +1 -1
- package/dist/{submit-BtP8she2.mjs → submit-pQNW7uWj.mjs} +1 -1
- package/dist/{tenant-CMwHa-tU.mjs → tenant-xkvdAutS.mjs} +1 -1
- package/dist/{token-validation-BYC7HTok.mjs → token-validation-5F2AbQCz.mjs} +1 -1
- package/dist/triggers-CYdZhJYr.mjs +2 -0
- package/dist/{turnstile-CP4nScaL.mjs → turnstile-BSIaunXn.mjs} +1 -1
- package/dist/{ui-BNoF0KpD.mjs → ui-CTo5OG9r.mjs} +1 -1
- package/dist/{url-info-Chs9h7Y-.mjs → url-info-Q7m7AVih.mjs} +1 -1
- package/dist/{url-normalization-XYxW5Gj0.mjs → url-normalization-Bs2m5jlD.mjs} +1 -1
- package/dist/{url-scanner-D4pYNlO-.mjs → url-scanner-CYmT3C99.mjs} +1 -1
- package/dist/{user-DtefniLc.mjs → user-Bay_0p3C.mjs} +1 -1
- package/dist/{vectorize-BeAY2g-7.mjs → vectorize-cP2OuB5N.mjs} +1 -1
- package/dist/{versions-dMW3bLVv.mjs → versions-D7F26fhH.mjs} +1 -1
- package/dist/{waiting-rooms-K78HeeTg.mjs → waiting-rooms-B5HR1-37.mjs} +1 -1
- package/dist/{web3-Dhw79l4S.mjs → web3-DqCXM4sx.mjs} +1 -1
- package/dist/{workers-l3zMNOU6.mjs → workers-Cu-A8AZc.mjs} +1 -1
- package/dist/{workers-builds-CuOAB3u4.mjs → workers-builds-CmCg27M-.mjs} +1 -1
- package/dist/{workflows-rb7RYBKP.mjs → workflows-DavS4SEh.mjs} +1 -1
- package/dist/{zaraz-CHecMYuo.mjs → zaraz-CKcVy5Xa.mjs} +1 -1
- package/dist/{zero-trust-DAZoa-Aj.mjs → zero-trust-BKVqb2yq.mjs} +1 -1
- package/dist/{zone-BnnqJwW-.mjs → zone-BOcuY4sU.mjs} +1 -1
- package/dist/{zones-DpI2YikF.mjs → zones-BR-9WaY7.mjs} +1 -1
- package/package.json +5 -4
- package/dist/ai-BzJg0RIX.mjs +0 -3
- package/dist/build-CWuStmDi.mjs +0 -2
- package/dist/chunk-2SIGYDH3-qXx_zE6v.mjs +0 -397
- package/dist/deploy-CVvkZFjR.mjs +0 -2
- package/dist/lib-Og5sB51C.mjs +0 -68
- package/dist/shared-Bod3-Exx.mjs +0 -990
- /package/dist/{schema-DCF4yEp_.mjs → schema-DAW-B7wT.mjs} +0 -0
- /package/dist/{tools-Dru4l8yh.mjs → tools-BpNGzfj2.mjs} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{O as e,w as t}from"./oauth-DBJ5GSFk.mjs";import{i as n,n as r}from"./auth-CZ0E51rF.mjs";import{t as i}from"./output-B6fBFRqe.mjs";import{n as a,t as o}from"./progress-O88q63Bk.mjs";import{t as s}from"./local-C6TLPAT6.mjs";import{n as c,t as l}from"./body-parser-BO6mfo_W.mjs";import{n as u,t as d}from"./input-validation-BwUR9z8e.mjs";import{n as f,r as p,t as m}from"./prompt-DTAWiEm2.mjs";import{t as h}from"./cli-types-CFw6Xygp.mjs";import{n as ee,t as te}from"./raw-fetch-DgezeshQ.mjs";function g(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`stream`,{type:`boolean`,description:`The stream 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 _={command:`chat-completions <id>`,describe:`Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses.`,builder:g,handler:async n=>{if(n.dryRun){a({command:`cf ai-search chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/chat/completions`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?l({ai_search_options:{cache:{cache_threshold:u(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:u(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:u(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:u(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:u(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},stream:n.stream}):c(n.body)});return}let d=await r(n),f=n.local?s:await t();if(n.accountId=f,n.body){let e=c(n.body);i(await o(`Creating`,async()=>d.aiSearch.chatCompletions({...e,account_id:f,name:n.name,id:n.id})),{successLabel:`Created`});return}let p=l({ai_search_options:{cache:{cache_threshold:u(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:u(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:u(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:u(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:u(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},stream:n.stream});i(await o(`Creating`,async()=>d.aiSearch.chatCompletions({...p,account_id:f,name:n.name,id:n.id})),{successLabel:`Created`})}};function v(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).positional(`id`,{type:`string`,description:`Unique ID for the new AI Search instance.`,demandOption:!0}).option(`ai-gateway-id`,{type:`string`,description:`The ai_gateway_id field`}).option(`ai-search-model`,{type:`string`,description:`The ai_search_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`cache`,{type:`boolean`,description:`The cache field`,default:!0}).option(`cache-threshold`,{type:`string`,description:`The cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`],default:`close_enough`}).option(`chunk`,{type:`boolean`,description:`The chunk field`,default:!0}).option(`chunk-overlap`,{type:`number`,description:`The chunk_overlap field`,default:10}).option(`chunk-size`,{type:`number`,description:`The chunk_size field`}).option(`embedding-model`,{type:`string`,description:`The embedding_model field`,choices:[`@cf/qwen/qwen3-embedding-0.6b`,`@cf/qwen/qwen3-vl-embedding-2b`,`@cf/baai/bge-m3`,`@cf/baai/bge-large-en-v1.5`,`@cf/google/embeddinggemma-300m`,`google-ai-studio/gemini-embedding-001`,`google-ai-studio/gemini-embedding-2-preview`,`google-ai-studio/gemini-embedding-2`,`openai/text-embedding-3-small`,`openai/text-embedding-3-large`]}).option(`fusion-method`,{type:`string`,description:`The fusion_method field`,choices:[`max`,`rrf`],default:`rrf`}).option(`hybrid-search-enabled`,{type:`boolean`,description:`Deprecated — use index_method instead.`,default:!1}).option(`index-method-keyword`,{type:`boolean`,description:`Enable keyword (BM25) storage backend.`}).option(`index-method-vector`,{type:`boolean`,description:`Enable vector (embedding) storage backend.`}).option(`indexing-options-keyword-tokenizer`,{type:`string`,description:`Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter.`,choices:[`porter`,`trigram`],default:`porter`}).option(`max-num-results`,{type:`number`,description:`The max_num_results field`,default:10}).option(`metadata-created-from-aisearch-wizard`,{type:`boolean`,description:`The metadata.created_from_aisearch_wizard field`}).option(`metadata-worker-domain`,{type:`string`,description:`The metadata.worker_domain field`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`,default:!1}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-default-domain-enabled`,{type:`boolean`,description:`When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.`,default:!0}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`,default:!1}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`,default:`Finds exactly what you're looking for`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`,default:!1}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`,default:!1}).option(`reranking`,{type:`boolean`,description:`The reranking field`,default:!1}).option(`reranking-model`,{type:`string`,description:`The reranking_model field`,choices:[`@cf/baai/bge-reranker-base`]}).option(`retrieval-options-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'.`,choices:[`and`,`or`]}).option(`rewrite-model`,{type:`string`,description:`The rewrite_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`,default:!1}).option(`score-threshold`,{type:`number`,description:`The score_threshold field`,default:.4}).option(`source`,{type:`string`,description:`The source field`}).option(`source-params-exclude-items`,{type:`string`,array:!0,description:`List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-include-items`,{type:`string`,array:!0,description:`List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-prefix`,{type:`string`,description:`The source_params.prefix field`}).option(`source-params-r2-jurisdiction`,{type:`string`,description:`The source_params.r2_jurisdiction field`,default:`default`}).option(`source-params-web-crawler-discover-options-depth`,{type:`number`,description:`Maximum link-follow depth from the seed URL.`,default:5}).option(`source-params-web-crawler-discover-options-include-external-links`,{type:`boolean`,description:"Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own.",default:!1}).option(`source-params-web-crawler-discover-options-include-subdomains`,{type:`boolean`,description:`Follow links to subdomains of the source host.`,default:!1}).option(`source-params-web-crawler-discover-options-limit`,{type:`number`,description:`Maximum number of pages to crawl (1-100000).`,default:1e5}).option(`source-params-web-crawler-discover-options-max-age`,{type:`number`,description:`Maximum content age in seconds to accept (0–604800).`,default:86400}).option(`source-params-web-crawler-discover-options-source`,{type:`string`,description:`Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both.`,choices:[`all`,`sitemaps`,`links`],default:`all`}).option(`source-params-web-crawler-parse-options-include-images`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.include_images field`,default:!1}).option(`source-params-web-crawler-parse-options-specific-sitemaps`,{type:`string`,array:!0,description:`List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.`}).option(`source-params-web-crawler-parse-options-use-browser-rendering`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.use_browser_rendering field`,default:!0}).option(`source-params-web-crawler-parse-type`,{type:`string`,description:`How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account.`,choices:[`sitemap`,`discover`],default:`sitemap`}).option(`token-id`,{type:`string`,description:`The token_id field`}).option(`type`,{type:`string`,description:`The type field`,choices:[`r2`,`web-crawler`]}).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([`index-method-keyword`,`index-method-vector`].some(t=>e[t]!==void 0)){let t=[`index-method-keyword`,`index-method-vector`].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 --index_method-* flag is set`)}return!0})}const y={command:`create <name> <id>`,describe:`Create a new AI Search instance with the given configuration.`,builder:v,handler:async n=>{if(n.dryRun){a({command:`cf ai-search create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances`,pathParams:{name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?l({ai_gateway_id:u(n[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:u(n[`ai-search-model`],`ai-search-model`,`text`),cache:n.cache,cache_threshold:u(n[`cache-threshold`],`cache-threshold`,`text`),chunk:n.chunk,chunk_overlap:n[`chunk-overlap`],chunk_size:n[`chunk-size`],embedding_model:u(n[`embedding-model`],`embedding-model`,`text`),fusion_method:u(n[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:n[`hybrid-search-enabled`],index_method:{keyword:n[`index-method-keyword`],vector:n[`index-method-vector`]},indexing_options:{keyword_tokenizer:u(n[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:n[`max-num-results`],metadata:{created_from_aisearch_wizard:n[`metadata-created-from-aisearch-wizard`],worker_domain:u(n[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],default_domain_enabled:n[`public-endpoint-params-default-domain-enabled`],enabled:n[`public-endpoint-params-enabled`],mcp:{description:u(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:u(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},reranking:n.reranking,reranking_model:u(n[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:u(n[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:u(n[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:n[`rewrite-query`],score_threshold:n[`score-threshold`],source:u(n.source,`source`,`text`),source_params:{exclude_items:n[`source-params-exclude-items`],include_items:n[`source-params-include-items`],prefix:u(n[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:u(n[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:n[`source-params-web-crawler-discover-options-depth`],include_external_links:n[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:n[`source-params-web-crawler-discover-options-include-subdomains`],limit:n[`source-params-web-crawler-discover-options-limit`],max_age:n[`source-params-web-crawler-discover-options-max-age`],source:u(n[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:n[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:n[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:n[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:u(n[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:u(n[`token-id`],`token-id`,`text`),type:u(n.type,`type`,`text`),id:n.id}):c(n.body)});return}let d=await r(n),f=n.local?s:await t();if(n.accountId=f,n.body){let e=c(n.body);i(await o(`Creating`,async()=>d.aiSearch.create({...e,account_id:f,name:n.name})),{successLabel:`Created`});return}let p=l({ai_gateway_id:u(n[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:u(n[`ai-search-model`],`ai-search-model`,`text`),cache:n.cache,cache_threshold:u(n[`cache-threshold`],`cache-threshold`,`text`),chunk:n.chunk,chunk_overlap:n[`chunk-overlap`],chunk_size:n[`chunk-size`],embedding_model:u(n[`embedding-model`],`embedding-model`,`text`),fusion_method:u(n[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:n[`hybrid-search-enabled`],index_method:{keyword:n[`index-method-keyword`],vector:n[`index-method-vector`]},indexing_options:{keyword_tokenizer:u(n[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:n[`max-num-results`],metadata:{created_from_aisearch_wizard:n[`metadata-created-from-aisearch-wizard`],worker_domain:u(n[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],default_domain_enabled:n[`public-endpoint-params-default-domain-enabled`],enabled:n[`public-endpoint-params-enabled`],mcp:{description:u(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:u(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},reranking:n.reranking,reranking_model:u(n[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:u(n[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:u(n[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:n[`rewrite-query`],score_threshold:n[`score-threshold`],source:u(n.source,`source`,`text`),source_params:{exclude_items:n[`source-params-exclude-items`],include_items:n[`source-params-include-items`],prefix:u(n[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:u(n[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:n[`source-params-web-crawler-discover-options-depth`],include_external_links:n[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:n[`source-params-web-crawler-discover-options-include-subdomains`],limit:n[`source-params-web-crawler-discover-options-limit`],max_age:n[`source-params-web-crawler-discover-options-max-age`],source:u(n[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:n[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:n[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:n[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:u(n[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:u(n[`token-id`],`token-id`,`text`),type:u(n.type,`type`,`text`),id:n.id});i(await o(`Creating`,async()=>d.aiSearch.create({...p,account_id:f,name:n.name})),{successLabel:`Created`})}};function b(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this 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 x={command:`delete <id>`,describe:`Permanently delete an AI Search instance and all its indexed data.`,builder:b,handler:async n=>{if(n.dryRun){a({command:`cf ai-search delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t();if(n.accountId=l,!await m({force:!!n.force,message:`This operation permanently deletes the AI Search instance and all its indexed data.`})){process.stderr.write(`Aborted.
|
|
2
|
+
import{O as e,w as t}from"./oauth-DC9g9uK_.mjs";import{i as n,n as r}from"./auth-B1CY5zpC.mjs";import{t as i}from"./output-B6fBFRqe.mjs";import{n as a,t as o}from"./progress-BLQ2xXwD.mjs";import{t as s}from"./local-C6TLPAT6.mjs";import{n as c,t as l}from"./body-parser-BO6mfo_W.mjs";import{n as u,t as d}from"./input-validation-BwUR9z8e.mjs";import{n as f,r as p,t as m}from"./prompt-DcfYBioA.mjs";import{t as h}from"./cli-types-CFw6Xygp.mjs";import{n as ee,t as te}from"./raw-fetch-CeW1mW_u.mjs";function g(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`stream`,{type:`boolean`,description:`The stream 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 _={command:`chat-completions <id>`,describe:`Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses.`,builder:g,handler:async n=>{if(n.dryRun){a({command:`cf ai-search chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/chat/completions`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?l({ai_search_options:{cache:{cache_threshold:u(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:u(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:u(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:u(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:u(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},stream:n.stream}):c(n.body)});return}let d=await r(n),f=n.local?s:await t();if(n.accountId=f,n.body){let e=c(n.body);i(await o(`Creating`,async()=>d.aiSearch.chatCompletions({...e,account_id:f,name:n.name,id:n.id})),{successLabel:`Created`});return}let p=l({ai_search_options:{cache:{cache_threshold:u(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:u(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:u(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:u(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:u(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},stream:n.stream});i(await o(`Creating`,async()=>d.aiSearch.chatCompletions({...p,account_id:f,name:n.name,id:n.id})),{successLabel:`Created`})}};function v(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).positional(`id`,{type:`string`,description:`Unique ID for the new AI Search instance.`,demandOption:!0}).option(`ai-gateway-id`,{type:`string`,description:`The ai_gateway_id field`}).option(`ai-search-model`,{type:`string`,description:`The ai_search_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`cache`,{type:`boolean`,description:`The cache field`,default:!0}).option(`cache-threshold`,{type:`string`,description:`The cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`],default:`close_enough`}).option(`chunk`,{type:`boolean`,description:`The chunk field`,default:!0}).option(`chunk-overlap`,{type:`number`,description:`The chunk_overlap field`,default:10}).option(`chunk-size`,{type:`number`,description:`The chunk_size field`}).option(`embedding-model`,{type:`string`,description:`The embedding_model field`,choices:[`@cf/qwen/qwen3-embedding-0.6b`,`@cf/qwen/qwen3-vl-embedding-2b`,`@cf/baai/bge-m3`,`@cf/baai/bge-large-en-v1.5`,`@cf/google/embeddinggemma-300m`,`google-ai-studio/gemini-embedding-001`,`google-ai-studio/gemini-embedding-2-preview`,`google-ai-studio/gemini-embedding-2`,`openai/text-embedding-3-small`,`openai/text-embedding-3-large`]}).option(`fusion-method`,{type:`string`,description:`The fusion_method field`,choices:[`max`,`rrf`],default:`rrf`}).option(`hybrid-search-enabled`,{type:`boolean`,description:`Deprecated — use index_method instead.`,default:!1}).option(`index-method-keyword`,{type:`boolean`,description:`Enable keyword (BM25) storage backend.`}).option(`index-method-vector`,{type:`boolean`,description:`Enable vector (embedding) storage backend.`}).option(`indexing-options-keyword-tokenizer`,{type:`string`,description:`Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter.`,choices:[`porter`,`trigram`],default:`porter`}).option(`max-num-results`,{type:`number`,description:`The max_num_results field`,default:10}).option(`metadata-created-from-aisearch-wizard`,{type:`boolean`,description:`The metadata.created_from_aisearch_wizard field`}).option(`metadata-worker-domain`,{type:`string`,description:`The metadata.worker_domain field`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`,default:!1}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-default-domain-enabled`,{type:`boolean`,description:`When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.`,default:!0}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`,default:!1}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`,default:`Finds exactly what you're looking for`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`,default:!1}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`,default:!1}).option(`reranking`,{type:`boolean`,description:`The reranking field`,default:!1}).option(`reranking-model`,{type:`string`,description:`The reranking_model field`,choices:[`@cf/baai/bge-reranker-base`]}).option(`retrieval-options-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'.`,choices:[`and`,`or`]}).option(`rewrite-model`,{type:`string`,description:`The rewrite_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`,default:!1}).option(`score-threshold`,{type:`number`,description:`The score_threshold field`,default:.4}).option(`source`,{type:`string`,description:`The source field`}).option(`source-params-exclude-items`,{type:`string`,array:!0,description:`List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-include-items`,{type:`string`,array:!0,description:`List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-prefix`,{type:`string`,description:`The source_params.prefix field`}).option(`source-params-r2-jurisdiction`,{type:`string`,description:`The source_params.r2_jurisdiction field`,default:`default`}).option(`source-params-web-crawler-discover-options-depth`,{type:`number`,description:`Maximum link-follow depth from the seed URL.`,default:5}).option(`source-params-web-crawler-discover-options-include-external-links`,{type:`boolean`,description:"Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own.",default:!1}).option(`source-params-web-crawler-discover-options-include-subdomains`,{type:`boolean`,description:`Follow links to subdomains of the source host.`,default:!1}).option(`source-params-web-crawler-discover-options-limit`,{type:`number`,description:`Maximum number of pages to crawl (1-100000).`,default:1e5}).option(`source-params-web-crawler-discover-options-max-age`,{type:`number`,description:`Maximum content age in seconds to accept (0–604800).`,default:86400}).option(`source-params-web-crawler-discover-options-source`,{type:`string`,description:`Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both.`,choices:[`all`,`sitemaps`,`links`],default:`all`}).option(`source-params-web-crawler-parse-options-include-images`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.include_images field`,default:!1}).option(`source-params-web-crawler-parse-options-specific-sitemaps`,{type:`string`,array:!0,description:`List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.`}).option(`source-params-web-crawler-parse-options-use-browser-rendering`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.use_browser_rendering field`,default:!0}).option(`source-params-web-crawler-parse-type`,{type:`string`,description:`How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account.`,choices:[`sitemap`,`discover`],default:`sitemap`}).option(`token-id`,{type:`string`,description:`The token_id field`}).option(`type`,{type:`string`,description:`The type field`,choices:[`r2`,`web-crawler`]}).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([`index-method-keyword`,`index-method-vector`].some(t=>e[t]!==void 0)){let t=[`index-method-keyword`,`index-method-vector`].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 --index_method-* flag is set`)}return!0})}const y={command:`create <name> <id>`,describe:`Create a new AI Search instance with the given configuration.`,builder:v,handler:async n=>{if(n.dryRun){a({command:`cf ai-search create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances`,pathParams:{name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?l({ai_gateway_id:u(n[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:u(n[`ai-search-model`],`ai-search-model`,`text`),cache:n.cache,cache_threshold:u(n[`cache-threshold`],`cache-threshold`,`text`),chunk:n.chunk,chunk_overlap:n[`chunk-overlap`],chunk_size:n[`chunk-size`],embedding_model:u(n[`embedding-model`],`embedding-model`,`text`),fusion_method:u(n[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:n[`hybrid-search-enabled`],index_method:{keyword:n[`index-method-keyword`],vector:n[`index-method-vector`]},indexing_options:{keyword_tokenizer:u(n[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:n[`max-num-results`],metadata:{created_from_aisearch_wizard:n[`metadata-created-from-aisearch-wizard`],worker_domain:u(n[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],default_domain_enabled:n[`public-endpoint-params-default-domain-enabled`],enabled:n[`public-endpoint-params-enabled`],mcp:{description:u(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:u(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},reranking:n.reranking,reranking_model:u(n[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:u(n[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:u(n[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:n[`rewrite-query`],score_threshold:n[`score-threshold`],source:u(n.source,`source`,`text`),source_params:{exclude_items:n[`source-params-exclude-items`],include_items:n[`source-params-include-items`],prefix:u(n[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:u(n[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:n[`source-params-web-crawler-discover-options-depth`],include_external_links:n[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:n[`source-params-web-crawler-discover-options-include-subdomains`],limit:n[`source-params-web-crawler-discover-options-limit`],max_age:n[`source-params-web-crawler-discover-options-max-age`],source:u(n[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:n[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:n[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:n[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:u(n[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:u(n[`token-id`],`token-id`,`text`),type:u(n.type,`type`,`text`),id:n.id}):c(n.body)});return}let d=await r(n),f=n.local?s:await t();if(n.accountId=f,n.body){let e=c(n.body);i(await o(`Creating`,async()=>d.aiSearch.create({...e,account_id:f,name:n.name})),{successLabel:`Created`});return}let p=l({ai_gateway_id:u(n[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:u(n[`ai-search-model`],`ai-search-model`,`text`),cache:n.cache,cache_threshold:u(n[`cache-threshold`],`cache-threshold`,`text`),chunk:n.chunk,chunk_overlap:n[`chunk-overlap`],chunk_size:n[`chunk-size`],embedding_model:u(n[`embedding-model`],`embedding-model`,`text`),fusion_method:u(n[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:n[`hybrid-search-enabled`],index_method:{keyword:n[`index-method-keyword`],vector:n[`index-method-vector`]},indexing_options:{keyword_tokenizer:u(n[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:n[`max-num-results`],metadata:{created_from_aisearch_wizard:n[`metadata-created-from-aisearch-wizard`],worker_domain:u(n[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],default_domain_enabled:n[`public-endpoint-params-default-domain-enabled`],enabled:n[`public-endpoint-params-enabled`],mcp:{description:u(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:u(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},reranking:n.reranking,reranking_model:u(n[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:u(n[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:u(n[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:n[`rewrite-query`],score_threshold:n[`score-threshold`],source:u(n.source,`source`,`text`),source_params:{exclude_items:n[`source-params-exclude-items`],include_items:n[`source-params-include-items`],prefix:u(n[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:u(n[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:n[`source-params-web-crawler-discover-options-depth`],include_external_links:n[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:n[`source-params-web-crawler-discover-options-include-subdomains`],limit:n[`source-params-web-crawler-discover-options-limit`],max_age:n[`source-params-web-crawler-discover-options-max-age`],source:u(n[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:n[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:n[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:n[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:u(n[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:u(n[`token-id`],`token-id`,`text`),type:u(n.type,`type`,`text`),id:n.id});i(await o(`Creating`,async()=>d.aiSearch.create({...p,account_id:f,name:n.name})),{successLabel:`Created`})}};function b(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this 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 x={command:`delete <id>`,describe:`Permanently delete an AI Search instance and all its indexed data.`,builder:b,handler:async n=>{if(n.dryRun){a({command:`cf ai-search delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t();if(n.accountId=l,!await m({force:!!n.force,message:`This operation permanently deletes the AI Search instance and all its indexed data.`})){process.stderr.write(`Aborted.
|
|
3
3
|
`);return}i(await o(`Deleting`,async()=>c.aiSearch.delete({account_id:l,name:n.name,id:n.id})),{successLabel:`Deleted`})}};function S(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const C={command:`get <id>`,describe:`Retrieve the configuration and status of an AI Search instance.`,builder:S,handler:async n=>{if(n.dryRun){a({command:`cf ai-search get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t();n.accountId=l,i(await o(`Loading`,async()=>c.aiSearch.get({account_id:l,name:n.name,id:n.id})),{successLabel:`Loaded`})}};function w(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`limit`,{type:`number`,description:`Limit`}).option(`offset`,{type:`number`,description:`Offset`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`chunks <item-id>`,describe:`Lists chunks for a specific item in an AI Search instance, including their text content.`,builder:w,handler:async n=>{let c={limit:n.limit,offset:n.offset};if(n.dryRun){a({command:`cf ai-search items chunks`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}/chunks`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t();n.accountId=u,i(await o(`Loading`,async()=>l.aiSearch.items.chunks({account_id:u,name:n.name,id:n.id,item_id:n[`item-id`],...c})),{successLabel:`Loaded`})}};function E(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const D={command:`delete <item-id>`,describe:`Deletes a file from a managed AI Search instance and triggers a reindex.`,builder:E,handler:async n=>{if(n.dryRun){a({command:`cf ai-search items delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t();if(n.accountId=l,!await m({force:!!n.force})){process.stderr.write(`Aborted.
|
|
4
4
|
`);return}i(await o(`Deleting`,async()=>c.aiSearch.items.delete({account_id:l,name:n.name,id:n.id,item_id:n[`item-id`]})),{successLabel:`Deleted`})}};function O(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const k={command:`download <item-id>`,describe:`Downloads the raw file content for a specific item from the managed AI Search instance storage.`,builder:O,handler:async n=>{if(n.dryRun){a({command:`cf ai-search items download`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}/download`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},bodyKind:`none`});return}await r(n);let i=n.local?s:await t();n.accountId=i;let c=await o(`Loading`,async()=>te(`/accounts/${i}/ai-search/namespaces/${encodeURIComponent(String(n.name))}/instances/${encodeURIComponent(String(n.id))}/items/${encodeURIComponent(String(n[`item-id`]))}/download`,{method:`GET`,localEndpoint:n.local?n.localEndpoint:void 0}));ee(n.text===!0?c.toString(`utf-8`):c)}};function A(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const j={command:`get <item-id>`,describe:`Retrieves a specific indexed item from an AI Search instance.`,builder:A,handler:async n=>{if(n.dryRun){a({command:`cf ai-search items get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t();n.accountId=l,i(await o(`Loading`,async()=>c.aiSearch.items.get({account_id:l,name:n.name,id:n.id,item_id:n[`item-id`]})),{successLabel:`Loaded`})}};function M(e){return e.option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`search`,{type:`string`,description:`Search`}).option(`sort-by`,{type:`string`,description:`Sort order for items. "status" (default) sorts by status priority then last_seen_at. "modified_at" sorts by file modification time (most recent first), falling back to created_at.`,choices:[`status`,`modified_at`]}).option(`status`,{type:`string`,description:`Status`,choices:[`queued`,`running`,`completed`,`error`,`skipped`,`outdated`]}).option(`source`,{type:`string`,description:`Filter items by source_id. Use "builtin" for uploaded files, or a source identifier like "web-crawler:https://example.com".`}).option(`metadata-filter`,{type:`string`,description:`JSON-encoded metadata filter using Vectorize filter syntax. Examples: {"folder":"reports/"}, {"timestamp":{"$gte":1700000000000}}, {"folder":{"$in":["docs/","reports/"]}}`}).option(`item-id`,{type:`string`,description:`Filter items by their unique ID. Returns at most one item.`}).option(`key`,{type:`string`,description:"Filter items by their exact key (object key / filename). Keys are unique per source, so combine with `source` to disambiguate across data sources."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const N={command:`list`,describe:`Lists indexed items in an AI Search instance.`,builder:h(M),handler:async n=>{let c={page:n.page,per_page:n[`per-page`],search:n.search,sort_by:n[`sort-by`],status:n.status,source:n.source,metadata_filter:n[`metadata-filter`],item_id:n[`item-id`],key:n.key};if(n.dryRun){a({command:`cf ai-search items list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items`,pathParams:{id:String(n.id??``),name:String(n.name??``)},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t();n.accountId=u,i(await o(`Loading`,async()=>l.aiSearch.items.list({account_id:u,name:n.name,id:n.id,...c})),{successLabel:`Loaded`})}};function P(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`limit`,{type:`number`,description:`Limit`}).option(`cursor`,{type:`string`,description:`Cursor`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const F={command:`logs <item-id>`,describe:`Lists processing logs for a specific item in an AI Search instance.`,builder:P,handler:async n=>{let c={limit:n.limit,cursor:n.cursor};if(n.dryRun){a({command:`cf ai-search items logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}/logs`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t();n.accountId=u,i(await o(`Loading`,async()=>l.aiSearch.items.logs({account_id:u,name:n.name,id:n.id,item_id:n[`item-id`],...c})),{successLabel:`Loaded`})}};function I(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`next-action`,{type:`string`,description:`The next_action field`,choices:[`INDEX`]}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."}).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 L={command:`sync <item-id>`,describe:`Syncs an item to an AI Search instance index.`,builder:I,handler:async n=>{if(n.dryRun){a({command:`cf ai-search items sync`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?l({next_action:u(n[`next-action`],`next-action`,`text`),wait_for_completion:n[`wait-for-completion`]}):c(n.body)});return}let d=await r(n),p=n.local?s:await t();if(n.accountId=p,n.body){let e=c(n.body);i(await o(`Updating`,async()=>d.aiSearch.items.sync({...e,account_id:p,name:n.name,id:n.id,item_id:n[`item-id`]})),{successLabel:`Updated`});return}n[`next-action`]===void 0&&(n[`next-action`]=await f(`next-action`,`The next_action field`,[`INDEX`]));let m=l({next_action:u(n[`next-action`],`next-action`,`text`),wait_for_completion:n[`wait-for-completion`]});i(await o(`Updating`,async()=>d.aiSearch.items.sync({...m,account_id:p,name:n.name,id:n.id,item_id:n[`item-id`]})),{successLabel:`Updated`})}};function R(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}).option(`metadata`,{type:`string`,description:`JSON string of custom metadata key-value pairs.`}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."})}const z={command:`upload <id>`,describe:`Uploads a file to a managed AI Search instance via multipart/form-data.`,builder:R,handler:async c=>{if(c.dryRun){a({command:`cf ai-search items upload`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${c.name==null?`<name>`:encodeURIComponent(String(c.name))}/instances/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}/items`,pathParams:{id:String(c.id??``),name:String(c.name??``)},bodyKind:`multipart`,body:{body:c.body,file:c.file,metadata:c.metadata,"wait-for-completion":c[`wait-for-completion`]}});return}let l=await r(c),f=c.local?s:await t();if(c.accountId=f,c.file!==void 0||c.body!==void 0||c.metadata!==void 0||c[`wait-for-completion`]!==void 0){let e=new FormData;if(c.file){let t=d(c.file);e.append(`file`,new Blob([t]),c.file.split(/[\\/]/).filter(Boolean).pop())}else c.body!==void 0&&e.append(`file`,c.body);c.metadata!==void 0&&e.append(`metadata`,String(u(c.metadata,`metadata`,`text`)??``)),c[`wait-for-completion`]!==void 0&&e.append(`wait_for_completion`,String(c[`wait-for-completion`])),i(await o(`Creating`,async()=>n(l,`POST`,`/accounts/${f}/ai-search/namespaces/${encodeURIComponent(String(c.name))}/instances/${encodeURIComponent(String(c.id))}/items`,{body:e})),{successLabel:`Created`});return}if(c.body){let e=u(c.body,`body`,`binary`);i(await o(`Creating`,async()=>n(l,`POST`,`/accounts/${f}/ai-search/namespaces/${encodeURIComponent(String(c.name))}/instances/${encodeURIComponent(String(c.id))}/items`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(c.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function B(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`key`,{type:`string`,description:`Item key / filename. Must not exceed 128 characters.`}).option(`next-action`,{type:`string`,description:`The next_action field`,choices:[`INDEX`]}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."}).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:`upsert <id>`,describe:`Creates or updates an indexed item in an AI Search instance.`,builder:B,handler:async n=>{if(n.dryRun){a({command:`cf ai-search items upsert`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?l({key:u(n.key,`key`,`text`),next_action:u(n[`next-action`],`next-action`,`text`),wait_for_completion:n[`wait-for-completion`]}):c(n.body)});return}let d=await r(n),m=n.local?s:await t();if(n.accountId=m,n.body){let e=c(n.body);i(await o(`Updating`,async()=>d.aiSearch.items.upsert({...e,account_id:m,name:n.name,id:n.id})),{successLabel:`Updated`});return}n.key===void 0&&(n.key=await p(`key`,`Item key / filename. Must not exceed 128 characters.`)),n[`next-action`]===void 0&&(n[`next-action`]=await f(`next-action`,`The next_action field`,[`INDEX`]));let h=l({key:u(n.key,`key`,`text`),next_action:u(n[`next-action`],`next-action`,`text`),wait_for_completion:n[`wait-for-completion`]});i(await o(`Updating`,async()=>d.aiSearch.items.upsert({...h,account_id:m,name:n.name,id:n.id})),{successLabel:`Updated`})}},H={command:`items`,describe:`Operations for items`,builder:e=>e.command(T).command(D).command(k).command(j).command(N).command(F).command(L).command(z).command(V).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function U(e){return e.positional(`job-id`,{type:`string`,description:`Indexing job ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`action`,{type:`string`,description:`The action field`,choices:[`cancel`]}).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:`cancel <job-id>`,describe:`Cancel an in-progress indexing job for an AI Search instance.`,builder:U,handler:async n=>{if(n.dryRun){a({command:`cf ai-search jobs cancel`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/jobs/${n[`job-id`]==null?`<job-id>`:encodeURIComponent(String(n[`job-id`]))}`,pathParams:{id:String(n.id??``),"job-id":String(n[`job-id`]??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?l({action:u(n.action,`action`,`text`)}):c(n.body)});return}let d=await r(n),p=n.local?s:await t();if(n.accountId=p,!await m({force:!!n.force,message:`This operation cancels the running indexing job.`})){process.stderr.write(`Aborted.
|
|
5
5
|
`);return}if(n.body){let e=c(n.body);i(await o(`Deleting`,async()=>d.aiSearch.jobs.cancel({...e,account_id:p,name:n.name,id:n.id,job_id:n[`job-id`]})),{successLabel:`Deleted`});return}n.action===void 0&&(n.action=await f(`action`,`The action field`,[`cancel`]));let h=l({action:u(n.action,`action`,`text`)});i(await o(`Deleting`,async()=>d.aiSearch.jobs.cancel({...h,account_id:p,name:n.name,id:n.id,job_id:n[`job-id`]})),{successLabel:`Deleted`})}};function G(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`description`,{type:`string`,description:`The description 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 K={command:`create <id>`,describe:`Creates a new indexing job for an AI Search instance.`,builder:G,handler:async n=>{if(n.dryRun){a({command:`cf ai-search jobs create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/jobs`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?l({description:u(n.description,`description`,`text`)}):c(n.body)});return}let d=await r(n),f=n.local?s:await t();if(n.accountId=f,n.body){let e=c(n.body);i(await o(`Creating`,async()=>d.aiSearch.jobs.create({...e,account_id:f,name:n.name,id:n.id})),{successLabel:`Created`});return}let p=l({description:u(n.description,`description`,`text`)});i(await o(`Creating`,async()=>d.aiSearch.jobs.create({...p,account_id:f,name:n.name,id:n.id})),{successLabel:`Created`})}};function q(e){return e.positional(`job-id`,{type:`string`,description:`Indexing job ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const J={command:`get <job-id>`,describe:`Retrieves details for a specific AI Search indexing job.`,builder:q,handler:async n=>{if(n.dryRun){a({command:`cf ai-search jobs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/jobs/${n[`job-id`]==null?`<job-id>`:encodeURIComponent(String(n[`job-id`]))}`,pathParams:{id:String(n.id??``),"job-id":String(n[`job-id`]??``),name:String(n.name??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t();n.accountId=l,i(await o(`Loading`,async()=>c.aiSearch.jobs.get({account_id:l,name:n.name,id:n.id,job_id:n[`job-id`]})),{successLabel:`Loaded`})}};function Y(e){return e.option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const X={command:`list`,describe:`Lists indexing jobs for an AI Search instance.`,builder:Y,handler:async n=>{let c={page:n.page,per_page:n[`per-page`]};if(n.dryRun){a({command:`cf ai-search jobs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/jobs`,pathParams:{id:String(n.id??``),name:String(n.name??``)},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t();n.accountId=u,i(await o(`Loading`,async()=>l.aiSearch.jobs.list({account_id:u,name:n.name,id:n.id,...c})),{successLabel:`Loaded`})}};function Z(e){return e.positional(`job-id`,{type:`string`,description:`Indexing job ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Q={command:`logs <job-id>`,describe:`Lists log entries for an AI Search indexing job.`,builder:Z,handler:async n=>{let c={page:n.page,per_page:n[`per-page`]};if(n.dryRun){a({command:`cf ai-search jobs logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/jobs/${n[`job-id`]==null?`<job-id>`:encodeURIComponent(String(n[`job-id`]))}/logs`,pathParams:{id:String(n.id??``),"job-id":String(n[`job-id`]??``),name:String(n.name??``)},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t();n.accountId=u,i(await o(`Loading`,async()=>l.aiSearch.jobs.logs({account_id:u,name:n.name,id:n.id,job_id:n[`job-id`],...c})),{successLabel:`Loaded`})}},ne={command:`jobs`,describe:`Operations for jobs`,builder:e=>e.command(W).command(K).command(J).command(X).command(Q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function re(e){return e.option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page number (1-indexed).`}).option(`per-page`,{type:`number`,description:`Number of results per page.`}).option(`search`,{type:`string`,description:`Filter instances whose id contains this string (case-insensitive).`}).option(`order-by`,{type:`string`,description:`Field to order results by.`,choices:[`created_at`]}).option(`order-by-direction`,{type:`string`,description:`Order direction.`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ie={command:`list`,describe:`List all AI Search instances in the account.`,builder:h(re),handler:async n=>{let c={page:n.page,per_page:n[`per-page`],search:n.search,order_by:n[`order-by`],order_by_direction:n[`order-by-direction`]};if(n.dryRun){a({command:`cf ai-search list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances`,pathParams:{name:String(n.name??``)},query:c,bodyKind:`none`});return}let l=await r(n),u=n.local?s:await t();n.accountId=u,i(await o(`Loading`,async()=>l.aiSearch.list({account_id:u,name:n.name,...c})),{successLabel:`Loaded`})}};function ae(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace currently containing the instance.`,demandOption:!0}).option(`destination-namespace`,{type:`string`,description:`Target namespace to move the instance into.`}).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:`move <id>`,describe:`Moves an instance from its current namespace to the specified target namespace. Use 'default' with --destination-namespace to move the instance back to the default namespace. Fails with 400 if the target namespace already has an instance with the same id (ids must be unique within a namespace — the same id can exist in different namespaces).`,builder:ae,handler:async n=>{if(n.dryRun){a({command:`cf ai-search move`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{name:String(n.name??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?l({new_namespace:u(n[`destination-namespace`],`destination-namespace`,`text`)}):c(n.body)});return}let d=await r(n),f=n.local?s:await t();if(n.accountId=f,n.body){let e=c(n.body);i(await o(`Updating`,async()=>d.aiSearch.move({...e,account_id:f,name:n.name,id:n.id})),{successLabel:`Updated`});return}n[`destination-namespace`]===void 0&&(n[`destination-namespace`]=await p(`destination-namespace`,`Target namespace to move the instance into.`));let m=l({new_namespace:u(n[`destination-namespace`],`destination-namespace`,`text`)});i(await o(`Updating`,async()=>d.aiSearch.move({...m,account_id:f,name:n.name,id:n.id})),{successLabel:`Updated`})}};function se(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-instance-ids`,{type:`string`,array:!0,description:`The ai_search_options.instance_ids field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`stream`,{type:`boolean`,description:`The stream 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 ce={command:`multi-chat-completions <name>`,describe:`Performs a chat completion request against multiple AI Search instances in parallel, merging retrieved content as context for generating a response.`,builder:se,handler:async n=>{if(n.dryRun){a({command:`cf ai-search multi-chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/chat/completions`,pathParams:{name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?l({ai_search_options:{cache:{cache_threshold:u(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},instance_ids:n[`ai-search-options-instance-ids`],query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:u(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:u(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:u(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:u(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},stream:n.stream}):c(n.body)});return}let d=await r(n),f=n.local?s:await t();if(n.accountId=f,n.body){let e=c(n.body);i(await o(`Creating`,async()=>d.aiSearch.multiChatCompletions({...e,account_id:f,name:n.name})),{successLabel:`Created`});return}if(n[`ai-search-options-instance-ids`]===void 0)throw Error(`--ai-search-options-instance-ids is required (or pass --body with this field set).`);let p=l({ai_search_options:{cache:{cache_threshold:u(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},instance_ids:n[`ai-search-options-instance-ids`],query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:u(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:u(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:u(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:u(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},stream:n.stream});i(await o(`Creating`,async()=>d.aiSearch.multiChatCompletions({...p,account_id:f,name:n.name})),{successLabel:`Created`})}};function le(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).positional(`query`,{type:`string`,description:`Text to search for.`}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-instance-ids`,{type:`string`,array:!0,description:`The ai_search_options.instance_ids field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!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 ue={command:`multi-search <name> <query>`,describe:`Performs a semantic search query against multiple AI Search instances in parallel, merging the retrieved results into a single ranked response.`,builder:le,handler:async n=>{if(n.dryRun){a({command:`cf ai-search multi-search`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/search`,pathParams:{name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?l({ai_search_options:{cache:{cache_threshold:u(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},instance_ids:n[`ai-search-options-instance-ids`],query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:u(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:u(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:u(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:u(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},query:n.query}):c(n.body)});return}let d=await r(n),f=n.local?s:await t();if(n.accountId=f,n.body){let e=c(n.body);i(await o(`Creating`,async()=>d.aiSearch.multiSearch({...e,account_id:f,name:n.name})),{successLabel:`Created`});return}if(n[`ai-search-options-instance-ids`]===void 0)throw Error(`--ai-search-options-instance-ids is required (or pass --body with this field set).`);let p=l({ai_search_options:{cache:{cache_threshold:u(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},instance_ids:n[`ai-search-options-instance-ids`],query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:u(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:u(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:u(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:u(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},query:n.query});i(await o(`Creating`,async()=>d.aiSearch.multiSearch({...p,account_id:f,name:n.name})),{successLabel:`Created`})}};function de(e){return e.positional(`namespace`,{type:`string`,description:`Name for the new namespace.`,demandOption:!0}).option(`description`,{type:`string`,description:`Optional description for the namespace. Max 256 characters.`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`,default:!1}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-default-domain-enabled`,{type:`boolean`,description:`When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.`,default:!0}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`,default:!1}).option(`public-endpoint-params-instances-allowed`,{type:`string`,array:!0,description:`Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit.`}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`,default:`Finds exactly what you're looking for`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`,default:!1}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`,default:!1}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const fe={command:`create <namespace>`,describe:`Create a namespace for organizing AI Search instances.`,builder:de,handler:async n=>{if(n.dryRun){a({command:`cf ai-search namespace create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces`,pathParams:{},bodyKind:`json`,body:n.body===void 0?l({description:u(n.description,`description`,`text`),public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],default_domain_enabled:n[`public-endpoint-params-default-domain-enabled`],enabled:n[`public-endpoint-params-enabled`],instances_allowed:n[`public-endpoint-params-instances-allowed`],mcp:{description:u(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:u(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},name:n.namespace}):c(n.body)});return}let d=await r(n),f=n.local?s:await t();if(n.accountId=f,n.body){let e=c(n.body);i(await o(`Creating`,async()=>d.aiSearch.namespace.create({...e,account_id:f})),{successLabel:`Created`});return}let p=l({description:u(n.description,`description`,`text`),public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],default_domain_enabled:n[`public-endpoint-params-default-domain-enabled`],enabled:n[`public-endpoint-params-enabled`],instances_allowed:n[`public-endpoint-params-instances-allowed`],mcp:{description:u(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:u(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},name:n.namespace});i(await o(`Creating`,async()=>d.aiSearch.namespace.create({...p,account_id:f})),{successLabel:`Created`})}};function pe(e){return e.positional(`name`,{type:`string`,description:`Namespace to delete.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const me={command:`delete <name>`,describe:`Permanently delete a namespace. The namespace must be empty (no instances), and the default namespace cannot be deleted.`,builder:pe,handler:async n=>{if(n.dryRun){a({command:`cf ai-search namespace delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}`,pathParams:{name:String(n.name??``)},bodyKind:`none`});return}let c=await r(n),l=n.local?s:await t();if(n.accountId=l,!await m({force:!!n.force,message:`This operation permanently deletes the namespace.`})){process.stderr.write(`Aborted.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{O as e,w as t}from"./oauth-
|
|
2
|
+
import{O as e,w as t}from"./oauth-DC9g9uK_.mjs";import{n}from"./auth-B1CY5zpC.mjs";import{t as r}from"./output-B6fBFRqe.mjs";import{n as i,t as a}from"./progress-BLQ2xXwD.mjs";import{t as o}from"./local-C6TLPAT6.mjs";import{n as s,t as c}from"./body-parser-BO6mfo_W.mjs";import{n as l}from"./input-validation-BwUR9z8e.mjs";import{n as u,r as d,t as f}from"./prompt-DcfYBioA.mjs";function p(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const m={command:`list`,describe:`Gets a list of all alert types for which an account is eligible.`,builder:p,handler:async s=>{if(s.dryRun){i({command:`cf alerting available-alerts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/available_alerts`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();s.accountId=l,r(await a(`Loading`,async()=>c.alerting.availableAlerts.list({account_id:l})),{successLabel:`Loaded`})}},h={command:`available-alerts`,describe:`List the alert types available for your account based on enabled products`,builder:e=>e.command(m).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ee(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`get`,describe:`Get a list of all delivery mechanism types for which an account is eligible.`,builder:ee,handler:async s=>{if(s.dryRun){i({command:`cf alerting destinations eligible get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/destinations/eligible`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();s.accountId=l,r(await a(`Loading`,async()=>c.alerting.destinations.eligible.get({account_id:l})),{successLabel:`Loaded`})}},_={command:`eligible`,describe:`Delivery mechanisms for alerts — email, PagerDuty integrations, and webhook endpoints`,builder:e=>e.command(g).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function v(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`create`,describe:`Creates a new token for integrating with PagerDuty.`,builder:v,handler:async s=>{if(s.dryRun){i({command:`cf alerting destinations pagerduty create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/destinations/pagerduty/connect`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();s.accountId=l,r(await a(`Creating`,async()=>c.alerting.destinations.pagerduty.create({account_id:l})),{successLabel:`Created`})}};function b(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const x={command:`delete`,describe:`Deletes all the PagerDuty Services connected to the account.`,builder:b,handler:async s=>{if(s.dryRun){i({command:`cf alerting destinations pagerduty delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/destinations/pagerduty`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();if(s.accountId=l,!await f({force:!!s.force})){process.stderr.write(`Aborted.
|
|
3
3
|
`);return}r(await a(`Deleting`,async()=>c.alerting.destinations.pagerduty.delete({account_id:l})),{successLabel:`Deleted`})}};function S(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const C={command:`get`,describe:`Get a list of all configured PagerDuty services.`,builder:S,handler:async s=>{if(s.dryRun){i({command:`cf alerting destinations pagerduty get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/destinations/pagerduty`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();s.accountId=l,r(await a(`Loading`,async()=>c.alerting.destinations.pagerduty.get({account_id:l})),{successLabel:`Loaded`})}};function w(e){return e.positional(`token-id`,{type:`string`,description:`The token integration key`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`link <token-id>`,describe:`Links PagerDuty with the account using the integration token.`,builder:w,handler:async s=>{if(s.dryRun){i({command:`cf alerting destinations pagerduty link`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/destinations/pagerduty/connect/${s[`token-id`]==null?`<token-id>`:encodeURIComponent(String(s[`token-id`]))}`,pathParams:{"token-id":String(s[`token-id`]??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();s.accountId=l,r(await a(`Loading`,async()=>c.alerting.destinations.pagerduty.link({account_id:l,token_id:s[`token-id`]})),{successLabel:`Loaded`})}},E={command:`pagerduty`,describe:`Delivery mechanisms for alerts — email, PagerDuty integrations, and webhook endpoints`,builder:e=>e.command(y).command(x).command(C).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`name`,{type:`string`,description:`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`}).option(`secret`,{type:`string`,description:"Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body."}).option(`url`,{type:`string`,description:`The POST endpoint to call when dispatching a notification.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const O={command:`create`,describe:`Creates a new webhook destination.`,builder:D,handler:async u=>{if(u.dryRun){i({command:`cf alerting destinations webhooks create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/destinations/webhooks`,pathParams:{},bodyKind:`json`,body:u.body===void 0?c({name:l(u.name,`name`,`text`),secret:l(u.secret,`secret`,`text`),url:l(u.url,`url`,`text`)}):s(u.body)});return}let f=await n(u),p=u.local?o:await t();if(u.accountId=p,u.body){let e=s(u.body);r(await a(`Creating`,async()=>f.alerting.destinations.webhooks.create({...e,account_id:p})),{successLabel:`Created`});return}u.name===void 0&&(u.name=await d(`name`,`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`)),u.url===void 0&&(u.url=await d(`url`,`The POST endpoint to call when dispatching a notification.`));let m=c({name:l(u.name,`name`,`text`),secret:l(u.secret,`secret`,`text`),url:l(u.url,`url`,`text`)});r(await a(`Creating`,async()=>f.alerting.destinations.webhooks.create({...m,account_id:p})),{successLabel:`Created`})}};function k(e){return e.positional(`webhook-id`,{type:`string`,description:`The unique identifier of a webhook`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const A={command:`delete <webhook-id>`,describe:`Delete a configured webhook destination.`,builder:k,handler:async s=>{if(s.dryRun){i({command:`cf alerting destinations webhooks delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/destinations/webhooks/${s[`webhook-id`]==null?`<webhook-id>`:encodeURIComponent(String(s[`webhook-id`]))}`,pathParams:{"webhook-id":String(s[`webhook-id`]??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();if(s.accountId=l,!await f({force:!!s.force})){process.stderr.write(`Aborted.
|
|
4
4
|
`);return}r(await a(`Deleting`,async()=>c.alerting.destinations.webhooks.delete({account_id:l,webhook_id:s[`webhook-id`]})),{successLabel:`Deleted`})}};function j(e){return e.positional(`webhook-id`,{type:`string`,description:`The unique identifier of a webhook`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`get <webhook-id>`,describe:`Get details for a single webhooks destination.`,builder:j,handler:async s=>{if(s.dryRun){i({command:`cf alerting destinations webhooks get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/destinations/webhooks/${s[`webhook-id`]==null?`<webhook-id>`:encodeURIComponent(String(s[`webhook-id`]))}`,pathParams:{"webhook-id":String(s[`webhook-id`]??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();s.accountId=l,r(await a(`Loading`,async()=>c.alerting.destinations.webhooks.get({account_id:l,webhook_id:s[`webhook-id`]})),{successLabel:`Loaded`})}};function N(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`list`,describe:`Gets a list of all configured webhook destinations.`,builder:N,handler:async s=>{if(s.dryRun){i({command:`cf alerting destinations webhooks list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/destinations/webhooks`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();s.accountId=l,r(await a(`Loading`,async()=>c.alerting.destinations.webhooks.list({account_id:l})),{successLabel:`Loaded`})}};function F(e){return e.positional(`webhook-id`,{type:`string`,description:`The unique identifier of a webhook`,demandOption:!0}).option(`name`,{type:`string`,description:`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`}).option(`secret`,{type:`string`,description:"Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body."}).option(`url`,{type:`string`,description:`The POST endpoint to call when dispatching a notification.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const I={command:`update <webhook-id>`,describe:`Update a webhook destination.`,builder:F,handler:async u=>{if(u.dryRun){i({command:`cf alerting destinations webhooks update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/destinations/webhooks/${u[`webhook-id`]==null?`<webhook-id>`:encodeURIComponent(String(u[`webhook-id`]))}`,pathParams:{"webhook-id":String(u[`webhook-id`]??``)},bodyKind:`json`,body:u.body===void 0?c({name:l(u.name,`name`,`text`),secret:l(u.secret,`secret`,`text`),url:l(u.url,`url`,`text`)}):s(u.body)});return}let f=await n(u),p=u.local?o:await t();if(u.accountId=p,u.body){let e=s(u.body);r(await a(`Updating`,async()=>f.alerting.destinations.webhooks.update({...e,account_id:p,webhook_id:u[`webhook-id`]})),{successLabel:`Updated`});return}u.name===void 0&&(u.name=await d(`name`,`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`)),u.url===void 0&&(u.url=await d(`url`,`The POST endpoint to call when dispatching a notification.`));let m=c({name:l(u.name,`name`,`text`),secret:l(u.secret,`secret`,`text`),url:l(u.url,`url`,`text`)});r(await a(`Updating`,async()=>f.alerting.destinations.webhooks.update({...m,account_id:p,webhook_id:u[`webhook-id`]})),{successLabel:`Updated`})}},L={command:`webhooks`,describe:`Delivery mechanisms for alerts — email, PagerDuty integrations, and webhook endpoints`,builder:e=>e.command(O).command(A).command(M).command(P).command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},R={command:`destinations`,describe:`Operations for destinations`,builder:e=>e.command(_).command(E).command(L).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function z(e){return e.option(`per-page`,{type:`number`,description:`Number of items per page.`}).option(`before`,{type:`string`,description:`Limit the returned results to history records older than the specified date. This must be a timestamp that conforms to RFC3339.`}).option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`since`,{type:`string`,description:`Limit the returned results to history records newer than the specified date. This must be a timestamp that conforms to RFC3339.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const te={command:`list`,describe:"Gets a list of history records for notifications sent to an account. The records are displayed for last `x` number of days based on the zone plan (free = 30, pro = 30, biz = 30, ent = 90).",builder:z,handler:async s=>{let c={per_page:s[`per-page`],before:s.before,page:s.page,since:s.since};if(s.dryRun){i({command:`cf alerting history list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/history`,pathParams:{},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await t();s.accountId=u,r(await a(`Loading`,async()=>l.alerting.history.list({account_id:u,...c})),{successLabel:`Loaded`})}},B={command:`history`,describe:`Browse previously sent alert notifications and their delivery status`,builder:e=>e.command(te).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function V(e){return e.option(`alert-interval`,{type:`string`,description:`Optional specification of how often to re-alert from the same incident, not support on all alert types.`}).option(`alert-type`,{type:`string`,description:`Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values.`,choices:`abuse_report_alert.access_custom_certificate_expiration_type.advanced_ddos_attack_l4_alert.advanced_ddos_attack_l7_alert.advanced_http_alert_error.bgp_hijack_notification.billing_usage_alert.block_notification_block_removed.block_notification_new_block.block_notification_review_rejected.bot_traffic_basic_alert.brand_protection_alert.brand_protection_digest.clickhouse_alert_fw_anomaly.clickhouse_alert_fw_ent_anomaly.cloudforce_one_request_notification.cni_maintenance_notification.custom_analytics.custom_bot_detection_alert.custom_ssl_certificate_event_type.dedicated_ssl_certificate_event_type.device_connectivity_anomaly_alert.dos_attack_l4.dos_attack_l7.expiring_service_token_alert.failing_logpush_job_disabled_alert.fbm_auto_advertisement.fbm_dosd_attack.fbm_volumetric_attack.health_check_status_notification.hostname_aop_custom_certificate_expiration_type.http_alert_edge_error.http_alert_origin_error.image_notification.image_resizing_notification.incident_alert.load_balancing_health_alert.load_balancing_pool_enablement_alert.logo_match_alert.magic_tunnel_health_check_event.magic_wan_tunnel_health.maintenance_event_notification.mtls_certificate_store_certificate_expiration_type.pages_event_alert.radar_notification.real_origin_monitoring.scriptmonitor_alert_new_code_change_detections.scriptmonitor_alert_new_hosts.scriptmonitor_alert_new_malicious_hosts.scriptmonitor_alert_new_malicious_scripts.scriptmonitor_alert_new_malicious_url.scriptmonitor_alert_new_max_length_resource_url.scriptmonitor_alert_new_resources.secondary_dns_all_primaries_failing.secondary_dns_primaries_failing.secondary_dns_warning.secondary_dns_zone_successfully_updated.secondary_dns_zone_validation_warning.security_insights_alert.sentinel_alert.stream_live_notifications.synthetic_test_latency_alert.synthetic_test_low_availability_alert.traffic_anomalies_alert.tunnel_health_event.tunnel_update_event.universal_ssl_event_type.web_analytics_metrics_update.zone_aop_custom_certificate_expiration_type`.split(`.`)}).option(`description`,{type:`string`,description:`Optional description for the Notification policy.`}).option(`enabled`,{type:`boolean`,description:`Whether or not the Notification policy is enabled.`,default:!0}).option(`filters-actions`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-affected-asns`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-affected-components`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-affected-locations`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-airport-code`,{type:`string`,array:!0,description:`Used for configuring maintenance_event_notification`}).option(`filters-alert-trigger-preferences`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-alert-trigger-preferences-value`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-enabled`,{type:`string`,array:!0,description:`Used for configuring load_balancing_pool_enablement_alert`}).option(`filters-environment`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event-source`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-event-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-group-by`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-health-check-id`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-incident-impact`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-input-id`,{type:`string`,array:!0,description:`Used for configuring stream_live_notifications`}).option(`filters-insight-class`,{type:`string`,array:!0,description:`Used for configuring security_insights_alert`}).option(`filters-limit`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-logo-tag`,{type:`string`,array:!0,description:`Used for configuring logo_match_alert`}).option(`filters-megabits-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-new-health`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-new-status`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-packets-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-pool-id`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-pop-names`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-product`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-project-id`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-protocol`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-query-tag`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-requests-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-selectors`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-services`,{type:`string`,array:!0,description:`Used for configuring clickhouse_alert_fw_ent_anomaly`}).option(`filters-slo`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-status`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-target-hostname`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-target-ip`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-target-zone-name`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-traffic-exclusions`,{type:`string`,array:!0,description:`Used for configuring traffic_anomalies_alert`}).option(`filters-tunnel-id`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-tunnel-name`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-where`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-zones`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`name`,{type:`string`,description:`Name of the policy.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const H={command:`create`,describe:`Creates a new Notification policy.`,builder:V,handler:async f=>{if(f.dryRun){i({command:`cf alerting policies create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/policies`,pathParams:{},bodyKind:`json`,body:f.body===void 0?c({alert_interval:l(f[`alert-interval`],`alert-interval`,`text`),alert_type:l(f[`alert-type`],`alert-type`,`text`),description:l(f.description,`description`,`text`),enabled:f.enabled,filters:{actions:f[`filters-actions`],affected_asns:f[`filters-affected-asns`],affected_components:f[`filters-affected-components`],affected_locations:f[`filters-affected-locations`],airport_code:f[`filters-airport-code`],alert_trigger_preferences:f[`filters-alert-trigger-preferences`],alert_trigger_preferences_value:f[`filters-alert-trigger-preferences-value`],enabled:f[`filters-enabled`],environment:f[`filters-environment`],event:f[`filters-event`],event_source:f[`filters-event-source`],event_type:f[`filters-event-type`],group_by:f[`filters-group-by`],health_check_id:f[`filters-health-check-id`],incident_impact:f[`filters-incident-impact`],input_id:f[`filters-input-id`],insight_class:f[`filters-insight-class`],limit:f[`filters-limit`],logo_tag:f[`filters-logo-tag`],megabits_per_second:f[`filters-megabits-per-second`],new_health:f[`filters-new-health`],new_status:f[`filters-new-status`],packets_per_second:f[`filters-packets-per-second`],pool_id:f[`filters-pool-id`],pop_names:f[`filters-pop-names`],product:f[`filters-product`],project_id:f[`filters-project-id`],protocol:f[`filters-protocol`],query_tag:f[`filters-query-tag`],requests_per_second:f[`filters-requests-per-second`],selectors:f[`filters-selectors`],services:f[`filters-services`],slo:f[`filters-slo`],status:f[`filters-status`],target_hostname:f[`filters-target-hostname`],target_ip:f[`filters-target-ip`],target_zone_name:f[`filters-target-zone-name`],traffic_exclusions:f[`filters-traffic-exclusions`],tunnel_id:f[`filters-tunnel-id`],tunnel_name:f[`filters-tunnel-name`],type:f[`filters-type`],where:f[`filters-where`],zones:f[`filters-zones`]},name:l(f.name,`name`,`text`)}):s(f.body)});return}let p=await n(f),m=f.local?o:await t();if(f.accountId=m,f.body){let e=s(f.body);r(await a(`Creating`,async()=>p.alerting.policies.create({...e,account_id:m})),{successLabel:`Created`});return}if(f[`alert-type`]===void 0&&(f[`alert-type`]=await u(`alert-type`,`Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values.`,`abuse_report_alert.access_custom_certificate_expiration_type.advanced_ddos_attack_l4_alert.advanced_ddos_attack_l7_alert.advanced_http_alert_error.bgp_hijack_notification.billing_usage_alert.block_notification_block_removed.block_notification_new_block.block_notification_review_rejected.bot_traffic_basic_alert.brand_protection_alert.brand_protection_digest.clickhouse_alert_fw_anomaly.clickhouse_alert_fw_ent_anomaly.cloudforce_one_request_notification.cni_maintenance_notification.custom_analytics.custom_bot_detection_alert.custom_ssl_certificate_event_type.dedicated_ssl_certificate_event_type.device_connectivity_anomaly_alert.dos_attack_l4.dos_attack_l7.expiring_service_token_alert.failing_logpush_job_disabled_alert.fbm_auto_advertisement.fbm_dosd_attack.fbm_volumetric_attack.health_check_status_notification.hostname_aop_custom_certificate_expiration_type.http_alert_edge_error.http_alert_origin_error.image_notification.image_resizing_notification.incident_alert.load_balancing_health_alert.load_balancing_pool_enablement_alert.logo_match_alert.magic_tunnel_health_check_event.magic_wan_tunnel_health.maintenance_event_notification.mtls_certificate_store_certificate_expiration_type.pages_event_alert.radar_notification.real_origin_monitoring.scriptmonitor_alert_new_code_change_detections.scriptmonitor_alert_new_hosts.scriptmonitor_alert_new_malicious_hosts.scriptmonitor_alert_new_malicious_scripts.scriptmonitor_alert_new_malicious_url.scriptmonitor_alert_new_max_length_resource_url.scriptmonitor_alert_new_resources.secondary_dns_all_primaries_failing.secondary_dns_primaries_failing.secondary_dns_warning.secondary_dns_zone_successfully_updated.secondary_dns_zone_validation_warning.security_insights_alert.sentinel_alert.stream_live_notifications.synthetic_test_latency_alert.synthetic_test_low_availability_alert.traffic_anomalies_alert.tunnel_health_event.tunnel_update_event.universal_ssl_event_type.web_analytics_metrics_update.zone_aop_custom_certificate_expiration_type`.split(`.`))),f.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);f.name===void 0&&(f.name=await d(`name`,`Name of the policy.`));let h=c({alert_interval:l(f[`alert-interval`],`alert-interval`,`text`),alert_type:l(f[`alert-type`],`alert-type`,`text`),description:l(f.description,`description`,`text`),enabled:f.enabled,filters:{actions:f[`filters-actions`],affected_asns:f[`filters-affected-asns`],affected_components:f[`filters-affected-components`],affected_locations:f[`filters-affected-locations`],airport_code:f[`filters-airport-code`],alert_trigger_preferences:f[`filters-alert-trigger-preferences`],alert_trigger_preferences_value:f[`filters-alert-trigger-preferences-value`],enabled:f[`filters-enabled`],environment:f[`filters-environment`],event:f[`filters-event`],event_source:f[`filters-event-source`],event_type:f[`filters-event-type`],group_by:f[`filters-group-by`],health_check_id:f[`filters-health-check-id`],incident_impact:f[`filters-incident-impact`],input_id:f[`filters-input-id`],insight_class:f[`filters-insight-class`],limit:f[`filters-limit`],logo_tag:f[`filters-logo-tag`],megabits_per_second:f[`filters-megabits-per-second`],new_health:f[`filters-new-health`],new_status:f[`filters-new-status`],packets_per_second:f[`filters-packets-per-second`],pool_id:f[`filters-pool-id`],pop_names:f[`filters-pop-names`],product:f[`filters-product`],project_id:f[`filters-project-id`],protocol:f[`filters-protocol`],query_tag:f[`filters-query-tag`],requests_per_second:f[`filters-requests-per-second`],selectors:f[`filters-selectors`],services:f[`filters-services`],slo:f[`filters-slo`],status:f[`filters-status`],target_hostname:f[`filters-target-hostname`],target_ip:f[`filters-target-ip`],target_zone_name:f[`filters-target-zone-name`],traffic_exclusions:f[`filters-traffic-exclusions`],tunnel_id:f[`filters-tunnel-id`],tunnel_name:f[`filters-tunnel-name`],type:f[`filters-type`],where:f[`filters-where`],zones:f[`filters-zones`]},name:l(f.name,`name`,`text`)});r(await a(`Creating`,async()=>p.alerting.policies.create({...h,account_id:m})),{successLabel:`Created`})}};function U(e){return e.positional(`policy-id`,{type:`string`,description:`The unique identifier of a notification policy`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const W={command:`delete <policy-id>`,describe:`Delete a Notification policy.`,builder:U,handler:async s=>{if(s.dryRun){i({command:`cf alerting policies delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/policies/${s[`policy-id`]==null?`<policy-id>`:encodeURIComponent(String(s[`policy-id`]))}`,pathParams:{"policy-id":String(s[`policy-id`]??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();if(s.accountId=l,!await f({force:!!s.force})){process.stderr.write(`Aborted.
|
|
5
5
|
`);return}r(await a(`Deleting`,async()=>c.alerting.policies.delete({account_id:l,policy_id:s[`policy-id`]})),{successLabel:`Deleted`})}};function G(e){return e.positional(`policy-id`,{type:`string`,description:`The unique identifier of a notification policy`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const K={command:`get <policy-id>`,describe:`Get details for a single policy.`,builder:G,handler:async s=>{if(s.dryRun){i({command:`cf alerting policies get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/policies/${s[`policy-id`]==null?`<policy-id>`:encodeURIComponent(String(s[`policy-id`]))}`,pathParams:{"policy-id":String(s[`policy-id`]??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();s.accountId=l,r(await a(`Loading`,async()=>c.alerting.policies.get({account_id:l,policy_id:s[`policy-id`]})),{successLabel:`Loaded`})}};function q(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const J={command:`list`,describe:`Get a list of all Notification policies.`,builder:q,handler:async s=>{if(s.dryRun){i({command:`cf alerting policies list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/policies`,pathParams:{},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();s.accountId=l,r(await a(`Loading`,async()=>c.alerting.policies.list({account_id:l})),{successLabel:`Loaded`})}};function Y(e){return e.positional(`policy-id`,{type:`string`,description:`The unique identifier of a notification policy`,demandOption:!0}).option(`alert-interval`,{type:`string`,description:`Optional specification of how often to re-alert from the same incident, not support on all alert types.`}).option(`alert-type`,{type:`string`,description:`Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values.`,choices:`abuse_report_alert.access_custom_certificate_expiration_type.advanced_ddos_attack_l4_alert.advanced_ddos_attack_l7_alert.advanced_http_alert_error.bgp_hijack_notification.billing_usage_alert.block_notification_block_removed.block_notification_new_block.block_notification_review_rejected.bot_traffic_basic_alert.brand_protection_alert.brand_protection_digest.clickhouse_alert_fw_anomaly.clickhouse_alert_fw_ent_anomaly.cloudforce_one_request_notification.cni_maintenance_notification.custom_analytics.custom_bot_detection_alert.custom_ssl_certificate_event_type.dedicated_ssl_certificate_event_type.device_connectivity_anomaly_alert.dos_attack_l4.dos_attack_l7.expiring_service_token_alert.failing_logpush_job_disabled_alert.fbm_auto_advertisement.fbm_dosd_attack.fbm_volumetric_attack.health_check_status_notification.hostname_aop_custom_certificate_expiration_type.http_alert_edge_error.http_alert_origin_error.image_notification.image_resizing_notification.incident_alert.load_balancing_health_alert.load_balancing_pool_enablement_alert.logo_match_alert.magic_tunnel_health_check_event.magic_wan_tunnel_health.maintenance_event_notification.mtls_certificate_store_certificate_expiration_type.pages_event_alert.radar_notification.real_origin_monitoring.scriptmonitor_alert_new_code_change_detections.scriptmonitor_alert_new_hosts.scriptmonitor_alert_new_malicious_hosts.scriptmonitor_alert_new_malicious_scripts.scriptmonitor_alert_new_malicious_url.scriptmonitor_alert_new_max_length_resource_url.scriptmonitor_alert_new_resources.secondary_dns_all_primaries_failing.secondary_dns_primaries_failing.secondary_dns_warning.secondary_dns_zone_successfully_updated.secondary_dns_zone_validation_warning.security_insights_alert.sentinel_alert.stream_live_notifications.synthetic_test_latency_alert.synthetic_test_low_availability_alert.traffic_anomalies_alert.tunnel_health_event.tunnel_update_event.universal_ssl_event_type.web_analytics_metrics_update.zone_aop_custom_certificate_expiration_type`.split(`.`)}).option(`description`,{type:`string`,description:`Optional description for the Notification policy.`}).option(`enabled`,{type:`boolean`,description:`Whether or not the Notification policy is enabled.`}).option(`filters-actions`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-affected-asns`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-affected-components`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-affected-locations`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-airport-code`,{type:`string`,array:!0,description:`Used for configuring maintenance_event_notification`}).option(`filters-alert-trigger-preferences`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-alert-trigger-preferences-value`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-enabled`,{type:`string`,array:!0,description:`Used for configuring load_balancing_pool_enablement_alert`}).option(`filters-environment`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event-source`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-event-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-group-by`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-health-check-id`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-incident-impact`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-input-id`,{type:`string`,array:!0,description:`Used for configuring stream_live_notifications`}).option(`filters-insight-class`,{type:`string`,array:!0,description:`Used for configuring security_insights_alert`}).option(`filters-limit`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-logo-tag`,{type:`string`,array:!0,description:`Used for configuring logo_match_alert`}).option(`filters-megabits-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-new-health`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-new-status`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-packets-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-pool-id`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-pop-names`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-product`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-project-id`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-protocol`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-query-tag`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-requests-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-selectors`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-services`,{type:`string`,array:!0,description:`Used for configuring clickhouse_alert_fw_ent_anomaly`}).option(`filters-slo`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-status`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-target-hostname`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-target-ip`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-target-zone-name`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-traffic-exclusions`,{type:`string`,array:!0,description:`Used for configuring traffic_anomalies_alert`}).option(`filters-tunnel-id`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-tunnel-name`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-where`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-zones`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`name`,{type:`string`,description:`Name of the policy.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const X={command:`update <policy-id>`,describe:`Update a Notification policy.`,builder:Y,handler:async u=>{if(u.dryRun){i({command:`cf alerting policies update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/policies/${u[`policy-id`]==null?`<policy-id>`:encodeURIComponent(String(u[`policy-id`]))}`,pathParams:{"policy-id":String(u[`policy-id`]??``)},bodyKind:`json`,body:u.body===void 0?c({alert_interval:l(u[`alert-interval`],`alert-interval`,`text`),alert_type:l(u[`alert-type`],`alert-type`,`text`),description:l(u.description,`description`,`text`),enabled:u.enabled,filters:{actions:u[`filters-actions`],affected_asns:u[`filters-affected-asns`],affected_components:u[`filters-affected-components`],affected_locations:u[`filters-affected-locations`],airport_code:u[`filters-airport-code`],alert_trigger_preferences:u[`filters-alert-trigger-preferences`],alert_trigger_preferences_value:u[`filters-alert-trigger-preferences-value`],enabled:u[`filters-enabled`],environment:u[`filters-environment`],event:u[`filters-event`],event_source:u[`filters-event-source`],event_type:u[`filters-event-type`],group_by:u[`filters-group-by`],health_check_id:u[`filters-health-check-id`],incident_impact:u[`filters-incident-impact`],input_id:u[`filters-input-id`],insight_class:u[`filters-insight-class`],limit:u[`filters-limit`],logo_tag:u[`filters-logo-tag`],megabits_per_second:u[`filters-megabits-per-second`],new_health:u[`filters-new-health`],new_status:u[`filters-new-status`],packets_per_second:u[`filters-packets-per-second`],pool_id:u[`filters-pool-id`],pop_names:u[`filters-pop-names`],product:u[`filters-product`],project_id:u[`filters-project-id`],protocol:u[`filters-protocol`],query_tag:u[`filters-query-tag`],requests_per_second:u[`filters-requests-per-second`],selectors:u[`filters-selectors`],services:u[`filters-services`],slo:u[`filters-slo`],status:u[`filters-status`],target_hostname:u[`filters-target-hostname`],target_ip:u[`filters-target-ip`],target_zone_name:u[`filters-target-zone-name`],traffic_exclusions:u[`filters-traffic-exclusions`],tunnel_id:u[`filters-tunnel-id`],tunnel_name:u[`filters-tunnel-name`],type:u[`filters-type`],where:u[`filters-where`],zones:u[`filters-zones`]},name:l(u.name,`name`,`text`)}):s(u.body)});return}let d=await n(u),f=u.local?o:await t();if(u.accountId=f,u.body){let e=s(u.body);r(await a(`Updating`,async()=>d.alerting.policies.update({...e,account_id:f,policy_id:u[`policy-id`]})),{successLabel:`Updated`});return}let p=c({alert_interval:l(u[`alert-interval`],`alert-interval`,`text`),alert_type:l(u[`alert-type`],`alert-type`,`text`),description:l(u.description,`description`,`text`),enabled:u.enabled,filters:{actions:u[`filters-actions`],affected_asns:u[`filters-affected-asns`],affected_components:u[`filters-affected-components`],affected_locations:u[`filters-affected-locations`],airport_code:u[`filters-airport-code`],alert_trigger_preferences:u[`filters-alert-trigger-preferences`],alert_trigger_preferences_value:u[`filters-alert-trigger-preferences-value`],enabled:u[`filters-enabled`],environment:u[`filters-environment`],event:u[`filters-event`],event_source:u[`filters-event-source`],event_type:u[`filters-event-type`],group_by:u[`filters-group-by`],health_check_id:u[`filters-health-check-id`],incident_impact:u[`filters-incident-impact`],input_id:u[`filters-input-id`],insight_class:u[`filters-insight-class`],limit:u[`filters-limit`],logo_tag:u[`filters-logo-tag`],megabits_per_second:u[`filters-megabits-per-second`],new_health:u[`filters-new-health`],new_status:u[`filters-new-status`],packets_per_second:u[`filters-packets-per-second`],pool_id:u[`filters-pool-id`],pop_names:u[`filters-pop-names`],product:u[`filters-product`],project_id:u[`filters-project-id`],protocol:u[`filters-protocol`],query_tag:u[`filters-query-tag`],requests_per_second:u[`filters-requests-per-second`],selectors:u[`filters-selectors`],services:u[`filters-services`],slo:u[`filters-slo`],status:u[`filters-status`],target_hostname:u[`filters-target-hostname`],target_ip:u[`filters-target-ip`],target_zone_name:u[`filters-target-zone-name`],traffic_exclusions:u[`filters-traffic-exclusions`],tunnel_id:u[`filters-tunnel-id`],tunnel_name:u[`filters-tunnel-name`],type:u[`filters-type`],where:u[`filters-where`],zones:u[`filters-zones`]},name:l(u.name,`name`,`text`)});r(await a(`Updating`,async()=>d.alerting.policies.update({...p,account_id:f,policy_id:u[`policy-id`]})),{successLabel:`Updated`})}},Z={command:`policies`,describe:`Notification policies that define which events trigger alerts and where they are delivered`,builder:e=>e.command(H).command(W).command(K).command(J).command(X).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Q(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ne={command:`create`,describe:`Creates a new silence for an account.`,builder:Q,handler:async c=>{if(c.dryRun){i({command:`cf alerting silences create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/silences`,pathParams:{},bodyKind:`json`,body:c.body===void 0?void 0:s(c.body)});return}let l=await n(c),u=c.local?o:await t();if(c.accountId=u,c.body){let e=s(c.body);r(await a(`Creating`,async()=>l.alerting.silences.create({body:e,account_id:u})),{successLabel:`Created`});return}if(c.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function re(e){return e.positional(`silence-id`,{type:`string`,description:`Silence ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const ie={command:`delete <silence-id>`,describe:`Deletes an existing silence for an account.`,builder:re,handler:async s=>{if(s.dryRun){i({command:`cf alerting silences delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/alerting/v3/silences/${s[`silence-id`]==null?`<silence-id>`:encodeURIComponent(String(s[`silence-id`]))}`,pathParams:{"silence-id":String(s[`silence-id`]??``)},bodyKind:`none`});return}let c=await n(s),l=s.local?o:await t();if(s.accountId=l,!await f({force:!!s.force})){process.stderr.write(`Aborted.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{D as e}from"./oauth-
|
|
2
|
+
import{D as e}from"./oauth-DC9g9uK_.mjs";import{n as t}from"./auth-B1CY5zpC.mjs";import{t as n}from"./output-B6fBFRqe.mjs";import{n as r,t as i}from"./progress-BLQ2xXwD.mjs";import{t as a}from"./cli-types-CFw6Xygp.mjs";function o(e){return e.positional(`zone-identifier`,{type:`string`,description:`Identifier`,demandOption:!0}).option(`until`,{type:`string`,description:`The (exclusive) end of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made, or can be an absolute timestamp that conforms to RFC 3339. If omitted, the time of the request is used.`}).option(`since`,{type:`string`,description:`The (inclusive) beginning of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made, or can be an absolute timestamp that conforms to RFC 3339. At this point in time, it cannot exceed a time in the past greater than one year.
|
|
3
3
|
|
|
4
4
|
Ranges that the Cloudflare web application provides will provide the following period length for each point:
|
|
5
5
|
- Last 60 minutes (from -59 to -1): 1 minute resolution
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{O as e,w as t}from"./oauth-
|
|
2
|
+
import{O as e,w as t}from"./oauth-DC9g9uK_.mjs";import{i as n,n as r}from"./auth-B1CY5zpC.mjs";import{t as i}from"./output-B6fBFRqe.mjs";import{n as a,t as o}from"./progress-BLQ2xXwD.mjs";import{t as s}from"./local-C6TLPAT6.mjs";import{n as c,t as l}from"./input-validation-BwUR9z8e.mjs";function u(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`})}const d={command:`query`,describe:`Executes a SQL query against Workers Analytics Engine data. Pass the SQL query in the request body as plain text. The response uses newline-delimited JSON (NDJSON) by default, or a single JSON object when the query includes a FORMAT JSON clause. Prefer this method for longer queries that may exceed URL length limits.`,builder:u,handler:async u=>{if(u.dryRun){a({command:`cf analytics_engine sql query`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await e()??`<account-id>`}/analytics_engine/sql`,pathParams:{},bodyKind:`octet-stream`,body:u.body});return}let d=await r(u),f=u.local?s:await t();if(u.accountId=f,u.file){let e=l(u.file);i(await o(`Loading`,async()=>n(d,`POST`,`/accounts/${f}/analytics_engine/sql`,{body:e,headers:{"Content-Type":`text/plain`}})),{successLabel:`Loaded`});return}if(u.body){let e=c(u.body,`body`,`binary`);i(await o(`Loading`,async()=>n(d,`POST`,`/accounts/${f}/analytics_engine/sql`,{body:e,headers:{"Content-Type":`text/plain`}})),{successLabel:`Loaded`});return}i(await o(`Loading`,async()=>d.analyticsEngine.sql.query({account_id:f})),{successLabel:`Loaded`})}},f={command:`sql`,describe:`Operations for sql`,builder:e=>e.command(d).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},p={command:`analytics_engine`,describe:`analytics_engine`,builder:e=>e.command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{p as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{D as e}from"./oauth-DBJ5GSFk.mjs";import{i as t,n}from"./auth-CZ0E51rF.mjs";import{t as r}from"./output-B6fBFRqe.mjs";import{n as i,t as a}from"./progress-O88q63Bk.mjs";import{n as o,t as s}from"./body-parser-BO6mfo_W.mjs";import{n as c,t as l}from"./input-validation-BwUR9z8e.mjs";import{n as u,r as d,t as f}from"./prompt-DTAWiEm2.mjs";import{t as p}from"./cli-types-CFw6Xygp.mjs";function ee(e){return e.option(`normalize`,{type:`boolean`,description:`Ensures that the configuration is written or retrieved in normalized fashion`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const te={command:`get`,describe:`Gets the current API Shield configuration settings for a zone, including validation behavior and enforcement mode.`,builder:ee,handler:async t=>{let o={normalize:t.normalize};if(t.dryRun){i({command:`cf api-gateway configurations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:o,bodyKind:`none`});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});t.zoneId=c,r(await a(`Loading`,async()=>s.apiGateway.configurations.get({zone_id:c,...o})),{successLabel:`Loaded`})}};function m(e){return e.option(`normalize`,{type:`boolean`,description:`Ensures that the configuration is written or retrieved in normalized fashion`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const h={command:`update`,describe:`Updates API Shield configuration settings for a zone. Can modify validation strictness, enforcement mode, and other global settings.`,builder:m,handler:async t=>{let s={normalize:t.normalize};if(t.dryRun){i({command:`cf api-gateway configurations update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:s,bodyKind:`json`,body:t.body===void 0?void 0:o(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=o(t.body);new URLSearchParams(Object.entries(s).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),r(await a(`Updating`,async()=>c.apiGateway.configurations.update({body:e,zone_id:l,...s})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},g={command:`configurations`,describe:`API Shield configuration — authentication requirements and session identifiers`,builder:e=>e.command(te).command(h).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function _(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`get`,describe:`Retrieve the most up to date view of discovered operations, rendered as OpenAPI schemas`,builder:_,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway discovery get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let o=await n(t),s=await e({zone:t.zone},o,{quiet:t.quiet});t.zoneId=s,r(await a(`Loading`,async()=>o.apiGateway.discovery.get({zone_id:s})),{successLabel:`Loaded`})}};function y(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const b={command:`bulk-edit`,describe:"Update the `state` on one or more discovered operations",builder:y,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway discovery operations bulk-edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=o(t.body);r(await a(`Updating`,async()=>s.apiGateway.discovery.operations.bulkEdit({body:e,zone_id:c})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function x(e){return e.positional(`discovery-id`,{type:`string`,description:`Discovery ID of a discovered operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const S={command:`edit <discovery-id>`,describe:"Update the `state` on a discovered operation",builder:x,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway discovery operations edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery/operations/${t[`discovery-id`]==null?`<discovery-id>`:encodeURIComponent(String(t[`discovery-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"discovery-id":String(t[`discovery-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=o(t.body);r(await a(`Updating`,async()=>s.apiGateway.discovery.operations.edit({...e,zone_id:c,discovery_id:t[`discovery-id`]})),{successLabel:`Updated`});return}r(await a(`Updating`,async()=>s.apiGateway.discovery.operations.edit({zone_id:c,discovery_id:t[`discovery-id`]})),{successLabel:`Updated`})}};function C(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`host`,{type:`string`,description:`Filter results to only include the specified hosts.`}).option(`method`,{type:`string`,description:`Filter results to only include the specified HTTP methods.`}).option(`endpoint`,{type:`string`,description:`Filter results to only include endpoints containing this pattern.`}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`host`,`method`,`endpoint`,`traffic_stats.requests`,`traffic_stats.last_updated`]}).option(`diff`,{type:`boolean`,description:"When `true`, only return API Discovery results that are not saved into API Shield Endpoint Management"}).option(`origin`,{type:`string`,description:"Filter results to only include discovery results sourced from a particular discovery engine\n * `ML` - Discovered operations that were sourced using ML API Discovery\n * `SessionIdentifier` - Discovered operations that were sourced using Session Identifier API Discovery",choices:[`ML`,`SessionIdentifier`,`LabelDiscovery`]}).option(`state`,{type:`string`,description:"Filter results to only include discovery results in a particular state. States are as follows\n * `review` - Discovered operations that are not saved into API Shield Endpoint Management\n * `saved` - Discovered operations that are already saved into API Shield Endpoint Management\n * `ignored` - Discovered operations that have been marked as ignored",choices:[`review`,`saved`,`ignored`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const w={command:`list`,describe:`Retrieve the most up to date view of discovered operations`,builder:p(C),handler:async t=>{let o={page:t.page,per_page:t[`per-page`],host:t.host,method:t.method,endpoint:t.endpoint,direction:t.direction,order:t.order,diff:t.diff,origin:t.origin,state:t.state};if(t.dryRun){i({command:`cf api-gateway discovery operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:o,bodyKind:`none`});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});t.zoneId=c,r(await a(`Loading`,async()=>s.apiGateway.discovery.operations.list({zone_id:c,...o})),{successLabel:`Loaded`})}},T={command:`operations`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(b).command(S).command(w).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},E={command:`discovery`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(v).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`hosts`,{type:`string`,array:!0,description:`List of hosts to be targeted in the expression`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const O={command:`create`,describe:`Creates an expression template fallthrough rule for API Shield. Used for configuring default behavior when no other expression templates match.`,builder:D,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway expression-template fallthrough create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/expression-template/fallthrough`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?s({hosts:t.hosts}):o(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=o(t.body);r(await a(`Creating`,async()=>c.apiGateway.expressionTemplate.fallthrough.create({...e,zone_id:l})),{successLabel:`Created`});return}if(t.hosts===void 0)throw Error(`--hosts is required (or pass --body with this field set).`);let u=s({hosts:t.hosts});r(await a(`Creating`,async()=>c.apiGateway.expressionTemplate.fallthrough.create({...u,zone_id:l})),{successLabel:`Created`})}},k={command:`fallthrough`,describe:`Reusable expression templates for API Gateway rule configurations`,builder:e=>e.command(O).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},A={command:`expression-template`,describe:`Operations for expression-template`,builder:e=>e.command(k).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function j(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`name`,`description`,`created_at`,`last_updated`,`mapped_resources.operations`]}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`source`,{type:`string`,description:`Filter for labels with source`,choices:[`user`,`managed`]}).option(`filter`,{type:`string`,description:`Filter for labels where the name or description matches using substring match`}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`list`,describe:`Retrieve all labels`,builder:p(j),handler:async t=>{let o={page:t.page,per_page:t[`per-page`],order:t.order,direction:t.direction,source:t.source,filter:t.filter,with_mapped_resource_counts:t[`with-mapped-resource-counts`]};if(t.dryRun){i({command:`cf api-gateway labels list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:o,bodyKind:`none`});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});t.zoneId=c,r(await a(`Loading`,async()=>s.apiGateway.labels.list({zone_id:c,...o})),{successLabel:`Loaded`})}};function N(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`get <name>`,describe:`Retrieve managed label`,builder:N,handler:async t=>{let o={with_mapped_resource_counts:t[`with-mapped-resource-counts`]};if(t.dryRun){i({command:`cf api-gateway labels managed get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/managed/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},query:o,bodyKind:`none`});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});t.zoneId=c,r(await a(`Loading`,async()=>s.apiGateway.labels.managed.get({zone_id:c,name:t.name,...o})),{successLabel:`Loaded`})}};function F(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const I={command:`update <name>`,describe:`Replace all operations(s) attached to a managed label`,builder:F,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway labels managed resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/managed/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/resources/operation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=o(t.body);r(await a(`Updating`,async()=>s.apiGateway.labels.managed.resources.operation.update({body:e,zone_id:c,name:t.name})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},L={command:`operation`,describe:`Labels operations`,builder:e=>e.command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},R={command:`resources`,describe:`Operations for labels.managed.resources`,builder:e=>e.command(L).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},z={command:`managed`,describe:`Labels operations`,builder:e=>e.command(P).command(R).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function B(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const V={command:`bulk-create`,describe:`Create user labels`,builder:B,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway labels user bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=o(t.body);r(await a(`Creating`,async()=>s.apiGateway.labels.user.bulkCreate({body:e,zone_id:c})),{successLabel:`Created`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function H(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const U={command:`bulk-delete`,describe:`Delete user labels`,builder:H,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway labels user bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,!await f({force:!!t.force})){process.stderr.write(`Aborted.
|
|
2
|
+
import{D as e}from"./oauth-DC9g9uK_.mjs";import{i as t,n}from"./auth-B1CY5zpC.mjs";import{t as r}from"./output-B6fBFRqe.mjs";import{n as i,t as a}from"./progress-BLQ2xXwD.mjs";import{n as o,t as s}from"./body-parser-BO6mfo_W.mjs";import{n as c,t as l}from"./input-validation-BwUR9z8e.mjs";import{n as u,r as d,t as f}from"./prompt-DcfYBioA.mjs";import{t as p}from"./cli-types-CFw6Xygp.mjs";function ee(e){return e.option(`normalize`,{type:`boolean`,description:`Ensures that the configuration is written or retrieved in normalized fashion`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const te={command:`get`,describe:`Gets the current API Shield configuration settings for a zone, including validation behavior and enforcement mode.`,builder:ee,handler:async t=>{let o={normalize:t.normalize};if(t.dryRun){i({command:`cf api-gateway configurations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:o,bodyKind:`none`});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});t.zoneId=c,r(await a(`Loading`,async()=>s.apiGateway.configurations.get({zone_id:c,...o})),{successLabel:`Loaded`})}};function m(e){return e.option(`normalize`,{type:`boolean`,description:`Ensures that the configuration is written or retrieved in normalized fashion`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const h={command:`update`,describe:`Updates API Shield configuration settings for a zone. Can modify validation strictness, enforcement mode, and other global settings.`,builder:m,handler:async t=>{let s={normalize:t.normalize};if(t.dryRun){i({command:`cf api-gateway configurations update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/configuration`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:s,bodyKind:`json`,body:t.body===void 0?void 0:o(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=o(t.body);new URLSearchParams(Object.entries(s).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),r(await a(`Updating`,async()=>c.apiGateway.configurations.update({body:e,zone_id:l,...s})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},g={command:`configurations`,describe:`API Shield configuration — authentication requirements and session identifiers`,builder:e=>e.command(te).command(h).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function _(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`get`,describe:`Retrieve the most up to date view of discovered operations, rendered as OpenAPI schemas`,builder:_,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway discovery get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`none`});return}let o=await n(t),s=await e({zone:t.zone},o,{quiet:t.quiet});t.zoneId=s,r(await a(`Loading`,async()=>o.apiGateway.discovery.get({zone_id:s})),{successLabel:`Loaded`})}};function y(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const b={command:`bulk-edit`,describe:"Update the `state` on one or more discovered operations",builder:y,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway discovery operations bulk-edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=o(t.body);r(await a(`Updating`,async()=>s.apiGateway.discovery.operations.bulkEdit({body:e,zone_id:c})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function x(e){return e.positional(`discovery-id`,{type:`string`,description:`Discovery ID of a discovered operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const S={command:`edit <discovery-id>`,describe:"Update the `state` on a discovered operation",builder:x,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway discovery operations edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery/operations/${t[`discovery-id`]==null?`<discovery-id>`:encodeURIComponent(String(t[`discovery-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"discovery-id":String(t[`discovery-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=o(t.body);r(await a(`Updating`,async()=>s.apiGateway.discovery.operations.edit({...e,zone_id:c,discovery_id:t[`discovery-id`]})),{successLabel:`Updated`});return}r(await a(`Updating`,async()=>s.apiGateway.discovery.operations.edit({zone_id:c,discovery_id:t[`discovery-id`]})),{successLabel:`Updated`})}};function C(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`host`,{type:`string`,description:`Filter results to only include the specified hosts.`}).option(`method`,{type:`string`,description:`Filter results to only include the specified HTTP methods.`}).option(`endpoint`,{type:`string`,description:`Filter results to only include endpoints containing this pattern.`}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`host`,`method`,`endpoint`,`traffic_stats.requests`,`traffic_stats.last_updated`]}).option(`diff`,{type:`boolean`,description:"When `true`, only return API Discovery results that are not saved into API Shield Endpoint Management"}).option(`origin`,{type:`string`,description:"Filter results to only include discovery results sourced from a particular discovery engine\n * `ML` - Discovered operations that were sourced using ML API Discovery\n * `SessionIdentifier` - Discovered operations that were sourced using Session Identifier API Discovery",choices:[`ML`,`SessionIdentifier`,`LabelDiscovery`]}).option(`state`,{type:`string`,description:"Filter results to only include discovery results in a particular state. States are as follows\n * `review` - Discovered operations that are not saved into API Shield Endpoint Management\n * `saved` - Discovered operations that are already saved into API Shield Endpoint Management\n * `ignored` - Discovered operations that have been marked as ignored",choices:[`review`,`saved`,`ignored`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const w={command:`list`,describe:`Retrieve the most up to date view of discovered operations`,builder:p(C),handler:async t=>{let o={page:t.page,per_page:t[`per-page`],host:t.host,method:t.method,endpoint:t.endpoint,direction:t.direction,order:t.order,diff:t.diff,origin:t.origin,state:t.state};if(t.dryRun){i({command:`cf api-gateway discovery operations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/discovery/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:o,bodyKind:`none`});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});t.zoneId=c,r(await a(`Loading`,async()=>s.apiGateway.discovery.operations.list({zone_id:c,...o})),{successLabel:`Loaded`})}},T={command:`operations`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(b).command(S).command(w).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},E={command:`discovery`,describe:`Auto-discovered API endpoints from traffic analysis with schema inference`,builder:e=>e.command(v).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`hosts`,{type:`string`,array:!0,description:`List of hosts to be targeted in the expression`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const O={command:`create`,describe:`Creates an expression template fallthrough rule for API Shield. Used for configuring default behavior when no other expression templates match.`,builder:D,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway expression-template fallthrough create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/expression-template/fallthrough`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?s({hosts:t.hosts}):o(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=o(t.body);r(await a(`Creating`,async()=>c.apiGateway.expressionTemplate.fallthrough.create({...e,zone_id:l})),{successLabel:`Created`});return}if(t.hosts===void 0)throw Error(`--hosts is required (or pass --body with this field set).`);let u=s({hosts:t.hosts});r(await a(`Creating`,async()=>c.apiGateway.expressionTemplate.fallthrough.create({...u,zone_id:l})),{successLabel:`Created`})}},k={command:`fallthrough`,describe:`Reusable expression templates for API Gateway rule configurations`,builder:e=>e.command(O).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},A={command:`expression-template`,describe:`Operations for expression-template`,builder:e=>e.command(k).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function j(e){return e.option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`per-page`,{type:`number`,description:`Maximum number of results per page.`}).option(`order`,{type:`string`,description:`Field to order by`,choices:[`name`,`description`,`created_at`,`last_updated`,`mapped_resources.operations`]}).option(`direction`,{type:`string`,description:`Direction to order results.`,choices:[`asc`,`desc`]}).option(`source`,{type:`string`,description:`Filter for labels with source`,choices:[`user`,`managed`]}).option(`filter`,{type:`string`,description:`Filter for labels where the name or description matches using substring match`}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`list`,describe:`Retrieve all labels`,builder:p(j),handler:async t=>{let o={page:t.page,per_page:t[`per-page`],order:t.order,direction:t.direction,source:t.source,filter:t.filter,with_mapped_resource_counts:t[`with-mapped-resource-counts`]};if(t.dryRun){i({command:`cf api-gateway labels list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},query:o,bodyKind:`none`});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});t.zoneId=c,r(await a(`Loading`,async()=>s.apiGateway.labels.list({zone_id:c,...o})),{successLabel:`Loaded`})}};function N(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`get <name>`,describe:`Retrieve managed label`,builder:N,handler:async t=>{let o={with_mapped_resource_counts:t[`with-mapped-resource-counts`]};if(t.dryRun){i({command:`cf api-gateway labels managed get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/managed/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},query:o,bodyKind:`none`});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});t.zoneId=c,r(await a(`Loading`,async()=>s.apiGateway.labels.managed.get({zone_id:c,name:t.name,...o})),{successLabel:`Loaded`})}};function F(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const I={command:`update <name>`,describe:`Replace all operations(s) attached to a managed label`,builder:F,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway labels managed resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/managed/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/resources/operation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=o(t.body);r(await a(`Updating`,async()=>s.apiGateway.labels.managed.resources.operation.update({body:e,zone_id:c,name:t.name})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},L={command:`operation`,describe:`Labels operations`,builder:e=>e.command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},R={command:`resources`,describe:`Operations for labels.managed.resources`,builder:e=>e.command(L).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},z={command:`managed`,describe:`Labels operations`,builder:e=>e.command(P).command(R).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function B(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const V={command:`bulk-create`,describe:`Create user labels`,builder:B,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway labels user bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=o(t.body);r(await a(`Creating`,async()=>s.apiGateway.labels.user.bulkCreate({body:e,zone_id:c})),{successLabel:`Created`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function H(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const U={command:`bulk-delete`,describe:`Delete user labels`,builder:H,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway labels user bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,!await f({force:!!t.force})){process.stderr.write(`Aborted.
|
|
3
3
|
`);return}if(t.body){let e=o(t.body);r(await a(`Deleting`,async()=>s.apiGateway.labels.user.bulkDelete({body:e,zone_id:c})),{successLabel:`Deleted`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function W(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const G={command:`delete <name>`,describe:`Delete user label`,builder:W,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway labels user delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`none`});return}let o=await n(t),s=await e({zone:t.zone},o,{quiet:t.quiet});if(t.zoneId=s,!await f({force:!!t.force})){process.stderr.write(`Aborted.
|
|
4
4
|
`);return}r(await a(`Deleting`,async()=>o.apiGateway.labels.user.delete({zone_id:s,name:t.name})),{successLabel:`Deleted`})}};function K(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`description`,{type:`string`,description:`The description of the label`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const q={command:`edit <name>`,describe:`Update certain fields on a label`,builder:K,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway labels user edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?s({description:c(t.description,`description`,`text`)}):o(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=o(t.body);r(await a(`Updating`,async()=>l.apiGateway.labels.user.edit({...e,zone_id:u,name:t.name})),{successLabel:`Updated`});return}let d=s({description:c(t.description,`description`,`text`)});r(await a(`Updating`,async()=>l.apiGateway.labels.user.edit({...d,zone_id:u,name:t.name})),{successLabel:`Updated`})}};function J(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`with-mapped-resource-counts`,{type:`boolean`,description:"Include `mapped_resources` for each label"}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Y={command:`get <name>`,describe:`Retrieve user label`,builder:J,handler:async t=>{let o={with_mapped_resource_counts:t[`with-mapped-resource-counts`]};if(t.dryRun){i({command:`cf api-gateway labels user get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},query:o,bodyKind:`none`});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});t.zoneId=c,r(await a(`Loading`,async()=>s.apiGateway.labels.user.get({zone_id:c,name:t.name,...o})),{successLabel:`Loaded`})}};function X(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Z={command:`update <name>`,describe:`Replace all operations(s) attached to a user label`,builder:X,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway labels user resources operation update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/resources/operation`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=o(t.body);r(await a(`Updating`,async()=>s.apiGateway.labels.user.resources.operation.update({body:e,zone_id:c,name:t.name})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Q={command:`operation`,describe:`Labels operations`,builder:e=>e.command(Z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ne={command:`resources`,describe:`Operations for labels.user.resources`,builder:e=>e.command(Q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function re(e){return e.positional(`name`,{type:`string`,description:`The label name`,demandOption:!0}).option(`description`,{type:`string`,description:`The description of the label`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ie={command:`update <name>`,describe:`Update all fields on a label`,builder:re,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway labels user update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/labels/user/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?s({description:c(t.description,`description`,`text`)}):o(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=o(t.body);r(await a(`Updating`,async()=>l.apiGateway.labels.user.update({...e,zone_id:u,name:t.name})),{successLabel:`Updated`});return}let d=s({description:c(t.description,`description`,`text`)});r(await a(`Updating`,async()=>l.apiGateway.labels.user.update({...d,zone_id:u,name:t.name})),{successLabel:`Updated`})}},ae={command:`user`,describe:`Labels operations`,builder:e=>e.command(V).command(U).command(G).command(q).command(Y).command(ie).command(ne).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},oe={command:`labels`,describe:`Labels operations`,builder:e=>e.command(M).command(z).command(ae).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function se(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ce={command:`bulk-create`,describe:`Add one or more operations to a zone. Endpoints can contain path variables. Host, method, endpoint will be normalized to a canoncial form when creating an operation and must be unique on the zone. Inserting an operation that matches an existing one will return the record of the already existing operation and update its last_updated date.`,builder:se,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway operations bulk-create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,t.body){let e=o(t.body);r(await a(`Creating`,async()=>s.apiGateway.operations.bulkCreate({body:e,zone_id:c})),{successLabel:`Created`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function le(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ue={command:`bulk-delete`,describe:`Bulk removes multiple API operations from API Shield endpoint management in a single request. Efficient for cleaning up unused endpoints.`,builder:le,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway operations bulk-delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let s=await n(t),c=await e({zone:t.zone},s,{quiet:t.quiet});if(t.zoneId=c,!await f({force:!!t.force})){process.stderr.write(`Aborted.
|
|
5
5
|
`);return}if(t.body){let e=o(t.body);r(await a(`Deleting`,async()=>s.apiGateway.operations.bulkDelete({body:e,zone_id:c})),{successLabel:`Deleted`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function de(e){return e.option(`endpoint`,{type:`string`,description:`The endpoint which can contain path parameter templates in curly braces, each will be replaced from left to right with {varN}, starting with {var1}, during insertion. This will further be Cloudflare-normalized upon insertion. See: https://developers.cloudflare.com/rules/normalization/how-it-works/.`}).option(`host`,{type:`string`,description:`RFC3986-compliant host.`}).option(`method`,{type:`string`,description:`The HTTP method used to access the endpoint.`,choices:[`GET`,`POST`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`CONNECT`,`PATCH`,`TRACE`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const fe={command:`create`,describe:`Add one operation to a zone. Endpoints can contain path variables. Host, method, endpoint will be normalized to a canoncial form when creating an operation and must be unique on the zone. Inserting an operation that matches an existing one will return the record of the already existing operation and update its last_updated date.`,builder:de,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway operations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/item`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?s({endpoint:c(t.endpoint,`endpoint`,`text`),host:c(t.host,`host`,`text`),method:c(t.method,`method`,`text`)}):o(t.body)});return}let l=await n(t),f=await e({zone:t.zone},l,{quiet:t.quiet});if(t.zoneId=f,t.body){let e=o(t.body);r(await a(`Creating`,async()=>l.apiGateway.operations.create({body:e,zone_id:f})),{successLabel:`Created`});return}t.endpoint===void 0&&(t.endpoint=await d(`endpoint`,`The endpoint which can contain path parameter templates in curly braces, each will be replaced from left to right with {varN}, starting with {var1}, during insertion. This will further be Cloudflare-normalized upon insertion. See: https://developers.cloudflare.com/rules/normalization/how-it-works/.`)),t.host===void 0&&(t.host=await d(`host`,`RFC3986-compliant host.`)),t.method===void 0&&(t.method=await u(`method`,`The HTTP method used to access the endpoint.`,[`GET`,`POST`,`HEAD`,`OPTIONS`,`PUT`,`DELETE`,`CONNECT`,`PATCH`,`TRACE`]));let p=s({endpoint:c(t.endpoint,`endpoint`,`text`),host:c(t.host,`host`,`text`),method:c(t.method,`method`,`text`)});r(await a(`Creating`,async()=>l.apiGateway.operations.create({body:p,zone_id:f})),{successLabel:`Created`})}};function pe(e){return e.positional(`operation-id`,{type:`string`,description:`Identifier for the operation`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const me={command:`delete <operation-id>`,describe:`Removes a single API operation from API Shield endpoint management. The operation will no longer be tracked or protected by API Shield rules.`,builder:pe,handler:async t=>{if(t.dryRun){i({command:`cf api-gateway operations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/api_gateway/operations/${t[`operation-id`]==null?`<operation-id>`:encodeURIComponent(String(t[`operation-id`]))}`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``),"operation-id":String(t[`operation-id`]??``)},bodyKind:`none`});return}let o=await n(t),s=await e({zone:t.zone},o,{quiet:t.quiet});if(t.zoneId=s,!await f({force:!!t.force})){process.stderr.write(`Aborted.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{D as e}from"./oauth-
|
|
2
|
+
import{D as e}from"./oauth-DC9g9uK_.mjs";import{n as t}from"./auth-B1CY5zpC.mjs";import{t as n}from"./output-B6fBFRqe.mjs";import{n as r,t as i}from"./progress-BLQ2xXwD.mjs";import{n as a,t as o}from"./body-parser-BO6mfo_W.mjs";import{n as s}from"./input-validation-BwUR9z8e.mjs";import{n as c}from"./prompt-DcfYBioA.mjs";function l(e){return e.option(`value`,{type:`string`,description:`Specifies the enablement value of Argo Smart Routing.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Configures the enablement of Argo Smart Routing.`})}const u={command:`edit`,describe:`Configures the value of the Argo Smart Routing enablement setting.`,builder:l,handler:async l=>{if(l.dryRun){r({command:`cf argo smart-routing edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${l.zone??l.zoneId??`<zone>`}/argo/smart_routing`,pathParams:{"zone-id":String(l.zone??l[`zone-id`]??``)},bodyKind:`json`,body:l.body===void 0?o({value:s(l.value,`value`,`text`)}):a(l.body)});return}let u=await t(l),d=await e({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,l.body){let e=a(l.body);n(await i(`Updating`,async()=>u.argo.smartRouting.edit({...e,zone_id:d})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await c(`value`,`Specifies the enablement value of Argo Smart Routing.`,[`on`,`off`]));let f=o({value:s(l.value,`value`,`text`)});n(await i(`Updating`,async()=>u.argo.smartRouting.edit({...f,zone_id:d})),{successLabel:`Updated`})}};function d(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const f={command:`get`,describe:`Retrieves the value of Argo Smart Routing enablement setting.`,builder:d,handler:async a=>{if(a.dryRun){r({command:`cf argo smart-routing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${a.zone??a.zoneId??`<zone>`}/argo/smart_routing`,pathParams:{"zone-id":String(a.zone??a[`zone-id`]??``)},bodyKind:`none`});return}let o=await t(a),s=await e({zone:a.zone},o,{quiet:a.quiet});a.zoneId=s,n(await i(`Loading`,async()=>o.argo.smartRouting.get({zone_id:s})),{successLabel:`Loaded`})}},p={command:`smart-routing`,describe:`Route traffic through the fastest network paths to your origin using real-time latency data`,builder:e=>e.command(u).command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function m(e){return e.option(`value`,{type:`string`,description:`Enables Tiered Caching.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Update enablement of Tiered Caching.`})}const h={command:`edit`,describe:`Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of lower-tiers and upper-tiers. If content is not cached in lower-tier data centers (generally the ones closest to a visitor), the lower-tier must ask an upper-tier to see if it has the content. If the upper-tier does not have the content, only the upper-tier can ask the origin for content. This practice improves bandwidth efficiency by limiting the number of data centers that can ask the origin for content, which reduces origin load and makes websites more cost-effective to operate. Additionally, Tiered Cache concentrates connections to origin servers so they come from a small number of data centers rather than the full set of network locations. This results in fewer open connections using server resources.`,builder:m,handler:async l=>{if(l.dryRun){r({command:`cf argo tiered-caching edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${l.zone??l.zoneId??`<zone>`}/argo/tiered_caching`,pathParams:{"zone-id":String(l.zone??l[`zone-id`]??``)},bodyKind:`json`,body:l.body===void 0?o({value:s(l.value,`value`,`text`)}):a(l.body)});return}let u=await t(l),d=await e({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,l.body){let e=a(l.body);n(await i(`Updating`,async()=>u.argo.tieredCaching.edit({...e,zone_id:d})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await c(`value`,`Enables Tiered Caching.`,[`on`,`off`]));let f=o({value:s(l.value,`value`,`text`)});n(await i(`Updating`,async()=>u.argo.tieredCaching.edit({...f,zone_id:d})),{successLabel:`Updated`})}};function g(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get`,describe:`Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of lower-tiers and upper-tiers. If content is not cached in lower-tier data centers (generally the ones closest to a visitor), the lower-tier must ask an upper-tier to see if it has the content. If the upper-tier does not have the content, only the upper-tier can ask the origin for content. This practice improves bandwidth efficiency by limiting the number of data centers that can ask the origin for content, which reduces origin load and makes websites more cost-effective to operate. Additionally, Tiered Cache concentrates connections to origin servers so they come from a small number of data centers rather than the full set of network locations. This results in fewer open connections using server resources.`,builder:g,handler:async a=>{if(a.dryRun){r({command:`cf argo tiered-caching get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${a.zone??a.zoneId??`<zone>`}/argo/tiered_caching`,pathParams:{"zone-id":String(a.zone??a[`zone-id`]??``)},bodyKind:`none`});return}let o=await t(a),s=await e({zone:a.zone},o,{quiet:a.quiet});a.zoneId=s,n(await i(`Loading`,async()=>o.argo.tieredCaching.get({zone_id:s})),{successLabel:`Loaded`})}},v={command:`tiered-caching`,describe:`Reduce origin load by having upper-tier data centers serve cache misses before reaching your origin`,builder:e=>e.command(h).command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},y={command:`argo`,describe:`Network optimization features that speed up and improve reliability of traffic to your origins`,builder:e=>e.command(p).command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};
|