@sentry/junior-github 0.265.0 → 0.266.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,38 @@
1
1
  // src/webhooks/events.ts
2
- import { z as z2 } from "zod";
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,7 +47,14 @@ var GITHUB_DEPLOYMENT_SUGGESTED_EVENTS = [
19
47
  "deployment.failed",
20
48
  "deployment.error"
21
49
  ];
22
- var GITHUB_DEPLOYMENT_MATCH_FIELDS = eventMatchFieldsSchema.parse({
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
60
  description: "lowercase deployment environment name, such as production",
@@ -62,8 +97,34 @@ function gitHubDeploymentSourceSubscribable(input) {
62
97
 
63
98
  // src/events/issue.ts
64
99
  import {
65
- eventMatchFieldsSchema as eventMatchFieldsSchema2
100
+ eventMatchFieldsSchema as eventMatchFieldsSchema4
66
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
67
128
  var GITHUB_ISSUE_EVENTS = [
68
129
  "issue.comment.created",
69
130
  "issue.opened",
@@ -75,21 +136,13 @@ var GITHUB_ISSUE_SUGGESTED_EVENTS = [
75
136
  "issue.closed",
76
137
  "issue.reopened"
77
138
  ];
78
- var GITHUB_ISSUE_COMMENT_MATCH_FIELDS = eventMatchFieldsSchema2.parse({
79
- mentionsBot: {
80
- kind: "boolean",
81
- description: "true when the issue comment mentions this GitHub App",
82
- events: ["issue.comment.created"]
83
- },
84
- senderId: {
139
+ var GITHUB_ISSUE_MATCH_FIELDS = eventMatchFieldsSchema4.parse({
140
+ ...gitHubCommentMatchFields(["issue.comment.created"]),
141
+ ...gitHubRepoMatchFields(GITHUB_ISSUE_EVENTS),
142
+ issue: {
85
143
  kind: "number",
86
- description: "immutable numeric GitHub user id of the issue commenter; prefer over logins",
87
- events: ["issue.comment.created"]
88
- },
89
- senderLogin: {
90
- kind: "string",
91
- description: "GitHub login of the issue commenter; logins can be renamed",
92
- events: ["issue.comment.created"]
144
+ description: "issue number, such as 12",
145
+ events: GITHUB_ISSUE_EVENTS
93
146
  }
94
147
  });
95
148
  var GITHUB_ISSUE_IDENTIFIER = {
@@ -115,7 +168,7 @@ function gitHubIssueSubscribable(input) {
115
168
 
116
169
  // src/events/pull-request.ts
117
170
  import {
118
- eventMatchFieldsSchema as eventMatchFieldsSchema3
171
+ eventMatchFieldsSchema as eventMatchFieldsSchema5
119
172
  } from "@sentry/junior-plugin-api";
120
173
  var GITHUB_PULL_REQUEST_EVENTS = [
121
174
  "pull_request.checks.failed",
@@ -168,7 +221,26 @@ var GITHUB_PULL_REQUEST_SUGGESTED_EVENTS = [
168
221
  "pull_request.merged",
169
222
  "pull_request.closed_unmerged"
170
223
  ];
171
- var GITHUB_PULL_REQUEST_MATCH_FIELDS = eventMatchFieldsSchema3.parse({
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]
243
+ },
172
244
  authors: {
173
245
  kind: "string",
174
246
  list: true,
@@ -229,7 +301,22 @@ function gitHubPullRequestSubscribable(input) {
229
301
  }
230
302
 
231
303
  // src/events/release.ts
304
+ import {
305
+ eventMatchFieldsSchema as eventMatchFieldsSchema6
306
+ } from "@sentry/junior-plugin-api";
307
+ import { z as z2 } from "zod";
232
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
+ });
233
320
  var GITHUB_RELEASE_SUGGESTED_EVENTS = ["release.published"];
234
321
  var GITHUB_RELEASE_SOURCE_IDENTIFIER = {
235
322
  format: "release-source:owner/repo[:tag]",
@@ -288,7 +375,7 @@ function gitHubRepositorySubscribable(input) {
288
375
  }
289
376
 
290
377
  // src/webhooks/check-suite.ts
291
- import { z } from "zod";
378
+ import { z as z3 } from "zod";
292
379
 
293
380
  // src/credential-support.ts
294
381
  import { createPrivateKey, createSign } from "crypto";
@@ -973,6 +1060,11 @@ function createPermissionCache() {
973
1060
  }
974
1061
 
975
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
+ }
976
1068
  function gitHubEventKey(deliveryId, eventType) {
977
1069
  return `github:${deliveryId}:${eventType}`;
978
1070
  }
@@ -994,48 +1086,48 @@ var CHECK_SUITE_PULL_REQUEST_MATCH_KEYS = /* @__PURE__ */ new Set([
994
1086
  "openerRole",
995
1087
  "openerUsername"
996
1088
  ]);
997
- var checkRunRepoRefSchema = z.object({
998
- id: z.number(),
999
- name: z.string().min(1),
1000
- url: z.string().min(1)
1089
+ var checkRunRepoRefSchema = z3.object({
1090
+ id: z3.number(),
1091
+ name: z3.string().min(1),
1092
+ url: z3.string().min(1)
1001
1093
  }).passthrough();
1002
- var checkRunPullRequestSideSchema = z.object({
1003
- ref: z.string().optional(),
1094
+ var checkRunPullRequestSideSchema = z3.object({
1095
+ ref: z3.string().optional(),
1004
1096
  repo: checkRunRepoRefSchema,
1005
- sha: z.string().optional()
1097
+ sha: z3.string().optional()
1006
1098
  }).passthrough();
1007
- var checkRunPullRequestSchema = z.object({
1099
+ var checkRunPullRequestSchema = z3.object({
1008
1100
  base: checkRunPullRequestSideSchema,
1009
1101
  head: checkRunPullRequestSideSchema.optional(),
1010
- id: z.number().optional(),
1011
- number: z.number(),
1012
- url: z.string().optional()
1102
+ id: z3.number().optional(),
1103
+ number: z3.number(),
1104
+ url: z3.string().optional()
1013
1105
  }).passthrough();
1014
- var repositorySchema = z.object({
1015
- full_name: z.string().min(1),
1016
- id: z.number(),
1017
- name: z.string().min(1),
1018
- owner: z.object({ login: z.string().min(1) }).passthrough()
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()
1019
1111
  }).passthrough();
1020
- var checkSuiteWebhookSchema = z.object({
1021
- action: z.string(),
1022
- check_suite: z.object({
1023
- app: z.object({
1024
- name: z.string().optional().nullable(),
1025
- slug: z.string().optional().nullable()
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()
1026
1118
  }).optional().nullable(),
1027
- conclusion: z.string().optional().nullable(),
1119
+ conclusion: z3.string().optional().nullable(),
1028
1120
  /** Branch name for the suite head commit when GitHub sends it. */
1029
- head_branch: z.string().optional().nullable(),
1030
- head_sha: z.string().optional(),
1031
- id: z.number().optional(),
1032
- latest_check_runs_count: z.number().optional().nullable(),
1033
- pull_requests: z.array(checkRunPullRequestSchema)
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)
1034
1126
  }),
1035
1127
  repository: repositorySchema
1036
1128
  });
1037
- var checkRunsListResponseSchema = z.object({
1038
- check_runs: z.array(z.unknown()).optional()
1129
+ var checkRunsListResponseSchema = z3.object({
1130
+ check_runs: z3.array(z3.unknown()).optional()
1039
1131
  }).passthrough();
1040
1132
  function isCheckSuiteRepositoryPullRequest(pullRequest, repositoryId) {
1041
1133
  return pullRequest.base.repo.id === repositoryId;
@@ -1069,6 +1161,29 @@ function checkSuiteHeadBranch(value) {
1069
1161
  const branch = value?.trim();
1070
1162
  return branch ? branch : void 0;
1071
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();
1072
1187
  function buildCheckSuiteEvent(args) {
1073
1188
  const pullRequestNumber = args.pullRequestNumber;
1074
1189
  const resource = pullRequestNumber === void 0 ? gitHubRepositoryResource({ repo: args.repo }) : gitHubPullRequestResource({
@@ -1080,36 +1195,32 @@ function buildCheckSuiteEvent(args) {
1080
1195
  const failingCount = failingChecks.length;
1081
1196
  const branchSuffix = args.headBranch ? ` on ${args.headBranch}` : "";
1082
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}.`;
1083
- const data = {
1084
- repo: args.repo,
1085
- scope: "check_suite",
1086
- suiteConclusion: args.suiteConclusion
1087
- };
1088
- if (pullRequestNumber !== void 0) data.pullRequest = pullRequestNumber;
1089
- if (typeof args.isDraft === "boolean") data.isDraft = args.isDraft;
1090
- if (args.openerUsername) data.openerUsername = args.openerUsername;
1091
- if (args.openerEmail) data.openerEmail = args.openerEmail;
1092
- if (args.headBranch) data.headBranch = args.headBranch;
1093
- if (args.headSha) data.headSha = args.headSha;
1094
- if (args.checkSuiteId !== void 0) data.checkSuiteId = args.checkSuiteId;
1095
- if (args.checkSuiteId !== void 0 && args.headSha) {
1096
- 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,
1097
1209
  checkSuiteId: args.checkSuiteId,
1098
- headSha: args.headSha,
1099
- repo: args.repo
1100
- });
1101
- }
1102
- if (args.appName) data.appName = oneLineLabel(args.appName, 120);
1103
- if (args.latestCheckRunsCount !== void 0) {
1104
- data.latestCheckRunsCount = args.latestCheckRunsCount;
1105
- }
1106
- if (args.eventType === "pull_request.checks.failed" && failingCount > 0) {
1107
- data.failingChecks = failingChecks.map((check) => ({
1108
- conclusion: check.conclusion,
1109
- ...check.htmlUrl ? { htmlUrl: check.htmlUrl } : void 0,
1110
- checkRunId: check.checkRunId
1111
- }));
1112
- }
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
+ );
1113
1224
  const untrustedParts = args.eventType === "pull_request.checks.failed" ? failingChecks.map((check) => {
1114
1225
  const name = oneLineLabel(check.name);
1115
1226
  if (!name) return void 0;
@@ -1423,60 +1534,40 @@ function mentionsBotLogin(text, botEmail) {
1423
1534
  }
1424
1535
 
1425
1536
  // src/webhooks/events.ts
1426
- function pullRequestDraftData(draft) {
1427
- return typeof draft === "boolean" ? { isDraft: draft } : void 0;
1428
- }
1429
- function pullRequestHeadBranchData(headRef) {
1430
- const headBranch = headRef?.trim();
1431
- return headBranch ? { headBranch } : void 0;
1432
- }
1433
- function pullRequestOpenerData(user) {
1434
- const data = {};
1435
- const username = user?.login?.trim();
1436
- if (username) data.openerUsername = username;
1437
- const email = user?.email?.trim();
1438
- if (email) data.openerEmail = email;
1439
- return data;
1440
- }
1441
1537
  function gitHubDoneBy(login) {
1442
1538
  const handle = login?.trim();
1443
1539
  return handle ? { doneBy: { provider: "github", handle } } : void 0;
1444
1540
  }
1445
- function pullRequestMatchData(parts) {
1446
- const data = {};
1447
- for (const part of parts) {
1448
- if (!part) continue;
1449
- Object.assign(data, part);
1450
- }
1451
- return Object.keys(data).length > 0 ? data : void 0;
1541
+ function nonBlank(value) {
1542
+ return value?.trim() || void 0;
1452
1543
  }
1453
- var repositorySchema2 = z2.object({ full_name: z2.string().min(1) }).passthrough();
1454
- var deploymentSchema = z2.object({
1455
- created_at: z2.string().optional(),
1456
- environment: z2.string().min(1),
1457
- id: z2.number(),
1458
- sha: z2.string().regex(/^[0-9a-f]{40}$/i)
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)
1459
1550
  }).passthrough();
1460
1551
  var deploymentWorkflowSchema = {
1461
- workflow: z2.object({ id: z2.number(), path: z2.string().min(1) }).passthrough().nullish(),
1462
- workflow_run: z2.object({ id: z2.number() }).passthrough().nullish()
1552
+ workflow: z4.object({ id: z4.number(), path: z4.string().min(1) }).passthrough().nullish(),
1553
+ workflow_run: z4.object({ id: z4.number() }).passthrough().nullish()
1463
1554
  };
1464
- var deploymentWebhookSchema = z2.object({
1465
- action: z2.string(),
1555
+ var deploymentWebhookSchema = z4.object({
1556
+ action: z4.string(),
1466
1557
  deployment: deploymentSchema,
1467
1558
  repository: repositorySchema2,
1468
1559
  ...deploymentWorkflowSchema
1469
1560
  }).passthrough();
1470
- var canonicalDeploymentEventSchema = z2.object({
1471
- action: z2.string(),
1472
- commitSha: z2.string().regex(/^[0-9a-f]{40}$/i),
1473
- createdAt: z2.string().optional(),
1474
- deploymentId: z2.number(),
1475
- environment: z2.string().min(1),
1476
- repo: z2.string().min(1),
1477
- workflowId: z2.number().optional(),
1478
- workflowPath: z2.string().min(1).optional(),
1479
- workflowRunId: z2.number().optional()
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()
1480
1571
  }).strict();
1481
1572
  function canonicalDeploymentFields(data) {
1482
1573
  return {
@@ -1513,16 +1604,16 @@ function normalizeDeploymentEvent(deliveryId, body) {
1513
1604
  }));
1514
1605
  }
1515
1606
  var deploymentStatusWebhookSchema = deploymentWebhookSchema.extend({
1516
- deployment_status: z2.object({
1517
- created_at: z2.string().optional(),
1518
- description: z2.string().optional().nullable(),
1519
- state: z2.string()
1607
+ deployment_status: z4.object({
1608
+ created_at: z4.string().optional(),
1609
+ description: z4.string().optional().nullable(),
1610
+ state: z4.string()
1520
1611
  }).passthrough()
1521
1612
  });
1522
1613
  var canonicalDeploymentStatusEventSchema = canonicalDeploymentEventSchema.extend({
1523
- description: z2.string().optional().nullable(),
1524
- state: z2.string(),
1525
- statusCreatedAt: z2.string().optional()
1614
+ description: z4.string().optional().nullable(),
1615
+ state: z4.string(),
1616
+ statusCreatedAt: z4.string().optional()
1526
1617
  }).strict();
1527
1618
  function parseDeploymentStatusEvent(body) {
1528
1619
  const parsed = deploymentStatusWebhookSchema.safeParse(body);
@@ -1571,13 +1662,28 @@ function normalizeDeploymentStatusEvent(deliveryId, body) {
1571
1662
  })
1572
1663
  );
1573
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();
1574
1675
  function deploymentEventData(input) {
1575
- return {
1576
- environment: input.environment.toLowerCase(),
1577
- ...input.workflowId === void 0 ? void 0 : { workflowId: input.workflowId },
1578
- ...input.workflowPath ? { workflowPath: input.workflowPath } : void 0,
1579
- ...input.workflowRunId === void 0 ? void 0 : { workflowRunId: input.workflowRunId }
1580
- };
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
+ );
1581
1687
  }
1582
1688
  function deploymentTargets(input) {
1583
1689
  return [
@@ -1598,47 +1704,92 @@ function deploymentTargets(input) {
1598
1704
  }
1599
1705
  ];
1600
1706
  }
1601
- var issueCommentWebhookSchema = z2.object({
1602
- action: z2.string(),
1603
- comment: z2.object({
1604
- body: z2.string(),
1605
- id: z2.number(),
1606
- user: z2.object({ login: z2.string().optional() }).optional()
1607
- }),
1608
- issue: z2.object({
1609
- draft: z2.boolean().optional(),
1610
- number: z2.number(),
1611
- pull_request: z2.object({ url: z2.string().min(1) }).optional(),
1612
- user: z2.object({
1613
- email: z2.string().optional().nullable(),
1614
- login: z2.string().optional().nullable()
1615
- }).optional().nullable()
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()
1616
1775
  }),
1617
1776
  repository: repositorySchema2,
1618
- sender: z2.object({ id: z2.number(), login: z2.string().min(1) }).optional()
1777
+ sender: senderSchema.optional()
1619
1778
  });
1620
1779
  function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
1621
1780
  const parsed = issueCommentWebhookSchema.safeParse(body);
1622
1781
  if (!parsed.success || parsed.data.action !== "created") return [];
1623
- const author = parsed.data.comment.user?.login;
1782
+ const { comment, issue, sender } = parsed.data;
1783
+ const author = comment.user?.login;
1624
1784
  if (isBotLogin(author, botEmail)) return [];
1625
1785
  const input = {
1626
- number: parsed.data.issue.number,
1786
+ number: issue.number,
1627
1787
  repo: parsed.data.repository.full_name
1628
1788
  };
1629
- if (parsed.data.issue.pull_request) {
1789
+ const writtenBy = commentAuthorData({ botEmail, sender, text: comment.body });
1790
+ if (issue.pull_request) {
1630
1791
  const eventType = "pull_request.comment.created";
1631
1792
  const resource = gitHubPullRequestResource(input);
1632
- const data2 = pullRequestMatchData([
1633
- pullRequestDraftData(parsed.data.issue.draft),
1634
- pullRequestOpenerData(parsed.data.issue.user),
1635
- {
1636
- repo: input.repo,
1637
- pullRequest: input.number,
1638
- commentId: parsed.data.comment.id,
1639
- commentKind: "conversation"
1640
- }
1641
- ]);
1642
1793
  return pullRequestTargets(
1643
1794
  {
1644
1795
  eventKey: gitHubEventKey(deliveryId, eventType),
@@ -1647,54 +1798,55 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
1647
1798
  identifier: resource.identifier,
1648
1799
  trustedSummary: `${resource.label} received a comment${author ? ` from ${author}` : ""}.`,
1649
1800
  ...gitHubDoneBy(author),
1650
- ...data2 ? { data: data2 } : void 0,
1651
- untrustedText: parsed.data.comment.body
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
1652
1811
  },
1653
1812
  input.repo
1654
1813
  );
1655
1814
  }
1656
- const issue = gitHubIssueResource(input);
1815
+ const issueResource = gitHubIssueResource(input);
1657
1816
  const repository = gitHubRepositoryResource(input);
1658
- const sender = parsed.data.sender;
1659
- const data = {
1817
+ const data = issueEventData({
1660
1818
  repo: input.repo,
1661
1819
  issue: input.number,
1662
- commentId: parsed.data.comment.id
1663
- };
1664
- if (sender) {
1665
- data.senderId = sender.id;
1666
- data.senderLogin = sender.login;
1667
- }
1668
- if (botEmail) {
1669
- data.mentionsBot = mentionsBotLogin(parsed.data.comment.body, botEmail);
1670
- }
1671
- return [issue, repository].map((resource) => ({
1820
+ commentId: comment.id,
1821
+ ...writtenBy
1822
+ });
1823
+ return [issueResource, repository].map((resource) => ({
1672
1824
  eventKey: gitHubEventKey(deliveryId, "issue.comment.created"),
1673
1825
  eventType: "issue.comment.created",
1674
1826
  occurredAtMs: Date.now(),
1675
1827
  identifier: resource.identifier,
1676
- trustedSummary: `${issue.label} received a comment${author ? ` from ${author}` : ""}.`,
1828
+ trustedSummary: `${issueResource.label} received a comment${author ? ` from ${author}` : ""}.`,
1677
1829
  ...gitHubDoneBy(author),
1678
1830
  data,
1679
- untrustedText: parsed.data.comment.body
1831
+ untrustedText: comment.body
1680
1832
  }));
1681
1833
  }
1682
- var issueWebhookSchema = z2.object({
1683
- action: z2.string(),
1684
- issue: z2.object({
1685
- body: z2.string().optional().nullable(),
1686
- closed_at: z2.string().optional().nullable(),
1687
- created_at: z2.string().optional(),
1688
- number: z2.number(),
1689
- title: z2.string().optional(),
1690
- updated_at: z2.string().optional()
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()
1691
1843
  }),
1692
1844
  repository: repositorySchema2
1693
1845
  });
1694
- function issueEventText(issue) {
1846
+ function titleAndBodyText(item) {
1695
1847
  const parts = [
1696
- issue.title ? `Title: ${issue.title}` : void 0,
1697
- issue.body?.trim() || void 0
1848
+ item.title ? `Title: ${item.title}` : void 0,
1849
+ nonBlank(item.body)
1698
1850
  ].filter((part) => part !== void 0);
1699
1851
  return parts.length > 0 ? parts.join("\n\n") : void 0;
1700
1852
  }
@@ -1712,68 +1864,37 @@ function normalizeIssueEvents(deliveryId, body) {
1712
1864
  const occurredAtMs = providerTime(
1713
1865
  state === "opened" ? parsed.data.issue.created_at : state === "closed" ? parsed.data.issue.closed_at : parsed.data.issue.updated_at
1714
1866
  ) ?? Date.now();
1715
- const untrustedText = issueEventText(parsed.data.issue);
1716
- return [
1717
- {
1718
- eventKey: gitHubEventKey(deliveryId, `issue.${state}`),
1719
- eventType: `issue.${state}`,
1720
- occurredAtMs,
1721
- identifier: issue.identifier,
1722
- trustedSummary: `${issue.label} was ${state}.`,
1723
- ...untrustedText ? { untrustedText } : void 0
1724
- },
1725
- {
1726
- eventKey: gitHubEventKey(deliveryId, `issue.${state}`),
1727
- eventType: `issue.${state}`,
1728
- occurredAtMs,
1729
- identifier: repository.identifier,
1730
- trustedSummary: `${issue.label} was ${state}.`,
1731
- ...untrustedText ? { untrustedText } : void 0
1732
- }
1733
- ];
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
+ }));
1734
1878
  }
1735
- var pullRequestReviewCommentWebhookSchema = z2.object({
1736
- action: z2.string(),
1737
- comment: z2.object({
1738
- body: z2.string(),
1739
- id: z2.number(),
1740
- user: z2.object({ login: z2.string().optional() }).optional()
1741
- }),
1742
- pull_request: z2.object({
1743
- draft: z2.boolean().optional(),
1744
- head: z2.object({
1745
- ref: z2.string().optional().nullable()
1746
- }).optional().nullable(),
1747
- number: z2.number(),
1748
- user: z2.object({
1749
- email: z2.string().optional().nullable(),
1750
- login: z2.string().optional().nullable()
1751
- }).optional().nullable()
1752
- }),
1753
- 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()
1754
1885
  });
1755
1886
  function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
1756
1887
  const parsed = pullRequestReviewCommentWebhookSchema.safeParse(body);
1757
1888
  if (!parsed.success || parsed.data.action !== "created") return [];
1758
- if (isBotLogin(parsed.data.comment.user?.login, botEmail)) return [];
1889
+ const { comment, pull_request: pullRequest, sender } = parsed.data;
1890
+ const author = comment.user?.login;
1891
+ if (isBotLogin(author, botEmail)) return [];
1759
1892
  const eventType = "pull_request.review_comment.created";
1760
1893
  const repo = parsed.data.repository.full_name;
1761
1894
  const resource = gitHubPullRequestResource({
1762
- number: parsed.data.pull_request.number,
1895
+ number: pullRequest.number,
1763
1896
  repo
1764
1897
  });
1765
- const author = parsed.data.comment.user?.login;
1766
- const data = pullRequestMatchData([
1767
- pullRequestDraftData(parsed.data.pull_request.draft),
1768
- pullRequestOpenerData(parsed.data.pull_request.user),
1769
- pullRequestHeadBranchData(parsed.data.pull_request.head?.ref),
1770
- {
1771
- repo,
1772
- pullRequest: parsed.data.pull_request.number,
1773
- commentId: parsed.data.comment.id,
1774
- commentKind: "review"
1775
- }
1776
- ]);
1777
1898
  return pullRequestTargets(
1778
1899
  {
1779
1900
  eventKey: gitHubEventKey(deliveryId, eventType),
@@ -1782,50 +1903,45 @@ function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
1782
1903
  identifier: resource.identifier,
1783
1904
  trustedSummary: `${resource.label} received an inline review comment${author ? ` from ${author}` : ""}.`,
1784
1905
  ...gitHubDoneBy(author),
1785
- ...data ? { data } : void 0,
1786
- untrustedText: parsed.data.comment.body
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
1787
1916
  },
1788
1917
  repo
1789
1918
  );
1790
1919
  }
1791
- var pullRequestReviewWebhookSchema = z2.object({
1792
- action: z2.string(),
1793
- pull_request: z2.object({
1794
- draft: z2.boolean().optional(),
1795
- head: z2.object({
1796
- ref: z2.string().optional().nullable()
1797
- }).optional().nullable(),
1798
- number: z2.number(),
1799
- user: z2.object({
1800
- email: z2.string().optional().nullable(),
1801
- login: z2.string().optional().nullable()
1802
- }).optional().nullable()
1803
- }),
1920
+ var pullRequestReviewWebhookSchema = z4.object({
1921
+ action: z4.string(),
1922
+ pull_request: pullRequestSchema,
1804
1923
  repository: repositorySchema2,
1805
- review: z2.object({
1806
- body: z2.string().optional().nullable(),
1807
- state: z2.string(),
1808
- user: z2.object({ login: z2.string().optional() }).optional()
1809
- })
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()
1810
1930
  });
1811
1931
  function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
1812
1932
  const parsed = pullRequestReviewWebhookSchema.safeParse(body);
1813
1933
  if (!parsed.success || parsed.data.action !== "submitted") return [];
1814
- if (isBotLogin(parsed.data.review.user?.login, botEmail)) return [];
1815
- const reviewState = parsed.data.review.state.toUpperCase();
1934
+ const { pull_request: pullRequest, review, sender } = parsed.data;
1935
+ if (isBotLogin(review.user?.login, botEmail)) return [];
1936
+ const reviewState = review.state.toUpperCase();
1816
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;
1817
1938
  if (!eventType) return [];
1818
1939
  const repo = parsed.data.repository.full_name;
1819
1940
  const resource = gitHubPullRequestResource({
1820
- number: parsed.data.pull_request.number,
1941
+ number: pullRequest.number,
1821
1942
  repo
1822
1943
  });
1823
- const reviewer = parsed.data.review.user?.login;
1824
- const data = pullRequestMatchData([
1825
- pullRequestDraftData(parsed.data.pull_request.draft),
1826
- pullRequestOpenerData(parsed.data.pull_request.user),
1827
- pullRequestHeadBranchData(parsed.data.pull_request.head?.ref)
1828
- ]);
1944
+ const reviewer = review.user?.login;
1829
1945
  const event = {
1830
1946
  eventKey: gitHubEventKey(deliveryId, eventType),
1831
1947
  eventType,
@@ -1833,11 +1949,15 @@ function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
1833
1949
  identifier: resource.identifier,
1834
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}` : ""}.`,
1835
1951
  ...gitHubDoneBy(reviewer),
1836
- ...data ? { data } : void 0,
1837
- untrustedText: parsed.data.review.body ?? void 0
1952
+ data: pullRequestEventData({
1953
+ comment: commentAuthorData({ botEmail, sender, text: review.body }),
1954
+ pullRequest,
1955
+ repo
1956
+ }),
1957
+ untrustedText: review.body ?? void 0
1838
1958
  };
1839
1959
  const events = pullRequestTargets(event, repo);
1840
- if (eventType !== "pull_request.review.approved" || !parsed.data.review.body?.trim()) {
1960
+ if (eventType !== "pull_request.review.approved" || !nonBlank(review.body)) {
1841
1961
  return events;
1842
1962
  }
1843
1963
  return [
@@ -1852,25 +1972,16 @@ function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
1852
1972
  )
1853
1973
  ];
1854
1974
  }
1855
- var pullRequestWebhookSchema = z2.object({
1856
- action: z2.string(),
1857
- pull_request: z2.object({
1858
- body: z2.string().optional().nullable(),
1859
- closed_at: z2.string().optional().nullable(),
1860
- created_at: z2.string().optional(),
1861
- draft: z2.boolean().optional(),
1862
- head: z2.object({
1863
- ref: z2.string().optional().nullable()
1864
- }).optional().nullable(),
1865
- merged: z2.boolean().optional(),
1866
- merged_at: z2.string().optional().nullable(),
1867
- number: z2.number(),
1868
- title: z2.string().optional(),
1869
- updated_at: z2.string().optional(),
1870
- user: z2.object({
1871
- email: z2.string().optional().nullable(),
1872
- login: z2.string().optional().nullable()
1873
- }).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()
1874
1985
  }),
1875
1986
  repository: repositorySchema2
1876
1987
  });
@@ -1879,76 +1990,48 @@ function providerTime(value) {
1879
1990
  const parsed = Date.parse(value);
1880
1991
  return Number.isFinite(parsed) ? parsed : void 0;
1881
1992
  }
1882
- function pullRequestEventText(pullRequest) {
1883
- const parts = [
1884
- pullRequest.title ? `Title: ${pullRequest.title}` : void 0,
1885
- pullRequest.body?.trim() || void 0
1886
- ].filter((part) => part !== void 0);
1887
- return parts.length > 0 ? parts.join("\n\n") : void 0;
1888
- }
1889
- function pullRequestLifecycleEvents(input) {
1890
- const data = pullRequestMatchData([
1891
- pullRequestDraftData(input.isDraft),
1892
- pullRequestOpenerData({
1893
- email: input.openerEmail,
1894
- login: input.openerUsername
1895
- }),
1896
- pullRequestHeadBranchData(input.headBranch)
1897
- ]);
1898
- return pullRequestTargets(
1899
- {
1900
- eventKey: gitHubEventKey(input.deliveryId, input.eventType),
1901
- eventType: input.eventType,
1902
- occurredAtMs: input.occurredAtMs,
1903
- identifier: input.resource.identifier,
1904
- ...input.terminal ? { terminal: true } : void 0,
1905
- trustedSummary: input.trustedSummary,
1906
- ...data ? { data } : void 0,
1907
- ...input.untrustedText ? { untrustedText: input.untrustedText } : void 0
1908
- },
1909
- input.repo
1910
- );
1911
- }
1912
1993
  function normalizePullRequestEvent(deliveryId, body) {
1913
1994
  const parsed = pullRequestWebhookSchema.safeParse(body);
1914
1995
  if (!parsed.success) return [];
1996
+ const { pull_request: pullRequest } = parsed.data;
1915
1997
  const repo = parsed.data.repository.full_name;
1916
1998
  const resource = gitHubPullRequestResource({
1917
- number: parsed.data.pull_request.number,
1999
+ number: pullRequest.number,
2000
+ repo
2001
+ });
2002
+ const data = pullRequestEventData({ pullRequest, repo });
2003
+ const readyData = pullRequestEventData({
2004
+ pullRequest: { ...pullRequest, draft: false },
1918
2005
  repo
1919
2006
  });
1920
- const draft = parsed.data.pull_request.draft;
1921
- const isDraft = typeof draft === "boolean" ? draft : void 0;
1922
- const opener = pullRequestOpenerData(parsed.data.pull_request.user);
1923
- const headBranch = pullRequestHeadBranchData(
1924
- parsed.data.pull_request.head?.ref
1925
- )?.headBranch;
1926
- const untrustedText = pullRequestEventText(parsed.data.pull_request);
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
+ );
1927
2021
  if (parsed.data.action === "opened") {
1928
- const openedAtMs = providerTime(parsed.data.pull_request.created_at) ?? Date.now();
1929
- const events = pullRequestLifecycleEvents({
1930
- ...opener,
1931
- deliveryId,
2022
+ const openedAtMs = providerTime(pullRequest.created_at) ?? Date.now();
2023
+ const events = lifecycleEvents({
1932
2024
  eventType: "pull_request.opened",
1933
- ...headBranch ? { headBranch } : void 0,
1934
- ...isDraft !== void 0 ? { isDraft } : void 0,
1935
2025
  occurredAtMs: openedAtMs,
1936
- repo,
1937
- resource,
1938
2026
  trustedSummary: `${resource.label} was opened.`,
1939
2027
  untrustedText
1940
2028
  });
1941
- if (draft !== true) {
2029
+ if (pullRequest.draft !== true) {
1942
2030
  events.push(
1943
- ...pullRequestLifecycleEvents({
1944
- ...opener,
1945
- deliveryId,
2031
+ ...lifecycleEvents({
1946
2032
  eventType: "pull_request.ready_for_review",
1947
- ...headBranch ? { headBranch } : void 0,
1948
2033
  isDraft: false,
1949
2034
  occurredAtMs: openedAtMs,
1950
- repo,
1951
- resource,
1952
2035
  trustedSummary: `${resource.label} is ready for review.`,
1953
2036
  untrustedText
1954
2037
  })
@@ -1957,49 +2040,42 @@ function normalizePullRequestEvent(deliveryId, body) {
1957
2040
  return events;
1958
2041
  }
1959
2042
  if (parsed.data.action === "ready_for_review") {
1960
- return pullRequestLifecycleEvents({
1961
- ...opener,
1962
- deliveryId,
2043
+ return lifecycleEvents({
1963
2044
  eventType: "pull_request.ready_for_review",
1964
- ...headBranch ? { headBranch } : void 0,
1965
2045
  isDraft: false,
1966
- occurredAtMs: providerTime(parsed.data.pull_request.updated_at) ?? Date.now(),
1967
- repo,
1968
- resource,
2046
+ occurredAtMs: providerTime(pullRequest.updated_at) ?? Date.now(),
1969
2047
  trustedSummary: `${resource.label} is ready for review.`,
1970
2048
  untrustedText
1971
2049
  });
1972
2050
  }
1973
2051
  if (parsed.data.action !== "closed") return [];
1974
- const eventType = parsed.data.pull_request.merged ? "pull_request.merged" : "pull_request.closed_unmerged";
1975
- return pullRequestLifecycleEvents({
1976
- ...opener,
1977
- deliveryId,
2052
+ const eventType = pullRequest.merged ? "pull_request.merged" : "pull_request.closed_unmerged";
2053
+ return lifecycleEvents({
1978
2054
  eventType,
1979
- ...headBranch ? { headBranch } : void 0,
1980
- ...isDraft !== void 0 ? { isDraft } : void 0,
1981
2055
  occurredAtMs: providerTime(
1982
- parsed.data.pull_request.merged ? parsed.data.pull_request.merged_at : parsed.data.pull_request.closed_at
2056
+ pullRequest.merged ? pullRequest.merged_at : pullRequest.closed_at
1983
2057
  ) ?? Date.now(),
1984
- repo,
1985
- resource,
1986
2058
  terminal: true,
1987
2059
  trustedSummary: eventType === "pull_request.merged" ? `${resource.label} was merged.` : `${resource.label} was closed without being merged.`
1988
2060
  });
1989
2061
  }
1990
- var releaseWebhookSchema = z2.object({
1991
- action: z2.string(),
1992
- release: z2.object({
1993
- body: z2.string().optional().nullable(),
1994
- draft: z2.boolean().optional(),
1995
- id: z2.number(),
1996
- name: z2.string().optional().nullable(),
1997
- prerelease: z2.boolean().optional(),
1998
- published_at: z2.string().optional().nullable(),
1999
- tag_name: z2.string().min(1)
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)
2000
2072
  }).passthrough(),
2001
2073
  repository: repositorySchema2
2002
2074
  }).passthrough();
2075
+ var releaseEventDataSchema = z4.object({
2076
+ repo: gitHubRepoDataSchema,
2077
+ tag: gitHubReleaseTagDataSchema
2078
+ }).strict();
2003
2079
  function releaseSourceTargets(input) {
2004
2080
  return [
2005
2081
  {
@@ -2018,13 +2094,15 @@ function normalizeReleaseEvent(deliveryId, body) {
2018
2094
  if (parsed.data.release.draft) return [];
2019
2095
  const eventType = "release.published";
2020
2096
  const repo = parsed.data.repository.full_name;
2021
- const tag = parsed.data.release.tag_name;
2097
+ const tag = parsed.data.release.tag_name.trim();
2098
+ if (!tag) return [];
2022
2099
  const untrustedParts = [
2023
- tag ? `Tag: ${tag}` : void 0,
2100
+ `Tag: ${tag}`,
2024
2101
  parsed.data.release.name?.trim() ? `Name: ${parsed.data.release.name.trim()}` : void 0,
2025
2102
  parsed.data.release.body?.trim() || void 0
2026
2103
  ].filter((part) => part !== void 0);
2027
2104
  const untrustedText = untrustedParts.length > 0 ? untrustedParts.join("\n\n") : void 0;
2105
+ const data = releaseEventDataSchema.parse({ repo, tag });
2028
2106
  return releaseSourceTargets({ repo, tag }).map(
2029
2107
  ({ completeOnTerminalEvent, resource }) => ({
2030
2108
  eventKey: gitHubEventKey(deliveryId, eventType),
@@ -2033,6 +2111,7 @@ function normalizeReleaseEvent(deliveryId, body) {
2033
2111
  identifier: resource.identifier,
2034
2112
  ...completeOnTerminalEvent ? { terminal: true } : void 0,
2035
2113
  trustedSummary: `${resource.label} was published (release ${parsed.data.release.id}).`,
2114
+ data,
2036
2115
  ...untrustedText ? { untrustedText } : void 0
2037
2116
  })
2038
2117
  );
@@ -2083,7 +2162,7 @@ export {
2083
2162
  readGrantPermissions,
2084
2163
  GITHUB_ISSUE_EVENTS,
2085
2164
  GITHUB_ISSUE_SUGGESTED_EVENTS,
2086
- GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
2165
+ GITHUB_ISSUE_MATCH_FIELDS,
2087
2166
  GITHUB_ISSUE_IDENTIFIER,
2088
2167
  gitHubIssueSubscribable,
2089
2168
  GITHUB_DEPLOYMENT_EVENTS,
@@ -2099,6 +2178,7 @@ export {
2099
2178
  GITHUB_PULL_REQUEST_IDENTIFIER,
2100
2179
  gitHubPullRequestSubscribable,
2101
2180
  GITHUB_RELEASE_EVENTS,
2181
+ GITHUB_RELEASE_MATCH_FIELDS,
2102
2182
  GITHUB_RELEASE_SUGGESTED_EVENTS,
2103
2183
  GITHUB_RELEASE_SOURCE_IDENTIFIER,
2104
2184
  gitHubReleaseSourceSubscribable,
@@ -2129,6 +2209,7 @@ export {
2129
2209
  issueInstallationToken,
2130
2210
  issueGitHubCredential,
2131
2211
  createPermissionCache,
2212
+ definedValues,
2132
2213
  parseCheckSuitePublishTargets,
2133
2214
  needsCheckSuitePullRequestFacts,
2134
2215
  loadCheckSuiteFacts,