@sentry/junior-github 0.263.0 → 0.265.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-VEN7LFRI.js → chunk-4RYMEHIK.js} +107 -95
- package/dist/credential-support.d.ts +1 -1
- package/dist/db/schema.d.ts +192 -0
- package/dist/events/deployment.d.ts +14 -3
- package/dist/events/issue.d.ts +12 -4
- package/dist/events/pull-request.d.ts +15 -3
- package/dist/events/release.d.ts +7 -2
- package/dist/events/repository.d.ts +11 -2
- package/dist/index.js +795 -532
- 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 +12 -0
- package/dist/webhooks/handler.d.ts +12 -7
- 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/skills/github-code/SKILL.md +2 -1
- package/skills/github-code/SPEC.md +2 -2
- package/dist/webhooks/pull-request-author-role.d.ts +0 -20
package/README.md
CHANGED
|
@@ -34,6 +34,57 @@ The plugin saves the created pull request before it tries assignment. Retrying
|
|
|
34
34
|
the same tool call returns the saved pull request without retrying assignment,
|
|
35
35
|
creating another pull request, or replacing existing assignees.
|
|
36
36
|
|
|
37
|
+
The plugin saves each person who asks Junior to open or update a pull request in
|
|
38
|
+
`junior_github_pull_request_requesters`. Each row has only the core Junior
|
|
39
|
+
identity id of that person. The plugin does not copy the user or GitHub login.
|
|
40
|
+
When a webhook needs the GitHub login, it reads the identity through
|
|
41
|
+
`ctx.users.readIdentity()` and uses the GitHub identity of the linked user. So a
|
|
42
|
+
person who links GitHub later is found on their older pull requests too. The
|
|
43
|
+
create tool saves the opener after GitHub opens the pull request. The first row
|
|
44
|
+
for a pull request is the opener. Later updates never replace it. When the
|
|
45
|
+
create has no Junior identity, the first person who asks Junior to update the
|
|
46
|
+
pull request is the opener. A retry of the same tool call saves the opener
|
|
47
|
+
again, in case the first call stopped before it did.
|
|
48
|
+
|
|
49
|
+
Pull request events have two kinds of people fields. `openerUsername`,
|
|
50
|
+
`openerEmail`, and `openerRole` name who opened the pull request. On a pull
|
|
51
|
+
request that Junior's bot opened, the opener is the person who asked Junior to
|
|
52
|
+
open it: the linked GitHub login of the saved opener row. With no saved row, no
|
|
53
|
+
linked GitHub login, or a failed identity lookup, the opener is unknown and the
|
|
54
|
+
event has no opener fields, so filters on them do not match. The bot is never
|
|
55
|
+
used in its place. An `opened` event can arrive before the create tool saves
|
|
56
|
+
the row. `authors` lists the GitHub logins of the commit authors and of the
|
|
57
|
+
`Co-authored-by` trailers with GitHub noreply emails, bots included. Webhooks
|
|
58
|
+
never read the pull request body.
|
|
59
|
+
|
|
60
|
+
The opener on Junior's pull requests, `openerRole`, and `authors` need database
|
|
61
|
+
or GitHub calls. A webhook loads the values that a Watch or event automation
|
|
62
|
+
filters on before it decides on a match. It loads the other values only when an
|
|
63
|
+
event matches, so the agent sees all of them. A failed load leaves the value
|
|
64
|
+
out. `authors` and the people involved in approvals and merges share one read of
|
|
65
|
+
the commits per delivery.
|
|
66
|
+
|
|
67
|
+
Deployment events come from GitHub `deployment` and `deployment_status`
|
|
68
|
+
webhooks:
|
|
69
|
+
|
|
70
|
+
| Event | GitHub source |
|
|
71
|
+
| ------------------------ | --------------------------- |
|
|
72
|
+
| `deployment.created` | `deployment` with `created` |
|
|
73
|
+
| `deployment.queued` | status `queued` |
|
|
74
|
+
| `deployment.pending` | status `pending` |
|
|
75
|
+
| `deployment.in_progress` | status `in_progress` |
|
|
76
|
+
| `deployment.succeeded` | status `success` |
|
|
77
|
+
| `deployment.failed` | status `failure` |
|
|
78
|
+
| `deployment.error` | status `error` |
|
|
79
|
+
|
|
80
|
+
GitHub has two failure states. `failure` means that the deployment ran and
|
|
81
|
+
failed. `error` means that the deploy tool reported an error. The deploy tool
|
|
82
|
+
sets the status, so the difference depends on that tool. Vercel
|
|
83
|
+
`deployment.error` is a failed deployment, so it is the same as GitHub
|
|
84
|
+
`deployment.failed`, not GitHub `deployment.error`. `succeeded`, `failed`, and
|
|
85
|
+
`error` end a watch on one commit and environment. Watches on a commit or a
|
|
86
|
+
repository stay active.
|
|
87
|
+
|
|
37
88
|
The plugin owns its signed webhook route, deployment, pull request, and release
|
|
38
89
|
events, and normalized pull request and issue outcome projections.
|
|
39
90
|
Those projections also feed native code-change records used by the dashboard
|
|
@@ -22,20 +22,23 @@ var GITHUB_DEPLOYMENT_SUGGESTED_EVENTS = [
|
|
|
22
22
|
var GITHUB_DEPLOYMENT_MATCH_FIELDS = eventMatchFieldsSchema.parse({
|
|
23
23
|
environment: {
|
|
24
24
|
kind: "string",
|
|
25
|
-
description: "lowercase deployment environment name, such as production"
|
|
25
|
+
description: "lowercase deployment environment name, such as production",
|
|
26
|
+
events: [...GITHUB_DEPLOYMENT_EVENTS]
|
|
26
27
|
},
|
|
27
28
|
workflowId: {
|
|
28
29
|
kind: "number",
|
|
29
|
-
description: "numeric GitHub Actions workflow id when a workflow created the deployment"
|
|
30
|
+
description: "numeric GitHub Actions workflow id when a workflow created the deployment",
|
|
31
|
+
events: [...GITHUB_DEPLOYMENT_EVENTS]
|
|
30
32
|
},
|
|
31
33
|
workflowPath: {
|
|
32
34
|
kind: "string",
|
|
33
|
-
description: "GitHub Actions workflow file, such as .github/workflows/deploy.yml, when a workflow created the deployment"
|
|
35
|
+
description: "GitHub Actions workflow file, such as .github/workflows/deploy.yml, when a workflow created the deployment",
|
|
36
|
+
events: [...GITHUB_DEPLOYMENT_EVENTS]
|
|
34
37
|
}
|
|
35
38
|
});
|
|
36
39
|
var GITHUB_DEPLOYMENT_SOURCE_IDENTIFIER = {
|
|
37
40
|
format: "deployment-source:owner/repo[:environment]:<full-commit-sha>",
|
|
38
|
-
pattern:
|
|
41
|
+
pattern: String.raw`^deployment-source:[^\s/:#]+\/[^\s/:#]+(?::[^\s:]+)?:[0-9a-f]+$`
|
|
39
42
|
};
|
|
40
43
|
function gitHubDeploymentSourceResource(input) {
|
|
41
44
|
const commitSha = input.commitSha.toLowerCase();
|
|
@@ -48,7 +51,7 @@ function gitHubDeploymentSourceResource(input) {
|
|
|
48
51
|
};
|
|
49
52
|
}
|
|
50
53
|
function gitHubDeploymentSourceSubscribable(input) {
|
|
51
|
-
if (!
|
|
54
|
+
if (!input.canSubscribe) return void 0;
|
|
52
55
|
return {
|
|
53
56
|
...gitHubDeploymentSourceResource(input),
|
|
54
57
|
suggestedEvents: GITHUB_DEPLOYMENT_SUGGESTED_EVENTS,
|
|
@@ -75,20 +78,23 @@ var GITHUB_ISSUE_SUGGESTED_EVENTS = [
|
|
|
75
78
|
var GITHUB_ISSUE_COMMENT_MATCH_FIELDS = eventMatchFieldsSchema2.parse({
|
|
76
79
|
mentionsBot: {
|
|
77
80
|
kind: "boolean",
|
|
78
|
-
description: "true when the issue comment mentions
|
|
81
|
+
description: "true when the issue comment mentions this GitHub App",
|
|
82
|
+
events: ["issue.comment.created"]
|
|
79
83
|
},
|
|
80
84
|
senderId: {
|
|
81
85
|
kind: "number",
|
|
82
|
-
description: "immutable numeric GitHub user id of the issue commenter; prefer over logins"
|
|
86
|
+
description: "immutable numeric GitHub user id of the issue commenter; prefer over logins",
|
|
87
|
+
events: ["issue.comment.created"]
|
|
83
88
|
},
|
|
84
89
|
senderLogin: {
|
|
85
90
|
kind: "string",
|
|
86
|
-
description: "GitHub login of the issue commenter; logins can be renamed"
|
|
91
|
+
description: "GitHub login of the issue commenter; logins can be renamed",
|
|
92
|
+
events: ["issue.comment.created"]
|
|
87
93
|
}
|
|
88
94
|
});
|
|
89
95
|
var GITHUB_ISSUE_IDENTIFIER = {
|
|
90
96
|
format: "owner/repo#number",
|
|
91
|
-
pattern:
|
|
97
|
+
pattern: String.raw`^[^\s/:#]+\/[^\s/:#]+#\d+$`
|
|
92
98
|
};
|
|
93
99
|
function gitHubIssueResource(input) {
|
|
94
100
|
return {
|
|
@@ -98,7 +104,7 @@ function gitHubIssueResource(input) {
|
|
|
98
104
|
};
|
|
99
105
|
}
|
|
100
106
|
function gitHubIssueSubscribable(input) {
|
|
101
|
-
if (!
|
|
107
|
+
if (!input.canSubscribe) return void 0;
|
|
102
108
|
return {
|
|
103
109
|
...gitHubIssueResource(input),
|
|
104
110
|
suggestedEvents: GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
@@ -163,30 +169,43 @@ var GITHUB_PULL_REQUEST_SUGGESTED_EVENTS = [
|
|
|
163
169
|
"pull_request.closed_unmerged"
|
|
164
170
|
];
|
|
165
171
|
var GITHUB_PULL_REQUEST_MATCH_FIELDS = eventMatchFieldsSchema3.parse({
|
|
166
|
-
|
|
172
|
+
authors: {
|
|
167
173
|
kind: "string",
|
|
168
|
-
|
|
174
|
+
list: true,
|
|
175
|
+
description: "GitHub logins of the commit authors and Co-authored-by people, including bots such as this GitHub App",
|
|
176
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
169
177
|
},
|
|
170
|
-
|
|
178
|
+
headBranch: {
|
|
171
179
|
kind: "string",
|
|
172
|
-
description: "
|
|
180
|
+
description: "head branch name from the webhook",
|
|
181
|
+
events: GITHUB_PULL_REQUEST_EVENTS.filter(
|
|
182
|
+
(eventType) => eventType !== "pull_request.comment.created"
|
|
183
|
+
)
|
|
184
|
+
},
|
|
185
|
+
isDraft: {
|
|
186
|
+
kind: "boolean",
|
|
187
|
+
description: "true when the pull request is a draft",
|
|
188
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
173
189
|
},
|
|
174
|
-
|
|
190
|
+
openerEmail: {
|
|
175
191
|
kind: "string",
|
|
176
|
-
description: "
|
|
192
|
+
description: "opener email when GitHub sends it; missing on pull requests that this GitHub App opened",
|
|
193
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
177
194
|
},
|
|
178
|
-
|
|
195
|
+
openerUsername: {
|
|
179
196
|
kind: "string",
|
|
180
|
-
description: "
|
|
197
|
+
description: "login of who opened the pull request; on pull requests that this GitHub App opened, the person who asked for it, missing until that person is saved",
|
|
198
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
181
199
|
},
|
|
182
|
-
|
|
183
|
-
kind: "
|
|
184
|
-
description: "
|
|
200
|
+
openerRole: {
|
|
201
|
+
kind: "string",
|
|
202
|
+
description: "opener's repository role: admin, maintain, write, triage, read, none (no access, such as most bots), or a custom role name",
|
|
203
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
185
204
|
}
|
|
186
205
|
});
|
|
187
206
|
var GITHUB_PULL_REQUEST_IDENTIFIER = {
|
|
188
207
|
format: "owner/repo#number",
|
|
189
|
-
pattern:
|
|
208
|
+
pattern: String.raw`^[^\s/:#]+\/[^\s/:#]+#\d+$`
|
|
190
209
|
};
|
|
191
210
|
function gitHubPullRequestResource(input) {
|
|
192
211
|
return {
|
|
@@ -196,7 +215,7 @@ function gitHubPullRequestResource(input) {
|
|
|
196
215
|
};
|
|
197
216
|
}
|
|
198
217
|
function gitHubPullRequestSubscribable(input) {
|
|
199
|
-
if (!
|
|
218
|
+
if (!input.canSubscribe) return void 0;
|
|
200
219
|
const omitted = new Set(input.omitSuggestedEvents ?? []);
|
|
201
220
|
const suggestedEvents = GITHUB_PULL_REQUEST_SUGGESTED_EVENTS.filter(
|
|
202
221
|
(eventType) => !omitted.has(eventType)
|
|
@@ -214,7 +233,7 @@ var GITHUB_RELEASE_EVENTS = ["release.published"];
|
|
|
214
233
|
var GITHUB_RELEASE_SUGGESTED_EVENTS = ["release.published"];
|
|
215
234
|
var GITHUB_RELEASE_SOURCE_IDENTIFIER = {
|
|
216
235
|
format: "release-source:owner/repo[:tag]",
|
|
217
|
-
pattern:
|
|
236
|
+
pattern: String.raw`^release-source:[^\s/:#]+\/[^\s/:#]+(?::[^\s:]+)?$`
|
|
218
237
|
};
|
|
219
238
|
function gitHubReleaseSourceResource(input) {
|
|
220
239
|
const repo = input.repo.toLowerCase();
|
|
@@ -226,7 +245,7 @@ function gitHubReleaseSourceResource(input) {
|
|
|
226
245
|
};
|
|
227
246
|
}
|
|
228
247
|
function gitHubReleaseSourceSubscribable(input) {
|
|
229
|
-
if (!
|
|
248
|
+
if (!input.canSubscribe) return void 0;
|
|
230
249
|
return {
|
|
231
250
|
...gitHubReleaseSourceResource(input),
|
|
232
251
|
suggestedEvents: GITHUB_RELEASE_SUGGESTED_EVENTS,
|
|
@@ -238,7 +257,7 @@ function gitHubReleaseSourceSubscribable(input) {
|
|
|
238
257
|
// src/events/repository.ts
|
|
239
258
|
var GITHUB_REPOSITORY_IDENTIFIER = {
|
|
240
259
|
format: "owner/repo",
|
|
241
|
-
pattern:
|
|
260
|
+
pattern: String.raw`^[^\s/:#]+\/[^\s/:#]+$`
|
|
242
261
|
};
|
|
243
262
|
function gitHubRepositoryResource(input) {
|
|
244
263
|
return {
|
|
@@ -247,21 +266,23 @@ function gitHubRepositoryResource(input) {
|
|
|
247
266
|
identifier: input.repo.toLowerCase()
|
|
248
267
|
};
|
|
249
268
|
}
|
|
269
|
+
var GITHUB_REPOSITORY_EVENTS = [
|
|
270
|
+
...GITHUB_DEPLOYMENT_EVENTS,
|
|
271
|
+
...GITHUB_ISSUE_EVENTS,
|
|
272
|
+
...GITHUB_PULL_REQUEST_EVENTS
|
|
273
|
+
];
|
|
274
|
+
var GITHUB_REPOSITORY_SUGGESTED_EVENTS = [
|
|
275
|
+
"issue.opened",
|
|
276
|
+
"pull_request.opened",
|
|
277
|
+
...GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
278
|
+
...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS
|
|
279
|
+
];
|
|
250
280
|
function gitHubRepositorySubscribable(input) {
|
|
251
|
-
if (!
|
|
281
|
+
if (!input.canSubscribe) return void 0;
|
|
252
282
|
return {
|
|
253
283
|
...gitHubRepositoryResource(input),
|
|
254
|
-
suggestedEvents: [
|
|
255
|
-
|
|
256
|
-
"pull_request.opened",
|
|
257
|
-
...GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
258
|
-
...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS
|
|
259
|
-
],
|
|
260
|
-
supportedEvents: [
|
|
261
|
-
...GITHUB_DEPLOYMENT_EVENTS,
|
|
262
|
-
...GITHUB_ISSUE_EVENTS,
|
|
263
|
-
...GITHUB_PULL_REQUEST_EVENTS
|
|
264
|
-
],
|
|
284
|
+
suggestedEvents: [...GITHUB_REPOSITORY_SUGGESTED_EVENTS],
|
|
285
|
+
supportedEvents: [...GITHUB_REPOSITORY_EVENTS],
|
|
265
286
|
type: "repository"
|
|
266
287
|
};
|
|
267
288
|
}
|
|
@@ -340,7 +361,7 @@ var USER_REFRESH_TIMEOUT_MS = 2e4;
|
|
|
340
361
|
var GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES = 64 * 1024;
|
|
341
362
|
var HTTP_READ_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
342
363
|
var USER_TOKEN_GRANTS = /* @__PURE__ */ new Set(["user-read", "user-write"]);
|
|
343
|
-
var CREATE_TOOL_ROUTING_GUIDANCE = "This is a
|
|
364
|
+
var CREATE_TOOL_ROUTING_GUIDANCE = "This is a tool-routing denial, not a GitHub permission failure. Do not ask the user for GitHub permissions; retry with the required tool.";
|
|
344
365
|
var USER_WRITE_REQUIREMENTS = [
|
|
345
366
|
"requesting GitHub user permission to perform this operation"
|
|
346
367
|
];
|
|
@@ -951,13 +972,7 @@ function createPermissionCache() {
|
|
|
951
972
|
};
|
|
952
973
|
}
|
|
953
974
|
|
|
954
|
-
// src/webhooks/
|
|
955
|
-
var CHECK_SUITE_PULL_REQUEST_MATCH_KEYS = /* @__PURE__ */ new Set([
|
|
956
|
-
"authorEmail",
|
|
957
|
-
"authorRole",
|
|
958
|
-
"authorUsername",
|
|
959
|
-
"isDraft"
|
|
960
|
-
]);
|
|
975
|
+
// src/webhooks/event-targets.ts
|
|
961
976
|
function gitHubEventKey(deliveryId, eventType) {
|
|
962
977
|
return `github:${deliveryId}:${eventType}`;
|
|
963
978
|
}
|
|
@@ -971,6 +986,14 @@ function pullRequestTargets(event, repo) {
|
|
|
971
986
|
}
|
|
972
987
|
];
|
|
973
988
|
}
|
|
989
|
+
|
|
990
|
+
// src/webhooks/check-suite.ts
|
|
991
|
+
var CHECK_SUITE_PULL_REQUEST_MATCH_KEYS = /* @__PURE__ */ new Set([
|
|
992
|
+
"isDraft",
|
|
993
|
+
"openerEmail",
|
|
994
|
+
"openerRole",
|
|
995
|
+
"openerUsername"
|
|
996
|
+
]);
|
|
974
997
|
var checkRunRepoRefSchema = z.object({
|
|
975
998
|
id: z.number(),
|
|
976
999
|
name: z.string().min(1),
|
|
@@ -1064,8 +1087,8 @@ function buildCheckSuiteEvent(args) {
|
|
|
1064
1087
|
};
|
|
1065
1088
|
if (pullRequestNumber !== void 0) data.pullRequest = pullRequestNumber;
|
|
1066
1089
|
if (typeof args.isDraft === "boolean") data.isDraft = args.isDraft;
|
|
1067
|
-
if (args.
|
|
1068
|
-
if (args.
|
|
1090
|
+
if (args.openerUsername) data.openerUsername = args.openerUsername;
|
|
1091
|
+
if (args.openerEmail) data.openerEmail = args.openerEmail;
|
|
1069
1092
|
if (args.headBranch) data.headBranch = args.headBranch;
|
|
1070
1093
|
if (args.headSha) data.headSha = args.headSha;
|
|
1071
1094
|
if (args.checkSuiteId !== void 0) data.checkSuiteId = args.checkSuiteId;
|
|
@@ -1174,8 +1197,8 @@ function normalizeCheckSuiteEvents(deliveryId, body, options) {
|
|
|
1174
1197
|
return pullRequestTargets(
|
|
1175
1198
|
buildCheckSuiteEvent({
|
|
1176
1199
|
...shared,
|
|
1177
|
-
...facts?.
|
|
1178
|
-
...facts?.
|
|
1200
|
+
...facts?.openerEmail ? { openerEmail: facts.openerEmail } : void 0,
|
|
1201
|
+
...facts?.openerUsername ? { openerUsername: facts.openerUsername } : void 0,
|
|
1179
1202
|
...pullRequestHeadBranch ? { headBranch: pullRequestHeadBranch } : void 0,
|
|
1180
1203
|
...typeof facts?.isDraft === "boolean" ? { isDraft: facts.isDraft } : void 0,
|
|
1181
1204
|
pullRequestNumber: pullRequest.number
|
|
@@ -1255,9 +1278,9 @@ function pullRequestFactsFromResponse(value) {
|
|
|
1255
1278
|
const user = value.user;
|
|
1256
1279
|
if (isRecord(user)) {
|
|
1257
1280
|
const username = typeof user.login === "string" ? user.login.trim() : void 0;
|
|
1258
|
-
if (username) facts.
|
|
1281
|
+
if (username) facts.openerUsername = username;
|
|
1259
1282
|
const email = typeof user.email === "string" ? user.email.trim() : void 0;
|
|
1260
|
-
if (email) facts.
|
|
1283
|
+
if (email) facts.openerEmail = email;
|
|
1261
1284
|
}
|
|
1262
1285
|
return Object.keys(facts).length > 0 ? facts : void 0;
|
|
1263
1286
|
}
|
|
@@ -1400,9 +1423,6 @@ function mentionsBotLogin(text, botEmail) {
|
|
|
1400
1423
|
}
|
|
1401
1424
|
|
|
1402
1425
|
// src/webhooks/events.ts
|
|
1403
|
-
function gitHubEventKey2(deliveryId, eventType) {
|
|
1404
|
-
return `github:${deliveryId}:${eventType}`;
|
|
1405
|
-
}
|
|
1406
1426
|
function pullRequestDraftData(draft) {
|
|
1407
1427
|
return typeof draft === "boolean" ? { isDraft: draft } : void 0;
|
|
1408
1428
|
}
|
|
@@ -1410,12 +1430,12 @@ function pullRequestHeadBranchData(headRef) {
|
|
|
1410
1430
|
const headBranch = headRef?.trim();
|
|
1411
1431
|
return headBranch ? { headBranch } : void 0;
|
|
1412
1432
|
}
|
|
1413
|
-
function
|
|
1433
|
+
function pullRequestOpenerData(user) {
|
|
1414
1434
|
const data = {};
|
|
1415
1435
|
const username = user?.login?.trim();
|
|
1416
|
-
if (username) data.
|
|
1436
|
+
if (username) data.openerUsername = username;
|
|
1417
1437
|
const email = user?.email?.trim();
|
|
1418
|
-
if (email) data.
|
|
1438
|
+
if (email) data.openerEmail = email;
|
|
1419
1439
|
return data;
|
|
1420
1440
|
}
|
|
1421
1441
|
function gitHubDoneBy(login) {
|
|
@@ -1430,16 +1450,6 @@ function pullRequestMatchData(parts) {
|
|
|
1430
1450
|
}
|
|
1431
1451
|
return Object.keys(data).length > 0 ? data : void 0;
|
|
1432
1452
|
}
|
|
1433
|
-
function pullRequestTargets2(event, repo) {
|
|
1434
|
-
const { terminal: _terminal, ...repositoryEvent } = event;
|
|
1435
|
-
return [
|
|
1436
|
-
event,
|
|
1437
|
-
{
|
|
1438
|
-
...repositoryEvent,
|
|
1439
|
-
identifier: gitHubRepositoryResource({ repo }).identifier
|
|
1440
|
-
}
|
|
1441
|
-
];
|
|
1442
|
-
}
|
|
1443
1453
|
var repositorySchema2 = z2.object({ full_name: z2.string().min(1) }).passthrough();
|
|
1444
1454
|
var deploymentSchema = z2.object({
|
|
1445
1455
|
created_at: z2.string().optional(),
|
|
@@ -1494,7 +1504,7 @@ function normalizeDeploymentEvent(deliveryId, body) {
|
|
|
1494
1504
|
const eventType = "deployment.created";
|
|
1495
1505
|
const { label } = gitHubDeploymentSourceResource(parsed);
|
|
1496
1506
|
return deploymentTargets(parsed).map(({ identifier }) => ({
|
|
1497
|
-
eventKey:
|
|
1507
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
1498
1508
|
eventType,
|
|
1499
1509
|
occurredAtMs: providerTime(parsed.createdAt) ?? Date.now(),
|
|
1500
1510
|
identifier,
|
|
@@ -1550,7 +1560,7 @@ function normalizeDeploymentStatusEvent(deliveryId, body) {
|
|
|
1550
1560
|
const { label } = gitHubDeploymentSourceResource(parsed);
|
|
1551
1561
|
return deploymentTargets(parsed).map(
|
|
1552
1562
|
({ completeOnTerminalEvent, identifier }) => ({
|
|
1553
|
-
eventKey:
|
|
1563
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
1554
1564
|
eventType,
|
|
1555
1565
|
occurredAtMs: providerTime(parsed.statusCreatedAt) ?? Date.now(),
|
|
1556
1566
|
identifier,
|
|
@@ -1621,7 +1631,7 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
|
1621
1631
|
const resource = gitHubPullRequestResource(input);
|
|
1622
1632
|
const data2 = pullRequestMatchData([
|
|
1623
1633
|
pullRequestDraftData(parsed.data.issue.draft),
|
|
1624
|
-
|
|
1634
|
+
pullRequestOpenerData(parsed.data.issue.user),
|
|
1625
1635
|
{
|
|
1626
1636
|
repo: input.repo,
|
|
1627
1637
|
pullRequest: input.number,
|
|
@@ -1629,9 +1639,9 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
|
1629
1639
|
commentKind: "conversation"
|
|
1630
1640
|
}
|
|
1631
1641
|
]);
|
|
1632
|
-
return
|
|
1642
|
+
return pullRequestTargets(
|
|
1633
1643
|
{
|
|
1634
|
-
eventKey:
|
|
1644
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
1635
1645
|
eventType,
|
|
1636
1646
|
occurredAtMs: Date.now(),
|
|
1637
1647
|
identifier: resource.identifier,
|
|
@@ -1659,7 +1669,7 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
|
1659
1669
|
data.mentionsBot = mentionsBotLogin(parsed.data.comment.body, botEmail);
|
|
1660
1670
|
}
|
|
1661
1671
|
return [issue, repository].map((resource) => ({
|
|
1662
|
-
eventKey:
|
|
1672
|
+
eventKey: gitHubEventKey(deliveryId, "issue.comment.created"),
|
|
1663
1673
|
eventType: "issue.comment.created",
|
|
1664
1674
|
occurredAtMs: Date.now(),
|
|
1665
1675
|
identifier: resource.identifier,
|
|
@@ -1705,7 +1715,7 @@ function normalizeIssueEvents(deliveryId, body) {
|
|
|
1705
1715
|
const untrustedText = issueEventText(parsed.data.issue);
|
|
1706
1716
|
return [
|
|
1707
1717
|
{
|
|
1708
|
-
eventKey:
|
|
1718
|
+
eventKey: gitHubEventKey(deliveryId, `issue.${state}`),
|
|
1709
1719
|
eventType: `issue.${state}`,
|
|
1710
1720
|
occurredAtMs,
|
|
1711
1721
|
identifier: issue.identifier,
|
|
@@ -1713,7 +1723,7 @@ function normalizeIssueEvents(deliveryId, body) {
|
|
|
1713
1723
|
...untrustedText ? { untrustedText } : void 0
|
|
1714
1724
|
},
|
|
1715
1725
|
{
|
|
1716
|
-
eventKey:
|
|
1726
|
+
eventKey: gitHubEventKey(deliveryId, `issue.${state}`),
|
|
1717
1727
|
eventType: `issue.${state}`,
|
|
1718
1728
|
occurredAtMs,
|
|
1719
1729
|
identifier: repository.identifier,
|
|
@@ -1755,7 +1765,7 @@ function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
|
|
|
1755
1765
|
const author = parsed.data.comment.user?.login;
|
|
1756
1766
|
const data = pullRequestMatchData([
|
|
1757
1767
|
pullRequestDraftData(parsed.data.pull_request.draft),
|
|
1758
|
-
|
|
1768
|
+
pullRequestOpenerData(parsed.data.pull_request.user),
|
|
1759
1769
|
pullRequestHeadBranchData(parsed.data.pull_request.head?.ref),
|
|
1760
1770
|
{
|
|
1761
1771
|
repo,
|
|
@@ -1764,9 +1774,9 @@ function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
|
|
|
1764
1774
|
commentKind: "review"
|
|
1765
1775
|
}
|
|
1766
1776
|
]);
|
|
1767
|
-
return
|
|
1777
|
+
return pullRequestTargets(
|
|
1768
1778
|
{
|
|
1769
|
-
eventKey:
|
|
1779
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
1770
1780
|
eventType,
|
|
1771
1781
|
occurredAtMs: Date.now(),
|
|
1772
1782
|
identifier: resource.identifier,
|
|
@@ -1813,11 +1823,11 @@ function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
|
|
|
1813
1823
|
const reviewer = parsed.data.review.user?.login;
|
|
1814
1824
|
const data = pullRequestMatchData([
|
|
1815
1825
|
pullRequestDraftData(parsed.data.pull_request.draft),
|
|
1816
|
-
|
|
1826
|
+
pullRequestOpenerData(parsed.data.pull_request.user),
|
|
1817
1827
|
pullRequestHeadBranchData(parsed.data.pull_request.head?.ref)
|
|
1818
1828
|
]);
|
|
1819
1829
|
const event = {
|
|
1820
|
-
eventKey:
|
|
1830
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
1821
1831
|
eventType,
|
|
1822
1832
|
occurredAtMs: Date.now(),
|
|
1823
1833
|
identifier: resource.identifier,
|
|
@@ -1826,16 +1836,16 @@ function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
|
|
|
1826
1836
|
...data ? { data } : void 0,
|
|
1827
1837
|
untrustedText: parsed.data.review.body ?? void 0
|
|
1828
1838
|
};
|
|
1829
|
-
const events =
|
|
1839
|
+
const events = pullRequestTargets(event, repo);
|
|
1830
1840
|
if (eventType !== "pull_request.review.approved" || !parsed.data.review.body?.trim()) {
|
|
1831
1841
|
return events;
|
|
1832
1842
|
}
|
|
1833
1843
|
return [
|
|
1834
1844
|
...events,
|
|
1835
|
-
...
|
|
1845
|
+
...pullRequestTargets(
|
|
1836
1846
|
{
|
|
1837
1847
|
...event,
|
|
1838
|
-
eventKey:
|
|
1848
|
+
eventKey: gitHubEventKey(deliveryId, "pull_request.review.commented"),
|
|
1839
1849
|
eventType: "pull_request.review.commented"
|
|
1840
1850
|
},
|
|
1841
1851
|
repo
|
|
@@ -1879,15 +1889,15 @@ function pullRequestEventText(pullRequest) {
|
|
|
1879
1889
|
function pullRequestLifecycleEvents(input) {
|
|
1880
1890
|
const data = pullRequestMatchData([
|
|
1881
1891
|
pullRequestDraftData(input.isDraft),
|
|
1882
|
-
|
|
1883
|
-
email: input.
|
|
1884
|
-
login: input.
|
|
1892
|
+
pullRequestOpenerData({
|
|
1893
|
+
email: input.openerEmail,
|
|
1894
|
+
login: input.openerUsername
|
|
1885
1895
|
}),
|
|
1886
1896
|
pullRequestHeadBranchData(input.headBranch)
|
|
1887
1897
|
]);
|
|
1888
|
-
return
|
|
1898
|
+
return pullRequestTargets(
|
|
1889
1899
|
{
|
|
1890
|
-
eventKey:
|
|
1900
|
+
eventKey: gitHubEventKey(input.deliveryId, input.eventType),
|
|
1891
1901
|
eventType: input.eventType,
|
|
1892
1902
|
occurredAtMs: input.occurredAtMs,
|
|
1893
1903
|
identifier: input.resource.identifier,
|
|
@@ -1909,7 +1919,7 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1909
1919
|
});
|
|
1910
1920
|
const draft = parsed.data.pull_request.draft;
|
|
1911
1921
|
const isDraft = typeof draft === "boolean" ? draft : void 0;
|
|
1912
|
-
const
|
|
1922
|
+
const opener = pullRequestOpenerData(parsed.data.pull_request.user);
|
|
1913
1923
|
const headBranch = pullRequestHeadBranchData(
|
|
1914
1924
|
parsed.data.pull_request.head?.ref
|
|
1915
1925
|
)?.headBranch;
|
|
@@ -1917,7 +1927,7 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1917
1927
|
if (parsed.data.action === "opened") {
|
|
1918
1928
|
const openedAtMs = providerTime(parsed.data.pull_request.created_at) ?? Date.now();
|
|
1919
1929
|
const events = pullRequestLifecycleEvents({
|
|
1920
|
-
...
|
|
1930
|
+
...opener,
|
|
1921
1931
|
deliveryId,
|
|
1922
1932
|
eventType: "pull_request.opened",
|
|
1923
1933
|
...headBranch ? { headBranch } : void 0,
|
|
@@ -1931,7 +1941,7 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1931
1941
|
if (draft !== true) {
|
|
1932
1942
|
events.push(
|
|
1933
1943
|
...pullRequestLifecycleEvents({
|
|
1934
|
-
...
|
|
1944
|
+
...opener,
|
|
1935
1945
|
deliveryId,
|
|
1936
1946
|
eventType: "pull_request.ready_for_review",
|
|
1937
1947
|
...headBranch ? { headBranch } : void 0,
|
|
@@ -1948,7 +1958,7 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1948
1958
|
}
|
|
1949
1959
|
if (parsed.data.action === "ready_for_review") {
|
|
1950
1960
|
return pullRequestLifecycleEvents({
|
|
1951
|
-
...
|
|
1961
|
+
...opener,
|
|
1952
1962
|
deliveryId,
|
|
1953
1963
|
eventType: "pull_request.ready_for_review",
|
|
1954
1964
|
...headBranch ? { headBranch } : void 0,
|
|
@@ -1963,7 +1973,7 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1963
1973
|
if (parsed.data.action !== "closed") return [];
|
|
1964
1974
|
const eventType = parsed.data.pull_request.merged ? "pull_request.merged" : "pull_request.closed_unmerged";
|
|
1965
1975
|
return pullRequestLifecycleEvents({
|
|
1966
|
-
...
|
|
1976
|
+
...opener,
|
|
1967
1977
|
deliveryId,
|
|
1968
1978
|
eventType,
|
|
1969
1979
|
...headBranch ? { headBranch } : void 0,
|
|
@@ -2017,7 +2027,7 @@ function normalizeReleaseEvent(deliveryId, body) {
|
|
|
2017
2027
|
const untrustedText = untrustedParts.length > 0 ? untrustedParts.join("\n\n") : void 0;
|
|
2018
2028
|
return releaseSourceTargets({ repo, tag }).map(
|
|
2019
2029
|
({ completeOnTerminalEvent, resource }) => ({
|
|
2020
|
-
eventKey:
|
|
2030
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
2021
2031
|
eventType,
|
|
2022
2032
|
occurredAtMs: providerTime(parsed.data.release.published_at) ?? Date.now(),
|
|
2023
2033
|
identifier: resource.identifier,
|
|
@@ -2093,6 +2103,8 @@ export {
|
|
|
2093
2103
|
GITHUB_RELEASE_SOURCE_IDENTIFIER,
|
|
2094
2104
|
gitHubReleaseSourceSubscribable,
|
|
2095
2105
|
GITHUB_REPOSITORY_IDENTIFIER,
|
|
2106
|
+
GITHUB_REPOSITORY_EVENTS,
|
|
2107
|
+
GITHUB_REPOSITORY_SUGGESTED_EVENTS,
|
|
2096
2108
|
gitHubRepositorySubscribable,
|
|
2097
2109
|
botLoginFromEmail,
|
|
2098
2110
|
isBotLogin,
|
|
@@ -47,7 +47,7 @@ export declare const GITHUB_AUTH_TOKEN_PLACEHOLDER = "ghp_host_managed_credentia
|
|
|
47
47
|
export declare const GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES: number;
|
|
48
48
|
export declare const HTTP_READ_METHODS: Set<string>;
|
|
49
49
|
export declare const USER_TOKEN_GRANTS: Set<string>;
|
|
50
|
-
export declare const CREATE_TOOL_ROUTING_GUIDANCE = "This is a
|
|
50
|
+
export declare const CREATE_TOOL_ROUTING_GUIDANCE = "This is a tool-routing denial, not a GitHub permission failure. Do not ask the user for GitHub permissions; retry with the required tool.";
|
|
51
51
|
export declare const USER_WRITE_REQUIREMENTS: string[];
|
|
52
52
|
export declare class GitHubPluginSetupError extends Error {
|
|
53
53
|
constructor(message: string);
|