@gitkraken/core-gitlens 0.12.0 → 0.14.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 +78 -1
- package/dist/git/cache.d.ts +84 -29
- package/dist/git/cache.js +188 -54
- package/dist/git/cache.js.map +1 -1
- package/dist/git/features.d.ts +1 -1
- package/dist/git/features.js +5 -0
- package/dist/git/features.js.map +1 -1
- package/dist/git/models/branch.d.ts +20 -2
- package/dist/git/models/branch.js +28 -6
- package/dist/git/models/branch.js.map +1 -1
- package/dist/git/models/reference.d.ts +3 -0
- package/dist/git/models/status.js +2 -2
- package/dist/git/models/worktree.d.ts +4 -1
- package/dist/git/models/worktree.js +4 -2
- package/dist/git/models/worktree.js.map +1 -1
- package/dist/git/parsers/diffParser.js +1 -1
- package/dist/git/providers/branches.d.ts +73 -8
- package/dist/git/providers/operations.d.ts +3 -2
- package/dist/git/providers/pausedOperations.d.ts +6 -0
- package/dist/git/providers/provider.d.ts +45 -2
- package/dist/git/providers/revision.d.ts +17 -3
- package/dist/git/providers/status.d.ts +8 -2
- package/dist/git/remotes/azure-devops.js +61 -53
- package/dist/git/remotes/azure-devops.js.map +1 -1
- package/dist/git/run.types.d.ts +12 -0
- package/dist/git/service.d.ts +8 -5
- package/dist/git/service.js +16 -8
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/branch.utils.d.ts +12 -2
- package/dist/git/utils/branch.utils.js +49 -5
- package/dist/git/utils/branch.utils.js.map +1 -1
- package/dist/git/utils/reference.utils.d.ts +1 -0
- package/dist/git/utils/reference.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -2
- package/dist/git/watching/changeEvent.js +17 -3
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/gitDirPoller.d.ts +111 -0
- package/dist/git/watching/gitDirPoller.js +266 -0
- package/dist/git/watching/gitDirPoller.js.map +1 -0
- package/dist/git/watching/provider.d.ts +16 -0
- package/dist/git/watching/watchGroup.d.ts +40 -4
- package/dist/git/watching/watchGroup.js +143 -17
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +70 -1
- package/dist/git/watching/watchService.js +158 -13
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +44 -0
- package/dist/git/watching/watchSession.js +91 -6
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +21 -0
- package/dist/git/watching/watcherPatterns.js +67 -1
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +34 -7
- package/dist/git/watching/worktreeSummary.js +39 -12
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +40 -2
- package/dist/git-cli/cliGitProvider.js +182 -18
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/commandClassifier.d.ts +15 -0
- package/dist/git-cli/exec/commandClassifier.js +48 -2
- package/dist/git-cli/exec/commandClassifier.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +20 -3
- package/dist/git-cli/exec/git.js +63 -19
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/gitQueue.d.ts +2 -0
- package/dist/git-cli/exec/gitQueue.js +2 -1
- package/dist/git-cli/exec/gitQueue.js.map +1 -1
- package/dist/git-cli/exec/indexLock.d.ts +39 -0
- package/dist/git-cli/exec/indexLock.js +160 -0
- package/dist/git-cli/exec/indexLock.js.map +1 -0
- package/dist/git-cli/parsers/blameParser.js +2 -2
- package/dist/git-cli/parsers/refParser.js +4 -2
- package/dist/git-cli/parsers/refParser.js.map +1 -1
- package/dist/git-cli/parsers/statusParser.d.ts +6 -0
- package/dist/git-cli/parsers/statusParser.js +33 -3
- package/dist/git-cli/parsers/statusParser.js.map +1 -1
- package/dist/git-cli/parsers/worktreeParser.js +42 -2
- package/dist/git-cli/parsers/worktreeParser.js.map +1 -1
- package/dist/git-cli/providers/branchRemote.d.ts +14 -0
- package/dist/git-cli/providers/branchRemote.js +36 -0
- package/dist/git-cli/providers/branchRemote.js.map +1 -0
- package/dist/git-cli/providers/branches.d.ts +109 -10
- package/dist/git-cli/providers/branches.js +630 -134
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.js +2 -2
- package/dist/git-cli/providers/config.d.ts +9 -5
- package/dist/git-cli/providers/config.js +58 -25
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.js +1 -1
- package/dist/git-cli/providers/graph.js +9 -6
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +17 -0
- package/dist/git-cli/providers/operations.js +172 -111
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.d.ts +8 -0
- package/dist/git-cli/providers/pausedOperations.js +59 -39
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/refs.js +11 -8
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/remotes.js +19 -10
- package/dist/git-cli/providers/remotes.js.map +1 -1
- package/dist/git-cli/providers/revision.d.ts +6 -2
- package/dist/git-cli/providers/revision.js +38 -12
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/staging.js +39 -14
- package/dist/git-cli/providers/staging.js.map +1 -1
- package/dist/git-cli/providers/stash.d.ts +2 -0
- package/dist/git-cli/providers/stash.js +33 -18
- package/dist/git-cli/providers/stash.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +3 -1
- package/dist/git-cli/providers/status.js +40 -22
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.js +6 -4
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/git-cli/providers/worktrees.d.ts +1 -0
- package/dist/git-cli/providers/worktrees.js +60 -31
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/git-cli/service.d.ts +6 -0
- package/dist/git-cli/service.js +5 -2
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/git-github/providers/github/revision.d.ts +6 -2
- package/dist/plus/git-github/providers/github/revision.js +15 -10
- package/dist/plus/git-github/providers/github/revision.js.map +1 -1
- package/dist/plus/git-github/providers/github/status.d.ts +3 -1
- package/dist/plus/git-github/providers/github/status.js +2 -2
- package/dist/plus/git-github/providers/github/status.js.map +1 -1
- package/dist/plus/integrations/collectionMetadata.d.ts +13 -2
- package/dist/plus/integrations/collectionMetadata.js +14 -2
- package/dist/plus/integrations/collectionMetadata.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +2 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +1 -0
- package/dist/plus/integrations/integrationService.js +1 -1
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +1 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +41 -5
- package/dist/plus/integrations/models/gitHostIntegration.js +106 -29
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/issueReads.d.ts +17 -4
- package/dist/plus/integrations/providers/apiClients.d.ts +2 -0
- package/dist/plus/integrations/providers/apiClients.js +7 -1
- package/dist/plus/integrations/providers/apiClients.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.d.ts +5 -4
- package/dist/plus/integrations/providers/azure/azure.js +36 -76
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.utils.js +20 -17
- package/dist/plus/integrations/providers/azure/azure.utils.js.map +1 -1
- package/dist/plus/integrations/providers/azure/models.d.ts +2 -2
- package/dist/plus/integrations/providers/azure/models.js +4 -4
- package/dist/plus/integrations/providers/azure/models.js.map +1 -1
- package/dist/plus/integrations/providers/azure/workItemStateCategories.d.ts +21 -12
- package/dist/plus/integrations/providers/azure/workItemStateCategories.js +74 -17
- package/dist/plus/integrations/providers/azure/workItemStateCategories.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +44 -0
- package/dist/plus/integrations/providers/azureDevOps.js +108 -17
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +45 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.js +121 -6
- package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
- package/dist/plus/integrations/providers/jira-server.js +18 -14
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jira.js +18 -14
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/models.d.ts +1 -2
- package/dist/plus/integrations/providers/models.js +9 -2
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +7 -17
- package/dist/plus/integrations/providers/providersApi.js +85 -78
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/providers/utils/jiraIssueDrains.d.ts +22 -0
- package/dist/plus/integrations/providers/utils/jiraIssueDrains.js +69 -9
- package/dist/plus/integrations/providers/utils/jiraIssueDrains.js.map +1 -1
- package/dist/plus/integrations/providers/utils/providerPaging.js +8 -2
- package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
- package/dist/plus/integrations/reads/filters.d.ts +3 -3
- package/dist/plus/integrations/reads/filters.js.map +1 -1
- package/dist/plus/integrations/reads/issueBatch.d.ts +2 -1
- package/dist/plus/integrations/reads/issueBatch.js +1 -1
- package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
- package/dist/plus/integrations/reads/issueTracker.js +23 -14
- package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
- package/dist/plus/integrations/reads/issues.d.ts +2 -1
- package/dist/plus/integrations/reads/issues.js +18 -3
- package/dist/plus/integrations/reads/issues.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBatch.js +1 -1
- package/dist/plus/integrations/reads/resolveRepository.js +12 -3
- package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
- package/dist/plus/integrations/reads/warnings.d.ts +11 -4
- package/dist/plus/integrations/reads/warnings.js +15 -5
- package/dist/plus/integrations/reads/warnings.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +36 -2
- package/dist/plus/integrations/results.js +33 -13
- package/dist/plus/integrations/results.js.map +1 -1
- package/dist/utils/promiseCache.d.ts +10 -0
- package/dist/utils/promiseCache.js +17 -2
- package/dist/utils/promiseCache.js.map +1 -1
- package/docs/integrations.md +52 -20
- package/package.json +2 -2
|
@@ -6,6 +6,7 @@ import { ProviderAuthenticationSession, TokenWithInfo } from "../authentication/
|
|
|
6
6
|
import { GitSelfManagedHostIntegrationId } from "../constants.js";
|
|
7
7
|
import { ProviderPullRequestCount, ProviderPullRequestSearchPage } from "../models/pullRequestReads.js";
|
|
8
8
|
import { ProviderAzureResource, ProviderPullRequest, ProviderRepoInput, ProviderReposInput } from "./models.js";
|
|
9
|
+
import { AzureRepositoryDescriptor } from "./azure/models.js";
|
|
9
10
|
import { ProvidersApi } from "./providersApi.js";
|
|
10
11
|
import { ProviderIssueSearchPage, ProviderSearchCount } from "../models/issueReads.js";
|
|
11
12
|
import { IntegrationKey } from "../models/integration.js";
|
|
@@ -13,7 +14,7 @@ import { IntegrationConnectionChangeEvent } from "../integrationService.js";
|
|
|
13
14
|
import { IntegrationAuthenticationService } from "../authentication/integrationAuthenticationService.js";
|
|
14
15
|
import { IntegrationAuthenticationProviderDescriptor } from "../authentication/integrationAuthenticationProvider.js";
|
|
15
16
|
import { IntegrationServiceContext } from "../context.js";
|
|
16
|
-
import { AzureDevOpsIntegrationBase } from "./azureDevOps.js";
|
|
17
|
+
import { AzureDevOpsIntegrationBase, AzureRepositoryTarget } from "./azureDevOps.js";
|
|
17
18
|
//#region ../plus/integrations/src/providers/azureDevOpsServer.d.ts
|
|
18
19
|
export declare class AzureDevOpsServerIntegration extends AzureDevOpsIntegrationBase<GitSelfManagedHostIntegrationId.AzureDevOpsServer> {
|
|
19
20
|
readonly domain: string;
|
|
@@ -43,6 +44,49 @@ export declare class AzureDevOpsServerIntegration extends AzureDevOpsIntegration
|
|
|
43
44
|
};
|
|
44
45
|
/** The base a request below `collection` appends to: the installation, whichever the address already ends in. */
|
|
45
46
|
protected collectionApiBaseUrl(session: ProviderAuthenticationSession, collection: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* The collection names per credential and installation, `undefined` when they couldn't be read. Only a
|
|
49
|
+
* tie-breaker for {@link getRepositoryTarget}, so a failed read is kept (for {@link discoveryCacheTtl}) rather than
|
|
50
|
+
* retried on every repository read; a successful one comes from the organizations, which are kept for the session.
|
|
51
|
+
*/
|
|
52
|
+
private readonly _collectionNames;
|
|
53
|
+
/**
|
|
54
|
+
* Settles which segment of a remote's path is the collection before reading the repository. Behind a virtual
|
|
55
|
+
* directory a repository named after its project is also served as `{vdir}/{collection}/_git/{repo}`, which the
|
|
56
|
+
* remote parser reads as collection `{vdir}` and project `{collection}`; the discovered collections tell the two
|
|
57
|
+
* apart (see {@link resolveAzureProjectlessRepository}). Only a path that reading could address below the connection
|
|
58
|
+
* is settled ({@link isAzureProjectlessCandidate}); any other reads as parsed, without discovery. A connection
|
|
59
|
+
* addressed at a collection discovers only that collection.
|
|
60
|
+
*/
|
|
61
|
+
protected getRepositoryTarget<T extends Pick<AzureRepositoryDescriptor, 'owner' | 'name' | 'project' | 'virtualDirectory'>>(session: ProviderAuthenticationSession, repo: T, cancellation?: AbortSignal): Promise<AzureRepositoryTarget<T>>;
|
|
62
|
+
/**
|
|
63
|
+
* The repository {@link getRepositoryTarget} reads `repo` as, and the base it reads it below: `undefined` when the
|
|
64
|
+
* connection doesn't serve its virtual directory (another installation's) or that directory isn't a valid one.
|
|
65
|
+
*/
|
|
66
|
+
private settleRepository;
|
|
67
|
+
/**
|
|
68
|
+
* Settles each coordinate as {@link getRepositoryTarget} settles a remote's descriptor: a consumer that parses a
|
|
69
|
+
* remote itself splits a project-less path behind a virtual directory the same way. Its owner is placed in the path
|
|
70
|
+
* the connection addresses ({@link getAzureScopeVirtualDirectory}), since a coordinate carries no virtual directory.
|
|
71
|
+
* Only the coordinate is settled, and only to a repository the connection serves: each read places it below the
|
|
72
|
+
* connection itself, so one settling elsewhere reads as given and fails its own read rather than every coordinate's.
|
|
73
|
+
*/
|
|
74
|
+
protected resolveRepositoryCoordinates<T extends {
|
|
75
|
+
owner: string;
|
|
76
|
+
repo: string;
|
|
77
|
+
project?: string;
|
|
78
|
+
}>(session: ProviderAuthenticationSession, coordinates: readonly T[], cancellation?: AbortSignal): Promise<{
|
|
79
|
+
coordinates: readonly T[];
|
|
80
|
+
unsettled?: readonly boolean[];
|
|
81
|
+
}>;
|
|
82
|
+
protected resolveRepositoryInputs(session: ProviderAuthenticationSession, repos: readonly ProviderRepoInput[], cancellation?: AbortSignal): Promise<ProviderRepoInput[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Never rejects. A credential refused the list leaves every path as parsed, as before discovery was asked; any other
|
|
85
|
+
* failure is `undefined`, so a read of a path it could have settled keeps a miss out of the caches (see
|
|
86
|
+
* `readRepository`).
|
|
87
|
+
*/
|
|
88
|
+
private getCollectionNames;
|
|
89
|
+
invalidateDiscoveryCaches(): void;
|
|
46
90
|
/**
|
|
47
91
|
* Only the server level lists the collections: below one, Azure DevOps Server answers `projectCollections` with a
|
|
48
92
|
* 404 page. On that 404 an address that names a collection reads the collection's own connection data, whose
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { CancellationError } from "../../../utils/cancellation.js";
|
|
1
|
+
import { CancellationError, raceWithSignal } from "../../../utils/cancellation.js";
|
|
2
|
+
import { Logger as _logger } from "../../../utils/logger.js";
|
|
2
3
|
import { mapBounded } from "../../../utils/promise.js";
|
|
3
4
|
import { PromiseCache } from "../../../utils/promiseCache.js";
|
|
4
|
-
import { RequestNotFoundError } from "../../../git/errors.js";
|
|
5
|
+
import { AuthenticationError, RequestNotFoundError } from "../../../git/errors.js";
|
|
5
6
|
import { uuid } from "../../../utils/crypto.js";
|
|
6
7
|
import "../../../git/models/pullRequest.js";
|
|
7
8
|
import { IntegrationReadUnavailableError } from "../errors.js";
|
|
@@ -10,7 +11,8 @@ import { toCollectionScopeFailure } from "../collectionMetadata.js";
|
|
|
10
11
|
import { toTokenWithInfo } from "../authentication/models.js";
|
|
11
12
|
import { compareAzurePullRequestSearchPositions, getInvalidAzureSearchDate, isAzureWorkItemSearchFirstPage, parseAzurePullRequestSearchCursor, toAzurePullRequestSearchCursorKey, toAzurePullRequestSearchFilter, toAzurePullRequestSearchPosition, toAzureSearchPageSize } from "./azure/search.js";
|
|
12
13
|
import { fromProviderPullRequest, getProviderPullRequestIdentity, isNativePullRequest, providersMetadata, toProviderPullRequestStates } from "./models.js";
|
|
13
|
-
import {
|
|
14
|
+
import { discoveryCacheTtl } from "./utils/discoveryCache.js";
|
|
15
|
+
import { AzureDevOpsIntegrationBase, findAzureRepositoryApiBaseUrl, getAzureRepositoryApiBaseUrl, getAzureRepositoryIdentity, getAzureScopeVirtualDirectory, isAzureProjectlessCandidate, markMyGroupReviews, resolveAzureProjectlessRepository, sameAzureName, toAzureReviewerReads, uniqueAzureNames } from "./azureDevOps.js";
|
|
14
16
|
//#region ../plus/integrations/src/providers/azureDevOpsServer.ts
|
|
15
17
|
/**
|
|
16
18
|
* Whether `value` can stand as one route segment. Encoding keeps `.` and `..` as they are, and a URL resolves them
|
|
@@ -147,6 +149,115 @@ var AzureDevOpsServerIntegration = class extends AzureDevOpsIntegrationBase {
|
|
|
147
149
|
});
|
|
148
150
|
}
|
|
149
151
|
/**
|
|
152
|
+
* The collection names per credential and installation, `undefined` when they couldn't be read. Only a
|
|
153
|
+
* tie-breaker for {@link getRepositoryTarget}, so a failed read is kept (for {@link discoveryCacheTtl}) rather than
|
|
154
|
+
* retried on every repository read; a successful one comes from the organizations, which are kept for the session.
|
|
155
|
+
*/
|
|
156
|
+
_collectionNames = new PromiseCache({
|
|
157
|
+
capacity: 10,
|
|
158
|
+
createTTL: discoveryCacheTtl
|
|
159
|
+
});
|
|
160
|
+
/**
|
|
161
|
+
* Settles which segment of a remote's path is the collection before reading the repository. Behind a virtual
|
|
162
|
+
* directory a repository named after its project is also served as `{vdir}/{collection}/_git/{repo}`, which the
|
|
163
|
+
* remote parser reads as collection `{vdir}` and project `{collection}`; the discovered collections tell the two
|
|
164
|
+
* apart (see {@link resolveAzureProjectlessRepository}). Only a path that reading could address below the connection
|
|
165
|
+
* is settled ({@link isAzureProjectlessCandidate}); any other reads as parsed, without discovery. A connection
|
|
166
|
+
* addressed at a collection discovers only that collection.
|
|
167
|
+
*/
|
|
168
|
+
async getRepositoryTarget(session, repo, cancellation) {
|
|
169
|
+
const { repo: settled, baseUrl, unsettled } = await this.settleRepository(session, repo, cancellation);
|
|
170
|
+
return {
|
|
171
|
+
repo: settled,
|
|
172
|
+
baseUrl: baseUrl ?? getAzureRepositoryApiBaseUrl(this.apiBaseUrlFor(session), settled),
|
|
173
|
+
unsettled
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The repository {@link getRepositoryTarget} reads `repo` as, and the base it reads it below: `undefined` when the
|
|
178
|
+
* connection doesn't serve its virtual directory (another installation's) or that directory isn't a valid one.
|
|
179
|
+
*/
|
|
180
|
+
async settleRepository(session, repo, cancellation) {
|
|
181
|
+
const baseUrl = this.apiBaseUrlFor(session);
|
|
182
|
+
let unsettled = false;
|
|
183
|
+
if (isAzureProjectlessCandidate(baseUrl, repo)) {
|
|
184
|
+
const names = this._collectionNames.getOrCreate(this.discoveryKey(session), () => this.getCollectionNames(session));
|
|
185
|
+
const collections = await (cancellation != null ? raceWithSignal(names, cancellation) : names);
|
|
186
|
+
if (collections != null) repo = resolveAzureProjectlessRepository(repo, collections);
|
|
187
|
+
else unsettled = true;
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
repo,
|
|
191
|
+
baseUrl: findAzureRepositoryApiBaseUrl(baseUrl, repo),
|
|
192
|
+
unsettled
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Settles each coordinate as {@link getRepositoryTarget} settles a remote's descriptor: a consumer that parses a
|
|
197
|
+
* remote itself splits a project-less path behind a virtual directory the same way. Its owner is placed in the path
|
|
198
|
+
* the connection addresses ({@link getAzureScopeVirtualDirectory}), since a coordinate carries no virtual directory.
|
|
199
|
+
* Only the coordinate is settled, and only to a repository the connection serves: each read places it below the
|
|
200
|
+
* connection itself, so one settling elsewhere reads as given and fails its own read rather than every coordinate's.
|
|
201
|
+
*/
|
|
202
|
+
async resolveRepositoryCoordinates(session, coordinates, cancellation) {
|
|
203
|
+
const baseUrl = this.apiBaseUrlFor(session);
|
|
204
|
+
const targets = await Promise.all(coordinates.map(async (c) => {
|
|
205
|
+
const virtualDirectory = c.project != null ? getAzureScopeVirtualDirectory(baseUrl, c.owner) : void 0;
|
|
206
|
+
if (virtualDirectory == null) return {
|
|
207
|
+
coordinate: c,
|
|
208
|
+
unsettled: false
|
|
209
|
+
};
|
|
210
|
+
const { repo, baseUrl: repoBaseUrl, unsettled } = await this.settleRepository(session, {
|
|
211
|
+
owner: c.owner,
|
|
212
|
+
name: `${c.project}/_git/${c.repo}`,
|
|
213
|
+
project: c.project,
|
|
214
|
+
virtualDirectory: virtualDirectory || void 0
|
|
215
|
+
}, cancellation);
|
|
216
|
+
return {
|
|
217
|
+
coordinate: repo.owner !== c.owner && repoBaseUrl != null ? {
|
|
218
|
+
...c,
|
|
219
|
+
owner: repo.owner,
|
|
220
|
+
project: repo.project
|
|
221
|
+
} : c,
|
|
222
|
+
unsettled
|
|
223
|
+
};
|
|
224
|
+
}));
|
|
225
|
+
return {
|
|
226
|
+
coordinates: targets.map((t) => t.coordinate),
|
|
227
|
+
unsettled: targets.map((t) => t.unsettled)
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
async resolveRepositoryInputs(session, repos, cancellation) {
|
|
231
|
+
const { coordinates } = await this.resolveRepositoryCoordinates(session, repos.map((r) => ({
|
|
232
|
+
...r,
|
|
233
|
+
owner: r.namespace,
|
|
234
|
+
repo: r.name
|
|
235
|
+
})), cancellation);
|
|
236
|
+
return coordinates.map(({ owner, repo, ...r }) => ({
|
|
237
|
+
...r,
|
|
238
|
+
namespace: owner,
|
|
239
|
+
name: repo
|
|
240
|
+
}));
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Never rejects. A credential refused the list leaves every path as parsed, as before discovery was asked; any other
|
|
244
|
+
* failure is `undefined`, so a read of a path it could have settled keeps a miss out of the caches (see
|
|
245
|
+
* `readRepository`).
|
|
246
|
+
*/
|
|
247
|
+
async getCollectionNames(session) {
|
|
248
|
+
try {
|
|
249
|
+
return (await this.getProviderResourcesForUser(session))?.map((r) => r.name);
|
|
250
|
+
} catch (ex) {
|
|
251
|
+
if (ex instanceof AuthenticationError) return [];
|
|
252
|
+
_logger.debug(`${this.name}: collections at ${this.apiBaseUrlFor(session)} couldn't be read to place a repository path`, ex);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
invalidateDiscoveryCaches() {
|
|
257
|
+
super.invalidateDiscoveryCaches();
|
|
258
|
+
this._collectionNames.clear();
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
150
261
|
* Only the server level lists the collections: below one, Azure DevOps Server answers `projectCollections` with a
|
|
151
262
|
* 404 page. On that 404 an address that names a collection reads the collection's own connection data, whose
|
|
152
263
|
* `webApplicationRelativeDirectory` spells it, and reports it as the one collection visible there.
|
|
@@ -169,7 +280,8 @@ var AzureDevOpsServerIntegration = class extends AzureDevOpsIntegrationBase {
|
|
|
169
280
|
const azure = await this.authenticationService.apis.azure;
|
|
170
281
|
if (azure == null) return void 0;
|
|
171
282
|
this.assertSearchDates(options.criteria);
|
|
172
|
-
const
|
|
283
|
+
const repos = options.repos && await this.resolveRepositoryInputs(session, options.repos, cancellation);
|
|
284
|
+
const scope = await this.resolveWorkItemSearchScope(session, repos, options.org, isAzureWorkItemSearchFirstPage(options.cursor));
|
|
173
285
|
return azure.searchWorkItemsPage(this, toTokenWithInfo(this.id, session), scope.collection, {
|
|
174
286
|
baseUrl: this.collectionApiBaseUrl(session, scope.collection),
|
|
175
287
|
criteria: options.criteria,
|
|
@@ -191,7 +303,8 @@ var AzureDevOpsServerIntegration = class extends AzureDevOpsIntegrationBase {
|
|
|
191
303
|
const tokenWithInfo = toTokenWithInfo(this.id, session);
|
|
192
304
|
return mapBounded(scopes, azureIssueCountConcurrency, (s) => refusalAsCount(async () => {
|
|
193
305
|
this.assertSearchDates(s.criteria);
|
|
194
|
-
const
|
|
306
|
+
const repos = s.repos && await this.resolveRepositoryInputs(session, s.repos, cancellation);
|
|
307
|
+
const scope = await this.resolveWorkItemSearchScope(session, repos, s.org, true);
|
|
195
308
|
return azure.countWorkItems(this, tokenWithInfo, scope.collection, {
|
|
196
309
|
baseUrl: this.collectionApiBaseUrl(session, scope.collection),
|
|
197
310
|
criteria: s.criteria,
|
|
@@ -355,7 +468,8 @@ var AzureDevOpsServerIntegration = class extends AzureDevOpsIntegrationBase {
|
|
|
355
468
|
const relationships = new Set(criteria?.relationships ?? []);
|
|
356
469
|
const wantAuthored = relationships.has("author");
|
|
357
470
|
const wantReviewed = relationships.has("assignee") || relationships.has("review-requested");
|
|
358
|
-
const
|
|
471
|
+
const repos = options.repos && await this.resolveRepositoryInputs(session, options.repos, cancellation);
|
|
472
|
+
const facets = await this.resolvePullRequestSearchFacets(session, repos, options.org);
|
|
359
473
|
const userIds = /* @__PURE__ */ new Map();
|
|
360
474
|
if (relationships.size > 0) for (const collection of uniqueAzureNames(facets.map((f) => f.collection))) {
|
|
361
475
|
const userId = await this.getFilterUserId(session, collection);
|
|
@@ -602,6 +716,7 @@ var AzureDevOpsServerIntegration = class extends AzureDevOpsIntegrationBase {
|
|
|
602
716
|
this._pullRequestSearches.clear();
|
|
603
717
|
this._latestPullRequestSearches.clear();
|
|
604
718
|
this._collectionUserIds.clear();
|
|
719
|
+
this._collectionNames.clear();
|
|
605
720
|
}
|
|
606
721
|
async _requestForCurrentUser(session) {
|
|
607
722
|
const azure = await this.authenticationService.apis.azure;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"azureDevOpsServer.js","names":[],"sources":["../../../../../plus/integrations/src/providers/azureDevOpsServer.ts"],"sourcesContent":["import type { CollectionScopeFailure } from '@gitkraken/provider-apis';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { IssueSearchCriteria } from '@gitlens/git/models/issue.js';\nimport type { PullRequest, PullRequestSearchCriteria, PullRequestSorting } from '@gitlens/git/models/pullRequest.js';\nimport { defaultPullRequestSort } from '@gitlens/git/models/pullRequest.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { uuid } from '@gitlens/utils/crypto.js';\nimport type { Emitter } from '@gitlens/utils/event.js';\nimport { mapBounded } from '@gitlens/utils/promise.js';\nimport { PromiseCache } from '@gitlens/utils/promiseCache.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';\nimport type { ProviderAuthenticationSession, TokenWithInfo } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { GitSelfManagedHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport { IntegrationReadUnavailableError, RequestNotFoundError } from '../errors.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport type {\n\tIntegrationKey,\n\tProviderIssueSearchPage,\n\tProviderPullRequestCount,\n\tProviderPullRequestSearchPage,\n\tProviderSearchCount,\n} from '../models/integration.js';\nimport type { AzureOrganizationDescriptor, AzureProjectDescriptor } from './azure/models.js';\nimport type { AzurePullRequestSearchPosition } from './azure/search.js';\nimport {\n\tcompareAzurePullRequestSearchPositions,\n\tgetInvalidAzureSearchDate,\n\tisAzureWorkItemSearchFirstPage,\n\tparseAzurePullRequestSearchCursor,\n\ttoAzurePullRequestSearchCursorKey,\n\ttoAzurePullRequestSearchFilter,\n\ttoAzurePullRequestSearchPosition,\n\ttoAzureSearchPageSize,\n} from './azure/search.js';\nimport type { AzureReviewerRead } from './azureDevOps.js';\nimport {\n\tAzureDevOpsIntegrationBase,\n\tgetAzureRepositoryApiBaseUrl,\n\tgetAzureRepositoryIdentity,\n\tmarkMyGroupReviews,\n\tsameAzureName,\n\ttoAzureReviewerReads,\n\tuniqueAzureNames,\n} from './azureDevOps.js';\nimport type {\n\tProviderApiCollectionResult,\n\tProviderAzureResource,\n\tProviderPullRequest,\n\tProviderRepoInput,\n\tProviderReposInput,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tgetProviderPullRequestIdentity,\n\tisNativePullRequest,\n\tprovidersMetadata,\n\tPullRequestFilter,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport type { ProvidersApi } from './providersApi.js';\n\n/**\n * Whether `value` can stand as one route segment. Encoding keeps `.` and `..` as they are, and a URL resolves them\n * as directory steps, so a name of either would address a different route than the one named.\n */\nfunction isAzureRouteSegment(value: string): boolean {\n\treturn value.length > 0 && value !== '.' && value !== '..';\n}\n\n/**\n * Runs one scope of a count probe, answering a refusal of THAT scope (see `searchUnavailable`) as the error itself,\n * which the facade reports and drops without failing the scopes around it. Anything else — a rejected credential,\n * a failed request — still rejects, so the batch reports it.\n */\nasync function refusalAsCount<T>(count: () => Promise<T>): Promise<T | IntegrationReadUnavailableError> {\n\ttry {\n\t\treturn await count();\n\t} catch (ex) {\n\t\tif (ex instanceof IntegrationReadUnavailableError) return ex;\n\n\t\tthrow ex;\n\t}\n}\n\nfunction findAzureCollection(\n\tcollections: readonly AzureOrganizationDescriptor[],\n\tname: string,\n): AzureOrganizationDescriptor | undefined {\n\treturn collections.find(c => sameAzureName(c.name, name) || c.id === name);\n}\n\n/**\n * The most pull requests one facet of a filtered pull-request search drains. Azure has no server-side text, date or\n * draft filter and no ordering, so a facet is read in full before any of them apply; past this bound the facet's\n * unread rows could sort anywhere, and the search reports itself truncated instead of guessing.\n */\nconst azurePullRequestSearchFacetLimit = 1000;\n\n/**\n * The page size a facet drain reads. The SDK's own default for both pull request reads, and the size it sizes\n * `$skip` by, so the budget above counts what was actually read.\n */\nconst azurePullRequestSearchPageSize = 100;\n\n/**\n * How many scopes of one work-item count batch query at once. The facade already runs several batches concurrently,\n * so this multiplies with it: kept small, so a large count preview can't flood a self-hosted server.\n */\nconst azureIssueCountConcurrency = 2;\n\n/**\n * How long a drained pull-request search keeps serving its continuation pages after the last one was read, and the\n * most it lives however actively it is paged. A pagination that keeps reading stays on one consistent drain; one\n * left idle, or paged for longer than that, is read again.\n */\nconst pullRequestSearchIdleTtl = 5 * 60 * 1000;\nconst pullRequestSearchMaxTtl = 30 * 60 * 1000;\n\n/**\n * How long a count reuses the drain a search of its query just read. Long enough for a count shown next to the\n * search it previews to agree with it, short enough that a count polled next to an unapplied filter stays live: the\n * window runs from the drain, not from the last count, so polling never extends it.\n */\nconst pullRequestCountReuseTtl = 60 * 1000;\n\n/**\n * Kept unconverted, so each page converts its rows with the projection its own caller asked for: the drain is shared\n * by every page of a query, whatever `summary` each page passes.\n */\ninterface AzurePullRequestSearchRow {\n\tpr: ProviderPullRequest;\n\tproject: AzureProjectDescriptor;\n\tcurrentAccount: { id: string } | undefined;\n\tposition: AzurePullRequestSearchPosition;\n}\n\ninterface AzurePullRequestSearchDrain {\n\trows: AzurePullRequestSearchRow[];\n\ttruncated: boolean;\n\t/** Collections whose groups couldn't be read, so what only those groups review is missing. */\n\tfailures?: CollectionScopeFailure[];\n}\n\n/**\n * Everything that decides a pull-request search's result set and order, as the value its cursor is fingerprinted\n * from. `pageSize` is left out on purpose: it only decides where a page ends, which the keyset cursor already\n * carries.\n */\nfunction toPullRequestSearchQuery(\n\toptions: { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria },\n\tsort: PullRequestSorting,\n): unknown {\n\tconst criteria = options.criteria;\n\treturn {\n\t\trepos: options.repos?.map(r => [r.namespace, r.project ?? null, r.name]),\n\t\torg: options.org ?? null,\n\t\trelationships: [...new Set(criteria?.relationships ?? [])].sort(),\n\t\tstates: [...new Set(criteria?.states ?? [])].sort(),\n\t\ttext: criteria?.text?.trim() ?? null,\n\t\tdraft: criteria?.draft ?? null,\n\t\tupdatedAfter: criteria?.updatedAfter ?? null,\n\t\tcreatedAfter: criteria?.createdAfter ?? null,\n\t\tsort: sort,\n\t};\n}\n\nconst serverMetadata = providersMetadata[GitSelfManagedHostIntegrationId.AzureDevOpsServer];\nconst serverAuthProvider = Object.freeze({ id: serverMetadata.id, scopes: serverMetadata.scopes });\n\nexport class AzureDevOpsServerIntegration extends AzureDevOpsIntegrationBase<GitSelfManagedHostIntegrationId.AzureDevOpsServer> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = serverAuthProvider;\n\treadonly id = GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\tprotected readonly key: IntegrationKey<GitSelfManagedHostIntegrationId.AzureDevOpsServer>;\n\treadonly name: string = 'Azure DevOps Server';\n\n\tconstructor(\n\t\tctx: IntegrationServiceContext,\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tgetProvidersApi: () => Promise<ProvidersApi>,\n\t\tdidChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t\treadonly domain: string,\n\t) {\n\t\tsuper(ctx, authenticationService, getProvidersApi, didChangeConnection);\n\t\tthis.key = `${this.id}:${this.domain}`;\n\t}\n\n\tprotected override apiBaseUrlFor(session: ProviderAuthenticationSession): string {\n\t\treturn this.getSelfManagedApiBaseUrl(session);\n\t}\n\n\t/**\n\t * The credential AND the installation it is used against: one integration instance serves every installation on\n\t * its host (context paths differ, the host doesn't), and the same token connected to two of them must not reuse\n\t * one installation's collections or projects on the other.\n\t */\n\tprotected override discoveryKey(session: ProviderAuthenticationSession): string {\n\t\treturn `${session.accessToken}:${this.apiBaseUrlFor(session)}`;\n\t}\n\n\tprotected override getRepositoriesApiBaseUrl(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos: ProviderReposInput,\n\t): string {\n\t\t// Requests append each repository's organization (its collection), which an address naming that collection\n\t\t// already ends with. Only repositories of a single organization can share one base; mixed ones keep the\n\t\t// address, so another collection's repository stays below it (see `resolveRepository`).\n\t\tconst owners = new Set(repos.map(r => (typeof r === 'object' ? r.namespace : undefined)));\n\t\tconst [owner] = owners;\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\t\treturn owners.size === 1 && owner != null\n\t\t\t? getAzureRepositoryApiBaseUrl(baseUrl, { owner: owner, virtualDirectory: undefined })\n\t\t\t: baseUrl;\n\t}\n\n\tprotected override getApiOptions(\n\t\tsession: ProviderAuthenticationSession,\n\t\tdoNotConvertToPat: boolean = false,\n\t): {\n\t\ttokenWithInfo: TokenWithInfo<GitSelfManagedHostIntegrationId.AzureDevOpsServer>;\n\t\toptions: { isPAT: boolean; baseUrl?: string };\n\t} {\n\t\tconst { options, ...rest } = super.getApiOptions(session, doNotConvertToPat);\n\t\treturn {\n\t\t\t...rest,\n\t\t\toptions: { ...options, baseUrl: this.apiBaseUrlFor(session) },\n\t\t};\n\t}\n\n\tprotected override getCollectionApiOptions(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcollection: string,\n\t): { isPAT: boolean; baseUrl?: string } {\n\t\treturn {\n\t\t\t...super.getCollectionApiOptions(session, collection),\n\t\t\tbaseUrl: this.collectionApiBaseUrl(session, collection),\n\t\t};\n\t}\n\n\t/** The base a request below `collection` appends to: the installation, whichever the address already ends in. */\n\tprotected override collectionApiBaseUrl(session: ProviderAuthenticationSession, collection: string): string {\n\t\treturn getAzureRepositoryApiBaseUrl(this.apiBaseUrlFor(session), {\n\t\t\towner: collection,\n\t\t\tvirtualDirectory: undefined,\n\t\t});\n\t}\n\n\t/**\n\t * Only the server level lists the collections: below one, Azure DevOps Server answers `projectCollections` with a\n\t * 404 page. On that 404 an address that names a collection reads the collection's own connection data, whose\n\t * `webApplicationRelativeDirectory` spells it, and reports it as the one collection visible there.\n\t */\n\tprotected override async requestResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tuserId: string,\n\t): Promise<ProviderAzureResource[] | undefined> {\n\t\ttry {\n\t\t\treturn await super.requestResourcesForUser(session, userId);\n\t\t} catch (ex) {\n\t\t\tif (!(ex instanceof RequestNotFoundError)) throw ex;\n\n\t\t\tconst azure = await this.authenticationService.apis.azure;\n\t\t\tconst addressed = await azure?.getAddressedCollection(\n\t\t\t\tthis,\n\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t);\n\t\t\tif (addressed == null) throw ex;\n\n\t\t\treturn [addressed];\n\t\t}\n\t}\n\n\t/**\n\t * The filtered work-item search: one WIQL query per page over ONE collection, then one detail read for the\n\t * page's slice. See {@link resolveWorkItemSearchScope} for why a search never spans several collections.\n\t */\n\tprotected override async searchProviderIssuesPage(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: {\n\t\t\trepos?: ProviderRepoInput[];\n\t\t\torg?: string;\n\t\t\tcriteria?: IssueSearchCriteria;\n\t\t\tcursor?: string;\n\t\t\tpageSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderIssueSearchPage | undefined> {\n\t\tconst azure = await this.authenticationService.apis.azure;\n\t\tif (azure == null) return undefined;\n\n\t\tthis.assertSearchDates(options.criteria);\n\t\t// A first page re-reads the collection's projects, so a project created since discovery is known before its\n\t\t// work items can turn up in a collection-wide query; a continuation keeps the set its first page resolved.\n\t\t// The facade's page-1 marker (`broadenIssues` retries a failed first page with it) is a first page too.\n\t\tconst scope = await this.resolveWorkItemSearchScope(\n\t\t\tsession,\n\t\t\toptions.repos,\n\t\t\toptions.org,\n\t\t\tisAzureWorkItemSearchFirstPage(options.cursor),\n\t\t);\n\t\treturn azure.searchWorkItemsPage(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tscope.collection,\n\t\t\t{\n\t\t\t\tbaseUrl: this.collectionApiBaseUrl(session, scope.collection),\n\t\t\t\tcriteria: options.criteria,\n\t\t\t\tprojectNames: scope.projectNames,\n\t\t\t\tresolveProject: name => scope.projects.find(p => sameAzureName(p.name, name)),\n\t\t\t\tcursor: options.cursor,\n\t\t\t\tpageSize: options.pageSize,\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * Counts each scope with the WIQL its search would page through, so a count never previews constraints the read\n\t * doesn't apply. A scope this provider refuses (see {@link resolveWorkItemSearchScope}) is answered as that\n\t * refusal, so the facade drops only it; a request failure still fails the batch, which the facade isolates from\n\t * the other batches.\n\t */\n\tprotected override async countProviderIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tscopes: readonly { repos?: ProviderRepoInput[]; org?: string; criteria?: IssueSearchCriteria }[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderSearchCount[] | undefined> {\n\t\tconst azure = await this.authenticationService.apis.azure;\n\t\tif (azure == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapBounded(scopes, azureIssueCountConcurrency, s =>\n\t\t\trefusalAsCount(async () => {\n\t\t\t\tthis.assertSearchDates(s.criteria);\n\t\t\t\t// Re-reads the projects like a first search page does, so a count and the page it previews resolve\n\t\t\t\t// the same project set — a newer project can't be counted by one and refused or missed by the other.\n\t\t\t\tconst scope = await this.resolveWorkItemSearchScope(session, s.repos, s.org, true);\n\t\t\t\treturn azure.countWorkItems(\n\t\t\t\t\tthis,\n\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\tscope.collection,\n\t\t\t\t\t{\n\t\t\t\t\t\tbaseUrl: this.collectionApiBaseUrl(session, scope.collection),\n\t\t\t\t\t\tcriteria: s.criteria,\n\t\t\t\t\t\tprojectNames: scope.projectNames,\n\t\t\t\t\t},\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * The ONE collection a work-item search runs in, and the projects that bound it.\n\t *\n\t * A WIQL query is collection-scoped, and ordering a union of several would need every match's details rather\n\t * than one page's, so a search never spans collections. `org` names the collection; without it the repositories'\n\t * collection is used, and without either the only collection the account can see. Anything else — repositories\n\t * in two collections, or several visible collections and nothing to choose one — is refused rather than\n\t * narrowed to whichever came first.\n\t *\n\t * Repositories bound the query by their PROJECT, since Azure work items belong to projects rather than to\n\t * repositories, and every project must be one the collection actually has: WIQL answers an unknown project name\n\t * with an empty result, which would read as \"nothing matched\".\n\t */\n\tprivate async resolveWorkItemSearchScope(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos: ProviderRepoInput[] | undefined,\n\t\torg: string | undefined,\n\t\trefreshProjects: boolean = false,\n\t): Promise<{ collection: string; projects: AzureProjectDescriptor[]; projectNames?: string[] }> {\n\t\tconst repoCollections = uniqueAzureNames(repos?.map(r => r.namespace) ?? []);\n\t\tif (repoCollections.length > 1) {\n\t\t\tthrow this.searchUnavailable(\n\t\t\t\t'the repositories span several collections; search each collection separately',\n\t\t\t);\n\t\t}\n\t\tif (org && repoCollections.length === 1 && !sameAzureName(org, repoCollections[0])) {\n\t\t\tthrow this.searchUnavailable(`the repositories are not in the '${org}' collection`);\n\t\t}\n\n\t\tconst collections = await this.getSearchCollections(session);\n\t\tconst name = org || repoCollections[0] || (collections.length === 1 ? collections[0].name : undefined);\n\t\tif (name == null) {\n\t\t\tthrow this.searchUnavailable(\n\t\t\t\t`the account can see ${collections.length} collections; pass \\`org\\` to choose the one to search`,\n\t\t\t);\n\t\t}\n\n\t\tconst collection = findAzureCollection(collections, name);\n\t\tif (collection == null) throw this.searchUnavailable(`the '${name}' collection is not visible`);\n\n\t\tconst projects = await this.getSearchProjects(session, collection, refreshProjects);\n\t\tif (!repos?.length) return { collection: collection.name, projects: projects };\n\n\t\tconst projectNames = uniqueAzureNames(\n\t\t\trepos.map(r => {\n\t\t\t\tconst projectName = getAzureRepositoryIdentity({\n\t\t\t\t\towner: r.namespace,\n\t\t\t\t\tname: r.name,\n\t\t\t\t\tproject: r.project,\n\t\t\t\t}).projectName;\n\t\t\t\tif (projectName == null) {\n\t\t\t\t\tthrow this.searchUnavailable(`repository '${r.namespace}/${r.name}' names no project`);\n\t\t\t\t}\n\n\t\t\t\tconst project = projects.find(p => sameAzureName(p.name, projectName));\n\t\t\t\tif (project == null) {\n\t\t\t\t\tthrow this.searchUnavailable(`project '${projectName}' is not visible in '${collection.name}'`);\n\t\t\t\t}\n\n\t\t\t\treturn project.name;\n\t\t\t}),\n\t\t);\n\t\treturn { collection: collection.name, projects: projects, projectNames: projectNames };\n\t}\n\n\t/**\n\t * The filtered pull-request search. Azure's pull request query can only narrow by creator, reviewer, status and\n\t * repository, so every facet is drained (see {@link drainPullRequestSearch}) and the criteria it can't express\n\t * are applied to the complete facets; the union is then ordered and served from a keyset cursor.\n\t */\n\tprotected override async searchProviderPullRequestsPage(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: {\n\t\t\trepos?: ProviderRepoInput[];\n\t\t\torg?: string;\n\t\t\tcriteria?: PullRequestSearchCriteria;\n\t\t\tcursor?: string;\n\t\t\tpageSize?: number;\n\t\t\tsummary?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderPullRequestSearchPage | undefined> {\n\t\tthis.assertSearchDates(options.criteria);\n\t\tconst sort = options.criteria?.sort ?? defaultPullRequestSort;\n\t\tconst query = toPullRequestSearchQuery(options, sort);\n\t\tconst key = toAzurePullRequestSearchCursorKey(query);\n\t\tconst cursor = parseAzurePullRequestSearchCursor(options.cursor, key);\n\t\t// A first page drains fresh, into a drain of its own, and its continuations page through that one: the cache\n\t\t// keeps it alive for as long as the pagination keeps reading it (an access TTL), so rows can't move between\n\t\t// pages, and a later first page of the same query never replaces it. A continuation whose drain is gone is\n\t\t// refused, like an expired work-item snapshot: resuming against a re-drain could skip or repeat a pull request\n\t\t// whose sort date changed. The drain is keyed by credential and installation too, so a cursor handed to\n\t\t// another connection finds nothing and is refused the same way.\n\t\tconst drainId = cursor?.drain ?? uuid();\n\t\tconst drainKey = this.pullRequestSearchCacheKey(session, query, drainId);\n\t\t// A continuation only ever READS its drain: creating one under its id would be the re-drain refused above.\n\t\tconst drainFound =\n\t\t\tcursor != null\n\t\t\t\t? this._pullRequestSearches.get(drainKey)\n\t\t\t\t: this.getPullRequestSearch(this._pullRequestSearches, drainKey, session, options, sort, cancellation);\n\t\tif (drainFound == null) {\n\t\t\tthrow new Error(\n\t\t\t\t'Pull request search results expired or belong to another connection; restart the read without a cursor',\n\t\t\t);\n\t\t}\n\n\t\tconst drain = await drainFound;\n\t\tif (cursor == null) {\n\t\t\t// Also the query's latest drain, which a count of the same query reads rather than draining again. Stored\n\t\t\t// through `getOrCreate`, which applies the cache's capacity and expiry; `set` applies neither.\n\t\t\tconst latestKey = this.pullRequestSearchCacheKey(session, query);\n\t\t\tthis._latestPullRequestSearches.delete(latestKey);\n\t\t\tvoid this._latestPullRequestSearches.getOrCreate(latestKey, () => Promise.resolve(drain));\n\t\t}\n\n\t\tconst pageSize = toAzureSearchPageSize(options.pageSize, 50, 100);\n\t\tconst start =\n\t\t\tcursor == null\n\t\t\t\t? 0\n\t\t\t\t: drain.rows.findIndex(r => compareAzurePullRequestSearchPositions(r.position, cursor.after, sort) > 0);\n\t\tconst slice = start < 0 ? [] : drain.rows.slice(start, start + pageSize);\n\t\tconst page = cursor?.page ?? 1;\n\t\tconst last = slice.at(-1);\n\t\tconst hasMore = last != null && start + slice.length < drain.rows.length;\n\t\treturn {\n\t\t\tvalues: slice.map(r =>\n\t\t\t\tfromProviderPullRequest(r.pr, this, {\n\t\t\t\t\tproject: r.project,\n\t\t\t\t\tcurrentAccount: r.currentAccount,\n\t\t\t\t\tprojection: options.summary ? 'search-summary' : 'search',\n\t\t\t\t}),\n\t\t\t),\n\t\t\tcursor: hasMore\n\t\t\t\t? JSON.stringify({ key: key, drain: drainId, page: page + 1, after: last.position })\n\t\t\t\t: undefined,\n\t\t\thasMore: hasMore,\n\t\t\tpage: page,\n\t\t\ttruncated: drain.truncated,\n\t\t\ttotalCount: drain.truncated ? undefined : drain.rows.length,\n\t\t\tmetadata: drain.failures != null ? { completeness: 'partial', failures: drain.failures } : undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Counts each scope from the latest drain of its query, the one a search's first page just read, or drains it; see\n\t * {@link searchProviderPullRequestsPage}.\n\t */\n\tprotected override async countProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tscopes: readonly { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria }[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<(ProviderPullRequestCount | Error)[] | undefined> {\n\t\t// One scope at a time: each is a drain that already fans out over its facets, and the facade runs several\n\t\t// batches of scopes at once, so a concurrent batch would multiply the requests reaching the server.\n\t\treturn mapBounded(scopes, 1, s =>\n\t\t\trefusalAsCount(async () => {\n\t\t\t\tthis.assertSearchDates(s.criteria);\n\t\t\t\tconst sort = s.criteria?.sort ?? defaultPullRequestSort;\n\t\t\t\tconst drain = await this.getPullRequestSearch(\n\t\t\t\t\tthis._latestPullRequestSearches,\n\t\t\t\t\tthis.pullRequestSearchCacheKey(session, toPullRequestSearchQuery(s, sort)),\n\t\t\t\t\tsession,\n\t\t\t\t\ts,\n\t\t\t\t\tsort,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t\t// Past the drain budget the true total is unknown, so it is reported as uncounted rather than understated.\n\t\t\t\treturn { count: drain.truncated ? undefined : drain.rows.length };\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * The drain each pagination pages through, one per first page (see {@link searchProviderPullRequestsPage}), so\n\t * the 50 most recently read paginations are kept for as long as they keep reading.\n\t */\n\tprivate readonly _pullRequestSearches = new PromiseCache<string, AzurePullRequestSearchDrain>({\n\t\tcapacity: 50,\n\t\taccessTTL: pullRequestSearchIdleTtl,\n\t\tcreateTTL: pullRequestSearchMaxTtl,\n\t});\n\t/**\n\t * Each query's latest drain, which its count reads for {@link pullRequestCountReuseTtl}. Apart from the\n\t * paginations' drains, so counting and starting searches never evicts a pagination still being read.\n\t */\n\tprivate readonly _latestPullRequestSearches = new PromiseCache<string, AzurePullRequestSearchDrain>({\n\t\tcapacity: 20,\n\t\tcreateTTL: pullRequestCountReuseTtl,\n\t});\n\n\t/**\n\t * Keyed by the query itself, not its cursor fingerprint, so two queries whose fingerprints collide can never share\n\t * a drain; by credential and installation, so two accounts or installations never read each other's results; and\n\t * by `drainId` for a pagination's own drain, left out for the query's latest one.\n\t */\n\tprivate pullRequestSearchCacheKey(\n\t\tsession: ProviderAuthenticationSession,\n\t\tquery: unknown,\n\t\tdrainId?: string,\n\t): string {\n\t\treturn JSON.stringify([session.accessToken, this.apiBaseUrlFor(session), query, drainId ?? null]);\n\t}\n\n\tprivate getPullRequestSearch(\n\t\tcache: PromiseCache<string, AzurePullRequestSearchDrain>,\n\t\tcacheKey: string,\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria },\n\t\tsort: PullRequestSorting,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<AzurePullRequestSearchDrain> {\n\t\treturn cache.getOrCreate(\n\t\t\tcacheKey,\n\t\t\t(_cacheable, signal) => this.drainPullRequestSearch(session, options, sort, signal),\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t/**\n\t * Every pull request matching the search, filtered, deduplicated and ordered.\n\t *\n\t * One facet per (repository or project) × relationship: `Author` reads by creator, while `Assignee` and\n\t * `ReviewRequested` both read by reviewer, since Azure has no assignee distinct from its reviewers: every open pull\n\t * request, kept when it names the user or one of the user's groups, and closed or merged ones through Azure's filter\n\t * for the user (see `toAzureReviewerReads`). Each facet is drained to {@link azurePullRequestSearchFacetLimit}; a\n\t * facet that still has more marks the whole result truncated, because its unread rows could sort anywhere in the\n\t * union. A facet that fails fails the search: a union missing one facet would be served in an order it doesn't\n\t * have. A collection whose groups can't be read is the exception: its facets still read what names the user, and\n\t * the result is reported incomplete with that collection's failure.\n\t */\n\tprivate async drainPullRequestSearch(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria },\n\t\tsort: PullRequestSorting,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<AzurePullRequestSearchDrain> {\n\t\tconst criteria = options.criteria;\n\t\t// Built before any request, so criteria it can't apply fail the search before the facets are drained.\n\t\tconst matches = toAzurePullRequestSearchFilter(criteria);\n\t\tconst relationships = new Set(criteria?.relationships ?? []);\n\t\tconst wantAuthored = relationships.has(PullRequestFilter.Author);\n\t\tconst wantReviewed =\n\t\t\trelationships.has(PullRequestFilter.Assignee) || relationships.has(PullRequestFilter.ReviewRequested);\n\n\t\t// A drain runs for a first page (or once its predecessor expired), so it re-reads the projects it fans out\n\t\t// over: an org search trusting the connection-long discovery cache would silently skip a newer project.\n\t\tconst facets = await this.resolvePullRequestSearchFacets(session, options.repos, options.org);\n\n\t\t// The current user's id is resolved PER COLLECTION: Azure DevOps Server gives one person a different\n\t\t// identity id in each collection than at the server level, and a creator/reviewer filter only matches the\n\t\t// collection's. The server-level id matches nothing there and would serve an empty result as if nobody had\n\t\t// authored anything.\n\t\tconst userIds = new Map<string, string>();\n\t\tif (relationships.size > 0) {\n\t\t\tfor (const collection of uniqueAzureNames(facets.map(f => f.collection))) {\n\t\t\t\tconst userId = await this.getFilterUserId(session, collection);\n\t\t\t\tif (userId == null) {\n\t\t\t\t\tthrow this.searchUnavailable(`the current user could not be resolved in '${collection}'`);\n\t\t\t\t}\n\n\t\t\t\tuserIds.set(collection, userId);\n\t\t\t}\n\t\t}\n\n\t\t// Every group the user is in, per collection, which the reviewer facets keep pull requests for too (see\n\t\t// `toAzureReviewerReads`). A collection whose groups can't be read (e.g. a token without the Identity scope)\n\t\t// keeps what names the user and is reported as a failure of that collection, so the search is incomplete\n\t\t// rather than refused, and a credential its other reads accept isn't treated as a dead one.\n\t\tconst failures: CollectionScopeFailure[] = [];\n\t\tconst groupsByCollection = new Map(\n\t\t\twantReviewed\n\t\t\t\t? await Promise.all(\n\t\t\t\t\t\tArray.from(userIds, async ([collection, userId]) => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\t\tawait this.getReviewerGroupIds(session, collection, userId),\n\t\t\t\t\t\t\t\t] as const;\n\t\t\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t\t\tconst resourceId = facets.find(f => f.collection === collection)!.project.resourceId;\n\t\t\t\t\t\t\t\tfailures.push(\n\t\t\t\t\t\t\t\t\ttoCollectionScopeFailure({ providerId: this.id, resourceId: resourceId }, ex),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn [collection, new Set<string>()] as const;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t: [],\n\t\t);\n\t\tconst groupIds = new Set([...groupsByCollection.values()].flatMap(ids => [...ids]));\n\n\t\tconst states = toProviderPullRequestStates(criteria?.states?.length ? criteria.states : 'open');\n\t\tconst filtersFor = (\n\t\t\tcollection: string,\n\t\t): { filter: AzureReviewerRead['filter'] & { authorLogin?: string }; keep?: AzureReviewerRead['keep'] }[] => {\n\t\t\tif (relationships.size === 0) return [{ filter: {} }];\n\n\t\t\tconst userId = userIds.get(collection)!;\n\t\t\treturn [\n\t\t\t\t...(wantAuthored ? [{ filter: { authorLogin: userId } }] : []),\n\t\t\t\t...(wantReviewed ? toAzureReviewerReads(userId, groupsByCollection.get(collection)!, states) : []),\n\t\t\t];\n\t\t};\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst { tokenWithInfo, options: apiOptions } = this.getApiOptions(session);\n\t\tconst drains = await mapBounded(\n\t\t\tfacets.flatMap(facet => filtersFor(facet.collection).map(f => ({ facet: facet, ...f }))),\n\t\t\tproviderFanOutConcurrency,\n\t\t\tasync ({ facet, filter, keep }) => {\n\t\t\t\tconst baseUrl = this.collectionApiBaseUrl(session, facet.collection);\n\t\t\t\tconst values: ProviderPullRequest[] = [];\n\t\t\t\tlet page = 1;\n\t\t\t\tfor (let read = 1; ; read++) {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\tconst input = {\n\t\t\t\t\t\t...apiOptions,\n\t\t\t\t\t\t// A reviewer facet narrows the states itself (see `toAzureReviewerReads`).\n\t\t\t\t\t\tstates: states,\n\t\t\t\t\t\t...filter,\n\t\t\t\t\t\tpage: page,\n\t\t\t\t\t\tpageSize: azurePullRequestSearchPageSize,\n\t\t\t\t\t\tbaseUrl: baseUrl,\n\t\t\t\t\t};\n\t\t\t\t\tconst result =\n\t\t\t\t\t\tfacet.repository != null\n\t\t\t\t\t\t\t? await api\n\t\t\t\t\t\t\t\t\t.getPullRequestsForRepo(\n\t\t\t\t\t\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tnamespace: facet.collection,\n\t\t\t\t\t\t\t\t\t\t\tname: facet.repository,\n\t\t\t\t\t\t\t\t\t\t\tproject: facet.project.name,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.then(r => ({\n\t\t\t\t\t\t\t\t\t\tvalues: r.values,\n\t\t\t\t\t\t\t\t\t\tmore: r.paging?.more === true,\n\t\t\t\t\t\t\t\t\t\tnextPage: r.paging?.nextPage,\n\t\t\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t\t: await api\n\t\t\t\t\t\t\t\t\t.getPullRequestsForAzureProject(\n\t\t\t\t\t\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\t\t\t\t\t\t{ namespace: facet.collection, project: facet.project.name },\n\t\t\t\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.then(r =>\n\t\t\t\t\t\t\t\t\t\tr != null\n\t\t\t\t\t\t\t\t\t\t\t? { values: r.data, more: r.hasMore, nextPage: r.nextPage ?? undefined }\n\t\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\tif (result == null) throw new Error('Azure DevOps returned no pull request page');\n\n\t\t\t\t\tvalues.push(...result.values);\n\t\t\t\t\tif (!result.more) return { facet: facet, keep: keep, values: values, truncated: false };\n\t\t\t\t\t// Follows the page the provider says comes next rather than assuming one: a continuation that\n\t\t\t\t\t// doesn't advance would re-read or skip rows, so it fails the facet — and with it the search —\n\t\t\t\t\t// instead of serving a union built from it.\n\t\t\t\t\tif (result.nextPage == null || result.nextPage <= page) {\n\t\t\t\t\t\tthrow new Error('Azure DevOps returned no advancing pull request continuation');\n\t\t\t\t\t}\n\t\t\t\t\t// The budget counts pages READ, not rows kept: several states are one `status=all` query the SDK\n\t\t\t\t\t// narrows client-side, so counting survivors would keep paging through rows it discards.\n\t\t\t\t\tif (read * azurePullRequestSearchPageSize >= azurePullRequestSearchFacetLimit) {\n\t\t\t\t\t\treturn { facet: facet, keep: keep, values: values, truncated: true };\n\t\t\t\t\t}\n\n\t\t\t\t\tpage = result.nextPage;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tconst rows = new Map<string, AzurePullRequestSearchRow>();\n\t\tfor (const { facet, keep, values } of drains) {\n\t\t\tfor (const pr of values) {\n\t\t\t\tif (keep != null && !keep(pr)) continue;\n\t\t\t\tif (!matches(pr)) continue;\n\n\t\t\t\tconst identity =\n\t\t\t\t\tgetProviderPullRequestIdentity(pr) ?? `project:${facet.collection}/${facet.project.name}:${pr.id}`;\n\t\t\t\tif (rows.has(identity)) continue;\n\n\t\t\t\tconst userId = userIds.get(facet.collection);\n\t\t\t\trows.set(identity, {\n\t\t\t\t\tpr: markMyGroupReviews(pr, groupIds),\n\t\t\t\t\tproject: facet.project,\n\t\t\t\t\tcurrentAccount: userId != null ? { id: userId } : undefined,\n\t\t\t\t\tposition: toAzurePullRequestSearchPosition(pr, sort, identity),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\trows: [...rows.values()].sort((a, b) =>\n\t\t\t\tcompareAzurePullRequestSearchPositions(a.position, b.position, sort),\n\t\t\t),\n\t\t\ttruncated: failures.length > 0 || drains.some(d => d.truncated),\n\t\t\tfailures: failures.length > 0 ? failures : undefined,\n\t\t};\n\t}\n\n\t/**\n\t * The repositories or projects a pull-request search reads, each with its collection and project descriptor.\n\t *\n\t * Repositories are read one by one; an `org` is its collection's projects; a search bounded only by the current\n\t * user reads every project the account can see, the same breadth as the account-wide pull request read.\n\t */\n\tprivate async resolvePullRequestSearchFacets(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos: ProviderRepoInput[] | undefined,\n\t\torg: string | undefined,\n\t): Promise<{ collection: string; project: AzureProjectDescriptor; repository?: string }[]> {\n\t\tconst collections = await this.getSearchCollections(session);\n\t\tconst collectionFor = (name: string): AzureOrganizationDescriptor => {\n\t\t\tconst collection = findAzureCollection(collections, name);\n\t\t\tif (collection == null) throw this.searchUnavailable(`the '${name}' collection is not visible`);\n\n\t\t\treturn collection;\n\t\t};\n\n\t\tif (repos?.length) {\n\t\t\tif (org && repos.some(r => !sameAzureName(r.namespace, org))) {\n\t\t\t\tthrow this.searchUnavailable(`the repositories are not all in the '${org}' collection`);\n\t\t\t}\n\n\t\t\t// One discovery per distinct collection, however many of its repositories the search names.\n\t\t\tconst projectsByCollection = new Map<string, Promise<AzureProjectDescriptor[]>>();\n\t\t\tconst projectsOf = (collection: AzureOrganizationDescriptor): Promise<AzureProjectDescriptor[]> => {\n\t\t\t\tlet projects = projectsByCollection.get(collection.id);\n\t\t\t\tif (projects == null) {\n\t\t\t\t\tprojects = this.getSearchProjects(session, collection, true);\n\t\t\t\t\tprojectsByCollection.set(collection.id, projects);\n\t\t\t\t}\n\t\t\t\treturn projects;\n\t\t\t};\n\n\t\t\treturn Promise.all(\n\t\t\t\trepos.map(async r => {\n\t\t\t\t\tconst collection = collectionFor(r.namespace);\n\t\t\t\t\tconst identity = getAzureRepositoryIdentity({\n\t\t\t\t\t\towner: r.namespace,\n\t\t\t\t\t\tname: r.name,\n\t\t\t\t\t\tproject: r.project,\n\t\t\t\t\t});\n\t\t\t\t\tif (identity.projectName == null) {\n\t\t\t\t\t\tthrow this.searchUnavailable(`repository '${r.namespace}/${r.name}' names no project`);\n\t\t\t\t\t}\n\t\t\t\t\t// The repository becomes a URL segment the SDK encodes but doesn't validate, and a segment of `..`\n\t\t\t\t\t// survives encoding and resolves to the project-wide route: refused rather than widened.\n\t\t\t\t\tif (!isAzureRouteSegment(identity.repositoryName)) {\n\t\t\t\t\t\tthrow this.searchUnavailable(`repository '${r.namespace}/${r.name}' is not a valid name`);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst project = (await projectsOf(collection)).find(p =>\n\t\t\t\t\t\tsameAzureName(p.name, identity.projectName!),\n\t\t\t\t\t);\n\t\t\t\t\tif (project == null) {\n\t\t\t\t\t\tthrow this.searchUnavailable(\n\t\t\t\t\t\t\t`project '${identity.projectName}' is not visible in '${collection.name}'`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn { collection: collection.name, project: project, repository: identity.repositoryName };\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tconst scoped = org ? [collectionFor(org)] : collections;\n\t\tconst projects = await Promise.all(scoped.map(c => this.getSearchProjects(session, c, true)));\n\t\treturn projects.flat().map(p => ({ collection: p.resourceName, project: p }));\n\t}\n\n\tprivate readonly _collectionUserIds = new PromiseCache<string, string | undefined>({ capacity: 50 });\n\n\t/**\n\t * The current user's identity id in `collection`, read from the collection's own connection data, which is\n\t * what Azure's creator and reviewer filters compare against. Cached per credential and collection, since it\n\t * can't change for either.\n\t */\n\tprotected override getFilterUserId(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcollection: string,\n\t): Promise<string | undefined> {\n\t\tconst baseUrl = this.collectionApiBaseUrl(session, collection);\n\t\treturn this._collectionUserIds.getOrCreate(\n\t\t\tJSON.stringify([session.accessToken, baseUrl, collection.toLowerCase()]),\n\t\t\tasync cacheable => {\n\t\t\t\tconst azure = await this.authenticationService.apis.azure;\n\t\t\t\tconst user = await azure?.getCurrentUserOnServer(\n\t\t\t\t\tthis,\n\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t`${baseUrl}/${encodeURIComponent(collection)}`,\n\t\t\t\t);\n\t\t\t\t// A response without an identity must not refuse later relationship searches from a cached miss.\n\t\t\t\tif (user?.id == null) {\n\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t}\n\n\t\t\t\treturn user?.id;\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Resolved per collection, which a raw row names as its repository owner: a collection's pull requests carry the\n\t * id {@link getFilterUserId} resolves there, never the server-level account's. A row that names no collection or\n\t * has no author to match gets no viewer, nor does one in a collection whose id can't be read: its authorship\n\t * stays unknown.\n\t */\n\toverride async getPullRequestViewers(\n\t\tpullRequests: readonly (ProviderPullRequest | PullRequest)[],\n\t\tconnectionId?: string,\n\t): Promise<({ id: string; username?: string } | undefined)[]> {\n\t\tconst session = await this.resolveReadSessionOrThrow(connectionId, undefined);\n\t\tif (session == null) return pullRequests.map(() => undefined);\n\n\t\tconst viewerFor = this.getOrganizationViewers(session, undefined);\n\t\treturn Promise.all(\n\t\t\tpullRequests.map(pr => {\n\t\t\t\t// Azure DevOps Server's rows are provider-apis' own; only GitHub's are native.\n\t\t\t\tconst collection = isNativePullRequest(pr) ? undefined : pr.repository?.owner?.login;\n\t\t\t\treturn collection && pr.author != null ? viewerFor(collection) : Promise.resolve(undefined);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Ignores `account`: it is the server-level one, which no collection's pull requests carry. A collection whose id\n\t * can't be read resolves `undefined`, since authorship is optional enrichment and one collection's failed lookup\n\t * must not fail the read or blank the others; it is asked once per read, as a miss isn't cached.\n\t */\n\tprotected override getOrganizationViewers(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_account: { id: string; username?: string } | undefined,\n\t): (collection: string) => Promise<{ id: string } | undefined> {\n\t\tconst viewers = new Map<string, Promise<{ id: string } | undefined>>();\n\t\treturn collection => {\n\t\t\tconst key = collection.toLowerCase();\n\t\t\tlet viewer = viewers.get(key);\n\t\t\tif (viewer == null) {\n\t\t\t\tviewer = this.getFilterUserId(session, collection).then(\n\t\t\t\t\tid => (id != null ? { id: id } : undefined),\n\t\t\t\t\t() => undefined,\n\t\t\t\t);\n\t\t\t\tviewers.set(key, viewer);\n\t\t\t}\n\t\t\treturn viewer;\n\t\t};\n\t}\n\n\t/** Every collection the account can see, or a refusal when discovery itself failed. */\n\tprivate async getSearchCollections(session: ProviderAuthenticationSession): Promise<AzureOrganizationDescriptor[]> {\n\t\tconst collections = await this.getProviderResourcesForUser(session);\n\t\tif (collections == null) throw this.searchUnavailable('the account’s collections could not be read');\n\n\t\treturn collections;\n\t}\n\n\t/**\n\t * A collection's projects, refused when discovery was incomplete: a search bounded by an incomplete project set\n\t * would silently omit the missing projects' matches. `refresh` re-reads them rather than trusting the discovery\n\t * cache, which lives for the whole connection and so doesn't know a project created since.\n\t */\n\tprivate async getSearchProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcollection: AzureOrganizationDescriptor,\n\t\trefresh: boolean = false,\n\t): Promise<AzureProjectDescriptor[]> {\n\t\tconst projects = refresh\n\t\t\t? await this.refreshSearchProjects(session, collection)\n\t\t\t: await this.getProviderProjectsForResources(session, [collection]);\n\t\tif (projects.metadata != null && projects.metadata.completeness !== 'complete') {\n\t\t\tthrow this.searchUnavailable(`the projects of the '${collection.name}' collection could not all be read`);\n\t\t}\n\n\t\treturn projects.values;\n\t}\n\n\tprivate readonly _projectRefreshes = new Map<\n\t\tstring,\n\t\tPromise<ProviderApiCollectionResult<AzureProjectDescriptor>>\n\t>();\n\n\t/**\n\t * Re-reads a collection's projects, sharing one read among the refreshes IN FLIGHT at once — a count batch or a\n\t * multi-repository drain refreshes the same collection once per scope, and each would otherwise re-read every\n\t * project page. Nothing outlives the read, so the next search still sees a project created after it.\n\t */\n\tprivate refreshSearchProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcollection: AzureOrganizationDescriptor,\n\t): Promise<ProviderApiCollectionResult<AzureProjectDescriptor>> {\n\t\tconst key = `${this.discoveryKey(session)}:${collection.id}`;\n\t\tlet pending = this._projectRefreshes.get(key);\n\t\tif (pending == null) {\n\t\t\tpending = this.getProviderProjectsForResources(session, [collection], true).finally(() => {\n\t\t\t\tthis._projectRefreshes.delete(key);\n\t\t\t});\n\t\t\tthis._projectRefreshes.set(key, pending);\n\t\t}\n\n\t\treturn pending;\n\t}\n\n\t/**\n\t * Refuses dates the search can't apply before anything is read. The facade only checks that dates are\n\t * supported, not their shape, and a refusal here stays with its own scope in a count batch.\n\t */\n\tprivate assertSearchDates(criteria: { updatedAfter?: string; createdAfter?: string } | undefined): void {\n\t\tconst invalid = getInvalidAzureSearchDate(criteria);\n\t\tif (invalid != null) throw this.searchUnavailable(invalid);\n\t}\n\n\tprivate searchUnavailable(reason: string): IntegrationReadUnavailableError {\n\t\treturn new IntegrationReadUnavailableError(this.name, `search refused: ${reason}.`);\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tsuper.providerOnDisconnect();\n\t\tthis._pullRequestSearches.clear();\n\t\tthis._latestPullRequestSearches.clear();\n\t\tthis._collectionUserIds.clear();\n\t}\n\n\tprotected override async _requestForCurrentUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst azure = await this.authenticationService.apis.azure;\n\t\tconst user = azure\n\t\t\t? await azure.getCurrentUserOnServer(this, toTokenWithInfo(this.id, session), this.apiBaseUrlFor(session))\n\t\t\t: undefined;\n\t\treturn user\n\t\t\t? {\n\t\t\t\t\tprovider: this,\n\t\t\t\t\tid: user.id,\n\t\t\t\t\tname: user.name ?? undefined,\n\t\t\t\t\temail: user.email ?? undefined,\n\t\t\t\t\tavatarUrl: user.avatarUrl ?? undefined,\n\t\t\t\t\tusername: user.username ?? undefined,\n\t\t\t\t}\n\t\t\t: undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqEA,SAAS,oBAAoB,OAAwB;CACpD,OAAO,MAAM,SAAS,KAAK,UAAU,OAAO,UAAU;AACvD;;;;;;AAOA,eAAe,eAAkB,OAAuE;CACvG,IAAI;EACH,OAAO,MAAM,MAAM;CACpB,SAAS,IAAI;EACZ,IAAI,cAAc,iCAAiC,OAAO;EAE1D,MAAM;CACP;AACD;AAEA,SAAS,oBACR,aACA,MAC0C;CAC1C,OAAO,YAAY,MAAK,MAAK,cAAc,EAAE,MAAM,IAAI,KAAK,EAAE,OAAO,IAAI;AAC1E;;;;;;AAOA,MAAM,mCAAmC;;;;;AAMzC,MAAM,iCAAiC;;;;;AAMvC,MAAM,6BAA6B;;;;;;AAOnC,MAAM,2BAA2B;AACjC,MAAM,0BAA0B;;;;;;AAOhC,MAAM,2BAA2B;;;;;;AAyBjC,SAAS,yBACR,SACA,MACU;CACV,MAAM,WAAW,QAAQ;CACzB,OAAO;EACN,OAAO,QAAQ,OAAO,KAAI,MAAK;GAAC,EAAE;GAAW,EAAE,WAAW;GAAM,EAAE;EAAI,CAAC;EACvE,KAAK,QAAQ,OAAO;EACpB,eAAe,CAAC,GAAG,IAAI,IAAI,UAAU,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;EAChE,QAAQ,CAAC,GAAG,IAAI,IAAI,UAAU,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK;EAClD,MAAM,UAAU,MAAM,KAAK,KAAK;EAChC,OAAO,UAAU,SAAS;EAC1B,cAAc,UAAU,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;CAC1D;CAEA,kBAA0B,QAAiD;EAC1E,OAAO,IAAI,gCAAgC,KAAK,MAAM,mBAAmB,OAAO,EAAE;CACnF;CAEA,uBAAgD;EAC/C,MAAM,qBAAqB;EAC3B,KAAK,qBAAqB,MAAM;EAChC,KAAK,2BAA2B,MAAM;EACtC,KAAK,mBAAmB,MAAM;CAC/B;CAEA,MAAyB,uBACxB,SAC+B;EAC/B,MAAM,QAAQ,MAAM,KAAK,sBAAsB,KAAK;EACpD,MAAM,OAAO,QACV,MAAM,MAAM,uBAAuB,MAAM,gBAAgB,KAAK,IAAI,OAAO,GAAG,KAAK,cAAc,OAAO,CAAC,IACvG,KAAA;EACH,OAAO,OACJ;GACA,UAAU;GACV,IAAI,KAAK;GACT,MAAM,KAAK,QAAQ,KAAA;GACnB,OAAO,KAAK,SAAS,KAAA;GACrB,WAAW,KAAK,aAAa,KAAA;GAC7B,UAAU,KAAK,YAAY,KAAA;EAC5B,IACC,KAAA;CACJ;AACD"}
|
|
1
|
+
{"version":3,"file":"azureDevOpsServer.js","names":[],"sources":["../../../../../plus/integrations/src/providers/azureDevOpsServer.ts"],"sourcesContent":["import type { CollectionScopeFailure } from '@gitkraken/provider-apis';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { IssueSearchCriteria } from '@gitlens/git/models/issue.js';\nimport type { PullRequest, PullRequestSearchCriteria, PullRequestSorting } from '@gitlens/git/models/pullRequest.js';\nimport { defaultPullRequestSort } from '@gitlens/git/models/pullRequest.js';\nimport { CancellationError, raceWithSignal } from '@gitlens/utils/cancellation.js';\nimport { uuid } from '@gitlens/utils/crypto.js';\nimport type { Emitter } from '@gitlens/utils/event.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { mapBounded } from '@gitlens/utils/promise.js';\nimport { PromiseCache } from '@gitlens/utils/promiseCache.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';\nimport type { ProviderAuthenticationSession, TokenWithInfo } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { GitSelfManagedHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport { AuthenticationError, IntegrationReadUnavailableError, RequestNotFoundError } from '../errors.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport type {\n\tIntegrationKey,\n\tProviderIssueSearchPage,\n\tProviderPullRequestCount,\n\tProviderPullRequestSearchPage,\n\tProviderSearchCount,\n} from '../models/integration.js';\nimport type { AzureOrganizationDescriptor, AzureProjectDescriptor, AzureRepositoryDescriptor } from './azure/models.js';\nimport type { AzurePullRequestSearchPosition } from './azure/search.js';\nimport {\n\tcompareAzurePullRequestSearchPositions,\n\tgetInvalidAzureSearchDate,\n\tisAzureWorkItemSearchFirstPage,\n\tparseAzurePullRequestSearchCursor,\n\ttoAzurePullRequestSearchCursorKey,\n\ttoAzurePullRequestSearchFilter,\n\ttoAzurePullRequestSearchPosition,\n\ttoAzureSearchPageSize,\n} from './azure/search.js';\nimport type { AzureRepositoryTarget, AzureReviewerRead } from './azureDevOps.js';\nimport {\n\tAzureDevOpsIntegrationBase,\n\tfindAzureRepositoryApiBaseUrl,\n\tgetAzureRepositoryApiBaseUrl,\n\tgetAzureRepositoryIdentity,\n\tgetAzureScopeVirtualDirectory,\n\tisAzureProjectlessCandidate,\n\tmarkMyGroupReviews,\n\tresolveAzureProjectlessRepository,\n\tsameAzureName,\n\ttoAzureReviewerReads,\n\tuniqueAzureNames,\n} from './azureDevOps.js';\nimport type {\n\tProviderApiCollectionResult,\n\tProviderAzureResource,\n\tProviderPullRequest,\n\tProviderRepoInput,\n\tProviderReposInput,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tgetProviderPullRequestIdentity,\n\tisNativePullRequest,\n\tprovidersMetadata,\n\tPullRequestFilter,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport type { ProvidersApi } from './providersApi.js';\nimport { discoveryCacheTtl } from './utils/discoveryCache.js';\n\n/**\n * Whether `value` can stand as one route segment. Encoding keeps `.` and `..` as they are, and a URL resolves them\n * as directory steps, so a name of either would address a different route than the one named.\n */\nfunction isAzureRouteSegment(value: string): boolean {\n\treturn value.length > 0 && value !== '.' && value !== '..';\n}\n\n/**\n * Runs one scope of a count probe, answering a refusal of THAT scope (see `searchUnavailable`) as the error itself,\n * which the facade reports and drops without failing the scopes around it. Anything else — a rejected credential,\n * a failed request — still rejects, so the batch reports it.\n */\nasync function refusalAsCount<T>(count: () => Promise<T>): Promise<T | IntegrationReadUnavailableError> {\n\ttry {\n\t\treturn await count();\n\t} catch (ex) {\n\t\tif (ex instanceof IntegrationReadUnavailableError) return ex;\n\n\t\tthrow ex;\n\t}\n}\n\nfunction findAzureCollection(\n\tcollections: readonly AzureOrganizationDescriptor[],\n\tname: string,\n): AzureOrganizationDescriptor | undefined {\n\treturn collections.find(c => sameAzureName(c.name, name) || c.id === name);\n}\n\n/**\n * The most pull requests one facet of a filtered pull-request search drains. Azure has no server-side text, date or\n * draft filter and no ordering, so a facet is read in full before any of them apply; past this bound the facet's\n * unread rows could sort anywhere, and the search reports itself truncated instead of guessing.\n */\nconst azurePullRequestSearchFacetLimit = 1000;\n\n/**\n * The page size a facet drain reads. The SDK's own default for both pull request reads, and the size it sizes\n * `$skip` by, so the budget above counts what was actually read.\n */\nconst azurePullRequestSearchPageSize = 100;\n\n/**\n * How many scopes of one work-item count batch query at once. The facade already runs several batches concurrently,\n * so this multiplies with it: kept small, so a large count preview can't flood a self-hosted server.\n */\nconst azureIssueCountConcurrency = 2;\n\n/**\n * How long a drained pull-request search keeps serving its continuation pages after the last one was read, and the\n * most it lives however actively it is paged. A pagination that keeps reading stays on one consistent drain; one\n * left idle, or paged for longer than that, is read again.\n */\nconst pullRequestSearchIdleTtl = 5 * 60 * 1000;\nconst pullRequestSearchMaxTtl = 30 * 60 * 1000;\n\n/**\n * How long a count reuses the drain a search of its query just read. Long enough for a count shown next to the\n * search it previews to agree with it, short enough that a count polled next to an unapplied filter stays live: the\n * window runs from the drain, not from the last count, so polling never extends it.\n */\nconst pullRequestCountReuseTtl = 60 * 1000;\n\n/**\n * Kept unconverted, so each page converts its rows with the projection its own caller asked for: the drain is shared\n * by every page of a query, whatever `summary` each page passes.\n */\ninterface AzurePullRequestSearchRow {\n\tpr: ProviderPullRequest;\n\tproject: AzureProjectDescriptor;\n\tcurrentAccount: { id: string } | undefined;\n\tposition: AzurePullRequestSearchPosition;\n}\n\ninterface AzurePullRequestSearchDrain {\n\trows: AzurePullRequestSearchRow[];\n\ttruncated: boolean;\n\t/** Collections whose groups couldn't be read, so what only those groups review is missing. */\n\tfailures?: CollectionScopeFailure[];\n}\n\n/**\n * Everything that decides a pull-request search's result set and order, as the value its cursor is fingerprinted\n * from. `pageSize` is left out on purpose: it only decides where a page ends, which the keyset cursor already\n * carries.\n */\nfunction toPullRequestSearchQuery(\n\toptions: { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria },\n\tsort: PullRequestSorting,\n): unknown {\n\tconst criteria = options.criteria;\n\treturn {\n\t\trepos: options.repos?.map(r => [r.namespace, r.project ?? null, r.name]),\n\t\torg: options.org ?? null,\n\t\trelationships: [...new Set(criteria?.relationships ?? [])].sort(),\n\t\tstates: [...new Set(criteria?.states ?? [])].sort(),\n\t\ttext: criteria?.text?.trim() ?? null,\n\t\tdraft: criteria?.draft ?? null,\n\t\tupdatedAfter: criteria?.updatedAfter ?? null,\n\t\tcreatedAfter: criteria?.createdAfter ?? null,\n\t\tsort: sort,\n\t};\n}\n\nconst serverMetadata = providersMetadata[GitSelfManagedHostIntegrationId.AzureDevOpsServer];\nconst serverAuthProvider = Object.freeze({ id: serverMetadata.id, scopes: serverMetadata.scopes });\n\nexport class AzureDevOpsServerIntegration extends AzureDevOpsIntegrationBase<GitSelfManagedHostIntegrationId.AzureDevOpsServer> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = serverAuthProvider;\n\treadonly id = GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\tprotected readonly key: IntegrationKey<GitSelfManagedHostIntegrationId.AzureDevOpsServer>;\n\treadonly name: string = 'Azure DevOps Server';\n\n\tconstructor(\n\t\tctx: IntegrationServiceContext,\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tgetProvidersApi: () => Promise<ProvidersApi>,\n\t\tdidChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t\treadonly domain: string,\n\t) {\n\t\tsuper(ctx, authenticationService, getProvidersApi, didChangeConnection);\n\t\tthis.key = `${this.id}:${this.domain}`;\n\t}\n\n\tprotected override apiBaseUrlFor(session: ProviderAuthenticationSession): string {\n\t\treturn this.getSelfManagedApiBaseUrl(session);\n\t}\n\n\t/**\n\t * The credential AND the installation it is used against: one integration instance serves every installation on\n\t * its host (context paths differ, the host doesn't), and the same token connected to two of them must not reuse\n\t * one installation's collections or projects on the other.\n\t */\n\tprotected override discoveryKey(session: ProviderAuthenticationSession): string {\n\t\treturn `${session.accessToken}:${this.apiBaseUrlFor(session)}`;\n\t}\n\n\tprotected override getRepositoriesApiBaseUrl(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos: ProviderReposInput,\n\t): string {\n\t\t// Requests append each repository's organization (its collection), which an address naming that collection\n\t\t// already ends with. Only repositories of a single organization can share one base; mixed ones keep the\n\t\t// address, so another collection's repository stays below it (see `resolveRepository`).\n\t\tconst owners = new Set(repos.map(r => (typeof r === 'object' ? r.namespace : undefined)));\n\t\tconst [owner] = owners;\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\t\treturn owners.size === 1 && owner != null\n\t\t\t? getAzureRepositoryApiBaseUrl(baseUrl, { owner: owner, virtualDirectory: undefined })\n\t\t\t: baseUrl;\n\t}\n\n\tprotected override getApiOptions(\n\t\tsession: ProviderAuthenticationSession,\n\t\tdoNotConvertToPat: boolean = false,\n\t): {\n\t\ttokenWithInfo: TokenWithInfo<GitSelfManagedHostIntegrationId.AzureDevOpsServer>;\n\t\toptions: { isPAT: boolean; baseUrl?: string };\n\t} {\n\t\tconst { options, ...rest } = super.getApiOptions(session, doNotConvertToPat);\n\t\treturn {\n\t\t\t...rest,\n\t\t\toptions: { ...options, baseUrl: this.apiBaseUrlFor(session) },\n\t\t};\n\t}\n\n\tprotected override getCollectionApiOptions(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcollection: string,\n\t): { isPAT: boolean; baseUrl?: string } {\n\t\treturn {\n\t\t\t...super.getCollectionApiOptions(session, collection),\n\t\t\tbaseUrl: this.collectionApiBaseUrl(session, collection),\n\t\t};\n\t}\n\n\t/** The base a request below `collection` appends to: the installation, whichever the address already ends in. */\n\tprotected override collectionApiBaseUrl(session: ProviderAuthenticationSession, collection: string): string {\n\t\treturn getAzureRepositoryApiBaseUrl(this.apiBaseUrlFor(session), {\n\t\t\towner: collection,\n\t\t\tvirtualDirectory: undefined,\n\t\t});\n\t}\n\n\t/**\n\t * The collection names per credential and installation, `undefined` when they couldn't be read. Only a\n\t * tie-breaker for {@link getRepositoryTarget}, so a failed read is kept (for {@link discoveryCacheTtl}) rather than\n\t * retried on every repository read; a successful one comes from the organizations, which are kept for the session.\n\t */\n\tprivate readonly _collectionNames = new PromiseCache<string, string[] | undefined>({\n\t\tcapacity: 10,\n\t\tcreateTTL: discoveryCacheTtl,\n\t});\n\n\t/**\n\t * Settles which segment of a remote's path is the collection before reading the repository. Behind a virtual\n\t * directory a repository named after its project is also served as `{vdir}/{collection}/_git/{repo}`, which the\n\t * remote parser reads as collection `{vdir}` and project `{collection}`; the discovered collections tell the two\n\t * apart (see {@link resolveAzureProjectlessRepository}). Only a path that reading could address below the connection\n\t * is settled ({@link isAzureProjectlessCandidate}); any other reads as parsed, without discovery. A connection\n\t * addressed at a collection discovers only that collection.\n\t */\n\tprotected override async getRepositoryTarget<\n\t\tT extends Pick<AzureRepositoryDescriptor, 'owner' | 'name' | 'project' | 'virtualDirectory'>,\n\t>(session: ProviderAuthenticationSession, repo: T, cancellation?: AbortSignal): Promise<AzureRepositoryTarget<T>> {\n\t\tconst { repo: settled, baseUrl, unsettled } = await this.settleRepository(session, repo, cancellation);\n\t\t// Throws for a virtual directory the connection doesn't serve, or an invalid one.\n\t\treturn {\n\t\t\trepo: settled,\n\t\t\tbaseUrl: baseUrl ?? getAzureRepositoryApiBaseUrl(this.apiBaseUrlFor(session), settled),\n\t\t\tunsettled: unsettled,\n\t\t};\n\t}\n\n\t/**\n\t * The repository {@link getRepositoryTarget} reads `repo` as, and the base it reads it below: `undefined` when the\n\t * connection doesn't serve its virtual directory (another installation's) or that directory isn't a valid one.\n\t */\n\tprivate async settleRepository<\n\t\tT extends Pick<AzureRepositoryDescriptor, 'owner' | 'name' | 'project' | 'virtualDirectory'>,\n\t>(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: T,\n\t\tcancellation?: AbortSignal,\n\t): Promise<{ repo: T; baseUrl: string | undefined; unsettled: boolean }> {\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\t\tlet unsettled = false;\n\t\tif (isAzureProjectlessCandidate(baseUrl, repo)) {\n\t\t\t// The discovery is shared, so it takes no signal: one caller's abort must neither cancel it for the others\n\t\t\t// nor be kept as its result.\n\t\t\tconst names = this._collectionNames.getOrCreate(this.discoveryKey(session), () =>\n\t\t\t\tthis.getCollectionNames(session),\n\t\t\t);\n\t\t\tconst collections = await (cancellation != null ? raceWithSignal(names, cancellation) : names);\n\t\t\tif (collections != null) {\n\t\t\t\trepo = resolveAzureProjectlessRepository(repo, collections);\n\t\t\t} else {\n\t\t\t\tunsettled = true;\n\t\t\t}\n\t\t}\n\n\t\treturn { repo: repo, baseUrl: findAzureRepositoryApiBaseUrl(baseUrl, repo), unsettled: unsettled };\n\t}\n\n\t/**\n\t * Settles each coordinate as {@link getRepositoryTarget} settles a remote's descriptor: a consumer that parses a\n\t * remote itself splits a project-less path behind a virtual directory the same way. Its owner is placed in the path\n\t * the connection addresses ({@link getAzureScopeVirtualDirectory}), since a coordinate carries no virtual directory.\n\t * Only the coordinate is settled, and only to a repository the connection serves: each read places it below the\n\t * connection itself, so one settling elsewhere reads as given and fails its own read rather than every coordinate's.\n\t */\n\tprotected override async resolveRepositoryCoordinates<T extends { owner: string; repo: string; project?: string }>(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly T[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<{ coordinates: readonly T[]; unsettled?: readonly boolean[] }> {\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\t\tconst targets = await Promise.all(\n\t\t\tcoordinates.map(async c => {\n\t\t\t\tconst virtualDirectory =\n\t\t\t\t\tc.project != null ? getAzureScopeVirtualDirectory(baseUrl, c.owner) : undefined;\n\t\t\t\tif (virtualDirectory == null) return { coordinate: c, unsettled: false };\n\n\t\t\t\tconst {\n\t\t\t\t\trepo,\n\t\t\t\t\tbaseUrl: repoBaseUrl,\n\t\t\t\t\tunsettled,\n\t\t\t\t} = await this.settleRepository(\n\t\t\t\t\tsession,\n\t\t\t\t\t{\n\t\t\t\t\t\towner: c.owner,\n\t\t\t\t\t\tname: `${c.project}/_git/${c.repo}`,\n\t\t\t\t\t\tproject: c.project,\n\t\t\t\t\t\tvirtualDirectory: virtualDirectory || undefined,\n\t\t\t\t\t},\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t\t// A repository this connection doesn't serve is another installation's: read the scope as given.\n\t\t\t\tconst settled = repo.owner !== c.owner && repoBaseUrl != null;\n\t\t\t\treturn {\n\t\t\t\t\tcoordinate: settled ? { ...c, owner: repo.owner, project: repo.project } : c,\n\t\t\t\t\tunsettled: unsettled,\n\t\t\t\t};\n\t\t\t}),\n\t\t);\n\t\treturn { coordinates: targets.map(t => t.coordinate), unsettled: targets.map(t => t.unsettled) };\n\t}\n\n\tprotected override async resolveRepositoryInputs(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos: readonly ProviderRepoInput[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderRepoInput[]> {\n\t\tconst { coordinates } = await this.resolveRepositoryCoordinates(\n\t\t\tsession,\n\t\t\trepos.map(r => ({ ...r, owner: r.namespace, repo: r.name })),\n\t\t\tcancellation,\n\t\t);\n\t\treturn coordinates.map(({ owner, repo, ...r }) => ({ ...r, namespace: owner, name: repo }));\n\t}\n\n\t/**\n\t * Never rejects. A credential refused the list leaves every path as parsed, as before discovery was asked; any other\n\t * failure is `undefined`, so a read of a path it could have settled keeps a miss out of the caches (see\n\t * `readRepository`).\n\t */\n\tprivate async getCollectionNames(session: ProviderAuthenticationSession): Promise<string[] | undefined> {\n\t\ttry {\n\t\t\treturn (await this.getProviderResourcesForUser(session))?.map(r => r.name);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof AuthenticationError) return [];\n\n\t\t\tLogger.debug(\n\t\t\t\t`${this.name}: collections at ${this.apiBaseUrlFor(session)} couldn't be read to place a repository path`,\n\t\t\t\tex,\n\t\t\t);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\toverride invalidateDiscoveryCaches(): void {\n\t\tsuper.invalidateDiscoveryCaches();\n\t\tthis._collectionNames.clear();\n\t}\n\n\t/**\n\t * Only the server level lists the collections: below one, Azure DevOps Server answers `projectCollections` with a\n\t * 404 page. On that 404 an address that names a collection reads the collection's own connection data, whose\n\t * `webApplicationRelativeDirectory` spells it, and reports it as the one collection visible there.\n\t */\n\tprotected override async requestResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tuserId: string,\n\t): Promise<ProviderAzureResource[] | undefined> {\n\t\ttry {\n\t\t\treturn await super.requestResourcesForUser(session, userId);\n\t\t} catch (ex) {\n\t\t\tif (!(ex instanceof RequestNotFoundError)) throw ex;\n\n\t\t\tconst azure = await this.authenticationService.apis.azure;\n\t\t\tconst addressed = await azure?.getAddressedCollection(\n\t\t\t\tthis,\n\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t);\n\t\t\tif (addressed == null) throw ex;\n\n\t\t\treturn [addressed];\n\t\t}\n\t}\n\n\t/**\n\t * The filtered work-item search: one WIQL query per page over ONE collection, then one detail read for the\n\t * page's slice. See {@link resolveWorkItemSearchScope} for why a search never spans several collections.\n\t */\n\tprotected override async searchProviderIssuesPage(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: {\n\t\t\trepos?: ProviderRepoInput[];\n\t\t\torg?: string;\n\t\t\tcriteria?: IssueSearchCriteria;\n\t\t\tcursor?: string;\n\t\t\tpageSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderIssueSearchPage | undefined> {\n\t\tconst azure = await this.authenticationService.apis.azure;\n\t\tif (azure == null) return undefined;\n\n\t\tthis.assertSearchDates(options.criteria);\n\t\tconst repos = options.repos && (await this.resolveRepositoryInputs(session, options.repos, cancellation));\n\t\t// A first page re-reads the collection's projects, so a project created since discovery is known before its\n\t\t// work items can turn up in a collection-wide query; a continuation keeps the set its first page resolved.\n\t\t// The facade's page-1 marker (`broadenIssues` retries a failed first page with it) is a first page too.\n\t\tconst scope = await this.resolveWorkItemSearchScope(\n\t\t\tsession,\n\t\t\trepos,\n\t\t\toptions.org,\n\t\t\tisAzureWorkItemSearchFirstPage(options.cursor),\n\t\t);\n\t\treturn azure.searchWorkItemsPage(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tscope.collection,\n\t\t\t{\n\t\t\t\tbaseUrl: this.collectionApiBaseUrl(session, scope.collection),\n\t\t\t\tcriteria: options.criteria,\n\t\t\t\tprojectNames: scope.projectNames,\n\t\t\t\tresolveProject: name => scope.projects.find(p => sameAzureName(p.name, name)),\n\t\t\t\tcursor: options.cursor,\n\t\t\t\tpageSize: options.pageSize,\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * Counts each scope with the WIQL its search would page through, so a count never previews constraints the read\n\t * doesn't apply. A scope this provider refuses (see {@link resolveWorkItemSearchScope}) is answered as that\n\t * refusal, so the facade drops only it; a request failure still fails the batch, which the facade isolates from\n\t * the other batches.\n\t */\n\tprotected override async countProviderIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tscopes: readonly { repos?: ProviderRepoInput[]; org?: string; criteria?: IssueSearchCriteria }[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderSearchCount[] | undefined> {\n\t\tconst azure = await this.authenticationService.apis.azure;\n\t\tif (azure == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapBounded(scopes, azureIssueCountConcurrency, s =>\n\t\t\trefusalAsCount(async () => {\n\t\t\t\tthis.assertSearchDates(s.criteria);\n\t\t\t\t// Re-reads the projects like a first search page does, so a count and the page it previews resolve\n\t\t\t\t// the same project set — a newer project can't be counted by one and refused or missed by the other.\n\t\t\t\tconst repos = s.repos && (await this.resolveRepositoryInputs(session, s.repos, cancellation));\n\t\t\t\tconst scope = await this.resolveWorkItemSearchScope(session, repos, s.org, true);\n\t\t\t\treturn azure.countWorkItems(\n\t\t\t\t\tthis,\n\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\tscope.collection,\n\t\t\t\t\t{\n\t\t\t\t\t\tbaseUrl: this.collectionApiBaseUrl(session, scope.collection),\n\t\t\t\t\t\tcriteria: s.criteria,\n\t\t\t\t\t\tprojectNames: scope.projectNames,\n\t\t\t\t\t},\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * The ONE collection a work-item search runs in, and the projects that bound it.\n\t *\n\t * A WIQL query is collection-scoped, and ordering a union of several would need every match's details rather\n\t * than one page's, so a search never spans collections. `org` names the collection; without it the repositories'\n\t * collection is used, and without either the only collection the account can see. Anything else — repositories\n\t * in two collections, or several visible collections and nothing to choose one — is refused rather than\n\t * narrowed to whichever came first.\n\t *\n\t * Repositories bound the query by their PROJECT, since Azure work items belong to projects rather than to\n\t * repositories, and every project must be one the collection actually has: WIQL answers an unknown project name\n\t * with an empty result, which would read as \"nothing matched\".\n\t */\n\tprivate async resolveWorkItemSearchScope(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos: ProviderRepoInput[] | undefined,\n\t\torg: string | undefined,\n\t\trefreshProjects: boolean = false,\n\t): Promise<{ collection: string; projects: AzureProjectDescriptor[]; projectNames?: string[] }> {\n\t\tconst repoCollections = uniqueAzureNames(repos?.map(r => r.namespace) ?? []);\n\t\tif (repoCollections.length > 1) {\n\t\t\tthrow this.searchUnavailable(\n\t\t\t\t'the repositories span several collections; search each collection separately',\n\t\t\t);\n\t\t}\n\t\tif (org && repoCollections.length === 1 && !sameAzureName(org, repoCollections[0])) {\n\t\t\tthrow this.searchUnavailable(`the repositories are not in the '${org}' collection`);\n\t\t}\n\n\t\tconst collections = await this.getSearchCollections(session);\n\t\tconst name = org || repoCollections[0] || (collections.length === 1 ? collections[0].name : undefined);\n\t\tif (name == null) {\n\t\t\tthrow this.searchUnavailable(\n\t\t\t\t`the account can see ${collections.length} collections; pass \\`org\\` to choose the one to search`,\n\t\t\t);\n\t\t}\n\n\t\tconst collection = findAzureCollection(collections, name);\n\t\tif (collection == null) throw this.searchUnavailable(`the '${name}' collection is not visible`);\n\n\t\tconst projects = await this.getSearchProjects(session, collection, refreshProjects);\n\t\tif (!repos?.length) return { collection: collection.name, projects: projects };\n\n\t\tconst projectNames = uniqueAzureNames(\n\t\t\trepos.map(r => {\n\t\t\t\tconst projectName = getAzureRepositoryIdentity({\n\t\t\t\t\towner: r.namespace,\n\t\t\t\t\tname: r.name,\n\t\t\t\t\tproject: r.project,\n\t\t\t\t}).projectName;\n\t\t\t\tif (projectName == null) {\n\t\t\t\t\tthrow this.searchUnavailable(`repository '${r.namespace}/${r.name}' names no project`);\n\t\t\t\t}\n\n\t\t\t\tconst project = projects.find(p => sameAzureName(p.name, projectName));\n\t\t\t\tif (project == null) {\n\t\t\t\t\tthrow this.searchUnavailable(`project '${projectName}' is not visible in '${collection.name}'`);\n\t\t\t\t}\n\n\t\t\t\treturn project.name;\n\t\t\t}),\n\t\t);\n\t\treturn { collection: collection.name, projects: projects, projectNames: projectNames };\n\t}\n\n\t/**\n\t * The filtered pull-request search. Azure's pull request query can only narrow by creator, reviewer, status and\n\t * repository, so every facet is drained (see {@link drainPullRequestSearch}) and the criteria it can't express\n\t * are applied to the complete facets; the union is then ordered and served from a keyset cursor.\n\t */\n\tprotected override async searchProviderPullRequestsPage(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: {\n\t\t\trepos?: ProviderRepoInput[];\n\t\t\torg?: string;\n\t\t\tcriteria?: PullRequestSearchCriteria;\n\t\t\tcursor?: string;\n\t\t\tpageSize?: number;\n\t\t\tsummary?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderPullRequestSearchPage | undefined> {\n\t\tthis.assertSearchDates(options.criteria);\n\t\tconst sort = options.criteria?.sort ?? defaultPullRequestSort;\n\t\tconst query = toPullRequestSearchQuery(options, sort);\n\t\tconst key = toAzurePullRequestSearchCursorKey(query);\n\t\tconst cursor = parseAzurePullRequestSearchCursor(options.cursor, key);\n\t\t// A first page drains fresh, into a drain of its own, and its continuations page through that one: the cache\n\t\t// keeps it alive for as long as the pagination keeps reading it (an access TTL), so rows can't move between\n\t\t// pages, and a later first page of the same query never replaces it. A continuation whose drain is gone is\n\t\t// refused, like an expired work-item snapshot: resuming against a re-drain could skip or repeat a pull request\n\t\t// whose sort date changed. The drain is keyed by credential and installation too, so a cursor handed to\n\t\t// another connection finds nothing and is refused the same way.\n\t\tconst drainId = cursor?.drain ?? uuid();\n\t\tconst drainKey = this.pullRequestSearchCacheKey(session, query, drainId);\n\t\t// A continuation only ever READS its drain: creating one under its id would be the re-drain refused above.\n\t\tconst drainFound =\n\t\t\tcursor != null\n\t\t\t\t? this._pullRequestSearches.get(drainKey)\n\t\t\t\t: this.getPullRequestSearch(this._pullRequestSearches, drainKey, session, options, sort, cancellation);\n\t\tif (drainFound == null) {\n\t\t\tthrow new Error(\n\t\t\t\t'Pull request search results expired or belong to another connection; restart the read without a cursor',\n\t\t\t);\n\t\t}\n\n\t\tconst drain = await drainFound;\n\t\tif (cursor == null) {\n\t\t\t// Also the query's latest drain, which a count of the same query reads rather than draining again. Stored\n\t\t\t// through `getOrCreate`, which applies the cache's capacity and expiry; `set` applies neither.\n\t\t\tconst latestKey = this.pullRequestSearchCacheKey(session, query);\n\t\t\tthis._latestPullRequestSearches.delete(latestKey);\n\t\t\tvoid this._latestPullRequestSearches.getOrCreate(latestKey, () => Promise.resolve(drain));\n\t\t}\n\n\t\tconst pageSize = toAzureSearchPageSize(options.pageSize, 50, 100);\n\t\tconst start =\n\t\t\tcursor == null\n\t\t\t\t? 0\n\t\t\t\t: drain.rows.findIndex(r => compareAzurePullRequestSearchPositions(r.position, cursor.after, sort) > 0);\n\t\tconst slice = start < 0 ? [] : drain.rows.slice(start, start + pageSize);\n\t\tconst page = cursor?.page ?? 1;\n\t\tconst last = slice.at(-1);\n\t\tconst hasMore = last != null && start + slice.length < drain.rows.length;\n\t\treturn {\n\t\t\tvalues: slice.map(r =>\n\t\t\t\tfromProviderPullRequest(r.pr, this, {\n\t\t\t\t\tproject: r.project,\n\t\t\t\t\tcurrentAccount: r.currentAccount,\n\t\t\t\t\tprojection: options.summary ? 'search-summary' : 'search',\n\t\t\t\t}),\n\t\t\t),\n\t\t\tcursor: hasMore\n\t\t\t\t? JSON.stringify({ key: key, drain: drainId, page: page + 1, after: last.position })\n\t\t\t\t: undefined,\n\t\t\thasMore: hasMore,\n\t\t\tpage: page,\n\t\t\ttruncated: drain.truncated,\n\t\t\ttotalCount: drain.truncated ? undefined : drain.rows.length,\n\t\t\tmetadata: drain.failures != null ? { completeness: 'partial', failures: drain.failures } : undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Counts each scope from the latest drain of its query, the one a search's first page just read, or drains it; see\n\t * {@link searchProviderPullRequestsPage}.\n\t */\n\tprotected override async countProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tscopes: readonly { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria }[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<(ProviderPullRequestCount | Error)[] | undefined> {\n\t\t// One scope at a time: each is a drain that already fans out over its facets, and the facade runs several\n\t\t// batches of scopes at once, so a concurrent batch would multiply the requests reaching the server.\n\t\treturn mapBounded(scopes, 1, s =>\n\t\t\trefusalAsCount(async () => {\n\t\t\t\tthis.assertSearchDates(s.criteria);\n\t\t\t\tconst sort = s.criteria?.sort ?? defaultPullRequestSort;\n\t\t\t\tconst drain = await this.getPullRequestSearch(\n\t\t\t\t\tthis._latestPullRequestSearches,\n\t\t\t\t\tthis.pullRequestSearchCacheKey(session, toPullRequestSearchQuery(s, sort)),\n\t\t\t\t\tsession,\n\t\t\t\t\ts,\n\t\t\t\t\tsort,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t\t// Past the drain budget the true total is unknown, so it is reported as uncounted rather than understated.\n\t\t\t\treturn { count: drain.truncated ? undefined : drain.rows.length };\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * The drain each pagination pages through, one per first page (see {@link searchProviderPullRequestsPage}), so\n\t * the 50 most recently read paginations are kept for as long as they keep reading.\n\t */\n\tprivate readonly _pullRequestSearches = new PromiseCache<string, AzurePullRequestSearchDrain>({\n\t\tcapacity: 50,\n\t\taccessTTL: pullRequestSearchIdleTtl,\n\t\tcreateTTL: pullRequestSearchMaxTtl,\n\t});\n\t/**\n\t * Each query's latest drain, which its count reads for {@link pullRequestCountReuseTtl}. Apart from the\n\t * paginations' drains, so counting and starting searches never evicts a pagination still being read.\n\t */\n\tprivate readonly _latestPullRequestSearches = new PromiseCache<string, AzurePullRequestSearchDrain>({\n\t\tcapacity: 20,\n\t\tcreateTTL: pullRequestCountReuseTtl,\n\t});\n\n\t/**\n\t * Keyed by the query itself, not its cursor fingerprint, so two queries whose fingerprints collide can never share\n\t * a drain; by credential and installation, so two accounts or installations never read each other's results; and\n\t * by `drainId` for a pagination's own drain, left out for the query's latest one.\n\t */\n\tprivate pullRequestSearchCacheKey(\n\t\tsession: ProviderAuthenticationSession,\n\t\tquery: unknown,\n\t\tdrainId?: string,\n\t): string {\n\t\treturn JSON.stringify([session.accessToken, this.apiBaseUrlFor(session), query, drainId ?? null]);\n\t}\n\n\tprivate getPullRequestSearch(\n\t\tcache: PromiseCache<string, AzurePullRequestSearchDrain>,\n\t\tcacheKey: string,\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria },\n\t\tsort: PullRequestSorting,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<AzurePullRequestSearchDrain> {\n\t\treturn cache.getOrCreate(\n\t\t\tcacheKey,\n\t\t\t(_cacheable, signal) => this.drainPullRequestSearch(session, options, sort, signal),\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\t/**\n\t * Every pull request matching the search, filtered, deduplicated and ordered.\n\t *\n\t * One facet per (repository or project) × relationship: `Author` reads by creator, while `Assignee` and\n\t * `ReviewRequested` both read by reviewer, since Azure has no assignee distinct from its reviewers: every open pull\n\t * request, kept when it names the user or one of the user's groups, and closed or merged ones through Azure's filter\n\t * for the user (see `toAzureReviewerReads`). Each facet is drained to {@link azurePullRequestSearchFacetLimit}; a\n\t * facet that still has more marks the whole result truncated, because its unread rows could sort anywhere in the\n\t * union. A facet that fails fails the search: a union missing one facet would be served in an order it doesn't\n\t * have. A collection whose groups can't be read is the exception: its facets still read what names the user, and\n\t * the result is reported incomplete with that collection's failure.\n\t */\n\tprivate async drainPullRequestSearch(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria },\n\t\tsort: PullRequestSorting,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<AzurePullRequestSearchDrain> {\n\t\tconst criteria = options.criteria;\n\t\t// Built before any request, so criteria it can't apply fail the search before the facets are drained.\n\t\tconst matches = toAzurePullRequestSearchFilter(criteria);\n\t\tconst relationships = new Set(criteria?.relationships ?? []);\n\t\tconst wantAuthored = relationships.has(PullRequestFilter.Author);\n\t\tconst wantReviewed =\n\t\t\trelationships.has(PullRequestFilter.Assignee) || relationships.has(PullRequestFilter.ReviewRequested);\n\n\t\t// A drain runs for a first page (or once its predecessor expired), so it re-reads the projects it fans out\n\t\t// over: an org search trusting the connection-long discovery cache would silently skip a newer project.\n\t\t// Settled here rather than before the query is keyed, so a cursor stays the caller's whatever discovery answers.\n\t\tconst repos = options.repos && (await this.resolveRepositoryInputs(session, options.repos, cancellation));\n\t\tconst facets = await this.resolvePullRequestSearchFacets(session, repos, options.org);\n\n\t\t// The current user's id is resolved PER COLLECTION: Azure DevOps Server gives one person a different\n\t\t// identity id in each collection than at the server level, and a creator/reviewer filter only matches the\n\t\t// collection's. The server-level id matches nothing there and would serve an empty result as if nobody had\n\t\t// authored anything.\n\t\tconst userIds = new Map<string, string>();\n\t\tif (relationships.size > 0) {\n\t\t\tfor (const collection of uniqueAzureNames(facets.map(f => f.collection))) {\n\t\t\t\tconst userId = await this.getFilterUserId(session, collection);\n\t\t\t\tif (userId == null) {\n\t\t\t\t\tthrow this.searchUnavailable(`the current user could not be resolved in '${collection}'`);\n\t\t\t\t}\n\n\t\t\t\tuserIds.set(collection, userId);\n\t\t\t}\n\t\t}\n\n\t\t// Every group the user is in, per collection, which the reviewer facets keep pull requests for too (see\n\t\t// `toAzureReviewerReads`). A collection whose groups can't be read (e.g. a token without the Identity scope)\n\t\t// keeps what names the user and is reported as a failure of that collection, so the search is incomplete\n\t\t// rather than refused, and a credential its other reads accept isn't treated as a dead one.\n\t\tconst failures: CollectionScopeFailure[] = [];\n\t\tconst groupsByCollection = new Map(\n\t\t\twantReviewed\n\t\t\t\t? await Promise.all(\n\t\t\t\t\t\tArray.from(userIds, async ([collection, userId]) => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\t\tawait this.getReviewerGroupIds(session, collection, userId),\n\t\t\t\t\t\t\t\t] as const;\n\t\t\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t\t\tconst resourceId = facets.find(f => f.collection === collection)!.project.resourceId;\n\t\t\t\t\t\t\t\tfailures.push(\n\t\t\t\t\t\t\t\t\ttoCollectionScopeFailure({ providerId: this.id, resourceId: resourceId }, ex),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn [collection, new Set<string>()] as const;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t: [],\n\t\t);\n\t\tconst groupIds = new Set([...groupsByCollection.values()].flatMap(ids => [...ids]));\n\n\t\tconst states = toProviderPullRequestStates(criteria?.states?.length ? criteria.states : 'open');\n\t\tconst filtersFor = (\n\t\t\tcollection: string,\n\t\t): { filter: AzureReviewerRead['filter'] & { authorLogin?: string }; keep?: AzureReviewerRead['keep'] }[] => {\n\t\t\tif (relationships.size === 0) return [{ filter: {} }];\n\n\t\t\tconst userId = userIds.get(collection)!;\n\t\t\treturn [\n\t\t\t\t...(wantAuthored ? [{ filter: { authorLogin: userId } }] : []),\n\t\t\t\t...(wantReviewed ? toAzureReviewerReads(userId, groupsByCollection.get(collection)!, states) : []),\n\t\t\t];\n\t\t};\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst { tokenWithInfo, options: apiOptions } = this.getApiOptions(session);\n\t\tconst drains = await mapBounded(\n\t\t\tfacets.flatMap(facet => filtersFor(facet.collection).map(f => ({ facet: facet, ...f }))),\n\t\t\tproviderFanOutConcurrency,\n\t\t\tasync ({ facet, filter, keep }) => {\n\t\t\t\tconst baseUrl = this.collectionApiBaseUrl(session, facet.collection);\n\t\t\t\tconst values: ProviderPullRequest[] = [];\n\t\t\t\tlet page = 1;\n\t\t\t\tfor (let read = 1; ; read++) {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\tconst input = {\n\t\t\t\t\t\t...apiOptions,\n\t\t\t\t\t\t// A reviewer facet narrows the states itself (see `toAzureReviewerReads`).\n\t\t\t\t\t\tstates: states,\n\t\t\t\t\t\t...filter,\n\t\t\t\t\t\tpage: page,\n\t\t\t\t\t\tpageSize: azurePullRequestSearchPageSize,\n\t\t\t\t\t\tbaseUrl: baseUrl,\n\t\t\t\t\t};\n\t\t\t\t\tconst result =\n\t\t\t\t\t\tfacet.repository != null\n\t\t\t\t\t\t\t? await api\n\t\t\t\t\t\t\t\t\t.getPullRequestsForRepo(\n\t\t\t\t\t\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\tnamespace: facet.collection,\n\t\t\t\t\t\t\t\t\t\t\tname: facet.repository,\n\t\t\t\t\t\t\t\t\t\t\tproject: facet.project.name,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.then(r => ({\n\t\t\t\t\t\t\t\t\t\tvalues: r.values,\n\t\t\t\t\t\t\t\t\t\tmore: r.paging?.more === true,\n\t\t\t\t\t\t\t\t\t\tnextPage: r.paging?.nextPage,\n\t\t\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t\t: await api\n\t\t\t\t\t\t\t\t\t.getPullRequestsForAzureProject(\n\t\t\t\t\t\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\t\t\t\t\t\t{ namespace: facet.collection, project: facet.project.name },\n\t\t\t\t\t\t\t\t\t\tinput,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t.then(r =>\n\t\t\t\t\t\t\t\t\t\tr != null\n\t\t\t\t\t\t\t\t\t\t\t? { values: r.data, more: r.hasMore, nextPage: r.nextPage ?? undefined }\n\t\t\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\tif (result == null) throw new Error('Azure DevOps returned no pull request page');\n\n\t\t\t\t\tvalues.push(...result.values);\n\t\t\t\t\tif (!result.more) return { facet: facet, keep: keep, values: values, truncated: false };\n\t\t\t\t\t// Follows the page the provider says comes next rather than assuming one: a continuation that\n\t\t\t\t\t// doesn't advance would re-read or skip rows, so it fails the facet — and with it the search —\n\t\t\t\t\t// instead of serving a union built from it.\n\t\t\t\t\tif (result.nextPage == null || result.nextPage <= page) {\n\t\t\t\t\t\tthrow new Error('Azure DevOps returned no advancing pull request continuation');\n\t\t\t\t\t}\n\t\t\t\t\t// The budget counts pages READ, not rows kept: several states are one `status=all` query the SDK\n\t\t\t\t\t// narrows client-side, so counting survivors would keep paging through rows it discards.\n\t\t\t\t\tif (read * azurePullRequestSearchPageSize >= azurePullRequestSearchFacetLimit) {\n\t\t\t\t\t\treturn { facet: facet, keep: keep, values: values, truncated: true };\n\t\t\t\t\t}\n\n\t\t\t\t\tpage = result.nextPage;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tconst rows = new Map<string, AzurePullRequestSearchRow>();\n\t\tfor (const { facet, keep, values } of drains) {\n\t\t\tfor (const pr of values) {\n\t\t\t\tif (keep != null && !keep(pr)) continue;\n\t\t\t\tif (!matches(pr)) continue;\n\n\t\t\t\tconst identity =\n\t\t\t\t\tgetProviderPullRequestIdentity(pr) ?? `project:${facet.collection}/${facet.project.name}:${pr.id}`;\n\t\t\t\tif (rows.has(identity)) continue;\n\n\t\t\t\tconst userId = userIds.get(facet.collection);\n\t\t\t\trows.set(identity, {\n\t\t\t\t\tpr: markMyGroupReviews(pr, groupIds),\n\t\t\t\t\tproject: facet.project,\n\t\t\t\t\tcurrentAccount: userId != null ? { id: userId } : undefined,\n\t\t\t\t\tposition: toAzurePullRequestSearchPosition(pr, sort, identity),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\trows: [...rows.values()].sort((a, b) =>\n\t\t\t\tcompareAzurePullRequestSearchPositions(a.position, b.position, sort),\n\t\t\t),\n\t\t\ttruncated: failures.length > 0 || drains.some(d => d.truncated),\n\t\t\tfailures: failures.length > 0 ? failures : undefined,\n\t\t};\n\t}\n\n\t/**\n\t * The repositories or projects a pull-request search reads, each with its collection and project descriptor.\n\t *\n\t * Repositories are read one by one; an `org` is its collection's projects; a search bounded only by the current\n\t * user reads every project the account can see, the same breadth as the account-wide pull request read.\n\t */\n\tprivate async resolvePullRequestSearchFacets(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos: ProviderRepoInput[] | undefined,\n\t\torg: string | undefined,\n\t): Promise<{ collection: string; project: AzureProjectDescriptor; repository?: string }[]> {\n\t\tconst collections = await this.getSearchCollections(session);\n\t\tconst collectionFor = (name: string): AzureOrganizationDescriptor => {\n\t\t\tconst collection = findAzureCollection(collections, name);\n\t\t\tif (collection == null) throw this.searchUnavailable(`the '${name}' collection is not visible`);\n\n\t\t\treturn collection;\n\t\t};\n\n\t\tif (repos?.length) {\n\t\t\tif (org && repos.some(r => !sameAzureName(r.namespace, org))) {\n\t\t\t\tthrow this.searchUnavailable(`the repositories are not all in the '${org}' collection`);\n\t\t\t}\n\n\t\t\t// One discovery per distinct collection, however many of its repositories the search names.\n\t\t\tconst projectsByCollection = new Map<string, Promise<AzureProjectDescriptor[]>>();\n\t\t\tconst projectsOf = (collection: AzureOrganizationDescriptor): Promise<AzureProjectDescriptor[]> => {\n\t\t\t\tlet projects = projectsByCollection.get(collection.id);\n\t\t\t\tif (projects == null) {\n\t\t\t\t\tprojects = this.getSearchProjects(session, collection, true);\n\t\t\t\t\tprojectsByCollection.set(collection.id, projects);\n\t\t\t\t}\n\t\t\t\treturn projects;\n\t\t\t};\n\n\t\t\treturn Promise.all(\n\t\t\t\trepos.map(async r => {\n\t\t\t\t\tconst collection = collectionFor(r.namespace);\n\t\t\t\t\tconst identity = getAzureRepositoryIdentity({\n\t\t\t\t\t\towner: r.namespace,\n\t\t\t\t\t\tname: r.name,\n\t\t\t\t\t\tproject: r.project,\n\t\t\t\t\t});\n\t\t\t\t\tif (identity.projectName == null) {\n\t\t\t\t\t\tthrow this.searchUnavailable(`repository '${r.namespace}/${r.name}' names no project`);\n\t\t\t\t\t}\n\t\t\t\t\t// The repository becomes a URL segment the SDK encodes but doesn't validate, and a segment of `..`\n\t\t\t\t\t// survives encoding and resolves to the project-wide route: refused rather than widened.\n\t\t\t\t\tif (!isAzureRouteSegment(identity.repositoryName)) {\n\t\t\t\t\t\tthrow this.searchUnavailable(`repository '${r.namespace}/${r.name}' is not a valid name`);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst project = (await projectsOf(collection)).find(p =>\n\t\t\t\t\t\tsameAzureName(p.name, identity.projectName!),\n\t\t\t\t\t);\n\t\t\t\t\tif (project == null) {\n\t\t\t\t\t\tthrow this.searchUnavailable(\n\t\t\t\t\t\t\t`project '${identity.projectName}' is not visible in '${collection.name}'`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn { collection: collection.name, project: project, repository: identity.repositoryName };\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\tconst scoped = org ? [collectionFor(org)] : collections;\n\t\tconst projects = await Promise.all(scoped.map(c => this.getSearchProjects(session, c, true)));\n\t\treturn projects.flat().map(p => ({ collection: p.resourceName, project: p }));\n\t}\n\n\tprivate readonly _collectionUserIds = new PromiseCache<string, string | undefined>({ capacity: 50 });\n\n\t/**\n\t * The current user's identity id in `collection`, read from the collection's own connection data, which is\n\t * what Azure's creator and reviewer filters compare against. Cached per credential and collection, since it\n\t * can't change for either.\n\t */\n\tprotected override getFilterUserId(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcollection: string,\n\t): Promise<string | undefined> {\n\t\tconst baseUrl = this.collectionApiBaseUrl(session, collection);\n\t\treturn this._collectionUserIds.getOrCreate(\n\t\t\tJSON.stringify([session.accessToken, baseUrl, collection.toLowerCase()]),\n\t\t\tasync cacheable => {\n\t\t\t\tconst azure = await this.authenticationService.apis.azure;\n\t\t\t\tconst user = await azure?.getCurrentUserOnServer(\n\t\t\t\t\tthis,\n\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t`${baseUrl}/${encodeURIComponent(collection)}`,\n\t\t\t\t);\n\t\t\t\t// A response without an identity must not refuse later relationship searches from a cached miss.\n\t\t\t\tif (user?.id == null) {\n\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t}\n\n\t\t\t\treturn user?.id;\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * Resolved per collection, which a raw row names as its repository owner: a collection's pull requests carry the\n\t * id {@link getFilterUserId} resolves there, never the server-level account's. A row that names no collection or\n\t * has no author to match gets no viewer, nor does one in a collection whose id can't be read: its authorship\n\t * stays unknown.\n\t */\n\toverride async getPullRequestViewers(\n\t\tpullRequests: readonly (ProviderPullRequest | PullRequest)[],\n\t\tconnectionId?: string,\n\t): Promise<({ id: string; username?: string } | undefined)[]> {\n\t\tconst session = await this.resolveReadSessionOrThrow(connectionId, undefined);\n\t\tif (session == null) return pullRequests.map(() => undefined);\n\n\t\tconst viewerFor = this.getOrganizationViewers(session, undefined);\n\t\treturn Promise.all(\n\t\t\tpullRequests.map(pr => {\n\t\t\t\t// Azure DevOps Server's rows are provider-apis' own; only GitHub's are native.\n\t\t\t\tconst collection = isNativePullRequest(pr) ? undefined : pr.repository?.owner?.login;\n\t\t\t\treturn collection && pr.author != null ? viewerFor(collection) : Promise.resolve(undefined);\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Ignores `account`: it is the server-level one, which no collection's pull requests carry. A collection whose id\n\t * can't be read resolves `undefined`, since authorship is optional enrichment and one collection's failed lookup\n\t * must not fail the read or blank the others; it is asked once per read, as a miss isn't cached.\n\t */\n\tprotected override getOrganizationViewers(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_account: { id: string; username?: string } | undefined,\n\t): (collection: string) => Promise<{ id: string } | undefined> {\n\t\tconst viewers = new Map<string, Promise<{ id: string } | undefined>>();\n\t\treturn collection => {\n\t\t\tconst key = collection.toLowerCase();\n\t\t\tlet viewer = viewers.get(key);\n\t\t\tif (viewer == null) {\n\t\t\t\tviewer = this.getFilterUserId(session, collection).then(\n\t\t\t\t\tid => (id != null ? { id: id } : undefined),\n\t\t\t\t\t() => undefined,\n\t\t\t\t);\n\t\t\t\tviewers.set(key, viewer);\n\t\t\t}\n\t\t\treturn viewer;\n\t\t};\n\t}\n\n\t/** Every collection the account can see, or a refusal when discovery itself failed. */\n\tprivate async getSearchCollections(session: ProviderAuthenticationSession): Promise<AzureOrganizationDescriptor[]> {\n\t\tconst collections = await this.getProviderResourcesForUser(session);\n\t\tif (collections == null) throw this.searchUnavailable('the account’s collections could not be read');\n\n\t\treturn collections;\n\t}\n\n\t/**\n\t * A collection's projects, refused when discovery was incomplete: a search bounded by an incomplete project set\n\t * would silently omit the missing projects' matches. `refresh` re-reads them rather than trusting the discovery\n\t * cache, which lives for the whole connection and so doesn't know a project created since.\n\t */\n\tprivate async getSearchProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcollection: AzureOrganizationDescriptor,\n\t\trefresh: boolean = false,\n\t): Promise<AzureProjectDescriptor[]> {\n\t\tconst projects = refresh\n\t\t\t? await this.refreshSearchProjects(session, collection)\n\t\t\t: await this.getProviderProjectsForResources(session, [collection]);\n\t\tif (projects.metadata != null && projects.metadata.completeness !== 'complete') {\n\t\t\tthrow this.searchUnavailable(`the projects of the '${collection.name}' collection could not all be read`);\n\t\t}\n\n\t\treturn projects.values;\n\t}\n\n\tprivate readonly _projectRefreshes = new Map<\n\t\tstring,\n\t\tPromise<ProviderApiCollectionResult<AzureProjectDescriptor>>\n\t>();\n\n\t/**\n\t * Re-reads a collection's projects, sharing one read among the refreshes IN FLIGHT at once — a count batch or a\n\t * multi-repository drain refreshes the same collection once per scope, and each would otherwise re-read every\n\t * project page. Nothing outlives the read, so the next search still sees a project created after it.\n\t */\n\tprivate refreshSearchProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcollection: AzureOrganizationDescriptor,\n\t): Promise<ProviderApiCollectionResult<AzureProjectDescriptor>> {\n\t\tconst key = `${this.discoveryKey(session)}:${collection.id}`;\n\t\tlet pending = this._projectRefreshes.get(key);\n\t\tif (pending == null) {\n\t\t\tpending = this.getProviderProjectsForResources(session, [collection], true).finally(() => {\n\t\t\t\tthis._projectRefreshes.delete(key);\n\t\t\t});\n\t\t\tthis._projectRefreshes.set(key, pending);\n\t\t}\n\n\t\treturn pending;\n\t}\n\n\t/**\n\t * Refuses dates the search can't apply before anything is read. The facade only checks that dates are\n\t * supported, not their shape, and a refusal here stays with its own scope in a count batch.\n\t */\n\tprivate assertSearchDates(criteria: { updatedAfter?: string; createdAfter?: string } | undefined): void {\n\t\tconst invalid = getInvalidAzureSearchDate(criteria);\n\t\tif (invalid != null) throw this.searchUnavailable(invalid);\n\t}\n\n\tprivate searchUnavailable(reason: string): IntegrationReadUnavailableError {\n\t\treturn new IntegrationReadUnavailableError(this.name, `search refused: ${reason}.`);\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tsuper.providerOnDisconnect();\n\t\tthis._pullRequestSearches.clear();\n\t\tthis._latestPullRequestSearches.clear();\n\t\tthis._collectionUserIds.clear();\n\t\tthis._collectionNames.clear();\n\t}\n\n\tprotected override async _requestForCurrentUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst azure = await this.authenticationService.apis.azure;\n\t\tconst user = azure\n\t\t\t? await azure.getCurrentUserOnServer(this, toTokenWithInfo(this.id, session), this.apiBaseUrlFor(session))\n\t\t\t: undefined;\n\t\treturn user\n\t\t\t? {\n\t\t\t\t\tprovider: this,\n\t\t\t\t\tid: user.id,\n\t\t\t\t\tname: user.name ?? undefined,\n\t\t\t\t\temail: user.email ?? undefined,\n\t\t\t\t\tavatarUrl: user.avatarUrl ?? undefined,\n\t\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gBAAgB,KAAK,IAAI,OAAO,GAAG,KAAK,cAAc,OAAO,CAAC,IACvG,KAAA;EACH,OAAO,OACJ;GACA,UAAU;GACV,IAAI,KAAK;GACT,MAAM,KAAK,QAAQ,KAAA;GACnB,OAAO,KAAK,SAAS,KAAA;GACrB,WAAW,KAAK,aAAa,KAAA;GAC7B,UAAU,KAAK,YAAY,KAAA;EAC5B,IACC,KAAA;CACJ;AACD"}
|
|
@@ -145,29 +145,33 @@ var JiraServerIntegration = class extends IssuesIntegration {
|
|
|
145
145
|
};
|
|
146
146
|
if (options?.user != null) {
|
|
147
147
|
const read = await readUserScopedJiraIssues(fetchPage, options.filters, toUserIdentities(options.user), drainOptions);
|
|
148
|
-
const
|
|
148
|
+
const drain = {
|
|
149
|
+
values: toUniqueJiraIssueShapes(read.issues, this),
|
|
150
|
+
metadata: read.metadata,
|
|
151
|
+
scope: drainOptions.failureScope
|
|
152
|
+
};
|
|
149
153
|
return read.truncated ? {
|
|
150
|
-
|
|
154
|
+
...drain,
|
|
151
155
|
truncated: true,
|
|
152
|
-
recovery: "none"
|
|
153
|
-
metadata: read.metadata
|
|
156
|
+
recovery: "none"
|
|
154
157
|
} : {
|
|
155
|
-
|
|
156
|
-
truncated: false
|
|
157
|
-
metadata: read.metadata
|
|
158
|
+
...drain,
|
|
159
|
+
truncated: false
|
|
158
160
|
};
|
|
159
161
|
}
|
|
160
162
|
const unscoped = await drainJiraIssues(fetchPage, {}, drainOptions);
|
|
161
|
-
const
|
|
163
|
+
const drain = {
|
|
164
|
+
values: unscoped.issues.map((issue) => toIssueShape(issue, this, { projection: "project" })).filter((result) => result !== void 0),
|
|
165
|
+
metadata: unscoped.metadata,
|
|
166
|
+
scope: drainOptions.failureScope
|
|
167
|
+
};
|
|
162
168
|
return unscoped.status !== "complete" ? {
|
|
163
|
-
|
|
169
|
+
...drain,
|
|
164
170
|
truncated: true,
|
|
165
|
-
recovery: unscoped.status === "backstop" ? "narrow-scope" : "none"
|
|
166
|
-
metadata: unscoped.metadata
|
|
171
|
+
recovery: unscoped.status === "backstop" ? "narrow-scope" : "none"
|
|
167
172
|
} : {
|
|
168
|
-
|
|
169
|
-
truncated: false
|
|
170
|
-
metadata: unscoped.metadata
|
|
173
|
+
...drain,
|
|
174
|
+
truncated: false
|
|
171
175
|
};
|
|
172
176
|
}
|
|
173
177
|
/**
|