@gitkraken/core-gitlens 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -1
- package/dist/plus/integrations/authentication/cloudIntegrationService.js +24 -7
- package/dist/plus/integrations/authentication/cloudIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +40 -27
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +92 -22
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts +7 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +22 -8
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/integrationService.js +6 -3
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/models/gitHostIntegration.js +38 -36
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +71 -7
- package/dist/plus/integrations/models/integration.js +201 -55
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issuesIntegration.js +9 -9
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.js +1 -1
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.js +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket-server.js +1 -1
- package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket.js +1 -1
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/github.js +3 -6
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab.js +1 -1
- package/dist/plus/integrations/providers/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/jira.js +1 -0
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.js +1 -0
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitlab.js","names":[],"sources":["../../../../../plus/integrations/src/providers/gitlab.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure } from '@gitkraken/provider-apis';\nimport * as l10n from '@vscode/l10n';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestMergeMethod,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport type { RepositoryDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport type { Emitter } from '@gitlens/utils/event.js';\nimport { uniqueBy } from '@gitlens/utils/iterable.js';\nimport { batch, mapSettledBounded } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';\nimport type { ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport { IntegrationReadUnavailableError } from '../errors.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport type { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from '../models/gitHostIntegration.js';\nimport { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type {\n\tAccountWideIssuesResult,\n\tIssueEtagFields,\n\tIssueEtagInclude,\n\tPullRequestEtagFields,\n\tPullRequestEtagInclude,\n\tSearchMyIssuesOptions,\n} from '../models/integration.js';\nimport type { GitLabIntegrationIds } from './gitlab/gitlab.utils.js';\nimport { getGitLabPullRequestIdentityFromMaybeUrl, matchesGitLabOrgNamespace } from './gitlab/gitlab.utils.js';\nimport {\n\tfromGitLabMergeRequestProvidersApi,\n\tgitLabEtagFieldsMaxIids,\n\tgitLabEtagFieldsWithChecksMaxIids,\n\ttoGitLabIssueEtagFields,\n\ttoGitLabPullRequestEtagFields,\n} from './gitlab/models.js';\nimport type {\n\tProviderApiPagedResult,\n\tProviderHierarchyResult,\n\tProviderOrganization,\n\tProviderPullRequest,\n\tProviderRepository,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tgetProviderPullRequestIdentity,\n\tIssueFilter,\n\tProviderPullRequestReviewState,\n\tprovidersMetadata,\n\tPullRequestFilter,\n\ttoIssueShape,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport type { ProvidersApi } from './providersApi.js';\nimport {\n\tcollectProviderPagedResult,\n\tmergeCollectionMetadata,\n\treadEtagFieldsByRepository,\n\tresolveBranchPullRequests,\n} from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[GitCloudHostIntegrationId.GitLab];\nconst authProvider: IntegrationAuthenticationProviderDescriptor = Object.freeze({\n\tid: metadata.id,\n\tscopes: metadata.scopes,\n});\n\nconst cloudEnterpriseMetadata = providersMetadata[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted];\nconst cloudEnterpriseAuthProvider: IntegrationAuthenticationProviderDescriptor = Object.freeze({\n\tid: cloudEnterpriseMetadata.id,\n\tscopes: cloudEnterpriseMetadata.scopes,\n});\n\ntype GitLabPullRequestAssociation = 'assigned' | 'authored' | 'reviewRequested';\ntype GitLabPullRequestFacetCursor = Partial<Record<GitLabPullRequestAssociation, string>>;\n\n/**\n * The account-wide relationships GitLab can express, and the `scope` each maps to. `undefined` means GitLab has\n * no equivalent axis (it has neither `Mention` nor `reviewed-by`), and this map is the single declaration of\n * that. Exhaustive over `PullRequestFilter` on purpose: a new member must be decided for GitLab here rather\n * than compiling through as silently unsupported. Exported for the advertised-vs-expressible capability test,\n * which is what keeps it agreeing with `supportedAccountWidePullRequestFilters`; no runtime consumer imports it.\n */\nexport const gitLabAssociationForFilter: Record<PullRequestFilter, GitLabPullRequestAssociation | undefined> = {\n\t[PullRequestFilter.Assignee]: 'assigned',\n\t[PullRequestFilter.Author]: 'authored',\n\t[PullRequestFilter.ReviewRequested]: 'reviewRequested',\n\t[PullRequestFilter.Reviewed]: undefined,\n\t[PullRequestFilter.Mention]: undefined,\n};\n\nfunction parseGitLabPullRequestFacetCursor(cursor: string | undefined): GitLabPullRequestFacetCursor {\n\tif (!cursor) return {};\n\n\ttry {\n\t\tconst parsed = JSON.parse(cursor) as { type?: unknown; cursors?: unknown };\n\t\tif (parsed.type !== 'gitlab-associations' || parsed.cursors == null || typeof parsed.cursors !== 'object') {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst cursors = parsed.cursors as Record<string, unknown>;\n\t\treturn Object.fromEntries(\n\t\t\t(['assigned', 'authored', 'reviewRequested'] as const)\n\t\t\t\t.filter(association => typeof cursors[association] === 'string' && cursors[association] !== '')\n\t\t\t\t.map(association => [association, cursors[association] as string]),\n\t\t);\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nexport type GitLabRepositoryDescriptor = RepositoryDescriptor;\n\n/** How many SSH signing-key lookups (account resolve + keys fetch) to run concurrently, to avoid a request burst. */\nconst sshSigningKeyResolveBatchSize = 10;\n\nabstract class GitLabIntegrationBase<ID extends GitLabIntegrationIds> extends GitHostIntegration<\n\tID,\n\tGitLabRepositoryDescriptor\n> {\n\tprotected abstract apiBaseUrlFor(session: ProviderAuthenticationSession): string;\n\n\t/** The installation base the PAT-based reads take on self-hosted GitLab; gitlab.com passes none. */\n\tprotected enterpriseBaseUrlFor(session: ProviderAuthenticationSession): string | undefined {\n\t\treturn this.isEnterprise ? this.getSelfManagedApiBaseUrl(session) : undefined;\n\t}\n\n\t/** Self-hosted GitLab uses PAT semantics and a domain-based API base; gitlab.com does not. */\n\tprotected get isEnterprise(): boolean {\n\t\treturn this.id === GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;\n\t}\n\n\tprotected override async getProviderAccountForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getAccountForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderAccountForEmail(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\temail: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getAccountForEmail(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\temail,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderSshSigningKeysForEmails(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\temails: string[],\n\t): Promise<Map<string, string[]>> {\n\t\tconst result = new Map<string, string[]>();\n\n\t\tconst api = await this.authenticationService.apis.gitlab;\n\t\tif (api == null) return result;\n\n\t\tconst token = toTokenWithInfo(this.id, session);\n\n\t\t// GitLab resolves users one email at a time (no batch search). Run them in bounded batches rather than firing all\n\t\t// (up to providerVerifyLimit) account + key lookups at once, to avoid a request burst that trips rate limiting.\n\t\tawait batch(emails, sshSigningKeyResolveBatchSize, async email => {\n\t\t\tconst account = await this.getProviderAccountForEmail(session, repo, email);\n\t\t\tif (account?.id == null) return;\n\n\t\t\tconst keys = await api.getUserSigningKeys(this, token, account.id, {\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t});\n\t\t\tresult.set(\n\t\t\t\temail.toLowerCase(),\n\t\t\t\tkeys.map(k => k.key),\n\t\t\t);\n\t\t});\n\n\t\treturn result;\n\t}\n\n\tprotected override async getProviderDefaultBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t): Promise<DefaultBranch | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getDefaultBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\t{ id }: { id: string; key: string },\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getIssueOrPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tNumber(id),\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\tconst api = await this.authenticationService.apis.gitlab;\n\t\tconst providerApi = await this.getProvidersApi();\n\t\tif (!api || !repo || !id) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst repoId = await api.getProjectId(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tundefined,\n\t\t);\n\t\tif (!repoId) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst apiResult = await providerApi.getIssue(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t{ namespace: repo.owner, name: repo.name, number: id },\n\t\t\t{\n\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t\tconst issue = apiResult != null ? toIssueShape(apiResult, this, { projection: 'point' }) : undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\tprotected override async getProviderPullRequestForBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\tbranch: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t\tinclude?: PullRequestState[];\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst { include, ...opts } = options ?? {};\n\n\t\tconst toGitLabMergeRequestState = (await import(/* webpackChunkName: \"integrations\" */ './gitlab/models.js'))\n\t\t\t.toGitLabMergeRequestState;\n\t\treturn (await this.authenticationService.apis.gitlab)?.getPullRequestForBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tbranch,\n\t\t\t{\n\t\t\t\t...opts,\n\t\t\t\tinclude: include?.map(s => toGitLabMergeRequestState(s)),\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\trev: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getPullRequestForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: GitLabRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tresource.owner,\n\t\t\tresource.name,\n\t\t\tparseInt(id, 10),\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot; through the\n\t * SDK's issue read and the conversion the repo-scoped list rows take. GitLens' own GitLab client can't alias\n\t * the read instead: it fails a whole document on any GraphQL error, where a batch needs per-target errors.\n\t */\n\tprotected override async getProviderIssuesBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<IssueShape | undefined>[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst baseUrl = this.enterpriseBaseUrlFor(session);\n\t\t// The confirming read must ask the same host, over the same protocol, as the read it confirms.\n\t\tconst confirmBaseUrl = this.apiBaseUrlFor(session);\n\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, async c => {\n\t\t\tconst issue = await api.getIssueForRepo(tokenWithInfo, { namespace: c.owner, name: c.repo }, c.number, {\n\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\tbaseUrl: baseUrl,\n\t\t\t});\n\t\t\tif (issue != null) {\n\t\t\t\tconst shape = toIssueShape(issue, this, { projection: 'batch' });\n\t\t\t\tif (shape == null) throw new Error(`GitLab returned issue ${c.number} without a URL or update time`);\n\n\t\t\t\treturn shape;\n\t\t\t}\n\n\t\t\t// provider-apis' \"not found\" can come from a reply carrying only GraphQL errors (see `getIssueForRepo`),\n\t\t\t// so only our own strict read can prove the miss.\n\t\t\tconst gitlab = await this.authenticationService.apis.gitlab;\n\t\t\tif (gitlab == null) {\n\t\t\t\tthrow new IntegrationReadUnavailableError(this.name, 'cannot confirm a missing issue');\n\t\t\t}\n\n\t\t\tconst exists = await gitlab.hasIssue(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tc.owner,\n\t\t\t\tc.repo,\n\t\t\t\tc.number,\n\t\t\t\t{ baseUrl: confirmBaseUrl, deferFailure: true },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\t// Our own query can't produce the list rows' shape, so a disagreement fails rather than answering thinner.\n\t\t\tif (exists) throw new Error(`GitLab reported issue ${c.number} missing, then found it`);\n\n\t\t\treturn undefined;\n\t\t});\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot; through\n\t * the same SDK read and conversion the manager's list rows take.\n\t */\n\tprotected override async getProviderPullRequestsBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string } } | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst baseUrl = this.enterpriseBaseUrlFor(session);\n\t\t// The confirming read must ask the same host, over the same protocol, as the read it confirms.\n\t\tconst confirmBaseUrl = this.apiBaseUrlFor(session);\n\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, async c => {\n\t\t\tconst pr = await api.getPullRequestForRepo(tokenWithInfo, { namespace: c.owner, name: c.repo }, c.number, {\n\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\tbaseUrl: baseUrl,\n\t\t\t});\n\t\t\tif (pr != null) {\n\t\t\t\treturn fromProviderPullRequest(pr, this, {\n\t\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\t\tprojection: 'batch',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// provider-apis' GitLab GraphQL helper ignores the response's `errors`, so a reply carrying only errors\n\t\t\t// (e.g. a server-side timeout) comes back as `null`, the same as not-found. Our own client throws on\n\t\t\t// `errors`, and `strict` makes it answer `undefined` only for a real miss.\n\t\t\tconst gitlab = await this.authenticationService.apis.gitlab;\n\t\t\tif (gitlab == null) {\n\t\t\t\tthrow new IntegrationReadUnavailableError(this.name, 'cannot confirm a missing merge request');\n\t\t\t}\n\n\t\t\tconst confirmed = await gitlab.getPullRequest(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tc.owner,\n\t\t\t\tc.repo,\n\t\t\t\tc.number,\n\t\t\t\t{ baseUrl: confirmBaseUrl, strict: true, deferFailure: true },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\t// Our own client's row can't produce the list rows' shape (`id` is the iid, not the global id; no\n\t\t\t// `authoredByMe`), so a disagreement fails rather than answering with a different identity.\n\t\t\tif (confirmed != null) throw new Error(`GitLab reported pull request ${c.number} missing, then found it`);\n\n\t\t\treturn undefined;\n\t\t});\n\t}\n\n\t/**\n\t * The cheap check behind the batch issue read's etags: GitLens' own GitLab client reads each project's issues by\n\t * iid, up to {@link gitLabEtagFieldsMaxIids} in ONE request, where {@link getProviderIssuesBatch} sends one or\n\t * two per target. Each row is converted as provider-apis and `toIssueShape` convert the full one, so both reads\n\t * compute the same etag, and `'reactions'` adds the upvote count the full row's `thumbsUpCount` comes from. A\n\t * request that throws rejects only its own targets' slots.\n\t */\n\tprotected override async getProviderIssuesEtagFields(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { etagIncludes?: readonly IssueEtagInclude[] },\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<IssueEtagFields | undefined>[] | undefined> {\n\t\tconst gitlab = await this.authenticationService.apis.gitlab;\n\t\tif (gitlab == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\t// The host and protocol the full read's confirming read asks.\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\t\tconst etagIncludes = options.etagIncludes ?? [];\n\n\t\treturn readEtagFieldsByRepository(\n\t\t\tcoordinates,\n\t\t\tgitLabEtagFieldsMaxIids,\n\t\t\t(owner, repo, iids) =>\n\t\t\t\tgitlab.getIssuesEtagFields(\n\t\t\t\t\tthis,\n\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\t`${owner}/${repo}`,\n\t\t\t\t\tiids,\n\t\t\t\t\t{ baseUrl: baseUrl, etagIncludes: etagIncludes, deferFailure: true },\n\t\t\t\t\tcancellation,\n\t\t\t\t),\n\t\t\tnode => toGitLabIssueEtagFields(node, etagIncludes),\n\t\t);\n\t}\n\n\t/**\n\t * The cheap check behind the batch pull request read's etags: {@link getProviderIssuesEtagFields}'s requests and\n\t * failure isolation over merge requests, selecting a merge request's change state plus the fields of each of\n\t * `options.etagIncludes`. Every include is meaningful here: a full row carries a mergeability, a review decision\n\t * and a check rollup, each of which can change without moving `updatedAt`.\n\t */\n\tprotected override async getProviderPullRequestsEtagFields(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { etagIncludes?: readonly PullRequestEtagInclude[] },\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestEtagFields | undefined>[] | undefined> {\n\t\tconst gitlab = await this.authenticationService.apis.gitlab;\n\t\tif (gitlab == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\t// The host and protocol the full read's confirming read asks.\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\t\tconst etagIncludes = options.etagIncludes ?? [];\n\n\t\treturn readEtagFieldsByRepository(\n\t\t\tcoordinates,\n\t\t\tetagIncludes.includes('checks') ? gitLabEtagFieldsWithChecksMaxIids : gitLabEtagFieldsMaxIids,\n\t\t\t(owner, repo, iids) =>\n\t\t\t\tgitlab.getMergeRequestsEtagFields(\n\t\t\t\t\tthis,\n\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\t`${owner}/${repo}`,\n\t\t\t\t\tiids,\n\t\t\t\t\t{ baseUrl: baseUrl, etagIncludes: etagIncludes, deferFailure: true },\n\t\t\t\t\tcancellation,\n\t\t\t\t),\n\t\t\tnode => toGitLabPullRequestEtagFields(node, etagIncludes),\n\t\t);\n\t}\n\n\t/**\n\t * Two steps, because provider-apis has no source-branch filter: GitLens' own GitLab client finds each branch's\n\t * matching iids, one request per target, then {@link getProviderPullRequestsBatch} resolves them — so a row is\n\t * the one `getPullRequestsBatch` returns for that merge request, `url` and `authoredByMe` included.\n\t */\n\tprotected override async getProviderPullRequestsForBranches(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { owner: string; repo: string; project?: string; branch: string; headOwner?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string }; limit: number },\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<{ pullRequests: PullRequestShape[]; truncated: boolean }>[] | undefined> {\n\t\tconst gitlab = await this.authenticationService.apis.gitlab;\n\t\tif (gitlab == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\t// The session's own host and protocol, as the batch read's confirming read uses.\n\t\tconst apiBaseUrl = this.apiBaseUrlFor(session);\n\n\t\tconst found = await mapSettledBounded(targets, providerFanOutConcurrency, t =>\n\t\t\tgitlab.getPullRequestNumbersForBranch(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tt.owner,\n\t\t\t\tt.repo,\n\t\t\t\tt.branch,\n\t\t\t\t{ baseUrl: apiBaseUrl, headOwner: t.headOwner, limit: options.limit, deferFailure: true },\n\t\t\t\tcancellation,\n\t\t\t),\n\t\t);\n\t\treturn resolveBranchPullRequests(targets, found, coordinates =>\n\t\t\tthis.getProviderPullRequestsBatch(\n\t\t\t\tsession,\n\t\t\t\tcoordinates,\n\t\t\t\t{ currentAccount: options.currentAccount },\n\t\t\t\tcancellation,\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic override async getRepoInfo(repo: {\n\t\towner: string;\n\t\tname: string;\n\t\tproject?: string;\n\t\tconnectionId?: string;\n\t}): Promise<ProviderRepository | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSession(repo.connectionId, undefined);\n\t\tif (session == null) return undefined;\n\n\t\treturn api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t});\n\t}\n\n\tprotected override async getProviderRepositoryMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getRepositoryMetadata(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async getProviderOrganizationsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderOrganization> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst result = await api.getGitlabGroupsForCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t});\n\t\treturn {\n\t\t\tvalues: result.values.map(g => ({ id: g.id, providerId: this.id, name: g.fullPath, url: g.webUrl })),\n\t\t\t...(result.truncated ? { truncated: true } : {}),\n\t\t\t...(result.metadata != null ? { metadata: result.metadata } : {}),\n\t\t};\n\t}\n\n\t/**\n\t * GitLab has no group-scoped repos endpoint, so each page is a page of the current user's member repos\n\t * across all namespaces, filtered to `org` and its subgroups (mirroring gkcli's `gitlabOrgMatches`).\n\t * Follow `paging.cursor` to page the full list; repos the user isn't a member of aren't returned.\n\t * Because the filter is applied per page, a page can come back with `values: []` while\n\t * `paging.more` is still `true` (e.g. a page full of repos outside `org`) — don't treat an empty\n\t * page as the end of pagination, only `paging.more`/`collectPagedResults` reaching exhaustion.\n\t */\n\tprotected override async getProviderRepositoriesForOrg(\n\t\tsession: ProviderAuthenticationSession,\n\t\torg: string,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst result = await api.getReposForCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\tcursor: options?.cursor,\n\t\t});\n\t\treturn {\n\t\t\tvalues: result.values.filter(r => matchesGitLabOrgNamespace(r.namespace, org)),\n\t\t\t...(result.paging != null ? { paging: result.paging } : {}),\n\t\t};\n\t}\n\n\tprotected override async getProviderRepositoriesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// GitLab's membership read is already user-affiliated, so the account-wide walk is the unfiltered\n\t\t// version of the per-org read above (which pages the same source and filters by namespace).\n\t\treturn api.getReposForCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\tcursor: options?.cursor,\n\t\t});\n\t}\n\n\tprotected override async searchProviderMyPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: GitLabRepositoryDescriptor[],\n\t\t_cancellation?: AbortSignal,\n\t\toptions?: SearchMyPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// Resolve the username from THIS session's token (multi-account: `session` may be a non-primary\n\t\t// connection); `getCurrentAccount()` would use the primary `_session` and filter by the wrong user.\n\t\tconst username = (await this.getProviderCurrentAccount(session))?.username;\n\t\tif (!username) {\n\t\t\treturn Promise.resolve([]);\n\t\t}\n\n\t\tconst apiResult = await api.getPullRequestsForUser(toTokenWithInfo(this.id, session), username, {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\tstates: toProviderPullRequestStates(options?.state),\n\t\t});\n\n\t\tif (apiResult == null) {\n\t\t\treturn Promise.resolve([]);\n\t\t}\n\n\t\t// now I'm going to filter prs from the result according to the repos parameter\n\t\tlet prs;\n\t\tif (repos != null) {\n\t\t\tconst repoMap = new Map<string, GitLabRepositoryDescriptor>();\n\t\t\tfor (const repo of repos) {\n\t\t\t\trepoMap.set(`${repo.owner}/${repo.name}`, repo);\n\t\t\t}\n\t\t\tprs = apiResult.values.filter(pr => {\n\t\t\t\tconst repo = repoMap.get(`${pr.repository.owner.login}/${pr.repository.name}`);\n\t\t\t\treturn repo != null;\n\t\t\t});\n\t\t} else {\n\t\t\tprs = apiResult.values;\n\t\t}\n\n\t\tconst results: IterableIterator<PullRequest> = uniqueBy(\n\t\t\t[\n\t\t\t\t...prs\n\t\t\t\t\t.filter(pr => {\n\t\t\t\t\t\tconst isAssignee = pr.assignees?.some(a => a.username === username);\n\t\t\t\t\t\tconst isRequestedReviewer = pr.reviews?.some(\n\t\t\t\t\t\t\t// Match only reviews assigned to the current user; a bare `state === ReviewRequested`\n\t\t\t\t\t\t\t// check would also match reviews requested from OTHER people, leaking their MRs in.\n\t\t\t\t\t\t\treview =>\n\t\t\t\t\t\t\t\treview.reviewer?.username === username &&\n\t\t\t\t\t\t\t\treview.state === ProviderPullRequestReviewState.ReviewRequested,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst isAuthor = pr.author?.username === username;\n\t\t\t\t\t\t// It seems like GitLab doesn't give us mentioned PRs.\n\t\t\t\t\t\t// const isMentioned = ???;\n\n\t\t\t\t\t\treturn isAssignee || isRequestedReviewer || isAuthor;\n\t\t\t\t\t})\n\t\t\t\t\t.map(pr => fromGitLabMergeRequestProvidersApi(pr, this, 'search')),\n\t\t\t],\n\t\t\tr => r.url,\n\t\t\t(original, _current) => original,\n\t\t);\n\n\t\treturn [...results];\n\t}\n\n\tprotected override async getProviderMyPullRequestsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { state?: PullRequestStateFilter[]; cursor?: string; filters?: PullRequestFilter[] },\n\t): Promise<ProviderApiPagedResult<ProviderPullRequest> | undefined> {\n\t\t// Resolve the username from THIS session's token (multi-account safe) to scope the account-wide read.\n\t\tconst username = (await this.getProviderCurrentAccount(session))?.username;\n\t\tif (username == null) return undefined;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst requested = options?.filters?.length ? new Set(options.filters) : undefined;\n\t\t// The filter contract is all-or-nothing, so refuse as soon as ONE requested member is inexpressible rather\n\t\t// than only when every one is: dropping the rest would answer a narrower question than was asked\n\t\t// (`[Author, Mention]` becoming `authored`). Throw rather than return `undefined`, which the facade reads\n\t\t// as \"no session could be resolved\" and a drain turns into a not-connected warning, misattributing a\n\t\t// refusal; `getMyPullRequestsForUserResult` recovers the throw into `{ error }`. Defense in depth:\n\t\t// `resolveAccountWidePullRequestFilters` already refuses such a set, so only a direct caller of the public\n\t\t// method reaches this.\n\t\tconst unsupported = requested == null ? [] : [...requested].filter(f => gitLabAssociationForFilter[f] == null);\n\t\tif (unsupported.length > 0) {\n\t\t\tthrow new IntegrationReadUnavailableError(\n\t\t\t\tthis.name,\n\t\t\t\t`account-wide pull request filters not expressible by GitLab: ${unsupported.join(', ')}`,\n\t\t\t);\n\t\t}\n\n\t\tconst associations: GitLabPullRequestAssociation[] =\n\t\t\trequested == null\n\t\t\t\t? ['authored', 'assigned', 'reviewRequested']\n\t\t\t\t: Array.from(requested, f => gitLabAssociationForFilter[f]).filter(a => a != null);\n\n\t\tconst cursors = parseGitLabPullRequestFacetCursor(options?.cursor);\n\t\tconst resumable = associations.filter(association => cursors[association] != null);\n\t\tconst associationsToQuery = options?.cursor != null && resumable.length > 0 ? resumable : associations;\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst settled = await Promise.allSettled(\n\t\t\tassociationsToQuery.map(async association => ({\n\t\t\t\tassociation: association,\n\t\t\t\tresult: await api.getGitLabPullRequestsForUserAssociation(tokenWithInfo, username, association, {\n\t\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\t\t\tstates: toProviderPullRequestStates(options?.state),\n\t\t\t\t\tcursor: cursors[association],\n\t\t\t\t}),\n\t\t\t})),\n\t\t);\n\t\tif (settled.every(outcome => outcome.status === 'rejected')) {\n\t\t\tconst first = settled[0];\n\t\t\tif (first?.status === 'rejected') throw first.reason;\n\t\t}\n\n\t\tconst values = new Map<string, ProviderPullRequest>();\n\t\tconst nextCursors: GitLabPullRequestFacetCursor = {};\n\t\tconst failures: CollectionScopeFailure[] = [];\n\t\tlet aggregateMetadata: CollectionMetadata | undefined;\n\t\tlet truncated = false;\n\t\tlet unkeyedPullRequest = 0;\n\t\tfor (let index = 0; index < settled.length; index++) {\n\t\t\tconst outcome = settled[index];\n\t\t\tconst association = associationsToQuery[index];\n\t\t\tif (outcome == null || association == null) continue;\n\t\t\tif (outcome.status === 'rejected') {\n\t\t\t\tconst failure = toCollectionScopeFailure({ providerId: this.id }, outcome.reason);\n\t\t\t\tfailures.push({\n\t\t\t\t\t...failure,\n\t\t\t\t\tmessage: `GitLab ${association} pull requests could not be read${\n\t\t\t\t\t\tfailure.message != null ? `: ${failure.message}` : ''\n\t\t\t\t\t}`,\n\t\t\t\t});\n\t\t\t\ttruncated = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = outcome.value.result;\n\t\t\taggregateMetadata = mergeCollectionMetadata(aggregateMetadata, result.metadata);\n\t\t\ttruncated ||=\n\t\t\t\tresult.paging?.truncated === true ||\n\t\t\t\t(result.metadata != null && result.metadata.completeness !== 'complete');\n\t\t\tfor (const pr of result.values) {\n\t\t\t\tconst identity = getProviderPullRequestIdentity(pr) ?? `unkeyed:${unkeyedPullRequest++}`;\n\t\t\t\tif (!values.has(identity)) {\n\t\t\t\t\tvalues.set(identity, pr);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (result.paging?.more && result.paging.cursor != null && result.paging.cursor !== '{}') {\n\t\t\t\tnextCursors[association] = result.paging.cursor;\n\t\t\t}\n\t\t}\n\n\t\taggregateMetadata = mergeCollectionMetadata(\n\t\t\taggregateMetadata,\n\t\t\tfailures.length > 0 ? { completeness: 'partial', failures: failures } : undefined,\n\t\t);\n\t\tconst hasMore = Object.keys(nextCursors).length > 0;\n\t\treturn {\n\t\t\tvalues: [...values.values()],\n\t\t\tpaging: {\n\t\t\t\tmore: hasMore,\n\t\t\t\tcursor: hasMore ? JSON.stringify({ type: 'gitlab-associations', cursors: nextCursors }) : '{}',\n\t\t\t\ttruncated: truncated || undefined,\n\t\t\t},\n\t\t\t...(aggregateMetadata != null ? { metadata: aggregateMetadata } : {}),\n\t\t};\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: GitLabRepositoryDescriptor[],\n\t): Promise<IssueShape[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.gitlab;\n\t\tconst providerApi = await this.getProvidersApi();\n\t\tif (!api || !repos) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst repoIdsResult = await Promise.allSettled(\n\t\t\trepos.map((r: GitLabRepositoryDescriptor): Promise<string | undefined> =>\n\t\t\t\tapi.getProjectId(\n\t\t\t\t\tthis,\n\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\tr.owner,\n\t\t\t\t\tr.name,\n\t\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t\t\tundefined,\n\t\t\t\t),\n\t\t\t) ?? [],\n\t\t);\n\t\tconst repoInput = repoIdsResult\n\t\t\t.map(result => (result.status === 'fulfilled' ? result.value : undefined))\n\t\t\t.filter((r): r is string => r != null);\n\t\tconst apiResult = await providerApi.getIssuesForRepos(toTokenWithInfo(this.id, session), repoInput, {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t});\n\n\t\treturn apiResult.values\n\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'account' }))\n\t\t\t.filter((result): result is IssueShape => result != null);\n\t}\n\n\t/**\n\t * Account-wide \"my issues\" for GitLab. GitLab's repo-scoped issue read bails without repos, and GitLab has\n\t * no GraphQL cross-project issue field, so this goes through the SDK's REST `GET /issues` read\n\t * ({@link ProvidersApi.getIssuesForCurrentUser}). Open issues only (matching GitHub's baked `is:open`).\n\t *\n\t * Default scope is the current user's assigned issues; `includeAllAssignees` broadens to `scope=all` (every\n\t * visible issue, any assignee). The read is numbered-paged, so each page is drained to exhaustion, bounded by\n\t * a defensive backstop — a hit backstop is reported as `truncated` so the facade surfaces an incomplete read\n\t * rather than publishing a partial list as complete.\n\t *\n\t * `options.filters` selects which relationships to read: `Assignee` (the default when omitted) and `Author`,\n\t * each its own drain, unioned by url — see the comment on `passes` for why they can't be one request. Mention\n\t * is absent because GitLab's REST read exposes no first-class mention filter, and approximating it via `search`\n\t * would return a different set than asked for; the facade refuses it\n\t * (see `ProviderMetadata.supportedAccountWideIssueFilters`).\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resources?: GitLabRepositoryDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst api = await this.getProvidersApi();\n\n\t\t// Resolve the username from THIS session's token (multi-account safe), matching the PR account-wide read.\n\t\t// Only needed to scope the default (assigned-to-me) read; the all-assignees broaden drops it.\n\t\tconst username = options?.includeAllAssignees\n\t\t\t? undefined\n\t\t\t: (await this.getProviderCurrentAccount(session))?.username;\n\t\tif (!options?.includeAllAssignees && username == null) return undefined;\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst baseUrl = this.enterpriseBaseUrlFor(session);\n\t\tconst maxPages = 20;\n\t\t// Dedupe by `url`, not `IssueShape.id`: for GitLab `id` is the per-project `iid`, which collides across\n\t\t// projects in an account-wide read (two repos both have issue `#1`), so an id-keyed map would silently\n\t\t// drop distinct issues. `url` is globally unique. Matches the GitHub/GitLab account-wide PR reads.\n\t\tconst issuesByUrl = new Map<string, IssueShape>();\n\t\tlet truncated = false;\n\t\tlet collectionMetadata: CollectionMetadata | undefined;\n\n\t\t// One drain PER requested relationship, unioned by url. The account-wide filter contract is a union\n\t\t// (`authored ∪ assigned`, matching GitHub's three searches and Azure's two drains), and GitLab can express\n\t\t// only one relationship per REST call: `assignee_username` and `author_username` on the same request\n\t\t// compose with AND, so a single combined call would return the intersection — issues the user both opened\n\t\t// and is assigned to — instead of either set. Overlap between the passes is collapsed by the url map.\n\t\tconst passes: { scope: 'assigned_to_me' | 'all'; assigneeUsername?: string; authorUsername?: string }[] = [];\n\t\tif (options?.includeAllAssignees) {\n\t\t\t// Broadens past \"mine\" entirely: every visible issue, any assignee. Contradicts `filters`, which the\n\t\t\t// facade refuses before reaching here.\n\t\t\tpasses.push({ scope: 'all' });\n\t\t} else {\n\t\t\tconst filters = options?.filters;\n\t\t\t// Assignee is this read's default relationship, so it runs unless the caller narrowed to author alone.\n\t\t\tif (filters == null || filters.length === 0 || filters.includes(IssueFilter.Assignee)) {\n\t\t\t\tpasses.push({ scope: 'assigned_to_me', assigneeUsername: username });\n\t\t\t}\n\t\t\t// `scope: 'all'` is required for the author axis: paired with `assigned_to_me` GitLab would intersect\n\t\t\t// the two rather than read authored issues.\n\t\t\tif (filters?.includes(IssueFilter.Author)) {\n\t\t\t\tpasses.push({ scope: 'all', authorUsername: username });\n\t\t\t}\n\t\t}\n\n\t\tfor (const pass of passes) {\n\t\t\tconst result = await collectProviderPagedResult(\n\t\t\t\tasync cursor => {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\tconst page = await api.getIssuesForCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\t\t\t\t...pass,\n\t\t\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\t\t\tbaseUrl: baseUrl,\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tsort: options?.sort,\n\t\t\t\t\t});\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t\t\t\treturn page;\n\t\t\t\t},\n\t\t\t\tmaxPages,\n\t\t\t\t{ providerId: this.id },\n\t\t\t);\n\n\t\t\tfor (const issue of result.values) {\n\t\t\t\tconst shape = toIssueShape(issue, this, { projection: 'account' });\n\t\t\t\tif (shape != null && !issuesByUrl.has(shape.url)) {\n\t\t\t\t\tissuesByUrl.set(shape.url, shape);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttruncated ||= result.truncated === true;\n\t\t\tcollectionMetadata = mergeCollectionMetadata(collectionMetadata, result.metadata);\n\t\t}\n\n\t\treturn {\n\t\t\tvalues: [...issuesByUrl.values()],\n\t\t\ttruncated: truncated,\n\t\t\t...(collectionMetadata != null ? { metadata: collectionMetadata } : {}),\n\t\t};\n\t}\n\n\tprotected override async searchProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tsearchQuery: string,\n\t\trepos?: GitLabRepositoryDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.gitlab;\n\t\tif (!api) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn api.searchPullRequests(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t{\n\t\t\t\tsearch: searchQuery,\n\t\t\t\trepos: repos?.map(r => `${r.owner}/${r.name}`),\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\tinclude: options?.include,\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async mergeProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tpr: PullRequest,\n\t\toptions?: {\n\t\t\tmergeMethod?: PullRequestMergeMethod;\n\t\t},\n\t): Promise<boolean> {\n\t\tif (!this.isPullRequest(pr)) return false;\n\n\t\tconst api = await this.getProvidersApi();\n\t\ttry {\n\t\t\tconst res = await api.mergePullRequest(toTokenWithInfo(this.id, session), pr, {\n\t\t\t\t...options,\n\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\t});\n\t\t\treturn res;\n\t\t} catch (ex) {\n\t\t\tvoid this.showMergeErrorMessage(ex);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate async showMergeErrorMessage(ex: Error) {\n\t\t// Unfortunately, providers-api does not let us know the exact reason for the error,\n\t\t// so we show the same message to everything.\n\t\t// When we update the library, we can improve the error handling here.\n\t\tconst reauthenticate = await this.ctx.hooks?.onReauthenticationRequired?.(\n\t\t\tl10n.t(\n\t\t\t\t\"{0}. Would you like to try reauthenticating to provide additional access? Your token needs to have the 'api' scope to perform merge.\",\n\t\t\t\tex.message,\n\t\t\t),\n\t\t);\n\n\t\tif (reauthenticate) {\n\t\t\tawait this.reauthenticate();\n\t\t}\n\t}\n\n\tprivate isPullRequest(pr: PullRequest | { id: string; headRefSha: string }): pr is PullRequest {\n\t\treturn (pr as PullRequest).refs != null;\n\t}\n\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst currentUser = await api.getCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t});\n\t\tif (currentUser == null) return undefined;\n\n\t\treturn {\n\t\t\tprovider: {\n\t\t\t\tid: this.id,\n\t\t\t\tname: this.name,\n\t\t\t\tdomain: this.domain,\n\t\t\t\ticon: this.icon,\n\t\t\t},\n\t\t\tid: currentUser.id,\n\t\t\tname: currentUser.name || undefined,\n\t\t\temail: currentUser.email || undefined,\n\t\t\tavatarUrl: currentUser.avatarUrl || undefined,\n\t\t\tusername: currentUser.username || undefined,\n\t\t};\n\t}\n\n\tprotected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {\n\t\treturn getGitLabPullRequestIdentityFromMaybeUrl(search, this.id);\n\t}\n}\n\nexport class GitLabIntegration extends GitLabIntegrationBase<GitCloudHostIntegrationId.GitLab> {\n\treadonly authProvider = authProvider;\n\treadonly id = GitCloudHostIntegrationId.GitLab;\n\tprotected readonly key = this.id;\n\treadonly name: string = 'GitLab';\n\tget domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\tprotected apiBaseUrlFor(_session: ProviderAuthenticationSession): string {\n\t\treturn 'https://gitlab.com/api';\n\t}\n\n\toverride access(): Promise<boolean> {\n\t\t// Always allow GitHub cloud integration access\n\t\treturn Promise.resolve(true);\n\t}\n}\n\nexport class GitLabSelfHostedIntegration extends GitLabIntegrationBase<GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted> {\n\treadonly authProvider = cloudEnterpriseAuthProvider;\n\treadonly id = GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;\n\tprotected readonly key;\n\treadonly name = 'GitLab Self-Hosted';\n\tget domain(): string {\n\t\treturn this._domain;\n\t}\n\tprotected override apiBaseUrlFor(session: ProviderAuthenticationSession): string {\n\t\treturn `${this.getSelfManagedApiBaseUrl(session)}/api`;\n\t}\n\n\tconstructor(\n\t\tctx: IntegrationServiceContext,\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tgetProvidersApi: () => Promise<ProvidersApi>,\n\t\tdidChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t\tprivate readonly _domain: string,\n\t) {\n\t\tsuper(ctx, authenticationService, getProvidersApi, didChangeConnection);\n\t\tthis.key = `${this.id}:${this.domain}` as const;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyEA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAA4D,OAAO,OAAO;CAC/E,IAAI,SAAS;CACb,QAAQ,SAAS;AAClB,CAAC;AAED,MAAM,0BAA0B,kBAAA;AAChC,MAAM,8BAA2E,OAAO,OAAO;CAC9F,IAAI,wBAAwB;CAC5B,QAAQ,wBAAwB;AACjC,CAAC;;;;;;;;AAYD,MAAa,6BAAkG;EAChF,aAAA;EACF,WAAA;EACS,qBAAA;EACP,gBAAA,KAAA;EACD,YAAA,KAAA;AAC9B;AAEA,SAAS,kCAAkC,QAA0D;CACpG,IAAI,CAAC,QAAQ,OAAO,CAAC;CAErB,IAAI;EACH,MAAM,SAAS,KAAK,MAAM,MAAM;EAChC,IAAI,OAAO,SAAS,yBAAyB,OAAO,WAAW,QAAQ,OAAO,OAAO,YAAY,UAChG,OAAO,CAAC;EAGT,MAAM,UAAU,OAA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gBAAgB,EAAA,CACT,eAAe,gBAAgB,KAAK,IAAI,OAAO,GAAG;GAC/E,OAAO,KAAK;GACZ,SAAS,KAAK,qBAAqB,OAAO;EAC3C,CAAC;EACD,IAAI,eAAe,MAAM,OAAO,KAAA;EAEhC,OAAO;GACN,UAAU;IACT,IAAI,KAAK;IACT,MAAM,KAAK;IACX,QAAQ,KAAK;IACb,MAAM,KAAK;GACZ;GACA,IAAI,YAAY;GAChB,MAAM,YAAY,QAAQ,KAAA;GAC1B,OAAO,YAAY,SAAS,KAAA;GAC5B,WAAW,YAAY,aAAa,KAAA;GACpC,UAAU,YAAY,YAAY,KAAA;EACnC;CACD;CAEA,2CAA8D,QAAoD;EACjH,OAAO,yCAAyC,QAAQ,KAAK,EAAE;CAChE;AACD;AAEA,IAAa,oBAAb,cAAuC,sBAAwD;CAC9F,eAAwB;CACxB,KAAS;CACT,MAAyB,KAAK;CAC9B,OAAwB;CACxB,IAAI,SAAiB;EACpB,OAAO,SAAS;CACjB;CAEA,cAAwB,UAAiD;EACxE,OAAO;CACR;CAEA,SAAoC;EAEnC,OAAO,QAAQ,QAAQ,IAAI;CAC5B;AACD;AAEA,IAAa,8BAAb,cAAiD,sBAA6E;CAiB3G;CAhBlB,eAAwB;CACxB,KAAS;CACT;CACA,OAAgB;CAChB,IAAI,SAAiB;EACpB,OAAO,KAAK;CACb;CACA,cAAiC,SAAgD;EAChF,OAAO,GAAG,KAAK,yBAAyB,OAAO,EAAE;CAClD;CAEA,YACC,KACA,uBACA,iBACA,qBACA,SACC;EACD,MAAM,KAAK,uBAAuB,iBAAiB,mBAAmB;EAFrD,KAAA,UAAA;EAGjB,KAAK,MAAM,GAAG,KAAK,GAAG,GAAG,KAAK;CAC/B;AACD"}
|
|
1
|
+
{"version":3,"file":"gitlab.js","names":[],"sources":["../../../../../plus/integrations/src/providers/gitlab.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure } from '@gitkraken/provider-apis';\nimport * as l10n from '@vscode/l10n';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestMergeMethod,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport type { RepositoryDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport type { Emitter } from '@gitlens/utils/event.js';\nimport { uniqueBy } from '@gitlens/utils/iterable.js';\nimport { batch, mapSettledBounded } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';\nimport type { ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport { IntegrationReadUnavailableError } from '../errors.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport type { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from '../models/gitHostIntegration.js';\nimport { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type {\n\tAccountWideIssuesResult,\n\tIssueEtagFields,\n\tIssueEtagInclude,\n\tPullRequestEtagFields,\n\tPullRequestEtagInclude,\n\tSearchMyIssuesOptions,\n} from '../models/integration.js';\nimport type { GitLabIntegrationIds } from './gitlab/gitlab.utils.js';\nimport { getGitLabPullRequestIdentityFromMaybeUrl, matchesGitLabOrgNamespace } from './gitlab/gitlab.utils.js';\nimport {\n\tfromGitLabMergeRequestProvidersApi,\n\tgitLabEtagFieldsMaxIids,\n\tgitLabEtagFieldsWithChecksMaxIids,\n\ttoGitLabIssueEtagFields,\n\ttoGitLabPullRequestEtagFields,\n} from './gitlab/models.js';\nimport type {\n\tProviderApiPagedResult,\n\tProviderHierarchyResult,\n\tProviderOrganization,\n\tProviderPullRequest,\n\tProviderRepository,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tgetProviderPullRequestIdentity,\n\tIssueFilter,\n\tProviderPullRequestReviewState,\n\tprovidersMetadata,\n\tPullRequestFilter,\n\ttoIssueShape,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport type { ProvidersApi } from './providersApi.js';\nimport {\n\tcollectProviderPagedResult,\n\tmergeCollectionMetadata,\n\treadEtagFieldsByRepository,\n\tresolveBranchPullRequests,\n} from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[GitCloudHostIntegrationId.GitLab];\nconst authProvider: IntegrationAuthenticationProviderDescriptor = Object.freeze({\n\tid: metadata.id,\n\tscopes: metadata.scopes,\n});\n\nconst cloudEnterpriseMetadata = providersMetadata[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted];\nconst cloudEnterpriseAuthProvider: IntegrationAuthenticationProviderDescriptor = Object.freeze({\n\tid: cloudEnterpriseMetadata.id,\n\tscopes: cloudEnterpriseMetadata.scopes,\n});\n\ntype GitLabPullRequestAssociation = 'assigned' | 'authored' | 'reviewRequested';\ntype GitLabPullRequestFacetCursor = Partial<Record<GitLabPullRequestAssociation, string>>;\n\n/**\n * The account-wide relationships GitLab can express, and the `scope` each maps to. `undefined` means GitLab has\n * no equivalent axis (it has neither `Mention` nor `reviewed-by`), and this map is the single declaration of\n * that. Exhaustive over `PullRequestFilter` on purpose: a new member must be decided for GitLab here rather\n * than compiling through as silently unsupported. Exported for the advertised-vs-expressible capability test,\n * which is what keeps it agreeing with `supportedAccountWidePullRequestFilters`; no runtime consumer imports it.\n */\nexport const gitLabAssociationForFilter: Record<PullRequestFilter, GitLabPullRequestAssociation | undefined> = {\n\t[PullRequestFilter.Assignee]: 'assigned',\n\t[PullRequestFilter.Author]: 'authored',\n\t[PullRequestFilter.ReviewRequested]: 'reviewRequested',\n\t[PullRequestFilter.Reviewed]: undefined,\n\t[PullRequestFilter.Mention]: undefined,\n};\n\nfunction parseGitLabPullRequestFacetCursor(cursor: string | undefined): GitLabPullRequestFacetCursor {\n\tif (!cursor) return {};\n\n\ttry {\n\t\tconst parsed = JSON.parse(cursor) as { type?: unknown; cursors?: unknown };\n\t\tif (parsed.type !== 'gitlab-associations' || parsed.cursors == null || typeof parsed.cursors !== 'object') {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst cursors = parsed.cursors as Record<string, unknown>;\n\t\treturn Object.fromEntries(\n\t\t\t(['assigned', 'authored', 'reviewRequested'] as const)\n\t\t\t\t.filter(association => typeof cursors[association] === 'string' && cursors[association] !== '')\n\t\t\t\t.map(association => [association, cursors[association] as string]),\n\t\t);\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nexport type GitLabRepositoryDescriptor = RepositoryDescriptor;\n\n/** How many SSH signing-key lookups (account resolve + keys fetch) to run concurrently, to avoid a request burst. */\nconst sshSigningKeyResolveBatchSize = 10;\n\nabstract class GitLabIntegrationBase<ID extends GitLabIntegrationIds> extends GitHostIntegration<\n\tID,\n\tGitLabRepositoryDescriptor\n> {\n\tprotected abstract apiBaseUrlFor(session: ProviderAuthenticationSession): string;\n\n\t/** The installation base the PAT-based reads take on self-hosted GitLab; gitlab.com passes none. */\n\tprotected enterpriseBaseUrlFor(session: ProviderAuthenticationSession): string | undefined {\n\t\treturn this.isEnterprise ? this.getSelfManagedApiBaseUrl(session) : undefined;\n\t}\n\n\t/** Self-hosted GitLab uses PAT semantics and a domain-based API base; gitlab.com does not. */\n\tprotected get isEnterprise(): boolean {\n\t\treturn this.id === GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;\n\t}\n\n\tprotected override async getProviderAccountForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getAccountForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderAccountForEmail(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\temail: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getAccountForEmail(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\temail,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderSshSigningKeysForEmails(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\temails: string[],\n\t): Promise<Map<string, string[]>> {\n\t\tconst result = new Map<string, string[]>();\n\n\t\tconst api = await this.authenticationService.apis.gitlab;\n\t\tif (api == null) return result;\n\n\t\tconst token = toTokenWithInfo(this.id, session);\n\n\t\t// GitLab resolves users one email at a time (no batch search). Run them in bounded batches rather than firing all\n\t\t// (up to providerVerifyLimit) account + key lookups at once, to avoid a request burst that trips rate limiting.\n\t\tawait batch(emails, sshSigningKeyResolveBatchSize, async email => {\n\t\t\tconst account = await this.getProviderAccountForEmail(session, repo, email);\n\t\t\tif (account?.id == null) return;\n\n\t\t\tconst keys = await api.getUserSigningKeys(this, token, account.id, {\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t});\n\t\t\tresult.set(\n\t\t\t\temail.toLowerCase(),\n\t\t\t\tkeys.map(k => k.key),\n\t\t\t);\n\t\t});\n\n\t\treturn result;\n\t}\n\n\tprotected override async getProviderDefaultBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t): Promise<DefaultBranch | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getDefaultBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\t{ id }: { id: string; key: string },\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getIssueOrPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tNumber(id),\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\tconst api = await this.authenticationService.apis.gitlab;\n\t\tconst providerApi = await this.getProvidersApi();\n\t\tif (!api || !repo || !id) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst repoId = await api.getProjectId(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tundefined,\n\t\t);\n\t\tif (!repoId) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst apiResult = await providerApi.getIssue(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t{ namespace: repo.owner, name: repo.name, number: id },\n\t\t\t{\n\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t\tconst issue = apiResult != null ? toIssueShape(apiResult, this, { projection: 'point' }) : undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\tprotected override async getProviderPullRequestForBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\tbranch: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t\tinclude?: PullRequestState[];\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\tconst { include, ...opts } = options ?? {};\n\n\t\tconst toGitLabMergeRequestState = (await import(/* webpackChunkName: \"integrations\" */ './gitlab/models.js'))\n\t\t\t.toGitLabMergeRequestState;\n\t\treturn (await this.authenticationService.apis.gitlab)?.getPullRequestForBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tbranch,\n\t\t\t{\n\t\t\t\t...opts,\n\t\t\t\tinclude: include?.map(s => toGitLabMergeRequestState(s)),\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\trev: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getPullRequestForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: GitLabRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tresource.owner,\n\t\t\tresource.name,\n\t\t\tparseInt(id, 10),\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot; through the\n\t * SDK's issue read and the conversion the repo-scoped list rows take. GitLens' own GitLab client can't alias\n\t * the read instead: it fails a whole document on any GraphQL error, where a batch needs per-target errors.\n\t */\n\tprotected override async getProviderIssuesBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<IssueShape | undefined>[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst baseUrl = this.enterpriseBaseUrlFor(session);\n\t\t// The confirming read must ask the same host, over the same protocol, as the read it confirms.\n\t\tconst confirmBaseUrl = this.apiBaseUrlFor(session);\n\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, async c => {\n\t\t\tconst issue = await api.getIssueForRepo(tokenWithInfo, { namespace: c.owner, name: c.repo }, c.number, {\n\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\tbaseUrl: baseUrl,\n\t\t\t});\n\t\t\tif (issue != null) {\n\t\t\t\tconst shape = toIssueShape(issue, this, { projection: 'batch' });\n\t\t\t\tif (shape == null) throw new Error(`GitLab returned issue ${c.number} without a URL or update time`);\n\n\t\t\t\treturn shape;\n\t\t\t}\n\n\t\t\t// provider-apis' \"not found\" can come from a reply carrying only GraphQL errors (see `getIssueForRepo`),\n\t\t\t// so only our own strict read can prove the miss.\n\t\t\tconst gitlab = await this.authenticationService.apis.gitlab;\n\t\t\tif (gitlab == null) {\n\t\t\t\tthrow new IntegrationReadUnavailableError(this.name, 'cannot confirm a missing issue');\n\t\t\t}\n\n\t\t\tconst exists = await gitlab.hasIssue(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tc.owner,\n\t\t\t\tc.repo,\n\t\t\t\tc.number,\n\t\t\t\t{ baseUrl: confirmBaseUrl, deferFailure: true },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\t// Our own query can't produce the list rows' shape, so a disagreement fails rather than answering thinner.\n\t\t\tif (exists) throw new Error(`GitLab reported issue ${c.number} missing, then found it`);\n\n\t\t\treturn undefined;\n\t\t});\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot; through\n\t * the same SDK read and conversion the manager's list rows take.\n\t */\n\tprotected override async getProviderPullRequestsBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string } } | undefined,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst baseUrl = this.enterpriseBaseUrlFor(session);\n\t\t// The confirming read must ask the same host, over the same protocol, as the read it confirms.\n\t\tconst confirmBaseUrl = this.apiBaseUrlFor(session);\n\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, async c => {\n\t\t\tconst pr = await api.getPullRequestForRepo(tokenWithInfo, { namespace: c.owner, name: c.repo }, c.number, {\n\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\tbaseUrl: baseUrl,\n\t\t\t});\n\t\t\tif (pr != null) {\n\t\t\t\treturn fromProviderPullRequest(pr, this, {\n\t\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\t\tprojection: 'batch',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// provider-apis' GitLab GraphQL helper ignores the response's `errors`, so a reply carrying only errors\n\t\t\t// (e.g. a server-side timeout) comes back as `null`, the same as not-found. Our own client throws on\n\t\t\t// `errors`, and `strict` makes it answer `undefined` only for a real miss.\n\t\t\tconst gitlab = await this.authenticationService.apis.gitlab;\n\t\t\tif (gitlab == null) {\n\t\t\t\tthrow new IntegrationReadUnavailableError(this.name, 'cannot confirm a missing merge request');\n\t\t\t}\n\n\t\t\tconst confirmed = await gitlab.getPullRequest(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tc.owner,\n\t\t\t\tc.repo,\n\t\t\t\tc.number,\n\t\t\t\t{ baseUrl: confirmBaseUrl, strict: true, deferFailure: true },\n\t\t\t\tcancellation,\n\t\t\t);\n\t\t\t// Our own client's row can't produce the list rows' shape (`id` is the iid, not the global id; no\n\t\t\t// `authoredByMe`), so a disagreement fails rather than answering with a different identity.\n\t\t\tif (confirmed != null) throw new Error(`GitLab reported pull request ${c.number} missing, then found it`);\n\n\t\t\treturn undefined;\n\t\t});\n\t}\n\n\t/**\n\t * The cheap check behind the batch issue read's etags: GitLens' own GitLab client reads each project's issues by\n\t * iid, up to {@link gitLabEtagFieldsMaxIids} in ONE request, where {@link getProviderIssuesBatch} sends one or\n\t * two per target. Each row is converted as provider-apis and `toIssueShape` convert the full one, so both reads\n\t * compute the same etag, and `'reactions'` adds the upvote count the full row's `thumbsUpCount` comes from. A\n\t * request that throws rejects only its own targets' slots.\n\t */\n\tprotected override async getProviderIssuesEtagFields(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { etagIncludes?: readonly IssueEtagInclude[] },\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<IssueEtagFields | undefined>[] | undefined> {\n\t\tconst gitlab = await this.authenticationService.apis.gitlab;\n\t\tif (gitlab == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\t// The host and protocol the full read's confirming read asks.\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\t\tconst etagIncludes = options.etagIncludes ?? [];\n\n\t\treturn readEtagFieldsByRepository(\n\t\t\tcoordinates,\n\t\t\tgitLabEtagFieldsMaxIids,\n\t\t\t(owner, repo, iids) =>\n\t\t\t\tgitlab.getIssuesEtagFields(\n\t\t\t\t\tthis,\n\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\t`${owner}/${repo}`,\n\t\t\t\t\tiids,\n\t\t\t\t\t{ baseUrl: baseUrl, etagIncludes: etagIncludes, deferFailure: true },\n\t\t\t\t\tcancellation,\n\t\t\t\t),\n\t\t\tnode => toGitLabIssueEtagFields(node, etagIncludes),\n\t\t);\n\t}\n\n\t/**\n\t * The cheap check behind the batch pull request read's etags: {@link getProviderIssuesEtagFields}'s requests and\n\t * failure isolation over merge requests, selecting a merge request's change state plus the fields of each of\n\t * `options.etagIncludes`. Every include is meaningful here: a full row carries a mergeability, a review decision\n\t * and a check rollup, each of which can change without moving `updatedAt`.\n\t */\n\tprotected override async getProviderPullRequestsEtagFields(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { etagIncludes?: readonly PullRequestEtagInclude[] },\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestEtagFields | undefined>[] | undefined> {\n\t\tconst gitlab = await this.authenticationService.apis.gitlab;\n\t\tif (gitlab == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\t// The host and protocol the full read's confirming read asks.\n\t\tconst baseUrl = this.apiBaseUrlFor(session);\n\t\tconst etagIncludes = options.etagIncludes ?? [];\n\n\t\treturn readEtagFieldsByRepository(\n\t\t\tcoordinates,\n\t\t\tetagIncludes.includes('checks') ? gitLabEtagFieldsWithChecksMaxIids : gitLabEtagFieldsMaxIids,\n\t\t\t(owner, repo, iids) =>\n\t\t\t\tgitlab.getMergeRequestsEtagFields(\n\t\t\t\t\tthis,\n\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\t`${owner}/${repo}`,\n\t\t\t\t\tiids,\n\t\t\t\t\t{ baseUrl: baseUrl, etagIncludes: etagIncludes, deferFailure: true },\n\t\t\t\t\tcancellation,\n\t\t\t\t),\n\t\t\tnode => toGitLabPullRequestEtagFields(node, etagIncludes),\n\t\t);\n\t}\n\n\t/**\n\t * Two steps, because provider-apis has no source-branch filter: GitLens' own GitLab client finds each branch's\n\t * matching iids, one request per target, then {@link getProviderPullRequestsBatch} resolves them — so a row is\n\t * the one `getPullRequestsBatch` returns for that merge request, `url` and `authoredByMe` included.\n\t */\n\tprotected override async getProviderPullRequestsForBranches(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { owner: string; repo: string; project?: string; branch: string; headOwner?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string }; limit: number },\n\t\tcancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<{ pullRequests: PullRequestShape[]; truncated: boolean }>[] | undefined> {\n\t\tconst gitlab = await this.authenticationService.apis.gitlab;\n\t\tif (gitlab == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\t// The session's own host and protocol, as the batch read's confirming read uses.\n\t\tconst apiBaseUrl = this.apiBaseUrlFor(session);\n\n\t\tconst found = await mapSettledBounded(targets, providerFanOutConcurrency, t =>\n\t\t\tgitlab.getPullRequestNumbersForBranch(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tt.owner,\n\t\t\t\tt.repo,\n\t\t\t\tt.branch,\n\t\t\t\t{ baseUrl: apiBaseUrl, headOwner: t.headOwner, limit: options.limit, deferFailure: true },\n\t\t\t\tcancellation,\n\t\t\t),\n\t\t);\n\t\treturn resolveBranchPullRequests(targets, found, coordinates =>\n\t\t\tthis.getProviderPullRequestsBatch(\n\t\t\t\tsession,\n\t\t\t\tcoordinates,\n\t\t\t\t{ currentAccount: options.currentAccount },\n\t\t\t\tcancellation,\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic override async getRepoInfo(repo: {\n\t\towner: string;\n\t\tname: string;\n\t\tproject?: string;\n\t\tconnectionId?: string;\n\t}): Promise<ProviderRepository | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSessionOrThrow(repo.connectionId, undefined);\n\t\tif (session == null) return undefined;\n\n\t\treturn api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t});\n\t}\n\n\tprotected override async getProviderRepositoryMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: GitLabRepositoryDescriptor,\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\treturn (await this.authenticationService.apis.gitlab)?.getRepositoryMetadata(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async getProviderOrganizationsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderOrganization> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst result = await api.getGitlabGroupsForCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t});\n\t\treturn {\n\t\t\tvalues: result.values.map(g => ({ id: g.id, providerId: this.id, name: g.fullPath, url: g.webUrl })),\n\t\t\t...(result.truncated ? { truncated: true } : {}),\n\t\t\t...(result.metadata != null ? { metadata: result.metadata } : {}),\n\t\t};\n\t}\n\n\t/**\n\t * GitLab has no group-scoped repos endpoint, so each page is a page of the current user's member repos\n\t * across all namespaces, filtered to `org` and its subgroups (mirroring gkcli's `gitlabOrgMatches`).\n\t * Follow `paging.cursor` to page the full list; repos the user isn't a member of aren't returned.\n\t * Because the filter is applied per page, a page can come back with `values: []` while\n\t * `paging.more` is still `true` (e.g. a page full of repos outside `org`) — don't treat an empty\n\t * page as the end of pagination, only `paging.more`/`collectPagedResults` reaching exhaustion.\n\t */\n\tprotected override async getProviderRepositoriesForOrg(\n\t\tsession: ProviderAuthenticationSession,\n\t\torg: string,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst result = await api.getReposForCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\tcursor: options?.cursor,\n\t\t});\n\t\treturn {\n\t\t\tvalues: result.values.filter(r => matchesGitLabOrgNamespace(r.namespace, org)),\n\t\t\t...(result.paging != null ? { paging: result.paging } : {}),\n\t\t};\n\t}\n\n\tprotected override async getProviderRepositoriesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// GitLab's membership read is already user-affiliated, so the account-wide walk is the unfiltered\n\t\t// version of the per-org read above (which pages the same source and filters by namespace).\n\t\treturn api.getReposForCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\tcursor: options?.cursor,\n\t\t});\n\t}\n\n\tprotected override async searchProviderMyPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: GitLabRepositoryDescriptor[],\n\t\t_cancellation?: AbortSignal,\n\t\toptions?: SearchMyPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// Resolve the username from THIS session's token (multi-account: `session` may be a non-primary\n\t\t// connection); `getCurrentAccount()` would use the primary `_session` and filter by the wrong user.\n\t\tconst username = (await this.getProviderCurrentAccount(session))?.username;\n\t\tif (!username) {\n\t\t\treturn Promise.resolve([]);\n\t\t}\n\n\t\tconst apiResult = await api.getPullRequestsForUser(toTokenWithInfo(this.id, session), username, {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\tstates: toProviderPullRequestStates(options?.state),\n\t\t});\n\n\t\tif (apiResult == null) {\n\t\t\treturn Promise.resolve([]);\n\t\t}\n\n\t\t// now I'm going to filter prs from the result according to the repos parameter\n\t\tlet prs;\n\t\tif (repos != null) {\n\t\t\tconst repoMap = new Map<string, GitLabRepositoryDescriptor>();\n\t\t\tfor (const repo of repos) {\n\t\t\t\trepoMap.set(`${repo.owner}/${repo.name}`, repo);\n\t\t\t}\n\t\t\tprs = apiResult.values.filter(pr => {\n\t\t\t\tconst repo = repoMap.get(`${pr.repository.owner.login}/${pr.repository.name}`);\n\t\t\t\treturn repo != null;\n\t\t\t});\n\t\t} else {\n\t\t\tprs = apiResult.values;\n\t\t}\n\n\t\tconst results: IterableIterator<PullRequest> = uniqueBy(\n\t\t\t[\n\t\t\t\t...prs\n\t\t\t\t\t.filter(pr => {\n\t\t\t\t\t\tconst isAssignee = pr.assignees?.some(a => a.username === username);\n\t\t\t\t\t\tconst isRequestedReviewer = pr.reviews?.some(\n\t\t\t\t\t\t\t// Match only reviews assigned to the current user; a bare `state === ReviewRequested`\n\t\t\t\t\t\t\t// check would also match reviews requested from OTHER people, leaking their MRs in.\n\t\t\t\t\t\t\treview =>\n\t\t\t\t\t\t\t\treview.reviewer?.username === username &&\n\t\t\t\t\t\t\t\treview.state === ProviderPullRequestReviewState.ReviewRequested,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst isAuthor = pr.author?.username === username;\n\t\t\t\t\t\t// It seems like GitLab doesn't give us mentioned PRs.\n\t\t\t\t\t\t// const isMentioned = ???;\n\n\t\t\t\t\t\treturn isAssignee || isRequestedReviewer || isAuthor;\n\t\t\t\t\t})\n\t\t\t\t\t.map(pr => fromGitLabMergeRequestProvidersApi(pr, this, 'search')),\n\t\t\t],\n\t\t\tr => r.url,\n\t\t\t(original, _current) => original,\n\t\t);\n\n\t\treturn [...results];\n\t}\n\n\tprotected override async getProviderMyPullRequestsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { state?: PullRequestStateFilter[]; cursor?: string; filters?: PullRequestFilter[] },\n\t): Promise<ProviderApiPagedResult<ProviderPullRequest> | undefined> {\n\t\t// Resolve the username from THIS session's token (multi-account safe) to scope the account-wide read.\n\t\tconst username = (await this.getProviderCurrentAccount(session))?.username;\n\t\tif (username == null) return undefined;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst requested = options?.filters?.length ? new Set(options.filters) : undefined;\n\t\t// The filter contract is all-or-nothing, so refuse as soon as ONE requested member is inexpressible rather\n\t\t// than only when every one is: dropping the rest would answer a narrower question than was asked\n\t\t// (`[Author, Mention]` becoming `authored`). Throw rather than return `undefined`, which the facade reads\n\t\t// as \"no session could be resolved\" and a drain turns into a not-connected warning, misattributing a\n\t\t// refusal; `getMyPullRequestsForUserResult` recovers the throw into `{ error }`. Defense in depth:\n\t\t// `resolveAccountWidePullRequestFilters` already refuses such a set, so only a direct caller of the public\n\t\t// method reaches this.\n\t\tconst unsupported = requested == null ? [] : [...requested].filter(f => gitLabAssociationForFilter[f] == null);\n\t\tif (unsupported.length > 0) {\n\t\t\tthrow new IntegrationReadUnavailableError(\n\t\t\t\tthis.name,\n\t\t\t\t`account-wide pull request filters not expressible by GitLab: ${unsupported.join(', ')}`,\n\t\t\t);\n\t\t}\n\n\t\tconst associations: GitLabPullRequestAssociation[] =\n\t\t\trequested == null\n\t\t\t\t? ['authored', 'assigned', 'reviewRequested']\n\t\t\t\t: Array.from(requested, f => gitLabAssociationForFilter[f]).filter(a => a != null);\n\n\t\tconst cursors = parseGitLabPullRequestFacetCursor(options?.cursor);\n\t\tconst resumable = associations.filter(association => cursors[association] != null);\n\t\tconst associationsToQuery = options?.cursor != null && resumable.length > 0 ? resumable : associations;\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst settled = await Promise.allSettled(\n\t\t\tassociationsToQuery.map(async association => ({\n\t\t\t\tassociation: association,\n\t\t\t\tresult: await api.getGitLabPullRequestsForUserAssociation(tokenWithInfo, username, association, {\n\t\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\t\t\tstates: toProviderPullRequestStates(options?.state),\n\t\t\t\t\tcursor: cursors[association],\n\t\t\t\t}),\n\t\t\t})),\n\t\t);\n\t\tif (settled.every(outcome => outcome.status === 'rejected')) {\n\t\t\tconst first = settled[0];\n\t\t\tif (first?.status === 'rejected') throw first.reason;\n\t\t}\n\n\t\tconst values = new Map<string, ProviderPullRequest>();\n\t\tconst nextCursors: GitLabPullRequestFacetCursor = {};\n\t\tconst failures: CollectionScopeFailure[] = [];\n\t\tlet aggregateMetadata: CollectionMetadata | undefined;\n\t\tlet truncated = false;\n\t\tlet unkeyedPullRequest = 0;\n\t\tfor (let index = 0; index < settled.length; index++) {\n\t\t\tconst outcome = settled[index];\n\t\t\tconst association = associationsToQuery[index];\n\t\t\tif (outcome == null || association == null) continue;\n\t\t\tif (outcome.status === 'rejected') {\n\t\t\t\tconst failure = toCollectionScopeFailure({ providerId: this.id }, outcome.reason);\n\t\t\t\tfailures.push({\n\t\t\t\t\t...failure,\n\t\t\t\t\tmessage: `GitLab ${association} pull requests could not be read${\n\t\t\t\t\t\tfailure.message != null ? `: ${failure.message}` : ''\n\t\t\t\t\t}`,\n\t\t\t\t});\n\t\t\t\ttruncated = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = outcome.value.result;\n\t\t\taggregateMetadata = mergeCollectionMetadata(aggregateMetadata, result.metadata);\n\t\t\ttruncated ||=\n\t\t\t\tresult.paging?.truncated === true ||\n\t\t\t\t(result.metadata != null && result.metadata.completeness !== 'complete');\n\t\t\tfor (const pr of result.values) {\n\t\t\t\tconst identity = getProviderPullRequestIdentity(pr) ?? `unkeyed:${unkeyedPullRequest++}`;\n\t\t\t\tif (!values.has(identity)) {\n\t\t\t\t\tvalues.set(identity, pr);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (result.paging?.more && result.paging.cursor != null && result.paging.cursor !== '{}') {\n\t\t\t\tnextCursors[association] = result.paging.cursor;\n\t\t\t}\n\t\t}\n\n\t\taggregateMetadata = mergeCollectionMetadata(\n\t\t\taggregateMetadata,\n\t\t\tfailures.length > 0 ? { completeness: 'partial', failures: failures } : undefined,\n\t\t);\n\t\tconst hasMore = Object.keys(nextCursors).length > 0;\n\t\treturn {\n\t\t\tvalues: [...values.values()],\n\t\t\tpaging: {\n\t\t\t\tmore: hasMore,\n\t\t\t\tcursor: hasMore ? JSON.stringify({ type: 'gitlab-associations', cursors: nextCursors }) : '{}',\n\t\t\t\ttruncated: truncated || undefined,\n\t\t\t},\n\t\t\t...(aggregateMetadata != null ? { metadata: aggregateMetadata } : {}),\n\t\t};\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: GitLabRepositoryDescriptor[],\n\t): Promise<IssueShape[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.gitlab;\n\t\tconst providerApi = await this.getProvidersApi();\n\t\tif (!api || !repos) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst repoIdsResult = await Promise.allSettled(\n\t\t\trepos.map((r: GitLabRepositoryDescriptor): Promise<string | undefined> =>\n\t\t\t\tapi.getProjectId(\n\t\t\t\t\tthis,\n\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\tr.owner,\n\t\t\t\t\tr.name,\n\t\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t\t\tundefined,\n\t\t\t\t),\n\t\t\t) ?? [],\n\t\t);\n\t\tconst repoInput = repoIdsResult\n\t\t\t.map(result => (result.status === 'fulfilled' ? result.value : undefined))\n\t\t\t.filter((r): r is string => r != null);\n\t\tconst apiResult = await providerApi.getIssuesForRepos(toTokenWithInfo(this.id, session), repoInput, {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t});\n\n\t\treturn apiResult.values\n\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'account' }))\n\t\t\t.filter((result): result is IssueShape => result != null);\n\t}\n\n\t/**\n\t * Account-wide \"my issues\" for GitLab. GitLab's repo-scoped issue read bails without repos, and GitLab has\n\t * no GraphQL cross-project issue field, so this goes through the SDK's REST `GET /issues` read\n\t * ({@link ProvidersApi.getIssuesForCurrentUser}). Open issues only (matching GitHub's baked `is:open`).\n\t *\n\t * Default scope is the current user's assigned issues; `includeAllAssignees` broadens to `scope=all` (every\n\t * visible issue, any assignee). The read is numbered-paged, so each page is drained to exhaustion, bounded by\n\t * a defensive backstop — a hit backstop is reported as `truncated` so the facade surfaces an incomplete read\n\t * rather than publishing a partial list as complete.\n\t *\n\t * `options.filters` selects which relationships to read: `Assignee` (the default when omitted) and `Author`,\n\t * each its own drain, unioned by url — see the comment on `passes` for why they can't be one request. Mention\n\t * is absent because GitLab's REST read exposes no first-class mention filter, and approximating it via `search`\n\t * would return a different set than asked for; the facade refuses it\n\t * (see `ProviderMetadata.supportedAccountWideIssueFilters`).\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resources?: GitLabRepositoryDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst api = await this.getProvidersApi();\n\n\t\t// Resolve the username from THIS session's token (multi-account safe), matching the PR account-wide read.\n\t\t// Only needed to scope the default (assigned-to-me) read; the all-assignees broaden drops it.\n\t\tconst username = options?.includeAllAssignees\n\t\t\t? undefined\n\t\t\t: (await this.getProviderCurrentAccount(session))?.username;\n\t\tif (!options?.includeAllAssignees && username == null) return undefined;\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst baseUrl = this.enterpriseBaseUrlFor(session);\n\t\tconst maxPages = 20;\n\t\t// Dedupe by `url`, not `IssueShape.id`: for GitLab `id` is the per-project `iid`, which collides across\n\t\t// projects in an account-wide read (two repos both have issue `#1`), so an id-keyed map would silently\n\t\t// drop distinct issues. `url` is globally unique. Matches the GitHub/GitLab account-wide PR reads.\n\t\tconst issuesByUrl = new Map<string, IssueShape>();\n\t\tlet truncated = false;\n\t\tlet collectionMetadata: CollectionMetadata | undefined;\n\n\t\t// One drain PER requested relationship, unioned by url. The account-wide filter contract is a union\n\t\t// (`authored ∪ assigned`, matching GitHub's three searches and Azure's two drains), and GitLab can express\n\t\t// only one relationship per REST call: `assignee_username` and `author_username` on the same request\n\t\t// compose with AND, so a single combined call would return the intersection — issues the user both opened\n\t\t// and is assigned to — instead of either set. Overlap between the passes is collapsed by the url map.\n\t\tconst passes: { scope: 'assigned_to_me' | 'all'; assigneeUsername?: string; authorUsername?: string }[] = [];\n\t\tif (options?.includeAllAssignees) {\n\t\t\t// Broadens past \"mine\" entirely: every visible issue, any assignee. Contradicts `filters`, which the\n\t\t\t// facade refuses before reaching here.\n\t\t\tpasses.push({ scope: 'all' });\n\t\t} else {\n\t\t\tconst filters = options?.filters;\n\t\t\t// Assignee is this read's default relationship, so it runs unless the caller narrowed to author alone.\n\t\t\tif (filters == null || filters.length === 0 || filters.includes(IssueFilter.Assignee)) {\n\t\t\t\tpasses.push({ scope: 'assigned_to_me', assigneeUsername: username });\n\t\t\t}\n\t\t\t// `scope: 'all'` is required for the author axis: paired with `assigned_to_me` GitLab would intersect\n\t\t\t// the two rather than read authored issues.\n\t\t\tif (filters?.includes(IssueFilter.Author)) {\n\t\t\t\tpasses.push({ scope: 'all', authorUsername: username });\n\t\t\t}\n\t\t}\n\n\t\tfor (const pass of passes) {\n\t\t\tconst result = await collectProviderPagedResult(\n\t\t\t\tasync cursor => {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\tconst page = await api.getIssuesForCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\t\t\t\t...pass,\n\t\t\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\t\t\tbaseUrl: baseUrl,\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tsort: options?.sort,\n\t\t\t\t\t});\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t\t\t\treturn page;\n\t\t\t\t},\n\t\t\t\tmaxPages,\n\t\t\t\t{ providerId: this.id },\n\t\t\t);\n\n\t\t\tfor (const issue of result.values) {\n\t\t\t\tconst shape = toIssueShape(issue, this, { projection: 'account' });\n\t\t\t\tif (shape != null && !issuesByUrl.has(shape.url)) {\n\t\t\t\t\tissuesByUrl.set(shape.url, shape);\n\t\t\t\t}\n\t\t\t}\n\t\t\ttruncated ||= result.truncated === true;\n\t\t\tcollectionMetadata = mergeCollectionMetadata(collectionMetadata, result.metadata);\n\t\t}\n\n\t\treturn {\n\t\t\tvalues: [...issuesByUrl.values()],\n\t\t\ttruncated: truncated,\n\t\t\t...(collectionMetadata != null ? { metadata: collectionMetadata } : {}),\n\t\t};\n\t}\n\n\tprotected override async searchProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tsearchQuery: string,\n\t\trepos?: GitLabRepositoryDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.gitlab;\n\t\tif (!api) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn api.searchPullRequests(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t{\n\t\t\t\tsearch: searchQuery,\n\t\t\t\trepos: repos?.map(r => `${r.owner}/${r.name}`),\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\tinclude: options?.include,\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async mergeProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tpr: PullRequest,\n\t\toptions?: {\n\t\t\tmergeMethod?: PullRequestMergeMethod;\n\t\t},\n\t): Promise<boolean> {\n\t\tif (!this.isPullRequest(pr)) return false;\n\n\t\tconst api = await this.getProvidersApi();\n\t\ttry {\n\t\t\tconst res = await api.mergePullRequest(toTokenWithInfo(this.id, session), pr, {\n\t\t\t\t...options,\n\t\t\t\tisPAT: this.isEnterprise,\n\t\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t\t});\n\t\t\treturn res;\n\t\t} catch (ex) {\n\t\t\tvoid this.showMergeErrorMessage(ex);\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate async showMergeErrorMessage(ex: Error) {\n\t\t// Unfortunately, providers-api does not let us know the exact reason for the error,\n\t\t// so we show the same message to everything.\n\t\t// When we update the library, we can improve the error handling here.\n\t\tconst reauthenticate = await this.ctx.hooks?.onReauthenticationRequired?.(\n\t\t\tl10n.t(\n\t\t\t\t\"{0}. Would you like to try reauthenticating to provide additional access? Your token needs to have the 'api' scope to perform merge.\",\n\t\t\t\tex.message,\n\t\t\t),\n\t\t);\n\n\t\tif (reauthenticate) {\n\t\t\tawait this.reauthenticate();\n\t\t}\n\t}\n\n\tprivate isPullRequest(pr: PullRequest | { id: string; headRefSha: string }): pr is PullRequest {\n\t\treturn (pr as PullRequest).refs != null;\n\t}\n\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst currentUser = await api.getCurrentUser(toTokenWithInfo(this.id, session), {\n\t\t\tisPAT: this.isEnterprise,\n\t\t\tbaseUrl: this.enterpriseBaseUrlFor(session),\n\t\t});\n\t\tif (currentUser == null) return undefined;\n\n\t\treturn {\n\t\t\tprovider: {\n\t\t\t\tid: this.id,\n\t\t\t\tname: this.name,\n\t\t\t\tdomain: this.domain,\n\t\t\t\ticon: this.icon,\n\t\t\t},\n\t\t\tid: currentUser.id,\n\t\t\tname: currentUser.name || undefined,\n\t\t\temail: currentUser.email || undefined,\n\t\t\tavatarUrl: currentUser.avatarUrl || undefined,\n\t\t\tusername: currentUser.username || undefined,\n\t\t};\n\t}\n\n\tprotected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {\n\t\treturn getGitLabPullRequestIdentityFromMaybeUrl(search, this.id);\n\t}\n}\n\nexport class GitLabIntegration extends GitLabIntegrationBase<GitCloudHostIntegrationId.GitLab> {\n\treadonly authProvider = authProvider;\n\treadonly id = GitCloudHostIntegrationId.GitLab;\n\tprotected readonly key = this.id;\n\treadonly name: string = 'GitLab';\n\tget domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\tprotected apiBaseUrlFor(_session: ProviderAuthenticationSession): string {\n\t\treturn 'https://gitlab.com/api';\n\t}\n\n\toverride access(): Promise<boolean> {\n\t\t// Always allow GitHub cloud integration access\n\t\treturn Promise.resolve(true);\n\t}\n}\n\nexport class GitLabSelfHostedIntegration extends GitLabIntegrationBase<GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted> {\n\treadonly authProvider = cloudEnterpriseAuthProvider;\n\treadonly id = GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;\n\tprotected readonly key;\n\treadonly name = 'GitLab Self-Hosted';\n\tget domain(): string {\n\t\treturn this._domain;\n\t}\n\tprotected override apiBaseUrlFor(session: ProviderAuthenticationSession): string {\n\t\treturn `${this.getSelfManagedApiBaseUrl(session)}/api`;\n\t}\n\n\tconstructor(\n\t\tctx: IntegrationServiceContext,\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tgetProvidersApi: () => Promise<ProvidersApi>,\n\t\tdidChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t\tprivate readonly _domain: string,\n\t) {\n\t\tsuper(ctx, authenticationService, getProvidersApi, didChangeConnection);\n\t\tthis.key = `${this.id}:${this.domain}` as const;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyEA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAA4D,OAAO,OAAO;CAC/E,IAAI,SAAS;CACb,QAAQ,SAAS;AAClB,CAAC;AAED,MAAM,0BAA0B,kBAAA;AAChC,MAAM,8BAA2E,OAAO,OAAO;CAC9F,IAAI,wBAAwB;CAC5B,QAAQ,wBAAwB;AACjC,CAAC;;;;;;;;AAYD,MAAa,6BAAkG;EAChF,aAAA;EACF,WAAA;EACS,qBAAA;EACP,gBAAA,KAAA;EACD,YAAA,KAAA;AAC9B;AAEA,SAAS,kCAAkC,QAA0D;CACpG,IAAI,CAAC,QAAQ,OAAO,CAAC;CAErB,IAAI;EACH,MAAM,SAAS,KAAK,MAAM,MAAM;EAChC,IAAI,OAAO,SAAS,yBAAyB,OAAO,WAAW,QAAQ,OAAO,OAAO,YAAY,UAChG,OAAO,CAAC;EAGT,MAAM,UAAU,OAAO;EACvB,OAAO,OAAO,YACZ;GAAC;GAAY;GAAY;EAAiB,CAAC,CAC1C,QAAO,gBAAe,OAAO,QAAQ,iBAAiB,YAAY,QAAQ,iBAAiB,EAAE,CAAC,CAC9F,KAAI,gBAAe,CAAC,aAAa,QAAQ,YAAsB,CAAC,CACnE;CACD,QAAQ;EACP,OAAO,CAAC;CACT;AACD;;AAKA,MAAM,gCAAgC;AAEtC,IAAe,wBAAf,cAA8E,mBAG5E;;CAID,qBAA+B,SAA4D;EAC1F,O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AY,SAAS,KAAA;GAC5B,WAAW,YAAY,aAAa,KAAA;GACpC,UAAU,YAAY,YAAY,KAAA;EACnC;CACD;CAEA,2CAA8D,QAAoD;EACjH,OAAO,yCAAyC,QAAQ,KAAK,EAAE;CAChE;AACD;AAEA,IAAa,oBAAb,cAAuC,sBAAwD;CAC9F,eAAwB;CACxB,KAAS;CACT,MAAyB,KAAK;CAC9B,OAAwB;CACxB,IAAI,SAAiB;EACpB,OAAO,SAAS;CACjB;CAEA,cAAwB,UAAiD;EACxE,OAAO;CACR;CAEA,SAAoC;EAEnC,OAAO,QAAQ,QAAQ,IAAI;CAC5B;AACD;AAEA,IAAa,8BAAb,cAAiD,sBAA6E;CAiB3G;CAhBlB,eAAwB;CACxB,KAAS;CACT;CACA,OAAgB;CAChB,IAAI,SAAiB;EACpB,OAAO,KAAK;CACb;CACA,cAAiC,SAAgD;EAChF,OAAO,GAAG,KAAK,yBAAyB,OAAO,EAAE;CAClD;CAEA,YACC,KACA,uBACA,iBACA,qBACA,SACC;EACD,MAAM,KAAK,uBAAuB,iBAAiB,mBAAmB;EAFrD,KAAA,UAAA;EAGjB,KAAK,MAAM,GAAG,KAAK,GAAG,GAAG,KAAK;CAC/B;AACD"}
|
|
@@ -62,6 +62,7 @@ var JiraIntegration = class extends IssuesIntegration {
|
|
|
62
62
|
if (!(this.maybeConnected ?? await this.isConnected()) || this._session == null) return [];
|
|
63
63
|
const session = this._session;
|
|
64
64
|
const cached = this._autolinks.get(session.accessToken);
|
|
65
|
+
if (this.connectionExpired === true) return cached?.autolinks ?? [];
|
|
65
66
|
if (cached == null) return this.buildAutolinks(session);
|
|
66
67
|
if (Date.now() - cached.builtAt >= 3e5) this.buildAutolinks(session);
|
|
67
68
|
return cached.autolinks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jira.js","names":[],"sources":["../../../../../plus/integrations/src/providers/jira.ts"],"sourcesContent":["import type { CollectionMetadata } from '@gitkraken/provider-apis';\nimport { JIRA_MAX_PROJECT_KEYS_PER_REQUEST } from '@gitkraken/provider-apis';\nimport * as l10n from '@vscode/l10n';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { AutolinkReference, DynamicAutolinkReference } from '@gitlens/git/models/autolink.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { IssueResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { chunk } from '@gitlens/utils/array.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { mapSettledBounded } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport type { ProviderRefusal } from '../collectionMetadata.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { IssuesCloudHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IssueEtagFields } from '../models/integration.js';\nimport type {\n\tAccountWideIssuesResult,\n\tIssuesForProjectOptions,\n\tProjectIssuesDrain,\n\tProjectIssuesRequest,\n\tSearchMyIssuesOptions,\n} from '../models/issueReads.js';\nimport { groupProjectIssuesSearches, IssuesIntegration } from '../models/issuesIntegration.js';\nimport type { JiraIssueEtagResponse } from './jiraIssueByKey.js';\nimport { jiraBulkFetchMaxKeys, toJiraIssueEtagFields } from './jiraIssueByKey.js';\nimport type { ProviderApiCollectionResult } from './models.js';\nimport { providersMetadata, toAccount, toIssueShape, toProviderIssueStates } from './models.js';\nimport { isJiraMissingProjectError } from './providerErrors.js';\nimport { DiscoveryCache, discoveryCacheTtl } from './utils/discoveryCache.js';\nimport type { JiraDrainOptions, JiraIssuePageFetcher } from './utils/jiraIssueDrains.js';\nimport {\n\tdrainJiraIssues,\n\treadUserScopedJiraIssues,\n\tsearchJiraProjectIssues,\n\ttoUniqueJiraIssueShapes,\n} from './utils/jiraIssueDrains.js';\nimport { collectProviderPagedResult, mergeCollectionMetadata } from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[IssuesCloudHostIntegrationId.Jira];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\nconst maxPagesPerRequest = 10;\n/** A numeric issue id, which Jira's issue reads accept in place of a key. */\nconst numericIssueId = /^\\d+$/;\n\n/**\n * `assignee` and `creator` are user FIELDS: Jira resolves an accountId against the directory, which is the identity\n * that keeps matching once a display name cannot be looked up — a deactivated account, or a profile whose visibility\n * hides the name. Measured against a live site: a deactivated assignee returns its issues by accountId and an empty\n * page by display name, and Jira reports that miss as a successful empty search rather than an error, so the list\n * simply appears empty.\n *\n * `mention` is NOT a user field. It is `comment ~ \"...\"`, a free-text search over comment bodies, so an accountId\n * matches nothing there and the display name is the only value that can. Hence the id is applied to the first two\n * and the handle is kept for the third, rather than swapping `user` wholesale.\n */\nfunction toUserIdentities(user: string, options: IssuesForProjectOptions): { userField: string; mention: string } {\n\treturn { userField: options.userId ?? user, mention: user };\n}\n\nexport type JiraBaseDescriptor = IssueResourceDescriptor;\n\nexport interface JiraOrganizationDescriptor extends JiraBaseDescriptor {\n\turl: string;\n\tavatarUrl: string;\n}\n\nexport interface JiraProjectDescriptor extends JiraBaseDescriptor {\n\tresourceId: string;\n}\n\nexport class JiraIntegration extends IssuesIntegration<IssuesCloudHostIntegrationId.Jira> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = IssuesCloudHostIntegrationId.Jira;\n\tprotected readonly key = this.id;\n\treadonly name: string = 'Jira';\n\n\tget domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\tprotected get apiBaseUrl(): string {\n\t\treturn 'https://api.atlassian.com';\n\t}\n\n\t/**\n\t * Built from the sites and their projects, so it follows them: rebuilt when a site's project list changes or the\n\t * caches are dropped, and once older than {@link discoveryCacheTtl}. An expired set is still served while it is\n\t * rebuilt in the background, because autolinks are read on every render of a commit message and must not wait\n\t * on the network, nor go empty just because nothing read the projects for a while (#5907).\n\t */\n\tprivate readonly _autolinks = new Map<\n\t\tstring,\n\t\t{ autolinks: (AutolinkReference | DynamicAutolinkReference)[]; builtAt: number }\n\t>();\n\tprivate readonly _autolinksBuilds = new Map<string, Promise<(AutolinkReference | DynamicAutolinkReference)[]>>();\n\n\toverride async autolinks(): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected || this._session == null) return [];\n\n\t\tconst session = this._session;\n\t\tconst cached = this._autolinks.get(session.accessToken);\n\t\tif (cached == null) return this.buildAutolinks(session);\n\n\t\tif (Date.now() - cached.builtAt >= discoveryCacheTtl) {\n\t\t\tvoid this.buildAutolinks(session);\n\t\t}\n\t\treturn cached.autolinks;\n\t}\n\n\t/** One build per token at a time: concurrent renders share it rather than each re-reading sites and projects. */\n\tprivate buildAutolinks(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tlet build = this._autolinksBuilds.get(accessToken);\n\t\tif (build == null) {\n\t\t\tbuild = this.buildAutolinksCore(session).finally(() => this._autolinksBuilds.delete(accessToken));\n\t\t\tthis._autolinksBuilds.set(accessToken, build);\n\t\t}\n\t\treturn build;\n\t}\n\n\tprivate async buildAutolinksCore(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tconst generation = this._projects.generation;\n\t\ttry {\n\t\t\tconst organizations = await this.getProviderResourcesForUser(session);\n\t\t\tif (!organizations?.length) return [];\n\n\t\t\t// Served from the cache for every site whose projects are still fresh; only the rest are read.\n\t\t\tconst { values: projects, metadata } = await this.getProviderProjectsForResourcesWithMetadata(\n\t\t\t\tsession,\n\t\t\t\torganizations,\n\t\t\t);\n\n\t\t\tconst autolinks: (AutolinkReference | DynamicAutolinkReference)[] = [];\n\t\t\tfor (const project of projects) {\n\t\t\t\tconst organization = organizations.find(o => o.id === project.resourceId);\n\t\t\t\tif (organization == null) continue;\n\n\t\t\t\tconst dashedPrefix = `${project.key}-`;\n\t\t\t\tconst underscoredPrefix = `${project.key}_`;\n\t\t\t\tautolinks.push({\n\t\t\t\t\tprefix: dashedPrefix,\n\t\t\t\t\turl: `${organization.url}/browse/${dashedPrefix}<num>`,\n\t\t\t\t\talphanumeric: false,\n\t\t\t\t\tignoreCase: false,\n\t\t\t\t\ttitle: l10n.t('Open Issue {0} on {1}', `${dashedPrefix}<num>`, organization.name),\n\n\t\t\t\t\ttype: 'issue',\n\t\t\t\t\tdescription: l10n.t('{0} Issue {1}', organization.name, `${dashedPrefix}<num>`),\n\t\t\t\t\tdescriptor: { ...organization },\n\t\t\t\t});\n\t\t\t\tautolinks.push({\n\t\t\t\t\tprefix: underscoredPrefix,\n\t\t\t\t\turl: `${organization.url}/browse/${dashedPrefix}<num>`,\n\t\t\t\t\talphanumeric: false,\n\t\t\t\t\tignoreCase: false,\n\t\t\t\t\treferenceType: 'branch',\n\t\t\t\t\ttitle: l10n.t('Open Issue {0} on {1}', `${dashedPrefix}<num>`, organization.name),\n\n\t\t\t\t\ttype: 'issue',\n\t\t\t\t\tdescription: l10n.t('{0} Issue {1}', organization.name, `${dashedPrefix}<num>`),\n\t\t\t\t\tdescriptor: { ...organization },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// A set missing a site's projects is served but not kept, so the next call tries that site again; one\n\t\t\t// built from projects read before the caches were dropped is not kept either.\n\t\t\tconst complete = metadata == null || metadata.completeness === 'complete';\n\t\t\tif (complete && this._projects.generation === generation) {\n\t\t\t\tthis._autolinks.set(accessToken, { autolinks: autolinks, builtAt: Date.now() });\n\t\t\t}\n\t\t\treturn autolinks;\n\t\t} catch (ex) {\n\t\t\t// Autolinks are decoration: keep serving the last set rather than failing the render that asked.\n\t\t\tLogger.error(ex, 'JiraIntegration.autolinks');\n\t\t\treturn this._autolinks.get(accessToken)?.autolinks ?? [];\n\t\t}\n\t}\n\n\tprotected override async getProviderAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api.getCurrentUserForResource(toTokenWithInfo(this.id, session), resource.id);\n\n\t\tif (user == null) return undefined;\n\t\treturn toAccount(user, this);\n\t}\n\n\t/** The site-list request the resource cache would otherwise answer; see `IntegrationBase.validateCredential`. */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tif ((await api.getJiraResourcesForCurrentUser(toTokenWithInfo(this.id, session))) == null) {\n\t\t\tthrow new Error('Jira did not confirm the credential');\n\t\t}\n\t}\n\n\t/**\n\t * Atlassian's `401` for a token missing a scope the request needs, which a reconnect fixes by consenting to it\n\t * again; see `IntegrationBase.isCredentialRefusal`. Atlassian gives the same answer to a malformed request URL,\n\t * so a request the SDK built wrong would read as the credential's too.\n\t */\n\tprotected override isCredentialRefusal(refusal: ProviderRefusal): boolean {\n\t\treturn refusal.status === 401 && /scope does not match/i.test(refusal.detail ?? '');\n\t}\n\n\t/**\n\t * The sites and the projects discovered under them, both of which expire and are dropped on a re-sync, so a site\n\t * or project created or deleted mid-session is picked up (#5907). Keyed by token, and projects by token and site.\n\t */\n\tprivate readonly _organizations = new DiscoveryCache<JiraOrganizationDescriptor[]>();\n\tprivate readonly _projects = new DiscoveryCache<JiraProjectDescriptor[]>();\n\t/** When the caches were last dropped; a persisted discovery read before then is as stale as they were. */\n\tprivate _discoveryInvalidatedAt = 0;\n\n\tprotected override async getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\tconst { accessToken } = session;\n\n\t\tconst cachedResources = this._organizations.get(accessToken);\n\t\tif (cachedResources != null && !force) return cachedResources;\n\n\t\tconst generation = this._organizations.generation;\n\t\tconst api = await this.getProvidersApi();\n\t\tconst resources = await api.getJiraResourcesForCurrentUser(toTokenWithInfo(this.id, session));\n\t\tconst organizations = resources?.map(r => ({ ...r, key: r.id }));\n\t\tif (organizations == null) {\n\t\t\tthis._organizations.delete(accessToken);\n\t\t\treturn undefined;\n\t\t}\n\n\t\tthis._organizations.set(accessToken, organizations, { generation: generation });\n\t\treturn organizations;\n\t}\n\n\tprotected override async getProviderProjectsForResources(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t\tforce: boolean = false,\n\t): Promise<JiraProjectDescriptor[] | undefined> {\n\t\treturn (await this.getProviderProjectsForResourcesWithMetadata(session, resources, force)).values;\n\t}\n\n\tprotected override async getProviderProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t\tforce: boolean = false,\n\t): Promise<ProviderApiCollectionResult<JiraProjectDescriptor>> {\n\t\tconst { accessToken } = session;\n\t\tconst projectsCache = this._projects;\n\t\tconst generation = projectsCache.generation;\n\n\t\tlet resourcesWithoutProjects = [];\n\t\tif (force) {\n\t\t\tresourcesWithoutProjects = resources;\n\t\t} else {\n\t\t\tfor (const resource of resources) {\n\t\t\t\tconst resourceKey = `${accessToken}:${resource.id}`;\n\t\t\t\tconst cachedProjects = projectsCache.get(resourceKey);\n\t\t\t\tif (cachedProjects == null) {\n\t\t\t\t\tresourcesWithoutProjects.push(resource);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\tconst partialProjects: JiraProjectDescriptor[] = [];\n\t\tif (resourcesWithoutProjects.length > 0) {\n\t\t\tconst api = await this.getProvidersApi();\n\t\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\t\tconst drains = await Promise.allSettled(\n\t\t\t\tresourcesWithoutProjects.map(async resource => ({\n\t\t\t\t\tresource: resource,\n\t\t\t\t\tresult: await collectProviderPagedResult(\n\t\t\t\t\t\tcursor => api.getJiraProjectsForResource(tokenWithInfo, resource.id, { cursor: cursor }),\n\t\t\t\t\t\tmaxPagesPerRequest,\n\t\t\t\t\t\t{ providerId: this.id, resourceId: resource.id },\n\t\t\t\t\t),\n\t\t\t\t})),\n\t\t\t);\n\n\t\t\tdrains.forEach((drain, index) => {\n\t\t\t\tif (drain.status === 'rejected') {\n\t\t\t\t\tconst resource = resourcesWithoutProjects[index];\n\t\t\t\t\tif (resource == null) return;\n\n\t\t\t\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\t\tfailures: [\n\t\t\t\t\t\t\ttoCollectionScopeFailure({ providerId: this.id, resourceId: resource.id }, drain.reason),\n\t\t\t\t\t\t],\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { resource, result } = drain.value;\n\t\t\t\tmetadata = mergeCollectionMetadata(metadata, result.metadata);\n\t\t\t\tconst projects = result.values\n\t\t\t\t\t.filter(project => project.resourceId === resource.id)\n\t\t\t\t\t.map(project => ({ ...project }));\n\t\t\t\tconst incomplete =\n\t\t\t\t\tresult.truncated === true ||\n\t\t\t\t\t(result.metadata != null && result.metadata.completeness !== 'complete');\n\t\t\t\tif (incomplete) {\n\t\t\t\t\tpartialProjects.push(...projects);\n\t\t\t\t\tif (\n\t\t\t\t\t\tresult.truncated === true &&\n\t\t\t\t\t\t(result.metadata == null || result.metadata.completeness === 'complete')\n\t\t\t\t\t) {\n\t\t\t\t\t\tmetadata = mergeCollectionMetadata(metadata, { completeness: 'partial' });\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Not stored when the cache was dropped while this read was in flight, but still returned below: it\n\t\t\t\t// is what this read found, only no longer trusted for the next one.\n\t\t\t\tif (!projectsCache.set(`${accessToken}:${resource.id}`, projects, { generation: generation })) {\n\t\t\t\t\tpartialProjects.push(...projects);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis._autolinks.delete(accessToken);\n\t\t\t});\n\t\t}\n\n\t\tconst values = resources.reduce<JiraProjectDescriptor[]>((projects, resource) => {\n\t\t\tconst resourceProjects = projectsCache.get(`${accessToken}:${resource.id}`);\n\t\t\tif (resourceProjects != null) {\n\t\t\t\tprojects.push(...resourceProjects);\n\t\t\t}\n\t\t\treturn projects;\n\t\t}, partialProjects);\n\n\t\tconst projectsByIdentity = new Map<string, JiraProjectDescriptor>();\n\t\tfor (const project of values) {\n\t\t\tconst identity = `${project.resourceId}:${project.id}`;\n\t\t\tif (!projectsByIdentity.has(identity)) {\n\t\t\t\tprojectsByIdentity.set(identity, project);\n\t\t\t}\n\t\t}\n\t\treturn { values: [...projectsByIdentity.values()], metadata: metadata };\n\t}\n\n\tprotected override async getProviderIssuesForProject(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.getProviderIssuesForProjectWithTruncation(session, project, options))?.values;\n\t}\n\n\tprotected override async getProviderIssuesForProjectWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<ProjectIssuesDrain | undefined> {\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\n\t\tconst api = await this.getProvidersApi();\n\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tconst fetchPage: JiraIssuePageFetcher = (scope, cursor) =>\n\t\t\tapi.getIssuesForProjectPaged(tokenWithInfo, project.name, project.resourceId, {\n\t\t\t\t...scope,\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t\tsort: options?.sort,\n\t\t\t});\n\t\tconst drainOptions: JiraDrainOptions = {\n\t\t\tmaxPages: maxPagesPerRequest,\n\t\t\tfailureScope: { providerId: this.id, resourceId: project.resourceId, projectId: project.name },\n\t\t\tproviderName: 'Jira',\n\t\t\t// A project this token can no longer see (deleted, or its browse permission removed) holds no issues\n\t\t\t// for it, and the site's project list that named it is stale: drop that list so the next read\n\t\t\t// re-reads it, instead of failing the whole provider on every read until a restart (#5907).\n\t\t\tisEmptyFailure: ex => {\n\t\t\t\tif (!isJiraMissingProjectError(ex)) return false;\n\n\t\t\t\tLogger.warn(`Jira project '${project.key}' no longer exists or is not visible`);\n\t\t\t\tthis._projects.delete(`${session.accessToken}:${project.resourceId}`);\n\t\t\t\tthis._autolinks.delete(session.accessToken);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\n\t\tif (options?.user != null) {\n\t\t\tconst read = await readUserScopedJiraIssues(\n\t\t\t\tfetchPage,\n\t\t\t\toptions.filters,\n\t\t\t\ttoUserIdentities(options.user, options),\n\t\t\t\tdrainOptions,\n\t\t\t);\n\t\t\tconst values = toUniqueJiraIssueShapes(read.issues, this);\n\t\t\treturn read.truncated\n\t\t\t\t? { values: values, truncated: true, recovery: 'none', metadata: read.metadata }\n\t\t\t\t: { values: values, truncated: false, metadata: read.metadata };\n\t\t}\n\n\t\tconst unscoped = await drainJiraIssues(fetchPage, {}, drainOptions);\n\t\tconst values = unscoped.issues\n\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'project' }))\n\t\t\t.filter((result): result is IssueShape => result !== undefined);\n\t\treturn unscoped.status !== 'complete'\n\t\t\t? {\n\t\t\t\t\tvalues: values,\n\t\t\t\t\ttruncated: true,\n\t\t\t\t\trecovery: unscoped.status === 'backstop' ? 'narrow-scope' : 'none',\n\t\t\t\t\tmetadata: unscoped.metadata,\n\t\t\t\t}\n\t\t\t: { values: values, truncated: false, metadata: unscoped.metadata };\n\t}\n\n\t/**\n\t * Searches a site's projects together for a user-scoped read: one JQL names up to\n\t * {@link JIRA_MAX_PROJECT_KEYS_PER_REQUEST} projects of one site and one user scope, past which the SDK refuses\n\t * the call rather than risk a query string Jira rejects.\n\t *\n\t * An unscoped read is never searched across projects: it drains every issue in the project, and its backstop is\n\t * reported as `narrow-scope` per project, which one search across projects could not attribute.\n\t */\n\tprotected override getProjectIssuesSearches(\n\t\trequests: readonly ProjectIssuesRequest<JiraProjectDescriptor>[],\n\t): number[][] | undefined {\n\t\treturn groupProjectIssuesSearches(\n\t\t\trequests,\n\t\t\t({ project, options }) =>\n\t\t\t\toptions.user != null\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tproject.resourceId,\n\t\t\t\t\t\t\toptions.user,\n\t\t\t\t\t\t\toptions.userId ?? '',\n\t\t\t\t\t\t\toptions.sort ?? '',\n\t\t\t\t\t\t\toptions.state ?? '',\n\t\t\t\t\t\t\toptions.filters?.join(',') ?? '',\n\t\t\t\t\t\t].join('\\0')\n\t\t\t\t\t: undefined,\n\t\t\tJIRA_MAX_PROJECT_KEYS_PER_REQUEST,\n\t\t);\n\t}\n\n\tprotected override async searchProviderProjectIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trequests: readonly ProjectIssuesRequest<JiraProjectDescriptor>[],\n\t): Promise<IssueShape[][] | undefined> {\n\t\t// Every request of a search shares its site and user scope (see `getProjectIssuesSearches`).\n\t\tconst { project, options } = requests[0];\n\t\tif (options.user == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst api = await this.getProvidersApi();\n\t\t// By key, not name: JQL resolves `project = \"<value>\"` against key first, so a name could read another\n\t\t// project's issues.\n\t\tconst projectKeys = requests.map(request => request.project.key);\n\t\tconst states = toProviderIssueStates(options.state);\n\n\t\treturn searchJiraProjectIssues(\n\t\t\t(userScope, cursor) =>\n\t\t\t\tapi.getIssuesForProjectsPaged(tokenWithInfo, projectKeys, project.resourceId, {\n\t\t\t\t\t...userScope,\n\t\t\t\t\tcursor: cursor,\n\t\t\t\t\tstates: states,\n\t\t\t\t\tsort: options.sort,\n\t\t\t\t}),\n\t\t\trequests.map(request => request.project.id),\n\t\t\toptions.filters,\n\t\t\ttoUserIdentities(options.user, options),\n\t\t\t{\n\t\t\t\tmaxPages: maxPagesPerRequest,\n\t\t\t\tfailureScope: { providerId: this.id, resourceId: project.resourceId },\n\t\t\t\tproviderName: 'Jira',\n\t\t\t},\n\t\t\tthis,\n\t\t);\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: JiraOrganizationDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation))?.values;\n\t}\n\n\t/**\n\t * Overridden so `state` reaches the per-site read, which the default drops. Still reports `truncated: false`,\n\t * as the default did: the per-site loop has no way to say it stopped early.\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: JiraOrganizationDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tconst myResources = resources ?? (await this.getProviderResourcesForUser(session));\n\t\tif (!myResources) return undefined;\n\n\t\tconst api = await this.getProvidersApi();\n\n\t\tconst results: IssueShape[] = [];\n\t\tfor (const resource of myResources) {\n\t\t\tif (cancellation?.aborted) break;\n\n\t\t\ttry {\n\t\t\t\tlet cursor = undefined;\n\t\t\t\tlet hasMore = false;\n\t\t\t\tlet requestCount = 0;\n\t\t\t\tdo {\n\t\t\t\t\tif (cancellation?.aborted) break;\n\n\t\t\t\t\tconst resourceIssues = await api.getIssuesForResourceForCurrentUser(\n\t\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t\tresource.id,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t\tstates: states,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\trequestCount += 1;\n\t\t\t\t\thasMore = resourceIssues.paging?.more ?? false;\n\t\t\t\t\tcursor = resourceIssues.paging?.cursor;\n\t\t\t\t\tconst formattedIssues = resourceIssues.values\n\t\t\t\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'account' }))\n\t\t\t\t\t\t.filter((result): result is IssueShape => result != null);\n\t\t\t\t\tif (formattedIssues.length > 0) {\n\t\t\t\t\t\tresults.push(...formattedIssues);\n\t\t\t\t\t}\n\t\t\t\t} while (requestCount < maxPagesPerRequest && hasMore);\n\t\t\t} catch (ex) {\n\t\t\t\t// TODO: We need a better way to message the failure to the user here.\n\t\t\t\t// This is a stopgap to prevent one bag org from throwing and preventing any issues from being returned.\n\t\t\t\tLogger.error(ex, 'searchProviderMyIssues');\n\t\t\t}\n\t\t}\n\n\t\treturn { values: results, truncated: false };\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t\t{ key }: { id: string; key: string },\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst issue = await api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resource.id,\n\t\t\tnumber: key,\n\t\t});\n\t\treturn issue != null ? toIssueShape(issue, this, { projection: 'point' }) : undefined;\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst apiResult = await api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resource.id,\n\t\t\tnumber: id,\n\t\t});\n\t\tconst issue = apiResult != null ? toIssueShape(apiResult, this, { projection: 'point' }) : undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\tprotected override async getProviderIssueByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresourceId: string,\n\t\tid: string,\n\t\tresourceUrl: string | undefined,\n\t): Promise<Issue | undefined> {\n\t\tif (resourceUrl == null) {\n\t\t\tthrow new Error('Jira direct issue reads require a resource URL');\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst apiResult = await api.getJiraIssueByKey(toTokenWithInfo(this.id, session), resourceId, resourceUrl, id);\n\t\tconst issue =\n\t\t\tapiResult != null\n\t\t\t\t? toIssueShape(apiResult, this, { reliableStateCategory: true, projection: 'batch' })\n\t\t\t\t: undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\t/**\n\t * The cheap check behind the batch issue read's etags: one bulk fetch per site and {@link jiraBulkFetchMaxKeys}\n\t * distinct keys, where {@link getProviderIssueByResourceId} sends one request per issue. A request that throws\n\t * rejects only its own targets' slots, with its error classified as the full read's would be.\n\t *\n\t * A target identified by a numeric issue id, which both reads accept as well as a key, is matched by the returned\n\t * issue's `id`; every other target by its key.\n\t *\n\t * Never proves an absence. Jira silently omits a key it can't find or show (listing it in no `issueErrors` either),\n\t * and answers a moved issue under its new key, which no longer matches the key asked for. Either way the target's\n\t * slot is rejected, so the full read, whose 404 does prove an absence, decides. When no target was answered and\n\t * nothing failed, the check declines instead, so a batch of only such keys costs a full read, not a failure.\n\t */\n\tprotected override async getProviderIssuesEtagFieldsByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { resourceId: string; identifier: string; resourceUrl?: string }[],\n\t): Promise<PromiseSettledResult<IssueEtagFields | undefined>[] | undefined> {\n\t\tconst slots = new Array<PromiseSettledResult<IssueEtagFields | undefined>>(targets.length);\n\t\tlet answered = false;\n\t\tlet failed = false;\n\n\t\t// Each site's distinct keys, matched case-insensitively as Jira matches them, with the targets asking for each.\n\t\tconst bySite = new Map<string, Map<string, number[]>>();\n\t\tfor (const [index, target] of targets.entries()) {\n\t\t\tif (target.resourceUrl == null) {\n\t\t\t\t// Required as the full read requires it, so a check never answers for a target the full read refuses.\n\t\t\t\tslots[index] = {\n\t\t\t\t\tstatus: 'rejected',\n\t\t\t\t\treason: new Error('Jira direct issue reads require a resource URL'),\n\t\t\t\t};\n\t\t\t\tfailed = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet keys = bySite.get(target.resourceId);\n\t\t\tif (keys == null) {\n\t\t\t\tkeys = new Map();\n\t\t\t\tbySite.set(target.resourceId, keys);\n\t\t\t}\n\n\t\t\tconst key = target.identifier.toUpperCase();\n\t\t\tlet indices = keys.get(key);\n\t\t\tif (indices == null) {\n\t\t\t\tindices = [];\n\t\t\t\tkeys.set(key, indices);\n\t\t\t}\n\t\t\tindices.push(index);\n\t\t}\n\n\t\tconst requests = [...bySite].flatMap(([resourceId, keys]) =>\n\t\t\tchunk([...keys], jiraBulkFetchMaxKeys).map(entries => ({ resourceId: resourceId, entries: entries })),\n\t\t);\n\t\tif (!requests.length) return slots;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst answers = await mapSettledBounded(requests, providerFanOutConcurrency, r =>\n\t\t\tapi.getJiraIssuesEtagFields(\n\t\t\t\ttokenWithInfo,\n\t\t\t\tr.resourceId,\n\t\t\t\tr.entries.map(([key]) => key),\n\t\t\t),\n\t\t);\n\n\t\tfor (const [i, answer] of answers.entries()) {\n\t\t\tconst { entries } = requests[i];\n\t\t\tif (answer.status === 'rejected') {\n\t\t\t\tfailed = true;\n\t\t\t\tfor (const [, indices] of entries) {\n\t\t\t\t\tfor (const index of indices) {\n\t\t\t\t\t\tslots[index] = answer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (answer.value.errorCount > 0) {\n\t\t\t\tfailed = true;\n\t\t\t}\n\n\t\t\t// By key or id, never by position: Jira returns the issues in its own order, and only the ones it found.\n\t\t\tconst byKey = new Map<string, JiraIssueEtagResponse>();\n\t\t\tconst byId = new Map<string, JiraIssueEtagResponse>();\n\t\t\tfor (const issue of answer.value.issues) {\n\t\t\t\tbyKey.set(issue.key.toUpperCase(), issue);\n\t\t\t\tbyId.set(issue.id, issue);\n\t\t\t}\n\n\t\t\tfor (const [key, indices] of entries) {\n\t\t\t\t// A key target never matches by id, so an issue returned under a different key (moved) is rejected.\n\t\t\t\tconst issue = numericIssueId.test(key) ? byId.get(key) : byKey.get(key);\n\t\t\t\tlet slot: PromiseSettledResult<IssueEtagFields | undefined>;\n\t\t\t\tif (issue == null) {\n\t\t\t\t\tslot = { status: 'rejected', reason: new Error(`Jira bulk fetch did not return ${key}`) };\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tslot = { status: 'fulfilled', value: toJiraIssueEtagFields(issue) };\n\t\t\t\t\t\tanswered = true;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tslot = { status: 'rejected', reason: ex };\n\t\t\t\t\t\tfailed = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const index of indices) {\n\t\t\t\t\tslots[index] = slot;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn answered || failed ? slots : undefined;\n\t}\n\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tthis._autolinks.clear();\n\t\tif (this._session == null) return;\n\n\t\tconst session = this._session;\n\t\tconst { accessToken } = session;\n\t\tconst organizationsGeneration = this._organizations.generation;\n\t\tconst projectsGeneration = this._projects.generation;\n\n\t\t// Persisted discovery seeds the caches only while it would still be fresh in them: read within the TTL, and\n\t\t// after the caches were last dropped. Otherwise a re-sync, which runs this again, would put back the very\n\t\t// project list it just dropped, and a restart would trust one read any time before (#5907).\n\t\tconst isFresh = (timestamp: unknown): timestamp is number =>\n\t\t\ttypeof timestamp === 'number' &&\n\t\t\ttimestamp > this._discoveryInvalidatedAt &&\n\t\t\tDate.now() - timestamp < discoveryCacheTtl;\n\n\t\tconst storedOrganizations = this.ctx.storage.get(`jira:${accessToken}:organizations`);\n\t\t// Projects persisted without their sites belong to a session whose sites were cleared below; ignore them.\n\t\tconst storedProjects =\n\t\t\tstoredOrganizations != null ? this.ctx.storage.get(`jira:${accessToken}:projects`) : undefined;\n\n\t\tlet organizations: JiraOrganizationDescriptor[] | undefined;\n\t\tif (storedOrganizations?.data != null && isFresh(storedOrganizations.timestamp)) {\n\t\t\tconst seeded = storedOrganizations.data.map((o: JiraOrganizationDescriptor) => ({ ...o }));\n\t\t\torganizations = seeded;\n\t\t\tthis._organizations.set(accessToken, seeded, {\n\t\t\t\tgeneration: organizationsGeneration,\n\t\t\t\tstoredAt: storedOrganizations.timestamp,\n\t\t\t});\n\t\t} else {\n\t\t\t// Stamped with when the read started, so the TTL counts from what it actually saw.\n\t\t\tconst readAt = Date.now();\n\t\t\torganizations = await this.getProviderResourcesForUser(session, true);\n\t\t\tif (storedOrganizations == null) {\n\t\t\t\t// Clear all other stored organizations and projects when our session changes\n\t\t\t\tawait this.ctx.storage.deleteWithPrefix('jira');\n\t\t\t}\n\t\t\t// Not persisted when the caches were dropped while it was in flight: it is then a read from before the\n\t\t\t// refresh, and the next start, which knows nothing of that refresh, would take it for fresh.\n\t\t\tif (this._organizations.generation === organizationsGeneration) {\n\t\t\t\tawait this.ctx.storage.store(`jira:${accessToken}:organizations`, {\n\t\t\t\t\tv: 1,\n\t\t\t\t\ttimestamp: readAt,\n\t\t\t\t\tdata: organizations,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (storedProjects?.data != null && isFresh(storedProjects.timestamp)) {\n\t\t\tconst projectsByResource = new Map<string, JiraProjectDescriptor[]>();\n\t\t\tfor (const project of storedProjects.data as JiraProjectDescriptor[]) {\n\t\t\t\tconst projects = projectsByResource.get(project.resourceId);\n\t\t\t\tif (projects == null) {\n\t\t\t\t\tprojectsByResource.set(project.resourceId, [{ ...project }]);\n\t\t\t\t} else if (!projects.some(p => p.id === project.id)) {\n\t\t\t\t\tprojects.push({ ...project });\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [resourceId, projects] of projectsByResource) {\n\t\t\t\tthis._projects.set(`${accessToken}:${resourceId}`, projects, {\n\t\t\t\t\tgeneration: projectsGeneration,\n\t\t\t\t\tstoredAt: storedProjects.timestamp,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (organizations?.length) {\n\t\t\tconst readAt = Date.now();\n\t\t\tconst projects = await this.getProviderProjectsForResources(session, organizations, true);\n\t\t\t// See the organizations above.\n\t\t\tif (this._projects.generation === projectsGeneration) {\n\t\t\t\tawait this.ctx.storage.store(`jira:${accessToken}:projects`, {\n\t\t\t\t\tv: 1,\n\t\t\t\t\ttimestamp: readAt,\n\t\t\t\t\tdata: projects,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\toverride invalidateDiscoveryCaches(): void {\n\t\tthis._discoveryInvalidatedAt = Date.now();\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._autolinks.clear();\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._autolinks.clear();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyCA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAC/E,MAAM,qBAAqB;;AAE3B,MAAM,iBAAiB;;;;;;;;;;;;AAavB,SAAS,iBAAiB,MAAc,SAA0E;CACjH,OAAO;EAAE,WAAW,QAAQ,UAAU;EAAM,SAAS;CAAK;AAC3D;AAaA,IAAa,kBAAb,cAAqC,kBAAqD;CACzF,eAAqE;CACrE,KAAS;CACT,MAAyB,KAAK;CAC9B,OAAwB;CAExB,IAAI,SAAiB;EACpB,OAAO,SAAS;CACjB;CAEA,IAAc,aAAqB;EAClC,OAAO;CACR;;;;;;;CAQA,6BAA8B,IAAI,IAGhC;CACF,mCAAoC,IAAI,IAAuE;CAE/G,MAAe,YAAuE;EAErF,IAAI,EADc,KAAK,kBAAmB,MAAM,KAAK,Y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AEH;EAEA,IAAI,gBAAgB,QAAQ,QAAQ,QAAQ,eAAe,SAAS,GAAG;GACtE,MAAM,qCAAqB,IAAI,IAAqC;GACpE,KAAK,MAAM,WAAW,eAAe,MAAiC;IACrE,MAAM,WAAW,mBAAmB,IAAI,QAAQ,UAAU;IAC1D,IAAI,YAAY,MACf,mBAAmB,IAAI,QAAQ,YAAY,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC;SACrD,IAAI,CAAC,SAAS,MAAK,MAAK,EAAE,OAAO,QAAQ,EAAE,GACjD,SAAS,KAAK,EAAE,GAAG,QAAQ,CAAC;GAE9B;GACA,KAAK,MAAM,CAAC,YAAY,aAAa,oBACpC,KAAK,UAAU,IAAI,GAAG,YAAY,GAAG,cAAc,UAAU;IAC5D,YAAY;IACZ,UAAU,eAAe;GAC1B,CAAC;EAEH,OAAO,IAAI,eAAe,QAAQ;GACjC,MAAM,SAAS,KAAK,IAAI;GACxB,MAAM,WAAW,MAAM,KAAK,gCAAgC,SAAS,eAAe,IAAI;GAExF,IAAI,KAAK,UAAU,eAAe,oBACjC,MAAM,KAAK,IAAI,QAAQ,MAAM,QAAQ,YAAY,YAAY;IAC5D,GAAG;IACH,WAAW;IACX,MAAM;GACP,CAAC;EAEH;CACD;CAEA,4BAA2C;EAC1C,KAAK,0BAA0B,KAAK,IAAI;EACxC,KAAK,eAAe,MAAM;EAC1B,KAAK,UAAU,MAAM;EACrB,KAAK,WAAW,MAAM;CACvB;CAEA,uBAAgD;EAC/C,KAAK,eAAe,MAAM;EAC1B,KAAK,UAAU,MAAM;EACrB,KAAK,WAAW,MAAM;CACvB;AACD"}
|
|
1
|
+
{"version":3,"file":"jira.js","names":[],"sources":["../../../../../plus/integrations/src/providers/jira.ts"],"sourcesContent":["import type { CollectionMetadata } from '@gitkraken/provider-apis';\nimport { JIRA_MAX_PROJECT_KEYS_PER_REQUEST } from '@gitkraken/provider-apis';\nimport * as l10n from '@vscode/l10n';\nimport type { Account } from '@gitlens/git/models/author.js';\nimport type { AutolinkReference, DynamicAutolinkReference } from '@gitlens/git/models/autolink.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { IssueResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { chunk } from '@gitlens/utils/array.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { mapSettledBounded } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport type { ProviderRefusal } from '../collectionMetadata.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { IssuesCloudHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IssueEtagFields } from '../models/integration.js';\nimport type {\n\tAccountWideIssuesResult,\n\tIssuesForProjectOptions,\n\tProjectIssuesDrain,\n\tProjectIssuesRequest,\n\tSearchMyIssuesOptions,\n} from '../models/issueReads.js';\nimport { groupProjectIssuesSearches, IssuesIntegration } from '../models/issuesIntegration.js';\nimport type { JiraIssueEtagResponse } from './jiraIssueByKey.js';\nimport { jiraBulkFetchMaxKeys, toJiraIssueEtagFields } from './jiraIssueByKey.js';\nimport type { ProviderApiCollectionResult } from './models.js';\nimport { providersMetadata, toAccount, toIssueShape, toProviderIssueStates } from './models.js';\nimport { isJiraMissingProjectError } from './providerErrors.js';\nimport { DiscoveryCache, discoveryCacheTtl } from './utils/discoveryCache.js';\nimport type { JiraDrainOptions, JiraIssuePageFetcher } from './utils/jiraIssueDrains.js';\nimport {\n\tdrainJiraIssues,\n\treadUserScopedJiraIssues,\n\tsearchJiraProjectIssues,\n\ttoUniqueJiraIssueShapes,\n} from './utils/jiraIssueDrains.js';\nimport { collectProviderPagedResult, mergeCollectionMetadata } from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[IssuesCloudHostIntegrationId.Jira];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\nconst maxPagesPerRequest = 10;\n/** A numeric issue id, which Jira's issue reads accept in place of a key. */\nconst numericIssueId = /^\\d+$/;\n\n/**\n * `assignee` and `creator` are user FIELDS: Jira resolves an accountId against the directory, which is the identity\n * that keeps matching once a display name cannot be looked up — a deactivated account, or a profile whose visibility\n * hides the name. Measured against a live site: a deactivated assignee returns its issues by accountId and an empty\n * page by display name, and Jira reports that miss as a successful empty search rather than an error, so the list\n * simply appears empty.\n *\n * `mention` is NOT a user field. It is `comment ~ \"...\"`, a free-text search over comment bodies, so an accountId\n * matches nothing there and the display name is the only value that can. Hence the id is applied to the first two\n * and the handle is kept for the third, rather than swapping `user` wholesale.\n */\nfunction toUserIdentities(user: string, options: IssuesForProjectOptions): { userField: string; mention: string } {\n\treturn { userField: options.userId ?? user, mention: user };\n}\n\nexport type JiraBaseDescriptor = IssueResourceDescriptor;\n\nexport interface JiraOrganizationDescriptor extends JiraBaseDescriptor {\n\turl: string;\n\tavatarUrl: string;\n}\n\nexport interface JiraProjectDescriptor extends JiraBaseDescriptor {\n\tresourceId: string;\n}\n\nexport class JiraIntegration extends IssuesIntegration<IssuesCloudHostIntegrationId.Jira> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = IssuesCloudHostIntegrationId.Jira;\n\tprotected readonly key = this.id;\n\treadonly name: string = 'Jira';\n\n\tget domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\tprotected get apiBaseUrl(): string {\n\t\treturn 'https://api.atlassian.com';\n\t}\n\n\t/**\n\t * Built from the sites and their projects, so it follows them: rebuilt when a site's project list changes or the\n\t * caches are dropped, and once older than {@link discoveryCacheTtl}. An expired set is still served while it is\n\t * rebuilt in the background, because autolinks are read on every render of a commit message and must not wait\n\t * on the network, nor go empty just because nothing read the projects for a while (#5907).\n\t */\n\tprivate readonly _autolinks = new Map<\n\t\tstring,\n\t\t{ autolinks: (AutolinkReference | DynamicAutolinkReference)[]; builtAt: number }\n\t>();\n\tprivate readonly _autolinksBuilds = new Map<string, Promise<(AutolinkReference | DynamicAutolinkReference)[]>>();\n\n\toverride async autolinks(): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected || this._session == null) return [];\n\n\t\tconst session = this._session;\n\t\tconst cached = this._autolinks.get(session.accessToken);\n\t\t// A session kept through a failed refresh is expired: building with it would send that token to the provider\n\t\t// on every render, so serve whatever was built before (none after a forced re-sync) until a read refreshes it.\n\t\tif (this.connectionExpired === true) return cached?.autolinks ?? [];\n\t\tif (cached == null) return this.buildAutolinks(session);\n\n\t\tif (Date.now() - cached.builtAt >= discoveryCacheTtl) {\n\t\t\tvoid this.buildAutolinks(session);\n\t\t}\n\t\treturn cached.autolinks;\n\t}\n\n\t/** One build per token at a time: concurrent renders share it rather than each re-reading sites and projects. */\n\tprivate buildAutolinks(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tlet build = this._autolinksBuilds.get(accessToken);\n\t\tif (build == null) {\n\t\t\tbuild = this.buildAutolinksCore(session).finally(() => this._autolinksBuilds.delete(accessToken));\n\t\t\tthis._autolinksBuilds.set(accessToken, build);\n\t\t}\n\t\treturn build;\n\t}\n\n\tprivate async buildAutolinksCore(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tconst generation = this._projects.generation;\n\t\ttry {\n\t\t\tconst organizations = await this.getProviderResourcesForUser(session);\n\t\t\tif (!organizations?.length) return [];\n\n\t\t\t// Served from the cache for every site whose projects are still fresh; only the rest are read.\n\t\t\tconst { values: projects, metadata } = await this.getProviderProjectsForResourcesWithMetadata(\n\t\t\t\tsession,\n\t\t\t\torganizations,\n\t\t\t);\n\n\t\t\tconst autolinks: (AutolinkReference | DynamicAutolinkReference)[] = [];\n\t\t\tfor (const project of projects) {\n\t\t\t\tconst organization = organizations.find(o => o.id === project.resourceId);\n\t\t\t\tif (organization == null) continue;\n\n\t\t\t\tconst dashedPrefix = `${project.key}-`;\n\t\t\t\tconst underscoredPrefix = `${project.key}_`;\n\t\t\t\tautolinks.push({\n\t\t\t\t\tprefix: dashedPrefix,\n\t\t\t\t\turl: `${organization.url}/browse/${dashedPrefix}<num>`,\n\t\t\t\t\talphanumeric: false,\n\t\t\t\t\tignoreCase: false,\n\t\t\t\t\ttitle: l10n.t('Open Issue {0} on {1}', `${dashedPrefix}<num>`, organization.name),\n\n\t\t\t\t\ttype: 'issue',\n\t\t\t\t\tdescription: l10n.t('{0} Issue {1}', organization.name, `${dashedPrefix}<num>`),\n\t\t\t\t\tdescriptor: { ...organization },\n\t\t\t\t});\n\t\t\t\tautolinks.push({\n\t\t\t\t\tprefix: underscoredPrefix,\n\t\t\t\t\turl: `${organization.url}/browse/${dashedPrefix}<num>`,\n\t\t\t\t\talphanumeric: false,\n\t\t\t\t\tignoreCase: false,\n\t\t\t\t\treferenceType: 'branch',\n\t\t\t\t\ttitle: l10n.t('Open Issue {0} on {1}', `${dashedPrefix}<num>`, organization.name),\n\n\t\t\t\t\ttype: 'issue',\n\t\t\t\t\tdescription: l10n.t('{0} Issue {1}', organization.name, `${dashedPrefix}<num>`),\n\t\t\t\t\tdescriptor: { ...organization },\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// A set missing a site's projects is served but not kept, so the next call tries that site again; one\n\t\t\t// built from projects read before the caches were dropped is not kept either.\n\t\t\tconst complete = metadata == null || metadata.completeness === 'complete';\n\t\t\tif (complete && this._projects.generation === generation) {\n\t\t\t\tthis._autolinks.set(accessToken, { autolinks: autolinks, builtAt: Date.now() });\n\t\t\t}\n\t\t\treturn autolinks;\n\t\t} catch (ex) {\n\t\t\t// Autolinks are decoration: keep serving the last set rather than failing the render that asked.\n\t\t\tLogger.error(ex, 'JiraIntegration.autolinks');\n\t\t\treturn this._autolinks.get(accessToken)?.autolinks ?? [];\n\t\t}\n\t}\n\n\tprotected override async getProviderAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api.getCurrentUserForResource(toTokenWithInfo(this.id, session), resource.id);\n\n\t\tif (user == null) return undefined;\n\t\treturn toAccount(user, this);\n\t}\n\n\t/** The site-list request the resource cache would otherwise answer; see `IntegrationBase.validateCredential`. */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tif ((await api.getJiraResourcesForCurrentUser(toTokenWithInfo(this.id, session))) == null) {\n\t\t\tthrow new Error('Jira did not confirm the credential');\n\t\t}\n\t}\n\n\t/**\n\t * Atlassian's `401` for a token missing a scope the request needs, which a reconnect fixes by consenting to it\n\t * again; see `IntegrationBase.isCredentialRefusal`. Atlassian gives the same answer to a malformed request URL,\n\t * so a request the SDK built wrong would read as the credential's too.\n\t */\n\tprotected override isCredentialRefusal(refusal: ProviderRefusal): boolean {\n\t\treturn refusal.status === 401 && /scope does not match/i.test(refusal.detail ?? '');\n\t}\n\n\t/**\n\t * The sites and the projects discovered under them, both of which expire and are dropped on a re-sync, so a site\n\t * or project created or deleted mid-session is picked up (#5907). Keyed by token, and projects by token and site.\n\t */\n\tprivate readonly _organizations = new DiscoveryCache<JiraOrganizationDescriptor[]>();\n\tprivate readonly _projects = new DiscoveryCache<JiraProjectDescriptor[]>();\n\t/** When the caches were last dropped; a persisted discovery read before then is as stale as they were. */\n\tprivate _discoveryInvalidatedAt = 0;\n\n\tprotected override async getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\tconst { accessToken } = session;\n\n\t\tconst cachedResources = this._organizations.get(accessToken);\n\t\tif (cachedResources != null && !force) return cachedResources;\n\n\t\tconst generation = this._organizations.generation;\n\t\tconst api = await this.getProvidersApi();\n\t\tconst resources = await api.getJiraResourcesForCurrentUser(toTokenWithInfo(this.id, session));\n\t\tconst organizations = resources?.map(r => ({ ...r, key: r.id }));\n\t\tif (organizations == null) {\n\t\t\tthis._organizations.delete(accessToken);\n\t\t\treturn undefined;\n\t\t}\n\n\t\tthis._organizations.set(accessToken, organizations, { generation: generation });\n\t\treturn organizations;\n\t}\n\n\tprotected override async getProviderProjectsForResources(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t\tforce: boolean = false,\n\t): Promise<JiraProjectDescriptor[] | undefined> {\n\t\treturn (await this.getProviderProjectsForResourcesWithMetadata(session, resources, force)).values;\n\t}\n\n\tprotected override async getProviderProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t\tforce: boolean = false,\n\t): Promise<ProviderApiCollectionResult<JiraProjectDescriptor>> {\n\t\tconst { accessToken } = session;\n\t\tconst projectsCache = this._projects;\n\t\tconst generation = projectsCache.generation;\n\n\t\tlet resourcesWithoutProjects = [];\n\t\tif (force) {\n\t\t\tresourcesWithoutProjects = resources;\n\t\t} else {\n\t\t\tfor (const resource of resources) {\n\t\t\t\tconst resourceKey = `${accessToken}:${resource.id}`;\n\t\t\t\tconst cachedProjects = projectsCache.get(resourceKey);\n\t\t\t\tif (cachedProjects == null) {\n\t\t\t\t\tresourcesWithoutProjects.push(resource);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\tconst partialProjects: JiraProjectDescriptor[] = [];\n\t\tif (resourcesWithoutProjects.length > 0) {\n\t\t\tconst api = await this.getProvidersApi();\n\t\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\t\tconst drains = await Promise.allSettled(\n\t\t\t\tresourcesWithoutProjects.map(async resource => ({\n\t\t\t\t\tresource: resource,\n\t\t\t\t\tresult: await collectProviderPagedResult(\n\t\t\t\t\t\tcursor => api.getJiraProjectsForResource(tokenWithInfo, resource.id, { cursor: cursor }),\n\t\t\t\t\t\tmaxPagesPerRequest,\n\t\t\t\t\t\t{ providerId: this.id, resourceId: resource.id },\n\t\t\t\t\t),\n\t\t\t\t})),\n\t\t\t);\n\n\t\t\tdrains.forEach((drain, index) => {\n\t\t\t\tif (drain.status === 'rejected') {\n\t\t\t\t\tconst resource = resourcesWithoutProjects[index];\n\t\t\t\t\tif (resource == null) return;\n\n\t\t\t\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\t\tfailures: [\n\t\t\t\t\t\t\ttoCollectionScopeFailure({ providerId: this.id, resourceId: resource.id }, drain.reason),\n\t\t\t\t\t\t],\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { resource, result } = drain.value;\n\t\t\t\tmetadata = mergeCollectionMetadata(metadata, result.metadata);\n\t\t\t\tconst projects = result.values\n\t\t\t\t\t.filter(project => project.resourceId === resource.id)\n\t\t\t\t\t.map(project => ({ ...project }));\n\t\t\t\tconst incomplete =\n\t\t\t\t\tresult.truncated === true ||\n\t\t\t\t\t(result.metadata != null && result.metadata.completeness !== 'complete');\n\t\t\t\tif (incomplete) {\n\t\t\t\t\tpartialProjects.push(...projects);\n\t\t\t\t\tif (\n\t\t\t\t\t\tresult.truncated === true &&\n\t\t\t\t\t\t(result.metadata == null || result.metadata.completeness === 'complete')\n\t\t\t\t\t) {\n\t\t\t\t\t\tmetadata = mergeCollectionMetadata(metadata, { completeness: 'partial' });\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Not stored when the cache was dropped while this read was in flight, but still returned below: it\n\t\t\t\t// is what this read found, only no longer trusted for the next one.\n\t\t\t\tif (!projectsCache.set(`${accessToken}:${resource.id}`, projects, { generation: generation })) {\n\t\t\t\t\tpartialProjects.push(...projects);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis._autolinks.delete(accessToken);\n\t\t\t});\n\t\t}\n\n\t\tconst values = resources.reduce<JiraProjectDescriptor[]>((projects, resource) => {\n\t\t\tconst resourceProjects = projectsCache.get(`${accessToken}:${resource.id}`);\n\t\t\tif (resourceProjects != null) {\n\t\t\t\tprojects.push(...resourceProjects);\n\t\t\t}\n\t\t\treturn projects;\n\t\t}, partialProjects);\n\n\t\tconst projectsByIdentity = new Map<string, JiraProjectDescriptor>();\n\t\tfor (const project of values) {\n\t\t\tconst identity = `${project.resourceId}:${project.id}`;\n\t\t\tif (!projectsByIdentity.has(identity)) {\n\t\t\t\tprojectsByIdentity.set(identity, project);\n\t\t\t}\n\t\t}\n\t\treturn { values: [...projectsByIdentity.values()], metadata: metadata };\n\t}\n\n\tprotected override async getProviderIssuesForProject(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.getProviderIssuesForProjectWithTruncation(session, project, options))?.values;\n\t}\n\n\tprotected override async getProviderIssuesForProjectWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: JiraProjectDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<ProjectIssuesDrain | undefined> {\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\n\t\tconst api = await this.getProvidersApi();\n\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tconst fetchPage: JiraIssuePageFetcher = (scope, cursor) =>\n\t\t\tapi.getIssuesForProjectPaged(tokenWithInfo, project.name, project.resourceId, {\n\t\t\t\t...scope,\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t\tsort: options?.sort,\n\t\t\t});\n\t\tconst drainOptions: JiraDrainOptions = {\n\t\t\tmaxPages: maxPagesPerRequest,\n\t\t\tfailureScope: { providerId: this.id, resourceId: project.resourceId, projectId: project.name },\n\t\t\tproviderName: 'Jira',\n\t\t\t// A project this token can no longer see (deleted, or its browse permission removed) holds no issues\n\t\t\t// for it, and the site's project list that named it is stale: drop that list so the next read\n\t\t\t// re-reads it, instead of failing the whole provider on every read until a restart (#5907).\n\t\t\tisEmptyFailure: ex => {\n\t\t\t\tif (!isJiraMissingProjectError(ex)) return false;\n\n\t\t\t\tLogger.warn(`Jira project '${project.key}' no longer exists or is not visible`);\n\t\t\t\tthis._projects.delete(`${session.accessToken}:${project.resourceId}`);\n\t\t\t\tthis._autolinks.delete(session.accessToken);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t};\n\n\t\tif (options?.user != null) {\n\t\t\tconst read = await readUserScopedJiraIssues(\n\t\t\t\tfetchPage,\n\t\t\t\toptions.filters,\n\t\t\t\ttoUserIdentities(options.user, options),\n\t\t\t\tdrainOptions,\n\t\t\t);\n\t\t\tconst values = toUniqueJiraIssueShapes(read.issues, this);\n\t\t\treturn read.truncated\n\t\t\t\t? { values: values, truncated: true, recovery: 'none', metadata: read.metadata }\n\t\t\t\t: { values: values, truncated: false, metadata: read.metadata };\n\t\t}\n\n\t\tconst unscoped = await drainJiraIssues(fetchPage, {}, drainOptions);\n\t\tconst values = unscoped.issues\n\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'project' }))\n\t\t\t.filter((result): result is IssueShape => result !== undefined);\n\t\treturn unscoped.status !== 'complete'\n\t\t\t? {\n\t\t\t\t\tvalues: values,\n\t\t\t\t\ttruncated: true,\n\t\t\t\t\trecovery: unscoped.status === 'backstop' ? 'narrow-scope' : 'none',\n\t\t\t\t\tmetadata: unscoped.metadata,\n\t\t\t\t}\n\t\t\t: { values: values, truncated: false, metadata: unscoped.metadata };\n\t}\n\n\t/**\n\t * Searches a site's projects together for a user-scoped read: one JQL names up to\n\t * {@link JIRA_MAX_PROJECT_KEYS_PER_REQUEST} projects of one site and one user scope, past which the SDK refuses\n\t * the call rather than risk a query string Jira rejects.\n\t *\n\t * An unscoped read is never searched across projects: it drains every issue in the project, and its backstop is\n\t * reported as `narrow-scope` per project, which one search across projects could not attribute.\n\t */\n\tprotected override getProjectIssuesSearches(\n\t\trequests: readonly ProjectIssuesRequest<JiraProjectDescriptor>[],\n\t): number[][] | undefined {\n\t\treturn groupProjectIssuesSearches(\n\t\t\trequests,\n\t\t\t({ project, options }) =>\n\t\t\t\toptions.user != null\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tproject.resourceId,\n\t\t\t\t\t\t\toptions.user,\n\t\t\t\t\t\t\toptions.userId ?? '',\n\t\t\t\t\t\t\toptions.sort ?? '',\n\t\t\t\t\t\t\toptions.state ?? '',\n\t\t\t\t\t\t\toptions.filters?.join(',') ?? '',\n\t\t\t\t\t\t].join('\\0')\n\t\t\t\t\t: undefined,\n\t\t\tJIRA_MAX_PROJECT_KEYS_PER_REQUEST,\n\t\t);\n\t}\n\n\tprotected override async searchProviderProjectIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trequests: readonly ProjectIssuesRequest<JiraProjectDescriptor>[],\n\t): Promise<IssueShape[][] | undefined> {\n\t\t// Every request of a search shares its site and user scope (see `getProjectIssuesSearches`).\n\t\tconst { project, options } = requests[0];\n\t\tif (options.user == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst api = await this.getProvidersApi();\n\t\t// By key, not name: JQL resolves `project = \"<value>\"` against key first, so a name could read another\n\t\t// project's issues.\n\t\tconst projectKeys = requests.map(request => request.project.key);\n\t\tconst states = toProviderIssueStates(options.state);\n\n\t\treturn searchJiraProjectIssues(\n\t\t\t(userScope, cursor) =>\n\t\t\t\tapi.getIssuesForProjectsPaged(tokenWithInfo, projectKeys, project.resourceId, {\n\t\t\t\t\t...userScope,\n\t\t\t\t\tcursor: cursor,\n\t\t\t\t\tstates: states,\n\t\t\t\t\tsort: options.sort,\n\t\t\t\t}),\n\t\t\trequests.map(request => request.project.id),\n\t\t\toptions.filters,\n\t\t\ttoUserIdentities(options.user, options),\n\t\t\t{\n\t\t\t\tmaxPages: maxPagesPerRequest,\n\t\t\t\tfailureScope: { providerId: this.id, resourceId: project.resourceId },\n\t\t\t\tproviderName: 'Jira',\n\t\t\t},\n\t\t\tthis,\n\t\t);\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: JiraOrganizationDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation))?.values;\n\t}\n\n\t/**\n\t * Overridden so `state` reaches the per-site read, which the default drops. Still reports `truncated: false`,\n\t * as the default did: the per-site loop has no way to say it stopped early.\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: JiraOrganizationDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tconst myResources = resources ?? (await this.getProviderResourcesForUser(session));\n\t\tif (!myResources) return undefined;\n\n\t\tconst api = await this.getProvidersApi();\n\n\t\tconst results: IssueShape[] = [];\n\t\tfor (const resource of myResources) {\n\t\t\tif (cancellation?.aborted) break;\n\n\t\t\ttry {\n\t\t\t\tlet cursor = undefined;\n\t\t\t\tlet hasMore = false;\n\t\t\t\tlet requestCount = 0;\n\t\t\t\tdo {\n\t\t\t\t\tif (cancellation?.aborted) break;\n\n\t\t\t\t\tconst resourceIssues = await api.getIssuesForResourceForCurrentUser(\n\t\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t\tresource.id,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t\tstates: states,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t\trequestCount += 1;\n\t\t\t\t\thasMore = resourceIssues.paging?.more ?? false;\n\t\t\t\t\tcursor = resourceIssues.paging?.cursor;\n\t\t\t\t\tconst formattedIssues = resourceIssues.values\n\t\t\t\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'account' }))\n\t\t\t\t\t\t.filter((result): result is IssueShape => result != null);\n\t\t\t\t\tif (formattedIssues.length > 0) {\n\t\t\t\t\t\tresults.push(...formattedIssues);\n\t\t\t\t\t}\n\t\t\t\t} while (requestCount < maxPagesPerRequest && hasMore);\n\t\t\t} catch (ex) {\n\t\t\t\t// TODO: We need a better way to message the failure to the user here.\n\t\t\t\t// This is a stopgap to prevent one bag org from throwing and preventing any issues from being returned.\n\t\t\t\tLogger.error(ex, 'searchProviderMyIssues');\n\t\t\t}\n\t\t}\n\n\t\treturn { values: results, truncated: false };\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t\t{ key }: { id: string; key: string },\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst issue = await api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resource.id,\n\t\t\tnumber: key,\n\t\t});\n\t\treturn issue != null ? toIssueShape(issue, this, { projection: 'point' }) : undefined;\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: JiraOrganizationDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst apiResult = await api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resource.id,\n\t\t\tnumber: id,\n\t\t});\n\t\tconst issue = apiResult != null ? toIssueShape(apiResult, this, { projection: 'point' }) : undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\tprotected override async getProviderIssueByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresourceId: string,\n\t\tid: string,\n\t\tresourceUrl: string | undefined,\n\t): Promise<Issue | undefined> {\n\t\tif (resourceUrl == null) {\n\t\t\tthrow new Error('Jira direct issue reads require a resource URL');\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst apiResult = await api.getJiraIssueByKey(toTokenWithInfo(this.id, session), resourceId, resourceUrl, id);\n\t\tconst issue =\n\t\t\tapiResult != null\n\t\t\t\t? toIssueShape(apiResult, this, { reliableStateCategory: true, projection: 'batch' })\n\t\t\t\t: undefined;\n\t\treturn issue != null ? { ...issue, type: 'issue' } : undefined;\n\t}\n\n\t/**\n\t * The cheap check behind the batch issue read's etags: one bulk fetch per site and {@link jiraBulkFetchMaxKeys}\n\t * distinct keys, where {@link getProviderIssueByResourceId} sends one request per issue. A request that throws\n\t * rejects only its own targets' slots, with its error classified as the full read's would be.\n\t *\n\t * A target identified by a numeric issue id, which both reads accept as well as a key, is matched by the returned\n\t * issue's `id`; every other target by its key.\n\t *\n\t * Never proves an absence. Jira silently omits a key it can't find or show (listing it in no `issueErrors` either),\n\t * and answers a moved issue under its new key, which no longer matches the key asked for. Either way the target's\n\t * slot is rejected, so the full read, whose 404 does prove an absence, decides. When no target was answered and\n\t * nothing failed, the check declines instead, so a batch of only such keys costs a full read, not a failure.\n\t */\n\tprotected override async getProviderIssuesEtagFieldsByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { resourceId: string; identifier: string; resourceUrl?: string }[],\n\t): Promise<PromiseSettledResult<IssueEtagFields | undefined>[] | undefined> {\n\t\tconst slots = new Array<PromiseSettledResult<IssueEtagFields | undefined>>(targets.length);\n\t\tlet answered = false;\n\t\tlet failed = false;\n\n\t\t// Each site's distinct keys, matched case-insensitively as Jira matches them, with the targets asking for each.\n\t\tconst bySite = new Map<string, Map<string, number[]>>();\n\t\tfor (const [index, target] of targets.entries()) {\n\t\t\tif (target.resourceUrl == null) {\n\t\t\t\t// Required as the full read requires it, so a check never answers for a target the full read refuses.\n\t\t\t\tslots[index] = {\n\t\t\t\t\tstatus: 'rejected',\n\t\t\t\t\treason: new Error('Jira direct issue reads require a resource URL'),\n\t\t\t\t};\n\t\t\t\tfailed = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet keys = bySite.get(target.resourceId);\n\t\t\tif (keys == null) {\n\t\t\t\tkeys = new Map();\n\t\t\t\tbySite.set(target.resourceId, keys);\n\t\t\t}\n\n\t\t\tconst key = target.identifier.toUpperCase();\n\t\t\tlet indices = keys.get(key);\n\t\t\tif (indices == null) {\n\t\t\t\tindices = [];\n\t\t\t\tkeys.set(key, indices);\n\t\t\t}\n\t\t\tindices.push(index);\n\t\t}\n\n\t\tconst requests = [...bySite].flatMap(([resourceId, keys]) =>\n\t\t\tchunk([...keys], jiraBulkFetchMaxKeys).map(entries => ({ resourceId: resourceId, entries: entries })),\n\t\t);\n\t\tif (!requests.length) return slots;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst answers = await mapSettledBounded(requests, providerFanOutConcurrency, r =>\n\t\t\tapi.getJiraIssuesEtagFields(\n\t\t\t\ttokenWithInfo,\n\t\t\t\tr.resourceId,\n\t\t\t\tr.entries.map(([key]) => key),\n\t\t\t),\n\t\t);\n\n\t\tfor (const [i, answer] of answers.entries()) {\n\t\t\tconst { entries } = requests[i];\n\t\t\tif (answer.status === 'rejected') {\n\t\t\t\tfailed = true;\n\t\t\t\tfor (const [, indices] of entries) {\n\t\t\t\t\tfor (const index of indices) {\n\t\t\t\t\t\tslots[index] = answer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (answer.value.errorCount > 0) {\n\t\t\t\tfailed = true;\n\t\t\t}\n\n\t\t\t// By key or id, never by position: Jira returns the issues in its own order, and only the ones it found.\n\t\t\tconst byKey = new Map<string, JiraIssueEtagResponse>();\n\t\t\tconst byId = new Map<string, JiraIssueEtagResponse>();\n\t\t\tfor (const issue of answer.value.issues) {\n\t\t\t\tbyKey.set(issue.key.toUpperCase(), issue);\n\t\t\t\tbyId.set(issue.id, issue);\n\t\t\t}\n\n\t\t\tfor (const [key, indices] of entries) {\n\t\t\t\t// A key target never matches by id, so an issue returned under a different key (moved) is rejected.\n\t\t\t\tconst issue = numericIssueId.test(key) ? byId.get(key) : byKey.get(key);\n\t\t\t\tlet slot: PromiseSettledResult<IssueEtagFields | undefined>;\n\t\t\t\tif (issue == null) {\n\t\t\t\t\tslot = { status: 'rejected', reason: new Error(`Jira bulk fetch did not return ${key}`) };\n\t\t\t\t} else {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tslot = { status: 'fulfilled', value: toJiraIssueEtagFields(issue) };\n\t\t\t\t\t\tanswered = true;\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tslot = { status: 'rejected', reason: ex };\n\t\t\t\t\t\tfailed = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const index of indices) {\n\t\t\t\t\tslots[index] = slot;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn answered || failed ? slots : undefined;\n\t}\n\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tthis._autolinks.clear();\n\t\tif (this._session == null) return;\n\n\t\tconst session = this._session;\n\t\tconst { accessToken } = session;\n\t\tconst organizationsGeneration = this._organizations.generation;\n\t\tconst projectsGeneration = this._projects.generation;\n\n\t\t// Persisted discovery seeds the caches only while it would still be fresh in them: read within the TTL, and\n\t\t// after the caches were last dropped. Otherwise a re-sync, which runs this again, would put back the very\n\t\t// project list it just dropped, and a restart would trust one read any time before (#5907).\n\t\tconst isFresh = (timestamp: unknown): timestamp is number =>\n\t\t\ttypeof timestamp === 'number' &&\n\t\t\ttimestamp > this._discoveryInvalidatedAt &&\n\t\t\tDate.now() - timestamp < discoveryCacheTtl;\n\n\t\tconst storedOrganizations = this.ctx.storage.get(`jira:${accessToken}:organizations`);\n\t\t// Projects persisted without their sites belong to a session whose sites were cleared below; ignore them.\n\t\tconst storedProjects =\n\t\t\tstoredOrganizations != null ? this.ctx.storage.get(`jira:${accessToken}:projects`) : undefined;\n\n\t\tlet organizations: JiraOrganizationDescriptor[] | undefined;\n\t\tif (storedOrganizations?.data != null && isFresh(storedOrganizations.timestamp)) {\n\t\t\tconst seeded = storedOrganizations.data.map((o: JiraOrganizationDescriptor) => ({ ...o }));\n\t\t\torganizations = seeded;\n\t\t\tthis._organizations.set(accessToken, seeded, {\n\t\t\t\tgeneration: organizationsGeneration,\n\t\t\t\tstoredAt: storedOrganizations.timestamp,\n\t\t\t});\n\t\t} else {\n\t\t\t// Stamped with when the read started, so the TTL counts from what it actually saw.\n\t\t\tconst readAt = Date.now();\n\t\t\torganizations = await this.getProviderResourcesForUser(session, true);\n\t\t\tif (storedOrganizations == null) {\n\t\t\t\t// Clear all other stored organizations and projects when our session changes\n\t\t\t\tawait this.ctx.storage.deleteWithPrefix('jira');\n\t\t\t}\n\t\t\t// Not persisted when the caches were dropped while it was in flight: it is then a read from before the\n\t\t\t// refresh, and the next start, which knows nothing of that refresh, would take it for fresh.\n\t\t\tif (this._organizations.generation === organizationsGeneration) {\n\t\t\t\tawait this.ctx.storage.store(`jira:${accessToken}:organizations`, {\n\t\t\t\t\tv: 1,\n\t\t\t\t\ttimestamp: readAt,\n\t\t\t\t\tdata: organizations,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tif (storedProjects?.data != null && isFresh(storedProjects.timestamp)) {\n\t\t\tconst projectsByResource = new Map<string, JiraProjectDescriptor[]>();\n\t\t\tfor (const project of storedProjects.data as JiraProjectDescriptor[]) {\n\t\t\t\tconst projects = projectsByResource.get(project.resourceId);\n\t\t\t\tif (projects == null) {\n\t\t\t\t\tprojectsByResource.set(project.resourceId, [{ ...project }]);\n\t\t\t\t} else if (!projects.some(p => p.id === project.id)) {\n\t\t\t\t\tprojects.push({ ...project });\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [resourceId, projects] of projectsByResource) {\n\t\t\t\tthis._projects.set(`${accessToken}:${resourceId}`, projects, {\n\t\t\t\t\tgeneration: projectsGeneration,\n\t\t\t\t\tstoredAt: storedProjects.timestamp,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (organizations?.length) {\n\t\t\tconst readAt = Date.now();\n\t\t\tconst projects = await this.getProviderProjectsForResources(session, organizations, true);\n\t\t\t// See the organizations above.\n\t\t\tif (this._projects.generation === projectsGeneration) {\n\t\t\t\tawait this.ctx.storage.store(`jira:${accessToken}:projects`, {\n\t\t\t\t\tv: 1,\n\t\t\t\t\ttimestamp: readAt,\n\t\t\t\t\tdata: projects,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\toverride invalidateDiscoveryCaches(): void {\n\t\tthis._discoveryInvalidatedAt = Date.now();\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._autolinks.clear();\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._autolinks.clear();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyCA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAC/E,MAAM,qBAAqB;;AAE3B,MAAM,iBAAiB;;;;;;;;;;;;AAavB,SAAS,iBAAiB,MAAc,SAA0E;CACjH,OAAO;EAAE,WAAW,QAAQ,UAAU;EAAM,SAAS;CAAK;AAC3D;AAaA,IAAa,kBAAb,cAAqC,kBAAqD;CACzF,eAAqE;CACrE,KAAS;CACT,MAAyB,KAAK;CAC9B,OAAwB;CAExB,IAAI,SAAiB;EACpB,OAAO,SAAS;CACjB;CAEA,IAAc,aAAqB;EAClC,OAAO;CACR;;;;;;;CAQA,6BAA8B,IAAI,IAGhC;CACF,mCAAoC,IAAI,IAAuE;CAE/G,MAAe,YAAuE;EAErF,IAAI,E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AK,IAAI,QAAQ,MAAM,QAAQ,YAAY,iBAAiB;IACjE,GAAG;IACH,WAAW;IACX,MAAM;GACP,CAAC;EAEH;EAEA,IAAI,gBAAgB,QAAQ,QAAQ,QAAQ,eAAe,SAAS,GAAG;GACtE,MAAM,qCAAqB,IAAI,IAAqC;GACpE,KAAK,MAAM,WAAW,eAAe,MAAiC;IACrE,MAAM,WAAW,mBAAmB,IAAI,QAAQ,UAAU;IAC1D,IAAI,YAAY,MACf,mBAAmB,IAAI,QAAQ,YAAY,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC;SACrD,IAAI,CAAC,SAAS,MAAK,MAAK,EAAE,OAAO,QAAQ,EAAE,GACjD,SAAS,KAAK,EAAE,GAAG,QAAQ,CAAC;GAE9B;GACA,KAAK,MAAM,CAAC,YAAY,aAAa,oBACpC,KAAK,UAAU,IAAI,GAAG,YAAY,GAAG,cAAc,UAAU;IAC5D,YAAY;IACZ,UAAU,eAAe;GAC1B,CAAC;EAEH,OAAO,IAAI,eAAe,QAAQ;GACjC,MAAM,SAAS,KAAK,IAAI;GACxB,MAAM,WAAW,MAAM,KAAK,gCAAgC,SAAS,eAAe,IAAI;GAExF,IAAI,KAAK,UAAU,eAAe,oBACjC,MAAM,KAAK,IAAI,QAAQ,MAAM,QAAQ,YAAY,YAAY;IAC5D,GAAG;IACH,WAAW;IACX,MAAM;GACP,CAAC;EAEH;CACD;CAEA,4BAA2C;EAC1C,KAAK,0BAA0B,KAAK,IAAI;EACxC,KAAK,eAAe,MAAM;EAC1B,KAAK,UAAU,MAAM;EACrB,KAAK,WAAW,MAAM;CACvB;CAEA,uBAAgD;EAC/C,KAAK,eAAe,MAAM;EAC1B,KAAK,UAAU,MAAM;EACrB,KAAK,WAAW,MAAM;CACvB;AACD"}
|
|
@@ -50,6 +50,7 @@ var LinearIntegration = class extends IssuesIntegration {
|
|
|
50
50
|
if (!(this.maybeConnected ?? await this.isConnected()) || this._session == null) return [];
|
|
51
51
|
const session = this._session;
|
|
52
52
|
const cached = this._autolinks.get(session.accessToken);
|
|
53
|
+
if (this.connectionExpired === true) return cached?.autolinks ?? [];
|
|
53
54
|
if (cached == null) return this.buildAutolinks(session);
|
|
54
55
|
if (Date.now() - cached.builtAt >= 3e5) this.buildAutolinks(session).catch(() => {});
|
|
55
56
|
return cached.autolinks;
|