vercel 56.3.2 → 56.4.1
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-2ITAPI7M.js → add-L3Z6PL54.js} +3 -3
- package/dist/chunks/{add-DVEAUH7N.js → add-RFEJCIBM.js} +2 -2
- package/dist/chunks/{chunk-BFFE4FAO.js → chunk-43B3LNUF.js} +1 -1
- package/dist/chunks/{chunk-FPMWXL3R.js → chunk-4M3ZQCYN.js} +63 -6
- package/dist/chunks/{chunk-TVLLFY7M.js → chunk-5EXIJBLL.js} +5 -5
- package/dist/chunks/{chunk-4Z5LC2CI.js → chunk-6RTK6BWX.js} +4 -96
- package/dist/chunks/{chunk-AVJRWFTM.js → chunk-A4XB42AB.js} +1 -1
- package/dist/chunks/{chunk-3OZQ7KHZ.js → chunk-CHZBEMLF.js} +2 -2
- package/dist/chunks/{chunk-O3UHQI3T.js → chunk-DXFSBJTA.js} +1 -1
- package/dist/chunks/{chunk-QW4XUBC3.js → chunk-F32B76CK.js} +1 -1
- package/dist/chunks/{query-K2TJKOAL.js → chunk-F5OMERHI.js} +65 -411
- package/dist/chunks/{chunk-5POUHPEH.js → chunk-GKVAAY2A.js} +1 -1
- package/dist/chunks/{chunk-HZAINEXG.js → chunk-GLAHGVBS.js} +6 -2
- package/dist/chunks/{chunk-573XYQ3D.js → chunk-HZKJMZEQ.js} +2 -2
- package/dist/chunks/{chunk-2CEGMXO6.js → chunk-IHQ7DPQI.js} +76 -2
- package/dist/chunks/{chunk-JQBH4QTB.js → chunk-J6KTUJHV.js} +1 -1
- package/dist/chunks/{chunk-WQN52QMS.js → chunk-MQRHJEBS.js} +2 -2
- package/dist/chunks/{chunk-GB3QQGZU.js → chunk-NLRIKNPX.js} +1 -1
- package/dist/chunks/{chunk-ZKKJEOQT.js → chunk-OOD67FAL.js} +1 -1
- package/dist/chunks/{chunk-5FF4WXVM.js → chunk-UHGAPG7O.js} +4 -4
- package/dist/chunks/{chunk-BZXHF66T.js → chunk-VLTQJKP6.js} +1 -1
- package/dist/chunks/{chunk-OK6EYKRX.js → chunk-XFGY3JAX.js} +1 -1
- package/dist/chunks/{chunk-SRIA62TV.js → chunk-Y7TVKRRJ.js} +3 -3
- package/dist/chunks/chunk-Z7NPYIZ6.js +116 -0
- package/dist/chunks/{compile-vercel-config-P3KRRAC6.js → compile-vercel-config-J2X5OV6K.js} +1 -1
- package/dist/chunks/{delete-OXEMVOQE.js → delete-57A44RN7.js} +2 -2
- package/dist/chunks/{disable-DZA53CJA.js → disable-DNZ52MEO.js} +2 -2
- package/dist/chunks/{discard-3E7Z7CKD.js → discard-HACSIZ74.js} +2 -2
- package/dist/chunks/{edit-UM6TWX2Z.js → edit-HJ47TQU3.js} +3 -3
- package/dist/chunks/{enable-3SH6X23Z.js → enable-BVLRVRYM.js} +2 -2
- package/dist/chunks/{export-TLQERLQP.js → export-7MJFGMG7.js} +2 -2
- package/dist/chunks/{image-YKGEEC2A.js → image-4UMD7UZP.js} +3 -3
- package/dist/chunks/{inspect-652QJ33O.js → inspect-4JD2QN67.js} +2 -2
- package/dist/chunks/{inspect-S6X6PCGS.js → inspect-5YZP7IWI.js} +2 -2
- package/dist/chunks/{inspect-34OE66PO.js → inspect-WBHUZC3R.js} +2 -2
- package/dist/chunks/{inspect-QW6RSV7Z.js → inspect-XX3OXSHC.js} +2 -2
- package/dist/chunks/{list-OVWTXBSN.js → list-5H57NTM4.js} +1 -1
- package/dist/chunks/{list-IWXFZBH7.js → list-AM6K2JCW.js} +2 -2
- package/dist/chunks/{login-S77F2DLW.js → login-YO34E4V5.js} +2 -2
- package/dist/chunks/{ls-SAY4VQIT.js → ls-44NPIO2N.js} +2 -2
- package/dist/chunks/{ls-J4HHGSFU.js → ls-MB74DIQV.js} +3 -3
- package/dist/chunks/{ls-FQIWFI4K.js → ls-P7ZLBWW2.js} +2 -2
- package/dist/chunks/{ls-PQPRURTJ.js → ls-YDUYTLXW.js} +2 -2
- package/dist/chunks/{publish-LWCEDLGX.js → publish-RXFUYSW3.js} +2 -2
- package/dist/chunks/query-ILJJL3BZ.js +391 -0
- package/dist/chunks/{reorder-J6OONT76.js → reorder-GBCOPZT4.js} +2 -2
- package/dist/chunks/{restore-3ME4ZHFW.js → restore-YK5DGGRX.js} +2 -2
- package/dist/chunks/{rm-XOUHC6CU.js → rm-FRZMXB2W.js} +3 -3
- package/dist/chunks/{rm-63AGQFIQ.js → rm-LK6P7XTA.js} +2 -2
- package/dist/chunks/{rm-EHEJRXQJ.js → rm-O474MI5C.js} +2 -2
- package/dist/chunks/{rule-inspect-3PRCEXIB.js → rule-inspect-YEZGYINZ.js} +3 -3
- package/dist/chunks/{rules-UBSIW5ZQ.js → rules-MZ2MP6KJ.js} +6 -6
- package/dist/chunks/{schema-I4SXEWLS.js → schema-FR6CCQIZ.js} +5 -5
- package/dist/chunks/{tags-HF2YOQ4V.js → tags-AKRTKFRV.js} +2 -2
- package/dist/chunks/{update-RRMAOQDP.js → update-W3CWQB2F.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 +411 -48
- package/dist/index.js +7 -7
- package/dist/vc.js +6 -1
- package/dist/version.mjs +1 -1
- package/package.json +86 -6
- package/dist/chunks/chunk-A3NYPUKZ.js +0 -17
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
handleVcrApiError,
|
|
16
16
|
resolveVcrScope,
|
|
17
17
|
validateVcrJsonOutput
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-NLRIKNPX.js";
|
|
19
19
|
import {
|
|
20
20
|
outputError,
|
|
21
21
|
validateOptionalIntegerRange
|
|
@@ -29,7 +29,7 @@ import "./chunk-FYQPTH5C.js";
|
|
|
29
29
|
import {
|
|
30
30
|
table
|
|
31
31
|
} from "./chunk-NZRWTCRM.js";
|
|
32
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-GLAHGVBS.js";
|
|
33
33
|
import {
|
|
34
34
|
AGENT_REASON,
|
|
35
35
|
outputAgentError
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
resolveVcrScope,
|
|
20
20
|
validateVcrChoice,
|
|
21
21
|
validateVcrJsonOutput
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-NLRIKNPX.js";
|
|
23
23
|
import {
|
|
24
24
|
outputError,
|
|
25
25
|
validateOptionalIntegerRange
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
import {
|
|
34
34
|
table
|
|
35
35
|
} from "./chunk-NZRWTCRM.js";
|
|
36
|
-
import "./chunk-
|
|
36
|
+
import "./chunk-GLAHGVBS.js";
|
|
37
37
|
import {
|
|
38
38
|
AGENT_REASON,
|
|
39
39
|
outputAgentError
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
printDiffSummary,
|
|
18
18
|
requireProjectContext,
|
|
19
19
|
withGlobalFlags
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-GKVAAY2A.js";
|
|
21
21
|
import {
|
|
22
22
|
publishSubcommand
|
|
23
23
|
} from "./chunk-VZSZBD4V.js";
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
stamp_default
|
|
26
26
|
} from "./chunk-64IF634X.js";
|
|
27
27
|
import "./chunk-VXYGCOKL.js";
|
|
28
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-GLAHGVBS.js";
|
|
29
29
|
import {
|
|
30
30
|
outputAgentError
|
|
31
31
|
} from "./chunk-UDWRZXIT.js";
|
|
@@ -0,0 +1,391 @@
|
|
|
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
|
+
fetchMetricDetailOrExit,
|
|
9
|
+
getDefaultAggregation
|
|
10
|
+
} from "./chunk-6RTK6BWX.js";
|
|
11
|
+
import {
|
|
12
|
+
computeGranularity,
|
|
13
|
+
formatText
|
|
14
|
+
} from "./chunk-F5OMERHI.js";
|
|
15
|
+
import {
|
|
16
|
+
formatErrorJson,
|
|
17
|
+
formatQueryJson,
|
|
18
|
+
getRollupColumnName,
|
|
19
|
+
handleApiError
|
|
20
|
+
} from "./chunk-Z7NPYIZ6.js";
|
|
21
|
+
import {
|
|
22
|
+
resolveTimeRange,
|
|
23
|
+
validateAllProjectMutualExclusivity
|
|
24
|
+
} from "./chunk-BUZRVER7.js";
|
|
25
|
+
import {
|
|
26
|
+
validateJsonOutput
|
|
27
|
+
} from "./chunk-XPKWKPWA.js";
|
|
28
|
+
import {
|
|
29
|
+
metricsCommand
|
|
30
|
+
} from "./chunk-4G6QZSBL.js";
|
|
31
|
+
import "./chunk-VXYGCOKL.js";
|
|
32
|
+
import "./chunk-NZRWTCRM.js";
|
|
33
|
+
import {
|
|
34
|
+
getLinkedProject,
|
|
35
|
+
getProjectByNameOrId,
|
|
36
|
+
getScope
|
|
37
|
+
} from "./chunk-GLAHGVBS.js";
|
|
38
|
+
import "./chunk-UDWRZXIT.js";
|
|
39
|
+
import "./chunk-ECCWJHC6.js";
|
|
40
|
+
import {
|
|
41
|
+
parseArguments,
|
|
42
|
+
printError
|
|
43
|
+
} from "./chunk-SZXT3PDQ.js";
|
|
44
|
+
import {
|
|
45
|
+
ProjectNotFound,
|
|
46
|
+
getFlagsSpecification,
|
|
47
|
+
isAPIError
|
|
48
|
+
} from "./chunk-KSSNLCL4.js";
|
|
49
|
+
import "./chunk-P4QNYOFB.js";
|
|
50
|
+
import "./chunk-52QYYTM5.js";
|
|
51
|
+
import {
|
|
52
|
+
output_manager_default
|
|
53
|
+
} from "./chunk-OX7KI3LF.js";
|
|
54
|
+
import "./chunk-GGP5R3FU.js";
|
|
55
|
+
import "./chunk-S7KYDPEM.js";
|
|
56
|
+
import "./chunk-TZ2YI2VH.js";
|
|
57
|
+
|
|
58
|
+
// src/commands/metrics/validation.ts
|
|
59
|
+
function validateMutualExclusivity(all, project) {
|
|
60
|
+
return validateAllProjectMutualExclusivity(all, project);
|
|
61
|
+
}
|
|
62
|
+
function validateRequiredMetric(metric) {
|
|
63
|
+
if (metric) {
|
|
64
|
+
return { valid: true, value: metric };
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
valid: false,
|
|
68
|
+
code: "MISSING_METRIC",
|
|
69
|
+
message: "Missing required metric. Specify the metric to query.\n\nRun 'vercel metrics schema' to see available metrics."
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function validateOrderDirection(orderDirection) {
|
|
73
|
+
if (orderDirection === void 0) {
|
|
74
|
+
return { valid: true, value: void 0 };
|
|
75
|
+
}
|
|
76
|
+
if (orderDirection === "asc" || orderDirection === "desc") {
|
|
77
|
+
return { valid: true, value: orderDirection };
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
valid: false,
|
|
81
|
+
code: "INVALID_ORDER",
|
|
82
|
+
message: `Invalid order "${orderDirection}". Use "asc" or "desc".`,
|
|
83
|
+
allowedValues: ["asc", "desc"]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function validateOrderBy(orderBy) {
|
|
87
|
+
if (orderBy === void 0) {
|
|
88
|
+
return { valid: true, value: void 0 };
|
|
89
|
+
}
|
|
90
|
+
if (orderBy === "value" || orderBy === "count") {
|
|
91
|
+
return { valid: true, value: orderBy };
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
valid: false,
|
|
95
|
+
code: "INVALID_ORDER_BY",
|
|
96
|
+
message: `Invalid order-by "${orderBy}". Use "value" or "count".`,
|
|
97
|
+
allowedValues: ["value", "count"]
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/commands/metrics/query.ts
|
|
102
|
+
function handleValidationError(result, jsonOutput, client) {
|
|
103
|
+
if (jsonOutput) {
|
|
104
|
+
client.stdout.write(
|
|
105
|
+
formatErrorJson(result.code, result.message, result.allowedValues)
|
|
106
|
+
);
|
|
107
|
+
} else {
|
|
108
|
+
output_manager_default.error(result.message);
|
|
109
|
+
if (result.allowedValues && result.allowedValues.length > 0) {
|
|
110
|
+
output_manager_default.print(`
|
|
111
|
+
Available values: ${result.allowedValues.join(", ")}
|
|
112
|
+
`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return 1;
|
|
116
|
+
}
|
|
117
|
+
var PRODUCTION_ENVIRONMENT_FILTER = "environment eq 'production'";
|
|
118
|
+
function combineFilters(filters, prod) {
|
|
119
|
+
const nonEmptyFilters = [
|
|
120
|
+
...filters?.filter((filter) => filter.length > 0) ?? [],
|
|
121
|
+
...prod ? [PRODUCTION_ENVIRONMENT_FILTER] : []
|
|
122
|
+
];
|
|
123
|
+
if (nonEmptyFilters.length === 0) {
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
if (nonEmptyFilters.length === 1) {
|
|
127
|
+
return nonEmptyFilters[0];
|
|
128
|
+
}
|
|
129
|
+
return nonEmptyFilters.map((filter) => `(${filter})`).join(" and ");
|
|
130
|
+
}
|
|
131
|
+
function getRequestOrderBy(metric, aggregation, orderBy) {
|
|
132
|
+
return orderBy === "value" ? getRollupColumnName(metric, aggregation) : void 0;
|
|
133
|
+
}
|
|
134
|
+
async function resolveQueryScope(client, opts) {
|
|
135
|
+
if (opts.project || opts.all) {
|
|
136
|
+
const { team } = await getScope(client);
|
|
137
|
+
if (!team) {
|
|
138
|
+
const errMsg = "No team context found. Run `vercel switch` to select a team, or use `vercel link` in a project directory.";
|
|
139
|
+
if (opts.jsonOutput) {
|
|
140
|
+
client.stdout.write(formatErrorJson("NO_TEAM", errMsg));
|
|
141
|
+
} else {
|
|
142
|
+
output_manager_default.error(errMsg);
|
|
143
|
+
}
|
|
144
|
+
return 1;
|
|
145
|
+
}
|
|
146
|
+
if (opts.all) {
|
|
147
|
+
return {
|
|
148
|
+
scope: { type: "owner", ownerId: team.id },
|
|
149
|
+
accountId: team.id,
|
|
150
|
+
teamName: team.slug
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const project = await getProjectByNameOrId(client, opts.project, team.id);
|
|
154
|
+
if (project instanceof ProjectNotFound) {
|
|
155
|
+
const errMsg = `Project "${opts.project}" was not found in team "${team.slug}".`;
|
|
156
|
+
if (opts.jsonOutput) {
|
|
157
|
+
client.stdout.write(formatErrorJson("PROJECT_NOT_FOUND", errMsg));
|
|
158
|
+
} else {
|
|
159
|
+
output_manager_default.error(errMsg);
|
|
160
|
+
}
|
|
161
|
+
return 1;
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
scope: {
|
|
165
|
+
type: "project",
|
|
166
|
+
ownerId: team.id,
|
|
167
|
+
projectIds: [project.id]
|
|
168
|
+
},
|
|
169
|
+
accountId: team.id,
|
|
170
|
+
teamName: team.slug,
|
|
171
|
+
projectName: project.name
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const linkedProject = await getLinkedProject(client);
|
|
175
|
+
if (linkedProject.status === "error") {
|
|
176
|
+
return linkedProject.exitCode;
|
|
177
|
+
}
|
|
178
|
+
if (linkedProject.status === "not_linked") {
|
|
179
|
+
const errMsg = "No linked project found. Run `vercel link` to link a project, or use --project <name-or-id> or --all.";
|
|
180
|
+
if (opts.jsonOutput) {
|
|
181
|
+
client.stdout.write(formatErrorJson("NOT_LINKED", errMsg));
|
|
182
|
+
} else {
|
|
183
|
+
output_manager_default.error(errMsg);
|
|
184
|
+
}
|
|
185
|
+
return 1;
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
scope: {
|
|
189
|
+
type: "project",
|
|
190
|
+
ownerId: linkedProject.org.id,
|
|
191
|
+
projectIds: [linkedProject.project.id]
|
|
192
|
+
},
|
|
193
|
+
accountId: linkedProject.org.id,
|
|
194
|
+
teamName: linkedProject.org.slug,
|
|
195
|
+
projectName: linkedProject.project.name
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
async function query(client, telemetry) {
|
|
199
|
+
let parsedArgs;
|
|
200
|
+
const flagsSpecification = getFlagsSpecification(metricsCommand.options);
|
|
201
|
+
try {
|
|
202
|
+
parsedArgs = parseArguments(client.argv.slice(2), flagsSpecification);
|
|
203
|
+
} catch (err) {
|
|
204
|
+
printError(err);
|
|
205
|
+
return 1;
|
|
206
|
+
}
|
|
207
|
+
const flags = parsedArgs.flags;
|
|
208
|
+
const positionalArgs = parsedArgs.args.slice(1);
|
|
209
|
+
const positionalMetric = positionalArgs[0] === "query" ? positionalArgs[1] : positionalArgs[0];
|
|
210
|
+
const formatResult = validateJsonOutput(flags);
|
|
211
|
+
if (!formatResult.valid) {
|
|
212
|
+
output_manager_default.error(formatResult.error);
|
|
213
|
+
return 1;
|
|
214
|
+
}
|
|
215
|
+
const jsonOutput = formatResult.jsonOutput;
|
|
216
|
+
const metricFlag = positionalMetric;
|
|
217
|
+
const aggregationFlag = flags["--aggregation"];
|
|
218
|
+
const groupBy = flags["--group-by"] ?? [];
|
|
219
|
+
const limit = flags["--limit"];
|
|
220
|
+
const orderByInput = typeof flags["--order-by"] === "string" ? flags["--order-by"].trim().toLowerCase() : void 0;
|
|
221
|
+
const orderInput = typeof flags["--order"] === "string" ? flags["--order"].trim().toLowerCase() : void 0;
|
|
222
|
+
const filters = flags["--filter"];
|
|
223
|
+
const prod = flags["--prod"];
|
|
224
|
+
const filter = combineFilters(filters, prod);
|
|
225
|
+
const since = flags["--since"];
|
|
226
|
+
const until = flags["--until"];
|
|
227
|
+
const granularity = flags["--granularity"];
|
|
228
|
+
const bucketTimezone = flags["--bucket-timezone"]?.trim();
|
|
229
|
+
const project = flags["--project"];
|
|
230
|
+
const all = flags["--all"];
|
|
231
|
+
telemetry.trackCliArgumentMetricId(metricFlag);
|
|
232
|
+
telemetry.trackCliOptionAggregation(aggregationFlag);
|
|
233
|
+
telemetry.trackCliOptionGroupBy(groupBy.length > 0 ? groupBy : void 0);
|
|
234
|
+
telemetry.trackCliOptionLimit(limit);
|
|
235
|
+
telemetry.trackCliOptionOrderBy(orderByInput);
|
|
236
|
+
telemetry.trackCliOptionOrder(orderInput);
|
|
237
|
+
telemetry.trackCliOptionFilter(filters);
|
|
238
|
+
telemetry.trackCliFlagProd(prod);
|
|
239
|
+
telemetry.trackCliOptionSince(since);
|
|
240
|
+
telemetry.trackCliOptionUntil(until);
|
|
241
|
+
telemetry.trackCliOptionGranularity(granularity);
|
|
242
|
+
telemetry.trackCliOptionBucketTimezone(bucketTimezone);
|
|
243
|
+
telemetry.trackCliOptionProject(project);
|
|
244
|
+
telemetry.trackCliFlagAll(all);
|
|
245
|
+
telemetry.trackCliOptionFormat(flags["--format"]);
|
|
246
|
+
const orderByResult = validateOrderBy(orderByInput);
|
|
247
|
+
if (!orderByResult.valid) {
|
|
248
|
+
return handleValidationError(orderByResult, jsonOutput, client);
|
|
249
|
+
}
|
|
250
|
+
const orderByMode = orderByResult.value;
|
|
251
|
+
const requiredMetric = validateRequiredMetric(metricFlag);
|
|
252
|
+
if (!requiredMetric.valid) {
|
|
253
|
+
return handleValidationError(requiredMetric, jsonOutput, client);
|
|
254
|
+
}
|
|
255
|
+
const metric = requiredMetric.value;
|
|
256
|
+
const mutualResult = validateMutualExclusivity(all, project);
|
|
257
|
+
if (!mutualResult.valid) {
|
|
258
|
+
return handleValidationError(mutualResult, jsonOutput, client);
|
|
259
|
+
}
|
|
260
|
+
const orderDirectionResult = validateOrderDirection(orderInput);
|
|
261
|
+
if (!orderDirectionResult.valid) {
|
|
262
|
+
return handleValidationError(orderDirectionResult, jsonOutput, client);
|
|
263
|
+
}
|
|
264
|
+
const orderDirection = orderDirectionResult.value;
|
|
265
|
+
const scopeResult = await resolveQueryScope(client, {
|
|
266
|
+
project,
|
|
267
|
+
all,
|
|
268
|
+
jsonOutput
|
|
269
|
+
});
|
|
270
|
+
if (typeof scopeResult === "number") {
|
|
271
|
+
return scopeResult;
|
|
272
|
+
}
|
|
273
|
+
const { scope, accountId, teamName, projectName } = scopeResult;
|
|
274
|
+
const detailOrExitCode = await fetchMetricDetailOrExit(
|
|
275
|
+
client,
|
|
276
|
+
accountId,
|
|
277
|
+
metric,
|
|
278
|
+
jsonOutput
|
|
279
|
+
);
|
|
280
|
+
if (typeof detailOrExitCode === "number") {
|
|
281
|
+
return detailOrExitCode;
|
|
282
|
+
}
|
|
283
|
+
const aggregationInput = aggregationFlag ?? getDefaultAggregation(detailOrExitCode, metric) ?? "sum";
|
|
284
|
+
const aggregation = aggregationInput;
|
|
285
|
+
const orderBy = getRequestOrderBy(metric, aggregation, orderByMode);
|
|
286
|
+
let startTime;
|
|
287
|
+
let endTime;
|
|
288
|
+
try {
|
|
289
|
+
({ startTime, endTime } = resolveTimeRange(since, until));
|
|
290
|
+
} catch (err) {
|
|
291
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
292
|
+
if (jsonOutput) {
|
|
293
|
+
client.stdout.write(formatErrorJson("INVALID_TIME", errMsg));
|
|
294
|
+
} else {
|
|
295
|
+
output_manager_default.error(errMsg);
|
|
296
|
+
}
|
|
297
|
+
return 1;
|
|
298
|
+
}
|
|
299
|
+
const rangeMs = endTime.getTime() - startTime.getTime();
|
|
300
|
+
const granResult = computeGranularity(rangeMs, granularity);
|
|
301
|
+
if (!jsonOutput && granResult.adjusted && granResult.notice) {
|
|
302
|
+
output_manager_default.log(`Notice: ${granResult.notice}`);
|
|
303
|
+
}
|
|
304
|
+
const body = {
|
|
305
|
+
scope,
|
|
306
|
+
metric,
|
|
307
|
+
aggregation,
|
|
308
|
+
startTime: startTime.toISOString(),
|
|
309
|
+
endTime: endTime.toISOString(),
|
|
310
|
+
granularity: granResult.duration,
|
|
311
|
+
...bucketTimezone ? { bucketTimezone } : {},
|
|
312
|
+
...groupBy.length > 0 ? { groupBy } : {},
|
|
313
|
+
...filter ? { filter } : {},
|
|
314
|
+
limit: limit ?? 10,
|
|
315
|
+
...orderBy ? { orderBy } : {},
|
|
316
|
+
...orderDirection ? { orderDirection } : {}
|
|
317
|
+
};
|
|
318
|
+
if (!jsonOutput) {
|
|
319
|
+
output_manager_default.spinner("Querying metrics...");
|
|
320
|
+
}
|
|
321
|
+
let response;
|
|
322
|
+
try {
|
|
323
|
+
response = await client.fetch(
|
|
324
|
+
"/v2/observability/query",
|
|
325
|
+
{
|
|
326
|
+
method: "POST",
|
|
327
|
+
body: JSON.stringify(body),
|
|
328
|
+
headers: { "Content-Type": "application/json" },
|
|
329
|
+
accountId,
|
|
330
|
+
bailOn429: true
|
|
331
|
+
}
|
|
332
|
+
);
|
|
333
|
+
} catch (err) {
|
|
334
|
+
if (isAPIError(err)) {
|
|
335
|
+
return handleApiError(err, jsonOutput, client);
|
|
336
|
+
}
|
|
337
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
338
|
+
if (jsonOutput) {
|
|
339
|
+
client.stdout.write(formatErrorJson("NETWORK_ERROR", errMsg));
|
|
340
|
+
} else {
|
|
341
|
+
output_manager_default.error(errMsg);
|
|
342
|
+
}
|
|
343
|
+
return 1;
|
|
344
|
+
} finally {
|
|
345
|
+
if (!jsonOutput) {
|
|
346
|
+
output_manager_default.stopSpinner();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (jsonOutput) {
|
|
350
|
+
client.stdout.write(
|
|
351
|
+
formatQueryJson(
|
|
352
|
+
{
|
|
353
|
+
metric,
|
|
354
|
+
aggregation,
|
|
355
|
+
groupBy,
|
|
356
|
+
filter,
|
|
357
|
+
startTime: startTime.toISOString(),
|
|
358
|
+
endTime: endTime.toISOString(),
|
|
359
|
+
granularity: granResult.duration,
|
|
360
|
+
...bucketTimezone ? { bucketTimezone } : {},
|
|
361
|
+
...orderByMode ? { orderBy: orderByMode } : {},
|
|
362
|
+
...orderDirection ? { orderDirection } : {}
|
|
363
|
+
},
|
|
364
|
+
response
|
|
365
|
+
)
|
|
366
|
+
);
|
|
367
|
+
} else {
|
|
368
|
+
client.stdout.write(
|
|
369
|
+
formatText(response, {
|
|
370
|
+
metric,
|
|
371
|
+
metricUnit: detailOrExitCode.find((item) => item.id === metric)?.unit ?? "count",
|
|
372
|
+
aggregation,
|
|
373
|
+
groupBy,
|
|
374
|
+
filter,
|
|
375
|
+
scope,
|
|
376
|
+
projectName,
|
|
377
|
+
teamName,
|
|
378
|
+
periodStart: startTime.toISOString(),
|
|
379
|
+
periodEnd: endTime.toISOString(),
|
|
380
|
+
granularity: granResult.duration,
|
|
381
|
+
bucketTimezone,
|
|
382
|
+
orderBy: orderByMode,
|
|
383
|
+
orderDirection
|
|
384
|
+
})
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
return 0;
|
|
388
|
+
}
|
|
389
|
+
export {
|
|
390
|
+
query as default
|
|
391
|
+
};
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
resolveRoute,
|
|
17
17
|
shellQuoteRouteIdentifierForSuggestion,
|
|
18
18
|
withGlobalFlags
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-GKVAAY2A.js";
|
|
20
20
|
import {
|
|
21
21
|
reorderSubcommand
|
|
22
22
|
} from "./chunk-VZSZBD4V.js";
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
stamp_default
|
|
25
25
|
} from "./chunk-64IF634X.js";
|
|
26
26
|
import "./chunk-VXYGCOKL.js";
|
|
27
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-GLAHGVBS.js";
|
|
28
28
|
import {
|
|
29
29
|
outputAgentError
|
|
30
30
|
} from "./chunk-UDWRZXIT.js";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
requireProjectContext,
|
|
20
20
|
validateRequiredArguments,
|
|
21
21
|
withGlobalFlags
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-GKVAAY2A.js";
|
|
23
23
|
import {
|
|
24
24
|
restoreSubcommand
|
|
25
25
|
} from "./chunk-VZSZBD4V.js";
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
stamp_default
|
|
28
28
|
} from "./chunk-64IF634X.js";
|
|
29
29
|
import "./chunk-VXYGCOKL.js";
|
|
30
|
-
import "./chunk-
|
|
30
|
+
import "./chunk-GLAHGVBS.js";
|
|
31
31
|
import {
|
|
32
32
|
outputAgentError
|
|
33
33
|
} from "./chunk-UDWRZXIT.js";
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
handleRulesApiError,
|
|
10
10
|
parseRulesFlagsAndScope,
|
|
11
11
|
rulesItemPath
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-A4XB42AB.js";
|
|
13
|
+
import "./chunk-XFGY3JAX.js";
|
|
14
14
|
import "./chunk-BUZRVER7.js";
|
|
15
15
|
import {
|
|
16
16
|
validateJsonOutput
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
rulesRmSubcommand
|
|
20
20
|
} from "./chunk-STJJ3DFO.js";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-GLAHGVBS.js";
|
|
22
22
|
import {
|
|
23
23
|
AGENT_REASON,
|
|
24
24
|
buildCommandWithGlobalFlags,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
requireVcrRepository,
|
|
14
14
|
resolveVcrScope,
|
|
15
15
|
validateVcrJsonOutput
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-NLRIKNPX.js";
|
|
17
17
|
import "./chunk-BUZRVER7.js";
|
|
18
18
|
import "./chunk-XPKWKPWA.js";
|
|
19
19
|
import {
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "./chunk-3VS4DTAU.js";
|
|
22
22
|
import "./chunk-GIL3VAUR.js";
|
|
23
23
|
import "./chunk-FYQPTH5C.js";
|
|
24
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-GLAHGVBS.js";
|
|
25
25
|
import {
|
|
26
26
|
AGENT_REASON,
|
|
27
27
|
buildCommandWithYes,
|
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
requireVcrRepositoryAndImageId,
|
|
14
14
|
resolveVcrScope,
|
|
15
15
|
validateVcrJsonOutput
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-NLRIKNPX.js";
|
|
17
17
|
import "./chunk-BUZRVER7.js";
|
|
18
18
|
import "./chunk-XPKWKPWA.js";
|
|
19
19
|
import {
|
|
20
20
|
imageRmSubcommand
|
|
21
21
|
} from "./chunk-FYQPTH5C.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-GLAHGVBS.js";
|
|
23
23
|
import {
|
|
24
24
|
AGENT_REASON,
|
|
25
25
|
buildCommandWithYes,
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
handleRulesApiError,
|
|
10
10
|
parseRulesFlagsAndScope,
|
|
11
11
|
rulesItemPath
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-A4XB42AB.js";
|
|
13
|
+
import "./chunk-XFGY3JAX.js";
|
|
14
14
|
import "./chunk-BUZRVER7.js";
|
|
15
15
|
import {
|
|
16
16
|
validateJsonOutput
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
rulesInspectSubcommand
|
|
20
20
|
} from "./chunk-STJJ3DFO.js";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-GLAHGVBS.js";
|
|
22
22
|
import {
|
|
23
23
|
AGENT_REASON,
|
|
24
24
|
buildCommandWithGlobalFlags,
|
|
@@ -30,7 +30,7 @@ var RULES_CONFIG = {
|
|
|
30
30
|
};
|
|
31
31
|
async function rules(client, argv) {
|
|
32
32
|
if (argv.length === 0 || argv[0].startsWith("-")) {
|
|
33
|
-
const lsFn = (await import("./ls-
|
|
33
|
+
const lsFn = (await import("./ls-MB74DIQV.js")).default;
|
|
34
34
|
return lsFn(client, argv);
|
|
35
35
|
}
|
|
36
36
|
const { subcommand, args, subcommandOriginal } = getSubcommand(
|
|
@@ -63,15 +63,15 @@ async function rules(client, argv) {
|
|
|
63
63
|
}
|
|
64
64
|
switch (subcommand) {
|
|
65
65
|
case "ls":
|
|
66
|
-
return (await import("./ls-
|
|
66
|
+
return (await import("./ls-MB74DIQV.js")).default(client, args);
|
|
67
67
|
case "add":
|
|
68
|
-
return (await import("./add-
|
|
68
|
+
return (await import("./add-L3Z6PL54.js")).default(client, args);
|
|
69
69
|
case "inspect":
|
|
70
|
-
return (await import("./rule-inspect-
|
|
70
|
+
return (await import("./rule-inspect-YEZGYINZ.js")).default(client, args);
|
|
71
71
|
case "rm":
|
|
72
|
-
return (await import("./rm-
|
|
72
|
+
return (await import("./rm-FRZMXB2W.js")).default(client, args);
|
|
73
73
|
case "update":
|
|
74
|
-
return (await import("./update-
|
|
74
|
+
return (await import("./update-W3CWQB2F.js")).default(client, args);
|
|
75
75
|
default:
|
|
76
76
|
output_manager_default.error(`Unhandled rules subcommand: ${String(subcommandOriginal)}`);
|
|
77
77
|
return 1;
|
|
@@ -6,12 +6,12 @@ const __filename = __fileURLToPath(import.meta.url);
|
|
|
6
6
|
const __dirname = __dirname_(__filename);
|
|
7
7
|
import {
|
|
8
8
|
fetchMetricDetailOrExit,
|
|
9
|
-
fetchMetricListOrExit
|
|
10
|
-
|
|
11
|
-
} from "./chunk-4Z5LC2CI.js";
|
|
9
|
+
fetchMetricListOrExit
|
|
10
|
+
} from "./chunk-6RTK6BWX.js";
|
|
12
11
|
import {
|
|
12
|
+
formatErrorJson,
|
|
13
13
|
indent_default
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-Z7NPYIZ6.js";
|
|
15
15
|
import {
|
|
16
16
|
formatTable
|
|
17
17
|
} from "./chunk-ZVLPUREX.js";
|
|
@@ -25,7 +25,7 @@ import "./chunk-NZRWTCRM.js";
|
|
|
25
25
|
import {
|
|
26
26
|
getScope,
|
|
27
27
|
require_pluralize
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-GLAHGVBS.js";
|
|
29
29
|
import "./chunk-UDWRZXIT.js";
|
|
30
30
|
import "./chunk-ECCWJHC6.js";
|
|
31
31
|
import {
|
|
@@ -52,9 +52,9 @@ async function tags(client, argv, telemetry) {
|
|
|
52
52
|
}
|
|
53
53
|
switch (subcommand) {
|
|
54
54
|
case "ls":
|
|
55
|
-
return (await import("./ls-
|
|
55
|
+
return (await import("./ls-YDUYTLXW.js")).default(client, args, telemetry);
|
|
56
56
|
case "inspect":
|
|
57
|
-
return (await import("./inspect-
|
|
57
|
+
return (await import("./inspect-4JD2QN67.js")).default(client, args, telemetry);
|
|
58
58
|
default:
|
|
59
59
|
output_manager_default.error(`Unhandled tags subcommand: ${subcommand}`);
|
|
60
60
|
return 1;
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
handleRulesApiError,
|
|
10
10
|
parseRulesFlagsAndScope,
|
|
11
11
|
rulesItemPath
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-A4XB42AB.js";
|
|
13
|
+
import "./chunk-XFGY3JAX.js";
|
|
14
14
|
import "./chunk-BUZRVER7.js";
|
|
15
15
|
import {
|
|
16
16
|
validateJsonOutput
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
rulesUpdateSubcommand
|
|
20
20
|
} from "./chunk-STJJ3DFO.js";
|
|
21
|
-
import "./chunk-
|
|
21
|
+
import "./chunk-GLAHGVBS.js";
|
|
22
22
|
import {
|
|
23
23
|
AGENT_REASON,
|
|
24
24
|
buildCommandWithGlobalFlags,
|