import { mapValues } from 'lodash' ; import { SavedObjectsType , SavedObjectUnsanitizedDoc } from 'kibana/server' ; import { EmbeddableSetup } from '../../../src/plugins/embeddable/server' ; import { mergeMigrationFunctionMaps } from './merge_migration_function_maps' ; export const searchableListSavedObject = ( embeddable ) => { const searchableListSO = { name : 'searchableList' , hidden : false , namespaceType : 'single' , management : { icon : 'visualizeApp' , defaultSearchField : 'title' , importableAndExportable : true , getTitle ( obj ) { return obj . attributes . title ; } , } , mappings : { properties : { title : { type : 'text' } , version : { type : 'integer' } , } , } , migrations : ( ) => { const searchableListSavedObjectMigrations = { } ; const embeddableMigrations = mapValues ( embeddable . getAllMigrations ( ) , ( migrate ) => { return ( state ) => ( { ... state , attributes : migrate ( state . attributes ) , } ) ; } ) ; return mergeMigrationFunctionMaps ( searchableListSavedObjectMigrations , embeddableMigrations ) ; } , } ; return searchableListSO ; } ;