import { IndexPatternsService } from '../../../../../../data/server' ; import { toSanitizedFieldType } from '../../../../common/fields_utils' ; import type { FetchedIndexPattern } from '../../../../common/types' ; import type { VisTypeTimeseriesRequest , VisTypeTimeseriesRequestHandlerContext , VisTypeTimeseriesVisDataRequest , } from '../../../types' ; export abstract class AbstractSearchStrategy { async search ( requestContext , req , bodies , indexType ? ) { const requests = [ ] ; bodies . forEach ( ( body ) => { requests . push ( requestContext . search . search ( { indexType , params : { ... body , } , } , req . body . searchSession ) . toPromise ( ) ) ; } ) ; return Promise . all ( requests ) ; } checkForViability ( requestContext , req , fetchedIndexPattern ) { throw new TypeError ( 'Must override method' ) ; } async getFieldsForWildcard ( fetchedIndexPattern , indexPatternsService , capabilities ? , options ? ) { return toSanitizedFieldType ( fetchedIndexPattern . indexPattern ? fetchedIndexPattern . indexPattern . getNonScriptedFields ( ) : await indexPatternsService . getFieldsForWildcard ( { pattern : fetchedIndexPattern . indexPatternString ?? '' , metaFields : [ ] , ... options , } ) ) ; } }