refactor:simplify syncWorkflowDraft parameters

This commit is contained in:
zhsama 2025-11-06 12:19:09 +08:00
parent 77e6e98234
commit fb6dc14e9b
1 changed files with 4 additions and 8 deletions

View File

@ -12,20 +12,16 @@ import type { BlockEnum } from '@/app/components/workflow/types'
import type { VarInInspect } from '@/types/workflow'
import type { FlowType } from '@/types/common'
import { getFlowPrefix } from './utils'
import { hydrateWorkflowDraftResponse, sanitizeWorkflowDraftPayload } from './workflow-payload'
import type { WorkflowDraftSyncParams } from './workflow-payload'
export const fetchWorkflowDraft = async (url: string) => {
const response = await get(url, {}, { silent: true }) as FetchWorkflowDraftResponse
return hydrateWorkflowDraftResponse(response)
export const fetchWorkflowDraft = (url: string) => {
return get(url, {}, { silent: true }) as Promise<FetchWorkflowDraftResponse>
}
export const syncWorkflowDraft = ({ url, params }: {
url: string
params: WorkflowDraftSyncParams
params: Pick<FetchWorkflowDraftResponse, 'graph' | 'features' | 'environment_variables' | 'conversation_variables'>
}) => {
const sanitizedParams = sanitizeWorkflowDraftPayload(params)
return post<CommonResponse & { updated_at: number; hash: string }>(url, { body: sanitizedParams }, { silent: true })
return post<CommonResponse & { updated_at: number; hash: string }>(url, { body: params }, { silent: true })
}
export const fetchNodesDefaultConfigs: Fetcher<NodesDefaultConfigsResponse, string> = (url) => {