flow.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. import { File } from 'buffer';
  2. import { Node } from 'reactflow';
  3. export type FlowState = 'deployed' | 'developing' | 'initializing' | 'testing' | 'disabled' | 'running' | 'load_failed';
  4. export type IFlowUpdateParam = {
  5. name: string;
  6. label: string;
  7. editable: boolean;
  8. deploy?: boolean;
  9. description?: string;
  10. uid?: string;
  11. flow_data?: IFlowData;
  12. state?: FlowState;
  13. variables?: IVariableItem[];
  14. };
  15. export type IFlowRefreshParams = {
  16. id: string;
  17. type_name: string;
  18. type_cls: string;
  19. flow_type: 'resource' | 'operator';
  20. refresh: {
  21. name: string;
  22. depends?: Array<{
  23. name: string;
  24. value: any;
  25. has_value: boolean;
  26. }>;
  27. }[];
  28. };
  29. export type IFlow = {
  30. dag_id: string;
  31. gmt_created: string;
  32. uid: string;
  33. name: string;
  34. label: string;
  35. editable: boolean;
  36. description: string;
  37. flow_data: IFlowData;
  38. source: string;
  39. gmt_modified?: string;
  40. admins?: string[];
  41. nick_name: string;
  42. state?: FlowState;
  43. error_message?: string;
  44. };
  45. export interface IFlowResponse {
  46. items: IFlow[];
  47. total_count: number;
  48. total_pages: number;
  49. page: number;
  50. page_size: number;
  51. }
  52. export type IFlowNodeParameter = {
  53. id: string;
  54. type_name: string;
  55. type_cls: string;
  56. label: string;
  57. name: string;
  58. category: string;
  59. optional: boolean;
  60. default?: any;
  61. placeholder?: any;
  62. description: string;
  63. options?: any;
  64. value: any;
  65. is_list?: boolean;
  66. ui: IFlowNodeParameterUI;
  67. };
  68. export type IFlowNodeParameterUI = {
  69. ui_type: string;
  70. language: string;
  71. file_types: string;
  72. action: string;
  73. attr: {
  74. disabled: boolean;
  75. [key: string]: any;
  76. };
  77. editor?: {
  78. width: number;
  79. height: number;
  80. };
  81. show_input?: boolean;
  82. refresh?: boolean;
  83. refresh_depends?: string[];
  84. };
  85. export type IFlowNodeInput = {
  86. type_name: string;
  87. type_cls: string;
  88. label: string;
  89. name: string;
  90. description: string;
  91. id: string;
  92. optional?: boolean | undefined;
  93. value: any;
  94. is_list?: boolean;
  95. };
  96. export type IFlowNodeOutput = {
  97. type_name: string;
  98. type_cls: string;
  99. label: string;
  100. name: string;
  101. description: string;
  102. id: string;
  103. optional?: boolean | undefined;
  104. is_list?: boolean;
  105. };
  106. export type IFlowNode = Node & {
  107. type_name: string;
  108. type_cls: string;
  109. parent_cls?: string; // resource have this key
  110. label: string;
  111. name: string;
  112. description: string;
  113. category: string;
  114. category_label: string;
  115. flow_type: 'resource' | 'operator';
  116. icon?: string;
  117. documentation_url?: null;
  118. id: string;
  119. tags?: any;
  120. parameters: Array<IFlowNodeParameter>;
  121. inputs: Array<IFlowNodeInput>;
  122. outputs: Array<IFlowNodeOutput>;
  123. version: string;
  124. invalid?: boolean;
  125. };
  126. interface Position {
  127. x: number;
  128. y: number;
  129. zoom: number;
  130. }
  131. // flodata, the data of the flow
  132. export type IFlowDataNode = {
  133. width: number;
  134. height: number;
  135. id: string;
  136. position: Position;
  137. position_absolute?: Position;
  138. positionAbsolute?: Position;
  139. data: IFlowNode;
  140. type: string;
  141. };
  142. export type IFlowDataEdge = {
  143. source: string;
  144. target: string;
  145. source_handle?: string;
  146. sourceHandle?: string;
  147. target_handle?: string;
  148. targetHandle?: string;
  149. id: string;
  150. type: string;
  151. };
  152. export type IFlowDataViewport = {
  153. x: number;
  154. y: number;
  155. zoom: number;
  156. };
  157. export type IFlowData = {
  158. nodes: IFlowDataNode[];
  159. edges: IFlowDataEdge[];
  160. variables?: IVariableItem[];
  161. viewport: IFlowDataViewport;
  162. };
  163. export type IFlowExportParams = {
  164. uid: string;
  165. export_type?: 'json' | 'dbgpts';
  166. format?: 'json' | 'file';
  167. file_name?: string;
  168. user_name?: string;
  169. sys_code?: string;
  170. };
  171. export type IFlowImportParams = {
  172. file: File;
  173. save_flow?: boolean;
  174. };
  175. export type IUploadFileRequestParams = {
  176. files: Array<File>;
  177. user_name?: string;
  178. sys_code?: string;
  179. };
  180. export type IUploadFileResponse = {
  181. file_name: string;
  182. file_id: string;
  183. bucket: string;
  184. uri?: string;
  185. };
  186. export type IGetKeysRequestParams = {
  187. user_name?: string;
  188. sys_code?: string;
  189. category?: string;
  190. };
  191. export type IGetKeysResponseData = {
  192. key: string;
  193. label: string;
  194. description: string;
  195. value_type: string;
  196. category: string;
  197. scope: string;
  198. scope_key: string | null;
  199. };
  200. export type IGetVariablesByKeyRequestParams = {
  201. key: string;
  202. scope: string;
  203. scope_key?: string;
  204. user_name?: string;
  205. sys_code?: string;
  206. page?: number;
  207. page_size?: number;
  208. };
  209. export type IGetVariablesByKeyResponseData = {
  210. items: IVariableItem[];
  211. total_count: number;
  212. total_pages: number;
  213. page: number;
  214. page_size: number;
  215. };
  216. export type IVariableItem = {
  217. key: string;
  218. label: string;
  219. description: string | null;
  220. value_type: string;
  221. category: string;
  222. scope: string;
  223. scope_key: string | null;
  224. name: string;
  225. value: string;
  226. enabled: boolean;
  227. user_name: string | null;
  228. sys_code: string | null;
  229. id: number;
  230. [key: string]: any;
  231. };