@sentry/junior-github 0.161.0 → 0.162.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,3 +1,3 @@
1
1
  import type { ConversationAnnotation, ConversationSidebarAnnotation } from "@sentry/junior-plugin-api";
2
- /** Select the one GitHub annotation summary shown in a conversation row. */
3
- export declare function githubSidebarAnnotation(annotations: ConversationAnnotation[]): ConversationSidebarAnnotation | undefined;
2
+ /** Return GitHub annotations for a conversation row, newest first. */
3
+ export declare function githubSidebarAnnotations(annotations: ConversationAnnotation[]): ConversationSidebarAnnotation[];
package/dist/index.js CHANGED
@@ -4506,13 +4506,6 @@ async function classifyGitHubPullRequestCommitComposition(args) {
4506
4506
  }
4507
4507
 
4508
4508
  // src/annotations.ts
4509
- var STATUS_RANK = {
4510
- warning: 5,
4511
- open: 4,
4512
- draft: 3,
4513
- merged: 2,
4514
- closed: 1
4515
- };
4516
4509
  var STATUS_ICON = {
4517
4510
  warning: "triangle-alert",
4518
4511
  open: "circle-dot",
@@ -4520,31 +4513,40 @@ var STATUS_ICON = {
4520
4513
  merged: "git-merge",
4521
4514
  closed: "circle-x"
4522
4515
  };
4523
- function repositoryScope(annotation) {
4516
+ function isPullRequestUrl(url) {
4517
+ try {
4518
+ return /^\/[^/]+\/[^/]+\/pull\/\d+(?:\/|$)/.test(new URL(url).pathname);
4519
+ } catch {
4520
+ return false;
4521
+ }
4522
+ }
4523
+ function sidebarIconForStatus(status, url) {
4524
+ if (status === "open" && isPullRequestUrl(url)) return "git-pull-request";
4525
+ return STATUS_ICON[status];
4526
+ }
4527
+ function repositoryName(annotation) {
4524
4528
  try {
4525
- const [, owner, repo] = new URL(annotation.url).pathname.split("/");
4526
- return owner && repo ? { key: `${owner}/${repo}`, label: repo } : void 0;
4529
+ const [, , repo] = new URL(annotation.url).pathname.split("/");
4530
+ return repo || void 0;
4527
4531
  } catch {
4528
4532
  return void 0;
4529
4533
  }
4530
4534
  }
4531
- function githubSidebarAnnotation(annotations) {
4532
- const links = annotations.flatMap((annotation) => {
4533
- const repo = repositoryScope(annotation);
4534
- const status2 = annotation.status;
4535
- return repo && status2 ? [{ repo, status: status2 }] : [];
4536
- });
4537
- if (links.length === 0) return void 0;
4538
- const repos = new Map(links.map((link) => [link.repo.key, link.repo.label]));
4539
- const status = links.reduce(
4540
- (current, link) => STATUS_RANK[link.status] > STATUS_RANK[current] ? link.status : current,
4541
- "closed"
4542
- );
4543
- return {
4544
- icon: STATUS_ICON[status],
4545
- key: "github",
4546
- label: repos.size === 1 ? [...repos.values()][0] : `${repos.size} repos`
4547
- };
4535
+ function githubSidebarAnnotations(annotations) {
4536
+ return annotations.flatMap((annotation) => {
4537
+ const status = annotation.status;
4538
+ const label = repositoryName(annotation);
4539
+ return status && label ? [
4540
+ {
4541
+ annotation: {
4542
+ icon: sidebarIconForStatus(status, annotation.url),
4543
+ key: annotation.key,
4544
+ label
4545
+ },
4546
+ updatedAt: annotation.updatedAt
4547
+ }
4548
+ ] : [];
4549
+ }).sort((left, right) => right.updatedAt.localeCompare(left.updatedAt)).map(({ annotation }) => annotation);
4548
4550
  }
4549
4551
 
4550
4552
  // src/webhooks/check-suite-enrichment.ts
@@ -5361,10 +5363,10 @@ function githubPlugin(options = {}) {
5361
5363
  return {
5362
5364
  annotationsByConversationId: Object.fromEntries(
5363
5365
  ctx.conversationIds.flatMap((conversationId) => {
5364
- const annotation = githubSidebarAnnotation(
5366
+ const annotations = githubSidebarAnnotations(
5365
5367
  ctx.annotationsByConversationId[conversationId] ?? []
5366
5368
  );
5367
- return annotation ? [[conversationId, [annotation]]] : [];
5369
+ return annotations.length > 0 ? [[conversationId, annotations]] : [];
5368
5370
  })
5369
5371
  )
5370
5372
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-github",
3
- "version": "0.161.0",
3
+ "version": "0.162.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -31,7 +31,7 @@
31
31
  "@sinclair/typebox": "^0.34.49",
32
32
  "drizzle-orm": "^0.45.2",
33
33
  "zod": "^4.4.3",
34
- "@sentry/junior-plugin-api": "0.161.0"
34
+ "@sentry/junior-plugin-api": "0.162.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^25.9.1",