@gitkraken/core-gitlens 0.43.0 → 0.45.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/dist/git/errors.d.ts +1 -0
  3. package/dist/git/errors.js +7 -1
  4. package/dist/git/errors.js.map +1 -1
  5. package/dist/plus/git-github/api/aliasedQuery.d.ts +3 -2
  6. package/dist/plus/git-github/api/aliasedQuery.js +7 -3
  7. package/dist/plus/git-github/api/aliasedQuery.js.map +1 -1
  8. package/dist/plus/git-github/api/github.d.ts +12 -0
  9. package/dist/plus/git-github/api/github.js +188 -41
  10. package/dist/plus/git-github/api/github.js.map +1 -1
  11. package/dist/plus/git-github/api/issueWrites.d.ts +7 -2
  12. package/dist/plus/git-github/api/issueWrites.js +9 -4
  13. package/dist/plus/git-github/api/issueWrites.js.map +1 -1
  14. package/dist/plus/git-github/api/pullRequestWrites.d.ts +95 -0
  15. package/dist/plus/git-github/api/pullRequestWrites.js +469 -0
  16. package/dist/plus/git-github/api/pullRequestWrites.js.map +1 -0
  17. package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +10 -9
  18. package/dist/plus/integrations/authentication/configuredIntegrationService.js +18 -12
  19. package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
  20. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts +9 -4
  21. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +26 -9
  22. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js.map +1 -1
  23. package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +1 -0
  24. package/dist/plus/integrations/authentication/integrationAuthenticationService.js +3 -0
  25. package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
  26. package/dist/plus/integrations/authentication/observedAuthenticationProvider.d.ts +1 -0
  27. package/dist/plus/integrations/authentication/observedAuthenticationProvider.js +14 -4
  28. package/dist/plus/integrations/authentication/observedAuthenticationProvider.js.map +1 -1
  29. package/dist/plus/integrations/authentication/rejectedTokenTracker.d.ts +2 -2
  30. package/dist/plus/integrations/authentication/rejectedTokenTracker.js +19 -5
  31. package/dist/plus/integrations/authentication/rejectedTokenTracker.js.map +1 -1
  32. package/dist/plus/integrations/collectionMetadata.js +2 -1
  33. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  34. package/dist/plus/integrations/context.d.ts +3 -3
  35. package/dist/plus/integrations/errors.d.ts +4 -0
  36. package/dist/plus/integrations/errors.js +8 -1
  37. package/dist/plus/integrations/errors.js.map +1 -1
  38. package/dist/plus/integrations/index.d.ts +4 -2
  39. package/dist/plus/integrations/index.js.map +1 -1
  40. package/dist/plus/integrations/integrationService.d.ts +22 -1
  41. package/dist/plus/integrations/integrationService.js +51 -2
  42. package/dist/plus/integrations/integrationService.js.map +1 -1
  43. package/dist/plus/integrations/lite.js +11 -1
  44. package/dist/plus/integrations/lite.js.map +1 -1
  45. package/dist/plus/integrations/manager.d.ts +96 -4
  46. package/dist/plus/integrations/models/gitHostIntegration.d.ts +21 -2
  47. package/dist/plus/integrations/models/gitHostIntegration.js +182 -14
  48. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  49. package/dist/plus/integrations/models/integration.d.ts +10 -2
  50. package/dist/plus/integrations/models/integration.js +53 -8
  51. package/dist/plus/integrations/models/integration.js.map +1 -1
  52. package/dist/plus/integrations/providers/apiClients.d.ts +1 -0
  53. package/dist/plus/integrations/providers/apiClients.js +3 -0
  54. package/dist/plus/integrations/providers/apiClients.js.map +1 -1
  55. package/dist/plus/integrations/providers/azure/azure.d.ts +3 -0
  56. package/dist/plus/integrations/providers/azure/azure.js +109 -18
  57. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  58. package/dist/plus/integrations/providers/azureDevOps.d.ts +12 -0
  59. package/dist/plus/integrations/providers/azureDevOps.js +22 -0
  60. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  61. package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +21 -2
  62. package/dist/plus/integrations/providers/bitbucket/bitbucket.js +59 -19
  63. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  64. package/dist/plus/integrations/providers/bitbucket-server.d.ts +2 -0
  65. package/dist/plus/integrations/providers/bitbucket-server.js +11 -3
  66. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  67. package/dist/plus/integrations/providers/bitbucket.d.ts +14 -0
  68. package/dist/plus/integrations/providers/bitbucket.js +30 -2
  69. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  70. package/dist/plus/integrations/providers/github.d.ts +12 -0
  71. package/dist/plus/integrations/providers/github.js +66 -2
  72. package/dist/plus/integrations/providers/github.js.map +1 -1
  73. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +19 -1
  74. package/dist/plus/integrations/providers/gitlab/gitlab.js +116 -17
  75. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  76. package/dist/plus/integrations/providers/gitlab.d.ts +15 -2
  77. package/dist/plus/integrations/providers/gitlab.js +34 -4
  78. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  79. package/dist/plus/integrations/providers/providerErrors.d.ts +8 -0
  80. package/dist/plus/integrations/providers/providerErrors.js +15 -2
  81. package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
  82. package/dist/plus/integrations/reads/pullRequestsForCommits.d.ts +45 -0
  83. package/dist/plus/integrations/reads/pullRequestsForCommits.js +97 -0
  84. package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -0
  85. package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
  86. package/dist/plus/integrations/utils/domain.utils.js +5 -1
  87. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  88. package/dist/plus/integrations/utils/failureBackoff.d.ts +13 -0
  89. package/dist/plus/integrations/utils/failureBackoff.js +47 -0
  90. package/dist/plus/integrations/utils/failureBackoff.js.map +1 -0
  91. package/docs/integrations.md +126 -6
  92. package/package.json +1 -1
