Data Transformation Addon

The purpose of this block is to produce a transformed result based on the data from the source

and filters blocks.

This block can be used in conjunction with pagination and filters for the

source block.

Usage

As shown in the example below, dataTransformationAddon blocks should be placed after

documentsSourceAddon and filtersAddon blocks.

Properties

Property Name
Description
Example

Expression

A custom JavaScript

function that transforms

the existing source data

and returns it in a

custom format

function main(documents){

let sum = 0;

for(let i=0; i< documents.length; i++) {

sum+=

documents[i].document.credentialSubject[0].fiel

d0 +

d1;

documents[i].document.credentialSubject[0].fiel

}

return {

sum

}

}

done(main(documents));

API

The API for the dataTransformationAddon uses the GET method

Example response to a GET request that returns the sum of 2 fields in a custom format:

{
"sum": 10
}

The request can be fulfilled through both endpoint

/api/v1/policies/{policyId}/blocks/{blockId}

and

/api/v1/policies/{policyId}/tag/{blockTag}/blocks

Last updated