@gitkraken/core-gitlens 0.45.0 → 0.47.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 +35 -1
- package/dist/git/models/remote.js +2 -2
- package/dist/git/models/remote.js.map +1 -1
- package/dist/git/remotes/matcher.js +25 -3
- package/dist/git/remotes/matcher.js.map +1 -1
- package/dist/git/utils/branchLanded.utils.d.ts +7 -0
- package/dist/git/utils/branchLanded.utils.js +10 -1
- package/dist/git/utils/branchLanded.utils.js.map +1 -1
- package/dist/git/utils/remote.utils.d.ts +1 -0
- package/dist/git/utils/remote.utils.js +14 -5
- package/dist/git/utils/remote.utils.js.map +1 -1
- package/dist/git-cli/parsers/logParser.js +227 -468
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/parsers/refParser.js +4 -4
- package/dist/git-cli/parsers/refParser.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +5 -0
- package/dist/git-cli/providers/branches.js +25 -21
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/config.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/staging.js +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.d.ts +31 -0
- package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.js +166 -0
- package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.js.map +1 -0
- package/dist/plus/git-github/api/github.d.ts +13 -5
- package/dist/plus/git-github/api/github.js +53 -13
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +7 -1
- package/dist/plus/git-github/api/issueWrites.js +62 -32
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestWrites.d.ts +7 -3
- package/dist/plus/git-github/api/pullRequestWrites.js +120 -67
- package/dist/plus/git-github/api/pullRequestWrites.js.map +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.d.ts +44 -0
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js +199 -0
- package/dist/plus/integrations/authentication/cloudIntegrationAuthenticationProvider.js.map +1 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +7 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +53 -7
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts +2 -38
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +0 -199
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +4 -2
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +12 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
- package/dist/plus/integrations/authentication/models.d.ts +0 -1
- package/dist/plus/integrations/authentication/models.js +1 -2
- package/dist/plus/integrations/authentication/models.js.map +1 -1
- package/dist/plus/integrations/constants.d.ts +0 -10
- package/dist/plus/integrations/constants.js +1 -95
- package/dist/plus/integrations/constants.js.map +1 -1
- package/dist/plus/integrations/context.d.ts +17 -17
- package/dist/plus/integrations/index.d.ts +44 -25
- package/dist/plus/integrations/index.js +41 -8
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +24 -24
- package/dist/plus/integrations/integrationService.js +125 -34
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/lite.js +1 -1
- package/dist/plus/integrations/lite.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +81 -21
- package/dist/plus/integrations/models/actionablePullRequest.d.ts +213 -0
- package/dist/plus/integrations/models/actionablePullRequest.js +25 -0
- package/dist/plus/integrations/models/actionablePullRequest.js.map +1 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +13 -46
- package/dist/plus/integrations/models/gitHostIntegration.js +22 -8
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +11 -175
- package/dist/plus/integrations/models/integration.js +22 -76
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issueTrackerWrites.d.ts +128 -0
- package/dist/plus/integrations/models/issueTrackerWrites.js +0 -0
- package/dist/plus/integrations/models/issuesIntegration.d.ts +9 -5
- package/dist/plus/integrations/models/issuesIntegration.js +5 -3
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/models/publicIntegration.d.ts +257 -0
- package/dist/plus/integrations/models/publicIntegration.js +21 -0
- package/dist/plus/integrations/models/publicIntegration.js.map +1 -0
- package/dist/plus/integrations/providerFilters.d.ts +58 -0
- package/dist/plus/integrations/providerFilters.js.map +1 -1
- package/dist/plus/integrations/providers/actionablePullRequests.d.ts +19 -0
- package/dist/plus/integrations/providers/actionablePullRequests.js +32 -0
- package/dist/plus/integrations/providers/actionablePullRequests.js.map +1 -0
- package/dist/plus/integrations/providers/apiClients.d.ts +1 -2
- package/dist/plus/integrations/providers/apiClients.js.map +1 -1
- package/dist/plus/integrations/providers/asana.d.ts +3 -2
- package/dist/plus/integrations/providers/asana.js +2 -1
- package/dist/plus/integrations/providers/asana.js.map +1 -1
- package/dist/plus/integrations/providers/azure/azure.d.ts +1 -1
- package/dist/plus/integrations/providers/azure/azure.js +1 -1
- package/dist/plus/integrations/providers/azure/azure.utils.d.ts +10 -3
- package/dist/plus/integrations/providers/azure/azure.utils.js +5 -1
- package/dist/plus/integrations/providers/azure/azure.utils.js.map +1 -1
- package/dist/plus/integrations/providers/azure/models.d.ts +1 -5
- package/dist/plus/integrations/providers/azure/models.js +1 -1
- package/dist/plus/integrations/providers/azure/models.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOps.d.ts +8 -5
- package/dist/plus/integrations/providers/azureDevOps.js +2 -1
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +5 -4
- package/dist/plus/integrations/providers/azureDevOpsServer.js +3 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +2 -2
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/models.d.ts +1 -1
- package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket-server.d.ts +5 -4
- package/dist/plus/integrations/providers/bitbucket-server.js +2 -1
- package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket.d.ts +4 -3
- package/dist/plus/integrations/providers/bitbucket.js +2 -1
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/github/github.d.ts +0 -1
- package/dist/plus/integrations/providers/github/github.js +1 -1
- package/dist/plus/integrations/providers/github/github.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +29 -11
- package/dist/plus/integrations/providers/github.js +195 -78
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +2 -2
- package/dist/plus/integrations/providers/gitlab/gitlab.js +1 -2
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +14 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/models.d.ts +2 -10
- package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab.d.ts +7 -5
- package/dist/plus/integrations/providers/gitlab.js +2 -1
- package/dist/plus/integrations/providers/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/providers/jira-server.d.ts +4 -4
- package/dist/plus/integrations/providers/jira-server.js +3 -2
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +3 -3
- package/dist/plus/integrations/providers/jira.js +4 -3
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +3 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
- package/dist/plus/integrations/providers/jiraIssueWriteErrors.d.ts +10 -0
- package/dist/plus/integrations/providers/jiraIssueWriteErrors.js +68 -0
- package/dist/plus/integrations/providers/jiraIssueWriteErrors.js.map +1 -0
- package/dist/plus/integrations/providers/jiraIssueWrites.d.ts +40 -0
- package/dist/plus/integrations/providers/jiraIssueWrites.js +397 -0
- package/dist/plus/integrations/providers/jiraIssueWrites.js.map +1 -0
- package/dist/plus/integrations/providers/linear.d.ts +4 -3
- package/dist/plus/integrations/providers/linear.js +3 -2
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/linearIssuesEtag.d.ts +1 -1
- package/dist/plus/integrations/providers/linearIssuesEtag.js +1 -1
- package/dist/plus/integrations/providers/linearIssuesEtag.js.map +1 -1
- package/dist/plus/integrations/providers/metadata.d.ts +136 -0
- package/dist/plus/integrations/providers/metadata.js +513 -0
- package/dist/plus/integrations/providers/metadata.js.map +1 -0
- package/dist/plus/integrations/providers/models.d.ts +10 -206
- package/dist/plus/integrations/providers/models.js +8 -539
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +7 -3
- package/dist/plus/integrations/providers/providersApi.js +23 -11
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/providers/trello.d.ts +1 -1
- package/dist/plus/integrations/providers/trello.js +2 -1
- package/dist/plus/integrations/providers/trello.js.map +1 -1
- package/dist/plus/integrations/providers/utils/providerPaging.d.ts +2 -0
- package/dist/plus/integrations/providers/utils/providerPaging.js +3 -2
- package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
- package/dist/plus/integrations/providers/utils.d.ts +119 -10
- package/dist/plus/integrations/providers/utils.js +57 -3
- package/dist/plus/integrations/providers/utils.js.map +1 -1
- package/dist/plus/integrations/reads/autolinks.d.ts +1 -1
- package/dist/plus/integrations/reads/autolinks.js +1 -1
- package/dist/plus/integrations/reads/autolinks.js.map +1 -1
- package/dist/plus/integrations/reads/broaden.d.ts +1 -1
- package/dist/plus/integrations/reads/broaden.js +3 -2
- package/dist/plus/integrations/reads/broaden.js.map +1 -1
- package/dist/plus/integrations/reads/context.d.ts +1 -1
- package/dist/plus/integrations/reads/counts.d.ts +1 -88
- package/dist/plus/integrations/reads/counts.js +4 -2
- package/dist/plus/integrations/reads/counts.js.map +1 -1
- package/dist/plus/integrations/reads/currentAccount.d.ts +1 -18
- package/dist/plus/integrations/reads/currentAccount.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +4 -3
- package/dist/plus/integrations/reads/drains.js +1 -1
- package/dist/plus/integrations/reads/drains.js.map +1 -1
- package/dist/plus/integrations/reads/etag.d.ts +174 -3
- package/dist/plus/integrations/reads/etag.js +69 -14
- package/dist/plus/integrations/reads/etag.js.map +1 -1
- package/dist/plus/integrations/reads/filters.d.ts +3 -61
- package/dist/plus/integrations/reads/filters.js +1 -1
- package/dist/plus/integrations/reads/filters.js.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.d.ts +1 -1
- package/dist/plus/integrations/reads/hierarchy.js +4 -2
- package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
- package/dist/plus/integrations/reads/issueBatch.d.ts +2 -102
- package/dist/plus/integrations/reads/issueBatch.js +3 -4
- package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
- package/dist/plus/integrations/reads/issueTracker.d.ts +1 -1
- package/dist/plus/integrations/reads/issueTracker.js +4 -3
- package/dist/plus/integrations/reads/issueTracker.js.map +1 -1
- package/dist/plus/integrations/reads/issues.d.ts +1 -1
- package/dist/plus/integrations/reads/issues.js +4 -2
- package/dist/plus/integrations/reads/issues.js.map +1 -1
- package/dist/plus/integrations/reads/paging.d.ts +1 -1
- package/dist/plus/integrations/reads/paging.js +1 -1
- package/dist/plus/integrations/reads/paging.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestActivity.d.ts +1 -24
- package/dist/plus/integrations/reads/pullRequestActivity.js +2 -1
- package/dist/plus/integrations/reads/pullRequestActivity.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBatch.d.ts +2 -56
- package/dist/plus/integrations/reads/pullRequestBatch.js +23 -3
- package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestBranches.d.ts +1 -47
- package/dist/plus/integrations/reads/pullRequestBranches.js +2 -1
- package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestCheckLogs.d.ts +1 -15
- package/dist/plus/integrations/reads/pullRequestCheckLogs.js +2 -1
- package/dist/plus/integrations/reads/pullRequestCheckLogs.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequests.js +4 -2
- package/dist/plus/integrations/reads/pullRequests.js.map +1 -1
- package/dist/plus/integrations/reads/pullRequestsForCommits.d.ts +1 -16
- package/dist/plus/integrations/reads/pullRequestsForCommits.js +2 -1
- package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -1
- package/dist/plus/integrations/reads/resolveRepository.js +10 -5
- package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
- package/dist/plus/integrations/reads/searchIssues.js +2 -1
- package/dist/plus/integrations/reads/searchIssues.js.map +1 -1
- package/dist/plus/integrations/reads/searchPullRequests.js +2 -1
- package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
- package/dist/plus/integrations/reads/sweeps.d.ts +1 -1
- package/dist/plus/integrations/reads/sweeps.js +3 -2
- package/dist/plus/integrations/reads/sweeps.js.map +1 -1
- package/dist/plus/integrations/reads/warnings.d.ts +1 -1
- package/dist/plus/integrations/reads/warnings.js +1 -1
- package/dist/plus/integrations/reads/warnings.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +324 -2
- package/dist/plus/integrations/results.js.map +1 -1
- package/dist/plus/integrations/telemetry.d.ts +0 -10
- package/dist/plus/integrations/telemetry.js +0 -11
- package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
- package/dist/plus/integrations/utils/domain.utils.js +10 -2
- package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
- package/dist/plus/integrations/utils/integration.utils.d.ts +2 -6
- package/dist/plus/integrations/utils/integration.utils.js +8 -9
- package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
- package/dist/utils/env/node/exec.js +2 -2
- package/dist/utils/keys/chord.d.ts +13 -2
- package/dist/utils/keys/chord.js +76 -17
- package/dist/utils/keys/chord.js.map +1 -1
- package/dist/utils/keys/keybinding.d.ts +12 -0
- package/dist/utils/keys/keybinding.js +52 -2
- package/dist/utils/keys/keybinding.js.map +1 -1
- package/dist/utils/markdown.d.ts +21 -0
- package/dist/utils/markdown.js +33 -1
- package/dist/utils/markdown.js.map +1 -1
- package/docs/integrations.md +174 -19
- package/package.json +5 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js.map +0 -1
- package/dist/plus/integrations/telemetry.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../../../plus/integrations/src/providers/utils.ts"],"sourcesContent":["import type { AnyEntityIdentifierInput, EntityIdentifier } from '@gitkraken/provider-apis';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequest } from '@gitlens/git/models/pullRequest.js';\nimport type {\n\tIssueResourceDescriptor,\n\tRepositoryDescriptor,\n\tResourceDescriptor,\n} from '@gitlens/git/models/resourceDescriptor.js';\nimport { isIssueResourceDescriptor, isRepositoryDescriptor } from '@gitlens/git/utils/resourceDescriptor.utils.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { IntegrationIds } from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from '../constants.js';\nimport { getSingleConfiguredDomain } from '../utils/domain.utils.js';\nimport {\n\tisCloudGitSelfManagedHostIntegrationId,\n\tisGitSelfManagedHostIntegrationId,\n\tisSelfManagedHostIntegrationId,\n} from '../utils/integration.utils.js';\nimport type { AzureProjectInputDescriptor } from './azure/models.js';\nimport type { GitConfigEntityIdentifier } from './models.js';\nimport { isGitHubDotCom, isGitLabDotCom } from './models.js';\n\n// Local runtime copies of the `@gitkraken/provider-apis` entity-identifier string enums. Exported so the\n// enum-parity test can guard them against upstream drift. `EntityVersion` is an intentional subset: the\n// package only ever writes version 1, so the parity test asserts each local entry matches the SDK rather\n// than a full mirror.\nexport const EntityIdentifierProviderType = {\n\tAzure: 'azure',\n\tAzureDevOpsServer: 'azureDevOpsServer',\n\tGithub: 'github',\n\tGithubEnterprise: 'githubEnterprise',\n\tGitlab: 'gitlab',\n\tGitlabSelfHosted: 'gitlabSelfHosted',\n\tBitbucket: 'bitbucket',\n\tBitbucketServer: 'bitbucketServer',\n\tJira: 'jira',\n\tJiraServer: 'jiraServer',\n\tLinear: 'linear',\n\tTrello: 'trello',\n\tAsana: 'asana',\n} as const;\n\nexport const EntityType = {\n\tPullRequest: 'pr',\n\tIssue: 'issue',\n} as const;\n\nexport const EntityVersion = {\n\tOne: '1',\n} as const;\n\n/**\n * Forward-compatible structural shape of the host's `LaunchpadItem`. The package\n * uses this for narrowing inside {@link getEntityIdentifierInput}; the host's\n * actual `LaunchpadItem` (in `src/plus/launchpad/launchpadProvider.ts`) carries\n * many more fields. The declared shape only includes fields integrations inspect.\n */\ntype LaunchpadItem = {\n\tuuid: string;\n\ttype: 'issue' | 'pullrequest';\n\tgraphQLId?: string;\n\tprovider: { id: string; domain?: string };\n\tunderlyingPullRequest?: {\n\t\tid: string;\n\t\tproject?: { id: string; resourceName?: string };\n\t\trepository?: { id?: string };\n\t};\n};\n\nfunction isLaunchpadItem(item: IssueOrPullRequest | LaunchpadItem): item is LaunchpadItem {\n\treturn (item as LaunchpadItem).uuid !== undefined;\n}\n\nfunction isIssue(item: IssueOrPullRequest | LaunchpadItem): item is Issue {\n\treturn item.type === 'issue';\n}\n\nexport function getEntityIdentifierInput(entity: Issue | PullRequest | LaunchpadItem): AnyEntityIdentifierInput {\n\tlet entityType: (typeof EntityType)[keyof typeof EntityType] = EntityType.Issue;\n\tif (entity.type === 'pullrequest') {\n\t\tentityType = EntityType.PullRequest;\n\t}\n\n\tlet provider = fromStringToEntityIdentifierProviderType(entity.provider.id);\n\tlet domain = null;\n\tif (provider === EntityIdentifierProviderType.Github && !isGitHubDotCom(entity.provider.domain)) {\n\t\tprovider = EntityIdentifierProviderType.GithubEnterprise;\n\t\tdomain = entity.provider.domain ?? null;\n\t}\n\tif (provider === EntityIdentifierProviderType.Gitlab && !isGitLabDotCom(entity.provider.domain)) {\n\t\tprovider = EntityIdentifierProviderType.GitlabSelfHosted;\n\t\tdomain = entity.provider.domain ?? null;\n\t}\n\t// An issue read through the self-managed integration already carries the enterprise id, so the rewrites above\n\t// never see it and its host was dropped — for exactly the issues that have one. A branch association has to\n\t// name it to be read back from the right server, since two hosts routinely share `owner/repo#number`. Issues\n\t// only: a pull request's identifier is also its Launchpad uuid, which keys stored pins and snoozes, so giving it\n\t// a host would orphan every existing one.\n\tif (\n\t\tentityType === EntityType.Issue &&\n\t\tdomain == null &&\n\t\t(provider === EntityIdentifierProviderType.GithubEnterprise ||\n\t\t\tprovider === EntityIdentifierProviderType.GitlabSelfHosted ||\n\t\t\tprovider === EntityIdentifierProviderType.BitbucketServer)\n\t) {\n\t\tdomain = entity.provider.domain ?? null;\n\t}\n\tif (provider === EntityIdentifierProviderType.AzureDevOpsServer) {\n\t\tdomain = entity.provider.domain ?? null;\n\t}\n\tif (provider === EntityIdentifierProviderType.JiraServer) {\n\t\t// The host is the identity here, not a decoration: two self-hosted instances routinely issue the same\n\t\t// project and issue keys, so an identifier without it collides across them. The SDK's\n\t\t// `JiraIssueEntityIdentifierInput` says as much — its `JiraServer` arm requires `domain` where the\n\t\t// `Jira` arm requires `resourceId`.\n\t\tdomain = entity.provider.domain ?? null;\n\t}\n\n\tlet projectId = null;\n\tlet resourceId = null;\n\tlet accountOrOrgId = null;\n\tlet organizationName = null;\n\tlet repoId = null;\n\tif (provider === EntityIdentifierProviderType.Jira) {\n\t\tif (!isIssue(entity) || entity.project == null) {\n\t\t\tthrow new Error('Jira issues must have a project');\n\t\t}\n\n\t\tprojectId = entity.project.id;\n\t\tresourceId = entity.project.resourceId;\n\t} else if (provider === EntityIdentifierProviderType.JiraServer) {\n\t\tif (!isIssue(entity) || entity.project == null) {\n\t\t\tthrow new Error('Jira Server issues must have a project');\n\t\t}\n\n\t\t// `projectId` only; the SDK's `JiraServer` arm carries `domain` where Cloud carries `resourceId`, and a\n\t\t// self-hosted instance's single synthetic resource is the host the `domain` above already names.\n\t\tprojectId = entity.project.id;\n\t} else if (\n\t\tprovider === EntityIdentifierProviderType.Azure ||\n\t\tprovider === EntityIdentifierProviderType.AzureDevOpsServer\n\t) {\n\t\tconst project = isLaunchpadItem(entity) ? entity.underlyingPullRequest?.project : entity.project;\n\t\tif (project == null) {\n\t\t\tthrow new Error('Azure issues and PRs must have a project to be encoded');\n\t\t}\n\n\t\tprojectId = project.id;\n\t\torganizationName = project.resourceName;\n\t\trepoId = isLaunchpadItem(entity) ? entity.underlyingPullRequest?.repository?.id : entity.repository?.id;\n\t\tif (entityType === EntityType.PullRequest && repoId == null) {\n\t\t\tthrow new Error('Azure PRs must have a repository ID to be encoded');\n\t\t}\n\t} else if (provider === EntityIdentifierProviderType.Trello) {\n\t\tif (!isIssue(entity) || entity.project == null) {\n\t\t\tthrow new Error('Trello issues must have a board project to be encoded');\n\t\t}\n\n\t\tprojectId = entity.project.id;\n\t\t// Trello currently exposes the board but not a separate workspace/org id here. Reuse the board id in\n\t\t// both serialization slots so branch associations remain round-trippable until the upstream shape grows.\n\t\taccountOrOrgId = entity.project.resourceId || entity.project.id;\n\t} else if (provider === EntityIdentifierProviderType.Asana) {\n\t\tif (!isIssue(entity) || !entity.project?.resourceId) {\n\t\t\tthrow new Error('Asana issues must have a workspace to be encoded');\n\t\t}\n\n\t\t// An Asana task is addressed by its gid alone; the workspace is what the SDK's identifier keys it under.\n\t\taccountOrOrgId = entity.project.resourceId;\n\t} else if (\n\t\tprovider === EntityIdentifierProviderType.Bitbucket ||\n\t\tprovider === EntityIdentifierProviderType.BitbucketServer\n\t) {\n\t\trepoId = isLaunchpadItem(entity) ? entity.underlyingPullRequest?.repository?.id : entity.repository?.id;\n\t}\n\n\tlet entityId = isLaunchpadItem(entity) ? entity.graphQLId! : entity.nodeId!;\n\tif (\n\t\tprovider === EntityIdentifierProviderType.Azure ||\n\t\tprovider === EntityIdentifierProviderType.AzureDevOpsServer\n\t) {\n\t\tentityId = (isLaunchpadItem(entity) ? entity.underlyingPullRequest?.id : entity.id) as string;\n\t}\n\n\t// `AnyEntityIdentifierInput` includes the catch-all `EntityIdentifier`\n\t// variant which requires all fields, while each provider-specific variant\n\t// requires a different subset. The function builds a polymorphic value\n\t// that's correct at runtime per `provider` but the literal can't be\n\t// structurally narrowed to any single variant. The 2-step cast through\n\t// `unknown` is the documented escape for this discriminated-union pattern.\n\treturn {\n\t\taccountOrOrgId: accountOrOrgId,\n\t\torganizationName: organizationName, // needed for Azure issues and PRs, once supported\n\t\tprojectId: projectId,\n\t\trepoId: repoId ?? null, // needed for Azure and BitBucket PRs, once supported\n\t\tresourceId: resourceId, // needed for Jira issues\n\t\tprovider: provider,\n\t\tentityType: entityType,\n\t\tversion: EntityVersion.One,\n\t\tdomain: domain,\n\t\tentityId: entityId,\n\t} as unknown as AnyEntityIdentifierInput;\n}\n\nexport function getProviderIdFromEntityIdentifier(\n\tentityIdentifier: EntityIdentifier | AnyEntityIdentifierInput | GitConfigEntityIdentifier,\n): IntegrationIds | undefined {\n\tswitch (entityIdentifier.provider) {\n\t\tcase EntityIdentifierProviderType.Github:\n\t\t\treturn GitCloudHostIntegrationId.GitHub;\n\t\tcase EntityIdentifierProviderType.GithubEnterprise:\n\t\t\treturn GitSelfManagedHostIntegrationId.CloudGitHubEnterprise;\n\t\tcase EntityIdentifierProviderType.Gitlab:\n\t\t\treturn GitCloudHostIntegrationId.GitLab;\n\t\tcase EntityIdentifierProviderType.GitlabSelfHosted:\n\t\t\treturn GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;\n\t\tcase EntityIdentifierProviderType.Jira:\n\t\t\treturn IssuesCloudHostIntegrationId.Jira;\n\t\tcase EntityIdentifierProviderType.JiraServer:\n\t\t\treturn IssuesSelfManagedHostIntegrationId.JiraServer;\n\t\tcase EntityIdentifierProviderType.Linear:\n\t\t\treturn IssuesCloudHostIntegrationId.Linear;\n\t\tcase EntityIdentifierProviderType.Trello:\n\t\t\treturn IssuesCloudHostIntegrationId.Trello;\n\t\tcase EntityIdentifierProviderType.Asana:\n\t\t\treturn IssuesCloudHostIntegrationId.Asana;\n\t\tcase EntityIdentifierProviderType.Azure:\n\t\t\treturn GitCloudHostIntegrationId.AzureDevOps;\n\t\tcase EntityIdentifierProviderType.AzureDevOpsServer:\n\t\t\treturn GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\t\tcase EntityIdentifierProviderType.Bitbucket:\n\t\t\treturn GitCloudHostIntegrationId.Bitbucket;\n\t\tcase EntityIdentifierProviderType.BitbucketServer:\n\t\t\treturn isGitConfigEntityIdentifier(entityIdentifier) && entityIdentifier.metadata.isCloudEnterprise\n\t\t\t\t? GitSelfManagedHostIntegrationId.BitbucketServer\n\t\t\t\t: undefined;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nfunction fromStringToEntityIdentifierProviderType(\n\tstr: string,\n): (typeof EntityIdentifierProviderType)[keyof typeof EntityIdentifierProviderType] {\n\tswitch (str) {\n\t\tcase 'github':\n\t\t\treturn EntityIdentifierProviderType.Github;\n\t\tcase 'cloud-github-enterprise':\n\t\t\treturn EntityIdentifierProviderType.GithubEnterprise;\n\t\tcase 'cloud-gitlab-self-hosted':\n\t\t\treturn EntityIdentifierProviderType.GitlabSelfHosted;\n\t\tcase 'gitlab':\n\t\t\treturn EntityIdentifierProviderType.Gitlab;\n\t\tcase 'jira':\n\t\t\treturn EntityIdentifierProviderType.Jira;\n\t\tcase 'jira-server':\n\t\t\treturn EntityIdentifierProviderType.JiraServer;\n\t\tcase 'linear':\n\t\t\treturn EntityIdentifierProviderType.Linear;\n\t\tcase 'trello':\n\t\t\treturn EntityIdentifierProviderType.Trello;\n\t\tcase 'asana':\n\t\t\treturn EntityIdentifierProviderType.Asana;\n\t\tcase 'azure':\n\t\tcase 'azureDevOps':\n\t\tcase 'azure-devops':\n\t\t\treturn EntityIdentifierProviderType.Azure;\n\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\treturn EntityIdentifierProviderType.AzureDevOpsServer;\n\t\tcase 'bitbucket':\n\t\t\treturn EntityIdentifierProviderType.Bitbucket;\n\t\tcase 'bitbucket-server':\n\t\t\treturn EntityIdentifierProviderType.BitbucketServer;\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown provider type '${str}'`);\n\t}\n}\n\nexport function encodeIssueOrPullRequestForGitConfig(\n\tentity: Issue | PullRequest,\n\towner: RepositoryDescriptor | IssueResourceDescriptor,\n): GitConfigEntityIdentifier {\n\tconst encodedOwner: GitConfigEntityIdentifier['metadata']['owner'] = {\n\t\tkey: owner.key,\n\t\tname: owner.name,\n\t\tid: undefined,\n\t\towner: undefined,\n\t};\n\tif (isRepositoryDescriptor(owner)) {\n\t\tencodedOwner.owner = owner.owner;\n\t} else if (isIssueResourceDescriptor(owner)) {\n\t\tencodedOwner.id = owner.id;\n\t} else {\n\t\tthrow new Error('Invalid owner');\n\t}\n\n\treturn {\n\t\t...getEntityIdentifierInput(entity),\n\t\tmetadata: {\n\t\t\tid: entity.id,\n\t\t\towner: encodedOwner,\n\t\t\tcreatedDate: new Date().toISOString(),\n\t\t\tisCloudEnterprise: isCloudGitSelfManagedHostIntegrationId(entity.provider.id as IntegrationIds),\n\t\t},\n\t};\n}\n\nexport function isGitConfigEntityIdentifier(entity: unknown): entity is GitConfigEntityIdentifier {\n\treturn (\n\t\tentity != null &&\n\t\ttypeof entity === 'object' &&\n\t\t'provider' in entity &&\n\t\tentity.provider != null &&\n\t\t'entityType' in entity &&\n\t\tentity.entityType != null &&\n\t\t'version' in entity &&\n\t\tentity.version != null &&\n\t\t'entityId' in entity &&\n\t\tentity.entityId != null &&\n\t\t'metadata' in entity &&\n\t\tentity.metadata != null &&\n\t\ttypeof entity.metadata === 'object' &&\n\t\t'id' in entity.metadata &&\n\t\tentity.metadata.id != null &&\n\t\t'owner' in entity.metadata &&\n\t\tentity.metadata.owner != null &&\n\t\t'createdDate' in entity.metadata &&\n\t\tentity.metadata.createdDate != null\n\t);\n}\n\nexport function isGitConfigEntityIdentifiers(entities: unknown): entities is GitConfigEntityIdentifier[] {\n\treturn Array.isArray(entities) && entities.every(entity => isGitConfigEntityIdentifier(entity));\n}\n\nexport function decodeEntityIdentifiersFromGitConfig(str: string): GitConfigEntityIdentifier[] {\n\tconst decoded = JSON.parse(str);\n\n\tif (!isGitConfigEntityIdentifiers(decoded)) {\n\t\tdebugger;\n\t\tLogger.error('Invalid entity identifiers in git config');\n\t\treturn [];\n\t}\n\n\tfor (const decodedEntity of decoded) {\n\t\tif (\n\t\t\tdecodedEntity.provider === EntityIdentifierProviderType.Jira &&\n\t\t\t(decodedEntity.resourceId == null || decodedEntity.projectId == null)\n\t\t) {\n\t\t\tdebugger;\n\t\t\tLogger.error('Invalid Jira issue in git config');\n\t\t}\n\n\t\t// The host is the identity of a self-hosted issue (see `getEntityIdentifierInput`); without it the\n\t\t// identifier cannot be resolved against any instance and `getIssueFromGitConfigEntityIdentifier` drops it.\n\t\tif (\n\t\t\tdecodedEntity.provider === EntityIdentifierProviderType.JiraServer &&\n\t\t\t(getDomainFromEntityIdentifier(decodedEntity) == null || decodedEntity.projectId == null)\n\t\t) {\n\t\t\tdebugger;\n\t\t\tLogger.error('Invalid Jira Server issue in git config');\n\t\t}\n\t}\n\n\treturn decoded;\n}\n\n/**\n * The host a self-managed identifier names, or `undefined` for a cloud one (or a malformed self-managed one).\n * `domain` lives on some arms of `AnyEntityIdentifierInput` and on the catch-all, so the read is structural.\n */\nfunction getDomainFromEntityIdentifier(identifier: GitConfigEntityIdentifier): string | undefined {\n\tconst domain = 'domain' in identifier ? identifier.domain : undefined;\n\treturn typeof domain === 'string' && domain.trim().length > 0 ? domain : undefined;\n}\n\ninterface IssueResolvableIntegration {\n\tgetIssue(owner: unknown, id: string): Promise<Issue | undefined>;\n}\n\n/**\n * Resolves the issue a branch association names.\n *\n * `resolveIntegration` receives the identifier's `domain` alongside the integration id, so a host-keyed\n * provider resolves the instance the association was encoded for rather than whichever connection is primary\n * (#5872). It is `undefined` for a cloud provider, which has a single host.\n */\nexport async function getIssueFromGitConfigEntityIdentifier(\n\tresolveIntegration: (id: IntegrationIds, domain?: string) => Promise<IssueResolvableIntegration | undefined>,\n\tidentifier: GitConfigEntityIdentifier,\n\toptions?: {\n\t\t/** Legacy git-host associations need configured connections to prove their host is unambiguous. */\n\t\tgetConfiguredIntegrations?: (id: IntegrationIds) => readonly { domain?: string }[];\n\t\t/** Only return a value already in the local cache. No remote fetch — returns undefined on cache miss. */\n\t\tcached?: boolean;\n\t\t/**\n\t\t * Host-supplied cache reader used when {@link cached} is set. The package is cache-agnostic, so the\n\t\t * host (which owns the cache) provides this to satisfy a cache-only read. When omitted, `cached`\n\t\t * yields undefined rather than falling through to a remote fetch.\n\t\t */\n\t\tpeekCachedIssue?: (\n\t\t\tintegration: IssueResolvableIntegration | undefined,\n\t\t\tresource: ResourceDescriptor,\n\t\t\tid: string,\n\t\t) => Issue | undefined;\n\t},\n): Promise<Issue | undefined> {\n\tif (identifier.entityType !== EntityType.Issue) {\n\t\treturn undefined;\n\t}\n\n\t// TODO: Centralize where we represent all supported providers for issues\n\tif (\n\t\tidentifier.provider !== EntityIdentifierProviderType.Jira &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.JiraServer &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Linear &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Github &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Gitlab &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.GithubEnterprise &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.GitlabSelfHosted &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Bitbucket &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.BitbucketServer &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.AzureDevOpsServer &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Azure &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Trello &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Asana\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst integrationId = getProviderIdFromEntityIdentifier(identifier);\n\tif (integrationId == null) {\n\t\treturn undefined;\n\t}\n\n\tlet domain = getDomainFromEntityIdentifier(identifier);\n\tif (domain == null && isGitSelfManagedHostIntegrationId(integrationId)) {\n\t\tdomain = getSingleConfiguredDomain(options?.getConfiguredIntegrations?.(integrationId) ?? []);\n\t}\n\t// Hosts can share issue keys. Legacy git associations may omit the host, but can only be recovered when\n\t// configuration identifies exactly one; self-hosted tracker associations always require an explicit host.\n\tif (domain == null && isSelfManagedHostIntegrationId(integrationId)) {\n\t\tLogger.error(`Cannot resolve a '${integrationId}' issue from git config without an unambiguous domain`);\n\t\treturn undefined;\n\t}\n\n\tconst integration = await resolveIntegration(integrationId, domain);\n\n\tconst resource: ResourceDescriptor = {\n\t\tid: identifier.metadata.owner.id,\n\t\tkey: identifier.metadata.owner.key,\n\t\towner: identifier.metadata.owner.owner,\n\t\tname: identifier.metadata.owner.name,\n\t};\n\tconst remoteLookupId =\n\t\tidentifier.provider === EntityIdentifierProviderType.Trello ? identifier.entityId : identifier.metadata.id;\n\n\t// Cache-only read (no remote fetch). The package can't reach the host cache directly, so defer to the\n\t// host-supplied reader; without one, honor the no-fetch contract by returning undefined. For a cloud\n\t// provider the cache key is resource+id (the integration only affects the etag), so peek even when the\n\t// integration is unresolvable — a still-cached issue must survive an unconfigured/disconnected integration.\n\t// A self-managed host's key also names the host, which only a resolved integration can supply: without one\n\t// the peek would fall back to the unscoped key a cloud provider writes for the same resource, so skip it.\n\tif (options?.cached) {\n\t\tif (integration == null && isSelfManagedHostIntegrationId(integrationId)) return undefined;\n\n\t\tconst cachedIssue = options.peekCachedIssue?.(integration, resource, identifier.metadata.id);\n\t\tif (\n\t\t\tcachedIssue != null ||\n\t\t\t(identifier.provider !== EntityIdentifierProviderType.Trello &&\n\t\t\t\tidentifier.provider !== EntityIdentifierProviderType.Linear)\n\t\t) {\n\t\t\treturn cachedIssue;\n\t\t}\n\n\t\t// Two id generations coexist for these providers: Trello identifiers persisted before the stable-id\n\t\t// switch carry the board-local `idShort` in `metadata.id` while the cache is keyed by the stable card\n\t\t// id (`entityId`); Linear identifiers persisted before `Issue.id` became the human identifier carry\n\t\t// the UUID in `metadata.id` while fresh cache entries key by the identifier — and vice versa, the\n\t\t// UUID always survives in `entityId` (via `nodeId`). Peeking both keys resolves either generation.\n\t\treturn options.peekCachedIssue?.(integration, resource, identifier.entityId);\n\t}\n\n\tif (integration == null) {\n\t\treturn undefined;\n\t}\n\n\treturn integration.getIssue(resource, remoteLookupId);\n}\n\nexport function getIssueOwner(\n\tissue: IssueShape,\n): RepositoryDescriptor | IssueResourceDescriptor | AzureProjectInputDescriptor | undefined {\n\tconst isAzure = ['azure', GitCloudHostIntegrationId.AzureDevOps, 'azure-devops'].includes(issue.provider.id);\n\treturn issue.repository\n\t\t? {\n\t\t\t\tkey: `${issue.repository.owner}/${issue.repository.repo}`,\n\t\t\t\towner: issue.repository.owner,\n\t\t\t\tname: issue.repository.repo,\n\t\t\t}\n\t\t: issue.project\n\t\t\t? {\n\t\t\t\t\tkey: isAzure ? issue.project.id : issue.project.resourceId,\n\t\t\t\t\tid: isAzure ? issue.project.id : issue.project.resourceId,\n\t\t\t\t\towner: isAzure ? issue.project.resourceName : undefined,\n\t\t\t\t\tname: isAzure ? issue.project.name : issue.project.resourceName,\n\t\t\t\t}\n\t\t\t: undefined;\n}\n"],"mappings":";;;;;;;AAgCA,MAAa,+BAA+B;CAC3C,OAAO;CACP,mBAAmB;CACnB,QAAQ;CACR,kBAAkB;CAClB,QAAQ;CACR,kBAAkB;CAClB,WAAW;CACX,iBAAiB;CACjB,MAAM;CACN,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,OAAO;AACR;AAEA,MAAa,aAAa;CACzB,aAAa;CACb,OAAO;AACR;AAEA,MAAa,gBAAgB,EAC5B,KAAK,IACN;AAoBA,SAAS,gBAAgB,MAAiE;CACzF,OAAQ,KAAuB,SAAS,KAAA;AACzC;AAEA,SAAS,QAAQ,MAAyD;CACzE,OAAO,KAAK,SAAS;AACtB;AAEA,SAAgB,yBAAyB,QAAuE;CAC/G,IAAI,aAA2D,WAAW;CAC1E,IAAI,OAAO,SAAS,eACnB,aAAa,WAAW;CAGzB,IAAI,WAAW,yCAAyC,OAAO,SAAS,EAAE;CAC1E,IAAI,SAAS;CACb,IAAI,aAAa,6BAA6B,UAAU,CAAC,eAAe,OAAO,SAAS,MAAM,GAAG;EAChG,WAAW,6BAA6B;EACxC,SAAS,OAAO,SAAS,UAAU;CACpC;CACA,IAAI,aAAa,6BAA6B,UAAU,CAAC,eAAe,OAAO,SAAS,MAAM,G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;EAC/C,OAAO,UAAU,MAAM,QAAQ,eAAe,KAAA;EAC9C,MAAM,UAAU,MAAM,QAAQ,OAAO,MAAM,QAAQ;CACpD,IACC,KAAA;AACL"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../../../plus/integrations/src/providers/utils.ts"],"sourcesContent":["import type { AnyEntityIdentifierInput } from '@gitkraken/provider-apis';\nimport { EntityIdentifierUtils } from '@gitkraken/provider-apis';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequest } from '@gitlens/git/models/pullRequest.js';\nimport type {\n\tIssueResourceDescriptor,\n\tRepositoryDescriptor,\n\tResourceDescriptor,\n} from '@gitlens/git/models/resourceDescriptor.js';\nimport { isIssueResourceDescriptor, isRepositoryDescriptor } from '@gitlens/git/utils/resourceDescriptor.utils.js';\nimport { Logger } from '@gitlens/utils/logger.js';\nimport type { IntegrationIds } from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from '../constants.js';\nimport { getSingleConfiguredDomain } from '../utils/domain.utils.js';\nimport {\n\tisCloudGitSelfManagedHostIntegrationId,\n\tisGitSelfManagedHostIntegrationId,\n\tisSelfManagedHostIntegrationId,\n} from '../utils/integration.utils.js';\nimport { isGitHubDotCom, isGitLabDotCom } from './metadata.js';\n\n// Local runtime copies of the `@gitkraken/provider-apis` entity-identifier string enums. Exported so the\n// enum-parity test can guard them against upstream drift. `EntityVersion` is an intentional subset: the\n// package only ever writes version 1, so the parity test asserts each local entry matches the SDK rather\n// than a full mirror.\nexport const EntityIdentifierProviderType = {\n\tAzure: 'azure',\n\tAzureDevOpsServer: 'azureDevOpsServer',\n\tGithub: 'github',\n\tGithubEnterprise: 'githubEnterprise',\n\tGitlab: 'gitlab',\n\tGitlabSelfHosted: 'gitlabSelfHosted',\n\tBitbucket: 'bitbucket',\n\tBitbucketServer: 'bitbucketServer',\n\tJira: 'jira',\n\tJiraServer: 'jiraServer',\n\tLinear: 'linear',\n\tTrello: 'trello',\n\tAsana: 'asana',\n} as const;\n\nexport const EntityType = {\n\tPullRequest: 'pr',\n\tIssue: 'issue',\n} as const;\n\nexport const EntityVersion = {\n\tOne: '1',\n} as const;\n\nexport type EntityIdentifierProviderType =\n\t(typeof EntityIdentifierProviderType)[keyof typeof EntityIdentifierProviderType];\nexport type EntityType = (typeof EntityType)[keyof typeof EntityType];\n\n/**\n * A decoded entity identifier: a GitLens-neutral copy of provider-apis' `EntityIdentifier`, so consumers never name\n * the SDK. `version` names every version the SDK decodes, unlike {@link EntityVersion}, which lists the one written.\n */\nexport interface EntityIdentifier {\n\tprovider: EntityIdentifierProviderType;\n\tentityType: EntityType;\n\tversion: '0' | '1';\n\tdomain: string | null;\n\tresourceId: string | null;\n\taccountOrOrgId: string | null;\n\torganizationName: string | null;\n\tprojectId: string | null;\n\trepoId: string | null;\n\tentityId: string;\n}\n\n/** The fields an entity identifier can carry. Which of them one needs depends on its provider and entity type. */\ninterface EntityIdentifierValues {\n\tversion?: '0' | '1';\n\tentityId: string;\n\tdomain?: string | null;\n\tresourceId?: string | null;\n\taccountOrOrgId?: string | null;\n\torganizationName?: string | null;\n\tprojectId?: string | null;\n\trepoId?: string | null;\n}\n\n/**\n * An entity identifier's fields as {@link getEntityIdentifierInput} builds them for any issue or pull request, and as\n * a branch-issue association stores them ({@link GitConfigEntityIdentifier}): every provider (Linear included), with\n * each provider-specific field nullable. Not every one of these encodes; {@link EntityIdentifierInput} is the subset\n * that does.\n */\nexport interface EntityIdentifierFields extends EntityIdentifierValues {\n\tprovider: EntityIdentifierProviderType;\n\tentityType: EntityType;\n}\n\ntype ProviderOf<K extends keyof typeof EntityIdentifierProviderType> = (typeof EntityIdentifierProviderType)[K];\n\n/**\n * What {@link encodeEntityIdentifier} accepts: one arm per provider and entity type the codec encodes, each requiring\n * the fields the codec refuses to encode without. Linear isn't encodable at all, and Jira and Trello have no pull\n * requests. The fields an arm doesn't require may still be present (as {@link getEntityIdentifierInput} fills them),\n * and are ignored.\n */\nexport type EntityIdentifierInput =\n\t| (EntityIdentifierValues & {\n\t\t\tprovider: ProviderOf<'Github' | 'GithubEnterprise' | 'Gitlab' | 'GitlabSelfHosted'>;\n\t\t\tentityType: EntityType;\n\t })\n\t| (EntityIdentifierValues & {\n\t\t\tprovider: ProviderOf<'Bitbucket' | 'BitbucketServer'>;\n\t\t\tentityType: EntityType;\n\t\t\trepoId: string;\n\t })\n\t| (EntityIdentifierValues & {\n\t\t\tprovider: ProviderOf<'Azure' | 'AzureDevOpsServer'>;\n\t\t\tentityType: typeof EntityType.Issue;\n\t\t\torganizationName: string;\n\t\t\tprojectId: string;\n\t })\n\t| (EntityIdentifierValues & {\n\t\t\tprovider: ProviderOf<'Azure' | 'AzureDevOpsServer'>;\n\t\t\tentityType: typeof EntityType.PullRequest;\n\t\t\torganizationName: string;\n\t\t\tprojectId: string;\n\t\t\trepoId: string;\n\t })\n\t| (EntityIdentifierValues & {\n\t\t\tprovider: ProviderOf<'Jira' | 'JiraServer'>;\n\t\t\tentityType: typeof EntityType.Issue;\n\t\t\tprojectId: string;\n\t })\n\t| (EntityIdentifierValues & {\n\t\t\tprovider: ProviderOf<'Trello'>;\n\t\t\tentityType: typeof EntityType.Issue;\n\t\t\taccountOrOrgId: string;\n\t\t\tprojectId: string;\n\t });\n\n/** The {@link EntityIdentifierInput} arms for a pull request: what a pull request's identifier encodes as. */\nexport type PullRequestEntityIdentifierInput = EntityIdentifierInput & { entityType: typeof EntityType.PullRequest };\n\n/** A branch-issue association as git config stores it: the identifier's fields plus what resolves it back. */\nexport type GitConfigEntityIdentifier = EntityIdentifierFields & {\n\tmetadata: {\n\t\tid: string;\n\t\towner: { key: string; name: string; id: string | undefined; owner: string | undefined };\n\t\tcreatedDate: string;\n\t\tisCloudEnterprise?: boolean;\n\t};\n};\n\n/** Encodes an entity identifier into the string form Launchpad keys pins/snoozes by and drafts store. */\nexport function encodeEntityIdentifier(entity: EntityIdentifierInput): string {\n\t// Each arm mirrors one of the SDK's, but the SDK's string enums are nominal, so its input can't be named without\n\t// them.\n\treturn EntityIdentifierUtils.encode(entity as unknown as AnyEntityIdentifierInput);\n}\n\n/** Decodes an identifier written by {@link encodeEntityIdentifier}; throws on a malformed one. */\nexport function decodeEntityIdentifier(encoded: string): EntityIdentifier {\n\treturn EntityIdentifierUtils.decode(encoded);\n}\n\n/**\n * Forward-compatible structural shape of the host's `LaunchpadItem`. The package\n * uses this for narrowing inside {@link getEntityIdentifierInput}; the host's\n * actual `LaunchpadItem` (in `src/plus/launchpad/launchpadProvider.ts`) carries\n * many more fields. The declared shape only includes fields integrations inspect.\n */\ntype LaunchpadItem = {\n\tuuid: string;\n\ttype: 'issue' | 'pullrequest';\n\tgraphQLId?: string;\n\tprovider: { id: string; domain?: string };\n\tunderlyingPullRequest?: {\n\t\tid: string;\n\t\tproject?: { id: string; resourceName?: string };\n\t\trepository?: { id?: string };\n\t};\n};\n\nfunction isLaunchpadItem(item: IssueOrPullRequest | LaunchpadItem): item is LaunchpadItem {\n\treturn (item as LaunchpadItem).uuid !== undefined;\n}\n\nfunction isIssue(item: IssueOrPullRequest | LaunchpadItem): item is Issue {\n\treturn item.type === 'issue';\n}\n\n/**\n * The identifier fields of an issue or pull request. A pull request's are checked to encode (see\n * {@link toPullRequestEntityIdentifierInput}), so they can go straight to {@link encodeEntityIdentifier}.\n */\nexport function getEntityIdentifierInput(entity: PullRequest): PullRequestEntityIdentifierInput;\nexport function getEntityIdentifierInput(entity: Issue | PullRequest | LaunchpadItem): EntityIdentifierFields;\nexport function getEntityIdentifierInput(\n\tentity: Issue | PullRequest | LaunchpadItem,\n): EntityIdentifierFields | PullRequestEntityIdentifierInput {\n\tlet entityType: EntityType = EntityType.Issue;\n\tif (entity.type === 'pullrequest') {\n\t\tentityType = EntityType.PullRequest;\n\t}\n\n\tlet provider = fromStringToEntityIdentifierProviderType(entity.provider.id);\n\tlet domain = null;\n\tif (provider === EntityIdentifierProviderType.Github && !isGitHubDotCom(entity.provider.domain)) {\n\t\tprovider = EntityIdentifierProviderType.GithubEnterprise;\n\t\tdomain = entity.provider.domain ?? null;\n\t}\n\tif (provider === EntityIdentifierProviderType.Gitlab && !isGitLabDotCom(entity.provider.domain)) {\n\t\tprovider = EntityIdentifierProviderType.GitlabSelfHosted;\n\t\tdomain = entity.provider.domain ?? null;\n\t}\n\t// An issue read through the self-managed integration already carries the enterprise id, so the rewrites above\n\t// never see it and its host was dropped — for exactly the issues that have one. A branch association has to\n\t// name it to be read back from the right server, since two hosts routinely share `owner/repo#number`. Issues\n\t// only: a pull request's identifier is also its Launchpad uuid, which keys stored pins and snoozes, so giving it\n\t// a host would orphan every existing one.\n\tif (\n\t\tentityType === EntityType.Issue &&\n\t\tdomain == null &&\n\t\t(provider === EntityIdentifierProviderType.GithubEnterprise ||\n\t\t\tprovider === EntityIdentifierProviderType.GitlabSelfHosted ||\n\t\t\tprovider === EntityIdentifierProviderType.BitbucketServer)\n\t) {\n\t\tdomain = entity.provider.domain ?? null;\n\t}\n\tif (provider === EntityIdentifierProviderType.AzureDevOpsServer) {\n\t\tdomain = entity.provider.domain ?? null;\n\t}\n\tif (provider === EntityIdentifierProviderType.JiraServer) {\n\t\t// The host is the identity here, not a decoration: two self-hosted instances routinely issue the same\n\t\t// project and issue keys, so an identifier without it collides across them. The SDK's\n\t\t// `JiraIssueEntityIdentifierInput` says as much — its `JiraServer` arm requires `domain` where the\n\t\t// `Jira` arm requires `resourceId`.\n\t\tdomain = entity.provider.domain ?? null;\n\t}\n\n\tlet projectId = null;\n\tlet resourceId = null;\n\tlet accountOrOrgId = null;\n\tlet organizationName = null;\n\tlet repoId = null;\n\tif (provider === EntityIdentifierProviderType.Jira) {\n\t\tif (!isIssue(entity) || entity.project == null) {\n\t\t\tthrow new Error('Jira issues must have a project');\n\t\t}\n\n\t\tprojectId = entity.project.id;\n\t\tresourceId = entity.project.resourceId;\n\t} else if (provider === EntityIdentifierProviderType.JiraServer) {\n\t\tif (!isIssue(entity) || entity.project == null) {\n\t\t\tthrow new Error('Jira Server issues must have a project');\n\t\t}\n\n\t\t// `projectId` only; the SDK's `JiraServer` arm carries `domain` where Cloud carries `resourceId`, and a\n\t\t// self-hosted instance's single synthetic resource is the host the `domain` above already names.\n\t\tprojectId = entity.project.id;\n\t} else if (\n\t\tprovider === EntityIdentifierProviderType.Azure ||\n\t\tprovider === EntityIdentifierProviderType.AzureDevOpsServer\n\t) {\n\t\tconst project = isLaunchpadItem(entity) ? entity.underlyingPullRequest?.project : entity.project;\n\t\tif (project == null) {\n\t\t\tthrow new Error('Azure issues and PRs must have a project to be encoded');\n\t\t}\n\n\t\tprojectId = project.id;\n\t\torganizationName = project.resourceName;\n\t\trepoId = isLaunchpadItem(entity) ? entity.underlyingPullRequest?.repository?.id : entity.repository?.id;\n\t\tif (entityType === EntityType.PullRequest && repoId == null) {\n\t\t\tthrow new Error('Azure PRs must have a repository ID to be encoded');\n\t\t}\n\t} else if (provider === EntityIdentifierProviderType.Trello) {\n\t\tif (!isIssue(entity) || entity.project == null) {\n\t\t\tthrow new Error('Trello issues must have a board project to be encoded');\n\t\t}\n\n\t\tprojectId = entity.project.id;\n\t\t// Trello currently exposes the board but not a separate workspace/org id here. Reuse the board id in\n\t\t// both serialization slots so branch associations remain round-trippable until the upstream shape grows.\n\t\taccountOrOrgId = entity.project.resourceId || entity.project.id;\n\t} else if (provider === EntityIdentifierProviderType.Asana) {\n\t\tif (!isIssue(entity) || !entity.project?.resourceId) {\n\t\t\tthrow new Error('Asana issues must have a workspace to be encoded');\n\t\t}\n\n\t\t// An Asana task is addressed by its gid alone; the workspace is what the SDK's identifier keys it under.\n\t\taccountOrOrgId = entity.project.resourceId;\n\t} else if (\n\t\tprovider === EntityIdentifierProviderType.Bitbucket ||\n\t\tprovider === EntityIdentifierProviderType.BitbucketServer\n\t) {\n\t\trepoId = isLaunchpadItem(entity) ? entity.underlyingPullRequest?.repository?.id : entity.repository?.id;\n\t}\n\n\tlet entityId = isLaunchpadItem(entity) ? entity.graphQLId! : entity.nodeId!;\n\tif (\n\t\tprovider === EntityIdentifierProviderType.Azure ||\n\t\tprovider === EntityIdentifierProviderType.AzureDevOpsServer\n\t) {\n\t\tentityId = (isLaunchpadItem(entity) ? entity.underlyingPullRequest?.id : entity.id) as string;\n\t}\n\n\tconst fields: EntityIdentifierFields = {\n\t\taccountOrOrgId: accountOrOrgId,\n\t\torganizationName: organizationName, // needed for Azure issues and PRs, once supported\n\t\tprojectId: projectId,\n\t\trepoId: repoId ?? null, // needed for Azure and BitBucket PRs, once supported\n\t\tresourceId: resourceId, // needed for Jira issues\n\t\tprovider: provider,\n\t\tentityType: entityType,\n\t\tversion: EntityVersion.One,\n\t\tdomain: domain,\n\t\tentityId: entityId,\n\t};\n\treturn entityType === EntityType.PullRequest && !isLaunchpadItem(entity)\n\t\t? toPullRequestEntityIdentifierInput(fields)\n\t\t: fields;\n}\n\n/**\n * Narrows a pull request's identifier fields to the arm the codec encodes it by, throwing (as the codec would) when a\n * field that arm requires is missing.\n */\nfunction toPullRequestEntityIdentifierInput(fields: EntityIdentifierFields): PullRequestEntityIdentifierInput {\n\tconst { provider, organizationName, projectId, repoId } = fields;\n\tswitch (provider) {\n\t\tcase EntityIdentifierProviderType.Github:\n\t\tcase EntityIdentifierProviderType.GithubEnterprise:\n\t\tcase EntityIdentifierProviderType.Gitlab:\n\t\tcase EntityIdentifierProviderType.GitlabSelfHosted:\n\t\t\treturn { ...fields, provider: provider, entityType: EntityType.PullRequest };\n\t\tcase EntityIdentifierProviderType.Bitbucket:\n\t\tcase EntityIdentifierProviderType.BitbucketServer:\n\t\t\tif (repoId == null) throw new Error('Bitbucket PRs must have a repository ID to be encoded');\n\n\t\t\treturn { ...fields, provider: provider, entityType: EntityType.PullRequest, repoId: repoId };\n\t\tcase EntityIdentifierProviderType.Azure:\n\t\tcase EntityIdentifierProviderType.AzureDevOpsServer:\n\t\t\tif (organizationName == null || projectId == null || repoId == null) {\n\t\t\t\tthrow new Error('Azure PRs must have an organization, a project and a repository ID to be encoded');\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...fields,\n\t\t\t\tprovider: provider,\n\t\t\t\tentityType: EntityType.PullRequest,\n\t\t\t\torganizationName: organizationName,\n\t\t\t\tprojectId: projectId,\n\t\t\t\trepoId: repoId,\n\t\t\t};\n\t\tdefault:\n\t\t\tthrow new Error(`Pull requests from '${provider}' can't be encoded`);\n\t}\n}\n\nexport function getProviderIdFromEntityIdentifier(\n\tentityIdentifier: EntityIdentifier | EntityIdentifierFields | EntityIdentifierInput | GitConfigEntityIdentifier,\n): IntegrationIds | undefined {\n\tswitch (entityIdentifier.provider) {\n\t\tcase EntityIdentifierProviderType.Github:\n\t\t\treturn GitCloudHostIntegrationId.GitHub;\n\t\tcase EntityIdentifierProviderType.GithubEnterprise:\n\t\t\treturn GitSelfManagedHostIntegrationId.CloudGitHubEnterprise;\n\t\tcase EntityIdentifierProviderType.Gitlab:\n\t\t\treturn GitCloudHostIntegrationId.GitLab;\n\t\tcase EntityIdentifierProviderType.GitlabSelfHosted:\n\t\t\treturn GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;\n\t\tcase EntityIdentifierProviderType.Jira:\n\t\t\treturn IssuesCloudHostIntegrationId.Jira;\n\t\tcase EntityIdentifierProviderType.JiraServer:\n\t\t\treturn IssuesSelfManagedHostIntegrationId.JiraServer;\n\t\tcase EntityIdentifierProviderType.Linear:\n\t\t\treturn IssuesCloudHostIntegrationId.Linear;\n\t\tcase EntityIdentifierProviderType.Trello:\n\t\t\treturn IssuesCloudHostIntegrationId.Trello;\n\t\tcase EntityIdentifierProviderType.Asana:\n\t\t\treturn IssuesCloudHostIntegrationId.Asana;\n\t\tcase EntityIdentifierProviderType.Azure:\n\t\t\treturn GitCloudHostIntegrationId.AzureDevOps;\n\t\tcase EntityIdentifierProviderType.AzureDevOpsServer:\n\t\t\treturn GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\t\tcase EntityIdentifierProviderType.Bitbucket:\n\t\t\treturn GitCloudHostIntegrationId.Bitbucket;\n\t\tcase EntityIdentifierProviderType.BitbucketServer:\n\t\t\treturn isGitConfigEntityIdentifier(entityIdentifier) && entityIdentifier.metadata.isCloudEnterprise\n\t\t\t\t? GitSelfManagedHostIntegrationId.BitbucketServer\n\t\t\t\t: undefined;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nfunction fromStringToEntityIdentifierProviderType(str: string): EntityIdentifierProviderType {\n\tswitch (str) {\n\t\tcase 'github':\n\t\t\treturn EntityIdentifierProviderType.Github;\n\t\tcase 'cloud-github-enterprise':\n\t\t\treturn EntityIdentifierProviderType.GithubEnterprise;\n\t\tcase 'cloud-gitlab-self-hosted':\n\t\t\treturn EntityIdentifierProviderType.GitlabSelfHosted;\n\t\tcase 'gitlab':\n\t\t\treturn EntityIdentifierProviderType.Gitlab;\n\t\tcase 'jira':\n\t\t\treturn EntityIdentifierProviderType.Jira;\n\t\tcase 'jira-server':\n\t\t\treturn EntityIdentifierProviderType.JiraServer;\n\t\tcase 'linear':\n\t\t\treturn EntityIdentifierProviderType.Linear;\n\t\tcase 'trello':\n\t\t\treturn EntityIdentifierProviderType.Trello;\n\t\tcase 'asana':\n\t\t\treturn EntityIdentifierProviderType.Asana;\n\t\tcase 'azure':\n\t\tcase 'azureDevOps':\n\t\tcase 'azure-devops':\n\t\t\treturn EntityIdentifierProviderType.Azure;\n\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\treturn EntityIdentifierProviderType.AzureDevOpsServer;\n\t\tcase 'bitbucket':\n\t\t\treturn EntityIdentifierProviderType.Bitbucket;\n\t\tcase 'bitbucket-server':\n\t\t\treturn EntityIdentifierProviderType.BitbucketServer;\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown provider type '${str}'`);\n\t}\n}\n\n/**\n * Builds the git-config form of a branch-issue association from an issue (the only thing production callers pass).\n * A pull request is accepted but goes through {@link getEntityIdentifierInput}, so it throws when its provider can't\n * encode pull requests (Jira, Trello, Linear) or a field its arm requires is missing (Bitbucket and Bitbucket Server\n * need `repoId`; Azure and Azure DevOps Server need an organization, a project and `repoId`).\n */\nexport function encodeIssueOrPullRequestForGitConfig(\n\tentity: Issue | PullRequest,\n\towner: RepositoryDescriptor | IssueResourceDescriptor,\n): GitConfigEntityIdentifier {\n\tconst encodedOwner: GitConfigEntityIdentifier['metadata']['owner'] = {\n\t\tkey: owner.key,\n\t\tname: owner.name,\n\t\tid: undefined,\n\t\towner: undefined,\n\t};\n\tif (isRepositoryDescriptor(owner)) {\n\t\tencodedOwner.owner = owner.owner;\n\t} else if (isIssueResourceDescriptor(owner)) {\n\t\tencodedOwner.id = owner.id;\n\t} else {\n\t\tthrow new Error('Invalid owner');\n\t}\n\n\treturn {\n\t\t...getEntityIdentifierInput(entity),\n\t\tmetadata: {\n\t\t\tid: entity.id,\n\t\t\towner: encodedOwner,\n\t\t\tcreatedDate: new Date().toISOString(),\n\t\t\tisCloudEnterprise: isCloudGitSelfManagedHostIntegrationId(entity.provider.id as IntegrationIds),\n\t\t},\n\t};\n}\n\nexport function isGitConfigEntityIdentifier(entity: unknown): entity is GitConfigEntityIdentifier {\n\treturn (\n\t\tentity != null &&\n\t\ttypeof entity === 'object' &&\n\t\t'provider' in entity &&\n\t\tentity.provider != null &&\n\t\t'entityType' in entity &&\n\t\tentity.entityType != null &&\n\t\t'version' in entity &&\n\t\tentity.version != null &&\n\t\t'entityId' in entity &&\n\t\tentity.entityId != null &&\n\t\t'metadata' in entity &&\n\t\tentity.metadata != null &&\n\t\ttypeof entity.metadata === 'object' &&\n\t\t'id' in entity.metadata &&\n\t\tentity.metadata.id != null &&\n\t\t'owner' in entity.metadata &&\n\t\tentity.metadata.owner != null &&\n\t\t'createdDate' in entity.metadata &&\n\t\tentity.metadata.createdDate != null\n\t);\n}\n\nexport function isGitConfigEntityIdentifiers(entities: unknown): entities is GitConfigEntityIdentifier[] {\n\treturn Array.isArray(entities) && entities.every(entity => isGitConfigEntityIdentifier(entity));\n}\n\nexport function decodeEntityIdentifiersFromGitConfig(str: string): GitConfigEntityIdentifier[] {\n\tconst decoded = JSON.parse(str);\n\n\tif (!isGitConfigEntityIdentifiers(decoded)) {\n\t\tdebugger;\n\t\tLogger.error('Invalid entity identifiers in git config');\n\t\treturn [];\n\t}\n\n\tfor (const decodedEntity of decoded) {\n\t\tif (\n\t\t\tdecodedEntity.provider === EntityIdentifierProviderType.Jira &&\n\t\t\t(decodedEntity.resourceId == null || decodedEntity.projectId == null)\n\t\t) {\n\t\t\tdebugger;\n\t\t\tLogger.error('Invalid Jira issue in git config');\n\t\t}\n\n\t\t// The host is the identity of a self-hosted issue (see `getEntityIdentifierInput`); without it the\n\t\t// identifier cannot be resolved against any instance and `getIssueFromGitConfigEntityIdentifier` drops it.\n\t\tif (\n\t\t\tdecodedEntity.provider === EntityIdentifierProviderType.JiraServer &&\n\t\t\t(getDomainFromEntityIdentifier(decodedEntity) == null || decodedEntity.projectId == null)\n\t\t) {\n\t\t\tdebugger;\n\t\t\tLogger.error('Invalid Jira Server issue in git config');\n\t\t}\n\t}\n\n\treturn decoded;\n}\n\n/**\n * The host a self-managed identifier names, or `undefined` for a cloud one (or a malformed self-managed one).\n * `domain` lives on some arms of `AnyEntityIdentifierInput` and on the catch-all, so the read is structural.\n */\nfunction getDomainFromEntityIdentifier(identifier: GitConfigEntityIdentifier): string | undefined {\n\tconst domain = 'domain' in identifier ? identifier.domain : undefined;\n\treturn typeof domain === 'string' && domain.trim().length > 0 ? domain : undefined;\n}\n\ninterface IssueResolvableIntegration {\n\tgetIssue(owner: unknown, id: string): Promise<Issue | undefined>;\n}\n\n/**\n * Resolves the issue a branch association names.\n *\n * `resolveIntegration` receives the identifier's `domain` alongside the integration id, so a host-keyed\n * provider resolves the instance the association was encoded for rather than whichever connection is primary\n * (#5872). It is `undefined` for a cloud provider, which has a single host.\n */\nexport async function getIssueFromGitConfigEntityIdentifier(\n\tresolveIntegration: (id: IntegrationIds, domain?: string) => Promise<IssueResolvableIntegration | undefined>,\n\tidentifier: GitConfigEntityIdentifier,\n\toptions?: {\n\t\t/** Legacy git-host associations need configured connections to prove their host is unambiguous. */\n\t\tgetConfiguredIntegrations?: (id: IntegrationIds) => readonly { domain?: string }[];\n\t\t/** Only return a value already in the local cache. No remote fetch — returns undefined on cache miss. */\n\t\tcached?: boolean;\n\t\t/**\n\t\t * Host-supplied cache reader used when {@link cached} is set. The package is cache-agnostic, so the\n\t\t * host (which owns the cache) provides this to satisfy a cache-only read. When omitted, `cached`\n\t\t * yields undefined rather than falling through to a remote fetch.\n\t\t */\n\t\tpeekCachedIssue?: (\n\t\t\tintegration: IssueResolvableIntegration | undefined,\n\t\t\tresource: ResourceDescriptor,\n\t\t\tid: string,\n\t\t) => Issue | undefined;\n\t},\n): Promise<Issue | undefined> {\n\tif (identifier.entityType !== EntityType.Issue) {\n\t\treturn undefined;\n\t}\n\n\t// TODO: Centralize where we represent all supported providers for issues\n\tif (\n\t\tidentifier.provider !== EntityIdentifierProviderType.Jira &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.JiraServer &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Linear &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Github &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Gitlab &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.GithubEnterprise &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.GitlabSelfHosted &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Bitbucket &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.BitbucketServer &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.AzureDevOpsServer &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Azure &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Trello &&\n\t\tidentifier.provider !== EntityIdentifierProviderType.Asana\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst integrationId = getProviderIdFromEntityIdentifier(identifier);\n\tif (integrationId == null) {\n\t\treturn undefined;\n\t}\n\n\tlet domain = getDomainFromEntityIdentifier(identifier);\n\tif (domain == null && isGitSelfManagedHostIntegrationId(integrationId)) {\n\t\tdomain = getSingleConfiguredDomain(options?.getConfiguredIntegrations?.(integrationId) ?? []);\n\t}\n\t// Hosts can share issue keys. Legacy git associations may omit the host, but can only be recovered when\n\t// configuration identifies exactly one; self-hosted tracker associations always require an explicit host.\n\tif (domain == null && isSelfManagedHostIntegrationId(integrationId)) {\n\t\tLogger.error(`Cannot resolve a '${integrationId}' issue from git config without an unambiguous domain`);\n\t\treturn undefined;\n\t}\n\n\tconst integration = await resolveIntegration(integrationId, domain);\n\n\tconst resource: ResourceDescriptor = {\n\t\tid: identifier.metadata.owner.id,\n\t\tkey: identifier.metadata.owner.key,\n\t\towner: identifier.metadata.owner.owner,\n\t\tname: identifier.metadata.owner.name,\n\t};\n\tconst remoteLookupId =\n\t\tidentifier.provider === EntityIdentifierProviderType.Trello ? identifier.entityId : identifier.metadata.id;\n\n\t// Cache-only read (no remote fetch). The package can't reach the host cache directly, so defer to the\n\t// host-supplied reader; without one, honor the no-fetch contract by returning undefined. For a cloud\n\t// provider the cache key is resource+id (the integration only affects the etag), so peek even when the\n\t// integration is unresolvable — a still-cached issue must survive an unconfigured/disconnected integration.\n\t// A self-managed host's key also names the host, which only a resolved integration can supply: without one\n\t// the peek would fall back to the unscoped key a cloud provider writes for the same resource, so skip it.\n\tif (options?.cached) {\n\t\tif (integration == null && isSelfManagedHostIntegrationId(integrationId)) return undefined;\n\n\t\tconst cachedIssue = options.peekCachedIssue?.(integration, resource, identifier.metadata.id);\n\t\tif (\n\t\t\tcachedIssue != null ||\n\t\t\t(identifier.provider !== EntityIdentifierProviderType.Trello &&\n\t\t\t\tidentifier.provider !== EntityIdentifierProviderType.Linear)\n\t\t) {\n\t\t\treturn cachedIssue;\n\t\t}\n\n\t\t// Two id generations coexist for these providers: Trello identifiers persisted before the stable-id\n\t\t// switch carry the board-local `idShort` in `metadata.id` while the cache is keyed by the stable card\n\t\t// id (`entityId`); Linear identifiers persisted before `Issue.id` became the human identifier carry\n\t\t// the UUID in `metadata.id` while fresh cache entries key by the identifier — and vice versa, the\n\t\t// UUID always survives in `entityId` (via `nodeId`). Peeking both keys resolves either generation.\n\t\treturn options.peekCachedIssue?.(integration, resource, identifier.entityId);\n\t}\n\n\tif (integration == null) {\n\t\treturn undefined;\n\t}\n\n\treturn integration.getIssue(resource, remoteLookupId);\n}\n\n/** An Azure DevOps project as {@link getIssueOwner} names it: the organization as `owner`, the project as `name`. */\nexport interface AzureProjectInputDescriptor extends ResourceDescriptor {\n\towner: string;\n\tname: string;\n}\n\nexport function getIssueOwner(\n\tissue: IssueShape,\n): RepositoryDescriptor | IssueResourceDescriptor | AzureProjectInputDescriptor | undefined {\n\tconst isAzure = ['azure', GitCloudHostIntegrationId.AzureDevOps, 'azure-devops'].includes(issue.provider.id);\n\treturn issue.repository\n\t\t? {\n\t\t\t\tkey: `${issue.repository.owner}/${issue.repository.repo}`,\n\t\t\t\towner: issue.repository.owner,\n\t\t\t\tname: issue.repository.repo,\n\t\t\t}\n\t\t: issue.project\n\t\t\t? {\n\t\t\t\t\tkey: isAzure ? issue.project.id : issue.project.resourceId,\n\t\t\t\t\tid: isAzure ? issue.project.id : issue.project.resourceId,\n\t\t\t\t\towner: isAzure ? issue.project.resourceName : undefined,\n\t\t\t\t\tname: isAzure ? issue.project.name : issue.project.resourceName,\n\t\t\t\t}\n\t\t\t: undefined;\n}\n"],"mappings":";;;;;;;;AA+BA,MAAa,+BAA+B;CAC3C,OAAO;CACP,mBAAmB;CACnB,QAAQ;CACR,kBAAkB;CAClB,QAAQ;CACR,kBAAkB;CAClB,WAAW;CACX,iBAAiB;CACjB,MAAM;CACN,YAAY;CACZ,QAAQ;CACR,QAAQ;CACR,OAAO;AACR;AAEA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M,WAAW,MAAM,GAAG,MAAM,WAAW;EACnD,OAAO,MAAM,WAAW;EACxB,MAAM,MAAM,WAAW;CACxB,IACC,MAAM,UACL;EACA,KAAK,UAAU,MAAM,QAAQ,KAAK,MAAM,QAAQ;EAChD,IAAI,UAAU,MAAM,QAAQ,KAAK,MAAM,QAAQ;EAC/C,OAAO,UAAU,MAAM,QAAQ,eAAe,KAAA;EAC9C,MAAM,UAAU,MAAM,QAAQ,OAAO,MAAM,QAAQ;CACpD,IACC,KAAA;AACL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefSet } from "../../../git/models/autolink.js";
|
|
2
|
-
import { ProviderReadContext } from "./context.js";
|
|
3
2
|
import { GetAutolinkReferencesOptions } from "../manager.js";
|
|
3
|
+
import { ProviderReadContext } from "./context.js";
|
|
4
4
|
//#region ../plus/integrations/src/reads/autolinks.d.ts
|
|
5
5
|
export declare function getAutolinkReferences(ctx: ProviderReadContext, options: GetAutolinkReferencesOptions): Promise<RefSet | undefined>;
|
|
6
6
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../constants.js";
|
|
2
2
|
import { isIncompleteCollection } from "../collectionMetadata.js";
|
|
3
|
-
import { isIssuesIntegration } from "../models/
|
|
3
|
+
import { isIssuesIntegration } from "../models/publicIntegration.js";
|
|
4
4
|
import { createIssueAutolinkReferences } from "../providers/utils/issueAutolinks.js";
|
|
5
5
|
//#region ../plus/integrations/src/reads/autolinks.ts
|
|
6
6
|
async function getAutolinkReferences(ctx, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autolinks.js","names":[],"sources":["../../../../../plus/integrations/src/reads/autolinks.ts"],"sourcesContent":["import type { RefSet } from '@gitlens/git/models/autolink.js';\nimport { isIncompleteCollection } from '../collectionMetadata.js';\nimport { IssuesCloudHostIntegrationId, IssuesSelfManagedHostIntegrationId } from '../constants.js';\nimport type { GetAutolinkReferencesOptions } from '../manager.js';\nimport { isIssuesIntegration } from '../models/
|
|
1
|
+
{"version":3,"file":"autolinks.js","names":[],"sources":["../../../../../plus/integrations/src/reads/autolinks.ts"],"sourcesContent":["import type { RefSet } from '@gitlens/git/models/autolink.js';\nimport { isIncompleteCollection } from '../collectionMetadata.js';\nimport { IssuesCloudHostIntegrationId, IssuesSelfManagedHostIntegrationId } from '../constants.js';\nimport type { GetAutolinkReferencesOptions } from '../manager.js';\nimport { isIssuesIntegration } from '../models/publicIntegration.js';\nimport { createIssueAutolinkReferences } from '../providers/utils/issueAutolinks.js';\nimport type { ProviderReadContext } from './context.js';\n\nexport async function getAutolinkReferences(\n\tctx: ProviderReadContext,\n\toptions: GetAutolinkReferencesOptions,\n): Promise<RefSet | undefined> {\n\tif (\n\t\toptions.providerId !== IssuesCloudHostIntegrationId.Jira &&\n\t\toptions.providerId !== IssuesSelfManagedHostIntegrationId.JiraServer\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(options.providerId, options.connectionId, options.domain);\n\tif (integration == null || !isIssuesIntegration(integration)) return undefined;\n\n\ttry {\n\t\tawait ctx.forceRefreshIfRequested(integration, options.forceSync, options.connectionId, {\n\t\t\tthrowOnFailure: true,\n\t\t});\n\t} catch {\n\t\treturn undefined;\n\t} finally {\n\t\tif (options.forceSync) {\n\t\t\t// Not the refresh's own drop (`beginForcedRefresh`, before the sync): this one, at completion, retires the\n\t\t\t// discovery reads other callers started while the refresh was pending, including when it failed, so a\n\t\t\t// per-token catalog read with the token being replaced does not outlive the refresh the caller asked for.\n\t\t\tintegration.invalidateDiscoveryForConnection(options.connectionId);\n\t\t}\n\t}\n\n\tconst result = await integration.getUncachedDiscoveryResult(() => true, options.connectionId);\n\tconst discovery = result?.value;\n\tif (\n\t\tresult?.error != null ||\n\t\tdiscovery?.resources == null ||\n\t\tdiscovery.projects == null ||\n\t\tdiscovery.generation !==\n\t\t\tintegration.getSessionDiscoveryGeneration(\n\t\t\t\tdiscovery.sessionId,\n\t\t\t\toptions.connectionId,\n\t\t\t\tdiscovery.sessionCloud,\n\t\t\t) ||\n\t\tisIncompleteCollection(discovery.projects.metadata)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst refs: RefSet[1] = [];\n\tfor (const project of discovery.projects.values) {\n\t\tif (options.providerId === IssuesSelfManagedHostIntegrationId.JiraServer && project.key === project.id) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst resource = discovery.resources.find(r => r.id === project.resourceId);\n\t\tif (resource == null || typeof resource.name !== 'string' || typeof resource.url !== 'string') return undefined;\n\n\t\trefs.push(\n\t\t\t...createIssueAutolinkReferences(project.key, `${resource.url}/browse/${project.key}-<num>`, {\n\t\t\t\t...resource,\n\t\t\t\tname: resource.name,\n\t\t\t}),\n\t\t);\n\t}\n\n\treturn [{ id: integration.id, name: integration.name, domain: integration.domain, icon: integration.icon }, refs];\n}\n"],"mappings":";;;;;AAQA,eAAsB,sBACrB,KACA,SAC8B;CAC9B,IACC,QAAQ,eAAA,UACR,QAAQ,eAAA,eAER;CAGD,MAAM,cAAc,MAAM,IAAI,sBAAsB,QAAQ,YAAY,QAAQ,cAAc,QAAQ,MAAM;CAC5G,IAAI,eAAe,QAAQ,CAAC,oBAAoB,WAAW,GAAG,OAAO,KAAA;CAErE,IAAI;EACH,MAAM,IAAI,wBAAwB,aAAa,QAAQ,WAAW,QAAQ,cAAc,EACvF,gBAAgB,KACjB,CAAC;CACF,QAAQ;EACP;CACD,UAAU;EACT,IAAI,QAAQ,WAIX,YAAY,iCAAiC,QAAQ,YAAY;CAEnE;CAEA,MAAM,SAAS,MAAM,YAAY,iCAAiC,MAAM,QAAQ,YAAY;CAC5F,MAAM,YAAY,QAAQ;CAC1B,IACC,QAAQ,SAAS,QACjB,WAAW,aAAa,QACxB,UAAU,YAAY,QACtB,UAAU,eACT,YAAY,8BACX,UAAU,WACV,QAAQ,cACR,UAAU,YACX,KACD,uBAAuB,UAAU,SAAS,QAAQ,GAElD;CAGD,MAAM,OAAkB,CAAC;CACzB,KAAK,MAAM,WAAW,UAAU,SAAS,QAAQ;EAChD,IAAI,QAAQ,eAAA,iBAAgE,QAAQ,QAAQ,QAAQ,IACnG;EAGD,MAAM,WAAW,UAAU,UAAU,MAAK,MAAK,EAAE,OAAO,QAAQ,UAAU;EAC1E,IAAI,YAAY,QAAQ,OAAO,SAAS,SAAS,YAAY,OAAO,SAAS,QAAQ,UAAU,OAAO,KAAA;EAEtG,KAAK,KACJ,GAAG,8BAA8B,QAAQ,KAAK,GAAG,SAAS,IAAI,UAAU,QAAQ,IAAI,SAAS;GAC5F,GAAG;GACH,MAAM,SAAS;EAChB,CAAC,CACF;CACD;CAEA,OAAO,CAAC;EAAE,IAAI,YAAY;EAAI,MAAM,YAAY;EAAM,QAAQ,YAAY;EAAQ,MAAM,YAAY;CAAK,GAAG,IAAI;AACjH"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IssueShape } from "../../../git/models/issue.js";
|
|
2
2
|
import { ProviderBroadenResult } from "../results.js";
|
|
3
|
-
import { ProviderReadContext } from "./context.js";
|
|
4
3
|
import { ProviderBroadenOrg } from "../manager.js";
|
|
4
|
+
import { ProviderReadContext } from "./context.js";
|
|
5
5
|
//#region ../plus/integrations/src/reads/broaden.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* The issue-broadening fan-out: every visible issue across a set of orgs, one page at a time.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { mapBounded } from "../../../utils/promise.js";
|
|
2
2
|
import { effectiveIssueSort } from "../../../git/utils/issue.utils.js";
|
|
3
|
-
import "../constants.js";
|
|
4
3
|
import { appendDedupedWarning } from "../results.js";
|
|
5
4
|
import { mergeAssessmentInto } from "../collectionMetadata.js";
|
|
5
|
+
import "../providers/utils/providerPaging.js";
|
|
6
6
|
import { hostFromDomain } from "../utils/domain.utils.js";
|
|
7
|
-
import {
|
|
7
|
+
import { isIssuesHostIntegrationId } from "../utils/integration.utils.js";
|
|
8
|
+
import { isGitHostIntegration } from "../models/publicIntegration.js";
|
|
8
9
|
import { resolveContinuation, toProviderPageInfo, usableCursor } from "./paging.js";
|
|
9
10
|
import { getBroadenIssuesCursor, isBroadenIssuesOrgExhausted, toBroadenIssuesCursor } from "./cursors.js";
|
|
10
11
|
import { gitHostOnlySurfaceWarning, issueSearchCapResultWarning, issuesUnsupportedWarning, noConnectionWarning, otherWarning, truncationWarning, unsupportedIssueSearchCriteriaWarning, unusableSearchScopeMessage } from "./warnings.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broaden.js","names":[],"sources":["../../../../../plus/integrations/src/reads/broaden.ts"],"sourcesContent":["import type { IssueShape } from '@gitlens/git/models/issue.js';\nimport { effectiveIssueSort } from '@gitlens/git/utils/issue.utils.js';\nimport { mapBounded } from '@gitlens/utils/promise.js';\nimport { mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport { providerFanOutConcurrency } from '../constants.js';\nimport type { ProviderBroadenOrg } from '../manager.js';\nimport type { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { ProviderReposInput } from '../providers/models.js';\nimport type { ProviderBroadenResult, ProviderWarning } from '../results.js';\nimport { appendDedupedWarning } from '../results.js';\nimport { hostFromDomain } from '../utils/domain.utils.js';\nimport { isGitHostIntegration, isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport type { ProviderReadContext } from './context.js';\nimport type { BroadenIssuesExhaustedOrg, BroadenIssuesOrgCursor } from './cursors.js';\nimport { getBroadenIssuesCursor, isBroadenIssuesOrgExhausted, toBroadenIssuesCursor } from './cursors.js';\nimport { drainRepositories, runCaptured } from './drains.js';\nimport { resolveIssueSearchScope, supportsFilteredIssueSearch } from './filters.js';\nimport { resolveContinuation, toProviderPageInfo, usableCursor } from './paging.js';\nimport {\n\tgitHostOnlySurfaceWarning,\n\tissueSearchCapResultWarning,\n\tissuesUnsupportedWarning,\n\tnoConnectionWarning,\n\totherWarning,\n\ttruncationWarning,\n\tunsupportedIssueSearchCriteriaWarning,\n\tunusableSearchScopeMessage,\n} from './warnings.js';\n\n/**\n * The issue-broadening fan-out: every visible issue across a set of orgs, one page at a time.\n *\n * What makes this its own read rather than a variant of `listIssuesPage` is that one logical page spans several\n * provider positions — one per org — so its continuation is a per-org cursor BUNDLE (see `cursors.ts`) and its\n * failure attribution is per provider across those orgs. Both are the reason a page number alone can't address a\n * later page, and why {@link broadenIssues} walks prior pages itself when given only `page`.\n *\n * Each org slice runs on ONE OF TWO ENGINES, chosen by what the provider declares (#5804):\n * - the org-scoped FILTERED SEARCH where the provider has one (GitHub/GHE): one request per page, no repositories\n * needed at all, since the search reaches the scope by naming the org;\n * - the REPOSITORY DRAIN plus the SDK's repo-scoped read where it doesn't (Azure DevOps, GitLab): up to 100\n * requests to enumerate the org, and a read whose over-limit recovery walk can spend 128 more per repository\n * and still return an incomplete set.\n *\n * Measured by running this read against the live API, three times per engine per org (median shown; each\n * engine returned a byte-identical result set on all three, so the sets below are not sampling noise):\n *\n * | | repo drain + SDK read | org-scoped search |\n * | --- | --- | --- |\n * | BELOW the ceiling (146 issues) | 9.3s, 11 requests, 146 issues | 6.2s, 2 requests, 146 issues |\n * | ABOVE it (1.475 issues, 217 repos) | 111s, 133 requests, 1.118 issues | 40s, 10 requests, 1.000 issues |\n * | ...of the 1.000 most recently updated | 644 | 1.000 |\n * | ...omissions reported | 99 × `recovery-budget`, no count | 1, carrying `totalCount: 1474` |\n *\n * BELOW the ceiling the two return the IDENTICAL SET (verified as set equality), so there the swap is a straight\n * saving and nothing else. ABOVE it they return DIFFERENT SETS — overlapping on 644 items, so the divergence is\n * not confined to the edge.\n *\n * Above the ceiling the search returns FEWER items and is nonetheless the more useful of the two, which is the\n * whole reason to prefer it: its 1.000 are exactly the 1.000 most recently updated (again set equality against a\n * ceiling-free enumeration, not a count), whereas the SDK read's 1.118 are an arbitrary subset — 474 of them from\n * beyond that window, at the cost of omitting 356 issues that ARE in it. Its recovery walk does not close the gap\n * it spends the budget on: all 99 of its omissions were exhausted budget.\n *\n * The second difference is what a consumer can SAY about the gap. At the ceiling the search succeeds and reports\n * one quantified omission (`issueSearchCapResultWarning` carries `totalCount`, `limit` and the order the window\n * was selected under), so a consumer can render \"1.474 matched, showing the 1.000 most recently updated\". The\n * SDK read reports one `recovery-budget` omission per exhausted repository, none of which carries how many issues\n * were missed — incompleteness that can be announced but not quantified.\n *\n * Note the time saving is the SMALLER half of this: 1.5× below the ceiling and 2.8× above it, against 5.5× and\n * 13.3× fewer requests. The request count is what matters for a rate limit shared with every other read.\n *\n * The public surface is the SAME on both: the options, the per-org cursor bundle, the `ProviderAttribution`\n * split, the warning dedupe and the return type. A consumer needs to know which engine ran only insofar as the\n * warnings say so.\n *\n * Broadening means ALL VISIBLE, and each engine expresses that differently — `includeAllAssignees: true` on the\n * SDK read, an OMITTED `relationships` on the search. Both resolve to no assignee constraint at all, so\n * unassigned issues ARE included. The search's equivalent is NOT `['any-assignee']`: `assignee:*` means \"has some\n * assignee\" and would silently exclude every unassigned issue, which is the opposite of broadening.\n *\n * Takes no `sort`, unlike `listIssuesPage` and `searchIssuesPage`. One logical page here spans several orgs, each\n * at its own provider position in a cursor bundle, so honoring an order across them would need a k-way merge with\n * a buffer per org rather than a sort of what arrived — the page is a slice of several independent walks, not a\n * union of one round's results. The search engine still orders each org's OWN query (it must: a ceiling policy of\n * \"the N most recent\" is only correct under a guaranteed order), so a slice is ordered where the merged page is\n * not. `searchIssuesPage({ repos, criteria: { sort } })` answers the ordered version of this question for a\n * caller that knows its repositories.\n */\n\nexport interface BroadenIssuesOptions {\n\torgs: ProviderBroadenOrg[];\n\tpage?: number;\n\tcursor?: string;\n\tforceSync?: boolean;\n}\n\n/** One org slice of the fan-out: its issues plus the position and health the aggregation keys the bundle by. */\ninterface BroadenSlice {\n\titems: IssueShape[];\n\twarnings: ProviderWarning[];\n\tbroadenedProviderIds: IntegrationIds[];\n\tproviderId: IntegrationIds;\n\torg: string;\n\tconnectionId?: string;\n\tdomain?: string;\n\tnextCursor?: string;\n\tretryPage?: number;\n\thasMore: boolean;\n\texhausted: boolean;\n\tfetchFailed: boolean;\n\ttruncated: boolean;\n}\n\n/**\n * Accumulates provider attribution across the rounds of a page-number traversal.\n *\n * The three sets are mutually exclusive per provider and the ordering rules are what keep them so: a provider\n * that failed in one round but broadened in another is INCOMPLETE, not failed, whichever round reported first.\n */\nclass ProviderAttribution {\n\tprivate readonly broadened = new Set<IntegrationIds>();\n\tprivate readonly failed = new Set<IntegrationIds>();\n\tprivate readonly incomplete = new Set<IntegrationIds>();\n\n\tmerge(result: ProviderBroadenResult<IssueShape>): void {\n\t\tfor (const providerId of result.failedProviderIds) {\n\t\t\tif (this.broadened.has(providerId) || result.broadenedProviderIds.includes(providerId)) {\n\t\t\t\tthis.incomplete.add(providerId);\n\t\t\t} else {\n\t\t\t\tthis.failed.add(providerId);\n\t\t\t}\n\t\t}\n\t\tfor (const providerId of result.incompleteProviderIds) {\n\t\t\tthis.failed.delete(providerId);\n\t\t\tthis.incomplete.add(providerId);\n\t\t}\n\t\tfor (const providerId of result.broadenedProviderIds) {\n\t\t\tthis.broadened.add(providerId);\n\t\t\tif (this.failed.delete(providerId)) {\n\t\t\t\tthis.incomplete.add(providerId);\n\t\t\t}\n\t\t}\n\t}\n\n\ttoResultFields(): Pick<\n\t\tProviderBroadenResult<IssueShape>,\n\t\t'broadenedProviderIds' | 'failedProviderIds' | 'incompleteProviderIds'\n\t> {\n\t\treturn {\n\t\t\tbroadenedProviderIds: [...this.broadened],\n\t\t\tfailedProviderIds: [...this.failed],\n\t\t\tincompleteProviderIds: [...this.incomplete],\n\t\t};\n\t}\n}\n\nexport async function broadenIssues(\n\tctx: ProviderReadContext,\n\toptions: BroadenIssuesOptions,\n): Promise<ProviderBroadenResult<IssueShape>> {\n\tconst page = Math.max(1, Math.trunc(options.page ?? 1));\n\n\t// Kepler's existing contract persists only a page number. When no opaque continuation was supplied,\n\t// advance through prior pages internally so cursor-only providers still return the requested page.\n\t// Each recursive call below carries a cursor, so it bypasses this block and performs exactly one round.\n\tif (options.cursor == null && page > 1) {\n\t\treturn traverseToRequestedPage(ctx, options, page);\n\t}\n\n\tconst results = await mapBounded(options.orgs, providerFanOutConcurrency, org =>\n\t\treadOrgSlice(ctx, options, org, page),\n\t);\n\n\tconst items: IssueShape[] = [];\n\tconst warnings: ProviderWarning[] = [];\n\tconst broadenedProviderIds = new Set<IntegrationIds>();\n\tconst problemProviderIds = new Set<IntegrationIds>();\n\tconst cursors: BroadenIssuesOrgCursor[] = [];\n\tconst exhausted: BroadenIssuesExhaustedOrg[] = [];\n\tlet hasMore = false;\n\tlet fetchFailed = false;\n\tlet truncated = false;\n\tfor (const result of results) {\n\t\tif (result == null) {\n\t\t\tcontinue;\n\t\t}\n\n\t\titems.push(...result.items);\n\t\t// Deduped across orgs: several orgs of one provider commonly fail the same way (one expired token, one\n\t\t// rate limit), producing the identical warning per slice, and the array's contract is that no two entries\n\t\t// are equal — `traverseToRequestedPage` already dedupes when it folds these same warnings across rounds.\n\t\tfor (const warning of result.warnings) {\n\t\t\tappendDedupedWarning(warnings, warning);\n\t\t}\n\t\tfor (const id of result.broadenedProviderIds) {\n\t\t\tbroadenedProviderIds.add(id);\n\t\t}\n\t\tif (result.nextCursor != null || result.retryPage != null) {\n\t\t\tcursors.push({\n\t\t\t\tproviderId: result.providerId,\n\t\t\t\torg: result.org,\n\t\t\t\tconnectionId: result.connectionId,\n\t\t\t\tdomain: result.domain,\n\t\t\t\tcursor: result.nextCursor,\n\t\t\t\tretryPage: result.retryPage,\n\t\t\t});\n\t\t}\n\t\tif (result.exhausted) {\n\t\t\texhausted.push({\n\t\t\t\tproviderId: result.providerId,\n\t\t\t\torg: result.org,\n\t\t\t\tconnectionId: result.connectionId,\n\t\t\t\tdomain: result.domain,\n\t\t\t});\n\t\t}\n\t\tif (result.hasMore) {\n\t\t\thasMore = true;\n\t\t}\n\t\tif (result.fetchFailed) {\n\t\t\tfetchFailed = true;\n\t\t}\n\t\tif (result.truncated) {\n\t\t\ttruncated = true;\n\t\t}\n\t\tif (result.fetchFailed || result.truncated) {\n\t\t\tproblemProviderIds.add(result.providerId);\n\t\t}\n\t}\n\n\tconst cursor = toBroadenIssuesCursor(cursors, exhausted, options.orgs.length);\n\tconst failedProviderIds: IntegrationIds[] = [];\n\tconst incompleteProviderIds: IntegrationIds[] = [];\n\tfor (const providerId of problemProviderIds) {\n\t\tif (broadenedProviderIds.has(providerId)) {\n\t\t\tincompleteProviderIds.push(providerId);\n\t\t} else {\n\t\t\tfailedProviderIds.push(providerId);\n\t\t}\n\t}\n\treturn {\n\t\titems: items,\n\t\twarnings: warnings,\n\t\t// `currentPage` is positional, per ProviderPageInfo.currentPage: this fan-out has no provider-reported\n\t\t// page of its own (its cursor is a per-org bundle, not a page), so the position is the one the caller\n\t\t// addressed — the `page` it supplied, or the page the internal traversal advanced to.\n\t\tpage: { currentPage: page, itemsPerPage: items.length, truncated: truncated || undefined },\n\t\t// `hasMore` promises a resumable continuation, so it must be true ONLY when a real cursor was\n\t\t// produced. Repo-drain truncation (a backstop hit with no persisted repo cursor) can't be resumed —\n\t\t// re-invoking would re-drain the same repos and repeat issues — so it is surfaced as the terminal\n\t\t// `page.truncated` incompleteness signal instead of `hasMore`, matching listRepos. Guard `hasMore`\n\t\t// against a missing cursor so we never advertise a continuation the caller can't make.\n\t\thasMore: hasMore && cursor != null,\n\t\tcursor: cursor,\n\t\tfetchFailed: fetchFailed || undefined,\n\t\tbroadenedProviderIds: [...broadenedProviderIds],\n\t\tfailedProviderIds: failedProviderIds,\n\t\tincompleteProviderIds: incompleteProviderIds,\n\t\tfanOutCount: options.orgs.length,\n\t};\n}\n\n/**\n * Advances to page N by re-running the fan-out for each prior page, threading each round's cursor bundle into the\n * next. Only the requested page's items are returned; warnings and provider attribution accumulate across the\n * whole walked prefix, since a failure in an earlier round still means this result is not authoritative.\n */\nasync function traverseToRequestedPage(\n\tctx: ProviderReadContext,\n\toptions: BroadenIssuesOptions,\n\tpage: number,\n): Promise<ProviderBroadenResult<IssueShape>> {\n\tlet cursor: string | undefined;\n\tconst traversalWarnings: ProviderWarning[] = [];\n\tconst attribution = new ProviderAttribution();\n\tlet traversalFetchFailed = false;\n\tlet traversalTruncated = false;\n\n\tfor (let currentPage = 1; currentPage < page; currentPage++) {\n\t\tconst previous = await broadenIssues(ctx, {\n\t\t\t...options,\n\t\t\tpage: currentPage,\n\t\t\tcursor: cursor,\n\t\t\t// A forced refresh belongs to the logical read, not every cursor-advancement round.\n\t\t\tforceSync: currentPage === 1 ? options.forceSync : false,\n\t\t});\n\t\tfor (const warning of previous.warnings) {\n\t\t\tappendDedupedWarning(traversalWarnings, warning);\n\t\t}\n\t\tattribution.merge(previous);\n\t\ttraversalFetchFailed ||= previous.fetchFailed === true;\n\t\ttraversalTruncated ||= previous.page.truncated === true;\n\t\tif (!previous.hasMore || previous.cursor == null) {\n\t\t\t// The requested page lies past the last continuation: an empty page N, never the last page relabeled.\n\t\t\treturn {\n\t\t\t\titems: [],\n\t\t\t\twarnings: traversalWarnings,\n\t\t\t\tpage: { currentPage: page, itemsPerPage: 0, truncated: traversalTruncated || undefined },\n\t\t\t\thasMore: false,\n\t\t\t\tfetchFailed: traversalFetchFailed || undefined,\n\t\t\t\t...attribution.toResultFields(),\n\t\t\t\tfanOutCount: options.orgs.length,\n\t\t\t};\n\t\t}\n\n\t\tcursor = previous.cursor;\n\t}\n\n\tconst requested = await broadenIssues(ctx, { ...options, page: page, cursor: cursor, forceSync: false });\n\tfor (const warning of requested.warnings) {\n\t\tappendDedupedWarning(traversalWarnings, warning);\n\t}\n\tattribution.merge(requested);\n\treturn {\n\t\t...requested,\n\t\twarnings: traversalWarnings,\n\t\tpage: {\n\t\t\t...requested.page,\n\t\t\ttruncated: traversalTruncated || requested.page.truncated === true || undefined,\n\t\t},\n\t\tfetchFailed: traversalFetchFailed || requested.fetchFailed === true || undefined,\n\t\t...attribution.toResultFields(),\n\t};\n}\n\n/**\n * One org's issues as either engine below reports them, normalized to the single shape {@link readOrgSlice}'s\n * bookkeeping consumes.\n *\n * The two engines return different envelopes — the SDK read's `PagedResult` + `paging`, the search's flat page —\n * and normalizing HERE rather than per engine is what keeps the continuation, retry, attribution and exhaustion\n * rules literally the same code on both paths. A second copy of those rules per engine is how one path would come\n * to advertise a continuation the other calls terminal.\n */\ninterface OrgIssuesRead {\n\t/** The page the provider served, or `undefined` when the read returned none (which `warning` explains). */\n\tvalue?: { items: IssueShape[]; hasMore: boolean; cursor?: string; truncated: boolean };\n\t/** The read's own failure. Already included in `warnings`; carried separately because the retry rules key off it. */\n\twarning?: ProviderWarning;\n\t/** Everything the engine produced, the read's own failure included. */\n\twarnings: ProviderWarning[];\n\tfetchFailed: boolean;\n\ttruncated: boolean;\n\t/**\n\t * The engine established there is NOTHING to read for this org — the repository drain returned no\n\t * repositories — so the slice is terminal and empty. Distinct from `value == null`, which means a read WAS\n\t * issued and came back with no page, and so is a position to retry.\n\t */\n\tnothingToRead?: boolean;\n}\n\n/**\n * The org-scoped filtered search: ONE request per page, whatever the org contains.\n *\n * Replaces the drain + SDK read for every provider that declares a filtered issue search — the repository drain\n * costs up to 100 requests per org, and the SDK's repo-scoped read past GitHub's result ceiling enters a\n * per-repository recovery walk that can spend 128 more and still return an incomplete set. Measured on an org\n * past that ceiling: 133 requests and 111s, against this read's 10 and 40s. The search reaches the same scope by\n * NAMING the org, so it needs no repositories at all.\n *\n * It is also the more COMPLETE of the two over the window a consumer reads first, despite returning fewer items —\n * see the module docstring's table for the measurement and why that is not a contradiction.\n *\n * `criteria` is omitted entirely, and each half of that is deliberate:\n * - `relationships` OMITTED is what drops the assignee constraint, which is the substitution `includeAllAssignees:\n * true` performs on the read this replaces. NOT `['any-assignee']`, which means \"assigned to somebody\" and would\n * exclude every unassigned issue — the opposite of broadening.\n * - every other criterion left unset resolves to the provider's own default, which is the state this read already\n * served (open issues only, archived repositories excluded).\n *\n * At the result ceiling this SUCCEEDS and reports how many matched instead of walking for the rest — see the\n * ceiling warning below.\n */\nasync function readOrgIssuesViaSearch(\n\tintegration: GitHostIntegration,\n\torg: ProviderBroadenOrg,\n\tdomain: string | undefined,\n\tcursor: string | undefined,\n): Promise<OrgIssuesRead> {\n\tconst connectionId = org.connectionId;\n\tconst captured = await runCaptured(\n\t\torg.providerId,\n\t\tdomain,\n\t\tconnectionId,\n\t\t() => integration.searchIssuesPageResult({ org: org.name, cursor: cursor }, undefined, connectionId),\n\t\t{ warnOnMissingSession: true },\n\t);\n\n\t// A provider that declares the capability but implements no search hook answers `undefined` with no error.\n\t// Reported as the explicit unsupported failure rather than left as a silent empty page, so it can't be mistaken\n\t// for an org with no issues — and as the read's `warning`, so the slice treats it as the read failure it is.\n\tconst warning =\n\t\tcaptured.warning ??\n\t\t(captured.value == null\n\t\t\t? unsupportedIssueSearchCriteriaWarning(org.providerId, domain, connectionId, {\n\t\t\t\t\treason: 'unsupported-search',\n\t\t\t\t})\n\t\t\t: undefined);\n\tconst warnings = warning != null ? [warning] : [];\n\n\tlet value: OrgIssuesRead['value'];\n\tif (captured.value != null) {\n\t\tconst page = captured.value;\n\t\tvalue = {\n\t\t\titems: page.values,\n\t\t\thasMore: page.hasMore,\n\t\t\tcursor: usableCursor(page.cursor),\n\t\t\ttruncated: page.truncated,\n\t\t};\n\t\t// The result ceiling is the one incompleteness this read can QUANTIFY, so it carries the total rather than\n\t\t// a bare \"may be incomplete\" — which is what lets a consumer say \"1.474 matched, showing the 1.000 most\n\t\t// recently updated\" instead of silently serving a truncated list. Only when nothing else already explained\n\t\t// the incompleteness, and only the ceiling gets the number: any other cause falls back to the generic\n\t\t// wording rather than reporting a limit it didn't hit. `exhausted`: nothing this read exposes would return\n\t\t// the withheld items.\n\t\tif (page.truncated && warnings.length === 0) {\n\t\t\twarnings.push(\n\t\t\t\tissueSearchCapResultWarning(\n\t\t\t\t\torg.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\tconnectionId,\n\t\t\t\t\tpage.totalCount,\n\t\t\t\t\teffectiveIssueSort(undefined),\n\t\t\t\t\tpage.limitReached,\n\t\t\t\t) ?? truncationWarning(org.providerId, domain, connectionId, 'Issue search', 'exhausted'),\n\t\t\t);\n\t\t}\n\t}\n\n\treturn { value: value, warning: warning, warnings: warnings, fetchFailed: false, truncated: false };\n}\n\n/**\n * The original engine: drain the org's repositories, then read the issues across them.\n *\n * Kept for a provider that declares NO filtered issue search (Azure DevOps Services, GitLab), where refusing the\n * org would be a regression rather than a saving. Its cost, and the arbitrary subset it serves past the result ceiling, are\n * what {@link readOrgIssuesViaSearch} exists to avoid — see the module docstring's measurement. Those providers\n * keep both, because on them there is nothing better to switch to.\n */\nasync function readOrgIssuesViaRepoDrain(\n\tintegration: GitHostIntegration,\n\torg: ProviderBroadenOrg,\n\tdomain: string | undefined,\n\tcursor: string | undefined,\n): Promise<OrgIssuesRead> {\n\tconst connectionId = org.connectionId;\n\tconst reposDrain = await drainRepositories(\n\t\tintegration,\n\t\torg.providerId,\n\t\tdomain,\n\t\torg.name,\n\t\tundefined,\n\t\tconnectionId,\n\t\t100,\n\t);\n\tconst warnings: ProviderWarning[] = [...reposDrain.warnings];\n\n\tconst repos: ProviderReposInput = reposDrain.repos.map(r => ({ ...r }));\n\tif (repos.length === 0) {\n\t\treturn {\n\t\t\twarnings: warnings,\n\t\t\tfetchFailed: reposDrain.fetchFailed,\n\t\t\ttruncated: reposDrain.truncated,\n\t\t\tnothingToRead: true,\n\t\t};\n\t}\n\n\t// Broaden = \"all visible\": drop the assigned-to-me filter so unassigned issues are included.\n\tconst captured = await runCaptured(\n\t\torg.providerId,\n\t\tdomain,\n\t\tconnectionId,\n\t\t() =>\n\t\t\t// Normalized shapes seam, uniform with listIssuesPage.\n\t\t\tintegration.getMyIssuesForReposAsShapesResult(\n\t\t\t\trepos,\n\t\t\t\t{ includeAllAssignees: true, cursor: cursor },\n\t\t\t\tconnectionId,\n\t\t\t),\n\t\t{ warnOnMissingSession: true },\n\t);\n\tif (captured.warning != null) {\n\t\twarnings.push(captured.warning);\n\t}\n\tconst assessment = mergeAssessmentInto(warnings, org.providerId, domain, connectionId, captured.value?.metadata);\n\n\tlet value: OrgIssuesRead['value'];\n\tif (captured.value != null) {\n\t\tconst paged = toProviderPageInfo(captured.value.values.length, captured.value.paging);\n\t\tvalue = {\n\t\t\titems: captured.value.values,\n\t\t\thasMore: paged.hasMore,\n\t\t\tcursor: paged.cursor,\n\t\t\t// Carry a truncation signal from the issue read too: a provider that couldn't confirm it drained a\n\t\t\t// repo (`paging.truncated`) means this org's issues may be incomplete, on top of any repo-drain\n\t\t\t// truncation already captured above.\n\t\t\ttruncated: paged.truncated || assessment.truncated,\n\t\t};\n\t}\n\n\treturn {\n\t\tvalue: value,\n\t\twarning: captured.warning,\n\t\twarnings: warnings,\n\t\tfetchFailed: reposDrain.fetchFailed || assessment.fetchFailed,\n\t\ttruncated: reposDrain.truncated,\n\t};\n}\n\n/**\n * Reads one org's visible issues, through the org-scoped filtered search where the provider has one and through\n * the repository drain where it doesn't. Everything below the engine — the position, the retry slot, the\n * attribution and the exhaustion mark — is the same on both paths.\n */\nasync function readOrgSlice(\n\tctx: ProviderReadContext,\n\toptions: BroadenIssuesOptions,\n\torg: ProviderBroadenOrg,\n\tpage: number,\n): Promise<BroadenSlice> {\n\tconst connectionId = org.connectionId;\n\tconst requestedDomain = org.domain;\n\tconst cursorDomain = hostFromDomain(requestedDomain) ?? requestedDomain;\n\t// An org slice that yielded no issues and has nothing to continue: the org's identity (which the\n\t// aggregation above keys the per-org cursor bundle by) plus why it produced nothing. `exhausted` marks\n\t// an org a prior round already drained, so it stays skipped rather than being re-read from page 1.\n\tconst barrenSlice = (\n\t\twarnings: ProviderWarning[],\n\t\tflags?: { exhausted?: boolean; fetchFailed?: boolean; truncated?: boolean },\n\t): BroadenSlice => ({\n\t\titems: [],\n\t\twarnings: warnings,\n\t\tbroadenedProviderIds: [],\n\t\tproviderId: org.providerId,\n\t\torg: org.name,\n\t\tconnectionId: connectionId,\n\t\tdomain: cursorDomain,\n\t\tnextCursor: undefined,\n\t\thasMore: false,\n\t\texhausted: flags?.exhausted ?? false,\n\t\tfetchFailed: flags?.fetchFailed ?? false,\n\t\ttruncated: flags?.truncated ?? false,\n\t});\n\n\tif (isIssuesHostIntegrationId(org.providerId)) {\n\t\treturn barrenSlice(\n\t\t\t[gitHostOnlySurfaceWarning(org.providerId, requestedDomain, connectionId, 'issue broadening')],\n\t\t\t{\n\t\t\t\tfetchFailed: true,\n\t\t\t},\n\t\t);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(org.providerId, connectionId, requestedDomain);\n\tif (integration == null) {\n\t\t// A requested connection or domain that can't be resolved is a broken target — surface it as a\n\t\t// warning + fetchFailed rather than dropping the org silently.\n\t\tconst early = ctx.earlyReturnConnectionWarnings(org.providerId, connectionId, requestedDomain);\n\t\treturn barrenSlice(\n\t\t\tearly.warnings.length > 0\n\t\t\t\t? early.warnings\n\t\t\t\t: [noConnectionWarning(org.providerId, requestedDomain, connectionId)],\n\t\t\t{ fetchFailed: true },\n\t\t);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn barrenSlice(\n\t\t\t[gitHostOnlySurfaceWarning(org.providerId, requestedDomain, connectionId, 'issue broadening')],\n\t\t\t{\n\t\t\t\tfetchFailed: true,\n\t\t\t},\n\t\t);\n\t}\n\t// A git host whose issue tracker is deprecated (Bitbucket) exposes no issues here — surface a\n\t// warning + fetchFailed and skip it (no repo drain), so broadening never serves a legacy source.\n\tif (!integration.supportsIssues) {\n\t\treturn barrenSlice(\n\t\t\t[\n\t\t\t\tissuesUnsupportedWarning(\n\t\t\t\t\torg.providerId,\n\t\t\t\t\tctx.domainForRead(integration, org.providerId, connectionId, requestedDomain),\n\t\t\t\t\tconnectionId,\n\t\t\t\t),\n\t\t\t],\n\t\t\t{ fetchFailed: true },\n\t\t);\n\t}\n\n\t// An org name NEITHER engine can use, refused before either is chosen. Declining the search for it is not\n\t// enough, because falling through to the repository drain is not the safe default it looks like: the drain\n\t// passes the SAME name to the org repository read, which matches nothing and reports `nothingToRead` — an\n\t// org that reads as empty, with no warning and no `fetchFailed`, after up to 100 requests. Indistinguishable\n\t// from an org that genuinely has no issues, and strictly worse than saying so.\n\t//\n\t// EVERY rejection, not just `unusable-scope`: with no repositories and no criteria the only other reachable\n\t// one is `unscoped`, which here means exactly `org.name === ''` — the same bad outcome by the same route, so\n\t// drawing the line between them would leave the emptiest case on the wrong side of the rule. (`repo-ids`\n\t// cannot arise: no repositories are passed.) Refusing them all is also what lets the engine choice below be\n\t// a plain capability question again, since no rejection survives this point.\n\tconst scopeRejection = resolveIssueSearchScope(org.providerId, undefined, org.name, undefined).rejection;\n\tif (scopeRejection != null) {\n\t\treturn barrenSlice(\n\t\t\t[\n\t\t\t\totherWarning(\n\t\t\t\t\torg.providerId,\n\t\t\t\t\tctx.domainForRead(integration, org.providerId, connectionId, requestedDomain),\n\t\t\t\t\tconnectionId,\n\t\t\t\t\tscopeRejection.reason === 'unusable-scope'\n\t\t\t\t\t\t? unusableSearchScopeMessage('issue broadening scopes', scopeRejection.scopes)\n\t\t\t\t\t\t: 'Issue broadening must name an organization; one was supplied with an empty name.',\n\t\t\t\t),\n\t\t\t],\n\t\t\t{ fetchFailed: true },\n\t\t);\n\t}\n\n\t// An org a prior round already drained must not be re-read: cursor-only providers would answer a\n\t// fresh page-1 request with their first page again, duplicating issues across rounds. Skip it\n\t// before any work (including the repo drain) and keep it marked exhausted so it stays skipped\n\t// for the rest of the fan-out.\n\tif (isBroadenIssuesOrgExhausted(options.cursor, org, options.orgs.length)) {\n\t\treturn barrenSlice([], { exhausted: true });\n\t}\n\n\tawait ctx.forceRefreshIfRequested(integration, options.forceSync, connectionId);\n\n\tconst domain = ctx.domainForRead(integration, org.providerId, connectionId, requestedDomain);\n\tconst cursor = getBroadenIssuesCursor(options.cursor, org, page, options.orgs.length);\n\t// A plain capability question, and only because the refusal above has already turned away every org whose\n\t// name the scope rule rejects. That order matters: `readOrgIssuesViaSearch` calls the integration's\n\t// `searchIssuesPageResult` directly rather than the `searchIssuesPage` read, and that method documents its\n\t// scope as already validated (\"the facade rejects it before here\") — so an unvalidated name reaching it would\n\t// go straight to the provider query that sanitizes it.\n\tconst read = supportsFilteredIssueSearch(org.providerId)\n\t\t? await readOrgIssuesViaSearch(integration, org, domain, cursor)\n\t\t: await readOrgIssuesViaRepoDrain(integration, org, domain, cursor);\n\tif (read.nothingToRead === true) {\n\t\treturn barrenSlice(read.warnings, { fetchFailed: read.fetchFailed, truncated: read.truncated });\n\t}\n\n\tconst warnings = read.warnings;\n\tlet issuesFetchFailed = read.fetchFailed || (read.warning != null && read.value == null);\n\tconst items: IssueShape[] = [];\n\tlet hasMore = false;\n\tlet nextCursor: string | undefined;\n\tlet retryPage: number | undefined;\n\tlet issuesTruncated = false;\n\tif (read.value != null) {\n\t\titems.push(...read.value.items);\n\t\t// An org that reports another page but no usable cursor can't be resumed: it would neither be\n\t\t// recorded in the composite cursor nor marked exhausted, so the next round would re-read its\n\t\t// page 1 and repeat every issue. Treat it as terminal-but-incomplete (which also marks the org\n\t\t// exhausted below, since `exhausted` keys off `!hasMore`).\n\t\tconst continuation = resolveContinuation(read.value, undefined);\n\t\thasMore = continuation.hasMore;\n\t\tnextCursor = continuation.cursor;\n\t\tissuesTruncated = continuation.truncated;\n\t} else if (read.warning != null || cursor != null) {\n\t\t// Keep the exact position that failed. Without this retry cursor a multi-org continuation would\n\t\t// omit this org from the bundle, then synthesize the next numbered page and silently skip the\n\t\t// failed page. The synthesized page cursor is also actionable for a first-page cursor-only read:\n\t\t// that provider ignores the page marker and retries its first page. A retry slot alone is NOT\n\t\t// forward progress, though: advertising `hasMore` for a persistent failure would make an infinite\n\t\t// query request it forever. Healthy sibling continuations set `hasMore` independently.\n\t\tif (cursor != null) {\n\t\t\tnextCursor = cursor;\n\t\t\tif (read.warning == null) {\n\t\t\t\tappendDedupedWarning(\n\t\t\t\t\twarnings,\n\t\t\t\t\totherWarning(\n\t\t\t\t\t\torg.providerId,\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\tconnectionId,\n\t\t\t\t\t\t'Issue continuation returned no result and must be retried',\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tissuesFetchFailed = true;\n\t\t\t\tissuesTruncated = true;\n\t\t\t}\n\t\t} else {\n\t\t\tretryPage = page;\n\t\t}\n\t}\n\n\treturn {\n\t\titems: items,\n\t\twarnings: warnings,\n\t\tbroadenedProviderIds: read.value != null ? [org.providerId] : [],\n\t\tproviderId: org.providerId,\n\t\torg: org.name,\n\t\tconnectionId: connectionId,\n\t\tdomain: cursorDomain,\n\t\tnextCursor: nextCursor,\n\t\tretryPage: retryPage,\n\t\thasMore: hasMore,\n\t\t// Exhausted once a successful read reports no more pages — recorded in the cursor so later\n\t\t// rounds skip it while other orgs keep paging.\n\t\texhausted: read.value != null && !hasMore,\n\t\tfetchFailed: issuesFetchFailed,\n\t\ttruncated: read.truncated || issuesTruncated,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0HA,IAAM,sBAAN,MAA0B;CACzB,4BAA6B,IAAI,IAAoB;CACrD,yBAA0B,IAAI,IAAoB;CAClD,6BAA8B,IAAI,IAAoB;CAEtD,MAAM,QAAiD;EACtD,KAAK,MAAM,cAAc,OAAO,mBAC/B,IAAI,KAAK,UAAU,IAAI,UAAU,KAAK,OAAO,qBAAqB,SAAS,UAAU,GACpF,KAAK,WAAW,IAAI,UAAU;OAE9B,KAAK,OAAO,IAAI,UAAU;EAG5B,KAAK,MAAM,cAAc,OAAO,uBAAuB;GACtD,KAAK,OAAO,OAAO,UAAU;GAC7B,KAAK,WAAW,IAAI,UAAU;EAC/B;EACA,KAAK,MAAM,cAAc,OAAO,sBAAsB;GACrD,KAAK,UAAU,IAAI,UAAU;GAC7B,IAAI,KAAK,OAAO,OAAO,UAAU,GAChC,KAAK,WAAW,IAAI,UAAU;EAEhC;CACD;CAEA,iBAGE;EACD,OAAO;GACN,sBAAsB,CAAC,GAAG,KAA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{"version":3,"file":"broaden.js","names":[],"sources":["../../../../../plus/integrations/src/reads/broaden.ts"],"sourcesContent":["import type { IssueShape } from '@gitlens/git/models/issue.js';\nimport { effectiveIssueSort } from '@gitlens/git/utils/issue.utils.js';\nimport { mapBounded } from '@gitlens/utils/promise.js';\nimport { mergeAssessmentInto } from '../collectionMetadata.js';\nimport type { IntegrationIds } from '../constants.js';\nimport type { ProviderBroadenOrg } from '../manager.js';\nimport type { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport { isGitHostIntegration } from '../models/publicIntegration.js';\nimport type { ProviderReposInput } from '../providers/models.js';\nimport { providerFanOutConcurrency } from '../providers/utils/providerPaging.js';\nimport type { ProviderBroadenResult, ProviderWarning } from '../results.js';\nimport { appendDedupedWarning } from '../results.js';\nimport { hostFromDomain } from '../utils/domain.utils.js';\nimport { isIssuesHostIntegrationId } from '../utils/integration.utils.js';\nimport type { ProviderReadContext } from './context.js';\nimport type { BroadenIssuesExhaustedOrg, BroadenIssuesOrgCursor } from './cursors.js';\nimport { getBroadenIssuesCursor, isBroadenIssuesOrgExhausted, toBroadenIssuesCursor } from './cursors.js';\nimport { drainRepositories, runCaptured } from './drains.js';\nimport { resolveIssueSearchScope, supportsFilteredIssueSearch } from './filters.js';\nimport { resolveContinuation, toProviderPageInfo, usableCursor } from './paging.js';\nimport {\n\tgitHostOnlySurfaceWarning,\n\tissueSearchCapResultWarning,\n\tissuesUnsupportedWarning,\n\tnoConnectionWarning,\n\totherWarning,\n\ttruncationWarning,\n\tunsupportedIssueSearchCriteriaWarning,\n\tunusableSearchScopeMessage,\n} from './warnings.js';\n\n/**\n * The issue-broadening fan-out: every visible issue across a set of orgs, one page at a time.\n *\n * What makes this its own read rather than a variant of `listIssuesPage` is that one logical page spans several\n * provider positions — one per org — so its continuation is a per-org cursor BUNDLE (see `cursors.ts`) and its\n * failure attribution is per provider across those orgs. Both are the reason a page number alone can't address a\n * later page, and why {@link broadenIssues} walks prior pages itself when given only `page`.\n *\n * Each org slice runs on ONE OF TWO ENGINES, chosen by what the provider declares (#5804):\n * - the org-scoped FILTERED SEARCH where the provider has one (GitHub/GHE): one request per page, no repositories\n * needed at all, since the search reaches the scope by naming the org;\n * - the REPOSITORY DRAIN plus the SDK's repo-scoped read where it doesn't (Azure DevOps, GitLab): up to 100\n * requests to enumerate the org, and a read whose over-limit recovery walk can spend 128 more per repository\n * and still return an incomplete set.\n *\n * Measured by running this read against the live API, three times per engine per org (median shown; each\n * engine returned a byte-identical result set on all three, so the sets below are not sampling noise):\n *\n * | | repo drain + SDK read | org-scoped search |\n * | --- | --- | --- |\n * | BELOW the ceiling (146 issues) | 9.3s, 11 requests, 146 issues | 6.2s, 2 requests, 146 issues |\n * | ABOVE it (1.475 issues, 217 repos) | 111s, 133 requests, 1.118 issues | 40s, 10 requests, 1.000 issues |\n * | ...of the 1.000 most recently updated | 644 | 1.000 |\n * | ...omissions reported | 99 × `recovery-budget`, no count | 1, carrying `totalCount: 1474` |\n *\n * BELOW the ceiling the two return the IDENTICAL SET (verified as set equality), so there the swap is a straight\n * saving and nothing else. ABOVE it they return DIFFERENT SETS — overlapping on 644 items, so the divergence is\n * not confined to the edge.\n *\n * Above the ceiling the search returns FEWER items and is nonetheless the more useful of the two, which is the\n * whole reason to prefer it: its 1.000 are exactly the 1.000 most recently updated (again set equality against a\n * ceiling-free enumeration, not a count), whereas the SDK read's 1.118 are an arbitrary subset — 474 of them from\n * beyond that window, at the cost of omitting 356 issues that ARE in it. Its recovery walk does not close the gap\n * it spends the budget on: all 99 of its omissions were exhausted budget.\n *\n * The second difference is what a consumer can SAY about the gap. At the ceiling the search succeeds and reports\n * one quantified omission (`issueSearchCapResultWarning` carries `totalCount`, `limit` and the order the window\n * was selected under), so a consumer can render \"1.474 matched, showing the 1.000 most recently updated\". The\n * SDK read reports one `recovery-budget` omission per exhausted repository, none of which carries how many issues\n * were missed — incompleteness that can be announced but not quantified.\n *\n * Note the time saving is the SMALLER half of this: 1.5× below the ceiling and 2.8× above it, against 5.5× and\n * 13.3× fewer requests. The request count is what matters for a rate limit shared with every other read.\n *\n * The public surface is the SAME on both: the options, the per-org cursor bundle, the `ProviderAttribution`\n * split, the warning dedupe and the return type. A consumer needs to know which engine ran only insofar as the\n * warnings say so.\n *\n * Broadening means ALL VISIBLE, and each engine expresses that differently — `includeAllAssignees: true` on the\n * SDK read, an OMITTED `relationships` on the search. Both resolve to no assignee constraint at all, so\n * unassigned issues ARE included. The search's equivalent is NOT `['any-assignee']`: `assignee:*` means \"has some\n * assignee\" and would silently exclude every unassigned issue, which is the opposite of broadening.\n *\n * Takes no `sort`, unlike `listIssuesPage` and `searchIssuesPage`. One logical page here spans several orgs, each\n * at its own provider position in a cursor bundle, so honoring an order across them would need a k-way merge with\n * a buffer per org rather than a sort of what arrived — the page is a slice of several independent walks, not a\n * union of one round's results. The search engine still orders each org's OWN query (it must: a ceiling policy of\n * \"the N most recent\" is only correct under a guaranteed order), so a slice is ordered where the merged page is\n * not. `searchIssuesPage({ repos, criteria: { sort } })` answers the ordered version of this question for a\n * caller that knows its repositories.\n */\n\nexport interface BroadenIssuesOptions {\n\torgs: ProviderBroadenOrg[];\n\tpage?: number;\n\tcursor?: string;\n\tforceSync?: boolean;\n}\n\n/** One org slice of the fan-out: its issues plus the position and health the aggregation keys the bundle by. */\ninterface BroadenSlice {\n\titems: IssueShape[];\n\twarnings: ProviderWarning[];\n\tbroadenedProviderIds: IntegrationIds[];\n\tproviderId: IntegrationIds;\n\torg: string;\n\tconnectionId?: string;\n\tdomain?: string;\n\tnextCursor?: string;\n\tretryPage?: number;\n\thasMore: boolean;\n\texhausted: boolean;\n\tfetchFailed: boolean;\n\ttruncated: boolean;\n}\n\n/**\n * Accumulates provider attribution across the rounds of a page-number traversal.\n *\n * The three sets are mutually exclusive per provider and the ordering rules are what keep them so: a provider\n * that failed in one round but broadened in another is INCOMPLETE, not failed, whichever round reported first.\n */\nclass ProviderAttribution {\n\tprivate readonly broadened = new Set<IntegrationIds>();\n\tprivate readonly failed = new Set<IntegrationIds>();\n\tprivate readonly incomplete = new Set<IntegrationIds>();\n\n\tmerge(result: ProviderBroadenResult<IssueShape>): void {\n\t\tfor (const providerId of result.failedProviderIds) {\n\t\t\tif (this.broadened.has(providerId) || result.broadenedProviderIds.includes(providerId)) {\n\t\t\t\tthis.incomplete.add(providerId);\n\t\t\t} else {\n\t\t\t\tthis.failed.add(providerId);\n\t\t\t}\n\t\t}\n\t\tfor (const providerId of result.incompleteProviderIds) {\n\t\t\tthis.failed.delete(providerId);\n\t\t\tthis.incomplete.add(providerId);\n\t\t}\n\t\tfor (const providerId of result.broadenedProviderIds) {\n\t\t\tthis.broadened.add(providerId);\n\t\t\tif (this.failed.delete(providerId)) {\n\t\t\t\tthis.incomplete.add(providerId);\n\t\t\t}\n\t\t}\n\t}\n\n\ttoResultFields(): Pick<\n\t\tProviderBroadenResult<IssueShape>,\n\t\t'broadenedProviderIds' | 'failedProviderIds' | 'incompleteProviderIds'\n\t> {\n\t\treturn {\n\t\t\tbroadenedProviderIds: [...this.broadened],\n\t\t\tfailedProviderIds: [...this.failed],\n\t\t\tincompleteProviderIds: [...this.incomplete],\n\t\t};\n\t}\n}\n\nexport async function broadenIssues(\n\tctx: ProviderReadContext,\n\toptions: BroadenIssuesOptions,\n): Promise<ProviderBroadenResult<IssueShape>> {\n\tconst page = Math.max(1, Math.trunc(options.page ?? 1));\n\n\t// Kepler's existing contract persists only a page number. When no opaque continuation was supplied,\n\t// advance through prior pages internally so cursor-only providers still return the requested page.\n\t// Each recursive call below carries a cursor, so it bypasses this block and performs exactly one round.\n\tif (options.cursor == null && page > 1) {\n\t\treturn traverseToRequestedPage(ctx, options, page);\n\t}\n\n\tconst results = await mapBounded(options.orgs, providerFanOutConcurrency, org =>\n\t\treadOrgSlice(ctx, options, org, page),\n\t);\n\n\tconst items: IssueShape[] = [];\n\tconst warnings: ProviderWarning[] = [];\n\tconst broadenedProviderIds = new Set<IntegrationIds>();\n\tconst problemProviderIds = new Set<IntegrationIds>();\n\tconst cursors: BroadenIssuesOrgCursor[] = [];\n\tconst exhausted: BroadenIssuesExhaustedOrg[] = [];\n\tlet hasMore = false;\n\tlet fetchFailed = false;\n\tlet truncated = false;\n\tfor (const result of results) {\n\t\tif (result == null) {\n\t\t\tcontinue;\n\t\t}\n\n\t\titems.push(...result.items);\n\t\t// Deduped across orgs: several orgs of one provider commonly fail the same way (one expired token, one\n\t\t// rate limit), producing the identical warning per slice, and the array's contract is that no two entries\n\t\t// are equal — `traverseToRequestedPage` already dedupes when it folds these same warnings across rounds.\n\t\tfor (const warning of result.warnings) {\n\t\t\tappendDedupedWarning(warnings, warning);\n\t\t}\n\t\tfor (const id of result.broadenedProviderIds) {\n\t\t\tbroadenedProviderIds.add(id);\n\t\t}\n\t\tif (result.nextCursor != null || result.retryPage != null) {\n\t\t\tcursors.push({\n\t\t\t\tproviderId: result.providerId,\n\t\t\t\torg: result.org,\n\t\t\t\tconnectionId: result.connectionId,\n\t\t\t\tdomain: result.domain,\n\t\t\t\tcursor: result.nextCursor,\n\t\t\t\tretryPage: result.retryPage,\n\t\t\t});\n\t\t}\n\t\tif (result.exhausted) {\n\t\t\texhausted.push({\n\t\t\t\tproviderId: result.providerId,\n\t\t\t\torg: result.org,\n\t\t\t\tconnectionId: result.connectionId,\n\t\t\t\tdomain: result.domain,\n\t\t\t});\n\t\t}\n\t\tif (result.hasMore) {\n\t\t\thasMore = true;\n\t\t}\n\t\tif (result.fetchFailed) {\n\t\t\tfetchFailed = true;\n\t\t}\n\t\tif (result.truncated) {\n\t\t\ttruncated = true;\n\t\t}\n\t\tif (result.fetchFailed || result.truncated) {\n\t\t\tproblemProviderIds.add(result.providerId);\n\t\t}\n\t}\n\n\tconst cursor = toBroadenIssuesCursor(cursors, exhausted, options.orgs.length);\n\tconst failedProviderIds: IntegrationIds[] = [];\n\tconst incompleteProviderIds: IntegrationIds[] = [];\n\tfor (const providerId of problemProviderIds) {\n\t\tif (broadenedProviderIds.has(providerId)) {\n\t\t\tincompleteProviderIds.push(providerId);\n\t\t} else {\n\t\t\tfailedProviderIds.push(providerId);\n\t\t}\n\t}\n\treturn {\n\t\titems: items,\n\t\twarnings: warnings,\n\t\t// `currentPage` is positional, per ProviderPageInfo.currentPage: this fan-out has no provider-reported\n\t\t// page of its own (its cursor is a per-org bundle, not a page), so the position is the one the caller\n\t\t// addressed — the `page` it supplied, or the page the internal traversal advanced to.\n\t\tpage: { currentPage: page, itemsPerPage: items.length, truncated: truncated || undefined },\n\t\t// `hasMore` promises a resumable continuation, so it must be true ONLY when a real cursor was\n\t\t// produced. Repo-drain truncation (a backstop hit with no persisted repo cursor) can't be resumed —\n\t\t// re-invoking would re-drain the same repos and repeat issues — so it is surfaced as the terminal\n\t\t// `page.truncated` incompleteness signal instead of `hasMore`, matching listRepos. Guard `hasMore`\n\t\t// against a missing cursor so we never advertise a continuation the caller can't make.\n\t\thasMore: hasMore && cursor != null,\n\t\tcursor: cursor,\n\t\tfetchFailed: fetchFailed || undefined,\n\t\tbroadenedProviderIds: [...broadenedProviderIds],\n\t\tfailedProviderIds: failedProviderIds,\n\t\tincompleteProviderIds: incompleteProviderIds,\n\t\tfanOutCount: options.orgs.length,\n\t};\n}\n\n/**\n * Advances to page N by re-running the fan-out for each prior page, threading each round's cursor bundle into the\n * next. Only the requested page's items are returned; warnings and provider attribution accumulate across the\n * whole walked prefix, since a failure in an earlier round still means this result is not authoritative.\n */\nasync function traverseToRequestedPage(\n\tctx: ProviderReadContext,\n\toptions: BroadenIssuesOptions,\n\tpage: number,\n): Promise<ProviderBroadenResult<IssueShape>> {\n\tlet cursor: string | undefined;\n\tconst traversalWarnings: ProviderWarning[] = [];\n\tconst attribution = new ProviderAttribution();\n\tlet traversalFetchFailed = false;\n\tlet traversalTruncated = false;\n\n\tfor (let currentPage = 1; currentPage < page; currentPage++) {\n\t\tconst previous = await broadenIssues(ctx, {\n\t\t\t...options,\n\t\t\tpage: currentPage,\n\t\t\tcursor: cursor,\n\t\t\t// A forced refresh belongs to the logical read, not every cursor-advancement round.\n\t\t\tforceSync: currentPage === 1 ? options.forceSync : false,\n\t\t});\n\t\tfor (const warning of previous.warnings) {\n\t\t\tappendDedupedWarning(traversalWarnings, warning);\n\t\t}\n\t\tattribution.merge(previous);\n\t\ttraversalFetchFailed ||= previous.fetchFailed === true;\n\t\ttraversalTruncated ||= previous.page.truncated === true;\n\t\tif (!previous.hasMore || previous.cursor == null) {\n\t\t\t// The requested page lies past the last continuation: an empty page N, never the last page relabeled.\n\t\t\treturn {\n\t\t\t\titems: [],\n\t\t\t\twarnings: traversalWarnings,\n\t\t\t\tpage: { currentPage: page, itemsPerPage: 0, truncated: traversalTruncated || undefined },\n\t\t\t\thasMore: false,\n\t\t\t\tfetchFailed: traversalFetchFailed || undefined,\n\t\t\t\t...attribution.toResultFields(),\n\t\t\t\tfanOutCount: options.orgs.length,\n\t\t\t};\n\t\t}\n\n\t\tcursor = previous.cursor;\n\t}\n\n\tconst requested = await broadenIssues(ctx, { ...options, page: page, cursor: cursor, forceSync: false });\n\tfor (const warning of requested.warnings) {\n\t\tappendDedupedWarning(traversalWarnings, warning);\n\t}\n\tattribution.merge(requested);\n\treturn {\n\t\t...requested,\n\t\twarnings: traversalWarnings,\n\t\tpage: {\n\t\t\t...requested.page,\n\t\t\ttruncated: traversalTruncated || requested.page.truncated === true || undefined,\n\t\t},\n\t\tfetchFailed: traversalFetchFailed || requested.fetchFailed === true || undefined,\n\t\t...attribution.toResultFields(),\n\t};\n}\n\n/**\n * One org's issues as either engine below reports them, normalized to the single shape {@link readOrgSlice}'s\n * bookkeeping consumes.\n *\n * The two engines return different envelopes — the SDK read's `PagedResult` + `paging`, the search's flat page —\n * and normalizing HERE rather than per engine is what keeps the continuation, retry, attribution and exhaustion\n * rules literally the same code on both paths. A second copy of those rules per engine is how one path would come\n * to advertise a continuation the other calls terminal.\n */\ninterface OrgIssuesRead {\n\t/** The page the provider served, or `undefined` when the read returned none (which `warning` explains). */\n\tvalue?: { items: IssueShape[]; hasMore: boolean; cursor?: string; truncated: boolean };\n\t/** The read's own failure. Already included in `warnings`; carried separately because the retry rules key off it. */\n\twarning?: ProviderWarning;\n\t/** Everything the engine produced, the read's own failure included. */\n\twarnings: ProviderWarning[];\n\tfetchFailed: boolean;\n\ttruncated: boolean;\n\t/**\n\t * The engine established there is NOTHING to read for this org — the repository drain returned no\n\t * repositories — so the slice is terminal and empty. Distinct from `value == null`, which means a read WAS\n\t * issued and came back with no page, and so is a position to retry.\n\t */\n\tnothingToRead?: boolean;\n}\n\n/**\n * The org-scoped filtered search: ONE request per page, whatever the org contains.\n *\n * Replaces the drain + SDK read for every provider that declares a filtered issue search — the repository drain\n * costs up to 100 requests per org, and the SDK's repo-scoped read past GitHub's result ceiling enters a\n * per-repository recovery walk that can spend 128 more and still return an incomplete set. Measured on an org\n * past that ceiling: 133 requests and 111s, against this read's 10 and 40s. The search reaches the same scope by\n * NAMING the org, so it needs no repositories at all.\n *\n * It is also the more COMPLETE of the two over the window a consumer reads first, despite returning fewer items —\n * see the module docstring's table for the measurement and why that is not a contradiction.\n *\n * `criteria` is omitted entirely, and each half of that is deliberate:\n * - `relationships` OMITTED is what drops the assignee constraint, which is the substitution `includeAllAssignees:\n * true` performs on the read this replaces. NOT `['any-assignee']`, which means \"assigned to somebody\" and would\n * exclude every unassigned issue — the opposite of broadening.\n * - every other criterion left unset resolves to the provider's own default, which is the state this read already\n * served (open issues only, archived repositories excluded).\n *\n * At the result ceiling this SUCCEEDS and reports how many matched instead of walking for the rest — see the\n * ceiling warning below.\n */\nasync function readOrgIssuesViaSearch(\n\tintegration: GitHostIntegration,\n\torg: ProviderBroadenOrg,\n\tdomain: string | undefined,\n\tcursor: string | undefined,\n): Promise<OrgIssuesRead> {\n\tconst connectionId = org.connectionId;\n\tconst captured = await runCaptured(\n\t\torg.providerId,\n\t\tdomain,\n\t\tconnectionId,\n\t\t() => integration.searchIssuesPageResult({ org: org.name, cursor: cursor }, undefined, connectionId),\n\t\t{ warnOnMissingSession: true },\n\t);\n\n\t// A provider that declares the capability but implements no search hook answers `undefined` with no error.\n\t// Reported as the explicit unsupported failure rather than left as a silent empty page, so it can't be mistaken\n\t// for an org with no issues — and as the read's `warning`, so the slice treats it as the read failure it is.\n\tconst warning =\n\t\tcaptured.warning ??\n\t\t(captured.value == null\n\t\t\t? unsupportedIssueSearchCriteriaWarning(org.providerId, domain, connectionId, {\n\t\t\t\t\treason: 'unsupported-search',\n\t\t\t\t})\n\t\t\t: undefined);\n\tconst warnings = warning != null ? [warning] : [];\n\n\tlet value: OrgIssuesRead['value'];\n\tif (captured.value != null) {\n\t\tconst page = captured.value;\n\t\tvalue = {\n\t\t\titems: page.values,\n\t\t\thasMore: page.hasMore,\n\t\t\tcursor: usableCursor(page.cursor),\n\t\t\ttruncated: page.truncated,\n\t\t};\n\t\t// The result ceiling is the one incompleteness this read can QUANTIFY, so it carries the total rather than\n\t\t// a bare \"may be incomplete\" — which is what lets a consumer say \"1.474 matched, showing the 1.000 most\n\t\t// recently updated\" instead of silently serving a truncated list. Only when nothing else already explained\n\t\t// the incompleteness, and only the ceiling gets the number: any other cause falls back to the generic\n\t\t// wording rather than reporting a limit it didn't hit. `exhausted`: nothing this read exposes would return\n\t\t// the withheld items.\n\t\tif (page.truncated && warnings.length === 0) {\n\t\t\twarnings.push(\n\t\t\t\tissueSearchCapResultWarning(\n\t\t\t\t\torg.providerId,\n\t\t\t\t\tdomain,\n\t\t\t\t\tconnectionId,\n\t\t\t\t\tpage.totalCount,\n\t\t\t\t\teffectiveIssueSort(undefined),\n\t\t\t\t\tpage.limitReached,\n\t\t\t\t) ?? truncationWarning(org.providerId, domain, connectionId, 'Issue search', 'exhausted'),\n\t\t\t);\n\t\t}\n\t}\n\n\treturn { value: value, warning: warning, warnings: warnings, fetchFailed: false, truncated: false };\n}\n\n/**\n * The original engine: drain the org's repositories, then read the issues across them.\n *\n * Kept for a provider that declares NO filtered issue search (Azure DevOps Services, GitLab), where refusing the\n * org would be a regression rather than a saving. Its cost, and the arbitrary subset it serves past the result ceiling, are\n * what {@link readOrgIssuesViaSearch} exists to avoid — see the module docstring's measurement. Those providers\n * keep both, because on them there is nothing better to switch to.\n */\nasync function readOrgIssuesViaRepoDrain(\n\tintegration: GitHostIntegration,\n\torg: ProviderBroadenOrg,\n\tdomain: string | undefined,\n\tcursor: string | undefined,\n): Promise<OrgIssuesRead> {\n\tconst connectionId = org.connectionId;\n\tconst reposDrain = await drainRepositories(\n\t\tintegration,\n\t\torg.providerId,\n\t\tdomain,\n\t\torg.name,\n\t\tundefined,\n\t\tconnectionId,\n\t\t100,\n\t);\n\tconst warnings: ProviderWarning[] = [...reposDrain.warnings];\n\n\tconst repos: ProviderReposInput = reposDrain.repos.map(r => ({ ...r }));\n\tif (repos.length === 0) {\n\t\treturn {\n\t\t\twarnings: warnings,\n\t\t\tfetchFailed: reposDrain.fetchFailed,\n\t\t\ttruncated: reposDrain.truncated,\n\t\t\tnothingToRead: true,\n\t\t};\n\t}\n\n\t// Broaden = \"all visible\": drop the assigned-to-me filter so unassigned issues are included.\n\tconst captured = await runCaptured(\n\t\torg.providerId,\n\t\tdomain,\n\t\tconnectionId,\n\t\t() =>\n\t\t\t// Normalized shapes seam, uniform with listIssuesPage.\n\t\t\tintegration.getMyIssuesForReposAsShapesResult(\n\t\t\t\trepos,\n\t\t\t\t{ includeAllAssignees: true, cursor: cursor },\n\t\t\t\tconnectionId,\n\t\t\t),\n\t\t{ warnOnMissingSession: true },\n\t);\n\tif (captured.warning != null) {\n\t\twarnings.push(captured.warning);\n\t}\n\tconst assessment = mergeAssessmentInto(warnings, org.providerId, domain, connectionId, captured.value?.metadata);\n\n\tlet value: OrgIssuesRead['value'];\n\tif (captured.value != null) {\n\t\tconst paged = toProviderPageInfo(captured.value.values.length, captured.value.paging);\n\t\tvalue = {\n\t\t\titems: captured.value.values,\n\t\t\thasMore: paged.hasMore,\n\t\t\tcursor: paged.cursor,\n\t\t\t// Carry a truncation signal from the issue read too: a provider that couldn't confirm it drained a\n\t\t\t// repo (`paging.truncated`) means this org's issues may be incomplete, on top of any repo-drain\n\t\t\t// truncation already captured above.\n\t\t\ttruncated: paged.truncated || assessment.truncated,\n\t\t};\n\t}\n\n\treturn {\n\t\tvalue: value,\n\t\twarning: captured.warning,\n\t\twarnings: warnings,\n\t\tfetchFailed: reposDrain.fetchFailed || assessment.fetchFailed,\n\t\ttruncated: reposDrain.truncated,\n\t};\n}\n\n/**\n * Reads one org's visible issues, through the org-scoped filtered search where the provider has one and through\n * the repository drain where it doesn't. Everything below the engine — the position, the retry slot, the\n * attribution and the exhaustion mark — is the same on both paths.\n */\nasync function readOrgSlice(\n\tctx: ProviderReadContext,\n\toptions: BroadenIssuesOptions,\n\torg: ProviderBroadenOrg,\n\tpage: number,\n): Promise<BroadenSlice> {\n\tconst connectionId = org.connectionId;\n\tconst requestedDomain = org.domain;\n\tconst cursorDomain = hostFromDomain(requestedDomain) ?? requestedDomain;\n\t// An org slice that yielded no issues and has nothing to continue: the org's identity (which the\n\t// aggregation above keys the per-org cursor bundle by) plus why it produced nothing. `exhausted` marks\n\t// an org a prior round already drained, so it stays skipped rather than being re-read from page 1.\n\tconst barrenSlice = (\n\t\twarnings: ProviderWarning[],\n\t\tflags?: { exhausted?: boolean; fetchFailed?: boolean; truncated?: boolean },\n\t): BroadenSlice => ({\n\t\titems: [],\n\t\twarnings: warnings,\n\t\tbroadenedProviderIds: [],\n\t\tproviderId: org.providerId,\n\t\torg: org.name,\n\t\tconnectionId: connectionId,\n\t\tdomain: cursorDomain,\n\t\tnextCursor: undefined,\n\t\thasMore: false,\n\t\texhausted: flags?.exhausted ?? false,\n\t\tfetchFailed: flags?.fetchFailed ?? false,\n\t\ttruncated: flags?.truncated ?? false,\n\t});\n\n\tif (isIssuesHostIntegrationId(org.providerId)) {\n\t\treturn barrenSlice(\n\t\t\t[gitHostOnlySurfaceWarning(org.providerId, requestedDomain, connectionId, 'issue broadening')],\n\t\t\t{\n\t\t\t\tfetchFailed: true,\n\t\t\t},\n\t\t);\n\t}\n\n\tconst integration = await ctx.getIntegrationForRead(org.providerId, connectionId, requestedDomain);\n\tif (integration == null) {\n\t\t// A requested connection or domain that can't be resolved is a broken target — surface it as a\n\t\t// warning + fetchFailed rather than dropping the org silently.\n\t\tconst early = ctx.earlyReturnConnectionWarnings(org.providerId, connectionId, requestedDomain);\n\t\treturn barrenSlice(\n\t\t\tearly.warnings.length > 0\n\t\t\t\t? early.warnings\n\t\t\t\t: [noConnectionWarning(org.providerId, requestedDomain, connectionId)],\n\t\t\t{ fetchFailed: true },\n\t\t);\n\t}\n\tif (!isGitHostIntegration(integration)) {\n\t\treturn barrenSlice(\n\t\t\t[gitHostOnlySurfaceWarning(org.providerId, requestedDomain, connectionId, 'issue broadening')],\n\t\t\t{\n\t\t\t\tfetchFailed: true,\n\t\t\t},\n\t\t);\n\t}\n\t// A git host whose issue tracker is deprecated (Bitbucket) exposes no issues here — surface a\n\t// warning + fetchFailed and skip it (no repo drain), so broadening never serves a legacy source.\n\tif (!integration.supportsIssues) {\n\t\treturn barrenSlice(\n\t\t\t[\n\t\t\t\tissuesUnsupportedWarning(\n\t\t\t\t\torg.providerId,\n\t\t\t\t\tctx.domainForRead(integration, org.providerId, connectionId, requestedDomain),\n\t\t\t\t\tconnectionId,\n\t\t\t\t),\n\t\t\t],\n\t\t\t{ fetchFailed: true },\n\t\t);\n\t}\n\n\t// An org name NEITHER engine can use, refused before either is chosen. Declining the search for it is not\n\t// enough, because falling through to the repository drain is not the safe default it looks like: the drain\n\t// passes the SAME name to the org repository read, which matches nothing and reports `nothingToRead` — an\n\t// org that reads as empty, with no warning and no `fetchFailed`, after up to 100 requests. Indistinguishable\n\t// from an org that genuinely has no issues, and strictly worse than saying so.\n\t//\n\t// EVERY rejection, not just `unusable-scope`: with no repositories and no criteria the only other reachable\n\t// one is `unscoped`, which here means exactly `org.name === ''` — the same bad outcome by the same route, so\n\t// drawing the line between them would leave the emptiest case on the wrong side of the rule. (`repo-ids`\n\t// cannot arise: no repositories are passed.) Refusing them all is also what lets the engine choice below be\n\t// a plain capability question again, since no rejection survives this point.\n\tconst scopeRejection = resolveIssueSearchScope(org.providerId, undefined, org.name, undefined).rejection;\n\tif (scopeRejection != null) {\n\t\treturn barrenSlice(\n\t\t\t[\n\t\t\t\totherWarning(\n\t\t\t\t\torg.providerId,\n\t\t\t\t\tctx.domainForRead(integration, org.providerId, connectionId, requestedDomain),\n\t\t\t\t\tconnectionId,\n\t\t\t\t\tscopeRejection.reason === 'unusable-scope'\n\t\t\t\t\t\t? unusableSearchScopeMessage('issue broadening scopes', scopeRejection.scopes)\n\t\t\t\t\t\t: 'Issue broadening must name an organization; one was supplied with an empty name.',\n\t\t\t\t),\n\t\t\t],\n\t\t\t{ fetchFailed: true },\n\t\t);\n\t}\n\n\t// An org a prior round already drained must not be re-read: cursor-only providers would answer a\n\t// fresh page-1 request with their first page again, duplicating issues across rounds. Skip it\n\t// before any work (including the repo drain) and keep it marked exhausted so it stays skipped\n\t// for the rest of the fan-out.\n\tif (isBroadenIssuesOrgExhausted(options.cursor, org, options.orgs.length)) {\n\t\treturn barrenSlice([], { exhausted: true });\n\t}\n\n\tawait ctx.forceRefreshIfRequested(integration, options.forceSync, connectionId);\n\n\tconst domain = ctx.domainForRead(integration, org.providerId, connectionId, requestedDomain);\n\tconst cursor = getBroadenIssuesCursor(options.cursor, org, page, options.orgs.length);\n\t// A plain capability question, and only because the refusal above has already turned away every org whose\n\t// name the scope rule rejects. That order matters: `readOrgIssuesViaSearch` calls the integration's\n\t// `searchIssuesPageResult` directly rather than the `searchIssuesPage` read, and that method documents its\n\t// scope as already validated (\"the facade rejects it before here\") — so an unvalidated name reaching it would\n\t// go straight to the provider query that sanitizes it.\n\tconst read = supportsFilteredIssueSearch(org.providerId)\n\t\t? await readOrgIssuesViaSearch(integration, org, domain, cursor)\n\t\t: await readOrgIssuesViaRepoDrain(integration, org, domain, cursor);\n\tif (read.nothingToRead === true) {\n\t\treturn barrenSlice(read.warnings, { fetchFailed: read.fetchFailed, truncated: read.truncated });\n\t}\n\n\tconst warnings = read.warnings;\n\tlet issuesFetchFailed = read.fetchFailed || (read.warning != null && read.value == null);\n\tconst items: IssueShape[] = [];\n\tlet hasMore = false;\n\tlet nextCursor: string | undefined;\n\tlet retryPage: number | undefined;\n\tlet issuesTruncated = false;\n\tif (read.value != null) {\n\t\titems.push(...read.value.items);\n\t\t// An org that reports another page but no usable cursor can't be resumed: it would neither be\n\t\t// recorded in the composite cursor nor marked exhausted, so the next round would re-read its\n\t\t// page 1 and repeat every issue. Treat it as terminal-but-incomplete (which also marks the org\n\t\t// exhausted below, since `exhausted` keys off `!hasMore`).\n\t\tconst continuation = resolveContinuation(read.value, undefined);\n\t\thasMore = continuation.hasMore;\n\t\tnextCursor = continuation.cursor;\n\t\tissuesTruncated = continuation.truncated;\n\t} else if (read.warning != null || cursor != null) {\n\t\t// Keep the exact position that failed. Without this retry cursor a multi-org continuation would\n\t\t// omit this org from the bundle, then synthesize the next numbered page and silently skip the\n\t\t// failed page. The synthesized page cursor is also actionable for a first-page cursor-only read:\n\t\t// that provider ignores the page marker and retries its first page. A retry slot alone is NOT\n\t\t// forward progress, though: advertising `hasMore` for a persistent failure would make an infinite\n\t\t// query request it forever. Healthy sibling continuations set `hasMore` independently.\n\t\tif (cursor != null) {\n\t\t\tnextCursor = cursor;\n\t\t\tif (read.warning == null) {\n\t\t\t\tappendDedupedWarning(\n\t\t\t\t\twarnings,\n\t\t\t\t\totherWarning(\n\t\t\t\t\t\torg.providerId,\n\t\t\t\t\t\tdomain,\n\t\t\t\t\t\tconnectionId,\n\t\t\t\t\t\t'Issue continuation returned no result and must be retried',\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tissuesFetchFailed = true;\n\t\t\t\tissuesTruncated = true;\n\t\t\t}\n\t\t} else {\n\t\t\tretryPage = page;\n\t\t}\n\t}\n\n\treturn {\n\t\titems: items,\n\t\twarnings: warnings,\n\t\tbroadenedProviderIds: read.value != null ? [org.providerId] : [],\n\t\tproviderId: org.providerId,\n\t\torg: org.name,\n\t\tconnectionId: connectionId,\n\t\tdomain: cursorDomain,\n\t\tnextCursor: nextCursor,\n\t\tretryPage: retryPage,\n\t\thasMore: hasMore,\n\t\t// Exhausted once a successful read reports no more pages — recorded in the cursor so later\n\t\t// rounds skip it while other orgs keep paging.\n\t\texhausted: read.value != null && !hasMore,\n\t\tfetchFailed: issuesFetchFailed,\n\t\ttruncated: read.truncated || issuesTruncated,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2HA,IAAM,sBAAN,MAA0B;CACzB,4BAA6B,IAAI,IAAoB;CACrD,yBAA0B,IAAI,IAAoB;CAClD,6BAA8B,IAAI,IAAoB;CAEtD,MAAM,QAAiD;EACtD,KAAK,MAAM,cAAc,OAAO,mBAC/B,IAAI,KAAK,UAAU,IAAI,UAAU,KAAK,OAAO,qBAAqB,SAAS,UAAU,GACpF,KAAK,WAAW,IAAI,UAAU;OAE9B,KAAK,OAAO,IAAI,UAAU;EAG5B,KAAK,MAAM,cAAc,OAAO,uBAAuB;GACtD,KAAK,OAAO,OAAO,UAAU;GAC7B,KAAK,WAAW,IAAI,UAAU;EAC/B;EACA,KAAK,MAAM,cAAc,OAAO,sBAAsB;GACrD,KAAK,UAAU,IAAI,UAAU;GAC7B,IAAI,KAAK,OAAO,OAAO,UAAU,GAChC,KAAK,WAAW,IAAI,UAAU;EAEhC;CACD;CAEA,iBAGE;EACD,OAAO;GACN,sBAAsB,CAAC,GAAG,KAAK,SAAS;GACxC,mBAAmB,CAAC,GAAG,KAAK,MAAM;GAClC,uBAAuB,CAAC,GAAG,KAAK,UAAU;EAC3C;CACD;AACD;AAEA,eAAsB,cACrB,KACA,SAC6C;CAC7C,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,QAAQ,CAAC,CAAC;CAKtD,IAAI,QAAQ,UAAU,QAAQ,OAAO,GACpC,OAAO,wBAAwB,KAAK,SAAS,IAAI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AM;CACnE,IAAI,KAAK,kBAAkB,MAC1B,OAAO,YAAY,KAAK,UAAU;EAAE,aAAa,KAAK;EAAa,WAAW,KAAK;CAAU,CAAC;CAG/F,MAAM,WAAW,KAAK;CACtB,IAAI,oBAAoB,KAAK,eAAgB,KAAK,WAAW,QAAQ,KAAK,SAAS;CACnF,MAAM,QAAsB,CAAC;CAC7B,IAAI,UAAU;CACd,IAAI;CACJ,IAAI;CACJ,IAAI,kBAAkB;CACtB,IAAI,KAAK,SAAS,MAAM;EACvB,MAAM,KAAK,GAAG,KAAK,MAAM,KAAK;EAK9B,MAAM,eAAe,oBAAoB,KAAK,OAAO,KAAA,CAAS;EAC9D,UAAU,aAAa;EACvB,aAAa,aAAa;EAC1B,kBAAkB,aAAa;CAChC,OAAO,IAAI,KAAK,WAAW,QAAQ,UAAU,MAAM;EAOlD,IAAI,UAAU,MAAM;GACnB,aAAa;GACb,IAAI,KAAK,WAAW,MAAM;IACzB,qBACC,UACA,aACC,IAAI,YACJ,QACA,cACA,2DACD,CACD;IACA,oBAAoB;IACpB,kBAAkB;GACnB;EACD,OACC,YAAY;CAEd;CAEA,OAAO;EACC;EACG;EACV,sBAAsB,KAAK,SAAS,OAAO,CAAC,IAAI,UAAU,IAAI,CAAC;EAC/D,YAAY,IAAI;EAChB,KAAK,IAAI;EACK;EACd,QAAQ;EACI;EACD;EACF;EAGT,WAAW,KAAK,SAAS,QAAQ,CAAC;EAClC,aAAa;EACb,WAAW,KAAK,aAAa;CAC9B;AACD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ConfiguredIntegrationDescriptor } from "../authentication/models.js";
|
|
2
2
|
import { IntegrationIds } from "../constants.js";
|
|
3
3
|
import { ProviderWarning } from "../results.js";
|
|
4
|
-
import { Integration } from "../models/integration.js";
|
|
5
4
|
import { IntegrationsRemoteConfig } from "../context.js";
|
|
5
|
+
import { Integration } from "../models/integration.js";
|
|
6
6
|
//#region ../plus/integrations/src/reads/context.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* Everything the facade's provider reads need from the service that owns connection state — and nothing else.
|
|
@@ -1,94 +1,7 @@
|
|
|
1
|
-
import { IssueSearchCriteria } from "../../../git/models/issue.js";
|
|
2
|
-
import { PullRequestSearchCriteria } from "../../../git/models/pullRequest.js";
|
|
3
1
|
import { IntegrationIds } from "../constants.js";
|
|
4
|
-
import { ProviderResult } from "../results.js";
|
|
5
|
-
import { ProviderReposInput } from "../providers/models.js";
|
|
2
|
+
import { IssueCountResult, IssueCountScope, ProviderResult, PullRequestCountResult, PullRequestCountScope } from "../results.js";
|
|
6
3
|
import { ProviderReadContext } from "./context.js";
|
|
7
4
|
//#region ../plus/integrations/src/reads/counts.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* One scope to count.
|
|
10
|
-
*
|
|
11
|
-
* `key` is caller-owned and echoed back verbatim, so a batch result needs no positional matching by the consumer.
|
|
12
|
-
* It never reaches the provider query — the aliases in the upstream document are generated — so it can be any
|
|
13
|
-
* string the caller finds meaningful.
|
|
14
|
-
*/
|
|
15
|
-
export interface IssueCountScope {
|
|
16
|
-
key: string;
|
|
17
|
-
/** Repositories to count over. Combines with `org`, exactly as in `searchIssuesPage`. */
|
|
18
|
-
repos?: ProviderReposInput;
|
|
19
|
-
org?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Same criteria model as `searchIssuesPage`, validated against the same capability table.
|
|
22
|
-
*
|
|
23
|
-
* `criteria.sort` does not affect the count — a total is invariant under ordering — but it is still VALIDATED,
|
|
24
|
-
* and an unsupported key refuses this scope exactly as it would refuse the read. That is the point of the
|
|
25
|
-
* count: it previews the constraints the read will apply, so one that accepted what the read refuses would
|
|
26
|
-
* promise a fetch that can't happen, which is worse than no preview at all.
|
|
27
|
-
*/
|
|
28
|
-
criteria?: IssueSearchCriteria;
|
|
29
|
-
}
|
|
30
|
-
/** The count for one {@link IssueCountScope}, echoed back under the caller's own `key`. */
|
|
31
|
-
export interface IssueCountResult {
|
|
32
|
-
key: string;
|
|
33
|
-
/**
|
|
34
|
-
* Total matches the provider reports. `undefined` when the provider didn't report one for this scope — NEVER
|
|
35
|
-
* zero, which is a real answer. Render the difference: an unreported count means "unknown", and showing it as
|
|
36
|
-
* 0 would tell the user this filter matches nothing.
|
|
37
|
-
*/
|
|
38
|
-
count?: number;
|
|
39
|
-
/**
|
|
40
|
-
* True when `count` exceeds the provider's own result ceiling, so a full read CANNOT return everything no
|
|
41
|
-
* matter how it is paged. This is the signal to warn before starting an expensive fetch.
|
|
42
|
-
*/
|
|
43
|
-
exceedsProviderLimit: boolean;
|
|
44
|
-
/** The ceiling itself, when the provider declares one. */
|
|
45
|
-
providerLimit?: number;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* One scope to count pull requests over — the PR twin of {@link IssueCountScope}.
|
|
49
|
-
*
|
|
50
|
-
* `key` is caller-owned and echoed back verbatim, never reaching the provider query (the aliases are generated), so
|
|
51
|
-
* it can be any string the caller finds meaningful.
|
|
52
|
-
*/
|
|
53
|
-
export interface PullRequestCountScope {
|
|
54
|
-
key: string;
|
|
55
|
-
/** Repositories to count over. Combines with `org`, exactly as in `searchPullRequestsPage`. */
|
|
56
|
-
repos?: ProviderReposInput;
|
|
57
|
-
org?: string;
|
|
58
|
-
/**
|
|
59
|
-
* Same criteria model as `searchPullRequestsPage`, validated against the same capability table — so a count
|
|
60
|
-
* refuses exactly what the read would, and never previews a fetch that can't happen.
|
|
61
|
-
*/
|
|
62
|
-
criteria?: PullRequestSearchCriteria;
|
|
63
|
-
}
|
|
64
|
-
/** The count for one {@link PullRequestCountScope}, echoed back under the caller's own `key`. */
|
|
65
|
-
export interface PullRequestCountResult {
|
|
66
|
-
key: string;
|
|
67
|
-
/**
|
|
68
|
-
* Total matches the provider reports. `undefined` when the provider didn't report one for this scope — NEVER
|
|
69
|
-
* zero, which is a real answer.
|
|
70
|
-
*
|
|
71
|
-
* For a multi-state scope, GitHub/GHE report the LARGEST of their per-state counts (the same total
|
|
72
|
-
* `searchPullRequestsPage` surfaces, since each state is its own capped search), not their sum. Bitbucket Data
|
|
73
|
-
* Center has no ceiling to stay under, so it reports the exact union — the number of rows the search returns —
|
|
74
|
-
* and so does Azure DevOps Server, which reads every state in one drain.
|
|
75
|
-
*/
|
|
76
|
-
count?: number;
|
|
77
|
-
/**
|
|
78
|
-
* True when `count` is a FLOOR rather than the total: the provider has no count query (Bitbucket Data Center),
|
|
79
|
-
* so it counts by reading within a budget, and this scope had more than the budget read. Render it as "N+", and
|
|
80
|
-
* treat the scope as at least that expensive. Absent means `count` is exact — the provider's own total, or for a
|
|
81
|
-
* provider that counts by reading, every match it read.
|
|
82
|
-
*/
|
|
83
|
-
lowerBound?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* True when `count` exceeds the provider's own per-search result ceiling, so a full read CANNOT return
|
|
86
|
-
* everything no matter how it is paged. This is the signal to warn before starting an expensive fetch.
|
|
87
|
-
*/
|
|
88
|
-
exceedsProviderLimit: boolean;
|
|
89
|
-
/** The ceiling itself, when the provider declares one. */
|
|
90
|
-
providerLimit?: number;
|
|
91
|
-
}
|
|
92
5
|
/**
|
|
93
6
|
* Counts issues for many scopes without fetching any — the probe behind a "this will fetch ~N issues" preview.
|
|
94
7
|
*
|
|
@@ -2,8 +2,10 @@ import { chunk } from "../../../utils/array.js";
|
|
|
2
2
|
import { mapBounded } from "../../../utils/promise.js";
|
|
3
3
|
import "../constants.js";
|
|
4
4
|
import { appendDedupedWarning, toProviderWarning } from "../results.js";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
5
|
+
import "../providers/utils/providerPaging.js";
|
|
6
|
+
import { providersMetadata } from "../providers/metadata.js";
|
|
7
|
+
import { isIssuesHostIntegrationId, warnOnMissingSessionForDomain } from "../utils/integration.utils.js";
|
|
8
|
+
import { isGitHostIntegration } from "../models/publicIntegration.js";
|
|
7
9
|
import { gitHostOnlySurfaceWarning, issuesUnsupportedWarning, otherWarning, unsupportedIssueSearchCriteriaWarning, unsupportedPullRequestSearchCriteriaWarning, unsupportedWarning, unusableSearchScopeMessage } from "./warnings.js";
|
|
8
10
|
import { runCaptured } from "./drains.js";
|
|
9
11
|
import { resolveIssueSearchCriteria, resolveIssueSearchScope, resolvePullRequestSearchCriteria, resolvePullRequestSearchScope } from "./filters.js";
|