Node Reference

Node Properties

INodeProperties

PropertiesTypeDescription
labelStringDisplay name of the node
nameStringActual name of the node using CamelCase
iconStringIcon name in the folder
typeEnumType of node. Can be either trigger or action or webhook
versionNumberVersion of the node
description (optional)StringDescription of the node
incomingNumberNumber of input edges this node is expected to receive from upstream. From ui, this corresponds to number of dots available at the top of the node.
outgoingNumberNumber of output edges this node is expected to emit to downstream. From ui, this corresponds to number of dots available at the bottom of the node.

Example

class ExampleBlock implements INode {
label: string;
name: string;
type: NodeType;
description?: string;
version: number;
icon: string;
incoming: number;
outgoing: number;
constructor() {
this.label = 'ExampleBlock';
this.name = 'exampleBlock';
this.icon = 'example-block.svg';
this.type = 'action';
this.version = 1.0;
this.description = 'This is an example block';
this.incoming = 1;
this.outgoing = 1;
}
}

Node Parameters

INodeParams[]

There are 4 main groups of node parameters. They are designed to give a better user experience in ui, allowing user to enter inputs step by step.

ParametersDescription
actions (optional)Type of action/event this node is going to execute or get triggered
networks (optional)Blockchain network to execute on. Only used for onchain nodes
credentials (optional)Credential needed to authenticate the node
inputParameters (optional)Remaining input parameters (e.g: query params, body)

Outerbridge Node Parameters

Example

