Data Transformation Utilities
Utility functions for common data operations like encoding, merging, grouping, and formatting. These functions help you transform data between steps in your flows.
Quick Data Transformation : These utilities handle common data manipulation tasks without needing custom code. Use them for encoding, merging objects, formatting templates, and more.
Function List
base64-encode Encode to base64
base64-decode Decode from base64
json-xml Convert JSON to XML
xml-json Convert XML to JSON
Handlebars Template Dynamic templates
Mapping JSON path data mapping
secret-key-get-node Retrieve secret keys
function-invoke Invoke other functions
sftp Upload files via SFTP
base64-encode
Encode text or objects to base64 format. Automatically handles both string and object inputs, converting objects to JSON before encoding.
Parameters
Takes a single input value directly (not wrapped in a params object):
The data to encode. Can be:
String : Encoded directly to base64
Object : Automatically converted to JSON string, then encoded to base64
Response
Returns the base64-encoded string directly (not wrapped in an object).
Example Usage
Common Use Cases
Encode files before sending to APIs
Store binary content as text
Auto-Stringify : Objects are automatically converted to JSON before encoding. No need to manually stringify objects.
base64-decode
Decode base64-encoded data. Automatically detects and parses JSON objects in the decoded output.
Parameters
Takes a single input value directly:
The base64-encoded string to decode.
Response
Returns decoded data directly (not wrapped in an object). The return type depends on the decoded content:
Object : If the decoded string is valid JSON, returns the parsed object
String : If the decoded string is plain text, returns the string
Example Usage
Common Patterns
Decode files received from APIs
Decode stored base64 data
Auto-Detection : This function automatically detects if the decoded string is valid JSON and parses it into an object. You don’t need to specify the output format or manually parse JSON.
json-xml
Transform JSON data to XML format. Useful for integrating with systems that require XML.
Parameters
json
object | string | Buffer
required
The JSON data to convert to XML. Can be:
Object : Converted directly to XML
String : Parsed as JSON first, then converted
Buffer : Converted to string, parsed as JSON, then converted
XML conversion options:
useXmlJs (boolean): Use xml-js library instead of custom converter
compact (boolean, default: false): Produce compact XML format
spaces (number, default: 0): Number of spaces for indentation
fullTagEmptyElement (boolean): Use full tags instead of self-closing tags
indentCdata (boolean): Indent CDATA sections
indentAttributes (boolean): Print attributes on multiple lines
ignoreDeclaration (boolean): Omit XML declaration
ignoreInstruction (boolean): Omit processing instructions
ignoreAttributes (boolean): Omit element attributes
ignoreComment (boolean): Omit comments
ignoreCdata (boolean): Omit CDATA sections
ignoreDoctype (boolean): Omit DOCTYPE declaration
ignoreText (boolean): Omit text content
Response
Returns XML as a string with XML declaration.
Example Usage
Common Use Cases
Legacy System Integration
Send data to XML-only systems
Generate XML files for export
XML Declaration : The output always includes XML version declaration at the beginning. Use ignoreDeclaration option set to true to omit it.
xml-json
Convert XML to JSON format. This is the reverse operation of json-xml, useful for parsing XML responses from APIs.
Parameters
The XML string to convert to JSON.
XML parsing options:
useXmlJs (boolean): Use xml-js library instead of custom parser
compact (boolean, default: false): Produce compact JSON format
trim (boolean): Trim whitespace from text content
sanitize (boolean): Replace special characters with HTML entities
nativeType (boolean): Convert numeric/boolean strings to native types
nativeTypeAttributes (boolean): Convert attribute values to native types
addParent (boolean): Add parent property to each element
alwaysArray (boolean | array): Force elements to be arrays
alwaysChildren (boolean): Always generate elements property
instructionHasAttributes (boolean): Parse processing instructions as attributes
captureSpacesBetweenElements (boolean): Capture whitespace between elements
ignoreDeclaration (boolean): Skip XML declaration
ignoreInstruction (boolean): Skip processing instructions
ignoreAttributes (boolean): Skip element attributes
ignoreText (boolean): Skip text content
ignoreComment (boolean): Skip comments
ignoreCdata (boolean): Skip CDATA sections
ignoreDoctype (boolean): Skip DOCTYPE declaration
Response
Returns a JSON string (you may need to parse it in subsequent steps).
Example Usage
Common Use Cases
Convert SOAP API responses to JSON
Legacy System Integration
Parse XML from legacy systems
Return Type : This function returns a JSON string, not a parsed object. You may need to use JSON.parse() or another step to convert the string to an object for further processing.
Handlebars Template
Use Handlebars templating engine to create dynamic templates with variables that are replaced at runtime.
Parameters
The Handlebars template string with variables in double curly braces.
The data object containing values to replace in the template.
Response
Returns the rendered template as a string.
Example Usage
Template Features
Access nested object properties
Show content based on conditions
Common Use Cases
Create personalized emails
Create dynamic notifications
Mapping
Use JSONPath expressions to select, transform, and map data into new structures. Powerful for data transformation and restructuring with support for filters, array operations, and conditional selection.
Parameters
The source data object to query and transform.
path
string | array | object
required
JSONPath expression(s) defining how to map the data:
String : Single JSONPath query
Array : For array transformations with mapping
Object : Map of output keys to JSONPath expressions
Optional lookup data accessible as variables in path expressions for filtering and conditional selection.
Response
Returns the mapped/extracted data in the specified structure.
Path Syntax
Access properties using JSONPath
Combine values using pipe delimiter
Transform arrays with custom mapping
Create new object structure
Filter using external variables
Search recursively through nested structures
Example Usage
Common Use Cases
API Response Transformation
Conditional Data Selection
Select data based on conditions
JSONPath Plus : This function uses the jsonpath-plus library with full support for complex queries, filters, recursive descent, and array operations.
secret-key-get-node
Retrieve secret values stored in QuivaWorks’ secret manager. Use this to securely access API keys, tokens, and other sensitive configuration.
Parameters
The name/identifier of the secret to retrieve.
Response
Returns an object with either a value property (on success) or an error property (if not found).
Example Usage
Error Handling
Always check for the error property in the response to handle missing keys gracefully:
Common Use Cases
Securely access API keys for external services
Retrieve database credentials
Security Best Practice : Never hardcode secrets in flows. Always use the secret manager and retrieve secrets at runtime using this function. Secrets are stored in the quiva-secrets KV bucket.
function-invoke
Invoke other QuivaWorks functions programmatically from within your flow. Useful for orchestrating complex workflows and modular function composition.
Parameters
Type of invocation:
"Async": Fire and forget (returns immediately, doesn’t wait for result)
"RequestResponse": Synchronous (waits for function to complete and returns result)
Input data to pass to the invoked function. Structure depends on the target function’s requirements.
The identifier/name of the function to invoke.
Response
Returns an object. Structure depends on the invoked function and invocation type.
Example Usage
Invocation Types
RequestResponse (Synchronous)
Wait for function completion and get result Use when : You need the result to continue processing
Invoke function without waiting Use when : Result not needed, or for triggering side effects
Common Use Cases
Chain multiple functions together
Break complex logic into reusable functions
Trigger long-running operations
Implementation : Uses QuivaWorks SDK func.invoke() method. Ensures proper function calling within the platform’s execution environment.
sftp
Upload files to SFTP servers securely. Supports both password and key-based authentication with configurable timeouts.
Parameters
SFTP server hostname or IP address.
SFTP server port number (typically 22).
Username for authentication.
The file contents to upload (as a string).
Remote file path where the file should be uploaded.
SSH private key for key-based authentication. Alternative to password authentication.
Password for password-based authentication. Alternative to key-based authentication.
SSH algorithm configuration. Specify allowed server host key algorithms.
Connection timeout in milliseconds. Default is 10 seconds.
File transfer timeout in milliseconds. Default is 30 seconds.
Response
Returns a success message string on completion, or throws an error on failure.
Example Usage
Timeout Errors
The function provides specific error messages for timeout scenarios:
If server takes too long to accept connection: Solutions :
Verify host and port are correct
Check network connectivity
Increase connectionTimeout if server is slow
If file upload takes too long: Solutions :
Increase transferTimeout for large files
Check network bandwidth
Verify server is accepting uploads
Authentication Methods
Use username and password When to use : Simple setups, testing
Use SSH private key When to use : Production environments, automated systems, enhanced security
Common Use Cases
Deliver files to partners or systems
Send backups to remote storage
Exchange data with external systems
Deploy files to remote servers
Connection Management : The SFTP connection is automatically closed after the upload completes or if an error occurs. No manual cleanup required.
Large Files : For large files, increase the transferTimeout parameter appropriately. As a guideline, allow approximately 1 second per MB plus overhead.
Best Practices
Auto-Detection Benefits base64-decode automatically parses JSON - leverage this for cleaner flows
Always Handle Errors Check for error properties in responses, especially with secret-key-get-node
Template Dynamic Content Use Handlebars for emails, notifications, and reports with the variables parameter
Restructure with Mapping Use Mapping with JSONPath for powerful data transformations
Secure SFTP Uploads Prefer key-based authentication over passwords for production SFTP
Store Secrets Securely Always use secret manager for sensitive data - never hardcode secrets
Function Orchestration Use function-invoke for modular, reusable flow architectures
Set Appropriate Timeouts Configure SFTP timeouts based on file sizes and network conditions
Migration Notes
If you’re updating existing flows that use these functions, note these breaking changes:
Breaking Changes:
base64-encode : Remove encoding parameter - pass data directly
base64-decode : Remove output_encoding parameter - auto-detection enabled
handlebars : Rename data parameter to variables
json-xml : Restructure to use json and options object instead of separate parameters
secret-key-get-node : Rename key_name to key, expect simplified response structure
Next Steps
Stream Functions Real-time event processing
Key-Value Storage Fast key-based storage
Object Storage Store large files
Functions Step Using Functions in flows