@depup/vercel 58.4.4-depup.0 → 59.1.3-depup.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.
Files changed (119) hide show
  1. package/README.md +8 -9
  2. package/changes.json +7 -11
  3. package/dist/chunks/{add-245XOFJO.js → add-CUGPQYFW.js} +11 -11
  4. package/dist/chunks/{add-XH24V5VU.js → add-PP3PJPJV.js} +8 -8
  5. package/dist/chunks/{add-P7WBQMBW.js → add-PRG4KKYH.js} +45 -12
  6. package/dist/chunks/{build-M7NJYJPE.js → build-T22GMLY6.js} +11 -11
  7. package/dist/chunks/{chunk-AW5YINX6.js → chunk-2MF3ZAVW.js} +48 -6
  8. package/dist/chunks/{chunk-WR7JTCGL.js → chunk-3BU2UCGV.js} +1 -1
  9. package/dist/chunks/{chunk-MAHXF73X.js → chunk-3L2YLLHC.js} +1 -1
  10. package/dist/chunks/{chunk-ZGBBPJ6B.js → chunk-43DD2KNM.js} +254 -1539
  11. package/dist/chunks/{chunk-M5NOLAJ4.js → chunk-4HI7G6KG.js} +1 -1
  12. package/dist/chunks/chunk-4JKZ7SRX.js +559 -0
  13. package/dist/chunks/{chunk-Y5GTPWXB.js → chunk-57G6HBJ4.js} +3 -3
  14. package/dist/chunks/{chunk-2LBVX2H3.js → chunk-5DVMXOFT.js} +3 -3
  15. package/dist/chunks/{chunk-YCPUAG77.js → chunk-7NQLRE5V.js} +1 -1
  16. package/dist/chunks/{chunk-JLWQWYKO.js → chunk-BBSS3XIW.js} +2 -4
  17. package/dist/chunks/{chunk-IEDUCUDV.js → chunk-BCZFZETZ.js} +92 -46
  18. package/dist/chunks/{chunk-SJYAUEZR.js → chunk-DAWJOQF6.js} +52 -79
  19. package/dist/chunks/chunk-DEB45ND4.js +61 -0
  20. package/dist/chunks/{chunk-AQDWMAPM.js → chunk-DOMLWKKZ.js} +795 -516
  21. package/dist/chunks/{chunk-EBLH23AQ.js → chunk-F7OXZLY2.js} +6 -9
  22. package/dist/chunks/{chunk-J6LK45HT.js → chunk-GFCTRJI5.js} +16 -2
  23. package/dist/chunks/{chunk-V5P25P7F.js → chunk-GGPE5377.js} +5 -12
  24. package/dist/chunks/{chunk-4LDQIDRM.js → chunk-GMWRTZVZ.js} +9 -1
  25. package/dist/chunks/{chunk-NJUPUGOE.js → chunk-HT2XWSAJ.js} +1 -1
  26. package/dist/chunks/chunk-IKKUCZE7.js +96 -0
  27. package/dist/chunks/chunk-JKQWQA2T.js +39 -0
  28. package/dist/chunks/{chunk-XIG4GH62.js → chunk-JYEO6OJS.js} +188 -102
  29. package/dist/chunks/{chunk-HSYF5SI3.js → chunk-KTLFN5FV.js} +1 -1
  30. package/dist/chunks/{chunk-XPKWKPWA.js → chunk-KXDWXXJH.js} +27 -1
  31. package/dist/chunks/chunk-LNVZ3T7X.js +2908 -0
  32. package/dist/chunks/{chunk-NJ6QXKQD.js → chunk-M34ZRNDQ.js} +1 -1
  33. package/dist/chunks/chunk-MXLA3VQS.js +20 -0
  34. package/dist/chunks/{chunk-2SFMOCWR.js → chunk-PD7ZUXE7.js} +1 -1
  35. package/dist/chunks/chunk-QCVKGY2A.js +151 -0
  36. package/dist/chunks/{chunk-XE5VSQ25.js → chunk-QD5NX7RG.js} +1 -1
  37. package/dist/chunks/{chunk-4N7XLXM2.js → chunk-QQ6PH4RY.js} +1 -0
  38. package/dist/chunks/{chunk-A5KP5HAI.js → chunk-RIB4S2IB.js} +10 -1
  39. package/dist/chunks/{chunk-ZX2FSPWV.js → chunk-SJQEGGH7.js} +4 -4
  40. package/dist/chunks/{chunk-3QAUXPIR.js → chunk-SOKQBFF7.js} +1128 -162
  41. package/dist/chunks/chunk-SQGMTRZD.js +1385 -0
  42. package/dist/chunks/{chunk-TJJ562C5.js → chunk-TJLBCLEX.js} +15 -0
  43. package/dist/chunks/{chunk-62MH5KPX.js → chunk-TM3F7PLR.js} +7 -7
  44. package/dist/chunks/{chunk-2WILSD7J.js → chunk-TNKRSTMB.js} +1 -1
  45. package/dist/chunks/{chunk-4UYKSYKQ.js → chunk-UMA66MKW.js} +66 -2
  46. package/dist/chunks/{chunk-KT4XXKJK.js → chunk-VAFU7DXZ.js} +195 -3
  47. package/dist/chunks/{chunk-RQ7H43CJ.js → chunk-VDJN4WKH.js} +1 -1
  48. package/dist/chunks/{chunk-4CCY5OPH.js → chunk-VE545BR3.js} +5039 -3119
  49. package/dist/chunks/{chunk-B3JTF4CF.js → chunk-WC7IINFV.js} +10 -1
  50. package/dist/chunks/{chunk-YDUINEII.js → chunk-XZLI27ES.js} +7 -5
  51. package/dist/chunks/{chunk-4BUPRO5B.js → chunk-ZUVJISHS.js} +3 -3
  52. package/dist/chunks/{clear-HWIKQ4NC.js → clear-Z4IKUIN7.js} +8 -8
  53. package/dist/chunks/{compile-vercel-config-U5NRIMZ2.js → compile-vercel-config-PSVXFAZW.js} +4 -4
  54. package/dist/chunks/config-M5GMZ2X5.js +159 -0
  55. package/dist/chunks/{constants-3FSSR6E7.js → constants-YMCRE6IG.js} +5 -3
  56. package/dist/chunks/{delete-NVMGVD5Z.js → delete-5GRRDJSF.js} +5 -5
  57. package/dist/chunks/{delete-FZCOUFGN.js → delete-P4XIBY7T.js} +8 -8
  58. package/dist/chunks/{disable-ERM2BWEQ.js → disable-NT5NYVO7.js} +5 -5
  59. package/dist/chunks/{discard-KM5OLEN4.js → discard-TBNIEAJZ.js} +5 -5
  60. package/dist/chunks/{edit-HT3UTATZ.js → edit-DJ6MT6HA.js} +6 -6
  61. package/dist/chunks/{edit-TOSB2EMI.js → edit-UF3D2CCH.js} +9 -9
  62. package/dist/chunks/{enable-BQL6AOQV.js → enable-JTQBQMBO.js} +5 -5
  63. package/dist/chunks/{export-UOWQHOG3.js → export-OKMRGRVM.js} +5 -5
  64. package/dist/chunks/{image-F5SC6Q7Y.js → image-ARUJH4H5.js} +4 -4
  65. package/dist/chunks/import-builders-3NTMZM64.js +30 -0
  66. package/dist/chunks/{inspect-PZJM2CWT.js → inspect-5NETOGAI.js} +11 -12
  67. package/dist/chunks/{inspect-GKJ6T5H4.js → inspect-CHFKZKKP.js} +8 -8
  68. package/dist/chunks/{inspect-LGKOLH2O.js → inspect-FXZTQY62.js} +9 -9
  69. package/dist/chunks/{inspect-35FU5R62.js → inspect-PTXIBSYW.js} +11 -11
  70. package/dist/chunks/{inspect-5J5GSTOB.js → inspect-UXP2HDES.js} +8 -8
  71. package/dist/chunks/{list-2IIE7CAP.js → list-2WMIVJ2R.js} +31 -15
  72. package/dist/chunks/{list-ITFJYYQ2.js → list-ADI55WKW.js} +13 -14
  73. package/dist/chunks/{list-KZETH3ZE.js → list-DYCZA2VX.js} +6 -6
  74. package/dist/chunks/{login-BQPJCJEZ.js → login-YCSIQG6B.js} +11 -11
  75. package/dist/chunks/{ls-UXUEP54B.js → ls-2TKUIUK4.js} +14 -15
  76. package/dist/chunks/{ls-YSFWSM6J.js → ls-EOMIQLRH.js} +14 -15
  77. package/dist/chunks/{ls-7GHDK4MD.js → ls-PQFDGOJL.js} +17 -18
  78. package/dist/chunks/{ls-DL2LA35C.js → ls-RZVTIP5U.js} +14 -15
  79. package/dist/chunks/{ls-ZZFLH7PK.js → ls-VIOMDUGW.js} +17 -18
  80. package/dist/chunks/{open-ADNJQN5E.js → open-JYPWOXQD.js} +7 -7
  81. package/dist/chunks/{permissions-72SZCBIY.js → permissions-SGJWGEVD.js} +6 -6
  82. package/dist/chunks/{publish-OOAGSEBM.js → publish-ZUQHJAXL.js} +5 -5
  83. package/dist/chunks/{push-B6TZDXNF.js → push-XMVKG5A5.js} +11 -11
  84. package/dist/chunks/{query-LZWS5TDH.js → query-ZLJZEGZB.js} +240 -52
  85. package/dist/chunks/{reorder-MRHFKPMK.js → reorder-NVHDWMRU.js} +5 -5
  86. package/dist/chunks/{reply-BKTJXO3B.js → reply-PUUPUQ3V.js} +9 -9
  87. package/dist/chunks/{resolve-BKVGSGPN.js → resolve-5U2LJVE6.js} +8 -8
  88. package/dist/chunks/{restore-USR7SKWV.js → restore-OXIUY2UI.js} +5 -5
  89. package/dist/chunks/{rm-2UO6BT3A.js → rm-3IOCBNPE.js} +9 -9
  90. package/dist/chunks/{rm-37MKKV3I.js → rm-BZNKJRXU.js} +8 -8
  91. package/dist/chunks/{rm-VY3OHKFH.js → rm-OUI4ZB5R.js} +8 -8
  92. package/dist/chunks/{rm-KUWPNZIS.js → rm-Z2KYJ7XT.js} +11 -11
  93. package/dist/chunks/{rule-inspect-JVDOOTWK.js → rule-inspect-ZBJJCDQV.js} +17 -25
  94. package/dist/chunks/{rules-NTBFZBIF.js → rules-HEGAXXUN.js} +10 -7
  95. package/dist/chunks/{schema-6EZ72OVH.js → schema-7GVL3BNP.js} +65 -33
  96. package/dist/chunks/schema-ZYIJYA2E.js +425 -0
  97. package/dist/chunks/{tags-HNPC63QA.js → tags-3SCWCMNQ.js} +3 -3
  98. package/dist/chunks/{types-QTOA2BTQ.js → types-AJHILHO5.js} +3 -5
  99. package/dist/chunks/{update-LUYWNZP3.js → update-YR2GCCJN.js} +40 -9
  100. package/dist/commands/build/index.js +282 -2932
  101. package/dist/commands/deploy/index.js +397 -84
  102. package/dist/commands/dev/index.js +339 -194
  103. package/dist/commands/env/index.js +101 -163
  104. package/dist/commands/link/index.js +17 -23
  105. package/dist/commands/list/index.js +11 -13
  106. package/dist/commands-bulk.js +10189 -4062
  107. package/dist/help.js +1 -1
  108. package/dist/index.js +141 -114
  109. package/dist/vc.js +18 -17
  110. package/dist/version.mjs +2 -1
  111. package/package.json +80 -77
  112. package/dist/chunks/chunk-2FMPLU44.js +0 -106
  113. package/dist/chunks/chunk-2MAPZXVV.js +0 -206
  114. package/dist/chunks/chunk-CPFNFVCL.js +0 -85
  115. package/dist/chunks/chunk-GFG6QDIE.js +0 -101
  116. package/dist/chunks/chunk-KBEX5MYS.js +0 -208
  117. package/dist/chunks/chunk-UE3JUVUZ.js +0 -1474
  118. package/dist/chunks/{chunk-BUZRVER7.js → chunk-P65EEFTR.js} +3 -3
  119. /package/dist/{commands/dev/next-dev-websocket-shim-preload.cjs → runtime-assets/node-preloads/next-dev-websocket.cjs} +0 -0
