@sentry/junior-github 0.314.0 → 0.315.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.
Files changed (70) hide show
  1. package/dist/{events-D51HE9X3.js → events-D3Qnj4yY.js} +56 -18
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +3275 -2113
  4. package/dist/testing.js +1 -1
  5. package/migrations/20260722180343_pull_request_outcomes/snapshot.json +315 -0
  6. package/migrations/20260722224832_issue_outcomes/snapshot.json +301 -0
  7. package/migrations/20260722230324_pull_request_commit_composition/snapshot.json +42 -0
  8. package/migrations/20260722231413_pull_request_conversations/snapshot.json +42 -0
  9. package/migrations/20260723023722_marvelous_toad_men/snapshot.json +42 -0
  10. package/migrations/20260724235000_github_cost_associations/snapshot.json +73 -0
  11. package/migrations/20260725024522_fat_korvac/snapshot.json +158 -0
  12. package/migrations/20260811221145_shallow_millenium_guard/snapshot.json +54 -0
  13. package/migrations/20260824190830_native_code_backfill/snapshot.json +9 -0
  14. package/migrations/20261028220913_nostalgic_thing/snapshot.json +128 -0
  15. package/migrations/20261101195735_sleepy_slayback/snapshot.json +169 -0
  16. package/migrations/20261112142844_pull_request_draft/snapshot.json +42 -0
  17. package/migrations/20261113213858_pull_request_next_action/snapshot.json +61 -0
  18. package/migrations/20261119095049_conflict_fixes_resumed_at/snapshot.json +42 -0
  19. package/migrations/20261119230607_conflict_fixes/snapshot.json +42 -0
  20. package/migrations/20261120232426_conflict_fix_asked_at/snapshot.json +42 -0
  21. package/migrations/20261121002146_pull_request_finished_at/snapshot.json +42 -0
  22. package/migrations/20261121002159_pull_request_lifecycle_copies/snapshot.json +118 -0
  23. package/migrations/20261123212042_drop_pull_request_issues/snapshot.json +51 -0
  24. package/migrations/20261123220932_drop_github_issues/snapshot.json +83 -0
  25. package/migrations/20261123224011_pull_request_lifecycle_backfill/migration.sql +80 -0
  26. package/migrations/20261123224011_pull_request_lifecycle_backfill/snapshot.json +9 -0
  27. package/migrations/20261123224012_pull_request_lifecycle_in_code_index/migration.sql +10 -0
  28. package/migrations/20261123224012_pull_request_lifecycle_in_code_index/snapshot.json +219 -0
  29. package/package.json +4 -4
  30. package/migrations/meta/0000_snapshot.json +0 -148
  31. package/migrations/meta/0001_snapshot.json +0 -256
  32. package/migrations/meta/0002_snapshot.json +0 -262
  33. package/migrations/meta/0003_snapshot.json +0 -269
  34. package/migrations/meta/0004_snapshot.json +0 -275
  35. package/migrations/meta/0005_snapshot.json +0 -289
  36. package/migrations/meta/0006_snapshot.json +0 -336
  37. package/migrations/meta/0007_snapshot.json +0 -352
  38. package/migrations/meta/0008_snapshot.json +0 -348
  39. package/migrations/meta/0009_snapshot.json +0 -404
  40. package/migrations/meta/0010_snapshot.json +0 -427
  41. package/migrations/meta/0011_snapshot.json +0 -434
  42. package/migrations/meta/0012_snapshot.json +0 -434
  43. package/migrations/meta/0013_snapshot.json +0 -448
  44. package/migrations/meta/0014_snapshot.json +0 -455
  45. package/migrations/meta/0015_snapshot.json +0 -461
  46. package/migrations/meta/0016_snapshot.json +0 -467
  47. package/migrations/meta/0017_snapshot.json +0 -418
  48. package/migrations/meta/0018_snapshot.json +0 -364
  49. package/migrations/meta/0019_snapshot.json +0 -243
  50. package/migrations/meta/_journal.json +0 -146
  51. /package/migrations/{0000_pull_request_outcomes.sql → 20260722180343_pull_request_outcomes/migration.sql} +0 -0
  52. /package/migrations/{0001_issue_outcomes.sql → 20260722224832_issue_outcomes/migration.sql} +0 -0
  53. /package/migrations/{0002_pull_request_commit_composition.sql → 20260722230324_pull_request_commit_composition/migration.sql} +0 -0
  54. /package/migrations/{0003_pull_request_conversations.sql → 20260722231413_pull_request_conversations/migration.sql} +0 -0
  55. /package/migrations/{0004_marvelous_toad_men.sql → 20260723023722_marvelous_toad_men/migration.sql} +0 -0
  56. /package/migrations/{0005_github_cost_associations.sql → 20260724235000_github_cost_associations/migration.sql} +0 -0
  57. /package/migrations/{0006_fat_korvac.sql → 20260725024522_fat_korvac/migration.sql} +0 -0
  58. /package/migrations/{0007_shallow_millenium_guard.sql → 20260811221145_shallow_millenium_guard/migration.sql} +0 -0
  59. /package/migrations/{0008_native_code_backfill.sql → 20260824190830_native_code_backfill/migration.sql} +0 -0
  60. /package/migrations/{0009_nostalgic_thing.sql → 20261028220913_nostalgic_thing/migration.sql} +0 -0
  61. /package/migrations/{0010_sleepy_slayback.sql → 20261101195735_sleepy_slayback/migration.sql} +0 -0
  62. /package/migrations/{0011_pull_request_draft.sql → 20261112142844_pull_request_draft/migration.sql} +0 -0
  63. /package/migrations/{0012_pull_request_next_action.sql → 20261113213858_pull_request_next_action/migration.sql} +0 -0
  64. /package/migrations/{0013_conflict_fixes_resumed_at.sql → 20261119095049_conflict_fixes_resumed_at/migration.sql} +0 -0
  65. /package/migrations/{0014_conflict_fixes.sql → 20261119230607_conflict_fixes/migration.sql} +0 -0
  66. /package/migrations/{0015_conflict_fix_asked_at.sql → 20261120232426_conflict_fix_asked_at/migration.sql} +0 -0
  67. /package/migrations/{0016_pull_request_finished_at.sql → 20261121002146_pull_request_finished_at/migration.sql} +0 -0
  68. /package/migrations/{0017_pull_request_lifecycle_copies.sql → 20261121002159_pull_request_lifecycle_copies/migration.sql} +0 -0
  69. /package/migrations/{0018_drop_pull_request_issues.sql → 20261123212042_drop_pull_request_issues/migration.sql} +0 -0
  70. /package/migrations/{0019_drop_github_issues.sql → 20261123220932_drop_github_issues/migration.sql} +0 -0
