import { StateStore } from '@stream-io/state-store'; import { type DebouncedFunc } from '../utils'; import type { QueryReturnValue, SearchSourceOptions, SearchSourceState, SearchSourceType } from './types'; export type DebounceOptions = { debounceMs: number; }; type DebouncedExecQueryFunction = DebouncedFunc<(searchString?: string) => Promise>; interface ISearchSource { activate(): void; canExecuteQuery(newSearchString?: string): boolean; deactivate(): void; readonly hasNext: boolean; readonly hasResults: boolean; readonly initialState: SearchSourceState; readonly isActive: boolean; readonly isLoading: boolean; readonly items: T[] | undefined; readonly lastQueryError: Error | undefined; readonly next: string | undefined | null; readonly offset: number | undefined; resetState(): void; readonly searchQuery: string; readonly state: StateStore>; readonly type: SearchSourceType; } export interface SearchSource extends ISearchSource { cancelScheduledQuery(): void; setDebounceOptions(options: DebounceOptions): void; search(text?: string): Promise | undefined; } export interface SearchSourceSync extends ISearchSource { cancelScheduledQuery(): void; setDebounceOptions(options: DebounceOptions): void; search(text?: string): void; } declare abstract class BaseSearchSourceBase implements ISearchSource { state: StateStore>; pageSize: number; protected allowEmptySearchString: boolean; protected resetOnNewSearchQuery: boolean; abstract readonly type: SearchSourceType; protected constructor(options?: SearchSourceOptions); get lastQueryError(): Error | undefined; get hasNext(): boolean; get hasResults(): boolean; get isActive(): boolean; get isLoading(): boolean; get initialState(): { hasNext: boolean; isActive: boolean; isLoading: boolean; items: undefined; lastQueryError: undefined; next: undefined; offset: number; searchQuery: string; }; get items(): T[] | undefined; get next(): string | null | undefined; get offset(): number | undefined; get searchQuery(): string; activate: () => void; deactivate: () => void; canExecuteQuery: (newSearchString?: string) => boolean; protected getStateBeforeFirstQuery(newSearchString: string): SearchSourceState; protected getStateAfterQuery(stateUpdate: Partial>, isFirstPage: boolean): SearchSourceState; protected prepareStateForQuery(newSearchString?: string): { searchString: string; hasNewSearchQuery: boolean; }; protected updatePaginationStateFromQuery(result: QueryReturnValue): Partial>; resetState(): void; resetStateAndActivate(): void; } export declare abstract class BaseSearchSource extends BaseSearchSourceBase implements SearchSource { protected searchDebounced: DebouncedExecQueryFunction; constructor(options?: SearchSourceOptions); protected abstract query(searchQuery: string): Promise>; protected abstract filterQueryResults(items: T[]): T[] | Promise; setDebounceOptions: ({ debounceMs }: DebounceOptions) => void; executeQuery(newSearchString?: string): Promise; search: (searchQuery?: string) => Promise | undefined; cancelScheduledQuery(): void; } export declare abstract class BaseSearchSourceSync extends BaseSearchSourceBase implements SearchSourceSync { protected searchDebounced: DebouncedExecQueryFunction; constructor(options?: SearchSourceOptions); protected abstract query(searchQuery: string): QueryReturnValue; protected abstract filterQueryResults(items: T[]): T[]; setDebounceOptions: ({ debounceMs }: DebounceOptions) => void; executeQuery(newSearchString?: string): void; search: (searchQuery?: string) => Promise | undefined; cancelScheduledQuery(): void; } export {}; //# sourceMappingURL=BaseSearchSource.d.ts.map