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 {
@@ -196,6 +197,12 @@ export interface BitbucketIssue {
196197 created_on : string ;
197198 updated_on : string ;
198199 repository : BitbucketRepository ;
200+ votes ?: number ;
201+ content : {
202+ raw : string ;
203+ markup : string ;
204+ html : string ;
205+ } ;
199206 links : {
200207 self : BitbucketLink ;
201208 html : BitbucketLink ;
@@ -240,6 +247,10 @@ export function isClosedBitbucketPullRequestState(state: BitbucketPullRequestSta
240247 return bitbucketPullRequestStateToState ( state ) !== 'opened' ;
241248}
242249
250+ export function isClosedBitbucketIssueState ( state : BitbucketIssueState ) : boolean {
251+ return bitbucketIssueStateToState ( state ) !== 'opened' ;
252+ }
253+
243254export function fromBitbucketUser ( user : BitbucketUser ) : PullRequestMember {
244255 return {
245256 avatarUrl : user . links . avatar . href ,
@@ -295,6 +306,46 @@ function getBitbucketReviewDecision(pr: BitbucketPullRequest): PullRequestReview
295306 return PullRequestReviewDecision . ReviewRequired ; // nobody has reviewed yet.
296307}
297308
309+ function fromBitbucketRepository ( repo : BitbucketRepository ) : IssueRepository {
310+ return {
311+ owner : repo . full_name . split ( '/' ) [ 0 ] ,
312+ repo : repo . name ,
313+ id : repo . uuid ,
314+ // TODO: Remove this assumption once actual access level is available
315+ accessLevel : RepositoryAccessLevel . Write ,
316+ } ;
317+ }
318+
319+ export function fromBitbucketIssue ( issue : BitbucketIssue , provider : Provider ) : Issue {
320+ return new Issue (
321+ provider ,
322+ issue . id . toString ( ) ,
323+ issue . id . toString ( ) ,
324+ issue . title ,
325+ issue . links . html . href ,
326+ new Date ( issue . created_on ) ,
327+ new Date ( issue . updated_on ) ,
328+ isClosedBitbucketIssueState ( issue . state ) ,
329+ bitbucketIssueStateToState ( issue . state ) ,
330+ fromBitbucketUser ( issue . reporter ) ,
331+ issue . assignee ? [ fromBitbucketUser ( issue . assignee ) ] : [ ] ,
332+ fromBitbucketRepository ( issue . repository ) ,
333+ undefined , // closedDate
334+ undefined , // labels
335+ undefined , // commentsCount
336+ issue . votes , // thumbsUpCount
337+ issue . content . html , // body
338+ ! issue . repository ?. project
339+ ? undefined
340+ : {
341+ id : issue . repository . project . uuid ,
342+ name : issue . repository . project . name ,
343+ resourceId : issue . repository . project . uuid ,
344+ resourceName : issue . repository . project . name ,
345+ } ,
346+ ) ;
347+ }
348+
298349export function fromBitbucketPullRequest ( pr : BitbucketPullRequest , provider : Provider ) : PullRequest {
299350 return new PullRequest (
300351 provider ,
@@ -303,13 +354,7 @@ export function fromBitbucketPullRequest(pr: BitbucketPullRequest, provider: Pro
303354 pr . id . toString ( ) ,
304355 pr . title ,
305356 pr . links . html . href ,
306- {
307- owner : pr . destination . repository . full_name . split ( '/' ) [ 0 ] ,
308- repo : pr . destination . repository . name ,
309- id : pr . destination . repository . uuid ,
310- // TODO: Remove this assumption once actual access level is available
311- accessLevel : RepositoryAccessLevel . Write ,
312- } ,
357+ fromBitbucketRepository ( pr . destination . repository ) ,
313358 bitbucketPullRequestStateToState ( pr . state ) ,
314359 new Date ( pr . created_on ) ,
315360 new Date ( pr . updated_on ) ,
0 commit comments