vercel 56.5.0 → 57.0.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-6GRH6G2M.js → add-7M577U56.js} +6 -5
- package/dist/chunks/{add-KNK5E2YT.js → add-YRZTDNXX.js} +2 -2
- package/dist/chunks/{chunk-4MK452Y5.js → chunk-2EDWKVNP.js} +8 -8
- package/dist/chunks/{chunk-YS6EDZHB.js → chunk-2MJROFVC.js} +5 -1
- package/dist/chunks/{chunk-JQG5EDRD.js → chunk-3242RXCN.js} +1 -1
- package/dist/chunks/chunk-3PGXYIKC.js +147 -0
- package/dist/chunks/{chunk-3BHSS5E2.js → chunk-4PGF367U.js} +47 -210
- package/dist/chunks/{chunk-ARKHETJP.js → chunk-555WJSO5.js} +1 -1
- package/dist/chunks/chunk-5AJPMLDV.js +28 -0
- package/dist/chunks/{chunk-IBP2XAUH.js → chunk-A2TYQBX2.js} +17 -3
- package/dist/chunks/{chunk-V5P25P7F.js → chunk-A3NYPUKZ.js} +7 -12
- package/dist/chunks/{chunk-W346YNDN.js → chunk-DWMH5M4Q.js} +4 -1
- package/dist/chunks/{chunk-BM36UWE2.js → chunk-F5PQWDOC.js} +1 -1
- package/dist/chunks/{chunk-DOF6CJLL.js → chunk-F7X55TOY.js} +15 -839
- package/dist/chunks/chunk-FGDKMNEN.js +21 -0
- package/dist/chunks/{chunk-DI3HR3K6.js → chunk-GP5VCTEU.js} +1 -1
- package/dist/chunks/chunk-GZLPFESR.js +48 -0
- package/dist/chunks/{chunk-X43U65TH.js → chunk-HD7B425F.js} +2 -2
- package/dist/chunks/{chunk-CM3DLBDY.js → chunk-IOAZNR6Z.js} +1 -1
- package/dist/chunks/{chunk-STJJ3DFO.js → chunk-KCF6S3XF.js} +16 -1
- package/dist/chunks/{chunk-YTFJGKRG.js → chunk-LMHT3QR3.js} +1 -1
- package/dist/chunks/{chunk-SWEPOMSA.js → chunk-MAHINYBW.js} +4 -3
- package/dist/chunks/{chunk-G4MTGCZ5.js → chunk-MIFDRYTN.js} +1 -1
- package/dist/chunks/{chunk-PRYNIKBZ.js → chunk-NH43BFJ3.js} +1 -1
- package/dist/chunks/{chunk-Z7NPYIZ6.js → chunk-NM43FFV6.js} +0 -8
- package/dist/chunks/{chunk-PPEQUJ7T.js → chunk-NRNMT43R.js} +3 -3
- package/dist/chunks/chunk-OF2GNB42.js +53 -0
- package/dist/chunks/chunk-PRWJUY5U.js +848 -0
- package/dist/chunks/{chunk-F5OMERHI.js → chunk-QZD5DKUR.js} +10 -23
- package/dist/chunks/{chunk-26TEKOBZ.js → chunk-RAFH25WW.js} +8 -1
- package/dist/chunks/{chunk-GAOAGU5K.js → chunk-RYO6FJFB.js} +1 -1
- package/dist/chunks/{chunk-23U6FANO.js → chunk-T4NODP6Y.js} +11 -18
- package/dist/chunks/{chunk-TMK6RSYW.js → chunk-TBR2Q37Y.js} +1202 -947
- package/dist/chunks/chunk-V4RMJKQP.js +36 -0
- package/dist/chunks/{chunk-6RTK6BWX.js → chunk-YA3WQFLY.js} +1 -1
- package/dist/chunks/{chunk-EYICIM2K.js → chunk-YOZCJHLZ.js} +4 -4
- package/dist/chunks/{compile-vercel-config-IFET4E6H.js → compile-vercel-config-3OHO3TJA.js} +1 -1
- package/dist/chunks/config-validator.mjs +1 -1
- package/dist/chunks/{delete-X2MUMONI.js → delete-3DZOCWCC.js} +2 -2
- package/dist/chunks/{delete-PXB5WRH7.js → delete-VOSJLNEA.js} +2 -2
- package/dist/chunks/{disable-GBL3SHJL.js → disable-LQDEVRQF.js} +2 -2
- package/dist/chunks/{discard-XVVSRGDR.js → discard-RGV4JKXQ.js} +2 -2
- package/dist/chunks/{edit-EIHRP6XT.js → edit-SFIEOQ24.js} +3 -3
- package/dist/chunks/{edit-K5Y2BDJO.js → edit-UPZPI54L.js} +2 -2
- package/dist/chunks/{enable-W7AMJWKH.js → enable-6UVH35WC.js} +2 -2
- package/dist/chunks/{export-N3AZ2KOO.js → export-6CEG3CK7.js} +2 -2
- package/dist/chunks/{image-DRTGVPVJ.js → image-CQRCD2OE.js} +3 -3
- package/dist/chunks/{inspect-SLZLI6ZC.js → inspect-4ZAH3RFT.js} +3 -3
- package/dist/chunks/inspect-EXQBIAFF.js +587 -0
- package/dist/chunks/{inspect-AAIVWSJI.js → inspect-K5ZMQG7X.js} +2 -2
- package/dist/chunks/{inspect-DYXTX6P4.js → inspect-UM3LDRPV.js} +2 -2
- package/dist/chunks/{inspect-IPSAYR2C.js → inspect-ZFRY3X3H.js} +2 -2
- package/dist/chunks/{list-V7VTXVK4.js → list-4DRVM7Q4.js} +41 -54
- package/dist/chunks/{list-IF2YW73F.js → list-FJCBOCCA.js} +1 -1
- package/dist/chunks/{list-K2HLGUXV.js → list-KCUHD4OA.js} +3 -3
- package/dist/chunks/{login-7C6HQEOG.js → login-DFGYNU3K.js} +2 -2
- package/dist/chunks/{ls-QQQHOJBE.js → ls-34NCZKBE.js} +2 -2
- package/dist/chunks/{ls-NKECPPOR.js → ls-4QHHVXXD.js} +2 -2
- package/dist/chunks/{ls-2NU353QP.js → ls-CG6A7UXF.js} +2 -2
- package/dist/chunks/ls-RHEQ6YQB.js +188 -0
- package/dist/chunks/{open-2FAPZA6V.js → open-E3XADEMX.js} +2 -2
- package/dist/chunks/{publish-G7PB64LJ.js → publish-Z3AQRUCS.js} +2 -2
- package/dist/chunks/{query-D4QBT4WR.js → query-3EV66DO3.js} +8 -8
- package/dist/chunks/{reorder-3Z7YIPAX.js → reorder-VA5E5ZJT.js} +2 -2
- package/dist/chunks/{reply-7QQBXL5H.js → reply-SNSCNKAW.js} +2 -2
- package/dist/chunks/{resolve-UYKTDZEX.js → resolve-6ZX4RTXX.js} +2 -2
- package/dist/chunks/{restore-Q2DR7SMW.js → restore-NEHI5B5P.js} +2 -2
- package/dist/chunks/{rm-PCWMEHQ2.js → rm-22B22E47.js} +2 -2
- package/dist/chunks/{rm-O4M4GFSK.js → rm-E5ZVLAKO.js} +2 -2
- package/dist/chunks/{rm-OCLUTM57.js → rm-FR6KE744.js} +6 -5
- package/dist/chunks/rule-inspect-DMP2CKJQ.js +283 -0
- package/dist/chunks/{rules-LIH5FLPJ.js → rules-EYGXEI2Z.js} +7 -7
- package/dist/chunks/{schema-OFALTXXM.js → schema-2IIWOBSQ.js} +6 -4
- package/dist/chunks/{tags-P4HIAI6D.js → tags-ZDVYRHAY.js} +2 -2
- package/dist/chunks/{update-E3ZQAFBS.js → update-QH4DQMZV.js} +6 -5
- package/dist/commands/build/index.js +42 -10
- package/dist/commands/deploy/index.js +34 -24
- package/dist/commands/dev/index.js +10 -13
- package/dist/commands/env/index.js +8 -7
- package/dist/commands/link/index.js +8 -8
- package/dist/commands/list/index.js +2 -2
- package/dist/commands-bulk.js +1836 -1796
- package/dist/index.js +19 -20
- package/dist/vc.js +54 -18
- package/dist/version.mjs +1 -1
- package/package.json +38 -38
- package/dist/chunks/chunk-GNV7547O.js +0 -86
- package/dist/chunks/inspect-5YUAEI3L.js +0 -351
- package/dist/chunks/ls-RH6Y4XBS.js +0 -113
- package/dist/chunks/rule-inspect-XJ47UEG7.js +0 -141
|
@@ -0,0 +1,587 @@
|
|
|
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
|
+
formatTriggerOperator,
|
|
9
|
+
getGroupStartedAt,
|
|
10
|
+
getGroupTitle,
|
|
11
|
+
getGroupType,
|
|
12
|
+
humanizeReference,
|
|
13
|
+
normalizeTimestamp,
|
|
14
|
+
renderAlertTable
|
|
15
|
+
} from "./chunk-3PGXYIKC.js";
|
|
16
|
+
import {
|
|
17
|
+
resolveAlertsScope
|
|
18
|
+
} from "./chunk-T4NODP6Y.js";
|
|
19
|
+
import {
|
|
20
|
+
formatDate
|
|
21
|
+
} from "./chunk-GZLPFESR.js";
|
|
22
|
+
import {
|
|
23
|
+
formatGranularity
|
|
24
|
+
} from "./chunk-5AJPMLDV.js";
|
|
25
|
+
import "./chunk-A3NYPUKZ.js";
|
|
26
|
+
import {
|
|
27
|
+
outputError
|
|
28
|
+
} from "./chunk-BUZRVER7.js";
|
|
29
|
+
import "./chunk-FGDKMNEN.js";
|
|
30
|
+
import "./chunk-PRWJUY5U.js";
|
|
31
|
+
import {
|
|
32
|
+
truncateEnd,
|
|
33
|
+
truncateMiddle
|
|
34
|
+
} from "./chunk-OF2GNB42.js";
|
|
35
|
+
import {
|
|
36
|
+
validateJsonOutput
|
|
37
|
+
} from "./chunk-XPKWKPWA.js";
|
|
38
|
+
import {
|
|
39
|
+
inspectSubcommand
|
|
40
|
+
} from "./chunk-2MJROFVC.js";
|
|
41
|
+
import "./chunk-KCF6S3XF.js";
|
|
42
|
+
import "./chunk-NZRWTCRM.js";
|
|
43
|
+
import "./chunk-TBR2Q37Y.js";
|
|
44
|
+
import "./chunk-ECCWJHC6.js";
|
|
45
|
+
import {
|
|
46
|
+
AGENT_REASON,
|
|
47
|
+
buildCommandWithGlobalFlags,
|
|
48
|
+
outputAgentError
|
|
49
|
+
} from "./chunk-UDWRZXIT.js";
|
|
50
|
+
import {
|
|
51
|
+
parseArguments,
|
|
52
|
+
printError
|
|
53
|
+
} from "./chunk-SZXT3PDQ.js";
|
|
54
|
+
import {
|
|
55
|
+
getFlagsSpecification,
|
|
56
|
+
isAPIError,
|
|
57
|
+
packageName
|
|
58
|
+
} from "./chunk-KSSNLCL4.js";
|
|
59
|
+
import "./chunk-P4QNYOFB.js";
|
|
60
|
+
import "./chunk-52QYYTM5.js";
|
|
61
|
+
import {
|
|
62
|
+
output_manager_default
|
|
63
|
+
} from "./chunk-OX7KI3LF.js";
|
|
64
|
+
import "./chunk-GGP5R3FU.js";
|
|
65
|
+
import {
|
|
66
|
+
require_source
|
|
67
|
+
} from "./chunk-S7KYDPEM.js";
|
|
68
|
+
import {
|
|
69
|
+
__toESM
|
|
70
|
+
} from "./chunk-TZ2YI2VH.js";
|
|
71
|
+
|
|
72
|
+
// src/commands/alerts/inspect.ts
|
|
73
|
+
var import_chalk = __toESM(require_source(), 1);
|
|
74
|
+
var aggregationLabels = {
|
|
75
|
+
sum: "Sum",
|
|
76
|
+
avg: "Average",
|
|
77
|
+
min: "Min",
|
|
78
|
+
max: "Max",
|
|
79
|
+
p50: "P50",
|
|
80
|
+
p75: "P75",
|
|
81
|
+
p90: "P90",
|
|
82
|
+
p95: "P95",
|
|
83
|
+
p99: "P99",
|
|
84
|
+
stddev: "Std Dev",
|
|
85
|
+
unique: "Unique",
|
|
86
|
+
persecond: "Per Second",
|
|
87
|
+
percent: "Percent"
|
|
88
|
+
};
|
|
89
|
+
var formatCustomAlertRatioBelowFivePercent = new Intl.NumberFormat("en-US", {
|
|
90
|
+
maximumFractionDigits: 2,
|
|
91
|
+
minimumFractionDigits: 2,
|
|
92
|
+
style: "percent"
|
|
93
|
+
});
|
|
94
|
+
var formatCustomAlertRatioThresholdValue = new Intl.NumberFormat("en-US", {
|
|
95
|
+
maximumFractionDigits: 4,
|
|
96
|
+
minimumFractionDigits: 0,
|
|
97
|
+
style: "percent"
|
|
98
|
+
});
|
|
99
|
+
function getGroupStatus(group) {
|
|
100
|
+
if (group.status) {
|
|
101
|
+
return group.status;
|
|
102
|
+
}
|
|
103
|
+
const alerts = group.alerts ?? [];
|
|
104
|
+
if (alerts.some((alert) => alert.status === "active")) {
|
|
105
|
+
return "active";
|
|
106
|
+
}
|
|
107
|
+
if (alerts.length > 0) {
|
|
108
|
+
return "resolved";
|
|
109
|
+
}
|
|
110
|
+
return "-";
|
|
111
|
+
}
|
|
112
|
+
function humanizeLabel(value) {
|
|
113
|
+
return humanizeReference(value, { case: "title" });
|
|
114
|
+
}
|
|
115
|
+
function formatAlertFieldValue(value, maxLength = 64) {
|
|
116
|
+
if (value === null || value === void 0) {
|
|
117
|
+
return void 0;
|
|
118
|
+
}
|
|
119
|
+
const displayValue = typeof value === "number" ? formatNumber(value) : String(value);
|
|
120
|
+
if (!displayValue) {
|
|
121
|
+
return void 0;
|
|
122
|
+
}
|
|
123
|
+
return truncateMiddle(displayValue, maxLength);
|
|
124
|
+
}
|
|
125
|
+
function formatNumber(value) {
|
|
126
|
+
const absValue = Math.abs(value);
|
|
127
|
+
const sign = value < 0 ? "-" : "";
|
|
128
|
+
for (const [threshold, suffix] of [
|
|
129
|
+
[1e9, "B"],
|
|
130
|
+
[1e6, "M"],
|
|
131
|
+
[1e3, "k"]
|
|
132
|
+
]) {
|
|
133
|
+
if (absValue >= threshold) {
|
|
134
|
+
return `${sign}${(absValue / threshold).toFixed(1).replace(/\.0$/, "")}${suffix}`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return Number.isInteger(value) ? String(value) : value.toFixed(2).replace(/\.?0+$/, "");
|
|
138
|
+
}
|
|
139
|
+
function parseFormattedNumber(value) {
|
|
140
|
+
const trimmed = value.trim();
|
|
141
|
+
if (!trimmed) {
|
|
142
|
+
return void 0;
|
|
143
|
+
}
|
|
144
|
+
const number = Number(trimmed.replace(/,/g, ""));
|
|
145
|
+
return Number.isFinite(number) ? number : void 0;
|
|
146
|
+
}
|
|
147
|
+
function formatRatio(value) {
|
|
148
|
+
if (value.trim().endsWith("%")) {
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
const number = parseFormattedNumber(value);
|
|
152
|
+
if (number === void 0) {
|
|
153
|
+
return value;
|
|
154
|
+
}
|
|
155
|
+
const percent = number * 100;
|
|
156
|
+
if (percent >= 5) {
|
|
157
|
+
return `${Math.floor(percent)}%`;
|
|
158
|
+
}
|
|
159
|
+
return formatCustomAlertRatioBelowFivePercent.format(number);
|
|
160
|
+
}
|
|
161
|
+
function formatRatioThreshold(value) {
|
|
162
|
+
if (value.trim().endsWith("%")) {
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
const number = parseFormattedNumber(value);
|
|
166
|
+
return number === void 0 ? value : formatCustomAlertRatioThresholdValue.format(number);
|
|
167
|
+
}
|
|
168
|
+
function getAlertSonarQuery(alert) {
|
|
169
|
+
return alert.sonarQuery ?? alert.data?.sonarQuery;
|
|
170
|
+
}
|
|
171
|
+
function getCustomAlertBaselineTitle(alert) {
|
|
172
|
+
const granularity = getAlertSonarQuery(alert)?.granularity;
|
|
173
|
+
const baseline = granularity && ("hours" in granularity || "days" in granularity) ? "7-day baseline" : "24-hour baseline";
|
|
174
|
+
return baseline.replace(/\b[a-z]/g, (character) => character.toUpperCase());
|
|
175
|
+
}
|
|
176
|
+
function appendUnit(value, unit) {
|
|
177
|
+
if (!unit || unit === "score") {
|
|
178
|
+
return value;
|
|
179
|
+
}
|
|
180
|
+
if (unit === "ratio") {
|
|
181
|
+
return formatRatio(value);
|
|
182
|
+
}
|
|
183
|
+
if (unit === "%") {
|
|
184
|
+
return value.endsWith("%") ? value : `${value}%`;
|
|
185
|
+
}
|
|
186
|
+
if (value.toLowerCase().includes(unit.toLowerCase())) {
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
return `${value} ${unit}`;
|
|
190
|
+
}
|
|
191
|
+
function formatThreshold(alert) {
|
|
192
|
+
const data = alert.data;
|
|
193
|
+
const formatted = alert.formattedValues?.formattedThreshold ?? (data?.triggerThreshold === void 0 ? void 0 : formatNumber(data.triggerThreshold));
|
|
194
|
+
if (!formatted) {
|
|
195
|
+
return void 0;
|
|
196
|
+
}
|
|
197
|
+
const operator = formatTriggerOperator(data?.triggerOperator);
|
|
198
|
+
const threshold = data?.triggerType === "anomaly" ? `${formatted} z-score` : alert.unit === "ratio" ? formatRatioThreshold(formatted) : appendUnit(formatted, alert.unit);
|
|
199
|
+
return [operator, threshold].filter(Boolean).join(" ");
|
|
200
|
+
}
|
|
201
|
+
function getRuleIds(alert) {
|
|
202
|
+
const ids = /* @__PURE__ */ new Set();
|
|
203
|
+
const dataRuleId = alert.data?.ruleId;
|
|
204
|
+
if (dataRuleId) {
|
|
205
|
+
ids.add(dataRuleId);
|
|
206
|
+
}
|
|
207
|
+
for (const ruleId of alert.rules ?? []) {
|
|
208
|
+
if (ruleId) {
|
|
209
|
+
ids.add(ruleId);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return [...ids];
|
|
213
|
+
}
|
|
214
|
+
function getAlertResolvedAt(alert) {
|
|
215
|
+
return normalizeTimestamp(alert.recordedResolvedAt ?? alert.resolvedAt);
|
|
216
|
+
}
|
|
217
|
+
function getSignalRows(alert) {
|
|
218
|
+
const rows = [];
|
|
219
|
+
const formattedValues = alert.formattedValues ?? {};
|
|
220
|
+
const observed = formattedValues.formattedCount;
|
|
221
|
+
const baseline = formattedValues.formattedAvg;
|
|
222
|
+
const change = [formattedValues.changeDirection, formattedValues.changeAmount].filter(Boolean).join(" ");
|
|
223
|
+
const zscore = alert.data?.zscore;
|
|
224
|
+
const threshold = formatThreshold(alert);
|
|
225
|
+
const minThreshold = alert.data?.minThreshold;
|
|
226
|
+
const isRatioFormulaAlert = Boolean(getCustomAlertFormula(alert));
|
|
227
|
+
if (alert.eventLabel) {
|
|
228
|
+
rows.push(["Event", alert.eventLabel]);
|
|
229
|
+
}
|
|
230
|
+
if (alert.measureLabel) {
|
|
231
|
+
rows.push(["Measure", alert.measureLabel]);
|
|
232
|
+
}
|
|
233
|
+
if (observed) {
|
|
234
|
+
rows.push(["Observed Value", appendUnit(observed, alert.unit)]);
|
|
235
|
+
}
|
|
236
|
+
if (baseline) {
|
|
237
|
+
rows.push([
|
|
238
|
+
alert.type === "custom_alert" && alert.data?.triggerType === "anomaly" ? getCustomAlertBaselineTitle(alert) : "Baseline",
|
|
239
|
+
appendUnit(baseline, alert.unit)
|
|
240
|
+
]);
|
|
241
|
+
}
|
|
242
|
+
if (change) {
|
|
243
|
+
rows.push(["Change", change]);
|
|
244
|
+
}
|
|
245
|
+
if (zscore !== void 0) {
|
|
246
|
+
rows.push(["Observed Deviation", `${formatNumber(zscore)} z-score`]);
|
|
247
|
+
}
|
|
248
|
+
if (threshold) {
|
|
249
|
+
rows.push(["Threshold", threshold]);
|
|
250
|
+
}
|
|
251
|
+
if (minThreshold !== void 0 && !isRatioFormulaAlert) {
|
|
252
|
+
rows.push([
|
|
253
|
+
"Minimum",
|
|
254
|
+
alert.unit === "ratio" ? formatNumber(minThreshold) : appendUnit(formatNumber(minThreshold), alert.unit)
|
|
255
|
+
]);
|
|
256
|
+
}
|
|
257
|
+
if (formattedValues.errorRate) {
|
|
258
|
+
rows.push(["Error Rate", formattedValues.errorRate]);
|
|
259
|
+
}
|
|
260
|
+
if (formattedValues.avgErrorRate) {
|
|
261
|
+
rows.push(["Baseline Error Rate", formattedValues.avgErrorRate]);
|
|
262
|
+
}
|
|
263
|
+
rows.push(...getFieldRows(alert));
|
|
264
|
+
return rows;
|
|
265
|
+
}
|
|
266
|
+
function getFieldRows(alert) {
|
|
267
|
+
const fields = alert.data?.fields;
|
|
268
|
+
if (!fields) {
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
const groupBy = getAlertSonarQuery(alert)?.groupBy ?? [];
|
|
272
|
+
const fieldKeys = [
|
|
273
|
+
...groupBy,
|
|
274
|
+
...Object.keys(fields).filter((key) => !groupBy.includes(key))
|
|
275
|
+
];
|
|
276
|
+
return fieldKeys.flatMap((key) => {
|
|
277
|
+
const value = fields[key];
|
|
278
|
+
const displayValue = formatAlertFieldValue(value);
|
|
279
|
+
return displayValue ? [[humanizeLabel(key), displayValue]] : [];
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
function formatAggregation(value) {
|
|
283
|
+
return value ? aggregationLabels[value] ?? humanizeLabel(value) : void 0;
|
|
284
|
+
}
|
|
285
|
+
function formatQueryReference(value) {
|
|
286
|
+
return value ? humanizeLabel(value) : void 0;
|
|
287
|
+
}
|
|
288
|
+
function formatRollupDetail(rollup, fallbackMeasure) {
|
|
289
|
+
if (!rollup) {
|
|
290
|
+
return void 0;
|
|
291
|
+
}
|
|
292
|
+
const aggregation = formatAggregation(rollup.aggregation);
|
|
293
|
+
const measure = fallbackMeasure ?? formatQueryReference(rollup.measure);
|
|
294
|
+
const detail = [aggregation, measure].filter(Boolean).join(" ");
|
|
295
|
+
return detail || void 0;
|
|
296
|
+
}
|
|
297
|
+
function getPrimaryRollup(rollups) {
|
|
298
|
+
return Object.values(rollups ?? {})[0];
|
|
299
|
+
}
|
|
300
|
+
function getCustomAlertFormula(alert) {
|
|
301
|
+
const formula = alert.data?.formula;
|
|
302
|
+
if (formula?.operator === "divide" && formula.left && formula.right) {
|
|
303
|
+
return {
|
|
304
|
+
operator: formula.operator,
|
|
305
|
+
left: formula.left,
|
|
306
|
+
right: formula.right
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return void 0;
|
|
310
|
+
}
|
|
311
|
+
function getQueryRows(alert) {
|
|
312
|
+
if (alert.type !== "custom_alert") {
|
|
313
|
+
return [];
|
|
314
|
+
}
|
|
315
|
+
const query = getAlertSonarQuery(alert);
|
|
316
|
+
if (!query) {
|
|
317
|
+
return [];
|
|
318
|
+
}
|
|
319
|
+
const formula = getCustomAlertFormula(alert);
|
|
320
|
+
const rows = [];
|
|
321
|
+
const addRow = (label, value) => {
|
|
322
|
+
if (value) {
|
|
323
|
+
rows.push([label, truncateMiddle(value, 120)]);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
addRow("Event", alert.eventLabel ?? formatQueryReference(query.event));
|
|
327
|
+
if (formula) {
|
|
328
|
+
addRow("Numerator", formatRollupDetail(query.rollups?.[formula.left]));
|
|
329
|
+
addRow("Denominator", formatRollupDetail(query.rollups?.[formula.right]));
|
|
330
|
+
} else {
|
|
331
|
+
const primaryRollup = getPrimaryRollup(query.rollups);
|
|
332
|
+
addRow(
|
|
333
|
+
"Measure",
|
|
334
|
+
alert.measureLabel ?? formatQueryReference(primaryRollup?.measure)
|
|
335
|
+
);
|
|
336
|
+
addRow("Aggregation", formatAggregation(primaryRollup?.aggregation));
|
|
337
|
+
}
|
|
338
|
+
addRow("Granularity", formatGranularity(query.granularity));
|
|
339
|
+
const groupBy = query.groupBy?.filter(Boolean) ?? [];
|
|
340
|
+
if (groupBy.length > 0) {
|
|
341
|
+
addRow("Group by", groupBy.map(humanizeLabel).join(", "));
|
|
342
|
+
}
|
|
343
|
+
if (formula && typeof alert.data?.minThreshold === "number") {
|
|
344
|
+
addRow("Minimum Numerator", formatNumber(alert.data.minThreshold));
|
|
345
|
+
}
|
|
346
|
+
addRow("Filter by", query.filter?.trim());
|
|
347
|
+
if (formula) {
|
|
348
|
+
for (const [label, rollupName] of [
|
|
349
|
+
["Numerator filter", formula.left],
|
|
350
|
+
["Denominator filter", formula.right]
|
|
351
|
+
]) {
|
|
352
|
+
addRow(label, query.rollups?.[rollupName]?.filter?.trim());
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return rows;
|
|
356
|
+
}
|
|
357
|
+
function getDetailRows(alert) {
|
|
358
|
+
const data = alert.data;
|
|
359
|
+
if (!data) {
|
|
360
|
+
return [];
|
|
361
|
+
}
|
|
362
|
+
const rows = [];
|
|
363
|
+
const addRow = (label, value) => {
|
|
364
|
+
const displayValue = formatAlertFieldValue(value);
|
|
365
|
+
if (displayValue) {
|
|
366
|
+
rows.push([label, displayValue]);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
addRow("Route", data.route);
|
|
370
|
+
addRow("Status Group", data.statusGroup);
|
|
371
|
+
addRow("Deployment ID", data.deploymentId);
|
|
372
|
+
return rows;
|
|
373
|
+
}
|
|
374
|
+
function renderAlertSections(alert) {
|
|
375
|
+
const lines = [];
|
|
376
|
+
const signalRows = getSignalRows(alert);
|
|
377
|
+
if (signalRows.length > 0) {
|
|
378
|
+
lines.push(import_chalk.default.cyan("Signals"));
|
|
379
|
+
lines.push(renderAlertTable(signalRows, 3));
|
|
380
|
+
}
|
|
381
|
+
const queryRows = getQueryRows(alert);
|
|
382
|
+
if (queryRows.length > 0) {
|
|
383
|
+
lines.push(import_chalk.default.cyan("Query"));
|
|
384
|
+
lines.push(renderAlertTable(queryRows, 3));
|
|
385
|
+
}
|
|
386
|
+
return lines.join("\n");
|
|
387
|
+
}
|
|
388
|
+
function renderAlert(alert, index, totalAlerts) {
|
|
389
|
+
const title = alert.title || `Alert ${index + 1}`;
|
|
390
|
+
const ruleIds = getRuleIds(alert);
|
|
391
|
+
const resolvedAt = getAlertResolvedAt(alert);
|
|
392
|
+
const sections = renderAlertSections(alert);
|
|
393
|
+
const summaryRows = [
|
|
394
|
+
["Alert id", alert.id || "-"],
|
|
395
|
+
["Type", alert.type || "-"],
|
|
396
|
+
["Status", alert.status || "-"],
|
|
397
|
+
[
|
|
398
|
+
"Started At",
|
|
399
|
+
formatDate(
|
|
400
|
+
normalizeTimestamp(alert.recordedStartedAt ?? alert.startedAt)
|
|
401
|
+
)
|
|
402
|
+
],
|
|
403
|
+
...resolvedAt !== void 0 ? [["Resolved At", formatDate(resolvedAt)]] : [],
|
|
404
|
+
...ruleIds.length > 0 ? [["Rule id", ruleIds.map((id) => truncateMiddle(id, 48)).join(", ")]] : [],
|
|
405
|
+
...getDetailRows(alert)
|
|
406
|
+
];
|
|
407
|
+
return [
|
|
408
|
+
import_chalk.default.bold(totalAlerts > 1 ? `Alert ${index + 1}: ${title}` : title),
|
|
409
|
+
renderAlertTable(summaryRows, 3),
|
|
410
|
+
...sections ? [sections] : []
|
|
411
|
+
].join("\n");
|
|
412
|
+
}
|
|
413
|
+
function printAlertGroup(group, groupId) {
|
|
414
|
+
const alerts = group.alerts ?? [];
|
|
415
|
+
const singleAlert = alerts.length === 1 ? alerts[0] : void 0;
|
|
416
|
+
const singleAlertRuleIds = singleAlert ? getRuleIds(singleAlert) : [];
|
|
417
|
+
const singleAlertResolvedAt = singleAlert ? getAlertResolvedAt(singleAlert) : void 0;
|
|
418
|
+
const summaryRows = [
|
|
419
|
+
["Title", truncateEnd(getGroupTitle(group), 80)],
|
|
420
|
+
["Group id", group.id || groupId],
|
|
421
|
+
["Type", getGroupType(group)],
|
|
422
|
+
["Status", getGroupStatus(group)],
|
|
423
|
+
["Started At", formatDate(getGroupStartedAt(group))],
|
|
424
|
+
...singleAlertResolvedAt !== void 0 ? [["Resolved At", formatDate(singleAlertResolvedAt)]] : [],
|
|
425
|
+
["Alerts", String(alerts.length)],
|
|
426
|
+
...singleAlert?.id ? [["Alert id", singleAlert.id]] : [],
|
|
427
|
+
...singleAlertRuleIds.length > 0 ? [
|
|
428
|
+
[
|
|
429
|
+
"Rule id",
|
|
430
|
+
singleAlertRuleIds.map((id) => truncateMiddle(id, 48)).join(", ")
|
|
431
|
+
]
|
|
432
|
+
] : [],
|
|
433
|
+
...singleAlert ? getDetailRows(singleAlert) : []
|
|
434
|
+
];
|
|
435
|
+
const renderedAlerts = alerts.length > 0 ? alerts.length === 1 ? renderAlertSections(alerts[0]) : alerts.map((alert, index) => renderAlert(alert, index, alerts.length)).join("\n\n") : "No alerts in this group.";
|
|
436
|
+
output_manager_default.print(
|
|
437
|
+
[
|
|
438
|
+
"",
|
|
439
|
+
`${import_chalk.default.bold("Alert group")} ${import_chalk.default.cyan(group.id || groupId)}`,
|
|
440
|
+
renderAlertTable(summaryRows, 3),
|
|
441
|
+
"",
|
|
442
|
+
renderedAlerts,
|
|
443
|
+
""
|
|
444
|
+
].join("\n")
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
async function inspect(client, argv) {
|
|
448
|
+
let parsedArgs;
|
|
449
|
+
const spec = getFlagsSpecification(inspectSubcommand.options);
|
|
450
|
+
try {
|
|
451
|
+
parsedArgs = parseArguments(argv, spec);
|
|
452
|
+
} catch (e) {
|
|
453
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
454
|
+
const projectFlagMissingArg = msg.includes("--project") && msg.includes("requires argument");
|
|
455
|
+
outputAgentError(
|
|
456
|
+
client,
|
|
457
|
+
{
|
|
458
|
+
status: "error",
|
|
459
|
+
reason: AGENT_REASON.INVALID_ARGUMENTS,
|
|
460
|
+
message: projectFlagMissingArg ? "`--project` requires a project name or id (for example `--project my-app`)." : msg,
|
|
461
|
+
next: projectFlagMissingArg ? [
|
|
462
|
+
{
|
|
463
|
+
command: buildCommandWithGlobalFlags(
|
|
464
|
+
client.argv,
|
|
465
|
+
"alerts inspect <groupId> --project <name-or-id>"
|
|
466
|
+
),
|
|
467
|
+
when: "Re-run with placeholders replaced"
|
|
468
|
+
}
|
|
469
|
+
] : [
|
|
470
|
+
{
|
|
471
|
+
command: buildCommandWithGlobalFlags(
|
|
472
|
+
client.argv,
|
|
473
|
+
"alerts inspect --help"
|
|
474
|
+
),
|
|
475
|
+
when: "See valid `alerts inspect` usage"
|
|
476
|
+
}
|
|
477
|
+
]
|
|
478
|
+
},
|
|
479
|
+
1
|
|
480
|
+
);
|
|
481
|
+
printError(e);
|
|
482
|
+
return 1;
|
|
483
|
+
}
|
|
484
|
+
const groupId = parsedArgs.args[0];
|
|
485
|
+
const fr = validateJsonOutput(parsedArgs.flags);
|
|
486
|
+
if (!fr.valid) {
|
|
487
|
+
outputAgentError(
|
|
488
|
+
client,
|
|
489
|
+
{
|
|
490
|
+
status: "error",
|
|
491
|
+
reason: AGENT_REASON.INVALID_ARGUMENTS,
|
|
492
|
+
message: fr.error
|
|
493
|
+
},
|
|
494
|
+
1
|
|
495
|
+
);
|
|
496
|
+
output_manager_default.error(fr.error);
|
|
497
|
+
return 1;
|
|
498
|
+
}
|
|
499
|
+
if (!groupId) {
|
|
500
|
+
outputAgentError(
|
|
501
|
+
client,
|
|
502
|
+
{
|
|
503
|
+
status: "error",
|
|
504
|
+
reason: AGENT_REASON.MISSING_ARGUMENTS,
|
|
505
|
+
message: `Missing group id. Example: ${packageName} alerts inspect <groupId>`,
|
|
506
|
+
next: [
|
|
507
|
+
{
|
|
508
|
+
command: buildCommandWithGlobalFlags(
|
|
509
|
+
client.argv,
|
|
510
|
+
"alerts inspect <groupId>"
|
|
511
|
+
),
|
|
512
|
+
when: "Replace <groupId> with a group id from `vercel alerts`"
|
|
513
|
+
}
|
|
514
|
+
]
|
|
515
|
+
},
|
|
516
|
+
1
|
|
517
|
+
);
|
|
518
|
+
return outputError(
|
|
519
|
+
client,
|
|
520
|
+
fr.jsonOutput,
|
|
521
|
+
"MISSING_ARGUMENTS",
|
|
522
|
+
"Usage: `vercel alerts inspect <groupId>`"
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
const scope = await resolveAlertsScope(client, {
|
|
526
|
+
project: parsedArgs.flags["--project"],
|
|
527
|
+
all: parsedArgs.flags["--all"],
|
|
528
|
+
jsonOutput: fr.jsonOutput,
|
|
529
|
+
command: `alerts inspect ${groupId}`
|
|
530
|
+
});
|
|
531
|
+
if (typeof scope === "number") {
|
|
532
|
+
return scope;
|
|
533
|
+
}
|
|
534
|
+
const query = new URLSearchParams({ teamId: scope.teamId });
|
|
535
|
+
if (scope.projectId) {
|
|
536
|
+
query.set("projectId", scope.projectId);
|
|
537
|
+
}
|
|
538
|
+
const path = `/alerts/v3/groups/${encodeURIComponent(groupId)}?${query.toString()}`;
|
|
539
|
+
output_manager_default.spinner("Fetching alert group...");
|
|
540
|
+
try {
|
|
541
|
+
const group = await client.fetch(path);
|
|
542
|
+
if (fr.jsonOutput) {
|
|
543
|
+
client.stdout.write(`${JSON.stringify({ group }, null, 2)}
|
|
544
|
+
`);
|
|
545
|
+
} else {
|
|
546
|
+
printAlertGroup(group, groupId);
|
|
547
|
+
}
|
|
548
|
+
return 0;
|
|
549
|
+
} catch (err) {
|
|
550
|
+
if (isAPIError(err)) {
|
|
551
|
+
const msg = err.serverMessage || `API error (${err.status}).`;
|
|
552
|
+
const 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;
|
|
553
|
+
outputAgentError(
|
|
554
|
+
client,
|
|
555
|
+
{
|
|
556
|
+
status: "error",
|
|
557
|
+
reason,
|
|
558
|
+
message: msg,
|
|
559
|
+
...err.status === 401 || err.status === 403 ? {
|
|
560
|
+
hint: "Confirm team scope; use --scope <team-slug> if the group belongs to another team.",
|
|
561
|
+
next: [
|
|
562
|
+
{
|
|
563
|
+
command: buildCommandWithGlobalFlags(client.argv, "whoami"),
|
|
564
|
+
when: "See current user and team"
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
command: buildCommandWithGlobalFlags(
|
|
568
|
+
client.argv,
|
|
569
|
+
`alerts inspect ${groupId}`
|
|
570
|
+
),
|
|
571
|
+
when: "Retry after fixing scope or permissions"
|
|
572
|
+
}
|
|
573
|
+
]
|
|
574
|
+
} : {}
|
|
575
|
+
},
|
|
576
|
+
1
|
|
577
|
+
);
|
|
578
|
+
return outputError(client, fr.jsonOutput, err.code || "API_ERROR", msg);
|
|
579
|
+
}
|
|
580
|
+
throw err;
|
|
581
|
+
} finally {
|
|
582
|
+
output_manager_default.stopSpinner();
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
export {
|
|
586
|
+
inspect as default
|
|
587
|
+
};
|
|
@@ -20,13 +20,13 @@ import {
|
|
|
20
20
|
requireVcrRepositoryAndImageId,
|
|
21
21
|
resolveVcrScope,
|
|
22
22
|
validateVcrJsonOutput
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-GP5VCTEU.js";
|
|
24
24
|
import "./chunk-BUZRVER7.js";
|
|
25
25
|
import "./chunk-XPKWKPWA.js";
|
|
26
26
|
import {
|
|
27
27
|
imageInspectSubcommand
|
|
28
28
|
} from "./chunk-FYQPTH5C.js";
|
|
29
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-TBR2Q37Y.js";
|
|
30
30
|
import "./chunk-ECCWJHC6.js";
|
|
31
31
|
import "./chunk-UDWRZXIT.js";
|
|
32
32
|
import {
|
|
@@ -20,13 +20,13 @@ import {
|
|
|
20
20
|
requireVcrRepositoryAndTag,
|
|
21
21
|
resolveVcrScope,
|
|
22
22
|
validateVcrJsonOutput
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-GP5VCTEU.js";
|
|
24
24
|
import "./chunk-BUZRVER7.js";
|
|
25
25
|
import "./chunk-XPKWKPWA.js";
|
|
26
26
|
import {
|
|
27
27
|
tagsInspectSubcommand
|
|
28
28
|
} from "./chunk-GIL3VAUR.js";
|
|
29
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-TBR2Q37Y.js";
|
|
30
30
|
import "./chunk-ECCWJHC6.js";
|
|
31
31
|
import "./chunk-UDWRZXIT.js";
|
|
32
32
|
import {
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
requireVcrRepository,
|
|
17
17
|
resolveVcrScope,
|
|
18
18
|
validateVcrJsonOutput
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-GP5VCTEU.js";
|
|
20
20
|
import "./chunk-BUZRVER7.js";
|
|
21
21
|
import "./chunk-XPKWKPWA.js";
|
|
22
22
|
import {
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from "./chunk-3VS4DTAU.js";
|
|
25
25
|
import "./chunk-GIL3VAUR.js";
|
|
26
26
|
import "./chunk-FYQPTH5C.js";
|
|
27
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-TBR2Q37Y.js";
|
|
28
28
|
import "./chunk-ECCWJHC6.js";
|
|
29
29
|
import "./chunk-UDWRZXIT.js";
|
|
30
30
|
import {
|