Skip to content

Add enrichInput and enrichOutput DSL functions#1197

Draft
mcruzdev wants to merge 1 commit intoserverlessworkflow:mainfrom
mcruzdev:issue-1196
Draft

Add enrichInput and enrichOutput DSL functions#1197
mcruzdev wants to merge 1 commit intoserverlessworkflow:mainfrom
mcruzdev:issue-1196

Conversation

@mcruzdev
Copy link
Collaborator

@mcruzdev mcruzdev commented Mar 3, 2026

This pull request add enrich for inputFrom and enrichedOutput for outputAs methods.

  1. outputAs(enrichedOutput
function("task", (Long input) -> input + 5, Long.class)
    .outputAs(enrichOutput((taskOutput, rootInput) -> 
        taskOutput + rootInput.as(Long.class).orElse(0L), Long.class))
  1. outputAs(enrichedOutput handling only the root WorkflowModel
.outputAs(
    enrichOutput(rootInput -> {
                                  return rootInput.asNumber().orElseThrow().longValue();
                            })))
  1. inputFrom(enriched
                        enrichInput(
                            (lastState, rootInputModel) -> {
                              Long originalInput = rootInputModel.as(Long.class).orElse(0L);
                              return lastState + originalInput;
                            },
                            Long.class)
  1. inputFrom(enriched handling only the root WorkflowModel
.inputFrom(
                        enrichInput(rootInput -> rootInput.asNumber().orElseThrow().longValue())))

Closes #1196

Copilot AI review requested due to automatic review settings March 3, 2026 03:17
@mcruzdev mcruzdev requested a review from fjtirado as a code owner March 3, 2026 03:17
@mcruzdev mcruzdev requested a review from ricardozanini March 3, 2026 03:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds DSL helpers to simplify enriching inputFrom(...) and outputAs(...) transformations with access to the root workflow input (WorkflowModel), addressing #1196 by reducing boilerplate when reading workflowContext.instanceData().input().

Changes:

  • Added FuncDSL.enriched(...) and FuncDSL.enrichedOutput(...) helper functions (including root-input-only variants).
  • Introduced EnrichWithModelBiFunction functional interface to support (typedValue, WorkflowModel) enrichment lambdas.
  • Added new integration-style tests and updated impl/test Maven dependencies to compile/run them.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/FuncDSL.java Adds new enrichment helpers and their Javadocs.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/EnrichWithModelBiFunction.java New functional interface for enrichment with WorkflowModel.
impl/test/src/test/java/io/serverlessworkflow/impl/test/FuncDSLEnrichWithTest.java New tests covering enriched input/output scenarios.
impl/test/pom.xml Adds test-scope dependencies required by the new tests.
experimental/fluent/func/src/main/java/io/serverlessworkflow/fluent/func/dsl/Step.java Minor formatting-only changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 3, 2026 12:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@ricardozanini ricardozanini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but please consider renaming to enrich instead and fwiw: https://www.enterpriseintegrationpatterns.com/patterns/messaging/DataEnricher.html

Copilot AI review requested due to automatic review settings March 3, 2026 18:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 3, 2026 20:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 3, 2026 21:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com>
Copilot AI review requested due to automatic review settings March 3, 2026 21:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mcruzdev mcruzdev changed the title Add enriched and enrichedOutput DSL functions Add enrichInput and enrichOutput DSL functions Mar 4, 2026
@fjtirado
Copy link
Collaborator

fjtirado commented Mar 4, 2026

See my comment on the issue, I think the PR needs to be refactor accordingly

@fjtirado fjtirado marked this pull request as draft March 4, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add outputAs|inputFrom(WorkflowModel workflowInput) method to DSL

4 participants