import { HttpVerb } from './http-verbs'; /** * Middleware decorator parameter. */ export declare type MiddlewareParameter = Array | any; /** * Function that returns T. */ export declare type FunctionReturning = (...args: Array) => T; /** * A class or function returning T. */ export declare type ClassOrFunctionReturning = FunctionReturning | Constructor; /** * A class constructor. For example: * * class MyClass {} * * MyClass * ^^^^^^^ */ export declare type Constructor = { new (...args: any[]): T; }; /** * Target to instantiate and it's router state. */ export interface IStateAndTarget { /** * The target to call. */ target: Constructor | Function; /** * Routing state to configure. */ state: IRouterConfigState; } /** * Router config state. */ export interface IRouterConfigState { /** * Root config (class-level). */ root: IRouteConfig; /** * Method configs (method-level). */ methods: Map; } /** * A specific route config. */ export interface IRouteConfig { /** * Paths to register. */ paths: Array; /** * Middleware to run before the method. */ beforeMiddleware: Array; /** * Middleware to run after the method. */ afterMiddleware: Array; /** * HTTP verbs to register. */ verbs: Array; } /** * Method name type. */ export declare type MethodName = string | number | symbol | null; /** * Rolls up state so paths are joined, middleware rolled into * the correct order, etc. * * @param state */ export declare function rollUpState(state: IRouterConfigState): Map; /** * Given a decorated class or a controller builder, returns a normalized * target + state object. For example, if using the controller builder, * we need to use the `target` property. If using decorators, the required * value *is* the target. * * @param src * @returns The normalized target + state, or `null` if not applicable. */ export declare function getStateAndTarget(src: any): IStateAndTarget | null; /** * Adds a route to the state. * * @param state * @param methodName * @param path */ export declare function addRoute(state: IRouterConfigState, methodName: MethodName, path: string): IRouterConfigState; /** * Adds middleware that runs before the method on the specified config. * * @param state * @param methodName * @param middleware */ export declare function addBeforeMiddleware(state: IRouterConfigState, methodName: MethodName, middleware: MiddlewareParameter): IRouterConfigState; /** * Adds middleware that runs after the method on the specified config. * * @param state * @param methodName * @param middleware */ export declare function addAfterMiddleware(state: IRouterConfigState, methodName: MethodName, middleware: MiddlewareParameter): IRouterConfigState; /** * Adds middleware that runs after the method on the specified config. * * @param state * @param methodName * @param value */ export declare function addHttpVerbs(state: IRouterConfigState, methodName: MethodName, value: Array): IRouterConfigState; /** * Gets or creates a method config. * * @param state * @param methodName */ export declare function getOrCreateConfig(state: IRouterConfigState, methodName: MethodName): IRouteConfig; /** * Gets the config state from the target. * * @param target */ export declare function getState(target: any): IRouterConfigState | null; /** * Sets the config state on the target. * * @param target * @param state */ export declare function setState(target: any, state: IRouterConfigState): IRouterConfigState; /** * Updates the state on the specified target by invoking the callback with the previous state. * * @param target * @param updater */ export declare function updateState(target: any, updater: (state: IRouterConfigState) => IRouterConfigState): void; /** * Gets or initializes the state for a decorated target * * @param target * @param name */ export declare function getOrInitStateForDecoratorTarget(target: any): IRouterConfigState; /** * Creates a new state object. */ export declare function createState(): IRouterConfigState; /** * Updates a config on a state, returns the new state. * * @param state * Existing state. * * @param methodName * If null, updates the root config. Else, the method config. * * @param newConfig * Config to shallow-merge in. */ export declare function updateConfig(state: IRouterConfigState, methodName: MethodName, newConfig: Partial): IRouterConfigState; /** * Creates a new route config object. */ export declare function createRouteConfig(): IRouteConfig;