-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expose consumers API and recursive export option #7309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sfmskywalker
merged 14 commits into
release/3.6.0
from
copilot/expose-api-endpoint-consumers
Feb 20, 2026
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9052993
Initial plan
Copilot a685981
Add consumers API endpoint and enhance export with IncludeConsumingWo…
Copilot bd99220
Address greptile-apps feedback: fix double-fetch, remove redundant Ha…
Copilot d48ac7a
Address greptile-apps round 2: 404 for unknown definitions, determini…
Copilot 9258d13
Implement workflow reference graph feature
sfmskywalker b4c1673
Refactor workflow consumers to utilize recursive graph-based approach…
sfmskywalker 447e364
Enhance workflow export by adding support for including consuming wor…
sfmskywalker 3f01d38
Add WorkflowReferenceGraphOptions for depth and definition limit conf…
sfmskywalker a9ee05c
Refactor `WorkflowReferenceGraphBuilder` to utilize target-typed new …
sfmskywalker 0d88c80
Add Workflow Reference Graph tests and scenarios
sfmskywalker 9139eaf
Include DefinitionId in exported workflow definition filenames for un…
sfmskywalker bd0d6c3
Remove unused models and constants from `WorkflowReferenceGraphTests`.
sfmskywalker 897de6d
Refactor `WorkflowReferenceGraphBuilderTests`: streamline test setup …
sfmskywalker 3f8b0af
Deterministic ZIP export and 404 test coverage for consumers endpoint…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...Client/Resources/WorkflowDefinitions/Responses/GetConsumingWorkflowDefinitionsResponse.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| namespace Elsa.Api.Client.Resources.WorkflowDefinitions.Responses; | ||
|
|
||
| /// <summary> | ||
| /// A response containing the IDs of workflow definitions that consume a specified workflow definition. | ||
| /// </summary> | ||
| /// <param name="ConsumingWorkflowDefinitionIds">The IDs of consuming workflow definitions.</param> | ||
| public record GetConsumingWorkflowDefinitionsResponse(ICollection<string> ConsumingWorkflowDefinitionIds); | ||
|
|
43 changes: 43 additions & 0 deletions
43
src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Consumers/Endpoint.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| using Elsa.Abstractions; | ||
| using Elsa.Common.Models; | ||
| using Elsa.Workflows.Management; | ||
| using Elsa.Workflows.Management.Filters; | ||
| using JetBrains.Annotations; | ||
|
|
||
| namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Consumers; | ||
|
|
||
| /// <summary> | ||
| /// Returns all workflow definitions that consume the specified workflow definition (recursively). | ||
| /// </summary> | ||
| [PublicAPI] | ||
| internal class Consumers(IWorkflowDefinitionStore store, IWorkflowReferenceGraphBuilder workflowReferenceGraphBuilder) : ElsaEndpoint<Request, Response> | ||
| { | ||
| /// <inheritdoc /> | ||
| public override void Configure() | ||
| { | ||
| Get("/workflow-definitions/{definitionId}/consumers"); | ||
| ConfigurePermissions("read:workflow-definitions"); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public override async Task HandleAsync(Request request, CancellationToken cancellationToken) | ||
| { | ||
| var filter = new WorkflowDefinitionFilter | ||
| { | ||
| DefinitionId = request.DefinitionId, | ||
| VersionOptions = VersionOptions.Latest | ||
| }; | ||
|
|
||
| var definition = await store.FindAsync(filter, cancellationToken); | ||
|
|
||
| if (definition == null) | ||
| { | ||
| await Send.NotFoundAsync(cancellationToken); | ||
| return; | ||
| } | ||
|
|
||
| var graph = await workflowReferenceGraphBuilder.BuildGraphAsync(request.DefinitionId, cancellationToken); | ||
| var consumerIds = graph.ConsumerDefinitionIds.ToList(); | ||
| await Send.OkAsync(new Response(consumerIds), cancellationToken); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Consumers/Models.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Consumers; | ||
|
|
||
| internal record Request | ||
| { | ||
| /// <summary> | ||
| /// The workflow definition ID. | ||
| /// </summary> | ||
| public string DefinitionId { get; set; } = null!; | ||
| } | ||
|
|
||
| internal record Response(ICollection<string> ConsumingWorkflowDefinitionIds); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/modules/Elsa.Workflows.Management/Contracts/IWorkflowReferenceGraphBuilder.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| using Elsa.Workflows.Management.Models; | ||
|
|
||
| namespace Elsa.Workflows.Management; | ||
|
|
||
| /// <summary> | ||
| /// Builds a complete graph of workflow references by recursively discovering all workflows | ||
| /// that consume (directly or indirectly) a given workflow definition. | ||
| /// </summary> | ||
| public interface IWorkflowReferenceGraphBuilder | ||
| { | ||
| /// <summary> | ||
| /// Builds a complete reference graph starting from the specified workflow definition. | ||
| /// </summary> | ||
| /// <param name="definitionId">The ID of the workflow definition to start from.</param> | ||
| /// <param name="cancellationToken">The cancellation token.</param> | ||
| /// <returns>A <see cref="WorkflowReferenceGraph"/> containing all reference relationships.</returns> | ||
| Task<WorkflowReferenceGraph> BuildGraphAsync(string definitionId, CancellationToken cancellationToken = default); | ||
|
|
||
| /// <summary> | ||
| /// Builds a complete reference graph starting from multiple workflow definitions. | ||
| /// </summary> | ||
| /// <param name="definitionIds">The IDs of the workflow definitions to start from.</param> | ||
| /// <param name="cancellationToken">The cancellation token.</param> | ||
| /// <returns>A merged <see cref="WorkflowReferenceGraph"/> containing all reference relationships from all starting points.</returns> | ||
| Task<WorkflowReferenceGraph> BuildGraphAsync(IEnumerable<string> definitionIds, CancellationToken cancellationToken = default); | ||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.