@sentry/junior-github 0.265.0 → 0.266.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/{chunk-4RYMEHIK.js → chunk-B6WCXAII.js} +458 -377
- package/dist/events/comment.d.ts +7 -0
- package/dist/events/issue.d.ts +4 -4
- package/dist/events/pull-request.d.ts +2 -1
- package/dist/events/release.d.ts +19 -1
- package/dist/events/scope.d.ts +13 -0
- package/dist/index.js +44 -33
- package/dist/testing.js +1 -1
- package/dist/webhooks/event-targets.d.ts +7 -1
- package/dist/webhooks/handler.d.ts +11 -5
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type EventMatchFields } from "@sentry/junior-plugin-api";
|
|
2
|
+
/**
|
|
3
|
+
* Filters on who wrote a GitHub comment or review. Issue comments, pull
|
|
4
|
+
* request comments, reviews, and inline review comments set them, so the
|
|
5
|
+
* issue, pull request, and repository resource types share one definition.
|
|
6
|
+
*/
|
|
7
|
+
export declare function gitHubCommentMatchFields(events: readonly string[]): EventMatchFields;
|
package/dist/events/issue.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { type SubscribableResource } from "@sentry/junior-plugin-api";
|
|
|
2
2
|
export declare const GITHUB_ISSUE_EVENTS: string[];
|
|
3
3
|
export declare const GITHUB_ISSUE_SUGGESTED_EVENTS: string[];
|
|
4
4
|
/**
|
|
5
|
-
* Exact values GitHub sets on issue
|
|
6
|
-
* `issue.comment.created` sets
|
|
7
|
-
* select other events.
|
|
5
|
+
* Exact values GitHub sets on issue event data. Every issue event sets the
|
|
6
|
+
* repository and issue number. Only `issue.comment.created` sets the comment
|
|
7
|
+
* filters, so a trigger with them cannot select other events.
|
|
8
8
|
*/
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const GITHUB_ISSUE_MATCH_FIELDS: Record<string, {
|
|
10
10
|
kind: "boolean" | "number" | "string";
|
|
11
11
|
description: string;
|
|
12
12
|
enum?: string[] | undefined;
|
|
@@ -26,7 +26,8 @@ export declare const GITHUB_PULL_REQUEST_SUGGESTED_EVENTS: readonly ["pull_reque
|
|
|
26
26
|
* Exact values GitHub may set on pull request event data. Missing keys do not
|
|
27
27
|
* match. The opener and author values load in
|
|
28
28
|
* `webhooks/pull-request-match-data.ts` for every pull request event. The
|
|
29
|
-
* pull request comment webhook has no head branch.
|
|
29
|
+
* pull request comment webhook has no head branch. A check suite result that
|
|
30
|
+
* GitHub links to no pull request has no `pullRequest`.
|
|
30
31
|
*/
|
|
31
32
|
export declare const GITHUB_PULL_REQUEST_MATCH_FIELDS: Record<string, {
|
|
32
33
|
kind: "boolean" | "number" | "string";
|
package/dist/events/release.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SubscribableResource } from "@sentry/junior-plugin-api";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
export declare const GITHUB_RELEASE_EVENTS: readonly ["release.published"];
|
|
4
|
+
/**
|
|
5
|
+
* `tag` in event data: the trimmed tag with ASCII letters in lowercase. The
|
|
6
|
+
* release-source identifier has the URI-encoded tag, and the plugin
|
|
7
|
+
* lowercases identifiers. Encoding turns other characters into `%XX`
|
|
8
|
+
* escapes, so only ASCII letters change case there. This form is the same
|
|
9
|
+
* text, so `release/1.0` is not `release%2f1.0`, and `Ü` stays `Ü`. To turn
|
|
10
|
+
* an identifier into a `tag` filter, decode its tag part.
|
|
11
|
+
*/
|
|
12
|
+
export declare const gitHubReleaseTagDataSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
13
|
+
/** Exact values that every release event sets. */
|
|
14
|
+
export declare const GITHUB_RELEASE_MATCH_FIELDS: Record<string, {
|
|
15
|
+
kind: "boolean" | "number" | "string";
|
|
16
|
+
description: string;
|
|
17
|
+
enum?: string[] | undefined;
|
|
18
|
+
list?: true | undefined;
|
|
19
|
+
events?: string[] | undefined;
|
|
20
|
+
}>;
|
|
3
21
|
export declare const GITHUB_RELEASE_SUGGESTED_EVENTS: string[];
|
|
4
22
|
/** The identifier shape that `gitHubReleaseSourceResource` builds. */
|
|
5
23
|
export declare const GITHUB_RELEASE_SOURCE_IDENTIFIER: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type EventMatchFields } from "@sentry/junior-plugin-api";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* `repo` in event data: lowercase `owner/repo`. GitHub ignores case in
|
|
5
|
+
* repository names, so tools accept this form.
|
|
6
|
+
*/
|
|
7
|
+
export declare const gitHubRepoDataSchema: z.ZodString;
|
|
8
|
+
/** `commitSha` in event data: the full lowercase commit SHA. */
|
|
9
|
+
export declare const gitHubCommitShaDataSchema: z.ZodString;
|
|
10
|
+
/** Filter on the repository of an event. */
|
|
11
|
+
export declare function gitHubRepoMatchFields(events: readonly string[]): EventMatchFields;
|
|
12
|
+
/** Filter on the commit of an event. */
|
|
13
|
+
export declare function gitHubCommitMatchFields(events: readonly string[]): EventMatchFields;
|
package/dist/index.js
CHANGED
|
@@ -10,15 +10,16 @@ import {
|
|
|
10
10
|
GITHUB_DEPLOYMENT_SUGGESTED_EVENTS,
|
|
11
11
|
GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES,
|
|
12
12
|
GITHUB_INSTALLATION_ID_ENV,
|
|
13
|
-
GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
|
|
14
13
|
GITHUB_ISSUE_EVENTS,
|
|
15
14
|
GITHUB_ISSUE_IDENTIFIER,
|
|
15
|
+
GITHUB_ISSUE_MATCH_FIELDS,
|
|
16
16
|
GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
17
17
|
GITHUB_PULL_REQUEST_EVENTS,
|
|
18
18
|
GITHUB_PULL_REQUEST_IDENTIFIER,
|
|
19
19
|
GITHUB_PULL_REQUEST_MATCH_FIELDS,
|
|
20
20
|
GITHUB_PULL_REQUEST_SUGGESTED_EVENTS,
|
|
21
21
|
GITHUB_RELEASE_EVENTS,
|
|
22
|
+
GITHUB_RELEASE_MATCH_FIELDS,
|
|
22
23
|
GITHUB_RELEASE_SOURCE_IDENTIFIER,
|
|
23
24
|
GITHUB_RELEASE_SUGGESTED_EVENTS,
|
|
24
25
|
GITHUB_REPOSITORY_EVENTS,
|
|
@@ -29,6 +30,7 @@ import {
|
|
|
29
30
|
botLoginFromEmail,
|
|
30
31
|
botUserIdFromEmail,
|
|
31
32
|
createPermissionCache,
|
|
33
|
+
definedValues,
|
|
32
34
|
gitHubDeploymentSourceSubscribable,
|
|
33
35
|
gitHubIssueSubscribable,
|
|
34
36
|
gitHubPullRequestCreateWatch,
|
|
@@ -53,7 +55,7 @@ import {
|
|
|
53
55
|
readGrantPermissions,
|
|
54
56
|
requireEnv,
|
|
55
57
|
resolveUserAccount
|
|
56
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-B6WCXAII.js";
|
|
57
59
|
|
|
58
60
|
// src/tool-support/attribution.ts
|
|
59
61
|
var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
|
|
@@ -3094,6 +3096,7 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3094
3096
|
|
|
3095
3097
|
// src/webhooks/handler.ts
|
|
3096
3098
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
3099
|
+
import { z as z21 } from "zod";
|
|
3097
3100
|
|
|
3098
3101
|
// src/issue-outcomes/store.ts
|
|
3099
3102
|
import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
|
|
@@ -3676,15 +3679,22 @@ var LOOKUPS_BY_MATCH_KEY = {
|
|
|
3676
3679
|
openerUsername: ["opener"]
|
|
3677
3680
|
};
|
|
3678
3681
|
var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
|
|
3682
|
+
var lookupDataSchema = z19.object({
|
|
3683
|
+
authors: z19.array(z19.string().min(1)).min(1).optional(),
|
|
3684
|
+
openerRole: z19.string().min(1).optional(),
|
|
3685
|
+
openerUsername: z19.string().min(1).optional()
|
|
3686
|
+
}).strict();
|
|
3687
|
+
function lookupData(input) {
|
|
3688
|
+
return lookupDataSchema.parse(definedValues(input));
|
|
3689
|
+
}
|
|
3679
3690
|
var webhookSchema = z19.object({
|
|
3680
3691
|
repository: z19.object({ full_name: z19.string().min(1) })
|
|
3681
3692
|
});
|
|
3682
3693
|
function pullRequestNumbers(events) {
|
|
3683
3694
|
const numbers = /* @__PURE__ */ new Map();
|
|
3684
3695
|
for (const event of events) {
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
if (match) numbers.set(event.eventKey, Number(match[1]));
|
|
3696
|
+
const number = event.data?.pullRequest;
|
|
3697
|
+
if (typeof number === "number") numbers.set(event.eventKey, number);
|
|
3688
3698
|
}
|
|
3689
3699
|
return numbers;
|
|
3690
3700
|
}
|
|
@@ -3727,7 +3737,7 @@ async function withJuniorOpeners(context, events) {
|
|
|
3727
3737
|
} = event.data ?? {};
|
|
3728
3738
|
return {
|
|
3729
3739
|
...event,
|
|
3730
|
-
data: { ...data, ...
|
|
3740
|
+
data: { ...data, ...lookupData({ openerUsername: login || void 0 }) }
|
|
3731
3741
|
};
|
|
3732
3742
|
});
|
|
3733
3743
|
}
|
|
@@ -3766,8 +3776,10 @@ async function withRolesAndAuthors(context, events, lookups) {
|
|
|
3766
3776
|
...event,
|
|
3767
3777
|
data: {
|
|
3768
3778
|
...event.data,
|
|
3769
|
-
...
|
|
3770
|
-
|
|
3779
|
+
...lookupData({
|
|
3780
|
+
authors: logins?.length ? logins : void 0,
|
|
3781
|
+
openerRole: role || void 0
|
|
3782
|
+
})
|
|
3771
3783
|
}
|
|
3772
3784
|
};
|
|
3773
3785
|
})
|
|
@@ -3980,19 +3992,17 @@ function webhookInstallationId(body) {
|
|
|
3980
3992
|
}
|
|
3981
3993
|
return parseInstallationId(installation.id);
|
|
3982
3994
|
}
|
|
3995
|
+
var feedbackTargetSchema = z21.object({
|
|
3996
|
+
commentId: z21.number(),
|
|
3997
|
+
commentKind: z21.enum(["conversation", "review"]),
|
|
3998
|
+
repo: z21.string().min(1)
|
|
3999
|
+
});
|
|
3983
4000
|
function pullRequestFeedbackTarget(events) {
|
|
3984
4001
|
const event = events.find(
|
|
3985
4002
|
(candidate) => candidate.eventType === "pull_request.comment.created" || candidate.eventType === "pull_request.review_comment.created"
|
|
3986
4003
|
);
|
|
3987
|
-
const
|
|
3988
|
-
|
|
3989
|
-
return void 0;
|
|
3990
|
-
}
|
|
3991
|
-
return {
|
|
3992
|
-
commentId: data.commentId,
|
|
3993
|
-
commentKind: data.commentKind,
|
|
3994
|
-
repo: data.repo
|
|
3995
|
-
};
|
|
4004
|
+
const parsed = feedbackTargetSchema.safeParse(event?.data);
|
|
4005
|
+
return parsed.success ? parsed.data : void 0;
|
|
3996
4006
|
}
|
|
3997
4007
|
function githubCodeChange(outcome, conversationIds) {
|
|
3998
4008
|
return {
|
|
@@ -4210,7 +4220,7 @@ function createGitHubWebhookRoute(args) {
|
|
|
4210
4220
|
}
|
|
4211
4221
|
|
|
4212
4222
|
// src/webhooks/installation-requests.ts
|
|
4213
|
-
import { z as
|
|
4223
|
+
import { z as z22 } from "zod";
|
|
4214
4224
|
function splitRepository(fullName, label) {
|
|
4215
4225
|
const [owner, name, ...extra] = fullName.split("/");
|
|
4216
4226
|
if (!owner || !name || extra.length > 0) {
|
|
@@ -4255,9 +4265,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
4255
4265
|
}
|
|
4256
4266
|
);
|
|
4257
4267
|
}
|
|
4258
|
-
var repositoryPermissionSchema =
|
|
4259
|
-
permission:
|
|
4260
|
-
role_name:
|
|
4268
|
+
var repositoryPermissionSchema = z22.object({
|
|
4269
|
+
permission: z22.string().min(1),
|
|
4270
|
+
role_name: z22.string().optional()
|
|
4261
4271
|
});
|
|
4262
4272
|
var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
|
|
4263
4273
|
async function loadRepositoryRole(env, cache, target) {
|
|
@@ -4289,18 +4299,18 @@ async function loadRepositoryRole(env, cache, target) {
|
|
|
4289
4299
|
}
|
|
4290
4300
|
|
|
4291
4301
|
// src/pull-request-outcomes/commit-composition.ts
|
|
4292
|
-
import { z as
|
|
4293
|
-
var canonicalCommitSchema =
|
|
4294
|
-
authorEmail:
|
|
4295
|
-
authorLogin:
|
|
4302
|
+
import { z as z23 } from "zod";
|
|
4303
|
+
var canonicalCommitSchema = z23.object({
|
|
4304
|
+
authorEmail: z23.string().nullable(),
|
|
4305
|
+
authorLogin: z23.string().nullable()
|
|
4296
4306
|
}).strict();
|
|
4297
|
-
var providerCommitSchema =
|
|
4298
|
-
author:
|
|
4299
|
-
commit:
|
|
4300
|
-
author:
|
|
4307
|
+
var providerCommitSchema = z23.object({
|
|
4308
|
+
author: z23.object({ login: z23.string() }).passthrough().nullable(),
|
|
4309
|
+
commit: z23.object({
|
|
4310
|
+
author: z23.object({ email: z23.string() }).passthrough().nullable()
|
|
4301
4311
|
}).passthrough()
|
|
4302
4312
|
}).passthrough();
|
|
4303
|
-
var commitPageSchema2 =
|
|
4313
|
+
var commitPageSchema2 = z23.array(providerCommitSchema).transform(
|
|
4304
4314
|
(commits) => commits.map(
|
|
4305
4315
|
(commit) => canonicalCommitSchema.parse({
|
|
4306
4316
|
authorEmail: commit.commit.author?.email ?? null,
|
|
@@ -5560,7 +5570,7 @@ function githubPlugin(options = {}) {
|
|
|
5560
5570
|
identifier: GITHUB_ISSUE_IDENTIFIER,
|
|
5561
5571
|
supportedEvents: [...GITHUB_ISSUE_EVENTS],
|
|
5562
5572
|
suggestedEvents: [...GITHUB_ISSUE_SUGGESTED_EVENTS],
|
|
5563
|
-
matchFields:
|
|
5573
|
+
matchFields: GITHUB_ISSUE_MATCH_FIELDS
|
|
5564
5574
|
},
|
|
5565
5575
|
{
|
|
5566
5576
|
type: "pull_request",
|
|
@@ -5576,7 +5586,8 @@ function githubPlugin(options = {}) {
|
|
|
5576
5586
|
type: "release_source",
|
|
5577
5587
|
identifier: GITHUB_RELEASE_SOURCE_IDENTIFIER,
|
|
5578
5588
|
supportedEvents: [...GITHUB_RELEASE_EVENTS],
|
|
5579
|
-
suggestedEvents: [...GITHUB_RELEASE_SUGGESTED_EVENTS]
|
|
5589
|
+
suggestedEvents: [...GITHUB_RELEASE_SUGGESTED_EVENTS],
|
|
5590
|
+
matchFields: GITHUB_RELEASE_MATCH_FIELDS
|
|
5580
5591
|
},
|
|
5581
5592
|
{
|
|
5582
5593
|
type: "repository",
|
|
@@ -5585,7 +5596,7 @@ function githubPlugin(options = {}) {
|
|
|
5585
5596
|
suggestedEvents: [...GITHUB_REPOSITORY_SUGGESTED_EVENTS],
|
|
5586
5597
|
matchFields: mergeEventMatchFields(
|
|
5587
5598
|
GITHUB_DEPLOYMENT_MATCH_FIELDS,
|
|
5588
|
-
|
|
5599
|
+
GITHUB_ISSUE_MATCH_FIELDS,
|
|
5589
5600
|
GITHUB_PULL_REQUEST_MATCH_FIELDS
|
|
5590
5601
|
),
|
|
5591
5602
|
guidance: gitHubPullRequestEventGuidance(
|
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Event key and target helpers shared by the GitHub webhook
|
|
2
|
+
* Event data, event key, and target helpers shared by the GitHub webhook
|
|
3
|
+
* normalizers.
|
|
3
4
|
*/
|
|
4
5
|
import type { EventInput } from "@sentry/junior-plugin-api";
|
|
6
|
+
/**
|
|
7
|
+
* Drop missing values from event data. A filter on a value that GitHub did not
|
|
8
|
+
* send then does not match.
|
|
9
|
+
*/
|
|
10
|
+
export declare function definedValues(data: Record<string, unknown>): Record<string, unknown>;
|
|
5
11
|
/** Build the event key for one event type from one webhook delivery. */
|
|
6
12
|
export declare function gitHubEventKey(deliveryId: string, eventType: string): string;
|
|
7
13
|
/**
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import type { CodeChangePublisher, PluginConversationAnnotations, PluginLogger, PluginRoute, EventPublisher } from "@sentry/junior-plugin-api";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import type { GitHubDb } from "../db/database.js";
|
|
3
4
|
import type { GitHubPullRequestCommitComposition } from "../db/schema.js";
|
|
4
5
|
import { type GitHubRoleTarget } from "./pull-request-match-data.js";
|
|
5
6
|
import { type GitHubCommitPageLoader, type GitHubPullRequestTarget } from "./pull-request-people.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
/** The pull request comment data that the feedback reaction needs. */
|
|
8
|
+
declare const feedbackTargetSchema: z.ZodObject<{
|
|
9
|
+
commentId: z.ZodNumber;
|
|
10
|
+
commentKind: z.ZodEnum<{
|
|
11
|
+
conversation: "conversation";
|
|
12
|
+
review: "review";
|
|
13
|
+
}>;
|
|
14
|
+
repo: z.ZodString;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
type FeedbackTarget = z.output<typeof feedbackTargetSchema>;
|
|
11
17
|
/** Create the public, signed GitHub webhook route owned by the plugin. */
|
|
12
18
|
export declare function createGitHubWebhookRoute(args: {
|
|
13
19
|
annotations: PluginConversationAnnotations;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.266.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"drizzle-orm": "^0.45.2",
|
|
33
33
|
"marked": "^18.1.2",
|
|
34
34
|
"zod": "^4.5.4",
|
|
35
|
-
"@sentry/junior-plugin-api": "0.
|
|
35
|
+
"@sentry/junior-plugin-api": "0.266.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@oxlint/plugins": "1.79.0",
|