import { AxiosInstance, AxiosRequestConfig } from 'axios'; type NodeExecutionStatus = 'CREATED' | 'RUNNING' | 'FINISHED' | 'FAILED' | 'SUSPENDED' | 'REVOKED'; type PortOrientation = 'Top' | 'Right' | 'Bottom' | 'Left'; type GatewayType = 'ExclusiveGateway' | 'ParallelGateway' | 'ConditionalParallelGateway' | 'ConvergeGateway'; type NodeType = StartEvent | EndEvent | Activity | Gateway; interface PluginInputDataItem { value: | string | boolean | number | string[] | boolean[] | number[] | Record | Record; hook?: boolean; need_render?: boolean; } type ActivityComponentData = Record; interface ActivityComponent { code: string; data: ActivityComponentData; version: string; api_meta?: { id: string; name: string; alias?: string; meta_url: string; api_key: string; category: { id: string; name: string; }; }; } interface Activity { component: ActivityComponent; error_ignorable: boolean; id: string; incoming: string[]; name: string; stage_name?: string; outgoing: string; type: 'ServiceActivity'; retryable: boolean; skippable: boolean; auto_retry: { enable: boolean; interval: number; times: number; }; timeout_config: { enable: boolean; seconds: number; action: string; }; status?: NodeExecutionStatus; /** 执行态:实际重试次数 */ retry?: number; /** 执行态:是否被跳过 */ skip?: boolean; /** 执行态:是否自动忽略错误 */ error_ignored?: boolean; /** 执行态:循环执行次数 */ loop?: number; /** 执行态:生命周期阶段 */ phase?: number; } interface StartEvent { id: string; name: string; incoming: ''; outgoing: string; type: 'EmptyStartEvent'; labels: []; status?: NodeExecutionStatus; } interface EndEvent { id: string; name: string; incoming: string[]; outgoing: string; type: 'EmptyEndEvent'; labels: []; status?: NodeExecutionStatus; } interface GatewayCondition { name: string; tag: string; evaluate?: string; // 只有自定义分支需要 loc?: number; flow_id?: string; // 只有默认分支需要 } interface Gateway { id: string; name: string; incoming: string[]; outgoing: string[] | string; type: GatewayType; conditions?: Record; default_condition?: GatewayCondition; converge_gateway_id?: string; extra_info?: { parse_lang?: 'boolrule' | 'FEEL' | 'MAKO'; }; status?: NodeExecutionStatus; } interface Flow { id: string; is_default: boolean; source: string; target: string; } interface Location { id: string; type: | 'startpoint' | 'endpoint' | 'tasknode' | 'branchgateway' | 'convergegateway' | 'parallelgateway' | 'conditionalparallelgateway'; x: number; y: number; group?: string; icon?: string; name?: string; } interface Line { id: string; source: { arrow: PortOrientation; id: string; }; target: { arrow: PortOrientation; id: string; }; } interface Variable { custom_type: string; desc: string; index: number; key: string; name: string; show_type: 'show' | 'hide'; source_info: Record; source_tag: string; source_type: 'custom' | 'component_inputs' | 'component_outputs' | 'system' | 'space'; validation: string; value?: string | number | boolean | Record; version?: string; form_schema?: Record; pre_render_mako?: boolean; plugin_code?: string; } interface PipelineTree { activities: Record; end_event: EndEvent; flows: Record; gateways: Record; line: Line[]; location: Location[]; start_event: StartEvent; outputs: string[]; constants: Record; canvas_mode: 'horizontal'; canvas_version?: string; } // 通知配置 interface NotifyConfig { notify_type: { fail: string[]; success: string[]; }; notify_receivers: { more_receiver: string; receiver_group: string[]; }; } // 触发器 Cron 配置 interface TriggerCron { minute: string; hour: string; day_of_week: string; day_of_month: string; month_of_year: string; } // 触发器配置项 interface TriggerItem { id: number | null; name: string; type: string; is_enabled: boolean; is_deleted: boolean; space_id: number | string; template_id: number | string; config: { cron: TriggerCron; mode?: string; constants?: Record; [key: string]: any; }; isNewTrigger?: boolean; [key: string]: any; } // 流程模板基础配置 interface TemplateConfigs { name: string; desc: string; notify_config: NotifyConfig; triggers?: TriggerItem[]; } // 节点配置数据 interface NodeConfigData { id: string; type: string; name: string; status?: NodeExecutionStatus; component?: Record; error_ignorable?: boolean; isSkipped?: boolean; skippable?: boolean; can_retry?: boolean; retryable?: boolean; auto_retry?: { enable: boolean; }; create_method?: string; } // 变量引用统计 interface VariableReference { defined: Record< string, { activities: string; conditions: string[]; constants: string[]; } >; nodefined: Record< string, { activities: string; conditions: string[]; constants: string[]; } >; } // 值约束配置 interface ConditionConfig { enum?: (string | number | boolean)[]; range?: [number, number]; } // 输入参数字段配置(data._slots) interface SlotFieldConfig { name: string; desc: string; required: boolean; type: 'string' | 'integer' | 'float' | 'boolean'; role: 'timestamp' | 'feature' | string; } // 应用参数配置(predict_args._slots) interface SlotArgConfig { name: string; desc: string; required: boolean; type: 'string' | 'integer' | 'float' | 'boolean'; condition?: ConditionConfig; default?: string | number | boolean; } interface FlowTemplate { id: number; name: string; desc: string; notify_config: NotifyConfig; pipeline_tree: PipelineTree; extra_info: Record; triggers: TriggerItem[]; version: string; } interface FlowDetailByVersion { constants_not_referred: Record; name: string; outputs: Record; pipeline_tree: PipelineTree; version: string; } interface FlowDraftDetail { create_time: string; update_time: string; version: string | null; template_id: number; desc: string | null; draft: boolean; creator: string; operator: string; md5sum: string; pipeline_tree: PipelineTree; } interface FlowListItem { id: number; name: string; tag: string[]; desc: string; update_time: string; creator: string; update_at: string; } interface SpaceFlowConfig { gateway_expression?: 'boolrule' | 'FEEL' | 'MAKO'; uiform_api?: { api: Record; }; } interface UpdateFlowParams { name: string; desc: string; notify_config: NotifyConfig; pipeline_tree: PipelineTree; triggers: TriggerItem[]; } interface PluginGroupConfig { id: string; name: string; alias: string; properties: Record; iconUrl: string; } interface PluginMetaItem { alias: string; category: string; display_content: Record; group: string; id: string; meta_url: string; name: string; plugin_type: string; api_key?: string; version?: string; icon?: string; category_id: string; } interface BkflowThirdPartyPluginGroupItem { code_name: string; id: number; name: string; priority: number; } interface BkflowInnerPluginMetaItem { output: { name: string; key: string; type: string; schema: { type: string; description: string; enum: string[]; }; }[]; form: string; output_form: null; desc: string; form_is_embedded: boolean; group_name: string; group_icon: string; name: string; sort_key_group_en: string; code: string; version: string; is_default_version: boolean; } interface BkflowThirdPartyPluginMetaItem { code: string; name: string; tag: number; logo_url: string; created_time: string; updated_time: string; introduction: string; managers: string[]; extra_info: Record; } interface BkflowThirdPartyPluginMetaDetail { code: string; versions: string[]; language: string; description: string; framework_version: string; runtime_version: string; } interface BkflowThirdPartyPluginDetail { desc: string; version: string; inputs: { type: string; properties: Record; required: string[]; definitions: Record; }; outputs: { type: string; properties: Record; required: string[]; definitions: Record; }; forms: { renderform: string; }; app: BkflowThirdPartyPluginAppDetail; } interface BkflowThirdPartyPluginAppDetail { url: string; urls: string[]; name: string; code: string; updated: string; apigw_name: string; tag_info: { id: number; name: string; code_name: string; priority: number; }; } interface GroupsPluginItem extends PluginGroupConfig { children: (PluginMetaItem | BkflowThirdPartyPluginGroupItem)[]; } interface UniformApiPluginDetail { alias: string; bk_tenant_id: string; category: string; config: UniformApiPluginConfig; created_at: string; created_by: string; group: string; id: number; name: string; plugin_type: 'uniform_api'; url: string; methods: string[]; inputs: Record; outputs: string[]; scope_id: string; sign: string; updated_at: string; updated_by: string; credential_key?: string; polling?: Record; component_type?: string; } interface UniformApiPluginConfig { polling: string; callback: Record; resource: string; extra_config: { timeout: number; retry_times: number; instructions: Record; }; } interface UniformApiPluginInputsItem { desc: string; form_type?: string; key: string; name: string; required: boolean; type: string; default?: string | boolean | number | string[] | boolean[] | number[] | Record; _slots?: Record; options?: { value: string; text: string; }[]; } interface PluginOutputItem { description: string; key: string; type: string; name: string; } interface VariableRefRequestParams { activities: Record; constants: Record; gateways: Record; } interface CustomVariableType { name: string; form: string; type: string; tag: string; meta_tag: string | null; description: string; code: string; } /** * Flow API 配置接口 */ interface FlowApiConfig { /** API 基础路径 */ baseURL?: string; /** 自定义 axios 实例(可选,如果提供则优先使用) */ axiosInstance?: AxiosInstance; /** axios 配置(可选,用于创建新的 axios 实例) */ axiosConfig?: AxiosRequestConfig; /** CSRF cookie 名称(可选,用于创建新的 axios 实例时设置 xsrfCookieName) */ xsrfCookieName?: string; /** 作用域数据(必需,由外部传入) */ scopeData: { scope_type: string; scope_value: number; }; /** 用户查询 API 地址(可选) */ fetchUserApi?: string; /** 是否启用第三方插件(可选,默认为 true) */ enableThirdPlugin?: boolean; } interface DrawPipelineParams { pipeline_tree: PipelineTree; canvas_width: number; activity_size?: [number, number]; event_size?: [number, number]; gateway_size?: [number, number]; start?: [number, number]; } interface CreateFlowTaskParams { template_id: number; name: string; creator: string; constants: Record; label_ids?: number[]; [key: string]: unknown; } interface CreateFlowTaskResult { data: { id: number; template_id: number; [key: string]: unknown; }; [key: string]: unknown; } interface ExecuteFlowTaskResult { result?: boolean; code?: number; data?: { /** 任务详情页跳转地址(含正确的 bkflow task id 与 templateId) */ url?: string; [key: string]: unknown; }; message?: string | null; request_id?: string; trace_id?: string | null; [key: string]: unknown; } interface FlowViewApiConfig { fetchFlowDetail: (id: string) => Promise; fetchSpaceFlowConfig: (id: string) => Promise; fetchSystemVariables: (id: string) => Promise; fetchUserApi?: string; /** 作用域数据(必需,由外部传入) */ scopeData: { scope_type: string; scope_value: number; }; fetchFlowDraftDetail?: (id: string) => Promise; fetchFlowDetailByVersion?: (id: string, version: string) => Promise; fetchVariableRef?: (params: { template_id: number; activities: Record; constants: Record; gateways: Record; }) => Promise<{ data: VariableReference; }>; fetchCustomVariableTypes?: () => Promise<{ data: CustomVariableType[]; }>; fetchFlowOperateRecord?: (id: number) => Promise<{ data: { data: any[]; }; }>; createFlowTask?: (params: CreateFlowTaskParams) => Promise; executeFlowTask?: (params: { task_id: number; action: string; resource_type: string; resource_id: number; permission_type: string; }) => Promise; fetchControlConfig?: () => Promise>; checkSpaceConfig?: (scopeValue: number, params: { name: string; }) => Promise<{ value: string; }>; } interface FlowEditApiConfig extends FlowViewApiConfig { saveFlow: (id: string, params: UpdateFlowParams) => Promise; fetchBkFlowInnerPluginList: () => Promise; fetchBkFlowInnerPluginDetail: (code: string, version: string) => Promise; fetchInnerVariableDetail: (code: string) => Promise; fetchBkFlowThirdPartyPluginList: (tag: number) => Promise<{ data: { count: number; plugins: BkflowThirdPartyPluginMetaItem[]; }; }>; searchBkFlowThirdPartyPlugins?: (search_term: string) => Promise<{ data: { count: number; plugins: BkflowThirdPartyPluginMetaItem[]; }; }>; fetchBkFlowThirdPartyPluginTags: () => Promise; fetchBkFlowThirdPartyPluginMeta: (plugin_code: string) => Promise; fetchBkFlowThirdPartyPluginDetail: (plugin_code: string, plugin_version: string) => Promise; fetchBkFlowThirdPartyPluginAppDetail: (plugin_code: string, plugin_version: string) => Promise; fetchPluginGroupList: () => Promise; fetchCategoryPlugins: (category: string) => Promise; fetchAllPluginGroups: () => Promise; enableThirdPlugin?: boolean; fetchPluginDetail?: (id: string) => Promise; fetchApplyInstructionData?: (params: any) => Promise; drawPipeline?: (params: DrawPipelineParams) => Promise<{ pipeline_tree: PipelineTree; }>; createFlowTask?: (params: CreateFlowTaskParams) => Promise; executeFlowTask?: (params: { task_id: number; action: string; resource_type: string; resource_id: number; permission_type: string; }) => Promise; } declare const PLUGIN_GROUP_ICON_MAP: Record; /** * 使用 Flow API 的 composable * 返回所有 API 方法,兼容 FlowEditApiConfig 接口 */ declare function useFlowApi(config: FlowApiConfig): FlowEditApiConfig; export { PLUGIN_GROUP_ICON_MAP, useFlowApi }; export type { CustomVariableType, EndEvent, Flow, FlowEditApiConfig, FlowListItem, FlowViewApiConfig, GatewayType, Line, Location, NodeConfigData, NodeType, NotifyConfig, PluginGroupConfig, PluginOutputItem, PortOrientation, StartEvent, TemplateConfigs, UniformApiPluginConfig, UniformApiPluginInputsItem, VariableRefRequestParams };