vercel 59.0.0 → 59.1.3

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.
Files changed (107) hide show
  1. package/dist/chunks/{add-SQ6ERCFZ.js → add-CUGPQYFW.js} +8 -8
  2. package/dist/chunks/{add-QZUQNL2C.js → add-PP3PJPJV.js} +5 -5
  3. package/dist/chunks/{add-3LO3UMYC.js → add-PRG4KKYH.js} +9 -11
  4. package/dist/chunks/{build-WMUKZEFH.js → build-T22GMLY6.js} +8 -8
  5. package/dist/chunks/{chunk-ELA5VN3A.js → chunk-2MF3ZAVW.js} +13 -4
  6. package/dist/chunks/{chunk-ZFTRB6AB.js → chunk-43DD2KNM.js} +1 -1
  7. package/dist/chunks/{chunk-N5DK7EMY.js → chunk-4HI7G6KG.js} +1 -1
  8. package/dist/chunks/{chunk-DQDJVHA5.js → chunk-4JKZ7SRX.js} +4 -4
  9. package/dist/chunks/{chunk-ZRWSSPW5.js → chunk-57G6HBJ4.js} +2 -2
  10. package/dist/chunks/{chunk-RWRSUGXY.js → chunk-5DVMXOFT.js} +2 -2
  11. package/dist/chunks/{chunk-SHR6DYA5.js → chunk-7NQLRE5V.js} +1 -1
  12. package/dist/chunks/{chunk-JLWQWYKO.js → chunk-BBSS3XIW.js} +2 -4
  13. package/dist/chunks/{chunk-V42UVZDX.js → chunk-BCZFZETZ.js} +5 -5
  14. package/dist/chunks/{chunk-MZ3L3SGZ.js → chunk-DAWJOQF6.js} +4 -6
  15. package/dist/chunks/{chunk-W34XLJ44.js → chunk-DEB45ND4.js} +3 -3
  16. package/dist/chunks/{chunk-QGQX7BYN.js → chunk-DOMLWKKZ.js} +38 -15
  17. package/dist/chunks/{chunk-TEQKKTJQ.js → chunk-F7OXZLY2.js} +2 -2
  18. package/dist/chunks/{chunk-J6LK45HT.js → chunk-GFCTRJI5.js} +16 -2
  19. package/dist/chunks/{chunk-O26N2UPI.js → chunk-GGPE5377.js} +1 -1
  20. package/dist/chunks/{chunk-4LDQIDRM.js → chunk-GMWRTZVZ.js} +9 -1
  21. package/dist/chunks/{chunk-LT5UQNTC.js → chunk-IKKUCZE7.js} +3 -3
  22. package/dist/chunks/{chunk-XIG4GH62.js → chunk-JYEO6OJS.js} +188 -102
  23. package/dist/chunks/{chunk-DMLU5KQE.js → chunk-KTLFN5FV.js} +1 -1
  24. package/dist/chunks/{chunk-L6NIIAB7.js → chunk-LNVZ3T7X.js} +6 -8
  25. package/dist/chunks/{chunk-UQVOFOP2.js → chunk-M34ZRNDQ.js} +1 -1
  26. package/dist/chunks/{chunk-2SFMOCWR.js → chunk-PD7ZUXE7.js} +1 -1
  27. package/dist/chunks/chunk-QCVKGY2A.js +151 -0
  28. package/dist/chunks/{chunk-S3H7ITUR.js → chunk-QD5NX7RG.js} +1 -1
  29. package/dist/chunks/{chunk-4N7XLXM2.js → chunk-QQ6PH4RY.js} +1 -0
  30. package/dist/chunks/{chunk-A5KP5HAI.js → chunk-RIB4S2IB.js} +10 -1
  31. package/dist/chunks/{chunk-ZX2FSPWV.js → chunk-SJQEGGH7.js} +4 -4
  32. package/dist/chunks/{chunk-5KI3SUJI.js → chunk-SOKQBFF7.js} +609 -73
  33. package/dist/chunks/{chunk-PSZQNYEV.js → chunk-SQGMTRZD.js} +91 -43
  34. package/dist/chunks/{chunk-TJJ562C5.js → chunk-TJLBCLEX.js} +15 -0
  35. package/dist/chunks/{chunk-WE3TFESA.js → chunk-TM3F7PLR.js} +2 -2
  36. package/dist/chunks/{chunk-SD2QZHZA.js → chunk-TNKRSTMB.js} +1 -1
  37. package/dist/chunks/{chunk-KT4XXKJK.js → chunk-VAFU7DXZ.js} +195 -3
  38. package/dist/chunks/{chunk-RQ7H43CJ.js → chunk-VDJN4WKH.js} +1 -1
  39. package/dist/chunks/{chunk-3R5JGMHV.js → chunk-VE545BR3.js} +4473 -2796
  40. package/dist/chunks/{chunk-B3JTF4CF.js → chunk-WC7IINFV.js} +10 -1
  41. package/dist/chunks/{chunk-SQAQED4U.js → chunk-XZLI27ES.js} +2 -2
  42. package/dist/chunks/{chunk-CMR5KQVR.js → chunk-ZUVJISHS.js} +3 -3
  43. package/dist/chunks/{clear-W2B4CHTP.js → clear-Z4IKUIN7.js} +5 -5
  44. package/dist/chunks/{compile-vercel-config-HTWOS7DZ.js → compile-vercel-config-PSVXFAZW.js} +3 -3
  45. package/dist/chunks/{config-EGJY4UUE.js → config-M5GMZ2X5.js} +8 -8
  46. package/dist/chunks/{constants-WEQVJSYS.js → constants-YMCRE6IG.js} +1 -1
  47. package/dist/chunks/{delete-BVMID4W2.js → delete-5GRRDJSF.js} +4 -4
  48. package/dist/chunks/{delete-6I7V5AGV.js → delete-P4XIBY7T.js} +5 -5
  49. package/dist/chunks/{disable-I54JNXJE.js → disable-NT5NYVO7.js} +4 -4
  50. package/dist/chunks/{discard-6TSJJCUQ.js → discard-TBNIEAJZ.js} +4 -4
  51. package/dist/chunks/{edit-YS2SWHFJ.js → edit-DJ6MT6HA.js} +5 -5
  52. package/dist/chunks/{edit-KCWYQ2YT.js → edit-UF3D2CCH.js} +5 -5
  53. package/dist/chunks/{enable-RYXRIGQN.js → enable-JTQBQMBO.js} +4 -4
  54. package/dist/chunks/{export-G3NYOADE.js → export-OKMRGRVM.js} +4 -4
  55. package/dist/chunks/{image-RJBLSUES.js → image-ARUJH4H5.js} +4 -4
  56. package/dist/chunks/{import-builders-M6F3F4DH.js → import-builders-3NTMZM64.js} +6 -4
  57. package/dist/chunks/{inspect-YTCVTZHY.js → inspect-5NETOGAI.js} +6 -7
  58. package/dist/chunks/{inspect-AE4YIJYS.js → inspect-CHFKZKKP.js} +5 -5
  59. package/dist/chunks/{inspect-Z74NZZ2A.js → inspect-FXZTQY62.js} +6 -6
  60. package/dist/chunks/{inspect-E7TBGK7D.js → inspect-PTXIBSYW.js} +8 -8
  61. package/dist/chunks/{inspect-7XUEVBDM.js → inspect-UXP2HDES.js} +5 -5
  62. package/dist/chunks/{list-SGPLL4KJ.js → list-2WMIVJ2R.js} +15 -10
  63. package/dist/chunks/{list-KJNC3NOE.js → list-ADI55WKW.js} +6 -7
  64. package/dist/chunks/{list-WXS2AFQD.js → list-DYCZA2VX.js} +3 -3
  65. package/dist/chunks/{login-XD3CFPBF.js → login-YCSIQG6B.js} +8 -8
  66. package/dist/chunks/{ls-5DSOTTYX.js → ls-2TKUIUK4.js} +11 -12
  67. package/dist/chunks/{ls-KE5I7BZO.js → ls-EOMIQLRH.js} +11 -12
  68. package/dist/chunks/{ls-SVSO3677.js → ls-PQFDGOJL.js} +7 -8
  69. package/dist/chunks/{ls-5A4327XJ.js → ls-RZVTIP5U.js} +11 -12
  70. package/dist/chunks/{ls-NBKSDTWX.js → ls-VIOMDUGW.js} +14 -15
  71. package/dist/chunks/{open-M2MOAE2K.js → open-JYPWOXQD.js} +5 -5
  72. package/dist/chunks/{permissions-ADPY554K.js → permissions-SGJWGEVD.js} +6 -6
  73. package/dist/chunks/{publish-OBIOOL7T.js → publish-ZUQHJAXL.js} +4 -4
  74. package/dist/chunks/{push-5237XBTO.js → push-XMVKG5A5.js} +8 -8
  75. package/dist/chunks/{query-ILL74HIA.js → query-ZLJZEGZB.js} +237 -49
  76. package/dist/chunks/{reorder-GAUAO4LW.js → reorder-NVHDWMRU.js} +4 -4
  77. package/dist/chunks/{reply-IZJHEULD.js → reply-PUUPUQ3V.js} +5 -5
  78. package/dist/chunks/{resolve-HTIT7CGL.js → resolve-5U2LJVE6.js} +5 -5
  79. package/dist/chunks/{restore-IKL74HSE.js → restore-OXIUY2UI.js} +4 -4
  80. package/dist/chunks/{rm-QAVNP5KX.js → rm-3IOCBNPE.js} +5 -5
  81. package/dist/chunks/{rm-5Y6BL47T.js → rm-BZNKJRXU.js} +5 -5
  82. package/dist/chunks/{rm-C37ZORQV.js → rm-OUI4ZB5R.js} +5 -5
  83. package/dist/chunks/{rm-XJU5SBGH.js → rm-Z2KYJ7XT.js} +8 -8
  84. package/dist/chunks/{rule-inspect-DYHWWROS.js → rule-inspect-ZBJJCDQV.js} +7 -8
  85. package/dist/chunks/{rules-M6EJ2Y6S.js → rules-HEGAXXUN.js} +8 -8
  86. package/dist/chunks/{schema-LLBDZNIC.js → schema-7GVL3BNP.js} +63 -31
  87. package/dist/chunks/{schema-ZNPIMQL5.js → schema-ZYIJYA2E.js} +2 -3
  88. package/dist/chunks/{tags-HR5RVQFA.js → tags-3SCWCMNQ.js} +3 -3
  89. package/dist/chunks/{types-UWI4HETD.js → types-AJHILHO5.js} +2 -4
  90. package/dist/chunks/{update-6A5V6HBH.js → update-YR2GCCJN.js} +7 -8
  91. package/dist/commands/build/index.js +10 -15
  92. package/dist/commands/deploy/index.js +310 -302
  93. package/dist/commands/dev/index.js +254 -181
  94. package/dist/commands/env/index.js +15 -16
  95. package/dist/commands/link/index.js +14 -20
  96. package/dist/commands/list/index.js +7 -9
  97. package/dist/commands-bulk.js +4408 -1246
  98. package/dist/help.js +1 -1
  99. package/dist/index.js +30 -22
  100. package/dist/version.mjs +1 -1
  101. package/package.json +41 -40
  102. package/dist/chunks/chunk-BGILSKZ5.js +0 -85
  103. package/dist/chunks/chunk-GFG6QDIE.js +0 -101
  104. package/dist/chunks/chunk-KBEX5MYS.js +0 -208
  105. package/dist/chunks/chunk-PBECT5BN.js +0 -107
  106. package/dist/chunks/chunk-PVCJIMVY.js +0 -1552
  107. /package/dist/{commands/dev/next-dev-websocket-shim-preload.cjs → runtime-assets/node-preloads/next-dev-websocket.cjs} +0 -0
