import { requestClient } from '#/api/request';

export namespace WorkflowApi {
  export interface WorkflowParams {
    appid: string;
    conversationId: string;
    userId: string;
    inputs: {
      [key: string]: any;
    };
    files: [];
  }
  export interface WorkflowRunBody {
    conversationId: string;
    userId: string;
    inputs: {
      [key: string]: any;
    };
    files: [];
  }
  export interface WorkflowLogParams {
    appid: string;
    lastId?: string;
    page?: number;
    limit?: number;
    keyword?: string;
    workflowRunId?: string;
  }
  export interface WorkflowLinkParams {
    workflowId: string;
    deptIds: string[];
  }
}

// 工作流
export function sendWorkflow(
  params: WorkflowApi.WorkflowParams,
  data: WorkflowApi.WorkflowRunBody,
) {
  return requestClient.post(`/v1/workflow/run/${params.appid}`, data);
}

export function sendPpt(appId: any, data: WorkflowApi.WorkflowRunBody) {
  return requestClient.post(`/ppt/run/${appId}`, data);
}

export function getWorkflowInfo(data: WorkflowApi.WorkflowLogParams) {
  return requestClient.get(`/v1/workflow/info/${data.appid}`, { params: data });
}

export function getWorkflowList(params: WorkflowApi.WorkflowLogParams) {
  return requestClient.get(`/v1/workflow/list/${params.appid}`, {
    params,
  });
}

export function linkWorkflow(data: WorkflowApi.WorkflowLinkParams) {
  return requestClient.post(`/v1/server/link`, data);
}

export function linkDetail(workflowId: string) {
  return requestClient.get(`/v1/server/link/${workflowId}`);
}
