@gitkraken/core-gitlens 0.41.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/dist/git/errors.d.ts +1 -0
  3. package/dist/git/errors.js +7 -1
  4. package/dist/git/errors.js.map +1 -1
  5. package/dist/git/models/issue.d.ts +2 -0
  6. package/dist/git/models/issue.js.map +1 -1
  7. package/dist/git/models/issueOrPullRequest.d.ts +4 -0
  8. package/dist/git/models/pullRequest.d.ts +2 -0
  9. package/dist/git/models/pullRequest.js.map +1 -1
  10. package/dist/git-cli/providers/config.js +2 -2
  11. package/dist/git-cli/providers/pausedOperations.js +2 -2
  12. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  13. package/dist/git-cli/providers/staging.js +1 -1
  14. package/dist/ipc/discovery.js +1 -1
  15. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  16. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  17. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  18. package/dist/plus/git-github/api/aliasedQuery.d.ts +3 -2
  19. package/dist/plus/git-github/api/aliasedQuery.js +7 -3
  20. package/dist/plus/git-github/api/aliasedQuery.js.map +1 -1
  21. package/dist/plus/git-github/api/github.d.ts +7 -4
  22. package/dist/plus/git-github/api/github.js +112 -14
  23. package/dist/plus/git-github/api/github.js.map +1 -1
  24. package/dist/plus/git-github/api/issueWrites.d.ts +5 -1
  25. package/dist/plus/git-github/api/issueWrites.js +15 -5
  26. package/dist/plus/git-github/api/issueWrites.js.map +1 -1
  27. package/dist/plus/git-github/models.js +7 -3
  28. package/dist/plus/git-github/models.js.map +1 -1
  29. package/dist/plus/integrations/collectionMetadata.js +2 -1
  30. package/dist/plus/integrations/collectionMetadata.js.map +1 -1
  31. package/dist/plus/integrations/context.d.ts +3 -3
  32. package/dist/plus/integrations/errors.d.ts +4 -0
  33. package/dist/plus/integrations/errors.js +8 -1
  34. package/dist/plus/integrations/errors.js.map +1 -1
  35. package/dist/plus/integrations/index.d.ts +3 -2
  36. package/dist/plus/integrations/index.js.map +1 -1
  37. package/dist/plus/integrations/integrationService.d.ts +18 -1
  38. package/dist/plus/integrations/integrationService.js +19 -0
  39. package/dist/plus/integrations/integrationService.js.map +1 -1
  40. package/dist/plus/integrations/lite.js +11 -1
  41. package/dist/plus/integrations/lite.js.map +1 -1
  42. package/dist/plus/integrations/manager.d.ts +93 -0
  43. package/dist/plus/integrations/models/gitHostIntegration.d.ts +21 -2
  44. package/dist/plus/integrations/models/gitHostIntegration.js +182 -14
  45. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  46. package/dist/plus/integrations/models/integration.d.ts +9 -1
  47. package/dist/plus/integrations/models/integration.js +43 -3
  48. package/dist/plus/integrations/models/integration.js.map +1 -1
  49. package/dist/plus/integrations/providers/apiClients.d.ts +1 -0
  50. package/dist/plus/integrations/providers/apiClients.js +3 -0
  51. package/dist/plus/integrations/providers/apiClients.js.map +1 -1
  52. package/dist/plus/integrations/providers/azure/azure.d.ts +3 -0
  53. package/dist/plus/integrations/providers/azure/azure.js +130 -33
  54. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  55. package/dist/plus/integrations/providers/azure/models.js +7 -3
  56. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  57. package/dist/plus/integrations/providers/azureDevOps.d.ts +12 -0
  58. package/dist/plus/integrations/providers/azureDevOps.js +22 -0
  59. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  60. package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +21 -2
  61. package/dist/plus/integrations/providers/bitbucket/bitbucket.js +77 -32
  62. package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
  63. package/dist/plus/integrations/providers/bitbucket/models.js +5 -2
  64. package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
  65. package/dist/plus/integrations/providers/bitbucket-server/models.js +3 -1
  66. package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
  67. package/dist/plus/integrations/providers/bitbucket-server.d.ts +2 -0
  68. package/dist/plus/integrations/providers/bitbucket-server.js +11 -3
  69. package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
  70. package/dist/plus/integrations/providers/bitbucket.d.ts +14 -0
  71. package/dist/plus/integrations/providers/bitbucket.js +30 -2
  72. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  73. package/dist/plus/integrations/providers/github.d.ts +9 -4
  74. package/dist/plus/integrations/providers/github.js +12 -1
  75. package/dist/plus/integrations/providers/github.js.map +1 -1
  76. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +19 -1
  77. package/dist/plus/integrations/providers/gitlab/gitlab.js +128 -23
  78. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  79. package/dist/plus/integrations/providers/gitlab/models.js +5 -2
  80. package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
  81. package/dist/plus/integrations/providers/gitlab.d.ts +15 -2
  82. package/dist/plus/integrations/providers/gitlab.js +34 -4
  83. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  84. package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -1
  85. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  86. package/dist/plus/integrations/providers/models.js +9 -4
  87. package/dist/plus/integrations/providers/models.js.map +1 -1
  88. package/dist/plus/integrations/providers/providerApiClient.js +10 -7
  89. package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
  90. package/dist/plus/integrations/providers/providerErrors.d.ts +8 -0
  91. package/dist/plus/integrations/providers/providerErrors.js +15 -2
  92. package/dist/plus/integrations/providers/providerErrors.js.map +1 -1
  93. package/dist/plus/integrations/providers/providersApi.js +3 -1
  94. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  95. package/dist/plus/integrations/reads/pullRequestsForCommits.d.ts +45 -0
  96. package/dist/plus/integrations/reads/pullRequestsForCommits.js +97 -0
  97. package/dist/plus/integrations/reads/pullRequestsForCommits.js.map +1 -0
  98. package/dist/plus/integrations/utils/domain.utils.d.ts +1 -0
  99. package/dist/plus/integrations/utils/domain.utils.js +5 -1
  100. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  101. package/dist/plus/integrations/utils/failureBackoff.d.ts +13 -0
  102. package/dist/plus/integrations/utils/failureBackoff.js +47 -0
  103. package/dist/plus/integrations/utils/failureBackoff.js.map +1 -0
  104. package/dist/utils/env/node/exec.js +2 -2
  105. package/docs/integrations.md +105 -15
  106. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/bitbucket/models.ts"],"sourcesContent":["import type { IssueProjection, IssueRepository } from '@gitlens/git/models/issue.js';\nimport { Issue } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequestState } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequestMember, PullRequestProjection, PullRequestReviewer } from '@gitlens/git/models/pullRequest.js';\nimport { PullRequest, PullRequestReviewDecision, PullRequestReviewState } from '@gitlens/git/models/pullRequest.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport type { PullRequestEtagFields, PullRequestEtagInclude } from '../../models/integration.js';\n\nexport interface BitbucketRepositoryDescriptor extends ResourceDescriptor {\n\towner: string;\n\tname: string;\n}\n\nexport interface BitbucketWorkspaceDescriptor extends ResourceDescriptor {\n\tid: string;\n\tname: string;\n\tslug: string;\n}\n\nexport type BitbucketPullRequestState = 'OPEN' | 'DECLINED' | 'MERGED' | 'SUPERSEDED';\n\ninterface BitbucketLink {\n\thref: string;\n\tname?: string;\n}\n\n// Bitbucket's `account` schema: a person (`user`) or an app/bot (`app_user`, e.g. a review bot on a PR).\n// An `app_user` has no `links.html` and no `nickname`, and the schema requires none of the links.\ninterface BitbucketUser {\n\ttype: 'user' | 'app_user';\n\tuuid: string;\n\tdisplay_name: string;\n\taccount_id?: string;\n\tnickname?: string;\n\tlinks?: {\n\t\tself?: BitbucketLink;\n\t\tavatar?: BitbucketLink;\n\t\thtml?: BitbucketLink;\n\t};\n}\n\ninterface BitbucketWorkspace {\n\ttype: 'workspace';\n\tuuid: string;\n\tname: string;\n\tslug: string;\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tavatar: BitbucketLink;\n\t};\n}\n\ninterface BitbucketProject {\n\ttype: 'project';\n\tkey: string;\n\tuuid: string;\n\tname: string;\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tavatar: BitbucketLink;\n\t};\n}\n\ninterface BitbucketPullRequestParticipant {\n\ttype: 'participant';\n\tuser: BitbucketUser;\n\trole: 'PARTICIPANT' | 'REVIEWER';\n\tapproved: boolean;\n\tstate: null | 'approved' | 'changes_requested';\n\tparticipated_on: null | string;\n}\n\nexport interface BitbucketRepository {\n\ttype: 'repository';\n\tuuid: string;\n\tfull_name: string;\n\tname: string;\n\tslug: string;\n\tdescription?: string;\n\tis_private: boolean;\n\tparent: null | BitbucketRepository;\n\tscm: 'git';\n\towner: BitbucketUser;\n\tworkspace: BitbucketWorkspace;\n\tproject: BitbucketProject;\n\tcreated_on: string;\n\tupdated_on: string;\n\tsize: number;\n\tlanguage: string;\n\thas_issues: boolean;\n\thas_wiki: boolean;\n\tfork_policy: 'allow_forks' | 'no_public_forks' | 'no_forks';\n\twebsite: string;\n\tmainbranch?: BitbucketBranch;\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tavatar: BitbucketLink;\n\t};\n}\n\ninterface BitbucketCommitAuthor {\n\ttype: 'author';\n\traw: string;\n\tuser: BitbucketUser;\n}\n\ntype BitbucketMergeStrategy =\n\t| 'merge_commit'\n\t| 'squash'\n\t| 'fast_forward'\n\t| 'squash_fast_forward'\n\t| 'rebase_fast_forward'\n\t| 'rebase_merge';\n\ninterface BitbucketBranch {\n\tname: string;\n\tmerge_strategies?: BitbucketMergeStrategy[];\n\tdefault_merge_strategy?: BitbucketMergeStrategy;\n}\n\n// It parses a raw author sitring like \"Sergei Shmakov GK <sergei.shmakov@gitkraken.com>\" to name and email\nconst parseRawBitbucketAuthorRegex = /^(.*) <(.*)>$/;\nexport function parseRawBitbucketAuthor(raw: string): { name: string; email: string } {\n\tconst match = raw.match(parseRawBitbucketAuthorRegex);\n\tif (match) {\n\t\treturn { name: match[1], email: match[2] };\n\t}\n\treturn { name: raw, email: '' };\n}\n\nexport interface BitbucketCommit extends BitbucketBriefCommit {\n\tauthor: BitbucketCommitAuthor;\n\tdate: string;\n\tlinks: {\n\t\tapprove: BitbucketLink;\n\t\tcomments: BitbucketLink;\n\t\tdiff: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tself: BitbucketLink;\n\t\tstatuses: BitbucketLink;\n\t};\n\tmessage: string;\n\tparents: BitbucketBriefCommit[];\n\tparticipants: BitbucketPullRequestParticipant[];\n\trendered: {\n\t\tmessage: string;\n\t};\n\trepository: BitbucketRepository;\n\tsummary: {\n\t\ttype: 'rendered';\n\t\traw: string;\n\t\tmarkup: string;\n\t\thtml: string;\n\t};\n}\n\ninterface BitbucketBriefCommit {\n\ttype: 'commit';\n\thash: string;\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t};\n}\n\nexport type BitbucketIssueState =\n\t| 'submitted'\n\t| 'new'\n\t| 'open'\n\t| 'resolved'\n\t| 'on hold'\n\t| 'invalid'\n\t| 'duplicate'\n\t| 'wontfix'\n\t| 'closed';\n\nexport interface BitbucketPullRequest {\n\ttype: 'pullrequest';\n\tid: number;\n\ttitle: string;\n\tdescription: string;\n\tstate: BitbucketPullRequestState;\n\tdraft?: boolean;\n\tmerge_commit: null | BitbucketBriefCommit;\n\tcomment_count: number;\n\ttask_count: number;\n\tclose_source_branch: boolean;\n\tclosed_by: BitbucketUser | null;\n\tauthor: BitbucketUser;\n\treason: string;\n\tcreated_on: string;\n\tupdated_on: string;\n\tdestination: {\n\t\tbranch: BitbucketBranch;\n\t\tcommit: BitbucketBriefCommit;\n\t\trepository: BitbucketRepository;\n\t};\n\tsource: {\n\t\tbranch: BitbucketBranch;\n\t\tcommit: BitbucketBriefCommit;\n\t\trepository: BitbucketRepository;\n\t};\n\tsummary: {\n\t\ttype: 'rendered';\n\t\traw: string;\n\t\tmarkup: string;\n\t\thtml: string;\n\t};\n\treviewers?: BitbucketUser[];\n\tparticipants?: BitbucketPullRequestParticipant[];\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tcommits: BitbucketLink;\n\t\tapprove: BitbucketLink;\n\t\t'request-changes': BitbucketLink;\n\t\tdiff: BitbucketLink;\n\t\tdiffstat: BitbucketLink;\n\t\tcomments: BitbucketLink;\n\t\tactivity: BitbucketLink;\n\t\tmerge: BitbucketLink;\n\t\tdecline: BitbucketLink;\n\t\tstatuses: BitbucketLink;\n\t};\n}\n\nexport interface BitbucketIssue {\n\ttype: string;\n\tid: number;\n\ttitle: string;\n\treporter: BitbucketUser;\n\tassignee?: BitbucketUser;\n\tstate: BitbucketIssueState;\n\tcreated_on: string;\n\tupdated_on: string;\n\trepository: BitbucketRepository;\n\tvotes?: number;\n\tcontent: {\n\t\traw: string;\n\t\tmarkup: string;\n\t\thtml: string;\n\t};\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tcomments: BitbucketLink;\n\t\tattachments: BitbucketLink;\n\t\twatch: BitbucketLink;\n\t\tvote: BitbucketLink;\n\t};\n}\n\nexport function bitbucketPullRequestStateToState(state: BitbucketPullRequestState): IssueOrPullRequestState {\n\tswitch (state) {\n\t\tcase 'DECLINED':\n\t\tcase 'SUPERSEDED':\n\t\t\treturn 'closed';\n\t\tcase 'MERGED':\n\t\t\treturn 'merged';\n\t\tcase 'OPEN':\n\t\tdefault:\n\t\t\treturn 'opened';\n\t}\n}\n\nexport function bitbucketIssueStateToState(state: BitbucketIssueState): IssueOrPullRequestState {\n\tswitch (state) {\n\t\tcase 'resolved':\n\t\tcase 'invalid':\n\t\tcase 'duplicate':\n\t\tcase 'wontfix':\n\t\tcase 'closed':\n\t\t\treturn 'closed';\n\t\tcase 'submitted':\n\t\tcase 'new':\n\t\tcase 'open':\n\t\tcase 'on hold':\n\t\tdefault:\n\t\t\treturn 'opened';\n\t}\n}\n\nexport function isClosedBitbucketPullRequestState(state: BitbucketPullRequestState): boolean {\n\treturn bitbucketPullRequestStateToState(state) !== 'opened';\n}\n\nexport function isClosedBitbucketIssueState(state: BitbucketIssueState): boolean {\n\treturn bitbucketIssueStateToState(state) !== 'opened';\n}\n\nexport function fromBitbucketUser(user: BitbucketUser): PullRequestMember {\n\treturn {\n\t\tavatarUrl: user.links?.avatar?.href,\n\t\tname: user.display_name,\n\t\tusername: user.nickname,\n\t\turl: user.links?.html?.href,\n\t\tid: user.uuid,\n\t};\n}\n\nexport function fromBitbucketParticipantToReviewer(\n\tprt: BitbucketPullRequestParticipant,\n\tclosedBy: BitbucketUser | null,\n\tprState: BitbucketPullRequestState,\n): PullRequestReviewer {\n\treturn {\n\t\treviewer: fromBitbucketUser(prt.user),\n\t\tstate: prt.approved\n\t\t\t? PullRequestReviewState.Approved\n\t\t\t: prt.state === 'changes_requested'\n\t\t\t\t? PullRequestReviewState.ChangesRequested\n\t\t\t\t: prt.participated_on != null\n\t\t\t\t\t? PullRequestReviewState.Commented\n\t\t\t\t\t: prt.user.uuid === closedBy?.uuid && prState === 'DECLINED'\n\t\t\t\t\t\t? PullRequestReviewState.Dismissed\n\t\t\t\t\t\t: PullRequestReviewState.ReviewRequested,\n\t};\n}\n\n/**\n * The review decision a Bitbucket Cloud row carries, derived from its participants and reviewers. Reads only the\n * participants' `participated_on`, `approved` and `state` and whether there are reviewers, which is what the cheap etag\n * read selects for it.\n */\nexport function getBitbucketReviewDecision(pr: {\n\tparticipants?: readonly Pick<BitbucketPullRequestParticipant, 'approved' | 'state' | 'participated_on'>[];\n\treviewers?: readonly unknown[];\n}): PullRequestReviewDecision | undefined {\n\tif (!pr.participants?.length && pr.reviewers?.length) {\n\t\treturn PullRequestReviewDecision.ReviewRequired;\n\t}\n\tif (!pr.participants) {\n\t\treturn undefined;\n\t}\n\n\tlet hasReviews = false;\n\tlet hasChangeRequests = false;\n\tlet hasApprovals = false;\n\tfor (const prt of pr.participants) {\n\t\tif (prt.participated_on != null) {\n\t\t\thasReviews = true;\n\t\t}\n\t\tif (prt.approved) {\n\t\t\thasApprovals = true;\n\t\t}\n\t\tif (prt.state === 'changes_requested') {\n\t\t\thasChangeRequests = true;\n\t\t}\n\t}\n\tif (hasChangeRequests) return PullRequestReviewDecision.ChangesRequested;\n\tif (hasApprovals) return PullRequestReviewDecision.Approved;\n\tif (hasReviews) return undefined; // not approved, not rejected, but reviewed\n\treturn PullRequestReviewDecision.ReviewRequired; // nobody has reviewed yet.\n}\n\nfunction fromBitbucketRepository(repo: BitbucketRepository): IssueRepository {\n\treturn {\n\t\towner: repo.full_name.split('/')[0],\n\t\trepo: repo.name,\n\t\tid: repo.uuid,\n\t};\n}\n\nexport function fromBitbucketIssue(issue: BitbucketIssue, provider: Provider, projection?: IssueProjection): Issue {\n\treturn new Issue(\n\t\tprovider,\n\t\tissue.id.toString(),\n\t\tissue.id.toString(),\n\t\tissue.title,\n\t\tissue.links.html.href,\n\t\tnew Date(issue.created_on),\n\t\tnew Date(issue.updated_on),\n\t\tisClosedBitbucketIssueState(issue.state),\n\t\tbitbucketIssueStateToState(issue.state),\n\t\tfromBitbucketUser(issue.reporter),\n\t\tissue.assignee ? [fromBitbucketUser(issue.assignee)] : [],\n\t\tfromBitbucketRepository(issue.repository),\n\t\tundefined, // closedDate\n\t\tundefined, // labels\n\t\tundefined, // commentsCount\n\t\tissue.votes, // thumbsUpCount\n\t\tissue.content.html, // body\n\t\t!issue.repository?.project\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tid: issue.repository.project.uuid,\n\t\t\t\t\tname: issue.repository.project.name,\n\t\t\t\t\tresourceId: issue.repository.project.uuid,\n\t\t\t\t\tresourceName: issue.repository.project.name,\n\t\t\t\t},\n\t\tundefined, // number\n\t\tundefined, // issueType\n\t\tundefined, // providerState\n\t\tundefined, // bodyFormat\n\t\tundefined, // iterations\n\t\tprojection,\n\t);\n}\n\nexport function fromBitbucketPullRequest(\n\tpr: BitbucketPullRequest,\n\tprovider: Provider,\n\toptions?: { currentAccount?: { id: string; username?: string }; projection?: PullRequestProjection },\n): PullRequest {\n\tconst author = fromBitbucketUser(pr.author);\n\treturn new PullRequest(\n\t\tprovider,\n\t\tauthor,\n\t\tpr.id.toString(),\n\t\tpr.id.toString(),\n\t\tpr.title,\n\t\tpr.links.html.href,\n\t\tfromBitbucketRepository(pr.destination.repository),\n\t\tbitbucketPullRequestStateToState(pr.state),\n\t\tnew Date(pr.created_on),\n\t\tnew Date(pr.updated_on),\n\t\tpr.closed_by ? new Date(pr.updated_on) : undefined,\n\t\tpr.state === 'MERGED' ? new Date(pr.updated_on) : undefined,\n\t\tundefined, // mergeableState: not read\n\t\tundefined, // viewerCanUpdate\n\t\t{\n\t\t\tbase: {\n\t\t\t\tbranch: pr.destination.branch.name,\n\t\t\t\tsha: pr.destination.commit.hash,\n\t\t\t\trepo: pr.destination.repository.name,\n\t\t\t\towner: pr.destination.repository.full_name.split('/')[0],\n\t\t\t\texists: true,\n\t\t\t\turl: pr.destination.repository.links.html.href,\n\t\t\t},\n\t\t\thead: {\n\t\t\t\tbranch: pr.source.branch.name,\n\t\t\t\tsha: pr.source.commit.hash,\n\t\t\t\trepo: pr.source.repository.name,\n\t\t\t\towner: pr.source.repository.full_name.split('/')[0],\n\t\t\t\texists: true,\n\t\t\t\turl: pr.source.repository.links.html.href,\n\t\t\t},\n\t\t\tisCrossRepository: pr.source.repository.uuid !== pr.destination.repository.uuid,\n\t\t},\n\t\tpr.draft,\n\t\tundefined, // additions\n\t\tundefined, // deletions\n\t\tundefined, // commentsCount\n\t\tundefined, // thumbsCount\n\t\tgetBitbucketReviewDecision(pr),\n\t\tpr.participants // reviewRequests:PullRequestReviewer[]\n\t\t\t?.filter(prt => prt.role === 'REVIEWER')\n\t\t\t.map(prt => fromBitbucketParticipantToReviewer(prt, pr.closed_by, pr.state))\n\t\t\t.filter(rv => rv.state === PullRequestReviewState.ReviewRequested),\n\t\tpr.participants // latestReviews:PullRequestReviewer[]\n\t\t\t?.filter(prt => prt.participated_on != null)\n\t\t\t.map(prt => fromBitbucketParticipantToReviewer(prt, pr.closed_by, pr.state)),\n\t\tundefined, // assignees:PullRequestMember[] -- it looks like there is no such thing as assignees on Bitbucket\n\t\tundefined, // PullRequestStatusCheckRollupState\n\t\tundefined, // IssueProject\n\t\tundefined, // version\n\t\tundefined, // commitCount\n\t\tundefined, // stack\n\t\tundefined, // filesChanged\n\t\tpr.description ?? undefined,\n\t\tpr.id,\n\t\toptions?.currentAccount != null ? author.id === options.currentAccount.id : undefined,\n\t\toptions?.projection,\n\t\toptions?.currentAccount,\n\t);\n}\n\n/** The most pull request ids one etag read asks for: Bitbucket Cloud's largest page of pull requests. */\nexport const bitbucketEtagFieldsMaxIds = 50;\n\n/**\n * A pull request as the cheap etag read selects it (`BitbucketApi.getPullRequestsEtagFields`): only the fields\n * {@link fromBitbucketPullRequest} maps into a full row's etag inputs. `participants` and `reviewers` are selected\n * only for the `reviewDecision` include.\n */\nexport interface BitbucketPullRequestEtagNode {\n\tid: number;\n\tstate: BitbucketPullRequestState;\n\tupdated_on: string;\n\tdraft?: boolean;\n\tsource: { commit: { hash: string } };\n\tparticipants?: Pick<BitbucketPullRequestParticipant, 'approved' | 'state' | 'participated_on'>[];\n\treviewers?: unknown[];\n}\n\n/**\n * A cheap etag read's pull request in the vocabulary {@link fromBitbucketPullRequest}'s row ends in, so both reads\n * compute the same etag. That row reads neither a mergeability nor a check rollup, so neither does this.\n */\nexport function toBitbucketPullRequestEtagFields(\n\tnode: BitbucketPullRequestEtagNode,\n\tetagIncludes: readonly PullRequestEtagInclude[],\n): PullRequestEtagFields {\n\tconst fields: PullRequestEtagFields = {\n\t\tstate: bitbucketPullRequestStateToState(node.state),\n\t\tisDraft: node.draft,\n\t\tupdatedDate: new Date(node.updated_on),\n\t\theadSha: node.source.commit.hash,\n\t};\n\n\tif (etagIncludes.includes('reviewDecision')) {\n\t\t// The full read always has both lists, and the decision tells a missing list from an empty one, so a row\n\t\t// without them can't be compared: it rejects, and the full read answers instead.\n\t\tif (node.participants == null || node.reviewers == null) {\n\t\t\tthrow new Error(`Bitbucket returned pull request ${node.id} without its participants or reviewers`);\n\t\t}\n\n\t\tfields.reviewDecision = getBitbucketReviewDecision(node);\n\t}\n\n\treturn fields;\n}\n"],"mappings":";;;AA6HA,MAAM,+BAA+B;AACrC,SAAgB,wBAAwB,KAA8C;CACrF,MAAM,QAAQ,IAAI,MAAM,4BAA4B;CACpD,IAAI,OACH,OAAO;EAAE,MAAM,MAAM;EAAI,OAAO,MAAM;CAAG;CAE1C,OAAO;EAAE,MAAM;EAAK,OAAO;CAAG;AAC/B;AA4HA,SAAgB,iCAAiC,OAA2D;CAC3G,QAAQ,OAAR;EACC,KAAK;EACL,KAAK,cACJ,OAAO;EACR,KAAK,UACJ,OAAO;EAER,SACC,OAAO;CACT;AACD;AAEA,SAAgB,2BAA2B,OAAqD;CAC/F,QAAQ,OAAR;EACC,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,UACJ,OAAO;EAKR,SACC,OAAO;CACT;AACD;AAEA,SAAgB,kCAAkC,OAA2C;CAC5F,OAAO,iCAAiC,KAAK,MAAM;AACpD;AAEA,SAAgB,4BAA4B,OAAqC;CAChF,OAAO,2BAA2B,KAAK,MAAM;AAC9C;AAEA,SAAgB,kBAAkB,MAAwC;CACzE,OAAO;EACN,WAAW,KAAK,OAAO,QAAQ;EAC/B,MAAM,KAAK;EACX,UAAU,KAAK;EACf,KAAK,KAAK,OAAO,MAAM;E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ACA,KAAA,GACA,KAAA,GACA,KAAA,GACA,2BAA2B,EAAE,GAC7B,GAAG,cACA,QAAO,QAAO,IAAI,SAAS,UAAU,CAAC,CACvC,KAAI,QAAO,mCAAmC,KAAK,GAAG,WAAW,GAAG,KAAK,CAAC,CAAC,CAC3E,QAAO,OAAM,GAAG,UAAA,kBAAgD,GAClE,GAAG,cACA,QAAO,QAAO,IAAI,mBAAmB,IAAI,CAAC,CAC3C,KAAI,QAAO,mCAAmC,KAAK,GAAG,WAAW,GAAG,KAAK,CAAC,GAC5E,KAAA,GACA,KAAA,GACA,KAAA,GACA,KAAA,GACA,KAAA,GACA,KAAA,GACA,KAAA,GACA,GAAG,eAAe,KAAA,GAClB,GAAG,IACH,SAAS,kBAAkB,OAAO,OAAO,OAAO,QAAQ,eAAe,KAAK,KAAA,GAC5E,SAAS,YACT,SAAS,cACV;AACD;;AAGA,MAAa,4BAA4B;;;;;AAqBzC,SAAgB,iCACf,MACA,cACwB;CACxB,MAAM,SAAgC;EACrC,OAAO,iCAAiC,KAAK,KAAK;EAClD,SAAS,KAAK;EACd,aAAa,IAAI,KAAK,KAAK,UAAU;EACrC,SAAS,KAAK,OAAO,OAAO;CAC7B;CAEA,IAAI,aAAa,SAAS,gBAAgB,GAAG;EAG5C,IAAI,KAAK,gBAAgB,QAAQ,KAAK,aAAa,MAClD,MAAM,IAAI,MAAM,mCAAmC,KAAK,GAAG,uCAAuC;EAGnG,OAAO,iBAAiB,2BAA2B,IAAI;CACxD;CAEA,OAAO;AACR"}