@@ -5,13 +5,17 @@ const require = __createRequire(import.meta.url);
5
5
  const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
7
  import {
8
+ OBSERVABILITY_METRICS_PATH,
9
+ fetchCustomMetricCatalog,
8
10
  fetchMetricDetailOrExit,
9
11
  getDefaultAggregation
10
- } from "./chunk-GFG6QDIE.js";
12
+ } from "./chunk-QCVKGY2A.js";
11
13
  import {
12
14
  computeGranularity,
13
- formatText
14
- } from "./chunk-XIG4GH62.js";
15
+ formatText,
16
+ getDefaultCustomMetricAggregation,
17
+ isCanonicalAggregation
18
+ } from "./chunk-JYEO6OJS.js";
15
19
  import {
16
20
  formatErrorJson,
17
21
  formatQueryJson,
@@ -24,7 +28,7 @@ import {
24
28
  resolveTimeRange,
25
29
  validateAllProjectMutualExclusivity
26
30
  } from "./chunk-P65EEFTR.js";
27
- import "./chunk-RQ7H43CJ.js";
31
+ import "./chunk-VDJN4WKH.js";
28
32
  import {
29
33
  validateJsonOutput
30
34
  } from "./chunk-KXDWXXJH.js";
@@ -32,18 +36,17 @@ import {
32
36
  metricsCommand
33
37
  } from "./chunk-CSJBZKC5.js";
34
38
  import "./chunk-VXYGCOKL.js";
35
- import "./chunk-KT4XXKJK.js";
36
39
  import {
37
40
  getLinkedProject,
38
41
  getProjectByNameOrId,
39
42
  getScope
40
- } from "./chunk-3R5JGMHV.js";
43
+ } from "./chunk-VE545BR3.js";
41
44
  import "./chunk-ECCWJHC6.js";
