vercel 56.4.1 → 57.0.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 (94) hide show
  1. package/dist/chunks/{add-L3Z6PL54.js → add-7M577U56.js} +7 -6
  2. package/dist/chunks/{add-RFEJCIBM.js → add-YRZTDNXX.js} +3 -3
  3. package/dist/chunks/{chunk-V5P25P7F.js → chunk-2473DUBR.js} +4 -11
  4. package/dist/chunks/{chunk-5EXIJBLL.js → chunk-2EDWKVNP.js} +8 -8
  5. package/dist/chunks/{chunk-YS6EDZHB.js → chunk-2MJROFVC.js} +5 -1
  6. package/dist/chunks/{chunk-OOD67FAL.js → chunk-3242RXCN.js} +1 -1
  7. package/dist/chunks/chunk-3PGXYIKC.js +147 -0
  8. package/dist/chunks/{chunk-CHZBEMLF.js → chunk-4PGF367U.js} +47 -210
  9. package/dist/chunks/{chunk-GKVAAY2A.js → chunk-555WJSO5.js} +1 -1
  10. package/dist/chunks/chunk-5AJPMLDV.js +28 -0
  11. package/dist/chunks/{chunk-IHQ7DPQI.js → chunk-A2TYQBX2.js} +117 -3
  12. package/dist/chunks/chunk-A3NYPUKZ.js +17 -0
  13. package/dist/chunks/{chunk-W346YNDN.js → chunk-DWMH5M4Q.js} +4 -1
  14. package/dist/chunks/chunk-E336ZXPP.js +43 -0
  15. package/dist/chunks/chunk-F5PQWDOC.js +245 -0
  16. package/dist/chunks/{chunk-Y7TVKRRJ.js → chunk-F7X55TOY.js} +15 -839
  17. package/dist/chunks/chunk-FGDKMNEN.js +21 -0
  18. package/dist/chunks/chunk-FHEMFAHB.js +320 -0
  19. package/dist/chunks/{chunk-NLRIKNPX.js → chunk-GP5VCTEU.js} +1 -1
  20. package/dist/chunks/chunk-GZLPFESR.js +48 -0
  21. package/dist/chunks/{chunk-HZKJMZEQ.js → chunk-HD7B425F.js} +2 -2
  22. package/dist/chunks/{chunk-J6KTUJHV.js → chunk-IOAZNR6Z.js} +1 -1
  23. package/dist/chunks/{chunk-STJJ3DFO.js → chunk-KCF6S3XF.js} +16 -1
  24. package/dist/chunks/chunk-LMHT3QR3.js +247 -0
  25. package/dist/chunks/{chunk-A4XB42AB.js → chunk-MAHINYBW.js} +4 -3
  26. package/dist/chunks/{chunk-DXFSBJTA.js → chunk-MIFDRYTN.js} +1 -1
  27. package/dist/chunks/{chunk-VLTQJKP6.js → chunk-NH43BFJ3.js} +1 -1
  28. package/dist/chunks/{chunk-Z7NPYIZ6.js → chunk-NM43FFV6.js} +0 -8
  29. package/dist/chunks/{chunk-MQRHJEBS.js → chunk-NRNMT43R.js} +3 -3
  30. package/dist/chunks/chunk-OF2GNB42.js +53 -0
  31. package/dist/chunks/chunk-PRWJUY5U.js +848 -0
  32. package/dist/chunks/{chunk-F5OMERHI.js → chunk-QZD5DKUR.js} +10 -23
  33. package/dist/chunks/{chunk-4M3ZQCYN.js → chunk-RAFH25WW.js} +8 -1
  34. package/dist/chunks/{chunk-43B3LNUF.js → chunk-RYO6FJFB.js} +1 -1
  35. package/dist/chunks/{chunk-XFGY3JAX.js → chunk-T4NODP6Y.js} +11 -18
  36. package/dist/chunks/{chunk-GLAHGVBS.js → chunk-TBR2Q37Y.js} +2038 -1786
  37. package/dist/chunks/chunk-V4RMJKQP.js +36 -0
  38. package/dist/chunks/chunk-WR7JTCGL.js +104 -0
  39. package/dist/chunks/{chunk-6RTK6BWX.js → chunk-YA3WQFLY.js} +1 -1
  40. package/dist/chunks/{chunk-UHGAPG7O.js → chunk-YOZCJHLZ.js} +4 -4
  41. package/dist/chunks/{compile-vercel-config-J2X5OV6K.js → compile-vercel-config-3OHO3TJA.js} +2 -2
  42. package/dist/chunks/config-validator.mjs +1 -0
  43. package/dist/chunks/delete-3DZOCWCC.js +150 -0
  44. package/dist/chunks/{delete-57A44RN7.js → delete-VOSJLNEA.js} +3 -3
  45. package/dist/chunks/{disable-DNZ52MEO.js → disable-LQDEVRQF.js} +3 -3
  46. package/dist/chunks/{discard-HACSIZ74.js → discard-RGV4JKXQ.js} +3 -3
  47. package/dist/chunks/{edit-HJ47TQU3.js → edit-SFIEOQ24.js} +4 -4
  48. package/dist/chunks/edit-UPZPI54L.js +153 -0
  49. package/dist/chunks/{enable-BVLRVRYM.js → enable-6UVH35WC.js} +3 -3
  50. package/dist/chunks/{export-7MJFGMG7.js → export-6CEG3CK7.js} +3 -3
  51. package/dist/chunks/{image-4UMD7UZP.js → image-CQRCD2OE.js} +3 -3
  52. package/dist/chunks/inspect-4ZAH3RFT.js +205 -0
  53. package/dist/chunks/inspect-EXQBIAFF.js +587 -0
  54. package/dist/chunks/{inspect-WBHUZC3R.js → inspect-K5ZMQG7X.js} +3 -3
  55. package/dist/chunks/{inspect-4JD2QN67.js → inspect-UM3LDRPV.js} +3 -3
  56. package/dist/chunks/{inspect-XX3OXSHC.js → inspect-ZFRY3X3H.js} +3 -3
  57. package/dist/chunks/{list-AM6K2JCW.js → list-4DRVM7Q4.js} +42 -55
  58. package/dist/chunks/{list-5H57NTM4.js → list-FJCBOCCA.js} +2 -2
  59. package/dist/chunks/list-KCUHD4OA.js +360 -0
  60. package/dist/chunks/{login-YO34E4V5.js → login-DFGYNU3K.js} +3 -3
  61. package/dist/chunks/{ls-44NPIO2N.js → ls-34NCZKBE.js} +3 -3
  62. package/dist/chunks/{ls-P7ZLBWW2.js → ls-4QHHVXXD.js} +3 -3
  63. package/dist/chunks/{ls-YDUYTLXW.js → ls-CG6A7UXF.js} +3 -3
  64. package/dist/chunks/ls-RHEQ6YQB.js +188 -0
  65. package/dist/chunks/open-E3XADEMX.js +106 -0
  66. package/dist/chunks/{publish-RXFUYSW3.js → publish-Z3AQRUCS.js} +3 -3
  67. package/dist/chunks/{query-ILJJL3BZ.js → query-3EV66DO3.js} +9 -9
  68. package/dist/chunks/{reorder-GBCOPZT4.js → reorder-VA5E5ZJT.js} +3 -3
  69. package/dist/chunks/reply-SNSCNKAW.js +167 -0
  70. package/dist/chunks/resolve-6ZX4RTXX.js +228 -0
  71. package/dist/chunks/{restore-YK5DGGRX.js → restore-NEHI5B5P.js} +3 -3
  72. package/dist/chunks/{rm-O474MI5C.js → rm-22B22E47.js} +3 -3
  73. package/dist/chunks/{rm-LK6P7XTA.js → rm-E5ZVLAKO.js} +3 -3
  74. package/dist/chunks/{rm-FRZMXB2W.js → rm-FR6KE744.js} +7 -6
  75. package/dist/chunks/rule-inspect-DMP2CKJQ.js +283 -0
  76. package/dist/chunks/{rules-MZ2MP6KJ.js → rules-EYGXEI2Z.js} +7 -7
  77. package/dist/chunks/{schema-FR6CCQIZ.js → schema-2IIWOBSQ.js} +7 -5
  78. package/dist/chunks/{tags-AKRTKFRV.js → tags-ZDVYRHAY.js} +2 -2
  79. package/dist/chunks/{update-W3CWQB2F.js → update-QH4DQMZV.js} +7 -6
  80. package/dist/commands/build/index.js +45 -13
  81. package/dist/commands/deploy/index.js +38 -27
  82. package/dist/commands/dev/index.js +13 -16
  83. package/dist/commands/env/index.js +13 -11
  84. package/dist/commands/link/index.js +10 -9
  85. package/dist/commands/list/index.js +5 -5
  86. package/dist/commands-bulk.js +2981 -2179
  87. package/dist/index.js +31 -21
  88. package/dist/vc.js +54 -18
  89. package/dist/version.mjs +1 -1
  90. package/package.json +35 -35
  91. package/dist/chunks/chunk-F32B76CK.js +0 -86
  92. package/dist/chunks/inspect-5YZP7IWI.js +0 -351
  93. package/dist/chunks/ls-MB74DIQV.js +0 -113
  94. package/dist/chunks/rule-inspect-YEZGYINZ.js +0 -141