@@ -0,0 +1,97 @@
1
+ import { CancellationError } from "../../../utils/cancellation.js";
2
+ import { isAzureProviderId } from "../providers/providerErrors.js";
3
+ import { appendDedupedWarning } from "../results.js";
4
+ import { isGitHostIntegration, isIssuesHostIntegrationId } from "../utils/integration.utils.js";
5
+ import { gitHostOnlySurfaceWarning, otherWarning, unsupportedWarning } from "./warnings.js";
6
+ import { runCaptured } from "./drains.js";
7
+ import { appendBatchSlotWarning } from "./batchEtags.js";
8
+ import { trimCoordinateFields, unresolvedIntegration } from "./issueBatch.js";
9
+ //#region ../plus/integrations/src/reads/pullRequestsForCommits.ts
10
+ async function getPullRequestsForCommits(ctx, options) {
11
+ const cancellation = options.cancellation;
12
+ if (cancellation?.aborted) throw new CancellationError();
13
+ const refused = (warning) => ({
14
+ items: [],
15
+ warnings: [warning],
16
+ fetchFailed: true
17
+ });
18
+ const surface = "Pull requests by commit";
19
+ if (isIssuesHostIntegrationId(options.providerId)) return refused(gitHostOnlySurfaceWarning(options.providerId, void 0, options.connectionId, surface));
20
+ if (options.shas.length === 0) return {
21
+ items: [],
22
+ warnings: []
23
+ };
24
+ const repo = trimCoordinateFields({
25
+ owner: options.owner,
26
+ repo: options.repo,
27
+ project: options.project
28
+ });
29
+ const invalid = findInvalidRepository(options.providerId, repo) ?? findInvalidSha(options.shas);
30
+ if (invalid != null) return refused(otherWarning(options.providerId, void 0, options.connectionId, invalid));
31
+ const shas = [];
32
+ const asked = [];
33
+ const seen = /* @__PURE__ */ new Set();
34
+ for (const sha of options.shas) {
35
+ const trimmed = sha.trim();
36
+ const normalized = trimmed.toLowerCase();
37
+ if (seen.has(normalized)) continue;
38
+ seen.add(normalized);
39
+ shas.push(trimmed);
40
+ asked.push(normalized);
41
+ }
42
+ const integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);
43
+ if (cancellation?.aborted) throw new CancellationError();
44
+ if (integration == null) return unresolvedIntegration(ctx, options.providerId, options.connectionId, options.domain);
45
+ if (!isGitHostIntegration(integration)) return refused(gitHostOnlySurfaceWarning(options.providerId, void 0, options.connectionId, surface));
46
+ const domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);
47
+ const mergeQueue = options.mergeQueue ?? ctx.getPullRequestReadOptions().mergeQueue === true;
48
+ const warnings = [];
49
+ let fetchFailed = false;
50
+ const { value: slots, warning } = await runCaptured(options.providerId, domain, options.connectionId, () => integration.getPullRequestsForCommitsResult(repo, asked, { mergeQueue }, cancellation, options.connectionId), { warnOnMissingSession: true });
51
+ if (cancellation?.aborted) throw new CancellationError();
52
+ if (warning != null) appendDedupedWarning(warnings, {
53
+ ...warning,
54
+ targetKeys: shas
55
+ });
56
+ if (slots == null) {
57
+ if (warning == null) appendDedupedWarning(warnings, {
58
+ ...unsupportedWarning(options.providerId, domain, options.connectionId, `${surface} is not supported by '${options.providerId}'.`),
59
+ targetKeys: shas
60
+ });
61
+ return {
62
+ items: [],
63
+ warnings,
64
+ fetchFailed: true
65
+ };
66
+ }
67
+ const items = [];
68
+ for (let i = 0; i < shas.length; i++) {
69
+ const slot = slots[i];
70
+ if (slot.status === "rejected") {
71
+ appendBatchSlotWarning(warnings, options.providerId, domain, options.connectionId, slot, shas[i]);
72
+ fetchFailed = true;
73
+ continue;
74
+ }
75
+ items.push({
76
+ sha: shas[i],
77
+ ...slot.value != null ? { pullRequest: slot.value } : {}
78
+ });
79
+ }
80
+ return {
81
+ items,
82
+ warnings,
83
+ fetchFailed: fetchFailed || void 0
84
+ };
85
+ }
86
+ function findInvalidRepository(providerId, repo) {
87
+ if (repo.owner.length === 0 || repo.repo.length === 0) return `Pull requests by commit requires a non-empty owner and repo.`;
88
+ if (isAzureProviderId(providerId) && !repo.project) return `Pull requests by commit requires a project for '${providerId}'.`;
89
+ }
90
+ const fullShaRegex = /^[0-9a-f]{40}$/i;
91
+ function findInvalidSha(shas) {
92
+ for (const sha of shas) if (!fullShaRegex.test(sha.trim())) return `Pull requests by commit got '${sha}'; pass each commit as its full 40-character SHA.`;
93
+ }
94
+ //#endregion
95
+ export { getPullRequestsForCommits };
96
+
97
+ //# sourceMappingURL=pullRequestsForCommits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pullRequestsForCommits.js","names":[],"sources":["../../../../../plus/integrations/src/reads/pullRequestsForCommits.ts"],"sourcesContent":["import type { PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport type { IntegrationIds } from '../constants.js';\nimport { isAzureProviderId } from '../providers/providerErrors.js';\nimport type { ProviderResult, ProviderWarning } from '../results.js';\nimport { appendDedupedWarning } from '../results.js';\nimport { isGitHostIntegration, isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport { appendBatchSlotWarning } from './batchEtags.js';\nimport type { ProviderReadContext } from './context.js';\nimport { runCaptured } from './drains.js';\nimport { trimCoordinateFields, unresolvedIntegration } from './issueBatch.js';\nimport { gitHostOnlySurfaceWarning, otherWarning, unsupportedWarning } from './warnings.js';\n\n/** The answer for one SHA of {@link getPullRequestsForCommits}'s input. */\nexport interface PullRequestForCommitResult {\n\t/** The SHA as the caller passed it (trimmed), echoed so no positional matching is needed. */\n\tsha: string;\n\t/**\n\t * The pull request the commit belongs to, or `undefined` when the host ANSWERED that it has none (or when the SHA\n\t * is the working tree's all-zero one, which is never sent): a resolved \"none\" a caller can cache. A SHA whose read\n\t * FAILED is not returned at all and sets `fetchFailed`.\n\t *\n\t * When a commit belongs to several, the one the single-commit lookup returns, which each host picks its own way —\n\t * see {@link IntegrationManager.getPullRequestsForCommits}.\n\t */\n\tpullRequest?: PullRequestShape;\n}\n\nexport async function getPullRequestsForCommits(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\t/**\n\t\t * GitHub owner, GitLab namespace path (may be nested), Bitbucket workspace, Bitbucket Data Center project key, or\n\t\t * Azure DevOps organization.\n\t\t */\n\t\towner: string;\n\t\t/** Repository name or slug. */\n\t\trepo: string;\n\t\t/** Azure DevOps project. Required there, ignored elsewhere. */\n\t\tproject?: string;\n\t\t/** See {@link IntegrationManager.getPullRequestsForCommits}. Repeats (ignoring case) are resolved once. */\n\t\tshas: readonly string[];\n\t\tconnectionId?: string;\n\t\t/**\n\t\t * Explicit self-managed host domain. Used only when the requested connection has no configured domain;\n\t\t * it must come from the trusted authentication configuration, not repository or remote data.\n\t\t */\n\t\tdomain?: string;\n\t\t/** See {@link IntegrationManager.getPullRequestsForCommits}. */\n\t\tmergeQueue?: boolean;\n\t\t/** See {@link IntegrationManager.getPullRequestsForCommits}. */\n\t\tcancellation?: AbortSignal;\n\t},\n): Promise<ProviderResult<PullRequestForCommitResult>> {\n\tconst cancellation = options.cancellation;\n\tif (cancellation?.aborted) throw new CancellationError();\n\n\tconst refused = (warning: ProviderWarning): ProviderResult<PullRequestForCommitResult> => ({\n\t\titems: [],\n\t\twarnings: [warning],\n\t\tfetchFailed: true,\n\t});\n\tconst surface = 'Pull requests by commit';\n\n\tif (isIssuesHostIntegrationId(options.providerId)) {\n\t\treturn refused(gitHostOnlySurfaceWarning(options.providerId, undefined, options.connectionId, surface));\n\t}\n\n\tif (options.shas.length === 0) return { items: [], warnings: [] };\n\n\tconst repo = trimCoordinateFields({ owner: options.owner, repo: options.repo, project: options.project });\n\tconst invalid = findInvalidRepository(options.providerId, repo) ?? findInvalidSha(options.shas);\n\tif (invalid != null) {\n\t\treturn refused(otherWarning(options.providerId, undefined, options.connectionId, invalid));\n\t}\n\n\tconst shas: string[] = [];\n\tconst asked: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const sha of options.shas) {\n\t\tconst trimmed = sha.trim();\n\t\tconst normalized = trimmed.toLowerCase();\n\t\tif (seen.has(normalized)) continue;\n\n\t\tseen.add(normalized);\n\t\tshas.push(trimmed);\n\t\tasked.push(normalized);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\tif (cancellation?.aborted) throw new CancellationError();\n\tif (integration == null) {\n\t\treturn unresolvedIntegration(ctx, options.providerId, options.connectionId, options.domain);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn refused(gitHostOnlySurfaceWarning(options.providerId, undefined, options.connectionId, surface));\n\t}\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\tconst mergeQueue = options.mergeQueue ?? ctx.getPullRequestReadOptions().mergeQueue === true;\n\n\tconst warnings: ProviderWarning[] = [];\n\tlet fetchFailed = false;\n\n\tconst { value: slots, warning } = await runCaptured(\n\t\toptions.providerId,\n\t\tdomain,\n\t\toptions.connectionId,\n\t\t() =>\n\t\t\tintegration.getPullRequestsForCommitsResult(\n\t\t\t\trepo,\n\t\t\t\tasked,\n\t\t\t\t{ mergeQueue: mergeQueue },\n\t\t\t\tcancellation,\n\t\t\t\toptions.connectionId,\n\t\t\t),\n\t\t// KEEP: a missing session must warn on the primary path too, which otherwise reads it as not connected.\n\t\t{ warnOnMissingSession: true },\n\t);\n\tif (cancellation?.aborted) throw new CancellationError();\n\n\tif (warning != null) {\n\t\tappendDedupedWarning(warnings, { ...warning, targetKeys: shas });\n\t}\n\n\tif (slots == null) {\n\t\tif (warning == null) {\n\t\t\tappendDedupedWarning(warnings, {\n\t\t\t\t...unsupportedWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t`${surface} is not supported by '${options.providerId}'.`,\n\t\t\t\t),\n\t\t\t\ttargetKeys: shas,\n\t\t\t});\n\t\t}\n\t\treturn { items: [], warnings: warnings, fetchFailed: true };\n\t}\n\n\tconst items: PullRequestForCommitResult[] = [];\n\tfor (let i = 0; i < shas.length; i++) {\n\t\tconst slot = slots[i];\n\t\tif (slot.status === 'rejected') {\n\t\t\tappendBatchSlotWarning(warnings, options.providerId, domain, options.connectionId, slot, shas[i]);\n\t\t\tfetchFailed = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\titems.push({ sha: shas[i], ...(slot.value != null ? { pullRequest: slot.value } : {}) });\n\t}\n\n\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed || undefined };\n}\n\nfunction findInvalidRepository(\n\tproviderId: IntegrationIds,\n\trepo: { owner: string; repo: string; project?: string },\n): string | undefined {\n\tif (repo.owner.length === 0 || repo.repo.length === 0) {\n\t\treturn `Pull requests by commit requires a non-empty owner and repo.`;\n\t}\n\tif (isAzureProviderId(providerId) && !repo.project) {\n\t\treturn `Pull requests by commit requires a project for '${providerId}'.`;\n\t}\n\treturn undefined;\n}\n\nconst fullShaRegex = /^[0-9a-f]{40}$/i;\n\nfunction findInvalidSha(shas: readonly string[]): string | undefined {\n\tfor (const sha of shas) {\n\t\tif (!fullShaRegex.test(sha.trim())) {\n\t\t\treturn `Pull requests by commit got '${sha}'; pass each commit as its full 40-character SHA.`;\n\t\t}\n\t}\n\treturn undefined;\n}\n"],"mappings":";;;;;;;;;AA4BA,eAAsB,0BACrB,KACA,SAwBsD;CACtD,MAAM,eAAe,QAAQ;CAC7B,IAAI,cAAc,SAAS,MAAM,IAAI,kBAAkB;CAEvD,MAAM,WAAW,aAA0E;EAC1F,OAAO,CAAC;EACR,UAAU,CAAC,OAAO;EAClB,aAAa;CACd;CACA,MAAM,UAAU;CAEhB,IAAI,0BAA0B,QAAQ,UAAU,GAC/C,OAAO,QAAQ,0BAA0B,QAAQ,YAAY,KAAA,GAAW,QAAQ,cAAc,OAAO,CAAC;CAGvG,IAAI,QAAQ,KAAK,WAAW,GAAG,OAAO;EAAE,OAAO,CAAC;EAAG,UAAU,CAAC;CAAE;CAEhE,MAAM,OAAO,qBAAqB;EAAE,OAAO,QAAQ;EAAO,MAAM,QAAQ;EAAM,SAAS,QAAQ;CAAQ,CAAC;CACxG,MAAM,UAAU,sBAAsB,QAAQ,YAAY,IAAI,KAAK,eAAe,QAAQ,IAAI;CAC9F,IAAI,WAAW,MACd,OAAO,QAAQ,aAAa,QAAQ,YAAY,KAAA,GAAW,QAAQ,cAAc,OAAO,CAAC;CAG1F,MAAM,OAAiB,CAAC;CACxB,MAAM,QAAkB,CAAC;CACzB,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,OAAO,QAAQ,MAAM;EAC/B,MAAM,UAAU,IAAI,KAAK;EACzB,MAAM,aAAa,QAAQ,YAAY;EACvC,IAAI,KAAK,IAAI,UAAU,GAAG;EAE1B,KAAK,IAAI,UAAU;EACnB,KAAK,KAAK,OAAO;EACjB,MAAM,KAAK,UAAU;CACtB;CAEA,MAAM,cAAc,MAAM,IAAI,sBAAsB,QAAQ,YAAY,QAAQ,cAAc,QAAQ,MAAM;CAC5G,IAAI,cAAc,SAAS,MAAM,IAAI,kBAAkB;CACvD,IAAI,eAAe,MAClB,OAAO,sBAAsB,KAAK,QAAQ,YAAY,QAAQ,cAAc,QAAQ,MAAM;CAE3F,IAAI,CAAC,qBAAqB,WAAW,GACpC,OAAO,QAAQ,0BAA0B,QAAQ,YAAY,KAAA,GAAW,QAAQ,cAAc,OAAO,CAAC;CAGvG,MAAM,SAAS,IAAI,cAAc,aAAa,QAAQ,YAAY,QAAQ,cAAc,QAAQ,MAAM;CACtG,MAAM,aAAa,QAAQ,cAAc,IAAI,0BAA0B,CAAC,CAAC,eAAe;CAExF,MAAM,WAA8B,CAAC;CACrC,IAAI,cAAc;CAElB,MAAM,EAAE,OAAO,OAAO,YAAY,MAAM,YACvC,QAAQ,YACR,QACA,QAAQ,oBAEP,YAAY,gCACX,MACA,OACA,EAAc,WAAW,GACzB,cACA,QAAQ,YACT,GAED,EAAE,sBAAsB,KAAK,CAC9B;CACA,IAAI,cAAc,SAAS,MAAM,IAAI,kBAAkB;CAEvD,IAAI,WAAW,MACd,qBAAqB,UAAU;EAAE,GAAG;EAAS,YAAY;CAAK,CAAC;CAGhE,IAAI,SAAS,MAAM;EAClB,IAAI,WAAW,MACd,qBAAqB,UAAU;GAC9B,GAAG,mBACF,QAAQ,YACR,QACA,QAAQ,cACR,GAAG,QAAQ,wBAAwB,QAAQ,WAAW,GACvD;GACA,YAAY;EACb,CAAC;EAEF,OAAO;GAAE,OAAO,CAAC;GAAa;GAAU,aAAa;EAAK;CAC3D;CAEA,MAAM,QAAsC,CAAC;CAC7C,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM;EACnB,IAAI,KAAK,WAAW,YAAY;GAC/B,uBAAuB,UAAU,QAAQ,YAAY,QAAQ,QAAQ,cAAc,MAAM,KAAK,EAAE;GAChG,cAAc;GACd;EACD;EAEA,MAAM,KAAK;GAAE,KAAK,KAAK;GAAI,GAAI,KAAK,SAAS,OAAO,EAAE,aAAa,KAAK,MAAM,IAAI,CAAC;EAAG,CAAC;CACxF;CAEA,OAAO;EAAS;EAAiB;EAAU,aAAa,eAAe,KAAA;CAAU;AAClF;AAEA,SAAS,sBACR,YACA,MACqB;CACrB,IAAI,KAAK,MAAM,WAAW,KAAK,KAAK,KAAK,WAAW,GACnD,OAAO;CAER,IAAI,kBAAkB,UAAU,KAAK,CAAC,KAAK,SAC1C,OAAO,mDAAmD,WAAW;AAGvE;AAEA,MAAM,eAAe;AAErB,SAAS,eAAe,MAA6C;CACpE,KAAK,MAAM,OAAO,MACjB,IAAI,CAAC,aAAa,KAAK,IAAI,KAAK,CAAC,GAChC,OAAO,gCAAgC,IAAI;AAI9C"}
@@ -39,6 +39,7 @@ export declare function baseUrlFromDomain(domain: string | undefined, protocol:
39
39
  * connection gaining or losing one.
40
40
  */
41
41
  export declare function sameConfiguredBaseUrl(first: string | undefined, second: string | undefined): boolean;
42
+ export declare function encodePathSegment(value: string): string;
42
43
  /** Decodes one percent-encoded URL path segment, keeping a malformed one as written. */
43
44
  export declare function decodePathSegment(segment: string): string;
44
45
  //#endregion
@@ -82,6 +82,10 @@ function sameConfiguredBaseUrl(first, second) {
82
82
  const secondUrl = baseUrlFromDomain(second, void 0);
83
83
  return firstUrl != null && secondUrl != null && firstUrl === secondUrl;
84
84
  }
85
+ function encodePathSegment(value) {
86
+ if (value === "." || value === "..") throw new Error(`Invalid path segment '${value}'.`);
87
+ return encodeURIComponent(value);
88
+ }
85
89
  /** Decodes one percent-encoded URL path segment, keeping a malformed one as written. */
86
90
  function decodePathSegment(segment) {
87
91
  try {
@@ -91,6 +95,6 @@ function decodePathSegment(segment) {
91
95
  }
92
96
  }
93
97
  //#endregion
94
- export { areDomainsOnSameHost, areDomainsOnSameHostname, baseUrlFromDomain, decodePathSegment, getRemoteHostMatcher, getSingleConfiguredDomain, hostFromDomain, isWebRemoteScheme, sameConfiguredBaseUrl };
98
+ export { areDomainsOnSameHost, areDomainsOnSameHostname, baseUrlFromDomain, decodePathSegment, encodePathSegment, getRemoteHostMatcher, getSingleConfiguredDomain, hostFromDomain, isWebRemoteScheme, sameConfiguredBaseUrl };
95
99
 
96
100
  //# sourceMappingURL=domain.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain.utils.js","names":[],"sources":["../../../../../plus/integrations/src/utils/domain.utils.ts"],"sourcesContent":["import { trimTrailingSlashes } from '@gitlens/utils/path.js';\n\n/** Extracts the host from a domain expressed as either a URL or a bare host. */\nexport function hostFromDomain(domain: string | undefined): string | undefined {\n\tconst value = domain?.trim();\n\tif (!value) return undefined;\n\n\tif (/^[a-z][a-z\\d+\\-.]*:\\/\\//i.test(value)) {\n\t\ttry {\n\t\t\treturn new URL(value).host || undefined;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\ttry {\n\t\treturn new URL(`https://${value}`).host || undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Multiple accounts on the same host are unambiguous; an unknown configured host is not. */\nexport function getSingleConfiguredDomain(configured: readonly { domain?: string }[]): string | undefined {\n\tconst hosts = new Set(configured.map(connection => hostFromDomain(connection.domain)));\n\treturn hosts.size === 1 ? hosts.values().next().value : undefined;\n}\n\n/** Whether two URL-or-host domain values identify the same normalized host and port. */\nexport function areDomainsOnSameHost(first: string | undefined, second: string | undefined): boolean {\n\tconst firstHost = hostFromDomain(first);\n\tconst secondHost = hostFromDomain(second);\n\treturn firstHost != null && secondHost != null && firstHost === secondHost;\n}\n\n/**\n * Whether two URL-or-host domain values name the same machine, ignoring the port. For comparing an SSH remote\n * against a web address: an SSH port says nothing about the port the host serves its web UI and API on.\n */\nexport function areDomainsOnSameHostname(first: string | undefined, second: string | undefined): boolean {\n\tconst firstHost = hostFromDomain(first);\n\tconst secondHost = hostFromDomain(second);\n\tif (firstHost == null || secondHost == null) return false;\n\n\treturn new URL(`https://${firstHost}`).hostname === new URL(`https://${secondHost}`).hostname;\n}\n\n/** Whether a git remote was addressed over the host's web protocol (`https://`/`http://`) rather than SSH/git. */\nexport function isWebRemoteScheme(scheme: string | undefined): boolean {\n\treturn scheme === 'https://' || scheme === 'http://';\n}\n\n/**\n * The comparison to use when matching a git remote's host against a configured (web) host. A web remote names\n * the very host and port the API is served on, so it must match exactly; an SSH or git remote's port — which\n * `parseGitRemoteUrl` drops anyway — says nothing about the web port, so only the hostname can be compared.\n */\nexport function getRemoteHostMatcher(\n\tscheme: string | undefined,\n): (first: string | undefined, second: string | undefined) => boolean {\n\treturn isWebRemoteScheme(scheme) ? areDomainsOnSameHost : areDomainsOnSameHostname;\n}\n\n/**\n * Builds the API base URL for a self-managed host from a domain expressed as either a URL or a bare host.\n *\n * Distinct from {@link hostFromDomain}, which exists to collapse a domain to the identity the connection is\n * keyed by and therefore DROPS the path. An instance mounted below a context path — Jira Data Center's\n * `/jira`, a reverse-proxied GitLab or Bitbucket — has to be addressed at that path, so the value a request\n * is built from must keep it. Callers pass the session's own domain (the unnormalized one the backend\n * stored) rather than the integration's host-keyed `domain`, and fall back to the latter.\n */\nexport function baseUrlFromDomain(domain: string | undefined, protocol: string | undefined): string | undefined {\n\tconst value = domain?.trim();\n\tif (!value) return undefined;\n\n\tconst scheme = /^[a-z][a-z\\d+\\-.]*:\\/\\//i.test(value) ? undefined : (protocol ?? 'https:');\n\ttry {\n\t\tconst url = new URL(scheme == null ? value : `${scheme}//${value}`);\n\t\treturn `${url.protocol}//${url.host}${trimTrailingSlashes(url.pathname)}`;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Whether two configured addresses point at the same place, comparing them the way a request would.\n *\n * Both sides are run through {@link baseUrlFromDomain} first, so the shapes a domain legitimately arrives in\n * — a bare host, a full URL, a trailing slash — compare equal, while a genuinely different context path does\n * not. Two absent values are the same address (neither names a path); one absent is not, since that is a\n * connection gaining or losing one.\n */\nexport function sameConfiguredBaseUrl(first: string | undefined, second: string | undefined): boolean {\n\tif (!first?.trim() && !second?.trim()) return true;\n\n\tconst firstUrl = baseUrlFromDomain(first, undefined);\n\tconst secondUrl = baseUrlFromDomain(second, undefined);\n\treturn firstUrl != null && secondUrl != null && firstUrl === secondUrl;\n}\n\n/** Decodes one percent-encoded URL path segment, keeping a malformed one as written. */\nexport function decodePathSegment(segment: string): string {\n\ttry {\n\t\treturn decodeURIComponent(segment);\n\t} catch {\n\t\treturn segment;\n\t}\n}\n"],"mappings":";;;AAGA,SAAgB,eAAe,QAAgD;CAC9E,MAAM,QAAQ,QAAQ,KAAK;CAC3B,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,IAAI,2BAA2B,KAAK,KAAK,GACxC,IAAI;EACH,OAAO,IAAI,IAAI,KAAK,CAAC,CAAC,QAAQ,KAAA;CAC/B,QAAQ;EACP;CACD;CAGD,IAAI;EACH,OAAO,IAAI,IAAI,WAAW,OAAO,CAAC,CAAC,QAAQ,KAAA;CAC5C,QAAQ;EACP;CACD;AACD;;AAGA,SAAgB,0BAA0B,YAAgE;CACzG,MAAM,QAAQ,IAAI,IAAI,WAAW,KAAI,eAAc,eAAe,WAAW,MAAM,CAAC,CAAC;CACrF,OAAO,MAAM,SAAS,IAAI,MAAM,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,KAAA;AACzD;;AAGA,SAAgB,qBAAqB,OAA2B,QAAqC;CACpG,MAAM,YAAY,eAAe,KAAK;CACtC,MAAM,aAAa,eAAe,MAAM;CACxC,OAAO,aAAa,QAAQ,cAAc,QAAQ,cAAc;AACjE;;;;;AAMA,SAAgB,yBAAyB,OAA2B,QAAqC;CACxG,MAAM,YAAY,eAAe,KAAK;CACtC,MAAM,aAAa,eAAe,MAAM;CACxC,IAAI,aAAa,QAAQ,cAAc,MAAM,OAAO;CAEpD,OAAO,IAAI,IAAI,WAAW,WAAW,CAAC,CAAC,aAAa,IAAI,IAAI,WAAW,YAAY,CAAC,CAAC;AACtF;;AAGA,SAAgB,kBAAkB,QAAqC;CACtE,OAAO,WAAW,cAAc,WAAW;AAC5C;;;;;;AAOA,SAAgB,qBACf,QACqE;CACrE,OAAO,kBAAkB,MAAM,IAAI,uBAAuB;AAC3D;;;;;;;;;;AAWA,SAAgB,kBAAkB,QAA4B,UAAkD;CAC/G,MAAM,QAAQ,QAAQ,KAAK;CAC3B,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,MAAM,SAAS,2BAA2B,KAAK,KAAK,IAAI,KAAA,IAAa,YAAY;CACjF,IAAI;EACH,MAAM,MAAM,IAAI,IAAI,UAAU,OAAO,QAAQ,GAAG,OAAO,IAAI,OAAO;EAClE,OAAO,GAAG,IAAI,SAAS,IAAI,IAAI,OAAO,oBAAoB,IAAI,QAAQ;CACvE,QAAQ;EACP;CACD;AACD;;;;;;;;;AAUA,SAAgB,sBAAsB,OAA2B,QAAqC;CACrG,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,QAAQ,KAAK,GAAG,OAAO;CAE9C,MAAM,WAAW,kBAAkB,OAAO,KAAA,CAAS;CACnD,MAAM,YAAY,kBAAkB,QAAQ,KAAA,CAAS;CACrD,OAAO,YAAY,QAAQ,aAAa,QAAQ,aAAa;AAC9D;;AAGA,SAAgB,kBAAkB,SAAyB;CAC1D,IAAI;EACH,OAAO,mBAAmB,OAAO;CAClC,QAAQ;EACP,OAAO;CACR;AACD"}
1
+ {"version":3,"file":"domain.utils.js","names":[],"sources":["../../../../../plus/integrations/src/utils/domain.utils.ts"],"sourcesContent":["import { trimTrailingSlashes } from '@gitlens/utils/path.js';\n\n/** Extracts the host from a domain expressed as either a URL or a bare host. */\nexport function hostFromDomain(domain: string | undefined): string | undefined {\n\tconst value = domain?.trim();\n\tif (!value) return undefined;\n\n\tif (/^[a-z][a-z\\d+\\-.]*:\\/\\//i.test(value)) {\n\t\ttry {\n\t\t\treturn new URL(value).host || undefined;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\ttry {\n\t\treturn new URL(`https://${value}`).host || undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Multiple accounts on the same host are unambiguous; an unknown configured host is not. */\nexport function getSingleConfiguredDomain(configured: readonly { domain?: string }[]): string | undefined {\n\tconst hosts = new Set(configured.map(connection => hostFromDomain(connection.domain)));\n\treturn hosts.size === 1 ? hosts.values().next().value : undefined;\n}\n\n/** Whether two URL-or-host domain values identify the same normalized host and port. */\nexport function areDomainsOnSameHost(first: string | undefined, second: string | undefined): boolean {\n\tconst firstHost = hostFromDomain(first);\n\tconst secondHost = hostFromDomain(second);\n\treturn firstHost != null && secondHost != null && firstHost === secondHost;\n}\n\n/**\n * Whether two URL-or-host domain values name the same machine, ignoring the port. For comparing an SSH remote\n * against a web address: an SSH port says nothing about the port the host serves its web UI and API on.\n */\nexport function areDomainsOnSameHostname(first: string | undefined, second: string | undefined): boolean {\n\tconst firstHost = hostFromDomain(first);\n\tconst secondHost = hostFromDomain(second);\n\tif (firstHost == null || secondHost == null) return false;\n\n\treturn new URL(`https://${firstHost}`).hostname === new URL(`https://${secondHost}`).hostname;\n}\n\n/** Whether a git remote was addressed over the host's web protocol (`https://`/`http://`) rather than SSH/git. */\nexport function isWebRemoteScheme(scheme: string | undefined): boolean {\n\treturn scheme === 'https://' || scheme === 'http://';\n}\n\n/**\n * The comparison to use when matching a git remote's host against a configured (web) host. A web remote names\n * the very host and port the API is served on, so it must match exactly; an SSH or git remote's port — which\n * `parseGitRemoteUrl` drops anyway — says nothing about the web port, so only the hostname can be compared.\n */\nexport function getRemoteHostMatcher(\n\tscheme: string | undefined,\n): (first: string | undefined, second: string | undefined) => boolean {\n\treturn isWebRemoteScheme(scheme) ? areDomainsOnSameHost : areDomainsOnSameHostname;\n}\n\n/**\n * Builds the API base URL for a self-managed host from a domain expressed as either a URL or a bare host.\n *\n * Distinct from {@link hostFromDomain}, which exists to collapse a domain to the identity the connection is\n * keyed by and therefore DROPS the path. An instance mounted below a context path — Jira Data Center's\n * `/jira`, a reverse-proxied GitLab or Bitbucket — has to be addressed at that path, so the value a request\n * is built from must keep it. Callers pass the session's own domain (the unnormalized one the backend\n * stored) rather than the integration's host-keyed `domain`, and fall back to the latter.\n */\nexport function baseUrlFromDomain(domain: string | undefined, protocol: string | undefined): string | undefined {\n\tconst value = domain?.trim();\n\tif (!value) return undefined;\n\n\tconst scheme = /^[a-z][a-z\\d+\\-.]*:\\/\\//i.test(value) ? undefined : (protocol ?? 'https:');\n\ttry {\n\t\tconst url = new URL(scheme == null ? value : `${scheme}//${value}`);\n\t\treturn `${url.protocol}//${url.host}${trimTrailingSlashes(url.pathname)}`;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Whether two configured addresses point at the same place, comparing them the way a request would.\n *\n * Both sides are run through {@link baseUrlFromDomain} first, so the shapes a domain legitimately arrives in\n * — a bare host, a full URL, a trailing slash — compare equal, while a genuinely different context path does\n * not. Two absent values are the same address (neither names a path); one absent is not, since that is a\n * connection gaining or losing one.\n */\nexport function sameConfiguredBaseUrl(first: string | undefined, second: string | undefined): boolean {\n\tif (!first?.trim() && !second?.trim()) return true;\n\n\tconst firstUrl = baseUrlFromDomain(first, undefined);\n\tconst secondUrl = baseUrlFromDomain(second, undefined);\n\treturn firstUrl != null && secondUrl != null && firstUrl === secondUrl;\n}\n\nexport function encodePathSegment(value: string): string {\n\tif (value === '.' || value === '..') throw new Error(`Invalid path segment '${value}'.`);\n\n\treturn encodeURIComponent(value);\n}\n\n/** Decodes one percent-encoded URL path segment, keeping a malformed one as written. */\nexport function decodePathSegment(segment: string): string {\n\ttry {\n\t\treturn decodeURIComponent(segment);\n\t} catch {\n\t\treturn segment;\n\t}\n}\n"],"mappings":";;;AAGA,SAAgB,eAAe,QAAgD;CAC9E,MAAM,QAAQ,QAAQ,KAAK;CAC3B,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,IAAI,2BAA2B,KAAK,KAAK,GACxC,IAAI;EACH,OAAO,IAAI,IAAI,KAAK,CAAC,CAAC,QAAQ,KAAA;CAC/B,QAAQ;EACP;CACD;CAGD,IAAI;EACH,OAAO,IAAI,IAAI,WAAW,OAAO,CAAC,CAAC,QAAQ,KAAA;CAC5C,QAAQ;EACP;CACD;AACD;;AAGA,SAAgB,0BAA0B,YAAgE;CACzG,MAAM,QAAQ,IAAI,IAAI,WAAW,KAAI,eAAc,eAAe,WAAW,MAAM,CAAC,CAAC;CACrF,OAAO,MAAM,SAAS,IAAI,MAAM,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,KAAA;AACzD;;AAGA,SAAgB,qBAAqB,OAA2B,QAAqC;CACpG,MAAM,YAAY,eAAe,KAAK;CACtC,MAAM,aAAa,eAAe,MAAM;CACxC,OAAO,aAAa,QAAQ,cAAc,QAAQ,cAAc;AACjE;;;;;AAMA,SAAgB,yBAAyB,OAA2B,QAAqC;CACxG,MAAM,YAAY,eAAe,KAAK;CACtC,MAAM,aAAa,eAAe,MAAM;CACxC,IAAI,aAAa,QAAQ,cAAc,MAAM,OAAO;CAEpD,OAAO,IAAI,IAAI,WAAW,WAAW,CAAC,CAAC,aAAa,IAAI,IAAI,WAAW,YAAY,CAAC,CAAC;AACtF;;AAGA,SAAgB,kBAAkB,QAAqC;CACtE,OAAO,WAAW,cAAc,WAAW;AAC5C;;;;;;AAOA,SAAgB,qBACf,QACqE;CACrE,OAAO,kBAAkB,MAAM,IAAI,uBAAuB;AAC3D;;;;;;;;;;AAWA,SAAgB,kBAAkB,QAA4B,UAAkD;CAC/G,MAAM,QAAQ,QAAQ,KAAK;CAC3B,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,MAAM,SAAS,2BAA2B,KAAK,KAAK,IAAI,KAAA,IAAa,YAAY;CACjF,IAAI;EACH,MAAM,MAAM,IAAI,IAAI,UAAU,OAAO,QAAQ,GAAG,OAAO,IAAI,OAAO;EAClE,OAAO,GAAG,IAAI,SAAS,IAAI,IAAI,OAAO,oBAAoB,IAAI,QAAQ;CACvE,QAAQ;EACP;CACD;AACD;;;;;;;;;AAUA,SAAgB,sBAAsB,OAA2B,QAAqC;CACrG,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,QAAQ,KAAK,GAAG,OAAO;CAE9C,MAAM,WAAW,kBAAkB,OAAO,KAAA,CAAS;CACnD,MAAM,YAAY,kBAAkB,QAAQ,KAAA,CAAS;CACrD,OAAO,YAAY,QAAQ,aAAa,QAAQ,aAAa;AAC9D;AAEA,SAAgB,kBAAkB,OAAuB;CACxD,IAAI,UAAU,OAAO,UAAU,MAAM,MAAM,IAAI,MAAM,yBAAyB,MAAM,GAAG;CAEvF,OAAO,mBAAmB,KAAK;AAChC;;AAGA,SAAgB,kBAAkB,SAAyB;CAC1D,IAAI;EACH,OAAO,mBAAmB,OAAO;CAClC,QAAQ;EACP,OAAO;CACR;AACD"}
@@ -0,0 +1,13 @@
1
+ //#region ../plus/integrations/src/utils/failureBackoff.d.ts
2
+ export declare const failureBackoffInitialMs: number;
3
+ export declare const failureBackoffMaxMs: number;
4
+ export declare class FailureBackoff {
5
+ private readonly entries;
6
+ backedOffUntil(key: string, now: number): number | undefined;
7
+ isBackedOff(key: string, now: number): boolean;
8
+ fail(key: string, now: number, until?: number): number;
9
+ clear(key: string): void;
10
+ clearAll(): void;
11
+ }
12
+ //#endregion
13
+ //# sourceMappingURL=failureBackoff.d.ts.map
@@ -0,0 +1,47 @@
1
+ //#region ../plus/integrations/src/utils/failureBackoff.ts
2
+ const failureBackoffInitialMs = 3e4;
3
+ const failureBackoffMaxMs = 6e5;
4
+ const failureBackoffCapacity = 500;
5
+ var FailureBackoff = class {
6
+ entries = /* @__PURE__ */ new Map();
7
+ backedOffUntil(key, now) {
8
+ const entry = this.entries.get(key);
9
+ return entry != null && entry.until > now ? entry.until : void 0;
10
+ }
11
+ isBackedOff(key, now) {
12
+ return this.backedOffUntil(key, now) != null;
13
+ }
14
+ fail(key, now, until) {
15
+ const previous = this.entries.get(key);
16
+ if (previous != null && previous.until > now) {
17
+ if (until != null && until > previous.until) previous.until = until;
18
+ return previous.until;
19
+ }
20
+ const failures = previous != null && !isStale(previous, now) ? previous.failures + 1 : 1;
21
+ const next = until != null && until > now ? until : now + Math.min(failureBackoffInitialMs * 2 ** (failures - 1), failureBackoffMaxMs);
22
+ this.entries.delete(key);
23
+ for (const [k, entry] of this.entries) if (isStale(entry, now)) this.entries.delete(k);
24
+ for (const k of this.entries.keys()) {
25
+ if (this.entries.size < failureBackoffCapacity) break;
26
+ this.entries.delete(k);
27
+ }
28
+ this.entries.set(key, {
29
+ until: next,
30
+ failures
31
+ });
32
+ return next;
33
+ }
34
+ clear(key) {
35
+ this.entries.delete(key);
36
+ }
37
+ clearAll() {
38
+ this.entries.clear();
39
+ }
40
+ };
41
+ function isStale(entry, now) {
42
+ return entry.until + failureBackoffMaxMs <= now;
43
+ }
44
+ //#endregion
45
+ export { FailureBackoff, failureBackoffInitialMs, failureBackoffMaxMs };
46
+
47
+ //# sourceMappingURL=failureBackoff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failureBackoff.js","names":[],"sources":["../../../../../plus/integrations/src/utils/failureBackoff.ts"],"sourcesContent":["export const failureBackoffInitialMs = 30 * 1000;\nexport const failureBackoffMaxMs = 10 * 60 * 1000;\nconst failureBackoffCapacity = 500;\n\nexport class FailureBackoff {\n\tprivate readonly entries = new Map<string, { until: number; failures: number }>();\n\n\tbackedOffUntil(key: string, now: number): number | undefined {\n\t\tconst entry = this.entries.get(key);\n\t\treturn entry != null && entry.until > now ? entry.until : undefined;\n\t}\n\n\tisBackedOff(key: string, now: number): boolean {\n\t\treturn this.backedOffUntil(key, now) != null;\n\t}\n\n\tfail(key: string, now: number, until?: number): number {\n\t\tconst previous = this.entries.get(key);\n\t\tif (previous != null && previous.until > now) {\n\t\t\tif (until != null && until > previous.until) {\n\t\t\t\tprevious.until = until;\n\t\t\t}\n\t\t\treturn previous.until;\n\t\t}\n\n\t\tconst failures = previous != null && !isStale(previous, now) ? previous.failures + 1 : 1;\n\t\tconst next =\n\t\t\tuntil != null && until > now\n\t\t\t\t? until\n\t\t\t\t: now + Math.min(failureBackoffInitialMs * 2 ** (failures - 1), failureBackoffMaxMs);\n\n\t\tthis.entries.delete(key);\n\t\tfor (const [k, entry] of this.entries) {\n\t\t\tif (isStale(entry, now)) {\n\t\t\t\tthis.entries.delete(k);\n\t\t\t}\n\t\t}\n\t\tfor (const k of this.entries.keys()) {\n\t\t\tif (this.entries.size < failureBackoffCapacity) break;\n\n\t\t\tthis.entries.delete(k);\n\t\t}\n\n\t\tthis.entries.set(key, { until: next, failures: failures });\n\t\treturn next;\n\t}\n\n\tclear(key: string): void {\n\t\tthis.entries.delete(key);\n\t}\n\n\tclearAll(): void {\n\t\tthis.entries.clear();\n\t}\n}\n\nfunction isStale(entry: { until: number }, now: number): boolean {\n\treturn entry.until + failureBackoffMaxMs <= now;\n}\n"],"mappings":";AAAA,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AACnC,MAAM,yBAAyB;AAE/B,IAAa,iBAAb,MAA4B;CAC3B,0BAA2B,IAAI,IAAiD;CAEhF,eAAe,KAAa,KAAiC;EAC5D,MAAM,QAAQ,KAAK,QAAQ,IAAI,GAAG;EAClC,OAAO,SAAS,QAAQ,MAAM,QAAQ,MAAM,MAAM,QAAQ,KAAA;CAC3D;CAEA,YAAY,KAAa,KAAsB;EAC9C,OAAO,KAAK,eAAe,KAAK,GAAG,KAAK;CACzC;CAEA,KAAK,KAAa,KAAa,OAAwB;EACtD,MAAM,WAAW,KAAK,QAAQ,IAAI,GAAG;EACrC,IAAI,YAAY,QAAQ,SAAS,QAAQ,KAAK;GAC7C,IAAI,SAAS,QAAQ,QAAQ,SAAS,OACrC,SAAS,QAAQ;GAElB,OAAO,SAAS;EACjB;EAEA,MAAM,WAAW,YAAY,QAAQ,CAAC,QAAQ,UAAU,GAAG,IAAI,SAAS,WAAW,IAAI;EACvF,MAAM,OACL,SAAS,QAAQ,QAAQ,MACtB,QACA,MAAM,KAAK,IAAI,0BAA0B,MAAM,WAAW,IAAI,mBAAmB;EAErF,KAAK,QAAQ,OAAO,GAAG;EACvB,KAAK,MAAM,CAAC,GAAG,UAAU,KAAK,SAC7B,IAAI,QAAQ,OAAO,GAAG,GACrB,KAAK,QAAQ,OAAO,CAAC;EAGvB,KAAK,MAAM,KAAK,KAAK,QAAQ,KAAK,GAAG;GACpC,IAAI,KAAK,QAAQ,OAAO,wBAAwB;GAEhD,KAAK,QAAQ,OAAO,CAAC;EACtB;EAEA,KAAK,QAAQ,IAAI,KAAK;GAAE,OAAO;GAAgB;EAAS,CAAC;EACzD,OAAO;CACR;CAEA,MAAM,KAAmB;EACxB,KAAK,QAAQ,OAAO,GAAG;CACxB;CAEA,WAAiB;EAChB,KAAK,QAAQ,MAAM;CACpB;AACD;AAEA,SAAS,QAAQ,OAA0B,KAAsB;CAChE,OAAO,MAAM,QAAQ,uBAAuB;AAC7C"}
@@ -130,6 +130,7 @@ it with `page` + `hasMore` + `cursor?`. **No read throws for a provider-side fai
130
130
  | `getPullRequestsForBranches` | `PullRequestBranchResult` | Each branch's PRs, in any state and fork-aware; an empty list is a proven none. |
131
131
  | `getPullRequestCheckLogs` | `PullRequestCheckLogResult` | The tail of each check's log, by the `PullRequestCheckRun.id` a batch read returned. |
132
132
  | `getPullRequestActivity` | `PullRequestActivityResult` | New reviews, inline review comments and conversation comments after a caller-held cursor. |
133
+ | `getPullRequestsForCommits` | `PullRequestForCommitResult` | The PR each of N commits of one repo belongs to; a row without one is a resolved none. |
133
134
  | `listIssueTrackerIssuesPage` | `IssueShape` | Jira (Cloud + Data Center) / Linear / Trello / Asana (issues live under resource → project). |
134
135
  | `sweepPullRequests` | `ProviderSweepResult` | Drains **every** page across providers (`maxPages`, default 100). |
135
136
  | `sweepClosedPullRequests` | `ProviderSweepResult` | Same, pinned to `['closed','merged']`. |
@@ -299,16 +300,17 @@ fields on GitHub/GHE and Bitbucket DC and the by-id read's on Bitbucket Cloud. B
299
300
  `IntegrationCacheProvider.getPullRequestForBranch`.
300
301
 
301
302
  `listPullRequestsPage`, `searchPullRequestsPage`, `getPullRequestsBatch`, `getPullRequestsForBranches`,
302
- `sweepPullRequests` and `sweepClosedPullRequests` also take `mergeQueue`, a per-read override of the host's
303
+ `getPullRequestsForCommits`, `sweepPullRequests` and `sweepClosedPullRequests` also take `mergeQueue`, a per-read override of the host's
303
304
  `getPullRequestReadOptions().mergeQueue`, for a host that wants queue state on one surface without paying for it on
304
305
  all of them. `true` selects merge-queue data on GitHub.com for that read, `false` doesn't, and omitting it follows the
305
306
  host's setting (off when the host has none). Enterprise and every other provider ignore it, as does a read that goes
306
307
  through provider-apis, which selects none: the repo-scoped `listPullRequestsPage` and the repo-scoped targets of the
307
308
  sweeps. The point reads on the integration classes (`getPullRequest`, `getPullRequestForBranch`,
308
309
  `getPullRequestForCommit` and `getIssueOrPullRequest`) don't take it: the host caches their rows under a key that
309
- doesn't carry it, so they follow the host's setting alone. `getPullRequestsBatch` and `getPullRequestsForBranches`
310
- resolve it once per call, so the batch's cheap check and full read, and the branch read's by-name query and the batch
311
- read that settles a truncated target, always select the same data. A read that selects merge-queue data adds a
310
+ doesn't carry it, so they follow the host's setting alone. `getPullRequestsBatch`, `getPullRequestsForBranches` and
311
+ `getPullRequestsForCommits` resolve it once per call, so the batch's cheap check and full read, the branch read's
312
+ by-name query and the batch read that settles a truncated target, and the commit read's chunks, always select the same
313
+ data. A read that selects merge-queue data adds a
312
314
  marker to every etag it computes, so an etag from such a read never equals one from a read that doesn't, even for a
313
315
  pull request that was never queued. Changing either the per-read option or the host's setting therefore costs one
314
316
  full read per held target, and a row held without the data is read in full again to gain it. A read that doesn't
@@ -393,6 +395,79 @@ charges for the page size asked for rather than the items returned, which at the
393
395
  point per pull request. A new comment or review moves the pull request's update time, so a caller
394
396
  can gate this read on a batch read's `etag` or `updatedDate`; that was not verified for every kind of activity.
395
397
 
398
+ `getPullRequestsForCommits` answers "which pull request does each of these commits belong to" for N commits of one
399
+ repository (`owner`, `repo` and, on Azure DevOps, `project`), echoed under each commit's `sha`. A row with a
400
+ `pullRequest` found one; a row without one is a resolved none (the host answered, or the SHA is the working tree's
401
+ all-zero one, which is never sent), which a caller may cache per SHA; a SHA whose read failed has no row, and the call
402
+ sets `fetchFailed` with a warning naming it in `targetKeys`. Bitbucket Cloud answers `404` alike for a commit it doesn't
403
+ have (an unpushed one) and for a repository it doesn't have, so its `404` is a none only once another commit of the
404
+ repository answered, in the same call, whatever settled first, or in an earlier lookup with the same token;
405
+ until then the SHA fails on its own, and a `404` never stops the call. So on Bitbucket Cloud a caller shouldn't pass
406
+ commits the remote doesn't have (unpushed ones): a window made only of those can't resolve. An answer without a list,
407
+ or with `repo_indexed: false`, means the repository's pull request links aren't indexed yet: it fails the SHA, never
408
+ as a none, and stops the call as the missing commit links app does. Every SHA must be a full 40-character commit SHA
409
+ in either letter case: anything else, a branch name or a short SHA included, refuses the whole call with a warning,
410
+ since a ref the host can't resolve as a commit would otherwise come back as a cacheable none. It takes
411
+ `cancellation`, with `searchPullRequestsPage`'s contract: an aborted read sends nothing more and rejects with a
412
+ `CancellationError`.
413
+
414
+ A commit that belongs to several pull requests resolves to the one the single-commit lookup picks, each host its own
415
+ way, which the batch keeps rather than normalizes:
416
+
417
+ | Host | Pull request a commit with several resolves to |
418
+ | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
419
+ | GitHub/GHE | Of the two most recently updated GitHub associates with the commit (a fork's only when the fork is `owner`'s): `owner`'s own (ignoring case), then a merged one, then the most recently updated. A third is never considered. |
420
+ | GitLab | Of the first page GitLab lists: an open one, then the most recently updated. |
421
+ | Bitbucket Cloud and DC | Of the first page the host lists: the most recently updated. |
422
+ | Azure DevOps | The first the pull request query lists. |
423
+
424
+ Request cost for N commits, each fan-out run with bounded concurrency:
425
+
426
+ | Host | Requests |
427
+ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
428
+ | GitHub/GHE | ⌈N / 25⌉ aliased GraphQL requests. |
429
+ | Azure DevOps | ⌈N / 100⌉ pull request queries (the query takes a list of commits; Azure DevOps documents no limit on it), then one read per distinct pull request found. |
430
+ | GitLab | One project lookup (kept per token), then N. |
431
+ | Bitbucket Cloud and DC | N. |
432
+
433
+ There is no cap on N. After the first rate limit or refused credential in a call, the requests it hasn't sent yet are
434
+ never sent: their SHAs fail with that reason, under one warning. A `403` stops the call the same way when none of its
435
+ SHAs has answered yet, since it is then the repository's refusal, which every SHA would meet; its SHAs fail under one
436
+ warning, scoped to the repository on a host that can check the credential (see §6) and the connection's on GitLab. A
437
+ `403` after a SHA answered is that commit's own and stops nothing. A credential refused after some SHAs answered is
438
+ still the credential's failure: the SHAs it failed carry the connection's `auth` warning, not a scoped one, and it runs
439
+ the credential's recovery once for the call. Bitbucket Cloud stops the same way at the first commit it refuses because
440
+ the pull request commit links app isn't installed, which every commit then answers, fails the call with a warning that
441
+ names the app, and shows the host's `onBitbucketCommitLinksAppMissing` notice once. The reads are a strict form of the
442
+ single-commit lookup's own (one that throws on a failed request where the lookup answers `undefined`, so a failure is
443
+ never a resolved none), and a host without one reports the surface `unsupported`. Rows are that lookup's (the `point`
444
+ projection, without `authoredByMe` or `viewer`). It is uncached and bypasses
445
+ `IntegrationCacheProvider.getPullRequestForSha`.
446
+
447
+ The integration's single-commit lookup (`getPullRequestForCommit`) never caches a failure as a commit without a pull
448
+ request, and backs off from asking again: after a failed lookup it sends no request, spends no strike and shows no
449
+ notice, and answers `undefined` (or, with `throwOnError`, rejects with a `LookupBackedOffError`) for 30 seconds
450
+ after the first failure, doubling with each consecutive failure up to 10 minutes, or until a rate limit's reset time
451
+ when the host gives one. A server error, a network failure (a transport `TimeoutError` included), a cancellation whose reason is `timeout`, a
452
+ rate limit, Bitbucket Cloud's
453
+ missing commit links app or links not indexed yet, a failed GitLab project lookup, and an API client that failed to
454
+ load back off the repository; every other failure (Bitbucket
455
+ Cloud's `404` before the repository answered, a `403` or another `4xx`, an unrecognized failure) backs off only that
456
+ commit. Once a Bitbucket Cloud repository answered for the token, a `404` there is a commit without a pull
457
+ request, cached and not backed off. A refused credential (`401`) and any other cancellation never back off, so a
458
+ host `fetch` that enforces its own deadline by aborting with a plain `AbortError` reads as a cancellation and is asked
459
+ again.
460
+ The backoff is kept per credential and host, is cleared by a lookup that succeeds and by a disconnect, reconnect or
461
+ refresh, and is bypassed by `expiryOverride: true`. An answer already cached is served during a backoff. GitLab's project lookup backs
462
+ off the same way for every read of the project, so for that long a read that answers `undefined` for a failed lookup
463
+ (a commit's author, the repository's issues) answers it without asking. The merge request lookup and the repository
464
+ metadata read instead never keep a failed lookup as a missing project: the merge request lookup fails on it, and the
465
+ repository metadata read (`getRepositoryMetadata`) answers `undefined` without keeping that answer. During the backoff
466
+ they send no request, and they ask again once it has passed; `expiryOverride: true` bypasses the backoff for
467
+ both. A `401` of the project lookup backs off only the reads that swallow it; these two still ask, so that its refusal
468
+ reaches the credential's recovery. The token-scoped read (§10) rejects on a failed lookup and is never backed off.
469
+ `getPullRequestsForCommits` is not backed off.
470
+
396
471
  `getCurrentAccount` answers who a connection is signed in as. It returns a single `account?` rather than
397
472
  `items`, and `account` is never absent without a warning: no session, a failed request, or a provider that refuses
398
473
  (see §8). Jira Cloud answers with the first site's account, since an Atlassian account id is the same on every site. It goes through the host-supplied
@@ -431,7 +506,8 @@ read), `search` and `search-summary` (the filtered search, and on the host its "
431
506
  `text-search` (the host's free-text `searchPullRequests`), `account` and `account-summary` (the account-wide list and
432
507
  sweeps, `account` being a sweep's `includeReviews`, and a tracker's "my issues"), `repos` and `repos-summary` (the
433
508
  repository-scoped list and sweeps), `project` (a tracker project's issues: `listIssueTrackerIssuesPage`,
434
- `getIssuesForProject`), and `batch` (`getPullRequestsBatch`, `getPullRequestsForBranches`, `getIssuesBatch`). Issues
509
+ `getIssuesForProject`), and `batch` (`getPullRequestsBatch`, `getPullRequestsForBranches`, `getIssuesBatch`).
510
+ `getPullRequestsForCommits` rows carry `point`, the single-commit lookup's tag, since they are its rows. Issues
435
511
  have no `-summary` reads; `broadenIssues` rows carry the tag of the read that served each org. The tag names a read,
