56 lines
2.0 KiB
TypeScript
56 lines
2.0 KiB
TypeScript
import request from '../../utils/request';
|
|
import {
|
|
CreateWorkflowDefinitionRequest,
|
|
UpdateWorkflowDefinitionRequest,
|
|
WorkflowDefinition,
|
|
WorkflowDefinitionPage,
|
|
WorkflowDefinitionQuery,
|
|
NodeType,
|
|
NodeTypeQuery
|
|
} from './types';
|
|
|
|
const WORKFLOW_DEFINITION_URL = '/api/v1/workflow-definitions';
|
|
const NODE_TYPE_URL = '/api/v1/node-types';
|
|
|
|
// 创建工作流定义
|
|
export const createDefinition = (data: CreateWorkflowDefinitionRequest) =>
|
|
request.post<WorkflowDefinition>(WORKFLOW_DEFINITION_URL, data);
|
|
|
|
// 更新工作流定义
|
|
export const updateDefinition = (id: number, data: UpdateWorkflowDefinitionRequest) =>
|
|
request.put<WorkflowDefinition>(`${WORKFLOW_DEFINITION_URL}/${id}`, data);
|
|
|
|
// 获取工作流定义列表
|
|
export const getDefinitions = (params?: WorkflowDefinitionQuery) =>
|
|
request.get<WorkflowDefinitionPage>(`${WORKFLOW_DEFINITION_URL}/page`, { params });
|
|
|
|
// 获取工作流定义详情
|
|
export const getDefinition = (id: number) =>
|
|
request.get<WorkflowDefinition>(`${WORKFLOW_DEFINITION_URL}/${id}`);
|
|
|
|
// 删除工作流定义
|
|
export const deleteDefinition = (id: number) =>
|
|
request.delete(`${WORKFLOW_DEFINITION_URL}/${id}`);
|
|
|
|
// 发布工作流定义
|
|
export const publishDefinition = (id: number) =>
|
|
request.post<WorkflowDefinition>(`${WORKFLOW_DEFINITION_URL}/${id}/publish`);
|
|
|
|
// 禁用工作流定义
|
|
export const disableDefinition = (id: number) =>
|
|
request.post<WorkflowDefinition>(`${WORKFLOW_DEFINITION_URL}/${id}/disable`);
|
|
|
|
// 启用工作流定义
|
|
export const enableDefinition = (id: number) =>
|
|
request.post<WorkflowDefinition>(`${WORKFLOW_DEFINITION_URL}/${id}/enable`);
|
|
|
|
// 创建新版本
|
|
export const createVersion = (id: number) =>
|
|
request.post<WorkflowDefinition>(`${WORKFLOW_DEFINITION_URL}/${id}/versions`);
|
|
|
|
// 节点类型相关接口
|
|
export const getNodeTypes = (params?: NodeTypeQuery) =>
|
|
request.get<NodeType[]>(NODE_TYPE_URL, { params });
|
|
|
|
export const getNodeTypeExecutors = (code: string) =>
|
|
request.get<NodeType>(`${NODE_TYPE_URL}/${code}/executors`);
|