utils.mock.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import { interfaces } from 'inversify';
  6. import {
  7. WorkflowJSON,
  8. WorkflowDocumentContainerModule,
  9. WorkflowLinesManager,
  10. WorkflowSimpleLineContribution,
  11. } from '@flowgram.ai/free-layout-core';
  12. import { FlowDocumentContainerModule } from '@flowgram.ai/document';
  13. import { PlaygroundMockTools } from '@flowgram.ai/core';
  14. export function createWorkflowContainer(): interfaces.Container {
  15. const container = PlaygroundMockTools.createContainer([
  16. FlowDocumentContainerModule,
  17. WorkflowDocumentContainerModule,
  18. ]);
  19. const linesManager = container.get(WorkflowLinesManager);
  20. linesManager.registerContribution(WorkflowSimpleLineContribution);
  21. linesManager.switchLineType(WorkflowSimpleLineContribution.type);
  22. return container;
  23. }
  24. export const workflowJSON: WorkflowJSON = {
  25. nodes: [
  26. {
  27. id: 'start_0',
  28. type: 'start',
  29. meta: {
  30. position: { x: 0, y: 0 },
  31. testRun: {
  32. showError: undefined,
  33. },
  34. },
  35. data: undefined,
  36. },
  37. {
  38. id: 'condition_0',
  39. type: 'condition',
  40. meta: {
  41. position: { x: 400, y: 0 },
  42. testRun: {
  43. showError: undefined,
  44. },
  45. },
  46. data: undefined,
  47. },
  48. {
  49. id: 'end_0',
  50. type: 'end',
  51. meta: {
  52. position: { x: 800, y: 0 },
  53. testRun: {
  54. showError: undefined,
  55. },
  56. },
  57. data: undefined,
  58. },
  59. {
  60. id: 'loop_0',
  61. type: 'loop',
  62. meta: {
  63. position: { x: 1200, y: 0 },
  64. testRun: {
  65. showError: undefined,
  66. },
  67. },
  68. data: undefined,
  69. blocks: [
  70. {
  71. id: 'break_0',
  72. type: 'break',
  73. meta: {
  74. position: { x: 0, y: 0 },
  75. testRun: {
  76. showError: undefined,
  77. },
  78. },
  79. data: undefined,
  80. },
  81. {
  82. id: 'variable_0',
  83. type: 'variable',
  84. meta: {
  85. position: { x: 400, y: 0 },
  86. testRun: {
  87. showError: undefined,
  88. },
  89. },
  90. data: undefined,
  91. },
  92. ],
  93. edges: [
  94. {
  95. sourceNodeID: 'break_0',
  96. targetNodeID: 'variable_0',
  97. },
  98. ],
  99. },
  100. ],
  101. edges: [
  102. {
  103. sourceNodeID: 'start_0',
  104. targetNodeID: 'condition_0',
  105. },
  106. {
  107. sourceNodeID: 'condition_0',
  108. sourcePortID: 'if',
  109. targetNodeID: 'end_0',
  110. },
  111. {
  112. sourceNodeID: 'condition_0',
  113. sourcePortID: 'else',
  114. targetNodeID: 'end_0',
  115. },
  116. {
  117. sourceNodeID: 'loop_0',
  118. targetNodeID: 'end_0',
  119. },
  120. {
  121. sourceNodeID: 'start_0',
  122. targetNodeID: 'loop_0',
  123. },
  124. ],
  125. };