@gitkraken/core-gitlens 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/dist/git/models/issue.d.ts +13 -3
  3. package/dist/git/models/issue.js +3 -1
  4. package/dist/git/models/issue.js.map +1 -1
  5. package/dist/git/models/pullRequest.d.ts +13 -2
  6. package/dist/git/models/pullRequest.js +3 -1
  7. package/dist/git/models/pullRequest.js.map +1 -1
  8. package/dist/git/utils/issue.utils.js +2 -1
  9. package/dist/git/utils/issue.utils.js.map +1 -1
  10. package/dist/git/utils/pullRequest.utils.js +1 -0
  11. package/dist/git/utils/pullRequest.utils.js.map +1 -1
  12. package/dist/plus/integrations/models/gitHostIntegration.d.ts +7 -6
  13. package/dist/plus/integrations/models/gitHostIntegration.js +4 -3
  14. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  15. package/dist/plus/integrations/models/integration.d.ts +5 -0
  16. package/dist/plus/integrations/models/integration.js.map +1 -1
  17. package/dist/plus/integrations/providers/azure/azure.d.ts +8 -6
  18. package/dist/plus/integrations/providers/azure/azure.js +3 -2
  19. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  20. package/dist/plus/integrations/providers/azure/models.d.ts +4 -2
  21. package/dist/plus/integrations/providers/azure/models.js +6 -5
  22. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  23. package/dist/plus/integrations/providers/azureDevOps.d.ts +15 -13
  24. package/dist/plus/integrations/providers/azureDevOps.js +26 -22
  25. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  26. package/dist/plus/integrations/providers/azureDevOpsServer.js +6 -3
  27. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  28. package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
  29. package/dist/plus/integrations/providers/models.d.ts +26 -4
  30. package/dist/plus/integrations/providers/models.js +27 -5
  31. package/dist/plus/integrations/providers/models.js.map +1 -1
  32. package/dist/plus/integrations/reads/drains.d.ts +2 -1
  33. package/dist/plus/integrations/reads/drains.js.map +1 -1
  34. package/dist/plus/integrations/reads/etag.js +3 -1
  35. package/dist/plus/integrations/reads/etag.js.map +1 -1
  36. package/docs/integrations.md +21 -2
  37. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"azure.js","names":["Logger"],"sources":["../../../../../../plus/integrations/src/providers/azure/azure.ts"],"sourcesContent":["import type {\n\tAzureDevOpsRestResource,\n\tAzureDevOpsRestResourceInfo,\n\tAzureWorkItemHtmlField,\n\tAzureWorkItemTypeStates,\n} from '@gitkraken/provider-apis';\nimport * as l10n from '@vscode/l10n';\nimport type { UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue, IssueSearchCriteria } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequest } from '@gitlens/git/models/pullRequest.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport { effectiveIssueSort } from '@gitlens/git/utils/issue.utils.js';\nimport { base64 } from '@gitlens/utils/base64.js';\nimport { CancellationError, isCancellationError, raceWithSignal } from '@gitlens/utils/cancellation.js';\nimport { sha256, uuid } from '@gitlens/utils/crypto.js';\nimport { trace } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { ScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { mapBounded } from '@gitlens/utils/promise.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport { PromiseCache } from '@gitlens/utils/promiseCache.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { TokenWithInfo } from '../../authentication/models.js';\nimport type { IntegrationServiceContext } from '../../context.js';\nimport {\n\tAuthenticationError,\n\tAuthenticationErrorReason,\n\tisRateLimitResponse,\n\tProviderFetchError,\n\tRequestClientError,\n\tRequestNotFoundError,\n\ttoRateLimitError,\n} from '../../errors.js';\nimport type { ProviderIssueSearchPage } from '../../models/issueReads.js';\nimport { decodePathSegment } from '../../utils/domain.utils.js';\nimport type { ProviderApiConfig } from '../apiConfig.js';\nimport { baseProviderApiConfig } from '../apiConfig.js';\nimport { createProviderApiRequest, createProviderApis } from '../providerApiClient.js';\nimport { throwProviderError } from '../providerErrors.js';\nimport type {\n\tAzureForkRepositoryUrls,\n\tAzureGitCommit,\n\tAzureProjectDescriptor,\n\tAzurePullRequest,\n\tAzurePullRequestWithLinks,\n\tAzureRepositoryReference,\n\tAzureRepositoryUrls,\n\tAzureRepositoryWithMetadata,\n\tAzureWorkItemStateCategory,\n\tWorkItem,\n} from './models.js';\nimport {\n\tazurePullRequestStatusToState,\n\tazureWorkItemsStateCategoryToState,\n\tencodeAzurePathSegment,\n\tfromAzurePullRequest,\n\tfromAzureWorkItem,\n\tgetAzurePullRequestWebUrl,\n\tisClosedAzurePullRequestStatus,\n\tnormalizeAzureBranchName,\n\tparseAzureWorkItemDate,\n\tsanitizeAzureRepositoryUrl,\n} from './models.js';\nimport type { AzureWorkItemSearchCursor } from './search.js';\nimport {\n\tazureWorkItemBatchLimit,\n\tazureWorkItemSearchResultLimit,\n\tazureWorkItemWiqlLengthLimit,\n\tparseAzureWorkItemSearchCursor,\n\ttoAzureSearchPageSize,\n\ttoAzureWorkItemSearchCursorKey,\n\ttoAzureWorkItemSearchQueries,\n\ttoAzureWorkItemSearchWiql,\n} from './search.js';\nimport { AzureWorkItemDescriptionsCache } from './workItemDescriptions.js';\nimport { queryAzureWorkItemSearch } from './workItemSearch.js';\nimport {\n\tAzureWorkItemStatesCache,\n\tgetAzureWorkItemTypeStatesPath,\n\tgetAzureWorkItemTypesUrl,\n\trequireAzureWorkItemStateCategories,\n\tresolveAzureWorkItemStateCategory,\n} from './workItemStateCategories.js';\n\nconst forkRepositoryUrlCacheTtl = 5 * 60 * 1000;\nconst workItemMetadataConcurrency = 6;\n/** How long a work-item search's id snapshot outlives the last page read from it, and the most it lives at all. */\nconst workItemSearchSnapshotTtl = 5 * 60 * 1000;\nconst workItemSearchSnapshotMaxTtl = 30 * 60 * 1000;\n\ntype WorkItemSearchOptions = {\n\tbaseUrl: string;\n\tcriteria?: IssueSearchCriteria;\n\tprojectNames?: readonly string[];\n\tworkflowProjectNames?: readonly string[];\n};\n\n/** Whether Azure refused a WIQL query for matching more work items than it will return (`VS402337`). */\nfunction isWorkItemLimitRefusal(ex: unknown): boolean {\n\treturn ex instanceof RequestClientError && ex.message.includes('VS402337');\n}\n\nfunction parseAzureRepositoryDescriptor(repo: string): { projectName: string; repoName: string } {\n\tconst parts = repo.split('/');\n\tconst [projectName, segment, repoName] = parts;\n\tif (parts.length !== 3 || segment !== '_git' || !projectName || !repoName) {\n\t\tthrow new Error(`Invalid Azure repository descriptor '${repo}'; expected '{project}/_git/{repoName}'.`);\n\t}\n\n\treturn { projectName: projectName, repoName: repoName };\n}\n\nexport class AzureDevOpsApi implements Disposable {\n\tprivate readonly restApi: ReturnType<typeof createProviderApis>['azureDevOps'];\n\tprivate readonly _disposable: Disposable | undefined;\n\tprivate readonly _workItemStates: AzureWorkItemStatesCache;\n\tprivate readonly ownsWorkItemStates: boolean;\n\tprivate readonly _workItemDescriptions: AzureWorkItemDescriptionsCache;\n\tprivate readonly ownsWorkItemDescriptions: boolean;\n\tprivate readonly _forkRepositoryUrls = new PromiseCache<string, AzureForkRepositoryUrls | undefined>({\n\t\tcapacity: 100,\n\t\tcreateTTL: forkRepositoryUrlCacheTtl,\n\t});\n\t/**\n\t * The ordered ids each filtered work-item search's first page queried, paged through by its continuations. Kept\n\t * alive while a pagination keeps reading them (see `workItemSearchSnapshotTtl`). Every first page adds one, so\n\t * the capacity leaves room for repeated first pages before an idle pagination's snapshot is the one evicted.\n\t */\n\tprivate readonly _workItemSearches = new PromiseCache<string, number[]>({\n\t\tcapacity: 50,\n\t\taccessTTL: workItemSearchSnapshotTtl,\n\t\tcreateTTL: workItemSearchSnapshotMaxTtl,\n\t});\n\n\tconstructor(\n\t\tprivate readonly config: ProviderApiConfig,\n\t\tworkItemStates?: AzureWorkItemStatesCache,\n\t\tworkItemDescriptions?: AzureWorkItemDescriptionsCache,\n\t) {\n\t\tthis.restApi = createProviderApis({\n\t\t\trequest: createProviderApiRequest((input, init) => config.fetch(input, init)),\n\t\t}).azureDevOps;\n\t\tthis._workItemStates = workItemStates ?? new AzureWorkItemStatesCache();\n\t\tthis.ownsWorkItemStates = workItemStates == null;\n\t\tthis._workItemDescriptions = workItemDescriptions ?? new AzureWorkItemDescriptionsCache();\n\t\tthis.ownsWorkItemDescriptions = workItemDescriptions == null;\n\t\tthis._disposable = config.onConfigChanged?.(() => this.resetCaches());\n\t}\n\n\tdispose(): void {\n\t\tthis._disposable?.dispose();\n\t}\n\n\tprivate resetCaches(): void {\n\t\tthis.restApi.updateConfig({});\n\t\tif (this.ownsWorkItemStates) {\n\t\t\tthis._workItemStates.clear();\n\t\t}\n\t\tif (this.ownsWorkItemDescriptions) {\n\t\t\tthis._workItemDescriptions.clear();\n\t\t}\n\t\tthis._forkRepositoryUrls.clear();\n\t\tthis._workItemSearches.clear();\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t}),\n\t})\n\tpublic async getPullRequestForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { projectName, repoName } = parseAzureRepositoryDescriptor(repo);\n\n\t\ttry {\n\t\t\tconst prResult = await this.request<{ value: AzurePullRequest[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\toptions?.baseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(projectName)}/_apis/git/repositories/${encodeAzurePathSegment(repoName)}/pullRequests?searchCriteria.status=all&searchCriteria.sourceRefName=${encodeURIComponent(`refs/heads/${branch}`)}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\t// Sort PRs: open PRs first, then by most recent activity (creation or closure date)\n\t\t\tconst sortedPRs = prResult?.value.sort((a, b) => {\n\t\t\t\t// First, prioritize open PRs (active/notSet) over closed ones (abandoned/completed)\n\t\t\t\tconst aIsOpen = a.status === 'active' || a.status === 'notSet';\n\t\t\t\tconst bIsOpen = b.status === 'active' || b.status === 'notSet';\n\n\t\t\t\tif (aIsOpen !== bIsOpen) {\n\t\t\t\t\treturn aIsOpen ? -1 : 1; // Open PRs come first\n\t\t\t\t}\n\n\t\t\t\t// Among PRs with the same status, sort by most recent activity\n\t\t\t\t// Use closedDate if available, otherwise use creationDate\n\t\t\t\tconst aDate = new Date(a.closedDate || a.creationDate);\n\t\t\t\tconst bDate = new Date(b.closedDate || b.creationDate);\n\n\t\t\t\treturn bDate.getTime() - aDate.getTime(); // Most recent first\n\t\t\t});\n\n\t\t\tconst pr = sortedPRs?.[0];\n\t\t\tif (pr == null) return undefined;\n\n\t\t\treturn await this.toPullRequest(pr, provider, token, owner, options.baseUrl, scope);\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is actionable and must not be reported as an absent result; every other\n\t\t\t// failure keeps the existing degrade-to-undefined behavior.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getPullRequestForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { projectName, repoName } = parseAzureRepositoryDescriptor(repo);\n\t\tconst resource = await this.requireRestResource(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\towner,\n\t\t\tbaseUrl,\n\t\t\t'pullRequestQuery',\n\t\t\t'4.1',\n\t\t\tcancellation,\n\t\t);\n\t\ttry {\n\t\t\tconst encodedProject = encodeAzurePathSegment(projectName);\n\t\t\tconst encodedRepo = encodeAzurePathSegment(repoName);\n\t\t\tconst prResult = await this.request<{ results: Record<string, AzurePullRequest[]>[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodedProject}/_apis/git/repositories/${encodedRepo}/pullrequestquery?api-version=${resource.apiVersion}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tqueries: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\titems: [rev],\n\t\t\t\t\t\t\t\ttype: 'commit',\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\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\n\t\t\tconst pr = prResult?.results[0]?.[rev]?.[0];\n\t\t\tif (pr == null) return undefined;\n\n\t\t\tconst pullRequest = await this.request<AzurePullRequestWithLinks>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(pr.repository.project.id)}/_apis/git/repositories/${encodeAzurePathSegment(pr.repository.id)}/pullRequests/${encodeAzurePathSegment(pr.pullRequestId.toString())}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (pullRequest == null) return undefined;\n\n\t\t\treturn await this.toPullRequest(pullRequest, provider, token, owner, baseUrl, scope, cancellation);\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is actionable and must not be reported as an absent result; every other\n\t\t\t// failure keeps the existing degrade-to-undefined behavior.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, projectOrName, id) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\tprojectOrName: projectOrName,\n\t\t\tid: id,\n\t\t}),\n\t})\n\tpublic async getPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tprojectOrName: string,\n\t\tid: string,\n\t\toptions: { baseUrl: string },\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\t// A pull request id is unique within the organization, so no repository is required here — only the\n\t\t// project. `projectOrName` is either a bare project name or a `{project}/_git/{repo}` descriptor; either\n\t\t// way the project is its first segment.\n\t\tconst projectName = projectOrName.split('/')[0];\n\n\t\ttry {\n\t\t\tconst pr = await this.request<AzurePullRequest>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(projectName)}/_apis/git/pullrequests/${encodeAzurePathSegment(id)}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\treturn pr != null\n\t\t\t\t? await this.toPullRequest(pr, provider, token, owner, options.baseUrl, scope)\n\t\t\t\t: undefined;\n\t\t} catch (ex) {\n\t\t\t// Only a 404 is a proven absence; `Integration.getPullRequest` handles every other failure, so it is not\n\t\t\t// cached as a miss\n\t\t\tif (ex.original?.status === 404) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t}),\n\t})\n\tpublic async getIssueOrPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t\ttype?: IssueOrPullRequestType;\n\t\t},\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { projectName, repoName } = parseAzureRepositoryDescriptor(repo);\n\n\t\tif (options?.type === undefined || options?.type === 'issue') {\n\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t'workItems',\n\t\t\t\t'6.0',\n\t\t\t);\n\t\t\tlet issueResult: WorkItem | undefined;\n\t\t\ttry {\n\t\t\t\tissueResult = await this.getWorkItem(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tprojectName,\n\t\t\t\t\tid,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\tresource,\n\t\t\t\t\tscope,\n\t\t\t\t);\n\t\t\t} catch (ex) {\n\t\t\t\t// A rejected credential is actionable and must not be reported as an absent issue; every other\n\t\t\t\t// non-404 keeps the existing degrade-to-undefined behavior.\n\t\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\t\tif (ex.original?.status !== 404) {\n\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (issueResult != null) {\n\t\t\t\tawait this.requireWorkItemProject(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tprojectName,\n\t\t\t\t\tissueResult,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\tscope,\n\t\t\t\t);\n\t\t\t\tconst issueType = issueResult.fields['System.WorkItemType'];\n\t\t\t\tconst state = issueResult.fields['System.State'];\n\t\t\t\tconst stateCategory = await this.getWorkItemStateCategory(\n\t\t\t\t\tissueType,\n\t\t\t\t\tstate,\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tprojectName,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\n\t\t\t\tconst normalizedState = azureWorkItemsStateCategoryToState(\n\t\t\t\t\tstateCategory,\n\t\t\t\t\tparseAzureWorkItemDate(issueResult.fields['Microsoft.VSTS.Common.ClosedDate']) ?? undefined,\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tid: issueResult.id.toString(),\n\t\t\t\t\ttype: 'issue',\n\t\t\t\t\tnodeId: issueResult.id.toString(),\n\t\t\t\t\tprovider: provider,\n\t\t\t\t\tcreatedDate: new Date(issueResult.fields['System.CreatedDate']),\n\t\t\t\t\tupdatedDate: new Date(issueResult.fields['System.ChangedDate']),\n\t\t\t\t\tstate: normalizedState,\n\t\t\t\t\tclosed: normalizedState === 'closed',\n\t\t\t\t\ttitle: issueResult.fields['System.Title'],\n\t\t\t\t\turl: issueResult._links.html.href,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (options?.type === undefined || options?.type === 'pullrequest') {\n\t\t\ttry {\n\t\t\t\tconst prResult = await this.request<AzurePullRequestWithLinks>(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\toptions?.baseUrl,\n\t\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(projectName)}/_apis/git/repositories/${encodeAzurePathSegment(repoName)}/pullRequests/${encodeAzurePathSegment(id)}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t},\n\t\t\t\t\tscope,\n\t\t\t\t);\n\n\t\t\t\tif (prResult != null) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: prResult.pullRequestId.toString(),\n\t\t\t\t\t\ttype: 'pullrequest',\n\t\t\t\t\t\tnodeId: prResult.pullRequestId.toString(), // prResult.artifactId maybe?\n\t\t\t\t\t\tprovider: provider,\n\t\t\t\t\t\tcreatedDate: new Date(prResult.creationDate),\n\t\t\t\t\t\tupdatedDate: new Date(prResult.creationDate),\n\t\t\t\t\t\tstate: azurePullRequestStatusToState(prResult.status),\n\t\t\t\t\t\tclosed: isClosedAzurePullRequestStatus(prResult.status),\n\t\t\t\t\t\ttitle: prResult.title,\n\t\t\t\t\t\turl: getAzurePullRequestWebUrl(prResult, options.baseUrl, owner),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t} catch (ex) {\n\t\t\t\t// A rejected credential is actionable and must not be reported as an absent issue; every other\n\t\t\t\t// non-404 keeps the existing degrade-to-undefined behavior.\n\t\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\t\tif (ex.original?.status !== 404) {\n\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, project, id) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tproject: project,\n\t\t\tid: id,\n\t\t}),\n\t})\n\tpublic async getIssue(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tproject: AzureProjectDescriptor,\n\t\tid: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t\t/**\n\t\t\t * The current user as the organization's work items identify them, set as the row's `viewer`. Asked only once\n\t\t\t * the work item was read, alongside its state and fields; never rejects.\n\t\t\t */\n\t\t\tviewer?: () => Promise<{ id: string } | undefined>;\n\t\t},\n\t): Promise<Issue | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst resource = await this.requireRestResource(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tproject.resourceName,\n\t\t\toptions.baseUrl,\n\t\t\t'workItems',\n\t\t\t'6.0',\n\t\t);\n\n\t\tlet issueResult: WorkItem | undefined;\n\t\ttry {\n\t\t\tissueResult = await this.getWorkItem(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tproject.resourceName,\n\t\t\t\tproject.name,\n\t\t\t\tid,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tresource,\n\t\t\t\tscope,\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is actionable and must not be reported as an absent work item; every other\n\t\t\t// non-404 keeps the existing degrade-to-undefined behavior.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\tif (ex.original?.status !== 404) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (issueResult != null) {\n\t\t\tawait this.requireWorkItemProject(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tproject.resourceName,\n\t\t\t\tproject.name,\n\t\t\t\tissueResult,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tscope,\n\t\t\t);\n\t\t\tconst issueType = issueResult.fields['System.WorkItemType'];\n\t\t\tconst state = issueResult.fields['System.State'];\n\t\t\tconst [stateCategory, htmlFields, viewer] = await Promise.all([\n\t\t\t\tthis.getWorkItemStateCategory(\n\t\t\t\t\tissueType,\n\t\t\t\t\tstate,\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tproject.resourceName,\n\t\t\t\t\tproject.name,\n\t\t\t\t\toptions,\n\t\t\t\t),\n\t\t\t\tthis.getWorkItemHtmlFields(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tproject.resourceName,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\tissueResult.fields,\n\t\t\t\t\tscope,\n\t\t\t\t),\n\t\t\t\toptions.viewer?.(),\n\t\t\t]);\n\t\t\treturn fromAzureWorkItem(issueResult, provider, project, stateCategory, 'point', htmlFields, viewer);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getAccountForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<UnidentifiedAuthor | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { projectName, repoName } = parseAzureRepositoryDescriptor(repo);\n\n\t\ttry {\n\t\t\t// Try to get the Work item (wit) first with specific fields\n\t\t\tconst commit = await this.request<AzureGitCommit>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(projectName)}/_apis/git/repositories/${encodeAzurePathSegment(repoName)}/commits/${encodeAzurePathSegment(rev)}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\t\t\tconst author = commit?.author;\n\t\t\tif (!author) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Azure API never gives us an id/username we can use, therefore we always return UnidentifiedAuthor\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\tid: undefined,\n\t\t\t\tusername: undefined,\n\t\t\t\tname: author?.name,\n\t\t\t\temail: author?.email,\n\t\t\t\tavatarUrl: undefined,\n\t\t\t} satisfies UnidentifiedAuthor;\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is actionable and must not be reported as an absent work item; every other\n\t\t\t// non-404 keeps the existing degrade-to-undefined behavior.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\tif (ex.original?.status !== 404) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * The collection an Azure DevOps Server address names, or `undefined` when it names the installation.\n\t *\n\t * Below a collection, `connectionData` describes that collection: its `instanceId` is the collection's id, and its\n\t * `webApplicationRelativeDirectory` ends in the collection's path segment (`DefaultCollection/`); it is empty or\n\t * absent at the server level. As measured against Azure DevOps Server 2020. The directory may also carry the\n\t * installation's own virtual directory before the collection (`tfs/DefaultCollection/`), so only its LAST segment\n\t * names the collection, and only when it is the last segment of the address asked about.\n\t */\n\t@trace({\n\t\targs: (provider, token, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getAddressedCollection(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tbaseUrl: string,\n\t): Promise<{ id: string; name: string } | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst connectionData = await this.request<{ instanceId?: string; webApplicationRelativeDirectory?: string }>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t'_apis/connectionData',\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t);\n\t\tconst segment = connectionData?.webApplicationRelativeDirectory?.split('/').findLast(Boolean);\n\t\tconst addressed = new URL(baseUrl).pathname.split('/').findLast(Boolean);\n\t\tif (segment == null || addressed == null || connectionData?.instanceId == null) return undefined;\n\n\t\tconst name = decodePathSegment(segment);\n\t\tif (name.toLowerCase() !== decodePathSegment(addressed).toLowerCase()) return undefined;\n\n\t\treturn { id: connectionData.instanceId, name: name };\n\t}\n\n\t@trace({\n\t\targs: (provider, token, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getCurrentUserOnServer(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tbaseUrl: string,\n\t): Promise<{ id: string; name?: string; email?: string; username?: string; avatarUrl?: string } | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst connectionData = await this.request<{\n\t\t\t\tauthenticatedUser?: {\n\t\t\t\t\tid: string;\n\t\t\t\t\tdescriptor: string;\n\t\t\t\t\tisActive: boolean;\n\t\t\t\t\tmetTypeId: number;\n\t\t\t\t\tproviderDisplayName?: string;\n\t\t\t\t\temailAddress?: string;\n\t\t\t\t\tresourceVersion: 2;\n\t\t\t\t\tsubjectDescriptor: string;\n\t\t\t\t\tproperties?: {\n\t\t\t\t\t\tAccount?: {\n\t\t\t\t\t\t\t$type: string;\n\t\t\t\t\t\t\t$value: string;\n\t\t\t\t\t\t};\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t}>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t'_apis/connectionData',\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\tconst user = connectionData?.authenticatedUser;\n\t\t\tconst username = user?.properties?.Account?.$value;\n\t\t\tif (!username) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: user.id,\n\t\t\t\tname: user.providerDisplayName,\n\t\t\t\temail: user.emailAddress,\n\t\t\t\tusername: username,\n\t\t\t};\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to get current user from ${baseUrl}`);\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tasync getWorkItemStateCategory(\n\t\tissueType: string,\n\t\tstate: string,\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tprojectName: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureWorkItemStateCategory | undefined> {\n\t\tconst states = await this.getWorkItemTypeStates(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\towner,\n\t\t\tprojectName,\n\t\t\tissueType,\n\t\t\toptions.baseUrl,\n\t\t\tcancellation,\n\t\t);\n\t\treturn resolveAzureWorkItemStateCategory(states, state);\n\t}\n\n\tprivate getWorkItemTypeStates(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tproject: string,\n\t\ttype: string,\n\t\tbaseUrl: string,\n\t\tcancellation?: AbortSignal,\n\t) {\n\t\treturn this._workItemStates.getStates(\n\t\t\t{ baseUrl: baseUrl, namespace: owner, project: project, token: token.accessToken, isPAT: true },\n\t\t\ttype,\n\t\t\tasync signal => {\n\t\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\t'workItemTypeStates',\n\t\t\t\t\t'6.0-preview.1',\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\treturn this.request(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\tgetAzureWorkItemTypeStatesPath(owner, project, type, resource.apiVersion),\n\t\t\t\t\t{ method: 'GET' },\n\t\t\t\t\tundefined,\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t},\n\t\t\tcancellation,\n\t\t\tasync signal => {\n\t\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\t'backlogConfiguration',\n\t\t\t\t\t'6.0-preview.1',\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tconst path = `${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(project)}/_apis/work/backlogconfiguration?api-version=${resource.apiVersion}`;\n\t\t\t\treturn this.request(provider, token, baseUrl, path, { method: 'GET' }, undefined, signal);\n\t\t\t},\n\t\t);\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getRepositoryMetadata(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst resource = await this.requireRestResource(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\towner,\n\t\t\toptions.baseUrl,\n\t\t\t'repositories',\n\t\t\t'7.1',\n\t\t\tcancellation,\n\t\t);\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tresource.apiVersion,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (response == null) return undefined;\n\n\t\t\t// Azure's `parentRepository` only reliably carries the repo name and its project; a fork's parent\n\t\t\t// lives in the same organization, so the org (`owner`) is the parent owner. Only report `parent`\n\t\t\t// when the parent's name is actually present — never fall back to the fork's own name.\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\towner: owner,\n\t\t\t\t// Prefer the API's canonical name over parsing the composite `repo` descriptor string.\n\t\t\t\tname: response.name,\n\t\t\t\tisFork: response.isFork ?? false,\n\t\t\t\tparent:\n\t\t\t\t\tresponse.isFork && response.parentRepository?.name != null\n\t\t\t\t\t\t? { owner: owner, name: response.parentRepository.name }\n\t\t\t\t\t\t: undefined,\n\t\t\t} satisfies RepositoryMetadata;\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is not a probe outcome: it is actionable, and the caller routes it into the\n\t\t\t// session recovery. A cancellation or a 404 still degrades quietly.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getDefaultBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<DefaultBranch | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst resource = await this.requireRestResource(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\towner,\n\t\t\toptions.baseUrl,\n\t\t\t'repositories',\n\t\t\t'7.1',\n\t\t\tcancellation,\n\t\t);\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tresource.apiVersion,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (response?.defaultBranch == null) return undefined;\n\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\tname: normalizeAzureBranchName(response.defaultBranch),\n\t\t\t} satisfies DefaultBranch;\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is not a probe outcome: it is actionable, and the caller routes it into the\n\t\t\t// session recovery. A cancellation or a 404 still degrades quietly.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * One page of a filtered work-item search over a collection: bounded WIQL queries for the ordered ids, then one\n\t * detail read for the page's slice of them.\n\t *\n\t * The ids a first page queried are kept as the snapshot its continuations page through, for as long as the\n\t * pagination keeps reading it, so metadata changes cannot retarget the continuation. Each first page queries its\n\t * own snapshot, so paginations never share one. A continuation whose snapshot is gone is refused (see\n\t * {@link AzureWorkItemSearchCursor}).\n\t *\n\t * The query asks for one id more than {@link azureWorkItemSearchResultLimit}, bounded by `$top`: the extra id is\n\t * what tells \"exactly the limit\" from \"past it\". Past it, the page is `truncated` with `limitReached` and no total,\n\t * since the true count is unknowable here. A server that refuses the match set even so fails the page with a\n\t * \"narrow the search\" error: no bounded query could serve that order's first window.\n\t *\n\t * `resolveProject` maps each result's project name to its descriptor. A work item in a project it doesn't know\n\t * fails the page rather than being dropped or mis-attributed, since either would leave the page disagreeing with\n\t * the count of the same query; the caller refreshes its project discovery before a search so that means a\n\t * project created during the pagination.\n\t *\n\t * `viewer` resolves the current user as the collection's work items identify them, set as each row's `viewer`. It's\n\t * asked once for a page that read any work item, and never rejects.\n\t */\n\t@trace({\n\t\targs: (provider, token, collection) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tcollection: collection,\n\t\t}),\n\t})\n\tasync searchWorkItemsPage(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tcollection: string,\n\t\toptions: WorkItemSearchOptions & {\n\t\t\tresolveProject: (name: string) => AzureProjectDescriptor | undefined;\n\t\t\tviewer?: () => Promise<{ id: string } | undefined>;\n\t\t\tcursor?: string;\n\t\t\tpageSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderIssueSearchPage> {\n\t\tconst scope = getScopedLogger();\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst identity = JSON.stringify([\n\t\t\toptions.criteria?.state ?? 'open',\n\t\t\ttoAzureWorkItemSearchWiql(\n\t\t\t\t{ ...options.criteria, state: 'all' },\n\t\t\t\teffectiveIssueSort(options.criteria?.sort),\n\t\t\t\toptions.projectNames,\n\t\t\t),\n\t\t]);\n\t\tconst key = toAzureWorkItemSearchCursorKey(collection, identity);\n\t\tconst pageSize = toAzureSearchPageSize(options.pageSize, 100, azureWorkItemBatchLimit);\n\t\tconst cursor = parseAzureWorkItemSearchCursor(options.cursor, key, pageSize);\n\t\tconst page = cursor?.page ?? 1;\n\n\t\t// Keep the full request identity: metadata changes cannot retarget a live snapshot, and a hash collision\n\t\t// cannot let a different query or credential read it.\n\t\tconst snapshot = cursor?.snapshot ?? uuid();\n\t\tconst snapshotKey = JSON.stringify([\n\t\t\tawait sha256(token.accessToken),\n\t\t\toptions.baseUrl,\n\t\t\tcollection,\n\t\t\tidentity,\n\t\t\tsnapshot,\n\t\t]);\n\t\t// A continuation only ever READS its snapshot: resuming against a fresh query could skip a work item silently.\n\t\tconst snapshotFound = cursor?.snapshot != null ? this._workItemSearches.get(snapshotKey) : undefined;\n\t\tif (cursor?.snapshot != null && snapshotFound == null) {\n\t\t\tthrow new Error('Work item search results expired; restart the read without a cursor');\n\t\t}\n\n\t\tconst result = await (snapshotFound ??\n\t\t\tthis._workItemSearches.getOrCreate(\n\t\t\t\tsnapshotKey,\n\t\t\t\t(_cacheable, signal) =>\n\t\t\t\t\tthis.readWorkItemSearch(provider, token, collection, options, true, scope, signal).catch(\n\t\t\t\t\t\t(ex: unknown) => {\n\t\t\t\t\t\t\tif (isWorkItemLimitRefusal(ex)) {\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`${provider.name} refused a work item search matching more than ${azureWorkItemSearchResultLimit} results; narrow the search`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthrow ex;\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t\t{ cancellation: cancellation },\n\t\t\t));\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst limitReached = result.length > azureWorkItemSearchResultLimit;\n\t\tconst ids = limitReached ? result.slice(0, azureWorkItemSearchResultLimit) : result;\n\n\t\tconst offset = cursor?.offset ?? 0;\n\n\t\tconst slice = ids.slice(offset, offset + pageSize);\n\t\tconst values: Issue[] = [];\n\t\tif (slice.length > 0) {\n\t\t\tconst batch = await this.getRestResource(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tcollection,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t'workItemsBatch',\n\t\t\t\t'5.0',\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst resource =\n\t\t\t\tbatch ??\n\t\t\t\t(await this.requireRestResource(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tcollection,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\t'workItems',\n\t\t\t\t\t'5.0',\n\t\t\t\t\tcancellation,\n\t\t\t\t));\n\t\t\tconst route =\n\t\t\t\tbatch != null\n\t\t\t\t\t? `workitemsbatch?api-version=${resource.apiVersion}`\n\t\t\t\t\t: `workitems?ids=${slice.join(',')}&$expand=Links&errorPolicy=Omit&api-version=${resource.apiVersion}`;\n\t\t\tconst workItems = await this.request<{ value: (WorkItem | null)[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t`${encodeAzurePathSegment(collection)}/_apis/wit/${route}`,\n\t\t\t\tbatch != null\n\t\t\t\t\t? { method: 'POST', body: JSON.stringify({ ids: slice, $expand: 'Links', errorPolicy: 'Omit' }) }\n\t\t\t\t\t: { method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst byId = new Map((workItems?.value ?? []).filter(w => w != null).map(w => [w.id, w]));\n\t\t\tconst viewer = byId.size > 0 ? await options.viewer?.() : undefined;\n\t\t\tfor (const id of slice) {\n\t\t\t\t// A work item deleted since the ids were queried is gone, not a failure: skipping it keeps the page\n\t\t\t\t// honest, since it no longer matches anything.\n\t\t\t\tconst workItem = byId.get(id);\n\t\t\t\tif (workItem == null) continue;\n\n\t\t\t\tconst projectName = workItem.fields['System.TeamProject'];\n\t\t\t\tif (\n\t\t\t\t\toptions.projectNames?.length &&\n\t\t\t\t\t!options.projectNames.some(name => name.toLowerCase() === projectName?.toLowerCase())\n\t\t\t\t) {\n\t\t\t\t\tthrow new Error(`Azure DevOps work item ${id} is outside the requested projects`);\n\t\t\t\t}\n\n\t\t\t\tconst project = options.resolveProject(projectName);\n\t\t\t\tif (project == null) {\n\t\t\t\t\tthrow new Error(`Azure DevOps work item ${id} is in project '${projectName}', which isn't visible`);\n\t\t\t\t}\n\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\tconst stateCategory = await this.getWorkItemStateCategory(\n\t\t\t\t\tworkItem.fields['System.WorkItemType'],\n\t\t\t\t\tworkItem.fields['System.State'],\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tcollection,\n\t\t\t\t\tproject.name,\n\t\t\t\t\toptions,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t\tconst htmlFields = await this.getWorkItemHtmlFields(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tcollection,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\tworkItem.fields,\n\t\t\t\t\tscope,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t\tvalues.push(\n\t\t\t\t\tfromAzureWorkItem(workItem, provider, project, stateCategory, 'search', htmlFields, viewer),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst nextOffset = offset + slice.length;\n\t\tconst hasMore = nextOffset < ids.length;\n\t\tconst next: AzureWorkItemSearchCursor = { key: key, snapshot: snapshot, offset: nextOffset, page: page + 1 };\n\t\treturn {\n\t\t\tvalues: values,\n\t\t\tcursor: hasMore ? JSON.stringify(next) : undefined,\n\t\t\thasMore: hasMore,\n\t\t\tpage: page,\n\t\t\ttruncated: limitReached,\n\t\t\ttotalCount: limitReached ? undefined : ids.length,\n\t\t\tlimitReached: limitReached || undefined,\n\t\t};\n\t}\n\n\t/**\n\t * How many work items the same WIQL {@link searchWorkItemsPage} would page through match, reading no details.\n\t *\n\t * Asks for one id more than the result ceiling, so the count is exact up to it and `'exceeds-limit'` past it —\n\t * never the ceiling itself, which would understate the match set.\n\t */\n\t@trace({\n\t\targs: (provider, token, collection) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tcollection: collection,\n\t\t}),\n\t})\n\tasync countWorkItems(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tcollection: string,\n\t\toptions: WorkItemSearchOptions,\n\t\tcancellation?: AbortSignal,\n\t): Promise<number | 'exceeds-limit'> {\n\t\tconst scope = getScopedLogger();\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\ttry {\n\t\t\tconst result = await this.readWorkItemSearch(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tcollection,\n\t\t\t\toptions,\n\t\t\t\tfalse,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\treturn result.length > azureWorkItemSearchResultLimit ? 'exceeds-limit' : result.length;\n\t\t} catch (ex) {\n\t\t\tif (isWorkItemLimitRefusal(ex)) return 'exceeds-limit';\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tprivate async readWorkItemSearch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tcollection: string,\n\t\toptions: WorkItemSearchOptions,\n\t\tordered: boolean,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<number[]> {\n\t\tconst queries = await this.getWorkItemSearchQueries(provider, token, collection, options, cancellation);\n\t\treturn queryAzureWorkItemSearch(\n\t\t\tqueries,\n\t\t\teffectiveIssueSort(options.criteria?.sort),\n\t\t\tordered,\n\t\t\t(wiql, top, asOf) =>\n\t\t\t\tthis.queryWorkItemIds(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tcollection,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\twiql,\n\t\t\t\t\ttop,\n\t\t\t\t\tscope,\n\t\t\t\t\tcancellation,\n\t\t\t\t\tasOf,\n\t\t\t\t),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async getWorkItemSearchQueries(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tcollection: string,\n\t\toptions: WorkItemSearchOptions,\n\t\tcancellation?: AbortSignal,\n\t): Promise<string[]> {\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst projectNames = options.projectNames ?? options.workflowProjectNames ?? [];\n\t\tlet workflows: Map<string, AzureWorkItemTypeStates> | undefined;\n\t\tif (options.criteria?.state !== 'all') {\n\t\t\tconst types = (\n\t\t\t\tawait mapBounded(projectNames, workItemMetadataConcurrency, async project => {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\tconst scope = {\n\t\t\t\t\t\tbaseUrl: options.baseUrl,\n\t\t\t\t\t\tnamespace: collection,\n\t\t\t\t\t\tproject: project,\n\t\t\t\t\t\ttoken: token.accessToken,\n\t\t\t\t\t\tisPAT: true,\n\t\t\t\t\t};\n\t\t\t\t\tconst names = await this._workItemStates.getTypes(\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tasync signal => {\n\t\t\t\t\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\t\t\t\t\tprovider,\n\t\t\t\t\t\t\t\ttoken,\n\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\t\t\t\t'workItemTypes',\n\t\t\t\t\t\t\t\t'6.0',\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn this.request(\n\t\t\t\t\t\t\t\tprovider,\n\t\t\t\t\t\t\t\ttoken,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tgetAzureWorkItemTypesUrl(options.baseUrl, collection, project, resource.apiVersion),\n\t\t\t\t\t\t\t\t{ method: 'GET' },\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcancellation,\n\t\t\t\t\t);\n\t\t\t\t\treturn names.map(name => ({ project: project, name: name, scope: scope }));\n\t\t\t\t})\n\t\t\t).flat();\n\t\t\tconst states = await mapBounded(types, workItemMetadataConcurrency, async type => ({\n\t\t\t\tname: type.name,\n\t\t\t\tproject: type.project,\n\t\t\t\tstates: requireAzureWorkItemStateCategories(\n\t\t\t\t\tawait this.getWorkItemTypeStates(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\ttoken,\n\t\t\t\t\t\tcollection,\n\t\t\t\t\t\ttype.project,\n\t\t\t\t\t\ttype.name,\n\t\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\t\tcancellation,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t}));\n\t\t\tworkflows = new Map(\n\t\t\t\tprojectNames.map(project => [project, { types: states.filter(type => type.project === project) }]),\n\t\t\t);\n\t\t}\n\n\t\treturn toAzureWorkItemSearchQueries(\n\t\t\toptions.criteria,\n\t\t\teffectiveIssueSort(options.criteria?.sort),\n\t\t\tprojectNames,\n\t\t\tworkflows,\n\t\t);\n\t}\n\n\t/**\n\t * The ids a collection-level WIQL query matches, in its order.\n\t *\n\t * `timePrecision=true` lets the criteria's dates compare as instants, including on legacy servers.\n\t */\n\tprivate async queryWorkItemIds(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tcollection: string,\n\t\tbaseUrl: string,\n\t\twiql: string,\n\t\ttop: number,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t\tasOf?: string,\n\t): Promise<{ ids: number[]; asOf?: string }> {\n\t\tconst query = asOf == null ? wiql : `${wiql} ASOF '${asOf}'`;\n\t\tif (query.length > azureWorkItemWiqlLengthLimit) {\n\t\t\tthrow new Error('Azure DevOps work item search query is too long; narrow the search');\n\t\t}\n\n\t\tconst resource = await this.requireRestResource(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tcollection,\n\t\t\tbaseUrl,\n\t\t\t'wiql',\n\t\t\t'5.0',\n\t\t\tcancellation,\n\t\t);\n\t\tconst result = await this.request<{ workItems?: { id: number }[]; asOf?: string }>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`${encodeAzurePathSegment(collection)}/_apis/wit/wiql?$top=${top}&timePrecision=true&api-version=${resource.apiVersion}`,\n\t\t\t{ method: 'POST', body: JSON.stringify({ query: query }) },\n\t\t\tscope,\n\t\t\tcancellation,\n\t\t);\n\t\tif (result?.workItems == null) throw new Error('Azure DevOps returned no work item query result');\n\n\t\treturn { ids: result.workItems.map(w => w.id), asOf: result.asOf };\n\t}\n\n\tprivate async getRepository(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbaseUrl: string,\n\t\tapiVersion: string,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureRepositoryWithMetadata | undefined> {\n\t\tconst { projectName, repoName } = parseAzureRepositoryDescriptor(repo);\n\t\tconst encodedProject = encodeAzurePathSegment(projectName);\n\t\tconst encodedRepo = encodeAzurePathSegment(repoName);\n\t\treturn this.request<AzureRepositoryWithMetadata>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`${encodeAzurePathSegment(owner)}/${encodedProject}/_apis/git/repositories/${encodedRepo}?api-version=${apiVersion}`,\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async toPullRequest(\n\t\tpr: AzurePullRequest,\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tbaseUrl: string,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest> {\n\t\tconst forkRepositoryUrls = await this.getForkRepositoryUrls(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\towner,\n\t\t\tbaseUrl,\n\t\t\tpr.forkSource?.repository,\n\t\t\tscope,\n\t\t\tcancellation,\n\t\t);\n\t\t// Only the point reads convert through here.\n\t\treturn fromAzurePullRequest(pr, provider, owner, baseUrl, forkRepositoryUrls, 'point');\n\t}\n\n\t/**\n\t * Resolves the web and HTTPS clone URLs of the fork a cross-repository pull request comes from. Every other\n\t * repository URL the model reports is rebuilt from the pull request payload; only a fork reference lacks the\n\t * project to do that, so only a fork costs a request.\n\t *\n\t * Best-effort by contract: a fork in a project the token cannot read, a deleted fork, or a throttled request\n\t * leaves the head ref without a URL. It must never cost the pull request itself, which is what makes swallowing\n\t * the failure here the right call rather than a shortcut.\n\t */\n\tprivate async getForkRepositoryUrls(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tbaseUrl: string,\n\t\trepository: AzureRepositoryReference | undefined,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureForkRepositoryUrls | undefined> {\n\t\tif (repository == null) return undefined;\n\n\t\tlet tokenHash: string;\n\t\ttry {\n\t\t\ttokenHash = await sha256(token.accessToken);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst cacheKey = JSON.stringify([tokenHash, baseUrl, owner, repository.id]);\n\t\t// The request is shared, so the factory is handed the cache's aggregate signal rather than this caller's: it\n\t\t// aborts only once every caller waiting on the entry has cancelled.\n\t\treturn this._forkRepositoryUrls.getOrCreate(\n\t\t\tcacheKey,\n\t\t\t(cacheable, aggregate) =>\n\t\t\t\tthis.fetchForkRepositoryUrls(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\trepository.id,\n\t\t\t\t\tcacheable,\n\t\t\t\t\tscope,\n\t\t\t\t\taggregate,\n\t\t\t\t),\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\tprivate async fetchForkRepositoryUrls(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tbaseUrl: string,\n\t\trepositoryId: string,\n\t\tcacheable: CacheController,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureForkRepositoryUrls | undefined> {\n\t\ttry {\n\t\t\tencodeAzurePathSegment(repositoryId);\n\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\tbaseUrl,\n\t\t\t\t'repositories',\n\t\t\t\t'4.1',\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst response = await this.request<AzureRepositoryUrls>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/_apis/git/repositories/${encodeAzurePathSegment(repositoryId)}?api-version=${resource.apiVersion}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst webUrl = sanitizeAzureRepositoryUrl(response?.webUrl, baseUrl, owner);\n\t\t\tconst cloneHttps = sanitizeAzureRepositoryUrl(response?.remoteUrl, baseUrl, owner);\n\n\t\t\t// The clone URL stands in for the web URL when the response omits it — an older `api-version` promises\n\t\t\t// neither field, and naming the fork by the URL git would use beats naming it not at all.\n\t\t\tconst url = webUrl ?? cloneHttps;\n\t\t\tif (url == null) {\n\t\t\t\tcacheable.invalidate();\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { url: url, cloneHttps: cloneHttps };\n\t\t} catch (ex) {\n\t\t\t// Missing or inaccessible forks are cached briefly; transient failures retry on the next read.\n\t\t\tif (!(ex instanceof RequestNotFoundError) && !(ex instanceof AuthenticationError)) {\n\t\t\t\tcacheable.invalidate();\n\t\t\t}\n\n\t\t\tconst status = ex instanceof ProviderFetchError ? ` (${ex.status})` : '';\n\t\t\tscope?.warn(`Unable to resolve the fork repository URLs${status}`);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async getWorkItem(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tproject: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\tresource: AzureDevOpsRestResourceInfo,\n\t\tscope: ScopedLogger | undefined,\n\t): Promise<WorkItem | undefined> {\n\t\tconst encodedProject = encodeAzurePathSegment(project);\n\t\tconst encodedId = encodeAzurePathSegment(id);\n\t\tconst projectPath = resource.projectScoped ? `/${encodedProject}` : '';\n\t\treturn this.request<WorkItem>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`${encodeAzurePathSegment(owner)}${projectPath}/_apis/wit/workItems/${encodedId}?api-version=${resource.apiVersion}`,\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t);\n\t}\n\n\tprivate async requireWorkItemProject(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tproject: string,\n\t\tworkItem: WorkItem,\n\t\tbaseUrl: string,\n\t\tscope: ScopedLogger | undefined,\n\t): Promise<void> {\n\t\tconst actualProject = workItem.fields?.['System.TeamProject'];\n\t\tif (typeof actualProject !== 'string' || !actualProject.trim()) {\n\t\t\tthrow new Error(`Azure DevOps work item ${workItem.id} has no project`);\n\t\t}\n\n\t\tif (actualProject.toLowerCase() === project.toLowerCase()) return;\n\n\t\tconst canonical = await this.request<{ name: string }>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`${encodeAzurePathSegment(owner)}/_apis/projects/${encodeAzurePathSegment(project)}`,\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t);\n\t\tif (canonical?.name?.toLowerCase() !== actualProject.toLowerCase()) {\n\t\t\tthrow new Error(`Azure DevOps work item ${workItem.id} is outside the requested project`);\n\t\t}\n\t}\n\n\tprivate async getWorkItemHtmlFields(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tnamespace: string,\n\t\tbaseUrl: string,\n\t\tfields: WorkItem['fields'],\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<readonly AzureWorkItemHtmlField[]> {\n\t\ttry {\n\t\t\tconst requestToken = { ...token };\n\t\t\treturn await this._workItemDescriptions.getFields(\n\t\t\t\tfields,\n\t\t\t\t{ baseUrl: baseUrl, namespace: namespace, token: requestToken.accessToken, isPAT: true },\n\t\t\t\tasync signal => {\n\t\t\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\trequestToken,\n\t\t\t\t\t\tnamespace,\n\t\t\t\t\t\tbaseUrl,\n\t\t\t\t\t\t'fields',\n\t\t\t\t\t\t'6.0',\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t\treturn this.request(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\trequestToken,\n\t\t\t\t\t\tbaseUrl,\n\t\t\t\t\t\t`${encodeAzurePathSegment(namespace)}/_apis/wit/fields?api-version=${resource.apiVersion}`,\n\t\t\t\t\t\t{ method: 'GET' },\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex) && cancellation?.aborted) throw ex;\n\n\t\t\tscope?.warn(`Unable to read the Azure DevOps field catalog of '${namespace}': ${ex}`);\n\t\t\treturn [];\n\t\t}\n\t}\n\n\tprivate async getRestResource(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tnamespace: string,\n\t\tbaseUrl: string,\n\t\tresource: AzureDevOpsRestResource,\n\t\tversion: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureDevOpsRestResourceInfo | undefined> {\n\t\ttry {\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\tencodeAzurePathSegment(namespace);\n\t\t\tconst discovery = this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () =>\n\t\t\t\tthis.restApi.getRestApiResource(\n\t\t\t\t\t{ namespace: namespace, resource: resource, version: version },\n\t\t\t\t\t{ token: token.accessToken, isPAT: true, baseUrl: baseUrl },\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (cancellation?.aborted) {\n\t\t\t\t// The race skips observing discovery when setup aborts its caller synchronously.\n\t\t\t\tvoid discovery.catch(() => {});\n\t\t\t}\n\n\t\t\treturn await (cancellation != null ? raceWithSignal(discovery, cancellation) : discovery);\n\t\t} catch (ex) {\n\t\t\treturn throwProviderError(token, ex);\n\t\t}\n\t}\n\n\tprivate async requireRestResource(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tnamespace: string,\n\t\tbaseUrl: string,\n\t\tresource: AzureDevOpsRestResource,\n\t\tversion: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureDevOpsRestResourceInfo> {\n\t\tlet result: AzureDevOpsRestResourceInfo | undefined;\n\t\ttry {\n\t\t\tresult = await this.getRestResource(provider, token, namespace, baseUrl, resource, version, cancellation);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof RequestNotFoundError) {\n\t\t\t\tthrow new Error('Azure DevOps REST resource discovery failed', { cause: ex });\n\t\t\t}\n\n\t\t\tthrow ex;\n\t\t}\n\t\tif (result == null) throw new Error(`Azure DevOps REST resource ${resource} is unavailable`);\n\n\t\treturn result;\n\t}\n\n\tprivate async request<T>(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tbaseUrl: string | undefined,\n\t\troute: string,\n\t\toptions: { method: RequestInit['method'] } & Record<string, unknown>,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal | undefined,\n\t): Promise<T | undefined> {\n\t\tconst { accessToken } = token;\n\t\tconst url = baseUrl ? `${baseUrl}/${route}` : route;\n\n\t\tlet rsp: Response;\n\t\ttry {\n\t\t\tconst sw = maybeStopWatch(`[AZURE] ${options?.method ?? 'GET'} request`, { log: { onlyExit: true } });\n\n\t\t\ttry {\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\trsp = await this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () =>\n\t\t\t\t\tthis.config.fetch(url, {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\tAuthorization: `Basic ${base64(`PAT:${accessToken}`)}`,\n\t\t\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsignal: cancellation,\n\t\t\t\t\t\t...options,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (rsp.ok) {\n\t\t\t\t\t// Azure answers a rejected credential by redirecting to its sign-in page, which returns `203\n\t\t\t\t\t// text/html` rather than `401`. `rsp.ok` spans 200-299, so that page used to reach `json()` and\n\t\t\t\t\t// die as a bare `SyntaxError` — which `getIssue` and friends catch and report as \"not found\",\n\t\t\t\t\t// making an invalid credential indistinguishable from a missing work item (GKDEV-3617).\n\t\t\t\t\tconst contentType = rsp.headers.get('content-type')?.toLowerCase() ?? '';\n\t\t\t\t\tif (contentType.startsWith('text/html')) {\n\t\t\t\t\t\tconst { accessToken: _accessToken, ...tokenInfo } = token;\n\t\t\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\t\ttokenInfo,\n\t\t\t\t\t\t\tAuthenticationErrorReason.Unauthorized,\n\t\t\t\t\t\t\tnew Error(`(${rsp.status}) Azure DevOps returned a sign-in page instead of data`),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (await rsp.json()) as T;\n\t\t\t\t}\n\n\t\t\t\t// Reads the body so the 403 branch below can tell a throttled request from a permission failure.\n\t\t\t\tthrow await ProviderFetchError.fromResponse('AzureDevOps', rsp);\n\t\t\t} finally {\n\t\t\t\tsw?.stop();\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof ProviderFetchError || ex.name === 'AbortError') {\n\t\t\t\tthis.handleRequestError(provider, token, ex, scope);\n\t\t\t} else if (Logger.isDebugging) {\n\t\t\t\tthis.config.onError?.(`AzureDevOps request failed: ${ex.message}`);\n\t\t\t}\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tprivate handleRequestError(\n\t\tprovider: Provider | undefined,\n\t\ttoken: TokenWithInfo,\n\t\tex: ProviderFetchError | (Error & { name: 'AbortError' }),\n\t\tscope: ScopedLogger | undefined,\n\t): void {\n\t\tif (ex.name === 'AbortError' || !(ex instanceof ProviderFetchError)) throw new CancellationError(ex);\n\n\t\tconst { accessToken, ...tokenInfo } = token;\n\t\tswitch (ex.status) {\n\t\t\tcase 404: // Not found\n\t\t\tcase 410: // Gone\n\t\t\tcase 422: // Unprocessable Entity\n\t\t\t\tthrow new RequestNotFoundError(ex);\n\t\t\tcase 401: // Unauthorized\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, ex);\n\t\t\tcase 429: // Too Many Requests\n\t\t\t\tthrow toRateLimitError(ex, accessToken);\n\t\t\tcase 403: // Forbidden\n\t\t\t\t// Azure returns 403 for both a permission failure and a throttled request (\"Request was blocked\n\t\t\t\t// due to exceeding usage of resource 'RateLimit'\"), so the message is the discriminant. Reporting\n\t\t\t\t// a throttle as `auth` would prompt the user to re-authenticate a healthy connection instead of\n\t\t\t\t// retrying (see `isRateLimitResponse`).\n\t\t\t\tif (isRateLimitResponse(ex)) throw toRateLimitError(ex, accessToken);\n\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Forbidden, ex);\n\t\t\tcase 500: // Internal Server Error\n\t\t\t\tscope?.error(ex);\n\t\t\t\tif (ex.response != null) {\n\t\t\t\t\tthis.config.onRequestFailed?.(\n\t\t\t\t\t\tprovider == null || provider.id === 'azure'\n\t\t\t\t\t\t\t? l10n.t(\n\t\t\t\t\t\t\t\t\t'{0} failed to respond and might be experiencing issues. Please visit the [AzureDevOps status page](https://status.dev.azure.com) for more information.',\n\t\t\t\t\t\t\t\t\tprovider?.name ?? 'AzureDevOps',\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: l10n.t('{0} failed to respond and might be experiencing issues.', provider.name),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase 502: // Bad Gateway\n\t\t\t\tscope?.error(ex);\n\t\t\t\t// TODO: Learn the Azure API docs and put it in order:\n\t\t\t\t// if (ex.message.includes('timeout')) {\n\t\t\t\t// \tprovider?.trackRequestException();\n\t\t\t\t// \tvoid showIntegrationRequestTimedOutWarningMessage(provider?.name ?? 'Azure');\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (ex.status >= 400 && ex.status < 500) throw new RequestClientError(ex);\n\t\t\t\tbreak;\n\t\t}\n\n\t\tscope?.error(ex);\n\t\tif (Logger.isDebugging) {\n\t\t\tthis.config.onError?.(\n\t\t\t\t`AzureDevOps request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Wires an {@link AzureDevOpsApi} from the full runtime context, mapping `ctx` down to the narrow config. */\nexport function createAzureDevOpsApi(\n\tctx: IntegrationServiceContext,\n\tworkItemStates?: AzureWorkItemStatesCache,\n\tworkItemDescriptions?: AzureWorkItemDescriptionsCache,\n): AzureDevOpsApi {\n\treturn new AzureDevOpsApi(baseProviderApiConfig(ctx), workItemStates, workItemDescriptions);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyFA,MAAM,4BAA4B;AAClC,MAAM,8BAA8B;;AAEpC,MAAM,4BAA4B;AAClC,MAAM,+BAA+B;;AAUrC,SAAS,uBAAuB,IAAsB;CACrD,OAAO,cAAc,sBAAsB,GAAG,QAAQ,SAAS,UAAU;AAC1E;AAEA,SAAS,+BAA+B,MAAyD;CAChG,MAAM,QAAQ,KAAK,MAAM,GAAG;CAC5B,MAAM,CAAC,aAAa,SAAS,YAAY;CACzC,IAAI,MAAM,WAAW,KAAK,YAAY,UAAU,CAAC,eAAe,CAAC,UAChE,MAAM,IAAI,MAAM,wCAAwC,KAAK,yCAAyC;CAGvG,OAAO;EAAe;EAAuB;CAAS;AACvD;AAEA,IAAa,iBAAb,MAAkD;CAuB/B;CAtBlB;CACA;CACA;CACA;CACA;CACA;CACA,sBAAuC,IAAI,aAA0D;EACpG,UAAU;EACV,WAAW;CACZ,CAAC;;;;;;CAMD,oBAAqC,IAAI,aAA+B;EAC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ACP,GACD,CAAC,CAAA,GAAA,eAAA,WAAA,oBAAA,IAAA;AA0EA,WAAA,CAAA,MAAM,EACN,OAAO,UAAU,OAAO,gBAAgB;CACvC,UAAU,SAAS;CACnB,OAAO,UAAU,MAAM,UAAU;CACrB;AACb,GACD,CAAC,CAAA,GAAA,eAAA,WAAA,uBAAA,IAAA;AAiLA,WAAA,CAAA,MAAM,EACN,OAAO,UAAU,OAAO,gBAAgB;CACvC,UAAU,SAAS;CACnB,OAAO,UAAU,MAAM,UAAU;CACrB;AACb,GACD,CAAC,CAAA,GAAA,eAAA,WAAA,kBAAA,IAAA;;AA6lBF,SAAgB,qBACf,KACA,gBACA,sBACiB;CACjB,OAAO,IAAI,eAAe,sBAAsB,GAAG,GAAG,gBAAgB,oBAAoB;AAC3F"}
