Collection

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.

InputIDTypeDescription
Task ID (required)taskstringTASK_APPEND
Data (required)dataanyThe 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)valueanyThe 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.
OutputIDTypeDescription
DatadataanyThe 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.

InputIDTypeDescription
Task ID (required)taskstringTASK_ASSIGN
Data (required)dataanyThe input data structure to modify. Can be an array, object, or primitive value.
Path (required)pathstringThe 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)valueanyThe value to assign at the specified path. Can be any type (string, number, boolean, array, or object).
OutputIDTypeDescription
DatadataanyThe resulting data structure after the assign operation.

#Concat

Concatenate multiple arrays or merge multiple objects into a single collection.

InputIDTypeDescription
Task ID (required)taskstringTASK_CONCAT
Data (required)dataarray[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.
OutputIDTypeDescription
DatadataanyThe 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.

InputIDTypeDescription
Task ID (required)taskstringTASK_DIFFERENCE
Data (required)dataarray[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}.
OutputIDTypeDescription
DatadataanyThe resulting array or object after the difference operation.

#Intersection

Find common elements that exist in all input arrays or objects.

InputIDTypeDescription
Task ID (required)taskstringTASK_INTERSECTION
Data (required)dataarray[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}.
OutputIDTypeDescription
DatadataanyThe resulting array or object after the intersection operation.

#Split

Split arrays or objects into smaller chunks.

InputIDTypeDescription
Task ID (required)taskstringTASK_SPLIT
Data (required)dataanyThe 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)sizeintegerNumber of elements per group
OutputIDTypeDescription
Datadataarray[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.

InputIDTypeDescription
Task ID (required)taskstringTASK_SYMMETRIC_DIFFERENCE
Data (required)dataarray[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}.
OutputIDTypeDescription
DatadataanyThe resulting array or object after the symmetric difference operation.

#Union

Find unique elements that exist in any of the input arrays or objects.

InputIDTypeDescription
Task ID (required)taskstringTASK_UNION
Data (required)dataarray[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}.
OutputIDTypeDescription
DatadataanyThe resulting array or object after the union operation.

#Example Recipes

#Append


component:
# input.data: "a"
# input.value: "b"
# output.data: ["a", "b"]
append-primitives:
type: collection
task: TASK_APPEND
input:
data: a
value: b
# input.data: ["a", "b"]
# input.value: 0
# output.data: ["a", "b", 0]
append-a-primitive-to-an-array:
type: collection
task: TASK_APPEND
input:
data:
- a
- b
value: 0
# input.data: ["a", "b"]
# input.value: {"foo": "c"}
# output.data: ["a", "b", {"foo": "c"}]
append-an-object-to-an-array:
type: collection
task: TASK_APPEND
input:
data:
- a
- b
value:
foo: c
# input.data: {"foo": "a", "bar": "b"}
# input.value: "c"
# output.data: [{"foo": "a", "bar": "b"}, "c"]
append-a-primitive-to-an-object:
type: collection
task: TASK_APPEND
input:
data:
foo: a
bar: b
value: c
# input.data: {"foo": "a", "bar": "b"}
# input.value: {"baz": "c"}
# output.data: {"foo": "a", "bar": "b", "baz": "c"}
append-an-object-to-an-object:
type: collection
task: TASK_APPEND
input:
data:
foo: a
bar: b
value:
baz: c
output:
append-primitives:
title: Append primitives
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


component:
# input.data: [1, 2, 3]
# input.path: ".[1]"
# input.value: 10
# output.data: [1, 10, 3]
assign-array-element:
type: collection
task: TASK_ASSIGN
input:
data: [1, 2, 3]
path: ".[1]"
value: 10
# input.data: {"name": "John", "age": 30}
# input.path: "name"
# input.value: "Jane"
# output.data: {"name": "Jane", "age": 30}
assign-object-key:
type: collection
task: TASK_ASSIGN
input:
data:
name: John
age: 30
path: name
value: Jane
# input.data: {"users": [{"metadata": {"tags": ["tag1", "tag2"]}}]}
# input.path: "users.[0].metadata.tags.[1]"
# input.value: "new-tag"
# output.data: {"users": [{"metadata": {"tags": ["tag1", "new-tag"]}}]}
assign-nested-path:
type: collection
task: TASK_ASSIGN
input:
data:
users:
- metadata:
tags: ["tag1", "tag2"]
path: "users.[0].metadata.tags.[1]"
value: "new-tag"
# input.data: null
# input.path: ""
# input.value: "hello"
# output.data: "hello"
create-primitive:
type: collection
task: TASK_ASSIGN
input:
data: null
path: ""
value: hello
# input.data: null
# input.path: "users.[0].name"
# input.value: "John"
# output.data: {"users": [{"name": "John"}]}
create-nested-structure:
type: collection
task: TASK_ASSIGN
input:
data: null
path: "users.[0].name"
value: "John"
output:
assign-array-element:
title: Assign an array element
value: ${assign-array-element.output.data}
assign-object-key:
title: Assign an object key
value: ${assign-object-key.output.data}
assign-nested-path:
title: Assign using nested path
value: ${assign-nested-path.output.data}
create-primitive:
title: Create and assign a primitive value
value: ${create-primitive.output.data}
create-nested-structure:
title: Create and assign nested structure
value: ${create-nested-structure.output.data}

#Concat


component:
# input.data: [[1, 2], [3, 4]]
# output.data: [1, 2, 3, 4]
concat-arrays:
type: collection
task: TASK_CONCAT
input:
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}
concat-objects:
type: collection
task: TASK_CONCAT
input:
data:
- {"a": 1, "b": 2}
- {"c": 3, "d": 4}
output:
concat-arrays:
title: Concatenated Arrays
value: ${concat-arrays.output.data}
concat-objects:
title: Concatenated Objects
value: ${concat-objects.output.data}