42
- import "./chunk-TJJ562C5.js";
45
+ import "./chunk-TJLBCLEX.js";
43
46
  import "./chunk-GGP5R3FU.js";
44
47
  import {
45
48
  printError
46
- } from "./chunk-KBEX5MYS.js";
49
+ } from "./chunk-VAFU7DXZ.js";
47
50
  import {
48
51
  parseArguments
49
52
  } from "./chunk-XLKFJPMT.js";
@@ -117,6 +120,8 @@ Available values: ${result.allowedValues.join(", ")}
117
120
  return 1;
118
121
  }
119
122
  var PRODUCTION_ENVIRONMENT_FILTER = "environment eq 'production'";
123
+ var CUSTOM_METRIC_VALUE_ALIAS = "value";
124
+ var CUSTOM_METRIC_COUNT_ALIAS = "__seriesCount";
120
125
  function combineFilters(filters, prod) {
121
126
  const nonEmptyFilters = [
122
127
  ...filters?.filter((filter) => filter.length > 0) ?? [],
@@ -133,6 +138,107 @@ function combineFilters(filters, prod) {
133
138
  function getRequestOrderBy(metric, aggregation, orderBy) {
134
139
  return orderBy === "value" ? getRollupColumnName(metric, aggregation) : void 0;
135
140
  }
141
+ function toBucketSeconds(granularity) {
142
+ if ("minutes" in granularity)
143
+ return granularity.minutes * 60;
144
+ if ("hours" in granularity)
145
+ return granularity.hours * 60 * 60;
146
+ return granularity.days * 24 * 60 * 60;
147
+ }
148
+ function alignTimeRangeToGranularity(startTime, endTime, granularity) {
149
+ const bucketMs = toBucketSeconds(granularity) * 1e3;
150
+ return {
151
+ startTime: new Date(Math.floor(startTime.getTime() / bucketMs) * bucketMs),
152
+ endTime: new Date(Math.ceil(endTime.getTime() / bucketMs) * bucketMs)
153
+ };
154
+ }
155
+ function toCanonicalMetricSelection(metric, aggregation) {
156
+ if (aggregation === "persecond") {
157
+ return { metric, aggregation: "sum", per: "second" };
158
+ }
159
+ if (aggregation === "percent") {
160
+ return { metric, aggregation: "sum", normalize: "percent" };
161
+ }
162
+ if (aggregation === "unique") {
163
+ return {
164
+ valid: false,
165
+ code: "UNSUPPORTED_AGGREGATION",
166
+ message: "The unique aggregation for custom metrics requires an explicit distinct dimension, which vc metrics does not support yet."
167
+ };
168
+ }
169
+ if (isCanonicalAggregation(aggregation)) {
170
+ return { metric, aggregation };
171
+ }
172
+ return {
173
+ valid: false,
174
+ code: "INVALID_AGGREGATION",
175
+ message: `Aggregation "${aggregation}" is not supported for custom metrics.`
176
+ };
177
+ }
178
+ function createCanonicalMetricsRequest(options) {
179
+ const metrics = {
180
+ [CUSTOM_METRIC_VALUE_ALIAS]: options.selection
181
+ };
182
+ let rankMetric = CUSTOM_METRIC_VALUE_ALIAS;
183
+ if (options.groupBy.length > 0 && options.orderBy !== "value" && options.selection.aggregation !== "count") {
184
+ metrics[CUSTOM_METRIC_COUNT_ALIAS] = {
185
+ metric: options.metric,
186
+ aggregation: "count"
187
+ };
188
+ rankMetric = CUSTOM_METRIC_COUNT_ALIAS;
189
+ }
190
+ return {
191
+ scope: {
192
+ ownerId: options.scope.ownerId,
193
+ ...options.scope.type === "project" ? { projectIds: options.scope.projectIds } : {}
194
+ },
195
+ timeRange: {
196
+ start: options.startTime.toISOString(),
197
+ end: options.endTime.toISOString()
198
+ },
199
+ bucketSeconds: toBucketSeconds(options.granularity),
200
+ ...options.groupBy.length > 0 ? { groupBy: options.groupBy } : {},
201
+ ...options.filter ? { filter: options.filter } : {},
202
+ metrics,
203
+ outputs: [CUSTOM_METRIC_VALUE_ALIAS],
204
+ ...options.groupBy.length > 0 ? {
205
+ seriesSelection: {
206
+ limit: options.limit,
207
+ mode: "exact",
208
+ rankBy: [
209
+ {
210
+ metric: rankMetric,
211
+ direction: options.orderDirection ?? "desc"
212
+ }
213
+ ]
214
+ }
215
+ } : {}
216
+ };
217
+ }
218
+ function canonicalResponseToMetricsResponse(response, rollupColumn, orderBy, orderDirection) {
219
+ const toRow = (point) => ({
220
+ ...point.dimensions,
221
+ [rollupColumn]: point.values[CUSTOM_METRIC_VALUE_ALIAS] ?? null
222
+ });
223
+ return {
224
+ ...response.series ? {
225
+ data: response.series.map((point) => ({
226
+ timestamp: point.timestamp,
227
+ ...toRow(point)
228
+ }))
229
+ } : {},
230
+ summary: response.summary.map(toRow),
231
+ statistics: {
232
+ rowsRead: response.meta.statistics.rowsRead,
233
+ bytesRead: response.meta.statistics.bytesRead,
234
+ dbTimeSeconds: response.meta.statistics.databaseElapsedMs / 1e3,
235
+ engineTimeSeconds: response.meta.statistics.elapsedMs / 1e3,
236
+ queryTable: [...new Set(response.meta.sources.map((source) => source.id))].sort().join(",")
237
+ },
238
+ ...orderBy ? { orderBy } : {},
239
+ ...orderDirection ? { orderDirection } : {}
240
+ };
241
+ }
136
242
  async function resolveQueryScope(client, opts) {
137
243
  if (opts.project || opts.all) {
138
244
  const { team } = await getScope(client);
@@ -273,18 +379,6 @@ async function query(client, telemetry) {
273
379
  return scopeResult;
274
380
  }
275
381
  const { scope, accountId, teamName, projectName } = scopeResult;
276
- const detailOrExitCode = await fetchMetricDetailOrExit(
277
- client,
278
- accountId,
279
- metric,
280
- jsonOutput
281
- );
282
- if (typeof detailOrExitCode === "number") {
283
- return detailOrExitCode;
284
- }
285
- const aggregationInput = aggregationFlag ?? getDefaultAggregation(detailOrExitCode, metric) ?? "sum";
286
- const aggregation = aggregationInput;
287
- const orderBy = getRequestOrderBy(metric, aggregation, orderByMode);
288
382
  let startTime;
289
383
  let endTime;
290
384
  try {
@@ -298,40 +392,134 @@ async function query(client, telemetry) {
298
392
  }
299
393
  return 1;
300
394
  }
395
+ const isPlatformMetric = metric.startsWith("vercel.");
396
+ let metricUnit;
397
+ let aggregationInput;
398
+ let customMetricAggregations;
399
+ if (isPlatformMetric) {
400
+ const detailOrExitCode = await fetchMetricDetailOrExit(
401
+ client,
402
+ accountId,
403
+ metric,
404
+ jsonOutput
405
+ );
406
+ if (typeof detailOrExitCode === "number") {
407
+ return detailOrExitCode;
408
+ }
409
+ aggregationInput = aggregationFlag ?? getDefaultAggregation(detailOrExitCode, metric) ?? "sum";
410
+ metricUnit = detailOrExitCode.find((item) => item.id === metric)?.unit ?? "count";
411
+ } else {
412
+ const customMetric = await fetchCustomMetricCatalog(
413
+ client,
414
+ accountId,
415
+ metric,
416
+ startTime.toISOString()
417
+ ).then((metrics) => metrics.find((item) => item.id === metric)).catch(() => void 0);
418
+ metricUnit = customMetric?.unit ?? "units";
419
+ customMetricAggregations = customMetric?.aggregations;
420
+ aggregationInput = aggregationFlag ?? getDefaultCustomMetricAggregation(metricUnit, customMetricAggregations);
421
+ }
422
+ const aggregation = aggregationInput;
423
+ const orderBy = getRequestOrderBy(metric, aggregation, orderByMode);
301
424
  const rangeMs = endTime.getTime() - startTime.getTime();
302
425
  const granResult = computeGranularity(rangeMs, granularity);
426
+ const queryTimeRange = isPlatformMetric ? { startTime, endTime } : alignTimeRangeToGranularity(startTime, endTime, granResult.duration);
303
427
  if (!jsonOutput && granResult.adjusted && granResult.notice) {
304
428
  output_manager_default.log(`Notice: ${granResult.notice}`);
305
429
  }
306
- const body = {
307
- scope,
308
- metric,
309
- aggregation,
310
- startTime: startTime.toISOString(),
311
- endTime: endTime.toISOString(),
312
- granularity: granResult.duration,
313
- ...bucketTimezone ? { bucketTimezone } : {},
314
- ...groupBy.length > 0 ? { groupBy } : {},
315
- ...filter ? { filter } : {},
316
- limit: limit ?? 10,
317
- ...orderBy ? { orderBy } : {},
318
- ...orderDirection ? { orderDirection } : {}
319
- };
430
+ let body;
431
+ if (isPlatformMetric) {
432
+ body = {
433
+ scope,
434
+ metric,
435
+ aggregation,
436
+ startTime: startTime.toISOString(),
437
+ endTime: endTime.toISOString(),
438
+ granularity: granResult.duration,
439
+ ...bucketTimezone ? { bucketTimezone } : {},
440
+ ...groupBy.length > 0 ? { groupBy } : {},
441
+ ...filter ? { filter } : {},
442
+ limit: limit ?? 10,
443
+ ...orderBy ? { orderBy } : {},
444
+ ...orderDirection ? { orderDirection } : {}
445
+ };
446
+ } else {
447
+ if (bucketTimezone) {
448
+ return handleValidationError(
449
+ {
450
+ valid: false,
451
+ code: "UNSUPPORTED_BUCKET_TIMEZONE",
452
+ message: "--bucket-timezone is not supported for custom metrics yet."
453
+ },
454
+ jsonOutput,
455
+ client
456
+ );
457
+ }
458
+ const selection = toCanonicalMetricSelection(metric, aggregation);
459
+ if ("valid" in selection) {
460
+ return handleValidationError(selection, jsonOutput, client);
461
+ }
462
+ const supportedAggregation = selection.aggregation;
463
+ if (customMetricAggregations && !customMetricAggregations.includes(supportedAggregation)) {
464
+ return handleValidationError(
465
+ {
466
+ valid: false,
467
+ code: "INVALID_AGGREGATION",
468
+ message: `Aggregation "${aggregation}" is not valid for custom metric "${metric}".`,
469
+ allowedValues: [...customMetricAggregations]
470
+ },
471
+ jsonOutput,
472
+ client
473
+ );
474
+ }
475
+ body = createCanonicalMetricsRequest({
476
+ scope,
477
+ metric,
478
+ selection,
479
+ startTime: queryTimeRange.startTime,
480
+ endTime: queryTimeRange.endTime,
481
+ granularity: granResult.duration,
482
+ groupBy,
483
+ filter,
484
+ limit: limit ?? 10,
485
+ orderBy: orderByMode,
486
+ orderDirection
487
+ });
488
+ }
320
489
  if (!jsonOutput) {
321
490
  output_manager_default.spinner("Querying metrics...");
322
491
  }
323
492
  let response;
324
493
  try {
325
- response = await client.fetch(
326
- "/v2/observability/query",
327
- {
328
- method: "POST",
329
- body: JSON.stringify(body),
330
- headers: { "Content-Type": "application/json" },
331
- accountId,
332
- bailOn429: true
333
- }
334
- );
494
+ if (isPlatformMetric) {
495
+ response = await client.fetch(
496
+ "/v2/observability/query",
497
+ {
498
+ method: "POST",
499
+ body: JSON.stringify(body),
500
+ headers: { "Content-Type": "application/json" },
501
+ accountId,
502
+ bailOn429: true
503
+ }
504
+ );
505
+ } else {
506
+ const canonicalResponse = await client.fetch(
507
+ OBSERVABILITY_METRICS_PATH,
508
+ {
509
+ method: "POST",
510
+ body: JSON.stringify(body),
511
+ headers: { "Content-Type": "application/json" },
512
+ accountId,
513
+ bailOn429: true
514
+ }
515
+ );
516
+ response = canonicalResponseToMetricsResponse(
517
+ canonicalResponse,
518
+ getRollupColumnName(metric, aggregation),
519
+ groupBy.length > 0 ? orderByMode ?? "count" : void 0,
520
+ groupBy.length > 0 ? orderDirection ?? "desc" : void 0
521
+ );
522
+ }
335
523
  } catch (err) {
336
524
  if (isAPIError(err)) {
337
525
  return handleApiError(err, jsonOutput, client);
@@ -356,8 +544,8 @@ async function query(client, telemetry) {
356
544
  aggregation,
357
545
  groupBy,
358
546
  filter,
359
- startTime: startTime.toISOString(),
360
- endTime: endTime.toISOString(),
547
+ startTime: queryTimeRange.startTime.toISOString(),
548
+ endTime: queryTimeRange.endTime.toISOString(),
361
549
  granularity: granResult.duration,
362
550
  ...bucketTimezone ? { bucketTimezone } : {},
363
551
  ...orderByMode ? { orderBy: orderByMode } : {},
@@ -370,15 +558,15 @@ async function query(client, telemetry) {
370
558
  client.stdout.write(
371
559
  formatText(response, {
372
560
  metric,
373
- metricUnit: detailOrExitCode.find((item) => item.id === metric)?.unit ?? "count",
561
+ metricUnit,
374
562
  aggregation,
375
563
  groupBy,
376
564
  filter,
377
565
  scope,
378
566
  projectName,
379
567
  teamName,
380
- periodStart: startTime.toISOString(),
381
- periodEnd: endTime.toISOString(),
568
+ periodStart: queryTimeRange.startTime.toISOString(),
569
+ periodEnd: queryTimeRange.endTime.toISOString(),
382
570
  granularity: granResult.duration,
383
571
  bucketTimezone,
384
572
  orderBy: orderByMode,
@@ -16,7 +16,7 @@ import {
16
16
  resolveRoute,
17
17
  shellQuoteRouteIdentifierForSuggestion,
18
18
  withGlobalFlags
19
- } from "./chunk-CMR5KQVR.js";
19
+ } from "./chunk-ZUVJISHS.js";
20
20
  import {
21
21
  reorderSubcommand
22
22
  } from "./chunk-M22O6CYY.js";
@@ -24,13 +24,13 @@ import {
24
24
  stamp_default
25
25
  } from "./chunk-64IF634X.js";
26
26
  import "./chunk-VXYGCOKL.js";
27
- import "./chunk-3R5JGMHV.js";
27
+ import "./chunk-VE545BR3.js";
28
28
  import "./chunk-ECCWJHC6.js";
29
29
  import {
30
30
  outputAgentError
31
- } from "./chunk-TJJ562C5.js";
31
+ } from "./chunk-TJLBCLEX.js";
32
32
  import "./chunk-GGP5R3FU.js";
33
- import "./chunk-KBEX5MYS.js";
33
+ import "./chunk-VAFU7DXZ.js";
34
34
  import "./chunk-XLKFJPMT.js";
35
35
  import "./chunk-SOFC4MLS.js";
36
36
  import "./chunk-P4QNYOFB.js";
@@ -16,7 +16,7 @@ import {
16
16
  resolveCommentsScope,
17
17
  threadNotFoundMessage,
18
18
  toApiErrorParts
19
- } from "./chunk-RWRSUGXY.js";
19
+ } from "./chunk-5DVMXOFT.js";
20
20
  import "./chunk-2473DUBR.js";
21
21
  import {
22
22
  outputError
@@ -26,12 +26,12 @@ import {
26
26
  } from "./chunk-KXDWXXJH.js";
27
27
  import {
28
28
  replySubcommand
29
- } from "./chunk-4LDQIDRM.js";
30
- import "./chunk-3R5JGMHV.js";
29
+ } from "./chunk-GMWRTZVZ.js";
30
+ import "./chunk-VE545BR3.js";
31
31
  import "./chunk-ECCWJHC6.js";
32
- import "./chunk-TJJ562C5.js";
32
+ import "./chunk-TJLBCLEX.js";
33
33
  import "./chunk-GGP5R3FU.js";
34
- import "./chunk-KBEX5MYS.js";
34
+ import "./chunk-VAFU7DXZ.js";
35
35
  import {
36
36
  parseArguments
37
37
  } from "./chunk-XLKFJPMT.js";
@@ -14,7 +14,7 @@ import {
14
14
  threadNotFoundMessage,
15
15
  toApiErrorParts,
16
16
  updateThread
17
- } from "./chunk-RWRSUGXY.js";
17
+ } from "./chunk-5DVMXOFT.js";
18
18
  import {
19
19
  canPrompt
20
20
  } from "./chunk-2473DUBR.js";
@@ -27,12 +27,12 @@ import {
27
27
  import {
28
28
  reopenSubcommand,
29
29
  resolveSubcommand
30
- } from "./chunk-4LDQIDRM.js";
31
- import "./chunk-3R5JGMHV.js";
30
+ } from "./chunk-GMWRTZVZ.js";
31
+ import "./chunk-VE545BR3.js";
32
32
  import "./chunk-ECCWJHC6.js";
33
- import "./chunk-TJJ562C5.js";
33
+ import "./chunk-TJLBCLEX.js";
34
34
  import "./chunk-GGP5R3FU.js";
35
- import "./chunk-KBEX5MYS.js";
35
+ import "./chunk-VAFU7DXZ.js";
36
36
  import {
37
37
  parseArguments
38
38
  } from "./chunk-XLKFJPMT.js";
@@ -19,7 +19,7 @@ import {
19
19
  requireProjectContext,
20
20
  validateRequiredArguments,
21
21
  withGlobalFlags
22
- } from "./chunk-CMR5KQVR.js";
22
+ } from "./chunk-ZUVJISHS.js";
23
23
  import {
24
24
  restoreSubcommand
25
25
  } from "./chunk-M22O6CYY.js";
@@ -27,13 +27,13 @@ import {
27
27
  stamp_default
28
28
  } from "./chunk-64IF634X.js";
29
29
  import "./chunk-VXYGCOKL.js";
30
- import "./chunk-3R5JGMHV.js";
30
+ import "./chunk-VE545BR3.js";
31
31
  import "./chunk-ECCWJHC6.js";
32
32
  import {
33
33
  outputAgentError
34
- } from "./chunk-TJJ562C5.js";
34
+ } from "./chunk-TJLBCLEX.js";
35
35
  import "./chunk-GGP5R3FU.js";
36
- import "./chunk-KBEX5MYS.js";
36
+ import "./chunk-VAFU7DXZ.js";
37
37
  import "./chunk-XLKFJPMT.js";
38
38
  import "./chunk-SOFC4MLS.js";
39
39
  import "./chunk-P4QNYOFB.js";
@@ -9,8 +9,8 @@ import {
9
9
  handleRulesApiError,
10
10
  parseRulesFlagsAndScope,
11
11
  rulesItemPath
12
- } from "./chunk-ZRWSSPW5.js";
13
- import "./chunk-SQAQED4U.js";
12
+ } from "./chunk-57G6HBJ4.js";
13
+ import "./chunk-XZLI27ES.js";
14
14
  import "./chunk-P65EEFTR.js";
15
15
  import {
16
16
  validateJsonOutput
@@ -18,18 +18,18 @@ import {
18
18
  import {
19
19
  rulesRmSubcommand
20
20
  } from "./chunk-UMA66MKW.js";
21
- import "./chunk-3R5JGMHV.js";
21
+ import "./chunk-VE545BR3.js";
22
22
  import "./chunk-ECCWJHC6.js";
23
23
  import {
24
24
  AGENT_REASON,
25
25
  buildCommandWithGlobalFlags,
26
26
  buildCommandWithYes,
27
27
  outputAgentError
28
- } from "./chunk-TJJ562C5.js";
28
+ } from "./chunk-TJLBCLEX.js";
29
29
  import "./chunk-GGP5R3FU.js";
30
30
  import {
31
31
  printError
32
- } from "./chunk-KBEX5MYS.js";
32
+ } from "./chunk-VAFU7DXZ.js";
33
33
  import {
34
34
  parseArguments
35
35
  } from "./chunk-XLKFJPMT.js";
@@ -17,7 +17,7 @@ import {
17
17
  emitVcrArgParseError,
18
18
  resolveVcrScope,
19
19
  validateVcrJsonOutput
20
- } from "./chunk-WE3TFESA.js";
20
+ } from "./chunk-TM3F7PLR.js";
21
21
  import "./chunk-G75NFPIT.js";
22
22
  import {
23
23
  outputError
@@ -25,19 +25,19 @@ import {
25
25
  import "./chunk-KXDWXXJH.js";
26
26
  import {
27
27
  permissionsRmSubcommand
28
- } from "./chunk-J6LK45HT.js";
28
+ } from "./chunk-GFCTRJI5.js";
29
29
  import "./chunk-R6IGDGX3.js";
30
- import "./chunk-3R5JGMHV.js";
30
+ import "./chunk-VE545BR3.js";
31
31
  import "./chunk-ECCWJHC6.js";
32
32
  import {
33
33
  AGENT_REASON,
34
34
  buildCommandWithGlobalFlags,
35
35
  outputAgentError
36
- } from "./chunk-TJJ562C5.js";
36
+ } from "./chunk-TJLBCLEX.js";
37
37
  import "./chunk-GGP5R3FU.js";
38
38
  import {
39
39
  printError
40
- } from "./chunk-KBEX5MYS.js";
40
+ } from "./chunk-VAFU7DXZ.js";
41
41
  import {
42
42
  parseArguments
43
43
  } from "./chunk-XLKFJPMT.js";
@@ -13,25 +13,25 @@ import {
13
13
  requireVcrRepositoryAndImageId,
14
14
  resolveVcrScope,
15
15
  validateVcrJsonOutput
16
- } from "./chunk-WE3TFESA.js";
16
+ } from "./chunk-TM3F7PLR.js";
17
17
  import "./chunk-G75NFPIT.js";
18
18
  import "./chunk-P65EEFTR.js";
19
19
  import "./chunk-KXDWXXJH.js";
20
20
  import {
21
21
  imageRmSubcommand
22
- } from "./chunk-A5KP5HAI.js";
22
+ } from "./chunk-RIB4S2IB.js";
23
23
  import "./chunk-R6IGDGX3.js";
24
- import "./chunk-3R5JGMHV.js";
24
+ import "./chunk-VE545BR3.js";
25
25
  import "./chunk-ECCWJHC6.js";
26
26
  import {
27
27
  AGENT_REASON,
28
28
  buildCommandWithYes,
29
29
  outputAgentError
30
- } from "./chunk-TJJ562C5.js";
30
+ } from "./chunk-TJLBCLEX.js";
31
31
  import "./chunk-GGP5R3FU.js";
