cf 0.9.1 → 0.11.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/README.md +20 -5
- package/dist/_meta/agent-context.json +46 -39
- package/dist/_meta/commands.json +9358 -10581
- package/dist/_meta/hand-written-commands.json +784 -0
- package/dist/_meta/schemas.json +14870 -14667
- package/dist/abuse-reports-sDBTV0qZ.mjs +8 -0
- package/dist/{access-CxyW_sIW.mjs → access-DcNzuCue.mjs} +1 -1
- package/dist/account-BX90zXn5.mjs +2 -0
- package/dist/account-tags-Bz3JG5hI.mjs +9 -0
- package/dist/accounts-DCuW3xyZ.mjs +28 -0
- package/dist/{acm-CHacxa3s.mjs → acm-zjfShZLS.mjs} +1 -1
- package/dist/{addressing-BnqNmmYN.mjs → addressing-DORQ64Ux.mjs} +11 -11
- package/dist/{agent-context-Bu6yvDqA.mjs → agent-context-BgPR_aQr.mjs} +1 -1
- package/dist/agent-memory-C0hAUMeC.mjs +6 -0
- package/dist/ai-BpEBGMT2.mjs +5 -0
- package/dist/ai-audit-DnU3vn3E.mjs +2 -0
- package/dist/ai-gateway-COOrr_Yw.mjs +13 -0
- package/dist/ai-search-DKbN9Tyd.mjs +7 -0
- package/dist/ai-security-C_I5lo58.mjs +4 -0
- package/dist/{alerting-qa8SkXlD.mjs → alerting-4T8gmZs-.mjs} +4 -4
- package/dist/analytics-Bxh4TCP7.mjs +3 -0
- package/dist/analytics_engine-fV56bjVN.mjs +2 -0
- package/dist/{api-security-MfHbfZyf.mjs → api-security-COk_i184.mjs} +20 -20
- package/dist/argo-DIRfvxvv.mjs +2 -0
- package/dist/args-DlUhyGU0.mjs +2 -0
- package/dist/artifacts-BBfXNfUg.mjs +4 -0
- package/dist/audit-logs-BlOrlAWe.mjs +2 -0
- package/dist/{auth-DuLchM18.mjs → auth-D3X9HYhD.mjs} +3 -3
- package/dist/auth-DPhNN3Ly.mjs +5 -0
- package/dist/billing-B9e4PnvN.mjs +3 -0
- package/dist/body-parser-BshbixEq.mjs +2 -0
- package/dist/bot-management-D2JVeS-V.mjs +5 -0
- package/dist/botnet-feed-BTzTYs5d.mjs +3 -0
- package/dist/brand-protection-C5Q6Gpw9.mjs +3 -0
- package/dist/{browser-extension-q79xHrVW.mjs → browser-extension-u5uA0Lwk.mjs} +1 -1
- package/dist/browser-run-CHGOCTdG.mjs +4 -0
- package/dist/build-D0FhOj40.mjs +8 -0
- package/dist/{cache-Cl7vKJwH.mjs → cache-C6V7PbQM.mjs} +1 -1
- package/dist/{calls-DtK_ANxq.mjs → calls-Bye8Tyy-.mjs} +1 -1
- package/dist/certificate-authorities-B-U_e6JJ.mjs +2 -0
- package/dist/cf-Ds4JFovl.mjs +18 -0
- package/dist/chunk-LQW53VED-22IYZovK.mjs +119 -0
- package/dist/chunk-QBZBEHZB-CKzQKcIp.mjs +2 -0
- package/dist/{client-certificates-BtPU9GsQ.mjs → client-certificates-3RrC-6LG.mjs} +1 -1
- package/dist/{client-side-security-DAn-3jwp.mjs → client-side-security-DIdKvRMT.mjs} +1 -1
- package/dist/cloud-connector-CL1jPQud.mjs +2 -0
- package/dist/cloudforce-one-DULeqLkR.mjs +36 -0
- package/dist/command-C9VP3xaA.mjs +2 -0
- package/dist/{completions-BHE4pRjB.mjs → completions-CqgGKRAC.mjs} +3 -3
- package/dist/config.d.mts +1460 -1348
- package/dist/config.mjs +1 -1
- package/dist/connector-interrupts-CXlLObDv.mjs +2 -0
- package/dist/connector-telemetry-events-BrYX4ig4.mjs +2 -0
- package/dist/connector-telemetry-events-latest-BbpcII3_.mjs +2 -0
- package/dist/connector-telemetry-snapshots-BdeBQYcM.mjs +2 -0
- package/dist/connector-telemetry-snapshots-latest-DuCiimXl.mjs +2 -0
- package/dist/{connectors-Bo6ZT8PT.mjs → connectors-BQwyBJ4_.mjs} +1 -1
- package/dist/containers-BrQtGiNp.mjs +58 -0
- package/dist/{content-scan-D03UfK2X.mjs → content-scan-DNzhXYkY.mjs} +1 -1
- package/dist/{csamScanner-DgS-7ADh.mjs → csamScanner-CFq5s1Q3.mjs} +1 -1
- package/dist/{ct-alerting-8AKtNnUg.mjs → ct-alerting-CH6UmsGQ.mjs} +1 -1
- package/dist/custom-certificates-DnG73Wg2.mjs +5 -0
- package/dist/custom-csrs-bhClr2SU.mjs +3 -0
- package/dist/custom-hostnames-C0eiGvG9.mjs +5 -0
- package/dist/custom-nameservers-CVMhhLm6.mjs +3 -0
- package/dist/custom-pages-DTINMR30.mjs +3 -0
- package/dist/d1-sKdExJYF.mjs +20 -0
- package/dist/data-security-mV3a6UfW.mjs +7 -0
- package/dist/dcv-delegation-dBu3jdRw.mjs +2 -0
- package/dist/delegate.mjs +1 -1
- package/dist/{deploy-DGlmjPTS.mjs → deploy-BL59O1O1.mjs} +1 -1
- package/dist/deploy-input-Dz6q-__n.mjs +2 -0
- package/dist/{dev-BbLV0Ti-.mjs → dev-BDaavgH1.mjs} +2 -2
- package/dist/diagnostics-CJV6qWUA.mjs +3 -0
- package/dist/{directory-CCndFkbQ.mjs → directory-B5zCMusW.mjs} +1 -1
- package/dist/{dispatch-namespaces-C48JQ9EA.mjs → dispatch-namespaces-Dg5lu5xX.mjs} +1 -1
- package/dist/dist-BHi7UhXO.mjs +72 -0
- package/dist/dist-BWpErtDM.mjs +384 -0
- package/dist/{dls-BBq99pjI.mjs → dls-t0hnIe_P.mjs} +1 -1
- package/dist/dns-C8FC2hbh.mjs +29 -0
- package/dist/{dns-firewall-DdwVtm12.mjs → dns-firewall-CuhhUm55.mjs} +1 -1
- package/dist/{dot-prop-6SRZBKHT-C_xd7eTS.mjs → dot-prop-6SRZBKHT-wwGHcwAa.mjs} +1 -1
- package/dist/dry-run-DL2V6yFm.mjs +2 -0
- package/dist/durable-objects-BLrgM3Cw.mjs +2 -0
- package/dist/email-auth-BmYrl0pO.mjs +2 -0
- package/dist/email-routing-CF3_Z957.mjs +6 -0
- package/dist/email-security-F7OYcMkZ.mjs +18 -0
- package/dist/email-sending-EyU3WvGQ.mjs +7 -0
- package/dist/fieldExtractors-Cno37T2m.mjs +3 -0
- package/dist/firewall-8YWWy4iB.mjs +11 -0
- package/dist/flagship-C4x0l-8J.mjs +4 -0
- package/dist/{fraud-AH47n-wL.mjs → fraud-HR_SdUx3.mjs} +1 -1
- package/dist/google-tag-gateway-BdcS0WnX.mjs +2 -0
- package/dist/{healthchecks-DfEUG007.mjs → healthchecks-4qOvjrTN.mjs} +2 -2
- package/dist/{hostnames-DQUiD3Vr.mjs → hostnames-DehdYOMz.mjs} +1 -1
- package/dist/{hyperdrive-RyQboMWI.mjs → hyperdrive-3gD3hn70.mjs} +1 -1
- package/dist/iam-DR72hmii.mjs +6 -0
- package/dist/images-CeKc5JPh.mjs +8 -0
- package/dist/index.mjs +1 -1
- package/dist/intel-DtFix9WL.mjs +8 -0
- package/dist/{interactive-mV8PABm6.mjs → interactive-C7M55Wxx.mjs} +1 -1
- package/dist/ips-CtWCjXAN.mjs +2 -0
- package/dist/{keyless-certificates-oNu5jWKF.mjs → keyless-certificates-Dk24yQFz.mjs} +1 -1
- package/dist/keys-BmhG6Kn1.mjs +2 -0
- package/dist/{kv-Bi9B4E0A.mjs → kv-BuVPAuZP.mjs} +1 -1
- package/dist/{leaked-credential-checks-DKRjBLcr.mjs → leaked-credential-checks-XcZmt1I-.mjs} +1 -1
- package/dist/load-balancers-CylN-l7n.mjs +6 -0
- package/dist/{local-DTyuGwTw.mjs → local-Be3lg_9E.mjs} +1 -1
- package/dist/{local-runtime-IAXhEugU.mjs → local-runtime-Ce7k598H.mjs} +1 -1
- package/dist/logexplorer-CvRPoKbj.mjs +17 -0
- package/dist/logo-matches-Heuft3yF.mjs +2 -0
- package/dist/logos-DRYjGBDq.mjs +3 -0
- package/dist/logpush-Dve9jOMp.mjs +4 -0
- package/dist/{logs-DmWWL5f9.mjs → logs-SC86FE89.mjs} +1 -1
- package/dist/{magic-cloud-networking-XbTa6P52.mjs → magic-cloud-networking-DXzeqwX-.mjs} +4 -4
- package/dist/magic-network-monitoring-DW0Jl74i.mjs +4 -0
- package/dist/magic-transit-BK_3asH2.mjs +111 -0
- package/dist/managed-transforms-B6TV4qoE.mjs +3 -0
- package/dist/matches-Iss9Fo4R.mjs +2 -0
- package/dist/mcp-8wxXT6JU.mjs +4 -0
- package/dist/mesh-Bf9UAS4J.mjs +4 -0
- package/dist/{moq-CJpE-eNj.mjs → moq-ZKMFOeVz.mjs} +1 -1
- package/dist/mtls-certificates-DoWm6GiE.mjs +3 -0
- package/dist/{network-D2WRXCDe.mjs → network-B1lBARU9.mjs} +1 -1
- package/dist/{network-interconnects-Clq4X1U8.mjs → network-interconnects-CLYIFHfU.mjs} +1 -1
- package/dist/oauth-DuEONNgC.mjs +14 -0
- package/dist/{oauth-clients-hilWfAlm.mjs → oauth-clients-DgiTzLzu.mjs} +1 -1
- package/dist/oauth-scopes-BOBRMxjm.mjs +2 -0
- package/dist/observability-Jya7-zkl.mjs +4 -0
- package/dist/{open-PBXRGS4R-C46yIm3u.mjs → open-PBXRGS4R-CX8K4WYl.mjs} +3 -3
- package/dist/{organization-D41rIvJa.mjs → organization-CYxYV4e0.mjs} +6 -6
- package/dist/organizations-SacGUW44.mjs +2 -0
- package/dist/origin-ca-certificates-Ph1bJGQ1.mjs +3 -0
- package/dist/origin-post-quantum-encryption-BBLiGAGB.mjs +2 -0
- package/dist/origin-tls-client-auth-DSDgTN2X.mjs +4 -0
- package/dist/{output-DgW1hQGX.mjs → output-Ccqw2WOb.mjs} +1 -1
- package/dist/page-rules-BqEyFR2c.mjs +27 -0
- package/dist/pages-CQ7ZVWk1.mjs +14 -0
- package/dist/pay-per-crawl-BMe_3_Qj.mjs +4 -0
- package/dist/pipelines-6De2Pe2C.mjs +6 -0
- package/dist/precursor-iwK-1P_d.mjs +4 -0
- package/dist/progress-BqQcF5QH.mjs +2 -0
- package/dist/project-settings-C_1-JI6Y.mjs +3 -0
- package/dist/prompt-B0sWIs9c.mjs +3 -0
- package/dist/{public-BwQqexwo-DbWj8rrr.mjs → public-BYCVISMH-DnMJ5Jct.mjs} +1 -1
- package/dist/queries-c7zvnfEQ.mjs +3 -0
- package/dist/queues-BU6y16qS.mjs +6 -0
- package/dist/r2-Jo3QMahK.mjs +24 -0
- package/dist/{r2-data-catalog-DLtf9d6o.mjs → r2-data-catalog-B-tw-JdG.mjs} +1 -1
- package/dist/radar-DIYAMEof.mjs +2 -0
- package/dist/{rate-limits-B1YjnGue.mjs → rate-limits-DewOcznT.mjs} +1 -1
- package/dist/raw-fetch-Cc-MjHeL.mjs +2 -0
- package/dist/realtimekit-cnZEVNDn.mjs +7 -0
- package/dist/registrar-BsWr_aPM.mjs +23 -0
- package/dist/{registrar-sandbox-0i1T3zne.mjs → registrar-sandbox-BlcpUyIH.mjs} +6 -6
- package/dist/{registry-DDcSvd8H.mjs → registry-jifR3_Y6.mjs} +1 -1
- package/dist/reporting--1AyTV7k.mjs +2 -0
- package/dist/request-tracers-C_VX7X6-.mjs +2 -0
- package/dist/{resource-sharing-Ctdi9D-j.mjs → resource-sharing-Br5dqr3o.mjs} +1 -1
- package/dist/resource-tagging-C33U6T74.mjs +2 -0
- package/dist/rules-BfjzALMi.mjs +4 -0
- package/dist/rulesets-3i_1Vwt-.mjs +5 -0
- package/dist/rum-CjmIckiR.mjs +4 -0
- package/dist/{schema-BeXPWeK9.mjs → schema-1mwmslUV.mjs} +1 -1
- package/dist/schema-flags-llLJuFFw.mjs +5 -0
- package/dist/{scim-BgGsmHrL.mjs → scim-pApmzA5B.mjs} +1 -1
- package/dist/sdk-ZctLa5jW.mjs +3 -0
- package/dist/{secrets-store-BCpFhYFv.mjs → secrets-store-DBC9WJau.mjs} +1 -1
- package/dist/security-center-Djm06dq-.mjs +2 -0
- package/dist/{security-txt-Be2Bif0z.mjs → security-txt-Ci7bP4zH.mjs} +1 -1
- package/dist/{share-Bz2tFTUP.mjs → share-Dj-MNXrw.mjs} +4 -4
- package/dist/shared-BJvq4DkR.mjs +290 -0
- package/dist/smart-shield--8EpJjrF.mjs +4 -0
- package/dist/snippets-Dyz0PH60.mjs +4 -0
- package/dist/{spawn-CHkoow5W.mjs → spawn-C5Z7oWdp.mjs} +108 -112
- package/dist/{spectrum-BA0a42eM.mjs → spectrum-rAHWz8rH.mjs} +1 -1
- package/dist/{speed-mmOjxOzo.mjs → speed-BKepWBXj.mjs} +1 -1
- package/dist/src-gJma71Ec.mjs +108 -0
- package/dist/{ssl-Yr6kELqg.mjs → ssl-KdFiY3ev.mjs} +1 -1
- package/dist/startup-profile-GLNPHQ9U.mjs +17 -0
- package/dist/{state-DZC531l2.mjs → state-Cu3cItUg.mjs} +1 -1
- package/dist/{stream-Cu0kYWbc.mjs → stream-CKJ6Tb0M.mjs} +13 -13
- package/dist/submit-BxbKKhBn.mjs +2 -0
- package/dist/tags-DA8dq9fx.mjs +2 -0
- package/dist/tenant-DLXw48hS.mjs +2 -0
- package/dist/tenant-custom-nameservers-9G93XuvU.mjs +3 -0
- package/dist/{tools-D2Xxfkrc.mjs → tools-x8bj9E6b.mjs} +1 -1
- package/dist/{tunnel-CDYkWjnt.mjs → tunnel-CNQA5Flp.mjs} +1 -1
- package/dist/tunnels-CC10EOsU.mjs +2 -0
- package/dist/turnstile-CH58hnf4.mjs +23 -0
- package/dist/{ui-DIpjthrV.mjs → ui-CmnnBm_O.mjs} +1 -1
- package/dist/url-info-BpCgdUtL.mjs +2 -0
- package/dist/{url-normalization-BeKkOZz7.mjs → url-normalization-BzuynEy1.mjs} +1 -1
- package/dist/url-scanner-APIZbhB7.mjs +2 -0
- package/dist/user-2-NGebfI.mjs +12 -0
- package/dist/values-S_bNv819.mjs +2 -0
- package/dist/{vectorize-CjXfiFH4.mjs → vectorize-Bv7feLBC.mjs} +1 -1
- package/dist/waiting-rooms-Dk4LIpvm.mjs +11 -0
- package/dist/{web-assets-BzM5vVzy.mjs → web-assets-C1UmOyzD.mjs} +1 -1
- package/dist/web3-GnUocVYH.mjs +4 -0
- package/dist/workers-J1-PLwdl.mjs +28 -0
- package/dist/{workers-builds-B44wc67O.mjs → workers-builds-DCHmWOMS.mjs} +4 -4
- package/dist/{workflows-rFuQWClt.mjs → workflows-CArfEI2c.mjs} +2 -2
- package/dist/zaraz-mg2YlR3_.mjs +2 -0
- package/dist/zero-trust-DVdUPtj1.mjs +93 -0
- package/dist/zone-DMAfrDJX.mjs +2 -0
- package/dist/zones-CNwxUi7I.mjs +21 -0
- package/package.json +10 -7
- package/dist/abuse-reports-CzDAjFpo.mjs +0 -8
- package/dist/account-Dd4-tDYJ.mjs +0 -2
- package/dist/account-tags-65fAlHrf.mjs +0 -9
- package/dist/accounts-Bp5KGc6r.mjs +0 -28
- package/dist/agent-memory-D--BQS0W.mjs +0 -6
- package/dist/ai-BnVlQDiI.mjs +0 -5
- package/dist/ai-audit-CfpDKXkD.mjs +0 -2
- package/dist/ai-gateway-oG4j_oYN.mjs +0 -13
- package/dist/ai-search-B2l3B_jn.mjs +0 -7
- package/dist/ai-security-byjIIrfl.mjs +0 -4
- package/dist/analytics-DeIKjC9n.mjs +0 -3
- package/dist/analytics_engine-BnECMIWJ.mjs +0 -2
- package/dist/argo-DFerMyXF.mjs +0 -2
- package/dist/artifacts-CtyEYYDa.mjs +0 -4
- package/dist/audit-logs-retFtvow.mjs +0 -2
- package/dist/auth-aazs91XL.mjs +0 -5
- package/dist/billing-CxQVqpGZ.mjs +0 -3
- package/dist/body-parser-CYD7PKFC.mjs +0 -2
- package/dist/bot-management-Rli7v7tg.mjs +0 -5
- package/dist/botnet-feed-Cw6XSEf8.mjs +0 -3
- package/dist/brand-protection-CTvnHGfV.mjs +0 -3
- package/dist/browser-run-FwtwnBzA.mjs +0 -4
- package/dist/build-Dji9BYmV.mjs +0 -2
- package/dist/certificate-authorities-DZP1RzAs.mjs +0 -2
- package/dist/cf-oSz9pud_.mjs +0 -18
- package/dist/chunk-LQW53VED-Xakf_rUn.mjs +0 -499
- package/dist/cloud-connector-BpVcvhjZ.mjs +0 -2
- package/dist/cloudforce-one-2PecncfX.mjs +0 -30
- package/dist/connector-interrupts-ollUcksZ.mjs +0 -2
- package/dist/connector-telemetry-events-D5_3X7XW.mjs +0 -2
- package/dist/connector-telemetry-snapshots-CJ9gLRFR.mjs +0 -2
- package/dist/containers-Bog7j0Hw.mjs +0 -54
- package/dist/custom-certificates-4y35UC1X.mjs +0 -5
- package/dist/custom-csrs-DwBrLh-H.mjs +0 -4
- package/dist/custom-hostnames-CDIAnsRa.mjs +0 -5
- package/dist/custom-nameservers-stk7ymnP.mjs +0 -3
- package/dist/custom-pages-vfDxrXbt.mjs +0 -4
- package/dist/d1-Cllm-iTT.mjs +0 -20
- package/dist/data-security-rnoSCEdL.mjs +0 -7
- package/dist/dcv-delegation-DCRCOL6l.mjs +0 -2
- package/dist/deploy-input-DhCo1I0I.mjs +0 -242
- package/dist/diagnostics-D5Yo2xqx.mjs +0 -3
- package/dist/dist-COfwjT96.mjs +0 -72
- package/dist/dns-DdQYtenF.mjs +0 -29
- package/dist/durable-objects-BvxXBht_.mjs +0 -2
- package/dist/email-CGOC_evd.mjs +0 -2
- package/dist/email-auth-DFvXKSkg.mjs +0 -2
- package/dist/email-routing-QBRPBlyl.mjs +0 -6
- package/dist/email-security-BFagcRPP.mjs +0 -18
- package/dist/email-sending-Ddhe7xjN.mjs +0 -7
- package/dist/filters-CGisPGD1.mjs +0 -4
- package/dist/firewall-DD8U-Brd.mjs +0 -11
- package/dist/flagship-FJHc4mFi.mjs +0 -4
- package/dist/google-tag-gateway-149kbuG_.mjs +0 -2
- package/dist/iam-BhHYhMXO.mjs +0 -6
- package/dist/images-CDViyKtZ.mjs +0 -8
- package/dist/intel-YHZbPlS3.mjs +0 -8
- package/dist/ips-BpCdldFx.mjs +0 -2
- package/dist/keys-yYtv7Ztr.mjs +0 -2
- package/dist/load-balancers-jRCN75mX.mjs +0 -7
- package/dist/logexplorer-kO8CULiK.mjs +0 -24
- package/dist/logo-matches-LyDAYPbI.mjs +0 -2
- package/dist/logos-O9f5bGSB.mjs +0 -3
- package/dist/logpush-dtXLu3Ck.mjs +0 -5
- package/dist/magic-network-monitoring-CpfkgZMp.mjs +0 -4
- package/dist/magic-transit-DwgZeIj-.mjs +0 -111
- package/dist/managed-transforms-DCmogkxv.mjs +0 -3
- package/dist/matches-BAeN8VM1.mjs +0 -2
- package/dist/mcp-DKZ2D050.mjs +0 -4
- package/dist/media-CnxgOViL.mjs +0 -2
- package/dist/mesh-CzIPtuaM.mjs +0 -4
- package/dist/mtls-certificates-Bbm_1lQI.mjs +0 -3
- package/dist/oauth-BPizUUqP.mjs +0 -15
- package/dist/oauth-scopes-CmbgsPYd.mjs +0 -2
- package/dist/observability-DXYgDdU5.mjs +0 -4
- package/dist/organizations-eNzfOwlP.mjs +0 -2
- package/dist/origin-ca-certificates-DaiAmw45.mjs +0 -3
- package/dist/origin-post-quantum-encryption-7YztBged.mjs +0 -2
- package/dist/origin-tls-client-auth-DRwURM8s.mjs +0 -4
- package/dist/page-rules-B2Csdc4h.mjs +0 -18
- package/dist/pages-BAL6Q7OY.mjs +0 -14
- package/dist/pay-per-crawl-C-1-ZAtn.mjs +0 -4
- package/dist/pipelines-cyQOuFLb.mjs +0 -6
- package/dist/precursor-BrweY39h.mjs +0 -4
- package/dist/progress-B84wYh91.mjs +0 -2
- package/dist/prompt-CDtLWxNv.mjs +0 -3
- package/dist/queries-oM8uGZy5.mjs +0 -3
- package/dist/queues-CTx04ZNw.mjs +0 -6
- package/dist/r2-CnlIUn7R.mjs +0 -24
- package/dist/radar-CGNgGh8v.mjs +0 -2
- package/dist/raw-fetch-Dz-QBoP_.mjs +0 -2
- package/dist/realtimekit-BPwzhNS9.mjs +0 -7
- package/dist/registrar-BEcb90RX.mjs +0 -21
- package/dist/reporting-CLbjHlnw.mjs +0 -2
- package/dist/request-tracers-BcKpofP1.mjs +0 -2
- package/dist/resource-tagging-DGEyVTDN.mjs +0 -2
- package/dist/rules-CmuB5rIN.mjs +0 -4
- package/dist/rulesets-CGaMq8vG.mjs +0 -8
- package/dist/rum-QT6EP4JK.mjs +0 -4
- package/dist/schema-flags-DHryz6SF.mjs +0 -5
- package/dist/sdk-m4xeaua4.mjs +0 -3
- package/dist/security-center-BNm4uPVB.mjs +0 -2
- package/dist/session-Ckt20hHa.mjs +0 -2
- package/dist/shared-BzPQog8H.mjs +0 -2
- package/dist/smart-shield-SODkOUyO.mjs +0 -4
- package/dist/snippets-B5jY8v_7.mjs +0 -4
- package/dist/src-CHW7s5IS.mjs +0 -108
- package/dist/submit-Dl_27e0n.mjs +0 -2
- package/dist/tags-Cdo_Pwtr.mjs +0 -2
- package/dist/tenant-EX-ANl6X.mjs +0 -2
- package/dist/tenant-custom-nameservers-BPHUeckw.mjs +0 -3
- package/dist/triggers-Bf9hbP3h.mjs +0 -2
- package/dist/tunnels-CgyX8R2J.mjs +0 -2
- package/dist/turnstile-BUtzlW-0.mjs +0 -23
- package/dist/url-info-CJsa1Oc9.mjs +0 -2
- package/dist/url-scanner-Cz-yl0_3.mjs +0 -2
- package/dist/user-BxHjEqpd.mjs +0 -12
- package/dist/values-C43NurfT.mjs +0 -2
- package/dist/versions-BFbc90Wu.mjs +0 -2
- package/dist/waiting-rooms-C5jSQv_r.mjs +0 -11
- package/dist/web3-Ctv9HGiR.mjs +0 -4
- package/dist/workers-D-YbIedB.mjs +0 -24
- package/dist/zaraz-BA6kY-b6.mjs +0 -2
- package/dist/zero-trust-DOFLlUz1.mjs +0 -102
- package/dist/zone-B_rgejLV.mjs +0 -2
- package/dist/zone-tags-BWdza4rH.mjs +0 -9
- package/dist/zones-DTWO7Vvn.mjs +0 -21
- /package/dist/{Page-C-JHZnIy.mjs → Page-9ry_XAVC.mjs} +0 -0
- /package/dist/{alerts-B85uj2Vx.mjs → alerts-15-IW4jE.mjs} +0 -0
- /package/dist/{autorag-Do9l_LyY.mjs → autorag-CFwRkEKw.mjs} +0 -0
- /package/dist/{brands-DateHCdd.mjs → brands-BgT1vu9B.mjs} +0 -0
- /package/dist/{chunk-6EUZQHAF-l8tR2Qyj.mjs → chunk-6EUZQHAF-C3w62dek.mjs} +0 -0
- /package/dist/{chunk-Q72B4Q5Z-CPy_WJKU.mjs → chunk-Q72B4Q5Z-DVMMVVEs.mjs} +0 -0
- /package/dist/{clear-CB2kgcEB.mjs → clear-BlCK85Me.mjs} +0 -0
- /package/dist/{cli-types-BWdZbsFE.mjs → cli-types-DAYeL_Mj.mjs} +0 -0
- /package/dist/{domain-info-DJHEt8JJ.mjs → domain-info-C7LBxPBt.mjs} +0 -0
- /package/dist/{health-buY5f5pp.mjs → health-DZFfafkX.mjs} +0 -0
- /package/dist/{input-validation-BBKJRoRB.mjs → input-validation-QDIYu7Vb.mjs} +0 -0
- /package/dist/{internal-CwyoJUHh.mjs → internal-BKHC2D1Y.mjs} +0 -0
- /package/dist/{live-wEpA5V_n.mjs → live-DwCvDmaH.mjs} +0 -0
- /package/dist/{metadata-8AkOftcB.mjs → metadata-B5yfL0ln.mjs} +0 -0
- /package/dist/{rate-limit-analytics-Bf1uT0lT.mjs → rate-limit-analytics-B8Vuu1sU.mjs} +0 -0
- /package/dist/{ready-CBSCPiHE.mjs → ready-D9H2zHHI.mjs} +0 -0
- /package/dist/{recent-submissions-Dpmq1f7z.mjs → recent-submissions-BPo0J80d.mjs} +0 -0
- /package/dist/{refute-u7ZPQJZy.mjs → refute-2W8NLCN4.mjs} +0 -0
- /package/dist/{resolve-XgxRJ-Ys.mjs → resolve-B8CyM1mi.mjs} +0 -0
- /package/dist/{scan-logo-Ba8WZAyp.mjs → scan-logo-D5x6F1Y0.mjs} +0 -0
- /package/dist/{scan-page-Bcq3Ei86.mjs → scan-page-CWhta3x7.mjs} +0 -0
- /package/dist/{search-D9WDwnV4.mjs → search-DZmBQJL9.mjs} +0 -0
- /package/dist/{signed-url-CjPbG5zV.mjs → signed-url-CQrmWgz5.mjs} +0 -0
- /package/dist/{submission-info-Z9hhp9Rq.mjs → submission-info-C98A0bqq.mjs} +0 -0
- /package/dist/{theme-BePJemMn.mjs → theme-CrIBazAF.mjs} +0 -0
- /package/dist/{total-queries-aKAYX1iX.mjs → total-queries-BZoaFoDE.mjs} +0 -0
- /package/dist/{tracked-domains-Ck7Jm4Kn.mjs → tracked-domains-CNHogPHx.mjs} +0 -0
- /package/dist/{verify-2yi0H93r.mjs → verify-4e4L9IRk.mjs} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{t as e}from"./local-Be3lg_9E.mjs";import{f as t,g as n}from"./oauth-DuEONNgC.mjs";import{r}from"./auth-D3X9HYhD.mjs";import{t as i}from"./output-Ccqw2WOb.mjs";import{t as a}from"./dry-run-DL2V6yFm.mjs";import{t as o}from"./progress-BqQcF5QH.mjs";import{t as s}from"./cli-types-DAYeL_Mj.mjs";function c(e){return e.option(`id`,{type:`string`,description:`Finds a specific log by its ID.`}).option(`export`,{type:`boolean`,description:`Indicates that this request is an export of logs in CSV format.`}).option(`action-type`,{type:`string`,description:`Filters by the action type.`}).option(`actor-ip`,{type:`string`,description:`Filters by the IP address of the request that made the change by specific IP address or valid CIDR Range.`}).option(`actor-email`,{type:`string`,description:`Filters by the email address of the actor that made the change.`}).option(`since`,{type:`string`,description:"Limits the returned results to logs newer than the specified date. A `full-date` that conforms to RFC3339."}).option(`before`,{type:`string`,description:"Limits the returned results to logs older than the specified date. A `full-date` that conforms to RFC3339."}).option(`zone-name`,{type:`string`,description:`Filters by the name of the zone associated to the change.`}).option(`direction`,{type:`string`,description:`Changes the direction of the chronological sorting.`,choices:[`desc`,`asc`]}).option(`per-page`,{type:`number`,description:`Sets the number of results to return per page.`}).option(`page`,{type:`number`,description:`Defines which page of results to return.`}).option(`hide-user-logs`,{type:`boolean`,description:`Indicates whether or not to hide user level audit logs.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const l={command:`list`,describe:`Gets a list of audit logs for an account. Can be filtered by who made the change, on which zone, and the timeframe of the change.`,builder:s(c),handler:async s=>{let c={id:s.id,export:s.export,"action.type":s[`action-type`],"actor.ip":s[`actor-ip`],"actor.email":s[`actor-email`],since:s.since,before:s.before,"zone.name":s[`zone-name`],direction:s.direction,per_page:s[`per-page`],page:s.page,hide_user_logs:s[`hide-user-logs`]};if(s.dryRun){a({command:`cf audit-logs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/audit_logs`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.auditLogs.list({account_id:u,...c})),{successLabel:`Loaded`})}},u={command:`audit-logs`,describe:`audit-logs`,builder:e=>e.command(l).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{u as default};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
3
|
-
`).filter(e=>e.trim()&&!e.startsWith(`Node`)).pop()?.split(`,`);if(!n||n.length<4)return null;let[r,i,a,o]=n,s=o?parseInt(o.trim(),10):NaN,c=a?parseInt(a.trim(),10):NaN;return isNaN(s)||isNaN(c)?null:{pid:s,ppid:c,command:i?.trim()||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function g(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=h(r);if(!e||e.ppid===0||e.ppid===4)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function _(e=process.pid){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(`PID must be a positive integer`);return
|
|
2
|
+
import{s as e}from"./project-settings-C_1-JI6Y.mjs";import{n as t,r as n,t as r}from"./sdk-ZctLa5jW.mjs";import{B as i}from"./dist-BWpErtDM.mjs";import{o as a}from"./chunk-LQW53VED-22IYZovK.mjs";import{a as o,g as s,p as c}from"./oauth-DuEONNgC.mjs";import{r as l,t as u}from"./interactive-C7M55Wxx.mjs";import{execSync as d}from"child_process";import f from"os";function p(e){try{let t=d(`ps -p ${e} -o pid=,ppid=,command=`,{encoding:`utf8`,timeout:5e3}).trim();if(!t)return null;let[n,r,...i]=t.split(/\s+/),a=n?parseInt(n,10):NaN,o=r?parseInt(r,10):NaN;return isNaN(a)||isNaN(o)?null:{pid:a,ppid:o,command:i.join(` `)||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function m(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=p(r);if(!e||e.ppid===0||e.ppid===1)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function h(e){try{let t=d(`wmic process where (ProcessId=${e}) get ProcessId,ParentProcessId,CommandLine /format:csv`,{encoding:`utf8`,timeout:1e4});if(!t)return null;let n=t.split(`
|
|
3
|
+
`).filter(e=>e.trim()&&!e.startsWith(`Node`)).pop()?.split(`,`);if(!n||n.length<4)return null;let[r,i,a,o]=n,s=o?parseInt(o.trim(),10):NaN,c=a?parseInt(a.trim(),10):NaN;return isNaN(s)||isNaN(c)?null:{pid:s,ppid:c,command:i?.trim()||void 0}}catch(t){return t instanceof Error&&t.message.includes(`timeout`)&&console.warn(`Process lookup timed out for PID ${e}`),null}}function g(e){let t=[],n=new Set,r=e,i=1e3;for(;r&&i>0;){if(n.has(r)){console.warn(`Detected cycle in process tree at PID ${r}`);break}n.add(r);let e=h(r);if(!e||e.ppid===0||e.ppid===4)break;t.push(e),r=e.ppid,i--}return i===0&&console.warn(`Reached maximum depth limit while traversing process tree from PID ${e}`),t}function _(e=process.pid){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(`PID must be a positive integer`);return f.platform()===`win32`?g(e):m(e)}const v=[{id:`opencode`,name:`OpenCode`,type:`agent`,envVars:[{any:[`OPENCODE`,`OPENCODE_BIN_PATH`,`OPENCODE_SERVER`,`OPENCODE_APP_INFO`,`OPENCODE_MODES`]}]},{id:`jules`,name:`Jules`,type:`agent`,envVars:[{all:[[`HOME`,`/home/jules`],[`USER`,`swebot`]]}]},{id:`claude-code`,name:`Claude Code`,type:`agent`,envVars:[`CLAUDECODE`]},{id:`cursor-agent`,name:`Cursor Agent`,type:`agent`,envVars:[{all:[`CURSOR_TRACE_ID`,[`PAGER`,`head -n 10000 | cat`]]}]},{id:`cursor`,name:`Cursor`,type:`interactive`,envVars:[`CURSOR_TRACE_ID`]},{id:`gemini-agent`,name:`Gemini Agent`,type:`agent`,processChecks:[`gemini`]},{id:`codex`,name:`OpenAI Codex`,type:`agent`,processChecks:[`codex`]},{id:`replit`,name:`Replit`,type:`agent`,envVars:[`REPL_ID`]},{id:`aider`,name:`Aider`,type:`agent`,envVars:[`AIDER_API_KEY`],processChecks:[`aider`]},{id:`bolt-agent`,name:`Bolt.new Agent`,type:`agent`,envVars:[{all:[[`SHELL`,`/bin/jsh`],`npm_config_yes`]}]},{id:`bolt`,name:`Bolt.new`,type:`interactive`,envVars:[{all:[[`SHELL`,`/bin/jsh`]],none:[`npm_config_yes`]}]},{id:`zed-agent`,name:`Zed Agent`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`zed`],[`PAGER`,`cat`]]}]},{id:`zed`,name:`Zed`,type:`interactive`,envVars:[{all:[[`TERM_PROGRAM`,`zed`]],none:[[`PAGER`,`cat`]]}]},{id:`replit-assistant`,name:`Replit Assistant`,type:`agent`,envVars:[{all:[`REPL_ID`,[`REPLIT_MODE`,`assistant`]]}]},{id:`replit`,name:`Replit`,type:`interactive`,envVars:[{all:[`REPL_ID`],none:[[`REPLIT_MODE`,`assistant`]]}]},{id:`windsurf`,name:`Windsurf`,type:`agent`,envVars:[`CODEIUM_EDITOR_APP_ROOT`]},{id:`crush`,name:`Crush`,type:`agent`,processChecks:[`crush`]},{id:`vscode-copilot-agent`,name:`GitHub Copilot in VS Code`,type:`agent`,envVars:[{all:[[`TERM_PROGRAM`,`vscode`],[`GIT_PAGER`,`cat`]]}]},{id:`warp`,name:`Warp Terminal`,type:`hybrid`,envVars:[{all:[[`TERM_PROGRAM`,`WarpTerminal`]]}]},{id:`octofriend`,name:`Octofriend`,type:`agent`,processChecks:[`octofriend`]}];function y(e,t=process.env){let[n,r]=typeof e==`string`?[e,void 0]:e,i=t[n];return!!(i&&(!r||i===r))}function b(e,t){try{let n=t??_();for(let t of n)if(t.command?.includes(e))return!0}catch{}return!1}function x(e,t=process.env){if(typeof e==`string`||Array.isArray(e))return y(e,t);let{any:n,all:r,none:i}=e,a=!n?.length||n.some(e=>y(e,t)),o=!r?.length||r.every(e=>y(e,t)),s=!i?.length||!i.some(e=>y(e,t));return a&&o&&s}function S(e){return e.customDetectors?.some(e=>{try{return e()}catch{return!1}})??!1}function C(e){return{isAgentic:!0,id:e.id,name:e.name,type:e.type}}function w(e=process.env,t){for(let t of v)if(t.envVars?.some(t=>x(t,e)))return C(t);let n=t,r=()=>{if(n===void 0)try{n=_()}catch{n=[]}return n};for(let e of v)if(e.processChecks?.some(e=>b(e,r())))return C(e);for(let e of v)if(S(e))return C(e);return{isAgentic:!1,id:null,name:null,type:null}}function T(){return u?`ci`:l()?`interactive`:`non-interactive`}function E(){let t=w(),n=t.isAgentic&&t.id!==null?{"X-CF-CLI-Agent":t.id}:{};return{"User-Agent":e,"X-CF-CLI-Mode":T(),...n}}const D=3e4,O=t.Default;function k(e){return e instanceof FormData||e instanceof Blob||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||e instanceof ReadableStream||e instanceof URLSearchParams}function A(e){return Object.keys(e).some(e=>e.toLowerCase()===`content-type`)}async function j(e){let t=e.headers.get(`content-type`)??``;try{return t.includes(`application/json`)?await e.json():await e.text()}catch{return null}}function M(e,t,n){if(!(n==null||n===``)){if(Array.isArray(n)){for(let r of n)M(e,t,r);return}e.append(t,String(n))}}function N(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))M(t,n,r);return t.toString()}function P(e,t,n){let r=new URL(t.endsWith(`/`)?t:`${t}/`),i=new URL(e.startsWith(`/`)?e.slice(1):e,r);if(i.origin!==r.origin)throw Error(`Refusing to send an authenticated request to ${i.origin} (expected ${r.origin})`);let a=N(n??{});return a&&(i.search=a),i.toString()}const F=new WeakMap;async function I(e,t,r,i={}){let a=P(r,F.get(e)??O,i.query),o={...i.headers},s;i.body!==void 0&&(k(i.body)||typeof i.body==`string`&&A(o)?s=i.body:(o[`Content-Type`]??=`application/json`,s=JSON.stringify(i.body)));let c;try{c=await e.fetch(a,{method:t,headers:o,body:s,signal:i.signal},{timeoutInSeconds:i.timeout?i.timeout/1e3:void 0,abortSignal:i.signal})}catch(e){throw i.signal?.aborted?Error(`Request aborted`):e instanceof Error&&e.name===`AbortError`?Error(`Request timed out after ${i.timeout??3e4}ms`):e instanceof Error?Error(`Request failed: ${e.message}`):e}if(!c.ok)throw new n({statusCode:c.status,body:await j(c),rawResponse:{status:c.status,statusText:c.statusText,url:c.url||a,headers:c.headers,redirected:c.redirected,type:c.type}});if(c.status===204)return null;let l=c.headers.get(`content-type`)??``;if(!l.includes(`application/json`)&&i.preserveNonJsonBytes)return Buffer.from(await c.arrayBuffer());let u=await c.text();if(u===``)return null;if(!l.includes(`application/json`))return u;let d=JSON.parse(u);if(d.success===!1)throw new n({message:`API error: ${d.errors?.map(e=>e.message).filter(Boolean).join(`, `)||`unknown error`}`,statusCode:c.status,body:d});return`result`in d?d.result:d}function L(e){let t=e.baseURL??O,n=new r({baseUrl:t,auth:async()=>({headers:{Authorization:`Bearer ${e.apiToken}`}}),headers:e.defaultHeaders,timeoutInSeconds:(e.timeout??3e4)/1e3,maxRetries:0,fetch:e.fetch??globalThis.fetch});return F.set(n,t),n}async function R(){let e=a({allowGlobalAuthKey:!1});if(e&&`apiToken`in e)return e.apiToken;let t=await o();if(t)return t;throw Error(`No authentication token found.
|
|
4
4
|
|
|
5
5
|
Please set one of the following:
|
|
6
6
|
1. Set the CLOUDFLARE_API_TOKEN environment variable
|
|
7
7
|
2. Run 'cf auth login' to authenticate via OAuth
|
|
8
8
|
|
|
9
|
-
For API tokens, visit: https://dash.cloudflare.com/profile/api-tokens`)}async function z(e){let t=await s();if(t)return t;try{let t=await R(),n=i({compliance_region:await c()}),r=e-Date.now();if(r<=0)return;let a=L({apiToken:t,baseURL:n,defaultHeaders:E()}),o={timeoutInSeconds:r/1e3,maxRetries:0},[s,l]=await Promise.allSettled([a.accounts.list({per_page:50},o),a.user.memberships.list({per_page:50},o)]);if(s.status===`rejected`)return;let u=s.value;if((u.result_info?.total_count??u.result.length)>u.result.length)return;let d=u.result;if(l.status===`fulfilled`){let e=l.value.result??[];if((l.value.result_info?.total_count??e.length)>e.length)return;let t=new Set(e.map(e=>e.account?.id).filter(e=>e!==void 0));d=d.filter(e=>t.has(e.id))}return d.length===1?d[0]?.id:void 0}catch{return}}async function B(e){let t=i({compliance_region:await c()});if(e.local){let{createLocalFetch:n}=await import(`./local-
|
|
9
|
+
For API tokens, visit: https://dash.cloudflare.com/profile/api-tokens`)}async function z(e){let t=await s();if(t)return t;try{let t=await R(),n=i({compliance_region:await c()}),r=e-Date.now();if(r<=0)return;let a=L({apiToken:t,baseURL:n,defaultHeaders:E()}),o={timeoutInSeconds:r/1e3,maxRetries:0},[s,l]=await Promise.allSettled([a.accounts.list({per_page:50},o),a.user.memberships.list({per_page:50},o)]);if(s.status===`rejected`)return;let u=s.value;if((u.result_info?.total_count??u.result.length)>u.result.length)return;let d=u.result;if(l.status===`fulfilled`){let e=l.value.result??[];if((l.value.result_info?.total_count??e.length)>e.length)return;let t=new Set(e.map(e=>e.account?.id).filter(e=>e!==void 0));d=d.filter(e=>t.has(e.id))}return d.length===1?d[0]?.id:void 0}catch{return}}async function B(e){let t=i({compliance_region:await c()});if(e.local){let{createLocalFetch:n}=await import(`./local-Be3lg_9E.mjs`).then(e=>e.a);return L({apiToken:`cf-local-mode-no-auth`,baseURL:t,defaultHeaders:E(),fetch:n({persistTo:e.persistTo,apiBaseUrl:t})})}return L({apiToken:await R(),baseURL:t,defaultHeaders:E()})}export{I as a,R as i,L as n,z as o,B as r,E as s,D as t};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{m as e,o as t}from"./chunk-LQW53VED-22IYZovK.mjs";import{a as n}from"./theme-CrIBazAF.mjs";import{n as r,r as i,t as a}from"./ui-CmnnBm_O.mjs";import{a as o,c as s,d as c,i as l,n as u,o as d,r as f,s as p,t as m,u as h}from"./oauth-DuEONNgC.mjs";import{i as g,n as _}from"./auth-D3X9HYhD.mjs";import{t as v}from"./output-Ccqw2WOb.mjs";import y from"node:path";function b(e,t,n){if(!e.profile)return;let r=n?` ${n}`:``;throw Error(`The --profile flag cannot be used with \`cf auth ${t}\`.${r}`)}function x(){if(t({allowGlobalAuthKey:!1})!==void 0)throw Error(`Cannot manage auth profiles while CLOUDFLARE_API_TOKEN is set. Unset CLOUDFLARE_API_TOKEN and try again.`)}const S={command:`create <name>`,describe:`Create or re-authenticate a named auth profile`,builder:e=>e.positional(`name`,{type:`string`,description:`Name for the auth profile`,demandOption:!0}).option(`browser`,{type:`boolean`,description:`Open the authorization link in a browser (use --no-browser to print it instead)`,default:!0}).option(`device`,{type:`boolean`,description:`Use OAuth device authorization (use --no-device for the localhost callback flow)`,default:!0}).option(`scopes`,{type:`string`,array:!0,description:`The set of OAuth scopes to request`}),handler:async t=>{b(t,`create`,"Pass the profile name as the command argument: `cf auth create <name>`."),x(),e(t.name);let i=l().configs.exists(t.name);await p({browser:t.browser,device:t.device,scopes:t.scopes,profile:t.name}),console.log(r(i?`Profile "${t.name}" re-authenticated.`:`Profile "${t.name}" created.`)),console.log(a(`Run ${n.code(`cf auth activate ${t.name}`)} to use this profile in a directory.`))}},C={command:`delete <name>`,describe:`Delete a named auth profile`,builder:e=>e.positional(`name`,{type:`string`,description:`Name of the auth profile to delete`,demandOption:!0}),handler:async t=>{b(t,`delete`),x(),e(t.name);let i=l();if(!i.configs.exists(t.name))throw Error(`Profile "${t.name}" does not exist.`);let o=i.bindings.removeAllBindingsForProfile(t.name);if(o.length>0){console.log(r(`Removed directory bindings:`));for(let e of o)console.log(` ${e}`)}await s(t.name),i.configs.delete(t.name),console.log(r(`Profile "${t.name}" deleted.`));let c=i.bindings.getProfileForDirectory(process.cwd());c?console.log(r(`Active profile for this directory: ${c}.`)):i.configs.exists(`default`)?console.log(r(`This directory now uses the default profile.`)):console.log(a(`No active profile for this directory. Run ${n.code(`cf auth login`)} to set up the default profile, or ${n.code(`cf auth create <name>`)} to create a named profile.`))}},w={command:`activate <name> [dir]`,describe:`Bind a named auth profile to a directory`,builder:e=>e.positional(`name`,{type:`string`,description:`Name of the auth profile to activate`,demandOption:!0}).positional(`dir`,{type:`string`,description:`Directory to bind the profile to (defaults to current directory)`}),handler:t=>{b(t,`activate`,"Pass the profile name as the command argument: `cf auth activate <name>`."),x(),e(t.name);let n=l();if(!n.configs.exists(t.name))throw Error(`Profile "${t.name}" does not exist. Run \`cf auth create ${t.name}\` first.`);let i=t.dir??process.cwd();n.bindings.activate(t.name,i),console.log(r(`Profile "${t.name}" activated for "${y.resolve(i)}".`))}},T={command:`deactivate [dir]`,describe:`Remove the auth profile binding from a directory`,builder:e=>e.positional(`dir`,{type:`string`,description:`Directory to unbind (defaults to current directory). Must be the exact directory the profile was bound to.`}),handler:e=>{b(e,`deactivate`),x();let t=l(),i=e.dir??process.cwd(),{removedProfile:o,newResolution:s}=t.bindings.deactivate(i);console.log(r(`Profile "${o}" deactivated from "${y.resolve(i)}".`)),s.profile===void 0?console.log(a(`Run ${n.code(`cf auth login`)} to set up the default profile, or ${n.code(`cf auth create <name>`)} to create a named profile.`)):s.profile===`default`?console.log(r(`This directory now uses the default profile.`)):console.log(r(`Now using: ${s.profile} (${s.source}).`))}},E={command:`list`,describe:`List all auth profiles`,handler:e=>{b(e,`list`);let t=l(),n=t.bindings.read(),r={};for(let[e,t]of Object.entries(n))(r[t]??=[]).push(e);v(t.configs.list().map(e=>({name:e,boundDirectories:r[e]??[]})))}},D={command:`login`,describe:`Authenticate with Cloudflare`,builder:e=>e.option(`force`,{type:`boolean`,alias:`f`,description:`Force re-authentication even if already logged in`,default:!1}).option(`browser`,{type:`boolean`,description:`Open the authorization link in a browser (use --no-browser to print it instead)`,default:!0}).option(`device`,{type:`boolean`,description:`Use OAuth device authorization (use --no-device for the localhost callback flow)`,default:!0}).option(`scopes`,{type:`string`,array:!0,description:`The set of OAuth scopes to request`}),handler:async e=>{b(e,`login`,"Run `cf auth create <name>` to authenticate a named profile.");let t=u();if(t!==`default`&&console.log(i(`This directory has profile "${t}" active. \`cf auth login\` updates the default profile, not "${t}".\nTo re-authenticate "${t}", run \`cf auth create ${t}\`.`)),c(`default`),!e.force&&d()){if(await o()){let e=h();console.log(r(`You are already logged in.`)),console.log(`${n.info(`Config file:`)} ${n.muted(f())}`),e?.expiration_time&&console.log(`${n.info(`Token expires:`)} ${new Date(e.expiration_time).toLocaleString()}`),console.log(a(`Run ${n.code(`cf auth login --force`)} to re-authenticate, or ${n.code(`cf auth logout`)} to log out.`));return}console.log(i(`Existing tokens are invalid or expired. Starting fresh login...
|
|
3
|
+
`))}else e.force&&d()&&console.log(r(`Re-authenticating...
|
|
4
|
+
`));if(console.log(r(`Starting OAuth login flow...
|
|
5
|
+
`)),!await p({browser:e.browser,device:e.device,scopes:e.scopes,profile:`default`})){console.log(i(`CLOUDFLARE_API_TOKEN is set and takes precedence. Unset it to log in via OAuth.`));return}let s=h();console.log(`${n.info(`Config file:`)} ${n.muted(f())}`),s?.scopes&&console.log(`${n.info(`Scopes:`)} ${s.scopes.join(`, `)}`),s?.expiration_time&&console.log(`${n.info(`Token expires:`)} ${new Date(s.expiration_time).toLocaleString()}`)}},O={command:`logout`,describe:`Log out and remove stored credentials`,handler:async e=>{b(e,`logout`,"Run `cf auth delete <name>` to remove a named profile.");let t=u();t!==`default`&&console.log(i(`This directory has profile "${t}" active. \`cf auth logout\` removes the default profile's token, not "${t}".\nTo delete "${t}", run \`cf auth delete ${t}\`.`)),c(`default`);let o=d(),l=!!process.env.CLOUDFLARE_API_TOKEN;if(!o){l?(console.log(r(`No cf OAuth credentials found, but CLOUDFLARE_API_TOKEN environment variable is set.`)),console.log(r(`Unset it with: unset CLOUDFLARE_API_TOKEN`))):(console.log(r(`You are not currently logged in.`)),console.log(a(`Run ${n.code(`cf auth login`)} to authenticate.`)));return}console.log(r(`Logging out...`)),await s(`default`),console.log(`${n.info(`Removed:`)} OAuth tokens from ${n.muted(f())}`),l&&(console.log(``),console.log(i(`CLOUDFLARE_API_TOKEN environment variable is still set.`)),console.log(r(`You will remain authenticated via the env var. Unset it with: unset CLOUDFLARE_API_TOKEN`)))}},k={command:`whoami`,describe:`Show current user and authentication status`,builder:e=>e,handler:async e=>{let t=process.env.CLOUDFLARE_API_TOKEN,n=h(),r;r=t?`CLOUDFLARE_API_TOKEN environment variable`:n?.oauth_token?`OAuth token from ${f()}`:`none`;let i;try{i=await g()}catch{v({authenticated:!1,error:`Not logged in`});return}let a=_({apiToken:i}),o,s=[],[c,l]=await Promise.allSettled([a.user.get(),m()]);if(c.status===`fulfilled`){let e=c.value;e&&`email`in e&&typeof e.email==`string`&&(o=e.email)}else process.env.DEBUG&&console.error(`User lookup error:`,c.reason);l.status===`fulfilled`?s=l.value:process.env.DEBUG&&console.error(`Account lookup error:`,l.reason);let u=c.status===`fulfilled`||l.status===`fulfilled`,d={authenticated:!0,authSource:r,tokenValid:u,...o&&{email:o},accounts:s};n?.oauth_token&&(d.scopes=n.scopes,d.expiresAt=n.expiration_time),v(d)}},A={command:`auth`,describe:`Manage authentication and profiles`,builder:e=>e.command(D).command(O).command(k).command(S).command(C).command(w).command(T).command(E).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{A as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{t as e}from"./local-Be3lg_9E.mjs";import{f as t,g as n}from"./oauth-DuEONNgC.mjs";import{r}from"./auth-D3X9HYhD.mjs";import{t as i}from"./output-Ccqw2WOb.mjs";import{t as a}from"./dry-run-DL2V6yFm.mjs";import{t as o}from"./progress-BqQcF5QH.mjs";import{n as s,r as c,t as l}from"./body-parser-BshbixEq.mjs";import{n as u}from"./input-validation-QDIYu7Vb.mjs";import{n as d}from"./prompt-B0sWIs9c.mjs";function f(e){return e.option(`address`,{type:`string`,description:`Address line 1.`}).option(`address2`,{type:`string`,description:`Address line 2.`}).option(`city`,{type:`string`,description:`City.`}).option(`country`,{type:`string`,description:`Country code.`}).option(`state`,{type:`string`,description:`State or province.`}).option(`zipcode`,{type:`string`,description:`Postal or zip code.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const p={command:`validate`,describe:`Validates a billing address and returns validated address suggestions. Authentication is not enforced to support pre-signup address validation flows, so credentials are accepted but not required.`,builder:f,handler:async e=>{if(e.dryRun){a({command:`cf billing addresses validate`,method:`POST`,url:`https://api.cloudflare.com/client/v4/billing/address-validation`,pathParams:{},bodyKind:`json`,body:e.body===void 0?l({address:u(e.address,`address`,`text`),address2:u(e.address2,`address2`,`text`),city:u(e.city,`city`,`text`),country:u(e.country,`country`,`text`),state:u(e.state,`state`,`text`),zipcode:u(e.zipcode,`zipcode`,`text`)}):s(e.body)});return}let t=await r(e);if(e.body){let n=s(e.body);i(await o(`Creating`,async()=>t.billing.addresses.validate({...n})),{successLabel:`Created`});return}let n=l({address:u(e.address,`address`,`text`),address2:u(e.address2,`address2`,`text`),city:u(e.city,`city`,`text`),country:u(e.country,`country`,`text`),state:u(e.state,`state`,`text`),zipcode:u(e.zipcode,`zipcode`,`text`)});i(await o(`Creating`,async()=>t.billing.addresses.validate({...n})),{successLabel:`Created`})}},m={command:`addresses`,describe:`Operations for addresses`,builder:e=>e.command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function h(e){return e.option(`address`,{type:`string`,description:`Street address line 1.`}).option(`address2`,{type:`string`,description:`Street address line 2 (apt, suite, etc.).`}).option(`billing-email`,{type:`string`,description:`Primary billing email address.`}).option(`buying-rate-plan`,{type:`string`,description:`Rate plan being purchased right after profile setup.`}).option(`captcha-challenge-jwt`,{type:`string`,description:`Captcha challenge JWT issued during onboarding.`}).option(`cf-turnstile-response`,{type:`string`,description:`Cloudflare Turnstile response.`}).option(`city`,{type:`string`,description:`City on the billing profile.`}).option(`company`,{type:`string`,description:`Company name on the billing profile.`}).option(`country`,{type:`string`,description:`ISO 3166-1 alpha-2 country code.`}).option(`first-name`,{type:`string`,description:`First name on the billing profile.`}).option(`h-captcha-response`,{type:`string`,description:`hCaptcha response.`}).option(`last-name`,{type:`string`,description:`Last name on the billing profile.`}).option(`preferred-locale`,{type:`string`,description:`Preferred locale for invoice rendering (BCP 47).`}).option(`secondary-billing-email`,{type:`string`,description:`Secondary billing email address for CC on invoices.`}).option(`state`,{type:`string`,description:`State or region on the billing profile.`}).option(`tax-id-type`,{type:`string`,description:`Type of tax ID provided.`}).option(`telephone`,{type:`string`,description:`Contact phone number.`}).option(`vat`,{type:`string`,description:`VAT identifier.`}).option(`zipcode`,{type:`string`,description:`ZIP or postal code.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Request body for creating or updating a billing profile.`})}const g={command:`create`,describe:`Creates a billing profile for an account.`,builder:h,handler:async c=>{if(c.dryRun){a({command:`cf billing profiles create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/billing/profile`,pathParams:{},bodyKind:`json`,body:c.body===void 0?l({address:u(c.address,`address`,`text`),address2:u(c.address2,`address2`,`text`),billing_email:u(c[`billing-email`],`billing-email`,`text`),buying_rate_plan:u(c[`buying-rate-plan`],`buying-rate-plan`,`text`),captcha_challenge_jwt:u(c[`captcha-challenge-jwt`],`captcha-challenge-jwt`,`text`),cf_turnstile_response:u(c[`cf-turnstile-response`],`cf-turnstile-response`,`text`),city:u(c.city,`city`,`text`),company:u(c.company,`company`,`text`),country:u(c.country,`country`,`text`),first_name:u(c[`first-name`],`first-name`,`text`),h_captcha_response:u(c[`h-captcha-response`],`h-captcha-response`,`text`),last_name:u(c[`last-name`],`last-name`,`text`),preferred_locale:u(c[`preferred-locale`],`preferred-locale`,`text`),secondary_billing_email:u(c[`secondary-billing-email`],`secondary-billing-email`,`text`),state:u(c.state,`state`,`text`),tax_id_type:u(c[`tax-id-type`],`tax-id-type`,`text`),telephone:u(c.telephone,`telephone`,`text`),vat:u(c.vat,`vat`,`text`),zipcode:u(c.zipcode,`zipcode`,`text`)}):s(c.body)});return}let d=await r(c),f=c.local?e:await t();if(c.accountId=f,c.body){let e=s(c.body);i(await o(`Creating`,async()=>d.billing.profiles.create({body:e,account_id:f})),{successLabel:`Created`});return}let p=l({address:u(c.address,`address`,`text`),address2:u(c.address2,`address2`,`text`),billing_email:u(c[`billing-email`],`billing-email`,`text`),buying_rate_plan:u(c[`buying-rate-plan`],`buying-rate-plan`,`text`),captcha_challenge_jwt:u(c[`captcha-challenge-jwt`],`captcha-challenge-jwt`,`text`),cf_turnstile_response:u(c[`cf-turnstile-response`],`cf-turnstile-response`,`text`),city:u(c.city,`city`,`text`),company:u(c.company,`company`,`text`),country:u(c.country,`country`,`text`),first_name:u(c[`first-name`],`first-name`,`text`),h_captcha_response:u(c[`h-captcha-response`],`h-captcha-response`,`text`),last_name:u(c[`last-name`],`last-name`,`text`),preferred_locale:u(c[`preferred-locale`],`preferred-locale`,`text`),secondary_billing_email:u(c[`secondary-billing-email`],`secondary-billing-email`,`text`),state:u(c.state,`state`,`text`),tax_id_type:u(c[`tax-id-type`],`tax-id-type`,`text`),telephone:u(c.telephone,`telephone`,`text`),vat:u(c.vat,`vat`,`text`),zipcode:u(c.zipcode,`zipcode`,`text`)});i(await o(`Creating`,async()=>d.billing.profiles.create({body:p,account_id:f})),{successLabel:`Created`})}};function _(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`createPaymentIntent`,describe:`Creates a Stripe payment intent for adding or updating a payment method on the account's billing profile. Returns a client secret for frontend payment method collection.`,builder:_,handler:async s=>{if(s.dryRun){a({command:`cf billing profiles createPaymentIntent`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/billing/profile/payment-method`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Creating`,async()=>c.billing.profiles.createPaymentIntent({account_id:l})),{successLabel:`Created`})}};function y(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 b={command:`delete`,describe:`Deletes the billing profile for an account.`,builder:y,handler:async s=>{if(s.dryRun){a({command:`cf billing profiles delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/billing/profile`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await d({force:!!s.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}i(await o(`Deleting`,async()=>c.billing.profiles.delete({account_id:l})),{successLabel:`Deleted`})}};function x(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const S={command:`get`,describe:`Gets the current billing profile for the account.`,builder:x,handler:async s=>{if(s.dryRun){a({command:`cf billing profiles get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/billing/profile`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.billing.profiles.get({account_id:l})),{successLabel:`Loaded`})}};function C(e){return e.option(`address`,{type:`string`,description:`Street address line 1.`}).option(`address2`,{type:`string`,description:`Street address line 2 (apt, suite, etc.).`}).option(`billing-email`,{type:`string`,description:`Primary billing email address.`}).option(`buying-rate-plan`,{type:`string`,description:`Rate plan being purchased right after profile setup.`}).option(`captcha-challenge-jwt`,{type:`string`,description:`Captcha challenge JWT issued during onboarding.`}).option(`cf-turnstile-response`,{type:`string`,description:`Cloudflare Turnstile response.`}).option(`city`,{type:`string`,description:`City on the billing profile.`}).option(`company`,{type:`string`,description:`Company name on the billing profile.`}).option(`country`,{type:`string`,description:`ISO 3166-1 alpha-2 country code.`}).option(`first-name`,{type:`string`,description:`First name on the billing profile.`}).option(`h-captcha-response`,{type:`string`,description:`hCaptcha response.`}).option(`last-name`,{type:`string`,description:`Last name on the billing profile.`}).option(`preferred-locale`,{type:`string`,description:`Preferred locale for invoice rendering (BCP 47).`}).option(`secondary-billing-email`,{type:`string`,description:`Secondary billing email address for CC on invoices.`}).option(`state`,{type:`string`,description:`State or region on the billing profile.`}).option(`tax-id-type`,{type:`string`,description:`Type of tax ID provided.`}).option(`telephone`,{type:`string`,description:`Contact phone number.`}).option(`vat`,{type:`string`,description:`VAT identifier.`}).option(`zipcode`,{type:`string`,description:`ZIP or postal code.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Request body for creating or updating a billing profile.`})}const w={command:`update`,describe:`Updates the billing profile for an account.`,builder:C,handler:async c=>{if(c.dryRun){a({command:`cf billing profiles update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/billing/profile`,pathParams:{},bodyKind:`json`,body:c.body===void 0?l({address:u(c.address,`address`,`text`),address2:u(c.address2,`address2`,`text`),billing_email:u(c[`billing-email`],`billing-email`,`text`),buying_rate_plan:u(c[`buying-rate-plan`],`buying-rate-plan`,`text`),captcha_challenge_jwt:u(c[`captcha-challenge-jwt`],`captcha-challenge-jwt`,`text`),cf_turnstile_response:u(c[`cf-turnstile-response`],`cf-turnstile-response`,`text`),city:u(c.city,`city`,`text`),company:u(c.company,`company`,`text`),country:u(c.country,`country`,`text`),first_name:u(c[`first-name`],`first-name`,`text`),h_captcha_response:u(c[`h-captcha-response`],`h-captcha-response`,`text`),last_name:u(c[`last-name`],`last-name`,`text`),preferred_locale:u(c[`preferred-locale`],`preferred-locale`,`text`),secondary_billing_email:u(c[`secondary-billing-email`],`secondary-billing-email`,`text`),state:u(c.state,`state`,`text`),tax_id_type:u(c[`tax-id-type`],`tax-id-type`,`text`),telephone:u(c.telephone,`telephone`,`text`),vat:u(c.vat,`vat`,`text`),zipcode:u(c.zipcode,`zipcode`,`text`)}):s(c.body)});return}let d=await r(c),f=c.local?e:await t();if(c.accountId=f,c.body){let e=s(c.body);i(await o(`Updating`,async()=>d.billing.profiles.update({body:e,account_id:f})),{successLabel:`Updated`});return}let p=l({address:u(c.address,`address`,`text`),address2:u(c.address2,`address2`,`text`),billing_email:u(c[`billing-email`],`billing-email`,`text`),buying_rate_plan:u(c[`buying-rate-plan`],`buying-rate-plan`,`text`),captcha_challenge_jwt:u(c[`captcha-challenge-jwt`],`captcha-challenge-jwt`,`text`),cf_turnstile_response:u(c[`cf-turnstile-response`],`cf-turnstile-response`,`text`),city:u(c.city,`city`,`text`),company:u(c.company,`company`,`text`),country:u(c.country,`country`,`text`),first_name:u(c[`first-name`],`first-name`,`text`),h_captcha_response:u(c[`h-captcha-response`],`h-captcha-response`,`text`),last_name:u(c[`last-name`],`last-name`,`text`),preferred_locale:u(c[`preferred-locale`],`preferred-locale`,`text`),secondary_billing_email:u(c[`secondary-billing-email`],`secondary-billing-email`,`text`),state:u(c.state,`state`,`text`),tax_id_type:u(c[`tax-id-type`],`tax-id-type`,`text`),telephone:u(c.telephone,`telephone`,`text`),vat:u(c.vat,`vat`,`text`),zipcode:u(c.zipcode,`zipcode`,`text`)});i(await o(`Updating`,async()=>d.billing.profiles.update({body:p,account_id:f})),{successLabel:`Updated`})}};function T(e){return e.option(`billing-email`,{type:`string`,description:`The billing_email field`}).option(`preferred-locale`,{type:`string`,description:`The preferred_locale field`}).option(`secondary-billing-email`,{type:`string`,description:`The secondary_billing_email 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 E={command:`updateEmail`,describe:`Updates the billing email addresses and preferred locale for an account.`,builder:T,handler:async c=>{if(c.dryRun){a({command:`cf billing profiles updateEmail`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/billing/profile`,pathParams:{},bodyKind:`json`,body:c.body===void 0?l({billing_email:u(c[`billing-email`],`billing-email`,`text`),preferred_locale:u(c[`preferred-locale`],`preferred-locale`,`text`),secondary_billing_email:u(c[`secondary-billing-email`],`secondary-billing-email`,`text`)}):s(c.body)});return}let d=await r(c),f=c.local?e:await t();if(c.accountId=f,c.body){let e=s(c.body);i(await o(`Updating`,async()=>d.billing.profiles.updateEmail({...e,account_id:f})),{successLabel:`Updated`});return}let p=l({billing_email:u(c[`billing-email`],`billing-email`,`text`),preferred_locale:u(c[`preferred-locale`],`preferred-locale`,`text`),secondary_billing_email:u(c[`secondary-billing-email`],`secondary-billing-email`,`text`)});i(await o(`Updating`,async()=>d.billing.profiles.updateEmail({...p,account_id:f})),{successLabel:`Updated`})}},D={command:`profiles`,describe:`Billing profile with payment method, address, and invoice preferences`,builder:e=>e.command(g).command(v).command(b).command(S).command(w).command(E).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function O(e){return e.positional(`public-key`,{type:`string`,description:`The public key identifier for the rate plan.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const k={command:`get <public-key>`,describe:`Gets a rate plan's details by its public key (e.g., 'teams_free', 'cf_pro_20_20'). This is a public catalog endpoint, so authentication is not enforced and credentials are accepted but not required.`,builder:O,handler:async e=>{if(e.dryRun){a({command:`cf billing rate-plans get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/billing/rate_plans/${e[`public-key`]==null?`<public-key>`:encodeURIComponent(String(e[`public-key`]))}`,pathParams:{"public-key":String(e[`public-key`]??``)},bodyKind:`none`});return}let t=await r(e);i(await o(`Loading`,async()=>t.billing.ratePlans.get({public_key:e[`public-key`]})),{successLabel:`Loaded`})}},A={command:`rate-plans`,describe:`Operations for rate-plans`,builder:e=>e.command(k).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function j(e){return e.option(`from`,{type:`string`,description:"Start date for the usage query (ISO 8601). Required if `to` is set. When omitted along with `to`, defaults to the start of the current month. Filters by charge period (when consumption happened), not billing period. The maximum date range is 31 days."}).option(`to`,{type:`string`,description:"End date for the usage query (ISO 8601). Required if `from` is set. When omitted along with `from`, defaults to today. Filters by charge period (when consumption happened), not billing period. The maximum date range is 31 days."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`get-account-usage-v2`,describe:"Returns cost and usage data for a single Cloudflare account, aligned with the [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and Usage dataset specification. Each record represents one billable metric for one account on one day. This includes all metered usage, including usage that falls within free-tier allowances and may result in zero cost. **Note:** Cost and pricing fields are not yet populated and will be absent from responses until billing integration is complete. When `from` and `to` are omitted, defaults to the start of the current month through today. The maximum date range is 31 days.",builder:j,handler:async s=>{let c={from:s.from,to:s.to};if(s.dryRun){a({command:`cf billing usage get-account-usage-v2`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/billable/usage`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.billing.usage.getAccountUsageV2({account_id:u,...c})),{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:`get-info-v1`,describe:`Returns high-level usage information for the account, including coverage, and subscription metadata.`,builder:N,handler:async s=>{if(s.dryRun){a({command:`cf billing usage get-info-v1`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/billable-usage/info`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.billing.usage.getInfoV1({account_id:l})),{successLabel:`Loaded`})}};function F(e){return e.option(`from`,{type:`string`,description:`Start date for the usage query (ISO 8601). The provided time range must include the subscription billing cycle anchor day, otherwise no usage data is returned. Use the info endpoint to retrieve the subscription anchor day.`}).option(`to`,{type:`string`,description:`End date for the usage query (ISO 8601).`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const I={command:`get-v1`,describe:`Returns billable usage data for the account. When no query parameters are provided, returns usage for the current billing period.`,builder:F,handler:async s=>{let c={from:s.from,to:s.to};if(s.dryRun){a({command:`cf billing usage get-v1`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/billable-usage`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.billing.usage.getV1({account_id:u,...c})),{successLabel:`Loaded`})}};function L(e){return e.option(`filter-by-metric-ids`,{type:`string`,array:!0,description:"Restrict results to rows whose `x_BillableMetricId` matches one of these billable metric ids (e.g. `workers_standard_requests`). Values must be unique."}).option(`filter-by-product-family-ids`,{type:`string`,array:!0,description:`Restrict results to billable metrics belonging to these product families. Values must be unique UUIDs.`}).option(`group-by`,{type:`string`,description:`Customer resource tags used to split result rows. At most two unique tag keys may be supplied. Provide as a JSON array of objects or @path/to/file.json.`}).option(`time-period-from`,{type:`string`,description:"Start of the range (ISO 8601). Required if `To` is set."}).option(`time-period-to`,{type:`string`,description:"End of the range (ISO 8601). Required if `From` is set. Must be after `From` and no more than 31 days after it."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Filter criteria for a usage query. Every field is optional; an empty object is equivalent to omitting the body entirely. Unknown fields are rejected.`})}const R={command:`query`,describe:"Returns cost and usage data for a single Cloudflare account, aligned with the [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and Usage dataset specification. This is the filterable counterpart to `GET` on the same path. It is a read-only operation and requires only the `#billing:read` permission; `POST` is used so that filter criteria can be supplied in a request body rather than in the query string. Each record represents one billable metric for one account on one day. This includes all metered usage, including usage that falls within free-tier allowances and may result in zero cost. **Note:** Cost and pricing fields are not yet populated and will be absent from responses until billing integration is complete. The request body is optional. When it is omitted, or when `TimePeriod` is omitted, the range defaults to the start of the current month through today. The maximum date range is 31 days. Filters of different kinds are combined with AND. Values within one tag filter are combined with OR. Filter values that do not match usage produce an empty result set. Results can be grouped by up to two customer resource-tag keys. Grouped values are returned in the `Tags` field. Usage without a requested tag remains in an untagged group, with that key omitted from `Tags`. Requests using tag filtering or grouping return HTTP 400 when tag-aware usage data is unavailable.",builder:L,handler:async d=>{if(d.dryRun){a({command:`cf billing usage query`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/billable/usage`,pathParams:{},bodyKind:`json`,body:d.body===void 0?l({FilterBy:{MetricIds:d[`filter-by-metric-ids`],ProductFamilyIds:d[`filter-by-product-family-ids`]},GroupBy:c(d[`group-by`],`group-by`),TimePeriod:{From:u(d[`time-period-from`],`time-period-from`,`text`),To:u(d[`time-period-to`],`time-period-to`,`text`)}}):s(d.body)});return}let f=await r(d),p=d.local?e:await t();if(d.accountId=p,d.body){let e=s(d.body);i(await o(`Loading`,async()=>f.billing.usage.query({...e,account_id:p})),{successLabel:`Loaded`});return}let m=l({FilterBy:{MetricIds:d[`filter-by-metric-ids`],ProductFamilyIds:d[`filter-by-product-family-ids`]},GroupBy:c(d[`group-by`],`group-by`),TimePeriod:{From:u(d[`time-period-from`],`time-period-from`,`text`),To:u(d[`time-period-to`],`time-period-to`,`text`)}});i(await o(`Loading`,async()=>f.billing.usage.query({...m,account_id:p})),{successLabel:`Loaded`})}},z={command:`usage`,describe:`Metered usage data for billed services — requests, bandwidth, and feature consumption`,builder:e=>e.command(M).command(P).command(I).command(R).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},B={command:`billing`,describe:`Account billing profiles and usage data for Cloudflare subscriptions and add-on services`,builder:e=>e.command(m).command(D).command(A).command(z).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{B as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{readFileSync as e}from"node:fs";import{resolve as t}from"node:path";function n(e,t,n){if(t.length===0)return;let r=e;for(let e=0;e<t.length-1;e++){let n=t[e]??``;(!r[n]||typeof r[n]!=`object`)&&(r[n]={}),r=r[n]}let i=t[t.length-1]??``;r[i]=n}function r(e){let t=e=>{if(Array.isArray(e)||typeof e!=`object`||!e)return e;let n=Object.entries(e).flatMap(([e,n])=>{let r=t(n);return r===void 0||typeof r==`object`&&r&&!Array.isArray(r)&&Object.keys(r).length===0?[]:[[e,r]]});return Object.fromEntries(n)};return t(e)}function i(n,r){let i=r.startsWith(`--`)?r:`--${r}`,a=n;if(n.startsWith(`@`)){let r=n.slice(1);if(r.length===0)throw Error(`${i} '@' must be followed by a file path (got empty path)`);let o=t(r);try{a=e(o,`utf-8`)}catch(e){let t=e instanceof Error?e.message:`unknown read error`;throw Error(`${i}: cannot read file at '${r}': ${t}`)}}try{return JSON.parse(a)}catch{throw Error(`Invalid JSON in ${i}. Expected valid JSON.`)}}function a(e){return i(e,`body`)}function o(e,t){if(e===void 0)return;let n=t.startsWith(`--`)?t:`--${t}`;if(typeof e!=`string`)throw Error(`${n} must be provided once as a JSON array of objects.`);let r=i(e,t);if(!Array.isArray(r)||r.some(e=>typeof e!=`object`||!e||Array.isArray(e)))throw Error(`${n} must be a JSON array of objects.`);return r}export{n as i,a as n,o as r,r as t};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{h as e}from"./oauth-DuEONNgC.mjs";import{r as t}from"./auth-D3X9HYhD.mjs";import{t as n}from"./output-Ccqw2WOb.mjs";import{t as r}from"./dry-run-DL2V6yFm.mjs";import{t as i}from"./progress-BqQcF5QH.mjs";import{n as a,t as o}from"./body-parser-BshbixEq.mjs";import{n as s}from"./input-validation-QDIYu7Vb.mjs";import{a as c,i as l}from"./prompt-B0sWIs9c.mjs";function u(e){return e.option(`description`,{type:`string`,description:`The description field`}).option(`expression`,{type:`string`,description:`Wirefilter expression describing the traffic being reported.`}).option(`first-request-seen-at`,{type:`string`,description:`The first_request_seen_at field`}).option(`last-request-seen-at`,{type:`string`,description:`The last_request_seen_at field`}).option(`requests`,{type:`number`,description:`The requests field`}).option(`subtype`,{type:`string`,description:`The subtype field`}).option(`type`,{type:`string`,description:`Type of feedback report.`,choices:[`false_positive`,`false_negative`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const d={command:`create`,describe:"Submit a feedback report for the specified zone. Use `type` to indicate whether the report is a false positive (good traffic flagged as bot) or a false negative (bot traffic missed). Furthermore, you can also use `expression` as a wirefilter to identify the affected traffic sample. See more accepted API fields and expression types at https://developers.cloudflare.com/bots/concepts/feedback-loop/#api-fields and https://developers.cloudflare.com/bots/concepts/feedback-loop/#expression-fields, respectively.",builder:u,handler:async u=>{if(u.dryRun){r({command:`cf bot-management feedback create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${u.zone??u.zoneId??`<zone>`}/bot_management/feedback`,pathParams:{"zone-id":String(u.zone??u[`zone-id`]??``)},bodyKind:`json`,body:u.body===void 0?o({description:s(u.description,`description`,`text`),expression:s(u.expression,`expression`,`text`),first_request_seen_at:s(u[`first-request-seen-at`],`first-request-seen-at`,`text`),last_request_seen_at:s(u[`last-request-seen-at`],`last-request-seen-at`,`text`),requests:u.requests,subtype:s(u.subtype,`subtype`,`text`),type:s(u.type,`type`,`text`)}):a(u.body)});return}let d=await t(u),f=await e({zone:u.zone},d,{quiet:u.quiet});if(u.zoneId=f,u.body){let e=a(u.body);n(await i(`Creating`,async()=>d.botManagement.feedback.create({body:e,zone_id:f})),{successLabel:`Created`});return}if(u.description===void 0&&(u.description=await c(`description`,`The description field`)),u.expression===void 0&&(u.expression=await c(`expression`,`Wirefilter expression describing the traffic being reported.`)),u[`first-request-seen-at`]===void 0&&(u[`first-request-seen-at`]=await c(`first-request-seen-at`,`The first_request_seen_at field`)),u[`last-request-seen-at`]===void 0&&(u[`last-request-seen-at`]=await c(`last-request-seen-at`,`The last_request_seen_at field`)),u.requests===void 0)throw Error(`--requests is required (or pass --body with this field set).`);u.type===void 0&&(u.type=await l(`type`,`Type of feedback report.`,[`false_positive`,`false_negative`]));let p=o({description:s(u.description,`description`,`text`),expression:s(u.expression,`expression`,`text`),first_request_seen_at:s(u[`first-request-seen-at`],`first-request-seen-at`,`text`),last_request_seen_at:s(u[`last-request-seen-at`],`last-request-seen-at`,`text`),requests:u.requests,subtype:s(u.subtype,`subtype`,`text`),type:s(u.type,`type`,`text`)});n(await i(`Creating`,async()=>d.botManagement.feedback.create({body:p,zone_id:f})),{successLabel:`Created`})}};function f(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const p={command:`list`,describe:`Returns all feedback reports previously submitted for the specified zone. Feedback reports help improve detection by sharing samples of traffic that were misclassified as bots or humans.`,builder:f,handler:async a=>{if(a.dryRun){r({command:`cf bot-management feedback list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${a.zone??a.zoneId??`<zone>`}/bot_management/feedback`,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.botManagement.feedback.list({zone_id:s})),{successLabel:`Loaded`})}},m={command:`feedback`,describe:`Operations for feedback`,builder:e=>e.command(d).command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function h(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`get`,describe:`Retrieve a zone's Bot Management Config`,builder:h,handler:async a=>{if(a.dryRun){r({command:`cf bot-management get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${a.zone??a.zoneId??`<zone>`}/bot_management`,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.botManagement.get({zone_id:s})),{successLabel:`Loaded`})}};function _(e){return e.option(`ai-bots-protection`,{type:`string`,description:`Enable rule to block AI Scrapers and Crawlers.`,choices:[`block`,`disabled`,`only_on_ad_pages`]}).option(`bot-preference-sync-enabled`,{type:`boolean`,description:`Enable Bot Preference Sync for this zone. When enabled, Cloudflare can serve robots.txt content derived from the zone's AI Search, AI User, and AI Training preferences.`}).option(`cf-robots-variant`,{type:`string`,description:`Specifies the Robots Access Control License variant to use.`,choices:[`off`,`policy_only`]}).option(`content-bots-protection`,{type:`string`,description:`Enable rule to block content bots. When enabled, blocks automated traffic with low bot scores, excluding safe verified bot categories. Exceptions should be managed via skip rules.`,choices:[`block`,`disabled`]}).option(`crawler-protection`,{type:`string`,description:`Enable rule to punish AI Scrapers and Crawlers via a link maze.`,choices:[`enabled`,`disabled`]}).option(`enable-js`,{type:`boolean`,description:`Use lightweight, invisible JavaScript detections to improve Bot Management. [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/).`}).option(`is-robots-txt-managed`,{type:`boolean`,description:`Enable cloudflare managed robots.txt. If an existing robots.txt is detected, then managed robots.txt will be prepended to the existing robots.txt.`}).option(`fight-mode`,{type:`boolean`,description:`Whether to enable Bot Fight Mode.`}).option(`stale-zone-configuration-optimize-wordpress`,{type:`boolean`,description:`Indicates that the zone's wordpress optimization for SBFM is turned on.`}).option(`stale-zone-configuration-sbfm-definitely-automated`,{type:`string`,description:`Indicates that the zone's definitely automated requests are being blocked or challenged.`}).option(`stale-zone-configuration-sbfm-likely-automated`,{type:`string`,description:`Indicates that the zone's likely automated requests are being blocked or challenged.`}).option(`stale-zone-configuration-sbfm-static-resource-protection`,{type:`string`,description:`Indicates that the zone's static resource protection is turned on.`}).option(`stale-zone-configuration-sbfm-verified-bots`,{type:`string`,description:`Indicates that the zone's verified bot requests are being blocked.`}).option(`stale-zone-configuration-suppress-session-score`,{type:`boolean`,description:`Indicates that the zone's session score tracking is disabled.`}).option(`stale-zone-configuration-fight-mode`,{type:`boolean`,description:`Indicates that the zone's Bot Fight Mode is turned on.`}).option(`optimize-wordpress`,{type:`boolean`,description:`Whether to optimize Super Bot Fight Mode protections for Wordpress.`}).option(`sbfm-definitely-automated`,{type:`string`,description:`Super Bot Fight Mode (SBFM) action to take on definitely automated requests.`,choices:[`allow`,`block`,`managed_challenge`]}).option(`sbfm-static-resource-protection`,{type:`boolean`,description:`Super Bot Fight Mode (SBFM) to enable static resource protection.
|
|
3
|
+
Enable if static resources on your application need bot protection.
|
|
4
|
+
Note: Static resource protection can also result in legitimate traffic being blocked.
|
|
5
|
+
`}).option(`sbfm-verified-bots`,{type:`string`,description:`Super Bot Fight Mode (SBFM) action to take on verified bots requests.`,choices:[`allow`,`block`]}).option(`sbfm-likely-automated`,{type:`string`,description:`Super Bot Fight Mode (SBFM) action to take on likely automated requests.`,choices:[`allow`,`block`,`managed_challenge`]}).option(`auto-update-model`,{type:`boolean`,description:`Automatically update to the newest bot detection models created by Cloudflare as they are released. [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes)`}).option(`bm-cookie-enabled`,{type:`boolean`,description:`Indicates that the bot management cookie can be placed on end user devices accessing the site. Defaults to true`}).option(`suppress-session-score`,{type:`boolean`,description:`Whether to disable tracking the highest bot score for a session in the Bot Management cookie.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const v={command:`update`,describe:'Updates the Bot Management configuration for a zone. This API is used to update: - **Bot Fight Mode** - **Super Bot Fight Mode** - **Bot Management for Enterprise** See [Bot Plans](https://developers.cloudflare.com/bots/plans/) for more information on the different plans \\ If you recently upgraded or downgraded your plan, refer to the following examples to clean up old configurations. Copy and paste the example body to remove old zone configurations based on your current plan. #### Clean up configuration for Bot Fight Mode plan ```json { "sbfm_likely_automated": "allow", "sbfm_definitely_automated": "allow", "sbfm_verified_bots": "allow", "sbfm_static_resource_protection": false, "optimize_wordpress": false, "suppress_session_score": false } ``` #### Clean up configuration for SBFM Pro plan ```json { "sbfm_likely_automated": "allow", "fight_mode": false } ``` #### Clean up configuration for SBFM Biz plan ```json { "fight_mode": false } ``` #### Clean up configuration for BM Enterprise Subscription plan It is strongly recommended that you ensure you have [custom rules](https://developers.cloudflare.com/waf/custom-rules/) in place to protect your zone before disabling the SBFM rules. Without these protections, your zone is vulnerable to attacks. ```json { "sbfm_likely_automated": "allow", "sbfm_definitely_automated": "allow", "sbfm_verified_bots": "allow", "sbfm_static_resource_protection": false, "optimize_wordpress": false, "fight_mode": false } ```',builder:_,handler:async c=>{if(c.dryRun){r({command:`cf bot-management update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${c.zone??c.zoneId??`<zone>`}/bot_management`,pathParams:{"zone-id":String(c.zone??c[`zone-id`]??``)},bodyKind:`json`,body:c.body===void 0?o({ai_bots_protection:s(c[`ai-bots-protection`],`ai-bots-protection`,`text`),bot_preference_sync_enabled:c[`bot-preference-sync-enabled`],cf_robots_variant:s(c[`cf-robots-variant`],`cf-robots-variant`,`text`),content_bots_protection:s(c[`content-bots-protection`],`content-bots-protection`,`text`),crawler_protection:s(c[`crawler-protection`],`crawler-protection`,`text`),enable_js:c[`enable-js`],is_robots_txt_managed:c[`is-robots-txt-managed`],fight_mode:c[`fight-mode`],stale_zone_configuration:{optimize_wordpress:c[`stale-zone-configuration-optimize-wordpress`],sbfm_definitely_automated:s(c[`stale-zone-configuration-sbfm-definitely-automated`],`stale-zone-configuration-sbfm-definitely-automated`,`text`),sbfm_likely_automated:s(c[`stale-zone-configuration-sbfm-likely-automated`],`stale-zone-configuration-sbfm-likely-automated`,`text`),sbfm_static_resource_protection:s(c[`stale-zone-configuration-sbfm-static-resource-protection`],`stale-zone-configuration-sbfm-static-resource-protection`,`text`),sbfm_verified_bots:s(c[`stale-zone-configuration-sbfm-verified-bots`],`stale-zone-configuration-sbfm-verified-bots`,`text`),suppress_session_score:c[`stale-zone-configuration-suppress-session-score`],fight_mode:c[`stale-zone-configuration-fight-mode`]},optimize_wordpress:c[`optimize-wordpress`],sbfm_definitely_automated:s(c[`sbfm-definitely-automated`],`sbfm-definitely-automated`,`text`),sbfm_static_resource_protection:c[`sbfm-static-resource-protection`],sbfm_verified_bots:s(c[`sbfm-verified-bots`],`sbfm-verified-bots`,`text`),sbfm_likely_automated:s(c[`sbfm-likely-automated`],`sbfm-likely-automated`,`text`),auto_update_model:c[`auto-update-model`],bm_cookie_enabled:c[`bm-cookie-enabled`],suppress_session_score:c[`suppress-session-score`]}):a(c.body)});return}let l=await t(c),u=await e({zone:c.zone},l,{quiet:c.quiet});if(c.zoneId=u,c.body){let e=a(c.body);n(await i(`Updating`,async()=>l.botManagement.update({body:e,zone_id:u})),{successLabel:`Updated`});return}let d=o({ai_bots_protection:s(c[`ai-bots-protection`],`ai-bots-protection`,`text`),bot_preference_sync_enabled:c[`bot-preference-sync-enabled`],cf_robots_variant:s(c[`cf-robots-variant`],`cf-robots-variant`,`text`),content_bots_protection:s(c[`content-bots-protection`],`content-bots-protection`,`text`),crawler_protection:s(c[`crawler-protection`],`crawler-protection`,`text`),enable_js:c[`enable-js`],is_robots_txt_managed:c[`is-robots-txt-managed`],fight_mode:c[`fight-mode`],stale_zone_configuration:{optimize_wordpress:c[`stale-zone-configuration-optimize-wordpress`],sbfm_definitely_automated:s(c[`stale-zone-configuration-sbfm-definitely-automated`],`stale-zone-configuration-sbfm-definitely-automated`,`text`),sbfm_likely_automated:s(c[`stale-zone-configuration-sbfm-likely-automated`],`stale-zone-configuration-sbfm-likely-automated`,`text`),sbfm_static_resource_protection:s(c[`stale-zone-configuration-sbfm-static-resource-protection`],`stale-zone-configuration-sbfm-static-resource-protection`,`text`),sbfm_verified_bots:s(c[`stale-zone-configuration-sbfm-verified-bots`],`stale-zone-configuration-sbfm-verified-bots`,`text`),suppress_session_score:c[`stale-zone-configuration-suppress-session-score`],fight_mode:c[`stale-zone-configuration-fight-mode`]},optimize_wordpress:c[`optimize-wordpress`],sbfm_definitely_automated:s(c[`sbfm-definitely-automated`],`sbfm-definitely-automated`,`text`),sbfm_static_resource_protection:c[`sbfm-static-resource-protection`],sbfm_verified_bots:s(c[`sbfm-verified-bots`],`sbfm-verified-bots`,`text`),sbfm_likely_automated:s(c[`sbfm-likely-automated`],`sbfm-likely-automated`,`text`),auto_update_model:c[`auto-update-model`],bm_cookie_enabled:c[`bm-cookie-enabled`],suppress_session_score:c[`suppress-session-score`]});n(await i(`Updating`,async()=>l.botManagement.update({body:d,zone_id:u})),{successLabel:`Updated`})}},y={command:`bot-management`,describe:`bot-management`,builder:e=>e.command(g).command(v).command(m).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{t as e}from"./local-Be3lg_9E.mjs";import{f as t,g as n}from"./oauth-DuEONNgC.mjs";import{r}from"./auth-D3X9HYhD.mjs";import{t as i}from"./output-Ccqw2WOb.mjs";import{t as a}from"./dry-run-DL2V6yFm.mjs";import{t as o}from"./progress-BqQcF5QH.mjs";import{n as s}from"./prompt-B0sWIs9c.mjs";function c(e){return e.positional(`asn-id`,{type:`string`,description:`Asn ID`,demandOption:!0}).option(`date`,{type:`string`,description:`Date`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const l={command:`day-report <asn-id>`,describe:`Gets all the data the botnet tracking database has for a given ASN registered to user account for given date. If no date is given, it will return results for the previous day.`,builder:c,handler:async s=>{let c={date:s.date};if(s.dryRun){a({command:`cf botnet-feed asn day-report`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/botnet_feed/asn/${s[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(s[`asn-id`]))}/day_report`,pathParams:{"asn-id":String(s[`asn-id`]??``)},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.botnetFeed.asn.dayReport({account_id:u,asn_id:s[`asn-id`],...c})),{successLabel:`Loaded`})}};function u(e){return e.positional(`asn-id`,{type:`string`,description:`Asn ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const d={command:`full-report <asn-id>`,describe:`Gets all the data the botnet threat feed tracking database has for a given ASN registered to user account.`,builder:u,handler:async s=>{if(s.dryRun){a({command:`cf botnet-feed asn full-report`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/botnet_feed/asn/${s[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(s[`asn-id`]))}/full_report`,pathParams:{"asn-id":String(s[`asn-id`]??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.botnetFeed.asn.fullReport({account_id:l,asn_id:s[`asn-id`]})),{successLabel:`Loaded`})}},f={command:`asn`,describe:`Operations for asn`,builder:e=>e.command(l).command(d).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function p(e){return e.positional(`asn-id`,{type:`string`,description:`Asn ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const m={command:`delete <asn-id>`,describe:`Delete an ASN from botnet threat feed for a given user.`,builder:p,handler:async c=>{if(c.dryRun){a({command:`cf botnet-feed configs asn delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/botnet_feed/configs/asn/${c[`asn-id`]==null?`<asn-id>`:encodeURIComponent(String(c[`asn-id`]))}`,pathParams:{"asn-id":String(c[`asn-id`]??``)},bodyKind:`none`});return}let l=await r(c),u=c.local?e:await t();if(c.accountId=u,!await s({force:!!c.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}i(await o(`Deleting`,async()=>l.botnetFeed.configs.asn.delete({account_id:u,asn_id:c[`asn-id`]})),{successLabel:`Deleted`})}};function h(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`get`,describe:`Gets a list of all ASNs registered for a user for the DDoS Botnet Feed API.`,builder:h,handler:async s=>{if(s.dryRun){a({command:`cf botnet-feed configs asn get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/botnet_feed/configs/asn`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.botnetFeed.configs.asn.get({account_id:l})),{successLabel:`Loaded`})}},_={command:`asn`,describe:`Operations for configs.asn`,builder:e=>e.command(m).command(g).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},v={command:`configs`,describe:`Operations for configs`,builder:e=>e.command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},y={command:`botnet-feed`,describe:`botnet-feed`,builder:e=>e.command(f).command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{t as e}from"./local-Be3lg_9E.mjs";import{f as t,g as n}from"./oauth-DuEONNgC.mjs";import{r}from"./auth-D3X9HYhD.mjs";import{t as i}from"./output-Ccqw2WOb.mjs";import{t as a}from"./dry-run-DL2V6yFm.mjs";import{t as o}from"./progress-BqQcF5QH.mjs";import{n as s,t as c}from"./body-parser-BshbixEq.mjs";import{n as l}from"./input-validation-QDIYu7Vb.mjs";import{a as u,n as d}from"./prompt-B0sWIs9c.mjs";import{t as f}from"./cli-types-DAYeL_Mj.mjs";function p(e){return e.option(`show-historic`,{type:`string`,description:`Include scanned images without domain metadata (historic data). Default: false (only show images with domain)`}).option(`download`,{type:`string`,description:`If true, include base64-encoded image data in the response`}).option(`image-data`,{type:`string`,description:`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`}).option(`score-threshold`,{type:`number`,description:`Minimum similarity score threshold for matches (0-1, default: 0)`,default:0}).option(`top-k`,{type:`number`,description:`Number of closest matches to return (1-100, default: 10)`,default:10}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const m={command:`submit`,describe:`Submit an image and find the n closest matches from the scanned images index without creating any match records. Returns similarity scores and metadata for each match.`,builder:p,handler:async d=>{let f={showHistoric:d[`show-historic`],download:d.download};if(d.dryRun){a({command:`cf brand-protection submit`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/search`,pathParams:{},query:f,bodyKind:`json`,body:d.body===void 0?c({image_data:l(d[`image-data`],`image-data`,`text`),score_threshold:d[`score-threshold`],top_k:d[`top-k`]}):s(d.body)});return}let p=await r(d),m=d.local?e:await t();if(d.accountId=m,d.body){let e=s(d.body);new URLSearchParams(Object.entries(f).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),i(await o(`Creating`,async()=>p.brandProtection.submit({...e,account_id:m,...f})),{successLabel:`Created`});return}d[`image-data`]===void 0&&(d[`image-data`]=await u(`image-data`,`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`));let h=c({image_data:l(d[`image-data`],`image-data`,`text`),score_threshold:d[`score-threshold`],top_k:d[`top-k`]});new URLSearchParams(Object.entries(f).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),i(await o(`Creating`,async()=>p.brandProtection.submit({...h,account_id:m,...f})),{successLabel:`Created`})}};function h(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`url-info`,describe:`Get the total number of saved brand protection queries (domain + logo) for an account`,builder:h,handler:async s=>{if(s.dryRun){a({command:`cf brand-protection url-info`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/cloudforce-one/v2/brand-protection/total-queries`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.brandProtection.urlInfo({account_id:l})),{successLabel:`Loaded`})}};function _(e){return e.option(`offset`,{type:`string`,description:`Offset`}).option(`limit`,{type:`string`,description:`Limit`}).option(`query-id`,{type:`string`,description:`Query ID`,demandOption:!0}).option(`download`,{type:`string`,description:`Download`}).option(`order-by`,{type:`string`,description:`Column to sort by. Options: 'matchedAt', 'domain', 'similarityScore', or 'registrar'`,choices:[`matchedAt`,`domain`,`similarityScore`,`registrar`]}).option(`order`,{type:`string`,description:`Sort order. Options: 'asc' (ascending) or 'desc' (descending)`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const v={command:`get`,describe:`Get paginated list of logo matches for a specific brand protection logo query`,builder:f(_),handler:async s=>{let c={offset:s.offset,limit:s.limit,query_id:s[`query-id`],download:s.download,orderBy:s[`order-by`],order:s.order};if(s.dryRun){a({command:`cf brand-protection v2 logo-matches get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/matches`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.brandProtection.v2.logoMatches.get({account_id:u,...c})),{successLabel:`Loaded`})}},y={command:`logo-matches`,describe:`Operations for v2.logo-matches`,builder:e=>e.command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function b(e){return e.option(`image-data`,{type:`string`,description:`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`}).option(`search-lookback`,{type:`boolean`,description:`If true, search historic scanned images for matches above the similarity threshold`,default:!0}).option(`similarity-threshold`,{type:`number`,description:`Minimum similarity score (0-1) required for visual matches`}).option(`tag`,{type:`string`,description:`Unique identifier for the logo query`}).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:`create`,describe:`Create a new saved brand protection logo query for visual similarity matching`,builder:b,handler:async d=>{if(d.dryRun){a({command:`cf brand-protection v2 logos create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/queries`,pathParams:{},bodyKind:`json`,body:d.body===void 0?c({image_data:l(d[`image-data`],`image-data`,`text`),search_lookback:d[`search-lookback`],similarity_threshold:d[`similarity-threshold`],tag:l(d.tag,`tag`,`text`)}):s(d.body)});return}let f=await r(d),p=d.local?e:await t();if(d.accountId=p,d.body){let e=s(d.body);i(await o(`Creating`,async()=>f.brandProtection.v2.logos.create({...e,account_id:p})),{successLabel:`Created`});return}if(d[`image-data`]===void 0&&(d[`image-data`]=await u(`image-data`,`Base64 encoded image data. Can include data URI prefix (e.g., 'data:image/png;base64,...') or just the base64 string.`)),d[`similarity-threshold`]===void 0)throw Error(`--similarity-threshold is required (or pass --body with this field set).`);d.tag===void 0&&(d.tag=await u(`tag`,`Unique identifier for the logo query`));let m=c({image_data:l(d[`image-data`],`image-data`,`text`),search_lookback:d[`search-lookback`],similarity_threshold:d[`similarity-threshold`],tag:l(d.tag,`tag`,`text`)});i(await o(`Creating`,async()=>f.brandProtection.v2.logos.create({...m,account_id:p})),{successLabel:`Created`})}};function S(e){return e.positional(`query-id`,{type:`string`,description:`Query 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 C={command:`delete <query-id>`,describe:`Delete a saved brand protection logo query. Returns 404 if the query ID doesn't exist.`,builder:S,handler:async s=>{if(s.dryRun){a({command:`cf brand-protection v2 logos delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/queries/${s[`query-id`]==null?`<query-id>`:encodeURIComponent(String(s[`query-id`]))}`,pathParams:{"query-id":String(s[`query-id`]??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await d({force:!!s.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}i(await o(`Deleting`,async()=>c.brandProtection.v2.logos.delete({account_id:l,query_id:s[`query-id`]})),{successLabel:`Deleted`})}};function w(e){return e.option(`id`,{type:`string`,description:`Optional query ID to retrieve a specific logo query`}).option(`download`,{type:`string`,description:`If true, include base64-encoded image data in the response`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`get`,describe:`Get all saved brand protection logo queries for an account. Optionally specify id to get a single query. Set download=true to include base64-encoded image data.`,builder:w,handler:async s=>{let c={id:s.id,download:s.download};if(s.dryRun){a({command:`cf brand-protection v2 logos get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/cloudforce-one/v2/brand-protection/logo/queries`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.brandProtection.v2.logos.get({account_id:u,...c})),{successLabel:`Loaded`})}},E={command:`logos`,describe:`Operations for v2.logos`,builder:e=>e.command(x).command(C).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`offset`,{type:`string`,description:`Offset`}).option(`limit`,{type:`string`,description:`Limit`}).option(`query-id`,{type:`string`,description:`Query ID or comma-separated list of Query IDs. When multiple IDs are provided, matches are deduplicated across queries and each match includes a match_details array with per-match query metadata and dismissed state.`,demandOption:!0}).option(`include-domain-id`,{type:`string`,description:`Include domain ID`}).option(`include-dismissed`,{type:`string`,description:`Include dismissed`}).option(`domain-search`,{type:`string`,description:`Filter matches by domain name (substring match)`}).option(`order-by`,{type:`string`,description:`Column to sort by. Options: 'domain', 'first_seen', or 'registrar'`,choices:[`domain`,`first_seen`,`registrar`]}).option(`order`,{type:`string`,description:`Sort order. Options: 'asc' (ascending) or 'desc' (descending)`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const O={command:`get`,describe:`Get paginated list of domain matches for one or more brand protection queries. When multiple query_ids are provided (comma-separated), matches are deduplicated across queries and each match includes a match_details array with per-match query metadata and individual dismissed state.`,builder:f(D),handler:async s=>{let c={offset:s.offset,limit:s.limit,query_id:s[`query-id`],include_domain_id:s[`include-domain-id`],include_dismissed:s[`include-dismissed`],domain_search:s[`domain-search`],orderBy:s[`order-by`],order:s.order};if(s.dryRun){a({command:`cf brand-protection v2 matches get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/cloudforce-one/v2/brand-protection/domain/matches`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.brandProtection.v2.matches.get({account_id:u,...c})),{successLabel:`Loaded`})}},k={command:`matches`,describe:`Operations for v2.matches`,builder:e=>e.command(O).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function A(e){return e.option(`id`,{type:`string`,description:`ID`}).option(`page`,{type:`number`,description:`Optional page number for paginated list requests. Defaults to 1 when only per_page is supplied. Omit page and per_page to preserve the legacy full-list response.`}).option(`per-page`,{type:`number`,description:`Optional number of queries per page for paginated list requests. Defaults to 100 when only page is supplied. Maximum 100. Omit page and per_page to preserve the legacy full-list response.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const j={command:`get`,describe:`Get all saved brand protection queries for an account`,builder:A,handler:async s=>{let c={id:s.id,page:s.page,per_page:s[`per-page`]};if(s.dryRun){a({command:`cf brand-protection v2 queries get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/cloudforce-one/v2/brand-protection/domain/queries`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.brandProtection.v2.queries.get({account_id:u,...c})),{successLabel:`Loaded`})}},M={command:`queries`,describe:`Operations for v2.queries`,builder:e=>e.command(j).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},N={command:`v2`,describe:`Operations for v2`,builder:e=>e.command(y).command(E).command(k).command(M).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},P={command:`brand-protection`,describe:`brand-protection`,builder:e=>e.command(m).command(g).command(N).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{P as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{t as e}from"./local-
|
|
2
|
+
import{t as e}from"./local-Be3lg_9E.mjs";import{f as t,g as n}from"./oauth-DuEONNgC.mjs";import{r}from"./auth-D3X9HYhD.mjs";import{t as i}from"./output-Ccqw2WOb.mjs";import{t as a}from"./dry-run-DL2V6yFm.mjs";import{t as o}from"./progress-BqQcF5QH.mjs";import{n as s,t as c}from"./body-parser-BshbixEq.mjs";import{n as l}from"./input-validation-QDIYu7Vb.mjs";import{a as u,n as d}from"./prompt-B0sWIs9c.mjs";function f(e){return e.option(`config-min-extension-version`,{type:`string`,description:`Minimum required browser extension version.`}).option(`config-mode`,{type:`string`,description:`The config.mode field`,choices:[`proxy`],default:`proxy`}).option(`config-proxy-url`,{type:`string`,description:`PAC script URL for proxy configuration.`}).option(`config-team-domain`,{type:`string`,description:`Team domain for the browser extension.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const p={command:`create`,describe:`Creates the browser extension configuration for an account.`,builder:f,handler:async d=>{if(d.dryRun){a({command:`cf browser-extension config create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-extension/config`,pathParams:{},bodyKind:`json`,body:d.body===void 0?c({config:{min_extension_version:l(d[`config-min-extension-version`],`config-min-extension-version`,`text`),mode:l(d[`config-mode`],`config-mode`,`text`),proxy_url:l(d[`config-proxy-url`],`config-proxy-url`,`text`),team_domain:l(d[`config-team-domain`],`config-team-domain`,`text`)}}):s(d.body)});return}let f=await r(d),p=d.local?e:await t();if(d.accountId=p,d.body){let e=s(d.body);i(await o(`Creating`,async()=>f.browserExtension.config.create({...e,account_id:p})),{successLabel:`Created`});return}d[`config-proxy-url`]===void 0&&(d[`config-proxy-url`]=await u(`config-proxy-url`,`PAC script URL for proxy configuration.`)),d[`config-team-domain`]===void 0&&(d[`config-team-domain`]=await u(`config-team-domain`,`Team domain for the browser extension.`));let m=c({config:{min_extension_version:l(d[`config-min-extension-version`],`config-min-extension-version`,`text`),mode:l(d[`config-mode`],`config-mode`,`text`),proxy_url:l(d[`config-proxy-url`],`config-proxy-url`,`text`),team_domain:l(d[`config-team-domain`],`config-team-domain`,`text`)}});i(await o(`Creating`,async()=>f.browserExtension.config.create({...m,account_id:p})),{successLabel:`Created`})}};function m(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 h={command:`delete`,describe:`Deletes the browser extension configuration for an account. The shard mapping is preserved and not deleted.`,builder:m,handler:async s=>{if(s.dryRun){a({command:`cf browser-extension config delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-extension/config`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await d({force:!!s.force})){process.stderr.write(`Aborted.
|
|
3
3
|
`);return}i(await o(`Deleting`,async()=>c.browserExtension.config.delete({account_id:l})),{successLabel:`Deleted`})}};function g(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get`,describe:`Returns the browser extension configuration for an account.`,builder:g,handler:async s=>{if(s.dryRun){a({command:`cf browser-extension config get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-extension/config`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.browserExtension.config.get({account_id:l})),{successLabel:`Loaded`})}};function v(e){return e.option(`config-min-extension-version`,{type:`string`,description:`Minimum required browser extension version.`}).option(`config-mode`,{type:`string`,description:`The config.mode field`,choices:[`proxy`]}).option(`config-proxy-url`,{type:`string`,description:`PAC script URL for proxy configuration.`}).option(`config-team-domain`,{type:`string`,description:`Team domain for the browser extension.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const y={command:`update`,describe:`Replaces the browser extension configuration for an account. The configuration must already exist. The shard mapping is immutable.`,builder:v,handler:async d=>{if(d.dryRun){a({command:`cf browser-extension config update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-extension/config`,pathParams:{},bodyKind:`json`,body:d.body===void 0?c({config:{min_extension_version:l(d[`config-min-extension-version`],`config-min-extension-version`,`text`),mode:l(d[`config-mode`],`config-mode`,`text`),proxy_url:l(d[`config-proxy-url`],`config-proxy-url`,`text`),team_domain:l(d[`config-team-domain`],`config-team-domain`,`text`)}}):s(d.body)});return}let f=await r(d),p=d.local?e:await t();if(d.accountId=p,d.body){let e=s(d.body);i(await o(`Updating`,async()=>f.browserExtension.config.update({...e,account_id:p})),{successLabel:`Updated`});return}d[`config-proxy-url`]===void 0&&(d[`config-proxy-url`]=await u(`config-proxy-url`,`PAC script URL for proxy configuration.`)),d[`config-team-domain`]===void 0&&(d[`config-team-domain`]=await u(`config-team-domain`,`Team domain for the browser extension.`));let m=c({config:{min_extension_version:l(d[`config-min-extension-version`],`config-min-extension-version`,`text`),mode:l(d[`config-mode`],`config-mode`,`text`),proxy_url:l(d[`config-proxy-url`],`config-proxy-url`,`text`),team_domain:l(d[`config-team-domain`],`config-team-domain`,`text`)}});i(await o(`Updating`,async()=>f.browserExtension.config.update({...m,account_id:p})),{successLabel:`Updated`})}},b={command:`config`,describe:`Operations for config`,builder:e=>e.command(p).command(h).command(_).command(y).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},x={command:`browser-extension`,describe:`browser-extension`,builder:e=>e.command(b).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{x as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{t as e}from"./local-Be3lg_9E.mjs";import{f as t,g as n}from"./oauth-DuEONNgC.mjs";import{a as r,r as i}from"./auth-D3X9HYhD.mjs";import{t as a}from"./output-Ccqw2WOb.mjs";import{t as o}from"./dry-run-DL2V6yFm.mjs";import{t as s}from"./progress-BqQcF5QH.mjs";import{i as c,n as l,r as u,t as d}from"./body-parser-BshbixEq.mjs";import{n as f}from"./input-validation-QDIYu7Vb.mjs";import{n as p}from"./prompt-B0sWIs9c.mjs";import{t as m}from"./cli-types-DAYeL_Mj.mjs";import{n as h,t as g}from"./raw-fetch-Cc-MjHeL.mjs";function _(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).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:`create`,describe:"Starts a crawl job for the provided URL and its children. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.",builder:_,handler:async c=>{let u={cacheTTL:c[`cache-ttl`]};if(c.dryRun){o({command:`cf browser-run crawl create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/crawl`,pathParams:{},query:u,bodyKind:`json`,body:c.body===void 0?void 0:l(c.body)});return}let d=await i(c),f=c.local?e:await t();if(c.accountId=f,c.body){let e=l(c.body);new URLSearchParams(Object.entries(u).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>d.browserRun.crawl.create({body:e,account_id:f,...u})),{successLabel:`Created`});return}a(await s(`Creating`,async()=>r(d,`POST`,`/accounts/${f}/browser-rendering/crawl`,{query:u})),{successLabel:`Created`})}};function ee(e){return e.positional(`job-id`,{type:`string`,description:`The ID of the crawl job to cancel.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const y={command:`delete <job-id>`,describe:`Cancels an ongoing crawl job by setting its status to cancelled and stopping all queued URLs.`,builder:ee,handler:async r=>{if(r.dryRun){o({command:`cf browser-run crawl delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/crawl/${r[`job-id`]==null?`<job-id>`:encodeURIComponent(String(r[`job-id`]))}`,pathParams:{"job-id":String(r[`job-id`]??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();if(r.accountId=l,!await p({force:!!r.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}a(await s(`Deleting`,async()=>c.browserRun.crawl.delete({account_id:l,job_id:r[`job-id`]})),{successLabel:`Deleted`})}};function b(e){return e.positional(`job-id`,{type:`string`,description:`Crawl job ID.`,demandOption:!0}).option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`status`,{type:`string`,description:`Filter by URL status.`,choices:[`queued`,`errored`,`completed`,`disallowed`,`skipped`,`cancelled`]}).option(`cursor`,{type:`number`,description:`Cursor for pagination.`}).option(`limit`,{type:`number`,description:`Limit for pagination.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const x={command:`get <job-id>`,describe:`Returns the result of a crawl job.`,builder:m(b),handler:async r=>{let c={cacheTTL:r[`cache-ttl`],status:r.status,cursor:r.cursor,limit:r.limit};if(r.dryRun){o({command:`cf browser-run crawl get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/crawl/${r[`job-id`]==null?`<job-id>`:encodeURIComponent(String(r[`job-id`]))}`,pathParams:{"job-id":String(r[`job-id`]??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.browserRun.crawl.get({account_id:u,job_id:r[`job-id`],...c})),{successLabel:`Loaded`})}},S={command:`crawl`,describe:`Operations for crawl`,builder:e=>e.command(v).command(y).command(x).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function C(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID to connect to.`,demandOption:!0}).option(`keep-alive`,{type:`number`,description:`Keep-alive time in ms (only valid when acquiring new session).`}).option(`lab`,{type:`boolean`,description:`Use experimental browser.`}).option(`recording`,{type:`boolean`,description:`Recording`}).option(`cf-brapi-guardrails`,{type:`string`,description:`Optional base64url-encoded JSON connection guardrails (mode)`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const w={command:`connect <session-id>`,describe:`Establishes a WebSocket connection to an existing browser session.`,builder:C,handler:async c=>{let l={keep_alive:c[`keep-alive`],lab:c.lab,recording:c.recording},u={};if(c[`cf-brapi-guardrails`]!==void 0&&(u[`cf-brapi-guardrails`]=String(c[`cf-brapi-guardrails`])),c.dryRun){o({command:`cf browser-run devtools browser connect`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${c[`session-id`]==null?`<session-id>`:encodeURIComponent(String(c[`session-id`]))}`,pathParams:{"session-id":String(c[`session-id`]??``)},query:l,bodyKind:`none`});return}let d=await i(c),f=c.local?e:await t();c.accountId=f,a(await s(`Loading`,async()=>r(d,`GET`,`/accounts/${f}/browser-rendering/devtools/browser/${encodeURIComponent(String(c[`session-id`]))}`,{query:l,headers:Object.keys(u).length>0?u:void 0})),{successLabel:`Loaded`})}};function T(e){return e.option(`keep-alive`,{type:`number`,description:`Keep-alive time in milliseconds.`}).option(`lab`,{type:`boolean`,description:`Use experimental browser.`}).option(`targets`,{type:`boolean`,description:`Include browser targets in response.`}).option(`live-view-url-expires-in-ms`,{type:`number`,description:`How long the live view URL remains valid, in milliseconds (max 60 minutes). Only used when targets is true.`}).option(`recording`,{type:`boolean`,description:`Recording`}).option(`guardrails-allowed-domain-sets`,{type:`string`,array:!0,description:`Max 4 entries: curated preset names (common-cdns) and/or https URLs of newline-separated hostname lists.`}).option(`guardrails-allowed-domains`,{type:`string`,array:!0,description:`Hostname patterns, max 50. Supports exact hosts (example.com) or a single * wildcard anywhere. Prefer *.example.com (subdomain wildcard) over *example.com (prefix wildcard) to avoid matching overbroad lookalikes like evilexample.com.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const E={command:`create`,describe:`Acquires a browser and returns its session ID and websocket URL. Optionally accepts a JSON body with session guardrails to restrict outbound HTTP/S traffic.`,builder:T,handler:async r=>{let c={keep_alive:r[`keep-alive`],lab:r.lab,targets:r.targets,liveViewUrlExpiresInMs:r[`live-view-url-expires-in-ms`],recording:r.recording};if(r.dryRun){o({command:`cf browser-run devtools browser create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser`,pathParams:{},query:c,bodyKind:`json`,body:r.body===void 0?d({guardrails:{allowedDomainSets:r[`guardrails-allowed-domain-sets`],allowedDomains:r[`guardrails-allowed-domains`]}}):l(r.body)});return}let u=await i(r),f=r.local?e:await t();if(r.accountId=f,r.body){let e=l(r.body);new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>u.browserRun.devtools.browser.create({...e,account_id:f,...c})),{successLabel:`Created`});return}let p=d({guardrails:{allowedDomainSets:r[`guardrails-allowed-domain-sets`],allowedDomains:r[`guardrails-allowed-domains`]}});new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>u.browserRun.devtools.browser.create({...p,account_id:f,...c})),{successLabel:`Created`})}};function D(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID to close.`,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 O={command:`delete <session-id>`,describe:`Closes an existing browser session.`,builder:D,handler:async r=>{if(r.dryRun){o({command:`cf browser-run devtools browser delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}`,pathParams:{"session-id":String(r[`session-id`]??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();if(r.accountId=l,!await p({force:!!r.force})){process.stderr.write(`Aborted.
|
|
4
|
+
`);return}a(await s(`Deleting`,async()=>c.browserRun.devtools.browser.delete({account_id:l,session_id:r[`session-id`]})),{successLabel:`Deleted`})}};function k(e){return e.option(`keep-alive`,{type:`number`,description:`Keep-alive time in ms (only valid when acquiring new session).`}).option(`lab`,{type:`boolean`,description:`Use experimental browser.`}).option(`recording`,{type:`boolean`,description:`Recording`}).option(`cf-brapi-guardrails`,{type:`string`,description:`Optional base64url-encoded JSON session guardrails (allowedDomains and allowedDomainSets)`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`launch`,describe:'Acquires and establishes a WebSocket connection to a browser session. Session guardrails may be supplied in the `cf-brapi-guardrails` header as base64url-encoded JSON of the same `guardrails` object the POST body accepts (for example `{"allowedDomains":["*.example.com"]}`).',builder:k,handler:async c=>{let l={keep_alive:c[`keep-alive`],lab:c.lab,recording:c.recording},u={};if(c[`cf-brapi-guardrails`]!==void 0&&(u[`cf-brapi-guardrails`]=String(c[`cf-brapi-guardrails`])),c.dryRun){o({command:`cf browser-run devtools browser launch`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser`,pathParams:{},query:l,bodyKind:`none`});return}let d=await i(c),f=c.local?e:await t();c.accountId=f,a(await s(`Loading`,async()=>r(d,`GET`,`/accounts/${f}/browser-rendering/devtools/browser`,{query:l,headers:Object.keys(u).length>0?u:void 0})),{successLabel:`Loaded`})}};function j(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID`,demandOption:!0}).option(`expires-in-ms`,{type:`number`,description:`How long the live view URLs remain valid, in milliseconds. Default: 5 minutes. Max: 60 minutes.`,default:3e5}).option(`guardrails-mode`,{type:`string`,description:`The guardrails.mode field`,choices:[`readonly`]}).option(`target-id`,{type:`string`,description:`Target ID (page) to connect to. If omitted, auto-resolves to the first active page.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`guardrails-mode`].some(t=>e[t]!==void 0)){let t=[`guardrails-mode`].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 --guardrails-* flag is set`)}return!0})}const M={command:`create <session-id>`,describe:"Generates time-limited URLs to view a remote browser session. Set `guardrails: { mode: 'readonly' }` to create a view-only link.",builder:j,handler:async r=>{if(r.dryRun){o({command:`cf browser-run devtools browser live-view create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}/live_view`,pathParams:{"session-id":String(r[`session-id`]??``)},bodyKind:`json`,body:r.body===void 0?d({expiresInMs:r[`expires-in-ms`],guardrails:{mode:f(r[`guardrails-mode`],`guardrails-mode`,`text`)},targetId:f(r[`target-id`],`target-id`,`text`)}):l(r.body)});return}let c=await i(r),u=r.local?e:await t();if(r.accountId=u,r.body){let e=l(r.body);a(await s(`Creating`,async()=>c.browserRun.devtools.browser.liveView.create({...e,account_id:u,session_id:r[`session-id`]})),{successLabel:`Created`});return}let p=d({expiresInMs:r[`expires-in-ms`],guardrails:{mode:f(r[`guardrails-mode`],`guardrails-mode`,`text`)},targetId:f(r[`target-id`],`target-id`,`text`)});a(await s(`Creating`,async()=>c.browserRun.devtools.browser.liveView.create({...p,account_id:u,session_id:r[`session-id`]})),{successLabel:`Created`})}},N={command:`live-view`,describe:`Operations for devtools.browser.live-view`,builder:e=>e.command(M).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function P(e){return e.positional(`target-id`,{type:`string`,description:`Target ID, e.g. page ID.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`cf-brapi-guardrails`,{type:`string`,description:`Optional base64url-encoded JSON connection guardrails (mode)`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const F={command:`get <target-id>`,describe:`Establishes a WebSocket connection to a specific Chrome DevTools target or page.`,builder:P,handler:async c=>{let l={};if(c[`cf-brapi-guardrails`]!==void 0&&(l[`cf-brapi-guardrails`]=String(c[`cf-brapi-guardrails`])),c.dryRun){o({command:`cf browser-run devtools browser page get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${c[`session-id`]==null?`<session-id>`:encodeURIComponent(String(c[`session-id`]))}/page/${c[`target-id`]==null?`<target-id>`:encodeURIComponent(String(c[`target-id`]))}`,pathParams:{"session-id":String(c[`session-id`]??``),"target-id":String(c[`target-id`]??``)},bodyKind:`none`});return}let u=await i(c),d=c.local?e:await t();c.accountId=d,a(await s(`Loading`,async()=>r(u,`GET`,`/accounts/${d}/browser-rendering/devtools/browser/${encodeURIComponent(String(c[`session-id`]))}/page/${encodeURIComponent(String(c[`target-id`]))}`,{headers:Object.keys(l).length>0?l:void 0})),{successLabel:`Loaded`})}},I={command:`page`,describe:`Operations for devtools.browser.page`,builder:e=>e.command(F).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function L(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const R={command:`protocol <session-id>`,describe:`Returns the complete Chrome DevTools Protocol schema including all domains, commands, events, and types. This schema describes the entire CDP API surface.`,builder:L,handler:async r=>{if(r.dryRun){o({command:`cf browser-run devtools browser protocol`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}/json/protocol`,pathParams:{"session-id":String(r[`session-id`]??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.browserRun.devtools.browser.protocol({account_id:l,session_id:r[`session-id`]})),{successLabel:`Loaded`})}};function z(e){return e.positional(`target-id`,{type:`string`,description:`Target ID to activate.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const B={command:`activate <target-id>`,describe:`Activates (brings to front) a specific browser target by its ID.`,builder:z,handler:async r=>{if(r.dryRun){o({command:`cf browser-run devtools browser targets activate`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}/json/activate/${r[`target-id`]==null?`<target-id>`:encodeURIComponent(String(r[`target-id`]))}`,pathParams:{"session-id":String(r[`session-id`]??``),"target-id":String(r[`target-id`]??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.browserRun.devtools.browser.targets.activate({account_id:l,session_id:r[`session-id`],target_id:r[`target-id`]})),{successLabel:`Loaded`})}};function V(e){return e.positional(`target-id`,{type:`string`,description:`Target ID to close.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const H={command:`close <target-id>`,describe:`Closes a specific browser target (tab, page, etc.) by its ID. Returns 'Target is closing' on success or an error if the target is not found.`,builder:V,handler:async r=>{if(r.dryRun){o({command:`cf browser-run devtools browser targets close`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}/json/close/${r[`target-id`]==null?`<target-id>`:encodeURIComponent(String(r[`target-id`]))}`,pathParams:{"session-id":String(r[`session-id`]??``),"target-id":String(r[`target-id`]??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.browserRun.devtools.browser.targets.close({account_id:l,session_id:r[`session-id`],target_id:r[`target-id`]})),{successLabel:`Loaded`})}};function U(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`url`,{type:`string`,description:`Url`}).option(`live-view-url-expires-in-ms`,{type:`number`,description:`How long the live view URL remains valid, in milliseconds (max 60 minutes)`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const W={command:`create <session-id>`,describe:`Opens a new tab in the browser. Optionally specify a URL to navigate to.`,builder:U,handler:async r=>{let c={url:r.url,liveViewUrlExpiresInMs:r[`live-view-url-expires-in-ms`]};if(r.dryRun){o({command:`cf browser-run devtools browser targets create`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}/json/new`,pathParams:{"session-id":String(r[`session-id`]??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Updating`,async()=>l.browserRun.devtools.browser.targets.create({account_id:u,session_id:r[`session-id`],...c})),{successLabel:`Updated`})}};function G(e){return e.positional(`target-id`,{type:`string`,description:`Target ID.`,demandOption:!0}).option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const K={command:`get <target-id>`,describe:`Returns the debuggable target with the given ID.`,builder:G,handler:async r=>{if(r.dryRun){o({command:`cf browser-run devtools browser targets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}/json/list/${r[`target-id`]==null?`<target-id>`:encodeURIComponent(String(r[`target-id`]))}`,pathParams:{"session-id":String(r[`session-id`]??``),"target-id":String(r[`target-id`]??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.browserRun.devtools.browser.targets.get({account_id:l,session_id:r[`session-id`],target_id:r[`target-id`]})),{successLabel:`Loaded`})}};function te(e){return e.option(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`live-view-url-expires-in-ms`,{type:`number`,description:`How long the live view URLs remain valid, in milliseconds (max 60 minutes)`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const q={command:`list`,describe:`Returns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts.`,builder:te,handler:async r=>{let c={liveViewUrlExpiresInMs:r[`live-view-url-expires-in-ms`]};if(r.dryRun){o({command:`cf browser-run devtools browser targets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}/json/list`,pathParams:{"session-id":String(r[`session-id`]??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.browserRun.devtools.browser.targets.list({account_id:u,session_id:r[`session-id`],...c})),{successLabel:`Loaded`})}},J={command:`targets`,describe:`Operations for devtools.browser.targets`,builder:e=>e.command(B).command(H).command(W).command(K).command(q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Y(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const X={command:`version <session-id>`,describe:`Get browser version metadata.`,builder:Y,handler:async r=>{if(r.dryRun){o({command:`cf browser-run devtools browser version`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}/json/version`,pathParams:{"session-id":String(r[`session-id`]??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.browserRun.devtools.browser.version({account_id:l,session_id:r[`session-id`]})),{successLabel:`Loaded`})}},Z={command:`browser`,describe:`Operations for devtools.browser`,builder:e=>e.command(w).command(E).command(O).command(A).command(R).command(X).command(N).command(I).command(J).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Q(e){return e.positional(`session-id`,{type:`string`,description:`Browser session ID.`,demandOption:!0}).option(`live-view-url-expires-in-ms`,{type:`number`,description:`How long the live view URLs remain valid, in milliseconds (max 60 minutes)`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ne={command:`get <session-id>`,describe:`Returns a list of all debuggable targets including tabs, pages, service workers, and other browser contexts.`,builder:Q,handler:async r=>{let c={liveViewUrlExpiresInMs:r[`live-view-url-expires-in-ms`]};if(r.dryRun){o({command:`cf browser-run devtools json get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/browser/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}/json`,pathParams:{"session-id":String(r[`session-id`]??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.browserRun.devtools.json.get({account_id:u,session_id:r[`session-id`],...c})),{successLabel:`Loaded`})}},re={command:`json`,describe:`Operations for devtools.json`,builder:e=>e.command(ne).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ie(e){return e.positional(`session-id`,{type:`string`,description:`Session ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ae={command:`get <session-id>`,describe:`Get details for a specific browser session.`,builder:ie,handler:async r=>{if(r.dryRun){o({command:`cf browser-run devtools session get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/session/${r[`session-id`]==null?`<session-id>`:encodeURIComponent(String(r[`session-id`]))}`,pathParams:{"session-id":String(r[`session-id`]??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.browserRun.devtools.session.get({account_id:l,session_id:r[`session-id`]})),{successLabel:`Loaded`})}};function oe(e){return e.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 se={command:`list`,describe:`List active browser sessions.`,builder:oe,handler:async r=>{let c={limit:r.limit,offset:r.offset};if(r.dryRun){o({command:`cf browser-run devtools session list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/devtools/session`,pathParams:{},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.browserRun.devtools.session.list({account_id:u,...c})),{successLabel:`Loaded`})}},ce={command:`session`,describe:`Operations for devtools.session`,builder:e=>e.command(ae).command(se).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},le={command:`devtools`,describe:`Operations for devtools`,builder:e=>e.command(Z).command(re).command(ce).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ue(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`action-timeout`,{type:`number`,description:`The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.`}).option(`add-script-tag`,{type:`string`,description:"Adds a `<script>` tag into the page with the desired URL or content. Provide as a JSON array of objects or @path/to/file.json."}).option(`add-style-tag`,{type:`string`,description:'Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a `<style type="text/css">` tag with the content. Provide as a JSON array of objects or @path/to/file.json.'}).option(`allow-request-pattern`,{type:`string`,array:!0,description:`Only allow requests that match the provided regex patterns, eg. '/^.*\\.(css)'. Reject rules are applied first.`}).option(`authenticate-password`,{type:`string`,description:`The authenticate.password field`}).option(`authenticate-username`,{type:`string`,description:`The authenticate.username field`}).option(`best-attempt`,{type:`boolean`,description:`Attempt to proceed when 'awaited' events fail or timeout.`}).option(`cookies`,{type:`string`,description:`Check [options](https://pptr.dev/api/puppeteer.page.setcookie). Provide as a JSON array of objects or @path/to/file.json.`}).option(`emulate-media-type`,{type:`string`,description:`The emulateMediaType field`}).option(`goto-options-referer`,{type:`string`,description:`The gotoOptions.referer field`}).option(`goto-options-referrer-policy`,{type:`string`,description:`The gotoOptions.referrerPolicy field`}).option(`goto-options-timeout`,{type:`number`,description:`The gotoOptions.timeout field`}).option(`html`,{type:`string`,description:"Set the content of the page, eg: `<h1>Hello World!!</h1>`. Either `html` or `url` must be set."}).option(`interesting-only`,{type:`boolean`,description:`The interestingOnly field`}).option(`reject-request-pattern`,{type:`string`,array:!0,description:`Block undesired requests that match the provided regex patterns, eg. '/^.*\\.(css)'.`}).option(`root`,{type:`string`,description:`The root field`}).option(`set-java-script-enabled`,{type:`boolean`,description:`The setJavaScriptEnabled field`}).option(`url`,{type:`string`,description:"URL to navigate to, eg. `https://example.com`."}).option(`user-agent`,{type:`string`,description:`The userAgent field`,default:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36`}).option(`viewport-device-scale-factor`,{type:`number`,description:`The viewport.deviceScaleFactor field`}).option(`viewport-has-touch`,{type:`boolean`,description:`The viewport.hasTouch field`}).option(`viewport-height`,{type:`number`,description:`The viewport.height field`}).option(`viewport-is-landscape`,{type:`boolean`,description:`The viewport.isLandscape field`}).option(`viewport-is-mobile`,{type:`boolean`,description:`The viewport.isMobile field`}).option(`viewport-width`,{type:`number`,description:`The viewport.width field`}).option(`wait-for-selector-hidden`,{type:`boolean`,description:`The waitForSelector.hidden field`}).option(`wait-for-selector-selector`,{type:`string`,description:`The waitForSelector.selector field`}).option(`wait-for-selector-timeout`,{type:`number`,description:`The waitForSelector.timeout field`}).option(`wait-for-selector-visible`,{type:`boolean`,description:`The waitForSelector.visible field`}).option(`wait-for-timeout`,{type:`number`,description:`Waits for a specified timeout before continuing.`}).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([`authenticate-password`,`authenticate-username`].some(t=>e[t]!==void 0)){let t=[`authenticate-password`,`authenticate-username`].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 --authenticate-* flag is set`)}return!0}).check(e=>{if([`viewport-device-scale-factor`,`viewport-has-touch`,`viewport-height`,`viewport-is-landscape`,`viewport-is-mobile`,`viewport-width`].some(t=>e[t]!==void 0)){let t=[`viewport-height`,`viewport-width`].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 --viewport-* flag is set`)}return!0}).check(e=>{if([`wait-for-selector-hidden`,`wait-for-selector-selector`,`wait-for-selector-timeout`,`wait-for-selector-visible`].some(t=>e[t]!==void 0)){let t=[`wait-for-selector-selector`].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 --waitForSelector-* flag is set`)}return!0})}const de={command:`accessibility-tree`,describe:"Returns the page's accessibility tree. Use `interestingOnly` to only return semantically meaningful nodes; use `root` to scope the tree to a CSS-selector-anchored subtree. Control page loading with `gotoOptions` and `waitFor*` options.",builder:ue,handler:async r=>{let c={cacheTTL:r[`cache-ttl`]};if(r.dryRun){o({command:`cf browser-run quick-action accessibility-tree`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/accessibilityTree`,pathParams:{},query:c,bodyKind:`json`,body:r.body===void 0?d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),interestingOnly:r[`interesting-only`],rejectRequestPattern:r[`reject-request-pattern`],root:f(r.root,`root`,`text`),setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]}):l(r.body)});return}let p=await i(r),m=r.local?e:await t();if(r.accountId=m,r.body){let e=l(r.body);new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.accessibilityTree({...e,account_id:m,...c})),{successLabel:`Created`});return}let h=d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),interestingOnly:r[`interesting-only`],rejectRequestPattern:r[`reject-request-pattern`],root:f(r.root,`root`,`text`),setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]});new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.accessibilityTree({...h,account_id:m,...c})),{successLabel:`Created`})}};function fe(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`action-timeout`,{type:`number`,description:`The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.`}).option(`add-script-tag`,{type:`string`,description:"Adds a `<script>` tag into the page with the desired URL or content. Provide as a JSON array of objects or @path/to/file.json."}).option(`add-style-tag`,{type:`string`,description:'Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a `<style type="text/css">` tag with the content. Provide as a JSON array of objects or @path/to/file.json.'}).option(`allow-request-pattern`,{type:`string`,array:!0,description:`Only allow requests that match the provided regex patterns, eg. '/^.*\\.(css)'. Reject rules are applied first.`}).option(`authenticate-password`,{type:`string`,description:`The authenticate.password field`}).option(`authenticate-username`,{type:`string`,description:`The authenticate.username field`}).option(`best-attempt`,{type:`boolean`,description:`Attempt to proceed when 'awaited' events fail or timeout.`}).option(`cookies`,{type:`string`,description:`Check [options](https://pptr.dev/api/puppeteer.page.setcookie). Provide as a JSON array of objects or @path/to/file.json.`}).option(`emulate-media-type`,{type:`string`,description:`The emulateMediaType field`}).option(`goto-options-referer`,{type:`string`,description:`The gotoOptions.referer field`}).option(`goto-options-referrer-policy`,{type:`string`,description:`The gotoOptions.referrerPolicy field`}).option(`goto-options-timeout`,{type:`number`,description:`The gotoOptions.timeout field`}).option(`html`,{type:`string`,description:"Set the content of the page, eg: `<h1>Hello World!!</h1>`. Either `html` or `url` must be set."}).option(`reject-request-pattern`,{type:`string`,array:!0,description:`Block undesired requests that match the provided regex patterns, eg. '/^.*\\.(css)'.`}).option(`set-java-script-enabled`,{type:`boolean`,description:`The setJavaScriptEnabled field`}).option(`url`,{type:`string`,description:"URL to navigate to, eg. `https://example.com`."}).option(`user-agent`,{type:`string`,description:`The userAgent field`,default:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36`}).option(`viewport-device-scale-factor`,{type:`number`,description:`The viewport.deviceScaleFactor field`}).option(`viewport-has-touch`,{type:`boolean`,description:`The viewport.hasTouch field`}).option(`viewport-height`,{type:`number`,description:`The viewport.height field`}).option(`viewport-is-landscape`,{type:`boolean`,description:`The viewport.isLandscape field`}).option(`viewport-is-mobile`,{type:`boolean`,description:`The viewport.isMobile field`}).option(`viewport-width`,{type:`number`,description:`The viewport.width field`}).option(`wait-for-selector-hidden`,{type:`boolean`,description:`The waitForSelector.hidden field`}).option(`wait-for-selector-selector`,{type:`string`,description:`The waitForSelector.selector field`}).option(`wait-for-selector-timeout`,{type:`number`,description:`The waitForSelector.timeout field`}).option(`wait-for-selector-visible`,{type:`boolean`,description:`The waitForSelector.visible field`}).option(`wait-for-timeout`,{type:`number`,description:`Waits for a specified timeout before continuing.`}).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([`authenticate-password`,`authenticate-username`].some(t=>e[t]!==void 0)){let t=[`authenticate-password`,`authenticate-username`].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 --authenticate-* flag is set`)}return!0}).check(e=>{if([`viewport-device-scale-factor`,`viewport-has-touch`,`viewport-height`,`viewport-is-landscape`,`viewport-is-mobile`,`viewport-width`].some(t=>e[t]!==void 0)){let t=[`viewport-height`,`viewport-width`].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 --viewport-* flag is set`)}return!0}).check(e=>{if([`wait-for-selector-hidden`,`wait-for-selector-selector`,`wait-for-selector-timeout`,`wait-for-selector-visible`].some(t=>e[t]!==void 0)){let t=[`wait-for-selector-selector`].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 --waitForSelector-* flag is set`)}return!0})}const pe={command:`content`,describe:"Fetches rendered HTML content from provided URL or HTML. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.",builder:fe,handler:async r=>{let c={cacheTTL:r[`cache-ttl`]};if(r.dryRun){o({command:`cf browser-run quick-action content`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/content`,pathParams:{},query:c,bodyKind:`json`,body:r.body===void 0?d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]}):l(r.body)});return}let p=await i(r),m=r.local?e:await t();if(r.accountId=m,r.body){let e=l(r.body);new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.content({...e,account_id:m,...c})),{successLabel:`Created`});return}let h=d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]});new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.content({...h,account_id:m,...c})),{successLabel:`Created`})}};function me(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`action-timeout`,{type:`number`,description:`The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.`}).option(`add-script-tag`,{type:`string`,description:"Adds a `<script>` tag into the page with the desired URL or content. Provide as a JSON array of objects or @path/to/file.json."}).option(`add-style-tag`,{type:`string`,description:'Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a `<style type="text/css">` tag with the content. Provide as a JSON array of objects or @path/to/file.json.'}).option(`allow-request-pattern`,{type:`string`,array:!0,description:`Only allow requests that match the provided regex patterns, eg. '/^.*\\.(css)'. Reject rules are applied first.`}).option(`authenticate-password`,{type:`string`,description:`The authenticate.password field`}).option(`authenticate-username`,{type:`string`,description:`The authenticate.username field`}).option(`best-attempt`,{type:`boolean`,description:`Attempt to proceed when 'awaited' events fail or timeout.`}).option(`cookies`,{type:`string`,description:`Check [options](https://pptr.dev/api/puppeteer.page.setcookie). Provide as a JSON array of objects or @path/to/file.json.`}).option(`custom-ai`,{type:`string`,description:`Optional list of custom AI models to use for the request. The models will be tried in the order provided, and in case a model returns an error, the next one will be used as fallback. Provide as a JSON array of objects or @path/to/file.json.`}).option(`emulate-media-type`,{type:`string`,description:`The emulateMediaType field`}).option(`goto-options-referer`,{type:`string`,description:`The gotoOptions.referer field`}).option(`goto-options-referrer-policy`,{type:`string`,description:`The gotoOptions.referrerPolicy field`}).option(`goto-options-timeout`,{type:`number`,description:`The gotoOptions.timeout field`}).option(`html`,{type:`string`,description:"Set the content of the page, eg: `<h1>Hello World!!</h1>`. Either `html` or `url` must be set."}).option(`prompt`,{type:`string`,description:`The prompt field`}).option(`reject-request-pattern`,{type:`string`,array:!0,description:`Block undesired requests that match the provided regex patterns, eg. '/^.*\\.(css)'.`}).option(`response-format-type`,{type:`string`,description:`The response_format.type field`}).option(`set-java-script-enabled`,{type:`boolean`,description:`The setJavaScriptEnabled field`}).option(`url`,{type:`string`,description:"URL to navigate to, eg. `https://example.com`."}).option(`user-agent`,{type:`string`,description:`The userAgent field`,default:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36`}).option(`viewport-device-scale-factor`,{type:`number`,description:`The viewport.deviceScaleFactor field`}).option(`viewport-has-touch`,{type:`boolean`,description:`The viewport.hasTouch field`}).option(`viewport-height`,{type:`number`,description:`The viewport.height field`}).option(`viewport-is-landscape`,{type:`boolean`,description:`The viewport.isLandscape field`}).option(`viewport-is-mobile`,{type:`boolean`,description:`The viewport.isMobile field`}).option(`viewport-width`,{type:`number`,description:`The viewport.width field`}).option(`wait-for-selector-hidden`,{type:`boolean`,description:`The waitForSelector.hidden field`}).option(`wait-for-selector-selector`,{type:`string`,description:`The waitForSelector.selector field`}).option(`wait-for-selector-timeout`,{type:`number`,description:`The waitForSelector.timeout field`}).option(`wait-for-selector-visible`,{type:`boolean`,description:`The waitForSelector.visible field`}).option(`wait-for-timeout`,{type:`number`,description:`Waits for a specified timeout before continuing.`}).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([`authenticate-password`,`authenticate-username`].some(t=>e[t]!==void 0)){let t=[`authenticate-password`,`authenticate-username`].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 --authenticate-* flag is set`)}return!0}).check(e=>{if([`response-format-type`].some(t=>e[t]!==void 0)){let t=[`response-format-type`].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 --response_format-* flag is set`)}return!0}).check(e=>{if([`viewport-device-scale-factor`,`viewport-has-touch`,`viewport-height`,`viewport-is-landscape`,`viewport-is-mobile`,`viewport-width`].some(t=>e[t]!==void 0)){let t=[`viewport-height`,`viewport-width`].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 --viewport-* flag is set`)}return!0}).check(e=>{if([`wait-for-selector-hidden`,`wait-for-selector-selector`,`wait-for-selector-timeout`,`wait-for-selector-visible`].some(t=>e[t]!==void 0)){let t=[`wait-for-selector-selector`].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 --waitForSelector-* flag is set`)}return!0})}const he={command:`json`,describe:"Gets json from a webpage from a provided URL or HTML. Pass `prompt` or `schema` in the body. Control page loading with `gotoOptions` and `waitFor*` options.",builder:me,handler:async r=>{let c={cacheTTL:r[`cache-ttl`]};if(r.dryRun){o({command:`cf browser-run quick-action json`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/json`,pathParams:{},query:c,bodyKind:`json`,body:r.body===void 0?d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),custom_ai:u(r[`custom-ai`],`custom-ai`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),prompt:f(r.prompt,`prompt`,`text`),rejectRequestPattern:r[`reject-request-pattern`],response_format:{type:f(r[`response-format-type`],`response-format-type`,`text`)},setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]}):l(r.body)});return}let p=await i(r),m=r.local?e:await t();if(r.accountId=m,r.body){let e=l(r.body);new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.json({...e,account_id:m,...c})),{successLabel:`Created`});return}let h=d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),custom_ai:u(r[`custom-ai`],`custom-ai`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),prompt:f(r.prompt,`prompt`,`text`),rejectRequestPattern:r[`reject-request-pattern`],response_format:{type:f(r[`response-format-type`],`response-format-type`,`text`)},setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]});new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.json({...h,account_id:m,...c})),{successLabel:`Created`})}};function ge(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`action-timeout`,{type:`number`,description:`The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.`}).option(`add-script-tag`,{type:`string`,description:"Adds a `<script>` tag into the page with the desired URL or content. Provide as a JSON array of objects or @path/to/file.json."}).option(`add-style-tag`,{type:`string`,description:'Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a `<style type="text/css">` tag with the content. Provide as a JSON array of objects or @path/to/file.json.'}).option(`allow-request-pattern`,{type:`string`,array:!0,description:`Only allow requests that match the provided regex patterns, eg. '/^.*\\.(css)'. Reject rules are applied first.`}).option(`authenticate-password`,{type:`string`,description:`The authenticate.password field`}).option(`authenticate-username`,{type:`string`,description:`The authenticate.username field`}).option(`best-attempt`,{type:`boolean`,description:`Attempt to proceed when 'awaited' events fail or timeout.`}).option(`cookies`,{type:`string`,description:`Check [options](https://pptr.dev/api/puppeteer.page.setcookie). Provide as a JSON array of objects or @path/to/file.json.`}).option(`emulate-media-type`,{type:`string`,description:`The emulateMediaType field`}).option(`exclude-external-links`,{type:`boolean`,description:`The excludeExternalLinks field`,default:!1}).option(`goto-options-referer`,{type:`string`,description:`The gotoOptions.referer field`}).option(`goto-options-referrer-policy`,{type:`string`,description:`The gotoOptions.referrerPolicy field`}).option(`goto-options-timeout`,{type:`number`,description:`The gotoOptions.timeout field`}).option(`html`,{type:`string`,description:"Set the content of the page, eg: `<h1>Hello World!!</h1>`. Either `html` or `url` must be set."}).option(`reject-request-pattern`,{type:`string`,array:!0,description:`Block undesired requests that match the provided regex patterns, eg. '/^.*\\.(css)'.`}).option(`set-java-script-enabled`,{type:`boolean`,description:`The setJavaScriptEnabled field`}).option(`url`,{type:`string`,description:"URL to navigate to, eg. `https://example.com`."}).option(`user-agent`,{type:`string`,description:`The userAgent field`,default:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36`}).option(`viewport-device-scale-factor`,{type:`number`,description:`The viewport.deviceScaleFactor field`}).option(`viewport-has-touch`,{type:`boolean`,description:`The viewport.hasTouch field`}).option(`viewport-height`,{type:`number`,description:`The viewport.height field`}).option(`viewport-is-landscape`,{type:`boolean`,description:`The viewport.isLandscape field`}).option(`viewport-is-mobile`,{type:`boolean`,description:`The viewport.isMobile field`}).option(`viewport-width`,{type:`number`,description:`The viewport.width field`}).option(`visible-links-only`,{type:`boolean`,description:`The visibleLinksOnly field`,default:!1}).option(`wait-for-selector-hidden`,{type:`boolean`,description:`The waitForSelector.hidden field`}).option(`wait-for-selector-selector`,{type:`string`,description:`The waitForSelector.selector field`}).option(`wait-for-selector-timeout`,{type:`number`,description:`The waitForSelector.timeout field`}).option(`wait-for-selector-visible`,{type:`boolean`,description:`The waitForSelector.visible field`}).option(`wait-for-timeout`,{type:`number`,description:`Waits for a specified timeout before continuing.`}).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([`authenticate-password`,`authenticate-username`].some(t=>e[t]!==void 0)){let t=[`authenticate-password`,`authenticate-username`].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 --authenticate-* flag is set`)}return!0}).check(e=>{if([`viewport-device-scale-factor`,`viewport-has-touch`,`viewport-height`,`viewport-is-landscape`,`viewport-is-mobile`,`viewport-width`].some(t=>e[t]!==void 0)){let t=[`viewport-height`,`viewport-width`].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 --viewport-* flag is set`)}return!0}).check(e=>{if([`wait-for-selector-hidden`,`wait-for-selector-selector`,`wait-for-selector-timeout`,`wait-for-selector-visible`].some(t=>e[t]!==void 0)){let t=[`wait-for-selector-selector`].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 --waitForSelector-* flag is set`)}return!0})}const _e={command:`links`,describe:`Get links from a web page.`,builder:ge,handler:async r=>{let c={cacheTTL:r[`cache-ttl`]};if(r.dryRun){o({command:`cf browser-run quick-action links`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/links`,pathParams:{},query:c,bodyKind:`json`,body:r.body===void 0?d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),excludeExternalLinks:r[`exclude-external-links`],gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},visibleLinksOnly:r[`visible-links-only`],waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]}):l(r.body)});return}let p=await i(r),m=r.local?e:await t();if(r.accountId=m,r.body){let e=l(r.body);new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.links({...e,account_id:m,...c})),{successLabel:`Created`});return}let h=d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),excludeExternalLinks:r[`exclude-external-links`],gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},visibleLinksOnly:r[`visible-links-only`],waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]});new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.links({...h,account_id:m,...c})),{successLabel:`Created`})}};function ve(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`action-timeout`,{type:`number`,description:`The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.`}).option(`add-script-tag`,{type:`string`,description:"Adds a `<script>` tag into the page with the desired URL or content. Provide as a JSON array of objects or @path/to/file.json."}).option(`add-style-tag`,{type:`string`,description:'Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a `<style type="text/css">` tag with the content. Provide as a JSON array of objects or @path/to/file.json.'}).option(`allow-request-pattern`,{type:`string`,array:!0,description:`Only allow requests that match the provided regex patterns, eg. '/^.*\\.(css)'. Reject rules are applied first.`}).option(`authenticate-password`,{type:`string`,description:`The authenticate.password field`}).option(`authenticate-username`,{type:`string`,description:`The authenticate.username field`}).option(`best-attempt`,{type:`boolean`,description:`Attempt to proceed when 'awaited' events fail or timeout.`}).option(`cookies`,{type:`string`,description:`Check [options](https://pptr.dev/api/puppeteer.page.setcookie). Provide as a JSON array of objects or @path/to/file.json.`}).option(`emulate-media-type`,{type:`string`,description:`The emulateMediaType field`}).option(`goto-options-referer`,{type:`string`,description:`The gotoOptions.referer field`}).option(`goto-options-referrer-policy`,{type:`string`,description:`The gotoOptions.referrerPolicy field`}).option(`goto-options-timeout`,{type:`number`,description:`The gotoOptions.timeout field`}).option(`html`,{type:`string`,description:"Set the content of the page, eg: `<h1>Hello World!!</h1>`. Either `html` or `url` must be set."}).option(`reject-request-pattern`,{type:`string`,array:!0,description:`Block undesired requests that match the provided regex patterns, eg. '/^.*\\.(css)'.`}).option(`set-java-script-enabled`,{type:`boolean`,description:`The setJavaScriptEnabled field`}).option(`url`,{type:`string`,description:"URL to navigate to, eg. `https://example.com`."}).option(`user-agent`,{type:`string`,description:`The userAgent field`,default:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36`}).option(`viewport-device-scale-factor`,{type:`number`,description:`The viewport.deviceScaleFactor field`}).option(`viewport-has-touch`,{type:`boolean`,description:`The viewport.hasTouch field`}).option(`viewport-height`,{type:`number`,description:`The viewport.height field`}).option(`viewport-is-landscape`,{type:`boolean`,description:`The viewport.isLandscape field`}).option(`viewport-is-mobile`,{type:`boolean`,description:`The viewport.isMobile field`}).option(`viewport-width`,{type:`number`,description:`The viewport.width field`}).option(`wait-for-selector-hidden`,{type:`boolean`,description:`The waitForSelector.hidden field`}).option(`wait-for-selector-selector`,{type:`string`,description:`The waitForSelector.selector field`}).option(`wait-for-selector-timeout`,{type:`number`,description:`The waitForSelector.timeout field`}).option(`wait-for-selector-visible`,{type:`boolean`,description:`The waitForSelector.visible field`}).option(`wait-for-timeout`,{type:`number`,description:`Waits for a specified timeout before continuing.`}).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([`authenticate-password`,`authenticate-username`].some(t=>e[t]!==void 0)){let t=[`authenticate-password`,`authenticate-username`].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 --authenticate-* flag is set`)}return!0}).check(e=>{if([`viewport-device-scale-factor`,`viewport-has-touch`,`viewport-height`,`viewport-is-landscape`,`viewport-is-mobile`,`viewport-width`].some(t=>e[t]!==void 0)){let t=[`viewport-height`,`viewport-width`].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 --viewport-* flag is set`)}return!0}).check(e=>{if([`wait-for-selector-hidden`,`wait-for-selector-selector`,`wait-for-selector-timeout`,`wait-for-selector-visible`].some(t=>e[t]!==void 0)){let t=[`wait-for-selector-selector`].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 --waitForSelector-* flag is set`)}return!0})}const ye={command:`markdown`,describe:"Gets markdown of a webpage from provided URL or HTML. Control page loading with `gotoOptions` and `waitFor*` options.",builder:ve,handler:async r=>{let c={cacheTTL:r[`cache-ttl`]};if(r.dryRun){o({command:`cf browser-run quick-action markdown`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/markdown`,pathParams:{},query:c,bodyKind:`json`,body:r.body===void 0?d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]}):l(r.body)});return}let p=await i(r),m=r.local?e:await t();if(r.accountId=m,r.body){let e=l(r.body);new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.markdown({...e,account_id:m,...c})),{successLabel:`Created`});return}let h=d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]});new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.markdown({...h,account_id:m,...c})),{successLabel:`Created`})}};function be(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`action-timeout`,{type:`number`,description:`The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.`}).option(`add-script-tag`,{type:`string`,description:"Adds a `<script>` tag into the page with the desired URL or content. Provide as a JSON array of objects or @path/to/file.json."}).option(`add-style-tag`,{type:`string`,description:'Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a `<style type="text/css">` tag with the content. Provide as a JSON array of objects or @path/to/file.json.'}).option(`allow-request-pattern`,{type:`string`,array:!0,description:`Only allow requests that match the provided regex patterns, eg. '/^.*\\.(css)'. Reject rules are applied first.`}).option(`authenticate-password`,{type:`string`,description:`The authenticate.password field`}).option(`authenticate-username`,{type:`string`,description:`The authenticate.username field`}).option(`best-attempt`,{type:`boolean`,description:`Attempt to proceed when 'awaited' events fail or timeout.`}).option(`cookies`,{type:`string`,description:`Check [options](https://pptr.dev/api/puppeteer.page.setcookie). Provide as a JSON array of objects or @path/to/file.json.`}).option(`emulate-media-type`,{type:`string`,description:`The emulateMediaType field`}).option(`goto-options-referer`,{type:`string`,description:`The gotoOptions.referer field`}).option(`goto-options-referrer-policy`,{type:`string`,description:`The gotoOptions.referrerPolicy field`}).option(`goto-options-timeout`,{type:`number`,description:`The gotoOptions.timeout field`}).option(`html`,{type:`string`,description:"Set the content of the page, eg: `<h1>Hello World!!</h1>`. Either `html` or `url` must be set."}).option(`pdf-options-display-header-footer`,{type:`boolean`,description:`Whether to show the header and footer.`}).option(`pdf-options-footer-template`,{type:`string`,description:`HTML template for the print footer.`}).option(`pdf-options-format`,{type:`string`,description:`Paper format. Takes priority over width and height if set.`,choices:[`letter`,`legal`,`tabloid`,`ledger`,`a0`,`a1`,`a2`,`a3`,`a4`,`a5`,`a6`]}).option(`pdf-options-header-template`,{type:`string`,description:`HTML template for the print header.`}).option(`pdf-options-landscape`,{type:`boolean`,description:`Whether to print in landscape orientation.`}).option(`pdf-options-omit-background`,{type:`boolean`,description:`Hides default white background and allows generating pdfs with transparency.`}).option(`pdf-options-outline`,{type:`boolean`,description:`Generate document outline.`}).option(`pdf-options-page-ranges`,{type:`string`,description:`Paper ranges to print, e.g. '1-5, 8, 11-13'.`}).option(`pdf-options-prefer-csspage-size`,{type:`boolean`,description:`Give CSS @page size priority over other size declarations.`}).option(`pdf-options-print-background`,{type:`boolean`,description:`Set to true to print background graphics.`}).option(`pdf-options-scale`,{type:`number`,description:`Scales the rendering of the web page. Amount must be between 0.1 and 2.`}).option(`pdf-options-tagged`,{type:`boolean`,description:`Generate tagged (accessible) PDF.`}).option(`pdf-options-timeout`,{type:`number`,description:`Timeout in milliseconds.`}).option(`reject-request-pattern`,{type:`string`,array:!0,description:`Block undesired requests that match the provided regex patterns, eg. '/^.*\\.(css)'.`}).option(`set-java-script-enabled`,{type:`boolean`,description:`The setJavaScriptEnabled field`}).option(`url`,{type:`string`,description:"URL to navigate to, eg. `https://example.com`."}).option(`user-agent`,{type:`string`,description:`The userAgent field`,default:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36`}).option(`viewport-device-scale-factor`,{type:`number`,description:`The viewport.deviceScaleFactor field`}).option(`viewport-has-touch`,{type:`boolean`,description:`The viewport.hasTouch field`}).option(`viewport-height`,{type:`number`,description:`The viewport.height field`}).option(`viewport-is-landscape`,{type:`boolean`,description:`The viewport.isLandscape field`}).option(`viewport-is-mobile`,{type:`boolean`,description:`The viewport.isMobile field`}).option(`viewport-width`,{type:`number`,description:`The viewport.width field`}).option(`wait-for-selector-hidden`,{type:`boolean`,description:`The waitForSelector.hidden field`}).option(`wait-for-selector-selector`,{type:`string`,description:`The waitForSelector.selector field`}).option(`wait-for-selector-timeout`,{type:`number`,description:`The waitForSelector.timeout field`}).option(`wait-for-selector-visible`,{type:`boolean`,description:`The waitForSelector.visible field`}).option(`wait-for-timeout`,{type:`number`,description:`Waits for a specified timeout before continuing.`}).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(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1}).check(e=>{if([`authenticate-password`,`authenticate-username`].some(t=>e[t]!==void 0)){let t=[`authenticate-password`,`authenticate-username`].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 --authenticate-* flag is set`)}return!0}).check(e=>{if([`viewport-device-scale-factor`,`viewport-has-touch`,`viewport-height`,`viewport-is-landscape`,`viewport-is-mobile`,`viewport-width`].some(t=>e[t]!==void 0)){let t=[`viewport-height`,`viewport-width`].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 --viewport-* flag is set`)}return!0}).check(e=>{if([`wait-for-selector-hidden`,`wait-for-selector-selector`,`wait-for-selector-timeout`,`wait-for-selector-visible`].some(t=>e[t]!==void 0)){let t=[`wait-for-selector-selector`].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 --waitForSelector-* flag is set`)}return!0})}const $={command:`pdf`,describe:"Fetches rendered PDF from provided URL or HTML. Check available options like `gotoOptions` and `waitFor*` to control page load behaviour.",builder:be,handler:async r=>{let a={cacheTTL:r[`cache-ttl`]};if(r.dryRun){o({command:`cf browser-run quick-action pdf`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/pdf`,pathParams:{},query:a,bodyKind:`json`,body:r.body===void 0?d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),pdfOptions:{displayHeaderFooter:r[`pdf-options-display-header-footer`],footerTemplate:f(r[`pdf-options-footer-template`],`pdf-options-footer-template`,`text`),format:f(r[`pdf-options-format`],`pdf-options-format`,`text`),headerTemplate:f(r[`pdf-options-header-template`],`pdf-options-header-template`,`text`),landscape:r[`pdf-options-landscape`],omitBackground:r[`pdf-options-omit-background`],outline:r[`pdf-options-outline`],pageRanges:f(r[`pdf-options-page-ranges`],`pdf-options-page-ranges`,`text`),preferCSSPageSize:r[`pdf-options-prefer-csspage-size`],printBackground:r[`pdf-options-print-background`],scale:r[`pdf-options-scale`],tagged:r[`pdf-options-tagged`],timeout:r[`pdf-options-timeout`]},rejectRequestPattern:r[`reject-request-pattern`],setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]}):l(r.body)});return}await i(r);let p=r.local?e:await t();if(r.accountId=p,r.body){let e=l(r.body),t=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),n=await s(`Creating`,async()=>g(`/accounts/${p}/browser-rendering/pdf${t?`?`+t:``}`,{method:`POST`,local:r.local===!0,persistTo:r.persistTo,body:JSON.stringify(e),contentType:`application/json`}));h(r.text===!0?n.toString(`utf-8`):n);return}let m={};r[`action-timeout`]!==void 0&&c(m,[`actionTimeout`],r[`action-timeout`]),r[`add-script-tag`]!==void 0&&c(m,[`addScriptTag`],u(r[`add-script-tag`],`add-script-tag`)),r[`add-style-tag`]!==void 0&&c(m,[`addStyleTag`],u(r[`add-style-tag`],`add-style-tag`)),r[`allow-request-pattern`]!==void 0&&c(m,[`allowRequestPattern`],r[`allow-request-pattern`]),r[`authenticate-password`]!==void 0&&c(m,[`authenticate`,`password`],f(r[`authenticate-password`],`authenticate-password`,`text`)),r[`authenticate-username`]!==void 0&&c(m,[`authenticate`,`username`],f(r[`authenticate-username`],`authenticate-username`,`text`)),r[`best-attempt`]!==void 0&&c(m,[`bestAttempt`],r[`best-attempt`]),r.cookies!==void 0&&c(m,[`cookies`],u(r.cookies,`cookies`)),r[`emulate-media-type`]!==void 0&&c(m,[`emulateMediaType`],f(r[`emulate-media-type`],`emulate-media-type`,`text`)),r[`goto-options-referer`]!==void 0&&c(m,[`gotoOptions`,`referer`],f(r[`goto-options-referer`],`goto-options-referer`,`text`)),r[`goto-options-referrer-policy`]!==void 0&&c(m,[`gotoOptions`,`referrerPolicy`],f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`)),r[`goto-options-timeout`]!==void 0&&c(m,[`gotoOptions`,`timeout`],r[`goto-options-timeout`]),r.html!==void 0&&c(m,[`html`],f(r.html,`html`,`text`)),r[`pdf-options-display-header-footer`]!==void 0&&c(m,[`pdfOptions`,`displayHeaderFooter`],r[`pdf-options-display-header-footer`]),r[`pdf-options-footer-template`]!==void 0&&c(m,[`pdfOptions`,`footerTemplate`],f(r[`pdf-options-footer-template`],`pdf-options-footer-template`,`text`)),r[`pdf-options-format`]!==void 0&&c(m,[`pdfOptions`,`format`],f(r[`pdf-options-format`],`pdf-options-format`,`text`)),r[`pdf-options-header-template`]!==void 0&&c(m,[`pdfOptions`,`headerTemplate`],f(r[`pdf-options-header-template`],`pdf-options-header-template`,`text`)),r[`pdf-options-landscape`]!==void 0&&c(m,[`pdfOptions`,`landscape`],r[`pdf-options-landscape`]),r[`pdf-options-omit-background`]!==void 0&&c(m,[`pdfOptions`,`omitBackground`],r[`pdf-options-omit-background`]),r[`pdf-options-outline`]!==void 0&&c(m,[`pdfOptions`,`outline`],r[`pdf-options-outline`]),r[`pdf-options-page-ranges`]!==void 0&&c(m,[`pdfOptions`,`pageRanges`],f(r[`pdf-options-page-ranges`],`pdf-options-page-ranges`,`text`)),r[`pdf-options-prefer-csspage-size`]!==void 0&&c(m,[`pdfOptions`,`preferCSSPageSize`],r[`pdf-options-prefer-csspage-size`]),r[`pdf-options-print-background`]!==void 0&&c(m,[`pdfOptions`,`printBackground`],r[`pdf-options-print-background`]),r[`pdf-options-scale`]!==void 0&&c(m,[`pdfOptions`,`scale`],r[`pdf-options-scale`]),r[`pdf-options-tagged`]!==void 0&&c(m,[`pdfOptions`,`tagged`],r[`pdf-options-tagged`]),r[`pdf-options-timeout`]!==void 0&&c(m,[`pdfOptions`,`timeout`],r[`pdf-options-timeout`]),r[`reject-request-pattern`]!==void 0&&c(m,[`rejectRequestPattern`],r[`reject-request-pattern`]),r[`set-java-script-enabled`]!==void 0&&c(m,[`setJavaScriptEnabled`],r[`set-java-script-enabled`]),r.url!==void 0&&c(m,[`url`],f(r.url,`url`,`text`)),r[`user-agent`]!==void 0&&c(m,[`userAgent`],f(r[`user-agent`],`user-agent`,`text`)),r[`viewport-device-scale-factor`]!==void 0&&c(m,[`viewport`,`deviceScaleFactor`],r[`viewport-device-scale-factor`]),r[`viewport-has-touch`]!==void 0&&c(m,[`viewport`,`hasTouch`],r[`viewport-has-touch`]),r[`viewport-height`]!==void 0&&c(m,[`viewport`,`height`],r[`viewport-height`]),r[`viewport-is-landscape`]!==void 0&&c(m,[`viewport`,`isLandscape`],r[`viewport-is-landscape`]),r[`viewport-is-mobile`]!==void 0&&c(m,[`viewport`,`isMobile`],r[`viewport-is-mobile`]),r[`viewport-width`]!==void 0&&c(m,[`viewport`,`width`],r[`viewport-width`]),r[`wait-for-selector-hidden`]!==void 0&&c(m,[`waitForSelector`,`hidden`],r[`wait-for-selector-hidden`]),r[`wait-for-selector-selector`]!==void 0&&c(m,[`waitForSelector`,`selector`],f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`)),r[`wait-for-selector-timeout`]!==void 0&&c(m,[`waitForSelector`,`timeout`],r[`wait-for-selector-timeout`]),r[`wait-for-selector-visible`]!==void 0&&c(m,[`waitForSelector`,`visible`],r[`wait-for-selector-visible`]),r[`wait-for-timeout`]!==void 0&&c(m,[`waitForTimeout`],r[`wait-for-timeout`]);let _=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),v=await s(`Creating`,async()=>g(`/accounts/${p}/browser-rendering/pdf${_?`?`+_:``}`,{method:`POST`,local:r.local===!0,persistTo:r.persistTo,body:Object.keys(m).length>0?m:void 0}));h(r.text===!0?v.toString(`utf-8`):v)}};function xe(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`action-timeout`,{type:`number`,description:`The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.`}).option(`add-script-tag`,{type:`string`,description:"Adds a `<script>` tag into the page with the desired URL or content. Provide as a JSON array of objects or @path/to/file.json."}).option(`add-style-tag`,{type:`string`,description:'Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a `<style type="text/css">` tag with the content. Provide as a JSON array of objects or @path/to/file.json.'}).option(`allow-request-pattern`,{type:`string`,array:!0,description:`Only allow requests that match the provided regex patterns, eg. '/^.*\\.(css)'. Reject rules are applied first.`}).option(`authenticate-password`,{type:`string`,description:`The authenticate.password field`}).option(`authenticate-username`,{type:`string`,description:`The authenticate.username field`}).option(`best-attempt`,{type:`boolean`,description:`Attempt to proceed when 'awaited' events fail or timeout.`}).option(`cookies`,{type:`string`,description:`Check [options](https://pptr.dev/api/puppeteer.page.setcookie). Provide as a JSON array of objects or @path/to/file.json.`}).option(`elements`,{type:`string`,description:`The elements field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`emulate-media-type`,{type:`string`,description:`The emulateMediaType field`}).option(`goto-options-referer`,{type:`string`,description:`The gotoOptions.referer field`}).option(`goto-options-referrer-policy`,{type:`string`,description:`The gotoOptions.referrerPolicy field`}).option(`goto-options-timeout`,{type:`number`,description:`The gotoOptions.timeout field`}).option(`html`,{type:`string`,description:"Set the content of the page, eg: `<h1>Hello World!!</h1>`. Either `html` or `url` must be set."}).option(`reject-request-pattern`,{type:`string`,array:!0,description:`Block undesired requests that match the provided regex patterns, eg. '/^.*\\.(css)'.`}).option(`set-java-script-enabled`,{type:`boolean`,description:`The setJavaScriptEnabled field`}).option(`url`,{type:`string`,description:"URL to navigate to, eg. `https://example.com`."}).option(`user-agent`,{type:`string`,description:`The userAgent field`,default:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36`}).option(`viewport-device-scale-factor`,{type:`number`,description:`The viewport.deviceScaleFactor field`}).option(`viewport-has-touch`,{type:`boolean`,description:`The viewport.hasTouch field`}).option(`viewport-height`,{type:`number`,description:`The viewport.height field`}).option(`viewport-is-landscape`,{type:`boolean`,description:`The viewport.isLandscape field`}).option(`viewport-is-mobile`,{type:`boolean`,description:`The viewport.isMobile field`}).option(`viewport-width`,{type:`number`,description:`The viewport.width field`}).option(`wait-for-selector-hidden`,{type:`boolean`,description:`The waitForSelector.hidden field`}).option(`wait-for-selector-selector`,{type:`string`,description:`The waitForSelector.selector field`}).option(`wait-for-selector-timeout`,{type:`number`,description:`The waitForSelector.timeout field`}).option(`wait-for-selector-visible`,{type:`boolean`,description:`The waitForSelector.visible field`}).option(`wait-for-timeout`,{type:`number`,description:`Waits for a specified timeout before continuing.`}).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([`authenticate-password`,`authenticate-username`].some(t=>e[t]!==void 0)){let t=[`authenticate-password`,`authenticate-username`].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 --authenticate-* flag is set`)}return!0}).check(e=>{if([`viewport-device-scale-factor`,`viewport-has-touch`,`viewport-height`,`viewport-is-landscape`,`viewport-is-mobile`,`viewport-width`].some(t=>e[t]!==void 0)){let t=[`viewport-height`,`viewport-width`].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 --viewport-* flag is set`)}return!0}).check(e=>{if([`wait-for-selector-hidden`,`wait-for-selector-selector`,`wait-for-selector-timeout`,`wait-for-selector-visible`].some(t=>e[t]!==void 0)){let t=[`wait-for-selector-selector`].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 --waitForSelector-* flag is set`)}return!0})}const Se={command:`scrape`,describe:`Get meta attributes like height, width, text and others of selected elements.`,builder:xe,handler:async r=>{let c={cacheTTL:r[`cache-ttl`]};if(r.dryRun){o({command:`cf browser-run quick-action scrape`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/scrape`,pathParams:{},query:c,bodyKind:`json`,body:r.body===void 0?d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),elements:u(r.elements,`elements`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]}):l(r.body)});return}let p=await i(r),m=r.local?e:await t();if(r.accountId=m,r.body){let e=l(r.body);new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.scrape({...e,account_id:m,...c})),{successLabel:`Created`});return}if(r.elements===void 0)throw Error(`--elements is required (or pass --body with this field set).`);let h=d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),elements:u(r.elements,`elements`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]});new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.scrape({...h,account_id:m,...c})),{successLabel:`Created`})}};function Ce(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`action-timeout`,{type:`number`,description:`The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.`}).option(`add-script-tag`,{type:`string`,description:"Adds a `<script>` tag into the page with the desired URL or content. Provide as a JSON array of objects or @path/to/file.json."}).option(`add-style-tag`,{type:`string`,description:'Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a `<style type="text/css">` tag with the content. Provide as a JSON array of objects or @path/to/file.json.'}).option(`allow-request-pattern`,{type:`string`,array:!0,description:`Only allow requests that match the provided regex patterns, eg. '/^.*\\.(css)'. Reject rules are applied first.`}).option(`authenticate-password`,{type:`string`,description:`The authenticate.password field`}).option(`authenticate-username`,{type:`string`,description:`The authenticate.username field`}).option(`best-attempt`,{type:`boolean`,description:`Attempt to proceed when 'awaited' events fail or timeout.`}).option(`cookies`,{type:`string`,description:`Check [options](https://pptr.dev/api/puppeteer.page.setcookie). Provide as a JSON array of objects or @path/to/file.json.`}).option(`emulate-media-type`,{type:`string`,description:`The emulateMediaType field`}).option(`goto-options-referer`,{type:`string`,description:`The gotoOptions.referer field`}).option(`goto-options-referrer-policy`,{type:`string`,description:`The gotoOptions.referrerPolicy field`}).option(`goto-options-timeout`,{type:`number`,description:`The gotoOptions.timeout field`}).option(`html`,{type:`string`,description:"Set the content of the page, eg: `<h1>Hello World!!</h1>`. Either `html` or `url` must be set."}).option(`reject-request-pattern`,{type:`string`,array:!0,description:`Block undesired requests that match the provided regex patterns, eg. '/^.*\\.(css)'.`}).option(`screenshot-options-capture-beyond-viewport`,{type:`boolean`,description:`The screenshotOptions.captureBeyondViewport field`}).option(`screenshot-options-clip-height`,{type:`number`,description:`The screenshotOptions.clip.height field`}).option(`screenshot-options-clip-scale`,{type:`number`,description:`The screenshotOptions.clip.scale field`}).option(`screenshot-options-clip-width`,{type:`number`,description:`The screenshotOptions.clip.width field`}).option(`screenshot-options-clip-x`,{type:`number`,description:`The screenshotOptions.clip.x field`}).option(`screenshot-options-clip-y`,{type:`number`,description:`The screenshotOptions.clip.y field`}).option(`screenshot-options-from-surface`,{type:`boolean`,description:`The screenshotOptions.fromSurface field`}).option(`screenshot-options-full-page`,{type:`boolean`,description:`The screenshotOptions.fullPage field`}).option(`screenshot-options-omit-background`,{type:`boolean`,description:`The screenshotOptions.omitBackground field`}).option(`screenshot-options-optimize-for-speed`,{type:`boolean`,description:`The screenshotOptions.optimizeForSpeed field`}).option(`screenshot-options-quality`,{type:`number`,description:`The screenshotOptions.quality field`}).option(`scroll-page`,{type:`boolean`,description:`The scrollPage field`}).option(`selector`,{type:`string`,description:`The selector field`}).option(`set-java-script-enabled`,{type:`boolean`,description:`The setJavaScriptEnabled field`}).option(`url`,{type:`string`,description:"URL to navigate to, eg. `https://example.com`."}).option(`user-agent`,{type:`string`,description:`The userAgent field`,default:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36`}).option(`viewport-device-scale-factor`,{type:`number`,description:`The viewport.deviceScaleFactor field`}).option(`viewport-has-touch`,{type:`boolean`,description:`The viewport.hasTouch field`}).option(`viewport-height`,{type:`number`,description:`The viewport.height field`}).option(`viewport-is-landscape`,{type:`boolean`,description:`The viewport.isLandscape field`}).option(`viewport-is-mobile`,{type:`boolean`,description:`The viewport.isMobile field`}).option(`viewport-width`,{type:`number`,description:`The viewport.width field`}).option(`wait-for-selector-hidden`,{type:`boolean`,description:`The waitForSelector.hidden field`}).option(`wait-for-selector-selector`,{type:`string`,description:`The waitForSelector.selector field`}).option(`wait-for-selector-timeout`,{type:`number`,description:`The waitForSelector.timeout field`}).option(`wait-for-selector-visible`,{type:`boolean`,description:`The waitForSelector.visible field`}).option(`wait-for-timeout`,{type:`number`,description:`Waits for a specified timeout before continuing.`}).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(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1}).check(e=>{if([`authenticate-password`,`authenticate-username`].some(t=>e[t]!==void 0)){let t=[`authenticate-password`,`authenticate-username`].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 --authenticate-* flag is set`)}return!0}).check(e=>{if([`screenshot-options-capture-beyond-viewport`,`screenshot-options-clip-height`,`screenshot-options-clip-scale`,`screenshot-options-clip-width`,`screenshot-options-clip-x`,`screenshot-options-clip-y`,`screenshot-options-from-surface`,`screenshot-options-full-page`,`screenshot-options-omit-background`,`screenshot-options-optimize-for-speed`,`screenshot-options-quality`].some(t=>e[t]!==void 0)){let t=[`screenshot-options-clip-height`,`screenshot-options-clip-width`,`screenshot-options-clip-x`,`screenshot-options-clip-y`].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 --screenshotOptions-* flag is set`)}return!0}).check(e=>{if([`viewport-device-scale-factor`,`viewport-has-touch`,`viewport-height`,`viewport-is-landscape`,`viewport-is-mobile`,`viewport-width`].some(t=>e[t]!==void 0)){let t=[`viewport-height`,`viewport-width`].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 --viewport-* flag is set`)}return!0}).check(e=>{if([`wait-for-selector-hidden`,`wait-for-selector-selector`,`wait-for-selector-timeout`,`wait-for-selector-visible`].some(t=>e[t]!==void 0)){let t=[`wait-for-selector-selector`].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 --waitForSelector-* flag is set`)}return!0})}const we={command:`screenshot`,describe:"Takes a screenshot of a webpage from provided URL or HTML. Control page loading with `gotoOptions` and `waitFor*` options. Customize screenshots with `viewport`, `fullPage`, `clip` and others.",builder:Ce,handler:async r=>{let a={cacheTTL:r[`cache-ttl`]};if(r.dryRun){o({command:`cf browser-run quick-action screenshot`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/screenshot`,pathParams:{},query:a,bodyKind:`json`,body:r.body===void 0?d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],screenshotOptions:{captureBeyondViewport:r[`screenshot-options-capture-beyond-viewport`],clip:{height:r[`screenshot-options-clip-height`],scale:r[`screenshot-options-clip-scale`],width:r[`screenshot-options-clip-width`],x:r[`screenshot-options-clip-x`],y:r[`screenshot-options-clip-y`]},fromSurface:r[`screenshot-options-from-surface`],fullPage:r[`screenshot-options-full-page`],omitBackground:r[`screenshot-options-omit-background`],optimizeForSpeed:r[`screenshot-options-optimize-for-speed`],quality:r[`screenshot-options-quality`]},scrollPage:r[`scroll-page`],selector:f(r.selector,`selector`,`text`),setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]}):l(r.body)});return}await i(r);let p=r.local?e:await t();if(r.accountId=p,r.body){let e=l(r.body),t=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),n=await s(`Creating`,async()=>g(`/accounts/${p}/browser-rendering/screenshot${t?`?`+t:``}`,{method:`POST`,local:r.local===!0,persistTo:r.persistTo,body:JSON.stringify(e),contentType:`application/json`}));h(r.text===!0?n.toString(`utf-8`):n);return}let m={};r[`action-timeout`]!==void 0&&c(m,[`actionTimeout`],r[`action-timeout`]),r[`add-script-tag`]!==void 0&&c(m,[`addScriptTag`],u(r[`add-script-tag`],`add-script-tag`)),r[`add-style-tag`]!==void 0&&c(m,[`addStyleTag`],u(r[`add-style-tag`],`add-style-tag`)),r[`allow-request-pattern`]!==void 0&&c(m,[`allowRequestPattern`],r[`allow-request-pattern`]),r[`authenticate-password`]!==void 0&&c(m,[`authenticate`,`password`],f(r[`authenticate-password`],`authenticate-password`,`text`)),r[`authenticate-username`]!==void 0&&c(m,[`authenticate`,`username`],f(r[`authenticate-username`],`authenticate-username`,`text`)),r[`best-attempt`]!==void 0&&c(m,[`bestAttempt`],r[`best-attempt`]),r.cookies!==void 0&&c(m,[`cookies`],u(r.cookies,`cookies`)),r[`emulate-media-type`]!==void 0&&c(m,[`emulateMediaType`],f(r[`emulate-media-type`],`emulate-media-type`,`text`)),r[`goto-options-referer`]!==void 0&&c(m,[`gotoOptions`,`referer`],f(r[`goto-options-referer`],`goto-options-referer`,`text`)),r[`goto-options-referrer-policy`]!==void 0&&c(m,[`gotoOptions`,`referrerPolicy`],f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`)),r[`goto-options-timeout`]!==void 0&&c(m,[`gotoOptions`,`timeout`],r[`goto-options-timeout`]),r.html!==void 0&&c(m,[`html`],f(r.html,`html`,`text`)),r[`reject-request-pattern`]!==void 0&&c(m,[`rejectRequestPattern`],r[`reject-request-pattern`]),r[`screenshot-options-capture-beyond-viewport`]!==void 0&&c(m,[`screenshotOptions`,`captureBeyondViewport`],r[`screenshot-options-capture-beyond-viewport`]),r[`screenshot-options-clip-height`]!==void 0&&c(m,[`screenshotOptions`,`clip`,`height`],r[`screenshot-options-clip-height`]),r[`screenshot-options-clip-scale`]!==void 0&&c(m,[`screenshotOptions`,`clip`,`scale`],r[`screenshot-options-clip-scale`]),r[`screenshot-options-clip-width`]!==void 0&&c(m,[`screenshotOptions`,`clip`,`width`],r[`screenshot-options-clip-width`]),r[`screenshot-options-clip-x`]!==void 0&&c(m,[`screenshotOptions`,`clip`,`x`],r[`screenshot-options-clip-x`]),r[`screenshot-options-clip-y`]!==void 0&&c(m,[`screenshotOptions`,`clip`,`y`],r[`screenshot-options-clip-y`]),r[`screenshot-options-from-surface`]!==void 0&&c(m,[`screenshotOptions`,`fromSurface`],r[`screenshot-options-from-surface`]),r[`screenshot-options-full-page`]!==void 0&&c(m,[`screenshotOptions`,`fullPage`],r[`screenshot-options-full-page`]),r[`screenshot-options-omit-background`]!==void 0&&c(m,[`screenshotOptions`,`omitBackground`],r[`screenshot-options-omit-background`]),r[`screenshot-options-optimize-for-speed`]!==void 0&&c(m,[`screenshotOptions`,`optimizeForSpeed`],r[`screenshot-options-optimize-for-speed`]),r[`screenshot-options-quality`]!==void 0&&c(m,[`screenshotOptions`,`quality`],r[`screenshot-options-quality`]),r[`scroll-page`]!==void 0&&c(m,[`scrollPage`],r[`scroll-page`]),r.selector!==void 0&&c(m,[`selector`],f(r.selector,`selector`,`text`)),r[`set-java-script-enabled`]!==void 0&&c(m,[`setJavaScriptEnabled`],r[`set-java-script-enabled`]),r.url!==void 0&&c(m,[`url`],f(r.url,`url`,`text`)),r[`user-agent`]!==void 0&&c(m,[`userAgent`],f(r[`user-agent`],`user-agent`,`text`)),r[`viewport-device-scale-factor`]!==void 0&&c(m,[`viewport`,`deviceScaleFactor`],r[`viewport-device-scale-factor`]),r[`viewport-has-touch`]!==void 0&&c(m,[`viewport`,`hasTouch`],r[`viewport-has-touch`]),r[`viewport-height`]!==void 0&&c(m,[`viewport`,`height`],r[`viewport-height`]),r[`viewport-is-landscape`]!==void 0&&c(m,[`viewport`,`isLandscape`],r[`viewport-is-landscape`]),r[`viewport-is-mobile`]!==void 0&&c(m,[`viewport`,`isMobile`],r[`viewport-is-mobile`]),r[`viewport-width`]!==void 0&&c(m,[`viewport`,`width`],r[`viewport-width`]),r[`wait-for-selector-hidden`]!==void 0&&c(m,[`waitForSelector`,`hidden`],r[`wait-for-selector-hidden`]),r[`wait-for-selector-selector`]!==void 0&&c(m,[`waitForSelector`,`selector`],f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`)),r[`wait-for-selector-timeout`]!==void 0&&c(m,[`waitForSelector`,`timeout`],r[`wait-for-selector-timeout`]),r[`wait-for-selector-visible`]!==void 0&&c(m,[`waitForSelector`,`visible`],r[`wait-for-selector-visible`]),r[`wait-for-timeout`]!==void 0&&c(m,[`waitForTimeout`],r[`wait-for-timeout`]);let _=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),v=await s(`Creating`,async()=>g(`/accounts/${p}/browser-rendering/screenshot${_?`?`+_:``}`,{method:`POST`,local:r.local===!0,persistTo:r.persistTo,body:Object.keys(m).length>0?m:void 0}));h(r.text===!0?v.toString(`utf-8`):v)}};function Te(e){return e.option(`cache-ttl`,{type:`number`,description:`Cache TTL default is 5s. Set to 0 to disable.`}).option(`action-timeout`,{type:`number`,description:`The maximum duration allowed for the browser action to complete after the page has loaded (such as taking screenshots, extracting content, or generating PDFs). If this time limit is exceeded, the action stops and returns a timeout error.`}).option(`add-script-tag`,{type:`string`,description:"Adds a `<script>` tag into the page with the desired URL or content. Provide as a JSON array of objects or @path/to/file.json."}).option(`add-style-tag`,{type:`string`,description:'Adds a `<link rel="stylesheet">` tag into the page with the desired URL or a `<style type="text/css">` tag with the content. Provide as a JSON array of objects or @path/to/file.json.'}).option(`allow-request-pattern`,{type:`string`,array:!0,description:`Only allow requests that match the provided regex patterns, eg. '/^.*\\.(css)'. Reject rules are applied first.`}).option(`authenticate-password`,{type:`string`,description:`The authenticate.password field`}).option(`authenticate-username`,{type:`string`,description:`The authenticate.username field`}).option(`best-attempt`,{type:`boolean`,description:`Attempt to proceed when 'awaited' events fail or timeout.`}).option(`cookies`,{type:`string`,description:`Check [options](https://pptr.dev/api/puppeteer.page.setcookie). Provide as a JSON array of objects or @path/to/file.json.`}).option(`emulate-media-type`,{type:`string`,description:`The emulateMediaType field`}).option(`formats`,{type:`string`,array:!0,description:`The formats field`}).option(`goto-options-referer`,{type:`string`,description:`The gotoOptions.referer field`}).option(`goto-options-referrer-policy`,{type:`string`,description:`The gotoOptions.referrerPolicy field`}).option(`goto-options-timeout`,{type:`number`,description:`The gotoOptions.timeout field`}).option(`html`,{type:`string`,description:"Set the content of the page, eg: `<h1>Hello World!!</h1>`. Either `html` or `url` must be set."}).option(`reject-request-pattern`,{type:`string`,array:!0,description:`Block undesired requests that match the provided regex patterns, eg. '/^.*\\.(css)'.`}).option(`screenshot-options-capture-beyond-viewport`,{type:`boolean`,description:`The screenshotOptions.captureBeyondViewport field`}).option(`screenshot-options-clip-height`,{type:`number`,description:`The screenshotOptions.clip.height field`}).option(`screenshot-options-clip-scale`,{type:`number`,description:`The screenshotOptions.clip.scale field`}).option(`screenshot-options-clip-width`,{type:`number`,description:`The screenshotOptions.clip.width field`}).option(`screenshot-options-clip-x`,{type:`number`,description:`The screenshotOptions.clip.x field`}).option(`screenshot-options-clip-y`,{type:`number`,description:`The screenshotOptions.clip.y field`}).option(`screenshot-options-from-surface`,{type:`boolean`,description:`The screenshotOptions.fromSurface field`}).option(`screenshot-options-full-page`,{type:`boolean`,description:`The screenshotOptions.fullPage field`}).option(`screenshot-options-omit-background`,{type:`boolean`,description:`The screenshotOptions.omitBackground field`}).option(`screenshot-options-optimize-for-speed`,{type:`boolean`,description:`The screenshotOptions.optimizeForSpeed field`}).option(`screenshot-options-quality`,{type:`number`,description:`The screenshotOptions.quality field`}).option(`set-java-script-enabled`,{type:`boolean`,description:`The setJavaScriptEnabled field`}).option(`url`,{type:`string`,description:"URL to navigate to, eg. `https://example.com`."}).option(`user-agent`,{type:`string`,description:`The userAgent field`,default:`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36`}).option(`viewport-device-scale-factor`,{type:`number`,description:`The viewport.deviceScaleFactor field`}).option(`viewport-has-touch`,{type:`boolean`,description:`The viewport.hasTouch field`}).option(`viewport-height`,{type:`number`,description:`The viewport.height field`}).option(`viewport-is-landscape`,{type:`boolean`,description:`The viewport.isLandscape field`}).option(`viewport-is-mobile`,{type:`boolean`,description:`The viewport.isMobile field`}).option(`viewport-width`,{type:`number`,description:`The viewport.width field`}).option(`wait-for-selector-hidden`,{type:`boolean`,description:`The waitForSelector.hidden field`}).option(`wait-for-selector-selector`,{type:`string`,description:`The waitForSelector.selector field`}).option(`wait-for-selector-timeout`,{type:`number`,description:`The waitForSelector.timeout field`}).option(`wait-for-selector-visible`,{type:`boolean`,description:`The waitForSelector.visible field`}).option(`wait-for-timeout`,{type:`number`,description:`Waits for a specified timeout before continuing.`}).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([`authenticate-password`,`authenticate-username`].some(t=>e[t]!==void 0)){let t=[`authenticate-password`,`authenticate-username`].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 --authenticate-* flag is set`)}return!0}).check(e=>{if([`screenshot-options-capture-beyond-viewport`,`screenshot-options-clip-height`,`screenshot-options-clip-scale`,`screenshot-options-clip-width`,`screenshot-options-clip-x`,`screenshot-options-clip-y`,`screenshot-options-from-surface`,`screenshot-options-full-page`,`screenshot-options-omit-background`,`screenshot-options-optimize-for-speed`,`screenshot-options-quality`].some(t=>e[t]!==void 0)){let t=[`screenshot-options-clip-height`,`screenshot-options-clip-width`,`screenshot-options-clip-x`,`screenshot-options-clip-y`].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 --screenshotOptions-* flag is set`)}return!0}).check(e=>{if([`viewport-device-scale-factor`,`viewport-has-touch`,`viewport-height`,`viewport-is-landscape`,`viewport-is-mobile`,`viewport-width`].some(t=>e[t]!==void 0)){let t=[`viewport-height`,`viewport-width`].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 --viewport-* flag is set`)}return!0}).check(e=>{if([`wait-for-selector-hidden`,`wait-for-selector-selector`,`wait-for-selector-timeout`,`wait-for-selector-visible`].some(t=>e[t]!==void 0)){let t=[`wait-for-selector-selector`].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 --waitForSelector-* flag is set`)}return!0})}const Ee={command:`snapshot`,describe:"Returns the page's HTML content and screenshot. Control page loading with `gotoOptions` and `waitFor*` options. Customize screenshots with `viewport`, `fullPage`, `clip` and others.",builder:Te,handler:async r=>{let c={cacheTTL:r[`cache-ttl`]};if(r.dryRun){o({command:`cf browser-run quick-action snapshot`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/browser-rendering/snapshot`,pathParams:{},query:c,bodyKind:`json`,body:r.body===void 0?d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),formats:r.formats,gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],screenshotOptions:{captureBeyondViewport:r[`screenshot-options-capture-beyond-viewport`],clip:{height:r[`screenshot-options-clip-height`],scale:r[`screenshot-options-clip-scale`],width:r[`screenshot-options-clip-width`],x:r[`screenshot-options-clip-x`],y:r[`screenshot-options-clip-y`]},fromSurface:r[`screenshot-options-from-surface`],fullPage:r[`screenshot-options-full-page`],omitBackground:r[`screenshot-options-omit-background`],optimizeForSpeed:r[`screenshot-options-optimize-for-speed`],quality:r[`screenshot-options-quality`]},setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]}):l(r.body)});return}let p=await i(r),m=r.local?e:await t();if(r.accountId=m,r.body){let e=l(r.body);new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.snapshot({...e,account_id:m,...c})),{successLabel:`Created`});return}let h=d({actionTimeout:r[`action-timeout`],addScriptTag:u(r[`add-script-tag`],`add-script-tag`),addStyleTag:u(r[`add-style-tag`],`add-style-tag`),allowRequestPattern:r[`allow-request-pattern`],authenticate:{password:f(r[`authenticate-password`],`authenticate-password`,`text`),username:f(r[`authenticate-username`],`authenticate-username`,`text`)},bestAttempt:r[`best-attempt`],cookies:u(r.cookies,`cookies`),emulateMediaType:f(r[`emulate-media-type`],`emulate-media-type`,`text`),formats:r.formats,gotoOptions:{referer:f(r[`goto-options-referer`],`goto-options-referer`,`text`),referrerPolicy:f(r[`goto-options-referrer-policy`],`goto-options-referrer-policy`,`text`),timeout:r[`goto-options-timeout`]},html:f(r.html,`html`,`text`),rejectRequestPattern:r[`reject-request-pattern`],screenshotOptions:{captureBeyondViewport:r[`screenshot-options-capture-beyond-viewport`],clip:{height:r[`screenshot-options-clip-height`],scale:r[`screenshot-options-clip-scale`],width:r[`screenshot-options-clip-width`],x:r[`screenshot-options-clip-x`],y:r[`screenshot-options-clip-y`]},fromSurface:r[`screenshot-options-from-surface`],fullPage:r[`screenshot-options-full-page`],omitBackground:r[`screenshot-options-omit-background`],optimizeForSpeed:r[`screenshot-options-optimize-for-speed`],quality:r[`screenshot-options-quality`]},setJavaScriptEnabled:r[`set-java-script-enabled`],url:f(r.url,`url`,`text`),userAgent:f(r[`user-agent`],`user-agent`,`text`),viewport:{deviceScaleFactor:r[`viewport-device-scale-factor`],hasTouch:r[`viewport-has-touch`],height:r[`viewport-height`],isLandscape:r[`viewport-is-landscape`],isMobile:r[`viewport-is-mobile`],width:r[`viewport-width`]},waitForSelector:{hidden:r[`wait-for-selector-hidden`],selector:f(r[`wait-for-selector-selector`],`wait-for-selector-selector`,`text`),timeout:r[`wait-for-selector-timeout`],visible:r[`wait-for-selector-visible`]},waitForTimeout:r[`wait-for-timeout`]});new URLSearchParams(Object.entries(c).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),a(await s(`Creating`,async()=>p.browserRun.quickAction.snapshot({...h,account_id:m,...c})),{successLabel:`Created`})}},De={command:`quick-action`,describe:`Operations for quick-action`,builder:e=>e.command(de).command(pe).command(he).command(_e).command(ye).command($).command(Se).command(we).command(Ee).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Oe={command:`browser-run`,describe:`browser-run`,builder:e=>e.command(S).command(le).command(De).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{Oe as default};
|