2023-03-03 21:47:23 +00:00
|
|
|
using Elsa.Expressions.Contracts;
|
2022-05-27 10:36:39 +00:00
|
|
|
using Elsa.Expressions.Features;
|
2022-12-31 15:16:43 +00:00
|
|
|
using Elsa.Extensions;
|
2022-05-27 10:36:39 +00:00
|
|
|
using Elsa.Features.Abstractions;
|
|
|
|
|
using Elsa.Features.Attributes;
|
|
|
|
|
using Elsa.Features.Services;
|
2022-11-28 18:12:01 +00:00
|
|
|
using Elsa.JavaScript.Activities;
|
2023-02-13 11:15:20 +00:00
|
|
|
using Elsa.JavaScript.Contracts;
|
2022-05-26 15:05:36 +00:00
|
|
|
using Elsa.JavaScript.Expressions;
|
|
|
|
|
using Elsa.JavaScript.Providers;
|
|
|
|
|
using Elsa.JavaScript.Services;
|
2023-02-13 11:15:20 +00:00
|
|
|
using Elsa.JavaScript.TypeDefinitions.Contracts;
|
|
|
|
|
using Elsa.JavaScript.TypeDefinitions.Providers;
|
|
|
|
|
using Elsa.JavaScript.TypeDefinitions.Services;
|
2022-05-27 10:36:39 +00:00
|
|
|
using Elsa.Mediator.Features;
|
2023-03-20 18:55:11 +00:00
|
|
|
using Elsa.Workflows.Core.Contracts;
|
2022-05-26 15:05:36 +00:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
2022-05-27 10:36:39 +00:00
|
|
|
namespace Elsa.JavaScript.Features;
|
2022-05-26 15:05:36 +00:00
|
|
|
|
2022-12-30 12:11:29 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Installs JavaScript integration.
|
|
|
|
|
/// </summary>
|
2022-05-27 10:36:39 +00:00
|
|
|
[DependsOn(typeof(MediatorFeature))]
|
|
|
|
|
[DependsOn(typeof(ExpressionsFeature))]
|
|
|
|
|
public class JavaScriptFeature : FeatureBase
|
2022-05-26 15:05:36 +00:00
|
|
|
{
|
2022-12-30 12:11:29 +00:00
|
|
|
/// <inheritdoc />
|
2022-05-27 10:36:39 +00:00
|
|
|
public JavaScriptFeature(IModule module) : base(module)
|
2022-05-26 15:05:36 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-30 20:52:41 +00:00
|
|
|
/// <inheritdoc />
|
2022-05-26 15:05:36 +00:00
|
|
|
public override void Configure()
|
|
|
|
|
{
|
2023-03-02 20:21:50 +00:00
|
|
|
Module.UseWorkflowManagement(management => management.AddActivitiesFrom<JavaScriptFeature>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public override void Apply()
|
|
|
|
|
{
|
|
|
|
|
// JavaScript services.
|
2022-05-26 15:05:36 +00:00
|
|
|
Services
|
|
|
|
|
.AddSingleton<IExpressionSyntaxProvider, JavaScriptExpressionSyntaxProvider>()
|
|
|
|
|
.AddSingleton<IJavaScriptEvaluator, JintJavaScriptEvaluator>()
|
2022-11-28 18:12:01 +00:00
|
|
|
.AddSingleton<IActivityPropertyOptionsProvider, RunJavaScriptOptionsProvider>()
|
2023-01-19 13:09:58 +00:00
|
|
|
.AddSingleton<ITypeDefinitionService, TypeDefinitionService>()
|
2022-12-30 12:11:29 +00:00
|
|
|
.AddExpressionHandler<JavaScriptExpressionHandler, JavaScriptExpression>()
|
|
|
|
|
;
|
|
|
|
|
|
2023-03-02 20:21:50 +00:00
|
|
|
// Type definition services.
|
2023-01-19 13:09:58 +00:00
|
|
|
Services
|
|
|
|
|
.AddSingleton<ITypeDefinitionService, TypeDefinitionService>()
|
|
|
|
|
.AddSingleton<ITypeDescriber, TypeDescriber>()
|
|
|
|
|
.AddSingleton<ITypeDefinitionDocumentRenderer, TypeDefinitionDocumentRenderer>()
|
|
|
|
|
.AddSingleton<ITypeAliasRegistry, TypeAliasRegistry>()
|
2023-01-31 10:01:39 +00:00
|
|
|
.AddSingleton<IFunctionDefinitionProvider, CommonFunctionsDefinitionProvider>()
|
|
|
|
|
.AddSingleton<ITypeDefinitionProvider, CommonTypeDefinitionProvider>()
|
|
|
|
|
.AddSingleton<ITypeDefinitionProvider, VariableTypeDefinitionProvider>()
|
|
|
|
|
;
|
2023-03-02 20:21:50 +00:00
|
|
|
|
|
|
|
|
// Handlers.
|
|
|
|
|
Services.AddNotificationHandlersFrom<JavaScriptFeature>();
|
2022-05-26 15:05:36 +00:00
|
|
|
}
|
|
|
|
|
}
|