@gitkraken/core-gitlens 0.7.0 → 0.7.2

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 (125) hide show
  1. package/CHANGELOG.md +28 -2
  2. package/dist/git/remotes/azure-devops.js +3 -3
  3. package/dist/git/remotes/azure-devops.js.map +1 -1
  4. package/dist/plus/integrations/authentication/configuredIntegrationService.js +9 -2
  5. package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
  6. package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +1 -1
  7. package/dist/plus/integrations/collectionMetadata.d.ts +48 -3
  8. package/dist/plus/integrations/collectionMetadata.js +138 -8
  9. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  10. package/dist/plus/integrations/errors.d.ts +3 -1
  11. package/dist/plus/integrations/errors.js +7 -3
  12. package/dist/plus/integrations/errors.js.map +1 -1
  13. package/dist/plus/integrations/index.d.ts +3 -3
  14. package/dist/plus/integrations/index.js.map +1 -1
  15. package/dist/plus/integrations/integrationService.d.ts +35 -1
  16. package/dist/plus/integrations/integrationService.js +90 -43
  17. package/dist/plus/integrations/integrationService.js.map +1 -1
  18. package/dist/plus/integrations/lite.js +5 -4
  19. package/dist/plus/integrations/lite.js.map +1 -1
  20. package/dist/plus/integrations/manager.d.ts +68 -23
  21. package/dist/plus/integrations/models/gitHostIntegration.d.ts +31 -15
  22. package/dist/plus/integrations/models/gitHostIntegration.js +71 -22
  23. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  24. package/dist/plus/integrations/models/integration.d.ts +70 -12
  25. package/dist/plus/integrations/models/integration.js +56 -1
  26. package/dist/plus/integrations/models/integration.js.map +1 -1
  27. package/dist/plus/integrations/models/issueReads.d.ts +17 -0
  28. package/dist/plus/integrations/models/issuesIntegration.js +2 -0
  29. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  30. package/dist/plus/integrations/models/pullRequestReads.d.ts +26 -0
  31. package/dist/plus/integrations/providers/azure/azure.d.ts +66 -1
  32. package/dist/plus/integrations/providers/azure/azure.js +192 -12
  33. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  34. package/dist/plus/integrations/providers/azure/search.d.ts +144 -0
  35. package/dist/plus/integrations/providers/azure/search.js +250 -0
  36. package/dist/plus/integrations/providers/azure/search.js.map +1 -0
  37. package/dist/plus/integrations/providers/azureDevOps.d.ts +73 -36
  38. package/dist/plus/integrations/providers/azureDevOps.js +191 -122
  39. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  40. package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +176 -0
  41. package/dist/plus/integrations/providers/azureDevOpsServer.js +560 -0
  42. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -0
  43. package/dist/plus/integrations/providers/bitbucket-server/discovery.d.ts +12 -0
  44. package/dist/plus/integrations/providers/bitbucket-server/discovery.js +128 -0
  45. package/dist/plus/integrations/providers/bitbucket-server/discovery.js.map +1 -0
  46. package/dist/plus/integrations/providers/bitbucket-server/models.d.ts +10 -1
  47. package/dist/plus/integrations/providers/bitbucket-server/models.js +3 -2
  48. package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
  49. package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.d.ts +58 -0
  50. package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.js +485 -0
  51. package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.js.map +1 -0
  52. package/dist/plus/integrations/providers/bitbucket-server.d.ts +61 -3
  53. package/dist/plus/integrations/providers/bitbucket-server.js +114 -20
  54. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  55. package/dist/plus/integrations/providers/bitbucket.d.ts +9 -1
  56. package/dist/plus/integrations/providers/bitbucket.js +13 -2
  57. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  58. package/dist/plus/integrations/providers/github.d.ts +6 -6
  59. package/dist/plus/integrations/providers/github.js +35 -34
  60. package/dist/plus/integrations/providers/github.js.map +1 -1
  61. package/dist/plus/integrations/providers/gitlab.d.ts +6 -4
  62. package/dist/plus/integrations/providers/gitlab.js +32 -28
  63. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  64. package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
  65. package/dist/plus/integrations/providers/jira-server.d.ts +9 -0
  66. package/dist/plus/integrations/providers/jira-server.js +15 -7
  67. package/dist/plus/integrations/providers/jira-server.js.map +1 -1
  68. package/dist/plus/integrations/providers/jira.d.ts +9 -0
  69. package/dist/plus/integrations/providers/jira.js +14 -2
  70. package/dist/plus/integrations/providers/jira.js.map +1 -1
  71. package/dist/plus/integrations/providers/linear.js +2 -2
  72. package/dist/plus/integrations/providers/models.d.ts +10 -1
  73. package/dist/plus/integrations/providers/models.js +86 -0
  74. package/dist/plus/integrations/providers/models.js.map +1 -1
  75. package/dist/plus/integrations/providers/providersApi.d.ts +10 -0
  76. package/dist/plus/integrations/providers/providersApi.js +18 -3
  77. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  78. package/dist/plus/integrations/providers/utils.d.ts +12 -1
  79. package/dist/plus/integrations/providers/utils.js +36 -6
  80. package/dist/plus/integrations/providers/utils.js.map +1 -1
  81. package/dist/plus/integrations/reads/broaden.js +6 -6
  82. package/dist/plus/integrations/reads/broaden.js.map +1 -1
  83. package/dist/plus/integrations/reads/context.d.ts +1 -1
  84. package/dist/plus/integrations/reads/counts.d.ts +18 -4
  85. package/dist/plus/integrations/reads/counts.js +66 -15
  86. package/dist/plus/integrations/reads/counts.js.map +1 -1
  87. package/dist/plus/integrations/reads/cursors.js +1 -1
  88. package/dist/plus/integrations/reads/drains.d.ts +2 -1
  89. package/dist/plus/integrations/reads/drains.js +1 -1
  90. package/dist/plus/integrations/reads/filters.d.ts +1 -1
  91. package/dist/plus/integrations/reads/filters.js +17 -12
  92. package/dist/plus/integrations/reads/filters.js.map +1 -1
  93. package/dist/plus/integrations/reads/hierarchy.js +2 -2
  94. package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
  95. package/dist/plus/integrations/reads/hierarchy.utils.js +1 -1
  96. package/dist/plus/integrations/reads/issueBatch.js +1 -1
  97. package/dist/plus/integrations/reads/issueTracker.js +2 -2
  98. package/dist/plus/integrations/reads/issues.js +2 -2
  99. package/dist/plus/integrations/reads/paging.js +1 -1
  100. package/dist/plus/integrations/reads/resolveRepository.d.ts +12 -11
  101. package/dist/plus/integrations/reads/resolveRepository.js +110 -19
  102. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  103. package/dist/plus/integrations/reads/searchIssues.js +4 -2
  104. package/dist/plus/integrations/reads/searchIssues.js.map +1 -1
  105. package/dist/plus/integrations/reads/searchPullRequests.js +9 -3
  106. package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
  107. package/dist/plus/integrations/reads/sweeps.js +1 -1
  108. package/dist/plus/integrations/reads/trackerIssue.d.ts +9 -5
  109. package/dist/plus/integrations/reads/trackerIssue.js +15 -9
  110. package/dist/plus/integrations/reads/trackerIssue.js.map +1 -1
  111. package/dist/plus/integrations/reads/warnings.d.ts +6 -2
  112. package/dist/plus/integrations/reads/warnings.js +15 -19
  113. package/dist/plus/integrations/reads/warnings.js.map +1 -1
  114. package/dist/plus/integrations/results.d.ts +84 -6
  115. package/dist/plus/integrations/results.js +9 -2
  116. package/dist/plus/integrations/results.js.map +1 -1
  117. package/dist/plus/integrations/utils/domain.utils.d.ts +19 -0
  118. package/dist/plus/integrations/utils/domain.utils.js +36 -1
  119. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  120. package/dist/plus/integrations/utils/integration.utils.d.ts +1 -0
  121. package/dist/plus/integrations/utils/integration.utils.js +12 -1
  122. package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
  123. package/docs/integrations.md +263 -74
  124. package/docs/kepler-read-api-parity.md +19 -6
  125. package/package.json +1 -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\tthis._accounts = undefined;\n\t\tthis._workspaces = undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAmDA,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,OAAwB;CACxB,IAAI,SAAiB;EACpB,OAAO,SAAS;CACjB;CAEA,IAAc,aAAqB;EAClC,OAAO;CACR;CAEA,MAAyB,yBACxB,SACA,IACA,SAGmB;EAEnB,QAAO,MADW,KAAK,gBAAgB,EAAA,CAC5B,iBAAiB,gBAAgB,KAAK,IAAI,OAAO,GAAG,IAAI,EAClE,aAAa,SAAS,YACvB,CAAC;CACF;CAEA,MAAsB,YAAY,MAKU;EAC3C,MAAM,MAAM,MAAM,KAAK,gBAAgB;EAEvC,MAAM,UAAU,MAAM,KAAK,mBAAmB,KAAK,cAAc,KAAA,CAAS;EAC1E,IAAI,WAAW,MAAM,OAAO,KAAA;EAE5B,OAAO,IAAI,QAAQ,gBAAgB,KAAK,IAAI,OAAO,GAAG,KAAK,OAAO,KAAK,MAAM,KAAK,SAAS,EAC1F,SAAS,KAAK,WACf,CAAC;CACF;CAEA,MAAyB,4BACxB,SACA,MACA,KACA,SAGoD;EACpD,QAAQ,MAAM,KAAK,s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Y,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"}
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 type { ProviderRefusal } from '../collectionMetadata.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\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":";;;;;;;;;;;;AAoDA,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,OAAwB;CACxB,IAAI,SAAiB;EACpB,OAAO,SAAS;CACjB;CAEA,IAAc,aAAqB;EAClC,OAAO;CACR;CAEA,MAAyB,yBACxB,SACA,IACA,SAGmB;EAEnB,QAAO,MADW,KAAK,gBAAgB,EAAA,CAC5B,iBAAiB,gBAAgB,KAAK,IAAI,OAAO,GAAG,IAAI,EAClE,aAAa,SAAS,YACvB,CAAC;CACF;CAEA,MAAsB,YAAY,MAKU;EAC3C,MAAM,MAAM,MAAM,KAAK,gBAAgB;EAEvC,MAAM,UAAU,MAAM,KAAK,mBAAmB,KAAK,cAAc,KAAA,CAAS;EAC1E,IAAI,WAAW,MAAM,OAAO,KAAA;EAE5B,OAAO,IAAI,QAAQ,gBAAgB,KAAK,IAAI,OAAO,GAAG,KAAK,OAAO,KAAK,MAAM,KAAK,SAAS,EAC1F,SAAS,KAAK,WACf,CAAC;CACF;CAEA,MAAyB,4BACxB,SACA,MACA,KACA,SAGoD;EACpD,QAAQ,MAAM,KAAK,sBAAsB,KAAK,UAAA,EAAY,oBACzD,MACA,gBAAgB,KAAK,IAAI,OAAO,GAChC,KAAK,OACL,KAAK,MACL,KACA,KAAK,YACL,EACC,YAAY,SAAS,WACtB,CACD;CACD;CAEA,MAAyB,2BACxB,UACA,OACA,QACA,UAG+B;EAC/B,OAAO,QAAQ,QAAQ,KAAA,CAAS;CACjC;CAEA,MAAyB,yBACxB,SACA,MACA,cACqC;EACrC,QAAQ,MAAM,KAAK,sBAAsB,KAAK,UAAA,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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"}
@@ -9,12 +9,12 @@ 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";
13
+ import { ProviderPullRequestCount, ProviderPullRequestSearchPage } from "../models/pullRequestReads.js";
12
14
  import { ProvidersApi } from "./providersApi.js";
