import { map } from 'lodash' ; import { SerializedFieldFormat } from '../../types/common' ; import { Datatable , PointSeries , PointSeriesColumn } from '.' ; const name = 'opensearch_dashboards_datatable' ; export interface OpenSearchDashboardsDatatableColumnMeta { type : string ; indexPatternId ? : string ; aggConfigParams ? : Record < string , any > ; } export interface OpenSearchDashboardsDatatableColumn { id : string ; name : string ; meta ? : OpenSearchDashboardsDatatableColumnMeta ; formatHint ? : SerializedFieldFormat ; } export interface OpenSearchDashboardsDatatableRow { [ key ] : unknown ; } export interface OpenSearchDashboardsDatatable { type : typeof name ; columns : OpenSearchDashboardsDatatableColumn [ ] ; rows : OpenSearchDashboardsDatatableRow [ ] ; } export const opensearchDashboardsDatatable = { name , from : { datatable : ( context ) => { return { type : name , rows : context . rows , columns : context . columns . map ( ( column ) => { return { id : column . name , name : column . name , } ; } ) , } ; } , pointseries : ( context ) => { const columns = map ( context . columns , ( column , n ) => { return { id : n , name : n , ... column } ; } ) ; return { type : name , rows : context . rows , columns , } ; } , } , } ;