@sentry/junior-github 0.129.0 → 0.130.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/README.md +5 -5
- package/SETUP.md +9 -2
- package/dist/{chunk-25NTEYYB.js → chunk-6XR7J3LQ.js} +161 -59
- package/dist/index.js +428 -257
- package/dist/resource-events/release.d.ts +13 -0
- package/dist/testing.js +1 -1
- package/dist/tools/get-release.d.ts +62 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5,12 +5,15 @@ import {
|
|
|
5
5
|
GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
6
6
|
GITHUB_PULL_REQUEST_EVENTS,
|
|
7
7
|
GITHUB_PULL_REQUEST_SUGGESTED_EVENTS,
|
|
8
|
+
GITHUB_RELEASE_EVENTS,
|
|
9
|
+
GITHUB_RELEASE_SUGGESTED_EVENTS,
|
|
8
10
|
gitHubDeploymentSourceSubscribable,
|
|
9
11
|
gitHubIssueSubscribable,
|
|
10
12
|
gitHubPullRequestSubscribable,
|
|
13
|
+
gitHubReleaseSourceSubscribable,
|
|
11
14
|
gitHubRepositorySubscribable,
|
|
12
15
|
normalizeGitHubResourceEvents
|
|
13
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6XR7J3LQ.js";
|
|
14
17
|
|
|
15
18
|
// src/plugin.ts
|
|
16
19
|
import {
|
|
@@ -1207,7 +1210,7 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
1207
1210
|
});
|
|
1208
1211
|
}
|
|
1209
1212
|
|
|
1210
|
-
// src/tools/get-
|
|
1213
|
+
// src/tools/get-release.ts
|
|
1211
1214
|
import {
|
|
1212
1215
|
definePluginTool as definePluginTool5,
|
|
1213
1216
|
PluginToolInputError as PluginToolInputError6,
|
|
@@ -1216,26 +1219,49 @@ import {
|
|
|
1216
1219
|
} from "@sentry/junior-plugin-api";
|
|
1217
1220
|
import { z as z5 } from "zod";
|
|
1218
1221
|
var inputSchema3 = z5.object({
|
|
1219
|
-
repo: z5.string().describe('Repository in "owner/name" format.')
|
|
1222
|
+
repo: z5.string().describe('Repository in "owner/name" format.'),
|
|
1223
|
+
tag: z5.string().trim().min(1).describe(
|
|
1224
|
+
"Optional release tag name. Omit to inspect and watch every published release in the repository."
|
|
1225
|
+
).optional()
|
|
1220
1226
|
}).strict();
|
|
1221
|
-
var
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1227
|
+
var releaseSchema = z5.object({
|
|
1228
|
+
createdAt: z5.string(),
|
|
1229
|
+
draft: z5.boolean(),
|
|
1230
|
+
htmlUrl: z5.string(),
|
|
1231
|
+
id: z5.number(),
|
|
1232
|
+
name: z5.string().nullable(),
|
|
1233
|
+
prerelease: z5.boolean(),
|
|
1234
|
+
publishedAt: z5.string().nullable(),
|
|
1235
|
+
tagName: z5.string(),
|
|
1236
|
+
targetCommitish: z5.string()
|
|
1237
|
+
}).strict();
|
|
1238
|
+
var releaseSourceSchema = z5.object({
|
|
1239
|
+
release: releaseSchema.nullable(),
|
|
1240
|
+
repo: z5.string(),
|
|
1226
1241
|
subscribable: subscribableResourceSchema5.optional(),
|
|
1227
|
-
|
|
1228
|
-
});
|
|
1242
|
+
tag: z5.string().nullable()
|
|
1243
|
+
}).strict();
|
|
1229
1244
|
var outputSchema3 = pluginToolOutputSchema5.extend({
|
|
1230
|
-
target: z5.literal("
|
|
1231
|
-
...
|
|
1232
|
-
});
|
|
1245
|
+
target: z5.literal("getRelease"),
|
|
1246
|
+
...releaseSourceSchema.shape
|
|
1247
|
+
}).strict();
|
|
1248
|
+
var providerReleaseSchema = z5.object({
|
|
1249
|
+
created_at: z5.string(),
|
|
1250
|
+
draft: z5.boolean(),
|
|
1251
|
+
html_url: z5.string(),
|
|
1252
|
+
id: z5.number(),
|
|
1253
|
+
name: z5.string().nullable(),
|
|
1254
|
+
prerelease: z5.boolean(),
|
|
1255
|
+
published_at: z5.string().nullable(),
|
|
1256
|
+
tag_name: z5.string(),
|
|
1257
|
+
target_commitish: z5.string()
|
|
1258
|
+
}).passthrough();
|
|
1233
1259
|
function parseRepo5(value) {
|
|
1234
1260
|
const parts = value.split("/").map((part) => part.trim());
|
|
1235
1261
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
1236
1262
|
throw new PluginToolInputError6('repo must use "owner/name" format');
|
|
1237
1263
|
}
|
|
1238
|
-
return { owner: parts[0], name: parts[1] };
|
|
1264
|
+
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
1239
1265
|
}
|
|
1240
1266
|
async function readJson3(response) {
|
|
1241
1267
|
const text2 = await response.text();
|
|
@@ -1246,7 +1272,23 @@ async function readJson3(response) {
|
|
|
1246
1272
|
return text2;
|
|
1247
1273
|
}
|
|
1248
1274
|
}
|
|
1249
|
-
function
|
|
1275
|
+
function repositoryUrl2(repo, path) {
|
|
1276
|
+
return `https://api.github.com/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}/${path}`;
|
|
1277
|
+
}
|
|
1278
|
+
function mapRelease(providerRelease) {
|
|
1279
|
+
return {
|
|
1280
|
+
createdAt: providerRelease.created_at,
|
|
1281
|
+
draft: providerRelease.draft,
|
|
1282
|
+
htmlUrl: providerRelease.html_url,
|
|
1283
|
+
id: providerRelease.id,
|
|
1284
|
+
name: providerRelease.name,
|
|
1285
|
+
prerelease: providerRelease.prerelease,
|
|
1286
|
+
publishedAt: providerRelease.published_at,
|
|
1287
|
+
tagName: providerRelease.tag_name,
|
|
1288
|
+
targetCommitish: providerRelease.target_commitish
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
function createGitHubGetReleaseTool(ctx) {
|
|
1250
1292
|
return definePluginTool5({
|
|
1251
1293
|
annotations: {
|
|
1252
1294
|
destructiveHint: false,
|
|
@@ -1254,11 +1296,127 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
1254
1296
|
openWorldHint: true,
|
|
1255
1297
|
readOnlyHint: true
|
|
1256
1298
|
},
|
|
1257
|
-
description: "Get a GitHub repository.
|
|
1299
|
+
description: "Get a GitHub release for an exact repository, optionally limited to one tag. The result remains subscribable when no release exists yet, so use it before waiting for a published release. Omit the tag to watch every published release in the repository.",
|
|
1258
1300
|
inputSchema: inputSchema3,
|
|
1259
1301
|
outputSchema: outputSchema3,
|
|
1260
1302
|
async execute(input) {
|
|
1261
1303
|
const repo = parseRepo5(input.repo);
|
|
1304
|
+
const tag = input.tag?.trim() || void 0;
|
|
1305
|
+
let release = null;
|
|
1306
|
+
if (tag) {
|
|
1307
|
+
const response = await ctx.egress.fetch({
|
|
1308
|
+
provider: "github",
|
|
1309
|
+
operation: "github.release.get",
|
|
1310
|
+
request: new Request(
|
|
1311
|
+
repositoryUrl2(repo, `releases/tags/${encodeURIComponent(tag)}`),
|
|
1312
|
+
{
|
|
1313
|
+
headers: {
|
|
1314
|
+
Accept: "application/vnd.github+json",
|
|
1315
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
)
|
|
1319
|
+
});
|
|
1320
|
+
const body = await readJson3(response);
|
|
1321
|
+
if (response.ok) {
|
|
1322
|
+
release = mapRelease(providerReleaseSchema.parse(body));
|
|
1323
|
+
} else if (response.status !== 404) {
|
|
1324
|
+
throw new Error(
|
|
1325
|
+
`GitHub release lookup failed with HTTP ${response.status}`
|
|
1326
|
+
);
|
|
1327
|
+
}
|
|
1328
|
+
} else {
|
|
1329
|
+
const response = await ctx.egress.fetch({
|
|
1330
|
+
provider: "github",
|
|
1331
|
+
operation: "github.release.latest",
|
|
1332
|
+
request: new Request(repositoryUrl2(repo, "releases/latest"), {
|
|
1333
|
+
headers: {
|
|
1334
|
+
Accept: "application/vnd.github+json",
|
|
1335
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
1336
|
+
}
|
|
1337
|
+
})
|
|
1338
|
+
});
|
|
1339
|
+
const body = await readJson3(response);
|
|
1340
|
+
if (response.ok) {
|
|
1341
|
+
release = mapRelease(providerReleaseSchema.parse(body));
|
|
1342
|
+
} else if (response.status === 404) {
|
|
1343
|
+
release = null;
|
|
1344
|
+
} else {
|
|
1345
|
+
throw new Error(
|
|
1346
|
+
`GitHub release lookup failed with HTTP ${response.status}`
|
|
1347
|
+
);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
const subscribable = ctx.resourceEvents.canSubscribe ? gitHubReleaseSourceSubscribable({
|
|
1351
|
+
repo: repo.ref,
|
|
1352
|
+
tag
|
|
1353
|
+
}) : void 0;
|
|
1354
|
+
const data = {
|
|
1355
|
+
release,
|
|
1356
|
+
repo: repo.ref,
|
|
1357
|
+
tag: tag ?? null,
|
|
1358
|
+
...subscribable ? { subscribable } : {}
|
|
1359
|
+
};
|
|
1360
|
+
return {
|
|
1361
|
+
target: "getRelease",
|
|
1362
|
+
...data
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
// src/tools/get-repository.ts
|
|
1369
|
+
import {
|
|
1370
|
+
definePluginTool as definePluginTool6,
|
|
1371
|
+
PluginToolInputError as PluginToolInputError7,
|
|
1372
|
+
pluginToolOutputSchema as pluginToolOutputSchema6,
|
|
1373
|
+
subscribableResourceSchema as subscribableResourceSchema6
|
|
1374
|
+
} from "@sentry/junior-plugin-api";
|
|
1375
|
+
import { z as z6 } from "zod";
|
|
1376
|
+
var inputSchema4 = z6.object({
|
|
1377
|
+
repo: z6.string().describe('Repository in "owner/name" format.')
|
|
1378
|
+
}).strict();
|
|
1379
|
+
var repositorySchema = z6.object({
|
|
1380
|
+
defaultBranch: z6.string(),
|
|
1381
|
+
description: z6.string().nullable(),
|
|
1382
|
+
fullName: z6.string(),
|
|
1383
|
+
private: z6.boolean(),
|
|
1384
|
+
subscribable: subscribableResourceSchema6.optional(),
|
|
1385
|
+
url: z6.string()
|
|
1386
|
+
});
|
|
1387
|
+
var outputSchema4 = pluginToolOutputSchema6.extend({
|
|
1388
|
+
target: z6.literal("getRepository"),
|
|
1389
|
+
...repositorySchema.shape
|
|
1390
|
+
});
|
|
1391
|
+
function parseRepo6(value) {
|
|
1392
|
+
const parts = value.split("/").map((part) => part.trim());
|
|
1393
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
1394
|
+
throw new PluginToolInputError7('repo must use "owner/name" format');
|
|
1395
|
+
}
|
|
1396
|
+
return { owner: parts[0], name: parts[1] };
|
|
1397
|
+
}
|
|
1398
|
+
async function readJson4(response) {
|
|
1399
|
+
const text2 = await response.text();
|
|
1400
|
+
if (!text2) return void 0;
|
|
1401
|
+
try {
|
|
1402
|
+
return JSON.parse(text2);
|
|
1403
|
+
} catch {
|
|
1404
|
+
return text2;
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
function createGitHubGetRepositoryTool(ctx) {
|
|
1408
|
+
return definePluginTool6({
|
|
1409
|
+
annotations: {
|
|
1410
|
+
destructiveHint: false,
|
|
1411
|
+
idempotentHint: true,
|
|
1412
|
+
openWorldHint: true,
|
|
1413
|
+
readOnlyHint: true
|
|
1414
|
+
},
|
|
1415
|
+
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.",
|
|
1416
|
+
inputSchema: inputSchema4,
|
|
1417
|
+
outputSchema: outputSchema4,
|
|
1418
|
+
async execute(input) {
|
|
1419
|
+
const repo = parseRepo6(input.repo);
|
|
1262
1420
|
const response = await ctx.egress.fetch({
|
|
1263
1421
|
provider: "github",
|
|
1264
1422
|
operation: "github.repository.get",
|
|
@@ -1272,18 +1430,18 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
1272
1430
|
}
|
|
1273
1431
|
)
|
|
1274
1432
|
});
|
|
1275
|
-
const parsed = await
|
|
1433
|
+
const parsed = await readJson4(response);
|
|
1276
1434
|
if (!response.ok) {
|
|
1277
|
-
throw new
|
|
1435
|
+
throw new PluginToolInputError7(
|
|
1278
1436
|
`GitHub repository lookup failed with HTTP ${response.status}`
|
|
1279
1437
|
);
|
|
1280
1438
|
}
|
|
1281
|
-
const providerResult =
|
|
1282
|
-
default_branch:
|
|
1283
|
-
description:
|
|
1284
|
-
full_name:
|
|
1285
|
-
html_url:
|
|
1286
|
-
private:
|
|
1439
|
+
const providerResult = z6.object({
|
|
1440
|
+
default_branch: z6.string(),
|
|
1441
|
+
description: z6.string().nullable(),
|
|
1442
|
+
full_name: z6.string(),
|
|
1443
|
+
html_url: z6.string(),
|
|
1444
|
+
private: z6.boolean()
|
|
1287
1445
|
}).parse(parsed);
|
|
1288
1446
|
const subscribable = ctx.resourceEvents.canSubscribe ? gitHubRepositorySubscribable({
|
|
1289
1447
|
repo: providerResult.full_name
|
|
@@ -1306,53 +1464,53 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
1306
1464
|
|
|
1307
1465
|
// src/tools/update-pull-request.ts
|
|
1308
1466
|
import {
|
|
1309
|
-
definePluginTool as
|
|
1310
|
-
PluginToolInputError as
|
|
1311
|
-
pluginToolOutputSchema as
|
|
1467
|
+
definePluginTool as definePluginTool7,
|
|
1468
|
+
PluginToolInputError as PluginToolInputError8,
|
|
1469
|
+
pluginToolOutputSchema as pluginToolOutputSchema7
|
|
1312
1470
|
} from "@sentry/junior-plugin-api";
|
|
1313
|
-
import { z as
|
|
1314
|
-
import { subscribableResourceSchema as
|
|
1315
|
-
var
|
|
1316
|
-
repo:
|
|
1317
|
-
number:
|
|
1318
|
-
title:
|
|
1319
|
-
body:
|
|
1471
|
+
import { z as z7 } from "zod";
|
|
1472
|
+
import { subscribableResourceSchema as subscribableResourceSchema7 } from "@sentry/junior-plugin-api";
|
|
1473
|
+
var inputSchema5 = z7.object({
|
|
1474
|
+
repo: z7.string().describe('Repository in "owner/name" format.'),
|
|
1475
|
+
number: z7.number().int().positive().describe("Pull request number."),
|
|
1476
|
+
title: z7.string().trim().min(1).optional().describe("Replacement pull request title."),
|
|
1477
|
+
body: z7.string().optional().describe(
|
|
1320
1478
|
"Replacement pull request body. Junior appends requester attribution and the conversation footer."
|
|
1321
1479
|
),
|
|
1322
|
-
base:
|
|
1323
|
-
state:
|
|
1480
|
+
base: z7.string().trim().min(1).optional().describe("Replacement base branch."),
|
|
1481
|
+
state: z7.enum(["open", "closed"]).optional().describe("Replacement pull request state.")
|
|
1324
1482
|
}).strict().refine(
|
|
1325
1483
|
({ title, body, base, state }) => title !== void 0 || body !== void 0 || base !== void 0 || state !== void 0,
|
|
1326
1484
|
{ message: "At least one pull request field must be provided." }
|
|
1327
1485
|
);
|
|
1328
|
-
var pullRequestSchema2 =
|
|
1329
|
-
base:
|
|
1330
|
-
body:
|
|
1331
|
-
draft:
|
|
1332
|
-
number:
|
|
1333
|
-
state:
|
|
1334
|
-
subscribable:
|
|
1335
|
-
title:
|
|
1336
|
-
url:
|
|
1486
|
+
var pullRequestSchema2 = z7.object({
|
|
1487
|
+
base: z7.string(),
|
|
1488
|
+
body: z7.string().nullable(),
|
|
1489
|
+
draft: z7.boolean(),
|
|
1490
|
+
number: z7.number(),
|
|
1491
|
+
state: z7.string(),
|
|
1492
|
+
subscribable: subscribableResourceSchema7.optional(),
|
|
1493
|
+
title: z7.string(),
|
|
1494
|
+
url: z7.string()
|
|
1337
1495
|
});
|
|
1338
|
-
var
|
|
1339
|
-
target:
|
|
1496
|
+
var outputSchema5 = pluginToolOutputSchema7.extend({
|
|
1497
|
+
target: z7.literal("updatePullRequest"),
|
|
1340
1498
|
...pullRequestSchema2.shape
|
|
1341
1499
|
});
|
|
1342
1500
|
function nonEmptyString4(value, name) {
|
|
1343
1501
|
if (!value?.trim()) {
|
|
1344
|
-
throw new
|
|
1502
|
+
throw new PluginToolInputError8(`${name} is required`);
|
|
1345
1503
|
}
|
|
1346
1504
|
return value.trim();
|
|
1347
1505
|
}
|
|
1348
|
-
function
|
|
1506
|
+
function parseRepo7(value) {
|
|
1349
1507
|
const parts = value.split("/").map((part) => part.trim());
|
|
1350
1508
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
1351
|
-
throw new
|
|
1509
|
+
throw new PluginToolInputError8('repo must use "owner/name" format');
|
|
1352
1510
|
}
|
|
1353
1511
|
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
1354
1512
|
}
|
|
1355
|
-
async function
|
|
1513
|
+
async function readJson5(response) {
|
|
1356
1514
|
const text2 = await response.text();
|
|
1357
1515
|
if (!text2) return void 0;
|
|
1358
1516
|
try {
|
|
@@ -1370,7 +1528,7 @@ function githubApiErrorMessage3(payload) {
|
|
|
1370
1528
|
return "GitHub request failed";
|
|
1371
1529
|
}
|
|
1372
1530
|
function createGitHubUpdatePullRequestTool(ctx) {
|
|
1373
|
-
return
|
|
1531
|
+
return definePluginTool7({
|
|
1374
1532
|
annotations: {
|
|
1375
1533
|
destructiveHint: true,
|
|
1376
1534
|
idempotentHint: true,
|
|
@@ -1378,18 +1536,18 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
1378
1536
|
readOnlyHint: false
|
|
1379
1537
|
},
|
|
1380
1538
|
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.",
|
|
1381
|
-
inputSchema:
|
|
1382
|
-
outputSchema:
|
|
1539
|
+
inputSchema: inputSchema5,
|
|
1540
|
+
outputSchema: outputSchema5,
|
|
1383
1541
|
async execute(input) {
|
|
1384
|
-
const parsedInput =
|
|
1542
|
+
const parsedInput = inputSchema5.safeParse(input);
|
|
1385
1543
|
if (!parsedInput.success) {
|
|
1386
|
-
throw new
|
|
1544
|
+
throw new PluginToolInputError8(
|
|
1387
1545
|
"Invalid GitHub updatePullRequest input.",
|
|
1388
1546
|
{ cause: parsedInput.error }
|
|
1389
1547
|
);
|
|
1390
1548
|
}
|
|
1391
1549
|
const update = parsedInput.data;
|
|
1392
|
-
const repo =
|
|
1550
|
+
const repo = parseRepo7(update.repo);
|
|
1393
1551
|
const payload = {
|
|
1394
1552
|
...update.title !== void 0 ? { title: update.title } : {},
|
|
1395
1553
|
...update.body !== void 0 ? {
|
|
@@ -1418,20 +1576,20 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
1418
1576
|
}
|
|
1419
1577
|
)
|
|
1420
1578
|
});
|
|
1421
|
-
const parsed = await
|
|
1579
|
+
const parsed = await readJson5(response);
|
|
1422
1580
|
if (!response.ok) {
|
|
1423
1581
|
throw new Error(
|
|
1424
1582
|
`GitHub pull request update failed with HTTP ${response.status}: ${githubApiErrorMessage3(parsed)}`
|
|
1425
1583
|
);
|
|
1426
1584
|
}
|
|
1427
|
-
const providerResult =
|
|
1428
|
-
base:
|
|
1429
|
-
body:
|
|
1430
|
-
draft:
|
|
1431
|
-
html_url:
|
|
1432
|
-
number:
|
|
1433
|
-
state:
|
|
1434
|
-
title:
|
|
1585
|
+
const providerResult = z7.object({
|
|
1586
|
+
base: z7.object({ ref: z7.string() }),
|
|
1587
|
+
body: z7.string().nullable().optional().default(null),
|
|
1588
|
+
draft: z7.boolean(),
|
|
1589
|
+
html_url: z7.string(),
|
|
1590
|
+
number: z7.number(),
|
|
1591
|
+
state: z7.string(),
|
|
1592
|
+
title: z7.string()
|
|
1435
1593
|
}).parse(parsed);
|
|
1436
1594
|
const subscribable = ctx.resourceEvents.canSubscribe ? gitHubPullRequestSubscribable({
|
|
1437
1595
|
number: providerResult.number,
|
|
@@ -1462,6 +1620,7 @@ function createGitHubTools(ctx) {
|
|
|
1462
1620
|
createPullRequest: createGitHubPullRequestTool(ctx),
|
|
1463
1621
|
getDeployment: createGitHubGetDeploymentTool(ctx),
|
|
1464
1622
|
getPullRequest: createGitHubGetPullRequestTool(ctx),
|
|
1623
|
+
getRelease: createGitHubGetReleaseTool(ctx),
|
|
1465
1624
|
getRepository: createGitHubGetRepositoryTool(ctx),
|
|
1466
1625
|
updatePullRequest: createGitHubUpdatePullRequestTool(ctx)
|
|
1467
1626
|
};
|
|
@@ -1472,7 +1631,7 @@ import { createHmac, timingSafeEqual } from "crypto";
|
|
|
1472
1631
|
|
|
1473
1632
|
// src/issue-outcomes/store.ts
|
|
1474
1633
|
import { and, eq, lte, sql as sql2 } from "drizzle-orm";
|
|
1475
|
-
import { z as
|
|
1634
|
+
import { z as z9 } from "zod";
|
|
1476
1635
|
|
|
1477
1636
|
// src/db/schema.ts
|
|
1478
1637
|
import { sql } from "drizzle-orm";
|
|
@@ -1484,18 +1643,18 @@ import {
|
|
|
1484
1643
|
text,
|
|
1485
1644
|
timestamp
|
|
1486
1645
|
} from "drizzle-orm/pg-core";
|
|
1487
|
-
import { z as
|
|
1488
|
-
var githubPullRequestStateSchema =
|
|
1646
|
+
import { z as z8 } from "zod";
|
|
1647
|
+
var githubPullRequestStateSchema = z8.enum([
|
|
1489
1648
|
"closed_unmerged",
|
|
1490
1649
|
"merged",
|
|
1491
1650
|
"open"
|
|
1492
1651
|
]);
|
|
1493
|
-
var githubPullRequestCommitCompositionSchema =
|
|
1652
|
+
var githubPullRequestCommitCompositionSchema = z8.enum([
|
|
1494
1653
|
"junior_only",
|
|
1495
1654
|
"mixed"
|
|
1496
1655
|
]);
|
|
1497
|
-
var githubIssueStateSchema =
|
|
1498
|
-
var githubIssueStateReasonSchema =
|
|
1656
|
+
var githubIssueStateSchema = z8.enum(["closed", "open"]);
|
|
1657
|
+
var githubIssueStateReasonSchema = z8.enum([
|
|
1499
1658
|
"completed",
|
|
1500
1659
|
"duplicate",
|
|
1501
1660
|
"not_planned",
|
|
@@ -1564,21 +1723,21 @@ var juniorGitHubPullRequestIssues = pgTable(
|
|
|
1564
1723
|
);
|
|
1565
1724
|
|
|
1566
1725
|
// src/issue-outcomes/store.ts
|
|
1567
|
-
var githubIssueOutcomeInputSchema =
|
|
1568
|
-
candidateOwned:
|
|
1569
|
-
closedAt:
|
|
1570
|
-
issueId:
|
|
1571
|
-
number:
|
|
1572
|
-
openedAt:
|
|
1573
|
-
repositoryFullName:
|
|
1574
|
-
repositoryId:
|
|
1726
|
+
var githubIssueOutcomeInputSchema = z9.object({
|
|
1727
|
+
candidateOwned: z9.boolean(),
|
|
1728
|
+
closedAt: z9.date().optional(),
|
|
1729
|
+
issueId: z9.string().min(1),
|
|
1730
|
+
number: z9.number().int().positive(),
|
|
1731
|
+
openedAt: z9.date(),
|
|
1732
|
+
repositoryFullName: z9.string().min(1),
|
|
1733
|
+
repositoryId: z9.string().min(1),
|
|
1575
1734
|
state: githubIssueStateSchema,
|
|
1576
1735
|
stateReason: githubIssueStateReasonSchema.optional(),
|
|
1577
|
-
updatedAt:
|
|
1736
|
+
updatedAt: z9.date()
|
|
1578
1737
|
}).strict();
|
|
1579
|
-
var githubIssueConversationsInputSchema =
|
|
1580
|
-
conversationIds:
|
|
1581
|
-
issueId:
|
|
1738
|
+
var githubIssueConversationsInputSchema = z9.object({
|
|
1739
|
+
conversationIds: z9.array(z9.string().min(1)).min(1),
|
|
1740
|
+
issueId: z9.string().min(1)
|
|
1582
1741
|
}).strict();
|
|
1583
1742
|
function projectionValues(input) {
|
|
1584
1743
|
return {
|
|
@@ -1631,32 +1790,32 @@ async function recordGitHubIssueConversations(db, input) {
|
|
|
1631
1790
|
|
|
1632
1791
|
// src/pull-request-outcomes/store.ts
|
|
1633
1792
|
import { and as and2, eq as eq2, lte as lte2, sql as sql3 } from "drizzle-orm";
|
|
1634
|
-
import { z as
|
|
1635
|
-
var githubPullRequestOutcomeInputSchema =
|
|
1636
|
-
candidateOwned:
|
|
1637
|
-
closedAt:
|
|
1793
|
+
import { z as z10 } from "zod";
|
|
1794
|
+
var githubPullRequestOutcomeInputSchema = z10.object({
|
|
1795
|
+
candidateOwned: z10.boolean(),
|
|
1796
|
+
closedAt: z10.date().optional(),
|
|
1638
1797
|
commitComposition: githubPullRequestCommitCompositionSchema.optional(),
|
|
1639
|
-
mergedAt:
|
|
1640
|
-
number:
|
|
1641
|
-
openedAt:
|
|
1642
|
-
pullRequestId:
|
|
1643
|
-
repositoryFullName:
|
|
1644
|
-
repositoryId:
|
|
1798
|
+
mergedAt: z10.date().optional(),
|
|
1799
|
+
number: z10.number().int().positive(),
|
|
1800
|
+
openedAt: z10.date(),
|
|
1801
|
+
pullRequestId: z10.string().min(1),
|
|
1802
|
+
repositoryFullName: z10.string().min(1),
|
|
1803
|
+
repositoryId: z10.string().min(1),
|
|
1645
1804
|
state: githubPullRequestStateSchema,
|
|
1646
|
-
updatedAt:
|
|
1805
|
+
updatedAt: z10.date()
|
|
1647
1806
|
}).strict();
|
|
1648
|
-
var githubPullRequestConversationsInputSchema =
|
|
1649
|
-
conversationIds:
|
|
1650
|
-
pullRequestId:
|
|
1807
|
+
var githubPullRequestConversationsInputSchema = z10.object({
|
|
1808
|
+
conversationIds: z10.array(z10.string().min(1)).min(1),
|
|
1809
|
+
pullRequestId: z10.string().min(1)
|
|
1651
1810
|
}).strict();
|
|
1652
|
-
var githubPullRequestLinkedIssuesInputSchema =
|
|
1653
|
-
linkedIssues:
|
|
1654
|
-
|
|
1655
|
-
number:
|
|
1656
|
-
repositoryFullName:
|
|
1811
|
+
var githubPullRequestLinkedIssuesInputSchema = z10.object({
|
|
1812
|
+
linkedIssues: z10.array(
|
|
1813
|
+
z10.object({
|
|
1814
|
+
number: z10.number().int().positive(),
|
|
1815
|
+
repositoryFullName: z10.string().min(1)
|
|
1657
1816
|
}).strict()
|
|
1658
1817
|
).min(1),
|
|
1659
|
-
pullRequestId:
|
|
1818
|
+
pullRequestId: z10.string().min(1)
|
|
1660
1819
|
}).strict();
|
|
1661
1820
|
function projectionValues2(input) {
|
|
1662
1821
|
return {
|
|
@@ -1746,7 +1905,7 @@ async function recordGitHubPullRequestLinkedIssues(db, input) {
|
|
|
1746
1905
|
}
|
|
1747
1906
|
|
|
1748
1907
|
// src/webhooks/issue-outcome.ts
|
|
1749
|
-
import { z as
|
|
1908
|
+
import { z as z11 } from "zod";
|
|
1750
1909
|
|
|
1751
1910
|
// src/webhooks/ownership.ts
|
|
1752
1911
|
var GITHUB_NOREPLY_DOMAIN = "users.noreply.github.com";
|
|
@@ -1763,38 +1922,38 @@ function botLoginFromEmail(value) {
|
|
|
1763
1922
|
}
|
|
1764
1923
|
|
|
1765
1924
|
// src/webhooks/issue-outcome.ts
|
|
1766
|
-
var canonicalIssueOutcomeSchema =
|
|
1767
|
-
action:
|
|
1768
|
-
issue:
|
|
1769
|
-
body:
|
|
1770
|
-
closed_at:
|
|
1771
|
-
created_at:
|
|
1772
|
-
id:
|
|
1773
|
-
number:
|
|
1925
|
+
var canonicalIssueOutcomeSchema = z11.object({
|
|
1926
|
+
action: z11.enum(["opened", "closed", "reopened"]),
|
|
1927
|
+
issue: z11.object({
|
|
1928
|
+
body: z11.string().nullable().optional(),
|
|
1929
|
+
closed_at: z11.string().nullable().optional(),
|
|
1930
|
+
created_at: z11.string(),
|
|
1931
|
+
id: z11.number().int().positive(),
|
|
1932
|
+
number: z11.number().int().positive(),
|
|
1774
1933
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
1775
|
-
updated_at:
|
|
1776
|
-
user:
|
|
1934
|
+
updated_at: z11.string(),
|
|
1935
|
+
user: z11.object({ login: z11.string().min(1) }).strict()
|
|
1777
1936
|
}).strict(),
|
|
1778
|
-
repository:
|
|
1779
|
-
full_name:
|
|
1780
|
-
id:
|
|
1937
|
+
repository: z11.object({
|
|
1938
|
+
full_name: z11.string().min(1),
|
|
1939
|
+
id: z11.number().int().positive()
|
|
1781
1940
|
}).strict()
|
|
1782
1941
|
}).strict();
|
|
1783
|
-
var issueOutcomeSchema =
|
|
1784
|
-
action:
|
|
1785
|
-
issue:
|
|
1786
|
-
body:
|
|
1787
|
-
closed_at:
|
|
1788
|
-
created_at:
|
|
1789
|
-
id:
|
|
1790
|
-
number:
|
|
1942
|
+
var issueOutcomeSchema = z11.object({
|
|
1943
|
+
action: z11.enum(["opened", "closed", "reopened"]),
|
|
1944
|
+
issue: z11.object({
|
|
1945
|
+
body: z11.string().nullable().optional(),
|
|
1946
|
+
closed_at: z11.string().nullable().optional(),
|
|
1947
|
+
created_at: z11.string(),
|
|
1948
|
+
id: z11.number().int().positive(),
|
|
1949
|
+
number: z11.number().int().positive(),
|
|
1791
1950
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
1792
|
-
updated_at:
|
|
1793
|
-
user:
|
|
1951
|
+
updated_at: z11.string(),
|
|
1952
|
+
user: z11.object({ login: z11.string().min(1) }).passthrough()
|
|
1794
1953
|
}).passthrough(),
|
|
1795
|
-
repository:
|
|
1796
|
-
full_name:
|
|
1797
|
-
id:
|
|
1954
|
+
repository: z11.object({
|
|
1955
|
+
full_name: z11.string().min(1),
|
|
1956
|
+
id: z11.number().int().positive()
|
|
1798
1957
|
}).passthrough()
|
|
1799
1958
|
}).passthrough().transform(
|
|
1800
1959
|
(provider) => canonicalIssueOutcomeSchema.parse({
|
|
@@ -1815,7 +1974,7 @@ var issueOutcomeSchema = z10.object({
|
|
|
1815
1974
|
}
|
|
1816
1975
|
})
|
|
1817
1976
|
);
|
|
1818
|
-
var issueLifecycleActionSchema =
|
|
1977
|
+
var issueLifecycleActionSchema = z11.object({ action: z11.string() }).passthrough();
|
|
1819
1978
|
function timestamp2(value) {
|
|
1820
1979
|
if (!value) return void 0;
|
|
1821
1980
|
const parsed = new Date(value);
|
|
@@ -1861,21 +2020,21 @@ function normalizeGitHubIssueOutcome(args) {
|
|
|
1861
2020
|
updatedAt
|
|
1862
2021
|
};
|
|
1863
2022
|
}
|
|
1864
|
-
var canonicalIssueConversationSchema =
|
|
1865
|
-
issue:
|
|
1866
|
-
body:
|
|
1867
|
-
id:
|
|
1868
|
-
user:
|
|
2023
|
+
var canonicalIssueConversationSchema = z11.object({
|
|
2024
|
+
issue: z11.object({
|
|
2025
|
+
body: z11.string().nullable().optional(),
|
|
2026
|
+
id: z11.number().int().positive(),
|
|
2027
|
+
user: z11.object({ login: z11.string().min(1) }).strict()
|
|
1869
2028
|
}).strict(),
|
|
1870
|
-
sender:
|
|
2029
|
+
sender: z11.object({ login: z11.string().min(1) }).strict().optional()
|
|
1871
2030
|
}).strict();
|
|
1872
|
-
var issueConversationSchema =
|
|
1873
|
-
issue:
|
|
1874
|
-
body:
|
|
1875
|
-
id:
|
|
1876
|
-
user:
|
|
2031
|
+
var issueConversationSchema = z11.object({
|
|
2032
|
+
issue: z11.object({
|
|
2033
|
+
body: z11.string().nullable().optional(),
|
|
2034
|
+
id: z11.number().int().positive(),
|
|
2035
|
+
user: z11.object({ login: z11.string().min(1) }).passthrough()
|
|
1877
2036
|
}).passthrough(),
|
|
1878
|
-
sender:
|
|
2037
|
+
sender: z11.object({ login: z11.string().min(1) }).passthrough().optional()
|
|
1879
2038
|
}).passthrough().transform(
|
|
1880
2039
|
(provider) => canonicalIssueConversationSchema.parse({
|
|
1881
2040
|
issue: {
|
|
@@ -1902,41 +2061,41 @@ function normalizeGitHubIssueConversations(args) {
|
|
|
1902
2061
|
}
|
|
1903
2062
|
|
|
1904
2063
|
// src/webhooks/pull-request-outcome.ts
|
|
1905
|
-
import { z as
|
|
1906
|
-
var canonicalPullRequestOutcomeSchema =
|
|
1907
|
-
action:
|
|
1908
|
-
pull_request:
|
|
1909
|
-
body:
|
|
1910
|
-
closed_at:
|
|
1911
|
-
created_at:
|
|
1912
|
-
id:
|
|
1913
|
-
merged:
|
|
1914
|
-
merged_at:
|
|
1915
|
-
number:
|
|
1916
|
-
updated_at:
|
|
1917
|
-
user:
|
|
2064
|
+
import { z as z12 } from "zod";
|
|
2065
|
+
var canonicalPullRequestOutcomeSchema = z12.object({
|
|
2066
|
+
action: z12.enum(["opened", "closed", "reopened"]),
|
|
2067
|
+
pull_request: z12.object({
|
|
2068
|
+
body: z12.string().nullable().optional(),
|
|
2069
|
+
closed_at: z12.string().nullable().optional(),
|
|
2070
|
+
created_at: z12.string(),
|
|
2071
|
+
id: z12.number().int().positive(),
|
|
2072
|
+
merged: z12.boolean(),
|
|
2073
|
+
merged_at: z12.string().nullable().optional(),
|
|
2074
|
+
number: z12.number().int().positive(),
|
|
2075
|
+
updated_at: z12.string(),
|
|
2076
|
+
user: z12.object({ login: z12.string().min(1) }).strict()
|
|
1918
2077
|
}).strict(),
|
|
1919
|
-
repository:
|
|
1920
|
-
full_name:
|
|
1921
|
-
id:
|
|
2078
|
+
repository: z12.object({
|
|
2079
|
+
full_name: z12.string().min(1),
|
|
2080
|
+
id: z12.number().int().positive()
|
|
1922
2081
|
}).strict()
|
|
1923
2082
|
}).strict();
|
|
1924
|
-
var pullRequestOutcomeSchema =
|
|
1925
|
-
action:
|
|
1926
|
-
pull_request:
|
|
1927
|
-
body:
|
|
1928
|
-
closed_at:
|
|
1929
|
-
created_at:
|
|
1930
|
-
id:
|
|
1931
|
-
merged:
|
|
1932
|
-
merged_at:
|
|
1933
|
-
number:
|
|
1934
|
-
updated_at:
|
|
1935
|
-
user:
|
|
2083
|
+
var pullRequestOutcomeSchema = z12.object({
|
|
2084
|
+
action: z12.enum(["opened", "closed", "reopened"]),
|
|
2085
|
+
pull_request: z12.object({
|
|
2086
|
+
body: z12.string().nullable().optional(),
|
|
2087
|
+
closed_at: z12.string().nullable().optional(),
|
|
2088
|
+
created_at: z12.string(),
|
|
2089
|
+
id: z12.number().int().positive(),
|
|
2090
|
+
merged: z12.boolean(),
|
|
2091
|
+
merged_at: z12.string().nullable().optional(),
|
|
2092
|
+
number: z12.number().int().positive(),
|
|
2093
|
+
updated_at: z12.string(),
|
|
2094
|
+
user: z12.object({ login: z12.string().min(1) }).passthrough()
|
|
1936
2095
|
}).passthrough(),
|
|
1937
|
-
repository:
|
|
1938
|
-
full_name:
|
|
1939
|
-
id:
|
|
2096
|
+
repository: z12.object({
|
|
2097
|
+
full_name: z12.string().min(1),
|
|
2098
|
+
id: z12.number().int().positive()
|
|
1940
2099
|
}).passthrough()
|
|
1941
2100
|
}).passthrough().transform(
|
|
1942
2101
|
(provider) => canonicalPullRequestOutcomeSchema.parse({
|
|
@@ -1958,24 +2117,24 @@ var pullRequestOutcomeSchema = z11.object({
|
|
|
1958
2117
|
}
|
|
1959
2118
|
})
|
|
1960
2119
|
);
|
|
1961
|
-
var pullRequestLifecycleActionSchema =
|
|
1962
|
-
var canonicalPullRequestConversationSchema =
|
|
1963
|
-
pull_request:
|
|
1964
|
-
body:
|
|
1965
|
-
id:
|
|
1966
|
-
user:
|
|
2120
|
+
var pullRequestLifecycleActionSchema = z12.object({ action: z12.string() }).passthrough();
|
|
2121
|
+
var canonicalPullRequestConversationSchema = z12.object({
|
|
2122
|
+
pull_request: z12.object({
|
|
2123
|
+
body: z12.string().nullable().optional(),
|
|
2124
|
+
id: z12.number().int().positive(),
|
|
2125
|
+
user: z12.object({ login: z12.string().min(1) }).strict()
|
|
1967
2126
|
}).strict(),
|
|
1968
|
-
repository:
|
|
1969
|
-
sender:
|
|
2127
|
+
repository: z12.object({ full_name: z12.string().min(1) }).strict(),
|
|
2128
|
+
sender: z12.object({ login: z12.string().min(1) }).strict()
|
|
1970
2129
|
}).strict();
|
|
1971
|
-
var pullRequestConversationSchema =
|
|
1972
|
-
pull_request:
|
|
1973
|
-
body:
|
|
1974
|
-
id:
|
|
1975
|
-
user:
|
|
2130
|
+
var pullRequestConversationSchema = z12.object({
|
|
2131
|
+
pull_request: z12.object({
|
|
2132
|
+
body: z12.string().nullable().optional(),
|
|
2133
|
+
id: z12.number().int().positive(),
|
|
2134
|
+
user: z12.object({ login: z12.string().min(1) }).passthrough()
|
|
1976
2135
|
}).passthrough(),
|
|
1977
|
-
repository:
|
|
1978
|
-
sender:
|
|
2136
|
+
repository: z12.object({ full_name: z12.string().min(1) }).passthrough(),
|
|
2137
|
+
sender: z12.object({ login: z12.string().min(1) }).passthrough()
|
|
1979
2138
|
}).passthrough().transform(
|
|
1980
2139
|
(provider) => canonicalPullRequestConversationSchema.parse({
|
|
1981
2140
|
pull_request: {
|
|
@@ -2183,18 +2342,18 @@ function createGitHubWebhookRoute(args) {
|
|
|
2183
2342
|
|
|
2184
2343
|
// src/outcomes/report.ts
|
|
2185
2344
|
import { sql as sql5 } from "drizzle-orm";
|
|
2186
|
-
import { z as
|
|
2345
|
+
import { z as z14 } from "zod";
|
|
2187
2346
|
|
|
2188
2347
|
// src/outcomes/cost.ts
|
|
2189
2348
|
import { sql as sql4 } from "drizzle-orm";
|
|
2190
|
-
import { z as
|
|
2349
|
+
import { z as z13 } from "zod";
|
|
2191
2350
|
var DAY_MS = 24 * 60 * 60 * 1e3;
|
|
2192
|
-
var costWindowSchema =
|
|
2193
|
-
days:
|
|
2194
|
-
issueCostUsd:
|
|
2195
|
-
medianIssueCostUsd:
|
|
2196
|
-
medianPullRequestCostUsd:
|
|
2197
|
-
pullRequestCostUsd:
|
|
2351
|
+
var costWindowSchema = z13.object({
|
|
2352
|
+
days: z13.number().int().positive(),
|
|
2353
|
+
issueCostUsd: z13.number().nonnegative().nullable(),
|
|
2354
|
+
medianIssueCostUsd: z13.number().nonnegative().nullable(),
|
|
2355
|
+
medianPullRequestCostUsd: z13.number().nonnegative().nullable(),
|
|
2356
|
+
pullRequestCostUsd: z13.number().nonnegative().nullable()
|
|
2198
2357
|
}).strict().transform((row) => ({
|
|
2199
2358
|
days: row.days,
|
|
2200
2359
|
issueCostUsd: row.issueCostUsd ?? void 0,
|
|
@@ -2202,12 +2361,12 @@ var costWindowSchema = z12.object({
|
|
|
2202
2361
|
medianPullRequestCostUsd: row.medianPullRequestCostUsd ?? void 0,
|
|
2203
2362
|
pullRequestCostUsd: row.pullRequestCostUsd ?? void 0
|
|
2204
2363
|
}));
|
|
2205
|
-
var repositoryCostSchema =
|
|
2206
|
-
issueCostUsd:
|
|
2207
|
-
medianIssueCostUsd:
|
|
2208
|
-
medianPullRequestCostUsd:
|
|
2209
|
-
pullRequestCostUsd:
|
|
2210
|
-
repository:
|
|
2364
|
+
var repositoryCostSchema = z13.object({
|
|
2365
|
+
issueCostUsd: z13.number().nonnegative().nullable(),
|
|
2366
|
+
medianIssueCostUsd: z13.number().nonnegative().nullable(),
|
|
2367
|
+
medianPullRequestCostUsd: z13.number().nonnegative().nullable(),
|
|
2368
|
+
pullRequestCostUsd: z13.number().nonnegative().nullable(),
|
|
2369
|
+
repository: z13.string().min(1)
|
|
2211
2370
|
}).strict().transform((row) => ({
|
|
2212
2371
|
issueCostUsd: row.issueCostUsd ?? void 0,
|
|
2213
2372
|
medianIssueCostUsd: row.medianIssueCostUsd ?? void 0,
|
|
@@ -2412,7 +2571,7 @@ async function aggregateGitHubCostWindows(args) {
|
|
|
2412
2571
|
INNER JOIN issue_window ON issue_window.days = pull_request_window.days
|
|
2413
2572
|
ORDER BY pull_request_window.days
|
|
2414
2573
|
`);
|
|
2415
|
-
return
|
|
2574
|
+
return z13.array(costWindowSchema).parse(queryRows(result));
|
|
2416
2575
|
}
|
|
2417
2576
|
async function aggregateGitHubRepositoryCosts(args) {
|
|
2418
2577
|
if (!await hasConversationUsageTable(args.db)) {
|
|
@@ -2510,7 +2669,7 @@ async function aggregateGitHubRepositoryCosts(args) {
|
|
|
2510
2669
|
ON issue_totals.repository = repositories.repository
|
|
2511
2670
|
ORDER BY "repository" ASC
|
|
2512
2671
|
`);
|
|
2513
|
-
return
|
|
2672
|
+
return z13.array(repositoryCostSchema).parse(queryRows(result));
|
|
2514
2673
|
}
|
|
2515
2674
|
function formatCostUsd(value) {
|
|
2516
2675
|
if (value === void 0) return "\u2014";
|
|
@@ -2525,12 +2684,12 @@ function formatCostUsd(value) {
|
|
|
2525
2684
|
// src/outcomes/report.ts
|
|
2526
2685
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
2527
2686
|
var WINDOWS = [7, 30, 90];
|
|
2528
|
-
var pullRequestStatsSchema =
|
|
2529
|
-
closed:
|
|
2530
|
-
created:
|
|
2531
|
-
days:
|
|
2532
|
-
medianMergeTimeMs:
|
|
2533
|
-
merged:
|
|
2687
|
+
var pullRequestStatsSchema = z14.object({
|
|
2688
|
+
closed: z14.number().int().nonnegative(),
|
|
2689
|
+
created: z14.number().int().nonnegative(),
|
|
2690
|
+
days: z14.number().int().positive(),
|
|
2691
|
+
medianMergeTimeMs: z14.number().nonnegative().nullable(),
|
|
2692
|
+
merged: z14.number().int().nonnegative()
|
|
2534
2693
|
}).strict().transform((row) => {
|
|
2535
2694
|
const terminal = row.merged + row.closed;
|
|
2536
2695
|
return {
|
|
@@ -2539,12 +2698,12 @@ var pullRequestStatsSchema = z13.object({
|
|
|
2539
2698
|
mergeRate: terminal > 0 ? row.merged / terminal : void 0
|
|
2540
2699
|
};
|
|
2541
2700
|
});
|
|
2542
|
-
var pullRequestRepositoryStatsSchema =
|
|
2543
|
-
closed:
|
|
2544
|
-
created:
|
|
2545
|
-
juniorOnly:
|
|
2546
|
-
merged:
|
|
2547
|
-
repository:
|
|
2701
|
+
var pullRequestRepositoryStatsSchema = z14.object({
|
|
2702
|
+
closed: z14.number().int().nonnegative(),
|
|
2703
|
+
created: z14.number().int().nonnegative(),
|
|
2704
|
+
juniorOnly: z14.number().int().nonnegative(),
|
|
2705
|
+
merged: z14.number().int().nonnegative(),
|
|
2706
|
+
repository: z14.string().min(1)
|
|
2548
2707
|
}).strict().transform((row) => {
|
|
2549
2708
|
const terminal = row.merged + row.closed;
|
|
2550
2709
|
return {
|
|
@@ -2552,33 +2711,33 @@ var pullRequestRepositoryStatsSchema = z13.object({
|
|
|
2552
2711
|
mergeRate: terminal > 0 ? row.merged / terminal : void 0
|
|
2553
2712
|
};
|
|
2554
2713
|
});
|
|
2555
|
-
var issueStatsSchema =
|
|
2556
|
-
closedCompleted:
|
|
2557
|
-
closedDuplicate:
|
|
2558
|
-
closedNotPlanned:
|
|
2559
|
-
closedUnknown:
|
|
2560
|
-
created:
|
|
2561
|
-
days:
|
|
2562
|
-
medianCloseTimeMs:
|
|
2714
|
+
var issueStatsSchema = z14.object({
|
|
2715
|
+
closedCompleted: z14.number().int().nonnegative(),
|
|
2716
|
+
closedDuplicate: z14.number().int().nonnegative(),
|
|
2717
|
+
closedNotPlanned: z14.number().int().nonnegative(),
|
|
2718
|
+
closedUnknown: z14.number().int().nonnegative(),
|
|
2719
|
+
created: z14.number().int().nonnegative(),
|
|
2720
|
+
days: z14.number().int().positive(),
|
|
2721
|
+
medianCloseTimeMs: z14.number().nonnegative().nullable()
|
|
2563
2722
|
}).strict().transform((row) => ({
|
|
2564
2723
|
...row,
|
|
2565
2724
|
medianCloseTimeMs: row.medianCloseTimeMs ?? void 0
|
|
2566
2725
|
}));
|
|
2567
|
-
var pullRequestDaySchema =
|
|
2568
|
-
created:
|
|
2569
|
-
date:
|
|
2726
|
+
var pullRequestDaySchema = z14.object({
|
|
2727
|
+
created: z14.number().int().nonnegative(),
|
|
2728
|
+
date: z14.string().date()
|
|
2570
2729
|
}).strict();
|
|
2571
|
-
var issueDaySchema =
|
|
2572
|
-
created:
|
|
2573
|
-
date:
|
|
2730
|
+
var issueDaySchema = z14.object({
|
|
2731
|
+
created: z14.number().int().nonnegative(),
|
|
2732
|
+
date: z14.string().date()
|
|
2574
2733
|
}).strict();
|
|
2575
|
-
var issueRepositoryStatsSchema =
|
|
2576
|
-
closedCompleted:
|
|
2577
|
-
closedDuplicate:
|
|
2578
|
-
closedNotPlanned:
|
|
2579
|
-
closedUnknown:
|
|
2580
|
-
created:
|
|
2581
|
-
repository:
|
|
2734
|
+
var issueRepositoryStatsSchema = z14.object({
|
|
2735
|
+
closedCompleted: z14.number().int().nonnegative(),
|
|
2736
|
+
closedDuplicate: z14.number().int().nonnegative(),
|
|
2737
|
+
closedNotPlanned: z14.number().int().nonnegative(),
|
|
2738
|
+
closedUnknown: z14.number().int().nonnegative(),
|
|
2739
|
+
created: z14.number().int().nonnegative(),
|
|
2740
|
+
repository: z14.string().min(1)
|
|
2582
2741
|
}).strict();
|
|
2583
2742
|
function queryRows2(result) {
|
|
2584
2743
|
if (typeof result !== "object" || result === null || !("rows" in result) || !Array.isArray(result.rows)) {
|
|
@@ -2642,7 +2801,7 @@ async function aggregatePullRequestWindows(args) {
|
|
|
2642
2801
|
GROUP BY windows.days
|
|
2643
2802
|
ORDER BY windows.days
|
|
2644
2803
|
`);
|
|
2645
|
-
return
|
|
2804
|
+
return z14.array(pullRequestStatsSchema).parse(queryRows2(result));
|
|
2646
2805
|
}
|
|
2647
2806
|
async function aggregatePullRequestDays(args) {
|
|
2648
2807
|
const end = new Date(args.nowMs);
|
|
@@ -2670,7 +2829,7 @@ async function aggregatePullRequestDays(args) {
|
|
|
2670
2829
|
LEFT JOIN daily ON daily.day = days.day
|
|
2671
2830
|
ORDER BY days.day
|
|
2672
2831
|
`);
|
|
2673
|
-
return
|
|
2832
|
+
return z14.array(pullRequestDaySchema).parse(queryRows2(result));
|
|
2674
2833
|
}
|
|
2675
2834
|
async function aggregatePullRequestRepositories(args) {
|
|
2676
2835
|
const start = new Date(args.nowMs - 30 * DAY_MS2);
|
|
@@ -2700,7 +2859,7 @@ async function aggregatePullRequestRepositories(args) {
|
|
|
2700
2859
|
ORDER BY "merged" DESC, "created" DESC, "repository" ASC
|
|
2701
2860
|
LIMIT 25
|
|
2702
2861
|
`);
|
|
2703
|
-
return
|
|
2862
|
+
return z14.array(pullRequestRepositoryStatsSchema).parse(queryRows2(result));
|
|
2704
2863
|
}
|
|
2705
2864
|
async function aggregateIssueWindows(args) {
|
|
2706
2865
|
const starts = WINDOWS.map(
|
|
@@ -2769,7 +2928,7 @@ async function aggregateIssueWindows(args) {
|
|
|
2769
2928
|
GROUP BY windows.days
|
|
2770
2929
|
ORDER BY windows.days
|
|
2771
2930
|
`);
|
|
2772
|
-
return
|
|
2931
|
+
return z14.array(issueStatsSchema).parse(queryRows2(result));
|
|
2773
2932
|
}
|
|
2774
2933
|
async function aggregateIssueDays(args) {
|
|
2775
2934
|
const end = new Date(args.nowMs);
|
|
@@ -2797,7 +2956,7 @@ async function aggregateIssueDays(args) {
|
|
|
2797
2956
|
LEFT JOIN daily ON daily.day = days.day
|
|
2798
2957
|
ORDER BY days.day
|
|
2799
2958
|
`);
|
|
2800
|
-
return
|
|
2959
|
+
return z14.array(issueDaySchema).parse(queryRows2(result));
|
|
2801
2960
|
}
|
|
2802
2961
|
async function aggregateIssueRepositories(args) {
|
|
2803
2962
|
const start = new Date(args.nowMs - 30 * DAY_MS2);
|
|
@@ -2834,7 +2993,7 @@ async function aggregateIssueRepositories(args) {
|
|
|
2834
2993
|
ORDER BY "created" DESC, "closedCompleted" DESC, "repository" ASC
|
|
2835
2994
|
LIMIT 25
|
|
2836
2995
|
`);
|
|
2837
|
-
return
|
|
2996
|
+
return z14.array(issueRepositoryStatsSchema).parse(queryRows2(result));
|
|
2838
2997
|
}
|
|
2839
2998
|
function formatPercent(value) {
|
|
2840
2999
|
return value === void 0 ? "\u2014" : `${Math.round(value * 100)}%`;
|
|
@@ -2998,18 +3157,18 @@ async function buildGitHubOutcomeReport(args) {
|
|
|
2998
3157
|
}
|
|
2999
3158
|
|
|
3000
3159
|
// src/pull-request-outcomes/commit-composition.ts
|
|
3001
|
-
import { z as
|
|
3002
|
-
var canonicalCommitSchema =
|
|
3003
|
-
authorEmail:
|
|
3004
|
-
authorLogin:
|
|
3160
|
+
import { z as z15 } from "zod";
|
|
3161
|
+
var canonicalCommitSchema = z15.object({
|
|
3162
|
+
authorEmail: z15.string().nullable(),
|
|
3163
|
+
authorLogin: z15.string().nullable()
|
|
3005
3164
|
}).strict();
|
|
3006
|
-
var providerCommitSchema =
|
|
3007
|
-
author:
|
|
3008
|
-
commit:
|
|
3009
|
-
author:
|
|
3165
|
+
var providerCommitSchema = z15.object({
|
|
3166
|
+
author: z15.object({ login: z15.string() }).passthrough().nullable(),
|
|
3167
|
+
commit: z15.object({
|
|
3168
|
+
author: z15.object({ email: z15.string() }).passthrough().nullable()
|
|
3010
3169
|
}).passthrough()
|
|
3011
3170
|
}).passthrough();
|
|
3012
|
-
var commitPageSchema =
|
|
3171
|
+
var commitPageSchema = z15.array(providerCommitSchema).transform(
|
|
3013
3172
|
(commits) => commits.map(
|
|
3014
3173
|
(commit) => canonicalCommitSchema.parse({
|
|
3015
3174
|
authorEmail: commit.commit.author?.email ?? null,
|
|
@@ -4224,10 +4383,22 @@ function githubPlugin(options = {}) {
|
|
|
4224
4383
|
supportedEvents: [...GITHUB_PULL_REQUEST_EVENTS],
|
|
4225
4384
|
suggestedEvents: [...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS]
|
|
4226
4385
|
},
|
|
4386
|
+
{
|
|
4387
|
+
type: "release_source",
|
|
4388
|
+
supportedEvents: [...GITHUB_RELEASE_EVENTS],
|
|
4389
|
+
suggestedEvents: [...GITHUB_RELEASE_SUGGESTED_EVENTS]
|
|
4390
|
+
},
|
|
4227
4391
|
{
|
|
4228
4392
|
type: "repository",
|
|
4229
|
-
supportedEvents: [
|
|
4230
|
-
|
|
4393
|
+
supportedEvents: [
|
|
4394
|
+
...GITHUB_ISSUE_EVENTS,
|
|
4395
|
+
...GITHUB_PULL_REQUEST_EVENTS
|
|
4396
|
+
],
|
|
4397
|
+
suggestedEvents: [
|
|
4398
|
+
"issue.opened",
|
|
4399
|
+
...GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
4400
|
+
...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS
|
|
4401
|
+
]
|
|
4231
4402
|
}
|
|
4232
4403
|
],
|
|
4233
4404
|
isEnabled: () => Boolean(readEnv("GITHUB_WEBHOOK_SECRET")),
|
|
@@ -4236,7 +4407,7 @@ function githubPlugin(options = {}) {
|
|
|
4236
4407
|
manifest: {
|
|
4237
4408
|
name: "github",
|
|
4238
4409
|
displayName: "GitHub",
|
|
4239
|
-
description: "GitHub deployment, issue, pull request, and repository workflows via GitHub App",
|
|
4410
|
+
description: "GitHub deployment, issue, pull request, release, and repository workflows via GitHub App",
|
|
4240
4411
|
configKeys: ["org", "repo"],
|
|
4241
4412
|
domains: ["api.github.com", "github.com", "uploads.github.com"],
|
|
4242
4413
|
envVars: {
|