vercel 56.3.1 → 56.4.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-ANWCBEDB.js → add-2HLAH42D.js} +2 -2
- package/dist/chunks/{add-FWXAFWCU.js → add-XY2LNFK3.js} +3 -3
- package/dist/chunks/{chunk-7ZECC3BE.js → chunk-2KNVJ7ET.js} +88 -2
- package/dist/chunks/{chunk-74TJ5D35.js → chunk-4QRRJEYO.js} +2 -2
- package/dist/chunks/{chunk-4Z5LC2CI.js → chunk-6RTK6BWX.js} +4 -96
- package/dist/chunks/{chunk-JEWA7HG3.js → chunk-BRTMH4PL.js} +1 -1
- package/dist/chunks/{chunk-F3B65VPT.js → chunk-C4TEOOGB.js} +1 -1
- package/dist/chunks/{chunk-M5LOXLMK.js → chunk-EJNFC5AV.js} +1 -1
- package/dist/chunks/{chunk-UOB64NBX.js → chunk-ENIJVO7C.js} +2 -2
- package/dist/chunks/{query-XC3Y3EBD.js → chunk-F5OMERHI.js} +65 -411
- package/dist/chunks/{chunk-26VWIAO5.js → chunk-IN3RG4AU.js} +1 -1
- package/dist/chunks/{chunk-2E3ZC3JA.js → chunk-JGXABANG.js} +1 -1
- package/dist/chunks/{chunk-AHSE4X6V.js → chunk-JIK3GTU3.js} +1 -1
- package/dist/chunks/{chunk-NMAHBCNK.js → chunk-K6YMSJMZ.js} +4 -4
- package/dist/chunks/{chunk-ETWY3HX7.js → chunk-ORMDX3GR.js} +1 -1
- package/dist/chunks/{chunk-JAY74MG2.js → chunk-OSXJ6G4O.js} +3 -3
- package/dist/chunks/{chunk-IAEXF3FY.js → chunk-PEC4ROHM.js} +4 -4
- package/dist/chunks/{chunk-RGOP4OYL.js → chunk-QX4337BT.js} +10 -7
- package/dist/chunks/{chunk-SAEAR237.js → chunk-S7HMSWGQ.js} +2 -2
- package/dist/chunks/{chunk-VO6PK3ZA.js → chunk-SLCLT4P5.js} +1 -1
- package/dist/chunks/{chunk-XOED7Y6Z.js → chunk-UA3D44SL.js} +1 -1
- package/dist/chunks/{chunk-5R5FS7WB.js → chunk-VZGX4CKB.js} +1 -1
- package/dist/chunks/{chunk-D7SLHLED.js → chunk-WM3UMX65.js} +1 -1
- package/dist/chunks/chunk-Z7NPYIZ6.js +116 -0
- package/dist/chunks/{compile-vercel-config-ELXMKFUY.js → compile-vercel-config-4Q4YZ44O.js} +1 -1
- package/dist/chunks/{delete-BO3RQ3F6.js → delete-AUDPLCMU.js} +2 -2
- package/dist/chunks/{disable-WRXXRGYR.js → disable-WFPXR7GZ.js} +2 -2
- package/dist/chunks/{discard-5XOTKSVP.js → discard-RVFKIZZG.js} +2 -2
- package/dist/chunks/{edit-ML2P3MKK.js → edit-KO5KX4WU.js} +3 -3
- package/dist/chunks/{enable-E5YCEICZ.js → enable-I5HE32DI.js} +2 -2
- package/dist/chunks/{export-EUFPKG5T.js → export-4Y5L2TOT.js} +2 -2
- package/dist/chunks/{image-5WOBJQFO.js → image-QC5MVWKN.js} +3 -3
- package/dist/chunks/{inspect-7PJE37AJ.js → inspect-BULBAPNR.js} +2 -2
- package/dist/chunks/{inspect-I3ZNL35B.js → inspect-JUGFKEGR.js} +2 -2
- package/dist/chunks/{inspect-W4SOI7QI.js → inspect-PJDCPARM.js} +2 -2
- package/dist/chunks/{inspect-BX26XAK2.js → inspect-Q5BKZNVI.js} +2 -2
- package/dist/chunks/{list-44G7AUFR.js → list-FJT44SB6.js} +1 -1
- package/dist/chunks/{list-VLFAOPR5.js → list-N7OA4FBI.js} +2 -2
- package/dist/chunks/{login-CL57KXDR.js → login-BPE774JW.js} +2 -2
- package/dist/chunks/{ls-VD2DNABR.js → ls-26VFGQ6P.js} +3 -3
- package/dist/chunks/{ls-KIAXSLDB.js → ls-E47M6P5O.js} +2 -2
- package/dist/chunks/{ls-42JFBIDV.js → ls-H52WO65Y.js} +2 -2
- package/dist/chunks/{ls-EZRL6SGP.js → ls-YV554CRJ.js} +2 -2
- package/dist/chunks/{publish-C3QAGQJ7.js → publish-DUTEBRX3.js} +2 -2
- package/dist/chunks/query-QDOKUCHX.js +391 -0
- package/dist/chunks/{reorder-L56M5KP3.js → reorder-L2M3YGJ4.js} +2 -2
- package/dist/chunks/{restore-E5LGXKS3.js → restore-BVDNAJVC.js} +2 -2
- package/dist/chunks/{rm-KGRSF2OY.js → rm-4OQ7G6UX.js} +2 -2
- package/dist/chunks/{rm-EF4HUVO2.js → rm-7KSHXSTB.js} +3 -3
- package/dist/chunks/{rm-AG3FDPTQ.js → rm-VHWBHG3A.js} +2 -2
- package/dist/chunks/{rule-inspect-FRDI2PJF.js → rule-inspect-AT6IEOUF.js} +3 -3
- package/dist/chunks/{rules-OEOYTZ6U.js → rules-SQFCUKWS.js} +6 -6
- package/dist/chunks/{schema-OEWP27BI.js → schema-PWSCMD24.js} +5 -5
- package/dist/chunks/{tags-RUHWH6XO.js → tags-BT7ZGJP2.js} +2 -2
- package/dist/chunks/{update-BEXGZY7H.js → update-PTDGBKEH.js} +3 -3
- package/dist/commands/build/index.js +9 -9
- package/dist/commands/deploy/index.js +9 -9
- package/dist/commands/dev/index.js +7 -7
- package/dist/commands/env/index.js +4 -4
- package/dist/commands/link/index.js +6 -6
- package/dist/commands/list/index.js +2 -2
- package/dist/commands-bulk.js +595 -71
- package/dist/index.js +7 -7
- package/dist/version.mjs +1 -1
- package/package.json +10 -10
- package/dist/chunks/chunk-A3NYPUKZ.js +0 -17
|
@@ -5,51 +5,19 @@ const require = __createRequire(import.meta.url);
|
|
|
5
5
|
const __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __dirname_(__filename);
|
|
7
7
|
import {
|
|
8
|
-
fetchMetricDetailOrExit,
|
|
9
|
-
formatErrorJson,
|
|
10
|
-
formatQueryJson,
|
|
11
|
-
getDefaultAggregation,
|
|
12
8
|
getResolvedOrderMetadata,
|
|
13
9
|
getRollupColumnName,
|
|
14
|
-
handleApiError
|
|
15
|
-
} from "./chunk-4Z5LC2CI.js";
|
|
16
|
-
import {
|
|
17
10
|
indent_default
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import {
|
|
20
|
-
resolveTimeRange,
|
|
21
|
-
validateAllProjectMutualExclusivity
|
|
22
|
-
} from "./chunk-BUZRVER7.js";
|
|
23
|
-
import {
|
|
24
|
-
validateJsonOutput
|
|
25
|
-
} from "./chunk-XPKWKPWA.js";
|
|
11
|
+
} from "./chunk-Z7NPYIZ6.js";
|
|
26
12
|
import {
|
|
27
|
-
|
|
28
|
-
} from "./chunk-
|
|
13
|
+
elapsed
|
|
14
|
+
} from "./chunk-VXYGCOKL.js";
|
|
29
15
|
import {
|
|
30
16
|
table
|
|
31
17
|
} from "./chunk-NZRWTCRM.js";
|
|
32
18
|
import {
|
|
33
|
-
|
|
34
|
-
getProjectByNameOrId,
|
|
35
|
-
getScope
|
|
36
|
-
} from "./chunk-RGOP4OYL.js";
|
|
37
|
-
import "./chunk-UDWRZXIT.js";
|
|
38
|
-
import "./chunk-ECCWJHC6.js";
|
|
39
|
-
import {
|
|
40
|
-
parseArguments,
|
|
41
|
-
printError
|
|
19
|
+
require_strip_ansi
|
|
42
20
|
} from "./chunk-SZXT3PDQ.js";
|
|
43
|
-
import {
|
|
44
|
-
ProjectNotFound,
|
|
45
|
-
getFlagsSpecification,
|
|
46
|
-
isAPIError
|
|
47
|
-
} from "./chunk-KSSNLCL4.js";
|
|
48
|
-
import "./chunk-P4QNYOFB.js";
|
|
49
|
-
import "./chunk-52QYYTM5.js";
|
|
50
|
-
import {
|
|
51
|
-
output_manager_default
|
|
52
|
-
} from "./chunk-OX7KI3LF.js";
|
|
53
21
|
import {
|
|
54
22
|
require_ms
|
|
55
23
|
} from "./chunk-GGP5R3FU.js";
|
|
@@ -60,52 +28,6 @@ import {
|
|
|
60
28
|
__toESM
|
|
61
29
|
} from "./chunk-TZ2YI2VH.js";
|
|
62
30
|
|
|
63
|
-
// src/commands/metrics/validation.ts
|
|
64
|
-
function validateMutualExclusivity(all, project) {
|
|
65
|
-
return validateAllProjectMutualExclusivity(all, project);
|
|
66
|
-
}
|
|
67
|
-
function validateRequiredMetric(metric) {
|
|
68
|
-
if (metric) {
|
|
69
|
-
return { valid: true, value: metric };
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
valid: false,
|
|
73
|
-
code: "MISSING_METRIC",
|
|
74
|
-
message: "Missing required metric. Specify the metric to query.\n\nRun 'vercel metrics schema' to see available metrics."
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function validateOrderDirection(orderDirection) {
|
|
78
|
-
if (orderDirection === void 0) {
|
|
79
|
-
return { valid: true, value: void 0 };
|
|
80
|
-
}
|
|
81
|
-
if (orderDirection === "asc" || orderDirection === "desc") {
|
|
82
|
-
return { valid: true, value: orderDirection };
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
valid: false,
|
|
86
|
-
code: "INVALID_ORDER",
|
|
87
|
-
message: `Invalid order "${orderDirection}". Use "asc" or "desc".`,
|
|
88
|
-
allowedValues: ["asc", "desc"]
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function validateOrderBy(orderBy) {
|
|
92
|
-
if (orderBy === void 0) {
|
|
93
|
-
return { valid: true, value: void 0 };
|
|
94
|
-
}
|
|
95
|
-
if (orderBy === "value" || orderBy === "count") {
|
|
96
|
-
return { valid: true, value: orderBy };
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
valid: false,
|
|
100
|
-
code: "INVALID_ORDER_BY",
|
|
101
|
-
message: `Invalid order-by "${orderBy}". Use "value" or "count".`,
|
|
102
|
-
allowedValues: ["value", "count"]
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// src/commands/metrics/text-output.ts
|
|
107
|
-
var import_chalk = __toESM(require_source(), 1);
|
|
108
|
-
|
|
109
31
|
// src/commands/metrics/time-utils.ts
|
|
110
32
|
var import_ms = __toESM(require_ms(), 1);
|
|
111
33
|
var MINUTE_MS = 60 * 1e3;
|
|
@@ -199,6 +121,8 @@ function toGranularityMsFromDuration(duration) {
|
|
|
199
121
|
}
|
|
200
122
|
|
|
201
123
|
// src/commands/metrics/text-output.ts
|
|
124
|
+
var import_chalk = __toESM(require_source(), 1);
|
|
125
|
+
var import_strip_ansi = __toESM(require_strip_ansi(), 1);
|
|
202
126
|
var GROUP_KEY_DELIMITER = "";
|
|
203
127
|
var MAX_SPARKLINE_LENGTH = 120;
|
|
204
128
|
var COUNT_UNITS = /* @__PURE__ */ new Set(["count", "usd", "us dollars", "dollars"]);
|
|
@@ -243,6 +167,15 @@ function formatPeriodBound(input) {
|
|
|
243
167
|
}
|
|
244
168
|
return formatHumanMinute(date);
|
|
245
169
|
}
|
|
170
|
+
function formatPeriodSpan(startInput, endInput) {
|
|
171
|
+
const start = Date.parse(startInput);
|
|
172
|
+
const end = Date.parse(endInput);
|
|
173
|
+
const durationMs = end - start;
|
|
174
|
+
if (!Number.isFinite(durationMs) || durationMs <= 0) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
return elapsed(durationMs);
|
|
178
|
+
}
|
|
246
179
|
function formatGranularity(granularity) {
|
|
247
180
|
if ("minutes" in granularity) {
|
|
248
181
|
return `${granularity.minutes}m`;
|
|
@@ -511,12 +444,13 @@ function computeGroupStats(points) {
|
|
|
511
444
|
};
|
|
512
445
|
}
|
|
513
446
|
var MAX_GROUP_VALUE_LENGTH = 60;
|
|
514
|
-
function ellipsizeMiddle(str, maxLength) {
|
|
515
|
-
|
|
447
|
+
function ellipsizeMiddle(str, maxLength, useVisibleLength = false) {
|
|
448
|
+
const comparable = useVisibleLength ? (0, import_strip_ansi.default)(str) : str;
|
|
449
|
+
if (comparable.length <= maxLength)
|
|
516
450
|
return str;
|
|
517
451
|
const endLength = Math.floor((maxLength - 1) / 2);
|
|
518
452
|
const startLength = maxLength - 1 - endLength;
|
|
519
|
-
return `${
|
|
453
|
+
return `${comparable.slice(0, startLength)}\u2026${comparable.slice(comparable.length - endLength)}`;
|
|
520
454
|
}
|
|
521
455
|
function downsample(values, maxLen) {
|
|
522
456
|
if (maxLen <= 0) {
|
|
@@ -570,17 +504,21 @@ function generateSparkline(values) {
|
|
|
570
504
|
}).join("");
|
|
571
505
|
}
|
|
572
506
|
function formatMetadataHeader(opts) {
|
|
573
|
-
const
|
|
574
|
-
|
|
507
|
+
const periodSpan = opts.compact ? formatPeriodSpan(opts.periodStart, opts.periodEnd) : null;
|
|
508
|
+
const rows = [];
|
|
509
|
+
if (!opts.compact) {
|
|
510
|
+
rows.push({
|
|
575
511
|
key: "Metric",
|
|
576
512
|
value: `${opts.metric} ${opts.aggregation}`
|
|
577
|
-
}
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
rows.push(
|
|
578
516
|
{
|
|
579
517
|
// Period bounds are always UTC; annotate them so the boundary is
|
|
580
518
|
// unambiguous when the Interval below reports a different
|
|
581
519
|
// --bucket-timezone.
|
|
582
520
|
key: "Period",
|
|
583
|
-
value: `${formatPeriodBound(opts.periodStart)} to ${formatPeriodBound(opts.periodEnd)} (UTC)`
|
|
521
|
+
value: `${formatPeriodBound(opts.periodStart)} to ${formatPeriodBound(opts.periodEnd)} (UTC)${periodSpan ? ` ${periodSpan}` : ""}`
|
|
584
522
|
},
|
|
585
523
|
{
|
|
586
524
|
// Period bounds are always UTC; the timezone only controls calendar
|
|
@@ -590,17 +528,17 @@ function formatMetadataHeader(opts) {
|
|
|
590
528
|
key: "Interval",
|
|
591
529
|
value: "days" in opts.granularity ? `${formatGranularity(opts.granularity)} (${opts.bucketTimezone ?? "UTC"})` : formatGranularity(opts.granularity)
|
|
592
530
|
}
|
|
593
|
-
|
|
531
|
+
);
|
|
594
532
|
if (typeof opts.periodUnique === "number") {
|
|
595
533
|
rows.push({
|
|
596
534
|
key: "Unique (period)",
|
|
597
535
|
value: formatCount(opts.periodUnique)
|
|
598
536
|
});
|
|
599
537
|
}
|
|
600
|
-
if (opts.filter) {
|
|
538
|
+
if (!opts.compact && opts.filter) {
|
|
601
539
|
rows.push({ key: "Filter", value: opts.filter });
|
|
602
540
|
}
|
|
603
|
-
if (opts.orderBy && opts.orderDirection) {
|
|
541
|
+
if (!opts.compact && opts.orderBy && opts.orderDirection) {
|
|
604
542
|
rows.push({
|
|
605
543
|
key: "Order By",
|
|
606
544
|
value: `${opts.orderBy} ${opts.orderDirection}${opts.orderBy === "count" ? " (default)" : ""}`
|
|
@@ -620,7 +558,7 @@ function formatMetadataHeader(opts) {
|
|
|
620
558
|
if (opts.unit && normalizeUnit(opts.unit) !== "count") {
|
|
621
559
|
rows.push({ key: "Units", value: formatUnitLabel(opts.unit) });
|
|
622
560
|
}
|
|
623
|
-
if (typeof opts.groupCount === "number") {
|
|
561
|
+
if (!opts.compact && typeof opts.groupCount === "number") {
|
|
624
562
|
rows.push({ key: "Groups", value: String(opts.groupCount) });
|
|
625
563
|
}
|
|
626
564
|
return rows.map((row) => `> ${import_chalk.default.gray(`${row.key}:`)} ${row.value}`).join("\n");
|
|
@@ -631,7 +569,7 @@ function formatSummaryTable(opts) {
|
|
|
631
569
|
const rows = [header.map((name) => import_chalk.default.bold(import_chalk.default.cyan(name)))];
|
|
632
570
|
for (const row of opts.rows) {
|
|
633
571
|
const nextRow = row.groupValues.map(
|
|
634
|
-
(v) => ellipsizeMiddle(v, MAX_GROUP_VALUE_LENGTH)
|
|
572
|
+
(v) => ellipsizeMiddle(v, MAX_GROUP_VALUE_LENGTH, opts.ansiAwareGroupValues)
|
|
635
573
|
);
|
|
636
574
|
if (row.stats.allMissing) {
|
|
637
575
|
nextRow.push(...statColumns.map(() => "--"));
|
|
@@ -664,38 +602,33 @@ function formatSummaryTable(opts) {
|
|
|
664
602
|
2
|
|
665
603
|
);
|
|
666
604
|
}
|
|
667
|
-
function formatSparklineSection(groupRows, sparklines, groupByFields) {
|
|
668
|
-
const lines = ["sparklines:"];
|
|
605
|
+
function formatSparklineSection(groupRows, sparklines, groupByFields, compact = false) {
|
|
669
606
|
if (groupRows.length === 0) {
|
|
670
607
|
const sparkline = sparklines[0];
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
}
|
|
674
|
-
return lines.join("\n");
|
|
608
|
+
const chart2 = sparkline ? indent_default(sparkline, 2) : "";
|
|
609
|
+
return compact ? chart2 : ["sparklines:", chart2].filter(Boolean).join("\n");
|
|
675
610
|
}
|
|
676
|
-
const
|
|
677
|
-
groupValues,
|
|
678
|
-
sparkline: sparklines[index] ?? ""
|
|
679
|
-
}));
|
|
611
|
+
const header = [...groupByFields, compact ? "" : "sparkline"];
|
|
680
612
|
const rows = [
|
|
681
|
-
|
|
682
|
-
...
|
|
683
|
-
...groupValues.map(
|
|
684
|
-
|
|
613
|
+
header.map((name) => import_chalk.default.bold(import_chalk.default.cyan(name))),
|
|
614
|
+
...groupRows.map((groupValues, index) => [
|
|
615
|
+
...groupValues.map(
|
|
616
|
+
(v) => ellipsizeMiddle(v, MAX_GROUP_VALUE_LENGTH, compact)
|
|
617
|
+
),
|
|
618
|
+
sparklines[index] ?? ""
|
|
685
619
|
])
|
|
686
620
|
];
|
|
687
621
|
const align = groupByFields.map(() => "r");
|
|
688
622
|
align.push("l");
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
2
|
|
696
|
-
)
|
|
623
|
+
const chart = indent_default(
|
|
624
|
+
table(rows, {
|
|
625
|
+
align,
|
|
626
|
+
hsep: 2
|
|
627
|
+
}),
|
|
628
|
+
2
|
|
697
629
|
);
|
|
698
|
-
return
|
|
630
|
+
return compact ? chart : `sparklines:
|
|
631
|
+
${chart}`;
|
|
699
632
|
}
|
|
700
633
|
function getEffectiveDisplay(baseUnit, aggregation) {
|
|
701
634
|
if (isAggregationWithDimension(aggregation)) {
|
|
@@ -755,7 +688,8 @@ function formatText(response, opts) {
|
|
|
755
688
|
projectName: opts.projectName,
|
|
756
689
|
teamName: opts.teamName,
|
|
757
690
|
unit: displayUnit,
|
|
758
|
-
groupCount: opts.groupBy.length > 0 ? groups.length : void 0
|
|
691
|
+
groupCount: opts.groupBy.length > 0 ? groups.length : void 0,
|
|
692
|
+
compact: opts.presentation?.compact
|
|
759
693
|
});
|
|
760
694
|
if (groups.length === 0) {
|
|
761
695
|
return `${metadata}
|
|
@@ -770,11 +704,15 @@ No data found for this period.
|
|
|
770
704
|
const points = series.get(key) ?? [];
|
|
771
705
|
const values = points.map((point) => point.value);
|
|
772
706
|
const currentGroupValues = groupValues.get(key) ?? [];
|
|
707
|
+
const displayGroupValues = currentGroupValues.map((value, index) => {
|
|
708
|
+
const field = opts.groupBy[index];
|
|
709
|
+
return opts.presentation?.formatGroupValue?.(field, value) ?? value;
|
|
710
|
+
});
|
|
773
711
|
summaryRows.push({
|
|
774
|
-
groupValues:
|
|
712
|
+
groupValues: displayGroupValues,
|
|
775
713
|
stats: computeGroupStats(points)
|
|
776
714
|
});
|
|
777
|
-
groupRows.push(
|
|
715
|
+
groupRows.push(displayGroupValues);
|
|
778
716
|
sparklineRows.push(generateSparkline(values));
|
|
779
717
|
}
|
|
780
718
|
const summaryTable = formatSummaryTable({
|
|
@@ -783,307 +721,23 @@ No data found for this period.
|
|
|
783
721
|
measureType,
|
|
784
722
|
aggregation: opts.aggregation,
|
|
785
723
|
periodStart: new Date(opts.periodStart),
|
|
786
|
-
periodEnd: new Date(opts.periodEnd)
|
|
724
|
+
periodEnd: new Date(opts.periodEnd),
|
|
725
|
+
ansiAwareGroupValues: opts.presentation?.compact
|
|
787
726
|
});
|
|
788
727
|
const groupedOutput = opts.groupBy.length > 0;
|
|
789
728
|
const sparklineSection = formatSparklineSection(
|
|
790
729
|
groupedOutput ? groupRows : [],
|
|
791
730
|
sparklineRows,
|
|
792
|
-
opts.groupBy
|
|
731
|
+
opts.groupBy,
|
|
732
|
+
opts.presentation?.compact
|
|
793
733
|
);
|
|
794
734
|
const sections = [metadata, summaryTable, sparklineSection];
|
|
795
735
|
return `${sections.join("\n\n")}
|
|
796
736
|
`;
|
|
797
737
|
}
|
|
798
738
|
|
|
799
|
-
// src/commands/metrics/query.ts
|
|
800
|
-
function handleValidationError(result, jsonOutput, client) {
|
|
801
|
-
if (jsonOutput) {
|
|
802
|
-
client.stdout.write(
|
|
803
|
-
formatErrorJson(result.code, result.message, result.allowedValues)
|
|
804
|
-
);
|
|
805
|
-
} else {
|
|
806
|
-
output_manager_default.error(result.message);
|
|
807
|
-
if (result.allowedValues && result.allowedValues.length > 0) {
|
|
808
|
-
output_manager_default.print(`
|
|
809
|
-
Available values: ${result.allowedValues.join(", ")}
|
|
810
|
-
`);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
return 1;
|
|
814
|
-
}
|
|
815
|
-
var PRODUCTION_ENVIRONMENT_FILTER = "environment eq 'production'";
|
|
816
|
-
function combineFilters(filters, prod) {
|
|
817
|
-
const nonEmptyFilters = [
|
|
818
|
-
...filters?.filter((filter) => filter.length > 0) ?? [],
|
|
819
|
-
...prod ? [PRODUCTION_ENVIRONMENT_FILTER] : []
|
|
820
|
-
];
|
|
821
|
-
if (nonEmptyFilters.length === 0) {
|
|
822
|
-
return void 0;
|
|
823
|
-
}
|
|
824
|
-
if (nonEmptyFilters.length === 1) {
|
|
825
|
-
return nonEmptyFilters[0];
|
|
826
|
-
}
|
|
827
|
-
return nonEmptyFilters.map((filter) => `(${filter})`).join(" and ");
|
|
828
|
-
}
|
|
829
|
-
function getRequestOrderBy(metric, aggregation, orderBy) {
|
|
830
|
-
return orderBy === "value" ? getRollupColumnName(metric, aggregation) : void 0;
|
|
831
|
-
}
|
|
832
|
-
async function resolveQueryScope(client, opts) {
|
|
833
|
-
if (opts.project || opts.all) {
|
|
834
|
-
const { team } = await getScope(client);
|
|
835
|
-
if (!team) {
|
|
836
|
-
const errMsg = "No team context found. Run `vercel switch` to select a team, or use `vercel link` in a project directory.";
|
|
837
|
-
if (opts.jsonOutput) {
|
|
838
|
-
client.stdout.write(formatErrorJson("NO_TEAM", errMsg));
|
|
839
|
-
} else {
|
|
840
|
-
output_manager_default.error(errMsg);
|
|
841
|
-
}
|
|
842
|
-
return 1;
|
|
843
|
-
}
|
|
844
|
-
if (opts.all) {
|
|
845
|
-
return {
|
|
846
|
-
scope: { type: "owner", ownerId: team.id },
|
|
847
|
-
accountId: team.id,
|
|
848
|
-
teamName: team.slug
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
const project = await getProjectByNameOrId(client, opts.project, team.id);
|
|
852
|
-
if (project instanceof ProjectNotFound) {
|
|
853
|
-
const errMsg = `Project "${opts.project}" was not found in team "${team.slug}".`;
|
|
854
|
-
if (opts.jsonOutput) {
|
|
855
|
-
client.stdout.write(formatErrorJson("PROJECT_NOT_FOUND", errMsg));
|
|
856
|
-
} else {
|
|
857
|
-
output_manager_default.error(errMsg);
|
|
858
|
-
}
|
|
859
|
-
return 1;
|
|
860
|
-
}
|
|
861
|
-
return {
|
|
862
|
-
scope: {
|
|
863
|
-
type: "project",
|
|
864
|
-
ownerId: team.id,
|
|
865
|
-
projectIds: [project.id]
|
|
866
|
-
},
|
|
867
|
-
accountId: team.id,
|
|
868
|
-
teamName: team.slug,
|
|
869
|
-
projectName: project.name
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
const linkedProject = await getLinkedProject(client);
|
|
873
|
-
if (linkedProject.status === "error") {
|
|
874
|
-
return linkedProject.exitCode;
|
|
875
|
-
}
|
|
876
|
-
if (linkedProject.status === "not_linked") {
|
|
877
|
-
const errMsg = "No linked project found. Run `vercel link` to link a project, or use --project <name-or-id> or --all.";
|
|
878
|
-
if (opts.jsonOutput) {
|
|
879
|
-
client.stdout.write(formatErrorJson("NOT_LINKED", errMsg));
|
|
880
|
-
} else {
|
|
881
|
-
output_manager_default.error(errMsg);
|
|
882
|
-
}
|
|
883
|
-
return 1;
|
|
884
|
-
}
|
|
885
|
-
return {
|
|
886
|
-
scope: {
|
|
887
|
-
type: "project",
|
|
888
|
-
ownerId: linkedProject.org.id,
|
|
889
|
-
projectIds: [linkedProject.project.id]
|
|
890
|
-
},
|
|
891
|
-
accountId: linkedProject.org.id,
|
|
892
|
-
teamName: linkedProject.org.slug,
|
|
893
|
-
projectName: linkedProject.project.name
|
|
894
|
-
};
|
|
895
|
-
}
|
|
896
|
-
async function query(client, telemetry) {
|
|
897
|
-
let parsedArgs;
|
|
898
|
-
const flagsSpecification = getFlagsSpecification(metricsCommand.options);
|
|
899
|
-
try {
|
|
900
|
-
parsedArgs = parseArguments(client.argv.slice(2), flagsSpecification);
|
|
901
|
-
} catch (err) {
|
|
902
|
-
printError(err);
|
|
903
|
-
return 1;
|
|
904
|
-
}
|
|
905
|
-
const flags = parsedArgs.flags;
|
|
906
|
-
const positionalArgs = parsedArgs.args.slice(1);
|
|
907
|
-
const positionalMetric = positionalArgs[0] === "query" ? positionalArgs[1] : positionalArgs[0];
|
|
908
|
-
const formatResult = validateJsonOutput(flags);
|
|
909
|
-
if (!formatResult.valid) {
|
|
910
|
-
output_manager_default.error(formatResult.error);
|
|
911
|
-
return 1;
|
|
912
|
-
}
|
|
913
|
-
const jsonOutput = formatResult.jsonOutput;
|
|
914
|
-
const metricFlag = positionalMetric;
|
|
915
|
-
const aggregationFlag = flags["--aggregation"];
|
|
916
|
-
const groupBy = flags["--group-by"] ?? [];
|
|
917
|
-
const limit = flags["--limit"];
|
|
918
|
-
const orderByInput = typeof flags["--order-by"] === "string" ? flags["--order-by"].trim().toLowerCase() : void 0;
|
|
919
|
-
const orderInput = typeof flags["--order"] === "string" ? flags["--order"].trim().toLowerCase() : void 0;
|
|
920
|
-
const filters = flags["--filter"];
|
|
921
|
-
const prod = flags["--prod"];
|
|
922
|
-
const filter = combineFilters(filters, prod);
|
|
923
|
-
const since = flags["--since"];
|
|
924
|
-
const until = flags["--until"];
|
|
925
|
-
const granularity = flags["--granularity"];
|
|
926
|
-
const bucketTimezone = flags["--bucket-timezone"]?.trim();
|
|
927
|
-
const project = flags["--project"];
|
|
928
|
-
const all = flags["--all"];
|
|
929
|
-
telemetry.trackCliArgumentMetricId(metricFlag);
|
|
930
|
-
telemetry.trackCliOptionAggregation(aggregationFlag);
|
|
931
|
-
telemetry.trackCliOptionGroupBy(groupBy.length > 0 ? groupBy : void 0);
|
|
932
|
-
telemetry.trackCliOptionLimit(limit);
|
|
933
|
-
telemetry.trackCliOptionOrderBy(orderByInput);
|
|
934
|
-
telemetry.trackCliOptionOrder(orderInput);
|
|
935
|
-
telemetry.trackCliOptionFilter(filters);
|
|
936
|
-
telemetry.trackCliFlagProd(prod);
|
|
937
|
-
telemetry.trackCliOptionSince(since);
|
|
938
|
-
telemetry.trackCliOptionUntil(until);
|
|
939
|
-
telemetry.trackCliOptionGranularity(granularity);
|
|
940
|
-
telemetry.trackCliOptionBucketTimezone(bucketTimezone);
|
|
941
|
-
telemetry.trackCliOptionProject(project);
|
|
942
|
-
telemetry.trackCliFlagAll(all);
|
|
943
|
-
telemetry.trackCliOptionFormat(flags["--format"]);
|
|
944
|
-
const orderByResult = validateOrderBy(orderByInput);
|
|
945
|
-
if (!orderByResult.valid) {
|
|
946
|
-
return handleValidationError(orderByResult, jsonOutput, client);
|
|
947
|
-
}
|
|
948
|
-
const orderByMode = orderByResult.value;
|
|
949
|
-
const requiredMetric = validateRequiredMetric(metricFlag);
|
|
950
|
-
if (!requiredMetric.valid) {
|
|
951
|
-
return handleValidationError(requiredMetric, jsonOutput, client);
|
|
952
|
-
}
|
|
953
|
-
const metric = requiredMetric.value;
|
|
954
|
-
const mutualResult = validateMutualExclusivity(all, project);
|
|
955
|
-
if (!mutualResult.valid) {
|
|
956
|
-
return handleValidationError(mutualResult, jsonOutput, client);
|
|
957
|
-
}
|
|
958
|
-
const orderDirectionResult = validateOrderDirection(orderInput);
|
|
959
|
-
if (!orderDirectionResult.valid) {
|
|
960
|
-
return handleValidationError(orderDirectionResult, jsonOutput, client);
|
|
961
|
-
}
|
|
962
|
-
const orderDirection = orderDirectionResult.value;
|
|
963
|
-
const scopeResult = await resolveQueryScope(client, {
|
|
964
|
-
project,
|
|
965
|
-
all,
|
|
966
|
-
jsonOutput
|
|
967
|
-
});
|
|
968
|
-
if (typeof scopeResult === "number") {
|
|
969
|
-
return scopeResult;
|
|
970
|
-
}
|
|
971
|
-
const { scope, accountId, teamName, projectName } = scopeResult;
|
|
972
|
-
const detailOrExitCode = await fetchMetricDetailOrExit(
|
|
973
|
-
client,
|
|
974
|
-
accountId,
|
|
975
|
-
metric,
|
|
976
|
-
jsonOutput
|
|
977
|
-
);
|
|
978
|
-
if (typeof detailOrExitCode === "number") {
|
|
979
|
-
return detailOrExitCode;
|
|
980
|
-
}
|
|
981
|
-
const aggregationInput = aggregationFlag ?? getDefaultAggregation(detailOrExitCode, metric) ?? "sum";
|
|
982
|
-
const aggregation = aggregationInput;
|
|
983
|
-
const orderBy = getRequestOrderBy(metric, aggregation, orderByMode);
|
|
984
|
-
let startTime;
|
|
985
|
-
let endTime;
|
|
986
|
-
try {
|
|
987
|
-
({ startTime, endTime } = resolveTimeRange(since, until));
|
|
988
|
-
} catch (err) {
|
|
989
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
990
|
-
if (jsonOutput) {
|
|
991
|
-
client.stdout.write(formatErrorJson("INVALID_TIME", errMsg));
|
|
992
|
-
} else {
|
|
993
|
-
output_manager_default.error(errMsg);
|
|
994
|
-
}
|
|
995
|
-
return 1;
|
|
996
|
-
}
|
|
997
|
-
const rangeMs = endTime.getTime() - startTime.getTime();
|
|
998
|
-
const granResult = computeGranularity(rangeMs, granularity);
|
|
999
|
-
if (!jsonOutput && granResult.adjusted && granResult.notice) {
|
|
1000
|
-
output_manager_default.log(`Notice: ${granResult.notice}`);
|
|
1001
|
-
}
|
|
1002
|
-
const body = {
|
|
1003
|
-
scope,
|
|
1004
|
-
metric,
|
|
1005
|
-
aggregation,
|
|
1006
|
-
startTime: startTime.toISOString(),
|
|
1007
|
-
endTime: endTime.toISOString(),
|
|
1008
|
-
granularity: granResult.duration,
|
|
1009
|
-
...bucketTimezone ? { bucketTimezone } : {},
|
|
1010
|
-
...groupBy.length > 0 ? { groupBy } : {},
|
|
1011
|
-
...filter ? { filter } : {},
|
|
1012
|
-
limit: limit ?? 10,
|
|
1013
|
-
...orderBy ? { orderBy } : {},
|
|
1014
|
-
...orderDirection ? { orderDirection } : {}
|
|
1015
|
-
};
|
|
1016
|
-
if (!jsonOutput) {
|
|
1017
|
-
output_manager_default.spinner("Querying metrics...");
|
|
1018
|
-
}
|
|
1019
|
-
let response;
|
|
1020
|
-
try {
|
|
1021
|
-
response = await client.fetch(
|
|
1022
|
-
"/v2/observability/query",
|
|
1023
|
-
{
|
|
1024
|
-
method: "POST",
|
|
1025
|
-
body: JSON.stringify(body),
|
|
1026
|
-
headers: { "Content-Type": "application/json" },
|
|
1027
|
-
accountId,
|
|
1028
|
-
bailOn429: true
|
|
1029
|
-
}
|
|
1030
|
-
);
|
|
1031
|
-
} catch (err) {
|
|
1032
|
-
if (isAPIError(err)) {
|
|
1033
|
-
return handleApiError(err, jsonOutput, client);
|
|
1034
|
-
}
|
|
1035
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
1036
|
-
if (jsonOutput) {
|
|
1037
|
-
client.stdout.write(formatErrorJson("NETWORK_ERROR", errMsg));
|
|
1038
|
-
} else {
|
|
1039
|
-
output_manager_default.error(errMsg);
|
|
1040
|
-
}
|
|
1041
|
-
return 1;
|
|
1042
|
-
} finally {
|
|
1043
|
-
if (!jsonOutput) {
|
|
1044
|
-
output_manager_default.stopSpinner();
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
if (jsonOutput) {
|
|
1048
|
-
client.stdout.write(
|
|
1049
|
-
formatQueryJson(
|
|
1050
|
-
{
|
|
1051
|
-
metric,
|
|
1052
|
-
aggregation,
|
|
1053
|
-
groupBy,
|
|
1054
|
-
filter,
|
|
1055
|
-
startTime: startTime.toISOString(),
|
|
1056
|
-
endTime: endTime.toISOString(),
|
|
1057
|
-
granularity: granResult.duration,
|
|
1058
|
-
...bucketTimezone ? { bucketTimezone } : {},
|
|
1059
|
-
...orderByMode ? { orderBy: orderByMode } : {},
|
|
1060
|
-
...orderDirection ? { orderDirection } : {}
|
|
1061
|
-
},
|
|
1062
|
-
response
|
|
1063
|
-
)
|
|
1064
|
-
);
|
|
1065
|
-
} else {
|
|
1066
|
-
client.stdout.write(
|
|
1067
|
-
formatText(response, {
|
|
1068
|
-
metric,
|
|
1069
|
-
metricUnit: detailOrExitCode.find((item) => item.id === metric)?.unit ?? "count",
|
|
1070
|
-
aggregation,
|
|
1071
|
-
groupBy,
|
|
1072
|
-
filter,
|
|
1073
|
-
scope,
|
|
1074
|
-
projectName,
|
|
1075
|
-
teamName,
|
|
1076
|
-
periodStart: startTime.toISOString(),
|
|
1077
|
-
periodEnd: endTime.toISOString(),
|
|
1078
|
-
granularity: granResult.duration,
|
|
1079
|
-
bucketTimezone,
|
|
1080
|
-
orderBy: orderByMode,
|
|
1081
|
-
orderDirection
|
|
1082
|
-
})
|
|
1083
|
-
);
|
|
1084
|
-
}
|
|
1085
|
-
return 0;
|
|
1086
|
-
}
|
|
1087
739
|
export {
|
|
1088
|
-
|
|
740
|
+
computeGranularity,
|
|
741
|
+
toGranularityMsFromDuration,
|
|
742
|
+
formatText
|
|
1089
743
|
};
|
|
@@ -6,7 +6,7 @@ const __filename = __fileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = __dirname_(__filename);
|
|
7
7
|
import {
|
|
8
8
|
writeProjectSettings
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JIK3GTU3.js";
|
|
10
10
|
import {
|
|
11
11
|
autoInstallVercelPlugin
|
|
12
12
|
} from "./chunk-NJUPUGOE.js";
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
} from "./chunk-64IF634X.js";
|
|
16
16
|
import {
|
|
17
17
|
ensureLink
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4QRRJEYO.js";
|
|
19
19
|
import {
|
|
20
20
|
pullCommand
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-EJNFC5AV.js";
|
|
22
22
|
import {
|
|
23
23
|
help
|
|
24
24
|
} from "./chunk-DMSLNAVH.js";
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
envPullCommandLogic,
|
|
29
29
|
humanizePath,
|
|
30
30
|
parseTarget
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-QX4337BT.js";
|
|
32
32
|
import {
|
|
33
33
|
TelemetryClient
|
|
34
34
|
} from "./chunk-ECCWJHC6.js";
|