import { SavedObjectsServiceStart , KibanaRequest } from 'kibana/server' ; import { SavedObjectsClient } from '../../../../../src/core/server' ; import { ML_SAVED_OBJECT_TYPE } from '../../common/types/saved_objects' ; export function savedObjectClientsFactory ( getSavedObjectsStart ) { return { getMlSavedObjectsClient : ( request ) => { const savedObjectsStart = getSavedObjectsStart ( ) ; if ( savedObjectsStart === null ) { return null ; } return savedObjectsStart . getScopedClient ( request , { includedHiddenTypes : [ ML_SAVED_OBJECT_TYPE ] , } ) ; } , getInternalSavedObjectsClient : ( ) => { const savedObjectsStart = getSavedObjectsStart ( ) ; if ( savedObjectsStart === null ) { return null ; } const savedObjectsRepo = savedObjectsStart . createInternalRepository ( ) ; return new SavedObjectsClient ( savedObjectsRepo ) ; } , } ; } export function getSavedObjectClientError ( error ) { return error . isBoom && error . output ?. payload ? error . output . payload : error . body ?? error ; }