Databases, JQ, Liquid templating and run variables. Each function lists its parameters, defaults and return value.
Database connection and query functions.
Scope: Network
Function Description db.connect()Establish a database connection db.query()Execute a SQL query and return rows db.exec()Execute a SQL statement (INSERT, UPDATE, DELETE) db.insert()Insert rows into a table db.update()Update rows in a table db.delete()Delete rows from a table db.bulk()Perform bulk insert operations db.close()Close a database connection
Establish a database connection and return a connection handle for subsequent operations.
Parameter Type Default Description driverstring "postgres"Database driver: "postgres", "mysql", "sqlite", "duckdb" hoststring "localhost"Database host portint 5432Database port databasestring — Database name (required) usernamestring — Username for authentication passwordstring — Password for authentication sslModestring "disable"SSL mode: "disable", "require", "verify-ca", "verify-full" pathstring — File path for SQLite/DuckDB databases readOnlybool falseOpen in read-only mode
Field Type Description successbool Whether connection succeeded connectionIdstring Connection handle for subsequent operations
path: " /data/analytics.duckdb "
// Connect to SQLite (read-only)
Execute a SQL query and return rows.
Parameter Type Default Description connectionIdstring — Connection handle from db.connect() (required) sqlstring — SQL query to execute (required) argsarray — Positional arguments for parameterized queries namedmap — Named arguments for parameterized queries
Field Type Description successbool Whether query succeeded rowsarray Array of row objects
connectionId: conn . connectionId ,
sql: " SELECT id, name, email FROM users "
for ( let row of result . rows ) {
log ( row . name + " : " + row . email )
connectionId: conn . connectionId ,
sql: " SELECT * FROM users WHERE status = $1 AND age > $2 " ,
connectionId: conn . connectionId ,
sql: " SELECT * FROM users WHERE department = :dept " ,
named: { dept: " engineering " }
db . close ({ connectionId: conn . connectionId })
Execute a SQL statement that doesn’t return rows (INSERT, UPDATE, DELETE, DDL).
Parameter Type Default Description connectionIdstring — Connection handle (required) sqlstring — SQL statement to execute (required) argsarray — Positional arguments namedmap — Named arguments
Field Type Description successbool Whether execution succeeded rowsAffectedint Number of rows affected lastInsertIdint Last insert ID (if applicable)
connectionId: conn . connectionId ,
sql: " CREATE TABLE IF NOT EXISTS logs (id SERIAL, message TEXT, created_at TIMESTAMP DEFAULT NOW()) "
// Insert with parameters
connectionId: conn . connectionId ,
sql: " INSERT INTO logs (message) VALUES ($1) " ,
args: [ " Application started " ]
// Update with parameters
connectionId: conn . connectionId ,
sql: " UPDATE users SET status = $1 WHERE last_login < $2 " ,
args: [ " inactive " , " 2024-01-01 " ]
log ( " Updated " + result . rowsAffected + " rows " )
Insert rows into a database table using a structured API.
Parameter Type Default Description connectionIdstring — Connection handle (required) tablestring — Table name (required) columnsarray — Column names valuesarray — Values to insert returningarray — Columns to return after insert (e.g., ["id"])
Field Type Description successbool Whether insert succeeded rowsarray Returned rows (if returning specified) rowsAffectedint Number of rows inserted lastInsertIdint Last insert ID
connectionId: conn . connectionId ,
columns: [ " name " , " email " , " role " ] ,
log ( " New user ID: " + result . rows [ 0 ] . id )
Update rows in a database table.
Parameter Type Default Description connectionIdstring — Connection handle (required) tablestring — Table name (required) setmap — Column-value pairs to update (required) wherestring — WHERE clause (without WHERE keyword) whereArgsarray — Positional arguments for WHERE clause returningarray — Columns to return after update
Field Type Description successbool Whether update succeeded rowsarray Returned rows (if returning specified) rowsAffectedint Number of rows updated
connectionId: conn . connectionId ,
set: { status: " active " , verified: true },
log ( " Updated " + result . rowsAffected + " rows " )
Delete rows from a database table.
Parameter Type Default Description connectionIdstring — Connection handle (required) tablestring — Table name (required) wherestring — WHERE clause (without WHERE keyword) whereArgsarray — Positional arguments for WHERE clause returningarray — Columns to return after delete
Field Type Description successbool Whether delete succeeded rowsarray Returned rows (if returning specified) rowsAffectedint Number of rows deleted
connectionId: conn . connectionId ,
where: " expires_at < NOW() "
log ( " Deleted " + result . rowsAffected + " expired sessions " )
Perform efficient bulk insert operations.
Parameter Type Default Description connectionIdstring — Connection handle (required) tablestring — Table name (required) columnsarray — Column names (required) rowsarray — Array of arrays containing row values (required) onConflictstring — Conflict handling (e.g., "DO NOTHING", "DO UPDATE SET ...") batchSizeint 1000Number of rows per batch
Field Type Description successbool Whether bulk insert succeeded rowsAffectedint Total rows inserted
connectionId: conn . connectionId ,
columns: [ " type " , " payload " , " timestamp " ] ,
[ " click " , ' {"page": "/home"} ' , " 2024-01-15T10:00:00Z " ],
[ " view " , ' {"page": "/about"} ' , " 2024-01-15T10:01:00Z " ],
[ " click " , ' {"page": "/contact"} ' , " 2024-01-15T10:02:00Z " ]
log ( " Inserted " + result . rowsAffected + " events " )
// Upsert (insert or update on conflict)
connectionId: conn . connectionId ,
columns: [ " name " , " value " ],
onConflict: " DO UPDATE SET value = EXCLUDED.value "
Close a database connection and release resources.
Parameter Type Default Description connectionIdstring — Connection handle from db.connect() (required)
Field Type Description successbool Whether connection was closed
// Full database lifecycle
connectionId: conn . connectionId ,
sql: " SELECT * FROM users WHERE active = true "
log ( " Found " + users . rows . length + " active users " )
db . close ({ connectionId: conn . connectionId })
JQ expression evaluation functions.
Scope: System
Function Description jq.query()Evaluate a jq expression against provided data
Evaluate a jq expression against a data object. Uses the gojq library for jq-compatible query evaluation.
Parameter Type Default Description expressionstring — JQ expression to evaluate (required) datamap {}Data object to query against
Field Type Description successbool Whether evaluation succeeded valueany Query result
// Simple value extraction
data: { name: " Alice " , age: 30 }
log ( " Name: " + result . value ) // "Alice"
expression: " .users | length " ,
data: { users: [{ name: " Alice " }, { name: " Bob " }] }
log ( " User count: " + result . value ) // 2
expression: ' [.[] | select(.status == "active") | .name] ' ,
{ name: " app1 " , status: " active " },
{ name: " app2 " , status: " inactive " },
{ name: " app3 " , status: " active " }
log ( " Active: " + JSON . stringify ( result . value )) // ["app1", "app3"]
expression: " .config.database.host " ,
database: { host: " localhost " , port: 5432 }
log ( " DB host: " + result . value ) // "localhost"
expression: " { host: .db_host, port: .db_port } " ,
data: { db_host: " localhost " , db_port: 5432 , db_name: " myapp " }
log ( JSON . stringify ( result . value )) // {"host":"localhost","port":5432}
expression: ' [.items[] | {name, total: (.price * .quantity)}] ' ,
{ name: " Widget " , price: 10 , quantity: 5 },
{ name: " Gadget " , price: 25 , quantity: 2 }
log ( JSON . stringify ( result . value ))
expression: " .config | fromjson | .port " ,
data: { config: ' {"host":"localhost","port":8080} ' }
log ( " Port: " + result . value ) // 8080
Liquid template rendering functions.
Scope: System
Function Description liquid.render()Render a Liquid template with variables liquid.process()Process Liquid templates from a source directory
Render a Liquid template string or file with provided variables.
Parameter Type Default Description datastring — Inline template string filestring — Path to template file (alternative to data) pathstring — Base path for {% include %} tags varsmap — Variables to pass to the template
Either data or file must be provided.
Field Type Description successbool Whether rendering succeeded outputstring Rendered output
// Render inline template
let result = liquid . render ( {
data: " Hello, {{name}}! You have {{count}} items. " ,
vars: { name: " Alice " , count: 42 }
log ( result . output ) // "Hello, Alice! You have 42 items."
// Render with conditionals
let result = liquid . render ( {
{% if environment == "production" %}
vars: { environment: " production " }
let result = liquid . render ( {
file: " /templates/config.yaml.liquid " ,
file . write ({ path: " /config/config.yaml " , content: result . output })
let result = liquid . render ( {
data: " {% for item in items %}{{item.name}}: {{item.value}} \n {% endfor %} " ,
{ name: " cpu " , value: " 45% " },
{ name: " memory " , value: " 72% " }
Process Liquid templates from a source directory to a destination directory.
Parameter Type Default Description sourcestring — Source directory containing templates (required) destinationstring — Output directory for rendered files (required) includearray — Glob patterns to include excludearray — Glob patterns to exclude flattenbool falseFlatten directory structure in output varsmap — Variables to pass to all templates
Field Type Description successbool Whether processing succeeded processedint Number of files processed
// Process all templates in a directory
let result = liquid . process ( {
source: " /templates/kubernetes/ " ,
destination: " /output/k8s/ " ,
log ( " Processed " + result . processed + " templates " )
// Process with include/exclude filters
include: [ " *.yaml " , " *.conf " ],
exclude: [ " *.bak " , " test-* " ],
vars: { environment: " staging " }
// Flatten directory structure
source: " /templates/nested/config/ " ,
destination: " /output/flat/ " ,
vars: { host: " localhost " }
Workflow variable functions.
Scope: System
Function Description vars.set()Set workflow variables from a map vars.readFile()Read file contents into variables vars.readGlob()Read files matching a glob pattern into a map variable
Set workflow variables from a map of key-value pairs.
Parameter Type Default Description varsmap — Map of variable name → value (required)
Field Type Description successbool Whether variables were set contextmap Map of set variables
// Set multiple variables
environment: " production " ,
// Set computed variables
let timestamp = new Date () . toISOString ()
build_id: " build- " + Date . now ()
Read file contents into workflow variables. Supports single file or multiple files.
Parameter Type Default Description pathstring — File path to read (required) setvarstring "content"Variable name to store content
Parameter Type Default Description filesmap — Map of variable name → file path
Field Type Description successbool Whether read succeeded contextmap Map of variable name → file content
let result = vars . readFile ( {
path: " /config/settings.yaml " ,
log ( " Config: " + result . context . config )
let result = vars . readFile ( {
cert: " /etc/ssl/cert.pem " ,
log ( " Cert loaded: " + result . context . cert . substring ( 0 , 30 ))
log ( " Key loaded: " + result . context . key . substring ( 0 , 30 ))
Read files matching a glob pattern into a map variable. Each matching file becomes a key-value entry (filepath → content).
Parameter Type Default Description patternstring — Glob pattern to match files (required) setvarstring "files"Variable name to store result map
Parameter Type Default Description globsmap — Map of variable name → glob pattern
Field Type Description successbool Whether read succeeded contextmap Map of variable name → map of filepath → content
// Read all YAML config files
let result = vars . readGlob ( {
pattern: " /config/*.yaml " ,
log ( " Loaded " + Object . keys ( result . context . configs ) . length + " config files " )
// Read multiple glob patterns
let result = vars . readGlob ( {
templates: " /templates/*.liquid " ,
configs: " /config/*.yaml " ,
log ( " Templates: " + Object . keys ( result . context . templates ) . length )
log ( " Configs: " + Object . keys ( result . context . configs ) . length )
Numeric and string computation functions.
Scope: System
Function Description compute.sum()Add two numeric values compute.concat()Concatenate two strings compute.replicate()Create a deep copy of a record
Add two numeric values together.
Parameter Type Default Description valuenumber — Base value (required) addnumber — Value to add (required)
Field Type Description successbool Whether the computation succeeded resultnumber Sum of the two values errorstring Error message if failed
// Add two numeric values
var result = compute . sum ( { value: 42 , add: 8 } );
console . log ( result . result ); // 50
Concatenate two strings together.
Parameter Type Default Description valuestring — Base string (required) addstring — String to concatenate (required)
Field Type Description successbool Whether the computation succeeded resultstring Concatenated string errorstring Error message if failed
// Concatenate two strings
var result = compute . concat ( { value: " Hello " , add: " World " } );
console . log ( result . result ); // "Hello World"
Create a deep copy of a record (key-value map).
Parameter Type Default Description recordmap — Record to replicate (required)
Field Type Description successbool Whether the replication succeeded resultmap Deep copy of the input record errorstring Error message if failed
// Create a deep copy of a record
var result = compute . replicate ( {
record: { name: " Alice " , age: 30 , role: " admin " }
var copy = result . result ;
console . log ( copy . name ); // "Alice"
Multi-field aggregation computations.
Scope: System
Function Description aggregate.compute()Compute aggregate operations (sum, avg, min, max, count) on a set of records
Perform multiple aggregate operations across multiple fields on an array of records. Returns a single result map with keys named {field}_{op}.
Parameter Type Default Description fieldslist — List of field specifications (required) fields[].fieldstring — Field name to aggregate fields[].opslist — Operations to apply: sum, avg, min, max, count recordslist — List of key-value maps representing records (required)
Field Type Description successbool Whether the computation succeeded resultmap Aggregated values keyed as {field}_{op}, plus count (total records) errorstring Error message if failed
// Compute sum and average of amounts
var result = aggregate . compute ( {
{ field: " amount " , ops: [ " sum " , " avg " , " min " , " max " ] },
{ field: " quantity " , ops: [ " sum " ] }
{ amount: 100 , quantity: 5 },
{ amount: 200 , quantity: 3 },
{ amount: 150 , quantity: 8 }
// result.result = { amount_sum: 450, amount_avg: 150, amount_min: 100,
// amount_max: 200, quantity_sum: 16, count: 3 }
// Read CSV and aggregate in one script
var data = csv . read ( { path: " /data/sales.csv " } );
var stats = aggregate . compute ( {
{ field: " revenue " , ops: [ " sum " , " avg " ] },
{ field: " units " , ops: [ " sum " , " min " , " max " ] }
console . log ( " Total revenue: " + stats . result . revenue_sum );
console . log ( " Avg revenue: " + stats . result . revenue_avg );
console . log ( " Total units: " + stats . result . units_sum );
local result = aggregate . compute ({
{ field = " score " , ops = { " avg " , " min " , " max " } }
Read and write CSV files.
Scope: System
Function Description csv.read()Read a CSV file into an array of records csv.write()Write records to a CSV file
Read a CSV file and return all rows as key-value records. The first row is used as the header.
Parameter Type Default Description pathstring — CSV file path (required)
Field Type Description successbool Whether the read succeeded recordsarray Array of key-value maps (one per row) errorstring Error message if failed
for ( var i = 0 ; i < result . records . length ; i ++ ) {
console . log ( result . records [ i ] . name + " : " + result . records [ i ] . email );
Write an array of key-value records to a CSV file.
Parameter Type Default Description pathstring — Output CSV file path (required) recordsarray — Array of key-value maps to write (required) headerslist — Column headers (inferred from first record if omitted) overwritebool falseTruncate file before writing (vs append)
Field Type Description successbool Whether the write succeeded countint Number of records written errorstring Error message if failed
// Write records to a CSV file
path: " /output/data.csv " ,
{ name: " Alice " , age: " 30 " },
{ name: " Bob " , age: " 25 " }
console . log ( " Wrote " + result . count + " records " );
// Read, transform, and write CSV
var data = csv . read ( { path: " /data/input.csv " } );
for ( var i = 0 ; i < data . records . length ; i ++ ) {
full_name: r . first_name + " " + r . last_name ,
path: " /data/output.csv " ,
Read and write Excel spreadsheet files.
Scope: System
Function Description excel.read()Read an Excel file into an array of records excel.write()Write records to an Excel file
Read an Excel spreadsheet and return all rows as key-value records. The first row of each sheet is used as the header.
Parameter Type Default Description pathstring — Excel file path (required) sheetstring — Sheet name (reads all sheets if omitted)
Field Type Description successbool Whether the read succeeded recordsarray Array of key-value maps (one per row) errorstring Error message if failed
// Read records from an Excel file
var result = excel . read ( { path: " /data/report.xlsx " , sheet: " Sales " } );
for ( var i = 0 ; i < result . records . length ; i ++ ) {
console . log ( result . records [ i ] . product + " : " + result . records [ i ] . amount );
Write an array of key-value records to an Excel spreadsheet.
Parameter Type Default Description pathstring — Output Excel file path (required) sheetstring — Sheet name recordsarray — Array of key-value maps to write (required) overwritebool falseCreate new file (vs append to existing)
Field Type Description successbool Whether the write succeeded countint Number of records written errorstring Error message if failed
// Write records to an Excel file
var result = excel . write ( {
path: " /output/report.xlsx " ,
{ name: " Alice " , score: " 95 " },
{ name: " Bob " , score: " 87 " }
console . log ( " Wrote " + result . count + " records " );
Read and write Apache Parquet files.
Scope: System
Function Description parquet.read()Read a Parquet file into an array of records parquet.write()Write records to a Parquet file
Read an Apache Parquet file and return all rows as key-value records. All values are converted to strings.
Parameter Type Default Description pathstring — Parquet file path (required)
Field Type Description successbool Whether the read succeeded recordsarray Array of key-value maps (one per row) errorstring Error message if failed
// Read records from a Parquet file
var result = parquet . read ( { path: " /data/events.parquet " } );
for ( var i = 0 ; i < result . records . length ; i ++ ) {
console . log ( JSON . stringify ( result . records [ i ]));
Write an array of key-value records to an Apache Parquet file. All fields are written as strings.
Parameter Type Default Description pathstring — Output Parquet file path (required) recordsarray — Array of key-value maps to write (required)
Field Type Description successbool Whether the write succeeded countint Number of records written errorstring Error message if failed
// Write records to a Parquet file
var result = parquet . write ( {
path: " /output/data.parquet " ,
{ id: " 1 " , name: " Alice " },
console . log ( " Wrote " + result . count + " records " );
Query and mutate Data API entity stores.
Scope: System
Note: All entity functions require a pipeline environment with Data API EntityManager. The namespace functions are stubs in Script standalone mode and return errors directing to the YAML pipeline interface.
Function Description entity.query()Query records from an entity store entity.mutate()Write records to an entity store
Query records from a Data API entity store.
Parameter Type Default Description fileslist — Entity definition file paths dbpoolmap — Database pool configuration datastorestring — Datastore name (alternative to files/dbpool) querystring — Entity query to execute (required)
Field Type Description successbool Whether the query succeeded recordsarray Array of entity records errorstring Error message (stub always returns error)
// Entity queries are not available in Script standalone mode.
// Use the YAML pipeline interface (readentity or readentity-in-datastore) instead.
var result = entity . query ( {
files: [ " /schemas/user.yaml " ] ,
query: " SELECT * FROM user "
// result = { success: false, error: "entity operations require pipeline environment" }
Write records to a Data API entity store via bulk mutation.
Parameter Type Default Description datastorestring — Datastore name (required) recordmap — Entity record data (required)
Field Type Description successbool Whether the mutation succeeded errorstring Error message (stub always returns error)
// Entity mutations are not available in Script standalone mode.
// Use the YAML pipeline interface (writeentity-in-datastore) instead.
var result = entity . mutate ( {
datastore: " customer-db " ,
record: { id: " 1 " , name: " Alice " }
// result = { success: false, error: "entity operations require pipeline environment" }
Execute inline morph scripts with multi-language support.
Scope: System
Function Description morph.execute()Run a morph script inline with specified language and input
Execute a morph script from within another Script script. The target script must define a morph(input) function. Enables nested script execution for dynamically generating transformation code or running user-provided scripts.
Parameter Type Default Description languagestring javascriptScript language: javascript, js, lua, starlark, javascript-v8, v8 codestring — Script source defining a morph(input) function (required) inputany — Input data passed to the morph function
Field Type Description successbool Whether the execution succeeded resultany Return value from the morph function errorstring Error message if failed
// Execute a JavaScript morph inline
var result = morph . execute ( {
code: ' function morph(input) { return input.x * 2; } ' ,
// result = { success: true, result: 42 }
// Execute a Lua morph from JavaScript
var result = morph . execute ( {
code: ' function morph(input) return input.name .. " processed" end ' ,
// result = { success: true, result: "Alice processed" }
// Combine csv.read + morph.execute for dynamic processing
var data = csv . read ( { path: " /data/records.csv " } );
var transformCode = ' function morph(input) { return { upper: input.name.toUpperCase(), len: input.name.length }; } ' ;
for ( var i = 0 ; i < data . records . length ; i ++ ) {
var transformed = morph . execute ( {
console . log ( JSON . stringify ( transformed . result ));
Execute shell commands and parse CSV output.
Scope: System
Function Description stdout.exec()Execute a command and parse its CSV output into records
Execute a shell command and parse its stdout as CSV into key-value records. The first line of output is used as the header.
Parameter Type Default Description commandstring — Shell command to execute (required)
Field Type Description successbool Whether the execution succeeded recordsarray Array of key-value maps parsed from CSV output outputstring Raw command output errorstring Error message if failed
// Execute a command and parse CSV output
var result = stdout . exec ( {
command: " echo 'name,age \n Alice,30 \n Bob,25' "
for ( var i = 0 ; i < result . records . length ; i ++ ) {
console . log ( result . records [ i ] . name + " is " + result . records [ i ] . age );
// Read system process list
var result = stdout . exec ( {
command: " ps aux --no-headers | awk '{print $1 \" , \" $2 \" , \" $11}' "
console . log ( " Found " + result . records . length + " processes " );