Skip to main content

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):
input
string | object
required
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
Create data URLs or embed in JSON
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:
input
string
required
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
options
object
XML conversion options:

Response

Returns XML as a string with XML declaration.

Example Usage

Common Use Cases

Send data to XML-only systems
Generate XML files for export
Generate insurance industry standard formats
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

xml
string
required
The XML string to convert to JSON.
options
object
XML parsing options:

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
Parse XML from legacy systems
Process XML files
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

template
string
required
The Handlebars template string with variables in double curly braces.
variables
object
required
The data object containing values to replace in the template.

Response

Returns the rendered template as a string.

Example Usage

Template Features

Insert dynamic values
Access nested object properties
Show content based on conditions
Iterate over arrays

Common Use Cases

Create personalized emails
Generate dynamic reports
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

data
object
required
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
lookupData
object
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

Transform API responses to your format
Extract specific fields from complex objects
Convert between data formats
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

key
string
required
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
Access service tokens
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

invocation_type
string
required
Type of invocation:
  • "Async": Fire and forget (returns immediately, doesn’t wait for result)
  • "RequestResponse": Synchronous (waits for function to complete and returns result)
payload
object
required
Input data to pass to the invoked function. Structure depends on the target function’s requirements.
subject
string
required
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

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

host
string
required
SFTP server hostname or IP address.
port
number
required
SFTP server port number (typically 22).
username
string
required
Username for authentication.
fileContents
string
required
The file contents to upload (as a string).
filePath
string
required
Remote file path where the file should be uploaded.
privateKey
string
SSH private key for key-based authentication. Alternative to password authentication.
password
string
Password for password-based authentication. Alternative to key-based authentication.
algorithms
object
SSH algorithm configuration. Specify allowed server host key algorithms.
connectionTimeout
number
default:"10000"
Connection timeout in milliseconds. Default is 10 seconds.
transferTimeout
number
default:"30000"
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