cf 0.0.6 → 0.1.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 +2 -4
- package/bin/cf +11 -0
- package/dist/_meta/agent-context.json +7 -7
- package/dist/_meta/commands.json +9051 -1085
- package/dist/abuse-reports-ChV_yD7f.mjs +8 -0
- package/dist/accounts-BCYecXFh.mjs +21 -0
- package/dist/acm-DD8zSds2.mjs +3 -0
- package/dist/addressing-D4Eqw5Bi.mjs +13 -0
- package/dist/{agent-context-BBJnI_Q7.mjs → agent-context-D26woB9J.mjs} +1 -1
- package/dist/ai-DfXMOMx_.mjs +2 -0
- package/dist/ai-gateway-DdRFthMo.mjs +8 -0
- package/dist/ai-search-C_68CDj1.mjs +7 -0
- package/dist/alerting-DbhqhVCp.mjs +6 -0
- package/dist/analytics-BSBBc7ep.mjs +20 -0
- package/dist/api-gateway-CZ4swbkQ.mjs +33 -0
- package/dist/argo-tms9ZwHO.mjs +2 -0
- package/dist/audit-logs-24qyW8cl.mjs +2 -0
- package/dist/auth-BlSmtIKd.mjs +112 -0
- package/dist/auth-DQ8miey6.mjs +6 -0
- package/dist/autorag-kgNt06GD.mjs +2 -0
- package/dist/billing-lwBHNTXC.mjs +2 -0
- package/dist/body-parser-Br-BoYk-.mjs +2 -0
- package/dist/bot-management-LKf7BqUr.mjs +5 -0
- package/dist/botnet-feed-nQ-gErTS.mjs +3 -0
- package/dist/brand-protection-DOKv9GRr.mjs +3 -0
- package/dist/browser-rendering-CBExtgGt.mjs +4 -0
- package/dist/build-C_48VvoK.mjs +1056 -0
- package/dist/{builds-B5sC8Gh_.mjs → builds-C_ySULja.mjs} +1 -1
- package/dist/cache-BBiiNZHP.mjs +5 -0
- package/dist/calls-DA5Xzwev.mjs +4 -0
- package/dist/certificate-authorities-sXyR_yGp.mjs +2 -0
- package/dist/chunk-DH-VkVmc.mjs +2 -0
- package/dist/client-certificates-tV0aCLQJ.mjs +3 -0
- package/dist/cloud-connector-DZfHcSso.mjs +2 -0
- package/dist/cloudforce-one-y1PgQmI9.mjs +21 -0
- package/dist/{completions-BSRqbcrz.mjs → completions-BKrxcfhN.mjs} +1 -1
- package/dist/config-BIfdEY0E.mjs +2 -0
- package/dist/connectivity-8SOqaFDn.mjs +3 -0
- package/dist/content-scanning-B9y6K_G5.mjs +4 -0
- package/dist/context-DTIbtQn5.mjs +2 -0
- package/dist/custom-certificates-sWksR8Ys.mjs +5 -0
- package/dist/custom-hostnames-91QZkdqN.mjs +5 -0
- package/dist/custom-nameservers-DajZaZvE.mjs +3 -0
- package/dist/custom-pages-Cu7gmwzT.mjs +4 -0
- package/dist/d1-H_VRsVmF.mjs +3 -0
- package/dist/dcv-delegation-C-qhEYEZ.mjs +2 -0
- package/dist/delegate.mjs +2 -0
- package/dist/deploy--9wYOkHg.mjs +2 -0
- package/dist/dev-BfKYB-R_.mjs +6 -0
- package/dist/diagnostics-D2B2LPZZ.mjs +3 -0
- package/dist/dispatch-namespaces-CyrXBU_w.mjs +7 -0
- package/dist/dist-C_bu5HwZ.mjs +82 -0
- package/dist/dist-DvKjT2TT.mjs +303 -0
- package/dist/dns-Bn9Uz_Nj.mjs +29 -0
- package/dist/dns-firewall-BslP4p-j.mjs +57 -0
- package/dist/durable-objects-BN1ZnHhm.mjs +2 -0
- package/dist/email-routing-n2TnTaRR.mjs +10 -0
- package/dist/email-security-C9SEx0kh.mjs +60 -0
- package/dist/email-sending-DayZ7u3I.mjs +3 -0
- package/dist/filters-CI_XTgfQ.mjs +4 -0
- package/dist/firewall-CcaayGig.mjs +11 -0
- package/dist/fraud-Cr7aPCV8.mjs +8 -0
- package/dist/google-tag-gateway-B3GpYgQ4.mjs +2 -0
- package/dist/healthchecks-CVTsR_OC.mjs +4 -0
- package/dist/hostnames-Bd_Wa5l6.mjs +3 -0
- package/dist/hyperdrive-BBJhEDZd.mjs +18 -0
- package/dist/iam-D_FN0pDF.mjs +6 -0
- package/dist/images-CAP2hAlZ.mjs +5 -0
- package/dist/index.mjs +1 -1
- package/dist/input-validation-zEO81MWN.mjs +2 -0
- package/dist/intel-CkxfzqmJ.mjs +3 -0
- package/dist/ips-B0cK7D0_.mjs +2 -0
- package/dist/keyless-certificates-LcLmHZsX.mjs +3 -0
- package/dist/kv-_TkUQ6fs.mjs +5 -0
- package/dist/leaked-credential-checks-Dhvaen22.mjs +3 -0
- package/dist/lib-Eu1wXxuh.mjs +68 -0
- package/dist/load-balancers-Ckr0UIpk.mjs +6 -0
- package/dist/local-VJaJ3BZ1.mjs +2 -0
- package/dist/logpush-Cj946hxT.mjs +4 -0
- package/dist/logs-DgC9hjvJ.mjs +3 -0
- package/dist/magic-cloud-networking-WbDvPzuG.mjs +5 -0
- package/dist/magic-network-monitoring-BcHShvGQ.mjs +4 -0
- package/dist/magic-transit-B8sCOkt_.mjs +89 -0
- package/dist/managed-transforms-BpOr-8HY.mjs +3 -0
- package/dist/mtls-certificates-fOul8D5g.mjs +3 -0
- package/dist/network-interconnects-BSW65xlh.mjs +36 -0
- package/dist/organizations-T4vKGFAb.mjs +41 -0
- package/dist/origin-ca-certificates-ChM0lZ64.mjs +3 -0
- package/dist/origin-post-quantum-encryption-C7o26ARh.mjs +2 -0
- package/dist/origin-tls-client-auth-D32dpZk_.mjs +5 -0
- package/dist/{output-CqGQp2r6.mjs → output-D7_yAFVR.mjs} +1 -1
- package/dist/page-rules-RFoj8CjN.mjs +18 -0
- package/dist/page-shield-VTktzKDN.mjs +37 -0
- package/dist/pages-L1ITjXDZ.mjs +10 -0
- package/dist/pipelines-BPO0Lnil.mjs +6 -0
- package/dist/progress-DZfTxbrx.mjs +2 -0
- package/dist/queues-B0C06L9r.mjs +6 -0
- package/dist/r2-DP020Tmq.mjs +21 -0
- package/dist/r2-data-catalog-Dmipvz5F.mjs +14 -0
- package/dist/radar-DR3VMknH.mjs +2 -0
- package/dist/rate-limits-DnHPBPgU.mjs +5 -0
- package/dist/raw-fetch-DlXYwVA8.mjs +2 -0
- package/dist/realtime-kit-C430aq2d.mjs +6 -0
- package/dist/registrar-7Qy50zbW.mjs +46 -0
- package/dist/request-tracers-sv99NDIl.mjs +2 -0
- package/dist/resolve-BuJRWSk0.mjs +2 -0
- package/dist/resource-sharing-uEjC7lnQ.mjs +5 -0
- package/dist/resource-tagging-CiODdP3N.mjs +16 -0
- package/dist/rules-FXAyTrwk.mjs +4 -0
- package/dist/rulesets-B6aUsFFB.mjs +8 -0
- package/dist/rum-CyyGJhp5.mjs +4 -0
- package/dist/{schema-qJlCfmo8.mjs → schema-D0_cbcDt.mjs} +1 -1
- package/dist/schema-validation-ByU49h--.mjs +4 -0
- package/dist/scim-DdTS65_C.mjs +3 -0
- package/dist/{scm-C872x0C2.mjs → scm-CilfPOue.mjs} +1 -1
- package/dist/secrets-store-ClOUVhBJ.mjs +18 -0
- package/dist/security-center-4iSBqTrf.mjs +2 -0
- package/dist/security-txt-kGxdkDY6.mjs +3 -0
- package/dist/session-mW-s8ghP.mjs +2 -0
- package/dist/smart-shield-B-SQd2Qp.mjs +3 -0
- package/dist/snippets-Aq58ojqw.mjs +4 -0
- package/dist/spawn-D_cjG87Z.mjs +10 -0
- package/dist/spectrum-0gFvGI6y.mjs +59 -0
- package/dist/speed-DAZU8w3T.mjs +4 -0
- package/dist/src-C5qivNKH.mjs +108 -0
- package/dist/ssl-BRlXa-5w.mjs +15 -0
- package/dist/stream-BAxsVeBX.mjs +14 -0
- package/dist/tenants-Df6xDqoA.mjs +2 -0
- package/dist/{theme-BKCxTQTe.mjs → theme-BklJDrb2.mjs} +2 -2
- package/dist/token-validation-pO4dCjCy.mjs +4 -0
- package/dist/{tools-CawscCBu.mjs → tools-CtKbk6VS.mjs} +1 -1
- package/dist/turnstile-B1dmO8wE.mjs +23 -0
- package/dist/{ui-Dj3No2vN.mjs → ui-mP_arYIg.mjs} +1 -1
- package/dist/url-normalization-sUDVmrUt.mjs +3 -0
- package/dist/url-scanner-CwOKRkYo.mjs +2 -0
- package/dist/user-D_UrIdNq.mjs +10 -0
- package/dist/vectorize-BEbBn9G9.mjs +4 -0
- package/dist/{vuln-scanner-B1VwCIko.mjs → vuln-scanner-Br_2lQp1.mjs} +1 -1
- package/dist/waiting-rooms-BQC-urV4.mjs +11 -0
- package/dist/web3-CIH2iQeX.mjs +4 -0
- package/dist/workers-B9EvrpH3.mjs +16 -0
- package/dist/workers-builds-DzWSiRd2.mjs +7 -0
- package/dist/workflows-aD81gA4k.mjs +4 -0
- package/dist/zaraz-Cg1dsvrZ.mjs +2 -0
- package/dist/zero-trust-D-xQXWcy.mjs +119 -0
- package/dist/zones-DQzucJDd.mjs +28 -0
- package/package.json +13 -3
- package/dist/abuse-reports-DR0yMg-Q.mjs +0 -2
- package/dist/accounts-BjGtCB8T.mjs +0 -6
- package/dist/acm-h4YPDN7k.mjs +0 -3
- package/dist/addressing-BiEnQ1o1.mjs +0 -11
- package/dist/ai-BPln2Yka.mjs +0 -2
- package/dist/ai-gateway-DgD9nKyd.mjs +0 -8
- package/dist/ai-search-EjrONI5a.mjs +0 -7
- package/dist/alerting-CPWMKr-m.mjs +0 -6
- package/dist/analytics-3dX9-scQ.mjs +0 -2
- package/dist/api-gateway-7FKFHdI-.mjs +0 -9
- package/dist/argo-Dxz9P37E.mjs +0 -2
- package/dist/audit-logs-D_Xw5x8Y.mjs +0 -2
- package/dist/auth-BHD_B2p9.mjs +0 -277
- package/dist/auth-caVo2j1K.mjs +0 -6
- package/dist/autorag-D7nMweNF.mjs +0 -2
- package/dist/billing-yaIBp1Xq.mjs +0 -2
- package/dist/body-parser-iA3vRFmh.mjs +0 -2
- package/dist/bot-management-C0H6U0t4.mjs +0 -2
- package/dist/botnet-feed-BXV9GVwF.mjs +0 -3
- package/dist/brand-protection-CI0NQa_l.mjs +0 -3
- package/dist/browser-rendering-DnKNRJJe.mjs +0 -4
- package/dist/cache-B6M_pm_D.mjs +0 -5
- package/dist/calls-C5XCC0i1.mjs +0 -4
- package/dist/certificate-authorities-BQuHL4dm.mjs +0 -2
- package/dist/client-certificates-CwpzEnCT.mjs +0 -3
- package/dist/cloud-connector-CU3PLNLe.mjs +0 -2
- package/dist/cloudforce-one-DzrArr1o.mjs +0 -21
- package/dist/config-BmTd_qeU.mjs +0 -2
- package/dist/connectivity-C4tXPkW_.mjs +0 -3
- package/dist/content-scanning-CH_YXdlZ.mjs +0 -4
- package/dist/context-6lBIck1r.mjs +0 -2
- package/dist/custom-certificates-pllRyU2y.mjs +0 -3
- package/dist/custom-hostnames-GmF0DfYA.mjs +0 -5
- package/dist/custom-nameservers-DPVHUlUQ.mjs +0 -3
- package/dist/custom-pages-XWwfn7hV.mjs +0 -4
- package/dist/d1-c_zhZGWf.mjs +0 -3
- package/dist/dcv-delegation-pXpU48A8.mjs +0 -2
- package/dist/dev-Bu26u5Jm.mjs +0 -14
- package/dist/diagnostics-BU07Jnku.mjs +0 -3
- package/dist/dispatch-namespaces-D_Kq_2gX.mjs +0 -7
- package/dist/dns-CrvIxztB.mjs +0 -11
- package/dist/dns-firewall-CLtGAQ9x.mjs +0 -3
- package/dist/dry-run-FV0pZwdg.mjs +0 -2
- package/dist/durable-objects-Y5rLFSQX.mjs +0 -2
- package/dist/email-routing-CxU5JlXT.mjs +0 -10
- package/dist/email-security-CnpAHWpj.mjs +0 -8
- package/dist/email-sending-MeCKsktR.mjs +0 -3
- package/dist/filters-Sx2Po1UP.mjs +0 -4
- package/dist/firewall-B0_012XO.mjs +0 -9
- package/dist/fraud-CG0G_VG-.mjs +0 -2
- package/dist/google-tag-gateway-BLbj1y3h.mjs +0 -2
- package/dist/healthchecks-C0LgExxa.mjs +0 -4
- package/dist/hostnames-D4K6s9EX.mjs +0 -3
- package/dist/hyperdrive-D7XvTRys.mjs +0 -3
- package/dist/iam-4LhJianW.mjs +0 -6
- package/dist/images-BqXyIycX.mjs +0 -5
- package/dist/input-validation-BpVQi9rR.mjs +0 -2
- package/dist/intel-CiO3Sy4x.mjs +0 -3
- package/dist/ips-DLuGN7Mr.mjs +0 -2
- package/dist/keyless-certificates-x-87T5SM.mjs +0 -3
- package/dist/kv-CVYCrk7L.mjs +0 -5
- package/dist/leaked-credential-checks-FvhVCL23.mjs +0 -3
- package/dist/load-balancers-cxodJuI2.mjs +0 -6
- package/dist/local-OqhVQbv0.mjs +0 -2
- package/dist/logpush-BX7z2xWz.mjs +0 -4
- package/dist/logs-C7vxr6Kp.mjs +0 -3
- package/dist/magic-cloud-networking-C3grROf-.mjs +0 -5
- package/dist/magic-network-monitoring-DiZ5ZXxh.mjs +0 -4
- package/dist/magic-transit-troGMFb9.mjs +0 -30
- package/dist/managed-transforms-B5w_LlVN.mjs +0 -3
- package/dist/mtls-certificates-C1S9MciH.mjs +0 -3
- package/dist/network-interconnects-CVSiv1fF.mjs +0 -4
- package/dist/organizations-BtlEchi-.mjs +0 -4
- package/dist/origin-ca-certificates-0XCi4dO6.mjs +0 -3
- package/dist/origin-post-quantum-encryption-CTvkdYDG.mjs +0 -2
- package/dist/origin-tls-client-auth-qAvRD1BQ.mjs +0 -5
- package/dist/page-rules-CcMmrvY4.mjs +0 -3
- package/dist/page-shield-Dxh4bJ-w.mjs +0 -3
- package/dist/pages-F1vdzqgC.mjs +0 -6
- package/dist/pipelines-DsF1HHMY.mjs +0 -6
- package/dist/progress-5sHFvwez.mjs +0 -2
- package/dist/queues-BuvkxFPX.mjs +0 -6
- package/dist/r2-Du-fgHiT.mjs +0 -9
- package/dist/r2-data-catalog-BUiMNSwc.mjs +0 -3
- package/dist/radar-C0eqNmWR.mjs +0 -2
- package/dist/rate-limits-CUv2cxXV.mjs +0 -3
- package/dist/raw-fetch-CxFs4i0R.mjs +0 -2
- package/dist/realtime-kit-C-jix3I_.mjs +0 -6
- package/dist/registrar-B7V7i89n.mjs +0 -2
- package/dist/request-tracers-D2V7QUrC.mjs +0 -2
- package/dist/resolve-GtphSYWh.mjs +0 -2
- package/dist/resource-sharing-BgH0w9wm.mjs +0 -5
- package/dist/resource-tagging-BOknFugv.mjs +0 -4
- package/dist/rolldown-runtime-CR7SCCRW.mjs +0 -2
- package/dist/rules-DzJFHGW1.mjs +0 -4
- package/dist/rulesets-BzI1dUiq.mjs +0 -8
- package/dist/rum-CQ_rJ96u.mjs +0 -4
- package/dist/schema-validation-TmikfxS9.mjs +0 -4
- package/dist/scim-ByZ5kqXS.mjs +0 -3
- package/dist/secrets-store-D7HL4VXw.mjs +0 -8
- package/dist/security-center-OUrILUnx.mjs +0 -2
- package/dist/security-txt-Ca13oCJ8.mjs +0 -3
- package/dist/session-Dxi_LbAk.mjs +0 -2
- package/dist/smart-shield-foPT0J9L.mjs +0 -3
- package/dist/snippets-FDPiBMWc.mjs +0 -4
- package/dist/spectrum-DPoh_BPx.mjs +0 -3
- package/dist/speed-BuEappVX.mjs +0 -4
- package/dist/src-D8_cWUwt.mjs +0 -104
- package/dist/ssl-bJbzEoRv.mjs +0 -3
- package/dist/stream-DuYGiGk6.mjs +0 -13
- package/dist/tenants-BYqEutrr.mjs +0 -2
- package/dist/token-validation-DwmtbWUB.mjs +0 -4
- package/dist/turnstile-Dy91RVTn.mjs +0 -3
- package/dist/url-normalization-DoD9iHWH.mjs +0 -3
- package/dist/url-scanner-qwL64FIo.mjs +0 -2
- package/dist/user-Cduf3VRi.mjs +0 -7
- package/dist/vectorize-CMLobU9V.mjs +0 -4
- package/dist/waiting-rooms-B4-IAJeT.mjs +0 -5
- package/dist/web3-Bcx68Kq3.mjs +0 -4
- package/dist/workers-D5fOQsUA.mjs +0 -16
- package/dist/workers-builds-2kdzxjlN.mjs +0 -7
- package/dist/workflows-qFD80noW.mjs +0 -4
- package/dist/zaraz-C0iJimA4.mjs +0 -2
- package/dist/zero-trust-Btix6zOy.mjs +0 -73
- package/dist/zones-Nu3wMtds.mjs +0 -5
- /package/dist/{metadata-DhSO1vle.mjs → metadata-DGdCpUxn.mjs} +0 -0
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{d as e,h as t,l as n,m as r,o as i,p as a,t as o,u as s}from"./auth-BHD_B2p9.mjs";import{i as c,n as l,r as u}from"./input-validation-BpVQi9rR.mjs";import{n as d,t as f}from"./body-parser-iA3vRFmh.mjs";import{t as p}from"./output-CqGQp2r6.mjs";import{t as m}from"./dry-run-FV0pZwdg.mjs";import{t as h}from"./local-OqhVQbv0.mjs";import{t as g}from"./progress-5sHFvwez.mjs";import{n as _,t as v}from"./raw-fetch-CxFs4i0R.mjs";const y={command:`get`,describe:`Fetches Worker account settings for an account.`,builder:e=>e,handler:async e=>{let t=await o(e),n=e.local?h:await i(t);e.accountId=n,p(await g(`Loading account setting`,async()=>t.workers.accountSettings.get(n)),{successLabel:`Loaded account setting`})}},ee={command:`update`,describe:`Creates Worker account settings for an account.`,builder:e=>e.option(`default-usage-model`,{type:`string`,description:`The default_usage_model field`}).option(`green-compute`,{type:`boolean`,description:`The green_compute 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)`}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers account-settings update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/account-settings`,pathParams:{},bodyKind:`json`,body:{defaultUsageModel:t.defaultUsageModel,greenCompute:t.greenCompute,body:t.body},validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,t.body){let e=f(t.body);p(await g(`Updating account setting`,async()=>n.put(`/accounts/${r}/workers/account-settings`,{body:e})),{successLabel:`Updated account setting`});return}let a={};t.defaultUsageModel!==void 0&&d(a,[`default_usage_model`],l(t.defaultUsageModel,`defaultUsageModel`,`text`)),t.greenCompute!==void 0&&d(a,[`green_compute`],t.greenCompute),p(await g(`Updating account setting`,async()=>n.put(`/accounts/${r}/workers/account-settings`,{body:Object.keys(a).length>0?a:void 0})),{successLabel:`Updated account setting`})}},te={command:`account-settings`,describe:`Account-wide Worker settings such as default usage model and green compute`,builder:e=>e.command(y).command(ee).demandCommand(1),handler:()=>{}},b={command:`list`,describe:`Lists all the container applications that are associated with your account.`,builder:e=>e.option(`name`,{type:`string`,description:`Filter containers by name`}).option(`image`,{type:`string`,description:`Filter containers by image`}),handler:async e=>{let t={};e.name!==void 0&&(t.name=e.name),e.image!==void 0&&(t.image=e.image);let n=await o(e),r=e.local?h:await i(n);e.accountId=r,p(await g(`Loading applications`,async()=>n.workers.applications.list(r,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded applications`})}},x={command:`applications`,describe:`Public worker application listing`,builder:e=>e.command(b).demandCommand(1),handler:()=>{}},S={command:`create`,describe:`Upload assets ahead of creating a Worker version. To learn more about the direct uploads of assets, see https://developers.cloudflare.com/workers/static-assets/direct-upload/.`,builder:e=>e.option(`base64`,{type:`boolean`,description:"Whether the file contents are base64-encoded. Must be `true`.",demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}),handler:async t=>{let n={};if(t.base64!==void 0&&(n.base64=t.base64),t.dryRun){let r=e();r&&u(r,`accountId`),m({command:`cf workers assets upload create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r??`<account-id>`}/workers/assets/upload`,pathParams:{},bodyKind:`octet-stream`,body:{...n,body:t.body,file:t.file},validation:`passed`});return}let r=await o(t),a=t.local?h:await i(r);if(t.accountId=a,t.file){let{readFileSync:e}=await import(`node:fs`),{resolve:n}=await import(`node:path`),i=e(n(t.file)),o=new FormData;o.append(`file`,new Blob([i]),t.file.split(`/`).pop()),p(await g(`Creating upload`,async()=>r.post(`/accounts/${a}/workers/assets/upload`,{body:o})),{successLabel:`Created upload`});return}if(t.body){let e=l(t.body,`body`,`binary`),i=new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();p(await g(`Creating upload`,async()=>r.post(`/accounts/${a}/workers/assets/upload${i?`?`+i:``}`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created upload`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},C={command:`upload`,describe:`Upload static assets that are served alongside a Worker`,builder:e=>e.command(S).demandCommand(1),handler:()=>{}},w={command:`assets`,describe:`Operations for assets`,builder:e=>e.command(C).demandCommand(1),handler:()=>{}},T={command:`create`,describe:`Create a new Worker.`,builder:e=>e.option(`logpush`,{type:`boolean`,description:`Whether logpush is enabled for the Worker.`,default:!1}).option(`name`,{type:`string`,description:`Name of the Worker.`}).option(`observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`,default:!1}).option(`observability-head-sampling-rate`,{type:`number`,description:`The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).`,default:1}).option(`observability-logs-destinations`,{type:`string`,array:!0,description:`A list of destinations where logs will be exported to.`}).option(`observability-logs-enabled`,{type:`boolean`,description:`Whether logs are enabled for the Worker.`,default:!1}).option(`observability-logs-head-sampling-rate`,{type:`number`,description:`The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).`,default:1}).option(`observability-logs-invocation-logs`,{type:`boolean`,description:`Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.`,default:!0}).option(`observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`,default:!0}).option(`observability-traces-destinations`,{type:`string`,array:!0,description:`A list of destinations where traces will be exported to.`}).option(`observability-traces-enabled`,{type:`boolean`,description:`Whether traces are enabled for the Worker.`,default:!1}).option(`observability-traces-head-sampling-rate`,{type:`number`,description:`The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).`,default:1}).option(`observability-traces-persist`,{type:`boolean`,description:`Whether trace persistence is enabled for the Worker.`,default:!0}).option(`subdomain-enabled`,{type:`boolean`,description:`Whether the *.workers.dev subdomain is enabled for the Worker.`,default:!1}).option(`subdomain-previews-enabled`,{type:`boolean`,description:`Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.`}).option(`tags`,{type:`string`,array:!0,description:`Tags associated with the Worker.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Worker creation parameters.`}),handler:async n=>{if(n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers beta workers create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/workers`,pathParams:{},bodyKind:`json`,body:{logpush:n.logpush,name:n.name,observabilityEnabled:n.observabilityEnabled,observabilityHeadSamplingRate:n.observabilityHeadSamplingRate,observabilityLogsDestinations:n.observabilityLogsDestinations,observabilityLogsEnabled:n.observabilityLogsEnabled,observabilityLogsHeadSamplingRate:n.observabilityLogsHeadSamplingRate,observabilityLogsInvocationLogs:n.observabilityLogsInvocationLogs,observabilityLogsPersist:n.observabilityLogsPersist,observabilityTracesDestinations:n.observabilityTracesDestinations,observabilityTracesEnabled:n.observabilityTracesEnabled,observabilityTracesHeadSamplingRate:n.observabilityTracesHeadSamplingRate,observabilityTracesPersist:n.observabilityTracesPersist,subdomainEnabled:n.subdomainEnabled,subdomainPreviewsEnabled:n.subdomainPreviewsEnabled,tags:n.tags,body:n.body},validation:`passed`});return}let r=await o(n),a=n.local?h:await i(r);if(n.accountId=a,n.body){let e=f(n.body);p(await g(`Creating worker`,async()=>r.post(`/accounts/${a}/workers/workers`,{body:e})),{successLabel:`Created worker`});return}if(n.logpush===void 0)throw Error(`--logpush is required (or pass --body with this field set).`);if(n.name===void 0&&(n.name=await t(`name`,`Name of the Worker.`)),n.tags===void 0)throw Error(`--tags is required (or pass --body with this field set).`);let s={};n.logpush!==void 0&&d(s,[`logpush`],n.logpush),n.name!==void 0&&d(s,[`name`],l(n.name,`name`,`text`)),n.observabilityEnabled!==void 0&&d(s,[`observability`,`enabled`],n.observabilityEnabled),n.observabilityHeadSamplingRate!==void 0&&d(s,[`observability`,`head_sampling_rate`],n.observabilityHeadSamplingRate),n.observabilityLogsDestinations!==void 0&&d(s,[`observability`,`logs`,`destinations`],n.observabilityLogsDestinations),n.observabilityLogsEnabled!==void 0&&d(s,[`observability`,`logs`,`enabled`],n.observabilityLogsEnabled),n.observabilityLogsHeadSamplingRate!==void 0&&d(s,[`observability`,`logs`,`head_sampling_rate`],n.observabilityLogsHeadSamplingRate),n.observabilityLogsInvocationLogs!==void 0&&d(s,[`observability`,`logs`,`invocation_logs`],n.observabilityLogsInvocationLogs),n.observabilityLogsPersist!==void 0&&d(s,[`observability`,`logs`,`persist`],n.observabilityLogsPersist),n.observabilityTracesDestinations!==void 0&&d(s,[`observability`,`traces`,`destinations`],n.observabilityTracesDestinations),n.observabilityTracesEnabled!==void 0&&d(s,[`observability`,`traces`,`enabled`],n.observabilityTracesEnabled),n.observabilityTracesHeadSamplingRate!==void 0&&d(s,[`observability`,`traces`,`head_sampling_rate`],n.observabilityTracesHeadSamplingRate),n.observabilityTracesPersist!==void 0&&d(s,[`observability`,`traces`,`persist`],n.observabilityTracesPersist),n.subdomainEnabled!==void 0&&d(s,[`subdomain`,`enabled`],n.subdomainEnabled),n.subdomainPreviewsEnabled!==void 0&&d(s,[`subdomain`,`previews_enabled`],n.subdomainPreviewsEnabled),n.tags!==void 0&&d(s,[`tags`],n.tags),p(await g(`Creating worker`,async()=>r.post(`/accounts/${a}/workers/workers`,{body:Object.keys(s).length>0?s:void 0})),{successLabel:`Created worker`})}},E={command:`delete <workerId>`,describe:`Delete a Worker and all its associated resources (versions, deployments, etc.).`,builder:e=>e.positional(`workerId`,{type:`string`,description:`Identifier for the Worker, which can be ID or name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}),handler:async t=>{if(u(t.workerId,`workerId`),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers beta workers delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/workers/${t.workerId??`<workerId>`}`,pathParams:{workerId:String(t.workerId??``)},bodyKind:`none`,validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,!await a(`worker`,String(t.workerId??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
3
|
-
`);return}p(await g(`Deleting worker`,async()=>n.workers.beta.workers.delete(r,t.workerId)),{successLabel:`Deleted worker`})}},D={command:`edit <workerId>`,describe:`Perform a partial update on a Worker, where omitted properties are left unchanged from their current values.`,builder:e=>e.positional(`workerId`,{type:`string`,description:`Identifier for the Worker, which can be ID or name.`,demandOption:!0}).option(`logpush`,{type:`boolean`,description:`Whether logpush is enabled for the Worker.`,default:!1}).option(`name`,{type:`string`,description:`Name of the Worker.`}).option(`observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`,default:!1}).option(`observability-head-sampling-rate`,{type:`number`,description:`The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).`,default:1}).option(`observability-logs-destinations`,{type:`string`,array:!0,description:`A list of destinations where logs will be exported to.`}).option(`observability-logs-enabled`,{type:`boolean`,description:`Whether logs are enabled for the Worker.`,default:!1}).option(`observability-logs-head-sampling-rate`,{type:`number`,description:`The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).`,default:1}).option(`observability-logs-invocation-logs`,{type:`boolean`,description:`Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.`,default:!0}).option(`observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`,default:!0}).option(`observability-traces-destinations`,{type:`string`,array:!0,description:`A list of destinations where traces will be exported to.`}).option(`observability-traces-enabled`,{type:`boolean`,description:`Whether traces are enabled for the Worker.`,default:!1}).option(`observability-traces-head-sampling-rate`,{type:`number`,description:`The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).`,default:1}).option(`observability-traces-persist`,{type:`boolean`,description:`Whether trace persistence is enabled for the Worker.`,default:!0}).option(`subdomain-enabled`,{type:`boolean`,description:`Whether the *.workers.dev subdomain is enabled for the Worker.`,default:!1}).option(`subdomain-previews-enabled`,{type:`boolean`,description:`Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.`}).option(`tags`,{type:`string`,array:!0,description:`Tags associated with the Worker.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Worker partial update parameters.`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}),handler:async n=>{if(u(n.workerId,`workerId`),n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers beta workers edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/workers/${n.workerId??`<workerId>`}`,pathParams:{workerId:String(n.workerId??``)},bodyKind:`json`,body:{logpush:n.logpush,name:n.name,observabilityEnabled:n.observabilityEnabled,observabilityHeadSamplingRate:n.observabilityHeadSamplingRate,observabilityLogsDestinations:n.observabilityLogsDestinations,observabilityLogsEnabled:n.observabilityLogsEnabled,observabilityLogsHeadSamplingRate:n.observabilityLogsHeadSamplingRate,observabilityLogsInvocationLogs:n.observabilityLogsInvocationLogs,observabilityLogsPersist:n.observabilityLogsPersist,observabilityTracesDestinations:n.observabilityTracesDestinations,observabilityTracesEnabled:n.observabilityTracesEnabled,observabilityTracesHeadSamplingRate:n.observabilityTracesHeadSamplingRate,observabilityTracesPersist:n.observabilityTracesPersist,subdomainEnabled:n.subdomainEnabled,subdomainPreviewsEnabled:n.subdomainPreviewsEnabled,tags:n.tags,body:n.body,file:n.file},validation:`passed`});return}let r=await o(n),a=n.local?h:await i(r);if(n.accountId=a,n.file){let{readFileSync:e}=await import(`node:fs`),{resolve:t}=await import(`node:path`),i=e(t(n.file));p(await g(`Updating worker`,async()=>r.patch(`/accounts/${a}/workers/workers/${n.workerId}`,{body:i,headers:{"Content-Type":`application/merge-patch+json`}})),{successLabel:`Updated worker`});return}if(n.body){let e=f(n.body);p(await g(`Updating worker`,async()=>r.patch(`/accounts/${a}/workers/workers/${n.workerId}`,{body:e})),{successLabel:`Updated worker`});return}if(n.logpush===void 0)throw Error(`--logpush is required (or pass --body with this field set).`);if(n.name===void 0&&(n.name=await t(`name`,`Name of the Worker.`)),n.tags===void 0)throw Error(`--tags is required (or pass --body with this field set).`);let s={};n.logpush!==void 0&&d(s,[`logpush`],n.logpush),n.name!==void 0&&d(s,[`name`],l(n.name,`name`,`text`)),n.observabilityEnabled!==void 0&&d(s,[`observability`,`enabled`],n.observabilityEnabled),n.observabilityHeadSamplingRate!==void 0&&d(s,[`observability`,`head_sampling_rate`],n.observabilityHeadSamplingRate),n.observabilityLogsDestinations!==void 0&&d(s,[`observability`,`logs`,`destinations`],n.observabilityLogsDestinations),n.observabilityLogsEnabled!==void 0&&d(s,[`observability`,`logs`,`enabled`],n.observabilityLogsEnabled),n.observabilityLogsHeadSamplingRate!==void 0&&d(s,[`observability`,`logs`,`head_sampling_rate`],n.observabilityLogsHeadSamplingRate),n.observabilityLogsInvocationLogs!==void 0&&d(s,[`observability`,`logs`,`invocation_logs`],n.observabilityLogsInvocationLogs),n.observabilityLogsPersist!==void 0&&d(s,[`observability`,`logs`,`persist`],n.observabilityLogsPersist),n.observabilityTracesDestinations!==void 0&&d(s,[`observability`,`traces`,`destinations`],n.observabilityTracesDestinations),n.observabilityTracesEnabled!==void 0&&d(s,[`observability`,`traces`,`enabled`],n.observabilityTracesEnabled),n.observabilityTracesHeadSamplingRate!==void 0&&d(s,[`observability`,`traces`,`head_sampling_rate`],n.observabilityTracesHeadSamplingRate),n.observabilityTracesPersist!==void 0&&d(s,[`observability`,`traces`,`persist`],n.observabilityTracesPersist),n.subdomainEnabled!==void 0&&d(s,[`subdomain`,`enabled`],n.subdomainEnabled),n.subdomainPreviewsEnabled!==void 0&&d(s,[`subdomain`,`previews_enabled`],n.subdomainPreviewsEnabled),n.tags!==void 0&&d(s,[`tags`],n.tags),p(await g(`Updating worker`,async()=>r.patch(`/accounts/${a}/workers/workers/${n.workerId}`,{body:Object.keys(s).length>0?s:void 0})),{successLabel:`Updated worker`})}},O={command:`get <workerId>`,describe:`Get details about a specific Worker.`,builder:e=>e.positional(`workerId`,{type:`string`,description:`Identifier for the Worker, which can be ID or name.`,demandOption:!0}),handler:async e=>{u(e.workerId,`workerId`);let t=await o(e),n=e.local?h:await i(t);e.accountId=n,p(await g(`Loading worker`,async()=>t.workers.beta.workers.get(n,e.workerId)),{successLabel:`Loaded worker`})}},k={command:`list`,describe:`List all Workers for an account.`,builder:e=>e.option(`page`,{type:`number`,description:`Current page.`}).option(`per-page`,{type:`number`,description:`Items per-page.`}).option(`order-by`,{type:`string`,description:`Property to sort results by.`,choices:[`deployed_on`,`updated_on`,`created_on`,`name`]}).option(`order`,{type:`string`,description:`Sort direction.`,choices:[`asc`,`desc`]}),handler:async e=>{let t={};e.page!==void 0&&(t.page=e.page),e.perPage!==void 0&&(t.per_page=e.perPage),e.orderBy!==void 0&&(t.order_by=e.orderBy),e.order!==void 0&&(t.order=e.order);let n=await o(e),r=e.local?h:await i(n);e.accountId=r,p(await g(`Loading workers`,async()=>n.workers.beta.workers.list(r,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded workers`})}},A={command:`update <workerId>`,describe:`Perform a complete replacement of a Worker, where omitted properties are set to their default values. This is the exact same as the Create Worker endpoint, but operates on an existing Worker. To perform a partial update instead, use the Edit Worker endpoint.`,builder:e=>e.positional(`workerId`,{type:`string`,description:`Identifier for the Worker, which can be ID or name.`,demandOption:!0}).option(`logpush`,{type:`boolean`,description:`Whether logpush is enabled for the Worker.`,default:!1}).option(`name`,{type:`string`,description:`Name of the Worker.`}).option(`observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`,default:!1}).option(`observability-head-sampling-rate`,{type:`number`,description:`The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).`,default:1}).option(`observability-logs-destinations`,{type:`string`,array:!0,description:`A list of destinations where logs will be exported to.`}).option(`observability-logs-enabled`,{type:`boolean`,description:`Whether logs are enabled for the Worker.`,default:!1}).option(`observability-logs-head-sampling-rate`,{type:`number`,description:`The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).`,default:1}).option(`observability-logs-invocation-logs`,{type:`boolean`,description:`Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.`,default:!0}).option(`observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`,default:!0}).option(`observability-traces-destinations`,{type:`string`,array:!0,description:`A list of destinations where traces will be exported to.`}).option(`observability-traces-enabled`,{type:`boolean`,description:`Whether traces are enabled for the Worker.`,default:!1}).option(`observability-traces-head-sampling-rate`,{type:`number`,description:`The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%).`,default:1}).option(`observability-traces-persist`,{type:`boolean`,description:`Whether trace persistence is enabled for the Worker.`,default:!0}).option(`subdomain-enabled`,{type:`boolean`,description:`Whether the *.workers.dev subdomain is enabled for the Worker.`,default:!1}).option(`subdomain-previews-enabled`,{type:`boolean`,description:`Whether [preview URLs](https://developers.cloudflare.com/workers/configuration/previews/) are enabled for the Worker.`}).option(`tags`,{type:`string`,array:!0,description:`Tags associated with the Worker.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Worker update parameters.`}),handler:async n=>{if(u(n.workerId,`workerId`),n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers beta workers update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/workers/${n.workerId??`<workerId>`}`,pathParams:{workerId:String(n.workerId??``)},bodyKind:`json`,body:{logpush:n.logpush,name:n.name,observabilityEnabled:n.observabilityEnabled,observabilityHeadSamplingRate:n.observabilityHeadSamplingRate,observabilityLogsDestinations:n.observabilityLogsDestinations,observabilityLogsEnabled:n.observabilityLogsEnabled,observabilityLogsHeadSamplingRate:n.observabilityLogsHeadSamplingRate,observabilityLogsInvocationLogs:n.observabilityLogsInvocationLogs,observabilityLogsPersist:n.observabilityLogsPersist,observabilityTracesDestinations:n.observabilityTracesDestinations,observabilityTracesEnabled:n.observabilityTracesEnabled,observabilityTracesHeadSamplingRate:n.observabilityTracesHeadSamplingRate,observabilityTracesPersist:n.observabilityTracesPersist,subdomainEnabled:n.subdomainEnabled,subdomainPreviewsEnabled:n.subdomainPreviewsEnabled,tags:n.tags,body:n.body},validation:`passed`});return}let r=await o(n),a=n.local?h:await i(r);if(n.accountId=a,n.body){let e=f(n.body);p(await g(`Updating worker`,async()=>r.put(`/accounts/${a}/workers/workers/${n.workerId}`,{body:e})),{successLabel:`Updated worker`});return}if(n.logpush===void 0)throw Error(`--logpush is required (or pass --body with this field set).`);if(n.name===void 0&&(n.name=await t(`name`,`Name of the Worker.`)),n.tags===void 0)throw Error(`--tags is required (or pass --body with this field set).`);let s={};n.logpush!==void 0&&d(s,[`logpush`],n.logpush),n.name!==void 0&&d(s,[`name`],l(n.name,`name`,`text`)),n.observabilityEnabled!==void 0&&d(s,[`observability`,`enabled`],n.observabilityEnabled),n.observabilityHeadSamplingRate!==void 0&&d(s,[`observability`,`head_sampling_rate`],n.observabilityHeadSamplingRate),n.observabilityLogsDestinations!==void 0&&d(s,[`observability`,`logs`,`destinations`],n.observabilityLogsDestinations),n.observabilityLogsEnabled!==void 0&&d(s,[`observability`,`logs`,`enabled`],n.observabilityLogsEnabled),n.observabilityLogsHeadSamplingRate!==void 0&&d(s,[`observability`,`logs`,`head_sampling_rate`],n.observabilityLogsHeadSamplingRate),n.observabilityLogsInvocationLogs!==void 0&&d(s,[`observability`,`logs`,`invocation_logs`],n.observabilityLogsInvocationLogs),n.observabilityLogsPersist!==void 0&&d(s,[`observability`,`logs`,`persist`],n.observabilityLogsPersist),n.observabilityTracesDestinations!==void 0&&d(s,[`observability`,`traces`,`destinations`],n.observabilityTracesDestinations),n.observabilityTracesEnabled!==void 0&&d(s,[`observability`,`traces`,`enabled`],n.observabilityTracesEnabled),n.observabilityTracesHeadSamplingRate!==void 0&&d(s,[`observability`,`traces`,`head_sampling_rate`],n.observabilityTracesHeadSamplingRate),n.observabilityTracesPersist!==void 0&&d(s,[`observability`,`traces`,`persist`],n.observabilityTracesPersist),n.subdomainEnabled!==void 0&&d(s,[`subdomain`,`enabled`],n.subdomainEnabled),n.subdomainPreviewsEnabled!==void 0&&d(s,[`subdomain`,`previews_enabled`],n.subdomainPreviewsEnabled),n.tags!==void 0&&d(s,[`tags`],n.tags),p(await g(`Updating worker`,async()=>r.put(`/accounts/${a}/workers/workers/${n.workerId}`,{body:Object.keys(s).length>0?s:void 0})),{successLabel:`Updated worker`})}},j={command:`create <workerId>`,describe:`Create a new version.`,builder:e=>e.positional(`workerId`,{type:`string`,description:`Identifier for the Worker, which can be ID or name.`,demandOption:!0}).option(`deploy`,{type:`boolean`,description:`If true, a deployment will be created that sends 100% of traffic to the new version.`,default:!1}).option(`assets-config-html-handling`,{type:`string`,description:`Determines the redirects and rewrites of requests for HTML content.`,choices:[`auto-trailing-slash`,`force-trailing-slash`,`drop-trailing-slash`,`none`],default:`auto-trailing-slash`}).option(`assets-config-not-found-handling`,{type:`string`,description:`Determines the response when a request does not match a static asset, and there is no Worker script.`,choices:[`none`,`404-page`,`single-page-application`],default:`none`}).option(`assets-jwt`,{type:`string`,description:`Token provided upon successful upload of all files from a registered manifest.`}).option(`compatibility-date`,{type:`string`,description:`Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.`}).option(`compatibility-flags`,{type:`string`,array:!0,description:"Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a `compatibility_date`."}).option(`limits-cpu-ms`,{type:`number`,description:`CPU time limit in milliseconds.`}).option(`limits-subrequests`,{type:`number`,description:`Subrequest limit per request.`}).option(`main-module`,{type:`string`,description:"The name of the main module in the `modules` array (e.g. the name of the module that exports a `fetch` handler)."}).option(`migrations-new-tag`,{type:`string`,description:`Tag to set as the latest migration tag.`}).option(`migrations-old-tag`,{type:`string`,description:`Tag used to verify against the latest migration tag for this Worker. If they don't match, the upload is rejected.`}).option(`migrations-deleted-classes`,{type:`string`,array:!0,description:`A list of classes to delete Durable Object namespaces from.`}).option(`migrations-new-classes`,{type:`string`,array:!0,description:`A list of classes to create Durable Object namespaces from.`}).option(`migrations-new-sqlite-classes`,{type:`string`,array:!0,description:`A list of classes to create Durable Object namespaces with SQLite from.`}).option(`placement-mode`,{type:`string`,description:`Enables [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement).`,choices:[`smart`,`targeted`]}).option(`placement-region`,{type:`string`,description:`Cloud region for targeted placement in format 'provider:region'.`}).option(`placement-hostname`,{type:`string`,description:`HTTP hostname for targeted placement.`}).option(`placement-host`,{type:`string`,description:`TCP host and port for targeted placement.`}).option(`usage-model`,{type:`string`,description:`Usage model for the version.`,choices:[`standard`,`bundled`,`unbound`],default:`standard`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Version creation parameters.`}).conflicts(`placement-mode`,[`placement-region`,`placement-hostname`,`placement-host`]).conflicts(`placement-region`,[`placement-mode`,`placement-hostname`,`placement-host`]).conflicts(`placement-hostname`,[`placement-mode`,`placement-region`,`placement-host`]).conflicts(`placement-host`,[`placement-mode`,`placement-region`,`placement-hostname`]),handler:async t=>{u(t.workerId,`workerId`);let n={};if(t.deploy!==void 0&&(n.deploy=t.deploy),t.dryRun){let r=e();r&&u(r,`accountId`),m({command:`cf workers beta workers versions create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${r??`<account-id>`}/workers/workers/${t.workerId??`<workerId>`}/versions`,pathParams:{workerId:String(t.workerId??``)},bodyKind:`json`,body:{...n,assetsConfigHtmlHandling:t.assetsConfigHtmlHandling,assetsConfigNotFoundHandling:t.assetsConfigNotFoundHandling,assetsJwt:t.assetsJwt,compatibilityDate:t.compatibilityDate,compatibilityFlags:t.compatibilityFlags,limitsCpuMs:t.limitsCpuMs,limitsSubrequests:t.limitsSubrequests,mainModule:t.mainModule,migrationsNewTag:t.migrationsNewTag,migrationsOldTag:t.migrationsOldTag,migrationsDeletedClasses:t.migrationsDeletedClasses,migrationsNewClasses:t.migrationsNewClasses,migrationsNewSqliteClasses:t.migrationsNewSqliteClasses,placementMode:t.placementMode,placementRegion:t.placementRegion,placementHostname:t.placementHostname,placementHost:t.placementHost,usageModel:t.usageModel,body:t.body},validation:`passed`});return}let r=await o(t),a=t.local?h:await i(r);if(t.accountId=a,t.body){let e=f(t.body),i=new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();p(await g(`Creating version`,async()=>r.post(`/accounts/${a}/workers/workers/${t.workerId}/versions${i?`?`+i:``}`,{body:e})),{successLabel:`Created version`});return}let s={};t.assetsConfigHtmlHandling!==void 0&&d(s,[`assets`,`config`,`html_handling`],l(t.assetsConfigHtmlHandling,`assetsConfigHtmlHandling`,`text`)),t.assetsConfigNotFoundHandling!==void 0&&d(s,[`assets`,`config`,`not_found_handling`],l(t.assetsConfigNotFoundHandling,`assetsConfigNotFoundHandling`,`text`)),t.assetsJwt!==void 0&&d(s,[`assets`,`jwt`],l(t.assetsJwt,`assetsJwt`,`text`)),t.compatibilityDate!==void 0&&d(s,[`compatibility_date`],l(t.compatibilityDate,`compatibilityDate`,`text`)),t.compatibilityFlags!==void 0&&d(s,[`compatibility_flags`],t.compatibilityFlags),t.limitsCpuMs!==void 0&&d(s,[`limits`,`cpu_ms`],t.limitsCpuMs),t.limitsSubrequests!==void 0&&d(s,[`limits`,`subrequests`],t.limitsSubrequests),t.mainModule!==void 0&&d(s,[`main_module`],l(t.mainModule,`mainModule`,`text`)),t.migrationsNewTag!==void 0&&d(s,[`migrations`,`new_tag`],l(t.migrationsNewTag,`migrationsNewTag`,`text`)),t.migrationsOldTag!==void 0&&d(s,[`migrations`,`old_tag`],l(t.migrationsOldTag,`migrationsOldTag`,`text`)),t.migrationsDeletedClasses!==void 0&&d(s,[`migrations`,`deleted_classes`],t.migrationsDeletedClasses),t.migrationsNewClasses!==void 0&&d(s,[`migrations`,`new_classes`],t.migrationsNewClasses),t.migrationsNewSqliteClasses!==void 0&&d(s,[`migrations`,`new_sqlite_classes`],t.migrationsNewSqliteClasses),t.placementMode!==void 0&&d(s,[`placement`,`mode`],l(t.placementMode,`placementMode`,`text`)),t.placementRegion!==void 0&&d(s,[`placement`,`region`],l(t.placementRegion,`placementRegion`,`text`)),t.placementHostname!==void 0&&d(s,[`placement`,`hostname`],l(t.placementHostname,`placementHostname`,`text`)),t.placementHost!==void 0&&d(s,[`placement`,`host`],l(t.placementHost,`placementHost`,`text`)),t.usageModel!==void 0&&d(s,[`usage_model`],l(t.usageModel,`usageModel`,`text`));let c=new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();p(await g(`Creating version`,async()=>r.post(`/accounts/${a}/workers/workers/${t.workerId}/versions${c?`?`+c:``}`,{body:Object.keys(s).length>0?s:void 0})),{successLabel:`Created version`})}},M={command:`delete <versionId>`,describe:`Delete a version.`,builder:e=>e.positional(`versionId`,{type:`string`,description:`Identifier for the version, which can be a UUID, a UUID prefix (minimum length 8), or the literal "latest" to operate on the most recently created version.`,demandOption:!0}).option(`worker-id`,{type:`string`,description:`Identifier for the Worker, which can be ID or name.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}),handler:async t=>{if(u(t.versionId,`versionId`),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers beta workers versions delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/workers/${t.workerId??`<workerId>`}/versions/${t.versionId??`<versionId>`}`,pathParams:{workerId:String(t.workerId??``),versionId:String(t.versionId??``)},bodyKind:`none`,validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,!await a(`version`,String(t.versionId??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
4
|
-
`);return}p(await g(`Deleting version`,async()=>n.workers.beta.workers.versions.delete(r,t.workerId,t.versionId)),{successLabel:`Deleted version`})}},N={command:`get <versionId>`,describe:`Get details about a specific version.`,builder:e=>e.positional(`versionId`,{type:`string`,description:`Identifier for the version, which can be a UUID, a UUID prefix (minimum length 8), or the literal "latest" to operate on the most recently created version.`,demandOption:!0}).option(`worker-id`,{type:`string`,description:`Identifier for the Worker, which can be ID or name.`,demandOption:!0}).option(`include`,{type:`string`,description:"Whether to include the `modules` property of the version in the response, which contains code and sourcemap content and may add several megabytes to the response size.",choices:[`modules`]}),handler:async e=>{u(e.versionId,`versionId`);let t={};e.include!==void 0&&(t.include=e.include);let n=await o(e),r=e.local?h:await i(n);e.accountId=r,p(await g(`Loading version`,async()=>n.workers.beta.workers.versions.get(r,e.workerId,e.versionId,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded version`})}},P={command:`list`,describe:`List all versions for a Worker.`,builder:e=>e.option(`worker-id`,{type:`string`,description:`Identifier for the Worker, which can be ID or name.`,demandOption:!0}).option(`page`,{type:`number`,description:`Current page.`}).option(`per-page`,{type:`number`,description:`Items per-page.`}),handler:async e=>{let t={};e.page!==void 0&&(t.page=e.page),e.perPage!==void 0&&(t.per_page=e.perPage);let n=await o(e),r=e.local?h:await i(n);e.accountId=r,p(await g(`Loading versions`,async()=>n.workers.beta.workers.versions.list(r,e.workerId,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded versions`})}},F={command:`versions`,describe:`Beta Worker lifecycle APIs — create, update, version, and delete Workers (preview channel)`,builder:e=>e.command(j).command(M).command(N).command(P).demandCommand(1),handler:()=>{}},I={command:`workers`,describe:`Beta Worker lifecycle APIs — create, update, version, and delete Workers (preview channel)`,builder:e=>e.command(T).command(E).command(D).command(O).command(k).command(A).command(F).demandCommand(1),handler:()=>{}},L={command:`beta`,describe:`Operations for beta`,builder:e=>e.command(I).demandCommand(1),handler:()=>{}},R={command:`create`,describe:`Creates the pay-per-crawl config for a zone.`,builder:e=>e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Data for setting flag on zones`}),handler:async e=>{if(e.dryRun){m({command:`cf workers configuration create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/pay-per-crawl/configuration`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{body:e.body},validation:`passed`});return}let t=await o(e),n=await s({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let n=l(e.body,`body`,`binary`);p(await g(`Creating configuration`,async()=>t.post(`/zones/${e.zoneId}/pay-per-crawl/configuration`,{body:n,headers:{"Content-Type":`application/octet-stream`}})),{successLabel:`Created configuration`});return}p(await g(`Creating configuration`,async()=>t.workers.configuration.create(n)),{successLabel:`Created configuration`})}},z={command:`edit`,describe:`Changes the pay-per-crawl config for a zone.`,builder:e=>e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Data for setting flag on zones`}),handler:async e=>{if(e.dryRun){m({command:`cf workers configuration edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/pay-per-crawl/configuration`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{body:e.body},validation:`passed`});return}let t=await o(e),n=await s({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let n=l(e.body,`body`,`binary`);p(await g(`Updating configuration`,async()=>t.patch(`/zones/${e.zoneId}/pay-per-crawl/configuration`,{body:n,headers:{"Content-Type":`application/octet-stream`}})),{successLabel:`Updated configuration`});return}p(await g(`Updating configuration`,async()=>t.workers.configuration.edit(n)),{successLabel:`Updated configuration`})}},B={command:`get`,describe:`Gets the pay-per-crawl config for a zone including the bot configuration.`,builder:e=>e,handler:async e=>{let t=await o(e),n=await s({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,p(await g(`Loading configuration`,async()=>t.workers.configuration.get(n)),{successLabel:`Loaded configuration`})}},V={command:`configuration`,describe:`Configuration operations`,builder:e=>e.command(R).command(z).command(B).demandCommand(1),handler:()=>{}},H={command:`create`,describe:`Creates the stripe config for a crawler.`,builder:e=>e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}),handler:async t=>{if(t.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers crawler stripe create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/pay-per-crawl/crawler/stripe`,pathParams:{},bodyKind:`none`,validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);t.accountId=r,p(await g(`Creating stripe`,async()=>n.workers.crawler.stripe.create(r)),{successLabel:`Created stripe`})}},U={command:`delete`,describe:`Deletes the stripe config for a crawler.`,builder:e=>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}),handler:async t=>{if(t.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers crawler stripe delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/pay-per-crawl/crawler/stripe`,pathParams:{},bodyKind:`none`,validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,!await a(`stripe`,``,{force:!!t.force})){process.stderr.write(`Aborted.
|
|
5
|
-
`);return}p(await g(`Deleting stripe`,async()=>n.workers.crawler.stripe.delete(r)),{successLabel:`Deleted stripe`})}},W={command:`get`,describe:`Gets the stripe config for a crawler.`,builder:e=>e,handler:async e=>{let t=await o(e),n=e.local?h:await i(t);e.accountId=n,p(await g(`Loading stripe`,async()=>t.workers.crawler.stripe.get(n)),{successLabel:`Loaded stripe`})}},G={command:`stripe`,describe:`Crawler operations`,builder:e=>e.command(H).command(U).command(W).demandCommand(1),handler:()=>{}},K={command:`crawler`,describe:`Operations for crawler`,builder:e=>e.command(G).demandCommand(1),handler:()=>{}},q={command:`create`,describe:`Deployments configure how [Worker Versions](https://developers.cloudflare.com/api/operations/worker-versions-list-versions) are deployed to traffic. A deployment can consist of one or two versions of a Worker.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`force`,{type:`boolean`,description:`If set to true, the deployment will be created even if normally blocked by something such rolling back to an older version when a secret has changed.`,default:!1}).option(`strategy`,{type:`string`,description:`The strategy field`,choices:[`percentage`]}).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)`}),handler:async t=>{let a={};if(t.force!==void 0&&(a.force=t.force),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers deployments create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/deployments`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`json`,body:{...a,strategy:t.strategy,body:t.body},validation:`passed`});return}let s=await o(t),c=t.local?h:await i(s);t.accountId=c;let _=n({scriptName:t.scriptName});if(t.scriptName=_,t.body){let e=f(t.body),n=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();p(await g(`Creating deployment`,async()=>s.post(`/accounts/${c}/workers/scripts/${_}/deployments${n?`?`+n:``}`,{body:e})),{successLabel:`Created deployment`});return}t.strategy===void 0&&(t.strategy=await r(`strategy`,``,[`percentage`]));let v={};t.strategy!==void 0&&d(v,[`strategy`],l(t.strategy,`strategy`,`text`));let y=new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();p(await g(`Creating deployment`,async()=>s.post(`/accounts/${c}/workers/scripts/${_}/deployments${y?`?`+y:``}`,{body:Object.keys(v).length>0?v:void 0})),{successLabel:`Created deployment`})}},J={command:`delete <deploymentId>`,describe:`Delete a Worker Deployment. The latest deployment, which is actively serving traffic, cannot be deleted. All other deployments can be deleted.`,builder:e=>e.positional(`deploymentId`,{type:`string`,description:`Deployment ID`,demandOption:!0}).option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).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}),handler:async t=>{if(u(t.deploymentId,`deploymentId`),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers deployments delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/deployments/${t.deploymentId??`<deploymentId>`}`,pathParams:{scriptName:String(t.scriptName??``),deploymentId:String(t.deploymentId??``)},bodyKind:`none`,validation:`passed`});return}let r=await o(t),s=t.local?h:await i(r);t.accountId=s;let c=n({scriptName:t.scriptName});if(t.scriptName=c,!await a(`deployment`,String(t.deploymentId??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
6
|
-
`);return}p(await g(`Deleting deployment`,async()=>r.workers.deployments.delete(s,c,t.deploymentId)),{successLabel:`Deleted deployment`})}},Y={command:`get <deploymentId>`,describe:`Get information about a Worker Deployment.`,builder:e=>e.positional(`deploymentId`,{type:`string`,description:`Deployment ID`,demandOption:!0}).option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}),handler:async e=>{u(e.deploymentId,`deploymentId`);let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a,p(await g(`Loading deployment`,async()=>t.workers.deployments.get(r,a,e.deploymentId)),{successLabel:`Loaded deployment`})}},X={command:`list`,describe:`List of Worker Deployments. The first deployment in the list is the latest deployment actively serving traffic.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}),handler:async e=>{let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a,p(await g(`Loading deployments`,async()=>t.workers.deployments.list(r,a)),{successLabel:`Loaded deployments`})}},Z={command:`deployments`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(q).command(J).command(Y).command(X).demandCommand(1),handler:()=>{}},Q={command:`delete <domainId>`,describe:`Detaches a domain from a Worker. Both the Worker and all of its previews are no longer routable using this domain.`,builder:e=>e.positional(`domainId`,{type:`string`,description:`ID of the domain.`,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}),handler:async t=>{if(u(t.domainId,`domainId`),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers domains delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/domains/${t.domainId??`<domainId>`}`,pathParams:{domainId:String(t.domainId??``)},bodyKind:`none`,validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,!await a(`domain`,String(t.domainId??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
7
|
-
`);return}p(await g(`Deleting domain`,async()=>n.workers.domains.delete(r,t.domainId)),{successLabel:`Deleted domain`})}},ne={command:`get <domainId>`,describe:`Gets information about a domain.`,builder:e=>e.positional(`domainId`,{type:`string`,description:`ID of the domain.`,demandOption:!0}),handler:async e=>{u(e.domainId,`domainId`);let t=await o(e),n=e.local?h:await i(t);e.accountId=n,p(await g(`Loading domain`,async()=>t.workers.domains.get(n,e.domainId)),{successLabel:`Loaded domain`})}},re={command:`list`,describe:`Lists all domains for an account.`,builder:e=>e.option(`zone-id`,{type:`string`,description:`ID of the zone containing the domain hostname.`}).option(`zone-name`,{type:`string`,description:`Name of the zone containing the domain hostname.`}).option(`service`,{type:`string`,description:`Name of the Worker associated with the domain.`}).option(`hostname`,{type:`string`,description:`Hostname of the domain.`}).option(`environment`,{type:`string`,description:`Worker environment associated with the domain.`}),handler:async e=>{let t={};e.zoneId!==void 0&&(t.zone_id=e.zoneId),e.zoneName!==void 0&&(t.zone_name=e.zoneName),e.service!==void 0&&(t.service=e.service),e.hostname!==void 0&&(t.hostname=e.hostname),e.environment!==void 0&&(t.environment=e.environment);let n=await o(e),r=e.local?h:await i(n);e.accountId=r,p(await g(`Loading domains`,async()=>n.workers.domains.list(r,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded domains`})}},ie={command:`update`,describe:`Attaches a domain that routes traffic to a Worker.`,builder:e=>e.option(`environment`,{type:`string`,description:`Worker environment associated with the domain.`}).option(`hostname`,{type:`string`,description:`Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.`}).option(`service`,{type:`string`,description:`Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.`}).option(`zone-name`,{type:`string`,description:`Name of the zone containing the domain hostname.`}).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)`}),handler:async n=>{if(n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers domains update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/domains`,pathParams:{},bodyKind:`json`,body:{environment:n.environment,hostname:n.hostname,service:n.service,zoneName:n.zoneName,body:n.body},validation:`passed`});return}let r=await o(n),a=n.local?h:await i(r);if(n.accountId=a,n.body){let e=f(n.body);p(await g(`Updating domain`,async()=>r.put(`/accounts/${a}/workers/domains`,{body:e})),{successLabel:`Updated domain`});return}n.environment===void 0&&(n.environment=await t(`environment`,`Worker environment associated with the domain.`)),n.hostname===void 0&&(n.hostname=await t(`hostname`,`Hostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker.`)),n.service===void 0&&(n.service=await t(`service`,`Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.`)),n.zoneName===void 0&&(n.zoneName=await t(`zone-name`,`Name of the zone containing the domain hostname.`));let s={};n.environment!==void 0&&d(s,[`environment`],l(n.environment,`environment`,`text`)),n.hostname!==void 0&&d(s,[`hostname`],l(n.hostname,`hostname`,`text`)),n.service!==void 0&&d(s,[`service`],l(n.service,`service`,`text`)),n.zoneName!==void 0&&d(s,[`zone_name`],l(n.zoneName,`zoneName`,`text`)),p(await g(`Updating domain`,async()=>r.put(`/accounts/${a}/workers/domains`,{body:Object.keys(s).length>0?s:void 0})),{successLabel:`Updated domain`})}},ae={command:`domains`,describe:`Attach or detach custom domains that route directly to a Worker without a DNS record`,builder:e=>e.command(Q).command(ne).command(re).command(ie).demandCommand(1),handler:()=>{}},oe={command:`create`,describe:`Create a new Workers Observability Telemetry Destination.`,builder:e=>e.option(`configuration-type`,{type:`string`,description:`The configuration.type field`,choices:[`logpush`]}).option(`configuration-url`,{type:`string`,description:`The configuration.url field`}).option(`enabled`,{type:`boolean`,description:`The enabled field`}).option(`name`,{type:`string`,description:`The name field`}).option(`skip-preflight-check`,{type:`boolean`,description:`The skipPreflightCheck field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}),handler:async n=>{if(n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers observability destinations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/observability/destinations`,pathParams:{},bodyKind:`json`,body:{configurationType:n.configurationType,configurationUrl:n.configurationUrl,enabled:n.enabled,name:n.name,skipPreflightCheck:n.skipPreflightCheck,body:n.body},validation:`passed`});return}let a=await o(n),s=n.local?h:await i(a);if(n.accountId=s,n.body){let e=f(n.body);p(await g(`Creating destination`,async()=>a.post(`/accounts/${s}/workers/observability/destinations`,{body:e})),{successLabel:`Created destination`});return}if(n.configurationType===void 0&&(n.configurationType=await r(`configuration-type`,``,[`logpush`])),n.configurationUrl===void 0&&(n.configurationUrl=await t(`configuration-url`,``)),n.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);n.name===void 0&&(n.name=await t(`name`,``));let c={};n.configurationType!==void 0&&d(c,[`configuration`,`type`],l(n.configurationType,`configurationType`,`text`)),n.configurationUrl!==void 0&&d(c,[`configuration`,`url`],l(n.configurationUrl,`configurationUrl`,`text`)),n.enabled!==void 0&&d(c,[`enabled`],n.enabled),n.name!==void 0&&d(c,[`name`],l(n.name,`name`,`text`)),n.skipPreflightCheck!==void 0&&d(c,[`skipPreflightCheck`],n.skipPreflightCheck),p(await g(`Creating destination`,async()=>a.post(`/accounts/${s}/workers/observability/destinations`,{body:Object.keys(c).length>0?c:void 0})),{successLabel:`Created destination`})}},se={command:`delete <slug>`,describe:`Delete a Workers Observability Telemetry Destination.`,builder:e=>e.positional(`slug`,{type:`string`,description:`Slug`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}),handler:async t=>{if(u(t.slug,`slug`),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers observability destinations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/observability/destinations/${t.slug??`<slug>`}`,pathParams:{slug:String(t.slug??``)},bodyKind:`none`,validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,!await a(`destination`,String(t.slug??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
8
|
-
`);return}p(await g(`Deleting destination`,async()=>n.workers.observability.destinations.delete(t.slug,r)),{successLabel:`Deleted destination`})}},ce={command:`list`,describe:`List your Workers Observability Telemetry Destinations.`,builder:e=>e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`PerPage`}).option(`order`,{type:`string`,description:`Order`,choices:[`asc`,`desc`]}).option(`order-by`,{type:`string`,description:`OrderBy`,choices:[`created`,`updated`]}),handler:async e=>{let t={};e.page!==void 0&&(t.page=e.page),e.perPage!==void 0&&(t.perPage=e.perPage),e.order!==void 0&&(t.order=e.order),e.orderBy!==void 0&&(t.orderBy=e.orderBy);let n=await o(e),r=e.local?h:await i(n);e.accountId=r,p(await g(`Loading destinations`,async()=>n.workers.observability.destinations.list(r,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded destinations`})}},le={command:`update <slug>`,describe:`Update an existing Workers Observability Telemetry Destination.`,builder:e=>e.positional(`slug`,{type:`string`,description:`Slug`,demandOption:!0}).option(`configuration-type`,{type:`string`,description:`The configuration.type field`,choices:[`logpush`]}).option(`configuration-url`,{type:`string`,description:`The configuration.url field`}).option(`enabled`,{type:`boolean`,description:`The enabled field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}),handler:async n=>{if(u(n.slug,`slug`),n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers observability destinations update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/observability/destinations/${n.slug??`<slug>`}`,pathParams:{slug:String(n.slug??``)},bodyKind:`json`,body:{configurationType:n.configurationType,configurationUrl:n.configurationUrl,enabled:n.enabled,body:n.body},validation:`passed`});return}let a=await o(n),s=n.local?h:await i(a);if(n.accountId=s,n.body){let e=f(n.body);p(await g(`Updating destination`,async()=>a.patch(`/accounts/${s}/workers/observability/destinations/${n.slug}`,{body:e})),{successLabel:`Updated destination`});return}if(n.configurationType===void 0&&(n.configurationType=await r(`configuration-type`,``,[`logpush`])),n.configurationUrl===void 0&&(n.configurationUrl=await t(`configuration-url`,``)),n.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);let c={};n.configurationType!==void 0&&d(c,[`configuration`,`type`],l(n.configurationType,`configurationType`,`text`)),n.configurationUrl!==void 0&&d(c,[`configuration`,`url`],l(n.configurationUrl,`configurationUrl`,`text`)),n.enabled!==void 0&&d(c,[`enabled`],n.enabled),p(await g(`Updating destination`,async()=>a.patch(`/accounts/${s}/workers/observability/destinations/${n.slug}`,{body:Object.keys(c).length>0?c:void 0})),{successLabel:`Updated destination`})}},ue={command:`destinations`,describe:`Workers observability — destinations, queries, and telemetry for monitoring and debugging`,builder:e=>e.command(oe).command(se).command(ce).command(le).demandCommand(1),handler:()=>{}},de={command:`create`,describe:`Persist query for later use.`,builder:e=>e.option(`description`,{type:`string`,description:`The description field`}).option(`name`,{type:`string`,description:`Query name`}).option(`parameters-datasets`,{type:`string`,array:!0,description:`Set the Datasets to query. Leave it empty to query all the datasets.`}).option(`parameters-filter-combination`,{type:`string`,description:`Set a Flag to describe how to combine the filters on the query.`,choices:[`and`,`or`,`AND`,`OR`]}).option(`parameters-limit`,{type:`number`,description:`Set a limit on the number of results / records returned by the query`}).option(`parameters-needle-is-regex`,{type:`boolean`,description:`The parameters.needle.isRegex field`}).option(`parameters-needle-match-case`,{type:`boolean`,description:`The parameters.needle.matchCase field`}).option(`parameters-order-by-order`,{type:`string`,description:`Set the order of the results`,choices:[`asc`,`desc`]}).option(`parameters-order-by-value`,{type:`string`,description:`Configure which Calculation to order the results by.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Specify the new contents of the query.`}),handler:async n=>{if(n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers observability queries create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/observability/queries`,pathParams:{},bodyKind:`json`,body:{description:n.description,name:n.name,parametersDatasets:n.parametersDatasets,parametersFilterCombination:n.parametersFilterCombination,parametersLimit:n.parametersLimit,parametersNeedleIsRegex:n.parametersNeedleIsRegex,parametersNeedleMatchCase:n.parametersNeedleMatchCase,parametersOrderByOrder:n.parametersOrderByOrder,parametersOrderByValue:n.parametersOrderByValue,body:n.body},validation:`passed`});return}let r=await o(n),a=n.local?h:await i(r);if(n.accountId=a,n.body){let e=f(n.body);p(await g(`Creating query`,async()=>r.post(`/accounts/${a}/workers/observability/queries`,{body:e})),{successLabel:`Created query`});return}n.description===void 0&&(n.description=await t(`description`,``)),n.name===void 0&&(n.name=await t(`name`,`Query name`)),n.parametersOrderByValue===void 0&&(n.parametersOrderByValue=await t(`parameters-order-by-value`,`Configure which Calculation to order the results by.`));let s={};n.description!==void 0&&d(s,[`description`],l(n.description,`description`,`text`)),n.name!==void 0&&d(s,[`name`],l(n.name,`name`,`text`)),n.parametersDatasets!==void 0&&d(s,[`parameters`,`datasets`],n.parametersDatasets),n.parametersFilterCombination!==void 0&&d(s,[`parameters`,`filterCombination`],l(n.parametersFilterCombination,`parametersFilterCombination`,`text`)),n.parametersLimit!==void 0&&d(s,[`parameters`,`limit`],n.parametersLimit),n.parametersNeedleIsRegex!==void 0&&d(s,[`parameters`,`needle`,`isRegex`],n.parametersNeedleIsRegex),n.parametersNeedleMatchCase!==void 0&&d(s,[`parameters`,`needle`,`matchCase`],n.parametersNeedleMatchCase),n.parametersOrderByOrder!==void 0&&d(s,[`parameters`,`orderBy`,`order`],l(n.parametersOrderByOrder,`parametersOrderByOrder`,`text`)),n.parametersOrderByValue!==void 0&&d(s,[`parameters`,`orderBy`,`value`],l(n.parametersOrderByValue,`parametersOrderByValue`,`text`)),p(await g(`Creating query`,async()=>r.post(`/accounts/${a}/workers/observability/queries`,{body:Object.keys(s).length>0?s:void 0})),{successLabel:`Created query`})}},fe={command:`delete <queryId>`,describe:`Delete a saved query.`,builder:e=>e.positional(`queryId`,{type:`string`,description:`QueryId`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}),handler:async t=>{if(u(t.queryId,`queryId`),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers observability queries delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/observability/queries/${t.queryId??`<queryId>`}`,pathParams:{queryId:String(t.queryId??``)},bodyKind:`none`,validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,!await a(`query`,String(t.queryId??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
9
|
-
`);return}p(await g(`Deleting query`,async()=>n.workers.observability.queries.delete(t.queryId,r)),{successLabel:`Deleted query`})}},pe={command:`edit <queryId>`,describe:`Update saved query.`,builder:e=>e.positional(`queryId`,{type:`string`,description:`QueryId`,demandOption:!0}).option(`description`,{type:`string`,description:`The description field`}).option(`name`,{type:`string`,description:`Query name`}).option(`parameters-datasets`,{type:`string`,array:!0,description:`Set the Datasets to query. Leave it empty to query all the datasets.`}).option(`parameters-filter-combination`,{type:`string`,description:`Set a Flag to describe how to combine the filters on the query.`,choices:[`and`,`or`,`AND`,`OR`]}).option(`parameters-limit`,{type:`number`,description:`Set a limit on the number of results / records returned by the query`}).option(`parameters-needle-is-regex`,{type:`boolean`,description:`The parameters.needle.isRegex field`}).option(`parameters-needle-match-case`,{type:`boolean`,description:`The parameters.needle.matchCase field`}).option(`parameters-order-by-order`,{type:`string`,description:`Set the order of the results`,choices:[`asc`,`desc`]}).option(`parameters-order-by-value`,{type:`string`,description:`Configure which Calculation to order the results by.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Specify the new contents of the query.`}),handler:async n=>{if(u(n.queryId,`queryId`),n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers observability queries edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/observability/queries/${n.queryId??`<queryId>`}`,pathParams:{queryId:String(n.queryId??``)},bodyKind:`json`,body:{description:n.description,name:n.name,parametersDatasets:n.parametersDatasets,parametersFilterCombination:n.parametersFilterCombination,parametersLimit:n.parametersLimit,parametersNeedleIsRegex:n.parametersNeedleIsRegex,parametersNeedleMatchCase:n.parametersNeedleMatchCase,parametersOrderByOrder:n.parametersOrderByOrder,parametersOrderByValue:n.parametersOrderByValue,body:n.body},validation:`passed`});return}let r=await o(n),a=n.local?h:await i(r);if(n.accountId=a,n.body){let e=f(n.body);p(await g(`Updating query`,async()=>r.patch(`/accounts/${a}/workers/observability/queries/${n.queryId}`,{body:e})),{successLabel:`Updated query`});return}n.description===void 0&&(n.description=await t(`description`,``)),n.name===void 0&&(n.name=await t(`name`,`Query name`)),n.parametersOrderByValue===void 0&&(n.parametersOrderByValue=await t(`parameters-order-by-value`,`Configure which Calculation to order the results by.`));let s={};n.description!==void 0&&d(s,[`description`],l(n.description,`description`,`text`)),n.name!==void 0&&d(s,[`name`],l(n.name,`name`,`text`)),n.parametersDatasets!==void 0&&d(s,[`parameters`,`datasets`],n.parametersDatasets),n.parametersFilterCombination!==void 0&&d(s,[`parameters`,`filterCombination`],l(n.parametersFilterCombination,`parametersFilterCombination`,`text`)),n.parametersLimit!==void 0&&d(s,[`parameters`,`limit`],n.parametersLimit),n.parametersNeedleIsRegex!==void 0&&d(s,[`parameters`,`needle`,`isRegex`],n.parametersNeedleIsRegex),n.parametersNeedleMatchCase!==void 0&&d(s,[`parameters`,`needle`,`matchCase`],n.parametersNeedleMatchCase),n.parametersOrderByOrder!==void 0&&d(s,[`parameters`,`orderBy`,`order`],l(n.parametersOrderByOrder,`parametersOrderByOrder`,`text`)),n.parametersOrderByValue!==void 0&&d(s,[`parameters`,`orderBy`,`value`],l(n.parametersOrderByValue,`parametersOrderByValue`,`text`)),p(await g(`Updating query`,async()=>r.patch(`/accounts/${a}/workers/observability/queries/${n.queryId}`,{body:Object.keys(s).length>0?s:void 0})),{successLabel:`Updated query`})}},me={command:`get <queryId>`,describe:`Retrieve a saved query.`,builder:e=>e.positional(`queryId`,{type:`string`,description:`QueryId`,demandOption:!0}),handler:async e=>{u(e.queryId,`queryId`);let t=await o(e),n=e.local?h:await i(t);e.accountId=n,p(await g(`Loading query`,async()=>t.workers.observability.queries.get(e.queryId,n)),{successLabel:`Loaded query`})}},he={command:`list`,describe:`List saved queries.`,builder:e=>e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`PerPage`}).option(`order`,{type:`string`,description:`Order`,choices:[`asc`,`desc`]}).option(`order-by`,{type:`string`,description:`OrderBy`,choices:[`created`,`updated`]}),handler:async e=>{let t={};e.page!==void 0&&(t.page=e.page),e.perPage!==void 0&&(t.perPage=e.perPage),e.order!==void 0&&(t.order=e.order),e.orderBy!==void 0&&(t.orderBy=e.orderBy);let n=await o(e),r=e.local?h:await i(n);e.accountId=r,p(await g(`Loading queries`,async()=>n.workers.observability.queries.list(r,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded queries`})}},ge={command:`queries`,describe:`Workers observability — destinations, queries, and telemetry for monitoring and debugging`,builder:e=>e.command(de).command(fe).command(pe).command(me).command(he).demandCommand(1),handler:()=>{}},_e={command:`keys`,describe:`List all the keys in your telemetry events.`,builder:e=>e.option(`datasets`,{type:`string`,array:!0,description:`Leave this empty to use the default datasets`}).option(`from`,{type:`number`,description:`The from field`}).option(`key-needle-is-regex`,{type:`boolean`,description:`The keyNeedle.isRegex field`}).option(`key-needle-match-case`,{type:`boolean`,description:`The keyNeedle.matchCase field`}).option(`limit`,{type:`number`,description:`Advanced usage: set limit=1000+ to retrieve comprehensive key options without needing additional filtering.`}).option(`needle-is-regex`,{type:`boolean`,description:`The needle.isRegex field`}).option(`needle-match-case`,{type:`boolean`,description:`The needle.matchCase field`}).option(`to`,{type:`number`,description:`The to field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Find keys in your telemetry events matching a specific filter or needle.`}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers observability telemetry keys`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/observability/telemetry/keys`,pathParams:{},bodyKind:`json`,body:{datasets:t.datasets,from:t.from,keyNeedleIsRegex:t.keyNeedleIsRegex,keyNeedleMatchCase:t.keyNeedleMatchCase,limit:t.limit,needleIsRegex:t.needleIsRegex,needleMatchCase:t.needleMatchCase,to:t.to,body:t.body},validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,t.body){let e=f(t.body);p(await g(`Creating telemetry`,async()=>n.post(`/accounts/${r}/workers/observability/telemetry/keys`,{body:e})),{successLabel:`Created telemetry`});return}let a={};t.datasets!==void 0&&d(a,[`datasets`],t.datasets),t.from!==void 0&&d(a,[`from`],t.from),t.keyNeedleIsRegex!==void 0&&d(a,[`keyNeedle`,`isRegex`],t.keyNeedleIsRegex),t.keyNeedleMatchCase!==void 0&&d(a,[`keyNeedle`,`matchCase`],t.keyNeedleMatchCase),t.limit!==void 0&&d(a,[`limit`],t.limit),t.needleIsRegex!==void 0&&d(a,[`needle`,`isRegex`],t.needleIsRegex),t.needleMatchCase!==void 0&&d(a,[`needle`,`matchCase`],t.needleMatchCase),t.to!==void 0&&d(a,[`to`],t.to),p(await g(`Creating telemetry`,async()=>n.post(`/accounts/${r}/workers/observability/telemetry/keys`,{body:Object.keys(a).length>0?a:void 0})),{successLabel:`Created telemetry`})}},ve={command:`query`,describe:`Run a temporary or saved query.`,builder:e=>e.option(`chart`,{type:`boolean`,description:`Whether to include timeseties data in the response`}).option(`compare`,{type:`boolean`,description:`Whether to include comparison data with previous time periods`}).option(`dry`,{type:`boolean`,description:`Whether to perform a dry run without saving the results of the query. Useful for validation`,default:!1}).option(`granularity`,{type:`number`,description:`This is only used when the view is calculations. Leaving it empty lets Workers Observability detect the correct granularity.`}).option(`ignore-series`,{type:`boolean`,description:`Whether to ignore time-series data in the results and return only aggregated values`,default:!1}).option(`limit`,{type:`number`,description:`Use this limit to cap the number of events returned when the view is events.`,default:50}).option(`offset`,{type:`string`,description:`Cursor pagination for event/trace/invocation views. Pass the last item's $metadata.id as the next offset.`}).option(`offset-by`,{type:`number`,description:`Numeric offset for pattern results (top-N list). Use with limit to page pattern groups; not used by cursor pagination.`}).option(`offset-direction`,{type:`string`,description:`Direction for offset-based pagination (e.g., 'next', 'prev')`}).option(`parameters-datasets`,{type:`string`,array:!0,description:`Set the Datasets to query. Leave it empty to query all the datasets.`}).option(`parameters-filter-combination`,{type:`string`,description:`Set a Flag to describe how to combine the filters on the query.`,choices:[`and`,`or`,`AND`,`OR`]}).option(`parameters-limit`,{type:`number`,description:`Set a limit on the number of results / records returned by the query`}).option(`parameters-needle-is-regex`,{type:`boolean`,description:`The parameters.needle.isRegex field`}).option(`parameters-needle-match-case`,{type:`boolean`,description:`The parameters.needle.matchCase field`}).option(`parameters-order-by-order`,{type:`string`,description:`Set the order of the results`,choices:[`asc`,`desc`]}).option(`parameters-order-by-value`,{type:`string`,description:`Configure which Calculation to order the results by.`}).option(`query-id`,{type:`string`,description:`Unique identifier for the query to execute`}).option(`timeframe-from`,{type:`number`,description:`Start timestamp for the query timeframe (Unix timestamp in milliseconds)`}).option(`timeframe-to`,{type:`number`,description:`End timestamp for the query timeframe (Unix timestamp in milliseconds)`}).option(`view`,{type:`string`,description:`Examples by view type. Events: show errors for a worker in the last 30 minutes. Calculations: p99 of wall time or count by status code. Invocations: find a specific request that resulted in a 500.`,choices:[`traces`,`events`,`calculations`,`invocations`,`requests`,`agents`],default:`calculations`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Query your observability events, requests, and traces to build visualizations and identify insights.`}).check(e=>{if([`parameters-datasets`,`parameters-filter-combination`,`parameters-limit`,`parameters-needle-is-regex`,`parameters-needle-match-case`,`parameters-order-by-order`,`parameters-order-by-value`].some(t=>e[t]!==void 0)){let t=[`parameters-order-by-value`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --parameters-* flag is set`)}return!0}),handler:async n=>{if(n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers observability telemetry query`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/observability/telemetry/query`,pathParams:{},bodyKind:`json`,body:{chart:n.chart,compare:n.compare,dry:n.dry,granularity:n.granularity,ignoreSeries:n.ignoreSeries,limit:n.limit,offset:n.offset,offsetBy:n.offsetBy,offsetDirection:n.offsetDirection,parametersDatasets:n.parametersDatasets,parametersFilterCombination:n.parametersFilterCombination,parametersLimit:n.parametersLimit,parametersNeedleIsRegex:n.parametersNeedleIsRegex,parametersNeedleMatchCase:n.parametersNeedleMatchCase,parametersOrderByOrder:n.parametersOrderByOrder,parametersOrderByValue:n.parametersOrderByValue,queryId:n.queryId,timeframeFrom:n.timeframeFrom,timeframeTo:n.timeframeTo,view:n.view,body:n.body},validation:`passed`});return}let r=await o(n),a=n.local?h:await i(r);if(n.accountId=a,n.body){let e=f(n.body);p(await g(`Loading telemetry`,async()=>r.post(`/accounts/${a}/workers/observability/telemetry/query`,{body:e})),{successLabel:`Loaded telemetry`});return}if(n.queryId===void 0&&(n.queryId=await t(`query-id`,`Unique identifier for the query to execute`)),n.timeframeFrom===void 0)throw Error(`--timeframe-from is required (or pass --body with this field set).`);if(n.timeframeTo===void 0)throw Error(`--timeframe-to is required (or pass --body with this field set).`);let s={};n.chart!==void 0&&d(s,[`chart`],n.chart),n.compare!==void 0&&d(s,[`compare`],n.compare),n.dry!==void 0&&d(s,[`dry`],n.dry),n.granularity!==void 0&&d(s,[`granularity`],n.granularity),n.ignoreSeries!==void 0&&d(s,[`ignoreSeries`],n.ignoreSeries),n.limit!==void 0&&d(s,[`limit`],n.limit),n.offset!==void 0&&d(s,[`offset`],l(n.offset,`offset`,`text`)),n.offsetBy!==void 0&&d(s,[`offsetBy`],n.offsetBy),n.offsetDirection!==void 0&&d(s,[`offsetDirection`],l(n.offsetDirection,`offsetDirection`,`text`)),n.parametersDatasets!==void 0&&d(s,[`parameters`,`datasets`],n.parametersDatasets),n.parametersFilterCombination!==void 0&&d(s,[`parameters`,`filterCombination`],l(n.parametersFilterCombination,`parametersFilterCombination`,`text`)),n.parametersLimit!==void 0&&d(s,[`parameters`,`limit`],n.parametersLimit),n.parametersNeedleIsRegex!==void 0&&d(s,[`parameters`,`needle`,`isRegex`],n.parametersNeedleIsRegex),n.parametersNeedleMatchCase!==void 0&&d(s,[`parameters`,`needle`,`matchCase`],n.parametersNeedleMatchCase),n.parametersOrderByOrder!==void 0&&d(s,[`parameters`,`orderBy`,`order`],l(n.parametersOrderByOrder,`parametersOrderByOrder`,`text`)),n.parametersOrderByValue!==void 0&&d(s,[`parameters`,`orderBy`,`value`],l(n.parametersOrderByValue,`parametersOrderByValue`,`text`)),n.queryId!==void 0&&d(s,[`queryId`],l(n.queryId,`queryId`,`text`)),n.timeframeFrom!==void 0&&d(s,[`timeframe`,`from`],n.timeframeFrom),n.timeframeTo!==void 0&&d(s,[`timeframe`,`to`],n.timeframeTo),n.view!==void 0&&d(s,[`view`],l(n.view,`view`,`text`)),p(await g(`Loading telemetry`,async()=>r.post(`/accounts/${a}/workers/observability/telemetry/query`,{body:Object.keys(s).length>0?s:void 0})),{successLabel:`Loaded telemetry`})}},ye={command:`values`,describe:`List unique values found in your events.`,builder:e=>e.option(`datasets`,{type:`string`,array:!0,description:`Leave this empty to use the default datasets`}).option(`key`,{type:`string`,description:`The key field`}).option(`limit`,{type:`number`,description:`The limit field`,default:50}).option(`needle-is-regex`,{type:`boolean`,description:`The needle.isRegex field`}).option(`needle-match-case`,{type:`boolean`,description:`The needle.matchCase field`}).option(`timeframe-from`,{type:`number`,description:`The timeframe.from field`}).option(`timeframe-to`,{type:`number`,description:`The timeframe.to field`}).option(`type`,{type:`string`,description:`The type field`,choices:[`string`,`boolean`,`number`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Retrieve values from your telemetry events.`}),handler:async n=>{if(n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers observability telemetry values`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/observability/telemetry/values`,pathParams:{},bodyKind:`json`,body:{datasets:n.datasets,key:n.key,limit:n.limit,needleIsRegex:n.needleIsRegex,needleMatchCase:n.needleMatchCase,timeframeFrom:n.timeframeFrom,timeframeTo:n.timeframeTo,type:n.type,body:n.body},validation:`passed`});return}let a=await o(n),s=n.local?h:await i(a);if(n.accountId=s,n.body){let e=f(n.body);p(await g(`Creating telemetry`,async()=>a.post(`/accounts/${s}/workers/observability/telemetry/values`,{body:e})),{successLabel:`Created telemetry`});return}if(n.datasets===void 0)throw Error(`--datasets is required (or pass --body with this field set).`);if(n.key===void 0&&(n.key=await t(`key`,``)),n.timeframeFrom===void 0)throw Error(`--timeframe-from is required (or pass --body with this field set).`);if(n.timeframeTo===void 0)throw Error(`--timeframe-to is required (or pass --body with this field set).`);n.type===void 0&&(n.type=await r(`type`,``,[`string`,`boolean`,`number`]));let c={};n.datasets!==void 0&&d(c,[`datasets`],n.datasets),n.key!==void 0&&d(c,[`key`],l(n.key,`key`,`text`)),n.limit!==void 0&&d(c,[`limit`],n.limit),n.needleIsRegex!==void 0&&d(c,[`needle`,`isRegex`],n.needleIsRegex),n.needleMatchCase!==void 0&&d(c,[`needle`,`matchCase`],n.needleMatchCase),n.timeframeFrom!==void 0&&d(c,[`timeframe`,`from`],n.timeframeFrom),n.timeframeTo!==void 0&&d(c,[`timeframe`,`to`],n.timeframeTo),n.type!==void 0&&d(c,[`type`],l(n.type,`type`,`text`)),p(await g(`Creating telemetry`,async()=>a.post(`/accounts/${s}/workers/observability/telemetry/values`,{body:Object.keys(c).length>0?c:void 0})),{successLabel:`Created telemetry`})}},be={command:`telemetry`,describe:`Workers observability — destinations, queries, and telemetry for monitoring and debugging`,builder:e=>e.command(_e).command(ve).command(ye).demandCommand(1),handler:()=>{}},xe={command:`observability`,describe:`Operations for observability`,builder:e=>e.command(ue).command(ge).command(be).demandCommand(1),handler:()=>{}},Se={command:`list`,describe:`Returns a list of available placement regions organized by cloud provider. These regions can be used to configure Smart Placement for Workers.`,builder:e=>e,handler:async e=>{let t=await o(e),n=e.local?h:await i(t);e.accountId=n,p(await g(`Loading regions`,async()=>t.workers.placement.regions.list(n)),{successLabel:`Loaded regions`})}},Ce={command:`regions`,describe:`Placement operations`,builder:e=>e.command(Se).demandCommand(1),handler:()=>{}},we={command:`placement`,describe:`Operations for placement`,builder:e=>e.command(Ce).demandCommand(1),handler:()=>{}},Te={command:`create`,describe:`Creates the stripe config for a publisher.`,builder:e=>e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}),handler:async t=>{if(t.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers publisher stripe create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/pay-per-crawl/publisher/stripe`,pathParams:{},bodyKind:`none`,validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);t.accountId=r,p(await g(`Creating stripe`,async()=>n.workers.publisher.stripe.create(r)),{successLabel:`Created stripe`})}},Ee={command:`delete`,describe:`Deletes the stripe config for a publisher.`,builder:e=>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}),handler:async t=>{if(t.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers publisher stripe delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/pay-per-crawl/publisher/stripe`,pathParams:{},bodyKind:`none`,validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,!await a(`stripe`,``,{force:!!t.force})){process.stderr.write(`Aborted.
|
|
10
|
-
`);return}p(await g(`Deleting stripe`,async()=>n.workers.publisher.stripe.delete(r)),{successLabel:`Deleted stripe`})}},De={command:`get`,describe:`Gets the stripe config for a publisher.`,builder:e=>e,handler:async e=>{let t=await o(e),n=e.local?h:await i(t);e.accountId=n,p(await g(`Loading stripe`,async()=>t.workers.publisher.stripe.get(n)),{successLabel:`Loaded stripe`})}},Oe={command:`stripe`,describe:`Publisher operations`,builder:e=>e.command(Te).command(Ee).command(De).demandCommand(1),handler:()=>{}},ke={command:`publisher`,describe:`Operations for publisher`,builder:e=>e.command(Oe).demandCommand(1),handler:()=>{}},Ae={command:`generate <domain>`,describe:`Generates temporary credentials for accessing Cloudflare's container image registry. Used for pulling and pushing container images.`,builder:e=>e.positional(`domain`,{type:`string`,description:`The domain to get credentials for.`,demandOption:!0}).option(`expiration-minutes`,{type:`number`,description:`The number of minutes the credentials will be valid for.`}).option(`permissions`,{type:`string`,array:!0,description:`The permissions field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Specifies the configuration for the image registry credential to create.`}),handler:async t=>{if(u(t.domain,`domain`),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers registries credentials generate`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/containers/registries/${t.domain??`<domain>`}/credentials`,pathParams:{domain:String(t.domain??``)},bodyKind:`json`,body:{expirationMinutes:t.expirationMinutes,permissions:t.permissions,body:t.body},validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,t.body){let e=f(t.body);p(await g(`Creating credential`,async()=>n.post(`/accounts/${r}/containers/registries/${t.domain}/credentials`,{body:e})),{successLabel:`Created credential`});return}if(t.expirationMinutes===void 0)throw Error(`--expiration-minutes is required (or pass --body with this field set).`);if(t.permissions===void 0)throw Error(`--permissions is required (or pass --body with this field set).`);let a={};t.expirationMinutes!==void 0&&d(a,[`expiration_minutes`],t.expirationMinutes),t.permissions!==void 0&&d(a,[`permissions`],t.permissions),p(await g(`Creating credential`,async()=>n.post(`/accounts/${r}/containers/registries/${t.domain}/credentials`,{body:Object.keys(a).length>0?a:void 0})),{successLabel:`Created credential`})}},je={command:`credentials`,describe:`Registries operations`,builder:e=>e.command(Ae).demandCommand(1),handler:()=>{}},Me={command:`registries`,describe:`Operations for registries`,builder:e=>e.command(je).demandCommand(1),handler:()=>{}},Ne={command:`create`,describe:`Creates a route that maps a URL pattern to a Worker.`,builder:e=>e.option(`pattern`,{type:`string`,description:`Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).`}).option(`script`,{type:`string`,description:`Name of the script to run if the route matches.`}).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)`}),handler:async e=>{if(e.dryRun){m({command:`cf workers routes create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/workers/routes`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{pattern:e.pattern,script:e.script,body:e.body},validation:`passed`});return}let n=await o(e);if(e.zoneId=await s({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=f(e.body);p(await g(`Creating route`,async()=>n.post(`/zones/${e.zoneId}/workers/routes`,{body:t})),{successLabel:`Created route`});return}e.pattern===void 0&&(e.pattern=await t(`pattern`,`Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).`));let r={};e.pattern!==void 0&&d(r,[`pattern`],l(e.pattern,`pattern`,`text`)),e.script!==void 0&&d(r,[`script`],l(e.script,`script`,`text`)),p(await g(`Creating route`,async()=>n.post(`/zones/${e.zoneId}/workers/routes`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Created route`})}},Pe={command:`delete <routeId>`,describe:`Deletes a route.`,builder:e=>e.positional(`routeId`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}),handler:async e=>{if(u(e.routeId,`routeId`),e.dryRun){m({command:`cf workers routes delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/workers/routes/${e.routeId??`<routeId>`}`,pathParams:{routeId:String(e.routeId??``),zoneId:String(e.zoneId??``)},bodyKind:`none`,validation:`passed`});return}let t=await o(e),n=await s({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,!await a(`route`,String(e.routeId??``),{force:!!e.force})){process.stderr.write(`Aborted.
|
|
11
|
-
`);return}p(await g(`Deleting route`,async()=>t.workers.routes.delete(e.routeId,n)),{successLabel:`Deleted route`})}},Fe={command:`get <routeId>`,describe:`Returns information about a route, including URL pattern and Worker.`,builder:e=>e.positional(`routeId`,{type:`string`,description:`Identifier.`,demandOption:!0}),handler:async e=>{u(e.routeId,`routeId`);let t=await o(e),n=await s({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,p(await g(`Loading route`,async()=>t.workers.routes.get(e.routeId,n)),{successLabel:`Loaded route`})}},Ie={command:`list`,describe:`Returns routes for a zone.`,builder:e=>e,handler:async e=>{let t=await o(e),n=await s({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,p(await g(`Loading routes`,async()=>t.workers.routes.list(n)),{successLabel:`Loaded routes`})}},Le={command:`update <routeId>`,describe:`Updates the URL pattern or Worker associated with a route.`,builder:e=>e.positional(`routeId`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`pattern`,{type:`string`,description:`Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).`}).option(`script`,{type:`string`,description:`Name of the script to run if the route matches.`}).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)`}),handler:async e=>{if(u(e.routeId,`routeId`),e.dryRun){m({command:`cf workers routes update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/workers/routes/${e.routeId??`<routeId>`}`,pathParams:{routeId:String(e.routeId??``),zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{pattern:e.pattern,script:e.script,body:e.body},validation:`passed`});return}let n=await o(e);if(e.zoneId=await s({zone:e.zone},n,{quiet:e.quiet}),e.body){let t=f(e.body);p(await g(`Updating route`,async()=>n.put(`/zones/${e.zoneId}/workers/routes/${e.routeId}`,{body:t})),{successLabel:`Updated route`});return}e.pattern===void 0&&(e.pattern=await t(`pattern`,`Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).`));let r={};e.pattern!==void 0&&d(r,[`pattern`],l(e.pattern,`pattern`,`text`)),e.script!==void 0&&d(r,[`script`],l(e.script,`script`,`text`)),p(await g(`Updating route`,async()=>n.put(`/zones/${e.zoneId}/workers/routes/${e.routeId}`,{body:Object.keys(r).length>0?r:void 0})),{successLabel:`Updated route`})}},Re={command:`routes`,describe:`Map URL patterns to Workers so incoming requests are dispatched to the correct script`,builder:e=>e.command(Ne).command(Pe).command(Fe).command(Ie).command(Le).demandCommand(1),handler:()=>{}},ze={command:`create`,describe:`Start uploading a collection of assets for use in a Worker version. To learn more about the direct uploads of assets, see https://developers.cloudflare.com/workers/static-assets/direct-upload/.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).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)`}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts assets upload create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/assets-upload-session`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`json`,body:{body:t.body},validation:`passed`});return}let r=await o(t),a=t.local?h:await i(r);t.accountId=a;let s=n({scriptName:t.scriptName});if(t.scriptName=s,t.body){let e=f(t.body);p(await g(`Creating upload`,async()=>r.post(`/accounts/${a}/workers/scripts/${s}/assets-upload-session`,{body:e})),{successLabel:`Created upload`});return}p(await g(`Creating upload`,async()=>r.workers.scripts.assets.upload.create(a,s)),{successLabel:`Created upload`})}},Be={command:`upload`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(ze).demandCommand(1),handler:()=>{}},Ve={command:`assets`,describe:`Operations for scripts.assets`,builder:e=>e.command(Be).demandCommand(1),handler:()=>{}},He={command:`get`,describe:`Fetch script content only.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}),handler:async e=>{let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a,p(await g(`Loading content`,async()=>t.workers.scripts.content.get(r,a)),{successLabel:`Loaded content`})}},Ue={command:`update`,describe:`Put script content without touching config or metadata.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`cf-worker-body-part`,{type:`string`,description:`The multipart name of a script upload part containing script content in service worker format. Alternative to including in a metadata part.`}).option(`cf-worker-main-module-part`,{type:`string`,description:`The multipart name of a script upload part containing script content in es module format. Alternative to including in a metadata part.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}).option(`files`,{type:`string`,description:"An array of modules (often JavaScript files) comprising a Worker script. At least one module must be present and referenced in the metadata as `main_module` or `body_part` by filename.<br/>Possible Content-Type(s) are: `application/javascript+module`, `text/javascript+module`, `application/javascript`, `text/javascript`, `text/x-python`, `text/x-python-requirement`, `application/wasm`, `text/plain`, `application/octet-stream`, `application/source-map`."}).option(`metadata`,{type:`string`,description:`JSON-encoded metadata about the uploaded parts and Worker configuration.`}),handler:async t=>{let r={};if(t.cfWorkerBodyPart!==void 0&&(r[`CF-WORKER-BODY-PART`]=String(t.cfWorkerBodyPart)),t.cfWorkerMainModulePart!==void 0&&(r[`CF-WORKER-MAIN-MODULE-PART`]=String(t.cfWorkerMainModulePart)),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts content update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/content`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`multipart`,body:{body:t.body,file:t.file,files:t.files,metadata:t.metadata},validation:`passed`});return}let a=await o(t),s=t.local?h:await i(a);t.accountId=s;let c=n({scriptName:t.scriptName});if(t.scriptName=c,t.file!==void 0||t.body!==void 0||t.files!==void 0||t.metadata!==void 0){let e=new FormData;if(t.file){let{readFileSync:n}=await import(`node:fs`),{resolve:r}=await import(`node:path`),i=n(r(t.file));e.append(`file`,new Blob([i]),t.file.split(`/`).pop())}else t.body!==void 0&&e.append(`file`,t.body);if(t.files!==void 0){let n=typeof t.files==`string`?l(t.files,`files`,`text`):t.files;e.append(`files`,typeof n==`string`?n:JSON.stringify(n))}if(t.metadata!==void 0){let n=typeof t.metadata==`string`?l(t.metadata,`metadata`,`text`):t.metadata;e.append(`metadata`,typeof n==`string`?n:JSON.stringify(n))}p(await g(`Updating content`,async()=>a.put(`/accounts/${s}/workers/scripts/${c}/content`,{body:e,headers:Object.keys(r).length>0?r:void 0})),{successLabel:`Updated content`});return}if(t.body){let e=l(t.body,`body`,`binary`);p(await g(`Updating content`,async()=>a.put(`/accounts/${s}/workers/scripts/${c}/content`,{body:e,headers:{"Content-Type":`multipart/form-data`,...r}})),{successLabel:`Updated content`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},We={command:`content`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(He).command(Ue).demandCommand(1),handler:()=>{}},Ge={command:`delete`,describe:`Delete your worker. This call has no response body on a successful delete.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`force`,{type:`boolean`,description:`If set to true, delete will not be stopped by associated service binding, durable object, or other binding. Any of these associated bindings/durable objects will be deleted along with the script.`,default:!1}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}),handler:async t=>{let r={};if(t.force!==void 0&&(r.force=t.force),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`json`,body:{...r,body:t.body},validation:`passed`});return}let s=await o(t),c=t.local?h:await i(s);t.accountId=c;let l=n({scriptName:t.scriptName});if(t.scriptName=l,!await a(`script`,String(l??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
12
|
-
`);return}if(t.body){let e=f(t.body),n=new URLSearchParams(Object.entries(r).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();p(await g(`Deleting script`,async()=>s.delete(`/accounts/${c}/workers/scripts/${l}${n?`?`+n:``}`,{body:e})),{successLabel:`Deleted script`});return}p(await g(`Deleting script`,async()=>s.workers.scripts.delete(c,l,Object.keys(r).length>0?r:void 0)),{successLabel:`Deleted script`})}},Ke={command:`get`,describe:`Fetch raw script content for your worker. Note this is the original script content, not JSON encoded.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1}),handler:async e=>{let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a;let s=await g(`Loading script`,async()=>v(`/accounts/${r}/workers/scripts/${a}`,`GET`,e.local?e.localEndpoint:void 0));_(e.text===!0?s.toString(`utf-8`):s)}},qe={command:`list`,describe:`Fetch a list of uploaded workers.`,builder:e=>e.option(`tags`,{type:`string`,description:`Filter scripts by tags. Format: comma-separated list of tag:allowed pairs where allowed is 'yes' or 'no'.`}),handler:async e=>{let t={};e.tags!==void 0&&(t.tags=e.tags);let n=await o(e),r=e.local?h:await i(n);e.accountId=r,p(await g(`Loading scripts`,async()=>n.workers.scripts.list(r,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded scripts`})}},Je={command:`get`,describe:`Fetches Cron Triggers for a Worker.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}),handler:async e=>{let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a,p(await g(`Loading schedule`,async()=>t.workers.scripts.schedules.get(r,a)),{successLabel:`Loaded schedule`})}},Ye={command:`update`,describe:`Updates Cron Triggers for a Worker.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).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)`}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts schedules update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/schedules`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`json`,body:{body:t.body},validation:`passed`});return}let r=await o(t),a=t.local?h:await i(r);t.accountId=a;let s=n({scriptName:t.scriptName});if(t.scriptName=s,t.body){let e=f(t.body);p(await g(`Updating schedule`,async()=>r.put(`/accounts/${a}/workers/scripts/${s}/schedules`,{body:e})),{successLabel:`Updated schedule`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Xe={command:`schedules`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(Je).command(Ye).demandCommand(1),handler:()=>{}},Ze={command:`edit`,describe:`Patch metadata or config, such as bindings or usage model.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}).option(`settings`,{type:`string`,description:`The settings`}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts script-and-version-settings edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/settings`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`multipart`,body:{body:t.body,file:t.file,settings:t.settings},validation:`passed`});return}let r=await o(t),a=t.local?h:await i(r);t.accountId=a;let s=n({scriptName:t.scriptName});if(t.scriptName=s,t.file!==void 0||t.body!==void 0||t.settings!==void 0){let e=new FormData;if(t.file){let{readFileSync:n}=await import(`node:fs`),{resolve:r}=await import(`node:path`),i=n(r(t.file));e.append(`file`,new Blob([i]),t.file.split(`/`).pop())}else t.body!==void 0&&e.append(`file`,t.body);if(t.settings!==void 0){let n=typeof t.settings==`string`?l(t.settings,`settings`,`text`):t.settings;e.append(`settings`,typeof n==`string`?n:JSON.stringify(n))}p(await g(`Updating script and version setting`,async()=>r.patch(`/accounts/${a}/workers/scripts/${s}/settings`,{body:e})),{successLabel:`Updated script and version setting`});return}if(t.body){let e=l(t.body,`body`,`binary`);p(await g(`Updating script and version setting`,async()=>r.patch(`/accounts/${a}/workers/scripts/${s}/settings`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Updated script and version setting`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Qe={command:`get`,describe:`Get metadata and config, such as bindings or usage model.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}),handler:async e=>{let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a,p(await g(`Loading script and version setting`,async()=>t.workers.scripts.scriptAndVersionSettings.get(r,a)),{successLabel:`Loaded script and version setting`})}},$e={command:`script-and-version-settings`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(Ze).command(Qe).demandCommand(1),handler:()=>{}},et={command:`search`,describe:`Search for Workers in an account.`,builder:e=>e.option(`name`,{type:`string`,description:`Worker name to search for. Both exact and partial matches are returned.`}).option(`id`,{type:`string`,description:`Worker ID (also called tag) to search for. Only exact matches are returned.`}).option(`order-by`,{type:`string`,description:`Property to sort results by. Results are sorted in ascending order.`,choices:[`created_on`,`modified_on`,`name`]}).option(`page`,{type:`number`,description:`Current page.`}).option(`per-page`,{type:`number`,description:`Items per page.`}),handler:async e=>{let t={};e.name!==void 0&&(t.name=e.name),e.id!==void 0&&(t.id=e.id),e.orderBy!==void 0&&(t.order_by=e.orderBy),e.page!==void 0&&(t.page=e.page),e.perPage!==void 0&&(t.per_page=e.perPage);let n=await o(e),r=e.local?h:await i(n);e.accountId=r,p(await g(`Loading script`,async()=>n.workers.scripts.search(r,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded script`})}},tt={command:`edit`,describe:`Patch script-level settings when using [Worker Versions](https://developers.cloudflare.com/api/operations/worker-versions-list-versions). Including but not limited to Logpush and Tail Consumers.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`logpush`,{type:`boolean`,description:`Whether Logpush is turned on for the Worker.`,default:!1}).option(`observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`,default:!1}).option(`observability-head-sampling-rate`,{type:`number`,description:`The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.`}).option(`observability-logs-destinations`,{type:`string`,array:!0,description:`A list of destinations where logs will be exported to.`}).option(`observability-logs-enabled`,{type:`boolean`,description:`Whether logs are enabled for the Worker.`,default:!1}).option(`observability-logs-head-sampling-rate`,{type:`number`,description:`The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.`}).option(`observability-logs-invocation-logs`,{type:`boolean`,description:`Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.`,default:!1}).option(`observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`,default:!0}).option(`observability-traces-destinations`,{type:`string`,array:!0,description:`A list of destinations where traces will be exported to.`}).option(`observability-traces-enabled`,{type:`boolean`,description:`Whether traces are enabled for the Worker.`}).option(`observability-traces-head-sampling-rate`,{type:`number`,description:`The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.`}).option(`observability-traces-persist`,{type:`boolean`,description:`Whether trace persistence is enabled for the Worker.`,default:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`observability-enabled`,`observability-head-sampling-rate`,`observability-logs-destinations`,`observability-logs-enabled`,`observability-logs-head-sampling-rate`,`observability-logs-invocation-logs`,`observability-traces-destinations`,`observability-traces-enabled`,`observability-traces-head-sampling-rate`].some(t=>e[t]!==void 0)){let t=[`observability-enabled`,`observability-logs-enabled`,`observability-logs-invocation-logs`].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 --observability-* flag is set`)}return!0}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts settings edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/script-settings`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`json`,body:{logpush:t.logpush,observabilityEnabled:t.observabilityEnabled,observabilityHeadSamplingRate:t.observabilityHeadSamplingRate,observabilityLogsDestinations:t.observabilityLogsDestinations,observabilityLogsEnabled:t.observabilityLogsEnabled,observabilityLogsHeadSamplingRate:t.observabilityLogsHeadSamplingRate,observabilityLogsInvocationLogs:t.observabilityLogsInvocationLogs,observabilityLogsPersist:t.observabilityLogsPersist,observabilityTracesDestinations:t.observabilityTracesDestinations,observabilityTracesEnabled:t.observabilityTracesEnabled,observabilityTracesHeadSamplingRate:t.observabilityTracesHeadSamplingRate,observabilityTracesPersist:t.observabilityTracesPersist,body:t.body},validation:`passed`});return}let r=await o(t),a=t.local?h:await i(r);t.accountId=a;let s=n({scriptName:t.scriptName});if(t.scriptName=s,t.body){let e=f(t.body);p(await g(`Updating setting`,async()=>r.patch(`/accounts/${a}/workers/scripts/${s}/script-settings`,{body:e})),{successLabel:`Updated setting`});return}let c={};t.logpush!==void 0&&d(c,[`logpush`],t.logpush),t.observabilityEnabled!==void 0&&d(c,[`observability`,`enabled`],t.observabilityEnabled),t.observabilityHeadSamplingRate!==void 0&&d(c,[`observability`,`head_sampling_rate`],t.observabilityHeadSamplingRate),t.observabilityLogsDestinations!==void 0&&d(c,[`observability`,`logs`,`destinations`],t.observabilityLogsDestinations),t.observabilityLogsEnabled!==void 0&&d(c,[`observability`,`logs`,`enabled`],t.observabilityLogsEnabled),t.observabilityLogsHeadSamplingRate!==void 0&&d(c,[`observability`,`logs`,`head_sampling_rate`],t.observabilityLogsHeadSamplingRate),t.observabilityLogsInvocationLogs!==void 0&&d(c,[`observability`,`logs`,`invocation_logs`],t.observabilityLogsInvocationLogs),t.observabilityLogsPersist!==void 0&&d(c,[`observability`,`logs`,`persist`],t.observabilityLogsPersist),t.observabilityTracesDestinations!==void 0&&d(c,[`observability`,`traces`,`destinations`],t.observabilityTracesDestinations),t.observabilityTracesEnabled!==void 0&&d(c,[`observability`,`traces`,`enabled`],t.observabilityTracesEnabled),t.observabilityTracesHeadSamplingRate!==void 0&&d(c,[`observability`,`traces`,`head_sampling_rate`],t.observabilityTracesHeadSamplingRate),t.observabilityTracesPersist!==void 0&&d(c,[`observability`,`traces`,`persist`],t.observabilityTracesPersist),p(await g(`Updating setting`,async()=>r.patch(`/accounts/${a}/workers/scripts/${s}/script-settings`,{body:Object.keys(c).length>0?c:void 0})),{successLabel:`Updated setting`})}},nt={command:`get`,describe:`Get script-level settings when using [Worker Versions](https://developers.cloudflare.com/api/operations/worker-versions-list-versions). Includes Logpush and Tail Consumers.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}),handler:async e=>{let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a,p(await g(`Loading setting`,async()=>t.workers.scripts.settings.get(r,a)),{successLabel:`Loaded setting`})}},rt={command:`settings`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(tt).command(nt).demandCommand(1),handler:()=>{}},it={command:`create`,describe:`Enable or disable the Worker on the workers.dev subdomain.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`enabled`,{type:`boolean`,description:`Whether the Worker should be available on the workers.dev subdomain.`}).option(`previews-enabled`,{type:`boolean`,description:`Whether the Worker's Preview URLs should be available on the workers.dev subdomain.`}).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)`}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts subdomain create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/subdomain`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`json`,body:{enabled:t.enabled,previewsEnabled:t.previewsEnabled,body:t.body},validation:`passed`});return}let r=await o(t),a=t.local?h:await i(r);t.accountId=a;let s=n({scriptName:t.scriptName});if(t.scriptName=s,t.body){let e=f(t.body);p(await g(`Creating subdomain`,async()=>r.post(`/accounts/${a}/workers/scripts/${s}/subdomain`,{body:e})),{successLabel:`Created subdomain`});return}if(t.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);let c={};t.enabled!==void 0&&d(c,[`enabled`],t.enabled),t.previewsEnabled!==void 0&&d(c,[`previews_enabled`],t.previewsEnabled),p(await g(`Creating subdomain`,async()=>r.post(`/accounts/${a}/workers/scripts/${s}/subdomain`,{body:Object.keys(c).length>0?c:void 0})),{successLabel:`Created subdomain`})}},at={command:`delete`,describe:`Disable all workers.dev subdomains for a Worker.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).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}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts subdomain delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/subdomain`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`none`,validation:`passed`});return}let r=await o(t),s=t.local?h:await i(r);t.accountId=s;let c=n({scriptName:t.scriptName});if(t.scriptName=c,!await a(`subdomain`,String(c??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
13
|
-
`);return}p(await g(`Deleting subdomain`,async()=>r.workers.scripts.subdomain.delete(s,c)),{successLabel:`Deleted subdomain`})}},ot={command:`get`,describe:`Get if the Worker is available on the workers.dev subdomain.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}),handler:async e=>{let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a,p(await g(`Loading subdomain`,async()=>t.workers.scripts.subdomain.get(r,a)),{successLabel:`Loaded subdomain`})}},st={command:`subdomain`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(it).command(at).command(ot).demandCommand(1),handler:()=>{}},ct={command:`create`,describe:`Starts a tail that receives logs and exception from a Worker.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).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)`}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts tail create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/tails`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`json`,body:{body:t.body},validation:`passed`});return}let r=await o(t),a=t.local?h:await i(r);t.accountId=a;let s=n({scriptName:t.scriptName});if(t.scriptName=s,t.body){let e=f(t.body);p(await g(`Creating tail`,async()=>r.post(`/accounts/${a}/workers/scripts/${s}/tails`,{body:e})),{successLabel:`Created tail`});return}p(await g(`Creating tail`,async()=>r.workers.scripts.tail.create(a,s)),{successLabel:`Created tail`})}},lt={command:`delete <id>`,describe:`Deletes a tail from a Worker.`,builder:e=>e.positional(`id`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}),handler:async t=>{if(u(t.id,`id`),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts tail delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/tails/${t.id??`<id>`}`,pathParams:{scriptName:String(t.scriptName??``),id:String(t.id??``)},bodyKind:`json`,body:{body:t.body},validation:`passed`});return}let r=await o(t),s=t.local?h:await i(r);t.accountId=s;let c=n({scriptName:t.scriptName});if(t.scriptName=c,!await a(`tail`,String(t.id??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
14
|
-
`);return}if(t.body){let e=f(t.body);p(await g(`Deleting tail`,async()=>r.delete(`/accounts/${s}/workers/scripts/${c}/tails/${t.id}`,{body:e})),{successLabel:`Deleted tail`});return}p(await g(`Deleting tail`,async()=>r.workers.scripts.tail.delete(s,c,t.id)),{successLabel:`Deleted tail`})}},ut={command:`tail`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(ct).command(lt).demandCommand(1),handler:()=>{}},dt={command:`update`,describe:`Upload a worker module. You can find more about the multipart metadata on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`bindings-inherit`,{type:`string`,description:'When set to "strict", the upload will fail if any `inherit` type bindings cannot be resolved against the previous version of the Worker. Without this, unresolvable inherit bindings are silently dropped.',choices:[`strict`]}).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)`}),handler:async t=>{let r={};if(t.bindingsInherit!==void 0&&(r.bindings_inherit=t.bindingsInherit),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`json`,body:{...r,body:t.body},validation:`passed`});return}let a=await o(t),s=t.local?h:await i(a);t.accountId=s;let c=n({scriptName:t.scriptName});if(t.scriptName=c,t.body){let e=l(t.body,`body`,`binary`),n=new URLSearchParams(Object.entries(r).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();p(await g(`Updating script`,async()=>a.put(`/accounts/${s}/workers/scripts/${c}${n?`?`+n:``}`,{body:e,headers:{"Content-Type":`application/octet-stream`}})),{successLabel:`Updated script`});return}p(await g(`Updating script`,async()=>a.workers.scripts.update(s,c,Object.keys(r).length>0?r:void 0)),{successLabel:`Updated script`})}},ft={command:`get`,describe:`Fetches the Usage Model for a given Worker.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}),handler:async e=>{let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a,p(await g(`Loading usage model`,async()=>t.workers.scripts.usageModel.get(r,a)),{successLabel:`Loaded usage model`})}},pt={command:`update`,describe:`Updates the Usage Model for a given Worker. Requires a Workers Paid subscription.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`usage-model`,{type:`string`,description:`Usage model for the Worker invocations.`,choices:[`standard`,`bundled`,`unbound`],default:`standard`}).option(`user-limits-cpu-ms`,{type:`number`,description:`The amount of CPU time this Worker can use in milliseconds.`}).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)`}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers scripts usage-model update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/usage-model`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`json`,body:{usageModel:t.usageModel,userLimitsCpuMs:t.userLimitsCpuMs,body:t.body},validation:`passed`});return}let r=await o(t),a=t.local?h:await i(r);t.accountId=a;let s=n({scriptName:t.scriptName});if(t.scriptName=s,t.body){let e=f(t.body);p(await g(`Updating usage model`,async()=>r.put(`/accounts/${a}/workers/scripts/${s}/usage-model`,{body:e})),{successLabel:`Updated usage model`});return}let c={};t.usageModel!==void 0&&d(c,[`usage_model`],l(t.usageModel,`usageModel`,`text`)),t.userLimitsCpuMs!==void 0&&d(c,[`user_limits`,`cpu_ms`],t.userLimitsCpuMs),p(await g(`Updating usage model`,async()=>r.put(`/accounts/${a}/workers/scripts/${s}/usage-model`,{body:Object.keys(c).length>0?c:void 0})),{successLabel:`Updated usage model`})}},mt={command:`usage-model`,describe:`Worker script usage model operations (deprecated)`,builder:e=>e.command(ft).command(pt).demandCommand(1),handler:()=>{}},ht={command:`scripts`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(Ge).command(Ke).command(qe).command(et).command(dt).command(Ve).command(We).command(Xe).command($e).command(rt).command(st).command(ut).command(mt).demandCommand(1),handler:()=>{}},gt={command:`delete <secretName>`,describe:`Remove a secret from a script.`,builder:e=>e.positional(`secretName`,{type:`string`,description:`A JavaScript variable name for the secret binding.`,demandOption:!0}).option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`url-encoded`,{type:`string`,description:`Flag that indicates whether the secret name is URL encoded.`}).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}),handler:async t=>{u(t.secretName,`secretName`);let r={};if(t.urlEncoded!==void 0&&(r.url_encoded=t.urlEncoded),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers secrets delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/secrets/${t.secretName??`<secretName>`}`,pathParams:{scriptName:String(t.scriptName??``),secretName:String(t.secretName??``)},bodyKind:`json`,body:{...r},validation:`passed`});return}let s=await o(t),c=t.local?h:await i(s);t.accountId=c;let l=n({scriptName:t.scriptName});if(t.scriptName=l,!await a(`secret`,String(t.secretName??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
15
|
-
`);return}p(await g(`Deleting secret`,async()=>s.workers.secrets.delete(c,l,t.secretName,Object.keys(r).length>0?r:void 0)),{successLabel:`Deleted secret`})}},_t={command:`get <secretName>`,describe:`Get a given secret binding (value omitted) on a script.`,builder:e=>e.positional(`secretName`,{type:`string`,description:`A JavaScript variable name for the secret binding.`,demandOption:!0}).option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`url-encoded`,{type:`string`,description:`Flag that indicates whether the secret name is URL encoded.`}),handler:async e=>{u(e.secretName,`secretName`);let t={};e.urlEncoded!==void 0&&(t.url_encoded=e.urlEncoded);let r=await o(e),a=e.local?h:await i(r);e.accountId=a;let s=n({scriptName:e.scriptName});e.scriptName=s,p(await g(`Loading secret`,async()=>r.workers.secrets.get(a,s,e.secretName,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded secret`})}},vt={command:`list`,describe:`List secrets bound to a script.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}),handler:async e=>{let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a,p(await g(`Loading secrets`,async()=>t.workers.secrets.list(r,a)),{successLabel:`Loaded secrets`})}},yt={command:`update <name>`,describe:`Add a secret to a script.`,builder:e=>e.positional(`name`,{type:`string`,description:`A JavaScript variable name for the binding.`,demandOption:!0}).option(`script-name`,{type:`string`,description:`Name of the script, used in URLs and route configuration.`}).option(`text`,{type:`string`,description:`The secret value to use.`}).option(`type`,{type:`string`,description:`The kind of resource that the binding provides.`,choices:[`secret_text`,`secret_key`],default:`secret_text`}).option(`format`,{type:`string`,description:`Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).`,choices:[`raw`,`pkcs8`,`spki`,`jwk`]}).option(`key-base64`,{type:`string`,description:'Base64-encoded key data. Required if `format` is "raw", "pkcs8", or "spki".'}).option(`usages`,{type:`string`,array:!0,description:`Allowed operations with the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#keyUsages).`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`A secret value accessible through a binding.`}).conflicts(`text`,[`format`,`key-base64`,`usages`]).conflicts(`format`,[`text`]).implies(`format`,[`usages`]).conflicts(`key-base64`,[`text`]).conflicts(`usages`,[`text`]).implies(`usages`,[`format`]),handler:async a=>{if(c(a.name,`name`),a.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers secrets update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/scripts/${a.scriptName??`<scriptName>`}/secrets`,pathParams:{scriptName:String(a.scriptName??``)},bodyKind:`json`,body:{name:a.name,text:a.text,type:a.type,format:a.format,keyBase64:a.keyBase64,usages:a.usages,body:a.body},validation:`passed`});return}let s=await o(a),_=a.local?h:await i(s);a.accountId=_;let v=n({scriptName:a.scriptName});if(a.scriptName=v,a.body){let e=f(a.body);p(await g(`Updating secret`,async()=>s.put(`/accounts/${_}/workers/scripts/${v}/secrets`,{body:e})),{successLabel:`Updated secret`});return}a.type===void 0&&(a.type=await r(`type`,`The kind of resource that the binding provides.`,[`secret_text`,`secret_key`])),a.type===`secret_text`&&a.text===void 0&&(a.text=await t(`text`,`The secret value to use.`,{kind:`secret`,question:`Enter value for --text`})),a.type===`secret_key`&&a.format===void 0&&(a.format=await t(`format`,`Data format of the key. [Learn more](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey#format).`,{question:`Enter value for --format`}));let y={};a.text!==void 0&&d(y,[`text`],l(a.text,`text`,`text`)),a.type!==void 0&&d(y,[`type`],l(a.type,`type`,`text`)),a.format!==void 0&&d(y,[`format`],l(a.format,`format`,`text`)),a.keyBase64!==void 0&&d(y,[`key_base64`],l(a.keyBase64,`keyBase64`,`text`)),a.usages!==void 0&&d(y,[`usages`],a.usages),a.name!==void 0&&(y.name=a.name),p(await g(`Updating secret`,async()=>s.put(`/accounts/${_}/workers/scripts/${v}/secrets`,{body:Object.keys(y).length>0?y:void 0})),{successLabel:`Updated secret`})}},bt={command:`secrets`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(gt).command(_t).command(vt).command(yt).demandCommand(1),handler:()=>{}},xt={command:`get <environmentName>`,describe:`Get script content from a worker with an environment.`,builder:e=>e.positional(`environmentName`,{type:`string`,description:`Optional environment if the Worker utilizes one.`,demandOption:!0}).option(`service-name`,{type:`string`,description:`Name of Worker to bind to.`,demandOption:!0}),handler:async e=>{u(e.environmentName,`environmentName`);let t=await o(e),n=e.local?h:await i(t);e.accountId=n,p(await g(`Loading content`,async()=>t.workers.services.environments.content.get(n,e.serviceName,e.environmentName)),{successLabel:`Loaded content`})}},St={command:`update <environmentName>`,describe:`Put script content from a worker with an environment.`,builder:e=>e.positional(`environmentName`,{type:`string`,description:`Optional environment if the Worker utilizes one.`,demandOption:!0}).option(`service-name`,{type:`string`,description:`Name of Worker to bind to.`,demandOption:!0}).option(`cf-worker-body-part`,{type:`string`,description:`The multipart name of a script upload part containing script content in service worker format. Alternative to including in a metadata part.`}).option(`cf-worker-main-module-part`,{type:`string`,description:`The multipart name of a script upload part containing script content in es module format. Alternative to including in a metadata part.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}).option(`files`,{type:`string`,description:"An array of modules (often JavaScript files) comprising a Worker script. At least one module must be present and referenced in the metadata as `main_module` or `body_part` by filename.<br/>Possible Content-Type(s) are: `application/javascript+module`, `text/javascript+module`, `application/javascript`, `text/javascript`, `text/x-python`, `text/x-python-requirement`, `application/wasm`, `text/plain`, `application/octet-stream`, `application/source-map`."}).option(`metadata`,{type:`string`,description:`JSON-encoded metadata about the uploaded parts and Worker configuration.`}),handler:async t=>{u(t.environmentName,`environmentName`);let n={};if(t.cfWorkerBodyPart!==void 0&&(n[`CF-WORKER-BODY-PART`]=String(t.cfWorkerBodyPart)),t.cfWorkerMainModulePart!==void 0&&(n[`CF-WORKER-MAIN-MODULE-PART`]=String(t.cfWorkerMainModulePart)),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers services environments content update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/services/${t.serviceName??`<serviceName>`}/environments/${t.environmentName??`<environmentName>`}/content`,pathParams:{serviceName:String(t.serviceName??``),environmentName:String(t.environmentName??``)},bodyKind:`multipart`,body:{body:t.body,file:t.file,files:t.files,metadata:t.metadata},validation:`passed`});return}let r=await o(t),a=t.local?h:await i(r);if(t.accountId=a,t.file!==void 0||t.body!==void 0||t.files!==void 0||t.metadata!==void 0){let e=new FormData;if(t.file){let{readFileSync:n}=await import(`node:fs`),{resolve:r}=await import(`node:path`),i=n(r(t.file));e.append(`file`,new Blob([i]),t.file.split(`/`).pop())}else t.body!==void 0&&e.append(`file`,t.body);if(t.files!==void 0){let n=typeof t.files==`string`?l(t.files,`files`,`text`):t.files;e.append(`files`,typeof n==`string`?n:JSON.stringify(n))}if(t.metadata!==void 0){let n=typeof t.metadata==`string`?l(t.metadata,`metadata`,`text`):t.metadata;e.append(`metadata`,typeof n==`string`?n:JSON.stringify(n))}p(await g(`Updating content`,async()=>r.put(`/accounts/${a}/workers/services/${t.serviceName}/environments/${t.environmentName}/content`,{body:e,headers:Object.keys(n).length>0?n:void 0})),{successLabel:`Updated content`});return}if(t.body){let e=l(t.body,`body`,`binary`);p(await g(`Updating content`,async()=>r.put(`/accounts/${a}/workers/services/${t.serviceName}/environments/${t.environmentName}/content`,{body:e,headers:{"Content-Type":`multipart/form-data`,...n}})),{successLabel:`Updated content`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Ct={command:`content`,describe:`Services operations`,builder:e=>e.command(xt).command(St).demandCommand(1),handler:()=>{}},wt={command:`edit <environmentName>`,describe:`Patch script metadata, such as bindings.`,builder:e=>e.positional(`environmentName`,{type:`string`,description:`Optional environment if the Worker utilizes one.`,demandOption:!0}).option(`service-name`,{type:`string`,description:`Name of Worker to bind to.`,demandOption:!0}).option(`success`,{type:`boolean`,description:`Whether the API call was successful.`}).option(`result-logpush`,{type:`boolean`,description:`Whether Logpush is turned on for the Worker.`,default:!1}).option(`result-observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`}).option(`result-observability-head-sampling-rate`,{type:`number`,description:`The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.`}).option(`result-observability-logs-destinations`,{type:`string`,array:!0,description:`A list of destinations where logs will be exported to.`}).option(`result-observability-logs-enabled`,{type:`boolean`,description:`Whether logs are enabled for the Worker.`}).option(`result-observability-logs-head-sampling-rate`,{type:`number`,description:`The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.`}).option(`result-observability-logs-invocation-logs`,{type:`boolean`,description:`Whether [invocation logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs) are enabled for the Worker.`}).option(`result-observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`,default:!0}).option(`result-observability-traces-destinations`,{type:`string`,array:!0,description:`A list of destinations where traces will be exported to.`}).option(`result-observability-traces-enabled`,{type:`boolean`,description:`Whether traces are enabled for the Worker.`}).option(`result-observability-traces-head-sampling-rate`,{type:`number`,description:`The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.`}).option(`result-observability-traces-persist`,{type:`boolean`,description:`Whether trace persistence is enabled for the Worker.`,default:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}),handler:async t=>{if(u(t.environmentName,`environmentName`),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers services environments settings edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/services/${t.serviceName??`<serviceName>`}/environments/${t.environmentName??`<environmentName>`}/settings`,pathParams:{serviceName:String(t.serviceName??``),environmentName:String(t.environmentName??``)},bodyKind:`json`,body:{success:t.success,resultLogpush:t.resultLogpush,resultObservabilityEnabled:t.resultObservabilityEnabled,resultObservabilityHeadSamplingRate:t.resultObservabilityHeadSamplingRate,resultObservabilityLogsDestinations:t.resultObservabilityLogsDestinations,resultObservabilityLogsEnabled:t.resultObservabilityLogsEnabled,resultObservabilityLogsHeadSamplingRate:t.resultObservabilityLogsHeadSamplingRate,resultObservabilityLogsInvocationLogs:t.resultObservabilityLogsInvocationLogs,resultObservabilityLogsPersist:t.resultObservabilityLogsPersist,resultObservabilityTracesDestinations:t.resultObservabilityTracesDestinations,resultObservabilityTracesEnabled:t.resultObservabilityTracesEnabled,resultObservabilityTracesHeadSamplingRate:t.resultObservabilityTracesHeadSamplingRate,resultObservabilityTracesPersist:t.resultObservabilityTracesPersist,body:t.body},validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,t.body){let e=f(t.body);p(await g(`Updating setting`,async()=>n.patch(`/accounts/${r}/workers/services/${t.serviceName}/environments/${t.environmentName}/settings`,{body:e})),{successLabel:`Updated setting`});return}if(t.success===void 0)throw Error(`--success is required (or pass --body with this field set).`);if(t.resultObservabilityEnabled===void 0)throw Error(`--result-observability-enabled is required (or pass --body with this field set).`);if(t.resultObservabilityLogsEnabled===void 0)throw Error(`--result-observability-logs-enabled is required (or pass --body with this field set).`);if(t.resultObservabilityLogsInvocationLogs===void 0)throw Error(`--result-observability-logs-invocation-logs is required (or pass --body with this field set).`);let a={};t.success!==void 0&&d(a,[`success`],t.success),t.resultLogpush!==void 0&&d(a,[`result`,`logpush`],t.resultLogpush),t.resultObservabilityEnabled!==void 0&&d(a,[`result`,`observability`,`enabled`],t.resultObservabilityEnabled),t.resultObservabilityHeadSamplingRate!==void 0&&d(a,[`result`,`observability`,`head_sampling_rate`],t.resultObservabilityHeadSamplingRate),t.resultObservabilityLogsDestinations!==void 0&&d(a,[`result`,`observability`,`logs`,`destinations`],t.resultObservabilityLogsDestinations),t.resultObservabilityLogsEnabled!==void 0&&d(a,[`result`,`observability`,`logs`,`enabled`],t.resultObservabilityLogsEnabled),t.resultObservabilityLogsHeadSamplingRate!==void 0&&d(a,[`result`,`observability`,`logs`,`head_sampling_rate`],t.resultObservabilityLogsHeadSamplingRate),t.resultObservabilityLogsInvocationLogs!==void 0&&d(a,[`result`,`observability`,`logs`,`invocation_logs`],t.resultObservabilityLogsInvocationLogs),t.resultObservabilityLogsPersist!==void 0&&d(a,[`result`,`observability`,`logs`,`persist`],t.resultObservabilityLogsPersist),t.resultObservabilityTracesDestinations!==void 0&&d(a,[`result`,`observability`,`traces`,`destinations`],t.resultObservabilityTracesDestinations),t.resultObservabilityTracesEnabled!==void 0&&d(a,[`result`,`observability`,`traces`,`enabled`],t.resultObservabilityTracesEnabled),t.resultObservabilityTracesHeadSamplingRate!==void 0&&d(a,[`result`,`observability`,`traces`,`head_sampling_rate`],t.resultObservabilityTracesHeadSamplingRate),t.resultObservabilityTracesPersist!==void 0&&d(a,[`result`,`observability`,`traces`,`persist`],t.resultObservabilityTracesPersist),p(await g(`Updating setting`,async()=>n.patch(`/accounts/${r}/workers/services/${t.serviceName}/environments/${t.environmentName}/settings`,{body:Object.keys(a).length>0?a:void 0})),{successLabel:`Updated setting`})}},Tt={command:`get <environmentName>`,describe:`Get script settings from a worker with an environment.`,builder:e=>e.positional(`environmentName`,{type:`string`,description:`Optional environment if the Worker utilizes one.`,demandOption:!0}).option(`service-name`,{type:`string`,description:`Name of Worker to bind to.`,demandOption:!0}),handler:async e=>{u(e.environmentName,`environmentName`);let t=await o(e),n=e.local?h:await i(t);e.accountId=n,p(await g(`Loading setting`,async()=>t.workers.services.environments.settings.get(n,e.serviceName,e.environmentName)),{successLabel:`Loaded setting`})}},Et={command:`settings`,describe:`Services operations`,builder:e=>e.command(wt).command(Tt).demandCommand(1),handler:()=>{}},$={command:`environments`,describe:`Operations for services.environments`,builder:e=>e.command(Ct).command(Et).demandCommand(1),handler:()=>{}},Dt={command:`services`,describe:`Operations for services`,builder:e=>e.command($).demandCommand(1),handler:()=>{}},Ot={command:`delete`,describe:`Deletes a Workers subdomain for an account.`,builder:e=>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}),handler:async t=>{if(t.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers subdomains delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/subdomain`,pathParams:{},bodyKind:`none`,validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,!await a(`subdomain`,``,{force:!!t.force})){process.stderr.write(`Aborted.
|
|
16
|
-
`);return}p(await g(`Deleting subdomain`,async()=>n.workers.subdomains.delete(r)),{successLabel:`Deleted subdomain`})}},kt={command:`get`,describe:`Returns a Workers subdomain for an account.`,builder:e=>e,handler:async e=>{let t=await o(e),n=e.local?h:await i(t);e.accountId=n,p(await g(`Loading subdomain`,async()=>t.workers.subdomains.get(n)),{successLabel:`Loaded subdomain`})}},At={command:`update`,describe:`Creates a Workers subdomain for an account.`,builder:e=>e.option(`subdomain`,{type:`string`,description:`The subdomain 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)`}),handler:async n=>{if(n.dryRun){let t=e();t&&u(t,`accountId`),m({command:`cf workers subdomains update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workers/subdomain`,pathParams:{},bodyKind:`json`,body:{subdomain:n.subdomain,body:n.body},validation:`passed`});return}let r=await o(n),a=n.local?h:await i(r);if(n.accountId=a,n.body){let e=f(n.body);p(await g(`Updating subdomain`,async()=>r.put(`/accounts/${a}/workers/subdomain`,{body:e})),{successLabel:`Updated subdomain`});return}n.subdomain===void 0&&(n.subdomain=await t(`subdomain`,``));let s={};n.subdomain!==void 0&&d(s,[`subdomain`],l(n.subdomain,`subdomain`,`text`)),p(await g(`Updating subdomain`,async()=>r.put(`/accounts/${a}/workers/subdomain`,{body:Object.keys(s).length>0?s:void 0})),{successLabel:`Updated subdomain`})}},jt={command:`subdomains`,describe:`Configure the workers.dev subdomain used to reach Workers without a custom domain`,builder:e=>e.command(Ot).command(kt).command(At).demandCommand(1),handler:()=>{}},Mt={command:`create`,describe:`Upload a Worker Version without deploying to Cloudflare's network. You can find more about the multipart metadata on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script.`}).option(`bindings-inherit`,{type:`string`,description:'When set to "strict", the upload will fail if any `inherit` type bindings cannot be resolved against the previous version of the Worker. Without this, unresolvable inherit bindings are silently dropped.',choices:[`strict`]}).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)`}),handler:async t=>{let r={};if(t.bindingsInherit!==void 0&&(r.bindings_inherit=t.bindingsInherit),t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers versions create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workers/scripts/${t.scriptName??`<scriptName>`}/versions`,pathParams:{scriptName:String(t.scriptName??``)},bodyKind:`json`,body:{...r,body:t.body},validation:`passed`});return}let a=await o(t),s=t.local?h:await i(a);t.accountId=s;let c=n({scriptName:t.scriptName});if(t.scriptName=c,t.body){let e=l(t.body,`body`,`binary`),n=new URLSearchParams(Object.entries(r).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();p(await g(`Creating version`,async()=>a.post(`/accounts/${s}/workers/scripts/${c}/versions${n?`?`+n:``}`,{body:e,headers:{"Content-Type":`application/octet-stream`}})),{successLabel:`Created version`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Nt={command:`get <versionId>`,describe:`Retrieves detailed information about a specific version of a Workers script.`,builder:e=>e.positional(`versionId`,{type:`string`,description:`Version ID`,demandOption:!0}).option(`script-name`,{type:`string`,description:`Name of the script.`}),handler:async e=>{u(e.versionId,`versionId`);let t=await o(e),r=e.local?h:await i(t);e.accountId=r;let a=n({scriptName:e.scriptName});e.scriptName=a,p(await g(`Loading version`,async()=>t.workers.versions.get(r,a,e.versionId)),{successLabel:`Loaded version`})}},Pt={command:`list`,describe:`List of Worker Versions. The first version in the list is the latest version.`,builder:e=>e.option(`script-name`,{type:`string`,description:`Name of the script.`}).option(`deployable`,{type:`boolean`,description:`Only return versions that can be used in a deployment. Ignores pagination.`,default:!1}).option(`page`,{type:`number`,description:`Current page.`}).option(`per-page`,{type:`number`,description:`Items per-page.`}),handler:async e=>{let t={};e.deployable!==void 0&&(t.deployable=e.deployable),e.page!==void 0&&(t.page=e.page),e.perPage!==void 0&&(t.per_page=e.perPage);let r=await o(e),a=e.local?h:await i(r);e.accountId=a;let s=n({scriptName:e.scriptName});e.scriptName=s,p(await g(`Loading versions`,async()=>r.workers.versions.list(a,s,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded versions`})}},Ft={command:`versions`,describe:`Upload, download, and configure Worker scripts including bindings, secrets, cron triggers, and deployments`,builder:e=>e.command(Mt).command(Nt).command(Pt).demandCommand(1),handler:()=>{}},It={command:`edit`,describe:`Allows an account admin to set the can_be_enabled setting on a list of zones.`,builder:e=>e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Data for setting flag on zones`}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers zones-can-be-enabled edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/pay-per-crawl/zones_can_be_enabled`,pathParams:{},bodyKind:`json`,body:{body:t.body},validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,t.body){let e=l(t.body,`body`,`binary`);p(await g(`Updating zones can be enabled`,async()=>n.patch(`/accounts/${r}/pay-per-crawl/zones_can_be_enabled`,{body:e,headers:{"Content-Type":`application/octet-stream`}})),{successLabel:`Updated zones can be enabled`});return}p(await g(`Updating zones can be enabled`,async()=>n.workers.zonesCanBeEnabled.edit(r)),{successLabel:`Updated zones can be enabled`})}},Lt={command:`create`,describe:`Provided a list of pay-per-crawl configured zones this method will return whether they can enable PPC or not.`,builder:e=>e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Data for setting flag on zones`}),handler:async t=>{if(t.dryRun){let n=e();n&&u(n,`accountId`),m({command:`cf workers zones-can-be-enabled query create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/pay-per-crawl/zones_can_be_enabled/query`,pathParams:{},bodyKind:`json`,body:{body:t.body},validation:`passed`});return}let n=await o(t),r=t.local?h:await i(n);if(t.accountId=r,t.body){let e=l(t.body,`body`,`binary`);p(await g(`Creating query`,async()=>n.post(`/accounts/${r}/pay-per-crawl/zones_can_be_enabled/query`,{body:e,headers:{"Content-Type":`application/octet-stream`}})),{successLabel:`Created query`});return}p(await g(`Creating query`,async()=>n.workers.zonesCanBeEnabled.query.create(r)),{successLabel:`Created query`})}},Rt={command:`query`,describe:`Zones Can Be Enabled operations`,builder:e=>e.command(Lt).demandCommand(1),handler:()=>{}},zt={command:`zones-can-be-enabled`,describe:`Zones Can Be Enabled operations`,builder:e=>e.command(It).command(Rt).demandCommand(1),handler:()=>{}},Bt={command:`workers`,describe:`Deploy and manage serverless JavaScript/WASM applications on Cloudflare's global network`,builder:e=>e.command(te).command(x).command(w).command(L).command(V).command(K).command(Z).command(ae).command(xe).command(we).command(ke).command(Me).command(Re).command(ht).command(bt).command(Dt).command(jt).command(Ft).command(zt).demandCommand(1),handler:()=>{}};export{Bt as default};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{d as e,h as t,m as n,o as r,p as i,t as a}from"./auth-BHD_B2p9.mjs";import{n as o,r as s}from"./input-validation-BpVQi9rR.mjs";import{n as c,t as l}from"./body-parser-iA3vRFmh.mjs";import{t as u}from"./output-CqGQp2r6.mjs";import{t as d}from"./dry-run-FV0pZwdg.mjs";import{t as f}from"./local-OqhVQbv0.mjs";import{t as p}from"./progress-5sHFvwez.mjs";const m={command:`cancel <buildUuid>`,describe:`Cancel a running or queued build`,builder:e=>e.positional(`buildUuid`,{type:`string`,description:`Build UUID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}),handler:async t=>{if(s(t.buildUuid,`buildUuid`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workers-builds builds cancel`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/builds/builds/${t.buildUuid??`<buildUuid>`}/cancel`,pathParams:{buildUuid:String(t.buildUuid??``)},bodyKind:`none`,validation:`passed`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,u(await p(`Updating build`,async()=>n.workersBuilds.builds.cancel(i,t.buildUuid)),{successLabel:`Updated build`})}},h={command:`get <buildUuid>`,describe:`Retrieve detailed information about a specific build`,builder:e=>e.positional(`buildUuid`,{type:`string`,description:`Build UUID.`,demandOption:!0}),handler:async e=>{s(e.buildUuid,`buildUuid`);let t=await a(e),n=e.local?f:await r(t);e.accountId=n,u(await p(`Loading build`,async()=>t.workersBuilds.builds.get(n,e.buildUuid)),{successLabel:`Loaded build`})}},g={command:`list`,describe:`Get all builds for a specific worker script with pagination`,builder:e=>e.option(`external-script-id`,{type:`string`,description:`System-generated worker script tag.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page number for pagination`}).option(`per-page`,{type:`number`,description:`Number of items per page`}),handler:async e=>{let t={};e.page!==void 0&&(t.page=e.page),e.perPage!==void 0&&(t.per_page=e.perPage);let n=await a(e),i=e.local?f:await r(n);e.accountId=i,u(await p(`Loading builds`,async()=>n.workersBuilds.builds.list(i,e.externalScriptId,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded builds`})}},_={command:`get <buildUuid>`,describe:`Retrieve logs for a specific build with cursor-based pagination`,builder:e=>e.positional(`buildUuid`,{type:`string`,description:`Build UUID.`,demandOption:!0}).option(`cursor`,{type:`string`,description:`Pagination cursor for log retrieval.`}),handler:async e=>{s(e.buildUuid,`buildUuid`);let t={};e.cursor!==void 0&&(t.cursor=e.cursor);let n=await a(e),i=e.local?f:await r(n);e.accountId=i,u(await p(`Loading log`,async()=>n.workersBuilds.builds.logs.get(i,e.buildUuid,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded log`})}},v={command:`logs`,describe:`Build job operations`,builder:e=>e.command(_).demandCommand(1),handler:()=>{}},y={command:`builds`,describe:`Build job operations`,builder:e=>e.command(m).command(h).command(g).command(v).demandCommand(1),handler:()=>{}},b={command:`get-account-limits`,describe:`Retrieve account limits and usage information`,builder:e=>e,handler:async e=>{let t=await a(e),n=e.local?f:await r(t);e.accountId=n,u(await p(`Loading limit`,async()=>t.workersBuilds.getAccountLimits(n)),{successLabel:`Loaded limit`})}},x={command:`get-builds-by-version`,describe:`Retrieve builds for specific version IDs`,builder:e=>e.option(`version-ids`,{type:`string`,description:`Comma-separated list of version UUIDs (max 20).`,demandOption:!0}),handler:async e=>{let t={};e.versionIds!==void 0&&(t.version_ids=e.versionIds);let n=await a(e),i=e.local?f:await r(n);e.accountId=i,u(await p(`Loading version`,async()=>n.workersBuilds.getBuildsByVersion(i,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded version`})}},S={command:`get-latest-builds`,describe:`Retrieve the most recent builds for multiple worker scripts`,builder:e=>e.option(`external-script-ids`,{type:`string`,description:`Comma-separated list of system-generated worker script tags (max 20).`,demandOption:!0}),handler:async e=>{let t={};e.externalScriptIds!==void 0&&(t.external_script_ids=e.externalScriptIds);let n=await a(e),i=e.local?f:await r(n);e.accountId=i,u(await p(`Loading build`,async()=>n.workersBuilds.getLatestBuilds(i,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded build`})}},C={command:`get <repoId>`,describe:`Analyze repository for automatic configuration detection`,builder:e=>e.positional(`repoId`,{type:`string`,description:`Repository identifier.`,demandOption:!0}).option(`provider-type`,{type:`string`,description:`SCM provider type`,demandOption:!0}).option(`provider-account-id`,{type:`string`,description:`Provider account identifier.`,demandOption:!0}).option(`branch`,{type:`string`,description:`Git branch name.`,demandOption:!0}).option(`root-directory`,{type:`string`,description:`Root directory path.`}),handler:async e=>{s(e.repoId,`repoId`);let t={};e.branch!==void 0&&(t.branch=e.branch),e.rootDirectory!==void 0&&(t.root_directory=e.rootDirectory);let n=await a(e),i=e.local?f:await r(n);e.accountId=i,u(await p(`Loading config autofill`,async()=>n.workersBuilds.repos.configAutofill.get(i,e.providerType,e.providerAccountId,e.repoId,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded config autofill`})}},w={command:`config-autofill`,describe:`Repos operations`,builder:e=>e.command(C).demandCommand(1),handler:()=>{}},T={command:`delete <repoConnectionUuid>`,describe:`Remove a repository connection`,builder:e=>e.positional(`repoConnectionUuid`,{type:`string`,description:`Repository connection UUID.`,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}),handler:async t=>{if(s(t.repoConnectionUuid,`repoConnectionUuid`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workers-builds repos connections delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/builds/repos/connections/${t.repoConnectionUuid??`<repoConnectionUuid>`}`,pathParams:{repoConnectionUuid:String(t.repoConnectionUuid??``)},bodyKind:`none`,validation:`passed`});return}let n=await a(t),o=t.local?f:await r(n);if(t.accountId=o,!await i(`connection`,String(t.repoConnectionUuid??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
3
|
-
`);return}u(await p(`Deleting connection`,async()=>n.workersBuilds.repos.connections.delete(o,t.repoConnectionUuid)),{successLabel:`Deleted connection`})}},E={command:`upsert`,describe:`Upsert a repository connection for CI/CD integration`,builder:e=>e.option(`provider-account-id`,{type:`string`,description:`Provider account identifier.`}).option(`provider-account-name`,{type:`string`,description:`The provider_account_name field`}).option(`provider-type`,{type:`string`,description:`The provider_type field`,choices:[`github`]}).option(`repo-id`,{type:`string`,description:`Repository identifier.`}).option(`repo-name`,{type:`string`,description:`The repo_name 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)`}),handler:async i=>{if(i.dryRun){let t=e();t&&s(t,`accountId`),d({command:`cf workers-builds repos connections upsert`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/builds/repos/connections`,pathParams:{},bodyKind:`json`,body:{providerAccountId:i.providerAccountId,providerAccountName:i.providerAccountName,providerType:i.providerType,repoId:i.repoId,repoName:i.repoName,body:i.body},validation:`passed`});return}let m=await a(i),h=i.local?f:await r(m);if(i.accountId=h,i.body){let e=l(i.body);u(await p(`Updating connection`,async()=>m.put(`/accounts/${h}/builds/repos/connections`,{body:e})),{successLabel:`Updated connection`});return}i.providerAccountId===void 0&&(i.providerAccountId=await t(`provider-account-id`,`Provider account identifier.`)),i.providerAccountName===void 0&&(i.providerAccountName=await t(`provider-account-name`,``)),i.providerType===void 0&&(i.providerType=await n(`provider-type`,``,[`github`])),i.repoId===void 0&&(i.repoId=await t(`repo-id`,`Repository identifier.`)),i.repoName===void 0&&(i.repoName=await t(`repo-name`,``));let g={};i.providerAccountId!==void 0&&c(g,[`provider_account_id`],o(i.providerAccountId,`providerAccountId`,`text`)),i.providerAccountName!==void 0&&c(g,[`provider_account_name`],o(i.providerAccountName,`providerAccountName`,`text`)),i.providerType!==void 0&&c(g,[`provider_type`],o(i.providerType,`providerType`,`text`)),i.repoId!==void 0&&c(g,[`repo_id`],o(i.repoId,`repoId`,`text`)),i.repoName!==void 0&&c(g,[`repo_name`],o(i.repoName,`repoName`,`text`)),u(await p(`Updating connection`,async()=>m.put(`/accounts/${h}/builds/repos/connections`,{body:Object.keys(g).length>0?g:void 0})),{successLabel:`Updated connection`})}},D={command:`connections`,describe:`Repos operations`,builder:e=>e.command(T).command(E).demandCommand(1),handler:()=>{}},O={command:`repos`,describe:`Operations for repos`,builder:e=>e.command(w).command(D).demandCommand(1),handler:()=>{}},k={command:`create`,describe:`Create a new build authentication token`,builder:e=>e.option(`build-token-name`,{type:`string`,description:`The build_token_name field`}).option(`build-token-secret`,{type:`string`,description:`The build_token_secret field`}).option(`cloudflare-token-id`,{type:`string`,description:`The cloudflare_token_id 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)`}),handler:async n=>{if(n.dryRun){let t=e();t&&s(t,`accountId`),d({command:`cf workers-builds tokens create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/builds/tokens`,pathParams:{},bodyKind:`json`,body:{buildTokenName:n.buildTokenName,buildTokenSecret:n.buildTokenSecret,cloudflareTokenId:n.cloudflareTokenId,body:n.body},validation:`passed`});return}let i=await a(n),m=n.local?f:await r(i);if(n.accountId=m,n.body){let e=l(n.body);u(await p(`Creating token`,async()=>i.post(`/accounts/${m}/builds/tokens`,{body:e})),{successLabel:`Created token`});return}n.buildTokenName===void 0&&(n.buildTokenName=await t(`build-token-name`,``)),n.buildTokenSecret===void 0&&(n.buildTokenSecret=await t(`build-token-secret`,``)),n.cloudflareTokenId===void 0&&(n.cloudflareTokenId=await t(`cloudflare-token-id`,``));let h={};n.buildTokenName!==void 0&&c(h,[`build_token_name`],o(n.buildTokenName,`buildTokenName`,`text`)),n.buildTokenSecret!==void 0&&c(h,[`build_token_secret`],o(n.buildTokenSecret,`buildTokenSecret`,`text`)),n.cloudflareTokenId!==void 0&&c(h,[`cloudflare_token_id`],o(n.cloudflareTokenId,`cloudflareTokenId`,`text`)),u(await p(`Creating token`,async()=>i.post(`/accounts/${m}/builds/tokens`,{body:Object.keys(h).length>0?h:void 0})),{successLabel:`Created token`})}},A={command:`delete <buildTokenUuid>`,describe:`Remove a build authentication token`,builder:e=>e.positional(`buildTokenUuid`,{type:`string`,description:`Build token UUID.`,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}),handler:async t=>{if(s(t.buildTokenUuid,`buildTokenUuid`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workers-builds tokens delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/builds/tokens/${t.buildTokenUuid??`<buildTokenUuid>`}`,pathParams:{buildTokenUuid:String(t.buildTokenUuid??``)},bodyKind:`none`,validation:`passed`});return}let n=await a(t),o=t.local?f:await r(n);if(t.accountId=o,!await i(`token`,String(t.buildTokenUuid??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
4
|
-
`);return}u(await p(`Deleting token`,async()=>n.workersBuilds.tokens.delete(o,t.buildTokenUuid)),{successLabel:`Deleted token`})}},j={command:`list`,describe:`Get all build tokens with pagination`,builder:e=>e.option(`page`,{type:`number`,description:`Page number for pagination`}).option(`per-page`,{type:`number`,description:`Number of items per page`}),handler:async e=>{let t={};e.page!==void 0&&(t.page=e.page),e.perPage!==void 0&&(t.per_page=e.perPage);let n=await a(e),i=e.local?f:await r(n);e.accountId=i,u(await p(`Loading tokens`,async()=>n.workersBuilds.tokens.list(i,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded tokens`})}},M={command:`tokens`,describe:`Tokens operations`,builder:e=>e.command(k).command(A).command(j).demandCommand(1),handler:()=>{}},N={command:`create-build <triggerUuid>`,describe:`Trigger a manual build for a specific trigger`,builder:e=>e.positional(`triggerUuid`,{type:`string`,description:`Trigger UUID.`,demandOption:!0}).option(`seed-repo-branch`,{type:`string`,description:`Git branch name.`}).option(`seed-repo-owner`,{type:`string`,description:`The seed_repo.owner field`}).option(`seed-repo-path`,{type:`string`,description:`The seed_repo.path field`}).option(`seed-repo-provider`,{type:`string`,description:`The seed_repo.provider field`,choices:[`github`]}).option(`seed-repo-repository`,{type:`string`,description:`The seed_repo.repository field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`seed-repo-branch`,`seed-repo-owner`,`seed-repo-path`,`seed-repo-provider`,`seed-repo-repository`].some(t=>e[t]!==void 0)){let t=[`seed-repo-branch`,`seed-repo-owner`,`seed-repo-path`,`seed-repo-provider`,`seed-repo-repository`].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 --seed_repo-* flag is set`)}return!0}),handler:async t=>{if(s(t.triggerUuid,`triggerUuid`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workers-builds triggers create-build`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/builds/triggers/${t.triggerUuid??`<triggerUuid>`}/builds`,pathParams:{triggerUuid:String(t.triggerUuid??``)},bodyKind:`json`,body:{seedRepoBranch:t.seedRepoBranch,seedRepoOwner:t.seedRepoOwner,seedRepoPath:t.seedRepoPath,seedRepoProvider:t.seedRepoProvider,seedRepoRepository:t.seedRepoRepository,body:t.body},validation:`passed`});return}let n=await a(t),i=t.local?f:await r(n);if(t.accountId=i,t.body){let e=l(t.body);u(await p(`Creating trigger`,async()=>n.post(`/accounts/${i}/builds/triggers/${t.triggerUuid}/builds`,{body:e})),{successLabel:`Created trigger`});return}let m={};t.seedRepoBranch!==void 0&&c(m,[`seed_repo`,`branch`],o(t.seedRepoBranch,`seedRepoBranch`,`text`)),t.seedRepoOwner!==void 0&&c(m,[`seed_repo`,`owner`],o(t.seedRepoOwner,`seedRepoOwner`,`text`)),t.seedRepoPath!==void 0&&c(m,[`seed_repo`,`path`],o(t.seedRepoPath,`seedRepoPath`,`text`)),t.seedRepoProvider!==void 0&&c(m,[`seed_repo`,`provider`],o(t.seedRepoProvider,`seedRepoProvider`,`text`)),t.seedRepoRepository!==void 0&&c(m,[`seed_repo`,`repository`],o(t.seedRepoRepository,`seedRepoRepository`,`text`)),u(await p(`Creating trigger`,async()=>n.post(`/accounts/${i}/builds/triggers/${t.triggerUuid}/builds`,{body:Object.keys(m).length>0?m:void 0})),{successLabel:`Created trigger`})}},P={command:`create`,describe:`Create a new CI/CD trigger`,builder:e=>e.option(`branch-excludes`,{type:`string`,array:!0,description:`The branch_excludes field`}).option(`branch-includes`,{type:`string`,array:!0,description:`The branch_includes field`}).option(`build-caching-enabled`,{type:`boolean`,description:`The build_caching_enabled field`,default:!1}).option(`build-command`,{type:`string`,description:`The build_command field`}).option(`build-token-uuid`,{type:`string`,description:`Build token UUID.`}).option(`deploy-command`,{type:`string`,description:`The deploy_command field`}).option(`external-script-id`,{type:`string`,description:`System-generated worker script tag.`}).option(`path-excludes`,{type:`string`,array:!0,description:`The path_excludes field`}).option(`path-includes`,{type:`string`,array:!0,description:`The path_includes field`}).option(`repo-connection-uuid`,{type:`string`,description:`Repository connection UUID.`}).option(`root-directory`,{type:`string`,description:`Root directory path.`}).option(`trigger-name`,{type:`string`,description:`The trigger_name 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)`}),handler:async n=>{if(n.dryRun){let t=e();t&&s(t,`accountId`),d({command:`cf workers-builds triggers create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/builds/triggers`,pathParams:{},bodyKind:`json`,body:{branchExcludes:n.branchExcludes,branchIncludes:n.branchIncludes,buildCachingEnabled:n.buildCachingEnabled,buildCommand:n.buildCommand,buildTokenUuid:n.buildTokenUuid,deployCommand:n.deployCommand,externalScriptId:n.externalScriptId,pathExcludes:n.pathExcludes,pathIncludes:n.pathIncludes,repoConnectionUuid:n.repoConnectionUuid,rootDirectory:n.rootDirectory,triggerName:n.triggerName,body:n.body},validation:`passed`});return}let i=await a(n),m=n.local?f:await r(i);if(n.accountId=m,n.body){let e=l(n.body);u(await p(`Creating trigger`,async()=>i.post(`/accounts/${m}/builds/triggers`,{body:e})),{successLabel:`Created trigger`});return}if(n.branchExcludes===void 0)throw Error(`--branch-excludes is required (or pass --body with this field set).`);if(n.branchIncludes===void 0)throw Error(`--branch-includes is required (or pass --body with this field set).`);if(n.buildCommand===void 0&&(n.buildCommand=await t(`build-command`,``)),n.buildTokenUuid===void 0&&(n.buildTokenUuid=await t(`build-token-uuid`,`Build token UUID.`)),n.deployCommand===void 0&&(n.deployCommand=await t(`deploy-command`,``)),n.externalScriptId===void 0&&(n.externalScriptId=await t(`external-script-id`,`System-generated worker script tag.`)),n.pathExcludes===void 0)throw Error(`--path-excludes is required (or pass --body with this field set).`);if(n.pathIncludes===void 0)throw Error(`--path-includes is required (or pass --body with this field set).`);n.repoConnectionUuid===void 0&&(n.repoConnectionUuid=await t(`repo-connection-uuid`,`Repository connection UUID.`)),n.rootDirectory===void 0&&(n.rootDirectory=await t(`root-directory`,`Root directory path.`)),n.triggerName===void 0&&(n.triggerName=await t(`trigger-name`,``));let h={};n.branchExcludes!==void 0&&c(h,[`branch_excludes`],n.branchExcludes),n.branchIncludes!==void 0&&c(h,[`branch_includes`],n.branchIncludes),n.buildCachingEnabled!==void 0&&c(h,[`build_caching_enabled`],n.buildCachingEnabled),n.buildCommand!==void 0&&c(h,[`build_command`],o(n.buildCommand,`buildCommand`,`text`)),n.buildTokenUuid!==void 0&&c(h,[`build_token_uuid`],o(n.buildTokenUuid,`buildTokenUuid`,`text`)),n.deployCommand!==void 0&&c(h,[`deploy_command`],o(n.deployCommand,`deployCommand`,`text`)),n.externalScriptId!==void 0&&c(h,[`external_script_id`],o(n.externalScriptId,`externalScriptId`,`text`)),n.pathExcludes!==void 0&&c(h,[`path_excludes`],n.pathExcludes),n.pathIncludes!==void 0&&c(h,[`path_includes`],n.pathIncludes),n.repoConnectionUuid!==void 0&&c(h,[`repo_connection_uuid`],o(n.repoConnectionUuid,`repoConnectionUuid`,`text`)),n.rootDirectory!==void 0&&c(h,[`root_directory`],o(n.rootDirectory,`rootDirectory`,`text`)),n.triggerName!==void 0&&c(h,[`trigger_name`],o(n.triggerName,`triggerName`,`text`)),u(await p(`Creating trigger`,async()=>i.post(`/accounts/${m}/builds/triggers`,{body:Object.keys(h).length>0?h:void 0})),{successLabel:`Created trigger`})}},F={command:`delete <triggerUuid>`,describe:`Remove a CI/CD trigger`,builder:e=>e.positional(`triggerUuid`,{type:`string`,description:`Trigger UUID.`,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}),handler:async t=>{if(s(t.triggerUuid,`triggerUuid`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workers-builds triggers delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/builds/triggers/${t.triggerUuid??`<triggerUuid>`}`,pathParams:{triggerUuid:String(t.triggerUuid??``)},bodyKind:`none`,validation:`passed`});return}let n=await a(t),o=t.local?f:await r(n);if(t.accountId=o,!await i(`trigger`,String(t.triggerUuid??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
5
|
-
`);return}u(await p(`Deleting trigger`,async()=>n.workersBuilds.triggers.delete(o,t.triggerUuid)),{successLabel:`Deleted trigger`})}},I={command:`delete <environmentVariableKey>`,describe:`Remove a specific environment variable from a trigger`,builder:e=>e.positional(`environmentVariableKey`,{type:`string`,description:`Environment variable key.`,demandOption:!0}).option(`trigger-uuid`,{type:`string`,description:`Trigger UUID.`,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}),handler:async t=>{if(s(t.environmentVariableKey,`environmentVariableKey`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workers-builds triggers environment-variables delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/builds/triggers/${t.triggerUuid??`<triggerUuid>`}/environment_variables/${t.environmentVariableKey??`<environmentVariableKey>`}`,pathParams:{triggerUuid:String(t.triggerUuid??``),environmentVariableKey:String(t.environmentVariableKey??``)},bodyKind:`none`,validation:`passed`});return}let n=await a(t),o=t.local?f:await r(n);if(t.accountId=o,!await i(`environment variable`,String(t.environmentVariableKey??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
6
|
-
`);return}u(await p(`Deleting environment variable`,async()=>n.workersBuilds.triggers.environmentVariables.delete(o,t.triggerUuid,t.environmentVariableKey)),{successLabel:`Deleted environment variable`})}},L={command:`list`,describe:`Get all environment variables for a trigger`,builder:e=>e.option(`trigger-uuid`,{type:`string`,description:`Trigger UUID.`,demandOption:!0}),handler:async e=>{let t=await a(e),n=e.local?f:await r(t);e.accountId=n,u(await p(`Loading environment variables`,async()=>t.workersBuilds.triggers.environmentVariables.list(n,e.triggerUuid)),{successLabel:`Loaded environment variables`})}},R={command:`upsert <triggerUuid>`,describe:`Create or update environment variables for a trigger`,builder:e=>e.positional(`triggerUuid`,{type:`string`,description:`Trigger UUID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}),handler:async t=>{if(s(t.triggerUuid,`triggerUuid`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workers-builds triggers environment-variables upsert`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/builds/triggers/${t.triggerUuid??`<triggerUuid>`}/environment_variables`,pathParams:{triggerUuid:String(t.triggerUuid??``)},bodyKind:`json`,body:{body:t.body},validation:`passed`});return}let n=await a(t),i=t.local?f:await r(n);if(t.accountId=i,t.body){let e=l(t.body);u(await p(`Updating environment variable`,async()=>n.patch(`/accounts/${i}/builds/triggers/${t.triggerUuid}/environment_variables`,{body:e})),{successLabel:`Updated environment variable`});return}u(await p(`Updating environment variable`,async()=>n.workersBuilds.triggers.environmentVariables.upsert(i,t.triggerUuid)),{successLabel:`Updated environment variable`})}},z={command:`environment-variables`,describe:`Triggers operations`,builder:e=>e.command(I).command(L).command(R).demandCommand(1),handler:()=>{}},B={command:`list`,describe:`Get all triggers for a specific worker script`,builder:e=>e.option(`external-script-id`,{type:`string`,description:`System-generated worker script tag.`,demandOption:!0}),handler:async e=>{let t=await a(e),n=e.local?f:await r(t);e.accountId=n,u(await p(`Loading triggers`,async()=>t.workersBuilds.triggers.list(n,e.externalScriptId)),{successLabel:`Loaded triggers`})}},V={command:`purge-cache <triggerUuid>`,describe:`Clear the build cache for a specific trigger`,builder:e=>e.positional(`triggerUuid`,{type:`string`,description:`Trigger UUID.`,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}),handler:async t=>{if(s(t.triggerUuid,`triggerUuid`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workers-builds triggers purge-cache`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/builds/triggers/${t.triggerUuid??`<triggerUuid>`}/purge_build_cache`,pathParams:{triggerUuid:String(t.triggerUuid??``)},bodyKind:`none`,validation:`passed`});return}let n=await a(t),o=t.local?f:await r(n);if(t.accountId=o,!await i(`trigger`,String(t.triggerUuid??``),{force:!!t.force,message:`This operation wipes the workers-build cache.`})){process.stderr.write(`Aborted.
|
|
7
|
-
`);return}u(await p(`Deleting trigger`,async()=>n.workersBuilds.triggers.purgeCache(o,t.triggerUuid)),{successLabel:`Deleted trigger`})}},H={command:`update <triggerUuid>`,describe:`Update an existing CI/CD trigger`,builder:e=>e.positional(`triggerUuid`,{type:`string`,description:`Trigger UUID.`,demandOption:!0}).option(`branch-excludes`,{type:`string`,array:!0,description:`The branch_excludes field`}).option(`branch-includes`,{type:`string`,array:!0,description:`The branch_includes field`}).option(`build-caching-enabled`,{type:`boolean`,description:`The build_caching_enabled field`,default:!1}).option(`build-command`,{type:`string`,description:`The build_command field`}).option(`build-token-uuid`,{type:`string`,description:`Build token UUID.`}).option(`deploy-command`,{type:`string`,description:`The deploy_command field`}).option(`path-excludes`,{type:`string`,array:!0,description:`The path_excludes field`}).option(`path-includes`,{type:`string`,array:!0,description:`The path_includes field`}).option(`root-directory`,{type:`string`,description:`Root directory path.`}).option(`trigger-name`,{type:`string`,description:`The trigger_name 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)`}),handler:async t=>{if(s(t.triggerUuid,`triggerUuid`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workers-builds triggers update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/builds/triggers/${t.triggerUuid??`<triggerUuid>`}`,pathParams:{triggerUuid:String(t.triggerUuid??``)},bodyKind:`json`,body:{branchExcludes:t.branchExcludes,branchIncludes:t.branchIncludes,buildCachingEnabled:t.buildCachingEnabled,buildCommand:t.buildCommand,buildTokenUuid:t.buildTokenUuid,deployCommand:t.deployCommand,pathExcludes:t.pathExcludes,pathIncludes:t.pathIncludes,rootDirectory:t.rootDirectory,triggerName:t.triggerName,body:t.body},validation:`passed`});return}let n=await a(t),i=t.local?f:await r(n);if(t.accountId=i,t.body){let e=l(t.body);u(await p(`Updating trigger`,async()=>n.patch(`/accounts/${i}/builds/triggers/${t.triggerUuid}`,{body:e})),{successLabel:`Updated trigger`});return}let m={};t.branchExcludes!==void 0&&c(m,[`branch_excludes`],t.branchExcludes),t.branchIncludes!==void 0&&c(m,[`branch_includes`],t.branchIncludes),t.buildCachingEnabled!==void 0&&c(m,[`build_caching_enabled`],t.buildCachingEnabled),t.buildCommand!==void 0&&c(m,[`build_command`],o(t.buildCommand,`buildCommand`,`text`)),t.buildTokenUuid!==void 0&&c(m,[`build_token_uuid`],o(t.buildTokenUuid,`buildTokenUuid`,`text`)),t.deployCommand!==void 0&&c(m,[`deploy_command`],o(t.deployCommand,`deployCommand`,`text`)),t.pathExcludes!==void 0&&c(m,[`path_excludes`],t.pathExcludes),t.pathIncludes!==void 0&&c(m,[`path_includes`],t.pathIncludes),t.rootDirectory!==void 0&&c(m,[`root_directory`],o(t.rootDirectory,`rootDirectory`,`text`)),t.triggerName!==void 0&&c(m,[`trigger_name`],o(t.triggerName,`triggerName`,`text`)),u(await p(`Updating trigger`,async()=>n.patch(`/accounts/${i}/builds/triggers/${t.triggerUuid}`,{body:Object.keys(m).length>0?m:void 0})),{successLabel:`Updated trigger`})}},U={command:`triggers`,describe:`Triggers operations`,builder:e=>e.command(P).command(N).command(F).command(B).command(V).command(H).command(z).demandCommand(1),handler:()=>{}},W={command:`workers-builds`,describe:`Automated build and deployment pipeline for Workers — track builds, logs, and repo connections`,builder:e=>e.command(b).command(x).command(S).command(y).command(O).command(M).command(U).demandCommand(1),handler:()=>{}};export{W as default};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{d as e,h as t,m as n,o as r,p as i,t as a}from"./auth-BHD_B2p9.mjs";import{n as o,r as s}from"./input-validation-BpVQi9rR.mjs";import{n as c,t as l}from"./body-parser-iA3vRFmh.mjs";import{t as u}from"./output-CqGQp2r6.mjs";import{t as d}from"./dry-run-FV0pZwdg.mjs";import{t as f}from"./local-OqhVQbv0.mjs";import{t as p}from"./progress-5sHFvwez.mjs";const m={command:`delete <workflowName>`,describe:`Deletes a Workflow. This only deletes the Workflow and does not delete or modify any Worker associated to this Workflow or bounded to it.`,builder:e=>e.positional(`workflowName`,{type:`string`,description:`Workflow name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}),handler:async t=>{if(s(t.workflowName,`workflowName`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workflows delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workflows/${t.workflowName??`<workflowName>`}`,pathParams:{workflowName:String(t.workflowName??``)},bodyKind:`none`,validation:`passed`});return}let n=await a(t),o=t.local?f:await r(n);if(t.accountId=o,!await i(`workflow`,String(t.workflowName??``),{force:!!t.force})){process.stderr.write(`Aborted.
|
|
3
|
-
`);return}u(await p(`Deleting workflow`,async()=>n.workflows.delete(t.workflowName,o)),{successLabel:`Deleted workflow`})}},h={command:`get <workflowName>`,describe:`Retrieves configuration and metadata for a specific workflow.`,builder:e=>e.positional(`workflowName`,{type:`string`,description:`Workflow name`,demandOption:!0}),handler:async e=>{s(e.workflowName,`workflowName`);let t=await a(e),n=e.local?f:await r(t);e.accountId=n,u(await p(`Loading workflow`,async()=>t.workflows.get(e.workflowName,n)),{successLabel:`Loaded workflow`})}},g={command:`batch-terminate <workflowName>`,describe:`Terminates multiple workflow instances in a single batch operation.`,builder:e=>e.positional(`workflowName`,{type:`string`,description:`Workflow name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}),handler:async t=>{if(s(t.workflowName,`workflowName`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workflows instances batch-terminate`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workflows/${t.workflowName??`<workflowName>`}/instances/batch/terminate`,pathParams:{workflowName:String(t.workflowName??``)},bodyKind:`json`,body:{body:t.body},validation:`passed`});return}let n=await a(t),o=t.local?f:await r(n);if(t.accountId=o,!await i(`instance`,String(t.workflowName??``),{force:!!t.force,message:`This operation terminates running instances in bulk.`})){process.stderr.write(`Aborted.
|
|
4
|
-
`);return}if(t.body){let e=l(t.body);if(Array.isArray(e)&&e.length>100){let r=Math.ceil(e.length/100),i=null;for(let a=0;a<e.length;a+=100){let s=e.slice(a,a+100);i=await p(`Deleting instance: batch ${Math.floor(a/100)+1}/${r}`,async()=>n.post(`/accounts/${o}/workflows/${t.workflowName}/instances/batch/terminate`,{body:s}))}u(i,{successLabel:`Deleted instance`});return}u(await p(`Deleting instance`,async()=>n.post(`/accounts/${o}/workflows/${t.workflowName}/instances/batch/terminate`,{body:e})),{successLabel:`Deleted instance`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},_={command:`bulk`,describe:`Creates multiple workflow instances in a single batch operation.`,builder:e=>e.option(`workflow-name`,{type:`string`,description:`Workflow name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}),handler:async t=>{if(t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workflows instances bulk`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workflows/${t.workflowName??`<workflowName>`}/instances/batch`,pathParams:{workflowName:String(t.workflowName??``)},bodyKind:`json`,body:{body:t.body},validation:`passed`});return}let n=await a(t),i=t.local?f:await r(n);if(t.accountId=i,t.body){let e=l(t.body);if(Array.isArray(e)&&e.length>100){let r=Math.ceil(e.length/100),a=null;for(let o=0;o<e.length;o+=100){let s=e.slice(o,o+100);a=await p(`Creating instances: batch ${Math.floor(o/100)+1}/${r}`,async()=>n.post(`/accounts/${i}/workflows/${t.workflowName}/instances/batch`,{body:s}))}u(a,{successLabel:`Created instances`});return}u(await p(`Creating instances`,async()=>n.post(`/accounts/${i}/workflows/${t.workflowName}/instances/batch`,{body:e})),{successLabel:`Created instances`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},v={command:`create <workflowName>`,describe:`Creates a new instance of a workflow, starting its execution.`,builder:e=>e.positional(`workflowName`,{type:`string`,description:`Workflow name`,demandOption:!0}).option(`instance-id`,{type:`string`,description:`The instance_id 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)`}),handler:async t=>{if(s(t.workflowName,`workflowName`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workflows instances create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workflows/${t.workflowName??`<workflowName>`}/instances`,pathParams:{workflowName:String(t.workflowName??``)},bodyKind:`json`,body:{instanceId:t.instanceId,body:t.body},validation:`passed`});return}let n=await a(t),i=t.local?f:await r(n);if(t.accountId=i,t.body){let e=l(t.body);u(await p(`Creating instance`,async()=>n.post(`/accounts/${i}/workflows/${t.workflowName}/instances`,{body:e})),{successLabel:`Created instance`});return}let m={};t.instanceId!==void 0&&c(m,[`instance_id`],o(t.instanceId,`instanceId`,`text`)),u(await p(`Creating instance`,async()=>n.post(`/accounts/${i}/workflows/${t.workflowName}/instances`,{body:Object.keys(m).length>0?m:void 0})),{successLabel:`Created instance`})}},y={command:`create <eventType>`,describe:`Sends an event to a running workflow instance to trigger state transitions.`,builder:e=>e.positional(`eventType`,{type:`string`,description:`Event type`,demandOption:!0}).option(`workflow-name`,{type:`string`,description:`Workflow name`,demandOption:!0}).option(`instance-id`,{type:`string`,description:`Instance ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}),handler:async t=>{if(s(t.eventType,`eventType`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workflows instances events create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workflows/${t.workflowName??`<workflowName>`}/instances/${t.instanceId??`<instanceId>`}/events/${t.eventType??`<eventType>`}`,pathParams:{workflowName:String(t.workflowName??``),instanceId:String(t.instanceId??``),eventType:String(t.eventType??``)},bodyKind:`json`,body:{body:t.body},validation:`passed`});return}let n=await a(t),i=t.local?f:await r(n);if(t.accountId=i,t.body){let e=l(t.body);u(await p(`Creating event`,async()=>n.post(`/accounts/${i}/workflows/${t.workflowName}/instances/${t.instanceId}/events/${t.eventType}`,{body:e})),{successLabel:`Created event`});return}u(await p(`Creating event`,async()=>n.workflows.instances.events.create(t.workflowName,t.instanceId,t.eventType,i)),{successLabel:`Created event`})}},b={command:`events`,describe:`Workflow instance operations`,builder:e=>e.command(y).demandCommand(1),handler:()=>{}},x={command:`get <instanceId>`,describe:`Retrieves logs and execution status for a specific workflow instance.`,builder:e=>e.positional(`instanceId`,{type:`string`,description:`Instance ID`,demandOption:!0}).option(`workflow-name`,{type:`string`,description:`Workflow name`,demandOption:!0}).option(`simple`,{type:`string`,description:`When true, omits step details and returns only metadata with step_count.`,choices:[`true`,`false`]}).option(`order`,{type:`string`,description:`Step ordering: "asc" (default, oldest first) or "desc" (newest first).`,choices:[`asc`,`desc`]}),handler:async e=>{s(e.instanceId,`instanceId`);let t={};e.simple!==void 0&&(t.simple=e.simple),e.order!==void 0&&(t.order=e.order);let n=await a(e),i=e.local?f:await r(n);e.accountId=i,u(await p(`Loading instance`,async()=>n.workflows.instances.get(e.workflowName,e.instanceId,i,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded instance`})}},S={command:`list`,describe:`Lists all instances of a workflow with their execution status.`,builder:e=>e.option(`workflow-name`,{type:`string`,description:`Workflow name`,demandOption:!0}).option(`page`,{type:`number`,description:"Deprecated: use `cursor` for pagination instead."}).option(`per-page`,{type:`number`,description:`Per page`}).option(`cursor`,{type:`string`,description:"Opaque token for cursor-based pagination. Mutually exclusive with `page`."}).option(`direction`,{type:`string`,description:`Defines the direction for cursor-based pagination.`,choices:[`asc`,`desc`]}).option(`status`,{type:`string`,description:`Status`,choices:[`queued`,`running`,`paused`,`errored`,`terminated`,`complete`,`waitingForPause`,`waiting`]}).option(`date-start`,{type:`string`,description:`Accepts ISO 8601 with no timezone offsets and in UTC.`}).option(`date-end`,{type:`string`,description:`Accepts ISO 8601 with no timezone offsets and in UTC.`}),handler:async e=>{let t={};e.page!==void 0&&(t.page=e.page),e.perPage!==void 0&&(t.per_page=e.perPage),e.cursor!==void 0&&(t.cursor=e.cursor),e.direction!==void 0&&(t.direction=e.direction),e.status!==void 0&&(t.status=e.status),e.dateStart!==void 0&&(t.date_start=e.dateStart),e.dateEnd!==void 0&&(t.date_end=e.dateEnd);let n=await a(e),i=e.local?f:await r(n);e.accountId=i,u(await p(`Loading instances`,async()=>n.workflows.instances.list(e.workflowName,i,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded instances`})}},C={command:`status-terminate <workflowName>`,describe:`Gets the status of a bulk workflow instance termination job.`,builder:e=>e.positional(`workflowName`,{type:`string`,description:`Workflow name`,demandOption:!0}),handler:async e=>{s(e.workflowName,`workflowName`);let t=await a(e),n=e.local?f:await r(t);e.accountId=n,u(await p(`Loading instance`,async()=>t.workflows.instances.statusTerminate(e.workflowName,n)),{successLabel:`Loaded instance`})}},w={command:`edit <instanceId>`,describe:`Changes the execution status of a workflow instance (e.g., pause, resume, terminate).`,builder:e=>e.positional(`instanceId`,{type:`string`,description:`Instance ID`,demandOption:!0}).option(`workflow-name`,{type:`string`,description:`Workflow name`,demandOption:!0}).option(`from-count`,{type:`number`,description:`The from.count field`}).option(`from-name`,{type:`string`,description:`The from.name field`}).option(`from-type`,{type:`string`,description:`The from.type field`,choices:[`do`,`sleep`,`waitForEvent`]}).option(`status`,{type:`string`,description:`Apply action to instance.`,choices:[`resume`,`pause`,`terminate`,`restart`]}).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([`from-count`,`from-name`,`from-type`].some(t=>e[t]!==void 0)){let t=[`from-name`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --from-* flag is set`)}return!0}),handler:async t=>{if(s(t.instanceId,`instanceId`),t.dryRun){let n=e();n&&s(n,`accountId`),d({command:`cf workflows instances status edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${n??`<account-id>`}/workflows/${t.workflowName??`<workflowName>`}/instances/${t.instanceId??`<instanceId>`}/status`,pathParams:{workflowName:String(t.workflowName??``),instanceId:String(t.instanceId??``)},bodyKind:`json`,body:{fromCount:t.fromCount,fromName:t.fromName,fromType:t.fromType,status:t.status,body:t.body},validation:`passed`});return}let i=await a(t),m=t.local?f:await r(i);if(t.accountId=m,t.body){let e=l(t.body);u(await p(`Updating status`,async()=>i.patch(`/accounts/${m}/workflows/${t.workflowName}/instances/${t.instanceId}/status`,{body:e})),{successLabel:`Updated status`});return}t.status===void 0&&(t.status=await n(`status`,`Apply action to instance.`,[`resume`,`pause`,`terminate`,`restart`]));let h={};t.fromCount!==void 0&&c(h,[`from`,`count`],t.fromCount),t.fromName!==void 0&&c(h,[`from`,`name`],o(t.fromName,`fromName`,`text`)),t.fromType!==void 0&&c(h,[`from`,`type`],o(t.fromType,`fromType`,`text`)),t.status!==void 0&&c(h,[`status`],o(t.status,`status`,`text`)),u(await p(`Updating status`,async()=>i.patch(`/accounts/${m}/workflows/${t.workflowName}/instances/${t.instanceId}/status`,{body:Object.keys(h).length>0?h:void 0})),{successLabel:`Updated status`})}},T={command:`status`,describe:`Workflow instance operations`,builder:e=>e.command(w).demandCommand(1),handler:()=>{}},E={command:`instances`,describe:`Workflow instance operations`,builder:e=>e.command(g).command(_).command(v).command(x).command(S).command(C).command(b).command(T).demandCommand(1),handler:()=>{}},D={command:`list`,describe:`Lists all workflows configured for the account.`,builder:e=>e.option(`per-page`,{type:`number`,description:`Per page`}).option(`page`,{type:`number`,description:`Page`}).option(`search`,{type:`string`,description:"Allows filtering workflows` name."}),handler:async e=>{let t={};e.perPage!==void 0&&(t.per_page=e.perPage),e.page!==void 0&&(t.page=e.page),e.search!==void 0&&(t.search=e.search);let n=await a(e),i=e.local?f:await r(n);e.accountId=i,u(await p(`Loading workflows`,async()=>n.workflows.list(i,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded workflows`})}},O={command:`update <workflowName>`,describe:`Creates a new workflow or updates an existing workflow definition.`,builder:e=>e.positional(`workflowName`,{type:`string`,description:`Workflow name`,demandOption:!0}).option(`class-name`,{type:`string`,description:`The class_name field`}).option(`limits-steps`,{type:`number`,description:`The limits.steps field`}).option(`script-name`,{type:`string`,description:`The script_name 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)`}),handler:async n=>{if(s(n.workflowName,`workflowName`),n.dryRun){let t=e();t&&s(t,`accountId`),d({command:`cf workflows update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t??`<account-id>`}/workflows/${n.workflowName??`<workflowName>`}`,pathParams:{workflowName:String(n.workflowName??``)},bodyKind:`json`,body:{className:n.className,limitsSteps:n.limitsSteps,scriptName:n.scriptName,body:n.body},validation:`passed`});return}let i=await a(n),m=n.local?f:await r(i);if(n.accountId=m,n.body){let e=l(n.body);u(await p(`Updating workflow`,async()=>i.put(`/accounts/${m}/workflows/${n.workflowName}`,{body:e})),{successLabel:`Updated workflow`});return}n.className===void 0&&(n.className=await t(`class-name`,``)),n.scriptName===void 0&&(n.scriptName=await t(`script-name`,``));let h={};n.className!==void 0&&c(h,[`class_name`],o(n.className,`className`,`text`)),n.limitsSteps!==void 0&&c(h,[`limits`,`steps`],n.limitsSteps),n.scriptName!==void 0&&c(h,[`script_name`],o(n.scriptName,`scriptName`,`text`)),u(await p(`Updating workflow`,async()=>i.put(`/accounts/${m}/workflows/${n.workflowName}`,{body:Object.keys(h).length>0?h:void 0})),{successLabel:`Updated workflow`})}},k={command:`dag <versionId>`,describe:`Retrieves the directed acyclic graph (DAG) representation of a workflow version.`,builder:e=>e.positional(`versionId`,{type:`string`,description:`Version ID`,demandOption:!0}).option(`workflow-name`,{type:`string`,description:`Workflow name`,demandOption:!0}),handler:async e=>{s(e.versionId,`versionId`);let t=await a(e),n=e.local?f:await r(t);e.accountId=n,u(await p(`Loading version`,async()=>t.workflows.versions.dag(e.workflowName,e.versionId,n)),{successLabel:`Loaded version`})}},A={command:`get <versionId>`,describe:`Retrieves details for a specific deployed workflow version.`,builder:e=>e.positional(`versionId`,{type:`string`,description:`Version ID`,demandOption:!0}).option(`workflow-name`,{type:`string`,description:`Workflow name`,demandOption:!0}),handler:async e=>{s(e.versionId,`versionId`);let t=await a(e),n=e.local?f:await r(t);e.accountId=n,u(await p(`Loading version`,async()=>t.workflows.versions.get(e.workflowName,e.versionId,n)),{successLabel:`Loaded version`})}},j={command:`graph <versionId>`,describe:`Retrieves the graph visualization of a workflow version.`,builder:e=>e.positional(`versionId`,{type:`string`,description:`Version ID`,demandOption:!0}).option(`workflow-name`,{type:`string`,description:`Workflow name`,demandOption:!0}),handler:async e=>{s(e.versionId,`versionId`);let t=await a(e),n=e.local?f:await r(t);e.accountId=n,u(await p(`Loading version`,async()=>t.workflows.versions.graph(e.workflowName,e.versionId,n)),{successLabel:`Loaded version`})}},M={command:`list`,describe:`Lists all deployed versions of a workflow.`,builder:e=>e.option(`workflow-name`,{type:`string`,description:`Workflow name`,demandOption:!0}).option(`per-page`,{type:`number`,description:`Per page`}).option(`page`,{type:`number`,description:`Page`}),handler:async e=>{let t={};e.perPage!==void 0&&(t.per_page=e.perPage),e.page!==void 0&&(t.page=e.page);let n=await a(e),i=e.local?f:await r(n);e.accountId=i,u(await p(`Loading versions`,async()=>n.workflows.versions.list(e.workflowName,i,Object.keys(t).length>0?t:void 0)),{successLabel:`Loaded versions`})}},N={command:`versions`,describe:`Workflow version operations`,builder:e=>e.command(k).command(A).command(j).command(M).demandCommand(1),handler:()=>{}},P={command:`workflows`,describe:`Durable, multi-step workflows that run on Workers with automatic retries and state persistence`,builder:e=>e.command(m).command(h).command(D).command(O).command(E).command(N).demandCommand(1),handler:()=>{}};export{P as default};
|
package/dist/zaraz-C0iJimA4.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{h as e,t,u as n}from"./auth-BHD_B2p9.mjs";import{n as r}from"./input-validation-BpVQi9rR.mjs";import{n as i,t as a}from"./body-parser-iA3vRFmh.mjs";import{t as o}from"./output-CqGQp2r6.mjs";import{t as s}from"./dry-run-FV0pZwdg.mjs";import{t as c}from"./progress-5sHFvwez.mjs";const l={command:`get`,describe:`Gets latest Zaraz configuration for a zone. It can be preview or published configuration, whichever was the last updated. Secret variables values will not be included.`,builder:e=>e,handler:async e=>{let r=await t(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading config`,async()=>r.zaraz.config.get(i)),{successLabel:`Loaded config`})}},u={command:`update`,describe:`Updates Zaraz configuration for a zone.`,builder:e=>e.option(`analytics-default-purpose`,{type:`string`,description:`Consent purpose assigned to Monitoring.`}).option(`analytics-enabled`,{type:`boolean`,description:`Whether Advanced Monitoring reports are enabled.`}).option(`analytics-session-exp-time`,{type:`number`,description:`Session expiration time (seconds).`}).option(`consent-company-email`,{type:`string`,description:`The consent.companyEmail field`}).option(`consent-company-name`,{type:`string`,description:`The consent.companyName field`}).option(`consent-company-street-address`,{type:`string`,description:`The consent.companyStreetAddress field`}).option(`consent-consent-modal-intro-html`,{type:`string`,description:`The consent.consentModalIntroHTML field`}).option(`consent-cookie-name`,{type:`string`,description:`The consent.cookieName field`}).option(`consent-custom-css`,{type:`string`,description:`The consent.customCSS field`}).option(`consent-custom-intro-disclaimer-dismissed`,{type:`boolean`,description:`The consent.customIntroDisclaimerDismissed field`}).option(`consent-default-language`,{type:`string`,description:`The consent.defaultLanguage field`}).option(`consent-enabled`,{type:`boolean`,description:`The consent.enabled field`,default:!1}).option(`consent-hide-modal`,{type:`boolean`,description:`The consent.hideModal field`}).option(`consent-tcf-compliant`,{type:`boolean`,description:`The consent.tcfCompliant field`}).option(`data-layer`,{type:`boolean`,description:`Data layer compatibility mode enabled.`}).option(`debug-key`,{type:`string`,description:`The key for Zaraz debug mode.`}).option(`history-change`,{type:`boolean`,description:`Single Page Application support enabled.`}).option(`settings-auto-inject-script`,{type:`boolean`,description:`Automatic injection of Zaraz scripts enabled.`}).option(`settings-context-enricher-escaped-worker-name`,{type:`string`,description:`The settings.contextEnricher.escapedWorkerName field`}).option(`settings-context-enricher-worker-tag`,{type:`string`,description:`The settings.contextEnricher.workerTag field`}).option(`settings-cookie-domain`,{type:`string`,description:`The domain Zaraz will use for writing and reading its cookies.`}).option(`settings-ecommerce`,{type:`boolean`,description:`Ecommerce API enabled.`}).option(`settings-events-api-path`,{type:`string`,description:`Custom endpoint for server-side track events.`}).option(`settings-hide-external-referer`,{type:`boolean`,description:`Hiding external referrer URL enabled.`}).option(`settings-hide-ipaddress`,{type:`boolean`,description:`Trimming IP address enabled.`}).option(`settings-hide-query-params`,{type:`boolean`,description:`Removing URL query params enabled.`}).option(`settings-hide-user-agent`,{type:`boolean`,description:`Removing sensitive data from User Agent string enabled.`}).option(`settings-init-path`,{type:`string`,description:`Custom endpoint for Zaraz init script.`}).option(`settings-inject-iframes`,{type:`boolean`,description:`Injection of Zaraz scripts into iframes enabled.`}).option(`settings-mc-root-path`,{type:`string`,description:`Custom path for Managed Components server functionalities.`}).option(`settings-script-path`,{type:`string`,description:`Custom endpoint for Zaraz main script.`}).option(`settings-track-path`,{type:`string`,description:`Custom endpoint for Zaraz tracking requests.`}).option(`zaraz-version`,{type:`number`,description:`Zaraz internal version of the config.`}).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([`consent-company-email`,`consent-company-name`,`consent-company-street-address`,`consent-consent-modal-intro-html`,`consent-cookie-name`,`consent-custom-css`,`consent-custom-intro-disclaimer-dismissed`,`consent-default-language`,`consent-enabled`,`consent-hide-modal`,`consent-tcf-compliant`].some(t=>e[t]!==void 0)){let t=[`consent-enabled`].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 --consent-* flag is set`)}return!0}),handler:async l=>{if(l.dryRun){s({command:`cf zaraz config update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${l.zoneId??`<zoneId>`}/settings/zaraz/config`,pathParams:{zoneId:String(l.zoneId??``)},bodyKind:`json`,body:{analyticsDefaultPurpose:l.analyticsDefaultPurpose,analyticsEnabled:l.analyticsEnabled,analyticsSessionExpTime:l.analyticsSessionExpTime,consentCompanyEmail:l.consentCompanyEmail,consentCompanyName:l.consentCompanyName,consentCompanyStreetAddress:l.consentCompanyStreetAddress,consentConsentModalIntroHtml:l.consentConsentModalIntroHtml,consentCookieName:l.consentCookieName,consentCustomCss:l.consentCustomCss,consentCustomIntroDisclaimerDismissed:l.consentCustomIntroDisclaimerDismissed,consentDefaultLanguage:l.consentDefaultLanguage,consentEnabled:l.consentEnabled,consentHideModal:l.consentHideModal,consentTcfCompliant:l.consentTcfCompliant,dataLayer:l.dataLayer,debugKey:l.debugKey,historyChange:l.historyChange,settingsAutoInjectScript:l.settingsAutoInjectScript,settingsContextEnricherEscapedWorkerName:l.settingsContextEnricherEscapedWorkerName,settingsContextEnricherWorkerTag:l.settingsContextEnricherWorkerTag,settingsCookieDomain:l.settingsCookieDomain,settingsEcommerce:l.settingsEcommerce,settingsEventsApiPath:l.settingsEventsApiPath,settingsHideExternalReferer:l.settingsHideExternalReferer,settingsHideIpaddress:l.settingsHideIpaddress,settingsHideQueryParams:l.settingsHideQueryParams,settingsHideUserAgent:l.settingsHideUserAgent,settingsInitPath:l.settingsInitPath,settingsInjectIframes:l.settingsInjectIframes,settingsMcRootPath:l.settingsMcRootPath,settingsScriptPath:l.settingsScriptPath,settingsTrackPath:l.settingsTrackPath,zarazVersion:l.zarazVersion,body:l.body},validation:`passed`});return}let u=await t(l);if(l.zoneId=await n({zone:l.zone},u,{quiet:l.quiet}),l.body){let e=a(l.body);o(await c(`Updating config`,async()=>u.put(`/zones/${l.zoneId}/settings/zaraz/config`,{body:e})),{successLabel:`Updated config`});return}if(l.dataLayer===void 0)throw Error(`--data-layer is required (or pass --body with this field set).`);if(l.debugKey===void 0&&(l.debugKey=await e(`debug-key`,`The key for Zaraz debug mode.`)),l.settingsAutoInjectScript===void 0)throw Error(`--settings-auto-inject-script is required (or pass --body with this field set).`);if(l.settingsContextEnricherEscapedWorkerName===void 0&&(l.settingsContextEnricherEscapedWorkerName=await e(`settings-context-enricher-escaped-worker-name`,``)),l.settingsContextEnricherWorkerTag===void 0&&(l.settingsContextEnricherWorkerTag=await e(`settings-context-enricher-worker-tag`,``)),l.zarazVersion===void 0)throw Error(`--zaraz-version is required (or pass --body with this field set).`);let d={};l.analyticsDefaultPurpose!==void 0&&i(d,[`analytics`,`defaultPurpose`],r(l.analyticsDefaultPurpose,`analyticsDefaultPurpose`,`text`)),l.analyticsEnabled!==void 0&&i(d,[`analytics`,`enabled`],l.analyticsEnabled),l.analyticsSessionExpTime!==void 0&&i(d,[`analytics`,`sessionExpTime`],l.analyticsSessionExpTime),l.consentCompanyEmail!==void 0&&i(d,[`consent`,`companyEmail`],r(l.consentCompanyEmail,`consentCompanyEmail`,`text`)),l.consentCompanyName!==void 0&&i(d,[`consent`,`companyName`],r(l.consentCompanyName,`consentCompanyName`,`text`)),l.consentCompanyStreetAddress!==void 0&&i(d,[`consent`,`companyStreetAddress`],r(l.consentCompanyStreetAddress,`consentCompanyStreetAddress`,`text`)),l.consentConsentModalIntroHtml!==void 0&&i(d,[`consent`,`consentModalIntroHTML`],r(l.consentConsentModalIntroHtml,`consentConsentModalIntroHtml`,`text`)),l.consentCookieName!==void 0&&i(d,[`consent`,`cookieName`],r(l.consentCookieName,`consentCookieName`,`text`)),l.consentCustomCss!==void 0&&i(d,[`consent`,`customCSS`],r(l.consentCustomCss,`consentCustomCss`,`text`)),l.consentCustomIntroDisclaimerDismissed!==void 0&&i(d,[`consent`,`customIntroDisclaimerDismissed`],l.consentCustomIntroDisclaimerDismissed),l.consentDefaultLanguage!==void 0&&i(d,[`consent`,`defaultLanguage`],r(l.consentDefaultLanguage,`consentDefaultLanguage`,`text`)),l.consentEnabled!==void 0&&i(d,[`consent`,`enabled`],l.consentEnabled),l.consentHideModal!==void 0&&i(d,[`consent`,`hideModal`],l.consentHideModal),l.consentTcfCompliant!==void 0&&i(d,[`consent`,`tcfCompliant`],l.consentTcfCompliant),l.dataLayer!==void 0&&i(d,[`dataLayer`],l.dataLayer),l.debugKey!==void 0&&i(d,[`debugKey`],r(l.debugKey,`debugKey`,`text`)),l.historyChange!==void 0&&i(d,[`historyChange`],l.historyChange),l.settingsAutoInjectScript!==void 0&&i(d,[`settings`,`autoInjectScript`],l.settingsAutoInjectScript),l.settingsContextEnricherEscapedWorkerName!==void 0&&i(d,[`settings`,`contextEnricher`,`escapedWorkerName`],r(l.settingsContextEnricherEscapedWorkerName,`settingsContextEnricherEscapedWorkerName`,`text`)),l.settingsContextEnricherWorkerTag!==void 0&&i(d,[`settings`,`contextEnricher`,`workerTag`],r(l.settingsContextEnricherWorkerTag,`settingsContextEnricherWorkerTag`,`text`)),l.settingsCookieDomain!==void 0&&i(d,[`settings`,`cookieDomain`],r(l.settingsCookieDomain,`settingsCookieDomain`,`text`)),l.settingsEcommerce!==void 0&&i(d,[`settings`,`ecommerce`],l.settingsEcommerce),l.settingsEventsApiPath!==void 0&&i(d,[`settings`,`eventsApiPath`],r(l.settingsEventsApiPath,`settingsEventsApiPath`,`text`)),l.settingsHideExternalReferer!==void 0&&i(d,[`settings`,`hideExternalReferer`],l.settingsHideExternalReferer),l.settingsHideIpaddress!==void 0&&i(d,[`settings`,`hideIPAddress`],l.settingsHideIpaddress),l.settingsHideQueryParams!==void 0&&i(d,[`settings`,`hideQueryParams`],l.settingsHideQueryParams),l.settingsHideUserAgent!==void 0&&i(d,[`settings`,`hideUserAgent`],l.settingsHideUserAgent),l.settingsInitPath!==void 0&&i(d,[`settings`,`initPath`],r(l.settingsInitPath,`settingsInitPath`,`text`)),l.settingsInjectIframes!==void 0&&i(d,[`settings`,`injectIframes`],l.settingsInjectIframes),l.settingsMcRootPath!==void 0&&i(d,[`settings`,`mcRootPath`],r(l.settingsMcRootPath,`settingsMcRootPath`,`text`)),l.settingsScriptPath!==void 0&&i(d,[`settings`,`scriptPath`],r(l.settingsScriptPath,`settingsScriptPath`,`text`)),l.settingsTrackPath!==void 0&&i(d,[`settings`,`trackPath`],r(l.settingsTrackPath,`settingsTrackPath`,`text`)),l.zarazVersion!==void 0&&i(d,[`zarazVersion`],l.zarazVersion),o(await c(`Updating config`,async()=>u.put(`/zones/${l.zoneId}/settings/zaraz/config`,{body:Object.keys(d).length>0?d:void 0})),{successLabel:`Updated config`})}},d={command:`config`,describe:`Full Zaraz configuration including tools, triggers, and variables for the zone`,builder:e=>e.command(l).command(u).demandCommand(1),handler:()=>{}},f={command:`get`,describe:`Gets default Zaraz configuration for a zone.`,builder:e=>e,handler:async e=>{let r=await t(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading default`,async()=>r.zaraz.default.get(i)),{successLabel:`Loaded default`})}},p={command:`default`,describe:`Default Zaraz configuration template used as a starting point for new zones`,builder:e=>e.command(f).demandCommand(1),handler:()=>{}},m={command:`get`,describe:`Exports full current published Zaraz configuration for a zone, secret variables included.`,builder:e=>e,handler:async e=>{let r=await t(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading export`,async()=>r.zaraz.export.get(i)),{successLabel:`Loaded export`})}},h={command:`export`,describe:`Export the current Zaraz configuration as a portable JSON document`,builder:e=>e.command(m).demandCommand(1),handler:()=>{}},g={command:`get`,describe:`Gets a history of published Zaraz configurations by ID(s) for a zone.`,builder:e=>e.option(`ids`,{type:`string`,description:`Comma separated list of Zaraz configuration IDs.`,demandOption:!0}),handler:async e=>{let r={};e.ids!==void 0&&(r.ids=e.ids);let i=await t(e),a=await n({zone:e.zone},i,{quiet:e.quiet});e.zoneId=a,o(await c(`Loading config`,async()=>i.zaraz.history.configs.get(a,Object.keys(r).length>0?r:void 0)),{successLabel:`Loaded config`})}},_={command:`configs`,describe:`Configuration version history — browse and restore previous Zaraz configurations`,builder:e=>e.command(g).demandCommand(1),handler:()=>{}},v={command:`list`,describe:`Lists a history of published Zaraz configuration records for a zone.`,builder:e=>e.option(`offset`,{type:`number`,description:`Ordinal number to start listing the results with. Default value is 0.`}).option(`limit`,{type:`number`,description:`Maximum amount of results to list. Default value is 10.`}).option(`sort-field`,{type:`string`,description:`The field to sort by. Default is updated_at.`,choices:[`id`,`user_id`,`description`,`created_at`,`updated_at`]}).option(`sort-order`,{type:`string`,description:`Sorting order. Default is DESC.`,choices:[`DESC`,`ASC`]}),handler:async e=>{let r={};e.offset!==void 0&&(r.offset=e.offset),e.limit!==void 0&&(r.limit=e.limit),e.sortField!==void 0&&(r.sortField=e.sortField),e.sortOrder!==void 0&&(r.sortOrder=e.sortOrder);let i=await t(e),a=await n({zone:e.zone},i,{quiet:e.quiet});e.zoneId=a,o(await c(`Loading history`,async()=>i.zaraz.history.list(a,Object.keys(r).length>0?r:void 0)),{successLabel:`Loaded history`})}},y={command:`update`,describe:`Restores a historical published Zaraz configuration by ID for a zone.`,builder:e=>e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`ID of the Zaraz configuration to restore.`}),handler:async e=>{if(e.dryRun){s({command:`cf zaraz history update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/settings/zaraz/history`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{body:e.body},validation:`passed`});return}let r=await t(e),i=await n({zone:e.zone},r,{quiet:e.quiet});if(e.zoneId=i,e.body){let t=a(e.body);o(await c(`Updating history`,async()=>r.put(`/zones/${e.zoneId}/settings/zaraz/history`,{body:t})),{successLabel:`Updated history`});return}o(await c(`Updating history`,async()=>r.zaraz.history.update(i)),{successLabel:`Updated history`})}},b={command:`history`,describe:`Configuration version history — browse and restore previous Zaraz configurations`,builder:e=>e.command(v).command(y).command(_).demandCommand(1),handler:()=>{}},x={command:`create`,describe:`Publish current Zaraz preview configuration for a zone.`,builder:e=>e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Zaraz configuration description.`}),handler:async e=>{if(e.dryRun){s({command:`cf zaraz publish create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/settings/zaraz/publish`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{body:e.body},validation:`passed`});return}let r=await t(e),i=await n({zone:e.zone},r,{quiet:e.quiet});if(e.zoneId=i,e.body){let t=a(e.body);o(await c(`Creating publish`,async()=>r.post(`/zones/${e.zoneId}/settings/zaraz/publish`,{body:t})),{successLabel:`Created publish`});return}o(await c(`Creating publish`,async()=>r.zaraz.publish.create(i)),{successLabel:`Created publish`})}},S={command:`publish`,describe:`Publish pending Zaraz configuration changes to make them live on the zone`,builder:e=>e.command(x).demandCommand(1),handler:()=>{}},C={command:`update`,describe:`Updates Zaraz workflow for a zone.`,builder:e=>e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Zaraz workflow.`}),handler:async e=>{if(e.dryRun){s({command:`cf zaraz update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zoneId??`<zoneId>`}/settings/zaraz/workflow`,pathParams:{zoneId:String(e.zoneId??``)},bodyKind:`json`,body:{body:e.body},validation:`passed`});return}let r=await t(e),i=await n({zone:e.zone},r,{quiet:e.quiet});if(e.zoneId=i,e.body){let t=a(e.body);o(await c(`Updating zaraz`,async()=>r.put(`/zones/${e.zoneId}/settings/zaraz/workflow`,{body:t})),{successLabel:`Updated zaraz`});return}o(await c(`Updating zaraz`,async()=>r.zaraz.update(i)),{successLabel:`Updated zaraz`})}},w={command:`get`,describe:`Gets Zaraz workflow for a zone.`,builder:e=>e,handler:async e=>{let r=await t(e),i=await n({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,o(await c(`Loading workflow`,async()=>r.zaraz.workflow.get(i)),{successLabel:`Loaded workflow`})}},T={command:`workflow`,describe:`Workflow state for Zaraz configuration changes (draft vs. published)`,builder:e=>e.command(w).demandCommand(1),handler:()=>{}},E={command:`zaraz`,describe:`Server-side tag manager — load third-party tools (analytics, pixels, etc.) from Cloudflare's edge without client-side JS`,builder:e=>e.command(C).command(d).command(p).command(h).command(b).command(S).command(T).demandCommand(1),handler:()=>{}};export{E as default};
|