13
15
  import { ProviderIssueSearchPage, SearchMyIssuesOptions } from "../models/issueReads.js";
14
16
  import { GitHostIntegration, SearchMyPullRequestsOptions, SearchPullRequestsOptions } from "../models/gitHostIntegration.js";
15
- import { ProviderPullRequestSearchPage } from "../models/pullRequestReads.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";
@@ -29,7 +29,7 @@ declare abstract class GitHubIntegrationBase<ID extends GitHubIntegrationIds> ex
29
29
  * by appending GitHub Enterprise's paths. Only a GHE instance base belongs here; cloud passes `undefined`,
30
30
  * the sole value that selects the cloud endpoints (see the cloud subclass).
31
31
  */
32
- protected abstract get apiBaseUrl(): string | undefined;
32
+ protected abstract apiBaseUrlFor(session: ProviderAuthenticationSession): string | undefined;
33
33
  protected getProviderAccountForCommit(session: ProviderAuthenticationSession, repo: GitHubRepositoryDescriptor, rev: string, options?: {
34
34
  avatarSize?: number;
35
35
  }): Promise<Account | UnidentifiedAuthor | undefined>;
@@ -136,7 +136,7 @@ declare abstract class GitHubIntegrationBase<ID extends GitHubIntegrationIds> ex
136
136
  repos?: ProviderRepoInput[];
