vercel 56.3.2 → 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.
Files changed (66) hide show
  1. package/dist/chunks/{add-DVEAUH7N.js → add-2HLAH42D.js} +2 -2
  2. package/dist/chunks/{add-2ITAPI7M.js → add-XY2LNFK3.js} +3 -3
  3. package/dist/chunks/{chunk-2CEGMXO6.js → chunk-2KNVJ7ET.js} +76 -2
  4. package/dist/chunks/{chunk-573XYQ3D.js → chunk-4QRRJEYO.js} +2 -2
  5. package/dist/chunks/{chunk-4Z5LC2CI.js → chunk-6RTK6BWX.js} +4 -96
  6. package/dist/chunks/{chunk-AVJRWFTM.js → chunk-BRTMH4PL.js} +1 -1
  7. package/dist/chunks/{chunk-FPMWXL3R.js → chunk-C4TEOOGB.js} +1 -1
  8. package/dist/chunks/{chunk-BZXHF66T.js → chunk-EJNFC5AV.js} +1 -1
  9. package/dist/chunks/{chunk-WQN52QMS.js → chunk-ENIJVO7C.js} +2 -2
  10. package/dist/chunks/{query-K2TJKOAL.js → chunk-F5OMERHI.js} +65 -411
  11. package/dist/chunks/{chunk-BFFE4FAO.js → chunk-IN3RG4AU.js} +1 -1
  12. package/dist/chunks/{chunk-O3UHQI3T.js → chunk-JGXABANG.js} +1 -1
  13. package/dist/chunks/{chunk-ZKKJEOQT.js → chunk-JIK3GTU3.js} +1 -1
  14. package/dist/chunks/{chunk-5FF4WXVM.js → chunk-K6YMSJMZ.js} +4 -4
  15. package/dist/chunks/{chunk-5POUHPEH.js → chunk-ORMDX3GR.js} +1 -1
  16. package/dist/chunks/{chunk-SRIA62TV.js → chunk-OSXJ6G4O.js} +3 -3
  17. package/dist/chunks/{chunk-TVLLFY7M.js → chunk-PEC4ROHM.js} +4 -4
  18. package/dist/chunks/{chunk-HZAINEXG.js → chunk-QX4337BT.js} +3 -2
  19. package/dist/chunks/{chunk-3OZQ7KHZ.js → chunk-S7HMSWGQ.js} +2 -2
  20. package/dist/chunks/{chunk-GB3QQGZU.js → chunk-SLCLT4P5.js} +1 -1
  21. package/dist/chunks/{chunk-QW4XUBC3.js → chunk-UA3D44SL.js} +1 -1
  22. package/dist/chunks/{chunk-JQBH4QTB.js → chunk-VZGX4CKB.js} +1 -1
  23. package/dist/chunks/{chunk-OK6EYKRX.js → chunk-WM3UMX65.js} +1 -1
  24. package/dist/chunks/chunk-Z7NPYIZ6.js +116 -0
  25. package/dist/chunks/{compile-vercel-config-P3KRRAC6.js → compile-vercel-config-4Q4YZ44O.js} +1 -1
  26. package/dist/chunks/{delete-OXEMVOQE.js → delete-AUDPLCMU.js} +2 -2
  27. package/dist/chunks/{disable-DZA53CJA.js → disable-WFPXR7GZ.js} +2 -2
  28. package/dist/chunks/{discard-3E7Z7CKD.js → discard-RVFKIZZG.js} +2 -2
  29. package/dist/chunks/{edit-UM6TWX2Z.js → edit-KO5KX4WU.js} +3 -3
  30. package/dist/chunks/{enable-3SH6X23Z.js → enable-I5HE32DI.js} +2 -2
  31. package/dist/chunks/{export-TLQERLQP.js → export-4Y5L2TOT.js} +2 -2
  32. package/dist/chunks/{image-YKGEEC2A.js → image-QC5MVWKN.js} +3 -3
  33. package/dist/chunks/{inspect-34OE66PO.js → inspect-BULBAPNR.js} +2 -2
  34. package/dist/chunks/{inspect-652QJ33O.js → inspect-JUGFKEGR.js} +2 -2
  35. package/dist/chunks/{inspect-QW6RSV7Z.js → inspect-PJDCPARM.js} +2 -2
  36. package/dist/chunks/{inspect-S6X6PCGS.js → inspect-Q5BKZNVI.js} +2 -2
  37. package/dist/chunks/{list-OVWTXBSN.js → list-FJT44SB6.js} +1 -1
  38. package/dist/chunks/{list-IWXFZBH7.js → list-N7OA4FBI.js} +2 -2
  39. package/dist/chunks/{login-S77F2DLW.js → login-BPE774JW.js} +2 -2
  40. package/dist/chunks/{ls-J4HHGSFU.js → ls-26VFGQ6P.js} +3 -3
  41. package/dist/chunks/{ls-SAY4VQIT.js → ls-E47M6P5O.js} +2 -2
  42. package/dist/chunks/{ls-FQIWFI4K.js → ls-H52WO65Y.js} +2 -2
  43. package/dist/chunks/{ls-PQPRURTJ.js → ls-YV554CRJ.js} +2 -2
  44. package/dist/chunks/{publish-LWCEDLGX.js → publish-DUTEBRX3.js} +2 -2
  45. package/dist/chunks/query-QDOKUCHX.js +391 -0
  46. package/dist/chunks/{reorder-J6OONT76.js → reorder-L2M3YGJ4.js} +2 -2
  47. package/dist/chunks/{restore-3ME4ZHFW.js → restore-BVDNAJVC.js} +2 -2
  48. package/dist/chunks/{rm-EHEJRXQJ.js → rm-4OQ7G6UX.js} +2 -2
  49. package/dist/chunks/{rm-XOUHC6CU.js → rm-7KSHXSTB.js} +3 -3
  50. package/dist/chunks/{rm-63AGQFIQ.js → rm-VHWBHG3A.js} +2 -2
  51. package/dist/chunks/{rule-inspect-3PRCEXIB.js → rule-inspect-AT6IEOUF.js} +3 -3
  52. package/dist/chunks/{rules-UBSIW5ZQ.js → rules-SQFCUKWS.js} +6 -6
  53. package/dist/chunks/{schema-I4SXEWLS.js → schema-PWSCMD24.js} +5 -5
  54. package/dist/chunks/{tags-HF2YOQ4V.js → tags-BT7ZGJP2.js} +2 -2
  55. package/dist/chunks/{update-RRMAOQDP.js → update-PTDGBKEH.js} +3 -3
  56. package/dist/commands/build/index.js +9 -9
  57. package/dist/commands/deploy/index.js +9 -9
  58. package/dist/commands/dev/index.js +7 -7
  59. package/dist/commands/env/index.js +4 -4
  60. package/dist/commands/link/index.js +6 -6
  61. package/dist/commands/list/index.js +2 -2
  62. package/dist/commands-bulk.js +411 -48
  63. package/dist/index.js +7 -7
  64. package/dist/version.mjs +1 -1
  65. package/package.json +12 -12
  66. package/dist/chunks/chunk-A3NYPUKZ.js +0 -17
