loop.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { NodeConnectionTypes, type INodeType, type INodeDataBaseSchema } from '../Interface'
  2. export type LoopData = INodeDataBaseSchema & {
  3. /**
  4. * 循环次数
  5. */
  6. loop_count: number
  7. /**
  8. * 循环终止条件
  9. */
  10. break_conditions: Array<{
  11. comparison_operator:
  12. | 'contains'
  13. | 'not_contains'
  14. | 'start_with'
  15. | 'end_with'
  16. | 'is'
  17. | 'is_not'
  18. | 'empty'
  19. | 'not_empty'
  20. | '='
  21. | '!='
  22. | '>'
  23. | '<'
  24. | '≥'
  25. | '≤'
  26. | 'all_of'
  27. left_value: string
  28. right_value: string
  29. varType:
  30. | 'string'
  31. | 'number'
  32. | 'boolean'
  33. | 'object'
  34. | 'array[string]'
  35. | 'array[number]'
  36. | 'array[boolean]'
  37. | 'array[object]'
  38. }>
  39. /**
  40. * 逻辑操作(and/or)
  41. */
  42. logical_operator: 'and' | 'or'
  43. /**
  44. * 开始节点id
  45. */
  46. start_node_id: string
  47. /**
  48. * 错误处理模式(terminated/continue-on-error/remove-abnormal-output)
  49. */
  50. error_handle_mode: 'terminated' | 'continue-on-error' | 'remove-abnormal-output'
  51. }
  52. export const loopNode: INodeType = {
  53. version: ['1'],
  54. displayName: '循环',
  55. name: 'loop',
  56. description: '循环节点',
  57. group: '业务逻辑',
  58. icon: 'lucide:loop',
  59. iconColor: '#9373ee',
  60. inputs: [NodeConnectionTypes.main],
  61. outputs: [NodeConnectionTypes.main],
  62. // 业务数据
  63. schema: {
  64. appAgentId: '',
  65. parentId: '',
  66. position: {
  67. x: 20,
  68. y: 30
  69. },
  70. width: 96,
  71. height: 96,
  72. selected: false,
  73. nodeType: 'loop',
  74. zIndex: 1,
  75. data: {}
  76. }
  77. }