Array Module

Add

Description:
Add an object or value to a pre-existing array, like appending to the ‘numbers’ array in the process data object.

{
    "type": "array",
    "action": "add",
    "args": {
        "target": "$data.numbers",
        "value": 10
    }
}

Remove

Description:
Removes an value from a existing array.

{
   "type": "array",
   "action": "remove",
   "args": {
       "target": "$data.numbers",
       "value": 10
   }
}

Transfer

Description:
Move an object from one array to another, remove from the source and append it to the target.

{
  "type": "array",
  "action": "transfer",
  "args": {
       "source": "$data.array1",
       "target": "$data.array2",
       "value": 10
   }
}

Array to csv for a single field

Description:
Export an array of objects into a CSV text format for a specified field. This will create a single CSV line with each value in the collection separated by a delimiter.

{
    "type": "array",
    "action": "field_to_csv",
    "args": {
        "source": "@data.array",
        "target": "@data.csv",
        "field": "value",
        "delimeter": ";"
    }
}

Result example:
[{ value: 10 }, { value: 20 }, { value: 30 }] => “10;20;30”

Array to csv for multiple fields

Description:
Export an array of objects to CSV text, where each row comprises a combination of field values separated by a delimiter. Each object in the array corresponds to a row in the CSV, resulting in an array of CSV text lines.

{
    "type": "array",
    "action": "field_to_csv",
    "args": {
        "source": "@data.array",
        "target": "@data.csv",
        "fields": ["code", "value"],
        "delimeter": ";"
    }
}

Concatenate two arrays

Description:
Merge multiple arrays into one comprehensive result array, containing the elements from all the concatenated source arrays, regardless of their number.

{
    "type": "array",
    "action": "concat",
    "args": {
        "sources": ["$process.array1", "$process.array2"],
        "target": "$process.array"
    }
}

Update fields

Description:
Modify the values of a specific field in all objects within an array

{
    "type": "array",
    "action": "change_values",
    "args": {
        "source": "$data.array",
        "changes": {
            "code": "new value",
            "value": "$process.field"
        }
    }
}

“changes” is a dictionary where each key represents the name of the field to be altered, and the corresponding value is either the new value to assign or a path to the field that provides this new value.

Get field value

Description:
Retrieve the value of a specified field from an object located at a given index within an array.

{
    "type": "array",
    "action": "get_value",
    "args": {
        "source": "$data.array",
        "index": 10,
        "property": "value",
        "target": "$data.value"
    }
}

Flatten array using map

Description:
Create a new array from an existing array of objects, extracting and including only the fields of interest.

{
    "type": "array",
    "action": "map_objects",
    "args": {
        "source": "$process.array",
        "fields": ["code", "value"],
        "target": "$process.result"
    }
}

Get records batch

Description:
Fetch records starting from a designated page number, each batch conforming to a predetermined size. The records in each batch are then mapped to include only the fields of interest in the resulting set for that page.

{
    "type": "array",
    "action": "get_records",
    "args": {
       "source": "$data.array",
       "page_number": 0,
       "page_size": 10,
       "fields": ["field1", "field2"],
       "target": "$process.array"
    }
 }

Get value range

Description:
Calculate the smallest (minimum) and largest (maximum) values in a given array, and store these values in a resulting object with properties “min” and “max” corresponding to these calculated values.

{
    "type": "array",
    "action": "get_range",
    "args": {
        "source": "$process.array",
        "field": "field1",
        "target": "$process.array"
    }
}

Calculate page count

Description:
Determine the number of pages required to accommodate a given array, based on the specified page size.

{
    "type": "array",
    "action": "calculate_paging",
    "args": {
        "source": "$data.array",
        "page_size": 10,
        "target": "$process.pageSize"
    }
}

Assign and map fields

Description:
Transform an array of objects into a new array, in which fields from the original objects are renamed according to a predefined mapping. For example, if an object in the source array has a field named “value,” it will be represented as “oldValue” in the new array, ensuring “oldValue” in the new object aligns with “value” in the original. The new array will exclusively contain fields specified in these mappings.

{
    "type": "array",
    "action": "map_assign_data",
    "args": {
        "source": "$data.array",
        "mappings": {
            "id": "staffId",
            "code": "staffCode",
            "descrioption": null
        },
        "target": "$data.newArray"
    }
}

Delete properties

Description:
For each object in a given array, remove specified properties directly from the objects. This action modifies the source array itself, and thus, does not produce a separate result.

{
     "type": "array",
     "action": "delete_properties",
     "args": {
         "source": "$data.array",
         "properties": ["id", "code"]
     }
}