@@ -5,8 +5,15 @@ const require = __createRequire(import.meta.url);
5
5
  const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
7
  import {
8
+ computeGranularity,
9
+ formatText,
10
+ toGranularityMsFromDuration
11
+ } from "./chunks/chunk-F5OMERHI.js";
12
+ import {
13
+ getRollupColumnName,
14
+ handleApiError,
8
15
  indent_default
9
- } from "./chunks/chunk-A3NYPUKZ.js";
16
+ } from "./chunks/chunk-Z7NPYIZ6.js";
10
17
  import {
11
18
  RoutesAddTelemetryClient,
12
19
  RoutesTelemetryClient
@@ -31,7 +38,7 @@ import {
31
38
  runInteractiveEditLoop,
32
39
  stripQuotes,
33
40
  validateActionFlags
34
- } from "./chunks/chunk-JQBH4QTB.js";
41
+ } from "./chunks/chunk-VZGX4CKB.js";
35
42
  import {
36
43
  getRouteVersions
37
44
  } from "./chunks/chunk-AHU7WNL2.js";
@@ -51,10 +58,12 @@ import {
51
58
  requireProjectContext,
52
59
  validateRequiredArguments,
53
60
  withGlobalFlags as withGlobalFlags2
54
- } from "./chunks/chunk-5POUHPEH.js";
61
+ } from "./chunks/chunk-ORMDX3GR.js";
55
62
  import {
56
63
  normalizeRepeatableStringFilters,
57
- parseTimeFlag
64
+ outputError,
65
+ parseTimeFlag,
66
+ resolveTimeRange
58
67
  } from "./chunks/chunk-BUZRVER7.js";
59
68
  import {
60
69
  OpenApiCache,
@@ -68,11 +77,11 @@ import {
68
77
  resolveOpenApiTagForTeamsCli,
69
78
  setAutoUpdate,
70
79
  tryOpenApiFallback
71
- } from "./chunks/chunk-TVLLFY7M.js";
80
+ } from "./chunks/chunk-PEC4ROHM.js";
72
81
  import {
73
82
  getUpdateCommand,
74
83
  isGlobal
75
- } from "./chunks/chunk-BFFE4FAO.js";
84
+ } from "./chunks/chunk-IN3RG4AU.js";
76
85
  import {
77
86
  Now,
78
87
  addDomain,
@@ -94,14 +103,14 @@ import {
94
103
  require_format,
95
104
  require_jsonlines,
96
105
  setupDomain
97
- } from "./chunks/chunk-SRIA62TV.js";
106
+ } from "./chunks/chunk-OSXJ6G4O.js";
98
107
  import {
99
108
  getGlobalPathConfig,
100
109
  persistAuthConfig,
101
110
  readLocalConfig,
102
111
  sleep,
103
112
  writeToConfigFile
104
- } from "./chunks/chunk-3OZQ7KHZ.js";
113
+ } from "./chunks/chunk-S7HMSWGQ.js";
105
114
  import "./chunks/chunk-V5P25P7F.js";
