@gitkraken/core-gitlens 0.36.0 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/dist/git/utils/branch.utils.d.ts +14 -0
- package/dist/git/utils/branch.utils.js +37 -1
- package/dist/git/utils/branch.utils.js.map +1 -1
- package/dist/git/utils/branchLanded.utils.d.ts +43 -0
- package/dist/git/utils/branchLanded.utils.js +56 -0
- package/dist/git/utils/branchLanded.utils.js.map +1 -0
- package/dist/plus/ai/models/model.js +58 -4
- package/dist/plus/ai/models/model.js.map +1 -1
- package/dist/plus/ai/providers/anthropicProvider.js +58 -223
- package/dist/plus/ai/providers/anthropicProvider.js.map +1 -1
- package/dist/plus/ai/providers/deepSeekProvider.js +32 -18
- package/dist/plus/ai/providers/deepSeekProvider.js.map +1 -1
- package/dist/plus/ai/providers/geminiProvider.js +25 -189
- package/dist/plus/ai/providers/geminiProvider.js.map +1 -1
- package/dist/plus/ai/providers/mistralProvider.js +31 -73
- package/dist/plus/ai/providers/mistralProvider.js.map +1 -1
- package/dist/plus/ai/providers/xaiProvider.js +9 -11
- package/dist/plus/ai/providers/xaiProvider.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +18 -3
- package/dist/plus/git-github/api/github.js +58 -15
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +2 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +24 -5
- package/dist/plus/integrations/models/issuesIntegration.d.ts +2 -1
- package/dist/plus/integrations/models/issuesIntegration.js +6 -3
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +21 -6
- package/dist/plus/integrations/providers/azureDevOps.js +24 -12
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +49 -3
- package/dist/plus/integrations/providers/azureDevOpsServer.js +151 -23
- package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
- package/dist/plus/integrations/providers/linear.d.ts +3 -2
- package/dist/plus/integrations/providers/linear.js +7 -5
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +0 -1
- package/dist/plus/integrations/reads/searchPullRequests.d.ts +2 -0
- package/dist/plus/integrations/reads/searchPullRequests.js +18 -9
- package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
- package/docs/integrations.md +27 -6
- 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. The request can't be aborted (provider-apis takes no signal), so a lookup that outlives its\n\t * caller's timeout is joined by the next one rather than piling another request on top of it.\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\tlet request = this._organizationRequests.get(accessToken);\n\t\t\tif (request == null) {\n\t\t\t\trequest = this.fetchOrganization(session).finally(() => this._organizationRequests.delete(accessToken));\n\t\t\t\tthis._organizationRequests.set(accessToken, 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,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,WAAW,CAAC,QAAQ,EAAE,IACxB;EAAE,WAAW,CAAC,QAAQ;EAAG,sBAAsB,CAAC,QAAQ;CAAE;AAC9D;AAEA,IAAa,oBAAb,cAAuC,kBAAuD;;;;;;CAM7F,6BAA8B,IAAI,IAGhC;CACF,mCAAoC,IAAI,IAAuE;CAE/G,MAAe,YAAuE;EAErF,IAAI,EADc,KAAK,kBAAmB,MAAM,KAAK,YAAY,MAC/C,KAAK,YAAY,MAClC,OAAO,CAAC;EAGT,MAAM,UAAU,KAAK;EACrB,MAAM,SAAS,KAAK,WAAW,IAAI,QAAQ,WAAW;EAGtD,IAAI,KAAK,sBAAsB,MAAM,OAAO,QAAQ,aAAa,CAAC;EAClE,IAAI,UAAU,MAAM,OAAO,KAAK,eAAe,OAAO;EAEtD,IAAI,KAAK,IAAI,IAAI,OAAO,WAAA,KACvB,KAAU,eAAe,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;EAEjD,OAAO,OAAO;CACf;;CAGA,eACC,SAC4D;EAC5D,MAAM,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wBAAwB,KAAK;MAAE;MACpE,WAAW;KACZ,SAAS,IAAI;MACZ,OAAO;OAAE,QAAQ;OAAY,QAAQ;MAAG;MACxC,SAAS;KACV;KAGD,KAAK,MAAM,SAAS,SACnB,MAAM,SAAS;IAEjB;GACD;EACD;EAEA,OAAO,YAAY,SAAS,QAAQ,KAAA;CACrC;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 { 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,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,WAAW,CAAC,QAAQ,EAAE,IACxB;EAAE,WAAW,CAAC,QAAQ;EAAG,sBAAsB,CAAC,QAAQ;CAAE;AAC9D;AAEA,IAAa,oBAAb,cAAuC,kBAAuD;;;;;;CAM7F,6BAA8B,IAAI,IAG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CAC5D;AACD;AAtsBE,WAAA,CAAA,MAAM,CAAA,GAAA,kBAAA,WAAA,8BAAA,IAAA"}
|
|
@@ -2,7 +2,6 @@ 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";
|
|
6
5
|
import { ProviderPullRequest, ProviderReposInput, ProviderRepository } from "../providers/models.js";
|
|
7
6
|
import { GitHostIntegration } from "../models/gitHostIntegration.js";
|
|
8
7
|
import { IssuesIntegration } from "../models/issuesIntegration.js";
|
|
@@ -29,6 +29,8 @@ export declare function searchPullRequestsPage(ctx: ProviderReadContext, options
|
|
|
29
29
|
summary?: boolean;
|
|
30
30
|
/** See {@link IntegrationManager.searchPullRequestsPage}. */
|
|
31
31
|
mergeQueue?: boolean;
|
|
32
|
+
/** See {@link IntegrationManager.searchPullRequestsPage}. */
|
|
33
|
+
cancellation?: AbortSignal;
|
|
32
34
|
}): Promise<ProviderPagedResult<PullRequestShape>>;
|
|
33
35
|
//#endregion
|
|
34
36
|
//# sourceMappingURL=searchPullRequests.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CancellationError } from "../../../utils/cancellation.js";
|
|
1
2
|
import "../../../git/models/pullRequest.js";
|
|
2
3
|
import { mergeAssessmentInto } from "../collectionMetadata.js";
|
|
3
4
|
import { isGitHostIntegration, isIssuesHostIntegrationId, warnOnMissingSessionForDomain } from "../utils/integration.utils.js";
|
|
@@ -16,16 +17,20 @@ import { resolvePullRequestSearchCriteria, resolvePullRequestSearchScope } from
|
|
|
16
17
|
* names the order the reachable window was selected under.
|
|
17
18
|
*/
|
|
18
19
|
async function searchPullRequestsPage(ctx, options) {
|
|
20
|
+
const cancellation = options.cancellation;
|
|
21
|
+
if (cancellation?.aborted) throw new CancellationError();
|
|
19
22
|
const page = Math.max(1, Math.trunc(options.page ?? 1));
|
|
20
23
|
const refused = (warning) => refusedPage(1, [warning], true);
|
|
21
24
|
if (isIssuesHostIntegrationId(options.providerId)) return refused(gitHostOnlySurfaceWarning(options.providerId, void 0, options.connectionId, "Filtered pull request search"));
|
|
22
25
|
const integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);
|
|
26
|
+
if (cancellation?.aborted) throw new CancellationError();
|
|
23
27
|
if (integration == null) {
|
|
24
28
|
const early = ctx.earlyReturnConnectionWarnings(options.providerId, options.connectionId, options.domain);
|
|
25
29
|
return refusedPage(1, early.warnings, early.fetchFailed);
|
|
26
30
|
}
|
|
27
31
|
if (!isGitHostIntegration(integration)) return refused(gitHostOnlySurfaceWarning(options.providerId, void 0, options.connectionId, "Filtered pull request search"));
|
|
28
32
|
await ctx.forceRefreshIfRequested(integration, options.forceSync, options.connectionId);
|
|
33
|
+
if (cancellation?.aborted) throw new CancellationError();
|
|
29
34
|
const domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);
|
|
30
35
|
const warnOnMissingSession = warnOnMissingSessionForDomain(options.providerId, options.domain);
|
|
31
36
|
const resolved = resolvePullRequestSearchCriteria(options.providerId, options.criteria);
|
|
@@ -41,15 +46,19 @@ async function searchPullRequestsPage(ctx, options) {
|
|
|
41
46
|
}));
|
|
42
47
|
case "unusable-scope": return refused(otherWarning(options.providerId, domain, options.connectionId, unusableSearchScopeMessage("pull request search scopes", scope.rejection.scopes)));
|
|
43
48
|
}
|
|
44
|
-
const readPage = (cursor) =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
const readPage = async (cursor) => {
|
|
50
|
+
const read = await runCaptured(options.providerId, domain, options.connectionId, () => integration.searchPullRequestsPageResult({
|
|
51
|
+
repos: scope.repos,
|
|
52
|
+
org: options.org,
|
|
53
|
+
criteria: options.criteria,
|
|
54
|
+
cursor,
|
|
55
|
+
pageSize: options.itemsPerPage,
|
|
56
|
+
summary: options.summary,
|
|
57
|
+
mergeQueue: options.mergeQueue
|
|
58
|
+
}, cancellation, options.connectionId), { warnOnMissingSession });
|
|
59
|
+
if (cancellation?.aborted) throw new CancellationError();
|
|
60
|
+
return read;
|
|
61
|
+
};
|
|
53
62
|
const first = await readPage(options.cursor);
|
|
54
63
|
const warnings = first.warning != null ? [first.warning] : [];
|
|
55
64
|
let totalCount = first.value?.totalCount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchPullRequests.js","names":[],"sources":["../../../../../plus/integrations/src/reads/searchPullRequests.ts"],"sourcesContent":["import type { PullRequestSearchCriteria, PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport { defaultPullRequestSort } from '@gitlens/git/models/pullRequest.js';\nimport { mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type { ProviderReposInput } from '../providers/models.js';\nimport type { ProviderPagedResult, ProviderWarning } from '../results.js';\nimport {\n\tisGitHostIntegration,\n\tisIssuesHostIntegrationId,\n\twarnOnMissingSessionForDomain,\n} from '../utils/integration.utils.js';\nimport type { ProviderReadContext } from './context.js';\nimport { runCaptured } from './drains.js';\nimport { resolvePullRequestSearchCriteria, resolvePullRequestSearchScope } from './filters.js';\nimport {\n\tdrainFlatPagesToRequestedPage,\n\trefusedPage,\n\tresolveContinuation,\n\tresolveCurrentPage,\n\tusableCursor,\n} from './paging.js';\nimport {\n\tgitHostOnlySurfaceWarning,\n\totherWarning,\n\tpullRequestSearchCapResultWarning,\n\ttruncationWarning,\n\tunsupportedPullRequestSearchCriteriaWarning,\n\tunusableSearchScopeMessage,\n} from './warnings.js';\n\n/**\n * Pull requests matching structured criteria over a repository/organization or current-user relationship scope.\n *\n * The read is deliberately separate from `listPullRequestsPage`: the list has provider-specific \"my PRs\"\n * semantics and no text channel, while this method promises a sanitized query, an ordering the caller chooses\n * (`criteria.sort`, defaulting to most-recently-updated-first) and that is applied to the merged page as a whole,\n * one upstream request per cursor-threaded page, and a quantified omission at the provider's result ceiling that\n * names the order the reachable window was selected under.\n */\nexport async function searchPullRequestsPage(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\trepos?: ProviderReposInput;\n\t\torg?: string;\n\t\tcriteria?: PullRequestSearchCriteria;\n\t\tpage?: number;\n\t\tcursor?: string;\n\t\t/** Per relationship × state facet, not per page; see {@link IntegrationManager.searchPullRequestsPage}. */\n\t\titemsPerPage?: number;\n\t\tforceSync?: boolean;\n\t\tconnectionId?: string;\n\t\tdomain?: string;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tsummary?: boolean;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tmergeQueue?: boolean;\n\t},\n): Promise<ProviderPagedResult<PullRequestShape>> {\n\tconst page = Math.max(1, Math.trunc(options.page ?? 1));\n\tconst refused = (warning: ProviderWarning) => refusedPage<PullRequestShape>(1, [warning], true);\n\n\tif (isIssuesHostIntegrationId(options.providerId)) {\n\t\treturn refused(\n\t\t\tgitHostOnlySurfaceWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t'Filtered pull request search',\n\t\t\t),\n\t\t);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\tif (integration == null) {\n\t\tconst early = ctx.earlyReturnConnectionWarnings(options.providerId, options.connectionId, options.domain);\n\t\treturn refusedPage(1, early.warnings, early.fetchFailed);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn refused(\n\t\t\tgitHostOnlySurfaceWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t'Filtered pull request search',\n\t\t\t),\n\t\t);\n\t}\n\n\tawait ctx.forceRefreshIfRequested(integration, options.forceSync, options.connectionId);\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\tconst warnOnMissingSession = warnOnMissingSessionForDomain(options.providerId, options.domain);\n\n\tconst resolved = resolvePullRequestSearchCriteria(options.providerId, options.criteria);\n\tif (resolved.rejection != null) {\n\t\treturn refused(\n\t\t\tunsupportedPullRequestSearchCriteriaWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\tresolved.rejection,\n\t\t\t),\n\t\t);\n\t}\n\n\tconst scope = resolvePullRequestSearchScope(options.providerId, options.repos, options.org, options.criteria);\n\tswitch (scope.rejection?.reason) {\n\t\tcase 'unscoped':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t'A filtered pull request search must be scoped: pass `repos`, `org`, or at least one current-user relationship.',\n\t\t\t\t),\n\t\t\t);\n\t\tcase 'repo-ids':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t'A filtered pull request search cannot be scoped by repository id; pass repository descriptors (namespace + name) instead.',\n\t\t\t\t),\n\t\t\t);\n\t\tcase 'unsupported-repository-scope':\n\t\tcase 'unsupported-organization-scope':\n\t\t\treturn refused(\n\t\t\t\tunsupportedPullRequestSearchCriteriaWarning(options.providerId, domain, options.connectionId, {\n\t\t\t\t\treason: 'unsupported-criteria',\n\t\t\t\t\tcriteria: [\n\t\t\t\t\t\tscope.rejection.reason === 'unsupported-repository-scope'\n\t\t\t\t\t\t\t? 'repositoryScope'\n\t\t\t\t\t\t\t: 'organizationScope',\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t// A scope the query cannot spell, refused rather than sanitized — see `isUsableSearchScopeName`.\n\t\tcase 'unusable-scope':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\tunusableSearchScopeMessage('pull request search scopes', scope.rejection.scopes),\n\t\t\t\t),\n\t\t\t);\n\t}\n\n\tconst readPage = (cursor: string | undefined) =>\n\t\trunCaptured(\n\t\t\toptions.providerId,\n\t\t\tdomain,\n\t\t\toptions.connectionId,\n\t\t\t() =>\n\t\t\t\tintegration.searchPullRequestsPageResult(\n\t\t\t\t\t{\n\t\t\t\t\t\trepos: scope.repos,\n\t\t\t\t\t\torg: options.org,\n\t\t\t\t\t\tcriteria: options.criteria,\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tpageSize: options.itemsPerPage,\n\t\t\t\t\t\tsummary: options.summary,\n\t\t\t\t\t\tmergeQueue: options.mergeQueue,\n\t\t\t\t\t},\n\t\t\t\t\tundefined,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t),\n\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t);\n\n\tconst first = await readPage(options.cursor);\n\tconst warnings = first.warning != null ? [first.warning] : [];\n\tlet totalCount = first.value?.totalCount;\n\t// Facets whose rows are missing while their siblings answered. A page reports the walk's completeness so far, not\n\t// just its own requests: a failure dropped for good repeats on every later page, while one that recovered on a\n\t// retry drops out because its rows came back. So the latest page read is the one to assess, including when a later\n\t// page fails the walk outright — never union the pages, which would bring a recovered failure back.\n\tlet lastMetadata = first.value?.metadata;\n\tlet limitReached = first.value?.limitReached === true;\n\tconst drained = await drainFlatPagesToRequestedPage(first, {\n\t\trequestedPage: page,\n\t\tsuppliedCursor: options.cursor,\n\t\twarnings: warnings,\n\t\treadPage: readPage,\n\t\tfold: p => {\n\t\t\tif (p.totalCount != null) {\n\t\t\t\ttotalCount = Math.max(totalCount ?? 0, p.totalCount);\n\t\t\t}\n\t\t\tlastMetadata = p.metadata;\n\t\t\tlimitReached ||= p.limitReached === true;\n\t\t},\n\t});\n\tconst { value, currentPage, requestedPageMissing } = drained;\n\tconst assessment = mergeAssessmentInto(warnings, options.providerId, domain, options.connectionId, lastMetadata);\n\n\tif (value == null && warnings.length === 0) {\n\t\treturn refused(\n\t\t\tunsupportedPullRequestSearchCriteriaWarning(options.providerId, domain, options.connectionId, {\n\t\t\t\treason: 'unsupported-search',\n\t\t\t}),\n\t\t);\n\t}\n\n\tconst items = requestedPageMissing ? [] : (value?.values ?? []);\n\tconst continuation = resolveContinuation(\n\t\t{\n\t\t\thasMore: requestedPageMissing ? false : (value?.hasMore ?? false),\n\t\t\tcursor: requestedPageMissing ? undefined : usableCursor(value?.cursor),\n\t\t\ttruncated: drained.truncated,\n\t\t},\n\t\tundefined,\n\t);\n\t// A facet that failed while its siblings answered leaves the result incomplete, as `listPullRequestsPage` reports\n\t// it; its warning is already in `warnings`, so it adds no generic one below.\n\tconst truncated = continuation.truncated || assessment.truncated;\n\tif (truncated && warnings.length === 0) {\n\t\twarnings.push(\n\t\t\tpullRequestSearchCapResultWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\ttotalCount,\n\t\t\t\toptions.criteria?.sort ?? defaultPullRequestSort,\n\t\t\t\tlimitReached,\n\t\t\t) ??\n\t\t\t\ttruncationWarning(options.providerId, domain, options.connectionId, 'Pull request search', 'exhausted'),\n\t\t);\n\t}\n\n\treturn {\n\t\titems: items,\n\t\twarnings: warnings,\n\t\tpage: {\n\t\t\tcurrentPage: requestedPageMissing\n\t\t\t\t? page\n\t\t\t\t: resolveCurrentPage({\n\t\t\t\t\t\tproviderPage: currentPage,\n\t\t\t\t\t\trequestedPage: page,\n\t\t\t\t\t\tsuppliedCursor: options.cursor,\n\t\t\t\t\t\tpageAdvanceable: false,\n\t\t\t\t\t}),\n\t\t\titemsPerPage: items.length,\n\t\t\ttruncated: truncated || undefined,\n\t\t},\n\t\thasMore: continuation.hasMore,\n\t\tcursor: continuation.cursor,\n\t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Ac,EAC7F,QAAQ,qBACT,CAAC,CACF;CAGD,MAAM,QAAQ,uBAAuB,CAAC,IAAK,OAAO,UAAU,CAAC;CAC7D,MAAM,eAAe,oBACpB;EACC,SAAS,uBAAuB,QAAS,OAAO,WAAW;EAC3D,QAAQ,uBAAuB,KAAA,IAAY,aAAa,OAAO,MAAM;EACrE,WAAW,QAAQ;CACpB,GACA,KAAA,CACD;CAGA,MAAM,YAAY,aAAa,aAAa,WAAW;CACvD,IAAI,aAAa,SAAS,WAAW,GACpC,SAAS,KACR,kCACC,QAAQ,YACR,QACA,QAAQ,cACR,YACA,QAAQ,UAAU,QAAA,gBAClB,YACD,KACC,kBAAkB,QAAQ,YAAY,QAAQ,QAAQ,cAAc,uBAAuB,WAAW,CACxG;CAGD,OAAO;EACC;EACG;EACV,MAAM;GACL,aAAa,uBACV,OACA,mBAAmB;IACnB,cAAc;IACd,eAAe;IACf,gBAAgB,QAAQ;IACxB,iBAAiB;GAClB,CAAC;GACH,cAAc,MAAM;GACpB,WAAW,aAAa,KAAA;EACzB;EACA,SAAS,aAAa;EACtB,QAAQ,aAAa;EACrB,aAAa,QAAQ,eAAe,WAAW,eAAe,KAAA;CAC/D;AACD"}
|
|
1
|
+
{"version":3,"file":"searchPullRequests.js","names":[],"sources":["../../../../../plus/integrations/src/reads/searchPullRequests.ts"],"sourcesContent":["import type { PullRequestSearchCriteria, PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport { defaultPullRequestSort } from '@gitlens/git/models/pullRequest.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type { ProviderReposInput } from '../providers/models.js';\nimport type { ProviderPagedResult, ProviderWarning } from '../results.js';\nimport {\n\tisGitHostIntegration,\n\tisIssuesHostIntegrationId,\n\twarnOnMissingSessionForDomain,\n} from '../utils/integration.utils.js';\nimport type { ProviderReadContext } from './context.js';\nimport { runCaptured } from './drains.js';\nimport { resolvePullRequestSearchCriteria, resolvePullRequestSearchScope } from './filters.js';\nimport {\n\tdrainFlatPagesToRequestedPage,\n\trefusedPage,\n\tresolveContinuation,\n\tresolveCurrentPage,\n\tusableCursor,\n} from './paging.js';\nimport {\n\tgitHostOnlySurfaceWarning,\n\totherWarning,\n\tpullRequestSearchCapResultWarning,\n\ttruncationWarning,\n\tunsupportedPullRequestSearchCriteriaWarning,\n\tunusableSearchScopeMessage,\n} from './warnings.js';\n\n/**\n * Pull requests matching structured criteria over a repository/organization or current-user relationship scope.\n *\n * The read is deliberately separate from `listPullRequestsPage`: the list has provider-specific \"my PRs\"\n * semantics and no text channel, while this method promises a sanitized query, an ordering the caller chooses\n * (`criteria.sort`, defaulting to most-recently-updated-first) and that is applied to the merged page as a whole,\n * one upstream request per cursor-threaded page, and a quantified omission at the provider's result ceiling that\n * names the order the reachable window was selected under.\n */\nexport async function searchPullRequestsPage(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\trepos?: ProviderReposInput;\n\t\torg?: string;\n\t\tcriteria?: PullRequestSearchCriteria;\n\t\tpage?: number;\n\t\tcursor?: string;\n\t\t/** Per relationship × state facet, not per page; see {@link IntegrationManager.searchPullRequestsPage}. */\n\t\titemsPerPage?: number;\n\t\tforceSync?: boolean;\n\t\tconnectionId?: string;\n\t\tdomain?: string;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tsummary?: boolean;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tmergeQueue?: boolean;\n\t\t/** See {@link IntegrationManager.searchPullRequestsPage}. */\n\t\tcancellation?: AbortSignal;\n\t},\n): Promise<ProviderPagedResult<PullRequestShape>> {\n\tconst cancellation = options.cancellation;\n\tif (cancellation?.aborted) throw new CancellationError();\n\n\tconst page = Math.max(1, Math.trunc(options.page ?? 1));\n\tconst refused = (warning: ProviderWarning) => refusedPage<PullRequestShape>(1, [warning], true);\n\n\tif (isIssuesHostIntegrationId(options.providerId)) {\n\t\treturn refused(\n\t\t\tgitHostOnlySurfaceWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t'Filtered pull request search',\n\t\t\t),\n\t\t);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\t// Every refusal below resolves as a failed page, which a cancelled caller must never receive.\n\tif (cancellation?.aborted) throw new CancellationError();\n\tif (integration == null) {\n\t\tconst early = ctx.earlyReturnConnectionWarnings(options.providerId, options.connectionId, options.domain);\n\t\treturn refusedPage(1, early.warnings, early.fetchFailed);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn refused(\n\t\t\tgitHostOnlySurfaceWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tundefined,\n\t\t\t\toptions.connectionId,\n\t\t\t\t'Filtered pull request search',\n\t\t\t),\n\t\t);\n\t}\n\n\tawait ctx.forceRefreshIfRequested(integration, options.forceSync, options.connectionId);\n\tif (cancellation?.aborted) throw new CancellationError();\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\tconst warnOnMissingSession = warnOnMissingSessionForDomain(options.providerId, options.domain);\n\n\tconst resolved = resolvePullRequestSearchCriteria(options.providerId, options.criteria);\n\tif (resolved.rejection != null) {\n\t\treturn refused(\n\t\t\tunsupportedPullRequestSearchCriteriaWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\tresolved.rejection,\n\t\t\t),\n\t\t);\n\t}\n\n\tconst scope = resolvePullRequestSearchScope(options.providerId, options.repos, options.org, options.criteria);\n\tswitch (scope.rejection?.reason) {\n\t\tcase 'unscoped':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t'A filtered pull request search must be scoped: pass `repos`, `org`, or at least one current-user relationship.',\n\t\t\t\t),\n\t\t\t);\n\t\tcase 'repo-ids':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t'A filtered pull request search cannot be scoped by repository id; pass repository descriptors (namespace + name) instead.',\n\t\t\t\t),\n\t\t\t);\n\t\tcase 'unsupported-repository-scope':\n\t\tcase 'unsupported-organization-scope':\n\t\t\treturn refused(\n\t\t\t\tunsupportedPullRequestSearchCriteriaWarning(options.providerId, domain, options.connectionId, {\n\t\t\t\t\treason: 'unsupported-criteria',\n\t\t\t\t\tcriteria: [\n\t\t\t\t\t\tscope.rejection.reason === 'unsupported-repository-scope'\n\t\t\t\t\t\t\t? 'repositoryScope'\n\t\t\t\t\t\t\t: 'organizationScope',\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t// A scope the query cannot spell, refused rather than sanitized — see `isUsableSearchScopeName`.\n\t\tcase 'unusable-scope':\n\t\t\treturn refused(\n\t\t\t\totherWarning(\n\t\t\t\t\toptions.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t\tunusableSearchScopeMessage('pull request search scopes', scope.rejection.scopes),\n\t\t\t\t),\n\t\t\t);\n\t}\n\n\tconst readPage = async (cursor: string | undefined) => {\n\t\tconst read = await runCaptured(\n\t\t\toptions.providerId,\n\t\t\tdomain,\n\t\t\toptions.connectionId,\n\t\t\t() =>\n\t\t\t\tintegration.searchPullRequestsPageResult(\n\t\t\t\t\t{\n\t\t\t\t\t\trepos: scope.repos,\n\t\t\t\t\t\torg: options.org,\n\t\t\t\t\t\tcriteria: options.criteria,\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tpageSize: options.itemsPerPage,\n\t\t\t\t\t\tsummary: options.summary,\n\t\t\t\t\t\tmergeQueue: options.mergeQueue,\n\t\t\t\t\t},\n\t\t\t\t\tcancellation,\n\t\t\t\t\toptions.connectionId,\n\t\t\t\t),\n\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t);\n\t\t// The aborted request comes back as a failed read; a cancelled caller is owed the cancellation instead, and\n\t\t// a drain walking to a page number must stop here rather than read its next page.\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\treturn read;\n\t};\n\n\tconst first = await readPage(options.cursor);\n\tconst warnings = first.warning != null ? [first.warning] : [];\n\tlet totalCount = first.value?.totalCount;\n\t// Facets whose rows are missing while their siblings answered. A page reports the walk's completeness so far, not\n\t// just its own requests: a failure dropped for good repeats on every later page, while one that recovered on a\n\t// retry drops out because its rows came back. So the latest page read is the one to assess, including when a later\n\t// page fails the walk outright — never union the pages, which would bring a recovered failure back.\n\tlet lastMetadata = first.value?.metadata;\n\tlet limitReached = first.value?.limitReached === true;\n\tconst drained = await drainFlatPagesToRequestedPage(first, {\n\t\trequestedPage: page,\n\t\tsuppliedCursor: options.cursor,\n\t\twarnings: warnings,\n\t\treadPage: readPage,\n\t\tfold: p => {\n\t\t\tif (p.totalCount != null) {\n\t\t\t\ttotalCount = Math.max(totalCount ?? 0, p.totalCount);\n\t\t\t}\n\t\t\tlastMetadata = p.metadata;\n\t\t\tlimitReached ||= p.limitReached === true;\n\t\t},\n\t});\n\tconst { value, currentPage, requestedPageMissing } = drained;\n\tconst assessment = mergeAssessmentInto(warnings, options.providerId, domain, options.connectionId, lastMetadata);\n\n\tif (value == null && warnings.length === 0) {\n\t\treturn refused(\n\t\t\tunsupportedPullRequestSearchCriteriaWarning(options.providerId, domain, options.connectionId, {\n\t\t\t\treason: 'unsupported-search',\n\t\t\t}),\n\t\t);\n\t}\n\n\tconst items = requestedPageMissing ? [] : (value?.values ?? []);\n\tconst continuation = resolveContinuation(\n\t\t{\n\t\t\thasMore: requestedPageMissing ? false : (value?.hasMore ?? false),\n\t\t\tcursor: requestedPageMissing ? undefined : usableCursor(value?.cursor),\n\t\t\ttruncated: drained.truncated,\n\t\t},\n\t\tundefined,\n\t);\n\t// A facet that failed while its siblings answered leaves the result incomplete, as `listPullRequestsPage` reports\n\t// it; its warning is already in `warnings`, so it adds no generic one below.\n\tconst truncated = continuation.truncated || assessment.truncated;\n\tif (truncated && warnings.length === 0) {\n\t\twarnings.push(\n\t\t\tpullRequestSearchCapResultWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\ttotalCount,\n\t\t\t\toptions.criteria?.sort ?? defaultPullRequestSort,\n\t\t\t\tlimitReached,\n\t\t\t) ??\n\t\t\t\ttruncationWarning(options.providerId, domain, options.connectionId, 'Pull request search', 'exhausted'),\n\t\t);\n\t}\n\n\treturn {\n\t\titems: items,\n\t\twarnings: warnings,\n\t\tpage: {\n\t\t\tcurrentPage: requestedPageMissing\n\t\t\t\t? page\n\t\t\t\t: resolveCurrentPage({\n\t\t\t\t\t\tproviderPage: currentPage,\n\t\t\t\t\t\trequestedPage: page,\n\t\t\t\t\t\tsuppliedCursor: options.cursor,\n\t\t\t\t\t\tpageAdvanceable: false,\n\t\t\t\t\t}),\n\t\t\titemsPerPage: items.length,\n\t\t\ttruncated: truncated || undefined,\n\t\t},\n\t\thasMore: continuation.hasMore,\n\t\tcursor: continuation.cursor,\n\t\tfetchFailed: drained.fetchFailed || assessment.fetchFailed || undefined,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCA,eAAsB,uBACrB,KACA,SAmBiD;CACjD,MAAM,eAAe,QAAQ;CAC7B,IAAI,cAAc,SAAS,MAAM,IAAI,kBAAkB;CAEvD,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,QAAQ,CAAC,CAAC;CACtD,MAAM,WAAW,YAA6B,YAA8B,GAAG,CAAC,OAAO,GAAG,IAAI;CAE9F,IAAI,0BAA0B,QAAQ,UAAU,GAC/C,OAAO,QACN,0BACC,QAAQ,YACR,KAAA,GACA,QAAQ,cACR,8BACD,CACD;CAGD,MAAM,cAA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a,OAAO,MAAM;EACrE,WAAW,QAAQ;CACpB,GACA,KAAA,CACD;CAGA,MAAM,YAAY,aAAa,aAAa,WAAW;CACvD,IAAI,aAAa,SAAS,WAAW,GACpC,SAAS,KACR,kCACC,QAAQ,YACR,QACA,QAAQ,cACR,YACA,QAAQ,UAAU,QAAA,gBAClB,YACD,KACC,kBAAkB,QAAQ,YAAY,QAAQ,QAAQ,cAAc,uBAAuB,WAAW,CACxG;CAGD,OAAO;EACC;EACG;EACV,MAAM;GACL,aAAa,uBACV,OACA,mBAAmB;IACnB,cAAc;IACd,eAAe;IACf,gBAAgB,QAAQ;IACxB,iBAAiB;GAClB,CAAC;GACH,cAAc,MAAM;GACpB,WAAW,aAAa,KAAA;EACzB;EACA,SAAS,aAAa;EACtB,QAAQ,aAAa;EACrB,aAAa,QAAQ,eAAe,WAAW,eAAe,KAAA;CAC/D;AACD"}
|
package/docs/integrations.md
CHANGED
|
@@ -451,8 +451,9 @@ The cells that aren't obvious from the projection names:
|
|
|
451
451
|
summed, divided by 100 and rounded, minimum 1) that is one more request per pull request read: a 30-row full search
|
|
452
452
|
page goes from 121 requests (1 point) to 151 (2 points), a 100-row lite page from 1 to 101 (1 point either way), a
|
|
453
453
|
25-target batch read from 100 to 125 (1 point), and the cheap check's 25 targets from 0 or 25 (with `'checks'`) to 25
|
|
454
|
-
or 50 (1 point either way). The filtered search's
|
|
455
|
-
|
|
454
|
+
or 50 (1 point either way). The filtered search's pages are bounded per document (20 full rows, 100 lite rows,
|
|
455
|
+
across all facets), so every page of it costs 1 point either way: its costliest, ten facets of 2 full rows or of 10
|
|
456
|
+
lite rows, goes from 90 requests to 110 and from 10 to 110.
|
|
456
457
|
|
|
457
458
|
#### Every other provider
|
|
458
459
|
|
|
@@ -742,8 +743,9 @@ relationship is mandatory. This is deliberately not `involves:@me`: that GitHub
|
|
|
742
743
|
`review-requested` but includes `commenter`, so it cannot match the adjacent visible-PR list.
|
|
743
744
|
|
|
744
745
|
The read is ordered by `criteria.sort`, most-recently-updated-first when omitted; the keys a provider accepts are
|
|
745
|
-
`getSupportedFilters().pullRequestSearch.sorts`. On GitHub/GHE a threaded `cursor` is
|
|
746
|
-
since every active relationship × state facet travels as an alias in one
|
|
746
|
+
`getSupportedFilters().pullRequestSearch.sorts`. On GitHub/GHE a threaded `cursor` is one upstream request (two when
|
|
747
|
+
GitHub's gateway times out, see below), since every active relationship × state facet travels as an alias in one
|
|
748
|
+
GraphQL document; Bitbucket Data Center
|
|
747
749
|
has no such batching and spends one request per repository × relationship facet still being read. A page number
|
|
748
750
|
without a cursor walks from page 1. At GitHub's 1,000-result-per-facet ceiling, `page.truncated` is true and
|
|
749
751
|
the warning's `omission` carries `totalCount`, `limit`, and `recovery: 'none'`. `totalCount` is the largest
|
|
@@ -764,6 +766,24 @@ overlap; deduplication does **not** bring the page back to the requested size, s
|
|
|
764
766
|
the facets share. As in §5.1: size the list off `page.itemsPerPage`, not off the value you sent; a provider
|
|
765
767
|
may cap the `itemsPerPage` it honors below what you asked for.
|
|
766
768
|
|
|
769
|
+
On GitHub/GHE what caps it is time. GitHub gives up on a page it can't build in about 11 seconds and answers
|
|
770
|
+
502/504 with an HTML gateway page, and the time grows with how many pull requests the page selects and how much
|
|
771
|
+
each carries. So a page holds at most **20** pull requests across all of its facets in the full shape and
|
|
772
|
+
**100** in the `summary` shape, split evenly across the active facets (a 3-relationship full search gets 6 per
|
|
773
|
+
facet), and `itemsPerPage` can only lower a facet's share. If the gateway gives up anyway, the page is asked for
|
|
774
|
+
once more at half its size (unchanged once it is one row per facet), and the rest of the walk keeps that size; if
|
|
775
|
+
that fails at the gateway too, the read fails (warning + `fetchFailed`) rather than sending the third identical
|
|
776
|
+
request that made a failure take about 35 seconds. Other transient failures (503, a network failure) are retried
|
|
777
|
+
unchanged as before. A smaller page is a successful one: no warning, `page.itemsPerPage` says how many came back,
|
|
778
|
+
and its `cursor` resumes every facet right after the last row it served, so no facet skips or repeats a row. Never
|
|
779
|
+
treat a short page as the last; only `hasMore`/`cursor` say that. Facets that overlap are another matter, on every
|
|
780
|
+
page of this search: a pull request two facets share (authored and assigned, say) can come back once per facet, on
|
|
781
|
+
different pages, so dedupe the accumulated rows by `url`.
|
|
782
|
+
|
|
783
|
+
Pass `cancellation` to abort the read: the request in flight, a retry waiting to be sent, and any page a
|
|
784
|
+
page-number walk still has to read. The read then rejects with a `CancellationError` rather than resolving, so a
|
|
785
|
+
cancelled read is never mistaken for a failed or an empty one.
|
|
786
|
+
|
|
767
787
|
### 5.1 The filtered issue search and its count probe
|
|
768
788
|
|
|
769
789
|
`searchIssuesPage` answers "every issue in this scope matching X", which no other issue read can: the
|
|
@@ -1304,8 +1324,9 @@ both: only the full projection populates it.
|
|
|
1304
1324
|
|
|
1305
1325
|
The paginated read that does carry the full projection is `searchPullRequestsPage` with
|
|
1306
1326
|
`criteria.relationships` on GitHub/GHE (Bitbucket Data Center also exposes the search, with its native row shape):
|
|
1307
|
-
its results always include the review projection with `commitOid`, it honors `itemsPerPage
|
|
1308
|
-
cursor page is
|
|
1327
|
+
its results always include the review projection with `commitOid`, it honors `itemsPerPage` up to its page budget,
|
|
1328
|
+
and one threaded cursor page is one upstream request (two after a gateway timeout) — every relationship × state facet
|
|
1329
|
+
travels in the same query,
|
|
1309
1330
|
unlike the account-wide read, which spends one request per facet per page. So a surface that pages
|
|
1310
1331
|
incrementally should ask the search read for `Reviewed` (and `ReviewRequested` as its own read) rather than
|
|
1311
1332
|
reach for `includeReviews`, which only exists on the all-at-once sweep.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/core-gitlens",
|
|
3
3
|
"description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.37.1",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "GitKraken",
|