The Webhook Endpoints API configuration
The Webhook Endpoints API configuration
This commit is contained in:
parent
02d8e9f2fa
commit
a718273c00
|
|
@ -4,7 +4,7 @@
|
|||
<Import Project="..\..\..\..\configureawait.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Description>
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -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<WebhookOptions>? configure = default)
|
||||
Action<WebhookOptionsBuilder>? 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<IActivityTypeProvider, WebhookActivityTypeProvider>()
|
||||
.AddScoped(options.WebhookDefinitionStoreFactory);
|
||||
.AddScoped(webhookOptionsBuilder.WebhookOptions.WebhookDefinitionStoreFactory);
|
||||
|
||||
services.Decorate<IWebhookDefinitionStore, InitializingWebhookDefinitionStore>();
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// <auto-generated />
|
||||
// <auto-generated />
|
||||
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 =>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<Import Project="..\..\..\..\configureawait.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Description>
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\..\..\common.props"/>
|
||||
<Import Project="..\..\..\..\configureawait.props"/>
|
||||
<Import Project="..\..\..\..\common.props" />
|
||||
<Import Project="..\..\..\..\configureawait.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Description>
|
||||
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 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\persistence\Elsa.Persistence.YesSql\Elsa.Persistence.YesSql.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Activities.Webhooks\Elsa.Activities.Webhooks.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Webhooks.Abstractions\Elsa.Webhooks.Abstractions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -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<IServiceProvider, IConfiguration> configure)
|
||||
// {
|
||||
// elsa.Services
|
||||
// .AddScoped<YesSqlWebhookDefinitionStore>()
|
||||
// .AddSingleton(sp => CreateStore(sp, configure))
|
||||
// .AddSingleton<ISessionProvider, SessionProvider>()
|
||||
// .AddScoped(CreateSession)
|
||||
// .AddScoped<IDataMigrationManager, DataMigrationManager>()
|
||||
// .AddStartupTask<DatabaseInitializer>()
|
||||
// .AddStartupTask<RunMigrations>()
|
||||
// .AddDataMigration<Migrations>()
|
||||
// .AddAutoMapperProfile<AutoMapperProfile>()
|
||||
// .AddIndexProvider<WebhookDefinitionIndexProvider>();
|
||||
namespace Elsa.Webhooks.Persistence.YesSql.Extensions
|
||||
{
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static WebhookOptionsBuilder UseYesSqlPersistence(this WebhookOptionsBuilder elsa, Action<IServiceProvider, IConfiguration> configure)
|
||||
{
|
||||
elsa.Services
|
||||
.AddScoped<YesSqlWebhookDefinitionStore>()
|
||||
.AddSingleton(sp => CreateStore(sp, configure))
|
||||
.AddSingleton<ISessionProvider, SessionProvider>()
|
||||
.AddScoped(CreateSession)
|
||||
.AddScoped<IDataMigrationManager, DataMigrationManager>()
|
||||
.AddStartupTask<DatabaseInitializer>()
|
||||
.AddStartupTask<RunMigrations>()
|
||||
.AddDataMigration<Migrations>()
|
||||
.AddAutoMapperProfile<AutoMapperProfile>()
|
||||
.AddIndexProvider<WebhookDefinitionIndexProvider>();
|
||||
|
||||
// return elsa
|
||||
// .UseWebhookDefinitionStore(sp => sp.GetRequiredService<YesSqlWebhookDefinitionStore>());
|
||||
// }
|
||||
return elsa
|
||||
.UseWebhookDefinitionStore(sp => sp.GetRequiredService<YesSqlWebhookDefinitionStore>());
|
||||
}
|
||||
|
||||
// private static IStore CreateStore(
|
||||
// IServiceProvider serviceProvider,
|
||||
// Action<IServiceProvider, Configuration> configure)
|
||||
// {
|
||||
// var configuration = new Configuration
|
||||
// {
|
||||
// ContentSerializer = new CustomJsonContentSerializer()
|
||||
// };
|
||||
private static IStore CreateStore(
|
||||
IServiceProvider serviceProvider,
|
||||
Action<IServiceProvider, Configuration> 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<IIndexProvider>();
|
||||
// store.RegisterIndexes(indexes);
|
||||
var indexes = serviceProvider.GetServices<IIndexProvider>();
|
||||
store.RegisterIndexes(indexes);
|
||||
|
||||
// return store;
|
||||
// }
|
||||
return store;
|
||||
}
|
||||
|
||||
// private static ISession CreateSession(IServiceProvider serviceProvider)
|
||||
// {
|
||||
// var provider = serviceProvider.GetRequiredService<ISessionProvider>();
|
||||
// return provider.CreateSession();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
private static ISession CreateSession(IServiceProvider serviceProvider)
|
||||
{
|
||||
var provider = serviceProvider.GetRequiredService<ISessionProvider>();
|
||||
return provider.CreateSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
"": {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<ProjectReference Include="..\..\..\activities\Elsa.Activities.Temporal.Hangfire\Elsa.Activities.Temporal.Hangfire.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\Elsa.Activities.Temporal.Quartz\Elsa.Activities.Temporal.Quartz.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\Elsa.Activities.UserTask\Elsa.Activities.UserTask.csproj" />
|
||||
<ProjectReference Include="..\..\..\activities\webhooks\Elsa.Activities.Webhooks\Elsa.Activities.Webhooks.csproj" />
|
||||
<ProjectReference Include="..\..\..\caching\Elsa.Caching.Rebus\Elsa.Caching.Rebus.csproj" />
|
||||
<ProjectReference Include="..\..\..\locking\Elsa.DistributedLocking.SqlServer\Elsa.DistributedLocking.SqlServer.csproj" />
|
||||
<ProjectReference Include="..\..\..\persistence\Elsa.Persistence.EntityFramework\Elsa.Persistence.EntityFramework.PostgreSql\Elsa.Persistence.EntityFramework.PostgreSql.csproj" />
|
||||
|
|
|
|||
|
|
@ -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<Startup>()
|
||||
.AddWorkflowsFrom<Startup>()
|
||||
.AddWebhooks()
|
||||
);
|
||||
|
||||
// Elsa API endpoints.
|
||||
|
|
|
|||
Loading…
Reference in a new issue