@@ -0,0 +1,188 @@
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
+ formatCustomAlertMetric,
9
+ formatCustomAlertTrigger,
10
+ formatRuleScope,
11
+ isCustomAlertRule,
12
+ parseCustomAlertQuery,
13
+ renderAlertTable
14
+ } from "./chunk-3PGXYIKC.js";
15
+ import {
16
+ emitRulesArgParseError,
17
+ handleRulesApiError,
18
+ parseRulesFlagsAndScope,
19
+ rulesCollectionPath
20
+ } from "./chunk-MAHINYBW.js";
21
+ import "./chunk-T4NODP6Y.js";
22
+ import {
23
+ formatGranularity
24
+ } from "./chunk-5AJPMLDV.js";
25
+ import "./chunk-A3NYPUKZ.js";
26
+ import {
27
+ normalizeRepeatableStringFilters
28
+ } from "./chunk-BUZRVER7.js";
29
+ import "./chunk-FGDKMNEN.js";
30
+ import {
31
+ truncateEnd
32
+ } from "./chunk-OF2GNB42.js";
33
+ import {
34
+ validateJsonOutput
35
+ } from "./chunk-XPKWKPWA.js";
36
+ import {
37
+ rulesLsSubcommand
38
+ } from "./chunk-KCF6S3XF.js";
39
+ import "./chunk-NZRWTCRM.js";
40
+ import "./chunk-TBR2Q37Y.js";
41
+ import "./chunk-ECCWJHC6.js";
42
+ import {
43
+ AGENT_REASON,
44
+ outputAgentError
45
+ } from "./chunk-UDWRZXIT.js";
46
+ import {
47
+ parseArguments,
48
+ printError
49
+ } from "./chunk-SZXT3PDQ.js";
50
+ import {
51
+ getFlagsSpecification,
52
+ isAPIError
53
+ } from "./chunk-KSSNLCL4.js";
54
+ import "./chunk-P4QNYOFB.js";
55
+ import "./chunk-52QYYTM5.js";
56
+ import {
57
+ output_manager_default
58
+ } from "./chunk-OX7KI3LF.js";
59
+ import "./chunk-GGP5R3FU.js";
60
+ import {
61
+ require_source
62
+ } from "./chunk-S7KYDPEM.js";
63
+ import {
64
+ __toESM
65
+ } from "./chunk-TZ2YI2VH.js";
66
+
67
+ // src/commands/alerts/rules/ls.ts
68
+ var import_chalk = __toESM(require_source(), 1);
69
+ function getCustomAlertRuleDetails(rule) {
70
+ const customAlert = rule.customAlert;
71
+ if (!isCustomAlertRule(rule) || !customAlert) {
72
+ return "";
73
+ }
74
+ const metric = formatCustomAlertMetric(customAlert);
75
+ const trigger = formatCustomAlertTrigger(customAlert);
76
+ const min = typeof customAlert.minThreshold === "number" ? `min ${customAlert.minThreshold}` : void 0;
77
+ const granularity = formatGranularity(
78
+ parseCustomAlertQuery(customAlert.queryJsonString).granularity
79
+ );
80
+ const interval = granularity ? `every ${granularity}` : void 0;
81
+ return [metric, trigger, min, interval].filter(Boolean).join("; ");
82
+ }
83
+ function ruleMatchesTypes(rule, types) {
84
+ if (types.length === 0) {
85
+ return true;
86
+ }
87
+ return rule.alertTypes?.some((alertType) => types.includes(alertType.type)) || types.includes("custom_alert") && isCustomAlertRule(rule);
88
+ }
89
+ function getRuleScope(rule) {
90
+ return formatRuleScope(rule.projectId, {
91
+ projectIdMaxLength: 24,
92
+ filterMaxLength: 24
93
+ });
94
+ }
95
+ function printRules(rules) {
96
+ const showDetails = rules.some((rule) => getCustomAlertRuleDetails(rule));
97
+ const headers = [
98
+ "Name",
99
+ "Rule id",
100
+ "Scope",
101
+ ...showDetails ? ["Details"] : []
102
+ ].map((h) => import_chalk.default.cyan(h));
103
+ const rows = [
104
+ headers,
105
+ ...rules.map((rule) => {
106
+ const row = [
107
+ import_chalk.default.bold(truncateEnd(rule.name || "-", 44)),
108
+ import_chalk.default.dim(rule.id || "-"),
109
+ getRuleScope(rule)
110
+ ];
111
+ if (showDetails) {
112
+ row.push(truncateEnd(getCustomAlertRuleDetails(rule) || "-", 72));
113
+ }
114
+ return row;
115
+ })
116
+ ];
117
+ output_manager_default.print(`
118
+ ${renderAlertTable(rows, 2)}
119
+ `);
120
+ }
121
+ async function ls(client, argv) {
122
+ let parsedArgs;
123
+ try {
124
+ parsedArgs = parseArguments(
125
+ argv,
126
+ getFlagsSpecification(rulesLsSubcommand.options)
127
+ );
128
+ } catch (e) {
129
+ emitRulesArgParseError(client, e, "alerts rules ls --project <name-or-id>");
130
+ printError(e);
131
+ return 1;
132
+ }
133
+ const flags = parsedArgs.flags;
134
+ const fr = validateJsonOutput(flags);
135
+ if (!fr.valid) {
136
+ outputAgentError(
137
+ client,
138
+ {
139
+ status: "error",
140
+ reason: AGENT_REASON.INVALID_ARGUMENTS,
141
+ message: fr.error
142
+ },
143
+ 1
144
+ );
145
+ output_manager_default.error(fr.error);
146
+ return 1;
147
+ }
148
+ const scope = await parseRulesFlagsAndScope(
149
+ client,
150
+ {
151
+ "--project": flags["--project"],
152
+ "--all": flags["--all"]
153
+ },
154
+ fr.jsonOutput,
155
+ "alerts rules ls"
156
+ );
157
+ if (typeof scope === "number") {
158
+ return scope;
159
+ }
160
+ const path = rulesCollectionPath(scope);
161
+ output_manager_default.spinner("Fetching alert rules...");
162
+ try {
163
+ const rules = await client.fetch(path);
164
+ const types = normalizeRepeatableStringFilters(flags["--type"]);
165
+ const filteredRules = rules.filter((rule) => ruleMatchesTypes(rule, types));
166
+ if (fr.jsonOutput) {
167
+ client.stdout.write(
168
+ `${JSON.stringify({ rules: filteredRules }, null, 2)}
169
+ `
170
+ );
171
+ } else if (filteredRules.length === 0) {
172
+ output_manager_default.log("No alert rules found for this scope.");
173
+ } else {
174
+ printRules(filteredRules);
175
+ }
176
+ return 0;
177
+ } catch (err) {
178
+ if (isAPIError(err)) {
179
+ return handleRulesApiError(client, err, fr.jsonOutput);
180
+ }
181
+ throw err;
182
+ } finally {
183
+ output_manager_default.stopSpinner();
184
+ }
185
+ }
186
+ export {
187
+ ls as default
188
+ };
@@ -0,0 +1,106 @@
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
+ parseThreadArg
9
+ } from "./chunk-E336ZXPP.js";
10
+ import {
11
+ getThread,
12
+ handleCommentsParseError,
13
+ resolveCommentsScope,
14
+ threadNotFoundMessage,
15
+ toApiErrorParts
16
+ } from "./chunk-LMHT3QR3.js";
17
+ import {
18
+ outputError
19
+ } from "./chunk-BUZRVER7.js";
20
+ import {
21
+ openSubcommand
22
+ } from "./chunk-FHEMFAHB.js";
23
+ import {
24
+ require_open
25
+ } from "./chunk-TBR2Q37Y.js";
26
+ import "./chunk-ECCWJHC6.js";
27
+ import "./chunk-UDWRZXIT.js";
28
+ import {
29
+ parseArguments
30
+ } from "./chunk-SZXT3PDQ.js";
31
+ import {
32
+ getFlagsSpecification,
33
+ isAPIError
34
+ } from "./chunk-KSSNLCL4.js";
35
+ import "./chunk-P4QNYOFB.js";
36
+ import "./chunk-52QYYTM5.js";
37
+ import {
38
+ output_manager_default
39
+ } from "./chunk-OX7KI3LF.js";
40
+ import "./chunk-GGP5R3FU.js";
41
+ import "./chunk-S7KYDPEM.js";
42
+ import {
43
+ __toESM
44
+ } from "./chunk-TZ2YI2VH.js";
45
+
46
+ // src/commands/comments/open.ts
47
+ var import_open = __toESM(require_open(), 1);
48
+ async function openThread(client, telemetry) {
49
+ let parsedArgs;
50
+ const flagsSpecification = getFlagsSpecification(openSubcommand.options);
51
+ try {
52
+ parsedArgs = parseArguments(client.argv.slice(2), flagsSpecification);
53
+ } catch (err) {
54
+ return handleCommentsParseError(err, "open");
55
+ }
56
+ const threadInput = parsedArgs.args[2];
57
+ telemetry.trackCliArgumentThread(threadInput);
58
+ if (!threadInput) {
59
+ output_manager_default.error("Pass a thread ID or URL: `vercel comments open <thread>`.");
60
+ return 1;
61
+ }
62
+ const threadRef = parseThreadArg(threadInput);
63
+ if (!threadRef) {
64
+ output_manager_default.error(
65
+ `Could not extract a thread ID from "${threadInput}". Pass the thread ID or its vercel.com URL.`
66
+ );
67
+ return 1;
68
+ }
69
+ const threadId = threadRef.id;
70
+ telemetry.trackCliOptionProject(parsedArgs.flags["--project"]);
71
+ const scope = await resolveCommentsScope(client, {
72
+ project: parsedArgs.flags["--project"],
73
+ requireProject: false,
74
+ jsonOutput: false,
75
+ urlTeamSlug: threadRef.teamSlug
76
+ });
77
+ if (typeof scope === "number") {
78
+ return scope;
79
+ }
80
+ let webUrl;
81
+ try {
82
+ const thread = await getThread(client, scope.teamId, threadId);
83
+ webUrl = thread.webUrl;
84
+ } catch (err) {
85
+ if (isAPIError(err)) {
86
+ const { code, message } = toApiErrorParts(err);
87
+ return outputError(
88
+ client,
89
+ false,
90
+ code,
91
+ err.status === 404 ? threadNotFoundMessage(threadId, scope) : message
92
+ );
93
+ }
94
+ throw err;
95
+ }
96
+ if (!webUrl) {
97
+ output_manager_default.error(`The API returned no web URL for ${threadId}.`);
98
+ return 1;
99
+ }
100
+ output_manager_default.log(`Opening ${webUrl}`);
101
+ await (0, import_open.default)(webUrl);
102
+ return 0;
103
+ }
104
+ export {
105
+ openThread as default
106
+ };
@@ -17,7 +17,7 @@ import {
17
17
  printDiffSummary,
18
18
  requireProjectContext,
19
19
  withGlobalFlags
20
- } from "./chunk-GKVAAY2A.js";
20
+ } from "./chunk-555WJSO5.js";
21
21
  import {
22
22
  publishSubcommand
23
23
  } from "./chunk-VZSZBD4V.js";
