import type { Observable, Subscriber, Observer } from 'rxjs'; import type { DashboardJSON, DataSourceDefinition, DataSourceOptions, ExtendableDataSourceDefinition, RootDataSourcesDefinition } from './DashboardJSON'; import type { Store } from './DashboardState'; import type { RequestParams, SearchControlAction, SearchData, SearchCountsInfo } from './Search'; import type { PresetUtility } from './Preset'; import type { BroadcastEventArgs, BroadcastEventCallback } from './EventHandlers'; type TitleGetter = ({ searchType }: { searchType: string; }) => string; type DefaultOptionsGetter = ({ definition, searchType, }: { searchType: string; definition: DashboardJSON; }) => DataSourceOptions; export interface DataSourceConfigMeta, DefaultOptions = Record> { title: string | TitleGetter; displayDataSourceItemListByDefault: boolean; canCreateDataSource: boolean; dataSourceRemoveVerb: string; isDataSourceNameEditable: boolean; getDataSourceName: ({ dataSource, }: { dataSource?: DataSourceDefinition; }) => string; defaultOptions: DefaultOptions | DefaultOptionsGetter; editorConfig: unknown[]; optionsSchema: OptionsSchema; isChainEnabled?: boolean; extendableByDataSourceTypes?: string[]; customAddDataSourceText?: string; showRefreshEditor?: boolean; } export interface DataSourceEventPayload extends SearchData { consumerId?: string; } /** * Super generic DS type for preset */ interface DSStatics { config?: Partial; } export interface DSTypes { setup: Promise; request: Observable | ((observer?: Subscriber) => () => void) | ((observer?: any) => Promise); pause: Promise | null>; resume: Promise | null>; finalize: Promise | null>; teardown: Promise; equals: boolean; getObserver: Observer; shouldRefreshSubscription: boolean; supportsControlActions: boolean; } export interface DSRequired { options: any; context: any; setup(): DSTypes['setup']; request(requestParams?: RequestParams): DSTypes['request']; teardown(): DSTypes['teardown']; equals(other: any): DSTypes['equals']; getObserver(): DSTypes['getObserver']; shouldRefreshSubscription(): DSTypes['shouldRefreshSubscription']; } export interface DSOptional { pause(): DSTypes['pause']; resume(): DSTypes['resume']; supportsControlActions(action?: SearchControlAction): DSTypes['supportsControlActions']; finalize(): DSTypes['finalize']; } type DSConstructable = { new (options?: Options, context?: Context, meta?: Meta, baseChainModel?: BaseChainModel): R; new (options?: Options, context?: Context): R; } & DSStatics; export type BaseDS = DSConstructable>; export interface IRiskyCommandController { disableRiskyCheckList: Set; shouldCheckRiskyCommand(query: string): boolean; addToDisableCheckList(query: string): void; clearDisableCheckList(): void; } export interface IDataSourceRegistry> { definition: Record; preset: PresetUtility; store: Store; dataSourceContext?: Context; controllers: Record; riskyCommandController: IRiskyCommandController; broadcastCallback: BroadcastEventCallback; broadcastDataSourceEvent(event: BroadcastEventArgs): void; onEventBroadcast(callback: BroadcastEventCallback): void; allocate({ dataSourceId }: { dataSourceId: string; }): Controller; pauseDataSources(dsIds?: string[]): Promise[]>; resumeDataSources(dsIds?: string[]): Promise[]>; dataSourceValidation(dataSourceId: string): void; getActiveChainControllers(parentDataSourceId: string): Record; getDataSourceController(dataSourceId: string): Controller | undefined; getDataSourceControllers(): Record; updateDefinition({ definition, consumersInLayout, }: { definition: RootDataSourcesDefinition; consumersInLayout?: string[]; }): void; subscribeToStore(store: Store): void; setDataSourceContext(ctx: Context): void; setPreset(preset: PresetUtility): void; snapshot(): Record>; getSearchCounts(): SearchCountsInfo; handleDataSourceTeardown(key: number): void; teardown(): void; } export {}; //# sourceMappingURL=DataSource.d.ts.map