import request from '@/utils/request';
import { WorkflowTemplateWithInstances, WorkflowTemplateWithInstancesQuery } from './types';
import { Page } from '@/types/base';
import { WorkflowHistoricalInstance, WorkflowHistoricalInstanceQuery } from './types';

const INSTANCE_URL = '/api/v1/workflow/instance';

/**
 * 获取流程实例列表
 * @param params 查询参数
 */
export const getWorkflowInstances = (params?: WorkflowTemplateWithInstancesQuery) =>
    request.get<Page<WorkflowTemplateWithInstances>>(`${INSTANCE_URL}/templates-with-instances`, { params });

/**
 * 获取流程实例历史记录
 * @param params 查询参数
 */
export const getHistoricalInstances = (params?: WorkflowHistoricalInstanceQuery) =>
    request.get<Page<WorkflowHistoricalInstance>>(`${INSTANCE_URL}/historical-instances`, {params});
