@gitkraken/core-gitlens 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -1
- package/dist/git/cache.js +2 -0
- package/dist/git/cache.js.map +1 -1
- package/dist/git/models/issue.d.ts +3 -1
- package/dist/git/models/issue.js.map +1 -1
- package/dist/git/providers/branches.d.ts +4 -2
- package/dist/git/utils/issue.utils.d.ts +3 -1
- package/dist/git/utils/issue.utils.js +5 -1
- package/dist/git/utils/issue.utils.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +20 -9
- package/dist/git/watching/worktreeSummary.js +24 -22
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/providers/branches.js +26 -4
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/plus/integrations/models/gitHostIntegration.js +3 -1
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.js +1 -1
- package/dist/plus/integrations/providers/azure/azure.js +3 -2
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
- package/dist/plus/integrations/providers/azure/models.d.ts +27 -10
- package/dist/plus/integrations/providers/azure/models.js +39 -19
- package/dist/plus/integrations/providers/azure/models.js.map +1 -1
- package/dist/plus/integrations/providers/azure/workItemStateCategories.d.ts +19 -0
- package/dist/plus/integrations/providers/azure/workItemStateCategories.js +32 -0
- package/dist/plus/integrations/providers/azure/workItemStateCategories.js.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.js +5 -5
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
- package/dist/plus/integrations/providers/jira-server.js +11 -5
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +5 -2
- package/dist/plus/integrations/providers/jira.js +45 -30
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +3 -4
- package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -4
- package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
- package/dist/plus/integrations/providers/linearIssuesEtag.d.ts +5 -5
- package/dist/plus/integrations/providers/linearIssuesEtag.js +6 -6
- package/dist/plus/integrations/providers/linearIssuesEtag.js.map +1 -1
- package/dist/plus/integrations/providers/models.d.ts +11 -1
- package/dist/plus/integrations/providers/models.js +9 -9
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +30 -32
- package/dist/plus/integrations/providers/providersApi.js +149 -46
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/providers/utils/jiraIssueDrains.d.ts +27 -15
- package/dist/plus/integrations/providers/utils/jiraIssueDrains.js +72 -10
- package/dist/plus/integrations/providers/utils/jiraIssueDrains.js.map +1 -1
- package/dist/plus/integrations/reads/batchEtags.d.ts +5 -2
- package/dist/plus/integrations/reads/batchEtags.js +31 -10
- package/dist/plus/integrations/reads/batchEtags.js.map +1 -1
- package/dist/plus/integrations/reads/cursors.js +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +0 -1
- package/dist/plus/integrations/reads/hierarchy.js +2 -2
- package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.utils.d.ts +13 -0
- package/dist/plus/integrations/reads/hierarchy.utils.js +26 -1
- package/dist/plus/integrations/reads/hierarchy.utils.js.map +1 -1
- package/dist/plus/integrations/reads/issueTracker.js +4 -4
- package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
- package/dist/plus/integrations/reads/issues.js +1 -1
- package/dist/plus/integrations/reads/pullRequestBranches.js +10 -3
- package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +28 -3
- package/dist/plus/integrations/results.js +22 -3
- package/dist/plus/integrations/results.js.map +1 -1
- package/dist/plus/integrations/utils/integration.utils.d.ts +6 -1
- package/dist/plus/integrations/utils/integration.utils.js +8 -1
- package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
- package/docs/integrations.md +54 -19
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hierarchy.js","names":[],"sources":["../../../../../plus/integrations/src/reads/hierarchy.ts"],"sourcesContent":["import { mapBounded } from '@gitlens/utils/promise.js';\nimport { mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tproviderFanOutConcurrency,\n\tsupportedOrderedCloudIntegrationIds,\n\tsupportedOrderedCloudIssuesIntegrationIds,\n} from '../constants.js';\nimport type { ListOrgsOptions, ListProjectsOptions } from '../manager.js';\nimport { isIssuesIntegration } from '../models/issuesIntegration.js';\nimport type { ProviderHierarchyResult } from '../providers/models.js';\nimport { toProviderRepositoryShape } from '../providers/models.js';\nimport type {\n\tProviderOrganization,\n\tProviderPagedResult,\n\tProviderRepositoryShape,\n\tProviderResult,\n\tProviderWarning,\n} from '../results.js';\nimport { appendDedupedWarning } 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 {\n\tassertHierarchyReadTarget,\n\tmergeHierarchyResults,\n\torgForProject,\n\tresourceMatchesOrg,\n\tresourceToOrg,\n\twithProviderContext,\n} from './hierarchy.utils.js';\nimport { pageToCursor, refusedPage, resolveContinuation, resolveCurrentPage, toProviderPageInfo } from './paging.js';\nimport { gitHostOnlySurfaceWarning, truncationWarning, unsupportedWarning } from './warnings.js';\n\n/**\n * Folds a flat hierarchy result's incompleteness into `warnings`, returning whether it leaves the read\n * non-authoritative. The single funnel for both hierarchy reads, so neither can drift from the other on any of\n * the four decisions it makes:\n *\n * - The metadata is assessed FIRST, so the truncation warning can tell whether it already explained this gap.\n * Ordered deliberately: emitting first meant an expired credential produced BOTH a typed `auth` warning and\n * an unclassifiable one for the same cause, and a consumer routing on classification showed the second as\n * \"this provider failed to load\", with a remedy that doesn't exist, next to the reconnect prompt that was the\n * actual fix.\n * - The read states the truncation itself only when the metadata reported nothing — the rule\n * `assessCollectionMetadata` applies to its own generic fallback. Whatever the metadata reported already names\n * this provider and says something stronger, so restating it costs a false verdict and adds no information.\n * - `'exhausted'`, never `'page-budget'`: `truncated` is one boolean here, so a drain that stopped at its page\n * budget is indistinguishable from one whose cursor stalled, and `IncompleteReadCause` makes `'exhausted'`\n * the default whenever a raisable budget is not demonstrably the cause.\n * - A truncation counts as non-authoritative even though the omission above asserts the read succeeded. Unlike\n * paged repository reads, a flattened hierarchy result has no page object on which to carry incompleteness,\n * so `fetchFailed` is the only signal a consumer has that the list is short.\n */\nfunction mergeHierarchyIncompleteness(\n\twarnings: ProviderWarning[],\n\tid: IntegrationIds,\n\tdomain: string | undefined,\n\tconnectionId: string | undefined,\n\tresult: Pick<ProviderHierarchyResult<unknown>, 'truncated' | 'metadata'>,\n\treadKind: 'Organization' | 'Project',\n): boolean {\n\tconst assessment = mergeAssessmentInto(warnings, id, domain, connectionId, result.metadata);\n\tif (!result.truncated) return assessment.fetchFailed || assessment.truncated;\n\n\tif (!assessment.reported) {\n\t\t// Deduped like every other `truncationWarning` emission (see `drains.ts`), not plain-pushed: no caller can\n\t\t// collide with it today, but nothing about this funnel guarantees a third read won't.\n\t\tappendDedupedWarning(warnings, truncationWarning(id, domain, connectionId, readKind, 'exhausted'));\n\t}\n\treturn true;\n}\n\nexport async function listOrgs(\n\tctx: ProviderReadContext,\n\toptions?: ListOrgsOptions,\n): Promise<ProviderResult<ProviderOrganization>> {\n\tassertHierarchyReadTarget('listOrgs', options);\n\tconst ids = options?.providerId != null ? [options.providerId] : supportedOrderedCloudIntegrationIds;\n\tconst singleProvider = ids.length === 1;\n\tconst connectionId = singleProvider ? options?.connectionId : undefined;\n\tconst requestedDomain = singleProvider ? options?.domain : undefined;\n\n\tconst results = await mapBounded(ids, providerFanOutConcurrency, async id => {\n\t\tconst integration = await ctx.getIntegrationForRead(id, connectionId, requestedDomain);\n\t\tif (integration == null) {\n\t\t\t// A specifically requested connection that can't be resolved is a broken connection, not a\n\t\t\t// provider with no orgs — surface it (warning + fetchFailed) instead of dropping the id\n\t\t\t// silently, so a caller can tell it apart from an account that genuinely has no orgs.\n\t\t\tconst early = ctx.earlyReturnConnectionWarnings(id, connectionId, requestedDomain);\n\t\t\treturn {\n\t\t\t\titems: [] as ProviderOrganization[],\n\t\t\t\twarnings: early.warnings,\n\t\t\t\tfetchFailed: early.fetchFailed,\n\t\t\t};\n\t\t}\n\n\t\tconst items: ProviderOrganization[] = [];\n\t\tconst warnings: ProviderWarning[] = [];\n\t\tlet fetchFailed = false;\n\t\tconst domain = ctx.domainForRead(integration, id, connectionId, requestedDomain);\n\t\tconst warnOnMissingSession = warnOnMissingSessionForDomain(id, requestedDomain);\n\t\tif (isIssuesIntegration(integration)) {\n\t\t\t// Issue trackers expose \"resources\" (Jira sites, Linear orgs, …) as their org analogue.\n\t\t\tconst { value: resources, warning } = await runCaptured(\n\t\t\t\tid,\n\t\t\t\tdomain,\n\t\t\t\tconnectionId,\n\t\t\t\t() => integration.getResourcesForUserResult(connectionId),\n\t\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t\t);\n\t\t\tif (resources != null) {\n\t\t\t\titems.push(...resources.map(r => resourceToOrg(id, r)));\n\t\t\t}\n\t\t\tif (warning != null) {\n\t\t\t\twarnings.push(warning);\n\t\t\t\t// A warning with no value is a hard read failure, not an empty account.\n\t\t\t\tif (resources == null) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!integration.supportsOrganizationDiscovery) {\n\t\t\t// The provider registers no org-discovery hook. Report it as\n\t\t\t// explicitly unsupported rather than contributing a silent empty list that a caller can't\n\t\t\t// tell apart from \"this account has no orgs\".\n\t\t\tfetchFailed = true;\n\t\t\twarnings.push(\n\t\t\t\tunsupportedWarning(id, domain, connectionId, `Organization discovery is not supported by '${id}'.`),\n\t\t\t);\n\t\t} else {\n\t\t\tconst { value, warning } = await runCaptured(\n\t\t\t\tid,\n\t\t\t\tdomain,\n\t\t\t\tconnectionId,\n\t\t\t\t() => integration.getOrganizationsForUserResult(connectionId),\n\t\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t\t);\n\t\t\tif (value != null) {\n\t\t\t\titems.push(...value.values.map(org => withProviderContext(id, org)));\n\n\t\t\t\tif (mergeHierarchyIncompleteness(warnings, id, domain, connectionId, value, 'Organization')) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (warning != null) {\n\t\t\t\twarnings.push(warning);\n\t\t\t\tif (value == null) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed };\n\t});\n\n\treturn mergeHierarchyResults(results);\n}\n\nexport async function listProjects(\n\tctx: ProviderReadContext,\n\toptions?: ListProjectsOptions,\n): Promise<ProviderResult<ProviderOrganization>> {\n\tassertHierarchyReadTarget('listProjects', options);\n\tconst ids =\n\t\toptions?.providerId != null\n\t\t\t? [options.providerId]\n\t\t\t: [\n\t\t\t\t\t...supportedOrderedCloudIssuesIntegrationIds,\n\t\t\t\t\tGitCloudHostIntegrationId.AzureDevOps,\n\t\t\t\t\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n\t\t\t\t];\n\tconst singleProvider = ids.length === 1;\n\tconst connectionId = singleProvider ? options?.connectionId : undefined;\n\tconst requestedDomain = singleProvider ? options?.domain : undefined;\n\n\tconst results = await mapBounded(ids, providerFanOutConcurrency, async id => {\n\t\tconst integration = await ctx.getIntegrationForRead(id, connectionId, requestedDomain);\n\t\tif (integration == null) {\n\t\t\t// A requested connection that can't be resolved is a broken connection, not a provider with\n\t\t\t// no projects — surface it (warning + fetchFailed) instead of dropping the id silently.\n\t\t\tconst early = ctx.earlyReturnConnectionWarnings(id, connectionId, requestedDomain);\n\t\t\treturn {\n\t\t\t\titems: [] as ProviderOrganization[],\n\t\t\t\twarnings: early.warnings,\n\t\t\t\tfetchFailed: early.fetchFailed,\n\t\t\t};\n\t\t}\n\n\t\tconst items: ProviderOrganization[] = [];\n\t\tconst warnings: ProviderWarning[] = [];\n\t\tlet fetchFailed = false;\n\t\tconst domain = ctx.domainForRead(integration, id, connectionId, requestedDomain);\n\t\tconst org = options?.org;\n\t\tconst warnOnMissingSession = warnOnMissingSessionForDomain(id, requestedDomain);\n\n\t\t// Git hosts with a project tier (Azure DevOps) read projects through their own hierarchy hook,\n\t\t// scoped to `org` when given. Non-Azure git hosts have no project tier and return undefined.\n\t\tif (!isIssuesIntegration(integration)) {\n\t\t\t// Check the capability first, like listOrgs/listRepos/listIssuesPage do. Without it, a host\n\t\t\t// with no project tier returns `undefined` from a successful read, which `runCaptured` can't\n\t\t\t// tell apart from an unresolvable session — turning a healthy provider into a `no-connection`\n\t\t\t// warning + `fetchFailed` (and, in Kepler, a spurious reconnect prompt).\n\t\t\tif (!integration.supportsProjectDiscovery) {\n\t\t\t\treturn { items: items, warnings: warnings, fetchFailed: false };\n\t\t\t}\n\n\t\t\tconst { value: projects, warning } = await runCaptured(\n\t\t\t\tid,\n\t\t\t\tdomain,\n\t\t\t\tconnectionId,\n\t\t\t\t() => integration.getProjectsForOrgResult(org, connectionId),\n\t\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t\t);\n\t\t\tif (warning != null) {\n\t\t\t\twarnings.push(warning);\n\t\t\t\tif (projects == null) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (projects != null) {\n\t\t\t\titems.push(...projects.values.map(project => withProviderContext(id, project)));\n\n\t\t\t\tif (mergeHierarchyIncompleteness(warnings, id, domain, connectionId, projects, 'Project')) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed };\n\t\t}\n\n\t\tconst { value: resources, warning: resourcesWarning } = await runCaptured(\n\t\t\tid,\n\t\t\tdomain,\n\t\t\tconnectionId,\n\t\t\t() => integration.getResourcesForUserResult(connectionId),\n\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t);\n\t\tif (resourcesWarning != null) {\n\t\t\twarnings.push(resourcesWarning);\n\t\t\tif (resources == null) {\n\t\t\t\tfetchFailed = true;\n\t\t\t}\n\t\t}\n\n\t\tconst scopedResources =\n\t\t\torg != null ? resources?.filter(resource => resourceMatchesOrg(resource, org)) : resources;\n\t\tif (scopedResources != null && scopedResources.length !== 0) {\n\t\t\tconst { value: projects, warning: projectsWarning } = await runCaptured(id, domain, connectionId, () =>\n\t\t\t\tintegration.getProjectsForResourcesWithMetadataResult(scopedResources, connectionId),\n\t\t\t);\n\t\t\tif (projectsWarning != null) {\n\t\t\t\twarnings.push(projectsWarning);\n\t\t\t\tif (projects == null) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (projects != null) {\n\t\t\t\titems.push(\n\t\t\t\t\t...projects.values.map(project =>\n\t\t\t\t\t\tresourceToOrg(id, project, orgForProject(id, project, scopedResources)),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst assessment = mergeAssessmentInto(warnings, id, domain, connectionId, projects?.metadata);\n\t\t\tif (assessment.fetchFailed || assessment.truncated) {\n\t\t\t\tfetchFailed = true;\n\t\t\t}\n\t\t}\n\n\t\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed };\n\t});\n\n\treturn mergeHierarchyResults(results);\n}\n\nexport async function listRepos(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\torg?: string;\n\t\tproject?: string;\n\t\tpage?: number;\n\t\tcursor?: string;\n\t\titemsPerPage?: number;\n\t\tconnectionId?: string;\n\t\tdomain?: string;\n\t},\n): Promise<ProviderPagedResult<ProviderRepositoryShape>> {\n\t// Truncated as well as floored, like every other paged read here: `page` is reported back as\n\t// `page.currentPage` and bounds the cursor walk below, and neither can be fractional.\n\tconst page = Math.max(1, Math.trunc(options.page ?? 1));\n\tif (isIssuesHostIntegrationId(options.providerId)) {\n\t\treturn refusedPage(\n\t\t\tpage,\n\t\t\t[gitHostOnlySurfaceWarning(options.providerId, undefined, options.connectionId, 'repository discovery')],\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\tif (integration == null) {\n\t\t// A supplied connection or domain that no longer resolves is a broken target, not an empty account —\n\t\t// surface a no-connection warning + fetchFailed rather than a silent empty page.\n\t\tconst early = ctx.earlyReturnConnectionWarnings(options.providerId, options.connectionId, options.domain);\n\t\treturn refusedPage(page, early.warnings, early.fetchFailed);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn refusedPage(\n\t\t\tpage,\n\t\t\t[gitHostOnlySurfaceWarning(options.providerId, undefined, options.connectionId, 'repository discovery')],\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\n\tconst accountWide = options.org == null;\n\tconst supported = accountWide\n\t\t? integration.supportsUserRepositoryDiscovery\n\t\t: integration.supportsRepositoryDiscovery;\n\tif (!supported) {\n\t\t// No matching repo-discovery hook — org-scoped (e.g. Bitbucket Data Center) or account-wide (e.g.\n\t\t// Bitbucket/Azure, whose repos can only be walked per workspace/org). Report unsupported rather than\n\t\t// a silent empty page indistinguishable from \"no repos\"; for the account-wide case the caller should\n\t\t// fan out per org from listOrgs instead.\n\t\treturn refusedPage(\n\t\t\tpage,\n\t\t\t[\n\t\t\t\tunsupportedWarning(\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\taccountWide\n\t\t\t\t\t\t? `Account-wide repository discovery is not supported by '${options.providerId}'; list repositories per org instead.`\n\t\t\t\t\t\t: `Repository discovery is not supported by '${options.providerId}'.`,\n\t\t\t\t),\n\t\t\t],\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tconst org = options.org;\n\tconst warnOnMissingSession = warnOnMissingSessionForDomain(options.providerId, options.domain);\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\torg == null\n\t\t\t\t\t? integration.getRepositoriesForUserResult({ cursor: cursor, connectionId: options.connectionId })\n\t\t\t\t\t: integration.getRepositoriesForOrgResult(org, {\n\t\t\t\t\t\t\tproject: options.project,\n\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\t\t\t}),\n\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t);\n\n\t/**\n\t * Builds one page's result from what the provider returned. Shared by the initial read and by every round of\n\t * the cursor walk below, so a walked page N is described by exactly the same rules as a directly-requested one\n\t * (position, continuation, truncation) rather than by a second copy of them.\n\t */\n\tconst toResult = (\n\t\t{ value, warning }: Awaited<ReturnType<typeof readPage>>,\n\t\trequestedPage: number,\n\t\tsuppliedCursor: string | undefined,\n\t): ProviderPagedResult<ProviderRepositoryShape> => {\n\t\tconst items = value?.values ?? [];\n\t\tconst warnings = warning != null ? [warning] : [];\n\t\t// The repos read core is cursor-only and can't accept a page size, so don't echo the requested\n\t\t// `itemsPerPage` as if it were applied — report what the provider returned (its own pageSize when\n\t\t// available, else the actual item count).\n\t\tconst paged = toProviderPageInfo(items.length, value?.paging);\n\t\t// Convert the SDK collection metadata into scope-aware warnings + failure/truncation flags, appending\n\t\t// them to any captured thrown-error warning without discarding the partial result's items.\n\t\tconst assessment = mergeAssessmentInto(\n\t\t\twarnings,\n\t\t\toptions.providerId,\n\t\t\tdomain,\n\t\t\toptions.connectionId,\n\t\t\tvalue?.metadata,\n\t\t);\n\t\t// Whether this read honors a page NUMBER, decided from what the provider actually reported rather than\n\t\t// guessed from the absence of a cursor. A numbered-page repos host reports its position (`paging.page`)\n\t\t// and/or its successor (`paging.nextPage`) — Bitbucket's workspace walk consumes `page` as a real 1-based\n\t\t// page and reports `nextPage` without echoing `currentPage`, so both signals have to count. Every wired\n\t\t// cursor-based repos read (GitHub's org/user walks, GitLab's user walk, Bitbucket's cursor read) reports\n\t\t// neither. Keying off `paged.cursor == null` instead read the paging layer's \"reported another page,\n\t\t// handed back no continuation\" sentinel as evidence of a numbered host, which is exactly backwards.\n\t\tconst pageAdvanceable = value?.paging?.page != null || value?.paging?.nextPage != null;\n\t\t// Numbered-page hosts that don't echo `currentPage` may still be advanced by the requested `page` (initial\n\t\t// read) or by the cursor the caller threaded back. A cursor-only host ignores an UNTHREADED `page`\n\t\t// request, so its page-less first page is page 1.\n\t\tconst currentPage = resolveCurrentPage({\n\t\t\tproviderPage: paged.page.currentPage,\n\t\t\trequestedPage: requestedPage,\n\t\t\tsuppliedCursor: suppliedCursor,\n\t\t\tpageAdvanceable: pageAdvanceable,\n\t\t});\n\t\t// Never advertise `hasMore` without a continuation the caller can act on — the same contract\n\t\t// `listPullRequestsPage`, `listIssuesPage` and `broadenIssues` hold, via the same helper. A provider that\n\t\t// reports another page but hands back neither `endCursor` nor `nextPage` (surfaced as the `'{}'` sentinel,\n\t\t// which `toProviderPageInfo` drops) is terminal-but-incomplete: `hasMore: false` + `page.truncated`.\n\t\t// Synthesizing a page-number cursor for a cursor-only host instead — which is what this read used to do\n\t\t// unconditionally — handed back a continuation the provider ignores, so it answered with its FIRST page\n\t\t// again while still reporting `hasMore: true`. A consumer draining until `hasMore` clears (Kepler's repo\n\t\t// drain does exactly that) then looped to its own page cap, accumulating a duplicate copy of every repo\n\t\t// per round, and never saw a truncation signal.\n\t\tconst continuation = resolveContinuation(paged, pageAdvanceable ? currentPage + 1 : undefined);\n\t\t// The org-hierarchy read can also stop at a defensive backstop with more repos unlisted and no cursor to\n\t\t// resume (top-level `truncated`, or `paging.truncated` on a single-page read). Metadata incompleteness and\n\t\t// a demoted continuation are two further, independent sources of the same signal.\n\t\tconst truncated =\n\t\t\t(value?.truncated ?? false) ||\n\t\t\t(value?.paging?.truncated ?? false) ||\n\t\t\tassessment.truncated ||\n\t\t\tcontinuation.truncated;\n\t\treturn {\n\t\t\t// Normalize the raw provider-apis repos to the GitLens-owned shape at the surface boundary.\n\t\t\titems: items.map(toProviderRepositoryShape),\n\t\t\twarnings: warnings,\n\t\t\tpage: { ...paged.page, currentPage: currentPage, truncated: truncated || undefined },\n\t\t\thasMore: continuation.hasMore,\n\t\t\tcursor: continuation.cursor,\n\t\t\tfetchFailed: assessment.fetchFailed || (warning != null && value == null) || undefined,\n\t\t};\n\t};\n\n\tconst first = await readPage(\n\t\toptions.cursor ??\n\t\t\t(integration.id === GitSelfManagedHostIntegrationId.BitbucketServer ? undefined : pageToCursor(page)),\n\t);\n\tconst result = toResult(first, page, options.cursor);\n\t// A numbered-page host honored the synthesized cursor, so this IS page N; a cursor-only host ignored it and\n\t// answered with page 1, which the walk below advances. Decided from the provider's own paging metadata rather\n\t// than assumed, hence after the read.\n\tconst pageAdvanceable = first.value?.paging?.page != null || first.value?.paging?.nextPage != null;\n\tif (options.cursor != null || page === 1 || pageAdvanceable) return result;\n\n\t// Walk the provider's real continuations to the requested page. Only the last page's items are kept — pages\n\t// 1..N returned as \"page N\" would duplicate items for a normal paged consumer — while warnings, truncation,\n\t// and failure accumulate across the whole walked prefix, since an earlier round's problem still means this\n\t// result isn't authoritative. The provider read is re-issued per round, but the integration is resolved once:\n\t// re-entering this function per page would repeat its auth resolution N times for page N.\n\tconst walkedWarnings = [...result.warnings];\n\tlet walkedFetchFailed = result.fetchFailed === true;\n\tlet walkedTruncated = result.page.truncated === true;\n\tlet previous = result;\n\tfor (let currentPage = 2; currentPage <= page; currentPage++) {\n\t\tif (!previous.hasMore || previous.cursor == null) {\n\t\t\t// The requested page lies past the provider's terminal cursor: an EMPTY page N, never the last\n\t\t\t// available page relabeled (see ProviderPageInfo.currentPage).\n\t\t\treturn {\n\t\t\t\titems: [],\n\t\t\t\twarnings: walkedWarnings,\n\t\t\t\tpage: { currentPage: page, itemsPerPage: 0, truncated: walkedTruncated || undefined },\n\t\t\t\thasMore: false,\n\t\t\t\tfetchFailed: walkedFetchFailed || undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst suppliedCursor = previous.cursor;\n\t\tconst requested = toResult(await readPage(suppliedCursor), currentPage, suppliedCursor);\n\t\tfor (const warning of requested.warnings) {\n\t\t\tappendDedupedWarning(walkedWarnings, warning);\n\t\t}\n\t\twalkedFetchFailed ||= requested.fetchFailed === true;\n\t\twalkedTruncated ||= requested.page.truncated === true;\n\t\tif (currentPage === page) {\n\t\t\treturn {\n\t\t\t\t...requested,\n\t\t\t\twarnings: walkedWarnings,\n\t\t\t\tpage: { ...requested.page, truncated: walkedTruncated || undefined },\n\t\t\t\tfetchFailed: walkedFetchFailed || undefined,\n\t\t\t};\n\t\t}\n\n\t\tprevious = requested;\n\t}\n\n\treturn result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAS,6BACR,UACA,IACA,QACA,cACA,QACA,UACU;CACV,MAAM,aAAa,oBAAoB,UAAU,IAAI,QAAQ,cAAc,OAAO,QAAQ;CAC1F,IAAI,CAAC,OAAO,WAAW,OAAO,WAAW,eAAe,WAAW;CAEnE,IAAI,CAAC,WAAW,UAGf,qBAAqB,UAAU,kBAAkB,IAAI,QAAQ,cAAc,UAAU,WAAW,CAAC;CAElG,OAAO;AACR;AAEA,eAAsB,SACrB,KACA,SACgD;CAChD,0BAA0B,YAAY,OAAO;CAC7C,MAAM,MAAM,SAAS,cAAc,OAAO,CAAC,QAAQ,UAAU,IAAI;CACjE,MAAM,iBAAiB,IAAI,WAAW;CAC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AAA;GAAU;GACpF,SAAS;GACT,aAAa,qBAAqB,KAAA;EACnC;EAGD,MAAM,iBAAiB,SAAS;EAChC,MAAM,YAAY,SAAS,MAAM,SAAS,cAAc,GAAG,aAAa,cAAc;EACtF,KAAK,MAAM,WAAW,UAAU,UAC/B,qBAAqB,gBAAgB,OAAO;EAE7C,sBAAsB,UAAU,gBAAgB;EAChD,oBAAoB,UAAU,KAAK,cAAc;EACjD,IAAI,gBAAgB,MACnB,OAAO;GACN,GAAG;GACH,UAAU;GACV,MAAM;IAAE,GAAG,UAAU;IAAM,WAAW,mBAAmB,KAAA;GAAU;GACnE,aAAa,qBAAqB,KAAA;EACnC;EAGD,WAAW;CACZ;CAEA,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"hierarchy.js","names":[],"sources":["../../../../../plus/integrations/src/reads/hierarchy.ts"],"sourcesContent":["import { mapBounded } from '@gitlens/utils/promise.js';\nimport { mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tproviderFanOutConcurrency,\n\tsupportedOrderedCloudIntegrationIds,\n\tsupportedOrderedCloudIssuesIntegrationIds,\n} from '../constants.js';\nimport type { ListOrgsOptions, ListProjectsOptions } from '../manager.js';\nimport { isIssuesIntegration } from '../models/issuesIntegration.js';\nimport type { ProviderHierarchyResult } from '../providers/models.js';\nimport { toProviderRepositoryShape } from '../providers/models.js';\nimport type {\n\tProviderOrganization,\n\tProviderPagedResult,\n\tProviderRepositoryShape,\n\tProviderResult,\n\tProviderWarning,\n} from '../results.js';\nimport { appendDedupedWarning } 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 {\n\tassertHierarchyReadTarget,\n\tmergeHierarchyResults,\n\tprojectToOrg,\n\tresourceMatchesOrg,\n\tresourceToOrg,\n\twithProviderContext,\n} from './hierarchy.utils.js';\nimport { pageToCursor, refusedPage, resolveContinuation, resolveCurrentPage, toProviderPageInfo } from './paging.js';\nimport { gitHostOnlySurfaceWarning, truncationWarning, unsupportedWarning } from './warnings.js';\n\n/**\n * Folds a flat hierarchy result's incompleteness into `warnings`, returning whether it leaves the read\n * non-authoritative. The single funnel for both hierarchy reads, so neither can drift from the other on any of\n * the four decisions it makes:\n *\n * - The metadata is assessed FIRST, so the truncation warning can tell whether it already explained this gap.\n * Ordered deliberately: emitting first meant an expired credential produced BOTH a typed `auth` warning and\n * an unclassifiable one for the same cause, and a consumer routing on classification showed the second as\n * \"this provider failed to load\", with a remedy that doesn't exist, next to the reconnect prompt that was the\n * actual fix.\n * - The read states the truncation itself only when the metadata reported nothing — the rule\n * `assessCollectionMetadata` applies to its own generic fallback. Whatever the metadata reported already names\n * this provider and says something stronger, so restating it costs a false verdict and adds no information.\n * - `'exhausted'`, never `'page-budget'`: `truncated` is one boolean here, so a drain that stopped at its page\n * budget is indistinguishable from one whose cursor stalled, and `IncompleteReadCause` makes `'exhausted'`\n * the default whenever a raisable budget is not demonstrably the cause.\n * - A truncation counts as non-authoritative even though the omission above asserts the read succeeded. Unlike\n * paged repository reads, a flattened hierarchy result has no page object on which to carry incompleteness,\n * so `fetchFailed` is the only signal a consumer has that the list is short.\n */\nfunction mergeHierarchyIncompleteness(\n\twarnings: ProviderWarning[],\n\tid: IntegrationIds,\n\tdomain: string | undefined,\n\tconnectionId: string | undefined,\n\tresult: Pick<ProviderHierarchyResult<unknown>, 'truncated' | 'metadata'>,\n\treadKind: 'Organization' | 'Project',\n): boolean {\n\tconst assessment = mergeAssessmentInto(warnings, id, domain, connectionId, result.metadata);\n\tif (!result.truncated) return assessment.fetchFailed || assessment.truncated;\n\n\tif (!assessment.reported) {\n\t\t// Deduped like every other `truncationWarning` emission (see `drains.ts`), not plain-pushed: no caller can\n\t\t// collide with it today, but nothing about this funnel guarantees a third read won't.\n\t\tappendDedupedWarning(warnings, truncationWarning(id, domain, connectionId, readKind, 'exhausted'));\n\t}\n\treturn true;\n}\n\nexport async function listOrgs(\n\tctx: ProviderReadContext,\n\toptions?: ListOrgsOptions,\n): Promise<ProviderResult<ProviderOrganization>> {\n\tassertHierarchyReadTarget('listOrgs', options);\n\tconst ids = options?.providerId != null ? [options.providerId] : supportedOrderedCloudIntegrationIds;\n\tconst singleProvider = ids.length === 1;\n\tconst connectionId = singleProvider ? options?.connectionId : undefined;\n\tconst requestedDomain = singleProvider ? options?.domain : undefined;\n\n\tconst results = await mapBounded(ids, providerFanOutConcurrency, async id => {\n\t\tconst integration = await ctx.getIntegrationForRead(id, connectionId, requestedDomain);\n\t\tif (integration == null) {\n\t\t\t// A specifically requested connection that can't be resolved is a broken connection, not a\n\t\t\t// provider with no orgs — surface it (warning + fetchFailed) instead of dropping the id\n\t\t\t// silently, so a caller can tell it apart from an account that genuinely has no orgs.\n\t\t\tconst early = ctx.earlyReturnConnectionWarnings(id, connectionId, requestedDomain);\n\t\t\treturn {\n\t\t\t\titems: [] as ProviderOrganization[],\n\t\t\t\twarnings: early.warnings,\n\t\t\t\tfetchFailed: early.fetchFailed,\n\t\t\t};\n\t\t}\n\n\t\tconst items: ProviderOrganization[] = [];\n\t\tconst warnings: ProviderWarning[] = [];\n\t\tlet fetchFailed = false;\n\t\tconst domain = ctx.domainForRead(integration, id, connectionId, requestedDomain);\n\t\tconst warnOnMissingSession = warnOnMissingSessionForDomain(id, requestedDomain);\n\t\tif (isIssuesIntegration(integration)) {\n\t\t\t// Issue trackers expose \"resources\" (Jira sites, Linear orgs, …) as their org analogue.\n\t\t\tconst { value: resources, warning } = await runCaptured(\n\t\t\t\tid,\n\t\t\t\tdomain,\n\t\t\t\tconnectionId,\n\t\t\t\t() => integration.getResourcesForUserResult(connectionId),\n\t\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t\t);\n\t\t\tif (resources != null) {\n\t\t\t\titems.push(...resources.map(r => resourceToOrg(id, r)));\n\t\t\t}\n\t\t\tif (warning != null) {\n\t\t\t\twarnings.push(warning);\n\t\t\t\t// A warning with no value is a hard read failure, not an empty account.\n\t\t\t\tif (resources == null) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (!integration.supportsOrganizationDiscovery) {\n\t\t\t// The provider registers no org-discovery hook. Report it as\n\t\t\t// explicitly unsupported rather than contributing a silent empty list that a caller can't\n\t\t\t// tell apart from \"this account has no orgs\".\n\t\t\tfetchFailed = true;\n\t\t\twarnings.push(\n\t\t\t\tunsupportedWarning(id, domain, connectionId, `Organization discovery is not supported by '${id}'.`),\n\t\t\t);\n\t\t} else {\n\t\t\tconst { value, warning } = await runCaptured(\n\t\t\t\tid,\n\t\t\t\tdomain,\n\t\t\t\tconnectionId,\n\t\t\t\t() => integration.getOrganizationsForUserResult(connectionId),\n\t\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t\t);\n\t\t\tif (value != null) {\n\t\t\t\titems.push(...value.values.map(org => withProviderContext(id, org)));\n\n\t\t\t\tif (mergeHierarchyIncompleteness(warnings, id, domain, connectionId, value, 'Organization')) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (warning != null) {\n\t\t\t\twarnings.push(warning);\n\t\t\t\tif (value == null) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed };\n\t});\n\n\treturn mergeHierarchyResults(results);\n}\n\nexport async function listProjects(\n\tctx: ProviderReadContext,\n\toptions?: ListProjectsOptions,\n): Promise<ProviderResult<ProviderOrganization>> {\n\tassertHierarchyReadTarget('listProjects', options);\n\tconst ids =\n\t\toptions?.providerId != null\n\t\t\t? [options.providerId]\n\t\t\t: [\n\t\t\t\t\t...supportedOrderedCloudIssuesIntegrationIds,\n\t\t\t\t\tGitCloudHostIntegrationId.AzureDevOps,\n\t\t\t\t\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n\t\t\t\t];\n\tconst singleProvider = ids.length === 1;\n\tconst connectionId = singleProvider ? options?.connectionId : undefined;\n\tconst requestedDomain = singleProvider ? options?.domain : undefined;\n\n\tconst results = await mapBounded(ids, providerFanOutConcurrency, async id => {\n\t\tconst integration = await ctx.getIntegrationForRead(id, connectionId, requestedDomain);\n\t\tif (integration == null) {\n\t\t\t// A requested connection that can't be resolved is a broken connection, not a provider with\n\t\t\t// no projects — surface it (warning + fetchFailed) instead of dropping the id silently.\n\t\t\tconst early = ctx.earlyReturnConnectionWarnings(id, connectionId, requestedDomain);\n\t\t\treturn {\n\t\t\t\titems: [] as ProviderOrganization[],\n\t\t\t\twarnings: early.warnings,\n\t\t\t\tfetchFailed: early.fetchFailed,\n\t\t\t};\n\t\t}\n\n\t\tconst items: ProviderOrganization[] = [];\n\t\tconst warnings: ProviderWarning[] = [];\n\t\tlet fetchFailed = false;\n\t\tconst domain = ctx.domainForRead(integration, id, connectionId, requestedDomain);\n\t\tconst org = options?.org;\n\t\tconst warnOnMissingSession = warnOnMissingSessionForDomain(id, requestedDomain);\n\n\t\t// Git hosts with a project tier (Azure DevOps) read projects through their own hierarchy hook,\n\t\t// scoped to `org` when given. Non-Azure git hosts have no project tier and return undefined.\n\t\tif (!isIssuesIntegration(integration)) {\n\t\t\t// Check the capability first, like listOrgs/listRepos/listIssuesPage do. Without it, a host\n\t\t\t// with no project tier returns `undefined` from a successful read, which `runCaptured` can't\n\t\t\t// tell apart from an unresolvable session — turning a healthy provider into a `no-connection`\n\t\t\t// warning + `fetchFailed` (and, in Kepler, a spurious reconnect prompt).\n\t\t\tif (!integration.supportsProjectDiscovery) {\n\t\t\t\treturn { items: items, warnings: warnings, fetchFailed: false };\n\t\t\t}\n\n\t\t\tconst { value: projects, warning } = await runCaptured(\n\t\t\t\tid,\n\t\t\t\tdomain,\n\t\t\t\tconnectionId,\n\t\t\t\t() => integration.getProjectsForOrgResult(org, connectionId),\n\t\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t\t);\n\t\t\tif (warning != null) {\n\t\t\t\twarnings.push(warning);\n\t\t\t\tif (projects == null) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (projects != null) {\n\t\t\t\titems.push(...projects.values.map(project => withProviderContext(id, project)));\n\n\t\t\t\tif (mergeHierarchyIncompleteness(warnings, id, domain, connectionId, projects, 'Project')) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed };\n\t\t}\n\n\t\tconst { value: resources, warning: resourcesWarning } = await runCaptured(\n\t\t\tid,\n\t\t\tdomain,\n\t\t\tconnectionId,\n\t\t\t() => integration.getResourcesForUserResult(connectionId),\n\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t);\n\t\tif (resourcesWarning != null) {\n\t\t\twarnings.push(resourcesWarning);\n\t\t\tif (resources == null) {\n\t\t\t\tfetchFailed = true;\n\t\t\t}\n\t\t}\n\n\t\t// By any identifier, unlike the issue reads' `selectorMatches`: this lists what the caller can then select, so a\n\t\t// match through a name shows the user those projects rather than silently reading another backlog.\n\t\tconst scopedResources =\n\t\t\torg != null ? resources?.filter(resource => resourceMatchesOrg(resource, org)) : resources;\n\t\tif (scopedResources != null && scopedResources.length !== 0) {\n\t\t\tconst { value: projects, warning: projectsWarning } = await runCaptured(id, domain, connectionId, () =>\n\t\t\t\tintegration.getProjectsForResourcesWithMetadataResult(scopedResources, connectionId),\n\t\t\t);\n\t\t\tif (projectsWarning != null) {\n\t\t\t\twarnings.push(projectsWarning);\n\t\t\t\tif (projects == null) {\n\t\t\t\t\tfetchFailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (projects != null) {\n\t\t\t\titems.push(...projects.values.map(project => projectToOrg(id, project, scopedResources)));\n\t\t\t}\n\t\t\tconst assessment = mergeAssessmentInto(warnings, id, domain, connectionId, projects?.metadata);\n\t\t\tif (assessment.fetchFailed || assessment.truncated) {\n\t\t\t\tfetchFailed = true;\n\t\t\t}\n\t\t}\n\n\t\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed };\n\t});\n\n\treturn mergeHierarchyResults(results);\n}\n\nexport async function listRepos(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\torg?: string;\n\t\tproject?: string;\n\t\tpage?: number;\n\t\tcursor?: string;\n\t\titemsPerPage?: number;\n\t\tconnectionId?: string;\n\t\tdomain?: string;\n\t},\n): Promise<ProviderPagedResult<ProviderRepositoryShape>> {\n\t// Truncated as well as floored, like every other paged read here: `page` is reported back as\n\t// `page.currentPage` and bounds the cursor walk below, and neither can be fractional.\n\tconst page = Math.max(1, Math.trunc(options.page ?? 1));\n\tif (isIssuesHostIntegrationId(options.providerId)) {\n\t\treturn refusedPage(\n\t\t\tpage,\n\t\t\t[gitHostOnlySurfaceWarning(options.providerId, undefined, options.connectionId, 'repository discovery')],\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\tif (integration == null) {\n\t\t// A supplied connection or domain that no longer resolves is a broken target, not an empty account —\n\t\t// surface a no-connection warning + fetchFailed rather than a silent empty page.\n\t\tconst early = ctx.earlyReturnConnectionWarnings(options.providerId, options.connectionId, options.domain);\n\t\treturn refusedPage(page, early.warnings, early.fetchFailed);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn refusedPage(\n\t\t\tpage,\n\t\t\t[gitHostOnlySurfaceWarning(options.providerId, undefined, options.connectionId, 'repository discovery')],\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\n\tconst accountWide = options.org == null;\n\tconst supported = accountWide\n\t\t? integration.supportsUserRepositoryDiscovery\n\t\t: integration.supportsRepositoryDiscovery;\n\tif (!supported) {\n\t\t// No matching repo-discovery hook — org-scoped (e.g. Bitbucket Data Center) or account-wide (e.g.\n\t\t// Bitbucket/Azure, whose repos can only be walked per workspace/org). Report unsupported rather than\n\t\t// a silent empty page indistinguishable from \"no repos\"; for the account-wide case the caller should\n\t\t// fan out per org from listOrgs instead.\n\t\treturn refusedPage(\n\t\t\tpage,\n\t\t\t[\n\t\t\t\tunsupportedWarning(\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\taccountWide\n\t\t\t\t\t\t? `Account-wide repository discovery is not supported by '${options.providerId}'; list repositories per org instead.`\n\t\t\t\t\t\t: `Repository discovery is not supported by '${options.providerId}'.`,\n\t\t\t\t),\n\t\t\t],\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tconst org = options.org;\n\tconst warnOnMissingSession = warnOnMissingSessionForDomain(options.providerId, options.domain);\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\torg == null\n\t\t\t\t\t? integration.getRepositoriesForUserResult({ cursor: cursor, connectionId: options.connectionId })\n\t\t\t\t\t: integration.getRepositoriesForOrgResult(org, {\n\t\t\t\t\t\t\tproject: options.project,\n\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t\tconnectionId: options.connectionId,\n\t\t\t\t\t\t}),\n\t\t\t{ warnOnMissingSession: warnOnMissingSession },\n\t\t);\n\n\t/**\n\t * Builds one page's result from what the provider returned. Shared by the initial read and by every round of\n\t * the cursor walk below, so a walked page N is described by exactly the same rules as a directly-requested one\n\t * (position, continuation, truncation) rather than by a second copy of them.\n\t */\n\tconst toResult = (\n\t\t{ value, warning }: Awaited<ReturnType<typeof readPage>>,\n\t\trequestedPage: number,\n\t\tsuppliedCursor: string | undefined,\n\t): ProviderPagedResult<ProviderRepositoryShape> => {\n\t\tconst items = value?.values ?? [];\n\t\tconst warnings = warning != null ? [warning] : [];\n\t\t// The repos read core is cursor-only and can't accept a page size, so don't echo the requested\n\t\t// `itemsPerPage` as if it were applied — report what the provider returned (its own pageSize when\n\t\t// available, else the actual item count).\n\t\tconst paged = toProviderPageInfo(items.length, value?.paging);\n\t\t// Convert the SDK collection metadata into scope-aware warnings + failure/truncation flags, appending\n\t\t// them to any captured thrown-error warning without discarding the partial result's items.\n\t\tconst assessment = mergeAssessmentInto(\n\t\t\twarnings,\n\t\t\toptions.providerId,\n\t\t\tdomain,\n\t\t\toptions.connectionId,\n\t\t\tvalue?.metadata,\n\t\t);\n\t\t// Whether this read honors a page NUMBER, decided from what the provider actually reported rather than\n\t\t// guessed from the absence of a cursor. A numbered-page repos host reports its position (`paging.page`)\n\t\t// and/or its successor (`paging.nextPage`) — Bitbucket's workspace walk consumes `page` as a real 1-based\n\t\t// page and reports `nextPage` without echoing `currentPage`, so both signals have to count. Every wired\n\t\t// cursor-based repos read (GitHub's org/user walks, GitLab's user walk, Bitbucket's cursor read) reports\n\t\t// neither. Keying off `paged.cursor == null` instead read the paging layer's \"reported another page,\n\t\t// handed back no continuation\" sentinel as evidence of a numbered host, which is exactly backwards.\n\t\tconst pageAdvanceable = value?.paging?.page != null || value?.paging?.nextPage != null;\n\t\t// Numbered-page hosts that don't echo `currentPage` may still be advanced by the requested `page` (initial\n\t\t// read) or by the cursor the caller threaded back. A cursor-only host ignores an UNTHREADED `page`\n\t\t// request, so its page-less first page is page 1.\n\t\tconst currentPage = resolveCurrentPage({\n\t\t\tproviderPage: paged.page.currentPage,\n\t\t\trequestedPage: requestedPage,\n\t\t\tsuppliedCursor: suppliedCursor,\n\t\t\tpageAdvanceable: pageAdvanceable,\n\t\t});\n\t\t// Never advertise `hasMore` without a continuation the caller can act on — the same contract\n\t\t// `listPullRequestsPage`, `listIssuesPage` and `broadenIssues` hold, via the same helper. A provider that\n\t\t// reports another page but hands back neither `endCursor` nor `nextPage` (surfaced as the `'{}'` sentinel,\n\t\t// which `toProviderPageInfo` drops) is terminal-but-incomplete: `hasMore: false` + `page.truncated`.\n\t\t// Synthesizing a page-number cursor for a cursor-only host instead — which is what this read used to do\n\t\t// unconditionally — handed back a continuation the provider ignores, so it answered with its FIRST page\n\t\t// again while still reporting `hasMore: true`. A consumer draining until `hasMore` clears (Kepler's repo\n\t\t// drain does exactly that) then looped to its own page cap, accumulating a duplicate copy of every repo\n\t\t// per round, and never saw a truncation signal.\n\t\tconst continuation = resolveContinuation(paged, pageAdvanceable ? currentPage + 1 : undefined);\n\t\t// The org-hierarchy read can also stop at a defensive backstop with more repos unlisted and no cursor to\n\t\t// resume (top-level `truncated`, or `paging.truncated` on a single-page read). Metadata incompleteness and\n\t\t// a demoted continuation are two further, independent sources of the same signal.\n\t\tconst truncated =\n\t\t\t(value?.truncated ?? false) ||\n\t\t\t(value?.paging?.truncated ?? false) ||\n\t\t\tassessment.truncated ||\n\t\t\tcontinuation.truncated;\n\t\treturn {\n\t\t\t// Normalize the raw provider-apis repos to the GitLens-owned shape at the surface boundary.\n\t\t\titems: items.map(toProviderRepositoryShape),\n\t\t\twarnings: warnings,\n\t\t\tpage: { ...paged.page, currentPage: currentPage, truncated: truncated || undefined },\n\t\t\thasMore: continuation.hasMore,\n\t\t\tcursor: continuation.cursor,\n\t\t\tfetchFailed: assessment.fetchFailed || (warning != null && value == null) || undefined,\n\t\t};\n\t};\n\n\tconst first = await readPage(\n\t\toptions.cursor ??\n\t\t\t(integration.id === GitSelfManagedHostIntegrationId.BitbucketServer ? undefined : pageToCursor(page)),\n\t);\n\tconst result = toResult(first, page, options.cursor);\n\t// A numbered-page host honored the synthesized cursor, so this IS page N; a cursor-only host ignored it and\n\t// answered with page 1, which the walk below advances. Decided from the provider's own paging metadata rather\n\t// than assumed, hence after the read.\n\tconst pageAdvanceable = first.value?.paging?.page != null || first.value?.paging?.nextPage != null;\n\tif (options.cursor != null || page === 1 || pageAdvanceable) return result;\n\n\t// Walk the provider's real continuations to the requested page. Only the last page's items are kept — pages\n\t// 1..N returned as \"page N\" would duplicate items for a normal paged consumer — while warnings, truncation,\n\t// and failure accumulate across the whole walked prefix, since an earlier round's problem still means this\n\t// result isn't authoritative. The provider read is re-issued per round, but the integration is resolved once:\n\t// re-entering this function per page would repeat its auth resolution N times for page N.\n\tconst walkedWarnings = [...result.warnings];\n\tlet walkedFetchFailed = result.fetchFailed === true;\n\tlet walkedTruncated = result.page.truncated === true;\n\tlet previous = result;\n\tfor (let currentPage = 2; currentPage <= page; currentPage++) {\n\t\tif (!previous.hasMore || previous.cursor == null) {\n\t\t\t// The requested page lies past the provider's terminal cursor: an EMPTY page N, never the last\n\t\t\t// available page relabeled (see ProviderPageInfo.currentPage).\n\t\t\treturn {\n\t\t\t\titems: [],\n\t\t\t\twarnings: walkedWarnings,\n\t\t\t\tpage: { currentPage: page, itemsPerPage: 0, truncated: walkedTruncated || undefined },\n\t\t\t\thasMore: false,\n\t\t\t\tfetchFailed: walkedFetchFailed || undefined,\n\t\t\t};\n\t\t}\n\n\t\tconst suppliedCursor = previous.cursor;\n\t\tconst requested = toResult(await readPage(suppliedCursor), currentPage, suppliedCursor);\n\t\tfor (const warning of requested.warnings) {\n\t\t\tappendDedupedWarning(walkedWarnings, warning);\n\t\t}\n\t\twalkedFetchFailed ||= requested.fetchFailed === true;\n\t\twalkedTruncated ||= requested.page.truncated === true;\n\t\tif (currentPage === page) {\n\t\t\treturn {\n\t\t\t\t...requested,\n\t\t\t\twarnings: walkedWarnings,\n\t\t\t\tpage: { ...requested.page, truncated: walkedTruncated || undefined },\n\t\t\t\tfetchFailed: walkedFetchFailed || undefined,\n\t\t\t};\n\t\t}\n\n\t\tprevious = requested;\n\t}\n\n\treturn result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAS,6BACR,UACA,IACA,QACA,cACA,QACA,UACU;CACV,MAAM,aAAa,oBAAoB,UAAU,IAAI,QAAQ,cAAc,OAAO,QAAQ;CA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,OAAO,QAAQ;CAC1C,IAAI,oBAAoB,OAAO,gBAAgB;CAC/C,IAAI,kBAAkB,OAAO,KAAK,cAAc;CAChD,IAAI,WAAW;CACf,KAAK,IAAI,cAAc,GAAG,eAAe,MAAM,eAAe;EAC7D,IAAI,CAAC,SAAS,WAAW,SAAS,UAAU,MAG3C,OAAO;GACN,OAAO,CAAC;GACR,UAAU;GACV,MAAM;IAAE,aAAa;IAAM,cAAc;IAAG,WAAW,mBAAmB,KAAA;GAAU;GACpF,SAAS;GACT,aAAa,qBAAqB,KAAA;EACnC;EAGD,MAAM,iBAAiB,SAAS;EAChC,MAAM,YAAY,SAAS,MAAM,SAAS,cAAc,GAAG,aAAa,cAAc;EACtF,KAAK,MAAM,WAAW,UAAU,UAC/B,qBAAqB,gBAAgB,OAAO;EAE7C,sBAAsB,UAAU,gBAAgB;EAChD,oBAAoB,UAAU,KAAK,cAAc;EACjD,IAAI,gBAAgB,MACnB,OAAO;GACN,GAAG;GACH,UAAU;GACV,MAAM;IAAE,GAAG,UAAU;IAAM,WAAW,mBAAmB,KAAA;GAAU;GACnE,aAAa,qBAAqB,KAAA;EACnC;EAGD,WAAW;CACZ;CAEA,OAAO;AACR"}
|
|
@@ -20,6 +20,13 @@ import { ProviderOrganization, ProviderResult, ProviderWarning } from "../result
|
|
|
20
20
|
export declare function resourceLabel(resource: ResourceDescriptor): string;
|
|
21
21
|
/** Whether `org` addresses this resource by any of the identifiers a caller could reasonably have. */
|
|
22
22
|
export declare function resourceMatchesOrg(resource: ResourceDescriptor, org: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether a caller's `org`/`project` selector addresses this resource or project, for the reads that act on a
|
|
25
|
+
* remembered selection. Jira's only by its canonical key (a site's id, a project's key): a site or project that was
|
|
26
|
+
* removed must select nothing, not resolve through its old name or id to another one that happens to carry it as a
|
|
27
|
+
* name, id or key. Every other provider by any identifier, as {@link resourceMatchesOrg}.
|
|
28
|
+
*/
|
|
29
|
+
export declare function selectorMatches(providerId: IntegrationIds, resource: ResourceDescriptor, selector: string): boolean;
|
|
23
30
|
/**
|
|
24
31
|
* The id of the RESOURCE a project belongs to, used to look up which account (and therefore which user) that
|
|
25
32
|
* project's issues should be scoped to. Falls back through the project's own identifiers because some providers
|
|
@@ -38,6 +45,12 @@ export declare function projectKey(project: ResourceDescriptor): string;
|
|
|
38
45
|
* optional for the one provider family that may omit it.
|
|
39
46
|
*/
|
|
40
47
|
export declare function resourceToOrg(providerId: IntegrationIds, resource: ResourceDescriptor, org?: string): ProviderOrganization;
|
|
48
|
+
/**
|
|
49
|
+
* Maps an issue-tracker project descriptor to the unified org shape, as {@link resourceToOrg} does with its parent's
|
|
50
|
+
* label as `org`. A Jira project is published by what its reads take: `name` is its key (its display name can collide
|
|
51
|
+
* with another project's key), and `orgId` its site's id, since the label in `org` can't address the site.
|
|
52
|
+
*/
|
|
53
|
+
export declare function projectToOrg(providerId: IntegrationIds, project: ResourceDescriptor, resources: ResourceDescriptor[]): ProviderOrganization;
|
|
41
54
|
/**
|
|
42
55
|
* The resource a project belongs under, as a display label — the `org` of the project's unified org shape.
|
|
43
56
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../constants.js";
|
|
2
2
|
import { appendDedupedWarning } from "../results.js";
|
|
3
|
+
import { isJiraIntegrationId } from "../utils/integration.utils.js";
|
|
3
4
|
//#region ../plus/integrations/src/reads/hierarchy.utils.ts
|
|
4
5
|
/**
|
|
5
6
|
* Mapping of a provider's own hierarchy vocabulary onto the single {@link ProviderOrganization} shape the facade
|
|
@@ -26,6 +27,15 @@ function resourceMatchesOrg(resource, org) {
|
|
|
26
27
|
return resource.key === org || typed.id === org || typed.name === org;
|
|
27
28
|
}
|
|
28
29
|
/**
|
|
30
|
+
* Whether a caller's `org`/`project` selector addresses this resource or project, for the reads that act on a
|
|
31
|
+
* remembered selection. Jira's only by its canonical key (a site's id, a project's key): a site or project that was
|
|
32
|
+
* removed must select nothing, not resolve through its old name or id to another one that happens to carry it as a
|
|
33
|
+
* name, id or key. Every other provider by any identifier, as {@link resourceMatchesOrg}.
|
|
34
|
+
*/
|
|
35
|
+
function selectorMatches(providerId, resource, selector) {
|
|
36
|
+
return isJiraIntegrationId(providerId) ? resource.key === selector : resourceMatchesOrg(resource, selector);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
29
39
|
* The id of the RESOURCE a project belongs to, used to look up which account (and therefore which user) that
|
|
30
40
|
* project's issues should be scoped to. Falls back through the project's own identifiers because some providers
|
|
31
41
|
* (and test doubles) return project descriptors without naming their parent.
|
|
@@ -63,6 +73,21 @@ function resourceToOrg(providerId, resource, org) {
|
|
|
63
73
|
};
|
|
64
74
|
}
|
|
65
75
|
/**
|
|
76
|
+
* Maps an issue-tracker project descriptor to the unified org shape, as {@link resourceToOrg} does with its parent's
|
|
77
|
+
* label as `org`. A Jira project is published by what its reads take: `name` is its key (its display name can collide
|
|
78
|
+
* with another project's key), and `orgId` its site's id, since the label in `org` can't address the site.
|
|
79
|
+
*/
|
|
80
|
+
function projectToOrg(providerId, project, resources) {
|
|
81
|
+
const item = resourceToOrg(providerId, project, orgForProject(providerId, project, resources));
|
|
82
|
+
if (!isJiraIntegrationId(providerId)) return item;
|
|
83
|
+
const { resourceId } = project;
|
|
84
|
+
return {
|
|
85
|
+
...item,
|
|
86
|
+
name: project.key,
|
|
87
|
+
...typeof resourceId === "string" ? { orgId: resourceId } : {}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
66
91
|
* The resource a project belongs under, as a display label — the `org` of the project's unified org shape.
|
|
67
92
|
*
|
|
68
93
|
* A project doesn't reliably name its parent, so try each identifier it does carry against the resources that
|
|
@@ -124,6 +149,6 @@ function assertHierarchyReadTarget(method, options) {
|
|
|
124
149
|
if (options?.providerId == null && (options?.connectionId != null || options?.domain != null)) throw new TypeError(`'${method}' requires 'providerId' when 'connectionId' or 'domain' is supplied`);
|
|
125
150
|
}
|
|
126
151
|
//#endregion
|
|
127
|
-
export { assertHierarchyReadTarget, mergeHierarchyResults, orgForProject, projectKey, resourceIdForProject, resourceLabel, resourceMatchesOrg, resourceToOrg, withProviderContext };
|
|
152
|
+
export { assertHierarchyReadTarget, mergeHierarchyResults, orgForProject, projectKey, projectToOrg, resourceIdForProject, resourceLabel, resourceMatchesOrg, resourceToOrg, selectorMatches, withProviderContext };
|
|
128
153
|
|
|
129
154
|
//# sourceMappingURL=hierarchy.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hierarchy.utils.js","names":[],"sources":["../../../../../plus/integrations/src/reads/hierarchy.utils.ts"],"sourcesContent":["import type { IssueResourceDescriptor, ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { IssuesCloudHostIntegrationId } from '../constants.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type { ProviderOrganization, ProviderResult, ProviderWarning } from '../results.js';\nimport { appendDedupedWarning } from '../results.js';\n\n/**\n * Mapping of a provider's own hierarchy vocabulary onto the single {@link ProviderOrganization} shape the facade\n * publishes.\n *\n * Providers disagree about what sits above a repo or an issue: git hosts have orgs (and Azure DevOps a project\n * tier below that), while issue trackers have \"resources\" (Jira sites, Linear orgs, Trello workspaces) with\n * projects beneath them. `listOrgs`/`listProjects` unify all of it, so these helpers exist to keep the\n * per-provider shape-guessing — which field is the id, which is the display label, which resource is a\n * project's parent — in one place instead of inline in those reads.\n *\n * Everything here reads through the base {@link ResourceDescriptor} (which only guarantees `key`) and casts to\n * the concrete {@link IssueResourceDescriptor} for the optional `id`/`name`. That cast is why the fallbacks are\n * spelled out rather than assumed.\n */\n\n/** The label to show for a resource: its name, else its id, else the key that is always present. */\nexport function resourceLabel(resource: ResourceDescriptor): string {\n\tconst typed = resource as IssueResourceDescriptor;\n\treturn typed.name ?? typed.id ?? resource.key;\n}\n\n/** Whether `org` addresses this resource by any of the identifiers a caller could reasonably have. */\nexport function resourceMatchesOrg(resource: ResourceDescriptor, org: string): boolean {\n\tconst typed = resource as IssueResourceDescriptor;\n\treturn resource.key === org || typed.id === org || typed.name === org;\n}\n\n/**\n * The id of the RESOURCE a project belongs to, used to look up which account (and therefore which user) that\n * project's issues should be scoped to. Falls back through the project's own identifiers because some providers\n * (and test doubles) return project descriptors without naming their parent.\n */\nexport function resourceIdForProject(project: ResourceDescriptor): string | undefined {\n\tconst typed = project as IssueResourceDescriptor & { resourceId?: string };\n\treturn typed.resourceId ?? typed.id ?? project.key;\n}\n\n/**\n * A stable identity for one project across facade pages, for the retry/completed bookkeeping an issue-tracker\n * cursor carries. All three identifiers are included rather than one preferred value: two trackers can reuse the\n * same project id, so keying on a single field would collapse them into one entry.\n */\nexport function projectKey(project: ResourceDescriptor): string {\n\tconst typed = project as IssueResourceDescriptor & { resourceId?: string };\n\treturn JSON.stringify([typed.resourceId ?? '', typed.id ?? '', project.key]);\n}\n\n/**\n * Maps an issue-tracker resource descriptor to the unified {@link ProviderOrganization} org shape. `url` is\n * synthesized when the descriptor carries none, rather than widening the shared `ProviderOrganization.url` to\n * optional for the one provider family that may omit it.\n */\nexport function resourceToOrg(\n\tproviderId: IntegrationIds,\n\tresource: ResourceDescriptor,\n\torg?: string,\n): ProviderOrganization {\n\tconst typed = resource as IssueResourceDescriptor & { url?: string };\n\treturn {\n\t\tid: typed.id ?? resource.key,\n\t\tproviderId: providerId,\n\t\tname: resourceLabel(resource),\n\t\t...(org != null ? { org: org } : {}),\n\t\turl: typed.url ?? '',\n\t};\n}\n\n/**\n * The resource a project belongs under, as a display label — the `org` of the project's unified org shape.\n *\n * A project doesn't reliably name its parent, so try each identifier it does carry against the resources that\n * were read alongside it. When none matches but only ONE resource was in scope, that resource is the parent by\n * construction. Trello is excluded: its boards have no enclosing resource to name.\n */\nexport function orgForProject(\n\tproviderId: IntegrationIds,\n\tproject: ResourceDescriptor,\n\tresources: ResourceDescriptor[],\n): string | undefined {\n\tif (providerId === IssuesCloudHostIntegrationId.Trello) return undefined;\n\n\tconst typedProject = project as IssueResourceDescriptor & { resourceId?: string };\n\tconst parentMatch = [typedProject.resourceId, typedProject.id, project.key]\n\t\t.filter((value): value is string => value != null)\n\t\t.map(candidate => resources.find(resource => resourceMatchesOrg(resource, candidate)))\n\t\t.find((resource): resource is ResourceDescriptor => resource != null);\n\n\treturn parentMatch != null\n\t\t? resourceLabel(parentMatch)\n\t\t: resources.length === 1\n\t\t\t? resourceLabel(resources[0])\n\t\t\t: undefined;\n}\n\n/**\n * Stamps the provider onto an org the provider's own client produced. A git host's client fills the rest of the\n * shape but doesn't know which integration id it was reached through — and on a self-managed host the same\n * client serves several — so the fan-out attributes it here.\n */\nexport function withProviderContext(providerId: IntegrationIds, item: ProviderOrganization): ProviderOrganization {\n\treturn {\n\t\t...item,\n\t\tproviderId: providerId,\n\t\t...(item.org != null ? { org: item.org } : {}),\n\t};\n}\n\n/**\n * Merges the per-provider slices of a hierarchy fan-out into one flat result.\n *\n * `ProviderResult` has no page object, so `fetchFailed` is its only non-authoritative signal — any slice that\n * failed or came back incomplete has to set it, or a caller would treat a short list as the whole account.\n * Warnings are deduped because the same account can surface under two ids in one fan-out.\n */\nexport function mergeHierarchyResults<T>(\n\tresults: readonly ({ items: T[]; warnings: ProviderWarning[]; fetchFailed: boolean } | undefined)[],\n): ProviderResult<T> {\n\tconst items: T[] = [];\n\tconst warnings: ProviderWarning[] = [];\n\tlet fetchFailed = false;\n\tfor (const result of results) {\n\t\tif (result == null) continue;\n\n\t\titems.push(...result.items);\n\t\tfor (const warning of result.warnings) {\n\t\t\tappendDedupedWarning(warnings, warning);\n\t\t}\n\t\tif (result.fetchFailed) {\n\t\t\tfetchFailed = true;\n\t\t}\n\t}\n\n\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed || undefined };\n}\n\n/**\n * Rejects a hierarchy read whose scoped selectors have no provider to apply to. `connectionId` and `domain`\n * both select among the connections OF a provider, so either one without `providerId` is ambiguous rather than\n * merely redundant — the fan-out would have to guess which provider the caller meant, and silently picking one\n * would read that connection's data under another provider's name.\n */\nexport function assertHierarchyReadTarget(\n\tmethod: 'listOrgs' | 'listProjects',\n\toptions: { providerId?: IntegrationIds; connectionId?: string; domain?: string } | undefined,\n): void {\n\tif (options?.providerId == null && (options?.connectionId != null || options?.domain != null)) {\n\t\tthrow new TypeError(`'${method}' requires 'providerId' when 'connectionId' or 'domain' is supplied`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,SAAgB,cAAc,UAAsC;CACnE,MAAM,QAAQ;CACd,OAAO,MAAM,QAAQ,MAAM,MAAM,SAAS;AAC3C;;AAGA,SAAgB,mBAAmB,UAA8B,KAAsB;CACtF,MAAM,QAAQ;CACd,OAAO,SAAS,QAAQ,OAAO,MAAM,OAAO,OAAO,MAAM,SAAS;AACnE;;;;;;AAOA,SAAgB,qBAAqB,SAAiD;CACrF,MAAM,QAAQ;CACd,OAAO,MAAM,cAAc,MAAM,MAAM,QAAQ;AAChD;;;;;;AAOA,SAAgB,WAAW,SAAqC;CAC/D,MAAM,QAAQ;CACd,OAAO,KAAK,UAAU;EAAC,MAAM,cAAc;EAAI,MAAM,MAAM;EAAI,QAAQ;CAAG,CAAC;AAC5E;;;;;;AAOA,SAAgB,cACf,YACA,UACA,KACuB;CACvB,MAAM,QAAQ;CACd,OAAO;EACN,IAAI,MAAM,MAAM,SAAS;EACb;EACZ,MAAM,cAAc,QAAQ;EAC5B,GAAI,OAAO,OAAO,EAAO,IAAI,IAAI,CAAC;EAClC,KAAK,MAAM,OAAO;CACnB;AACD;;;;;;;;AASA,SAAgB,cACf,YACA,SACA,WACqB;CACrB,IAAI,eAAA,UAAoD,OAAO,KAAA;CAE/D,MAAM,eAAe;CACrB,MAAM,cAAc;EAAC,aAAa;EAAY,aAAa;EAAI,QAAQ;CAAG,CAAC,CACzE,QAAQ,UAA2B,SAAS,IAAI,CAAC,CACjD,KAAI,cAAa,UAAU,MAAK,aAAY,mBAAmB,UAAU,SAAS,CAAC,CAAC,CAAC,CACrF,MAAM,aAA6C,YAAY,IAAI;CAErE,OAAO,eAAe,OACnB,cAAc,WAAW,IACzB,UAAU,WAAW,IACpB,cAAc,UAAU,EAAE,IAC1B,KAAA;AACL;;;;;;AAOA,SAAgB,oBAAoB,YAA4B,MAAkD;CACjH,OAAO;EACN,GAAG;EACS;EACZ,GAAI,KAAK,OAAO,OAAO,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC;CAC7C;AACD;;;;;;;;AASA,SAAgB,sBACf,SACoB;CACpB,MAAM,QAAa,CAAC;CACpB,MAAM,WAA8B,CAAC;CACrC,IAAI,cAAc;CAClB,KAAK,MAAM,UAAU,SAAS;EAC7B,IAAI,UAAU,MAAM;EAEpB,MAAM,KAAK,GAAG,OAAO,KAAK;EAC1B,KAAK,MAAM,WAAW,OAAO,UAC5B,qBAAqB,UAAU,OAAO;EAEvC,IAAI,OAAO,aACV,cAAc;CAEhB;CAEA,OAAO;EAAS;EAAiB;EAAU,aAAa,eAAe,KAAA;CAAU;AAClF;;;;;;;AAQA,SAAgB,0BACf,QACA,SACO;CACP,IAAI,SAAS,cAAc,SAAS,SAAS,gBAAgB,QAAQ,SAAS,UAAU,OACvF,MAAM,IAAI,UAAU,IAAI,OAAO,oEAAoE;AAErG"}
|
|
1
|
+
{"version":3,"file":"hierarchy.utils.js","names":[],"sources":["../../../../../plus/integrations/src/reads/hierarchy.utils.ts"],"sourcesContent":["import type { IssueResourceDescriptor, ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { IssuesCloudHostIntegrationId } from '../constants.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type { ProviderOrganization, ProviderResult, ProviderWarning } from '../results.js';\nimport { appendDedupedWarning } from '../results.js';\nimport { isJiraIntegrationId } from '../utils/integration.utils.js';\n\n/**\n * Mapping of a provider's own hierarchy vocabulary onto the single {@link ProviderOrganization} shape the facade\n * publishes.\n *\n * Providers disagree about what sits above a repo or an issue: git hosts have orgs (and Azure DevOps a project\n * tier below that), while issue trackers have \"resources\" (Jira sites, Linear orgs, Trello workspaces) with\n * projects beneath them. `listOrgs`/`listProjects` unify all of it, so these helpers exist to keep the\n * per-provider shape-guessing — which field is the id, which is the display label, which resource is a\n * project's parent — in one place instead of inline in those reads.\n *\n * Everything here reads through the base {@link ResourceDescriptor} (which only guarantees `key`) and casts to\n * the concrete {@link IssueResourceDescriptor} for the optional `id`/`name`. That cast is why the fallbacks are\n * spelled out rather than assumed.\n */\n\n/** The label to show for a resource: its name, else its id, else the key that is always present. */\nexport function resourceLabel(resource: ResourceDescriptor): string {\n\tconst typed = resource as IssueResourceDescriptor;\n\treturn typed.name ?? typed.id ?? resource.key;\n}\n\n/** Whether `org` addresses this resource by any of the identifiers a caller could reasonably have. */\nexport function resourceMatchesOrg(resource: ResourceDescriptor, org: string): boolean {\n\tconst typed = resource as IssueResourceDescriptor;\n\treturn resource.key === org || typed.id === org || typed.name === org;\n}\n\n/**\n * Whether a caller's `org`/`project` selector addresses this resource or project, for the reads that act on a\n * remembered selection. Jira's only by its canonical key (a site's id, a project's key): a site or project that was\n * removed must select nothing, not resolve through its old name or id to another one that happens to carry it as a\n * name, id or key. Every other provider by any identifier, as {@link resourceMatchesOrg}.\n */\nexport function selectorMatches(providerId: IntegrationIds, resource: ResourceDescriptor, selector: string): boolean {\n\treturn isJiraIntegrationId(providerId) ? resource.key === selector : resourceMatchesOrg(resource, selector);\n}\n\n/**\n * The id of the RESOURCE a project belongs to, used to look up which account (and therefore which user) that\n * project's issues should be scoped to. Falls back through the project's own identifiers because some providers\n * (and test doubles) return project descriptors without naming their parent.\n */\nexport function resourceIdForProject(project: ResourceDescriptor): string | undefined {\n\tconst typed = project as IssueResourceDescriptor & { resourceId?: string };\n\treturn typed.resourceId ?? typed.id ?? project.key;\n}\n\n/**\n * A stable identity for one project across facade pages, for the retry/completed bookkeeping an issue-tracker\n * cursor carries. All three identifiers are included rather than one preferred value: two trackers can reuse the\n * same project id, so keying on a single field would collapse them into one entry.\n */\nexport function projectKey(project: ResourceDescriptor): string {\n\tconst typed = project as IssueResourceDescriptor & { resourceId?: string };\n\treturn JSON.stringify([typed.resourceId ?? '', typed.id ?? '', project.key]);\n}\n\n/**\n * Maps an issue-tracker resource descriptor to the unified {@link ProviderOrganization} org shape. `url` is\n * synthesized when the descriptor carries none, rather than widening the shared `ProviderOrganization.url` to\n * optional for the one provider family that may omit it.\n */\nexport function resourceToOrg(\n\tproviderId: IntegrationIds,\n\tresource: ResourceDescriptor,\n\torg?: string,\n): ProviderOrganization {\n\tconst typed = resource as IssueResourceDescriptor & { url?: string };\n\treturn {\n\t\tid: typed.id ?? resource.key,\n\t\tproviderId: providerId,\n\t\tname: resourceLabel(resource),\n\t\t...(org != null ? { org: org } : {}),\n\t\turl: typed.url ?? '',\n\t};\n}\n\n/**\n * Maps an issue-tracker project descriptor to the unified org shape, as {@link resourceToOrg} does with its parent's\n * label as `org`. A Jira project is published by what its reads take: `name` is its key (its display name can collide\n * with another project's key), and `orgId` its site's id, since the label in `org` can't address the site.\n */\nexport function projectToOrg(\n\tproviderId: IntegrationIds,\n\tproject: ResourceDescriptor,\n\tresources: ResourceDescriptor[],\n): ProviderOrganization {\n\tconst item = resourceToOrg(providerId, project, orgForProject(providerId, project, resources));\n\tif (!isJiraIntegrationId(providerId)) return item;\n\n\t// The descriptor's own parent id only: `resourceIdForProject` would fall back to the project's id or key.\n\tconst { resourceId } = project;\n\treturn { ...item, name: project.key, ...(typeof resourceId === 'string' ? { orgId: resourceId } : {}) };\n}\n\n/**\n * The resource a project belongs under, as a display label — the `org` of the project's unified org shape.\n *\n * A project doesn't reliably name its parent, so try each identifier it does carry against the resources that\n * were read alongside it. When none matches but only ONE resource was in scope, that resource is the parent by\n * construction. Trello is excluded: its boards have no enclosing resource to name.\n */\nexport function orgForProject(\n\tproviderId: IntegrationIds,\n\tproject: ResourceDescriptor,\n\tresources: ResourceDescriptor[],\n): string | undefined {\n\tif (providerId === IssuesCloudHostIntegrationId.Trello) return undefined;\n\n\tconst typedProject = project as IssueResourceDescriptor & { resourceId?: string };\n\tconst parentMatch = [typedProject.resourceId, typedProject.id, project.key]\n\t\t.filter((value): value is string => value != null)\n\t\t.map(candidate => resources.find(resource => resourceMatchesOrg(resource, candidate)))\n\t\t.find((resource): resource is ResourceDescriptor => resource != null);\n\n\treturn parentMatch != null\n\t\t? resourceLabel(parentMatch)\n\t\t: resources.length === 1\n\t\t\t? resourceLabel(resources[0])\n\t\t\t: undefined;\n}\n\n/**\n * Stamps the provider onto an org the provider's own client produced. A git host's client fills the rest of the\n * shape but doesn't know which integration id it was reached through — and on a self-managed host the same\n * client serves several — so the fan-out attributes it here.\n */\nexport function withProviderContext(providerId: IntegrationIds, item: ProviderOrganization): ProviderOrganization {\n\treturn {\n\t\t...item,\n\t\tproviderId: providerId,\n\t\t...(item.org != null ? { org: item.org } : {}),\n\t};\n}\n\n/**\n * Merges the per-provider slices of a hierarchy fan-out into one flat result.\n *\n * `ProviderResult` has no page object, so `fetchFailed` is its only non-authoritative signal — any slice that\n * failed or came back incomplete has to set it, or a caller would treat a short list as the whole account.\n * Warnings are deduped because the same account can surface under two ids in one fan-out.\n */\nexport function mergeHierarchyResults<T>(\n\tresults: readonly ({ items: T[]; warnings: ProviderWarning[]; fetchFailed: boolean } | undefined)[],\n): ProviderResult<T> {\n\tconst items: T[] = [];\n\tconst warnings: ProviderWarning[] = [];\n\tlet fetchFailed = false;\n\tfor (const result of results) {\n\t\tif (result == null) continue;\n\n\t\titems.push(...result.items);\n\t\tfor (const warning of result.warnings) {\n\t\t\tappendDedupedWarning(warnings, warning);\n\t\t}\n\t\tif (result.fetchFailed) {\n\t\t\tfetchFailed = true;\n\t\t}\n\t}\n\n\treturn { items: items, warnings: warnings, fetchFailed: fetchFailed || undefined };\n}\n\n/**\n * Rejects a hierarchy read whose scoped selectors have no provider to apply to. `connectionId` and `domain`\n * both select among the connections OF a provider, so either one without `providerId` is ambiguous rather than\n * merely redundant — the fan-out would have to guess which provider the caller meant, and silently picking one\n * would read that connection's data under another provider's name.\n */\nexport function assertHierarchyReadTarget(\n\tmethod: 'listOrgs' | 'listProjects',\n\toptions: { providerId?: IntegrationIds; connectionId?: string; domain?: string } | undefined,\n): void {\n\tif (options?.providerId == null && (options?.connectionId != null || options?.domain != null)) {\n\t\tthrow new TypeError(`'${method}' requires 'providerId' when 'connectionId' or 'domain' is supplied`);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,cAAc,UAAsC;CACnE,MAAM,QAAQ;CACd,OAAO,MAAM,QAAQ,MAAM,MAAM,SAAS;AAC3C;;AAGA,SAAgB,mBAAmB,UAA8B,KAAsB;CACtF,MAAM,QAAQ;CACd,OAAO,SAAS,QAAQ,OAAO,MAAM,OAAO,OAAO,MAAM,SAAS;AACnE;;;;;;;AAQA,SAAgB,gBAAgB,YAA4B,UAA8B,UAA2B;CACpH,OAAO,oBAAoB,UAAU,IAAI,SAAS,QAAQ,WAAW,mBAAmB,UAAU,QAAQ;AAC3G;;;;;;AAOA,SAAgB,qBAAqB,SAAiD;CACrF,MAAM,QAAQ;CACd,OAAO,MAAM,cAAc,MAAM,MAAM,QAAQ;AAChD;;;;;;AAOA,SAAgB,WAAW,SAAqC;CAC/D,MAAM,QAAQ;CACd,OAAO,KAAK,UAAU;EAAC,MAAM,cAAc;EAAI,MAAM,MAAM;EAAI,QAAQ;CAAG,CAAC;AAC5E;;;;;;AAOA,SAAgB,cACf,YACA,UACA,KACuB;CACvB,MAAM,QAAQ;CACd,OAAO;EACN,IAAI,MAAM,MAAM,SAAS;EACb;EACZ,MAAM,cAAc,QAAQ;EAC5B,GAAI,OAAO,OAAO,EAAO,IAAI,IAAI,CAAC;EAClC,KAAK,MAAM,OAAO;CACnB;AACD;;;;;;AAOA,SAAgB,aACf,YACA,SACA,WACuB;CACvB,MAAM,OAAO,cAAc,YAAY,SAAS,cAAc,YAAY,SAAS,SAAS,CAAC;CAC7F,IAAI,CAAC,oBAAoB,UAAU,GAAG,OAAO;CAG7C,MAAM,EAAE,eAAe;CACvB,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ileOmissionsWithFailure } from "../results.js";
|
|
5
5
|
import { assessCollectionMetadata, mergeAssessmentInto } from "../collectionMetadata.js";
|
|
6
6
|
import "../providerFilters.js";
|
|
7
|
-
import { mergeCollectionMetadata, parsePageCursor } from "../providers/utils/providerPaging.js";
|
|
8
7
|
import { isIssuesHostIntegrationId } from "../utils/integration.utils.js";
|
|
8
|
+
import { mergeCollectionMetadata, parsePageCursor } from "../providers/utils/providerPaging.js";
|
|
9
9
|
import { providersMetadata } from "../providers/models.js";
|
|
10
10
|
import { parseIssueTrackerPageCursor, toIssueTrackerPageCursor } from "./cursors.js";
|
|
11
11
|
import { incompleteReadWarning, issueTrackerOnlySurfaceWarning, otherWarning, unmergeableIssueSortWarning, unsupportedIssueSortWarning, unsupportedWarning } from "./warnings.js";
|
|
12
12
|
import { runCaptured } from "./drains.js";
|
|
13
13
|
import { isIssuesIntegration } from "../models/issuesIntegration.js";
|
|
14
|
-
import { projectKey, resourceIdForProject, resourceLabel,
|
|
14
|
+
import { projectKey, resourceIdForProject, resourceLabel, selectorMatches } from "./hierarchy.utils.js";
|
|
15
15
|
import { resolveIssueSort, toIssueOrdering } from "./ordering.js";
|
|
16
16
|
//#region ../plus/integrations/src/reads/issueTracker.ts
|
|
17
17
|
const issueStateFilters = [
|
|
@@ -98,7 +98,7 @@ async function listIssueTrackerIssuesPage(ctx, options) {
|
|
|
98
98
|
const fetchFailed = resourcesWarning != null && resources == null;
|
|
99
99
|
return emptyPage(fetchFailed, false, fetchFailed ? discoveryFailureRetry() : void 0);
|
|
100
100
|
}
|
|
101
|
-
const scopedResources = options.org != null ? resources.filter((r) =>
|
|
101
|
+
const scopedResources = options.org != null ? resources.filter((r) => selectorMatches(options.providerId, r, options.org)) : resources;
|
|
102
102
|
if (scopedResources.length === 0) return emptyPage();
|
|
103
103
|
const { value: projectsResult, warning: projectsWarning } = await runCaptured(options.providerId, domain, options.connectionId, () => integration.getProjectsForResourcesWithMetadataResult(scopedResources, options.connectionId));
|
|
104
104
|
if (projectsWarning != null) warnings.push(projectsWarning);
|
|
@@ -110,7 +110,7 @@ async function listIssueTrackerIssuesPage(ctx, options) {
|
|
|
110
110
|
const fetchFailed = projectsWarning != null && projectsResult == null || projectDiscoveryFailed;
|
|
111
111
|
return emptyPage(fetchFailed, projectDiscoveryTruncated, fetchFailed || projectDiscoveryTruncated ? discoveryFailureRetry() : void 0);
|
|
112
112
|
}
|
|
113
|
-
const matchedProjects = options.project != null ? projects.filter((p) =>
|
|
113
|
+
const matchedProjects = options.project != null ? projects.filter((p) => selectorMatches(options.providerId, p, options.project)) : projects;
|
|
114
114
|
if (options.filters?.length) {
|
|
115
115
|
const supported = providersMetadata[options.providerId]?.supportedIssueFilters;
|
|
116
116
|
if (!(supported != null && options.filters.every((f) => supported.includes(f)))) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issueTracker.js","names":[],"sources":["../../../../../plus/integrations/src/reads/issueTracker.ts"],"sourcesContent":["import type { CollectionMetadata } from '@gitkraken/provider-apis';\nimport type { IssueShape, IssueSorting, IssueStateFilter } from '@gitlens/git/models/issue.js';\nimport type { ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { mapBounded } from '@gitlens/utils/promise.js';\nimport { assessCollectionMetadata, mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport { providerFanOutConcurrency } from '../constants.js';\nimport { toError } from '../errors.js';\nimport type { IntegrationResult } from '../models/integration.js';\nimport type { ProjectIssuesDrain } from '../models/issueReads.js';\nimport { isIssuesIntegration } from '../models/issuesIntegration.js';\nimport { IssueFilter, providersMetadata } from '../providers/models.js';\nimport { mergeCollectionMetadata, parsePageCursor } from '../providers/utils/providerPaging.js';\nimport type { ProviderPagedResult, ProviderWarning } from '../results.js';\nimport { appendDedupedWarning, reconcileOmissionsWithFailure } from '../results.js';\nimport { isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport type { ProviderReadContext } from './context.js';\nimport { parseIssueTrackerPageCursor, toIssueTrackerPageCursor } from './cursors.js';\nimport { runCaptured } from './drains.js';\nimport { projectKey, resourceIdForProject, resourceLabel, resourceMatchesOrg } from './hierarchy.utils.js';\nimport { resolveIssueSort, toIssueOrdering } from './ordering.js';\nimport {\n\tincompleteReadWarning,\n\tissueTrackerOnlySurfaceWarning,\n\totherWarning,\n\tunmergeableIssueSortWarning,\n\tunsupportedIssueSortWarning,\n\tunsupportedWarning,\n} from './warnings.js';\n\nconst issueStateFilters: readonly IssueStateFilter[] = ['open', 'closed', 'all'];\n\nexport async function listIssueTrackerIssuesPage(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\torg?: string;\n\t\tproject?: string;\n\t\tfilters?: IssueFilter[];\n\t\t/** Broadens the read to every assignee. Scopes to user-assigned issues when omitted. */\n\t\tincludeAllAssignees?: boolean;\n\t\t/**\n\t\t * How to order the issues, as `field:direction`. Omitted orders most-recently-updated-first where the\n\t\t * tracker can express it.\n\t\t *\n\t\t * Validated against `getSupportedFilters().issues`' sibling `issueSorts` — a tracker reports there, not\n\t\t * under the account-wide table, because resource -> project IS its only issue surface. A key it can't\n\t\t * express refuses the read rather than serving a differently-ordered list.\n\t\t *\n\t\t * One page can span SEVERAL projects, whose issues are merged here, so a key no normalized issue carries\n\t\t * (`priority`, `dueDate`, `resolved`) is refused for a multi-project page even though the tracker orders by\n\t\t * it perfectly well within one project.\n\t\t *\n\t\t * Unlike the git-host reads this one is safe to change mid-pagination: its cursor windows PROJECTS and\n\t\t * drains each to exhaustion, so which projects a round covers doesn't depend on how their issues are\n\t\t * ordered. Only the order within a page changes.\n\t\t */\n\t\tsort?: IssueSorting;\n\t\t/**\n\t\t * Which issue states to read. Omitted reads open issues only.\n\t\t *\n\t\t * Applied server-side by every project read, so it narrows each project's drain rather than the merged page.\n\t\t * Only a tracker declaring `ProviderMetadata.supportsIssueStates` can express anything but `'open'`; asking\n\t\t * another for `'closed'`/`'all'` refuses the read rather than serving its open issues.\n\t\t */\n\t\tstate?: IssueStateFilter;\n\t\tforceSync?: boolean;\n\t\tpage?: number;\n\t\tcursor?: string;\n\t\titemsPerPage?: number;\n\t\tconnectionId?: string;\n\t\t/**\n\t\t * Explicit self-managed tracker host. Used to select the instance when the requested connection has no\n\t\t * configured domain; it must come from the trusted authentication configuration, never from repository\n\t\t * or remote data. Ignored for the cloud trackers.\n\t\t */\n\t\tdomain?: string;\n\t},\n): Promise<ProviderPagedResult<IssueShape>> {\n\t// Pagination is opt-in: only window the projects when the caller actually asked to page. A caller that\n\t// passes none of page/cursor/itemsPerPage keeps the \"aggregate every matched project\" contract, so an\n\t// existing consumer that doesn't inspect `hasMore` never silently loses projects past a default window.\n\tconst compositeCursor = parseIssueTrackerPageCursor(options.cursor);\n\tconst paginated =\n\t\tcompositeCursor?.unpaged !== true &&\n\t\t(options.page != null || options.cursor != null || options.itemsPerPage != null);\n\t// A composite cursor can carry retries from earlier project windows alongside the next untouched window.\n\t// `currentPage` remains the caller-facing position; `nextPage` is the window this round should advance.\n\tconst page = Math.max(\n\t\t1,\n\t\tMath.trunc(compositeCursor?.currentPage ?? parsePageCursor(options.cursor) ?? options.page ?? 1),\n\t);\n\tconst projectsPerPage = Math.max(1, Math.trunc(options.itemsPerPage ?? 20));\n\n\tconst items: IssueShape[] = [];\n\tconst warnings: ProviderWarning[] = [];\n\tconst emptyPage = (\n\t\tfetchFailed?: boolean,\n\t\ttruncated?: boolean,\n\t\tretry?: {\n\t\t\tnextPage?: number;\n\t\t\tpages?: readonly number[];\n\t\t\tprojects?: readonly string[];\n\t\t\tcompletedProjects?: readonly string[];\n\t\t},\n\t): ProviderPagedResult<IssueShape> => {\n\t\tconst cursor =\n\t\t\tretry != null\n\t\t\t\t? toIssueTrackerPageCursor({\n\t\t\t\t\t\tcurrentPage: page + 1,\n\t\t\t\t\t\tunpaged: !paginated,\n\t\t\t\t\t\tnextPage: retry.nextPage,\n\t\t\t\t\t\tretryPages: retry.pages ?? [],\n\t\t\t\t\t\tretryProjects: retry.projects ?? [],\n\t\t\t\t\t\tcompletedProjects: retry.completedProjects ?? [],\n\t\t\t\t\t\tstate: options.state,\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t\treturn {\n\t\t\titems: items,\n\t\t\twarnings: warnings,\n\t\t\tpage: { currentPage: page, itemsPerPage: items.length, truncated: truncated || undefined },\n\t\t\t// Retry-only state is deliberately manual: advertising it as forward progress would make a\n\t\t\t// persistent provider failure spin forever in a normal `while (hasMore)` consumer. An untouched\n\t\t\t// project window remains normal forward progress even when this window failed completely.\n\t\t\thasMore: retry?.nextPage != null && cursor != null,\n\t\t\tcursor: cursor,\n\t\t\tfetchFailed: fetchFailed || undefined,\n\t\t};\n\t};\n\tconst normalWindowPage = paginated\n\t\t? (compositeCursor?.nextPage ?? (compositeCursor == null ? page : undefined))\n\t\t: undefined;\n\tconst priorRetryPages = compositeCursor?.retryPages ?? [];\n\tconst priorRetryProjects = compositeCursor?.retryProjects ?? [];\n\tconst priorCompletedProjects = compositeCursor?.completedProjects ?? [];\n\tconst trackCompletedProjects =\n\t\tpriorCompletedProjects.length > 0 || priorRetryPages.length > 0 || compositeCursor?.completedProjects != null;\n\tconst retryPagesForDiscoveryFailure = (): number[] => [\n\t\t...priorRetryPages,\n\t\t...(normalWindowPage != null ? [normalWindowPage] : compositeCursor == null ? [1] : []),\n\t];\n\tconst discoveryFailureRetry = (): {\n\t\tpages: readonly number[];\n\t\tprojects: readonly string[];\n\t\tcompletedProjects: readonly string[];\n\t} => ({\n\t\tpages: retryPagesForDiscoveryFailure(),\n\t\tprojects: priorRetryProjects,\n\t\tcompletedProjects: priorCompletedProjects,\n\t});\n\n\tif (!isIssuesHostIntegrationId(options.providerId)) {\n\t\twarnings.push(\n\t\t\tissueTrackerOnlySurfaceWarning(options.providerId, options.connectionId, 'Issue-tracker project reads'),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\tif (integration == null) {\n\t\t// A supplied connectionId or domain that no longer resolves is a broken target, not an empty account.\n\t\tconst early = ctx.earlyReturnConnectionWarnings(options.providerId, options.connectionId, options.domain);\n\t\twarnings.push(...early.warnings);\n\t\treturn emptyPage(early.fetchFailed);\n\t}\n\tif (!isIssuesIntegration(integration)) {\n\t\twarnings.push(\n\t\t\tissueTrackerOnlySurfaceWarning(options.providerId, options.connectionId, 'Issue-tracker project reads'),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\n\t// Before any upstream request: the discovery fan-outs below (resources, projects, per-resource accounts) are\n\t// three round trips, and an order this tracker can't express refuses the read whatever they return. Placed after\n\t// `domain` only because every warning carries it.\n\tconst resolvedSort = resolveIssueSort(providersMetadata[options.providerId]?.supportedIssueSorts, options.sort);\n\tif (resolvedSort.rejection != null) {\n\t\twarnings.push(\n\t\t\tunsupportedIssueSortWarning(options.providerId, domain, options.connectionId, resolvedSort.rejection),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\tconst sort = resolvedSort.sort;\n\n\t// Refused before any request for the same reason as the sort: a state the tracker can't express would otherwise\n\t// be dropped by its project reads, and their open issues published as the requested state. A value outside the\n\t// vocabulary is refused too, since `toProviderIssueStates` would read it as omitted, which means open.\n\tif (\n\t\toptions.state != null &&\n\t\t(!issueStateFilters.includes(options.state) ||\n\t\t\t(options.state !== 'open' && !providersMetadata[options.providerId]?.supportsIssueStates))\n\t) {\n\t\t// A known state this tracker can't express is an unsupported capability; a value outside the vocabulary is\n\t\t// caller input the caller fixes in the request.\n\t\twarnings.push(\n\t\t\tissueStateFilters.includes(options.state)\n\t\t\t\t? unsupportedWarning(\n\t\t\t\t\t\toptions.providerId,\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t\t`Issue state '${options.state}' is not supported by '${options.providerId}'.`,\n\t\t\t\t\t)\n\t\t\t\t: otherWarning(\n\t\t\t\t\t\toptions.providerId,\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t\t`Unknown issue state; expected one of ${issueStateFilters.join(', ')}.`,\n\t\t\t\t\t),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\t// A cursor resumed under another state than it was minted for skips what it already covered, whose other-state\n\t// issues were never read. A narrowed read only mints composite cursors, which record their state, so any other\n\t// cursor came from an open read.\n\tconst cursorState =\n\t\tcompositeCursor != null ? (compositeCursor.state ?? 'open') : options.cursor != null ? 'open' : undefined;\n\tif (cursorState != null && cursorState !== (options.state ?? 'open')) {\n\t\twarnings.push(\n\t\t\totherWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\t'The cursor belongs to a read of another issue state; start again without it.',\n\t\t\t),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\tawait ctx.forceRefreshIfRequested(integration, options.forceSync, options.connectionId);\n\n\tawait integration.getCurrentAccount({ connectionId: options.connectionId }).catch(() => undefined);\n\n\tconst { value: resources, warning: resourcesWarning } = await runCaptured(\n\t\toptions.providerId,\n\t\tdomain,\n\t\toptions.connectionId,\n\t\t() => integration.getResourcesForUserResult(options.connectionId),\n\t);\n\tif (resourcesWarning != null) {\n\t\twarnings.push(resourcesWarning);\n\t}\n\tif (resources == null || resources.length === 0) {\n\t\tconst fetchFailed = resourcesWarning != null && resources == null;\n\t\treturn emptyPage(fetchFailed, false, fetchFailed ? discoveryFailureRetry() : undefined);\n\t}\n\n\tconst scopedResources =\n\t\toptions.org != null ? resources.filter(r => resourceMatchesOrg(r, options.org!)) : resources;\n\tif (scopedResources.length === 0) {\n\t\treturn emptyPage();\n\t}\n\n\tconst { value: projectsResult, warning: projectsWarning } = await runCaptured(\n\t\toptions.providerId,\n\t\tdomain,\n\t\toptions.connectionId,\n\t\t() => integration.getProjectsForResourcesWithMetadataResult(scopedResources, options.connectionId),\n\t);\n\tif (projectsWarning != null) {\n\t\twarnings.push(projectsWarning);\n\t}\n\t// Partial project discovery: continue with the resources that succeeded, but surface per-resource\n\t// failures as warnings and remember to mark the page fetchFailed so the caller knows some issues may be\n\t// missing. `projectDiscoveryFailed`/`projectDiscoveryTruncated` are OR-ed into the page's\n\t// fetchFailed/truncated at every return below (a truncated-but-not-failed discovery, e.g. a paging\n\t// backstop, still means the project set is incomplete).\n\tconst projectDiscoveryAssessment = mergeAssessmentInto(\n\t\twarnings,\n\t\toptions.providerId,\n\t\tdomain,\n\t\toptions.connectionId,\n\t\tprojectsResult?.metadata,\n\t);\n\tconst projectDiscoveryFailed = projectDiscoveryAssessment.fetchFailed;\n\tconst projectDiscoveryTruncated = projectDiscoveryAssessment.truncated;\n\tconst projects = projectsResult?.values;\n\tif (projects == null || projects.length === 0) {\n\t\tconst fetchFailed = (projectsWarning != null && projectsResult == null) || projectDiscoveryFailed;\n\t\treturn emptyPage(\n\t\t\tfetchFailed,\n\t\t\tprojectDiscoveryTruncated,\n\t\t\tfetchFailed || projectDiscoveryTruncated ? discoveryFailureRetry() : undefined,\n\t\t);\n\t}\n\n\tconst matchedProjects =\n\t\toptions.project != null ? projects.filter(p => resourceMatchesOrg(p, options.project!)) : projects;\n\n\t// Validate the requested filters against what this provider supports (e.g. Linear/Trello support only\n\t// Assignee). An unsupported filter must not silently degrade — Linear/Trello ignore the requested type\n\t// and apply Assignee regardless — so warn + fetchFailed instead of returning a differently-scoped set.\n\tif (options.filters?.length) {\n\t\tconst supported = providersMetadata[options.providerId]?.supportedIssueFilters;\n\t\tconst allSupported = supported != null && options.filters.every(f => supported.includes(f));\n\t\tif (!allSupported) {\n\t\t\twarnings.push(\n\t\t\t\tunsupportedWarning(\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`One or more requested issue filters are not supported by '${options.providerId}'.`,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn emptyPage(true);\n\t\t}\n\t}\n\n\t// `includeAllAssignees` drops the user scope, but a user-relative filter (Author/Mention) is meaningless\n\t// without a user. Passing both to the provider degrades silently: Jira, seeing no user, falls through to\n\t// an unscoped project fetch and returns EVERY issue instead of the requested author's/mentions. Reject\n\t// the incompatible combination up front rather than publishing a differently-scoped set as the result.\n\tif (options.includeAllAssignees === true && options.filters?.some(f => f !== IssueFilter.Assignee)) {\n\t\twarnings.push(\n\t\t\tunsupportedWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\t`\\`includeAllAssignees\\` cannot be combined with an author/mention filter for '${options.providerId}' (those filters require a user scope).`,\n\t\t\t),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\t// Scope to the current user's assigned issues unless the caller broadens to all assignees. Resolve the\n\t// handle from each resource's own account (multi-account safe), capturing any error so its kind\n\t// (e.g. auth) is preserved rather than collapsed to a generic warning.\n\tlet usersByResourceId: Map<string, string> | undefined;\n\t// The same accounts keyed by the same resource, holding the provider's stable id rather than the handle. A\n\t// separate map rather than a widened value because the two are resolved and consumed independently: a\n\t// provider may carry an account with no id, and `scopedProjectsWithUsers` gates on the HANDLE alone, so\n\t// folding them together would drop a resource whose id happened to be missing.\n\tlet userIdsByResourceId: Map<string, string> | undefined;\n\tlet accountLookupFailed = false;\n\tif (options.includeAllAssignees !== true) {\n\t\tusersByResourceId = new Map<string, string>();\n\t\tuserIdsByResourceId = new Map<string, string>();\n\t\tconst accounts = await mapBounded(scopedResources, providerFanOutConcurrency, async resource => ({\n\t\t\tresource: resource,\n\t\t\t...(await runCaptured(options.providerId, domain, options.connectionId, () =>\n\t\t\t\tintegration.getAccountForResourceResult(resource, options.connectionId),\n\t\t\t)),\n\t\t}));\n\n\t\tfor (const { resource, value: account, warning: accountWarning } of accounts) {\n\t\t\tconst user = account?.username ?? account?.name ?? undefined;\n\t\t\tif (user != null) {\n\t\t\t\tconst resourceKey = resourceIdForProject(resource) ?? resource.key;\n\t\t\t\tusersByResourceId.set(resourceKey, user);\n\t\t\t\t// Empty-checked, not just null-checked: an account shape declares `id` as a plain string, and a\n\t\t\t\t// provider with nothing to put there sets `''` rather than omitting it — which would otherwise\n\t\t\t\t// reach a user-field query as an empty identity and match nothing.\n\t\t\t\tif (account?.id != null && account.id !== '') {\n\t\t\t\t\tuserIdsByResourceId.set(resourceKey, account.id);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Deduped: a captured `accountWarning` carries only the provider error, with no resource in its\n\t\t\t// message, so one expired token across N resources would otherwise repeat verbatim N times. The\n\t\t\t// synthesized fallback names the resource, so those stay distinct on their own.\n\t\t\tappendDedupedWarning(\n\t\t\t\twarnings,\n\t\t\t\taccountWarning ??\n\t\t\t\t\totherWarning(\n\t\t\t\t\t\toptions.providerId,\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t\t`Could not resolve the current user for '${resourceLabel(resource)}'; skipping that resource to avoid returning issues assigned to others.`,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\taccountLookupFailed = true;\n\t\t}\n\t}\n\n\tconst fallbackUserForUnscopedProject =\n\t\tscopedResources.length === 1 && usersByResourceId?.size === 1\n\t\t\t? usersByResourceId.values().next().value\n\t\t\t: undefined;\n\tconst userForProject = (project: ResourceDescriptor): string | undefined => {\n\t\tconst resourceId = resourceIdForProject(project);\n\t\tif (resourceId != null) {\n\t\t\tconst user = usersByResourceId?.get(resourceId);\n\t\t\tif (user != null) {\n\t\t\t\treturn user;\n\t\t\t}\n\t\t}\n\n\t\t// Some providers/tests return project descriptors without their parent resource id. When we have only\n\t\t// one scoped resource, re-use that sole resolved user rather than silently dropping every project.\n\t\treturn fallbackUserForUnscopedProject;\n\t};\n\t// Deliberately NOT falling back the way `userForProject` does. That fallback exists so a project with no\n\t// parent resource id still gets scoped rather than dropped, and the handle is what the drop is judged on;\n\t// the id is optional everywhere it is read, so a miss degrades to the handle instead of widening the read.\n\tconst userIdForProject = (project: ResourceDescriptor): string | undefined => {\n\t\tconst resourceId = resourceIdForProject(project);\n\t\treturn resourceId != null ? userIdsByResourceId?.get(resourceId) : undefined;\n\t};\n\n\tconst retryProjectKeys = new Set<string>();\n\tconst completedProjectKeys = new Set(priorCompletedProjects);\n\tfor (const retryProject of priorRetryProjects) {\n\t\tcompletedProjectKeys.delete(retryProject);\n\t}\n\tconst scopedProjectsWithUsers =\n\t\tusersByResourceId != null\n\t\t\t? matchedProjects.filter(project => {\n\t\t\t\t\tif (userForProject(project) != null) return true;\n\n\t\t\t\t\tconst key = projectKey(project);\n\t\t\t\t\tretryProjectKeys.add(key);\n\t\t\t\t\tcompletedProjectKeys.delete(key);\n\t\t\t\t\treturn false;\n\t\t\t\t})\n\t\t\t: matchedProjects;\n\n\t// Select the untouched window plus any earlier windows/projects that explicitly need retrying. Keys\n\t// include the parent resource so two trackers can reuse the same project id without collapsing.\n\tconst projectsByRetryKey = new Map(scopedProjectsWithUsers.map(project => [projectKey(project), project]));\n\tconst scopedProjectsByKey = new Map<string, ResourceDescriptor>();\n\tconst addScopedProject = (project: ResourceDescriptor): void => {\n\t\tconst key = projectKey(project);\n\t\tif (completedProjectKeys.has(key)) return;\n\n\t\tscopedProjectsByKey.set(key, project);\n\t};\n\tfor (const retryProject of priorRetryProjects) {\n\t\tconst project = projectsByRetryKey.get(retryProject);\n\t\tif (project != null) {\n\t\t\taddScopedProject(project);\n\t\t} else if (projectDiscoveryFailed || projectDiscoveryTruncated) {\n\t\t\tretryProjectKeys.add(retryProject);\n\t\t}\n\t}\n\tconst windowPages = new Set<number>(priorRetryPages);\n\tif (normalWindowPage != null) {\n\t\twindowPages.add(normalWindowPage);\n\t}\n\tif (!paginated && (projectDiscoveryFailed || projectDiscoveryTruncated)) {\n\t\twindowPages.add(1);\n\t}\n\tif (paginated) {\n\t\tfor (const windowPage of windowPages) {\n\t\t\tconst windowStart = (windowPage - 1) * projectsPerPage;\n\t\t\tfor (const project of scopedProjectsWithUsers.slice(windowStart, windowStart + projectsPerPage)) {\n\t\t\t\taddScopedProject(project);\n\t\t\t}\n\t\t}\n\t} else if (compositeCursor == null || priorRetryPages.length > 0) {\n\t\t// An unpaged retry-only cursor should re-read only the explicitly failed projects already added\n\t\t// above. Discovery retries still rescan the aggregate set so newly recovered projects are included.\n\t\tfor (const project of scopedProjectsWithUsers) {\n\t\t\taddScopedProject(project);\n\t\t}\n\t}\n\tconst scopedProjects = [...scopedProjectsByKey.values()];\n\tconst furthestWindowPage = windowPages.size > 0 ? Math.max(...windowPages) : normalWindowPage;\n\tconst normalWindowEnd =\n\t\tfurthestWindowPage != null ? furthestWindowPage * projectsPerPage : scopedProjectsWithUsers.length;\n\tconst nextPage =\n\t\tpaginated && furthestWindowPage != null && scopedProjectsWithUsers.length > normalWindowEnd\n\t\t\t? furthestWindowPage + 1\n\t\t\t: undefined;\n\tconst retryWindowPages = (): number[] => {\n\t\tif (!projectDiscoveryFailed && !projectDiscoveryTruncated && retryProjectKeys.size === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst pages = new Set(windowPages);\n\t\tif (pages.size === 0) {\n\t\t\t// A terminal retry has no untouched next window to identify its origin. Keep a manual window\n\t\t\t// marker so a later partial discovery can reconcile against the projects already emitted.\n\t\t\tpages.add(paginated ? Math.max(1, page - 1) : 1);\n\t\t}\n\t\treturn [...pages];\n\t};\n\tif (scopedProjects.length === 0) {\n\t\t// The discovered projects didn't intersect the requested filter/window, or every matching resource\n\t\t// failed user resolution. If discovery or account lookup was partial, the empty result is not a\n\t\t// proven-empty account — carry `fetchFailed` so the caller knows issues may be missing.\n\t\treturn emptyPage(projectDiscoveryFailed || accountLookupFailed, projectDiscoveryTruncated, {\n\t\t\tnextPage: nextPage,\n\t\t\tpages: retryWindowPages(),\n\t\t\tprojects: [...retryProjectKeys],\n\t\t\tcompletedProjects: [...completedProjectKeys],\n\t\t});\n\t}\n\n\t// A read spanning several projects is a merge, so it can only honor a key a normalized issue carries. Bound here\n\t// rather than next to the key's validation above, because the project count is only known now — while still\n\t// before any project read, so a refusal costs no request. Refused rather than served as concatenated\n\t// per-project runs, which would look ordered without being so.\n\t//\n\t// Counted over every project the READ covers, not the `scopedProjects` window this page happens to hold: the\n\t// window is `itemsPerPage` projects wide, so counting it would refuse a 20-project page and then serve the\n\t// final 1-project page of the same paginated call — the same key answered two ways, with the earlier pages'\n\t// issues missing from a read that reported success.\n\t//\n\t// Projects are not the only thing a tracker read merges: a user-scoped read asking for several relationships\n\t// issues one provider query PER relationship and unions them within each project (Jira runs one JQL drain per\n\t// filter and folds them into one map, in filter order), so a single-project page of two filters is just as\n\t// concatenated as a two-project one. Counting only projects published those runs under the requested key.\n\t// Not gated on the provider: the two trackers that don't fan out (Linear, Trello) declare `Assignee` as their\n\t// only supported filter, so a multi-filter read is already refused above and can never reach this.\n\tconst mergesFilters = options.includeAllAssignees !== true && (options.filters?.length ?? 0) > 1;\n\tconst ordering = toIssueOrdering(sort, scopedProjectsWithUsers.length > 1 || mergesFilters);\n\tif (ordering.unmergeable != null) {\n\t\twarnings.push(\n\t\t\tunmergeableIssueSortWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\tordering.unmergeable,\n\t\t\t\tscopedProjectsWithUsers.length > 1 ? 'projects' : 'filters',\n\t\t\t),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\t// One call for the whole window, so a tracker that can search several projects at once (Jira) does, instead\n\t// of paying one drain per project. Results still come back per project, which the accounting below needs.\n\tlet projectReads: IntegrationResult<ProjectIssuesDrain | undefined>[];\n\ttry {\n\t\tprojectReads = await integration.getIssuesForProjectsWithTruncationResult(\n\t\t\tscopedProjects.map(project => ({\n\t\t\t\tproject: project,\n\t\t\t\toptions: {\n\t\t\t\t\tuser: userForProject(project),\n\t\t\t\t\tuserId: userIdForProject(project),\n\t\t\t\t\tfilters: options.filters,\n\t\t\t\t\tsort: sort,\n\t\t\t\t\tstate: options.state,\n\t\t\t\t},\n\t\t\t})),\n\t\t\toptions.connectionId,\n\t\t);\n\t} catch (ex) {\n\t\tconst error = toError(ex);\n\t\tprojectReads = scopedProjects.map(() => ({ error: error }));\n\t}\n\tconst perProject = await Promise.all(\n\t\tscopedProjects.map(async (project, index) => ({\n\t\t\tproject: project,\n\t\t\t...(await runCaptured(options.providerId, domain, options.connectionId, () =>\n\t\t\t\tPromise.resolve(projectReads[index]),\n\t\t\t)),\n\t\t})),\n\t);\n\n\t// Partial project discovery means some projects' issues are missing from this page; propagate it so the\n\t// page reports fetchFailed even when every discovered project's own read succeeded.\n\tlet fetchFailed = projectDiscoveryFailed || accountLookupFailed;\n\tlet truncationRecovery: 'narrow-scope' | 'none' | undefined = projectDiscoveryTruncated ? 'none' : undefined;\n\tlet drainMetadata: CollectionMetadata | undefined;\n\tfor (const { project, value: result, warning } of perProject) {\n\t\tconst key = projectKey(project);\n\t\tconst retryProject = result == null;\n\t\tif (warning != null) {\n\t\t\t// Deduped: the per-project warning is built from the provider error alone and names no project, so a\n\t\t\t// single failing token repeats verbatim once per project in the window.\n\t\t\tappendDedupedWarning(warnings, warning);\n\t\t\tfetchFailed = true;\n\t\t\ttruncationRecovery = 'none';\n\t\t}\n\t\t// A thrown/unsupported read (e.g. Linear not-implemented) surfaces as a warning with no value;\n\t\t// mark the aggregate as fetchFailed so an empty result isn't mistaken for \"no issues\".\n\t\tif (result == null) {\n\t\t\tfetchFailed = true;\n\t\t}\n\t\tif (result != null) {\n\t\t\titems.push(...result.values);\n\t\t\tif (result.truncated) {\n\t\t\t\tconst recovery = result.recovery;\n\t\t\t\ttruncationRecovery = truncationRecovery == null || truncationRecovery === recovery ? recovery : 'none';\n\t\t\t}\n\t\t\tif (result.metadata != null) {\n\t\t\t\tdrainMetadata = mergeCollectionMetadata(drainMetadata, result.metadata);\n\t\t\t}\n\t\t}\n\t\tif (retryProject) {\n\t\t\tretryProjectKeys.add(key);\n\t\t\tcompletedProjectKeys.delete(key);\n\t\t} else {\n\t\t\t// A usable partial/truncated project is emitted once and remains structurally incomplete.\n\t\t\t// Re-running the same project cursor would normally return the same prefix and duplicate it\n\t\t\t// across facade pages; only a project that returned no value is safe to retry automatically.\n\t\t\tcompletedProjectKeys.add(key);\n\t\t}\n\t}\n\n\t// Each provider query arrived ordered by the tracker; the union of them — across projects, and across the\n\t// per-relationship queries a multi-filter read fans out into — is not, and the union is what this read\n\t// publishes. A no-op when nothing merged, since the tracker already ordered that single run.\n\tconst orderedItems = ordering.order(items);\n\n\tconst projectReadReportedTruncation = truncationRecovery != null;\n\tconst drainAssessment = assessCollectionMetadata(options.providerId, domain, options.connectionId, drainMetadata);\n\tfor (const warning of drainAssessment.warnings) {\n\t\t// A project result already supplies the recovery semantics. Replace metadata's unstructured fallback with\n\t\t// the structured warning below, while retaining specific failures and omissions.\n\t\tif (projectReadReportedTruncation && !drainAssessment.fetchFailed && warning.omission == null) continue;\n\n\t\tappendDedupedWarning(warnings, warning);\n\t}\n\tfetchFailed = fetchFailed || drainAssessment.fetchFailed;\n\tif (drainAssessment.truncated) {\n\t\ttruncationRecovery = 'none';\n\t}\n\n\tconst projectTruncated = truncationRecovery != null;\n\tconst scopeTooLarge = !fetchFailed && truncationRecovery === 'narrow-scope';\n\tif (scopeTooLarge || (!fetchFailed && projectTruncated && !warnings.some(warning => warning.omission != null))) {\n\t\tappendDedupedWarning(\n\t\t\twarnings,\n\t\t\tincompleteReadWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\tscopeTooLarge\n\t\t\t\t\t? 'Some projects hold more issues than one read can return; narrow the scope to read the rest.'\n\t\t\t\t\t: 'Some issues were omitted; the provider returned an incomplete result.',\n\t\t\t\tscopeTooLarge ? 'scope-too-large' : 'exhausted',\n\t\t\t),\n\t\t);\n\t}\n\t// A metadata omission from an earlier project asserts the read succeeded; a later one may since have failed.\n\treconcileOmissionsWithFailure(warnings, fetchFailed);\n\n\tconst retryPages = retryWindowPages();\n\tconst cursor = toIssueTrackerPageCursor({\n\t\tcurrentPage: page + 1,\n\t\tunpaged: !paginated,\n\t\tnextPage: nextPage,\n\t\tretryPages: retryPages,\n\t\tretryProjects: [...retryProjectKeys],\n\t\tcompletedProjects:\n\t\t\t(trackCompletedProjects ||\n\t\t\t\tprojectDiscoveryFailed ||\n\t\t\t\tprojectDiscoveryTruncated ||\n\t\t\t\tretryProjectKeys.size > 0) &&\n\t\t\t(retryPages.length > 0 || nextPage != null)\n\t\t\t\t? [...completedProjectKeys]\n\t\t\t\t: [],\n\t\tstate: options.state,\n\t});\n\treturn {\n\t\titems: orderedItems,\n\t\twarnings: warnings,\n\t\tpage: { currentPage: page, itemsPerPage: orderedItems.length, truncated: projectTruncated || undefined },\n\t\t// Failed-project retries alone are manual. Only an untouched project window is automatic progress.\n\t\thasMore: nextPage != null && cursor != null,\n\t\tcursor: cursor,\n\t\tfetchFailed: fetchFailed || undefined,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAM,oBAAiD;CAAC;CAAQ;CAAU;AAAK;AAE/E,eAAsB,2BACrB,KACA,SA4C2C;CAI3C,MAAM,kBAAkB,4BAA4B,QAAQ,MAAM;CAClE,MAAM,YACL,iBAAiB,YAAY,SAC5B,QAAQ,QAAQ,QAAQ,QAAQ,UAAU,QAAQ,QAAQ,gBAAgB;CAG5E,MAAM,OAAO,KAAK,IACjB,GACA,KAAK,MAAM,iBAAiB,eAAe,gBAAgB,QAAQ,MAAM,KAAK,QAAQ,QAAQ,CAAC,CAChG;CACA,MAAM,kBAAkB,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,gBAAgB,EAAE,CAAC;CAE1E,MAAM,QAAsB,CAAC;CAC7B,MAAM,WAA8B,CAAC;CACrC,MAAM,aACL,aACA,WACA,UAMqC;EACrC,MAAM,SACL,SAAS,OACN,yBAAyB;GACzB,aAAa,OAAO;GACpB,SAAS,CAAC;GACV,UAAU,MAAM;GAChB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BAAqB,UAAU,OAAO;CACvC;CACA,cAAc,eAAe,gBAAgB;CAC7C,IAAI,gBAAgB,WACnB,qBAAqB;CAGtB,MAAM,mBAAmB,sBAAsB;CAC/C,MAAM,gBAAgB,CAAC,eAAe,uBAAuB;CAC7D,IAAI,iBAAkB,CAAC,eAAe,oBAAoB,CAAC,SAAS,MAAK,YAAW,QAAQ,YAAY,IAAI,GAC3G,qBACC,UACA,sBACC,QAAQ,YACR,QACA,QAAQ,cACR,gBACG,gGACA,yEACH,gBAAgB,oBAAoB,WACrC,CACD;CAGD,8BAA8B,UAAU,WAAW;CAEnD,MAAM,aAAa,iBAAiB;CACpC,MAAM,SAAS,yBAAyB;EACvC,aAAa,OAAO;EACpB,SAAS,CAAC;EACA;EACE;EACZ,eAAe,CAAC,GAAG,gBAAgB;EACnC,oBACE,0BACA,0BACA,6BACA,iBAAiB,OAAO,OACxB,WAAW,SAAS,KAAK,YAAY,QACnC,CAAC,GAAG,oBAAoB,IACxB,CAAC;EACL,OAAO,QAAQ;CAChB,CAAC;CACD,OAAO;EACN,OAAO;EACG;EACV,MAAM;GAAE,aAAa;GAAM,cAAc,aAAa;GAAQ,WAAW,oBAAoB,KAAA;EAAU;EAEvG,SAAS,YAAY,QAAQ,UAAU;EAC/B;EACR,aAAa,eAAe,KAAA;CAC7B;AACD"}
|
|
1
|
+
{"version":3,"file":"issueTracker.js","names":[],"sources":["../../../../../plus/integrations/src/reads/issueTracker.ts"],"sourcesContent":["import type { CollectionMetadata } from '@gitkraken/provider-apis';\nimport type { IssueShape, IssueSorting, IssueStateFilter } from '@gitlens/git/models/issue.js';\nimport type { ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport { mapBounded } from '@gitlens/utils/promise.js';\nimport { assessCollectionMetadata, mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport { providerFanOutConcurrency } from '../constants.js';\nimport { toError } from '../errors.js';\nimport type { IntegrationResult } from '../models/integration.js';\nimport type { ProjectIssuesDrain } from '../models/issueReads.js';\nimport { isIssuesIntegration } from '../models/issuesIntegration.js';\nimport { IssueFilter, providersMetadata } from '../providers/models.js';\nimport { mergeCollectionMetadata, parsePageCursor } from '../providers/utils/providerPaging.js';\nimport type { ProviderPagedResult, ProviderWarning } from '../results.js';\nimport { appendDedupedWarning, reconcileOmissionsWithFailure } from '../results.js';\nimport { isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport type { ProviderReadContext } from './context.js';\nimport { parseIssueTrackerPageCursor, toIssueTrackerPageCursor } from './cursors.js';\nimport { runCaptured } from './drains.js';\nimport { projectKey, resourceIdForProject, resourceLabel, selectorMatches } from './hierarchy.utils.js';\nimport { resolveIssueSort, toIssueOrdering } from './ordering.js';\nimport {\n\tincompleteReadWarning,\n\tissueTrackerOnlySurfaceWarning,\n\totherWarning,\n\tunmergeableIssueSortWarning,\n\tunsupportedIssueSortWarning,\n\tunsupportedWarning,\n} from './warnings.js';\n\nconst issueStateFilters: readonly IssueStateFilter[] = ['open', 'closed', 'all'];\n\nexport async function listIssueTrackerIssuesPage(\n\tctx: ProviderReadContext,\n\toptions: {\n\t\tproviderId: IntegrationIds;\n\t\torg?: string;\n\t\tproject?: string;\n\t\tfilters?: IssueFilter[];\n\t\t/** Broadens the read to every assignee. Scopes to user-assigned issues when omitted. */\n\t\tincludeAllAssignees?: boolean;\n\t\t/**\n\t\t * How to order the issues, as `field:direction`. Omitted orders most-recently-updated-first where the\n\t\t * tracker can express it.\n\t\t *\n\t\t * Validated against `getSupportedFilters().issues`' sibling `issueSorts` — a tracker reports there, not\n\t\t * under the account-wide table, because resource -> project IS its only issue surface. A key it can't\n\t\t * express refuses the read rather than serving a differently-ordered list.\n\t\t *\n\t\t * One page can span SEVERAL projects, whose issues are merged here, so a key no normalized issue carries\n\t\t * (`priority`, `dueDate`, `resolved`) is refused for a multi-project page even though the tracker orders by\n\t\t * it perfectly well within one project.\n\t\t *\n\t\t * Unlike the git-host reads this one is safe to change mid-pagination: its cursor windows PROJECTS and\n\t\t * drains each to exhaustion, so which projects a round covers doesn't depend on how their issues are\n\t\t * ordered. Only the order within a page changes.\n\t\t */\n\t\tsort?: IssueSorting;\n\t\t/**\n\t\t * Which issue states to read. Omitted reads open issues only.\n\t\t *\n\t\t * Applied server-side by every project read, so it narrows each project's drain rather than the merged page.\n\t\t * Only a tracker declaring `ProviderMetadata.supportsIssueStates` can express anything but `'open'`; asking\n\t\t * another for `'closed'`/`'all'` refuses the read rather than serving its open issues.\n\t\t */\n\t\tstate?: IssueStateFilter;\n\t\tforceSync?: boolean;\n\t\tpage?: number;\n\t\tcursor?: string;\n\t\titemsPerPage?: number;\n\t\tconnectionId?: string;\n\t\t/**\n\t\t * Explicit self-managed tracker host. Used to select the instance when the requested connection has no\n\t\t * configured domain; it must come from the trusted authentication configuration, never from repository\n\t\t * or remote data. Ignored for the cloud trackers.\n\t\t */\n\t\tdomain?: string;\n\t},\n): Promise<ProviderPagedResult<IssueShape>> {\n\t// Pagination is opt-in: only window the projects when the caller actually asked to page. A caller that\n\t// passes none of page/cursor/itemsPerPage keeps the \"aggregate every matched project\" contract, so an\n\t// existing consumer that doesn't inspect `hasMore` never silently loses projects past a default window.\n\tconst compositeCursor = parseIssueTrackerPageCursor(options.cursor);\n\tconst paginated =\n\t\tcompositeCursor?.unpaged !== true &&\n\t\t(options.page != null || options.cursor != null || options.itemsPerPage != null);\n\t// A composite cursor can carry retries from earlier project windows alongside the next untouched window.\n\t// `currentPage` remains the caller-facing position; `nextPage` is the window this round should advance.\n\tconst page = Math.max(\n\t\t1,\n\t\tMath.trunc(compositeCursor?.currentPage ?? parsePageCursor(options.cursor) ?? options.page ?? 1),\n\t);\n\tconst projectsPerPage = Math.max(1, Math.trunc(options.itemsPerPage ?? 20));\n\n\tconst items: IssueShape[] = [];\n\tconst warnings: ProviderWarning[] = [];\n\tconst emptyPage = (\n\t\tfetchFailed?: boolean,\n\t\ttruncated?: boolean,\n\t\tretry?: {\n\t\t\tnextPage?: number;\n\t\t\tpages?: readonly number[];\n\t\t\tprojects?: readonly string[];\n\t\t\tcompletedProjects?: readonly string[];\n\t\t},\n\t): ProviderPagedResult<IssueShape> => {\n\t\tconst cursor =\n\t\t\tretry != null\n\t\t\t\t? toIssueTrackerPageCursor({\n\t\t\t\t\t\tcurrentPage: page + 1,\n\t\t\t\t\t\tunpaged: !paginated,\n\t\t\t\t\t\tnextPage: retry.nextPage,\n\t\t\t\t\t\tretryPages: retry.pages ?? [],\n\t\t\t\t\t\tretryProjects: retry.projects ?? [],\n\t\t\t\t\t\tcompletedProjects: retry.completedProjects ?? [],\n\t\t\t\t\t\tstate: options.state,\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t\treturn {\n\t\t\titems: items,\n\t\t\twarnings: warnings,\n\t\t\tpage: { currentPage: page, itemsPerPage: items.length, truncated: truncated || undefined },\n\t\t\t// Retry-only state is deliberately manual: advertising it as forward progress would make a\n\t\t\t// persistent provider failure spin forever in a normal `while (hasMore)` consumer. An untouched\n\t\t\t// project window remains normal forward progress even when this window failed completely.\n\t\t\thasMore: retry?.nextPage != null && cursor != null,\n\t\t\tcursor: cursor,\n\t\t\tfetchFailed: fetchFailed || undefined,\n\t\t};\n\t};\n\tconst normalWindowPage = paginated\n\t\t? (compositeCursor?.nextPage ?? (compositeCursor == null ? page : undefined))\n\t\t: undefined;\n\tconst priorRetryPages = compositeCursor?.retryPages ?? [];\n\tconst priorRetryProjects = compositeCursor?.retryProjects ?? [];\n\tconst priorCompletedProjects = compositeCursor?.completedProjects ?? [];\n\tconst trackCompletedProjects =\n\t\tpriorCompletedProjects.length > 0 || priorRetryPages.length > 0 || compositeCursor?.completedProjects != null;\n\tconst retryPagesForDiscoveryFailure = (): number[] => [\n\t\t...priorRetryPages,\n\t\t...(normalWindowPage != null ? [normalWindowPage] : compositeCursor == null ? [1] : []),\n\t];\n\tconst discoveryFailureRetry = (): {\n\t\tpages: readonly number[];\n\t\tprojects: readonly string[];\n\t\tcompletedProjects: readonly string[];\n\t} => ({\n\t\tpages: retryPagesForDiscoveryFailure(),\n\t\tprojects: priorRetryProjects,\n\t\tcompletedProjects: priorCompletedProjects,\n\t});\n\n\tif (!isIssuesHostIntegrationId(options.providerId)) {\n\t\twarnings.push(\n\t\t\tissueTrackerOnlySurfaceWarning(options.providerId, options.connectionId, 'Issue-tracker project reads'),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\tif (integration == null) {\n\t\t// A supplied connectionId or domain that no longer resolves is a broken target, not an empty account.\n\t\tconst early = ctx.earlyReturnConnectionWarnings(options.providerId, options.connectionId, options.domain);\n\t\twarnings.push(...early.warnings);\n\t\treturn emptyPage(early.fetchFailed);\n\t}\n\tif (!isIssuesIntegration(integration)) {\n\t\twarnings.push(\n\t\t\tissueTrackerOnlySurfaceWarning(options.providerId, options.connectionId, 'Issue-tracker project reads'),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\tconst domain = ctx.domainForRead(integration, options.providerId, options.connectionId, options.domain);\n\n\t// Before any upstream request: the discovery fan-outs below (resources, projects, per-resource accounts) are\n\t// three round trips, and an order this tracker can't express refuses the read whatever they return. Placed after\n\t// `domain` only because every warning carries it.\n\tconst resolvedSort = resolveIssueSort(providersMetadata[options.providerId]?.supportedIssueSorts, options.sort);\n\tif (resolvedSort.rejection != null) {\n\t\twarnings.push(\n\t\t\tunsupportedIssueSortWarning(options.providerId, domain, options.connectionId, resolvedSort.rejection),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\tconst sort = resolvedSort.sort;\n\n\t// Refused before any request for the same reason as the sort: a state the tracker can't express would otherwise\n\t// be dropped by its project reads, and their open issues published as the requested state. A value outside the\n\t// vocabulary is refused too, since `toProviderIssueStates` would read it as omitted, which means open.\n\tif (\n\t\toptions.state != null &&\n\t\t(!issueStateFilters.includes(options.state) ||\n\t\t\t(options.state !== 'open' && !providersMetadata[options.providerId]?.supportsIssueStates))\n\t) {\n\t\t// A known state this tracker can't express is an unsupported capability; a value outside the vocabulary is\n\t\t// caller input the caller fixes in the request.\n\t\twarnings.push(\n\t\t\tissueStateFilters.includes(options.state)\n\t\t\t\t? unsupportedWarning(\n\t\t\t\t\t\toptions.providerId,\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t\t`Issue state '${options.state}' is not supported by '${options.providerId}'.`,\n\t\t\t\t\t)\n\t\t\t\t: otherWarning(\n\t\t\t\t\t\toptions.providerId,\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t\t`Unknown issue state; expected one of ${issueStateFilters.join(', ')}.`,\n\t\t\t\t\t),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\t// A cursor resumed under another state than it was minted for skips what it already covered, whose other-state\n\t// issues were never read. A narrowed read only mints composite cursors, which record their state, so any other\n\t// cursor came from an open read.\n\tconst cursorState =\n\t\tcompositeCursor != null ? (compositeCursor.state ?? 'open') : options.cursor != null ? 'open' : undefined;\n\tif (cursorState != null && cursorState !== (options.state ?? 'open')) {\n\t\twarnings.push(\n\t\t\totherWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\t'The cursor belongs to a read of another issue state; start again without it.',\n\t\t\t),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\tawait ctx.forceRefreshIfRequested(integration, options.forceSync, options.connectionId);\n\n\tawait integration.getCurrentAccount({ connectionId: options.connectionId }).catch(() => undefined);\n\n\tconst { value: resources, warning: resourcesWarning } = await runCaptured(\n\t\toptions.providerId,\n\t\tdomain,\n\t\toptions.connectionId,\n\t\t() => integration.getResourcesForUserResult(options.connectionId),\n\t);\n\tif (resourcesWarning != null) {\n\t\twarnings.push(resourcesWarning);\n\t}\n\tif (resources == null || resources.length === 0) {\n\t\tconst fetchFailed = resourcesWarning != null && resources == null;\n\t\treturn emptyPage(fetchFailed, false, fetchFailed ? discoveryFailureRetry() : undefined);\n\t}\n\n\tconst scopedResources =\n\t\toptions.org != null ? resources.filter(r => selectorMatches(options.providerId, r, options.org!)) : resources;\n\tif (scopedResources.length === 0) {\n\t\treturn emptyPage();\n\t}\n\n\tconst { value: projectsResult, warning: projectsWarning } = await runCaptured(\n\t\toptions.providerId,\n\t\tdomain,\n\t\toptions.connectionId,\n\t\t() => integration.getProjectsForResourcesWithMetadataResult(scopedResources, options.connectionId),\n\t);\n\tif (projectsWarning != null) {\n\t\twarnings.push(projectsWarning);\n\t}\n\t// Partial project discovery: continue with the resources that succeeded, but surface per-resource\n\t// failures as warnings and remember to mark the page fetchFailed so the caller knows some issues may be\n\t// missing. `projectDiscoveryFailed`/`projectDiscoveryTruncated` are OR-ed into the page's\n\t// fetchFailed/truncated at every return below (a truncated-but-not-failed discovery, e.g. a paging\n\t// backstop, still means the project set is incomplete).\n\tconst projectDiscoveryAssessment = mergeAssessmentInto(\n\t\twarnings,\n\t\toptions.providerId,\n\t\tdomain,\n\t\toptions.connectionId,\n\t\tprojectsResult?.metadata,\n\t);\n\tconst projectDiscoveryFailed = projectDiscoveryAssessment.fetchFailed;\n\tconst projectDiscoveryTruncated = projectDiscoveryAssessment.truncated;\n\tconst projects = projectsResult?.values;\n\tif (projects == null || projects.length === 0) {\n\t\tconst fetchFailed = (projectsWarning != null && projectsResult == null) || projectDiscoveryFailed;\n\t\treturn emptyPage(\n\t\t\tfetchFailed,\n\t\t\tprojectDiscoveryTruncated,\n\t\t\tfetchFailed || projectDiscoveryTruncated ? discoveryFailureRetry() : undefined,\n\t\t);\n\t}\n\n\tconst matchedProjects =\n\t\toptions.project != null\n\t\t\t? projects.filter(p => selectorMatches(options.providerId, p, options.project!))\n\t\t\t: projects;\n\n\t// Validate the requested filters against what this provider supports (e.g. Linear/Trello support only\n\t// Assignee). An unsupported filter must not silently degrade — Linear/Trello ignore the requested type\n\t// and apply Assignee regardless — so warn + fetchFailed instead of returning a differently-scoped set.\n\tif (options.filters?.length) {\n\t\tconst supported = providersMetadata[options.providerId]?.supportedIssueFilters;\n\t\tconst allSupported = supported != null && options.filters.every(f => supported.includes(f));\n\t\tif (!allSupported) {\n\t\t\twarnings.push(\n\t\t\t\tunsupportedWarning(\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`One or more requested issue filters are not supported by '${options.providerId}'.`,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn emptyPage(true);\n\t\t}\n\t}\n\n\t// `includeAllAssignees` drops the user scope, but a user-relative filter (Author/Mention) is meaningless\n\t// without a user. Passing both to the provider degrades silently: Jira, seeing no user, falls through to\n\t// an unscoped project fetch and returns EVERY issue instead of the requested author's/mentions. Reject\n\t// the incompatible combination up front rather than publishing a differently-scoped set as the result.\n\tif (options.includeAllAssignees === true && options.filters?.some(f => f !== IssueFilter.Assignee)) {\n\t\twarnings.push(\n\t\t\tunsupportedWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\t`\\`includeAllAssignees\\` cannot be combined with an author/mention filter for '${options.providerId}' (those filters require a user scope).`,\n\t\t\t),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\t// Scope to the current user's assigned issues unless the caller broadens to all assignees. Resolve the\n\t// handle from each resource's own account (multi-account safe), capturing any error so its kind\n\t// (e.g. auth) is preserved rather than collapsed to a generic warning.\n\tlet usersByResourceId: Map<string, string> | undefined;\n\t// The same accounts keyed by the same resource, holding the provider's stable id rather than the handle. A\n\t// separate map rather than a widened value because the two are resolved and consumed independently: a\n\t// provider may carry an account with no id, and `scopedProjectsWithUsers` gates on the HANDLE alone, so\n\t// folding them together would drop a resource whose id happened to be missing.\n\tlet userIdsByResourceId: Map<string, string> | undefined;\n\tlet accountLookupFailed = false;\n\tif (options.includeAllAssignees !== true) {\n\t\tusersByResourceId = new Map<string, string>();\n\t\tuserIdsByResourceId = new Map<string, string>();\n\t\tconst accounts = await mapBounded(scopedResources, providerFanOutConcurrency, async resource => ({\n\t\t\tresource: resource,\n\t\t\t...(await runCaptured(options.providerId, domain, options.connectionId, () =>\n\t\t\t\tintegration.getAccountForResourceResult(resource, options.connectionId),\n\t\t\t)),\n\t\t}));\n\n\t\tfor (const { resource, value: account, warning: accountWarning } of accounts) {\n\t\t\tconst user = account?.username ?? account?.name ?? undefined;\n\t\t\tif (user != null) {\n\t\t\t\tconst resourceKey = resourceIdForProject(resource) ?? resource.key;\n\t\t\t\tusersByResourceId.set(resourceKey, user);\n\t\t\t\t// Empty-checked, not just null-checked: an account shape declares `id` as a plain string, and a\n\t\t\t\t// provider with nothing to put there sets `''` rather than omitting it — which would otherwise\n\t\t\t\t// reach a user-field query as an empty identity and match nothing.\n\t\t\t\tif (account?.id != null && account.id !== '') {\n\t\t\t\t\tuserIdsByResourceId.set(resourceKey, account.id);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Deduped: a captured `accountWarning` carries only the provider error, with no resource in its\n\t\t\t// message, so one expired token across N resources would otherwise repeat verbatim N times. The\n\t\t\t// synthesized fallback names the resource, so those stay distinct on their own.\n\t\t\tappendDedupedWarning(\n\t\t\t\twarnings,\n\t\t\t\taccountWarning ??\n\t\t\t\t\totherWarning(\n\t\t\t\t\t\toptions.providerId,\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\toptions.connectionId,\n\t\t\t\t\t\t`Could not resolve the current user for '${resourceLabel(resource)}'; skipping that resource to avoid returning issues assigned to others.`,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\taccountLookupFailed = true;\n\t\t}\n\t}\n\n\tconst fallbackUserForUnscopedProject =\n\t\tscopedResources.length === 1 && usersByResourceId?.size === 1\n\t\t\t? usersByResourceId.values().next().value\n\t\t\t: undefined;\n\tconst userForProject = (project: ResourceDescriptor): string | undefined => {\n\t\tconst resourceId = resourceIdForProject(project);\n\t\tif (resourceId != null) {\n\t\t\tconst user = usersByResourceId?.get(resourceId);\n\t\t\tif (user != null) {\n\t\t\t\treturn user;\n\t\t\t}\n\t\t}\n\n\t\t// Some providers/tests return project descriptors without their parent resource id. When we have only\n\t\t// one scoped resource, re-use that sole resolved user rather than silently dropping every project.\n\t\treturn fallbackUserForUnscopedProject;\n\t};\n\t// Deliberately NOT falling back the way `userForProject` does. That fallback exists so a project with no\n\t// parent resource id still gets scoped rather than dropped, and the handle is what the drop is judged on;\n\t// the id is optional everywhere it is read, so a miss degrades to the handle instead of widening the read.\n\tconst userIdForProject = (project: ResourceDescriptor): string | undefined => {\n\t\tconst resourceId = resourceIdForProject(project);\n\t\treturn resourceId != null ? userIdsByResourceId?.get(resourceId) : undefined;\n\t};\n\n\tconst retryProjectKeys = new Set<string>();\n\tconst completedProjectKeys = new Set(priorCompletedProjects);\n\tfor (const retryProject of priorRetryProjects) {\n\t\tcompletedProjectKeys.delete(retryProject);\n\t}\n\tconst scopedProjectsWithUsers =\n\t\tusersByResourceId != null\n\t\t\t? matchedProjects.filter(project => {\n\t\t\t\t\tif (userForProject(project) != null) return true;\n\n\t\t\t\t\tconst key = projectKey(project);\n\t\t\t\t\tretryProjectKeys.add(key);\n\t\t\t\t\tcompletedProjectKeys.delete(key);\n\t\t\t\t\treturn false;\n\t\t\t\t})\n\t\t\t: matchedProjects;\n\n\t// Select the untouched window plus any earlier windows/projects that explicitly need retrying. Keys\n\t// include the parent resource so two trackers can reuse the same project id without collapsing.\n\tconst projectsByRetryKey = new Map(scopedProjectsWithUsers.map(project => [projectKey(project), project]));\n\tconst scopedProjectsByKey = new Map<string, ResourceDescriptor>();\n\tconst addScopedProject = (project: ResourceDescriptor): void => {\n\t\tconst key = projectKey(project);\n\t\tif (completedProjectKeys.has(key)) return;\n\n\t\tscopedProjectsByKey.set(key, project);\n\t};\n\tfor (const retryProject of priorRetryProjects) {\n\t\tconst project = projectsByRetryKey.get(retryProject);\n\t\tif (project != null) {\n\t\t\taddScopedProject(project);\n\t\t} else if (projectDiscoveryFailed || projectDiscoveryTruncated) {\n\t\t\tretryProjectKeys.add(retryProject);\n\t\t}\n\t}\n\tconst windowPages = new Set<number>(priorRetryPages);\n\tif (normalWindowPage != null) {\n\t\twindowPages.add(normalWindowPage);\n\t}\n\tif (!paginated && (projectDiscoveryFailed || projectDiscoveryTruncated)) {\n\t\twindowPages.add(1);\n\t}\n\tif (paginated) {\n\t\tfor (const windowPage of windowPages) {\n\t\t\tconst windowStart = (windowPage - 1) * projectsPerPage;\n\t\t\tfor (const project of scopedProjectsWithUsers.slice(windowStart, windowStart + projectsPerPage)) {\n\t\t\t\taddScopedProject(project);\n\t\t\t}\n\t\t}\n\t} else if (compositeCursor == null || priorRetryPages.length > 0) {\n\t\t// An unpaged retry-only cursor should re-read only the explicitly failed projects already added\n\t\t// above. Discovery retries still rescan the aggregate set so newly recovered projects are included.\n\t\tfor (const project of scopedProjectsWithUsers) {\n\t\t\taddScopedProject(project);\n\t\t}\n\t}\n\tconst scopedProjects = [...scopedProjectsByKey.values()];\n\tconst furthestWindowPage = windowPages.size > 0 ? Math.max(...windowPages) : normalWindowPage;\n\tconst normalWindowEnd =\n\t\tfurthestWindowPage != null ? furthestWindowPage * projectsPerPage : scopedProjectsWithUsers.length;\n\tconst nextPage =\n\t\tpaginated && furthestWindowPage != null && scopedProjectsWithUsers.length > normalWindowEnd\n\t\t\t? furthestWindowPage + 1\n\t\t\t: undefined;\n\tconst retryWindowPages = (): number[] => {\n\t\tif (!projectDiscoveryFailed && !projectDiscoveryTruncated && retryProjectKeys.size === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst pages = new Set(windowPages);\n\t\tif (pages.size === 0) {\n\t\t\t// A terminal retry has no untouched next window to identify its origin. Keep a manual window\n\t\t\t// marker so a later partial discovery can reconcile against the projects already emitted.\n\t\t\tpages.add(paginated ? Math.max(1, page - 1) : 1);\n\t\t}\n\t\treturn [...pages];\n\t};\n\tif (scopedProjects.length === 0) {\n\t\t// The discovered projects didn't intersect the requested filter/window, or every matching resource\n\t\t// failed user resolution. If discovery or account lookup was partial, the empty result is not a\n\t\t// proven-empty account — carry `fetchFailed` so the caller knows issues may be missing.\n\t\treturn emptyPage(projectDiscoveryFailed || accountLookupFailed, projectDiscoveryTruncated, {\n\t\t\tnextPage: nextPage,\n\t\t\tpages: retryWindowPages(),\n\t\t\tprojects: [...retryProjectKeys],\n\t\t\tcompletedProjects: [...completedProjectKeys],\n\t\t});\n\t}\n\n\t// A read spanning several projects is a merge, so it can only honor a key a normalized issue carries. Bound here\n\t// rather than next to the key's validation above, because the project count is only known now — while still\n\t// before any project read, so a refusal costs no request. Refused rather than served as concatenated\n\t// per-project runs, which would look ordered without being so.\n\t//\n\t// Counted over every project the READ covers, not the `scopedProjects` window this page happens to hold: the\n\t// window is `itemsPerPage` projects wide, so counting it would refuse a 20-project page and then serve the\n\t// final 1-project page of the same paginated call — the same key answered two ways, with the earlier pages'\n\t// issues missing from a read that reported success.\n\t//\n\t// Projects are not the only thing a tracker read merges: a user-scoped read asking for several relationships\n\t// issues one provider query PER relationship and unions them within each project (Jira runs one JQL drain per\n\t// filter and folds them into one map, in filter order), so a single-project page of two filters is just as\n\t// concatenated as a two-project one. Counting only projects published those runs under the requested key.\n\t// Not gated on the provider: the two trackers that don't fan out (Linear, Trello) declare `Assignee` as their\n\t// only supported filter, so a multi-filter read is already refused above and can never reach this.\n\tconst mergesFilters = options.includeAllAssignees !== true && (options.filters?.length ?? 0) > 1;\n\tconst ordering = toIssueOrdering(sort, scopedProjectsWithUsers.length > 1 || mergesFilters);\n\tif (ordering.unmergeable != null) {\n\t\twarnings.push(\n\t\t\tunmergeableIssueSortWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\tordering.unmergeable,\n\t\t\t\tscopedProjectsWithUsers.length > 1 ? 'projects' : 'filters',\n\t\t\t),\n\t\t);\n\t\treturn emptyPage(true);\n\t}\n\n\t// One call for the whole window, so a tracker that can search several projects at once (Jira) does, instead\n\t// of paying one drain per project. Results still come back per project, which the accounting below needs.\n\tlet projectReads: IntegrationResult<ProjectIssuesDrain | undefined>[];\n\ttry {\n\t\tprojectReads = await integration.getIssuesForProjectsWithTruncationResult(\n\t\t\tscopedProjects.map(project => ({\n\t\t\t\tproject: project,\n\t\t\t\toptions: {\n\t\t\t\t\tuser: userForProject(project),\n\t\t\t\t\tuserId: userIdForProject(project),\n\t\t\t\t\tfilters: options.filters,\n\t\t\t\t\tsort: sort,\n\t\t\t\t\tstate: options.state,\n\t\t\t\t},\n\t\t\t})),\n\t\t\toptions.connectionId,\n\t\t);\n\t} catch (ex) {\n\t\tconst error = toError(ex);\n\t\tprojectReads = scopedProjects.map(() => ({ error: error }));\n\t}\n\tconst perProject = await Promise.all(\n\t\tscopedProjects.map(async (project, index) => ({\n\t\t\tproject: project,\n\t\t\t...(await runCaptured(options.providerId, domain, options.connectionId, () =>\n\t\t\t\tPromise.resolve(projectReads[index]),\n\t\t\t)),\n\t\t})),\n\t);\n\n\t// Partial project discovery means some projects' issues are missing from this page; propagate it so the\n\t// page reports fetchFailed even when every discovered project's own read succeeded.\n\tlet fetchFailed = projectDiscoveryFailed || accountLookupFailed;\n\tlet truncationRecovery: 'narrow-scope' | 'none' | undefined = projectDiscoveryTruncated ? 'none' : undefined;\n\tlet drainMetadata: CollectionMetadata | undefined;\n\tfor (const { project, value: result, warning } of perProject) {\n\t\tconst key = projectKey(project);\n\t\tconst retryProject = result == null;\n\t\tif (warning != null) {\n\t\t\t// Deduped: the per-project warning is built from the provider error alone and names no project, so a\n\t\t\t// single failing token repeats verbatim once per project in the window.\n\t\t\tappendDedupedWarning(warnings, warning);\n\t\t\tfetchFailed = true;\n\t\t\ttruncationRecovery = 'none';\n\t\t}\n\t\t// A thrown/unsupported read (e.g. Linear not-implemented) surfaces as a warning with no value;\n\t\t// mark the aggregate as fetchFailed so an empty result isn't mistaken for \"no issues\".\n\t\tif (result == null) {\n\t\t\tfetchFailed = true;\n\t\t}\n\t\tif (result != null) {\n\t\t\titems.push(...result.values);\n\t\t\tif (result.truncated) {\n\t\t\t\tconst recovery = result.recovery;\n\t\t\t\ttruncationRecovery = truncationRecovery == null || truncationRecovery === recovery ? recovery : 'none';\n\t\t\t}\n\t\t\tif (result.metadata != null) {\n\t\t\t\tdrainMetadata = mergeCollectionMetadata(drainMetadata, result.metadata);\n\t\t\t}\n\t\t}\n\t\tif (retryProject) {\n\t\t\tretryProjectKeys.add(key);\n\t\t\tcompletedProjectKeys.delete(key);\n\t\t} else {\n\t\t\t// A usable partial/truncated project is emitted once and remains structurally incomplete.\n\t\t\t// Re-running the same project cursor would normally return the same prefix and duplicate it\n\t\t\t// across facade pages; only a project that returned no value is safe to retry automatically.\n\t\t\tcompletedProjectKeys.add(key);\n\t\t}\n\t}\n\n\t// Each provider query arrived ordered by the tracker; the union of them — across projects, and across the\n\t// per-relationship queries a multi-filter read fans out into — is not, and the union is what this read\n\t// publishes. A no-op when nothing merged, since the tracker already ordered that single run.\n\tconst orderedItems = ordering.order(items);\n\n\tconst projectReadReportedTruncation = truncationRecovery != null;\n\tconst drainAssessment = assessCollectionMetadata(options.providerId, domain, options.connectionId, drainMetadata);\n\tfor (const warning of drainAssessment.warnings) {\n\t\t// A project result already supplies the recovery semantics. Replace metadata's unstructured fallback with\n\t\t// the structured warning below, while retaining specific failures and omissions.\n\t\tif (projectReadReportedTruncation && !drainAssessment.fetchFailed && warning.omission == null) continue;\n\n\t\tappendDedupedWarning(warnings, warning);\n\t}\n\tfetchFailed = fetchFailed || drainAssessment.fetchFailed;\n\tif (drainAssessment.truncated) {\n\t\ttruncationRecovery = 'none';\n\t}\n\n\tconst projectTruncated = truncationRecovery != null;\n\tconst scopeTooLarge = !fetchFailed && truncationRecovery === 'narrow-scope';\n\tif (scopeTooLarge || (!fetchFailed && projectTruncated && !warnings.some(warning => warning.omission != null))) {\n\t\tappendDedupedWarning(\n\t\t\twarnings,\n\t\t\tincompleteReadWarning(\n\t\t\t\toptions.providerId,\n\t\t\t\tdomain,\n\t\t\t\toptions.connectionId,\n\t\t\t\tscopeTooLarge\n\t\t\t\t\t? 'Some projects hold more issues than one read can return; narrow the scope to read the rest.'\n\t\t\t\t\t: 'Some issues were omitted; the provider returned an incomplete result.',\n\t\t\t\tscopeTooLarge ? 'scope-too-large' : 'exhausted',\n\t\t\t),\n\t\t);\n\t}\n\t// A metadata omission from an earlier project asserts the read succeeded; a later one may since have failed.\n\treconcileOmissionsWithFailure(warnings, fetchFailed);\n\n\tconst retryPages = retryWindowPages();\n\tconst cursor = toIssueTrackerPageCursor({\n\t\tcurrentPage: page + 1,\n\t\tunpaged: !paginated,\n\t\tnextPage: nextPage,\n\t\tretryPages: retryPages,\n\t\tretryProjects: [...retryProjectKeys],\n\t\tcompletedProjects:\n\t\t\t(trackCompletedProjects ||\n\t\t\t\tprojectDiscoveryFailed ||\n\t\t\t\tprojectDiscoveryTruncated ||\n\t\t\t\tretryProjectKeys.size > 0) &&\n\t\t\t(retryPages.length > 0 || nextPage != null)\n\t\t\t\t? [...completedProjectKeys]\n\t\t\t\t: [],\n\t\tstate: options.state,\n\t});\n\treturn {\n\t\titems: orderedItems,\n\t\twarnings: warnings,\n\t\tpage: { currentPage: page, itemsPerPage: orderedItems.length, truncated: projectTruncated || undefined },\n\t\t// Failed-project retries alone are manual. Only an untouched project window is automatic progress.\n\t\thasMore: nextPage != null && cursor != null,\n\t\tcursor: cursor,\n\t\tfetchFailed: fetchFailed || undefined,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA8BA,MAAM,oBAAiD;CAAC;CAAQ;CAAU;AAAK;AAE/E,eAAsB,2BACrB,KACA,SA4C2C;CAI3C,MAAM,kBAAkB,4BAA4B,QAAQ,MAAM;CAClE,MAAM,YACL,iBAAiB,YAAY,SAC5B,QAAQ,QAAQ,QAAQ,QAAQ,UAAU,QAAQ,QAAQ,gBAAgB;CAG5E,MAAM,OAAO,KAAK,IACjB,GACA,KAAK,MAA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
2
2
|
import { reconcileOmissionsWithFailure } from "../results.js";
|
|
3
3
|
import { mergeAssessmentInto } from "../collectionMetadata.js";
|
|
4
|
-
import { mergeCollectionMetadata } from "../providers/utils/providerPaging.js";
|
|
5
4
|
import { isGitHostIntegration, isIssuesHostIntegrationId, warnOnMissingSessionForDomain } from "../utils/integration.utils.js";
|
|
5
|
+
import { mergeCollectionMetadata } from "../providers/utils/providerPaging.js";
|
|
6
6
|
import { isRepoIdsInput, providersMetadata } from "../providers/models.js";
|
|
7
7
|
import { drainFlatPagesToRequestedPage, drainToRequestedPage, isPageNumberAdvanceable, pageToCursor, refusedPage, resolveContinuation, resolveCurrentPage, toProviderPageInfo, usableCursor } from "./paging.js";
|
|
8
8
|
import { gitHostOnlySurfaceWarning, issuesUnsupportedWarning, otherWarning, truncationWarning, unmergeableIssueSortWarning, unsupportedAccountWideIssueFiltersWarning, unsupportedIssueSortWarning, unsupportedWarning } from "./warnings.js";
|
|
@@ -57,9 +57,16 @@ async function getPullRequestsForBranches(ctx, options) {
|
|
|
57
57
|
currentAccount,
|
|
58
58
|
limit: pullRequestsForBranchLimit
|
|
59
59
|
}, void 0, options.connectionId), { warnOnMissingSession: true });
|
|
60
|
-
|
|
60
|
+
const allKeys = targets.map((t) => t.key);
|
|
61
|
+
if (warning != null) appendDedupedWarning(warnings, {
|
|
62
|
+
...warning,
|
|
63
|
+
targetKeys: allKeys
|
|
64
|
+
});
|
|
61
65
|
if (slots == null) {
|
|
62
|
-
if (warning == null) appendDedupedWarning(warnings,
|
|
66
|
+
if (warning == null) appendDedupedWarning(warnings, {
|
|
67
|
+
...unsupportedWarning(options.providerId, domain, options.connectionId, `${surface} is not supported by '${options.providerId}'.`),
|
|
68
|
+
targetKeys: allKeys
|
|
69
|
+
});
|
|
63
70
|
return {
|
|
64
71
|
items: [],
|
|
65
72
|
warnings,
|
|
@@ -70,7 +77,7 @@ async function getPullRequestsForBranches(ctx, options) {
|
|
|
70
77
|
for (let i = 0; i < targets.length; i++) {
|
|
71
78
|
const slot = slots[i];
|
|
72
79
|
if (slot.status === "rejected") {
|
|
73
|
-
appendBatchSlotWarning(warnings, options.providerId, domain, options.connectionId, slot);
|
|
80
|
+
appendBatchSlotWarning(warnings, options.providerId, domain, options.connectionId, slot, targets[i].key);
|
|
74
81
|
fetchFailed = true;
|
|
75
82
|
continue;
|
|
76
83
|
}
|