import { Middleware } from './compose'; import { HookManager, HookContextData, HookContext, HookContextConstructor, HookOptions } from './base'; import { HookMap } from './hooks'; export * from './hooks'; export * from './compose'; export * from './base'; export interface WrapperAddon { original: F; Context: HookContextConstructor; createContext: (data?: HookContextData) => HookContext; } export declare type WrappedFunction = F & ((...rest: any[]) => Promise | Promise) & WrapperAddon; export declare type MiddlewareOptions = { params?: any; defaults?: any; props?: any; }; /** * Initializes a hook settings object with the given middleware. * @param mw The list of middleware * @param options Middleware options (params, default, props) */ export declare function middleware(mw?: Middleware[], options?: MiddlewareOptions): HookManager; /** * Returns a new function that wraps an existing async function * with hooks. * * @param fn The async function to add hooks to. * @param manager An array of middleware or hook settings * (`middleware([]).params()` etc.) */ export declare function hooks(fn: F & (() => void), manager?: HookManager): WrappedFunction; /** * Add hooks to one or more methods on an object or class. * @param obj The object to add hooks to * @param hookMap A map of middleware settings where the * key is the method name. */ export declare function hooks(obj: O | (new (...args: any[]) => O), hookMap: HookMap | Middleware[]): O; /** * Decorate a class method with hooks. * @param manager The hooks settings */ export declare function hooks(manager?: HookOptions): any;