137
137
  org?: string;
138
138
  criteria?: PullRequestSearchCriteria;
139
- }[], cancellation?: AbortSignal): Promise<(number | undefined)[] | undefined>;
139
+ }[], cancellation?: AbortSignal): Promise<ProviderPullRequestCount[] | undefined>;
140
140
  protected searchProviderPullRequests(session: ProviderAuthenticationSession, searchQuery: string, repos?: GitHubRepositoryDescriptor[], cancellation?: AbortSignal, options?: SearchPullRequestsOptions): Promise<PullRequest[] | undefined>;
141
141
  /**
142
142
  * Stack membership for every stacked pull request in the repository, keyed by pull request number.
@@ -164,7 +164,7 @@ export declare class GitHubIntegration extends GitHubIntegrationBase<GitCloudHos
164
164
  protected readonly key = GitCloudHostIntegrationId.GitHub;
165
165
  readonly name: string;
166
166
  get domain(): string;
167
- protected get apiBaseUrl(): string | undefined;
167
+ protected apiBaseUrlFor(_session: ProviderAuthenticationSession): string | undefined;
168
168
  access(): Promise<boolean>;
169
169
  refresh(): Promise<void>;
170
170
  }
@@ -175,7 +175,7 @@ export declare class GitHubEnterpriseIntegration extends GitHubIntegrationBase<G
175
175
  protected readonly key: `cloud-github-enterprise:${string}`;
176
176
  readonly name = "GitHub Enterprise";
177
177
  get domain(): string;
178
- protected get apiBaseUrl(): string;
178
+ protected apiBaseUrlFor(session: ProviderAuthenticationSession): string;
179
179
  constructor(ctx: IntegrationServiceContext, authenticationService: IntegrationAuthenticationService, getProvidersApi: () => Promise<ProvidersApi>, didChangeConnection: Emitter<IntegrationConnectionChangeEvent>, _domain: string);
180
180
  }
181
181
  //#endregion
@@ -2,8 +2,8 @@ import { batch } from "../../../utils/promise.js";
2
2
  import { getGitHubNoReplyAddressParts } from "../../../git/remotes/github.js";
3
3
  import "../../../git/models/pullRequest.js";
4
4
  import { IntegrationReadUnavailableError } from "../errors.js";
5
- import { toCollectionScopeFailure } from "../collectionMetadata.js";
6
5
  import "../constants.js";
6
+ import { toCollectionScopeFailure } from "../collectionMetadata.js";
7
7
  import { toTokenWithInfo } from "../authentication/models.js";
8
8
  import "../providerFilters.js";
9
9
  import { getProviderPullRequestIdentity, providersMetadata, toProviderPullRequest } from "./models.js";
@@ -44,13 +44,13 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
44
44
  async getProviderAccountForCommit(session, repo, rev, options) {
45
45
  return (await this.authenticationService.apis.github)?.getAccountForCommit(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, rev, {
46
46
  ...options,
47
- baseUrl: this.apiBaseUrl
47
+ baseUrl: this.apiBaseUrlFor(session)
48
48
  });
49
49
  }
50
50
  async getProviderAccountForEmail(session, repo, email, options) {
51
51
  return (await this.authenticationService.apis.github)?.getAccountForEmail(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, email, {
52
52
  ...options,
53
- baseUrl: this.apiBaseUrl
53
+ baseUrl: this.apiBaseUrlFor(session)
54
54
  });
55
55
  }
56
56
  async getProviderSshSigningKeysForEmails(session, repo, emails) {
@@ -66,31 +66,31 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
66
66
  else toResolve.push(email);
67
67
  }
68
68
  if (toResolve.length) {
69
- const resolved = await api.getAccountsForEmails(this, token, toResolve, { baseUrl: this.apiBaseUrl });
69
+ const resolved = await api.getAccountsForEmails(this, token, toResolve, { baseUrl: this.apiBaseUrlFor(session) });
70
70
  for (const [emailLower, login] of resolved) loginByEmail.set(emailLower, login);
71
71
  }
72
72
  const keysByLogin = /* @__PURE__ */ new Map();
