import type { Fetcher } from 'swr' import { get, post } from './base' import type { CommonResponse } from '@/models/common' import type { FetchWorkflowDraftResponse, NodesDefaultConfigsResponse, WorkflowRunHistoryResponse, } from '@/types/workflow' export const fetchWorkflowDraft: Fetcher = (url) => { return get(url, {}, { silent: true }) } export const syncWorkflowDraft = ({ url, params }: { url: string; params: Pick }) => { return post(url, { body: params }) } export const fetchNodesDefaultConfigs: Fetcher = (url) => { return get(url) } export const fetchWorkflowRunHistory: Fetcher = (url) => { return get(url) } export const singleNodeRun = (appId: string, nodeId: string, params: object) => { return post(`apps/${appId}/workflows/draft/nodes/${nodeId}/run`, { body: params }) } export const publishWorkflow = (url: string) => { return post(url) } export const stopWorkflowRun = (url: string) => { return post(url) }