@sentry/junior-github 0.292.0 → 0.293.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,5 +1,5 @@
1
1
  // src/webhooks/events.ts
2
- import * as z4 from "zod";
2
+ import * as z6 from "zod";
3
3
 
4
4
  // src/events/deployment.ts
5
5
  import {
@@ -106,54 +106,86 @@ function gitHubDeploymentSourceSubscribable(input) {
106
106
 
107
107
  // src/events/issue.ts
108
108
  import {
109
- eventMatchFieldsSchema as eventMatchFieldsSchema4
109
+ eventMatchFieldsSchema as eventMatchFieldsSchema4,
110
+ mergeEventMatchFields
110
111
  } from "@sentry/junior-plugin-api";
111
112
 
112
113
  // src/events/comment.ts
113
114
  import {
114
115
  eventMatchFieldsSchema as eventMatchFieldsSchema3
115
116
  } from "@sentry/junior-plugin-api";
116
- function gitHubCommentMatchFields(events) {
117
+ function gitHubSenderMatchFields(events) {
117
118
  return eventMatchFieldsSchema3.parse({
118
- mentionsBot: {
119
- kind: "boolean",
120
- description: "true when the comment or review mentions this GitHub App",
121
- events
122
- },
123
119
  senderId: {
124
120
  kind: "number",
125
- description: "immutable numeric GitHub user id of who wrote the comment or review; prefer over logins",
121
+ description: "immutable numeric GitHub user id of who wrote the comment or review, or made the update; prefer over logins",
126
122
  events
127
123
  },
128
124
  senderLogin: {
129
125
  kind: "string",
130
- description: "GitHub login of who wrote the comment or review; logins can be renamed",
126
+ description: "GitHub login of who wrote the comment or review, or made the update; logins can be renamed",
131
127
  events
132
128
  }
133
129
  });
134
130
  }
131
+ function gitHubCommentMatchFields(events) {
132
+ return eventMatchFieldsSchema3.parse({
133
+ mentionsBot: {
134
+ kind: "boolean",
135
+ description: "true when the comment or review mentions this GitHub App",
136
+ events
137
+ },
138
+ ...gitHubSenderMatchFields(events)
139
+ });
140
+ }
135
141
 
136
142
  // src/events/issue.ts
137
143
  var GITHUB_ISSUE_EVENTS = [
138
144
  "issue.comment.created",
139
145
  "issue.opened",
140
146
  "issue.closed",
141
- "issue.reopened"
147
+ "issue.reopened",
148
+ "issue.updated"
142
149
  ];
143
150
  var GITHUB_ISSUE_SUGGESTED_EVENTS = [
144
151
  "issue.comment.created",
145
152
  "issue.closed",
146
- "issue.reopened"
153
+ "issue.reopened",
154
+ "issue.updated"
147
155
  ];
148
- var GITHUB_ISSUE_MATCH_FIELDS = eventMatchFieldsSchema4.parse({
149
- ...gitHubCommentMatchFields(["issue.comment.created"]),
150
- ...gitHubRepoMatchFields(GITHUB_ISSUE_EVENTS),
151
- issue: {
152
- kind: "number",
153
- description: "issue number, such as 12",
154
- events: GITHUB_ISSUE_EVENTS
155
- }
156
- });
156
+ var GITHUB_ISSUE_UPDATE_CHANGES = [
157
+ "edited",
158
+ "labeled",
159
+ "unlabeled",
160
+ "assigned",
161
+ "unassigned",
162
+ "milestoned",
163
+ "demilestoned"
164
+ ];
165
+ var GITHUB_ISSUE_MATCH_FIELDS = mergeEventMatchFields(
166
+ gitHubCommentMatchFields(["issue.comment.created"]),
167
+ gitHubSenderMatchFields(["issue.updated"]),
168
+ eventMatchFieldsSchema4.parse({
169
+ ...gitHubRepoMatchFields(GITHUB_ISSUE_EVENTS),
170
+ issue: {
171
+ kind: "number",
172
+ description: "issue number, such as 12",
173
+ events: GITHUB_ISSUE_EVENTS
174
+ },
175
+ change: {
176
+ kind: "string",
177
+ enum: [...GITHUB_ISSUE_UPDATE_CHANGES],
178
+ description: "what the issue update changed, such as labeled",
179
+ events: ["issue.updated"]
180
+ },
181
+ label: {
182
+ kind: "string",
183
+ case: "lower",
184
+ description: "lowercase name of the label that was added or removed, set only when change is labeled or unlabeled",
185
+ events: ["issue.updated"]
186
+ }
187
+ })
188
+ );
157
189
  var GITHUB_ISSUE_IDENTIFIER = {
158
190
  format: "owner/repo#number",
159
191
  pattern: String.raw`^[^\s/:#]+\/[^\s/:#]+#\d+$`
@@ -404,7 +436,10 @@ var GITHUB_REPOSITORY_EVENTS = [
404
436
  var GITHUB_REPOSITORY_SUGGESTED_EVENTS = [
405
437
  "issue.opened",
406
438
  "pull_request.opened",
407
- ...GITHUB_ISSUE_SUGGESTED_EVENTS,
439
+ // Label, assignee, and edit updates are too frequent across a repository.
440
+ ...GITHUB_ISSUE_SUGGESTED_EVENTS.filter(
441
+ (eventType) => eventType !== "issue.updated"
442
+ ),
408
443
  ...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS
409
444
  ];
410
445
  function gitHubRepositorySubscribable(input) {
@@ -419,7 +454,7 @@ function gitHubRepositorySubscribable(input) {
419
454
  }
420
455
 
421
456
  // src/webhooks/check-suite.ts
422
- import * as z3 from "zod";
457
+ import * as z4 from "zod";
423
458
 
424
459
  // src/credential-support.ts
425
460
  import { createPrivateKey, createSign } from "crypto";
@@ -1104,6 +1139,33 @@ function createPermissionCache() {
1104
1139
  }
1105
1140
 
1106
1141
  // src/webhooks/event-targets.ts
1142
+ import * as z3 from "zod";
1143
+ var gitHubSenderSchema = z3.object({
1144
+ id: z3.number(),
1145
+ login: z3.string().min(1)
1146
+ });
1147
+ function gitHubSenderData(sender) {
1148
+ return { senderId: sender?.id, senderLogin: sender?.login };
1149
+ }
1150
+ function gitHubDoneBy(login) {
1151
+ const handle = login?.trim();
1152
+ return handle ? { doneBy: { provider: "github", handle } } : void 0;
1153
+ }
1154
+ function nonBlank(value) {
1155
+ return value?.trim() || void 0;
1156
+ }
1157
+ function titleAndBodyText(item) {
1158
+ const parts = [
1159
+ item.title ? `Title: ${item.title}` : void 0,
1160
+ nonBlank(item.body)
1161
+ ].filter((part) => part !== void 0);
1162
+ return parts.length > 0 ? parts.join("\n\n") : void 0;
1163
+ }
1164
+ function providerTime(value) {
1165
+ if (!value) return void 0;
1166
+ const parsed = Date.parse(value);
1167
+ return Number.isFinite(parsed) ? parsed : void 0;
1168
+ }
1107
1169
  function definedValues(data) {
1108
1170
  return Object.fromEntries(
1109
1171
  Object.entries(data).filter(([, value]) => value !== void 0)
@@ -1130,48 +1192,48 @@ var CHECK_SUITE_PULL_REQUEST_MATCH_KEYS = /* @__PURE__ */ new Set([
1130
1192
  "openerRole",
1131
1193
  "openerUsername"
1132
1194
  ]);
1133
- var checkRunRepoRefSchema = z3.object({
1134
- id: z3.number(),
1135
- name: z3.string().min(1),
1136
- url: z3.string().min(1)
1195
+ var checkRunRepoRefSchema = z4.object({
1196
+ id: z4.number(),
1197
+ name: z4.string().min(1),
1198
+ url: z4.string().min(1)
1137
1199
  }).passthrough();
1138
- var checkRunPullRequestSideSchema = z3.object({
1139
- ref: z3.string().optional(),
1200
+ var checkRunPullRequestSideSchema = z4.object({
1201
+ ref: z4.string().optional(),
1140
1202
  repo: checkRunRepoRefSchema,
1141
- sha: z3.string().optional()
1203
+ sha: z4.string().optional()
1142
1204
  }).passthrough();
1143
- var checkRunPullRequestSchema = z3.object({
1205
+ var checkRunPullRequestSchema = z4.object({
1144
1206
  base: checkRunPullRequestSideSchema,
1145
1207
  head: checkRunPullRequestSideSchema.optional(),
1146
- id: z3.number().optional(),
1147
- number: z3.number(),
1148
- url: z3.string().optional()
1208
+ id: z4.number().optional(),
1209
+ number: z4.number(),
1210
+ url: z4.string().optional()
1149
1211
  }).passthrough();
1150
- var repositorySchema = z3.object({
1151
- full_name: z3.string().min(1),
1152
- id: z3.number(),
1153
- name: z3.string().min(1),
1154
- owner: z3.object({ login: z3.string().min(1) }).passthrough()
1212
+ var repositorySchema = z4.object({
1213
+ full_name: z4.string().min(1),
1214
+ id: z4.number(),
1215
+ name: z4.string().min(1),
1216
+ owner: z4.object({ login: z4.string().min(1) }).passthrough()
1155
1217
  }).passthrough();
1156
- var checkSuiteWebhookSchema = z3.object({
1157
- action: z3.string(),
1158
- check_suite: z3.object({
1159
- app: z3.object({
1160
- name: z3.string().optional().nullable(),
1161
- slug: z3.string().optional().nullable()
1218
+ var checkSuiteWebhookSchema = z4.object({
1219
+ action: z4.string(),
1220
+ check_suite: z4.object({
1221
+ app: z4.object({
1222
+ name: z4.string().optional().nullable(),
1223
+ slug: z4.string().optional().nullable()
1162
1224
  }).optional().nullable(),
1163
- conclusion: z3.string().optional().nullable(),
1225
+ conclusion: z4.string().optional().nullable(),
1164
1226
  /** Branch name for the suite head commit when GitHub sends it. */
1165
- head_branch: z3.string().optional().nullable(),
1166
- head_sha: z3.string().optional(),
1167
- id: z3.number().optional(),
1168
- latest_check_runs_count: z3.number().optional().nullable(),
1169
- pull_requests: z3.array(checkRunPullRequestSchema)
1227
+ head_branch: z4.string().optional().nullable(),
1228
+ head_sha: z4.string().optional(),
1229
+ id: z4.number().optional(),
1230
+ latest_check_runs_count: z4.number().optional().nullable(),
1231
+ pull_requests: z4.array(checkRunPullRequestSchema)
1170
1232
  }),
1171
1233
  repository: repositorySchema
1172
1234
  });
1173
- var checkRunsListResponseSchema = z3.object({
1174
- check_runs: z3.array(z3.unknown()).optional()
1235
+ var checkRunsListResponseSchema = z4.object({
1236
+ check_runs: z4.array(z4.unknown()).optional()
1175
1237
  }).passthrough();
1176
1238
  function isCheckSuiteRepositoryPullRequest(pullRequest, repositoryId) {
1177
1239
  return pullRequest.base.repo.id === repositoryId;
@@ -1205,26 +1267,26 @@ function checkSuiteHeadBranch(value) {
1205
1267
  const branch = value?.trim();
1206
1268
  return branch ? branch : void 0;
1207
1269
  }
1208
- var checkSuiteEventDataSchema = z3.object({
1270
+ var checkSuiteEventDataSchema = z4.object({
1209
1271
  repo: gitHubRepoDataSchema,
1210
- pullRequest: z3.number().optional(),
1272
+ pullRequest: z4.number().optional(),
1211
1273
  commitSha: gitHubCommitShaDataSchema.optional(),
1212
- suiteConclusion: z3.string().min(1),
1213
- isDraft: z3.boolean().optional(),
1214
- openerUsername: z3.string().min(1).optional(),
1215
- openerEmail: z3.string().min(1).optional(),
1216
- headBranch: z3.string().min(1).optional(),
1217
- checkSuiteId: z3.number().optional(),
1218
- checkSuiteUrl: z3.string().min(1).optional(),
1219
- appName: z3.string().min(1).optional(),
1220
- latestCheckRunsCount: z3.number().optional(),
1274
+ suiteConclusion: z4.string().min(1),
1275
+ isDraft: z4.boolean().optional(),
1276
+ openerUsername: z4.string().min(1).optional(),
1277
+ openerEmail: z4.string().min(1).optional(),
1278
+ headBranch: z4.string().min(1).optional(),
1279
+ checkSuiteId: z4.number().optional(),
1280
+ checkSuiteUrl: z4.string().min(1).optional(),
1281
+ appName: z4.string().min(1).optional(),
1282
+ latestCheckRunsCount: z4.number().optional(),
1221
1283
  // Only system-set handles. Check names come from workflow YAML, so they
1222
1284
  // go in the untrusted text.
1223
- failingChecks: z3.array(
1224
- z3.object({
1225
- conclusion: z3.string(),
1226
- htmlUrl: z3.string().optional(),
1227
- checkRunId: z3.number()
1285
+ failingChecks: z4.array(
1286
+ z4.object({
1287
+ conclusion: z4.string(),
1288
+ htmlUrl: z4.string().optional(),
1289
+ checkRunId: z4.number()
1228
1290
  }).strict()
1229
1291
  ).optional()
1230
1292
  }).strict();
@@ -1306,18 +1368,18 @@ function selectFailingChecks(checkRuns, options) {
1306
1368
  const failing = [];
1307
1369
  for (const run of checkRuns) {
1308
1370
  if (!run || typeof run !== "object" || Array.isArray(run)) continue;
1309
- const record = run;
1371
+ const record2 = run;
1310
1372
  if (options?.checkSuiteId !== void 0) {
1311
- const suite = record.check_suite;
1373
+ const suite = record2.check_suite;
1312
1374
  const suiteId = suite && typeof suite === "object" && !Array.isArray(suite) && typeof suite.id === "number" ? suite.id : void 0;
1313
1375
  if (suiteId !== void 0 && suiteId !== options.checkSuiteId) continue;
1314
1376
  }
1315
- const conclusion = typeof record.conclusion === "string" ? record.conclusion : void 0;
1316
- const name = typeof record.name === "string" ? record.name.trim() : "";
1317
- const checkRunId = typeof record.id === "number" && Number.isSafeInteger(record.id) ? record.id : void 0;
1377
+ const conclusion = typeof record2.conclusion === "string" ? record2.conclusion : void 0;
1378
+ const name = typeof record2.name === "string" ? record2.name.trim() : "";
1379
+ const checkRunId = typeof record2.id === "number" && Number.isSafeInteger(record2.id) ? record2.id : void 0;
1318
1380
  if (!conclusion || !FAILING_CHECK_CONCLUSIONS.has(conclusion)) continue;
1319
1381
  if (!name || checkRunId === void 0) continue;
1320
- const htmlUrl = typeof record.html_url === "string" && record.html_url.length > 0 ? record.html_url : void 0;
1382
+ const htmlUrl = typeof record2.html_url === "string" && record2.html_url.length > 0 ? record2.html_url : void 0;
1321
1383
  failing.push({
1322
1384
  checkRunId,
1323
1385
  conclusion,
@@ -1527,20 +1589,20 @@ async function loadCheckSuiteFacts(args) {
1527
1589
  repositories: [target.repoName]
1528
1590
  });
1529
1591
  const loaded = await Promise.all(
1530
- target.pullRequestNumbers.map(async (number3) => {
1592
+ target.pullRequestNumbers.map(async (number5) => {
1531
1593
  try {
1532
1594
  const response = await githubRequest(
1533
1595
  "https://api.github.com",
1534
- `/repos/${encodeURIComponent(target.owner)}/${encodeURIComponent(target.repoName)}/pulls/${number3}`,
1596
+ `/repos/${encodeURIComponent(target.owner)}/${encodeURIComponent(target.repoName)}/pulls/${number5}`,
1535
1597
  { token: token.token }
1536
1598
  );
1537
1599
  const loadedFacts = pullRequestFactsFromResponse(response);
1538
- return loadedFacts ? [number3, loadedFacts] : void 0;
1600
+ return loadedFacts ? [number5, loadedFacts] : void 0;
1539
1601
  } catch (error) {
1540
1602
  if (!isGitHubNotFoundError(error)) {
1541
1603
  args.log?.error("GitHub pull request data load failed", {
1542
1604
  errorType: error instanceof Error ? error.name : "UnknownError",
1543
- pullRequest: number3,
1605
+ pullRequest: number5,
1544
1606
  repository: `${target.owner}/${target.repoName}`
1545
1607
  });
1546
1608
  }
@@ -1567,6 +1629,9 @@ async function loadCheckSuiteFacts(args) {
1567
1629
  return facts.failingChecks || facts.pullRequestFactsByNumber ? facts : void 0;
1568
1630
  }
1569
1631
 
1632
+ // src/webhooks/issue-update.ts
1633
+ import * as z5 from "zod";
1634
+
1570
1635
  // src/webhooks/ownership.ts
1571
1636
  import { lexer } from "marked";
1572
1637
  var GITHUB_BOT_NOREPLY_EMAIL = /^(?<userId>[1-9]\d*)\+(?<login>[^@]+\[bot\])@users\.noreply\.github\.com$/i;
@@ -1617,41 +1682,117 @@ function mentionsBotLogin(text, botEmail) {
1617
1682
  );
1618
1683
  }
1619
1684
 
1620
- // src/webhooks/events.ts
1621
- function gitHubDoneBy(login) {
1622
- const handle = login?.trim();
1623
- return handle ? { doneBy: { provider: "github", handle } } : void 0;
1685
+ // src/webhooks/issue-update.ts
1686
+ var issueUpdateWebhookSchema = z5.object({
1687
+ action: z5.enum(GITHUB_ISSUE_UPDATE_CHANGES),
1688
+ assignee: z5.object({ login: z5.string().nullish() }).nullish(),
1689
+ changes: z5.record(z5.string(), z5.unknown()).optional(),
1690
+ issue: z5.object({
1691
+ body: z5.string().optional().nullable(),
1692
+ number: z5.number(),
1693
+ title: z5.string().optional(),
1694
+ updated_at: z5.string().optional()
1695
+ }),
1696
+ label: z5.object({ name: z5.string() }).nullish(),
1697
+ milestone: z5.object({ title: z5.string() }).nullish(),
1698
+ repository: z5.object({ full_name: z5.string().min(1) }),
1699
+ sender: gitHubSenderSchema.optional()
1700
+ });
1701
+ function describeIssueUpdate(delivery) {
1702
+ const assignee = nonBlank(delivery.assignee?.login);
1703
+ switch (delivery.action) {
1704
+ case "edited": {
1705
+ const fields = ["title", "body"].filter(
1706
+ (field) => field in (delivery.changes ?? {})
1707
+ );
1708
+ return {
1709
+ change: fields.length ? `edited (${fields.join(", ")})` : "edited"
1710
+ };
1711
+ }
1712
+ case "labeled":
1713
+ case "unlabeled":
1714
+ return {
1715
+ change: delivery.action,
1716
+ untrustedText: delivery.label ? `Label: ${delivery.label.name}` : void 0
1717
+ };
1718
+ case "assigned":
1719
+ return { change: assignee ? `assigned to ${assignee}` : "assigned" };
1720
+ case "unassigned":
1721
+ return {
1722
+ change: assignee ? `unassigned from ${assignee}` : "unassigned"
1723
+ };
1724
+ case "milestoned":
1725
+ case "demilestoned":
1726
+ return {
1727
+ change: delivery.action,
1728
+ untrustedText: delivery.milestone ? `Milestone: ${delivery.milestone.title}` : void 0
1729
+ };
1730
+ }
1624
1731
  }
1625
- function nonBlank(value) {
1626
- return value?.trim() || void 0;
1732
+ function normalizeIssueUpdateEvents(deliveryId, body, botEmail) {
1733
+ const parsed = issueUpdateWebhookSchema.safeParse(body);
1734
+ if (!parsed.success) return void 0;
1735
+ const update = describeIssueUpdate(parsed.data);
1736
+ const { action, label, sender } = parsed.data;
1737
+ const doneBy = sender?.login;
1738
+ if (isBotLogin(doneBy, botEmail)) return [];
1739
+ const input = {
1740
+ number: parsed.data.issue.number,
1741
+ repo: parsed.data.repository.full_name
1742
+ };
1743
+ const issue = gitHubIssueResource(input);
1744
+ const untrustedText = [
1745
+ update.untrustedText,
1746
+ titleAndBodyText(parsed.data.issue)
1747
+ ].filter((part) => part !== void 0).join("\n\n");
1748
+ return [issue, gitHubRepositoryResource(input)].map((resource) => ({
1749
+ eventKey: gitHubEventKey(deliveryId, "issue.updated"),
1750
+ eventType: "issue.updated",
1751
+ occurredAtMs: providerTime(parsed.data.issue.updated_at) ?? Date.now(),
1752
+ identifier: resource.identifier,
1753
+ trustedSummary: `${issue.label} was ${update.change}${doneBy ? ` by ${doneBy}` : ""}.`,
1754
+ ...gitHubDoneBy(doneBy),
1755
+ // `change` and `label` let an automation select one label change in code,
1756
+ // so the model does not decide from untrusted text.
1757
+ data: definedValues({
1758
+ repo: gitHubRepoDataSchema.parse(input.repo),
1759
+ issue: input.number,
1760
+ change: action,
1761
+ label: label?.name.toLowerCase(),
1762
+ ...gitHubSenderData(sender)
1763
+ }),
1764
+ ...untrustedText ? { untrustedText } : void 0
1765
+ }));
1627
1766
  }
1628
- var repositorySchema2 = z4.object({ full_name: z4.string().min(1) }).passthrough();
1629
- var deploymentSchema = z4.object({
1630
- created_at: z4.string().optional(),
1631
- environment: z4.string().trim().min(1),
1632
- id: z4.number(),
1633
- sha: z4.string().regex(/^[0-9a-f]{40}$/i)
1767
+
1768
+ // src/webhooks/events.ts
1769
+ var repositorySchema2 = z6.object({ full_name: z6.string().min(1) }).passthrough();
1770
+ var deploymentSchema = z6.object({
1771
+ created_at: z6.string().optional(),
1772
+ environment: z6.string().trim().min(1),
1773
+ id: z6.number(),
1774
+ sha: z6.string().regex(/^[0-9a-f]{40}$/i)
1634
1775
  }).passthrough();
1635
1776
  var deploymentWorkflowSchema = {
1636
- workflow: z4.object({ id: z4.number(), path: z4.string().min(1) }).passthrough().nullish(),
1637
- workflow_run: z4.object({ id: z4.number() }).passthrough().nullish()
1777
+ workflow: z6.object({ id: z6.number(), path: z6.string().min(1) }).passthrough().nullish(),
1778
+ workflow_run: z6.object({ id: z6.number() }).passthrough().nullish()
1638
1779
  };
1639
- var deploymentWebhookSchema = z4.object({
1640
- action: z4.string(),
1780
+ var deploymentWebhookSchema = z6.object({
1781
+ action: z6.string(),
1641
1782
  deployment: deploymentSchema,
1642
1783
  repository: repositorySchema2,
1643
1784
  ...deploymentWorkflowSchema
1644
1785
  }).passthrough();
1645
- var canonicalDeploymentEventSchema = z4.object({
1646
- action: z4.string(),
1647
- commitSha: z4.string().regex(/^[0-9a-f]{40}$/i),
1648
- createdAt: z4.string().optional(),
1649
- deploymentId: z4.number(),
1650
- environment: z4.string().min(1),
1651
- repo: z4.string().min(1),
1652
- workflowId: z4.number().optional(),
1653
- workflowPath: z4.string().min(1).optional(),
1654
- workflowRunId: z4.number().optional()
1786
+ var canonicalDeploymentEventSchema = z6.object({
1787
+ action: z6.string(),
1788
+ commitSha: z6.string().regex(/^[0-9a-f]{40}$/i),
1789
+ createdAt: z6.string().optional(),
1790
+ deploymentId: z6.number(),
1791
+ environment: z6.string().min(1),
1792
+ repo: z6.string().min(1),
1793
+ workflowId: z6.number().optional(),
1794
+ workflowPath: z6.string().min(1).optional(),
1795
+ workflowRunId: z6.number().optional()
1655
1796
  }).strict();
1656
1797
  function canonicalDeploymentFields(data) {
1657
1798
  return {
@@ -1688,16 +1829,16 @@ function normalizeDeploymentEvent(deliveryId, body) {
1688
1829
  }));
1689
1830
  }
1690
1831
  var deploymentStatusWebhookSchema = deploymentWebhookSchema.extend({
1691
- deployment_status: z4.object({
1692
- created_at: z4.string().optional(),
1693
- description: z4.string().optional().nullable(),
1694
- state: z4.string()
1832
+ deployment_status: z6.object({
1833
+ created_at: z6.string().optional(),
1834
+ description: z6.string().optional().nullable(),
1835
+ state: z6.string()
1695
1836
  }).passthrough()
1696
1837
  });
1697
1838
  var canonicalDeploymentStatusEventSchema = canonicalDeploymentEventSchema.extend({
1698
- description: z4.string().optional().nullable(),
1699
- state: z4.string(),
1700
- statusCreatedAt: z4.string().optional()
1839
+ description: z6.string().optional().nullable(),
1840
+ state: z6.string(),
1841
+ statusCreatedAt: z6.string().optional()
1701
1842
  }).strict();
1702
1843
  function parseDeploymentStatusEvent(body) {
1703
1844
  const parsed = deploymentStatusWebhookSchema.safeParse(body);
@@ -1746,15 +1887,15 @@ function normalizeDeploymentStatusEvent(deliveryId, body) {
1746
1887
  })
1747
1888
  );
1748
1889
  }
1749
- var deploymentEventDataSchema = z4.object({
1890
+ var deploymentEventDataSchema = z6.object({
1750
1891
  repo: gitHubRepoDataSchema,
1751
1892
  commitSha: gitHubCommitShaDataSchema,
1752
- deploymentId: z4.number(),
1893
+ deploymentId: z6.number(),
1753
1894
  // Trimmed and lowercase, the same as in the identifier.
1754
- environment: z4.string().trim().min(1).toLowerCase(),
1755
- workflowId: z4.number().optional(),
1756
- workflowPath: z4.string().min(1).optional(),
1757
- workflowRunId: z4.number().optional()
1895
+ environment: z6.string().trim().min(1).toLowerCase(),
1896
+ workflowId: z6.number().optional(),
1897
+ workflowPath: z6.string().min(1).optional(),
1898
+ workflowRunId: z6.number().optional()
1758
1899
  }).strict();
1759
1900
  function deploymentEventData(input) {
1760
1901
  return deploymentEventDataSchema.parse(
@@ -1788,43 +1929,41 @@ function deploymentTargets(input) {
1788
1929
  }
1789
1930
  ];
1790
1931
  }
1791
- var gitHubUserSchema = z4.object({
1792
- email: z4.string().nullish(),
1793
- login: z4.string().nullish()
1932
+ var gitHubUserSchema = z6.object({
1933
+ email: z6.string().nullish(),
1934
+ login: z6.string().nullish()
1794
1935
  });
1795
- var senderSchema = z4.object({ id: z4.number(), login: z4.string().min(1) });
1796
- var commentSchema = z4.object({
1797
- body: z4.string(),
1798
- id: z4.number(),
1799
- user: z4.object({ login: z4.string().optional() }).optional()
1936
+ var commentSchema = z6.object({
1937
+ body: z6.string(),
1938
+ id: z6.number(),
1939
+ user: z6.object({ login: z6.string().optional() }).optional()
1800
1940
  });
1801
- var commentAuthorDataSchema = z4.object({
1802
- mentionsBot: z4.boolean().optional(),
1803
- senderId: z4.number().optional(),
1804
- senderLogin: z4.string().min(1).optional()
1941
+ var commentAuthorDataSchema = z6.object({
1942
+ mentionsBot: z6.boolean().optional(),
1943
+ senderId: z6.number().optional(),
1944
+ senderLogin: z6.string().min(1).optional()
1805
1945
  });
1806
1946
  function commentAuthorData(input) {
1807
1947
  return {
1808
1948
  mentionsBot: input.botEmail ? mentionsBotLogin(input.text ?? "", input.botEmail) : void 0,
1809
- senderId: input.sender?.id,
1810
- senderLogin: input.sender?.login
1949
+ ...gitHubSenderData(input.sender)
1811
1950
  };
1812
1951
  }
1813
- var pullRequestSchema = z4.object({
1814
- draft: z4.boolean().optional(),
1815
- head: z4.object({ ref: z4.string().nullish() }).nullish(),
1816
- number: z4.number(),
1952
+ var pullRequestSchema = z6.object({
1953
+ draft: z6.boolean().optional(),
1954
+ head: z6.object({ ref: z6.string().nullish() }).nullish(),
1955
+ number: z6.number(),
1817
1956
  user: gitHubUserSchema.nullish()
1818
1957
  });
1819
1958
  var pullRequestEventDataSchema = commentAuthorDataSchema.extend({
1820
1959
  repo: gitHubRepoDataSchema,
1821
- pullRequest: z4.number(),
1822
- headBranch: z4.string().min(1).optional(),
1823
- isDraft: z4.boolean().optional(),
1824
- openerEmail: z4.string().min(1).optional(),
1825
- openerUsername: z4.string().min(1).optional(),
1826
- commentId: z4.number().optional(),
1827
- commentKind: z4.enum(["conversation", "review"]).optional()
1960
+ pullRequest: z6.number(),
1961
+ headBranch: z6.string().min(1).optional(),
1962
+ isDraft: z6.boolean().optional(),
1963
+ openerEmail: z6.string().min(1).optional(),
1964
+ openerUsername: z6.string().min(1).optional(),
1965
+ commentId: z6.number().optional(),
1966
+ commentKind: z6.enum(["conversation", "review"]).optional()
1828
1967
  }).strict();
1829
1968
  function pullRequestEventData(input) {
1830
1969
  const { pullRequest } = input;
@@ -1842,23 +1981,23 @@ function pullRequestEventData(input) {
1842
1981
  }
1843
1982
  var issueEventDataSchema = commentAuthorDataSchema.extend({
1844
1983
  repo: gitHubRepoDataSchema,
1845
- issue: z4.number(),
1846
- commentId: z4.number().optional()
1984
+ issue: z6.number(),
1985
+ commentId: z6.number().optional()
1847
1986
  }).strict();
1848
1987
  function issueEventData(input) {
1849
1988
  return issueEventDataSchema.parse(definedValues(input));
1850
1989
  }
1851
- var issueCommentWebhookSchema = z4.object({
1852
- action: z4.string(),
1990
+ var issueCommentWebhookSchema = z6.object({
1991
+ action: z6.string(),
1853
1992
  comment: commentSchema,
1854
- issue: z4.object({
1855
- draft: z4.boolean().optional(),
1856
- number: z4.number(),
1857
- pull_request: z4.object({ url: z4.string().min(1) }).optional(),
1993
+ issue: z6.object({
1994
+ draft: z6.boolean().optional(),
1995
+ number: z6.number(),
1996
+ pull_request: z6.object({ url: z6.string().min(1) }).optional(),
1858
1997
  user: gitHubUserSchema.nullish()
1859
1998
  }),
1860
1999
  repository: repositorySchema2,
1861
- sender: senderSchema.optional()
2000
+ sender: gitHubSenderSchema.optional()
1862
2001
  });
1863
2002
  function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
1864
2003
  const parsed = issueCommentWebhookSchema.safeParse(body);
@@ -1915,26 +2054,21 @@ function normalizeIssueCommentEvents(deliveryId, body, botEmail) {
1915
2054
  untrustedText: comment.body
1916
2055
  }));
1917
2056
  }
1918
- var issueWebhookSchema = z4.object({
1919
- action: z4.string(),
1920
- issue: z4.object({
1921
- body: z4.string().optional().nullable(),
1922
- closed_at: z4.string().optional().nullable(),
1923
- created_at: z4.string().optional(),
1924
- number: z4.number(),
1925
- title: z4.string().optional(),
1926
- updated_at: z4.string().optional()
2057
+ var issueWebhookSchema = z6.object({
2058
+ action: z6.string(),
2059
+ issue: z6.object({
2060
+ body: z6.string().optional().nullable(),
2061
+ closed_at: z6.string().optional().nullable(),
2062
+ created_at: z6.string().optional(),
2063
+ number: z6.number(),
2064
+ title: z6.string().optional(),
2065
+ updated_at: z6.string().optional()
1927
2066
  }),
1928
2067
  repository: repositorySchema2
1929
2068
  });
1930
- function titleAndBodyText(item) {
1931
- const parts = [
1932
- item.title ? `Title: ${item.title}` : void 0,
1933
- nonBlank(item.body)
1934
- ].filter((part) => part !== void 0);
1935
- return parts.length > 0 ? parts.join("\n\n") : void 0;
1936
- }
1937
- function normalizeIssueEvents(deliveryId, body) {
2069
+ function normalizeIssueEvents(deliveryId, body, botEmail) {
2070
+ const updates = normalizeIssueUpdateEvents(deliveryId, body, botEmail);
2071
+ if (updates) return updates;
1938
2072
  const parsed = issueWebhookSchema.safeParse(body);
1939
2073
  if (!parsed.success) return [];
1940
2074
  const state = parsed.data.action === "opened" ? "opened" : parsed.data.action === "closed" ? "closed" : parsed.data.action === "reopened" ? "reopened" : void 0;
@@ -1960,12 +2094,12 @@ function normalizeIssueEvents(deliveryId, body) {
1960
2094
  ...untrustedText ? { untrustedText } : void 0
1961
2095
  }));
1962
2096
  }
1963
- var pullRequestReviewCommentWebhookSchema = z4.object({
1964
- action: z4.string(),
2097
+ var pullRequestReviewCommentWebhookSchema = z6.object({
2098
+ action: z6.string(),
1965
2099
  comment: commentSchema,
1966
2100
  pull_request: pullRequestSchema,
1967
2101
  repository: repositorySchema2,
1968
- sender: senderSchema.optional()
2102
+ sender: gitHubSenderSchema.optional()
1969
2103
  });
1970
2104
  function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
1971
2105
  const parsed = pullRequestReviewCommentWebhookSchema.safeParse(body);
@@ -2001,16 +2135,16 @@ function normalizePullRequestReviewCommentEvent(deliveryId, body, botEmail) {
2001
2135
  repo
2002
2136
  );
2003
2137
  }
2004
- var pullRequestReviewWebhookSchema = z4.object({
2005
- action: z4.string(),
2138
+ var pullRequestReviewWebhookSchema = z6.object({
2139
+ action: z6.string(),
2006
2140
  pull_request: pullRequestSchema,
2007
2141
  repository: repositorySchema2,
2008
- review: z4.object({
2009
- body: z4.string().optional().nullable(),
2010
- state: z4.string(),
2011
- user: z4.object({ login: z4.string().optional() }).optional()
2142
+ review: z6.object({
2143
+ body: z6.string().optional().nullable(),
2144
+ state: z6.string(),
2145
+ user: z6.object({ login: z6.string().optional() }).optional()
2012
2146
  }),
2013
- sender: senderSchema.optional()
2147
+ sender: gitHubSenderSchema.optional()
2014
2148
  });
2015
2149
  function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
2016
2150
  const parsed = pullRequestReviewWebhookSchema.safeParse(body);
@@ -2056,24 +2190,19 @@ function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
2056
2190
  )
2057
2191
  ];
2058
2192
  }
2059
- var pullRequestWebhookSchema = z4.object({
2060
- action: z4.string(),
2193
+ var pullRequestWebhookSchema = z6.object({
2194
+ action: z6.string(),
2061
2195
  pull_request: pullRequestSchema.extend({
2062
- body: z4.string().optional().nullable(),
2063
- closed_at: z4.string().optional().nullable(),
2064
- created_at: z4.string().optional(),
2065
- merged: z4.boolean().optional(),
2066
- merged_at: z4.string().optional().nullable(),
2067
- title: z4.string().optional(),
2068
- updated_at: z4.string().optional()
2196
+ body: z6.string().optional().nullable(),
2197
+ closed_at: z6.string().optional().nullable(),
2198
+ created_at: z6.string().optional(),
2199
+ merged: z6.boolean().optional(),
2200
+ merged_at: z6.string().optional().nullable(),
2201
+ title: z6.string().optional(),
2202
+ updated_at: z6.string().optional()
2069
2203
  }),
2070
2204
  repository: repositorySchema2
2071
2205
  });
2072
- function providerTime(value) {
2073
- if (!value) return void 0;
2074
- const parsed = Date.parse(value);
2075
- return Number.isFinite(parsed) ? parsed : void 0;
2076
- }
2077
2206
  function normalizePullRequestEvent(deliveryId, body) {
2078
2207
  const parsed = pullRequestWebhookSchema.safeParse(body);
2079
2208
  if (!parsed.success) return [];
@@ -2143,20 +2272,20 @@ function normalizePullRequestEvent(deliveryId, body) {
2143
2272
  trustedSummary: eventType === "pull_request.merged" ? `${resource.label} was merged.` : `${resource.label} was closed without being merged.`
2144
2273
  });
2145
2274
  }
2146
- var releaseWebhookSchema = z4.object({
2147
- action: z4.string(),
2148
- release: z4.object({
2149
- body: z4.string().optional().nullable(),
2150
- draft: z4.boolean().optional(),
2151
- id: z4.number(),
2152
- name: z4.string().optional().nullable(),
2153
- prerelease: z4.boolean().optional(),
2154
- published_at: z4.string().optional().nullable(),
2155
- tag_name: z4.string().min(1)
2275
+ var releaseWebhookSchema = z6.object({
2276
+ action: z6.string(),
2277
+ release: z6.object({
2278
+ body: z6.string().optional().nullable(),
2279
+ draft: z6.boolean().optional(),
2280
+ id: z6.number(),
2281
+ name: z6.string().optional().nullable(),
2282
+ prerelease: z6.boolean().optional(),
2283
+ published_at: z6.string().optional().nullable(),
2284
+ tag_name: z6.string().min(1)
2156
2285
  }).passthrough(),
2157
2286
  repository: repositorySchema2
2158
2287
  }).passthrough();
2159
- var releaseEventDataSchema = z4.object({
2288
+ var releaseEventDataSchema = z6.object({
2160
2289
  repo: gitHubRepoDataSchema,
2161
2290
  tag: gitHubReleaseTagDataSchema
2162
2291
  }).strict();
@@ -2209,7 +2338,7 @@ function normalizeGitHubEvents(args) {
2209
2338
  case "pull_request":
2210
2339
  return normalizePullRequestEvent(args.deliveryId, args.body);
2211
2340
  case "issues":
2212
- return normalizeIssueEvents(args.deliveryId, args.body);
2341
+ return normalizeIssueEvents(args.deliveryId, args.body, args.botEmail);
2213
2342
  case "pull_request_review":
2214
2343
  return normalizePullRequestReviewEvent(
2215
2344
  args.deliveryId,