73
73
  await batch([...new Set(loginByEmail.values())], sshSigningKeyResolveBatchSize, async (login) => {
74
- const keys = await api.getUserSshSigningKeys(this, token, login, { baseUrl: this.apiBaseUrl });
74
+ const keys = await api.getUserSshSigningKeys(this, token, login, { baseUrl: this.apiBaseUrlFor(session) });
75
75
  keysByLogin.set(login, keys.map((k) => k.key));
76
76
  });
77
77
  for (const [emailLower, login] of loginByEmail) result.set(emailLower, keysByLogin.get(login) ?? []);
78
78
  return result;
79
79
  }
80
80
  async getProviderDefaultBranch(session, repo) {
81
- return (await this.authenticationService.apis.github)?.getDefaultBranch(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, { baseUrl: this.apiBaseUrl });
81
+ return (await this.authenticationService.apis.github)?.getDefaultBranch(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, { baseUrl: this.apiBaseUrlFor(session) });
82
82
  }
83
83
  async getProviderLinkedIssueOrPullRequest(session, repo, { id }) {
84
- return (await this.authenticationService.apis.github)?.getIssueOrPullRequest(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, Number(id), { baseUrl: this.apiBaseUrl });
84
+ return (await this.authenticationService.apis.github)?.getIssueOrPullRequest(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, Number(id), { baseUrl: this.apiBaseUrlFor(session) });
85
85
  }
