@gitkraken/core-gitlens 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/dist/plus/integrations/authentication/cloudIntegrationService.js +24 -7
  3. package/dist/plus/integrations/authentication/cloudIntegrationService.js.map +1 -1
  4. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts +7 -0
  5. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +13 -3
  6. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js.map +1 -1
  7. package/dist/plus/integrations/integrationService.js +4 -2
  8. package/dist/plus/integrations/integrationService.js.map +1 -1
  9. package/dist/plus/integrations/models/gitHostIntegration.js +20 -20
  10. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  11. package/dist/plus/integrations/models/integration.d.ts +29 -3
  12. package/dist/plus/integrations/models/integration.js +53 -12
  13. package/dist/plus/integrations/models/integration.js.map +1 -1
  14. package/dist/plus/integrations/models/issuesIntegration.js +9 -9
  15. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  16. package/dist/plus/integrations/providers/azureDevOps.js +1 -1
  17. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  18. package/dist/plus/integrations/providers/azureDevOpsServer.js +1 -1
  19. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  20. package/dist/plus/integrations/providers/bitbucket-server.js +1 -1
  21. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  22. package/dist/plus/integrations/providers/bitbucket.js +1 -1
  23. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  24. package/dist/plus/integrations/providers/github.js +2 -2
  25. package/dist/plus/integrations/providers/github.js.map +1 -1
  26. package/dist/plus/integrations/providers/gitlab.js +1 -1
  27. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  28. package/package.json +1 -1
@@ -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 miss is not cached: the lookup degrades to `undefined` on a transient failure, and caching that\n\t\t\t\t// would refuse every relationship search in the collection until the connection is dropped.\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.resolveReadSession(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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AAqB;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 } 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 miss is not cached: the lookup degrades to `undefined` on a transient failure, and caching that\n\t\t\t\t// would refuse every relationship search in the collection until the connection is dropped.\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;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O,EAAE,GAAG,WAAW;EACxD,IAAI,UAAU,KAAK,kBAAkB,IAAI,GAAG;EAC5C,IAAI,WAAW,MAAM;GACpB,UAAU,KAAK,gCAAgC,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,cAAc;IACzF,KAAK,kBAAkB,OAAO,GAAG;GAClC,CAAC;GACD,KAAK,kBAAkB,IAAI,KAAK,OAAO;EACxC;EAEA,OAAO;CACR;;;;;CAMA,kBAA0B,UAA8E;EACvG,MAAM,UAAU,0BAA0B,QAAQ;EAClD,IAAI,WAAW,MAAM,MAAM,KAAK,kBAAkB,OAAO;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"}
@@ -101,7 +101,7 @@ var BitbucketServerIntegration = class extends GitHostIntegration {
101
101
  }
102
102
  async getRepoInfo(repo) {
103
103
  const api = await this.getProvidersApi();
104
- const session = await this.resolveReadSession(repo.connectionId, void 0);
104
+ const session = await this.resolveReadSessionOrThrow(repo.connectionId, void 0);
105
105
  if (session == null) return void 0;
106
106
  return api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, { baseUrl: this.apiBaseUrlFor(session) });
