< Summary

Information
Class: Elsa.Workflows.Api.Endpoints.Scripting.ExpressionDescriptors.List.List
Assembly: Elsa.Workflows.Api
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/Scripting/ExpressionDescriptors/List/Endpoint.cs
Line coverage
25%
Covered lines: 4
Uncovered lines: 12
Coverable lines: 16
Total lines: 45
Line coverage: 25%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Configure()100%11100%
HandleAsync(...)100%210%
Map(...)100%210%
Map(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Api/Endpoints/Scripting/ExpressionDescriptors/List/Endpoint.cs

#LineLine coverage
 1using Elsa.Abstractions;
 2using Elsa.Expressions.Contracts;
 3using Elsa.Expressions.Models;
 4using Elsa.Models;
 5using JetBrains.Annotations;
 6
 7namespace Elsa.Workflows.Api.Endpoints.Scripting.ExpressionDescriptors.List;
 8
 9/// <summary>
 10/// Returns a TypeScript definition that is used by the Monaco editor to display intellisense for JavaScript expressions
 11/// </summary>
 12[UsedImplicitly]
 113internal class List(IExpressionDescriptorRegistry expressionDescriptorRegistry) : ElsaEndpointWithoutRequest<ListRespons
 14{
 15    /// <inheritdoc />
 16    public override void Configure()
 17    {
 118        Get("/descriptors/expression-descriptors");
 119        ConfigurePermissions("read:*", "read:expression-descriptors");
 120    }
 21
 22    /// <inheritdoc />
 23    public override Task HandleAsync(CancellationToken cancellationToken)
 24    {
 025        var descriptors = expressionDescriptorRegistry.ListAll().ToList();
 026        var models = Map(descriptors).ToList();
 027        var response = new ListResponse<ExpressionDescriptorModel>(models);
 028        return Send.OkAsync(response, cancellationToken);
 29    }
 30
 031    private static IEnumerable<ExpressionDescriptorModel> Map(List<ExpressionDescriptor> descriptors) => descriptors.Sel
 32
 33    private static ExpressionDescriptorModel Map(ExpressionDescriptor descriptor)
 34    {
 035        var properties = descriptor.Properties;
 036        return new ExpressionDescriptorModel(
 037            descriptor.Type,
 038            descriptor.DisplayName,
 039            descriptor.IsSerializable,
 040            descriptor.IsBrowsable,
 041            properties);
 42    }
 43}
 44
 45internal record ExpressionDescriptorModel(string Type, string DisplayName, bool IsSerializable, bool IsBrowsable, IDicti