import { Injectable, InjectableClass, Service } from './utils'; export interface Provider { $get(...args: any[]): any; } export interface ProviderClass { new ($injector: Injector, serviceName: string): Provider; } export declare type InjectorLocals = { [name: string]: any; }; /** * */ export declare class Injector { private services; /** * */ constructor(); /** * This method invoke the given injectable applying right parameters based on their name * @param injectable A function to be invoked * @param self An object to which the injectable function will be bind to * @param locals Additional one-time services that will be injected into the injectable * @return The return value of injectable */ invoke(injectable: Injectable, self?: any, locals?: any): any; /** * Call new operator on the given injectableClass proving the controller with the right parameters. * @info injectableClass.$inject MUST be an array * @param injectableClass A injectable class * @param locals Additional variables that will be injected * @returns A new instance of injectableClass */ instantiate(injectableClass: InjectableClass, locals?: any): any; /** * This method lift a classic function to an injectable function. * @example * let middleware = (service1, req, res, nex) => console.log(service1, req, res, next) * let liftedMiddleware = $injector.lift(middleware, ["req", "res", "next"]); * app.use(liftedMiddleware) OR liftedMiddleware(req, res, next( * @param injectable The function you want to lift * @param self An object to which the injectable function will be bind to * @param paramNames the name of the parameter lift will received so they can be injected. * @param locals Additional variables that will be injected * @return {Function} The lifted function */ lift(injectable: Injectable, self?: any, paramNames?: string[], locals?: InjectorLocals): (...args: any[]) => any; /** * @param serviceName The name of the service * @param locals Additional variables that will be injected * @returns The service instance * @throws The service must exist * @private */ getService(serviceName: string, locals?: any): Service; /** * Add a child injector * @param $injector The child injector * @return {Injector} this */ addChild($injector: Injector): Injector; addProvider(serviceName: string, providerClass: ProviderClass): Injector; /** * @param serviceName The service name * @returns the provider * @private */ private _getProvider(serviceName); private _resolveFunctionInjectable(injectable, self); private _resolveArrayInjectable(injectable, self); private _resolveStringInjectable(injectable, self); /** * */ private _resolveInjectable(injectable, self); }