107
107
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucket-server.js","names":[],"sources":["../../../../../plus/integrations/src/providers/bitbucket-server.ts"],"sourcesContent":["import type { Account, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestMergeMethod,\n\tPullRequestSearchCriteria,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { GitRemote } from '@gitlens/git/models/remote.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport { CancellationError, raceWithSignal } from '@gitlens/utils/cancellation.js';\nimport { md5 } from '@gitlens/utils/crypto.js';\nimport type { Emitter } from '@gitlens/utils/event.js';\nimport type { PagedResult } from '@gitlens/utils/paging.js';\nimport { mapSettledBounded, nonnullSettled } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';\nimport type {\n\tAuthenticationSessionLike as AuthenticationSession,\n\tProviderAuthenticationSession,\n} from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { GitSelfManagedHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport type { ResponseHeaders } from '../errors.js';\nimport { AuthenticationError, getResponseHeader } from '../errors.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport type { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from '../models/gitHostIntegration.js';\nimport { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { IntegrationKey, ProviderPullRequestCount, ProviderPullRequestSearchPage } from '../models/integration.js';\nimport type { BitbucketServerSearchUser } from './bitbucket-server/pullRequestSearch.js';\nimport { getBitbucketServerPullRequestIdentityFromMaybeUrl } from './bitbucket/bitbucket.utils.js';\nimport type { BitbucketRepositoryDescriptor } from './bitbucket/models.js';\nimport type {\n\tProviderHierarchyResult,\n\tProviderOrganization,\n\tProviderPullRequest,\n\tProviderRepoInput,\n\tProviderRepository,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tproviderPullRequestMatchesSearch,\n\tProviderPullRequestReviewState,\n\tprovidersMetadata,\n\tPullRequestFilter,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport type { ProvidersApi } from './providersApi.js';\nimport {\n\tcollectProviderPagedResult,\n\tflatSettledOrThrow,\n\tparsePageCursor,\n\ttoPageCursor,\n} from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[GitSelfManagedHostIntegrationId.BitbucketServer];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\n\nexport class BitbucketServerIntegration extends GitHostIntegration<\n\tGitSelfManagedHostIntegrationId.BitbucketServer,\n\tBitbucketRepositoryDescriptor\n> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = GitSelfManagedHostIntegrationId.BitbucketServer;\n\tprotected readonly key =\n\t\t`${this.id}:${this.domain}` satisfies IntegrationKey<GitSelfManagedHostIntegrationId.BitbucketServer>;\n\treadonly name: string = 'Bitbucket Data Center';\n\n\tconstructor(\n\t\tctx: IntegrationServiceContext,\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tgetProvidersApi: () => Promise<ProvidersApi>,\n\t\tdidChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t\tprivate readonly _domain: string,\n\t) {\n\t\tsuper(ctx, authenticationService, getProvidersApi, didChangeConnection);\n\t}\n\n\tget domain(): string {\n\t\treturn this._domain;\n\t}\n\n\tprotected apiBaseUrlFor(session: ProviderAuthenticationSession): string {\n\t\treturn this.getSelfManagedApiBaseUrl(session);\n\t}\n\n\tprotected override async mergeProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tpr: PullRequest,\n\t\toptions?: {\n\t\t\tmergeMethod?: PullRequestMergeMethod;\n\t\t},\n\t): Promise<boolean> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.mergePullRequest(toTokenWithInfo(this.id, session), pr, {\n\t\t\tmergeMethod: options?.mergeMethod,\n\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t});\n\t}\n\n\tprotected override async getProviderAccountForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerAccountForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{\n\t\t\t\tavatarSize: options?.avatarSize,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderAccountForEmail(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_email: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\tprotected override async getProviderDefaultBranch(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t): Promise<DefaultBranch | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\t{ id }: { id: string; key: string },\n\t\ttype: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tif (type === 'issue') {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequestById(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot:\n\t * provider-apis has no single pull request read for Bitbucket, so this uses our own.\n\t */\n\tprotected override async getProviderPullRequestsBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string } } | undefined,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, c =>\n\t\t\tapi.getServerPullRequest(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tc.owner,\n\t\t\t\tc.repo,\n\t\t\t\tString(c.number),\n\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t\t{\n\t\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\t\tdeferFailure: true,\n\t\t\t\t\tprojection: 'batch',\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently, through our own client: provider-apis' pull request list has\n\t * no source-branch filter. Serves only a branch in the base repository — the manager read refuses a `headOwner`\n\t * naming another owner here, since Bitbucket Data Center finds a branch's pull requests only through the\n\t * repository the branch lives in, and a fork's slug can't be derived from its owner.\n\t */\n\tprotected override async getProviderPullRequestsForBranches(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { owner: string; repo: string; project?: string; branch: string; headOwner?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string }; limit: number },\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<{ pullRequests: PullRequestShape[]; truncated: boolean }>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(targets, providerFanOutConcurrency, async t => {\n\t\t\tif (t.headOwner != null) {\n\t\t\t\tthrow new Error(`Bitbucket Data Center can't find ${t.branch}'s pull requests in a fork by its owner`);\n\t\t\t}\n\n\t\t\treturn api.getServerPullRequestsForBranch(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tt.owner,\n\t\t\t\tt.repo,\n\t\t\t\tt.branch,\n\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t\t{\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\tdeferFailure: true,\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\tprotected override async getProviderIssue(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_id: string,\n\t): Promise<Issue | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\tprotected override async getProviderPullRequestForBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tbranch: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t\tinclude?: PullRequestState[];\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequestForBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tbranch,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequestForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: BitbucketRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tresource.owner,\n\t\t\tresource.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ projection: 'point' },\n\t\t);\n\t}\n\n\tprotected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {\n\t\treturn getBitbucketServerPullRequestIdentityFromMaybeUrl(search, this.id);\n\t}\n\n\tpublic override async getRepoInfo(repo: {\n\t\towner: string;\n\t\tname: string;\n\t\tproject?: string;\n\t\tconnectionId?: string;\n\t}): Promise<ProviderRepository | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSession(repo.connectionId, undefined);\n\t\tif (session == null) return undefined;\n\n\t\treturn api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, {\n\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t});\n\t}\n\n\tprotected override async getProviderRepositoryMetadata(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t/**\n\t * Accounts by {@link getAccountKey}. One integration serves every installation on its host, and installations\n\t * mounted at different context paths are different servers whose users differ, even under the same token.\n\t */\n\tprivate _accounts: Map<string, Account | undefined> | undefined;\n\n\t/** The installation the session's reads address, plus the credential — what decides whose account it is. */\n\tprivate getAccountKey(session: ProviderAuthenticationSession): string {\n\t\treturn `${this.apiBaseUrlFor(session)}\\n${session.accessToken}`;\n\t}\n\n\t/**\n\t * The account request the account cache would otherwise answer; see `IntegrationBase.validateCredential`. Needed\n\t * without any discovery cache: a repo-scoped pull request read fans out across its repositories in the SDK with\n\t * no request to the connection first, so a dead token comes back as one refused repository per request.\n\t *\n\t * A project access token never confirms: its bot user authenticates, but `/users` does not list it, so the SDK\n\t * cannot find the current user and the check proves nothing.\n\t */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api\n\t\t\t.getCurrentUser(toTokenWithInfo(this.id, session), { baseUrl: this.apiBaseUrlFor(session) })\n\t\t\t.catch((ex: unknown) => {\n\t\t\t\tif (!(ex instanceof AuthenticationError)) throw ex;\n\n\t\t\t\t// Bitbucket Data Center names the user it authenticated in `X-AUSERNAME`, and answers a dead token\n\t\t\t\t// exactly as it answers no credential: the same 401 and body, without that header. So a refusal that\n\t\t\t\t// names a user, or says the user holds no license, came from a credential that authenticated, and\n\t\t\t\t// proves nothing about the scopes' refusals.\n\t\t\t\tconst response = (ex.original as { response?: { headers?: ResponseHeaders } } | undefined)?.response;\n\t\t\t\tif (\n\t\t\t\t\tgetResponseHeader(response?.headers, 'x-ausername') ||\n\t\t\t\t\t/not (?:a|currently) licensed/i.test(ex.original?.message ?? '')\n\t\t\t\t) {\n\t\t\t\t\tthrow new Error('Bitbucket Data Center could not confirm the credential', { cause: ex });\n\t\t\t\t}\n\t\t\t\tthrow ex;\n\t\t\t});\n\t\tif (user == null) {\n\t\t\tthrow new Error('Bitbucket Data Center did not confirm the credential');\n\t\t}\n\t}\n\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst key = this.getAccountKey(session);\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\n\t\tconst cachedAccount = this._accounts.get(key);\n\t\tif (cachedAccount == null) {\n\t\t\tconst api = await this.getProvidersApi();\n\t\t\tconst user = await api.getCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t});\n\t\t\tthis._accounts.set(\n\t\t\t\tkey,\n\t\t\t\tuser\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tprovider: this,\n\t\t\t\t\t\t\tid: user.id,\n\t\t\t\t\t\t\tname: user.name ?? undefined,\n\t\t\t\t\t\t\temail: user.email ?? undefined,\n\t\t\t\t\t\t\tavatarUrl: user.avatarUrl ?? undefined,\n\t\t\t\t\t\t\tusername: user.username ?? undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t);\n\t\t}\n\n\t\treturn this._accounts.get(key);\n\t}\n\n\tprotected override async getProviderOrganizationsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderOrganization>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerProjects(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\n\t\t);\n\t}\n\n\tprotected override async getProviderRepositoriesForOrg(\n\t\tsession: ProviderAuthenticationSession,\n\t\torg: string,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerRepositories(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\n\t\t\t{\n\t\t\t\tproject: org,\n\t\t\t\tcursor: options?.cursor,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderRepositoriesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerRepositories(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tprotected override async searchProviderMyPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\t_cancellation?: AbortSignal,\n\t\toptions?: SearchMyPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (repos != null) {\n\t\t\t// TODO: implement repos version\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst prs = await api.getBitbucketServerPullRequestsForCurrentUser(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ states: toProviderPullRequestStates(options?.state) },\n\t\t);\n\t\treturn prs?.data.map(pr => fromProviderPullRequest(pr, this, { projection: 'search' }));\n\t}\n\n\tprotected override async getProviderMyPullRequestsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { state?: PullRequestStateFilter[]; cursor?: string; filters?: PullRequestFilter[] },\n\t): Promise<PagedResult<ProviderPullRequest> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst states = toProviderPullRequestStates(options?.state);\n\t\t// provider-apis translates the public 1-based `page` to Bitbucket Server's `start` offset and normalizes\n\t\t// `nextPageStart` back to the next page number. Thread that number inside our opaque cursor so the\n\t\t// ProviderBackend sweep drives the drain (bounded by its maxPages).\n\t\tconst page = parsePageCursor(options?.cursor);\n\t\tconst result = await api.getBitbucketServerPullRequestsForCurrentUser(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ states: states, page: page },\n\t\t);\n\t\tif (result == null) return undefined;\n\n\t\tconst account = options?.filters?.length ? await this.getProviderCurrentAccount(session) : undefined;\n\t\tconst identifiers = new Set([account?.id, account?.username].filter((id): id is string => id != null));\n\t\tif (options?.filters?.length && identifiers.size === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t'Unable to resolve the current Bitbucket Data Center account for the requested pull request filters.',\n\t\t\t);\n\t\t}\n\n\t\tconst values = options?.filters?.length\n\t\t\t? result.data.filter(pr => {\n\t\t\t\t\tconst isCurrentUser = (user: { id?: string | null; username?: string | null } | null | undefined) =>\n\t\t\t\t\t\tuser != null &&\n\t\t\t\t\t\t((user.id != null && identifiers.has(user.id)) ||\n\t\t\t\t\t\t\t(user.username != null && identifiers.has(user.username)));\n\t\t\t\t\tconst isAuthor = isCurrentUser(pr.author);\n\t\t\t\t\tconst isRequestedReviewer = pr.reviews?.some(\n\t\t\t\t\t\treview =>\n\t\t\t\t\t\t\tisCurrentUser(review.reviewer) &&\n\t\t\t\t\t\t\treview.state === ProviderPullRequestReviewState.ReviewRequested,\n\t\t\t\t\t);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(options.filters!.includes(PullRequestFilter.Author) && isAuthor) ||\n\t\t\t\t\t\t(options.filters!.includes(PullRequestFilter.ReviewRequested) && isRequestedReviewer)\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t: result.data;\n\n\t\treturn {\n\t\t\tvalues: values,\n\t\t\tpaging: {\n\t\t\t\tmore: result.hasMore,\n\t\t\t\tcursor: result.hasMore && result.nextPage != null ? toPageCursor(result.nextPage) : '{}',\n\t\t\t},\n\t\t};\n\t}\n\n\tprotected override async searchProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tsearchQuery: string,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) return undefined;\n\n\t\tconst repoInputs =\n\t\t\trepos != null\n\t\t\t\t? repos.map(r => ({ name: r.name, namespace: r.owner }))\n\t\t\t\t: await this.getWorkspaceRepoInputs();\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t// An explicitly-empty `repos` means \"search these zero repos\" -> no results; reserve `undefined`\n\t\t// (\"scope couldn't be determined\") for when no repos were requested and none were discovered.\n\t\tif (repoInputs.length === 0) return repos != null ? [] : undefined;\n\n\t\tconst token = toTokenWithInfo(this.id, session);\n\t\tconst states = toProviderPullRequestStates(options?.include);\n\t\tconst providerPullRequests = await flatSettledOrThrow(\n\t\t\trepoInputs.map(async repo => {\n\t\t\t\tconst result = await collectProviderPagedResult(cursor => {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\treturn api.getPullRequestsForRepo(token, repo, {\n\t\t\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tstates: states,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\treturn result.values;\n\t\t\t}),\n\t\t);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\treturn providerPullRequests\n\t\t\t.filter(pr => providerPullRequestMatchesSearch(pr, searchQuery))\n\t\t\t.map(pr => fromProviderPullRequest(pr, this, { projection: 'text-search' }));\n\t}\n\n\t/**\n\t * The filtered pull-request search, read by this module's own requests rather than the SDK's: the SDK's list\n\t * reads carry no text, draft or participant-status filter and no per-facet continuation. Every request goes to\n\t * the session's own address, context path included, so one connection's cursor can't be replayed on another.\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\tconst api = await this.getProvidersApi();\n\t\treturn api.searchBitbucketServerPullRequestsPage(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\tconnectionId: session.id,\n\t\t\t\tprovider: this,\n\t\t\t\trepos: options.repos,\n\t\t\t\torg: options.org,\n\t\t\t\tcriteria: options.criteria,\n\t\t\t\tcurrentUser: await this.getSearchUser(session, options.criteria, cancellation),\n\t\t\t\tcursor: options.cursor,\n\t\t\t\tpageSize: options.pageSize,\n\t\t\t\tprojection: options.summary ? 'search-summary' : 'search',\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * Counts each scope by reading it, since Bitbucket Data Center has neither a count query nor a total on its\n\t * pages. The facade hands over one scope per call and runs those calls concurrently (see `countPullRequests`),\n\t * so scopes here are counted one after another rather than multiplying that concurrency.\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[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst token = toTokenWithInfo(this.id, session);\n\t\tconst counts: ProviderPullRequestCount[] = [];\n\t\tfor (const scope of scopes) {\n\t\t\tcounts.push(\n\t\t\t\tawait api.countBitbucketServerPullRequests(\n\t\t\t\t\ttoken,\n\t\t\t\t\t{\n\t\t\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\t\t\trepos: scope.repos,\n\t\t\t\t\t\torg: scope.org,\n\t\t\t\t\t\tcriteria: scope.criteria,\n\t\t\t\t\t\tcurrentUser: await this.getSearchUser(session, scope.criteria, cancellation),\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\treturn counts;\n\t}\n\n\t/**\n\t * The session's own user, which a relationship facet filters by. Resolved per session rather than from the\n\t * primary connection, so a read pinned to one account never filters by another's identity; an account that\n\t * can't be resolved refuses the read instead of widening it to everyone's pull requests.\n\t *\n\t * The lookup is raced against `cancellation` so a cancelled read settles at once. The SDK's current-user read\n\t * takes no signal, so the request itself runs on; its answer still lands in the per-token account cache, so a\n\t * cold lookup a cancellation abandoned isn't wasted on the next read.\n\t */\n\tprivate async getSearchUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcriteria: PullRequestSearchCriteria | undefined,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<BitbucketServerSearchUser | undefined> {\n\t\tif (!criteria?.relationships?.length) return undefined;\n\n\t\tconst lookup = this.getProviderCurrentAccount(session);\n\t\tconst account = await (cancellation != null ? raceWithSignal(lookup, cancellation) : lookup);\n\t\tif (account?.id == null || account.username == null) {\n\t\t\tthrow new Error('Unable to resolve the current Bitbucket Data Center account for a relationship search.');\n\t\t}\n\n\t\treturn { id: account.id, username: account.username };\n\t}\n\n\tprivate async getWorkspaceRepoInputs(): Promise<{ name: string; namespace: string }[]> {\n\t\tconst remotes = await this.ctx.repositories.getOpenRemotes();\n\t\tconst inputs = await nonnullSettled(\n\t\t\tremotes.map(async (r: GitRemote) => {\n\t\t\t\tconst integration = await this.authenticationService.getByRemote(r);\n\t\t\t\tif (integration !== this) return undefined;\n\n\t\t\t\t// Use the remote provider's parsing so the Bitbucket Server `scm/<project>/<repo>` prefix is\n\t\t\t\t// stripped; a raw `path.split('/')` would yield namespace=`scm`, name=`<project>`.\n\t\t\t\tconst namespace = r.provider?.owner;\n\t\t\t\tconst name = r.provider?.repoName;\n\t\t\t\treturn namespace != null && name != null ? { name: name, namespace: namespace } : undefined;\n\t\t\t}),\n\t\t);\n\t\t// Dedupe: a repo with multiple remotes (e.g. `origin` + `upstream`) can map to the same input,\n\t\t// which would otherwise fetch and return the same PRs more than once.\n\t\treturn [...new Map(inputs.map(i => [`${i.namespace}/${i.name}`, i])).values()];\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\t_session: AuthenticationSession,\n\t\t_repos?: BitbucketRepositoryDescriptor[],\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t/**\n\t * Bitbucket Data Center exposes no issue tracker at all (issues live in Jira), so — like Bitbucket Cloud,\n\t * whose own tracker is deprecated — it is not an issue provider on the ProviderBackend surface. Without this\n\t * the facade would take `supportsIssues`' default `true` and route the read to a provider that registers no\n\t * issue client: the repo-scoped path fails with the SDK's `does not support function: getIssuesForReposFn`\n\t * as an opaque `kind: 'other'` warning, and `broadenIssues` first drains every repo of the org before hitting\n\t * the same failure. Its metadata already declares no issue filters, so this keeps both halves of the\n\t * capability answer consistent.\n\t */\n\toverride get supportsIssues(): boolean {\n\t\treturn false;\n\t}\n\n\tprivate readonly storagePrefix = 'bitbucket-server';\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tif (this._session == null) return;\n\n\t\tconst accountKey = this.getAccountKey(this._session);\n\t\tconst accountStorageKey = md5(accountKey);\n\n\t\tconst storedAccount = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:account`);\n\n\t\tlet account: Account | undefined = storedAccount?.data ? { ...storedAccount.data, provider: this } : undefined;\n\n\t\tif (storedAccount == null) {\n\t\t\taccount = await this.getProviderCurrentAccount(this._session);\n\t\t\tif (account != null) {\n\t\t\t\t// Clear all other stored workspaces and repositories and accounts when our session changes\n\t\t\t\tawait this.ctx.storage.deleteWithPrefix(this.storagePrefix);\n\t\t\t\tawait this.ctx.storage.store(`${this.storagePrefix}:${accountStorageKey}:account`, {\n\t\t\t\t\tv: 1,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tid: account.id,\n\t\t\t\t\t\tname: account.name,\n\t\t\t\t\t\temail: account.email,\n\t\t\t\t\t\tavatarUrl: account.avatarUrl,\n\t\t\t\t\t\tusername: account.username,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\t\tthis._accounts.set(accountKey, account);\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._accounts = undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA6DA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAE/E,IAAa,6BAAb,cAAgD,mBAG9C;CAYiB;CAXlB,eAAqE;CACrE,KAAS;CACT,MACC,GAAG,KAAK,GAAG,GAAG,KAAK;CACpB,OAAwB;CAExB,YACC,KACA,uBACA,iBACA,qBACA,SACC;EACD,MAAM,KAAK,uBAAuB,iBAAiB,mBAAmB;EAFrD,KAAA,UAAA;CAGlB;CAEA,IAAI,SAAiB;EACpB,OAAO,KAAK;CACb;CAEA,cAAwB,SAAgD;EACvE,OAAO,KAAK,yBAAyB,OAAO;CAC7C;CAEA,MAAyB,yBACxB,SACA,IACA,SAGmB;EAEnB,QAAO,MADW,KAAK,gBAAgB,EAAA,CAC5B,iBAAiB,gBAAgB,KAAK,IAAI,OAAO,GAAG,IAAI;GAClE,aAAa,SAAS;GACtB,SAAS,KAAK,cAAc,OAAO;EACpC,CAAC;CACF;CAEA,MAAyB,4BACxB,SACA,MACA,KACA,SAGoD;EACpD,QAAQ,MAAM,KAAK,sBAAsB,KAAK,UAAA,EAAY,0BACzD,MACA,gBAAgB,KAAK,IAAI,OAAO,GAChC,KAAK,OACL,KAAK,MACL,KACA,KAAK,cAAc,OAAO,GAC1B,EACC,YAAY,SAAS,WACtB,CACD;CACD;CAEA,MAAyB,2BACxB,UACA,OACA,QACA,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AClF,GAAG;KACH,WAAW,KAAK,IAAI;KACpB,MAAM;MACL,IAAI,QAAQ;MACZ,MAAM,QAAQ;MACd,OAAO,QAAQ;MACf,WAAW,QAAQ;MACnB,UAAU,QAAQ;KACnB;IACD,CAAC;GACF;EACD;EACA,KAAK,8BAAc,IAAI,IAAiC;EACxD,KAAK,UAAU,IAAI,YAAY,OAAO;CACvC;CAEA,uBAAgD;EAC/C,KAAK,YAAY,KAAA;CAClB;AACD"}
1
+ {"version":3,"file":"bitbucket-server.js","names":[],"sources":["../../../../../plus/integrations/src/providers/bitbucket-server.ts"],"sourcesContent":["import type { Account, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestMergeMethod,\n\tPullRequestSearchCriteria,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { GitRemote } from '@gitlens/git/models/remote.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport { CancellationError, raceWithSignal } from '@gitlens/utils/cancellation.js';\nimport { md5 } from '@gitlens/utils/crypto.js';\nimport type { Emitter } from '@gitlens/utils/event.js';\nimport type { PagedResult } from '@gitlens/utils/paging.js';\nimport { mapSettledBounded, nonnullSettled } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';\nimport type {\n\tAuthenticationSessionLike as AuthenticationSession,\n\tProviderAuthenticationSession,\n} from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { GitSelfManagedHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport type { ResponseHeaders } from '../errors.js';\nimport { AuthenticationError, getResponseHeader } from '../errors.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport type { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from '../models/gitHostIntegration.js';\nimport { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { IntegrationKey, ProviderPullRequestCount, ProviderPullRequestSearchPage } from '../models/integration.js';\nimport type { BitbucketServerSearchUser } from './bitbucket-server/pullRequestSearch.js';\nimport { getBitbucketServerPullRequestIdentityFromMaybeUrl } from './bitbucket/bitbucket.utils.js';\nimport type { BitbucketRepositoryDescriptor } from './bitbucket/models.js';\nimport type {\n\tProviderHierarchyResult,\n\tProviderOrganization,\n\tProviderPullRequest,\n\tProviderRepoInput,\n\tProviderRepository,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tproviderPullRequestMatchesSearch,\n\tProviderPullRequestReviewState,\n\tprovidersMetadata,\n\tPullRequestFilter,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport type { ProvidersApi } from './providersApi.js';\nimport {\n\tcollectProviderPagedResult,\n\tflatSettledOrThrow,\n\tparsePageCursor,\n\ttoPageCursor,\n} from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[GitSelfManagedHostIntegrationId.BitbucketServer];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\n\nexport class BitbucketServerIntegration extends GitHostIntegration<\n\tGitSelfManagedHostIntegrationId.BitbucketServer,\n\tBitbucketRepositoryDescriptor\n> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = GitSelfManagedHostIntegrationId.BitbucketServer;\n\tprotected readonly key =\n\t\t`${this.id}:${this.domain}` satisfies IntegrationKey<GitSelfManagedHostIntegrationId.BitbucketServer>;\n\treadonly name: string = 'Bitbucket Data Center';\n\n\tconstructor(\n\t\tctx: IntegrationServiceContext,\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tgetProvidersApi: () => Promise<ProvidersApi>,\n\t\tdidChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t\tprivate readonly _domain: string,\n\t) {\n\t\tsuper(ctx, authenticationService, getProvidersApi, didChangeConnection);\n\t}\n\n\tget domain(): string {\n\t\treturn this._domain;\n\t}\n\n\tprotected apiBaseUrlFor(session: ProviderAuthenticationSession): string {\n\t\treturn this.getSelfManagedApiBaseUrl(session);\n\t}\n\n\tprotected override async mergeProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tpr: PullRequest,\n\t\toptions?: {\n\t\t\tmergeMethod?: PullRequestMergeMethod;\n\t\t},\n\t): Promise<boolean> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.mergePullRequest(toTokenWithInfo(this.id, session), pr, {\n\t\t\tmergeMethod: options?.mergeMethod,\n\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t});\n\t}\n\n\tprotected override async getProviderAccountForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerAccountForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{\n\t\t\t\tavatarSize: options?.avatarSize,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderAccountForEmail(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_email: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\tprotected override async getProviderDefaultBranch(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t): Promise<DefaultBranch | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\t{ id }: { id: string; key: string },\n\t\ttype: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tif (type === 'issue') {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequestById(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot:\n\t * provider-apis has no single pull request read for Bitbucket, so this uses our own.\n\t */\n\tprotected override async getProviderPullRequestsBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string } } | undefined,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, c =>\n\t\t\tapi.getServerPullRequest(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tc.owner,\n\t\t\t\tc.repo,\n\t\t\t\tString(c.number),\n\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t\t{\n\t\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\t\tdeferFailure: true,\n\t\t\t\t\tprojection: 'batch',\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently, through our own client: provider-apis' pull request list has\n\t * no source-branch filter. Serves only a branch in the base repository — the manager read refuses a `headOwner`\n\t * naming another owner here, since Bitbucket Data Center finds a branch's pull requests only through the\n\t * repository the branch lives in, and a fork's slug can't be derived from its owner.\n\t */\n\tprotected override async getProviderPullRequestsForBranches(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { owner: string; repo: string; project?: string; branch: string; headOwner?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string }; limit: number },\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<{ pullRequests: PullRequestShape[]; truncated: boolean }>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(targets, providerFanOutConcurrency, async t => {\n\t\t\tif (t.headOwner != null) {\n\t\t\t\tthrow new Error(`Bitbucket Data Center can't find ${t.branch}'s pull requests in a fork by its owner`);\n\t\t\t}\n\n\t\t\treturn api.getServerPullRequestsForBranch(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tt.owner,\n\t\t\t\tt.repo,\n\t\t\t\tt.branch,\n\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t\t{\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\tdeferFailure: true,\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\tprotected override async getProviderIssue(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_id: string,\n\t): Promise<Issue | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\tprotected override async getProviderPullRequestForBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tbranch: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t\tinclude?: PullRequestState[];\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequestForBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tbranch,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequestForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: BitbucketRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tresource.owner,\n\t\t\tresource.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ projection: 'point' },\n\t\t);\n\t}\n\n\tprotected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {\n\t\treturn getBitbucketServerPullRequestIdentityFromMaybeUrl(search, this.id);\n\t}\n\n\tpublic override async getRepoInfo(repo: {\n\t\towner: string;\n\t\tname: string;\n\t\tproject?: string;\n\t\tconnectionId?: string;\n\t}): Promise<ProviderRepository | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSessionOrThrow(repo.connectionId, undefined);\n\t\tif (session == null) return undefined;\n\n\t\treturn api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, {\n\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t});\n\t}\n\n\tprotected override async getProviderRepositoryMetadata(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t/**\n\t * Accounts by {@link getAccountKey}. One integration serves every installation on its host, and installations\n\t * mounted at different context paths are different servers whose users differ, even under the same token.\n\t */\n\tprivate _accounts: Map<string, Account | undefined> | undefined;\n\n\t/** The installation the session's reads address, plus the credential — what decides whose account it is. */\n\tprivate getAccountKey(session: ProviderAuthenticationSession): string {\n\t\treturn `${this.apiBaseUrlFor(session)}\\n${session.accessToken}`;\n\t}\n\n\t/**\n\t * The account request the account cache would otherwise answer; see `IntegrationBase.validateCredential`. Needed\n\t * without any discovery cache: a repo-scoped pull request read fans out across its repositories in the SDK with\n\t * no request to the connection first, so a dead token comes back as one refused repository per request.\n\t *\n\t * A project access token never confirms: its bot user authenticates, but `/users` does not list it, so the SDK\n\t * cannot find the current user and the check proves nothing.\n\t */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api\n\t\t\t.getCurrentUser(toTokenWithInfo(this.id, session), { baseUrl: this.apiBaseUrlFor(session) })\n\t\t\t.catch((ex: unknown) => {\n\t\t\t\tif (!(ex instanceof AuthenticationError)) throw ex;\n\n\t\t\t\t// Bitbucket Data Center names the user it authenticated in `X-AUSERNAME`, and answers a dead token\n\t\t\t\t// exactly as it answers no credential: the same 401 and body, without that header. So a refusal that\n\t\t\t\t// names a user, or says the user holds no license, came from a credential that authenticated, and\n\t\t\t\t// proves nothing about the scopes' refusals.\n\t\t\t\tconst response = (ex.original as { response?: { headers?: ResponseHeaders } } | undefined)?.response;\n\t\t\t\tif (\n\t\t\t\t\tgetResponseHeader(response?.headers, 'x-ausername') ||\n\t\t\t\t\t/not (?:a|currently) licensed/i.test(ex.original?.message ?? '')\n\t\t\t\t) {\n\t\t\t\t\tthrow new Error('Bitbucket Data Center could not confirm the credential', { cause: ex });\n\t\t\t\t}\n\t\t\t\tthrow ex;\n\t\t\t});\n\t\tif (user == null) {\n\t\t\tthrow new Error('Bitbucket Data Center did not confirm the credential');\n\t\t}\n\t}\n\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst key = this.getAccountKey(session);\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\n\t\tconst cachedAccount = this._accounts.get(key);\n\t\tif (cachedAccount == null) {\n\t\t\tconst api = await this.getProvidersApi();\n\t\t\tconst user = await api.getCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t});\n\t\t\tthis._accounts.set(\n\t\t\t\tkey,\n\t\t\t\tuser\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tprovider: this,\n\t\t\t\t\t\t\tid: user.id,\n\t\t\t\t\t\t\tname: user.name ?? undefined,\n\t\t\t\t\t\t\temail: user.email ?? undefined,\n\t\t\t\t\t\t\tavatarUrl: user.avatarUrl ?? undefined,\n\t\t\t\t\t\t\tusername: user.username ?? undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t);\n\t\t}\n\n\t\treturn this._accounts.get(key);\n\t}\n\n\tprotected override async getProviderOrganizationsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderOrganization>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerProjects(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\n\t\t);\n\t}\n\n\tprotected override async getProviderRepositoriesForOrg(\n\t\tsession: ProviderAuthenticationSession,\n\t\torg: string,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerRepositories(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\n\t\t\t{\n\t\t\t\tproject: org,\n\t\t\t\tcursor: options?.cursor,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderRepositoriesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerRepositories(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tprotected override async searchProviderMyPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\t_cancellation?: AbortSignal,\n\t\toptions?: SearchMyPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (repos != null) {\n\t\t\t// TODO: implement repos version\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst prs = await api.getBitbucketServerPullRequestsForCurrentUser(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ states: toProviderPullRequestStates(options?.state) },\n\t\t);\n\t\treturn prs?.data.map(pr => fromProviderPullRequest(pr, this, { projection: 'search' }));\n\t}\n\n\tprotected override async getProviderMyPullRequestsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { state?: PullRequestStateFilter[]; cursor?: string; filters?: PullRequestFilter[] },\n\t): Promise<PagedResult<ProviderPullRequest> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst states = toProviderPullRequestStates(options?.state);\n\t\t// provider-apis translates the public 1-based `page` to Bitbucket Server's `start` offset and normalizes\n\t\t// `nextPageStart` back to the next page number. Thread that number inside our opaque cursor so the\n\t\t// ProviderBackend sweep drives the drain (bounded by its maxPages).\n\t\tconst page = parsePageCursor(options?.cursor);\n\t\tconst result = await api.getBitbucketServerPullRequestsForCurrentUser(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ states: states, page: page },\n\t\t);\n\t\tif (result == null) return undefined;\n\n\t\tconst account = options?.filters?.length ? await this.getProviderCurrentAccount(session) : undefined;\n\t\tconst identifiers = new Set([account?.id, account?.username].filter((id): id is string => id != null));\n\t\tif (options?.filters?.length && identifiers.size === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t'Unable to resolve the current Bitbucket Data Center account for the requested pull request filters.',\n\t\t\t);\n\t\t}\n\n\t\tconst values = options?.filters?.length\n\t\t\t? result.data.filter(pr => {\n\t\t\t\t\tconst isCurrentUser = (user: { id?: string | null; username?: string | null } | null | undefined) =>\n\t\t\t\t\t\tuser != null &&\n\t\t\t\t\t\t((user.id != null && identifiers.has(user.id)) ||\n\t\t\t\t\t\t\t(user.username != null && identifiers.has(user.username)));\n\t\t\t\t\tconst isAuthor = isCurrentUser(pr.author);\n\t\t\t\t\tconst isRequestedReviewer = pr.reviews?.some(\n\t\t\t\t\t\treview =>\n\t\t\t\t\t\t\tisCurrentUser(review.reviewer) &&\n\t\t\t\t\t\t\treview.state === ProviderPullRequestReviewState.ReviewRequested,\n\t\t\t\t\t);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(options.filters!.includes(PullRequestFilter.Author) && isAuthor) ||\n\t\t\t\t\t\t(options.filters!.includes(PullRequestFilter.ReviewRequested) && isRequestedReviewer)\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t: result.data;\n\n\t\treturn {\n\t\t\tvalues: values,\n\t\t\tpaging: {\n\t\t\t\tmore: result.hasMore,\n\t\t\t\tcursor: result.hasMore && result.nextPage != null ? toPageCursor(result.nextPage) : '{}',\n\t\t\t},\n\t\t};\n\t}\n\n\tprotected override async searchProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tsearchQuery: string,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) return undefined;\n\n\t\tconst repoInputs =\n\t\t\trepos != null\n\t\t\t\t? repos.map(r => ({ name: r.name, namespace: r.owner }))\n\t\t\t\t: await this.getWorkspaceRepoInputs();\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t// An explicitly-empty `repos` means \"search these zero repos\" -> no results; reserve `undefined`\n\t\t// (\"scope couldn't be determined\") for when no repos were requested and none were discovered.\n\t\tif (repoInputs.length === 0) return repos != null ? [] : undefined;\n\n\t\tconst token = toTokenWithInfo(this.id, session);\n\t\tconst states = toProviderPullRequestStates(options?.include);\n\t\tconst providerPullRequests = await flatSettledOrThrow(\n\t\t\trepoInputs.map(async repo => {\n\t\t\t\tconst result = await collectProviderPagedResult(cursor => {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\treturn api.getPullRequestsForRepo(token, repo, {\n\t\t\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tstates: states,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\treturn result.values;\n\t\t\t}),\n\t\t);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\treturn providerPullRequests\n\t\t\t.filter(pr => providerPullRequestMatchesSearch(pr, searchQuery))\n\t\t\t.map(pr => fromProviderPullRequest(pr, this, { projection: 'text-search' }));\n\t}\n\n\t/**\n\t * The filtered pull-request search, read by this module's own requests rather than the SDK's: the SDK's list\n\t * reads carry no text, draft or participant-status filter and no per-facet continuation. Every request goes to\n\t * the session's own address, context path included, so one connection's cursor can't be replayed on another.\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\tconst api = await this.getProvidersApi();\n\t\treturn api.searchBitbucketServerPullRequestsPage(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\tconnectionId: session.id,\n\t\t\t\tprovider: this,\n\t\t\t\trepos: options.repos,\n\t\t\t\torg: options.org,\n\t\t\t\tcriteria: options.criteria,\n\t\t\t\tcurrentUser: await this.getSearchUser(session, options.criteria, cancellation),\n\t\t\t\tcursor: options.cursor,\n\t\t\t\tpageSize: options.pageSize,\n\t\t\t\tprojection: options.summary ? 'search-summary' : 'search',\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * Counts each scope by reading it, since Bitbucket Data Center has neither a count query nor a total on its\n\t * pages. The facade hands over one scope per call and runs those calls concurrently (see `countPullRequests`),\n\t * so scopes here are counted one after another rather than multiplying that concurrency.\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[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst token = toTokenWithInfo(this.id, session);\n\t\tconst counts: ProviderPullRequestCount[] = [];\n\t\tfor (const scope of scopes) {\n\t\t\tcounts.push(\n\t\t\t\tawait api.countBitbucketServerPullRequests(\n\t\t\t\t\ttoken,\n\t\t\t\t\t{\n\t\t\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\t\t\trepos: scope.repos,\n\t\t\t\t\t\torg: scope.org,\n\t\t\t\t\t\tcriteria: scope.criteria,\n\t\t\t\t\t\tcurrentUser: await this.getSearchUser(session, scope.criteria, cancellation),\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\treturn counts;\n\t}\n\n\t/**\n\t * The session's own user, which a relationship facet filters by. Resolved per session rather than from the\n\t * primary connection, so a read pinned to one account never filters by another's identity; an account that\n\t * can't be resolved refuses the read instead of widening it to everyone's pull requests.\n\t *\n\t * The lookup is raced against `cancellation` so a cancelled read settles at once. The SDK's current-user read\n\t * takes no signal, so the request itself runs on; its answer still lands in the per-token account cache, so a\n\t * cold lookup a cancellation abandoned isn't wasted on the next read.\n\t */\n\tprivate async getSearchUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcriteria: PullRequestSearchCriteria | undefined,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<BitbucketServerSearchUser | undefined> {\n\t\tif (!criteria?.relationships?.length) return undefined;\n\n\t\tconst lookup = this.getProviderCurrentAccount(session);\n\t\tconst account = await (cancellation != null ? raceWithSignal(lookup, cancellation) : lookup);\n\t\tif (account?.id == null || account.username == null) {\n\t\t\tthrow new Error('Unable to resolve the current Bitbucket Data Center account for a relationship search.');\n\t\t}\n\n\t\treturn { id: account.id, username: account.username };\n\t}\n\n\tprivate async getWorkspaceRepoInputs(): Promise<{ name: string; namespace: string }[]> {\n\t\tconst remotes = await this.ctx.repositories.getOpenRemotes();\n\t\tconst inputs = await nonnullSettled(\n\t\t\tremotes.map(async (r: GitRemote) => {\n\t\t\t\tconst integration = await this.authenticationService.getByRemote(r);\n\t\t\t\tif (integration !== this) return undefined;\n\n\t\t\t\t// Use the remote provider's parsing so the Bitbucket Server `scm/<project>/<repo>` prefix is\n\t\t\t\t// stripped; a raw `path.split('/')` would yield namespace=`scm`, name=`<project>`.\n\t\t\t\tconst namespace = r.provider?.owner;\n\t\t\t\tconst name = r.provider?.repoName;\n\t\t\t\treturn namespace != null && name != null ? { name: name, namespace: namespace } : undefined;\n\t\t\t}),\n\t\t);\n\t\t// Dedupe: a repo with multiple remotes (e.g. `origin` + `upstream`) can map to the same input,\n\t\t// which would otherwise fetch and return the same PRs more than once.\n\t\treturn [...new Map(inputs.map(i => [`${i.namespace}/${i.name}`, i])).values()];\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\t_session: AuthenticationSession,\n\t\t_repos?: BitbucketRepositoryDescriptor[],\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t/**\n\t * Bitbucket Data Center exposes no issue tracker at all (issues live in Jira), so — like Bitbucket Cloud,\n\t * whose own tracker is deprecated — it is not an issue provider on the ProviderBackend surface. Without this\n\t * the facade would take `supportsIssues`' default `true` and route the read to a provider that registers no\n\t * issue client: the repo-scoped path fails with the SDK's `does not support function: getIssuesForReposFn`\n\t * as an opaque `kind: 'other'` warning, and `broadenIssues` first drains every repo of the org before hitting\n\t * the same failure. Its metadata already declares no issue filters, so this keeps both halves of the\n\t * capability answer consistent.\n\t */\n\toverride get supportsIssues(): boolean {\n\t\treturn false;\n\t}\n\n\tprivate readonly storagePrefix = 'bitbucket-server';\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tif (this._session == null) return;\n\n\t\tconst accountKey = this.getAccountKey(this._session);\n\t\tconst accountStorageKey = md5(accountKey);\n\n\t\tconst storedAccount = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:account`);\n\n\t\tlet account: Account | undefined = storedAccount?.data ? { ...storedAccount.data, provider: this } : undefined;\n\n\t\tif (storedAccount == null) {\n\t\t\taccount = await this.getProviderCurrentAccount(this._session);\n\t\t\tif (account != null) {\n\t\t\t\t// Clear all other stored workspaces and repositories and accounts when our session changes\n\t\t\t\tawait this.ctx.storage.deleteWithPrefix(this.storagePrefix);\n\t\t\t\tawait this.ctx.storage.store(`${this.storagePrefix}:${accountStorageKey}:account`, {\n\t\t\t\t\tv: 1,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tid: account.id,\n\t\t\t\t\t\tname: account.name,\n\t\t\t\t\t\temail: account.email,\n\t\t\t\t\t\tavatarUrl: account.avatarUrl,\n\t\t\t\t\t\tusername: account.username,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\t\tthis._accounts.set(accountKey, account);\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._accounts = undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA6DA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAE/E,IAAa,6BAAb,cAAgD,mBAG9C;CAYiB;CAXlB,eAAqE;CACrE,KAAS;CACT,MACC,GAAG,KAAK,GAAG,GAAG,KAAK;CACpB,OAAwB;CAExB,YACC,KACA,uBACA,iBACA,qBACA,SACC;EACD,MAAM,KAAK,uBAAuB,iBAAiB,mBAAmB;EAFrD,KAAA,UAAA;CAGlB;CAEA,IAAI,SAAiB;EACpB,OAAO,KAAK;CACb;CAEA,cAAwB,SAAgD;EACvE,OAAO,KAAK,yBAAyB,OAAO;CAC7C;CAEA,MAAyB,yBACxB,SACA,IACA,SAGmB;EAEnB,QAAO,MADW,KAAK,gBAAgB,EAAA,CAC5B,iBAAiB,gBAAgB,KAAK,IAAI,OAAO,GAAG,IAAI;GAClE,aAAa,SAAS;GACtB,SAAS,KAAK,cAAc,OAAO;EACpC,CAAC;CACF;CAEA,MAAyB,4BACxB,SACA,MAC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AErG,IAAI,iBAAiB,MAAM;GAC1B,UAAU,MAAM,KAAK,0BAA0B,KAAK,QAAQ;GAC5D,IAAI,WAAW,MAAM;IAEpB,MAAM,KAAK,IAAI,QAAQ,iBAAiB,KAAK,aAAa;IAC1D,MAAM,KAAK,IAAI,QAAQ,MAAM,GAAG,KAAK,cAAc,GAAG,kBAAkB,WAAW;KAClF,GAAG;KACH,WAAW,KAAK,IAAI;KACpB,MAAM;MACL,IAAI,QAAQ;MACZ,MAAM,QAAQ;MACd,OAAO,QAAQ;MACf,WAAW,QAAQ;MACnB,UAAU,QAAQ;KACnB;IACD,CAAC;GACF;EACD;EACA,KAAK,8BAAc,IAAI,IAAiC;EACxD,KAAK,UAAU,IAAI,YAAY,OAAO;CACvC;CAEA,uBAAgD;EAC/C,KAAK,YAAY,KAAA;CAClB;AACD"}
@@ -33,7 +33,7 @@ var BitbucketIntegration = class extends GitHostIntegration {
33
33
  }
34
34
  async getRepoInfo(repo) {
35
35
  const api = await this.getProvidersApi();
36
- const session = await this.resolveReadSession(repo.connectionId, void 0);
36
+ const session = await this.resolveReadSessionOrThrow(repo.connectionId, void 0);
37
37
  if (session == null) return void 0;
38
38
  return api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, { baseUrl: this.apiBaseUrl });
39
39
  }