import { ContainerModule, interfaces } from 'inversify'; import { ServiceIdentifiers } from '../../ServiceIdentifiers'; import { TControlFlowStorage } from '../../../types/storages/TControlFlowStorage'; import { TCustomCodeHelperGroupStorage } from '../../../types/storages/TCustomCodeHelperGroupStorage'; import { ILiteralNodesCacheStorage } from '../../../interfaces/storages/string-array-transformers/ILiteralNodesCacheStorage'; import { IOptions } from '../../../interfaces/options/IOptions'; import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator'; import { IStringArrayStorage } from '../../../interfaces/storages/string-array-transformers/IStringArrayStorage'; import { ControlFlowStorage } from '../../../storages/custom-nodes/ControlFlowStorage'; import { CustomCodeHelperGroupStorage } from '../../../storages/custom-code-helpers/CustomCodeHelperGroupStorage'; import { LiteralNodesCacheStorage } from '../../../storages/string-array-transformers/LiteralNodesCacheStorage'; import { StringArrayStorage } from '../../../storages/string-array-transformers/StringArrayStorage'; export const storagesModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => { // storages bind(ServiceIdentifiers.TCustomNodeGroupStorage) .to(CustomCodeHelperGroupStorage) .inSingletonScope(); bind(ServiceIdentifiers.ILiteralNodesCacheStorage) .to(LiteralNodesCacheStorage) .inSingletonScope(); bind(ServiceIdentifiers.IStringArrayStorage) .to(StringArrayStorage) .inSingletonScope(); bind>(ServiceIdentifiers.Newable__TControlFlowStorage) .toConstructor(ControlFlowStorage); // controlFlowStorage factory bind(ServiceIdentifiers.Factory__TControlFlowStorage) .toFactory((context: interfaces.Context) => { return (): TControlFlowStorage => { const constructor: interfaces.Newable = context.container .get>(ServiceIdentifiers.Newable__TControlFlowStorage); const randomGenerator: IRandomGenerator = context.container .get(ServiceIdentifiers.IRandomGenerator); const options: IOptions = context.container .get(ServiceIdentifiers.IOptions); const storage: TControlFlowStorage = new constructor(randomGenerator, options); storage.initialize(); return storage; }; }); });