class ExampleBlock implements INode {
//...properties
actions: INodeParams[];
networks: INodeParams[];
credentials: INodeParams[];
inputParameters: INodeParams[];
constructor() {
//...properties
this.actions = [
{
label: 'Select Action',
name: 'action',
type: 'options',
options: [
{
label: 'Action 1',
name: 'action1',
},
],
default: 'action1',
},
] as INodeParams[];
this.networks = [
{
label: 'Network',
name: 'network',
type: 'options',
options: [
{
label: 'Ethereum Mainnet',
name: 'homestead',
},
],
default: 'homestead',
},
] as INodeParams[];
this.credentials = [
{
label: 'Credential Method',
name: 'credentialMethod',
type: 'options',
options: [
{
label: 'Some API Key',
name: 'someApi',
},
],
default: 'someApi',
},
] as INodeParams[];
this.inputParameters = [
{
label: 'Input Field 1',
name: 'inputField1',
type: 'string',
default: '',
},
] as INodeParams[];
}

Node Parameters Properties

INodeParams

Each node parameter has the following properties:

PropertiesTypeDescription
labelStringDisplay name of parameter
nameStringActual name of parameter using CamelCase
typeEnum NodeParamsTypeType of parameter
default (optional)String, Number, Boolean, Object, ArrayDefault value of parameter
description (optional)StringDescription of parameter
options (optional)Array INodeOptionsValue[]Parameter options. Used with options
array (optional)Array INodeParams[]Parameter array. Used with array. See array example
loadMethod (optional)StringMethod name used to load async options. Used with asyncOptions. See asyncOptions example
loadFromDbCollections (optional)DbCollectionName[]Which database collection to retrieve from server. Used with asyncOptions and loadMethod. See asyncOptions example
optional (optional)Boolean, INodeDisplayTo indicate if this parameter is an optional field. If not specified, parameter is mandatory
show (optional)INodeDisplayShow this parameter if condition is met
hide (optional)INodeDisplayHide this parameter if condition is met
rows (optional)NumberNumber of rows for the parameter input field
placeholder (optional)StringPlaceholder text of the parameter input field

Node Parameter Option Properties

INodeOptionsValue

PropertiesTypeDescription
labelStringDisplay name of option
nameStringActual name of option using CamelCase
description (optional)StringDescription of option
parentGroup (optional)StringGroup of option
inputParameters (optional)StringDescription of additional parameter needed for this option. See inputParameters example
exampleParameters (optional)StringExample of additional parameter needed for this option. See exampleParameters example
exampleResponse (optional)ObjectExample of output response for this option. See exampleResponse example
show (optional)INodeDisplayShow this option if condition is met
hide (optional)INodeDisplayHide this option if condition is met
hideRegisteredCredential (optional)BooleanOnly used on credentialMethod option to hide registeredCredentials. See hideRegisteredCredential example

Node Parameter Display

INodeDisplay

Can be used with these parameter properties: show, hide to display or hide the parameter. This is useful when you want to hide a specific parameter depending on other parameters.

Example

this.inputParameters = [
{
label: 'Input 1',
name: 'input1',
type: 'options',
options: [
{
label: 'Option A',
name: 'optionA',
},
{
label: 'Option B',
name: 'optionB',
},
{
label: 'Option C',
name: 'optionC',
},
{
label: 'Option D',
name: 'optionD',
},
]
},
{
label: 'Input 2',
name: 'input2',
type: 'string',
description: 'Only show when Input1 has value of optionA OR optionB',
show: {
'inputParameters.input1': ['optionA', 'optionB']
}
},
{
label: 'Input 3',
name: 'input3',
type: 'string',
description: 'Only show when Input1 has value of optionC',
show: {
'inputParameters.input1': ['optionC']
}
},
{
label: 'Input 4',
name: 'input4',
type: 'string',
description: 'Only hide when Input1 has value of optionD',
show: {
'inputParameters.input1': ['optionD']
}
}
]

It supports string and regex match as well:

this.inputParameters = [
{
label: 'Input 1',
name: 'input1',
type: 'string',
},
{
label: 'Input 2',
name: 'input2',
type: 'string',
description: 'Only show when Input1 === "matchstring"',
show: {
'inputParameters.input1': "matchstring"
}
},
{
label: 'Input 3',
name: 'input3',
type: 'string',
description: 'Only show when Input1 matches the regex pattern where string is not empty or blank',
show: {
'inputParameters.input1': '(.|\\s)*\\S(.|\\s)*'
}
}
]

When used on options properties to display/hide a specific option depending on other parameters:

this.inputParameters = [
{
label: 'Input 1',
name: 'input1',
type: 'options',
options: [
{
label: 'Option A',
name: 'optionA',
},
{
label: 'Option B',
name: 'optionB',
}
]
},
{
label: 'Input 2',
name: 'input2',
type: 'options',
options: [
{
label: 'Option C',
name: 'optionC',
description: 'Only show optionC when Input1 has value of optionA',
show: {
'inputParameters.input1': ['optionA']
}
},
{
label: 'Option D',
name: 'optionD',
description: 'Only hide optionD when Input1 has value of optionA',
hide: {
'inputParameters.input1': ['optionA']
}
}
]
}
]

INodeDisplay can also be used on optional parameter properties to make a specific parameter become an optional parameter depending on other parameters.

this.inputParameters = [
{
label: 'Input 1',
name: 'input1',
type: 'options',
options: [
{
label: 'Option A',
name: 'optionA',
},
{
label: 'Option B',
name: 'optionB',
}
]
},
{
label: 'Input 2',
name: 'input2',
type: 'string',
description: 'Make Input2 become optional if Input1 has value of optionB, otherwise it is mandatory',
optional: {
'inputParameters.input1': ['optionB']
}
},
]

Node Parameter Type

NodeParamsType

A parameter can be one of these types: string, number, boolean, options, asyncOptions, array, password, json, code, date, file.

String

{
label: 'Input String',
name: 'inputString',
type: 'string',
}
// Get as string
const inputString = nodeData[paramCategory].inputString as string;

Outerbridge Input String

Number

{
label: 'Input Number',
name: 'inputNumber',
type: 'number',
}
// Get as number
const inputNumber = nodeData[paramCategory].inputNumber as number;

Outerbridge Input Number

Options

{
label: 'Input Options',
name: 'inputOptions',
type: 'options',
options: [
{
label: 'Option A',
name: 'optionA',
},
{
label: 'Option B',
name: 'optionB',
},
]
}
// Get as string
const inputOptions = nodeData[paramCategory].inputOptions as string;

Outerbridge Input Options

AsyncOptions

AsyncOptions can be used when we want to display parameter options depending on the value of other parameters. It has to be used with loadMethod to specify which function to get the options.

class ExampleAsyncOption implements INode {
//...properties
//...parameters
inputParameters?: INodeParams[];
constructor() {
//...properties
//...parameters
this.inputParameters = [
{
label: 'Input 1',
name: 'input1',
type: 'options',
options: [
{
label: 'Option A',
name: 'optionA',
},
{
label: 'Option B',
name: 'optionB',
}
]
},
{
label: 'Input 2',
name: 'input2',
type: 'asyncOptions',
loadMethod: 'getInput2Option'
},
] as INodeParams[];
}
loadMethods = {
async getInput2Option(nodeData: INodeData): Promise<INodeOptionsValue[]> {
const returnData: INodeOptionsValue[] = [];
const inputParametersData = nodeData.inputParameters;
if (inputParametersData === undefined) throw new Error('Required data missing');
const input1 = inputParametersData.input1 as string;
if (input1 === 'optionA') {
returnData.push({
label: 'A Selected',
description: 'Only visible when Option A selected',
name: 'aSelected',
});
} else if (input1 === 'optionB') {
returnData.push({
label: 'B Selected',
description: 'Only visible when Option B selected',
name: 'bSelected',
});
}
return returnData;
}
}
}

Outerbridge Async Options

AsyncOptions can also be used with loadFromDbCollections to retrieve database collection.

class ExampleAsyncOption implements INode {
//...properties
//...parameters
inputParameters?: INodeParams[];
constructor() {
//...properties
//...parameters
this.inputParameters = [
{
label: 'Select Workflow',
name: 'workflow',
type: 'asyncOptions',
loadFromDbCollections: ['Workflow'],
loadMethod: 'getWorkflows',
}
] as INodeParams[];
}
loadMethods = {
async getWorkflows(nodeData: INodeData, dbCollection?: IDbCollection): Promise<INodeOptionsValue[]> {
const returnData: INodeOptionsValue[] = [];
const workflows: IWorkflow[] = dbCollection.Workflow;
for (let i = 0; i < workflows.length; i+=1) {
returnData.push({
label: workflows[i].name,
name: workflows[i]._id,
});
}
return returnData;
}
}
}

See ContractEventTrigger.ts example

Array

Array can be used whenever we want to display a set of parameter collections.

{
label: 'Input Array',
name: 'inputArray',
type: 'array',
array: [
{
label: 'Child Input Options',
name: 'childInputOptions',
type: 'options',
options: [
{
label: 'Option A',
name: 'optionA',
},
{
label: 'Option B',
name: 'optionB',
},
]
},
{
label: 'Child Input String',
name: 'childInputString',
type: 'string',
}
]
}
// Declare custom array interface
interface IArray {
childInputOptions: string;
childInputString: string;
}
for (const item of nodeData[paramCategory].inputArray as IArray[]) {
console.log(item.childInputOptions)
console.log(item.childInputString)
}

Outerbridge Input Array

See Scheduler.ts example

Password

{
label: 'Input Password',
name: 'inputPW',
type: 'password',
}
// Get as string
const inputPW = nodeData[paramCategory].inputPW as string;

Outerbridge Input Password

Json

Can be used when the parameter is of JSON format {} or an array [].

{
label: 'Input Json',
name: 'inputJson',
type: 'json',
}
// Get as string
let inputJson = nodeData[paramCategory].inputJson as string;
//Remove whitespaces
inputJson = inputJson.replace(/\s/g, '');
try {
const parsedInputJson = JSON.parse(inputJson);
} catch(error) {
throw handleErrorMessage(error);
}

Outerbridge Input Json

Code

{
label: 'Input Code',
name: 'inputCode',
type: 'code',
}
// Get as string
const inputCode = nodeData[paramCategory].inputCode as string;

Outerbridge Input Code

Date

{
label: 'Input Date',
name: 'inputDate',
type: 'date',
}
// Get as string
const inputDate = nodeData[paramCategory].inputDate as string;
// Convert to milliseconds
const startTime = Date.parse(inputDate);

Outerbridge Input Date

File

{
label: 'Input File',
name: 'inputFile',
type: 'file',
}
// Get as string (base64)
const fileBase64 = nodeData[paramCategory].inputFile as string;
// Get file as buffer
const splitDataURI = fileBase64.split(',');
const bf = Buffer.from(splitDataURI[1], "base64");

Outerbridge Input File

Folder

{
label: 'Input Folder',
name: 'inputFolder',
type: 'folder',
}
const folderContent = nodeData[paramCategory].inputFolder as string;
const base64Array = JSON.parse(folderContent.replace(/\s/g, ''));
for (let i = 0; i < base64Array.length; i+=1 ) {
const fileBase64 = base64Array[i];
const splitDataURI = fileBase64.split(',');
const filepath = (splitDataURI.pop() || 'filepath:').split(':')[1];
const bf = Buffer.from((splitDataURI.pop() || ''), "base64");
}

Outerbridge Input Folder