@@ -340,7 +340,7 @@ export class ProvidersApi {
340340 }
341341
342342 async getPagedResult < T > (
343- _provider : ProviderInfo ,
343+ provider : ProviderInfo ,
344344 args : any ,
345345 providerFn :
346346 | ( (
@@ -372,27 +372,31 @@ export class ProvidersApi {
372372 ...cursorOrPage ,
373373 } ;
374374
375- const result = await providerFn ?.( input , { token : token , isPAT : usePAT } ) ;
376- if ( result == null ) {
377- return { values : [ ] } ;
378- }
375+ try {
376+ const result = await providerFn ?.( input , { token : token , isPAT : usePAT } ) ;
377+ if ( result == null ) {
378+ return { values : [ ] } ;
379+ }
379380
380- const hasMore = result . pageInfo ?. hasNextPage ?? false ;
381+ const hasMore = result . pageInfo ?. hasNextPage ?? false ;
381382
382- let nextCursor = '{}' ;
383- if ( result . pageInfo ?. endCursor != null ) {
384- nextCursor = JSON . stringify ( { value : result . pageInfo ?. endCursor , type : 'cursor' } ) ;
385- } else if ( result . pageInfo ?. nextPage != null ) {
386- nextCursor = JSON . stringify ( { value : result . pageInfo ?. nextPage , type : 'page' } ) ;
387- }
383+ let nextCursor = '{}' ;
384+ if ( result . pageInfo ?. endCursor != null ) {
385+ nextCursor = JSON . stringify ( { value : result . pageInfo ?. endCursor , type : 'cursor' } ) ;
386+ } else if ( result . pageInfo ?. nextPage != null ) {
387+ nextCursor = JSON . stringify ( { value : result . pageInfo ?. nextPage , type : 'page' } ) ;
388+ }
388389
389- return {
390- values : result . data ,
391- paging : {
392- cursor : nextCursor ,
393- more : hasMore ,
394- } ,
395- } ;
390+ return {
391+ values : result . data ,
392+ paging : {
393+ cursor : nextCursor ,
394+ more : hasMore ,
395+ } ,
396+ } ;
397+ } catch ( e ) {
398+ return this . handleProviderError < PagedResult < T > > ( provider . id , token , e ) ;
399+ }
396400 }
397401
398402 async getCurrentUser (
@@ -784,24 +788,21 @@ export class ProvidersApi {
784788 async getIssuesForResourceForCurrentUser (
785789 providerId : IntegrationId ,
786790 resourceId : string ,
787- options ?: { accessToken ?: string } ,
788- ) : Promise < ProviderIssue [ ] | undefined > {
791+ options ?: { accessToken ?: string ; cursor ?: string } ,
792+ ) : Promise < PagedResult < ProviderIssue > > {
789793 const { provider, token } = await this . ensureProviderTokenAndFunction (
790794 providerId ,
791795 'getIssuesForResourceForCurrentUserFn' ,
792796 options ?. accessToken ,
793797 ) ;
794798
795- try {
796- const result = await provider . getIssuesForResourceForCurrentUserFn ?.(
797- { resourceId : resourceId } ,
798- { token : token } ,
799- ) ;
800-
801- return result ?. data ;
802- } catch ( e ) {
803- return this . handleProviderError < ProviderIssue [ ] | undefined > ( providerId , token , e ) ;
804- }
799+ return this . getPagedResult < ProviderIssue > (
800+ provider ,
801+ { resourceId : resourceId } ,
802+ provider . getIssuesForResourceForCurrentUserFn ,
803+ token ,
804+ options ?. cursor ,
805+ ) ;
805806 }
806807
807808 async getIssue (
0 commit comments