This document provides a comprehensive reference for all built-in nodes in the Pocket framework.
Routes to different nodes based on conditions
Since: 1.0.0
{
"properties": {
"conditions": {
"items": {
"properties": {
"if": {
"type": "string"
},
"then": {
"type": "string"
}
},
"required": [
"if",
"then"
],
"type": "object"
},
"type": "array"
},
"else": {
"description": "Default route if no conditions match",
"type": "string"
}
},
"required": [
"conditions"
],
"type": "object"
}Properties:
- conditions (required):
- Type:
array
- Type:
- else: Default route if no conditions match
- Type:
string
- Type:
Example 1: Route by score
type: conditional
config:
conditions: [map[if:{{gt .score 0.8}} then:high] map[if:{{gt .score 0.5}} then:medium]]
else: lowExample 2: Route by type
type: conditional
config:
conditions: [map[if:{{eq .type "error"}} then:error-handler] map[if:{{eq .type "warning"}} then:warning-handler]]
else: successDelays execution for a specified duration
Since: 1.0.0
{
"properties": {
"duration": {
"default": "1s",
"description": "Duration to delay (e.g., '1s', '500ms')",
"pattern": "^[0-9]+[a-z]+$",
"type": "string"
}
},
"type": "object"
}Properties:
- duration: Duration to delay (e.g., '1s', '500ms')
- Type:
string - Default:
1s
- Type:
Example 1: Simple delay
Delay for 1 second
type: delay
config:
duration: 1sExample 2: Short delay
Delay for 500 milliseconds
type: delay
config:
duration: 500msOutputs a message and passes through input
Since: 1.0.0
{
"properties": {
"message": {
"default": "Hello from echo node",
"description": "Message to output",
"type": "string"
}
},
"type": "object"
}Properties:
- message: Message to output
- Type:
string - Default:
Hello from echo node
- Type:
{
"properties": {
"input": {
"type": [
"null",
"object",
"string",
"number",
"boolean",
"array"
]
},
"message": {
"type": "string"
},
"node": {
"type": "string"
}
},
"type": "object"
}Example 1: Simple echo
Output a message
type: echo
config:
message: Hello, World!Output:
{
"input": null,
"message": "Hello, World!",
"node": "echo1"
}Example 2: Echo with input
Echo message with input passthrough
type: echo
config:
message: Processing completeInput:
{
"data": "test"
}Output:
{
"input": {
"data": "test"
},
"message": "Processing complete",
"node": "echo2"
}Routes to a specific node based on configuration
Since: 1.0.0
{
"properties": {
"route": {
"default": "default",
"description": "The route/action to take",
"type": "string"
}
},
"type": "object"
}Properties:
- route: The route/action to take
- Type:
string - Default:
default
- Type:
Example 1: Simple routing
Route to a specific action
type: router
config:
route: successExample 2: Default routing
Use default route
type: router
config:Collects and combines data from multiple inputs
Since: 1.0.0
{
"properties": {
"count": {
"description": "Number of inputs to collect before continuing",
"minimum": 1,
"type": "integer"
},
"key": {
"description": "Key to use for object mode (supports templates)",
"type": "string"
},
"mode": {
"default": "array",
"description": "How to aggregate inputs: array (collect all), object (key-value pairs), merge (deep merge objects), concat (concatenate arrays)",
"enum": [
"array",
"object",
"merge",
"concat"
],
"type": "string"
},
"partial": {
"default": false,
"description": "Allow partial results if timeout occurs",
"type": "boolean"
},
"timeout": {
"default": "30s",
"description": "Maximum time to wait for all inputs",
"type": "string"
}
},
"type": "object"
}Properties:
- count: Number of inputs to collect before continuing
- Type:
integer
- Type:
- key: Key to use for object mode (supports templates)
- Type:
string
- Type:
- mode: How to aggregate inputs: array (collect all), object (key-value pairs), merge (deep merge objects), concat (concatenate arrays)
- Type:
string - Default:
array
- Type:
- partial: Allow partial results if timeout occurs
- Type:
boolean - Default:
false
- Type:
- timeout: Maximum time to wait for all inputs
- Type:
string - Default:
30s
- Type:
{
"properties": {
"complete": {
"description": "Whether all expected inputs were received",
"type": "boolean"
},
"count": {
"description": "Number of items collected",
"type": "integer"
},
"data": {
"description": "Aggregated data (array, object, or merged result)"
}
},
"type": "object"
}Example 1: Collect array of results
Aggregate multiple inputs into an array
type: aggregate
config:
mode: array
count: 3Output:
{
"complete": true,
"count": 3,
"data": [
"input1",
"input2",
"input3"
]
}Example 2: Build object from inputs
Create object with dynamic keys
type: aggregate
config:
mode: object
key: {{.type}}Output:
{
"complete": true,
"count": 2,
"data": {
"product": {
"name": "Widget",
"type": "product"
},
"user": {
"name": "Alice",
"type": "user"
}
}
}Example 3: Merge objects deeply
Deep merge multiple objects
type: aggregate
config:
mode: mergeOutput:
{
"complete": true,
"count": 3,
"data": {
"role": "admin",
"settings": {
"lang": "en",
"theme": "dark"
},
"user": "Alice"
}
}Extracts data from JSON using JSONPath expressions
Since: 1.0.0
{
"properties": {
"default": {
"description": "Default value if path not found"
},
"multiple": {
"default": false,
"description": "Return all matches as array (true) or first match only (false)",
"type": "boolean"
},
"path": {
"description": "JSONPath expression to extract data",
"type": "string"
},
"unwrap": {
"default": true,
"description": "Unwrap single-element arrays",
"type": "boolean"
}
},
"required": [
"path"
],
"type": "object"
}Properties:
- default: Default value if path not found
- multiple: Return all matches as array (true) or first match only (false)
- Type:
boolean - Default:
false
- Type:
- path (required): JSONPath expression to extract data
- Type:
string
- Type:
- unwrap: Unwrap single-element arrays
- Type:
boolean - Default:
true
- Type:
{
"description": "Extracted value(s) from the JSONPath query"
}Example 1: Extract user name
Get user name from nested object
type: jsonpath
config:
path: $.user.nameInput:
{
"user": {
"age": 30,
"name": "Alice"
}
}Output:
"Alice"Example 2: Extract all prices
Get all prices from array of items
type: jsonpath
config:
path: $.items[*].price
multiple: trueInput:
{
"items": [
{
"name": "Book",
"price": 10.99
},
{
"name": "Pen",
"price": 2.5
}
]
}Output:
[
10.99,
2.5
]Example 3: Extract with default
Use default value when path not found
type: jsonpath
config:
default: Not found
path: $.missing.fieldInput:
{
"other": "data"
}Output:
"Not found"Renders Go templates with input data
Since: 1.0.0
{
"oneOf": [
{
"required": [
"template"
]
},
{
"required": [
"file"
]
}
],
"properties": {
"file": {
"description": "Path to template file (alternative to inline template)",
"type": "string"
},
"output_format": {
"default": "string",
"description": "Output format for the rendered template",
"enum": [
"string",
"json",
"yaml"
],
"type": "string"
},
"template": {
"description": "Go template string to render",
"type": "string"
}
},
"type": "object"
}Properties:
- file: Path to template file (alternative to inline template)
- Type:
string
- Type:
- output_format: Output format for the rendered template
- Type:
string - Default:
string
- Type:
- template: Go template string to render
- Type:
string
- Type:
Example 1: Simple greeting
Render a greeting message
type: template
config:
template: Hello, {{.name}}! Your score is {{.score}}.Input:
{
"name": "Alice",
"score": 95
}Output:
"Hello, Alice! Your score is 95."Example 2: JSON output
Render template and output as JSON
type: template
config:
template: {"message": "Welcome {{.user}}", "timestamp": "{{.time}}"}
output_format: jsonInput:
{
"time": "2024-01-01T00:00:00Z",
"user": "Bob"
}Output:
{
"message": "Welcome Bob",
"timestamp": "2024-01-01T00:00:00Z"
}Transforms input data
Since: 1.0.0
{
"properties": {},
"type": "object"
}Properties:
{
"properties": {
"node": {
"type": "string"
},
"original": {
"type": [
"null",
"object",
"string",
"number",
"boolean",
"array"
]
},
"timestamp": {
"format": "date-time",
"type": "string"
},
"transformed": {
"type": "boolean"
}
},
"type": "object"
}Example 1: Simple transform
Wrap input with metadata
type: transform
config:Input:
{
"value": 42
}Output:
{
"node": "transform1",
"original": {
"value": 42
},
"timestamp": "2024-01-01T00:00:00Z",
"transformed": true
}Validates data against schema
Since: 1.0.0
{
"properties": {
"fail_on_error": {
"default": true,
"description": "Whether to fail the node on validation error",
"type": "boolean"
},
"schema": {
"description": "JSON Schema to validate against",
"type": "object"
}
},
"required": [
"schema"
],
"type": "object"
}Properties:
- fail_on_error: Whether to fail the node on validation error
- Type:
boolean - Default:
true
- Type:
- schema (required): JSON Schema to validate against
- Type:
object
- Type:
{
"properties": {
"data": {},
"errors": {
"items": {
"type": "string"
},
"type": "array"
},
"valid": {
"type": "boolean"
}
},
"type": "object"
}Example 1: Validate user data
type: validate
config:
schema:
type: object
properties:
name:
type: string
age:
type: integer
minimum: 0
required: [name, age]Input:
{
"age": 30,
"name": "Alice"
}Output:
{
"data": {
"age": 30,
"name": "Alice"
},
"errors": [],
"valid": true
}Example 2: Handle validation errors
type: validate
config:
schema:
type: object
properties:
email:
type: string
format: email
fail_on_error: falseInput:
{
"email": "not-an-email"
}Output:
{
"data": {
"email": "not-an-email"
},
"errors": [
"email: Does not match format 'email'"
],
"valid": false
}Executes external commands
Since: 1.0.0
{
"properties": {
"args": {
"description": "Command arguments",
"items": {
"type": "string"
},
"type": "array"
},
"command": {
"description": "Command to execute",
"type": "string"
},
"dir": {
"description": "Working directory",
"type": "string"
},
"env": {
"additionalProperties": {
"type": "string"
},
"description": "Environment variables",
"type": "object"
},
"timeout": {
"default": "30s",
"description": "Command timeout",
"type": "string"
}
},
"required": [
"command"
],
"type": "object"
}Properties:
- args: Command arguments
- Type:
array
- Type:
- command (required): Command to execute
- Type:
string
- Type:
- dir: Working directory
- Type:
string
- Type:
- env: Environment variables
- Type:
object
- Type:
- timeout: Command timeout
- Type:
string - Default:
30s
- Type:
{
"properties": {
"code": {
"description": "Exit code",
"type": "integer"
},
"stderr": {
"description": "Standard error output",
"type": "string"
},
"stdout": {
"description": "Standard output",
"type": "string"
}
},
"type": "object"
}Example 1: Run simple command
type: exec
config:
command: echo
args: ["Hello, World!"]Output:
{
"code": 0,
"stderr": "",
"stdout": "Hello, World!\n"
}Example 2: Run with environment
type: exec
config:
command: sh
args: ["-c", "echo $MESSAGE"]
env:
MESSAGE: "Hello from env"Output:
{
"code": 0,
"stderr": "",
"stdout": "Hello from env\n"
}File operations (read, write, append)
Since: 1.0.0
{
"properties": {
"content": {
"description": "Content to write (for write/append operations)",
"type": "string"
},
"encoding": {
"default": "utf-8",
"description": "File encoding",
"type": "string"
},
"operation": {
"default": "read",
"description": "Operation to perform",
"enum": [
"read",
"write",
"append",
"delete",
"exists"
],
"type": "string"
},
"path": {
"description": "File path",
"type": "string"
}
},
"required": [
"path"
],
"type": "object"
}Properties:
- content: Content to write (for write/append operations)
- Type:
string
- Type:
- encoding: File encoding
- Type:
string - Default:
utf-8
- Type:
- operation: Operation to perform
- Type:
string - Default:
read
- Type:
- path (required): File path
- Type:
string
- Type:
{
"oneOf": [
{
"description": "File content (for read)",
"type": "string"
},
{
"description": "Success status (for write/append/delete)",
"type": "boolean"
},
{
"description": "Existence status (for exists)",
"type": "boolean"
}
]
}Example 1: Read file
type: file
config:
path: /tmp/data.txt
operation: readOutput:
"File contents here..."Example 2: Write file
type: file
config:
path: /tmp/output.txt
operation: write
content: "Hello, World!"Output:
trueExample 3: Check existence
type: file
config:
path: /tmp/check.txt
operation: existsOutput:
falseMakes HTTP requests
Since: 1.0.0
{
"properties": {
"body": {
"description": "Request body"
},
"headers": {
"additionalProperties": {
"type": "string"
},
"description": "Request headers",
"type": "object"
},
"method": {
"default": "GET",
"description": "HTTP method",
"enum": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS"
],
"type": "string"
},
"params": {
"additionalProperties": {
"type": "string"
},
"description": "Query parameters",
"type": "object"
},
"timeout": {
"default": "30s",
"description": "Request timeout",
"type": "string"
},
"url": {
"description": "Request URL",
"type": "string"
}
},
"required": [
"url"
],
"type": "object"
}Properties:
- body: Request body
- headers: Request headers
- Type:
object
- Type:
- method: HTTP method
- Type:
string - Default:
GET
- Type:
- params: Query parameters
- Type:
object
- Type:
- timeout: Request timeout
- Type:
string - Default:
30s
- Type:
- url (required): Request URL
- Type:
string
- Type:
{
"properties": {
"body": {
"description": "Response body"
},
"headers": {
"additionalProperties": {
"type": "string"
},
"description": "Response headers",
"type": "object"
},
"status": {
"description": "HTTP status code",
"type": "integer"
}
},
"type": "object"
}Example 1: Simple GET request
type: http
config:
url: https://api.example.com/usersOutput:
{
"body": [
{
"id": 1,
"name": "Alice"
}
],
"headers": {
"content-type": "application/json"
},
"status": 200
}Example 2: POST with data
type: http
config:
url: https://api.example.com/users
method: POST
headers:
Content-Type: application/json
body:
name: Bob
email: bob@example.comOutput:
{
"body": {
"email": "bob@example.com",
"id": 2,
"name": "Bob"
},
"headers": {
"content-type": "application/json"
},
"status": 201
}Execute multiple tasks concurrently
Since: 1.0.0
{
"properties": {
"tasks": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"node": {
"type": "string"
},
"config": {
"type": "object"
},
"input": {}
},
"required": ["name", "node"]
}
},
"max_concurrency": {
"type": "integer",
"description": "Maximum concurrent tasks"
},
"fail_fast": {
"type": "boolean",
"default": true,
"description": "Stop on first error"
},
"timeout": {
"type": "string",
"description": "Overall timeout"
}
},
"required": ["tasks"],
"type": "object"
}Example 1: Fetch data in parallel
type: parallel
config:
max_concurrency: 3
tasks:
- name: fetch-users
node: http
config:
url: https://api.example.com/users
- name: fetch-orders
node: http
config:
url: https://api.example.com/ordersExample 2: Process files concurrently
type: parallel
config:
fail_fast: false
tasks:
- name: process-csv
node: file
config:
path: data.csv
operation: read
- name: process-json
node: file
config:
path: data.json
operation: read
- name: process-xml
node: file
config:
path: data.xml
operation: readExecute Lua scripts for custom logic
Since: 1.0.0
{
"oneOf": [
{
"required": ["script"]
},
{
"required": ["file"]
}
],
"properties": {
"file": {
"description": "Path to Lua script file",
"type": "string"
},
"sandbox": {
"default": true,
"description": "Enable sandboxing",
"type": "boolean"
},
"script": {
"description": "Inline Lua script",
"type": "string"
},
"timeout": {
"default": "30s",
"description": "Script execution timeout",
"type": "string"
}
},
"type": "object"
}Example 1: Filter high scores
type: lua
config:
script: |
if input.score > 0.8 then
return {status = "high", data = input}
else
return {status = "low", data = input}
endExample 2: Transform data with utilities
type: lua
config:
script: |
local result = {
name = str_trim(input.name),
data = json_decode(input.json_string),
timestamp = os.time()
}
return resultExample 3: Complex data processing
type: lua
config:
script: |
-- Calculate statistics
local items = input.items or {}
local total = 0
local count = #items
for _, item in ipairs(items) do
total = total + (item.value or 0)
end
local avg = count > 0 and (total / count) or 0
-- Filter and transform
local processed = {}
for _, item in ipairs(items) do
if item.value > avg then
table.insert(processed, {
id = item.id,
value = item.value,
above_average = true
})
end
end
return {
total = total,
count = count,
average = avg,
above_average_items = processed
}Example 4: Use external script file
type: lua
config:
file: scripts/process_order.lua
timeout: 45s