106
115
  import {
107
116
  CHECKBOX_INSTRUCTIONS,
@@ -128,7 +137,7 @@ import {
128
137
  import {
129
138
  formatEnvironment,
130
139
  validateLsArgs
131
- } from "./chunks/chunk-O3UHQI3T.js";
140
+ } from "./chunks/chunk-JGXABANG.js";
132
141
  import {
133
142
  validateJsonOutput
134
143
  } from "./chunks/chunk-XPKWKPWA.js";
@@ -140,6 +149,7 @@ import {
140
149
  CREDIT_TYPE_LABELS,
141
150
  FLAG_CONDITION_LIST_COMPARATORS,
142
151
  FLAG_CONDITION_RHS_OPTIONAL_COMPARATORS,
152
+ FLAG_EVALUATIONS_GRANULARITIES,
143
153
  SUPPORTED_ADDON_ALIASES,
144
154
  SUPPORTED_CREDIT_TYPES,
145
155
  abortSubcommand,
@@ -225,6 +235,7 @@ import {
225
235
  enableSubcommand,
226
236
  enableSubcommand2,
227
237
  enableSubcommand3 as enableSubcommand4,
238
+ evaluationsSubcommand,
228
239
  fetchSubcommand,
229
240
  firewallCommand,
230
241
  flagsCommand,
@@ -260,6 +271,7 @@ import {
260
271
  ipBlocksListSubcommand,
261
272
  ipBlocksSubcommand,
262
273
  ipBlocksUnblockSubcommand,
274
+ isFlagEvaluationsGranularity,
263
275
  issueSubcommand,
264
276
  itemsSubcommand,
265
277
  listStoresSubcommand,
@@ -415,7 +427,7 @@ import {
415
427
  webAnalyticsSubcommand,
416
428
  webhooksCommand,
417
429
  whoamiCommand
418
- } from "./chunks/chunk-2CEGMXO6.js";
430
+ } from "./chunks/chunk-2KNVJ7ET.js";
419
431
  import {
420
432
  addSubcommand as addSubcommand12,
421
433
  inspectSubcommand as inspectSubcommand8,
@@ -476,9 +488,9 @@ import "./chunks/chunk-OGG6UBXK.js";
476
488
  import "./chunks/chunk-LHFNIZ2P.js";
477
489
  import {
478
490
  main
479
- } from "./chunks/chunk-5FF4WXVM.js";
491
+ } from "./chunks/chunk-K6YMSJMZ.js";
480
492
  import "./chunks/chunk-IB5L4LKZ.js";
481
- import "./chunks/chunk-ZKKJEOQT.js";
493
+ import "./chunks/chunk-JIK3GTU3.js";
482
494
  import {
483
495
  require_execa
484
496
  } from "./chunks/chunk-R6IGDGX3.js";
@@ -493,10 +505,10 @@ import {
493
505
  } from "./chunks/chunk-VXYGCOKL.js";
494
506
  import {
495
507
  ensureLink
496
- } from "./chunks/chunk-573XYQ3D.js";
497
- import "./chunks/chunk-WQN52QMS.js";
498
- import "./chunks/chunk-QW4XUBC3.js";
499
- import "./chunks/chunk-BZXHF66T.js";
508
+ } from "./chunks/chunk-4QRRJEYO.js";
509
+ import "./chunks/chunk-ENIJVO7C.js";
510
+ import "./chunks/chunk-UA3D44SL.js";
511
+ import "./chunks/chunk-EJNFC5AV.js";
500
512
  import {
501
513
  help
502
514
  } from "./chunks/chunk-DMSLNAVH.js";
@@ -561,7 +573,7 @@ import {
561
573
  selectOrg,
562
574
  toHost,
563
575
  ua_default
564
- } from "./chunks/chunk-HZAINEXG.js";
576
+ } from "./chunks/chunk-QX4337BT.js";
565
577
  import {
566
578
  AGENT_ACTION,
567
579
  AGENT_REASON,
@@ -2396,7 +2408,7 @@ async function activity(client) {
2396
2408
  return 0;
2397
2409
  }
2398
2410
  telemetry2.trackCliSubcommandLs(subcommandOriginal);
2399
- const listFn = (await import("./chunks/list-OVWTXBSN.js")).default;
2411
+ const listFn = (await import("./chunks/list-FJT44SB6.js")).default;
2400
2412
  return listFn(client, telemetry2);
2401
2413
  }
2402
2414
  }
@@ -6049,12 +6061,12 @@ async function alerts(client) {
6049
6061
  switch (subcommand) {
6050
6062
  case "inspect": {
6051
6063
  telemetry2.trackCliSubcommandInspect(subcommandOriginal);
6052
- const inspectFn = (await import("./chunks/inspect-S6X6PCGS.js")).default;
6064
+ const inspectFn = (await import("./chunks/inspect-Q5BKZNVI.js")).default;
6053
6065
  return inspectFn(client, args);
6054
6066
  }
6055
6067
  case "rules": {
6056
6068
  telemetry2.trackCliSubcommandRules(args[0] ?? "ls");
6057
- const rulesFn = (await import("./chunks/rules-UBSIW5ZQ.js")).default;
6069
+ const rulesFn = (await import("./chunks/rules-SQFCUKWS.js")).default;
6058
6070
  const rulesArgs = [...args];
6059
6071
  const project = parsedArgs.flags["--project"];
6060
6072
  const format4 = parsedArgs.flags["--format"];
@@ -6068,7 +6080,7 @@ async function alerts(client) {
6068
6080
  }
6069
6081
  default: {
6070
6082
  telemetry2.trackCliSubcommandLs(subcommandOriginal);
6071
- const listFn = (await import("./chunks/list-IWXFZBH7.js")).default;
6083
+ const listFn = (await import("./chunks/list-N7OA4FBI.js")).default;
6072
6084
  return listFn(client, telemetry2);
6073
6085
  }
6074
6086
  }
@@ -30175,6 +30187,12 @@ var FlagsTelemetryClient = class extends TelemetryClient {
30175
30187
  value: actual
30176
30188
  });
30177
30189
  }
