vercel 59.11.2 → 59.12.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-BKSHWTPX.js → add-OO3JGLZW.js} +23 -18
- package/dist/chunks/{add-HPLJZFM2.js → add-RTXDASSS.js} +23 -18
- package/dist/chunks/add-XGO6LHMD.js +221 -0
- package/dist/chunks/{build-V4ZLAJWB.js → build-JINV2UD4.js} +23 -18
- package/dist/chunks/{chunk-NGGLYKNU.js → chunk-26CU4Q3C.js} +3 -115
- package/dist/chunks/{chunk-QFAS4OVW.js → chunk-2JIX6UMI.js} +3 -84
- package/dist/chunks/chunk-2NIDTSQJ.js +305 -0
- package/dist/chunks/chunk-32XSMM3W.js +49 -0
- package/dist/chunks/chunk-332LMJLZ.js +16014 -0
- package/dist/chunks/{chunk-RO44KX6Y.js → chunk-3BB2HOO2.js} +12 -7
- package/dist/chunks/{chunk-HDBQPBL6.js → chunk-3F25W3GA.js} +13 -9
- package/dist/chunks/{chunk-AYLY3ZVL.js → chunk-3VM7HWF6.js} +2 -2
- package/dist/chunks/chunk-4IALDGB7.js +22 -0
- package/dist/chunks/{chunk-MTWHQEXI.js → chunk-4TUMNBEE.js} +7 -5
- package/dist/chunks/{chunk-5XECIWME.js → chunk-5NF5HOBJ.js} +5 -3
- package/dist/chunks/chunk-6E6KPBXY.js +43 -0
- package/dist/chunks/{chunk-ASBP32T6.js → chunk-7MRDIPJY.js} +1 -1
- package/dist/chunks/chunk-ABSZNJQO.js +522 -0
- package/dist/chunks/{chunk-7ST552E3.js → chunk-AKLTIZCU.js} +1 -1
- package/dist/chunks/{chunk-ONRLTUP2.js → chunk-AV747POV.js} +43 -36
- package/dist/chunks/chunk-B5XLQKHI.js +849 -0
- package/dist/chunks/{chunk-BMKU5KEL.js → chunk-CV5YC2EN.js} +1 -1
- package/dist/chunks/{chunk-TPATD2MM.js → chunk-CZ5QQRXD.js} +14 -6
- package/dist/chunks/{chunk-2EAIC3SH.js → chunk-E47NARDE.js} +8 -8
- package/dist/chunks/{chunk-XM3LOQIX.js → chunk-EDMW7SBH.js} +76 -92
- package/dist/chunks/{chunk-QAT3CW4G.js → chunk-EFYMIIER.js} +2 -2
- package/dist/chunks/chunk-ELZ6WQQA.js +81 -0
- package/dist/chunks/{chunk-FKDO3CM4.js → chunk-EOLGLGXJ.js} +17 -13
- package/dist/chunks/chunk-FRVG4OW3.js +7438 -0
- package/dist/chunks/chunk-G5FBSUL4.js +822 -0
- package/dist/chunks/chunk-GDOUDU6O.js +74 -0
- package/dist/chunks/{chunk-OQ3C5VXZ.js → chunk-GVNCVKCI.js} +4 -2
- package/dist/chunks/chunk-HB4UKFDO.js +1295 -0
- package/dist/chunks/{chunk-FRAXI2WT.js → chunk-HD4DR3DA.js} +4 -3
- package/dist/chunks/{chunk-DWIC7MRV.js → chunk-HKHXKSXQ.js} +1 -1
- package/dist/chunks/{chunk-6JPVTPTU.js → chunk-HM24ZWQL.js} +4 -4
- package/dist/chunks/chunk-HR2MP4XF.js +324 -0
- package/dist/chunks/chunk-HRXRELD3.js +338 -0
- package/dist/chunks/{chunk-IJ4X426J.js → chunk-IIMSID24.js} +1 -1
- package/dist/chunks/{chunk-B4TXCKXE.js → chunk-JOXNBQ7W.js} +10 -8
- package/dist/chunks/{chunk-O75LSD3C.js → chunk-JSD4EZL3.js} +1 -1
- package/dist/chunks/{chunk-7AEEQOD4.js → chunk-K3RED3VO.js} +1 -1
- package/dist/chunks/chunk-KAF4WFF3.js +257 -0
- package/dist/chunks/{chunk-3T7WSWZH.js → chunk-KFWQ3EFH.js} +1 -1
- package/dist/chunks/{chunk-6CZZ3SH3.js → chunk-KNO327AW.js} +2 -2
- package/dist/chunks/{chunk-L3UXB2CW.js → chunk-KW7BS25T.js} +1 -1
- package/dist/chunks/{chunk-2NJJ2K5S.js → chunk-L6B6BRHH.js} +6 -6
- package/dist/chunks/{chunk-FZRBF25Y.js → chunk-LDV2R4P4.js} +4 -4
- package/dist/chunks/chunk-MADFAH3O.js +14059 -0
- package/dist/chunks/{chunk-OO3OF6MK.js → chunk-MDGPZHSM.js} +151 -26
- package/dist/chunks/{chunk-XRWOTCDO.js → chunk-ND5CF2H3.js} +1 -1
- package/dist/chunks/{chunk-6TBDHUXK.js → chunk-NDY3JDOU.js} +21 -15
- package/dist/chunks/{chunk-RKDCNQ4S.js → chunk-NW34PW6V.js} +3 -105
- package/dist/chunks/{chunk-C5HKWXRR.js → chunk-OAMU5QO6.js} +1 -1
- package/dist/chunks/{chunk-RSJBU3ON.js → chunk-OJHDGHOB.js} +35 -27
- package/dist/chunks/chunk-P7VSBDR4.js +827 -0
- package/dist/chunks/chunk-PEC3CQSK.js +90 -0
- package/dist/chunks/{chunk-KJBZ5ZST.js → chunk-PIMIVJYK.js} +1 -0
- package/dist/chunks/chunk-PNGVSHR3.js +40 -0
- package/dist/chunks/chunk-PP5GKSIX.js +137 -0
- package/dist/chunks/chunk-QB2UHSUB.js +58 -0
- package/dist/chunks/chunk-QIUK4Z7Q.js +79 -0
- package/dist/chunks/chunk-RN6V5ODW.js +114 -0
- package/dist/chunks/chunk-RNK3LXLR.js +1288 -0
- package/dist/chunks/chunk-RVBZ64EQ.js +52 -0
- package/dist/chunks/{chunk-WA2SJE5S.js → chunk-SWO66HE2.js} +4 -4
- package/dist/chunks/{chunk-NBW3BWOJ.js → chunk-TDGK45FB.js} +2 -2
- package/dist/chunks/{chunk-WNAKOXGK.js → chunk-TO7QZGYK.js} +1 -1
- package/dist/chunks/{chunk-QDV5LZ4Q.js → chunk-UA55I7M6.js} +12 -8
- package/dist/chunks/{chunk-FWKSJYDV.js → chunk-UG2WOB5L.js} +1 -1
- package/dist/chunks/chunk-UJPVHLL5.js +233 -0
- package/dist/chunks/chunk-V4RMJKQP.js +36 -0
- package/dist/chunks/chunk-VJSREJVM.js +875 -0
- package/dist/chunks/chunk-VUS2JQB2.js +121 -0
- package/dist/chunks/{chunk-4KVJ2M4J.js → chunk-WPBCUXMZ.js} +582 -37
- package/dist/chunks/chunk-WSZ5E4WH.js +92 -0
- package/dist/chunks/{chunk-Q5K5DEOK.js → chunk-WT2Y7FRD.js} +42 -28
- package/dist/chunks/chunk-WT6C2ALC.js +18188 -0
- package/dist/chunks/chunk-X6TGUHFD.js +59 -0
- package/dist/chunks/{chunk-ZSFEACZU.js → chunk-XFF5TGRA.js} +1 -1
- package/dist/chunks/chunk-XNIZGCN5.js +58 -0
- package/dist/chunks/chunk-XPJLPUKO.js +117 -0
- package/dist/chunks/{chunk-FXD67VN5.js → chunk-XUAWTW4W.js} +1 -1
- package/dist/chunks/chunk-YPMFZRTN.js +417 -0
- package/dist/chunks/chunk-YRESLJCW.js +1536 -0
- package/dist/chunks/{chunk-I526H4AS.js → chunk-YS76T533.js} +2 -2
- package/dist/chunks/{chunk-52QYYTM5.js → chunk-ZDU2NODC.js} +3 -127
- package/dist/chunks/chunk-ZW6HETRE.js +97 -0
- package/dist/chunks/{clear-IYGWCNXT.js → clear-GQTDYSKJ.js} +23 -18
- package/dist/chunks/{compile-vercel-config-NEEBZRUJ.js → compile-vercel-config-URVMKDVW.js} +8 -11
- package/dist/chunks/{config-6DS6BBR2.js → config-MSVQR5T6.js} +23 -18
- package/dist/chunks/{config-NTB5EMV4.js → config-OAXY4J6P.js} +23 -18
- package/dist/chunks/config-validator.mjs +1 -1
- package/dist/chunks/{delete-LSGID5FV.js → delete-57QO64HD.js} +19 -14
- package/dist/chunks/{delete-LLC2OGHA.js → delete-XN6ESD7C.js} +16 -12
- package/dist/chunks/detect-projects-ODNU4PK2.js +18 -0
- package/dist/chunks/detect-services-UPY4LTBZ.js +40 -0
- package/dist/chunks/{disable-H4EXEQK7.js → disable-BYI46V7B.js} +17 -13
- package/dist/chunks/{discard-FG6VKHWN.js → discard-IIQL44ZZ.js} +17 -13
- package/dist/chunks/{edit-BZJSGUHT.js → edit-BRNS3OR4.js} +19 -15
- package/dist/chunks/{edit-YE7D3CPJ.js → edit-JTW7XZH7.js} +17 -13
- package/dist/chunks/{enable-6ESD4QTE.js → enable-CH5FSQMR.js} +17 -13
- package/dist/chunks/{exec-XH4K34JM.js → exec-4IPHZ55G.js} +9 -5
- package/dist/chunks/{export-QWSJROLG.js → export-6WHQOWKM.js} +16 -13
- package/dist/chunks/{image-LTHQMKFG.js → image-ZSLYATWG.js} +11 -8
- package/dist/chunks/{import-builders-6O7ILGQJ.js → import-builders-FNMYJZGG.js} +18 -13
- package/dist/chunks/{inspect-2C4ZSNYC.js → inspect-4RDZSYWU.js} +27 -23
- package/dist/chunks/{inspect-N6SMHV3Z.js → inspect-7WQXZWET.js} +18 -14
- package/dist/chunks/{inspect-F7KCTHIL.js → inspect-CGXTNMMO.js} +19 -15
- package/dist/chunks/{inspect-ICKNCDMT.js → inspect-XJ7BYLZ5.js} +18 -14
- package/dist/chunks/{inspect-TWDPMXZ5.js → inspect-Z2MBTTB7.js} +18 -14
- package/dist/chunks/{list-NWTIJF3L.js → list-65LW6OTM.js} +20 -16
- package/dist/chunks/{list-DS7ZOUXA.js → list-7W3PHRB6.js} +25 -21
- package/dist/chunks/{list-IPGQVBJO.js → list-KS22Y57L.js} +16 -14
- package/dist/chunks/{login-F7A7ONKC.js → login-NXULVQZ2.js} +23 -18
- package/dist/chunks/{ls-2QW3ZSM6.js → ls-35EOVEIQ.js} +24 -18
- package/dist/chunks/{ls-XINES6PL.js → ls-5GKS5QRW.js} +24 -18
- package/dist/chunks/ls-ADYFYYIW.js +204 -0
- package/dist/chunks/{ls-D4TUDBIH.js → ls-DZYN3SNS.js} +24 -18
- package/dist/chunks/{ls-LSJEUPFX.js → ls-HVQOGBGV.js} +23 -16
- package/dist/chunks/{ls-NBDX3MKN.js → ls-I2PWG7YN.js} +24 -18
- package/dist/chunks/{open-VRQDWZAW.js → open-H34HXJHP.js} +18 -13
- package/dist/chunks/{permissions-6C5C7TEV.js → permissions-ZPPEPKVE.js} +14 -11
- package/dist/chunks/{publish-GVIZPNLN.js → publish-NRMKXHAU.js} +17 -13
- package/dist/chunks/pull-WUT3XTZX.js +45 -0
- package/dist/chunks/{push-EFZ5P5Z6.js → push-WFNCEA5J.js} +23 -18
- package/dist/chunks/{query-GBS2PIT4.js → query-2FQM3F7N.js} +23 -20
- package/dist/chunks/{reorder-TN65IFRL.js → reorder-GYCT7L3C.js} +17 -13
- package/dist/chunks/{reply-DYVEV3PY.js → reply-RFEXNYZ7.js} +17 -13
- package/dist/chunks/{resolve-JAWFBPUM.js → resolve-ZFGT7W6Z.js} +16 -12
- package/dist/chunks/resolve-deployment-framework-preset-NPE6RLV3.js +36 -0
- package/dist/chunks/{restore-TJVMHUBQ.js → restore-JAXPMYL5.js} +17 -13
- package/dist/chunks/rm-CLKQN5E4.js +162 -0
- package/dist/chunks/{rm-HQ5CYNJA.js → rm-JPV5V2SH.js} +23 -18
- package/dist/chunks/{rm-7XACNZ2U.js → rm-N7SGFQOA.js} +23 -18
- package/dist/chunks/{rm-REJVXALW.js → rm-UQJ4CZJH.js} +23 -18
- package/dist/chunks/{rm-CBPNMSRP.js → rm-ZUQ4U454.js} +24 -17
- package/dist/chunks/{routes-2OLIBRYX.js → routes-QVMBXOSX.js} +7 -3
- package/dist/chunks/rule-inspect-HI3YY7OY.js +123 -0
- package/dist/chunks/{rules-VGV4M4KY.js → rules-DA3Q64M4.js} +15 -12
- package/dist/chunks/{schema-GMTQOQCV.js → schema-R3C4CXJ6.js} +20 -18
- package/dist/chunks/schema-UYYFV3JB.js +381 -0
- package/dist/chunks/{set-Z5FO2FCC.js → set-TOJPGW4J.js} +21 -14
- package/dist/chunks/setup-and-link-DRYXQOH4.js +65 -0
- package/dist/chunks/{tags-SDRXWJ63.js → tags-TNLVFNVI.js} +10 -7
- package/dist/chunks/{types-JGANJ5EQ.js → types-4GAJ7XQQ.js} +9 -7
- package/dist/chunks/update-X6JB3NPI.js +224 -0
- package/dist/chunks/vlt-builder-importer-USCFHWPL.js +322 -0
- package/dist/commands/build/index.js +86 -49
- package/dist/commands/deploy/index.js +76 -67
- package/dist/commands/dev/index.js +98 -52
- package/dist/commands/env/index.js +68 -44
- package/dist/commands/link/index.js +49 -28
- package/dist/commands/list/index.js +33 -22
- package/dist/commands-bulk.js +8715 -3581
- package/dist/help.js +1 -1
- package/dist/index.js +74 -42
- package/dist/runtime-assets/node-preloads/next-dev-websocket.cjs +6 -0
- package/dist/version.mjs +1 -1
- package/package.json +52 -48
- package/dist/chunks/add-RBW7QITR.js +0 -219
- package/dist/chunks/chunk-26XDDLXM.js +0 -144
- package/dist/chunks/chunk-5GGUB4EO.js +0 -31
- package/dist/chunks/chunk-MXLA3VQS.js +0 -20
- package/dist/chunks/chunk-OTXE7MHI.js +0 -96
- package/dist/chunks/chunk-RSEAADCE.js +0 -138
- package/dist/chunks/chunk-WYU64FLP.js +0 -62123
- package/dist/chunks/chunk-XNFHNTS2.js +0 -2939
- package/dist/chunks/ls-RNGO257R.js +0 -193
- package/dist/chunks/rm-5B5VHWWN.js +0 -170
- package/dist/chunks/rule-inspect-ZSTDDFID.js +0 -281
- package/dist/chunks/schema-45SJNY5L.js +0 -427
- package/dist/chunks/update-JBQBC3IV.js +0 -233
|
@@ -7,7 +7,7 @@ const __dirname = __dirname_(__filename);
|
|
|
7
7
|
import {
|
|
8
8
|
getResolvedOrderMetadata,
|
|
9
9
|
getRollupColumnName
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7MRDIPJY.js";
|
|
11
11
|
import {
|
|
12
12
|
formatGranularity
|
|
13
13
|
} from "./chunk-5AJPMLDV.js";
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-A3NYPUKZ.js";
|
|
17
17
|
import {
|
|
18
18
|
ellipsizeMiddle
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-ND5CF2H3.js";
|
|
20
20
|
import {
|
|
21
21
|
elapsed
|
|
22
22
|
} from "./chunk-VXYGCOKL.js";
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "./chunk-GGP5R3FU.js";
|
|
26
26
|
import {
|
|
27
27
|
table
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-NW34PW6V.js";
|
|
29
29
|
import {
|
|
30
30
|
require_source
|
|
31
31
|
} from "./chunk-S7KYDPEM.js";
|
|
@@ -813,5 +813,6 @@ export {
|
|
|
813
813
|
toGranularityMsFromDuration,
|
|
814
814
|
isCanonicalAggregation,
|
|
815
815
|
getDefaultCustomMetricAggregation,
|
|
816
|
+
generateSparkline,
|
|
816
817
|
formatText
|
|
817
818
|
};
|
|
@@ -7,13 +7,13 @@ const __dirname = __dirname_(__filename);
|
|
|
7
7
|
import {
|
|
8
8
|
formatErrorJson,
|
|
9
9
|
handleApiError
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-7MRDIPJY.js";
|
|
11
11
|
import {
|
|
12
12
|
isAPIError
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-CV5YC2EN.js";
|
|
14
14
|
import {
|
|
15
15
|
output_manager_default
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-2JIX6UMI.js";
|
|
17
17
|
|
|
18
18
|
// src/commands/metrics/schema-api.ts
|
|
19
19
|
var OBSERVABILITY_METRICS_PATH = "/metrics/v1";
|
|
@@ -57,7 +57,7 @@ async function fetchMetricCatalog(client, accountId, kind, search, activeSince)
|
|
|
57
57
|
}
|
|
58
58
|
const response = await client.fetch(
|
|
59
59
|
`${OBSERVABILITY_METRICS_PATH}?${searchParams}`,
|
|
60
|
-
{ accountId }
|
|
60
|
+
{ accountId, bailOn429: true }
|
|
61
61
|
);
|
|
62
62
|
metrics.push(
|
|
63
63
|
...response.metrics.map((metric) => ({
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __dirname_ } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __dirname_(__filename);
|
|
7
|
+
import {
|
|
8
|
+
emitAlertsScopeError,
|
|
9
|
+
resolveAlertsScope
|
|
10
|
+
} from "./chunk-3BB2HOO2.js";
|
|
11
|
+
import {
|
|
12
|
+
handleValidationError,
|
|
13
|
+
validateAllProjectMutualExclusivity
|
|
14
|
+
} from "./chunk-KFWQ3EFH.js";
|
|
15
|
+
import {
|
|
16
|
+
isJSONObject
|
|
17
|
+
} from "./chunk-WT2Y7FRD.js";
|
|
18
|
+
import {
|
|
19
|
+
AGENT_REASON
|
|
20
|
+
} from "./chunk-VUS2JQB2.js";
|
|
21
|
+
import {
|
|
22
|
+
getScope
|
|
23
|
+
} from "./chunk-ABSZNJQO.js";
|
|
24
|
+
import {
|
|
25
|
+
getProjectByNameOrId
|
|
26
|
+
} from "./chunk-MADFAH3O.js";
|
|
27
|
+
import {
|
|
28
|
+
buildCommandWithGlobalFlags,
|
|
29
|
+
outputAgentError
|
|
30
|
+
} from "./chunk-26CU4Q3C.js";
|
|
31
|
+
import {
|
|
32
|
+
ProjectNotFound,
|
|
33
|
+
isAPIError
|
|
34
|
+
} from "./chunk-CV5YC2EN.js";
|
|
35
|
+
import {
|
|
36
|
+
output_manager_default
|
|
37
|
+
} from "./chunk-2JIX6UMI.js";
|
|
38
|
+
|
|
39
|
+
// src/commands/alerts/rules/parse-scope.ts
|
|
40
|
+
async function resolveRulesTeam(client, jsonOutput) {
|
|
41
|
+
const { team } = await getScope(client, { resolveLocalScope: true });
|
|
42
|
+
if (team) {
|
|
43
|
+
return { teamId: team.id };
|
|
44
|
+
}
|
|
45
|
+
const message = "No team context found. Run `vercel switch` to select a team, use `--scope <team>`, or link a team project.";
|
|
46
|
+
return emitAlertsScopeError(client, jsonOutput, "NO_TEAM", message, {
|
|
47
|
+
reason: AGENT_REASON.MISSING_SCOPE,
|
|
48
|
+
hint: "Alert rules belong to a team. Select the team before retrying.",
|
|
49
|
+
next: [
|
|
50
|
+
{
|
|
51
|
+
command: buildCommandWithGlobalFlags(client.argv, "teams switch"),
|
|
52
|
+
when: "Select a team"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
command: buildCommandWithGlobalFlags(client.argv, "whoami"),
|
|
56
|
+
when: "Inspect the current scope"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async function resolveRulesProject(client, projectNameOrId, jsonOutput, command) {
|
|
62
|
+
const teamScope = await resolveRulesTeam(client, jsonOutput);
|
|
63
|
+
if (typeof teamScope === "number") {
|
|
64
|
+
return teamScope;
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const project = await getProjectByNameOrId(
|
|
68
|
+
client,
|
|
69
|
+
projectNameOrId,
|
|
70
|
+
teamScope.teamId
|
|
71
|
+
);
|
|
72
|
+
if (project instanceof ProjectNotFound) {
|
|
73
|
+
return emitAlertsScopeError(
|
|
74
|
+
client,
|
|
75
|
+
jsonOutput,
|
|
76
|
+
"PROJECT_NOT_FOUND",
|
|
77
|
+
`Project "${projectNameOrId}" was not found in the selected team.`,
|
|
78
|
+
{
|
|
79
|
+
reason: AGENT_REASON.NOT_FOUND,
|
|
80
|
+
next: [
|
|
81
|
+
{
|
|
82
|
+
command: buildCommandWithGlobalFlags(
|
|
83
|
+
client.argv,
|
|
84
|
+
`${command} --project <name_or_id>`
|
|
85
|
+
),
|
|
86
|
+
when: "Retry with a valid project"
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...teamScope,
|
|
94
|
+
projectId: project.id,
|
|
95
|
+
projectName: project.name
|
|
96
|
+
};
|
|
97
|
+
} catch (error) {
|
|
98
|
+
if (!isAPIError(error)) {
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
return emitAlertsScopeError(
|
|
102
|
+
client,
|
|
103
|
+
jsonOutput,
|
|
104
|
+
error.code || "API_ERROR",
|
|
105
|
+
error.serverMessage || `API error (${error.status}).`,
|
|
106
|
+
{
|
|
107
|
+
reason: error.status === 401 ? "not_authorized" : error.status === 403 ? "forbidden" : AGENT_REASON.API_ERROR
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async function parseRulesFlagsAndScope(client, flags, jsonOutput, command = "alerts rules ls") {
|
|
113
|
+
const mutual = validateAllProjectMutualExclusivity(
|
|
114
|
+
flags["--all"],
|
|
115
|
+
flags["--project"]
|
|
116
|
+
);
|
|
117
|
+
if (!mutual.valid) {
|
|
118
|
+
outputAgentError(
|
|
119
|
+
client,
|
|
120
|
+
{
|
|
121
|
+
status: "error",
|
|
122
|
+
reason: AGENT_REASON.INVALID_ARGUMENTS,
|
|
123
|
+
message: mutual.message,
|
|
124
|
+
next: [
|
|
125
|
+
{
|
|
126
|
+
command: buildCommandWithGlobalFlags(
|
|
127
|
+
client.argv,
|
|
128
|
+
"alerts rules --help"
|
|
129
|
+
),
|
|
130
|
+
when: "Use either `--project` or `--all`, not both"
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
1
|
|
135
|
+
);
|
|
136
|
+
return handleValidationError(mutual, jsonOutput, client);
|
|
137
|
+
}
|
|
138
|
+
if (flags["--all"]) {
|
|
139
|
+
return resolveRulesTeam(client, jsonOutput);
|
|
140
|
+
}
|
|
141
|
+
if (flags["--project"]) {
|
|
142
|
+
return resolveRulesProject(client, flags["--project"], jsonOutput, command);
|
|
143
|
+
}
|
|
144
|
+
const linkedScope = await resolveAlertsScope(client, {
|
|
145
|
+
jsonOutput,
|
|
146
|
+
command
|
|
147
|
+
});
|
|
148
|
+
if (typeof linkedScope === "number")
|
|
149
|
+
return linkedScope;
|
|
150
|
+
const teamScope = await resolveRulesTeam(client, jsonOutput);
|
|
151
|
+
if (typeof teamScope === "number")
|
|
152
|
+
return teamScope;
|
|
153
|
+
return linkedScope.teamId === teamScope.teamId ? linkedScope : teamScope;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// src/commands/alerts/rules/util.ts
|
|
157
|
+
import { readFileSync } from "fs";
|
|
158
|
+
import { resolve } from "path";
|
|
159
|
+
function rulesCollectionPath(teamId, options = {}) {
|
|
160
|
+
const query = new URLSearchParams({ teamId });
|
|
161
|
+
if (options.limit !== void 0)
|
|
162
|
+
query.set("limit", String(options.limit));
|
|
163
|
+
if (options.cursor)
|
|
164
|
+
query.set("cursor", options.cursor);
|
|
165
|
+
if (options.projectId)
|
|
166
|
+
query.set("projectId", options.projectId);
|
|
167
|
+
if (options.type)
|
|
168
|
+
query.set("type", options.type);
|
|
169
|
+
return `/alerts/v3/alert-rules?${query.toString()}`;
|
|
170
|
+
}
|
|
171
|
+
function rulesItemPath(teamId, ruleId) {
|
|
172
|
+
const query = new URLSearchParams({ teamId });
|
|
173
|
+
return `/alerts/v3/alert-rules/${encodeURIComponent(ruleId)}?${query.toString()}`;
|
|
174
|
+
}
|
|
175
|
+
function rulesSchemaPath(teamId, type) {
|
|
176
|
+
const query = new URLSearchParams({ teamId });
|
|
177
|
+
if (type)
|
|
178
|
+
query.set("type", type);
|
|
179
|
+
return `/alerts/v3/alert-rules/schema?${query.toString()}`;
|
|
180
|
+
}
|
|
181
|
+
async function fetchRule(client, scope, ruleId) {
|
|
182
|
+
const response = await client.fetch(
|
|
183
|
+
rulesItemPath(scope.teamId, ruleId)
|
|
184
|
+
);
|
|
185
|
+
return response.rule;
|
|
186
|
+
}
|
|
187
|
+
function getIssues(error) {
|
|
188
|
+
if (!Array.isArray(error.issues))
|
|
189
|
+
return [];
|
|
190
|
+
return error.issues.filter(
|
|
191
|
+
(issue) => isJSONObject(issue) && typeof issue.path === "string" && typeof issue.message === "string"
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
function outputRulesError(client, jsonOutput, code, message, options = {}) {
|
|
195
|
+
const issues = options.issues ?? [];
|
|
196
|
+
const issueSummary = issues.slice(0, 5).map((issue) => `${issue.path || "body"}: ${issue.message}`).join("; ");
|
|
197
|
+
outputAgentError(
|
|
198
|
+
client,
|
|
199
|
+
{
|
|
200
|
+
status: "error",
|
|
201
|
+
reason: options.reason ?? AGENT_REASON.INVALID_ARGUMENTS,
|
|
202
|
+
message,
|
|
203
|
+
hint: options.hint ?? (issueSummary || void 0)
|
|
204
|
+
},
|
|
205
|
+
1
|
|
206
|
+
);
|
|
207
|
+
if (jsonOutput) {
|
|
208
|
+
client.stdout.write(
|
|
209
|
+
`${JSON.stringify(
|
|
210
|
+
{ error: { code, message, ...issues.length ? { issues } : {} } },
|
|
211
|
+
null,
|
|
212
|
+
2
|
|
213
|
+
)}
|
|
214
|
+
`
|
|
215
|
+
);
|
|
216
|
+
} else {
|
|
217
|
+
output_manager_default.fatal(
|
|
218
|
+
[
|
|
219
|
+
message,
|
|
220
|
+
...issues.map((issue) => ` ${issue.path}: ${issue.message}`)
|
|
221
|
+
].join("\n")
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
return 1;
|
|
225
|
+
}
|
|
226
|
+
function handleRulesApiError(client, err, jsonOutput) {
|
|
227
|
+
const message = err.status === 401 ? "You do not have access to alert rules in this team. Ensure your role can manage Alert Rules, or pass --token and --scope." : err.status === 403 ? err.serverMessage || "You do not have permission to manage alert rules in this team." : err.status >= 500 ? `The alert rules endpoint failed (${err.status}). Re-run with --debug and share the x-vercel-id from the failed request.` : err.serverMessage || `API error (${err.status}).`;
|
|
228
|
+
return outputRulesError(
|
|
229
|
+
client,
|
|
230
|
+
jsonOutput,
|
|
231
|
+
err.code || "API_ERROR",
|
|
232
|
+
message,
|
|
233
|
+
{
|
|
234
|
+
reason: err.status === 401 ? "not_authorized" : err.status === 403 ? "forbidden" : err.status === 404 ? AGENT_REASON.NOT_FOUND : err.status === 429 ? "rate_limited" : AGENT_REASON.API_ERROR,
|
|
235
|
+
issues: getIssues(err),
|
|
236
|
+
hint: err.status === 401 || err.status === 403 ? "Confirm the team with `vercel whoami`; use --scope <team-slug> if the rule belongs to another team." : void 0
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
var LEGACY_BODY_FIELDS = ["alertTypes", "customAlert", "queryJsonString"];
|
|
241
|
+
function readRuleBody(client, bodyPath, jsonOutput) {
|
|
242
|
+
let raw;
|
|
243
|
+
try {
|
|
244
|
+
raw = readFileSync(resolve(client.cwd, bodyPath), "utf8");
|
|
245
|
+
} catch {
|
|
246
|
+
return outputRulesError(
|
|
247
|
+
client,
|
|
248
|
+
jsonOutput,
|
|
249
|
+
"INVALID_ARGUMENTS",
|
|
250
|
+
`Could not read --body file: ${bodyPath}`
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
let parsed;
|
|
254
|
+
try {
|
|
255
|
+
parsed = JSON.parse(raw);
|
|
256
|
+
} catch {
|
|
257
|
+
return outputRulesError(
|
|
258
|
+
client,
|
|
259
|
+
jsonOutput,
|
|
260
|
+
"INVALID_ARGUMENTS",
|
|
261
|
+
"Invalid JSON in --body file."
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
if (!isJSONObject(parsed)) {
|
|
265
|
+
return outputRulesError(
|
|
266
|
+
client,
|
|
267
|
+
jsonOutput,
|
|
268
|
+
"INVALID_ARGUMENTS",
|
|
269
|
+
"The --body file must contain a JSON object."
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
if (LEGACY_BODY_FIELDS.some((field) => Object.hasOwn(parsed, field))) {
|
|
273
|
+
return outputRulesError(
|
|
274
|
+
client,
|
|
275
|
+
jsonOutput,
|
|
276
|
+
"LEGACY_ALERT_RULE_BODY",
|
|
277
|
+
"This body uses the previous alert-rules shape. Rewrite it using the built-in or custom schema.",
|
|
278
|
+
{
|
|
279
|
+
hint: "Run `vercel alerts rules schema --type built-in` or `vercel alerts rules schema --type custom` for examples."
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return parsed;
|
|
284
|
+
}
|
|
285
|
+
function getBodyType(body) {
|
|
286
|
+
return body.type === "built-in" || body.type === "custom" ? body.type : void 0;
|
|
287
|
+
}
|
|
288
|
+
function emitRulesArgParseError(client, err, recoverWithProjectFlag) {
|
|
289
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
290
|
+
const projectFlagMissingArg = message.includes("--project") && message.includes("requires argument");
|
|
291
|
+
outputAgentError(
|
|
292
|
+
client,
|
|
293
|
+
{
|
|
294
|
+
status: "error",
|
|
295
|
+
reason: AGENT_REASON.INVALID_ARGUMENTS,
|
|
296
|
+
message: projectFlagMissingArg ? "`--project` requires a project name or id (for example `--project my-app`)." : message,
|
|
297
|
+
next: [
|
|
298
|
+
{
|
|
299
|
+
command: buildCommandWithGlobalFlags(
|
|
300
|
+
client.argv,
|
|
301
|
+
projectFlagMissingArg ? recoverWithProjectFlag : "alerts rules --help"
|
|
302
|
+
),
|
|
303
|
+
when: projectFlagMissingArg ? "Retry with a project name or id" : "See valid `alerts rules` subcommands"
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
1
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export {
|
|
312
|
+
resolveRulesTeam,
|
|
313
|
+
resolveRulesProject,
|
|
314
|
+
parseRulesFlagsAndScope,
|
|
315
|
+
rulesCollectionPath,
|
|
316
|
+
rulesItemPath,
|
|
317
|
+
rulesSchemaPath,
|
|
318
|
+
fetchRule,
|
|
319
|
+
outputRulesError,
|
|
320
|
+
handleRulesApiError,
|
|
321
|
+
readRuleBody,
|
|
322
|
+
getBodyType,
|
|
323
|
+
emitRulesArgParseError
|
|
324
|
+
};
|