paperclip-github-plugin 0.14.0 → 0.14.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 +2 -0
- package/dist/manifest.js +1 -1
- package/dist/ui/index.js +5 -5
- package/dist/ui/index.js.map +3 -3
- package/dist/worker.js +68 -5
- package/package.json +3 -3
package/dist/worker.js
CHANGED
|
@@ -2978,7 +2978,7 @@ async function resolvePaperclipIssueGitHubLink(ctx, issueId, companyId, options
|
|
|
2978
2978
|
};
|
|
2979
2979
|
return await hydrateRecoveredPaperclipIssueGitHubLink(ctx, issueId, fallbackLink) ?? fallbackLink;
|
|
2980
2980
|
}
|
|
2981
|
-
async function
|
|
2981
|
+
async function listPaperclipIssueGitHubPullRequestLinks(ctx, issueId, companyId) {
|
|
2982
2982
|
const links = await listGitHubPullRequestLinkRecords(ctx, {
|
|
2983
2983
|
paperclipIssueId: issueId
|
|
2984
2984
|
});
|
|
@@ -2988,7 +2988,10 @@ async function resolvePaperclipIssueGitHubPullRequestLink(ctx, issueId, companyI
|
|
|
2988
2988
|
const safeRightTimestamp = Number.isFinite(rightTimestamp) ? rightTimestamp : 0;
|
|
2989
2989
|
const safeLeftTimestamp = Number.isFinite(leftTimestamp) ? leftTimestamp : 0;
|
|
2990
2990
|
return safeRightTimestamp - safeLeftTimestamp;
|
|
2991
|
-
})
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
async function resolvePaperclipIssueGitHubPullRequestLink(ctx, issueId, companyId) {
|
|
2994
|
+
return (await listPaperclipIssueGitHubPullRequestLinks(ctx, issueId, companyId))[0] ?? null;
|
|
2992
2995
|
}
|
|
2993
2996
|
async function hydrateRecoveredPaperclipIssueGitHubLink(ctx, issueId, fallbackLink) {
|
|
2994
2997
|
const repository = parseRepositoryReference(fallbackLink.repositoryUrl);
|
|
@@ -11401,12 +11404,72 @@ async function resolveGitHubIssueToolTarget(ctx, runCtx, input) {
|
|
|
11401
11404
|
async function resolveGitHubPullRequestToolTarget(ctx, runCtx, input) {
|
|
11402
11405
|
const paperclipIssueId = normalizeOptionalToolString(input.paperclipIssueId);
|
|
11403
11406
|
if (paperclipIssueId) {
|
|
11404
|
-
const link = await
|
|
11405
|
-
|
|
11407
|
+
const [link, directPullRequestLinks] = await Promise.all([
|
|
11408
|
+
resolvePaperclipIssueGitHubLink(ctx, paperclipIssueId, runCtx.companyId),
|
|
11409
|
+
listPaperclipIssueGitHubPullRequestLinks(ctx, paperclipIssueId, runCtx.companyId)
|
|
11410
|
+
]);
|
|
11411
|
+
const directPullRequestReferences = normalizeLinkedPullRequestReferences(
|
|
11412
|
+
directPullRequestLinks.map((record) => ({
|
|
11413
|
+
number: record.data.githubPullRequestNumber,
|
|
11414
|
+
repositoryUrl: record.data.repositoryUrl
|
|
11415
|
+
}))
|
|
11416
|
+
);
|
|
11417
|
+
if (!link && directPullRequestReferences.length === 0) {
|
|
11406
11418
|
throw new Error("This Paperclip issue is not linked to GitHub yet.");
|
|
11407
11419
|
}
|
|
11408
11420
|
const explicitPullRequestNumber = normalizeToolPositiveInteger(input.pullRequestNumber);
|
|
11409
|
-
|
|
11421
|
+
if (!link) {
|
|
11422
|
+
const explicitRepository = normalizeOptionalToolString(input.repository);
|
|
11423
|
+
if (explicitPullRequestNumber !== void 0) {
|
|
11424
|
+
const matchingPullRequests = directPullRequestReferences.filter(
|
|
11425
|
+
(pullRequest) => pullRequest.number === explicitPullRequestNumber
|
|
11426
|
+
);
|
|
11427
|
+
if (explicitRepository) {
|
|
11428
|
+
const requestedRepository = requireRepositoryReference(explicitRepository);
|
|
11429
|
+
const matchingPullRequest = matchingPullRequests.find(
|
|
11430
|
+
(pullRequest) => areRepositoriesEqual(requestedRepository, requireRepositoryReference(pullRequest.repositoryUrl))
|
|
11431
|
+
);
|
|
11432
|
+
if (!matchingPullRequest) {
|
|
11433
|
+
throw new Error("repository and pullRequestNumber must match a pull request directly linked to the provided Paperclip issue.");
|
|
11434
|
+
}
|
|
11435
|
+
return {
|
|
11436
|
+
repository: requestedRepository,
|
|
11437
|
+
pullRequestNumber: explicitPullRequestNumber,
|
|
11438
|
+
paperclipIssueId
|
|
11439
|
+
};
|
|
11440
|
+
}
|
|
11441
|
+
if (matchingPullRequests.length === 1) {
|
|
11442
|
+
return {
|
|
11443
|
+
repository: requireRepositoryReference(matchingPullRequests[0].repositoryUrl),
|
|
11444
|
+
pullRequestNumber: explicitPullRequestNumber,
|
|
11445
|
+
paperclipIssueId
|
|
11446
|
+
};
|
|
11447
|
+
}
|
|
11448
|
+
if (matchingPullRequests.length > 1) {
|
|
11449
|
+
throw new Error("repository is required because the Paperclip issue has matching direct pull request links in multiple repositories.");
|
|
11450
|
+
}
|
|
11451
|
+
throw new Error("pullRequestNumber must match a pull request directly linked to the provided Paperclip issue.");
|
|
11452
|
+
}
|
|
11453
|
+
if (directPullRequestReferences.length === 1) {
|
|
11454
|
+
const inferredPullRequest = directPullRequestReferences[0];
|
|
11455
|
+
if (explicitRepository) {
|
|
11456
|
+
const requestedRepository = requireRepositoryReference(explicitRepository);
|
|
11457
|
+
if (!areRepositoriesEqual(requestedRepository, requireRepositoryReference(inferredPullRequest.repositoryUrl))) {
|
|
11458
|
+
throw new Error("repository must match the GitHub repository for the directly linked pull request.");
|
|
11459
|
+
}
|
|
11460
|
+
}
|
|
11461
|
+
return {
|
|
11462
|
+
repository: requireRepositoryReference(inferredPullRequest.repositoryUrl),
|
|
11463
|
+
pullRequestNumber: inferredPullRequest.number,
|
|
11464
|
+
paperclipIssueId
|
|
11465
|
+
};
|
|
11466
|
+
}
|
|
11467
|
+
throw new Error("pullRequestNumber is required unless the Paperclip issue has exactly one directly linked pull request.");
|
|
11468
|
+
}
|
|
11469
|
+
const linkedPullRequests = normalizeLinkedPullRequestReferences([
|
|
11470
|
+
...link.linkedPullRequests.length > 0 ? link.linkedPullRequests : normalizeLinkedPullRequestReferences(link.linkedPullRequestNumbers, link.repositoryUrl),
|
|
11471
|
+
...directPullRequestReferences
|
|
11472
|
+
]);
|
|
11410
11473
|
if (explicitPullRequestNumber !== void 0) {
|
|
11411
11474
|
const explicitRepository = normalizeOptionalToolString(input.repository);
|
|
11412
11475
|
const matchingLinkedPullRequests = linkedPullRequests.filter(
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paperclip-github-plugin",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Paperclip plugin for synchronizing GitHub issues into Paperclip projects.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"packageManager": "pnpm@11.
|
|
7
|
+
"packageManager": "pnpm@11.9.0",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=20"
|
|
10
10
|
},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/node": "24.13.2",
|
|
53
53
|
"@types/react": "19.2.17",
|
|
54
54
|
"esbuild": "0.28.1",
|
|
55
|
-
"playwright": "1.61.
|
|
55
|
+
"playwright": "1.61.1",
|
|
56
56
|
"tsx": "4.22.4",
|
|
57
57
|
"typescript": "6.0.3"
|
|
58
58
|
}
|