import { Connection } from "@salesforce/core" ; const retry = require ( "async-retry" ) ; export default class LimitsFetcher { constructor ( private conn ) { } public async getApiLimits ( ) { const limits = [ ] ; const endpoint = `${ this . conn . instanceUrl }/services/data/v${ this . conn . version }/limits` ; const result = await retry ( async ( bail ) => { return this . conn . request < { [ p ] : { Max : number ; Remaining : number ; } ; } > ( endpoint ) ; } , { retries : 3 , minTimeout : 2000 } ) ; Object . keys ( result ) . forEach ( ( limitName ) => { limits . push ( { name : limitName , max : result [ limitName ] . Max , remaining : result [ limitName ] . Remaining , } ) ; } ) ; return limits ; } }