vercel 59.11.7 → 59.12.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 (125) hide show
  1. package/dist/chunks/{add-KSJQYR5C.js → add-OO3JGLZW.js} +3 -3
  2. package/dist/chunks/{add-WU2QYHYL.js → add-RTXDASSS.js} +3 -3
  3. package/dist/chunks/add-XGO6LHMD.js +221 -0
  4. package/dist/chunks/{build-F3J6FLPD.js → build-JINV2UD4.js} +3 -3
  5. package/dist/chunks/chunk-2NIDTSQJ.js +305 -0
  6. package/dist/chunks/{chunk-SHFNEZVI.js → chunk-32XSMM3W.js} +1 -1
  7. package/dist/chunks/{chunk-N4QHMXOO.js → chunk-3BB2HOO2.js} +3 -2
  8. package/dist/chunks/{chunk-DSTNNQVV.js → chunk-3F25W3GA.js} +3 -3
  9. package/dist/chunks/{chunk-OIH6FP5Y.js → chunk-4TUMNBEE.js} +2 -2
  10. package/dist/chunks/{chunk-4IVSM24H.js → chunk-ABSZNJQO.js} +1 -1
  11. package/dist/chunks/{chunk-CNDPIHY5.js → chunk-AV747POV.js} +24 -19
  12. package/dist/chunks/{chunk-QHS645AZ.js → chunk-CZ5QQRXD.js} +3 -3
  13. package/dist/chunks/{chunk-FL4JLNT2.js → chunk-E47NARDE.js} +2 -2
  14. package/dist/chunks/{chunk-XM3LOQIX.js → chunk-EDMW7SBH.js} +76 -92
  15. package/dist/chunks/{chunk-PJXMXMCO.js → chunk-ELZ6WQQA.js} +2 -2
  16. package/dist/chunks/{chunk-FVNJTRCE.js → chunk-EOLGLGXJ.js} +2 -2
  17. package/dist/chunks/chunk-GDOUDU6O.js +74 -0
  18. package/dist/chunks/{chunk-GCVXKRR5.js → chunk-HD4DR3DA.js} +1 -0
  19. package/dist/chunks/{chunk-DWIC7MRV.js → chunk-HKHXKSXQ.js} +1 -1
  20. package/dist/chunks/{chunk-ZBEECGFD.js → chunk-HM24ZWQL.js} +1 -1
  21. package/dist/chunks/chunk-HR2MP4XF.js +324 -0
  22. package/dist/chunks/{chunk-EZQDYIVB.js → chunk-JOXNBQ7W.js} +1 -1
  23. package/dist/chunks/{chunk-DBYHS3CK.js → chunk-KAF4WFF3.js} +2 -2
  24. package/dist/chunks/{chunk-VYC45Q4Z.js → chunk-KNO327AW.js} +1 -1
  25. package/dist/chunks/{chunk-XD4DCYMX.js → chunk-L6B6BRHH.js} +2 -2
  26. package/dist/chunks/{chunk-X7DBBZQD.js → chunk-LDV2R4P4.js} +1 -1
  27. package/dist/chunks/{chunk-2TSBB22D.js → chunk-MADFAH3O.js} +2 -2
  28. package/dist/chunks/{chunk-TGNEG57M.js → chunk-MDGPZHSM.js} +110 -14
  29. package/dist/chunks/{chunk-XIFATBH5.js → chunk-NDY3JDOU.js} +4 -4
  30. package/dist/chunks/{chunk-NSOYO6JQ.js → chunk-OJHDGHOB.js} +6 -6
  31. package/dist/chunks/{chunk-KJBZ5ZST.js → chunk-PIMIVJYK.js} +1 -0
  32. package/dist/chunks/{chunk-C762AAVU.js → chunk-PP5GKSIX.js} +4 -4
  33. package/dist/chunks/{chunk-Z7JWYFOY.js → chunk-QB2UHSUB.js} +1 -1
  34. package/dist/chunks/chunk-QIUK4Z7Q.js +79 -0
  35. package/dist/chunks/{chunk-GHKJAK5V.js → chunk-RNK3LXLR.js} +4 -4
  36. package/dist/chunks/{chunk-CEDN47PH.js → chunk-SWO66HE2.js} +1 -1
  37. package/dist/chunks/{chunk-EPOLDWRA.js → chunk-TDGK45FB.js} +1 -1
  38. package/dist/chunks/{chunk-PFM75KY3.js → chunk-UA55I7M6.js} +3 -3
  39. package/dist/chunks/{chunk-VT3Z7HF6.js → chunk-UJPVHLL5.js} +4 -4
  40. package/dist/chunks/{chunk-UARGTFCT.js → chunk-VJSREJVM.js} +1 -1
  41. package/dist/chunks/{chunk-WL6QYSGD.js → chunk-WPBCUXMZ.js} +506 -22
  42. package/dist/chunks/{chunk-A5JZS6ZN.js → chunk-WSZ5E4WH.js} +1 -1
  43. package/dist/chunks/{chunk-GUU4Z2AQ.js → chunk-WT2Y7FRD.js} +6 -6
  44. package/dist/chunks/{chunk-G3PXSXIB.js → chunk-WT6C2ALC.js} +3 -3
  45. package/dist/chunks/{chunk-7KROIXQM.js → chunk-X6TGUHFD.js} +3 -3
  46. package/dist/chunks/{chunk-QOPTXV4G.js → chunk-YPMFZRTN.js} +1 -1
  47. package/dist/chunks/{chunk-FVT74RZ5.js → chunk-YRESLJCW.js} +11 -11
  48. package/dist/chunks/{clear-XUQO4ZTK.js → clear-GQTDYSKJ.js} +3 -3
  49. package/dist/chunks/{compile-vercel-config-D3ARNHTN.js → compile-vercel-config-URVMKDVW.js} +2 -2
  50. package/dist/chunks/{config-37OAE7QJ.js → config-MSVQR5T6.js} +7 -7
  51. package/dist/chunks/{config-MEDLXUVM.js → config-OAXY4J6P.js} +3 -3
  52. package/dist/chunks/config-validator.mjs +1 -1
  53. package/dist/chunks/{delete-VSWDZ2SW.js → delete-57QO64HD.js} +5 -5
  54. package/dist/chunks/{delete-3N3YZZOF.js → delete-XN6ESD7C.js} +5 -5
  55. package/dist/chunks/{detect-services-TESZCQWG.js → detect-services-UPY4LTBZ.js} +6 -6
  56. package/dist/chunks/{disable-A4FLFMC7.js → disable-BYI46V7B.js} +5 -5
  57. package/dist/chunks/{discard-CHGFULBZ.js → discard-IIQL44ZZ.js} +5 -5
  58. package/dist/chunks/{edit-MHSYAPDR.js → edit-BRNS3OR4.js} +6 -6
  59. package/dist/chunks/{edit-JZ63AJYQ.js → edit-JTW7XZH7.js} +5 -5
  60. package/dist/chunks/{enable-KD46SEC5.js → enable-CH5FSQMR.js} +5 -5
  61. package/dist/chunks/{export-42QZLBSN.js → export-6WHQOWKM.js} +5 -5
  62. package/dist/chunks/{image-GP4H73A2.js → image-ZSLYATWG.js} +3 -3
  63. package/dist/chunks/{import-builders-6TBLMPL2.js → import-builders-FNMYJZGG.js} +4 -4
  64. package/dist/chunks/{inspect-5FMWMY3C.js → inspect-4RDZSYWU.js} +10 -10
  65. package/dist/chunks/{inspect-MUVK6MMT.js → inspect-7WQXZWET.js} +3 -3
  66. package/dist/chunks/{inspect-Q3DWW7MC.js → inspect-CGXTNMMO.js} +9 -9
  67. package/dist/chunks/{inspect-RNTSYM6O.js → inspect-XJ7BYLZ5.js} +3 -3
  68. package/dist/chunks/{inspect-QFXAOUL4.js → inspect-Z2MBTTB7.js} +3 -3
  69. package/dist/chunks/{list-IHHIPXEC.js → list-65LW6OTM.js} +6 -6
  70. package/dist/chunks/{list-XHD5DLEX.js → list-7W3PHRB6.js} +7 -7
  71. package/dist/chunks/{list-JRNWLSO5.js → list-KS22Y57L.js} +2 -2
  72. package/dist/chunks/{login-PCT6KFWY.js → login-NXULVQZ2.js} +3 -3
  73. package/dist/chunks/{ls-TGHCCARZ.js → ls-35EOVEIQ.js} +4 -4
  74. package/dist/chunks/{ls-PQZ2RIDX.js → ls-5GKS5QRW.js} +4 -4
  75. package/dist/chunks/ls-ADYFYYIW.js +204 -0
  76. package/dist/chunks/{ls-SVOHC3XW.js → ls-DZYN3SNS.js} +4 -4
  77. package/dist/chunks/{ls-VRIH5WA3.js → ls-HVQOGBGV.js} +7 -7
  78. package/dist/chunks/{ls-GPEHEFCF.js → ls-I2PWG7YN.js} +4 -4
  79. package/dist/chunks/{open-E7DEKYDU.js → open-H34HXJHP.js} +5 -5
  80. package/dist/chunks/{permissions-JKOONWVL.js → permissions-ZPPEPKVE.js} +4 -4
  81. package/dist/chunks/{publish-EDDELDE5.js → publish-NRMKXHAU.js} +5 -5
  82. package/dist/chunks/{pull-646WEVDE.js → pull-WUT3XTZX.js} +7 -7
  83. package/dist/chunks/{push-LTNW5OVD.js → push-WFNCEA5J.js} +3 -3
  84. package/dist/chunks/{query-LU4N6KPO.js → query-2FQM3F7N.js} +7 -7
  85. package/dist/chunks/{reorder-22PKJMZP.js → reorder-GYCT7L3C.js} +5 -5
  86. package/dist/chunks/{reply-SF2EZMVZ.js → reply-RFEXNYZ7.js} +5 -5
  87. package/dist/chunks/{resolve-ZCZGXTOT.js → resolve-ZFGT7W6Z.js} +5 -5
  88. package/dist/chunks/{restore-VJAWZXB4.js → restore-JAXPMYL5.js} +5 -5
  89. package/dist/chunks/rm-CLKQN5E4.js +162 -0
  90. package/dist/chunks/{rm-WNPGTUBH.js → rm-JPV5V2SH.js} +3 -3
  91. package/dist/chunks/{rm-KN2QFCKO.js → rm-N7SGFQOA.js} +3 -3
  92. package/dist/chunks/{rm-KVEAJPRE.js → rm-UQJ4CZJH.js} +3 -3
  93. package/dist/chunks/{rm-OSZ5FZUM.js → rm-ZUQ4U454.js} +7 -7
  94. package/dist/chunks/rule-inspect-HI3YY7OY.js +123 -0
  95. package/dist/chunks/{rules-65LKAQ35.js → rules-DA3Q64M4.js} +7 -7
  96. package/dist/chunks/{schema-NXCW4M75.js → schema-R3C4CXJ6.js} +6 -6
  97. package/dist/chunks/schema-UYYFV3JB.js +381 -0
  98. package/dist/chunks/{set-FYJVKMPV.js → set-TOJPGW4J.js} +7 -7
  99. package/dist/chunks/{setup-and-link-KXPZE32P.js → setup-and-link-DRYXQOH4.js} +16 -16
  100. package/dist/chunks/{tags-ANIRP5E3.js → tags-TNLVFNVI.js} +2 -2
  101. package/dist/chunks/update-X6JB3NPI.js +224 -0
  102. package/dist/chunks/vlt-builder-importer-USCFHWPL.js +322 -0
  103. package/dist/commands/build/index.js +19 -19
  104. package/dist/commands/deploy/index.js +19 -19
  105. package/dist/commands/dev/index.js +25 -25
  106. package/dist/commands/env/index.js +12 -12
  107. package/dist/commands/link/index.js +12 -12
  108. package/dist/commands/list/index.js +5 -5
  109. package/dist/commands-bulk.js +8273 -3511
  110. package/dist/help.js +1 -1
  111. package/dist/index.js +28 -18
  112. package/dist/runtime-assets/node-preloads/next-dev-websocket.cjs +6 -0
  113. package/dist/version.mjs +1 -1
  114. package/package.json +52 -48
  115. package/dist/chunks/add-PERLOALD.js +0 -233
  116. package/dist/chunks/chunk-5GGUB4EO.js +0 -31
  117. package/dist/chunks/chunk-ARU7VBKR.js +0 -144
  118. package/dist/chunks/chunk-KEKR7OCB.js +0 -140
  119. package/dist/chunks/chunk-MXLA3VQS.js +0 -20
  120. package/dist/chunks/chunk-QKX7WKIN.js +0 -98
  121. package/dist/chunks/ls-PF7F4PP4.js +0 -197
  122. package/dist/chunks/rm-W722Q2AO.js +0 -173
  123. package/dist/chunks/rule-inspect-25Z6SNX3.js +0 -285
  124. package/dist/chunks/schema-7D6IGJEJ.js +0 -429
  125. package/dist/chunks/update-UT6CTKVG.js +0 -246