32
32
  import {
33
33
  printError
34
- } from "./chunk-KBEX5MYS.js";
34
+ } from "./chunk-VAFU7DXZ.js";
35
35
  import {
36
36
  parseArguments
37
37
  } from "./chunk-XLKFJPMT.js";
@@ -13,28 +13,28 @@ import {
13
13
  requireVcrRepository,
14
14
  resolveVcrScope,
15
15
  validateVcrJsonOutput
16
- } from "./chunk-WE3TFESA.js";
16
+ } from "./chunk-TM3F7PLR.js";
17
17
  import "./chunk-G75NFPIT.js";
18
18
  import "./chunk-P65EEFTR.js";
19
19
  import "./chunk-KXDWXXJH.js";
20
20
  import {
21
21
  removeSubcommand
22
- } from "./chunk-ELA5VN3A.js";
23
- import "./chunk-B3JTF4CF.js";
24
- import "./chunk-A5KP5HAI.js";
25
- import "./chunk-J6LK45HT.js";
22
+ } from "./chunk-2MF3ZAVW.js";
23
+ import "./chunk-WC7IINFV.js";
24
+ import "./chunk-RIB4S2IB.js";
25
+ import "./chunk-GFCTRJI5.js";
26
26
  import "./chunk-R6IGDGX3.js";
