@vercel/cli-support 65.6.0-snapshot-1ef3a0de66d0 → 65.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{add-6UOKR26K.js → add-7G5PAIUN.js} +1 -1
- package/dist/chunks/{add-RPAOJH5O.js → add-LA2T477X.js} +1 -1
- package/dist/chunks/{add-GULZ6EGJ.js → add-TPDABQQA.js} +1 -1
- package/dist/chunks/{build-MLAKPRSC.js → build-A463NBA2.js} +1 -1
- package/dist/chunks/{chunk-CU2FTX57.js → chunk-2H4UEVTG.js} +1 -1
- package/dist/chunks/{chunk-L4XLDN6T.js → chunk-2KINJIWA.js} +1 -1
- package/dist/chunks/{chunk-5K426HWC.js → chunk-3DFEM7ZL.js} +1 -1
- package/dist/chunks/{chunk-JXAEI2GJ.js → chunk-3UD4MZMH.js} +1 -1
- package/dist/chunks/{chunk-7G4PQR6J.js → chunk-43WS2YU4.js} +1 -1
- package/dist/chunks/{chunk-2QIJEHNE.js → chunk-4KO6U4CW.js} +2 -2
- package/dist/chunks/{chunk-YIRSRF6D.js → chunk-4P6IRBBK.js} +1 -1
- package/dist/chunks/{chunk-ZUYPTLVO.js → chunk-5ULKEPKM.js} +1 -1
- package/dist/chunks/{chunk-ZUNQHI5Y.js → chunk-6GSI4VMJ.js} +1 -1
- package/dist/chunks/{chunk-DAUAVRFC.js → chunk-7CNJTFWP.js} +1 -1
- package/dist/chunks/{chunk-SW3JRXUW.js → chunk-A4UOBMZR.js} +1 -1
- package/dist/chunks/{chunk-4G7ZQONX.js → chunk-A7E3WORN.js} +1 -1
- package/dist/chunks/{chunk-QUSEBFDO.js → chunk-CNE5UGJC.js} +1 -1
- package/dist/chunks/{chunk-HVDGNAPM.js → chunk-DCX2PBSX.js} +1 -1
- package/dist/chunks/{chunk-MZQEDXOH.js → chunk-DFXYDOFX.js} +2 -2
- package/dist/chunks/{chunk-5WYPJ2T5.js → chunk-E32IBIXV.js} +2 -2
- package/dist/chunks/{chunk-3NG2EYQ5.js → chunk-EOK43KMC.js} +1 -1
- package/dist/chunks/{chunk-CWO4HMKU.js → chunk-F6MHQRDG.js} +1 -1
- package/dist/chunks/{chunk-YALEYPMP.js → chunk-FN3W5CJQ.js} +1 -1
- package/dist/chunks/{chunk-R3BEQTZZ.js → chunk-FSBAVQQP.js} +1 -1
- package/dist/chunks/{chunk-JSAY52FE.js → chunk-FVIVFDCB.js} +1 -1
- package/dist/chunks/{chunk-ORJBK5FT.js → chunk-G62JX3C5.js} +1 -1
- package/dist/chunks/{chunk-ODAV7Z2H.js → chunk-GAGROISK.js} +1 -1
- package/dist/chunks/{chunk-WICRM2JL.js → chunk-GKCTMBCM.js} +1 -1
- package/dist/chunks/{chunk-JMLKK7RL.js → chunk-GTHPBDPB.js} +2 -2
- package/dist/chunks/{chunk-NZPGWZLV.js → chunk-H3E4YX2M.js} +1 -1
- package/dist/chunks/{chunk-PRFIFS3Q.js → chunk-HKZKGIBQ.js} +1 -1
- package/dist/chunks/chunk-HNNCK5KD.js +13 -0
- package/dist/chunks/{chunk-FAEC4BER.js → chunk-HOOQ7ZMB.js} +1 -1
- package/dist/chunks/{chunk-AOC6XXOO.js → chunk-HTOZY5SI.js} +1 -1
- package/dist/chunks/{chunk-LT5UZRMK.js → chunk-I64T5ZML.js} +1 -1
- package/dist/chunks/chunk-I7U2XP4X.js +10 -0
- package/dist/chunks/{chunk-RWPQOJTT.js → chunk-I7YEXDVF.js} +1 -1
- package/dist/chunks/{chunk-PHHZ6J7Q.js → chunk-IEZKTS2C.js} +1 -1
- package/dist/chunks/{chunk-ARQMFBV4.js → chunk-IUMJJFEP.js} +1 -1
- package/dist/chunks/{chunk-JGMJP4T3.js → chunk-JPEIHA57.js} +1 -1
- package/dist/chunks/{chunk-CLVEFWEX.js → chunk-JW57JYRO.js} +1 -1
- package/dist/chunks/{chunk-VUQWLLNI.js → chunk-KBFHUWSQ.js} +1 -1
- package/dist/chunks/{chunk-JWUXHL35.js → chunk-LAINBICC.js} +1 -1
- package/dist/chunks/{chunk-VQ755MPP.js → chunk-LCMNJNSQ.js} +1 -1
- package/dist/chunks/{chunk-IC3THLYP.js → chunk-LIXU6EGC.js} +1 -1
- package/dist/chunks/{chunk-SDOPVIKJ.js → chunk-MJ7JIQL3.js} +1 -1
- package/dist/chunks/{chunk-WDUHDLUA.js → chunk-MMKG5W42.js} +1 -1
- package/dist/chunks/{chunk-XAU3KTPX.js → chunk-MYTOHLYZ.js} +1 -1
- package/dist/chunks/{chunk-GP55VEOQ.js → chunk-N36OHJVQ.js} +1 -1
- package/dist/chunks/{chunk-6WMO5G45.js → chunk-OEPDTNS3.js} +1 -1
- package/dist/chunks/{chunk-EFEQQXRU.js → chunk-OGSTNJJ5.js} +1 -1
- package/dist/chunks/{chunk-ED3VA7D4.js → chunk-OORHGYZ3.js} +1 -1
- package/dist/chunks/{chunk-ZQUVDDPB.js → chunk-OS5I5TXU.js} +1 -1
- package/dist/chunks/{chunk-JHNLBVO2.js → chunk-QBP6E2YB.js} +1 -1
- package/dist/chunks/{chunk-NVNE3W7S.js → chunk-QDQ4NHQN.js} +1 -1
- package/dist/chunks/{chunk-OQX4YVGU.js → chunk-QFUCWOCL.js} +1 -1
- package/dist/chunks/{chunk-GFD6UAAO.js → chunk-QRYQADGN.js} +1 -1
- package/dist/chunks/{chunk-WSVYZKI6.js → chunk-RD2VHI66.js} +1 -1
- package/dist/chunks/{chunk-36NK2Z3C.js → chunk-RNTS4MJP.js} +1 -1
- package/dist/chunks/{chunk-JCGEXU7T.js → chunk-RQYXFSED.js} +2 -2
- package/dist/chunks/{chunk-ETEVOJQJ.js → chunk-S22GZWJS.js} +1 -1
- package/dist/chunks/{chunk-MLGQ233X.js → chunk-S52O6DKC.js} +1 -1
- package/dist/chunks/{chunk-NM44RWS6.js → chunk-SAUBWYQJ.js} +1 -1
- package/dist/chunks/{chunk-5EMSOR2P.js → chunk-SKDLXVRO.js} +1 -1
- package/dist/chunks/{chunk-AIRQFG5A.js → chunk-SXRZZDON.js} +1 -1
- package/dist/chunks/{chunk-VLYVVC3P.js → chunk-TKKGZI7O.js} +5 -5
- package/dist/chunks/{chunk-4HJGSSSZ.js → chunk-TYL6IYR4.js} +1 -1
- package/dist/chunks/{chunk-I2WEQWCA.js → chunk-UWGWRZP5.js} +1 -1
- package/dist/chunks/chunk-V6NMCQUQ.js +7 -0
- package/dist/chunks/chunk-VH5Z5VHD.js +10 -0
- package/dist/chunks/{chunk-QDPYU6KS.js → chunk-VKJVYR4T.js} +1 -1
- package/dist/chunks/chunk-WRHQTUHU.js +8 -0
- package/dist/chunks/{chunk-TGOGYSBO.js → chunk-WZAJYSJZ.js} +1 -1
- package/dist/chunks/{chunk-KWKEBKUR.js → chunk-X4K3UJN7.js} +1 -1
- package/dist/chunks/{clear-UZWOOGOH.js → clear-ISIDZTUZ.js} +1 -1
- package/dist/chunks/{compile-vercel-config-2RQDL3RD.js → compile-vercel-config-CZVX4OWQ.js} +1 -1
- package/dist/chunks/{config-RMJWRS7O.js → config-GMCTHBY6.js} +1 -1
- package/dist/chunks/{config-C76IGJ6B.js → config-MAFBMJV3.js} +1 -1
- package/dist/chunks/config-validator.mjs +1 -1
- package/dist/chunks/{delete-OKOBDL7Z.js → delete-LLQFSC7R.js} +1 -1
- package/dist/chunks/{delete-2WBR5JQW.js → delete-PIFKRZEO.js} +1 -1
- package/dist/chunks/{detect-projects-XPB3R7VS.js → detect-projects-EYF4ZSYF.js} +1 -1
- package/dist/chunks/{detect-services-DRHV22O5.js → detect-services-LNYPPBJP.js} +1 -1
- package/dist/chunks/{disable-DFEABU2Z.js → disable-7JLE53D2.js} +1 -1
- package/dist/chunks/{discard-KGBEMNFT.js → discard-EXDT6QIK.js} +1 -1
- package/dist/chunks/{edit-5XIRLUKG.js → edit-3NOKVF5V.js} +1 -1
- package/dist/chunks/{edit-PJIDMKUS.js → edit-BQCPB3ZR.js} +1 -1
- package/dist/chunks/{enable-UDWDPFOI.js → enable-KYVZIXZM.js} +1 -1
- package/dist/chunks/{export-W75EA6EQ.js → export-4RZRCFX7.js} +1 -1
- package/dist/chunks/{fetch-proxy-45DGILKR.js → fetch-proxy-MOKBS56A.js} +1 -1
- package/dist/chunks/{future-PHSAEQIE.js → future-YZGJX6FF.js} +1 -1
- package/dist/chunks/{generate-cert-for-deploy-C67VL5Z6.js → generate-cert-for-deploy-I236CHA2.js} +1 -1
- package/dist/chunks/{image-U5CV2PRP.js → image-EIMVSQLG.js} +1 -1
- package/dist/chunks/{import-builders-PHIIX7HW.js → import-builders-JEJRMLNC.js} +1 -1
- package/dist/chunks/{inspect-DQQI3PM7.js → inspect-2SCDEURI.js} +1 -1
- package/dist/chunks/{inspect-AU3MX7E2.js → inspect-BMBFYISW.js} +1 -1
- package/dist/chunks/{inspect-RNWLPR7I.js → inspect-IOKO45PV.js} +1 -1
- package/dist/chunks/{inspect-LJK7I6RZ.js → inspect-P246VXF5.js} +1 -1
- package/dist/chunks/{inspect-WHPWW4BI.js → inspect-UJAAVGJT.js} +1 -1
- package/dist/chunks/{list-QNRFVMMQ.js → list-34Z62YFO.js} +1 -1
- package/dist/chunks/{list-JV26NNYL.js → list-PC4ZVIHQ.js} +1 -1
- package/dist/chunks/{list-YF4FXWUZ.js → list-WL3WA7CS.js} +1 -1
- package/dist/chunks/{login-A4KNOUNA.js → login-BOBO3TKA.js} +1 -1
- package/dist/chunks/{login-COGE7JQU.js → login-RAN3UBFA.js} +1 -1
- package/dist/chunks/{logs-KMQATUYR.js → logs-L3VFH7SK.js} +1 -1
- package/dist/chunks/{ls-HMYU2ZGA.js → ls-FKECGTP3.js} +1 -1
- package/dist/chunks/{ls-DTFLHFOW.js → ls-FL3FCE2T.js} +1 -1
- package/dist/chunks/{ls-IHF33MQP.js → ls-HQHXDVPG.js} +1 -1
- package/dist/chunks/{ls-RNRMYD3V.js → ls-MDTI26PW.js} +1 -1
- package/dist/chunks/{ls-ZQLCDIQJ.js → ls-NQVH63KO.js} +1 -1
- package/dist/chunks/{ls-QD54I4S7.js → ls-PQBYVYPW.js} +1 -1
- package/dist/chunks/{ls-FOKMPVIB.js → ls-ZK5ESMRT.js} +1 -1
- package/dist/chunks/{mutate-RMIFQOF6.js → mutate-6OEPBAJF.js} +1 -1
- package/dist/chunks/{notifications-BFBNV2HY.js → notifications-A46PC7QX.js} +1 -1
- package/dist/chunks/{open-L6HEXHAI.js → open-QWJQWDZD.js} +1 -1
- package/dist/chunks/{openapi-6JKCOR7K.js → openapi-5QWHDLKR.js} +1 -1
- package/dist/chunks/{permissions-UYGTYRKA.js → permissions-MCOS247Q.js} +1 -1
- package/dist/chunks/{plugin-offer-NBHRXMNR.js → plugin-offer-ZMTZG6FR.js} +1 -1
- package/dist/chunks/{prompt-missing-credentials-2IYIF2JI.js → prompt-missing-credentials-AUJFBZRC.js} +1 -1
- package/dist/chunks/{publish-T2VSTPG4.js → publish-CQ5FHKNN.js} +1 -1
- package/dist/chunks/{pull-4GL47Z2S.js → pull-RVNTGJ4C.js} +1 -1
- package/dist/chunks/{purchase-domain-if-available-BHFBD3LW.js → purchase-domain-if-available-6FAGFFWC.js} +1 -1
- package/dist/chunks/{push-CQPIDVTL.js → push-IBOUSKO7.js} +1 -1
- package/dist/chunks/{query-HN45ORIB.js → query-OG4FG2AO.js} +1 -1
- package/dist/chunks/{reauthenticate-FTHGAWK3.js → reauthenticate-TVQDXIFS.js} +1 -1
- package/dist/chunks/{reorder-7BD5JZKQ.js → reorder-LWKTDFSH.js} +1 -1
- package/dist/chunks/{reply-2INQJ5KM.js → reply-5CE2KUD7.js} +1 -1
- package/dist/chunks/{resolve-DHAJC3I7.js → resolve-S35UEM35.js} +1 -1
- package/dist/chunks/{resolve-agent-team-KGYPHN5F.js → resolve-agent-team-DXHF7XLU.js} +1 -1
- package/dist/chunks/{restore-OQKNWEFQ.js → restore-K66POLY7.js} +1 -1
- package/dist/chunks/{rm-CTP4UZH7.js → rm-6PBYTCDC.js} +1 -1
- package/dist/chunks/{rm-OG3OXA6H.js → rm-C4FXH2RT.js} +1 -1
- package/dist/chunks/{rm-GFHEXQQW.js → rm-C73EKJS4.js} +1 -1
- package/dist/chunks/{rm-PFZYHXEN.js → rm-MNT5XIGK.js} +1 -1
- package/dist/chunks/{rm-XAW3WJ3I.js → rm-VJOHV243.js} +1 -1
- package/dist/chunks/{routes-XKEWEA3P.js → routes-LQGTKBXU.js} +1 -1
- package/dist/chunks/{rule-inspect-MKQE5IVJ.js → rule-inspect-4EBB5IDK.js} +1 -1
- package/dist/chunks/{schema-TFN5PSYE.js → schema-H5RRV4J3.js} +1 -1
- package/dist/chunks/{schema-XFER2RCF.js → schema-S32JRZH5.js} +1 -1
- package/dist/chunks/{select-org-PFTR6HQZ.js → select-org-VTLOMQYC.js} +1 -1
- package/dist/chunks/{set-KWOZNGRL.js → set-52J54LJU.js} +1 -1
- package/dist/chunks/{setup-and-link-BRYK42L7.js → setup-and-link-XGBTMVW7.js} +1 -1
- package/dist/chunks/{skills-2MOFBKIE.js → skills-CY57F35A.js} +1 -1
- package/dist/chunks/{tags-BHZUQTOQ.js → tags-WAVSTC2G.js} +1 -1
- package/dist/chunks/{types-IWO5QLAV.js → types-EK3C4EHF.js} +1 -1
- package/dist/chunks/{update-LP7ZZUFZ.js → update-4LNUD2AB.js} +1 -1
- package/dist/commands/build/index.js +1 -1
- package/dist/commands/deploy/index.js +9 -6
- package/dist/commands/dev/index.js +3 -3
- package/dist/commands/env/index.js +1 -1
- package/dist/commands/link/index.js +1 -1
- package/dist/commands/list/index.js +1 -1
- package/dist/commands/project/index.js +1 -1
- package/dist/commands-account.js +7 -3
- package/dist/commands-ai.js +3 -3
- package/dist/commands-blob.js +1 -1
- package/dist/commands-core.js +26 -14
- package/dist/commands-deployments.js +1 -1
- package/dist/commands-flags.js +1 -1
- package/dist/commands-integrations.js +1 -1
- package/dist/commands-observability.js +2 -2
- package/dist/commands-routing.js +2 -2
- package/dist/index.js +5 -5
- package/dist/internal-build.js +2 -2
- package/dist/native-download.js +2 -1
- package/dist/package.json +58 -58
- package/dist/vc.js +26 -7
- package/dist/version.mjs +1 -1
- package/package.json +51 -51
- package/dist/chunks/chunk-6IATT2ID.js +0 -8
- package/dist/chunks/chunk-EE2FTI3R.js +0 -7
- package/dist/chunks/chunk-EWP5WICJ.js +0 -10
- package/dist/chunks/chunk-XE24Y6NM.js +0 -10
- package/dist/chunks/chunk-YQDOADMG.js +0 -10
|
@@ -4,7 +4,7 @@ import { dirname as __dirname_ } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
const __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __dirname_(__filename);
|
|
7
|
-
import{humanReadableColumnLabel}from"./chunk-GHAY4PSD.js";import{FETCH_TIMEOUT_MS,OpenApiCache,SSO_API_URL,assertAllowedSpecUrl,readSpecResponse}from"./chunk-7VTPAXDC.js";import{table}from"./chunk-5SIC5273.js";import{apiCommand,listSubcommand}from"./chunk-UJQ6PBRF.js";import{printError}from"./chunk-VQ755MPP.js";import{help}from"./chunk-SLDWAIO3.js";import{TelemetryClient}from"./chunk-5WYPJ2T5.js";import{require_ms}from"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-F22QLVTX.js";import{validateJsonOutput}from"./chunk-7SAEZ4NC.js";import{packageName}from"./chunk-JESNVRVR.js";import{output_manager_default}from"./chunk-DWOJP4ST.js";import{getFlagsSpecification}from"./chunk-A2UZ2O7H.js";import{require_source}from"./chunk-NB2WLB3J.js";import{__toESM}from"./chunk-BZENIQ7N.js";import{createHash}from"crypto";var MAX_REDIRECTS=3;async function fetchSpecUrl(client,specUrl){let specOrigin=assertAllowedSpecUrl(specUrl).origin,probe=await fetchWithTimeout(specUrl,{readSpec:!0});if(probe.response.ok)return probe.spec??null;let nonce=getSetCookieValue(probe.response,"_vercel_sso_nonce");if(!nonce)throw output_manager_default.debug(`OpenAPI spec URL returned ${probe.response.status} without a Vercel SSO nonce`),new Error(formatHttpError(specUrl,probe.response));let token=client.authConfig.token;if(!token)return output_manager_default.debug("OpenAPI spec URL requires Vercel authentication"),null;let hashedNonce=createHash("sha256").update(nonce).digest("hex"),ssoUrl=`${SSO_API_URL}?url=${encodeURIComponent(specUrl)}&nonce=${hashedNonce}`,sso=await fetchWithTimeout(ssoUrl,{cookie:`authorization=${encodeURIComponent(`Bearer ${token}`)}; isLoggedIn=1`}),location=sso.response.headers.get("location");if(!location||!location.includes("_vercel_jwt="))throw output_manager_default.debug("OpenAPI spec URL: user has no access"),new Error(formatHttpError(specUrl,sso.response));let cookies=new Map([["_vercel_sso_nonce",nonce]]),url=location;for(let i=0;i<=MAX_REDIRECTS;i++){if(!isSameOriginUrl(url,specOrigin))return output_manager_default.debug("OpenAPI spec URL: cross-origin redirect rejected"),null;let{response,spec}=await fetchWithTimeout(url,{cookie:Array.from(cookies,([name,value])=>`${name}=${value}`).join("; "),readSpec:!0});if(response.ok)return spec??null;let next=response.headers.get("location");if(response.status>=300&&response.status<400&&next){let setJwt=getSetCookieValue(response,"_vercel_jwt");setJwt&&cookies.set("_vercel_jwt",setJwt);let nextUrl=new URL(next,url).href;if(!isSameOriginUrl(nextUrl,specOrigin))return output_manager_default.debug("OpenAPI spec URL: cross-origin redirect rejected"),null;url=nextUrl;continue}throw output_manager_default.debug(`OpenAPI spec URL: unexpected response ${response.status}`),new Error(formatHttpError(url,response))}return output_manager_default.debug("OpenAPI spec URL: too many redirects"),null}function createOpenApiCache(client,specUrl){return new OpenApiCache(specUrl?{specUrl,fetchSpecUrl:url=>fetchSpecUrl(client,url)}:void 0)}async function fetchWithTimeout(url,options){let controller=new AbortController,timeoutId=setTimeout(()=>controller.abort(),1e4);try{let response=await fetch(url,{redirect:"manual",signal:controller.signal,headers:options?.cookie?{cookie:options.cookie}:void 0}),spec=options?.readSpec&&response.ok?await readSpecResponse(response,formatDiagnosticUrl(url)):void 0;return{response,spec}}finally{clearTimeout(timeoutId)}}function isSameOriginUrl(url,origin){try{return new URL(url).origin===origin}catch{return!1}}function formatHttpError(url,response){let statusText=response.statusText?` ${response.statusText}`:"";return`Could not load OpenAPI spec from ${formatDiagnosticUrl(url)}: HTTP ${response.status}${statusText}.`}function formatDiagnosticUrl(url){try{let parsed=new URL(url);parsed.hash="";for(let key of parsed.searchParams.keys())parsed.searchParams.set(key,"[redacted]");return parsed.href}catch{return url}}function getSetCookieValue(response,name){let header=response.headers.get("set-cookie");if(!header)return null;let match=header.match(new RegExp(`${name}=([^;,\\s]+)`));return match?match[1]:null}function foldNamingStyle(input){return input.trim().replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/([A-Z])([A-Z][a-z])/g,"$1 $2").replace(/[-_\s]+/g," ").trim().toLowerCase().replace(/\s+/g,"")}function operationIdToKebabCase(operationId){let s=operationId.trim();return s?s.replace(/([a-z\d])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/[-_\s]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase():"unnamed"}function inferCliSubcommandAliases(ep){let upper=ep.method.toUpperCase(),hasPathParams=ep.parameters.some(p=>p.in==="path");switch(upper){case"GET":return hasPathParams?["inspect","get"]:["ls","list"];case"POST":return["add","create"];case"DELETE":return["rm","remove"];case"PUT":case"PATCH":return["update"];default:return[]}}var import_ms=__toESM(require_ms(),1),import_chalk=__toESM(require_source(),1);function getByPath(obj,path){let parts=path.split(".").filter(Boolean),cur=obj;for(let p of parts){if(cur===null||typeof cur!="object")return;cur=cur[p]}return cur}var TIMESTAMP_FIELD_PATTERN=/(?:^|\.)(created|updated|deleted|expired|blocked|completed|started|finished|modified|verified|published|cancelled|revoked|invited|accepted|accessed|deployed)(?:At|_at|On|_on)?$/i,MIN_TIMESTAMP_MS=1e12,MAX_TIMESTAMP_MS=41024448e5;function isTimestampValue(value,columnPath){return typeof value!="number"||!Number.isFinite(value)||value<MIN_TIMESTAMP_MS||value>MAX_TIMESTAMP_MS?!1:TIMESTAMP_FIELD_PATTERN.test(columnPath)}function formatRelativeTime(timestamp){let diff=Date.now()-timestamp;return diff<0?"just now":import_chalk.default.gray((0,import_ms.default)(diff))}function stringifyCell(value,columnPath){return value==null?import_chalk.default.gray("--"):columnPath&&isTimestampValue(value,columnPath)?formatRelativeTime(value):typeof value=="object"?JSON.stringify(value):String(value)}function styleColumnKey(plainLabel){return import_chalk.default.gray(plainLabel)}function columnsForRow(r,display){return r.limited===!0&&display.columnsWhenLimited?.length?display.columnsWhenLimited:display.columnsDefault}function formatAsCard(r,display){let columns=columnsForRow(r,display);if(!columns.length)return null;let rows=columns.map(colPath=>[styleColumnKey(humanReadableColumnLabel(colPath)),stringifyCell(getByPath(r,colPath),colPath)]);return table(rows,{align:["l","l"],hsep:2})}function formatAsDataTable(items,display){if(items.length===0)return"(empty)";let first=items[0];if(first===null||typeof first!="object"||Array.isArray(first)){let headers2=[styleColumnKey(humanReadableColumnLabel("#")),styleColumnKey(humanReadableColumnLabel("value"))],rows=items.map((v,i)=>[String(i),stringifyCell(v,"value")]);return table([headers2,...rows])}let columns=columnsForRow(first,display);if(!columns.length)return null;let headers=columns.map(p=>styleColumnKey(humanReadableColumnLabel(p))),dataRows=items.map(item=>{let row=item!==null&&typeof item=="object"&&!Array.isArray(item)?item:{};return columns.map(colPath=>stringifyCell(getByPath(row,colPath),colPath))});return table([headers,...dataRows])}function resolveEndpointByTagAndOperationId(endpoints,tag,operationHint){let tagLower=tag.toLowerCase(),tagMatches=endpoints.filter(ep=>ep.tags.some(t=>t.toLowerCase()===tagLower));if(tagMatches.length===0)return{ok:!1,reason:"no_tag",tag,tagMatches:[],operationHint};let withOpId=tagMatches.filter(ep=>ep.operationId.length>0);if(withOpId.length===0)return{ok:!1,reason:"no_operation",tag,tagMatches,operationHint};let hint=operationHint.trim(),hintLower=hint.toLowerCase(),exact=withOpId.filter(ep=>ep.operationId===hint);if(exact.length===1)return{ok:!0,endpoint:exact[0]};if(exact.length>1)return{ok:!1,reason:"ambiguous_operation",tag,tagMatches:exact,operationHint:hint};let exactCi=withOpId.filter(ep=>ep.operationId.toLowerCase()===hintLower);return exactCi.length===1?{ok:!0,endpoint:exactCi[0]}:exactCi.length>1?{ok:!1,reason:"ambiguous_operation",tag,tagMatches:exactCi,operationHint:hint}:{ok:!1,reason:"no_operation",tag,tagMatches,operationHint:hint}}var import_chalk4=__toESM(require_source(),1);var ApiTelemetryClient=class extends TelemetryClient{trackCliArgumentEndpoint(endpoint){if(endpoint){let normalized=this.normalizeEndpoint(endpoint);this.trackCliArgument({arg:"endpoint",value:normalized})}}trackCliArgumentOperationId(operationId){operationId&&this.trackCliArgument({arg:"operationId",value:operationId})}trackCliOptionMethod(method){if(method){let validMethods=["GET","POST","PUT","DELETE","PATCH","HEAD"],upperMethod=method.toUpperCase(),value=validMethods.includes(upperMethod)?upperMethod:this.redactedValue;this.trackCliOption({option:"method",value})}}trackCliOptionField(fields){fields&&fields.length>0&&this.trackCliOption({option:"field",value:this.redactedArgumentsLength(fields)})}trackCliOptionRawField(fields){fields&&fields.length>0&&this.trackCliOption({option:"raw-field",value:this.redactedArgumentsLength(fields)})}trackCliOptionHeader(headers){headers&&headers.length>0&&this.trackCliOption({option:"header",value:this.redactedArgumentsLength(headers)})}trackCliOptionInput(input){if(input){let value=input==="-"?"stdin":"file";this.trackCliOption({option:"input",value})}}trackCliOptionSpecUrl(specUrl){specUrl&&this.trackCliOption({option:"spec-url",value:this.redactedValue})}trackCliFlagPaginate(value){value&&this.trackCliFlag("paginate")}trackCliFlagInclude(value){value&&this.trackCliFlag("include")}trackCliFlagSilent(value){value&&this.trackCliFlag("silent")}trackCliFlagVerbose(value){value&&this.trackCliFlag("verbose")}trackCliFlagRaw(value){value&&this.trackCliFlag("raw")}trackCliFlagRefresh(value){value&&this.trackCliFlag("refresh")}trackCliOptionGenerate(format){if(format){let value=["curl"].includes(format)?format:this.redactedValue;this.trackCliOption({option:"generate",value})}}trackCliFlagDangerouslySkipPermissions(value){value&&this.trackCliFlag("dangerously-skip-permissions")}trackCliSubcommandList(){this.trackCliSubcommand({subcommand:"list",value:"list"})}trackCliOptionFormat(format){if(format){let value=["table","json"].includes(format)?format:this.redactedValue;this.trackCliOption({option:"format",value})}}trackCliFlagJson(json){json&&this.trackCliFlag("json")}normalizeEndpoint(endpoint){return endpoint.replace(/\/dpl_[a-zA-Z0-9]+/g,"/:deploymentId").replace(/\/prj_[a-zA-Z0-9]+/g,"/:projectId").replace(/\/team_[a-zA-Z0-9]+/g,"/:teamId").replace(/\/[a-f0-9]{24}/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:uuid")}};import{readFile}from"fs/promises";import{resolve}from"path";async function buildRequest(endpoint,flags){let headers={},body,customHeaders=flags["--header"]||[];for(let header of customHeaders){let colonIndex=header.indexOf(":");if(colonIndex>0){let key=header.substring(0,colonIndex).trim(),value=header.substring(colonIndex+1).trim();headers[key]=value}}let fields=flags["--field"]||[],rawFields=flags["--raw-field"]||[];if(fields.length>0||rawFields.length>0){body={};for(let field of fields){let{key,value}=await parseField(field,!0);body[key]=value}for(let field of rawFields){let{key,value}=await parseField(field,!1);body[key]=value}}if(flags["--input"]){let inputPath=flags["--input"];if(inputPath==="-"?body=await readStdin():body=await readFile(resolve(inputPath),"utf-8"),typeof body=="string")try{body=JSON.parse(body)}catch{}}let method=flags["--method"]?.toUpperCase()||"GET";return!flags["--method"]&&body&&(method="POST"),{url:endpoint,method,headers,body}}async function parseCliKeyValueField(field,typed){return parseField(field,typed)}async function parseField(field,typed){let eqIndex=field.indexOf("=");if(eqIndex===-1)throw new Error(`Invalid field format: ${field}. Expected key=value`);let key=field.substring(0,eqIndex),value=field.substring(eqIndex+1);if(typed&&typeof value=="string"){if(value.startsWith("@")){let filePath=value.substring(1);if(filePath==="-"?value=await readStdin():value=await readFile(resolve(filePath),"utf-8"),typeof value=="string")try{value=JSON.parse(value)}catch{}}else if(value==="true")value=!0;else if(value==="false")value=!1;else if(value==="null")value=null;else if(/^-?\d+$/.test(value))value=parseInt(value,10);else if(/^-?\d*\.\d+$/.test(value))value=parseFloat(value);else if(value.startsWith("[")||value.startsWith("{"))try{value=JSON.parse(value)}catch{}}return{key,value}}async function readStdin(){let chunks=[];for await(let chunk of process.stdin)chunks.push(Buffer.from(chunk));return Buffer.concat(chunks).toString("utf-8")}function formatOutput(data,options){return options.raw?typeof data=="string"?data:JSON.stringify(data):JSON.stringify(data,null,2)}function generateCurlCommand(config,baseUrl){let parts=["curl"];config.method!=="GET"&&parts.push(`-X ${config.method}`),parts.push("-H 'Authorization: Bearer <TOKEN>'");for(let[key,value]of Object.entries(config.headers))parts.push(`-H '${key}: ${escapeShellArg(value)}'`);if(config.method!=="GET"&&config.body){let bodyStr=typeof config.body=="string"?config.body:JSON.stringify(config.body);parts.push("-H 'Content-Type: application/json'"),parts.push(`-d '${escapeShellArg(bodyStr)}'`)}let fullUrl=`${baseUrl}${config.url}`;return parts.push(`'${fullUrl}'`),parts.join(` \\
|
|
7
|
+
import{humanReadableColumnLabel}from"./chunk-GHAY4PSD.js";import{FETCH_TIMEOUT_MS,OpenApiCache,SSO_API_URL,assertAllowedSpecUrl,readSpecResponse}from"./chunk-7VTPAXDC.js";import{table}from"./chunk-5SIC5273.js";import{apiCommand,listSubcommand}from"./chunk-UJQ6PBRF.js";import{printError}from"./chunk-LCMNJNSQ.js";import{help}from"./chunk-SLDWAIO3.js";import{TelemetryClient}from"./chunk-E32IBIXV.js";import{require_ms}from"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-F22QLVTX.js";import{validateJsonOutput}from"./chunk-7SAEZ4NC.js";import{packageName}from"./chunk-JESNVRVR.js";import{output_manager_default}from"./chunk-DWOJP4ST.js";import{getFlagsSpecification}from"./chunk-A2UZ2O7H.js";import{require_source}from"./chunk-NB2WLB3J.js";import{__toESM}from"./chunk-BZENIQ7N.js";import{createHash}from"crypto";var MAX_REDIRECTS=3;async function fetchSpecUrl(client,specUrl){let specOrigin=assertAllowedSpecUrl(specUrl).origin,probe=await fetchWithTimeout(specUrl,{readSpec:!0});if(probe.response.ok)return probe.spec??null;let nonce=getSetCookieValue(probe.response,"_vercel_sso_nonce");if(!nonce)throw output_manager_default.debug(`OpenAPI spec URL returned ${probe.response.status} without a Vercel SSO nonce`),new Error(formatHttpError(specUrl,probe.response));let token=client.authConfig.token;if(!token)return output_manager_default.debug("OpenAPI spec URL requires Vercel authentication"),null;let hashedNonce=createHash("sha256").update(nonce).digest("hex"),ssoUrl=`${SSO_API_URL}?url=${encodeURIComponent(specUrl)}&nonce=${hashedNonce}`,sso=await fetchWithTimeout(ssoUrl,{cookie:`authorization=${encodeURIComponent(`Bearer ${token}`)}; isLoggedIn=1`}),location=sso.response.headers.get("location");if(!location||!location.includes("_vercel_jwt="))throw output_manager_default.debug("OpenAPI spec URL: user has no access"),new Error(formatHttpError(specUrl,sso.response));let cookies=new Map([["_vercel_sso_nonce",nonce]]),url=location;for(let i=0;i<=MAX_REDIRECTS;i++){if(!isSameOriginUrl(url,specOrigin))return output_manager_default.debug("OpenAPI spec URL: cross-origin redirect rejected"),null;let{response,spec}=await fetchWithTimeout(url,{cookie:Array.from(cookies,([name,value])=>`${name}=${value}`).join("; "),readSpec:!0});if(response.ok)return spec??null;let next=response.headers.get("location");if(response.status>=300&&response.status<400&&next){let setJwt=getSetCookieValue(response,"_vercel_jwt");setJwt&&cookies.set("_vercel_jwt",setJwt);let nextUrl=new URL(next,url).href;if(!isSameOriginUrl(nextUrl,specOrigin))return output_manager_default.debug("OpenAPI spec URL: cross-origin redirect rejected"),null;url=nextUrl;continue}throw output_manager_default.debug(`OpenAPI spec URL: unexpected response ${response.status}`),new Error(formatHttpError(url,response))}return output_manager_default.debug("OpenAPI spec URL: too many redirects"),null}function createOpenApiCache(client,specUrl){return new OpenApiCache(specUrl?{specUrl,fetchSpecUrl:url=>fetchSpecUrl(client,url)}:void 0)}async function fetchWithTimeout(url,options){let controller=new AbortController,timeoutId=setTimeout(()=>controller.abort(),1e4);try{let response=await fetch(url,{redirect:"manual",signal:controller.signal,headers:options?.cookie?{cookie:options.cookie}:void 0}),spec=options?.readSpec&&response.ok?await readSpecResponse(response,formatDiagnosticUrl(url)):void 0;return{response,spec}}finally{clearTimeout(timeoutId)}}function isSameOriginUrl(url,origin){try{return new URL(url).origin===origin}catch{return!1}}function formatHttpError(url,response){let statusText=response.statusText?` ${response.statusText}`:"";return`Could not load OpenAPI spec from ${formatDiagnosticUrl(url)}: HTTP ${response.status}${statusText}.`}function formatDiagnosticUrl(url){try{let parsed=new URL(url);parsed.hash="";for(let key of parsed.searchParams.keys())parsed.searchParams.set(key,"[redacted]");return parsed.href}catch{return url}}function getSetCookieValue(response,name){let header=response.headers.get("set-cookie");if(!header)return null;let match=header.match(new RegExp(`${name}=([^;,\\s]+)`));return match?match[1]:null}function foldNamingStyle(input){return input.trim().replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/([A-Z])([A-Z][a-z])/g,"$1 $2").replace(/[-_\s]+/g," ").trim().toLowerCase().replace(/\s+/g,"")}function operationIdToKebabCase(operationId){let s=operationId.trim();return s?s.replace(/([a-z\d])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").replace(/[-_\s]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase():"unnamed"}function inferCliSubcommandAliases(ep){let upper=ep.method.toUpperCase(),hasPathParams=ep.parameters.some(p=>p.in==="path");switch(upper){case"GET":return hasPathParams?["inspect","get"]:["ls","list"];case"POST":return["add","create"];case"DELETE":return["rm","remove"];case"PUT":case"PATCH":return["update"];default:return[]}}var import_ms=__toESM(require_ms(),1),import_chalk=__toESM(require_source(),1);function getByPath(obj,path){let parts=path.split(".").filter(Boolean),cur=obj;for(let p of parts){if(cur===null||typeof cur!="object")return;cur=cur[p]}return cur}var TIMESTAMP_FIELD_PATTERN=/(?:^|\.)(created|updated|deleted|expired|blocked|completed|started|finished|modified|verified|published|cancelled|revoked|invited|accepted|accessed|deployed)(?:At|_at|On|_on)?$/i,MIN_TIMESTAMP_MS=1e12,MAX_TIMESTAMP_MS=41024448e5;function isTimestampValue(value,columnPath){return typeof value!="number"||!Number.isFinite(value)||value<MIN_TIMESTAMP_MS||value>MAX_TIMESTAMP_MS?!1:TIMESTAMP_FIELD_PATTERN.test(columnPath)}function formatRelativeTime(timestamp){let diff=Date.now()-timestamp;return diff<0?"just now":import_chalk.default.gray((0,import_ms.default)(diff))}function stringifyCell(value,columnPath){return value==null?import_chalk.default.gray("--"):columnPath&&isTimestampValue(value,columnPath)?formatRelativeTime(value):typeof value=="object"?JSON.stringify(value):String(value)}function styleColumnKey(plainLabel){return import_chalk.default.gray(plainLabel)}function columnsForRow(r,display){return r.limited===!0&&display.columnsWhenLimited?.length?display.columnsWhenLimited:display.columnsDefault}function formatAsCard(r,display){let columns=columnsForRow(r,display);if(!columns.length)return null;let rows=columns.map(colPath=>[styleColumnKey(humanReadableColumnLabel(colPath)),stringifyCell(getByPath(r,colPath),colPath)]);return table(rows,{align:["l","l"],hsep:2})}function formatAsDataTable(items,display){if(items.length===0)return"(empty)";let first=items[0];if(first===null||typeof first!="object"||Array.isArray(first)){let headers2=[styleColumnKey(humanReadableColumnLabel("#")),styleColumnKey(humanReadableColumnLabel("value"))],rows=items.map((v,i)=>[String(i),stringifyCell(v,"value")]);return table([headers2,...rows])}let columns=columnsForRow(first,display);if(!columns.length)return null;let headers=columns.map(p=>styleColumnKey(humanReadableColumnLabel(p))),dataRows=items.map(item=>{let row=item!==null&&typeof item=="object"&&!Array.isArray(item)?item:{};return columns.map(colPath=>stringifyCell(getByPath(row,colPath),colPath))});return table([headers,...dataRows])}function resolveEndpointByTagAndOperationId(endpoints,tag,operationHint){let tagLower=tag.toLowerCase(),tagMatches=endpoints.filter(ep=>ep.tags.some(t=>t.toLowerCase()===tagLower));if(tagMatches.length===0)return{ok:!1,reason:"no_tag",tag,tagMatches:[],operationHint};let withOpId=tagMatches.filter(ep=>ep.operationId.length>0);if(withOpId.length===0)return{ok:!1,reason:"no_operation",tag,tagMatches,operationHint};let hint=operationHint.trim(),hintLower=hint.toLowerCase(),exact=withOpId.filter(ep=>ep.operationId===hint);if(exact.length===1)return{ok:!0,endpoint:exact[0]};if(exact.length>1)return{ok:!1,reason:"ambiguous_operation",tag,tagMatches:exact,operationHint:hint};let exactCi=withOpId.filter(ep=>ep.operationId.toLowerCase()===hintLower);return exactCi.length===1?{ok:!0,endpoint:exactCi[0]}:exactCi.length>1?{ok:!1,reason:"ambiguous_operation",tag,tagMatches:exactCi,operationHint:hint}:{ok:!1,reason:"no_operation",tag,tagMatches,operationHint:hint}}var import_chalk4=__toESM(require_source(),1);var ApiTelemetryClient=class extends TelemetryClient{trackCliArgumentEndpoint(endpoint){if(endpoint){let normalized=this.normalizeEndpoint(endpoint);this.trackCliArgument({arg:"endpoint",value:normalized})}}trackCliArgumentOperationId(operationId){operationId&&this.trackCliArgument({arg:"operationId",value:operationId})}trackCliOptionMethod(method){if(method){let validMethods=["GET","POST","PUT","DELETE","PATCH","HEAD"],upperMethod=method.toUpperCase(),value=validMethods.includes(upperMethod)?upperMethod:this.redactedValue;this.trackCliOption({option:"method",value})}}trackCliOptionField(fields){fields&&fields.length>0&&this.trackCliOption({option:"field",value:this.redactedArgumentsLength(fields)})}trackCliOptionRawField(fields){fields&&fields.length>0&&this.trackCliOption({option:"raw-field",value:this.redactedArgumentsLength(fields)})}trackCliOptionHeader(headers){headers&&headers.length>0&&this.trackCliOption({option:"header",value:this.redactedArgumentsLength(headers)})}trackCliOptionInput(input){if(input){let value=input==="-"?"stdin":"file";this.trackCliOption({option:"input",value})}}trackCliOptionSpecUrl(specUrl){specUrl&&this.trackCliOption({option:"spec-url",value:this.redactedValue})}trackCliFlagPaginate(value){value&&this.trackCliFlag("paginate")}trackCliFlagInclude(value){value&&this.trackCliFlag("include")}trackCliFlagSilent(value){value&&this.trackCliFlag("silent")}trackCliFlagVerbose(value){value&&this.trackCliFlag("verbose")}trackCliFlagRaw(value){value&&this.trackCliFlag("raw")}trackCliFlagRefresh(value){value&&this.trackCliFlag("refresh")}trackCliOptionGenerate(format){if(format){let value=["curl"].includes(format)?format:this.redactedValue;this.trackCliOption({option:"generate",value})}}trackCliFlagDangerouslySkipPermissions(value){value&&this.trackCliFlag("dangerously-skip-permissions")}trackCliSubcommandList(){this.trackCliSubcommand({subcommand:"list",value:"list"})}trackCliOptionFormat(format){if(format){let value=["table","json"].includes(format)?format:this.redactedValue;this.trackCliOption({option:"format",value})}}trackCliFlagJson(json){json&&this.trackCliFlag("json")}normalizeEndpoint(endpoint){return endpoint.replace(/\/dpl_[a-zA-Z0-9]+/g,"/:deploymentId").replace(/\/prj_[a-zA-Z0-9]+/g,"/:projectId").replace(/\/team_[a-zA-Z0-9]+/g,"/:teamId").replace(/\/[a-f0-9]{24}/g,"/:id").replace(/\/[a-f0-9-]{36}/g,"/:uuid")}};import{readFile}from"fs/promises";import{resolve}from"path";async function buildRequest(endpoint,flags){let headers={},body,customHeaders=flags["--header"]||[];for(let header of customHeaders){let colonIndex=header.indexOf(":");if(colonIndex>0){let key=header.substring(0,colonIndex).trim(),value=header.substring(colonIndex+1).trim();headers[key]=value}}let fields=flags["--field"]||[],rawFields=flags["--raw-field"]||[];if(fields.length>0||rawFields.length>0){body={};for(let field of fields){let{key,value}=await parseField(field,!0);body[key]=value}for(let field of rawFields){let{key,value}=await parseField(field,!1);body[key]=value}}if(flags["--input"]){let inputPath=flags["--input"];if(inputPath==="-"?body=await readStdin():body=await readFile(resolve(inputPath),"utf-8"),typeof body=="string")try{body=JSON.parse(body)}catch{}}let method=flags["--method"]?.toUpperCase()||"GET";return!flags["--method"]&&body&&(method="POST"),{url:endpoint,method,headers,body}}async function parseCliKeyValueField(field,typed){return parseField(field,typed)}async function parseField(field,typed){let eqIndex=field.indexOf("=");if(eqIndex===-1)throw new Error(`Invalid field format: ${field}. Expected key=value`);let key=field.substring(0,eqIndex),value=field.substring(eqIndex+1);if(typed&&typeof value=="string"){if(value.startsWith("@")){let filePath=value.substring(1);if(filePath==="-"?value=await readStdin():value=await readFile(resolve(filePath),"utf-8"),typeof value=="string")try{value=JSON.parse(value)}catch{}}else if(value==="true")value=!0;else if(value==="false")value=!1;else if(value==="null")value=null;else if(/^-?\d+$/.test(value))value=parseInt(value,10);else if(/^-?\d*\.\d+$/.test(value))value=parseFloat(value);else if(value.startsWith("[")||value.startsWith("{"))try{value=JSON.parse(value)}catch{}}return{key,value}}async function readStdin(){let chunks=[];for await(let chunk of process.stdin)chunks.push(Buffer.from(chunk));return Buffer.concat(chunks).toString("utf-8")}function formatOutput(data,options){return options.raw?typeof data=="string"?data:JSON.stringify(data):JSON.stringify(data,null,2)}function generateCurlCommand(config,baseUrl){let parts=["curl"];config.method!=="GET"&&parts.push(`-X ${config.method}`),parts.push("-H 'Authorization: Bearer <TOKEN>'");for(let[key,value]of Object.entries(config.headers))parts.push(`-H '${key}: ${escapeShellArg(value)}'`);if(config.method!=="GET"&&config.body){let bodyStr=typeof config.body=="string"?config.body:JSON.stringify(config.body);parts.push("-H 'Content-Type: application/json'"),parts.push(`-d '${escapeShellArg(bodyStr)}'`)}let fullUrl=`${baseUrl}${config.url}`;return parts.push(`'${fullUrl}'`),parts.join(` \\
|
|
8
8
|
`)}function escapeShellArg(str){return str.replace(/'/g,"'\\''")}import{readFile as readFile2}from"fs/promises";import{resolve as resolve2}from"path";var GLOBAL_CLI_QUERY_PARAMS=new Set(["teamId","slug"]);async function parseOperationKeyValuePairs(endpoint,bodyFields,flags,positionalKeyValues){let pathParamNames=new Set(endpoint.parameters.filter(p=>p.in==="path").map(p=>p.name)),queryParamNames=new Set(endpoint.parameters.filter(p=>p.in==="query").map(p=>p.name)),headerParamNames=new Set(endpoint.parameters.filter(p=>p.in==="header").map(p=>p.name)),bodyFieldNames=new Set(bodyFields.map(f=>f.name)),pathValues={},queryValues={},headerValues={},body={};async function dispatchPair(field,typed){let eqIndex=field.indexOf("=");if(eqIndex===-1)throw new Error(`Invalid option "${field}". Expected key=value (or use options -F / -f).`);let key=field.slice(0,eqIndex),param=endpoint.parameters.find(p=>p.name===key);if(param?.in==="path"){let{value}=await parseCliKeyValueField(field,!1);pathValues[key]=String(value);return}if(param?.in==="query"){let{value}=await parseCliKeyValueField(field,typed);queryValues[key]=typeof value=="object"&&value!==null?JSON.stringify(value):String(value);return}if(param?.in==="header"){let{value}=await parseCliKeyValueField(field,!1);headerValues[key]=String(value);return}if(param?.in==="cookie")throw new Error(`Option "${key}" is cookie-based; set it via headers instead.`);if(bodyFieldNames.has(key)){let{value}=await parseCliKeyValueField(field,typed);body[key]=value;return}if(!param&&pathParamNames.has(key)){let{value}=await parseCliKeyValueField(field,!1);pathValues[key]=String(value);return}if(!param&&queryParamNames.has(key)){let{value}=await parseCliKeyValueField(field,typed);queryValues[key]=typeof value=="object"&&value!==null?JSON.stringify(value):String(value);return}if(!param&&headerParamNames.has(key)){let{value}=await parseCliKeyValueField(field,!1);headerValues[key]=String(value);return}throw new Error(`Unknown option "${key}" for operation ${endpoint.operationId}. Check the API docs or run \`vercel api ls --json\`.`)}for(let field of flags["--field"]||[])await dispatchPair(field,!0);for(let field of flags["--raw-field"]||[])await dispatchPair(field,!1);for(let field of positionalKeyValues)await dispatchPair(field,!0);return{pathValues,queryValues,headerValues,body}}function getMissingRequiredOperationParams(endpoint,bodyFields,parsed,flags){let missingPath=endpoint.parameters.filter(p=>p.in==="path").filter(p=>parsed.pathValues[p.name]===void 0),missingQuery=endpoint.parameters.filter(p=>p.in==="query"&&p.required&&!GLOBAL_CLI_QUERY_PARAMS.has(p.name)).filter(p=>parsed.queryValues[p.name]===void 0),missingHeader=endpoint.parameters.filter(p=>p.in==="header"&&p.required).filter(p=>parsed.headerValues[p.name]===void 0),missingBody=bodyFields.filter(f=>f.required&&parsed.body[f.name]===void 0&&!flags["--input"]);return{path:missingPath,query:missingQuery,header:missingHeader,body:missingBody}}function getUnsetOptionalOperationParams(endpoint,bodyFields,parsed,flags){let unsetQuery=endpoint.parameters.filter(p=>p.in==="query"&&parsed.queryValues[p.name]===void 0&&(!p.required||GLOBAL_CLI_QUERY_PARAMS.has(p.name))),unsetHeader=endpoint.parameters.filter(p=>p.in==="header"&&!p.required&&parsed.headerValues[p.name]===void 0),unsetBody=bodyFields.filter(f=>!f.required&&parsed.body[f.name]===void 0&&!flags["--input"]);return{query:unsetQuery,header:unsetHeader,body:unsetBody}}async function buildRequestForResolvedOperation(endpoint,bodyFields,flags,positionalKeyValues){let headers={},customHeaders=flags["--header"]||[];for(let header of customHeaders){let colonIndex=header.indexOf(":");if(colonIndex>0){let key=header.substring(0,colonIndex).trim(),value=header.substring(colonIndex+1).trim();headers[key]=value}}let method=(flags["--method"]?.toUpperCase()||endpoint.method).toUpperCase(),pathParamNames=new Set(endpoint.parameters.filter(p=>p.in==="path").map(p=>p.name)),parsed=await parseOperationKeyValuePairs(endpoint,bodyFields,flags,positionalKeyValues),{pathValues,queryValues,headerValues,body}=parsed;for(let[k,v]of Object.entries(headerValues))headers[k]=v;let urlPath=endpoint.path;for(let name of pathParamNames){let value=pathValues[name];if(value===void 0)throw new Error(`Missing required path option {${name}} for ${endpoint.operationId}.`);urlPath=urlPath.replace(`{${name}}`,encodeURIComponent(value))}if(/\{[^}]+\}/.test(urlPath))throw new Error(`Unresolved path placeholders in ${urlPath}. Provide values for all path options.`);let requiredQuery=endpoint.parameters.filter(p=>p.in==="query"&&p.required&&!GLOBAL_CLI_QUERY_PARAMS.has(p.name));for(let p of requiredQuery)if(queryValues[p.name]===void 0)throw new Error(`Missing required query option "${p.name}" for ${endpoint.operationId}.`);let requiredHeader=endpoint.parameters.filter(h=>h.in==="header"&&h.required);for(let h of requiredHeader)if(headerValues[h.name]===void 0)throw new Error(`Missing required header option "${h.name}" for ${endpoint.operationId}.`);let requiredBody=bodyFields.filter(f=>f.required);for(let f of requiredBody)if(body[f.name]===void 0&&!flags["--input"])throw new Error(`Missing required body option "${f.name}" for ${endpoint.operationId}.`);let queryString=new URLSearchParams(queryValues).toString();queryString&&(urlPath+=(urlPath.includes("?")?"&":"?")+queryString);let finalBody=Object.keys(body).length>0?body:void 0;if(flags["--input"]){let inputPath=flags["--input"],inputBody;if(inputPath==="-"?inputBody=await readStdin():inputBody=await readFile2(resolve2(inputPath),"utf-8"),typeof inputBody=="string")try{finalBody=JSON.parse(inputBody)}catch{finalBody=inputBody}else finalBody=inputBody}return(method==="GET"||method==="HEAD")&&(finalBody=void 0),{url:urlPath,method,headers,body:finalBody}}var API_BASE_URL="https://api.vercel.com";var import_chalk2=__toESM(require_source(),1);function colorizeMethod(method){switch(method){case"GET":return import_chalk2.default.cyan(method);case"POST":return import_chalk2.default.green(method);case"PUT":return import_chalk2.default.yellow(method);case"PATCH":return import_chalk2.default.blue(method);case"DELETE":return import_chalk2.default.red(method);default:return method}}function colorizeMethodPadded(method,width=7){let colored=colorizeMethod(method),padding=" ".repeat(Math.max(0,width-method.length));return colored+padding}function formatPathParam(paramName){return import_chalk2.default.cyan(`{${paramName}}`)}function formatTypeHint(type){return import_chalk2.default.dim(`[${type}]`)}function formatDescription(description){return description?import_chalk2.default.gray(` (${description})`):""}var import_chalk3=__toESM(require_source(),1);function getByPath2(obj,path){let current=obj;for(let segment of path.split(".")){if(current==null||typeof current!="object")return;current=current[segment]}return current}function parseArrayColumns(data,columns){let entries=Object.entries(columns),first=entries[0];if(!first)return null;let bracketIdx=first[1].indexOf("[].");if(bracketIdx===-1)return null;let arrayKey=first[1].slice(0,bracketIdx),rowColumns={};for(let[label,path]of entries){let prefix=path.slice(0,bracketIdx);if(prefix!==arrayKey||!path.startsWith(prefix+"[]."))return null;rowColumns[label]=path.slice(bracketIdx+3)}let arr=getByPath2(data,arrayKey);return Array.isArray(arr)?{rows:arr,rowColumns}:null}function formatValue(value){return value==null?import_chalk3.default.dim("\u2013"):typeof value=="number"?value>1e12&&value<2e12?new Date(value).toISOString():String(value):typeof value=="boolean"?String(value):typeof value=="string"?value:JSON.stringify(value)}function renderCard(data,columns){let entries=Object.entries(columns),maxLabel=Math.max(...entries.map(([label])=>label.length));return entries.map(([label,path])=>{let value=getByPath2(data,path);return` ${import_chalk3.default.gray(label.padEnd(maxLabel))} ${formatValue(value)}`}).join(`
|
|
9
9
|
`)}function renderTable(rows,columns){let entries=Object.entries(columns),headerRow=entries.map(([label])=>label),dataRows=rows.map(row=>entries.map(([,path])=>formatValue(getByPath2(row,path)))),widths=entries.map(([label],colIdx)=>{let dataMax=dataRows.reduce((max,row)=>Math.max(max,stripAnsi(row[colIdx]).length),0);return Math.max(label.length,dataMax)}),header=headerRow.map((h,i)=>import_chalk3.default.bold(h.padEnd(widths[i]))).join(" "),body=dataRows.map(row=>row.map((cell,i)=>{let pad=widths[i]-stripAnsi(cell).length;return cell+" ".repeat(Math.max(0,pad))}).join(" "));return[header,...body].join(`
|
|
10
10
|
`)}function stripAnsi(str){return str.replace(/\x1b\[[0-9;]*m/g,"")}async function api(client){let telemetryClient=new ApiTelemetryClient({opts:{store:client.telemetryEventStore}}),parsedArgs,flagsSpec=getFlagsSpecification(apiCommand.options);try{parsedArgs=parseArguments(client.argv.slice(2),flagsSpec,{permissive:!0})}catch(err){return printError(err),2}let{args,flags}=parsedArgs,needHelp=flags["--help"],firstArg=args[1];if(firstArg==="ls"||firstArg==="list"){let lsFlagsSpec=getFlagsSpecification(listSubcommand.options),lsParsedArgs;try{lsParsedArgs=parseArguments(client.argv.slice(2),lsFlagsSpec)}catch(err){return printError(err),2}let lsFlags=lsParsedArgs.flags;if(lsFlags["--help"])return telemetryClient.trackCliFlagHelp("api",firstArg),output_manager_default.print(help(listSubcommand,{stream:client.stderr,parent:apiCommand,columns:client.stderr.columns})),0;let formatResult=validateJsonOutput(lsFlags);return formatResult.valid?(telemetryClient.trackCliSubcommandList(),lsFlags["--refresh"]&&telemetryClient.trackCliFlagRefresh(!0),lsFlags["--format"]&&telemetryClient.trackCliOptionFormat(lsFlags["--format"]),telemetryClient.trackCliFlagJson(lsFlags["--json"]),lsFlags["--spec-url"]&&telemetryClient.trackCliOptionSpecUrl(lsFlags["--spec-url"]),listEndpoints(client,lsFlags["--refresh"]??!1,lsFlags["--spec-url"],formatResult.jsonOutput?"json":"table")):(output_manager_default.error(formatResult.error),2)}if(needHelp)return telemetryClient.trackCliFlagHelp("api"),output_manager_default.print(help(apiCommand,{stream:client.stderr,columns:client.stderr.columns})),0;flags["--dangerously-skip-permissions"]&&(client.dangerouslySkipPermissions=!0);let endpoint,selectedMethod,selectedBodyFields=[];if(firstArg)endpoint=firstArg;else if(client.stdin.isTTY){let selected=await promptEndpointSelection(client,flags["--refresh"]??!1,flags["--spec-url"]);if(!selected)return 1;endpoint=selected.finalUrl,selectedMethod=selected.method,selectedBodyFields=selected.bodyFields}else return output_manager_default.error("Endpoint is required. Usage: vercel api <endpoint>"),2;if(endpoint&&!endpoint.startsWith("/"))return output_manager_default.error(`Invalid arguments. Use an API path starting with /, or run \`${packageName} api\` interactively.`),2;try{if(new URL(endpoint,API_BASE_URL).origin!==API_BASE_URL)return output_manager_default.error("Invalid endpoint: must be a Vercel API path, not an external URL"),2}catch{return output_manager_default.error("Invalid endpoint URL format"),1}let finalFlags={...flags};if(selectedMethod&&!flags["--method"]&&(finalFlags["--method"]=selectedMethod),selectedBodyFields.length>0){let existingFields=finalFlags["--field"]||[];finalFlags["--field"]=[...existingFields,...selectedBodyFields]}let requestConfig;try{requestConfig=await buildRequest(endpoint,finalFlags)}catch(err){return printError(err),1}if(telemetryClient.trackCliArgumentEndpoint(requestConfig.url),telemetryClient.trackCliArgumentOperationId(void 0),telemetryClient.trackCliOptionMethod(flags["--method"]),telemetryClient.trackCliOptionHeader(flags["--header"]),telemetryClient.trackCliOptionInput(flags["--input"]),flags["--paginate"]&&telemetryClient.trackCliFlagPaginate(!0),flags["--include"]&&telemetryClient.trackCliFlagInclude(!0),flags["--silent"]&&telemetryClient.trackCliFlagSilent(!0),flags["--verbose"]&&telemetryClient.trackCliFlagVerbose(!0),flags["--raw"]&&telemetryClient.trackCliFlagRaw(!0),flags["--refresh"]&&telemetryClient.trackCliFlagRefresh(!0),flags["--spec-url"]&&telemetryClient.trackCliOptionSpecUrl(flags["--spec-url"]),flags["--generate"]&&telemetryClient.trackCliOptionGenerate(flags["--generate"]),flags["--dangerously-skip-permissions"]&&telemetryClient.trackCliFlagDangerouslySkipPermissions(!0),flags["--generate"]==="curl"){let curlCmd=generateCurlCommand(requestConfig,"https://api.vercel.com");return output_manager_default.log(""),output_manager_default.log("Replace <TOKEN> with your auth token:"),output_manager_default.log(""),client.stdout.write(curlCmd+`
|
|
@@ -4,7 +4,7 @@ import { dirname as __dirname_ } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
const __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __dirname_(__filename);
|
|
7
|
-
import{humanizeReference,renderAlertTable}from"./chunk-SKSOCUDZ.js";import{truncateEnd,truncateMiddle}from"./chunk-ID663OJ7.js";import{formatDate}from"./chunk-HRR57QNP.js";import{buildCommandWithGlobalFlags}from"./chunk-
|
|
7
|
+
import{humanizeReference,renderAlertTable}from"./chunk-SKSOCUDZ.js";import{truncateEnd,truncateMiddle}from"./chunk-ID663OJ7.js";import{formatDate}from"./chunk-HRR57QNP.js";import{buildCommandWithGlobalFlags}from"./chunk-I7U2XP4X.js";import{printAlignedLabel}from"./chunk-26QK3I2S.js";import{quoteArg}from"./chunk-F53OKXYI.js";import{output_manager_default}from"./chunk-DWOJP4ST.js";import{require_source}from"./chunk-NB2WLB3J.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function formatBoolean(value){return value?"yes":"no"}function formatOperator(operator){return{gt:">",gte:">=",lt:"<",lte:"<="}[operator]??operator}function formatPublicRuleScope(rule){let scope=rule.ruleScope;return scope.type==="all"?"all projects":scope.type==="project"?`project: ${scope.projectId}`:`${scope.type}: ${scope.projectIds.join(", ")}`}function formatMetricSelection(metric){let modifiers=[metric.per?`per ${metric.per}`:void 0,metric.normalize?`normalize ${metric.normalize}`:void 0,metric.dimensions?.length?`dimensions ${metric.dimensions.join(", ")}`:void 0].filter(Boolean);return`${metric.aggregation} ${metric.metric}${modifiers.length?` (${modifiers.join("; ")})`:""}`}function formatCustomTrigger(trigger){let minimum=trigger.minimum?`; minimum ${trigger.minimum.output} >= ${trigger.minimum.threshold}`:"";return trigger.type==="anomaly"?`${trigger.output} anomaly at ${trigger.standardDeviations} standard deviations${minimum}`:`${trigger.output} ${formatOperator(trigger.operator)} ${trigger.threshold}${minimum}`}function formatCustomCondition(rule){if(!rule.querySupported)return"Query unavailable via API";let query=rule.evaluation.query,output=query.outputs[0];return`${query.formulas?.[output]?`${output} = ${query.formulas[output]}`:query.metrics[output]?formatMetricSelection(query.metrics[output]):output}; ${formatCustomTrigger(rule.trigger)}; ${rule.evaluation.window}`}function formatBuiltInCondition(rule){return`${rule.triggers.mode==="all"?"all triggers":rule.triggers.items.map(trigger=>humanizeReference(trigger.type)).join(", ")}; minimum ${rule.matchMinimumSeverityLevel}`}function formatRuleCondition(rule){return rule.type==="built-in"?formatBuiltInCondition(rule):formatCustomCondition(rule)}function printRules(rules){let rows=[["Name","Monitor ID","Type","Scope","Condition"].map(header=>import_chalk.default.cyan(header)),...rules.map(rule=>[import_chalk.default.bold(truncateEnd(rule.name,36)),import_chalk.default.dim(rule.id),rule.isDefault?`${rule.type} (default)`:rule.type,truncateMiddle(formatPublicRuleScope(rule),38),truncateEnd(formatRuleCondition(rule),72)])];output_manager_default.print(`
|
|
8
8
|
${renderAlertTable(rows,2)}
|
|
9
9
|
`)}function commonRows(rule){return[["Name",rule.name],["Monitor ID",rule.id],["Type",rule.type],["Scope",formatPublicRuleScope(rule)],["Default",formatBoolean(rule.isDefault)],...rule.createdAt?[["Created",formatDate(rule.createdAt)]]:[],...rule.updatedAt?[["Updated",formatDate(rule.updatedAt)]]:[]]}function notificationRows(rule){return[["Team owner notifications",formatBoolean(rule.notificationSettings.enableTeamOwnerNotifications)],...rule.notificationSettings.incidentIoRoutingKey?[["Incident.io routing key",rule.notificationSettings.incidentIoRoutingKey]]:[]]}function printBuiltInRule(rule){output_manager_default.print(`${import_chalk.default.cyan("Built-in conditions")}
|
|
10
10
|
|
|
@@ -4,4 +4,4 @@ import { dirname as __dirname_ } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
const __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __dirname_(__filename);
|
|
7
|
-
import{getSubcommand}from"./chunk-ETV3C2CV.js";import{monitorsCommand,monitorsNotificationsAggregateCommand}from"./chunk-BGWS5R5R.js";import{TelemetryClient}from"./chunk-
|
|
7
|
+
import{getSubcommand}from"./chunk-ETV3C2CV.js";import{monitorsCommand,monitorsNotificationsAggregateCommand}from"./chunk-BGWS5R5R.js";import{TelemetryClient}from"./chunk-E32IBIXV.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError}from"./chunk-I7U2XP4X.js";import{takeCommand}from"./chunk-F22QLVTX.js";import{warnDeprecatedSubcommand}from"./chunk-7SAEZ4NC.js";import{output_manager_default}from"./chunk-DWOJP4ST.js";import{getFlagsSpecification}from"./chunk-A2UZ2O7H.js";var MonitorsTelemetryClient=class extends TelemetryClient{trackCliSubcommandLs(actual){this.trackCliSubcommand({subcommand:"ls",value:actual})}trackCliSubcommandSchema(actual){this.trackCliSubcommand({subcommand:"schema",value:actual})}trackCliSubcommandAdd(actual){this.trackCliSubcommand({subcommand:"add",value:actual})}trackCliSubcommandInspect(actual){this.trackCliSubcommand({subcommand:"inspect",value:actual})}trackCliSubcommandRemove(actual){this.trackCliSubcommand({subcommand:"remove",value:actual})}trackCliSubcommandUpdate(actual){this.trackCliSubcommand({subcommand:"update",value:actual})}trackCliSubcommandNotifications(actual){this.trackCliSubcommand({subcommand:"notifications",value:actual})}trackCliOptionType(v){v&&v.length>0&&this.trackCliOption({option:"type",value:v.join(",")})}trackCliFlagAll(v){v&&this.trackCliFlag("all")}trackCliFlagJson(v){v&&this.trackCliFlag("json")}};var MONITORS_CONFIG={ls:["ls","list"],schema:["schema"],add:["add","create"],inspect:["inspect","get"],remove:["remove","rm","delete"],update:["update","patch"],notifications:["notifications"]},monitorsRoutingFlags=getFlagsSpecification([...monitorsCommand.subcommands,...monitorsNotificationsAggregateCommand.subcommands].flatMap(command=>[...command.options]));async function runMonitors(client,argv,api){let{command,args:argsWithoutCommand}=takeCommand(argv,monitorsRoutingFlags),found=command?getSubcommand([command],MONITORS_CONFIG):void 0;if(command&&found?.subcommand==null)return outputAgentError(client,{status:"error",reason:AGENT_REASON.INVALID_ARGUMENTS,message:`Unknown "monitors" subcommand "${command}".`,next:[{command:buildCommandWithGlobalFlags(client.argv,"monitors --help"),when:"Show valid monitors subcommands"}]},2),output_manager_default.error(`Unknown "monitors" subcommand "${command}". Run \`vercel monitors --help\`.`),2;let resolved=found?.subcommand??"ls",original=found?.subcommandOriginal??"ls",args=found?argsWithoutCommand:argv,telemetry=new MonitorsTelemetryClient({opts:{store:client.telemetryEventStore}});switch(resolved){case"ls":return telemetry.trackCliSubcommandLs(original),(await import("./ls-NQVH63KO.js")).default(client,args,api,telemetry);case"schema":return telemetry.trackCliSubcommandSchema(original),(await import("./schema-H5RRV4J3.js")).default(client,args,api);case"add":return telemetry.trackCliSubcommandAdd(original),original==="create"&&warnDeprecatedSubcommand(client,"monitors create","monitors add"),(await import("./add-TPDABQQA.js")).default(client,args,api);case"inspect":return telemetry.trackCliSubcommandInspect(original),original==="get"&&warnDeprecatedSubcommand(client,"monitors get","monitors inspect"),(await import("./rule-inspect-4EBB5IDK.js")).default(client,args,api);case"remove":return telemetry.trackCliSubcommandRemove(original),original==="delete"&&warnDeprecatedSubcommand(client,"monitors delete","monitors remove"),(await import("./rm-C73EKJS4.js")).default(client,args,api);case"update":return telemetry.trackCliSubcommandUpdate(original),original==="patch"&&warnDeprecatedSubcommand(client,"monitors patch","monitors update"),(await import("./update-4LNUD2AB.js")).default(client,args,api);case"notifications":return(await import("./notifications-A46PC7QX.js")).default(client,args,api,telemetry);default:return output_manager_default.error(`Unhandled monitors subcommand: ${String(resolved)}`),1}}export{monitorsRoutingFlags,runMonitors};
|
|
@@ -4,4 +4,4 @@ import { dirname as __dirname_ } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
const __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __dirname_(__filename);
|
|
7
|
-
import{require_dist,require_dist2}from"./chunk-HVDGNAPM.js";import{require_types}from"./chunk-VLYVVC3P.js";import{require_build_utils}from"./chunk-DWOJP4ST.js";import{__commonJS,__toESM}from"./chunk-BZENIQ7N.js";var require_dist3=__commonJS({"../../internals/service-topology/dist/index.js"(exports,module){"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),src_exports={};__export(src_exports,{INTERNAL_SERVICE_PREFIX:()=>import_fs_detectors2.INTERNAL_SERVICE_PREFIX,autoDetectServices:()=>import_fs_detectors2.autoDetectServices,detectDaemons:()=>import_fs_detectors2.detectDaemons,detectServices:()=>import_fs_detectors2.detectServices,generateServiceRewrites:()=>import_fs_detectors2.generateServiceRewrites,generateServicesRoutes:()=>import_fs_detectors2.generateServicesRoutes,getInternalServiceCronPath:()=>import_fs_detectors2.getInternalServiceCronPath,getInternalServiceCronPathPrefix:()=>import_fs_detectors2.getInternalServiceCronPathPrefix,getInternalServiceFunctionPath:()=>import_fs_detectors2.getInternalServiceFunctionPath,getInternalServiceWorkerPath:()=>import_fs_detectors2.getInternalServiceWorkerPath,getInternalServiceWorkerPathPrefix:()=>import_fs_detectors2.getInternalServiceWorkerPathPrefix,hasLegacyServicesConfig:()=>import_fs_detectors2.hasLegacyServicesConfig,isExperimentalService:()=>import_fs_detectors2.isExperimentalService,isExperimentalServiceV2:()=>import_fs_detectors2.isExperimentalServiceV2,isRouteOwningBuilder:()=>import_fs_detectors2.isRouteOwningBuilder,isStaticBuild:()=>import_fs_detectors2.isStaticBuild,migrateExperimentalServices:()=>import_fs_detectors2.migrateExperimentalServices,planExperimentalServicesMigration:()=>import_fs_detectors2.planExperimentalServicesMigration,resolveAllConfiguredServices:()=>import_fs_detectors2.resolveAllConfiguredServices,resolveAllConfiguredServicesV2:()=>import_fs_detectors2.resolveAllConfiguredServicesV2,resolveConfiguredServiceV2:()=>import_fs_detectors2.resolveConfiguredServiceV2,validateServiceConfigV2:()=>import_fs_detectors2.validateServiceConfigV2});module.exports=__toCommonJS(src_exports);var import_fs_detectors2=require_dist2()}});var import_routing_utils=__toESM(require_dist(),1),import_build_utils=__toESM(require_build_utils(),1),import_types=__toESM(require_types(),1),import_fs_detectors=__toESM(require_dist2(),1);import{getConfigValidator}from"./config-validator.mjs";var imagesSchema={type:"object",additionalProperties:!1,required:["sizes"],properties:{contentDispositionType:{enum:["inline","attachment"]},contentSecurityPolicy:{type:"string",minLength:1,maxLength:256},dangerouslyAllowSVG:{type:"boolean"},domains:{type:"array",minItems:0,maxItems:50,items:{type:"string",minLength:1,maxLength:256}},formats:{type:"array",minItems:1,maxItems:4,items:{enum:["image/avif","image/webp","image/jpeg","image/png"]}},localPatterns:{type:"array",minItems:0,maxItems:25,items:{type:"object",additionalProperties:!1,properties:{pathname:{type:"string",minLength:1,maxLength:256},search:{type:"string",minLength:0,maxLength:256}}}},minimumCacheTTL:{type:"integer",minimum:1,maximum:31536e4},qualities:{type:"array",minItems:1,maxItems:20,items:{type:"integer",minimum:1,maximum:100}},remotePatterns:{type:"array",minItems:0,maxItems:50,items:{type:"object",additionalProperties:!1,required:["hostname"],properties:{protocol:{enum:["http","https"]},hostname:{type:"string",minLength:1,maxLength:256},port:{type:"string",minLength:0,maxLength:5},pathname:{type:"string",minLength:1,maxLength:256},search:{type:"string",minLength:0,maxLength:256}}}},sizes:{type:"array",minItems:1,maxItems:50,items:{type:"number"}}}},cronsSchema={type:"array",minItems:0,items:{type:"object",additionalProperties:!1,required:["path","schedule"],properties:{path:{type:"string",minLength:1,maxLength:512,pattern:"^/.*"},schedule:{type:"string",minLength:9,maxLength:256}}}},scheduleNameSchema={type:"string",minLength:1,maxLength:256,pattern:"^[0-9A-Za-z][0-9A-Za-z._-]*$"},scheduleDefinitionSchema={type:"object",additionalProperties:!1,required:["schedule"],properties:{schedule:{type:"string",minLength:9,maxLength:256},timezone:{type:"string",minLength:1,maxLength:50,description:"IANA timezone for cron evaluation. Defaults to UTC."},jitter:{type:"integer",minimum:1,maximum:15},path:{description:"Deployment path to invoke over HTTP, like `crons[].path`. Must start with `/`.",type:"string",maxLength:512,pattern:"^/"},requestMethod:{description:"HTTP method used to invoke `path`. Only valid with `path`. Defaults to `POST`.",enum:["GET","POST"]},function:{type:"string",minLength:1},service:{description:"Service that owns `function`, from `services`. When set, `function` is the path within that service. Only valid with `function`.",type:"string",minLength:1,maxLength:64,pattern:"^[a-z]([a-z_-]*[a-z])?$"},topic:{type:"string",minLength:1,maxLength:256,pattern:"^[A-Za-z0-9_-]+$"},command:{description:"Command to run for each firing. Only valid with a Dockerfile or Containerfile entrypoint.",type:"array",minItems:1,items:[{type:"string",pattern:"\\S"}],additionalItems:{type:"string"}},root:{description:"Directory of the service that runs `command`. `entrypoint` is relative to it. Only valid with `command`.",type:"string",minLength:1,maxLength:512},entrypoint:{type:"string",minLength:1,maxLength:512}},dependencies:{requestMethod:["path"],service:["function"],command:["entrypoint","root"],root:["command"]},oneOf:[{required:["path"]},{required:["function"]},{required:["topic"]},{required:["entrypoint"]}]},maxSchedules=100,schedulesSchema={type:"object",maxProperties:maxSchedules,propertyNames:scheduleNameSchema,additionalProperties:scheduleDefinitionSchema},experimentalServicesMountSchema={oneOf:[{type:"string",minLength:1,maxLength:512},{type:"object",additionalProperties:!1,properties:{path:{type:"string",minLength:1,maxLength:512},subdomain:{type:"string",minLength:1,maxLength:63}},anyOf:[{required:["path"]},{required:["subdomain"]}]}]},staticExperimentalServiceScheduleSchema={type:"string",minLength:9,maxLength:256,not:{const:"<dynamic>"}},experimentalServiceScheduleSchema={oneOf:[{type:"string",minLength:9,maxLength:256},{type:"array",minItems:1,items:staticExperimentalServiceScheduleSchema}]},experimentalServiceQueueTopicSchema={type:"object",additionalProperties:!1,required:["topic"],properties:{topic:{type:"string",minLength:1,maxLength:256},retryAfterSeconds:{type:"integer",minimum:1,maximum:86400},initialDelaySeconds:{type:"integer",minimum:0,maximum:86400}}},experimentalServiceTopicsSchema={oneOf:[{type:"array",minItems:1,items:{type:"string",minLength:1,maxLength:256}},{type:"array",minItems:1,items:experimentalServiceQueueTopicSchema}]},envVarNamesSchema={pattern:"^[A-Za-z_][A-Za-z0-9_]*$",maxLength:256},getExperimentalServicesCommonProperties=()=>({entrypoint:{type:"string",minLength:1,maxLength:512},root:{type:"string",minLength:1,maxLength:512},workspace:{type:"string",minLength:1,maxLength:512},framework:{type:"string",minLength:1,maxLength:256},builder:{type:"string",minLength:1,maxLength:256},runtime:{type:"string",minLength:1,maxLength:256},buildCommand:{type:"string",minLength:1,maxLength:2048},installCommand:{type:"string",minLength:1,maxLength:2048},preDeployCommand:{type:"string",minLength:1,maxLength:2048},command:{oneOf:[{type:"string",minLength:1,maxLength:2048},{type:"array",minItems:1,items:{type:"string",minLength:1,maxLength:2048}}]},memory:{type:"integer",minimum:128,maximum:10240},maxDuration:(0,import_build_utils.getMaxDurationSchema)(),includeFiles:{oneOf:[{type:"string",minLength:1},{type:"array",items:{type:"string",minLength:1}}]},excludeFiles:{oneOf:[{type:"string",minLength:1},{type:"array",items:{type:"string",minLength:1}}]}}),experimentalServicesRoutableProperties={mount:experimentalServicesMountSchema,routePrefix:{type:"string",minLength:1,maxLength:512},subdomain:{type:"string",minLength:1,maxLength:63}},getExperimentalServicesServiceConfigSchema=()=>({oneOf:[{type:"object",additionalProperties:!1,properties:{...getExperimentalServicesCommonProperties(),...experimentalServicesRoutableProperties,type:{enum:["web"]}}},{type:"object",additionalProperties:!1,required:["type","trigger","schedule"],properties:{...getExperimentalServicesCommonProperties(),type:{const:"job"},trigger:{const:"schedule"},schedule:experimentalServiceScheduleSchema}},{type:"object",additionalProperties:!1,required:["type","trigger","topics"],properties:{...getExperimentalServicesCommonProperties(),type:{const:"job"},trigger:{const:"queue"},topics:experimentalServiceTopicsSchema,consumer:{type:"string",minLength:1,maxLength:256}}},{type:"object",additionalProperties:!1,required:["type","trigger","entrypoint"],properties:{...getExperimentalServicesCommonProperties(),type:{const:"job"},trigger:{const:"workflow"}}},{type:"object",additionalProperties:!1,required:["type"],properties:{...getExperimentalServicesCommonProperties(),type:{const:"worker"},topics:{type:"array",items:{type:"string",minLength:1,maxLength:256},minItems:1},consumer:{type:"string",minLength:1,maxLength:256}}},{type:"object",additionalProperties:!1,required:["type","schedule"],properties:{...getExperimentalServicesCommonProperties(),type:{const:"cron"},schedule:experimentalServiceScheduleSchema}}]}),getExperimentalServicesSchema=()=>({type:"object",propertyNames:{pattern:"^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$",maxLength:64},additionalProperties:getExperimentalServicesServiceConfigSchema()}),experimentalServiceGroupsSchema={type:"object",propertyNames:{pattern:"^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$",maxLength:64},additionalProperties:{type:"array",items:{type:"string",minLength:1,maxLength:256}}},servicesPathSchema={type:"string",minLength:1,maxLength:512},servicesCommandSchema={type:"string",minLength:1,maxLength:2048},servicesBindingSchema={type:"object",additionalProperties:!1,required:["service","format","env"],properties:{type:{description:"Optional binding type marker. Currently the only supported type is `service`. When present this must be `service`.",const:"service"},service:{type:"string",minLength:1,maxLength:64,pattern:import_build_utils.SERVICE_NAME_PATTERN},format:{const:"url"},env:{type:"string",...envVarNamesSchema}}},servicesBindingsSchema={type:"array",maxItems:100,items:servicesBindingSchema},getServicesServiceConfigSchema=()=>({type:"object",additionalProperties:!1,required:["root"],properties:{root:servicesPathSchema,framework:{type:"string",minLength:1,maxLength:256},runtime:{type:"string",minLength:1,maxLength:256},entrypoint:servicesPathSchema,command:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},installCommand:servicesCommandSchema,buildCommand:servicesCommandSchema,devCommand:servicesCommandSchema,ignoreCommand:servicesCommandSchema,outputDirectory:servicesPathSchema,bindings:servicesBindingsSchema,functions:(0,import_build_utils.getFunctionsSchema)(),headers:import_routing_utils.headersSchema,redirects:import_routing_utils.redirectsSchema,rewrites:import_routing_utils.rewritesSchema,routes:import_routing_utils.routesSchema,cleanUrls:import_routing_utils.cleanUrlsSchema,trailingSlash:import_routing_utils.trailingSlashSchema}}),daemonConfigSchema={type:"object",additionalProperties:!1,required:["root","entrypoint"],anyOf:[{required:["instances"]},{required:["replicas"]}],properties:{root:servicesPathSchema,entrypoint:servicesPathSchema,command:{type:"array",minItems:1,maxItems:128,items:{type:"string",minLength:1,maxLength:4096}},instances:{type:"object",additionalProperties:{type:"integer",minimum:0}},replicas:{description:"Deprecated. Use `instances`. Ignored when `instances` is set.",deprecated:!0,type:"object",additionalProperties:{type:"integer",minimum:0}},resources:{type:"object",additionalProperties:!1,required:["requests"],properties:{requests:{type:"object",additionalProperties:!1,required:["memory"],properties:{memory:{enum:["1Gi","2Gi","4Gi","8Gi"]}}}}},terminationGracePeriodSeconds:{type:"integer",minimum:0},livenessProbe:{type:"object",additionalProperties:!1,required:["httpGet"],properties:{httpGet:{type:"object",additionalProperties:!1,required:["port"],properties:{path:{type:"string",minLength:1},port:{type:"integer",minimum:1,maximum:65535},host:{type:"string",minLength:1},scheme:{enum:["HTTP","HTTPS"]},httpHeaders:{type:"array",items:{type:"object",additionalProperties:!1,required:["name","value"],properties:{name:{type:"string",minLength:1},value:{type:"string"}}}}}},initialDelaySeconds:{type:"integer",minimum:0,maximum:86400},periodSeconds:{type:"integer",minimum:1,maximum:86400},timeoutSeconds:{type:"integer",minimum:1,maximum:86400},successThreshold:{type:"integer",minimum:1,maximum:10},failureThreshold:{type:"integer",minimum:1,maximum:10}}},bindings:{...servicesBindingsSchema,items:{...servicesBindingSchema,required:["type",...servicesBindingSchema.required]}}}},getServicesSchema=()=>({type:"object",propertyNames:{pattern:import_build_utils.SERVICE_NAME_PATTERN,maxLength:64},additionalProperties:getServicesServiceConfigSchema()}),maxDaemons=100,daemonsSchema={type:"object",maxProperties:maxDaemons,propertyNames:{pattern:import_build_utils.DAEMON_NAME_PATTERN,maxLength:64},additionalProperties:daemonConfigSchema},proxySchema={type:"object",additionalProperties:!1,required:["entrypoint"],properties:{entrypoint:{type:"string",minLength:1},matcher:{oneOf:[{type:"string",minLength:1},{type:"array",minItems:1,items:{type:"string",minLength:1}}]}}};function buildVercelConfigSchema(){return{type:"object",additionalProperties:!0,properties:{builds:import_build_utils.buildsSchema,routes:import_routing_utils.routesSchema,cleanUrls:import_routing_utils.cleanUrlsSchema,headers:import_routing_utils.headersSchema,redirects:import_routing_utils.redirectsSchema,rewrites:import_routing_utils.rewritesSchema,trailingSlash:import_routing_utils.trailingSlashSchema,functions:(0,import_build_utils.getFunctionsSchema)(),images:imagesSchema,crons:cronsSchema,schedules:schedulesSchema,bunVersion:{type:"string"},proxy:proxySchema,experimentalServices:getExperimentalServicesSchema(),experimentalServiceGroups:experimentalServiceGroupsSchema,services:getServicesSchema(),experimentalServicesV2:getServicesSchema(),daemons:daemonsSchema}}}var isDockerfilePath=path=>/(docker|container)file/i.test(path.split(/[\\/]/).pop()??"");function validateConfig(config){let validate=getConfigValidator(buildVercelConfigSchema);if(!validate(config)&&validate.errors&&validate.errors[0]){let error=validate.errors[0],fileName=config[import_types.fileNameSymbol]||"vercel.json",niceError=(0,import_build_utils.getPrettyError)(error);return niceError.message=`Invalid ${fileName} - ${niceError.message}`,niceError}let serviceNames=new Set([...Object.keys(config.services??{}),...Object.keys(config.daemons??{})]),invalidCommand=message=>new import_build_utils.NowBuildError({code:"INVALID_SCHEDULE_COMMAND",message:`Invalid ${config[import_types.fileNameSymbol]||"vercel.json"} - ${message}`});for(let[name,schedule]of Object.entries(config.schedules??{})){let path=`schedules.${name}`;if("command"in schedule){if(!isDockerfilePath(schedule.entrypoint))return invalidCommand(`\`${path}.command\` requires a Dockerfile or Containerfile \`entrypoint\`.`);if(name.length>64||!new RegExp(import_build_utils.SERVICE_NAME_PATTERN).test(name))return invalidCommand(`\`${path}\` runs a command, so its name must be a valid service name: lowercase letters, \`-\` and \`_\`, at most 64 characters.`);if(serviceNames.has(name))return invalidCommand(`\`${path}\` runs a command as service "${name}", which is already the name of a service or daemon.`)}if(schedule.timezone!==void 0)try{if(!/^[A-Za-z][A-Za-z0-9_+/-]*$/.test(schedule.timezone))throw new RangeError("Expected a named timezone");new Intl.DateTimeFormat("en-US",{timeZone:schedule.timezone})}catch{return new import_build_utils.NowBuildError({code:"INVALID_SCHEDULE_TIMEZONE",message:`Invalid ${config[import_types.fileNameSymbol]||"vercel.json"} - \`schedules.${name}.timezone\` must be a valid IANA timezone, such as "America/New_York". Omit it to use UTC.`})}}let functionMaps=[config.functions,...Object.values(config.services??{}).map(service=>service.functions),...Object.values(config.experimentalServicesV2??{}).map(service=>service.functions)];for(let functions of functionMaps)for(let[pattern,fn]of Object.entries(functions??{})){let regions=[...new Set(fn.regions)];if(fn.affinity?.mode==="strict"&&(regions.includes("all")||regions.length>1))return new import_build_utils.NowBuildError({code:"INVALID_FUNCTION_AFFINITY_REGIONS",message:`Function affinity mode "strict" requires at most one statically configured region. Update \`functions[${JSON.stringify(pattern)}].regions\` to contain a single region.`,link:"https://vercel.com/docs/concepts/projects/project-configuration#functions"})}if(config.proxy){let proxyError=(0,import_fs_detectors.validateProxyConfig)(config.proxy);if(proxyError)return new import_build_utils.NowBuildError({code:proxyError.code.toUpperCase(),message:proxyError.message})}if(config.functions&&config.builds)return new import_build_utils.NowBuildError({code:"FUNCTIONS_AND_BUILDS",message:"The `functions` property cannot be used in conjunction with the `builds` property. Please remove one of them.",link:"https://vercel.link/functions-and-builds"});if(config.proxy&&config.builds)return new import_build_utils.NowBuildError({code:"PROXY_AND_BUILDS",message:"The `proxy` property cannot be used with the `builds` property. Remove `builds` to use an explicit proxy entrypoint."});let hasExperimentalServices=!!config.experimentalServices;if(hasExperimentalServices&&config.builds)return new import_build_utils.NowBuildError({code:"EXPERIMENTAL_SERVICES_AND_BUILDS",message:"The `experimentalServices` property cannot be used in conjunction with the `builds` property. Please remove one of them."});if(hasExperimentalServices&&config.functions)return new import_build_utils.NowBuildError({code:"EXPERIMENTAL_SERVICES_AND_FUNCTIONS",message:"The `experimentalServices` property cannot be used in conjunction with the `functions` property. Please remove one of them."});if(config.experimentalServiceGroups&&!config.experimentalServices)return new import_build_utils.NowBuildError({code:"SERVICE_GROUPS_WITHOUT_SERVICES",message:"The `experimentalServiceGroups` property requires `experimentalServices` to be defined. Service groups reference services by name."});let hasServices=config.services!=null,hasExperimentalServicesV2=config.experimentalServicesV2!=null;if(hasServices&&hasExperimentalServicesV2)return new import_build_utils.NowBuildError({code:"SERVICES_AND_EXPERIMENTAL_SERVICES_V2",message:"The `services` property cannot be used in conjunction with its deprecated alias `experimentalServicesV2`. Please use only `services`."});let servicesConfig=config.services??config.experimentalServicesV2,servicesConfigKey=hasServices?"services":"experimentalServicesV2",servicesErrorCodePrefix=hasServices?"SERVICES":"EXPERIMENTAL_SERVICES_V2";if(servicesConfig&&hasExperimentalServices)return new import_build_utils.NowBuildError({code:`${servicesErrorCodePrefix}_AND_EXPERIMENTAL_SERVICES`,message:`The \`${servicesConfigKey}\` property cannot be used in conjunction with the \`experimentalServices\` property. Please use only one services configuration.`});if(servicesConfig&&config.builds)return new import_build_utils.NowBuildError({code:`${servicesErrorCodePrefix}_AND_BUILDS`,message:`The \`${servicesConfigKey}\` property cannot be used in conjunction with the \`builds\` property. Please remove one of them.`});if(servicesConfig){let ambiguousTopLevel=[];if(config.functions!=null&&ambiguousTopLevel.push("functions"),config.installCommand!=null&&ambiguousTopLevel.push("installCommand"),config.buildCommand!=null&&ambiguousTopLevel.push("buildCommand"),config.devCommand!=null&&ambiguousTopLevel.push("devCommand"),config.ignoreCommand!=null&&ambiguousTopLevel.push("ignoreCommand"),config.outputDirectory!=null&&ambiguousTopLevel.push("outputDirectory"),config.framework!=null&&ambiguousTopLevel.push("framework"),ambiguousTopLevel.length>0){let count=ambiguousTopLevel.length,fields=ambiguousTopLevel.map(field=>`\`${field}\``).join(", ");return new import_build_utils.NowBuildError({code:`${servicesErrorCodePrefix}_AND_TOP_LEVEL_BUILD_SETTINGS`,message:`The top-level ${count>1?"properties":"property"} ${fields} cannot be used with \`${servicesConfigKey}\` because the owning service is ambiguous. Move ${count>1?"them":"it"} under the relevant service in \`${servicesConfigKey}\`.`})}}if(config.daemons){let daemonError=validateDaemons(config,config.daemons);if(daemonError)return daemonError}if(servicesConfig){let serviceNames2=new Set(Object.keys(servicesConfig));for(let[serviceName,serviceConfig]of Object.entries(servicesConfig))for(let binding of serviceConfig.bindings??[])if(!serviceNames2.has(binding.service))return new import_build_utils.NowBuildError({code:`${servicesErrorCodePrefix}_BINDING_UNKNOWN_SERVICE`,message:`Service "${serviceName}" declares a binding to unknown service "${binding.service}". Add "${binding.service}" to \`${servicesConfigKey}\` or fix the binding.`})}return null}function validateDaemons(config,daemons){let invalid=message=>new import_build_utils.NowBuildError({code:"INVALID_DAEMON",message}),daemonNames=new Set(Object.keys(daemons));for(let[name,daemon]of Object.entries(daemons))if(!isDockerfilePath(daemon.entrypoint))return invalid(`Daemon "${name}" must set \`entrypoint\` to a Dockerfile or Containerfile.`);let services={...config.experimentalServicesV2,...config.services},isDaemonTarget=name=>daemonNames.has(name)&&!Object.prototype.hasOwnProperty.call(services,name);for(let[name,service]of Object.entries(services)){let binding=service.bindings?.find(binding2=>isDaemonTarget(binding2.service));if(binding)return invalid(`Service "${name}" cannot bind to daemon "${binding.service}" because daemons do not receive traffic.`)}for(let[name,daemon]of Object.entries(daemons)){let envs=new Set;for(let binding of daemon.bindings??[]){if(!Object.prototype.hasOwnProperty.call(services,binding.service))return invalid(`Daemon "${name}" declares a binding to unknown service "${binding.service}". Add "${binding.service}" to \`services\` or fix the binding.`);if(envs.has(binding.env))return invalid(`Daemon "${name}" declares more than one binding for the environment variable "${binding.env}".`);envs.add(binding.env)}}let destinations=[...config.rewrites??[],...config.routes??[],...Object.values(services).flatMap(service=>[...service.rewrites??[],...service.routes??[]])].map(entry=>"destination"in entry?entry.destination:void 0);for(let destination of destinations)if(typeof destination=="object"&&destination!==null&&isDaemonTarget(destination.service))return invalid(`Rewrites and routes cannot target daemon "${destination.service}" because daemons do not receive traffic.`);return null}export{require_dist3 as require_dist,validateConfig};
|
|
7
|
+
import{require_dist,require_dist2}from"./chunk-DCX2PBSX.js";import{require_types}from"./chunk-TKKGZI7O.js";import{require_build_utils}from"./chunk-DWOJP4ST.js";import{__commonJS,__toESM}from"./chunk-BZENIQ7N.js";var require_dist3=__commonJS({"../../internals/service-topology/dist/index.js"(exports,module){"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),src_exports={};__export(src_exports,{INTERNAL_SERVICE_PREFIX:()=>import_fs_detectors2.INTERNAL_SERVICE_PREFIX,autoDetectServices:()=>import_fs_detectors2.autoDetectServices,detectDaemons:()=>import_fs_detectors2.detectDaemons,detectServices:()=>import_fs_detectors2.detectServices,generateServiceRewrites:()=>import_fs_detectors2.generateServiceRewrites,generateServicesRoutes:()=>import_fs_detectors2.generateServicesRoutes,getInternalServiceCronPath:()=>import_fs_detectors2.getInternalServiceCronPath,getInternalServiceCronPathPrefix:()=>import_fs_detectors2.getInternalServiceCronPathPrefix,getInternalServiceFunctionPath:()=>import_fs_detectors2.getInternalServiceFunctionPath,getInternalServiceWorkerPath:()=>import_fs_detectors2.getInternalServiceWorkerPath,getInternalServiceWorkerPathPrefix:()=>import_fs_detectors2.getInternalServiceWorkerPathPrefix,hasLegacyServicesConfig:()=>import_fs_detectors2.hasLegacyServicesConfig,isExperimentalService:()=>import_fs_detectors2.isExperimentalService,isExperimentalServiceV2:()=>import_fs_detectors2.isExperimentalServiceV2,isRouteOwningBuilder:()=>import_fs_detectors2.isRouteOwningBuilder,isStaticBuild:()=>import_fs_detectors2.isStaticBuild,migrateExperimentalServices:()=>import_fs_detectors2.migrateExperimentalServices,planExperimentalServicesMigration:()=>import_fs_detectors2.planExperimentalServicesMigration,resolveAllConfiguredServices:()=>import_fs_detectors2.resolveAllConfiguredServices,resolveAllConfiguredServicesV2:()=>import_fs_detectors2.resolveAllConfiguredServicesV2,resolveConfiguredServiceV2:()=>import_fs_detectors2.resolveConfiguredServiceV2,validateServiceConfigV2:()=>import_fs_detectors2.validateServiceConfigV2});module.exports=__toCommonJS(src_exports);var import_fs_detectors2=require_dist2()}});var import_routing_utils=__toESM(require_dist(),1),import_build_utils=__toESM(require_build_utils(),1),import_types=__toESM(require_types(),1),import_fs_detectors=__toESM(require_dist2(),1);import{getConfigValidator}from"./config-validator.mjs";var imagesSchema={type:"object",additionalProperties:!1,required:["sizes"],properties:{contentDispositionType:{enum:["inline","attachment"]},contentSecurityPolicy:{type:"string",minLength:1,maxLength:256},dangerouslyAllowSVG:{type:"boolean"},domains:{type:"array",minItems:0,maxItems:50,items:{type:"string",minLength:1,maxLength:256}},formats:{type:"array",minItems:1,maxItems:4,items:{enum:["image/avif","image/webp","image/jpeg","image/png"]}},localPatterns:{type:"array",minItems:0,maxItems:25,items:{type:"object",additionalProperties:!1,properties:{pathname:{type:"string",minLength:1,maxLength:256},search:{type:"string",minLength:0,maxLength:256}}}},minimumCacheTTL:{type:"integer",minimum:1,maximum:31536e4},qualities:{type:"array",minItems:1,maxItems:20,items:{type:"integer",minimum:1,maximum:100}},remotePatterns:{type:"array",minItems:0,maxItems:50,items:{type:"object",additionalProperties:!1,required:["hostname"],properties:{protocol:{enum:["http","https"]},hostname:{type:"string",minLength:1,maxLength:256},port:{type:"string",minLength:0,maxLength:5},pathname:{type:"string",minLength:1,maxLength:256},search:{type:"string",minLength:0,maxLength:256}}}},sizes:{type:"array",minItems:1,maxItems:50,items:{type:"number"}}}},cronsSchema={type:"array",minItems:0,items:{type:"object",additionalProperties:!1,required:["path","schedule"],properties:{path:{type:"string",minLength:1,maxLength:512,pattern:"^/.*"},schedule:{type:"string",minLength:9,maxLength:256}}}},scheduleNameSchema={type:"string",minLength:1,maxLength:256,pattern:"^[0-9A-Za-z][0-9A-Za-z._-]*$"},scheduleDefinitionSchema={type:"object",additionalProperties:!1,required:["schedule"],properties:{schedule:{type:"string",minLength:9,maxLength:256},timezone:{type:"string",minLength:1,maxLength:50,description:"IANA timezone for cron evaluation. Defaults to UTC."},jitter:{type:"integer",minimum:1,maximum:15},path:{description:"Deployment path to invoke over HTTP, like `crons[].path`. Must start with `/`.",type:"string",maxLength:512,pattern:"^/"},requestMethod:{description:"HTTP method used to invoke `path`. Only valid with `path`. Defaults to `POST`.",enum:["GET","POST"]},function:{type:"string",minLength:1},service:{description:"Service that owns `function`, from `services`. When set, `function` is the path within that service. Only valid with `function`.",type:"string",minLength:1,maxLength:64,pattern:"^[a-z]([a-z_-]*[a-z])?$"},topic:{type:"string",minLength:1,maxLength:256,pattern:"^[A-Za-z0-9_-]+$"},command:{description:"Command to run for each firing. Only valid with a Dockerfile or Containerfile entrypoint.",type:"array",minItems:1,items:[{type:"string",pattern:"\\S"}],additionalItems:{type:"string"}},root:{description:"Directory of the service that runs `command`. `entrypoint` is relative to it. Only valid with `command`.",type:"string",minLength:1,maxLength:512},entrypoint:{type:"string",minLength:1,maxLength:512}},dependencies:{requestMethod:["path"],service:["function"],command:["entrypoint","root"],root:["command"]},oneOf:[{required:["path"]},{required:["function"]},{required:["topic"]},{required:["entrypoint"]}]},maxSchedules=100,schedulesSchema={type:"object",maxProperties:maxSchedules,propertyNames:scheduleNameSchema,additionalProperties:scheduleDefinitionSchema},experimentalServicesMountSchema={oneOf:[{type:"string",minLength:1,maxLength:512},{type:"object",additionalProperties:!1,properties:{path:{type:"string",minLength:1,maxLength:512},subdomain:{type:"string",minLength:1,maxLength:63}},anyOf:[{required:["path"]},{required:["subdomain"]}]}]},staticExperimentalServiceScheduleSchema={type:"string",minLength:9,maxLength:256,not:{const:"<dynamic>"}},experimentalServiceScheduleSchema={oneOf:[{type:"string",minLength:9,maxLength:256},{type:"array",minItems:1,items:staticExperimentalServiceScheduleSchema}]},experimentalServiceQueueTopicSchema={type:"object",additionalProperties:!1,required:["topic"],properties:{topic:{type:"string",minLength:1,maxLength:256},retryAfterSeconds:{type:"integer",minimum:1,maximum:86400},initialDelaySeconds:{type:"integer",minimum:0,maximum:86400}}},experimentalServiceTopicsSchema={oneOf:[{type:"array",minItems:1,items:{type:"string",minLength:1,maxLength:256}},{type:"array",minItems:1,items:experimentalServiceQueueTopicSchema}]},envVarNamesSchema={pattern:"^[A-Za-z_][A-Za-z0-9_]*$",maxLength:256},getExperimentalServicesCommonProperties=()=>({entrypoint:{type:"string",minLength:1,maxLength:512},root:{type:"string",minLength:1,maxLength:512},workspace:{type:"string",minLength:1,maxLength:512},framework:{type:"string",minLength:1,maxLength:256},builder:{type:"string",minLength:1,maxLength:256},runtime:{type:"string",minLength:1,maxLength:256},buildCommand:{type:"string",minLength:1,maxLength:2048},installCommand:{type:"string",minLength:1,maxLength:2048},preDeployCommand:{type:"string",minLength:1,maxLength:2048},command:{oneOf:[{type:"string",minLength:1,maxLength:2048},{type:"array",minItems:1,items:{type:"string",minLength:1,maxLength:2048}}]},memory:{type:"integer",minimum:128,maximum:10240},maxDuration:(0,import_build_utils.getMaxDurationSchema)(),includeFiles:{oneOf:[{type:"string",minLength:1},{type:"array",items:{type:"string",minLength:1}}]},excludeFiles:{oneOf:[{type:"string",minLength:1},{type:"array",items:{type:"string",minLength:1}}]}}),experimentalServicesRoutableProperties={mount:experimentalServicesMountSchema,routePrefix:{type:"string",minLength:1,maxLength:512},subdomain:{type:"string",minLength:1,maxLength:63}},getExperimentalServicesServiceConfigSchema=()=>({oneOf:[{type:"object",additionalProperties:!1,properties:{...getExperimentalServicesCommonProperties(),...experimentalServicesRoutableProperties,type:{enum:["web"]}}},{type:"object",additionalProperties:!1,required:["type","trigger","schedule"],properties:{...getExperimentalServicesCommonProperties(),type:{const:"job"},trigger:{const:"schedule"},schedule:experimentalServiceScheduleSchema}},{type:"object",additionalProperties:!1,required:["type","trigger","topics"],properties:{...getExperimentalServicesCommonProperties(),type:{const:"job"},trigger:{const:"queue"},topics:experimentalServiceTopicsSchema,consumer:{type:"string",minLength:1,maxLength:256}}},{type:"object",additionalProperties:!1,required:["type","trigger","entrypoint"],properties:{...getExperimentalServicesCommonProperties(),type:{const:"job"},trigger:{const:"workflow"}}},{type:"object",additionalProperties:!1,required:["type"],properties:{...getExperimentalServicesCommonProperties(),type:{const:"worker"},topics:{type:"array",items:{type:"string",minLength:1,maxLength:256},minItems:1},consumer:{type:"string",minLength:1,maxLength:256}}},{type:"object",additionalProperties:!1,required:["type","schedule"],properties:{...getExperimentalServicesCommonProperties(),type:{const:"cron"},schedule:experimentalServiceScheduleSchema}}]}),getExperimentalServicesSchema=()=>({type:"object",propertyNames:{pattern:"^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$",maxLength:64},additionalProperties:getExperimentalServicesServiceConfigSchema()}),experimentalServiceGroupsSchema={type:"object",propertyNames:{pattern:"^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$",maxLength:64},additionalProperties:{type:"array",items:{type:"string",minLength:1,maxLength:256}}},servicesPathSchema={type:"string",minLength:1,maxLength:512},servicesCommandSchema={type:"string",minLength:1,maxLength:2048},servicesBindingSchema={type:"object",additionalProperties:!1,required:["service","format","env"],properties:{type:{description:"Optional binding type marker. Currently the only supported type is `service`. When present this must be `service`.",const:"service"},service:{type:"string",minLength:1,maxLength:64,pattern:import_build_utils.SERVICE_NAME_PATTERN},format:{const:"url"},env:{type:"string",...envVarNamesSchema}}},servicesBindingsSchema={type:"array",maxItems:100,items:servicesBindingSchema},getServicesServiceConfigSchema=()=>({type:"object",additionalProperties:!1,required:["root"],properties:{root:servicesPathSchema,framework:{type:"string",minLength:1,maxLength:256},runtime:{type:"string",minLength:1,maxLength:256},entrypoint:servicesPathSchema,command:{oneOf:[{type:"string"},{type:"array",items:{type:"string"}}]},installCommand:servicesCommandSchema,buildCommand:servicesCommandSchema,devCommand:servicesCommandSchema,ignoreCommand:servicesCommandSchema,outputDirectory:servicesPathSchema,bindings:servicesBindingsSchema,functions:(0,import_build_utils.getFunctionsSchema)(),headers:import_routing_utils.headersSchema,redirects:import_routing_utils.redirectsSchema,rewrites:import_routing_utils.rewritesSchema,routes:import_routing_utils.routesSchema,cleanUrls:import_routing_utils.cleanUrlsSchema,trailingSlash:import_routing_utils.trailingSlashSchema}}),daemonConfigSchema={type:"object",additionalProperties:!1,required:["root","entrypoint"],anyOf:[{required:["instances"]},{required:["replicas"]}],properties:{root:servicesPathSchema,entrypoint:servicesPathSchema,command:{type:"array",minItems:1,maxItems:128,items:{type:"string",minLength:1,maxLength:4096}},instances:{type:"object",additionalProperties:{type:"integer",minimum:0}},replicas:{description:"Deprecated. Use `instances`. Ignored when `instances` is set.",deprecated:!0,type:"object",additionalProperties:{type:"integer",minimum:0}},resources:{type:"object",additionalProperties:!1,required:["requests"],properties:{requests:{type:"object",additionalProperties:!1,required:["memory"],properties:{memory:{enum:["1Gi","2Gi","4Gi","8Gi"]}}}}},terminationGracePeriodSeconds:{type:"integer",minimum:0},livenessProbe:{type:"object",additionalProperties:!1,required:["httpGet"],properties:{httpGet:{type:"object",additionalProperties:!1,required:["port"],properties:{path:{type:"string",minLength:1},port:{type:"integer",minimum:1,maximum:65535},host:{type:"string",minLength:1},scheme:{enum:["HTTP","HTTPS"]},httpHeaders:{type:"array",items:{type:"object",additionalProperties:!1,required:["name","value"],properties:{name:{type:"string",minLength:1},value:{type:"string"}}}}}},initialDelaySeconds:{type:"integer",minimum:0,maximum:86400},periodSeconds:{type:"integer",minimum:1,maximum:86400},timeoutSeconds:{type:"integer",minimum:1,maximum:86400},successThreshold:{type:"integer",minimum:1,maximum:10},failureThreshold:{type:"integer",minimum:1,maximum:10}}},bindings:{...servicesBindingsSchema,items:{...servicesBindingSchema,required:["type",...servicesBindingSchema.required]}}}},getServicesSchema=()=>({type:"object",propertyNames:{pattern:import_build_utils.SERVICE_NAME_PATTERN,maxLength:64},additionalProperties:getServicesServiceConfigSchema()}),maxDaemons=100,daemonsSchema={type:"object",maxProperties:maxDaemons,propertyNames:{pattern:import_build_utils.DAEMON_NAME_PATTERN,maxLength:64},additionalProperties:daemonConfigSchema},proxySchema={type:"object",additionalProperties:!1,required:["entrypoint"],properties:{entrypoint:{type:"string",minLength:1},matcher:{oneOf:[{type:"string",minLength:1},{type:"array",minItems:1,items:{type:"string",minLength:1}}]}}};function buildVercelConfigSchema(){return{type:"object",additionalProperties:!0,properties:{builds:import_build_utils.buildsSchema,routes:import_routing_utils.routesSchema,cleanUrls:import_routing_utils.cleanUrlsSchema,headers:import_routing_utils.headersSchema,redirects:import_routing_utils.redirectsSchema,rewrites:import_routing_utils.rewritesSchema,trailingSlash:import_routing_utils.trailingSlashSchema,functions:(0,import_build_utils.getFunctionsSchema)(),images:imagesSchema,crons:cronsSchema,schedules:schedulesSchema,bunVersion:{type:"string"},proxy:proxySchema,experimentalServices:getExperimentalServicesSchema(),experimentalServiceGroups:experimentalServiceGroupsSchema,services:getServicesSchema(),experimentalServicesV2:getServicesSchema(),daemons:daemonsSchema}}}var isDockerfilePath=path=>/(docker|container)file/i.test(path.split(/[\\/]/).pop()??"");function validateConfig(config){let validate=getConfigValidator(buildVercelConfigSchema);if(!validate(config)&&validate.errors&&validate.errors[0]){let error=validate.errors[0],fileName=config[import_types.fileNameSymbol]||"vercel.json",niceError=(0,import_build_utils.getPrettyError)(error);return niceError.message=`Invalid ${fileName} - ${niceError.message}`,niceError}let serviceNames=new Set([...Object.keys(config.services??{}),...Object.keys(config.daemons??{})]),invalidCommand=message=>new import_build_utils.NowBuildError({code:"INVALID_SCHEDULE_COMMAND",message:`Invalid ${config[import_types.fileNameSymbol]||"vercel.json"} - ${message}`});for(let[name,schedule]of Object.entries(config.schedules??{})){let path=`schedules.${name}`;if("command"in schedule){if(!isDockerfilePath(schedule.entrypoint))return invalidCommand(`\`${path}.command\` requires a Dockerfile or Containerfile \`entrypoint\`.`);if(name.length>64||!new RegExp(import_build_utils.SERVICE_NAME_PATTERN).test(name))return invalidCommand(`\`${path}\` runs a command, so its name must be a valid service name: lowercase letters, \`-\` and \`_\`, at most 64 characters.`);if(serviceNames.has(name))return invalidCommand(`\`${path}\` runs a command as service "${name}", which is already the name of a service or daemon.`)}if(schedule.timezone!==void 0)try{if(!/^[A-Za-z][A-Za-z0-9_+/-]*$/.test(schedule.timezone))throw new RangeError("Expected a named timezone");new Intl.DateTimeFormat("en-US",{timeZone:schedule.timezone})}catch{return new import_build_utils.NowBuildError({code:"INVALID_SCHEDULE_TIMEZONE",message:`Invalid ${config[import_types.fileNameSymbol]||"vercel.json"} - \`schedules.${name}.timezone\` must be a valid IANA timezone, such as "America/New_York". Omit it to use UTC.`})}}let functionMaps=[config.functions,...Object.values(config.services??{}).map(service=>service.functions),...Object.values(config.experimentalServicesV2??{}).map(service=>service.functions)];for(let functions of functionMaps)for(let[pattern,fn]of Object.entries(functions??{})){let regions=[...new Set(fn.regions)];if(fn.affinity?.mode==="strict"&&(regions.includes("all")||regions.length>1))return new import_build_utils.NowBuildError({code:"INVALID_FUNCTION_AFFINITY_REGIONS",message:`Function affinity mode "strict" requires at most one statically configured region. Update \`functions[${JSON.stringify(pattern)}].regions\` to contain a single region.`,link:"https://vercel.com/docs/concepts/projects/project-configuration#functions"})}if(config.proxy){let proxyError=(0,import_fs_detectors.validateProxyConfig)(config.proxy);if(proxyError)return new import_build_utils.NowBuildError({code:proxyError.code.toUpperCase(),message:proxyError.message})}if(config.functions&&config.builds)return new import_build_utils.NowBuildError({code:"FUNCTIONS_AND_BUILDS",message:"The `functions` property cannot be used in conjunction with the `builds` property. Please remove one of them.",link:"https://vercel.link/functions-and-builds"});if(config.proxy&&config.builds)return new import_build_utils.NowBuildError({code:"PROXY_AND_BUILDS",message:"The `proxy` property cannot be used with the `builds` property. Remove `builds` to use an explicit proxy entrypoint."});let hasExperimentalServices=!!config.experimentalServices;if(hasExperimentalServices&&config.builds)return new import_build_utils.NowBuildError({code:"EXPERIMENTAL_SERVICES_AND_BUILDS",message:"The `experimentalServices` property cannot be used in conjunction with the `builds` property. Please remove one of them."});if(hasExperimentalServices&&config.functions)return new import_build_utils.NowBuildError({code:"EXPERIMENTAL_SERVICES_AND_FUNCTIONS",message:"The `experimentalServices` property cannot be used in conjunction with the `functions` property. Please remove one of them."});if(config.experimentalServiceGroups&&!config.experimentalServices)return new import_build_utils.NowBuildError({code:"SERVICE_GROUPS_WITHOUT_SERVICES",message:"The `experimentalServiceGroups` property requires `experimentalServices` to be defined. Service groups reference services by name."});let hasServices=config.services!=null,hasExperimentalServicesV2=config.experimentalServicesV2!=null;if(hasServices&&hasExperimentalServicesV2)return new import_build_utils.NowBuildError({code:"SERVICES_AND_EXPERIMENTAL_SERVICES_V2",message:"The `services` property cannot be used in conjunction with its deprecated alias `experimentalServicesV2`. Please use only `services`."});let servicesConfig=config.services??config.experimentalServicesV2,servicesConfigKey=hasServices?"services":"experimentalServicesV2",servicesErrorCodePrefix=hasServices?"SERVICES":"EXPERIMENTAL_SERVICES_V2";if(servicesConfig&&hasExperimentalServices)return new import_build_utils.NowBuildError({code:`${servicesErrorCodePrefix}_AND_EXPERIMENTAL_SERVICES`,message:`The \`${servicesConfigKey}\` property cannot be used in conjunction with the \`experimentalServices\` property. Please use only one services configuration.`});if(servicesConfig&&config.builds)return new import_build_utils.NowBuildError({code:`${servicesErrorCodePrefix}_AND_BUILDS`,message:`The \`${servicesConfigKey}\` property cannot be used in conjunction with the \`builds\` property. Please remove one of them.`});if(servicesConfig){let ambiguousTopLevel=[];if(config.functions!=null&&ambiguousTopLevel.push("functions"),config.installCommand!=null&&ambiguousTopLevel.push("installCommand"),config.buildCommand!=null&&ambiguousTopLevel.push("buildCommand"),config.devCommand!=null&&ambiguousTopLevel.push("devCommand"),config.ignoreCommand!=null&&ambiguousTopLevel.push("ignoreCommand"),config.outputDirectory!=null&&ambiguousTopLevel.push("outputDirectory"),config.framework!=null&&ambiguousTopLevel.push("framework"),ambiguousTopLevel.length>0){let count=ambiguousTopLevel.length,fields=ambiguousTopLevel.map(field=>`\`${field}\``).join(", ");return new import_build_utils.NowBuildError({code:`${servicesErrorCodePrefix}_AND_TOP_LEVEL_BUILD_SETTINGS`,message:`The top-level ${count>1?"properties":"property"} ${fields} cannot be used with \`${servicesConfigKey}\` because the owning service is ambiguous. Move ${count>1?"them":"it"} under the relevant service in \`${servicesConfigKey}\`.`})}}if(config.daemons){let daemonError=validateDaemons(config,config.daemons);if(daemonError)return daemonError}if(servicesConfig){let serviceNames2=new Set(Object.keys(servicesConfig));for(let[serviceName,serviceConfig]of Object.entries(servicesConfig))for(let binding of serviceConfig.bindings??[])if(!serviceNames2.has(binding.service))return new import_build_utils.NowBuildError({code:`${servicesErrorCodePrefix}_BINDING_UNKNOWN_SERVICE`,message:`Service "${serviceName}" declares a binding to unknown service "${binding.service}". Add "${binding.service}" to \`${servicesConfigKey}\` or fix the binding.`})}return null}function validateDaemons(config,daemons){let invalid=message=>new import_build_utils.NowBuildError({code:"INVALID_DAEMON",message}),daemonNames=new Set(Object.keys(daemons));for(let[name,daemon]of Object.entries(daemons))if(!isDockerfilePath(daemon.entrypoint))return invalid(`Daemon "${name}" must set \`entrypoint\` to a Dockerfile or Containerfile.`);let services={...config.experimentalServicesV2,...config.services},isDaemonTarget=name=>daemonNames.has(name)&&!Object.prototype.hasOwnProperty.call(services,name);for(let[name,service]of Object.entries(services)){let binding=service.bindings?.find(binding2=>isDaemonTarget(binding2.service));if(binding)return invalid(`Service "${name}" cannot bind to daemon "${binding.service}" because daemons do not receive traffic.`)}for(let[name,daemon]of Object.entries(daemons)){let envs=new Set;for(let binding of daemon.bindings??[]){if(!Object.prototype.hasOwnProperty.call(services,binding.service))return invalid(`Daemon "${name}" declares a binding to unknown service "${binding.service}". Add "${binding.service}" to \`services\` or fix the binding.`);if(envs.has(binding.env))return invalid(`Daemon "${name}" declares more than one binding for the environment variable "${binding.env}".`);envs.add(binding.env)}}let destinations=[...config.rewrites??[],...config.routes??[],...Object.values(services).flatMap(service=>[...service.rewrites??[],...service.routes??[]])].map(entry=>"destination"in entry?entry.destination:void 0);for(let destination of destinations)if(typeof destination=="object"&&destination!==null&&isDaemonTarget(destination.service))return invalid(`Rewrites and routes cannot target daemon "${destination.service}" because daemons do not receive traffic.`);return null}export{require_dist3 as require_dist,validateConfig};
|