@sentry/junior-github 0.120.0 → 0.121.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/SETUP.md +7 -4
- package/dist/{chunk-EPYBKNXS.js → chunk-NNSOXVGR.js} +36 -31
- package/dist/index.js +14 -7
- package/dist/resource-events/deployment.d.ts +2 -2
- package/dist/testing.js +1 -1
- package/dist/tools/get-deployment.d.ts +3 -3
- package/dist/tools/get-pull-request.d.ts +2 -0
- package/package.json +2 -2
package/SETUP.md
CHANGED
|
@@ -83,10 +83,13 @@ status, Issue comment, Pull request review, and Pull request review comment
|
|
|
83
83
|
events.
|
|
84
84
|
|
|
85
85
|
`github_getDeployment` reads the latest deployment and status for an exact
|
|
86
|
-
repository
|
|
87
|
-
result can subscribe the current conversation to
|
|
88
|
-
success, failure, and error events.
|
|
89
|
-
|
|
86
|
+
repository and commit SHA, optionally limited to one environment. When
|
|
87
|
+
webhooks are configured, its result can subscribe the current conversation to
|
|
88
|
+
deployment creation, progress, success, failure, and error events. Omitting the
|
|
89
|
+
environment watches deployments for that commit across environments. The
|
|
90
|
+
subscription remains available when GitHub has not created the deployment yet.
|
|
91
|
+
Commit-wide watches remain active across terminal outcomes so later
|
|
92
|
+
environments for the same commit can also notify the conversation.
|
|
90
93
|
|
|
91
94
|
```bash
|
|
92
95
|
vercel env add GITHUB_WEBHOOK_SECRET production
|
|
@@ -18,12 +18,12 @@ var SUGGESTED_EVENTS = [
|
|
|
18
18
|
];
|
|
19
19
|
function gitHubDeploymentSourceResource(input) {
|
|
20
20
|
const commitSha = input.commitSha.toLowerCase();
|
|
21
|
-
const environment = input.environment
|
|
21
|
+
const environment = input.environment?.trim();
|
|
22
22
|
const repo = input.repo.toLowerCase();
|
|
23
23
|
return {
|
|
24
24
|
label: `GitHub deployment for ${repo} at ${commitSha.slice(0, 12)}`,
|
|
25
25
|
provider: "github",
|
|
26
|
-
resourceRef: `github:deployment-source:${repo}:${encodeURIComponent(environment.toLowerCase())}:${commitSha}`
|
|
26
|
+
resourceRef: environment ? `github:deployment-source:${repo}:${encodeURIComponent(environment.toLowerCase())}:${commitSha}` : `github:deployment-source:${repo}:${commitSha}`
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
function gitHubDeploymentSourceSubscribable(input) {
|
|
@@ -112,21 +112,16 @@ function parseDeploymentEvent(body) {
|
|
|
112
112
|
}
|
|
113
113
|
function normalizeDeploymentEvent(deliveryId, body) {
|
|
114
114
|
const parsed = parseDeploymentEvent(body);
|
|
115
|
-
if (!parsed || parsed.action !== "created") return
|
|
116
|
-
const resource = gitHubDeploymentSourceResource({
|
|
117
|
-
commitSha: parsed.commitSha,
|
|
118
|
-
environment: parsed.environment,
|
|
119
|
-
repo: parsed.repo
|
|
120
|
-
});
|
|
115
|
+
if (!parsed || parsed.action !== "created") return [];
|
|
121
116
|
const eventType = "deployment.created";
|
|
122
|
-
return {
|
|
117
|
+
return deploymentSourceTargets(parsed).map(({ resource }) => ({
|
|
123
118
|
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
124
119
|
eventType,
|
|
125
120
|
occurredAtMs: providerTime(parsed.createdAt) ?? Date.now(),
|
|
126
121
|
provider: "github",
|
|
127
122
|
resourceRef: resource.resourceRef,
|
|
128
123
|
trustedSummary: `${resource.label} was created (deployment ${parsed.deploymentId}).`
|
|
129
|
-
};
|
|
124
|
+
}));
|
|
130
125
|
}
|
|
131
126
|
var deploymentStatusWebhookSchema = z.object({
|
|
132
127
|
action: z.string(),
|
|
@@ -176,26 +171,38 @@ function deploymentStatusEventType(state) {
|
|
|
176
171
|
}
|
|
177
172
|
function normalizeDeploymentStatusEvent(deliveryId, body) {
|
|
178
173
|
const parsed = parseDeploymentStatusEvent(body);
|
|
179
|
-
if (!parsed || parsed.action !== "created") return
|
|
174
|
+
if (!parsed || parsed.action !== "created") return [];
|
|
180
175
|
const eventType = deploymentStatusEventType(parsed.state);
|
|
181
|
-
if (!eventType) return
|
|
182
|
-
const resource = gitHubDeploymentSourceResource({
|
|
183
|
-
commitSha: parsed.commitSha,
|
|
184
|
-
environment: parsed.environment,
|
|
185
|
-
repo: parsed.repo
|
|
186
|
-
});
|
|
176
|
+
if (!eventType) return [];
|
|
187
177
|
const outcome = eventType === "deployment.succeeded" ? "succeeded" : eventType === "deployment.failed" ? "failed" : eventType === "deployment.error" ? "reported an error" : eventType === "deployment.in_progress" ? "started" : `is ${parsed.state}`;
|
|
188
178
|
const terminal = eventType === "deployment.succeeded" || eventType === "deployment.failed" || eventType === "deployment.error";
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
179
|
+
return deploymentSourceTargets(parsed).map(
|
|
180
|
+
({ completeOnTerminalEvent, resource }) => ({
|
|
181
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
182
|
+
eventType,
|
|
183
|
+
occurredAtMs: providerTime(parsed.statusCreatedAt) ?? Date.now(),
|
|
184
|
+
provider: "github",
|
|
185
|
+
resourceRef: resource.resourceRef,
|
|
186
|
+
...terminal && completeOnTerminalEvent ? { terminal: true } : {},
|
|
187
|
+
trustedSummary: `${resource.label} ${outcome} (deployment ${parsed.deploymentId}).`,
|
|
188
|
+
untrustedText: parsed.description ?? void 0
|
|
189
|
+
})
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
function deploymentSourceTargets(input) {
|
|
193
|
+
return [
|
|
194
|
+
{
|
|
195
|
+
completeOnTerminalEvent: true,
|
|
196
|
+
resource: gitHubDeploymentSourceResource(input)
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
completeOnTerminalEvent: false,
|
|
200
|
+
resource: gitHubDeploymentSourceResource({
|
|
201
|
+
commitSha: input.commitSha,
|
|
202
|
+
repo: input.repo
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
];
|
|
199
206
|
}
|
|
200
207
|
var checkSuiteWebhookSchema = z.object({
|
|
201
208
|
action: z.string(),
|
|
@@ -361,12 +368,10 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
361
368
|
function normalizeGitHubResourceEvents(args) {
|
|
362
369
|
switch (args.eventName) {
|
|
363
370
|
case "deployment": {
|
|
364
|
-
|
|
365
|
-
return event ? [event] : [];
|
|
371
|
+
return normalizeDeploymentEvent(args.deliveryId, args.body);
|
|
366
372
|
}
|
|
367
373
|
case "deployment_status": {
|
|
368
|
-
|
|
369
|
-
return event ? [event] : [];
|
|
374
|
+
return normalizeDeploymentStatusEvent(args.deliveryId, args.body);
|
|
370
375
|
}
|
|
371
376
|
case "pull_request": {
|
|
372
377
|
const event = normalizePullRequestEvent(args.deliveryId, args.body);
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
gitHubDeploymentSourceSubscribable,
|
|
3
3
|
gitHubPullRequestSubscribable,
|
|
4
4
|
normalizeGitHubResourceEvents
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-NNSOXVGR.js";
|
|
6
6
|
|
|
7
7
|
// src/plugin.ts
|
|
8
8
|
import {
|
|
@@ -537,7 +537,9 @@ var inputSchema = z2.object({
|
|
|
537
537
|
commitSha: commitShaSchema.describe(
|
|
538
538
|
"Full 40-character Git commit SHA recorded by the deployment."
|
|
539
539
|
),
|
|
540
|
-
environment: z2.string().trim().min(1).describe(
|
|
540
|
+
environment: z2.string().trim().min(1).describe(
|
|
541
|
+
'Optional GitHub deployment environment, such as "Production". Omit to inspect and watch deployments for the commit across environments.'
|
|
542
|
+
).optional()
|
|
541
543
|
}).strict();
|
|
542
544
|
var statusSchema = z2.object({
|
|
543
545
|
createdAt: z2.string(),
|
|
@@ -563,7 +565,7 @@ var deploymentSchema = z2.object({
|
|
|
563
565
|
var deploymentSourceSchema = z2.object({
|
|
564
566
|
commitSha: commitShaSchema,
|
|
565
567
|
deployment: deploymentSchema.nullable(),
|
|
566
|
-
environment: z2.string(),
|
|
568
|
+
environment: z2.string().nullable(),
|
|
567
569
|
repo: z2.string(),
|
|
568
570
|
subscribable: subscribableResourceSchema.optional()
|
|
569
571
|
}).strict();
|
|
@@ -623,7 +625,7 @@ function repositoryUrl(repo, path) {
|
|
|
623
625
|
}
|
|
624
626
|
function createGitHubGetDeploymentTool(ctx) {
|
|
625
627
|
return definePluginTool2({
|
|
626
|
-
description: "Get the latest GitHub deployment and status for an exact repository
|
|
628
|
+
description: "Get the latest GitHub deployment and status for an exact repository and full commit SHA, optionally limited to one environment. The result remains subscribable when no deployment exists yet, so use it before waiting for a deployment outcome.",
|
|
627
629
|
inputSchema,
|
|
628
630
|
outputSchema,
|
|
629
631
|
async execute(input) {
|
|
@@ -631,7 +633,9 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
631
633
|
const commitSha = input.commitSha.toLowerCase();
|
|
632
634
|
const deploymentsUrl = new URL(repositoryUrl(repo, "deployments"));
|
|
633
635
|
deploymentsUrl.searchParams.set("sha", commitSha);
|
|
634
|
-
|
|
636
|
+
if (input.environment) {
|
|
637
|
+
deploymentsUrl.searchParams.set("environment", input.environment);
|
|
638
|
+
}
|
|
635
639
|
deploymentsUrl.searchParams.set("per_page", "1");
|
|
636
640
|
const deploymentsResponse = await ctx.egress.fetch({
|
|
637
641
|
provider: "github",
|
|
@@ -705,7 +709,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
705
709
|
const data = {
|
|
706
710
|
commitSha,
|
|
707
711
|
deployment,
|
|
708
|
-
environment: input.environment,
|
|
712
|
+
environment: input.environment ?? null,
|
|
709
713
|
repo: repo.ref,
|
|
710
714
|
...subscribable ? { subscribable } : {}
|
|
711
715
|
};
|
|
@@ -1073,6 +1077,7 @@ import {
|
|
|
1073
1077
|
} from "@sentry/junior-plugin-api";
|
|
1074
1078
|
import { z as z4 } from "zod";
|
|
1075
1079
|
import { subscribableResourceSchema as subscribableResourceSchema3 } from "@sentry/junior-plugin-api";
|
|
1080
|
+
var commitShaSchema2 = z4.string().regex(/^[0-9a-f]{40}$/i);
|
|
1076
1081
|
var inputSchema2 = z4.object({
|
|
1077
1082
|
repo: z4.string().describe('Repository in "owner/name" format.'),
|
|
1078
1083
|
number: z4.number().int().positive().describe("Pull request number.")
|
|
@@ -1081,6 +1086,7 @@ var pullRequestSchema = z4.object({
|
|
|
1081
1086
|
base: z4.string(),
|
|
1082
1087
|
draft: z4.boolean(),
|
|
1083
1088
|
head: z4.string(),
|
|
1089
|
+
headSha: commitShaSchema2,
|
|
1084
1090
|
merged: z4.boolean(),
|
|
1085
1091
|
number: z4.number(),
|
|
1086
1092
|
state: z4.string(),
|
|
@@ -1139,7 +1145,7 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
1139
1145
|
const providerResult = z4.object({
|
|
1140
1146
|
base: z4.object({ ref: z4.string() }),
|
|
1141
1147
|
draft: z4.boolean(),
|
|
1142
|
-
head: z4.object({ ref: z4.string() }),
|
|
1148
|
+
head: z4.object({ ref: z4.string(), sha: commitShaSchema2 }),
|
|
1143
1149
|
html_url: z4.string(),
|
|
1144
1150
|
merged: z4.boolean().optional().default(false),
|
|
1145
1151
|
number: z4.number(),
|
|
@@ -1154,6 +1160,7 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
1154
1160
|
base: providerResult.base.ref,
|
|
1155
1161
|
draft: providerResult.draft,
|
|
1156
1162
|
head: providerResult.head.ref,
|
|
1163
|
+
headSha: providerResult.head.sha.toLowerCase(),
|
|
1157
1164
|
merged: providerResult.merged,
|
|
1158
1165
|
number: providerResult.number,
|
|
1159
1166
|
state: providerResult.state,
|
|
@@ -3,12 +3,12 @@ export declare const GITHUB_DEPLOYMENT_EVENTS: readonly ["deployment.created", "
|
|
|
3
3
|
/** Build the stable deployment-source identity shared by tools and webhooks. */
|
|
4
4
|
export declare function gitHubDeploymentSourceResource(input: {
|
|
5
5
|
commitSha: string;
|
|
6
|
-
environment
|
|
6
|
+
environment?: string;
|
|
7
7
|
repo: string;
|
|
8
8
|
}): Pick<SubscribableResource, "label" | "provider" | "resourceRef">;
|
|
9
9
|
/** Describe a deployment source when GitHub webhooks are enabled. */
|
|
10
10
|
export declare function gitHubDeploymentSourceSubscribable(input: {
|
|
11
11
|
commitSha: string;
|
|
12
|
-
environment
|
|
12
|
+
environment?: string;
|
|
13
13
|
repo: string;
|
|
14
14
|
}): SubscribableResource | undefined;
|
package/dist/testing.js
CHANGED
|
@@ -3,7 +3,7 @@ import { type ToolRegistrationHookContext } from "@sentry/junior-plugin-api";
|
|
|
3
3
|
export declare function createGitHubGetDeploymentTool(ctx: ToolRegistrationHookContext): import("@sentry/junior-plugin-api").PluginToolDefinition<{
|
|
4
4
|
repo: string;
|
|
5
5
|
commitSha: string;
|
|
6
|
-
environment
|
|
6
|
+
environment?: string | undefined;
|
|
7
7
|
}, {
|
|
8
8
|
commitSha: string;
|
|
9
9
|
deployment: {
|
|
@@ -26,7 +26,7 @@ export declare function createGitHubGetDeploymentTool(ctx: ToolRegistrationHookC
|
|
|
26
26
|
updatedAt: string;
|
|
27
27
|
url: string;
|
|
28
28
|
} | null;
|
|
29
|
-
environment: string;
|
|
29
|
+
environment: string | null;
|
|
30
30
|
repo: string;
|
|
31
31
|
data: {
|
|
32
32
|
commitSha: string;
|
|
@@ -50,7 +50,7 @@ export declare function createGitHubGetDeploymentTool(ctx: ToolRegistrationHookC
|
|
|
50
50
|
updatedAt: string;
|
|
51
51
|
url: string;
|
|
52
52
|
} | null;
|
|
53
|
-
environment: string;
|
|
53
|
+
environment: string | null;
|
|
54
54
|
repo: string;
|
|
55
55
|
subscribable?: {
|
|
56
56
|
label: string;
|
|
@@ -8,6 +8,7 @@ export declare function createGitHubGetPullRequestTool(ctx: ToolRegistrationHook
|
|
|
8
8
|
base: string;
|
|
9
9
|
draft: boolean;
|
|
10
10
|
head: string;
|
|
11
|
+
headSha: string;
|
|
11
12
|
merged: boolean;
|
|
12
13
|
number: number;
|
|
13
14
|
state: string;
|
|
@@ -20,6 +21,7 @@ export declare function createGitHubGetPullRequestTool(ctx: ToolRegistrationHook
|
|
|
20
21
|
base: string;
|
|
21
22
|
draft: boolean;
|
|
22
23
|
head: string;
|
|
24
|
+
headSha: string;
|
|
23
25
|
merged: boolean;
|
|
24
26
|
number: number;
|
|
25
27
|
state: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.121.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@sinclair/typebox": "^0.34.49",
|
|
32
32
|
"drizzle-orm": "^0.45.2",
|
|
33
33
|
"zod": "^4.4.3",
|
|
34
|
-
"@sentry/junior-plugin-api": "0.
|
|
34
|
+
"@sentry/junior-plugin-api": "0.121.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^25.9.1",
|