surrogate
Version:
Object method hooks made easy
41 lines (40 loc) • 1.74 kB
TypeScript
import type { WhichContainers } from '../../interfaces';
import type { ContextController } from './interfaces';
import type { SurrogateProxy } from '../../proxy';
import type { NextNode } from '../interfaces';
import type { Context } from '../../context';
export declare abstract class ExecutionContext<T extends object> implements ContextController<T> {
readonly context: Context<T>;
private utilizeLatest;
private hasThrown;
protected nextNode: NextNode<T>;
readonly timeTracker: import("../../timeTracker").TimeTracking;
readonly correlationId: string;
latestArgs: any[];
returnValue: any;
constructor(context: Context<T>);
static for<T extends object>(context: Context<T>, typeContainers: WhichContainers<T>): ContextController<T>;
setupPipeline(proxy: SurrogateProxy<T>, typeContainers: WhichContainers<T>): this;
private static hasAsync;
protected setReturnValue(value: any): void;
setNext(next: NextNode<T>): void;
addNext(next: NextNode<T>): this;
updateLatestArgs(updatedArgs: any): void;
get currentArgs(): any[];
protected runNext(next?: NextNode<T>): void;
protected logError(node: NextNode<T>, error: Error): void;
abstract handleError(node: NextNode<T>, error?: Error): never | void;
/**
* @description Runs the target method after pre hooks and before post hooks.
*
* @note Original method could be an instance method of the proxied class if it is a member of hook pipeline
*
* @abstract
* @param {NextNode<T>} node
* @memberof ExecutionContext
*/
abstract runOriginal(node: NextNode<T>): void;
abstract bail(bailWith?: any): any;
abstract complete(): void;
abstract start(): any;
}