@@ -605,14 +605,19 @@ const GITHUB_PULL_REQUEST_EVENTS = [
605
605
  "pull_request.checks.recovered",
606
606
  "pull_request.comment.created",
607
607
  "pull_request.opened",
608
+ "pull_request.reopened",
608
609
  "pull_request.ready_for_review",
610
+ "pull_request.converted_to_draft",
611
+ "pull_request.synchronized",
612
+ "pull_request.review_requested",
609
613
  "pull_request.review.approved",
610
614
  "pull_request.review.changes_requested",
611
615
  "pull_request.review.commented",
612
616
  "pull_request.review_comment.created",
613
617
  "pull_request.merged",
614
618
  "pull_request.closed_unmerged",
615
- "pull_request.merge_conflict"
619
+ "pull_request.merge_conflict",
620
+ "pull_request.merge_conflict.resolved"
616
621
  ];
617
622
  /**
618
623
  * A stack merges only with a linear history, so a stacked pull request is
@@ -624,9 +629,11 @@ const STACK_CONFLICT_STEPS = "run `gh stack rebase`, resolve each conflict so th
624
629
  /**
625
630
  * Every comment on a pull request gets the same feedback status: a
626
631
  * conversation comment, an inline review comment, and a review body. A review
627
- * sets comment_id only when it has a body.
632
+ * sets comment_id only when it has a body. A reply that hands the decision
633
+ * back to the reviewer reaches their Inbox only through the mark
634
+ * (`pull-request-review-again.ts`).
628
635
  */