@@ -1,173 +0,0 @@
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
- emitRulesArgParseError,
9
- handleRulesApiError,
10
- parseRulesFlagsAndScope,
11
- rulesItemPath
12
- } from "./chunk-KEKR7OCB.js";
13
- import "./chunk-N4QHMXOO.js";
14
- import "./chunk-KFWQ3EFH.js";
15
- import {
16
- validateJsonOutput
17
- } from "./chunk-KXDWXXJH.js";
18
- import {
19
- rulesRmSubcommand
20
- } from "./chunk-XM3LOQIX.js";
21
- import "./chunk-GGP5R3FU.js";
22
- import {
23
- AGENT_REASON
24
- } from "./chunk-VUS2JQB2.js";
25
- import "./chunk-4IVSM24H.js";
26
- import "./chunk-XNIZGCN5.js";
27
- import {
28
- printError
29
- } from "./chunk-3VM7HWF6.js";
30
- import {
31
- parseArguments
32
- } from "./chunk-57RHXXXG.js";
33
- import "./chunk-2TSBB22D.js";
34
- import "./chunk-G5FBSUL4.js";
35
- import {
36
- buildCommandWithGlobalFlags,
37
- buildCommandWithYes,
38
- outputAgentError
39
- } from "./chunk-26CU4Q3C.js";
40
- import "./chunk-XPJLPUKO.js";
41
- import {
42
- isAPIError
43
- } from "./chunk-CV5YC2EN.js";
44
- import {
45
- getFlagsSpecification,
46
- packageName
47
- } from "./chunk-Q2DGFCO7.js";
48
- import {
49
- output_manager_default
50
- } from "./chunk-2JIX6UMI.js";
51
- import "./chunk-P4QNYOFB.js";
52
- import "./chunk-ZW6HETRE.js";
53
- import "./chunk-S7KYDPEM.js";
54
- import "./chunk-TZ2YI2VH.js";
55
-
56
- // src/commands/alerts/rules/rm.ts
57
- async function rm(client, argv) {
58
- let parsedArgs;
59
- try {
60
- parsedArgs = parseArguments(
61
- argv,
62
- getFlagsSpecification(rulesRmSubcommand.options)
63
- );
64
- } catch (e) {
65
- emitRulesArgParseError(
66
- client,
67
- e,
68
- "alerts rules rm <ruleId> --project <name-or-id> --yes"
69
- );
70
- printError(e);
71
- return 1;
72
- }
73
- const ruleId = parsedArgs.args[0];
74
- const fr = validateJsonOutput(parsedArgs.flags);
75
- if (!fr.valid) {
76
- outputAgentError(
77
- client,
78
- {
79
- status: "error",
80
- reason: AGENT_REASON.INVALID_ARGUMENTS,
81
- message: fr.error
82
- },
83
- 1
84
- );
85
- output_manager_default.error(fr.error);
86
- return 1;
87
- }
88
- if (!ruleId) {
89
- outputAgentError(
90
- client,
91
- {
92
- status: "error",
93
- reason: AGENT_REASON.MISSING_ARGUMENTS,
94
- message: `Missing rule id. Example: ${packageName} alerts rules rm <ruleId> --yes`,
95
- next: [
96
- {
97
- command: buildCommandWithGlobalFlags(
98
- client.argv,
99
- "alerts rules rm <ruleId> --yes"
100
- ),
101
- when: "Replace <ruleId> with an id from `alerts rules ls`"
102
- },
103
- {
104
- command: buildCommandWithGlobalFlags(
105
- client.argv,
106
- "alerts rules ls"
107
- ),
108
- when: "List rule ids in the current scope"
109
- }
110
- ]
111
- },
112
- 1
113
- );
114
- output_manager_default.error("Usage: `vercel alerts rules rm <ruleId>`");
115
- return 1;
116
- }
117
- const skipConfirmation = Boolean(parsedArgs.flags["--yes"]);
118
- const scope = await parseRulesFlagsAndScope(
119
- client,
120
- {
121
- "--project": parsedArgs.flags["--project"],
122
- "--all": parsedArgs.flags["--all"]
123
- },
124
- fr.jsonOutput,
125
- `alerts rules rm ${ruleId}`
126
- );
127
- if (typeof scope === "number") {
128
- return scope;
129
- }
130
- if (!skipConfirmation) {
131
- outputAgentError(
132
- client,
133
- {
134
- status: "error",
135
- reason: AGENT_REASON.CONFIRMATION_REQUIRED,
136
- message: "Removing an alert rule requires confirmation. Re-run with --yes.",
137
- next: [{ command: buildCommandWithYes(client.argv) }]
138
- },
139
- 1
140
- );
141
- if (!await client.input.confirm(
142
- `Delete alert rule ${ruleId}? This cannot be undone.`,
143
- false
144
- )) {
145
- output_manager_default.log("Canceled");
146
- return 0;
147
- }
148
- }
149
- const path = rulesItemPath(scope, ruleId);
150
- output_manager_default.spinner("Deleting alert rule...");
151
- try {
152
- await client.fetch(path, { method: "DELETE" });
153
- if (fr.jsonOutput) {
154
- client.stdout.write(
155
- `${JSON.stringify({ ok: true, ruleId, deleted: true }, null, 2)}
156
- `
157
- );
158
- } else {
159
- output_manager_default.success(`Deleted alert rule ${ruleId}`);
160
- }
161
- return 0;
162
- } catch (err) {
163
- if (isAPIError(err)) {
164
- return handleRulesApiError(client, err, fr.jsonOutput);
165
- }
166
- throw err;
167
- } finally {
168
- output_manager_default.stopSpinner();
169
- }
170
- }
171
- export {
172
- rm as default
173
- };
@@ -1,285 +0,0 @@
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
- humanizeReference,
12
- isCustomAlertRule,
13
- parseCustomAlertQuery,
14
- renderAlertTable
15
- } from "./chunk-ARU7VBKR.js";
16
- import {
17
- emitRulesArgParseError,
18
- handleRulesApiError,
19
- parseRulesFlagsAndScope,
20
- rulesItemPath
21
- } from "./chunk-KEKR7OCB.js";
22
- import "./chunk-N4QHMXOO.js";
23
- import {
24
- formatDate
25
- } from "./chunk-GZLPFESR.js";
26
- import {
27
- formatGranularity
28
- } from "./chunk-5AJPMLDV.js";
29
- import "./chunk-A3NYPUKZ.js";
30
- import "./chunk-KFWQ3EFH.js";
31
- import "./chunk-FGDKMNEN.js";
32
- import "./chunk-PRWJUY5U.js";
33
- import {
34
- truncateMiddle
35
- } from "./chunk-ND5CF2H3.js";
36
- import {
37
- validateJsonOutput
38
- } from "./chunk-KXDWXXJH.js";
39
- import {
40
- rulesInspectSubcommand
41
- } from "./chunk-XM3LOQIX.js";
42
- import "./chunk-GGP5R3FU.js";
43
- import {
44
- AGENT_REASON
45
- } from "./chunk-VUS2JQB2.js";
46
- import "./chunk-NW34PW6V.js";
47
- import "./chunk-4IVSM24H.js";
48
- import "./chunk-XNIZGCN5.js";
49
- import {
50
- printError
51
- } from "./chunk-3VM7HWF6.js";
52
- import {
53
- parseArguments
54
- } from "./chunk-57RHXXXG.js";
55
- import "./chunk-2TSBB22D.js";
56
- import "./chunk-G5FBSUL4.js";
57
- import {
58
- buildCommandWithGlobalFlags,
59
- outputAgentError
60
- } from "./chunk-26CU4Q3C.js";
61
- import "./chunk-XPJLPUKO.js";
62
- import {
63
- isAPIError
64
- } from "./chunk-CV5YC2EN.js";
65
- import {
66
- getFlagsSpecification,
67
- packageName
68
- } from "./chunk-Q2DGFCO7.js";
69
- import {
70
- output_manager_default
71
- } from "./chunk-2JIX6UMI.js";
72
- import "./chunk-P4QNYOFB.js";
73
- import "./chunk-ZW6HETRE.js";
74
- import {
75
- require_source
76
- } from "./chunk-S7KYDPEM.js";
77
- import {
78
- __toESM
79
- } from "./chunk-TZ2YI2VH.js";
80
-
81
- // src/commands/alerts/rules/rule-inspect.ts
82
- var import_chalk = __toESM(require_source(), 1);
83
- function formatBoolean(value) {
84
- if (value === void 0) {
85
- return "-";
86
- }
87
- return value ? "yes" : "no";
88
- }
89
- function getAlertTypeRows(rule) {
90
- const types = rule.alertTypes?.map((alertType) => alertType.type) ?? (rule.customAlert ? ["custom_alert"] : []);
91
- if (types.length === 0) {
92
- return [];
93
- }
94
- const uniqueTypes = [...new Set(types)];
95
- return [
96
- [
97
- uniqueTypes.length === 1 ? "Type" : "Types",
98
- uniqueTypes.map((value) => humanizeReference(value)).join(", ")
99
- ]
100
- ];
101
- }
102
- function getNotificationRows(rule) {
103
- const rows = [];
104
- if (rule.autosubscribeOwnersInKnock !== void 0) {
105
- rows.push([
106
- "Auto-subscribe owners",
107
- formatBoolean(rule.autosubscribeOwnersInKnock)
108
- ]);
109
- }
110
- const slackChannels = /* @__PURE__ */ new Set();
111
- const webhooks = /* @__PURE__ */ new Set();
112
- for (const notification of rule.notifications ?? []) {
113
- for (const channel of notification.slack ?? []) {
114
- slackChannels.add(channel);
115
- }
116
- for (const webhook of notification.webhooks ?? []) {
117
- webhooks.add(webhook);
118
- }
119
- }
120
- if (slackChannels.size > 0) {
121
- rows.push(["Slack", [...slackChannels].join(", ")]);
122
- }
123
- if (webhooks.size > 0) {
124
- rows.push(["Webhooks", [...webhooks].join(", ")]);
125
- }
126
- return rows;
127
- }
128
- function getCustomAlertRows(customAlert) {
129
- const query = parseCustomAlertQuery(customAlert.queryJsonString);
130
- const granularity = formatGranularity(query.granularity);
131
- const groupBy = query.groupBy ?? [];
132
- const rows = [
133
- ["Title", customAlert.title || "-"],
134
- ["Metric", formatCustomAlertMetric(customAlert) || "-"],
135
- ["Trigger", formatCustomAlertTrigger(customAlert) || "-"],
136
- ...typeof customAlert.minThreshold === "number" ? [["Minimum", String(customAlert.minThreshold)]] : [],
137
- ...query.event ? [["Event", humanizeReference(query.event)]] : [],
138
- ...groupBy.length > 0 ? [
139
- [
140
- "Group By",
141
- groupBy.map((value) => humanizeReference(value)).join(", ")
142
- ]
143
- ] : [],
144
- ...granularity ? [["Granularity", granularity]] : [],
145
- ...customAlert.createdAt ? [["Created At", formatDate(customAlert.createdAt)]] : []
146
- ];
147
- return rows.map(([label, value]) => [label, truncateMiddle(value, 96)]);
148
- }
149
- function printRule(rule, ruleId) {
150
- const summaryRows = [
151
- ["Name", rule.name || "-"],
152
- ...rule.action === "exclude" ? [["Action", rule.action]] : [],
153
- ["Scope", formatRuleScope(rule)],
154
- ...getAlertTypeRows(rule),
155
- ...rule.isDefault !== void 0 ? [["Default", formatBoolean(rule.isDefault)]] : [],
156
- ...rule.owner ? [["Owner", rule.owner]] : [],
157
- ...rule.teamId ? [["Team id", rule.teamId]] : [],
158
- ...rule.lastEditedByUserId ? [["Last Edited By", rule.lastEditedByUserId]] : [],
159
- ...rule.odataFilters ? [["OData Filters", rule.odataFilters]] : []
160
- ];
161
- const sections = [
162
- "",
163
- `${import_chalk.default.bold("Alert rule")} ${import_chalk.default.cyan(rule.id || ruleId)}`,
164
- renderAlertTable(summaryRows, 3)
165
- ];
166
- const notificationRows = getNotificationRows(rule);
167
- if (notificationRows.length > 0) {
168
- sections.push(
169
- "",
170
- import_chalk.default.cyan("Notifications"),
171
- renderAlertTable(notificationRows, 3)
172
- );
173
- }
174
- if (rule.customAlert) {
175
- sections.push(
176
- "",
177
- import_chalk.default.cyan("Custom Alert"),
178
- renderAlertTable(getCustomAlertRows(rule.customAlert), 3)
179
- );
180
- } else if (isCustomAlertRule(rule)) {
181
- sections.push(
182
- "",
183
- import_chalk.default.cyan("Custom Alert"),
184
- " No custom alert definition returned."
185
- );
186
- }
187
- output_manager_default.print(`${sections.join("\n")}
188
- `);
189
- }
190
- async function ruleInspect(client, argv) {
191
- let parsedArgs;
192
- try {
193
- parsedArgs = parseArguments(
194
- argv,
195
- getFlagsSpecification(rulesInspectSubcommand.options)
196
- );
197
- } catch (e) {
198
- emitRulesArgParseError(
199
- client,
200
- e,
201
- "alerts rules inspect <ruleId> --project <name-or-id>"
202
- );
203
- printError(e);
204
- return 1;
205
- }
206
- const ruleId = parsedArgs.args[0];
207
- const fr = validateJsonOutput(parsedArgs.flags);
208
- if (!fr.valid) {
209
- outputAgentError(
210
- client,
211
- {
212
- status: "error",
213
- reason: AGENT_REASON.INVALID_ARGUMENTS,
214
- message: fr.error
215
- },
216
- 1
217
- );
218
- output_manager_default.error(fr.error);
219
- return 1;
220
- }
221
- if (!ruleId) {
222
- outputAgentError(
223
- client,
224
- {
225
- status: "error",
226
- reason: AGENT_REASON.MISSING_ARGUMENTS,
227
- message: `Missing rule id. Example: ${packageName} alerts rules inspect <ruleId>`,
228
- next: [
229
- {
230
- command: buildCommandWithGlobalFlags(
231
- client.argv,
232
- "alerts rules inspect <ruleId>"
233
- ),
234
- when: "Replace <ruleId> with an id from `alerts rules ls`"
235
- },
236
- {
237
- command: buildCommandWithGlobalFlags(
238
- client.argv,
239
- "alerts rules ls"
240
- ),
241
- when: "List rule ids in the current scope"
242
- }
243
- ]
244
- },
245
- 1
246
- );
247
- output_manager_default.error("Usage: `vercel alerts rules inspect <ruleId>`");
248
- return 1;
249
- }
250
- const scope = await parseRulesFlagsAndScope(
251
- client,
252
- {
253
- "--project": parsedArgs.flags["--project"],
254
- "--all": parsedArgs.flags["--all"]
255
- },
256
- fr.jsonOutput,
257
- `alerts rules inspect ${ruleId}`
258
- );
259
- if (typeof scope === "number") {
260
- return scope;
261
- }
262
- const path = rulesItemPath(scope, ruleId);
263
- output_manager_default.spinner("Fetching alert rule...");
264
- try {
265
- const rule = await client.fetch(path);
266
- output_manager_default.stopSpinner();
267
- if (fr.jsonOutput) {
268
- client.stdout.write(`${JSON.stringify({ rule }, null, 2)}
269
- `);
270
- } else {
271
- printRule(rule, ruleId);
272
- }
273
- return 0;
274
- } catch (err) {
275
- if (isAPIError(err)) {
276
- return handleRulesApiError(client, err, fr.jsonOutput);
277
- }
278
- throw err;
279
- } finally {
280
- output_manager_default.stopSpinner();
281
- }
282
- }
283
- export {
284
- ruleInspect as default
285
- };