@sentry/junior-vercel 0.310.0 → 0.312.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/index.js +177 -152
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,43 +1,55 @@
|
|
|
1
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
2
|
import { PluginToolInputError, defineJuniorPlugin, definePluginTool, pluginToolOutputSchema } from "@sentry/junior-plugin-api";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
-
// src/
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
// src/tool-support/vercel-api.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vercel API calls and shared shapes of the deployment and alias tools. The
|
|
7
|
+
* tools return selected fields because Vercel responses can contain
|
|
8
|
+
* environment credentials.
|
|
9
|
+
*/
|
|
10
|
+
/** Text with at least one character after trimming. */
|
|
11
|
+
const nonEmptyText = z.string().trim().min(1);
|
|
12
|
+
/** Optional Vercel team scope of a request. */
|
|
13
|
+
const teamSchema = nonEmptyText.describe("Vercel team slug or team_ ID. Omit for the token's default account.").optional();
|
|
14
|
+
/** Exact Vercel deployment ID. */
|
|
7
15
|
const deploymentIdSchema = z.string().regex(/^dpl_[a-zA-Z0-9]+$/).describe("Exact Vercel deployment ID, not an alias.");
|
|
8
|
-
|
|
16
|
+
/** Alias hostname of a deployment. */
|
|
17
|
+
const aliasNameSchema = z.string().regex(/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?\.[a-z]{2,}$/).describe("Alias hostname without a scheme or path.");
|
|
9
18
|
const deploymentSchema = z.object({
|
|
10
|
-
id:
|
|
11
|
-
url:
|
|
12
|
-
readyState:
|
|
19
|
+
id: nonEmptyText,
|
|
20
|
+
url: nonEmptyText,
|
|
21
|
+
readyState: nonEmptyText,
|
|
13
22
|
target: z.string().nullable().optional(),
|
|
14
|
-
projectId:
|
|
23
|
+
projectId: nonEmptyText.optional(),
|
|
15
24
|
gitSource: z.object({
|
|
16
|
-
sha:
|
|
17
|
-
ref:
|
|
25
|
+
sha: nonEmptyText.optional(),
|
|
26
|
+
ref: nonEmptyText.optional()
|
|
18
27
|
}).nullable().optional()
|
|
19
28
|
});
|
|
20
|
-
|
|
29
|
+
/** Output of the tools that return one deployment. */
|
|
30
|
+
const deploymentOutputSchema = pluginToolOutputSchema.extend({
|
|
21
31
|
target: z.literal("deployment"),
|
|
22
|
-
deployment_id:
|
|
23
|
-
url:
|
|
24
|
-
state:
|
|
32
|
+
deployment_id: nonEmptyText,
|
|
33
|
+
url: nonEmptyText,
|
|
34
|
+
state: nonEmptyText,
|
|
25
35
|
deployment_target: z.string().nullable(),
|
|
26
|
-
project_id:
|
|
27
|
-
commit_sha:
|
|
28
|
-
ref:
|
|
36
|
+
project_id: nonEmptyText.nullable(),
|
|
37
|
+
commit_sha: nonEmptyText.nullable(),
|
|
38
|
+
ref: nonEmptyText.nullable()
|
|
29
39
|
});
|
|
30
40
|
const aliasSchema = z.object({
|
|
31
|
-
alias:
|
|
32
|
-
deploymentId:
|
|
33
|
-
redirect:
|
|
41
|
+
alias: nonEmptyText,
|
|
42
|
+
deploymentId: nonEmptyText.nullable(),
|
|
43
|
+
redirect: nonEmptyText.nullable().optional()
|
|
34
44
|
});
|
|
35
|
-
|
|
45
|
+
/** Output of the tools that return one alias. */
|
|
46
|
+
const aliasOutputSchema = pluginToolOutputSchema.extend({
|
|
36
47
|
target: z.literal("alias"),
|
|
37
|
-
alias:
|
|
38
|
-
deployment_id:
|
|
39
|
-
redirect:
|
|
48
|
+
alias: nonEmptyText,
|
|
49
|
+
deployment_id: nonEmptyText.nullable(),
|
|
50
|
+
redirect: nonEmptyText.nullable()
|
|
40
51
|
});
|
|
52
|
+
/** Select the safe fields of a Vercel deployment for a tool result. */
|
|
41
53
|
function deploymentResult(data) {
|
|
42
54
|
const value = deploymentSchema.parse(data);
|
|
43
55
|
return {
|
|
@@ -68,7 +80,8 @@ function deploymentResult(data) {
|
|
|
68
80
|
}]
|
|
69
81
|
};
|
|
70
82
|
}
|
|
71
|
-
|
|
83
|
+
/** Call the Vercel API through plugin egress and return the JSON body. */
|
|
84
|
+
async function vercelRequest(egress, operation, path, scope, method = "GET", body) {
|
|
72
85
|
const url = new URL(path, "https://api.vercel.com");
|
|
73
86
|
if (scope) url.searchParams.set(scope.startsWith("team_") ? "teamId" : "slug", scope);
|
|
74
87
|
const init = {
|
|
@@ -93,8 +106,9 @@ async function request(egress, operation, path, scope, method = "GET", body) {
|
|
|
93
106
|
if (response.status === 204) return void 0;
|
|
94
107
|
return response.json();
|
|
95
108
|
}
|
|
109
|
+
/** Read one Vercel alias and select its safe fields. */
|
|
96
110
|
async function inspectAlias(egress, alias, scope) {
|
|
97
|
-
const result = aliasSchema.parse(await
|
|
111
|
+
const result = aliasSchema.parse(await vercelRequest(egress, "vercel.alias.get", `/v4/aliases/${encodeURIComponent(alias)}`, scope));
|
|
98
112
|
return {
|
|
99
113
|
target: "alias",
|
|
100
114
|
alias: result.alias,
|
|
@@ -102,132 +116,139 @@ async function inspectAlias(egress, alias, scope) {
|
|
|
102
116
|
redirect: result.redirect ?? null
|
|
103
117
|
};
|
|
104
118
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
119
|
+
// src/tools/alias-assign.ts
|
|
120
|
+
/** Assign a Vercel alias to a deployment and read it back. */
|
|
121
|
+
const vercelAliasAssignTool = definePluginTool({
|
|
122
|
+
annotations: {
|
|
123
|
+
destructiveHint: true,
|
|
124
|
+
idempotentHint: true,
|
|
125
|
+
openWorldHint: true,
|
|
126
|
+
readOnlyHint: false
|
|
127
|
+
},
|
|
128
|
+
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.",
|
|
129
|
+
inputSchema: z.object({
|
|
130
|
+
deployment_id: deploymentIdSchema,
|
|
131
|
+
alias: aliasNameSchema,
|
|
132
|
+
team: teamSchema
|
|
133
|
+
}).strict(),
|
|
134
|
+
outputSchema: aliasOutputSchema.extend({ matches: z.boolean() }),
|
|
135
|
+
async execute(input, _options, ctx) {
|
|
136
|
+
await vercelRequest(ctx.egress, "vercel.alias.assign", `/v2/deployments/${encodeURIComponent(input.deployment_id)}/aliases`, input.team, "POST", { alias: input.alias });
|
|
137
|
+
const result = await inspectAlias(ctx.egress, input.alias, input.team);
|
|
138
|
+
return {
|
|
139
|
+
...result,
|
|
140
|
+
matches: result.deployment_id === input.deployment_id && !result.redirect
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
// src/tools/alias-inspect.ts
|
|
145
|
+
/** Read a Vercel alias. */
|
|
146
|
+
const vercelAliasInspectTool = definePluginTool({
|
|
147
|
+
annotations: {
|
|
148
|
+
destructiveHint: false,
|
|
149
|
+
idempotentHint: true,
|
|
150
|
+
openWorldHint: true,
|
|
151
|
+
readOnlyHint: true
|
|
152
|
+
},
|
|
153
|
+
description: "Read a Vercel alias's current deployment ID or redirect.",
|
|
154
|
+
inputSchema: z.object({
|
|
155
|
+
alias: aliasNameSchema,
|
|
156
|
+
team: teamSchema
|
|
157
|
+
}).strict(),
|
|
158
|
+
outputSchema: aliasOutputSchema,
|
|
159
|
+
async execute(input, _options, ctx) {
|
|
160
|
+
return inspectAlias(ctx.egress, input.alias, input.team);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
// src/tools/deployment-create.ts
|
|
164
|
+
/** Start a Vercel deployment from a linked GitHub repository. */
|
|
165
|
+
const vercelDeploymentCreateTool = definePluginTool({
|
|
166
|
+
annotations: {
|
|
167
|
+
destructiveHint: true,
|
|
168
|
+
idempotentHint: false,
|
|
169
|
+
openWorldHint: true,
|
|
170
|
+
readOnlyHint: false
|
|
171
|
+
},
|
|
172
|
+
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.",
|
|
173
|
+
inputSchema: z.object({
|
|
174
|
+
project: nonEmptyText.describe("Existing Vercel project name or ID."),
|
|
175
|
+
team: teamSchema,
|
|
176
|
+
ref: nonEmptyText.describe("Git branch, tag, or full commit SHA in the project's linked repository."),
|
|
177
|
+
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(),
|
|
178
|
+
target: z.enum(["preview", "production"]).describe("Deployment environment; defaults to preview.").optional()
|
|
179
|
+
}).strict(),
|
|
180
|
+
outputSchema: deploymentOutputSchema,
|
|
181
|
+
async execute(input, _options, ctx) {
|
|
182
|
+
const project = z.object({
|
|
183
|
+
id: nonEmptyText,
|
|
184
|
+
name: nonEmptyText,
|
|
185
|
+
link: z.object({
|
|
186
|
+
type: nonEmptyText,
|
|
187
|
+
repoId: z.union([nonEmptyText, z.number()]).optional()
|
|
188
|
+
}).nullable().optional()
|
|
189
|
+
}).parse(await vercelRequest(ctx.egress, "vercel.project.get", `/v9/projects/${encodeURIComponent(input.project)}`, input.team));
|
|
190
|
+
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.");
|
|
191
|
+
const gitSource = {
|
|
192
|
+
type: "github",
|
|
193
|
+
repoId: project.link.repoId,
|
|
194
|
+
ref: input.ref,
|
|
195
|
+
sha: input.commit_sha?.toLowerCase()
|
|
196
|
+
};
|
|
197
|
+
return deploymentResult(await vercelRequest(ctx.egress, "vercel.deployment.create", "/v13/deployments", input.team, "POST", {
|
|
198
|
+
name: project.name,
|
|
199
|
+
project: project.id,
|
|
200
|
+
target: input.target === "production" ? "production" : void 0,
|
|
201
|
+
gitSource
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
// src/tools/deployment-delete.ts
|
|
206
|
+
/** Delete a Vercel deployment. */
|
|
207
|
+
const vercelDeploymentDeleteTool = definePluginTool({
|
|
208
|
+
annotations: {
|
|
209
|
+
destructiveHint: true,
|
|
210
|
+
idempotentHint: true,
|
|
211
|
+
openWorldHint: true,
|
|
212
|
+
readOnlyHint: false
|
|
213
|
+
},
|
|
214
|
+
description: "Delete a Vercel deployment by ID. This can remove a live deployment. Does not delete its database or other external state.",
|
|
215
|
+
inputSchema: z.object({
|
|
216
|
+
deployment_id: deploymentIdSchema,
|
|
217
|
+
team: teamSchema
|
|
218
|
+
}).strict(),
|
|
219
|
+
outputSchema: pluginToolOutputSchema.extend({
|
|
220
|
+
target: z.literal("deployment"),
|
|
221
|
+
deployment_id: nonEmptyText,
|
|
222
|
+
deleted: z.literal(true)
|
|
203
223
|
}),
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
224
|
+
async execute(input, _options, ctx) {
|
|
225
|
+
await vercelRequest(ctx.egress, "vercel.deployment.delete", `/v13/deployments/${encodeURIComponent(input.deployment_id)}`, input.team, "DELETE");
|
|
226
|
+
return {
|
|
227
|
+
target: "deployment",
|
|
228
|
+
deployment_id: input.deployment_id,
|
|
229
|
+
deleted: true
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
// src/tools/deployment-inspect.ts
|
|
234
|
+
/** Inspect a Vercel deployment. */
|
|
235
|
+
const vercelDeploymentInspectTool = definePluginTool({
|
|
236
|
+
annotations: {
|
|
237
|
+
destructiveHint: false,
|
|
238
|
+
idempotentHint: true,
|
|
239
|
+
openWorldHint: true,
|
|
240
|
+
readOnlyHint: true
|
|
241
|
+
},
|
|
242
|
+
description: "Inspect a Vercel deployment by ID or hostname. Returns its ID, state, environment, and Git source when available. Use the CLI for logs.",
|
|
243
|
+
inputSchema: z.object({
|
|
244
|
+
deployment: nonEmptyText.describe("Deployment ID or hostname, without a scheme or path."),
|
|
245
|
+
team: teamSchema
|
|
246
|
+
}).strict(),
|
|
247
|
+
outputSchema: deploymentOutputSchema,
|
|
248
|
+
async execute(input, _options, ctx) {
|
|
249
|
+
return deploymentResult(await vercelRequest(ctx.egress, "vercel.deployment.get", `/v13/deployments/${encodeURIComponent(input.deployment)}?withGitRepoInfo=true`, input.team));
|
|
250
|
+
}
|
|
251
|
+
});
|
|
231
252
|
// src/webhooks/secret.ts
|
|
232
253
|
/** Read the normalized secret shared by plugin enablement and webhook ingress. */
|
|
233
254
|
function vercelWebhookSecret() {
|
|
@@ -283,7 +304,11 @@ function vercelPlugin() {
|
|
|
283
304
|
tools() {
|
|
284
305
|
return {
|
|
285
306
|
deployment: vercelDeploymentTool,
|
|
286
|
-
|
|
307
|
+
deploymentCreate: vercelDeploymentCreateTool,
|
|
308
|
+
deploymentInspect: vercelDeploymentInspectTool,
|
|
309
|
+
aliasAssign: vercelAliasAssignTool,
|
|
310
|
+
aliasInspect: vercelAliasInspectTool,
|
|
311
|
+
deploymentDelete: vercelDeploymentDeleteTool
|
|
287
312
|
};
|
|
288
313
|
}
|
|
289
314
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-vercel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.312.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"skills"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sentry/junior-plugin-api": "0.
|
|
29
|
+
"@sentry/junior-plugin-api": "0.312.0",
|
|
30
30
|
"zod": "^4.6.7"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|