@sentry/junior-github 0.264.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/README.md +51 -0
- package/dist/{chunk-KWVC6CU5.js → chunk-B6WCXAII.js} +534 -441
- package/dist/credential-support.d.ts +1 -1
- package/dist/db/schema.d.ts +192 -0
- package/dist/events/comment.d.ts +7 -0
- package/dist/events/deployment.d.ts +13 -2
- package/dist/events/issue.d.ts +12 -4
- package/dist/events/pull-request.d.ts +15 -2
- package/dist/events/release.d.ts +25 -2
- package/dist/events/repository.d.ts +10 -1
- package/dist/events/scope.d.ts +13 -0
- package/dist/index.js +819 -545
- package/dist/plugin.d.ts +0 -5
- package/dist/pull-request-requesters/store.d.ts +34 -0
- package/dist/testing.js +1 -1
- package/dist/tool-support/attribution.d.ts +22 -11
- package/dist/tools/update-pull-request.d.ts +1 -0
- package/dist/webhooks/check-suite.d.ts +4 -4
- package/dist/webhooks/event-targets.d.ts +18 -0
- package/dist/webhooks/handler.d.ts +23 -12
- package/dist/webhooks/pull-request-match-data.d.ts +31 -0
- package/dist/webhooks/pull-request-people.d.ts +25 -5
- package/migrations/0009_nostalgic_thing.sql +8 -0
- package/migrations/meta/0009_snapshot.json +404 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +2 -2
- package/dist/webhooks/pull-request-author-role.d.ts +0 -20
package/dist/index.js
CHANGED
|
@@ -10,23 +10,27 @@ 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,
|
|
25
|
+
GITHUB_REPOSITORY_EVENTS,
|
|
24
26
|
GITHUB_REPOSITORY_IDENTIFIER,
|
|
27
|
+
GITHUB_REPOSITORY_SUGGESTED_EVENTS,
|
|
25
28
|
HTTP_READ_METHODS,
|
|
26
29
|
USER_WRITE_REQUIREMENTS,
|
|
27
30
|
botLoginFromEmail,
|
|
28
31
|
botUserIdFromEmail,
|
|
29
32
|
createPermissionCache,
|
|
33
|
+
definedValues,
|
|
30
34
|
gitHubDeploymentSourceSubscribable,
|
|
31
35
|
gitHubIssueSubscribable,
|
|
32
36
|
gitHubPullRequestCreateWatch,
|
|
@@ -51,11 +55,118 @@ import {
|
|
|
51
55
|
readGrantPermissions,
|
|
52
56
|
requireEnv,
|
|
53
57
|
resolveUserAccount
|
|
54
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-B6WCXAII.js";
|
|
59
|
+
|
|
60
|
+
// src/tool-support/attribution.ts
|
|
61
|
+
var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
|
|
62
|
+
var GITHUB_REQUEST_ATTRIBUTION_END = "<!-- junior-request-attribution:end -->";
|
|
63
|
+
var SLACK_USER_ID_DISPLAY_PATTERN = /^[UW][A-Z0-9]{5,}$/;
|
|
64
|
+
var GITHUB_LOGIN_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/;
|
|
65
|
+
function linkedGitHubLogin(user) {
|
|
66
|
+
const login = user?.identities.find((identity) => identity.provider === "github")?.handle?.trim().replace(/^@/, "");
|
|
67
|
+
return login && GITHUB_LOGIN_PATTERN.test(login) ? login : void 0;
|
|
68
|
+
}
|
|
69
|
+
function cleanDisplayValue(value, userId) {
|
|
70
|
+
const cleaned = value?.replace(/[\r\n<>]/g, " ").trim();
|
|
71
|
+
if (!cleaned) {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
if (cleaned.toLowerCase() === "unknown") {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
if (userId && cleaned === userId) {
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
if (SLACK_USER_ID_DISPLAY_PATTERN.test(cleaned)) {
|
|
81
|
+
return void 0;
|
|
82
|
+
}
|
|
83
|
+
return cleaned;
|
|
84
|
+
}
|
|
85
|
+
function automationLabel(source, automationUrl) {
|
|
86
|
+
if (source?.kind !== "event_automation" && source?.kind !== "scheduled_automation" || !source.automationId) {
|
|
87
|
+
return void 0;
|
|
88
|
+
}
|
|
89
|
+
const automation = `automation \`${source.automationId}\``;
|
|
90
|
+
const label = automationUrl ? `[${automation}](${automationUrl})` : automation;
|
|
91
|
+
return source.automationRunId ? `${label} \xB7 Run ID \`${source.automationRunId}\`` : label;
|
|
92
|
+
}
|
|
93
|
+
function requesterLabel(args) {
|
|
94
|
+
const { actor, identity, user } = args;
|
|
95
|
+
const automation = automationLabel(args.source, args.automationUrl);
|
|
96
|
+
if (automation) {
|
|
97
|
+
return automation;
|
|
98
|
+
}
|
|
99
|
+
if (!actor || actor.platform === "system") {
|
|
100
|
+
return void 0;
|
|
101
|
+
}
|
|
102
|
+
const login = linkedGitHubLogin(user);
|
|
103
|
+
if (login) {
|
|
104
|
+
return `@${login}`;
|
|
105
|
+
}
|
|
106
|
+
const userId = actor.userId;
|
|
107
|
+
const display = cleanDisplayValue(user?.displayName, userId) ?? cleanDisplayValue(identity?.displayName, userId) ?? cleanDisplayValue(identity?.handle, userId) ?? cleanDisplayValue(actor.fullName, userId) ?? cleanDisplayValue(actor.userName, userId);
|
|
108
|
+
return display ? `**${display.replaceAll("*", "\\*")}**` : void 0;
|
|
109
|
+
}
|
|
110
|
+
function parseExistingLabels(blockContents) {
|
|
111
|
+
const trimmed = blockContents.trim().replace(/\.$/, "");
|
|
112
|
+
if (!trimmed) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
const withoutLeadIn = trimmed.replace(/^(?:Requested by|via)\s+/i, "");
|
|
116
|
+
return withoutLeadIn.split(/,\s*(?=\*\*|@|\[?automation `|Junior system actor `|via\s)/i).map((entry) => entry.trim().replace(/^via\s+/i, "")).filter(Boolean);
|
|
117
|
+
}
|
|
118
|
+
function formatAttributionBlock(labels) {
|
|
119
|
+
return `${GITHUB_REQUEST_ATTRIBUTION_START}
|
|
120
|
+
via ${labels.join(", ")}.
|
|
121
|
+
${GITHUB_REQUEST_ATTRIBUTION_END}`;
|
|
122
|
+
}
|
|
123
|
+
function applyAttribution(body, label) {
|
|
124
|
+
const normalizedBody = body.trimEnd();
|
|
125
|
+
const existing = new RegExp(
|
|
126
|
+
`${GITHUB_REQUEST_ATTRIBUTION_START}([\\s\\S]*?)${GITHUB_REQUEST_ATTRIBUTION_END}`
|
|
127
|
+
);
|
|
128
|
+
const existingMatch = normalizedBody.match(existing);
|
|
129
|
+
const existingLabels = existingMatch?.[1] !== void 0 ? parseExistingLabels(existingMatch[1]) : [];
|
|
130
|
+
const labels = label && !existingLabels.includes(label) ? [...existingLabels, label] : existingLabels;
|
|
131
|
+
const attribution = labels.length ? formatAttributionBlock(labels) : void 0;
|
|
132
|
+
if (existingMatch) {
|
|
133
|
+
return attribution ? normalizedBody.replace(existing, attribution) : normalizedBody.replace(existing, "").trimEnd();
|
|
134
|
+
}
|
|
135
|
+
if (!attribution) {
|
|
136
|
+
return normalizedBody;
|
|
137
|
+
}
|
|
138
|
+
return normalizedBody ? `${normalizedBody}
|
|
139
|
+
|
|
140
|
+
${attribution}` : attribution;
|
|
141
|
+
}
|
|
142
|
+
async function resolveGitHubRequester(ctx) {
|
|
143
|
+
if (!ctx.actor || ctx.actor.platform === "system") return void 0;
|
|
144
|
+
try {
|
|
145
|
+
return await ctx.users.resolveActor();
|
|
146
|
+
} catch (error) {
|
|
147
|
+
ctx.log.warn("github.requester.resolve_actor.failed", {
|
|
148
|
+
"exception.message": error instanceof Error ? error.message : String(error)
|
|
149
|
+
});
|
|
150
|
+
return void 0;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function appendGitHubRequesterAttribution(body, ctx, requester) {
|
|
154
|
+
return applyAttribution(
|
|
155
|
+
body,
|
|
156
|
+
requesterLabel({
|
|
157
|
+
actor: ctx.actor,
|
|
158
|
+
automationUrl: ctx.automationLink?.url,
|
|
159
|
+
identity: requester?.identity,
|
|
160
|
+
source: ctx.source,
|
|
161
|
+
user: requester?.user
|
|
162
|
+
})
|
|
163
|
+
);
|
|
164
|
+
}
|
|
55
165
|
|
|
56
166
|
// src/plugin.ts
|
|
57
167
|
import {
|
|
58
|
-
defineJuniorPlugin
|
|
168
|
+
defineJuniorPlugin,
|
|
169
|
+
mergeEventMatchFields
|
|
59
170
|
} from "@sentry/junior-plugin-api";
|
|
60
171
|
|
|
61
172
|
// src/tools/clone-repository.ts
|
|
@@ -458,7 +569,7 @@ function githubConversationFooter(conversationId, dashboardUrl) {
|
|
|
458
569
|
const id = nonEmptyString(conversationId, "conversationId");
|
|
459
570
|
const normalizedDashboardUrl = dashboardUrl?.trim();
|
|
460
571
|
const sentryUrl = sentryConversationUrl(id);
|
|
461
|
-
const sessionLinks = normalizedDashboardUrl ? `[View
|
|
572
|
+
const sessionLinks = normalizedDashboardUrl ? `[View Session](${normalizedDashboardUrl})${sentryUrl ? ` [[Sentry]](${sentryUrl})` : ""}` : sentryUrl ? `[View Session in Sentry](${sentryUrl})` : void 0;
|
|
462
573
|
if (!sessionLinks) {
|
|
463
574
|
return void 0;
|
|
464
575
|
}
|
|
@@ -534,111 +645,6 @@ function appendGitHubFooter(body, conversationId, dashboardUrl) {
|
|
|
534
645
|
${footer}` : footer;
|
|
535
646
|
}
|
|
536
647
|
|
|
537
|
-
// src/tool-support/attribution.ts
|
|
538
|
-
var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
|
|
539
|
-
var GITHUB_REQUEST_ATTRIBUTION_END = "<!-- junior-request-attribution:end -->";
|
|
540
|
-
var SLACK_USER_ID_DISPLAY_PATTERN = /^[UW][A-Z0-9]{5,}$/;
|
|
541
|
-
var GITHUB_LOGIN_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/;
|
|
542
|
-
function linkedGitHubLogin(user) {
|
|
543
|
-
const login = user?.identities.find((identity) => identity.provider === "github")?.handle?.trim().replace(/^@/, "");
|
|
544
|
-
return login && GITHUB_LOGIN_PATTERN.test(login) ? login : void 0;
|
|
545
|
-
}
|
|
546
|
-
function cleanDisplayValue(value, userId) {
|
|
547
|
-
const cleaned = value?.replace(/[\r\n<>]/g, " ").trim();
|
|
548
|
-
if (!cleaned) {
|
|
549
|
-
return void 0;
|
|
550
|
-
}
|
|
551
|
-
if (cleaned.toLowerCase() === "unknown") {
|
|
552
|
-
return void 0;
|
|
553
|
-
}
|
|
554
|
-
if (userId && cleaned === userId) {
|
|
555
|
-
return void 0;
|
|
556
|
-
}
|
|
557
|
-
if (SLACK_USER_ID_DISPLAY_PATTERN.test(cleaned)) {
|
|
558
|
-
return void 0;
|
|
559
|
-
}
|
|
560
|
-
return cleaned;
|
|
561
|
-
}
|
|
562
|
-
function automationLabel(source, automationUrl) {
|
|
563
|
-
if (source?.kind !== "event_automation" && source?.kind !== "scheduled_automation" || !source.automationId) {
|
|
564
|
-
return void 0;
|
|
565
|
-
}
|
|
566
|
-
const automation = `automation \`${source.automationId}\``;
|
|
567
|
-
const label = automationUrl ? `[${automation}](${automationUrl})` : automation;
|
|
568
|
-
return source.automationRunId ? `${label} \xB7 Run ID \`${source.automationRunId}\`` : label;
|
|
569
|
-
}
|
|
570
|
-
function requesterLabel(args) {
|
|
571
|
-
const { actor, identity, user } = args;
|
|
572
|
-
const automation = automationLabel(args.source, args.automationUrl);
|
|
573
|
-
if (automation) {
|
|
574
|
-
return automation;
|
|
575
|
-
}
|
|
576
|
-
if (!actor || actor.platform === "system") {
|
|
577
|
-
return void 0;
|
|
578
|
-
}
|
|
579
|
-
const login = linkedGitHubLogin(user);
|
|
580
|
-
if (login) {
|
|
581
|
-
return `@${login}`;
|
|
582
|
-
}
|
|
583
|
-
const userId = actor.userId;
|
|
584
|
-
const display = cleanDisplayValue(user?.displayName, userId) ?? cleanDisplayValue(identity?.displayName, userId) ?? cleanDisplayValue(identity?.handle, userId) ?? cleanDisplayValue(actor.fullName, userId) ?? cleanDisplayValue(actor.userName, userId);
|
|
585
|
-
return display ? `**${display.replaceAll("*", "\\*")}**` : void 0;
|
|
586
|
-
}
|
|
587
|
-
function parseExistingLabels(blockContents) {
|
|
588
|
-
const trimmed = blockContents.trim().replace(/\.$/, "");
|
|
589
|
-
if (!trimmed) {
|
|
590
|
-
return [];
|
|
591
|
-
}
|
|
592
|
-
const withoutLeadIn = trimmed.replace(/^(?:Requested by|via)\s+/i, "");
|
|
593
|
-
return withoutLeadIn.split(/,\s*(?=\*\*|@|\[?automation `|Junior system actor `|via\s)/i).map((entry) => entry.trim().replace(/^via\s+/i, "")).filter(Boolean);
|
|
594
|
-
}
|
|
595
|
-
function formatAttributionBlock(labels) {
|
|
596
|
-
return `${GITHUB_REQUEST_ATTRIBUTION_START}
|
|
597
|
-
via ${labels.join(", ")}.
|
|
598
|
-
${GITHUB_REQUEST_ATTRIBUTION_END}`;
|
|
599
|
-
}
|
|
600
|
-
function applyAttribution(body, label) {
|
|
601
|
-
const normalizedBody = body.trimEnd();
|
|
602
|
-
const existing = new RegExp(
|
|
603
|
-
`${GITHUB_REQUEST_ATTRIBUTION_START}([\\s\\S]*?)${GITHUB_REQUEST_ATTRIBUTION_END}`
|
|
604
|
-
);
|
|
605
|
-
const existingMatch = normalizedBody.match(existing);
|
|
606
|
-
const existingLabels = existingMatch?.[1] !== void 0 ? parseExistingLabels(existingMatch[1]) : [];
|
|
607
|
-
const labels = label && !existingLabels.includes(label) ? [...existingLabels, label] : existingLabels;
|
|
608
|
-
const attribution = labels.length ? formatAttributionBlock(labels) : void 0;
|
|
609
|
-
if (existingMatch) {
|
|
610
|
-
return attribution ? normalizedBody.replace(existing, attribution) : normalizedBody.replace(existing, "").trimEnd();
|
|
611
|
-
}
|
|
612
|
-
if (!attribution) {
|
|
613
|
-
return normalizedBody;
|
|
614
|
-
}
|
|
615
|
-
return normalizedBody ? `${normalizedBody}
|
|
616
|
-
|
|
617
|
-
${attribution}` : attribution;
|
|
618
|
-
}
|
|
619
|
-
async function appendGitHubRequesterAttribution(body, ctx) {
|
|
620
|
-
let resolved;
|
|
621
|
-
if (ctx.actor) {
|
|
622
|
-
try {
|
|
623
|
-
resolved = await ctx.users.resolveActor();
|
|
624
|
-
} catch (error) {
|
|
625
|
-
ctx.log.warn("github.requester_attribution.resolve_actor.failed", {
|
|
626
|
-
"exception.message": error instanceof Error ? error.message : String(error)
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
return applyAttribution(
|
|
631
|
-
body,
|
|
632
|
-
requesterLabel({
|
|
633
|
-
actor: ctx.actor,
|
|
634
|
-
automationUrl: ctx.automationLink?.url,
|
|
635
|
-
identity: resolved?.identity,
|
|
636
|
-
source: ctx.source,
|
|
637
|
-
user: resolved?.user
|
|
638
|
-
})
|
|
639
|
-
);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
648
|
// src/tools/create-issue.ts
|
|
643
649
|
var GITHUB_ISSUE_CREATE_IDEMPOTENCY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
644
650
|
var GITHUB_ISSUE_CREATE_LOCK_TTL_MS = 6e4;
|
|
@@ -712,10 +718,11 @@ var gitHubIssueOutputSchema = pluginToolOutputSchema2.merge(
|
|
|
712
718
|
);
|
|
713
719
|
function gitHubIssueToolResult(input, result, canSubscribe) {
|
|
714
720
|
const repo = parseRepo2(input.repo);
|
|
715
|
-
const subscribable =
|
|
721
|
+
const subscribable = gitHubIssueSubscribable({
|
|
722
|
+
canSubscribe,
|
|
716
723
|
number: result.number,
|
|
717
724
|
repo: `${repo.owner}/${repo.name}`
|
|
718
|
-
})
|
|
725
|
+
});
|
|
719
726
|
const data = {
|
|
720
727
|
number: result.number,
|
|
721
728
|
url: result.url,
|
|
@@ -817,7 +824,11 @@ async function createGitHubIssueRequest(conversationId, input, ctx, dashboardUrl
|
|
|
817
824
|
const payload = {
|
|
818
825
|
title: nonEmptyString2(input.title, "title"),
|
|
819
826
|
body: appendGitHubFooter(
|
|
820
|
-
|
|
827
|
+
appendGitHubRequesterAttribution(
|
|
828
|
+
input.body ?? "",
|
|
829
|
+
ctx,
|
|
830
|
+
await resolveGitHubRequester(ctx)
|
|
831
|
+
),
|
|
821
832
|
conversationId,
|
|
822
833
|
dashboardUrl
|
|
823
834
|
),
|
|
@@ -1140,11 +1151,12 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1140
1151
|
url: `https://github.com/${repo.ref}/deployments`
|
|
1141
1152
|
};
|
|
1142
1153
|
}
|
|
1143
|
-
const subscribable =
|
|
1154
|
+
const subscribable = gitHubDeploymentSourceSubscribable({
|
|
1155
|
+
canSubscribe: ctx.events.canSubscribe,
|
|
1144
1156
|
commitSha,
|
|
1145
1157
|
environment: input.environment,
|
|
1146
1158
|
repo: repo.ref
|
|
1147
|
-
})
|
|
1159
|
+
});
|
|
1148
1160
|
const data = {
|
|
1149
1161
|
commitSha,
|
|
1150
1162
|
deployment,
|
|
@@ -1172,7 +1184,169 @@ import {
|
|
|
1172
1184
|
} from "@sentry/junior-plugin-api";
|
|
1173
1185
|
import { Type as Type2 } from "@sinclair/typebox";
|
|
1174
1186
|
import { Value as Value2 } from "@sinclair/typebox/value";
|
|
1187
|
+
import { z as z6 } from "zod";
|
|
1188
|
+
|
|
1189
|
+
// src/pull-request-requesters/store.ts
|
|
1190
|
+
import { and, asc, eq, inArray, lt } from "drizzle-orm";
|
|
1191
|
+
|
|
1192
|
+
// src/db/schema.ts
|
|
1193
|
+
import { sql } from "drizzle-orm";
|
|
1194
|
+
import {
|
|
1195
|
+
index,
|
|
1196
|
+
integer,
|
|
1197
|
+
pgTable,
|
|
1198
|
+
primaryKey,
|
|
1199
|
+
text,
|
|
1200
|
+
timestamp
|
|
1201
|
+
} from "drizzle-orm/pg-core";
|
|
1175
1202
|
import { z as z5 } from "zod";
|
|
1203
|
+
var githubPullRequestStateSchema = z5.enum([
|
|
1204
|
+
"closed_unmerged",
|
|
1205
|
+
"merged",
|
|
1206
|
+
"open"
|
|
1207
|
+
]);
|
|
1208
|
+
var githubPullRequestCommitCompositionSchema = z5.enum([
|
|
1209
|
+
"junior_only",
|
|
1210
|
+
"mixed"
|
|
1211
|
+
]);
|
|
1212
|
+
var githubIssueStateSchema = z5.enum(["closed", "open"]);
|
|
1213
|
+
var githubIssueStateReasonSchema = z5.enum([
|
|
1214
|
+
"completed",
|
|
1215
|
+
"duplicate",
|
|
1216
|
+
"not_planned",
|
|
1217
|
+
"reopened"
|
|
1218
|
+
]);
|
|
1219
|
+
var juniorGitHubIssues = pgTable(
|
|
1220
|
+
"junior_github_issues",
|
|
1221
|
+
{
|
|
1222
|
+
issueId: text("issue_id").primaryKey(),
|
|
1223
|
+
repositoryId: text("repository_id").notNull(),
|
|
1224
|
+
repositoryFullName: text("repository_full_name").notNull(),
|
|
1225
|
+
number: integer("number").notNull(),
|
|
1226
|
+
state: text("state").$type().notNull(),
|
|
1227
|
+
stateReason: text("state_reason").$type(),
|
|
1228
|
+
conversationIds: text("conversation_ids").array().notNull().default(sql`ARRAY[]::text[]`),
|
|
1229
|
+
openedAt: timestamp("opened_at", { withTimezone: true }).notNull(),
|
|
1230
|
+
closedAt: timestamp("closed_at", { withTimezone: true }),
|
|
1231
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
1232
|
+
},
|
|
1233
|
+
(table2) => [
|
|
1234
|
+
index("junior_github_issues_opened_at_idx").on(table2.openedAt),
|
|
1235
|
+
index("junior_github_issues_closed_at_idx").on(table2.closedAt),
|
|
1236
|
+
index("junior_github_issues_open_idx").on(table2.issueId).where(sql`${table2.state} = 'open'`)
|
|
1237
|
+
]
|
|
1238
|
+
);
|
|
1239
|
+
var juniorGitHubPullRequests = pgTable(
|
|
1240
|
+
"junior_github_pull_requests",
|
|
1241
|
+
{
|
|
1242
|
+
pullRequestId: text("pull_request_id").primaryKey(),
|
|
1243
|
+
repositoryId: text("repository_id").notNull(),
|
|
1244
|
+
repositoryFullName: text("repository_full_name").notNull(),
|
|
1245
|
+
number: integer("number").notNull(),
|
|
1246
|
+
state: text("state").$type().notNull(),
|
|
1247
|
+
commitComposition: text("commit_composition").$type(),
|
|
1248
|
+
conversationIds: text("conversation_ids").array().notNull().default(sql`ARRAY[]::text[]`),
|
|
1249
|
+
openedAt: timestamp("opened_at", { withTimezone: true }).notNull(),
|
|
1250
|
+
mergedAt: timestamp("merged_at", { withTimezone: true }),
|
|
1251
|
+
closedAt: timestamp("closed_at", { withTimezone: true }),
|
|
1252
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
1253
|
+
},
|
|
1254
|
+
(table2) => [
|
|
1255
|
+
index("junior_github_pull_requests_opened_at_idx").on(table2.openedAt),
|
|
1256
|
+
index("junior_github_pull_requests_merged_at_idx").on(table2.mergedAt),
|
|
1257
|
+
index("junior_github_pull_requests_closed_at_idx").on(table2.closedAt),
|
|
1258
|
+
index("junior_github_pull_requests_open_idx").on(table2.pullRequestId).where(sql`${table2.state} = 'open'`),
|
|
1259
|
+
index("junior_github_pull_requests_unmerged_conversations_idx").using("gin", table2.conversationIds).where(sql`${table2.state} <> 'merged'`)
|
|
1260
|
+
]
|
|
1261
|
+
);
|
|
1262
|
+
var juniorGitHubPullRequestIssues = pgTable(
|
|
1263
|
+
"junior_github_pull_request_issues",
|
|
1264
|
+
{
|
|
1265
|
+
pullRequestId: text("pull_request_id").notNull().references(() => juniorGitHubPullRequests.pullRequestId, {
|
|
1266
|
+
onDelete: "cascade"
|
|
1267
|
+
}),
|
|
1268
|
+
issueRepositoryFullName: text("issue_repository_full_name").notNull(),
|
|
1269
|
+
issueNumber: integer("issue_number").notNull()
|
|
1270
|
+
},
|
|
1271
|
+
(table2) => [
|
|
1272
|
+
primaryKey({
|
|
1273
|
+
columns: [
|
|
1274
|
+
table2.pullRequestId,
|
|
1275
|
+
table2.issueRepositoryFullName,
|
|
1276
|
+
table2.issueNumber
|
|
1277
|
+
]
|
|
1278
|
+
})
|
|
1279
|
+
]
|
|
1280
|
+
);
|
|
1281
|
+
var juniorGitHubPullRequestRequesters = pgTable(
|
|
1282
|
+
"junior_github_pull_request_requesters",
|
|
1283
|
+
{
|
|
1284
|
+
/** Lowercase `owner/name`. */
|
|
1285
|
+
repositoryFullName: text("repository_full_name").notNull(),
|
|
1286
|
+
number: integer("number").notNull(),
|
|
1287
|
+
/** Core `junior_identities.id` of the person who acted. */
|
|
1288
|
+
identityId: text("identity_id").notNull(),
|
|
1289
|
+
createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
|
|
1290
|
+
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
1291
|
+
},
|
|
1292
|
+
(table2) => [
|
|
1293
|
+
primaryKey({
|
|
1294
|
+
columns: [table2.repositoryFullName, table2.number, table2.identityId]
|
|
1295
|
+
})
|
|
1296
|
+
]
|
|
1297
|
+
);
|
|
1298
|
+
|
|
1299
|
+
// src/pull-request-requesters/store.ts
|
|
1300
|
+
var table = juniorGitHubPullRequestRequesters;
|
|
1301
|
+
async function recordGitHubPullRequestOpener(db, input) {
|
|
1302
|
+
const repositoryFullName = input.repositoryFullName.toLowerCase();
|
|
1303
|
+
await db.insert(table).values({
|
|
1304
|
+
createdAt: input.createdAt,
|
|
1305
|
+
identityId: input.identityId,
|
|
1306
|
+
number: input.number,
|
|
1307
|
+
repositoryFullName,
|
|
1308
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
1309
|
+
}).onConflictDoUpdate({
|
|
1310
|
+
target: [table.repositoryFullName, table.number, table.identityId],
|
|
1311
|
+
set: { createdAt: input.createdAt }
|
|
1312
|
+
});
|
|
1313
|
+
await db.delete(table).where(
|
|
1314
|
+
and(
|
|
1315
|
+
eq(table.repositoryFullName, repositoryFullName),
|
|
1316
|
+
eq(table.number, input.number),
|
|
1317
|
+
lt(table.createdAt, input.createdAt)
|
|
1318
|
+
)
|
|
1319
|
+
);
|
|
1320
|
+
}
|
|
1321
|
+
async function recordGitHubPullRequestRequester(db, input) {
|
|
1322
|
+
const now = /* @__PURE__ */ new Date();
|
|
1323
|
+
await db.insert(table).values({
|
|
1324
|
+
createdAt: now,
|
|
1325
|
+
identityId: input.identityId,
|
|
1326
|
+
number: input.number,
|
|
1327
|
+
repositoryFullName: input.repositoryFullName.toLowerCase(),
|
|
1328
|
+
updatedAt: now
|
|
1329
|
+
}).onConflictDoUpdate({
|
|
1330
|
+
target: [table.repositoryFullName, table.number, table.identityId],
|
|
1331
|
+
set: { updatedAt: now }
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
async function listGitHubPullRequestOpeners(db, input) {
|
|
1335
|
+
const openers = /* @__PURE__ */ new Map();
|
|
1336
|
+
if (input.numbers.length === 0) return openers;
|
|
1337
|
+
const rows = await db.select().from(table).where(
|
|
1338
|
+
and(
|
|
1339
|
+
eq(table.repositoryFullName, input.repositoryFullName.toLowerCase()),
|
|
1340
|
+
inArray(table.number, [...new Set(input.numbers)])
|
|
1341
|
+
)
|
|
1342
|
+
).orderBy(asc(table.createdAt));
|
|
1343
|
+
for (const row of rows) {
|
|
1344
|
+
if (!openers.has(row.number)) openers.set(row.number, row.identityId);
|
|
1345
|
+
}
|
|
1346
|
+
return openers;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
// src/tools/create-pull-request.ts
|
|
1176
1350
|
var GITHUB_PULL_REQUEST_CREATE_IDEMPOTENCY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
1177
1351
|
var GITHUB_PULL_REQUEST_CREATE_LOCK_TTL_MS = 6e4;
|
|
1178
1352
|
var GitHubPullRequestCreateRejectedError = class extends Error {
|
|
@@ -1210,15 +1384,15 @@ var createPullRequestInputSchema = Type2.Object(
|
|
|
1210
1384
|
},
|
|
1211
1385
|
{ additionalProperties: false }
|
|
1212
1386
|
);
|
|
1213
|
-
var createPullRequestToolInputSchema =
|
|
1214
|
-
repo:
|
|
1215
|
-
title:
|
|
1216
|
-
head:
|
|
1217
|
-
base:
|
|
1218
|
-
body:
|
|
1387
|
+
var createPullRequestToolInputSchema = z6.object({
|
|
1388
|
+
repo: z6.string().describe('Repository in "owner/name" format.'),
|
|
1389
|
+
title: z6.string().describe("Pull request title."),
|
|
1390
|
+
head: z6.string().describe("Head branch or owner:branch ref."),
|
|
1391
|
+
base: z6.string().describe("Base branch."),
|
|
1392
|
+
body: z6.string().describe(
|
|
1219
1393
|
"Pull request body. The runtime appends the conversation footer."
|
|
1220
1394
|
).optional(),
|
|
1221
|
-
draft:
|
|
1395
|
+
draft: z6.boolean().describe("Whether to open the pull request as a draft.").optional()
|
|
1222
1396
|
}).strict();
|
|
1223
1397
|
var createPullRequestStateSchema = Type2.Union([
|
|
1224
1398
|
Type2.Object(
|
|
@@ -1243,15 +1417,15 @@ var createPullRequestStateSchema = Type2.Union([
|
|
|
1243
1417
|
{ additionalProperties: false }
|
|
1244
1418
|
)
|
|
1245
1419
|
]);
|
|
1246
|
-
var gitHubPullRequestDataSchema =
|
|
1247
|
-
number:
|
|
1248
|
-
url:
|
|
1420
|
+
var gitHubPullRequestDataSchema = z6.object({
|
|
1421
|
+
number: z6.number(),
|
|
1422
|
+
url: z6.string(),
|
|
1249
1423
|
subscribable: subscribableResourceSchema3.optional(),
|
|
1250
1424
|
subscription: watchResultSchema.optional()
|
|
1251
1425
|
});
|
|
1252
1426
|
var gitHubPullRequestOutputSchema = pluginToolOutputSchema4.merge(
|
|
1253
1427
|
gitHubPullRequestDataSchema.extend({
|
|
1254
|
-
target:
|
|
1428
|
+
target: z6.literal("createPullRequest")
|
|
1255
1429
|
})
|
|
1256
1430
|
);
|
|
1257
1431
|
function parseCreatePullRequestInput(input) {
|
|
@@ -1343,14 +1517,14 @@ function isDefinitiveGitHubPullRequestCreateRejection(error) {
|
|
|
1343
1517
|
}
|
|
1344
1518
|
return [400, 401, 404, 410, 422].includes(error.status);
|
|
1345
1519
|
}
|
|
1346
|
-
|
|
1520
|
+
function createGitHubPullRequestRequest(conversationId, input, ctx, requester, dashboardUrl) {
|
|
1347
1521
|
const repo = parseRepo4(input.repo);
|
|
1348
1522
|
const payload = {
|
|
1349
1523
|
title: nonEmptyString3(input.title, "title"),
|
|
1350
1524
|
head: nonEmptyString3(input.head, "head"),
|
|
1351
1525
|
base: nonEmptyString3(input.base, "base"),
|
|
1352
1526
|
body: appendGitHubFooter(
|
|
1353
|
-
|
|
1527
|
+
appendGitHubRequesterAttribution(input.body ?? "", ctx, requester),
|
|
1354
1528
|
conversationId,
|
|
1355
1529
|
dashboardUrl
|
|
1356
1530
|
),
|
|
@@ -1403,12 +1577,20 @@ async function createGitHubPullRequest(ctx, request) {
|
|
|
1403
1577
|
url: pullRequest.html_url
|
|
1404
1578
|
};
|
|
1405
1579
|
}
|
|
1406
|
-
async function
|
|
1407
|
-
if (!
|
|
1580
|
+
async function recordOpener(ctx, input, state, identityId) {
|
|
1581
|
+
if (!identityId) return;
|
|
1582
|
+
const repo = parseRepo4(input.repo);
|
|
1583
|
+
await recordGitHubPullRequestOpener(ctx.db, {
|
|
1584
|
+
createdAt: new Date(state.createdAtMs),
|
|
1585
|
+
identityId,
|
|
1586
|
+
number: state.number,
|
|
1587
|
+
repositoryFullName: `${repo.owner}/${repo.name}`
|
|
1588
|
+
});
|
|
1589
|
+
}
|
|
1590
|
+
async function assignPullRequestRequester(ctx, input, result, requester) {
|
|
1591
|
+
const assignee = linkedGitHubLogin(requester?.user);
|
|
1592
|
+
if (!assignee) return;
|
|
1408
1593
|
try {
|
|
1409
|
-
const requester = await ctx.users.resolveActor();
|
|
1410
|
-
const assignee = linkedGitHubLogin(requester?.user);
|
|
1411
|
-
if (!assignee) return;
|
|
1412
1594
|
const repo = parseRepo4(input.repo);
|
|
1413
1595
|
const response = await ctx.egress.fetch({
|
|
1414
1596
|
provider: "github",
|
|
@@ -1443,11 +1625,12 @@ async function assignPullRequestRequester(ctx, input, result) {
|
|
|
1443
1625
|
}
|
|
1444
1626
|
function gitHubPullRequestToolResult(input, result, canSubscribe, omitSuggestedEvents) {
|
|
1445
1627
|
const repo = parseRepo4(input.repo);
|
|
1446
|
-
const subscribable =
|
|
1628
|
+
const subscribable = gitHubPullRequestSubscribable({
|
|
1629
|
+
canSubscribe,
|
|
1447
1630
|
number: result.number,
|
|
1448
1631
|
repo: `${repo.owner}/${repo.name}`,
|
|
1449
1632
|
...omitSuggestedEvents ? { omitSuggestedEvents } : void 0
|
|
1450
|
-
})
|
|
1633
|
+
});
|
|
1451
1634
|
return {
|
|
1452
1635
|
number: result.number,
|
|
1453
1636
|
url: result.url,
|
|
@@ -1538,6 +1721,12 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
1538
1721
|
const state = createPullRequestState(await ctx.state.get(key));
|
|
1539
1722
|
if (state?.status === "completed") {
|
|
1540
1723
|
const completedInput = state.input ?? parsedInput;
|
|
1724
|
+
await recordOpener(
|
|
1725
|
+
ctx,
|
|
1726
|
+
completedInput,
|
|
1727
|
+
state,
|
|
1728
|
+
(await resolveGitHubRequester(ctx))?.identity?.id
|
|
1729
|
+
);
|
|
1541
1730
|
const completedResult = {
|
|
1542
1731
|
facts: state.facts === void 0 ? void 0 : objectFactsSchema2.parse(state.facts),
|
|
1543
1732
|
sourceUpdatedAt: state.sourceUpdatedAt,
|
|
@@ -1557,10 +1746,13 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
1557
1746
|
"GitHub pull request creation for this tool call has an uncertain pending result; refusing to create a duplicate pull request."
|
|
1558
1747
|
);
|
|
1559
1748
|
}
|
|
1560
|
-
const
|
|
1749
|
+
const requester = await resolveGitHubRequester(ctx);
|
|
1750
|
+
const identityId = requester?.identity?.id;
|
|
1751
|
+
const request = createGitHubPullRequestRequest(
|
|
1561
1752
|
conversationId,
|
|
1562
1753
|
parsedInput,
|
|
1563
1754
|
ctx,
|
|
1755
|
+
requester,
|
|
1564
1756
|
ctx.slack?.conversationLink?.url
|
|
1565
1757
|
);
|
|
1566
1758
|
const pendingState = {
|
|
@@ -1599,7 +1791,8 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
1599
1791
|
{ cause: error }
|
|
1600
1792
|
);
|
|
1601
1793
|
}
|
|
1602
|
-
await
|
|
1794
|
+
await recordOpener(ctx, parsedInput, completedState, identityId);
|
|
1795
|
+
await assignPullRequestRequester(ctx, parsedInput, result, requester);
|
|
1603
1796
|
return await gitHubPullRequestStructuredResult(
|
|
1604
1797
|
ctx,
|
|
1605
1798
|
parsedInput,
|
|
@@ -1618,28 +1811,28 @@ import {
|
|
|
1618
1811
|
PluginToolInputError as PluginToolInputError6,
|
|
1619
1812
|
pluginToolOutputSchema as pluginToolOutputSchema5
|
|
1620
1813
|
} from "@sentry/junior-plugin-api";
|
|
1621
|
-
import { z as
|
|
1814
|
+
import { z as z7 } from "zod";
|
|
1622
1815
|
import { subscribableResourceSchema as subscribableResourceSchema4 } from "@sentry/junior-plugin-api";
|
|
1623
|
-
var commitShaSchema2 =
|
|
1624
|
-
var inputSchema3 =
|
|
1625
|
-
repo:
|
|
1626
|
-
number:
|
|
1816
|
+
var commitShaSchema2 = z7.string().regex(/^[0-9a-f]{40}$/i);
|
|
1817
|
+
var inputSchema3 = z7.object({
|
|
1818
|
+
repo: z7.string().describe('Repository in "owner/name" format.'),
|
|
1819
|
+
number: z7.number().int().positive().describe("Pull request number.")
|
|
1627
1820
|
}).strict();
|
|
1628
|
-
var pullRequestSchema =
|
|
1629
|
-
base:
|
|
1630
|
-
draft:
|
|
1631
|
-
head:
|
|
1821
|
+
var pullRequestSchema = z7.object({
|
|
1822
|
+
base: z7.string(),
|
|
1823
|
+
draft: z7.boolean(),
|
|
1824
|
+
head: z7.string(),
|
|
1632
1825
|
headSha: commitShaSchema2,
|
|
1633
|
-
merged:
|
|
1634
|
-
number:
|
|
1635
|
-
state:
|
|
1826
|
+
merged: z7.boolean(),
|
|
1827
|
+
number: z7.number(),
|
|
1828
|
+
state: z7.string(),
|
|
1636
1829
|
subscribable: subscribableResourceSchema4.optional(),
|
|
1637
|
-
title:
|
|
1638
|
-
url:
|
|
1830
|
+
title: z7.string(),
|
|
1831
|
+
url: z7.string()
|
|
1639
1832
|
});
|
|
1640
1833
|
var outputSchema3 = pluginToolOutputSchema5.merge(
|
|
1641
1834
|
pullRequestSchema.extend({
|
|
1642
|
-
target:
|
|
1835
|
+
target: z7.literal("getPullRequest")
|
|
1643
1836
|
})
|
|
1644
1837
|
);
|
|
1645
1838
|
function parseRepo5(value) {
|
|
@@ -1692,20 +1885,21 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
1692
1885
|
}
|
|
1693
1886
|
throw new Error(message);
|
|
1694
1887
|
}
|
|
1695
|
-
const providerResult =
|
|
1696
|
-
base:
|
|
1697
|
-
draft:
|
|
1698
|
-
head:
|
|
1699
|
-
html_url:
|
|
1700
|
-
merged:
|
|
1701
|
-
number:
|
|
1702
|
-
state:
|
|
1703
|
-
title:
|
|
1888
|
+
const providerResult = z7.object({
|
|
1889
|
+
base: z7.object({ ref: z7.string() }),
|
|
1890
|
+
draft: z7.boolean(),
|
|
1891
|
+
head: z7.object({ ref: z7.string(), sha: commitShaSchema2 }),
|
|
1892
|
+
html_url: z7.string(),
|
|
1893
|
+
merged: z7.boolean().optional().default(false),
|
|
1894
|
+
number: z7.number(),
|
|
1895
|
+
state: z7.string(),
|
|
1896
|
+
title: z7.string()
|
|
1704
1897
|
}).parse(parsed);
|
|
1705
|
-
const subscribable =
|
|
1898
|
+
const subscribable = gitHubPullRequestSubscribable({
|
|
1899
|
+
canSubscribe: ctx.events.canSubscribe,
|
|
1706
1900
|
number: providerResult.number,
|
|
1707
1901
|
repo: repo.ref
|
|
1708
|
-
})
|
|
1902
|
+
});
|
|
1709
1903
|
const data = {
|
|
1710
1904
|
base: providerResult.base.ref,
|
|
1711
1905
|
draft: providerResult.draft,
|
|
@@ -1744,45 +1938,45 @@ import {
|
|
|
1744
1938
|
pluginToolOutputSchema as pluginToolOutputSchema6,
|
|
1745
1939
|
subscribableResourceSchema as subscribableResourceSchema5
|
|
1746
1940
|
} from "@sentry/junior-plugin-api";
|
|
1747
|
-
import { z as
|
|
1748
|
-
var inputSchema4 =
|
|
1749
|
-
repo:
|
|
1750
|
-
tag:
|
|
1941
|
+
import { z as z8 } from "zod";
|
|
1942
|
+
var inputSchema4 = z8.object({
|
|
1943
|
+
repo: z8.string().describe('Repository in "owner/name" format.'),
|
|
1944
|
+
tag: z8.string().trim().min(1).describe(
|
|
1751
1945
|
"Optional release tag name. Omit to inspect and watch every published release in the repository."
|
|
1752
1946
|
).optional()
|
|
1753
1947
|
}).strict();
|
|
1754
|
-
var releaseSchema =
|
|
1755
|
-
createdAt:
|
|
1756
|
-
draft:
|
|
1757
|
-
htmlUrl:
|
|
1758
|
-
id:
|
|
1759
|
-
name:
|
|
1760
|
-
prerelease:
|
|
1761
|
-
publishedAt:
|
|
1762
|
-
tagName:
|
|
1763
|
-
targetCommitish:
|
|
1948
|
+
var releaseSchema = z8.object({
|
|
1949
|
+
createdAt: z8.string(),
|
|
1950
|
+
draft: z8.boolean(),
|
|
1951
|
+
htmlUrl: z8.string(),
|
|
1952
|
+
id: z8.number(),
|
|
1953
|
+
name: z8.string().nullable(),
|
|
1954
|
+
prerelease: z8.boolean(),
|
|
1955
|
+
publishedAt: z8.string().nullable(),
|
|
1956
|
+
tagName: z8.string(),
|
|
1957
|
+
targetCommitish: z8.string()
|
|
1764
1958
|
}).strict();
|
|
1765
|
-
var releaseSourceSchema =
|
|
1959
|
+
var releaseSourceSchema = z8.object({
|
|
1766
1960
|
release: releaseSchema.nullable(),
|
|
1767
|
-
repo:
|
|
1961
|
+
repo: z8.string(),
|
|
1768
1962
|
subscribable: subscribableResourceSchema5.optional(),
|
|
1769
|
-
tag:
|
|
1963
|
+
tag: z8.string().nullable()
|
|
1770
1964
|
}).strict();
|
|
1771
1965
|
var outputSchema4 = pluginToolOutputSchema6.merge(
|
|
1772
1966
|
releaseSourceSchema.extend({
|
|
1773
|
-
target:
|
|
1967
|
+
target: z8.literal("getRelease")
|
|
1774
1968
|
})
|
|
1775
1969
|
);
|
|
1776
|
-
var providerReleaseSchema =
|
|
1777
|
-
created_at:
|
|
1778
|
-
draft:
|
|
1779
|
-
html_url:
|
|
1780
|
-
id:
|
|
1781
|
-
name:
|
|
1782
|
-
prerelease:
|
|
1783
|
-
published_at:
|
|
1784
|
-
tag_name:
|
|
1785
|
-
target_commitish:
|
|
1970
|
+
var providerReleaseSchema = z8.object({
|
|
1971
|
+
created_at: z8.string(),
|
|
1972
|
+
draft: z8.boolean(),
|
|
1973
|
+
html_url: z8.string(),
|
|
1974
|
+
id: z8.number(),
|
|
1975
|
+
name: z8.string().nullable(),
|
|
1976
|
+
prerelease: z8.boolean(),
|
|
1977
|
+
published_at: z8.string().nullable(),
|
|
1978
|
+
tag_name: z8.string(),
|
|
1979
|
+
target_commitish: z8.string()
|
|
1786
1980
|
}).passthrough();
|
|
1787
1981
|
function parseRepo6(value) {
|
|
1788
1982
|
const parts = value.split("/").map((part) => part.trim());
|
|
@@ -1875,10 +2069,11 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
1875
2069
|
);
|
|
1876
2070
|
}
|
|
1877
2071
|
}
|
|
1878
|
-
const subscribable =
|
|
2072
|
+
const subscribable = gitHubReleaseSourceSubscribable({
|
|
2073
|
+
canSubscribe: ctx.events.canSubscribe,
|
|
1879
2074
|
repo: repo.ref,
|
|
1880
2075
|
tag
|
|
1881
|
-
})
|
|
2076
|
+
});
|
|
1882
2077
|
const data = {
|
|
1883
2078
|
release,
|
|
1884
2079
|
repo: repo.ref,
|
|
@@ -1900,21 +2095,21 @@ import {
|
|
|
1900
2095
|
pluginToolOutputSchema as pluginToolOutputSchema7,
|
|
1901
2096
|
subscribableResourceSchema as subscribableResourceSchema6
|
|
1902
2097
|
} from "@sentry/junior-plugin-api";
|
|
1903
|
-
import { z as
|
|
1904
|
-
var inputSchema5 =
|
|
1905
|
-
repo:
|
|
2098
|
+
import { z as z9 } from "zod";
|
|
2099
|
+
var inputSchema5 = z9.object({
|
|
2100
|
+
repo: z9.string().describe('Repository in "owner/name" format.')
|
|
1906
2101
|
}).strict();
|
|
1907
|
-
var repositorySchema =
|
|
1908
|
-
defaultBranch:
|
|
1909
|
-
description:
|
|
1910
|
-
fullName:
|
|
1911
|
-
private:
|
|
2102
|
+
var repositorySchema = z9.object({
|
|
2103
|
+
defaultBranch: z9.string(),
|
|
2104
|
+
description: z9.string().nullable(),
|
|
2105
|
+
fullName: z9.string(),
|
|
2106
|
+
private: z9.boolean(),
|
|
1912
2107
|
subscribable: subscribableResourceSchema6.optional(),
|
|
1913
|
-
url:
|
|
2108
|
+
url: z9.string()
|
|
1914
2109
|
});
|
|
1915
2110
|
var outputSchema5 = pluginToolOutputSchema7.merge(
|
|
1916
2111
|
repositorySchema.extend({
|
|
1917
|
-
target:
|
|
2112
|
+
target: z9.literal("getRepository")
|
|
1918
2113
|
})
|
|
1919
2114
|
);
|
|
1920
2115
|
function parseRepo7(value) {
|
|
@@ -1965,16 +2160,17 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
1965
2160
|
`GitHub repository lookup failed with HTTP ${response.status}`
|
|
1966
2161
|
);
|
|
1967
2162
|
}
|
|
1968
|
-
const providerResult =
|
|
1969
|
-
default_branch:
|
|
1970
|
-
description:
|
|
1971
|
-
full_name:
|
|
1972
|
-
html_url:
|
|
1973
|
-
private:
|
|
2163
|
+
const providerResult = z9.object({
|
|
2164
|
+
default_branch: z9.string(),
|
|
2165
|
+
description: z9.string().nullable(),
|
|
2166
|
+
full_name: z9.string(),
|
|
2167
|
+
html_url: z9.string(),
|
|
2168
|
+
private: z9.boolean()
|
|
1974
2169
|
}).parse(parsed);
|
|
1975
|
-
const subscribable =
|
|
2170
|
+
const subscribable = gitHubRepositorySubscribable({
|
|
2171
|
+
canSubscribe: ctx.events.canSubscribe,
|
|
1976
2172
|
repo: providerResult.full_name
|
|
1977
|
-
})
|
|
2173
|
+
});
|
|
1978
2174
|
const data = {
|
|
1979
2175
|
defaultBranch: providerResult.default_branch,
|
|
1980
2176
|
description: providerResult.description,
|
|
@@ -1998,30 +2194,30 @@ import {
|
|
|
1998
2194
|
pluginToolOutputSchema as pluginToolOutputSchema8,
|
|
1999
2195
|
subscribableResourceSchema as subscribableResourceSchema7
|
|
2000
2196
|
} from "@sentry/junior-plugin-api";
|
|
2001
|
-
import { z as
|
|
2002
|
-
var inputSchema6 =
|
|
2003
|
-
repo:
|
|
2004
|
-
number:
|
|
2005
|
-
title:
|
|
2006
|
-
body:
|
|
2197
|
+
import { z as z10 } from "zod";
|
|
2198
|
+
var inputSchema6 = z10.object({
|
|
2199
|
+
repo: z10.string().describe('Repository in "owner/name" format.'),
|
|
2200
|
+
number: z10.number().int().positive().describe("Issue number."),
|
|
2201
|
+
title: z10.string().trim().min(1).optional().describe("Replacement issue title."),
|
|
2202
|
+
body: z10.string().optional().describe(
|
|
2007
2203
|
"Replacement issue body. The runtime appends requester attribution and the conversation footer."
|
|
2008
2204
|
),
|
|
2009
|
-
state:
|
|
2205
|
+
state: z10.enum(["open", "closed"]).optional().describe("Replacement issue state.")
|
|
2010
2206
|
}).strict().refine(
|
|
2011
2207
|
({ title, body, state }) => title !== void 0 || body !== void 0 || state !== void 0,
|
|
2012
2208
|
{ message: "At least one issue field must be provided." }
|
|
2013
2209
|
);
|
|
2014
|
-
var issueSchema =
|
|
2015
|
-
body:
|
|
2016
|
-
number:
|
|
2017
|
-
state:
|
|
2210
|
+
var issueSchema = z10.object({
|
|
2211
|
+
body: z10.string().nullable(),
|
|
2212
|
+
number: z10.number(),
|
|
2213
|
+
state: z10.string(),
|
|
2018
2214
|
subscribable: subscribableResourceSchema7.optional(),
|
|
2019
|
-
title:
|
|
2020
|
-
url:
|
|
2215
|
+
title: z10.string(),
|
|
2216
|
+
url: z10.string()
|
|
2021
2217
|
});
|
|
2022
2218
|
var outputSchema6 = pluginToolOutputSchema8.merge(
|
|
2023
2219
|
issueSchema.extend({
|
|
2024
|
-
target:
|
|
2220
|
+
target: z10.literal("updateIssue")
|
|
2025
2221
|
})
|
|
2026
2222
|
);
|
|
2027
2223
|
function nonEmptyString4(value, name) {
|
|
@@ -2076,7 +2272,11 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2076
2272
|
...update.title !== void 0 ? { title: update.title } : void 0,
|
|
2077
2273
|
...update.body !== void 0 ? {
|
|
2078
2274
|
body: appendGitHubFooter(
|
|
2079
|
-
|
|
2275
|
+
appendGitHubRequesterAttribution(
|
|
2276
|
+
update.body,
|
|
2277
|
+
ctx,
|
|
2278
|
+
await resolveGitHubRequester(ctx)
|
|
2279
|
+
),
|
|
2080
2280
|
nonEmptyString4(ctx.conversationId, "conversationId"),
|
|
2081
2281
|
ctx.slack?.conversationLink?.url
|
|
2082
2282
|
)
|
|
@@ -2105,17 +2305,18 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2105
2305
|
`GitHub issue update failed with HTTP ${response.status}: ${githubApiErrorMessage3(parsed)}`
|
|
2106
2306
|
);
|
|
2107
2307
|
}
|
|
2108
|
-
const providerResult =
|
|
2109
|
-
body:
|
|
2110
|
-
html_url:
|
|
2111
|
-
number:
|
|
2112
|
-
state:
|
|
2113
|
-
title:
|
|
2308
|
+
const providerResult = z10.object({
|
|
2309
|
+
body: z10.string().nullable().optional().default(null),
|
|
2310
|
+
html_url: z10.string(),
|
|
2311
|
+
number: z10.number(),
|
|
2312
|
+
state: z10.string(),
|
|
2313
|
+
title: z10.string()
|
|
2114
2314
|
}).parse(parsed);
|
|
2115
|
-
const subscribable =
|
|
2315
|
+
const subscribable = gitHubIssueSubscribable({
|
|
2316
|
+
canSubscribe: ctx.events.canSubscribe,
|
|
2116
2317
|
number: providerResult.number,
|
|
2117
2318
|
repo: repo.ref
|
|
2118
|
-
})
|
|
2319
|
+
});
|
|
2119
2320
|
return {
|
|
2120
2321
|
objectAnnotations: [
|
|
2121
2322
|
githubObjectAnnotation({
|
|
@@ -2146,18 +2347,18 @@ import {
|
|
|
2146
2347
|
PluginToolInputError as PluginToolInputError10,
|
|
2147
2348
|
pluginToolOutputSchema as pluginToolOutputSchema9
|
|
2148
2349
|
} from "@sentry/junior-plugin-api";
|
|
2149
|
-
import { z as
|
|
2350
|
+
import { z as z11 } from "zod";
|
|
2150
2351
|
import { subscribableResourceSchema as subscribableResourceSchema8 } from "@sentry/junior-plugin-api";
|
|
2151
|
-
var inputSchema7 =
|
|
2152
|
-
repo:
|
|
2153
|
-
number:
|
|
2154
|
-
title:
|
|
2155
|
-
body:
|
|
2352
|
+
var inputSchema7 = z11.object({
|
|
2353
|
+
repo: z11.string().describe('Repository in "owner/name" format.'),
|
|
2354
|
+
number: z11.number().int().positive().describe("Pull request number."),
|
|
2355
|
+
title: z11.string().trim().min(1).optional().describe("Replacement pull request title."),
|
|
2356
|
+
body: z11.string().optional().describe(
|
|
2156
2357
|
"Replacement pull request body. The runtime appends requester attribution and the conversation footer."
|
|
2157
2358
|
),
|
|
2158
|
-
base:
|
|
2159
|
-
state:
|
|
2160
|
-
draft:
|
|
2359
|
+
base: z11.string().trim().min(1).optional().describe("Replacement base branch."),
|
|
2360
|
+
state: z11.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
|
|
2361
|
+
draft: z11.boolean().optional().describe(
|
|
2161
2362
|
"Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
|
|
2162
2363
|
)
|
|
2163
2364
|
}).strict().refine(
|
|
@@ -2172,27 +2373,27 @@ var CONVERT_TO_DRAFT = {
|
|
|
2172
2373
|
operationName: "ConvertPullRequestToDraft",
|
|
2173
2374
|
query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
|
|
2174
2375
|
};
|
|
2175
|
-
var draftMutationResponseSchema =
|
|
2176
|
-
data:
|
|
2177
|
-
result:
|
|
2376
|
+
var draftMutationResponseSchema = z11.object({
|
|
2377
|
+
data: z11.object({
|
|
2378
|
+
result: z11.object({ pullRequest: z11.object({ isDraft: z11.boolean() }) })
|
|
2178
2379
|
})
|
|
2179
2380
|
});
|
|
2180
|
-
var graphqlErrorsSchema =
|
|
2181
|
-
errors:
|
|
2381
|
+
var graphqlErrorsSchema = z11.object({
|
|
2382
|
+
errors: z11.array(z11.object({ message: z11.string() })).min(1)
|
|
2182
2383
|
});
|
|
2183
|
-
var pullRequestSchema2 =
|
|
2184
|
-
base:
|
|
2185
|
-
body:
|
|
2186
|
-
draft:
|
|
2187
|
-
number:
|
|
2188
|
-
state:
|
|
2384
|
+
var pullRequestSchema2 = z11.object({
|
|
2385
|
+
base: z11.string(),
|
|
2386
|
+
body: z11.string().nullable(),
|
|
2387
|
+
draft: z11.boolean(),
|
|
2388
|
+
number: z11.number(),
|
|
2389
|
+
state: z11.string(),
|
|
2189
2390
|
subscribable: subscribableResourceSchema8.optional(),
|
|
2190
|
-
title:
|
|
2191
|
-
url:
|
|
2391
|
+
title: z11.string(),
|
|
2392
|
+
url: z11.string()
|
|
2192
2393
|
});
|
|
2193
2394
|
var outputSchema7 = pluginToolOutputSchema9.merge(
|
|
2194
2395
|
pullRequestSchema2.extend({
|
|
2195
|
-
target:
|
|
2396
|
+
target: z11.literal("updatePullRequest")
|
|
2196
2397
|
})
|
|
2197
2398
|
);
|
|
2198
2399
|
function nonEmptyString5(value, name) {
|
|
@@ -2274,11 +2475,12 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2274
2475
|
}
|
|
2275
2476
|
const update = parsedInput.data;
|
|
2276
2477
|
const repo = parseRepo9(update.repo);
|
|
2478
|
+
const requester = await resolveGitHubRequester(ctx);
|
|
2277
2479
|
const payload = {
|
|
2278
2480
|
...update.title !== void 0 ? { title: update.title } : void 0,
|
|
2279
2481
|
...update.body !== void 0 ? {
|
|
2280
2482
|
body: appendGitHubFooter(
|
|
2281
|
-
|
|
2483
|
+
appendGitHubRequesterAttribution(update.body, ctx, requester),
|
|
2282
2484
|
nonEmptyString5(ctx.conversationId, "conversationId"),
|
|
2283
2485
|
ctx.slack?.conversationLink?.url
|
|
2284
2486
|
)
|
|
@@ -2307,16 +2509,16 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2307
2509
|
`GitHub pull request update failed with HTTP ${response.status}: ${githubApiErrorMessage4(parsed)}`
|
|
2308
2510
|
);
|
|
2309
2511
|
}
|
|
2310
|
-
const providerResult =
|
|
2311
|
-
base:
|
|
2312
|
-
body:
|
|
2313
|
-
draft:
|
|
2314
|
-
html_url:
|
|
2315
|
-
merged:
|
|
2316
|
-
node_id:
|
|
2317
|
-
number:
|
|
2318
|
-
state:
|
|
2319
|
-
title:
|
|
2512
|
+
const providerResult = z11.object({
|
|
2513
|
+
base: z11.object({ ref: z11.string() }),
|
|
2514
|
+
body: z11.string().nullable().optional().default(null),
|
|
2515
|
+
draft: z11.boolean(),
|
|
2516
|
+
html_url: z11.string(),
|
|
2517
|
+
merged: z11.boolean(),
|
|
2518
|
+
node_id: z11.string().optional(),
|
|
2519
|
+
number: z11.number(),
|
|
2520
|
+
state: z11.string(),
|
|
2521
|
+
title: z11.string()
|
|
2320
2522
|
}).parse(parsed);
|
|
2321
2523
|
if (update.draft !== void 0 && update.draft !== providerResult.draft) {
|
|
2322
2524
|
if (!providerResult.node_id) {
|
|
@@ -2331,10 +2533,18 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2331
2533
|
repo: repo.ref
|
|
2332
2534
|
});
|
|
2333
2535
|
}
|
|
2334
|
-
|
|
2536
|
+
if (requester?.identity) {
|
|
2537
|
+
await recordGitHubPullRequestRequester(ctx.db, {
|
|
2538
|
+
identityId: requester.identity.id,
|
|
2539
|
+
number: providerResult.number,
|
|
2540
|
+
repositoryFullName: repo.ref
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
const subscribable = gitHubPullRequestSubscribable({
|
|
2544
|
+
canSubscribe: ctx.events.canSubscribe,
|
|
2335
2545
|
number: providerResult.number,
|
|
2336
2546
|
repo: repo.ref
|
|
2337
|
-
})
|
|
2547
|
+
});
|
|
2338
2548
|
const data = {
|
|
2339
2549
|
base: providerResult.base.ref,
|
|
2340
2550
|
body: providerResult.body,
|
|
@@ -2373,7 +2583,7 @@ import {
|
|
|
2373
2583
|
PluginToolInputError as PluginToolInputError11,
|
|
2374
2584
|
pluginToolOutputSchema as pluginToolOutputSchema10
|
|
2375
2585
|
} from "@sentry/junior-plugin-api";
|
|
2376
|
-
import { z as
|
|
2586
|
+
import { z as z12 } from "zod";
|
|
2377
2587
|
var STATUS_TO_REACTION_CONTENT = {
|
|
2378
2588
|
reviewing: "eyes",
|
|
2379
2589
|
addressed: "+1",
|
|
@@ -2382,24 +2592,24 @@ var STATUS_TO_REACTION_CONTENT = {
|
|
|
2382
2592
|
var FEEDBACK_REACTION_CONTENTS = new Set(
|
|
2383
2593
|
Object.values(STATUS_TO_REACTION_CONTENT)
|
|
2384
2594
|
);
|
|
2385
|
-
var inputSchema8 =
|
|
2386
|
-
repo:
|
|
2387
|
-
commentKind:
|
|
2595
|
+
var inputSchema8 = z12.object({
|
|
2596
|
+
repo: z12.string().describe('Repository in "owner/name" format.'),
|
|
2597
|
+
commentKind: z12.enum(["conversation", "review"]).describe(
|
|
2388
2598
|
'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment.'
|
|
2389
2599
|
),
|
|
2390
|
-
commentId:
|
|
2600
|
+
commentId: z12.number().int().positive().describe(
|
|
2391
2601
|
"GitHub comment id (conversation comment id or inline review comment id)."
|
|
2392
2602
|
),
|
|
2393
|
-
status:
|
|
2603
|
+
status: z12.enum(["addressed", "declined"]).describe(
|
|
2394
2604
|
"Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
|
|
2395
2605
|
)
|
|
2396
2606
|
}).strict();
|
|
2397
2607
|
var outputSchema8 = pluginToolOutputSchema10.extend({
|
|
2398
|
-
target:
|
|
2399
|
-
repo:
|
|
2400
|
-
commentId:
|
|
2401
|
-
status:
|
|
2402
|
-
reactionId:
|
|
2608
|
+
target: z12.literal("updatePullRequestFeedback"),
|
|
2609
|
+
repo: z12.string(),
|
|
2610
|
+
commentId: z12.number(),
|
|
2611
|
+
status: z12.enum(["addressed", "declined"]),
|
|
2612
|
+
reactionId: z12.number()
|
|
2403
2613
|
});
|
|
2404
2614
|
function parseRepo10(value) {
|
|
2405
2615
|
const parts = value.split("/").map((part) => part.trim());
|
|
@@ -2431,10 +2641,10 @@ function githubError(payload) {
|
|
|
2431
2641
|
}
|
|
2432
2642
|
return "GitHub request failed";
|
|
2433
2643
|
}
|
|
2434
|
-
var reactionSchema =
|
|
2435
|
-
id:
|
|
2436
|
-
content:
|
|
2437
|
-
user:
|
|
2644
|
+
var reactionSchema = z12.object({
|
|
2645
|
+
id: z12.number(),
|
|
2646
|
+
content: z12.string(),
|
|
2647
|
+
user: z12.object({ id: z12.number() }).nullable()
|
|
2438
2648
|
});
|
|
2439
2649
|
function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
2440
2650
|
return definePluginTool10({
|
|
@@ -2444,7 +2654,7 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2444
2654
|
openWorldHint: true,
|
|
2445
2655
|
readOnlyHint: false
|
|
2446
2656
|
},
|
|
2447
|
-
description: "Set
|
|
2657
|
+
description: "Set your outcome reaction on GitHub pull request feedback: addressed (+1) or declined (-1). Use the commentId and commentKind from the event after acting on the feedback. Replaces only your prior status reaction on that comment.",
|
|
2448
2658
|
exposure: "direct",
|
|
2449
2659
|
inputSchema: inputSchema8,
|
|
2450
2660
|
outputSchema: outputSchema8,
|
|
@@ -2482,7 +2692,7 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2482
2692
|
`GitHub reaction lookup failed with HTTP ${listResponse.status}: ${githubError(listPayload)}`
|
|
2483
2693
|
);
|
|
2484
2694
|
}
|
|
2485
|
-
const botReactions =
|
|
2695
|
+
const botReactions = z12.array(reactionSchema).parse(listPayload).filter(
|
|
2486
2696
|
(reaction) => reaction.user?.id === botUserId && FEEDBACK_REACTION_CONTENTS.has(reaction.content)
|
|
2487
2697
|
);
|
|
2488
2698
|
const existing = botReactions.find(
|
|
@@ -2549,21 +2759,21 @@ import {
|
|
|
2549
2759
|
PluginToolInputError as PluginToolInputError12,
|
|
2550
2760
|
pluginToolOutputSchema as pluginToolOutputSchema11
|
|
2551
2761
|
} from "@sentry/junior-plugin-api";
|
|
2552
|
-
import { z as
|
|
2553
|
-
var inputSchema9 =
|
|
2554
|
-
repo:
|
|
2762
|
+
import { z as z13 } from "zod";
|
|
2763
|
+
var inputSchema9 = z13.object({
|
|
2764
|
+
repo: z13.string().describe(
|
|
2555
2765
|
'Repository in "owner/name" format. Required because GraphQL has no repo path.'
|
|
2556
2766
|
),
|
|
2557
|
-
threadId:
|
|
2767
|
+
threadId: z13.string().trim().min(1).describe(
|
|
2558
2768
|
"GitHub pull request review thread node ID (the same `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
|
|
2559
2769
|
)
|
|
2560
2770
|
}).strict();
|
|
2561
2771
|
var outputSchema9 = pluginToolOutputSchema11.extend({
|
|
2562
|
-
target:
|
|
2563
|
-
repo:
|
|
2564
|
-
number:
|
|
2565
|
-
threadId:
|
|
2566
|
-
resolved:
|
|
2772
|
+
target: z13.literal("resolvePullRequestReviewThread"),
|
|
2773
|
+
repo: z13.string(),
|
|
2774
|
+
number: z13.number(),
|
|
2775
|
+
threadId: z13.string(),
|
|
2776
|
+
resolved: z13.boolean()
|
|
2567
2777
|
});
|
|
2568
2778
|
function parseRepo11(value) {
|
|
2569
2779
|
const parts = value.split("/").map((part) => part.trim());
|
|
@@ -2645,18 +2855,18 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
2645
2855
|
`GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubError2(lookupPayload)}`
|
|
2646
2856
|
);
|
|
2647
2857
|
}
|
|
2648
|
-
const threadNodeSchema =
|
|
2649
|
-
id:
|
|
2650
|
-
isResolved:
|
|
2651
|
-
pullRequest:
|
|
2652
|
-
author:
|
|
2653
|
-
number:
|
|
2654
|
-
repository:
|
|
2858
|
+
const threadNodeSchema = z13.object({
|
|
2859
|
+
id: z13.string(),
|
|
2860
|
+
isResolved: z13.boolean(),
|
|
2861
|
+
pullRequest: z13.object({
|
|
2862
|
+
author: z13.object({ databaseId: z13.number().optional() }).passthrough().nullable(),
|
|
2863
|
+
number: z13.number(),
|
|
2864
|
+
repository: z13.object({ nameWithOwner: z13.string() }).passthrough()
|
|
2655
2865
|
}).passthrough()
|
|
2656
2866
|
}).passthrough();
|
|
2657
|
-
const lookupResultSchema =
|
|
2658
|
-
data:
|
|
2659
|
-
node:
|
|
2867
|
+
const lookupResultSchema = z13.object({
|
|
2868
|
+
data: z13.object({
|
|
2869
|
+
node: z13.unknown().nullable().optional()
|
|
2660
2870
|
}).passthrough()
|
|
2661
2871
|
}).passthrough();
|
|
2662
2872
|
const lookupResult = lookupResultSchema.safeParse(lookupPayload);
|
|
@@ -2706,10 +2916,10 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
2706
2916
|
`GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubError2(resolvePayload)}`
|
|
2707
2917
|
);
|
|
2708
2918
|
}
|
|
2709
|
-
const resolveResultSchema =
|
|
2710
|
-
data:
|
|
2711
|
-
resolveReviewThread:
|
|
2712
|
-
thread:
|
|
2919
|
+
const resolveResultSchema = z13.object({
|
|
2920
|
+
data: z13.object({
|
|
2921
|
+
resolveReviewThread: z13.object({
|
|
2922
|
+
thread: z13.object({ id: z13.string(), isResolved: z13.boolean() }).passthrough()
|
|
2713
2923
|
}).passthrough()
|
|
2714
2924
|
}).passthrough()
|
|
2715
2925
|
}).passthrough();
|
|
@@ -2741,32 +2951,32 @@ import {
|
|
|
2741
2951
|
PluginToolInputError as PluginToolInputError13,
|
|
2742
2952
|
pluginToolOutputSchema as pluginToolOutputSchema12
|
|
2743
2953
|
} from "@sentry/junior-plugin-api";
|
|
2744
|
-
import { z as
|
|
2745
|
-
var reviewCommentSchema =
|
|
2746
|
-
path:
|
|
2747
|
-
body:
|
|
2748
|
-
line:
|
|
2749
|
-
side:
|
|
2750
|
-
startLine:
|
|
2751
|
-
startSide:
|
|
2954
|
+
import { z as z14 } from "zod";
|
|
2955
|
+
var reviewCommentSchema = z14.object({
|
|
2956
|
+
path: z14.string().trim().min(1).describe("File path in the pull request."),
|
|
2957
|
+
body: z14.string().trim().min(1).describe("Inline review comment."),
|
|
2958
|
+
line: z14.number().int().positive().describe("Line in the pull request diff."),
|
|
2959
|
+
side: z14.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
|
|
2960
|
+
startLine: z14.number().int().positive().optional().describe("First line of a multi-line comment."),
|
|
2961
|
+
startSide: z14.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
|
|
2752
2962
|
}).strict().refine(
|
|
2753
2963
|
({ startLine, startSide }) => startLine === void 0 === (startSide === void 0),
|
|
2754
2964
|
{ message: "startLine and startSide must be provided together." }
|
|
2755
2965
|
);
|
|
2756
|
-
var inputSchema10 =
|
|
2757
|
-
repo:
|
|
2758
|
-
number:
|
|
2759
|
-
event:
|
|
2760
|
-
body:
|
|
2761
|
-
comments:
|
|
2966
|
+
var inputSchema10 = z14.object({
|
|
2967
|
+
repo: z14.string().describe('Repository in "owner/name" format.'),
|
|
2968
|
+
number: z14.number().int().positive().describe("Pull request number."),
|
|
2969
|
+
event: z14.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
|
|
2970
|
+
body: z14.string().trim().min(1).describe("Review summary."),
|
|
2971
|
+
comments: z14.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
|
|
2762
2972
|
}).strict();
|
|
2763
2973
|
var outputSchema10 = pluginToolOutputSchema12.extend({
|
|
2764
|
-
target:
|
|
2765
|
-
repo:
|
|
2766
|
-
number:
|
|
2767
|
-
reviewId:
|
|
2768
|
-
state:
|
|
2769
|
-
url:
|
|
2974
|
+
target: z14.literal("submitPullRequestReview"),
|
|
2975
|
+
repo: z14.string(),
|
|
2976
|
+
number: z14.number(),
|
|
2977
|
+
reviewId: z14.number(),
|
|
2978
|
+
state: z14.string(),
|
|
2979
|
+
url: z14.string()
|
|
2770
2980
|
});
|
|
2771
2981
|
function parseRepo12(value) {
|
|
2772
2982
|
const parts = value.split("/").map((part) => part.trim());
|
|
@@ -2807,7 +3017,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
2807
3017
|
openWorldHint: true,
|
|
2808
3018
|
readOnlyHint: false
|
|
2809
3019
|
},
|
|
2810
|
-
description: "Submit a GitHub pull request review as a comment or change request. Use this instead of `gh pr review`, GraphQL, or direct REST calls.
|
|
3020
|
+
description: "Submit a GitHub pull request review as a comment or change request. Use this instead of `gh pr review`, GraphQL, or direct REST calls. You cannot approve pull requests.",
|
|
2811
3021
|
exposure: "direct",
|
|
2812
3022
|
inputSchema: inputSchema10,
|
|
2813
3023
|
outputSchema: outputSchema10,
|
|
@@ -2845,7 +3055,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
2845
3055
|
if (!response.ok) {
|
|
2846
3056
|
throwReviewError(response.status, parsed);
|
|
2847
3057
|
}
|
|
2848
|
-
const providerResult =
|
|
3058
|
+
const providerResult = z14.object({ id: z14.number(), html_url: z14.string(), state: z14.string() }).parse(parsed);
|
|
2849
3059
|
return {
|
|
2850
3060
|
target: "submitPullRequestReview",
|
|
2851
3061
|
repo: repo.ref,
|
|
@@ -2886,102 +3096,11 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
2886
3096
|
|
|
2887
3097
|
// src/webhooks/handler.ts
|
|
2888
3098
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
3099
|
+
import { z as z21 } from "zod";
|
|
2889
3100
|
|
|
2890
3101
|
// src/issue-outcomes/store.ts
|
|
2891
|
-
import { and, eq, lte, sql as sql2 } from "drizzle-orm";
|
|
3102
|
+
import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
|
|
2892
3103
|
import { z as z15 } from "zod";
|
|
2893
|
-
|
|
2894
|
-
// src/db/schema.ts
|
|
2895
|
-
import { sql } from "drizzle-orm";
|
|
2896
|
-
import {
|
|
2897
|
-
index,
|
|
2898
|
-
integer,
|
|
2899
|
-
pgTable,
|
|
2900
|
-
primaryKey,
|
|
2901
|
-
text,
|
|
2902
|
-
timestamp
|
|
2903
|
-
} from "drizzle-orm/pg-core";
|
|
2904
|
-
import { z as z14 } from "zod";
|
|
2905
|
-
var githubPullRequestStateSchema = z14.enum([
|
|
2906
|
-
"closed_unmerged",
|
|
2907
|
-
"merged",
|
|
2908
|
-
"open"
|
|
2909
|
-
]);
|
|
2910
|
-
var githubPullRequestCommitCompositionSchema = z14.enum([
|
|
2911
|
-
"junior_only",
|
|
2912
|
-
"mixed"
|
|
2913
|
-
]);
|
|
2914
|
-
var githubIssueStateSchema = z14.enum(["closed", "open"]);
|
|
2915
|
-
var githubIssueStateReasonSchema = z14.enum([
|
|
2916
|
-
"completed",
|
|
2917
|
-
"duplicate",
|
|
2918
|
-
"not_planned",
|
|
2919
|
-
"reopened"
|
|
2920
|
-
]);
|
|
2921
|
-
var juniorGitHubIssues = pgTable(
|
|
2922
|
-
"junior_github_issues",
|
|
2923
|
-
{
|
|
2924
|
-
issueId: text("issue_id").primaryKey(),
|
|
2925
|
-
repositoryId: text("repository_id").notNull(),
|
|
2926
|
-
repositoryFullName: text("repository_full_name").notNull(),
|
|
2927
|
-
number: integer("number").notNull(),
|
|
2928
|
-
state: text("state").$type().notNull(),
|
|
2929
|
-
stateReason: text("state_reason").$type(),
|
|
2930
|
-
conversationIds: text("conversation_ids").array().notNull().default(sql`ARRAY[]::text[]`),
|
|
2931
|
-
openedAt: timestamp("opened_at", { withTimezone: true }).notNull(),
|
|
2932
|
-
closedAt: timestamp("closed_at", { withTimezone: true }),
|
|
2933
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2934
|
-
},
|
|
2935
|
-
(table) => [
|
|
2936
|
-
index("junior_github_issues_opened_at_idx").on(table.openedAt),
|
|
2937
|
-
index("junior_github_issues_closed_at_idx").on(table.closedAt),
|
|
2938
|
-
index("junior_github_issues_open_idx").on(table.issueId).where(sql`${table.state} = 'open'`)
|
|
2939
|
-
]
|
|
2940
|
-
);
|
|
2941
|
-
var juniorGitHubPullRequests = pgTable(
|
|
2942
|
-
"junior_github_pull_requests",
|
|
2943
|
-
{
|
|
2944
|
-
pullRequestId: text("pull_request_id").primaryKey(),
|
|
2945
|
-
repositoryId: text("repository_id").notNull(),
|
|
2946
|
-
repositoryFullName: text("repository_full_name").notNull(),
|
|
2947
|
-
number: integer("number").notNull(),
|
|
2948
|
-
state: text("state").$type().notNull(),
|
|
2949
|
-
commitComposition: text("commit_composition").$type(),
|
|
2950
|
-
conversationIds: text("conversation_ids").array().notNull().default(sql`ARRAY[]::text[]`),
|
|
2951
|
-
openedAt: timestamp("opened_at", { withTimezone: true }).notNull(),
|
|
2952
|
-
mergedAt: timestamp("merged_at", { withTimezone: true }),
|
|
2953
|
-
closedAt: timestamp("closed_at", { withTimezone: true }),
|
|
2954
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
|
|
2955
|
-
},
|
|
2956
|
-
(table) => [
|
|
2957
|
-
index("junior_github_pull_requests_opened_at_idx").on(table.openedAt),
|
|
2958
|
-
index("junior_github_pull_requests_merged_at_idx").on(table.mergedAt),
|
|
2959
|
-
index("junior_github_pull_requests_closed_at_idx").on(table.closedAt),
|
|
2960
|
-
index("junior_github_pull_requests_open_idx").on(table.pullRequestId).where(sql`${table.state} = 'open'`),
|
|
2961
|
-
index("junior_github_pull_requests_unmerged_conversations_idx").using("gin", table.conversationIds).where(sql`${table.state} <> 'merged'`)
|
|
2962
|
-
]
|
|
2963
|
-
);
|
|
2964
|
-
var juniorGitHubPullRequestIssues = pgTable(
|
|
2965
|
-
"junior_github_pull_request_issues",
|
|
2966
|
-
{
|
|
2967
|
-
pullRequestId: text("pull_request_id").notNull().references(() => juniorGitHubPullRequests.pullRequestId, {
|
|
2968
|
-
onDelete: "cascade"
|
|
2969
|
-
}),
|
|
2970
|
-
issueRepositoryFullName: text("issue_repository_full_name").notNull(),
|
|
2971
|
-
issueNumber: integer("issue_number").notNull()
|
|
2972
|
-
},
|
|
2973
|
-
(table) => [
|
|
2974
|
-
primaryKey({
|
|
2975
|
-
columns: [
|
|
2976
|
-
table.pullRequestId,
|
|
2977
|
-
table.issueRepositoryFullName,
|
|
2978
|
-
table.issueNumber
|
|
2979
|
-
]
|
|
2980
|
-
})
|
|
2981
|
-
]
|
|
2982
|
-
);
|
|
2983
|
-
|
|
2984
|
-
// src/issue-outcomes/store.ts
|
|
2985
3104
|
var githubIssueOutcomeInputSchema = z15.object({
|
|
2986
3105
|
candidateOwned: z15.boolean(),
|
|
2987
3106
|
closedAt: z15.date().optional(),
|
|
@@ -3015,8 +3134,8 @@ async function recordGitHubIssueOutcome(db, input) {
|
|
|
3015
3134
|
const values = projectionValues(outcome);
|
|
3016
3135
|
if (!outcome.candidateOwned) {
|
|
3017
3136
|
const updated = await db.update(juniorGitHubIssues).set(values).where(
|
|
3018
|
-
|
|
3019
|
-
|
|
3137
|
+
and2(
|
|
3138
|
+
eq2(juniorGitHubIssues.issueId, outcome.issueId),
|
|
3020
3139
|
lte(juniorGitHubIssues.updatedAt, outcome.updatedAt)
|
|
3021
3140
|
)
|
|
3022
3141
|
).returning({
|
|
@@ -3054,12 +3173,12 @@ async function recordGitHubIssueConversations(db, input) {
|
|
|
3054
3173
|
) AS value
|
|
3055
3174
|
ORDER BY value
|
|
3056
3175
|
)`
|
|
3057
|
-
}).where(
|
|
3176
|
+
}).where(eq2(juniorGitHubIssues.issueId, association.issueId)).returning({ issueId: juniorGitHubIssues.issueId });
|
|
3058
3177
|
return updated.length > 0;
|
|
3059
3178
|
}
|
|
3060
3179
|
|
|
3061
3180
|
// src/pull-request-outcomes/store.ts
|
|
3062
|
-
import { and as
|
|
3181
|
+
import { and as and3, eq as eq3, lte as lte2, ne, sql as sql3 } from "drizzle-orm";
|
|
3063
3182
|
import { z as z16 } from "zod";
|
|
3064
3183
|
var githubPullRequestOutcomeInputSchema = z16.object({
|
|
3065
3184
|
candidateOwned: z16.boolean(),
|
|
@@ -3106,8 +3225,8 @@ async function recordGitHubPullRequestOutcome(db, input) {
|
|
|
3106
3225
|
const values = projectionValues2(outcome);
|
|
3107
3226
|
if (!outcome.candidateOwned) {
|
|
3108
3227
|
const updated = await db.update(juniorGitHubPullRequests).set(values).where(
|
|
3109
|
-
|
|
3110
|
-
|
|
3228
|
+
and3(
|
|
3229
|
+
eq3(juniorGitHubPullRequests.pullRequestId, outcome.pullRequestId),
|
|
3111
3230
|
lte2(juniorGitHubPullRequests.updatedAt, outcome.updatedAt)
|
|
3112
3231
|
)
|
|
3113
3232
|
).returning({
|
|
@@ -3153,7 +3272,7 @@ async function listGitHubUnfinishedWork(db, conversationIds) {
|
|
|
3153
3272
|
sql3`, `
|
|
3154
3273
|
);
|
|
3155
3274
|
const rows = await db.select({ conversationIds: juniorGitHubPullRequests.conversationIds }).from(juniorGitHubPullRequests).where(
|
|
3156
|
-
|
|
3275
|
+
and3(
|
|
3157
3276
|
ne(juniorGitHubPullRequests.state, "merged"),
|
|
3158
3277
|
sql3`${juniorGitHubPullRequests.conversationIds} && ARRAY[${values}]::text[]`
|
|
3159
3278
|
)
|
|
@@ -3170,8 +3289,8 @@ async function listGitHubFinishedWork(db, conversationIds) {
|
|
|
3170
3289
|
conversationIds: juniorGitHubPullRequests.conversationIds,
|
|
3171
3290
|
mergedAt: juniorGitHubPullRequests.mergedAt
|
|
3172
3291
|
}).from(juniorGitHubPullRequests).where(
|
|
3173
|
-
|
|
3174
|
-
|
|
3292
|
+
and3(
|
|
3293
|
+
eq3(juniorGitHubPullRequests.state, "merged"),
|
|
3175
3294
|
sql3`${juniorGitHubPullRequests.conversationIds} && ARRAY[${values}]::text[]`
|
|
3176
3295
|
)
|
|
3177
3296
|
);
|
|
@@ -3221,7 +3340,7 @@ async function recordGitHubPullRequestConversations(db, input) {
|
|
|
3221
3340
|
ORDER BY value
|
|
3222
3341
|
)`
|
|
3223
3342
|
}).where(
|
|
3224
|
-
|
|
3343
|
+
eq3(juniorGitHubPullRequests.pullRequestId, association.pullRequestId)
|
|
3225
3344
|
).returning({ pullRequestId: juniorGitHubPullRequests.pullRequestId });
|
|
3226
3345
|
return updated.length > 0;
|
|
3227
3346
|
}
|
|
@@ -3237,7 +3356,7 @@ async function recordGitHubPullRequestLinkedIssues(db, input) {
|
|
|
3237
3356
|
),
|
|
3238
3357
|
issueNumber: sql3`${issue.number}`.as("issue_number")
|
|
3239
3358
|
}).from(juniorGitHubPullRequests).where(
|
|
3240
|
-
|
|
3359
|
+
eq3(
|
|
3241
3360
|
juniorGitHubPullRequests.pullRequestId,
|
|
3242
3361
|
association.pullRequestId
|
|
3243
3362
|
)
|
|
@@ -3551,48 +3670,160 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
|
|
|
3551
3670
|
} : void 0;
|
|
3552
3671
|
}
|
|
3553
3672
|
|
|
3554
|
-
// src/webhooks/pull-request-
|
|
3673
|
+
// src/webhooks/pull-request-match-data.ts
|
|
3555
3674
|
import { z as z19 } from "zod";
|
|
3556
|
-
var
|
|
3675
|
+
var LOOKUPS_BY_MATCH_KEY = {
|
|
3676
|
+
authors: ["authors"],
|
|
3677
|
+
openerEmail: ["opener"],
|
|
3678
|
+
openerRole: ["opener", "openerRole"],
|
|
3679
|
+
openerUsername: ["opener"]
|
|
3680
|
+
};
|
|
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
|
+
}
|
|
3557
3690
|
var webhookSchema = z19.object({
|
|
3558
3691
|
repository: z19.object({ full_name: z19.string().min(1) })
|
|
3559
3692
|
});
|
|
3560
|
-
|
|
3561
|
-
const
|
|
3562
|
-
const
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3693
|
+
function pullRequestNumbers(events) {
|
|
3694
|
+
const numbers = /* @__PURE__ */ new Map();
|
|
3695
|
+
for (const event of events) {
|
|
3696
|
+
const number = event.data?.pullRequest;
|
|
3697
|
+
if (typeof number === "number") numbers.set(event.eventKey, number);
|
|
3698
|
+
}
|
|
3699
|
+
return numbers;
|
|
3700
|
+
}
|
|
3701
|
+
function logFailure(context, lookup, error) {
|
|
3702
|
+
context.log?.error(`GitHub pull request ${lookup} lookup failed`, {
|
|
3703
|
+
deliveryId: context.deliveryId,
|
|
3704
|
+
errorType: error instanceof Error ? error.name : "UnknownError",
|
|
3705
|
+
repository: context.repositoryFullName
|
|
3572
3706
|
});
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3707
|
+
return void 0;
|
|
3708
|
+
}
|
|
3709
|
+
async function withJuniorOpeners(context, events) {
|
|
3710
|
+
const botNumber = (event) => {
|
|
3711
|
+
const number = context.numbers.get(event.eventKey);
|
|
3712
|
+
return number !== void 0 && isBotLogin(event.data?.openerUsername, context.botEmail) ? number : void 0;
|
|
3713
|
+
};
|
|
3714
|
+
const numbers = events.flatMap((event) => botNumber(event) ?? []);
|
|
3715
|
+
if (numbers.length === 0) return events;
|
|
3716
|
+
const openers = await listGitHubPullRequestOpeners(context.db, {
|
|
3717
|
+
numbers,
|
|
3718
|
+
repositoryFullName: context.repositoryFullName
|
|
3719
|
+
});
|
|
3720
|
+
const logins = /* @__PURE__ */ new Map();
|
|
3721
|
+
for (const identityId of new Set(openers.values())) {
|
|
3580
3722
|
try {
|
|
3581
|
-
|
|
3723
|
+
logins.set(identityId, await context.loadGitHubLogin?.(identityId));
|
|
3582
3724
|
} catch (error) {
|
|
3583
|
-
|
|
3584
|
-
deliveryId: args.deliveryId,
|
|
3585
|
-
errorType: error instanceof Error ? error.name : "UnknownError",
|
|
3586
|
-
repository: repositoryFullName
|
|
3587
|
-
});
|
|
3725
|
+
logFailure(context, "opener", error);
|
|
3588
3726
|
}
|
|
3589
3727
|
}
|
|
3590
|
-
return
|
|
3591
|
-
const
|
|
3592
|
-
|
|
3593
|
-
|
|
3728
|
+
return events.map((event) => {
|
|
3729
|
+
const number = botNumber(event);
|
|
3730
|
+
if (number === void 0) return event;
|
|
3731
|
+
const identityId = openers.get(number);
|
|
3732
|
+
const login = identityId ? logins.get(identityId) : void 0;
|
|
3733
|
+
const {
|
|
3734
|
+
openerEmail: _email,
|
|
3735
|
+
openerUsername: _login,
|
|
3736
|
+
...data
|
|
3737
|
+
} = event.data ?? {};
|
|
3738
|
+
return {
|
|
3739
|
+
...event,
|
|
3740
|
+
data: { ...data, ...lookupData({ openerUsername: login || void 0 }) }
|
|
3741
|
+
};
|
|
3594
3742
|
});
|
|
3595
3743
|
}
|
|
3744
|
+
async function withRolesAndAuthors(context, events, lookups) {
|
|
3745
|
+
const { repositoryFullName } = context;
|
|
3746
|
+
const roles = /* @__PURE__ */ new Map();
|
|
3747
|
+
const authors = /* @__PURE__ */ new Map();
|
|
3748
|
+
const loadRole = lookups.has("openerRole") ? context.loadRole : void 0;
|
|
3749
|
+
const loadAuthors = lookups.has("authors") ? context.loadAuthors : void 0;
|
|
3750
|
+
if (!loadRole && !loadAuthors) return events;
|
|
3751
|
+
return await Promise.all(
|
|
3752
|
+
events.map(async (event) => {
|
|
3753
|
+
const number = context.numbers.get(event.eventKey);
|
|
3754
|
+
if (number === void 0) return event;
|
|
3755
|
+
const login = event.data?.openerUsername;
|
|
3756
|
+
if (loadRole && typeof login === "string" && !roles.has(login)) {
|
|
3757
|
+
roles.set(
|
|
3758
|
+
login,
|
|
3759
|
+
loadRole({ login, repositoryFullName }).catch(
|
|
3760
|
+
(error) => logFailure(context, "role", error)
|
|
3761
|
+
)
|
|
3762
|
+
);
|
|
3763
|
+
}
|
|
3764
|
+
if (loadAuthors && !authors.has(number)) {
|
|
3765
|
+
authors.set(
|
|
3766
|
+
number,
|
|
3767
|
+
loadAuthors({ number, repositoryFullName }).catch(
|
|
3768
|
+
(error) => logFailure(context, "authors", error)
|
|
3769
|
+
)
|
|
3770
|
+
);
|
|
3771
|
+
}
|
|
3772
|
+
const role = loadRole && typeof login === "string" ? await roles.get(login) : void 0;
|
|
3773
|
+
const logins = loadAuthors ? await authors.get(number) : void 0;
|
|
3774
|
+
if (!role && !logins?.length) return event;
|
|
3775
|
+
return {
|
|
3776
|
+
...event,
|
|
3777
|
+
data: {
|
|
3778
|
+
...event.data,
|
|
3779
|
+
...lookupData({
|
|
3780
|
+
authors: logins?.length ? logins : void 0,
|
|
3781
|
+
openerRole: role || void 0
|
|
3782
|
+
})
|
|
3783
|
+
}
|
|
3784
|
+
};
|
|
3785
|
+
})
|
|
3786
|
+
);
|
|
3787
|
+
}
|
|
3788
|
+
async function withLookups(context, events, lookups) {
|
|
3789
|
+
const opened = lookups.has("opener") ? await withJuniorOpeners(context, events) : events;
|
|
3790
|
+
return await withRolesAndAuthors(context, opened, lookups);
|
|
3791
|
+
}
|
|
3792
|
+
async function withGitHubPullRequestMatchData(args) {
|
|
3793
|
+
const parsed = webhookSchema.safeParse(args.body);
|
|
3794
|
+
const numbers = pullRequestNumbers(args.events);
|
|
3795
|
+
const pullRequestEvents = args.events.filter(
|
|
3796
|
+
(event) => numbers.has(event.eventKey)
|
|
3797
|
+
);
|
|
3798
|
+
if (!parsed.success || pullRequestEvents.length === 0) return args.events;
|
|
3799
|
+
const context = {
|
|
3800
|
+
botEmail: args.botEmail,
|
|
3801
|
+
db: args.db,
|
|
3802
|
+
deliveryId: args.deliveryId,
|
|
3803
|
+
...args.loadAuthors ? { loadAuthors: args.loadAuthors } : void 0,
|
|
3804
|
+
...args.loadGitHubLogin ? { loadGitHubLogin: args.loadGitHubLogin } : void 0,
|
|
3805
|
+
...args.loadRole ? { loadRole: args.loadRole } : void 0,
|
|
3806
|
+
...args.log ? { log: args.log } : void 0,
|
|
3807
|
+
numbers,
|
|
3808
|
+
repositoryFullName: parsed.data.repository.full_name
|
|
3809
|
+
};
|
|
3810
|
+
const keys = await args.neededMatchKeys?.({
|
|
3811
|
+
eventTypes: [...new Set(pullRequestEvents.map((e) => e.eventType))],
|
|
3812
|
+
identifiers: [...new Set(pullRequestEvents.map((e) => e.identifier))]
|
|
3813
|
+
}) ?? [];
|
|
3814
|
+
const filtered = new Set(
|
|
3815
|
+
keys.flatMap((key) => LOOKUPS_BY_MATCH_KEY[key] ?? [])
|
|
3816
|
+
);
|
|
3817
|
+
const events = filtered.size > 0 ? await withLookups(context, args.events, filtered) : args.events;
|
|
3818
|
+
const rest = new Set(ALL_LOOKUPS.filter((lookup) => !filtered.has(lookup)));
|
|
3819
|
+
const { hasMatch } = args;
|
|
3820
|
+
if (rest.size === 0 || !hasMatch) return events;
|
|
3821
|
+
const matches = await Promise.all(
|
|
3822
|
+
events.filter((event) => numbers.has(event.eventKey)).map((event) => hasMatch(event))
|
|
3823
|
+
);
|
|
3824
|
+
if (!matches.some(Boolean)) return events;
|
|
3825
|
+
return await withLookups(context, events, rest);
|
|
3826
|
+
}
|
|
3596
3827
|
|
|
3597
3828
|
// src/webhooks/pull-request-people.ts
|
|
3598
3829
|
import { z as z20 } from "zod";
|
|
@@ -3619,6 +3850,42 @@ var commitPageSchema = z20.array(
|
|
|
3619
3850
|
commit: z20.object({ message: z20.string() })
|
|
3620
3851
|
})
|
|
3621
3852
|
);
|
|
3853
|
+
function shareCommitPages(load) {
|
|
3854
|
+
const loaders = /* @__PURE__ */ new Map();
|
|
3855
|
+
const pages = /* @__PURE__ */ new Map();
|
|
3856
|
+
return (target) => async (page, perPage) => {
|
|
3857
|
+
const pullRequest = `${target.repositoryFullName.toLowerCase()}#${target.number}`;
|
|
3858
|
+
const key = `${pullRequest}:${page}:${perPage}`;
|
|
3859
|
+
let result = pages.get(key);
|
|
3860
|
+
if (!result) {
|
|
3861
|
+
let loader = loaders.get(pullRequest);
|
|
3862
|
+
if (!loader) {
|
|
3863
|
+
loader = load(target);
|
|
3864
|
+
loaders.set(pullRequest, loader);
|
|
3865
|
+
}
|
|
3866
|
+
result = loader.then((loadPage) => loadPage(page, perPage));
|
|
3867
|
+
pages.set(key, result);
|
|
3868
|
+
}
|
|
3869
|
+
return await result;
|
|
3870
|
+
};
|
|
3871
|
+
}
|
|
3872
|
+
async function forEachCommit(loadPage, visit) {
|
|
3873
|
+
for (let page = 1; page <= MAX_PAGES; page += 1) {
|
|
3874
|
+
const commits = commitPageSchema.parse(await loadPage(page, PAGE_SIZE));
|
|
3875
|
+
for (const commit of commits) {
|
|
3876
|
+
visit({
|
|
3877
|
+
coAuthorEmails: [
|
|
3878
|
+
...commit.commit.message.matchAll(CO_AUTHOR_TRAILER)
|
|
3879
|
+
].map((match) => match[1]),
|
|
3880
|
+
...commit.author ? { login: commit.author.login } : void 0
|
|
3881
|
+
});
|
|
3882
|
+
}
|
|
3883
|
+
if (commits.length < PAGE_SIZE) break;
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
function noreplyLogin(email) {
|
|
3887
|
+
return GITHUB_NOREPLY_EMAIL.exec(email)?.groups?.login;
|
|
3888
|
+
}
|
|
3622
3889
|
async function loadGitHubPullRequestPeople(args) {
|
|
3623
3890
|
const people = /* @__PURE__ */ new Map();
|
|
3624
3891
|
const addLogin = (login) => {
|
|
@@ -3628,28 +3895,33 @@ async function loadGitHubPullRequestPeople(args) {
|
|
|
3628
3895
|
people.set(key, { provider: "github", handle: login });
|
|
3629
3896
|
};
|
|
3630
3897
|
const addEmail = (value) => {
|
|
3898
|
+
const login = noreplyLogin(value);
|
|
3899
|
+
if (login) return addLogin(login);
|
|
3631
3900
|
const email = value.toLowerCase();
|
|
3632
|
-
|
|
3633
|
-
if (login) addLogin(login);
|
|
3634
|
-
else if (!people.has(`email:${email}`)) {
|
|
3901
|
+
if (!people.has(`email:${email}`)) {
|
|
3635
3902
|
people.set(`email:${email}`, { email });
|
|
3636
3903
|
}
|
|
3637
3904
|
};
|
|
3638
3905
|
args.logins.forEach(addLogin);
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
for (const commit of commits) {
|
|
3644
|
-
if (commit.author) addLogin(commit.author.login);
|
|
3645
|
-
for (const match of commit.commit.message.matchAll(CO_AUTHOR_TRAILER)) {
|
|
3646
|
-
addEmail(match[1]);
|
|
3647
|
-
}
|
|
3648
|
-
}
|
|
3649
|
-
if (commits.length < PAGE_SIZE) break;
|
|
3650
|
-
}
|
|
3906
|
+
await forEachCommit(args.loadPage, (commit) => {
|
|
3907
|
+
if (commit.login) addLogin(commit.login);
|
|
3908
|
+
commit.coAuthorEmails.forEach(addEmail);
|
|
3909
|
+
});
|
|
3651
3910
|
return [...people.values()].slice(0, MAX_PEOPLE);
|
|
3652
3911
|
}
|
|
3912
|
+
async function loadGitHubPullRequestAuthors(args) {
|
|
3913
|
+
const authors = /* @__PURE__ */ new Map();
|
|
3914
|
+
const add = (login) => {
|
|
3915
|
+
if (login && !authors.has(login.toLowerCase())) {
|
|
3916
|
+
authors.set(login.toLowerCase(), login);
|
|
3917
|
+
}
|
|
3918
|
+
};
|
|
3919
|
+
await forEachCommit(args.loadPage, (commit) => {
|
|
3920
|
+
add(commit.login);
|
|
3921
|
+
commit.coAuthorEmails.forEach((email) => add(noreplyLogin(email)));
|
|
3922
|
+
});
|
|
3923
|
+
return [...authors.values()].slice(0, MAX_PEOPLE);
|
|
3924
|
+
}
|
|
3653
3925
|
async function withGitHubPullRequestPeople(args) {
|
|
3654
3926
|
const { hasMatch } = args;
|
|
3655
3927
|
const peopleEvents = args.events.filter(
|
|
@@ -3720,19 +3992,17 @@ function webhookInstallationId(body) {
|
|
|
3720
3992
|
}
|
|
3721
3993
|
return parseInstallationId(installation.id);
|
|
3722
3994
|
}
|
|
3995
|
+
var feedbackTargetSchema = z21.object({
|
|
3996
|
+
commentId: z21.number(),
|
|
3997
|
+
commentKind: z21.enum(["conversation", "review"]),
|
|
3998
|
+
repo: z21.string().min(1)
|
|
3999
|
+
});
|
|
3723
4000
|
function pullRequestFeedbackTarget(events) {
|
|
3724
4001
|
const event = events.find(
|
|
3725
4002
|
(candidate) => candidate.eventType === "pull_request.comment.created" || candidate.eventType === "pull_request.review_comment.created"
|
|
3726
4003
|
);
|
|
3727
|
-
const
|
|
3728
|
-
|
|
3729
|
-
return void 0;
|
|
3730
|
-
}
|
|
3731
|
-
return {
|
|
3732
|
-
commentId: data.commentId,
|
|
3733
|
-
commentKind: data.commentKind,
|
|
3734
|
-
repo: data.repo
|
|
3735
|
-
};
|
|
4004
|
+
const parsed = feedbackTargetSchema.safeParse(event?.data);
|
|
4005
|
+
return parsed.success ? parsed.data : void 0;
|
|
3736
4006
|
}
|
|
3737
4007
|
function githubCodeChange(outcome, conversationIds) {
|
|
3738
4008
|
return {
|
|
@@ -3883,11 +4153,14 @@ function createGitHubWebhookRoute(args) {
|
|
|
3883
4153
|
privateKeyEnv: args.privateKeyEnv
|
|
3884
4154
|
}) : void 0;
|
|
3885
4155
|
const hasMatch = args.events.hasMatch;
|
|
4156
|
+
const commitPages = args.loadPullRequestCommitPages ? shareCommitPages(args.loadPullRequestCommitPages) : void 0;
|
|
3886
4157
|
const events = await withGitHubPullRequestPeople({
|
|
3887
4158
|
body,
|
|
3888
4159
|
deliveryId,
|
|
3889
|
-
events: await
|
|
4160
|
+
events: await withGitHubPullRequestMatchData({
|
|
3890
4161
|
body,
|
|
4162
|
+
botEmail,
|
|
4163
|
+
db: args.db,
|
|
3891
4164
|
deliveryId,
|
|
3892
4165
|
events: normalizeGitHubEvents({
|
|
3893
4166
|
body,
|
|
@@ -3896,12 +4169,24 @@ function createGitHubWebhookRoute(args) {
|
|
|
3896
4169
|
deliveryId,
|
|
3897
4170
|
eventName
|
|
3898
4171
|
}),
|
|
3899
|
-
|
|
4172
|
+
hasMatch,
|
|
4173
|
+
...commitPages ? {
|
|
4174
|
+
loadAuthors: async (target) => await loadGitHubPullRequestAuthors({
|
|
4175
|
+
loadPage: commitPages(target)
|
|
4176
|
+
})
|
|
4177
|
+
} : void 0,
|
|
4178
|
+
loadGitHubLogin: args.loadGitHubLogin,
|
|
4179
|
+
loadRole: args.loadRepositoryRole,
|
|
3900
4180
|
log: args.log,
|
|
3901
4181
|
neededMatchKeys: args.events.neededMatchKeys
|
|
3902
4182
|
}),
|
|
3903
4183
|
hasMatch,
|
|
3904
|
-
|
|
4184
|
+
...commitPages ? {
|
|
4185
|
+
load: async (target) => await loadGitHubPullRequestPeople({
|
|
4186
|
+
logins: target.logins,
|
|
4187
|
+
loadPage: commitPages(target)
|
|
4188
|
+
})
|
|
4189
|
+
} : void 0,
|
|
3905
4190
|
log: args.log
|
|
3906
4191
|
});
|
|
3907
4192
|
const feedbackTarget = pullRequestFeedbackTarget(events);
|
|
@@ -3935,7 +4220,7 @@ function createGitHubWebhookRoute(args) {
|
|
|
3935
4220
|
}
|
|
3936
4221
|
|
|
3937
4222
|
// src/webhooks/installation-requests.ts
|
|
3938
|
-
import { z as
|
|
4223
|
+
import { z as z22 } from "zod";
|
|
3939
4224
|
function splitRepository(fullName, label) {
|
|
3940
4225
|
const [owner, name, ...extra] = fullName.split("/");
|
|
3941
4226
|
if (!owner || !name || extra.length > 0) {
|
|
@@ -3980,9 +4265,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
3980
4265
|
}
|
|
3981
4266
|
);
|
|
3982
4267
|
}
|
|
3983
|
-
var repositoryPermissionSchema =
|
|
3984
|
-
permission:
|
|
3985
|
-
role_name:
|
|
4268
|
+
var repositoryPermissionSchema = z22.object({
|
|
4269
|
+
permission: z22.string().min(1),
|
|
4270
|
+
role_name: z22.string().optional()
|
|
3986
4271
|
});
|
|
3987
4272
|
var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
|
|
3988
4273
|
async function loadRepositoryRole(env, cache, target) {
|
|
@@ -4014,18 +4299,18 @@ async function loadRepositoryRole(env, cache, target) {
|
|
|
4014
4299
|
}
|
|
4015
4300
|
|
|
4016
4301
|
// src/pull-request-outcomes/commit-composition.ts
|
|
4017
|
-
import { z as
|
|
4018
|
-
var canonicalCommitSchema =
|
|
4019
|
-
authorEmail:
|
|
4020
|
-
authorLogin:
|
|
4302
|
+
import { z as z23 } from "zod";
|
|
4303
|
+
var canonicalCommitSchema = z23.object({
|
|
4304
|
+
authorEmail: z23.string().nullable(),
|
|
4305
|
+
authorLogin: z23.string().nullable()
|
|
4021
4306
|
}).strict();
|
|
4022
|
-
var providerCommitSchema =
|
|
4023
|
-
author:
|
|
4024
|
-
commit:
|
|
4025
|
-
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()
|
|
4026
4311
|
}).passthrough()
|
|
4027
4312
|
}).passthrough();
|
|
4028
|
-
var commitPageSchema2 =
|
|
4313
|
+
var commitPageSchema2 = z23.array(providerCommitSchema).transform(
|
|
4029
4314
|
(commits) => commits.map(
|
|
4030
4315
|
(commit) => canonicalCommitSchema.parse({
|
|
4031
4316
|
authorEmail: commit.commit.author?.email ?? null,
|
|
@@ -4156,12 +4441,12 @@ if [ -z "$message_file" ]; then
|
|
|
4156
4441
|
fi
|
|
4157
4442
|
|
|
4158
4443
|
if [ -z "\${JUNIOR_GIT_AUTHOR_NAME:-}" ] || [ -z "\${JUNIOR_GIT_AUTHOR_EMAIL:-}" ]; then
|
|
4159
|
-
echo "
|
|
4444
|
+
echo "GitHub plugin internal error: the host runtime did not inject the Git author identity. Do not set Git author env vars manually; report this configuration error." >&2
|
|
4160
4445
|
exit 1
|
|
4161
4446
|
fi
|
|
4162
4447
|
|
|
4163
4448
|
if [ "\${GIT_AUTHOR_NAME:-}" != "$JUNIOR_GIT_AUTHOR_NAME" ] || [ "\${GIT_AUTHOR_EMAIL:-}" != "$JUNIOR_GIT_AUTHOR_EMAIL" ]; then
|
|
4164
|
-
echo "
|
|
4449
|
+
echo "GitHub plugin internal error: Git author was not set to the configured identity. Do not override Git author manually; report this configuration error." >&2
|
|
4165
4450
|
exit 1
|
|
4166
4451
|
fi
|
|
4167
4452
|
|
|
@@ -4759,7 +5044,7 @@ function assertGitHubPullRequestApprovalDenied(input) {
|
|
|
4759
5044
|
if (!bodyText) {
|
|
4760
5045
|
if (isEventsPath) {
|
|
4761
5046
|
throw new EgressPolicyDenied(
|
|
4762
|
-
"GitHub pull request review submissions must include a parseable non-APPROVE event so
|
|
5047
|
+
"GitHub pull request review submissions must include a parseable non-APPROVE event so the no-approve policy can be enforced."
|
|
4763
5048
|
);
|
|
4764
5049
|
}
|
|
4765
5050
|
return;
|
|
@@ -4769,31 +5054,31 @@ function assertGitHubPullRequestApprovalDenied(input) {
|
|
|
4769
5054
|
body = JSON.parse(bodyText);
|
|
4770
5055
|
} catch {
|
|
4771
5056
|
throw new EgressPolicyDenied(
|
|
4772
|
-
"GitHub pull request review requests must use JSON bodies so
|
|
5057
|
+
"GitHub pull request review requests must use JSON bodies so the no-approve policy can be enforced."
|
|
4773
5058
|
);
|
|
4774
5059
|
}
|
|
4775
5060
|
if (!isRecord(body)) {
|
|
4776
5061
|
throw new EgressPolicyDenied(
|
|
4777
|
-
"GitHub pull request review requests must use JSON object bodies so
|
|
5062
|
+
"GitHub pull request review requests must use JSON object bodies so the no-approve policy can be enforced."
|
|
4778
5063
|
);
|
|
4779
5064
|
}
|
|
4780
5065
|
let event;
|
|
4781
5066
|
if ("event" in body) {
|
|
4782
5067
|
if (typeof body.event !== "string" || body.event.trim().length === 0) {
|
|
4783
5068
|
throw new EgressPolicyDenied(
|
|
4784
|
-
"GitHub pull request review submissions must include a parseable non-APPROVE event so
|
|
5069
|
+
"GitHub pull request review submissions must include a parseable non-APPROVE event so the no-approve policy can be enforced."
|
|
4785
5070
|
);
|
|
4786
5071
|
}
|
|
4787
5072
|
event = body.event.trim().toUpperCase();
|
|
4788
5073
|
}
|
|
4789
5074
|
if (event === "APPROVE") {
|
|
4790
5075
|
throw new EgressPolicyDenied(
|
|
4791
|
-
"
|
|
5076
|
+
"You cannot approve GitHub pull requests. Request changes, leave a comment review, or dismiss your own review instead."
|
|
4792
5077
|
);
|
|
4793
5078
|
}
|
|
4794
5079
|
if (isEventsPath && event === void 0) {
|
|
4795
5080
|
throw new EgressPolicyDenied(
|
|
4796
|
-
"GitHub pull request review submissions must include a parseable non-APPROVE event so
|
|
5081
|
+
"GitHub pull request review submissions must include a parseable non-APPROVE event so the no-approve policy can be enforced."
|
|
4797
5082
|
);
|
|
4798
5083
|
}
|
|
4799
5084
|
}
|
|
@@ -4997,14 +5282,14 @@ async function githubPermissionDeniedMessage(ctx) {
|
|
|
4997
5282
|
var PULL_REQUEST_COMMENT_REACTIONS_PATH = /^\/repos\/[^/]+\/[^/]+\/(issues|pulls)\/comments\/[^/]+\/reactions(?:\/[^/]+)?$/;
|
|
4998
5283
|
var GITHUB_BODY_WRITES = [
|
|
4999
5284
|
{
|
|
5000
|
-
denialMessage: `GitHub issue creation must use the github_createIssue tool
|
|
5285
|
+
denialMessage: `GitHub issue creation must use the github_createIssue tool, which owns idempotency and the conversation footer. ${CREATE_TOOL_ROUTING_GUIDANCE}`,
|
|
5001
5286
|
graphqlField: "createIssue",
|
|
5002
5287
|
method: "POST",
|
|
5003
5288
|
operation: "github.issue.create",
|
|
5004
5289
|
restPath: /^\/repos\/[^/]+\/[^/]+\/issues$/
|
|
5005
5290
|
},
|
|
5006
5291
|
{
|
|
5007
|
-
denialMessage: `GitHub pull request creation must use the github_createPullRequest tool
|
|
5292
|
+
denialMessage: `GitHub pull request creation must use the github_createPullRequest tool, which owns idempotency and the conversation footer. ${CREATE_TOOL_ROUTING_GUIDANCE}`,
|
|
5008
5293
|
graphqlField: "createPullRequest",
|
|
5009
5294
|
method: "POST",
|
|
5010
5295
|
operation: "github.pull.create",
|
|
@@ -5018,14 +5303,14 @@ var GITHUB_BODY_WRITES = [
|
|
|
5018
5303
|
restPath: /^\/repos\/[^/]+\/[^/]+\/pulls\/[^/]+\/reviews$/
|
|
5019
5304
|
},
|
|
5020
5305
|
{
|
|
5021
|
-
denialMessage: `GitHub issue updates must use the github_updateIssue tool
|
|
5306
|
+
denialMessage: `GitHub issue updates must use the github_updateIssue tool, which owns requester attribution and the conversation footer. ${CREATE_TOOL_ROUTING_GUIDANCE}`,
|
|
5022
5307
|
graphqlField: "updateIssue",
|
|
5023
5308
|
method: "PATCH",
|
|
5024
5309
|
operation: "github.issue.update",
|
|
5025
5310
|
restPath: /^\/repos\/[^/]+\/[^/]+\/issues\/[^/]+$/
|
|
5026
5311
|
},
|
|
5027
5312
|
{
|
|
5028
|
-
denialMessage: `GitHub pull request updates must use the github_updatePullRequest tool
|
|
5313
|
+
denialMessage: `GitHub pull request updates must use the github_updatePullRequest tool, which owns requester attribution and the conversation footer. ${CREATE_TOOL_ROUTING_GUIDANCE}`,
|
|
5029
5314
|
graphqlField: "updatePullRequest",
|
|
5030
5315
|
method: "PATCH",
|
|
5031
5316
|
operation: "github.pull.update",
|
|
@@ -5249,7 +5534,7 @@ async function githubGrantForEgress(ctx) {
|
|
|
5249
5534
|
const access = HTTP_READ_METHODS.has(method) ? "read" : "write";
|
|
5250
5535
|
if (access === "write") {
|
|
5251
5536
|
throw new EgressPolicyDenied2(
|
|
5252
|
-
"
|
|
5537
|
+
"This GitHub write request is not supported. Use the matching GitHub tool or a supported REST endpoint."
|
|
5253
5538
|
);
|
|
5254
5539
|
}
|
|
5255
5540
|
return grantForAccess(access, "github.api-read", "installation-read");
|
|
@@ -5285,7 +5570,7 @@ function githubPlugin(options = {}) {
|
|
|
5285
5570
|
identifier: GITHUB_ISSUE_IDENTIFIER,
|
|
5286
5571
|
supportedEvents: [...GITHUB_ISSUE_EVENTS],
|
|
5287
5572
|
suggestedEvents: [...GITHUB_ISSUE_SUGGESTED_EVENTS],
|
|
5288
|
-
matchFields:
|
|
5573
|
+
matchFields: GITHUB_ISSUE_MATCH_FIELDS
|
|
5289
5574
|
},
|
|
5290
5575
|
{
|
|
5291
5576
|
type: "pull_request",
|
|
@@ -5301,27 +5586,19 @@ function githubPlugin(options = {}) {
|
|
|
5301
5586
|
type: "release_source",
|
|
5302
5587
|
identifier: GITHUB_RELEASE_SOURCE_IDENTIFIER,
|
|
5303
5588
|
supportedEvents: [...GITHUB_RELEASE_EVENTS],
|
|
5304
|
-
suggestedEvents: [...GITHUB_RELEASE_SUGGESTED_EVENTS]
|
|
5589
|
+
suggestedEvents: [...GITHUB_RELEASE_SUGGESTED_EVENTS],
|
|
5590
|
+
matchFields: GITHUB_RELEASE_MATCH_FIELDS
|
|
5305
5591
|
},
|
|
5306
5592
|
{
|
|
5307
5593
|
type: "repository",
|
|
5308
5594
|
identifier: GITHUB_REPOSITORY_IDENTIFIER,
|
|
5309
|
-
supportedEvents: [
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
"pull_request.opened",
|
|
5317
|
-
...GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
5318
|
-
...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS
|
|
5319
|
-
],
|
|
5320
|
-
matchFields: {
|
|
5321
|
-
...GITHUB_DEPLOYMENT_MATCH_FIELDS,
|
|
5322
|
-
...GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
|
|
5323
|
-
...GITHUB_PULL_REQUEST_MATCH_FIELDS
|
|
5324
|
-
},
|
|
5595
|
+
supportedEvents: [...GITHUB_REPOSITORY_EVENTS],
|
|
5596
|
+
suggestedEvents: [...GITHUB_REPOSITORY_SUGGESTED_EVENTS],
|
|
5597
|
+
matchFields: mergeEventMatchFields(
|
|
5598
|
+
GITHUB_DEPLOYMENT_MATCH_FIELDS,
|
|
5599
|
+
GITHUB_ISSUE_MATCH_FIELDS,
|
|
5600
|
+
GITHUB_PULL_REQUEST_MATCH_FIELDS
|
|
5601
|
+
),
|
|
5325
5602
|
guidance: gitHubPullRequestEventGuidance(
|
|
5326
5603
|
options.pullRequestEvents?.guidance
|
|
5327
5604
|
)
|
|
@@ -5471,14 +5748,11 @@ function githubPlugin(options = {}) {
|
|
|
5471
5748
|
db: ctx.db,
|
|
5472
5749
|
installationId: () => readEnv(installationIdEnv),
|
|
5473
5750
|
installationIdEnv,
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
pullRequest
|
|
5480
|
-
)
|
|
5481
|
-
}),
|
|
5751
|
+
loadRepositoryRole: async (target) => await loadRepositoryRole(installationEnv, ctx.cache, target),
|
|
5752
|
+
loadGitHubLogin: async (identityId) => linkedGitHubLogin(
|
|
5753
|
+
(await ctx.users.readIdentity(identityId))?.user
|
|
5754
|
+
),
|
|
5755
|
+
loadPullRequestCommitPages: async (pullRequest) => await loadPullRequestCommitPages(installationEnv, pullRequest),
|
|
5482
5756
|
log: ctx.log,
|
|
5483
5757
|
markFeedbackReviewing: async (target) => await markPullRequestFeedbackReviewing(installationEnv, target),
|
|
5484
5758
|
privateKeyEnv,
|