elsa-workflows / elsa-workflows/elsa-core
[FEAT] Map Activity to Transform Collections with Custom Logic
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
**Summary:**
Introduce a new `Map` activity that allows users to apply a transformation to each item in a collection. The transformation logic should be defined within a `Body` property, which can host any activity like `Sequence` or `Flowchart`.
**Details:**
- **Input:** A collection of items.
- **Body Property:** Should be of type `IActivity`. This property represents the transformation logic to be applied to each item in the input collection.
- **Iteration Mechanism:** The `Map` activity needs to iterate over the input collection, executing the `Body` activity for each item.
- **Output of Body:** Each execution of the `Body` activity produces an output which should be collected into a new list.
- **Final Output:** The `Map` activity outputs the new list, which consists of the transformed items.
**Expected Behavior:**
- The `Map` activity should be versatile, capable of handling different types of collections (e.g., lists, arrays).
- The implementation should ensure efficient execution, especially for large collections.
**Use Case:**
This feature would be beneficial for scenarios where a set of items needs to be individually processed and transformed, potentially using complex logic encapsulated within other activities like `Sequence` or `Flowchart`.
Think of it like the `Select` for LINQ and `Array.map` in JavaScript.
Contributor guide
Research direction
No source files or tests are named. Start by locating the existing Select activity and the IActivity implementations used by Sequence or Flowchart, then determine how an input item and each Body result are represented. Done means a Map activity accepts supported collections, runs Body once per item, and returns the collected transformed values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100