@sentry/junior-vercel 0.300.0 → 0.302.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.
@@ -133,53 +133,51 @@ function projectLookupUrl(project, team) {
133
133
  }
134
134
  return url.toString();
135
135
  }
136
- function createVercelDeploymentTool(ctx) {
137
- return definePluginTool({
138
- annotations: {
139
- destructiveHint: false,
140
- idempotentHint: true,
141
- openWorldHint: true,
142
- readOnlyHint: true
143
- },
144
- description: "Resolve a Vercel project name or ID and describe a subscribable deployment resource for one deployment or every deployment of the project. Use the user's explicit project and team, otherwise the vercel.project and vercel.team conversation defaults.",
145
- inputSchema,
146
- outputSchema,
147
- async execute(input) {
148
- const response = await ctx.egress.fetch({
149
- operation: "vercel.project.get",
150
- provider: "vercel",
151
- request: new Request(projectLookupUrl(input.project, input.team))
152
- });
153
- const parsed = await readJson(response);
154
- if (!response.ok) {
155
- const message = `Vercel project lookup failed with HTTP ${response.status}`;
156
- if (response.status === 404) {
157
- throw new PluginToolInputError(message);
158
- }
159
- throw new Error(message);
136
+ var vercelDeploymentTool = definePluginTool({
137
+ annotations: {
138
+ destructiveHint: false,
139
+ idempotentHint: true,
140
+ openWorldHint: true,
141
+ readOnlyHint: true
142
+ },
143
+ description: "Resolve a Vercel project name or ID and describe a subscribable deployment resource for one deployment or every deployment of the project. Use the user's explicit project and team, otherwise the vercel.project and vercel.team conversation defaults.",
144
+ inputSchema,
145
+ outputSchema,
146
+ async execute(input, _options, ctx) {
147
+ const response = await ctx.egress.fetch({
148
+ operation: "vercel.project.get",
149
+ provider: "vercel",
150
+ request: new Request(projectLookupUrl(input.project, input.team))
151
+ });
152
+ const parsed = await readJson(response);
153
+ if (!response.ok) {
154
+ const message = `Vercel project lookup failed with HTTP ${response.status}`;
155
+ if (response.status === 404) {
156
+ throw new PluginToolInputError(message);
160
157
  }
161
- const projectId = z2.object({ id: vercelProjectIdSchema }).parse(parsed).id;
162
- const commitSha = input.commit_sha?.toLowerCase();
163
- const deploymentTarget = input.target ?? (commitSha ? "production" : void 0);
164
- const subscribable = vercelDeploymentSubscribable({
165
- canSubscribe: ctx.events.canSubscribe,
166
- commitSha,
167
- projectId,
168
- target: deploymentTarget
169
- });
170
- const data = {
171
- commit_sha: commitSha ?? null,
172
- deployment_target: deploymentTarget ?? null,
173
- project_id: projectId,
174
- ...subscribable ? { subscribable } : void 0
175
- };
176
- return {
177
- target: "deployment",
178
- ...data
179
- };
158
+ throw new Error(message);
180
159
  }
181
- });
182
- }
160
+ const projectId = z2.object({ id: vercelProjectIdSchema }).parse(parsed).id;
161
+ const commitSha = input.commit_sha?.toLowerCase();
162
+ const deploymentTarget = input.target ?? (commitSha ? "production" : void 0);
163
+ const subscribable = vercelDeploymentSubscribable({
164
+ canSubscribe: ctx.events.canSubscribe,
165
+ commitSha,
166
+ projectId,
167
+ target: deploymentTarget
168
+ });
169
+ const data = {
170
+ commit_sha: commitSha ?? null,
171
+ deployment_target: deploymentTarget ?? null,
172
+ project_id: projectId,
173
+ ...subscribable ? { subscribable } : void 0
174
+ };
175
+ return {
176
+ target: "deployment",
177
+ ...data
178
+ };
179
+ }
180
+ });
183
181
 
184
182
  // src/webhooks/events.ts
185
183
  import * as z3 from "zod";
@@ -328,7 +326,7 @@ export {
328
326
  VERCEL_DEPLOYMENT_EVENTS,
329
327
  VERCEL_DEPLOYMENT_SUGGESTED_EVENTS,
330
328
  VERCEL_DEPLOYMENT_MATCH_FIELDS,
331
- createVercelDeploymentTool,
329
+ vercelDeploymentTool,
332
330
  normalizeVercelEvents,
333
331
  createVercelWebhookRoute
334
332
  };
package/dist/index.js CHANGED
@@ -2,9 +2,9 @@ import {
2
2
  VERCEL_DEPLOYMENT_EVENTS,
3
3
  VERCEL_DEPLOYMENT_MATCH_FIELDS,
4
4
  VERCEL_DEPLOYMENT_SUGGESTED_EVENTS,
5
- createVercelDeploymentTool,
6
- createVercelWebhookRoute
7
- } from "./chunk-QCT7VK3J.js";
5
+ createVercelWebhookRoute,
6
+ vercelDeploymentTool
7
+ } from "./chunk-JY7QEZ73.js";
8
8
 
9
9
  // src/index.ts
10
10
  import {
@@ -85,209 +85,210 @@ function deploymentResult(data) {
85
85
  ]
86
86
  };
87
87
  }
