| | | 1 | | using CShells.FastEndpoints.Features; |
| | | 2 | | using CShells.Features; |
| | | 3 | | using Elsa.Extensions; |
| | | 4 | | using Elsa.Workflows.Api.Constants; |
| | | 5 | | using Elsa.Workflows.Api.Contracts; |
| | | 6 | | using Elsa.Workflows.Api.Requirements; |
| | | 7 | | using Elsa.Workflows.Api.Serialization; |
| | | 8 | | using Elsa.Workflows.Api.Services; |
| | | 9 | | using JetBrains.Annotations; |
| | | 10 | | using Microsoft.AspNetCore.Authorization; |
| | | 11 | | using Microsoft.Extensions.DependencyInjection; |
| | | 12 | | |
| | | 13 | | namespace Elsa.Workflows.Api.ShellFeatures; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Adds workflows API features with FastEndpoints support. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <remarks> |
| | | 19 | | /// This feature implements <see cref="IFastEndpointsShellFeature"/> to indicate that this assembly |
| | | 20 | | /// contains FastEndpoints that should be automatically discovered and registered. |
| | | 21 | | /// </remarks> |
| | | 22 | | [ShellFeature( |
| | | 23 | | DisplayName = "Workflows API", |
| | | 24 | | Description = "Provides REST API endpoints for workflow management", |
| | | 25 | | DependsOn = |
| | | 26 | | [ |
| | | 27 | | "ElsaFastEndpoints", |
| | | 28 | | "WorkflowInstances", |
| | | 29 | | "WorkflowManagement", |
| | | 30 | | "WorkflowRuntime", |
| | | 31 | | "SasTokens" |
| | | 32 | | ])] |
| | | 33 | | [UsedImplicitly] |
| | | 34 | | public class WorkflowsApiFeature : IFastEndpointsShellFeature |
| | | 35 | | { |
| | | 36 | | public void ConfigureServices(IServiceCollection services) |
| | | 37 | | { |
| | 0 | 38 | | services.AddSerializationOptionsConfigurator<SerializationConfigurator>(); |
| | 0 | 39 | | services.AddScoped<IWorkflowDefinitionLinker, StaticWorkflowDefinitionLinker>(); |
| | 0 | 40 | | services.AddScoped<IAuthorizationHandler, NotReadOnlyRequirementHandler>(); |
| | 0 | 41 | | services.Configure<AuthorizationOptions>(options => |
| | 0 | 42 | | { |
| | 0 | 43 | | options.AddPolicy(AuthorizationPolicies.NotReadOnlyPolicy, policy => policy.AddRequirements(new NotReadOnlyR |
| | 0 | 44 | | }); |
| | 0 | 45 | | services.AddScoped<IWorkflowInstanceExportNameProvider, DefaultWorkflowInstanceExportNameProvider>(); |
| | 0 | 46 | | services.AddSingleton<IShellReloadOrchestrator, ShellReloadOrchestrator>(); |
| | 0 | 47 | | } |
| | | 48 | | } |