import { OpenSearchDashboardsDatatableColumnMeta } from '../../../../../../plugins/expressions/public' ; import { IAggConfig } from '../../../../common' ; import { IndexPattern } from '../../../index_patterns' ; import { getSearchService } from '../../../services' ; internal export const serializeAggConfig = ( aggConfig ) : OpenSearchDashboardsDatatableColumnMeta => { return { type : aggConfig . type . name , indexPatternId : aggConfig . getIndexPattern ( ) . id , aggConfigParams : aggConfig . serialize ( ) . params , } ; } ; interface DeserializeAggConfigParams { type : string ; aggConfigParams : Record < string , any > ; indexPattern : IndexPattern ; } internal export const deserializeAggConfig = ( { type , aggConfigParams , indexPattern , } ) => { const { aggs } = getSearchService ( ) ; const aggConfigs = aggs . createAggConfigs ( indexPattern ) ; const aggConfig = aggConfigs . createAggConfig ( { enabled : true , type , params : aggConfigParams , } ) ; return aggConfig ; } ;