88
- function createVercelActionTools(ctx) {
89
- async function request(operation, path, scope, method = "GET", body) {
90
- const url = new URL(path, "https://api.vercel.com");
91
- if (scope)
92
- url.searchParams.set(
93
- scope.startsWith("team_") ? "teamId" : "slug",
94
- scope
95
- );
96
- const init = {
97
- method,
98
- redirect: "error",
99
- signal: AbortSignal.timeout(3e4)
100
- };
101
- if (body !== void 0) {
102
- init.headers = { "Content-Type": "application/json" };
103
- init.body = JSON.stringify(body);
104
- }
105
- const response = await ctx.egress.fetch({
106
- provider: "vercel",
107
- operation,
108
- request: new Request(url, init)
109
- });
110
- if (!response.ok) {
111
- const message = `${operation} failed with HTTP ${response.status}`;
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();
88
+ async function request(egress, operation, path, scope, method = "GET", body) {
89
+ const url = new URL(path, "https://api.vercel.com");
90
+ if (scope)
91
+ url.searchParams.set(scope.startsWith("team_") ? "teamId" : "slug", scope);
92
+ const init = {
93
+ method,
94
+ redirect: "error",
95
+ signal: AbortSignal.timeout(3e4)
96
+ };
97
+ if (body !== void 0) {
98
+ init.headers = { "Content-Type": "application/json" };
99
+ init.body = JSON.stringify(body);
118
100
  }
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
- };
101
+ const response = await egress.fetch({
102
+ provider: "vercel",
103
+ operation,
104
+ request: new Request(url, init)
105
+ });
106
+ if (!response.ok) {
107
+ const message = `${operation} failed with HTTP ${response.status}`;
108
+ if (response.status === 400 || response.status === 404)
109
+ throw new PluginToolInputError(message);
110
+ throw new Error(message);
133
111
  }
112
+ if (response.status === 204) return void 0;
113
+ return response.json();
114
+ }
115
+ async function inspectAlias(egress, alias, scope) {
116
+ const result = aliasSchema.parse(
117
+ await request(
118
+ egress,
119
+ "vercel.alias.get",
120
+ `/v4/aliases/${encodeURIComponent(alias)}`,
121
+ scope
122
+ )
123
+ );
134
124
  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
- )
125
+ target: "alias",
126
+ alias: result.alias,
127
+ deployment_id: result.deploymentId,
128
+ redirect: result.redirect ?? null
129
+ };
130
+ }
131
+ var vercelActionTools = {
132
+ deploymentCreate: definePluginTool({
133
+ annotations: {
134
+ destructiveHint: true,
135
+ idempotentHint: false,
136
+ openWorldHint: true,
137
+ readOnlyHint: false
138
+ },
139
+ 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.",
140
+ inputSchema: z.object({
141
+ project: text.describe("Existing Vercel project name or ID."),
142
+ team,
143
+ ref: text.describe(
144
+ "Git branch, tag, or full commit SHA in the project's linked repository."
145
+ ),
146
+ commit_sha: z.string().regex(/^[a-f0-9]{40}$/i).describe(
147
+ "Full commit SHA to pin the source while retaining branch context in ref."
148
+ ).optional(),
149
+ target: z.enum(["preview", "production"]).describe("Deployment environment; defaults to preview.").optional()
150
+ }).strict(),
151
+ outputSchema: deploymentOutput,
152
+ async execute(input, _options, ctx) {
153
+ const project = z.object({
154
+ id: text,
155
+ name: text,
156
+ link: z.object({
157
+ type: text,
158
+ repoId: z.union([text, z.number()]).optional()
159
+ }).nullable().optional()
160
+ }).parse(
161
+ await request(
162
+ ctx.egress,
163
+ "vercel.project.get",
164
+ `/v9/projects/${encodeURIComponent(input.project)}`,
165
+ input.team
166
+ )
167
+ );
168
+ if (project.link?.type !== "github" || !project.link.repoId)
169
+ throw new PluginToolInputError(
170
+ "This deployment tool requires a project linked to GitHub. Use the Vercel CLI for other source types."
219
171
  );
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) {
172
+ const gitSource = {
173
+ type: "github",
174
+ repoId: project.link.repoId,
175
+ ref: input.ref,
176
+ sha: input.commit_sha?.toLowerCase()
177
+ };
178
+ return deploymentResult(
233
179
  await request(
234
- "vercel.alias.assign",
235
- `/v2/deployments/${encodeURIComponent(input.deployment_id)}/aliases`,
180
+ ctx.egress,
181
+ "vercel.deployment.create",
182
+ "/v13/deployments",
236
183
  input.team,
237
184
  "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) {
185
+ {
186
+ name: project.name,
187
+ project: project.id,
188
+ // Vercel uses an omitted target for Preview, not "preview".
189
+ target: input.target === "production" ? "production" : void 0,
190
+ gitSource
191
+ }
192
+ )
193
+ );
194
+ }
195
+ }),
196
+ deploymentInspect: definePluginTool({
197
+ annotations: {
198
+ destructiveHint: false,
199
+ idempotentHint: true,
200
+ openWorldHint: true,
201
+ readOnlyHint: true
202
+ },
203
+ description: "Inspect a Vercel deployment by ID or hostname. Returns its ID, state, environment, and Git source when available. Use the CLI for logs.",
204
+ inputSchema: z.object({
205
+ deployment: text.describe(
206
+ "Deployment ID or hostname, without a scheme or path."
207
+ ),
208
+ team
209
+ }).strict(),
210
+ outputSchema: deploymentOutput,
211
+ async execute(input, _options, ctx) {
212
+ return deploymentResult(
276
213
  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
- };
290
- }
214
+ ctx.egress,
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, _options, ctx) {
233
+ await request(
234
+ ctx.egress,
235
+ "vercel.alias.assign",
236
+ `/v2/deployments/${encodeURIComponent(input.deployment_id)}/aliases`,
237
+ input.team,
238
+ "POST",
239
+ { alias: input.alias }
240
+ );
241
+ const result = await inspectAlias(ctx.egress, input.alias, input.team);
242
+ return {
243
+ ...result,
244
+ matches: result.deployment_id === input.deployment_id && !result.redirect
245
+ };
246
+ }
247
+ }),
248
+ aliasInspect: definePluginTool({
249
+ annotations: {
250
+ destructiveHint: false,
251
+ idempotentHint: true,
252
+ openWorldHint: true,
253
+ readOnlyHint: true
254
+ },
255
+ description: "Read a Vercel alias's current deployment ID or redirect.",
256
+ inputSchema: z.object({ alias: aliasName, team }).strict(),
257
+ outputSchema: aliasOutput,
258
+ async execute(input, _options, ctx) {
259
+ return inspectAlias(ctx.egress, input.alias, input.team);
260
+ }
261
+ }),
262
+ deploymentDelete: definePluginTool({
263
+ annotations: {
264
+ destructiveHint: true,
265
+ idempotentHint: true,
266
+ openWorldHint: true,
267
+ readOnlyHint: false
268
+ },
269
+ description: "Delete a Vercel deployment by ID. This can remove a live deployment. Does not delete its database or other external state.",
270
+ inputSchema: z.object({ deployment_id: deploymentIdSchema, team }).strict(),
271
+ outputSchema: pluginToolOutputSchema.extend({
272
+ target: z.literal("deployment"),
273
+ deployment_id: text,
274
+ deleted: z.literal(true)
275
+ }),
276
+ async execute(input, _options, ctx) {
277
+ await request(
278
+ ctx.egress,
279
+ "vercel.deployment.delete",
280
+ `/v13/deployments/${encodeURIComponent(input.deployment_id)}`,
281
+ input.team,
282
+ "DELETE"
283
+ );
284
+ return {
285
+ target: "deployment",
286
+ deployment_id: input.deployment_id,
287
+ deleted: true
288
+ };
289
+ }
290
+ })
291
+ };
291
292
 
