| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Extensions; |
| | | 3 | | using Elsa.Workflows.Management; |
| | | 4 | | using Elsa.Workflows.Serialization.Converters; |
| | | 5 | | using Elsa.Workflows.Serialization.Helpers; |
| | | 6 | | using JetBrains.Annotations; |
| | | 7 | | using Microsoft.AspNetCore.Http; |
| | | 8 | | |
| | | 9 | | namespace Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Graph; |
| | | 10 | | |
| | | 11 | | [PublicAPI] |
| | 2 | 12 | | internal class Graph(IWorkflowDefinitionService workflowDefinitionService, IApiSerializer apiSerializer, ActivityWriter |
| | | 13 | | { |
| | | 14 | | public override void Configure() |
| | | 15 | | { |
| | 1 | 16 | | Get("/workflow-definitions/subgraph/{id}"); |
| | 1 | 17 | | ConfigurePermissions("read:workflow-definitions"); |
| | 1 | 18 | | } |
| | | 19 | | |
| | | 20 | | public override async Task HandleAsync(Request request, CancellationToken cancellationToken) |
| | | 21 | | { |
| | 1 | 22 | | var workflowGraph = await workflowDefinitionService.FindWorkflowGraphAsync(request.Id, cancellationToken); |
| | | 23 | | |
| | 1 | 24 | | if (workflowGraph == null) |
| | | 25 | | { |
| | 0 | 26 | | await Send.NotFoundAsync(cancellationToken); |
| | 0 | 27 | | return; |
| | | 28 | | } |
| | | 29 | | |
| | 1 | 30 | | var parentNode = workflowGraph.NodeIdLookup.TryGetValue(request.ParentNodeId, out var node) ? node : workflowGra |
| | 1 | 31 | | var serializerOptions = apiSerializer.GetOptions().Clone(); |
| | 1 | 32 | | serializerOptions.Converters.Add(new RootActivityNodeConverter(activityWriter)); |
| | 1 | 33 | | await HttpContext.Response.WriteAsJsonAsync(parentNode, serializerOptions, cancellationToken); |
| | 1 | 34 | | } |
| | | 35 | | } |