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' ;
@@ -191,6 +192,12 @@ export interface BitbucketIssue {
191192 created_on : string ;
192193 updated_on : string ;
193194 repository : BitbucketRepository ;
195+ votes ?: number ;
196+ content : {
197+ raw : string ;
198+ markup : string ;
199+ html : string ;
200+ } ;
194201 links : {
195202 self : BitbucketLink ;
196203 html : BitbucketLink ;
@@ -235,6 +242,10 @@ export function isClosedBitbucketPullRequestState(state: BitbucketPullRequestSta
235242 return bitbucketPullRequestStateToState ( state ) !== 'opened' ;
236243}
237244
245+ export function isClosedBitbucketIssueState ( state : BitbucketIssueState ) : boolean {
246+ return bitbucketIssueStateToState ( state ) !== 'opened' ;
247+ }
248+
238249export function fromBitbucketUser ( user : BitbucketUser ) : PullRequestMember {
239250 return {
240251 avatarUrl : user . links . avatar . href ,
@@ -290,6 +301,46 @@ function getBitbucketReviewDecision(pr: BitbucketPullRequest): PullRequestReview
290301 return PullRequestReviewDecision . ReviewRequired ; // nobody has reviewed yet.
291302}
292303
304+ function fromBitbucketRepository ( repo : BitbucketRepository ) : IssueRepository {
305+ return {
306+ owner : repo . full_name . split ( '/' ) [ 0 ] ,
307+ repo : repo . name ,
308+ id : repo . uuid ,
309+ // TODO: Remove this assumption once actual access level is available
310+ accessLevel : RepositoryAccessLevel . Write ,
311+ } ;
312+ }
313+
314+ export function fromBitbucketIssue ( issue : BitbucketIssue , provider : Provider ) : Issue {
315+ return new Issue (
316+ provider ,
317+ issue . id . toString ( ) ,
318+ issue . id . toString ( ) ,
319+ issue . title ,
320+ issue . links . html . href ,
321+ new Date ( issue . created_on ) ,
322+ new Date ( issue . updated_on ) ,
323+ isClosedBitbucketIssueState ( issue . state ) ,
324+ bitbucketIssueStateToState ( issue . state ) ,
325+ fromBitbucketUser ( issue . reporter ) ,
326+ issue . assignee ? [ fromBitbucketUser ( issue . assignee ) ] : [ ] ,
327+ fromBitbucketRepository ( issue . repository ) ,
328+ undefined , // closedDate
329+ undefined , // labels
330+ undefined , // commentsCount
331+ issue . votes , // thumbsUpCount
332+ issue . content . html , // body
333+ ! issue . repository ?. project
334+ ? undefined
335+ : {
336+ id : issue . repository . project . uuid ,
337+ name : issue . repository . project . name ,
338+ resourceId : issue . repository . project . uuid ,
339+ resourceName : issue . repository . project . name ,
340+ } ,
341+ ) ;
342+ }
343+
293344export function fromBitbucketPullRequest ( pr : BitbucketPullRequest , provider : Provider ) : PullRequest {
294345 return new PullRequest (
295346 provider ,
@@ -298,13 +349,7 @@ export function fromBitbucketPullRequest(pr: BitbucketPullRequest, provider: Pro
298349 pr . id . toString ( ) ,
299350 pr . title ,
300351 pr . links . html . href ,
301- {
302- owner : pr . destination . repository . full_name . split ( '/' ) [ 0 ] ,
303- repo : pr . destination . repository . name ,
304- id : pr . destination . repository . uuid ,
305- // TODO: Remove this assumption once actual access level is available
306- accessLevel : RepositoryAccessLevel . Write ,
307- } ,
352+ fromBitbucketRepository ( pr . destination . repository ) ,
308353 bitbucketPullRequestStateToState ( pr . state ) ,
309354 new Date ( pr . created_on ) ,
310355 new Date ( pr . updated_on ) ,
0 commit comments