@@ -25,11 +25,11 @@ import {
25
25
  stamp_default
26
26
  } from "./chunk-64IF634X.js";
27
27
  import "./chunk-VXYGCOKL.js";
28
- import "./chunk-GLAHGVBS.js";
28
+ import "./chunk-TBR2Q37Y.js";
29
+ import "./chunk-ECCWJHC6.js";
29
30
  import {
30
31
  outputAgentError
31
32
  } from "./chunk-UDWRZXIT.js";
32
- import "./chunk-ECCWJHC6.js";
33
33
  import "./chunk-SZXT3PDQ.js";
34
34
  import "./chunk-KSSNLCL4.js";
35
35
  import "./chunk-P4QNYOFB.js";
@@ -7,21 +7,24 @@ const __dirname = __dirname_(__filename);
7
7
  import {
8
8
  fetchMetricDetailOrExit,
9
9
  getDefaultAggregation
10
- } from "./chunk-6RTK6BWX.js";
10
+ } from "./chunk-YA3WQFLY.js";
11
11
  import {
12
12
  computeGranularity,
13
13
  formatText
14
- } from "./chunk-F5OMERHI.js";
14
+ } from "./chunk-QZD5DKUR.js";
15
15
  import {
16
16
  formatErrorJson,
17
17
  formatQueryJson,
18
18
  getRollupColumnName,
19
19
  handleApiError
20
- } from "./chunk-Z7NPYIZ6.js";
20
+ } from "./chunk-NM43FFV6.js";
21
+ import "./chunk-5AJPMLDV.js";
22
+ import "./chunk-A3NYPUKZ.js";
21
23
  import {
22
24
  resolveTimeRange,
23
25
  validateAllProjectMutualExclusivity
24
26
  } from "./chunk-BUZRVER7.js";
