Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Langgenius Dify BlockEnum Node Types

From Leeroopedia
Knowledge Sources Dify
Domains Workflow, DAG, Frontend
Last Updated 2026-02-12 00:00 GMT

Overview

Description

The BlockEnum enumeration and CommonNodeType interface define the complete set of workflow node types and their shared data structure in the Dify frontend. BlockEnum enumerates all 31 distinct node types available in the workflow builder, while CommonNodeType provides the generic type parameter used with ReactFlow's Node<T> to create fully typed workflow nodes. Together, they form the type-safe foundation for the entire visual DAG editor.

Usage

BlockEnum is used throughout the workflow builder to identify node types when adding nodes to the canvas, rendering node-specific configuration panels, validating graph structure, and dispatching execution logic. CommonNodeType is the base type for all node data, extended via TypeScript's intersection type (CommonNodeType<T>) to add node-specific configuration fields.

Code Reference

Source Location

web/app/components/workflow/types.ts, lines 28-59 (BlockEnum), lines 75-116 (CommonNodeType), lines 118-133 (CommonEdgeType), lines 135-143 (Node, Edge type aliases).

Signature

export enum BlockEnum {
  Start = 'start',
  End = 'end',
  Answer = 'answer',
  LLM = 'llm',
  KnowledgeRetrieval = 'knowledge-retrieval',
  QuestionClassifier = 'question-classifier',
  IfElse = 'if-else',
  Code = 'code',
  TemplateTransform = 'template-transform',
  HttpRequest = 'http-request',
  VariableAssigner = 'variable-assigner',
  VariableAggregator = 'variable-aggregator',
  Tool = 'tool',
  ParameterExtractor = 'parameter-extractor',
  Iteration = 'iteration',
  DocExtractor = 'document-extractor',
  ListFilter = 'list-operator',
  IterationStart = 'iteration-start',
  Assigner = 'assigner',
  Agent = 'agent',
  Loop = 'loop',
  LoopStart = 'loop-start',
  LoopEnd = 'loop-end',
  HumanInput = 'human-input',
  DataSource = 'datasource',
  DataSourceEmpty = 'datasource-empty',
  KnowledgeBase = 'knowledge-index',
  TriggerSchedule = 'trigger-schedule',
  TriggerWebhook = 'trigger-webhook',
  TriggerPlugin = 'trigger-plugin',
}

export type CommonNodeType<T = {}> = {
  _connectedSourceHandleIds?: string[]
  _connectedTargetHandleIds?: string[]
  _targetBranches?: Branch[]
  _isSingleRun?: boolean
  _runningStatus?: NodeRunningStatus
  _runningBranchId?: string
  _singleRunningStatus?: NodeRunningStatus
  _isCandidate?: boolean
  _isBundled?: boolean
  _children?: { nodeId: string, nodeType: BlockEnum }[]
  _isEntering?: boolean
  _showAddVariablePopup?: boolean
  _holdAddVariablePopup?: boolean
  _iterationLength?: number
  _iterationIndex?: number
  _waitingRun?: boolean
  _retryIndex?: number
  _dataSourceStartToAdd?: boolean
  _isTempNode?: boolean
  isInIteration?: boolean
  iteration_id?: string
  selected?: boolean
  title: string
  desc: string
  type: BlockEnum
  width?: number
  height?: number
  position?: XYPosition
  _loopLength?: number
  _loopIndex?: number
  isInLoop?: boolean
  loop_id?: string
  error_strategy?: ErrorHandleTypeEnum
  retry_config?: WorkflowRetryConfig
  default_value?: DefaultValueForm[]
  credential_id?: string
  subscription_id?: string
  provider_id?: string
  _dimmed?: boolean
  _pluginInstallLocked?: boolean
} & T & Partial<PluginDefaultValue>

// ReactFlow type aliases
export type Node<T = {}> = ReactFlowNode<CommonNodeType<T>>
export type Edge = ReactFlowEdge<CommonEdgeType>

Import

import { BlockEnum, type CommonNodeType, type Node, type Edge } from '@/app/components/workflow/types'

I/O Contract

Inputs (BlockEnum values by category)

Category Node Types Description
Control Flow Start, End, Answer, IfElse, QuestionClassifier, Iteration, Loop, HumanInput Govern execution flow, branching, looping, and terminal output
Data Processing LLM, Code, TemplateTransform, HttpRequest, KnowledgeRetrieval, DocExtractor, ListFilter Transform, generate, or retrieve data
Variable Management VariableAssigner, VariableAggregator, Assigner Assign, aggregate, or manipulate variables
Integration Tool, Agent, ParameterExtractor, DataSource, KnowledgeBase Connect to external tools, agents, and data sources
Triggers TriggerSchedule, TriggerWebhook, TriggerPlugin Initiate workflow execution from external events
Internal IterationStart, LoopStart, LoopEnd, DataSourceEmpty Internal nodes for container and placeholder behavior

Outputs (CommonNodeType key properties)

Property Type Description
title string Display name of the node
desc string Description text
type BlockEnum The node's block type identifier
position XYPosition Canvas coordinates
error_strategy ErrorHandleTypeEnum How errors are handled (terminated, continue, remove abnormal)
retry_config WorkflowRetryConfig Retry behavior on failure
isInIteration boolean Whether this node is inside an Iteration container
isInLoop boolean Whether this node is inside a Loop container

Usage Examples

import { BlockEnum, type Node, type CommonNodeType } from '@/app/components/workflow/types'

// Check if a node is an LLM node
function isLLMNode(node: Node): boolean {
  return node.data.type === BlockEnum.LLM
}

// Create a node data object for a Code node
const codeNodeData: CommonNodeType = {
  title: 'Transform Data',
  desc: 'Processes the input JSON',
  type: BlockEnum.Code,
}

// Filter nodes inside an iteration container
function getIterationChildren(nodes: Node[], iterationId: string): Node[] {
  return nodes.filter(n => n.data.isInIteration && n.data.iteration_id === iterationId)
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment