@gitkraken/core-gitlens 0.38.2 → 0.38.4
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 +24 -1
- package/dist/git/parsers/diffParser.d.ts +25 -0
- package/dist/git/parsers/diffParser.js +169 -23
- package/dist/git/parsers/diffParser.js.map +1 -1
- package/dist/git/providers/diff.d.ts +10 -0
- package/dist/git/providers/revision.d.ts +8 -1
- package/dist/git-cli/parsers/blameParser.js +25 -5
- package/dist/git-cli/parsers/blameParser.js.map +1 -1
- package/dist/git-cli/parsers/logParser.js +28 -18
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/parsers/statusParser.d.ts +5 -1
- package/dist/git-cli/parsers/statusParser.js +17 -6
- package/dist/git-cli/parsers/statusParser.js.map +1 -1
- package/dist/git-cli/parsers/treeParser.js +5 -3
- package/dist/git-cli/parsers/treeParser.js.map +1 -1
- package/dist/git-cli/parsers/worktreeParser.js +1 -41
- package/dist/git-cli/parsers/worktreeParser.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts +2 -0
- package/dist/git-cli/providers/diff.js +10 -7
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/revision.d.ts +3 -1
- package/dist/git-cli/providers/revision.js +10 -5
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/status.js +1 -0
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/plus/git-github/providers/github/revision.d.ts +3 -1
- package/dist/plus/git-github/providers/github/revision.js +1 -1
- package/dist/plus/git-github/providers/github/revision.js.map +1 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +2 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +23 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/models.d.ts +1 -0
- package/dist/plus/integrations/authentication/models.js.map +1 -1
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js +4 -1
- package/dist/plus/integrations/authentication/observedAuthenticationProvider.js.map +1 -1
- package/dist/plus/integrations/integrationService.js +7 -1
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +1 -0
- package/dist/plus/integrations/models/integration.js +8 -0
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issuesIntegration.d.ts +5 -0
- package/dist/plus/integrations/models/issuesIntegration.js +33 -1
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +3 -2
- package/dist/plus/integrations/providers/jira.js +36 -17
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +1 -0
- package/dist/plus/integrations/providers/linear.js +40 -17
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +6 -3
- package/dist/plus/integrations/providers/utils/discoveryCache.js +12 -6
- package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
- package/dist/utils/string.d.ts +15 -0
- package/dist/utils/string.js +61 -1
- package/dist/utils/string.js.map +1 -1
- package/package.json +1 -1
|
@@ -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 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, isAutolinkSetExpired } from './utils/discoveryCache.js';\nimport { createIssueAutolinkReferences } from './utils/issueAutolinks.js';\nimport type { JiraDrainOptions, JiraIssuePageFetcher } from './utils/jiraIssueDrains.js';\nimport {\n\tdrainJiraIssues,\n\treadUserScopedJiraIssues,\n\tsearchJiraProjectIssues,\n\tsummarizePageMetadata,\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 {@link isAutolinkSetExpired}: older than the TTL, or than a shorter retry delay when\n\t * the sites or a site's projects couldn't be read whole. An expired set is still served while it is rebuilt in the\n\t * background, because autolinks are read on every render of a commit message and must not wait on the network,\n\t * nor go empty just because nothing read the projects for a while (#5907, #6183).\n\t */\n\tprivate readonly _autolinks = new Map<\n\t\tstring,\n\t\t{ autolinks: (AutolinkReference | DynamicAutolinkReference)[]; builtAt: number; complete: boolean }\n\t>();\n\tprivate readonly _autolinksBuilds = new Map<string, Promise<(AutolinkReference | DynamicAutolinkReference)[]>>();\n\t/**\n\t * Moves, by token, on every missing-project eviction, which drops one site's list without clearing the caches: a\n\t * build or project read that started before it puts neither the list it read back in `_projects` nor what it built\n\t * from it in `_autolinks` (#6176). Cleared with `_projects`, whose generation then refuses those same writes.\n\t */\n\tprivate readonly _projectEvictions = new Map<string, number>();\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 || (cached.builtAt === 0 && !cached.complete && cached.autolinks.length === 0)) {\n\t\t\treturn this.buildAutolinks(session);\n\t\t}\n\n\t\tif (cached.builtAt === 0 || isAutolinkSetExpired(cached)) {\n\t\t\tvoid this.buildAutolinks(session);\n\t\t}\n\t\treturn cached.autolinks;\n\t}\n\n\t/**\n\t * One build per token at a time: concurrent renders share it rather than each re-reading sites and projects. A\n\t * drop, a missing-project eviction or a change to a site's project list retires it, so a render after one doesn't\n\t * join a build reading the lists as they were before (#6170, #6176, #6184).\n\t */\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, () => build).finally(() => {\n\t\t\t\t// A drop, an eviction or a list change meanwhile retired this build, and the entry may be a later\n\t\t\t\t// one's now.\n\t\t\t\tif (this._autolinksBuilds.get(accessToken) === build) {\n\t\t\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t\t\t}\n\t\t\t});\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\treader?: () => Promise<unknown> | undefined,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tconst generation = this._projects.generation;\n\t\tconst evictions = this._projectEvictions.get(accessToken);\n\t\ttry {\n\t\t\tconst organizations = await this.getProviderResourcesForUser(session, false, reader);\n\t\t\tif (\n\t\t\t\torganizations != null &&\n\t\t\t\tthis._projects.generation === generation &&\n\t\t\t\tthis._projectEvictions.get(accessToken) === evictions\n\t\t\t) {\n\t\t\t\tconst projects = await this.getProviderProjectsForResourcesWithMetadata(\n\t\t\t\t\tsession,\n\t\t\t\t\torganizations,\n\t\t\t\t\tfalse,\n\t\t\t\t\treader,\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\t(this._projects.generation !== generation ||\n\t\t\t\t\t\tthis._projectEvictions.get(accessToken) !== evictions) &&\n\t\t\t\t\t(projects.values.length > 0 || !projects.metadata?.failures?.length)\n\t\t\t\t) {\n\t\t\t\t\t// Existing waiters own this successful response, but the active generation must not retain it.\n\t\t\t\t\treturn organizations.flatMap(organization =>\n\t\t\t\t\t\tgetProjectAutolinks(\n\t\t\t\t\t\t\torganization,\n\t\t\t\t\t\t\tprojects.values.filter(p => p.resourceId === organization.id),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tLogger.error(ex, 'JiraIntegration.autolinks');\n\t\t}\n\t\treturn this.deriveAutolinks(accessToken, {\n\t\t\tstore: this._projects.generation === generation && this._projectEvictions.get(accessToken) === evictions,\n\t\t});\n\t}\n\n\tprivate deriveAutolinks(\n\t\taccessToken: string,\n\t\toptions?: {\n\t\t\tstore?: boolean;\n\t\t\tsettled?: boolean;\n\t\t},\n\t): (AutolinkReference | DynamicAutolinkReference)[] {\n\t\tconst organizations = this._organizations.peek(accessToken);\n\t\tlet complete = this._organizations.get(accessToken) != null;\n\t\tconst autolinks: (AutolinkReference | DynamicAutolinkReference)[] = [];\n\t\tfor (const organization of organizations ?? []) {\n\t\t\tconst key = `${accessToken}:${organization.id}`;\n\t\t\tcomplete &&= this._projects.get(key) != null;\n\t\t\tautolinks.push(...getProjectAutolinks(organization, this._projects.peek(key) ?? []));\n\t\t}\n\t\tif (options?.store !== false) {\n\t\t\tthis._autolinks.set(accessToken, {\n\t\t\t\tautolinks: autolinks,\n\t\t\t\tcomplete: complete,\n\t\t\t\t// Stores preserve the retry deadline; only a settled build restarts it.\n\t\t\t\tbuiltAt:\n\t\t\t\t\toptions?.settled !== false\n\t\t\t\t\t\t? Date.now()\n\t\t\t\t\t\t: this._autolinks.get(accessToken)?.builtAt || (complete ? Date.now() : 0),\n\t\t\t});\n\t\t}\n\t\treturn autolinks;\n\t}\n\n\tprivate onDiscoveryStored(accessToken: string, reader?: () => Promise<unknown> | undefined): void {\n\t\t// A build's own store must not break sharing before its continuation runs.\n\t\tif (this._autolinksBuilds.get(accessToken) !== reader?.()) {\n\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t}\n\t\tthis.deriveAutolinks(accessToken, { settled: false });\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/** Atlassian's account id is the same on every site, so the first site answers for all of them. */\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst resource = (await this.getProviderResourcesForUser(session))?.[0];\n\t\treturn resource != null ? this.getProviderAccountForResource(session, resource) : undefined;\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\n\tprotected override async getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t\treader?: () => Promise<unknown> | undefined,\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 started = this._organizations.startRead();\n\t\tconst organizations = await this.readOrganizations(session);\n\t\tif (organizations == null) return undefined;\n\n\t\tconst stored = this._organizations.set(accessToken, organizations, { generation: generation, read: started });\n\t\tif (stored === 'changed') {\n\t\t\tthis.onDiscoveryStored(accessToken, reader);\n\t\t}\n\t\treturn stored === false && this._organizations.generation === generation\n\t\t\t? this._organizations.peek(accessToken)\n\t\t\t: organizations;\n\t}\n\n\tprotected override getProviderUncachedResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\treturn this.readOrganizations(session);\n\t}\n\n\tprivate async readOrganizations(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst resources = await api.getJiraResourcesForCurrentUser(toTokenWithInfo(this.id, session));\n\t\treturn resources?.map(r => ({ ...r, key: r.id }));\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\treader?: () => Promise<unknown> | undefined,\n\t): Promise<ProviderApiCollectionResult<JiraProjectDescriptor>> {\n\t\tconst { accessToken } = session;\n\t\tconst projectsCache = this._projects;\n\t\tconst generation = projectsCache.generation;\n\t\tconst evictions = this._projectEvictions.get(accessToken);\n\t\tconst started = projectsCache.startRead();\n\n\t\t// Taken before the read, so a clear while it is in flight can't empty what was cached when it started. A forced\n\t\t// read reads every resource, and still keeps a cached list for one it can't read completely.\n\t\tconst cachedProjects = new Map<string, JiraProjectDescriptor[]>();\n\t\tfor (const resource of resources) {\n\t\t\tconst projects = projectsCache.get(`${accessToken}:${resource.id}`);\n\t\t\tif (projects != null) {\n\t\t\t\tcachedProjects.set(resource.id, projects);\n\t\t\t}\n\t\t}\n\t\tconst resourcesWithoutProjects = force\n\t\t\t? resources\n\t\t\t: resources.filter(resource => !cachedProjects.has(resource.id));\n\n\t\tconst read = await this.readProjects(session, resourcesWithoutProjects);\n\t\tconst values: JiraProjectDescriptor[] = [];\n\t\tlet metadata = read.metadata;\n\t\tlet changed = false;\n\t\tfor (const [resourceId, projects] of [...read.complete, ...read.incomplete]) {\n\t\t\t// Not stored when the cache was dropped, a list evicted, or a read started after this one stored it, while\n\t\t\t// this read was in flight: what it found is then no longer trusted for the next read.\n\t\t\tif (this._projectEvictions.get(accessToken) !== evictions) continue;\n\n\t\t\tconst stored = projectsCache.set(`${accessToken}:${resourceId}`, projects, {\n\t\t\t\tgeneration: generation,\n\t\t\t\tread: started,\n\t\t\t\tcomplete: read.complete.has(resourceId),\n\t\t\t});\n\t\t\tif (stored === 'changed') {\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\t\tif (changed) {\n\t\t\tthis.onDiscoveryStored(accessToken, reader);\n\t\t}\n\n\t\t// A site read whole, or served from the cache, answers with its newest list stored: this read's own, or the one\n\t\t// a read started after it stored, which this older read must not stand in for, not even once expired (#6184).\n\t\t// Once the cache was dropped or a list evicted meanwhile, only what it found itself.\n\t\tconst current =\n\t\t\tprojectsCache.generation === generation && this._projectEvictions.get(accessToken) === evictions;\n\t\tfor (const resource of resources) {\n\t\t\tconst resourceProjects =\n\t\t\t\tread.complete.get(resource.id) ?? read.incomplete.get(resource.id) ?? cachedProjects.get(resource.id);\n\t\t\tif (resourceProjects == null) continue;\n\n\t\t\tconst stored = current ? projectsCache.peek(`${accessToken}:${resource.id}`) : undefined;\n\t\t\tvalues.push(...(stored ?? resourceProjects));\n\t\t\tif (stored != null && projectsCache.get(`${accessToken}:${resource.id}`) == null) {\n\t\t\t\tmetadata = mergeCollectionMetadata(metadata, { completeness: 'unknown' });\n\t\t\t}\n\t\t}\n\t\treturn { values: uniqueProjects(values), metadata: metadata };\n\t}\n\n\tprotected override async getProviderUncachedProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t): Promise<ProviderApiCollectionResult<JiraProjectDescriptor>> {\n\t\tconst read = await this.readProjects(session, resources);\n\t\treturn {\n\t\t\tvalues: uniqueProjects([...read.incomplete.values(), ...read.complete.values()].flat()),\n\t\t\tmetadata: read.metadata,\n\t\t};\n\t}\n\n\t/**\n\t * Reads the projects of each resource from the provider, apart by whether a resource's list came back complete:\n\t * incomplete lists remain available for decoration but cannot satisfy a fresh discovery read.\n\t */\n\tprivate async readProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t): Promise<{\n\t\tcomplete: Map<string, JiraProjectDescriptor[]>;\n\t\tincomplete: Map<string, JiraProjectDescriptor[]>;\n\t\tmetadata: CollectionMetadata | undefined;\n\t}> {\n\t\tconst complete = new Map<string, JiraProjectDescriptor[]>();\n\t\tconst incompleteLists = new Map<string, JiraProjectDescriptor[]>();\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\tif (resources.length === 0) {\n\t\t\treturn { complete: complete, incomplete: incompleteLists, metadata: metadata };\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst drains = await Promise.allSettled(\n\t\t\tresources.map(async resource => {\n\t\t\t\tlet readPage = false;\n\t\t\t\tconst result = await collectProviderPagedResult(\n\t\t\t\t\tasync cursor => {\n\t\t\t\t\t\tconst page = await api.getJiraProjectsForResource(tokenWithInfo, resource.id, {\n\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treadPage ||= page != null && (page.values.length > 0 || !page.metadata?.failures?.length);\n\t\t\t\t\t\treturn page;\n\t\t\t\t\t},\n\t\t\t\t\tmaxPagesPerRequest,\n\t\t\t\t\t{ providerId: this.id, resourceId: resource.id },\n\t\t\t\t);\n\t\t\t\treturn { resource: resource, result: result, readPage: readPage };\n\t\t\t}),\n\t\t);\n\n\t\tdrains.forEach((drain, index) => {\n\t\t\tif (drain.status === 'rejected') {\n\t\t\t\tconst resource = resources[index];\n\t\t\t\tif (resource == null) return;\n\n\t\t\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\tfailures: [\n\t\t\t\t\t\ttoCollectionScopeFailure({ providerId: this.id, resourceId: resource.id }, drain.reason),\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { resource, result, readPage } = drain.value;\n\t\t\tmetadata = mergeCollectionMetadata(metadata, result.metadata);\n\t\t\tconst projects = result.values\n\t\t\t\t.filter(project => project.resourceId === resource.id)\n\t\t\t\t.map(project => ({ ...project }));\n\t\t\tconst incomplete =\n\t\t\t\tresult.truncated === true || (result.metadata != null && result.metadata.completeness !== 'complete');\n\t\t\tif (incomplete) {\n\t\t\t\tif (readPage) {\n\t\t\t\t\tincompleteLists.set(resource.id, projects);\n\t\t\t\t}\n\t\t\t\tif (\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\t) {\n\t\t\t\t\tmetadata = mergeCollectionMetadata(metadata, { completeness: 'partial' });\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcomplete.set(resource.id, projects);\n\t\t});\n\t\treturn { complete: complete, incomplete: incompleteLists, 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\t// By key, not name, as the multi-project search: JQL's `project = \"<value>\"` also accepts a name or id, so a\n\t\t// display name equal to another project's key would address that project. The key is the only unambiguous one.\n\t\tconst fetchPage: JiraIssuePageFetcher = (scope, cursor) =>\n\t\t\tapi.getIssuesForProjectPaged(tokenWithInfo, project.key, 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.key },\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\tconst { accessToken } = session;\n\t\t\t\tthis._projects.delete(`${accessToken}:${project.resourceId}`);\n\t\t\t\t// A build or project read in flight may hold the list just dropped; see `_projectEvictions`.\n\t\t\t\tthis._projectEvictions.set(accessToken, (this._projectEvictions.get(accessToken) ?? 0) + 1);\n\t\t\t\tthis._autolinks.delete(accessToken);\n\t\t\t\tthis._autolinksBuilds.delete(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\tconst drain = { values: values, metadata: read.metadata, scope: drainOptions.failureScope };\n\t\t\treturn read.truncated ? { ...drain, truncated: true, recovery: 'none' } : { ...drain, truncated: false };\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\tconst drain = { values: values, metadata: unscoped.metadata, scope: drainOptions.failureScope };\n\t\treturn unscoped.status !== 'complete'\n\t\t\t? { ...drain, truncated: true, recovery: unscoped.status === 'backstop' ? 'narrow-scope' : 'none' }\n\t\t\t: { ...drain, truncated: false };\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\t\t// One project's search is its own read, by the same key and user clauses, so it costs no more to read it as one;\n\t\t// and that read attributes a failure to the project and drops a project list that no longer has it.\n\t\tif (requests.length === 1) 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\tconst result = await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation);\n\t\t// This read can only return values, so what the account-wide read reports as missing is at least logged.\n\t\tfor (const failure of result?.metadata?.failures ?? []) {\n\t\t\tLogger.warn(\n\t\t\t\t`searchProviderMyIssues: Jira site '${failure.scope?.resourceId ?? '?'}' was not fully read: ${failure.message ?? failure.kind}`,\n\t\t\t);\n\t\t}\n\t\treturn result?.values;\n\t}\n\n\t/**\n\t * Overridden so `state` reaches the per-site read, which the default drops. Each site is drained on its own, so a\n\t * site that fails keeps what it read and is recorded as that site's failure instead of discarding the sites that\n\t * answered; so is an issue a page dropped because it could not be read. A page backstop or a stalled continuation\n\t * makes the read `truncated`. A refused site therefore goes through `confirmScopedAuthFailures`, which publishes it\n\t * as that site's auth warning or, if the credential itself is refused, as the connection's.\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\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\n\t\tconst results: IssueShape[] = [];\n\t\tlet truncated = false;\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\t// What each page reported failing, summarized at the end so a site whose many pages dropped issues reports\n\t\t// it once (see `summarizePageMetadata`); the pages keep the rest of their metadata, so `truncated` holds.\n\t\tconst pages: CollectionMetadata[] = [];\n\t\tconst readPage = async (resourceId: string, cursor: string | undefined) => {\n\t\t\tconst page = await api.getIssuesForResourceForCurrentUser(tokenWithInfo, resourceId, {\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t});\n\t\t\tif (!page.metadata?.failures?.length) return page;\n\n\t\t\tconst { failures: _failures, ...rest } = page.metadata;\n\t\t\tpages.push(page.metadata);\n\t\t\treturn { ...page, metadata: rest };\n\t\t};\n\t\tfor (const resource of myResources) {\n\t\t\tif (cancellation?.aborted) break;\n\n\t\t\tconst site = await collectProviderPagedResult(\n\t\t\t\tcursor =>\n\t\t\t\t\t// Cancellation is not truncation: the caller asked for the stop, so the site ends where it is.\n\t\t\t\t\tcancellation?.aborted\n\t\t\t\t\t\t? Promise.resolve({ values: [], paging: { cursor: '{}', more: false } })\n\t\t\t\t\t\t: readPage(resource.id, cursor),\n\t\t\t\tmaxPagesPerRequest,\n\t\t\t\t{ providerId: this.id, resourceId: resource.id },\n\t\t\t);\n\t\t\tresults.push(\n\t\t\t\t...site.values\n\t\t\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'account' }))\n\t\t\t\t\t.filter((result): result is IssueShape => result != null),\n\t\t\t);\n\t\t\ttruncated ||= site.truncated === true;\n\t\t\tmetadata = mergeCollectionMetadata(metadata, site.metadata);\n\t\t}\n\n\t\treturn {\n\t\t\tvalues: results,\n\t\t\ttruncated: truncated,\n\t\t\tmetadata: mergeCollectionMetadata(summarizePageMetadata(pages), metadata),\n\t\t};\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 = apiResult != null ? toIssueShape(apiResult, this, { projection: 'batch' }) : 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 distinguishes a missing issue from a site failure. When no target was\n\t * answered and nothing failed, the check declines, 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 organizations = await this.getProviderResourcesForUser(session, true);\n\t\tif (organizations?.length) {\n\t\t\tawait this.getProviderProjectsForResources(session, organizations, true);\n\t\t}\n\t}\n\n\tprotected override clearDiscoveryCaches(): void {\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._projectEvictions.clear();\n\t\tthis._autolinks.clear();\n\t\tthis._autolinksBuilds.clear();\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._projectEvictions.clear();\n\t\tthis._autolinks.clear();\n\t}\n}\n\nfunction getProjectAutolinks(\n\torganization: JiraOrganizationDescriptor,\n\tprojects: readonly JiraProjectDescriptor[],\n): AutolinkReference[] {\n\treturn projects.flatMap(project =>\n\t\tcreateIssueAutolinkReferences(project.key, `${organization.url}/browse/${project.key}-<num>`, organization),\n\t);\n}\n\n/** The projects once each, by site and id. */\nfunction uniqueProjects(projects: JiraProjectDescriptor[]): JiraProjectDescriptor[] {\n\tconst projectsByIdentity = new Map<string, JiraProjectDescriptor>();\n\tfor (const project of projects) {\n\t\tconst identity = `${project.resourceId}:${project.id}`;\n\t\tif (!projectsByIdentity.has(identity)) {\n\t\t\tprojectsByIdentity.set(identity, project);\n\t\t}\n\t}\n\treturn [...projectsByIdentity.values()];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,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;;;;;;;;CASA,6BAA8B,IAAI,IAGhC;CACF,mCAAoC,IAAI,IAAuE;;;;;;CAM/G,oCAAqC,IAAI,IAAoB;CAE7D,MAAe,YAAuE;EAErF,IAAI,EADc,KAAK,kBAAmB,MAAM,KAAK,YAAY,MAC/C,KAAK,YAAY,MAAM,OAAO,CAAC;EAEjD,MAAM,UAAU,KAAK;EACrB,MAAM,SAAS,KAAK,WAAW,IAAI,QAAQ,WAAW;EAGtD,IAAI,KAAK,sBAAsB,MAAM,OAAO,QAAQ,aAAa,CAAC;EAClE,IAAI,UAAU,QAAS,OAAO,YAAY,KAAK,CAAC,OAAO,YAAY,OAAO,UAAU,WAAW,GAC9F,OAAO,KAAK,eAAe,OAAO;EAGnC,IAAI,OAAO,YAAY,KAAK,qBAAqB,MAAM,GACtD,KAAU,eAAe,OAAO;EAEjC,OAAO,OAAO;CACf;;;;;;CAOA,eACC,SAC4D;EAC5D,MAAM,EAAE,gBAAgB;EACxB,IAAI,QAAQ,KAAK,iBAAiB,IAAI,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AM;EAE3B,MAAM,UAAU,KAAK;EACrB,MAAM,gBAAgB,MAAM,KAAK,4BAA4B,SAAS,IAAI;EAC1E,IAAI,eAAe,QAClB,MAAM,KAAK,gCAAgC,SAAS,eAAe,IAAI;CAEzE;CAEA,uBAAgD;EAC/C,KAAK,eAAe,MAAM;EAC1B,KAAK,UAAU,MAAM;EACrB,KAAK,kBAAkB,MAAM;EAC7B,KAAK,WAAW,MAAM;EACtB,KAAK,iBAAiB,MAAM;CAC7B;CAEA,uBAAgD;EAC/C,KAAK,eAAe,MAAM;EAC1B,KAAK,UAAU,MAAM;EACrB,KAAK,kBAAkB,MAAM;EAC7B,KAAK,WAAW,MAAM;CACvB;AACD;AAEA,SAAS,oBACR,cACA,UACsB;CACtB,OAAO,SAAS,SAAQ,YACvB,8BAA8B,QAAQ,KAAK,GAAG,aAAa,IAAI,UAAU,QAAQ,IAAI,SAAS,YAAY,CAC3G;AACD;;AAGA,SAAS,eAAe,UAA4D;CACnF,MAAM,qCAAqB,IAAI,IAAmC;CAClE,KAAK,MAAM,WAAW,UAAU;EAC/B,MAAM,WAAW,GAAG,QAAQ,WAAW,GAAG,QAAQ;EAClD,IAAI,CAAC,mBAAmB,IAAI,QAAQ,GACnC,mBAAmB,IAAI,UAAU,OAAO;CAE1C;CACA,OAAO,CAAC,GAAG,mBAAmB,OAAO,CAAC;AACvC"}
|
|
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 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, isAutolinkSetExpired } from './utils/discoveryCache.js';\nimport { createIssueAutolinkReferences } from './utils/issueAutolinks.js';\nimport type { JiraDrainOptions, JiraIssuePageFetcher } from './utils/jiraIssueDrains.js';\nimport {\n\tdrainJiraIssues,\n\treadUserScopedJiraIssues,\n\tsearchJiraProjectIssues,\n\tsummarizePageMetadata,\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 {@link isAutolinkSetExpired}: older than the TTL, or than a shorter retry delay when\n\t * the sites or a site's projects couldn't be read whole. An expired set is still served while it is rebuilt in the\n\t * background, because autolinks are read on every render of a commit message and must not wait on the network,\n\t * nor go empty just because nothing read the projects for a while (#5907, #6183).\n\t */\n\tprivate readonly _autolinks = new Map<\n\t\tstring,\n\t\t{\n\t\t\tautolinks: (AutolinkReference | DynamicAutolinkReference)[];\n\t\t\tbuiltAt: number;\n\t\t\tcomplete: boolean;\n\t\t\tisCurrent?: () => boolean;\n\t\t}\n\t>();\n\tprivate readonly _autolinksBuilds = new Map<string, Promise<(AutolinkReference | DynamicAutolinkReference)[]>>();\n\tprivate readonly _autolinksBuildLifetimes = new WeakMap<Promise<unknown>, () => boolean>();\n\t/**\n\t * Moves, by token, on every missing-project eviction, which drops one site's list without clearing the caches: a\n\t * build or project read that started before it puts neither the list it read back in `_projects` nor what it built\n\t * from it in `_autolinks` (#6176). Cleared with `_projects`, whose generation then refuses those same writes.\n\t */\n\tprivate readonly _projectEvictions = new Map<string, number>();\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 (!this.captureDiscoveryLifetime(session)() || cached?.isCurrent?.() === false) {\n\t\t\tthis._autolinks.delete(session.accessToken);\n\t\t\treturn [];\n\t\t}\n\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 || (cached.builtAt === 0 && !cached.complete && cached.autolinks.length === 0)) {\n\t\t\treturn this.buildAutolinks(session);\n\t\t}\n\n\t\tif (cached.builtAt === 0 || isAutolinkSetExpired(cached)) {\n\t\t\tvoid this.buildAutolinks(session);\n\t\t}\n\t\treturn cached.autolinks;\n\t}\n\n\t/**\n\t * One build per token at a time: concurrent renders share it rather than each re-reading sites and projects. A\n\t * drop, a missing-project eviction or a change to a site's project list retires it, so a render after one doesn't\n\t * join a build reading the lists as they were before (#6170, #6176, #6184).\n\t */\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 || this._autolinksBuildLifetimes.get(build)?.() === false) {\n\t\t\tconst isCurrent = this.captureDiscoveryLifetime(session);\n\t\t\tbuild = this.buildAutolinksCore(session, () => build).finally(() => {\n\t\t\t\t// A drop, an eviction or a list change meanwhile retired this build, and the entry may be a later\n\t\t\t\t// one's now.\n\t\t\t\tif (this._autolinksBuilds.get(accessToken) === build) {\n\t\t\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t\t\t}\n\t\t\t});\n\t\t\tthis._autolinksBuilds.set(accessToken, build);\n\t\t\tthis._autolinksBuildLifetimes.set(build, isCurrent);\n\t\t}\n\t\treturn build;\n\t}\n\n\tprivate async buildAutolinksCore(\n\t\tsession: ProviderAuthenticationSession,\n\t\treader?: () => Promise<unknown> | undefined,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tconst isCurrent = this.captureDiscoveryLifetime(session);\n\t\tconst generation = this._projects.generation;\n\t\tconst evictions = this._projectEvictions.get(accessToken);\n\t\ttry {\n\t\t\tconst organizations = await this.getProviderResourcesForUser(session, false, reader, isCurrent);\n\t\t\tif (\n\t\t\t\torganizations != null &&\n\t\t\t\tisCurrent() &&\n\t\t\t\tthis._projects.generation === generation &&\n\t\t\t\tthis._projectEvictions.get(accessToken) === evictions\n\t\t\t) {\n\t\t\t\tconst projects = await this.getProviderProjectsForResourcesWithMetadata(\n\t\t\t\t\tsession,\n\t\t\t\t\torganizations,\n\t\t\t\t\tfalse,\n\t\t\t\t\treader,\n\t\t\t\t\tisCurrent,\n\t\t\t\t);\n\t\t\t\tif (\n\t\t\t\t\t(!isCurrent() ||\n\t\t\t\t\t\tthis._projects.generation !== generation ||\n\t\t\t\t\t\tthis._projectEvictions.get(accessToken) !== evictions) &&\n\t\t\t\t\t(projects.values.length > 0 || !projects.metadata?.failures?.length)\n\t\t\t\t) {\n\t\t\t\t\t// Existing waiters own this successful response, but the active generation must not retain it.\n\t\t\t\t\treturn organizations.flatMap(organization =>\n\t\t\t\t\t\tgetProjectAutolinks(\n\t\t\t\t\t\t\torganization,\n\t\t\t\t\t\t\tprojects.values.filter(p => p.resourceId === organization.id),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tLogger.error(ex, 'JiraIntegration.autolinks');\n\t\t}\n\t\treturn this.deriveAutolinks(accessToken, {\n\t\t\tisCurrent: isCurrent,\n\t\t\tstore:\n\t\t\t\tisCurrent() &&\n\t\t\t\tthis._projects.generation === generation &&\n\t\t\t\tthis._projectEvictions.get(accessToken) === evictions,\n\t\t});\n\t}\n\n\tprivate deriveAutolinks(\n\t\taccessToken: string,\n\t\toptions?: {\n\t\t\tstore?: boolean;\n\t\t\tsettled?: boolean;\n\t\t\tisCurrent?: () => boolean;\n\t\t},\n\t): (AutolinkReference | DynamicAutolinkReference)[] {\n\t\tconst organizations = this._organizations.peek(accessToken);\n\t\tlet complete = this._organizations.get(accessToken) != null;\n\t\tconst autolinks: (AutolinkReference | DynamicAutolinkReference)[] = [];\n\t\tfor (const organization of organizations ?? []) {\n\t\t\tconst key = `${accessToken}:${organization.id}`;\n\t\t\tcomplete &&= this._projects.get(key) != null;\n\t\t\tautolinks.push(...getProjectAutolinks(organization, this._projects.peek(key) ?? []));\n\t\t}\n\t\tfor (const [token, cached] of this._autolinks) {\n\t\t\tif (cached.isCurrent?.() === false) {\n\t\t\t\tthis._autolinks.delete(token);\n\t\t\t}\n\t\t}\n\t\tif (options?.store !== false) {\n\t\t\tthis._autolinks.set(accessToken, {\n\t\t\t\tautolinks: autolinks,\n\t\t\t\tisCurrent: options?.isCurrent,\n\t\t\t\tcomplete: complete,\n\t\t\t\t// Stores preserve the retry deadline; only a settled build restarts it.\n\t\t\t\tbuiltAt:\n\t\t\t\t\toptions?.settled !== false\n\t\t\t\t\t\t? Date.now()\n\t\t\t\t\t\t: this._autolinks.get(accessToken)?.builtAt || (complete ? Date.now() : 0),\n\t\t\t});\n\t\t}\n\t\treturn autolinks;\n\t}\n\n\tprivate onDiscoveryStored(\n\t\taccessToken: string,\n\t\treader: (() => Promise<unknown> | undefined) | undefined,\n\t\tisCurrent: () => boolean,\n\t): void {\n\t\t// A build's own store must not break sharing before its continuation runs.\n\t\tif (this._autolinksBuilds.get(accessToken) !== reader?.()) {\n\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t}\n\t\tthis.deriveAutolinks(accessToken, { settled: false, isCurrent: isCurrent });\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/** Atlassian's account id is the same on every site, so the first site answers for all of them. */\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst resource = (await this.getProviderResourcesForUser(session))?.[0];\n\t\treturn resource != null ? this.getProviderAccountForResource(session, resource) : undefined;\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\n\tprotected override async getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t\treader?: () => Promise<unknown> | undefined,\n\t\tisCurrent: () => boolean = this.captureDiscoveryLifetime(session),\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 started = this._organizations.startRead();\n\t\tconst organizations = await this.readOrganizations(session);\n\t\tif (organizations == null) return undefined;\n\n\t\tconst stored = this._organizations.set(accessToken, organizations, {\n\t\t\tgeneration: generation,\n\t\t\tread: started,\n\t\t\tisCurrent: isCurrent,\n\t\t});\n\t\tif (stored === 'changed') {\n\t\t\tthis.onDiscoveryStored(accessToken, reader, isCurrent);\n\t\t}\n\t\treturn stored === false && isCurrent() && this._organizations.generation === generation\n\t\t\t? this._organizations.peek(accessToken)\n\t\t\t: organizations;\n\t}\n\n\tprotected override getProviderUncachedResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\treturn this.readOrganizations(session);\n\t}\n\n\tprivate async readOrganizations(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<JiraOrganizationDescriptor[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst resources = await api.getJiraResourcesForCurrentUser(toTokenWithInfo(this.id, session));\n\t\treturn resources?.map(r => ({ ...r, key: r.id }));\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\treader?: () => Promise<unknown> | undefined,\n\t\tisCurrent: () => boolean = this.captureDiscoveryLifetime(session),\n\t): Promise<ProviderApiCollectionResult<JiraProjectDescriptor>> {\n\t\tconst { accessToken } = session;\n\t\tconst projectsCache = this._projects;\n\t\tconst generation = projectsCache.generation;\n\t\tconst evictions = this._projectEvictions.get(accessToken);\n\t\tconst started = projectsCache.startRead();\n\n\t\t// Taken before the read, so a clear while it is in flight can't empty what was cached when it started. A forced\n\t\t// read reads every resource, and still keeps a cached list for one it can't read completely.\n\t\tconst cachedProjects = new Map<string, JiraProjectDescriptor[]>();\n\t\tfor (const resource of resources) {\n\t\t\tconst projects = projectsCache.get(`${accessToken}:${resource.id}`);\n\t\t\tif (projects != null) {\n\t\t\t\tcachedProjects.set(resource.id, projects);\n\t\t\t}\n\t\t}\n\t\tconst resourcesWithoutProjects = force\n\t\t\t? resources\n\t\t\t: resources.filter(resource => !cachedProjects.has(resource.id));\n\n\t\tconst read = await this.readProjects(session, resourcesWithoutProjects);\n\t\tconst values: JiraProjectDescriptor[] = [];\n\t\tlet metadata = read.metadata;\n\t\tlet changed = false;\n\t\tfor (const [resourceId, projects] of [...read.complete, ...read.incomplete]) {\n\t\t\t// Not stored when the cache was dropped, a list evicted, or a read started after this one stored it, while\n\t\t\t// this read was in flight: what it found is then no longer trusted for the next read.\n\t\t\tif (this._projectEvictions.get(accessToken) !== evictions) continue;\n\n\t\t\tconst stored = projectsCache.set(`${accessToken}:${resourceId}`, projects, {\n\t\t\t\tgeneration: generation,\n\t\t\t\tread: started,\n\t\t\t\tisCurrent: isCurrent,\n\t\t\t\tcomplete: read.complete.has(resourceId),\n\t\t\t});\n\t\t\tif (stored === 'changed') {\n\t\t\t\tchanged = true;\n\t\t\t}\n\t\t}\n\t\tif (changed) {\n\t\t\tthis.onDiscoveryStored(accessToken, reader, isCurrent);\n\t\t}\n\n\t\t// A site read whole, or served from the cache, answers with its newest list stored: this read's own, or the one\n\t\t// a read started after it stored, which this older read must not stand in for, not even once expired (#6184).\n\t\t// Once the cache was dropped or a list evicted meanwhile, only what it found itself.\n\t\tconst current =\n\t\t\tisCurrent() &&\n\t\t\tprojectsCache.generation === generation &&\n\t\t\tthis._projectEvictions.get(accessToken) === evictions;\n\t\tfor (const resource of resources) {\n\t\t\tconst resourceProjects =\n\t\t\t\tread.complete.get(resource.id) ?? read.incomplete.get(resource.id) ?? cachedProjects.get(resource.id);\n\t\t\tif (resourceProjects == null) continue;\n\n\t\t\tconst stored = current ? projectsCache.peek(`${accessToken}:${resource.id}`) : undefined;\n\t\t\tvalues.push(...(stored ?? resourceProjects));\n\t\t\tif (stored != null && projectsCache.get(`${accessToken}:${resource.id}`) == null) {\n\t\t\t\tmetadata = mergeCollectionMetadata(metadata, { completeness: 'unknown' });\n\t\t\t}\n\t\t}\n\t\treturn { values: uniqueProjects(values), metadata: metadata };\n\t}\n\n\tprotected override async getProviderUncachedProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t): Promise<ProviderApiCollectionResult<JiraProjectDescriptor>> {\n\t\tconst read = await this.readProjects(session, resources);\n\t\treturn {\n\t\t\tvalues: uniqueProjects([...read.incomplete.values(), ...read.complete.values()].flat()),\n\t\t\tmetadata: read.metadata,\n\t\t};\n\t}\n\n\t/**\n\t * Reads the projects of each resource from the provider, apart by whether a resource's list came back complete:\n\t * incomplete lists remain available for decoration but cannot satisfy a fresh discovery read.\n\t */\n\tprivate async readProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources: JiraOrganizationDescriptor[],\n\t): Promise<{\n\t\tcomplete: Map<string, JiraProjectDescriptor[]>;\n\t\tincomplete: Map<string, JiraProjectDescriptor[]>;\n\t\tmetadata: CollectionMetadata | undefined;\n\t}> {\n\t\tconst complete = new Map<string, JiraProjectDescriptor[]>();\n\t\tconst incompleteLists = new Map<string, JiraProjectDescriptor[]>();\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\tif (resources.length === 0) {\n\t\t\treturn { complete: complete, incomplete: incompleteLists, metadata: metadata };\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tconst drains = await Promise.allSettled(\n\t\t\tresources.map(async resource => {\n\t\t\t\tlet readPage = false;\n\t\t\t\tconst result = await collectProviderPagedResult(\n\t\t\t\t\tasync cursor => {\n\t\t\t\t\t\tconst page = await api.getJiraProjectsForResource(tokenWithInfo, resource.id, {\n\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t});\n\t\t\t\t\t\treadPage ||= page != null && (page.values.length > 0 || !page.metadata?.failures?.length);\n\t\t\t\t\t\treturn page;\n\t\t\t\t\t},\n\t\t\t\t\tmaxPagesPerRequest,\n\t\t\t\t\t{ providerId: this.id, resourceId: resource.id },\n\t\t\t\t);\n\t\t\t\treturn { resource: resource, result: result, readPage: readPage };\n\t\t\t}),\n\t\t);\n\n\t\tdrains.forEach((drain, index) => {\n\t\t\tif (drain.status === 'rejected') {\n\t\t\t\tconst resource = resources[index];\n\t\t\t\tif (resource == null) return;\n\n\t\t\t\tmetadata = mergeCollectionMetadata(metadata, {\n\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\tfailures: [\n\t\t\t\t\t\ttoCollectionScopeFailure({ providerId: this.id, resourceId: resource.id }, drain.reason),\n\t\t\t\t\t],\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { resource, result, readPage } = drain.value;\n\t\t\tmetadata = mergeCollectionMetadata(metadata, result.metadata);\n\t\t\tconst projects = result.values\n\t\t\t\t.filter(project => project.resourceId === resource.id)\n\t\t\t\t.map(project => ({ ...project }));\n\t\t\tconst incomplete =\n\t\t\t\tresult.truncated === true || (result.metadata != null && result.metadata.completeness !== 'complete');\n\t\t\tif (incomplete) {\n\t\t\t\tif (readPage) {\n\t\t\t\t\tincompleteLists.set(resource.id, projects);\n\t\t\t\t}\n\t\t\t\tif (\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\t) {\n\t\t\t\t\tmetadata = mergeCollectionMetadata(metadata, { completeness: 'partial' });\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcomplete.set(resource.id, projects);\n\t\t});\n\t\treturn { complete: complete, incomplete: incompleteLists, 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\t// By key, not name, as the multi-project search: JQL's `project = \"<value>\"` also accepts a name or id, so a\n\t\t// display name equal to another project's key would address that project. The key is the only unambiguous one.\n\t\tconst fetchPage: JiraIssuePageFetcher = (scope, cursor) =>\n\t\t\tapi.getIssuesForProjectPaged(tokenWithInfo, project.key, 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.key },\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\tconst { accessToken } = session;\n\t\t\t\tthis._projects.delete(`${accessToken}:${project.resourceId}`);\n\t\t\t\t// A build or project read in flight may hold the list just dropped; see `_projectEvictions`.\n\t\t\t\tthis._projectEvictions.set(accessToken, (this._projectEvictions.get(accessToken) ?? 0) + 1);\n\t\t\t\tthis._autolinks.delete(accessToken);\n\t\t\t\tthis._autolinksBuilds.delete(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\tconst drain = { values: values, metadata: read.metadata, scope: drainOptions.failureScope };\n\t\t\treturn read.truncated ? { ...drain, truncated: true, recovery: 'none' } : { ...drain, truncated: false };\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\tconst drain = { values: values, metadata: unscoped.metadata, scope: drainOptions.failureScope };\n\t\treturn unscoped.status !== 'complete'\n\t\t\t? { ...drain, truncated: true, recovery: unscoped.status === 'backstop' ? 'narrow-scope' : 'none' }\n\t\t\t: { ...drain, truncated: false };\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\t\t// One project's search is its own read, by the same key and user clauses, so it costs no more to read it as one;\n\t\t// and that read attributes a failure to the project and drops a project list that no longer has it.\n\t\tif (requests.length === 1) 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\tconst result = await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation);\n\t\t// This read can only return values, so what the account-wide read reports as missing is at least logged.\n\t\tfor (const failure of result?.metadata?.failures ?? []) {\n\t\t\tLogger.warn(\n\t\t\t\t`searchProviderMyIssues: Jira site '${failure.scope?.resourceId ?? '?'}' was not fully read: ${failure.message ?? failure.kind}`,\n\t\t\t);\n\t\t}\n\t\treturn result?.values;\n\t}\n\n\t/**\n\t * Overridden so `state` reaches the per-site read, which the default drops. Each site is drained on its own, so a\n\t * site that fails keeps what it read and is recorded as that site's failure instead of discarding the sites that\n\t * answered; so is an issue a page dropped because it could not be read. A page backstop or a stalled continuation\n\t * makes the read `truncated`. A refused site therefore goes through `confirmScopedAuthFailures`, which publishes it\n\t * as that site's auth warning or, if the credential itself is refused, as the connection's.\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\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\n\t\tconst results: IssueShape[] = [];\n\t\tlet truncated = false;\n\t\tlet metadata: CollectionMetadata | undefined;\n\t\t// What each page reported failing, summarized at the end so a site whose many pages dropped issues reports\n\t\t// it once (see `summarizePageMetadata`); the pages keep the rest of their metadata, so `truncated` holds.\n\t\tconst pages: CollectionMetadata[] = [];\n\t\tconst readPage = async (resourceId: string, cursor: string | undefined) => {\n\t\t\tconst page = await api.getIssuesForResourceForCurrentUser(tokenWithInfo, resourceId, {\n\t\t\t\tcursor: cursor,\n\t\t\t\tstates: states,\n\t\t\t});\n\t\t\tif (!page.metadata?.failures?.length) return page;\n\n\t\t\tconst { failures: _failures, ...rest } = page.metadata;\n\t\t\tpages.push(page.metadata);\n\t\t\treturn { ...page, metadata: rest };\n\t\t};\n\t\tfor (const resource of myResources) {\n\t\t\tif (cancellation?.aborted) break;\n\n\t\t\tconst site = await collectProviderPagedResult(\n\t\t\t\tcursor =>\n\t\t\t\t\t// Cancellation is not truncation: the caller asked for the stop, so the site ends where it is.\n\t\t\t\t\tcancellation?.aborted\n\t\t\t\t\t\t? Promise.resolve({ values: [], paging: { cursor: '{}', more: false } })\n\t\t\t\t\t\t: readPage(resource.id, cursor),\n\t\t\t\tmaxPagesPerRequest,\n\t\t\t\t{ providerId: this.id, resourceId: resource.id },\n\t\t\t);\n\t\t\tresults.push(\n\t\t\t\t...site.values\n\t\t\t\t\t.map(issue => toIssueShape(issue, this, { projection: 'account' }))\n\t\t\t\t\t.filter((result): result is IssueShape => result != null),\n\t\t\t);\n\t\t\ttruncated ||= site.truncated === true;\n\t\t\tmetadata = mergeCollectionMetadata(metadata, site.metadata);\n\t\t}\n\n\t\treturn {\n\t\t\tvalues: results,\n\t\t\ttruncated: truncated,\n\t\t\tmetadata: mergeCollectionMetadata(summarizePageMetadata(pages), metadata),\n\t\t};\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 = apiResult != null ? toIssueShape(apiResult, this, { projection: 'batch' }) : 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 distinguishes a missing issue from a site failure. When no target was\n\t * answered and nothing failed, the check declines, 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 isCurrent = this.captureDiscoveryLifetime(session);\n\t\tconst organizations = await this.getProviderResourcesForUser(session, true, undefined, isCurrent);\n\t\tif (organizations?.length && isCurrent()) {\n\t\t\tawait this.getProviderProjectsForResourcesWithMetadata(session, organizations, true, undefined, isCurrent);\n\t\t}\n\t}\n\n\tprotected override clearDiscoveryCaches(): void {\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._projectEvictions.clear();\n\t\tthis._autolinks.clear();\n\t\tthis._autolinksBuilds.clear();\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._organizations.clear();\n\t\tthis._projects.clear();\n\t\tthis._projectEvictions.clear();\n\t\tthis._autolinks.clear();\n\t}\n}\n\nfunction getProjectAutolinks(\n\torganization: JiraOrganizationDescriptor,\n\tprojects: readonly JiraProjectDescriptor[],\n): AutolinkReference[] {\n\treturn projects.flatMap(project =>\n\t\tcreateIssueAutolinkReferences(project.key, `${organization.url}/browse/${project.key}-<num>`, organization),\n\t);\n}\n\n/** The projects once each, by site and id. */\nfunction uniqueProjects(projects: JiraProjectDescriptor[]): JiraProjectDescriptor[] {\n\tconst projectsByIdentity = new Map<string, JiraProjectDescriptor>();\n\tfor (const project of projects) {\n\t\tconst identity = `${project.resourceId}:${project.id}`;\n\t\tif (!projectsByIdentity.has(identity)) {\n\t\t\tprojectsByIdentity.set(identity, project);\n\t\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CAAqB,IAAI,IAAmC;CAClE,KAAK,MAAM,WAAW,UAAU;EAC/B,MAAM,WAAW,GAAG,QAAQ,WAAW,GAAG,QAAQ;EAClD,IAAI,CAAC,mBAAmB,IAAI,QAAQ,GACnC,mBAAmB,IAAI,UAAU,OAAO;CAE1C;CACA,OAAO,CAAC,GAAG,mBAAmB,OAAO,CAAC;AACvC"}
|
|
@@ -27,6 +27,7 @@ export declare class LinearIntegration extends IssuesIntegration<IssuesCloudHost
|
|
|
27
27
|
*/
|
|
28
28
|
private readonly _autolinks;
|
|
29
29
|
private readonly _autolinksBuilds;
|
|
30
|
+
private readonly _autolinksBuildLifetimes;
|
|
30
31
|
autolinks(): Promise<(AutolinkReference | DynamicAutolinkReference)[]>;
|
|
31
32
|
/**
|
|
32
33
|
* One build per token at a time: concurrent renders share it rather than each re-reading the teams. A drop or a
|
|
@@ -70,10 +70,15 @@ var LinearIntegration = class extends IssuesIntegration {
|
|
|
70
70
|
*/
|
|
71
71
|
_autolinks = /* @__PURE__ */ new Map();
|
|
72
72
|
_autolinksBuilds = /* @__PURE__ */ new Map();
|
|
73
|
+
_autolinksBuildLifetimes = /* @__PURE__ */ new WeakMap();
|
|
73
74
|
async autolinks() {
|
|
74
75
|
if (!(this.maybeConnected ?? await this.isConnected()) || this._session == null) return [];
|
|
75
76
|
const session = this._session;
|
|
76
77
|
const cached = this._autolinks.get(session.accessToken);
|
|
78
|
+
if (!this.captureDiscoveryLifetime(session)() || cached?.isCurrent?.() === false) {
|
|
79
|
+
this._autolinks.delete(session.accessToken);
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
77
82
|
if (this.connectionExpired === true) return cached?.autolinks ?? [];
|
|
78
83
|
if (cached == null || cached.builtAt === 0 && !cached.complete && cached.autolinks.length === 0) return this.buildAutolinks(session);
|
|
79
84
|
if (cached.builtAt === 0 || isAutolinkSetExpired(cached)) this.buildAutolinks(session);
|
|
@@ -87,42 +92,53 @@ var LinearIntegration = class extends IssuesIntegration {
|
|
|
87
92
|
buildAutolinks(session) {
|
|
88
93
|
const { accessToken } = session;
|
|
89
94
|
let build = this._autolinksBuilds.get(accessToken);
|
|
90
|
-
if (build == null) {
|
|
95
|
+
if (build == null || this._autolinksBuildLifetimes.get(build)?.() === false) {
|
|
96
|
+
const isCurrent = this.captureDiscoveryLifetime(session);
|
|
91
97
|
build = this.buildAutolinksCore(session, () => build).finally(() => {
|
|
92
98
|
if (this._autolinksBuilds.get(accessToken) === build) this._autolinksBuilds.delete(accessToken);
|
|
93
99
|
});
|
|
94
100
|
this._autolinksBuilds.set(accessToken, build);
|
|
101
|
+
this._autolinksBuildLifetimes.set(build, isCurrent);
|
|
95
102
|
}
|
|
96
103
|
return build;
|
|
97
104
|
}
|
|
98
105
|
async buildAutolinksCore(session, reader) {
|
|
99
106
|
const { accessToken } = session;
|
|
107
|
+
const isCurrent = this.captureDiscoveryLifetime(session);
|
|
100
108
|
const generation = this._teams.generation;
|
|
101
109
|
try {
|
|
102
|
-
const organization = await this.getOrganization(session, false, reader);
|
|
103
|
-
if (organization != null && this._teams.generation === generation) {
|
|
104
|
-
const teams = await this.getTeamsWithMetadata(session, false, reader);
|
|
105
|
-
if (teams != null && this._teams.generation !== generation) return getTeamAutolinks(organization, teams.values);
|
|
110
|
+
const organization = await this.getOrganization(session, false, reader, isCurrent);
|
|
111
|
+
if (organization != null && isCurrent() && this._teams.generation === generation) {
|
|
112
|
+
const teams = await this.getTeamsWithMetadata(session, false, reader, isCurrent);
|
|
113
|
+
if (teams != null && (!isCurrent() || this._teams.generation !== generation)) return getTeamAutolinks(organization, teams.values);
|
|
106
114
|
}
|
|
107
115
|
} catch (ex) {
|
|
108
116
|
_logger.error(ex, "LinearIntegration.autolinks");
|
|
109
117
|
}
|
|
110
|
-
return this.deriveAutolinks(accessToken, {
|
|
118
|
+
return this.deriveAutolinks(accessToken, {
|
|
119
|
+
isCurrent,
|
|
120
|
+
store: isCurrent() && this._teams.generation === generation
|
|
121
|
+
});
|
|
111
122
|
}
|
|
112
123
|
deriveAutolinks(accessToken, options) {
|
|
113
124
|
const organization = this._organizations.peek(accessToken);
|
|
114
125
|
const complete = this._organizations.get(accessToken) != null && this._teams.get(accessToken) != null;
|
|
115
126
|
const autolinks = organization != null ? getTeamAutolinks(organization, this._teams.peek(accessToken) ?? []) : [];
|
|
127
|
+
for (const [token, cached] of this._autolinks) if (cached.isCurrent?.() === false) this._autolinks.delete(token);
|
|
116
128
|
if (options?.store !== false) this._autolinks.set(accessToken, {
|
|
117
129
|
autolinks,
|
|
130
|
+
isCurrent: options?.isCurrent,
|
|
118
131
|
complete,
|
|
119
132
|
builtAt: options?.settled !== false ? Date.now() : this._autolinks.get(accessToken)?.builtAt || (complete ? Date.now() : 0)
|
|
120
133
|
});
|
|
121
134
|
return autolinks;
|
|
122
135
|
}
|
|
123
|
-
onDiscoveryStored(accessToken, reader) {
|
|
136
|
+
onDiscoveryStored(accessToken, reader, isCurrent) {
|
|
124
137
|
if (this._autolinksBuilds.get(accessToken) !== reader?.()) this._autolinksBuilds.delete(accessToken);
|
|
125
|
-
this.deriveAutolinks(accessToken, {
|
|
138
|
+
this.deriveAutolinks(accessToken, {
|
|
139
|
+
settled: false,
|
|
140
|
+
isCurrent
|
|
141
|
+
});
|
|
126
142
|
}
|
|
127
143
|
/** The workspace is the token's organization; kept only as a complete, trimmed pair. */
|
|
128
144
|
async getProviderResourceForSession(session) {
|
|
@@ -141,7 +157,7 @@ var LinearIntegration = class extends IssuesIntegration {
|
|
|
141
157
|
* it; but not across a drop, since a lookup started before a forced refresh answers as from before it (#6162).
|
|
142
158
|
*/
|
|
143
159
|
_organizationRequests = /* @__PURE__ */ new Map();
|
|
144
|
-
async getOrganization(session, force = false, reader) {
|
|
160
|
+
async getOrganization(session, force = false, reader, isCurrent = this.captureDiscoveryLifetime(session)) {
|
|
145
161
|
const { accessToken } = session;
|
|
146
162
|
const cached = this._organizations.get(accessToken);
|
|
147
163
|
if (cached != null && !force) return cached;
|
|
@@ -157,10 +173,11 @@ var LinearIntegration = class extends IssuesIntegration {
|
|
|
157
173
|
if (organization == null) return void 0;
|
|
158
174
|
const stored = this._organizations.set(accessToken, organization, {
|
|
159
175
|
generation,
|
|
160
|
-
read: started
|
|
176
|
+
read: started,
|
|
177
|
+
isCurrent
|
|
161
178
|
});
|
|
162
|
-
if (stored === "changed") this.onDiscoveryStored(accessToken, reader);
|
|
163
|
-
return stored === false && this._organizations.generation === generation ? this._organizations.peek(accessToken) : organization;
|
|
179
|
+
if (stored === "changed") this.onDiscoveryStored(accessToken, reader, isCurrent);
|
|
180
|
+
return stored === false && isCurrent() && this._organizations.generation === generation ? this._organizations.peek(accessToken) : organization;
|
|
164
181
|
}
|
|
165
182
|
async fetchOrganization(session) {
|
|
166
183
|
const organization = await (await this.getProvidersApi()).getLinearOrganization(toTokenWithInfo(this.id, session));
|
|
@@ -176,7 +193,7 @@ var LinearIntegration = class extends IssuesIntegration {
|
|
|
176
193
|
async getTeams(session, force = false) {
|
|
177
194
|
return (await this.getTeamsWithMetadata(session, force))?.values;
|
|
178
195
|
}
|
|
179
|
-
async getTeamsWithMetadata(session, force = false, reader) {
|
|
196
|
+
async getTeamsWithMetadata(session, force = false, reader, isCurrent = this.captureDiscoveryLifetime(session)) {
|
|
180
197
|
const { accessToken } = session;
|
|
181
198
|
const cachedResources = this._teams.get(accessToken);
|
|
182
199
|
if (cachedResources != null && !force) return { values: cachedResources };
|
|
@@ -187,10 +204,11 @@ var LinearIntegration = class extends IssuesIntegration {
|
|
|
187
204
|
const stored = this._teams.set(accessToken, read.values, {
|
|
188
205
|
generation,
|
|
189
206
|
read: started,
|
|
207
|
+
isCurrent,
|
|
190
208
|
complete: read.metadata == null || read.metadata.completeness === "complete"
|
|
191
209
|
});
|
|
192
|
-
if (stored === "changed") this.onDiscoveryStored(accessToken, reader);
|
|
193
|
-
else if (stored === false && this._teams.generation === generation) return {
|
|
210
|
+
if (stored === "changed") this.onDiscoveryStored(accessToken, reader, isCurrent);
|
|
211
|
+
else if (stored === false && isCurrent() && this._teams.generation === generation) return {
|
|
194
212
|
values: this._teams.peek(accessToken) ?? read.values,
|
|
195
213
|
metadata: this._teams.get(accessToken) == null ? { completeness: "unknown" } : void 0
|
|
196
214
|
};
|
|
@@ -245,18 +263,23 @@ var LinearIntegration = class extends IssuesIntegration {
|
|
|
245
263
|
getWorkspaceProjects(session, fresh) {
|
|
246
264
|
const { accessToken } = session;
|
|
247
265
|
const generation = this._workspaceProjects.generation;
|
|
266
|
+
const isCurrent = this.captureDiscoveryLifetime(session);
|
|
248
267
|
if (!fresh) {
|
|
249
268
|
const cached = this._workspaceProjects.get(accessToken);
|
|
250
269
|
if (cached != null) return Promise.resolve({ values: cached });
|
|
251
270
|
const inFlight = this._workspaceProjectsReads.get(accessToken);
|
|
252
|
-
if (inFlight?.generation === generation) return inFlight.read;
|
|
271
|
+
if (inFlight?.generation === generation && inFlight.isCurrent()) return inFlight.read;
|
|
253
272
|
}
|
|
254
273
|
const entry = {
|
|
255
274
|
generation,
|
|
275
|
+
isCurrent,
|
|
256
276
|
read: this.readWorkspaceProjects(session)
|
|
257
277
|
};
|
|
258
278
|
entry.read = entry.read.then((result) => {
|
|
259
|
-
if (this._workspaceProjectsReads.get(accessToken) === entry && result.truncated !== true && (result.metadata == null || result.metadata.completeness === "complete")) this._workspaceProjects.set(accessToken, result.values, {
|
|
279
|
+
if (this._workspaceProjectsReads.get(accessToken) === entry && result.truncated !== true && (result.metadata == null || result.metadata.completeness === "complete")) this._workspaceProjects.set(accessToken, result.values, {
|
|
280
|
+
generation,
|
|
281
|
+
isCurrent
|
|
282
|
+
});
|
|
260
283
|
return result;
|
|
261
284
|
});
|
|
262
285
|
this._workspaceProjectsReads.set(accessToken, entry);
|