436
512
  not a field set: the same tag can carry different fields on different providers.
437
513
 
@@ -772,6 +848,42 @@ An `ok: false` result contains a typed reason. GitHub can report inaccessible pr
772
848
  `not-found`. Check GitHub before retrying an `unknown` result, since GitHub may have applied the mutation
773
849
  before the response was lost.
774
850
 
851
+ ### GitHub.com pull request writes
852
+
853
+ Use `providerId: 'github'` and the `connectionId` that read the repository or pull request. Pass the
854
+ repository’s `owner` and `repo`, plus the `number` and `expectedNodeId` for an existing pull request.
855
+ Core checks the node’s repository and number before dispatching the write by canonical node ID. Use
856
+ `resolvePullRequestWriteTarget` to obtain that ID and the viewer’s current capabilities. Hosts can
857
+ serialize writes and publication on that canonical ID, including across legacy node aliases.
858
+ For creation, `getPullRequestCreateCapability` checks the viewer’s repository access and returns
859
+ the canonical repository ID. Pass it as `expectedRepositoryId` to prevent selecting a replacement
860
+ repository at the same address. For an active repository, `canCreate` is `true` when GitHub reports
861
+ a repository role for the viewer, and `undefined` when the role is unavailable. GitHub determines
862
+ whether the viewer may create a pull request between the chosen branches when it receives the write.
863
+
864
+ | Action for `writePullRequest` | Required input and result |
865
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
866
+ | `create` | `headRef` and `baseRef` are branch names in the selected repository. Pass a `title` and optional `body`. Returns `created`. |
867
+ | `edit` | Pass at least one of `title` and `body`. An empty body clears the description. Returns `updated`. |
868
+ | `set-state` | Pass `state: 'closed'` or `state: 'open'`. Returns `closed` or `reopened`. |
869
+ | `merge` | Pass `expectedHeadSha`, `expectedBaseRef` and a `mergeMethod` listed in the direct merge capability. Returns `merged`. |
870
+ | `enqueue` | Pass `expectedHeadSha` and `expectedBaseRef` for a target with the queue capability. The base branch’s queue configuration selects the strategy. Returns `queued`. |
871
+
872
+ The target read is uncached. Core checks active branch restrictions for direct merge and marks that
873
+ capability unavailable if it cannot read them. Edit, close and reopen use the viewer’s permissions
874
+ on the pull request. GitHub still applies its permissions, checks and policy at the time it receives a
875
+ write. The write preflight checks the observed base branch. GitHub checks the expected head atomically
876
+ for direct merge and enqueue.
877
+ Stacked merge actions can land more than one pull request and are unavailable through this API.
878
+
879
+ Every confirmed result carries a canonical snapshot with GitHub’s update time and close or merge
880
+ time when available. An enqueue receipt carries the snapshot verified at dispatch and the `queued`
881
+ status. Consumers should refresh the item and related views for its latest
882
+ queue position or merge state. `outcome-unknown` means the write may have reached GitHub. Reconcile it
883
+ through a fresh read before retrying. `blocked` means the action was refused by the pull request state or
884
+ branch policy. Inaccessible private resources can appear as `not-found`. After GitHub rejects a credential
885
+ with HTTP 401, the next operation on that connection can recover it. Core never replays the write.
886
+
775
887
  ## 5. Paging
