import MillenniumDBError from './millenniumdb-error'; import QueryObserver from './query-observer'; import Record from './record'; import { QueryPreamble } from './response-handler'; export interface ResultObserver { /** Event handler triggered when variables are available. This should be the first event triggered during a query */ onVariables?: (variables: Array, queryPreamble?: QueryPreamble) => void; /** Event handler triggered when a record is available */ onRecord?: (record: Record) => void; /** Event handler triggered after a successful execution */ onSuccess?: (summary: any) => void; /** Event handler triggered when an error occurs */ onError?: (error: MillenniumDBError) => void; } /** * Result represents the result of a query */ declare class Result { _queryPreamble: QueryPreamble | null; private readonly _queryObserver; private _variables; private _summary; private _error; private _recordsPromise; /** * This constructor should never be called directly * * @param queryObserver the {@link QueryObserver} that will handle the received data */ constructor(queryObserver: QueryObserver); /** * Get the variables associated with the result * * @returns a promise that resolves when the variables are received */ variables(): Promise>; /** * Get the records associated with the result * * @returns a promise that resolves when the records are received */ records(): Promise>; /** * Get the summary associated with the result * * @returns a promise that resolves when the summary is received */ summary(): Promise; /** * * @param observer the {@link ResultObserver} that will handle the received data */ subscribe(observer: ResultObserver): void; unsubscribe(): void; /** * Wrap the observer in order to store relevant query information * * @param observer the {@link ResultObserver} that will handle the received data * @returns the observer wrapped */ private _wrapObserver; } export default Result;