629
- const PULL_REQUEST_FEEDBACK = "When Verified details include comment_id, call github_updatePullRequestFeedback after acting on actionable feedback or answering a question, with the exact repo, pull_request, comment_id, and comment_kind from Verified details, and status \"addressed\" or \"declined\".";
636
+ const PULL_REQUEST_FEEDBACK = "When Verified details include comment_id, call github_updatePullRequestFeedback after you act on the comment or reply to it, with the exact repo, pull_request, comment_id, and comment_kind from Verified details. Also mark a comment that you push back on, defer, or answer with a question: a change request asks its reviewer to review again only when each of its comments is marked, so an unmarked comment drops the pull request from their Inbox.";
630
637
  const GITHUB_PULL_REQUEST_EVENT_GUIDANCE = {
631
638
  "pull_request.checks.failed": "Fix only failures that the pull request causes. Do not skip, disable, or weaken a check to make it pass.",
632
639
  "pull_request.review.approved": `When the approval includes actionable feedback, address it like any other review feedback. ${PULL_REQUEST_FEEDBACK}`,
@@ -722,11 +729,12 @@ const GITHUB_PULL_REQUEST_SUGGESTED_EVENTS = [
722
729
  "pull_request.merge_conflict"
723
730
  ];
724
731
  /**
725
- * Pull request events that a GitHub webhook payload describes. GitHub sends
726
- * no webhook when a pull request gets a conflict, so the webhook reads the
727
- * pull request for `pull_request.merge_conflict` instead.
732
+ * Merge conflict events. GitHub sends no webhook when a pull request gets a
733
+ * conflict or loses it, so the plugin reads the pull request for them.
728
734
  */
729
- const GITHUB_PULL_REQUEST_PAYLOAD_EVENTS = GITHUB_PULL_REQUEST_EVENTS.filter((eventType) => eventType !== "pull_request.merge_conflict");
735
+ const GITHUB_MERGE_CONFLICT_EVENTS = /* @__PURE__ */ new Set(["pull_request.merge_conflict", "pull_request.merge_conflict.resolved"]);
736
+ /** Pull request events that a GitHub webhook payload describes. */
737
+ const GITHUB_PULL_REQUEST_PAYLOAD_EVENTS = GITHUB_PULL_REQUEST_EVENTS.filter((eventType) => !GITHUB_MERGE_CONFLICT_EVENTS.has(eventType));
730
738
  /** Pull request events that a comment or review starts. */
731
739
  const GITHUB_PULL_REQUEST_COMMENT_EVENTS = [
732
740
  "pull_request.comment.created",
@@ -748,7 +756,8 @@ const GITHUB_PULL_REQUEST_CHECK_EVENTS = [
748
756
  * The pull request comment webhook has no head branch. A check suite result
749
757
  * that GitHub links to no pull request has no `pullRequest`. The webhook
750
758
  * checks for a Watch or event automation before it reads a pull request for
751
- * a conflict, so `pull_request.merge_conflict` matches only `repo` and
759
+ * a conflict, so `pull_request.merge_conflict` and
760
+ * `pull_request.merge_conflict.resolved` match only `repo` and
752
761
  * `pullRequest`.
753
762
  */
754
763
  const GITHUB_PULL_REQUEST_MATCH_FIELDS = eventMatchFieldsSchema.parse({
@@ -2840,9 +2849,11 @@ const pullRequestWebhookSchema = z.object({
2840
2849
  title: z.string().optional(),
2841
2850
  updated_at: z.string().optional()
2842
2851
  }),
2843
- repository: repositorySchema
2852
+ repository: repositorySchema,
2853
+ requested_reviewer: z.object({ login: z.string().min(1) }).nullish(),
2854
+ requested_team: z.object({ slug: z.string().min(1) }).nullish()
2844
2855
  });
2845
- /** Normalize pull request opened, ready-for-review, and terminal lifecycle events. */
2856
+ /** Normalize pull request lifecycle, push, and review request events. */
2846
2857
  function normalizePullRequestEvent(deliveryId, body) {
2847
2858
  const parsed = pullRequestWebhookSchema.safeParse(body);
2848
2859
  if (!parsed.success) return [];
@@ -2890,14 +2901,41 @@ function normalizePullRequestEvent(deliveryId, body) {
2890
2901
  }));
2891
2902
  return events;
2892
2903
  }
2893
- if (parsed.data.action === "ready_for_review") return lifecycleEvents({
2894
- eventType: "pull_request.ready_for_review",
2895
- isDraft: false,
2896
- occurredAtMs: providerTime(pullRequest.updated_at) ?? Date.now(),
2897
- trustedSummary: `${resource.label} is ready for review.`,
2898
- untrustedText
2899
- });
2900
- return gitHubPullRequestTerminalEvents(body);
2904
+ const updatedAtMs = providerTime(pullRequest.updated_at) ?? Date.now();
2905
+ switch (parsed.data.action) {
2906
+ case "ready_for_review": return lifecycleEvents({
2907
+ eventType: "pull_request.ready_for_review",
2908
+ isDraft: false,
2909
+ occurredAtMs: updatedAtMs,
2910
+ trustedSummary: `${resource.label} is ready for review.`,
2911
+ untrustedText
2912
+ });
2913
+ case "reopened": return lifecycleEvents({
2914
+ eventType: "pull_request.reopened",
2915
+ occurredAtMs: updatedAtMs,
2916
+ trustedSummary: `${resource.label} was reopened.`,
2917
+ untrustedText
2918
+ });
2919
+ case "converted_to_draft": return lifecycleEvents({
2920
+ eventType: "pull_request.converted_to_draft",
2921
+ occurredAtMs: updatedAtMs,
2922
+ trustedSummary: `${resource.label} was converted to a draft.`
2923
+ });
2924
+ case "review_requested": {
2925
+ const reviewer = nonBlank(parsed.data.requested_reviewer?.login) ?? (parsed.data.requested_team ? `team ${parsed.data.requested_team.slug}` : void 0);
2926
+ return lifecycleEvents({
2927
+ eventType: "pull_request.review_requested",
2928
+ occurredAtMs: updatedAtMs,
2929
+ trustedSummary: reviewer ? `${resource.label} has a review request for ${reviewer}.` : `${resource.label} has a review request.`
2930
+ });
2931
+ }
2932
+ case "synchronize": return lifecycleEvents({
2933
+ eventType: "pull_request.synchronized",
2934
+ occurredAtMs: updatedAtMs,
2935
+ trustedSummary: `${resource.label} has new commits.`
2936
+ });
2937
+ default: return gitHubPullRequestTerminalEvents(body);
2938
+ }
2901
2939
  }
