FormView on GitHub
External TS File Pattern
Referencing an external .ts.swirls file from a code node with @ts "path".
code
Source
/**
* Demonstrates referencing an external .ts.swirls file from a code node.
* The transform node loads its function body from ./transform.ts.swirls;
* the other nodes keep their logic inline for contrast.
*/
form data_input {
label: "Data Input"
schema: @json {
{
"type": "object",
"required": ["items"],
"properties": {
"items": {
"type": "array",
"title": "Items",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"value": { "type": "number" }
}
}
}
}
}
}
}
workflow process_data {
label: "Process Data"
root {
type: code
label: "Extract data"
code: @ts { return context.nodes.root.input }
outputSchema: @json {
{
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"value": { "type": "number" }
}
}
}
}
}
}
}
node transform {
type: code
label: "Transform data"
code: @ts "./transform.ts.swirls"
}
node summarize {
type: code
label: "Summarize results"
code: @ts {
const result = context.nodes.transform.output
return {
item_count: result.items ? result.items.length : 0,
total: result.total || 0,
processed_at: new Date().toISOString()
}
}
}
flow {
root -> transform
transform -> summarize
}
}
trigger on_data {
form:data_input -> process_data
enabled: true
}
Flow
Trigger to workflow
Workflow nodes