iteration.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { NodeConnectionTypes, type INodeType, type INodeDataBaseSchema } from '../Interface'
  2. export type IterationData = INodeDataBaseSchema & {
  3. /**
  4. * 错误处理模式
  5. * terminated: 终止
  6. * continue-on-error: 出错继续
  7. * remove-abnormal-output: 移除异常输出
  8. */
  9. error_handle_mode: 'terminated' | 'continue-on-error' | 'remove-abnormal-output'
  10. /**
  11. * 是否并行
  12. */
  13. is_parallel: boolean
  14. /**
  15. * 并行数量
  16. */
  17. parallel_nums: number
  18. /**
  19. * 扁平化输出
  20. */
  21. flatten_output: boolean
  22. /**
  23. * 开始节点id
  24. */
  25. start_node_id: string
  26. /**
  27. * 迭代输出变量
  28. */
  29. output_iteration_variable: Array<{
  30. name: string
  31. describe: string
  32. type:
  33. | 'string'
  34. | 'number'
  35. | 'boolean'
  36. | 'object'
  37. | 'array[string]'
  38. | 'array[number]'
  39. | 'array[boolean]'
  40. | 'array[object]'
  41. value: any
  42. value_type?: 'constant' | 'variable'
  43. }>
  44. }
  45. export const iterationNode: INodeType = {
  46. version: ['1'],
  47. displayName: '迭代',
  48. name: 'iteration',
  49. description: '迭代节点',
  50. group: '业务逻辑',
  51. icon: 'lucide:repeat-2',
  52. iconColor: '#9373ee',
  53. inputs: [NodeConnectionTypes.main],
  54. outputs: [NodeConnectionTypes.main],
  55. // 业务数据
  56. schema: {
  57. appAgentId: '',
  58. parentId: '',
  59. position: {
  60. x: 20,
  61. y: 30
  62. },
  63. width: 96,
  64. height: 96,
  65. selected: false,
  66. nodeType: 'iteration',
  67. zIndex: 1,
  68. data: {}
  69. }
  70. }