Interface.ts 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. import type { XYPosition } from '@repo/workflow'
  2. import type { FormItemRule } from 'element-plus'
  3. import type { VNode } from 'vue'
  4. /**
  5. * 渲染回调参数
  6. */
  7. export interface RenderCallbackParams {
  8. [key: string]: any
  9. }
  10. /**
  11. * 表单项配置模型
  12. */
  13. export interface ConfigSchema {
  14. // 其他未明确指定的属性
  15. [fieldName: string]: any
  16. /**
  17. * 子节点列表,可选
  18. */
  19. children?: ConfigSchema[]
  20. /**
  21. * 表单控件属性,可选
  22. * @example { type: 'input', options: [{ label: '用户名', value: 'username' }] }
  23. */
  24. componentProps?: any
  25. /**
  26. * 节点字段path,可选 获取参考lodash get方法
  27. * @example 'data.username'
  28. */
  29. field?: string
  30. // 是否为表单输入组件,可选
  31. input?: boolean
  32. // 节点标签,可选
  33. label?: string
  34. /**
  35. * 是否在物料库中隐藏
  36. */
  37. hideInLibary?: boolean
  38. /**
  39. * 标签配置
  40. */
  41. labelConfig?: {
  42. /**
  43. * 宽度,可选
  44. */
  45. width?: number
  46. /**
  47. * 是否显示,可选
  48. */
  49. show?: boolean
  50. /**
  51. * 位置,可选
  52. */
  53. position?: 'top' | 'left'
  54. /**
  55. * 配置提示
  56. */
  57. tooltip?: string
  58. }
  59. // 是否无需表单项,可选
  60. noFormItem?: boolean
  61. // 事件绑定
  62. // 表单验证规则,可选
  63. rules?: FormItemRule[]
  64. // 是否显示(属性编辑组件可以添加函数动态显示隐藏),可选
  65. show?: ((renderCallbackParams: RenderCallbackParams) => boolean) | boolean
  66. // 插槽名称(组件为插槽类型时,需要设置插槽name),可选
  67. slotName?: string
  68. // 插槽列表,可选
  69. slots?: { [slotName: string]: ConfigSchema[] }
  70. /**
  71. * 节点类型,必选
  72. * @example 'text' | 'textarea' | 'select' | 'checkbox' | 'radio' | 'switch' | 'date' | 'time' | 'datetime' | 'color' | 'file' | 'image' | 'video' | 'audio' | 'range' | 'number' | 'password' | 'hidden' | 'button' | 'reset' | 'submit' | 'html' | 'custom'
  73. */
  74. valueType: string
  75. // 渲染表单项
  76. render?: (renderCallbackParams: RenderCallbackParams) => Element
  77. // 渲染组件
  78. renderItem?: (renderCallbackParams: RenderCallbackParams) => Element
  79. }
  80. type EndpointType = string | { type: string; label: string; id: string }
  81. export interface INodeType {
  82. /**
  83. * 版本信息
  84. */
  85. version: string[]
  86. /**
  87. * 所属分组
  88. */
  89. group?: 'start' | 'logic' | 'data' | 'tool' | 'other'
  90. /**
  91. * 展示名称
  92. */
  93. displayName: string
  94. /**
  95. * 名称
  96. */
  97. name: string
  98. /**
  99. * 副标题 带格式化信息
  100. */
  101. subtitle?: string
  102. /**
  103. * 描述
  104. */
  105. description?: string
  106. /**
  107. * 节点图标 默认使用iconify图标名称
  108. * @example 'mdi:home'
  109. * 参考 https://icon-sets.iconify.design/
  110. */
  111. icon?: string
  112. /**
  113. * 图标颜色
  114. */
  115. iconColor?: string
  116. /**
  117. * 输入端口列表
  118. */
  119. inputs: EndpointType[] | ((params: any) => EndpointType[])
  120. /**
  121. * 输出端口列表
  122. */
  123. outputs: EndpointType[] | ((params: any) => EndpointType[])
  124. /**
  125. * 隐藏显示工具栏
  126. */
  127. hideToolBar?: boolean
  128. /**
  129. * 输出端口名称
  130. */
  131. schema: {
  132. // 流程id
  133. appAgentId?: string
  134. // 父级节点Id
  135. parentId?: string
  136. // 节点位置
  137. position: XYPosition
  138. // 节点宽度
  139. width: number
  140. // 节点高度
  141. height: number
  142. // 当前是否选中
  143. selected: boolean
  144. // 节点类型
  145. nodeType: string
  146. // 节点层级
  147. zIndex: number
  148. // 节点业务数据 存储配置等
  149. data: Record<string, any>
  150. }
  151. /**
  152. * 表单配置
  153. */
  154. formConfig?: ConfigSchema[]
  155. /**
  156. * 节点自定义渲染
  157. */
  158. render?: (renderCallbackParams: RenderCallbackParams) => Element | VNode
  159. /**
  160. * 配置校验
  161. */
  162. validate?: (data: any) => boolean | string | Promise<boolean | string>
  163. /**
  164. * 节点副标题
  165. */
  166. getSubtitle?: (data: any) => string | Promise<string> | undefined
  167. // 其他配置
  168. [key: string]: any
  169. }
  170. /**
  171. * 节点连接类型
  172. */
  173. export const NodeConnectionTypes = {
  174. main: 'main'
  175. }
  176. /**
  177. * 节点变量类型
  178. */
  179. export type NodeVariableType =
  180. | 'string'
  181. | 'number'
  182. | 'boolean'
  183. | 'object'
  184. | 'array[string]'
  185. | 'array[number]'
  186. | 'array[boolean]'
  187. | 'array[object]'
  188. | 'array[file]'
  189. /**
  190. * 节点变量值类型
  191. */
  192. export type NodeVariableValueType = 'constant' | 'variable'
  193. /**
  194. * 节点变量
  195. */
  196. export interface NodeVariable {
  197. name: string
  198. describe?: string
  199. type?: NodeVariableType
  200. value?: any
  201. value_type?: NodeVariableValueType
  202. }
  203. /**
  204. * 节点重试配置
  205. */
  206. export interface NodeRetryConfig {
  207. retry_enabled: boolean
  208. max_retries: number
  209. retry_interval: number // milliseconds
  210. }
  211. /**
  212. * 节点错误处理策略
  213. */
  214. export type NodeErrorStrategy = 'none' | 'default-value' | 'fail-branch'
  215. /**
  216. * 节点类型
  217. */
  218. export type NodeType =
  219. | 'http-request'
  220. | 'code'
  221. | 'if-else'
  222. | 'iteration'
  223. | 'iteration-start'
  224. | 'list-operator'
  225. | 'loop'
  226. | 'loop-start'
  227. | 'end'
  228. | string
  229. /**
  230. * 节点公共配置信息
  231. */
  232. export interface INodeDataBaseSchema {
  233. /**
  234. * 节点类型
  235. */
  236. type: NodeType
  237. /**
  238. * 标题
  239. */
  240. title: string
  241. /**
  242. * 是否在迭代中
  243. */
  244. isInIteration: boolean
  245. /**
  246. * 迭代id
  247. */
  248. iteration_id: string
  249. /**
  250. * 是否在循环中
  251. */
  252. isInLoop: boolean
  253. /**
  254. * 循环id
  255. */
  256. loop_id: string
  257. /**
  258. * 输入变量列表
  259. */
  260. variables: NodeVariable[]
  261. /**
  262. * 重试配置
  263. */
  264. retry_config: NodeRetryConfig
  265. /**
  266. * 错误处理策略
  267. */
  268. error_strategy: NodeErrorStrategy
  269. /**
  270. * 失败分支节点id
  271. */
  272. fail_branch_node_id: string
  273. /**
  274. * 默认值
  275. */
  276. default_value: NodeVariable[]
  277. /**
  278. * 输出变量是否可修改
  279. */
  280. output_can_alter: boolean
  281. /**
  282. * 输出变量列表
  283. */
  284. outputs: NodeVariable[]
  285. /**
  286. * 节点id
  287. */
  288. id?: string
  289. }
  290. /**
  291. * 条件项类型
  292. */
  293. export interface ConditionType {
  294. /**
  295. * 比较操作符
  296. * 可选值: contains, not_contains, start_with, end_with, is, is_not, empty, not_empty, =, !=, >, <, ≥, ≤, all_of
  297. */
  298. comparison_operator:
  299. | 'contains'
  300. | 'not_contains'
  301. | 'start_with'
  302. | 'end_with'
  303. | 'is'
  304. | 'is_not'
  305. | 'empty'
  306. | 'not_empty'
  307. | '='
  308. | '!='
  309. | '>'
  310. | '<'
  311. | '≥'
  312. | '≤'
  313. | 'all_of'
  314. /**
  315. * 左值,支持常量或#{}方式的动态变量
  316. */
  317. left_value: string
  318. /**
  319. * 右值,支持常量或#{}方式的动态变量
  320. */
  321. right_value: string
  322. /**
  323. * 右值列表,预留
  324. */
  325. right_value_list?: string[]
  326. /**
  327. * 变量类型
  328. * 可选值: string | number | boolean | object | array[string] | array[number] | array[boolean] | array[object] | array[file]
  329. */
  330. varType:
  331. | 'string'
  332. | 'number'
  333. | 'boolean'
  334. | 'object'
  335. | 'array[string]'
  336. | 'array[number]'
  337. | 'array[boolean]'
  338. | 'array[object]'
  339. | 'array[file]'
  340. }
  341. /**
  342. * 文件类型
  343. */
  344. export interface FileType {
  345. id: string
  346. name: string
  347. extensionName: string
  348. size: number
  349. path: string
  350. }
  351. /**
  352. * 文本类型
  353. */
  354. export interface TextType {
  355. id: string
  356. parentId: string
  357. isRoot: boolean
  358. path: string
  359. text: string
  360. value: string
  361. displayOrder: number
  362. }
  363. /**
  364. * 输出视图数据
  365. * view-data-output
  366. */
  367. export interface ViewDataOutput {
  368. viewTable: [] // "数据列表",
  369. viewName: string // "视图名称",
  370. totalCount: number // "数据总数",
  371. }