@@ -12,10 +12,10 @@ import {
12
12
  } from "./chunk-FGDKMNEN.js";
13
13
  import {
14
14
  truncateMiddle
15
- } from "./chunk-RQ7H43CJ.js";
15
+ } from "./chunk-VDJN4WKH.js";
16
16
  import {
17
17
  table
18
- } from "./chunk-KT4XXKJK.js";
18
+ } from "./chunk-VAFU7DXZ.js";
19
19
 
20
20
  // src/commands/alerts/format.ts
21
21
  function renderAlertTable(rows, hsep = 3) {
@@ -65,21 +65,18 @@ function humanizeReference(value, opts = {}) {
65
65
  return opts.case === "title" ? label : label.toLowerCase();
66
66
  }).join(" / ");
67
67
  }
68
- function formatRuleScope(projectId, {
68
+ function formatRuleScope(rule, {
69
69
  projectIdMaxLength = 48,
70
70
  filterMaxLength = 80
71
71
  } = {}) {
72
+ const { projectId } = rule;
72
73
  if (!projectId) {
73
74
  return "team-wide";
74
75
  }
75
- const projectIdMatch = projectId.match(/^projectId eq '([^']+)'$/);
76
- if (projectIdMatch?.[1]) {
77
- return `project: ${truncateMiddle(projectIdMatch[1], projectIdMaxLength)}`;
78
- }
79
- if (!/\s/.test(projectId)) {
76
+ if (isCustomAlertRule(rule)) {
80
77
  return `project: ${truncateMiddle(projectId, projectIdMaxLength)}`;
81
78
  }
82
- return `project filter: ${truncateMiddle(projectId, filterMaxLength)}`;
79
+ return truncateMiddle(projectId, filterMaxLength);
83
80
  }
84
81
  function isCustomAlertRule(rule) {
85
82
  return Boolean(rule.customAlert) || Boolean(
@@ -24,11 +24,19 @@ var projectScopeOption = {
24
24
  shorthand: "p",
25
25
  description: "Project name or ID (defaults to the linked project)."
26
26
  };
27
+ var nextOption = {
28
+ name: "next",
29
+ shorthand: null,
30
+ type: String,
31
+ deprecated: false,
32
+ description: "Continue from a previous response",
33
+ argument: "CURSOR"
34
+ };
27
35
  var cursorOption = {
28
36
  name: "cursor",
29
37
  shorthand: "c",
30
38
  type: String,
31
- deprecated: false,
39
+ deprecated: true,
32
40
  description: "Cursor from a previous page to continue listing from",
33
41
  argument: "STRING"
34
42
  };
@@ -37,7 +45,13 @@ var permissionsLsSubcommand = {
37
45
  aliases: ["list"],
38
46
  description: "List teams with access to a repository",
39
47
  arguments: [],
40
- options: [projectScopeOption, limitOption, cursorOption, formatOption],
48
+ options: [
49
+ projectScopeOption,
50
+ limitOption,
51
+ nextOption,
52
+ cursorOption,
53
+ formatOption
54
+ ],
41
55
  examples: [
42
56
  {
43
57
  name: "List teams with access to a repository",
@@ -4,19 +4,12 @@ import { dirname as __dirname_ } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
- import {
8
- require_source
9
- } from "./chunk-S7KYDPEM.js";
10
- import {
11
- __toESM
12
- } from "./chunk-TZ2YI2VH.js";
13
7
 
14
- // src/util/output/highlight.ts
15
- var import_chalk = __toESM(require_source(), 1);
16
- function highlight(text) {
17
- return import_chalk.default.bold.underline(text);
18
- }
8
+ // src/util/constants.ts
9
+ var SENTRY_DSN = void 0;
10
+ var BUILD_LABEL = void 0;
19
11
 
20
12
  export {
21
- highlight
13
+ SENTRY_DSN,
14
+ BUILD_LABEL
22
15
  };
@@ -83,13 +83,21 @@ var listSubcommand = {
83
83
  description: "unresolved (default), resolved, or all"
84
84
  },
85
85
  {
86
- name: "page",
86
+ name: "page-path",
87
87
  shorthand: null,
88
88
  type: [String],
89
89
  argument: "PATH",
90
90
  deprecated: false,
91
91
  description: "Filter by recorded page path or glob (repeatable). Note: rewrites may record a different path than the browser URL"
92
92
  },
93
+ {
94
+ name: "page",
95
+ shorthand: null,
96
+ type: [String],
97
+ argument: "PATH",
98
+ deprecated: true,
99
+ description: "Filter by recorded page path or glob"
100
+ },
93
101
  {
94
102
  name: "author",
95
103
  shorthand: null,
@@ -173,7 +173,7 @@ async function isPluginInstalledForTarget(target) {
173
173
  return false;
174
174
  }
175
175
  async function confirm(client, message) {
176
- if (!client.stdin.isTTY) {
176
+ if (client.nonInteractive || !client.stdin.isTTY) {
177
177
  return false;
178
178
  }
179
179
  return client.input.confirm(message, true);
@@ -0,0 +1,96 @@
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
+ isJSONObject
9
+ } from "./chunk-DAWJOQF6.js";
10
+ import {
11
+ getProjectByNameOrId
12
+ } from "./chunk-VE545BR3.js";
13
+ import {
14
+ AGENT_REASON,
15
+ outputAgentError
16
+ } from "./chunk-TJLBCLEX.js";
17
+ import {
18
+ ProjectNotFound,
19
+ isAPIError
20
+ } from "./chunk-SOFC4MLS.js";
21
+ import {
22
+ output_manager_default
23
+ } from "./chunk-OX7KI3LF.js";
24
+
25
+ // src/commands/alerts/rules/custom-alert-query.ts
26
+ async function resolveCustomAlertProjectName(client, scope, projectId) {
27
+ if (scope.projectId === projectId && scope.projectName) {
28
+ return scope.projectName;
29
+ }
30
+ try {
31
+ const project = await getProjectByNameOrId(client, projectId, scope.teamId);
32
+ return project instanceof ProjectNotFound ? void 0 : project.name;
33
+ } catch (error) {
34
+ if (isAPIError(error)) {
35
+ return void 0;
36
+ }
37
+ throw error;
38
+ }
39
+ }
40
+ function parseCustomAlertQueryBody(client, body) {
41
+ const customAlert = body.customAlert;
42
+ if (!isJSONObject(customAlert)) {
43
+ return void 0;
44
+ }
45
+ const queryJsonString = customAlert.queryJsonString;
46
+ if (typeof queryJsonString !== "string") {
47
+ return void 0;
48
+ }
49
+ let query;
50
+ try {
51
+ query = JSON.parse(queryJsonString);
52
+ } catch {
53
+ const message = "Invalid JSON in customAlert.queryJsonString.";
54
+ outputAgentError(
55
+ client,
56
+ {
57
+ status: "error",
58
+ reason: AGENT_REASON.INVALID_ARGUMENTS,
59
+ message,
60
+ hint: "Provide queryJsonString as an escaped JSON string. Run `vercel alerts rules schema --type custom_alert` for examples."
61
+ },
62
+ 1
63
+ );
64
+ output_manager_default.error(message);
65
+ return 1;
66
+ }
67
+ if (!isJSONObject(query)) {
68
+ return void 0;
69
+ }
70
+ return { customAlert, query };
71
+ }
72
+ function setMissingCustomAlertProjectScope(parsedQuery, teamId, projectId, projectName) {
73
+ const existingScope = parsedQuery.query.scope;
74
+ if (existingScope !== void 0 && !isJSONObject(existingScope)) {
75
+ return;
76
+ }
77
+ const projectScope = existingScope ?? {
78
+ type: "project",
79
+ ownerId: teamId,
80
+ projectIds: [projectId]
81
+ };
82
+ if (!Object.hasOwn(projectScope, "projectId")) {
83
+ projectScope.projectId = projectId;
84
+ }
85
+ if (projectName && !Object.hasOwn(projectScope, "projectName")) {
86
+ projectScope.projectName = projectName;
87
+ }
88
+ parsedQuery.query.scope = projectScope;
89
+ parsedQuery.customAlert.queryJsonString = JSON.stringify(parsedQuery.query);
90
+ }
91
+
92
+ export {
93
+ resolveCustomAlertProjectName,
94
+ parseCustomAlertQueryBody,
95
+ setMissingCustomAlertProjectScope
96
+ };
@@ -0,0 +1,39 @@
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
+ parseArguments
9
+ } from "./chunk-XLKFJPMT.js";
10
+ import {
11
+ require_source
12
+ } from "./chunk-S7KYDPEM.js";
13
+ import {
14
+ __toESM
15
+ } from "./chunk-TZ2YI2VH.js";
16
+
17
+ // src/util/config/global-path.ts
18
+ import path from "path";
19
+ import * as config from "@vercel/cli-config";
20
+ function getGlobalPathConfig2(argvSlice = process.argv.slice(2), cwd = process.cwd()) {
21
+ const args = parseArguments(argvSlice, {}, { permissive: true });
22
+ const confFlag = args.flags["--global-config"];
23
+ if (confFlag) {
24
+ return path.resolve(cwd, confFlag);
25
+ } else {
26
+ return config.getGlobalPathConfig();
27
+ }
28
+ }
29
+
30
+ // src/util/output/highlight.ts
31
+ var import_chalk = __toESM(require_source(), 1);
32
+ function highlight(text) {
33
+ return import_chalk.default.bold.underline(text);
34
+ }
35
+
36
+ export {
37
+ getGlobalPathConfig2 as getGlobalPathConfig,
38
+ highlight
39
+ };
@@ -16,16 +16,16 @@ import {
16
16
  } from "./chunk-A3NYPUKZ.js";
17
17
  import {
18
18
  ellipsizeMiddle
19
- } from "./chunk-RQ7H43CJ.js";
19
+ } from "./chunk-VDJN4WKH.js";
20
20
  import {
21
21
  elapsed
22
22
  } from "./chunk-VXYGCOKL.js";
23
- import {
24
- table
25
- } from "./chunk-KT4XXKJK.js";
26
23
  import {
27
24
  require_ms
28
25
  } from "./chunk-GGP5R3FU.js";
26
+ import {
27
+ table
28
+ } from "./chunk-VAFU7DXZ.js";
29
29
  import {
30
30
  require_source
31
31
  } from "./chunk-S7KYDPEM.js";
@@ -125,26 +125,101 @@ function toGranularityMsFromDuration(duration) {
125
125
  return duration.days * DAY_MS;
126
126
  }
127
127
 
128
+ // src/commands/metrics/types.ts
129
+ var CANONICAL_AGGREGATIONS = [
130
+ "count",
131
+ "sum",
132
+ "avg",
133
+ "min",
134
+ "max",
135
+ "p50",
136
+ "p75",
137
+ "p90",
138
+ "p95",
139
+ "p99"
140
+ ];
141
+ function isCanonicalAggregation(aggregation) {
142
+ return CANONICAL_AGGREGATIONS.includes(aggregation);
143
+ }
144
+
145
+ // src/commands/metrics/metric-units.ts
146
+ var DURATION_UNITS = /* @__PURE__ */ new Set([
147
+ "nanoseconds",
148
+ "microseconds",
149
+ "milliseconds",
150
+ "seconds",
151
+ "minutes",
152
+ "hours",
153
+ "days"
154
+ ]);
155
+ function normalizeMetricUnit(unit) {
156
+ return unit.trim().toLowerCase().replace(/[_\s]+/g, " ");
157
+ }
158
+ function getPreferredCustomMetricAggregation(unit) {
159
+ const normalizedUnit = normalizeMetricUnit(unit);
160
+ if (DURATION_UNITS.has(normalizedUnit)) {
161
+ return "p75";
162
+ }
163
+ if (normalizedUnit === "percent") {
164
+ return "avg";
165
+ }
166
+ return "sum";
167
+ }
168
+ function getDefaultCustomMetricAggregation(unit, aggregations) {
169
+ const preferredAggregation = getPreferredCustomMetricAggregation(unit);
170
+ if (aggregations?.includes(preferredAggregation)) {
171
+ return preferredAggregation;
172
+ }
173
+ if (aggregations?.includes("sum")) {
174
+ return "sum";
175
+ }
176
+ return aggregations?.find(isCanonicalAggregation) ?? "sum";
177
+ }
178
+
128
179
  // src/commands/metrics/text-output.ts
129
180
  var import_chalk = __toESM(require_source(), 1);
130
181
  var GROUP_KEY_DELIMITER = "";
131
182
  var MAX_SPARKLINE_LENGTH = 120;
132
- var COUNT_UNITS = /* @__PURE__ */ new Set(["count", "usd", "us dollars", "dollars"]);
133
- var DURATION_UNITS = /* @__PURE__ */ new Set(["milliseconds", "seconds"]);
134
- var BYTES_UNITS = /* @__PURE__ */ new Set([
135
- "bytes",
136
- "megabytes",
137
- "gigabyte hour",
138
- "gigabyte_hour",
139
- "gigabyte hours",
140
- "gigabyte_hours"
141
- ]);
142
- var RATIO_UNITS = /* @__PURE__ */ new Set(["ratio", "percent"]);
183
+ var DURATION_SCALE_MS = {
184
+ seconds: 1e3,
185
+ minutes: 6e4,
186
+ hours: 36e5,
187
+ days: 864e5
188
+ };
189
+ var BYTE_SCALE = {
190
+ bytes: 1,
191
+ kilobytes: 1e3,
192
+ megabytes: 1e6,
193
+ gigabytes: 1e9,
194
+ terabytes: 1e12,
195
+ petabytes: 1e15
196
+ };
197
+ var COMPACT_NUMBER_FORMATTER = new Intl.NumberFormat("en-US", {
198
+ notation: "compact",
199
+ compactDisplay: "short"
200
+ });
201
+ var TWO_FRACTION_NUMBER_FORMATTER = new Intl.NumberFormat("en-US", {
202
+ maximumFractionDigits: 2
203
+ });
204
+ var TWO_SIGNIFICANT_NUMBER_FORMATTER = new Intl.NumberFormat("en-US", {
205
+ minimumSignificantDigits: 2,
206
+ maximumSignificantDigits: 2,
207
+ maximumFractionDigits: 2
208
+ });
209
+ var PERCENTAGE_FORMATTER = new Intl.NumberFormat("en-US", {
210
+ style: "unit",
211
+ unit: "percent",
212
+ unitDisplay: "narrow",
213
+ maximumFractionDigits: 1
214
+ });
215
+ var USD_FORMATTER = new Intl.NumberFormat("en-US", {
216
+ style: "currency",
217
+ currency: "USD",
218
+ minimumFractionDigits: 2,
219
+ maximumFractionDigits: 2
220
+ });
143
221
  var BLOCKS = ["\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"];
144
222
  var MISSING_CHAR = "\xB7";
145
- function normalizeUnit(unit) {
146
- return unit.trim().toLowerCase().replace(/[_\s]+/g, " ");
147
- }
148
223
  function isAggregationWithDimension(aggregation) {
149
224
  const [, dimension] = aggregation.split("/");
150
225
  return Boolean(dimension);
@@ -180,36 +255,8 @@ function formatPeriodSpan(startInput, endInput) {
180
255
  }
181
256
  return elapsed(durationMs);
182
257
  }
183
- function formatUnitLabel(unit) {
184
- switch (normalizeUnit(unit)) {
185
- case "milliseconds":
186
- return "ms";
187
- case "seconds":
188
- return "s";
189
- case "usd":
190
- case "us dollars":
191
- return "USD";
192
- case "gigabyte hour":
193
- case "gigabyte hours":
194
- return "GB-h";
195
- default:
196
- return unit;
197
- }
198
- }
199
- function isCountIntegerDisplay(measureType, aggregation) {
200
- return measureType === "count" && aggregation === "sum";
201
- }
202
- function formatNumber(value, measureType, aggregation, opts) {
203
- if (isCountIntegerDisplay(measureType, aggregation)) {
204
- if (opts?.preserveFractionalCountSum && !Number.isInteger(value)) {
205
- return formatDecimal(value);
206
- }
207
- return formatCount(value);
208
- }
209
- return formatDecimal(value);
210
- }
211
258
  function getStatColumns(aggregation) {
212
- if (aggregation === "sum") {
259
+ if (aggregation === "sum" || aggregation === "count") {
213
260
  return ["total", "avg", "min", "max"];
214
261
  }
215
262
  return ["avg", "min", "max"];
@@ -250,13 +297,13 @@ function normalizeTimestampToIso(timestamp) {
250
297
  }
251
298
  return new Date(parsed).toISOString();
252
299
  }
253
- function formatStatCell(column, stats, measureType, aggregation, periodStart, periodEnd) {
300
+ function formatStatCell(column, stats, periodStart, periodEnd, formatValue) {
254
301
  switch (column) {
255
302
  case "total":
256
- return formatNumber(stats.total, measureType, aggregation);
303
+ return formatValue(stats.total);
257
304
  case "avg":
258
- return formatNumber(stats.avg, measureType, aggregation, {
259
- preserveFractionalCountSum: true
305
+ return formatValue(stats.avg, {
306
+ preserveFractionalCount: true
260
307
  });
261
308
  case "min": {
262
309
  const ts = formatMinMaxTimestamp(
@@ -264,7 +311,7 @@ function formatStatCell(column, stats, measureType, aggregation, periodStart, pe
264
311
  periodStart,
265
312
  periodEnd
266
313
  );
267
- return `${formatNumber(stats.min.value, measureType, aggregation)} at ${ts}`;
314
+ return `${formatValue(stats.min.value)} at ${ts}`;
268
315
  }
269
316
  case "max": {
270
317
  const ts = formatMinMaxTimestamp(
@@ -272,7 +319,7 @@ function formatStatCell(column, stats, measureType, aggregation, periodStart, pe
272
319
  periodStart,
273
320
  periodEnd
274
321
  );
275
- return `${formatNumber(stats.max.value, measureType, aggregation)} at ${ts}`;
322
+ return `${formatValue(stats.max.value)} at ${ts}`;
276
323
  }
277
324
  }
278
325
  }
@@ -312,22 +359,6 @@ function buildSeriesTimestamps(periodStart, periodEnd, granularityMs, observedTi
312
359
  }
313
360
  return buildObservedTimestamps(observedTimestamps, granularityMs);
314
361
  }
315
- function getMeasureType(unit) {
316
- const normalized = normalizeUnit(unit);
317
- if (COUNT_UNITS.has(normalized)) {
318
- return "count";
319
- }
320
- if (DURATION_UNITS.has(normalized)) {
321
- return "duration";
322
- }
323
- if (BYTES_UNITS.has(normalized)) {
324
- return "bytes";
325
- }
326
- if (RATIO_UNITS.has(normalized)) {
327
- return "ratio";
328
- }
329
- return "ratio";
330
- }
331
362
  function formatCount(n) {
332
363
  return Math.round(n).toLocaleString("en-US");
333
364
  }
@@ -349,6 +380,88 @@ function formatDecimal(n) {
349
380
  const trimmed = fixed.replace(/(\.\d*?[1-9])0+$/, "$1").replace(/\.0+$/, "").replace(/\.$/, "");
350
381
  return `${sign}${trimmed}`;
351
382
  }
383
+ function formatDuration(durationMs) {
384
+ const durationSeconds = durationMs / 1e3;
385
+ if (durationMs < 1e3) {
386
+ return `${durationMs.toFixed(0)}ms`;
387
+ }
388
+ if (durationMs < 5e3) {
389
+ return `${Math.round(durationSeconds * 100) / 100}s`;
390
+ }
391
+ if (durationSeconds < 60) {
392
+ return `${durationSeconds.toFixed(0)}s`;
393
+ }
394
+ if (durationSeconds < 3600) {
395
+ return `${(durationSeconds / 60).toFixed(0)}m`;
396
+ }
397
+ return `${(durationSeconds / 3600).toFixed(0)}h`;
398
+ }
399
+ function formatBytes(bytes) {
400
+ if (bytes === 0) {
401
+ return "0 Bytes";
402
+ }
403
+ const units = ["Bytes", "KB", "MB", "GB", "TB", "PB"];
404
+ const absoluteBytes = Math.abs(bytes);
405
+ let unitIndex = Math.min(
406
+ units.length - 1,
407
+ Math.max(0, Math.floor(Math.log(absoluteBytes) / Math.log(1e3)))
408
+ );
409
+ let value = bytes / 1e3 ** unitIndex;
410
+ if (unitIndex === 1 || unitIndex === 2) {
411
+ value = Math.round(value);
412
+ if (Math.abs(value) === 1e3 && unitIndex < units.length - 1) {
413
+ value /= 1e3;
414
+ unitIndex += 1;
415
+ }
416
+ }
417
+ return `${TWO_FRACTION_NUMBER_FORMATTER.format(value)} ${units[unitIndex]}`;
418
+ }
419
+ function formatMetricValue(value, baseUnit, aggregation, opts) {
420
+ const formatCountValue = () => opts?.preserveFractionalCount && !Number.isInteger(value) ? formatDecimal(value) : formatCount(value);
421
+ if (isAggregationWithDimension(aggregation) || aggregation === "count") {
422
+ return formatCountValue();
423
+ }
424
+ const unit = normalizeMetricUnit(baseUnit ?? "units");
425
+ if (aggregation === "percent" || unit === "percent") {
426
+ return PERCENTAGE_FORMATTER.format(value);
427
+ }
428
+ if (aggregation === "unique") {
429
+ return COMPACT_NUMBER_FORMATTER.format(value);
430
+ }
431
+ const withRateSuffix = (formatted2) => aggregation === "persecond" ? `${formatted2}/s` : formatted2;
432
+ if (unit === "milliseconds") {
433
+ return withRateSuffix(formatDuration(value));
434
+ }
435
+ const durationScale = DURATION_SCALE_MS[unit];
436
+ if (durationScale) {
437
+ return withRateSuffix(formatDuration(value * durationScale));
438
+ }
439
+ if (unit === "nanoseconds" || unit === "microseconds") {
440
+ const suffix = unit === "nanoseconds" ? " ns" : " \xB5s";
441
+ const formatted2 = TWO_FRACTION_NUMBER_FORMATTER.format(value);
442
+ return withRateSuffix(`${formatted2}${suffix}`);
443
+ }
444
+ const byteScale = BYTE_SCALE[unit];
445
+ if (byteScale) {
446
+ return withRateSuffix(formatBytes(value * byteScale));
447
+ }
448
+ if (unit === "gigabyte hour" || unit === "gigabyte hours") {
449
+ const formatted2 = TWO_SIGNIFICANT_NUMBER_FORMATTER.format(value);
450
+ return withRateSuffix(`${formatted2} GB-hrs`);
451
+ }
452
+ if (unit === "usd" || unit === "us dollars" || unit === "dollars") {
453
+ return withRateSuffix(USD_FORMATTER.format(value));
454
+ }
455
+ if (unit === "count" && aggregation === "sum") {
456
+ return formatCountValue();
457
+ }
458
+ const formatted = COMPACT_NUMBER_FORMATTER.format(value);
459
+ const unitLabel = baseUnit?.trim();
460
+ if (!unitLabel || unit === "units" || unit === "count" || unit === "ratio") {
461
+ return withRateSuffix(formatted);
462
+ }
463
+ return withRateSuffix(`${formatted} ${unitLabel}`);
464
+ }
352
465
  function formatMinMaxTimestamp(date, periodStart, periodEnd) {
353
466
  const sameDay = periodStart.getUTCFullYear() === periodEnd.getUTCFullYear() && periodStart.getUTCMonth() === periodEnd.getUTCMonth() && periodStart.getUTCDate() === periodEnd.getUTCDate();
354
467
  if (sameDay) {
@@ -542,9 +655,6 @@ function formatMetadataHeader(opts) {
542
655
  value: `${opts.teamName ?? opts.scope.ownerId} (all projects)`
543
656
  });
544
657
  }
545
- if (opts.unit && normalizeUnit(opts.unit) !== "count") {
546
- rows.push({ key: "Units", value: formatUnitLabel(opts.unit) });
547
- }
548
658
  if (!opts.compact && typeof opts.groupCount === "number") {
549
659
  rows.push({ key: "Groups", value: String(opts.groupCount) });
550
660
  }
@@ -568,10 +678,9 @@ function formatSummaryTable(opts) {
568
678
  (column) => formatStatCell(
569
679
  column,
570
680
  row.stats,
571
- opts.measureType,
572
- opts.aggregation,
573
681
  opts.periodStart,
574
- opts.periodEnd
682
+ opts.periodEnd,
683
+ opts.formatValue
575
684
  )
576
685
  )
577
686
  );
@@ -617,33 +726,9 @@ function formatSparklineSection(groupRows, sparklines, groupByFields, compact =
617
726
  return compact ? chart : `sparklines:
618
727
  ${chart}`;
619
728
  }
620
- function getEffectiveDisplay(baseUnit, aggregation) {
621
- if (isAggregationWithDimension(aggregation)) {
622
- return { displayUnit: void 0, measureType: "count" };
623
- }
624
- switch (aggregation) {
625
- case "percent":
626
- return { displayUnit: "%", measureType: "ratio" };
627
- case "persecond": {
628
- const label = baseUnit ? formatUnitLabel(baseUnit) : void 0;
629
- return {
630
- displayUnit: label ? `${label}/s` : void 0,
631
- measureType: getMeasureType(baseUnit ?? "ratio")
632
- };
633
- }
634
- default:
635
- return {
636
- displayUnit: baseUnit,
637
- measureType: getMeasureType(baseUnit ?? "ratio")
638
- };
639
- }
640
- }
641
729
  function formatText(response, opts) {
642
730
  const rollupColumn = getRollupColumnName(opts.metric, opts.aggregation);
643
- const { displayUnit, measureType } = getEffectiveDisplay(
644
- opts.metricUnit,
645
- opts.aggregation
646
- );
731
+ const formatValue = (value, formatOptions) => formatMetricValue(value, opts.metricUnit, opts.aggregation, formatOptions);
647
732
  const granularityMs = toGranularityMsFromDuration(opts.granularity);
648
733
  const orderMetadata = getResolvedOrderMetadata(opts, response);
649
734
  const { groups, series, groupValues } = extractGroupedSeries(
@@ -674,7 +759,6 @@ function formatText(response, opts) {
674
759
  scope: opts.scope,
675
760
  projectName: opts.projectName,
676
761
  teamName: opts.teamName,
677
- unit: displayUnit,
678
762
  groupCount: opts.groupBy.length > 0 ? groups.length : void 0,
679
763
  compact: opts.presentation?.compact
680
764
  });
@@ -705,10 +789,10 @@ No data found for this period.
705
789
  const summaryTable = formatSummaryTable({
706
790
  rows: summaryRows,
707
791
  groupByFields: opts.groupBy,
708
- measureType,
709
792
  aggregation: opts.aggregation,
710
793
  periodStart: new Date(opts.periodStart),
711
794
  periodEnd: new Date(opts.periodEnd),
795
+ formatValue,
712
796
  ansiAwareGroupValues: opts.presentation?.compact
713
797
  });
714
798
  const groupedOutput = opts.groupBy.length > 0;
@@ -726,5 +810,7 @@ No data found for this period.
726
810
  export {
727
811
  computeGranularity,
728
812
  toGranularityMsFromDuration,
813
+ isCanonicalAggregation,
814
+ getDefaultCustomMetricAggregation,
729
815
  formatText
730
816
  };
@@ -8,7 +8,7 @@ import {
8
8
  formatCondition,
9
9
  formatTransform,
10
10
  isTargetTransform
11
- } from "./chunk-4BUPRO5B.js";
11
+ } from "./chunk-ZUVJISHS.js";
12
12
  import {
13
13
  output_manager_default
14
14
  } from "./chunk-OX7KI3LF.js";