@gitkraken/core-gitlens 0.7.1 → 0.8.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.
Files changed (188) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/dist/git/cache.d.ts +18 -5
  3. package/dist/git/cache.js +26 -8
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/context.d.ts +5 -1
  6. package/dist/git/context.js.map +1 -1
  7. package/dist/git/errors.d.ts +28 -1
  8. package/dist/git/errors.js +45 -1
  9. package/dist/git/errors.js.map +1 -1
  10. package/dist/git/providers/branches.d.ts +5 -1
  11. package/dist/git/providers/commits.d.ts +24 -1
  12. package/dist/git/providers/config.d.ts +7 -1
  13. package/dist/git/providers/operations.d.ts +6 -0
  14. package/dist/git/providers/provider.d.ts +17 -0
  15. package/dist/git/providers/refs.d.ts +38 -3
  16. package/dist/git/providers/revision.d.ts +5 -1
  17. package/dist/git/providers/staging.d.ts +12 -0
  18. package/dist/git/providers/worktrees.d.ts +23 -3
  19. package/dist/git/run.types.d.ts +6 -0
  20. package/dist/git-cli/cliGitProvider.d.ts +17 -1
  21. package/dist/git-cli/cliGitProvider.js +37 -1
  22. package/dist/git-cli/cliGitProvider.js.map +1 -1
  23. package/dist/git-cli/exec/git.d.ts +12 -2
  24. package/dist/git-cli/exec/git.js +48 -17
  25. package/dist/git-cli/exec/git.js.map +1 -1
  26. package/dist/git-cli/exec/gitQueue.d.ts +4 -1
  27. package/dist/git-cli/exec/gitQueue.js +1 -1
  28. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  29. package/dist/git-cli/providers/branches.d.ts +10 -1
  30. package/dist/git-cli/providers/branches.js +15 -8
  31. package/dist/git-cli/providers/branches.js.map +1 -1
  32. package/dist/git-cli/providers/commits.d.ts +23 -1
  33. package/dist/git-cli/providers/commits.js +57 -8
  34. package/dist/git-cli/providers/commits.js.map +1 -1
  35. package/dist/git-cli/providers/config.js +4 -3
  36. package/dist/git-cli/providers/config.js.map +1 -1
  37. package/dist/git-cli/providers/operations.d.ts +1 -0
  38. package/dist/git-cli/providers/operations.js +39 -3
  39. package/dist/git-cli/providers/operations.js.map +1 -1
  40. package/dist/git-cli/providers/patch.js +20 -41
  41. package/dist/git-cli/providers/patch.js.map +1 -1
  42. package/dist/git-cli/providers/pausedOperations.js +2 -2
  43. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  44. package/dist/git-cli/providers/refs.d.ts +15 -3
  45. package/dist/git-cli/providers/refs.js +115 -10
  46. package/dist/git-cli/providers/refs.js.map +1 -1
  47. package/dist/git-cli/providers/revision.d.ts +3 -1
  48. package/dist/git-cli/providers/revision.js +9 -5
  49. package/dist/git-cli/providers/revision.js.map +1 -1
  50. package/dist/git-cli/providers/staging.d.ts +8 -0
  51. package/dist/git-cli/providers/staging.js +59 -7
  52. package/dist/git-cli/providers/staging.js.map +1 -1
  53. package/dist/git-cli/providers/worktrees.d.ts +31 -2
  54. package/dist/git-cli/providers/worktrees.js +75 -7
  55. package/dist/git-cli/providers/worktrees.js.map +1 -1
  56. package/dist/ipc/discovery.js +1 -1
  57. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  58. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  59. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  60. package/dist/plus/git-github/api/github.d.ts +64 -3
  61. package/dist/plus/git-github/api/github.js +237 -24
  62. package/dist/plus/git-github/api/github.js.map +1 -1
  63. package/dist/plus/git-github/providers/github/branches.d.ts +3 -1
  64. package/dist/plus/git-github/providers/github/branches.js +2 -1
  65. package/dist/plus/git-github/providers/github/branches.js.map +1 -1
  66. package/dist/plus/git-github/providers/github/refs.d.ts +10 -3
  67. package/dist/plus/git-github/providers/github/refs.js +4 -4
  68. package/dist/plus/git-github/providers/github/refs.js.map +1 -1
  69. package/dist/plus/git-github/providers/github/revision.d.ts +3 -1
  70. package/dist/plus/git-github/providers/github/revision.js +1 -1
  71. package/dist/plus/git-github/providers/github/revision.js.map +1 -1
  72. package/dist/plus/integrations/collectionMetadata.d.ts +48 -3
  73. package/dist/plus/integrations/collectionMetadata.js +138 -8
  74. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  75. package/dist/plus/integrations/errors.d.ts +3 -1
  76. package/dist/plus/integrations/errors.js +7 -3
  77. package/dist/plus/integrations/errors.js.map +1 -1
  78. package/dist/plus/integrations/index.d.ts +6 -3
  79. package/dist/plus/integrations/index.js.map +1 -1
  80. package/dist/plus/integrations/integrationService.d.ts +36 -10
  81. package/dist/plus/integrations/integrationService.js +16 -3
  82. package/dist/plus/integrations/integrationService.js.map +1 -1
  83. package/dist/plus/integrations/manager.d.ts +107 -37
  84. package/dist/plus/integrations/models/gitHostIntegration.d.ts +129 -14
  85. package/dist/plus/integrations/models/gitHostIntegration.js +142 -18
  86. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  87. package/dist/plus/integrations/models/integration.d.ts +117 -11
  88. package/dist/plus/integrations/models/integration.js +175 -13
  89. package/dist/plus/integrations/models/integration.js.map +1 -1
  90. package/dist/plus/integrations/models/issuesIntegration.d.ts +18 -5
  91. package/dist/plus/integrations/models/issuesIntegration.js +42 -10
  92. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  93. package/dist/plus/integrations/providers/azure/azure.d.ts +1 -1
  94. package/dist/plus/integrations/providers/azure/azure.js +14 -18
  95. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  96. package/dist/plus/integrations/providers/azure/models.d.ts +29 -0
  97. package/dist/plus/integrations/providers/azure/models.js +112 -1
  98. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  99. package/dist/plus/integrations/providers/azureDevOps.d.ts +73 -3
  100. package/dist/plus/integrations/providers/azureDevOps.js +117 -3
  101. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  102. package/dist/plus/integrations/providers/azureDevOpsServer.js +2 -1
  103. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  104. package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +61 -0
  105. package/dist/plus/integrations/providers/bitbucket/bitbucket.js +165 -23
  106. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  107. package/dist/plus/integrations/providers/bitbucket/models.d.ts +6 -1
  108. package/dist/plus/integrations/providers/bitbucket/models.js +4 -3
  109. package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
  110. package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.js +2 -2
  111. package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.js.map +1 -1
  112. package/dist/plus/integrations/providers/bitbucket-server.d.ts +48 -2
  113. package/dist/plus/integrations/providers/bitbucket-server.js +51 -1
  114. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  115. package/dist/plus/integrations/providers/bitbucket.d.ts +45 -2
  116. package/dist/plus/integrations/providers/bitbucket.js +41 -2
  117. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  118. package/dist/plus/integrations/providers/github.d.ts +49 -5
  119. package/dist/plus/integrations/providers/github.js +102 -7
  120. package/dist/plus/integrations/providers/github.js.map +1 -1
  121. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +35 -0
  122. package/dist/plus/integrations/providers/gitlab/gitlab.js +132 -15
  123. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  124. package/dist/plus/integrations/providers/gitlab/models.d.ts +1 -0
  125. package/dist/plus/integrations/providers/gitlab/models.js +1 -1
  126. package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
  127. package/dist/plus/integrations/providers/gitlab.d.ts +49 -2
  128. package/dist/plus/integrations/providers/gitlab.js +80 -4
  129. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  130. package/dist/plus/integrations/providers/jira-server.d.ts +3 -3
  131. package/dist/plus/integrations/providers/jira-server.js +5 -8
  132. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  133. package/dist/plus/integrations/providers/jira.d.ts +9 -0
  134. package/dist/plus/integrations/providers/jira.js +13 -1
  135. package/dist/plus/integrations/providers/jira.js.map +1 -1
  136. package/dist/plus/integrations/providers/linear.js +1 -1
  137. package/dist/plus/integrations/providers/models.d.ts +13 -2
  138. package/dist/plus/integrations/providers/models.js +11 -1
  139. package/dist/plus/integrations/providers/models.js.map +1 -1
  140. package/dist/plus/integrations/providers/providerErrors.d.ts +9 -1
  141. package/dist/plus/integrations/providers/providerErrors.js +10 -1
  142. package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
  143. package/dist/plus/integrations/providers/providersApi.d.ts +60 -1
  144. package/dist/plus/integrations/providers/providersApi.js +137 -2
  145. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  146. package/dist/plus/integrations/providers/utils/providerPaging.d.ts +42 -0
  147. package/dist/plus/integrations/providers/utils/providerPaging.js +58 -1
  148. package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -1
  149. package/dist/plus/integrations/providers/utils.d.ts +1 -1
  150. package/dist/plus/integrations/reads/broaden.js +1 -1
  151. package/dist/plus/integrations/reads/context.d.ts +1 -1
  152. package/dist/plus/integrations/reads/counts.js +1 -1
  153. package/dist/plus/integrations/reads/currentAccount.d.ts +35 -0
  154. package/dist/plus/integrations/reads/currentAccount.js +46 -0
  155. package/dist/plus/integrations/reads/currentAccount.js.map +1 -0
  156. package/dist/plus/integrations/reads/drains.d.ts +5 -2
  157. package/dist/plus/integrations/reads/drains.js +8 -4
  158. package/dist/plus/integrations/reads/drains.js.map +1 -1
  159. package/dist/plus/integrations/reads/hierarchy.js +1 -1
  160. package/dist/plus/integrations/reads/hierarchy.utils.js +1 -1
  161. package/dist/plus/integrations/reads/issueBatch.d.ts +72 -12
  162. package/dist/plus/integrations/reads/issueBatch.js +193 -48
  163. package/dist/plus/integrations/reads/issueBatch.js.map +1 -1
  164. package/dist/plus/integrations/reads/issueTracker.js +1 -1
  165. package/dist/plus/integrations/reads/issues.js +1 -1
  166. package/dist/plus/integrations/reads/pullRequestBatch.d.ts +57 -0
  167. package/dist/plus/integrations/reads/pullRequestBatch.js +80 -0
  168. package/dist/plus/integrations/reads/pullRequestBatch.js.map +1 -0
  169. package/dist/plus/integrations/reads/pullRequestBranches.d.ts +58 -0
  170. package/dist/plus/integrations/reads/pullRequestBranches.js +111 -0
  171. package/dist/plus/integrations/reads/pullRequestBranches.js.map +1 -0
  172. package/dist/plus/integrations/reads/pullRequests.js +3 -3
  173. package/dist/plus/integrations/reads/pullRequests.js.map +1 -1
  174. package/dist/plus/integrations/reads/resolveRepository.js +1 -1
  175. package/dist/plus/integrations/reads/sweeps.js +4 -4
  176. package/dist/plus/integrations/reads/sweeps.js.map +1 -1
  177. package/dist/plus/integrations/results.d.ts +87 -6
  178. package/dist/plus/integrations/results.js +9 -2
  179. package/dist/plus/integrations/results.js.map +1 -1
  180. package/dist/utils/env/node/exec.js +3 -3
  181. package/dist/utils/env/node/exec.js.map +1 -1
  182. package/docs/integrations.md +175 -35
  183. package/docs/kepler-git-write-api-parity.md +239 -0
  184. package/docs/kepler-read-api-parity.md +75 -28
  185. package/package.json +1 -1
  186. package/dist/plus/integrations/reads/trackerIssue.d.ts +0 -33
  187. package/dist/plus/integrations/reads/trackerIssue.js +0 -60
  188. package/dist/plus/integrations/reads/trackerIssue.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucket.js","names":[],"sources":["../../../../../plus/integrations/src/providers/bitbucket.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure } from '@gitkraken/provider-apis';\nimport type { Account, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestMergeMethod,\n\tPullRequestState,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { GitRemote } from '@gitlens/git/models/remote.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { md5 } from '@gitlens/utils/crypto.js';\nimport { uniqueBy } from '@gitlens/utils/iterable.js';\nimport { batchResults, flatSettled, nonnullSettled } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type {\n\tAuthenticationSessionLike as AuthenticationSession,\n\tProviderAuthenticationSession,\n} from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { GitCloudHostIntegrationId } from '../constants.js';\nimport type { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from '../models/gitHostIntegration.js';\nimport { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { BitbucketRepositoryDescriptor, BitbucketWorkspaceDescriptor } from './bitbucket/models.js';\nimport type {\n\tProviderApiCollectionResult,\n\tProviderApiPagedResult,\n\tProviderHierarchyResult,\n\tProviderOrganization,\n\tProviderPullRequest,\n\tProviderRepository,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tgetProviderPullRequestIdentity,\n\tprovidersMetadata,\n\tPullRequestFilter,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport {\n\tcollectProviderPagedResult,\n\tflatSettledOrThrow,\n\tmergeCollectionMetadata,\n\tparsePageCursor,\n\ttoPageCursor,\n} from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[GitCloudHostIntegrationId.Bitbucket];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\n\nexport class BitbucketIntegration extends GitHostIntegration<\n\tGitCloudHostIntegrationId.Bitbucket,\n\tBitbucketRepositoryDescriptor\n> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = GitCloudHostIntegrationId.Bitbucket;\n\tprotected readonly key = this.id;\n\treadonly name: string = 'Bitbucket';\n\tget domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\tprotected get apiBaseUrl(): string {\n\t\treturn 'https://api.bitbucket.org/2.0';\n\t}\n\n\tprotected override async mergeProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tpr: PullRequest,\n\t\toptions?: {\n\t\t\tmergeMethod?: PullRequestMergeMethod;\n\t\t},\n\t): Promise<boolean> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.mergePullRequest(toTokenWithInfo(this.id, session), pr, {\n\t\t\tmergeMethod: options?.mergeMethod,\n\t\t});\n\t}\n\n\tpublic override async getRepoInfo(repo: {\n\t\towner: string;\n\t\tname: string;\n\t\tproject?: string;\n\t\tconnectionId?: string;\n\t}): Promise<ProviderRepository | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSession(repo.connectionId, undefined);\n\t\tif (session == null) return undefined;\n\n\t\treturn api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, {\n\t\t\tbaseUrl: this.apiBaseUrl,\n\t\t});\n\t}\n\n\tprotected override async getProviderAccountForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getAccountForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{\n\t\t\t\tavatarSize: options?.avatarSize,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderAccountForEmail(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_email: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\tprotected override async getProviderDefaultBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tcancellation?: AbortSignal,\n\t): Promise<DefaultBranch | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getDefaultBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{ baseUrl: this.apiBaseUrl },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\t{ id }: { id: string; key: string },\n\t\ttype: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getIssueOrPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{\n\t\t\t\ttype: type,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getIssue(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrl,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestForBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tbranch: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t\tinclude?: PullRequestState[];\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getPullRequestForBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tbranch,\n\t\t\tthis.apiBaseUrl,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getPullRequestForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrl,\n\t\t);\n\t}\n\n\tprotected override async getProviderRepositoryMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getRepositoryMetadata(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{ baseUrl: this.apiBaseUrl },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate _accounts: Map<string, Account | undefined> | undefined;\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst { accessToken } = session;\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\n\t\tconst cachedAccount = this._accounts.get(accessToken);\n\t\tif (cachedAccount == null) {\n\t\t\tconst api = await this.getProvidersApi();\n\t\t\tconst user = await api.getCurrentUser(toTokenWithInfo(this.id, session));\n\t\t\tthis._accounts.set(\n\t\t\t\taccessToken,\n\t\t\t\tuser\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tprovider: this,\n\t\t\t\t\t\t\tid: user.id,\n\t\t\t\t\t\t\tname: user.name ?? undefined,\n\t\t\t\t\t\t\temail: user.email ?? undefined,\n\t\t\t\t\t\t\tavatarUrl: user.avatarUrl ?? undefined,\n\t\t\t\t\t\t\tusername: user.username ?? undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t);\n\t\t}\n\n\t\treturn this._accounts.get(accessToken);\n\t}\n\n\tprivate _workspaces: Map<string, ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined> | undefined;\n\tprivate async getProviderResourcesForCurrentUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined> {\n\t\tthis._workspaces ??= new Map<string, ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined>();\n\t\tconst { accessToken } = session;\n\t\tconst cachedResources = this._workspaces.get(accessToken);\n\t\tif (cachedResources != null && !force) return cachedResources;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst resources = await api.getBitbucketResourcesForCurrentUser(toTokenWithInfo(this.id, session));\n\t\tif (resources == null) return undefined;\n\n\t\tconst values = resources.values.map(r => ({ ...r, key: r.id, name: r.name ?? r.slug }));\n\t\tconst metadata = mergeCollectionMetadata(\n\t\t\tresources.metadata,\n\t\t\tresources.paging?.truncated === true ? { completeness: 'partial' } : undefined,\n\t\t);\n\t\tconst result: ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> = {\n\t\t\tvalues: values,\n\t\t\t...(metadata != null ? { metadata: metadata } : {}),\n\t\t};\n\n\t\t// A partial workspace prefix is useful to the current read but must not become authoritative cache state:\n\t\t// a transient page-2 failure must be retried on the next call rather than hiding every later workspace\n\t\t// until disconnect.\n\t\tif (metadata == null || metadata.completeness === 'complete') {\n\t\t\tthis._workspaces.set(accessToken, result);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected override async getProviderOrganizationsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderOrganization> | undefined> {\n\t\tconst workspaces = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspaces == null) return undefined;\n\n\t\treturn {\n\t\t\tvalues: workspaces.values.map(w => ({\n\t\t\t\tid: w.id,\n\t\t\t\tproviderId: this.id,\n\t\t\t\tname: w.slug,\n\t\t\t\turl: `https://bitbucket.org/${w.slug}`,\n\t\t\t})),\n\t\t\t...(workspaces.metadata != null ? { metadata: workspaces.metadata } : {}),\n\t\t};\n\t}\n\n\tprotected override async getProviderRepositoriesForOrg(\n\t\tsession: ProviderAuthenticationSession,\n\t\torg: string,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getReposForBitbucketWorkspace(toTokenWithInfo(this.id, session), org, {\n\t\t\tcursor: options?.cursor,\n\t\t});\n\t}\n\n\tprotected override async searchProviderMyPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\t_cancellation?: AbortSignal,\n\t\toptions?: SearchMyPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (repos != null) {\n\t\t\t// TODO: implement repos version\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst state = options?.state;\n\t\tconst states = toProviderPullRequestStates(state);\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\t// `user.id` feeds both the authored workspace reads and the reviewer BBQL clause; guard on it so we\n\t\t// never issue requests/queries with an undefined uuid. `username` isn't used here, so don't gate on it.\n\t\tif (user?.id == null) return undefined;\n\n\t\tconst workspacesResult = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspacesResult == null) return undefined;\n\n\t\tconst workspaces = workspacesResult.values;\n\t\tif (workspaces.length === 0) return [];\n\n\t\tconst authoredPrs = workspaces.map(async ws => {\n\t\t\tconst prs = await api.getBitbucketPullRequestsAuthoredByUserForWorkspace(\n\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\tuser.id,\n\t\t\t\tws.slug,\n\t\t\t\t{ states: states },\n\t\t\t);\n\t\t\treturn prs?.data.map(pr => fromProviderPullRequest(pr, this));\n\t\t});\n\n\t\tif (!options?.includeReviewRequested) {\n\t\t\treturn [\n\t\t\t\t...uniqueBy(\n\t\t\t\t\tawait flatSettled(authoredPrs),\n\t\t\t\t\tpr => pr.url,\n\t\t\t\t\t(orig, _cur) => orig,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\t// Bitbucket's reviewing PRs require a repo-scoped BBQL query; keep that sweep opt-in so the default\n\t\t// \"my pull requests\" feed stays aligned with backends that only expose authored PRs.\n\t\tconst stateClause =\n\t\t\tstate === 'closed'\n\t\t\t\t? '(state=\"DECLINED\" OR state=\"SUPERSEDED\")'\n\t\t\t\t: state === 'merged'\n\t\t\t\t\t? 'state=\"MERGED\"'\n\t\t\t\t\t: state === 'all'\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: 'state=\"OPEN\"';\n\n\t\tconst workspaceRepos = await this.getWorkspaceRepoInputs();\n\t\tif (workspaceRepos.length === 0) {\n\t\t\treturn [\n\t\t\t\t...uniqueBy(\n\t\t\t\t\tawait flatSettled(authoredPrs),\n\t\t\t\t\tpr => pr.url,\n\t\t\t\t\t(orig, _cur) => orig,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\tconst reviewerClause = `reviewers.uuid=\"${user.id}\"`;\n\t\tconst reviewingPrs = api\n\t\t\t.getPullRequestsForRepos(toTokenWithInfo(this.id, session), workspaceRepos, {\n\t\t\t\tquery: stateClause ? `${stateClause} AND ${reviewerClause}` : reviewerClause,\n\t\t\t})\n\t\t\t.then(r => r.values?.map(pr => fromProviderPullRequest(pr, this)));\n\n\t\treturn [\n\t\t\t...uniqueBy(\n\t\t\t\tawait flatSettled([...authoredPrs, reviewingPrs]),\n\t\t\t\tpr => pr.url,\n\t\t\t\t(orig, _cur) => orig,\n\t\t\t),\n\t\t];\n\t}\n\n\tprotected override async getProviderMyPullRequestsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: {\n\t\t\tstate?: PullRequestStateFilter[];\n\t\t\tcursor?: string;\n\t\t\tincludeReviewRequested?: boolean;\n\t\t\tfilters?: PullRequestFilter[];\n\t\t},\n\t): Promise<ProviderApiPagedResult<ProviderPullRequest> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\tif (user?.id == null) return undefined;\n\n\t\tconst workspacesResult = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspacesResult == null) return undefined;\n\n\t\tconst workspaces = workspacesResult.values;\n\t\tif (workspaces.length === 0) {\n\t\t\tconst incomplete =\n\t\t\t\tworkspacesResult.metadata != null && workspacesResult.metadata.completeness !== 'complete';\n\t\t\treturn {\n\t\t\t\tvalues: [],\n\t\t\t\tpaging: { cursor: '{}', more: false, truncated: incomplete || undefined },\n\t\t\t\t...(workspacesResult.metadata != null ? { metadata: workspacesResult.metadata } : {}),\n\t\t\t};\n\t\t}\n\n\t\t// Account-wide \"my PRs\" for Bitbucket = the user's authored PRs across every workspace they belong to,\n\t\t// plus the PRs they've been requested to review. Bitbucket's cross-workspace read is per-workspace and\n\t\t// numbered-page, so drain each workspace fully (bounded by a defensive backstop) and concatenate.\n\t\t// There's no single cross-workspace cursor, so the aggregate is one page; `truncated` is set when a\n\t\t// workspace hit the backstop with more pages left, or when a workspace's read was dropped by a failure.\n\t\tconst states = toProviderPullRequestStates(options?.state);\n\t\tconst requested = options?.filters?.length ? new Set(options.filters) : undefined;\n\t\tconst wantAuthored = requested == null || requested.has(PullRequestFilter.Author);\n\t\tconst wantReviewRequested =\n\t\t\trequested?.has(PullRequestFilter.ReviewRequested) ?? options?.includeReviewRequested === true;\n\t\tconst maxPagesPerWorkspace = 20;\n\t\tlet truncated = workspacesResult.metadata != null && workspacesResult.metadata.completeness !== 'complete';\n\t\t// Structured per-scope failures from BOTH the authored and reviewer slices. A rejected scope is recorded\n\t\t// here (never re-thrown) so successful sibling workspaces/repos survive and the ProviderBackend facade\n\t\t// maps each failure to an actionable warning + `fetchFailed` (auth/rate-limit failures still drive\n\t\t// recovery through their warning kind, matching the SDK's own collect-across-scopes model).\n\t\tconst failures: CollectionScopeFailure[] = [];\n\t\tlet aggregateMetadata = workspacesResult.metadata;\n\t\tconst absorbCollectionResult = (result: ProviderHierarchyResult<unknown>): void => {\n\t\t\taggregateMetadata = mergeCollectionMetadata(aggregateMetadata, result.metadata);\n\t\t\tif (result.truncated || (result.metadata != null && result.metadata.completeness !== 'complete')) {\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t};\n\t\tconst settled = wantAuthored\n\t\t\t? await Promise.allSettled(\n\t\t\t\t\tworkspaces.map(async ws => {\n\t\t\t\t\t\treturn collectProviderPagedResult(\n\t\t\t\t\t\t\tasync cursor => {\n\t\t\t\t\t\t\t\tconst result = await api.getBitbucketPullRequestsAuthoredByUserForWorkspace(\n\t\t\t\t\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t\t\t\t\tuser.id,\n\t\t\t\t\t\t\t\t\tws.slug,\n\t\t\t\t\t\t\t\t\t{ states: states, page: parsePageCursor(cursor) },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result == null) return undefined;\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tvalues: result.data,\n\t\t\t\t\t\t\t\t\tpaging: {\n\t\t\t\t\t\t\t\t\t\tmore: result.hasMore,\n\t\t\t\t\t\t\t\t\t\tcursor:\n\t\t\t\t\t\t\t\t\t\t\tresult.hasMore && result.nextPage != null\n\t\t\t\t\t\t\t\t\t\t\t\t? toPageCursor(result.nextPage)\n\t\t\t\t\t\t\t\t\t\t\t\t: '{}',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmaxPagesPerWorkspace,\n\t\t\t\t\t\t\t{ providerId: this.id, resourceId: ws.slug },\n\t\t\t\t\t\t);\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t: [];\n\n\t\tconst prsByIdentity = new Map<string, ProviderPullRequest>();\n\t\tlet unkeyedPullRequest = 0;\n\t\tconst addPullRequest = (pr: ProviderPullRequest): void => {\n\t\t\tconst key = getProviderPullRequestIdentity(pr) ?? `unkeyed:${unkeyedPullRequest++}`;\n\t\t\tif (!prsByIdentity.has(key)) {\n\t\t\t\tprsByIdentity.set(key, pr);\n\t\t\t}\n\t\t};\n\t\t// `allSettled` preserves order, so `settled[i]` is `workspaces[i]`. A rejected workspace becomes a\n\t\t// structured failure (attributed to its slug) instead of a generic truncation or a re-throw, preserving\n\t\t// every sibling workspace's authored PRs.\n\t\tsettled.forEach((outcome, i) => {\n\t\t\tif (outcome.status !== 'fulfilled') {\n\t\t\t\tfailures.push(this.toWorkspaceFailure(workspaces[i].slug, outcome.reason));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tabsorbCollectionResult(outcome.value);\n\t\t\tfor (const pr of outcome.value.values) {\n\t\t\t\taddPullRequest(pr);\n\t\t\t}\n\t\t});\n\n\t\t// Bitbucket's account-wide (per-workspace) endpoint returns authored PRs only, and the SDK exposes no\n\t\t// workspace-level reviewer query — only a repo-scoped one. Adding the reviewer slice therefore requires\n\t\t// draining every workspace's full repo list and then a per-repo `getPullRequestsForRepo` with `reviewerId`\n\t\t// (O(workspaces × repos) requests), so keep it opt-in: gate it on `includeReviewRequested` so the default\n\t\t// sweep matches the gkcli baseline (authored PRs only, no reviewer fan-out) and a caller pays that cost\n\t\t// only when it deliberately asks for review-requested PRs.\n\t\tif (wantReviewRequested) {\n\t\t\t// Enumerate the account's repos by draining each resolved workspace's repository list, then drain the\n\t\t\t// real per-repo paged `getPullRequestsForRepo` for each repo with `reviewerId`, so review-requested PRs\n\t\t\t// aren't bounded to the currently-open remotes and a reviewer PR past the first page isn't dropped.\n\t\t\t// Structured per-scope failures are collected as CollectionScopeFailure so the ProviderBackend facade\n\t\t\t// maps them to actionable warnings (Step 3).\n\t\t\tconst maxReposPagesPerWorkspace = 20;\n\t\t\tconst maxPrPagesPerRepo = 20;\n\t\t\t// Bound concurrency: workspaces are few, so process them concurrently, but drain each workspace's repos\n\t\t\t// in a bounded batch rather than an unbounded Promise.all over every repo in every workspace.\n\t\t\tconst repoBatchSize = 5;\n\n\t\t\tawait Promise.all(\n\t\t\t\tworkspaces.map(async ws => {\n\t\t\t\t\tlet repos: ProviderRepository[];\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst discovered = await collectProviderPagedResult(\n\t\t\t\t\t\t\tcursor =>\n\t\t\t\t\t\t\t\tapi.getReposForBitbucketWorkspace(toTokenWithInfo(this.id, session), ws.slug, {\n\t\t\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tmaxReposPagesPerWorkspace,\n\t\t\t\t\t\t\t{ providerId: this.id, resourceId: ws.slug },\n\t\t\t\t\t\t);\n\t\t\t\t\t\trepos = discovered.values;\n\t\t\t\t\t\tabsorbCollectionResult(discovered);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// Record the workspace as a structured failure and keep going: the failure metadata drives\n\t\t\t\t\t\t// the warning + `fetchFailed` + incompleteness for every kind (auth/rate-limit stay\n\t\t\t\t\t\t// actionable via their warning kind), so sibling workspaces' repos are still drained.\n\t\t\t\t\t\tfailures.push(this.toWorkspaceFailure(ws.slug, ex));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst drained = await batchResults(repos, repoBatchSize, async repo => {\n\t\t\t\t\t\tconst reviewing = await collectProviderPagedResult(\n\t\t\t\t\t\t\tcursor =>\n\t\t\t\t\t\t\t\tapi.getPullRequestsForRepo(\n\t\t\t\t\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t\t\t\t\t{ namespace: repo.namespace, name: repo.name },\n\t\t\t\t\t\t\t\t\t{ reviewerId: user.id, states: states, cursor: cursor },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tmaxPrPagesPerRepo,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tproviderId: this.id,\n\t\t\t\t\t\t\t\tresourceId: ws.slug,\n\t\t\t\t\t\t\t\trepositoryId: `${repo.namespace}/${repo.name}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn { repo: repo, reviewing: reviewing };\n\t\t\t\t\t});\n\n\t\t\t\t\tfor (let i = 0; i < drained.length; i++) {\n\t\t\t\t\t\tconst outcome = drained[i];\n\t\t\t\t\t\tif (outcome.status !== 'fulfilled') {\n\t\t\t\t\t\t\tconst repo = repos[i];\n\t\t\t\t\t\t\tfailures.push(\n\t\t\t\t\t\t\t\tthis.toRepositoryFailure(\n\t\t\t\t\t\t\t\t\t`${repo?.namespace ?? ws.slug}/${repo?.name ?? 'unknown'}`,\n\t\t\t\t\t\t\t\t\toutcome.reason,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst { reviewing } = outcome.value;\n\t\t\t\t\t\tabsorbCollectionResult(reviewing);\n\t\t\t\t\t\tfor (const pr of reviewing.values) {\n\t\t\t\t\t\t\taddPullRequest(pr);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// Every slice that ran (authored workspaces always, reviewer workspaces/repos when opted in) records its\n\t\t// per-scope rejections as structured failures instead of re-throwing: re-throwing would discard every\n\t\t// successful sibling's PRs. Auth/rate-limit failures stay actionable through the metadata (the facade maps\n\t\t// kind `authentication` → an `auth` warning, `rate-limit` → a `rate-limit` warning) while the survivors are\n\t\t// returned with `fetchFailed`.\n\t\tconst metadata: CollectionMetadata | undefined = mergeCollectionMetadata(\n\t\t\tfailures.length > 0 ? { completeness: 'partial', failures: failures } : undefined,\n\t\t\taggregateMetadata,\n\t\t);\n\n\t\treturn {\n\t\t\tvalues: [...prsByIdentity.values()],\n\t\t\tpaging: { cursor: '{}', more: false, truncated: truncated || undefined },\n\t\t\tmetadata: metadata,\n\t\t};\n\t}\n\n\t/** Classifies a caught workspace-scope error into a structured {@link CollectionScopeFailure}. */\n\tprivate toWorkspaceFailure(workspaceSlug: string, ex: unknown): CollectionScopeFailure {\n\t\treturn toCollectionScopeFailure({ providerId: this.id, resourceId: workspaceSlug }, ex);\n\t}\n\n\t/** Classifies a caught repository-scope error into a structured {@link CollectionScopeFailure}. */\n\tprivate toRepositoryFailure(repositoryId: string, ex: unknown): CollectionScopeFailure {\n\t\treturn toCollectionScopeFailure({ providerId: this.id, repositoryId: repositoryId }, ex);\n\t}\n\n\tprotected override async searchProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tsearchQuery: string,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) return undefined;\n\n\t\tconst workspaceRepos =\n\t\t\trepos != null\n\t\t\t\t? repos.map(r => ({ name: r.name, namespace: r.owner }))\n\t\t\t\t: await this.getWorkspaceRepoInputs();\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t// An explicitly-empty `repos` means \"search these zero repos\" -> no results; reserve `undefined`\n\t\t// (\"scope couldn't be determined\") for when no repos were requested and none were discovered.\n\t\tif (workspaceRepos.length === 0) return repos != null ? [] : undefined;\n\n\t\tconst token = toTokenWithInfo(this.id, session);\n\t\tconst states = toProviderPullRequestStates(options?.include);\n\t\tconst providerPullRequests = await flatSettledOrThrow(\n\t\t\tworkspaceRepos.map(async repo => {\n\t\t\t\tconst result = await collectProviderPagedResult(cursor => {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\treturn api.getPullRequestsForRepo(token, repo, {\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tquery: searchQuery,\n\t\t\t\t\t\tstates: states,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\treturn result.values;\n\t\t\t}),\n\t\t);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\treturn providerPullRequests.map(pr => fromProviderPullRequest(pr, this));\n\t}\n\n\tprivate async getWorkspaceRepoInputs(): Promise<{ name: string; namespace: string }[]> {\n\t\tconst remotes = await this.ctx.repositories.getOpenRemotes();\n\t\tconst inputs = await nonnullSettled(\n\t\t\tremotes.map(async (r: GitRemote) => {\n\t\t\t\tconst integration = await this.authenticationService.getByRemote(r);\n\t\t\t\tif (integration !== this) return undefined;\n\n\t\t\t\t// Use the remote provider's parsing rather than splitting `r.path`, so adornments like a\n\t\t\t\t// trailing `.git` or extra path segments don't leak into the namespace/name.\n\t\t\t\tconst namespace = r.provider?.owner;\n\t\t\t\tconst name = r.provider?.repoName;\n\t\t\t\treturn namespace != null && name != null ? { name: name, namespace: namespace } : undefined;\n\t\t\t}),\n\t\t);\n\t\t// Dedupe: a repo with multiple remotes (e.g. `origin` + `upstream`) can map to the same input,\n\t\t// which would otherwise fetch and return the same PRs more than once.\n\t\treturn [...new Map(inputs.map(i => [`${i.namespace}/${i.name}`, i])).values()];\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t): Promise<IssueShape[] | undefined> {\n\t\tif (repos == null || repos.length === 0) return undefined;\n\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\tif (user?.username == null) return undefined;\n\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (!api) return undefined;\n\n\t\tconst issueResult = await flatSettled(\n\t\t\trepos.map(repo => {\n\t\t\t\treturn api.getUsersIssuesForRepo(\n\t\t\t\t\tthis,\n\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\tuser.id,\n\t\t\t\t\trepo.owner,\n\t\t\t\t\trepo.name,\n\t\t\t\t\tthis.apiBaseUrl,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\treturn issueResult;\n\t}\n\n\t/**\n\t * Bitbucket is not an issue provider on the ProviderBackend surface: Bitbucket Cloud deprecated its issue\n\t * tracker in favor of dedicated issue integrations (e.g. Jira). The legacy per-repo `getUsersIssuesForRepo`\n\t * client is retained only for autolink/hover enrichment, not for the ProviderBackend issue reads, so the\n\t * facade reports issues as unsupported rather than serving a deprecated, partial source.\n\t */\n\toverride get supportsIssues(): boolean {\n\t\treturn false;\n\t}\n\n\tprivate readonly storagePrefix = 'bitbucket';\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tif (this._session == null) return;\n\n\t\tconst accountStorageKey = md5(this._session.accessToken);\n\n\t\tconst storedAccount = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:account`);\n\t\tconst storedWorkspaces = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:workspaces`);\n\n\t\tlet account: Account | undefined = storedAccount?.data ? { ...storedAccount.data, provider: this } : undefined;\n\n\t\tconst storedWorkspacesData = storedWorkspaces?.data as\n\t\t\t| ProviderApiCollectionResult<BitbucketWorkspaceDescriptor>\n\t\t\t| BitbucketWorkspaceDescriptor[]\n\t\t\t| undefined;\n\t\tlet workspaces: ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined;\n\t\tif (\n\t\t\t!Array.isArray(storedWorkspacesData) &&\n\t\t\tArray.isArray(storedWorkspacesData?.values) &&\n\t\t\t(storedWorkspacesData.metadata == null || storedWorkspacesData.metadata.completeness === 'complete')\n\t\t) {\n\t\t\tworkspaces = {\n\t\t\t\tvalues: storedWorkspacesData.values.map((o: BitbucketWorkspaceDescriptor) => ({ ...o })),\n\t\t\t\t...(storedWorkspacesData.metadata != null ? { metadata: storedWorkspacesData.metadata } : {}),\n\t\t\t};\n\t\t}\n\n\t\tif (storedAccount == null) {\n\t\t\taccount = await this.getProviderCurrentAccount(this._session);\n\t\t\tif (account != null) {\n\t\t\t\t// Clear all other stored workspaces and repositories and accounts when our session changes\n\t\t\t\tawait this.ctx.storage.deleteWithPrefix(this.storagePrefix);\n\t\t\t\tawait this.ctx.storage.store(`${this.storagePrefix}:${accountStorageKey}:account`, {\n\t\t\t\t\tv: 1,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tid: account.id,\n\t\t\t\t\t\tname: account.name,\n\t\t\t\t\t\temail: account.email,\n\t\t\t\t\t\tavatarUrl: account.avatarUrl,\n\t\t\t\t\t\tusername: account.username,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\t\tthis._accounts.set(this._session.accessToken, account);\n\n\t\tif (workspaces == null) {\n\t\t\tconst discovered = await this.getProviderResourcesForCurrentUser(this._session, true);\n\t\t\tif (discovered?.metadata == null || discovered.metadata.completeness === 'complete') {\n\t\t\t\tworkspaces = discovered;\n\t\t\t\tif (workspaces != null) {\n\t\t\t\t\tawait this.ctx.storage.store(`${this.storagePrefix}:${accountStorageKey}:workspaces`, {\n\t\t\t\t\t\tv: 2,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\tdata: workspaces,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (workspaces != null) {\n\t\t\tthis._workspaces ??= new Map<\n\t\t\t\tstring,\n\t\t\t\tProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined\n\t\t\t>();\n\t\t\tthis._workspaces.set(this._session.accessToken, workspaces);\n\t\t}\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t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YAAY,KAAA;EACjB,KAAK,cAAc,KAAA;CACpB;AACD"}
1
+ {"version":3,"file":"bitbucket.js","names":[],"sources":["../../../../../plus/integrations/src/providers/bitbucket.ts"],"sourcesContent":["import type { CollectionMetadata, CollectionScopeFailure } from '@gitkraken/provider-apis';\nimport type { Account, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequest, IssueOrPullRequestType } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestMergeMethod,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { GitRemote } from '@gitlens/git/models/remote.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { md5 } from '@gitlens/utils/crypto.js';\nimport { uniqueBy } from '@gitlens/utils/iterable.js';\nimport { batchResults, flatSettled, mapSettledBounded, nonnullSettled } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type {\n\tAuthenticationSessionLike as AuthenticationSession,\n\tProviderAuthenticationSession,\n} from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport type { ProviderRefusal } from '../collectionMetadata.js';\nimport { toCollectionScopeFailure } from '../collectionMetadata.js';\nimport { GitCloudHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from '../models/gitHostIntegration.js';\nimport { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { BitbucketRepositoryDescriptor, BitbucketWorkspaceDescriptor } from './bitbucket/models.js';\nimport type {\n\tProviderApiCollectionResult,\n\tProviderApiPagedResult,\n\tProviderHierarchyResult,\n\tProviderOrganization,\n\tProviderPullRequest,\n\tProviderRepository,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tgetProviderPullRequestIdentity,\n\tprovidersMetadata,\n\tPullRequestFilter,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport {\n\tcollectProviderPagedResult,\n\tflatSettledOrThrow,\n\tmergeCollectionMetadata,\n\tparsePageCursor,\n\ttoPageCursor,\n} from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[GitCloudHostIntegrationId.Bitbucket];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\n\nexport class BitbucketIntegration extends GitHostIntegration<\n\tGitCloudHostIntegrationId.Bitbucket,\n\tBitbucketRepositoryDescriptor\n> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = GitCloudHostIntegrationId.Bitbucket;\n\tprotected readonly key = this.id;\n\treadonly name: string = 'Bitbucket';\n\tget domain(): string {\n\t\treturn metadata.domain;\n\t}\n\n\tprotected get apiBaseUrl(): string {\n\t\treturn 'https://api.bitbucket.org/2.0';\n\t}\n\n\tprotected override async mergeProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tpr: PullRequest,\n\t\toptions?: {\n\t\t\tmergeMethod?: PullRequestMergeMethod;\n\t\t},\n\t): Promise<boolean> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.mergePullRequest(toTokenWithInfo(this.id, session), pr, {\n\t\t\tmergeMethod: options?.mergeMethod,\n\t\t});\n\t}\n\n\tpublic override async getRepoInfo(repo: {\n\t\towner: string;\n\t\tname: string;\n\t\tproject?: string;\n\t\tconnectionId?: string;\n\t}): Promise<ProviderRepository | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\t// `connectionId` targets a specific account (multi-account); omitted reads the primary.\n\t\tconst session = await this.resolveReadSession(repo.connectionId, undefined);\n\t\tif (session == null) return undefined;\n\n\t\treturn api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, {\n\t\t\tbaseUrl: this.apiBaseUrl,\n\t\t});\n\t}\n\n\tprotected override async getProviderAccountForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | UnidentifiedAuthor | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getAccountForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{\n\t\t\t\tavatarSize: options?.avatarSize,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderAccountForEmail(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_email: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t},\n\t): Promise<Account | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\tprotected override async getProviderDefaultBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tcancellation?: AbortSignal,\n\t): Promise<DefaultBranch | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getDefaultBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{ baseUrl: this.apiBaseUrl },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async getProviderLinkedIssueOrPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\t{ id }: { id: string; key: string },\n\t\ttype: undefined | IssueOrPullRequestType,\n\t): Promise<IssueOrPullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getIssueOrPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrl,\n\t\t\t{\n\t\t\t\ttype: type,\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot:\n\t * provider-apis has no single pull request read for Bitbucket, so this uses our own.\n\t */\n\tprotected override async getProviderPullRequestsBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string } } | undefined,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, c =>\n\t\t\tapi.getPullRequest(this, tokenWithInfo, c.owner, c.repo, String(c.number), this.apiBaseUrl, {\n\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\tdeferFailure: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently, through our own client: provider-apis' pull request list has\n\t * no source-branch filter.\n\t */\n\tprotected override async getProviderPullRequestsForBranches(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { owner: string; repo: string; project?: string; branch: string; headOwner?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string }; limit: number },\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<{ pullRequests: PullRequestShape[]; truncated: boolean }>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(targets, providerFanOutConcurrency, t =>\n\t\t\tapi.getPullRequestsForBranch(this, tokenWithInfo, t.owner, t.repo, t.branch, this.apiBaseUrl, {\n\t\t\t\theadOwner: t.headOwner,\n\t\t\t\tlimit: options.limit,\n\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\tdeferFailure: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\tprotected override async getProviderIssue(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<Issue | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getIssue(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrl,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestForBranch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tbranch: string,\n\t\t_options?: {\n\t\t\tavatarSize?: number;\n\t\t\tinclude?: PullRequestState[];\n\t\t},\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getPullRequestForBranch(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\tbranch,\n\t\t\tthis.apiBaseUrl,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getPullRequestForCommit(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\trev,\n\t\t\tthis.apiBaseUrl,\n\t\t);\n\t}\n\n\tprotected override async getProviderRepositoryMetadata(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\tcancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getRepositoryMetadata(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\trepo.owner,\n\t\t\trepo.name,\n\t\t\t{ baseUrl: this.apiBaseUrl },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprivate _accounts: Map<string, Account | undefined> | undefined;\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst { accessToken } = session;\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\n\t\tconst cachedAccount = this._accounts.get(accessToken);\n\t\tif (cachedAccount == null) {\n\t\t\tconst api = await this.getProvidersApi();\n\t\t\tconst user = await api.getCurrentUser(toTokenWithInfo(this.id, session));\n\t\t\tthis._accounts.set(\n\t\t\t\taccessToken,\n\t\t\t\tuser\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tprovider: this,\n\t\t\t\t\t\t\tid: user.id,\n\t\t\t\t\t\t\tname: user.name ?? undefined,\n\t\t\t\t\t\t\temail: user.email ?? undefined,\n\t\t\t\t\t\t\tavatarUrl: user.avatarUrl ?? undefined,\n\t\t\t\t\t\t\tusername: user.username ?? undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined,\n\t\t\t);\n\t\t}\n\n\t\treturn this._accounts.get(accessToken);\n\t}\n\n\t/** The profile request the account cache would otherwise answer; see `IntegrationBase.validateCredential`. */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tif ((await api.getCurrentUser(toTokenWithInfo(this.id, session))) == null) {\n\t\t\tthrow new Error('Bitbucket did not confirm the credential');\n\t\t}\n\t}\n\n\t/**\n\t * Bitbucket's `403` for a token missing the OAuth scopes a request needs, which a reconnect fixes by consenting to\n\t * them again; see `IntegrationBase.isCredentialRefusal`.\n\t */\n\tprotected override isCredentialRefusal(refusal: ProviderRefusal): boolean {\n\t\treturn refusal.status === 403 && /required privilege scopes/i.test(refusal.detail ?? '');\n\t}\n\n\tprivate _workspaces: Map<string, ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined> | undefined;\n\tprivate async getProviderResourcesForCurrentUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tforce: boolean = false,\n\t): Promise<ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined> {\n\t\tthis._workspaces ??= new Map<string, ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined>();\n\t\tconst { accessToken } = session;\n\t\tconst cachedResources = this._workspaces.get(accessToken);\n\t\tif (cachedResources != null && !force) return cachedResources;\n\n\t\tconst api = await this.getProvidersApi();\n\t\tconst resources = await api.getBitbucketResourcesForCurrentUser(toTokenWithInfo(this.id, session));\n\t\tif (resources == null) return undefined;\n\n\t\tconst values = resources.values.map(r => ({ ...r, key: r.id, name: r.name ?? r.slug }));\n\t\tconst metadata = mergeCollectionMetadata(\n\t\t\tresources.metadata,\n\t\t\tresources.paging?.truncated === true ? { completeness: 'partial' } : undefined,\n\t\t);\n\t\tconst result: ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> = {\n\t\t\tvalues: values,\n\t\t\t...(metadata != null ? { metadata: metadata } : {}),\n\t\t};\n\n\t\t// A partial workspace prefix is useful to the current read but must not become authoritative cache state:\n\t\t// a transient page-2 failure must be retried on the next call rather than hiding every later workspace\n\t\t// until disconnect.\n\t\tif (metadata == null || metadata.completeness === 'complete') {\n\t\t\tthis._workspaces.set(accessToken, result);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprotected override async getProviderOrganizationsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderOrganization> | undefined> {\n\t\tconst workspaces = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspaces == null) return undefined;\n\n\t\treturn {\n\t\t\tvalues: workspaces.values.map(w => ({\n\t\t\t\tid: w.id,\n\t\t\t\tproviderId: this.id,\n\t\t\t\tname: w.slug,\n\t\t\t\turl: `https://bitbucket.org/${w.slug}`,\n\t\t\t})),\n\t\t\t...(workspaces.metadata != null ? { metadata: workspaces.metadata } : {}),\n\t\t};\n\t}\n\n\tprotected override async getProviderRepositoriesForOrg(\n\t\tsession: ProviderAuthenticationSession,\n\t\torg: string,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getReposForBitbucketWorkspace(toTokenWithInfo(this.id, session), org, {\n\t\t\tcursor: options?.cursor,\n\t\t});\n\t}\n\n\tprotected override async searchProviderMyPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\t_cancellation?: AbortSignal,\n\t\toptions?: SearchMyPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (repos != null) {\n\t\t\t// TODO: implement repos version\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst state = options?.state;\n\t\tconst states = toProviderPullRequestStates(state);\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\t// `user.id` feeds both the authored workspace reads and the reviewer BBQL clause; guard on it so we\n\t\t// never issue requests/queries with an undefined uuid. `username` isn't used here, so don't gate on it.\n\t\tif (user?.id == null) return undefined;\n\n\t\tconst workspacesResult = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspacesResult == null) return undefined;\n\n\t\tconst workspaces = workspacesResult.values;\n\t\tif (workspaces.length === 0) return [];\n\n\t\tconst authoredPrs = workspaces.map(async ws => {\n\t\t\tconst prs = await api.getBitbucketPullRequestsAuthoredByUserForWorkspace(\n\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\tuser.id,\n\t\t\t\tws.slug,\n\t\t\t\t{ states: states },\n\t\t\t);\n\t\t\treturn prs?.data.map(pr => fromProviderPullRequest(pr, this));\n\t\t});\n\n\t\tif (!options?.includeReviewRequested) {\n\t\t\treturn [\n\t\t\t\t...uniqueBy(\n\t\t\t\t\tawait flatSettled(authoredPrs),\n\t\t\t\t\tpr => pr.url,\n\t\t\t\t\t(orig, _cur) => orig,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\t// Bitbucket's reviewing PRs require a repo-scoped BBQL query; keep that sweep opt-in so the default\n\t\t// \"my pull requests\" feed stays aligned with backends that only expose authored PRs.\n\t\tconst stateClause =\n\t\t\tstate === 'closed'\n\t\t\t\t? '(state=\"DECLINED\" OR state=\"SUPERSEDED\")'\n\t\t\t\t: state === 'merged'\n\t\t\t\t\t? 'state=\"MERGED\"'\n\t\t\t\t\t: state === 'all'\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: 'state=\"OPEN\"';\n\n\t\tconst workspaceRepos = await this.getWorkspaceRepoInputs();\n\t\tif (workspaceRepos.length === 0) {\n\t\t\treturn [\n\t\t\t\t...uniqueBy(\n\t\t\t\t\tawait flatSettled(authoredPrs),\n\t\t\t\t\tpr => pr.url,\n\t\t\t\t\t(orig, _cur) => orig,\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\n\t\tconst reviewerClause = `reviewers.uuid=\"${user.id}\"`;\n\t\tconst reviewingPrs = api\n\t\t\t.getPullRequestsForRepos(toTokenWithInfo(this.id, session), workspaceRepos, {\n\t\t\t\tquery: stateClause ? `${stateClause} AND ${reviewerClause}` : reviewerClause,\n\t\t\t})\n\t\t\t.then(r => r.values?.map(pr => fromProviderPullRequest(pr, this)));\n\n\t\treturn [\n\t\t\t...uniqueBy(\n\t\t\t\tawait flatSettled([...authoredPrs, reviewingPrs]),\n\t\t\t\tpr => pr.url,\n\t\t\t\t(orig, _cur) => orig,\n\t\t\t),\n\t\t];\n\t}\n\n\tprotected override async getProviderMyPullRequestsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: {\n\t\t\tstate?: PullRequestStateFilter[];\n\t\t\tcursor?: string;\n\t\t\tincludeReviewRequested?: boolean;\n\t\t\tfilters?: PullRequestFilter[];\n\t\t},\n\t): Promise<ProviderApiPagedResult<ProviderPullRequest> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\tif (user?.id == null) return undefined;\n\n\t\tconst workspacesResult = await this.getProviderResourcesForCurrentUser(session);\n\t\tif (workspacesResult == null) return undefined;\n\n\t\tconst workspaces = workspacesResult.values;\n\t\tif (workspaces.length === 0) {\n\t\t\tconst incomplete =\n\t\t\t\tworkspacesResult.metadata != null && workspacesResult.metadata.completeness !== 'complete';\n\t\t\treturn {\n\t\t\t\tvalues: [],\n\t\t\t\tpaging: { cursor: '{}', more: false, truncated: incomplete || undefined },\n\t\t\t\t...(workspacesResult.metadata != null ? { metadata: workspacesResult.metadata } : {}),\n\t\t\t};\n\t\t}\n\n\t\t// Account-wide \"my PRs\" for Bitbucket = the user's authored PRs across every workspace they belong to,\n\t\t// plus the PRs they've been requested to review. Bitbucket's cross-workspace read is per-workspace and\n\t\t// numbered-page, so drain each workspace fully (bounded by a defensive backstop) and concatenate.\n\t\t// There's no single cross-workspace cursor, so the aggregate is one page; `truncated` is set when a\n\t\t// workspace hit the backstop with more pages left, or when a workspace's read was dropped by a failure.\n\t\tconst states = toProviderPullRequestStates(options?.state);\n\t\tconst requested = options?.filters?.length ? new Set(options.filters) : undefined;\n\t\tconst wantAuthored = requested == null || requested.has(PullRequestFilter.Author);\n\t\tconst wantReviewRequested =\n\t\t\trequested?.has(PullRequestFilter.ReviewRequested) ?? options?.includeReviewRequested === true;\n\t\tconst maxPagesPerWorkspace = 20;\n\t\tlet truncated = workspacesResult.metadata != null && workspacesResult.metadata.completeness !== 'complete';\n\t\t// Structured per-scope failures from BOTH the authored and reviewer slices. A rejected scope is recorded\n\t\t// here (never re-thrown) so successful sibling workspaces/repos survive and the ProviderBackend facade\n\t\t// maps each failure to an actionable warning + `fetchFailed` (auth/rate-limit failures still drive\n\t\t// recovery through their warning kind, matching the SDK's own collect-across-scopes model).\n\t\tconst failures: CollectionScopeFailure[] = [];\n\t\tlet aggregateMetadata = workspacesResult.metadata;\n\t\tconst absorbCollectionResult = (result: ProviderHierarchyResult<unknown>): void => {\n\t\t\taggregateMetadata = mergeCollectionMetadata(aggregateMetadata, result.metadata);\n\t\t\tif (result.truncated || (result.metadata != null && result.metadata.completeness !== 'complete')) {\n\t\t\t\ttruncated = true;\n\t\t\t}\n\t\t};\n\t\tconst settled = wantAuthored\n\t\t\t? await Promise.allSettled(\n\t\t\t\t\tworkspaces.map(async ws => {\n\t\t\t\t\t\treturn collectProviderPagedResult(\n\t\t\t\t\t\t\tasync cursor => {\n\t\t\t\t\t\t\t\tconst result = await api.getBitbucketPullRequestsAuthoredByUserForWorkspace(\n\t\t\t\t\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t\t\t\t\tuser.id,\n\t\t\t\t\t\t\t\t\tws.slug,\n\t\t\t\t\t\t\t\t\t{ states: states, page: parsePageCursor(cursor) },\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tif (result == null) return undefined;\n\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tvalues: result.data,\n\t\t\t\t\t\t\t\t\tpaging: {\n\t\t\t\t\t\t\t\t\t\tmore: result.hasMore,\n\t\t\t\t\t\t\t\t\t\tcursor:\n\t\t\t\t\t\t\t\t\t\t\tresult.hasMore && result.nextPage != null\n\t\t\t\t\t\t\t\t\t\t\t\t? toPageCursor(result.nextPage)\n\t\t\t\t\t\t\t\t\t\t\t\t: '{}',\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmaxPagesPerWorkspace,\n\t\t\t\t\t\t\t{ providerId: this.id, resourceId: ws.slug },\n\t\t\t\t\t\t);\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t: [];\n\n\t\tconst prsByIdentity = new Map<string, ProviderPullRequest>();\n\t\tlet unkeyedPullRequest = 0;\n\t\tconst addPullRequest = (pr: ProviderPullRequest): void => {\n\t\t\tconst key = getProviderPullRequestIdentity(pr) ?? `unkeyed:${unkeyedPullRequest++}`;\n\t\t\tif (!prsByIdentity.has(key)) {\n\t\t\t\tprsByIdentity.set(key, pr);\n\t\t\t}\n\t\t};\n\t\t// `allSettled` preserves order, so `settled[i]` is `workspaces[i]`. A rejected workspace becomes a\n\t\t// structured failure (attributed to its slug) instead of a generic truncation or a re-throw, preserving\n\t\t// every sibling workspace's authored PRs.\n\t\tsettled.forEach((outcome, i) => {\n\t\t\tif (outcome.status !== 'fulfilled') {\n\t\t\t\tfailures.push(this.toWorkspaceFailure(workspaces[i].slug, outcome.reason));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tabsorbCollectionResult(outcome.value);\n\t\t\tfor (const pr of outcome.value.values) {\n\t\t\t\taddPullRequest(pr);\n\t\t\t}\n\t\t});\n\n\t\t// Bitbucket's account-wide (per-workspace) endpoint returns authored PRs only, and the SDK exposes no\n\t\t// workspace-level reviewer query — only a repo-scoped one. Adding the reviewer slice therefore requires\n\t\t// draining every workspace's full repo list and then a per-repo `getPullRequestsForRepo` with `reviewerId`\n\t\t// (O(workspaces × repos) requests), so keep it opt-in: gate it on `includeReviewRequested` so the default\n\t\t// sweep matches the gkcli baseline (authored PRs only, no reviewer fan-out) and a caller pays that cost\n\t\t// only when it deliberately asks for review-requested PRs.\n\t\tif (wantReviewRequested) {\n\t\t\t// Enumerate the account's repos by draining each resolved workspace's repository list, then drain the\n\t\t\t// real per-repo paged `getPullRequestsForRepo` for each repo with `reviewerId`, so review-requested PRs\n\t\t\t// aren't bounded to the currently-open remotes and a reviewer PR past the first page isn't dropped.\n\t\t\t// Structured per-scope failures are collected as CollectionScopeFailure so the ProviderBackend facade\n\t\t\t// maps them to actionable warnings (Step 3).\n\t\t\tconst maxReposPagesPerWorkspace = 20;\n\t\t\tconst maxPrPagesPerRepo = 20;\n\t\t\t// Bound concurrency: workspaces are few, so process them concurrently, but drain each workspace's repos\n\t\t\t// in a bounded batch rather than an unbounded Promise.all over every repo in every workspace.\n\t\t\tconst repoBatchSize = 5;\n\n\t\t\tawait Promise.all(\n\t\t\t\tworkspaces.map(async ws => {\n\t\t\t\t\tlet repos: ProviderRepository[];\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst discovered = await collectProviderPagedResult(\n\t\t\t\t\t\t\tcursor =>\n\t\t\t\t\t\t\t\tapi.getReposForBitbucketWorkspace(toTokenWithInfo(this.id, session), ws.slug, {\n\t\t\t\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tmaxReposPagesPerWorkspace,\n\t\t\t\t\t\t\t{ providerId: this.id, resourceId: ws.slug },\n\t\t\t\t\t\t);\n\t\t\t\t\t\trepos = discovered.values;\n\t\t\t\t\t\tabsorbCollectionResult(discovered);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\t// Record the workspace as a structured failure and keep going: the failure metadata drives\n\t\t\t\t\t\t// the warning + `fetchFailed` + incompleteness for every kind (auth/rate-limit stay\n\t\t\t\t\t\t// actionable via their warning kind), so sibling workspaces' repos are still drained.\n\t\t\t\t\t\tfailures.push(this.toWorkspaceFailure(ws.slug, ex));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst drained = await batchResults(repos, repoBatchSize, async repo => {\n\t\t\t\t\t\tconst reviewing = await collectProviderPagedResult(\n\t\t\t\t\t\t\tcursor =>\n\t\t\t\t\t\t\t\tapi.getPullRequestsForRepo(\n\t\t\t\t\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\t\t\t\t\t{ namespace: repo.namespace, name: repo.name },\n\t\t\t\t\t\t\t\t\t{ reviewerId: user.id, states: states, cursor: cursor },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tmaxPrPagesPerRepo,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tproviderId: this.id,\n\t\t\t\t\t\t\t\tresourceId: ws.slug,\n\t\t\t\t\t\t\t\trepositoryId: `${repo.namespace}/${repo.name}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn { repo: repo, reviewing: reviewing };\n\t\t\t\t\t});\n\n\t\t\t\t\tfor (let i = 0; i < drained.length; i++) {\n\t\t\t\t\t\tconst outcome = drained[i];\n\t\t\t\t\t\tif (outcome.status !== 'fulfilled') {\n\t\t\t\t\t\t\tconst repo = repos[i];\n\t\t\t\t\t\t\tfailures.push(\n\t\t\t\t\t\t\t\tthis.toRepositoryFailure(\n\t\t\t\t\t\t\t\t\t`${repo?.namespace ?? ws.slug}/${repo?.name ?? 'unknown'}`,\n\t\t\t\t\t\t\t\t\toutcome.reason,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst { reviewing } = outcome.value;\n\t\t\t\t\t\tabsorbCollectionResult(reviewing);\n\t\t\t\t\t\tfor (const pr of reviewing.values) {\n\t\t\t\t\t\t\taddPullRequest(pr);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\n\t\t// Every slice that ran (authored workspaces always, reviewer workspaces/repos when opted in) records its\n\t\t// per-scope rejections as structured failures instead of re-throwing: re-throwing would discard every\n\t\t// successful sibling's PRs. Auth/rate-limit failures stay actionable through the metadata (the facade maps\n\t\t// kind `authentication` → an `auth` warning, `rate-limit` → a `rate-limit` warning) while the survivors are\n\t\t// returned with `fetchFailed`.\n\t\tconst metadata: CollectionMetadata | undefined = mergeCollectionMetadata(\n\t\t\tfailures.length > 0 ? { completeness: 'partial', failures: failures } : undefined,\n\t\t\taggregateMetadata,\n\t\t);\n\n\t\treturn {\n\t\t\tvalues: [...prsByIdentity.values()],\n\t\t\tpaging: { cursor: '{}', more: false, truncated: truncated || undefined },\n\t\t\tmetadata: metadata,\n\t\t};\n\t}\n\n\t/** Classifies a caught workspace-scope error into a structured {@link CollectionScopeFailure}. */\n\tprivate toWorkspaceFailure(workspaceSlug: string, ex: unknown): CollectionScopeFailure {\n\t\treturn toCollectionScopeFailure({ providerId: this.id, resourceId: workspaceSlug }, ex);\n\t}\n\n\t/** Classifies a caught repository-scope error into a structured {@link CollectionScopeFailure}. */\n\tprivate toRepositoryFailure(repositoryId: string, ex: unknown): CollectionScopeFailure {\n\t\treturn toCollectionScopeFailure({ providerId: this.id, repositoryId: repositoryId }, ex);\n\t}\n\n\tprotected override async searchProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tsearchQuery: string,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchPullRequestsOptions,\n\t): Promise<PullRequest[] | undefined> {\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\tconst api = await this.getProvidersApi();\n\t\tif (!api) return undefined;\n\n\t\tconst workspaceRepos =\n\t\t\trepos != null\n\t\t\t\t? repos.map(r => ({ name: r.name, namespace: r.owner }))\n\t\t\t\t: await this.getWorkspaceRepoInputs();\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\t\t// An explicitly-empty `repos` means \"search these zero repos\" -> no results; reserve `undefined`\n\t\t// (\"scope couldn't be determined\") for when no repos were requested and none were discovered.\n\t\tif (workspaceRepos.length === 0) return repos != null ? [] : undefined;\n\n\t\tconst token = toTokenWithInfo(this.id, session);\n\t\tconst states = toProviderPullRequestStates(options?.include);\n\t\tconst providerPullRequests = await flatSettledOrThrow(\n\t\t\tworkspaceRepos.map(async repo => {\n\t\t\t\tconst result = await collectProviderPagedResult(cursor => {\n\t\t\t\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\t\t\t\treturn api.getPullRequestsForRepo(token, repo, {\n\t\t\t\t\t\tcursor: cursor,\n\t\t\t\t\t\tquery: searchQuery,\n\t\t\t\t\t\tstates: states,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\treturn result.values;\n\t\t\t}),\n\t\t);\n\t\tif (cancellation?.aborted) throw new CancellationError();\n\n\t\treturn providerPullRequests.map(pr => fromProviderPullRequest(pr, this));\n\t}\n\n\tprivate async getWorkspaceRepoInputs(): Promise<{ name: string; namespace: string }[]> {\n\t\tconst remotes = await this.ctx.repositories.getOpenRemotes();\n\t\tconst inputs = await nonnullSettled(\n\t\t\tremotes.map(async (r: GitRemote) => {\n\t\t\t\tconst integration = await this.authenticationService.getByRemote(r);\n\t\t\t\tif (integration !== this) return undefined;\n\n\t\t\t\t// Use the remote provider's parsing rather than splitting `r.path`, so adornments like a\n\t\t\t\t// trailing `.git` or extra path segments don't leak into the namespace/name.\n\t\t\t\tconst namespace = r.provider?.owner;\n\t\t\t\tconst name = r.provider?.repoName;\n\t\t\t\treturn namespace != null && name != null ? { name: name, namespace: namespace } : undefined;\n\t\t\t}),\n\t\t);\n\t\t// Dedupe: a repo with multiple remotes (e.g. `origin` + `upstream`) can map to the same input,\n\t\t// which would otherwise fetch and return the same PRs more than once.\n\t\treturn [...new Map(inputs.map(i => [`${i.namespace}/${i.name}`, i])).values()];\n\t}\n\n\tprotected override async searchProviderMyIssues(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepos?: BitbucketRepositoryDescriptor[],\n\t): Promise<IssueShape[] | undefined> {\n\t\tif (repos == null || repos.length === 0) return undefined;\n\n\t\tconst user = await this.getProviderCurrentAccount(session);\n\t\tif (user?.username == null) return undefined;\n\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (!api) return undefined;\n\n\t\tconst issueResult = await flatSettled(\n\t\t\trepos.map(repo => {\n\t\t\t\treturn api.getUsersIssuesForRepo(\n\t\t\t\t\tthis,\n\t\t\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t\t\tuser.id,\n\t\t\t\t\trepo.owner,\n\t\t\t\t\trepo.name,\n\t\t\t\t\tthis.apiBaseUrl,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\treturn issueResult;\n\t}\n\n\t/**\n\t * Bitbucket is not an issue provider on the ProviderBackend surface: Bitbucket Cloud deprecated its issue\n\t * tracker in favor of dedicated issue integrations (e.g. Jira). The legacy per-repo `getUsersIssuesForRepo`\n\t * client is retained only for autolink/hover enrichment, not for the ProviderBackend issue reads, so the\n\t * facade reports issues as unsupported rather than serving a deprecated, partial source.\n\t */\n\toverride get supportsIssues(): boolean {\n\t\treturn false;\n\t}\n\n\tprivate readonly storagePrefix = 'bitbucket';\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tif (this._session == null) return;\n\n\t\tconst accountStorageKey = md5(this._session.accessToken);\n\n\t\tconst storedAccount = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:account`);\n\t\tconst storedWorkspaces = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:workspaces`);\n\n\t\tlet account: Account | undefined = storedAccount?.data ? { ...storedAccount.data, provider: this } : undefined;\n\n\t\tconst storedWorkspacesData = storedWorkspaces?.data as\n\t\t\t| ProviderApiCollectionResult<BitbucketWorkspaceDescriptor>\n\t\t\t| BitbucketWorkspaceDescriptor[]\n\t\t\t| undefined;\n\t\tlet workspaces: ProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined;\n\t\tif (\n\t\t\t!Array.isArray(storedWorkspacesData) &&\n\t\t\tArray.isArray(storedWorkspacesData?.values) &&\n\t\t\t(storedWorkspacesData.metadata == null || storedWorkspacesData.metadata.completeness === 'complete')\n\t\t) {\n\t\t\tworkspaces = {\n\t\t\t\tvalues: storedWorkspacesData.values.map((o: BitbucketWorkspaceDescriptor) => ({ ...o })),\n\t\t\t\t...(storedWorkspacesData.metadata != null ? { metadata: storedWorkspacesData.metadata } : {}),\n\t\t\t};\n\t\t}\n\n\t\tif (storedAccount == null) {\n\t\t\taccount = await this.getProviderCurrentAccount(this._session);\n\t\t\tif (account != null) {\n\t\t\t\t// Clear all other stored workspaces and repositories and accounts when our session changes\n\t\t\t\tawait this.ctx.storage.deleteWithPrefix(this.storagePrefix);\n\t\t\t\tawait this.ctx.storage.store(`${this.storagePrefix}:${accountStorageKey}:account`, {\n\t\t\t\t\tv: 1,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tid: account.id,\n\t\t\t\t\t\tname: account.name,\n\t\t\t\t\t\temail: account.email,\n\t\t\t\t\t\tavatarUrl: account.avatarUrl,\n\t\t\t\t\t\tusername: account.username,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\t\tthis._accounts.set(this._session.accessToken, account);\n\n\t\tif (workspaces == null) {\n\t\t\tconst discovered = await this.getProviderResourcesForCurrentUser(this._session, true);\n\t\t\tif (discovered?.metadata == null || discovered.metadata.completeness === 'complete') {\n\t\t\t\tworkspaces = discovered;\n\t\t\t\tif (workspaces != null) {\n\t\t\t\t\tawait this.ctx.storage.store(`${this.storagePrefix}:${accountStorageKey}:workspaces`, {\n\t\t\t\t\t\tv: 2,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t\tdata: workspaces,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (workspaces != null) {\n\t\t\tthis._workspaces ??= new Map<\n\t\t\t\tstring,\n\t\t\t\tProviderApiCollectionResult<BitbucketWorkspaceDescriptor> | undefined\n\t\t\t>();\n\t\t\tthis._workspaces.set(this._session.accessToken, workspaces);\n\t\t}\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._accounts = undefined;\n\t\tthis._workspaces = undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAqDA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAE/E,IAAa,uBAAb,cAA0C,mBAGxC;CACD,eAAqE;CACrE,KAAS;CACT,MAAyB,KAAK;CAC9B,O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AK,cAAc,GAAG,kBAAkB,WAAW;KAClF,GAAG;KACH,WAAW,KAAK,IAAI;KACpB,MAAM;MACL,IAAI,QAAQ;MACZ,MAAM,QAAQ;MACd,OAAO,QAAQ;MACf,WAAW,QAAQ;MACnB,UAAU,QAAQ;KACnB;IACD,CAAC;GACF;EACD;EACA,KAAK,8BAAc,IAAI,IAAiC;EACxD,KAAK,UAAU,IAAI,KAAK,SAAS,aAAa,OAAO;EAErD,IAAI,cAAc,MAAM;GACvB,MAAM,aAAa,MAAM,KAAK,mCAAmC,KAAK,UAAU,IAAI;GACpF,IAAI,YAAY,YAAY,QAAQ,WAAW,SAAS,iBAAiB,YAAY;IACpF,aAAa;IACb,IAAI,cAAc,MACjB,MAAM,KAAK,IAAI,QAAQ,MAAM,GAAG,KAAK,cAAc,GAAG,kBAAkB,cAAc;KACrF,GAAG;KACH,WAAW,KAAK,IAAI;KACpB,MAAM;IACP,CAAC;GAEH;EACD;EACA,IAAI,cAAc,MAAM;GACvB,KAAK,gCAAgB,IAAI,IAGvB;GACF,KAAK,YAAY,IAAI,KAAK,SAAS,aAAa,UAAU;EAC3D;CACD;CAEA,uBAAgD;EAC/C,KAAK,YAAY,KAAA;EACjB,KAAK,cAAc,KAAA;CACpB;AACD"}
@@ -2,19 +2,19 @@ import { Emitter } from "../../../utils/event.js";
2
2
  import { RepositoryDescriptor } from "../../../git/models/resourceDescriptor.js";
3
3
  import { IssueOrPullRequest, IssueOrPullRequestState } from "../../../git/models/issueOrPullRequest.js";
4
4
  import { Issue, IssueSearchCriteria, IssueShape } from "../../../git/models/issue.js";
5
- import { PullRequest, PullRequestFilter, PullRequestMergeMethod, PullRequestSearchCriteria, PullRequestStackInfo, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
5
+ import { PullRequest, PullRequestFilter, PullRequestMergeMethod, PullRequestSearchCriteria, PullRequestShape, PullRequestStackInfo, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
6
6
  import { Account, UnidentifiedAuthor } from "../../../git/models/author.js";
7
7
  import { DefaultBranch } from "../../../git/models/defaultBranch.js";
8
8
  import { RepositoryMetadata } from "../../../git/models/repositoryMetadata.js";
9
9
  import { PullRequestUrlIdentity } from "../../../git/utils/pullRequest.utils.js";
10
10
  import { ProviderAuthenticationSession } from "../authentication/models.js";
11
11
  import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId } from "../constants.js";
12
+ import { ProviderOrganization } from "../results.js";
12
13
  import { ProviderPullRequestCount, ProviderPullRequestSearchPage } from "../models/pullRequestReads.js";
13
14
  import { ProvidersApi } from "./providersApi.js";
14
15
  import { ProviderIssueSearchPage, SearchMyIssuesOptions } from "../models/issueReads.js";
15
16
  import { GitHostIntegration, SearchMyPullRequestsOptions, SearchPullRequestsOptions } from "../models/gitHostIntegration.js";
16
17
  import "../models/integration.js";
17
- import { ProviderOrganization } from "../results.js";
18
18
  import { ProviderApiPagedResult, ProviderHierarchyResult, ProviderPullRequest, ProviderRepoInput, ProviderRepository } from "./models.js";
19
19
  import { IntegrationConnectionChangeEvent } from "../integrationService.js";
20
20
  import { IntegrationAuthenticationService } from "../authentication/integrationAuthenticationService.js";
@@ -120,14 +120,58 @@ declare abstract class GitHubIntegrationBase<ID extends GitHubIntegrationIds> ex
120
120
  criteria?: IssueSearchCriteria;
121
121
  }[], cancellation?: AbortSignal): Promise<(number | undefined)[] | undefined>;
122
122
  /**
123
- * Resolves several issues by `(owner, repo, number)` in ONE request, by aliasing the point read rather than a
124
- * search — see {@link GitHubApi.getIssuesBatch} for why that distinction is the whole design.
123
+ * Resolves several issues by `(owner, repo, number)` by aliasing the point read rather than a search — see
124
+ * {@link GitHubApi.getIssuesBatch} for why that distinction is the whole design — chunked into requests of up
125
+ * to {@link issuesBatchChunkSize} coordinates, run with bounded concurrency. Settled per target already: a
126
+ * coordinate whose alias fails on its own (e.g. an org enforcing SAML SSO the token isn't authorized for)
127
+ * rejects only that slot, and a chunk that throws rejects only its own slots.
125
128
  */
126
129
  protected getProviderIssuesBatch(session: ProviderAuthenticationSession, coordinates: readonly {
127
130
  owner: string;
128
131
  repo: string;
129
132
  number: number;
130
- }[], cancellation?: AbortSignal): Promise<(IssueShape | undefined)[] | undefined>;
133
+ project?: string;
134
+ }[], cancellation?: AbortSignal): Promise<PromiseSettledResult<IssueShape | undefined>[] | undefined>;
135
+ /**
136
+ * Resolves several pull requests by `(owner, repo, number)` by aliasing the point read — see
137
+ * {@link GitHubApi.getPullRequestsBatch} — chunked into requests of up to {@link pullRequestsBatchChunkSize}
138
+ * coordinates, run with bounded concurrency. Rows take the same conversion as the account-wide list rows, so a
139
+ * pull request reads the same whichever of the two returned it.
140
+ *
141
+ * A chunk that throws rejects only its own slots, so its sibling chunks still answer.
142
+ */
143
+ protected getProviderPullRequestsBatch(session: ProviderAuthenticationSession, coordinates: readonly {
144
+ owner: string;
145
+ repo: string;
146
+ number: number;
147
+ project?: string;
148
+ }[], options: {
149
+ currentAccount?: {
150
+ id: string;
151
+ username?: string;
152
+ };
153
+ } | undefined, cancellation?: AbortSignal): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined>;
154
+ /**
155
+ * Finds each branch's pull requests by aliasing a head-ref-name query per target — see
156
+ * {@link GitHubApi.getPullRequestsForBranches} — chunked and converted exactly as
157
+ * {@link getProviderPullRequestsBatch} is, with the same per-target and per-chunk failure isolation.
158
+ */
159
+ protected getProviderPullRequestsForBranches(session: ProviderAuthenticationSession, targets: readonly {
160
+ owner: string;
161
+ repo: string;
162
+ project?: string;
163
+ branch: string;
164
+ headOwner?: string;
165
+ }[], options: {
166
+ currentAccount?: {
167
+ id: string;
168
+ username?: string;
169
+ };
170
+ limit: number;
171
+ }, cancellation?: AbortSignal): Promise<PromiseSettledResult<{
172
+ pullRequests: PullRequestShape[];
173
+ truncated: boolean;
174
+ }>[] | undefined>;
131
175
  /**
132
176
  * Counts several pull-request scopes in ONE request. Like {@link countProviderIssues}, GitHub's `search`
133
177
  * reports `issueCount` on a zero-node selection, so a count preview costs no pull-request transfer.
@@ -1,12 +1,13 @@
1
- import { batch } from "../../../utils/promise.js";
1
+ import { chunk } from "../../../utils/array.js";
2
+ import { batch, mapBounded } from "../../../utils/promise.js";
2
3
  import { getGitHubNoReplyAddressParts } from "../../../git/remotes/github.js";
3
4
  import "../../../git/models/pullRequest.js";
4
5
  import { IntegrationReadUnavailableError } from "../errors.js";
5
- import { toCollectionScopeFailure } from "../collectionMetadata.js";
6
6
  import "../constants.js";
7
+ import { toCollectionScopeFailure } from "../collectionMetadata.js";
7
8
  import { toTokenWithInfo } from "../authentication/models.js";
8
9
  import "../providerFilters.js";
9
- import { getProviderPullRequestIdentity, providersMetadata, toProviderPullRequest } from "./models.js";
10
+ import { fromProviderPullRequest, getProviderPullRequestIdentity, providersMetadata, toProviderPullRequest } from "./models.js";
10
11
  import { gitHubPullRequestRelationshipQualifiers } from "../../git-github/api/pullRequestSearchQuery.js";
11
12
  import { GitHostIntegration } from "../models/gitHostIntegration.js";
12
13
  import { getGitHubPullRequestIdentityFromMaybeUrl } from "./github/github.utils.js";
@@ -40,6 +41,51 @@ const cloudEnterpriseAuthProvider = Object.freeze({
40
41
  });
41
42
  /** How many per-login SSH signing-key lookups to run concurrently, to avoid a request burst that trips rate limiting. */