#Difference


component:
# input.data: [[1, 2, 3], [2, 3, 4]]
# output.data: [1]
difference-arrays:
type: collection
task: TASK_DIFFERENCE
input:
data:
- [1, 2, 3]
- [2, 3, 4]
# input.data: [{"a": 1, "b": 2}, {"b": 2, "c": 3}]
# output.data: {"a": 1}
difference-objects:
type: collection
task: TASK_DIFFERENCE
input:
data:
- {"a": 1, "b": 2}
- {"b": 2, "c": 3}
output:
difference-arrays:
title: Difference of Arrays
value: ${difference-arrays.output.data}
difference-objects:
title: Difference of Objects
value: ${difference-objects.output.data}

#Intersection


component:
# input.data: [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
# output.data: [3]
intersection-arrays:
type: collection
task: TASK_INTERSECTION
input:
data:
- [1, 2, 3]
- [2, 3, 4]
- [3, 4, 5]
# input.data: [{"a": 1, "b": 2}, {"b": 2, "c": 3}]
# output.data: {"b": 2}
intersection-objects:
type: collection
task: TASK_INTERSECTION
input:
data:
- {"a": 1, "b": 2}
- {"b": 2, "c": 3}
output:
intersection-arrays:
title: Intersection of Arrays
value: ${intersection-arrays.output.data}
intersection-objects:
title: Intersection of Objects
value: ${intersection-objects.output.data}

#Split


component:
# input.data: [1, 2, 3, 4, 5]
# input.size: 2
# output.data: [[1, 2], [3, 4], [5]]
split-array:
type: collection
task: TASK_SPLIT
input:
data: [1, 2, 3, 4, 5]
size: 2
# input.data: {"a": 1, "b": 2, "c": 3, "d": 4}
# input.size: 2
# output.data: [{"a": 1, "b": 2}, {"c": 3, "d": 4}]
split-object:
type: collection
task: TASK_SPLIT
input:
data:
a: 1
b: 2
c: 3
d: 4
size: 2
output:
split-array:
title: Split Array
value: ${split-array.output.data}
split-object:
title: Split Object
value: ${split-object.output.data}

#Symmetric Difference


component:
# input.data: [[1, 2], [2, 3]]
# output.data: [1, 3]
symmetric-difference-arrays:
type: collection
task: TASK_SYMMETRIC_DIFFERENCE
input:
data:
- [1, 2]
- [2, 3]
# input.data: [{"a": 1, "b": 2}, {"b": 2, "c": 3}]
# output.data: {"a": 1, "c": 3}
symmetric-difference-objects:
type: collection
task: TASK_SYMMETRIC_DIFFERENCE
input:
data:
- {"a": 1, "b": 2}
- {"b": 2, "c": 3}
output:
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


component:
# input.data: [[1, 2], [2, 3]]
# output.data: [1, 2, 3]
union-arrays:
type: collection
task: TASK_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}
union-objects:
type: collection
task: TASK_UNION
input:
data:
- {"a": 1, "b": 2}
- {"b": 3, "c": 3}
output:
union-arrays:
title: Union of Arrays
value: ${union-arrays.output.data}
union-objects:
title: Union of Objects
value: ${union-objects.output.data}