cf 0.3.0 → 0.5.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 +7 -1
- package/dist/_meta/agent-context.json +26 -21
- package/dist/_meta/commands.json +7696 -18100
- package/dist/_meta/schemas.json +6411 -13925
- package/dist/{abuse-reports-dMIfUJ8v.mjs → abuse-reports-Ina5TlsU.mjs} +2 -2
- package/dist/{accounts-Kx1epdA1.mjs → accounts-B_joQcMi.mjs} +9 -9
- package/dist/{acm-Utu252kC.mjs → acm-_kIHqYME.mjs} +2 -2
- package/dist/{addressing-CBq7Z7Vq.mjs → addressing-CaFlw8y1.mjs} +10 -10
- package/dist/{agent-context-BGTU299M.mjs → agent-context-DMPfi54f.mjs} +1 -1
- package/dist/ai-CqnhNb_c.mjs +2 -0
- package/dist/ai-gateway-pgYGI519.mjs +8 -0
- package/dist/ai-search-eqQMPQol.mjs +7 -0
- package/dist/ai_gateway--vuVLnOm.mjs +4 -0
- package/dist/{alerting-CqmEIaKn.mjs → alerting-CPxHiYHb.mjs} +5 -5
- package/dist/{analytics-Dv-X8x7D.mjs → analytics-DSSRDZz8.mjs} +1 -1
- package/dist/analytics_engine-gWyfnsCs.mjs +2 -0
- package/dist/{api-gateway-CNv0IHTU.mjs → api-gateway-BXXGFCVR.mjs} +10 -10
- package/dist/argo-aC6A3JyX.mjs +2 -0
- package/dist/artifacts-HD4V2xpK.mjs +4 -0
- package/dist/audit-logs-BuExU_nz.mjs +2 -0
- package/dist/auth-CSC4yhEJ.mjs +9 -0
- package/dist/auth-D5hNsOFq.mjs +5 -0
- package/dist/billing-COaghyxl.mjs +2 -0
- package/dist/bot-management-DmEzeV1Y.mjs +5 -0
- package/dist/botnet-feed-ByEAXAkw.mjs +3 -0
- package/dist/brand-protection-dPrGe8sL.mjs +3 -0
- package/dist/browser-rendering-BiSGnpBf.mjs +4 -0
- package/dist/{build-DYkGW4dh.mjs → build-HuS9-R0V.mjs} +131 -131
- package/dist/{cache-DsoW6Xwv.mjs → cache-CY-7Lt71.mjs} +4 -4
- package/dist/calls-wOQGDWPl.mjs +4 -0
- package/dist/certificate-authorities-CtqzAtxQ.mjs +2 -0
- package/dist/chunk-6IEM75FG-BEjRFMGh.mjs +2 -0
- package/dist/client-certificates-CRf41xLe.mjs +3 -0
- package/dist/cloud-connector-BA5IRZUP.mjs +2 -0
- package/dist/{cloudforce-one-2Bhz8YdW.mjs → cloudforce-one-Bq_qPAWs.mjs} +20 -20
- package/dist/{completions-BwRpZQVn.mjs → completions-DOeHPdCG.mjs} +2 -2
- package/dist/config-B5k-XbwS.mjs +2 -0
- package/dist/connectivity-Bx3MgTHX.mjs +3 -0
- package/dist/connector-interrupts-D7ylweJZ.mjs +2 -0
- package/dist/connector-telemetry-events-6izV1kbP.mjs +2 -0
- package/dist/connector-telemetry-snapshots-BnjKbyxX.mjs +2 -0
- package/dist/connectors-DRt4e6d_.mjs +3 -0
- package/dist/content-scanning-Cd2vy5Sz.mjs +4 -0
- package/dist/context-jpewmual.mjs +2 -0
- package/dist/{custom-certificates-aAiEguR7.mjs → custom-certificates-DYE-9epx.mjs} +3 -3
- package/dist/{custom-hostnames-AG5yBHIi.mjs → custom-hostnames-CtuTdFcX.mjs} +4 -4
- package/dist/custom-nameservers-CWqA51in.mjs +3 -0
- package/dist/custom-pages-DeUKEFGe.mjs +4 -0
- package/dist/d1-DvWY9Gp4.mjs +4 -0
- package/dist/data-security-BPo6dIWu.mjs +6 -0
- package/dist/dcv-delegation-Bgf86J-r.mjs +2 -0
- package/dist/{deploy-CQial3kN.mjs → deploy-dVrgDUOp.mjs} +1 -1
- package/dist/{dev-B38LfCTl.mjs → dev-C01_Lby6.mjs} +1 -1
- package/dist/diagnostics-6nKPmVgz.mjs +3 -0
- package/dist/{dispatch-namespaces-DmHvoBOg.mjs → dispatch-namespaces-64lXx2WJ.mjs} +6 -6
- package/dist/dist-C6zxsVdY.mjs +306 -0
- package/dist/{dist-AIcZFk0U.mjs → dist-t_YrL25p.mjs} +7 -7
- package/dist/{dns-VMhQSr5n.mjs → dns-ClciFGxx.mjs} +13 -13
- package/dist/dns-firewall-DfUmXDCe.mjs +57 -0
- package/dist/durable-objects-CMaYZ-YU.mjs +2 -0
- package/dist/{email-routing-tIR2SFu-.mjs → email-routing-CGXhFqF5.mjs} +9 -9
- package/dist/{email-security-Ca1id3rZ.mjs → email-security-D5viPq8S.mjs} +7 -7
- package/dist/email-sending-C2jpc3gh.mjs +3 -0
- package/dist/{filters-A4dg_a68.mjs → filters-bzsFcWt0.mjs} +3 -3
- package/dist/{firewall-DWPQgYd9.mjs → firewall-DYZcTtIC.mjs} +10 -10
- package/dist/{fraud-BMkSsJGU.mjs → fraud-C03MtdZb.mjs} +1 -1
- package/dist/google-tag-gateway-Dfy887yA.mjs +2 -0
- package/dist/{healthchecks-CtIfrFql.mjs → healthchecks-DRoAlWgr.mjs} +3 -3
- package/dist/hostnames-CFgIVI3s.mjs +3 -0
- package/dist/hyperdrive-C7-gwTSV.mjs +18 -0
- package/dist/iam-DqVPzGrb.mjs +6 -0
- package/dist/images-BYfl4YgR.mjs +7 -0
- package/dist/index.mjs +1 -1
- package/dist/intel-duTEPIHc.mjs +3 -0
- package/dist/{ips-K4bzaGqd.mjs → ips-nv9INuWZ.mjs} +1 -1
- package/dist/keyless-certificates-CRCDVd3g.mjs +3 -0
- package/dist/{kv-8o27w_pY.mjs → kv-CZoV4tiv.mjs} +4 -4
- package/dist/leaked-credential-checks-DNIBg7Pe.mjs +3 -0
- package/dist/{load-balancers-DtG8nj25.mjs → load-balancers--OMg0HNt.mjs} +5 -5
- package/dist/{logpush-4L0njy1d.mjs → logpush-C0_lZTyY.mjs} +3 -3
- package/dist/{logs-B_Yp95hv.mjs → logs-BtpWZQfV.mjs} +2 -2
- package/dist/magic-cloud-networking-u6rwYbGg.mjs +5 -0
- package/dist/{magic-network-monitoring-BnwvM4-I.mjs → magic-network-monitoring-CKgQyRj4.mjs} +3 -3
- package/dist/{magic-transit-CXDyvhxq.mjs → magic-transit-CLhMcJ_-.mjs} +32 -33
- package/dist/managed-transforms-D0Z2mlth.mjs +3 -0
- package/dist/mtls-certificates-BL65NK5T.mjs +3 -0
- package/dist/{network-interconnects-rrr7red3.mjs → network-interconnects-Bgu9gmaG.mjs} +5 -5
- package/dist/oauth-Bk-F-tIO.mjs +52 -0
- package/dist/{observability-DWvpqnQJ.mjs → observability-BynRbTF4.mjs} +3 -3
- package/dist/open-YWOUIZ5Y-3jqSKAB1.mjs +4 -0
- package/dist/{organizations-T77D50Sq.mjs → organizations-BqJHyvMK.mjs} +3 -3
- package/dist/origin-ca-certificates-BGvYwm3C.mjs +3 -0
- package/dist/origin-post-quantum-encryption-9KOE8YPI.mjs +2 -0
- package/dist/{origin-tls-client-auth-CaVW1Ztp.mjs → origin-tls-client-auth-d3snC3vr.mjs} +3 -3
- package/dist/{output-BJFNwj7b.mjs → output-B6fBFRqe.mjs} +1 -1
- package/dist/{page-rules-CjZPTMQX.mjs → page-rules-EZHJePmn.mjs} +4 -4
- package/dist/{page-shield-D5RRNJCY.mjs → page-shield-CXJioWPs.mjs} +5 -5
- package/dist/{pages-CWJtJnL0.mjs → pages-D4aYteKk.mjs} +8 -8
- package/dist/{pipelines-B0L_7j9e.mjs → pipelines-G8Iusxq-.mjs} +5 -5
- package/dist/progress-DrDErV9w.mjs +2 -0
- package/dist/queues-DEkbKqZX.mjs +6 -0
- package/dist/{r2-DQIcyRtA.mjs → r2-CV0IkCAW.mjs} +9 -9
- package/dist/r2-data-catalog-NtqGC_a_.mjs +14 -0
- package/dist/radar-D986zPJr.mjs +2 -0
- package/dist/{rate-limits-DcrQV6Ar.mjs → rate-limits-B2wRsUX1.mjs} +3 -3
- package/dist/raw-fetch-_n0lMAnD.mjs +2 -0
- package/dist/{realtime-kit-CaquuVOE.mjs → realtime-kit-Ld3c5eU6.mjs} +9 -9
- package/dist/{registrar-Ko-xZemf.mjs → registrar-CDIwTz3G.mjs} +6 -6
- package/dist/request-tracers-D7SFMDik.mjs +2 -0
- package/dist/resource-sharing-YIQ04jXE.mjs +5 -0
- package/dist/{resource-tagging-C3qtLzCz.mjs → resource-tagging-Bd6Y03sg.mjs} +7 -7
- package/dist/rules-DHjLP5Kx.mjs +4 -0
- package/dist/{rulesets-CBgpeSvJ.mjs → rulesets-q4QABpKs.mjs} +7 -7
- package/dist/rum-SmT4HZmM.mjs +4 -0
- package/dist/{schema-D16TgWBg.mjs → schema-BR31o4P6.mjs} +1 -1
- package/dist/{schema-validation-Dgv_opM3.mjs → schema-validation-vVetgC_P.mjs} +5 -5
- package/dist/{scim-DdSEr4kZ.mjs → scim-ChOkZpNx.mjs} +2 -2
- package/dist/{session-COHHdS7A.mjs → sdk-DhIhH6GB.mjs} +4 -4
- package/dist/{secrets-store-7BfyvJLb.mjs → secrets-store-BAK9G12O.mjs} +12 -12
- package/dist/security-center-eScuYDKP.mjs +2 -0
- package/dist/security-txt-x7R4gmQu.mjs +3 -0
- package/dist/session-DHYCE-PM.mjs +93 -0
- package/dist/shared-BAjo72Lz.mjs +2 -0
- package/dist/{smart-shield-TeWZFnH2.mjs → smart-shield-CWlSsNi8.mjs} +2 -2
- package/dist/snippets-DrlgYJYp.mjs +4 -0
- package/dist/{spawn-DcppKGI5.mjs → spawn-CCGzKlC4.mjs} +1 -1
- package/dist/{spectrum-CTTZID8u.mjs → spectrum-pVGxb7u5.mjs} +6 -6
- package/dist/speed-ZFrMWDgd.mjs +4 -0
- package/dist/src-DU7FBCOX.mjs +108 -0
- package/dist/ssl-9JY05sYt.mjs +15 -0
- package/dist/stream-tRU39b8K.mjs +14 -0
- package/dist/{tenants-Bd7NGQ_m.mjs → tenants-HLGUazms.mjs} +1 -1
- package/dist/{token-validation-DAgtFOvs.mjs → token-validation-_VdamKpz.mjs} +4 -4
- package/dist/{tools-DXQmfFuE.mjs → tools-D_hfUU_Z.mjs} +1 -1
- package/dist/{turnstile-cfdaO4ca.mjs → turnstile-BRzXd28B.mjs} +4 -4
- package/dist/{ui-D4KtlMh9.mjs → ui-erjBdVKL.mjs} +1 -1
- package/dist/url-normalization-D-NxuLtN.mjs +3 -0
- package/dist/url-scanner-BzzR6iDx.mjs +2 -0
- package/dist/{user-CAo-yCJA.mjs → user-C4omq__w.mjs} +2 -2
- package/dist/vectorize-By6EqcNR.mjs +4 -0
- package/dist/{versions-CUwWJWmy.mjs → versions-CBHwWPAM.mjs} +1 -1
- package/dist/{waiting-rooms-Dln5ICg5.mjs → waiting-rooms-u6KwrzWd.mjs} +6 -6
- package/dist/{web3-HQJRm38W.mjs → web3-DQ5dmE9W.mjs} +3 -3
- package/dist/{workers-Dg7ddG2Q.mjs → workers-D8Be7_as.mjs} +14 -14
- package/dist/workers-builds-BE3W3qNk.mjs +7 -0
- package/dist/{workflows-VquuSh2J.mjs → workflows-BWWufqFA.mjs} +3 -3
- package/dist/zaraz-Bsa9AvVL.mjs +2 -0
- package/dist/{zero-trust-CP96wnSh.mjs → zero-trust-UNVZFnKu.mjs} +87 -87
- package/dist/zero_trust-B0_Rk4p2.mjs +3 -0
- package/dist/zones-BXtdwt6E.mjs +21 -0
- package/package.json +4 -4
- package/dist/ai-DOOKLPkG.mjs +0 -2
- package/dist/ai-gateway-Cj1T3avF.mjs +0 -8
- package/dist/ai-search-CQF_Sn7d.mjs +0 -7
- package/dist/ai_gateway-C3fH22C0.mjs +0 -4
- package/dist/analytics_engine-DdXVR8z2.mjs +0 -2
- package/dist/argo-CX_A4kcn.mjs +0 -2
- package/dist/audit-logs-BfBf3oo-.mjs +0 -2
- package/dist/auth-SyWhMmPu.mjs +0 -6
- package/dist/auth-ffdf9yR0.mjs +0 -135
- package/dist/autorag-BuGhGTeZ.mjs +0 -2
- package/dist/billing-PoG81XaQ.mjs +0 -2
- package/dist/bot-management-CFvtVx62.mjs +0 -5
- package/dist/botnet-feed-B-M4Yu0W.mjs +0 -3
- package/dist/brand-protection-D05Eg-_6.mjs +0 -3
- package/dist/browser-rendering-xu8F_Rrv.mjs +0 -4
- package/dist/calls-CZbO7TyR.mjs +0 -4
- package/dist/certificate-authorities-D2yr7_3t.mjs +0 -2
- package/dist/client-certificates-MJcDsTId.mjs +0 -3
- package/dist/cloud-connector-DWOrN2eM.mjs +0 -2
- package/dist/config-DYzlVxcB.mjs +0 -2
- package/dist/connectivity-BX8C7tvK.mjs +0 -3
- package/dist/content-scanning-r6uzMO1r.mjs +0 -4
- package/dist/context-DGlHRGWM.mjs +0 -2
- package/dist/custom-nameservers-D1DtlRue.mjs +0 -3
- package/dist/custom-pages-DQCi2plU.mjs +0 -4
- package/dist/d1-DbnYhw45.mjs +0 -4
- package/dist/data-security-D_EtYBfo.mjs +0 -6
- package/dist/dcv-delegation-CHspSzTI.mjs +0 -2
- package/dist/diagnostics-BJQGjVJn.mjs +0 -3
- package/dist/dist-DNBSHor6.mjs +0 -301
- package/dist/dns-firewall-B4DVXFBQ.mjs +0 -57
- package/dist/durable-objects-CTboySEo.mjs +0 -2
- package/dist/email-sending-DwWKc5jC.mjs +0 -3
- package/dist/google-tag-gateway-BGD49nRC.mjs +0 -2
- package/dist/hostnames-BiomxukN.mjs +0 -3
- package/dist/hyperdrive-Da104VaQ.mjs +0 -18
- package/dist/iam-BIGKo0WW.mjs +0 -6
- package/dist/images-BO8FbDAa.mjs +0 -5
- package/dist/intel-CY6_79v8.mjs +0 -3
- package/dist/keyless-certificates-CZC-L8gM.mjs +0 -3
- package/dist/leaked-credential-checks-qLzRyu85.mjs +0 -3
- package/dist/magic-cloud-networking-CSOM3EM-.mjs +0 -5
- package/dist/managed-transforms-D15yVbZx.mjs +0 -3
- package/dist/mtls-certificates-D8k0AXWK.mjs +0 -3
- package/dist/origin-ca-certificates-DXIvD8H5.mjs +0 -3
- package/dist/origin-post-quantum-encryption-C8oOczyV.mjs +0 -2
- package/dist/progress-CrCGTq7N.mjs +0 -2
- package/dist/queues-CN6DPhRR.mjs +0 -6
- package/dist/r2-data-catalog-Bbo93TJx.mjs +0 -14
- package/dist/radar-Bxb0WX8V.mjs +0 -2
- package/dist/raw-fetch-Dlccg0Tr.mjs +0 -2
- package/dist/request-tracers-DOW_reTJ.mjs +0 -2
- package/dist/resource-sharing-D7TX0JV0.mjs +0 -5
- package/dist/rules-BXRADHL5.mjs +0 -4
- package/dist/rum-BjPptTUP.mjs +0 -4
- package/dist/security-center-DAy6AKtT.mjs +0 -2
- package/dist/security-txt-xAMb7K6Y.mjs +0 -3
- package/dist/shared-AGtpXwwL.mjs +0 -2
- package/dist/snippets-CCSsCXVs.mjs +0 -4
- package/dist/speed-CuzTE0AL.mjs +0 -4
- package/dist/src-BW6vfAwE.mjs +0 -108
- package/dist/ssl-BWA2LdwC.mjs +0 -15
- package/dist/stream-GFsIZ-pP.mjs +0 -14
- package/dist/url-normalization-B5RN4nLD.mjs +0 -3
- package/dist/url-scanner-BrZ1L9OC.mjs +0 -2
- package/dist/vectorize-C7_oQlaI.mjs +0 -4
- package/dist/workers-builds-AVfx8IyL.mjs +0 -7
- package/dist/zaraz-xYSWIV4P.mjs +0 -2
- package/dist/zones-BSgmZ9WC.mjs +0 -21
- /package/dist/{body-parser-DKa8Ipg1.mjs → body-parser-DWSy7uZ8.mjs} +0 -0
- /package/dist/{cli-types-CRIDdDw3.mjs → cli-types-BeyOc81z.mjs} +0 -0
- /package/dist/{input-validation-zEO81MWN.mjs → input-validation-_fMCApaH.mjs} +0 -0
- /package/dist/{lib-Eu1wXxuh.mjs → lib-4PQI6yRW.mjs} +0 -0
- /package/dist/{local-VJaJ3BZ1.mjs → local-CYc9q7l2.mjs} +0 -0
- /package/dist/{metadata-5VwHPW6C.mjs → metadata-OOwvpR8m.mjs} +0 -0
- /package/dist/{resolve-4-OSeHlK.mjs → resolve-C3h-mwp7.mjs} +0 -0
- /package/dist/{theme-BklJDrb2.mjs → theme-DbNbIY4d.mjs} +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{C as e,D as t,E as n,S as r,T as i,_ as a,i as o,n as s,x as c}from"./auth-ffdf9yR0.mjs";import{n as l,r as u,t as d}from"./body-parser-DKa8Ipg1.mjs";import{t as f}from"./output-BJFNwj7b.mjs";import{n as p,t as m}from"./progress-CrCGTq7N.mjs";import{n as h,t as g}from"./input-validation-zEO81MWN.mjs";import{t as _}from"./local-VJaJ3BZ1.mjs";import{t as v}from"./cli-types-CRIDdDw3.mjs";import{n as ee,t as te}from"./raw-fetch-Dlccg0Tr.mjs";function y(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`get`,describe:`Fetches Worker account settings for an account.`,builder:y,handler:async t=>{if(t.dryRun){p({command:`cf workers account-settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/account-settings`,pathParams:{},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r,f(await m(`Loading`,async()=>n.workers.accountSettings.get({account_id:r})),{successLabel:`Loaded`})}};function x(e){return 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)`})}const S={command:`update`,describe:`Creates Worker account settings for an account.`,builder:x,handler:async t=>{if(t.dryRun){p({command:`cf workers account-settings update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/account-settings`,pathParams:{},bodyKind:`json`,body:t.body===void 0?d({default_usage_model:h(t[`default-usage-model`],`default-usage-model`,`text`),green_compute:t[`green-compute`]}):l(t.body)});return}let n=await s(t),r=t.local?_:await a(n);if(t.accountId=r,t.body){let e=l(t.body);f(await m(`Updating`,async()=>n.workers.accountSettings.update({body:e,account_id:r})),{successLabel:`Updated`});return}let i=d({default_usage_model:h(t[`default-usage-model`],`default-usage-model`,`text`),green_compute:t[`green-compute`]});f(await m(`Updating`,async()=>n.workers.accountSettings.update({body:i,account_id:r})),{successLabel:`Updated`})}},C={command:`account-settings`,describe:`Operations for account-settings`,builder:e=>e.command(b).command(S).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function w(e){return e.option(`base64`,{type:`string`,description:"Whether the file contents are base64-encoded. Must be `true`.",choices:[`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`})}const T={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:v(w),handler:async t=>{let n={base64:t.base64};if(t.dryRun){p({command:`cf workers assets upload create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/assets/upload`,pathParams:{},query:n,bodyKind:`octet-stream`,body:t.body});return}let r=await s(t),i=t.local?_:await a(r);if(t.accountId=i,t.file){let e=g(t.file),n=new FormData;n.append(`file`,new Blob([e]),t.file.split(/[\\/]/).filter(Boolean).pop()),f(await m(`Creating`,async()=>o(r,`POST`,`/accounts/${i}/workers/assets/upload`,{body:n})),{successLabel:`Created`});return}if(t.body){let e=h(t.body,`body`,`binary`),a=new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();f(await m(`Creating`,async()=>o(r,`POST`,`/accounts/${i}/workers/assets/upload${a?`?`+a:``}`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}f(await m(`Creating`,async()=>r.workers.assets.upload.create({account_id:i,...n})),{successLabel:`Created`})}},E={command:`upload`,describe:`Operations for assets.upload`,builder:e=>e.command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},D={command:`assets`,describe:`Operations for assets`,builder:e=>e.command(E).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function O(e){return 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(`observability-traces-propagation-policy`,{type:`string`,description:`Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. "authenticated" (default) honors inbound trace context only when accompanied by a valid trace auth token. "accept" unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.`,choices:[`authenticated`,`accept`],default:`authenticated`}).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.`})}const k={command:`create`,describe:`Create a new Worker.`,builder:O,handler:async n=>{if(n.dryRun){p({command:`cf workers beta workers create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/workers`,pathParams:{},bodyKind:`json`,body:n.body===void 0?d({logpush:n.logpush,name:h(n.name,`name`,`text`),observability:{enabled:n[`observability-enabled`],head_sampling_rate:n[`observability-head-sampling-rate`],logs:{destinations:n[`observability-logs-destinations`],enabled:n[`observability-logs-enabled`],head_sampling_rate:n[`observability-logs-head-sampling-rate`],invocation_logs:n[`observability-logs-invocation-logs`],persist:n[`observability-logs-persist`]},traces:{destinations:n[`observability-traces-destinations`],enabled:n[`observability-traces-enabled`],head_sampling_rate:n[`observability-traces-head-sampling-rate`],persist:n[`observability-traces-persist`],propagation_policy:h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}},subdomain:{enabled:n[`subdomain-enabled`],previews_enabled:n[`subdomain-previews-enabled`]},tags:n.tags}):l(n.body)});return}let r=await s(n),i=n.local?_:await a(r);if(n.accountId=i,n.body){let e=l(n.body);f(await m(`Creating`,async()=>r.workers.beta.workers.create({...e,account_id:i})),{successLabel:`Created`});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 o=d({logpush:n.logpush,name:h(n.name,`name`,`text`),observability:{enabled:n[`observability-enabled`],head_sampling_rate:n[`observability-head-sampling-rate`],logs:{destinations:n[`observability-logs-destinations`],enabled:n[`observability-logs-enabled`],head_sampling_rate:n[`observability-logs-head-sampling-rate`],invocation_logs:n[`observability-logs-invocation-logs`],persist:n[`observability-logs-persist`]},traces:{destinations:n[`observability-traces-destinations`],enabled:n[`observability-traces-enabled`],head_sampling_rate:n[`observability-traces-head-sampling-rate`],persist:n[`observability-traces-persist`],propagation_policy:h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}},subdomain:{enabled:n[`subdomain-enabled`],previews_enabled:n[`subdomain-previews-enabled`]},tags:n.tags});f(await m(`Creating`,async()=>r.workers.beta.workers.create({...o,account_id:i})),{successLabel:`Created`})}};function A(e){return e.positional(`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})}const j={command:`delete <worker-id>`,describe:`Delete a Worker and all its associated resources (versions, deployments, etc.).`,builder:A,handler:async t=>{if(t.dryRun){p({command:`cf workers beta workers delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/workers/${t[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(t[`worker-id`]))}`,pathParams:{"worker-id":String(t[`worker-id`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);if(t.accountId=r,!await i({force:!!t.force})){process.stderr.write(`Aborted.
|
|
3
|
-
`);return}f(await m(`Deleting`,async()=>n.workers.beta.workers.delete({account_id:r,worker_id:t[`worker-id`]})),{successLabel:`Deleted`})}};function M(e){return e.positional(`worker-id`,{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.`}).option(`name`,{type:`string`,description:`Name of the Worker.`}).option(`observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`}).option(`observability-head-sampling-rate`,{type:`number`,description:`The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).`}).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.`}).option(`observability-logs-head-sampling-rate`,{type:`number`,description:`The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).`}).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.`}).option(`observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`}).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%).`}).option(`observability-traces-persist`,{type:`boolean`,description:`Whether trace persistence is enabled for the Worker.`}).option(`observability-traces-propagation-policy`,{type:`string`,description:`Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. "authenticated" (default) honors inbound trace context only when accompanied by a valid trace auth token. "accept" unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.`,choices:[`authenticated`,`accept`]}).option(`subdomain-enabled`,{type:`boolean`,description:`Whether the *.workers.dev subdomain is enabled for the Worker.`}).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`})}const N={command:`edit <worker-id>`,describe:`Perform a partial update on a Worker, where omitted properties are left unchanged from their current values.`,builder:M,handler:async n=>{if(n.dryRun){p({command:`cf workers beta workers edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/workers/${n[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(n[`worker-id`]))}`,pathParams:{"worker-id":String(n[`worker-id`]??``)},bodyKind:`json`,body:n.body===void 0?d({logpush:n.logpush,name:h(n.name,`name`,`text`),observability:{enabled:n[`observability-enabled`],head_sampling_rate:n[`observability-head-sampling-rate`],logs:{destinations:n[`observability-logs-destinations`],enabled:n[`observability-logs-enabled`],head_sampling_rate:n[`observability-logs-head-sampling-rate`],invocation_logs:n[`observability-logs-invocation-logs`],persist:n[`observability-logs-persist`]},traces:{destinations:n[`observability-traces-destinations`],enabled:n[`observability-traces-enabled`],head_sampling_rate:n[`observability-traces-head-sampling-rate`],persist:n[`observability-traces-persist`],propagation_policy:h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}},subdomain:{enabled:n[`subdomain-enabled`],previews_enabled:n[`subdomain-previews-enabled`]},tags:n.tags}):l(n.body)});return}let r=await s(n),i=n.local?_:await a(r);if(n.accountId=i,n.file){let e=g(n.file);f(await m(`Updating`,async()=>o(r,`PATCH`,`/accounts/${i}/workers/workers/${encodeURIComponent(String(n[`worker-id`]))}`,{body:e,headers:{"Content-Type":`application/merge-patch+json`}})),{successLabel:`Updated`});return}if(n.body){let e=l(n.body);f(await m(`Updating`,async()=>o(r,`PATCH`,`/accounts/${i}/workers/workers/${encodeURIComponent(String(n[`worker-id`]))}`,{body:e})),{successLabel:`Updated`});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 c={};n.logpush!==void 0&&u(c,[`logpush`],n.logpush),n.name!==void 0&&u(c,[`name`],h(n.name,`name`,`text`)),n[`observability-enabled`]!==void 0&&u(c,[`observability`,`enabled`],n[`observability-enabled`]),n[`observability-head-sampling-rate`]!==void 0&&u(c,[`observability`,`head_sampling_rate`],n[`observability-head-sampling-rate`]),n[`observability-logs-destinations`]!==void 0&&u(c,[`observability`,`logs`,`destinations`],n[`observability-logs-destinations`]),n[`observability-logs-enabled`]!==void 0&&u(c,[`observability`,`logs`,`enabled`],n[`observability-logs-enabled`]),n[`observability-logs-head-sampling-rate`]!==void 0&&u(c,[`observability`,`logs`,`head_sampling_rate`],n[`observability-logs-head-sampling-rate`]),n[`observability-logs-invocation-logs`]!==void 0&&u(c,[`observability`,`logs`,`invocation_logs`],n[`observability-logs-invocation-logs`]),n[`observability-logs-persist`]!==void 0&&u(c,[`observability`,`logs`,`persist`],n[`observability-logs-persist`]),n[`observability-traces-destinations`]!==void 0&&u(c,[`observability`,`traces`,`destinations`],n[`observability-traces-destinations`]),n[`observability-traces-enabled`]!==void 0&&u(c,[`observability`,`traces`,`enabled`],n[`observability-traces-enabled`]),n[`observability-traces-head-sampling-rate`]!==void 0&&u(c,[`observability`,`traces`,`head_sampling_rate`],n[`observability-traces-head-sampling-rate`]),n[`observability-traces-persist`]!==void 0&&u(c,[`observability`,`traces`,`persist`],n[`observability-traces-persist`]),n[`observability-traces-propagation-policy`]!==void 0&&u(c,[`observability`,`traces`,`propagation_policy`],h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)),n[`subdomain-enabled`]!==void 0&&u(c,[`subdomain`,`enabled`],n[`subdomain-enabled`]),n[`subdomain-previews-enabled`]!==void 0&&u(c,[`subdomain`,`previews_enabled`],n[`subdomain-previews-enabled`]),n.tags!==void 0&&u(c,[`tags`],n.tags),f(await m(`Updating`,async()=>o(r,`PATCH`,`/accounts/${i}/workers/workers/${encodeURIComponent(String(n[`worker-id`]))}`,{body:Object.keys(c).length>0?c:void 0})),{successLabel:`Updated`})}};function P(e){return e.positional(`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})}const F={command:`get <worker-id>`,describe:`Get details about a specific Worker.`,builder:P,handler:async t=>{if(t.dryRun){p({command:`cf workers beta workers get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/workers/${t[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(t[`worker-id`]))}`,pathParams:{"worker-id":String(t[`worker-id`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r,f(await m(`Loading`,async()=>n.workers.beta.workers.get({account_id:r,worker_id:t[`worker-id`]})),{successLabel:`Loaded`})}};function I(e){return 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`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const L={command:`list`,describe:`List all Workers for an account.`,builder:v(I),handler:async t=>{let n={page:t.page,per_page:t[`per-page`],order_by:t[`order-by`],order:t.order};if(t.dryRun){p({command:`cf workers beta workers list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/workers`,pathParams:{},query:n,bodyKind:`none`});return}let r=await s(t),i=t.local?_:await a(r);t.accountId=i,f(await m(`Loading`,async()=>r.workers.beta.workers.list({account_id:i,...n})),{successLabel:`Loaded`})}};function R(e){return e.positional(`worker-id`,{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.`}).option(`name`,{type:`string`,description:`Name of the Worker.`}).option(`observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`}).option(`observability-head-sampling-rate`,{type:`number`,description:`The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).`}).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.`}).option(`observability-logs-head-sampling-rate`,{type:`number`,description:`The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).`}).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.`}).option(`observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`}).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%).`}).option(`observability-traces-persist`,{type:`boolean`,description:`Whether trace persistence is enabled for the Worker.`}).option(`observability-traces-propagation-policy`,{type:`string`,description:`Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. "authenticated" (default) honors inbound trace context only when accompanied by a valid trace auth token. "accept" unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.`,choices:[`authenticated`,`accept`]}).option(`subdomain-enabled`,{type:`boolean`,description:`Whether the *.workers.dev subdomain is enabled for the Worker.`}).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.`})}const z={command:`update <worker-id>`,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:R,handler:async n=>{if(n.dryRun){p({command:`cf workers beta workers update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/workers/${n[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(n[`worker-id`]))}`,pathParams:{"worker-id":String(n[`worker-id`]??``)},bodyKind:`json`,body:n.body===void 0?d({logpush:n.logpush,name:h(n.name,`name`,`text`),observability:{enabled:n[`observability-enabled`],head_sampling_rate:n[`observability-head-sampling-rate`],logs:{destinations:n[`observability-logs-destinations`],enabled:n[`observability-logs-enabled`],head_sampling_rate:n[`observability-logs-head-sampling-rate`],invocation_logs:n[`observability-logs-invocation-logs`],persist:n[`observability-logs-persist`]},traces:{destinations:n[`observability-traces-destinations`],enabled:n[`observability-traces-enabled`],head_sampling_rate:n[`observability-traces-head-sampling-rate`],persist:n[`observability-traces-persist`],propagation_policy:h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}},subdomain:{enabled:n[`subdomain-enabled`],previews_enabled:n[`subdomain-previews-enabled`]},tags:n.tags}):l(n.body)});return}let r=await s(n),i=n.local?_:await a(r);if(n.accountId=i,n.body){let e=l(n.body);f(await m(`Updating`,async()=>r.workers.beta.workers.update({...e,account_id:i,worker_id:n[`worker-id`]})),{successLabel:`Updated`});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 o=d({logpush:n.logpush,name:h(n.name,`name`,`text`),observability:{enabled:n[`observability-enabled`],head_sampling_rate:n[`observability-head-sampling-rate`],logs:{destinations:n[`observability-logs-destinations`],enabled:n[`observability-logs-enabled`],head_sampling_rate:n[`observability-logs-head-sampling-rate`],invocation_logs:n[`observability-logs-invocation-logs`],persist:n[`observability-logs-persist`]},traces:{destinations:n[`observability-traces-destinations`],enabled:n[`observability-traces-enabled`],head_sampling_rate:n[`observability-traces-head-sampling-rate`],persist:n[`observability-traces-persist`],propagation_policy:h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}},subdomain:{enabled:n[`subdomain-enabled`],previews_enabled:n[`subdomain-previews-enabled`]},tags:n.tags});f(await m(`Updating`,async()=>r.workers.beta.workers.update({...o,account_id:i,worker_id:n[`worker-id`]})),{successLabel:`Updated`})}};function B(e){return e.positional(`worker-id`,{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.`}).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(`cache-options-cross-version-cache`,{type:`boolean`,description:`Whether cached responses are shared across Worker version
|
|
2
|
+
import{E as e,S as t,T as n,b as r,g as i,w as a,x as o}from"./oauth-Bk-F-tIO.mjs";import{i as s,n as c}from"./auth-CSC4yhEJ.mjs";import{n as l,r as u,t as d}from"./body-parser-DWSy7uZ8.mjs";import{t as f}from"./output-B6fBFRqe.mjs";import{n as p,t as m}from"./progress-DrDErV9w.mjs";import{n as h,t as g}from"./input-validation-_fMCApaH.mjs";import{t as _}from"./local-CYc9q7l2.mjs";import{t as v}from"./cli-types-BeyOc81z.mjs";import{n as ee,t as te}from"./raw-fetch-_n0lMAnD.mjs";function y(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`get`,describe:`Fetches Worker account settings for an account.`,builder:y,handler:async e=>{if(e.dryRun){p({command:`cf workers account-settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/account-settings`,pathParams:{},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Loading`,async()=>n.workers.accountSettings.get({account_id:r})),{successLabel:`Loaded`})}};function x(e){return 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)`})}const S={command:`update`,describe:`Creates Worker account settings for an account.`,builder:x,handler:async e=>{if(e.dryRun){p({command:`cf workers account-settings update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/account-settings`,pathParams:{},bodyKind:`json`,body:e.body===void 0?d({default_usage_model:h(e[`default-usage-model`],`default-usage-model`,`text`),green_compute:e[`green-compute`]}):l(e.body)});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,e.body){let t=l(e.body);f(await m(`Updating`,async()=>n.workers.accountSettings.update({body:t,account_id:r})),{successLabel:`Updated`});return}let a=d({default_usage_model:h(e[`default-usage-model`],`default-usage-model`,`text`),green_compute:e[`green-compute`]});f(await m(`Updating`,async()=>n.workers.accountSettings.update({body:a,account_id:r})),{successLabel:`Updated`})}},C={command:`account-settings`,describe:`Operations for account-settings`,builder:e=>e.command(b).command(S).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function w(e){return e.option(`base64`,{type:`string`,description:"Whether the file contents are base64-encoded. Must be `true`.",choices:[`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`})}const T={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:v(w),handler:async e=>{let n={base64:e.base64};if(e.dryRun){p({command:`cf workers assets upload create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/assets/upload`,pathParams:{},query:n,bodyKind:`octet-stream`,body:e.body});return}let r=await c(e),a=e.local?_:await i(r);if(e.accountId=a,e.file){let t=g(e.file),n=new FormData;n.append(`file`,new Blob([t]),e.file.split(/[\\/]/).filter(Boolean).pop()),f(await m(`Creating`,async()=>s(r,`POST`,`/accounts/${a}/workers/assets/upload`,{body:n})),{successLabel:`Created`});return}if(e.body){let t=h(e.body,`body`,`binary`),i=new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();f(await m(`Creating`,async()=>s(r,`POST`,`/accounts/${a}/workers/assets/upload${i?`?`+i:``}`,{body:t,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}f(await m(`Creating`,async()=>r.workers.assets.upload.create({account_id:a,...n})),{successLabel:`Created`})}},E={command:`upload`,describe:`Operations for assets.upload`,builder:e=>e.command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},D={command:`assets`,describe:`Operations for assets`,builder:e=>e.command(E).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function O(e){return 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(`observability-traces-propagation-policy`,{type:`string`,description:`Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. "authenticated" (default) honors inbound trace context only when accompanied by a valid trace auth token. "accept" unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.`,choices:[`authenticated`,`accept`],default:`authenticated`}).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.`})}const k={command:`create`,describe:`Create a new Worker.`,builder:O,handler:async n=>{if(n.dryRun){p({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:n.body===void 0?d({logpush:n.logpush,name:h(n.name,`name`,`text`),observability:{enabled:n[`observability-enabled`],head_sampling_rate:n[`observability-head-sampling-rate`],logs:{destinations:n[`observability-logs-destinations`],enabled:n[`observability-logs-enabled`],head_sampling_rate:n[`observability-logs-head-sampling-rate`],invocation_logs:n[`observability-logs-invocation-logs`],persist:n[`observability-logs-persist`]},traces:{destinations:n[`observability-traces-destinations`],enabled:n[`observability-traces-enabled`],head_sampling_rate:n[`observability-traces-head-sampling-rate`],persist:n[`observability-traces-persist`],propagation_policy:h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}},subdomain:{enabled:n[`subdomain-enabled`],previews_enabled:n[`subdomain-previews-enabled`]},tags:n.tags}):l(n.body)});return}let r=await c(n),a=n.local?_:await i(r);if(n.accountId=a,n.body){let e=l(n.body);f(await m(`Creating`,async()=>r.workers.beta.workers.create({...e,account_id:a})),{successLabel:`Created`});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 e(`name`,`Name of the Worker.`)),n.tags===void 0)throw Error(`--tags is required (or pass --body with this field set).`);let o=d({logpush:n.logpush,name:h(n.name,`name`,`text`),observability:{enabled:n[`observability-enabled`],head_sampling_rate:n[`observability-head-sampling-rate`],logs:{destinations:n[`observability-logs-destinations`],enabled:n[`observability-logs-enabled`],head_sampling_rate:n[`observability-logs-head-sampling-rate`],invocation_logs:n[`observability-logs-invocation-logs`],persist:n[`observability-logs-persist`]},traces:{destinations:n[`observability-traces-destinations`],enabled:n[`observability-traces-enabled`],head_sampling_rate:n[`observability-traces-head-sampling-rate`],persist:n[`observability-traces-persist`],propagation_policy:h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}},subdomain:{enabled:n[`subdomain-enabled`],previews_enabled:n[`subdomain-previews-enabled`]},tags:n.tags});f(await m(`Creating`,async()=>r.workers.beta.workers.create({...o,account_id:a})),{successLabel:`Created`})}};function A(e){return e.positional(`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})}const j={command:`delete <worker-id>`,describe:`Delete a Worker and all its associated resources (versions, deployments, etc.).`,builder:A,handler:async e=>{if(e.dryRun){p({command:`cf workers beta workers delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/workers/${e[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(e[`worker-id`]))}`,pathParams:{"worker-id":String(e[`worker-id`]??``)},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
3
|
+
`);return}f(await m(`Deleting`,async()=>n.workers.beta.workers.delete({account_id:r,worker_id:e[`worker-id`]})),{successLabel:`Deleted`})}};function M(e){return e.positional(`worker-id`,{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.`}).option(`name`,{type:`string`,description:`Name of the Worker.`}).option(`observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`}).option(`observability-head-sampling-rate`,{type:`number`,description:`The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).`}).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.`}).option(`observability-logs-head-sampling-rate`,{type:`number`,description:`The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).`}).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.`}).option(`observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`}).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%).`}).option(`observability-traces-persist`,{type:`boolean`,description:`Whether trace persistence is enabled for the Worker.`}).option(`observability-traces-propagation-policy`,{type:`string`,description:`Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. "authenticated" (default) honors inbound trace context only when accompanied by a valid trace auth token. "accept" unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.`,choices:[`authenticated`,`accept`]}).option(`subdomain-enabled`,{type:`boolean`,description:`Whether the *.workers.dev subdomain is enabled for the Worker.`}).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`})}const N={command:`edit <worker-id>`,describe:`Perform a partial update on a Worker, where omitted properties are left unchanged from their current values.`,builder:M,handler:async n=>{if(n.dryRun){p({command:`cf workers beta workers edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/workers/${n[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(n[`worker-id`]))}`,pathParams:{"worker-id":String(n[`worker-id`]??``)},bodyKind:`json`,body:n.body===void 0?d({logpush:n.logpush,name:h(n.name,`name`,`text`),observability:{enabled:n[`observability-enabled`],head_sampling_rate:n[`observability-head-sampling-rate`],logs:{destinations:n[`observability-logs-destinations`],enabled:n[`observability-logs-enabled`],head_sampling_rate:n[`observability-logs-head-sampling-rate`],invocation_logs:n[`observability-logs-invocation-logs`],persist:n[`observability-logs-persist`]},traces:{destinations:n[`observability-traces-destinations`],enabled:n[`observability-traces-enabled`],head_sampling_rate:n[`observability-traces-head-sampling-rate`],persist:n[`observability-traces-persist`],propagation_policy:h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}},subdomain:{enabled:n[`subdomain-enabled`],previews_enabled:n[`subdomain-previews-enabled`]},tags:n.tags}):l(n.body)});return}let r=await c(n),a=n.local?_:await i(r);if(n.accountId=a,n.file){let e=g(n.file);f(await m(`Updating`,async()=>s(r,`PATCH`,`/accounts/${a}/workers/workers/${encodeURIComponent(String(n[`worker-id`]))}`,{body:e,headers:{"Content-Type":`application/merge-patch+json`}})),{successLabel:`Updated`});return}if(n.body){let e=l(n.body);f(await m(`Updating`,async()=>s(r,`PATCH`,`/accounts/${a}/workers/workers/${encodeURIComponent(String(n[`worker-id`]))}`,{body:e})),{successLabel:`Updated`});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 e(`name`,`Name of the Worker.`)),n.tags===void 0)throw Error(`--tags is required (or pass --body with this field set).`);let o={};n.logpush!==void 0&&u(o,[`logpush`],n.logpush),n.name!==void 0&&u(o,[`name`],h(n.name,`name`,`text`)),n[`observability-enabled`]!==void 0&&u(o,[`observability`,`enabled`],n[`observability-enabled`]),n[`observability-head-sampling-rate`]!==void 0&&u(o,[`observability`,`head_sampling_rate`],n[`observability-head-sampling-rate`]),n[`observability-logs-destinations`]!==void 0&&u(o,[`observability`,`logs`,`destinations`],n[`observability-logs-destinations`]),n[`observability-logs-enabled`]!==void 0&&u(o,[`observability`,`logs`,`enabled`],n[`observability-logs-enabled`]),n[`observability-logs-head-sampling-rate`]!==void 0&&u(o,[`observability`,`logs`,`head_sampling_rate`],n[`observability-logs-head-sampling-rate`]),n[`observability-logs-invocation-logs`]!==void 0&&u(o,[`observability`,`logs`,`invocation_logs`],n[`observability-logs-invocation-logs`]),n[`observability-logs-persist`]!==void 0&&u(o,[`observability`,`logs`,`persist`],n[`observability-logs-persist`]),n[`observability-traces-destinations`]!==void 0&&u(o,[`observability`,`traces`,`destinations`],n[`observability-traces-destinations`]),n[`observability-traces-enabled`]!==void 0&&u(o,[`observability`,`traces`,`enabled`],n[`observability-traces-enabled`]),n[`observability-traces-head-sampling-rate`]!==void 0&&u(o,[`observability`,`traces`,`head_sampling_rate`],n[`observability-traces-head-sampling-rate`]),n[`observability-traces-persist`]!==void 0&&u(o,[`observability`,`traces`,`persist`],n[`observability-traces-persist`]),n[`observability-traces-propagation-policy`]!==void 0&&u(o,[`observability`,`traces`,`propagation_policy`],h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)),n[`subdomain-enabled`]!==void 0&&u(o,[`subdomain`,`enabled`],n[`subdomain-enabled`]),n[`subdomain-previews-enabled`]!==void 0&&u(o,[`subdomain`,`previews_enabled`],n[`subdomain-previews-enabled`]),n.tags!==void 0&&u(o,[`tags`],n.tags),f(await m(`Updating`,async()=>s(r,`PATCH`,`/accounts/${a}/workers/workers/${encodeURIComponent(String(n[`worker-id`]))}`,{body:Object.keys(o).length>0?o:void 0})),{successLabel:`Updated`})}};function P(e){return e.positional(`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})}const F={command:`get <worker-id>`,describe:`Get details about a specific Worker.`,builder:P,handler:async e=>{if(e.dryRun){p({command:`cf workers beta workers get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/workers/${e[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(e[`worker-id`]))}`,pathParams:{"worker-id":String(e[`worker-id`]??``)},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Loading`,async()=>n.workers.beta.workers.get({account_id:r,worker_id:e[`worker-id`]})),{successLabel:`Loaded`})}};function I(e){return 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`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const L={command:`list`,describe:`List all Workers for an account.`,builder:v(I),handler:async e=>{let n={page:e.page,per_page:e[`per-page`],order_by:e[`order-by`],order:e.order};if(e.dryRun){p({command:`cf workers beta workers list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/workers`,pathParams:{},query:n,bodyKind:`none`});return}let r=await c(e),a=e.local?_:await i(r);e.accountId=a,f(await m(`Loading`,async()=>r.workers.beta.workers.list({account_id:a,...n})),{successLabel:`Loaded`})}};function R(e){return e.positional(`worker-id`,{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.`}).option(`name`,{type:`string`,description:`Name of the Worker.`}).option(`observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`}).option(`observability-head-sampling-rate`,{type:`number`,description:`The sampling rate for observability. From 0 to 1 (1 = 100%, 0.1 = 10%).`}).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.`}).option(`observability-logs-head-sampling-rate`,{type:`number`,description:`The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%).`}).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.`}).option(`observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`}).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%).`}).option(`observability-traces-persist`,{type:`boolean`,description:`Whether trace persistence is enabled for the Worker.`}).option(`observability-traces-propagation-policy`,{type:`string`,description:`Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. "authenticated" (default) honors inbound trace context only when accompanied by a valid trace auth token. "accept" unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.`,choices:[`authenticated`,`accept`]}).option(`subdomain-enabled`,{type:`boolean`,description:`Whether the *.workers.dev subdomain is enabled for the Worker.`}).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.`})}const z={command:`update <worker-id>`,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:R,handler:async n=>{if(n.dryRun){p({command:`cf workers beta workers update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/workers/${n[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(n[`worker-id`]))}`,pathParams:{"worker-id":String(n[`worker-id`]??``)},bodyKind:`json`,body:n.body===void 0?d({logpush:n.logpush,name:h(n.name,`name`,`text`),observability:{enabled:n[`observability-enabled`],head_sampling_rate:n[`observability-head-sampling-rate`],logs:{destinations:n[`observability-logs-destinations`],enabled:n[`observability-logs-enabled`],head_sampling_rate:n[`observability-logs-head-sampling-rate`],invocation_logs:n[`observability-logs-invocation-logs`],persist:n[`observability-logs-persist`]},traces:{destinations:n[`observability-traces-destinations`],enabled:n[`observability-traces-enabled`],head_sampling_rate:n[`observability-traces-head-sampling-rate`],persist:n[`observability-traces-persist`],propagation_policy:h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}},subdomain:{enabled:n[`subdomain-enabled`],previews_enabled:n[`subdomain-previews-enabled`]},tags:n.tags}):l(n.body)});return}let r=await c(n),a=n.local?_:await i(r);if(n.accountId=a,n.body){let e=l(n.body);f(await m(`Updating`,async()=>r.workers.beta.workers.update({...e,account_id:a,worker_id:n[`worker-id`]})),{successLabel:`Updated`});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 e(`name`,`Name of the Worker.`)),n.tags===void 0)throw Error(`--tags is required (or pass --body with this field set).`);let o=d({logpush:n.logpush,name:h(n.name,`name`,`text`),observability:{enabled:n[`observability-enabled`],head_sampling_rate:n[`observability-head-sampling-rate`],logs:{destinations:n[`observability-logs-destinations`],enabled:n[`observability-logs-enabled`],head_sampling_rate:n[`observability-logs-head-sampling-rate`],invocation_logs:n[`observability-logs-invocation-logs`],persist:n[`observability-logs-persist`]},traces:{destinations:n[`observability-traces-destinations`],enabled:n[`observability-traces-enabled`],head_sampling_rate:n[`observability-traces-head-sampling-rate`],persist:n[`observability-traces-persist`],propagation_policy:h(n[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}},subdomain:{enabled:n[`subdomain-enabled`],previews_enabled:n[`subdomain-previews-enabled`]},tags:n.tags});f(await m(`Updating`,async()=>r.workers.beta.workers.update({...o,account_id:a,worker_id:n[`worker-id`]})),{successLabel:`Updated`})}};function B(e){return e.positional(`worker-id`,{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.`}).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(`cache-options-cross-version-cache`,{type:`boolean`,description:`Whether cached responses are shared across Worker version
|
|
4
4
|
uploads. This is independent of \`enabled\`. It can stay true
|
|
5
5
|
while caching is off, so the preference survives turning
|
|
6
6
|
caching off and back on.
|
|
7
|
-
`,default:!1}).option(`cache-options-enabled`,{type:`boolean`,description:`Whether caching is enabled for this Worker.`,default:!1}).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`])}const V={command:`create <worker-id>`,describe:`Create a new version.`,builder:B,handler:async
|
|
8
|
-
`);return}f(await m(`Deleting`,async()=>n.workers.beta.workers.versions.delete({account_id:r,worker_id:
|
|
9
|
-
`);return}f(await m(`Deleting`,async()=>n.workers.crawler.stripe.delete({account_id:r})),{successLabel:`Deleted`})}};function de(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const fe={command:`get`,describe:`Gets the stripe config for a crawler.`,builder:de,handler:async
|
|
10
|
-
`);return}f(await m(`Deleting`,async()=>n.workers.deployments.delete({account_id:
|
|
11
|
-
`);return}f(await m(`Deleting`,async()=>n.workers.domains.delete({account_id:r,domain_id:
|
|
12
|
-
`);return}f(await m(`Deleting`,async()=>n.workers.publisher.stripe.delete({account_id:r})),{successLabel:`Deleted`})}};function Ve(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const He={command:`get`,describe:`Gets the stripe config for a publisher.`,builder:Ve,handler:async
|
|
13
|
-
`);return}f(await m(`Deleting`,async()=>t.workers.routes.delete({zone_id:n,route_id:e[`route-id`]})),{successLabel:`Deleted`})}};function $e(e){return e.positional(`route-id`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const et={command:`get <route-id>`,describe:`Returns information about a route, including URL pattern and Worker.`,builder:$e,handler:async e=>{if(e.dryRun){p({command:`cf workers routes get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/workers/routes/${e[`route-id`]==null?`<route-id>`:encodeURIComponent(String(e[`route-id`]))}`,pathParams:{"route-id":String(e[`route-id`]??``),"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await s(e),n=await r({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,f(await m(`Loading`,async()=>t.workers.routes.get({zone_id:n,route_id:e[`route-id`]})),{successLabel:`Loaded`})}};function tt(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const nt={command:`list`,describe:`Returns routes for a zone.`,builder:tt,handler:async e=>{if(e.dryRun){p({command:`cf workers routes list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/workers/routes`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await s(e),n=await r({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,f(await m(`Loading`,async()=>t.workers.routes.list({zone_id:n})),{successLabel:`Loaded`})}};function rt(e){return e.positional(`route-id`,{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)`})}const it={command:`update <route-id>`,describe:`Updates the URL pattern or Worker associated with a route.`,builder:rt,handler:async e=>{if(e.dryRun){p({command:`cf workers routes update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/workers/routes/${e[`route-id`]==null?`<route-id>`:encodeURIComponent(String(e[`route-id`]))}`,pathParams:{"route-id":String(e[`route-id`]??``),"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?d({pattern:h(e.pattern,`pattern`,`text`),script:h(e.script,`script`,`text`)}):l(e.body)});return}let n=await s(e),i=await r({zone:e.zone},n,{quiet:e.quiet});if(e.zoneId=i,e.body){let t=l(e.body);f(await m(`Updating`,async()=>n.workers.routes.update({body:t,zone_id:i,route_id:e[`route-id`]})),{successLabel:`Updated`});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 a=d({pattern:h(e.pattern,`pattern`,`text`),script:h(e.script,`script`,`text`)});f(await m(`Updating`,async()=>n.workers.routes.update({body:a,zone_id:i,route_id:e[`route-id`]})),{successLabel:`Updated`})}},at={command:`routes`,describe:`Operations for routes`,builder:e=>e.command(Xe).command(Qe).command(et).command(nt).command(it).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ot(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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)`})}const st={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:ot,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts assets upload create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/assets-upload-session`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:l(t.body)});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});if(t.worker=i,t.body){let e=l(t.body);f(await m(`Creating`,async()=>n.workers.scripts.assets.upload.create({body:e,account_id:r,script_name:i})),{successLabel:`Created`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},ct={command:`upload`,describe:`Operations for scripts.assets.upload`,builder:e=>e.command(st).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},lt={command:`assets`,describe:`Operations for scripts.assets`,builder:e=>e.command(ct).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ut(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const dt={command:`get`,describe:`Fetch script content only.`,builder:ut,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts content get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/content/v2`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});t.worker=i,f(await m(`Loading`,async()=>n.workers.scripts.content.get({account_id:r,script_name:i})),{successLabel:`Loaded`})}};function ft(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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.`})}const pt={command:`update`,describe:`Put script content without touching config or metadata.`,builder:ft,handler:async t=>{let n={};if(t[`cf-worker-body-part`]!==void 0&&(n[`CF-WORKER-BODY-PART`]=String(t[`cf-worker-body-part`])),t[`cf-worker-main-module-part`]!==void 0&&(n[`CF-WORKER-MAIN-MODULE-PART`]=String(t[`cf-worker-main-module-part`])),t.dryRun){p({command:`cf workers scripts content update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/content`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`multipart`,body:{body:t.body,file:t.file,files:t.files,metadata:t.metadata}});return}let r=await s(t),i=t.local?_:await a(r);t.accountId=i;let l=c({scriptName:t.worker});if(t.worker=l,t.file!==void 0||t.body!==void 0||t.files!==void 0||t.metadata!==void 0){let e=new FormData;if(t.file){let n=g(t.file);e.append(`file`,new Blob([n]),t.file.split(/[\\/]/).filter(Boolean).pop())}else t.body!==void 0&&e.append(`file`,t.body);if(t.files!==void 0){let n=typeof t.files==`string`?h(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`?h(t.metadata,`metadata`,`text`):t.metadata;e.append(`metadata`,typeof n==`string`?n:JSON.stringify(n))}f(await m(`Updating`,async()=>o(r,`PUT`,`/accounts/${i}/workers/scripts/${l}/content`,{body:e,headers:Object.keys(n).length>0?n:void 0})),{successLabel:`Updated`});return}if(t.body){let e=h(t.body,`body`,`binary`);f(await m(`Updating`,async()=>o(r,`PUT`,`/accounts/${i}/workers/scripts/${l}/content`,{body:e,headers:{"Content-Type":`multipart/form-data`,...n}})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},mt={command:`content`,describe:`Operations for scripts.content`,builder:e=>e.command(dt).command(pt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ht(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const gt={command:`delete`,describe:`Delete your worker. This call has no response body on a successful delete.`,builder:ht,handler:async t=>{let n={force:t.force};if(t.dryRun){p({command:`cf workers scripts delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}`,pathParams:{"script-name":String(t[`script-name`]??``)},query:n,bodyKind:`none`});return}let r=await s(t),o=t.local?_:await a(r);t.accountId=o;let l=c({scriptName:t.worker});if(t.worker=l,!await i({force:!!t.force})){process.stderr.write(`Aborted.
|
|
14
|
-
`);return}f(await m(`Deleting`,async()=>r.workers.scripts.delete({account_id:o,script_name:l,...n})),{successLabel:`Deleted`})}};function _t(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const vt={command:`get`,describe:`Fetch raw script content for your worker. Note this is the original script content, not JSON encoded.`,builder:_t,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});t.worker=i;let o=await m(`Loading`,async()=>te(`/accounts/${r}/workers/scripts/${i}`,{method:`GET`,localEndpoint:t.local?t.localEndpoint:void 0}));ee(t.text===!0?o.toString(`utf-8`):o)}};function yt(e){return e.option(`tags`,{type:`string`,description:`Filter scripts by tags. Format: comma-separated list of tag:allowed pairs where allowed is 'yes' or 'no'.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const bt={command:`list`,describe:`Fetch a list of uploaded workers.`,builder:yt,handler:async t=>{let n={tags:t.tags};if(t.dryRun){p({command:`cf workers scripts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts`,pathParams:{},query:n,bodyKind:`none`});return}let r=await s(t),i=t.local?_:await a(r);t.accountId=i,f(await m(`Loading`,async()=>r.workers.scripts.list({account_id:i,...n})),{successLabel:`Loaded`})}};function xt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const St={command:`get`,describe:`Fetches Cron Triggers for a Worker.`,builder:xt,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts schedules get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/schedules`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});t.worker=i,f(await m(`Loading`,async()=>n.workers.scripts.schedules.get({account_id:r,script_name:i})),{successLabel:`Loaded`})}};function Ct(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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)`})}const wt={command:`update`,describe:`Updates Cron Triggers for a Worker.`,builder:Ct,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts schedules update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/schedules`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`json`,body:t.body===void 0?void 0:l(t.body)});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});if(t.worker=i,t.body){let e=l(t.body);f(await m(`Updating`,async()=>n.workers.scripts.schedules.update({body:e,account_id:r,script_name:i})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Tt={command:`schedules`,describe:`Operations for scripts.schedules`,builder:e=>e.command(St).command(wt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Et(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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`})}const Dt={command:`edit`,describe:`Patch metadata or config, such as bindings or usage model.`,builder:Et,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts script-and-version-settings edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/settings`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`multipart`,body:{body:t.body,file:t.file,settings:t.settings}});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});if(t.worker=i,t.file!==void 0||t.body!==void 0||t.settings!==void 0){let e=new FormData;if(t.file){let n=g(t.file);e.append(`file`,new Blob([n]),t.file.split(/[\\/]/).filter(Boolean).pop())}else t.body!==void 0&&e.append(`file`,t.body);if(t.settings!==void 0){let n=typeof t.settings==`string`?h(t.settings,`settings`,`text`):t.settings;e.append(`settings`,typeof n==`string`?n:JSON.stringify(n))}f(await m(`Updating`,async()=>o(n,`PATCH`,`/accounts/${r}/workers/scripts/${i}/settings`,{body:e})),{successLabel:`Updated`});return}if(t.body){let e=h(t.body,`body`,`binary`);f(await m(`Updating`,async()=>o(n,`PATCH`,`/accounts/${r}/workers/scripts/${i}/settings`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Updated`});return}f(await m(`Updating`,async()=>n.workers.scripts.scriptAndVersionSettings.edit({account_id:r,script_name:i})),{successLabel:`Updated`})}};function Ot(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const kt={command:`get`,describe:`Get metadata and config, such as bindings or usage model.`,builder:Ot,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts script-and-version-settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/settings`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});t.worker=i,f(await m(`Loading`,async()=>n.workers.scripts.scriptAndVersionSettings.get({account_id:r,script_name:i})),{successLabel:`Loaded`})}},At={command:`script-and-version-settings`,describe:`Operations for scripts.script-and-version-settings`,builder:e=>e.command(Dt).command(kt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function jt(e){return 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.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Mt={command:`search`,describe:`Search for Workers in an account.`,builder:v(jt),handler:async t=>{let n={name:t.name,id:t.id,order_by:t[`order-by`],page:t.page,per_page:t[`per-page`]};if(t.dryRun){p({command:`cf workers scripts search`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts-search`,pathParams:{},query:n,bodyKind:`none`});return}let r=await s(t),i=t.local?_:await a(r);t.accountId=i,f(await m(`Loading`,async()=>r.workers.scripts.search({account_id:i,...n})),{successLabel:`Loaded`})}};function Nt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,description:`Name of the script, used in URLs and route configuration.`}).option(`logpush`,{type:`boolean`,description:`Whether Logpush is turned on for the Worker.`}).option(`observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`}).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.`}).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.`}).option(`observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`}).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.`}).option(`observability-traces-propagation-policy`,{type:`string`,description:`Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. "authenticated" (default) honors inbound trace context only when accompanied by a valid trace auth token. "accept" unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.`,choices:[`authenticated`,`accept`]}).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})}const Pt={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:Nt,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts settings edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/script-settings`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`json`,body:t.body===void 0?d({logpush:t.logpush,observability:{enabled:t[`observability-enabled`],head_sampling_rate:t[`observability-head-sampling-rate`],logs:{destinations:t[`observability-logs-destinations`],enabled:t[`observability-logs-enabled`],head_sampling_rate:t[`observability-logs-head-sampling-rate`],invocation_logs:t[`observability-logs-invocation-logs`],persist:t[`observability-logs-persist`]},traces:{destinations:t[`observability-traces-destinations`],enabled:t[`observability-traces-enabled`],head_sampling_rate:t[`observability-traces-head-sampling-rate`],persist:t[`observability-traces-persist`],propagation_policy:h(t[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}}}):l(t.body)});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});if(t.worker=i,t.body){let e=l(t.body);f(await m(`Updating`,async()=>n.workers.scripts.settings.edit({body:e,account_id:r,script_name:i})),{successLabel:`Updated`});return}let o=d({logpush:t.logpush,observability:{enabled:t[`observability-enabled`],head_sampling_rate:t[`observability-head-sampling-rate`],logs:{destinations:t[`observability-logs-destinations`],enabled:t[`observability-logs-enabled`],head_sampling_rate:t[`observability-logs-head-sampling-rate`],invocation_logs:t[`observability-logs-invocation-logs`],persist:t[`observability-logs-persist`]},traces:{destinations:t[`observability-traces-destinations`],enabled:t[`observability-traces-enabled`],head_sampling_rate:t[`observability-traces-head-sampling-rate`],persist:t[`observability-traces-persist`],propagation_policy:h(t[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}}});f(await m(`Updating`,async()=>n.workers.scripts.settings.edit({body:o,account_id:r,script_name:i})),{successLabel:`Updated`})}};function Ft(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const It={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:Ft,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/script-settings`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});t.worker=i,f(await m(`Loading`,async()=>n.workers.scripts.settings.get({account_id:r,script_name:i})),{successLabel:`Loaded`})}},Lt={command:`settings`,describe:`Operations for scripts.settings`,builder:e=>e.command(Pt).command(It).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Rt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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)`})}const zt={command:`create`,describe:`Enable or disable the Worker on the workers.dev subdomain.`,builder:Rt,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts subdomain create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/subdomain`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`json`,body:t.body===void 0?d({enabled:t.enabled,previews_enabled:t[`previews-enabled`]}):l(t.body)});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});if(t.worker=i,t.body){let e=l(t.body);f(await m(`Creating`,async()=>n.workers.scripts.subdomain.create({...e,account_id:r,script_name:i})),{successLabel:`Created`});return}if(t.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);let o=d({enabled:t.enabled,previews_enabled:t[`previews-enabled`]});f(await m(`Creating`,async()=>n.workers.scripts.subdomain.create({...o,account_id:r,script_name:i})),{successLabel:`Created`})}};function Bt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const Vt={command:`delete`,describe:`Disable all workers.dev subdomains for a Worker.`,builder:Bt,handler:async t=>{if(t.dryRun){p({command:`cf workers scripts subdomain delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/subdomain`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let o=c({scriptName:t.worker});if(t.worker=o,!await i({force:!!t.force})){process.stderr.write(`Aborted.
|
|
15
|
-
`);return}f(await m(`Deleting`,async()=>n.workers.scripts.subdomain.delete({account_id:
|
|
16
|
-
`);return}f(await m(`Deleting`,async()=>n.workers.scripts.tail.delete({account_id:
|
|
17
|
-
`);return}f(await m(`Deleting`,async()=>r.workers.secrets.delete({account_id:o,script_name:l,secret_name:t[`secret-name`],...n})),{successLabel:`Deleted`})}};function sn(e){return e.positional(`secret-name`,{type:`string`,description:`A JavaScript variable name for the secret binding.`,demandOption:!0}).option(`worker`,{type:`string`,alias:`script-name`,description:`Name of the script, used in URLs and route configuration.`}).option(`url-encoded`,{type:`boolean`,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})}const cn={command:`get <secret-name>`,describe:`Get a given secret binding (value omitted) on a script.`,builder:sn,handler:async t=>{let n={url_encoded:t[`url-encoded`]};if(t.dryRun){p({command:`cf workers secrets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/secrets/${t[`secret-name`]==null?`<secret-name>`:encodeURIComponent(String(t[`secret-name`]))}`,pathParams:{"script-name":String(t[`script-name`]??``),"secret-name":String(t[`secret-name`]??``)},query:n,bodyKind:`none`});return}let r=await s(t),i=t.local?_:await a(r);t.accountId=i;let o=c({scriptName:t.worker});t.worker=o,f(await m(`Loading`,async()=>r.workers.secrets.get({account_id:i,script_name:o,secret_name:t[`secret-name`],...n})),{successLabel:`Loaded`})}};function ln(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const un={command:`list`,describe:`List secrets bound to a script.`,builder:ln,handler:async t=>{if(t.dryRun){p({command:`cf workers secrets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/secrets`,pathParams:{"script-name":String(t[`script-name`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});t.worker=i,f(await m(`Loading`,async()=>n.workers.secrets.list({account_id:r,script_name:i})),{successLabel:`Loaded`})}};function dn(e){return e.positional(`name`,{type:`string`,description:`A JavaScript variable name for the binding.`,demandOption:!0}).option(`worker`,{type:`string`,alias:`script-name`,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`])}const fn={command:`update <name>`,describe:`Add a secret to a script.`,builder:dn,handler:async r=>{if(r.dryRun){p({command:`cf workers secrets update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${r.worker??`<worker>`}/secrets`,pathParams:{"script-name":String(r[`script-name`]??``)},bodyKind:`json`,body:r.body===void 0?d({text:h(r.text,`text`,`text`),type:h(r.type,`type`,`text`),format:h(r.format,`format`,`text`),key_base64:h(r[`key-base64`],`key-base64`,`text`),usages:r.usages,name:r.name}):l(r.body)});return}let i=await s(r),o=r.local?_:await a(i);r.accountId=o;let u=c({scriptName:r.worker});if(r.worker=u,r.body){let e=l(r.body);f(await m(`Updating`,async()=>i.workers.secrets.update({body:e,account_id:o,script_name:u})),{successLabel:`Updated`});return}r.type===void 0&&(r.type=await n(`type`,`The kind of resource that the binding provides.`,[`secret_text`,`secret_key`])),r.type===`secret_text`&&r.text===void 0&&(r.text=await t(`text`,`The secret value to use.`,{kind:`secret`,question:`Enter value for --text`})),r.type===`secret_key`&&r.format===void 0&&(r.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 g=d({text:h(r.text,`text`,`text`),type:h(r.type,`type`,`text`),format:h(r.format,`format`,`text`),key_base64:h(r[`key-base64`],`key-base64`,`text`),usages:r.usages,name:r.name});f(await m(`Updating`,async()=>i.workers.secrets.update({body:g,account_id:o,script_name:u})),{successLabel:`Updated`})}},pn={command:`secrets`,describe:`Operations for secrets`,builder:e=>e.command(on).command(cn).command(un).command(fn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function mn(e){return e.positional(`environment-name`,{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(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const hn={command:`get <environment-name>`,describe:`Get script content from a worker with an environment.`,builder:mn,handler:async t=>{if(t.dryRun){p({command:`cf workers services environments content get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/services/${t[`service-name`]==null?`<service-name>`:encodeURIComponent(String(t[`service-name`]))}/environments/${t[`environment-name`]==null?`<environment-name>`:encodeURIComponent(String(t[`environment-name`]))}/content`,pathParams:{"service-name":String(t[`service-name`]??``),"environment-name":String(t[`environment-name`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r,f(await m(`Loading`,async()=>n.workers.services.environments.content.get({account_id:r,service_name:t[`service-name`],environment_name:t[`environment-name`]})),{successLabel:`Loaded`})}};function gn(e){return e.positional(`environment-name`,{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.`})}const _n={command:`update <environment-name>`,describe:`Put script content from a worker with an environment.`,builder:gn,handler:async t=>{let n={};if(t[`cf-worker-body-part`]!==void 0&&(n[`CF-WORKER-BODY-PART`]=String(t[`cf-worker-body-part`])),t[`cf-worker-main-module-part`]!==void 0&&(n[`CF-WORKER-MAIN-MODULE-PART`]=String(t[`cf-worker-main-module-part`])),t.dryRun){p({command:`cf workers services environments content update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/services/${t[`service-name`]==null?`<service-name>`:encodeURIComponent(String(t[`service-name`]))}/environments/${t[`environment-name`]==null?`<environment-name>`:encodeURIComponent(String(t[`environment-name`]))}/content`,pathParams:{"service-name":String(t[`service-name`]??``),"environment-name":String(t[`environment-name`]??``)},bodyKind:`multipart`,body:{body:t.body,file:t.file,files:t.files,metadata:t.metadata}});return}let r=await s(t),i=t.local?_:await a(r);if(t.accountId=i,t.file!==void 0||t.body!==void 0||t.files!==void 0||t.metadata!==void 0){let e=new FormData;if(t.file){let n=g(t.file);e.append(`file`,new Blob([n]),t.file.split(/[\\/]/).filter(Boolean).pop())}else t.body!==void 0&&e.append(`file`,t.body);if(t.files!==void 0){let n=typeof t.files==`string`?h(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`?h(t.metadata,`metadata`,`text`):t.metadata;e.append(`metadata`,typeof n==`string`?n:JSON.stringify(n))}f(await m(`Updating`,async()=>o(r,`PUT`,`/accounts/${i}/workers/services/${encodeURIComponent(String(t[`service-name`]))}/environments/${encodeURIComponent(String(t[`environment-name`]))}/content`,{body:e,headers:Object.keys(n).length>0?n:void 0})),{successLabel:`Updated`});return}if(t.body){let e=h(t.body,`body`,`binary`);f(await m(`Updating`,async()=>o(r,`PUT`,`/accounts/${i}/workers/services/${encodeURIComponent(String(t[`service-name`]))}/environments/${encodeURIComponent(String(t[`environment-name`]))}/content`,{body:e,headers:{"Content-Type":`multipart/form-data`,...n}})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},vn={command:`content`,describe:`Operations for services.environments.content`,builder:e=>e.command(hn).command(_n).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function yn(e){return e.positional(`environment-name`,{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.`}).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.`}).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.`}).option(`result-observability-traces-propagation-policy`,{type:`string`,description:`Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. "authenticated" (default) honors inbound trace context only when accompanied by a valid trace auth token. "accept" unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.`,choices:[`authenticated`,`accept`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const bn={command:`edit <environment-name>`,describe:`Patch script metadata, such as bindings.`,builder:yn,handler:async t=>{if(t.dryRun){p({command:`cf workers services environments settings edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/services/${t[`service-name`]==null?`<service-name>`:encodeURIComponent(String(t[`service-name`]))}/environments/${t[`environment-name`]==null?`<environment-name>`:encodeURIComponent(String(t[`environment-name`]))}/settings`,pathParams:{"service-name":String(t[`service-name`]??``),"environment-name":String(t[`environment-name`]??``)},bodyKind:`json`,body:t.body===void 0?d({success:t.success,result:{logpush:t[`result-logpush`],observability:{enabled:t[`result-observability-enabled`],head_sampling_rate:t[`result-observability-head-sampling-rate`],logs:{destinations:t[`result-observability-logs-destinations`],enabled:t[`result-observability-logs-enabled`],head_sampling_rate:t[`result-observability-logs-head-sampling-rate`],invocation_logs:t[`result-observability-logs-invocation-logs`],persist:t[`result-observability-logs-persist`]},traces:{destinations:t[`result-observability-traces-destinations`],enabled:t[`result-observability-traces-enabled`],head_sampling_rate:t[`result-observability-traces-head-sampling-rate`],persist:t[`result-observability-traces-persist`],propagation_policy:h(t[`result-observability-traces-propagation-policy`],`result-observability-traces-propagation-policy`,`text`)}}}}):l(t.body)});return}let n=await s(t),r=t.local?_:await a(n);if(t.accountId=r,t.body){let e=l(t.body);f(await m(`Updating`,async()=>n.workers.services.environments.settings.edit({...e,account_id:r,service_name:t[`service-name`],environment_name:t[`environment-name`]})),{successLabel:`Updated`});return}if(t.success===void 0)throw Error(`--success is required (or pass --body with this field set).`);if(t[`result-observability-enabled`]===void 0)throw Error(`--result-observability-enabled is required (or pass --body with this field set).`);if(t[`result-observability-logs-enabled`]===void 0)throw Error(`--result-observability-logs-enabled is required (or pass --body with this field set).`);if(t[`result-observability-logs-invocation-logs`]===void 0)throw Error(`--result-observability-logs-invocation-logs is required (or pass --body with this field set).`);let i=d({success:t.success,result:{logpush:t[`result-logpush`],observability:{enabled:t[`result-observability-enabled`],head_sampling_rate:t[`result-observability-head-sampling-rate`],logs:{destinations:t[`result-observability-logs-destinations`],enabled:t[`result-observability-logs-enabled`],head_sampling_rate:t[`result-observability-logs-head-sampling-rate`],invocation_logs:t[`result-observability-logs-invocation-logs`],persist:t[`result-observability-logs-persist`]},traces:{destinations:t[`result-observability-traces-destinations`],enabled:t[`result-observability-traces-enabled`],head_sampling_rate:t[`result-observability-traces-head-sampling-rate`],persist:t[`result-observability-traces-persist`],propagation_policy:h(t[`result-observability-traces-propagation-policy`],`result-observability-traces-propagation-policy`,`text`)}}}});f(await m(`Updating`,async()=>n.workers.services.environments.settings.edit({...i,account_id:r,service_name:t[`service-name`],environment_name:t[`environment-name`]})),{successLabel:`Updated`})}};function xn(e){return e.positional(`environment-name`,{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(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Sn={command:`get <environment-name>`,describe:`Get script settings from a worker with an environment.`,builder:xn,handler:async t=>{if(t.dryRun){p({command:`cf workers services environments settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/services/${t[`service-name`]==null?`<service-name>`:encodeURIComponent(String(t[`service-name`]))}/environments/${t[`environment-name`]==null?`<environment-name>`:encodeURIComponent(String(t[`environment-name`]))}/settings`,pathParams:{"service-name":String(t[`service-name`]??``),"environment-name":String(t[`environment-name`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r,f(await m(`Loading`,async()=>n.workers.services.environments.settings.get({account_id:r,service_name:t[`service-name`],environment_name:t[`environment-name`]})),{successLabel:`Loaded`})}},Cn={command:`settings`,describe:`Operations for services.environments.settings`,builder:e=>e.command(bn).command(Sn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},wn={command:`environments`,describe:`Operations for services.environments`,builder:e=>e.command(vn).command(Cn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Tn={command:`services`,describe:`Operations for services`,builder:e=>e.command(wn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function En(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const $={command:`delete`,describe:`Deletes a Workers subdomain for an account.`,builder:En,handler:async t=>{if(t.dryRun){p({command:`cf workers subdomains delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/subdomain`,pathParams:{},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);if(t.accountId=r,!await i({force:!!t.force})){process.stderr.write(`Aborted.
|
|
18
|
-
`);return}f(await m(`Deleting`,async()=>n.workers.subdomains.delete({account_id:r})),{successLabel:`Deleted`})}};function Dn(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const On={command:`get`,describe:`Returns a Workers subdomain for an account.`,builder:Dn,handler:async t=>{if(t.dryRun){p({command:`cf workers subdomains get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/subdomain`,pathParams:{},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r,f(await m(`Loading`,async()=>n.workers.subdomains.get({account_id:r})),{successLabel:`Loaded`})}};function kn(e){return 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)`})}const An={command:`update`,describe:`Creates a Workers subdomain for an account.`,builder:kn,handler:async n=>{if(n.dryRun){p({command:`cf workers subdomains update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/subdomain`,pathParams:{},bodyKind:`json`,body:n.body===void 0?d({subdomain:h(n.subdomain,`subdomain`,`text`)}):l(n.body)});return}let r=await s(n),i=n.local?_:await a(r);if(n.accountId=i,n.body){let e=l(n.body);f(await m(`Updating`,async()=>r.workers.subdomains.update({body:e,account_id:i})),{successLabel:`Updated`});return}n.subdomain===void 0&&(n.subdomain=await t(`subdomain`,`The subdomain field`));let o=d({subdomain:h(n.subdomain,`subdomain`,`text`)});f(await m(`Updating`,async()=>r.workers.subdomains.update({body:o,account_id:i})),{successLabel:`Updated`})}},jn={command:`subdomains`,describe:`Operations for subdomains`,builder:e=>e.command($).command(On).command(An).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Mn(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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)`}).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.`})}const Nn={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:Mn,handler:async t=>{let n={bindings_inherit:t[`bindings-inherit`]};if(t.dryRun){p({command:`cf workers versions create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/versions`,pathParams:{"script-name":String(t[`script-name`]??``)},query:n,bodyKind:`multipart`,body:{body:t.body,file:t.file,files:t.files,metadata:t.metadata}});return}let r=await s(t),i=t.local?_:await a(r);t.accountId=i;let l=c({scriptName:t.worker});if(t.worker=l,t.file!==void 0||t.body!==void 0||t.files!==void 0||t.metadata!==void 0){let e=new FormData;if(t.file){let n=g(t.file);e.append(`file`,new Blob([n]),t.file.split(/[\\/]/).filter(Boolean).pop())}else t.body!==void 0&&e.append(`file`,t.body);if(t.files!==void 0){let n=typeof t.files==`string`?h(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`?h(t.metadata,`metadata`,`text`):t.metadata;e.append(`metadata`,typeof n==`string`?n:JSON.stringify(n))}f(await m(`Creating`,async()=>o(r,`POST`,`/accounts/${i}/workers/scripts/${l}/versions`,{body:e})),{successLabel:`Created`});return}if(t.body){let e=h(t.body,`body`,`binary`),a=new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();f(await m(`Creating`,async()=>o(r,`POST`,`/accounts/${i}/workers/scripts/${l}/versions${a?`?`+a:``}`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function Pn(e){return e.positional(`version-id`,{type:`string`,description:`Version ID`,demandOption:!0}).option(`worker`,{type:`string`,alias:`script-name`,description:`Name of the script.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Fn={command:`get <version-id>`,describe:`Retrieves detailed information about a specific version of a Workers script.`,builder:Pn,handler:async t=>{if(t.dryRun){p({command:`cf workers versions get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/versions/${t[`version-id`]==null?`<version-id>`:encodeURIComponent(String(t[`version-id`]))}`,pathParams:{"script-name":String(t[`script-name`]??``),"version-id":String(t[`version-id`]??``)},bodyKind:`none`});return}let n=await s(t),r=t.local?_:await a(n);t.accountId=r;let i=c({scriptName:t.worker});t.worker=i,f(await m(`Loading`,async()=>n.workers.versions.get({account_id:r,script_name:i,version_id:t[`version-id`]})),{successLabel:`Loaded`})}};function In(e){return e.option(`worker`,{type:`string`,alias:`script-name`,description:`Name of the script.`}).option(`deployable`,{type:`boolean`,description:`Only return versions that can be used in a deployment. Ignores pagination.`}).option(`page`,{type:`number`,description:`Current page.`}).option(`per-page`,{type:`number`,description:`Items per-page.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ln={command:`list`,describe:`List of Worker Versions. The first version in the list is the latest version.`,builder:In,handler:async t=>{let n={deployable:t.deployable,page:t.page,per_page:t[`per-page`]};if(t.dryRun){p({command:`cf workers versions list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/workers/scripts/${t.worker??`<worker>`}/versions`,pathParams:{"script-name":String(t[`script-name`]??``)},query:n,bodyKind:`none`});return}let r=await s(t),i=t.local?_:await a(r);t.accountId=i;let o=c({scriptName:t.worker});t.worker=o,f(await m(`Loading`,async()=>r.workers.versions.list({account_id:i,script_name:o,...n})),{successLabel:`Loaded`})}},Rn={command:`versions`,describe:`Operations for versions`,builder:e=>e.command(Nn).command(Fn).command(Ln).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function zn(e){return 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`})}const Bn={command:`edit`,describe:`Allows an account admin to set the can_be_enabled setting on a list of zones.`,builder:zn,handler:async t=>{if(t.dryRun){p({command:`cf workers zones-can-be-enabled edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/pay-per-crawl/zones_can_be_enabled`,pathParams:{},bodyKind:`json`,body:t.body===void 0?void 0:l(t.body)});return}let n=await s(t),r=t.local?_:await a(n);if(t.accountId=r,t.body){let e=l(t.body);f(await m(`Updating`,async()=>n.workers.zonesCanBeEnabled.edit({body:e,account_id:r})),{successLabel:`Updated`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function Vn(e){return 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`})}const Hn={command:`create`,describe:`Provided a list of pay-per-crawl configured zones this method will return whether they can enable PPC or not.`,builder:Vn,handler:async t=>{if(t.dryRun){p({command:`cf workers zones-can-be-enabled query create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/pay-per-crawl/zones_can_be_enabled/query`,pathParams:{},bodyKind:`json`,body:t.body===void 0?void 0:l(t.body)});return}let n=await s(t),r=t.local?_:await a(n);if(t.accountId=r,t.body){let e=l(t.body);f(await m(`Creating`,async()=>n.workers.zonesCanBeEnabled.query.create({body:e,account_id:r})),{successLabel:`Created`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Un={command:`query`,describe:`Zones Can Be Enabled operations`,builder:e=>e.command(Hn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Wn={command:`zones-can-be-enabled`,describe:`Zones Can Be Enabled operations`,builder:e=>e.command(Bn).command(Un).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Gn={command:`workers`,describe:`Deploy and manage serverless JavaScript/WASM applications on Cloudflare's global network`,builder:e=>e.command(C).command(D).command(X).command(oe).command(me).command(Ce).command(Me).command(Ie).command(We).command(Je).command(at).command(rn).command(pn).command(Tn).command(jn).command(Rn).command(Wn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{Gn as default};
|
|
7
|
+
`,default:!1}).option(`cache-options-enabled`,{type:`boolean`,description:`Whether caching is enabled for this Worker.`,default:!1}).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`])}const V={command:`create <worker-id>`,describe:`Create a new version.`,builder:B,handler:async e=>{let n={deploy:e.deploy};if(e.dryRun){p({command:`cf workers beta workers versions create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/workers/${e[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(e[`worker-id`]))}/versions`,pathParams:{"worker-id":String(e[`worker-id`]??``)},query:n,bodyKind:`json`,body:e.body===void 0?d({assets:{config:{html_handling:h(e[`assets-config-html-handling`],`assets-config-html-handling`,`text`),not_found_handling:h(e[`assets-config-not-found-handling`],`assets-config-not-found-handling`,`text`)},jwt:h(e[`assets-jwt`],`assets-jwt`,`text`)},cache_options:{cross_version_cache:e[`cache-options-cross-version-cache`],enabled:e[`cache-options-enabled`]},compatibility_date:h(e[`compatibility-date`],`compatibility-date`,`text`),compatibility_flags:e[`compatibility-flags`],limits:{cpu_ms:e[`limits-cpu-ms`],subrequests:e[`limits-subrequests`]},main_module:h(e[`main-module`],`main-module`,`text`),migrations:{new_tag:h(e[`migrations-new-tag`],`migrations-new-tag`,`text`),old_tag:h(e[`migrations-old-tag`],`migrations-old-tag`,`text`),deleted_classes:e[`migrations-deleted-classes`],new_classes:e[`migrations-new-classes`],new_sqlite_classes:e[`migrations-new-sqlite-classes`]},placement:{mode:h(e[`placement-mode`],`placement-mode`,`text`),region:h(e[`placement-region`],`placement-region`,`text`),hostname:h(e[`placement-hostname`],`placement-hostname`,`text`),host:h(e[`placement-host`],`placement-host`,`text`)},usage_model:h(e[`usage-model`],`usage-model`,`text`)}):l(e.body)});return}let r=await c(e),a=e.local?_:await i(r);if(e.accountId=a,e.body){let t=l(e.body);new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),f(await m(`Creating`,async()=>r.workers.beta.workers.versions.create({body:t,account_id:a,worker_id:e[`worker-id`],...n})),{successLabel:`Created`});return}let o=d({assets:{config:{html_handling:h(e[`assets-config-html-handling`],`assets-config-html-handling`,`text`),not_found_handling:h(e[`assets-config-not-found-handling`],`assets-config-not-found-handling`,`text`)},jwt:h(e[`assets-jwt`],`assets-jwt`,`text`)},cache_options:{cross_version_cache:e[`cache-options-cross-version-cache`],enabled:e[`cache-options-enabled`]},compatibility_date:h(e[`compatibility-date`],`compatibility-date`,`text`),compatibility_flags:e[`compatibility-flags`],limits:{cpu_ms:e[`limits-cpu-ms`],subrequests:e[`limits-subrequests`]},main_module:h(e[`main-module`],`main-module`,`text`),migrations:{new_tag:h(e[`migrations-new-tag`],`migrations-new-tag`,`text`),old_tag:h(e[`migrations-old-tag`],`migrations-old-tag`,`text`),deleted_classes:e[`migrations-deleted-classes`],new_classes:e[`migrations-new-classes`],new_sqlite_classes:e[`migrations-new-sqlite-classes`]},placement:{mode:h(e[`placement-mode`],`placement-mode`,`text`),region:h(e[`placement-region`],`placement-region`,`text`),hostname:h(e[`placement-hostname`],`placement-hostname`,`text`),host:h(e[`placement-host`],`placement-host`,`text`)},usage_model:h(e[`usage-model`],`usage-model`,`text`)});new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),f(await m(`Creating`,async()=>r.workers.beta.workers.versions.create({body:o,account_id:a,worker_id:e[`worker-id`],...n})),{successLabel:`Created`})}};function H(e){return e.positional(`version-id`,{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})}const U={command:`delete <version-id>`,describe:`Delete a version.`,builder:H,handler:async e=>{if(e.dryRun){p({command:`cf workers beta workers versions delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/workers/${e[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(e[`worker-id`]))}/versions/${e[`version-id`]==null?`<version-id>`:encodeURIComponent(String(e[`version-id`]))}`,pathParams:{"worker-id":String(e[`worker-id`]??``),"version-id":String(e[`version-id`]??``)},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
8
|
+
`);return}f(await m(`Deleting`,async()=>n.workers.beta.workers.versions.delete({account_id:r,worker_id:e[`worker-id`],version_id:e[`version-id`]})),{successLabel:`Deleted`})}};function W(e){return e.positional(`version-id`,{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`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const G={command:`get <version-id>`,describe:`Get details about a specific version.`,builder:v(W),handler:async e=>{let n={include:e.include};if(e.dryRun){p({command:`cf workers beta workers versions get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/workers/${e[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(e[`worker-id`]))}/versions/${e[`version-id`]==null?`<version-id>`:encodeURIComponent(String(e[`version-id`]))}`,pathParams:{"worker-id":String(e[`worker-id`]??``),"version-id":String(e[`version-id`]??``)},query:n,bodyKind:`none`});return}let r=await c(e),a=e.local?_:await i(r);e.accountId=a,f(await m(`Loading`,async()=>r.workers.beta.workers.versions.get({account_id:a,worker_id:e[`worker-id`],version_id:e[`version-id`],...n})),{successLabel:`Loaded`})}};function K(e){return 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.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const q={command:`list`,describe:`List all versions for a Worker.`,builder:K,handler:async e=>{let n={page:e.page,per_page:e[`per-page`]};if(e.dryRun){p({command:`cf workers beta workers versions list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/workers/${e[`worker-id`]==null?`<worker-id>`:encodeURIComponent(String(e[`worker-id`]))}/versions`,pathParams:{"worker-id":String(e[`worker-id`]??``)},query:n,bodyKind:`none`});return}let r=await c(e),a=e.local?_:await i(r);e.accountId=a,f(await m(`Loading`,async()=>r.workers.beta.workers.versions.list({account_id:a,worker_id:e[`worker-id`],...n})),{successLabel:`Loaded`})}},J={command:`versions`,describe:`Operations for beta.workers.versions`,builder:e=>e.command(V).command(U).command(G).command(q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Y={command:`workers`,describe:`Operations for beta.workers`,builder:e=>e.command(k).command(j).command(N).command(F).command(L).command(z).command(J).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},X={command:`beta`,describe:`Operations for beta`,builder:e=>e.command(Y).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Z(e){return e.option(`enabled`,{type:`boolean`,description:`The enabled field`}).option(`price-usd-microcents`,{type:`number`,description:`Price in microcents 1 USD = 100,000,000 microcents. Must be 0 or a multiple of 100,000 $0.001. Range: $0.001–$9,999.999.`}).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`})}const Q={command:`create`,describe:`Creates the pay-per-crawl config for a zone.`,builder:Z,handler:async e=>{if(e.dryRun){p({command:`cf workers configuration create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/pay-per-crawl/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?d({enabled:e.enabled,price_usd_microcents:e[`price-usd-microcents`]}):l(e.body)});return}let t=await c(e),n=await o({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=l(e.body);f(await m(`Creating`,async()=>t.workers.configuration.create({body:r,zone_id:n})),{successLabel:`Created`});return}let r=d({enabled:e.enabled,price_usd_microcents:e[`price-usd-microcents`]});f(await m(`Creating`,async()=>t.workers.configuration.create({body:r,zone_id:n})),{successLabel:`Created`})}};function ne(e){return e.option(`enabled`,{type:`boolean`,description:`The enabled field`}).option(`price-usd-microcents`,{type:`number`,description:`Price in microcents 1 USD = 100,000,000 microcents. Must be 0 or a multiple of 100,000 $0.001. Range: $0.001–$9,999.999.`}).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`})}const re={command:`edit`,describe:`Changes the pay-per-crawl config for a zone.`,builder:ne,handler:async e=>{if(e.dryRun){p({command:`cf workers configuration edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/pay-per-crawl/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`json`,body:e.body===void 0?d({enabled:e.enabled,price_usd_microcents:e[`price-usd-microcents`]}):l(e.body)});return}let t=await c(e),n=await o({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,e.body){let r=l(e.body);f(await m(`Updating`,async()=>t.workers.configuration.edit({body:r,zone_id:n})),{successLabel:`Updated`});return}let r=d({enabled:e.enabled,price_usd_microcents:e[`price-usd-microcents`]});f(await m(`Updating`,async()=>t.workers.configuration.edit({body:r,zone_id:n})),{successLabel:`Updated`})}};function ie(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ae={command:`get`,describe:`Gets the pay-per-crawl config for a zone including the bot configuration.`,builder:ie,handler:async e=>{if(e.dryRun){p({command:`cf workers configuration get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/pay-per-crawl/configuration`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await c(e),n=await o({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,f(await m(`Loading`,async()=>t.workers.configuration.get({zone_id:n})),{successLabel:`Loaded`})}},oe={command:`configuration`,describe:`Configuration operations`,builder:e=>e.command(Q).command(re).command(ae).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function se(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ce={command:`create`,describe:`Creates the stripe config for a crawler.`,builder:se,handler:async e=>{if(e.dryRun){p({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`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Creating`,async()=>n.workers.crawler.stripe.create({account_id:r})),{successLabel:`Created`})}};function le(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const ue={command:`delete`,describe:`Deletes the stripe config for a crawler.`,builder:le,handler:async e=>{if(e.dryRun){p({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`});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
9
|
+
`);return}f(await m(`Deleting`,async()=>n.workers.crawler.stripe.delete({account_id:r})),{successLabel:`Deleted`})}};function de(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const fe={command:`get`,describe:`Gets the stripe config for a crawler.`,builder:de,handler:async e=>{if(e.dryRun){p({command:`cf workers crawler stripe get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/pay-per-crawl/crawler/stripe`,pathParams:{},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Loading`,async()=>n.workers.crawler.stripe.get({account_id:r})),{successLabel:`Loaded`})}},pe={command:`stripe`,describe:`Crawler operations`,builder:e=>e.command(ce).command(ue).command(fe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},me={command:`crawler`,describe:`Operations for crawler`,builder:e=>e.command(pe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function he(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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.`}).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)`})}const ge={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:he,handler:async e=>{let a={force:e.force};if(e.dryRun){p({command:`cf workers deployments create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/deployments`,pathParams:{"script-name":String(e[`script-name`]??``)},query:a,bodyKind:`json`,body:e.body===void 0?d({strategy:h(e.strategy,`strategy`,`text`)}):l(e.body)});return}let o=await c(e),s=e.local?_:await i(o);e.accountId=s;let u=r({scriptName:e.worker});if(e.worker=u,e.body){let t=l(e.body);new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),f(await m(`Creating`,async()=>o.workers.deployments.create({body:t,account_id:s,script_name:u,...a})),{successLabel:`Created`});return}e.strategy===void 0&&(e.strategy=await n(`strategy`,`The strategy field`,[`percentage`]));let g=d({strategy:h(e.strategy,`strategy`,`text`)});new URLSearchParams(Object.entries(a).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString(),f(await m(`Creating`,async()=>o.workers.deployments.create({body:g,account_id:s,script_name:u,...a})),{successLabel:`Created`})}};function _e(e){return e.positional(`deployment-id`,{type:`string`,description:`Deployment ID`,demandOption:!0}).option(`worker`,{type:`string`,alias:`script-name`,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})}const ve={command:`delete <deployment-id>`,describe:`Delete a Worker Deployment. The latest deployment, which is actively serving traffic, cannot be deleted. All other deployments can be deleted.`,builder:_e,handler:async e=>{if(e.dryRun){p({command:`cf workers deployments delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/deployments/${e[`deployment-id`]==null?`<deployment-id>`:encodeURIComponent(String(e[`deployment-id`]))}`,pathParams:{"script-name":String(e[`script-name`]??``),"deployment-id":String(e[`deployment-id`]??``)},bodyKind:`none`});return}let n=await c(e),o=e.local?_:await i(n);e.accountId=o;let s=r({scriptName:e.worker});if(e.worker=s,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
10
|
+
`);return}f(await m(`Deleting`,async()=>n.workers.deployments.delete({account_id:o,script_name:s,deployment_id:e[`deployment-id`]})),{successLabel:`Deleted`})}};function ye(e){return e.positional(`deployment-id`,{type:`string`,description:`Deployment ID`,demandOption:!0}).option(`worker`,{type:`string`,alias:`script-name`,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})}const be={command:`get <deployment-id>`,describe:`Get information about a Worker Deployment.`,builder:ye,handler:async e=>{if(e.dryRun){p({command:`cf workers deployments get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/deployments/${e[`deployment-id`]==null?`<deployment-id>`:encodeURIComponent(String(e[`deployment-id`]))}`,pathParams:{"script-name":String(e[`script-name`]??``),"deployment-id":String(e[`deployment-id`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Loading`,async()=>n.workers.deployments.get({account_id:a,script_name:o,deployment_id:e[`deployment-id`]})),{successLabel:`Loaded`})}};function xe(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const Se={command:`list`,describe:`List of Worker Deployments. The first deployment in the list is the latest deployment actively serving traffic.`,builder:xe,handler:async e=>{if(e.dryRun){p({command:`cf workers deployments list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/deployments`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Loading`,async()=>n.workers.deployments.list({account_id:a,script_name:o})),{successLabel:`Loaded`})}},Ce={command:`deployments`,describe:`Operations for deployments`,builder:e=>e.command(ge).command(ve).command(be).command(Se).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function we(e){return e.positional(`domain-id`,{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})}const Te={command:`delete <domain-id>`,describe:`Detaches a domain from a Worker. Both the Worker and all of its previews are no longer routable using this domain.`,builder:we,handler:async e=>{if(e.dryRun){p({command:`cf workers domains delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/domains/${e[`domain-id`]==null?`<domain-id>`:encodeURIComponent(String(e[`domain-id`]))}`,pathParams:{"domain-id":String(e[`domain-id`]??``)},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
11
|
+
`);return}f(await m(`Deleting`,async()=>n.workers.domains.delete({account_id:r,domain_id:e[`domain-id`]})),{successLabel:`Deleted`})}};function Ee(e){return e.positional(`domain-id`,{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})}const De={command:`get <domain-id>`,describe:`Gets information about a domain.`,builder:Ee,handler:async e=>{if(e.dryRun){p({command:`cf workers domains get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/domains/${e[`domain-id`]==null?`<domain-id>`:encodeURIComponent(String(e[`domain-id`]))}`,pathParams:{"domain-id":String(e[`domain-id`]??``)},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Loading`,async()=>n.workers.domains.get({account_id:r,domain_id:e[`domain-id`]})),{successLabel:`Loaded`})}};function Oe(e){return 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.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ke={command:`list`,describe:`Lists all domains for an account.`,builder:Oe,handler:async e=>{let n={zone_id:e[`zone-id`],zone_name:e[`zone-name`],service:e.service,hostname:e.hostname,environment:e.environment};if(e.dryRun){p({command:`cf workers domains list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/domains`,pathParams:{},query:n,bodyKind:`none`});return}let r=await c(e),a=e.local?_:await i(r);e.accountId=a,f(await m(`Loading`,async()=>r.workers.domains.list({account_id:a,...n})),{successLabel:`Loaded`})}};function Ae(e){return e.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-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(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const je={command:`update`,describe:`Attaches a domain that routes traffic to a Worker.`,builder:Ae,handler:async n=>{if(n.dryRun){p({command:`cf workers domains update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/domains`,pathParams:{},bodyKind:`json`,body:n.body===void 0?d({hostname:h(n.hostname,`hostname`,`text`),service:h(n.service,`service`,`text`),zone_id:h(n[`zone-id`],`zone-id`,`text`),zone_name:h(n[`zone-name`],`zone-name`,`text`)}):l(n.body)});return}let r=await c(n),a=n.local?_:await i(r);if(n.accountId=a,n.body){let e=l(n.body);f(await m(`Updating`,async()=>r.workers.domains.update({...e,account_id:a})),{successLabel:`Updated`});return}n.hostname===void 0&&(n.hostname=await e(`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 e(`service`,`Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker.`)),n[`zone-id`]===void 0&&(n[`zone-id`]=await e(`zone-id`,`ID of the zone containing the domain hostname.`)),n[`zone-name`]===void 0&&(n[`zone-name`]=await e(`zone-name`,`Name of the zone containing the domain hostname.`));let o=d({hostname:h(n.hostname,`hostname`,`text`),service:h(n.service,`service`,`text`),zone_id:h(n[`zone-id`],`zone-id`,`text`),zone_name:h(n[`zone-name`],`zone-name`,`text`)});f(await m(`Updating`,async()=>r.workers.domains.update({...o,account_id:a})),{successLabel:`Updated`})}},Me={command:`domains`,describe:`Operations for domains`,builder:e=>e.command(Te).command(De).command(ke).command(je).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ne(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Pe={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:Ne,handler:async e=>{if(e.dryRun){p({command:`cf workers placement regions list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/placement/regions`,pathParams:{},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Loading`,async()=>n.workers.placement.regions.list({account_id:r})),{successLabel:`Loaded`})}},Fe={command:`regions`,describe:`Operations for placement.regions`,builder:e=>e.command(Pe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Ie={command:`placement`,describe:`Operations for placement`,builder:e=>e.command(Fe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Le(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Re={command:`create`,describe:`Creates the stripe config for a publisher.`,builder:Le,handler:async e=>{if(e.dryRun){p({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`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Creating`,async()=>n.workers.publisher.stripe.create({account_id:r})),{successLabel:`Created`})}};function ze(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const Be={command:`delete`,describe:`Deletes the stripe config for a publisher.`,builder:ze,handler:async e=>{if(e.dryRun){p({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`});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
12
|
+
`);return}f(await m(`Deleting`,async()=>n.workers.publisher.stripe.delete({account_id:r})),{successLabel:`Deleted`})}};function Ve(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const He={command:`get`,describe:`Gets the stripe config for a publisher.`,builder:Ve,handler:async e=>{if(e.dryRun){p({command:`cf workers publisher stripe get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/pay-per-crawl/publisher/stripe`,pathParams:{},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Loading`,async()=>n.workers.publisher.stripe.get({account_id:r})),{successLabel:`Loaded`})}},Ue={command:`stripe`,describe:`Publisher operations`,builder:e=>e.command(Re).command(Be).command(He).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},We={command:`publisher`,describe:`Operations for publisher`,builder:e=>e.command(Ue).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ge(e){return e.positional(`domain`,{type:`string`,description:`The domain to get credentials for.`,demandOption:!0}).option(`expiration-minutes`,{type:`number`,description:`The minimum number of minutes the token will be valid for. Must be positive. We make a best effort to respect this value, but some registry providers do not let us configure the token lifetime, so the token may be valid for longer.`}).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.`})}const Ke={command:`generate <domain>`,describe:`Generates temporary credentials for accessing Cloudflare's container image registry. Used for pulling and pushing container images.`,builder:Ge,handler:async e=>{if(e.dryRun){p({command:`cf workers registries credentials generate`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/containers/registries/${e.domain==null?`<domain>`:encodeURIComponent(String(e.domain))}/credentials`,pathParams:{domain:String(e.domain??``)},bodyKind:`json`,body:e.body===void 0?d({expiration_minutes:e[`expiration-minutes`],permissions:e.permissions}):l(e.body)});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,e.body){let t=l(e.body);f(await m(`Creating`,async()=>n.workers.registries.credentials.generate({...t,account_id:r,domain:e.domain})),{successLabel:`Created`});return}if(e[`expiration-minutes`]===void 0)throw Error(`--expiration-minutes is required (or pass --body with this field set).`);if(e.permissions===void 0)throw Error(`--permissions is required (or pass --body with this field set).`);let a=d({expiration_minutes:e[`expiration-minutes`],permissions:e.permissions});f(await m(`Creating`,async()=>n.workers.registries.credentials.generate({...a,account_id:r,domain:e.domain})),{successLabel:`Created`})}},qe={command:`credentials`,describe:`Registries operations`,builder:e=>e.command(Ke).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Je={command:`registries`,describe:`Operations for registries`,builder:e=>e.command(qe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ye(e){return 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)`})}const Xe={command:`create`,describe:`Creates a route that maps a URL pattern to a Worker.`,builder:Ye,handler:async t=>{if(t.dryRun){p({command:`cf workers routes create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/workers/routes`,pathParams:{"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?d({pattern:h(t.pattern,`pattern`,`text`),script:h(t.script,`script`,`text`)}):l(t.body)});return}let n=await c(t),r=await o({zone:t.zone},n,{quiet:t.quiet});if(t.zoneId=r,t.body){let e=l(t.body);f(await m(`Creating`,async()=>n.workers.routes.create({body:e,zone_id:r})),{successLabel:`Created`});return}t.pattern===void 0&&(t.pattern=await e(`pattern`,`Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).`));let i=d({pattern:h(t.pattern,`pattern`,`text`),script:h(t.script,`script`,`text`)});f(await m(`Creating`,async()=>n.workers.routes.create({body:i,zone_id:r})),{successLabel:`Created`})}};function Ze(e){return e.positional(`route-id`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const Qe={command:`delete <route-id>`,describe:`Deletes a route.`,builder:Ze,handler:async e=>{if(e.dryRun){p({command:`cf workers routes delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/workers/routes/${e[`route-id`]==null?`<route-id>`:encodeURIComponent(String(e[`route-id`]))}`,pathParams:{"route-id":String(e[`route-id`]??``),"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await c(e),n=await o({zone:e.zone},t,{quiet:e.quiet});if(e.zoneId=n,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
13
|
+
`);return}f(await m(`Deleting`,async()=>t.workers.routes.delete({zone_id:n,route_id:e[`route-id`]})),{successLabel:`Deleted`})}};function $e(e){return e.positional(`route-id`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const et={command:`get <route-id>`,describe:`Returns information about a route, including URL pattern and Worker.`,builder:$e,handler:async e=>{if(e.dryRun){p({command:`cf workers routes get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/workers/routes/${e[`route-id`]==null?`<route-id>`:encodeURIComponent(String(e[`route-id`]))}`,pathParams:{"route-id":String(e[`route-id`]??``),"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await c(e),n=await o({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,f(await m(`Loading`,async()=>t.workers.routes.get({zone_id:n,route_id:e[`route-id`]})),{successLabel:`Loaded`})}};function tt(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const nt={command:`list`,describe:`Returns routes for a zone.`,builder:tt,handler:async e=>{if(e.dryRun){p({command:`cf workers routes list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/workers/routes`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let t=await c(e),n=await o({zone:e.zone},t,{quiet:e.quiet});e.zoneId=n,f(await m(`Loading`,async()=>t.workers.routes.list({zone_id:n})),{successLabel:`Loaded`})}};function rt(e){return e.positional(`route-id`,{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)`})}const it={command:`update <route-id>`,describe:`Updates the URL pattern or Worker associated with a route.`,builder:rt,handler:async t=>{if(t.dryRun){p({command:`cf workers routes update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${t.zone??t.zoneId??`<zone>`}/workers/routes/${t[`route-id`]==null?`<route-id>`:encodeURIComponent(String(t[`route-id`]))}`,pathParams:{"route-id":String(t[`route-id`]??``),"zone-id":String(t.zone??t[`zone-id`]??``)},bodyKind:`json`,body:t.body===void 0?d({pattern:h(t.pattern,`pattern`,`text`),script:h(t.script,`script`,`text`)}):l(t.body)});return}let n=await c(t),r=await o({zone:t.zone},n,{quiet:t.quiet});if(t.zoneId=r,t.body){let e=l(t.body);f(await m(`Updating`,async()=>n.workers.routes.update({body:e,zone_id:r,route_id:t[`route-id`]})),{successLabel:`Updated`});return}t.pattern===void 0&&(t.pattern=await e(`pattern`,`Pattern to match incoming requests against. [Learn more](https://developers.cloudflare.com/workers/configuration/routing/routes/#matching-behavior).`));let i=d({pattern:h(t.pattern,`pattern`,`text`),script:h(t.script,`script`,`text`)});f(await m(`Updating`,async()=>n.workers.routes.update({body:i,zone_id:r,route_id:t[`route-id`]})),{successLabel:`Updated`})}},at={command:`routes`,describe:`Operations for routes`,builder:e=>e.command(Xe).command(Qe).command(et).command(nt).command(it).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ot(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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)`})}const st={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:ot,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts assets upload create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/assets-upload-session`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:l(e.body)});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});if(e.worker=o,e.body){let t=l(e.body);f(await m(`Creating`,async()=>n.workers.scripts.assets.upload.create({body:t,account_id:a,script_name:o})),{successLabel:`Created`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},ct={command:`upload`,describe:`Operations for scripts.assets.upload`,builder:e=>e.command(st).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},lt={command:`assets`,describe:`Operations for scripts.assets`,builder:e=>e.command(ct).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ut(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const dt={command:`get`,describe:`Fetch script content only.`,builder:ut,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts content get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/content/v2`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Loading`,async()=>n.workers.scripts.content.get({account_id:a,script_name:o})),{successLabel:`Loaded`})}};function ft(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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.`})}const pt={command:`update`,describe:`Put script content without touching config or metadata.`,builder:ft,handler:async e=>{let n={};if(e[`cf-worker-body-part`]!==void 0&&(n[`CF-WORKER-BODY-PART`]=String(e[`cf-worker-body-part`])),e[`cf-worker-main-module-part`]!==void 0&&(n[`CF-WORKER-MAIN-MODULE-PART`]=String(e[`cf-worker-main-module-part`])),e.dryRun){p({command:`cf workers scripts content update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/content`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`multipart`,body:{body:e.body,file:e.file,files:e.files,metadata:e.metadata}});return}let a=await c(e),o=e.local?_:await i(a);e.accountId=o;let l=r({scriptName:e.worker});if(e.worker=l,e.file!==void 0||e.body!==void 0||e.files!==void 0||e.metadata!==void 0){let t=new FormData;if(e.file){let n=g(e.file);t.append(`file`,new Blob([n]),e.file.split(/[\\/]/).filter(Boolean).pop())}else e.body!==void 0&&t.append(`file`,e.body);if(e.files!==void 0){let n=typeof e.files==`string`?h(e.files,`files`,`text`):e.files;t.append(`files`,typeof n==`string`?n:JSON.stringify(n))}if(e.metadata!==void 0){let n=typeof e.metadata==`string`?h(e.metadata,`metadata`,`text`):e.metadata;t.append(`metadata`,typeof n==`string`?n:JSON.stringify(n))}f(await m(`Updating`,async()=>s(a,`PUT`,`/accounts/${o}/workers/scripts/${l}/content`,{body:t,headers:Object.keys(n).length>0?n:void 0})),{successLabel:`Updated`});return}if(e.body){let t=h(e.body,`body`,`binary`);f(await m(`Updating`,async()=>s(a,`PUT`,`/accounts/${o}/workers/scripts/${l}/content`,{body:t,headers:{"Content-Type":`multipart/form-data`,...n}})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},mt={command:`content`,describe:`Operations for scripts.content`,builder:e=>e.command(dt).command(pt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ht(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const gt={command:`delete`,describe:`Delete your worker. This call has no response body on a successful delete.`,builder:ht,handler:async e=>{let n={force:e.force};if(e.dryRun){p({command:`cf workers scripts delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}`,pathParams:{"script-name":String(e[`script-name`]??``)},query:n,bodyKind:`none`});return}let o=await c(e),s=e.local?_:await i(o);e.accountId=s;let l=r({scriptName:e.worker});if(e.worker=l,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
14
|
+
`);return}f(await m(`Deleting`,async()=>o.workers.scripts.delete({account_id:s,script_name:l,...n})),{successLabel:`Deleted`})}};function _t(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const vt={command:`get`,describe:`Fetch raw script content for your worker. Note this is the original script content, not JSON encoded.`,builder:_t,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o;let s=await m(`Loading`,async()=>te(`/accounts/${a}/workers/scripts/${o}`,{method:`GET`,localEndpoint:e.local?e.localEndpoint:void 0}));ee(e.text===!0?s.toString(`utf-8`):s)}};function yt(e){return e.option(`tags`,{type:`string`,description:`Filter scripts by tags. Format: comma-separated list of tag:allowed pairs where allowed is 'yes' or 'no'.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const bt={command:`list`,describe:`Fetch a list of uploaded workers.`,builder:yt,handler:async e=>{let n={tags:e.tags};if(e.dryRun){p({command:`cf workers scripts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts`,pathParams:{},query:n,bodyKind:`none`});return}let r=await c(e),a=e.local?_:await i(r);e.accountId=a,f(await m(`Loading`,async()=>r.workers.scripts.list({account_id:a,...n})),{successLabel:`Loaded`})}};function xt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const St={command:`get`,describe:`Fetches Cron Triggers for a Worker.`,builder:xt,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts schedules get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/schedules`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Loading`,async()=>n.workers.scripts.schedules.get({account_id:a,script_name:o})),{successLabel:`Loaded`})}};function Ct(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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)`})}const wt={command:`update`,describe:`Updates Cron Triggers for a Worker.`,builder:Ct,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts schedules update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/schedules`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`json`,body:e.body===void 0?void 0:l(e.body)});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});if(e.worker=o,e.body){let t=l(e.body);f(await m(`Updating`,async()=>n.workers.scripts.schedules.update({body:t,account_id:a,script_name:o})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Tt={command:`schedules`,describe:`Operations for scripts.schedules`,builder:e=>e.command(St).command(wt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Et(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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`})}const Dt={command:`edit`,describe:`Patch metadata or config, such as bindings or usage model.`,builder:Et,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts script-and-version-settings edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/settings`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`multipart`,body:{body:e.body,file:e.file,settings:e.settings}});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});if(e.worker=o,e.file!==void 0||e.body!==void 0||e.settings!==void 0){let t=new FormData;if(e.file){let n=g(e.file);t.append(`file`,new Blob([n]),e.file.split(/[\\/]/).filter(Boolean).pop())}else e.body!==void 0&&t.append(`file`,e.body);if(e.settings!==void 0){let n=typeof e.settings==`string`?h(e.settings,`settings`,`text`):e.settings;t.append(`settings`,typeof n==`string`?n:JSON.stringify(n))}f(await m(`Updating`,async()=>s(n,`PATCH`,`/accounts/${a}/workers/scripts/${o}/settings`,{body:t})),{successLabel:`Updated`});return}if(e.body){let t=h(e.body,`body`,`binary`);f(await m(`Updating`,async()=>s(n,`PATCH`,`/accounts/${a}/workers/scripts/${o}/settings`,{body:t,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Updated`});return}f(await m(`Updating`,async()=>n.workers.scripts.scriptAndVersionSettings.edit({account_id:a,script_name:o})),{successLabel:`Updated`})}};function Ot(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const kt={command:`get`,describe:`Get metadata and config, such as bindings or usage model.`,builder:Ot,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts script-and-version-settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/settings`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Loading`,async()=>n.workers.scripts.scriptAndVersionSettings.get({account_id:a,script_name:o})),{successLabel:`Loaded`})}},At={command:`script-and-version-settings`,describe:`Operations for scripts.script-and-version-settings`,builder:e=>e.command(Dt).command(kt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function jt(e){return 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.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Mt={command:`search`,describe:`Search for Workers in an account.`,builder:v(jt),handler:async e=>{let n={name:e.name,id:e.id,order_by:e[`order-by`],page:e.page,per_page:e[`per-page`]};if(e.dryRun){p({command:`cf workers scripts search`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts-search`,pathParams:{},query:n,bodyKind:`none`});return}let r=await c(e),a=e.local?_:await i(r);e.accountId=a,f(await m(`Loading`,async()=>r.workers.scripts.search({account_id:a,...n})),{successLabel:`Loaded`})}};function Nt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,description:`Name of the script, used in URLs and route configuration.`}).option(`logpush`,{type:`boolean`,description:`Whether Logpush is turned on for the Worker.`}).option(`observability-enabled`,{type:`boolean`,description:`Whether observability is enabled for the Worker.`}).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.`}).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.`}).option(`observability-logs-persist`,{type:`boolean`,description:`Whether log persistence is enabled for the Worker.`}).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.`}).option(`observability-traces-propagation-policy`,{type:`string`,description:`Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. "authenticated" (default) honors inbound trace context only when accompanied by a valid trace auth token. "accept" unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.`,choices:[`authenticated`,`accept`]}).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})}const Pt={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:Nt,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts settings edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/script-settings`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`json`,body:e.body===void 0?d({logpush:e.logpush,observability:{enabled:e[`observability-enabled`],head_sampling_rate:e[`observability-head-sampling-rate`],logs:{destinations:e[`observability-logs-destinations`],enabled:e[`observability-logs-enabled`],head_sampling_rate:e[`observability-logs-head-sampling-rate`],invocation_logs:e[`observability-logs-invocation-logs`],persist:e[`observability-logs-persist`]},traces:{destinations:e[`observability-traces-destinations`],enabled:e[`observability-traces-enabled`],head_sampling_rate:e[`observability-traces-head-sampling-rate`],persist:e[`observability-traces-persist`],propagation_policy:h(e[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}}}):l(e.body)});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});if(e.worker=o,e.body){let t=l(e.body);f(await m(`Updating`,async()=>n.workers.scripts.settings.edit({body:t,account_id:a,script_name:o})),{successLabel:`Updated`});return}let s=d({logpush:e.logpush,observability:{enabled:e[`observability-enabled`],head_sampling_rate:e[`observability-head-sampling-rate`],logs:{destinations:e[`observability-logs-destinations`],enabled:e[`observability-logs-enabled`],head_sampling_rate:e[`observability-logs-head-sampling-rate`],invocation_logs:e[`observability-logs-invocation-logs`],persist:e[`observability-logs-persist`]},traces:{destinations:e[`observability-traces-destinations`],enabled:e[`observability-traces-enabled`],head_sampling_rate:e[`observability-traces-head-sampling-rate`],persist:e[`observability-traces-persist`],propagation_policy:h(e[`observability-traces-propagation-policy`],`observability-traces-propagation-policy`,`text`)}}});f(await m(`Updating`,async()=>n.workers.scripts.settings.edit({body:s,account_id:a,script_name:o})),{successLabel:`Updated`})}};function Ft(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const It={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:Ft,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/script-settings`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Loading`,async()=>n.workers.scripts.settings.get({account_id:a,script_name:o})),{successLabel:`Loaded`})}},Lt={command:`settings`,describe:`Operations for scripts.settings`,builder:e=>e.command(Pt).command(It).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Rt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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)`})}const zt={command:`create`,describe:`Enable or disable the Worker on the workers.dev subdomain.`,builder:Rt,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts subdomain create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/subdomain`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`json`,body:e.body===void 0?d({enabled:e.enabled,previews_enabled:e[`previews-enabled`]}):l(e.body)});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});if(e.worker=o,e.body){let t=l(e.body);f(await m(`Creating`,async()=>n.workers.scripts.subdomain.create({...t,account_id:a,script_name:o})),{successLabel:`Created`});return}if(e.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);let s=d({enabled:e.enabled,previews_enabled:e[`previews-enabled`]});f(await m(`Creating`,async()=>n.workers.scripts.subdomain.create({...s,account_id:a,script_name:o})),{successLabel:`Created`})}};function Bt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const Vt={command:`delete`,describe:`Disable all workers.dev subdomains for a Worker.`,builder:Bt,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts subdomain delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/subdomain`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),o=e.local?_:await i(n);e.accountId=o;let s=r({scriptName:e.worker});if(e.worker=s,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
15
|
+
`);return}f(await m(`Deleting`,async()=>n.workers.scripts.subdomain.delete({account_id:o,script_name:s})),{successLabel:`Deleted`})}};function Ht(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const Ut={command:`get`,describe:`Get if the Worker is available on the workers.dev subdomain.`,builder:Ht,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts subdomain get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/subdomain`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Loading`,async()=>n.workers.scripts.subdomain.get({account_id:a,script_name:o})),{successLabel:`Loaded`})}},Wt={command:`subdomain`,describe:`Operations for scripts.subdomain`,builder:e=>e.command(zt).command(Vt).command(Ut).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Gt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const Kt={command:`create`,describe:`Starts a tail that receives logs and exception from a Worker.`,builder:Gt,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts tail create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/tails`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Creating`,async()=>n.workers.scripts.tail.create({account_id:a,script_name:o})),{successLabel:`Created`})}};function qt(e){return e.positional(`id`,{type:`string`,description:`Identifier.`,demandOption:!0}).option(`worker`,{type:`string`,alias:`script-name`,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})}const Jt={command:`delete <id>`,describe:`Deletes a tail from a Worker.`,builder:qt,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts tail delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/tails/${e.id==null?`<id>`:encodeURIComponent(String(e.id))}`,pathParams:{"script-name":String(e[`script-name`]??``),id:String(e.id??``)},bodyKind:`none`});return}let n=await c(e),o=e.local?_:await i(n);e.accountId=o;let s=r({scriptName:e.worker});if(e.worker=s,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
16
|
+
`);return}f(await m(`Deleting`,async()=>n.workers.scripts.tail.delete({account_id:o,script_name:s,id:e.id})),{successLabel:`Deleted`})}},Yt={command:`tail`,describe:`Operations for scripts.tail`,builder:e=>e.command(Kt).command(Jt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Xt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`})}const Zt={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:v(Xt),handler:async e=>{let n={bindings_inherit:e[`bindings-inherit`]};if(e.dryRun){p({command:`cf workers scripts update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}`,pathParams:{"script-name":String(e[`script-name`]??``)},query:n,bodyKind:`octet-stream`,body:e.body});return}let a=await c(e),o=e.local?_:await i(a);e.accountId=o;let l=r({scriptName:e.worker});if(e.worker=l,e.file){let t=g(e.file);f(await m(`Updating`,async()=>s(a,`PUT`,`/accounts/${o}/workers/scripts/${l}`,{body:t,headers:{"Content-Type":`application/javascript`}})),{successLabel:`Updated`});return}if(e.body){let t=h(e.body,`body`,`binary`),r=new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();f(await m(`Updating`,async()=>s(a,`PUT`,`/accounts/${o}/workers/scripts/${l}${r?`?`+r:``}`,{body:t,headers:{"Content-Type":`application/javascript`}})),{successLabel:`Updated`});return}f(await m(`Updating`,async()=>a.workers.scripts.update({account_id:o,script_name:l,...n})),{successLabel:`Updated`})}};function Qt(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const $t={command:`get`,describe:`Fetches the Usage Model for a given Worker.`,builder:Qt,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts usage-model get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/usage-model`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Loading`,async()=>n.workers.scripts.usageModel.get({account_id:a,script_name:o})),{successLabel:`Loaded`})}};function en(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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`]}).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)`})}const tn={command:`update`,describe:`Updates the Usage Model for a given Worker. Requires a Workers Paid subscription.`,builder:en,handler:async e=>{if(e.dryRun){p({command:`cf workers scripts usage-model update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/usage-model`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`json`,body:e.body===void 0?d({usage_model:h(e[`usage-model`],`usage-model`,`text`),user_limits:{cpu_ms:e[`user-limits-cpu-ms`]}}):l(e.body)});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});if(e.worker=o,e.body){let t=l(e.body);f(await m(`Updating`,async()=>n.workers.scripts.usageModel.update({...t,account_id:a,script_name:o})),{successLabel:`Updated`});return}let s=d({usage_model:h(e[`usage-model`],`usage-model`,`text`),user_limits:{cpu_ms:e[`user-limits-cpu-ms`]}});f(await m(`Updating`,async()=>n.workers.scripts.usageModel.update({...s,account_id:a,script_name:o})),{successLabel:`Updated`})}},nn={command:`usage-model`,describe:`Operations for scripts.usage-model`,builder:e=>e.command($t).command(tn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},rn={command:`scripts`,describe:`Operations for scripts`,builder:e=>e.command(gt).command(vt).command(bt).command(Mt).command(Zt).command(lt).command(mt).command(Tt).command(At).command(Lt).command(Wt).command(Yt).command(nn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function an(e){return e.positional(`secret-name`,{type:`string`,description:`A JavaScript variable name for the secret binding.`,demandOption:!0}).option(`worker`,{type:`string`,alias:`script-name`,description:`Name of the script, used in URLs and route configuration.`}).option(`url-encoded`,{type:`boolean`,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})}const on={command:`delete <secret-name>`,describe:`Remove a secret from a script.`,builder:an,handler:async e=>{let n={url_encoded:e[`url-encoded`]};if(e.dryRun){p({command:`cf workers secrets delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/secrets/${e[`secret-name`]==null?`<secret-name>`:encodeURIComponent(String(e[`secret-name`]))}`,pathParams:{"script-name":String(e[`script-name`]??``),"secret-name":String(e[`secret-name`]??``)},query:n,bodyKind:`none`});return}let o=await c(e),s=e.local?_:await i(o);e.accountId=s;let l=r({scriptName:e.worker});if(e.worker=l,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
17
|
+
`);return}f(await m(`Deleting`,async()=>o.workers.secrets.delete({account_id:s,script_name:l,secret_name:e[`secret-name`],...n})),{successLabel:`Deleted`})}};function sn(e){return e.positional(`secret-name`,{type:`string`,description:`A JavaScript variable name for the secret binding.`,demandOption:!0}).option(`worker`,{type:`string`,alias:`script-name`,description:`Name of the script, used in URLs and route configuration.`}).option(`url-encoded`,{type:`boolean`,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})}const cn={command:`get <secret-name>`,describe:`Get a given secret binding (value omitted) on a script.`,builder:sn,handler:async e=>{let n={url_encoded:e[`url-encoded`]};if(e.dryRun){p({command:`cf workers secrets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/secrets/${e[`secret-name`]==null?`<secret-name>`:encodeURIComponent(String(e[`secret-name`]))}`,pathParams:{"script-name":String(e[`script-name`]??``),"secret-name":String(e[`secret-name`]??``)},query:n,bodyKind:`none`});return}let a=await c(e),o=e.local?_:await i(a);e.accountId=o;let s=r({scriptName:e.worker});e.worker=s,f(await m(`Loading`,async()=>a.workers.secrets.get({account_id:o,script_name:s,secret_name:e[`secret-name`],...n})),{successLabel:`Loaded`})}};function ln(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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})}const un={command:`list`,describe:`List secrets bound to a script.`,builder:ln,handler:async e=>{if(e.dryRun){p({command:`cf workers secrets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/secrets`,pathParams:{"script-name":String(e[`script-name`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Loading`,async()=>n.workers.secrets.list({account_id:a,script_name:o})),{successLabel:`Loaded`})}};function dn(e){return e.positional(`name`,{type:`string`,description:`A JavaScript variable name for the binding.`,demandOption:!0}).option(`worker`,{type:`string`,alias:`script-name`,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`])}const fn={command:`update <name>`,describe:`Add a secret to a script.`,builder:dn,handler:async a=>{if(a.dryRun){p({command:`cf workers secrets update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${a.worker??`<worker>`}/secrets`,pathParams:{"script-name":String(a[`script-name`]??``)},bodyKind:`json`,body:a.body===void 0?d({text:h(a.text,`text`,`text`),type:h(a.type,`type`,`text`),format:h(a.format,`format`,`text`),key_base64:h(a[`key-base64`],`key-base64`,`text`),usages:a.usages,name:a.name}):l(a.body)});return}let o=await c(a),s=a.local?_:await i(o);a.accountId=s;let u=r({scriptName:a.worker});if(a.worker=u,a.body){let e=l(a.body);f(await m(`Updating`,async()=>o.workers.secrets.update({body:e,account_id:s,script_name:u})),{successLabel:`Updated`});return}a.type===void 0&&(a.type=await n(`type`,`The kind of resource that the binding provides.`,[`secret_text`,`secret_key`])),a.type===`secret_text`&&a.text===void 0&&(a.text=await e(`text`,`The secret value to use.`,{kind:`secret`,question:`Enter value for --text`})),a.type===`secret_key`&&a.format===void 0&&(a.format=await e(`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 g=d({text:h(a.text,`text`,`text`),type:h(a.type,`type`,`text`),format:h(a.format,`format`,`text`),key_base64:h(a[`key-base64`],`key-base64`,`text`),usages:a.usages,name:a.name});f(await m(`Updating`,async()=>o.workers.secrets.update({body:g,account_id:s,script_name:u})),{successLabel:`Updated`})}},pn={command:`secrets`,describe:`Operations for secrets`,builder:e=>e.command(on).command(cn).command(un).command(fn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function mn(e){return e.positional(`environment-name`,{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(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const hn={command:`get <environment-name>`,describe:`Get script content from a worker with an environment.`,builder:mn,handler:async e=>{if(e.dryRun){p({command:`cf workers services environments content get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/services/${e[`service-name`]==null?`<service-name>`:encodeURIComponent(String(e[`service-name`]))}/environments/${e[`environment-name`]==null?`<environment-name>`:encodeURIComponent(String(e[`environment-name`]))}/content`,pathParams:{"service-name":String(e[`service-name`]??``),"environment-name":String(e[`environment-name`]??``)},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Loading`,async()=>n.workers.services.environments.content.get({account_id:r,service_name:e[`service-name`],environment_name:e[`environment-name`]})),{successLabel:`Loaded`})}};function gn(e){return e.positional(`environment-name`,{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.`})}const _n={command:`update <environment-name>`,describe:`Put script content from a worker with an environment.`,builder:gn,handler:async e=>{let n={};if(e[`cf-worker-body-part`]!==void 0&&(n[`CF-WORKER-BODY-PART`]=String(e[`cf-worker-body-part`])),e[`cf-worker-main-module-part`]!==void 0&&(n[`CF-WORKER-MAIN-MODULE-PART`]=String(e[`cf-worker-main-module-part`])),e.dryRun){p({command:`cf workers services environments content update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/services/${e[`service-name`]==null?`<service-name>`:encodeURIComponent(String(e[`service-name`]))}/environments/${e[`environment-name`]==null?`<environment-name>`:encodeURIComponent(String(e[`environment-name`]))}/content`,pathParams:{"service-name":String(e[`service-name`]??``),"environment-name":String(e[`environment-name`]??``)},bodyKind:`multipart`,body:{body:e.body,file:e.file,files:e.files,metadata:e.metadata}});return}let r=await c(e),a=e.local?_:await i(r);if(e.accountId=a,e.file!==void 0||e.body!==void 0||e.files!==void 0||e.metadata!==void 0){let t=new FormData;if(e.file){let n=g(e.file);t.append(`file`,new Blob([n]),e.file.split(/[\\/]/).filter(Boolean).pop())}else e.body!==void 0&&t.append(`file`,e.body);if(e.files!==void 0){let n=typeof e.files==`string`?h(e.files,`files`,`text`):e.files;t.append(`files`,typeof n==`string`?n:JSON.stringify(n))}if(e.metadata!==void 0){let n=typeof e.metadata==`string`?h(e.metadata,`metadata`,`text`):e.metadata;t.append(`metadata`,typeof n==`string`?n:JSON.stringify(n))}f(await m(`Updating`,async()=>s(r,`PUT`,`/accounts/${a}/workers/services/${encodeURIComponent(String(e[`service-name`]))}/environments/${encodeURIComponent(String(e[`environment-name`]))}/content`,{body:t,headers:Object.keys(n).length>0?n:void 0})),{successLabel:`Updated`});return}if(e.body){let t=h(e.body,`body`,`binary`);f(await m(`Updating`,async()=>s(r,`PUT`,`/accounts/${a}/workers/services/${encodeURIComponent(String(e[`service-name`]))}/environments/${encodeURIComponent(String(e[`environment-name`]))}/content`,{body:t,headers:{"Content-Type":`multipart/form-data`,...n}})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},vn={command:`content`,describe:`Operations for services.environments.content`,builder:e=>e.command(hn).command(_n).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function yn(e){return e.positional(`environment-name`,{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.`}).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.`}).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.`}).option(`result-observability-traces-propagation-policy`,{type:`string`,description:`Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. "authenticated" (default) honors inbound trace context only when accompanied by a valid trace auth token. "accept" unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.`,choices:[`authenticated`,`accept`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const bn={command:`edit <environment-name>`,describe:`Patch script metadata, such as bindings.`,builder:yn,handler:async e=>{if(e.dryRun){p({command:`cf workers services environments settings edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/services/${e[`service-name`]==null?`<service-name>`:encodeURIComponent(String(e[`service-name`]))}/environments/${e[`environment-name`]==null?`<environment-name>`:encodeURIComponent(String(e[`environment-name`]))}/settings`,pathParams:{"service-name":String(e[`service-name`]??``),"environment-name":String(e[`environment-name`]??``)},bodyKind:`json`,body:e.body===void 0?d({success:e.success,result:{logpush:e[`result-logpush`],observability:{enabled:e[`result-observability-enabled`],head_sampling_rate:e[`result-observability-head-sampling-rate`],logs:{destinations:e[`result-observability-logs-destinations`],enabled:e[`result-observability-logs-enabled`],head_sampling_rate:e[`result-observability-logs-head-sampling-rate`],invocation_logs:e[`result-observability-logs-invocation-logs`],persist:e[`result-observability-logs-persist`]},traces:{destinations:e[`result-observability-traces-destinations`],enabled:e[`result-observability-traces-enabled`],head_sampling_rate:e[`result-observability-traces-head-sampling-rate`],persist:e[`result-observability-traces-persist`],propagation_policy:h(e[`result-observability-traces-propagation-policy`],`result-observability-traces-propagation-policy`,`text`)}}}}):l(e.body)});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,e.body){let t=l(e.body);f(await m(`Updating`,async()=>n.workers.services.environments.settings.edit({...t,account_id:r,service_name:e[`service-name`],environment_name:e[`environment-name`]})),{successLabel:`Updated`});return}if(e.success===void 0)throw Error(`--success is required (or pass --body with this field set).`);if(e[`result-observability-enabled`]===void 0)throw Error(`--result-observability-enabled is required (or pass --body with this field set).`);if(e[`result-observability-logs-enabled`]===void 0)throw Error(`--result-observability-logs-enabled is required (or pass --body with this field set).`);if(e[`result-observability-logs-invocation-logs`]===void 0)throw Error(`--result-observability-logs-invocation-logs is required (or pass --body with this field set).`);let a=d({success:e.success,result:{logpush:e[`result-logpush`],observability:{enabled:e[`result-observability-enabled`],head_sampling_rate:e[`result-observability-head-sampling-rate`],logs:{destinations:e[`result-observability-logs-destinations`],enabled:e[`result-observability-logs-enabled`],head_sampling_rate:e[`result-observability-logs-head-sampling-rate`],invocation_logs:e[`result-observability-logs-invocation-logs`],persist:e[`result-observability-logs-persist`]},traces:{destinations:e[`result-observability-traces-destinations`],enabled:e[`result-observability-traces-enabled`],head_sampling_rate:e[`result-observability-traces-head-sampling-rate`],persist:e[`result-observability-traces-persist`],propagation_policy:h(e[`result-observability-traces-propagation-policy`],`result-observability-traces-propagation-policy`,`text`)}}}});f(await m(`Updating`,async()=>n.workers.services.environments.settings.edit({...a,account_id:r,service_name:e[`service-name`],environment_name:e[`environment-name`]})),{successLabel:`Updated`})}};function xn(e){return e.positional(`environment-name`,{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(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Sn={command:`get <environment-name>`,describe:`Get script settings from a worker with an environment.`,builder:xn,handler:async e=>{if(e.dryRun){p({command:`cf workers services environments settings get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/services/${e[`service-name`]==null?`<service-name>`:encodeURIComponent(String(e[`service-name`]))}/environments/${e[`environment-name`]==null?`<environment-name>`:encodeURIComponent(String(e[`environment-name`]))}/settings`,pathParams:{"service-name":String(e[`service-name`]??``),"environment-name":String(e[`environment-name`]??``)},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Loading`,async()=>n.workers.services.environments.settings.get({account_id:r,service_name:e[`service-name`],environment_name:e[`environment-name`]})),{successLabel:`Loaded`})}},Cn={command:`settings`,describe:`Operations for services.environments.settings`,builder:e=>e.command(bn).command(Sn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},wn={command:`environments`,describe:`Operations for services.environments`,builder:e=>e.command(vn).command(Cn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Tn={command:`services`,describe:`Operations for services`,builder:e=>e.command(wn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function En(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const $={command:`delete`,describe:`Deletes a Workers subdomain for an account.`,builder:En,handler:async e=>{if(e.dryRun){p({command:`cf workers subdomains delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/subdomain`,pathParams:{},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,!await a({force:!!e.force})){process.stderr.write(`Aborted.
|
|
18
|
+
`);return}f(await m(`Deleting`,async()=>n.workers.subdomains.delete({account_id:r})),{successLabel:`Deleted`})}};function Dn(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const On={command:`get`,describe:`Returns a Workers subdomain for an account.`,builder:Dn,handler:async e=>{if(e.dryRun){p({command:`cf workers subdomains get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/subdomain`,pathParams:{},bodyKind:`none`});return}let n=await c(e),r=e.local?_:await i(n);e.accountId=r,f(await m(`Loading`,async()=>n.workers.subdomains.get({account_id:r})),{successLabel:`Loaded`})}};function kn(e){return 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)`})}const An={command:`update`,describe:`Creates a Workers subdomain for an account.`,builder:kn,handler:async n=>{if(n.dryRun){p({command:`cf workers subdomains update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/subdomain`,pathParams:{},bodyKind:`json`,body:n.body===void 0?d({subdomain:h(n.subdomain,`subdomain`,`text`)}):l(n.body)});return}let r=await c(n),a=n.local?_:await i(r);if(n.accountId=a,n.body){let e=l(n.body);f(await m(`Updating`,async()=>r.workers.subdomains.update({body:e,account_id:a})),{successLabel:`Updated`});return}n.subdomain===void 0&&(n.subdomain=await e(`subdomain`,`The subdomain field`));let o=d({subdomain:h(n.subdomain,`subdomain`,`text`)});f(await m(`Updating`,async()=>r.workers.subdomains.update({body:o,account_id:a})),{successLabel:`Updated`})}},jn={command:`subdomains`,describe:`Operations for subdomains`,builder:e=>e.command($).command(On).command(An).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Mn(e){return e.option(`worker`,{type:`string`,alias:`script-name`,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)`}).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.`})}const Nn={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:Mn,handler:async e=>{let n={bindings_inherit:e[`bindings-inherit`]};if(e.dryRun){p({command:`cf workers versions create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/versions`,pathParams:{"script-name":String(e[`script-name`]??``)},query:n,bodyKind:`multipart`,body:{body:e.body,file:e.file,files:e.files,metadata:e.metadata}});return}let a=await c(e),o=e.local?_:await i(a);e.accountId=o;let l=r({scriptName:e.worker});if(e.worker=l,e.file!==void 0||e.body!==void 0||e.files!==void 0||e.metadata!==void 0){let t=new FormData;if(e.file){let n=g(e.file);t.append(`file`,new Blob([n]),e.file.split(/[\\/]/).filter(Boolean).pop())}else e.body!==void 0&&t.append(`file`,e.body);if(e.files!==void 0){let n=typeof e.files==`string`?h(e.files,`files`,`text`):e.files;t.append(`files`,typeof n==`string`?n:JSON.stringify(n))}if(e.metadata!==void 0){let n=typeof e.metadata==`string`?h(e.metadata,`metadata`,`text`):e.metadata;t.append(`metadata`,typeof n==`string`?n:JSON.stringify(n))}f(await m(`Creating`,async()=>s(a,`POST`,`/accounts/${o}/workers/scripts/${l}/versions`,{body:t})),{successLabel:`Created`});return}if(e.body){let t=h(e.body,`body`,`binary`),r=new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0).map(([e,t])=>[e,String(t)])).toString();f(await m(`Creating`,async()=>s(a,`POST`,`/accounts/${o}/workers/scripts/${l}/versions${r?`?`+r:``}`,{body:t,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function Pn(e){return e.positional(`version-id`,{type:`string`,description:`Version ID`,demandOption:!0}).option(`worker`,{type:`string`,alias:`script-name`,description:`Name of the script.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Fn={command:`get <version-id>`,describe:`Retrieves detailed information about a specific version of a Workers script.`,builder:Pn,handler:async e=>{if(e.dryRun){p({command:`cf workers versions get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/versions/${e[`version-id`]==null?`<version-id>`:encodeURIComponent(String(e[`version-id`]))}`,pathParams:{"script-name":String(e[`script-name`]??``),"version-id":String(e[`version-id`]??``)},bodyKind:`none`});return}let n=await c(e),a=e.local?_:await i(n);e.accountId=a;let o=r({scriptName:e.worker});e.worker=o,f(await m(`Loading`,async()=>n.workers.versions.get({account_id:a,script_name:o,version_id:e[`version-id`]})),{successLabel:`Loaded`})}};function In(e){return e.option(`worker`,{type:`string`,alias:`script-name`,description:`Name of the script.`}).option(`deployable`,{type:`boolean`,description:`Only return versions that can be used in a deployment. Ignores pagination.`}).option(`page`,{type:`number`,description:`Current page.`}).option(`per-page`,{type:`number`,description:`Items per-page.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ln={command:`list`,describe:`List of Worker Versions. The first version in the list is the latest version.`,builder:In,handler:async e=>{let n={deployable:e.deployable,page:e.page,per_page:e[`per-page`]};if(e.dryRun){p({command:`cf workers versions list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/workers/scripts/${e.worker??`<worker>`}/versions`,pathParams:{"script-name":String(e[`script-name`]??``)},query:n,bodyKind:`none`});return}let a=await c(e),o=e.local?_:await i(a);e.accountId=o;let s=r({scriptName:e.worker});e.worker=s,f(await m(`Loading`,async()=>a.workers.versions.list({account_id:o,script_name:s,...n})),{successLabel:`Loaded`})}},Rn={command:`versions`,describe:`Operations for versions`,builder:e=>e.command(Nn).command(Fn).command(Ln).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function zn(e){return 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`})}const Bn={command:`edit`,describe:`Allows an account admin to set the can_be_enabled setting on a list of zones.`,builder:zn,handler:async e=>{if(e.dryRun){p({command:`cf workers zones-can-be-enabled edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/pay-per-crawl/zones_can_be_enabled`,pathParams:{},bodyKind:`json`,body:e.body===void 0?void 0:l(e.body)});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,e.body){let t=l(e.body);f(await m(`Updating`,async()=>n.workers.zonesCanBeEnabled.edit({body:t,account_id:r})),{successLabel:`Updated`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function Vn(e){return 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`})}const Hn={command:`create`,describe:`Provided a list of pay-per-crawl configured zones this method will return whether they can enable PPC or not.`,builder:Vn,handler:async e=>{if(e.dryRun){p({command:`cf workers zones-can-be-enabled query create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/pay-per-crawl/zones_can_be_enabled/query`,pathParams:{},bodyKind:`json`,body:e.body===void 0?void 0:l(e.body)});return}let n=await c(e),r=e.local?_:await i(n);if(e.accountId=r,e.body){let t=l(e.body);f(await m(`Creating`,async()=>n.workers.zonesCanBeEnabled.query.create({body:t,account_id:r})),{successLabel:`Created`});return}if(e.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Un={command:`query`,describe:`Zones Can Be Enabled operations`,builder:e=>e.command(Hn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Wn={command:`zones-can-be-enabled`,describe:`Zones Can Be Enabled operations`,builder:e=>e.command(Bn).command(Un).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Gn={command:`workers`,describe:`Deploy and manage serverless JavaScript/WASM applications on Cloudflare's global network`,builder:e=>e.command(C).command(D).command(X).command(oe).command(me).command(Ce).command(Me).command(Ie).command(We).command(Je).command(at).command(rn).command(pn).command(Tn).command(jn).command(Rn).command(Wn).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{Gn as default};
|