42
43
  const sshSigningKeyResolveBatchSize = 10;
44
+ const pullRequestsBatchChunkSize = 25;
45
+ /**
46
+ * How many coordinates go into one aliased issue request.
47
+ *
48
+ * Measured rather than inherited from `issueCountChunkSize`, since that one rests on a zero-node selection and
49
+ * this carries the full issue projection per alias. Against the live API on all-resolving coordinates: 10 took
50
+ * 875ms, 25 took 890ms — so up to 25 is effectively free — 50 took 1.3s, and 75 took 2.7s. No complexity refusal
51
+ * appeared up to 100.
52
+ *
53
+ * 25 is where latency is still flat, with room before it degrades. It also puts any realistic correlation batch
54
+ * in ONE request, which is the whole point of the read.
55
+ */
56
+ const issuesBatchChunkSize = 25;
57
+ /**
58
+ * Runs an aliased batch read over `items` in chunks of `chunkSize`, with bounded concurrency, converting each
59
+ * fulfilled slot with `map`. Settled per target throughout: a chunk that throws rejects only its own slots, and a
60
+ * slot whose conversion throws rejects only itself, so one bad row never takes its chunk's siblings down with it.
61
+ */
62
+ async function readChunked(items, chunkSize, read, map) {
63
+ return (await mapBounded(chunk([...items], chunkSize), 6, async (chunkItems) => {
64
+ let slots;
65
+ try {
66
+ slots = await read(chunkItems);
67
+ } catch (ex) {
68
+ return chunkItems.map(() => ({
69
+ status: "rejected",
70
+ reason: ex
71
+ }));
72
+ }
73
+ return slots.map((slot) => {
74
+ if (slot.status === "rejected") return slot;
75
+ try {
76
+ return {
77
+ status: "fulfilled",
78
+ value: map(slot.value)
79
+ };
80
+ } catch (ex) {
81
+ return {
82
+ status: "rejected",
83
+ reason: ex
84
+ };
85
+ }
86
+ });
87
+ })).flat();
88
+ }
43
89
  var GitHubIntegrationBase = class extends GitHostIntegration {
44
90
  async getProviderAccountForCommit(session, repo, rev, options) {
45
91
  return (await this.authenticationService.apis.github)?.getAccountForCommit(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, rev, {
@@ -313,14 +359,63 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
313
359
  })), { baseUrl: this.apiBaseUrlFor(session) }, cancellation);
