/// /// import EventEmitter from 'events'; import { DataLoadServiceI, JaqlRequest } from './types.js'; declare type DataCache = { [key: string]: any; }; declare type LoadState = { [key: string]: number; }; /** * Initiate single socket connection and creates new PivotDataSource for each JAQL request */ export declare class AbstractDataLoadService implements DataLoadServiceI { /** * * @private * * EventEmitter instance */ events: EventEmitter; /** * @private * * jaql request object */ jaql?: JaqlRequest; /** * @private * * cache object */ data?: DataCache; /** * @private * * state for "load" method */ isLoadInProgress: boolean; /** @private */ loadPromiseResolve?: Function; /** * * @private */ loadPromiseReject?: Function; /** * @private * * info about amount of data which already loaded from cache */ loadFromCacheState?: LoadState; /** @private */ loadFromCacheInitialTimer?: NodeJS.Timeout; /** @private */ loadFromCacheTimer?: NodeJS.Immediate; /** * @private * * defines initial pivot data structure */ isSingleBranchTree: boolean; /** * @private * * items count loaded on client side */ loadedItemsCount: number; /** * @private * * total items count on back-end side */ totalItemsCount: number; /** * @private * * defines if amount of data was limited on back-end or not */ isLimited: boolean; /** * @private * * detects if finish event was received */ isFinishEventReceived: boolean; constructor(events?: EventEmitter); /** * Destroys data load service * * @returns {void} */ destroy(): void; /** * Return copy of load service * * @returns {DataLoadService} - cloned instance */ clone(): DataLoadServiceI; /** * Start data loading according to JAQL request * * @param {JaqlRequest} jaql - JAQL request * @returns {Promise} - whole data loading promise */ load(jaql: JaqlRequest): Promise; /** * Clear data cache * * @returns {void} */ clear(): void; /** * Returns current jaql request object * * @returns {JaqlRequest} - jaql request object */ getJaql(): JaqlRequest | undefined; /** * Defines data structure * * @returns {boolean} - true - single branch tree */ isSingleRowTree(): boolean; /** * Returns total amount items count handled on back-end side * * @returns {number} - items count */ getTotalItemsCount(): number; /** * Defines if new jaql has only formatting changes or it requires new data loading from server * * @param {JaqlRequest} jaql - jaql request object * @returns {boolean} - true - only formatting changes, can use cached data */ isFormattingChanges(jaql?: JaqlRequest): boolean; /** * Defines if service have some data * * @returns {boolean} - true - has some data */ hasData(): boolean; /** * Defines if service have some error * * @returns {boolean} - true - has some error */ hasError(): boolean; /** * Start data loading from the server * * @returns {void} * @private */ loadFromServer(): void; /** * Method for canceling the processing of query already sent * * @returns {Promise} - waiting promise */ cancelQuery(): Promise; /** * Method for detection if cancel query is still needed * * @returns {boolean} - is cancel query needed */ isCancelQueryNeeded(): boolean; /** * Start data loading from the cache * * @returns {Promise} - waiting promise * @private */ loadFromCache(): Promise; /** * Starts loading data from cache queue * * @param {Function} onFinish - on finish callback * @returns {void} * @private */ loadMessageFromCache(onFinish: () => void): void; /** * Cache appropriate message * * @param {string} type - message type * @param {any} data - message payload * @returns {void} * @private */ cacheData(type: string, data?: any): void; /** * Notify outside about data chunk with saving to inner cache, applying chunk formatting with * saving initial messages queue * * @param {string} type - data chunk type * @param {any} chunk - data chunk data * @param {boolean} isFromCache - mark data which already was cached * @returns {void} * @private */ notifyAboutDataChunk(type: string, chunk?: any, isFromCache?: boolean): void; /** * Resolve "load" method with appropriate data information * * @param {any} data - data to resolve with * @returns {void} * @private */ notifyAboutDataLoaded(data?: any): void; /** * Reject "load" method with appropriate data information * * @param {any} data - data to reject with * @returns {void} * @private */ notifyAboutDataError(data?: any): void; /** * Subscribe to event notification * * @param {string} eventName - event name to subscribe * @param {Function} callback - event handler * @returns {void} */ on(eventName: string, callback: (payload: any) => void): void; /** * Unsubscribe from event notification * * @param {string} eventName - event name to unsubscribe * @param {Function} callback - event handler * @returns {void} */ off(eventName: string, callback: (payload: any) => void): void; /** * Unsubscribe from all event notifications * * @param {string} eventName - event name to unsubscribe * @returns {void} */ offAll(eventName: string): void; listenerCount(eventName: string): number; /** * Trigger event notification * * @param {string} eventName - event name to subscribe * @param {Array} rest - arguments will be passed to event handler * @returns {void} */ emit(eventName: string, ...rest: Array): void; } export default AbstractDataLoadService;