@sentry/junior-vercel 0.311.0 → 0.313.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 (2) hide show
  1. package/dist/index.js +177 -152
  2. 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/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();
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
- 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.");
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: text,
11
- url: text,
12
- readyState: text,
19
+ id: nonEmptyText,
20
+ url: nonEmptyText,
21
+ readyState: nonEmptyText,
13
22
  target: z.string().nullable().optional(),
14
- projectId: text.optional(),
23
+ projectId: nonEmptyText.optional(),
15
24
  gitSource: z.object({
16
- sha: text.optional(),
17
- ref: text.optional()
25
+ sha: nonEmptyText.optional(),
26
+ ref: nonEmptyText.optional()
18
27
  }).nullable().optional()
19
28
  });
20
- const deploymentOutput = pluginToolOutputSchema.extend({
29
+ /** Output of the tools that return one deployment. */
30
+ const deploymentOutputSchema = pluginToolOutputSchema.extend({
21
31
  target: z.literal("deployment"),
22
- deployment_id: text,
23
- url: text,
24
- state: text,
32
+ deployment_id: nonEmptyText,
33
+ url: nonEmptyText,
34
+ state: nonEmptyText,
25
35
  deployment_target: z.string().nullable(),
26
- project_id: text.nullable(),
27
- commit_sha: text.nullable(),
28
- ref: text.nullable()
36
+ project_id: nonEmptyText.nullable(),
37
+ commit_sha: nonEmptyText.nullable(),
38
+ ref: nonEmptyText.nullable()
29
39
  });
30
40
  const aliasSchema = z.object({
31
- alias: text,
32
- deploymentId: text.nullable(),
33
- redirect: text.nullable().optional()
41
+ alias: nonEmptyText,
42
+ deploymentId: nonEmptyText.nullable(),
43
+ redirect: nonEmptyText.nullable().optional()
34
44
  });
35
- const aliasOutput = pluginToolOutputSchema.extend({
45
+ /** Output of the tools that return one alias. */
46
+ const aliasOutputSchema = pluginToolOutputSchema.extend({
36
47
  target: z.literal("alias"),
37
- alias: text,
38
- deployment_id: text.nullable(),
39
- redirect: text.nullable()
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
- async function request(egress, operation, path, scope, method = "GET", body) {
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 request(egress, "vercel.alias.get", `/v4/aliases/${encodeURIComponent(alias)}`, scope));
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
- /** 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
- }
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
- 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
- };
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
- ...vercelActionTools
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.311.0",
3
+ "version": "0.313.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.311.0",
29
+ "@sentry/junior-plugin-api": "0.313.0",
30
30
  "zod": "^4.6.7"
31
31
  },
32
32
  "devDependencies": {