314
360
  }
315
361
  /**
316
- * Resolves several issues by `(owner, repo, number)` in ONE request, by aliasing the point read rather than a
317
- * search — see {@link GitHubApi.getIssuesBatch} for why that distinction is the whole design.
362
+ * Resolves several issues by `(owner, repo, number)` by aliasing the point read rather than a search — see
363
+ * {@link GitHubApi.getIssuesBatch} for why that distinction is the whole design — chunked into requests of up
364
+ * to {@link issuesBatchChunkSize} coordinates, run with bounded concurrency. Settled per target already: a
365
+ * coordinate whose alias fails on its own (e.g. an org enforcing SAML SSO the token isn't authorized for)
366
+ * rejects only that slot, and a chunk that throws rejects only its own slots.
318
367
  */
319
368
  async getProviderIssuesBatch(session, coordinates, cancellation) {
320
- return (await this.authenticationService.apis.github)?.getIssuesBatch(this, toTokenWithInfo(this.id, session), coordinates, {
369
+ const github = await this.authenticationService.apis.github;
370
+ if (github == null) return void 0;
371
+ return readChunked(coordinates, issuesBatchChunkSize, (chunkCoordinates) => github.getIssuesBatch(this, toTokenWithInfo(this.id, session), chunkCoordinates.map((c) => ({
372
+ owner: c.owner,
373
+ repo: c.repo,
374
+ number: c.number
375
+ })), {
321
376
  baseUrl: this.apiBaseUrlFor(session),
322
377
  includeBody: true
323
- }, cancellation);
378
+ }, cancellation), (issue) => issue);
379
+ }
380
+ /**
381
+ * Resolves several pull requests by `(owner, repo, number)` by aliasing the point read — see
382
+ * {@link GitHubApi.getPullRequestsBatch} — chunked into requests of up to {@link pullRequestsBatchChunkSize}
383
+ * coordinates, run with bounded concurrency. Rows take the same conversion as the account-wide list rows, so a
384
+ * pull request reads the same whichever of the two returned it.
385
+ *
386
+ * A chunk that throws rejects only its own slots, so its sibling chunks still answer.
387
+ */
388
+ async getProviderPullRequestsBatch(session, coordinates, options, cancellation) {
389
+ const github = await this.authenticationService.apis.github;
390
+ if (github == null) return void 0;
391
+ const currentAccount = options?.currentAccount;
392
+ return readChunked(coordinates, pullRequestsBatchChunkSize, (chunkCoordinates) => github.getPullRequestsBatch(this, toTokenWithInfo(this.id, session), chunkCoordinates.map((c) => ({
393
+ owner: c.owner,
394
+ repo: c.repo,
395
+ number: c.number
396
+ })), { baseUrl: this.apiBaseUrlFor(session) }, cancellation), (pr) => pr != null ? fromProviderPullRequest(toProviderPullRequest(pr), this, { currentAccount }) : void 0);
397
+ }
398
+ /**
399
+ * Finds each branch's pull requests by aliasing a head-ref-name query per target — see
400
+ * {@link GitHubApi.getPullRequestsForBranches} — chunked and converted exactly as
401
+ * {@link getProviderPullRequestsBatch} is, with the same per-target and per-chunk failure isolation.
402
+ */
403
+ async getProviderPullRequestsForBranches(session, targets, options, cancellation) {
404
+ const github = await this.authenticationService.apis.github;
405
+ if (github == null) return void 0;
406
+ const currentAccount = options.currentAccount;
407
+ return readChunked(targets, pullRequestsBatchChunkSize, (chunkTargets) => github.getPullRequestsForBranches(this, toTokenWithInfo(this.id, session), chunkTargets.map((t) => ({
408
+ owner: t.owner,
409
+ repo: t.repo,
410
+ branch: t.branch,
411
+ headOwner: t.headOwner
412
+ })), {
413
+ baseUrl: this.apiBaseUrlFor(session),
414
+ limit: options.limit
415
+ }, cancellation), (found) => ({
416
+ pullRequests: found.pullRequests.map((pr) => fromProviderPullRequest(toProviderPullRequest(pr), this, { currentAccount })),
417
+ truncated: found.truncated
418
+ }));
324
419
  }
325
420
  /**
326
421
  * Counts several pull-request scopes in ONE request. Like {@link countProviderIssues}, GitHub's `search`