27
+ import "./chunk-OF2GNB42.js";
25
28
  import {
26
29
  validateJsonOutput
27
30
  } from "./chunk-XPKWKPWA.js";
@@ -34,9 +37,9 @@ import {
34
37
  getLinkedProject,
35
38
  getProjectByNameOrId,
36
39
  getScope
37
- } from "./chunk-GLAHGVBS.js";
38
- import "./chunk-UDWRZXIT.js";
40
+ } from "./chunk-TBR2Q37Y.js";
39
41
  import "./chunk-ECCWJHC6.js";
42
+ import "./chunk-UDWRZXIT.js";
40
43
  import {
41
44
  parseArguments,
42
45
  printError
@@ -56,9 +59,6 @@ import "./chunk-S7KYDPEM.js";
56
59
  import "./chunk-TZ2YI2VH.js";
57
60
 
58
61
  // src/commands/metrics/validation.ts
59
- function validateMutualExclusivity(all, project) {
60
- return validateAllProjectMutualExclusivity(all, project);
61
- }
62
62
  function validateRequiredMetric(metric) {
63
63
  if (metric) {
64
64
  return { valid: true, value: metric };
@@ -253,7 +253,7 @@ async function query(client, telemetry) {
253
253
  return handleValidationError(requiredMetric, jsonOutput, client);
254
254
  }
255
255
  const metric = requiredMetric.value;
256
- const mutualResult = validateMutualExclusivity(all, project);
256
+ const mutualResult = validateAllProjectMutualExclusivity(all, project);
257
257
  if (!mutualResult.valid) {
258
258
  return handleValidationError(mutualResult, jsonOutput, client);
259
259
  }
@@ -16,7 +16,7 @@ import {
16
16
  resolveRoute,
17
17
  shellQuoteRouteIdentifierForSuggestion,
18
18
  withGlobalFlags
19
- } from "./chunk-GKVAAY2A.js";
19
+ } from "./chunk-555WJSO5.js";
20
20
  import {
21
21
  reorderSubcommand
22
22
  } from "./chunk-VZSZBD4V.js";
@@ -24,11 +24,11 @@ import {
24
24
  stamp_default
25
25
  } from "./chunk-64IF634X.js";
26
26
  import "./chunk-VXYGCOKL.js";
27
- import "./chunk-GLAHGVBS.js";
27
+ import "./chunk-TBR2Q37Y.js";
28
+ import "./chunk-ECCWJHC6.js";
28
29
  import {
29
30
  outputAgentError
30
31
  } from "./chunk-UDWRZXIT.js";
31
- import "./chunk-ECCWJHC6.js";
32
32
  import "./chunk-SZXT3PDQ.js";
33
33
  import "./chunk-KSSNLCL4.js";
34
34
  import "./chunk-P4QNYOFB.js";
@@ -0,0 +1,167 @@
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
+ resolveMessageContent
9
+ } from "./chunk-WR7JTCGL.js";
10
+ import {
11
+ parseThreadArg
12
+ } from "./chunk-E336ZXPP.js";
13
+ import {
14
+ addMessage,
15
+ handleCommentsParseError,
16
+ resolveCommentsScope,
17
+ threadNotFoundMessage,
18
+ toApiErrorParts
19
+ } from "./chunk-LMHT3QR3.js";
20
+ import "./chunk-2473DUBR.js";
21
+ import {
22
+ outputError
23
+ } from "./chunk-BUZRVER7.js";
24
+ import {
25
+ validateJsonOutput
26
+ } from "./chunk-XPKWKPWA.js";
27
+ import {
28
+ replySubcommand
29
+ } from "./chunk-FHEMFAHB.js";
30
+ import "./chunk-TBR2Q37Y.js";
31
+ import "./chunk-ECCWJHC6.js";
32
+ import "./chunk-UDWRZXIT.js";
33
+ import {
34
+ parseArguments
35
+ } from "./chunk-SZXT3PDQ.js";
36
+ import {
37
+ getFlagsSpecification,
38
+ isAPIError
39
+ } from "./chunk-KSSNLCL4.js";
40
+ import "./chunk-P4QNYOFB.js";
41
+ import "./chunk-52QYYTM5.js";
42
+ import {
43
+ output_manager_default
44
+ } from "./chunk-OX7KI3LF.js";
45
+ import "./chunk-GGP5R3FU.js";
46
+ import {
47
+ require_source
48
+ } from "./chunk-S7KYDPEM.js";
49
+ import {
50
+ __toESM
51
+ } from "./chunk-TZ2YI2VH.js";
52
+
53
+ // src/commands/comments/reply.ts
54
+ var import_chalk = __toESM(require_source(), 1);
55
+ function validateAttachments(attach) {
56
+ if (!attach || attach.length === 0) {
57
+ return void 0;
58
+ }
59
+ if (attach.length > 10) {
60
+ return "A message can have at most 10 attachments.";
61
+ }
62
+ for (const url of attach) {
63
+ if (!/^https:\/\//i.test(url)) {
64
+ return `Attachments must be https URLs (the API fetches them); got "${url}". Local file upload is not supported by the API.`;
65
+ }
66
+ }
67
+ return void 0;
68
+ }
69
+ async function reply(client, telemetry) {
70
+ let parsedArgs;
71
+ const flagsSpecification = getFlagsSpecification(replySubcommand.options);
72
+ try {
73
+ parsedArgs = parseArguments(client.argv.slice(2), flagsSpecification);
74
+ } catch (err) {
75
+ return handleCommentsParseError(err, "reply");
76
+ }
77
+ const formatResult = validateJsonOutput(parsedArgs.flags);
78
+ if (!formatResult.valid) {
79
+ output_manager_default.error(formatResult.error);
80
+ return 1;
81
+ }
82
+ const jsonOutput = formatResult.jsonOutput;
83
+ telemetry.trackCliOptionFormat(parsedArgs.flags["--format"]);
84
+ telemetry.trackCliOptionMessage(parsedArgs.flags["--message"]);
85
+ telemetry.trackCliOptionFile(parsedArgs.flags["--file"]);
86
+ telemetry.trackCliOptionAttach(parsedArgs.flags["--attach"]);
87
+ const threadInput = parsedArgs.args[2];
88
+ telemetry.trackCliArgumentThread(threadInput);
89
+ if (!threadInput) {
90
+ return outputError(
91
+ client,
92
+ jsonOutput,
93
+ "MISSING_THREAD",
94
+ "Pass a thread ID or URL: `vercel comments reply <thread> -m <text>`."
95
+ );
96
+ }
97
+ const threadRef = parseThreadArg(threadInput);
98
+ if (!threadRef) {
99
+ return outputError(
100
+ client,
101
+ jsonOutput,
102
+ "INVALID_THREAD",
103
+ `Could not extract a thread ID from "${threadInput}". Pass the thread ID or its vercel.com URL.`
104
+ );
105
+ }
106
+ const threadId = threadRef.id;
107
+ const attach = parsedArgs.flags["--attach"];
108
+ const attachError = validateAttachments(attach);
109
+ if (attachError) {
110
+ return outputError(client, jsonOutput, "INVALID_ATTACHMENT", attachError);
111
+ }
112
+ const content = await resolveMessageContent(
113
+ client,
114
+ {
115
+ message: parsedArgs.flags["--message"],
116
+ file: parsedArgs.flags["--file"],
117
+ hasAttachments: Boolean(attach && attach.length > 0)
118
+ },
119
+ jsonOutput
120
+ );
121
+ if (typeof content === "number") {
122
+ return content;
123
+ }
124
+ telemetry.trackCliOptionProject(parsedArgs.flags["--project"]);
125
+ const scope = await resolveCommentsScope(client, {
126
+ project: parsedArgs.flags["--project"],
127
+ requireProject: false,
128
+ jsonOutput,
129
+ urlTeamSlug: threadRef.teamSlug
130
+ });
131
+ if (typeof scope === "number") {
132
+ return scope;
133
+ }
134
+ if (!jsonOutput) {
135
+ output_manager_default.spinner("Posting reply\u2026");
136
+ }
137
+ try {
138
+ const message = await addMessage(client, scope.teamId, threadId, {
139
+ ...content !== void 0 && { markdown: content },
140
+ ...attach && attach.length > 0 && { attachments: attach.map((url) => ({ url })) }
141
+ });
142
+ if (jsonOutput) {
143
+ client.stdout.write(`${JSON.stringify(message, null, 2)}
144
+ `);
145
+ return 0;
146
+ }
147
+ output_manager_default.print(`${import_chalk.default.green("\u2713")} Replied to ${threadId}
148
+ `);
149
+ return 0;
150
+ } catch (err) {
151
+ if (isAPIError(err)) {
152
+ const { code, message } = toApiErrorParts(err);
153
+ return outputError(
154
+ client,
155
+ jsonOutput,
156
+ code,
157
+ err.status === 404 ? threadNotFoundMessage(threadId, scope) : message
158
+ );
159
+ }
160
+ throw err;
161
+ } finally {
162
+ output_manager_default.stopSpinner();
163
+ }
164
+ }
165
+ export {
166
+ reply as default
167
+ };