DomainLockCustomNodesFactory.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { ICustomNode } from '../../../interfaces/custom-nodes/ICustomNode';
  2. import { DomainLockNode } from '../DomainLockNode';
  3. import { NodeCallsControllerFunctionNode } from '../../node-calls-controller-nodes/NodeCallsControllerFunctionNode';
  4. import { AbstractCustomNodesFactory } from '../../AbstractCustomNodesFactory';
  5. import { NodeAppender } from '../../../node/NodeAppender';
  6. import { Utils } from '../../../Utils';
  7. export class DomainLockCustomNodesFactory extends AbstractCustomNodesFactory {
  8. /**
  9. * @returns {Map<string, ICustomNode> | undefined}
  10. */
  11. public getNodes (): Map <string, ICustomNode> | undefined {
  12. if (!this.options.domainLock.length) {
  13. return;
  14. }
  15. const callsControllerFunctionName: string = Utils.getRandomVariableName();
  16. const randomStackTraceIndex: number = NodeAppender.getRandomStackTraceIndex(this.stackTraceData.length);
  17. return this.syncCustomNodesWithNodesGroup(new Map <string, ICustomNode> ([
  18. [
  19. 'DomainLockNode',
  20. new DomainLockNode(
  21. this.stackTraceData,
  22. callsControllerFunctionName,
  23. randomStackTraceIndex,
  24. this.options
  25. )
  26. ],
  27. [
  28. 'DomainLockNodeCallsControllerFunctionNode',
  29. new NodeCallsControllerFunctionNode(
  30. this.stackTraceData,
  31. callsControllerFunctionName,
  32. randomStackTraceIndex,
  33. this.options
  34. )
  35. ]
  36. ]));
  37. }
  38. }