@sentry/junior-github 0.126.1 → 0.127.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/{chunk-NNSOXVGR.js → chunk-25NTEYYB.js} +188 -62
- package/dist/index.js +390 -243
- package/dist/resource-events/deployment.d.ts +2 -1
- package/dist/resource-events/issue.d.ts +13 -0
- package/dist/resource-events/pull-request.d.ts +3 -1
- package/dist/resource-events/repository.d.ts +9 -0
- package/dist/testing.js +1 -1
- package/dist/tools/create-issue.d.ts +32 -0
- package/dist/tools/create-pull-request.d.ts +8 -8
- package/dist/tools/get-deployment.d.ts +8 -8
- package/dist/tools/get-pull-request.d.ts +8 -8
- package/dist/tools/get-repository.d.ts +91 -0
- package/dist/tools/update-pull-request.d.ts +8 -8
- package/dist/webhooks/resource-events.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
GITHUB_DEPLOYMENT_EVENTS,
|
|
3
|
+
GITHUB_DEPLOYMENT_SUGGESTED_EVENTS,
|
|
4
|
+
GITHUB_ISSUE_EVENTS,
|
|
5
|
+
GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
6
|
+
GITHUB_PULL_REQUEST_EVENTS,
|
|
7
|
+
GITHUB_PULL_REQUEST_SUGGESTED_EVENTS,
|
|
2
8
|
gitHubDeploymentSourceSubscribable,
|
|
9
|
+
gitHubIssueSubscribable,
|
|
3
10
|
gitHubPullRequestSubscribable,
|
|
11
|
+
gitHubRepositorySubscribable,
|
|
4
12
|
normalizeGitHubResourceEvents
|
|
5
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-25NTEYYB.js";
|
|
6
14
|
|
|
7
15
|
// src/plugin.ts
|
|
8
16
|
import {
|
|
@@ -71,6 +79,7 @@ import {
|
|
|
71
79
|
definePluginTool,
|
|
72
80
|
EgressAuthRequired,
|
|
73
81
|
PluginToolInputError as PluginToolInputError2,
|
|
82
|
+
subscribableResourceSchema,
|
|
74
83
|
pluginToolResultSchema
|
|
75
84
|
} from "@sentry/junior-plugin-api";
|
|
76
85
|
import { Type } from "@sinclair/typebox";
|
|
@@ -120,7 +129,7 @@ function githubConversationFooter(conversationId, dashboardUrl) {
|
|
|
120
129
|
const id = nonEmptyString(conversationId, "conversationId");
|
|
121
130
|
const normalizedDashboardUrl = dashboardUrl?.trim();
|
|
122
131
|
const sentryUrl = sentryConversationUrl(id);
|
|
123
|
-
const sessionLinks = normalizedDashboardUrl ? `[View Junior Session](${normalizedDashboardUrl})${sentryUrl ? ` [Sentry](${sentryUrl})` : ""}` : sentryUrl ? `[View Junior Session in Sentry](${sentryUrl})` : void 0;
|
|
132
|
+
const sessionLinks = normalizedDashboardUrl ? `[View Junior Session](${normalizedDashboardUrl})${sentryUrl ? ` [[Sentry]](${sentryUrl})` : ""}` : sentryUrl ? `[View Junior Session in Sentry](${sentryUrl})` : void 0;
|
|
124
133
|
if (!sessionLinks) {
|
|
125
134
|
return void 0;
|
|
126
135
|
}
|
|
@@ -293,6 +302,7 @@ var createIssueStateSchema = Type.Union([
|
|
|
293
302
|
]);
|
|
294
303
|
var gitHubIssueDataSchema = z.object({
|
|
295
304
|
number: z.number(),
|
|
305
|
+
subscribable: subscribableResourceSchema.optional(),
|
|
296
306
|
url: z.string()
|
|
297
307
|
});
|
|
298
308
|
var gitHubIssueOutputSchema = pluginToolResultSchema.extend({
|
|
@@ -301,15 +311,22 @@ var gitHubIssueOutputSchema = pluginToolResultSchema.extend({
|
|
|
301
311
|
target: z.literal("createIssue"),
|
|
302
312
|
data: gitHubIssueDataSchema,
|
|
303
313
|
number: z.number(),
|
|
314
|
+
subscribable: subscribableResourceSchema.optional(),
|
|
304
315
|
url: z.string()
|
|
305
316
|
});
|
|
306
|
-
function gitHubIssueToolResult(result) {
|
|
317
|
+
function gitHubIssueToolResult(input, result) {
|
|
318
|
+
const repo = parseRepo(input.repo);
|
|
319
|
+
const subscribable = gitHubIssueSubscribable({
|
|
320
|
+
number: result.number,
|
|
321
|
+
repo: `${repo.owner}/${repo.name}`
|
|
322
|
+
});
|
|
323
|
+
const data = { ...result, ...subscribable ? { subscribable } : {} };
|
|
307
324
|
return {
|
|
308
325
|
ok: true,
|
|
309
326
|
status: "success",
|
|
310
327
|
target: "createIssue",
|
|
311
|
-
data
|
|
312
|
-
...
|
|
328
|
+
data,
|
|
329
|
+
...data
|
|
313
330
|
};
|
|
314
331
|
}
|
|
315
332
|
function parseCreateIssueInput(input) {
|
|
@@ -479,7 +496,7 @@ function createGitHubIssueTool(ctx) {
|
|
|
479
496
|
url: state.url
|
|
480
497
|
};
|
|
481
498
|
await annotateIssue(ctx, completedInput, completedResult);
|
|
482
|
-
return gitHubIssueToolResult(completedResult);
|
|
499
|
+
return gitHubIssueToolResult(completedInput, completedResult);
|
|
483
500
|
}
|
|
484
501
|
if (state?.status === "pending") {
|
|
485
502
|
throw new Error(
|
|
@@ -518,7 +535,7 @@ function createGitHubIssueTool(ctx) {
|
|
|
518
535
|
);
|
|
519
536
|
}
|
|
520
537
|
await annotateIssue(ctx, parsedInput, result);
|
|
521
|
-
return gitHubIssueToolResult(result);
|
|
538
|
+
return gitHubIssueToolResult(parsedInput, result);
|
|
522
539
|
} catch (error) {
|
|
523
540
|
if (isEgressAuthRequired(error) || isDefinitiveGitHubIssueCreateRejection(error)) {
|
|
524
541
|
await ctx.state.delete(key);
|
|
@@ -536,7 +553,7 @@ import {
|
|
|
536
553
|
definePluginTool as definePluginTool2,
|
|
537
554
|
PluginToolInputError as PluginToolInputError3,
|
|
538
555
|
pluginToolResultSchema as pluginToolResultSchema2,
|
|
539
|
-
subscribableResourceSchema
|
|
556
|
+
subscribableResourceSchema as subscribableResourceSchema2
|
|
540
557
|
} from "@sentry/junior-plugin-api";
|
|
541
558
|
import { z as z2 } from "zod";
|
|
542
559
|
var commitShaSchema = z2.string().regex(/^[0-9a-f]{40}$/i);
|
|
@@ -575,7 +592,7 @@ var deploymentSourceSchema = z2.object({
|
|
|
575
592
|
deployment: deploymentSchema.nullable(),
|
|
576
593
|
environment: z2.string().nullable(),
|
|
577
594
|
repo: z2.string(),
|
|
578
|
-
subscribable:
|
|
595
|
+
subscribable: subscribableResourceSchema2.optional()
|
|
579
596
|
}).strict();
|
|
580
597
|
var outputSchema = pluginToolResultSchema2.extend({
|
|
581
598
|
data: deploymentSourceSchema,
|
|
@@ -748,7 +765,7 @@ import {
|
|
|
748
765
|
import { Type as Type2 } from "@sinclair/typebox";
|
|
749
766
|
import { Value as Value2 } from "@sinclair/typebox/value";
|
|
750
767
|
import { z as z3 } from "zod";
|
|
751
|
-
import { subscribableResourceSchema as
|
|
768
|
+
import { subscribableResourceSchema as subscribableResourceSchema3 } from "@sentry/junior-plugin-api";
|
|
752
769
|
var GITHUB_PULL_REQUEST_CREATE_IDEMPOTENCY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
753
770
|
var GITHUB_PULL_REQUEST_CREATE_LOCK_TTL_MS = 6e4;
|
|
754
771
|
var GitHubPullRequestCreateRejectedError = class extends Error {
|
|
@@ -817,7 +834,7 @@ var createPullRequestStateSchema = Type2.Union([
|
|
|
817
834
|
var gitHubPullRequestDataSchema = z3.object({
|
|
818
835
|
number: z3.number(),
|
|
819
836
|
url: z3.string(),
|
|
820
|
-
subscribable:
|
|
837
|
+
subscribable: subscribableResourceSchema3.optional()
|
|
821
838
|
});
|
|
822
839
|
var gitHubPullRequestOutputSchema = pluginToolResultSchema3.extend({
|
|
823
840
|
ok: z3.literal(true),
|
|
@@ -826,7 +843,7 @@ var gitHubPullRequestOutputSchema = pluginToolResultSchema3.extend({
|
|
|
826
843
|
data: gitHubPullRequestDataSchema,
|
|
827
844
|
number: z3.number(),
|
|
828
845
|
url: z3.string(),
|
|
829
|
-
subscribable:
|
|
846
|
+
subscribable: subscribableResourceSchema3.optional()
|
|
830
847
|
});
|
|
831
848
|
function parseCreatePullRequestInput(input) {
|
|
832
849
|
try {
|
|
@@ -1096,7 +1113,7 @@ import {
|
|
|
1096
1113
|
pluginToolResultSchema as pluginToolResultSchema4
|
|
1097
1114
|
} from "@sentry/junior-plugin-api";
|
|
1098
1115
|
import { z as z4 } from "zod";
|
|
1099
|
-
import { subscribableResourceSchema as
|
|
1116
|
+
import { subscribableResourceSchema as subscribableResourceSchema4 } from "@sentry/junior-plugin-api";
|
|
1100
1117
|
var commitShaSchema2 = z4.string().regex(/^[0-9a-f]{40}$/i);
|
|
1101
1118
|
var inputSchema2 = z4.object({
|
|
1102
1119
|
repo: z4.string().describe('Repository in "owner/name" format.'),
|
|
@@ -1110,7 +1127,7 @@ var pullRequestSchema = z4.object({
|
|
|
1110
1127
|
merged: z4.boolean(),
|
|
1111
1128
|
number: z4.number(),
|
|
1112
1129
|
state: z4.string(),
|
|
1113
|
-
subscribable:
|
|
1130
|
+
subscribable: subscribableResourceSchema4.optional(),
|
|
1114
1131
|
title: z4.string(),
|
|
1115
1132
|
url: z4.string()
|
|
1116
1133
|
});
|
|
@@ -1205,58 +1222,161 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
1205
1222
|
});
|
|
1206
1223
|
}
|
|
1207
1224
|
|
|
1208
|
-
// src/tools/
|
|
1225
|
+
// src/tools/get-repository.ts
|
|
1209
1226
|
import {
|
|
1210
1227
|
definePluginTool as definePluginTool5,
|
|
1211
1228
|
PluginToolInputError as PluginToolInputError6,
|
|
1212
|
-
pluginToolResultSchema as pluginToolResultSchema5
|
|
1229
|
+
pluginToolResultSchema as pluginToolResultSchema5,
|
|
1230
|
+
subscribableResourceSchema as subscribableResourceSchema5
|
|
1213
1231
|
} from "@sentry/junior-plugin-api";
|
|
1214
1232
|
import { z as z5 } from "zod";
|
|
1215
|
-
import { subscribableResourceSchema as subscribableResourceSchema4 } from "@sentry/junior-plugin-api";
|
|
1216
1233
|
var inputSchema3 = z5.object({
|
|
1217
|
-
repo: z5.string().describe('Repository in "owner/name" format.')
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1234
|
+
repo: z5.string().describe('Repository in "owner/name" format.')
|
|
1235
|
+
}).strict();
|
|
1236
|
+
var repositorySchema = z5.object({
|
|
1237
|
+
defaultBranch: z5.string(),
|
|
1238
|
+
description: z5.string().nullable(),
|
|
1239
|
+
fullName: z5.string(),
|
|
1240
|
+
private: z5.boolean(),
|
|
1241
|
+
subscribable: subscribableResourceSchema5.optional(),
|
|
1242
|
+
url: z5.string()
|
|
1243
|
+
});
|
|
1244
|
+
var outputSchema3 = pluginToolResultSchema5.extend({
|
|
1245
|
+
ok: z5.literal(true),
|
|
1246
|
+
status: z5.literal("success"),
|
|
1247
|
+
target: z5.literal("getRepository"),
|
|
1248
|
+
data: repositorySchema,
|
|
1249
|
+
...repositorySchema.shape
|
|
1250
|
+
});
|
|
1251
|
+
function parseRepo5(value) {
|
|
1252
|
+
const parts = value.split("/").map((part) => part.trim());
|
|
1253
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
1254
|
+
throw new PluginToolInputError6('repo must use "owner/name" format');
|
|
1255
|
+
}
|
|
1256
|
+
return { owner: parts[0], name: parts[1] };
|
|
1257
|
+
}
|
|
1258
|
+
async function readJson3(response) {
|
|
1259
|
+
const text2 = await response.text();
|
|
1260
|
+
if (!text2) return void 0;
|
|
1261
|
+
try {
|
|
1262
|
+
return JSON.parse(text2);
|
|
1263
|
+
} catch {
|
|
1264
|
+
return text2;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
function createGitHubGetRepositoryTool(ctx) {
|
|
1268
|
+
return definePluginTool5({
|
|
1269
|
+
annotations: {
|
|
1270
|
+
destructiveHint: false,
|
|
1271
|
+
idempotentHint: true,
|
|
1272
|
+
openWorldHint: true,
|
|
1273
|
+
readOnlyHint: true
|
|
1274
|
+
},
|
|
1275
|
+
description: "Get a GitHub repository. Use this when repository-wide issue activity may need resource-event monitoring; the result includes a subscribable hint when GitHub webhooks are configured.",
|
|
1276
|
+
inputSchema: inputSchema3,
|
|
1277
|
+
outputSchema: outputSchema3,
|
|
1278
|
+
async execute(input) {
|
|
1279
|
+
const repo = parseRepo5(input.repo);
|
|
1280
|
+
const response = await ctx.egress.fetch({
|
|
1281
|
+
provider: "github",
|
|
1282
|
+
operation: "github.repository.get",
|
|
1283
|
+
request: new Request(
|
|
1284
|
+
`https://api.github.com/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}`,
|
|
1285
|
+
{
|
|
1286
|
+
headers: {
|
|
1287
|
+
Accept: "application/vnd.github+json",
|
|
1288
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
)
|
|
1292
|
+
});
|
|
1293
|
+
const parsed = await readJson3(response);
|
|
1294
|
+
if (!response.ok) {
|
|
1295
|
+
throw new PluginToolInputError6(
|
|
1296
|
+
`GitHub repository lookup failed with HTTP ${response.status}`
|
|
1297
|
+
);
|
|
1298
|
+
}
|
|
1299
|
+
const providerResult = z5.object({
|
|
1300
|
+
default_branch: z5.string(),
|
|
1301
|
+
description: z5.string().nullable(),
|
|
1302
|
+
full_name: z5.string(),
|
|
1303
|
+
html_url: z5.string(),
|
|
1304
|
+
private: z5.boolean()
|
|
1305
|
+
}).parse(parsed);
|
|
1306
|
+
const subscribable = gitHubRepositorySubscribable({
|
|
1307
|
+
repo: providerResult.full_name
|
|
1308
|
+
});
|
|
1309
|
+
const data = {
|
|
1310
|
+
defaultBranch: providerResult.default_branch,
|
|
1311
|
+
description: providerResult.description,
|
|
1312
|
+
fullName: providerResult.full_name,
|
|
1313
|
+
private: providerResult.private,
|
|
1314
|
+
...subscribable ? { subscribable } : {},
|
|
1315
|
+
url: providerResult.html_url
|
|
1316
|
+
};
|
|
1317
|
+
return {
|
|
1318
|
+
ok: true,
|
|
1319
|
+
status: "success",
|
|
1320
|
+
target: "getRepository",
|
|
1321
|
+
data,
|
|
1322
|
+
...data
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
// src/tools/update-pull-request.ts
|
|
1329
|
+
import {
|
|
1330
|
+
definePluginTool as definePluginTool6,
|
|
1331
|
+
PluginToolInputError as PluginToolInputError7,
|
|
1332
|
+
pluginToolResultSchema as pluginToolResultSchema6
|
|
1333
|
+
} from "@sentry/junior-plugin-api";
|
|
1334
|
+
import { z as z6 } from "zod";
|
|
1335
|
+
import { subscribableResourceSchema as subscribableResourceSchema6 } from "@sentry/junior-plugin-api";
|
|
1336
|
+
var inputSchema4 = z6.object({
|
|
1337
|
+
repo: z6.string().describe('Repository in "owner/name" format.'),
|
|
1338
|
+
number: z6.number().int().positive().describe("Pull request number."),
|
|
1339
|
+
title: z6.string().trim().min(1).optional().describe("Replacement pull request title."),
|
|
1340
|
+
body: z6.string().optional().describe(
|
|
1221
1341
|
"Replacement pull request body. Junior appends requester attribution and the conversation footer."
|
|
1222
1342
|
),
|
|
1223
|
-
base:
|
|
1224
|
-
state:
|
|
1343
|
+
base: z6.string().trim().min(1).optional().describe("Replacement base branch."),
|
|
1344
|
+
state: z6.enum(["open", "closed"]).optional().describe("Replacement pull request state.")
|
|
1225
1345
|
}).strict().refine(
|
|
1226
1346
|
({ title, body, base, state }) => title !== void 0 || body !== void 0 || base !== void 0 || state !== void 0,
|
|
1227
1347
|
{ message: "At least one pull request field must be provided." }
|
|
1228
1348
|
);
|
|
1229
|
-
var pullRequestSchema2 =
|
|
1230
|
-
base:
|
|
1231
|
-
body:
|
|
1232
|
-
draft:
|
|
1233
|
-
number:
|
|
1234
|
-
state:
|
|
1235
|
-
subscribable:
|
|
1236
|
-
title:
|
|
1237
|
-
url:
|
|
1349
|
+
var pullRequestSchema2 = z6.object({
|
|
1350
|
+
base: z6.string(),
|
|
1351
|
+
body: z6.string().nullable(),
|
|
1352
|
+
draft: z6.boolean(),
|
|
1353
|
+
number: z6.number(),
|
|
1354
|
+
state: z6.string(),
|
|
1355
|
+
subscribable: subscribableResourceSchema6.optional(),
|
|
1356
|
+
title: z6.string(),
|
|
1357
|
+
url: z6.string()
|
|
1238
1358
|
});
|
|
1239
|
-
var
|
|
1240
|
-
ok:
|
|
1241
|
-
status:
|
|
1242
|
-
target:
|
|
1359
|
+
var outputSchema4 = pluginToolResultSchema6.extend({
|
|
1360
|
+
ok: z6.literal(true),
|
|
1361
|
+
status: z6.literal("success"),
|
|
1362
|
+
target: z6.literal("updatePullRequest"),
|
|
1243
1363
|
data: pullRequestSchema2,
|
|
1244
1364
|
...pullRequestSchema2.shape
|
|
1245
1365
|
});
|
|
1246
1366
|
function nonEmptyString4(value, name) {
|
|
1247
1367
|
if (!value?.trim()) {
|
|
1248
|
-
throw new
|
|
1368
|
+
throw new PluginToolInputError7(`${name} is required`);
|
|
1249
1369
|
}
|
|
1250
1370
|
return value.trim();
|
|
1251
1371
|
}
|
|
1252
|
-
function
|
|
1372
|
+
function parseRepo6(value) {
|
|
1253
1373
|
const parts = value.split("/").map((part) => part.trim());
|
|
1254
1374
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
1255
|
-
throw new
|
|
1375
|
+
throw new PluginToolInputError7('repo must use "owner/name" format');
|
|
1256
1376
|
}
|
|
1257
1377
|
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
1258
1378
|
}
|
|
1259
|
-
async function
|
|
1379
|
+
async function readJson4(response) {
|
|
1260
1380
|
const text2 = await response.text();
|
|
1261
1381
|
if (!text2) return void 0;
|
|
1262
1382
|
try {
|
|
@@ -1274,7 +1394,7 @@ function githubApiErrorMessage3(payload) {
|
|
|
1274
1394
|
return "GitHub request failed";
|
|
1275
1395
|
}
|
|
1276
1396
|
function createGitHubUpdatePullRequestTool(ctx) {
|
|
1277
|
-
return
|
|
1397
|
+
return definePluginTool6({
|
|
1278
1398
|
annotations: {
|
|
1279
1399
|
destructiveHint: true,
|
|
1280
1400
|
idempotentHint: true,
|
|
@@ -1282,18 +1402,18 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
1282
1402
|
readOnlyHint: false
|
|
1283
1403
|
},
|
|
1284
1404
|
description: "Update an existing GitHub pull request's title, body, base branch, or open/closed state. Use this instead of raw GitHub API calls when changing PR metadata.",
|
|
1285
|
-
inputSchema:
|
|
1286
|
-
outputSchema:
|
|
1405
|
+
inputSchema: inputSchema4,
|
|
1406
|
+
outputSchema: outputSchema4,
|
|
1287
1407
|
async execute(input) {
|
|
1288
|
-
const parsedInput =
|
|
1408
|
+
const parsedInput = inputSchema4.safeParse(input);
|
|
1289
1409
|
if (!parsedInput.success) {
|
|
1290
|
-
throw new
|
|
1410
|
+
throw new PluginToolInputError7(
|
|
1291
1411
|
"Invalid GitHub updatePullRequest input.",
|
|
1292
1412
|
{ cause: parsedInput.error }
|
|
1293
1413
|
);
|
|
1294
1414
|
}
|
|
1295
1415
|
const update = parsedInput.data;
|
|
1296
|
-
const repo =
|
|
1416
|
+
const repo = parseRepo6(update.repo);
|
|
1297
1417
|
const payload = {
|
|
1298
1418
|
...update.title !== void 0 ? { title: update.title } : {},
|
|
1299
1419
|
...update.body !== void 0 ? {
|
|
@@ -1322,20 +1442,20 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
1322
1442
|
}
|
|
1323
1443
|
)
|
|
1324
1444
|
});
|
|
1325
|
-
const parsed = await
|
|
1445
|
+
const parsed = await readJson4(response);
|
|
1326
1446
|
if (!response.ok) {
|
|
1327
1447
|
throw new Error(
|
|
1328
1448
|
`GitHub pull request update failed with HTTP ${response.status}: ${githubApiErrorMessage3(parsed)}`
|
|
1329
1449
|
);
|
|
1330
1450
|
}
|
|
1331
|
-
const providerResult =
|
|
1332
|
-
base:
|
|
1333
|
-
body:
|
|
1334
|
-
draft:
|
|
1335
|
-
html_url:
|
|
1336
|
-
number:
|
|
1337
|
-
state:
|
|
1338
|
-
title:
|
|
1451
|
+
const providerResult = z6.object({
|
|
1452
|
+
base: z6.object({ ref: z6.string() }),
|
|
1453
|
+
body: z6.string().nullable().optional().default(null),
|
|
1454
|
+
draft: z6.boolean(),
|
|
1455
|
+
html_url: z6.string(),
|
|
1456
|
+
number: z6.number(),
|
|
1457
|
+
state: z6.string(),
|
|
1458
|
+
title: z6.string()
|
|
1339
1459
|
}).parse(parsed);
|
|
1340
1460
|
const subscribable = gitHubPullRequestSubscribable({
|
|
1341
1461
|
number: providerResult.number,
|
|
@@ -1369,6 +1489,7 @@ function createGitHubTools(ctx) {
|
|
|
1369
1489
|
createPullRequest: createGitHubPullRequestTool(ctx),
|
|
1370
1490
|
getDeployment: createGitHubGetDeploymentTool(ctx),
|
|
1371
1491
|
getPullRequest: createGitHubGetPullRequestTool(ctx),
|
|
1492
|
+
getRepository: createGitHubGetRepositoryTool(ctx),
|
|
1372
1493
|
updatePullRequest: createGitHubUpdatePullRequestTool(ctx)
|
|
1373
1494
|
};
|
|
1374
1495
|
}
|
|
@@ -1378,7 +1499,7 @@ import { createHmac, timingSafeEqual } from "crypto";
|
|
|
1378
1499
|
|
|
1379
1500
|
// src/issue-outcomes/store.ts
|
|
1380
1501
|
import { and, eq, lte, sql as sql2 } from "drizzle-orm";
|
|
1381
|
-
import { z as
|
|
1502
|
+
import { z as z8 } from "zod";
|
|
1382
1503
|
|
|
1383
1504
|
// src/db/schema.ts
|
|
1384
1505
|
import { sql } from "drizzle-orm";
|
|
@@ -1390,18 +1511,18 @@ import {
|
|
|
1390
1511
|
text,
|
|
1391
1512
|
timestamp
|
|
1392
1513
|
} from "drizzle-orm/pg-core";
|
|
1393
|
-
import { z as
|
|
1394
|
-
var githubPullRequestStateSchema =
|
|
1514
|
+
import { z as z7 } from "zod";
|
|
1515
|
+
var githubPullRequestStateSchema = z7.enum([
|
|
1395
1516
|
"closed_unmerged",
|
|
1396
1517
|
"merged",
|
|
1397
1518
|
"open"
|
|
1398
1519
|
]);
|
|
1399
|
-
var githubPullRequestCommitCompositionSchema =
|
|
1520
|
+
var githubPullRequestCommitCompositionSchema = z7.enum([
|
|
1400
1521
|
"junior_only",
|
|
1401
1522
|
"mixed"
|
|
1402
1523
|
]);
|
|
1403
|
-
var githubIssueStateSchema =
|
|
1404
|
-
var githubIssueStateReasonSchema =
|
|
1524
|
+
var githubIssueStateSchema = z7.enum(["closed", "open"]);
|
|
1525
|
+
var githubIssueStateReasonSchema = z7.enum([
|
|
1405
1526
|
"completed",
|
|
1406
1527
|
"duplicate",
|
|
1407
1528
|
"not_planned",
|
|
@@ -1470,21 +1591,21 @@ var juniorGitHubPullRequestIssues = pgTable(
|
|
|
1470
1591
|
);
|
|
1471
1592
|
|
|
1472
1593
|
// src/issue-outcomes/store.ts
|
|
1473
|
-
var githubIssueOutcomeInputSchema =
|
|
1474
|
-
candidateOwned:
|
|
1475
|
-
closedAt:
|
|
1476
|
-
issueId:
|
|
1477
|
-
number:
|
|
1478
|
-
openedAt:
|
|
1479
|
-
repositoryFullName:
|
|
1480
|
-
repositoryId:
|
|
1594
|
+
var githubIssueOutcomeInputSchema = z8.object({
|
|
1595
|
+
candidateOwned: z8.boolean(),
|
|
1596
|
+
closedAt: z8.date().optional(),
|
|
1597
|
+
issueId: z8.string().min(1),
|
|
1598
|
+
number: z8.number().int().positive(),
|
|
1599
|
+
openedAt: z8.date(),
|
|
1600
|
+
repositoryFullName: z8.string().min(1),
|
|
1601
|
+
repositoryId: z8.string().min(1),
|
|
1481
1602
|
state: githubIssueStateSchema,
|
|
1482
1603
|
stateReason: githubIssueStateReasonSchema.optional(),
|
|
1483
|
-
updatedAt:
|
|
1604
|
+
updatedAt: z8.date()
|
|
1484
1605
|
}).strict();
|
|
1485
|
-
var githubIssueConversationsInputSchema =
|
|
1486
|
-
conversationIds:
|
|
1487
|
-
issueId:
|
|
1606
|
+
var githubIssueConversationsInputSchema = z8.object({
|
|
1607
|
+
conversationIds: z8.array(z8.string().min(1)).min(1),
|
|
1608
|
+
issueId: z8.string().min(1)
|
|
1488
1609
|
}).strict();
|
|
1489
1610
|
function projectionValues(input) {
|
|
1490
1611
|
return {
|
|
@@ -1537,32 +1658,32 @@ async function recordGitHubIssueConversations(db, input) {
|
|
|
1537
1658
|
|
|
1538
1659
|
// src/pull-request-outcomes/store.ts
|
|
1539
1660
|
import { and as and2, eq as eq2, lte as lte2, sql as sql3 } from "drizzle-orm";
|
|
1540
|
-
import { z as
|
|
1541
|
-
var githubPullRequestOutcomeInputSchema =
|
|
1542
|
-
candidateOwned:
|
|
1543
|
-
closedAt:
|
|
1661
|
+
import { z as z9 } from "zod";
|
|
1662
|
+
var githubPullRequestOutcomeInputSchema = z9.object({
|
|
1663
|
+
candidateOwned: z9.boolean(),
|
|
1664
|
+
closedAt: z9.date().optional(),
|
|
1544
1665
|
commitComposition: githubPullRequestCommitCompositionSchema.optional(),
|
|
1545
|
-
mergedAt:
|
|
1546
|
-
number:
|
|
1547
|
-
openedAt:
|
|
1548
|
-
pullRequestId:
|
|
1549
|
-
repositoryFullName:
|
|
1550
|
-
repositoryId:
|
|
1666
|
+
mergedAt: z9.date().optional(),
|
|
1667
|
+
number: z9.number().int().positive(),
|
|
1668
|
+
openedAt: z9.date(),
|
|
1669
|
+
pullRequestId: z9.string().min(1),
|
|
1670
|
+
repositoryFullName: z9.string().min(1),
|
|
1671
|
+
repositoryId: z9.string().min(1),
|
|
1551
1672
|
state: githubPullRequestStateSchema,
|
|
1552
|
-
updatedAt:
|
|
1673
|
+
updatedAt: z9.date()
|
|
1553
1674
|
}).strict();
|
|
1554
|
-
var githubPullRequestConversationsInputSchema =
|
|
1555
|
-
conversationIds:
|
|
1556
|
-
pullRequestId:
|
|
1675
|
+
var githubPullRequestConversationsInputSchema = z9.object({
|
|
1676
|
+
conversationIds: z9.array(z9.string().min(1)).min(1),
|
|
1677
|
+
pullRequestId: z9.string().min(1)
|
|
1557
1678
|
}).strict();
|
|
1558
|
-
var githubPullRequestLinkedIssuesInputSchema =
|
|
1559
|
-
linkedIssues:
|
|
1560
|
-
|
|
1561
|
-
number:
|
|
1562
|
-
repositoryFullName:
|
|
1679
|
+
var githubPullRequestLinkedIssuesInputSchema = z9.object({
|
|
1680
|
+
linkedIssues: z9.array(
|
|
1681
|
+
z9.object({
|
|
1682
|
+
number: z9.number().int().positive(),
|
|
1683
|
+
repositoryFullName: z9.string().min(1)
|
|
1563
1684
|
}).strict()
|
|
1564
1685
|
).min(1),
|
|
1565
|
-
pullRequestId:
|
|
1686
|
+
pullRequestId: z9.string().min(1)
|
|
1566
1687
|
}).strict();
|
|
1567
1688
|
function projectionValues2(input) {
|
|
1568
1689
|
return {
|
|
@@ -1652,7 +1773,7 @@ async function recordGitHubPullRequestLinkedIssues(db, input) {
|
|
|
1652
1773
|
}
|
|
1653
1774
|
|
|
1654
1775
|
// src/webhooks/issue-outcome.ts
|
|
1655
|
-
import { z as
|
|
1776
|
+
import { z as z10 } from "zod";
|
|
1656
1777
|
|
|
1657
1778
|
// src/webhooks/ownership.ts
|
|
1658
1779
|
var GITHUB_NOREPLY_DOMAIN = "users.noreply.github.com";
|
|
@@ -1669,38 +1790,38 @@ function botLoginFromEmail(value) {
|
|
|
1669
1790
|
}
|
|
1670
1791
|
|
|
1671
1792
|
// src/webhooks/issue-outcome.ts
|
|
1672
|
-
var canonicalIssueOutcomeSchema =
|
|
1673
|
-
action:
|
|
1674
|
-
issue:
|
|
1675
|
-
body:
|
|
1676
|
-
closed_at:
|
|
1677
|
-
created_at:
|
|
1678
|
-
id:
|
|
1679
|
-
number:
|
|
1793
|
+
var canonicalIssueOutcomeSchema = z10.object({
|
|
1794
|
+
action: z10.enum(["opened", "closed", "reopened"]),
|
|
1795
|
+
issue: z10.object({
|
|
1796
|
+
body: z10.string().nullable().optional(),
|
|
1797
|
+
closed_at: z10.string().nullable().optional(),
|
|
1798
|
+
created_at: z10.string(),
|
|
1799
|
+
id: z10.number().int().positive(),
|
|
1800
|
+
number: z10.number().int().positive(),
|
|
1680
1801
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
1681
|
-
updated_at:
|
|
1682
|
-
user:
|
|
1802
|
+
updated_at: z10.string(),
|
|
1803
|
+
user: z10.object({ login: z10.string().min(1) }).strict()
|
|
1683
1804
|
}).strict(),
|
|
1684
|
-
repository:
|
|
1685
|
-
full_name:
|
|
1686
|
-
id:
|
|
1805
|
+
repository: z10.object({
|
|
1806
|
+
full_name: z10.string().min(1),
|
|
1807
|
+
id: z10.number().int().positive()
|
|
1687
1808
|
}).strict()
|
|
1688
1809
|
}).strict();
|
|
1689
|
-
var issueOutcomeSchema =
|
|
1690
|
-
action:
|
|
1691
|
-
issue:
|
|
1692
|
-
body:
|
|
1693
|
-
closed_at:
|
|
1694
|
-
created_at:
|
|
1695
|
-
id:
|
|
1696
|
-
number:
|
|
1810
|
+
var issueOutcomeSchema = z10.object({
|
|
1811
|
+
action: z10.enum(["opened", "closed", "reopened"]),
|
|
1812
|
+
issue: z10.object({
|
|
1813
|
+
body: z10.string().nullable().optional(),
|
|
1814
|
+
closed_at: z10.string().nullable().optional(),
|
|
1815
|
+
created_at: z10.string(),
|
|
1816
|
+
id: z10.number().int().positive(),
|
|
1817
|
+
number: z10.number().int().positive(),
|
|
1697
1818
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
1698
|
-
updated_at:
|
|
1699
|
-
user:
|
|
1819
|
+
updated_at: z10.string(),
|
|
1820
|
+
user: z10.object({ login: z10.string().min(1) }).passthrough()
|
|
1700
1821
|
}).passthrough(),
|
|
1701
|
-
repository:
|
|
1702
|
-
full_name:
|
|
1703
|
-
id:
|
|
1822
|
+
repository: z10.object({
|
|
1823
|
+
full_name: z10.string().min(1),
|
|
1824
|
+
id: z10.number().int().positive()
|
|
1704
1825
|
}).passthrough()
|
|
1705
1826
|
}).passthrough().transform(
|
|
1706
1827
|
(provider) => canonicalIssueOutcomeSchema.parse({
|
|
@@ -1721,7 +1842,7 @@ var issueOutcomeSchema = z9.object({
|
|
|
1721
1842
|
}
|
|
1722
1843
|
})
|
|
1723
1844
|
);
|
|
1724
|
-
var issueLifecycleActionSchema =
|
|
1845
|
+
var issueLifecycleActionSchema = z10.object({ action: z10.string() }).passthrough();
|
|
1725
1846
|
function timestamp2(value) {
|
|
1726
1847
|
if (!value) return void 0;
|
|
1727
1848
|
const parsed = new Date(value);
|
|
@@ -1767,21 +1888,21 @@ function normalizeGitHubIssueOutcome(args) {
|
|
|
1767
1888
|
updatedAt
|
|
1768
1889
|
};
|
|
1769
1890
|
}
|
|
1770
|
-
var canonicalIssueConversationSchema =
|
|
1771
|
-
issue:
|
|
1772
|
-
body:
|
|
1773
|
-
id:
|
|
1774
|
-
user:
|
|
1891
|
+
var canonicalIssueConversationSchema = z10.object({
|
|
1892
|
+
issue: z10.object({
|
|
1893
|
+
body: z10.string().nullable().optional(),
|
|
1894
|
+
id: z10.number().int().positive(),
|
|
1895
|
+
user: z10.object({ login: z10.string().min(1) }).strict()
|
|
1775
1896
|
}).strict(),
|
|
1776
|
-
sender:
|
|
1897
|
+
sender: z10.object({ login: z10.string().min(1) }).strict().optional()
|
|
1777
1898
|
}).strict();
|
|
1778
|
-
var issueConversationSchema =
|
|
1779
|
-
issue:
|
|
1780
|
-
body:
|
|
1781
|
-
id:
|
|
1782
|
-
user:
|
|
1899
|
+
var issueConversationSchema = z10.object({
|
|
1900
|
+
issue: z10.object({
|
|
1901
|
+
body: z10.string().nullable().optional(),
|
|
1902
|
+
id: z10.number().int().positive(),
|
|
1903
|
+
user: z10.object({ login: z10.string().min(1) }).passthrough()
|
|
1783
1904
|
}).passthrough(),
|
|
1784
|
-
sender:
|
|
1905
|
+
sender: z10.object({ login: z10.string().min(1) }).passthrough().optional()
|
|
1785
1906
|
}).passthrough().transform(
|
|
1786
1907
|
(provider) => canonicalIssueConversationSchema.parse({
|
|
1787
1908
|
issue: {
|
|
@@ -1808,41 +1929,41 @@ function normalizeGitHubIssueConversations(args) {
|
|
|
1808
1929
|
}
|
|
1809
1930
|
|
|
1810
1931
|
// src/webhooks/pull-request-outcome.ts
|
|
1811
|
-
import { z as
|
|
1812
|
-
var canonicalPullRequestOutcomeSchema =
|
|
1813
|
-
action:
|
|
1814
|
-
pull_request:
|
|
1815
|
-
body:
|
|
1816
|
-
closed_at:
|
|
1817
|
-
created_at:
|
|
1818
|
-
id:
|
|
1819
|
-
merged:
|
|
1820
|
-
merged_at:
|
|
1821
|
-
number:
|
|
1822
|
-
updated_at:
|
|
1823
|
-
user:
|
|
1932
|
+
import { z as z11 } from "zod";
|
|
1933
|
+
var canonicalPullRequestOutcomeSchema = z11.object({
|
|
1934
|
+
action: z11.enum(["opened", "closed", "reopened"]),
|
|
1935
|
+
pull_request: z11.object({
|
|
1936
|
+
body: z11.string().nullable().optional(),
|
|
1937
|
+
closed_at: z11.string().nullable().optional(),
|
|
1938
|
+
created_at: z11.string(),
|
|
1939
|
+
id: z11.number().int().positive(),
|
|
1940
|
+
merged: z11.boolean(),
|
|
1941
|
+
merged_at: z11.string().nullable().optional(),
|
|
1942
|
+
number: z11.number().int().positive(),
|
|
1943
|
+
updated_at: z11.string(),
|
|
1944
|
+
user: z11.object({ login: z11.string().min(1) }).strict()
|
|
1824
1945
|
}).strict(),
|
|
1825
|
-
repository:
|
|
1826
|
-
full_name:
|
|
1827
|
-
id:
|
|
1946
|
+
repository: z11.object({
|
|
1947
|
+
full_name: z11.string().min(1),
|
|
1948
|
+
id: z11.number().int().positive()
|
|
1828
1949
|
}).strict()
|
|
1829
1950
|
}).strict();
|
|
1830
|
-
var pullRequestOutcomeSchema =
|
|
1831
|
-
action:
|
|
1832
|
-
pull_request:
|
|
1833
|
-
body:
|
|
1834
|
-
closed_at:
|
|
1835
|
-
created_at:
|
|
1836
|
-
id:
|
|
1837
|
-
merged:
|
|
1838
|
-
merged_at:
|
|
1839
|
-
number:
|
|
1840
|
-
updated_at:
|
|
1841
|
-
user:
|
|
1951
|
+
var pullRequestOutcomeSchema = z11.object({
|
|
1952
|
+
action: z11.enum(["opened", "closed", "reopened"]),
|
|
1953
|
+
pull_request: z11.object({
|
|
1954
|
+
body: z11.string().nullable().optional(),
|
|
1955
|
+
closed_at: z11.string().nullable().optional(),
|
|
1956
|
+
created_at: z11.string(),
|
|
1957
|
+
id: z11.number().int().positive(),
|
|
1958
|
+
merged: z11.boolean(),
|
|
1959
|
+
merged_at: z11.string().nullable().optional(),
|
|
1960
|
+
number: z11.number().int().positive(),
|
|
1961
|
+
updated_at: z11.string(),
|
|
1962
|
+
user: z11.object({ login: z11.string().min(1) }).passthrough()
|
|
1842
1963
|
}).passthrough(),
|
|
1843
|
-
repository:
|
|
1844
|
-
full_name:
|
|
1845
|
-
id:
|
|
1964
|
+
repository: z11.object({
|
|
1965
|
+
full_name: z11.string().min(1),
|
|
1966
|
+
id: z11.number().int().positive()
|
|
1846
1967
|
}).passthrough()
|
|
1847
1968
|
}).passthrough().transform(
|
|
1848
1969
|
(provider) => canonicalPullRequestOutcomeSchema.parse({
|
|
@@ -1864,24 +1985,24 @@ var pullRequestOutcomeSchema = z10.object({
|
|
|
1864
1985
|
}
|
|
1865
1986
|
})
|
|
1866
1987
|
);
|
|
1867
|
-
var pullRequestLifecycleActionSchema =
|
|
1868
|
-
var canonicalPullRequestConversationSchema =
|
|
1869
|
-
pull_request:
|
|
1870
|
-
body:
|
|
1871
|
-
id:
|
|
1872
|
-
user:
|
|
1988
|
+
var pullRequestLifecycleActionSchema = z11.object({ action: z11.string() }).passthrough();
|
|
1989
|
+
var canonicalPullRequestConversationSchema = z11.object({
|
|
1990
|
+
pull_request: z11.object({
|
|
1991
|
+
body: z11.string().nullable().optional(),
|
|
1992
|
+
id: z11.number().int().positive(),
|
|
1993
|
+
user: z11.object({ login: z11.string().min(1) }).strict()
|
|
1873
1994
|
}).strict(),
|
|
1874
|
-
repository:
|
|
1875
|
-
sender:
|
|
1995
|
+
repository: z11.object({ full_name: z11.string().min(1) }).strict(),
|
|
1996
|
+
sender: z11.object({ login: z11.string().min(1) }).strict()
|
|
1876
1997
|
}).strict();
|
|
1877
|
-
var pullRequestConversationSchema =
|
|
1878
|
-
pull_request:
|
|
1879
|
-
body:
|
|
1880
|
-
id:
|
|
1881
|
-
user:
|
|
1998
|
+
var pullRequestConversationSchema = z11.object({
|
|
1999
|
+
pull_request: z11.object({
|
|
2000
|
+
body: z11.string().nullable().optional(),
|
|
2001
|
+
id: z11.number().int().positive(),
|
|
2002
|
+
user: z11.object({ login: z11.string().min(1) }).passthrough()
|
|
1882
2003
|
}).passthrough(),
|
|
1883
|
-
repository:
|
|
1884
|
-
sender:
|
|
2004
|
+
repository: z11.object({ full_name: z11.string().min(1) }).passthrough(),
|
|
2005
|
+
sender: z11.object({ login: z11.string().min(1) }).passthrough()
|
|
1885
2006
|
}).passthrough().transform(
|
|
1886
2007
|
(provider) => canonicalPullRequestConversationSchema.parse({
|
|
1887
2008
|
pull_request: {
|
|
@@ -2066,18 +2187,18 @@ function createGitHubWebhookRoute(args) {
|
|
|
2066
2187
|
|
|
2067
2188
|
// src/outcomes/report.ts
|
|
2068
2189
|
import { sql as sql5 } from "drizzle-orm";
|
|
2069
|
-
import { z as
|
|
2190
|
+
import { z as z13 } from "zod";
|
|
2070
2191
|
|
|
2071
2192
|
// src/outcomes/cost.ts
|
|
2072
2193
|
import { sql as sql4 } from "drizzle-orm";
|
|
2073
|
-
import { z as
|
|
2194
|
+
import { z as z12 } from "zod";
|
|
2074
2195
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
2075
|
-
var costWindowSchema =
|
|
2076
|
-
days:
|
|
2077
|
-
issueCostUsd:
|
|
2078
|
-
medianIssueCostUsd:
|
|
2079
|
-
medianPullRequestCostUsd:
|
|
2080
|
-
pullRequestCostUsd:
|
|
2196
|
+
var costWindowSchema = z12.object({
|
|
2197
|
+
days: z12.number().int().positive(),
|
|
2198
|
+
issueCostUsd: z12.number().nonnegative().nullable(),
|
|
2199
|
+
medianIssueCostUsd: z12.number().nonnegative().nullable(),
|
|
2200
|
+
medianPullRequestCostUsd: z12.number().nonnegative().nullable(),
|
|
2201
|
+
pullRequestCostUsd: z12.number().nonnegative().nullable()
|
|
2081
2202
|
}).strict().transform((row) => ({
|
|
2082
2203
|
days: row.days,
|
|
2083
2204
|
issueCostUsd: row.issueCostUsd ?? void 0,
|
|
@@ -2085,12 +2206,12 @@ var costWindowSchema = z11.object({
|
|
|
2085
2206
|
medianPullRequestCostUsd: row.medianPullRequestCostUsd ?? void 0,
|
|
2086
2207
|
pullRequestCostUsd: row.pullRequestCostUsd ?? void 0
|
|
2087
2208
|
}));
|
|
2088
|
-
var repositoryCostSchema =
|
|
2089
|
-
issueCostUsd:
|
|
2090
|
-
medianIssueCostUsd:
|
|
2091
|
-
medianPullRequestCostUsd:
|
|
2092
|
-
pullRequestCostUsd:
|
|
2093
|
-
repository:
|
|
2209
|
+
var repositoryCostSchema = z12.object({
|
|
2210
|
+
issueCostUsd: z12.number().nonnegative().nullable(),
|
|
2211
|
+
medianIssueCostUsd: z12.number().nonnegative().nullable(),
|
|
2212
|
+
medianPullRequestCostUsd: z12.number().nonnegative().nullable(),
|
|
2213
|
+
pullRequestCostUsd: z12.number().nonnegative().nullable(),
|
|
2214
|
+
repository: z12.string().min(1)
|
|
2094
2215
|
}).strict().transform((row) => ({
|
|
2095
2216
|
issueCostUsd: row.issueCostUsd ?? void 0,
|
|
2096
2217
|
medianIssueCostUsd: row.medianIssueCostUsd ?? void 0,
|
|
@@ -2295,7 +2416,7 @@ async function aggregateGitHubCostWindows(args) {
|
|
|
2295
2416
|
INNER JOIN issue_window ON issue_window.days = pull_request_window.days
|
|
2296
2417
|
ORDER BY pull_request_window.days
|
|
2297
2418
|
`);
|
|
2298
|
-
return
|
|
2419
|
+
return z12.array(costWindowSchema).parse(queryRows(result));
|
|
2299
2420
|
}
|
|
2300
2421
|
async function aggregateGitHubRepositoryCosts(args) {
|
|
2301
2422
|
if (!await hasConversationUsageTable(args.db)) {
|
|
@@ -2393,7 +2514,7 @@ async function aggregateGitHubRepositoryCosts(args) {
|
|
|
2393
2514
|
ON issue_totals.repository = repositories.repository
|
|
2394
2515
|
ORDER BY "repository" ASC
|
|
2395
2516
|
`);
|
|
2396
|
-
return
|
|
2517
|
+
return z12.array(repositoryCostSchema).parse(queryRows(result));
|
|
2397
2518
|
}
|
|
2398
2519
|
function formatCostUsd(value) {
|
|
2399
2520
|
if (value === void 0) return "\u2014";
|
|
@@ -2408,12 +2529,12 @@ function formatCostUsd(value) {
|
|
|
2408
2529
|
// src/outcomes/report.ts
|
|
2409
2530
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
2410
2531
|
var WINDOWS = [7, 30, 90];
|
|
2411
|
-
var pullRequestStatsSchema =
|
|
2412
|
-
closed:
|
|
2413
|
-
created:
|
|
2414
|
-
days:
|
|
2415
|
-
medianMergeTimeMs:
|
|
2416
|
-
merged:
|
|
2532
|
+
var pullRequestStatsSchema = z13.object({
|
|
2533
|
+
closed: z13.number().int().nonnegative(),
|
|
2534
|
+
created: z13.number().int().nonnegative(),
|
|
2535
|
+
days: z13.number().int().positive(),
|
|
2536
|
+
medianMergeTimeMs: z13.number().nonnegative().nullable(),
|
|
2537
|
+
merged: z13.number().int().nonnegative()
|
|
2417
2538
|
}).strict().transform((row) => {
|
|
2418
2539
|
const terminal = row.merged + row.closed;
|
|
2419
2540
|
return {
|
|
@@ -2422,12 +2543,12 @@ var pullRequestStatsSchema = z12.object({
|
|
|
2422
2543
|
mergeRate: terminal > 0 ? row.merged / terminal : void 0
|
|
2423
2544
|
};
|
|
2424
2545
|
});
|
|
2425
|
-
var pullRequestRepositoryStatsSchema =
|
|
2426
|
-
closed:
|
|
2427
|
-
created:
|
|
2428
|
-
juniorOnly:
|
|
2429
|
-
merged:
|
|
2430
|
-
repository:
|
|
2546
|
+
var pullRequestRepositoryStatsSchema = z13.object({
|
|
2547
|
+
closed: z13.number().int().nonnegative(),
|
|
2548
|
+
created: z13.number().int().nonnegative(),
|
|
2549
|
+
juniorOnly: z13.number().int().nonnegative(),
|
|
2550
|
+
merged: z13.number().int().nonnegative(),
|
|
2551
|
+
repository: z13.string().min(1)
|
|
2431
2552
|
}).strict().transform((row) => {
|
|
2432
2553
|
const terminal = row.merged + row.closed;
|
|
2433
2554
|
return {
|
|
@@ -2435,33 +2556,33 @@ var pullRequestRepositoryStatsSchema = z12.object({
|
|
|
2435
2556
|
mergeRate: terminal > 0 ? row.merged / terminal : void 0
|
|
2436
2557
|
};
|
|
2437
2558
|
});
|
|
2438
|
-
var issueStatsSchema =
|
|
2439
|
-
closedCompleted:
|
|
2440
|
-
closedDuplicate:
|
|
2441
|
-
closedNotPlanned:
|
|
2442
|
-
closedUnknown:
|
|
2443
|
-
created:
|
|
2444
|
-
days:
|
|
2445
|
-
medianCloseTimeMs:
|
|
2559
|
+
var issueStatsSchema = z13.object({
|
|
2560
|
+
closedCompleted: z13.number().int().nonnegative(),
|
|
2561
|
+
closedDuplicate: z13.number().int().nonnegative(),
|
|
2562
|
+
closedNotPlanned: z13.number().int().nonnegative(),
|
|
2563
|
+
closedUnknown: z13.number().int().nonnegative(),
|
|
2564
|
+
created: z13.number().int().nonnegative(),
|
|
2565
|
+
days: z13.number().int().positive(),
|
|
2566
|
+
medianCloseTimeMs: z13.number().nonnegative().nullable()
|
|
2446
2567
|
}).strict().transform((row) => ({
|
|
2447
2568
|
...row,
|
|
2448
2569
|
medianCloseTimeMs: row.medianCloseTimeMs ?? void 0
|
|
2449
2570
|
}));
|
|
2450
|
-
var pullRequestDaySchema =
|
|
2451
|
-
created:
|
|
2452
|
-
date:
|
|
2571
|
+
var pullRequestDaySchema = z13.object({
|
|
2572
|
+
created: z13.number().int().nonnegative(),
|
|
2573
|
+
date: z13.string().date()
|
|
2453
2574
|
}).strict();
|
|
2454
|
-
var issueDaySchema =
|
|
2455
|
-
created:
|
|
2456
|
-
date:
|
|
2575
|
+
var issueDaySchema = z13.object({
|
|
2576
|
+
created: z13.number().int().nonnegative(),
|
|
2577
|
+
date: z13.string().date()
|
|
2457
2578
|
}).strict();
|
|
2458
|
-
var issueRepositoryStatsSchema =
|
|
2459
|
-
closedCompleted:
|
|
2460
|
-
closedDuplicate:
|
|
2461
|
-
closedNotPlanned:
|
|
2462
|
-
closedUnknown:
|
|
2463
|
-
created:
|
|
2464
|
-
repository:
|
|
2579
|
+
var issueRepositoryStatsSchema = z13.object({
|
|
2580
|
+
closedCompleted: z13.number().int().nonnegative(),
|
|
2581
|
+
closedDuplicate: z13.number().int().nonnegative(),
|
|
2582
|
+
closedNotPlanned: z13.number().int().nonnegative(),
|
|
2583
|
+
closedUnknown: z13.number().int().nonnegative(),
|
|
2584
|
+
created: z13.number().int().nonnegative(),
|
|
2585
|
+
repository: z13.string().min(1)
|
|
2465
2586
|
}).strict();
|
|
2466
2587
|
function queryRows2(result) {
|
|
2467
2588
|
if (typeof result !== "object" || result === null || !("rows" in result) || !Array.isArray(result.rows)) {
|
|
@@ -2525,7 +2646,7 @@ async function aggregatePullRequestWindows(args) {
|
|
|
2525
2646
|
GROUP BY windows.days
|
|
2526
2647
|
ORDER BY windows.days
|
|
2527
2648
|
`);
|
|
2528
|
-
return
|
|
2649
|
+
return z13.array(pullRequestStatsSchema).parse(queryRows2(result));
|
|
2529
2650
|
}
|
|
2530
2651
|
async function aggregatePullRequestDays(args) {
|
|
2531
2652
|
const end = new Date(args.nowMs);
|
|
@@ -2553,7 +2674,7 @@ async function aggregatePullRequestDays(args) {
|
|
|
2553
2674
|
LEFT JOIN daily ON daily.day = days.day
|
|
2554
2675
|
ORDER BY days.day
|
|
2555
2676
|
`);
|
|
2556
|
-
return
|
|
2677
|
+
return z13.array(pullRequestDaySchema).parse(queryRows2(result));
|
|
2557
2678
|
}
|
|
2558
2679
|
async function aggregatePullRequestRepositories(args) {
|
|
2559
2680
|
const start = new Date(args.nowMs - 30 * DAY_MS2);
|
|
@@ -2583,7 +2704,7 @@ async function aggregatePullRequestRepositories(args) {
|
|
|
2583
2704
|
ORDER BY "merged" DESC, "created" DESC, "repository" ASC
|
|
2584
2705
|
LIMIT 25
|
|
2585
2706
|
`);
|
|
2586
|
-
return
|
|
2707
|
+
return z13.array(pullRequestRepositoryStatsSchema).parse(queryRows2(result));
|
|
2587
2708
|
}
|
|
2588
2709
|
async function aggregateIssueWindows(args) {
|
|
2589
2710
|
const starts = WINDOWS.map(
|
|
@@ -2652,7 +2773,7 @@ async function aggregateIssueWindows(args) {
|
|
|
2652
2773
|
GROUP BY windows.days
|
|
2653
2774
|
ORDER BY windows.days
|
|
2654
2775
|
`);
|
|
2655
|
-
return
|
|
2776
|
+
return z13.array(issueStatsSchema).parse(queryRows2(result));
|
|
2656
2777
|
}
|
|
2657
2778
|
async function aggregateIssueDays(args) {
|
|
2658
2779
|
const end = new Date(args.nowMs);
|
|
@@ -2680,7 +2801,7 @@ async function aggregateIssueDays(args) {
|
|
|
2680
2801
|
LEFT JOIN daily ON daily.day = days.day
|
|
2681
2802
|
ORDER BY days.day
|
|
2682
2803
|
`);
|
|
2683
|
-
return
|
|
2804
|
+
return z13.array(issueDaySchema).parse(queryRows2(result));
|
|
2684
2805
|
}
|
|
2685
2806
|
async function aggregateIssueRepositories(args) {
|
|
2686
2807
|
const start = new Date(args.nowMs - 30 * DAY_MS2);
|
|
@@ -2717,7 +2838,7 @@ async function aggregateIssueRepositories(args) {
|
|
|
2717
2838
|
ORDER BY "created" DESC, "closedCompleted" DESC, "repository" ASC
|
|
2718
2839
|
LIMIT 25
|
|
2719
2840
|
`);
|
|
2720
|
-
return
|
|
2841
|
+
return z13.array(issueRepositoryStatsSchema).parse(queryRows2(result));
|
|
2721
2842
|
}
|
|
2722
2843
|
function formatPercent(value) {
|
|
2723
2844
|
return value === void 0 ? "\u2014" : `${Math.round(value * 100)}%`;
|
|
@@ -2881,18 +3002,18 @@ async function buildGitHubOutcomeReport(args) {
|
|
|
2881
3002
|
}
|
|
2882
3003
|
|
|
2883
3004
|
// src/pull-request-outcomes/commit-composition.ts
|
|
2884
|
-
import { z as
|
|
2885
|
-
var canonicalCommitSchema =
|
|
2886
|
-
authorEmail:
|
|
2887
|
-
authorLogin:
|
|
3005
|
+
import { z as z14 } from "zod";
|
|
3006
|
+
var canonicalCommitSchema = z14.object({
|
|
3007
|
+
authorEmail: z14.string().nullable(),
|
|
3008
|
+
authorLogin: z14.string().nullable()
|
|
2888
3009
|
}).strict();
|
|
2889
|
-
var providerCommitSchema =
|
|
2890
|
-
author:
|
|
2891
|
-
commit:
|
|
2892
|
-
author:
|
|
3010
|
+
var providerCommitSchema = z14.object({
|
|
3011
|
+
author: z14.object({ login: z14.string() }).passthrough().nullable(),
|
|
3012
|
+
commit: z14.object({
|
|
3013
|
+
author: z14.object({ email: z14.string() }).passthrough().nullable()
|
|
2893
3014
|
}).passthrough()
|
|
2894
3015
|
}).passthrough();
|
|
2895
|
-
var commitPageSchema =
|
|
3016
|
+
var commitPageSchema = z14.array(providerCommitSchema).transform(
|
|
2896
3017
|
(commits) => commits.map(
|
|
2897
3018
|
(commit) => canonicalCommitSchema.parse({
|
|
2898
3019
|
authorEmail: commit.commit.author?.email ?? null,
|
|
@@ -4090,6 +4211,32 @@ function githubPlugin(options = {}) {
|
|
|
4090
4211
|
const userScope = userScopes.length ? userScopes.join(" ") : void 0;
|
|
4091
4212
|
return defineJuniorPlugin({
|
|
4092
4213
|
packageName: "@sentry/junior-github",
|
|
4214
|
+
resourceEvents: {
|
|
4215
|
+
resourceTypes: [
|
|
4216
|
+
{
|
|
4217
|
+
type: "deployment_source",
|
|
4218
|
+
supportedEvents: [...GITHUB_DEPLOYMENT_EVENTS],
|
|
4219
|
+
suggestedEvents: [...GITHUB_DEPLOYMENT_SUGGESTED_EVENTS]
|
|
4220
|
+
},
|
|
4221
|
+
{
|
|
4222
|
+
type: "issue",
|
|
4223
|
+
supportedEvents: [...GITHUB_ISSUE_EVENTS],
|
|
4224
|
+
suggestedEvents: [...GITHUB_ISSUE_SUGGESTED_EVENTS]
|
|
4225
|
+
},
|
|
4226
|
+
{
|
|
4227
|
+
type: "pull_request",
|
|
4228
|
+
supportedEvents: [...GITHUB_PULL_REQUEST_EVENTS],
|
|
4229
|
+
suggestedEvents: [...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS]
|
|
4230
|
+
},
|
|
4231
|
+
{
|
|
4232
|
+
type: "repository",
|
|
4233
|
+
supportedEvents: [...GITHUB_ISSUE_EVENTS],
|
|
4234
|
+
suggestedEvents: ["issue.opened", ...GITHUB_ISSUE_SUGGESTED_EVENTS]
|
|
4235
|
+
}
|
|
4236
|
+
],
|
|
4237
|
+
isEnabled: () => Boolean(readEnv("GITHUB_WEBHOOK_SECRET")),
|
|
4238
|
+
normalizeIdentifier: (identifier) => identifier.toLowerCase()
|
|
4239
|
+
},
|
|
4093
4240
|
manifest: {
|
|
4094
4241
|
name: "github",
|
|
4095
4242
|
displayName: "GitHub",
|