86
86
  async getProviderIssue(session, repo, id) {
87
87
  return (await this.authenticationService.apis.github)?.getIssue(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, Number(id), {
88
- baseUrl: this.apiBaseUrl,
88
+ baseUrl: this.apiBaseUrlFor(session),
89
89
  includeBody: true
90
90
  });
91
91
  }
92
92
  async getProviderPullRequest(session, repo, id) {
93
- return (await this.authenticationService.apis.github)?.getPullRequest(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, parseInt(id, 10), { baseUrl: this.apiBaseUrl });
93
+ return (await this.authenticationService.apis.github)?.getPullRequest(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, parseInt(id, 10), { baseUrl: this.apiBaseUrlFor(session) });
94
94
  }
95
95
  async getProviderPullRequestForBranch(session, repo, branch, options) {
96
96
  const { include, ...opts } = options ?? {};
@@ -101,23 +101,24 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
101
101
  return (await this.authenticationService.apis.github)?.getPullRequestForBranch(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, branch, {
102
102
  ...opts,
103
103
  include: include?.map((s) => toGitHubPullRequestState(s)),
104
- baseUrl: this.apiBaseUrl
104
+ baseUrl: this.apiBaseUrlFor(session)
105
105
  });
106
106
  }
107
107
  async getProviderPullRequestForCommit(session, repo, rev) {
108
- return (await this.authenticationService.apis.github)?.getPullRequestForCommit(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, rev, { baseUrl: this.apiBaseUrl });
108
+ return (await this.authenticationService.apis.github)?.getPullRequestForCommit(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, rev, { baseUrl: this.apiBaseUrlFor(session) });
109
109
  }
