import { VisTypeTimeseriesRequest , VisTypeTimeseriesRequestHandlerContext } from '../../types' ; import { AbstractSearchStrategy } from './strategies' ; import type { FetchedIndexPattern } from '../../../common/types' ; export class SearchStrategyRegistry { private strategies : AbstractSearchStrategy [ ] = [ ] ; public addStrategy ( searchStrategy ) { if ( searchStrategy instanceof AbstractSearchStrategy ) { this . strategies . unshift ( searchStrategy ) ; } return this . strategies ; } async getViableStrategy ( requestContext , req , fetchedIndexPattern ) { for ( const searchStrategy of this . strategies ) { const { isViable , capabilities } = await searchStrategy . checkForViability ( requestContext , req , fetchedIndexPattern ) ; if ( isViable ) { return { searchStrategy , capabilities , } ; } } } }