1
+ {"version":3,"file":"models.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/bitbucket/models.ts"],"sourcesContent":["import { copyReadProvenance } from '@gitkraken/provider-apis/read-provenance';\nimport type { IssueProjection, IssueRepository } from '@gitlens/git/models/issue.js';\nimport { Issue } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequestState } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type { PullRequestMember, PullRequestProjection, PullRequestReviewer } from '@gitlens/git/models/pullRequest.js';\nimport { PullRequest, PullRequestReviewDecision, PullRequestReviewState } from '@gitlens/git/models/pullRequest.js';\nimport type { Provider } from '@gitlens/git/models/remoteProvider.js';\nimport type { ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport type { PullRequestEtagFields, PullRequestEtagInclude } from '../../models/integration.js';\n\nexport interface BitbucketRepositoryDescriptor extends ResourceDescriptor {\n\towner: string;\n\tname: string;\n}\n\nexport interface BitbucketWorkspaceDescriptor extends ResourceDescriptor {\n\tid: string;\n\tname: string;\n\tslug: string;\n}\n\nexport type BitbucketPullRequestState = 'OPEN' | 'DECLINED' | 'MERGED' | 'SUPERSEDED';\n\ninterface BitbucketLink {\n\thref: string;\n\tname?: string;\n}\n\n// Bitbucket's `account` schema: a person (`user`) or an app/bot (`app_user`, e.g. a review bot on a PR).\n// An `app_user` has no `links.html` and no `nickname`, and the schema requires none of the links.\ninterface BitbucketUser {\n\ttype: 'user' | 'app_user';\n\tuuid: string;\n\tdisplay_name: string;\n\taccount_id?: string;\n\tnickname?: string;\n\tlinks?: {\n\t\tself?: BitbucketLink;\n\t\tavatar?: BitbucketLink;\n\t\thtml?: BitbucketLink;\n\t};\n}\n\ninterface BitbucketWorkspace {\n\ttype: 'workspace';\n\tuuid: string;\n\tname: string;\n\tslug: string;\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tavatar: BitbucketLink;\n\t};\n}\n\ninterface BitbucketProject {\n\ttype: 'project';\n\tkey: string;\n\tuuid: string;\n\tname: string;\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tavatar: BitbucketLink;\n\t};\n}\n\ninterface BitbucketPullRequestParticipant {\n\ttype: 'participant';\n\tuser: BitbucketUser;\n\trole: 'PARTICIPANT' | 'REVIEWER';\n\tapproved: boolean;\n\tstate: null | 'approved' | 'changes_requested';\n\tparticipated_on: null | string;\n}\n\nexport interface BitbucketRepository {\n\ttype: 'repository';\n\tuuid: string;\n\tfull_name: string;\n\tname: string;\n\tslug: string;\n\tdescription?: string;\n\tis_private: boolean;\n\tparent: null | BitbucketRepository;\n\tscm: 'git';\n\towner: BitbucketUser;\n\tworkspace: BitbucketWorkspace;\n\tproject: BitbucketProject;\n\tcreated_on: string;\n\tupdated_on: string;\n\tsize: number;\n\tlanguage: string;\n\thas_issues: boolean;\n\thas_wiki: boolean;\n\tfork_policy: 'allow_forks' | 'no_public_forks' | 'no_forks';\n\twebsite: string;\n\tmainbranch?: BitbucketBranch;\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tavatar: BitbucketLink;\n\t};\n}\n\ninterface BitbucketCommitAuthor {\n\ttype: 'author';\n\traw: string;\n\tuser: BitbucketUser;\n}\n\ntype BitbucketMergeStrategy =\n\t| 'merge_commit'\n\t| 'squash'\n\t| 'fast_forward'\n\t| 'squash_fast_forward'\n\t| 'rebase_fast_forward'\n\t| 'rebase_merge';\n\ninterface BitbucketBranch {\n\tname: string;\n\tmerge_strategies?: BitbucketMergeStrategy[];\n\tdefault_merge_strategy?: BitbucketMergeStrategy;\n}\n\n// It parses a raw author sitring like \"Sergei Shmakov GK <sergei.shmakov@gitkraken.com>\" to name and email\nconst parseRawBitbucketAuthorRegex = /^(.*) <(.*)>$/;\nexport function parseRawBitbucketAuthor(raw: string): { name: string; email: string } {\n\tconst match = raw.match(parseRawBitbucketAuthorRegex);\n\tif (match) {\n\t\treturn { name: match[1], email: match[2] };\n\t}\n\treturn { name: raw, email: '' };\n}\n\nexport interface BitbucketCommit extends BitbucketBriefCommit {\n\tauthor: BitbucketCommitAuthor;\n\tdate: string;\n\tlinks: {\n\t\tapprove: BitbucketLink;\n\t\tcomments: BitbucketLink;\n\t\tdiff: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tself: BitbucketLink;\n\t\tstatuses: BitbucketLink;\n\t};\n\tmessage: string;\n\tparents: BitbucketBriefCommit[];\n\tparticipants: BitbucketPullRequestParticipant[];\n\trendered: {\n\t\tmessage: string;\n\t};\n\trepository: BitbucketRepository;\n\tsummary: {\n\t\ttype: 'rendered';\n\t\traw: string;\n\t\tmarkup: string;\n\t\thtml: string;\n\t};\n}\n\ninterface BitbucketBriefCommit {\n\ttype: 'commit';\n\thash: string;\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t};\n}\n\nexport type BitbucketIssueState =\n\t| 'submitted'\n\t| 'new'\n\t| 'open'\n\t| 'resolved'\n\t| 'on hold'\n\t| 'invalid'\n\t| 'duplicate'\n\t| 'wontfix'\n\t| 'closed';\n\nexport interface BitbucketPullRequest {\n\ttype: 'pullrequest';\n\tid: number;\n\ttitle: string;\n\tdescription: string;\n\tstate: BitbucketPullRequestState;\n\tdraft?: boolean;\n\tmerge_commit: null | BitbucketBriefCommit;\n\tcomment_count: number;\n\ttask_count: number;\n\tclose_source_branch: boolean;\n\tclosed_by: BitbucketUser | null;\n\tauthor: BitbucketUser;\n\treason: string;\n\tcreated_on: string;\n\tupdated_on: string;\n\tdestination: {\n\t\tbranch: BitbucketBranch;\n\t\tcommit: BitbucketBriefCommit;\n\t\trepository: BitbucketRepository;\n\t};\n\tsource: {\n\t\tbranch: BitbucketBranch;\n\t\tcommit: BitbucketBriefCommit;\n\t\trepository: BitbucketRepository;\n\t};\n\tsummary: {\n\t\ttype: 'rendered';\n\t\traw: string;\n\t\tmarkup: string;\n\t\thtml: string;\n\t};\n\treviewers?: BitbucketUser[];\n\tparticipants?: BitbucketPullRequestParticipant[];\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tcommits: BitbucketLink;\n\t\tapprove: BitbucketLink;\n\t\t'request-changes': BitbucketLink;\n\t\tdiff: BitbucketLink;\n\t\tdiffstat: BitbucketLink;\n\t\tcomments: BitbucketLink;\n\t\tactivity: BitbucketLink;\n\t\tmerge: BitbucketLink;\n\t\tdecline: BitbucketLink;\n\t\tstatuses: BitbucketLink;\n\t};\n}\n\nexport interface BitbucketIssue {\n\ttype: string;\n\tid: number;\n\ttitle: string;\n\treporter: BitbucketUser;\n\tassignee?: BitbucketUser;\n\tstate: BitbucketIssueState;\n\tcreated_on: string;\n\tupdated_on: string;\n\trepository: BitbucketRepository;\n\tvotes?: number;\n\tcontent: {\n\t\traw: string;\n\t\tmarkup: string;\n\t\thtml: string;\n\t};\n\tlinks: {\n\t\tself: BitbucketLink;\n\t\thtml: BitbucketLink;\n\t\tcomments: BitbucketLink;\n\t\tattachments: BitbucketLink;\n\t\twatch: BitbucketLink;\n\t\tvote: BitbucketLink;\n\t};\n}\n\nexport function bitbucketPullRequestStateToState(state: BitbucketPullRequestState): IssueOrPullRequestState {\n\tswitch (state) {\n\t\tcase 'DECLINED':\n\t\tcase 'SUPERSEDED':\n\t\t\treturn 'closed';\n\t\tcase 'MERGED':\n\t\t\treturn 'merged';\n\t\tcase 'OPEN':\n\t\tdefault:\n\t\t\treturn 'opened';\n\t}\n}\n\nexport function bitbucketIssueStateToState(state: BitbucketIssueState): IssueOrPullRequestState {\n\tswitch (state) {\n\t\tcase 'resolved':\n\t\tcase 'invalid':\n\t\tcase 'duplicate':\n\t\tcase 'wontfix':\n\t\tcase 'closed':\n\t\t\treturn 'closed';\n\t\tcase 'submitted':\n\t\tcase 'new':\n\t\tcase 'open':\n\t\tcase 'on hold':\n\t\tdefault:\n\t\t\treturn 'opened';\n\t}\n}\n\nexport function isClosedBitbucketPullRequestState(state: BitbucketPullRequestState): boolean {\n\treturn bitbucketPullRequestStateToState(state) !== 'opened';\n}\n\nexport function isClosedBitbucketIssueState(state: BitbucketIssueState): boolean {\n\treturn bitbucketIssueStateToState(state) !== 'opened';\n}\n\nexport function fromBitbucketUser(user: BitbucketUser): PullRequestMember {\n\treturn {\n\t\tavatarUrl: user.links?.avatar?.href,\n\t\tname: user.display_name,\n\t\tusername: user.nickname,\n\t\turl: user.links?.html?.href,\n\t\tid: user.uuid,\n\t};\n}\n\nexport function fromBitbucketParticipantToReviewer(\n\tprt: BitbucketPullRequestParticipant,\n\tclosedBy: BitbucketUser | null,\n\tprState: BitbucketPullRequestState,\n): PullRequestReviewer {\n\treturn {\n\t\treviewer: fromBitbucketUser(prt.user),\n\t\tstate: prt.approved\n\t\t\t? PullRequestReviewState.Approved\n\t\t\t: prt.state === 'changes_requested'\n\t\t\t\t? PullRequestReviewState.ChangesRequested\n\t\t\t\t: prt.participated_on != null\n\t\t\t\t\t? PullRequestReviewState.Commented\n\t\t\t\t\t: prt.user.uuid === closedBy?.uuid && prState === 'DECLINED'\n\t\t\t\t\t\t? PullRequestReviewState.Dismissed\n\t\t\t\t\t\t: PullRequestReviewState.ReviewRequested,\n\t};\n}\n\n/**\n * The review decision a Bitbucket Cloud row carries, derived from its participants and reviewers. Reads only the\n * participants' `participated_on`, `approved` and `state` and whether there are reviewers, which is what the cheap etag\n * read selects for it.\n */\nexport function getBitbucketReviewDecision(pr: {\n\tparticipants?: readonly Pick<BitbucketPullRequestParticipant, 'approved' | 'state' | 'participated_on'>[];\n\treviewers?: readonly unknown[];\n}): PullRequestReviewDecision | undefined {\n\tif (!pr.participants?.length && pr.reviewers?.length) {\n\t\treturn PullRequestReviewDecision.ReviewRequired;\n\t}\n\tif (!pr.participants) {\n\t\treturn undefined;\n\t}\n\n\tlet hasReviews = false;\n\tlet hasChangeRequests = false;\n\tlet hasApprovals = false;\n\tfor (const prt of pr.participants) {\n\t\tif (prt.participated_on != null) {\n\t\t\thasReviews = true;\n\t\t}\n\t\tif (prt.approved) {\n\t\t\thasApprovals = true;\n\t\t}\n\t\tif (prt.state === 'changes_requested') {\n\t\t\thasChangeRequests = true;\n\t\t}\n\t}\n\tif (hasChangeRequests) return PullRequestReviewDecision.ChangesRequested;\n\tif (hasApprovals) return PullRequestReviewDecision.Approved;\n\tif (hasReviews) return undefined; // not approved, not rejected, but reviewed\n\treturn PullRequestReviewDecision.ReviewRequired; // nobody has reviewed yet.\n}\n\nfunction fromBitbucketRepository(repo: BitbucketRepository): IssueRepository {\n\treturn {\n\t\towner: repo.full_name.split('/')[0],\n\t\trepo: repo.name,\n\t\tid: repo.uuid,\n\t};\n}\n\nexport function fromBitbucketIssue(issue: BitbucketIssue, provider: Provider, projection?: IssueProjection): Issue {\n\tconst result = new Issue(\n\t\tprovider,\n\t\tissue.id.toString(),\n\t\tissue.id.toString(),\n\t\tissue.title,\n\t\tissue.links.html.href,\n\t\tnew Date(issue.created_on),\n\t\tnew Date(issue.updated_on),\n\t\tisClosedBitbucketIssueState(issue.state),\n\t\tbitbucketIssueStateToState(issue.state),\n\t\tfromBitbucketUser(issue.reporter),\n\t\tissue.assignee ? [fromBitbucketUser(issue.assignee)] : [],\n\t\tfromBitbucketRepository(issue.repository),\n\t\tundefined, // closedDate\n\t\tundefined, // labels\n\t\tundefined, // commentsCount\n\t\tissue.votes, // thumbsUpCount\n\t\tissue.content.html, // body\n\t\t!issue.repository?.project\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\tid: issue.repository.project.uuid,\n\t\t\t\t\tname: issue.repository.project.name,\n\t\t\t\t\tresourceId: issue.repository.project.uuid,\n\t\t\t\t\tresourceName: issue.repository.project.name,\n\t\t\t\t},\n\t\tundefined, // number\n\t\tundefined, // issueType\n\t\tundefined, // providerState\n\t\tundefined, // bodyFormat\n\t\tundefined, // iterations\n\t\tprojection,\n\t);\n\treturn copyReadProvenance(result, issue);\n}\n\nexport function fromBitbucketPullRequest(\n\tpr: BitbucketPullRequest,\n\tprovider: Provider,\n\toptions?: { currentAccount?: { id: string; username?: string }; projection?: PullRequestProjection },\n): PullRequest {\n\tconst author = fromBitbucketUser(pr.author);\n\tconst result = new PullRequest(\n\t\tprovider,\n\t\tauthor,\n\t\tpr.id.toString(),\n\t\tpr.id.toString(),\n\t\tpr.title,\n\t\tpr.links.html.href,\n\t\tfromBitbucketRepository(pr.destination.repository),\n\t\tbitbucketPullRequestStateToState(pr.state),\n\t\tnew Date(pr.created_on),\n\t\tnew Date(pr.updated_on),\n\t\tpr.closed_by ? new Date(pr.updated_on) : undefined,\n\t\tpr.state === 'MERGED' ? new Date(pr.updated_on) : undefined,\n\t\tundefined, // mergeableState: not read\n\t\tundefined, // viewerCanUpdate\n\t\t{\n\t\t\tbase: {\n\t\t\t\tbranch: pr.destination.branch.name,\n\t\t\t\tsha: pr.destination.commit.hash,\n\t\t\t\trepo: pr.destination.repository.name,\n\t\t\t\towner: pr.destination.repository.full_name.split('/')[0],\n\t\t\t\texists: true,\n\t\t\t\turl: pr.destination.repository.links.html.href,\n\t\t\t},\n\t\t\thead: {\n\t\t\t\tbranch: pr.source.branch.name,\n\t\t\t\tsha: pr.source.commit.hash,\n\t\t\t\trepo: pr.source.repository.name,\n\t\t\t\towner: pr.source.repository.full_name.split('/')[0],\n\t\t\t\texists: true,\n\t\t\t\turl: pr.source.repository.links.html.href,\n\t\t\t},\n\t\t\tisCrossRepository: pr.source.repository.uuid !== pr.destination.repository.uuid,\n\t\t},\n\t\tpr.draft,\n\t\tundefined, // additions\n\t\tundefined, // deletions\n\t\tundefined, // commentsCount\n\t\tundefined, // thumbsCount\n\t\tgetBitbucketReviewDecision(pr),\n\t\tpr.participants // reviewRequests:PullRequestReviewer[]\n\t\t\t?.filter(prt => prt.role === 'REVIEWER')\n\t\t\t.map(prt => fromBitbucketParticipantToReviewer(prt, pr.closed_by, pr.state))\n\t\t\t.filter(rv => rv.state === PullRequestReviewState.ReviewRequested),\n\t\tpr.participants // latestReviews:PullRequestReviewer[]\n\t\t\t?.filter(prt => prt.participated_on != null)\n\t\t\t.map(prt => fromBitbucketParticipantToReviewer(prt, pr.closed_by, pr.state)),\n\t\tundefined, // assignees:PullRequestMember[] -- it looks like there is no such thing as assignees on Bitbucket\n\t\tundefined, // PullRequestStatusCheckRollupState\n\t\tundefined, // IssueProject\n\t\tundefined, // version\n\t\tundefined, // commitCount\n\t\tundefined, // stack\n\t\tundefined, // filesChanged\n\t\tpr.description ?? undefined,\n\t\tpr.id,\n\t\toptions?.currentAccount != null ? author.id === options.currentAccount.id : undefined,\n\t\toptions?.projection,\n\t\toptions?.currentAccount,\n\t);\n\treturn copyReadProvenance(result, pr);\n}\n\n/** The most pull request ids one etag read asks for: Bitbucket Cloud's largest page of pull requests. */\nexport const bitbucketEtagFieldsMaxIds = 50;\n\n/**\n * A pull request as the cheap etag read selects it (`BitbucketApi.getPullRequestsEtagFields`): only the fields\n * {@link fromBitbucketPullRequest} maps into a full row's etag inputs. `participants` and `reviewers` are selected\n * only for the `reviewDecision` include.\n */\nexport interface BitbucketPullRequestEtagNode {\n\tid: number;\n\tstate: BitbucketPullRequestState;\n\tupdated_on: string;\n\tdraft?: boolean;\n\tsource: { commit: { hash: string } };\n\tparticipants?: Pick<BitbucketPullRequestParticipant, 'approved' | 'state' | 'participated_on'>[];\n\treviewers?: unknown[];\n}\n\n/**\n * A cheap etag read's pull request in the vocabulary {@link fromBitbucketPullRequest}'s row ends in, so both reads\n * compute the same etag. That row reads neither a mergeability nor a check rollup, so neither does this.\n */\nexport function toBitbucketPullRequestEtagFields(\n\tnode: BitbucketPullRequestEtagNode,\n\tetagIncludes: readonly PullRequestEtagInclude[],\n): PullRequestEtagFields {\n\tconst fields: PullRequestEtagFields = {\n\t\tstate: bitbucketPullRequestStateToState(node.state),\n\t\tisDraft: node.draft,\n\t\tupdatedDate: new Date(node.updated_on),\n\t\theadSha: node.source.commit.hash,\n\t};\n\n\tif (etagIncludes.includes('reviewDecision')) {\n\t\t// The full read always has both lists, and the decision tells a missing list from an empty one, so a row\n\t\t// without them can't be compared: it rejects, and the full read answers instead.\n\t\tif (node.participants == null || node.reviewers == null) {\n\t\t\tthrow new Error(`Bitbucket returned pull request ${node.id} without its participants or reviewers`);\n\t\t}\n\n\t\tfields.reviewDecision = getBitbucketReviewDecision(node);\n\t}\n\n\treturn fields;\n}\n"],"mappings":";;;;AA8HA,MAAM,+BAA+B;AACrC,SAAgB,wBAAwB,KAA8C;CACrF,MAAM,QAAQ,IAAI,MAAM,4BAA4B;CACpD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,SAAS,cACV;CACA,OAAO,mBAAmB,QAAQ,EAAE;AACrC;;AAGA,MAAa,4BAA4B;;;;;AAqBzC,SAAgB,iCACf,MACA,cACwB;CACxB,MAAM,SAAgC;EACrC,OAAO,iCAAiC,KAAK,KAAK;EAClD,SAAS,KAAK;EACd,aAAa,IAAI,KAAK,KAAK,UAAU;EACrC,SAAS,KAAK,OAAO,OAAO;CAC7B;CAEA,IAAI,aAAa,SAAS,gBAAgB,GAAG;EAG5C,IAAI,KAAK,gBAAgB,QAAQ,KAAK,aAAa,MAClD,MAAM,IAAI,MAAM,mCAAmC,KAAK,GAAG,uCAAuC;EAGnG,OAAO,iBAAiB,2BAA2B,IAAI;CACxD;CAEA,OAAO;AACR"}
@@ -1,3 +1,4 @@
1
+ import { copyReadProvenance } from "@gitkraken/provider-apis/read-provenance";
1
2
  //#region ../plus/integrations/src/providers/bitbucket-server/models.ts