292
293
  // src/webhooks/secret.ts
293
294
  function vercelWebhookSecret() {
@@ -351,11 +352,8 @@ function vercelPlugin() {
351
352
  })
352
353
  ];
353
354
  },
354
- tools(ctx) {
355
- return {
356
- deployment: createVercelDeploymentTool(ctx),
357
- ...createVercelActionTools(ctx)
358
- };
355
+ tools() {
356
+ return { deployment: vercelDeploymentTool, ...vercelActionTools };
359
357
  }
360
358
  }
361
359
  });
package/dist/testing.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { createVercelDeploymentTool } from "./tools/deployment.js";
1
+ export { vercelDeploymentTool } from "./tools/deployment.js";
2
2
  export { createVercelWebhookRoute } from "./webhooks/handler.js";
3
3
  export { normalizeVercelEvents } from "./webhooks/events.js";
package/dist/testing.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
- createVercelDeploymentTool,
3
2
  createVercelWebhookRoute,
4
- normalizeVercelEvents
5
- } from "./chunk-QCT7VK3J.js";
3
+ normalizeVercelEvents,
4
+ vercelDeploymentTool
5
+ } from "./chunk-JY7QEZ73.js";
6
6
  export {
7
- createVercelDeploymentTool,
8
7
  createVercelWebhookRoute,
9
- normalizeVercelEvents
8
+ normalizeVercelEvents,
9
+ vercelDeploymentTool
10
10
  };