@villedemontreal/workit-core
Version:
This package provides default and no-op implementations of the WorkIt types for client packages.
75 lines (74 loc) • 3.17 kB
TypeScript
import { IIoC } from '@villedemontreal/workit-types';
import { Container } from 'inversify';
export { Container };
/**
* Useful IOC (Inversion Of Control)
* CORE identifier (aka name param in static method) use the following enum: SERVICE_IDENTIFIER
*/
export declare class IOC implements IIoC {
static charSplit: string;
private readonly _container;
constructor(container: Container);
/**
* return false if there is nothing to unbind
*/
unbind(name: string | symbol): boolean;
isServiceBound(serviceIdentifier: symbol | string, name?: string): boolean;
/**
* Bind your Class to a SERVICE_IDENTIFIER
*
* @param {*} ctor Constructor
* @param {(string | symbol)} serviceIdentifier
* @param {((symbol | string)[])} [dependencies]
* @param {(string | symbol | null)} [named]
* @param {boolean} [singletonMode=true] default true.
*/
bindTo(ctor: new (...args: any[]) => unknown, serviceIdentifier: string | symbol, dependencies?: (symbol | string)[], named?: string | symbol | null, singletonMode?: boolean): void;
bindToAsDefault(ctor: new (...args: any[]) => unknown, serviceIdentifier: string | symbol, dependencies?: (symbol | string)[]): void;
bindToObject(obj: any, serviceIdentifier: symbol | string, named?: string): void;
/**
* @deprecated
* Bind your Class to a SERVICE_IDENTIFIER
* This method doesn't support dependencies
* @template T
* @param {string} serviceIdentifier
* @param {*} ctor contstructor
* @param {string} targetNamed
* @param {boolean} [singletonMode=true] default true
* @memberof IoC
*/
bind<T = any>(serviceIdentifier: string, ctor: new (...args: any[]) => T, targetNamed: string, singletonMode?: boolean): void;
get<T>(serviceIdentifier: symbol | string, named?: string | symbol): T;
/**
* Useful for getting task instance for a specific workflow.
* It can check if there is a task for a specific workflow version or it will rollback to the serviceIdentifier if nothing is boundNamed.
* Otherwise it will throw an error
*/
getTask<T = any>(serviceIdentifier: symbol | string, workflow?: {
bpmnProcessId: string;
version: number;
}): T;
bindTask(ctor: new (...args: any[]) => unknown, serviceIdentifier: string | symbol, workflow: {
bpmnProcessId: string;
version?: number;
}, dependencies?: (symbol | string)[], singletonMode?: boolean): void;
getWorkflowNamed(workflow: {
bpmnProcessId: string;
version?: number;
}): string;
/**
* Warning: You should not use this or you know what you are doing.
* Container is exposed for avoiding to block developpers.
* Container is Inversify Object.
* If you need to use it, please create a ticket on Github and describe your use case.
* @memberof IoC
*/
getContainer(): Container;
/**
* Seems Hacky, we should look to use inversify factory in order to inject config and then override.
*
*/
private static _overrideConfig;
private static _inject;
private static _validateWorkflow;
}