@sentry/junior-vercel 0.301.0 → 0.303.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.
- package/dist/handler-yrda69iT.js +299 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +278 -351
- package/dist/testing.d.ts +404 -3
- package/dist/testing.js +1 -10
- package/package.json +9 -12
- package/dist/chunk-QCT7VK3J.js +0 -334
- package/dist/events/deployment.d.ts +0 -37
- package/dist/project.d.ts +0 -3
- package/dist/tools/actions.d.ts +0 -1024
- package/dist/tools/deployment.d.ts +0 -220
- package/dist/webhooks/events.d.ts +0 -14
- package/dist/webhooks/handler.d.ts +0 -6
- package/dist/webhooks/secret.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -1,365 +1,292 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
VERCEL_DEPLOYMENT_MATCH_FIELDS,
|
|
4
|
-
VERCEL_DEPLOYMENT_SUGGESTED_EVENTS,
|
|
5
|
-
createVercelDeploymentTool,
|
|
6
|
-
createVercelWebhookRoute
|
|
7
|
-
} from "./chunk-QCT7VK3J.js";
|
|
8
|
-
|
|
9
|
-
// src/index.ts
|
|
10
|
-
import {
|
|
11
|
-
defineJuniorPlugin
|
|
12
|
-
} from "@sentry/junior-plugin-api";
|
|
13
|
-
|
|
14
|
-
// src/tools/actions.ts
|
|
15
|
-
import {
|
|
16
|
-
definePluginTool,
|
|
17
|
-
PluginToolInputError,
|
|
18
|
-
pluginToolOutputSchema
|
|
19
|
-
} from "@sentry/junior-plugin-api";
|
|
1
|
+
import { a as VERCEL_DEPLOYMENT_MATCH_FIELDS, i as VERCEL_DEPLOYMENT_EVENTS, o as VERCEL_DEPLOYMENT_SUGGESTED_EVENTS, r as vercelDeploymentTool, t as createVercelWebhookRoute } from "./handler-yrda69iT.js";
|
|
2
|
+
import { PluginToolInputError, defineJuniorPlugin, definePluginTool, pluginToolOutputSchema } from "@sentry/junior-plugin-api";
|
|
20
3
|
import * as z from "zod";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
).
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
4
|
+
// src/tools/actions.ts
|
|
5
|
+
const text = z.string().trim().min(1);
|
|
6
|
+
const team = text.describe("Vercel team slug or team_ ID. Omit for the token's default account.").optional();
|
|
7
|
+
const deploymentIdSchema = z.string().regex(/^dpl_[a-zA-Z0-9]+$/).describe("Exact Vercel deployment ID, not an alias.");
|
|
8
|
+
const aliasName = z.string().regex(/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?\.[a-z]{2,}$/).describe("Alias hostname without a scheme or path.");
|
|
9
|
+
const deploymentSchema = z.object({
|
|
10
|
+
id: text,
|
|
11
|
+
url: text,
|
|
12
|
+
readyState: text,
|
|
13
|
+
target: z.string().nullable().optional(),
|
|
14
|
+
projectId: text.optional(),
|
|
15
|
+
gitSource: z.object({
|
|
16
|
+
sha: text.optional(),
|
|
17
|
+
ref: text.optional()
|
|
18
|
+
}).nullable().optional()
|
|
34
19
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
20
|
+
const deploymentOutput = pluginToolOutputSchema.extend({
|
|
21
|
+
target: z.literal("deployment"),
|
|
22
|
+
deployment_id: text,
|
|
23
|
+
url: text,
|
|
24
|
+
state: text,
|
|
25
|
+
deployment_target: z.string().nullable(),
|
|
26
|
+
project_id: text.nullable(),
|
|
27
|
+
commit_sha: text.nullable(),
|
|
28
|
+
ref: text.nullable()
|
|
44
29
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
30
|
+
const aliasSchema = z.object({
|
|
31
|
+
alias: text,
|
|
32
|
+
deploymentId: text.nullable(),
|
|
33
|
+
redirect: text.nullable().optional()
|
|
49
34
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
const aliasOutput = pluginToolOutputSchema.extend({
|
|
36
|
+
target: z.literal("alias"),
|
|
37
|
+
alias: text,
|
|
38
|
+
deployment_id: text.nullable(),
|
|
39
|
+
redirect: text.nullable()
|
|
55
40
|
});
|
|
56
41
|
function deploymentResult(data) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
]
|
|
86
|
-
};
|
|
42
|
+
const value = deploymentSchema.parse(data);
|
|
43
|
+
return {
|
|
44
|
+
target: "deployment",
|
|
45
|
+
deployment_id: value.id,
|
|
46
|
+
url: `https://${value.url}`,
|
|
47
|
+
state: value.readyState,
|
|
48
|
+
deployment_target: value.target ?? null,
|
|
49
|
+
project_id: value.projectId ?? null,
|
|
50
|
+
commit_sha: value.gitSource?.sha ?? null,
|
|
51
|
+
ref: value.gitSource?.ref ?? null,
|
|
52
|
+
objectAnnotations: [{
|
|
53
|
+
kind: "object",
|
|
54
|
+
objectType: "deployment",
|
|
55
|
+
displayType: "Deployment",
|
|
56
|
+
key: value.id,
|
|
57
|
+
label: value.id,
|
|
58
|
+
title: value.url.slice(0, 512),
|
|
59
|
+
url: `https://${value.url}`,
|
|
60
|
+
status: value.readyState,
|
|
61
|
+
facts: {
|
|
62
|
+
type: "deployment",
|
|
63
|
+
project: value.projectId?.slice(0, 64),
|
|
64
|
+
environment: value.target?.slice(0, 64) ?? void 0,
|
|
65
|
+
revision: value.gitSource?.sha?.slice(0, 64),
|
|
66
|
+
branch: value.gitSource?.ref?.slice(0, 64)
|
|
67
|
+
}
|
|
68
|
+
}]
|
|
69
|
+
};
|
|
87
70
|
}
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (response.status === 400 || response.status === 404)
|
|
113
|
-
throw new PluginToolInputError(message);
|
|
114
|
-
throw new Error(message);
|
|
115
|
-
}
|
|
116
|
-
if (response.status === 204) return void 0;
|
|
117
|
-
return response.json();
|
|
118
|
-
}
|
|
119
|
-
async function inspectAlias(alias, scope) {
|
|
120
|
-
const result = aliasSchema.parse(
|
|
121
|
-
await request(
|
|
122
|
-
"vercel.alias.get",
|
|
123
|
-
`/v4/aliases/${encodeURIComponent(alias)}`,
|
|
124
|
-
scope
|
|
125
|
-
)
|
|
126
|
-
);
|
|
127
|
-
return {
|
|
128
|
-
target: "alias",
|
|
129
|
-
alias: result.alias,
|
|
130
|
-
deployment_id: result.deploymentId,
|
|
131
|
-
redirect: result.redirect ?? null
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
deploymentCreate: definePluginTool({
|
|
136
|
-
annotations: {
|
|
137
|
-
destructiveHint: true,
|
|
138
|
-
idempotentHint: false,
|
|
139
|
-
openWorldHint: true,
|
|
140
|
-
readOnlyHint: false
|
|
141
|
-
},
|
|
142
|
-
description: "Start a deployment from a Vercel project's linked GitHub repository. Uses project build settings and environment credentials, so builds may run migrations. Returns the new deployment; inspect it to check readiness.",
|
|
143
|
-
inputSchema: z.object({
|
|
144
|
-
project: text.describe("Existing Vercel project name or ID."),
|
|
145
|
-
team,
|
|
146
|
-
ref: text.describe(
|
|
147
|
-
"Git branch, tag, or full commit SHA in the project's linked repository."
|
|
148
|
-
),
|
|
149
|
-
commit_sha: z.string().regex(/^[a-f0-9]{40}$/i).describe(
|
|
150
|
-
"Full commit SHA to pin the source while retaining branch context in ref."
|
|
151
|
-
).optional(),
|
|
152
|
-
target: z.enum(["preview", "production"]).describe("Deployment environment; defaults to preview.").optional()
|
|
153
|
-
}).strict(),
|
|
154
|
-
outputSchema: deploymentOutput,
|
|
155
|
-
async execute(input) {
|
|
156
|
-
const project = z.object({
|
|
157
|
-
id: text,
|
|
158
|
-
name: text,
|
|
159
|
-
link: z.object({
|
|
160
|
-
type: text,
|
|
161
|
-
repoId: z.union([text, z.number()]).optional()
|
|
162
|
-
}).nullable().optional()
|
|
163
|
-
}).parse(
|
|
164
|
-
await request(
|
|
165
|
-
"vercel.project.get",
|
|
166
|
-
`/v9/projects/${encodeURIComponent(input.project)}`,
|
|
167
|
-
input.team
|
|
168
|
-
)
|
|
169
|
-
);
|
|
170
|
-
if (project.link?.type !== "github" || !project.link.repoId)
|
|
171
|
-
throw new PluginToolInputError(
|
|
172
|
-
"This deployment tool requires a project linked to GitHub. Use the Vercel CLI for other source types."
|
|
173
|
-
);
|
|
174
|
-
const gitSource = {
|
|
175
|
-
type: "github",
|
|
176
|
-
repoId: project.link.repoId,
|
|
177
|
-
ref: input.ref,
|
|
178
|
-
sha: input.commit_sha?.toLowerCase()
|
|
179
|
-
};
|
|
180
|
-
return deploymentResult(
|
|
181
|
-
await request(
|
|
182
|
-
"vercel.deployment.create",
|
|
183
|
-
"/v13/deployments",
|
|
184
|
-
input.team,
|
|
185
|
-
"POST",
|
|
186
|
-
{
|
|
187
|
-
name: project.name,
|
|
188
|
-
project: project.id,
|
|
189
|
-
// Vercel uses an omitted target for Preview, not "preview".
|
|
190
|
-
target: input.target === "production" ? "production" : void 0,
|
|
191
|
-
gitSource
|
|
192
|
-
}
|
|
193
|
-
)
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
}),
|
|
197
|
-
deploymentInspect: definePluginTool({
|
|
198
|
-
annotations: {
|
|
199
|
-
destructiveHint: false,
|
|
200
|
-
idempotentHint: true,
|
|
201
|
-
openWorldHint: true,
|
|
202
|
-
readOnlyHint: true
|
|
203
|
-
},
|
|
204
|
-
description: "Inspect a Vercel deployment by ID or hostname. Returns its ID, state, environment, and Git source when available. Use the CLI for logs.",
|
|
205
|
-
inputSchema: z.object({
|
|
206
|
-
deployment: text.describe(
|
|
207
|
-
"Deployment ID or hostname, without a scheme or path."
|
|
208
|
-
),
|
|
209
|
-
team
|
|
210
|
-
}).strict(),
|
|
211
|
-
outputSchema: deploymentOutput,
|
|
212
|
-
async execute(input) {
|
|
213
|
-
return deploymentResult(
|
|
214
|
-
await request(
|
|
215
|
-
"vercel.deployment.get",
|
|
216
|
-
`/v13/deployments/${encodeURIComponent(input.deployment)}?withGitRepoInfo=true`,
|
|
217
|
-
input.team
|
|
218
|
-
)
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
}),
|
|
222
|
-
aliasAssign: definePluginTool({
|
|
223
|
-
annotations: {
|
|
224
|
-
destructiveHint: true,
|
|
225
|
-
idempotentHint: true,
|
|
226
|
-
openWorldHint: true,
|
|
227
|
-
readOnlyHint: false
|
|
228
|
-
},
|
|
229
|
-
description: "Assign an alias hostname to a deployment ID. This can replace live traffic. Reads the alias back and returns matches=false if its target changed or it redirects.",
|
|
230
|
-
inputSchema: z.object({ deployment_id: deploymentIdSchema, alias: aliasName, team }).strict(),
|
|
231
|
-
outputSchema: aliasOutput.extend({ matches: z.boolean() }),
|
|
232
|
-
async execute(input) {
|
|
233
|
-
await request(
|
|
234
|
-
"vercel.alias.assign",
|
|
235
|
-
`/v2/deployments/${encodeURIComponent(input.deployment_id)}/aliases`,
|
|
236
|
-
input.team,
|
|
237
|
-
"POST",
|
|
238
|
-
{ alias: input.alias }
|
|
239
|
-
);
|
|
240
|
-
const result = await inspectAlias(input.alias, input.team);
|
|
241
|
-
return {
|
|
242
|
-
...result,
|
|
243
|
-
matches: result.deployment_id === input.deployment_id && !result.redirect
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
}),
|
|
247
|
-
aliasInspect: definePluginTool({
|
|
248
|
-
annotations: {
|
|
249
|
-
destructiveHint: false,
|
|
250
|
-
idempotentHint: true,
|
|
251
|
-
openWorldHint: true,
|
|
252
|
-
readOnlyHint: true
|
|
253
|
-
},
|
|
254
|
-
description: "Read a Vercel alias's current deployment ID or redirect.",
|
|
255
|
-
inputSchema: z.object({ alias: aliasName, team }).strict(),
|
|
256
|
-
outputSchema: aliasOutput,
|
|
257
|
-
async execute(input) {
|
|
258
|
-
return inspectAlias(input.alias, input.team);
|
|
259
|
-
}
|
|
260
|
-
}),
|
|
261
|
-
deploymentDelete: definePluginTool({
|
|
262
|
-
annotations: {
|
|
263
|
-
destructiveHint: true,
|
|
264
|
-
idempotentHint: true,
|
|
265
|
-
openWorldHint: true,
|
|
266
|
-
readOnlyHint: false
|
|
267
|
-
},
|
|
268
|
-
description: "Delete a Vercel deployment by ID. This can remove a live deployment. Does not delete its database or other external state.",
|
|
269
|
-
inputSchema: z.object({ deployment_id: deploymentIdSchema, team }).strict(),
|
|
270
|
-
outputSchema: pluginToolOutputSchema.extend({
|
|
271
|
-
target: z.literal("deployment"),
|
|
272
|
-
deployment_id: text,
|
|
273
|
-
deleted: z.literal(true)
|
|
274
|
-
}),
|
|
275
|
-
async execute(input) {
|
|
276
|
-
await request(
|
|
277
|
-
"vercel.deployment.delete",
|
|
278
|
-
`/v13/deployments/${encodeURIComponent(input.deployment_id)}`,
|
|
279
|
-
input.team,
|
|
280
|
-
"DELETE"
|
|
281
|
-
);
|
|
282
|
-
return {
|
|
283
|
-
target: "deployment",
|
|
284
|
-
deployment_id: input.deployment_id,
|
|
285
|
-
deleted: true
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
})
|
|
289
|
-
};
|
|
71
|
+
async function request(egress, operation, path, scope, method = "GET", body) {
|
|
72
|
+
const url = new URL(path, "https://api.vercel.com");
|
|
73
|
+
if (scope) url.searchParams.set(scope.startsWith("team_") ? "teamId" : "slug", scope);
|
|
74
|
+
const init = {
|
|
75
|
+
method,
|
|
76
|
+
redirect: "error",
|
|
77
|
+
signal: AbortSignal.timeout(3e4)
|
|
78
|
+
};
|
|
79
|
+
if (body !== void 0) {
|
|
80
|
+
init.headers = { "Content-Type": "application/json" };
|
|
81
|
+
init.body = JSON.stringify(body);
|
|
82
|
+
}
|
|
83
|
+
const response = await egress.fetch({
|
|
84
|
+
provider: "vercel",
|
|
85
|
+
operation,
|
|
86
|
+
request: new Request(url, init)
|
|
87
|
+
});
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
const message = `${operation} failed with HTTP ${response.status}`;
|
|
90
|
+
if (response.status === 400 || response.status === 404) throw new PluginToolInputError(message);
|
|
91
|
+
throw new Error(message);
|
|
92
|
+
}
|
|
93
|
+
if (response.status === 204) return void 0;
|
|
94
|
+
return response.json();
|
|
290
95
|
}
|
|
291
|
-
|
|
96
|
+
async function inspectAlias(egress, alias, scope) {
|
|
97
|
+
const result = aliasSchema.parse(await request(egress, "vercel.alias.get", `/v4/aliases/${encodeURIComponent(alias)}`, scope));
|
|
98
|
+
return {
|
|
99
|
+
target: "alias",
|
|
100
|
+
alias: result.alias,
|
|
101
|
+
deployment_id: result.deploymentId,
|
|
102
|
+
redirect: result.redirect ?? null
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** Vercel deployment and alias operations. */
|
|
106
|
+
const vercelActionTools = {
|
|
107
|
+
deploymentCreate: definePluginTool({
|
|
108
|
+
annotations: {
|
|
109
|
+
destructiveHint: true,
|
|
110
|
+
idempotentHint: false,
|
|
111
|
+
openWorldHint: true,
|
|
112
|
+
readOnlyHint: false
|
|
113
|
+
},
|
|
114
|
+
description: "Start a deployment from a Vercel project's linked GitHub repository. Uses project build settings and environment credentials, so builds may run migrations. Returns the new deployment; inspect it to check readiness.",
|
|
115
|
+
inputSchema: z.object({
|
|
116
|
+
project: text.describe("Existing Vercel project name or ID."),
|
|
117
|
+
team,
|
|
118
|
+
ref: text.describe("Git branch, tag, or full commit SHA in the project's linked repository."),
|
|
119
|
+
commit_sha: z.string().regex(/^[a-f0-9]{40}$/i).describe("Full commit SHA to pin the source while retaining branch context in ref.").optional(),
|
|
120
|
+
target: z.enum(["preview", "production"]).describe("Deployment environment; defaults to preview.").optional()
|
|
121
|
+
}).strict(),
|
|
122
|
+
outputSchema: deploymentOutput,
|
|
123
|
+
async execute(input, _options, ctx) {
|
|
124
|
+
const project = z.object({
|
|
125
|
+
id: text,
|
|
126
|
+
name: text,
|
|
127
|
+
link: z.object({
|
|
128
|
+
type: text,
|
|
129
|
+
repoId: z.union([text, z.number()]).optional()
|
|
130
|
+
}).nullable().optional()
|
|
131
|
+
}).parse(await request(ctx.egress, "vercel.project.get", `/v9/projects/${encodeURIComponent(input.project)}`, input.team));
|
|
132
|
+
if (project.link?.type !== "github" || !project.link.repoId) throw new PluginToolInputError("This deployment tool requires a project linked to GitHub. Use the Vercel CLI for other source types.");
|
|
133
|
+
const gitSource = {
|
|
134
|
+
type: "github",
|
|
135
|
+
repoId: project.link.repoId,
|
|
136
|
+
ref: input.ref,
|
|
137
|
+
sha: input.commit_sha?.toLowerCase()
|
|
138
|
+
};
|
|
139
|
+
return deploymentResult(await request(ctx.egress, "vercel.deployment.create", "/v13/deployments", input.team, "POST", {
|
|
140
|
+
name: project.name,
|
|
141
|
+
project: project.id,
|
|
142
|
+
target: input.target === "production" ? "production" : void 0,
|
|
143
|
+
gitSource
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
}),
|
|
147
|
+
deploymentInspect: definePluginTool({
|
|
148
|
+
annotations: {
|
|
149
|
+
destructiveHint: false,
|
|
150
|
+
idempotentHint: true,
|
|
151
|
+
openWorldHint: true,
|
|
152
|
+
readOnlyHint: true
|
|
153
|
+
},
|
|
154
|
+
description: "Inspect a Vercel deployment by ID or hostname. Returns its ID, state, environment, and Git source when available. Use the CLI for logs.",
|
|
155
|
+
inputSchema: z.object({
|
|
156
|
+
deployment: text.describe("Deployment ID or hostname, without a scheme or path."),
|
|
157
|
+
team
|
|
158
|
+
}).strict(),
|
|
159
|
+
outputSchema: deploymentOutput,
|
|
160
|
+
async execute(input, _options, ctx) {
|
|
161
|
+
return deploymentResult(await request(ctx.egress, "vercel.deployment.get", `/v13/deployments/${encodeURIComponent(input.deployment)}?withGitRepoInfo=true`, input.team));
|
|
162
|
+
}
|
|
163
|
+
}),
|
|
164
|
+
aliasAssign: definePluginTool({
|
|
165
|
+
annotations: {
|
|
166
|
+
destructiveHint: true,
|
|
167
|
+
idempotentHint: true,
|
|
168
|
+
openWorldHint: true,
|
|
169
|
+
readOnlyHint: false
|
|
170
|
+
},
|
|
171
|
+
description: "Assign an alias hostname to a deployment ID. This can replace live traffic. Reads the alias back and returns matches=false if its target changed or it redirects.",
|
|
172
|
+
inputSchema: z.object({
|
|
173
|
+
deployment_id: deploymentIdSchema,
|
|
174
|
+
alias: aliasName,
|
|
175
|
+
team
|
|
176
|
+
}).strict(),
|
|
177
|
+
outputSchema: aliasOutput.extend({ matches: z.boolean() }),
|
|
178
|
+
async execute(input, _options, ctx) {
|
|
179
|
+
await request(ctx.egress, "vercel.alias.assign", `/v2/deployments/${encodeURIComponent(input.deployment_id)}/aliases`, input.team, "POST", { alias: input.alias });
|
|
180
|
+
const result = await inspectAlias(ctx.egress, input.alias, input.team);
|
|
181
|
+
return {
|
|
182
|
+
...result,
|
|
183
|
+
matches: result.deployment_id === input.deployment_id && !result.redirect
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}),
|
|
187
|
+
aliasInspect: definePluginTool({
|
|
188
|
+
annotations: {
|
|
189
|
+
destructiveHint: false,
|
|
190
|
+
idempotentHint: true,
|
|
191
|
+
openWorldHint: true,
|
|
192
|
+
readOnlyHint: true
|
|
193
|
+
},
|
|
194
|
+
description: "Read a Vercel alias's current deployment ID or redirect.",
|
|
195
|
+
inputSchema: z.object({
|
|
196
|
+
alias: aliasName,
|
|
197
|
+
team
|
|
198
|
+
}).strict(),
|
|
199
|
+
outputSchema: aliasOutput,
|
|
200
|
+
async execute(input, _options, ctx) {
|
|
201
|
+
return inspectAlias(ctx.egress, input.alias, input.team);
|
|
202
|
+
}
|
|
203
|
+
}),
|
|
204
|
+
deploymentDelete: definePluginTool({
|
|
205
|
+
annotations: {
|
|
206
|
+
destructiveHint: true,
|
|
207
|
+
idempotentHint: true,
|
|
208
|
+
openWorldHint: true,
|
|
209
|
+
readOnlyHint: false
|
|
210
|
+
},
|
|
211
|
+
description: "Delete a Vercel deployment by ID. This can remove a live deployment. Does not delete its database or other external state.",
|
|
212
|
+
inputSchema: z.object({
|
|
213
|
+
deployment_id: deploymentIdSchema,
|
|
214
|
+
team
|
|
215
|
+
}).strict(),
|
|
216
|
+
outputSchema: pluginToolOutputSchema.extend({
|
|
217
|
+
target: z.literal("deployment"),
|
|
218
|
+
deployment_id: text,
|
|
219
|
+
deleted: z.literal(true)
|
|
220
|
+
}),
|
|
221
|
+
async execute(input, _options, ctx) {
|
|
222
|
+
await request(ctx.egress, "vercel.deployment.delete", `/v13/deployments/${encodeURIComponent(input.deployment_id)}`, input.team, "DELETE");
|
|
223
|
+
return {
|
|
224
|
+
target: "deployment",
|
|
225
|
+
deployment_id: input.deployment_id,
|
|
226
|
+
deleted: true
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
};
|
|
292
231
|
// src/webhooks/secret.ts
|
|
232
|
+
/** Read the normalized secret shared by plugin enablement and webhook ingress. */
|
|
293
233
|
function vercelWebhookSecret() {
|
|
294
|
-
|
|
234
|
+
return process.env["VERCEL_WEBHOOK_SECRET"]?.trim() || void 0;
|
|
295
235
|
}
|
|
296
|
-
|
|
297
236
|
// src/index.ts
|
|
237
|
+
/**
|
|
238
|
+
* Vercel plugin runtime boundary.
|
|
239
|
+
*
|
|
240
|
+
* This package owns Vercel CLI setup, host-managed API authentication, signed
|
|
241
|
+
* webhook normalization, and deployment tools. Junior core owns the resulting
|
|
242
|
+
* conversation subscriptions and event delivery.
|
|
243
|
+
*/
|
|
244
|
+
/** Register Vercel runtime metadata, tools, and signed webhook ingress. */
|
|
298
245
|
function vercelPlugin() {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
},
|
|
345
|
-
hooks: {
|
|
346
|
-
routes(ctx) {
|
|
347
|
-
return [
|
|
348
|
-
createVercelWebhookRoute({
|
|
349
|
-
events: ctx.events,
|
|
350
|
-
webhookSecret: vercelWebhookSecret
|
|
351
|
-
})
|
|
352
|
-
];
|
|
353
|
-
},
|
|
354
|
-
tools(ctx) {
|
|
355
|
-
return {
|
|
356
|
-
deployment: createVercelDeploymentTool(ctx),
|
|
357
|
-
...createVercelActionTools(ctx)
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
});
|
|
246
|
+
return defineJuniorPlugin({
|
|
247
|
+
packageName: "@sentry/junior-vercel",
|
|
248
|
+
events: {
|
|
249
|
+
resourceTypes: [{
|
|
250
|
+
type: "deployment",
|
|
251
|
+
supportedEvents: [...VERCEL_DEPLOYMENT_EVENTS],
|
|
252
|
+
suggestedEvents: [...VERCEL_DEPLOYMENT_SUGGESTED_EVENTS],
|
|
253
|
+
matchFields: VERCEL_DEPLOYMENT_MATCH_FIELDS
|
|
254
|
+
}],
|
|
255
|
+
events: Object.fromEntries(VERCEL_DEPLOYMENT_EVENTS.map((eventType) => [eventType, { reach: "all" }])),
|
|
256
|
+
isEnabled: () => Boolean(vercelWebhookSecret())
|
|
257
|
+
},
|
|
258
|
+
manifest: {
|
|
259
|
+
apiHeaders: { Authorization: "Bearer ${JUNIOR_VERCEL_TOKEN}" },
|
|
260
|
+
commandEnv: { VERCEL_TOKEN: "host_managed_credential" },
|
|
261
|
+
configKeys: ["project", "team"],
|
|
262
|
+
description: "Deploy and inspect Vercel projects, manage aliases, query logs, and monitor outcomes",
|
|
263
|
+
displayName: "Vercel",
|
|
264
|
+
domains: ["api.vercel.com"],
|
|
265
|
+
envVars: {
|
|
266
|
+
JUNIOR_VERCEL_TOKEN: {},
|
|
267
|
+
VERCEL_WEBHOOK_SECRET: {}
|
|
268
|
+
},
|
|
269
|
+
name: "vercel",
|
|
270
|
+
runtimeDependencies: [{
|
|
271
|
+
package: "vercel",
|
|
272
|
+
type: "npm",
|
|
273
|
+
version: "latest"
|
|
274
|
+
}]
|
|
275
|
+
},
|
|
276
|
+
hooks: {
|
|
277
|
+
routes(ctx) {
|
|
278
|
+
return [createVercelWebhookRoute({
|
|
279
|
+
events: ctx.events,
|
|
280
|
+
webhookSecret: vercelWebhookSecret
|
|
281
|
+
})];
|
|
282
|
+
},
|
|
283
|
+
tools() {
|
|
284
|
+
return {
|
|
285
|
+
deployment: vercelDeploymentTool,
|
|
286
|
+
...vercelActionTools
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
});
|
|
362
291
|
}
|
|
363
|
-
export {
|
|
364
|
-
vercelPlugin
|
|
365
|
-
};
|
|
292
|
+
export { vercelPlugin };
|