declare type BeforeAfterResult = void | { value: T; }; declare type BeforeAfterEvent = { target: any; args: any[]; result?: T; }; declare type BeforeAfterCallback = (err?: Error, result?: { value: T; }) => void; /** * A decorator function that executes a specified callable function before the original method. * The callable function can modify the arguments or prevent the original method from being called. * * @param callable - A function that takes an event object and a callback function as arguments. * The event object contains the target object and the arguments of the original method. * The callback function should be called with an error or a result object. * If the result object contains a 'value' property, the original method will not be called. * Otherwise, the original method will be called with the modified arguments. * @returns A decorator function that can be applied to a method. */ declare function before(callable: (event: BeforeAfterEvent, ...callback: BeforeAfterCallback[]) => BeforeAfterResult): any; /** * A decorator that executes an asynchronous function before the decorated method is called. * * @param callable - An asynchronous function that takes an event object containing the target and arguments of the method call. * @returns A decorator function that modifies the method to call the provided asynchronous function before executing the original method. * * @example * ```typescript * class Example { * @beforeAsync(async (event) => { * console.log('Before method call', event); * }) * async myMethod(arg1: string, arg2: number) { * console.log('Original method', arg1, arg2); * } * } * ``` */ declare function beforeAsync(callable: (event: { target: any; args: any[]; }) => Promise>): any; /** * A decorator function that executes a callable function after the original method. * The callable function can modify the result of the original method. * * @param callable - A function that takes an event object and an optional callback, * and returns a result object. The event object contains the target object, * the arguments passed to the original method, and the result of the original method. * The callback is used to handle asynchronous operations. * * @returns A decorator function that wraps the original method. * * @example * ```typescript * class Example { * @after((event, callback) => { * console.log('After method execution:', event.result); * if (callback) { * callback(null, event.result); * } * return { value: event.result }; * }) * someMethod(arg1: string, arg2: number, callback: (err: Error, result: any) => void) { * // original method implementation * callback(null, 'result'); * } * } * ``` */ declare function after(callable: (event: BeforeAfterEvent, ...callback: BeforeAfterCallback[]) => BeforeAfterResult): any; /** * A decorator that executes an asynchronous callback function after the original method is called. * * @param callable - An asynchronous function that takes an event object containing the target object, * the arguments passed to the original method, and the result of the original method. * @returns A decorator function that wraps the original method and executes the callback after the method completes. * * @example * ```typescript * class Example { * @afterAsync(async (event) => { * console.log('After method call:', event); * }) * async someMethod(arg1: string, arg2: number) { * // method implementation * } * } * ``` */ declare function afterAsync(callable: (event: { target: any; args: any; result?: any; }) => Promise>): any; export { BeforeAfterEvent, BeforeAfterResult, BeforeAfterCallback, before, after, beforeAsync, afterAsync };