import { buildRequestBody } from './build_request_body' ; import type { FetchedIndexPattern , Panel , Series } from '../../../../common/types' ; import type { VisTypeTimeseriesRequestServices , VisTypeTimeseriesVisDataRequest , } from '../../../types' ; import type { SearchCapabilities } from '../../search_strategies' ; export async function getSeriesRequestParams ( req , panel , panelIndex , series , capabilities , { esQueryConfig , esShardTimeout , uiSettings , cachedIndexPatternFetcher , buildSeriesMetaParams , } ) { let seriesIndex = panelIndex ; if ( series . override_index_pattern ) { seriesIndex = await cachedIndexPatternFetcher ( series . series_index_pattern ?? '' ) ; } const request = await buildRequestBody ( req , panel , series , esQueryConfig , seriesIndex , capabilities , uiSettings , ( ) => buildSeriesMetaParams ( seriesIndex , Boolean ( panel . use_kibana_indexes ) , series ) ) ; return { index : seriesIndex . indexPatternString , body : { ... request , runtime_mappings : seriesIndex . indexPattern ?. getComputedFields ( ) . runtimeFields ?? { } , timeout : esShardTimeout > 0 ? `${ esShardTimeout }ms` : undefined , } , } ; }