2902
2940
  /**
2903
2941
  * Build the merged or closed_unmerged events of one closed pull request.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PluginRegistration } from "@sentry/junior-plugin-api";
2
2
  type GitHubAppPermissionLevel = "admin" | "read" | "write";
3
3
  type GitHubAppPermissions = Record<string, GitHubAppPermissionLevel>;
4
- declare const GITHUB_PULL_REQUEST_EVENTS: readonly ["pull_request.checks.failed", "pull_request.checks.passed", "pull_request.checks.recovered", "pull_request.comment.created", "pull_request.opened", "pull_request.ready_for_review", "pull_request.review.approved", "pull_request.review.changes_requested", "pull_request.review.commented", "pull_request.review_comment.created", "pull_request.merged", "pull_request.closed_unmerged", "pull_request.merge_conflict"];
4
+ declare const GITHUB_PULL_REQUEST_EVENTS: readonly ["pull_request.checks.failed", "pull_request.checks.passed", "pull_request.checks.recovered", "pull_request.comment.created", "pull_request.opened", "pull_request.reopened", "pull_request.ready_for_review", "pull_request.converted_to_draft", "pull_request.synchronized", "pull_request.review_requested", "pull_request.review.approved", "pull_request.review.changes_requested", "pull_request.review.commented", "pull_request.review_comment.created", "pull_request.merged", "pull_request.closed_unmerged", "pull_request.merge_conflict", "pull_request.merge_conflict.resolved"];
5
5
  type GitHubPullRequestEvent = (typeof GITHUB_PULL_REQUEST_EVENTS)[number];
6
6
  /** App-configured pull request event behavior. */
7
7
  interface GitHubPullRequestEventOptions {