Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

673 B
Raw Blame
import type { useNodesSyncDraft } from '@/app/components/workflow/hooks/use-nodes-sync-draft'

export class HumanInputDraftSyncError extends Error {
  constructor() {
    super('Human Input draft could not be saved')
    this.name = 'HumanInputDraftSyncError'
  }
}

export const syncHumanInputDraft = async (
  syncDraft: ReturnType<typeof useNodesSyncDraft>['doSyncWorkflowDraft'],
): Promise<void> => {
  let saved = false
  let failed = false
  const result = await syncDraft(true, {
    onSuccess: () => {
      saved = true
    },
    onError: () => {
      failed = true
    },
  })
  if (failed || (!saved && result == null)) throw new HumanInputDraftSyncError()
}