27
- import "./chunk-3R5JGMHV.js";
27
+ import "./chunk-VE545BR3.js";
28
28
  import "./chunk-ECCWJHC6.js";
29
29
  import {
30
30
  AGENT_REASON,
31
31
  buildCommandWithYes,
32
32
  outputAgentError
33
- } from "./chunk-TJJ562C5.js";
33
+ } from "./chunk-TJLBCLEX.js";
34
34
  import "./chunk-GGP5R3FU.js";
35
35
  import {
36
36
  printError
37
- } from "./chunk-KBEX5MYS.js";
37
+ } from "./chunk-VAFU7DXZ.js";
38
38
  import {
39
39
  parseArguments
40
40
  } from "./chunk-XLKFJPMT.js";
@@ -9,7 +9,7 @@ import {
9
9
  handleRulesApiError,
10
10
  parseRulesFlagsAndScope,
11
11
  rulesItemPath
12
- } from "./chunk-ZRWSSPW5.js";
12
+ } from "./chunk-57G6HBJ4.js";
13
13
  import {
14
14
  formatCustomAlertMetric,
15
15
  formatCustomAlertTrigger,
@@ -18,8 +18,8 @@ import {
18
18
  isCustomAlertRule,
19
19
  parseCustomAlertQuery,
20
20
  renderAlertTable
21
- } from "./chunk-TEQKKTJQ.js";
22
- import "./chunk-SQAQED4U.js";
21
+ } from "./chunk-F7OXZLY2.js";
22
+ import "./chunk-XZLI27ES.js";
23
23
  import {
24
24
  formatDate
25
25
  } from "./chunk-GZLPFESR.js";
