@gitkraken/core-gitlens 0.43.0 → 0.44.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/CHANGELOG.md +23 -1
- package/dist/git/errors.d.ts +1 -0
- package/dist/git/errors.js +7 -1
- package/dist/git/errors.js.map +1 -1
- package/dist/git-cli/providers/config.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/staging.js +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/api/aliasedQuery.d.ts +3 -2
- package/dist/plus/git-github/api/aliasedQuery.js +7 -3
- package/dist/plus/git-github/api/aliasedQuery.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +5 -0
- package/dist/plus/git-github/api/github.js +100 -12
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +4 -1
- package/dist/plus/git-github/api/issueWrites.js +9 -4
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/integrations/collectionMetadata.js +2 -1
- package/dist/plus/integrations/collectionMetadata.js.map +1 -1
- package/dist/plus/integrations/context.d.ts +3 -3
- package/dist/plus/integrations/errors.d.ts +4 -0
- package/dist/plus/integrations/errors.js +8 -1
- package/dist/plus/integrations/errors.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +2 -1
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +16 -0
- package/dist/plus/integrations/integrationService.js +6 -1
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/lite.js +11 -1
- package/dist/plus/integrations/lite.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +87 -2
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +21 -2
- package/dist/plus/integrations/models/gitHostIntegration.js +182 -14
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +9 -1
- package/dist/plus/integrations/models/integration.js +43 -3
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/apiClients.d.ts +1 -0
- package/dist/plus/integrations/providers/apiClients.js +3 -0
- package/dist/plus/integrations/providers/apiClients.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.d.ts +3 -0
- package/dist/plus/integrations/providers/azure/azure.js +110 -19
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +12 -0
- package/dist/plus/integrations/providers/azureDevOps.js +22 -0
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +21 -2
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js +59 -19
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket-server.d.ts +2 -0
- package/dist/plus/integrations/providers/bitbucket-server.js +11 -3
- package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket.d.ts +14 -0
- package/dist/plus/integrations/providers/bitbucket.js +30 -2
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +7 -0
- package/dist/plus/integrations/providers/github.js +12 -1
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +19 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.js +116 -17
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab.d.ts +15 -2
- package/dist/plus/integrations/providers/gitlab.js +34 -4
- package/dist/plus/integrations/providers/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/providers/providerErrors.d.ts +8 -0
- package/dist/plus/integrations/providers/providerErrors.js +15 -2
- package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/plus/integrations/reads/pullRequestsForCommits.d.ts +45 -0
- package/dist/plus/integrations/reads/pullRequestsForCommits.js +97 -0
- package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -0
- package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
- package/dist/plus/integrations/utils/domain.utils.js +5 -1
- package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
- package/dist/plus/integrations/utils/failureBackoff.d.ts +13 -0
- package/dist/plus/integrations/utils/failureBackoff.js +47 -0
- package/dist/plus/integrations/utils/failureBackoff.js.map +1 -0
- package/dist/utils/env/node/exec.js +2 -2
- package/docs/integrations.md +90 -6
- package/package.json +1 -1
|
@@ -9,15 +9,30 @@ import { RepositoryMetadata } from "../../../../git/models/repositoryMetadata.js
|
|
|
9
9
|
import { TokenWithInfo } from "../../authentication/models.js";
|
|
10
10
|
import { PullRequestEtagInclude } from "../../models/integration.js";
|
|
11
11
|
import { ProviderApiConfig } from "../apiConfig.js";
|
|
12
|
+
import { CommitReadRefusedError } from "../providerErrors.js";
|
|
12
13
|
import { BitbucketPullRequestEtagNode } from "./models.js";
|
|
13
14
|
import { IntegrationServiceContext } from "../../context.js";
|
|
14
15
|
//#region ../plus/integrations/src/providers/bitbucket/bitbucket.d.ts
|
|
16
|
+
export declare class BitbucketCommitNotFoundError extends CommitReadRefusedError {}
|
|
17
|
+
export declare class BitbucketCommitPullRequestsUnindexedError extends CommitReadRefusedError {}
|
|
18
|
+
export declare class BitbucketCommitLinksAppMissingError extends CommitReadRefusedError {
|
|
19
|
+
readonly commitUrl: string;
|
|
20
|
+
constructor(commitUrl: string);
|
|
21
|
+
}
|
|
15
22
|
export declare class BitbucketApi implements Disposable {
|
|
16
23
|
private readonly config;
|
|
17
24
|
private readonly _disposable;
|
|
18
25
|
constructor(config: ProviderApiConfig);
|
|
19
26
|
dispose(): void;
|
|
20
27
|
private resetCaches;
|
|
28
|
+
private readonly _indexedRepositories;
|
|
29
|
+
isRepositoryIndexed(token: TokenWithInfo, owner: string, repo: string): boolean;
|
|
30
|
+
private readonly _commitLinksAppNoticeShownFor;
|
|
31
|
+
/**
|
|
32
|
+
* Shows the notice that the pull request commit links app must be installed once per workspace for the life of
|
|
33
|
+
* this client.
|
|
34
|
+
*/
|
|
35
|
+
notifyCommitLinksAppMissing(owner: string, commitWebUrl: string): void;
|
|
21
36
|
getPullRequestForBranch(provider: Provider, token: TokenWithInfo, owner: string, repo: string, branch: string, baseUrl: string): Promise<PullRequest | undefined>;
|
|
22
37
|
getServerPullRequestForBranch(provider: Provider, token: TokenWithInfo, owner: string, repo: string, branch: string, baseUrl: string): Promise<PullRequest | undefined>;
|
|
23
38
|
getUsersIssuesForRepo(provider: Provider, token: TokenWithInfo, userUuid: string, owner: string, repo: string, baseUrl: string): Promise<Issue[] | undefined>;
|
|
@@ -115,11 +130,15 @@ export declare class BitbucketApi implements Disposable {
|
|
|
115
130
|
baseUrl: string;
|
|
116
131
|
}, cancellation?: AbortSignal): Promise<DefaultBranch | undefined>;
|
|
117
132
|
private getRepository;
|
|
118
|
-
getServerPullRequestForCommit(provider: Provider, token: TokenWithInfo, owner: string, repo: string, rev: string, baseUrl: string,
|
|
133
|
+
getServerPullRequestForCommit(provider: Provider, token: TokenWithInfo, owner: string, repo: string, rev: string, baseUrl: string, options?: {
|
|
119
134
|
avatarSize?: number;
|
|
135
|
+
/** For a batch read: the batch reports a failed request once rather than each request showing its own. */
|
|
136
|
+
deferFailure?: boolean;
|
|
120
137
|
}, cancellation?: AbortSignal): Promise<PullRequest | undefined>;
|
|
121
|
-
getPullRequestForCommit(provider: Provider, token: TokenWithInfo, owner: string, repo: string, rev: string, baseUrl: string,
|
|
138
|
+
getPullRequestForCommit(provider: Provider, token: TokenWithInfo, owner: string, repo: string, rev: string, baseUrl: string, options?: {
|
|
122
139
|
avatarSize?: number;
|
|
140
|
+
/** For a batch read: the batch reports a failed request once rather than each request showing its own. */
|
|
141
|
+
deferFailure?: boolean;
|
|
123
142
|
}, cancellation?: AbortSignal): Promise<PullRequest | undefined>;
|
|
124
143
|
getAccountForCommit(provider: Provider, token: TokenWithInfo, owner: string, repo: string, rev: string, baseUrl: string, _options?: {
|
|
125
144
|
avatarSize?: number;
|
|
@@ -7,7 +7,9 @@ import __decorate from "../../../../_virtual/@oxc-project+runtime/helpers/esm/de
|
|
|
7
7
|
import { AuthenticationError, RequestClientError, RequestNotFoundError, reportRequestFailure } from "../../../../git/errors.js";
|
|
8
8
|
import { maybeStopWatch } from "../../../../utils/stopwatch.js";
|
|
9
9
|
import { ProviderFetchError, isRateLimitResponse, toRateLimitError } from "../../errors.js";
|
|
10
|
+
import { CommitReadRefusedError, isCommitReadRefusal, isNotFoundResponse } from "../providerErrors.js";
|
|
10
11
|
import { selectBranchPullRequests } from "../utils/providerPaging.js";
|
|
12
|
+
import { encodePathSegment } from "../../utils/domain.utils.js";
|
|
11
13
|
import { fromProviderPullRequest } from "../models.js";
|
|
12
14
|
import { baseProviderApiConfig } from "../apiConfig.js";
|
|
13
15
|
import { normalizeBitbucketServerPullRequest } from "../bitbucket-server/models.js";
|
|
@@ -15,9 +17,22 @@ import { bitbucketIssueStateToState, fromBitbucketIssue, fromBitbucketPullReques
|
|
|
15
17
|
import * as l10n from "@vscode/l10n";
|
|
16
18
|
import { captureReadNodes, copyReadProvenance, createReadCapture } from "@gitkraken/provider-apis/read-provenance";
|
|
17
19
|
//#region ../plus/integrations/src/providers/bitbucket/bitbucket.ts
|
|
18
|
-
/**
|
|
19
|
-
function
|
|
20
|
-
|
|
20
|
+
/** KEEP: reads the message `ProviderFetchError.fromResponse` folds the body into; the body is already consumed. */
|
|
21
|
+
function isCommitLinksAppMissing(ex) {
|
|
22
|
+
const original = ex instanceof Error && "original" in ex ? ex.original : ex;
|
|
23
|
+
return original instanceof ProviderFetchError && original.message.includes("Invalid or unknown installation");
|
|
24
|
+
}
|
|
25
|
+
var BitbucketCommitNotFoundError = class extends CommitReadRefusedError {};
|
|
26
|
+
var BitbucketCommitPullRequestsUnindexedError = class extends CommitReadRefusedError {};
|
|
27
|
+
var BitbucketCommitLinksAppMissingError = class extends CommitReadRefusedError {
|
|
28
|
+
commitUrl;
|
|
29
|
+
constructor(commitUrl) {
|
|
30
|
+
super(`Bitbucket lists a commit's pull requests only once the Bitbucket pull request commit links app is installed; choosing 'Go to pull request' on a commit (${commitUrl}) installs it.`);
|
|
31
|
+
this.commitUrl = commitUrl;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function indexedRepositoryKey(token, owner, repo) {
|
|
35
|
+
return `${token.accessToken}|${`${owner}/${repo}`.toLowerCase()}`;
|
|
21
36
|
}
|
|
22
37
|
var BitbucketApi = class {
|
|
23
38
|
config;
|
|
@@ -29,7 +44,24 @@ var BitbucketApi = class {
|
|
|
29
44
|
dispose() {
|
|
30
45
|
this._disposable?.dispose();
|
|
31
46
|
}
|
|
32
|
-
resetCaches() {
|
|
47
|
+
resetCaches() {
|
|
48
|
+
this._indexedRepositories.clear();
|
|
49
|
+
}
|
|
50
|
+
_indexedRepositories = /* @__PURE__ */ new Set();
|
|
51
|
+
isRepositoryIndexed(token, owner, repo) {
|
|
52
|
+
return this._indexedRepositories.has(indexedRepositoryKey(token, owner, repo));
|
|
53
|
+
}
|
|
54
|
+
_commitLinksAppNoticeShownFor = /* @__PURE__ */ new Set();
|
|
55
|
+
/**
|
|
56
|
+
* Shows the notice that the pull request commit links app must be installed once per workspace for the life of
|
|
57
|
+
* this client.
|
|
58
|
+
*/
|
|
59
|
+
notifyCommitLinksAppMissing(owner, commitWebUrl) {
|
|
60
|
+
const workspace = owner.toLowerCase();
|
|
61
|
+
if (this._commitLinksAppNoticeShownFor.has(workspace)) return;
|
|
62
|
+
this._commitLinksAppNoticeShownFor.add(workspace);
|
|
63
|
+
this.config.onBitbucketCommitLinksAppMissing?.(commitWebUrl);
|
|
64
|
+
}
|
|
33
65
|
async getPullRequestForBranch(provider, token, owner, repo, branch, baseUrl) {
|
|
34
66
|
const scope = getScopedLogger();
|
|
35
67
|
const response = await this.request(provider, token, baseUrl, `repositories/${owner}/${repo}/pullrequests?q=source.branch.name="${branch}"&fields=%2Bvalues.reviewers,%2Bvalues.participants`, { method: "GET" }, scope);
|
|
@@ -337,19 +369,22 @@ var BitbucketApi = class {
|
|
|
337
369
|
getRepository(provider, token, owner, repo, baseUrl, scope, cancellation) {
|
|
338
370
|
return this.request(provider, token, baseUrl, `repositories/${owner}/${repo}`, { method: "GET" }, scope, cancellation);
|
|
339
371
|
}
|
|
340
|
-
async getServerPullRequestForCommit(provider, token, owner, repo, rev, baseUrl,
|
|
372
|
+
async getServerPullRequestForCommit(provider, token, owner, repo, rev, baseUrl, options, cancellation) {
|
|
341
373
|
const scope = getScopedLogger();
|
|
342
374
|
try {
|
|
343
|
-
const
|
|
375
|
+
const response = await this.request(provider, token, baseUrl, `projects/${encodePathSegment(owner)}/repos/${encodePathSegment(repo)}/commits/${rev}/pull-requests`, { method: "GET" }, scope, cancellation, options?.deferFailure);
|
|
376
|
+
if (response?.values == null) throw new Error(`Bitbucket returned no pull requests for ${owner}/${repo}@${rev}`);
|
|
377
|
+
const prResponse = response.values.reduce((acc, pr) => !acc || pr.updatedDate > acc.updatedDate ? pr : acc, void 0);
|
|
344
378
|
if (!prResponse) return void 0;
|
|
345
379
|
const providersPr = normalizeBitbucketServerPullRequest(prResponse);
|
|
346
380
|
return fromProviderPullRequest(providersPr, provider, { projection: "point" });
|
|
347
381
|
} catch (ex) {
|
|
348
|
-
|
|
349
|
-
|
|
382
|
+
if (isNotFoundResponse(ex)) return void 0;
|
|
383
|
+
if (!options?.deferFailure && isCommitReadRefusal(ex)) throw new CommitReadRefusedError(ex.message, ex);
|
|
384
|
+
throw ex;
|
|
350
385
|
}
|
|
351
386
|
}
|
|
352
|
-
async getPullRequestForCommit(provider, token, owner, repo, rev, baseUrl,
|
|
387
|
+
async getPullRequestForCommit(provider, token, owner, repo, rev, baseUrl, options, cancellation) {
|
|
353
388
|
const scope = getScopedLogger();
|
|
354
389
|
try {
|
|
355
390
|
const fieldsParam = encodeURIComponent([
|
|
@@ -361,19 +396,24 @@ var BitbucketApi = class {
|
|
|
361
396
|
"+values.source.branch.*",
|
|
362
397
|
"+values.source.commit.*"
|
|
363
398
|
].join(","));
|
|
364
|
-
const
|
|
399
|
+
const response = await this.request(provider, token, baseUrl, `repositories/${encodePathSegment(owner)}/${encodePathSegment(repo)}/commit/${rev}/pullrequests?fields=${fieldsParam}`, { method: "GET" }, scope, cancellation, options?.deferFailure);
|
|
400
|
+
if (response?.values == null || response.repo_indexed === false) throw new BitbucketCommitPullRequestsUnindexedError(`Bitbucket is still indexing the pull requests of ${owner}/${repo}`);
|
|
401
|
+
this._indexedRepositories.add(indexedRepositoryKey(token, owner, repo));
|
|
402
|
+
const pr = response.values.reduce((acc, pr) => !acc || pr.updated_on > acc.updated_on ? pr : acc, void 0);
|
|
365
403
|
if (!pr) return void 0;
|
|
366
404
|
return fromBitbucketPullRequest(pr, provider, { projection: "point" });
|
|
367
405
|
} catch (ex) {
|
|
368
|
-
if (ex
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
406
|
+
if (isCommitLinksAppMissing(ex)) {
|
|
407
|
+
const commitWebUrl = `https://bitbucket.org/${owner}/${repo}/commits/${rev}`;
|
|
408
|
+
if (!options?.deferFailure) this.notifyCommitLinksAppMissing(owner, commitWebUrl);
|
|
409
|
+
throw new BitbucketCommitLinksAppMissingError(commitWebUrl);
|
|
374
410
|
}
|
|
375
|
-
|
|
376
|
-
|
|
411
|
+
if (isNotFoundResponse(ex)) {
|
|
412
|
+
if (!options?.deferFailure && this.isRepositoryIndexed(token, owner, repo)) return void 0;
|
|
413
|
+
throw new BitbucketCommitNotFoundError(`Bitbucket has no such commit in ${owner}/${repo}, or no such repository`, ex);
|
|
414
|
+
}
|
|
415
|
+
if (!options?.deferFailure && isCommitReadRefusal(ex)) throw new CommitReadRefusedError(ex.message, ex);
|
|
416
|
+
throw ex;
|
|
377
417
|
}
|
|
378
418
|
}
|
|
379
419
|
async getAccountForCommit(provider, token, owner, repo, rev, baseUrl, _options, cancellation) {
|
|
@@ -627,6 +667,6 @@ function createBitbucketApi(ctx) {
|
|
|
627
667
|
});
|
|
628
668
|
}
|
|
629
669
|
//#endregion
|
|
630
|
-
export { BitbucketApi, createBitbucketApi };
|
|
670
|
+
export { BitbucketApi, BitbucketCommitLinksAppMissingError, BitbucketCommitNotFoundError, BitbucketCommitPullRequestsUnindexedError, createBitbucketApi };
|
|
631
671
|
|
|
632
672
|
//# sourceMappingURL=bitbucket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitbucket.js","names":["Logger"],"sources":["../../../../../../plus/integrations/src/providers/bitbucket/bitbucket.ts"],"sourcesContent":["import { captureReadNodes, copyReadProvenance, createReadCapture } from '@gitkraken/provider-apis/read-provenance';\nimport * as l10n from '@vscode/l10n';\nimport { reportRequestFailure } from '@gitlens/git/errors.js';\nimport type { Account, CommitAuthor, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequest, PullRequestProjection } from '@gitlens/git/models/pullRequest.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { trace } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { ScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { equalsIgnoreCase } from '@gitlens/utils/string.js';\nimport type { TokenWithInfo } from '../../authentication/models.js';\nimport type { IntegrationServiceContext } from '../../context.js';\nimport {\n\tAuthenticationError,\n\tAuthenticationErrorReason,\n\tisRateLimitResponse,\n\tProviderFetchError,\n\tRequestClientError,\n\tRequestNotFoundError,\n\ttoRateLimitError,\n} from '../../errors.js';\nimport type { PullRequestEtagInclude } from '../../models/integration.js';\nimport type { ProviderApiConfig } from '../apiConfig.js';\nimport { baseProviderApiConfig } from '../apiConfig.js';\nimport type { BitbucketServerCommit, BitbucketServerPullRequest } from '../bitbucket-server/models.js';\nimport { normalizeBitbucketServerPullRequest } from '../bitbucket-server/models.js';\nimport { fromProviderPullRequest } from '../models.js';\nimport { selectBranchPullRequests } from '../utils/providerPaging.js';\nimport type {\n\tBitbucketCommit,\n\tBitbucketIssue,\n\tBitbucketPullRequest,\n\tBitbucketPullRequestEtagNode,\n\tBitbucketPullRequestState,\n\tBitbucketRepository,\n} from './models.js';\nimport {\n\tbitbucketEtagFieldsMaxIds,\n\tbitbucketIssueStateToState,\n\tfromBitbucketIssue,\n\tfromBitbucketPullRequest,\n\tparseRawBitbucketAuthor,\n} from './models.js';\n\n/** `handleRequestError` maps 410 and 422 to the same error as a 404, but only a 404 proves the resource absent. */\nfunction isNotFoundResponse(ex: unknown): boolean {\n\treturn RequestNotFoundError.is(ex) && ex.original instanceof ProviderFetchError && ex.original.status === 404;\n}\n\nexport class BitbucketApi implements Disposable {\n\tprivate readonly _disposable: Disposable | undefined;\n\n\tconstructor(private readonly config: ProviderApiConfig) {\n\t\tthis._disposable = config.onConfigChanged?.(() => this.resetCaches());\n\t}\n\n\tdispose(): void {\n\t\tthis._disposable?.dispose();\n\t}\n\n\tprivate resetCaches(): void {}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequestForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketPullRequest[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}/pullrequests?q=source.branch.name=\"${branch}\"&fields=%2Bvalues.reviewers,%2Bvalues.participants`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn fromBitbucketPullRequest(response.values[0], provider, { projection: 'point' });\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketServerPullRequest[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`projects/${owner}/repos/${repo}/pull-requests?at=refs/heads/${branch}&direction=OUTGOING&state=ALL`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst providersPr = normalizeBitbucketServerPullRequest(response.values[0]);\n\t\tconst gitlensPr = fromProviderPullRequest(providersPr, provider, { projection: 'point' });\n\t\treturn gitlensPr;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, userUuid, owner, repo, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tuserUuid: userUuid,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getUsersIssuesForRepo(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tuserUuid: string,\n\t\towner: string,\n\t\trepo: string,\n\t\tbaseUrl: string,\n\t): Promise<Issue[] | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst query = encodeURIComponent(`assignee.uuid=\"${userUuid}\" OR reporter.uuid=\"${userUuid}\"`);\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketIssue[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}/issues?q=${query}`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn response.values.map(issue => fromBitbucketIssue(issue, provider, 'account'));\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getIssue(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t): Promise<Issue | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.request<BitbucketIssue>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/issues/${id}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\tif (response) {\n\t\t\t\treturn fromBitbucketIssue(response, provider, 'point');\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getIssueOrPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\ttype?: IssueOrPullRequestType;\n\t\t},\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (options?.type === undefined || options?.type === 'pullrequest') {\n\t\t\ttry {\n\t\t\t\tconst pr = await this.getPullRequest(provider, token, owner, repo, id, baseUrl);\n\t\t\t\tif (pr != null) return pr;\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (options?.type === undefined || options?.type === 'issue') {\n\t\t\ttry {\n\t\t\t\tconst issueResponse = await this.request<BitbucketIssue>(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\t`repositories/${owner}/${repo}/issues/${id}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t},\n\t\t\t\t\tscope,\n\t\t\t\t);\n\n\t\t\t\tif (issueResponse) {\n\t\t\t\t\tconst result: IssueOrPullRequest = {\n\t\t\t\t\t\tid: issueResponse.id.toString(),\n\t\t\t\t\t\ttype: 'issue',\n\t\t\t\t\t\tnodeId: issueResponse.id.toString(),\n\t\t\t\t\t\tprovider: provider,\n\t\t\t\t\t\tcreatedDate: new Date(issueResponse.created_on),\n\t\t\t\t\t\tupdatedDate: new Date(issueResponse.updated_on),\n\t\t\t\t\t\tstate: bitbucketIssueStateToState(issueResponse.state),\n\t\t\t\t\t\tclosed: issueResponse.state === 'closed',\n\t\t\t\t\t\ttitle: issueResponse.title,\n\t\t\t\t\t\turl: issueResponse.links.html.href,\n\t\t\t\t\t};\n\t\t\t\t\treturn copyReadProvenance(result, issueResponse);\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestById(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\treturn await this.getServerPullRequest(provider, token, owner, repo, id, baseUrl);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * A Bitbucket Cloud pull request by id. Strict, unlike {@link getIssueOrPullRequest}: `undefined` means a 404,\n\t * and every other failure throws, so the answer can be cached as a proven absence.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t\t/** The calling read, stamped on the row. */\n\t\t\tprojection?: PullRequestProjection;\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst pr = await this.request<BitbucketPullRequest>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/pullrequests/${id}?fields=%2Bvalues.reviewers,%2Bvalues.participants`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions?.deferFailure,\n\t\t\t);\n\t\t\tif (pr == null) throw new Error(`Bitbucket returned no pull request for ${owner}/${repo}#${id}`);\n\n\t\t\treturn fromBitbucketPullRequest(pr, provider, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tprojection: options?.projection,\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * The change state of pull requests `ids` in `owner/repo` — the cheap check behind the batch read's etags — in ONE\n\t * request for up to {@link bitbucketEtagFieldsMaxIds} ids, selecting only what {@link getPullRequest}'s row reads\n\t * into its etag (plus the participants and reviewers for the `reviewDecision` include). One entry per input id, in\n\t * order.\n\t *\n\t * Strict like {@link getPullRequest}: `undefined` is a PROVEN ABSENCE, for an id missing from a complete page, or\n\t * for every id when the repository is a 404, as each id's own read would be. A page with more (`next`) and every\n\t * other failure throw. Every state is asked for, since the list answers only open pull requests by default.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, ids) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tids: ids.length,\n\t\t}),\n\t})\n\tpublic async getPullRequestsEtagFields(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tids: readonly number[],\n\t\tbaseUrl: string,\n\t\toptions: { etagIncludes: readonly PullRequestEtagInclude[]; deferFailure?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<(BitbucketPullRequestEtagNode | undefined)[]> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (!ids.length) return [];\n\t\tif (ids.length > bitbucketEtagFieldsMaxIds) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot read more than ${bitbucketEtagFieldsMaxIds} Bitbucket pull requests in one request`,\n\t\t\t);\n\t\t}\n\n\t\tconst fields = [\n\t\t\t'values.id',\n\t\t\t'values.state',\n\t\t\t'values.draft',\n\t\t\t'values.updated_on',\n\t\t\t'values.source.commit.hash',\n\t\t\t'next',\n\t\t];\n\t\tif (options.etagIncludes.includes('reviewDecision')) {\n\t\t\tfields.push(\n\t\t\t\t'values.participants.approved',\n\t\t\t\t'values.participants.state',\n\t\t\t\t'values.participants.participated_on',\n\t\t\t\t'values.reviewers.uuid',\n\t\t\t);\n\t\t}\n\n\t\tconst params = new URLSearchParams({\n\t\t\tq: `id IN (${ids.join(',')})`,\n\t\t\tfields: fields.join(','),\n\t\t\tpagelen: String(ids.length),\n\t\t});\n\t\tfor (const state of ['OPEN', 'MERGED', 'DECLINED', 'SUPERSEDED'] satisfies BitbucketPullRequestState[]) {\n\t\t\tparams.append('state', state);\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values?: BitbucketPullRequestEtagNode[]; next?: string }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/pullrequests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}`);\n\t\t\t}\n\t\t\tif (response.next != null) throw new Error(`Bitbucket returned a partial page of ${owner}/${repo}`);\n\n\t\t\tconst byId = new Map(response.values.map(pr => [pr.id, pr]));\n\t\t\treturn ids.map(id => byId.get(id));\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return ids.map(() => undefined);\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * A Bitbucket Data Center pull request by id. Strict, unlike {@link getServerPullRequestById}: `undefined` means\n\t * a 404, and every other failure throws, so the answer can be cached as a proven absence.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t\t/** The calling read, stamped on the row. */\n\t\t\tprojection?: PullRequestProjection;\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst pr = await this.request<BitbucketServerPullRequest>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/pull-requests/${id}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions?.deferFailure,\n\t\t\t);\n\t\t\tif (pr == null) throw new Error(`Bitbucket returned no pull request for ${owner}/${repo}#${id}`);\n\n\t\t\treturn fromProviderPullRequest(normalizeBitbucketServerPullRequest(pr), provider, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tprojection: options?.projection,\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * Every Bitbucket Cloud pull request into `owner/repo` whose source is `branch`, in any state, newest first, at\n\t * most `limit`: from the repository itself when `headOwner` is omitted, otherwise from a fork in the `headOwner`\n\t * workspace. Keyed on the source branch NAME, so a merged pull request whose branch was deleted still matches.\n\t *\n\t * Strict like {@link getPullRequest}: a 404 (a missing repository) is an empty list, and every other failure\n\t * throws.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequestsForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t\toptions: {\n\t\t\theadOwner?: string;\n\t\t\tlimit: number;\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t},\n\t): Promise<{ pullRequests: PullRequest[]; truncated: boolean }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst escapedBranch = branch.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n\t\tconst params = new URLSearchParams({\n\t\t\t// Every state named: Bitbucket answers only OPEN pull requests unless asked for the others.\n\t\t\tq: `source.branch.name=\"${escapedBranch}\" AND (state=\"OPEN\" OR state=\"MERGED\" OR state=\"DECLINED\" OR state=\"SUPERSEDED\")`,\n\t\t\tsort: '-updated_on',\n\t\t\tpagelen: String(options.limit),\n\t\t\tfields: '+values.reviewers,+values.participants',\n\t\t});\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketPullRequest[]; next?: string }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/pullrequests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}:${branch}`);\n\t\t\t}\n\n\t\t\tconst headOwner = options.headOwner;\n\t\t\tconst { values, truncated } = selectBranchPullRequests(response.values, {\n\t\t\t\tmatchesHead: pr => {\n\t\t\t\t\tconst source = pr.source.repository;\n\t\t\t\t\tif (pr.source.branch.name !== branch || source == null) return false;\n\t\t\t\t\tif (headOwner == null) return source.uuid === pr.destination.repository.uuid;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\tsource.uuid !== pr.destination.repository.uuid &&\n\t\t\t\t\t\tequalsIgnoreCase(source.full_name.split('/')[0], headOwner)\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tupdatedAt: pr => Date.parse(pr.updated_on),\n\t\t\t\tmap: pr =>\n\t\t\t\t\tfromBitbucketPullRequest(pr, provider, {\n\t\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\t\tprojection: 'batch',\n\t\t\t\t\t}),\n\t\t\t\tlimit: options.limit,\n\t\t\t\tmore: response.next != null,\n\t\t\t});\n\t\t\treturn { pullRequests: values, truncated: truncated };\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return { pullRequests: [], truncated: false };\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * Every Bitbucket Data Center pull request whose source is `branch` in `owner/repo` and whose target is that same\n\t * repository, in any state, newest first, at most `limit`. Asked of the repository the branch lives in\n\t * (`direction=OUTGOING`), which is why a fork's pull requests can't be found through the repository they target.\n\t *\n\t * Strict like {@link getServerPullRequest}: a 404 (a missing repository) is an empty list, and every other\n\t * failure throws.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestsForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t\toptions: { limit: number; currentAccount?: { id: string; username?: string }; deferFailure?: boolean },\n\t): Promise<{ pullRequests: PullRequest[]; truncated: boolean }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst ref = `refs/heads/${branch}`;\n\t\tconst params = new URLSearchParams({\n\t\t\tat: ref,\n\t\t\tdirection: 'OUTGOING',\n\t\t\tstate: 'ALL',\n\t\t\torder: 'NEWEST',\n\t\t\tlimit: String(options.limit),\n\t\t});\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketServerPullRequest[]; isLastPage?: boolean }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${encodeURIComponent(owner)}/repos/${encodeURIComponent(repo)}/pull-requests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}:${branch}`);\n\t\t\t}\n\n\t\t\tconst { values, truncated } = selectBranchPullRequests(response.values, {\n\t\t\t\t// `OUTGOING` also lists this branch's pull requests into other repositories, e.g. the upstream of a\n\t\t\t\t// repository that is itself a fork.\n\t\t\t\tmatchesHead: pr => pr.fromRef.id === ref && pr.fromRef.repository.id === pr.toRef.repository.id,\n\t\t\t\tupdatedAt: pr => pr.updatedDate,\n\t\t\t\tmap: pr =>\n\t\t\t\t\tfromProviderPullRequest(normalizeBitbucketServerPullRequest(pr), provider, {\n\t\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\t\tprojection: 'batch',\n\t\t\t\t\t}),\n\t\t\t\tlimit: options.limit,\n\t\t\t\tmore: response.isLastPage !== true,\n\t\t\t});\n\t\t\treturn { pullRequests: values, truncated: truncated };\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return { pullRequests: [], truncated: false };\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, workspace) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tworkspace: workspace,\n\t\t}),\n\t})\n\tasync getRepositoriesForWorkspace(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tworkspace: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t): Promise<RepositoryMetadata[] | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tinterface BitbucketRepositoriesResponse {\n\t\t\t\tsize: number;\n\t\t\t\tpage: number;\n\t\t\t\tpagelen: number;\n\t\t\t\tnext?: string;\n\t\t\t\tprevious?: string;\n\t\t\t\tvalues: BitbucketRepository[];\n\t\t\t}\n\n\t\t\tconst response = await this.request<BitbucketRepositoriesResponse>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t`repositories/${workspace}?role=contributor&fields=%2Bvalues.parent.workspace`, // field=+<field> must be encoded as field=%2B<field>\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\tif (response) {\n\t\t\t\treturn response.values.map(repo => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tprovider: provider,\n\t\t\t\t\t\towner: repo.workspace.slug,\n\t\t\t\t\t\tname: repo.slug,\n\t\t\t\t\t\tisFork: Boolean(repo.parent),\n\t\t\t\t\t\tparent: repo.parent\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\towner: repo.parent.workspace.slug,\n\t\t\t\t\t\t\t\t\tname: repo.parent.slug,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getRepositoryMetadata(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (response == null) return undefined;\n\n\t\t\tlet parent: RepositoryMetadata['parent'];\n\t\t\tif (response.parent != null) {\n\t\t\t\t// Derive the parent from `full_name` (\"owner/repo\") rather than `parent.workspace`, which is a\n\t\t\t\t// requested field expansion Bitbucket doesn't always honor (an unexpanded parent would otherwise\n\t\t\t\t// throw and null out the whole result).\n\t\t\t\t// `full_name` is \"owner/repo\"; only report a parent when both parts are present so a malformed\n\t\t\t\t// value doesn't produce a parent with an undefined owner/name while `isFork` stays true.\n\t\t\t\tconst [parentOwner, parentName] = response.parent.full_name.split('/');\n\t\t\t\tif (parentOwner && parentName) {\n\t\t\t\t\tparent = { owner: parentOwner, name: parentName };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\towner: response.workspace.slug,\n\t\t\t\tname: response.slug,\n\t\t\t\tisFork: response.parent != null,\n\t\t\t\tparent: parent,\n\t\t\t} satisfies RepositoryMetadata;\n\t\t} catch (ex) {\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getDefaultBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<DefaultBranch | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst name = response?.mainbranch?.name;\n\t\t\tif (name == null) return undefined;\n\n\t\t\treturn { provider: provider, name: name } satisfies DefaultBranch;\n\t\t} catch (ex) {\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate getRepository(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbaseUrl: string,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<BitbucketRepository | undefined> {\n\t\treturn this.request<BitbucketRepository>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}`,\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getServerPullRequestForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketServerPullRequest[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/commits/${rev}/pull-requests`, //?fields=${fieldsParam}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst prResponse = response?.values?.reduce<BitbucketServerPullRequest | undefined>(\n\t\t\t\t(acc, pr) => (!acc || pr.updatedDate > acc.updatedDate ? pr : acc),\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tif (!prResponse) return undefined;\n\n\t\t\tconst providersPr = normalizeBitbucketServerPullRequest(prResponse);\n\t\t\tconst gitlensPr = fromProviderPullRequest(providersPr, provider, { projection: 'point' });\n\t\t\treturn gitlensPr;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getPullRequestForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst fields = [\n\t\t\t\t'+values.*',\n\t\t\t\t'+values.destination.repository',\n\t\t\t\t'+values.destination.branch.*',\n\t\t\t\t'+values.destination.commit.*',\n\t\t\t\t'+values.source.repository.*',\n\t\t\t\t'+values.source.branch.*',\n\t\t\t\t'+values.source.commit.*',\n\t\t\t];\n\t\t\tconst fieldsParam = encodeURIComponent(fields.join(','));\n\t\t\tconst response = await this.request<{ values: BitbucketPullRequest[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/commit/${rev}/pullrequests?fields=${fieldsParam}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst pr = response?.values?.reduce<BitbucketPullRequest | undefined>(\n\t\t\t\t(acc, pr) => (!acc || pr.updated_on > acc.updated_on ? pr : acc),\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tif (!pr) return undefined;\n\t\t\treturn fromBitbucketPullRequest(pr, provider, { projection: 'point' });\n\t\t} catch (ex) {\n\t\t\tif (ex.original instanceof ProviderFetchError) {\n\t\t\t\tconst json = await ex.original.response.json();\n\t\t\t\tif (json?.error === 'Invalid or unknown installation') {\n\t\t\t\t\t// TODO: In future get it on to home as an warning on the integration itself \"this integration has issues\"\n\t\t\t\t\t// even user suppresses the message it's still visible with some capacity. It's a broader thing to get other errors.\n\t\t\t\t\tconst commitWebUrl = `https://bitbucket.org/${owner}/${repo}/commits/${rev}`;\n\t\t\t\t\tthis.config.onBitbucketCommitLinksAppMissing?.(commitWebUrl);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getAccountForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst commit = await this.request<BitbucketCommit>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/commit/${rev}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!commit) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { name, email } = parseRawBitbucketAuthor(commit.author.raw);\n\t\t\tconst commitAuthor: CommitAuthor = {\n\t\t\t\tprovider: provider,\n\t\t\t\tid: commit.author.user?.account_id,\n\t\t\t\tusername: commit.author.user?.nickname,\n\t\t\t\tname: commit.author.user?.display_name || name,\n\t\t\t\temail: email,\n\t\t\t\tavatarUrl: commit.author.user?.links?.avatar?.href,\n\t\t\t};\n\t\t\tif (commitAuthor.id != null && commitAuthor.username != null) {\n\t\t\t\treturn {\n\t\t\t\t\t...commitAuthor,\n\t\t\t\t\tid: commitAuthor.id,\n\t\t\t\t} satisfies Account;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...commitAuthor,\n\t\t\t\tid: undefined,\n\t\t\t\tusername: undefined,\n\t\t\t} satisfies UnidentifiedAuthor;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getServerAccountForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst commit = await this.request<BitbucketServerCommit>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/commits/${rev}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!commit?.author) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (commit.author.id != null) {\n\t\t\t\treturn {\n\t\t\t\t\tprovider: provider,\n\t\t\t\t\tid: commit.author.id.toString(),\n\t\t\t\t\tusername: commit.author.name,\n\t\t\t\t\tname: commit.author.name,\n\t\t\t\t\temail: commit.author.emailAddress,\n\t\t\t\t\tavatarUrl: commit.author?.avatarUrl,\n\t\t\t\t} satisfies Account;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\tid: undefined,\n\t\t\t\tusername: undefined,\n\t\t\t\tname: commit.author.name,\n\t\t\t\temail: commit.author.emailAddress,\n\t\t\t\tavatarUrl: undefined,\n\t\t\t} satisfies UnidentifiedAuthor;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async request<T>(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tbaseUrl: string,\n\t\troute: string,\n\t\toptions?: { method: RequestInit['method'] } & Record<string, unknown>,\n\t\tscope?: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal | undefined,\n\t\tdeferFailure?: boolean,\n\t): Promise<T | undefined> {\n\t\tconst { accessToken } = token;\n\t\tconst url = `${baseUrl}/${route}`;\n\n\t\tlet rsp: Response;\n\t\ttry {\n\t\t\tconst sw = maybeStopWatch(`[BITBUCKET] ${options?.method ?? 'GET'} ${url}`, { log: { onlyExit: true } });\n\n\t\t\ttry {\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\tconst capture = createReadCapture();\n\t\t\t\trsp = await this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () =>\n\t\t\t\t\tthis.config.fetch(url, {\n\t\t\t\t\t\theaders: { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' },\n\t\t\t\t\t\tsignal: cancellation,\n\t\t\t\t\t\t...options,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (rsp.ok) {\n\t\t\t\t\treturn captureReadNodes(await rsp.json(), capture) as T;\n\t\t\t\t}\n\n\t\t\t\t// Reads the body so the 403 branch below can tell a throttled request from a permission failure.\n\t\t\t\tthrow await ProviderFetchError.fromResponse('Bitbucket', rsp);\n\t\t\t} finally {\n\t\t\t\tsw?.stop();\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof ProviderFetchError || ex.name === 'AbortError') {\n\t\t\t\tthis.handleRequestError(provider, token, ex, scope, deferFailure);\n\t\t\t} else if (Logger.isDebugging) {\n\t\t\t\tthis.config.onError?.(`Bitbucket request failed: ${ex.message}`);\n\t\t\t}\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tprivate handleRequestError(\n\t\tprovider: Provider | undefined,\n\t\ttoken: TokenWithInfo,\n\t\tex: ProviderFetchError | (Error & { name: 'AbortError' }),\n\t\tscope: ScopedLogger | undefined,\n\t\tdeferFailure: boolean | undefined,\n\t): void {\n\t\tif (ex.name === 'AbortError' || !(ex instanceof ProviderFetchError)) throw new CancellationError(ex);\n\n\t\tconst { accessToken, ...tokenInfo } = token;\n\t\tswitch (ex.status) {\n\t\t\tcase 404: // Not found\n\t\t\tcase 410: // Gone\n\t\t\tcase 422: // Unprocessable Entity\n\t\t\t\tthrow new RequestNotFoundError(ex);\n\t\t\tcase 401: // Unauthorized\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, ex);\n\t\t\tcase 429: // Too Many Requests\n\t\t\t\tthrow toRateLimitError(ex, accessToken);\n\t\t\tcase 403: // Forbidden\n\t\t\t\t// Bitbucket returns 403 for both a permission failure and a throttled request (\"API rate limit\n\t\t\t\t// exceeded\"), so the message is the discriminant. Reporting a throttle as `auth` would prompt the\n\t\t\t\t// user to re-authenticate a healthy connection instead of retrying (see `isRateLimitResponse`).\n\t\t\t\tif (isRateLimitResponse(ex)) throw toRateLimitError(ex, accessToken);\n\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Forbidden, ex);\n\t\t\tcase 500: // Internal Server Error\n\t\t\t\tscope?.error(ex);\n\t\t\t\tif (ex.response != null) {\n\t\t\t\t\treportRequestFailure(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tex,\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tthis.config.onRequestFailed?.(\n\t\t\t\t\t\t\t\tprovider == null || provider.id === 'bitbucket'\n\t\t\t\t\t\t\t\t\t? l10n.t(\n\t\t\t\t\t\t\t\t\t\t\t'{0} failed to respond and might be experiencing issues. Please visit the [Bitbucket status page](https://bitbucket.status.atlassian.com/) for more information.',\n\t\t\t\t\t\t\t\t\t\t\tprovider?.name ?? 'Bitbucket',\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t: l10n.t('{0} failed to respond and might be experiencing issues.', provider.name),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tdeferFailure,\n\t\t\t\t\t\ttoken.connectionId,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase 502: // Bad Gateway\n\t\t\t\tscope?.error(ex);\n\t\t\t\t// TODO: Learn the Bitbucket API docs and put it in order:\n\t\t\t\t// if (ex.message.includes('timeout')) {\n\t\t\t\t// \tprovider?.trackRequestException();\n\t\t\t\t// \tvoid showIntegrationRequestTimedOutWarningMessage(provider?.name ?? 'Bitbucket');\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (ex.status >= 400 && ex.status < 500) throw new RequestClientError(ex);\n\t\t\t\tbreak;\n\t\t}\n\n\t\tscope?.error(ex);\n\t\tif (Logger.isDebugging) {\n\t\t\tthis.config.onError?.(\n\t\t\t\t`Bitbucket request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Wires a {@link BitbucketApi} from the full runtime context, mapping `ctx` down to the narrow config. */\nexport function createBitbucketApi(ctx: IntegrationServiceContext): BitbucketApi {\n\tconst config: ProviderApiConfig = {\n\t\t...baseProviderApiConfig(ctx),\n\t\tonBitbucketCommitLinksAppMissing: revLink => ctx.hooks?.ui?.onBitbucketCommitLinksAppMissing?.(revLink),\n\t};\n\n\treturn new BitbucketApi(config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqDA,SAAS,mBAAmB,IAAsB;CACjD,OAAO,qBAAqB,GAAG,EAAE,KAAK,GAAG,oBAAoB,sBAAsB,GAAG,SAAS,WAAW;AAC3G;AAEA,IAAa,eAAb,MAAgD;CAGlB;CAF7B;CAEA,YAAY,QAA4C;EAA3B,KAAA,SAAA;EAC5B,KAAK,cAAc,OAAO,wBAAwB,KAAK,YAAY,CAAC;CACrE;CAEA,UAAgB;EACf,KAAK,aAAa,QAAQ;CAC3B;CAEA,cAA4B,CAAC;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AAU;CAC1B;CACD;CACD;CACI;AACV,GACD,CAAC,CAAA,GAAA,aAAA,WAAA,uBAAA,IAAA;AAyDA,WAAA,CAAA,MAAM,EACN,OAAO,UAAU,OAAO,OAAO,MAAM,KAAK,aAAa;CACtD,UAAU,SAAS;CACnB,OAAO,UAAU,MAAM,UAAU;CAC1B;CACD;CACD;CACI;AACV,GACD,CAAC,CAAA,GAAA,aAAA,WAAA,6BAAA,IAAA;;AA6KF,SAAgB,mBAAmB,KAA8C;CAMhF,OAAO,IAAI,aAAa;EAJvB,GAAG,sBAAsB,GAAG;EAC5B,mCAAkC,YAAW,IAAI,OAAO,IAAI,mCAAmC,OAAO;CAG/E,CAAM;AAC/B"}
|
|
1
|
+
{"version":3,"file":"bitbucket.js","names":["Logger"],"sources":["../../../../../../plus/integrations/src/providers/bitbucket/bitbucket.ts"],"sourcesContent":["import { captureReadNodes, copyReadProvenance, createReadCapture } from '@gitkraken/provider-apis/read-provenance';\nimport * as l10n from '@vscode/l10n';\nimport { reportRequestFailure } from '@gitlens/git/errors.js';\nimport type { Account, CommitAuthor, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequest, PullRequestProjection } from '@gitlens/git/models/pullRequest.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport { CancellationError, isCancellationError } from '@gitlens/utils/cancellation.js';\nimport { trace } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { ScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport { equalsIgnoreCase } from '@gitlens/utils/string.js';\nimport type { TokenWithInfo } from '../../authentication/models.js';\nimport type { IntegrationServiceContext } from '../../context.js';\nimport {\n\tAuthenticationError,\n\tAuthenticationErrorReason,\n\tisRateLimitResponse,\n\tProviderFetchError,\n\tRequestClientError,\n\tRequestNotFoundError,\n\ttoRateLimitError,\n} from '../../errors.js';\nimport type { PullRequestEtagInclude } from '../../models/integration.js';\nimport { encodePathSegment } from '../../utils/domain.utils.js';\nimport type { ProviderApiConfig } from '../apiConfig.js';\nimport { baseProviderApiConfig } from '../apiConfig.js';\nimport type { BitbucketServerCommit, BitbucketServerPullRequest } from '../bitbucket-server/models.js';\nimport { normalizeBitbucketServerPullRequest } from '../bitbucket-server/models.js';\nimport { fromProviderPullRequest } from '../models.js';\nimport { CommitReadRefusedError, isCommitReadRefusal, isNotFoundResponse } from '../providerErrors.js';\nimport { selectBranchPullRequests } from '../utils/providerPaging.js';\nimport type {\n\tBitbucketCommit,\n\tBitbucketIssue,\n\tBitbucketPullRequest,\n\tBitbucketPullRequestEtagNode,\n\tBitbucketPullRequestState,\n\tBitbucketRepository,\n} from './models.js';\nimport {\n\tbitbucketEtagFieldsMaxIds,\n\tbitbucketIssueStateToState,\n\tfromBitbucketIssue,\n\tfromBitbucketPullRequest,\n\tparseRawBitbucketAuthor,\n} from './models.js';\n\n/** KEEP: reads the message `ProviderFetchError.fromResponse` folds the body into; the body is already consumed. */\nfunction isCommitLinksAppMissing(ex: unknown): boolean {\n\tconst original: unknown = ex instanceof Error && 'original' in ex ? ex.original : ex;\n\treturn original instanceof ProviderFetchError && original.message.includes('Invalid or unknown installation');\n}\n\nexport class BitbucketCommitNotFoundError extends CommitReadRefusedError {}\n\nexport class BitbucketCommitPullRequestsUnindexedError extends CommitReadRefusedError {}\n\nexport class BitbucketCommitLinksAppMissingError extends CommitReadRefusedError {\n\tconstructor(readonly commitUrl: string) {\n\t\tsuper(\n\t\t\t`Bitbucket lists a commit's pull requests only once the Bitbucket pull request commit links app is installed; choosing 'Go to pull request' on a commit (${commitUrl}) installs it.`,\n\t\t);\n\t}\n}\n\nfunction indexedRepositoryKey(token: TokenWithInfo, owner: string, repo: string): string {\n\treturn `${token.accessToken}|${`${owner}/${repo}`.toLowerCase()}`;\n}\n\nexport class BitbucketApi implements Disposable {\n\tprivate readonly _disposable: Disposable | undefined;\n\n\tconstructor(private readonly config: ProviderApiConfig) {\n\t\tthis._disposable = config.onConfigChanged?.(() => this.resetCaches());\n\t}\n\n\tdispose(): void {\n\t\tthis._disposable?.dispose();\n\t}\n\n\tprivate resetCaches(): void {\n\t\tthis._indexedRepositories.clear();\n\t}\n\n\tprivate readonly _indexedRepositories = new Set<string>();\n\n\tisRepositoryIndexed(token: TokenWithInfo, owner: string, repo: string): boolean {\n\t\treturn this._indexedRepositories.has(indexedRepositoryKey(token, owner, repo));\n\t}\n\n\tprivate readonly _commitLinksAppNoticeShownFor = new Set<string>();\n\n\t/**\n\t * Shows the notice that the pull request commit links app must be installed once per workspace for the life of\n\t * this client.\n\t */\n\tnotifyCommitLinksAppMissing(owner: string, commitWebUrl: string): void {\n\t\tconst workspace = owner.toLowerCase();\n\t\tif (this._commitLinksAppNoticeShownFor.has(workspace)) return;\n\n\t\tthis._commitLinksAppNoticeShownFor.add(workspace);\n\t\tthis.config.onBitbucketCommitLinksAppMissing?.(commitWebUrl);\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequestForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketPullRequest[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}/pullrequests?q=source.branch.name=\"${branch}\"&fields=%2Bvalues.reviewers,%2Bvalues.participants`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn fromBitbucketPullRequest(response.values[0], provider, { projection: 'point' });\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketServerPullRequest[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`projects/${owner}/repos/${repo}/pull-requests?at=refs/heads/${branch}&direction=OUTGOING&state=ALL`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst providersPr = normalizeBitbucketServerPullRequest(response.values[0]);\n\t\tconst gitlensPr = fromProviderPullRequest(providersPr, provider, { projection: 'point' });\n\t\treturn gitlensPr;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, userUuid, owner, repo, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tuserUuid: userUuid,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getUsersIssuesForRepo(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tuserUuid: string,\n\t\towner: string,\n\t\trepo: string,\n\t\tbaseUrl: string,\n\t): Promise<Issue[] | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst query = encodeURIComponent(`assignee.uuid=\"${userUuid}\" OR reporter.uuid=\"${userUuid}\"`);\n\n\t\tconst response = await this.request<{\n\t\t\tvalues: BitbucketIssue[];\n\t\t\tpagelen: number;\n\t\t\tsize: number;\n\t\t\tpage: number;\n\t\t}>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}/issues?q=${query}`,\n\t\t\t{\n\t\t\t\tmethod: 'GET',\n\t\t\t},\n\t\t\tscope,\n\t\t);\n\n\t\tif (!response?.values?.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn response.values.map(issue => fromBitbucketIssue(issue, provider, 'account'));\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getIssue(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t): Promise<Issue | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.request<BitbucketIssue>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/issues/${id}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\tif (response) {\n\t\t\t\treturn fromBitbucketIssue(response, provider, 'point');\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getIssueOrPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\ttype?: IssueOrPullRequestType;\n\t\t},\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (options?.type === undefined || options?.type === 'pullrequest') {\n\t\t\ttry {\n\t\t\t\tconst pr = await this.getPullRequest(provider, token, owner, repo, id, baseUrl);\n\t\t\t\tif (pr != null) return pr;\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (options?.type === undefined || options?.type === 'issue') {\n\t\t\ttry {\n\t\t\t\tconst issueResponse = await this.request<BitbucketIssue>(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\t`repositories/${owner}/${repo}/issues/${id}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t},\n\t\t\t\t\tscope,\n\t\t\t\t);\n\n\t\t\t\tif (issueResponse) {\n\t\t\t\t\tconst result: IssueOrPullRequest = {\n\t\t\t\t\t\tid: issueResponse.id.toString(),\n\t\t\t\t\t\ttype: 'issue',\n\t\t\t\t\t\tnodeId: issueResponse.id.toString(),\n\t\t\t\t\t\tprovider: provider,\n\t\t\t\t\t\tcreatedDate: new Date(issueResponse.created_on),\n\t\t\t\t\t\tupdatedDate: new Date(issueResponse.updated_on),\n\t\t\t\t\t\tstate: bitbucketIssueStateToState(issueResponse.state),\n\t\t\t\t\t\tclosed: issueResponse.state === 'closed',\n\t\t\t\t\t\ttitle: issueResponse.title,\n\t\t\t\t\t\turl: issueResponse.links.html.href,\n\t\t\t\t\t};\n\t\t\t\t\treturn copyReadProvenance(result, issueResponse);\n\t\t\t\t}\n\t\t\t} catch (ex) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestById(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\treturn await this.getServerPullRequest(provider, token, owner, repo, id, baseUrl);\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * A Bitbucket Cloud pull request by id. Strict, unlike {@link getIssueOrPullRequest}: `undefined` means a 404,\n\t * and every other failure throws, so the answer can be cached as a proven absence.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t\t/** The calling read, stamped on the row. */\n\t\t\tprojection?: PullRequestProjection;\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst pr = await this.request<BitbucketPullRequest>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/pullrequests/${id}?fields=%2Bvalues.reviewers,%2Bvalues.participants`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions?.deferFailure,\n\t\t\t);\n\t\t\tif (pr == null) throw new Error(`Bitbucket returned no pull request for ${owner}/${repo}#${id}`);\n\n\t\t\treturn fromBitbucketPullRequest(pr, provider, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tprojection: options?.projection,\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * The change state of pull requests `ids` in `owner/repo` — the cheap check behind the batch read's etags — in ONE\n\t * request for up to {@link bitbucketEtagFieldsMaxIds} ids, selecting only what {@link getPullRequest}'s row reads\n\t * into its etag (plus the participants and reviewers for the `reviewDecision` include). One entry per input id, in\n\t * order.\n\t *\n\t * Strict like {@link getPullRequest}: `undefined` is a PROVEN ABSENCE, for an id missing from a complete page, or\n\t * for every id when the repository is a 404, as each id's own read would be. A page with more (`next`) and every\n\t * other failure throw. Every state is asked for, since the list answers only open pull requests by default.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, ids) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tids: ids.length,\n\t\t}),\n\t})\n\tpublic async getPullRequestsEtagFields(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tids: readonly number[],\n\t\tbaseUrl: string,\n\t\toptions: { etagIncludes: readonly PullRequestEtagInclude[]; deferFailure?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<(BitbucketPullRequestEtagNode | undefined)[]> {\n\t\tconst scope = getScopedLogger();\n\n\t\tif (!ids.length) return [];\n\t\tif (ids.length > bitbucketEtagFieldsMaxIds) {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot read more than ${bitbucketEtagFieldsMaxIds} Bitbucket pull requests in one request`,\n\t\t\t);\n\t\t}\n\n\t\tconst fields = [\n\t\t\t'values.id',\n\t\t\t'values.state',\n\t\t\t'values.draft',\n\t\t\t'values.updated_on',\n\t\t\t'values.source.commit.hash',\n\t\t\t'next',\n\t\t];\n\t\tif (options.etagIncludes.includes('reviewDecision')) {\n\t\t\tfields.push(\n\t\t\t\t'values.participants.approved',\n\t\t\t\t'values.participants.state',\n\t\t\t\t'values.participants.participated_on',\n\t\t\t\t'values.reviewers.uuid',\n\t\t\t);\n\t\t}\n\n\t\tconst params = new URLSearchParams({\n\t\t\tq: `id IN (${ids.join(',')})`,\n\t\t\tfields: fields.join(','),\n\t\t\tpagelen: String(ids.length),\n\t\t});\n\t\tfor (const state of ['OPEN', 'MERGED', 'DECLINED', 'SUPERSEDED'] satisfies BitbucketPullRequestState[]) {\n\t\t\tparams.append('state', state);\n\t\t}\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values?: BitbucketPullRequestEtagNode[]; next?: string }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/pullrequests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}`);\n\t\t\t}\n\t\t\tif (response.next != null) throw new Error(`Bitbucket returned a partial page of ${owner}/${repo}`);\n\n\t\t\tconst byId = new Map(response.values.map(pr => [pr.id, pr]));\n\t\t\treturn ids.map(id => byId.get(id));\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return ids.map(() => undefined);\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * A Bitbucket Data Center pull request by id. Strict, unlike {@link getServerPullRequestById}: `undefined` means\n\t * a 404, and every other failure throws, so the answer can be cached as a proven absence.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, id, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t\t/** The calling read, stamped on the row. */\n\t\t\tprojection?: PullRequestProjection;\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst pr = await this.request<BitbucketServerPullRequest>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/pull-requests/${id}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions?.deferFailure,\n\t\t\t);\n\t\t\tif (pr == null) throw new Error(`Bitbucket returned no pull request for ${owner}/${repo}#${id}`);\n\n\t\t\treturn fromProviderPullRequest(normalizeBitbucketServerPullRequest(pr), provider, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tprojection: options?.projection,\n\t\t\t});\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * Every Bitbucket Cloud pull request into `owner/repo` whose source is `branch`, in any state, newest first, at\n\t * most `limit`: from the repository itself when `headOwner` is omitted, otherwise from a fork in the `headOwner`\n\t * workspace. Keyed on the source branch NAME, so a merged pull request whose branch was deleted still matches.\n\t *\n\t * Strict like {@link getPullRequest}: a 404 (a missing repository) is an empty list, and every other failure\n\t * throws.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getPullRequestsForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t\toptions: {\n\t\t\theadOwner?: string;\n\t\t\tlimit: number;\n\t\t\tcurrentAccount?: { id: string; username?: string };\n\t\t\tdeferFailure?: boolean;\n\t\t},\n\t): Promise<{ pullRequests: PullRequest[]; truncated: boolean }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst escapedBranch = branch.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n\t\tconst params = new URLSearchParams({\n\t\t\t// Every state named: Bitbucket answers only OPEN pull requests unless asked for the others.\n\t\t\tq: `source.branch.name=\"${escapedBranch}\" AND (state=\"OPEN\" OR state=\"MERGED\" OR state=\"DECLINED\" OR state=\"SUPERSEDED\")`,\n\t\t\tsort: '-updated_on',\n\t\t\tpagelen: String(options.limit),\n\t\t\tfields: '+values.reviewers,+values.participants',\n\t\t});\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketPullRequest[]; next?: string }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/pullrequests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}:${branch}`);\n\t\t\t}\n\n\t\t\tconst headOwner = options.headOwner;\n\t\t\tconst { values, truncated } = selectBranchPullRequests(response.values, {\n\t\t\t\tmatchesHead: pr => {\n\t\t\t\t\tconst source = pr.source.repository;\n\t\t\t\t\tif (pr.source.branch.name !== branch || source == null) return false;\n\t\t\t\t\tif (headOwner == null) return source.uuid === pr.destination.repository.uuid;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\tsource.uuid !== pr.destination.repository.uuid &&\n\t\t\t\t\t\tequalsIgnoreCase(source.full_name.split('/')[0], headOwner)\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tupdatedAt: pr => Date.parse(pr.updated_on),\n\t\t\t\tmap: pr =>\n\t\t\t\t\tfromBitbucketPullRequest(pr, provider, {\n\t\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\t\tprojection: 'batch',\n\t\t\t\t\t}),\n\t\t\t\tlimit: options.limit,\n\t\t\t\tmore: response.next != null,\n\t\t\t});\n\t\t\treturn { pullRequests: values, truncated: truncated };\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return { pullRequests: [], truncated: false };\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t/**\n\t * Every Bitbucket Data Center pull request whose source is `branch` in `owner/repo` and whose target is that same\n\t * repository, in any state, newest first, at most `limit`. Asked of the repository the branch lives in\n\t * (`direction=OUTGOING`), which is why a fork's pull requests can't be found through the repository they target.\n\t *\n\t * Strict like {@link getServerPullRequest}: a 404 (a missing repository) is an empty list, and every other\n\t * failure throws.\n\t */\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tpublic async getServerPullRequestsForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\tbaseUrl: string,\n\t\toptions: { limit: number; currentAccount?: { id: string; username?: string }; deferFailure?: boolean },\n\t): Promise<{ pullRequests: PullRequest[]; truncated: boolean }> {\n\t\tconst scope = getScopedLogger();\n\n\t\tconst ref = `refs/heads/${branch}`;\n\t\tconst params = new URLSearchParams({\n\t\t\tat: ref,\n\t\t\tdirection: 'OUTGOING',\n\t\t\tstate: 'ALL',\n\t\t\torder: 'NEWEST',\n\t\t\tlimit: String(options.limit),\n\t\t});\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketServerPullRequest[]; isLastPage?: boolean }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${encodeURIComponent(owner)}/repos/${encodeURIComponent(repo)}/pull-requests?${params.toString()}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tundefined,\n\t\t\t\toptions.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}:${branch}`);\n\t\t\t}\n\n\t\t\tconst { values, truncated } = selectBranchPullRequests(response.values, {\n\t\t\t\t// `OUTGOING` also lists this branch's pull requests into other repositories, e.g. the upstream of a\n\t\t\t\t// repository that is itself a fork.\n\t\t\t\tmatchesHead: pr => pr.fromRef.id === ref && pr.fromRef.repository.id === pr.toRef.repository.id,\n\t\t\t\tupdatedAt: pr => pr.updatedDate,\n\t\t\t\tmap: pr =>\n\t\t\t\t\tfromProviderPullRequest(normalizeBitbucketServerPullRequest(pr), provider, {\n\t\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\t\tprojection: 'batch',\n\t\t\t\t\t}),\n\t\t\t\tlimit: options.limit,\n\t\t\t\tmore: response.isLastPage !== true,\n\t\t\t});\n\t\t\treturn { pullRequests: values, truncated: truncated };\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return { pullRequests: [], truncated: false };\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, workspace) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tworkspace: workspace,\n\t\t}),\n\t})\n\tasync getRepositoriesForWorkspace(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tworkspace: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t): Promise<RepositoryMetadata[] | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tinterface BitbucketRepositoriesResponse {\n\t\t\t\tsize: number;\n\t\t\t\tpage: number;\n\t\t\t\tpagelen: number;\n\t\t\t\tnext?: string;\n\t\t\t\tprevious?: string;\n\t\t\t\tvalues: BitbucketRepository[];\n\t\t\t}\n\n\t\t\tconst response = await this.request<BitbucketRepositoriesResponse>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t`repositories/${workspace}?role=contributor&fields=%2Bvalues.parent.workspace`, // field=+<field> must be encoded as field=%2B<field>\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\tif (response) {\n\t\t\t\treturn response.values.map(repo => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tprovider: provider,\n\t\t\t\t\t\towner: repo.workspace.slug,\n\t\t\t\t\t\tname: repo.slug,\n\t\t\t\t\t\tisFork: Boolean(repo.parent),\n\t\t\t\t\t\tparent: repo.parent\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\towner: repo.parent.workspace.slug,\n\t\t\t\t\t\t\t\t\tname: repo.parent.slug,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t};\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn undefined;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getRepositoryMetadata(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (response == null) return undefined;\n\n\t\t\tlet parent: RepositoryMetadata['parent'];\n\t\t\tif (response.parent != null) {\n\t\t\t\t// Derive the parent from `full_name` (\"owner/repo\") rather than `parent.workspace`, which is a\n\t\t\t\t// requested field expansion Bitbucket doesn't always honor (an unexpanded parent would otherwise\n\t\t\t\t// throw and null out the whole result).\n\t\t\t\t// `full_name` is \"owner/repo\"; only report a parent when both parts are present so a malformed\n\t\t\t\t// value doesn't produce a parent with an undefined owner/name while `isFork` stays true.\n\t\t\t\tconst [parentOwner, parentName] = response.parent.full_name.split('/');\n\t\t\t\tif (parentOwner && parentName) {\n\t\t\t\t\tparent = { owner: parentOwner, name: parentName };\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\towner: response.workspace.slug,\n\t\t\t\tname: response.slug,\n\t\t\t\tisFork: response.parent != null,\n\t\t\t\tparent: parent,\n\t\t\t} satisfies RepositoryMetadata;\n\t\t} catch (ex) {\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getDefaultBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<DefaultBranch | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst name = response?.mainbranch?.name;\n\t\t\tif (name == null) return undefined;\n\n\t\t\treturn { provider: provider, name: name } satisfies DefaultBranch;\n\t\t} catch (ex) {\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate getRepository(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbaseUrl: string,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<BitbucketRepository | undefined> {\n\t\treturn this.request<BitbucketRepository>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`repositories/${owner}/${repo}`,\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getServerPullRequestForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t\t/** For a batch read: the batch reports a failed request once rather than each request showing its own. */\n\t\t\tdeferFailure?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst response = await this.request<{ values: BitbucketServerPullRequest[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${encodePathSegment(owner)}/repos/${encodePathSegment(repo)}/commits/${rev}/pull-requests`, //?fields=${fieldsParam}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t\toptions?.deferFailure,\n\t\t\t);\n\t\t\tif (response?.values == null) {\n\t\t\t\tthrow new Error(`Bitbucket returned no pull requests for ${owner}/${repo}@${rev}`);\n\t\t\t}\n\n\t\t\tconst prResponse = response.values.reduce<BitbucketServerPullRequest | undefined>(\n\t\t\t\t(acc, pr) => (!acc || pr.updatedDate > acc.updatedDate ? pr : acc),\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tif (!prResponse) return undefined;\n\n\t\t\tconst providersPr = normalizeBitbucketServerPullRequest(prResponse);\n\t\t\tconst gitlensPr = fromProviderPullRequest(providersPr, provider, { projection: 'point' });\n\t\t\treturn gitlensPr;\n\t\t} catch (ex) {\n\t\t\tif (isNotFoundResponse(ex)) return undefined;\n\n\t\t\tif (!options?.deferFailure && isCommitReadRefusal(ex)) {\n\t\t\t\tthrow new CommitReadRefusedError(ex.message, ex);\n\t\t\t}\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getPullRequestForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t\t/** For a batch read: the batch reports a failed request once rather than each request showing its own. */\n\t\t\tdeferFailure?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst fields = [\n\t\t\t\t'+values.*',\n\t\t\t\t'+values.destination.repository',\n\t\t\t\t'+values.destination.branch.*',\n\t\t\t\t'+values.destination.commit.*',\n\t\t\t\t'+values.source.repository.*',\n\t\t\t\t'+values.source.branch.*',\n\t\t\t\t'+values.source.commit.*',\n\t\t\t];\n\t\t\tconst fieldsParam = encodeURIComponent(fields.join(','));\n\t\t\tconst response = await this.request<{ values?: BitbucketPullRequest[]; repo_indexed?: boolean }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${encodePathSegment(owner)}/${encodePathSegment(repo)}/commit/${rev}/pullrequests?fields=${fieldsParam}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t\toptions?.deferFailure,\n\t\t\t);\n\t\t\t// SEE: api.bitbucket.org/swagger.json getPullrequestsForCommit: 404 is a missing repository or links not yet indexed, 202 is still indexing.\n\t\t\t// SEE: observed 2026-11-22: an unknown commit and a missing repository both answer 404 \"Resource not found\"; an indexed repository answers 200 with repo_indexed true.\n\t\t\tif (response?.values == null || response.repo_indexed === false) {\n\t\t\t\tthrow new BitbucketCommitPullRequestsUnindexedError(\n\t\t\t\t\t`Bitbucket is still indexing the pull requests of ${owner}/${repo}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis._indexedRepositories.add(indexedRepositoryKey(token, owner, repo));\n\n\t\t\tconst pr = response.values.reduce<BitbucketPullRequest | undefined>(\n\t\t\t\t(acc, pr) => (!acc || pr.updated_on > acc.updated_on ? pr : acc),\n\t\t\t\tundefined,\n\t\t\t);\n\t\t\tif (!pr) return undefined;\n\t\t\treturn fromBitbucketPullRequest(pr, provider, { projection: 'point' });\n\t\t} catch (ex) {\n\t\t\tif (isCommitLinksAppMissing(ex)) {\n\t\t\t\tconst commitWebUrl = `https://bitbucket.org/${owner}/${repo}/commits/${rev}`;\n\t\t\t\tif (!options?.deferFailure) {\n\t\t\t\t\t// TODO: In future get it on to home as an warning on the integration itself \"this integration has issues\"\n\t\t\t\t\t// even user suppresses the message it's still visible with some capacity. It's a broader thing to get other errors.\n\t\t\t\t\tthis.notifyCommitLinksAppMissing(owner, commitWebUrl);\n\t\t\t\t}\n\t\t\t\tthrow new BitbucketCommitLinksAppMissingError(commitWebUrl);\n\t\t\t}\n\n\t\t\tif (isNotFoundResponse(ex)) {\n\t\t\t\tif (!options?.deferFailure && this.isRepositoryIndexed(token, owner, repo)) return undefined;\n\n\t\t\t\tthrow new BitbucketCommitNotFoundError(\n\t\t\t\t\t`Bitbucket has no such commit in ${owner}/${repo}, or no such repository`,\n\t\t\t\t\tex,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (!options?.deferFailure && isCommitReadRefusal(ex)) {\n\t\t\t\tthrow new CommitReadRefusedError(ex.message, ex);\n\t\t\t}\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getAccountForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst commit = await this.request<BitbucketCommit>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`repositories/${owner}/${repo}/commit/${rev}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!commit) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst { name, email } = parseRawBitbucketAuthor(commit.author.raw);\n\t\t\tconst commitAuthor: CommitAuthor = {\n\t\t\t\tprovider: provider,\n\t\t\t\tid: commit.author.user?.account_id,\n\t\t\t\tusername: commit.author.user?.nickname,\n\t\t\t\tname: commit.author.user?.display_name || name,\n\t\t\t\temail: email,\n\t\t\t\tavatarUrl: commit.author.user?.links?.avatar?.href,\n\t\t\t};\n\t\t\tif (commitAuthor.id != null && commitAuthor.username != null) {\n\t\t\t\treturn {\n\t\t\t\t\t...commitAuthor,\n\t\t\t\t\tid: commitAuthor.id,\n\t\t\t\t} satisfies Account;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...commitAuthor,\n\t\t\t\tid: undefined,\n\t\t\t\tusername: undefined,\n\t\t\t} satisfies UnidentifiedAuthor;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getServerAccountForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst commit = await this.request<BitbucketServerCommit>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`projects/${owner}/repos/${repo}/commits/${rev}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (!commit?.author) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tif (commit.author.id != null) {\n\t\t\t\treturn {\n\t\t\t\t\tprovider: provider,\n\t\t\t\t\tid: commit.author.id.toString(),\n\t\t\t\t\tusername: commit.author.name,\n\t\t\t\t\tname: commit.author.name,\n\t\t\t\t\temail: commit.author.emailAddress,\n\t\t\t\t\tavatarUrl: commit.author?.avatarUrl,\n\t\t\t\t} satisfies Account;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\tid: undefined,\n\t\t\t\tusername: undefined,\n\t\t\t\tname: commit.author.name,\n\t\t\t\temail: commit.author.emailAddress,\n\t\t\t\tavatarUrl: undefined,\n\t\t\t} satisfies UnidentifiedAuthor;\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async request<T>(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tbaseUrl: string,\n\t\troute: string,\n\t\toptions?: { method: RequestInit['method'] } & Record<string, unknown>,\n\t\tscope?: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal | undefined,\n\t\tdeferFailure?: boolean,\n\t): Promise<T | undefined> {\n\t\tconst { accessToken } = token;\n\t\tconst url = `${baseUrl}/${route}`;\n\n\t\tlet rsp: Response;\n\t\ttry {\n\t\t\tconst sw = maybeStopWatch(`[BITBUCKET] ${options?.method ?? 'GET'} ${url}`, { log: { onlyExit: true } });\n\n\t\t\ttry {\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\tconst capture = createReadCapture();\n\t\t\t\trsp = await this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () =>\n\t\t\t\t\tthis.config.fetch(url, {\n\t\t\t\t\t\theaders: { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' },\n\t\t\t\t\t\tsignal: cancellation,\n\t\t\t\t\t\t...options,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (rsp.ok) {\n\t\t\t\t\treturn captureReadNodes(await rsp.json(), capture) as T;\n\t\t\t\t}\n\n\t\t\t\t// Reads the body so the 403 branch below can tell a throttled request from a permission failure.\n\t\t\t\tthrow await ProviderFetchError.fromResponse('Bitbucket', rsp);\n\t\t\t} finally {\n\t\t\t\tsw?.stop();\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof ProviderFetchError || ex.name === 'AbortError') {\n\t\t\t\tthis.handleRequestError(provider, token, ex, scope, deferFailure);\n\t\t\t} else if (Logger.isDebugging) {\n\t\t\t\tthis.config.onError?.(`Bitbucket request failed: ${ex.message}`);\n\t\t\t}\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tprivate handleRequestError(\n\t\tprovider: Provider | undefined,\n\t\ttoken: TokenWithInfo,\n\t\tex: ProviderFetchError | (Error & { name: 'AbortError' }),\n\t\tscope: ScopedLogger | undefined,\n\t\tdeferFailure: boolean | undefined,\n\t): void {\n\t\tif (ex.name === 'AbortError' || !(ex instanceof ProviderFetchError)) throw new CancellationError(ex);\n\n\t\tconst { accessToken, ...tokenInfo } = token;\n\t\tswitch (ex.status) {\n\t\t\tcase 404: // Not found\n\t\t\tcase 410: // Gone\n\t\t\tcase 422: // Unprocessable Entity\n\t\t\t\tthrow new RequestNotFoundError(ex);\n\t\t\tcase 401: // Unauthorized\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, ex);\n\t\t\tcase 429: // Too Many Requests\n\t\t\t\tthrow toRateLimitError(ex, accessToken);\n\t\t\tcase 403: // Forbidden\n\t\t\t\t// Bitbucket returns 403 for both a permission failure and a throttled request (\"API rate limit\n\t\t\t\t// exceeded\"), so the message is the discriminant. Reporting a throttle as `auth` would prompt the\n\t\t\t\t// user to re-authenticate a healthy connection instead of retrying (see `isRateLimitResponse`).\n\t\t\t\tif (isRateLimitResponse(ex)) throw toRateLimitError(ex, accessToken);\n\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Forbidden, ex);\n\t\t\tcase 500: // Internal Server Error\n\t\t\t\tscope?.error(ex);\n\t\t\t\tif (ex.response != null) {\n\t\t\t\t\treportRequestFailure(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\tex,\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tthis.config.onRequestFailed?.(\n\t\t\t\t\t\t\t\tprovider == null || provider.id === 'bitbucket'\n\t\t\t\t\t\t\t\t\t? l10n.t(\n\t\t\t\t\t\t\t\t\t\t\t'{0} failed to respond and might be experiencing issues. Please visit the [Bitbucket status page](https://bitbucket.status.atlassian.com/) for more information.',\n\t\t\t\t\t\t\t\t\t\t\tprovider?.name ?? 'Bitbucket',\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t: l10n.t('{0} failed to respond and might be experiencing issues.', provider.name),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\tdeferFailure,\n\t\t\t\t\t\ttoken.connectionId,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase 502: // Bad Gateway\n\t\t\t\tscope?.error(ex);\n\t\t\t\t// TODO: Learn the Bitbucket API docs and put it in order:\n\t\t\t\t// if (ex.message.includes('timeout')) {\n\t\t\t\t// \tprovider?.trackRequestException();\n\t\t\t\t// \tvoid showIntegrationRequestTimedOutWarningMessage(provider?.name ?? 'Bitbucket');\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (ex.status >= 400 && ex.status < 500) throw new RequestClientError(ex);\n\t\t\t\tbreak;\n\t\t}\n\n\t\tscope?.error(ex);\n\t\tif (Logger.isDebugging) {\n\t\t\tthis.config.onError?.(\n\t\t\t\t`Bitbucket request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Wires a {@link BitbucketApi} from the full runtime context, mapping `ctx` down to the narrow config. */\nexport function createBitbucketApi(ctx: IntegrationServiceContext): BitbucketApi {\n\tconst config: ProviderApiConfig = {\n\t\t...baseProviderApiConfig(ctx),\n\t\tonBitbucketCommitLinksAppMissing: revLink => ctx.hooks?.ui?.onBitbucketCommitLinksAppMissing?.(revLink),\n\t};\n\n\treturn new BitbucketApi(config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuDA,SAAS,wBAAwB,IAAsB;CACtD,MAAM,WAAoB,cAAc,SAAS,cAAc,KAAK,GAAG,WAAW;CAClF,OAAO,oBAAoB,sBAAsB,SAAS,QAAQ,SAAS,iCAAiC;AAC7G;AAEA,IAAa,+BAAb,cAAkD,uBAAuB,CAAC;AAE1E,IAAa,4CAAb,cAA+D,uBAAuB,CAAC;AAEvF,IAAa,sCAAb,cAAyD,uBAAuB;CAC1D;CAArB,YAAY,WAA4B;EACvC,MACC,2JAA2J,UAAU,eACtK;EAHoB,KAAA,YAAA;CAIrB;AACD;AAEA,SAAS,qBAAqB,OAAsB,OAAe,MAAsB;CACxF,OAAO,GAAG,MAAM,YAAY,GAAG,GAAG,MAAM,GAAG,OAAO,YAAY;AAC/D;AAEA,IAAa,eAAb,MAAgD;CAGlB;CAF7B;CAEA,YAAY,QAA4C;EAA3B,KAAA,SAAA;EAC5B,KAAK,cAAc,OAAO,wBAAwB,KAAK,YAAY,CAAC;CACrE;CAEA,UAAgB;EACf,KAAK,aAAa,QAAQ;CAC3B;CAEA,cAA4B;EAC3B,KAAK,qBAAqB,MAAM;CACjC;CAEA,uCAAwC,IAAI,IAAY;CAExD,oBAAoB,OAAsB,OAAe,MAAuB;EAC/E,OAAO,KAAK,qBAAqB,IAAI,qBAAqB,OAAO,OAAO,IAAI,CAAC;CAC9E;CAEA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I,aAAa;EAJvB,GAAG,sBAAsB,GAAG;EAC5B,mCAAkC,YAAW,IAAI,OAAO,IAAI,mCAAmC,OAAO;CAG/E,CAAM;AAC/B"}
|
|
@@ -86,7 +86,9 @@ export declare class BitbucketServerIntegration extends GitHostIntegration<GitSe
|
|
|
86
86
|
avatarSize?: number;
|
|
87
87
|
include?: IssueOrPullRequestState[];
|
|
88
88
|
}): Promise<PullRequest | undefined>;
|
|
89
|
+
protected getProviderPullRequestForCommitInBatch(session: ProviderAuthenticationSession, repo: BitbucketRepositoryDescriptor, rev: string, cancellation?: AbortSignal): Promise<PullRequest | undefined>;
|
|
89
90
|
protected getProviderPullRequestForCommit(session: ProviderAuthenticationSession, repo: BitbucketRepositoryDescriptor, rev: string): Promise<PullRequest | undefined>;
|
|
91
|
+
private readPullRequestForCommit;
|
|
90
92
|
protected getProviderPullRequest(session: ProviderAuthenticationSession, resource: BitbucketRepositoryDescriptor, id: string): Promise<PullRequest | undefined>;
|
|
91
93
|
protected getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined;
|
|
92
94
|
getRepoInfo(repo: {
|
|
@@ -3,7 +3,7 @@ import { mapSettledBounded, nonnullSettled } from "../../../utils/promise.js";
|
|
|
3
3
|
import { AuthenticationError } from "../../../git/errors.js";
|
|
4
4
|
import { md5 } from "../../../utils/crypto.js";
|
|
5
5
|
import "../../../git/models/pullRequest.js";
|
|
6
|
-
import { getAuthenticatedUser } from "../errors.js";
|
|
6
|
+
import { IntegrationReadUnavailableError, getAuthenticatedUser } from "../errors.js";
|
|
7
7
|
import "../constants.js";
|
|
8
8
|
import { collectProviderPagedResult, flatSettledOrThrow, parsePageCursor, toPageCursor } from "./utils/providerPaging.js";
|
|
9
9
|
import { ProviderPullRequestReviewState, fromProviderPullRequest, providerPullRequestMatchesSearch, providersMetadata, toProviderPullRequestStates } from "./models.js";
|
|
@@ -90,8 +90,16 @@ var BitbucketServerIntegration = class extends GitHostIntegration {
|
|
|
90
90
|
async getProviderPullRequestForBranch(session, repo, branch, _options) {
|
|
91
91
|
return (await this.authenticationService.apis.bitbucket)?.getServerPullRequestForBranch(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, branch, this.apiBaseUrlFor(session));
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
return
|
|
93
|
+
getProviderPullRequestForCommitInBatch(session, repo, rev, cancellation) {
|
|
94
|
+
return this.readPullRequestForCommit(session, repo, rev, true, cancellation);
|
|
95
|
+
}
|
|
96
|
+
getProviderPullRequestForCommit(session, repo, rev) {
|
|
97
|
+
return this.readPullRequestForCommit(session, repo, rev, false);
|
|
98
|
+
}
|
|
99
|
+
async readPullRequestForCommit(session, repo, rev, deferFailure, cancellation) {
|
|
100
|
+
const api = await this.authenticationService.apis.bitbucket;
|
|
101
|
+
if (api == null) throw new IntegrationReadUnavailableError(this.name, "no client to read the pull requests of a commit");
|
|
102
|
+
return api.getServerPullRequestForCommit(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, rev, this.apiBaseUrlFor(session), { deferFailure }, cancellation);
|
|
95
103
|
}
|
|
96
104
|
async getProviderPullRequest(session, resource, id) {
|
|
97
105
|
return (await this.authenticationService.apis.bitbucket)?.getServerPullRequest(this, toTokenWithInfo(this.id, session), resource.owner, resource.name, id, this.apiBaseUrlFor(session), { projection: "point" });
|