@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
|
@@ -1,10 +1,38 @@
|
|
|
1
1
|
// src/webhooks/events.ts
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as z4 } from "zod";
|
|
3
3
|
|
|
4
4
|
// src/events/deployment.ts
|
|
5
|
+
import {
|
|
6
|
+
eventMatchFieldsSchema as eventMatchFieldsSchema2
|
|
7
|
+
} from "@sentry/junior-plugin-api";
|
|
8
|
+
|
|
9
|
+
// src/events/scope.ts
|
|
5
10
|
import {
|
|
6
11
|
eventMatchFieldsSchema
|
|
7
12
|
} from "@sentry/junior-plugin-api";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
var gitHubRepoDataSchema = z.string().min(1).toLowerCase();
|
|
15
|
+
var gitHubCommitShaDataSchema = z.string().regex(/^[0-9a-f]{40}$/i).toLowerCase();
|
|
16
|
+
function gitHubRepoMatchFields(events) {
|
|
17
|
+
return eventMatchFieldsSchema.parse({
|
|
18
|
+
repo: {
|
|
19
|
+
kind: "string",
|
|
20
|
+
description: "lowercase repository as owner/repo, such as getsentry/junior",
|
|
21
|
+
events
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function gitHubCommitMatchFields(events) {
|
|
26
|
+
return eventMatchFieldsSchema.parse({
|
|
27
|
+
commitSha: {
|
|
28
|
+
kind: "string",
|
|
29
|
+
description: "full lowercase Git commit SHA",
|
|
30
|
+
events
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/events/deployment.ts
|
|
8
36
|
var GITHUB_DEPLOYMENT_EVENTS = [
|
|
9
37
|
"deployment.created",
|
|
10
38
|
"deployment.queued",
|
|
@@ -19,18 +47,28 @@ var GITHUB_DEPLOYMENT_SUGGESTED_EVENTS = [
|
|
|
19
47
|
"deployment.failed",
|
|
20
48
|
"deployment.error"
|
|
21
49
|
];
|
|
22
|
-
var GITHUB_DEPLOYMENT_MATCH_FIELDS =
|
|
50
|
+
var GITHUB_DEPLOYMENT_MATCH_FIELDS = eventMatchFieldsSchema2.parse({
|
|
51
|
+
...gitHubRepoMatchFields(GITHUB_DEPLOYMENT_EVENTS),
|
|
52
|
+
...gitHubCommitMatchFields(GITHUB_DEPLOYMENT_EVENTS),
|
|
53
|
+
deploymentId: {
|
|
54
|
+
kind: "number",
|
|
55
|
+
description: "numeric GitHub deployment id, such as 3001",
|
|
56
|
+
events: [...GITHUB_DEPLOYMENT_EVENTS]
|
|
57
|
+
},
|
|
23
58
|
environment: {
|
|
24
59
|
kind: "string",
|
|
25
|
-
description: "lowercase deployment environment name, such as production"
|
|
60
|
+
description: "lowercase deployment environment name, such as production",
|
|
61
|
+
events: [...GITHUB_DEPLOYMENT_EVENTS]
|
|
26
62
|
},
|
|
27
63
|
workflowId: {
|
|
28
64
|
kind: "number",
|
|
29
|
-
description: "numeric GitHub Actions workflow id when a workflow created the deployment"
|
|
65
|
+
description: "numeric GitHub Actions workflow id when a workflow created the deployment",
|
|
66
|
+
events: [...GITHUB_DEPLOYMENT_EVENTS]
|
|
30
67
|
},
|
|
31
68
|
workflowPath: {
|
|
32
69
|
kind: "string",
|
|
33
|
-
description: "GitHub Actions workflow file, such as .github/workflows/deploy.yml, when a workflow created the deployment"
|
|
70
|
+
description: "GitHub Actions workflow file, such as .github/workflows/deploy.yml, when a workflow created the deployment",
|
|
71
|
+
events: [...GITHUB_DEPLOYMENT_EVENTS]
|
|
34
72
|
}
|
|
35
73
|
});
|
|
36
74
|
var GITHUB_DEPLOYMENT_SOURCE_IDENTIFIER = {
|
|
@@ -48,7 +86,7 @@ function gitHubDeploymentSourceResource(input) {
|
|
|
48
86
|
};
|
|
49
87
|
}
|
|
50
88
|
function gitHubDeploymentSourceSubscribable(input) {
|
|
51
|
-
if (!
|
|
89
|
+
if (!input.canSubscribe) return void 0;
|
|
52
90
|
return {
|
|
53
91
|
...gitHubDeploymentSourceResource(input),
|
|
54
92
|
suggestedEvents: GITHUB_DEPLOYMENT_SUGGESTED_EVENTS,
|
|
@@ -59,8 +97,34 @@ function gitHubDeploymentSourceSubscribable(input) {
|
|
|
59
97
|
|
|
60
98
|
// src/events/issue.ts
|
|
61
99
|
import {
|
|
62
|
-
eventMatchFieldsSchema as
|
|
100
|
+
eventMatchFieldsSchema as eventMatchFieldsSchema4
|
|
63
101
|
} from "@sentry/junior-plugin-api";
|
|
102
|
+
|
|
103
|
+
// src/events/comment.ts
|
|
104
|
+
import {
|
|
105
|
+
eventMatchFieldsSchema as eventMatchFieldsSchema3
|
|
106
|
+
} from "@sentry/junior-plugin-api";
|
|
107
|
+
function gitHubCommentMatchFields(events) {
|
|
108
|
+
return eventMatchFieldsSchema3.parse({
|
|
109
|
+
mentionsBot: {
|
|
110
|
+
kind: "boolean",
|
|
111
|
+
description: "true when the comment or review mentions this GitHub App",
|
|
112
|
+
events
|
|
113
|
+
},
|
|
114
|
+
senderId: {
|
|
115
|
+
kind: "number",
|
|
116
|
+
description: "immutable numeric GitHub user id of who wrote the comment or review; prefer over logins",
|
|
117
|
+
events
|
|
118
|
+
},
|
|
119
|
+
senderLogin: {
|
|
120
|
+
kind: "string",
|
|
121
|
+
description: "GitHub login of who wrote the comment or review; logins can be renamed",
|
|
122
|
+
events
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/events/issue.ts
|
|
64
128
|
var GITHUB_ISSUE_EVENTS = [
|
|
65
129
|
"issue.comment.created",
|
|
66
130
|
"issue.opened",
|
|
@@ -72,18 +136,13 @@ var GITHUB_ISSUE_SUGGESTED_EVENTS = [
|
|
|
72
136
|
"issue.closed",
|
|
73
137
|
"issue.reopened"
|
|
74
138
|
];
|
|
75
|
-
var
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
},
|
|
80
|
-
senderId: {
|
|
139
|
+
var GITHUB_ISSUE_MATCH_FIELDS = eventMatchFieldsSchema4.parse({
|
|
140
|
+
...gitHubCommentMatchFields(["issue.comment.created"]),
|
|
141
|
+
...gitHubRepoMatchFields(GITHUB_ISSUE_EVENTS),
|
|
142
|
+
issue: {
|
|
81
143
|
kind: "number",
|
|
82
|
-
description: "
|
|
83
|
-
|
|
84
|
-
senderLogin: {
|
|
85
|
-
kind: "string",
|
|
86
|
-
description: "GitHub login of the issue commenter; logins can be renamed"
|
|
144
|
+
description: "issue number, such as 12",
|
|
145
|
+
events: GITHUB_ISSUE_EVENTS
|
|
87
146
|
}
|
|
88
147
|
});
|
|
89
148
|
var GITHUB_ISSUE_IDENTIFIER = {
|
|
@@ -98,7 +157,7 @@ function gitHubIssueResource(input) {
|
|
|
98
157
|
};
|
|
99
158
|
}
|
|
100
159
|
function gitHubIssueSubscribable(input) {
|
|
101
|
-
if (!
|
|
160
|
+
if (!input.canSubscribe) return void 0;
|
|
102
161
|
return {
|
|
103
162
|
...gitHubIssueResource(input),
|
|
104
163
|
suggestedEvents: GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
@@ -109,7 +168,7 @@ function gitHubIssueSubscribable(input) {
|
|
|
109
168
|
|
|
110
169
|
// src/events/pull-request.ts
|
|
111
170
|
import {
|
|
112
|
-
eventMatchFieldsSchema as
|
|
171
|
+
eventMatchFieldsSchema as eventMatchFieldsSchema5
|
|
113
172
|
} from "@sentry/junior-plugin-api";
|
|
114
173
|
var GITHUB_PULL_REQUEST_EVENTS = [
|
|
115
174
|
"pull_request.checks.failed",
|
|
@@ -162,26 +221,58 @@ var GITHUB_PULL_REQUEST_SUGGESTED_EVENTS = [
|
|
|
162
221
|
"pull_request.merged",
|
|
163
222
|
"pull_request.closed_unmerged"
|
|
164
223
|
];
|
|
165
|
-
var
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
224
|
+
var GITHUB_PULL_REQUEST_COMMENT_EVENTS = [
|
|
225
|
+
"pull_request.comment.created",
|
|
226
|
+
"pull_request.review.approved",
|
|
227
|
+
"pull_request.review.changes_requested",
|
|
228
|
+
"pull_request.review.commented",
|
|
229
|
+
"pull_request.review_comment.created"
|
|
230
|
+
];
|
|
231
|
+
var GITHUB_PULL_REQUEST_CHECK_EVENTS = [
|
|
232
|
+
"pull_request.checks.failed",
|
|
233
|
+
"pull_request.checks.recovered"
|
|
234
|
+
];
|
|
235
|
+
var GITHUB_PULL_REQUEST_MATCH_FIELDS = eventMatchFieldsSchema5.parse({
|
|
236
|
+
...gitHubCommentMatchFields(GITHUB_PULL_REQUEST_COMMENT_EVENTS),
|
|
237
|
+
...gitHubRepoMatchFields(GITHUB_PULL_REQUEST_EVENTS),
|
|
238
|
+
...gitHubCommitMatchFields(GITHUB_PULL_REQUEST_CHECK_EVENTS),
|
|
239
|
+
pullRequest: {
|
|
240
|
+
kind: "number",
|
|
241
|
+
description: "pull request number, such as 946",
|
|
242
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
173
243
|
},
|
|
174
|
-
|
|
244
|
+
authors: {
|
|
175
245
|
kind: "string",
|
|
176
|
-
|
|
246
|
+
list: true,
|
|
247
|
+
description: "GitHub logins of the commit authors and Co-authored-by people, including bots such as this GitHub App",
|
|
248
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
177
249
|
},
|
|
178
250
|
headBranch: {
|
|
179
251
|
kind: "string",
|
|
180
|
-
description: "head branch name from the webhook"
|
|
252
|
+
description: "head branch name from the webhook",
|
|
253
|
+
events: GITHUB_PULL_REQUEST_EVENTS.filter(
|
|
254
|
+
(eventType) => eventType !== "pull_request.comment.created"
|
|
255
|
+
)
|
|
181
256
|
},
|
|
182
257
|
isDraft: {
|
|
183
258
|
kind: "boolean",
|
|
184
|
-
description: "true when the pull request is a draft"
|
|
259
|
+
description: "true when the pull request is a draft",
|
|
260
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
261
|
+
},
|
|
262
|
+
openerEmail: {
|
|
263
|
+
kind: "string",
|
|
264
|
+
description: "opener email when GitHub sends it; missing on pull requests that this GitHub App opened",
|
|
265
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
266
|
+
},
|
|
267
|
+
openerUsername: {
|
|
268
|
+
kind: "string",
|
|
269
|
+
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",
|
|
270
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
271
|
+
},
|
|
272
|
+
openerRole: {
|
|
273
|
+
kind: "string",
|
|
274
|
+
description: "opener's repository role: admin, maintain, write, triage, read, none (no access, such as most bots), or a custom role name",
|
|
275
|
+
events: [...GITHUB_PULL_REQUEST_EVENTS]
|
|
185
276
|
}
|
|
186
277
|
});
|
|
187
278
|
var GITHUB_PULL_REQUEST_IDENTIFIER = {
|
|
@@ -196,7 +287,7 @@ function gitHubPullRequestResource(input) {
|
|
|
196
287
|
};
|
|
197
288
|
}
|
|
198
289
|
function gitHubPullRequestSubscribable(input) {
|
|
199
|
-
if (!
|
|
290
|
+
if (!input.canSubscribe) return void 0;
|
|
200
291
|
const omitted = new Set(input.omitSuggestedEvents ?? []);
|
|
201
292
|
const suggestedEvents = GITHUB_PULL_REQUEST_SUGGESTED_EVENTS.filter(
|
|
202
293
|
(eventType) => !omitted.has(eventType)
|
|
@@ -210,7 +301,22 @@ function gitHubPullRequestSubscribable(input) {
|
|
|
210
301
|
}
|
|
211
302
|
|
|
212
303
|
// src/events/release.ts
|
|
304
|
+
import {
|
|
305
|
+
eventMatchFieldsSchema as eventMatchFieldsSchema6
|
|
306
|
+
} from "@sentry/junior-plugin-api";
|
|
307
|
+
import { z as z2 } from "zod";
|
|
213
308
|
var GITHUB_RELEASE_EVENTS = ["release.published"];
|
|
309
|
+
var gitHubReleaseTagDataSchema = z2.string().trim().min(1).transform(
|
|
310
|
+
(tag) => tag.replace(/[A-Z]+/g, (letters) => letters.toLowerCase())
|
|
311
|
+
);
|
|
312
|
+
var GITHUB_RELEASE_MATCH_FIELDS = eventMatchFieldsSchema6.parse({
|
|
313
|
+
...gitHubRepoMatchFields(GITHUB_RELEASE_EVENTS),
|
|
314
|
+
tag: {
|
|
315
|
+
kind: "string",
|
|
316
|
+
description: "release tag with ASCII letters in lowercase, such as v1.2.0 or release/1.0",
|
|
317
|
+
events: [...GITHUB_RELEASE_EVENTS]
|
|
318
|
+
}
|
|
319
|
+
});
|
|
214
320
|
var GITHUB_RELEASE_SUGGESTED_EVENTS = ["release.published"];
|
|
215
321
|
var GITHUB_RELEASE_SOURCE_IDENTIFIER = {
|
|
216
322
|
format: "release-source:owner/repo[:tag]",
|
|
@@ -226,7 +332,7 @@ function gitHubReleaseSourceResource(input) {
|
|
|
226
332
|
};
|
|
227
333
|
}
|
|
228
334
|
function gitHubReleaseSourceSubscribable(input) {
|
|
229
|
-
if (!
|
|
335
|
+
if (!input.canSubscribe) return void 0;
|
|
230
336
|
return {
|
|
231
337
|
...gitHubReleaseSourceResource(input),
|
|
232
338
|
suggestedEvents: GITHUB_RELEASE_SUGGESTED_EVENTS,
|
|
@@ -247,27 +353,29 @@ function gitHubRepositoryResource(input) {
|
|
|
247
353
|
identifier: input.repo.toLowerCase()
|
|
248
354
|
};
|
|
249
355
|
}
|
|
356
|
+
var GITHUB_REPOSITORY_EVENTS = [
|
|
357
|
+
...GITHUB_DEPLOYMENT_EVENTS,
|
|
358
|
+
...GITHUB_ISSUE_EVENTS,
|
|
359
|
+
...GITHUB_PULL_REQUEST_EVENTS
|
|
360
|
+
];
|
|
361
|
+
var GITHUB_REPOSITORY_SUGGESTED_EVENTS = [
|
|
362
|
+
"issue.opened",
|
|
363
|
+
"pull_request.opened",
|
|
364
|
+
...GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
365
|
+
...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS
|
|
366
|
+
];
|
|
250
367
|
function gitHubRepositorySubscribable(input) {
|
|
251
|
-
if (!
|
|
368
|
+
if (!input.canSubscribe) return void 0;
|
|
252
369
|
return {
|
|
253
370
|
...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
|
-
],
|
|
371
|
+
suggestedEvents: [...GITHUB_REPOSITORY_SUGGESTED_EVENTS],
|
|
372
|
+
supportedEvents: [...GITHUB_REPOSITORY_EVENTS],
|
|
265
373
|
type: "repository"
|
|
266
374
|
};
|
|
267
375
|
}
|
|
268
376
|
|
|
269
377
|
// src/webhooks/check-suite.ts
|
|
270
|
-
import { z } from "zod";
|
|
378
|
+
import { z as z3 } from "zod";
|
|
271
379
|
|
|
272
380
|
// src/credential-support.ts
|
|
273
381
|
import { createPrivateKey, createSign } from "crypto";
|
|
@@ -340,7 +448,7 @@ var USER_REFRESH_TIMEOUT_MS = 2e4;
|
|
|
340
448
|
var GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES = 64 * 1024;
|
|
341
449
|
var HTTP_READ_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS"]);
|
|
342
450
|
var USER_TOKEN_GRANTS = /* @__PURE__ */ new Set(["user-read", "user-write"]);
|
|
343
|
-
var CREATE_TOOL_ROUTING_GUIDANCE = "This is a
|
|
451
|
+
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
452
|
var USER_WRITE_REQUIREMENTS = [
|
|
345
453
|
"requesting GitHub user permission to perform this operation"
|
|
346
454
|
];
|
|
@@ -951,13 +1059,12 @@ function createPermissionCache() {
|
|
|
951
1059
|
};
|
|
952
1060
|
}
|
|
953
1061
|
|
|
954
|
-
// src/webhooks/
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
]);
|
|
1062
|
+
// src/webhooks/event-targets.ts
|
|
1063
|
+
function definedValues(data) {
|
|
1064
|
+
return Object.fromEntries(
|
|
1065
|
+
Object.entries(data).filter(([, value]) => value !== void 0)
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
961
1068
|
function gitHubEventKey(deliveryId, eventType) {
|
|
962
1069
|
return `github:${deliveryId}:${eventType}`;
|
|
963
1070
|
}
|
|
@@ -971,48 +1078,56 @@ function pullRequestTargets(event, repo) {
|
|
|
971
1078
|
}
|
|
972
1079
|
];
|
|
973
1080
|
}
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1081
|
+
|
|
1082
|
+
// src/webhooks/check-suite.ts
|
|
1083
|
+
var CHECK_SUITE_PULL_REQUEST_MATCH_KEYS = /* @__PURE__ */ new Set([
|
|
1084
|
+
"isDraft",
|
|
1085
|
+
"openerEmail",
|
|
1086
|
+
"openerRole",
|
|
1087
|
+
"openerUsername"
|
|
1088
|
+
]);
|
|
1089
|
+
var checkRunRepoRefSchema = z3.object({
|
|
1090
|
+
id: z3.number(),
|
|
1091
|
+
name: z3.string().min(1),
|
|
1092
|
+
url: z3.string().min(1)
|
|
978
1093
|
}).passthrough();
|
|
979
|
-
var checkRunPullRequestSideSchema =
|
|
980
|
-
ref:
|
|
1094
|
+
var checkRunPullRequestSideSchema = z3.object({
|
|
1095
|
+
ref: z3.string().optional(),
|
|
981
1096
|
repo: checkRunRepoRefSchema,
|
|
982
|
-
sha:
|
|
1097
|
+
sha: z3.string().optional()
|
|
983
1098
|
}).passthrough();
|
|
984
|
-
var checkRunPullRequestSchema =
|
|
1099
|
+
var checkRunPullRequestSchema = z3.object({
|
|
985
1100
|
base: checkRunPullRequestSideSchema,
|
|
986
1101
|
head: checkRunPullRequestSideSchema.optional(),
|
|
987
|
-
id:
|
|
988
|
-
number:
|
|
989
|
-
url:
|
|
1102
|
+
id: z3.number().optional(),
|
|
1103
|
+
number: z3.number(),
|
|
1104
|
+
url: z3.string().optional()
|
|
990
1105
|
}).passthrough();
|
|
991
|
-
var repositorySchema =
|
|
992
|
-
full_name:
|
|
993
|
-
id:
|
|
994
|
-
name:
|
|
995
|
-
owner:
|
|
1106
|
+
var repositorySchema = z3.object({
|
|
1107
|
+
full_name: z3.string().min(1),
|
|
1108
|
+
id: z3.number(),
|
|
1109
|
+
name: z3.string().min(1),
|
|
1110
|
+
owner: z3.object({ login: z3.string().min(1) }).passthrough()
|
|
996
1111
|
}).passthrough();
|
|
997
|
-
var checkSuiteWebhookSchema =
|
|
998
|
-
action:
|
|
999
|
-
check_suite:
|
|
1000
|
-
app:
|
|
1001
|
-
name:
|
|
1002
|
-
slug:
|
|
1112
|
+
var checkSuiteWebhookSchema = z3.object({
|
|
1113
|
+
action: z3.string(),
|
|
1114
|
+
check_suite: z3.object({
|
|
1115
|
+
app: z3.object({
|
|
1116
|
+
name: z3.string().optional().nullable(),
|
|
1117
|
+
slug: z3.string().optional().nullable()
|
|
1003
1118
|
}).optional().nullable(),
|
|
1004
|
-
conclusion:
|
|
1119
|
+
conclusion: z3.string().optional().nullable(),
|
|
1005
1120
|
/** Branch name for the suite head commit when GitHub sends it. */
|
|
1006
|
-
head_branch:
|
|
1007
|
-
head_sha:
|
|
1008
|
-
id:
|
|
1009
|
-
latest_check_runs_count:
|
|
1010
|
-
pull_requests:
|
|
1121
|
+
head_branch: z3.string().optional().nullable(),
|
|
1122
|
+
head_sha: z3.string().optional(),
|
|
1123
|
+
id: z3.number().optional(),
|
|
1124
|
+
latest_check_runs_count: z3.number().optional().nullable(),
|
|
1125
|
+
pull_requests: z3.array(checkRunPullRequestSchema)
|
|
1011
1126
|
}),
|
|
1012
1127
|
repository: repositorySchema
|
|
1013
1128
|
});
|
|
1014
|
-
var checkRunsListResponseSchema =
|
|
1015
|
-
check_runs:
|
|
1129
|
+
var checkRunsListResponseSchema = z3.object({
|
|
1130
|
+
check_runs: z3.array(z3.unknown()).optional()
|
|
1016
1131
|
}).passthrough();
|
|
1017
1132
|
function isCheckSuiteRepositoryPullRequest(pullRequest, repositoryId) {
|
|
1018
1133
|
return pullRequest.base.repo.id === repositoryId;
|
|
@@ -1046,6 +1161,29 @@ function checkSuiteHeadBranch(value) {
|
|
|
1046
1161
|
const branch = value?.trim();
|
|
1047
1162
|
return branch ? branch : void 0;
|
|
1048
1163
|
}
|
|
1164
|
+
var checkSuiteEventDataSchema = z3.object({
|
|
1165
|
+
repo: gitHubRepoDataSchema,
|
|
1166
|
+
pullRequest: z3.number().optional(),
|
|
1167
|
+
commitSha: gitHubCommitShaDataSchema.optional(),
|
|
1168
|
+
suiteConclusion: z3.string().min(1),
|
|
1169
|
+
isDraft: z3.boolean().optional(),
|
|
1170
|
+
openerUsername: z3.string().min(1).optional(),
|
|
1171
|
+
openerEmail: z3.string().min(1).optional(),
|
|
1172
|
+
headBranch: z3.string().min(1).optional(),
|
|
1173
|
+
checkSuiteId: z3.number().optional(),
|
|
1174
|
+
checkSuiteUrl: z3.string().min(1).optional(),
|
|
1175
|
+
appName: z3.string().min(1).optional(),
|
|
1176
|
+
latestCheckRunsCount: z3.number().optional(),
|
|
1177
|
+
// Only system-set handles. Check names come from workflow YAML, so they
|
|
1178
|
+
// go in the untrusted text.
|
|
1179
|
+
failingChecks: z3.array(
|
|
1180
|
+
z3.object({
|
|
1181
|
+
conclusion: z3.string(),
|
|
1182
|
+
htmlUrl: z3.string().optional(),
|
|
1183
|
+
checkRunId: z3.number()
|
|
1184
|
+
}).strict()
|
|
1185
|
+
).optional()
|
|
1186
|
+
}).strict();
|
|
1049
1187
|
function buildCheckSuiteEvent(args) {
|
|
1050
1188
|
const pullRequestNumber = args.pullRequestNumber;
|
|
1051
1189
|
const resource = pullRequestNumber === void 0 ? gitHubRepositoryResource({ repo: args.repo }) : gitHubPullRequestResource({
|
|
@@ -1057,36 +1195,32 @@ function buildCheckSuiteEvent(args) {
|
|
|
1057
1195
|
const failingCount = failingChecks.length;
|
|
1058
1196
|
const branchSuffix = args.headBranch ? ` on ${args.headBranch}` : "";
|
|
1059
1197
|
const trustedSummary = args.eventType === "pull_request.checks.failed" ? `${resource.label} checks failed${failingCount > 0 ? ` (${failingCount})` : ""}${shortSha ? ` for ${shortSha}` : ""}${branchSuffix}.` : `${resource.label} check suite recovered${shortSha ? ` for ${shortSha}` : ""}${branchSuffix}.`;
|
|
1060
|
-
const data =
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
if (args.checkSuiteId !== void 0) data.checkSuiteId = args.checkSuiteId;
|
|
1072
|
-
if (args.checkSuiteId !== void 0 && args.headSha) {
|
|
1073
|
-
data.checkSuiteUrl = buildCheckSuiteUrl({
|
|
1198
|
+
const data = checkSuiteEventDataSchema.parse(
|
|
1199
|
+
definedValues({
|
|
1200
|
+
repo: args.repo,
|
|
1201
|
+
pullRequest: pullRequestNumber,
|
|
1202
|
+
// A short SHA counts as missing, so a commitSha filter does not match.
|
|
1203
|
+
commitSha: gitHubCommitShaDataSchema.safeParse(args.headSha).data,
|
|
1204
|
+
suiteConclusion: args.suiteConclusion,
|
|
1205
|
+
isDraft: args.isDraft,
|
|
1206
|
+
openerUsername: args.openerUsername,
|
|
1207
|
+
openerEmail: args.openerEmail,
|
|
1208
|
+
headBranch: args.headBranch,
|
|
1074
1209
|
checkSuiteId: args.checkSuiteId,
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
}
|
|
1210
|
+
checkSuiteUrl: args.checkSuiteId !== void 0 && args.headSha ? buildCheckSuiteUrl({
|
|
1211
|
+
checkSuiteId: args.checkSuiteId,
|
|
1212
|
+
headSha: args.headSha,
|
|
1213
|
+
repo: args.repo
|
|
1214
|
+
}) : void 0,
|
|
1215
|
+
appName: args.appName ? oneLineLabel(args.appName, 120) : void 0,
|
|
1216
|
+
latestCheckRunsCount: args.latestCheckRunsCount,
|
|
1217
|
+
failingChecks: args.eventType === "pull_request.checks.failed" && failingCount > 0 ? failingChecks.map((check) => ({
|
|
1218
|
+
conclusion: check.conclusion,
|
|
1219
|
+
...check.htmlUrl ? { htmlUrl: check.htmlUrl } : void 0,
|
|
1220
|
+
checkRunId: check.checkRunId
|
|
1221
|
+
})) : void 0
|
|
1222
|
+
})
|
|
1223
|
+
);
|
|
1090
1224
|
const untrustedParts = args.eventType === "pull_request.checks.failed" ? failingChecks.map((check) => {
|
|
1091
1225
|
const name = oneLineLabel(check.name);
|
|
1092
1226
|
if (!name) return void 0;
|
|
@@ -1174,8 +1308,8 @@ function normalizeCheckSuiteEvents(deliveryId, body, options) {
|
|
|
1174
1308
|
return pullRequestTargets(
|
|
1175
1309
|
buildCheckSuiteEvent({
|
|
1176
1310
|
...shared,
|
|
1177
|
-
...facts?.
|
|
1178
|
-
...facts?.
|
|
1311
|
+
...facts?.openerEmail ? { openerEmail: facts.openerEmail } : void 0,
|
|
1312
|
+
...facts?.openerUsername ? { openerUsername: facts.openerUsername } : void 0,
|
|
1179
1313
|
...pullRequestHeadBranch ? { headBranch: pullRequestHeadBranch } : void 0,
|
|
1180
1314
|
...typeof facts?.isDraft === "boolean" ? { isDraft: facts.isDraft } : void 0,
|
|
1181
1315
|
pullRequestNumber: pullRequest.number
|
|
@@ -1255,9 +1389,9 @@ function pullRequestFactsFromResponse(value) {
|
|
|
1255
1389
|
const user = value.user;
|
|
1256
1390
|
if (isRecord(user)) {
|
|
1257
1391
|
const username = typeof user.login === "string" ? user.login.trim() : void 0;
|
|
1258
|
-
if (username) facts.
|
|
1392
|
+
if (username) facts.openerUsername = username;
|
|
1259
1393
|
const email = typeof user.email === "string" ? user.email.trim() : void 0;
|
|
1260
|
-
if (email) facts.
|
|
1394
|
+
if (email) facts.openerEmail = email;
|
|
1261
1395
|
}
|
|
1262
1396
|
return Object.keys(facts).length > 0 ? facts : void 0;
|
|
1263
1397
|
}
|
|
@@ -1400,73 +1534,40 @@ function mentionsBotLogin(text, botEmail) {
|
|
|
1400
1534
|
}
|
|
1401
1535
|
|
|
1402
1536
|
// src/webhooks/events.ts
|
|
1403
|
-
function gitHubEventKey2(deliveryId, eventType) {
|
|
1404
|
-
return `github:${deliveryId}:${eventType}`;
|
|
1405
|
-
}
|
|
1406
|
-
function pullRequestDraftData(draft) {
|
|
1407
|
-
return typeof draft === "boolean" ? { isDraft: draft } : void 0;
|
|
1408
|
-
}
|
|
1409
|
-
function pullRequestHeadBranchData(headRef) {
|
|
1410
|
-
const headBranch = headRef?.trim();
|
|
1411
|
-
return headBranch ? { headBranch } : void 0;
|
|
1412
|
-
}
|
|
1413
|
-
function pullRequestAuthorData(user) {
|
|
1414
|
-
const data = {};
|
|
1415
|
-
const username = user?.login?.trim();
|
|
1416
|
-
if (username) data.authorUsername = username;
|
|
1417
|
-
const email = user?.email?.trim();
|
|
1418
|
-
if (email) data.authorEmail = email;
|
|
1419
|
-
return data;
|
|
1420
|
-
}
|
|
1421
1537
|
function gitHubDoneBy(login) {
|
|
1422
1538
|
const handle = login?.trim();
|
|
1423
1539
|
return handle ? { doneBy: { provider: "github", handle } } : void 0;
|
|
1424
1540
|
}
|
|
1425
|
-
function
|
|
1426
|
-
|
|
1427
|
-
for (const part of parts) {
|
|
1428
|
-
if (!part) continue;
|
|
1429
|
-
Object.assign(data, part);
|
|
1430
|
-
}
|
|
1431
|
-
return Object.keys(data).length > 0 ? data : void 0;
|
|
1432
|
-
}
|
|
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
|
-
];
|
|
1541
|
+
function nonBlank(value) {
|
|
1542
|
+
return value?.trim() || void 0;
|
|
1442
1543
|
}
|
|
1443
|
-
var repositorySchema2 =
|
|
1444
|
-
var deploymentSchema =
|
|
1445
|
-
created_at:
|
|
1446
|
-
environment:
|
|
1447
|
-
id:
|
|
1448
|
-
sha:
|
|
1544
|
+
var repositorySchema2 = z4.object({ full_name: z4.string().min(1) }).passthrough();
|
|
1545
|
+
var deploymentSchema = z4.object({
|
|
1546
|
+
created_at: z4.string().optional(),
|
|
1547
|
+
environment: z4.string().trim().min(1),
|
|
1548
|
+
id: z4.number(),
|
|
1549
|
+
sha: z4.string().regex(/^[0-9a-f]{40}$/i)
|
|
1449
1550
|
}).passthrough();
|
|
1450
1551
|
var deploymentWorkflowSchema = {
|
|
1451
|
-
workflow:
|
|
1452
|
-
workflow_run:
|
|
1552
|
+
workflow: z4.object({ id: z4.number(), path: z4.string().min(1) }).passthrough().nullish(),
|
|
1553
|
+
workflow_run: z4.object({ id: z4.number() }).passthrough().nullish()
|
|
1453
1554
|
};
|
|
1454
|
-
var deploymentWebhookSchema =
|
|
1455
|
-
action:
|
|
1555
|
+
var deploymentWebhookSchema = z4.object({
|
|
1556
|
+
action: z4.string(),
|
|
1456
1557
|
deployment: deploymentSchema,
|
|
1457
1558
|
repository: repositorySchema2,
|
|
1458
1559
|
...deploymentWorkflowSchema
|
|
1459
1560
|
}).passthrough();
|
|
1460
|
-
var canonicalDeploymentEventSchema =
|
|
1461
|
-
action:
|
|
1462
|
-
commitSha:
|
|
1463
|
-
createdAt:
|
|
1464
|
-
deploymentId:
|
|
1465
|
-
environment:
|
|
1466
|
-
repo:
|
|
1467
|
-
workflowId:
|
|
1468
|
-
workflowPath:
|
|
1469
|
-
workflowRunId:
|
|
1561
|
+
var canonicalDeploymentEventSchema = z4.object({
|
|
1562
|
+
action: z4.string(),
|
|
1563
|
+
commitSha: z4.string().regex(/^[0-9a-f]{40}$/i),
|
|
1564
|
+
createdAt: z4.string().optional(),
|
|
1565
|
+
deploymentId: z4.number(),
|
|
1566
|
+
environment: z4.string().min(1),
|
|
1567
|
+
repo: z4.string().min(1),
|
|
1568
|
+
workflowId: z4.number().optional(),
|
|
1569
|
+
workflowPath: z4.string().min(1).optional(),
|
|
1570
|
+
workflowRunId: z4.number().optional()
|
|
1470
1571
|
}).strict();
|
|
1471
1572
|
function canonicalDeploymentFields(data) {
|
|
1472
1573
|
return {
|
|
@@ -1494,7 +1595,7 @@ function normalizeDeploymentEvent(deliveryId, body) {
|
|
|
1494
1595
|
const eventType = "deployment.created";
|
|
1495
1596
|
const { label } = gitHubDeploymentSourceResource(parsed);
|
|
1496
1597
|
return deploymentTargets(parsed).map(({ identifier }) => ({
|
|
1497
|
-
eventKey:
|
|
1598
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
1498
1599
|
eventType,
|
|
1499
1600
|
occurredAtMs: providerTime(parsed.createdAt) ?? Date.now(),
|
|
1500
1601
|
identifier,
|
|
@@ -1503,16 +1604,16 @@ function normalizeDeploymentEvent(deliveryId, body) {
|
|
|
1503
1604
|
}));
|
|
1504
1605
|
}
|
|
1505
1606
|
var deploymentStatusWebhookSchema = deploymentWebhookSchema.extend({
|
|
1506
|
-
deployment_status:
|
|
1507
|
-
created_at:
|
|
1508
|
-
description:
|
|
1509
|
-
state:
|
|
1607
|
+
deployment_status: z4.object({
|
|
1608
|
+
created_at: z4.string().optional(),
|
|
1609
|
+
description: z4.string().optional().nullable(),
|
|
1610
|
+
state: z4.string()
|
|
1510
1611
|
}).passthrough()
|
|
1511
1612
|
});
|
|
1512
1613
|
var canonicalDeploymentStatusEventSchema = canonicalDeploymentEventSchema.extend({
|
|
1513
|
-
description:
|
|
1514
|
-
state:
|
|
1515
|
-
statusCreatedAt:
|
|
1614
|
+
description: z4.string().optional().nullable(),
|
|
1615
|
+
state: z4.string(),
|
|
1616
|
+
statusCreatedAt: z4.string().optional()
|
|
1516
1617
|
}).strict();
|
|
1517
1618
|
function parseDeploymentStatusEvent(body) {
|
|
1518
1619
|
const parsed = deploymentStatusWebhookSchema.safeParse(body);
|
|
@@ -1550,7 +1651,7 @@ function normalizeDeploymentStatusEvent(deliveryId, body) {
|
|
|
1550
1651
|
const { label } = gitHubDeploymentSourceResource(parsed);
|
|
1551
1652
|
return deploymentTargets(parsed).map(
|
|
1552
1653
|
({ completeOnTerminalEvent, identifier }) => ({
|
|
1553
|
-
eventKey:
|
|
1654
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
1554
1655
|
eventType,
|
|
1555
1656
|
occurredAtMs: providerTime(parsed.statusCreatedAt) ?? Date.now(),
|
|
1556
1657
|
identifier,
|
|
@@ -1561,13 +1662,28 @@ function normalizeDeploymentStatusEvent(deliveryId, body) {
|
|
|
1561
1662
|
})
|
|
1562
1663
|
);
|
|
1563
1664
|
}
|
|
1665
|
+
var deploymentEventDataSchema = z4.object({
|
|
1666
|
+
repo: gitHubRepoDataSchema,
|
|
1667
|
+
commitSha: gitHubCommitShaDataSchema,
|
|
1668
|
+
deploymentId: z4.number(),
|
|
1669
|
+
// Trimmed and lowercase, the same as in the identifier.
|
|
1670
|
+
environment: z4.string().trim().min(1).toLowerCase(),
|
|
1671
|
+
workflowId: z4.number().optional(),
|
|
1672
|
+
workflowPath: z4.string().min(1).optional(),
|
|
1673
|
+
workflowRunId: z4.number().optional()
|
|
1674
|
+
}).strict();
|
|
1564
1675
|
function deploymentEventData(input) {
|
|
1565
|
-
return
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1676
|
+
return deploymentEventDataSchema.parse(
|
|
1677
|
+
definedValues({
|
|
1678
|
+
repo: input.repo,
|
|
1679
|
+
commitSha: input.commitSha,
|
|
1680
|
+
deploymentId: input.deploymentId,
|
|
1681
|
+
environment: input.environment,
|
|
1682
|
+
workflowId: input.workflowId,
|
|
1683
|
+
workflowPath: input.workflowPath,
|
|
1684
|
+
workflowRunId: input.workflowRunId
|
|
1685
|
+
})
|
|
1686
|
+
);
|
|
1571
1687
|
}
|
|
1572
1688
|
function deploymentTargets(input) {
|
|
1573
1689
|
return [
|
|
@@ -1588,103 +1704,149 @@ function deploymentTargets(input) {
|
|
|
1588
1704
|
}
|
|
1589
1705
|
];
|
|
1590
1706
|
}
|
|
1591
|
-
var
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1707
|
+
var gitHubUserSchema = z4.object({
|
|
1708
|
+
email: z4.string().nullish(),
|
|
1709
|
+
login: z4.string().nullish()
|
|
1710
|
+
});
|
|
1711
|
+
var senderSchema = z4.object({ id: z4.number(), login: z4.string().min(1) });
|
|
1712
|
+
var commentSchema = z4.object({
|
|
1713
|
+
body: z4.string(),
|
|
1714
|
+
id: z4.number(),
|
|
1715
|
+
user: z4.object({ login: z4.string().optional() }).optional()
|
|
1716
|
+
});
|
|
1717
|
+
var commentAuthorDataSchema = z4.object({
|
|
1718
|
+
mentionsBot: z4.boolean().optional(),
|
|
1719
|
+
senderId: z4.number().optional(),
|
|
1720
|
+
senderLogin: z4.string().min(1).optional()
|
|
1721
|
+
});
|
|
1722
|
+
function commentAuthorData(input) {
|
|
1723
|
+
return {
|
|
1724
|
+
mentionsBot: input.botEmail ? mentionsBotLogin(input.text ?? "", input.botEmail) : void 0,
|
|
1725
|
+
senderId: input.sender?.id,
|
|
1726
|
+
senderLogin: input.sender?.login
|
|
1727
|
+
};
|
|
1728
|
+
}
|
|
1729
|
+
var pullRequestSchema = z4.object({
|
|
1730
|
+
draft: z4.boolean().optional(),
|
|
1731
|
+
head: z4.object({ ref: z4.string().nullish() }).nullish(),
|
|
1732
|
+
number: z4.number(),
|
|
1733
|
+
user: gitHubUserSchema.nullish()
|
|
1734
|
+
});
|
|
1735
|
+
var pullRequestEventDataSchema = commentAuthorDataSchema.extend({
|
|
1736
|
+
repo: gitHubRepoDataSchema,
|
|
1737
|
+
pullRequest: z4.number(),
|
|
1738
|
+
headBranch: z4.string().min(1).optional(),
|
|
1739
|
+
isDraft: z4.boolean().optional(),
|
|
1740
|
+
openerEmail: z4.string().min(1).optional(),
|
|
1741
|
+
openerUsername: z4.string().min(1).optional(),
|
|
1742
|
+
commentId: z4.number().optional(),
|
|
1743
|
+
commentKind: z4.enum(["conversation", "review"]).optional()
|
|
1744
|
+
}).strict();
|
|
1745
|
+
function pullRequestEventData(input) {
|
|
1746
|
+
const { pullRequest } = input;
|
|
1747
|
+
return pullRequestEventDataSchema.parse(
|
|
1748
|
+
definedValues({
|
|
1749
|
+
repo: input.repo,
|
|
1750
|
+
pullRequest: pullRequest.number,
|
|
1751
|
+
headBranch: nonBlank(pullRequest.head?.ref),
|
|
1752
|
+
isDraft: pullRequest.draft,
|
|
1753
|
+
openerEmail: nonBlank(pullRequest.user?.email),
|
|
1754
|
+
openerUsername: nonBlank(pullRequest.user?.login),
|
|
1755
|
+
...input.comment
|
|
1756
|
+
})
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
1759
|
+
var issueEventDataSchema = commentAuthorDataSchema.extend({
|
|
1760
|
+
repo: gitHubRepoDataSchema,
|
|
1761
|
+
issue: z4.number(),
|
|
1762
|
+
commentId: z4.number().optional()
|
|
1763
|
+
}).strict();
|
|
1764
|
+
function issueEventData(input) {
|
|
1765
|
+
return issueEventDataSchema.parse(definedValues(input));
|
|
1766
|
+
}
|
|
1767
|
+
var issueCommentWebhookSchema = z4.object({
|
|
1768
|
+
action: z4.string(),
|
|
1769
|
+
comment: commentSchema,
|
|
1770
|
+
issue: z4.object({
|
|
1771
|
+
draft: z4.boolean().optional(),
|
|
1772
|
+
number: z4.number(),
|
|
1773
|
+
pull_request: z4.object({ url: z4.string().min(1) }).optional(),
|
|
1774
|
+
user: gitHubUserSchema.nullish()
|
|
1606
1775
|
}),
|
|
1607
1776
|
repository: repositorySchema2,
|
|
1608
|
-
sender:
|
|
1777
|
+
sender: senderSchema.optional()
|
|
1609
1778
|
});
|
|
1610
1779
|
function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
|
|
1611
1780
|
const parsed = issueCommentWebhookSchema.safeParse(body);
|
|
1612
1781
|
if (!parsed.success || parsed.data.action !== "created") return [];
|
|
1613
|
-
const
|
|
1782
|
+
const { comment, issue, sender } = parsed.data;
|
|
1783
|
+
const author = comment.user?.login;
|
|
1614
1784
|
if (isBotLogin(author, botEmail)) return [];
|
|
1615
1785
|
const input = {
|
|
1616
|
-
number:
|
|
1786
|
+
number: issue.number,
|
|
1617
1787
|
repo: parsed.data.repository.full_name
|
|
1618
1788
|
};
|
|
1619
|
-
|
|
1789
|
+
const writtenBy = commentAuthorData({ botEmail, sender, text: comment.body });
|
|
1790
|
+
if (issue.pull_request) {
|
|
1620
1791
|
const eventType = "pull_request.comment.created";
|
|
1621
1792
|
const resource = gitHubPullRequestResource(input);
|
|
1622
|
-
|
|
1623
|
-
pullRequestDraftData(parsed.data.issue.draft),
|
|
1624
|
-
pullRequestAuthorData(parsed.data.issue.user),
|
|
1625
|
-
{
|
|
1626
|
-
repo: input.repo,
|
|
1627
|
-
pullRequest: input.number,
|
|
1628
|
-
commentId: parsed.data.comment.id,
|
|
1629
|
-
commentKind: "conversation"
|
|
1630
|
-
}
|
|
1631
|
-
]);
|
|
1632
|
-
return pullRequestTargets2(
|
|
1793
|
+
return pullRequestTargets(
|
|
1633
1794
|
{
|
|
1634
|
-
eventKey:
|
|
1795
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
1635
1796
|
eventType,
|
|
1636
1797
|
occurredAtMs: Date.now(),
|
|
1637
1798
|
identifier: resource.identifier,
|
|
1638
1799
|
trustedSummary: `${resource.label} received a comment${author ? ` from ${author}` : ""}.`,
|
|
1639
1800
|
...gitHubDoneBy(author),
|
|
1640
|
-
|
|
1641
|
-
|
|
1801
|
+
data: pullRequestEventData({
|
|
1802
|
+
comment: {
|
|
1803
|
+
commentId: comment.id,
|
|
1804
|
+
commentKind: "conversation",
|
|
1805
|
+
...writtenBy
|
|
1806
|
+
},
|
|
1807
|
+
pullRequest: issue,
|
|
1808
|
+
repo: input.repo
|
|
1809
|
+
}),
|
|
1810
|
+
untrustedText: comment.body
|
|
1642
1811
|
},
|
|
1643
1812
|
input.repo
|
|
1644
1813
|
);
|
|
1645
1814
|
}
|
|
1646
|
-
const
|
|
1815
|
+
const issueResource = gitHubIssueResource(input);
|
|
1647
1816
|
const repository = gitHubRepositoryResource(input);
|
|
1648
|
-
const
|
|
1649
|
-
const data = {
|
|
1817
|
+
const data = issueEventData({
|
|
1650
1818
|
repo: input.repo,
|
|
1651
1819
|
issue: input.number,
|
|
1652
|
-
commentId:
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
}
|
|
1658
|
-
if (botEmail) {
|
|
1659
|
-
data.mentionsBot = mentionsBotLogin(parsed.data.comment.body, botEmail);
|
|
1660
|
-
}
|
|
1661
|
-
return [issue, repository].map((resource) => ({
|
|
1662
|
-
eventKey: gitHubEventKey2(deliveryId, "issue.comment.created"),
|
|
1820
|
+
commentId: comment.id,
|
|
1821
|
+
...writtenBy
|
|
1822
|
+
});
|
|
1823
|
+
return [issueResource, repository].map((resource) => ({
|
|
1824
|
+
eventKey: gitHubEventKey(deliveryId, "issue.comment.created"),
|
|
1663
1825
|
eventType: "issue.comment.created",
|
|
1664
1826
|
occurredAtMs: Date.now(),
|
|
1665
1827
|
identifier: resource.identifier,
|
|
1666
|
-
trustedSummary: `${
|
|
1828
|
+
trustedSummary: `${issueResource.label} received a comment${author ? ` from ${author}` : ""}.`,
|
|
1667
1829
|
...gitHubDoneBy(author),
|
|
1668
1830
|
data,
|
|
1669
|
-
untrustedText:
|
|
1831
|
+
untrustedText: comment.body
|
|
1670
1832
|
}));
|
|
1671
1833
|
}
|
|
1672
|
-
var issueWebhookSchema =
|
|
1673
|
-
action:
|
|
1674
|
-
issue:
|
|
1675
|
-
body:
|
|
1676
|
-
closed_at:
|
|
1677
|
-
created_at:
|
|
1678
|
-
number:
|
|
1679
|
-
title:
|
|
1680
|
-
updated_at:
|
|
1834
|
+
var issueWebhookSchema = z4.object({
|
|
1835
|
+
action: z4.string(),
|
|
1836
|
+
issue: z4.object({
|
|
1837
|
+
body: z4.string().optional().nullable(),
|
|
1838
|
+
closed_at: z4.string().optional().nullable(),
|
|
1839
|
+
created_at: z4.string().optional(),
|
|
1840
|
+
number: z4.number(),
|
|
1841
|
+
title: z4.string().optional(),
|
|
1842
|
+
updated_at: z4.string().optional()
|
|
1681
1843
|
}),
|
|
1682
1844
|
repository: repositorySchema2
|
|
1683
1845
|
});
|
|
1684
|
-
function
|
|
1846
|
+
function titleAndBodyText(item) {
|
|
1685
1847
|
const parts = [
|
|
1686
|
-
|
|
1687
|
-
|
|
1848
|
+
item.title ? `Title: ${item.title}` : void 0,
|
|
1849
|
+
nonBlank(item.body)
|
|
1688
1850
|
].filter((part) => part !== void 0);
|
|
1689
1851
|
return parts.length > 0 ? parts.join("\n\n") : void 0;
|
|
1690
1852
|
}
|
|
@@ -1702,165 +1864,124 @@ function normalizeIssueEvents(deliveryId, body) {
|
|
|
1702
1864
|
const occurredAtMs = providerTime(
|
|
1703
1865
|
state === "opened" ? parsed.data.issue.created_at : state === "closed" ? parsed.data.issue.closed_at : parsed.data.issue.updated_at
|
|
1704
1866
|
) ?? Date.now();
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
eventKey: gitHubEventKey2(deliveryId, `issue.${state}`),
|
|
1717
|
-
eventType: `issue.${state}`,
|
|
1718
|
-
occurredAtMs,
|
|
1719
|
-
identifier: repository.identifier,
|
|
1720
|
-
trustedSummary: `${issue.label} was ${state}.`,
|
|
1721
|
-
...untrustedText ? { untrustedText } : void 0
|
|
1722
|
-
}
|
|
1723
|
-
];
|
|
1867
|
+
const data = issueEventData({ repo: input.repo, issue: input.number });
|
|
1868
|
+
const untrustedText = titleAndBodyText(parsed.data.issue);
|
|
1869
|
+
return [issue, repository].map((resource) => ({
|
|
1870
|
+
eventKey: gitHubEventKey(deliveryId, `issue.${state}`),
|
|
1871
|
+
eventType: `issue.${state}`,
|
|
1872
|
+
occurredAtMs,
|
|
1873
|
+
identifier: resource.identifier,
|
|
1874
|
+
trustedSummary: `${issue.label} was ${state}.`,
|
|
1875
|
+
data,
|
|
1876
|
+
...untrustedText ? { untrustedText } : void 0
|
|
1877
|
+
}));
|
|
1724
1878
|
}
|
|
1725
|
-
var pullRequestReviewCommentWebhookSchema =
|
|
1726
|
-
action:
|
|
1727
|
-
comment:
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
}),
|
|
1732
|
-
pull_request: z2.object({
|
|
1733
|
-
draft: z2.boolean().optional(),
|
|
1734
|
-
head: z2.object({
|
|
1735
|
-
ref: z2.string().optional().nullable()
|
|
1736
|
-
}).optional().nullable(),
|
|
1737
|
-
number: z2.number(),
|
|
1738
|
-
user: z2.object({
|
|
1739
|
-
email: z2.string().optional().nullable(),
|
|
1740
|
-
login: z2.string().optional().nullable()
|
|
1741
|
-
}).optional().nullable()
|
|
1742
|
-
}),
|
|
1743
|
-
repository: repositorySchema2
|
|
1879
|
+
var pullRequestReviewCommentWebhookSchema = z4.object({
|
|
1880
|
+
action: z4.string(),
|
|
1881
|
+
comment: commentSchema,
|
|
1882
|
+
pull_request: pullRequestSchema,
|
|
1883
|
+
repository: repositorySchema2,
|
|
1884
|
+
sender: senderSchema.optional()
|
|
1744
1885
|
});
|
|
1745
1886
|
function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
|
|
1746
1887
|
const parsed = pullRequestReviewCommentWebhookSchema.safeParse(body);
|
|
1747
1888
|
if (!parsed.success || parsed.data.action !== "created") return [];
|
|
1748
|
-
|
|
1889
|
+
const { comment, pull_request: pullRequest, sender } = parsed.data;
|
|
1890
|
+
const author = comment.user?.login;
|
|
1891
|
+
if (isBotLogin(author, botEmail)) return [];
|
|
1749
1892
|
const eventType = "pull_request.review_comment.created";
|
|
1750
1893
|
const repo = parsed.data.repository.full_name;
|
|
1751
1894
|
const resource = gitHubPullRequestResource({
|
|
1752
|
-
number:
|
|
1895
|
+
number: pullRequest.number,
|
|
1753
1896
|
repo
|
|
1754
1897
|
});
|
|
1755
|
-
|
|
1756
|
-
const data = pullRequestMatchData([
|
|
1757
|
-
pullRequestDraftData(parsed.data.pull_request.draft),
|
|
1758
|
-
pullRequestAuthorData(parsed.data.pull_request.user),
|
|
1759
|
-
pullRequestHeadBranchData(parsed.data.pull_request.head?.ref),
|
|
1760
|
-
{
|
|
1761
|
-
repo,
|
|
1762
|
-
pullRequest: parsed.data.pull_request.number,
|
|
1763
|
-
commentId: parsed.data.comment.id,
|
|
1764
|
-
commentKind: "review"
|
|
1765
|
-
}
|
|
1766
|
-
]);
|
|
1767
|
-
return pullRequestTargets2(
|
|
1898
|
+
return pullRequestTargets(
|
|
1768
1899
|
{
|
|
1769
|
-
eventKey:
|
|
1900
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
1770
1901
|
eventType,
|
|
1771
1902
|
occurredAtMs: Date.now(),
|
|
1772
1903
|
identifier: resource.identifier,
|
|
1773
1904
|
trustedSummary: `${resource.label} received an inline review comment${author ? ` from ${author}` : ""}.`,
|
|
1774
1905
|
...gitHubDoneBy(author),
|
|
1775
|
-
|
|
1776
|
-
|
|
1906
|
+
data: pullRequestEventData({
|
|
1907
|
+
comment: {
|
|
1908
|
+
commentId: comment.id,
|
|
1909
|
+
commentKind: "review",
|
|
1910
|
+
...commentAuthorData({ botEmail, sender, text: comment.body })
|
|
1911
|
+
},
|
|
1912
|
+
pullRequest,
|
|
1913
|
+
repo
|
|
1914
|
+
}),
|
|
1915
|
+
untrustedText: comment.body
|
|
1777
1916
|
},
|
|
1778
1917
|
repo
|
|
1779
1918
|
);
|
|
1780
1919
|
}
|
|
1781
|
-
var pullRequestReviewWebhookSchema =
|
|
1782
|
-
action:
|
|
1783
|
-
pull_request:
|
|
1784
|
-
draft: z2.boolean().optional(),
|
|
1785
|
-
head: z2.object({
|
|
1786
|
-
ref: z2.string().optional().nullable()
|
|
1787
|
-
}).optional().nullable(),
|
|
1788
|
-
number: z2.number(),
|
|
1789
|
-
user: z2.object({
|
|
1790
|
-
email: z2.string().optional().nullable(),
|
|
1791
|
-
login: z2.string().optional().nullable()
|
|
1792
|
-
}).optional().nullable()
|
|
1793
|
-
}),
|
|
1920
|
+
var pullRequestReviewWebhookSchema = z4.object({
|
|
1921
|
+
action: z4.string(),
|
|
1922
|
+
pull_request: pullRequestSchema,
|
|
1794
1923
|
repository: repositorySchema2,
|
|
1795
|
-
review:
|
|
1796
|
-
body:
|
|
1797
|
-
state:
|
|
1798
|
-
user:
|
|
1799
|
-
})
|
|
1924
|
+
review: z4.object({
|
|
1925
|
+
body: z4.string().optional().nullable(),
|
|
1926
|
+
state: z4.string(),
|
|
1927
|
+
user: z4.object({ login: z4.string().optional() }).optional()
|
|
1928
|
+
}),
|
|
1929
|
+
sender: senderSchema.optional()
|
|
1800
1930
|
});
|
|
1801
1931
|
function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
|
|
1802
1932
|
const parsed = pullRequestReviewWebhookSchema.safeParse(body);
|
|
1803
1933
|
if (!parsed.success || parsed.data.action !== "submitted") return [];
|
|
1804
|
-
|
|
1805
|
-
|
|
1934
|
+
const { pull_request: pullRequest, review, sender } = parsed.data;
|
|
1935
|
+
if (isBotLogin(review.user?.login, botEmail)) return [];
|
|
1936
|
+
const reviewState = review.state.toUpperCase();
|
|
1806
1937
|
const eventType = reviewState === "APPROVED" ? "pull_request.review.approved" : reviewState === "CHANGES_REQUESTED" ? "pull_request.review.changes_requested" : reviewState === "COMMENTED" ? "pull_request.review.commented" : void 0;
|
|
1807
1938
|
if (!eventType) return [];
|
|
1808
1939
|
const repo = parsed.data.repository.full_name;
|
|
1809
1940
|
const resource = gitHubPullRequestResource({
|
|
1810
|
-
number:
|
|
1941
|
+
number: pullRequest.number,
|
|
1811
1942
|
repo
|
|
1812
1943
|
});
|
|
1813
|
-
const reviewer =
|
|
1814
|
-
const data = pullRequestMatchData([
|
|
1815
|
-
pullRequestDraftData(parsed.data.pull_request.draft),
|
|
1816
|
-
pullRequestAuthorData(parsed.data.pull_request.user),
|
|
1817
|
-
pullRequestHeadBranchData(parsed.data.pull_request.head?.ref)
|
|
1818
|
-
]);
|
|
1944
|
+
const reviewer = review.user?.login;
|
|
1819
1945
|
const event = {
|
|
1820
|
-
eventKey:
|
|
1946
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
1821
1947
|
eventType,
|
|
1822
1948
|
occurredAtMs: Date.now(),
|
|
1823
1949
|
identifier: resource.identifier,
|
|
1824
1950
|
trustedSummary: eventType === "pull_request.review.approved" ? `${resource.label} was approved${reviewer ? ` by ${reviewer}` : ""}.` : eventType === "pull_request.review.changes_requested" ? `${resource.label} received requested changes${reviewer ? ` from ${reviewer}` : ""}.` : `${resource.label} received a review comment${reviewer ? ` from ${reviewer}` : ""}.`,
|
|
1825
1951
|
...gitHubDoneBy(reviewer),
|
|
1826
|
-
|
|
1827
|
-
|
|
1952
|
+
data: pullRequestEventData({
|
|
1953
|
+
comment: commentAuthorData({ botEmail, sender, text: review.body }),
|
|
1954
|
+
pullRequest,
|
|
1955
|
+
repo
|
|
1956
|
+
}),
|
|
1957
|
+
untrustedText: review.body ?? void 0
|
|
1828
1958
|
};
|
|
1829
|
-
const events =
|
|
1830
|
-
if (eventType !== "pull_request.review.approved" || !
|
|
1959
|
+
const events = pullRequestTargets(event, repo);
|
|
1960
|
+
if (eventType !== "pull_request.review.approved" || !nonBlank(review.body)) {
|
|
1831
1961
|
return events;
|
|
1832
1962
|
}
|
|
1833
1963
|
return [
|
|
1834
1964
|
...events,
|
|
1835
|
-
...
|
|
1965
|
+
...pullRequestTargets(
|
|
1836
1966
|
{
|
|
1837
1967
|
...event,
|
|
1838
|
-
eventKey:
|
|
1968
|
+
eventKey: gitHubEventKey(deliveryId, "pull_request.review.commented"),
|
|
1839
1969
|
eventType: "pull_request.review.commented"
|
|
1840
1970
|
},
|
|
1841
1971
|
repo
|
|
1842
1972
|
)
|
|
1843
1973
|
];
|
|
1844
1974
|
}
|
|
1845
|
-
var pullRequestWebhookSchema =
|
|
1846
|
-
action:
|
|
1847
|
-
pull_request:
|
|
1848
|
-
body:
|
|
1849
|
-
closed_at:
|
|
1850
|
-
created_at:
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
merged: z2.boolean().optional(),
|
|
1856
|
-
merged_at: z2.string().optional().nullable(),
|
|
1857
|
-
number: z2.number(),
|
|
1858
|
-
title: z2.string().optional(),
|
|
1859
|
-
updated_at: z2.string().optional(),
|
|
1860
|
-
user: z2.object({
|
|
1861
|
-
email: z2.string().optional().nullable(),
|
|
1862
|
-
login: z2.string().optional().nullable()
|
|
1863
|
-
}).optional().nullable()
|
|
1975
|
+
var pullRequestWebhookSchema = z4.object({
|
|
1976
|
+
action: z4.string(),
|
|
1977
|
+
pull_request: pullRequestSchema.extend({
|
|
1978
|
+
body: z4.string().optional().nullable(),
|
|
1979
|
+
closed_at: z4.string().optional().nullable(),
|
|
1980
|
+
created_at: z4.string().optional(),
|
|
1981
|
+
merged: z4.boolean().optional(),
|
|
1982
|
+
merged_at: z4.string().optional().nullable(),
|
|
1983
|
+
title: z4.string().optional(),
|
|
1984
|
+
updated_at: z4.string().optional()
|
|
1864
1985
|
}),
|
|
1865
1986
|
repository: repositorySchema2
|
|
1866
1987
|
});
|
|
@@ -1869,76 +1990,48 @@ function providerTime(value) {
|
|
|
1869
1990
|
const parsed = Date.parse(value);
|
|
1870
1991
|
return Number.isFinite(parsed) ? parsed : void 0;
|
|
1871
1992
|
}
|
|
1872
|
-
function pullRequestEventText(pullRequest) {
|
|
1873
|
-
const parts = [
|
|
1874
|
-
pullRequest.title ? `Title: ${pullRequest.title}` : void 0,
|
|
1875
|
-
pullRequest.body?.trim() || void 0
|
|
1876
|
-
].filter((part) => part !== void 0);
|
|
1877
|
-
return parts.length > 0 ? parts.join("\n\n") : void 0;
|
|
1878
|
-
}
|
|
1879
|
-
function pullRequestLifecycleEvents(input) {
|
|
1880
|
-
const data = pullRequestMatchData([
|
|
1881
|
-
pullRequestDraftData(input.isDraft),
|
|
1882
|
-
pullRequestAuthorData({
|
|
1883
|
-
email: input.authorEmail,
|
|
1884
|
-
login: input.authorUsername
|
|
1885
|
-
}),
|
|
1886
|
-
pullRequestHeadBranchData(input.headBranch)
|
|
1887
|
-
]);
|
|
1888
|
-
return pullRequestTargets2(
|
|
1889
|
-
{
|
|
1890
|
-
eventKey: gitHubEventKey2(input.deliveryId, input.eventType),
|
|
1891
|
-
eventType: input.eventType,
|
|
1892
|
-
occurredAtMs: input.occurredAtMs,
|
|
1893
|
-
identifier: input.resource.identifier,
|
|
1894
|
-
...input.terminal ? { terminal: true } : void 0,
|
|
1895
|
-
trustedSummary: input.trustedSummary,
|
|
1896
|
-
...data ? { data } : void 0,
|
|
1897
|
-
...input.untrustedText ? { untrustedText: input.untrustedText } : void 0
|
|
1898
|
-
},
|
|
1899
|
-
input.repo
|
|
1900
|
-
);
|
|
1901
|
-
}
|
|
1902
1993
|
function normalizePullRequestEvent(deliveryId, body) {
|
|
1903
1994
|
const parsed = pullRequestWebhookSchema.safeParse(body);
|
|
1904
1995
|
if (!parsed.success) return [];
|
|
1996
|
+
const { pull_request: pullRequest } = parsed.data;
|
|
1905
1997
|
const repo = parsed.data.repository.full_name;
|
|
1906
1998
|
const resource = gitHubPullRequestResource({
|
|
1907
|
-
number:
|
|
1999
|
+
number: pullRequest.number,
|
|
1908
2000
|
repo
|
|
1909
2001
|
});
|
|
1910
|
-
const
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
)
|
|
1916
|
-
const
|
|
2002
|
+
const data = pullRequestEventData({ pullRequest, repo });
|
|
2003
|
+
const readyData = pullRequestEventData({
|
|
2004
|
+
pullRequest: { ...pullRequest, draft: false },
|
|
2005
|
+
repo
|
|
2006
|
+
});
|
|
2007
|
+
const untrustedText = titleAndBodyText(pullRequest);
|
|
2008
|
+
const lifecycleEvents = (event) => pullRequestTargets(
|
|
2009
|
+
{
|
|
2010
|
+
eventKey: gitHubEventKey(deliveryId, event.eventType),
|
|
2011
|
+
eventType: event.eventType,
|
|
2012
|
+
occurredAtMs: event.occurredAtMs,
|
|
2013
|
+
identifier: resource.identifier,
|
|
2014
|
+
...event.terminal ? { terminal: true } : void 0,
|
|
2015
|
+
trustedSummary: event.trustedSummary,
|
|
2016
|
+
data: event.isDraft === false ? readyData : data,
|
|
2017
|
+
...event.untrustedText ? { untrustedText: event.untrustedText } : void 0
|
|
2018
|
+
},
|
|
2019
|
+
repo
|
|
2020
|
+
);
|
|
1917
2021
|
if (parsed.data.action === "opened") {
|
|
1918
|
-
const openedAtMs = providerTime(
|
|
1919
|
-
const events =
|
|
1920
|
-
...author,
|
|
1921
|
-
deliveryId,
|
|
2022
|
+
const openedAtMs = providerTime(pullRequest.created_at) ?? Date.now();
|
|
2023
|
+
const events = lifecycleEvents({
|
|
1922
2024
|
eventType: "pull_request.opened",
|
|
1923
|
-
...headBranch ? { headBranch } : void 0,
|
|
1924
|
-
...isDraft !== void 0 ? { isDraft } : void 0,
|
|
1925
2025
|
occurredAtMs: openedAtMs,
|
|
1926
|
-
repo,
|
|
1927
|
-
resource,
|
|
1928
2026
|
trustedSummary: `${resource.label} was opened.`,
|
|
1929
2027
|
untrustedText
|
|
1930
2028
|
});
|
|
1931
|
-
if (draft !== true) {
|
|
2029
|
+
if (pullRequest.draft !== true) {
|
|
1932
2030
|
events.push(
|
|
1933
|
-
...
|
|
1934
|
-
...author,
|
|
1935
|
-
deliveryId,
|
|
2031
|
+
...lifecycleEvents({
|
|
1936
2032
|
eventType: "pull_request.ready_for_review",
|
|
1937
|
-
...headBranch ? { headBranch } : void 0,
|
|
1938
2033
|
isDraft: false,
|
|
1939
2034
|
occurredAtMs: openedAtMs,
|
|
1940
|
-
repo,
|
|
1941
|
-
resource,
|
|
1942
2035
|
trustedSummary: `${resource.label} is ready for review.`,
|
|
1943
2036
|
untrustedText
|
|
1944
2037
|
})
|
|
@@ -1947,49 +2040,42 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
1947
2040
|
return events;
|
|
1948
2041
|
}
|
|
1949
2042
|
if (parsed.data.action === "ready_for_review") {
|
|
1950
|
-
return
|
|
1951
|
-
...author,
|
|
1952
|
-
deliveryId,
|
|
2043
|
+
return lifecycleEvents({
|
|
1953
2044
|
eventType: "pull_request.ready_for_review",
|
|
1954
|
-
...headBranch ? { headBranch } : void 0,
|
|
1955
2045
|
isDraft: false,
|
|
1956
|
-
occurredAtMs: providerTime(
|
|
1957
|
-
repo,
|
|
1958
|
-
resource,
|
|
2046
|
+
occurredAtMs: providerTime(pullRequest.updated_at) ?? Date.now(),
|
|
1959
2047
|
trustedSummary: `${resource.label} is ready for review.`,
|
|
1960
2048
|
untrustedText
|
|
1961
2049
|
});
|
|
1962
2050
|
}
|
|
1963
2051
|
if (parsed.data.action !== "closed") return [];
|
|
1964
|
-
const eventType =
|
|
1965
|
-
return
|
|
1966
|
-
...author,
|
|
1967
|
-
deliveryId,
|
|
2052
|
+
const eventType = pullRequest.merged ? "pull_request.merged" : "pull_request.closed_unmerged";
|
|
2053
|
+
return lifecycleEvents({
|
|
1968
2054
|
eventType,
|
|
1969
|
-
...headBranch ? { headBranch } : void 0,
|
|
1970
|
-
...isDraft !== void 0 ? { isDraft } : void 0,
|
|
1971
2055
|
occurredAtMs: providerTime(
|
|
1972
|
-
|
|
2056
|
+
pullRequest.merged ? pullRequest.merged_at : pullRequest.closed_at
|
|
1973
2057
|
) ?? Date.now(),
|
|
1974
|
-
repo,
|
|
1975
|
-
resource,
|
|
1976
2058
|
terminal: true,
|
|
1977
2059
|
trustedSummary: eventType === "pull_request.merged" ? `${resource.label} was merged.` : `${resource.label} was closed without being merged.`
|
|
1978
2060
|
});
|
|
1979
2061
|
}
|
|
1980
|
-
var releaseWebhookSchema =
|
|
1981
|
-
action:
|
|
1982
|
-
release:
|
|
1983
|
-
body:
|
|
1984
|
-
draft:
|
|
1985
|
-
id:
|
|
1986
|
-
name:
|
|
1987
|
-
prerelease:
|
|
1988
|
-
published_at:
|
|
1989
|
-
tag_name:
|
|
2062
|
+
var releaseWebhookSchema = z4.object({
|
|
2063
|
+
action: z4.string(),
|
|
2064
|
+
release: z4.object({
|
|
2065
|
+
body: z4.string().optional().nullable(),
|
|
2066
|
+
draft: z4.boolean().optional(),
|
|
2067
|
+
id: z4.number(),
|
|
2068
|
+
name: z4.string().optional().nullable(),
|
|
2069
|
+
prerelease: z4.boolean().optional(),
|
|
2070
|
+
published_at: z4.string().optional().nullable(),
|
|
2071
|
+
tag_name: z4.string().min(1)
|
|
1990
2072
|
}).passthrough(),
|
|
1991
2073
|
repository: repositorySchema2
|
|
1992
2074
|
}).passthrough();
|
|
2075
|
+
var releaseEventDataSchema = z4.object({
|
|
2076
|
+
repo: gitHubRepoDataSchema,
|
|
2077
|
+
tag: gitHubReleaseTagDataSchema
|
|
2078
|
+
}).strict();
|
|
1993
2079
|
function releaseSourceTargets(input) {
|
|
1994
2080
|
return [
|
|
1995
2081
|
{
|
|
@@ -2008,21 +2094,24 @@ function normalizeReleaseEvent(deliveryId, body) {
|
|
|
2008
2094
|
if (parsed.data.release.draft) return [];
|
|
2009
2095
|
const eventType = "release.published";
|
|
2010
2096
|
const repo = parsed.data.repository.full_name;
|
|
2011
|
-
const tag = parsed.data.release.tag_name;
|
|
2097
|
+
const tag = parsed.data.release.tag_name.trim();
|
|
2098
|
+
if (!tag) return [];
|
|
2012
2099
|
const untrustedParts = [
|
|
2013
|
-
|
|
2100
|
+
`Tag: ${tag}`,
|
|
2014
2101
|
parsed.data.release.name?.trim() ? `Name: ${parsed.data.release.name.trim()}` : void 0,
|
|
2015
2102
|
parsed.data.release.body?.trim() || void 0
|
|
2016
2103
|
].filter((part) => part !== void 0);
|
|
2017
2104
|
const untrustedText = untrustedParts.length > 0 ? untrustedParts.join("\n\n") : void 0;
|
|
2105
|
+
const data = releaseEventDataSchema.parse({ repo, tag });
|
|
2018
2106
|
return releaseSourceTargets({ repo, tag }).map(
|
|
2019
2107
|
({ completeOnTerminalEvent, resource }) => ({
|
|
2020
|
-
eventKey:
|
|
2108
|
+
eventKey: gitHubEventKey(deliveryId, eventType),
|
|
2021
2109
|
eventType,
|
|
2022
2110
|
occurredAtMs: providerTime(parsed.data.release.published_at) ?? Date.now(),
|
|
2023
2111
|
identifier: resource.identifier,
|
|
2024
2112
|
...completeOnTerminalEvent ? { terminal: true } : void 0,
|
|
2025
2113
|
trustedSummary: `${resource.label} was published (release ${parsed.data.release.id}).`,
|
|
2114
|
+
data,
|
|
2026
2115
|
...untrustedText ? { untrustedText } : void 0
|
|
2027
2116
|
})
|
|
2028
2117
|
);
|
|
@@ -2073,7 +2162,7 @@ export {
|
|
|
2073
2162
|
readGrantPermissions,
|
|
2074
2163
|
GITHUB_ISSUE_EVENTS,
|
|
2075
2164
|
GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
2076
|
-
|
|
2165
|
+
GITHUB_ISSUE_MATCH_FIELDS,
|
|
2077
2166
|
GITHUB_ISSUE_IDENTIFIER,
|
|
2078
2167
|
gitHubIssueSubscribable,
|
|
2079
2168
|
GITHUB_DEPLOYMENT_EVENTS,
|
|
@@ -2089,10 +2178,13 @@ export {
|
|
|
2089
2178
|
GITHUB_PULL_REQUEST_IDENTIFIER,
|
|
2090
2179
|
gitHubPullRequestSubscribable,
|
|
2091
2180
|
GITHUB_RELEASE_EVENTS,
|
|
2181
|
+
GITHUB_RELEASE_MATCH_FIELDS,
|
|
2092
2182
|
GITHUB_RELEASE_SUGGESTED_EVENTS,
|
|
2093
2183
|
GITHUB_RELEASE_SOURCE_IDENTIFIER,
|
|
2094
2184
|
gitHubReleaseSourceSubscribable,
|
|
2095
2185
|
GITHUB_REPOSITORY_IDENTIFIER,
|
|
2186
|
+
GITHUB_REPOSITORY_EVENTS,
|
|
2187
|
+
GITHUB_REPOSITORY_SUGGESTED_EVENTS,
|
|
2096
2188
|
gitHubRepositorySubscribable,
|
|
2097
2189
|
botLoginFromEmail,
|
|
2098
2190
|
isBotLogin,
|
|
@@ -2117,6 +2209,7 @@ export {
|
|
|
2117
2209
|
issueInstallationToken,
|
|
2118
2210
|
issueGitHubCredential,
|
|
2119
2211
|
createPermissionCache,
|
|
2212
|
+
definedValues,
|
|
2120
2213
|
parseCheckSuitePublishTargets,
|
|
2121
2214
|
needsCheckSuitePullRequestFacts,
|
|
2122
2215
|
loadCheckSuiteFacts,
|