776
888
 
777
889
  Two mechanisms live behind one shape, and they are **not** interchangeable:
@@ -1068,7 +1180,8 @@ keeps its existing behavior. It is set only on warnings derived from a structure
1068
1180
  least one ID when present; a failure attributed to nothing below the provider carries none. A warning built
1069
1181
  from a caught exception never carries one, even when that call targeted a single organization, and an omission
1070
1182
  keeps its attribution in `omission.scope` instead. The batch reads (`getIssuesBatch`, `getPullRequestsBatch`,
1071
- `getPullRequestsForBranches`) are the exception: a refused target's warning names the scope its target names —
1183
+ `getPullRequestsForBranches`, `getPullRequestsForCommits`) are the exception: a refused target's warning names the
1184
+ scope its target names (for the commit read, every SHA names its one repository) —
1072
1185
  the Azure DevOps organization and project, the repository on other git hosts, or the tracker's resource. So is
1073
1186
  `resolveRepository`: a `401`/`403` for the one repository it resolves settles as a batch read's refused target does,
1074
1187
  so on a host that can check the credential (Azure DevOps, Azure DevOps Server, Bitbucket, Bitbucket Data Center,
@@ -1083,6 +1196,12 @@ organizations, workspaces or sites, and their projects), or an SDK fan-out acros
1083
1196
  with one uncached check before reporting them; a batch read does so only when every target was refused, since a
