StoragesModule.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { ContainerModule, interfaces } from 'inversify';
  2. import { ServiceIdentifiers } from '../../ServiceIdentifiers';
  3. import { TControlFlowStorage } from '../../../types/storages/TControlFlowStorage';
  4. import { TCustomNodeGroupStorage } from '../../../types/storages/TCustomNodeGroupStorage';
  5. import { TStringArrayStorage } from '../../../types/storages/TStringArrayStorage';
  6. import { ControlFlowStorage } from '../../../storages/control-flow/ControlFlowStorage';
  7. import { CustomNodeGroupStorage } from '../../../storages/custom-node-group/CustomNodeGroupStorage';
  8. import { StringArrayStorage } from '../../../storages/string-array/StringArrayStorage';
  9. export const storagesModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
  10. // storages
  11. bind<TCustomNodeGroupStorage>(ServiceIdentifiers.TCustomNodeGroupStorage)
  12. .to(CustomNodeGroupStorage)
  13. .inSingletonScope();
  14. bind<TStringArrayStorage>(ServiceIdentifiers.TStringArrayStorage)
  15. .to(StringArrayStorage)
  16. .inSingletonScope();
  17. bind<interfaces.Newable<TControlFlowStorage>>(ServiceIdentifiers.Newable__TControlFlowStorage)
  18. .toConstructor(ControlFlowStorage);
  19. // controlFlowStorage factory
  20. bind<TControlFlowStorage>(ServiceIdentifiers.Factory__TControlFlowStorage)
  21. .toFactory<TControlFlowStorage>((context: interfaces.Context) => {
  22. return () => {
  23. const constructor: interfaces.Newable<TControlFlowStorage> = context.container
  24. .get<interfaces.Newable<TControlFlowStorage>>(ServiceIdentifiers.Newable__TControlFlowStorage);
  25. return new constructor();
  26. };
  27. });
  28. });