@@ -32,25 +32,24 @@ import "./chunk-FGDKMNEN.js";
32
32
  import "./chunk-PRWJUY5U.js";
33
33
  import {
34
34
  truncateMiddle
35
- } from "./chunk-RQ7H43CJ.js";
35
+ } from "./chunk-VDJN4WKH.js";
36
36
  import {
37
37
  validateJsonOutput
38
38
  } from "./chunk-KXDWXXJH.js";
39
39
  import {
40
40
  rulesInspectSubcommand
41
41
  } from "./chunk-UMA66MKW.js";
42
- import "./chunk-KT4XXKJK.js";
43
- import "./chunk-3R5JGMHV.js";
42
+ import "./chunk-VE545BR3.js";
44
43
  import "./chunk-ECCWJHC6.js";
45
44
  import {
46
45
  AGENT_REASON,
47
46
  buildCommandWithGlobalFlags,
48
47
  outputAgentError
49
- } from "./chunk-TJJ562C5.js";
48
+ } from "./chunk-TJLBCLEX.js";
50
49
  import "./chunk-GGP5R3FU.js";
51
50
  import {
52
51
  printError
53
- } from "./chunk-KBEX5MYS.js";
52
+ } from "./chunk-VAFU7DXZ.js";
54
53
  import {
55
54
  parseArguments
56
55
  } from "./chunk-XLKFJPMT.js";