import { ISavedObjectsRepository , SavedObjectAttributes } from 'kibana/server' ; import { SavedDashboardPanel730ToLatest } from '../../common' ; export const findByValueEmbeddables = async ( savedObjectClient , embeddableType ) => { const dashboards = await savedObjectClient . find < SavedObjectAttributes > ( { type : 'dashboard' , } ) ; return dashboards . saved_objects . map ( ( dashboard ) => { try { return JSON . parse ( dashboard . attributes . panelsJSON as string ) as unknown as SavedDashboardPanel730ToLatest [ ] ; } catch ( exception ) { return [ ] ; } } ) . flat ( ) . filter ( ( panel ) => ( panel as Record < string , any > ) . panelRefName === undefined ) . filter ( ( panel ) => panel . type === embeddableType ) . map ( ( panel ) => panel . embeddableConfig ) ; } ;