import { KibanaRequest , SavedObjectsClientContract } from 'kibana/server' ; import { resultsServiceProvider } from '../../models/results_service' ; import { GetGuards } from '../shared_services' ; type OrigResultsServiceProvider = ReturnType < typeof resultsServiceProvider > ; export interface ResultsServiceProvider { resultsServiceProvider ( request , savedObjectsClient ) : { getAnomaliesTableData : OrigResultsServiceProvider [ 'getAnomaliesTableData' ] ; } ; } export function getResultsServiceProvider ( getGuards ) { return { resultsServiceProvider ( request , savedObjectsClient ) { return { async getAnomaliesTableData ( ... args ) { return await getGuards ( request , savedObjectsClient ) . isFullLicense ( ) . hasMlCapabilities ( [ 'canGetJobs' ] ) . ok ( async ( { mlClient } ) => { const { getAnomaliesTableData } = resultsServiceProvider ( mlClient ) ; return getAnomaliesTableData ( ... args ) ; } ) ; } , } ; } , } ; }