nope-js-node
Version:
NoPE Runtime for Nodejs. For Browser-Support please use nope-browser
136 lines (135 loc) • 4.97 kB
TypeScript
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
* @desc [description]
*/
import { Container, interfaces } from "inversify";
import "reflect-metadata";
import { IexportAsNopeServiceParameters } from "../decorators";
import { INopeDispatcher } from "../types/nope/nopeDispatcher.interface";
import { INopeModule } from "../types/nope/nopeModule.interface";
import { IClassDescriptor, INopeActivationHanlder, IPackageDescription } from "../types/nope/nopePackage.interface";
import { INopePackageLoader } from "../types/nope/nopePackageLoader.interface";
/**
* Helper Class to Build an inversify Container.
*
* @export
* @class NopePackageLoader
* @implements {INopePackageLoader}
*/
export declare class NopePackageLoader implements INopePackageLoader {
/**
* Array containing multipl Activation Handlers
*
* @protected
* @memberof NopePackageLoader
*/
protected _actionHandlers: Map<string, INopeActivationHanlder>;
_logger: import("js-logger").ILogger;
get activationHandlers(): INopeActivationHanlder[];
/**
* Adds an Activation Handler. (Those are called, after an Object has been created)
*
* @param {(context: interfaces.Context, element: any) => any} func The Corresponding Method which will be called.
* @memberof NopePackageLoader
*/
addActivationHandler(func: INopeActivationHanlder | Array<INopeActivationHanlder>): Promise<void>;
private _dispatcher;
get dispatcher(): INopeDispatcher;
/**
* Adds the Container to the given Container.
*
* @param {Container} container the Container, that should be merged
* @memberof NopePackageLoader
*/
addContainers(container: Container): void;
/**
* Function which will perform all Activation Handlers.
*
* @protected
* @param {interfaces.Context} _context
* @param {*} _element
* @returns
* @memberof NopePackageLoader
*/
protected _onActivation(_context: interfaces.Context, _element: any): any;
availableElements: IClassDescriptor[];
protected _compareElements(_a: IClassDescriptor, _b: IClassDescriptor): boolean;
/**
* Internal Method to Test, whether an Element exists or not.
*
* @protected
* @param {IClassDescriptor} _item
* @return {*} {boolean}
* @memberof NopePackageLoader
*/
protected _hasElement(_item: IClassDescriptor): boolean;
/**
* Method to add an Element to the Build
*
* @param {IClassDescriptor[]} _elements Definition containing the Elements that should be added
* @memberof NopePackageLoader
*/
addDescription(_elements: IClassDescriptor[], _instance?: NopePackageLoader | null): Promise<void>;
/**
* Internal Helper Function to Merge an external Builder for creating Tasks.
*
* @protected
* @param {IClassDescriptor} _element
* @param {NopePackageLoader} _instance
* @memberof NopePackageLoader
*/
protected _linkExternalBuilder(_element: IClassDescriptor, _instance: NopePackageLoader): void;
/**
* Internal Funcitont to add an Description.
*
* @protected
* @param {IClassDescriptor} _element
* @memberof NopePackageLoader
*/
protected _addElement(_element: IClassDescriptor): void;
/**
* The Inversify-Container see https://github.com/inversify/InversifyJS
*
* @type {Container}
* @memberof NopePackageLoader
*/
container: Container;
reset(): Promise<void>;
constructor();
packages: {
[index: string]: IPackageDescription<any>;
};
protected _instances: Map<string | symbol, number>;
/**
* Loader Function. This function will register all provided functions,
* create the desired instances. Additionally it will add all descriptors.
*
* @param {IPackageDescription<any>} element
* @memberof NopePackageLoader
*/
addPackage(element: IPackageDescription<any>): Promise<void>;
/**
* Function to initialize all the instances.
*
* @param {boolean} [testRequirements=true]
* @memberof NopePackageLoader
*/
generateInstances(testRequirements?: boolean): Promise<void>;
/**
* Helper to provide all linked services.
*/
provideLinkedServices(): Promise<void>;
/**
* Function to load all decorated elements with the decorators `exportAsNopeService`
*
* @param options
*/
addDecoratedElements(options?: {
addServiceCallback?: (options: IexportAsNopeServiceParameters) => Promise<boolean>;
addClassCallback?: (options: INopeModule) => Promise<boolean>;
consider?: Array<"services" | "classes">;
}): Promise<void>;
protected _disposeDefaultInstance: Array<() => Promise<void>>;
dispose(): Promise<void>;
}