Swirls

SWIRLS_

  • How it works
  • Pricing

56 matches

OverviewDeliver client operations10Win and grow accounts8Resolve customer issues6Create and distribute content9Run people and operations5Review money and agreements3Monitor systems and data9Compose dependable work6

56 matches

OverviewDeliver client operations10Win and grow accounts8Resolve customer issues6Create and distribute content9Run people and operations5Review money and agreements3Monitor systems and data9Compose dependable work6
← PatternsFormView 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

data_inputform
process_data
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

Workflow nodes

CODE
Code Node
Extract data
CODE
Code Node
Transform data
CODE
Code Node
Summarize results
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.