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.

1.3 KB
Raw Blame
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
import type { PluginTriggerNodeType } from '@/app/components/workflow/nodes/trigger-plugin/types'

type TriggerCheckParams = {
  triggerInputsSchema: Array<{
    variable: string
    label: string
    required?: boolean
  }>
  isReadyForCheckValid: boolean
}

export const getTriggerCheckParams = (
  triggerData: PluginTriggerNodeType,
  triggerProviders: TriggerWithProvider[] | undefined,
  language: string,
): TriggerCheckParams => {
  if (!triggerProviders) {
    return {
      triggerInputsSchema: [],
      isReadyForCheckValid: false,
    }
  }

  const { provider_id, provider_name, event_name } = triggerData

  const provider = triggerProviders.find(
    (item) =>
      item.name === provider_name ||
      item.id === provider_id ||
      (provider_id && item.plugin_id === provider_id),
  )

  const currentEvent = provider?.events.find((event) => event.name === event_name)

  const triggerInputsSchema = (currentEvent?.parameters || []).map((parameter) => {
    const label = parameter.label?.[language] || parameter.label?.en_US || parameter.name
    return {
      variable: parameter.name,
      label,
      required: parameter.required,
    }
  })

  return {
    triggerInputsSchema,
    isReadyForCheckValid: true,
  }
}