@sentry/junior-github 0.159.0 → 0.160.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.
package/dist/index.js CHANGED
@@ -2695,19 +2695,30 @@ async function recordGitHubIssueOutcome(db, input) {
2695
2695
  const outcome = githubIssueOutcomeInputSchema.parse(input);
2696
2696
  const values = projectionValues(outcome);
2697
2697
  if (!outcome.candidateOwned) {
2698
- await db.update(juniorGitHubIssues).set(values).where(
2698
+ const updated = await db.update(juniorGitHubIssues).set(values).where(
2699
2699
  and(
2700
2700
  eq(juniorGitHubIssues.issueId, outcome.issueId),
2701
2701
  lte(juniorGitHubIssues.updatedAt, outcome.updatedAt)
2702
2702
  )
2703
- );
2704
- return;
2703
+ ).returning({
2704
+ conversationIds: juniorGitHubIssues.conversationIds
2705
+ });
2706
+ return {
2707
+ applied: updated.length > 0,
2708
+ conversationIds: updated[0]?.conversationIds ?? []
2709
+ };
2705
2710
  }
2706
- await db.insert(juniorGitHubIssues).values({ issueId: outcome.issueId, ...values }).onConflictDoUpdate({
2711
+ const inserted = await db.insert(juniorGitHubIssues).values({ issueId: outcome.issueId, ...values }).onConflictDoUpdate({
2707
2712
  target: juniorGitHubIssues.issueId,
2708
2713
  set: values,
2709
2714
  where: lte(juniorGitHubIssues.updatedAt, outcome.updatedAt)
2715
+ }).returning({
2716
+ conversationIds: juniorGitHubIssues.conversationIds
2710
2717
  });
2718
+ return {
2719
+ applied: inserted.length > 0,
2720
+ conversationIds: inserted[0]?.conversationIds ?? []
2721
+ };
2711
2722
  }
2712
2723
  async function recordGitHubIssueConversations(db, input) {
2713
2724
  const association = githubIssueConversationsInputSchema.parse(input);
@@ -3342,7 +3353,23 @@ function createGitHubWebhookRoute(args) {
3342
3353
  }
3343
3354
  }
3344
3355
  if (issueOutcome) {
3345
- await recordGitHubIssueOutcome(args.db, issueOutcome);
3356
+ const recordedOutcome = await recordGitHubIssueOutcome(
3357
+ args.db,
3358
+ issueOutcome
3359
+ );
3360
+ if (recordedOutcome.applied && issueOutcome.state === "closed") {
3361
+ await Promise.all(
3362
+ recordedOutcome.conversationIds.map(
3363
+ (conversationId) => args.annotations.forConversation(conversationId).upsert({
3364
+ kind: "resource_link",
3365
+ key: `${issueOutcome.repositoryFullName.toLowerCase()}#${issueOutcome.number}`,
3366
+ label: `${issueOutcome.repositoryFullName}#${issueOutcome.number}`,
3367
+ url: `https://github.com/${issueOutcome.repositoryFullName}/issues/${issueOutcome.number}`,
3368
+ status: "closed"
3369
+ })
3370
+ )
3371
+ );
3372
+ }
3346
3373
  }
3347
3374
  const recordedIssueConversations = issueConversations ? await recordGitHubIssueConversations(args.db, issueConversations) : false;
3348
3375
  const recordedPullRequestConversations = pullRequestConversations ? await recordGitHubPullRequestConversations(
@@ -30,8 +30,13 @@ export type GitHubIssueConversationsInput = z.output<typeof githubIssueConversat
30
30
  * Record the newest lifecycle projection for one Junior-owned issue.
31
31
  * Ownership-qualified opening or closing events insert; later events update
32
32
  * existing rows, and older provider timestamps cannot regress them.
33
+ * Returns the written row state so follow-up annotation updates stay scoped to
34
+ * associated conversations.
33
35
  */
34
- export declare function recordGitHubIssueOutcome(db: GitHubDb, input: GitHubIssueOutcomeInput): Promise<void>;
36
+ export declare function recordGitHubIssueOutcome(db: GitHubDb, input: GitHubIssueOutcomeInput): Promise<{
37
+ applied: boolean;
38
+ conversationIds: string[];
39
+ }>;
35
40
  /** Append native conversation ids to an existing Junior-owned issue projection. */
36
41
  export declare function recordGitHubIssueConversations(db: GitHubDb, input: GitHubIssueConversationsInput): Promise<boolean>;
37
42
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-github",
3
- "version": "0.159.0",
3
+ "version": "0.160.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.159.0"
34
+ "@sentry/junior-plugin-api": "0.160.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^25.9.1",