110
110
  async getProviderRepositoryMetadata(session, repo, cancellation) {
111
- return (await this.authenticationService.apis.github)?.getRepositoryMetadata(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, { baseUrl: this.apiBaseUrl }, cancellation);
111
+ return (await this.authenticationService.apis.github)?.getRepositoryMetadata(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, { baseUrl: this.apiBaseUrlFor(session) }, cancellation);
112
112
  }
113
113
  async getProviderOrganizationsForUser(session) {
114
- const result = await (await this.getProvidersApi()).getGitHubOrgsForCurrentUser(toTokenWithInfo(this.id, session), { baseUrl: this.apiBaseUrl });
114
+ const result = await (await this.getProvidersApi()).getGitHubOrgsForCurrentUser(toTokenWithInfo(this.id, session), { baseUrl: this.apiBaseUrlFor(session) });
115
+ const webUrl = this.id === "cloud-github-enterprise" ? this.getSelfManagedInstallationUrl(session) : `https://${this.domain}`;
115
116
  return {
116
117
  values: result.values.map((o) => ({
117
118
  id: o.id,
118
119
  providerId: this.id,
119
120
  name: o.username,
120
- url: `https://${this.domain}/${o.username}`
121
+ url: `${webUrl}/${o.username}`
121
122
  })),
122
123
  ...result.truncated ? { truncated: true } : {},
123
124
  ...result.metadata != null ? { metadata: result.metadata } : {}
@@ -125,7 +126,7 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
125
126
  }
126
127
  async getProviderRepositoriesForOrg(session, org, options) {
127
128
  return (await this.getProvidersApi()).getReposForOrg(toTokenWithInfo(this.id, session), org, {
128
- baseUrl: this.apiBaseUrl,
129
+ baseUrl: this.apiBaseUrlFor(session),
129
130
  cursor: options?.cursor
130
131
  });
131
132
  }
@@ -136,7 +137,7 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
136
137
  "collaborator",
137
138
  "organization_member"
138
139
  ],
139
- baseUrl: this.apiBaseUrl,
140
+ baseUrl: this.apiBaseUrlFor(session),
140
141
  cursor: options?.cursor
141
142
  });
142
143
  }
@@ -144,12 +145,12 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
144
145
  const api = await this.getProvidersApi();
145
146
  const session = await this.resolveReadSession(repo.connectionId, void 0);
146
147
  if (session == null) return void 0;
147
- return api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, { baseUrl: this.apiBaseUrl });
148
+ return api.getRepo(toTokenWithInfo(this.id, session), repo.owner, repo.name, repo.project, { baseUrl: this.apiBaseUrlFor(session) });
148
149
  }
