Spanish Total.js
English
Documentation For AI agents
Contents

Data and transformations

Components that parse, read, template and generate data.

.md GitHub
On this page

Components that parse, read, template and generate data. This page holds the catalogue groups Transformations, Objects, Data, Array, Templates, HTML, Generators, Scripting.

Each entry lists the inputs and outputs of the component, its main settings and the text of its readme. To add a component to a FlowStream, see Download components.

API

component

cheerio.html · version 1

Runs your code with Cheerio to read data from HTML.
ParameterTypeDescription
fn? String The code that reads the HTML. $ is the Cheerio instance and html is the HTML string; return the result.
path? String Path to html.

Inputs: input (Input).

Outputs: output (Output).

Flow installs the npm package cheerio when you add the component.

Uses Cheerio

Please refer to the documentation for available functions.

Input

<any>

Output

{
result: <the data returned from the code>,
input: <incomming data>
}

Example code

// instance : component instance
// $: cheerio instance
// html: html string

var txt = [];
$('ul > li').each(function (i, elem) {
txt.push($(this).text());
});
return txt;
component

dataparser.html · version 1

Splits a buffer or string into parts by new lines or by begin and end phrases.
ParameterTypeDescription
convert? Boolean Convert parsed value to the object. Default: false
beg? String Begin phrase.
end? String End phrase.

Inputs: input (Input).

Outputs: output (Output).

The component can parse newline data or begin/end phrases in the buffer or string. In addition, it can help with parsing XML or CSV files.

component

model.html · version 3

Prepares incoming data according to a schema.
ParameterTypeDescription
name? String Model name. Default: Model
path? String Load data from the specific property/field.
rewrite? Boolean Rewrite value only (otherwise, it will replace entire message data). Default: true

Inputs: input (Data), partial (Partial data).

Outputs: output (Output), error (Error).

This component prepares incoming data according to the defined schema. Output is prepared model or Error.

component

object.html · version 1

Creates an object from a Tangular template.
ParameterTypeDescription
template? String The Tangular template of the object.

Inputs: input (Input).

Outputs: output (Output).

The component creates an object from the defined string (Tangular) template. With the help of the Tangular template engine, you can use conditions, loops, etc..

Available markup:

  • {{ data.key }} represents data
  • {{ variables.key }} represents local and global Flow variables
  • {{ hostname }} contains a current URL address to the main Flow app {String}
  • {{ url }} contains a current URL address to the current Flow {String}
  • {{ env }} contains a current environment {String}
component

qrcode.html · version 1

Generates a QR code.

Inputs: input (Input).

Outputs: output (Output), error (Error).

Flow installs the npm package qrcode when you add the component.

The component generates QR Code.

Input data:

{
    text: String
}

Output data:

{
    text: String,
    data: 'Data URL - BASE64'
}
component

read.html · version 3

Reads specific values from the data according to a map.
ParameterTypeDescription
path? String Load data from the specific property/field.
keep? Boolean Keep the message data and transform only specific paths. Default: false
rewrite? String Rewrite value only (otherwise, it will replace entire message data).

Inputs: input (Input).

Outputs: output (Output).

This component reads specific values according to the configured map.

component

rssreader.html · version 1

Downloads every item of an RSS feed.
ParameterTypeDescription
url? String URL address.
type? String Output. One of: a (Send all items), b (Send only new items), c (Send every item separately), d (Send only new items separately). Default: a

Inputs: input (Trigger).

Outputs: output (Output).

The component downloads every item from the RSS source. A message on to this Trigger input starts downloading RSS data.

Example:

{
    title: String,
    description: String,
    link: String,
    image: String, // optional
    date: Date // optional
}
component

script.html · version 1

Runs your own JavaScript code with a simple send function.
ParameterTypeDescription
code? String The JavaScript code that runs for each message.

Inputs: input (Input).

Outputs: output (Output).

This component executes a custom JavaScript code as it is. To send data to the default output use send(data);

component

snapshot.html · version 1

Saves snapshots of incoming data to send them again later.
ParameterTypeDescription
id? String Message ID. Default: id
name? String Snapshot name. Default: {{ data.name }}
status? String Snapshot status. Default: Initial data
remove? String Remove snapshots older than. Default: 1 year

Inputs: input (Input).

Outputs: output (Output).

The component takes a snapshot of the incoming data and the user can reuse saved snapshots in the future.

component

split.html · version 1

Splits an array into separate messages.
ParameterTypeDescription
path? String Load data from the specific property/field.

Inputs: input (Input).

Outputs: output (Output).

The component splits a message with an array of objects on the input into separate messages with individual objects on the output.

Input example:

[
    {
        "email": "michal@totaljs.com",
        "date": 20220202,
        "name": "Michal Klacan"
    },
    {
        "email": "martin@totaljs.com",
        "date": 20220204,
        "name": "Martin Smola"
    },
    {
        "email": "peter@totaljs.com",
        "datum": 20220210,
        "name": "Peter Sirka"
    }
]

Output example:

{
    "email": "michal@totaljs.com",
    "date": 20220202,
    "name": "Michal Klacan"
}
{
    "email": "martin@totaljs.com",
    "date": 20220204,
    "name": "Martin Smola"
}
{
    "email": "peter@totaljs.com",
    "datum": 20220210,
    "name": "Peter Sirka"
}
component

tangular.html · version 1

Renders a Tangular template with the incoming data.

Inputs: input (Input).

Outputs: output (Output).

The component uses server-side implementation of Tangular template engine.

Example

Incomming data:

{
    app_name: 'Total.js Flow'
}

Template:

App name: {{ value.app_name }}

In the example bellow, the $.refs.controller is only available if the message was created by the Route component:

URL: {{ $.refs.controller.url }}
component

vs.html · version 1

Generates a variable symbol in a custom format.
ParameterTypeDescription
format? String Format. Default: yyyy####
path? String Path.
autoreset? String Auto-reset. One of: yyyy (Yearly), MM (Monthly), dd (Daily). Default: yyyy
start? Number Start from. Default: 0
reset? Boolean Reset indexer. Default: false

Inputs: input (Input).

Outputs: output (Output).

The component will generate a variable symbol according to a custom format.

Made in Europe