@gitkraken/core-gitlens 0.37.1 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -1
- package/dist/git/cache.d.ts +128 -8
- package/dist/git/cache.js +425 -46
- package/dist/git/cache.js.map +1 -1
- package/dist/git/features.d.ts +1 -1
- package/dist/git/features.js +3 -0
- package/dist/git/features.js.map +1 -1
- package/dist/git/providers/branches.d.ts +42 -1
- package/dist/git/providers/diff.d.ts +17 -0
- package/dist/git/providers/provider.d.ts +7 -0
- package/dist/git/providers/shared/remotes.js +8 -4
- package/dist/git/providers/shared/remotes.js.map +1 -1
- package/dist/git/remotes/matcher.js +2 -2
- package/dist/git/remotes/matcher.js.map +1 -1
- package/dist/git/repositoryService.d.ts +16 -1
- package/dist/git/repositoryService.js +51 -3
- package/dist/git/repositoryService.js.map +1 -1
- package/dist/git/run.types.d.ts +1 -0
- package/dist/git/service.js +6 -2
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/fileStatus.utils.d.ts +5 -0
- package/dist/git/utils/fileStatus.utils.js +18 -1
- package/dist/git/utils/fileStatus.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -3
- package/dist/git/watching/changeEvent.js +15 -4
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/changeOrdinal.d.ts +9 -0
- package/dist/git/watching/changeOrdinal.js +14 -0
- package/dist/git/watching/changeOrdinal.js.map +1 -0
- package/dist/git/watching/unwatchedCacheValidator.d.ts +38 -5
- package/dist/git/watching/unwatchedCacheValidator.js +180 -36
- package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
- package/dist/git/watching/watchGroup.d.ts +63 -14
- package/dist/git/watching/watchGroup.js +213 -74
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.js +4 -3
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +10 -2
- package/dist/git/watching/watchSession.js +18 -4
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +18 -4
- package/dist/git/watching/watcherPatterns.js +39 -8
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +23 -12
- package/dist/git/watching/worktreeSummary.js +164 -41
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +1 -0
- package/dist/git-cli/cliGitProvider.js +11 -2
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +7 -2
- package/dist/git-cli/exec/git.js +46 -10
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/headState.d.ts +24 -0
- package/dist/git-cli/exec/headState.js +46 -6
- package/dist/git-cli/exec/headState.js.map +1 -1
- package/dist/git-cli/parsers/logParser.js +6 -3
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +135 -10
- package/dist/git-cli/providers/branches.js +622 -80
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.d.ts +16 -0
- package/dist/git-cli/providers/commits.js +80 -28
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +10 -0
- package/dist/git-cli/providers/config.js +50 -12
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.js +11 -7
- package/dist/git-cli/providers/contributors.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts +12 -0
- package/dist/git-cli/providers/diff.js +107 -15
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/graph.js +32 -25
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +37 -3
- package/dist/git-cli/providers/operations.js +124 -46
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/patch.js +1 -1
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/refs.d.ts +1 -1
- package/dist/git-cli/providers/refs.js +10 -11
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +4 -5
- package/dist/git-cli/providers/status.js +36 -33
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.d.ts +8 -0
- package/dist/git-cli/providers/tags.js +53 -34
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/git-cli/service.d.ts +15 -0
- package/dist/git-cli/service.js +19 -1
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/git-github/providers/github/diff.d.ts +1 -0
- package/dist/plus/git-github/providers/github/diff.js +6 -1
- package/dist/plus/git-github/providers/github/diff.js.map +1 -1
- package/dist/plus/integrations/integrationService.js +9 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/providers/jira-server.js +1 -1
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +38 -6
- package/dist/plus/integrations/providers/jira.js +111 -69
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +31 -3
- package/dist/plus/integrations/providers/linear.js +77 -18
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +41 -4
- package/dist/plus/integrations/providers/utils/discoveryCache.js +50 -11
- package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/dist/utils/env/node/exec.d.ts +5 -4
- package/dist/utils/env/node/exec.js +52 -9
- package/dist/utils/env/node/exec.js.map +1 -1
- package/dist/utils/holdOffMap.d.ts +23 -0
- package/dist/utils/holdOffMap.js +43 -0
- package/dist/utils/holdOffMap.js.map +1 -0
- package/dist/utils/promiseCache.d.ts +15 -2
- package/dist/utils/promiseCache.js +34 -4
- package/dist/utils/promiseCache.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linear.js","names":[],"sources":["../../../../../plus/integrations/src/providers/linear.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure, GitIssueState } 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, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { IssueResourceDescriptor, ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { isIssueResourceDescriptor } from '@gitlens/git/utils/resourceDescriptor.utils.js';\nimport { chunk } from '@gitlens/utils/array.js';\nimport { trace } from '@gitlens/utils/decorators/log.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { mapSettledBounded } from '@gitlens/utils/promise.js';\nimport { PromiseCache } from '@gitlens/utils/promiseCache.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { ConnectionResource, ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { IssuesCloudHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport { IntegrationReadUnavailableError, toError } from '../errors.js';\nimport type { IntegrationResult, IssueEtagFields } from '../models/integration.js';\nimport { isReadSessionFailure } from '../models/integration.js';\nimport type {\n\tAccountWideIssuesResult,\n\tIssuesForProjectOptions,\n\tProjectIssuesDrain,\n\tProjectIssuesRequest,\n\tSearchMyIssuesOptions,\n} from '../models/issueReads.js';\nimport {\n\tgroupProjectIssuesSearches,\n\tIssuesIntegration,\n\tsplitProjectIssuesSearch,\n} from '../models/issuesIntegration.js';\nimport { IssueFilter } from '../providerFilters.js';\nimport type { LinearIssueEtagNode } from './linearIssuesEtag.js';\nimport { linearIssuesEtagMaxNumbers, toLinearIssueEtagFields } from './linearIssuesEtag.js';\nimport type {\n\tProviderApiCollectionResult,\n\tProviderHierarchyResult,\n\tProviderIssue,\n\tProviderLinearProject,\n} from './models.js';\nimport { fromProviderIssue, providersMetadata, toIssueShape, toProviderIssueStates } from './models.js';\nimport { DiscoveryCache, discoveryCacheTtl } from './utils/discoveryCache.js';\nimport { createIssueAutolinkReferences } from './utils/issueAutolinks.js';\nimport { collectProviderPagedResult, mergeCollectionMetadata } from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[IssuesCloudHostIntegrationId.Linear];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\nconst maxPagesPerRequest = 10;\n/**\n * The account-wide drain's own backstop, separate from {@link maxPagesPerRequest}.\n *\n * Raised to 50 (5,000 issues at the SDK's 100-per-page) because 10 no longer means what it used to. That read\n * once fanned out over four overlapping relationship queries and merged them, so most of what a page cost was\n * rows already returned — a low budget capped the waste. It is now a single server-ordered query over an `or`\n * filter, so every page is 100 issues the caller has not seen, and the same budget just truncates real results\n * at 1,000.\n *\n * Reaching it is reported rather than silent: {@link LinearIntegration.searchProviderMyIssuesWithTruncation}\n * returns `truncated`, so the facade can say the read was incomplete instead of publishing a capped list as a\n * whole account. The bound stays — a runaway cursor must not spend requests forever — but it is now set where a\n * real Linear account is unlikely to reach it rather than where the duplication used to hurt.\n */\nconst maxAccountWidePagesPerRequest = 50;\nconst linearImplicitTeamsPageSize = 50;\n/** The workspace Projects read's backstop: provider-apis pages them 100 at a time, so 2,000 Projects. */\nconst maxWorkspaceProjectPages = 20;\n/** Long enough to span one tracker read, short enough that a profile change shows on the next. */\nconst recentAccountTTL = 60 * 1000;\n/** A team key and issue number, as Linear writes an issue's identifier (`ENG-123`). */\nconst linearIdentifier = /^([A-Za-z0-9]+)-(\\d+)$/;\n\nexport interface LinearTeamDescriptor extends IssueResourceDescriptor {\n\tavatarUrl: string | undefined;\n}\n\nexport interface LinearOrganizationDescriptor extends IssueResourceDescriptor {\n\turl: string;\n}\n\nexport interface LinearProjectDescriptor extends IssueResourceDescriptor {}\n\n/** The part of a team read's filter that narrows it to the viewer. */\ntype LinearViewerScope = { assignees: string[]; githubSyncedCreators?: string[] };\n\n/**\n * How a user-scoped team read narrows to the viewer: the issues assigned to them, plus, unless the caller asked for\n * assigned issues by name, the GitHub-synced issues they created. Linear's GitHub Issues sync makes the GitHub author\n * of an issue (one who linked their GitHub account) the creator of its Linear copy but assigns no one GitHub doesn't,\n * so an assignee-only read never returns the copy of a GitHub issue the user filed (gitkraken/kepler#4480). Only\n * synced issues widen, and only those the viewer created on either side: the rest of what the user created in Linear\n * stays out of \"my issues\", as does a synced issue they merely follow.\n */\nfunction viewerScope(viewerId: string, filters: IssueFilter[] | undefined): LinearViewerScope {\n\treturn filters?.includes(IssueFilter.Assignee)\n\t\t? { assignees: [viewerId] }\n\t\t: { assignees: [viewerId], githubSyncedCreators: [viewerId] };\n}\n\nexport class LinearIntegration extends IssuesIntegration<IssuesCloudHostIntegrationId.Linear> {\n\t/**\n\t * Built from the teams, so it follows them: rebuilt when the team list changes or the caches are dropped, and once\n\t * older than {@link discoveryCacheTtl}. An expired set is still served while it is rebuilt in the background, because\n\t * autolinks are read on every render of a commit message and must not wait on the network (#5907).\n\t */\n\tprivate readonly _autolinks = new Map<\n\t\tstring,\n\t\t{ autolinks: (AutolinkReference | DynamicAutolinkReference)[]; builtAt: number }\n\t>();\n\tprivate readonly _autolinksBuilds = new Map<string, Promise<(AutolinkReference | DynamicAutolinkReference)[]>>();\n\n\toverride async autolinks(): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected || this._session == null) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst session = this._session;\n\t\tconst cached = this._autolinks.get(session.accessToken);\n\t\t// A session kept through a failed refresh is expired: building with it would send that token to the provider\n\t\t// on every render, so serve whatever was built before (none after a forced re-sync) until a read refreshes it.\n\t\tif (this.connectionExpired === true) return cached?.autolinks ?? [];\n\t\tif (cached == null) return this.buildAutolinks(session);\n\n\t\tif (Date.now() - cached.builtAt >= discoveryCacheTtl) {\n\t\t\tvoid this.buildAutolinks(session).catch(() => {});\n\t\t}\n\t\treturn cached.autolinks;\n\t}\n\n\t/** One build per token at a time: concurrent renders share it rather than each re-reading the teams. */\n\tprivate buildAutolinks(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tlet build = this._autolinksBuilds.get(accessToken);\n\t\tif (build == null) {\n\t\t\tbuild = this.buildAutolinksCore(session).finally(() => this._autolinksBuilds.delete(accessToken));\n\t\t\tthis._autolinksBuilds.set(accessToken, build);\n\t\t}\n\t\treturn build;\n\t}\n\n\tprivate async buildAutolinksCore(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst generation = this._teams.generation;\n\t\tconst organization = await this.getOrganization(session);\n\t\tif (organization == null) return [];\n\n\t\tconst autolinks: (AutolinkReference | DynamicAutolinkReference)[] = [];\n\n\t\tconst teams = await this.getTeams(session);\n\t\tfor (const team of teams ?? []) {\n\t\t\tautolinks.push(\n\t\t\t\t...createIssueAutolinkReferences(team.key, `${organization.url}/issue/${team.key}-<num>`, organization),\n\t\t\t);\n\t\t}\n\n\t\t// Not kept when built from teams read before the caches were dropped.\n\t\tif (this._teams.generation === generation) {\n\t\t\tthis._autolinks.set(session.accessToken, { autolinks: autolinks, builtAt: Date.now() });\n\t\t}\n\t\treturn autolinks;\n\t}\n\n\t/** The workspace is the token's organization; kept only as a complete, trimmed pair. */\n\toverride async getProviderResourceForSession(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ConnectionResource | undefined> {\n\t\tconst organization = await this.getOrganization(session, true);\n\t\tconst id = organization?.id.trim();\n\t\tconst name = organization?.name.trim();\n\t\treturn id && name ? { id: id, name: name } : undefined;\n\t}\n\n\tprivate _organizations: Map<string, LinearOrganizationDescriptor | undefined> | undefined;\n\t/**\n\t * In flight by token and discovery generation. The request can't be aborted (provider-apis takes no signal), so a\n\t * lookup that outlives its caller's timeout is joined by the next one rather than piling another request on top of\n\t * it; but not across a drop, since a lookup started before a forced refresh answers as from before it (#6162).\n\t */\n\tprivate readonly _organizationRequests = new Map<string, Promise<LinearOrganizationDescriptor | undefined>>();\n\tprivate async getOrganization(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<LinearOrganizationDescriptor | undefined> {\n\t\tconst { accessToken } = session;\n\t\t// Held across the await: a re-sync drops `_organizations` meanwhile, and this read must still complete.\n\t\tconst organizations = (this._organizations ??= new Map<string, LinearOrganizationDescriptor | undefined>());\n\n\t\tconst cachedResources = organizations.get(accessToken);\n\n\t\tif (cachedResources == null || force) {\n\t\t\tconst requestKey = `${this.discoveryGeneration}:${accessToken}`;\n\t\t\tlet request = this._organizationRequests.get(requestKey);\n\t\t\tif (request == null) {\n\t\t\t\trequest = this.fetchOrganization(session).finally(() => this._organizationRequests.delete(requestKey));\n\t\t\t\tthis._organizationRequests.set(requestKey, request);\n\t\t\t}\n\n\t\t\tconst descriptor = await request;\n\t\t\tif (descriptor) {\n\t\t\t\torganizations.set(accessToken, descriptor);\n\t\t\t}\n\t\t}\n\n\t\treturn organizations.get(accessToken);\n\t}\n\n\tprivate async fetchOrganization(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<LinearOrganizationDescriptor | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst organization = await api.getLinearOrganization(toTokenWithInfo(this.id, session));\n\t\treturn (\n\t\t\torganization && {\n\t\t\t\tid: organization.id,\n\t\t\t\tkey: organization.key,\n\t\t\t\tname: organization.name,\n\t\t\t\turl: organization.url,\n\t\t\t}\n\t\t);\n\t}\n\n\t/** Expires, and is dropped on a re-sync, so a team created or left mid-session is picked up (#5907). */\n\tprivate readonly _teams = new DiscoveryCache<LinearTeamDescriptor[]>();\n\tprivate async getTeams(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<LinearTeamDescriptor[] | undefined> {\n\t\treturn (await this.getTeamsWithMetadata(session, force))?.values;\n\t}\n\n\tprivate async getTeamsWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<ProviderApiCollectionResult<LinearTeamDescriptor> | undefined> {\n\t\tconst { accessToken } = session;\n\n\t\tconst cachedResources = this._teams.get(accessToken);\n\t\tif (cachedResources != null && !force) return { values: cachedResources };\n\n\t\tconst generation = this._teams.generation;\n\t\tconst read = await this.readTeams(session);\n\t\tif (read?.metadata != null) return read;\n\n\t\tif (read != null && this._teams.set(accessToken, read.values, { generation: generation })) {\n\t\t\t// Built from the teams; a new set means new prefixes.\n\t\t\tthis._autolinks.delete(accessToken);\n\t\t}\n\t\treturn read;\n\t}\n\n\tprivate async readTeams(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderApiCollectionResult<LinearTeamDescriptor> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst teams = await api.getLinearTeamsForCurrentUser(toTokenWithInfo(this.id, session));\n\t\tconst descriptors: LinearTeamDescriptor[] | undefined = teams?.map(t => ({\n\t\t\tid: t.id,\n\t\t\tkey: t.key,\n\t\t\tname: t.name,\n\t\t\tavatarUrl: t.iconUrl,\n\t\t}));\n\t\tif (descriptors == null) return undefined;\n\n\t\t// provider-apis currently requests Linear's teams connection without pageInfo or a cursor. Linear's\n\t\t// implicit page size is 50, so exactly a full page cannot prove there is no team 51. Preserve the useful\n\t\t// prefix, but mark it unknown and leave it uncached so the next read retries instead of treating it as\n\t\t// authoritative. Once provider-apis exposes a paged primitive, replace this fail-closed guard with a drain.\n\t\tif (descriptors.length >= linearImplicitTeamsPageSize) {\n\t\t\treturn { values: descriptors, metadata: { completeness: 'unknown' } };\n\t\t}\n\n\t\treturn { values: descriptors };\n\t}\n\n\t/**\n\t * The workspace's Linear Projects (Linear's `Project` entity), drained across their pages. Separate from the\n\t * teams this integration lists as its projects: a Linear Project can span several teams, and selecting one\n\t * narrows an issue read (`IssuesForProjectOptions.linearProjects`) rather than naming what is read.\n\t *\n\t * Cached like the teams, and only when complete: a drain cut short by its backstop or a failed page is returned\n\t * with its `truncated`/`metadata` so the facade can say so, and read again next time. A first-page failure\n\t * rejects, which the result wrapper turns into `{ error }`. `fresh` reads past the cache and any read in flight,\n\t * for a caller that must not take a list from before what it needs to see (a Project created since).\n\t */\n\t@trace()\n\tasync getWorkspaceProjectsResult(\n\t\tconnectionId?: string,\n\t\toptions?: { fresh?: boolean },\n\t): Promise<IntegrationResult<ProviderHierarchyResult<ProviderLinearProject>>> {\n\t\tconst scope = getScopedLogger();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSession(connectionId, scope);\n\t\tif (session == null || isReadSessionFailure(session)) return session && { error: session.error };\n\n\t\ttry {\n\t\t\tconst projects = await this.getWorkspaceProjects(session, options?.fresh === true);\n\t\t\tawait this.confirmScopedAuthFailures(session, projects.metadata);\n\t\t\tthis.resetRequestExceptionCount('getProjectsForResources', connectionId);\n\t\t\treturn { value: projects };\n\t\t} catch (ex) {\n\t\t\tthis.handleProviderException('getProjectsForResources', ex, { connectionId: connectionId });\n\t\t\treturn { error: toError(ex) };\n\t\t}\n\t}\n\n\t/** Expires, and is dropped on a re-sync, so a Project created or archived mid-session is picked up. */\n\tprivate readonly _workspaceProjects = new DiscoveryCache<ProviderLinearProject[]>();\n\t/**\n\t * In flight by token, with the cache generation it started under: concurrent cold reads share one drain, but a\n\t * read after the cache was dropped (a `forceSync`) never joins one started before, which could miss what it asks\n\t * to see.\n\t */\n\tprivate readonly _workspaceProjectsReads = new Map<\n\t\tstring,\n\t\t{ generation: number; read: Promise<ProviderHierarchyResult<ProviderLinearProject>> }\n\t>();\n\tprivate getWorkspaceProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t\tfresh: boolean,\n\t): Promise<ProviderHierarchyResult<ProviderLinearProject>> {\n\t\tconst { accessToken } = session;\n\t\tconst generation = this._workspaceProjects.generation;\n\t\tif (!fresh) {\n\t\t\tconst cached = this._workspaceProjects.get(accessToken);\n\t\t\tif (cached != null) return Promise.resolve({ values: cached });\n\n\t\t\tconst inFlight = this._workspaceProjectsReads.get(accessToken);\n\t\t\tif (inFlight?.generation === generation) return inFlight.read;\n\t\t}\n\n\t\tconst entry = { generation: generation, read: this.readWorkspaceProjects(session) };\n\t\tentry.read = entry.read.then(result => {\n\t\t\tif (\n\t\t\t\tthis._workspaceProjectsReads.get(accessToken) === entry &&\n\t\t\t\tresult.truncated !== true &&\n\t\t\t\t(result.metadata == null || result.metadata.completeness === 'complete')\n\t\t\t) {\n\t\t\t\tthis._workspaceProjects.set(accessToken, result.values, { generation: generation });\n\t\t\t}\n\t\t\treturn result;\n\t\t});\n\t\tthis._workspaceProjectsReads.set(accessToken, entry);\n\t\tvoid entry.read\n\t\t\t.finally(() => {\n\t\t\t\tif (this._workspaceProjectsReads.get(accessToken) === entry) {\n\t\t\t\t\tthis._workspaceProjectsReads.delete(accessToken);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(() => {});\n\t\treturn entry.read;\n\t}\n\n\t/**\n\t * Drains the Projects cursor up to {@link maxWorkspaceProjectPages}. A first-page failure rejects, so the read\n\t * fails as the team read does rather than reading as a workspace with no Projects; a later one keeps the prefix\n\t * and records the failure, as do a stalled cursor and the backstop with pages left.\n\t */\n\tprivate async readWorkspaceProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderLinearProject>> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tlet pagesRead = 0;\n\t\tlet firstPageError: Error | undefined;\n\t\tconst read = await collectProviderPagedResult(\n\t\t\tasync cursor => {\n\t\t\t\ttry {\n\t\t\t\t\tconst page = await api.getLinearProjects(tokenWithInfo, { cursor: cursor });\n\t\t\t\t\tpagesRead++;\n\t\t\t\t\treturn page;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (pagesRead === 0) {\n\t\t\t\t\t\tfirstPageError = toError(ex);\n\t\t\t\t\t}\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\tmaxWorkspaceProjectPages,\n\t\t\t{ providerId: this.id },\n\t\t);\n\t\t// The drain records any failure against its scope and keeps the prefix; with no prefix, there is no list.\n\t\tif (firstPageError != null) throw firstPageError;\n\n\t\treturn read;\n\t}\n\n\tprotected override async getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ResourceDescriptor[] | undefined> {\n\t\tconst organization = await this.getOrganization(session);\n\t\treturn organization != null ? [organization] : undefined;\n\t}\n\tprotected override async getProviderUncachedResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ResourceDescriptor[] | undefined> {\n\t\t// Joins none in flight, unlike `getOrganization`: one may have started before what the caller needs to see.\n\t\tconst organization = await this.fetchOrganization(session);\n\t\treturn organization != null ? [organization] : undefined;\n\t}\n\tprotected override getProviderProjectsForResources(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resources: ResourceDescriptor[],\n\t): Promise<ResourceDescriptor[] | undefined> {\n\t\treturn this.getTeams(session);\n\t}\n\tprotected override async getProviderProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resources: ResourceDescriptor[],\n\t): Promise<ProviderApiCollectionResult<ResourceDescriptor>> {\n\t\treturn (await this.getTeamsWithMetadata(session)) ?? { values: [], metadata: { completeness: 'unknown' } };\n\t}\n\tprotected override async getProviderUncachedProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resources: ResourceDescriptor[],\n\t): Promise<ProviderApiCollectionResult<ResourceDescriptor>> {\n\t\treturn (await this.readTeams(session)) ?? { values: [], metadata: { completeness: 'unknown' } };\n\t}\n\n\tprotected override clearDiscoveryCaches(): void {\n\t\tthis._organizations = undefined;\n\t\tthis._teams.clear();\n\t\tthis._workspaceProjects.clear();\n\t\tthis._workspaceProjectsReads.clear();\n\t\tthis._autolinks.clear();\n\t\tthis._recentAccounts.clear();\n\t}\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\n\t/**\n\t * Always asks Linear: the host's current-account cache decides when this runs. The viewer query is account-wide,\n\t * so the answer is lent briefly to the per-resource lookup a tracker read makes right after it.\n\t */\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst account = await this.fetchAccount(session);\n\t\tif (account != null) {\n\t\t\tthis._recentAccounts.set(session.accessToken, Promise.resolve(account));\n\t\t}\n\t\treturn account;\n\t}\n\n\tprotected override getProviderUncachedAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: ResourceDescriptor,\n\t): Promise<Account | undefined> {\n\t\treturn this.fetchAccount(session);\n\t}\n\n\tprotected override async getProviderAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: ResourceDescriptor,\n\t): Promise<Account | undefined> {\n\t\treturn this._recentAccounts.getOrCreate(session.accessToken, () => this.fetchAccount(session), {\n\t\t\tevictWhen: account => account == null,\n\t\t});\n\t}\n\n\tprivate readonly _recentAccounts = new PromiseCache<string, Account | undefined>({\n\t\tcapacity: 10,\n\t\tcreateTTL: recentAccountTTL,\n\t});\n\n\tprivate async fetchAccount(session: ProviderAuthenticationSession): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// Linear's viewer isn't a ProviderAccount (no username/avatar), so build the Account manually\n\t\t// (Trello-style) from the fields the viewer query returns.\n\t\tconst user = await api.getLinearCurrentUser(toTokenWithInfo(this.id, session));\n\t\tif (user == null) return undefined;\n\n\t\treturn {\n\t\t\tprovider: this,\n\t\t\tid: user.id,\n\t\t\tname: user.name ?? user.displayName ?? undefined,\n\t\t\tusername: user.displayName ?? undefined,\n\t\t\temail: user.email ?? undefined,\n\t\t\tavatarUrl: undefined,\n\t\t};\n\t}\n\n\tprotected override async getProviderIssuesForProject(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: ResourceDescriptor,\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: ResourceDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<ProjectIssuesDrain | undefined> {\n\t\tif (!isIssueResourceDescriptor(project)) return undefined;\n\n\t\t// Scope to \"my issues\" by the viewer's stable id, not the passed display name: Linear's `name` (full name)\n\t\t// and `displayName` (nickname) are distinct fields, and assignees are normalized with `.name` = the full\n\t\t// name while the caller's `user` is the displayName — so a name string can miss. The assignee `.id` is the\n\t\t// Linear user id, which is unambiguous.\n\t\tlet viewerId: string | undefined;\n\t\tif (options?.user != null) {\n\t\t\tviewerId = await this.getViewerId(session, options);\n\t\t\t// If the viewer can't be resolved we can't scope to \"my issues\" — returning the unfiltered team\n\t\t\t// issues would leak everyone else's, and returning [] is indistinguishable from \"no issues assigned\n\t\t\t// to me\". Throw so the facade (getIssuesForProjectResult → runCaptured) surfaces a warning +\n\t\t\t// fetchFailed the caller can act on, instead of a silent empty.\n\t\t\tif (viewerId == null) {\n\t\t\t\tthrow new IntegrationReadUnavailableError(\n\t\t\t\t\tmetadata.name,\n\t\t\t\t\t'could not resolve the current user to scope issues to',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// `getProviderProjectsForResources` returns Linear teams, so `project.id` is a team id here.\n\t\t//\n\t\t// The state and the viewer are narrowed server-side, not after the drain: a team's done work and other\n\t\t// people's issues would otherwise count against the backstop, so a busy team runs out of pages before the\n\t\t// viewer's open issues and hands back a page that looks complete.\n\t\tconst drain = await this.drainIssues(\n\t\t\tsession,\n\t\t\t{\n\t\t\t\tteams: [project.id],\n\t\t\t\t...(options?.linearProjects?.length ? { projects: [...options.linearProjects] } : {}),\n\t\t\t\t...(viewerId != null ? viewerScope(viewerId, options?.filters) : {}),\n\t\t\t\tstates: toProviderIssueStates(options?.state),\n\t\t\t},\n\t\t\toptions?.sort,\n\t\t\t{ providerId: this.id, projectId: project.id },\n\t\t);\n\n\t\treturn drain.truncated\n\t\t\t? { values: drain.issues, truncated: true, recovery: 'none', metadata: drain.metadata }\n\t\t\t: { values: drain.issues, truncated: false, metadata: drain.metadata };\n\t}\n\n\t/**\n\t * Searches every team of a user-scoped read together: one `getIssues` names all of them and the viewer's scope\n\t * (see {@link viewerScope}), so a team with none of the user's issues costs no request of its own. Linear's filter\n\t * is a GraphQL body, not a query string, so there is no key bound to chunk at.\n\t *\n\t * A read narrowed to Linear Projects is searched together even across every assignee: the Projects already bound\n\t * it to a few teams' worth of issues, so a team holding none of them costs no request either. An unnarrowed read\n\t * of every assignee is still read team by team, since a search over all of them would just spend one team's page\n\t * budget before falling back.\n\t */\n\tprotected override getProjectIssuesSearches(\n\t\trequests: readonly ProjectIssuesRequest<ResourceDescriptor>[],\n\t): number[][] | undefined {\n\t\treturn groupProjectIssuesSearches(requests, ({ project, options }) =>\n\t\t\t(options.user != null || options.linearProjects?.length) && isIssueResourceDescriptor(project)\n\t\t\t\t? [\n\t\t\t\t\t\toptions.user ?? '',\n\t\t\t\t\t\toptions.userId ?? '',\n\t\t\t\t\t\toptions.sort ?? '',\n\t\t\t\t\t\toptions.state ?? '',\n\t\t\t\t\t\toptions.filters?.join(',') ?? '',\n\t\t\t\t\t\t...(options.linearProjects ?? []),\n\t\t\t\t\t].join('\\0')\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\tprotected override async searchProviderProjectIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trequests: readonly ProjectIssuesRequest<ResourceDescriptor>[],\n\t): Promise<IssueShape[][] | undefined> {\n\t\t// Every request of a search shares every option read here (see the key in `getProjectIssuesSearches`).\n\t\tconst { options } = requests[0];\n\t\tlet viewerId: string | undefined;\n\t\tif (options.user != null) {\n\t\t\t// Unresolvable here means each team's own read throws the same warning, so let them.\n\t\t\tviewerId = await this.getViewerId(session, options);\n\t\t\tif (viewerId == null) return undefined;\n\t\t} else if (!options.linearProjects?.length) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst teams = requests.map(request => request.project).filter(isIssueResourceDescriptor);\n\t\tif (teams.length !== requests.length) return undefined;\n\n\t\tconst drain = await this.drainIssues(\n\t\t\tsession,\n\t\t\t{\n\t\t\t\tteams: teams.map(team => team.id),\n\t\t\t\t...(options.linearProjects?.length ? { projects: [...options.linearProjects] } : {}),\n\t\t\t\t...(viewerId != null ? viewerScope(viewerId, options.filters) : {}),\n\t\t\t\tstates: toProviderIssueStates(options.state),\n\t\t\t},\n\t\t\toptions.sort,\n\t\t\t// Never published: an incomplete search is read again per team, which records its own failures.\n\t\t\t{ providerId: this.id },\n\t\t);\n\t\t// Deliberately discarded rather than served: an incomplete search says nothing about which of its teams it\n\t\t// covered, so only the per-team reads can report each one's completeness. The waste is bounded by one team's\n\t\t// page budget, and paid only by a search that needed more than that or failed partway.\n\t\tif (drain.truncated || (drain.metadata != null && drain.metadata.completeness !== 'complete')) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// A normalized Linear issue carries its team only inside `project`, which is absent for an issue in no\n\t\t// Linear project, so split by the identifier instead: Linear numbers every issue `<team key>-<n>`, and\n\t\t// renumbers it under its new team's key when it moves.\n\t\treturn splitProjectIssuesSearch(\n\t\t\tteams.map(team => team.key),\n\t\t\tdrain.issues,\n\t\t\tissue => {\n\t\t\t\tconst separator = issue.id.lastIndexOf('-');\n\t\t\t\treturn separator > 0 ? issue.id.slice(0, separator) : undefined;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate readonly _viewerIds = new PromiseCache<string, string | undefined>({ capacity: 10 });\n\t/**\n\t * The viewer's Linear user id: the caller's resolved `userId` when it has one, else the viewer query, shared per\n\t * token. A tracker read hands each team the id of the team's own resource, which Linear's team descriptors don't\n\t * name, so without sharing every team read (and a search's fallback) would ask for the viewer again.\n\t */\n\tprivate getViewerId(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: IssuesForProjectOptions,\n\t): Promise<string | undefined> {\n\t\tif (options.userId) return Promise.resolve(options.userId);\n\n\t\treturn this._viewerIds.getOrCreate(\n\t\t\tsession.accessToken,\n\t\t\tasync () => {\n\t\t\t\tconst api = await this.getProvidersApi();\n\t\t\t\treturn (await api.getLinearCurrentUser(toTokenWithInfo(this.id, session)))?.id;\n\t\t\t},\n\t\t\t// Only a resolved id is worth keeping; an unresolved viewer is asked for again next time, as is a failure.\n\t\t\t{ evictWhen: id => id == null },\n\t\t);\n\t}\n\n\t/**\n\t * Follows `getIssues`' cursor up to {@link maxPagesPerRequest}. `truncated` is set when that backstop stopped\n\t * the drain with more pages still available, when the provider stalled its cursor or flagged its paging as\n\t * truncated, or when a page after the first failed, which is recorded at `failureScope` while the prefix is\n\t * kept. A failure before any issue was kept throws, so the caller sees a hard error rather than an empty success.\n\t */\n\tprivate async drainIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tfilter: { teams: string[]; projects?: string[]; states?: GitIssueState[] } & Partial<LinearViewerScope>,\n\t\tsort: IssuesForProjectOptions['sort'],\n\t\tfailureScope: CollectionScopeFailure['scope'],\n\t): Promise<{ issues: IssueShape[]; truncated: boolean; metadata?: CollectionMetadata }> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst assignees = filter.assignees?.length ? filter.assignees : undefined;\n\t\tconst syncedCreators = filter.githubSyncedCreators?.length ? filter.githubSyncedCreators : undefined;\n\t\tlet cursor: string | undefined;\n\t\tlet hasMore: boolean;\n\t\tlet requestCount = 0;\n\t\tlet truncated = false;\n\t\tlet collectionMetadata: CollectionMetadata | undefined;\n\t\tconst issues: IssueShape[] = [];\n\t\tdo {\n\t\t\tlet result: Awaited<ReturnType<typeof api.getLinearIssues>>;\n\t\t\ttry {\n\t\t\t\tresult = await api.getLinearIssues(toTokenWithInfo(this.id, session), filter, {\n\t\t\t\t\tcursor: cursor,\n\t\t\t\t\tsort: sort,\n\t\t\t\t});\n\t\t\t} catch (ex) {\n\t\t\t\t// Keyed on what was kept, not on the page: provider-apis can empty a page it filters after the query\n\t\t\t\t// (synced-creator reads) and still report more, and a drain that kept nothing has nothing to serve, so\n\t\t\t\t// its caller retries it rather than recording an empty prefix as read.\n\t\t\t\tif (issues.length === 0) throw ex;\n\n\t\t\t\ttruncated = true;\n\t\t\t\tcollectionMetadata = mergeCollectionMetadata(collectionMetadata, {\n\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\tfailures: [toCollectionScopeFailure(failureScope, ex)],\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\trequestCount += 1;\n\t\t\thasMore = result.paging?.more ?? false;\n\t\t\tconst nextCursor = result.paging?.cursor;\n\t\t\ttruncated ||= result.paging?.truncated === true;\n\t\t\tcollectionMetadata = mergeCollectionMetadata(collectionMetadata, result.metadata);\n\t\t\tfor (const issue of result.values) {\n\t\t\t\tconst shape = toIssueShape(issue, this, { projection: 'project' });\n\t\t\t\t// The read already scopes to the assignees and to the synced issues the creators filed, leaving out the\n\t\t\t\t// issues with no GitHub sync link (`[]`) and keeping one whose link list Linear failed to resolve\n\t\t\t\t// (absent). Checking again keeps another user's issue, or an unsynced one only its GitHub attachment\n\t\t\t\t// matched, out of \"my issues\" should the provider ever return one.\n\t\t\t\tif (\n\t\t\t\t\tshape != null &&\n\t\t\t\t\t(assignees == null ||\n\t\t\t\t\t\tshape.assignees?.some(a => assignees.includes(a.id)) ||\n\t\t\t\t\t\t(syncedCreators != null &&\n\t\t\t\t\t\t\tshape.author != null &&\n\t\t\t\t\t\t\tsyncedCreators.includes(shape.author.id) &&\n\t\t\t\t\t\t\tshape.syncedWith?.length !== 0))\n\t\t\t\t) {\n\t\t\t\t\tissues.push(shape);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// The provider claims more but returns no advancing cursor: we can't continue without re-reading the\n\t\t\t// same page, so the drain is incomplete — flag it rather than silently stopping.\n\t\t\tif (hasMore && (nextCursor == null || nextCursor === cursor)) {\n\t\t\t\ttruncated = true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tif (hasMore && requestCount >= maxPagesPerRequest) {\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t} while (requestCount < maxPagesPerRequest && hasMore);\n\n\t\treturn { issues: issues, truncated: truncated, metadata: collectionMetadata };\n\t}\n\n\toverride get id(): IssuesCloudHostIntegrationId.Linear {\n\t\treturn IssuesCloudHostIntegrationId.Linear;\n\t}\n\tprotected override get key(): 'linear' {\n\t\treturn 'linear';\n\t}\n\toverride get name(): string {\n\t\treturn metadata.name;\n\t}\n\toverride get domain(): string {\n\t\treturn metadata.domain;\n\t}\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation))?.values;\n\t}\n\n\t/**\n\t * Account-wide \"my issues\" for Linear, drained to exhaustion and reporting whether it got there.\n\t *\n\t * The SDK read is one server-ordered query over an `or` filter across the four relationships (assigned,\n\t * created, named in an issue's content, named in a comment), so each page is 100 issues the caller has not\n\t * seen and the pages are ordered as one sequence. Draining it is therefore just following the cursor.\n\t *\n\t * Overridden rather than left to the base default because that default hardcodes `truncated: false`, and a\n\t * bounded drain that stops early is exactly the case a caller must be able to see. Three things end the\n\t * drain, and only one of them is completion:\n\t *\n\t * - the provider says there is no next page — complete;\n\t * - the backstop is reached — `truncated`, because issues beyond it exist and were not read;\n\t * - the provider claims a next page but hands back a cursor that does not advance — also `truncated`, since\n\t * the read cannot continue and the remainder is unreachable rather than absent.\n\t *\n\t * Cancellation is deliberately NOT truncation: the caller asked for the read to stop, so the partial list is\n\t * what it asked for, and flagging it would surface an incompleteness warning for a user action.\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tif (resources != null) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tlet cursor = undefined;\n\t\t// Starts false so an immediate cancellation, which leaves the loop before the first response, reads as\n\t\t// \"no more pages known\" rather than as an unfinished drain.\n\t\tlet hasMore = false;\n\t\tlet requestCount = 0;\n\t\tlet truncated = false;\n\t\tconst issues = [];\n\t\ttry {\n\t\t\tdo {\n\t\t\t\tif (cancellation?.aborted) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst result = await api.getIssuesForCurrentUser(toTokenWithInfo(this.id, session), {\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\t\trequestCount += 1;\n\t\t\t\thasMore = result.paging?.more ?? false;\n\t\t\t\tconst nextCursor = result.paging?.cursor;\n\n\t\t\t\t// Keep this page before deciding whether to continue: the request is already paid for, so\n\t\t\t\t// dropping its rows would lose real results to save nothing.\n\t\t\t\tconst formattedIssues = result.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\tif (formattedIssues.length > 0) {\n\t\t\t\t\tissues.push(...formattedIssues);\n\t\t\t\t}\n\n\t\t\t\t// The provider claims more but hands back no advancing cursor: continuing would re-read the page\n\t\t\t\t// just returned. `ProvidersApi.getPagedResult` already normalizes this into `more: false`, so\n\t\t\t\t// this is a backstop for if that ever stops holding rather than a case seen today -- but the rest\n\t\t\t\t// of the account is unreachable either way, which is what `truncated` says.\n\t\t\t\tif (hasMore && (nextCursor == null || nextCursor === cursor)) {\n\t\t\t\t\ttruncated = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcursor = nextCursor;\n\t\t\t} while (requestCount < maxAccountWidePagesPerRequest && hasMore);\n\n\t\t\t// Ran out of budget with pages still to come.\n\t\t\tif (hasMore && requestCount >= maxAccountWidePagesPerRequest) {\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (issues.length === 0) {\n\t\t\t\tthrow ex;\n\t\t\t}\n\n\t\t\t// Kept what was already fetched, so the list is real but short of the account.\n\t\t\ttruncated = true;\n\t\t\tLogger.error(ex, 'searchProviderMyIssues');\n\t\t}\n\t\treturn { values: issues, truncated: truncated };\n\t}\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: ResourceDescriptor,\n\t\t{ key }: { id: string; key: string },\n\t\t_type: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst issue = await this.getRawProviderIssue(session, resource, key);\n\t\tconst autolinkableIssue: ProviderIssue | undefined = issue && {\n\t\t\t...issue,\n\t\t\turl: this.getIssueAutolinkLikeUrl(issue),\n\t\t};\n\t\treturn autolinkableIssue && toIssueShape(autolinkableIssue, this, { projection: 'point' });\n\t}\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\tconst result = await this.getRawProviderIssue(session, resource, id);\n\t\treturn result && fromProviderIssue(result, this, { projection: 'point' });\n\t}\n\n\tprotected override async getProviderIssueByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresourceId: string,\n\t\tid: string,\n\t\t_resourceUrl: string | undefined,\n\t): Promise<Issue | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst result = await api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resourceId,\n\t\t\tnumber: id,\n\t\t});\n\t\treturn result && fromProviderIssue(result, this, { projection: 'batch' });\n\t}\n\n\t/**\n\t * The cheap check behind the batch issue read's etags: one `issues` query per team and\n\t * {@link linearIssuesEtagMaxNumbers} distinct numbers, where {@link getProviderIssueByResourceId} sends one request\n\t * per issue. A request that throws rejects only its own targets' slots, with its error classified as the full\n\t * read's would be.\n\t *\n\t * Never proves an absence. The query filters by the team's CURRENT key and asks for archived issues too, but the\n\t * full read's `issue(id:)` may also resolve an identifier the issue no longer carries (its team was renamed, or it\n\t * moved to another team), so an issue the query leaves out may still exist. Its target's slot is rejected, as is a\n\t * target whose identifier isn't a team key and a number, so the full read decides. When no target was answered and\n\t * nothing failed, the check declines instead, so a batch of only such targets 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 workspace and team's distinct numbers, with the targets asking for each.\n\t\tconst byTeam = new Map<string, { teamKey: string; numbers: Map<number, number[]> }>();\n\t\tfor (const [index, target] of targets.entries()) {\n\t\t\tconst match = linearIdentifier.exec(target.identifier);\n\t\t\tconst number = match != null ? Number(match[2]) : Number.NaN;\n\t\t\t// Only a number written as Linear writes it, so `ENG-012` never answers for `ENG-12`.\n\t\t\tif (match == null || !Number.isSafeInteger(number) || String(number) !== match[2]) {\n\t\t\t\tslots[index] = {\n\t\t\t\t\tstatus: 'rejected',\n\t\t\t\t\treason: new Error(`Not a Linear issue identifier: ${target.identifier}`),\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst teamKey = match[1].toUpperCase();\n\t\t\tconst groupKey = `${target.resourceId}\\n${teamKey}`;\n\t\t\tlet group = byTeam.get(groupKey);\n\t\t\tif (group == null) {\n\t\t\t\tgroup = { teamKey: teamKey, numbers: new Map() };\n\t\t\t\tbyTeam.set(groupKey, group);\n\t\t\t}\n\n\t\t\tlet indices = group.numbers.get(number);\n\t\t\tif (indices == null) {\n\t\t\t\tindices = [];\n\t\t\t\tgroup.numbers.set(number, indices);\n\t\t\t}\n\t\t\tindices.push(index);\n\t\t}\n\n\t\tconst requests = [...byTeam.values()].flatMap(({ teamKey, numbers }) =>\n\t\t\tchunk([...numbers], linearIssuesEtagMaxNumbers).map(entries => ({ teamKey: teamKey, entries: entries })),\n\t\t);\n\t\tif (requests.length) {\n\t\t\tconst api = await this.getProvidersApi();\n\t\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\t\tconst answers = await mapSettledBounded(requests, providerFanOutConcurrency, r =>\n\t\t\t\tapi.getLinearIssuesEtagFields(\n\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\tr.teamKey,\n\t\t\t\t\tr.entries.map(([number]) => number),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tfor (const [i, answer] of answers.entries()) {\n\t\t\t\tconst { teamKey, entries } = requests[i];\n\t\t\t\tif (answer.status === 'rejected') {\n\t\t\t\t\tfailed = true;\n\t\t\t\t\tfor (const [, indices] of entries) {\n\t\t\t\t\t\tfor (const index of indices) {\n\t\t\t\t\t\t\tslots[index] = answer;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// By number, never by position: Linear returns the issues in its own order, and only the ones it found.\n\t\t\t\tconst byNumber = new Map<number, LinearIssueEtagNode>();\n\t\t\t\tfor (const issue of answer.value) {\n\t\t\t\t\tbyNumber.set(issue.number, issue);\n\t\t\t\t}\n\n\t\t\t\tfor (const [number, indices] of entries) {\n\t\t\t\t\tconst issue = byNumber.get(number);\n\t\t\t\t\tlet slot: PromiseSettledResult<IssueEtagFields | undefined>;\n\t\t\t\t\tif (issue == null) {\n\t\t\t\t\t\tslot = { status: 'rejected', reason: new Error(`Linear did not return ${teamKey}-${number}`) };\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tslot = { status: 'fulfilled', value: toLinearIssueEtagFields(issue) };\n\t\t\t\t\t\t\tanswered = true;\n\t\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t\tslot = { status: 'rejected', reason: ex };\n\t\t\t\t\t\t\tfailed = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const index of indices) {\n\t\t\t\t\t\tslots[index] = slot;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn answered || failed ? slots : undefined;\n\t}\n\n\tprivate async getRawProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t): Promise<ProviderIssue | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!isIssueResourceDescriptor(resource)) {\n\t\t\tLogger.error(undefined, 'getProviderIssue: resource is not an IssueResourceDescriptor');\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resource.id,\n\t\t\tnumber: id,\n\t\t});\n\t}\n\tprivate getIssueAutolinkLikeUrl(issue: ProviderIssue): string | null {\n\t\tconst url = issue.url;\n\t\tif (url == null) return null;\n\n\t\tconst lastSegment = url.split('/').pop();\n\t\tif (!lastSegment || issue.number === lastSegment) {\n\t\t\treturn url;\n\t\t}\n\t\treturn url.substring(0, url.length - lastSegment.length - 1);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+CA,M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CAEA,MAAc,oBACb,SACA,UACA,IACqC;EACrC,MAAM,MAAM,MAAM,KAAK,gBAAgB;EACvC,IAAI,CAAC,0BAA0B,QAAQ,GAAG;GACzC,QAAO,MAAM,KAAA,GAAW,8DAA8D;GACtF;EACD;EAEA,OAAO,IAAI,SAAS,gBAAgB,KAAK,IAAI,OAAO,GAAG;GACtD,YAAY,SAAS;GACrB,QAAQ;EACT,CAAC;CACF;CACA,wBAAgC,OAAqC;EACpE,MAAM,MAAM,MAAM;EAClB,IAAI,OAAO,MAAM,OAAO;EAExB,MAAM,cAAc,IAAI,MAAM,GAAG,CAAC,CAAC,IAAI;EACvC,IAAI,CAAC,eAAe,MAAM,WAAW,aACpC,OAAO;EAER,OAAO,IAAI,UAAU,GAAG,IAAI,SAAS,YAAY,SAAS,CAAC;CAC5D;AACD;AAtsBE,WAAA,CAAA,MAAM,CAAA,GAAA,kBAAA,WAAA,8BAAA,IAAA"}
|
|
1
|
+
{"version":3,"file":"linear.js","names":[],"sources":["../../../../../plus/integrations/src/providers/linear.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure, GitIssueState } 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, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { IssueResourceDescriptor, ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { isIssueResourceDescriptor } from '@gitlens/git/utils/resourceDescriptor.utils.js';\nimport { chunk } from '@gitlens/utils/array.js';\nimport { trace } from '@gitlens/utils/decorators/log.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport { areEqual } from '@gitlens/utils/object.js';\nimport { mapSettledBounded } from '@gitlens/utils/promise.js';\nimport { PromiseCache } from '@gitlens/utils/promiseCache.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { ConnectionResource, ProviderAuthenticationSession } from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { IssuesCloudHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport { IntegrationReadUnavailableError, toError } from '../errors.js';\nimport type { IntegrationResult, IssueEtagFields } from '../models/integration.js';\nimport { isReadSessionFailure } from '../models/integration.js';\nimport type {\n\tAccountWideIssuesResult,\n\tIssuesForProjectOptions,\n\tProjectIssuesDrain,\n\tProjectIssuesRequest,\n\tSearchMyIssuesOptions,\n} from '../models/issueReads.js';\nimport {\n\tgroupProjectIssuesSearches,\n\tIssuesIntegration,\n\tsplitProjectIssuesSearch,\n} from '../models/issuesIntegration.js';\nimport { IssueFilter } from '../providerFilters.js';\nimport type { LinearIssueEtagNode } from './linearIssuesEtag.js';\nimport { linearIssuesEtagMaxNumbers, toLinearIssueEtagFields } from './linearIssuesEtag.js';\nimport type {\n\tProviderApiCollectionResult,\n\tProviderHierarchyResult,\n\tProviderIssue,\n\tProviderLinearProject,\n} from './models.js';\nimport { fromProviderIssue, providersMetadata, toIssueShape, toProviderIssueStates } from './models.js';\nimport { DiscoveryCache, isAutolinkSetExpired, isEmptyAutolinkFallback } from './utils/discoveryCache.js';\nimport { createIssueAutolinkReferences } from './utils/issueAutolinks.js';\nimport { collectProviderPagedResult, mergeCollectionMetadata } from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[IssuesCloudHostIntegrationId.Linear];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\nconst maxPagesPerRequest = 10;\n/**\n * The account-wide drain's own backstop, separate from {@link maxPagesPerRequest}.\n *\n * Raised to 50 (5,000 issues at the SDK's 100-per-page) because 10 no longer means what it used to. That read\n * once fanned out over four overlapping relationship queries and merged them, so most of what a page cost was\n * rows already returned — a low budget capped the waste. It is now a single server-ordered query over an `or`\n * filter, so every page is 100 issues the caller has not seen, and the same budget just truncates real results\n * at 1,000.\n *\n * Reaching it is reported rather than silent: {@link LinearIntegration.searchProviderMyIssuesWithTruncation}\n * returns `truncated`, so the facade can say the read was incomplete instead of publishing a capped list as a\n * whole account. The bound stays — a runaway cursor must not spend requests forever — but it is now set where a\n * real Linear account is unlikely to reach it rather than where the duplication used to hurt.\n */\nconst maxAccountWidePagesPerRequest = 50;\nconst linearImplicitTeamsPageSize = 50;\n/** The workspace Projects read's backstop: provider-apis pages them 100 at a time, so 2,000 Projects. */\nconst maxWorkspaceProjectPages = 20;\n/** Long enough to span one tracker read, short enough that a profile change shows on the next. */\nconst recentAccountTTL = 60 * 1000;\n/** A team key and issue number, as Linear writes an issue's identifier (`ENG-123`). */\nconst linearIdentifier = /^([A-Za-z0-9]+)-(\\d+)$/;\n\nexport interface LinearTeamDescriptor extends IssueResourceDescriptor {\n\tavatarUrl: string | undefined;\n}\n\nexport interface LinearOrganizationDescriptor extends IssueResourceDescriptor {\n\turl: string;\n}\n\nexport interface LinearProjectDescriptor extends IssueResourceDescriptor {}\n\n/** The part of a team read's filter that narrows it to the viewer. */\ntype LinearViewerScope = { assignees: string[]; githubSyncedCreators?: string[] };\n\n/**\n * How a user-scoped team read narrows to the viewer: the issues assigned to them, plus, unless the caller asked for\n * assigned issues by name, the GitHub-synced issues they created. Linear's GitHub Issues sync makes the GitHub author\n * of an issue (one who linked their GitHub account) the creator of its Linear copy but assigns no one GitHub doesn't,\n * so an assignee-only read never returns the copy of a GitHub issue the user filed (gitkraken/kepler#4480). Only\n * synced issues widen, and only those the viewer created on either side: the rest of what the user created in Linear\n * stays out of \"my issues\", as does a synced issue they merely follow.\n */\nfunction viewerScope(viewerId: string, filters: IssueFilter[] | undefined): LinearViewerScope {\n\treturn filters?.includes(IssueFilter.Assignee)\n\t\t? { assignees: [viewerId] }\n\t\t: { assignees: [viewerId], githubSyncedCreators: [viewerId] };\n}\n\nexport class LinearIntegration extends IssuesIntegration<IssuesCloudHostIntegrationId.Linear> {\n\t/**\n\t * Built from the teams, so it follows them: rebuilt when the team list changes or the caches are dropped, and once\n\t * {@link isAutolinkSetExpired}: older than the TTL, or than a shorter retry delay when the organization or the teams\n\t * couldn't be read whole. An expired set is still served while it is rebuilt in the background, because autolinks\n\t * are read on every render of a commit message and must not wait on the network (#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 whenever `_autolinks` is dropped for a list a build reads, so a build that then fails keeps no fallback\n\t * over a list it didn't read; the next render builds from it instead (#6183). Rule: every writer that stores a\n\t * different team list must bump it and retire the token's build, through {@link onTeamListStored}, today only\n\t * `getTeamsWithMetadata`'s store; the same list stored again does neither while a complete set is kept (#6184). The\n\t * organization map deliberately doesn't: it only changes the links' url, on a forced read. Drops need no bump: they\n\t * move `_teams.generation`, which fails the build.\n\t */\n\tprivate _autolinksResets = 0;\n\n\toverride async autolinks(): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst connected = this.maybeConnected ?? (await this.isConnected());\n\t\tif (!connected || this._session == null) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst session = this._session;\n\t\tconst cached = this._autolinks.get(session.accessToken);\n\t\t// A session kept through a failed refresh is expired: building with it would send that token to the provider\n\t\t// on every render, so serve whatever was built before (none after a forced re-sync) until a read refreshes it.\n\t\tif (this.connectionExpired === true) return cached?.autolinks ?? [];\n\t\tif (cached == null) return this.buildAutolinks(session);\n\n\t\tif (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 the teams. A drop or a\n\t * change to the team list retires it, so a render after one doesn't join a build reading the teams as they were\n\t * before (#6170, #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).finally(() => {\n\t\t\t\t// A drop or a list change meanwhile retired this build, and the entry may be a later 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): Promise<(AutolinkReference | DynamicAutolinkReference)[]> {\n\t\tconst { accessToken } = session;\n\t\tconst generation = this._teams.generation;\n\t\tconst resets = this._autolinksResets;\n\t\t// What this build falls back on when it can't read the organization or the teams\n\t\tconst held = this._autolinks.get(accessToken);\n\t\t// Kept even when incomplete, to be retried sooner rather than by every render (#6183); not when built from\n\t\t// teams read before the caches were dropped. Complete only when built from the team list and the organization\n\t\t// as stored now. Once a list change retired this build, another may have kept a set meanwhile: a complete set\n\t\t// still replaces it, and any replaces an empty incomplete one, the fallback of a build that read none;\n\t\t// otherwise, as it also rests on what only this build read (an organization since read again and changed, a\n\t\t// read cut short) or held, it only replaces the set it held, or none (#6184). Refused, it still answers the\n\t\t// renders waiting on it with its own result, a known limit.\n\t\tconst keep = (\n\t\t\tautolinks: (AutolinkReference | DynamicAutolinkReference)[],\n\t\t\tcomplete: boolean,\n\t\t): (AutolinkReference | DynamicAutolinkReference)[] => {\n\t\t\tconst kept = this._autolinks.get(accessToken);\n\t\t\tif (\n\t\t\t\tthis._teams.generation === generation &&\n\t\t\t\t(complete || kept == null || kept === held || isEmptyAutolinkFallback(kept))\n\t\t\t) {\n\t\t\t\tthis._autolinks.set(accessToken, {\n\t\t\t\t\tautolinks: autolinks,\n\t\t\t\t\tbuiltAt: Date.now(),\n\t\t\t\t\tcomplete: complete,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn autolinks;\n\t\t};\n\t\t// Serves the held set until the retry, unless a team list was stored meanwhile\n\t\tconst keepHeld = (): (AutolinkReference | DynamicAutolinkReference)[] =>\n\t\t\tthis._autolinksResets === resets ? keep(held?.autolinks ?? [], false) : (held?.autolinks ?? []);\n\t\ttry {\n\t\t\tconst organization = await this.getOrganization(session);\n\t\t\tif (organization == null) return keepHeld();\n\n\t\t\tconst teams = await this.getTeamsWithMetadata(session);\n\t\t\tif (teams == null) return keepHeld();\n\n\t\t\t// While this build is current, a team list cached meanwhile outranks its read, as with Jira's sites\n\t\t\tconst cached = this._teams.generation === generation ? this._teams.get(accessToken) : undefined;\n\t\t\tconst autolinks: (AutolinkReference | DynamicAutolinkReference)[] = [];\n\t\t\tfor (const team of cached ?? teams.values) {\n\t\t\t\tautolinks.push(\n\t\t\t\t\t...createIssueAutolinkReferences(\n\t\t\t\t\t\tteam.key,\n\t\t\t\t\t\t`${organization.url}/issue/${team.key}-<num>`,\n\t\t\t\t\t\torganization,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Built from teams not cached now, an incomplete read or a newer list since expired, or with an organization\n\t\t\t// that differs from the one stored now, the set is served, and read again after the retry delay\n\t\t\treturn keep(autolinks, cached != null && areEqual(this._organizations?.get(accessToken), organization));\n\t\t} catch (ex) {\n\t\t\t// Autolinks are decoration: don't fail the render that asked\n\t\t\tLogger.error(ex, 'LinearIntegration.autolinks');\n\t\t\treturn keepHeld();\n\t\t}\n\t}\n\n\t/** The workspace is the token's organization; kept only as a complete, trimmed pair. */\n\toverride async getProviderResourceForSession(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ConnectionResource | undefined> {\n\t\tconst organization = await this.getOrganization(session, true);\n\t\tconst id = organization?.id.trim();\n\t\tconst name = organization?.name.trim();\n\t\treturn id && name ? { id: id, name: name } : undefined;\n\t}\n\n\tprivate _organizations: Map<string, LinearOrganizationDescriptor | undefined> | undefined;\n\t/**\n\t * In flight by token and discovery generation. The request can't be aborted (provider-apis takes no signal), so a\n\t * lookup that outlives its caller's timeout is joined by the next one rather than piling another request on top of\n\t * it; but not across a drop, since a lookup started before a forced refresh answers as from before it (#6162).\n\t */\n\tprivate readonly _organizationRequests = new Map<string, Promise<LinearOrganizationDescriptor | undefined>>();\n\tprivate async getOrganization(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<LinearOrganizationDescriptor | undefined> {\n\t\tconst { accessToken } = session;\n\t\t// Held across the await: a re-sync drops `_organizations` meanwhile, and this read must still complete.\n\t\tconst organizations = (this._organizations ??= new Map<string, LinearOrganizationDescriptor | undefined>());\n\n\t\tconst cachedResources = organizations.get(accessToken);\n\n\t\tif (cachedResources == null || force) {\n\t\t\tconst requestKey = `${this.discoveryGeneration}:${accessToken}`;\n\t\t\tlet request = this._organizationRequests.get(requestKey);\n\t\t\tif (request == null) {\n\t\t\t\trequest = this.fetchOrganization(session).finally(() => this._organizationRequests.delete(requestKey));\n\t\t\t\tthis._organizationRequests.set(requestKey, request);\n\t\t\t}\n\n\t\t\tconst descriptor = await request;\n\t\t\tif (descriptor) {\n\t\t\t\torganizations.set(accessToken, descriptor);\n\t\t\t}\n\t\t}\n\n\t\treturn organizations.get(accessToken);\n\t}\n\n\tprivate async fetchOrganization(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<LinearOrganizationDescriptor | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst organization = await api.getLinearOrganization(toTokenWithInfo(this.id, session));\n\t\treturn (\n\t\t\torganization && {\n\t\t\t\tid: organization.id,\n\t\t\t\tkey: organization.key,\n\t\t\t\tname: organization.name,\n\t\t\t\turl: organization.url,\n\t\t\t}\n\t\t);\n\t}\n\n\t/** Expires, and is dropped on a re-sync, so a team created or left mid-session is picked up (#5907). */\n\tprivate readonly _teams = new DiscoveryCache<LinearTeamDescriptor[]>();\n\tprivate async getTeams(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<LinearTeamDescriptor[] | undefined> {\n\t\treturn (await this.getTeamsWithMetadata(session, force))?.values;\n\t}\n\n\tprivate async getTeamsWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<ProviderApiCollectionResult<LinearTeamDescriptor> | undefined> {\n\t\tconst { accessToken } = session;\n\n\t\tconst cachedResources = this._teams.get(accessToken);\n\t\tif (cachedResources != null && !force) return { values: cachedResources };\n\n\t\tconst generation = this._teams.generation;\n\t\tconst started = this._teams.startRead();\n\t\tconst read = await this.readTeams(session);\n\t\tif (read == null || read.metadata != null) return read;\n\n\t\t// Not stored when the cache was dropped, or a read started after this one stored the teams, while this read\n\t\t// was in flight.\n\t\tconst stored = this._teams.set(accessToken, read.values, { generation: generation, read: started });\n\t\tif (stored !== false) {\n\t\t\tthis.onTeamListStored(accessToken, stored);\n\t\t} else if (this._teams.generation === generation) {\n\t\t\t// Refused for a read started after it: answers with that read's newer list, which this older one must not\n\t\t\t// stand in for, not even once expired (#6184).\n\t\t\treturn { values: this._teams.peek(accessToken) ?? read.values };\n\t\t}\n\t\treturn read;\n\t}\n\n\t/**\n\t * The team list was stored, and the autolinks are built from it. A different one drops them, so a build that then\n\t * fails keeps no fallback, and retires the build in flight, which may hold the list as it was. The same one again\n\t * keeps a complete set and the build in flight; otherwise it drops the incomplete set kept, if any, so the next\n\t * render builds from the list again, and still fences a failing build's fallback (#6183, #6184). Other tokens' sets\n\t * and builds stay; only `_autolinksResets`, shared by all tokens, also stops their failing builds' fallback.\n\t *\n\t * A known limit: a build whose own read stores a different list, or the first one (with nothing stored since a start\n\t * or a clear, every first store reads as different), retires itself too. A render in the microtasks before that\n\t * build resumes then starts a second one rather than joining it; that one builds from the team list just stored and\n\t * the organization cached, without reading the network. A loss of the sharing core had, with no effect on what is\n\t * kept, and none on an identical list, which retires nothing.\n\t */\n\tprivate onTeamListStored(accessToken: string, stored: 'changed' | 'unchanged'): void {\n\t\tif (stored === 'changed') {\n\t\t\tthis._autolinksBuilds.delete(accessToken);\n\t\t} else if (this._autolinks.get(accessToken)?.complete === true) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._autolinks.delete(accessToken);\n\t\tthis._autolinksResets++;\n\t}\n\n\tprivate async readTeams(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderApiCollectionResult<LinearTeamDescriptor> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst teams = await api.getLinearTeamsForCurrentUser(toTokenWithInfo(this.id, session));\n\t\tconst descriptors: LinearTeamDescriptor[] | undefined = teams?.map(t => ({\n\t\t\tid: t.id,\n\t\t\tkey: t.key,\n\t\t\tname: t.name,\n\t\t\tavatarUrl: t.iconUrl,\n\t\t}));\n\t\tif (descriptors == null) return undefined;\n\n\t\t// provider-apis currently requests Linear's teams connection without pageInfo or a cursor. Linear's\n\t\t// implicit page size is 50, so exactly a full page cannot prove there is no team 51. Preserve the useful\n\t\t// prefix, but mark it unknown and leave it uncached so the next read retries instead of treating it as\n\t\t// authoritative. Once provider-apis exposes a paged primitive, replace this fail-closed guard with a drain.\n\t\tif (descriptors.length >= linearImplicitTeamsPageSize) {\n\t\t\treturn { values: descriptors, metadata: { completeness: 'unknown' } };\n\t\t}\n\n\t\treturn { values: descriptors };\n\t}\n\n\t/**\n\t * The workspace's Linear Projects (Linear's `Project` entity), drained across their pages. Separate from the\n\t * teams this integration lists as its projects: a Linear Project can span several teams, and selecting one\n\t * narrows an issue read (`IssuesForProjectOptions.linearProjects`) rather than naming what is read.\n\t *\n\t * Cached like the teams, and only when complete: a drain cut short by its backstop or a failed page is returned\n\t * with its `truncated`/`metadata` so the facade can say so, and read again next time. A first-page failure\n\t * rejects, which the result wrapper turns into `{ error }`. `fresh` reads past the cache and any read in flight,\n\t * for a caller that must not take a list from before what it needs to see (a Project created since).\n\t */\n\t@trace()\n\tasync getWorkspaceProjectsResult(\n\t\tconnectionId?: string,\n\t\toptions?: { fresh?: boolean },\n\t): Promise<IntegrationResult<ProviderHierarchyResult<ProviderLinearProject>>> {\n\t\tconst scope = getScopedLogger();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSession(connectionId, scope);\n\t\tif (session == null || isReadSessionFailure(session)) return session && { error: session.error };\n\n\t\ttry {\n\t\t\tconst projects = await this.getWorkspaceProjects(session, options?.fresh === true);\n\t\t\tawait this.confirmScopedAuthFailures(session, projects.metadata);\n\t\t\tthis.resetRequestExceptionCount('getProjectsForResources', connectionId);\n\t\t\treturn { value: projects };\n\t\t} catch (ex) {\n\t\t\tthis.handleProviderException('getProjectsForResources', ex, { connectionId: connectionId });\n\t\t\treturn { error: toError(ex) };\n\t\t}\n\t}\n\n\t/** Expires, and is dropped on a re-sync, so a Project created or archived mid-session is picked up. */\n\tprivate readonly _workspaceProjects = new DiscoveryCache<ProviderLinearProject[]>();\n\t/**\n\t * In flight by token, with the cache generation it started under: concurrent cold reads share one drain, but a\n\t * read after the cache was dropped (a `forceSync`) never joins one started before, which could miss what it asks\n\t * to see.\n\t */\n\tprivate readonly _workspaceProjectsReads = new Map<\n\t\tstring,\n\t\t{ generation: number; read: Promise<ProviderHierarchyResult<ProviderLinearProject>> }\n\t>();\n\tprivate getWorkspaceProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t\tfresh: boolean,\n\t): Promise<ProviderHierarchyResult<ProviderLinearProject>> {\n\t\tconst { accessToken } = session;\n\t\tconst generation = this._workspaceProjects.generation;\n\t\tif (!fresh) {\n\t\t\tconst cached = this._workspaceProjects.get(accessToken);\n\t\t\tif (cached != null) return Promise.resolve({ values: cached });\n\n\t\t\tconst inFlight = this._workspaceProjectsReads.get(accessToken);\n\t\t\tif (inFlight?.generation === generation) return inFlight.read;\n\t\t}\n\n\t\tconst entry = { generation: generation, read: this.readWorkspaceProjects(session) };\n\t\tentry.read = entry.read.then(result => {\n\t\t\tif (\n\t\t\t\tthis._workspaceProjectsReads.get(accessToken) === entry &&\n\t\t\t\tresult.truncated !== true &&\n\t\t\t\t(result.metadata == null || result.metadata.completeness === 'complete')\n\t\t\t) {\n\t\t\t\tthis._workspaceProjects.set(accessToken, result.values, { generation: generation });\n\t\t\t}\n\t\t\treturn result;\n\t\t});\n\t\tthis._workspaceProjectsReads.set(accessToken, entry);\n\t\tvoid entry.read\n\t\t\t.finally(() => {\n\t\t\t\tif (this._workspaceProjectsReads.get(accessToken) === entry) {\n\t\t\t\t\tthis._workspaceProjectsReads.delete(accessToken);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch(() => {});\n\t\treturn entry.read;\n\t}\n\n\t/**\n\t * Drains the Projects cursor up to {@link maxWorkspaceProjectPages}. A first-page failure rejects, so the read\n\t * fails as the team read does rather than reading as a workspace with no Projects; a later one keeps the prefix\n\t * and records the failure, as do a stalled cursor and the backstop with pages left.\n\t */\n\tprivate async readWorkspaceProjects(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderLinearProject>> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\tlet pagesRead = 0;\n\t\tlet firstPageError: Error | undefined;\n\t\tconst read = await collectProviderPagedResult(\n\t\t\tasync cursor => {\n\t\t\t\ttry {\n\t\t\t\t\tconst page = await api.getLinearProjects(tokenWithInfo, { cursor: cursor });\n\t\t\t\t\tpagesRead++;\n\t\t\t\t\treturn page;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tif (pagesRead === 0) {\n\t\t\t\t\t\tfirstPageError = toError(ex);\n\t\t\t\t\t}\n\t\t\t\t\tthrow ex;\n\t\t\t\t}\n\t\t\t},\n\t\t\tmaxWorkspaceProjectPages,\n\t\t\t{ providerId: this.id },\n\t\t);\n\t\t// The drain records any failure against its scope and keeps the prefix; with no prefix, there is no list.\n\t\tif (firstPageError != null) throw firstPageError;\n\n\t\treturn read;\n\t}\n\n\tprotected override async getProviderResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ResourceDescriptor[] | undefined> {\n\t\tconst organization = await this.getOrganization(session);\n\t\treturn organization != null ? [organization] : undefined;\n\t}\n\tprotected override async getProviderUncachedResourcesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ResourceDescriptor[] | undefined> {\n\t\t// Joins none in flight, unlike `getOrganization`: one may have started before what the caller needs to see.\n\t\tconst organization = await this.fetchOrganization(session);\n\t\treturn organization != null ? [organization] : undefined;\n\t}\n\tprotected override getProviderProjectsForResources(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resources: ResourceDescriptor[],\n\t): Promise<ResourceDescriptor[] | undefined> {\n\t\treturn this.getTeams(session);\n\t}\n\tprotected override async getProviderProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resources: ResourceDescriptor[],\n\t): Promise<ProviderApiCollectionResult<ResourceDescriptor>> {\n\t\treturn (await this.getTeamsWithMetadata(session)) ?? { values: [], metadata: { completeness: 'unknown' } };\n\t}\n\tprotected override async getProviderUncachedProjectsForResourcesWithMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resources: ResourceDescriptor[],\n\t): Promise<ProviderApiCollectionResult<ResourceDescriptor>> {\n\t\treturn (await this.readTeams(session)) ?? { values: [], metadata: { completeness: 'unknown' } };\n\t}\n\n\tprotected override clearDiscoveryCaches(): void {\n\t\tthis._organizations = undefined;\n\t\tthis._teams.clear();\n\t\tthis._workspaceProjects.clear();\n\t\tthis._workspaceProjectsReads.clear();\n\t\tthis._autolinks.clear();\n\t\tthis._autolinksBuilds.clear();\n\t\tthis._recentAccounts.clear();\n\t}\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\n\t/**\n\t * Always asks Linear: the host's current-account cache decides when this runs. The viewer query is account-wide,\n\t * so the answer is lent briefly to the per-resource lookup a tracker read makes right after it.\n\t */\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst account = await this.fetchAccount(session);\n\t\tif (account != null) {\n\t\t\tthis._recentAccounts.set(session.accessToken, Promise.resolve(account));\n\t\t}\n\t\treturn account;\n\t}\n\n\tprotected override getProviderUncachedAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: ResourceDescriptor,\n\t): Promise<Account | undefined> {\n\t\treturn this.fetchAccount(session);\n\t}\n\n\tprotected override async getProviderAccountForResource(\n\t\tsession: ProviderAuthenticationSession,\n\t\t_resource: ResourceDescriptor,\n\t): Promise<Account | undefined> {\n\t\treturn this._recentAccounts.getOrCreate(session.accessToken, () => this.fetchAccount(session), {\n\t\t\tevictWhen: account => account == null,\n\t\t});\n\t}\n\n\tprivate readonly _recentAccounts = new PromiseCache<string, Account | undefined>({\n\t\tcapacity: 10,\n\t\tcreateTTL: recentAccountTTL,\n\t});\n\n\tprivate async fetchAccount(session: ProviderAuthenticationSession): Promise<Account | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// Linear's viewer isn't a ProviderAccount (no username/avatar), so build the Account manually\n\t\t// (Trello-style) from the fields the viewer query returns.\n\t\tconst user = await api.getLinearCurrentUser(toTokenWithInfo(this.id, session));\n\t\tif (user == null) return undefined;\n\n\t\treturn {\n\t\t\tprovider: this,\n\t\t\tid: user.id,\n\t\t\tname: user.name ?? user.displayName ?? undefined,\n\t\t\tusername: user.displayName ?? undefined,\n\t\t\temail: user.email ?? undefined,\n\t\t\tavatarUrl: undefined,\n\t\t};\n\t}\n\n\tprotected override async getProviderIssuesForProject(\n\t\tsession: ProviderAuthenticationSession,\n\t\tproject: ResourceDescriptor,\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: ResourceDescriptor,\n\t\toptions?: IssuesForProjectOptions,\n\t): Promise<ProjectIssuesDrain | undefined> {\n\t\tif (!isIssueResourceDescriptor(project)) return undefined;\n\n\t\t// Scope to \"my issues\" by the viewer's stable id, not the passed display name: Linear's `name` (full name)\n\t\t// and `displayName` (nickname) are distinct fields, and assignees are normalized with `.name` = the full\n\t\t// name while the caller's `user` is the displayName — so a name string can miss. The assignee `.id` is the\n\t\t// Linear user id, which is unambiguous.\n\t\tlet viewerId: string | undefined;\n\t\tif (options?.user != null) {\n\t\t\tviewerId = await this.getViewerId(session, options);\n\t\t\t// If the viewer can't be resolved we can't scope to \"my issues\" — returning the unfiltered team\n\t\t\t// issues would leak everyone else's, and returning [] is indistinguishable from \"no issues assigned\n\t\t\t// to me\". Throw so the facade (getIssuesForProjectResult → runCaptured) surfaces a warning +\n\t\t\t// fetchFailed the caller can act on, instead of a silent empty.\n\t\t\tif (viewerId == null) {\n\t\t\t\tthrow new IntegrationReadUnavailableError(\n\t\t\t\t\tmetadata.name,\n\t\t\t\t\t'could not resolve the current user to scope issues to',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// `getProviderProjectsForResources` returns Linear teams, so `project.id` is a team id here.\n\t\t//\n\t\t// The state and the viewer are narrowed server-side, not after the drain: a team's done work and other\n\t\t// people's issues would otherwise count against the backstop, so a busy team runs out of pages before the\n\t\t// viewer's open issues and hands back a page that looks complete.\n\t\tconst drain = await this.drainIssues(\n\t\t\tsession,\n\t\t\t{\n\t\t\t\tteams: [project.id],\n\t\t\t\t...(options?.linearProjects?.length ? { projects: [...options.linearProjects] } : {}),\n\t\t\t\t...(viewerId != null ? viewerScope(viewerId, options?.filters) : {}),\n\t\t\t\tstates: toProviderIssueStates(options?.state),\n\t\t\t},\n\t\t\toptions?.sort,\n\t\t\t{ providerId: this.id, projectId: project.id },\n\t\t);\n\n\t\treturn drain.truncated\n\t\t\t? { values: drain.issues, truncated: true, recovery: 'none', metadata: drain.metadata }\n\t\t\t: { values: drain.issues, truncated: false, metadata: drain.metadata };\n\t}\n\n\t/**\n\t * Searches every team of a user-scoped read together: one `getIssues` names all of them and the viewer's scope\n\t * (see {@link viewerScope}), so a team with none of the user's issues costs no request of its own. Linear's filter\n\t * is a GraphQL body, not a query string, so there is no key bound to chunk at.\n\t *\n\t * A read narrowed to Linear Projects is searched together even across every assignee: the Projects already bound\n\t * it to a few teams' worth of issues, so a team holding none of them costs no request either. An unnarrowed read\n\t * of every assignee is still read team by team, since a search over all of them would just spend one team's page\n\t * budget before falling back.\n\t */\n\tprotected override getProjectIssuesSearches(\n\t\trequests: readonly ProjectIssuesRequest<ResourceDescriptor>[],\n\t): number[][] | undefined {\n\t\treturn groupProjectIssuesSearches(requests, ({ project, options }) =>\n\t\t\t(options.user != null || options.linearProjects?.length) && isIssueResourceDescriptor(project)\n\t\t\t\t? [\n\t\t\t\t\t\toptions.user ?? '',\n\t\t\t\t\t\toptions.userId ?? '',\n\t\t\t\t\t\toptions.sort ?? '',\n\t\t\t\t\t\toptions.state ?? '',\n\t\t\t\t\t\toptions.filters?.join(',') ?? '',\n\t\t\t\t\t\t...(options.linearProjects ?? []),\n\t\t\t\t\t].join('\\0')\n\t\t\t\t: undefined,\n\t\t);\n\t}\n\n\tprotected override async searchProviderProjectIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trequests: readonly ProjectIssuesRequest<ResourceDescriptor>[],\n\t): Promise<IssueShape[][] | undefined> {\n\t\t// Every request of a search shares every option read here (see the key in `getProjectIssuesSearches`).\n\t\tconst { options } = requests[0];\n\t\tlet viewerId: string | undefined;\n\t\tif (options.user != null) {\n\t\t\t// Unresolvable here means each team's own read throws the same warning, so let them.\n\t\t\tviewerId = await this.getViewerId(session, options);\n\t\t\tif (viewerId == null) return undefined;\n\t\t} else if (!options.linearProjects?.length) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst teams = requests.map(request => request.project).filter(isIssueResourceDescriptor);\n\t\tif (teams.length !== requests.length) return undefined;\n\n\t\tconst drain = await this.drainIssues(\n\t\t\tsession,\n\t\t\t{\n\t\t\t\tteams: teams.map(team => team.id),\n\t\t\t\t...(options.linearProjects?.length ? { projects: [...options.linearProjects] } : {}),\n\t\t\t\t...(viewerId != null ? viewerScope(viewerId, options.filters) : {}),\n\t\t\t\tstates: toProviderIssueStates(options.state),\n\t\t\t},\n\t\t\toptions.sort,\n\t\t\t// Never published: an incomplete search is read again per team, which records its own failures.\n\t\t\t{ providerId: this.id },\n\t\t);\n\t\t// Deliberately discarded rather than served: an incomplete search says nothing about which of its teams it\n\t\t// covered, so only the per-team reads can report each one's completeness. The waste is bounded by one team's\n\t\t// page budget, and paid only by a search that needed more than that or failed partway.\n\t\tif (drain.truncated || (drain.metadata != null && drain.metadata.completeness !== 'complete')) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// A normalized Linear issue carries its team only inside `project`, which is absent for an issue in no\n\t\t// Linear project, so split by the identifier instead: Linear numbers every issue `<team key>-<n>`, and\n\t\t// renumbers it under its new team's key when it moves.\n\t\treturn splitProjectIssuesSearch(\n\t\t\tteams.map(team => team.key),\n\t\t\tdrain.issues,\n\t\t\tissue => {\n\t\t\t\tconst separator = issue.id.lastIndexOf('-');\n\t\t\t\treturn separator > 0 ? issue.id.slice(0, separator) : undefined;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate readonly _viewerIds = new PromiseCache<string, string | undefined>({ capacity: 10 });\n\t/**\n\t * The viewer's Linear user id: the caller's resolved `userId` when it has one, else the viewer query, shared per\n\t * token. A tracker read hands each team the id of the team's own resource, which Linear's team descriptors don't\n\t * name, so without sharing every team read (and a search's fallback) would ask for the viewer again.\n\t */\n\tprivate getViewerId(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: IssuesForProjectOptions,\n\t): Promise<string | undefined> {\n\t\tif (options.userId) return Promise.resolve(options.userId);\n\n\t\treturn this._viewerIds.getOrCreate(\n\t\t\tsession.accessToken,\n\t\t\tasync () => {\n\t\t\t\tconst api = await this.getProvidersApi();\n\t\t\t\treturn (await api.getLinearCurrentUser(toTokenWithInfo(this.id, session)))?.id;\n\t\t\t},\n\t\t\t// Only a resolved id is worth keeping; an unresolved viewer is asked for again next time, as is a failure.\n\t\t\t{ evictWhen: id => id == null },\n\t\t);\n\t}\n\n\t/**\n\t * Follows `getIssues`' cursor up to {@link maxPagesPerRequest}. `truncated` is set when that backstop stopped\n\t * the drain with more pages still available, when the provider stalled its cursor or flagged its paging as\n\t * truncated, or when a page after the first failed, which is recorded at `failureScope` while the prefix is\n\t * kept. A failure before any issue was kept throws, so the caller sees a hard error rather than an empty success.\n\t */\n\tprivate async drainIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tfilter: { teams: string[]; projects?: string[]; states?: GitIssueState[] } & Partial<LinearViewerScope>,\n\t\tsort: IssuesForProjectOptions['sort'],\n\t\tfailureScope: CollectionScopeFailure['scope'],\n\t): Promise<{ issues: IssueShape[]; truncated: boolean; metadata?: CollectionMetadata }> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst assignees = filter.assignees?.length ? filter.assignees : undefined;\n\t\tconst syncedCreators = filter.githubSyncedCreators?.length ? filter.githubSyncedCreators : undefined;\n\t\tlet cursor: string | undefined;\n\t\tlet hasMore: boolean;\n\t\tlet requestCount = 0;\n\t\tlet truncated = false;\n\t\tlet collectionMetadata: CollectionMetadata | undefined;\n\t\tconst issues: IssueShape[] = [];\n\t\tdo {\n\t\t\tlet result: Awaited<ReturnType<typeof api.getLinearIssues>>;\n\t\t\ttry {\n\t\t\t\tresult = await api.getLinearIssues(toTokenWithInfo(this.id, session), filter, {\n\t\t\t\t\tcursor: cursor,\n\t\t\t\t\tsort: sort,\n\t\t\t\t});\n\t\t\t} catch (ex) {\n\t\t\t\t// Keyed on what was kept, not on the page: provider-apis can empty a page it filters after the query\n\t\t\t\t// (synced-creator reads) and still report more, and a drain that kept nothing has nothing to serve, so\n\t\t\t\t// its caller retries it rather than recording an empty prefix as read.\n\t\t\t\tif (issues.length === 0) throw ex;\n\n\t\t\t\ttruncated = true;\n\t\t\t\tcollectionMetadata = mergeCollectionMetadata(collectionMetadata, {\n\t\t\t\t\tcompleteness: 'partial',\n\t\t\t\t\tfailures: [toCollectionScopeFailure(failureScope, ex)],\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\trequestCount += 1;\n\t\t\thasMore = result.paging?.more ?? false;\n\t\t\tconst nextCursor = result.paging?.cursor;\n\t\t\ttruncated ||= result.paging?.truncated === true;\n\t\t\tcollectionMetadata = mergeCollectionMetadata(collectionMetadata, result.metadata);\n\t\t\tfor (const issue of result.values) {\n\t\t\t\tconst shape = toIssueShape(issue, this, { projection: 'project' });\n\t\t\t\t// The read already scopes to the assignees and to the synced issues the creators filed, leaving out the\n\t\t\t\t// issues with no GitHub sync link (`[]`) and keeping one whose link list Linear failed to resolve\n\t\t\t\t// (absent). Checking again keeps another user's issue, or an unsynced one only its GitHub attachment\n\t\t\t\t// matched, out of \"my issues\" should the provider ever return one.\n\t\t\t\tif (\n\t\t\t\t\tshape != null &&\n\t\t\t\t\t(assignees == null ||\n\t\t\t\t\t\tshape.assignees?.some(a => assignees.includes(a.id)) ||\n\t\t\t\t\t\t(syncedCreators != null &&\n\t\t\t\t\t\t\tshape.author != null &&\n\t\t\t\t\t\t\tsyncedCreators.includes(shape.author.id) &&\n\t\t\t\t\t\t\tshape.syncedWith?.length !== 0))\n\t\t\t\t) {\n\t\t\t\t\tissues.push(shape);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// The provider claims more but returns no advancing cursor: we can't continue without re-reading the\n\t\t\t// same page, so the drain is incomplete — flag it rather than silently stopping.\n\t\t\tif (hasMore && (nextCursor == null || nextCursor === cursor)) {\n\t\t\t\ttruncated = true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcursor = nextCursor;\n\t\t\tif (hasMore && requestCount >= maxPagesPerRequest) {\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t} while (requestCount < maxPagesPerRequest && hasMore);\n\n\t\treturn { issues: issues, truncated: truncated, metadata: collectionMetadata };\n\t}\n\n\toverride get id(): IssuesCloudHostIntegrationId.Linear {\n\t\treturn IssuesCloudHostIntegrationId.Linear;\n\t}\n\tprotected override get key(): 'linear' {\n\t\treturn 'linear';\n\t}\n\toverride get name(): string {\n\t\treturn metadata.name;\n\t}\n\toverride get domain(): string {\n\t\treturn metadata.domain;\n\t}\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn (await this.searchProviderMyIssuesWithTruncation(session, resources, cancellation))?.values;\n\t}\n\n\t/**\n\t * Account-wide \"my issues\" for Linear, drained to exhaustion and reporting whether it got there.\n\t *\n\t * The SDK read is one server-ordered query over an `or` filter across the four relationships (assigned,\n\t * created, named in an issue's content, named in a comment), so each page is 100 issues the caller has not\n\t * seen and the pages are ordered as one sequence. Draining it is therefore just following the cursor.\n\t *\n\t * Overridden rather than left to the base default because that default hardcodes `truncated: false`, and a\n\t * bounded drain that stops early is exactly the case a caller must be able to see. Three things end the\n\t * drain, and only one of them is completion:\n\t *\n\t * - the provider says there is no next page — complete;\n\t * - the backstop is reached — `truncated`, because issues beyond it exist and were not read;\n\t * - the provider claims a next page but hands back a cursor that does not advance — also `truncated`, since\n\t * the read cannot continue and the remainder is unreachable rather than absent.\n\t *\n\t * Cancellation is deliberately NOT truncation: the caller asked for the read to stop, so the partial list is\n\t * what it asked for, and flagging it would surface an incompleteness warning for a user action.\n\t */\n\tprotected override async searchProviderMyIssuesWithTruncation(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresources?: ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyIssuesOptions,\n\t): Promise<AccountWideIssuesResult | undefined> {\n\t\tif (resources != null) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst states = toProviderIssueStates(options?.state);\n\t\tlet cursor = undefined;\n\t\t// Starts false so an immediate cancellation, which leaves the loop before the first response, reads as\n\t\t// \"no more pages known\" rather than as an unfinished drain.\n\t\tlet hasMore = false;\n\t\tlet requestCount = 0;\n\t\tlet truncated = false;\n\t\tconst issues = [];\n\t\ttry {\n\t\t\tdo {\n\t\t\t\tif (cancellation?.aborted) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst result = await api.getIssuesForCurrentUser(toTokenWithInfo(this.id, session), {\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\t\trequestCount += 1;\n\t\t\t\thasMore = result.paging?.more ?? false;\n\t\t\t\tconst nextCursor = result.paging?.cursor;\n\n\t\t\t\t// Keep this page before deciding whether to continue: the request is already paid for, so\n\t\t\t\t// dropping its rows would lose real results to save nothing.\n\t\t\t\tconst formattedIssues = result.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\tif (formattedIssues.length > 0) {\n\t\t\t\t\tissues.push(...formattedIssues);\n\t\t\t\t}\n\n\t\t\t\t// The provider claims more but hands back no advancing cursor: continuing would re-read the page\n\t\t\t\t// just returned. `ProvidersApi.getPagedResult` already normalizes this into `more: false`, so\n\t\t\t\t// this is a backstop for if that ever stops holding rather than a case seen today -- but the rest\n\t\t\t\t// of the account is unreachable either way, which is what `truncated` says.\n\t\t\t\tif (hasMore && (nextCursor == null || nextCursor === cursor)) {\n\t\t\t\t\ttruncated = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcursor = nextCursor;\n\t\t\t} while (requestCount < maxAccountWidePagesPerRequest && hasMore);\n\n\t\t\t// Ran out of budget with pages still to come.\n\t\t\tif (hasMore && requestCount >= maxAccountWidePagesPerRequest) {\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t} catch (ex) {\n\t\t\tif (issues.length === 0) {\n\t\t\t\tthrow ex;\n\t\t\t}\n\n\t\t\t// Kept what was already fetched, so the list is real but short of the account.\n\t\t\ttruncated = true;\n\t\t\tLogger.error(ex, 'searchProviderMyIssues');\n\t\t}\n\t\treturn { values: issues, truncated: truncated };\n\t}\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: ResourceDescriptor,\n\t\t{ key }: { id: string; key: string },\n\t\t_type: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\tconst issue = await this.getRawProviderIssue(session, resource, key);\n\t\tconst autolinkableIssue: ProviderIssue | undefined = issue && {\n\t\t\t...issue,\n\t\t\turl: this.getIssueAutolinkLikeUrl(issue),\n\t\t};\n\t\treturn autolinkableIssue && toIssueShape(autolinkableIssue, this, { projection: 'point' });\n\t}\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\tconst result = await this.getRawProviderIssue(session, resource, id);\n\t\treturn result && fromProviderIssue(result, this, { projection: 'point' });\n\t}\n\n\tprotected override async getProviderIssueByResourceId(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresourceId: string,\n\t\tid: string,\n\t\t_resourceUrl: string | undefined,\n\t): Promise<Issue | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst result = await api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resourceId,\n\t\t\tnumber: id,\n\t\t});\n\t\treturn result && fromProviderIssue(result, this, { projection: 'batch' });\n\t}\n\n\t/**\n\t * The cheap check behind the batch issue read's etags: one `issues` query per team and\n\t * {@link linearIssuesEtagMaxNumbers} distinct numbers, where {@link getProviderIssueByResourceId} sends one request\n\t * per issue. A request that throws rejects only its own targets' slots, with its error classified as the full\n\t * read's would be.\n\t *\n\t * Never proves an absence. The query filters by the team's CURRENT key and asks for archived issues too, but the\n\t * full read's `issue(id:)` may also resolve an identifier the issue no longer carries (its team was renamed, or it\n\t * moved to another team), so an issue the query leaves out may still exist. Its target's slot is rejected, as is a\n\t * target whose identifier isn't a team key and a number, so the full read decides. When no target was answered and\n\t * nothing failed, the check declines instead, so a batch of only such targets 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 workspace and team's distinct numbers, with the targets asking for each.\n\t\tconst byTeam = new Map<string, { teamKey: string; numbers: Map<number, number[]> }>();\n\t\tfor (const [index, target] of targets.entries()) {\n\t\t\tconst match = linearIdentifier.exec(target.identifier);\n\t\t\tconst number = match != null ? Number(match[2]) : Number.NaN;\n\t\t\t// Only a number written as Linear writes it, so `ENG-012` never answers for `ENG-12`.\n\t\t\tif (match == null || !Number.isSafeInteger(number) || String(number) !== match[2]) {\n\t\t\t\tslots[index] = {\n\t\t\t\t\tstatus: 'rejected',\n\t\t\t\t\treason: new Error(`Not a Linear issue identifier: ${target.identifier}`),\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst teamKey = match[1].toUpperCase();\n\t\t\tconst groupKey = `${target.resourceId}\\n${teamKey}`;\n\t\t\tlet group = byTeam.get(groupKey);\n\t\t\tif (group == null) {\n\t\t\t\tgroup = { teamKey: teamKey, numbers: new Map() };\n\t\t\t\tbyTeam.set(groupKey, group);\n\t\t\t}\n\n\t\t\tlet indices = group.numbers.get(number);\n\t\t\tif (indices == null) {\n\t\t\t\tindices = [];\n\t\t\t\tgroup.numbers.set(number, indices);\n\t\t\t}\n\t\t\tindices.push(index);\n\t\t}\n\n\t\tconst requests = [...byTeam.values()].flatMap(({ teamKey, numbers }) =>\n\t\t\tchunk([...numbers], linearIssuesEtagMaxNumbers).map(entries => ({ teamKey: teamKey, entries: entries })),\n\t\t);\n\t\tif (requests.length) {\n\t\t\tconst api = await this.getProvidersApi();\n\t\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\t\tconst answers = await mapSettledBounded(requests, providerFanOutConcurrency, r =>\n\t\t\t\tapi.getLinearIssuesEtagFields(\n\t\t\t\t\ttokenWithInfo,\n\t\t\t\t\tr.teamKey,\n\t\t\t\t\tr.entries.map(([number]) => number),\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tfor (const [i, answer] of answers.entries()) {\n\t\t\t\tconst { teamKey, entries } = requests[i];\n\t\t\t\tif (answer.status === 'rejected') {\n\t\t\t\t\tfailed = true;\n\t\t\t\t\tfor (const [, indices] of entries) {\n\t\t\t\t\t\tfor (const index of indices) {\n\t\t\t\t\t\t\tslots[index] = answer;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// By number, never by position: Linear returns the issues in its own order, and only the ones it found.\n\t\t\t\tconst byNumber = new Map<number, LinearIssueEtagNode>();\n\t\t\t\tfor (const issue of answer.value) {\n\t\t\t\t\tbyNumber.set(issue.number, issue);\n\t\t\t\t}\n\n\t\t\t\tfor (const [number, indices] of entries) {\n\t\t\t\t\tconst issue = byNumber.get(number);\n\t\t\t\t\tlet slot: PromiseSettledResult<IssueEtagFields | undefined>;\n\t\t\t\t\tif (issue == null) {\n\t\t\t\t\t\tslot = { status: 'rejected', reason: new Error(`Linear did not return ${teamKey}-${number}`) };\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tslot = { status: 'fulfilled', value: toLinearIssueEtagFields(issue) };\n\t\t\t\t\t\t\tanswered = true;\n\t\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t\tslot = { status: 'rejected', reason: ex };\n\t\t\t\t\t\t\tfailed = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const index of indices) {\n\t\t\t\t\t\tslots[index] = slot;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn answered || failed ? slots : undefined;\n\t}\n\n\tprivate async getRawProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t): Promise<ProviderIssue | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!isIssueResourceDescriptor(resource)) {\n\t\t\tLogger.error(undefined, 'getProviderIssue: resource is not an IssueResourceDescriptor');\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn api.getIssue(toTokenWithInfo(this.id, session), {\n\t\t\tresourceId: resource.id,\n\t\t\tnumber: id,\n\t\t});\n\t}\n\tprivate getIssueAutolinkLikeUrl(issue: ProviderIssue): string | null {\n\t\tconst url = issue.url;\n\t\tif (url == null) return null;\n\n\t\tconst lastSegment = url.split('/').pop();\n\t\tif (!lastSegment || issue.number === lastSegment) {\n\t\t\treturn url;\n\t\t}\n\t\treturn url.substring(0, url.length - lastSegment.length - 1);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAC/E,MAAM,qBAAqB;;;;;;;;;;;;;;;AAe3B,MAAM,gCAAgC;AACtC,MAAM,8BAA8B;;AAEpC,MAAM,2BAA2B;;AAEjC,MAAM,mBAAmB;;AAEzB,MAAM,mBAAmB;;;;;;;;;AAuBzB,SAAS,YAAY,UAAkB,SAAuD;CAC7F,OAAO,SAAS,SAAA,UAA6B,IAC1C,EAAE,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AvsBE,WAAA,CAAA,MAAM,CAAA,GAAA,kBAAA,WAAA,8BAAA,IAAA"}
|
|
@@ -5,30 +5,67 @@
|
|
|
5
5
|
* project never appears, and a deleted one keeps being searched, which Jira refuses with a `400` (#5907).
|
|
6
6
|
*/
|
|
7
7
|
export declare const discoveryCacheTtl: number;
|
|
8
|
+
/**
|
|
9
|
+
* How long an autolink set built from an incomplete or failed discovery read is served before the read is retried.
|
|
10
|
+
* Short, so what the read missed shows up soon; but autolinks are read on every render of a commit message, and
|
|
11
|
+
* retrying on each would make every render wait on the provider (#6183).
|
|
12
|
+
*/
|
|
13
|
+
export declare const incompleteAutolinksRetryDelay: number;
|
|
14
|
+
/** Whether a kept autolink set is due a rebuild: once older than the TTL, or the retry delay when incomplete. */
|
|
15
|
+
export declare function isAutolinkSetExpired(set: {
|
|
16
|
+
builtAt: number;
|
|
17
|
+
complete: boolean;
|
|
18
|
+
}): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a kept autolink set is empty and incomplete: the fallback of a failing build that held none, built from no
|
|
21
|
+
* list, so it stands for no set to any set built from the lists (#6184).
|
|
22
|
+
*/
|
|
23
|
+
export declare function isEmptyAutolinkFallback(set: {
|
|
24
|
+
autolinks: readonly unknown[];
|
|
25
|
+
complete: boolean;
|
|
26
|
+
}): boolean;
|
|
8
27
|
/**
|
|
9
28
|
* A per-key cache of discovery results that expires entries after {@link discoveryCacheTtl} and can be dropped
|
|
10
29
|
* wholesale when the connection is re-synced.
|
|
11
30
|
*
|
|
12
31
|
* {@link clear} bumps a generation, and {@link set} refuses a value read under an older one, so a read that was
|
|
13
32
|
* already in flight when the cache was cleared cannot write the set it read before the clear back into it.
|
|
33
|
+
*
|
|
34
|
+
* A read can also be ordered by when it started ({@link startRead}): its value is then refused once a read that started
|
|
35
|
+
* after it stored the key, so a slower, possibly older read can't put back a list that a newer read replaced (#6184).
|
|
36
|
+
* The start stands in for when the provider answered, which a read doesn't report: one that started first but was
|
|
37
|
+
* answered with a later state (a paged list's last page read after the other read stored, say) is refused too, and one
|
|
38
|
+
* that started later but was answered with an earlier state is stored over it. Either way the stored list lags until a
|
|
39
|
+
* read replaces it, at most the TTL, and what is built from it with its own TTL, like autolinks, up to about twice
|
|
40
|
+
* that. A deletion keeps no such order: Jira Cloud fences the reads in flight across its evictions itself (#6176).
|
|
41
|
+
*
|
|
42
|
+
* An expired entry is no longer served, but is kept until replaced, for that order and so {@link set} can tell whether
|
|
43
|
+
* the read that replaces it found anything new.
|
|
14
44
|
*/
|
|
15
45
|
export declare class DiscoveryCache<V> {
|
|
16
46
|
private readonly ttl;
|
|
17
47
|
private readonly entries;
|
|
18
48
|
private _generation;
|
|
49
|
+
private reads;
|
|
19
50
|
constructor(ttl?: number);
|
|
20
51
|
/** Pass to {@link set} to have a value read now refused if the cache is cleared before it is stored. */
|
|
21
52
|
get generation(): number;
|
|
53
|
+
/** Pass to {@link set} as `read`, taken when a read starts, to order its value against other reads'. */
|
|
54
|
+
startRead(): number;
|
|
22
55
|
get(key: string): V | undefined;
|
|
56
|
+
/** The value stored under `key`, expired or not: what a reader that can't wait for a re-read last knew of it. */
|
|
57
|
+
peek(key: string): V | undefined;
|
|
23
58
|
/**
|
|
24
|
-
* Stores `value` unless the cache was cleared since `generation` was taken
|
|
25
|
-
*
|
|
26
|
-
*
|
|
59
|
+
* Stores `value` unless the cache was cleared since `generation` was taken, or, for a `read` from
|
|
60
|
+
* {@link startRead}, a read started after it stored `key`. `storedAt` backdates an entry seeded from persisted
|
|
61
|
+
* storage, so it expires on the schedule of the read that produced it rather than of the seeding. Returns `false`
|
|
62
|
+
* when refused, `'unchanged'` when `value` equals the one it replaces, expired or not, and `'changed'` otherwise.
|
|
27
63
|
*/
|
|
28
64
|
set(key: string, value: V, options?: {
|
|
29
65
|
generation?: number;
|
|
66
|
+
read?: number;
|
|
30
67
|
storedAt?: number;
|
|
31
|
-
}):
|
|
68
|
+
}): 'changed' | 'unchanged' | false;
|
|
32
69
|
delete(key: string): void;
|
|
33
70
|
clear(): void;
|
|
34
71
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { areEqual } from "../../../../utils/object.js";
|
|
1
2
|
//#region ../plus/integrations/src/providers/utils/discoveryCache.ts
|
|
2
3
|
/**
|
|
3
4
|
* How long a tracker's discovered project set (Jira sites and projects, Linear teams) is trusted before it is read
|
|
@@ -6,16 +7,45 @@
|
|
|
6
7
|
*/
|
|
7
8
|
const discoveryCacheTtl = 3e5;
|
|
8
9
|
/**
|
|
10
|
+
* How long an autolink set built from an incomplete or failed discovery read is served before the read is retried.
|
|
11
|
+
* Short, so what the read missed shows up soon; but autolinks are read on every render of a commit message, and
|
|
12
|
+
* retrying on each would make every render wait on the provider (#6183).
|
|
13
|
+
*/
|
|
14
|
+
const incompleteAutolinksRetryDelay = 6e4;
|
|
15
|
+
/** Whether a kept autolink set is due a rebuild: once older than the TTL, or the retry delay when incomplete. */
|
|
16
|
+
function isAutolinkSetExpired(set) {
|
|
17
|
+
return Date.now() - set.builtAt >= (set.complete ? discoveryCacheTtl : incompleteAutolinksRetryDelay);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Whether a kept autolink set is empty and incomplete: the fallback of a failing build that held none, built from no
|
|
21
|
+
* list, so it stands for no set to any set built from the lists (#6184).
|
|
22
|
+
*/
|
|
23
|
+
function isEmptyAutolinkFallback(set) {
|
|
24
|
+
return !set.complete && !set.autolinks.length;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
9
27
|
* A per-key cache of discovery results that expires entries after {@link discoveryCacheTtl} and can be dropped
|
|
10
28
|
* wholesale when the connection is re-synced.
|
|
11
29
|
*
|
|
12
30
|
* {@link clear} bumps a generation, and {@link set} refuses a value read under an older one, so a read that was
|
|
13
31
|
* already in flight when the cache was cleared cannot write the set it read before the clear back into it.
|
|
32
|
+
*
|
|
33
|
+
* A read can also be ordered by when it started ({@link startRead}): its value is then refused once a read that started
|
|
34
|
+
* after it stored the key, so a slower, possibly older read can't put back a list that a newer read replaced (#6184).
|
|
35
|
+
* The start stands in for when the provider answered, which a read doesn't report: one that started first but was
|
|
36
|
+
* answered with a later state (a paged list's last page read after the other read stored, say) is refused too, and one
|
|
37
|
+
* that started later but was answered with an earlier state is stored over it. Either way the stored list lags until a
|
|
38
|
+
* read replaces it, at most the TTL, and what is built from it with its own TTL, like autolinks, up to about twice
|
|
39
|
+
* that. A deletion keeps no such order: Jira Cloud fences the reads in flight across its evictions itself (#6176).
|
|
40
|
+
*
|
|
41
|
+
* An expired entry is no longer served, but is kept until replaced, for that order and so {@link set} can tell whether
|
|
42
|
+
* the read that replaces it found anything new.
|
|
14
43
|
*/
|
|
15
44
|
var DiscoveryCache = class {
|
|
16
45
|
ttl;
|
|
17
46
|
entries = /* @__PURE__ */ new Map();
|
|
18
47
|
_generation = 0;
|
|
48
|
+
reads = 0;
|
|
19
49
|
constructor(ttl = discoveryCacheTtl) {
|
|
20
50
|
this.ttl = ttl;
|
|
21
51
|
}
|
|
@@ -23,27 +53,36 @@ var DiscoveryCache = class {
|
|
|
23
53
|
get generation() {
|
|
24
54
|
return this._generation;
|
|
25
55
|
}
|
|
56
|
+
/** Pass to {@link set} as `read`, taken when a read starts, to order its value against other reads'. */
|
|
57
|
+
startRead() {
|
|
58
|
+
return ++this.reads;
|
|
59
|
+
}
|
|
26
60
|
get(key) {
|
|
27
61
|
const entry = this.entries.get(key);
|
|
28
|
-
if (entry == null) return void 0;
|
|
29
|
-
if (Date.now() - entry.storedAt >= this.ttl) {
|
|
30
|
-
this.entries.delete(key);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
62
|
+
if (entry == null || Date.now() - entry.storedAt >= this.ttl) return void 0;
|
|
33
63
|
return entry.value;
|
|
34
64
|
}
|
|
65
|
+
/** The value stored under `key`, expired or not: what a reader that can't wait for a re-read last knew of it. */
|
|
66
|
+
peek(key) {
|
|
67
|
+
return this.entries.get(key)?.value;
|
|
68
|
+
}
|
|
35
69
|
/**
|
|
36
|
-
* Stores `value` unless the cache was cleared since `generation` was taken
|
|
37
|
-
*
|
|
38
|
-
*
|
|
70
|
+
* Stores `value` unless the cache was cleared since `generation` was taken, or, for a `read` from
|
|
71
|
+
* {@link startRead}, a read started after it stored `key`. `storedAt` backdates an entry seeded from persisted
|
|
72
|
+
* storage, so it expires on the schedule of the read that produced it rather than of the seeding. Returns `false`
|
|
73
|
+
* when refused, `'unchanged'` when `value` equals the one it replaces, expired or not, and `'changed'` otherwise.
|
|
39
74
|
*/
|
|
40
75
|
set(key, value, options) {
|
|
41
76
|
if (options?.generation != null && options.generation !== this._generation) return false;
|
|
77
|
+
const previous = this.entries.get(key);
|
|
78
|
+
const read = options?.read;
|
|
79
|
+
if (read != null && read < (previous?.read ?? 0)) return false;
|
|
42
80
|
this.entries.set(key, {
|
|
43
81
|
value,
|
|
44
|
-
storedAt: options?.storedAt ?? Date.now()
|
|
82
|
+
storedAt: options?.storedAt ?? Date.now(),
|
|
83
|
+
read: read ?? previous?.read ?? 0
|
|
45
84
|
});
|
|
46
|
-
return
|
|
85
|
+
return previous != null && areEqual(previous.value, value) ? "unchanged" : "changed";
|
|
47
86
|
}
|
|
48
87
|
delete(key) {
|
|
49
88
|
this.entries.delete(key);
|
|
@@ -54,6 +93,6 @@ var DiscoveryCache = class {
|
|
|
54
93
|
}
|
|
55
94
|
};
|
|
56
95
|
//#endregion
|
|
57
|
-
export { DiscoveryCache, discoveryCacheTtl };
|
|
96
|
+
export { DiscoveryCache, discoveryCacheTtl, incompleteAutolinksRetryDelay, isAutolinkSetExpired, isEmptyAutolinkFallback };
|
|
58
97
|
|
|
59
98
|
//# sourceMappingURL=discoveryCache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discoveryCache.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/utils/discoveryCache.ts"],"sourcesContent":["/**\n * How long a tracker's discovered project set (Jira sites and projects, Linear teams) is trusted before it is read\n * again. Projects are created and deleted while a session runs, and a stale set costs more than a re-read: a created\n * project never appears, and a deleted one keeps being searched, which Jira refuses with a `400` (#5907).\n */\nexport const discoveryCacheTtl = 5 * 60 * 1000;\n\n/**\n * A per-key cache of discovery results that expires entries after {@link discoveryCacheTtl} and can be dropped\n * wholesale when the connection is re-synced.\n *\n * {@link clear} bumps a generation, and {@link set} refuses a value read under an older one, so a read that was\n * already in flight when the cache was cleared cannot write the set it read before the clear back into it.\n */\nexport class DiscoveryCache<V> {\n\tprivate readonly entries = new Map<string, { value: V; storedAt: number }>();\n\tprivate _generation = 0;\n\n\tconstructor(private readonly ttl: number = discoveryCacheTtl) {}\n\n\t/** Pass to {@link set} to have a value read now refused if the cache is cleared before it is stored. */\n\tget generation(): number {\n\t\treturn this._generation;\n\t}\n\n\tget(key: string): V | undefined {\n\t\tconst entry = this.entries.get(key);\n\t\tif (entry == null
|
|
1
|
+
{"version":3,"file":"discoveryCache.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/utils/discoveryCache.ts"],"sourcesContent":["import { areEqual } from '@gitlens/utils/object.js';\n\n/**\n * How long a tracker's discovered project set (Jira sites and projects, Linear teams) is trusted before it is read\n * again. Projects are created and deleted while a session runs, and a stale set costs more than a re-read: a created\n * project never appears, and a deleted one keeps being searched, which Jira refuses with a `400` (#5907).\n */\nexport const discoveryCacheTtl = 5 * 60 * 1000;\n\n/**\n * How long an autolink set built from an incomplete or failed discovery read is served before the read is retried.\n * Short, so what the read missed shows up soon; but autolinks are read on every render of a commit message, and\n * retrying on each would make every render wait on the provider (#6183).\n */\nexport const incompleteAutolinksRetryDelay = 60 * 1000;\n\n/** Whether a kept autolink set is due a rebuild: once older than the TTL, or the retry delay when incomplete. */\nexport function isAutolinkSetExpired(set: { builtAt: number; complete: boolean }): boolean {\n\treturn Date.now() - set.builtAt >= (set.complete ? discoveryCacheTtl : incompleteAutolinksRetryDelay);\n}\n\n/**\n * Whether a kept autolink set is empty and incomplete: the fallback of a failing build that held none, built from no\n * list, so it stands for no set to any set built from the lists (#6184).\n */\nexport function isEmptyAutolinkFallback(set: { autolinks: readonly unknown[]; complete: boolean }): boolean {\n\treturn !set.complete && !set.autolinks.length;\n}\n\n/**\n * A per-key cache of discovery results that expires entries after {@link discoveryCacheTtl} and can be dropped\n * wholesale when the connection is re-synced.\n *\n * {@link clear} bumps a generation, and {@link set} refuses a value read under an older one, so a read that was\n * already in flight when the cache was cleared cannot write the set it read before the clear back into it.\n *\n * A read can also be ordered by when it started ({@link startRead}): its value is then refused once a read that started\n * after it stored the key, so a slower, possibly older read can't put back a list that a newer read replaced (#6184).\n * The start stands in for when the provider answered, which a read doesn't report: one that started first but was\n * answered with a later state (a paged list's last page read after the other read stored, say) is refused too, and one\n * that started later but was answered with an earlier state is stored over it. Either way the stored list lags until a\n * read replaces it, at most the TTL, and what is built from it with its own TTL, like autolinks, up to about twice\n * that. A deletion keeps no such order: Jira Cloud fences the reads in flight across its evictions itself (#6176).\n *\n * An expired entry is no longer served, but is kept until replaced, for that order and so {@link set} can tell whether\n * the read that replaces it found anything new.\n */\nexport class DiscoveryCache<V> {\n\tprivate readonly entries = new Map<string, { value: V; storedAt: number; read: number }>();\n\tprivate _generation = 0;\n\tprivate reads = 0;\n\n\tconstructor(private readonly ttl: number = discoveryCacheTtl) {}\n\n\t/** Pass to {@link set} to have a value read now refused if the cache is cleared before it is stored. */\n\tget generation(): number {\n\t\treturn this._generation;\n\t}\n\n\t/** Pass to {@link set} as `read`, taken when a read starts, to order its value against other reads'. */\n\tstartRead(): number {\n\t\treturn ++this.reads;\n\t}\n\n\tget(key: string): V | undefined {\n\t\tconst entry = this.entries.get(key);\n\t\tif (entry == null || Date.now() - entry.storedAt >= this.ttl) return undefined;\n\n\t\treturn entry.value;\n\t}\n\n\t/** The value stored under `key`, expired or not: what a reader that can't wait for a re-read last knew of it. */\n\tpeek(key: string): V | undefined {\n\t\treturn this.entries.get(key)?.value;\n\t}\n\n\t/**\n\t * Stores `value` unless the cache was cleared since `generation` was taken, or, for a `read` from\n\t * {@link startRead}, a read started after it stored `key`. `storedAt` backdates an entry seeded from persisted\n\t * storage, so it expires on the schedule of the read that produced it rather than of the seeding. Returns `false`\n\t * when refused, `'unchanged'` when `value` equals the one it replaces, expired or not, and `'changed'` otherwise.\n\t */\n\tset(\n\t\tkey: string,\n\t\tvalue: V,\n\t\toptions?: { generation?: number; read?: number; storedAt?: number },\n\t): 'changed' | 'unchanged' | false {\n\t\tif (options?.generation != null && options.generation !== this._generation) return false;\n\n\t\tconst previous = this.entries.get(key);\n\t\tconst read = options?.read;\n\t\tif (read != null && read < (previous?.read ?? 0)) return false;\n\n\t\t// A value stored without a read keeps the order of the one it replaces.\n\t\tthis.entries.set(key, {\n\t\t\tvalue: value,\n\t\t\tstoredAt: options?.storedAt ?? Date.now(),\n\t\t\tread: read ?? previous?.read ?? 0,\n\t\t});\n\t\treturn previous != null && areEqual(previous.value, value) ? 'unchanged' : 'changed';\n\t}\n\n\tdelete(key: string): void {\n\t\tthis.entries.delete(key);\n\t}\n\n\tclear(): void {\n\t\tthis._generation++;\n\t\tthis.entries.clear();\n\t}\n}\n"],"mappings":";;;;;;;AAOA,MAAa,oBAAoB;;;;;;AAOjC,MAAa,gCAAgC;;AAG7C,SAAgB,qBAAqB,KAAsD;CAC1F,OAAO,KAAK,IAAI,IAAI,IAAI,YAAY,IAAI,WAAW,oBAAoB;AACxE;;;;;AAMA,SAAgB,wBAAwB,KAAoE;CAC3G,OAAO,CAAC,IAAI,YAAY,CAAC,IAAI,UAAU;AACxC;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,iBAAb,MAA+B;CAKD;CAJ7B,0BAA2B,IAAI,IAA0D;CACzF,cAAsB;CACtB,QAAgB;CAEhB,YAAY,MAA+B,mBAAmB;EAAjC,KAAA,MAAA;CAAkC;;CAG/D,IAAI,aAAqB;EACxB,OAAO,KAAK;CACb;;CAGA,YAAoB;EACnB,OAAO,EAAE,KAAK;CACf;CAEA,IAAI,KAA4B;EAC/B,MAAM,QAAQ,KAAK,QAAQ,IAAI,GAAG;EAClC,IAAI,SAAS,QAAQ,KAAK,IAAI,IAAI,MAAM,YAAY,KAAK,KAAK,OAAO,KAAA;EAErE,OAAO,MAAM;CACd;;CAGA,KAAK,KAA4B;EAChC,OAAO,KAAK,QAAQ,IAAI,GAAG,CAAC,EAAE;CAC/B;;;;;;;CAQA,IACC,KACA,OACA,SACkC;EAClC,IAAI,SAAS,cAAc,QAAQ,QAAQ,eAAe,KAAK,aAAa,OAAO;EAEnF,MAAM,WAAW,KAAK,QAAQ,IAAI,GAAG;EACrC,MAAM,OAAO,SAAS;EACtB,IAAI,QAAQ,QAAQ,QAAQ,UAAU,QAAQ,IAAI,OAAO;EAGzD,KAAK,QAAQ,IAAI,KAAK;GACd;GACP,UAAU,SAAS,YAAY,KAAK,IAAI;GACxC,MAAM,QAAQ,UAAU,QAAQ;EACjC,CAAC;EACD,OAAO,YAAY,QAAQ,SAAS,SAAS,OAAO,KAAK,IAAI,cAAc;CAC5E;CAEA,OAAO,KAAmB;EACzB,KAAK,QAAQ,OAAO,GAAG;CACxB;CAEA,QAAc;EACb,KAAK;EACL,KAAK,QAAQ,MAAM;CACpB;AACD"}
|
|
@@ -2,6 +2,7 @@ import { ResourceDescriptor } from "../../../git/models/resourceDescriptor.js";
|
|
|
2
2
|
import { PullRequest, PullRequestFilter, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
|
|
3
3
|
import { IntegrationIds } from "../constants.js";
|
|
4
4
|
import { ProviderWarning } from "../results.js";
|
|
5
|
+
import "../providerFilters.js";
|
|
5
6
|
import { ProviderPullRequest, ProviderReposInput, ProviderRepository } from "../providers/models.js";
|
|
6
7
|
import { GitHostIntegration } from "../models/gitHostIntegration.js";
|
|
7
8
|
import { IssuesIntegration } from "../models/issuesIntegration.js";
|
|
@@ -43,6 +43,8 @@ export interface SpawnedProcess {
|
|
|
43
43
|
readonly killed: boolean;
|
|
44
44
|
readonly exitCode: number | null;
|
|
45
45
|
readonly spawnargs: string[];
|
|
46
|
+
/** Used to stop a run that passes its `maxBuffer`; without it the run destroys the output streams instead */
|
|
47
|
+
kill?(signal?: NodeJS.Signals): boolean;
|
|
46
48
|
once(event: 'error', listener: (error: Error) => void): this;
|
|
47
49
|
once(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
|
48
50
|
removeAllListeners(): this;
|
|
@@ -91,11 +93,10 @@ export interface RunOptions<TEncoding = BufferEncoding | 'buffer'> {
|
|
|
91
93
|
readonly encoding: string;
|
|
92
94
|
}) => string | Promise<string>;
|
|
93
95
|
/**
|
|
94
|
-
* The
|
|
95
|
-
*
|
|
96
|
+
* The most bytes each of stdout and stderr may produce; past it the process is killed and the run rejects
|
|
97
|
+
* with a `RunError` whose `code` is `ERR_CHILD_PROCESS_STDIO_MAXBUFFER`.
|
|
96
98
|
*
|
|
97
|
-
* If not specified,
|
|
98
|
-
* enough for most Git operations.
|
|
99
|
+
* If not specified, `run` allows 1000MB per stream and `runSpawn` allows unlimited output.
|
|
99
100
|
*/
|
|
100
101
|
readonly maxBuffer?: number;
|
|
101
102
|
readonly cancellation?: AbortSignal;
|