import { KibanaRequest , SavedObjectsClientContract } from 'kibana/server' ; import { jobServiceProvider } from '../../models/job_service' ; import { GetGuards } from '../shared_services' ; type OrigJobServiceProvider = ReturnType < typeof jobServiceProvider > ; export interface JobServiceProvider { jobServiceProvider ( request , savedObjectsClient ) : { jobsSummary : OrigJobServiceProvider [ 'jobsSummary' ] ; } ; } export function getJobServiceProvider ( getGuards ) { return { jobServiceProvider ( request , savedObjectsClient ) { return { jobsSummary : async ( ... args ) => { return await getGuards ( request , savedObjectsClient ) . isFullLicense ( ) . hasMlCapabilities ( [ 'canGetJobs' ] ) . ok ( ( { scopedClient , mlClient } ) => { const { jobsSummary } = jobServiceProvider ( scopedClient , mlClient ) ; return jobsSummary ( ... args ) ; } ) ; } , } ; } , } ; }