What are Decorators?
Decorators are special annotations that add metadata to classes and properties:Decorators are a TypeScript feature that requires
experimentalDecorators: true in your tsconfig.json@defineNode
The@defineNode decorator registers a node class with CrystalFlow:
Parameters
string
required
Unique identifier for the node type (e.g.,
'math.add', 'http.request')Convention: Use dot notation like category.operationstring
required
Human-readable name shown in the UI
string
required
Category for organizing nodes in the palette (e.g.,
'Math', 'Data', 'Network')string
Optional description explaining what the node does
Example
@Input
The@Input decorator defines an input port on a node:
Parameters
string
required
Data type of the input:
'string', 'number', 'boolean', 'any', or custom typesstring
required
Display name for the input port in the UI
any
Default value if no connection is made
boolean
default:"false"
Whether this input must be connected or have a value
string
Optional description of the input’s purpose
Example
@Output
The@Output decorator defines an output port on a node:
Parameters
string
required
Data type of the output:
'string', 'number', 'boolean', 'any', or custom typesstring
required
Display name for the output port in the UI
string
Optional description of what the output represents
Example
@Property
The@Property decorator defines a static configuration value (not connected to other nodes):
Parameters
'string' | 'number' | 'boolean' | 'select'
required
The property type
string
required
Display label in the properties panel
any
Default value for the property
boolean
default:"false"
Whether the property is required
string
Description shown in the UI
Array<{value: any, label: string}>
Options for select type properties
number
Minimum value for number properties
number
Maximum value for number properties
number
Step increment for number properties
Example
Property vs Input
Key Difference:
@Property= Static configuration in properties panel (not connected)@Input= Dynamic data flow via connections@Output= Computed results during execution
Decorator Inheritance
Properties and decorators are inherited from base classes:TypeScript Configuration
To use decorators, configure yourtsconfig.json:
tsconfig.json
Best Practices
Use Descriptive Labels
Use Descriptive Labels
Labels should be clear and concise - they’re shown to users in the UI.
Add Descriptions
Add Descriptions
Always add descriptions to help users understand what inputs, outputs, and properties do.
Set Sensible Defaults
Set Sensible Defaults
Provide default values that work out of the box.
Use Type Prefixes
Use Type Prefixes
Name node types with category prefixes:
math.add, string.uppercase, http.requestComplete Example
Here’s a complete node using all decorators:Next Steps
Creating Custom Nodes
Deep dive into building custom nodes
Property System
Master the property system
Inheritance
Learn about decorator inheritance
Decorators API
Complete decorators API reference