2
3
  const GitPullRequestState = {
3
4
  Open: "OPEN",
@@ -50,7 +51,7 @@ const normalizeBitbucketServerPullRequest = (pr) => {
50
51
  const headSSHUrl = pr.fromRef.repository.links.clone.find((link) => link.name === "ssh")?.href ?? null;
51
52
  let headHTTPSUrl = pr.fromRef.repository.links.clone.find((link) => link.name === "https")?.href ?? null;
52
53
  if (!headHTTPSUrl) headHTTPSUrl = pr.fromRef.repository.links.clone.find((link) => link.name === "http")?.href ?? null;
53
- return {
54
+ const result = {
54
55
  id: pr.id.toString(),
55
56
  number: pr.id,
56
57
  title: pr.title,
@@ -103,6 +104,7 @@ const normalizeBitbucketServerPullRequest = (pr) => {
103
104
  permissions: null,
104
105
  version: pr.version
105
106
  };
107
+ return copyReadProvenance(result, pr);
106
108
  };
107
109
  //#endregion
108
110
  export { GitPullRequestReviewState, GitPullRequestState, normalizeBitbucketServerPullRequest, summarizeReviewDecision };
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/bitbucket-server/models.ts"],"sourcesContent":["import type {\n\tGitPullRequestReviewState as GitPullRequestReviewStateType,\n\tGitPullRequestState as GitPullRequestStateType,\n} from '@gitkraken/provider-apis';\nimport type { ProviderAccount, ProviderPullRequest } from '../models.js';\n\ntype GitPullRequestReviewState = GitPullRequestReviewStateType;\ntype GitPullRequestState = GitPullRequestStateType;\n\n// Local runtime copies of the `@gitkraken/provider-apis` PR string enums. Exported so the enum-parity\n// test can guard them against upstream drift.\nexport const GitPullRequestState = {\n\tOpen: 'OPEN' as GitPullRequestState,\n\tClosed: 'CLOSED' as GitPullRequestState,\n\tMerged: 'MERGED' as GitPullRequestState,\n} as const;\n\nexport const GitPullRequestReviewState = {\n\tApproved: 'APPROVED' as GitPullRequestReviewState,\n\tChangesRequested: 'CHANGES_REQUESTED' as GitPullRequestReviewState,\n\tCommented: 'COMMENTED' as GitPullRequestReviewState,\n\tReviewRequested: 'REVIEW_REQUESTED' as GitPullRequestReviewState,\n} as const;\n\nexport interface BitbucketServerLink {\n\thref: string;\n}\n\nexport interface NamedBitbucketServerLink<T extends string = string> extends BitbucketServerLink {\n\tname: T;\n}\n\nexport interface BitbucketServerPagedResponse<T> {\n\tvalues: T[];\n\tsize: number;\n\tlimit: number;\n\tisLastPage: boolean;\n\tnextPageStart: number;\n\tstart: number;\n}\n\nexport interface BitbucketServerPullRequestRef {\n\tid: string;\n\tdisplayId: string;\n\tlatestCommit: string;\n\ttype: string;\n\trepository: {\n\t\tslug: string;\n\t\tid: number;\n\t\tname: string;\n\t\thierarchyId: string;\n\t\tscmId: string;\n\t\tstate: string;\n\t\tstatusMessage: string;\n\t\tforkable: boolean;\n\t\tproject: {\n\t\t\tkey: string;\n\t\t\tid: number;\n\t\t\tname: string;\n\t\t\tpublic: boolean;\n\t\t\ttype: string;\n\t\t\tlinks: {\n\t\t\t\tself: BitbucketServerLink[];\n\t\t\t};\n\t\t};\n\t\tpublic: boolean;\n\t\tarchived: boolean;\n\t\tlinks: {\n\t\t\tclone: NamedBitbucketServerLink[];\n\t\t\tself: BitbucketServerLink[];\n\t\t};\n\t};\n}\n\nexport interface BitbucketAuthor {\n\tname: string;\n\temailAddress: string;\n\tid: undefined;\n}\n\nexport interface BitbucketServerUser {\n\tname: string;\n\temailAddress: string;\n\tactive: boolean;\n\tdisplayName: string;\n\tid: number;\n\tslug: string;\n\ttype: string;\n\tlinks: {\n\t\tself: BitbucketServerLink[];\n\t};\n\tavatarUrl?: string;\n}\n\nexport interface BitbucketServerPullRequestUser {\n\tuser: BitbucketServerUser;\n\tlastReviewedCommit?: string;\n\trole: 'REVIEWER' | 'AUTHOR' | 'PARTICIPANT';\n\tapproved: boolean;\n\tstatus: 'UNAPPROVED' | 'NEEDS_WORK' | 'APPROVED';\n}\n\nexport interface BitbucketServerBriefCommit {\n\tdisplayId: string;\n\tid: string;\n}\n\nexport interface BitbucketServerCommit extends BitbucketServerBriefCommit {\n\tauthor: BitbucketServerUser | BitbucketAuthor;\n\tauthorTimestamp: number;\n\tcommitter: BitbucketServerUser | BitbucketAuthor;\n\tcommitterTimestamp: number;\n\tmessage: string;\n\tparents: (BitbucketServerCommit | BitbucketServerBriefCommit)[];\n}\n\nexport interface BitbucketServerPullRequest {\n\tid: number;\n\tversion: number;\n\ttitle: string;\n\tdescription: string;\n\t/**\n\t * `SUPERSEDED` is not in the published schema, but a server can still report it for a pull request closed by a\n\t * newer one (the Bitbucket SDK maps it too); it is a closed pull request, like `DECLINED`.\n\t */\n\tstate: 'OPEN' | 'MERGED' | 'DECLINED' | 'SUPERSEDED';\n\t/**\n\t * Drafts shipped in Bitbucket Data Center 8.18 (8.17 exposed the field experimentally); absent means the server\n\t * has no drafts, so not a draft.\n\t */\n\tdraft?: boolean;\n\topen: boolean;\n\tclosed: boolean;\n\tcreatedDate: number;\n\tupdatedDate: number;\n\tclosedDate: number | null;\n\tfromRef: BitbucketServerPullRequestRef;\n\ttoRef: BitbucketServerPullRequestRef;\n\tlocked: boolean;\n\tauthor: BitbucketServerPullRequestUser;\n\treviewers: BitbucketServerPullRequestUser[];\n\tparticipants: BitbucketServerPullRequestUser[];\n\tproperties: {\n\t\tmergeResult: {\n\t\t\toutcome: string;\n\t\t\tcurrent: boolean;\n\t\t};\n\t\tresolvedTaskCount: number;\n\t\tcommentCount: number;\n\t\topenTaskCount: number;\n\t};\n\tlinks: {\n\t\tself: BitbucketServerLink[];\n\t};\n}\n\nconst normalizeUser = (user: BitbucketServerUser): ProviderAccount => ({\n\tname: user.displayName,\n\temail: user.emailAddress,\n\tavatarUrl: user.avatarUrl ?? null,\n\tid: user.id.toString(),\n\tusername: user.name,\n\turl: user.links.self[0].href,\n});\n\nconst reviewDecisionWeightByReviewState = {\n\t[GitPullRequestReviewState.Approved]: 0,\n\t[GitPullRequestReviewState.Commented]: 1,\n\t[GitPullRequestReviewState.ReviewRequested]: 2,\n\t[GitPullRequestReviewState.ChangesRequested]: 3,\n};\n\nexport const summarizeReviewDecision = (\n\treviews: { state: GitPullRequestReviewState }[] | null,\n): GitPullRequestReviewState | null => {\n\tif (!reviews || reviews.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn reviews.reduce(\n\t\t(prev: GitPullRequestReviewState, review) =>\n\t\t\treviewDecisionWeightByReviewState[review.state] > reviewDecisionWeightByReviewState[prev]\n\t\t\t\t? review.state\n\t\t\t\t: prev,\n\t\tGitPullRequestReviewState.Approved,\n\t);\n};\n\nexport const normalizeBitbucketServerPullRequest = (pr: BitbucketServerPullRequest): ProviderPullRequest => {\n\tconst bitbucketStateToGitState = {\n\t\tOPEN: GitPullRequestState.Open,\n\t\tMERGED: GitPullRequestState.Merged,\n\t\tDECLINED: GitPullRequestState.Closed,\n\t\tSUPERSEDED: GitPullRequestState.Closed,\n\t};\n\n\tconst reviewerStatusToGitState = {\n\t\tUNAPPROVED: GitPullRequestReviewState.ReviewRequested,\n\t\tNEEDS_WORK: GitPullRequestReviewState.ChangesRequested,\n\t\tAPPROVED: GitPullRequestReviewState.Approved,\n\t};\n\n\tconst reviews = pr.reviewers.map(reviewer => ({\n\t\treviewer: normalizeUser(reviewer.user),\n\t\tstate: reviewerStatusToGitState[reviewer.status],\n\t}));\n\n\tconst baseSSHUrl = pr.toRef.repository.links.clone.find(link => link.name === 'ssh')?.href ?? null;\n\tlet baseHTTPSUrl = pr.toRef.repository.links.clone.find(link => link.name === 'https')?.href ?? null;\n\tif (!baseHTTPSUrl) {\n\t\tbaseHTTPSUrl = pr.toRef.repository.links.clone.find(link => link.name === 'http')?.href ?? null;\n\t}\n\n\tconst headSSHUrl = pr.fromRef.repository.links.clone.find(link => link.name === 'ssh')?.href ?? null;\n\tlet headHTTPSUrl = pr.fromRef.repository.links.clone.find(link => link.name === 'https')?.href ?? null;\n\tif (!headHTTPSUrl) {\n\t\theadHTTPSUrl = pr.fromRef.repository.links.clone.find(link => link.name === 'http')?.href ?? null;\n\t}\n\n\treturn {\n\t\tid: pr.id.toString(),\n\t\tnumber: pr.id,\n\t\ttitle: pr.title,\n\t\tdescription: pr.description ?? null,\n\t\turl: pr.links.self[0].href,\n\t\tstate: bitbucketStateToGitState[pr.state],\n\t\tisCrossRepository: pr.toRef.repository.id !== pr.fromRef.repository.id,\n\t\tisDraft: pr.draft === true,\n\t\tcreatedDate: new Date(pr.createdDate),\n\t\tupdatedDate: new Date(pr.updatedDate),\n\t\tclosedDate: pr.closedDate ? new Date(pr.closedDate) : null,\n\t\tmergedDate: pr.state === 'MERGED' && pr.closedDate ? new Date(pr.closedDate) : null,\n\t\tbaseRef: {\n\t\t\tname: pr.toRef.displayId,\n\t\t\toid: pr.toRef.latestCommit,\n\t\t},\n\t\theadRef: {\n\t\t\tname: pr.fromRef.displayId,\n\t\t\toid: pr.fromRef.latestCommit,\n\t\t},\n\t\tcommentCount: pr.properties?.commentCount,\n\t\tupvoteCount: null,\n\t\tcommitCount: null,\n\t\tfileCount: null,\n\t\tadditions: null,\n\t\tdeletions: null,\n\t\tauthor: normalizeUser(pr.author.user),\n\t\tassignees: null,\n\t\treviews: reviews,\n\t\treviewDecision: summarizeReviewDecision(reviews),\n\t\trepository: {\n\t\t\tid: pr.toRef.repository.id.toString(),\n\t\t\tname: pr.toRef.repository.name,\n\t\t\towner: {\n\t\t\t\tlogin: pr.toRef.repository.project.key,\n\t\t\t},\n\t\t\tremoteInfo:\n\t\t\t\tbaseHTTPSUrl && baseSSHUrl\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcloneUrlHTTPS: baseHTTPSUrl,\n\t\t\t\t\t\t\tcloneUrlSSH: baseSSHUrl,\n\t\t\t\t\t\t}\n\t\t\t\t\t: null,\n\t\t},\n\t\theadRepository: {\n\t\t\tid: pr.fromRef.repository.id.toString(),\n\t\t\tname: pr.fromRef.repository.name,\n\t\t\towner: {\n\t\t\t\tlogin: pr.fromRef.repository.project.key,\n\t\t\t},\n\t\t\tremoteInfo:\n\t\t\t\theadHTTPSUrl && headSSHUrl\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcloneUrlHTTPS: headHTTPSUrl,\n\t\t\t\t\t\t\tcloneUrlSSH: headSSHUrl,\n\t\t\t\t\t\t}\n\t\t\t\t\t: null,\n\t\t},\n\t\theadCommit: null,\n\t\tpermissions: null,\n\t\tversion: pr.version,\n\t};\n};\n"],"mappings":";AAWA,MAAa,sBAAsB;CAClC,MAAM;CACN,QAAQ;CACR,QAAQ;AACT;AAEA,MAAa,4BAA4B;CACxC,UAAU;CACV,kBAAkB;CAClB,WAAW;CACX,iBAAiB;AAClB;AAsIA,MAAM,iBAAiB,UAAgD;CACtE,MAAM,KAAK;CACX,OAAO,KAAK;CACZ,WAAW,KAAK,aAAa;CAC7B,IAAI,KAAK,GAAG,SAAS;CACrB,UAAU,KAAK;CACf,KAAK,KAAK,MAAM,KAAK,EAAE,CAAC;AACzB;AAEA,MAAM,oCAAoC;EACxC,0BAA0B,WAAW;EACrC,0BAA0B,YAAY;EACtC,0BAA0B,kBAAkB;EAC5C,0BAA0B,mBAAmB;AAC/C;AAEA,MAAa,2BACZ,YACsC;CACtC,IAAI,CAAC,WAAW,QAAQ,WAAW,GAClC,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AAO,yBAAyB,GAAG;EACnC,mBAAmB,GAAG,MAAM,WAAW,OAAO,GAAG,QAAQ,WAAW;EACpE,SAAS,GAAG,UAAU;EACtB,aAAa,IAAI,KAAK,GAAG,WAAW;EACpC,aAAa,IAAI,KAAK,GAAG,WAAW;EACpC,YAAY,GAAG,aAAa,IAAI,KAAK,GAAG,UAAU,IAAI;EACtD,YAAY,GAAG,UAAU,YAAY,GAAG,aAAa,IAAI,KAAK,GAAG,UAAU,IAAI;EAC/E,SAAS;GACR,MAAM,GAAG,MAAM;GACf,KAAK,GAAG,MAAM;EACf;EACA,SAAS;GACR,MAAM,GAAG,QAAQ;GACjB,KAAK,GAAG,QAAQ;EACjB;EACA,cAAc,GAAG,YAAY;EAC7B,aAAa;EACb,aAAa;EACb,WAAW;EACX,WAAW;EACX,WAAW;EACX,QAAQ,cAAc,GAAG,OAAO,IAAI;EACpC,WAAW;EACF;EACT,gBAAgB,wBAAwB,OAAO;EAC/C,YAAY;GACX,IAAI,GAAG,MAAM,WAAW,GAAG,SAAS;GACpC,MAAM,GAAG,MAAM,WAAW;GAC1B,OAAO,EACN,OAAO,GAAG,MAAM,WAAW,QAAQ,IACpC;GACA,YACC,gBAAgB,aACb;IACA,eAAe;IACf,aAAa;GACd,IACC;EACL;EACA,gBAAgB;GACf,IAAI,GAAG,QAAQ,WAAW,GAAG,SAAS;GACtC,MAAM,GAAG,QAAQ,WAAW;GAC5B,OAAO,EACN,OAAO,GAAG,QAAQ,WAAW,QAAQ,IACtC;GACA,YACC,gBAAgB,aACb;IACA,eAAe;IACf,aAAa;GACd,IACC;EACL;EACA,YAAY;EACZ,aAAa;EACb,SAAS,GAAG;CACb;AACD"}
1
+ {"version":3,"file":"models.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/bitbucket-server/models.ts"],"sourcesContent":["import type {\n\tGitPullRequestReviewState as GitPullRequestReviewStateType,\n\tGitPullRequestState as GitPullRequestStateType,\n} from '@gitkraken/provider-apis';\nimport { copyReadProvenance } from '@gitkraken/provider-apis/read-provenance';\nimport type { ProviderAccount, ProviderPullRequest } from '../models.js';\n\ntype GitPullRequestReviewState = GitPullRequestReviewStateType;\ntype GitPullRequestState = GitPullRequestStateType;\n\n// Local runtime copies of the `@gitkraken/provider-apis` PR string enums. Exported so the enum-parity\n// test can guard them against upstream drift.\nexport const GitPullRequestState = {\n\tOpen: 'OPEN' as GitPullRequestState,\n\tClosed: 'CLOSED' as GitPullRequestState,\n\tMerged: 'MERGED' as GitPullRequestState,\n} as const;\n\nexport const GitPullRequestReviewState = {\n\tApproved: 'APPROVED' as GitPullRequestReviewState,\n\tChangesRequested: 'CHANGES_REQUESTED' as GitPullRequestReviewState,\n\tCommented: 'COMMENTED' as GitPullRequestReviewState,\n\tReviewRequested: 'REVIEW_REQUESTED' as GitPullRequestReviewState,\n} as const;\n\nexport interface BitbucketServerLink {\n\thref: string;\n}\n\nexport interface NamedBitbucketServerLink<T extends string = string> extends BitbucketServerLink {\n\tname: T;\n}\n\nexport interface BitbucketServerPagedResponse<T> {\n\tvalues: T[];\n\tsize: number;\n\tlimit: number;\n\tisLastPage: boolean;\n\tnextPageStart: number;\n\tstart: number;\n}\n\nexport interface BitbucketServerPullRequestRef {\n\tid: string;\n\tdisplayId: string;\n\tlatestCommit: string;\n\ttype: string;\n\trepository: {\n\t\tslug: string;\n\t\tid: number;\n\t\tname: string;\n\t\thierarchyId: string;\n\t\tscmId: string;\n\t\tstate: string;\n\t\tstatusMessage: string;\n\t\tforkable: boolean;\n\t\tproject: {\n\t\t\tkey: string;\n\t\t\tid: number;\n\t\t\tname: string;\n\t\t\tpublic: boolean;\n\t\t\ttype: string;\n\t\t\tlinks: {\n\t\t\t\tself: BitbucketServerLink[];\n\t\t\t};\n\t\t};\n\t\tpublic: boolean;\n\t\tarchived: boolean;\n\t\tlinks: {\n\t\t\tclone: NamedBitbucketServerLink[];\n\t\t\tself: BitbucketServerLink[];\n\t\t};\n\t};\n}\n\nexport interface BitbucketAuthor {\n\tname: string;\n\temailAddress: string;\n\tid: undefined;\n}\n\nexport interface BitbucketServerUser {\n\tname: string;\n\temailAddress: string;\n\tactive: boolean;\n\tdisplayName: string;\n\tid: number;\n\tslug: string;\n\ttype: string;\n\tlinks: {\n\t\tself: BitbucketServerLink[];\n\t};\n\tavatarUrl?: string;\n}\n\nexport interface BitbucketServerPullRequestUser {\n\tuser: BitbucketServerUser;\n\tlastReviewedCommit?: string;\n\trole: 'REVIEWER' | 'AUTHOR' | 'PARTICIPANT';\n\tapproved: boolean;\n\tstatus: 'UNAPPROVED' | 'NEEDS_WORK' | 'APPROVED';\n}\n\nexport interface BitbucketServerBriefCommit {\n\tdisplayId: string;\n\tid: string;\n}\n\nexport interface BitbucketServerCommit extends BitbucketServerBriefCommit {\n\tauthor: BitbucketServerUser | BitbucketAuthor;\n\tauthorTimestamp: number;\n\tcommitter: BitbucketServerUser | BitbucketAuthor;\n\tcommitterTimestamp: number;\n\tmessage: string;\n\tparents: (BitbucketServerCommit | BitbucketServerBriefCommit)[];\n}\n\nexport interface BitbucketServerPullRequest {\n\tid: number;\n\tversion: number;\n\ttitle: string;\n\tdescription: string;\n\t/**\n\t * `SUPERSEDED` is not in the published schema, but a server can still report it for a pull request closed by a\n\t * newer one (the Bitbucket SDK maps it too); it is a closed pull request, like `DECLINED`.\n\t */\n\tstate: 'OPEN' | 'MERGED' | 'DECLINED' | 'SUPERSEDED';\n\t/**\n\t * Drafts shipped in Bitbucket Data Center 8.18 (8.17 exposed the field experimentally); absent means the server\n\t * has no drafts, so not a draft.\n\t */\n\tdraft?: boolean;\n\topen: boolean;\n\tclosed: boolean;\n\tcreatedDate: number;\n\tupdatedDate: number;\n\tclosedDate: number | null;\n\tfromRef: BitbucketServerPullRequestRef;\n\ttoRef: BitbucketServerPullRequestRef;\n\tlocked: boolean;\n\tauthor: BitbucketServerPullRequestUser;\n\treviewers: BitbucketServerPullRequestUser[];\n\tparticipants: BitbucketServerPullRequestUser[];\n\tproperties: {\n\t\tmergeResult: {\n\t\t\toutcome: string;\n\t\t\tcurrent: boolean;\n\t\t};\n\t\tresolvedTaskCount: number;\n\t\tcommentCount: number;\n\t\topenTaskCount: number;\n\t};\n\tlinks: {\n\t\tself: BitbucketServerLink[];\n\t};\n}\n\nconst normalizeUser = (user: BitbucketServerUser): ProviderAccount => ({\n\tname: user.displayName,\n\temail: user.emailAddress,\n\tavatarUrl: user.avatarUrl ?? null,\n\tid: user.id.toString(),\n\tusername: user.name,\n\turl: user.links.self[0].href,\n});\n\nconst reviewDecisionWeightByReviewState = {\n\t[GitPullRequestReviewState.Approved]: 0,\n\t[GitPullRequestReviewState.Commented]: 1,\n\t[GitPullRequestReviewState.ReviewRequested]: 2,\n\t[GitPullRequestReviewState.ChangesRequested]: 3,\n};\n\nexport const summarizeReviewDecision = (\n\treviews: { state: GitPullRequestReviewState }[] | null,\n): GitPullRequestReviewState | null => {\n\tif (!reviews || reviews.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn reviews.reduce(\n\t\t(prev: GitPullRequestReviewState, review) =>\n\t\t\treviewDecisionWeightByReviewState[review.state] > reviewDecisionWeightByReviewState[prev]\n\t\t\t\t? review.state\n\t\t\t\t: prev,\n\t\tGitPullRequestReviewState.Approved,\n\t);\n};\n\nexport const normalizeBitbucketServerPullRequest = (pr: BitbucketServerPullRequest): ProviderPullRequest => {\n\tconst bitbucketStateToGitState = {\n\t\tOPEN: GitPullRequestState.Open,\n\t\tMERGED: GitPullRequestState.Merged,\n\t\tDECLINED: GitPullRequestState.Closed,\n\t\tSUPERSEDED: GitPullRequestState.Closed,\n\t};\n\n\tconst reviewerStatusToGitState = {\n\t\tUNAPPROVED: GitPullRequestReviewState.ReviewRequested,\n\t\tNEEDS_WORK: GitPullRequestReviewState.ChangesRequested,\n\t\tAPPROVED: GitPullRequestReviewState.Approved,\n\t};\n\n\tconst reviews = pr.reviewers.map(reviewer => ({\n\t\treviewer: normalizeUser(reviewer.user),\n\t\tstate: reviewerStatusToGitState[reviewer.status],\n\t}));\n\n\tconst baseSSHUrl = pr.toRef.repository.links.clone.find(link => link.name === 'ssh')?.href ?? null;\n\tlet baseHTTPSUrl = pr.toRef.repository.links.clone.find(link => link.name === 'https')?.href ?? null;\n\tif (!baseHTTPSUrl) {\n\t\tbaseHTTPSUrl = pr.toRef.repository.links.clone.find(link => link.name === 'http')?.href ?? null;\n\t}\n\n\tconst headSSHUrl = pr.fromRef.repository.links.clone.find(link => link.name === 'ssh')?.href ?? null;\n\tlet headHTTPSUrl = pr.fromRef.repository.links.clone.find(link => link.name === 'https')?.href ?? null;\n\tif (!headHTTPSUrl) {\n\t\theadHTTPSUrl = pr.fromRef.repository.links.clone.find(link => link.name === 'http')?.href ?? null;\n\t}\n\n\tconst result: ProviderPullRequest = {\n\t\tid: pr.id.toString(),\n\t\tnumber: pr.id,\n\t\ttitle: pr.title,\n\t\tdescription: pr.description ?? null,\n\t\turl: pr.links.self[0].href,\n\t\tstate: bitbucketStateToGitState[pr.state],\n\t\tisCrossRepository: pr.toRef.repository.id !== pr.fromRef.repository.id,\n\t\tisDraft: pr.draft === true,\n\t\tcreatedDate: new Date(pr.createdDate),\n\t\tupdatedDate: new Date(pr.updatedDate),\n\t\tclosedDate: pr.closedDate ? new Date(pr.closedDate) : null,\n\t\tmergedDate: pr.state === 'MERGED' && pr.closedDate ? new Date(pr.closedDate) : null,\n\t\tbaseRef: {\n\t\t\tname: pr.toRef.displayId,\n\t\t\toid: pr.toRef.latestCommit,\n\t\t},\n\t\theadRef: {\n\t\t\tname: pr.fromRef.displayId,\n\t\t\toid: pr.fromRef.latestCommit,\n\t\t},\n\t\tcommentCount: pr.properties?.commentCount,\n\t\tupvoteCount: null,\n\t\tcommitCount: null,\n\t\tfileCount: null,\n\t\tadditions: null,\n\t\tdeletions: null,\n\t\tauthor: normalizeUser(pr.author.user),\n\t\tassignees: null,\n\t\treviews: reviews,\n\t\treviewDecision: summarizeReviewDecision(reviews),\n\t\trepository: {\n\t\t\tid: pr.toRef.repository.id.toString(),\n\t\t\tname: pr.toRef.repository.name,\n\t\t\towner: {\n\t\t\t\tlogin: pr.toRef.repository.project.key,\n\t\t\t},\n\t\t\tremoteInfo:\n\t\t\t\tbaseHTTPSUrl && baseSSHUrl\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcloneUrlHTTPS: baseHTTPSUrl,\n\t\t\t\t\t\t\tcloneUrlSSH: baseSSHUrl,\n\t\t\t\t\t\t}\n\t\t\t\t\t: null,\n\t\t},\n\t\theadRepository: {\n\t\t\tid: pr.fromRef.repository.id.toString(),\n\t\t\tname: pr.fromRef.repository.name,\n\t\t\towner: {\n\t\t\t\tlogin: pr.fromRef.repository.project.key,\n\t\t\t},\n\t\t\tremoteInfo:\n\t\t\t\theadHTTPSUrl && headSSHUrl\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tcloneUrlHTTPS: headHTTPSUrl,\n\t\t\t\t\t\t\tcloneUrlSSH: headSSHUrl,\n\t\t\t\t\t\t}\n\t\t\t\t\t: null,\n\t\t},\n\t\theadCommit: null,\n\t\tpermissions: null,\n\t\tversion: pr.version,\n\t};\n\treturn copyReadProvenance(result, pr);\n};\n"],"mappings":";;AAYA,MAAa,sBAAsB;CAClC,MAAM;CACN,QAAQ;CACR,QAAQ;AACT;AAEA,MAAa,4BAA4B;CACxC,UAAU;CACV,kBAAkB;CAClB,WAAW;CACX,iBAAiB;AAClB;AAsIA,MAAM,iBAAiB,UAAgD;CACtE,MAAM,KAAK;CACX,OAAO,KAAK;CACZ,WAAW,KAAK,aAAa;CAC7B,IAAI,KAAK,GAAG,SAAS;CACrB,UAAU,KAAK;CACf,KAAK,KAAK,MAAM,KAAK,EAAE,CAAC;AACzB;AAEA,MAAM,oCAAoC;EACxC,0BAA0B,WAAW;EACrC,0BAA0B,YAAY;EACtC,0BAA0B,kBAAkB;EAC5C,0BAA0B,mBAAmB;AAC/C;AAEA,MAAa,2BACZ,YACsC;CACtC,IAAI,CAAC,WAAW,QAAQ,WAAW,GAClC,OAAO;CAGR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O,yBAAyB,GAAG;EACnC,mBAAmB,GAAG,MAAM,WAAW,OAAO,GAAG,QAAQ,WAAW;EACpE,SAAS,GAAG,UAAU;EACtB,aAAa,IAAI,KAAK,GAAG,WAAW;EACpC,aAAa,IAAI,KAAK,GAAG,WAAW;EACpC,YAAY,GAAG,aAAa,IAAI,KAAK,GAAG,UAAU,IAAI;EACtD,YAAY,GAAG,UAAU,YAAY,GAAG,aAAa,IAAI,KAAK,GAAG,UAAU,IAAI;EAC/E,SAAS;GACR,MAAM,GAAG,MAAM;GACf,KAAK,GAAG,MAAM;EACf;EACA,SAAS;GACR,MAAM,GAAG,QAAQ;GACjB,KAAK,GAAG,QAAQ;EACjB;EACA,cAAc,GAAG,YAAY;EAC7B,aAAa;EACb,aAAa;EACb,WAAW;EACX,WAAW;EACX,WAAW;EACX,QAAQ,cAAc,GAAG,OAAO,IAAI;EACpC,WAAW;EACF;EACT,gBAAgB,wBAAwB,OAAO;EAC/C,YAAY;GACX,IAAI,GAAG,MAAM,WAAW,GAAG,SAAS;GACpC,MAAM,GAAG,MAAM,WAAW;GAC1B,OAAO,EACN,OAAO,GAAG,MAAM,WAAW,QAAQ,IACpC;GACA,YACC,gBAAgB,aACb;IACA,eAAe;IACf,aAAa;GACd,IACC;EACL;EACA,gBAAgB;GACf,IAAI,GAAG,QAAQ,WAAW,GAAG,SAAS;GACtC,MAAM,GAAG,QAAQ,WAAW;GAC5B,OAAO,EACN,OAAO,GAAG,QAAQ,WAAW,QAAQ,IACtC;GACA,YACC,gBAAgB,aACb;IACA,eAAe;IACf,aAAa;GACd,IACC;EACL;EACA,YAAY;EACZ,aAAa;EACb,SAAS,GAAG;CACb;CACA,OAAO,mBAAmB,QAAQ,EAAE;AACrC"}
@@ -86,7 +86,9 @@ export declare class BitbucketServerIntegration extends GitHostIntegration<GitSe
86
86
  avatarSize?: number;
87
87
  include?: IssueOrPullRequestState[];
88
88
  }): Promise<PullRequest | undefined>;
