1- import { RepositoryAccessLevel } from '../../../../git/models/issue' ;
1+ import type { IssueRepository } from '../../../../git/models/issue' ;
2+ import { Issue , RepositoryAccessLevel } from '../../../../git/models/issue' ;
23import type { IssueOrPullRequestState } from '../../../../git/models/issueOrPullRequest' ;
34import type { PullRequestMember , PullRequestReviewer } from '../../../../git/models/pullRequest' ;
45import { PullRequest , PullRequestReviewDecision , PullRequestReviewState } from '../../../../git/models/pullRequest' ;
@@ -199,6 +200,12 @@ export interface BitbucketIssue {
199200 created_on : string ;
200201 updated_on : string ;
201202 repository : BitbucketRepository ;
203+ votes ?: number ;
204+ content : {
205+ raw : string ;
206+ markup : string ;
207+ html : string ;
208+ } ;
202209 links : {
203210 self : BitbucketLink ;
204211 html : BitbucketLink ;
@@ -243,6 +250,10 @@ export function isClosedBitbucketPullRequestState(state: BitbucketPullRequestSta
243250 return bitbucketPullRequestStateToState ( state ) !== 'opened' ;
244251}
245252
253+ export function isClosedBitbucketIssueState ( state : BitbucketIssueState ) : boolean {
254+ return bitbucketIssueStateToState ( state ) !== 'opened' ;
255+ }
256+
246257export function fromBitbucketUser ( user : BitbucketUser ) : PullRequestMember {
247258 return {
248259 avatarUrl : user . links . avatar . href ,
@@ -298,6 +309,46 @@ function getBitbucketReviewDecision(pr: BitbucketPullRequest): PullRequestReview
298309 return PullRequestReviewDecision . ReviewRequired ; // nobody has reviewed yet.
299310}
300311
312+ function fromBitbucketRepository ( repo : BitbucketRepository ) : IssueRepository {
313+ return {
314+ owner : repo . full_name . split ( '/' ) [ 0 ] ,
315+ repo : repo . name ,
316+ id : repo . uuid ,
317+ // TODO: Remove this assumption once actual access level is available
318+ accessLevel : RepositoryAccessLevel . Write ,
319+ } ;
320+ }
321+
322+ export function fromBitbucketIssue ( issue : BitbucketIssue , provider : Provider ) : Issue {
323+ return new Issue (
324+ provider ,
325+ issue . id . toString ( ) ,
326+ issue . id . toString ( ) ,
327+ issue . title ,
328+ issue . links . html . href ,
329+ new Date ( issue . created_on ) ,
330+ new Date ( issue . updated_on ) ,
331+ isClosedBitbucketIssueState ( issue . state ) ,
332+ bitbucketIssueStateToState ( issue . state ) ,
333+ fromBitbucketUser ( issue . reporter ) ,
334+ issue . assignee ? [ fromBitbucketUser ( issue . assignee ) ] : [ ] ,
335+ fromBitbucketRepository ( issue . repository ) ,
336+ undefined , // closedDate
337+ undefined , // labels
338+ undefined , // commentsCount
339+ issue . votes , // thumbsUpCount
340+ issue . content . html , // body
341+ ! issue . repository ?. project
342+ ? undefined
343+ : {
344+ id : issue . repository . project . uuid ,
345+ name : issue . repository . project . name ,
346+ resourceId : issue . repository . project . uuid ,
347+ resourceName : issue . repository . project . name ,
348+ } ,
349+ ) ;
350+ }
351+
301352export function fromBitbucketPullRequest ( pr : BitbucketPullRequest , provider : Provider ) : PullRequest {
302353 return new PullRequest (
303354 provider ,
@@ -306,13 +357,7 @@ export function fromBitbucketPullRequest(pr: BitbucketPullRequest, provider: Pro
306357 pr . id . toString ( ) ,
307358 pr . title ,
308359 pr . links . html . href ,
309- {
310- owner : pr . destination . repository . full_name . split ( '/' ) [ 0 ] ,
311- repo : pr . destination . repository . name ,
312- id : pr . destination . repository . uuid ,
313- // TODO: Remove this assumption once actual access level is available
314- accessLevel : RepositoryAccessLevel . Write ,
315- } ,
360+ fromBitbucketRepository ( pr . destination . repository ) ,
316361 bitbucketPullRequestStateToState ( pr . state ) ,
317362 new Date ( pr . created_on ) ,
318363 new Date ( pr . updated_on ) ,
0 commit comments