mirror of
https://github.com/langgenius/dify.git
synced 2026-09-24 23:22:26 +08:00
refactor(api): migrate console.app.workflow to BaseModel (#36216)
Co-authored-by: WH-2099 <wh2099@pm.me> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
WH-2099
autofix-ci[bot]
parent
7e8147295b
commit
2eb37caf2e
@@ -175,7 +175,7 @@ describe('usePipelineConfig', () => {
|
||||
expect(mockSetPublishedAt).toHaveBeenCalledWith('2024-01-01T00:00:00Z')
|
||||
})
|
||||
|
||||
it('should handle undefined workflow response', () => {
|
||||
it('should reset published at when workflow response is empty', () => {
|
||||
let capturedCallback: ((data: unknown) => void) | undefined
|
||||
mockUseWorkflowConfig.mockImplementation((url: string, callback: (data: unknown) => void) => {
|
||||
if (url.includes('/publish')) {
|
||||
@@ -187,7 +187,7 @@ describe('usePipelineConfig', () => {
|
||||
|
||||
capturedCallback?.(undefined)
|
||||
|
||||
expect(mockSetPublishedAt).toHaveBeenCalledWith(undefined)
|
||||
expect(mockSetPublishedAt).toHaveBeenCalledWith(0)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@ export const usePipelineConfig = () => {
|
||||
handleUpdateNodesDefaultConfigs,
|
||||
)
|
||||
|
||||
const handleUpdatePublishedAt = useCallback((publishedWorkflow: FetchWorkflowDraftResponse) => {
|
||||
const handleUpdatePublishedAt = useCallback((publishedWorkflow: FetchWorkflowDraftResponse | null) => {
|
||||
const { setPublishedAt } = workflowStore.getState()
|
||||
|
||||
setPublishedAt(publishedWorkflow?.created_at)
|
||||
setPublishedAt(publishedWorkflow?.created_at ?? 0)
|
||||
}, [workflowStore])
|
||||
useWorkflowConfig(
|
||||
pipelineId ? `/rag/pipelines/${pipelineId}/workflows/publish` : '',
|
||||
|
||||
@@ -124,7 +124,7 @@ export const useWorkflowInit = () => {
|
||||
return acc
|
||||
}, {} as Record<string, any>),
|
||||
})
|
||||
workflowStore.getState().setPublishedAt(publishedWorkflow?.created_at)
|
||||
workflowStore.getState().setPublishedAt(publishedWorkflow?.created_at ?? 0)
|
||||
const graph = publishedWorkflow?.graph
|
||||
workflowStore.getState().setLastPublishedHasUserInput(
|
||||
hasConnectedUserInput(graph?.nodes, graph?.edges),
|
||||
|
||||
@@ -195,10 +195,10 @@ export const useInvalidDataSourceList = () => {
|
||||
export const publishedPipelineInfoQueryKeyPrefix = [NAME_SPACE, 'published-pipeline']
|
||||
|
||||
export const usePublishedPipelineInfo = (pipelineId: string) => {
|
||||
return useQuery<PublishedPipelineInfoResponse>({
|
||||
return useQuery<PublishedPipelineInfoResponse | null>({
|
||||
queryKey: [...publishedPipelineInfoQueryKeyPrefix, pipelineId],
|
||||
queryFn: () => {
|
||||
return get<PublishedPipelineInfoResponse>(`/rag/pipelines/${pipelineId}/workflows/publish`)
|
||||
return get<PublishedPipelineInfoResponse | null>(`/rag/pipelines/${pipelineId}/workflows/publish`)
|
||||
},
|
||||
enabled: !!pipelineId,
|
||||
})
|
||||
|
||||
@@ -19,10 +19,10 @@ import { getFlowPrefix } from './utils'
|
||||
const NAME_SPACE = 'workflow'
|
||||
|
||||
export const useAppWorkflow = (appID: string) => {
|
||||
return useQuery<FetchWorkflowDraftResponse>({
|
||||
return useQuery<FetchWorkflowDraftResponse | null>({
|
||||
enabled: !!appID,
|
||||
queryKey: [NAME_SPACE, 'publish', appID],
|
||||
queryFn: () => get<FetchWorkflowDraftResponse>(`/apps/${appID}/workflows/publish`),
|
||||
queryFn: () => get<FetchWorkflowDraftResponse | null>(`/apps/${appID}/workflows/publish`),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export const getLoopSingleNodeRunUrl = (flowType: FlowType, isChatFlow: boolean,
|
||||
}
|
||||
|
||||
export const fetchPublishedWorkflow = (url: string) => {
|
||||
return get<FetchWorkflowDraftResponse>(url)
|
||||
return get<FetchWorkflowDraftResponse | null>(url)
|
||||
}
|
||||
|
||||
export const stopWorkflowRun = (url: string) => {
|
||||
|
||||
Reference in New Issue
Block a user