@sentry/junior-github 0.265.0 → 0.267.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,40 @@
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
+ case: "lower",
21
+ description: "lowercase repository as owner/repo, such as getsentry/junior",
22
+ events
23
+ }
24
+ });
25
+ }
26
+ function gitHubCommitMatchFields(events) {
27
+ return eventMatchFieldsSchema.parse({
28
+ commitSha: {
29
+ kind: "string",
30
+ case: "lower",
31
+ description: "full lowercase Git commit SHA",
32
+ events
33
+ }
34
+ });
35
+ }
36
+
37
+ // src/events/deployment.ts
8
38
  var GITHUB_DEPLOYMENT_EVENTS = [
9
39
  "deployment.created",
10
40
  "deployment.queued",
@@ -19,9 +49,17 @@ var GITHUB_DEPLOYMENT_SUGGESTED_EVENTS = [
19
49
  "deployment.failed",
20
50
  "deployment.error"
21
51
  ];
22
- var GITHUB_DEPLOYMENT_MATCH_FIELDS = eventMatchFieldsSchema.parse({
52
+ var GITHUB_DEPLOYMENT_MATCH_FIELDS = eventMatchFieldsSchema2.parse({
53
+ ...gitHubRepoMatchFields(GITHUB_DEPLOYMENT_EVENTS),
54
+ ...gitHubCommitMatchFields(GITHUB_DEPLOYMENT_EVENTS),
55
+ deploymentId: {
56
+ kind: "number",
57
+ description: "numeric GitHub deployment id, such as 3001",
58
+ events: [...GITHUB_DEPLOYMENT_EVENTS]
59
+ },
23
60
  environment: {
24
61
  kind: "string",
62
+ case: "lower",
25
63
  description: "lowercase deployment environment name, such as production",
26
64
  events: [...GITHUB_DEPLOYMENT_EVENTS]
27
65
  },
@@ -62,8 +100,34 @@ function gitHubDeploymentSourceSubscribable(input) {
62
100
 
63
101
  // src/events/issue.ts
64
102
  import {
65
- eventMatchFieldsSchema as eventMatchFieldsSchema2
103
+ eventMatchFieldsSchema as eventMatchFieldsSchema4
66
104
  } from "@sentry/junior-plugin-api";
105
+
106
+ // src/events/comment.ts
107
+ import {
108
+ eventMatchFieldsSchema as eventMatchFieldsSchema3
109
+ } from "@sentry/junior-plugin-api";
110
+ function gitHubCommentMatchFields(events) {
111
+ return eventMatchFieldsSchema3.parse({
112
+ mentionsBot: {
113
+ kind: "boolean",
114
+ description: "true when the comment or review mentions this GitHub App",
115
+ events
116
+ },
117
+ senderId: {
118
+ kind: "number",
119
+ description: "immutable numeric GitHub user id of who wrote the comment or review; prefer over logins",
120
+ events
121
+ },
122
+ senderLogin: {
123
+ kind: "string",
124
+ description: "GitHub login of who wrote the comment or review; logins can be renamed",
125
+ events
126
+ }
127
+ });
128
+ }
129
+
130
+ // src/events/issue.ts
67
131
  var GITHUB_ISSUE_EVENTS = [
68
132
  "issue.comment.created",
69
133
  "issue.opened",
@@ -75,21 +139,13 @@ var GITHUB_ISSUE_SUGGESTED_EVENTS = [
75
139
  "issue.closed",
76
140
  "issue.reopened"
77
141
  ];
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: {
142
+ var GITHUB_ISSUE_MATCH_FIELDS = eventMatchFieldsSchema4.parse({
143
+ ...gitHubCommentMatchFields(["issue.comment.created"]),
144
+ ...gitHubRepoMatchFields(GITHUB_ISSUE_EVENTS),
145
+ issue: {
85
146
  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"]
147
+ description: "issue number, such as 12",
148
+ events: GITHUB_ISSUE_EVENTS
93
149
  }
94
150
  });
95
151
  var GITHUB_ISSUE_IDENTIFIER = {
@@ -115,7 +171,7 @@ function gitHubIssueSubscribable(input) {
115
171
 
116
172
  // src/events/pull-request.ts
117
173
  import {
118
- eventMatchFieldsSchema as eventMatchFieldsSchema3
174
+ eventMatchFieldsSchema as eventMatchFieldsSchema5
119
175
  } from "@sentry/junior-plugin-api";
120
176
  var GITHUB_PULL_REQUEST_EVENTS = [
121
177
  "pull_request.checks.failed",
@@ -168,7 +224,26 @@ var GITHUB_PULL_REQUEST_SUGGESTED_EVENTS = [
168
224
  "pull_request.merged",
169
225
  "pull_request.closed_unmerged"
170
226
  ];
171
- var GITHUB_PULL_REQUEST_MATCH_FIELDS = eventMatchFieldsSchema3.parse({
227
+ var GITHUB_PULL_REQUEST_COMMENT_EVENTS = [
228
+ "pull_request.comment.created",
229
+ "pull_request.review.approved",
230
+ "pull_request.review.changes_requested",
231
+ "pull_request.review.commented",
232
+ "pull_request.review_comment.created"
233
+ ];
234
+ var GITHUB_PULL_REQUEST_CHECK_EVENTS = [
235
+ "pull_request.checks.failed",
236
+ "pull_request.checks.recovered"
237
+ ];
238
+ var GITHUB_PULL_REQUEST_MATCH_FIELDS = eventMatchFieldsSchema5.parse({
239
+ ...gitHubCommentMatchFields(GITHUB_PULL_REQUEST_COMMENT_EVENTS),
240
+ ...gitHubRepoMatchFields(GITHUB_PULL_REQUEST_EVENTS),
241
+ ...gitHubCommitMatchFields(GITHUB_PULL_REQUEST_CHECK_EVENTS),
242
+ pullRequest: {
243
+ kind: "number",
244
+ description: "pull request number, such as 946",
245
+ events: [...GITHUB_PULL_REQUEST_EVENTS]
246
+ },
172
247
  authors: {
173
248
  kind: "string",
174
249
  list: true,
@@ -229,7 +304,22 @@ function gitHubPullRequestSubscribable(input) {
229
304
  }
230
305
 
231
306
  // src/events/release.ts
307
+ import {
308
+ eventMatchFieldsSchema as eventMatchFieldsSchema6
309
+ } from "@sentry/junior-plugin-api";
310
+ import { z as z2 } from "zod";
232
311
  var GITHUB_RELEASE_EVENTS = ["release.published"];
312
+ var gitHubReleaseTagDataSchema = z2.string().trim().min(1).transform(
313
+ (tag) => tag.replace(/[A-Z]+/g, (letters) => letters.toLowerCase())
314
+ );
315
+ var GITHUB_RELEASE_MATCH_FIELDS = eventMatchFieldsSchema6.parse({
316
+ ...gitHubRepoMatchFields(GITHUB_RELEASE_EVENTS),
317
+ tag: {
318
+ kind: "string",
319
+ description: "release tag with ASCII letters in lowercase, such as v1.2.0 or release/1.0",
320
+ events: [...GITHUB_RELEASE_EVENTS]
321
+ }
322
+ });
233
323
  var GITHUB_RELEASE_SUGGESTED_EVENTS = ["release.published"];
234
324
  var GITHUB_RELEASE_SOURCE_IDENTIFIER = {
235
325
  format: "release-source:owner/repo[:tag]",
@@ -288,7 +378,7 @@ function gitHubRepositorySubscribable(input) {
288
378
  }
289
379
 
290
380
  // src/webhooks/check-suite.ts
291
- import { z } from "zod";
381
+ import { z as z3 } from "zod";
292
382
 
293
383
  // src/credential-support.ts
294
384
  import { createPrivateKey, createSign } from "crypto";
@@ -973,6 +1063,11 @@ function createPermissionCache() {
973
1063
  }
974
1064
 
975
1065
  // src/webhooks/event-targets.ts
1066
+ function definedValues(data) {
1067
+ return Object.fromEntries(
1068
+ Object.entries(data).filter(([, value]) => value !== void 0)
1069
+ );
1070
+ }
976
1071
  function gitHubEventKey(deliveryId, eventType) {
977
1072
  return `github:${deliveryId}:${eventType}`;
978
1073
  }
@@ -994,48 +1089,48 @@ var CHECK_SUITE_PULL_REQUEST_MATCH_KEYS = /* @__PURE__ */ new Set([
994
1089
  "openerRole",
995
1090
  "openerUsername"
996
1091
  ]);
997
- var checkRunRepoRefSchema = z.object({
998
- id: z.number(),
999
- name: z.string().min(1),
1000
- url: z.string().min(1)
1092
+ var checkRunRepoRefSchema = z3.object({
1093
+ id: z3.number(),
1094
+ name: z3.string().min(1),
1095
+ url: z3.string().min(1)
1001
1096
  }).passthrough();
1002
- var checkRunPullRequestSideSchema = z.object({
1003
- ref: z.string().optional(),
1097
+ var checkRunPullRequestSideSchema = z3.object({
1098
+ ref: z3.string().optional(),
1004
1099
  repo: checkRunRepoRefSchema,
1005
- sha: z.string().optional()
1100
+ sha: z3.string().optional()
1006
1101
  }).passthrough();
1007
- var checkRunPullRequestSchema = z.object({
1102
+ var checkRunPullRequestSchema = z3.object({
1008
1103
  base: checkRunPullRequestSideSchema,
1009
1104
  head: checkRunPullRequestSideSchema.optional(),
1010
- id: z.number().optional(),
1011
- number: z.number(),
1012
- url: z.string().optional()
1105
+ id: z3.number().optional(),
1106
+ number: z3.number(),
1107
+ url: z3.string().optional()
1013
1108
  }).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()
1109
+ var repositorySchema = z3.object({
1110
+ full_name: z3.string().min(1),
1111
+ id: z3.number(),
1112
+ name: z3.string().min(1),
1113
+ owner: z3.object({ login: z3.string().min(1) }).passthrough()
1019
1114
  }).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()
1115
+ var checkSuiteWebhookSchema = z3.object({
1116
+ action: z3.string(),
1117
+ check_suite: z3.object({
1118
+ app: z3.object({
1119
+ name: z3.string().optional().nullable(),
1120
+ slug: z3.string().optional().nullable()
1026
1121
  }).optional().nullable(),
1027
- conclusion: z.string().optional().nullable(),
1122
+ conclusion: z3.string().optional().nullable(),
1028
1123
  /** 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)
1124
+ head_branch: z3.string().optional().nullable(),
1125
+ head_sha: z3.string().optional(),
1126
+ id: z3.number().optional(),
1127
+ latest_check_runs_count: z3.number().optional().nullable(),
1128
+ pull_requests: z3.array(checkRunPullRequestSchema)
1034
1129
  }),
1035
1130
  repository: repositorySchema
1036
1131
  });
1037
- var checkRunsListResponseSchema = z.object({
1038
- check_runs: z.array(z.unknown()).optional()
1132
+ var checkRunsListResponseSchema = z3.object({
1133
+ check_runs: z3.array(z3.unknown()).optional()
1039
1134
  }).passthrough();
1040
1135
  function isCheckSuiteRepositoryPullRequest(pullRequest, repositoryId) {
1041
1136
  return pullRequest.base.repo.id === repositoryId;
@@ -1069,6 +1164,29 @@ function checkSuiteHeadBranch(value) {
1069
1164
  const branch = value?.trim();
1070
1165
  return branch ? branch : void 0;
1071
1166
  }
1167
+ var checkSuiteEventDataSchema = z3.object({
1168
+ repo: gitHubRepoDataSchema,
1169
+ pullRequest: z3.number().optional(),
1170
+ commitSha: gitHubCommitShaDataSchema.optional(),
1171
+ suiteConclusion: z3.string().min(1),
1172
+ isDraft: z3.boolean().optional(),
1173
+ openerUsername: z3.string().min(1).optional(),
1174
+ openerEmail: z3.string().min(1).optional(),
1175
+ headBranch: z3.string().min(1).optional(),
1176
+ checkSuiteId: z3.number().optional(),
1177
+ checkSuiteUrl: z3.string().min(1).optional(),
1178
+ appName: z3.string().min(1).optional(),
1179
+ latestCheckRunsCount: z3.number().optional(),
1180
+ // Only system-set handles. Check names come from workflow YAML, so they
1181
+ // go in the untrusted text.
1182
+ failingChecks: z3.array(
1183
+ z3.object({
1184
+ conclusion: z3.string(),
1185
+ htmlUrl: z3.string().optional(),
1186
+ checkRunId: z3.number()
1187
+ }).strict()
1188
+ ).optional()
1189
+ }).strict();
1072
1190
  function buildCheckSuiteEvent(args) {
1073
1191
  const pullRequestNumber = args.pullRequestNumber;
1074
1192
  const resource = pullRequestNumber === void 0 ? gitHubRepositoryResource({ repo: args.repo }) : gitHubPullRequestResource({
@@ -1080,36 +1198,32 @@ function buildCheckSuiteEvent(args) {
1080
1198
  const failingCount = failingChecks.length;
1081
1199
  const branchSuffix = args.headBranch ? ` on ${args.headBranch}` : "";
1082
1200
  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({
1201
+ const data = checkSuiteEventDataSchema.parse(
1202
+ definedValues({
1203
+ repo: args.repo,
1204
+ pullRequest: pullRequestNumber,
1205
+ // A short SHA counts as missing, so a commitSha filter does not match.
1206
+ commitSha: gitHubCommitShaDataSchema.safeParse(args.headSha).data,
1207
+ suiteConclusion: args.suiteConclusion,
1208
+ isDraft: args.isDraft,
1209
+ openerUsername: args.openerUsername,
1210
+ openerEmail: args.openerEmail,
1211
+ headBranch: args.headBranch,
1097
1212
  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
- }
1213
+ checkSuiteUrl: args.checkSuiteId !== void 0 && args.headSha ? buildCheckSuiteUrl({
1214
+ checkSuiteId: args.checkSuiteId,
1215
+ headSha: args.headSha,
1216
+ repo: args.repo
1217
+ }) : void 0,
1218
+ appName: args.appName ? oneLineLabel(args.appName, 120) : void 0,
1219
+ latestCheckRunsCount: args.latestCheckRunsCount,
1220
+ failingChecks: args.eventType === "pull_request.checks.failed" && failingCount > 0 ? failingChecks.map((check) => ({
1221
+ conclusion: check.conclusion,
1222
+ ...check.htmlUrl ? { htmlUrl: check.htmlUrl } : void 0,
1223
+ checkRunId: check.checkRunId
1224
+ })) : void 0
1225
+ })
1226
+ );
1113
1227
  const untrustedParts = args.eventType === "pull_request.checks.failed" ? failingChecks.map((check) => {
1114
1228
  const name = oneLineLabel(check.name);
1115
1229
  if (!name) return void 0;
@@ -1225,6 +1339,9 @@ function parseCheckSuitePublishTargets(body) {
1225
1339
  );
1226
1340
  }
1227
1341
  return {
1342
+ // Every copy sets this repo, so a broad trigger for another repo adds
1343
+ // no lazy keys.
1344
+ data: { repo: gitHubRepoDataSchema.parse(repo) },
1228
1345
  eventTypes: [eventType],
1229
1346
  identifiers: [...identifiers]
1230
1347
  };
@@ -1423,60 +1540,40 @@ function mentionsBotLogin(text, botEmail) {
1423
1540
  }
1424
1541
 
1425
1542
  // 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
1543
  function gitHubDoneBy(login) {
1442
1544
  const handle = login?.trim();
1443
1545
  return handle ? { doneBy: { provider: "github", handle } } : void 0;
1444
1546
  }
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;
1547
+ function nonBlank(value) {
1548
+ return value?.trim() || void 0;
1452
1549
  }
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)
1550
+ var repositorySchema2 = z4.object({ full_name: z4.string().min(1) }).passthrough();
1551
+ var deploymentSchema = z4.object({
1552
+ created_at: z4.string().optional(),
1553
+ environment: z4.string().trim().min(1),
1554
+ id: z4.number(),
1555
+ sha: z4.string().regex(/^[0-9a-f]{40}$/i)
1459
1556
  }).passthrough();
1460
1557
  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()
1558
+ workflow: z4.object({ id: z4.number(), path: z4.string().min(1) }).passthrough().nullish(),
1559
+ workflow_run: z4.object({ id: z4.number() }).passthrough().nullish()
1463
1560
  };
1464
- var deploymentWebhookSchema = z2.object({
1465
- action: z2.string(),
1561
+ var deploymentWebhookSchema = z4.object({
1562
+ action: z4.string(),
1466
1563
  deployment: deploymentSchema,
1467
1564
  repository: repositorySchema2,
1468
1565
  ...deploymentWorkflowSchema
1469
1566
  }).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()
1567
+ var canonicalDeploymentEventSchema = z4.object({
1568
+ action: z4.string(),
1569
+ commitSha: z4.string().regex(/^[0-9a-f]{40}$/i),
1570
+ createdAt: z4.string().optional(),
1571
+ deploymentId: z4.number(),
1572
+ environment: z4.string().min(1),
1573
+ repo: z4.string().min(1),
1574
+ workflowId: z4.number().optional(),
1575
+ workflowPath: z4.string().min(1).optional(),
1576
+ workflowRunId: z4.number().optional()
1480
1577
  }).strict();
1481
1578
  function canonicalDeploymentFields(data) {
1482
1579
  return {
@@ -1513,16 +1610,16 @@ function normalizeDeploymentEvent(deliveryId, body) {
1513
1610
  }));
1514
1611
  }
1515
1612
  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()
1613
+ deployment_status: z4.object({
1614
+ created_at: z4.string().optional(),
1615
+ description: z4.string().optional().nullable(),
1616
+ state: z4.string()
1520
1617
  }).passthrough()
1521
1618
  });
1522
1619
  var canonicalDeploymentStatusEventSchema = canonicalDeploymentEventSchema.extend({
1523
- description: z2.string().optional().nullable(),
1524
- state: z2.string(),
1525
- statusCreatedAt: z2.string().optional()
1620
+ description: z4.string().optional().nullable(),
1621
+ state: z4.string(),
1622
+ statusCreatedAt: z4.string().optional()
1526
1623
  }).strict();
1527
1624
  function parseDeploymentStatusEvent(body) {
1528
1625
  const parsed = deploymentStatusWebhookSchema.safeParse(body);
@@ -1571,13 +1668,28 @@ function normalizeDeploymentStatusEvent(deliveryId, body) {
1571
1668
  })
1572
1669
  );
1573
1670
  }
1671
+ var deploymentEventDataSchema = z4.object({
1672
+ repo: gitHubRepoDataSchema,
1673
+ commitSha: gitHubCommitShaDataSchema,
1674
+ deploymentId: z4.number(),
1675
+ // Trimmed and lowercase, the same as in the identifier.
1676
+ environment: z4.string().trim().min(1).toLowerCase(),
1677
+ workflowId: z4.number().optional(),
1678
+ workflowPath: z4.string().min(1).optional(),
1679
+ workflowRunId: z4.number().optional()
1680
+ }).strict();
1574
1681
  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
- };
1682
+ return deploymentEventDataSchema.parse(
1683
+ definedValues({
1684
+ repo: input.repo,
1685
+ commitSha: input.commitSha,
1686
+ deploymentId: input.deploymentId,
1687
+ environment: input.environment,
1688
+ workflowId: input.workflowId,
1689
+ workflowPath: input.workflowPath,
1690
+ workflowRunId: input.workflowRunId
1691
+ })
1692
+ );
1581
1693
  }
1582
1694
  function deploymentTargets(input) {
1583
1695
  return [
@@ -1598,47 +1710,92 @@ function deploymentTargets(input) {
1598
1710
  }
1599
1711
  ];
1600
1712
  }
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()
1713
+ var gitHubUserSchema = z4.object({
1714
+ email: z4.string().nullish(),
1715
+ login: z4.string().nullish()
1716
+ });
1717
+ var senderSchema = z4.object({ id: z4.number(), login: z4.string().min(1) });
1718
+ var commentSchema = z4.object({
1719
+ body: z4.string(),
1720
+ id: z4.number(),
1721
+ user: z4.object({ login: z4.string().optional() }).optional()
1722
+ });
1723
+ var commentAuthorDataSchema = z4.object({
1724
+ mentionsBot: z4.boolean().optional(),
1725
+ senderId: z4.number().optional(),
1726
+ senderLogin: z4.string().min(1).optional()
1727
+ });
1728
+ function commentAuthorData(input) {
1729
+ return {
1730
+ mentionsBot: input.botEmail ? mentionsBotLogin(input.text ?? "", input.botEmail) : void 0,
1731
+ senderId: input.sender?.id,
1732
+ senderLogin: input.sender?.login
1733
+ };
1734
+ }
1735
+ var pullRequestSchema = z4.object({
1736
+ draft: z4.boolean().optional(),
1737
+ head: z4.object({ ref: z4.string().nullish() }).nullish(),
1738
+ number: z4.number(),
1739
+ user: gitHubUserSchema.nullish()
1740
+ });
1741
+ var pullRequestEventDataSchema = commentAuthorDataSchema.extend({
1742
+ repo: gitHubRepoDataSchema,
1743
+ pullRequest: z4.number(),
1744
+ headBranch: z4.string().min(1).optional(),
1745
+ isDraft: z4.boolean().optional(),
1746
+ openerEmail: z4.string().min(1).optional(),
1747
+ openerUsername: z4.string().min(1).optional(),
1748
+ commentId: z4.number().optional(),
1749
+ commentKind: z4.enum(["conversation", "review"]).optional()
1750
+ }).strict();
1751
+ function pullRequestEventData(input) {
1752
+ const { pullRequest } = input;
1753
+ return pullRequestEventDataSchema.parse(
1754
+ definedValues({
1755
+ repo: input.repo,
1756
+ pullRequest: pullRequest.number,
1757
+ headBranch: nonBlank(pullRequest.head?.ref),
1758
+ isDraft: pullRequest.draft,
1759
+ openerEmail: nonBlank(pullRequest.user?.email),
1760
+ openerUsername: nonBlank(pullRequest.user?.login),
1761
+ ...input.comment
1762
+ })
1763
+ );
1764
+ }
1765
+ var issueEventDataSchema = commentAuthorDataSchema.extend({
1766
+ repo: gitHubRepoDataSchema,
1767
+ issue: z4.number(),
1768
+ commentId: z4.number().optional()
1769
+ }).strict();
1770
+ function issueEventData(input) {
1771
+ return issueEventDataSchema.parse(definedValues(input));
1772
+ }
1773
+ var issueCommentWebhookSchema = z4.object({
1774
+ action: z4.string(),
1775
+ comment: commentSchema,
1776
+ issue: z4.object({
1777
+ draft: z4.boolean().optional(),
1778
+ number: z4.number(),
1779
+ pull_request: z4.object({ url: z4.string().min(1) }).optional(),
1780
+ user: gitHubUserSchema.nullish()
1616
1781
  }),
1617
1782
  repository: repositorySchema2,
1618
- sender: z2.object({ id: z2.number(), login: z2.string().min(1) }).optional()
1783
+ sender: senderSchema.optional()
1619
1784
  });
1620
1785
  function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
1621
1786
  const parsed = issueCommentWebhookSchema.safeParse(body);
1622
1787
  if (!parsed.success || parsed.data.action !== "created") return [];
1623
- const author = parsed.data.comment.user?.login;
1788
+ const { comment, issue, sender } = parsed.data;
1789
+ const author = comment.user?.login;
1624
1790
  if (isBotLogin(author, botEmail)) return [];
1625
1791
  const input = {
1626
- number: parsed.data.issue.number,
1792
+ number: issue.number,
1627
1793
  repo: parsed.data.repository.full_name
1628
1794
  };
1629
- if (parsed.data.issue.pull_request) {
1795
+ const writtenBy = commentAuthorData({ botEmail, sender, text: comment.body });
1796
+ if (issue.pull_request) {
1630
1797
  const eventType = "pull_request.comment.created";
1631
1798
  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
1799
  return pullRequestTargets(
1643
1800
  {
1644
1801
  eventKey: gitHubEventKey(deliveryId, eventType),
@@ -1647,54 +1804,55 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
1647
1804
  identifier: resource.identifier,
1648
1805
  trustedSummary: `${resource.label} received a comment${author ? ` from ${author}` : ""}.`,
1649
1806
  ...gitHubDoneBy(author),
1650
- ...data2 ? { data: data2 } : void 0,
1651
- untrustedText: parsed.data.comment.body
1807
+ data: pullRequestEventData({
1808
+ comment: {
1809
+ commentId: comment.id,
1810
+ commentKind: "conversation",
1811
+ ...writtenBy
1812
+ },
1813
+ pullRequest: issue,
1814
+ repo: input.repo
1815
+ }),
1816
+ untrustedText: comment.body
1652
1817
  },
1653
1818
  input.repo
1654
1819
  );
1655
1820
  }
1656
- const issue = gitHubIssueResource(input);
1821
+ const issueResource = gitHubIssueResource(input);
1657
1822
  const repository = gitHubRepositoryResource(input);
1658
- const sender = parsed.data.sender;
1659
- const data = {
1823
+ const data = issueEventData({
1660
1824
  repo: input.repo,
1661
1825
  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) => ({
1826
+ commentId: comment.id,
1827
+ ...writtenBy
1828
+ });
1829
+ return [issueResource, repository].map((resource) => ({
1672
1830
  eventKey: gitHubEventKey(deliveryId, "issue.comment.created"),
1673
1831
  eventType: "issue.comment.created",
1674
1832
  occurredAtMs: Date.now(),
1675
1833
  identifier: resource.identifier,
1676
- trustedSummary: `${issue.label} received a comment${author ? ` from ${author}` : ""}.`,
1834
+ trustedSummary: `${issueResource.label} received a comment${author ? ` from ${author}` : ""}.`,
1677
1835
  ...gitHubDoneBy(author),
1678
1836
  data,
1679
- untrustedText: parsed.data.comment.body
1837
+ untrustedText: comment.body
1680
1838
  }));
1681
1839
  }
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()
1840
+ var issueWebhookSchema = z4.object({
1841
+ action: z4.string(),
1842
+ issue: z4.object({
1843
+ body: z4.string().optional().nullable(),
1844
+ closed_at: z4.string().optional().nullable(),
1845
+ created_at: z4.string().optional(),
1846
+ number: z4.number(),
1847
+ title: z4.string().optional(),
1848
+ updated_at: z4.string().optional()
1691
1849
  }),
1692
1850
  repository: repositorySchema2
1693
1851
  });
1694
- function issueEventText(issue) {
1852
+ function titleAndBodyText(item) {
1695
1853
  const parts = [
1696
- issue.title ? `Title: ${issue.title}` : void 0,
1697
- issue.body?.trim() || void 0
1854
+ item.title ? `Title: ${item.title}` : void 0,
1855
+ nonBlank(item.body)
1698
1856
  ].filter((part) => part !== void 0);
1699
1857
  return parts.length > 0 ? parts.join("\n\n") : void 0;
1700
1858
  }
@@ -1712,68 +1870,37 @@ function normalizeIssueEvents(deliveryId, body) {
1712
1870
  const occurredAtMs = providerTime(
1713
1871
  state === "opened" ? parsed.data.issue.created_at : state === "closed" ? parsed.data.issue.closed_at : parsed.data.issue.updated_at
1714
1872
  ) ?? 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
- ];
1873
+ const data = issueEventData({ repo: input.repo, issue: input.number });
1874
+ const untrustedText = titleAndBodyText(parsed.data.issue);
1875
+ return [issue, repository].map((resource) => ({
1876
+ eventKey: gitHubEventKey(deliveryId, `issue.${state}`),
1877
+ eventType: `issue.${state}`,
1878
+ occurredAtMs,
1879
+ identifier: resource.identifier,
1880
+ trustedSummary: `${issue.label} was ${state}.`,
1881
+ data,
1882
+ ...untrustedText ? { untrustedText } : void 0
1883
+ }));
1734
1884
  }
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
1885
+ var pullRequestReviewCommentWebhookSchema = z4.object({
1886
+ action: z4.string(),
1887
+ comment: commentSchema,
1888
+ pull_request: pullRequestSchema,
1889
+ repository: repositorySchema2,
1890
+ sender: senderSchema.optional()
1754
1891
  });
1755
1892
  function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
1756
1893
  const parsed = pullRequestReviewCommentWebhookSchema.safeParse(body);
1757
1894
  if (!parsed.success || parsed.data.action !== "created") return [];
1758
- if (isBotLogin(parsed.data.comment.user?.login, botEmail)) return [];
1895
+ const { comment, pull_request: pullRequest, sender } = parsed.data;
1896
+ const author = comment.user?.login;
1897
+ if (isBotLogin(author, botEmail)) return [];
1759
1898
  const eventType = "pull_request.review_comment.created";
1760
1899
  const repo = parsed.data.repository.full_name;
1761
1900
  const resource = gitHubPullRequestResource({
1762
- number: parsed.data.pull_request.number,
1901
+ number: pullRequest.number,
1763
1902
  repo
1764
1903
  });
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
1904
  return pullRequestTargets(
1778
1905
  {
1779
1906
  eventKey: gitHubEventKey(deliveryId, eventType),
@@ -1782,50 +1909,45 @@ function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
1782
1909
  identifier: resource.identifier,
1783
1910
  trustedSummary: `${resource.label} received an inline review comment${author ? ` from ${author}` : ""}.`,
1784
1911
  ...gitHubDoneBy(author),
1785
- ...data ? { data } : void 0,
1786
- untrustedText: parsed.data.comment.body
1912
+ data: pullRequestEventData({
1913
+ comment: {
1914
+ commentId: comment.id,
1915
+ commentKind: "review",
1916
+ ...commentAuthorData({ botEmail, sender, text: comment.body })
1917
+ },
1918
+ pullRequest,
1919
+ repo
1920
+ }),
1921
+ untrustedText: comment.body
1787
1922
  },
1788
1923
  repo
1789
1924
  );
1790
1925
  }
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
- }),
1926
+ var pullRequestReviewWebhookSchema = z4.object({
1927
+ action: z4.string(),
1928
+ pull_request: pullRequestSchema,
1804
1929
  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
- })
1930
+ review: z4.object({
1931
+ body: z4.string().optional().nullable(),
1932
+ state: z4.string(),
1933
+ user: z4.object({ login: z4.string().optional() }).optional()
1934
+ }),
1935
+ sender: senderSchema.optional()
1810
1936
  });
1811
1937
  function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
1812
1938
  const parsed = pullRequestReviewWebhookSchema.safeParse(body);
1813
1939
  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();
1940
+ const { pull_request: pullRequest, review, sender } = parsed.data;
1941
+ if (isBotLogin(review.user?.login, botEmail)) return [];
1942
+ const reviewState = review.state.toUpperCase();
1816
1943
  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
1944
  if (!eventType) return [];
1818
1945
  const repo = parsed.data.repository.full_name;
1819
1946
  const resource = gitHubPullRequestResource({
1820
- number: parsed.data.pull_request.number,
1947
+ number: pullRequest.number,
1821
1948
  repo
1822
1949
  });
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
- ]);
1950
+ const reviewer = review.user?.login;
1829
1951
  const event = {
1830
1952
  eventKey: gitHubEventKey(deliveryId, eventType),
1831
1953
  eventType,
@@ -1833,11 +1955,15 @@ function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
1833
1955
  identifier: resource.identifier,
1834
1956
  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
1957
  ...gitHubDoneBy(reviewer),
1836
- ...data ? { data } : void 0,
1837
- untrustedText: parsed.data.review.body ?? void 0
1958
+ data: pullRequestEventData({
1959
+ comment: commentAuthorData({ botEmail, sender, text: review.body }),
1960
+ pullRequest,
1961
+ repo
1962
+ }),
1963
+ untrustedText: review.body ?? void 0
1838
1964
  };
1839
1965
  const events = pullRequestTargets(event, repo);
1840
- if (eventType !== "pull_request.review.approved" || !parsed.data.review.body?.trim()) {
1966
+ if (eventType !== "pull_request.review.approved" || !nonBlank(review.body)) {
1841
1967
  return events;
1842
1968
  }
1843
1969
  return [
@@ -1852,25 +1978,16 @@ function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
1852
1978
  )
1853
1979
  ];
1854
1980
  }
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()
1981
+ var pullRequestWebhookSchema = z4.object({
1982
+ action: z4.string(),
1983
+ pull_request: pullRequestSchema.extend({
1984
+ body: z4.string().optional().nullable(),
1985
+ closed_at: z4.string().optional().nullable(),
1986
+ created_at: z4.string().optional(),
1987
+ merged: z4.boolean().optional(),
1988
+ merged_at: z4.string().optional().nullable(),
1989
+ title: z4.string().optional(),
1990
+ updated_at: z4.string().optional()
1874
1991
  }),
1875
1992
  repository: repositorySchema2
1876
1993
  });
@@ -1879,76 +1996,48 @@ function providerTime(value) {
1879
1996
  const parsed = Date.parse(value);
1880
1997
  return Number.isFinite(parsed) ? parsed : void 0;
1881
1998
  }
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
1999
  function normalizePullRequestEvent(deliveryId, body) {
1913
2000
  const parsed = pullRequestWebhookSchema.safeParse(body);
1914
2001
  if (!parsed.success) return [];
2002
+ const { pull_request: pullRequest } = parsed.data;
1915
2003
  const repo = parsed.data.repository.full_name;
1916
2004
  const resource = gitHubPullRequestResource({
1917
- number: parsed.data.pull_request.number,
2005
+ number: pullRequest.number,
2006
+ repo
2007
+ });
2008
+ const data = pullRequestEventData({ pullRequest, repo });
2009
+ const readyData = pullRequestEventData({
2010
+ pullRequest: { ...pullRequest, draft: false },
1918
2011
  repo
1919
2012
  });
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);
2013
+ const untrustedText = titleAndBodyText(pullRequest);
2014
+ const lifecycleEvents = (event) => pullRequestTargets(
2015
+ {
2016
+ eventKey: gitHubEventKey(deliveryId, event.eventType),
2017
+ eventType: event.eventType,
2018
+ occurredAtMs: event.occurredAtMs,
2019
+ identifier: resource.identifier,
2020
+ ...event.terminal ? { terminal: true } : void 0,
2021
+ trustedSummary: event.trustedSummary,
2022
+ data: event.isDraft === false ? readyData : data,
2023
+ ...event.untrustedText ? { untrustedText: event.untrustedText } : void 0
2024
+ },
2025
+ repo
2026
+ );
1927
2027
  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,
2028
+ const openedAtMs = providerTime(pullRequest.created_at) ?? Date.now();
2029
+ const events = lifecycleEvents({
1932
2030
  eventType: "pull_request.opened",
1933
- ...headBranch ? { headBranch } : void 0,
1934
- ...isDraft !== void 0 ? { isDraft } : void 0,
1935
2031
  occurredAtMs: openedAtMs,
1936
- repo,
1937
- resource,
1938
2032
  trustedSummary: `${resource.label} was opened.`,
1939
2033
  untrustedText
1940
2034
  });
1941
- if (draft !== true) {
2035
+ if (pullRequest.draft !== true) {
1942
2036
  events.push(
1943
- ...pullRequestLifecycleEvents({
1944
- ...opener,
1945
- deliveryId,
2037
+ ...lifecycleEvents({
1946
2038
  eventType: "pull_request.ready_for_review",
1947
- ...headBranch ? { headBranch } : void 0,
1948
2039
  isDraft: false,
1949
2040
  occurredAtMs: openedAtMs,
1950
- repo,
1951
- resource,
1952
2041
  trustedSummary: `${resource.label} is ready for review.`,
1953
2042
  untrustedText
1954
2043
  })
@@ -1957,49 +2046,42 @@ function normalizePullRequestEvent(deliveryId, body) {
1957
2046
  return events;
1958
2047
  }
1959
2048
  if (parsed.data.action === "ready_for_review") {
1960
- return pullRequestLifecycleEvents({
1961
- ...opener,
1962
- deliveryId,
2049
+ return lifecycleEvents({
1963
2050
  eventType: "pull_request.ready_for_review",
1964
- ...headBranch ? { headBranch } : void 0,
1965
2051
  isDraft: false,
1966
- occurredAtMs: providerTime(parsed.data.pull_request.updated_at) ?? Date.now(),
1967
- repo,
1968
- resource,
2052
+ occurredAtMs: providerTime(pullRequest.updated_at) ?? Date.now(),
1969
2053
  trustedSummary: `${resource.label} is ready for review.`,
1970
2054
  untrustedText
1971
2055
  });
1972
2056
  }
1973
2057
  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,
2058
+ const eventType = pullRequest.merged ? "pull_request.merged" : "pull_request.closed_unmerged";
2059
+ return lifecycleEvents({
1978
2060
  eventType,
1979
- ...headBranch ? { headBranch } : void 0,
1980
- ...isDraft !== void 0 ? { isDraft } : void 0,
1981
2061
  occurredAtMs: providerTime(
1982
- parsed.data.pull_request.merged ? parsed.data.pull_request.merged_at : parsed.data.pull_request.closed_at
2062
+ pullRequest.merged ? pullRequest.merged_at : pullRequest.closed_at
1983
2063
  ) ?? Date.now(),
1984
- repo,
1985
- resource,
1986
2064
  terminal: true,
1987
2065
  trustedSummary: eventType === "pull_request.merged" ? `${resource.label} was merged.` : `${resource.label} was closed without being merged.`
1988
2066
  });
1989
2067
  }
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)
2068
+ var releaseWebhookSchema = z4.object({
2069
+ action: z4.string(),
2070
+ release: z4.object({
2071
+ body: z4.string().optional().nullable(),
2072
+ draft: z4.boolean().optional(),
2073
+ id: z4.number(),
2074
+ name: z4.string().optional().nullable(),
2075
+ prerelease: z4.boolean().optional(),
2076
+ published_at: z4.string().optional().nullable(),
2077
+ tag_name: z4.string().min(1)
2000
2078
  }).passthrough(),
2001
2079
  repository: repositorySchema2
2002
2080
  }).passthrough();
2081
+ var releaseEventDataSchema = z4.object({
2082
+ repo: gitHubRepoDataSchema,
2083
+ tag: gitHubReleaseTagDataSchema
2084
+ }).strict();
2003
2085
  function releaseSourceTargets(input) {
2004
2086
  return [
2005
2087
  {
@@ -2018,13 +2100,15 @@ function normalizeReleaseEvent(deliveryId, body) {
2018
2100
  if (parsed.data.release.draft) return [];
2019
2101
  const eventType = "release.published";
2020
2102
  const repo = parsed.data.repository.full_name;
2021
- const tag = parsed.data.release.tag_name;
2103
+ const tag = parsed.data.release.tag_name.trim();
2104
+ if (!tag) return [];
2022
2105
  const untrustedParts = [
2023
- tag ? `Tag: ${tag}` : void 0,
2106
+ `Tag: ${tag}`,
2024
2107
  parsed.data.release.name?.trim() ? `Name: ${parsed.data.release.name.trim()}` : void 0,
2025
2108
  parsed.data.release.body?.trim() || void 0
2026
2109
  ].filter((part) => part !== void 0);
2027
2110
  const untrustedText = untrustedParts.length > 0 ? untrustedParts.join("\n\n") : void 0;
2111
+ const data = releaseEventDataSchema.parse({ repo, tag });
2028
2112
  return releaseSourceTargets({ repo, tag }).map(
2029
2113
  ({ completeOnTerminalEvent, resource }) => ({
2030
2114
  eventKey: gitHubEventKey(deliveryId, eventType),
@@ -2033,6 +2117,7 @@ function normalizeReleaseEvent(deliveryId, body) {
2033
2117
  identifier: resource.identifier,
2034
2118
  ...completeOnTerminalEvent ? { terminal: true } : void 0,
2035
2119
  trustedSummary: `${resource.label} was published (release ${parsed.data.release.id}).`,
2120
+ data,
2036
2121
  ...untrustedText ? { untrustedText } : void 0
2037
2122
  })
2038
2123
  );
@@ -2081,9 +2166,10 @@ function normalizeGitHubEvents(args) {
2081
2166
  export {
2082
2167
  normalizePermissions,
2083
2168
  readGrantPermissions,
2169
+ gitHubRepoDataSchema,
2084
2170
  GITHUB_ISSUE_EVENTS,
2085
2171
  GITHUB_ISSUE_SUGGESTED_EVENTS,
2086
- GITHUB_ISSUE_COMMENT_MATCH_FIELDS,
2172
+ GITHUB_ISSUE_MATCH_FIELDS,
2087
2173
  GITHUB_ISSUE_IDENTIFIER,
2088
2174
  gitHubIssueSubscribable,
2089
2175
  GITHUB_DEPLOYMENT_EVENTS,
@@ -2099,6 +2185,7 @@ export {
2099
2185
  GITHUB_PULL_REQUEST_IDENTIFIER,
2100
2186
  gitHubPullRequestSubscribable,
2101
2187
  GITHUB_RELEASE_EVENTS,
2188
+ GITHUB_RELEASE_MATCH_FIELDS,
2102
2189
  GITHUB_RELEASE_SUGGESTED_EVENTS,
2103
2190
  GITHUB_RELEASE_SOURCE_IDENTIFIER,
2104
2191
  gitHubReleaseSourceSubscribable,
@@ -2129,6 +2216,7 @@ export {
2129
2216
  issueInstallationToken,
2130
2217
  issueGitHubCredential,
2131
2218
  createPermissionCache,
2219
+ definedValues,
2132
2220
  parseCheckSuitePublishTargets,
2133
2221
  needsCheckSuitePullRequestFacts,
2134
2222
  loadCheckSuiteFacts,