@sentry/junior-github 0.106.0 → 0.107.1
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/README.md +4 -0
- package/SETUP.md +32 -0
- package/dist/chunk-JDNXIBCQ.js +239 -0
- package/dist/db/schema.d.ts +334 -0
- package/dist/index.js +617 -51
- package/dist/pull-request-outcomes/report.d.ts +7 -0
- package/dist/pull-request-outcomes/store.d.ts +29 -0
- package/dist/resource-events/pull-request.d.ts +6 -1
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +6 -0
- package/dist/tools/update-pull-request.d.ts +57 -0
- package/dist/webhooks/handler.d.ts +9 -0
- package/dist/webhooks/pull-request-outcome.d.ts +6 -0
- package/dist/webhooks/resource-events.d.ts +7 -0
- package/migrations/0000_pull_request_outcomes.sql +16 -0
- package/migrations/meta/0000_snapshot.json +148 -0
- package/migrations/meta/_journal.json +13 -0
- package/package.json +12 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PluginOperationalReportContent } from "@sentry/junior-plugin-api";
|
|
2
|
+
import type { GitHubDb } from "./store.js";
|
|
3
|
+
/** Build the generic dashboard report for Junior-owned pull request outcomes. */
|
|
4
|
+
export declare function buildGitHubOutcomeReport(args: {
|
|
5
|
+
db: GitHubDb;
|
|
6
|
+
nowMs: number;
|
|
7
|
+
}): Promise<PluginOperationalReportContent>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PgDatabase } from "drizzle-orm/pg-core";
|
|
2
|
+
import type { PgQueryResultHKT } from "drizzle-orm/pg-core/session";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { githubSqlSchema } from "../db/schema.js";
|
|
5
|
+
export type GitHubDb = PgDatabase<PgQueryResultHKT, typeof githubSqlSchema>;
|
|
6
|
+
declare const githubPullRequestOutcomeInputSchema: z.ZodObject<{
|
|
7
|
+
candidateOwned: z.ZodBoolean;
|
|
8
|
+
closedAt: z.ZodOptional<z.ZodDate>;
|
|
9
|
+
mergedAt: z.ZodOptional<z.ZodDate>;
|
|
10
|
+
number: z.ZodNumber;
|
|
11
|
+
openedAt: z.ZodDate;
|
|
12
|
+
pullRequestId: z.ZodString;
|
|
13
|
+
repositoryFullName: z.ZodString;
|
|
14
|
+
repositoryId: z.ZodString;
|
|
15
|
+
state: z.ZodEnum<{
|
|
16
|
+
merged: "merged";
|
|
17
|
+
open: "open";
|
|
18
|
+
closed_unmerged: "closed_unmerged";
|
|
19
|
+
}>;
|
|
20
|
+
updatedAt: z.ZodDate;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
export type GitHubPullRequestOutcomeInput = z.output<typeof githubPullRequestOutcomeInputSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* Record the newest lifecycle projection for one Junior-owned pull request.
|
|
25
|
+
* An ownership-qualified opening or terminal recovery inserts; later events
|
|
26
|
+
* update existing rows, and older provider timestamps cannot regress it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function recordGitHubPullRequestOutcome(db: GitHubDb, input: GitHubPullRequestOutcomeInput): Promise<void>;
|
|
29
|
+
export {};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { SubscribableResource } from "@sentry/junior-plugin-api";
|
|
2
|
-
/** Build the stable
|
|
2
|
+
/** Build the stable pull request identity shared by tools and webhooks. */
|
|
3
|
+
export declare function gitHubPullRequestResource(input: {
|
|
4
|
+
number: number;
|
|
5
|
+
repo: string;
|
|
6
|
+
}): Pick<SubscribableResource, "label" | "provider" | "resourceRef">;
|
|
7
|
+
/** Describe a pull request as a resource when webhook subscriptions are enabled. */
|
|
3
8
|
export declare function gitHubPullRequestSubscribable(input: {
|
|
4
9
|
number: number;
|
|
5
10
|
repo: string;
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type ToolRegistrationHookContext } from "@sentry/junior-plugin-api";
|
|
2
|
+
/** Update mutable PR metadata while preserving Junior-owned body attribution. */
|
|
3
|
+
export declare function createGitHubUpdatePullRequestTool(ctx: ToolRegistrationHookContext): import("@sentry/junior-plugin-api").PluginToolDefinition<{
|
|
4
|
+
repo: string;
|
|
5
|
+
number: number;
|
|
6
|
+
title?: string | undefined;
|
|
7
|
+
body?: string | undefined;
|
|
8
|
+
base?: string | undefined;
|
|
9
|
+
state?: "open" | "closed" | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
[x: string]: unknown;
|
|
12
|
+
base: string;
|
|
13
|
+
body: string | null;
|
|
14
|
+
draft: boolean;
|
|
15
|
+
number: number;
|
|
16
|
+
state: string;
|
|
17
|
+
title: string;
|
|
18
|
+
url: string;
|
|
19
|
+
ok: true;
|
|
20
|
+
status: "success";
|
|
21
|
+
target: "updatePullRequest";
|
|
22
|
+
data: {
|
|
23
|
+
base: string;
|
|
24
|
+
body: string | null;
|
|
25
|
+
draft: boolean;
|
|
26
|
+
number: number;
|
|
27
|
+
state: string;
|
|
28
|
+
title: string;
|
|
29
|
+
url: string;
|
|
30
|
+
subscribable?: {
|
|
31
|
+
label: string;
|
|
32
|
+
provider: string;
|
|
33
|
+
resourceRef: string;
|
|
34
|
+
supportedEvents: string[];
|
|
35
|
+
type: string;
|
|
36
|
+
suggestedEvents?: string[] | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
};
|
|
39
|
+
truncated?: boolean | undefined;
|
|
40
|
+
continuation?: {
|
|
41
|
+
arguments: Record<string, unknown>;
|
|
42
|
+
reason?: string | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
error?: string | {
|
|
45
|
+
kind: string;
|
|
46
|
+
message: string;
|
|
47
|
+
retryable?: boolean | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
subscribable?: {
|
|
50
|
+
label: string;
|
|
51
|
+
provider: string;
|
|
52
|
+
resourceRef: string;
|
|
53
|
+
supportedEvents: string[];
|
|
54
|
+
type: string;
|
|
55
|
+
suggestedEvents?: string[] | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PluginRoute, ResourceEventPublisher } from "@sentry/junior-plugin-api";
|
|
2
|
+
import type { GitHubDb } from "../pull-request-outcomes/store.js";
|
|
3
|
+
/** Create the public, signed GitHub webhook route owned by the plugin. */
|
|
4
|
+
export declare function createGitHubWebhookRoute(args: {
|
|
5
|
+
botEmail(): string | undefined;
|
|
6
|
+
db: GitHubDb;
|
|
7
|
+
resourceEvents: ResourceEventPublisher;
|
|
8
|
+
webhookSecret(): string | undefined;
|
|
9
|
+
}): PluginRoute;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GitHubPullRequestOutcomeInput } from "../pull-request-outcomes/store.js";
|
|
2
|
+
/** Normalize only the fields required for the Junior-owned PR projection. */
|
|
3
|
+
export declare function normalizeGitHubPullRequestOutcome(args: {
|
|
4
|
+
body: unknown;
|
|
5
|
+
botEmail?: string;
|
|
6
|
+
}): GitHubPullRequestOutcomeInput | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResourceEvent } from "@sentry/junior-plugin-api";
|
|
2
|
+
/** Normalize one verified GitHub delivery into conversation resource events. */
|
|
3
|
+
export declare function normalizeGitHubResourceEvents(args: {
|
|
4
|
+
body: unknown;
|
|
5
|
+
deliveryId: string;
|
|
6
|
+
eventName: string;
|
|
7
|
+
}): ResourceEvent[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
CREATE TABLE "junior_github_pull_requests" (
|
|
2
|
+
"pull_request_id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"repository_id" text NOT NULL,
|
|
4
|
+
"repository_full_name" text NOT NULL,
|
|
5
|
+
"number" integer NOT NULL,
|
|
6
|
+
"state" text NOT NULL,
|
|
7
|
+
"opened_at" timestamp with time zone NOT NULL,
|
|
8
|
+
"merged_at" timestamp with time zone,
|
|
9
|
+
"closed_at" timestamp with time zone,
|
|
10
|
+
"updated_at" timestamp with time zone NOT NULL
|
|
11
|
+
);
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
CREATE INDEX "junior_github_pull_requests_opened_at_idx" ON "junior_github_pull_requests" USING btree ("opened_at");--> statement-breakpoint
|
|
14
|
+
CREATE INDEX "junior_github_pull_requests_merged_at_idx" ON "junior_github_pull_requests" USING btree ("merged_at");--> statement-breakpoint
|
|
15
|
+
CREATE INDEX "junior_github_pull_requests_closed_at_idx" ON "junior_github_pull_requests" USING btree ("closed_at");--> statement-breakpoint
|
|
16
|
+
CREATE INDEX "junior_github_pull_requests_open_idx" ON "junior_github_pull_requests" USING btree ("pull_request_id") WHERE "junior_github_pull_requests"."state" = 'open';
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "2c771be0-ac94-4eff-a69a-ade43801be34",
|
|
3
|
+
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
4
|
+
"version": "7",
|
|
5
|
+
"dialect": "postgresql",
|
|
6
|
+
"tables": {
|
|
7
|
+
"public.junior_github_pull_requests": {
|
|
8
|
+
"name": "junior_github_pull_requests",
|
|
9
|
+
"schema": "",
|
|
10
|
+
"columns": {
|
|
11
|
+
"pull_request_id": {
|
|
12
|
+
"name": "pull_request_id",
|
|
13
|
+
"type": "text",
|
|
14
|
+
"primaryKey": true,
|
|
15
|
+
"notNull": true
|
|
16
|
+
},
|
|
17
|
+
"repository_id": {
|
|
18
|
+
"name": "repository_id",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true
|
|
22
|
+
},
|
|
23
|
+
"repository_full_name": {
|
|
24
|
+
"name": "repository_full_name",
|
|
25
|
+
"type": "text",
|
|
26
|
+
"primaryKey": false,
|
|
27
|
+
"notNull": true
|
|
28
|
+
},
|
|
29
|
+
"number": {
|
|
30
|
+
"name": "number",
|
|
31
|
+
"type": "integer",
|
|
32
|
+
"primaryKey": false,
|
|
33
|
+
"notNull": true
|
|
34
|
+
},
|
|
35
|
+
"state": {
|
|
36
|
+
"name": "state",
|
|
37
|
+
"type": "text",
|
|
38
|
+
"primaryKey": false,
|
|
39
|
+
"notNull": true
|
|
40
|
+
},
|
|
41
|
+
"opened_at": {
|
|
42
|
+
"name": "opened_at",
|
|
43
|
+
"type": "timestamp with time zone",
|
|
44
|
+
"primaryKey": false,
|
|
45
|
+
"notNull": true
|
|
46
|
+
},
|
|
47
|
+
"merged_at": {
|
|
48
|
+
"name": "merged_at",
|
|
49
|
+
"type": "timestamp with time zone",
|
|
50
|
+
"primaryKey": false,
|
|
51
|
+
"notNull": false
|
|
52
|
+
},
|
|
53
|
+
"closed_at": {
|
|
54
|
+
"name": "closed_at",
|
|
55
|
+
"type": "timestamp with time zone",
|
|
56
|
+
"primaryKey": false,
|
|
57
|
+
"notNull": false
|
|
58
|
+
},
|
|
59
|
+
"updated_at": {
|
|
60
|
+
"name": "updated_at",
|
|
61
|
+
"type": "timestamp with time zone",
|
|
62
|
+
"primaryKey": false,
|
|
63
|
+
"notNull": true
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"indexes": {
|
|
67
|
+
"junior_github_pull_requests_opened_at_idx": {
|
|
68
|
+
"name": "junior_github_pull_requests_opened_at_idx",
|
|
69
|
+
"columns": [
|
|
70
|
+
{
|
|
71
|
+
"expression": "opened_at",
|
|
72
|
+
"isExpression": false,
|
|
73
|
+
"asc": true,
|
|
74
|
+
"nulls": "last"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"isUnique": false,
|
|
78
|
+
"concurrently": false,
|
|
79
|
+
"method": "btree",
|
|
80
|
+
"with": {}
|
|
81
|
+
},
|
|
82
|
+
"junior_github_pull_requests_merged_at_idx": {
|
|
83
|
+
"name": "junior_github_pull_requests_merged_at_idx",
|
|
84
|
+
"columns": [
|
|
85
|
+
{
|
|
86
|
+
"expression": "merged_at",
|
|
87
|
+
"isExpression": false,
|
|
88
|
+
"asc": true,
|
|
89
|
+
"nulls": "last"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"isUnique": false,
|
|
93
|
+
"concurrently": false,
|
|
94
|
+
"method": "btree",
|
|
95
|
+
"with": {}
|
|
96
|
+
},
|
|
97
|
+
"junior_github_pull_requests_closed_at_idx": {
|
|
98
|
+
"name": "junior_github_pull_requests_closed_at_idx",
|
|
99
|
+
"columns": [
|
|
100
|
+
{
|
|
101
|
+
"expression": "closed_at",
|
|
102
|
+
"isExpression": false,
|
|
103
|
+
"asc": true,
|
|
104
|
+
"nulls": "last"
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"isUnique": false,
|
|
108
|
+
"concurrently": false,
|
|
109
|
+
"method": "btree",
|
|
110
|
+
"with": {}
|
|
111
|
+
},
|
|
112
|
+
"junior_github_pull_requests_open_idx": {
|
|
113
|
+
"name": "junior_github_pull_requests_open_idx",
|
|
114
|
+
"columns": [
|
|
115
|
+
{
|
|
116
|
+
"expression": "pull_request_id",
|
|
117
|
+
"isExpression": false,
|
|
118
|
+
"asc": true,
|
|
119
|
+
"nulls": "last"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"isUnique": false,
|
|
123
|
+
"where": "\"junior_github_pull_requests\".\"state\" = 'open'",
|
|
124
|
+
"concurrently": false,
|
|
125
|
+
"method": "btree",
|
|
126
|
+
"with": {}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"foreignKeys": {},
|
|
130
|
+
"compositePrimaryKeys": {},
|
|
131
|
+
"uniqueConstraints": {},
|
|
132
|
+
"policies": {},
|
|
133
|
+
"checkConstraints": {},
|
|
134
|
+
"isRLSEnabled": false
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"enums": {},
|
|
138
|
+
"schemas": {},
|
|
139
|
+
"sequences": {},
|
|
140
|
+
"roles": {},
|
|
141
|
+
"policies": {},
|
|
142
|
+
"views": {},
|
|
143
|
+
"_meta": {
|
|
144
|
+
"columns": {},
|
|
145
|
+
"schemas": {},
|
|
146
|
+
"tables": {}
|
|
147
|
+
}
|
|
148
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.107.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,28 +15,37 @@
|
|
|
15
15
|
".": {
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./testing": {
|
|
20
|
+
"types": "./dist/testing.d.ts",
|
|
21
|
+
"default": "./dist/testing.js"
|
|
18
22
|
}
|
|
19
23
|
},
|
|
20
24
|
"files": [
|
|
21
25
|
"dist",
|
|
26
|
+
"migrations",
|
|
22
27
|
"skills",
|
|
23
28
|
"SETUP.md"
|
|
24
29
|
],
|
|
25
30
|
"dependencies": {
|
|
26
31
|
"@sinclair/typebox": "^0.34.49",
|
|
32
|
+
"drizzle-orm": "^0.45.2",
|
|
27
33
|
"zod": "^4.4.3",
|
|
28
|
-
"@sentry/junior-plugin-api": "0.
|
|
34
|
+
"@sentry/junior-plugin-api": "0.107.1"
|
|
29
35
|
},
|
|
30
36
|
"devDependencies": {
|
|
31
37
|
"@types/node": "^25.9.1",
|
|
32
38
|
"msw": "^2.14.6",
|
|
39
|
+
"drizzle-kit": "^0.31.8",
|
|
33
40
|
"oxlint": "^1.66.0",
|
|
34
41
|
"tsup": "^8.5.1",
|
|
35
42
|
"typescript": "^6.0.3",
|
|
36
|
-
"vitest": "^4.1.7"
|
|
43
|
+
"vitest": "^4.1.7",
|
|
44
|
+
"@sentry/junior-testing": "0.0.0"
|
|
37
45
|
},
|
|
38
46
|
"scripts": {
|
|
39
47
|
"build": "tsup && tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
48
|
+
"db:generate": "pnpm exec drizzle-kit generate --config drizzle.config.ts",
|
|
40
49
|
"lint": "oxlint --config ../junior/.oxlintrc.json --deny-warnings src tests tsup.config.ts vitest.config.ts",
|
|
41
50
|
"test": "vitest run",
|
|
42
51
|
"typecheck": "tsc --noEmit"
|