utils.mock.ts 2.7 KB

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