< Summary

Information
Class: Elsa.Expressions.JavaScript.Providers.ActivityOutputFunctionsDefinitionProvider
Assembly: Elsa.Expressions.JavaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Providers/ActivityOutputFunctionsDefinitionProvider.cs
Line coverage
7%
Covered lines: 1
Uncovered lines: 13
Coverable lines: 14
Total lines: 39
Line coverage: 7.1%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetFunctionDefinitionsAsync()0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Providers/ActivityOutputFunctionsDefinitionProvider.cs

#LineLine coverage
 1using Elsa.Extensions;
 2using Elsa.Expressions.JavaScript.Extensions;
 3using Elsa.Expressions.JavaScript.Options;
 4using Elsa.Expressions.JavaScript.TypeDefinitions.Abstractions;
 5using Elsa.Expressions.JavaScript.TypeDefinitions.Models;
 6using Elsa.Workflows;
 7using Humanizer;
 8using JetBrains.Annotations;
 9using Microsoft.Extensions.Options;
 10
 11namespace Elsa.Expressions.JavaScript.Providers;
 12
 13/// <summary>
 14/// Produces <see cref="FunctionDefinition"/>s for common functions.
 15/// </summary>
 16[UsedImplicitly]
 117internal class ActivityOutputFunctionsDefinitionProvider(IActivityRegistryLookupService activityRegistryLookup, IOptions
 18{
 19    protected override async ValueTask<IEnumerable<FunctionDefinition>> GetFunctionDefinitionsAsync(TypeDefinitionContex
 20    {
 021        if(options.Value.DisableWrappers)
 022            return [];
 23
 024        var nodes = context.WorkflowGraph.Nodes;
 025        var activitiesWithOutputs = nodes.GetActivitiesWithOutputs(activityRegistryLookup).Where(x => x.activity.Name !=
 026        var definitions = new List<FunctionDefinition>();
 27
 028        await foreach (var (activity, activityDescriptor) in activitiesWithOutputs)
 29        {
 030            definitions.AddRange(from output in activityDescriptor.Outputs.Where(x => x.Name.IsValidVariableName())
 031                select output.Name.Pascalize()
 032                into outputPascalName
 033                let activityNamePascalName = activity.Name.Pascalize()
 034                select CreateFunctionDefinition(builder => builder.Name($"get{outputPascalName}From{activityNamePascalNa
 35        }
 36
 037        return definitions;
 038    }
 39}