import { LegacyAPICaller } from 'opensearch-dashboards/server' ; import { getFieldCapabilities , resolveTimePattern , createNoMatchingIndicesError } from './lib' ; export interface FieldDescriptor { aggregatable : boolean ; name : string ; readFromDocValues : boolean ; searchable : boolean ; type : string ; esTypes : string [ ] ; subType ? : FieldSubType ; } interface FieldSubType { multi ? : { parent : string ; } ; nested ? : { path : string ; } ; } export class IndexPatternsFetcher { private _callDataCluster : LegacyAPICaller ; constructor ( callDataCluster ) { this . _callDataCluster = callDataCluster ; } param { Object } options property property return { Promise < Array < Fields > > } async getFieldsForWildcard ( options ) { const { pattern , metaFields , fieldCapsOptions } = options ; return await getFieldCapabilities ( this . _callDataCluster , pattern , metaFields , fieldCapsOptions ) ; } param { Object } options property property property return { Promise < Array < Fields > > } async getFieldsForTimePattern ( options ) { const { pattern , lookBack , metaFields } = options ; const { matches } = await resolveTimePattern ( this . _callDataCluster , pattern ) ; const indices = matches . slice ( 0 , lookBack ) ; if ( indices . length === 0 ) { throw createNoMatchingIndicesError ( pattern ) ; } return await getFieldCapabilities ( this . _callDataCluster , indices , metaFields ) ; } }