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

#Assign

Assign the data.

InputIDTypeDescription
Task ID (required)taskstringTASK_ASSIGN
Data (required)dataanySpecify the data you want to assign.
OutputIDTypeDescription
DatadataanyThe data you assign.

#Append

Add data to the end of an array.

InputIDTypeDescription
Task ID (required)taskstringTASK_APPEND
Array (required)arrayarraySpecify the array you want to append to.
Data (required)elementanySpecify the data you want to append.
OutputIDTypeDescription
ArrayarrayarrayA updated array with the specified data appended to the end of it.

#Union

Find the union of the sets

InputIDTypeDescription
Task ID (required)taskstringTASK_UNION
Array (required)setsarraySpecify the sets you want to union.
OutputIDTypeDescription
ArraysetarrayThe union set.

#Intersection

Find the intersection of the sets

InputIDTypeDescription
Task ID (required)taskstringTASK_INTERSECTION
Array (required)setsarraySpecify the sets you want to intersect.
OutputIDTypeDescription
ArraysetarrayThe intersection set.

#Difference

Find the difference between the two sets, i.e. set-a \ set-b, identifying the elements that are in set-a but not in set-b.

InputIDTypeDescription
Task ID (required)taskstringTASK_DIFFERENCE
Array (required)set-aarraySpecify the set-a.
Array (required)set-barraySpecify the set-b.
OutputIDTypeDescription
ArraysetarrayThe difference set.

#Concat

Concatenate the arrays. i.e. [1, 2] + [3, 4] = [1, 2, 3, 4]

InputIDTypeDescription
Task ID (required)taskstringTASK_CONCAT
Arrays (required)arraysarrayThe arrays to be concatenated.
OutputIDTypeDescription
ArrayarrayarrayThe concatenated arrays.

#Split

Split the array into an array of arrays with group size. i.e. [1, 2, 3, 4, 5, 6] with group size 2 = [[1, 2], [3, 4], [5, 6]]. If the array length is not divisible by the group size, the last group will have fewer elements.

InputIDTypeDescription
Task ID (required)taskstringTASK_SPLIT
Array (required)arrayarrayThe array to be split.
Group Size (required)group-sizeintegerThe size of each group.
OutputIDTypeDescription
ArraysarraysarrayThe array of arrays with group size.

#Example Recipes

#Combine 2 arrays using TASK_UNION and TASK_CONCAT


variable:
texts:
format: array:string
title: Text
texts-2:
format: array:string
title: Text
component:
# This component combines two arrays of strings in a union, ensuring that no duplicates are included.
# Examples:
# ["foo", "bar"], ["foo", "bat"] -> ["foo", "bar", "bat"]
union:
type: collection
input:
sets:
- ${variable.texts}
- ${variable.texts-2}
condition:
task: TASK_UNION
# This component concatenates two arrays of strings.
# Examples:
# ["foo", "bar"], ["zot", "bat"] -> ["foo", "bar", "zot", "bat"]
concat:
type: collection
input:
arrays:
- ${variable.texts}
- ${variable.texts-2}
condition:
task: TASK_CONCAT
output:
union-result:
title: Union Result
value: ${union.output.set}
concat-result:
title: Concat Result
value: ${concat.output.array}

#Use TASK_ASSIGN to create an object with type and text keys


variable:
text:
format: string
title: Text
component:
text-object:
type: collection
input:
data:
type: text
text: ${variable.text}
condition:
task: TASK_ASSIGN
output:
result:
title: Object
value: ${text-object.output.data}

#Use TASK_SPLIT to split an array of strings into groups of a specified size


# This pipeline splits an array of elements into groups of a specified size.
# Examples:
# ["foo", "bar", "bat", "zot"], 2 -> [["foo", "bar"], ["bat", "zot"]]
# ["foo", "bar", "bat", "zot"], 3 -> [["foo", "bar", "bat"], ["zot"]]
variable:
texts:
format: array:string
title: Text
group-size:
format: number
title: Group Size
component:
split:
type: collection
input:
array: ${variable.texts}
group-size: ${variable.group-size}
condition:
task: TASK_SPLIT
output:
split:
title: Split
value: ${split.output}