The Collection component is a generic component that allows users to manipulate collection-type data.
It can carry out the following tasks:
#Release Stage
Alpha
#Configuration
The component definition and tasks are defined in the definition.json and tasks.json files respectively.
#Supported Tasks
#Append
Append values to create or extend an array, or add key-value pairs to an object.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_APPEND |
Data (required) | data | any | The input data. If it's an array, the value will be appended. If it's an object, the key-value pairs from value will be added. If it's a primitive type (string, number, boolean), it will be converted to a single-element array before appending. |
Value (required) | value | any | The value to append. For arrays: the value will be appended as a new element. For objects: if value is an object, its key-value pairs will be added to the input object. For primitives: value will be appended to create/extend an array. |
Output | ID | Type | Description |
---|
Data | data | any | The resulting data structure after the append operation. Will be either an array (if input was array or primitive) or an object (if input was object). Examples: [1,2,3], {'name':'John', 'age':25}, or ['hello','world']. |
#Assign
Assign a value to a specific path in a data structure.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_ASSIGN |
Data (required) | data | any | The input data structure to modify. Can be an array, object, or primitive value. |
Path (required) | path | string | The path where to assign the value. Use dot notation for nested objects and [n] for array indices. Examples: 'users.[0].name', '.[0].key', 'metadata.tags.[2]'. |
Value (required) | value | any | The value to assign at the specified path. Can be any type (string, number, boolean, array, or object). |
Output | ID | Type | Description |
---|
Data | data | any | The resulting data structure after the assign operation. |
#Concat
Concatenate multiple arrays or merge multiple objects into a single collection.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_CONCAT |
Data (required) | data | array[any] | An array of arrays or objects to be concatenated/merged. For arrays: [[1, 2], [3, 4]] becomes [1, 2, 3, 4]. For objects: [{'a': 1}, {'b': 2}] becomes {'a': 1, 'b': 2}. Later values override earlier ones for objects. |
Output | ID | Type | Description |
---|
Data | data | any | The resulting array or object after concat operation. |
#Difference
Find elements that exist in the first array or object but not in any of the other arrays or objects.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_DIFFERENCE |
Data (required) | data | array[any] | An array of arrays or objects to find the difference. The first element is compared against all subsequent elements. For example, given arrays [[1, 2, 3], [2, 3, 4], [3, 4, 5]], the result will be [1]. For objects, given [{'a': 1, 'b': 2}, {'b': 2, 'c': 3}], the result will be {'a': 1}. |
Output | ID | Type | Description |
---|
Data | data | any | The resulting array or object after the difference operation. |
#Intersection
Find common elements that exist in all input arrays or objects.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_INTERSECTION |
Data (required) | data | array[any] | An array of arrays or objects to find common elements. For arrays: given [[1, 2, 3], [2, 3, 4]], the result will be [2, 3]. For objects: given [{'a': 1, 'b': 2}, {'b': 2, 'c': 3}], the result will be {'b': 2}. |
Output | ID | Type | Description |
---|
Data | data | any | The resulting array or object after the intersection operation. |
#Split
Split arrays or objects into smaller chunks.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_SPLIT |
Data (required) | data | any | The source data to be split. Can be: 1) An array to split into groups 2) An object to split by property count (keys are sorted alphabetically for consistent ordering) |
Size (required) | size | integer | Number of elements per group |
Output | ID | Type | Description |
---|
Data | data | array[any] | The resulting array after splitting. For arrays: array of subarrays. For objects: array of smaller objects with alphabetically ordered keys |
#Symmetric Difference
Find elements that exist in exactly one of the input arrays or objects, but not in multiple inputs.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_SYMMETRIC_DIFFERENCE |
Data (required) | data | array[any] | An array of arrays or objects to find symmetric difference. For arrays: given [[1, 2], [2, 3]], the result will be [1, 3]. For objects: given [{'a': 1, 'b': 2}, {'b': 2, 'c': 3}], the result will be {'a': 1, 'c': 3}. |
Output | ID | Type | Description |
---|
Data | data | any | The resulting array or object after the symmetric difference operation. |
#Union
Find unique elements that exist in any of the input arrays or objects.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_UNION |
Data (required) | data | array[any] | An array of arrays or objects to find unique elements. For arrays: given [[1, 2], [2, 3]], the result will be [1, 2, 3]. For objects: given [{'a': 1, 'b': 2}, {'b': 2, 'c': 3}], the result will be {'a': 1, 'b': 2, 'c': 3}. |
Output | ID | Type | Description |
---|
Data | data | any | The resulting array or object after the union operation. |
#Example Recipes
#Append
# output.data: ["a", "b"]
# output.data: ["a", "b", 0]
append-a-primitive-to-an-array:
# input.value: {"foo": "c"}
# output.data: ["a", "b", {"foo": "c"}]
append-an-object-to-an-array:
# input.data: {"foo": "a", "bar": "b"}
# output.data: [{"foo": "a", "bar": "b"}, "c"]
append-a-primitive-to-an-object:
# input.data: {"foo": "a", "bar": "b"}
# input.value: {"baz": "c"}
# output.data: {"foo": "a", "bar": "b", "baz": "c"}
append-an-object-to-an-object:
value: ${append-primitives.output.data}
append-a-primitive-to-an-array:
title: Append a primitive to an array
value: ${append-a-primitive-to-an-array.output.data}
append-an-object-to-an-array:
title: Append an object to an array
value: ${append-an-object-to-an-array.output.data}
append-a-primitive-to-an-object:
title: Append a primitive to an object
value: ${append-a-primitive-to-an-object.output.data}
append-an-object-to-an-object:
title: Append an object to an object
value: ${append-an-object-to-an-object.output.data}
#Assign
# output.data: [1, 10, 3]
# input.data: {"name": "John", "age": 30}
# output.data: {"name": "Jane", "age": 30}
# input.data: {"users": [{"metadata": {"tags": ["tag1", "tag2"]}}]}
# input.path: "users.[0].metadata.tags.[1]"
# output.data: {"users": [{"metadata": {"tags": ["tag1", "new-tag"]}}]}
path: "users.[0].metadata.tags.[1]"
# input.path: "users.[0].name"
# output.data: {"users": [{"name": "John"}]}
title: Assign an array element
value: ${assign-array-element.output.data}
title: Assign an object key
value: ${assign-object-key.output.data}
title: Assign using nested path
value: ${assign-nested-path.output.data}
title: Create and assign a primitive value
value: ${create-primitive.output.data}
title: Create and assign nested structure
value: ${create-nested-structure.output.data}
#Concat
# input.data: [[1, 2], [3, 4]]
# output.data: [1, 2, 3, 4]
# input.data: [{"a": 1, "b": 2}, {"c": 3, "d": 4}]
# output.data: {"a": 1, "b": 2, "c": 3, "d": 4}
title: Concatenated Arrays
value: ${concat-arrays.output.data}
title: Concatenated Objects
value: ${concat-objects.output.data}
#Difference
# input.data: [[1, 2, 3], [2, 3, 4]]
# input.data: [{"a": 1, "b": 2}, {"b": 2, "c": 3}]
title: Difference of Arrays
value: ${difference-arrays.output.data}
title: Difference of Objects
value: ${difference-objects.output.data}
#Intersection
# input.data: [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
# input.data: [{"a": 1, "b": 2}, {"b": 2, "c": 3}]
title: Intersection of Arrays
value: ${intersection-arrays.output.data}
title: Intersection of Objects
value: ${intersection-objects.output.data}
#Split
# input.data: [1, 2, 3, 4, 5]
# output.data: [[1, 2], [3, 4], [5]]
# input.data: {"a": 1, "b": 2, "c": 3, "d": 4}
# output.data: [{"a": 1, "b": 2}, {"c": 3, "d": 4}]
value: ${split-array.output.data}
value: ${split-object.output.data}
#Symmetric Difference
# input.data: [[1, 2], [2, 3]]
symmetric-difference-arrays:
task: TASK_SYMMETRIC_DIFFERENCE
# input.data: [{"a": 1, "b": 2}, {"b": 2, "c": 3}]
# output.data: {"a": 1, "c": 3}
symmetric-difference-objects:
task: TASK_SYMMETRIC_DIFFERENCE
symmetric-difference-arrays:
title: Symmetric Difference of Arrays
value: ${symmetric-difference-arrays.output.data}
symmetric-difference-objects:
title: Symmetric Difference of Objects
value: ${symmetric-difference-objects.output.data}
#Union
# input.data: [[1, 2], [2, 3]]
# input.data: [{"a": 1, "b": 2}, {"b": 3, "c": 3}]
# output.data: {"a": 1, "b": 3, "c": 3}
value: ${union-arrays.output.data}
value: ${union-objects.output.data}