Implementation:Langgenius Dify InputVar Types
| Knowledge Sources | Dify |
|---|---|
| Domains | Workflow, DAG, Frontend |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Description
The InputVar Types implementation defines the TypeScript type system for workflow input variables in the Dify frontend. It consists of three key constructs: the InputVarType enum for user-facing form field types, the VarType enum for runtime variable types, and the ValueSelector type alias for path-based variable references. Together, these types form the backbone of the workflow's data model, enabling type-safe variable definition, wiring, and validation across the DAG.
Usage
These types are imported throughout the workflow component tree. InputVarType is used when configuring Start node form fields and when rendering input panels for single-node test runs. VarType is used for type-checking variable connections between nodes. ValueSelector is used whenever a node needs to reference an upstream node's output.
Code Reference
Source Location
web/app/components/workflow/types.ts, lines 151-234 (InputVarType: lines 196-211, VarType: lines 281-297, ValueSelector: line 151, Variable: lines 153-167).
Signature
// Path-based variable reference: [nodeId, key | obj key path]
export type ValueSelector = string[]
// User-facing input form field types
export enum InputVarType {
textInput = 'text-input',
paragraph = 'paragraph',
select = 'select',
number = 'number',
url = 'url',
files = 'files',
json = 'json', // object or array
jsonObject = 'json_object', // only object, supports JSON schema
contexts = 'contexts', // knowledge retrieval
iterator = 'iterator', // iteration input
singleFile = 'file',
multiFiles = 'file-list',
loop = 'loop', // loop input
checkbox = 'checkbox',
}
// Runtime variable data types
export enum VarType {
string = 'string',
number = 'number',
integer = 'integer',
secret = 'secret',
boolean = 'boolean',
object = 'object',
file = 'file',
array = 'array',
arrayString = 'array[string]',
arrayNumber = 'array[number]',
arrayObject = 'array[object]',
arrayBoolean = 'array[boolean]',
arrayFile = 'array[file]',
any = 'any',
arrayAny = 'array[any]',
}
// Variable definition combining name, selector, and type
export type Variable = {
variable: string
label?: string | {
nodeType: BlockEnum
nodeName: string
variable: string
}
value_selector: ValueSelector
value_type?: VarType
variable_type?: VarKindType
value?: string
options?: string[]
required?: boolean
isParagraph?: boolean
}
// Input variable for form rendering
export type InputVar = {
type: InputVarType
label: string | {
nodeType: BlockEnum
nodeName: string
variable: string
isChatVar?: boolean
}
variable: string
max_length?: number
default?: string | number
required: boolean
hint?: string
options?: string[]
value_selector?: ValueSelector
placeholder?: string
unit?: string
json_schema?: string | Record<string, any>
} & Partial<UploadFileSetting>
Import
import {
InputVarType,
VarType,
type ValueSelector,
type Variable,
type InputVar,
} from '@/app/components/workflow/types'
I/O Contract
Inputs (InputVarType enum values)
| Enum Key | String Value | Description |
|---|---|---|
| textInput | 'text-input' |
Single-line text input field |
| paragraph | 'paragraph' |
Multi-line text area |
| select | 'select' |
Dropdown selection from predefined options |
| number | 'number' |
Numeric input field |
| url | 'url' |
URL input with validation |
| files | 'files' |
Multiple file upload |
| json | 'json' |
Raw JSON input (object or array) |
| jsonObject | 'json_object' |
JSON object with schema validation |
| contexts | 'contexts' |
Knowledge retrieval context input |
| iterator | 'iterator' |
Iteration node input |
| singleFile | 'file' |
Single file upload |
| multiFiles | 'file-list' |
File list upload |
| loop | 'loop' |
Loop node input |
| checkbox | 'checkbox' |
Boolean checkbox |
Outputs (VarType enum values)
| Enum Key | String Value | Description |
|---|---|---|
| string | 'string' |
Text data |
| number | 'number' |
Floating-point number |
| integer | 'integer' |
Integer number |
| secret | 'secret' |
Sensitive/masked value |
| boolean | 'boolean' |
True/false value |
| object | 'object' |
Key-value object |
| file | 'file' |
Single file reference |
| array | 'array' |
Untyped array |
| arrayString | 'array[string]' |
Array of strings |
| arrayNumber | 'array[number]' |
Array of numbers |
| arrayObject | 'array[object]' |
Array of objects |
| arrayBoolean | 'array[boolean]' |
Array of booleans |
| arrayFile | 'array[file]' |
Array of files |
| any | 'any' |
Any type (escape hatch) |
| arrayAny | 'array[any]' |
Array of any type |
Usage Examples
import { InputVarType, VarType, type ValueSelector } from '@/app/components/workflow/types'
// Define a Start node input variable
const userQueryInput: InputVar = {
type: InputVarType.textInput,
label: 'User Query',
variable: 'query',
required: true,
max_length: 2000,
placeholder: 'Enter your question...',
}
// Wire an upstream node output to a downstream node input
const valueRef: ValueSelector = ['start-node-id', 'query']
// Declare a variable with runtime type
const outputVar: Variable = {
variable: 'result',
value_selector: ['llm-node-id', 'text'],
value_type: VarType.string,
}