149
150
  async searchProviderMyPullRequests(session, repos, cancellation, options) {
150
151
  return (await this.authenticationService.apis.github)?.searchMyPullRequests(this, toTokenWithInfo(this.id, session), {
151
152
  repos: repos?.map((r) => `${r.owner}/${r.name}`),
152
- baseUrl: this.apiBaseUrl,
153
+ baseUrl: this.apiBaseUrlFor(session),
153
154
  silent: options?.silent,
154
155
  state: options?.state
155
156
  }, cancellation);
@@ -179,7 +180,7 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
179
180
  const results = await Promise.allSettled(facetsToQuery.map(async (facet) => ({
180
181
  key: facet.key,
181
182
  result: await github.searchMyPullRequestsPage(this, toTokenWithInfo(this.id, session), {
182
- baseUrl: this.apiBaseUrl,
183
+ baseUrl: this.apiBaseUrlFor(session),
183
184
  state: facet.state,
184
185
  cursor: cursors[facet.key],
185
186
  summary: options?.summary,
@@ -253,7 +254,7 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
253
254
  if ((repos == null || repos.length === 0) && options?.includeAllAssignees) throw new IntegrationReadUnavailableError(this.name, "`includeAllAssignees` is not supported for account-wide issue reads; scope the read to repositories instead.");
254
255
  return (await this.authenticationService.apis.github)?.searchMyIssues(this, toTokenWithInfo(this.id, session), {
255
256
  repos: repos?.map((r) => `${r.owner}/${r.name}`),
256
- baseUrl: this.apiBaseUrl,
257
+ baseUrl: this.apiBaseUrlFor(session),
257
258
  includeBody: true,
258
259
  includeAllAssignees: options?.includeAllAssignees,
259
260
  cursor: options?.cursor,
@@ -276,7 +277,7 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
276
277
  repos: options.repos?.map((r) => `${r.namespace}/${r.name}`),
277
278
  org: options.org,
278
279
  criteria: options.criteria,
279
- baseUrl: this.apiBaseUrl,
280
+ baseUrl: this.apiBaseUrlFor(session),
280
281
  cursor: options.cursor,
281
282
  pageSize: options.pageSize,
282
283
  summary: options.summary
@@ -294,7 +295,7 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
294
295
  repos: options.repos?.map((r) => `${r.namespace}/${r.name}`),
295
296
  org: options.org,
296
297
  criteria: options.criteria,
297
- baseUrl: this.apiBaseUrl,
298
+ baseUrl: this.apiBaseUrlFor(session),
298
299
  includeBody: true,
299
300
  cursor: options.cursor,
300
301
  pageSize: options.pageSize
@@ -309,7 +310,7 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
309
310
  repos: s.repos?.map((r) => `${r.namespace}/${r.name}`),
310
311
  org: s.org,
311
312
  criteria: s.criteria
312
- })), { baseUrl: this.apiBaseUrl }, cancellation);
313
+ })), { baseUrl: this.apiBaseUrlFor(session) }, cancellation);
313
314
  }
314
315
  /**
315
316
  * Resolves several issues by `(owner, repo, number)` in ONE request, by aliasing the point read rather than a
@@ -317,7 +318,7 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
317
318
  */
318
319
  async getProviderIssuesBatch(session, coordinates, cancellation) {
319
320
  return (await this.authenticationService.apis.github)?.getIssuesBatch(this, toTokenWithInfo(this.id, session), coordinates, {
320
- baseUrl: this.apiBaseUrl,
321
+ baseUrl: this.apiBaseUrlFor(session),
321
322
  includeBody: true
322
323
  }, cancellation);
323
324
  }
@@ -326,17 +327,17 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
326
327
  * reports `issueCount` on a zero-node selection, so a count preview costs no pull-request transfer.
327
328
  */
328
329
  async countProviderPullRequests(session, scopes, cancellation) {
329
- return (await this.authenticationService.apis.github)?.countPullRequests(this, toTokenWithInfo(this.id, session), scopes.map((s) => ({
330
+ return (await (await this.authenticationService.apis.github)?.countPullRequests(this, toTokenWithInfo(this.id, session), scopes.map((s) => ({
330
331
  repos: s.repos?.map((r) => `${r.namespace}/${r.name}`),
331
332
  org: s.org,
332
333
  criteria: s.criteria
333
- })), { baseUrl: this.apiBaseUrl }, cancellation);
334
+ })), { baseUrl: this.apiBaseUrlFor(session) }, cancellation))?.map((count) => ({ count }));
334
335
  }
