mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
refactor(web): migrate workflow run history from useSWR to TanStack Query (#30077)
This commit is contained in:
@ -1,14 +1,11 @@
|
||||
import type { Fetcher } from 'swr'
|
||||
import type { BlockEnum } from '@/app/components/workflow/types'
|
||||
import type { CommonResponse } from '@/models/common'
|
||||
import type { FlowType } from '@/types/common'
|
||||
import type {
|
||||
ChatRunHistoryResponse,
|
||||
ConversationVariableResponse,
|
||||
FetchWorkflowDraftResponse,
|
||||
NodesDefaultConfigsResponse,
|
||||
VarInInspect,
|
||||
WorkflowRunHistoryResponse,
|
||||
} from '@/types/workflow'
|
||||
import { get, post } from './base'
|
||||
import { getFlowPrefix } from './utils'
|
||||
@ -24,18 +21,10 @@ export const syncWorkflowDraft = ({ url, params }: {
|
||||
return post<CommonResponse & { updated_at: number, hash: string }>(url, { body: params }, { silent: true })
|
||||
}
|
||||
|
||||
export const fetchNodesDefaultConfigs: Fetcher<NodesDefaultConfigsResponse, string> = (url) => {
|
||||
export const fetchNodesDefaultConfigs = (url: string) => {
|
||||
return get<NodesDefaultConfigsResponse>(url)
|
||||
}
|
||||
|
||||
export const fetchWorkflowRunHistory: Fetcher<WorkflowRunHistoryResponse, string> = (url) => {
|
||||
return get<WorkflowRunHistoryResponse>(url)
|
||||
}
|
||||
|
||||
export const fetchChatRunHistory: Fetcher<ChatRunHistoryResponse, string> = (url) => {
|
||||
return get<ChatRunHistoryResponse>(url)
|
||||
}
|
||||
|
||||
export const singleNodeRun = (flowType: FlowType, flowId: string, nodeId: string, params: object) => {
|
||||
return post(`${getFlowPrefix(flowType)}/${flowId}/workflows/draft/nodes/${nodeId}/run`, { body: params })
|
||||
}
|
||||
@ -48,7 +37,7 @@ export const getLoopSingleNodeRunUrl = (flowType: FlowType, isChatFlow: boolean,
|
||||
return `${getFlowPrefix(flowType)}/${flowId}/${isChatFlow ? 'advanced-chat/' : ''}workflows/draft/loop/nodes/${nodeId}/run`
|
||||
}
|
||||
|
||||
export const fetchPublishedWorkflow: Fetcher<FetchWorkflowDraftResponse, string> = (url) => {
|
||||
export const fetchPublishedWorkflow = (url: string) => {
|
||||
return get<FetchWorkflowDraftResponse>(url)
|
||||
}
|
||||
|
||||
@ -68,15 +57,13 @@ export const fetchPipelineNodeDefault = (pipelineId: string, blockType: BlockEnu
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: archived
|
||||
export const updateWorkflowDraftFromDSL = (appId: string, data: string) => {
|
||||
return post<FetchWorkflowDraftResponse>(`apps/${appId}/workflows/draft/import`, { body: { data } })
|
||||
}
|
||||
|
||||
export const fetchCurrentValueOfConversationVariable: Fetcher<ConversationVariableResponse, {
|
||||
export const fetchCurrentValueOfConversationVariable = ({
|
||||
url,
|
||||
params,
|
||||
}: {
|
||||
url: string
|
||||
params: { conversation_id: string }
|
||||
}> = ({ url, params }) => {
|
||||
}) => {
|
||||
return get<ConversationVariableResponse>(url, { params })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user