import type { SavedObjectsClientContract , SimpleSavedObject , SavedObjectAttributes , } from 'kibana/public' ; /** Returns an object matching a given title */ export async function findObjectByTitle < T extends SavedObjectAttributes > ( savedObjectsClient , type , title ) { if ( ! title ) { return ; } const response = await savedObjectsClient . find < T > ( { type , perPage : 10 , search : `"${ title }"` , searchFields : [ 'title' ] , fields : [ 'title' ] , } ) ; return response . savedObjects . find ( ( obj ) => obj . get ( 'title' ) . toLowerCase ( ) === title . toLowerCase ( ) ) ; }