1
+ {"version":3,"file":"azure.js","names":["Logger"],"sources":["../../../../../../plus/integrations/src/providers/azure/azure.ts"],"sourcesContent":["import type {\n\tAzureDevOpsRestResource,\n\tAzureDevOpsRestResourceInfo,\n\tAzureWorkItemHtmlField,\n\tAzureWorkItemTypeStates,\n} from '@gitkraken/provider-apis';\nimport * as l10n from '@vscode/l10n';\nimport type { UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue, IssueSearchCriteria } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequest } from '@gitlens/git/models/pullRequest.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport { effectiveIssueSort } from '@gitlens/git/utils/issue.utils.js';\nimport { base64 } from '@gitlens/utils/base64.js';\nimport { CancellationError, isCancellationError, raceWithSignal } from '@gitlens/utils/cancellation.js';\nimport { sha256, uuid } from '@gitlens/utils/crypto.js';\nimport { trace } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { ScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { mapBounded } from '@gitlens/utils/promise.js';\nimport type { CacheController } from '@gitlens/utils/promiseCache.js';\nimport { PromiseCache } from '@gitlens/utils/promiseCache.js';\nimport { maybeStopWatch } from '@gitlens/utils/stopwatch.js';\nimport type { TokenWithInfo } from '../../authentication/models.js';\nimport type { IntegrationServiceContext } from '../../context.js';\nimport {\n\tAuthenticationError,\n\tAuthenticationErrorReason,\n\tisRateLimitResponse,\n\tProviderFetchError,\n\tRequestClientError,\n\tRequestNotFoundError,\n\ttoRateLimitError,\n} from '../../errors.js';\nimport type { ProviderIssueSearchPage } from '../../models/issueReads.js';\nimport { decodePathSegment } from '../../utils/domain.utils.js';\nimport type { ProviderApiConfig } from '../apiConfig.js';\nimport { baseProviderApiConfig } from '../apiConfig.js';\nimport { createProviderApiRequest, createProviderApis } from '../providerApiClient.js';\nimport { throwProviderError } from '../providerErrors.js';\nimport type {\n\tAzureForkRepositoryUrls,\n\tAzureGitCommit,\n\tAzureProjectDescriptor,\n\tAzurePullRequest,\n\tAzurePullRequestWithLinks,\n\tAzureRepositoryReference,\n\tAzureRepositoryUrls,\n\tAzureRepositoryWithMetadata,\n\tAzureWorkItemStateCategory,\n\tWorkItem,\n} from './models.js';\nimport {\n\tazurePullRequestStatusToState,\n\tazureWorkItemsStateCategoryToState,\n\tencodeAzurePathSegment,\n\tfromAzurePullRequest,\n\tfromAzureWorkItem,\n\tgetAzurePullRequestWebUrl,\n\tisClosedAzurePullRequestStatus,\n\tnormalizeAzureBranchName,\n\tparseAzureWorkItemDate,\n\tsanitizeAzureRepositoryUrl,\n} from './models.js';\nimport type { AzureWorkItemSearchCursor } from './search.js';\nimport {\n\tazureWorkItemBatchLimit,\n\tazureWorkItemSearchResultLimit,\n\tazureWorkItemWiqlLengthLimit,\n\tparseAzureWorkItemSearchCursor,\n\ttoAzureSearchPageSize,\n\ttoAzureWorkItemSearchCursorKey,\n\ttoAzureWorkItemSearchQueries,\n\ttoAzureWorkItemSearchWiql,\n} from './search.js';\nimport { AzureWorkItemDescriptionsCache } from './workItemDescriptions.js';\nimport { queryAzureWorkItemSearch } from './workItemSearch.js';\nimport {\n\tAzureWorkItemStatesCache,\n\tgetAzureWorkItemTypeStatesPath,\n\tgetAzureWorkItemTypesUrl,\n\trequireAzureWorkItemStateCategories,\n\tresolveAzureWorkItemStateCategory,\n} from './workItemStateCategories.js';\n\nconst forkRepositoryUrlCacheTtl = 5 * 60 * 1000;\nconst workItemMetadataConcurrency = 6;\n/** How long a work-item search's id snapshot outlives the last page read from it, and the most it lives at all. */\nconst workItemSearchSnapshotTtl = 5 * 60 * 1000;\nconst workItemSearchSnapshotMaxTtl = 30 * 60 * 1000;\n\ntype WorkItemSearchOptions = {\n\tbaseUrl: string;\n\tcriteria?: IssueSearchCriteria;\n\tprojectNames?: readonly string[];\n\tworkflowProjectNames?: readonly string[];\n};\n\n/** Whether Azure refused a WIQL query for matching more work items than it will return (`VS402337`). */\nfunction isWorkItemLimitRefusal(ex: unknown): boolean {\n\treturn ex instanceof RequestClientError && ex.message.includes('VS402337');\n}\n\nfunction parseAzureRepositoryDescriptor(repo: string): { projectName: string; repoName: string } {\n\tconst parts = repo.split('/');\n\tconst [projectName, segment, repoName] = parts;\n\tif (parts.length !== 3 || segment !== '_git' || !projectName || !repoName) {\n\t\tthrow new Error(`Invalid Azure repository descriptor '${repo}'; expected '{project}/_git/{repoName}'.`);\n\t}\n\n\treturn { projectName: projectName, repoName: repoName };\n}\n\nexport class AzureDevOpsApi implements Disposable {\n\tprivate readonly restApi: ReturnType<typeof createProviderApis>['azureDevOps'];\n\tprivate readonly _disposable: Disposable | undefined;\n\tprivate readonly _workItemStates: AzureWorkItemStatesCache;\n\tprivate readonly ownsWorkItemStates: boolean;\n\tprivate readonly _workItemDescriptions: AzureWorkItemDescriptionsCache;\n\tprivate readonly ownsWorkItemDescriptions: boolean;\n\tprivate readonly _forkRepositoryUrls = new PromiseCache<string, AzureForkRepositoryUrls | undefined>({\n\t\tcapacity: 100,\n\t\tcreateTTL: forkRepositoryUrlCacheTtl,\n\t});\n\t/**\n\t * The ordered ids each filtered work-item search's first page queried, paged through by its continuations. Kept\n\t * alive while a pagination keeps reading them (see `workItemSearchSnapshotTtl`). Every first page adds one, so\n\t * the capacity leaves room for repeated first pages before an idle pagination's snapshot is the one evicted.\n\t */\n\tprivate readonly _workItemSearches = new PromiseCache<string, number[]>({\n\t\tcapacity: 50,\n\t\taccessTTL: workItemSearchSnapshotTtl,\n\t\tcreateTTL: workItemSearchSnapshotMaxTtl,\n\t});\n\n\tconstructor(\n\t\tprivate readonly config: ProviderApiConfig,\n\t\tworkItemStates?: AzureWorkItemStatesCache,\n\t\tworkItemDescriptions?: AzureWorkItemDescriptionsCache,\n\t) {\n\t\tthis.restApi = createProviderApis({\n\t\t\trequest: createProviderApiRequest((input, init) => config.fetch(input, init)),\n\t\t}).azureDevOps;\n\t\tthis._workItemStates = workItemStates ?? new AzureWorkItemStatesCache();\n\t\tthis.ownsWorkItemStates = workItemStates == null;\n\t\tthis._workItemDescriptions = workItemDescriptions ?? new AzureWorkItemDescriptionsCache();\n\t\tthis.ownsWorkItemDescriptions = workItemDescriptions == null;\n\t\tthis._disposable = config.onConfigChanged?.(() => this.resetCaches());\n\t}\n\n\tdispose(): void {\n\t\tthis._disposable?.dispose();\n\t}\n\n\tprivate resetCaches(): void {\n\t\tthis.restApi.updateConfig({});\n\t\tif (this.ownsWorkItemStates) {\n\t\t\tthis._workItemStates.clear();\n\t\t}\n\t\tif (this.ownsWorkItemDescriptions) {\n\t\t\tthis._workItemDescriptions.clear();\n\t\t}\n\t\tthis._forkRepositoryUrls.clear();\n\t\tthis._workItemSearches.clear();\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, branch) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tbranch: branch,\n\t\t}),\n\t})\n\tpublic async getPullRequestForBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbranch: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { projectName, repoName } = parseAzureRepositoryDescriptor(repo);\n\n\t\ttry {\n\t\t\tconst prResult = await this.request<{ value: AzurePullRequest[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\toptions?.baseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(projectName)}/_apis/git/repositories/${encodeAzurePathSegment(repoName)}/pullRequests?searchCriteria.status=all&searchCriteria.sourceRefName=${encodeURIComponent(`refs/heads/${branch}`)}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\t// Sort PRs: open PRs first, then by most recent activity (creation or closure date)\n\t\t\tconst sortedPRs = prResult?.value.sort((a, b) => {\n\t\t\t\t// First, prioritize open PRs (active/notSet) over closed ones (abandoned/completed)\n\t\t\t\tconst aIsOpen = a.status === 'active' || a.status === 'notSet';\n\t\t\t\tconst bIsOpen = b.status === 'active' || b.status === 'notSet';\n\n\t\t\t\tif (aIsOpen !== bIsOpen) {\n\t\t\t\t\treturn aIsOpen ? -1 : 1; // Open PRs come first\n\t\t\t\t}\n\n\t\t\t\t// Among PRs with the same status, sort by most recent activity\n\t\t\t\t// Use closedDate if available, otherwise use creationDate\n\t\t\t\tconst aDate = new Date(a.closedDate || a.creationDate);\n\t\t\t\tconst bDate = new Date(b.closedDate || b.creationDate);\n\n\t\t\t\treturn bDate.getTime() - aDate.getTime(); // Most recent first\n\t\t\t});\n\n\t\t\tconst pr = sortedPRs?.[0];\n\t\t\tif (pr == null) return undefined;\n\n\t\t\treturn await this.toPullRequest(pr, provider, token, owner, options.baseUrl, scope);\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is actionable and must not be reported as an absent result; every other\n\t\t\t// failure keeps the existing degrade-to-undefined behavior.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getPullRequestForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { projectName, repoName } = parseAzureRepositoryDescriptor(repo);\n\t\tconst resource = await this.requireRestResource(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\towner,\n\t\t\tbaseUrl,\n\t\t\t'pullRequestQuery',\n\t\t\t'4.1',\n\t\t\tcancellation,\n\t\t);\n\t\ttry {\n\t\t\tconst encodedProject = encodeAzurePathSegment(projectName);\n\t\t\tconst encodedRepo = encodeAzurePathSegment(repoName);\n\t\t\tconst prResult = await this.request<{ results: Record<string, AzurePullRequest[]>[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodedProject}/_apis/git/repositories/${encodedRepo}/pullrequestquery?api-version=${resource.apiVersion}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tqueries: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\titems: [rev],\n\t\t\t\t\t\t\t\ttype: 'commit',\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\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\n\t\t\tconst pr = prResult?.results[0]?.[rev]?.[0];\n\t\t\tif (pr == null) return undefined;\n\n\t\t\tconst pullRequest = await this.request<AzurePullRequestWithLinks>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(pr.repository.project.id)}/_apis/git/repositories/${encodeAzurePathSegment(pr.repository.id)}/pullRequests/${encodeAzurePathSegment(pr.pullRequestId.toString())}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (pullRequest == null) return undefined;\n\n\t\t\treturn await this.toPullRequest(pullRequest, provider, token, owner, baseUrl, scope, cancellation);\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is actionable and must not be reported as an absent result; every other\n\t\t\t// failure keeps the existing degrade-to-undefined behavior.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\tscope?.error(ex);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, projectOrName, id) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\tprojectOrName: projectOrName,\n\t\t\tid: id,\n\t\t}),\n\t})\n\tpublic async getPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tprojectOrName: string,\n\t\tid: string,\n\t\toptions: { baseUrl: string },\n\t): Promise<PullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\t// A pull request id is unique within the organization, so no repository is required here — only the\n\t\t// project. `projectOrName` is either a bare project name or a `{project}/_git/{repo}` descriptor; either\n\t\t// way the project is its first segment.\n\t\tconst projectName = projectOrName.split('/')[0];\n\n\t\ttry {\n\t\t\tconst pr = await this.request<AzurePullRequest>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(projectName)}/_apis/git/pullrequests/${encodeAzurePathSegment(id)}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\treturn pr != null\n\t\t\t\t? await this.toPullRequest(pr, provider, token, owner, options.baseUrl, scope)\n\t\t\t\t: undefined;\n\t\t} catch (ex) {\n\t\t\t// Only a 404 is a proven absence; `Integration.getPullRequest` handles every other failure, so it is not\n\t\t\t// cached as a miss\n\t\t\tif (ex.original?.status === 404) return undefined;\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, id) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\tid: id,\n\t\t}),\n\t})\n\tpublic async getIssueOrPullRequest(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tid: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t\ttype?: IssueOrPullRequestType;\n\t\t},\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { projectName, repoName } = parseAzureRepositoryDescriptor(repo);\n\n\t\tif (options?.type === undefined || options?.type === 'issue') {\n\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t'workItems',\n\t\t\t\t'6.0',\n\t\t\t);\n\t\t\tlet issueResult: WorkItem | undefined;\n\t\t\ttry {\n\t\t\t\tissueResult = await this.getWorkItem(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tprojectName,\n\t\t\t\t\tid,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\tresource,\n\t\t\t\t\tscope,\n\t\t\t\t);\n\t\t\t} catch (ex) {\n\t\t\t\t// A rejected credential is actionable and must not be reported as an absent issue; every other\n\t\t\t\t// non-404 keeps the existing degrade-to-undefined behavior.\n\t\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\t\tif (ex.original?.status !== 404) {\n\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (issueResult != null) {\n\t\t\t\tawait this.requireWorkItemProject(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tprojectName,\n\t\t\t\t\tissueResult,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\tscope,\n\t\t\t\t);\n\t\t\t\tconst issueType = issueResult.fields['System.WorkItemType'];\n\t\t\t\tconst state = issueResult.fields['System.State'];\n\t\t\t\tconst stateCategory = await this.getWorkItemStateCategory(\n\t\t\t\t\tissueType,\n\t\t\t\t\tstate,\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tprojectName,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\n\t\t\t\tconst normalizedState = azureWorkItemsStateCategoryToState(\n\t\t\t\t\tstateCategory,\n\t\t\t\t\tparseAzureWorkItemDate(issueResult.fields['Microsoft.VSTS.Common.ClosedDate']) ?? undefined,\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\tid: issueResult.id.toString(),\n\t\t\t\t\ttype: 'issue',\n\t\t\t\t\tnodeId: issueResult.id.toString(),\n\t\t\t\t\tprovider: provider,\n\t\t\t\t\tcreatedDate: new Date(issueResult.fields['System.CreatedDate']),\n\t\t\t\t\tupdatedDate: new Date(issueResult.fields['System.ChangedDate']),\n\t\t\t\t\tstate: normalizedState,\n\t\t\t\t\tclosed: normalizedState === 'closed',\n\t\t\t\t\ttitle: issueResult.fields['System.Title'],\n\t\t\t\t\turl: issueResult._links.html.href,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tif (options?.type === undefined || options?.type === 'pullrequest') {\n\t\t\ttry {\n\t\t\t\tconst prResult = await this.request<AzurePullRequestWithLinks>(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\toptions?.baseUrl,\n\t\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(projectName)}/_apis/git/repositories/${encodeAzurePathSegment(repoName)}/pullRequests/${encodeAzurePathSegment(id)}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tmethod: 'GET',\n\t\t\t\t\t},\n\t\t\t\t\tscope,\n\t\t\t\t);\n\n\t\t\t\tif (prResult != null) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tid: prResult.pullRequestId.toString(),\n\t\t\t\t\t\ttype: 'pullrequest',\n\t\t\t\t\t\tnodeId: prResult.pullRequestId.toString(), // prResult.artifactId maybe?\n\t\t\t\t\t\tprovider: provider,\n\t\t\t\t\t\tcreatedDate: new Date(prResult.creationDate),\n\t\t\t\t\t\tupdatedDate: new Date(prResult.creationDate),\n\t\t\t\t\t\tstate: azurePullRequestStatusToState(prResult.status),\n\t\t\t\t\t\tclosed: isClosedAzurePullRequestStatus(prResult.status),\n\t\t\t\t\t\ttitle: prResult.title,\n\t\t\t\t\t\turl: getAzurePullRequestWebUrl(prResult, options.baseUrl, owner),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn undefined;\n\t\t\t} catch (ex) {\n\t\t\t\t// A rejected credential is actionable and must not be reported as an absent issue; every other\n\t\t\t\t// non-404 keeps the existing degrade-to-undefined behavior.\n\t\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\t\tif (ex.original?.status !== 404) {\n\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, project, id) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tproject: project,\n\t\t\tid: id,\n\t\t}),\n\t})\n\tpublic async getIssue(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tproject: AzureProjectDescriptor,\n\t\tid: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t\t/**\n\t\t\t * The current user as the organization's work items identify them, set as the row's `viewer`, or `null` when\n\t\t\t * it couldn't be resolved, which marks the row `viewerUnresolved`. Asked only once the work item was read,\n\t\t\t * alongside its state and fields; never rejects.\n\t\t\t */\n\t\t\tviewer?: () => Promise<{ id: string } | null>;\n\t\t},\n\t): Promise<Issue | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst resource = await this.requireRestResource(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tproject.resourceName,\n\t\t\toptions.baseUrl,\n\t\t\t'workItems',\n\t\t\t'6.0',\n\t\t);\n\n\t\tlet issueResult: WorkItem | undefined;\n\t\ttry {\n\t\t\tissueResult = await this.getWorkItem(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tproject.resourceName,\n\t\t\t\tproject.name,\n\t\t\t\tid,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tresource,\n\t\t\t\tscope,\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is actionable and must not be reported as an absent work item; every other\n\t\t\t// non-404 keeps the existing degrade-to-undefined behavior.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\tif (ex.original?.status !== 404) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\tif (issueResult != null) {\n\t\t\tawait this.requireWorkItemProject(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tproject.resourceName,\n\t\t\t\tproject.name,\n\t\t\t\tissueResult,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tscope,\n\t\t\t);\n\t\t\tconst issueType = issueResult.fields['System.WorkItemType'];\n\t\t\tconst state = issueResult.fields['System.State'];\n\t\t\tconst [stateCategory, htmlFields, viewer] = await Promise.all([\n\t\t\t\tthis.getWorkItemStateCategory(\n\t\t\t\t\tissueType,\n\t\t\t\t\tstate,\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tproject.resourceName,\n\t\t\t\t\tproject.name,\n\t\t\t\t\toptions,\n\t\t\t\t),\n\t\t\t\tthis.getWorkItemHtmlFields(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tproject.resourceName,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\tissueResult.fields,\n\t\t\t\t\tscope,\n\t\t\t\t),\n\t\t\t\toptions.viewer?.(),\n\t\t\t]);\n\t\t\treturn fromAzureWorkItem(issueResult, provider, project, stateCategory, 'point', htmlFields, viewer);\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo, rev, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t\trev: rev,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getAccountForCommit(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\trev: string,\n\t\tbaseUrl: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<UnidentifiedAuthor | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst { projectName, repoName } = parseAzureRepositoryDescriptor(repo);\n\n\t\ttry {\n\t\t\t// Try to get the Work item (wit) first with specific fields\n\t\t\tconst commit = await this.request<AzureGitCommit>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(projectName)}/_apis/git/repositories/${encodeAzurePathSegment(repoName)}/commits/${encodeAzurePathSegment(rev)}`,\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\t\t\tconst author = commit?.author;\n\t\t\tif (!author) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Azure API never gives us an id/username we can use, therefore we always return UnidentifiedAuthor\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\tid: undefined,\n\t\t\t\tusername: undefined,\n\t\t\t\tname: author?.name,\n\t\t\t\temail: author?.email,\n\t\t\t\tavatarUrl: undefined,\n\t\t\t} satisfies UnidentifiedAuthor;\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is actionable and must not be reported as an absent work item; every other\n\t\t\t// non-404 keeps the existing degrade-to-undefined behavior.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\tif (ex.original?.status !== 404) {\n\t\t\t\tscope?.error(ex);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * The collection an Azure DevOps Server address names, or `undefined` when it names the installation.\n\t *\n\t * Below a collection, `connectionData` describes that collection: its `instanceId` is the collection's id, and its\n\t * `webApplicationRelativeDirectory` ends in the collection's path segment (`DefaultCollection/`); it is empty or\n\t * absent at the server level. As measured against Azure DevOps Server 2020. The directory may also carry the\n\t * installation's own virtual directory before the collection (`tfs/DefaultCollection/`), so only its LAST segment\n\t * names the collection, and only when it is the last segment of the address asked about.\n\t */\n\t@trace({\n\t\targs: (provider, token, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getAddressedCollection(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tbaseUrl: string,\n\t): Promise<{ id: string; name: string } | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst connectionData = await this.request<{ instanceId?: string; webApplicationRelativeDirectory?: string }>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t'_apis/connectionData',\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t);\n\t\tconst segment = connectionData?.webApplicationRelativeDirectory?.split('/').findLast(Boolean);\n\t\tconst addressed = new URL(baseUrl).pathname.split('/').findLast(Boolean);\n\t\tif (segment == null || addressed == null || connectionData?.instanceId == null) return undefined;\n\n\t\tconst name = decodePathSegment(segment);\n\t\tif (name.toLowerCase() !== decodePathSegment(addressed).toLowerCase()) return undefined;\n\n\t\treturn { id: connectionData.instanceId, name: name };\n\t}\n\n\t@trace({\n\t\targs: (provider, token, baseUrl) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tbaseUrl: baseUrl,\n\t\t}),\n\t})\n\tasync getCurrentUserOnServer(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tbaseUrl: string,\n\t): Promise<{ id: string; name?: string; email?: string; username?: string; avatarUrl?: string } | undefined> {\n\t\tconst scope = getScopedLogger();\n\n\t\ttry {\n\t\t\tconst connectionData = await this.request<{\n\t\t\t\tauthenticatedUser?: {\n\t\t\t\t\tid: string;\n\t\t\t\t\tdescriptor: string;\n\t\t\t\t\tisActive: boolean;\n\t\t\t\t\tmetTypeId: number;\n\t\t\t\t\tproviderDisplayName?: string;\n\t\t\t\t\temailAddress?: string;\n\t\t\t\t\tresourceVersion: 2;\n\t\t\t\t\tsubjectDescriptor: string;\n\t\t\t\t\tproperties?: {\n\t\t\t\t\t\tAccount?: {\n\t\t\t\t\t\t\t$type: string;\n\t\t\t\t\t\t\t$value: string;\n\t\t\t\t\t\t};\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t}>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t'_apis/connectionData',\n\t\t\t\t{\n\t\t\t\t\tmethod: 'GET',\n\t\t\t\t},\n\t\t\t\tscope,\n\t\t\t);\n\n\t\t\tconst user = connectionData?.authenticatedUser;\n\t\t\tconst username = user?.properties?.Account?.$value;\n\t\t\tif (!username) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: user.id,\n\t\t\t\tname: user.providerDisplayName,\n\t\t\t\temail: user.emailAddress,\n\t\t\t\tusername: username,\n\t\t\t};\n\t\t} catch (ex) {\n\t\t\tscope?.error(ex, `Failed to get current user from ${baseUrl}`);\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tasync getWorkItemStateCategory(\n\t\tissueType: string,\n\t\tstate: string,\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tprojectName: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureWorkItemStateCategory | undefined> {\n\t\tconst states = await this.getWorkItemTypeStates(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\towner,\n\t\t\tprojectName,\n\t\t\tissueType,\n\t\t\toptions.baseUrl,\n\t\t\tcancellation,\n\t\t);\n\t\treturn resolveAzureWorkItemStateCategory(states, state);\n\t}\n\n\tprivate getWorkItemTypeStates(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tproject: string,\n\t\ttype: string,\n\t\tbaseUrl: string,\n\t\tcancellation?: AbortSignal,\n\t) {\n\t\treturn this._workItemStates.getStates(\n\t\t\t{ baseUrl: baseUrl, namespace: owner, project: project, token: token.accessToken, isPAT: true },\n\t\t\ttype,\n\t\t\tasync signal => {\n\t\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\t'workItemTypeStates',\n\t\t\t\t\t'6.0-preview.1',\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\treturn this.request(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\tgetAzureWorkItemTypeStatesPath(owner, project, type, resource.apiVersion),\n\t\t\t\t\t{ method: 'GET' },\n\t\t\t\t\tundefined,\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t},\n\t\t\tcancellation,\n\t\t\tasync signal => {\n\t\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\t'backlogConfiguration',\n\t\t\t\t\t'6.0-preview.1',\n\t\t\t\t\tsignal,\n\t\t\t\t);\n\t\t\t\tconst path = `${encodeAzurePathSegment(owner)}/${encodeAzurePathSegment(project)}/_apis/work/backlogconfiguration?api-version=${resource.apiVersion}`;\n\t\t\t\treturn this.request(provider, token, baseUrl, path, { method: 'GET' }, undefined, signal);\n\t\t\t},\n\t\t);\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getRepositoryMetadata(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst resource = await this.requireRestResource(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\towner,\n\t\t\toptions.baseUrl,\n\t\t\t'repositories',\n\t\t\t'7.1',\n\t\t\tcancellation,\n\t\t);\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tresource.apiVersion,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (response == null) return undefined;\n\n\t\t\t// Azure's `parentRepository` only reliably carries the repo name and its project; a fork's parent\n\t\t\t// lives in the same organization, so the org (`owner`) is the parent owner. Only report `parent`\n\t\t\t// when the parent's name is actually present — never fall back to the fork's own name.\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\towner: owner,\n\t\t\t\t// Prefer the API's canonical name over parsing the composite `repo` descriptor string.\n\t\t\t\tname: response.name,\n\t\t\t\tisFork: response.isFork ?? false,\n\t\t\t\tparent:\n\t\t\t\t\tresponse.isFork && response.parentRepository?.name != null\n\t\t\t\t\t\t? { owner: owner, name: response.parentRepository.name }\n\t\t\t\t\t\t: undefined,\n\t\t\t} satisfies RepositoryMetadata;\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is not a probe outcome: it is actionable, and the caller routes it into the\n\t\t\t// session recovery. A cancellation or a 404 still degrades quietly.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t@trace({\n\t\targs: (provider, token, owner, repo) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\towner: owner,\n\t\t\trepo: repo,\n\t\t}),\n\t})\n\tasync getDefaultBranch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\toptions: {\n\t\t\tbaseUrl: string;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<DefaultBranch | undefined> {\n\t\tconst scope = getScopedLogger();\n\t\tconst resource = await this.requireRestResource(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\towner,\n\t\t\toptions.baseUrl,\n\t\t\t'repositories',\n\t\t\t'7.1',\n\t\t\tcancellation,\n\t\t);\n\n\t\ttry {\n\t\t\tconst response = await this.getRepository(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\trepo,\n\t\t\t\toptions.baseUrl,\n\t\t\t\tresource.apiVersion,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tif (response?.defaultBranch == null) return undefined;\n\n\t\t\treturn {\n\t\t\t\tprovider: provider,\n\t\t\t\tname: normalizeAzureBranchName(response.defaultBranch),\n\t\t\t} satisfies DefaultBranch;\n\t\t} catch (ex) {\n\t\t\t// A rejected credential is not a probe outcome: it is actionable, and the caller routes it into the\n\t\t\t// session recovery. A cancellation or a 404 still degrades quietly.\n\t\t\tif (ex instanceof AuthenticationError) throw ex;\n\n\t\t\t// Cancellations and 404s are expected outcomes for a probe; don't log them as errors.\n\t\t\tif (!isCancellationError(ex) && !(ex instanceof RequestNotFoundError)) {\n\t\t\t\tscope?.error(ex);\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t/**\n\t * One page of a filtered work-item search over a collection: bounded WIQL queries for the ordered ids, then one\n\t * detail read for the page's slice of them.\n\t *\n\t * The ids a first page queried are kept as the snapshot its continuations page through, for as long as the\n\t * pagination keeps reading it, so metadata changes cannot retarget the continuation. Each first page queries its\n\t * own snapshot, so paginations never share one. A continuation whose snapshot is gone is refused (see\n\t * {@link AzureWorkItemSearchCursor}).\n\t *\n\t * The query asks for one id more than {@link azureWorkItemSearchResultLimit}, bounded by `$top`: the extra id is\n\t * what tells \"exactly the limit\" from \"past it\". Past it, the page is `truncated` with `limitReached` and no total,\n\t * since the true count is unknowable here. A server that refuses the match set even so fails the page with a\n\t * \"narrow the search\" error: no bounded query could serve that order's first window.\n\t *\n\t * `resolveProject` maps each result's project name to its descriptor. A work item in a project it doesn't know\n\t * fails the page rather than being dropped or mis-attributed, since either would leave the page disagreeing with\n\t * the count of the same query; the caller refreshes its project discovery before a search so that means a\n\t * project created during the pagination.\n\t *\n\t * `viewer` resolves the current user as the collection's work items identify them, set as each row's `viewer`, or\n\t * `null` when it couldn't be resolved, which marks the rows `viewerUnresolved`. It's asked once for a page that read\n\t * any work item, and never rejects.\n\t */\n\t@trace({\n\t\targs: (provider, token, collection) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tcollection: collection,\n\t\t}),\n\t})\n\tasync searchWorkItemsPage(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tcollection: string,\n\t\toptions: WorkItemSearchOptions & {\n\t\t\tresolveProject: (name: string) => AzureProjectDescriptor | undefined;\n\t\t\tviewer?: () => Promise<{ id: string } | null>;\n\t\t\tcursor?: string;\n\t\t\tpageSize?: number;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderIssueSearchPage> {\n\t\tconst scope = getScopedLogger();\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst identity = JSON.stringify([\n\t\t\toptions.criteria?.state ?? 'open',\n\t\t\ttoAzureWorkItemSearchWiql(\n\t\t\t\t{ ...options.criteria, state: 'all' },\n\t\t\t\teffectiveIssueSort(options.criteria?.sort),\n\t\t\t\toptions.projectNames,\n\t\t\t),\n\t\t]);\n\t\tconst key = toAzureWorkItemSearchCursorKey(collection, identity);\n\t\tconst pageSize = toAzureSearchPageSize(options.pageSize, 100, azureWorkItemBatchLimit);\n\t\tconst cursor = parseAzureWorkItemSearchCursor(options.cursor, key, pageSize);\n\t\tconst page = cursor?.page ?? 1;\n\n\t\t// Keep the full request identity: metadata changes cannot retarget a live snapshot, and a hash collision\n\t\t// cannot let a different query or credential read it.\n\t\tconst snapshot = cursor?.snapshot ?? uuid();\n\t\tconst snapshotKey = JSON.stringify([\n\t\t\tawait sha256(token.accessToken),\n\t\t\toptions.baseUrl,\n\t\t\tcollection,\n\t\t\tidentity,\n\t\t\tsnapshot,\n\t\t]);\n\t\t// A continuation only ever READS its snapshot: resuming against a fresh query could skip a work item silently.\n\t\tconst snapshotFound = cursor?.snapshot != null ? this._workItemSearches.get(snapshotKey) : undefined;\n\t\tif (cursor?.snapshot != null && snapshotFound == null) {\n\t\t\tthrow new Error('Work item search results expired; restart the read without a cursor');\n\t\t}\n\n\t\tconst result = await (snapshotFound ??\n\t\t\tthis._workItemSearches.getOrCreate(\n\t\t\t\tsnapshotKey,\n\t\t\t\t(_cacheable, signal) =>\n\t\t\t\t\tthis.readWorkItemSearch(provider, token, collection, options, true, scope, signal).catch(\n\t\t\t\t\t\t(ex: unknown) => {\n\t\t\t\t\t\t\tif (isWorkItemLimitRefusal(ex)) {\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`${provider.name} refused a work item search matching more than ${azureWorkItemSearchResultLimit} results; narrow the search`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthrow ex;\n\t\t\t\t\t\t},\n\t\t\t\t\t),\n\t\t\t\t{ cancellation: cancellation },\n\t\t\t));\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst limitReached = result.length > azureWorkItemSearchResultLimit;\n\t\tconst ids = limitReached ? result.slice(0, azureWorkItemSearchResultLimit) : result;\n\n\t\tconst offset = cursor?.offset ?? 0;\n\n\t\tconst slice = ids.slice(offset, offset + pageSize);\n\t\tconst values: Issue[] = [];\n\t\tif (slice.length > 0) {\n\t\t\tconst batch = await this.getRestResource(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tcollection,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t'workItemsBatch',\n\t\t\t\t'5.0',\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst resource =\n\t\t\t\tbatch ??\n\t\t\t\t(await this.requireRestResource(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tcollection,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\t'workItems',\n\t\t\t\t\t'5.0',\n\t\t\t\t\tcancellation,\n\t\t\t\t));\n\t\t\tconst route =\n\t\t\t\tbatch != null\n\t\t\t\t\t? `workitemsbatch?api-version=${resource.apiVersion}`\n\t\t\t\t\t: `workitems?ids=${slice.join(',')}&$expand=Links&errorPolicy=Omit&api-version=${resource.apiVersion}`;\n\t\t\tconst workItems = await this.request<{ value: (WorkItem | null)[] }>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\toptions.baseUrl,\n\t\t\t\t`${encodeAzurePathSegment(collection)}/_apis/wit/${route}`,\n\t\t\t\tbatch != null\n\t\t\t\t\t? { method: 'POST', body: JSON.stringify({ ids: slice, $expand: 'Links', errorPolicy: 'Omit' }) }\n\t\t\t\t\t: { method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst byId = new Map((workItems?.value ?? []).filter(w => w != null).map(w => [w.id, w]));\n\t\t\tconst viewer = byId.size > 0 ? await options.viewer?.() : undefined;\n\t\t\tfor (const id of slice) {\n\t\t\t\t// A work item deleted since the ids were queried is gone, not a failure: skipping it keeps the page\n\t\t\t\t// honest, since it no longer matches anything.\n\t\t\t\tconst workItem = byId.get(id);\n\t\t\t\tif (workItem == null) continue;\n\n\t\t\t\tconst projectName = workItem.fields['System.TeamProject'];\n\t\t\t\tif (\n\t\t\t\t\toptions.projectNames?.length &&\n\t\t\t\t\t!options.projectNames.some(name => name.toLowerCase() === projectName?.toLowerCase())\n\t\t\t\t) {\n\t\t\t\t\tthrow new Error(`Azure DevOps work item ${id} is outside the requested projects`);\n\t\t\t\t}\n\n\t\t\t\tconst project = options.resolveProject(projectName);\n\t\t\t\tif (project == null) {\n\t\t\t\t\tthrow new Error(`Azure DevOps work item ${id} is in project '${projectName}', which isn't visible`);\n\t\t\t\t}\n\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\tconst stateCategory = await this.getWorkItemStateCategory(\n\t\t\t\t\tworkItem.fields['System.WorkItemType'],\n\t\t\t\t\tworkItem.fields['System.State'],\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tcollection,\n\t\t\t\t\tproject.name,\n\t\t\t\t\toptions,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t\tconst htmlFields = await this.getWorkItemHtmlFields(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tcollection,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\tworkItem.fields,\n\t\t\t\t\tscope,\n\t\t\t\t\tcancellation,\n\t\t\t\t);\n\t\t\t\tvalues.push(\n\t\t\t\t\tfromAzureWorkItem(workItem, provider, project, stateCategory, 'search', htmlFields, viewer),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst nextOffset = offset + slice.length;\n\t\tconst hasMore = nextOffset < ids.length;\n\t\tconst next: AzureWorkItemSearchCursor = { key: key, snapshot: snapshot, offset: nextOffset, page: page + 1 };\n\t\treturn {\n\t\t\tvalues: values,\n\t\t\tcursor: hasMore ? JSON.stringify(next) : undefined,\n\t\t\thasMore: hasMore,\n\t\t\tpage: page,\n\t\t\ttruncated: limitReached,\n\t\t\ttotalCount: limitReached ? undefined : ids.length,\n\t\t\tlimitReached: limitReached || undefined,\n\t\t};\n\t}\n\n\t/**\n\t * How many work items the same WIQL {@link searchWorkItemsPage} would page through match, reading no details.\n\t *\n\t * Asks for one id more than the result ceiling, so the count is exact up to it and `'exceeds-limit'` past it —\n\t * never the ceiling itself, which would understate the match set.\n\t */\n\t@trace({\n\t\targs: (provider, token, collection) => ({\n\t\t\tprovider: provider.name,\n\t\t\ttoken: `<token:${token.microHash}>`,\n\t\t\tcollection: collection,\n\t\t}),\n\t})\n\tasync countWorkItems(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tcollection: string,\n\t\toptions: WorkItemSearchOptions,\n\t\tcancellation?: AbortSignal,\n\t): Promise<number | 'exceeds-limit'> {\n\t\tconst scope = getScopedLogger();\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\ttry {\n\t\t\tconst result = await this.readWorkItemSearch(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tcollection,\n\t\t\t\toptions,\n\t\t\t\tfalse,\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\treturn result.length > azureWorkItemSearchResultLimit ? 'exceeds-limit' : result.length;\n\t\t} catch (ex) {\n\t\t\tif (isWorkItemLimitRefusal(ex)) return 'exceeds-limit';\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tprivate async readWorkItemSearch(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tcollection: string,\n\t\toptions: WorkItemSearchOptions,\n\t\tordered: boolean,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<number[]> {\n\t\tconst queries = await this.getWorkItemSearchQueries(provider, token, collection, options, cancellation);\n\t\treturn queryAzureWorkItemSearch(\n\t\t\tqueries,\n\t\t\teffectiveIssueSort(options.criteria?.sort),\n\t\t\tordered,\n\t\t\t(wiql, top, asOf) =>\n\t\t\t\tthis.queryWorkItemIds(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\tcollection,\n\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\twiql,\n\t\t\t\t\ttop,\n\t\t\t\t\tscope,\n\t\t\t\t\tcancellation,\n\t\t\t\t\tasOf,\n\t\t\t\t),\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async getWorkItemSearchQueries(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tcollection: string,\n\t\toptions: WorkItemSearchOptions,\n\t\tcancellation?: AbortSignal,\n\t): Promise<string[]> {\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst projectNames = options.projectNames ?? options.workflowProjectNames ?? [];\n\t\tlet workflows: Map<string, AzureWorkItemTypeStates> | undefined;\n\t\tif (options.criteria?.state !== 'all') {\n\t\t\tconst types = (\n\t\t\t\tawait mapBounded(projectNames, workItemMetadataConcurrency, async project => {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\tconst scope = {\n\t\t\t\t\t\tbaseUrl: options.baseUrl,\n\t\t\t\t\t\tnamespace: collection,\n\t\t\t\t\t\tproject: project,\n\t\t\t\t\t\ttoken: token.accessToken,\n\t\t\t\t\t\tisPAT: true,\n\t\t\t\t\t};\n\t\t\t\t\tconst names = await this._workItemStates.getTypes(\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\tasync signal => {\n\t\t\t\t\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\t\t\t\t\tprovider,\n\t\t\t\t\t\t\t\ttoken,\n\t\t\t\t\t\t\t\tcollection,\n\t\t\t\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\t\t\t\t'workItemTypes',\n\t\t\t\t\t\t\t\t'6.0',\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn this.request(\n\t\t\t\t\t\t\t\tprovider,\n\t\t\t\t\t\t\t\ttoken,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tgetAzureWorkItemTypesUrl(options.baseUrl, collection, project, resource.apiVersion),\n\t\t\t\t\t\t\t\t{ method: 'GET' },\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcancellation,\n\t\t\t\t\t);\n\t\t\t\t\treturn names.map(name => ({ project: project, name: name, scope: scope }));\n\t\t\t\t})\n\t\t\t).flat();\n\t\t\tconst states = await mapBounded(types, workItemMetadataConcurrency, async type => ({\n\t\t\t\tname: type.name,\n\t\t\t\tproject: type.project,\n\t\t\t\tstates: requireAzureWorkItemStateCategories(\n\t\t\t\t\tawait this.getWorkItemTypeStates(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\ttoken,\n\t\t\t\t\t\tcollection,\n\t\t\t\t\t\ttype.project,\n\t\t\t\t\t\ttype.name,\n\t\t\t\t\t\toptions.baseUrl,\n\t\t\t\t\t\tcancellation,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t}));\n\t\t\tworkflows = new Map(\n\t\t\t\tprojectNames.map(project => [project, { types: states.filter(type => type.project === project) }]),\n\t\t\t);\n\t\t}\n\n\t\treturn toAzureWorkItemSearchQueries(\n\t\t\toptions.criteria,\n\t\t\teffectiveIssueSort(options.criteria?.sort),\n\t\t\tprojectNames,\n\t\t\tworkflows,\n\t\t);\n\t}\n\n\t/**\n\t * The ids a collection-level WIQL query matches, in its order.\n\t *\n\t * `timePrecision=true` lets the criteria's dates compare as instants, including on legacy servers.\n\t */\n\tprivate async queryWorkItemIds(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tcollection: string,\n\t\tbaseUrl: string,\n\t\twiql: string,\n\t\ttop: number,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t\tasOf?: string,\n\t): Promise<{ ids: number[]; asOf?: string }> {\n\t\tconst query = asOf == null ? wiql : `${wiql} ASOF '${asOf}'`;\n\t\tif (query.length > azureWorkItemWiqlLengthLimit) {\n\t\t\tthrow new Error('Azure DevOps work item search query is too long; narrow the search');\n\t\t}\n\n\t\tconst resource = await this.requireRestResource(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tcollection,\n\t\t\tbaseUrl,\n\t\t\t'wiql',\n\t\t\t'5.0',\n\t\t\tcancellation,\n\t\t);\n\t\tconst result = await this.request<{ workItems?: { id: number }[]; asOf?: string }>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`${encodeAzurePathSegment(collection)}/_apis/wit/wiql?$top=${top}&timePrecision=true&api-version=${resource.apiVersion}`,\n\t\t\t{ method: 'POST', body: JSON.stringify({ query: query }) },\n\t\t\tscope,\n\t\t\tcancellation,\n\t\t);\n\t\tif (result?.workItems == null) throw new Error('Azure DevOps returned no work item query result');\n\n\t\treturn { ids: result.workItems.map(w => w.id), asOf: result.asOf };\n\t}\n\n\tprivate async getRepository(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\trepo: string,\n\t\tbaseUrl: string,\n\t\tapiVersion: string,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureRepositoryWithMetadata | undefined> {\n\t\tconst { projectName, repoName } = parseAzureRepositoryDescriptor(repo);\n\t\tconst encodedProject = encodeAzurePathSegment(projectName);\n\t\tconst encodedRepo = encodeAzurePathSegment(repoName);\n\t\treturn this.request<AzureRepositoryWithMetadata>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`${encodeAzurePathSegment(owner)}/${encodedProject}/_apis/git/repositories/${encodedRepo}?api-version=${apiVersion}`,\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate async toPullRequest(\n\t\tpr: AzurePullRequest,\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tbaseUrl: string,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest> {\n\t\tconst forkRepositoryUrls = await this.getForkRepositoryUrls(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\towner,\n\t\t\tbaseUrl,\n\t\t\tpr.forkSource?.repository,\n\t\t\tscope,\n\t\t\tcancellation,\n\t\t);\n\t\t// Only the point reads convert through here.\n\t\treturn fromAzurePullRequest(pr, provider, owner, baseUrl, forkRepositoryUrls, 'point');\n\t}\n\n\t/**\n\t * Resolves the web and HTTPS clone URLs of the fork a cross-repository pull request comes from. Every other\n\t * repository URL the model reports is rebuilt from the pull request payload; only a fork reference lacks the\n\t * project to do that, so only a fork costs a request.\n\t *\n\t * Best-effort by contract: a fork in a project the token cannot read, a deleted fork, or a throttled request\n\t * leaves the head ref without a URL. It must never cost the pull request itself, which is what makes swallowing\n\t * the failure here the right call rather than a shortcut.\n\t */\n\tprivate async getForkRepositoryUrls(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tbaseUrl: string,\n\t\trepository: AzureRepositoryReference | undefined,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureForkRepositoryUrls | undefined> {\n\t\tif (repository == null) return undefined;\n\n\t\tlet tokenHash: string;\n\t\ttry {\n\t\t\ttokenHash = await sha256(token.accessToken);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst cacheKey = JSON.stringify([tokenHash, baseUrl, owner, repository.id]);\n\t\t// The request is shared, so the factory is handed the cache's aggregate signal rather than this caller's: it\n\t\t// aborts only once every caller waiting on the entry has cancelled.\n\t\treturn this._forkRepositoryUrls.getOrCreate(\n\t\t\tcacheKey,\n\t\t\t(cacheable, aggregate) =>\n\t\t\t\tthis.fetchForkRepositoryUrls(\n\t\t\t\t\tprovider,\n\t\t\t\t\ttoken,\n\t\t\t\t\towner,\n\t\t\t\t\tbaseUrl,\n\t\t\t\t\trepository.id,\n\t\t\t\t\tcacheable,\n\t\t\t\t\tscope,\n\t\t\t\t\taggregate,\n\t\t\t\t),\n\t\t\t{ cancellation: cancellation },\n\t\t);\n\t}\n\n\tprivate async fetchForkRepositoryUrls(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tbaseUrl: string,\n\t\trepositoryId: string,\n\t\tcacheable: CacheController,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureForkRepositoryUrls | undefined> {\n\t\ttry {\n\t\t\tencodeAzurePathSegment(repositoryId);\n\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\towner,\n\t\t\t\tbaseUrl,\n\t\t\t\t'repositories',\n\t\t\t\t'4.1',\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst response = await this.request<AzureRepositoryUrls>(\n\t\t\t\tprovider,\n\t\t\t\ttoken,\n\t\t\t\tbaseUrl,\n\t\t\t\t`${encodeAzurePathSegment(owner)}/_apis/git/repositories/${encodeAzurePathSegment(repositoryId)}?api-version=${resource.apiVersion}`,\n\t\t\t\t{ method: 'GET' },\n\t\t\t\tscope,\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\tconst webUrl = sanitizeAzureRepositoryUrl(response?.webUrl, baseUrl, owner);\n\t\t\tconst cloneHttps = sanitizeAzureRepositoryUrl(response?.remoteUrl, baseUrl, owner);\n\n\t\t\t// The clone URL stands in for the web URL when the response omits it — an older `api-version` promises\n\t\t\t// neither field, and naming the fork by the URL git would use beats naming it not at all.\n\t\t\tconst url = webUrl ?? cloneHttps;\n\t\t\tif (url == null) {\n\t\t\t\tcacheable.invalidate();\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn { url: url, cloneHttps: cloneHttps };\n\t\t} catch (ex) {\n\t\t\t// Missing or inaccessible forks are cached briefly; transient failures retry on the next read.\n\t\t\tif (!(ex instanceof RequestNotFoundError) && !(ex instanceof AuthenticationError)) {\n\t\t\t\tcacheable.invalidate();\n\t\t\t}\n\n\t\t\tconst status = ex instanceof ProviderFetchError ? ` (${ex.status})` : '';\n\t\t\tscope?.warn(`Unable to resolve the fork repository URLs${status}`);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async getWorkItem(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tproject: string,\n\t\tid: string,\n\t\tbaseUrl: string,\n\t\tresource: AzureDevOpsRestResourceInfo,\n\t\tscope: ScopedLogger | undefined,\n\t): Promise<WorkItem | undefined> {\n\t\tconst encodedProject = encodeAzurePathSegment(project);\n\t\tconst encodedId = encodeAzurePathSegment(id);\n\t\tconst projectPath = resource.projectScoped ? `/${encodedProject}` : '';\n\t\treturn this.request<WorkItem>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`${encodeAzurePathSegment(owner)}${projectPath}/_apis/wit/workItems/${encodedId}?api-version=${resource.apiVersion}`,\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t);\n\t}\n\n\tprivate async requireWorkItemProject(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\towner: string,\n\t\tproject: string,\n\t\tworkItem: WorkItem,\n\t\tbaseUrl: string,\n\t\tscope: ScopedLogger | undefined,\n\t): Promise<void> {\n\t\tconst actualProject = workItem.fields?.['System.TeamProject'];\n\t\tif (typeof actualProject !== 'string' || !actualProject.trim()) {\n\t\t\tthrow new Error(`Azure DevOps work item ${workItem.id} has no project`);\n\t\t}\n\n\t\tif (actualProject.toLowerCase() === project.toLowerCase()) return;\n\n\t\tconst canonical = await this.request<{ name: string }>(\n\t\t\tprovider,\n\t\t\ttoken,\n\t\t\tbaseUrl,\n\t\t\t`${encodeAzurePathSegment(owner)}/_apis/projects/${encodeAzurePathSegment(project)}`,\n\t\t\t{ method: 'GET' },\n\t\t\tscope,\n\t\t);\n\t\tif (canonical?.name?.toLowerCase() !== actualProject.toLowerCase()) {\n\t\t\tthrow new Error(`Azure DevOps work item ${workItem.id} is outside the requested project`);\n\t\t}\n\t}\n\n\tprivate async getWorkItemHtmlFields(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tnamespace: string,\n\t\tbaseUrl: string,\n\t\tfields: WorkItem['fields'],\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<readonly AzureWorkItemHtmlField[]> {\n\t\ttry {\n\t\t\tconst requestToken = { ...token };\n\t\t\treturn await this._workItemDescriptions.getFields(\n\t\t\t\tfields,\n\t\t\t\t{ baseUrl: baseUrl, namespace: namespace, token: requestToken.accessToken, isPAT: true },\n\t\t\t\tasync signal => {\n\t\t\t\t\tconst resource = await this.requireRestResource(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\trequestToken,\n\t\t\t\t\t\tnamespace,\n\t\t\t\t\t\tbaseUrl,\n\t\t\t\t\t\t'fields',\n\t\t\t\t\t\t'6.0',\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t\treturn this.request(\n\t\t\t\t\t\tprovider,\n\t\t\t\t\t\trequestToken,\n\t\t\t\t\t\tbaseUrl,\n\t\t\t\t\t\t`${encodeAzurePathSegment(namespace)}/_apis/wit/fields?api-version=${resource.apiVersion}`,\n\t\t\t\t\t\t{ method: 'GET' },\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t} catch (ex) {\n\t\t\tif (isCancellationError(ex) && cancellation?.aborted) throw ex;\n\n\t\t\tscope?.warn(`Unable to read the Azure DevOps field catalog of '${namespace}': ${ex}`);\n\t\t\treturn [];\n\t\t}\n\t}\n\n\tprivate async getRestResource(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tnamespace: string,\n\t\tbaseUrl: string,\n\t\tresource: AzureDevOpsRestResource,\n\t\tversion: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureDevOpsRestResourceInfo | undefined> {\n\t\ttry {\n\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\tencodeAzurePathSegment(namespace);\n\t\t\tconst discovery = this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () =>\n\t\t\t\tthis.restApi.getRestApiResource(\n\t\t\t\t\t{ namespace: namespace, resource: resource, version: version },\n\t\t\t\t\t{ token: token.accessToken, isPAT: true, baseUrl: baseUrl },\n\t\t\t\t),\n\t\t\t);\n\t\t\tif (cancellation?.aborted) {\n\t\t\t\t// The race skips observing discovery when setup aborts its caller synchronously.\n\t\t\t\tvoid discovery.catch(() => {});\n\t\t\t}\n\n\t\t\treturn await (cancellation != null ? raceWithSignal(discovery, cancellation) : discovery);\n\t\t} catch (ex) {\n\t\t\treturn throwProviderError(token, ex);\n\t\t}\n\t}\n\n\tprivate async requireRestResource(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tnamespace: string,\n\t\tbaseUrl: string,\n\t\tresource: AzureDevOpsRestResource,\n\t\tversion: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<AzureDevOpsRestResourceInfo> {\n\t\tlet result: AzureDevOpsRestResourceInfo | undefined;\n\t\ttry {\n\t\t\tresult = await this.getRestResource(provider, token, namespace, baseUrl, resource, version, cancellation);\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof RequestNotFoundError) {\n\t\t\t\tthrow new Error('Azure DevOps REST resource discovery failed', { cause: ex });\n\t\t\t}\n\n\t\t\tthrow ex;\n\t\t}\n\t\tif (result == null) throw new Error(`Azure DevOps REST resource ${resource} is unavailable`);\n\n\t\treturn result;\n\t}\n\n\tprivate async request<T>(\n\t\tprovider: Provider,\n\t\ttoken: TokenWithInfo,\n\t\tbaseUrl: string | undefined,\n\t\troute: string,\n\t\toptions: { method: RequestInit['method'] } & Record<string, unknown>,\n\t\tscope: ScopedLogger | undefined,\n\t\tcancellation?: AbortSignal | undefined,\n\t): Promise<T | undefined> {\n\t\tconst { accessToken } = token;\n\t\tconst url = baseUrl ? `${baseUrl}/${route}` : route;\n\n\t\tlet rsp: Response;\n\t\ttry {\n\t\t\tconst sw = maybeStopWatch(`[AZURE] ${options?.method ?? 'GET'} request`, { log: { onlyExit: true } });\n\n\t\t\ttry {\n\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\trsp = await this.config.wrapForForcedInsecureSSL(provider.getIgnoreSSLErrors(), () =>\n\t\t\t\t\tthis.config.fetch(url, {\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\tAuthorization: `Basic ${base64(`PAT:${accessToken}`)}`,\n\t\t\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsignal: cancellation,\n\t\t\t\t\t\t...options,\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tif (rsp.ok) {\n\t\t\t\t\t// Azure answers a rejected credential by redirecting to its sign-in page, which returns `203\n\t\t\t\t\t// text/html` rather than `401`. `rsp.ok` spans 200-299, so that page used to reach `json()` and\n\t\t\t\t\t// die as a bare `SyntaxError` — which `getIssue` and friends catch and report as \"not found\",\n\t\t\t\t\t// making an invalid credential indistinguishable from a missing work item (GKDEV-3617).\n\t\t\t\t\tconst contentType = rsp.headers.get('content-type')?.toLowerCase() ?? '';\n\t\t\t\t\tif (contentType.startsWith('text/html')) {\n\t\t\t\t\t\tconst { accessToken: _accessToken, ...tokenInfo } = token;\n\t\t\t\t\t\tthrow new AuthenticationError(\n\t\t\t\t\t\t\ttokenInfo,\n\t\t\t\t\t\t\tAuthenticationErrorReason.Unauthorized,\n\t\t\t\t\t\t\tnew Error(`(${rsp.status}) Azure DevOps returned a sign-in page instead of data`),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (await rsp.json()) as T;\n\t\t\t\t}\n\n\t\t\t\t// Reads the body so the 403 branch below can tell a throttled request from a permission failure.\n\t\t\t\tthrow await ProviderFetchError.fromResponse('AzureDevOps', rsp);\n\t\t\t} finally {\n\t\t\t\tsw?.stop();\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (ex instanceof ProviderFetchError || ex.name === 'AbortError') {\n\t\t\t\tthis.handleRequestError(provider, token, ex, scope);\n\t\t\t} else if (Logger.isDebugging) {\n\t\t\t\tthis.config.onError?.(`AzureDevOps request failed: ${ex.message}`);\n\t\t\t}\n\n\t\t\tthrow ex;\n\t\t}\n\t}\n\n\tprivate handleRequestError(\n\t\tprovider: Provider | undefined,\n\t\ttoken: TokenWithInfo,\n\t\tex: ProviderFetchError | (Error & { name: 'AbortError' }),\n\t\tscope: ScopedLogger | undefined,\n\t): void {\n\t\tif (ex.name === 'AbortError' || !(ex instanceof ProviderFetchError)) throw new CancellationError(ex);\n\n\t\tconst { accessToken, ...tokenInfo } = token;\n\t\tswitch (ex.status) {\n\t\t\tcase 404: // Not found\n\t\t\tcase 410: // Gone\n\t\t\tcase 422: // Unprocessable Entity\n\t\t\t\tthrow new RequestNotFoundError(ex);\n\t\t\tcase 401: // Unauthorized\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Unauthorized, ex);\n\t\t\tcase 429: // Too Many Requests\n\t\t\t\tthrow toRateLimitError(ex, accessToken);\n\t\t\tcase 403: // Forbidden\n\t\t\t\t// Azure returns 403 for both a permission failure and a throttled request (\"Request was blocked\n\t\t\t\t// due to exceeding usage of resource 'RateLimit'\"), so the message is the discriminant. Reporting\n\t\t\t\t// a throttle as `auth` would prompt the user to re-authenticate a healthy connection instead of\n\t\t\t\t// retrying (see `isRateLimitResponse`).\n\t\t\t\tif (isRateLimitResponse(ex)) throw toRateLimitError(ex, accessToken);\n\n\t\t\t\tthrow new AuthenticationError(tokenInfo, AuthenticationErrorReason.Forbidden, ex);\n\t\t\tcase 500: // Internal Server Error\n\t\t\t\tscope?.error(ex);\n\t\t\t\tif (ex.response != null) {\n\t\t\t\t\tthis.config.onRequestFailed?.(\n\t\t\t\t\t\tprovider == null || provider.id === 'azure'\n\t\t\t\t\t\t\t? l10n.t(\n\t\t\t\t\t\t\t\t\t'{0} failed to respond and might be experiencing issues. Please visit the [AzureDevOps status page](https://status.dev.azure.com) for more information.',\n\t\t\t\t\t\t\t\t\tprovider?.name ?? 'AzureDevOps',\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: l10n.t('{0} failed to respond and might be experiencing issues.', provider.name),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\tcase 502: // Bad Gateway\n\t\t\t\tscope?.error(ex);\n\t\t\t\t// TODO: Learn the Azure API docs and put it in order:\n\t\t\t\t// if (ex.message.includes('timeout')) {\n\t\t\t\t// \tprovider?.trackRequestException();\n\t\t\t\t// \tvoid showIntegrationRequestTimedOutWarningMessage(provider?.name ?? 'Azure');\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (ex.status >= 400 && ex.status < 500) throw new RequestClientError(ex);\n\t\t\t\tbreak;\n\t\t}\n\n\t\tscope?.error(ex);\n\t\tif (Logger.isDebugging) {\n\t\t\tthis.config.onError?.(\n\t\t\t\t`AzureDevOps request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** Wires an {@link AzureDevOpsApi} from the full runtime context, mapping `ctx` down to the narrow config. */\nexport function createAzureDevOpsApi(\n\tctx: IntegrationServiceContext,\n\tworkItemStates?: AzureWorkItemStatesCache,\n\tworkItemDescriptions?: AzureWorkItemDescriptionsCache,\n): AzureDevOpsApi {\n\treturn new AzureDevOpsApi(baseProviderApiConfig(ctx), workItemStates, workItemDescriptions);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyFA,MAAM,4BAA4B;AAClC,MAAM,8BAA8B;;AAEpC,MAAM,4BAA4B;AAClC,MAAM,+BAA+B;;AAUrC,SAAS,uBAAuB,IAAsB;CACrD,OAAO,cAAc,sBAAsB,GAAG,QAAQ,SAAS,UAAU;AAC1E;AAEA,SAAS,+BAA+B,MAAyD;CAChG,MAAM,QAAQ,KAAK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M,UAAU;CACxB;AACV,GACD,CAAC,CAAA,GAAA,eAAA,WAAA,0BAAA,IAAA;AAgIA,WAAA,CAAA,MAAM,EACN,OAAO,UAAU,OAAO,OAAO,UAAU;CACxC,UAAU,SAAS;CACnB,OAAO,UAAU,MAAM,UAAU;CAC1B;CACD;AACP,GACD,CAAC,CAAA,GAAA,eAAA,WAAA,yBAAA,IAAA;AA8DA,WAAA,CAAA,MAAM,EACN,OAAO,UAAU,OAAO,OAAO,UAAU;CACxC,UAAU,SAAS;CACnB,OAAO,UAAU,MAAM,UAAU;CAC1B;CACD;AACP,GACD,CAAC,CAAA,GAAA,eAAA,WAAA,oBAAA,IAAA;AA2EA,WAAA,CAAA,MAAM,EACN,OAAO,UAAU,OAAO,gBAAgB;CACvC,UAAU,SAAS;CACnB,OAAO,UAAU,MAAM,UAAU;CACrB;AACb,GACD,CAAC,CAAA,GAAA,eAAA,WAAA,uBAAA,IAAA;AAiLA,WAAA,CAAA,MAAM,EACN,OAAO,UAAU,OAAO,gBAAgB;CACvC,UAAU,SAAS;CACnB,OAAO,UAAU,MAAM,UAAU;CACrB;AACb,GACD,CAAC,CAAA,GAAA,eAAA,WAAA,kBAAA,IAAA;;AA6lBF,SAAgB,qBACf,KACA,gBACA,sBACiB;CACjB,OAAO,IAAI,eAAe,sBAAsB,GAAG,GAAG,gBAAgB,oBAAoB;AAC3F"}
@@ -341,9 +341,11 @@ export interface AzureForkRepositoryUrls {
341
341
  * them. The required `forkRepositoryUrls` argument makes each call site resolve the best-effort fork URLs explicitly.
342
342
  */
343
343
  export declare function fromAzurePullRequest(pr: AzurePullRequest, provider: Provider, owner: string, baseUrl: string, forkRepositoryUrls: AzureForkRepositoryUrls | undefined, projection?: PullRequestProjection): PullRequest;
344
- export declare function fromAzureWorkItem(workItem: WorkItem, provider: Provider, project: AzureProjectDescriptor, stateCategory?: AzureWorkItemStateCategory, projection?: IssueProjection, htmlFields?: readonly AzureWorkItemHtmlField[], viewer?: {
344
+ export declare function fromAzureWorkItem(workItem: WorkItem, provider: Provider, project: AzureProjectDescriptor, stateCategory?: AzureWorkItemStateCategory, projection?: IssueProjection, htmlFields?: readonly AzureWorkItemHtmlField[],
345
+ /** As `toIssueShape` takes it: `null` where the read couldn't resolve it. */
346
+ viewer?: {
345
347
  id: string;
346
- }): Issue$1;
348
+ } | null): Issue$1;
347
349
  /**
348
350
  * A work item as `GET …/_apis/wit/workitems/{id}?$expand=Links` returns it. Loosely typed because
349
351
  * {@link fromAzureWorkItemToProviderIssue} checks every field it reads, as provider-apis does.
@@ -2,7 +2,7 @@ import { Issue as Issue$1 } from "../../../../git/models/issue.js";
2
2
  import { PullRequest } from "../../../../git/models/pullRequest.js";
3
3
  import { isTerminalIssueStateCategory } from "../../../../git/utils/issue.utils.js";
4
4
  import { decideProviderReviewDecision, fromPullRequestReviewDecision, toCompletedReviews, toReviewRequests } from "../pullRequestReviews.js";
5
- import { GitPullRequestMergeableState as GitPullRequestMergeableState$1, GitPullRequestReviewState as GitPullRequestReviewState$1, GitPullRequestState as GitPullRequestState$1, fromProviderPullRequestMergeableState, fromProviderPullRequestState, issueNamesPeople, toIssueBodyField } from "../models.js";
5
+ import { GitPullRequestMergeableState as GitPullRequestMergeableState$1, GitPullRequestReviewState as GitPullRequestReviewState$1, GitPullRequestState as GitPullRequestState$1, fromProviderPullRequestMergeableState, fromProviderPullRequestState, toIssueBodyField, toIssueViewer } from "../models.js";
6
6
  import { pullRequestRevision } from "../../models/integration.js";
7
7
  import { getAzureWorkItemDescription } from "@gitkraken/provider-apis";
8
8
  //#region ../plus/integrations/src/providers/azure/models.ts
@@ -255,13 +255,14 @@ function fromAzureWorkItem(workItem, provider, project, stateCategory, projectio
255
255
  const author = fromAzureWorkItemUserToMember(workItem.fields["System.CreatedBy"]);
256
256
  const assignee = fromAzureWorkItemUserToMember(workItem.fields["System.AssignedTo"]);
257
257
  const assignees = assignee != null ? [assignee] : [];
258
+ const viewerFields = toIssueViewer({
259
+ author,
260
+ assignees
261
+ }, viewer);
258
262
  return new Issue$1(provider, workItem.id.toString(), workItem.id.toString(), workItem.fields["System.Title"], workItem._links.html.href, new Date(workItem.fields["System.CreatedDate"]), new Date(workItem.fields["System.ChangedDate"]), normalizedState === "closed", normalizedState, author, assignees, void 0, closedDate, void 0, workItem.fields["System.CommentCount"], void 0, description?.value, project, void 0, workItem.fields["System.WorkItemType"], typeof state === "string" && state ? {
259
263
  name: state,
260
264
  category: azureIssueStateCategory(stateCategory)
261
- } : void 0, void 0, toWorkItemIterations(workItem.fields["System.IterationPath"]), projection, description != null ? toIssueBodyField(description.field) : void 0, issueNamesPeople({
262
- author,
263
- assignees
264
- }) ? viewer : void 0);
265
+ } : void 0, void 0, toWorkItemIterations(workItem.fields["System.IterationPath"]), projection, description != null ? toIssueBodyField(description.field) : void 0, viewerFields?.viewer, viewerFields?.viewerUnresolved);
265
266
  }
266
267
  /**
267
268
  * Azure reports the iteration as a backslash-delimited path rooted at the project. The project root is its default