335
336
  async searchProviderPullRequests(session, searchQuery, repos, cancellation, options) {
336
337
  return (await this.authenticationService.apis.github)?.searchPullRequests(this, toTokenWithInfo(this.id, session), {
337
338
  search: searchQuery,
338
339
  repos: repos?.map((r) => `${r.owner}/${r.name}`),
339
- baseUrl: this.apiBaseUrl,
340
+ baseUrl: this.apiBaseUrlFor(session),
340
341
  ...options
341
342
  }, cancellation);
342
343
  }
@@ -354,7 +355,7 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
354
355
  async getStacksByPullRequestNumber(owner, repo, cancellation) {
355
356
  const session = await this.resolveReadSession(void 0, void 0);
356
357
  if (session == null) return void 0;
357
- const stacks = await (await this.authenticationService.apis.github)?.getRepositoryStacks(this, toTokenWithInfo(this.id, session), owner, repo, { baseUrl: this.apiBaseUrl }, cancellation);
358
+ const stacks = await (await this.authenticationService.apis.github)?.getRepositoryStacks(this, toTokenWithInfo(this.id, session), owner, repo, { baseUrl: this.apiBaseUrlFor(session) }, cancellation);
358
359
  if (stacks == null) return void 0;
359
360
  const byNumber = /* @__PURE__ */ new Map();
360
361
  for (const stack of stacks) {
@@ -380,17 +381,17 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
380
381
  const api = await this.authenticationService.apis.github;
381
382
  if (pr.stack != null) return await api?.mergeStackedPullRequest(this, toTokenWithInfo(this.id, session), pr.repository.owner, pr.repository.repo, Number(pr.id), headRefSha, {
382
383
  mergeMethod: options?.mergeMethod,
383
- baseUrl: this.apiBaseUrl
384
+ baseUrl: this.apiBaseUrlFor(session)
384
385
  }, cancellation) ?? false;
385
386
  return api?.mergePullRequest(this, toTokenWithInfo(this.id, session), id, headRefSha, {
386
387
  mergeMethod: options?.mergeMethod,
387
- baseUrl: this.apiBaseUrl
388
+ baseUrl: this.apiBaseUrlFor(session)
388
389
  }, cancellation) ?? false;
389
390
  }
390
391
  async getProviderCurrentAccount(session, options) {
391
392
  return (await this.authenticationService.apis.github)?.getCurrentAccount(this, toTokenWithInfo(this.id, session), {
392
393
  ...options,
393
- baseUrl: this.apiBaseUrl
394
+ baseUrl: this.apiBaseUrlFor(session)
394
395
  });
395
396
  }
396
397
  getProviderPullRequestIdentityFromMaybeUrl(search) {
@@ -405,7 +406,7 @@ var GitHubIntegration = class extends GitHubIntegrationBase {
405
406
  get domain() {
406
407
  return metadata.domain;
407
408
  }
408
- get apiBaseUrl() {}
409
+ apiBaseUrlFor(_session) {}
409
410
  access() {
410
411
  return Promise.resolve(true);
411
412
  }
@@ -427,8 +428,8 @@ var GitHubEnterpriseIntegration = class extends GitHubIntegrationBase {
427
428
  get domain() {
428
429
  return this._domain;
429
430
  }
430
- get apiBaseUrl() {
431
- return `https://${this._domain}/api/v3`;
431
+ apiBaseUrlFor(session) {
432
+ return this.getSelfManagedApiBaseUrl(session);
432
433
  }
433
434
  constructor(ctx, authenticationService, getProvidersApi, didChangeConnection, _domain) {
434
435
  super(ctx, authenticationService, getProvidersApi, didChangeConnection);