89
+ protected getProviderPullRequestForCommitInBatch(session: ProviderAuthenticationSession, repo: BitbucketRepositoryDescriptor, rev: string, cancellation?: AbortSignal): Promise<PullRequest | undefined>;
89
90
  protected getProviderPullRequestForCommit(session: ProviderAuthenticationSession, repo: BitbucketRepositoryDescriptor, rev: string): Promise<PullRequest | undefined>;
91
+ private readPullRequestForCommit;
90
92
  protected getProviderPullRequest(session: ProviderAuthenticationSession, resource: BitbucketRepositoryDescriptor, id: string): Promise<PullRequest | undefined>;
91
93
  protected getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined;
92
94
  getRepoInfo(repo: {
@@ -3,7 +3,7 @@ import { mapSettledBounded, nonnullSettled } from "../../../utils/promise.js";
3
3
  import { AuthenticationError } from "../../../git/errors.js";
4
4
  import { md5 } from "../../../utils/crypto.js";
5
5
  import "../../../git/models/pullRequest.js";
6
- import { getAuthenticatedUser } from "../errors.js";
6
+ import { IntegrationReadUnavailableError, getAuthenticatedUser } from "../errors.js";
7
7
  import "../constants.js";
8
8
  import { collectProviderPagedResult, flatSettledOrThrow, parsePageCursor, toPageCursor } from "./utils/providerPaging.js";
9
9
  import { ProviderPullRequestReviewState, fromProviderPullRequest, providerPullRequestMatchesSearch, providersMetadata, toProviderPullRequestStates } from "./models.js";
@@ -90,8 +90,16 @@ var BitbucketServerIntegration = class extends GitHostIntegration {
90
90
  async getProviderPullRequestForBranch(session, repo, branch, _options) {
91
91
  return (await this.authenticationService.apis.bitbucket)?.getServerPullRequestForBranch(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, branch, this.apiBaseUrlFor(session));
92
92
  }
93
- async getProviderPullRequestForCommit(session, repo, rev) {
94
- return (await this.authenticationService.apis.bitbucket)?.getServerPullRequestForCommit(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, rev, this.apiBaseUrlFor(session));
93
+ getProviderPullRequestForCommitInBatch(session, repo, rev, cancellation) {
94
+ return this.readPullRequestForCommit(session, repo, rev, true, cancellation);
95
+ }
96
+ getProviderPullRequestForCommit(session, repo, rev) {
97
+ return this.readPullRequestForCommit(session, repo, rev, false);
98
+ }
99
+ async readPullRequestForCommit(session, repo, rev, deferFailure, cancellation) {
100
+ const api = await this.authenticationService.apis.bitbucket;
101
+ if (api == null) throw new IntegrationReadUnavailableError(this.name, "no client to read the pull requests of a commit");
102
+ return api.getServerPullRequestForCommit(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, rev, this.apiBaseUrlFor(session), { deferFailure }, cancellation);
95
103
  }
96
104
  async getProviderPullRequest(session, resource, id) {
97
105
  return (await this.authenticationService.apis.bitbucket)?.getServerPullRequest(this, toTokenWithInfo(this.id, session), resource.owner, resource.name, id, this.apiBaseUrlFor(session), { projection: "point" });
@@ -1 +1 @@
1
- {"version":3,"file":"bitbucket-server.js","names":[],"sources":["../../../../../plus/integrations/src/providers/bitbucket-server.ts"],"sourcesContent":["import 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\tPullRequestSearchCriteria,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { GitRemote } from '@gitlens/git/models/remote.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport { CancellationError, raceWithSignal } from '@gitlens/utils/cancellation.js';\nimport { md5 } from '@gitlens/utils/crypto.js';\nimport type { Emitter } from '@gitlens/utils/event.js';\nimport type { PagedResult } from '@gitlens/utils/paging.js';\nimport { mapSettledBounded, nonnullSettled } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';\nimport type {\n\tAuthenticationSessionLike as AuthenticationSession,\n\tProviderAuthenticationSession,\n} from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { GitSelfManagedHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport type { ResponseHeaders } from '../errors.js';\nimport { AuthenticationError, getAuthenticatedUser } from '../errors.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport type { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from '../models/gitHostIntegration.js';\nimport { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { IntegrationKey, ProviderPullRequestCount, ProviderPullRequestSearchPage } from '../models/integration.js';\nimport type { BitbucketServerSearchUser } from './bitbucket-server/pullRequestSearch.js';\nimport { getBitbucketServerPullRequestIdentityFromMaybeUrl } from './bitbucket/bitbucket.utils.js';\nimport type { BitbucketRepositoryDescriptor } from './bitbucket/models.js';\nimport type {\n\tProviderHierarchyResult,\n\tProviderOrganization,\n\tProviderPullRequest,\n\tProviderRepoInput,\n\tProviderRepository,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tproviderPullRequestMatchesSearch,\n\tProviderPullRequestReviewState,\n\tprovidersMetadata,\n\tPullRequestFilter,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport type { ProvidersApi } from './providersApi.js';\nimport {\n\tcollectProviderPagedResult,\n\tflatSettledOrThrow,\n\tparsePageCursor,\n\ttoPageCursor,\n} from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[GitSelfManagedHostIntegrationId.BitbucketServer];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\n\nexport class BitbucketServerIntegration extends GitHostIntegration<\n\tGitSelfManagedHostIntegrationId.BitbucketServer,\n\tBitbucketRepositoryDescriptor\n> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = GitSelfManagedHostIntegrationId.BitbucketServer;\n\tprotected readonly key =\n\t\t`${this.id}:${this.domain}` satisfies IntegrationKey<GitSelfManagedHostIntegrationId.BitbucketServer>;\n\treadonly name: string = 'Bitbucket Data Center';\n\n\tconstructor(\n\t\tctx: IntegrationServiceContext,\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tgetProvidersApi: () => Promise<ProvidersApi>,\n\t\tdidChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t\tprivate readonly _domain: string,\n\t) {\n\t\tsuper(ctx, authenticationService, getProvidersApi, didChangeConnection);\n\t}\n\n\tget domain(): string {\n\t\treturn this._domain;\n\t}\n\n\tprotected apiBaseUrlFor(session: ProviderAuthenticationSession): string {\n\t\treturn this.getSelfManagedApiBaseUrl(session);\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\tbaseUrl: this.apiBaseUrlFor(session),\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)?.getServerAccountForCommit(\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.apiBaseUrlFor(session),\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\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t): Promise<DefaultBranch | undefined> {\n\t\treturn Promise.resolve(undefined);\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\tif (type === 'issue') {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequestById(\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.apiBaseUrlFor(session),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot:\n\t * provider-apis has no single pull request read for Bitbucket, so this uses our own.\n\t */\n\tprotected override async getProviderPullRequestsBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string } } | undefined,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, c =>\n\t\t\tapi.getServerPullRequest(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tc.owner,\n\t\t\t\tc.repo,\n\t\t\t\tString(c.number),\n\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t\t{\n\t\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\t\tdeferFailure: true,\n\t\t\t\t\tprojection: 'batch',\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently, through our own client: provider-apis' pull request list has\n\t * no source-branch filter. Serves only a branch in the base repository — the manager read refuses a `headOwner`\n\t * naming another owner here, since Bitbucket Data Center finds a branch's pull requests only through the\n\t * repository the branch lives in, and a fork's slug can't be derived from its owner.\n\t */\n\tprotected override async getProviderPullRequestsForBranches(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { owner: string; repo: string; project?: string; branch: string; headOwner?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string }; limit: number },\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<{ pullRequests: PullRequestShape[]; truncated: boolean }>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(targets, providerFanOutConcurrency, async t => {\n\t\t\tif (t.headOwner != null) {\n\t\t\t\tthrow new Error(`Bitbucket Data Center can't find ${t.branch}'s pull requests in a fork by its owner`);\n\t\t\t}\n\n\t\t\treturn api.getServerPullRequestsForBranch(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tt.owner,\n\t\t\t\tt.repo,\n\t\t\t\tt.branch,\n\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t\t{\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\tdeferFailure: true,\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\tprotected override async getProviderIssue(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_id: string,\n\t): Promise<Issue | undefined> {\n\t\treturn Promise.resolve(undefined);\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)?.getServerPullRequestForBranch(\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.apiBaseUrlFor(session),\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)?.getServerPullRequestForCommit(\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.apiBaseUrlFor(session),\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: BitbucketRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tresource.owner,\n\t\t\tresource.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ projection: 'point' },\n\t\t);\n\t}\n\n\tprotected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {\n\t\treturn getBitbucketServerPullRequestIdentityFromMaybeUrl(search, this.id);\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.resolveReadSessionOrThrow(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.apiBaseUrlFor(session),\n\t\t});\n\t}\n\n\tprotected override async getProviderRepositoryMetadata(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t/**\n\t * Accounts by {@link getAccountKey}. One integration serves every installation on its host, and installations\n\t * mounted at different context paths are different servers whose users differ, even under the same token.\n\t */\n\tprivate _accounts: Map<string, Account | undefined> | undefined;\n\n\t/** The installation the session's reads address, plus the credential — what decides whose account it is. */\n\tprivate getAccountKey(session: ProviderAuthenticationSession): string {\n\t\treturn `${this.apiBaseUrlFor(session)}\\n${session.accessToken}`;\n\t}\n\n\t/**\n\t * The account request the account cache would otherwise answer; see `IntegrationBase.validateCredential`. Needed\n\t * without any discovery cache: a repo-scoped pull request read fans out across its repositories in the SDK with\n\t * no request to the connection first, so a dead token comes back as one refused repository per request.\n\t *\n\t * A project access token never confirms: its bot user authenticates, but `/users` does not list it, so the SDK\n\t * cannot find the current user and the check proves nothing.\n\t */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api\n\t\t\t.getCurrentUser(toTokenWithInfo(this.id, session), { baseUrl: this.apiBaseUrlFor(session) })\n\t\t\t.catch((ex: unknown) => {\n\t\t\t\tif (!(ex instanceof AuthenticationError)) throw ex;\n\n\t\t\t\t// Bitbucket Data Center names the user it authenticated in `X-AUSERNAME`, and answers a dead token\n\t\t\t\t// exactly as it answers no credential: the same 401 and body, without that header. So a refusal that\n\t\t\t\t// names a user other than `anonymous`, or says the user holds no license, came from a credential that\n\t\t\t\t// authenticated, and proves nothing about the scopes' refusals.\n\t\t\t\tconst response = (ex.original as { response?: { headers?: ResponseHeaders } } | undefined)?.response;\n\t\t\t\tconst user = getAuthenticatedUser(response?.headers);\n\t\t\t\tif (\n\t\t\t\t\t(user != null && user !== 'anonymous') ||\n\t\t\t\t\t/not (?:a|currently) licensed/i.test(ex.original?.message ?? '')\n\t\t\t\t) {\n\t\t\t\t\tthrow new Error('Bitbucket Data Center could not confirm the credential', { cause: ex });\n\t\t\t\t}\n\t\t\t\tthrow ex;\n\t\t\t});\n\t\tif (user == null) {\n\t\t\tthrow new Error('Bitbucket Data Center did not confirm the credential');\n\t\t}\n\t}\n\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst key = this.getAccountKey(session);\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\n\t\tconst cachedAccount = this._accounts.get(key);\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\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t});\n\t\t\tthis._accounts.set(\n\t\t\t\tkey,\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(key);\n\t}\n\n\tprotected override async getProviderOrganizationsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderOrganization>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerProjects(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\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>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerRepositories(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\n\t\t\t{\n\t\t\t\tproject: org,\n\t\t\t\tcursor: options?.cursor,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderRepositoriesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerRepositories(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\n\t\t\toptions,\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 api = await this.getProvidersApi();\n\t\tif (!api) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst prs = await api.getBitbucketServerPullRequestsForCurrentUser(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ states: toProviderPullRequestStates(options?.state) },\n\t\t);\n\t\treturn prs?.data.map(pr => fromProviderPullRequest(pr, this, { projection: 'search' }));\n\t}\n\n\tprotected override async getProviderMyPullRequestsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { state?: PullRequestStateFilter[]; cursor?: string; filters?: PullRequestFilter[] },\n\t): Promise<PagedResult<ProviderPullRequest> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst states = toProviderPullRequestStates(options?.state);\n\t\t// provider-apis translates the public 1-based `page` to Bitbucket Server's `start` offset and normalizes\n\t\t// `nextPageStart` back to the next page number. Thread that number inside our opaque cursor so the\n\t\t// ProviderBackend sweep drives the drain (bounded by its maxPages).\n\t\tconst page = parsePageCursor(options?.cursor);\n\t\tconst result = await api.getBitbucketServerPullRequestsForCurrentUser(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ states: states, page: page },\n\t\t);\n\t\tif (result == null) return undefined;\n\n\t\tconst account = options?.filters?.length ? await this.getProviderCurrentAccount(session) : undefined;\n\t\tconst identifiers = new Set([account?.id, account?.username].filter((id): id is string => id != null));\n\t\tif (options?.filters?.length && identifiers.size === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t'Unable to resolve the current Bitbucket Data Center account for the requested pull request filters.',\n\t\t\t);\n\t\t}\n\n\t\tconst values = options?.filters?.length\n\t\t\t? result.data.filter(pr => {\n\t\t\t\t\tconst isCurrentUser = (user: { id?: string | null; username?: string | null } | null | undefined) =>\n\t\t\t\t\t\tuser != null &&\n\t\t\t\t\t\t((user.id != null && identifiers.has(user.id)) ||\n\t\t\t\t\t\t\t(user.username != null && identifiers.has(user.username)));\n\t\t\t\t\tconst isAuthor = isCurrentUser(pr.author);\n\t\t\t\t\tconst isRequestedReviewer = pr.reviews?.some(\n\t\t\t\t\t\treview =>\n\t\t\t\t\t\t\tisCurrentUser(review.reviewer) &&\n\t\t\t\t\t\t\treview.state === ProviderPullRequestReviewState.ReviewRequested,\n\t\t\t\t\t);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(options.filters!.includes(PullRequestFilter.Author) && isAuthor) ||\n\t\t\t\t\t\t(options.filters!.includes(PullRequestFilter.ReviewRequested) && isRequestedReviewer)\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t: result.data;\n\n\t\treturn {\n\t\t\tvalues: values,\n\t\t\tpaging: {\n\t\t\t\tmore: result.hasMore,\n\t\t\t\tcursor: result.hasMore && result.nextPage != null ? toPageCursor(result.nextPage) : '{}',\n\t\t\t},\n\t\t};\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 repoInputs =\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 (repoInputs.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\trepoInputs.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\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\t\t\tcursor: cursor,\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\n\t\t\t.filter(pr => providerPullRequestMatchesSearch(pr, searchQuery))\n\t\t\t.map(pr => fromProviderPullRequest(pr, this, { projection: 'text-search' }));\n\t}\n\n\t/**\n\t * The filtered pull-request search, read by this module's own requests rather than the SDK's: the SDK's list\n\t * reads carry no text, draft or participant-status filter and no per-facet continuation. Every request goes to\n\t * the session's own address, context path included, so one connection's cursor can't be replayed on another.\n\t */\n\tprotected override async searchProviderPullRequestsPage(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: {\n\t\t\trepos?: ProviderRepoInput[];\n\t\t\torg?: string;\n\t\t\tcriteria?: PullRequestSearchCriteria;\n\t\t\tcursor?: string;\n\t\t\tpageSize?: number;\n\t\t\tsummary?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderPullRequestSearchPage | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.searchBitbucketServerPullRequestsPage(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\tconnectionId: session.id,\n\t\t\t\tprovider: this,\n\t\t\t\trepos: options.repos,\n\t\t\t\torg: options.org,\n\t\t\t\tcriteria: options.criteria,\n\t\t\t\tcurrentUser: await this.getSearchUser(session, options.criteria, cancellation),\n\t\t\t\tcursor: options.cursor,\n\t\t\t\tpageSize: options.pageSize,\n\t\t\t\tprojection: options.summary ? 'search-summary' : 'search',\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * Counts each scope by reading it, since Bitbucket Data Center has neither a count query nor a total on its\n\t * pages. The facade hands over one scope per call and runs those calls concurrently (see `countPullRequests`),\n\t * so scopes here are counted one after another rather than multiplying that concurrency.\n\t */\n\tprotected override async countProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tscopes: readonly { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria }[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderPullRequestCount[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst token = toTokenWithInfo(this.id, session);\n\t\tconst counts: ProviderPullRequestCount[] = [];\n\t\tfor (const scope of scopes) {\n\t\t\tcounts.push(\n\t\t\t\tawait api.countBitbucketServerPullRequests(\n\t\t\t\t\ttoken,\n\t\t\t\t\t{\n\t\t\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\t\t\trepos: scope.repos,\n\t\t\t\t\t\torg: scope.org,\n\t\t\t\t\t\tcriteria: scope.criteria,\n\t\t\t\t\t\tcurrentUser: await this.getSearchUser(session, scope.criteria, cancellation),\n\t\t\t\t\t},\n\t\t\t\t\tcancellation,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn counts;\n\t}\n\n\t/**\n\t * The session's own user, which a relationship facet filters by. Resolved per session rather than from the\n\t * primary connection, so a read pinned to one account never filters by another's identity; an account that\n\t * can't be resolved refuses the read instead of widening it to everyone's pull requests.\n\t *\n\t * The lookup is raced against `cancellation` so a cancelled read settles at once. The SDK's current-user read\n\t * takes no signal, so the request itself runs on; its answer still lands in the per-token account cache, so a\n\t * cold lookup a cancellation abandoned isn't wasted on the next read.\n\t */\n\tprivate async getSearchUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcriteria: PullRequestSearchCriteria | undefined,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<BitbucketServerSearchUser | undefined> {\n\t\tif (!criteria?.relationships?.length) return undefined;\n\n\t\tconst lookup = this.getProviderCurrentAccount(session);\n\t\tconst account = await (cancellation != null ? raceWithSignal(lookup, cancellation) : lookup);\n\t\tif (account?.id == null || account.username == null) {\n\t\t\tthrow new Error('Unable to resolve the current Bitbucket Data Center account for a relationship search.');\n\t\t}\n\n\t\treturn { id: account.id, username: account.username };\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 so the Bitbucket Server `scm/<project>/<repo>` prefix is\n\t\t\t\t// stripped; a raw `path.split('/')` would yield namespace=`scm`, name=`<project>`.\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\t_session: AuthenticationSession,\n\t\t_repos?: BitbucketRepositoryDescriptor[],\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t/**\n\t * Bitbucket Data Center exposes no issue tracker at all (issues live in Jira), so — like Bitbucket Cloud,\n\t * whose own tracker is deprecated — it is not an issue provider on the ProviderBackend surface. Without this\n\t * the facade would take `supportsIssues`' default `true` and route the read to a provider that registers no\n\t * issue client: the repo-scoped path fails with the SDK's `does not support function: getIssuesForReposFn`\n\t * as an opaque `kind: 'other'` warning, and `broadenIssues` first drains every repo of the org before hitting\n\t * the same failure. Its metadata already declares no issue filters, so this keeps both halves of the\n\t * capability answer consistent.\n\t */\n\toverride get supportsIssues(): boolean {\n\t\treturn false;\n\t}\n\n\tprivate readonly storagePrefix = 'bitbucket-server';\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tif (this._session == null) return;\n\n\t\tconst accountKey = this.getAccountKey(this._session);\n\t\tconst accountStorageKey = md5(accountKey);\n\n\t\tconst storedAccount = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:account`);\n\n\t\tlet account: Account | undefined = storedAccount?.data ? { ...storedAccount.data, provider: this } : undefined;\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(accountKey, account);\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._accounts = undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA6DA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAE/E,IAAa,6BAAb,cAAgD,mBAG9C;CAYiB;CAXlB,eAAqE;CACrE,KAAS;CACT,MACC,GAAG,KAAK,GAAG,GAAG,KAAK;CACpB,OAAwB;CAExB,YACC,KACA,uBACA,iBACA,qBACA,SACC;EACD,MAAM,KAAK,uBAAuB,iBAAiB,mBAAmB;EAFrD,KAAA,UAAA;CAGlB;CAEA,IAAI,SAAiB;EACpB,OAAO,KAAK;CACb;CAEA,cAAwB,SAAgD;EACvE,OAAO,KAAK,yBAAyB,OAAO;CAC7C;CAEA,MAAyB,yBACxB,SACA,IACA,SAGm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AK,cAAc,KAAK,QAAQ;EACnD,MAAM,oBAAoB,IAAI,UAAU;EAExC,MAAM,gBAAgB,KAAK,IAAI,QAAQ,IAAI,GAAG,KAAK,cAAc,GAAG,kBAAkB,SAAS;EAE/F,IAAI,UAA+B,eAAe,OAAO;GAAE,GAAG,cAAc;GAAM,UAAU;EAAK,IAAI,KAAA;EAErG,IAAI,iBAAiB,MAAM;GAC1B,UAAU,MAAM,KAAK,0BAA0B,KAAK,QAAQ;GAC5D,IAAI,WAAW,MAAM;IAEpB,MAAM,KAAK,IAAI,QAAQ,iBAAiB,KAAK,aAAa;IAC1D,MAAM,KAAK,IAAI,QAAQ,MAAM,GAAG,KAAK,cAAc,GAAG,kBAAkB,WAAW;KAClF,GAAG;KACH,WAAW,KAAK,IAAI;KACpB,MAAM;MACL,IAAI,QAAQ;MACZ,MAAM,QAAQ;MACd,OAAO,QAAQ;MACf,WAAW,QAAQ;MACnB,UAAU,QAAQ;KACnB;IACD,CAAC;GACF;EACD;EACA,KAAK,8BAAc,IAAI,IAAiC;EACxD,KAAK,UAAU,IAAI,YAAY,OAAO;CACvC;CAEA,uBAAgD;EAC/C,KAAK,YAAY,KAAA;CAClB;AACD"}
1
+ {"version":3,"file":"bitbucket-server.js","names":[],"sources":["../../../../../plus/integrations/src/providers/bitbucket-server.ts"],"sourcesContent":["import 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\tPullRequestSearchCriteria,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { GitRemote } from '@gitlens/git/models/remote.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport { CancellationError, raceWithSignal } from '@gitlens/utils/cancellation.js';\nimport { md5 } from '@gitlens/utils/crypto.js';\nimport type { Emitter } from '@gitlens/utils/event.js';\nimport type { PagedResult } from '@gitlens/utils/paging.js';\nimport { mapSettledBounded, nonnullSettled } from '@gitlens/utils/promise.js';\nimport type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider.js';\nimport type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';\nimport type {\n\tAuthenticationSessionLike as AuthenticationSession,\n\tProviderAuthenticationSession,\n} from '../authentication/models.js';\nimport { toTokenWithInfo } from '../authentication/models.js';\nimport { GitSelfManagedHostIntegrationId, providerFanOutConcurrency } from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport type { ResponseHeaders } from '../errors.js';\nimport { AuthenticationError, getAuthenticatedUser, IntegrationReadUnavailableError } from '../errors.js';\nimport type { IntegrationConnectionChangeEvent } from '../integrationService.js';\nimport type { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from '../models/gitHostIntegration.js';\nimport { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { IntegrationKey, ProviderPullRequestCount, ProviderPullRequestSearchPage } from '../models/integration.js';\nimport type { BitbucketServerSearchUser } from './bitbucket-server/pullRequestSearch.js';\nimport { getBitbucketServerPullRequestIdentityFromMaybeUrl } from './bitbucket/bitbucket.utils.js';\nimport type { BitbucketRepositoryDescriptor } from './bitbucket/models.js';\nimport type {\n\tProviderHierarchyResult,\n\tProviderOrganization,\n\tProviderPullRequest,\n\tProviderRepoInput,\n\tProviderRepository,\n} from './models.js';\nimport {\n\tfromProviderPullRequest,\n\tproviderPullRequestMatchesSearch,\n\tProviderPullRequestReviewState,\n\tprovidersMetadata,\n\tPullRequestFilter,\n\ttoProviderPullRequestStates,\n} from './models.js';\nimport type { ProvidersApi } from './providersApi.js';\nimport {\n\tcollectProviderPagedResult,\n\tflatSettledOrThrow,\n\tparsePageCursor,\n\ttoPageCursor,\n} from './utils/providerPaging.js';\n\nconst metadata = providersMetadata[GitSelfManagedHostIntegrationId.BitbucketServer];\nconst authProvider = Object.freeze({ id: metadata.id, scopes: metadata.scopes });\n\nexport class BitbucketServerIntegration extends GitHostIntegration<\n\tGitSelfManagedHostIntegrationId.BitbucketServer,\n\tBitbucketRepositoryDescriptor\n> {\n\treadonly authProvider: IntegrationAuthenticationProviderDescriptor = authProvider;\n\treadonly id = GitSelfManagedHostIntegrationId.BitbucketServer;\n\tprotected readonly key =\n\t\t`${this.id}:${this.domain}` satisfies IntegrationKey<GitSelfManagedHostIntegrationId.BitbucketServer>;\n\treadonly name: string = 'Bitbucket Data Center';\n\n\tconstructor(\n\t\tctx: IntegrationServiceContext,\n\t\tauthenticationService: IntegrationAuthenticationService,\n\t\tgetProvidersApi: () => Promise<ProvidersApi>,\n\t\tdidChangeConnection: Emitter<IntegrationConnectionChangeEvent>,\n\t\tprivate readonly _domain: string,\n\t) {\n\t\tsuper(ctx, authenticationService, getProvidersApi, didChangeConnection);\n\t}\n\n\tget domain(): string {\n\t\treturn this._domain;\n\t}\n\n\tprotected apiBaseUrlFor(session: ProviderAuthenticationSession): string {\n\t\treturn this.getSelfManagedApiBaseUrl(session);\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\tbaseUrl: this.apiBaseUrlFor(session),\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)?.getServerAccountForCommit(\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.apiBaseUrlFor(session),\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\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t): Promise<DefaultBranch | undefined> {\n\t\treturn Promise.resolve(undefined);\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\tif (type === 'issue') {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequestById(\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.apiBaseUrlFor(session),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently so one target's failure rejects only its own slot:\n\t * provider-apis has no single pull request read for Bitbucket, so this uses our own.\n\t */\n\tprotected override async getProviderPullRequestsBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcoordinates: readonly { owner: string; repo: string; number: number; project?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string } } | undefined,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(coordinates, providerFanOutConcurrency, c =>\n\t\t\tapi.getServerPullRequest(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tc.owner,\n\t\t\t\tc.repo,\n\t\t\t\tString(c.number),\n\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t\t{\n\t\t\t\t\tcurrentAccount: options?.currentAccount,\n\t\t\t\t\tdeferFailure: true,\n\t\t\t\t\tprojection: 'batch',\n\t\t\t\t},\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * One request per target, settled independently, through our own client: provider-apis' pull request list has\n\t * no source-branch filter. Serves only a branch in the base repository — the manager read refuses a `headOwner`\n\t * naming another owner here, since Bitbucket Data Center finds a branch's pull requests only through the\n\t * repository the branch lives in, and a fork's slug can't be derived from its owner.\n\t */\n\tprotected override async getProviderPullRequestsForBranches(\n\t\tsession: ProviderAuthenticationSession,\n\t\ttargets: readonly { owner: string; repo: string; project?: string; branch: string; headOwner?: string }[],\n\t\toptions: { currentAccount?: { id: string; username?: string }; limit: number },\n\t\t_cancellation?: AbortSignal,\n\t): Promise<PromiseSettledResult<{ pullRequests: PullRequestShape[]; truncated: boolean }>[] | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) return undefined;\n\n\t\tconst tokenWithInfo = toTokenWithInfo(this.id, session);\n\t\treturn mapSettledBounded(targets, providerFanOutConcurrency, async t => {\n\t\t\tif (t.headOwner != null) {\n\t\t\t\tthrow new Error(`Bitbucket Data Center can't find ${t.branch}'s pull requests in a fork by its owner`);\n\t\t\t}\n\n\t\t\treturn api.getServerPullRequestsForBranch(\n\t\t\t\tthis,\n\t\t\t\ttokenWithInfo,\n\t\t\t\tt.owner,\n\t\t\t\tt.repo,\n\t\t\t\tt.branch,\n\t\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t\t{\n\t\t\t\t\tlimit: options.limit,\n\t\t\t\t\tcurrentAccount: options.currentAccount,\n\t\t\t\t\tdeferFailure: true,\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\tprotected override async getProviderIssue(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_id: string,\n\t): Promise<Issue | undefined> {\n\t\treturn Promise.resolve(undefined);\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)?.getServerPullRequestForBranch(\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.apiBaseUrlFor(session),\n\t\t);\n\t}\n\n\tprotected override getProviderPullRequestForCommitInBatch(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\treturn this.readPullRequestForCommit(session, repo, rev, true, cancellation);\n\t}\n\n\tprotected override getProviderPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn this.readPullRequestForCommit(session, repo, rev, false);\n\t}\n\n\tprivate async readPullRequestForCommit(\n\t\tsession: ProviderAuthenticationSession,\n\t\trepo: BitbucketRepositoryDescriptor,\n\t\trev: string,\n\t\tdeferFailure: boolean,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequest | undefined> {\n\t\tconst api = await this.authenticationService.apis.bitbucket;\n\t\tif (api == null) {\n\t\t\tthrow new IntegrationReadUnavailableError(this.name, 'no client to read the pull requests of a commit');\n\t\t}\n\n\t\treturn api.getServerPullRequestForCommit(\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.apiBaseUrlFor(session),\n\t\t\t{ deferFailure: deferFailure },\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\tprotected override async getProviderPullRequest(\n\t\tsession: ProviderAuthenticationSession,\n\t\tresource: BitbucketRepositoryDescriptor,\n\t\tid: string,\n\t): Promise<PullRequest | undefined> {\n\t\treturn (await this.authenticationService.apis.bitbucket)?.getServerPullRequest(\n\t\t\tthis,\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tresource.owner,\n\t\t\tresource.name,\n\t\t\tid,\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ projection: 'point' },\n\t\t);\n\t}\n\n\tprotected override getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined {\n\t\treturn getBitbucketServerPullRequestIdentityFromMaybeUrl(search, this.id);\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.resolveReadSessionOrThrow(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.apiBaseUrlFor(session),\n\t\t});\n\t}\n\n\tprotected override async getProviderRepositoryMetadata(\n\t\t_session: AuthenticationSession,\n\t\t_repo: BitbucketRepositoryDescriptor,\n\t\t_cancellation?: AbortSignal,\n\t): Promise<RepositoryMetadata | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t/**\n\t * Accounts by {@link getAccountKey}. One integration serves every installation on its host, and installations\n\t * mounted at different context paths are different servers whose users differ, even under the same token.\n\t */\n\tprivate _accounts: Map<string, Account | undefined> | undefined;\n\n\t/** The installation the session's reads address, plus the credential — what decides whose account it is. */\n\tprivate getAccountKey(session: ProviderAuthenticationSession): string {\n\t\treturn `${this.apiBaseUrlFor(session)}\\n${session.accessToken}`;\n\t}\n\n\t/**\n\t * The account request the account cache would otherwise answer; see `IntegrationBase.validateCredential`. Needed\n\t * without any discovery cache: a repo-scoped pull request read fans out across its repositories in the SDK with\n\t * no request to the connection first, so a dead token comes back as one refused repository per request.\n\t *\n\t * A project access token never confirms: its bot user authenticates, but `/users` does not list it, so the SDK\n\t * cannot find the current user and the check proves nothing.\n\t */\n\tprotected override async validateCredential(session: ProviderAuthenticationSession): Promise<void> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst user = await api\n\t\t\t.getCurrentUser(toTokenWithInfo(this.id, session), { baseUrl: this.apiBaseUrlFor(session) })\n\t\t\t.catch((ex: unknown) => {\n\t\t\t\tif (!(ex instanceof AuthenticationError)) throw ex;\n\n\t\t\t\t// Bitbucket Data Center names the user it authenticated in `X-AUSERNAME`, and answers a dead token\n\t\t\t\t// exactly as it answers no credential: the same 401 and body, without that header. So a refusal that\n\t\t\t\t// names a user other than `anonymous`, or says the user holds no license, came from a credential that\n\t\t\t\t// authenticated, and proves nothing about the scopes' refusals.\n\t\t\t\tconst response = (ex.original as { response?: { headers?: ResponseHeaders } } | undefined)?.response;\n\t\t\t\tconst user = getAuthenticatedUser(response?.headers);\n\t\t\t\tif (\n\t\t\t\t\t(user != null && user !== 'anonymous') ||\n\t\t\t\t\t/not (?:a|currently) licensed/i.test(ex.original?.message ?? '')\n\t\t\t\t) {\n\t\t\t\t\tthrow new Error('Bitbucket Data Center could not confirm the credential', { cause: ex });\n\t\t\t\t}\n\t\t\t\tthrow ex;\n\t\t\t});\n\t\tif (user == null) {\n\t\t\tthrow new Error('Bitbucket Data Center did not confirm the credential');\n\t\t}\n\t}\n\n\tprotected override async getProviderCurrentAccount(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<Account | undefined> {\n\t\tconst key = this.getAccountKey(session);\n\t\tthis._accounts ??= new Map<string, Account | undefined>();\n\n\t\tconst cachedAccount = this._accounts.get(key);\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\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t});\n\t\t\tthis._accounts.set(\n\t\t\t\tkey,\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(key);\n\t}\n\n\tprotected override async getProviderOrganizationsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t): Promise<ProviderHierarchyResult<ProviderOrganization>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerProjects(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\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>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerRepositories(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\n\t\t\t{\n\t\t\t\tproject: org,\n\t\t\t\tcursor: options?.cursor,\n\t\t\t},\n\t\t);\n\t}\n\n\tprotected override async getProviderRepositoriesForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { cursor?: string },\n\t): Promise<ProviderHierarchyResult<ProviderRepository>> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.getBitbucketServerRepositories(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\tsession.id,\n\t\t\toptions,\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 api = await this.getProvidersApi();\n\t\tif (!api) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst prs = await api.getBitbucketServerPullRequestsForCurrentUser(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ states: toProviderPullRequestStates(options?.state) },\n\t\t);\n\t\treturn prs?.data.map(pr => fromProviderPullRequest(pr, this, { projection: 'search' }));\n\t}\n\n\tprotected override async getProviderMyPullRequestsForUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions?: { state?: PullRequestStateFilter[]; cursor?: string; filters?: PullRequestFilter[] },\n\t): Promise<PagedResult<ProviderPullRequest> | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst states = toProviderPullRequestStates(options?.state);\n\t\t// provider-apis translates the public 1-based `page` to Bitbucket Server's `start` offset and normalizes\n\t\t// `nextPageStart` back to the next page number. Thread that number inside our opaque cursor so the\n\t\t// ProviderBackend sweep drives the drain (bounded by its maxPages).\n\t\tconst page = parsePageCursor(options?.cursor);\n\t\tconst result = await api.getBitbucketServerPullRequestsForCurrentUser(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\tthis.apiBaseUrlFor(session),\n\t\t\t{ states: states, page: page },\n\t\t);\n\t\tif (result == null) return undefined;\n\n\t\tconst account = options?.filters?.length ? await this.getProviderCurrentAccount(session) : undefined;\n\t\tconst identifiers = new Set([account?.id, account?.username].filter((id): id is string => id != null));\n\t\tif (options?.filters?.length && identifiers.size === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t'Unable to resolve the current Bitbucket Data Center account for the requested pull request filters.',\n\t\t\t);\n\t\t}\n\n\t\tconst values = options?.filters?.length\n\t\t\t? result.data.filter(pr => {\n\t\t\t\t\tconst isCurrentUser = (user: { id?: string | null; username?: string | null } | null | undefined) =>\n\t\t\t\t\t\tuser != null &&\n\t\t\t\t\t\t((user.id != null && identifiers.has(user.id)) ||\n\t\t\t\t\t\t\t(user.username != null && identifiers.has(user.username)));\n\t\t\t\t\tconst isAuthor = isCurrentUser(pr.author);\n\t\t\t\t\tconst isRequestedReviewer = pr.reviews?.some(\n\t\t\t\t\t\treview =>\n\t\t\t\t\t\t\tisCurrentUser(review.reviewer) &&\n\t\t\t\t\t\t\treview.state === ProviderPullRequestReviewState.ReviewRequested,\n\t\t\t\t\t);\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(options.filters!.includes(PullRequestFilter.Author) && isAuthor) ||\n\t\t\t\t\t\t(options.filters!.includes(PullRequestFilter.ReviewRequested) && isRequestedReviewer)\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t: result.data;\n\n\t\treturn {\n\t\t\tvalues: values,\n\t\t\tpaging: {\n\t\t\t\tmore: result.hasMore,\n\t\t\t\tcursor: result.hasMore && result.nextPage != null ? toPageCursor(result.nextPage) : '{}',\n\t\t\t},\n\t\t};\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 repoInputs =\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 (repoInputs.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\trepoInputs.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\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\t\t\tcursor: cursor,\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\n\t\t\t.filter(pr => providerPullRequestMatchesSearch(pr, searchQuery))\n\t\t\t.map(pr => fromProviderPullRequest(pr, this, { projection: 'text-search' }));\n\t}\n\n\t/**\n\t * The filtered pull-request search, read by this module's own requests rather than the SDK's: the SDK's list\n\t * reads carry no text, draft or participant-status filter and no per-facet continuation. Every request goes to\n\t * the session's own address, context path included, so one connection's cursor can't be replayed on another.\n\t */\n\tprotected override async searchProviderPullRequestsPage(\n\t\tsession: ProviderAuthenticationSession,\n\t\toptions: {\n\t\t\trepos?: ProviderRepoInput[];\n\t\t\torg?: string;\n\t\t\tcriteria?: PullRequestSearchCriteria;\n\t\t\tcursor?: string;\n\t\t\tpageSize?: number;\n\t\t\tsummary?: boolean;\n\t\t},\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderPullRequestSearchPage | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\treturn api.searchBitbucketServerPullRequestsPage(\n\t\t\ttoTokenWithInfo(this.id, session),\n\t\t\t{\n\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\tconnectionId: session.id,\n\t\t\t\tprovider: this,\n\t\t\t\trepos: options.repos,\n\t\t\t\torg: options.org,\n\t\t\t\tcriteria: options.criteria,\n\t\t\t\tcurrentUser: await this.getSearchUser(session, options.criteria, cancellation),\n\t\t\t\tcursor: options.cursor,\n\t\t\t\tpageSize: options.pageSize,\n\t\t\t\tprojection: options.summary ? 'search-summary' : 'search',\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\t}\n\n\t/**\n\t * Counts each scope by reading it, since Bitbucket Data Center has neither a count query nor a total on its\n\t * pages. The facade hands over one scope per call and runs those calls concurrently (see `countPullRequests`),\n\t * so scopes here are counted one after another rather than multiplying that concurrency.\n\t */\n\tprotected override async countProviderPullRequests(\n\t\tsession: ProviderAuthenticationSession,\n\t\tscopes: readonly { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria }[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<ProviderPullRequestCount[] | undefined> {\n\t\tconst api = await this.getProvidersApi();\n\t\tconst token = toTokenWithInfo(this.id, session);\n\t\tconst counts: ProviderPullRequestCount[] = [];\n\t\tfor (const scope of scopes) {\n\t\t\tcounts.push(\n\t\t\t\tawait api.countBitbucketServerPullRequests(\n\t\t\t\t\ttoken,\n\t\t\t\t\t{\n\t\t\t\t\t\tbaseUrl: this.apiBaseUrlFor(session),\n\t\t\t\t\t\trepos: scope.repos,\n\t\t\t\t\t\torg: scope.org,\n\t\t\t\t\t\tcriteria: scope.criteria,\n\t\t\t\t\t\tcurrentUser: await this.getSearchUser(session, scope.criteria, cancellation),\n\t\t\t\t\t},\n\t\t\t\t\tcancellation,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t\treturn counts;\n\t}\n\n\t/**\n\t * The session's own user, which a relationship facet filters by. Resolved per session rather than from the\n\t * primary connection, so a read pinned to one account never filters by another's identity; an account that\n\t * can't be resolved refuses the read instead of widening it to everyone's pull requests.\n\t *\n\t * The lookup is raced against `cancellation` so a cancelled read settles at once. The SDK's current-user read\n\t * takes no signal, so the request itself runs on; its answer still lands in the per-token account cache, so a\n\t * cold lookup a cancellation abandoned isn't wasted on the next read.\n\t */\n\tprivate async getSearchUser(\n\t\tsession: ProviderAuthenticationSession,\n\t\tcriteria: PullRequestSearchCriteria | undefined,\n\t\tcancellation: AbortSignal | undefined,\n\t): Promise<BitbucketServerSearchUser | undefined> {\n\t\tif (!criteria?.relationships?.length) return undefined;\n\n\t\tconst lookup = this.getProviderCurrentAccount(session);\n\t\tconst account = await (cancellation != null ? raceWithSignal(lookup, cancellation) : lookup);\n\t\tif (account?.id == null || account.username == null) {\n\t\t\tthrow new Error('Unable to resolve the current Bitbucket Data Center account for a relationship search.');\n\t\t}\n\n\t\treturn { id: account.id, username: account.username };\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 so the Bitbucket Server `scm/<project>/<repo>` prefix is\n\t\t\t\t// stripped; a raw `path.split('/')` would yield namespace=`scm`, name=`<project>`.\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\t_session: AuthenticationSession,\n\t\t_repos?: BitbucketRepositoryDescriptor[],\n\t): Promise<IssueShape[] | undefined> {\n\t\treturn Promise.resolve(undefined);\n\t}\n\n\t/**\n\t * Bitbucket Data Center exposes no issue tracker at all (issues live in Jira), so — like Bitbucket Cloud,\n\t * whose own tracker is deprecated — it is not an issue provider on the ProviderBackend surface. Without this\n\t * the facade would take `supportsIssues`' default `true` and route the read to a provider that registers no\n\t * issue client: the repo-scoped path fails with the SDK's `does not support function: getIssuesForReposFn`\n\t * as an opaque `kind: 'other'` warning, and `broadenIssues` first drains every repo of the org before hitting\n\t * the same failure. Its metadata already declares no issue filters, so this keeps both halves of the\n\t * capability answer consistent.\n\t */\n\toverride get supportsIssues(): boolean {\n\t\treturn false;\n\t}\n\n\tprivate readonly storagePrefix = 'bitbucket-server';\n\tprotected override async providerOnConnect(): Promise<void> {\n\t\tif (this._session == null) return;\n\n\t\tconst accountKey = this.getAccountKey(this._session);\n\t\tconst accountStorageKey = md5(accountKey);\n\n\t\tconst storedAccount = this.ctx.storage.get(`${this.storagePrefix}:${accountStorageKey}:account`);\n\n\t\tlet account: Account | undefined = storedAccount?.data ? { ...storedAccount.data, provider: this } : undefined;\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(accountKey, account);\n\t}\n\n\tprotected override providerOnDisconnect(): void {\n\t\tthis._accounts = undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AA6DA,MAAM,WAAW,kBAAA;AACjB,MAAM,eAAe,OAAO,OAAO;CAAE,IAAI,SAAS;CAAI,QAAQ,SAAS;AAAO,CAAC;AAE/E,IAAa,6BAAb,cAAgD,mBAG9C;CAYiB;CAXlB,eAAqE;CACrE,KAAS;CACT,MACC,GAAG,KAAK,GAAG,GAAG,KAAK;CACpB,OAAwB;CAExB,YACC,KACA,uBACA,iBACA,qBACA,SACC;EACD,MAAM,KAAK,uBAAuB,iBAAiB,mBAAmB;EAFrD,KAAA,UAAA;CAGlB;CAEA,IAAI,SAAiB;EACpB,OAAO,KAAK;CACb;CAEA,cAAwB,SAAgD;EACvE,OAAO,KAAK,yBAAyB,OAAO;CAC7C;CAEA,MAAyB,yBACxB,SACA,IACA,SAGmB;EAEnB,QAAO,MADW,KAAK,gBAAgB,EAAA,CAC5B,iBAAiB,gBAAgB,KAAK,IAAI,OAAO,GAAG,IAAI;GAClE,aAAa,SAAS;GACtB,SAAS,KAAK,cAAc,OAAO;EACpC,CAAC;CACF;CAEA,MAAyB,4BACxB,SACA,MACA,KACA,SAGoD;EACpD,QAAQ,MAAM,KAAK,sBAAsB,KAAK,UAAA,EAAY,0BACzD,MACA,gBAAgB,KAAK,IAAI,OAAO,GAChC,KAAK,OACL,KAAK,MACL,KACA,KAAK,cAAc,OAAO,GAC1B,EACC,YAAY,SAAS,WACtB,CAC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,QAAQ,IAAI,GAAG,KAAK,cAAc,GAAG,kBAAkB,SAAS;EAE/F,IAAI,UAA+B,eAAe,OAAO;GAAE,GAAG,cAAc;GAAM,UAAU;EAAK,IAAI,KAAA;EAErG,IAAI,iBAAiB,MAAM;GAC1B,UAAU,MAAM,KAAK,0BAA0B,KAAK,QAAQ;GAC5D,IAAI,WAAW,MAAM;IAEpB,MAAM,KAAK,IAAI,QAAQ,iBAAiB,KAAK,aAAa;IAC1D,MAAM,KAAK,IAAI,QAAQ,MAAM,GAAG,KAAK,cAAc,GAAG,kBAAkB,WAAW;KAClF,GAAG;KACH,WAAW,KAAK,IAAI;KACpB,MAAM;MACL,IAAI,QAAQ;MACZ,MAAM,QAAQ;MACd,OAAO,QAAQ;MACf,WAAW,QAAQ;MACnB,UAAU,QAAQ;KACnB;IACD,CAAC;GACF;EACD;EACA,KAAK,8BAAc,IAAI,IAAiC;EACxD,KAAK,UAAU,IAAI,YAAY,OAAO;CACvC;CAEA,uBAAgD;EAC/C,KAAK,YAAY,KAAA;CAClB;AACD"}
@@ -101,7 +101,21 @@ export declare class BitbucketIntegration extends GitHostIntegration<GitCloudHos
101
101
  avatarSize?: number;
102
102
  include?: IssueOrPullRequestState[];
103
103
  }): Promise<PullRequest | undefined>;
104
+ protected getProviderPullRequestsForCommits(session: ProviderAuthenticationSession, repo: {
105
+ owner: string;
106
+ repo: string;
107
+ project?: string;
108
+ }, shas: readonly string[], options: {
109
+ mergeQueue?: boolean;
110
+ }, cancellation?: AbortSignal): Promise<PromiseSettledResult<PullRequestShape | undefined>[] | undefined>;
111
+ protected getCommitLookupBackoff(ex: unknown): {
112
+ scope: 'repository' | 'commit';
113
+ until?: number;
114
+ } | undefined;
115
+ protected stopsCommitFanOut(reason: unknown, answered: boolean): boolean;
116
+ protected getProviderPullRequestForCommitInBatch(session: ProviderAuthenticationSession, repo: BitbucketRepositoryDescriptor, rev: string, cancellation?: AbortSignal): Promise<PullRequest | undefined>;
104
117
  protected getProviderPullRequestForCommit(session: ProviderAuthenticationSession, repo: BitbucketRepositoryDescriptor, rev: string): Promise<PullRequest | undefined>;
118
+ private readPullRequestForCommit;
105
119
  protected getProviderPullRequest(session: ProviderAuthenticationSession, resource: BitbucketRepositoryDescriptor, id: string): Promise<PullRequest | undefined>;
106
120
  protected getProviderPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined;
107
121
  protected getProviderRepositoryMetadata(session: ProviderAuthenticationSession, repo: BitbucketRepositoryDescriptor, cancellation?: AbortSignal): Promise<RepositoryMetadata | undefined>;
@@ -10,6 +10,7 @@ import { collectProviderPagedResult, flatSettledOrThrow, mergeCollectionMetadata
10
10
  import { fromProviderPullRequest, getProviderPullRequestIdentity, providersMetadata, toProviderPullRequestStates } from "./models.js";
11
11
  import { toTokenWithInfo } from "../authentication/models.js";
12
12
  import { toBitbucketPullRequestEtagFields } from "./bitbucket/models.js";
13
+ import { BitbucketCommitLinksAppMissingError, BitbucketCommitNotFoundError, BitbucketCommitPullRequestsUnindexedError } from "./bitbucket/bitbucket.js";
13
14
  import { GitHostIntegration } from "../models/gitHostIntegration.js";
14
15
  import { getBitbucketPullRequestIdentityFromMaybeUrl } from "./bitbucket/bitbucket.utils.js";
15
16
  //#region ../plus/integrations/src/providers/bitbucket.ts
@@ -106,8 +107,35 @@ var BitbucketIntegration = class extends GitHostIntegration {
106
107
  async getProviderPullRequestForBranch(session, repo, branch, _options) {
107
108
  return (await this.authenticationService.apis.bitbucket)?.getPullRequestForBranch(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, branch, this.apiBaseUrl);
108
109
  }
109
- async getProviderPullRequestForCommit(session, repo, rev) {
110
- return (await this.authenticationService.apis.bitbucket)?.getPullRequestForCommit(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, rev, this.apiBaseUrl);
110
+ async getProviderPullRequestsForCommits(session, repo, shas, options, cancellation) {
111
+ const slots = await super.getProviderPullRequestsForCommits(session, repo, shas, options, cancellation);
112
+ if (slots == null) return void 0;
113
+ const api = await this.authenticationService.apis.bitbucket;
114
+ const missing = slots.find((slot) => slot.status === "rejected" && slot.reason instanceof BitbucketCommitLinksAppMissingError);
115
+ if (missing != null) api?.notifyCommitLinksAppMissing(repo.owner, missing.reason.commitUrl);
116
+ if (!(slots.some((slot) => slot.status === "fulfilled") || api?.isRepositoryIndexed(toTokenWithInfo(this.id, session), repo.owner, repo.repo) === true)) return slots;
117
+ return slots.map((slot) => slot.status === "rejected" && slot.reason instanceof BitbucketCommitNotFoundError ? {
118
+ status: "fulfilled",
119
+ value: void 0
120
+ } : slot);
121
+ }
122
+ getCommitLookupBackoff(ex) {
123
+ if (ex instanceof BitbucketCommitLinksAppMissingError || ex instanceof BitbucketCommitPullRequestsUnindexedError) return { scope: "repository" };
124
+ return super.getCommitLookupBackoff(ex);
125
+ }
126
+ stopsCommitFanOut(reason, answered) {
127
+ return reason instanceof BitbucketCommitLinksAppMissingError || reason instanceof BitbucketCommitPullRequestsUnindexedError || super.stopsCommitFanOut(reason, answered);
128
+ }
129
+ getProviderPullRequestForCommitInBatch(session, repo, rev, cancellation) {
130
+ return this.readPullRequestForCommit(session, repo, rev, true, cancellation);
131
+ }
132
+ getProviderPullRequestForCommit(session, repo, rev) {
133
+ return this.readPullRequestForCommit(session, repo, rev, false);
134
+ }
135
+ async readPullRequestForCommit(session, repo, rev, deferFailure, cancellation) {
136
+ const api = await this.authenticationService.apis.bitbucket;
137
+ if (api == null) throw new IntegrationReadUnavailableError(this.name, "no client to read the pull requests of a commit");
138
+ return api.getPullRequestForCommit(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, rev, this.apiBaseUrl, { deferFailure }, cancellation);
111
139
  }
112
140
  async getProviderPullRequest(session, resource, id) {
113
141
  return (await this.authenticationService.apis.bitbucket)?.getPullRequest(this, toTokenWithInfo(this.id, session), resource.owner, resource.name, id, this.apiBaseUrl, { projection: "point" });