1084
1197
  target that answered already proved the credential. A refused credential fails the whole read instead: an
1085
1198
  unscoped `auth` warning, `fetchFailed`, no results served from the cache, and the usual connection recovery.
1199
+ In a batch read, a `401` for a target of a repository another target of the same call answered from is the
1200
+ credential dying mid-call, never that repository's refusal: those targets fail under the connection's unscoped
1201
+ `auth` warning while the answered ones keep their results, the connection recovery runs once for the call, and the
1202
+ call doesn't reset the failure budget. Every other `401` of that call is then the credential's too, its repository
1203
+ answered or not. A `401` beside answers from other repositories only stays scoped when the call holds no such `401`,
1204
+ and a `403` always does.
1086
1205
  A refusal the provider pins on the credential itself, like Bitbucket's or Jira Cloud's for a token missing the
1087
1206
  OAuth scopes the read needs, is published unscoped too, once for the connection, because a reconnect (consenting
1088
1207
  to them again) is what fixes it; the scopes that answered keep their results.
@@ -1472,6 +1591,7 @@ footnote says otherwise.
1472
1591
  | `getPullRequestsForBranches` | ✓ | ✓ | ✓ | ✓¹ | ✓¹ | ✗ | ✗ | ✗ | ✗ |
1473
1592
  | `getPullRequestCheckLogs` | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ |
1474
1593
  | `getPullRequestActivity` | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ | ✗ |
1594
+ | `getPullRequestsForCommits` | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ |
1475
1595
  | Issues by `org`/`project` | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✓ | ✓ |
1476
1596
  | `listIssueTrackerIssuesPage` | — | — | — | — | — | ✓ | ✓ | ✓ | ✓ |
1477
1597
  | `broadenIssues` | ✓ | ✓ | ✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ |
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gitkraken/core-gitlens",
3
3
  "description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
4
- "version": "0.43.0",
4
+ "version": "0.45.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
7
7
  "name": "GitKraken",