From a718273c00379ce86d719619924fa7ab6adcd2db Mon Sep 17 00:00:00 2001 From: axeleron007 Date: Tue, 1 Jun 2021 14:26:43 +0300 Subject: [PATCH] The Webhook Endpoints API configuration The Webhook Endpoints API configuration --- .../Elsa.Activities.Webhooks.csproj | 2 +- ....cs => WebhookOptionsBuilderExtensions.cs} | 16 +-- .../Migrations/WebhookContextModelSnapshot.cs | 4 +- .../Elsa.Webhooks.Persistence.MongoDb.csproj | 2 +- .../Elsa.Webhooks.Persistence.YesSql.csproj | 9 +- .../Extensions/ServiceCollectionExtensions.cs | 110 +++++++++--------- .../elsa-workflows-studio/package-lock.json | 5 - .../Elsa.Samples.Server.Host.csproj | 1 + .../Elsa.Samples.Server.Host/Startup.cs | 2 + 9 files changed, 75 insertions(+), 76 deletions(-) rename src/activities/webhooks/Elsa.Activities.Webhooks/Extensions/{ElsaOptionsExtensions.cs => WebhookOptionsBuilderExtensions.cs} (59%) diff --git a/src/activities/webhooks/Elsa.Activities.Webhooks/Elsa.Activities.Webhooks.csproj b/src/activities/webhooks/Elsa.Activities.Webhooks/Elsa.Activities.Webhooks.csproj index de6164a3f..9e1f3a559 100644 --- a/src/activities/webhooks/Elsa.Activities.Webhooks/Elsa.Activities.Webhooks.csproj +++ b/src/activities/webhooks/Elsa.Activities.Webhooks/Elsa.Activities.Webhooks.csproj @@ -4,7 +4,7 @@ - netstandard2.1 + net5.0 Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. This package provides Webhook activities. diff --git a/src/activities/webhooks/Elsa.Activities.Webhooks/Extensions/ElsaOptionsExtensions.cs b/src/activities/webhooks/Elsa.Activities.Webhooks/Extensions/WebhookOptionsBuilderExtensions.cs similarity index 59% rename from src/activities/webhooks/Elsa.Activities.Webhooks/Extensions/ElsaOptionsExtensions.cs rename to src/activities/webhooks/Elsa.Activities.Webhooks/Extensions/WebhookOptionsBuilderExtensions.cs index 2cb95852b..7f02db14f 100644 --- a/src/activities/webhooks/Elsa.Activities.Webhooks/Extensions/ElsaOptionsExtensions.cs +++ b/src/activities/webhooks/Elsa.Activities.Webhooks/Extensions/WebhookOptionsBuilderExtensions.cs @@ -1,30 +1,30 @@ using System; -using Elsa; +using Elsa.Activities.Webhooks; using Elsa.Activities.Webhooks.ActivityTypes; using Elsa.Activities.Webhooks.Options; using Elsa.Activities.Webhooks.Persistence.Decorators; using Elsa.Services; using Elsa.Webhooks.Abstractions.Persistence; +using Microsoft.Extensions.DependencyInjection; -// ReSharper disable once CheckNamespace -namespace Microsoft.Extensions.DependencyInjection +namespace Elsa.Activities.Webhooks.Extensions { - public static class ElsaOptionsExtensions + public static class WebhookOptionsBuilderExtensions { public static ElsaOptionsBuilder AddWebhooks( this ElsaOptionsBuilder elsaOptions, - Action? configure = default) + Action? configure = default) { var services = elsaOptions.Services; // Configure Webhooks. - var options = new WebhookOptions(); - configure?.Invoke(options); + var webhookOptionsBuilder = new WebhookOptionsBuilder(services); + configure?.Invoke(webhookOptionsBuilder); // Services. services .AddScoped() - .AddScoped(options.WebhookDefinitionStoreFactory); + .AddScoped(webhookOptionsBuilder.WebhookOptions.WebhookDefinitionStoreFactory); services.Decorate(); diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/WebhookContextModelSnapshot.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/WebhookContextModelSnapshot.cs index f0693c94b..765884df5 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/WebhookContextModelSnapshot.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.EntityFramework.SqlServer/Migrations/WebhookContextModelSnapshot.cs @@ -1,4 +1,4 @@ -// +// using Elsa.Webhooks.Persistence.EntityFramework.Core; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -15,7 +15,7 @@ namespace Elsa.Webhooks.Persistence.EntityFramework.SqlServer.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("ProductVersion", "5.0.6") + .HasAnnotation("ProductVersion", "5.0.6") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity("Elsa.Webhooks.Abstractions.Models.WebhookDefinition", b => diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.MongoDb/Elsa.Webhooks.Persistence.MongoDb.csproj b/src/activities/webhooks/Elsa.Webhooks.Persistence.MongoDb/Elsa.Webhooks.Persistence.MongoDb.csproj index 408a1b2d6..203c9b803 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.MongoDb/Elsa.Webhooks.Persistence.MongoDb.csproj +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.MongoDb/Elsa.Webhooks.Persistence.MongoDb.csproj @@ -4,7 +4,7 @@ - netstandard2.1 + net5.0 Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. This package provides the MongoDB provider for Webhook persistence. diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Elsa.Webhooks.Persistence.YesSql.csproj b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Elsa.Webhooks.Persistence.YesSql.csproj index 0d88ccccf..276cdc71e 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Elsa.Webhooks.Persistence.YesSql.csproj +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Elsa.Webhooks.Persistence.YesSql.csproj @@ -1,10 +1,10 @@ - + - - + + - netstandard2.1 + net5.0 Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. This package provides the YesSQL provider for Webhook persistence. @@ -20,6 +20,7 @@ + diff --git a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Extensions/ServiceCollectionExtensions.cs b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Extensions/ServiceCollectionExtensions.cs index 4fa0c32af..c5e40e5ba 100644 --- a/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Extensions/ServiceCollectionExtensions.cs +++ b/src/activities/webhooks/Elsa.Webhooks.Persistence.YesSql/Extensions/ServiceCollectionExtensions.cs @@ -1,63 +1,63 @@ -//using System; -//using Elsa.Persistence.YesSql; -//using Elsa.Webhooks.Persistence.YesSql.Stores; -//using Microsoft.Extensions.DependencyInjection; -//using YesSql; -//using YesSql.Indexes; -//using Elsa.Runtime; -//using Elsa.Webhooks.Persistence.YesSql.Mapping; -//using Elsa.Persistence.YesSql.Services; -//using Elsa.Persistence.YesSql.Data; -//using Elsa.Webhooks.Persistence.YesSql.Indexes; -//using Elsa.Activities.Webhooks; +using System; +using Elsa.Activities.Webhooks; +using Elsa.Persistence.YesSql; +using Elsa.Webhooks.Persistence.YesSql.Stores; +using Microsoft.Extensions.DependencyInjection; +using YesSql; +using YesSql.Indexes; +using Elsa.Runtime; +using Elsa.Webhooks.Persistence.YesSql.Mapping; +using Elsa.Persistence.YesSql.Services; +using Elsa.Persistence.YesSql.Data; +using Elsa.Webhooks.Persistence.YesSql.Indexes; -//namespace Elsa.Webhooks.Persistence.YesSql.Extensions -//{ -// public static class ServiceCollectionExtensions -// { -// public static ElsaOptionsBuilder UseYesSqlPersistence(this WebhookOptionsBuilder elsa, Action configure) -// { -// elsa.Services -// .AddScoped() -// .AddSingleton(sp => CreateStore(sp, configure)) -// .AddSingleton() -// .AddScoped(CreateSession) -// .AddScoped() -// .AddStartupTask() -// .AddStartupTask() -// .AddDataMigration() -// .AddAutoMapperProfile() -// .AddIndexProvider(); +namespace Elsa.Webhooks.Persistence.YesSql.Extensions +{ + public static class ServiceCollectionExtensions + { + public static WebhookOptionsBuilder UseYesSqlPersistence(this WebhookOptionsBuilder elsa, Action configure) + { + elsa.Services + .AddScoped() + .AddSingleton(sp => CreateStore(sp, configure)) + .AddSingleton() + .AddScoped(CreateSession) + .AddScoped() + .AddStartupTask() + .AddStartupTask() + .AddDataMigration() + .AddAutoMapperProfile() + .AddIndexProvider(); -// return elsa -// .UseWebhookDefinitionStore(sp => sp.GetRequiredService()); -// } + return elsa + .UseWebhookDefinitionStore(sp => sp.GetRequiredService()); + } -// private static IStore CreateStore( -// IServiceProvider serviceProvider, -// Action configure) -// { -// var configuration = new Configuration -// { -// ContentSerializer = new CustomJsonContentSerializer() -// }; + private static IStore CreateStore( + IServiceProvider serviceProvider, + Action configure) + { + var configuration = new Configuration + { + ContentSerializer = new CustomJsonContentSerializer() + }; -// configure(serviceProvider, configuration); + configure(serviceProvider, configuration); -// // TODO: The following line is a temporary workaround until the bug in YesSql is fixed: https://github.com/sebastienros/yessql/pull/280 -// var store = StoreFactory.CreateAndInitializeAsync(configuration).GetAwaiter().GetResult(); -// //var store = StoreFactory.Create(configuration); + // TODO: The following line is a temporary workaround until the bug in YesSql is fixed: https://github.com/sebastienros/yessql/pull/280 + var store = StoreFactory.CreateAndInitializeAsync(configuration).GetAwaiter().GetResult(); + //var store = StoreFactory.Create(configuration); -// var indexes = serviceProvider.GetServices(); -// store.RegisterIndexes(indexes); + var indexes = serviceProvider.GetServices(); + store.RegisterIndexes(indexes); -// return store; -// } + return store; + } -// private static ISession CreateSession(IServiceProvider serviceProvider) -// { -// var provider = serviceProvider.GetRequiredService(); -// return provider.CreateSession(); -// } -// } -//} + private static ISession CreateSession(IServiceProvider serviceProvider) + { + var provider = serviceProvider.GetRequiredService(); + return provider.CreateSession(); + } + } +} diff --git a/src/designer/elsa-workflows-studio/package-lock.json b/src/designer/elsa-workflows-studio/package-lock.json index ce9a2a753..f38c90b59 100644 --- a/src/designer/elsa-workflows-studio/package-lock.json +++ b/src/designer/elsa-workflows-studio/package-lock.json @@ -1,12 +1,7 @@ { "name": "@elsa-workflows/elsa-workflow-designer", -<<<<<<< Updated upstream - "version": "2.0.0-preview-9", - "lockfileVersion": 1, -======= "version": "2.0.0-rc1.1", "lockfileVersion": 2, ->>>>>>> Stashed changes "requires": true, "packages": { "": { diff --git a/src/samples/server/Elsa.Samples.Server.Host/Elsa.Samples.Server.Host.csproj b/src/samples/server/Elsa.Samples.Server.Host/Elsa.Samples.Server.Host.csproj index e68baf593..8c4143f69 100644 --- a/src/samples/server/Elsa.Samples.Server.Host/Elsa.Samples.Server.Host.csproj +++ b/src/samples/server/Elsa.Samples.Server.Host/Elsa.Samples.Server.Host.csproj @@ -15,6 +15,7 @@ + diff --git a/src/samples/server/Elsa.Samples.Server.Host/Startup.cs b/src/samples/server/Elsa.Samples.Server.Host/Startup.cs index c545d16ca..3db174d6d 100644 --- a/src/samples/server/Elsa.Samples.Server.Host/Startup.cs +++ b/src/samples/server/Elsa.Samples.Server.Host/Startup.cs @@ -1,5 +1,6 @@ using Elsa.Activities.Conductor.Extensions; using Elsa.Activities.UserTask.Extensions; +using Elsa.Activities.Webhooks.Extensions; using Elsa.Persistence.EntityFramework.Core.Extensions; using Elsa.Persistence.EntityFramework.Sqlite; using Microsoft.Extensions.Hosting; @@ -60,6 +61,7 @@ namespace Elsa.Samples.Server.Host .AddConductorActivities(options => elsaSection.GetSection("Conductor").Bind(options)) .AddActivitiesFrom() .AddWorkflowsFrom() + .AddWebhooks() ); // Elsa API endpoints.