30190
+ trackCliSubcommandEvaluations(actual) {
30191
+ this.trackCliSubcommand({
30192
+ subcommand: "evaluations",
30193
+ value: actual
30194
+ });
30195
+ }
30178
30196
  trackCliSubcommandOpen(actual) {
30179
30197
  this.trackCliSubcommand({
30180
30198
  subcommand: "open",
@@ -30432,10 +30450,11 @@ function quoteArg(value) {
30432
30450
  function getProjectNameFromFlags(flags) {
30433
30451
  return flags["--project"];
30434
30452
  }
30435
- function getLinkedFlagsProject(client, projectName) {
30453
+ function getLinkedFlagsProject(client, projectName, options) {
30436
30454
  return resolveProjectContext({
30437
30455
  client,
30438
- projectNameOrId: projectName
30456
+ projectNameOrId: projectName,
30457
+ projectNotFoundHandling: options?.projectNotFoundHandling
30439
30458
  });
30440
30459
  }
30441
30460
 
@@ -30689,6 +30708,13 @@ function formatVariantForDisplay(variant) {
30689
30708
  }
30690
30709
  return parts.join(" ");
30691
30710
  }
30711
+ function formatVariantListSummary(variant) {
30712
+ const value = formatVariantValue(variant.value);
30713
+ if (!variant.label) {
30714
+ return value;
30715
+ }
30716
+ return `${value}: ${import_chalk117.default.gray(variant.label)}`;
30717
+ }
30692
30718
  function formatAvailableVariants(variants) {
30693
30719
  return variants.map((v) => ` - ${formatAvailableVariant(v)}`).join("\n");
30694
30720
  }
@@ -31022,13 +31048,6 @@ function getSortedEnvironmentEntries(flag, environments) {
31022
31048
  function hasCustomConfigurationEnabled(envConfig) {
31023
31049
  return Boolean(envConfig.targets && Object.keys(envConfig.targets).length > 0) || envConfig.rules.length > 0 || envConfig.fallthrough.type === "split" || envConfig.fallthrough.type === "rollout";
31024
31050
  }
31025
- function formatVariantListSummary(variant) {
31026
- const value = formatVariantValue(variant.value);
31027
- if (!variant.label) {
31028
- return value;
31029
- }
31030
- return `${value}: ${import_chalk119.default.gray(variant.label)}`;
31031
- }
31032
31051
 
31033
31052
  // src/commands/flags/inspect.ts
31034
31053
  async function inspect4(client, argv) {
@@ -32235,6 +32254,341 @@ function buildNextPageCommand2(flagArg, flags, nextCursor) {
32235
32254
  return `flags versions ${quoteArg(flagArg)}${baseFlags}${environmentFlag} --cursor ${quoteArg(nextCursor)}`;
32236
32255
  }
32237
32256
 
32257
+ // src/util/telemetry/commands/flags/evaluations.ts
32258
+ var FlagsEvaluationsTelemetryClient = class extends TelemetryClient {
32259
+ trackCliArgumentFlag(flag) {
32260
+ if (flag) {
32261
+ this.trackCliArgument({
32262
+ arg: "flag",
32263
+ value: this.redactedValue
32264
+ });
32265
+ }
32266
+ }
32267
+ trackCliOptionSince(since) {
32268
+ if (since) {
32269
+ this.trackCliOption({
32270
+ option: "since",
32271
+ value: this.redactedValue
32272
+ });
32273
+ }
32274
+ }
32275
+ trackCliOptionUntil(until) {
32276
+ if (until) {
32277
+ this.trackCliOption({
32278
+ option: "until",
32279
+ value: this.redactedValue
32280
+ });
32281
+ }
32282
+ }
32283
+ trackCliOptionGranularity(granularity) {
32284
+ if (granularity) {
32285
+ this.trackCliOption({
32286
+ option: "granularity",
32287
+ value: isFlagEvaluationsGranularity(granularity) ? granularity : this.redactedValue
32288
+ });
32289
+ }
32290
+ }
32291
+ trackCliFlagJson(json) {
32292
+ if (json) {
32293
+ this.trackCliFlag("json");
32294
+ }
32295
+ }
32296
+ };
32297
+
32298
+ // src/commands/flags/evaluations.ts
32299
+ var FLAG_EVALUATIONS_API_URL = "https://vercel.com/api/observability/metrics";
32300
+ var FLAG_EVALUATIONS_METRIC = "vercel.flag_evaluation.flag_evaluations";
32301
+ var FLAG_EVALUATIONS_AGGREGATION = "sum";
32302
+ var FLAG_EVALUATIONS_ROLLUP = getRollupColumnName(
32303
+ FLAG_EVALUATIONS_METRIC,
32304
+ FLAG_EVALUATIONS_AGGREGATION
32305
+ );
32306
+ var DISPLAY_GROUP_BY = "Variants";
32307
+ var QUERY_ENGINE_GROUP_BY = "flagVariant";
32308
+ var MAX_VARIANTS = 100;
32309
+ function getFlagEvaluationsApiUrl(ownerId) {
32310
+ const url = new URL(
32311
+ process.env.VERCEL_FLAG_EVALUATIONS_API_URL || FLAG_EVALUATIONS_API_URL
32312
+ );
32313
+ url.searchParams.set("ownerId", ownerId);
32314
+ return url.href;
32315
+ }
32316
+ function escapeODataString(value) {
32317
+ return value.replace(/'/g, "''");
32318
+ }
32319
+ function alignTimeRange(startTime, endTime, granularity) {
32320
+ const granularityMs = toGranularityMsFromDuration(granularity);
32321
+ return {
32322
+ startTime: new Date(
32323
+ Math.floor(startTime.getTime() / granularityMs) * granularityMs
32324
+ ),
32325
+ endTime: new Date(
32326
+ Math.ceil(endTime.getTime() / granularityMs) * granularityMs
32327
+ )
32328
+ };
32329
+ }
32330
+ function getVariantDisplayName(flag, variantId2) {
32331
+ if (!variantId2 || variantId2 === "(not set)") {
32332
+ return "Default in Code";
32333
+ }
32334
+ const variant = flag.variants.find((item) => item.id === variantId2);
32335
+ return variant ? formatVariantListSummary(variant) : variantId2;
32336
+ }
32337
+ function handleCommandError(client, error, jsonOutput) {
32338
+ if (!jsonOutput) {
32339
+ printError(error);
32340
+ return 1;
32341
+ }
32342
+ if (isAPIError(error)) {
32343
+ return outputError(
32344
+ client,
32345
+ true,
32346
+ error.code || "API_ERROR",
32347
+ error.serverMessage || `API error (${error.status}).`
32348
+ );
32349
+ }
32350
+ const message = error instanceof Error ? error.message : String(error);
32351
+ return outputError(client, true, "UNEXPECTED_ERROR", message);
32352
+ }
32353
+ function handleMetricsQueryError(client, error, jsonOutput) {
32354
+ return isAPIError(error) ? handleApiError(error, jsonOutput, client) : handleCommandError(client, error, jsonOutput);
32355
+ }
32356
+ function limitEvaluationVariants(response) {
32357
+ if (response.summary.length <= MAX_VARIANTS) {
32358
+ return { response, truncated: false };
32359
+ }
32360
+ const summary = response.summary.slice(0, MAX_VARIANTS);
32361
+ const visibleVariants = new Set(
32362
+ summary.map((row) => row[QUERY_ENGINE_GROUP_BY])
32363
+ );
32364
+ return {
32365
+ response: {
32366
+ ...response,
32367
+ summary,
32368
+ data: response.data?.filter(
32369
+ (row) => visibleVariants.has(row[QUERY_ENGINE_GROUP_BY])
32370
+ )
32371
+ },
32372
+ truncated: true
32373
+ };
32374
+ }
32375
+ function formatEvaluationsJson(flag, response, startTime, endTime, granularity, truncated) {
32376
+ return `${JSON.stringify(
32377
+ {
32378
+ flag: flag.slug,
32379
+ variants: Object.fromEntries(
32380
+ flag.variants.map(({ id, value }) => [id, value])
32381
+ ),
32382
+ startTime: startTime.toISOString(),
32383
+ endTime: endTime.toISOString(),
32384
+ granularity,
32385
+ truncated,
32386
+ buckets: (response.data ?? []).map((row) => ({
32387
+ timestamp: row.timestamp,
32388
+ variant: row[QUERY_ENGINE_GROUP_BY] ?? null,
32389
+ evaluations: row[FLAG_EVALUATIONS_ROLLUP] ?? null
32390
+ }))
32391
+ },
32392
+ null,
32393
+ 2
32394
+ )}
32395
+ `;
32396
+ }
32397
+ async function evaluations(client, argv) {
32398
+ const telemetry2 = new FlagsEvaluationsTelemetryClient({
32399
+ opts: { store: client.telemetryEventStore }
32400
+ });
32401
+ let parsedArgs;
32402
+ const flagsSpecification = getFlagsSpecification(
32403
+ evaluationsSubcommand.options
32404
+ );
32405
+ try {
32406
+ parsedArgs = parseArguments(argv, flagsSpecification);
32407
+ } catch (error) {
32408
+ printError(error);
32409
+ return 1;
32410
+ }
32411
+ const { args, flags } = parsedArgs;
32412
+ const [flagArgument] = args;
32413
+ const projectName = getProjectNameFromFlags(flags);
32414
+ const since = flags["--since"];
32415
+ const until = flags["--until"];
32416
+ const granularity = flags["--granularity"];
32417
+ telemetry2.trackCliArgumentFlag(flagArgument);
32418
+ telemetry2.trackCliOptionProject(projectName);
32419
+ telemetry2.trackCliOptionSince(since);
32420
+ telemetry2.trackCliOptionUntil(until);
32421
+ telemetry2.trackCliOptionGranularity(granularity);
32422
+ telemetry2.trackCliFlagJson(flags["--json"]);
32423
+ const jsonOutput = flags["--json"] ?? false;
32424
+ if (!flagArgument) {
32425
+ return outputError(
32426
+ client,
32427
+ jsonOutput,
32428
+ "MISSING_FLAG",
32429
+ `Missing required argument: flag. Usage: ${getCommandName("flags evaluations <flag>")}`
32430
+ );
32431
+ }
32432
+ if (granularity && !isFlagEvaluationsGranularity(granularity)) {
32433
+ return outputError(
32434
+ client,
32435
+ jsonOutput,
32436
+ "INVALID_GRANULARITY",
32437
+ `Invalid granularity "${granularity}". Use one of: ${FLAG_EVALUATIONS_GRANULARITIES.join(", ")}.`
32438
+ );
32439
+ }
32440
+ let startTime;
32441
+ let endTime;
32442
+ let resolvedGranularity;
32443
+ try {
32444
+ ({ startTime, endTime } = resolveTimeRange(since, until));
32445
+ if (startTime.getTime() >= endTime.getTime()) {
32446
+ throw new Error("The start time must be before the end time.");
32447
+ }
32448
+ resolvedGranularity = computeGranularity(
32449
+ endTime.getTime() - startTime.getTime(),
32450
+ granularity
32451
+ );
32452
+ ({ startTime, endTime } = alignTimeRange(
32453
+ startTime,
32454
+ endTime,
32455
+ resolvedGranularity.duration
32456
+ ));
32457
+ } catch (error) {
32458
+ const message = error instanceof Error ? error.message : String(error);
32459
+ return outputError(client, jsonOutput, "INVALID_TIME", message);
32460
+ }
32461
+ if (!jsonOutput && resolvedGranularity.adjusted && resolvedGranularity.notice) {
32462
+ output_manager_default.log(`Notice: ${resolvedGranularity.notice}`);
32463
+ }
32464
+ let link;
32465
+ try {
32466
+ link = await getLinkedFlagsProject(client, projectName, {
32467
+ projectNotFoundHandling: jsonOutput ? "return" : "report"
32468
+ });
32469
+ } catch (error) {
32470
+ return handleCommandError(client, error, jsonOutput);
32471
+ }
32472
+ if (link.status === "error") {
32473
+ return jsonOutput ? outputError(
32474
+ client,
32475
+ true,
32476
+ "PROJECT_RESOLUTION_FAILED",
32477
+ "Unable to resolve the requested Vercel project."
32478
+ ) : link.exitCode;
32479
+ }
32480
+ if (link.status === "not_linked") {
32481
+ const code2 = projectName ? "PROJECT_NOT_FOUND" : "NOT_LINKED";
32482
+ const message = projectName ? `Project "${projectName}" was not found in the current scope.` : `Your codebase isn't linked to a project on Vercel. Pass --project <name>, or run ${getCommandName("link")} to link it.`;
32483
+ return outputError(client, jsonOutput, code2, message);
32484
+ }
32485
+ client.config.currentTeam = link.org.type === "team" ? link.org.id : void 0;
32486
+ const { project, org } = link;
32487
+ let flag;
32488
+ try {
32489
+ flag = await getFlag(client, project.id, flagArgument);
32490
+ } catch (error) {
32491
+ return handleCommandError(client, error, jsonOutput);
32492
+ }
32493
+ if (!jsonOutput) {
32494
+ output_manager_default.spinner("Querying flag evaluations...");
32495
+ }
32496
+ const scope = {
32497
+ type: "project",
32498
+ ownerId: org.id,
32499
+ projectIds: [project.id]
32500
+ };
32501
+ let response;
32502
+ try {
32503
+ const body = {
32504
+ scope,
32505
+ reason: "flag_evaluation_chart",
32506
+ event: "flagEvaluation",
32507
+ rollups: {
32508
+ [FLAG_EVALUATIONS_ROLLUP]: {
32509
+ measure: "flagEvaluations",
32510
+ aggregation: "sum"
32511
+ }
32512
+ },
32513
+ orderBy: FLAG_EVALUATIONS_ROLLUP,
32514
+ orderDirection: "desc",
32515
+ groupBy: [QUERY_ENGINE_GROUP_BY],
32516
+ // Fetch one extra variant so output can disclose truncation reliably.
32517
+ limit: MAX_VARIANTS + 1,
32518
+ limitRanking: "single_pass",
32519
+ tailRollup: "truncate",
32520
+ summaryOnly: false,
32521
+ filter: `flagKey eq '${escapeODataString(flag.slug)}'`,
32522
+ granularity: resolvedGranularity.duration,
32523
+ startTime: startTime.toISOString(),
32524
+ endTime: endTime.toISOString()
32525
+ };
32526
+ response = await client.fetch(
32527
+ getFlagEvaluationsApiUrl(org.id),
32528
+ {
32529
+ method: "POST",
32530
+ body: JSON.stringify(body),
32531
+ headers: { "Content-Type": "application/json" },
32532
+ useCurrentTeam: false,
32533
+ bailOn429: true
32534
+ }
32535
+ );
32536
+ } catch (error) {
32537
+ return handleMetricsQueryError(client, error, jsonOutput);
32538
+ } finally {
32539
+ if (!jsonOutput) {
32540
+ output_manager_default.stopSpinner();
32541
+ }
32542
+ }
32543
+ const limited = limitEvaluationVariants(response);
32544
+ if (jsonOutput) {
32545
+ client.stdout.write(
32546
+ formatEvaluationsJson(
32547
+ flag,
32548
+ limited.response,
32549
+ startTime,
32550
+ endTime,
32551
+ resolvedGranularity.duration,
32552
+ limited.truncated
32553
+ )
32554
+ );
32555
+ } else {
32556
+ if (limited.truncated) {
32557
+ output_manager_default.warn(
32558
+ `Results are limited to the ${MAX_VARIANTS} most evaluated variants.`
32559
+ );
32560
+ }
32561
+ client.stdout.write(
32562
+ formatText(
32563
+ {
32564
+ ...limited.response,
32565
+ data: limited.response.data?.map((row) => ({
32566
+ ...row,
32567
+ [DISPLAY_GROUP_BY]: row[QUERY_ENGINE_GROUP_BY] ?? null
32568
+ }))
32569
+ },
32570
+ {
32571
+ metric: FLAG_EVALUATIONS_METRIC,
32572
+ metricUnit: "count",
32573
+ aggregation: FLAG_EVALUATIONS_AGGREGATION,
32574
+ groupBy: [DISPLAY_GROUP_BY],
32575
+ scope,
32576
+ projectName: project.name,
32577
+ teamName: org.slug,
32578
+ periodStart: startTime.toISOString(),
32579
+ periodEnd: endTime.toISOString(),
32580
+ granularity: resolvedGranularity.duration,
32581
+ presentation: {
32582
+ compact: true,
32583
+ formatGroupValue: (_field, value) => getVariantDisplayName(flag, value)
32584
+ }
32585
+ }
32586
+ )
32587
+ );
32588
+ }
32589
+ return 0;
32590
+ }
32591
+
32238
32592
  // src/commands/flags/add.ts
32239
32593
  var import_chalk122 = __toESM(require_source(), 1);
32240
32594
  import { randomBytes as randomBytes2 } from "crypto";
@@ -38740,6 +39094,7 @@ var COMMAND_CONFIG30 = {
38740
39094
  ls: getCommandAliases(listSubcommand11),
38741
39095
  inspect: getCommandAliases(inspectSubcommand4),
38742
39096
  versions: getCommandAliases(versionsSubcommand),
39097
+ evaluations: getCommandAliases(evaluationsSubcommand),
38743
39098
  create: getCommandAliases(createSubcommand4),
38744
39099
  open: getCommandAliases(openSubcommand2),
38745
39100
  update: getCommandAliases(updateSubcommand3),
@@ -38808,6 +39163,14 @@ async function main17(client) {
38808
39163
  case "versions":
38809
39164
  telemetry2.trackCliSubcommandVersions(subcommandOriginal);
38810
39165
  return versions(client, needHelp ? [...args, "--help"] : args);
39166
+ case "evaluations":
39167
+ if (needHelp) {
39168
+ telemetry2.trackCliFlagHelp("flags", subcommandOriginal);
39169
+ printHelp(evaluationsSubcommand);
39170
+ return 2;
39171
+ }
39172
+ telemetry2.trackCliSubcommandEvaluations(subcommandOriginal);
39173
+ return evaluations(client, args);
38811
39174
  case "open":
38812
39175
  if (needHelp) {
38813
39176
  telemetry2.trackCliFlagHelp("flags", subcommandOriginal);
@@ -48439,7 +48802,7 @@ async function metrics(client) {
48439
48802
  return 0;
48440
48803
  }
48441
48804
  telemetry2.trackCliSubcommandSchema(subcommandOriginal);
48442
- const schemaFn = (await import("./chunks/schema-I4SXEWLS.js")).default;
48805
+ const schemaFn = (await import("./chunks/schema-PWSCMD24.js")).default;
48443
48806
  return schemaFn(client, telemetry2);
48444
48807
  }
48445
48808
  default: {
@@ -48452,7 +48815,7 @@ async function metrics(client) {
48452
48815
  output_manager_default.print(help(metricsCommand, { columns: client.stderr.columns }));
48453
48816
  return 2;
48454
48817
  }
48455
- const queryFn = (await import("./chunks/query-K2TJKOAL.js")).default;
48818
+ const queryFn = (await import("./chunks/query-QDOKUCHX.js")).default;
48456
48819
  return queryFn(client, telemetry2);
48457
48820
  }
48458
48821
  }
@@ -59032,7 +59395,7 @@ async function main26(client) {
59032
59395
  return 2;
59033
59396
  }
59034
59397
  telemetry2.trackCliSubcommandEdit(subcommandOriginal);
59035
- return (await import("./chunks/edit-UM6TWX2Z.js")).default(client, args);
59398
+ return (await import("./chunks/edit-KO5KX4WU.js")).default(client, args);
59036
59399
  case "delete":
59037
59400
  if (needHelp) {
59038
59401
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -59040,7 +59403,7 @@ async function main26(client) {
59040
59403
  return 2;
59041
59404
  }
59042
59405
  telemetry2.trackCliSubcommandDelete(subcommandOriginal);
59043
- return (await import("./chunks/delete-OXEMVOQE.js")).default(client, args);
59406
+ return (await import("./chunks/delete-AUDPLCMU.js")).default(client, args);
59044
59407
  case "enable":
59045
59408
  if (needHelp) {
59046
59409
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -59048,7 +59411,7 @@ async function main26(client) {
59048
59411
  return 2;
59049
59412
  }
59050
59413
  telemetry2.trackCliSubcommandEnable(subcommandOriginal);
59051
- return (await import("./chunks/enable-3SH6X23Z.js")).default(client, args);
59414
+ return (await import("./chunks/enable-I5HE32DI.js")).default(client, args);
59052
59415
  case "disable":
59053
59416
  if (needHelp) {
59054
59417
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -59056,7 +59419,7 @@ async function main26(client) {
59056
59419
  return 2;
59057
59420
  }
59058
59421
  telemetry2.trackCliSubcommandDisable(subcommandOriginal);
59059
- return (await import("./chunks/disable-DZA53CJA.js")).default(client, args);
59422
+ return (await import("./chunks/disable-WFPXR7GZ.js")).default(client, args);
59060
59423
  case "reorder":
59061
59424
  if (needHelp) {
59062
59425
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -59064,7 +59427,7 @@ async function main26(client) {
59064
59427
  return 2;
59065
59428
  }
59066
59429
  telemetry2.trackCliSubcommandReorder(subcommandOriginal);
59067
- return (await import("./chunks/reorder-J6OONT76.js")).default(client, args);
59430
+ return (await import("./chunks/reorder-L2M3YGJ4.js")).default(client, args);
59068
59431
  case "export":
59069
59432
  if (needHelp) {
59070
59433
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -59072,7 +59435,7 @@ async function main26(client) {
59072
59435
  return 2;
59073
59436
  }
59074
59437
  telemetry2.trackCliSubcommandExport(subcommandOriginal);
59075
- return (await import("./chunks/export-TLQERLQP.js")).default(client, args);
59438
+ return (await import("./chunks/export-4Y5L2TOT.js")).default(client, args);
59076
59439
  case "publish":
59077
59440
  if (needHelp) {
59078
59441
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -59080,7 +59443,7 @@ async function main26(client) {
59080
59443
  return 2;
59081
59444
  }
59082
59445
  telemetry2.trackCliSubcommandPublish(subcommandOriginal);
59083
- return (await import("./chunks/publish-LWCEDLGX.js")).default(client, args);
59446
+ return (await import("./chunks/publish-DUTEBRX3.js")).default(client, args);
59084
59447
  case "restore":
59085
59448
  if (needHelp) {
59086
59449
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -59088,7 +59451,7 @@ async function main26(client) {
59088
59451
  return 2;
59089
59452
  }
59090
59453
  telemetry2.trackCliSubcommandRestore(subcommandOriginal);
59091
- return (await import("./chunks/restore-3ME4ZHFW.js")).default(client, args);
59454
+ return (await import("./chunks/restore-BVDNAJVC.js")).default(client, args);
59092
59455
  case "discard-staging":
59093
59456
  if (needHelp) {
59094
59457
  telemetry2.trackCliFlagHelp("routes", subcommandOriginal);
@@ -59096,7 +59459,7 @@ async function main26(client) {
59096
59459
  return 2;
59097
59460
  }
59098
59461
  telemetry2.trackCliSubcommandDiscardStaging(subcommandOriginal);
59099
- return (await import("./chunks/discard-3E7Z7CKD.js")).default(client, args);
59462
+ return (await import("./chunks/discard-RVFKIZZG.js")).default(client, args);
59100
59463
  default:
59101
59464
  output_manager_default.error(getInvalidSubcommand(COMMAND_CONFIG41));
59102
59465
  output_manager_default.print(help(routesCommand, { columns: client.stderr.columns }));
@@ -63707,25 +64070,25 @@ async function vcr(client) {
63707
64070
  switch (subcommand) {
63708
64071
  case "ls":
63709
64072
  telemetry2.trackCliSubcommandLs(subcommandOriginal);
63710
- return (await import("./chunks/ls-FQIWFI4K.js")).default(client, args, telemetry2);
64073
+ return (await import("./chunks/ls-H52WO65Y.js")).default(client, args, telemetry2);
63711
64074
  case "inspect":
63712
64075
  telemetry2.trackCliSubcommandInspect(subcommandOriginal);
63713
- return (await import("./chunks/inspect-QW6RSV7Z.js")).default(client, args, telemetry2);
64076
+ return (await import("./chunks/inspect-PJDCPARM.js")).default(client, args, telemetry2);
63714
64077
  case "add":
63715
64078
  telemetry2.trackCliSubcommandAdd(subcommandOriginal);
63716
- return (await import("./chunks/add-DVEAUH7N.js")).default(client, args, telemetry2);
64079
+ return (await import("./chunks/add-2HLAH42D.js")).default(client, args, telemetry2);
63717
64080
  case "rm":
63718
64081
  telemetry2.trackCliSubcommandRm(subcommandOriginal);
63719
- return (await import("./chunks/rm-63AGQFIQ.js")).default(client, args, telemetry2);
64082
+ return (await import("./chunks/rm-VHWBHG3A.js")).default(client, args, telemetry2);
63720
64083
  case "login":
63721
64084
  telemetry2.trackCliSubcommandLogin(subcommandOriginal);
63722
- return (await import("./chunks/login-S77F2DLW.js")).default(client, args, telemetry2);
64085
+ return (await import("./chunks/login-BPE774JW.js")).default(client, args, telemetry2);
63723
64086
  case "tag":
63724
64087
  telemetry2.trackCliSubcommandTag(subcommandOriginal);
63725
- return (await import("./chunks/tags-HF2YOQ4V.js")).default(client, args, telemetry2);
64088
+ return (await import("./chunks/tags-BT7ZGJP2.js")).default(client, args, telemetry2);
63726
64089
  case "image":
63727
64090
  telemetry2.trackCliSubcommandImage(subcommandOriginal);
63728
- return (await import("./chunks/image-YKGEEC2A.js")).default(client, args, telemetry2);
64091
+ return (await import("./chunks/image-QC5MVWKN.js")).default(client, args, telemetry2);
63729
64092
  default:
63730
64093
  output_manager_default.error(getInvalidSubcommand(COMMAND_CONFIG47));
63731
64094
  output_manager_default.print(help(vcrCommand, { columns: client.stderr.columns }));