* WIP #667 - Webhook activity project * WIP #667 - Webhook definition with InMemoryStore * WIP #667 - Add Webhook activity provider * Prevent part assembly generation See https://github.com/dotnet/aspnetcore/issues/24171 * Make optional args optional * Small changes * Move Refit client api to ElsaClient Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
This commit is contained in:
parent
caf15ecc70
commit
bc986ec003
|
|
@ -11,7 +11,6 @@ using Elsa.Metadata;
|
|||
using Elsa.Persistence.Specifications;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Elsa.Activities.Webhooks.ActivityTypes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
using System;
|
||||
using Elsa;
|
||||
using Elsa.Activities.Webhooks;
|
||||
using Elsa.Activities.Webhooks.ActivityTypes;
|
||||
using Elsa.Activities.Webhooks.Options;
|
||||
using Elsa.Activities.Webhooks.Persistence;
|
||||
using Elsa.Activities.Webhooks.Persistence.Decorators;
|
||||
using Elsa.ActivityProviders;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
|
||||
// Services.
|
||||
services
|
||||
.AddActivityTypeProvider<WebhookActivityTypeProvider>()
|
||||
.AddScoped<IActivityTypeProvider, WebhookActivityTypeProvider>()
|
||||
.AddScoped(options.WebhookDefinitionStoreFactory);
|
||||
|
||||
services.Decorate<IWebhookDefinitionStore, InitializingWebhookDefinitionStore>();
|
||||
|
|
|
|||
|
|
@ -1,19 +1,22 @@
|
|||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Elsa.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Elsa.Activities.Webhooks.Models
|
||||
{
|
||||
public class WebhookDefinition : Entity, ITenantScope
|
||||
[DataContract]
|
||||
public class WebhookDefinition : IEntity, ITenantScope
|
||||
{
|
||||
public string Name { get; set; } = default!;
|
||||
[DataMember(Order = 1)] public string Id { get; set; } = default!;
|
||||
|
||||
public PathString Path { get; set; }
|
||||
[DataMember(Order = 2)] public string? TenantId { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
[DataMember(Order = 3)] public string Name { get; set; } = default!;
|
||||
|
||||
public string? PayloadTypeName { get; set; }
|
||||
[DataMember(Order = 4)] public string Path { get; set; } = default!;
|
||||
|
||||
public string? TenantId { get; set; }
|
||||
[DataMember(Order = 5)] public string? Description { get; set; }
|
||||
|
||||
[DataMember(Order = 6)] public string? PayloadTypeName { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using Elsa.Activities.Webhooks.Services;
|
||||
using Elsa.Client.Services;
|
||||
|
||||
namespace Elsa.Client
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using Elsa.Client.Converters;
|
||||
using Elsa.Client.Options;
|
||||
|
|
@ -27,7 +27,8 @@ namespace Elsa.Client.Extensions
|
|||
.AddApiClient<IActivitiesApi>(refitSettings, httpClientFactory)
|
||||
.AddApiClient<IWorkflowDefinitionsApi>(refitSettings, httpClientFactory)
|
||||
.AddApiClient<IWorkflowRegistryApi>(refitSettings, httpClientFactory)
|
||||
.AddApiClient<IWorkflowInstancesApi>(refitSettings, httpClientFactory);
|
||||
.AddApiClient<IWorkflowInstancesApi>(refitSettings, httpClientFactory)
|
||||
.AddApiClient<IWebhookDefinitionsApi>(refitSettings, httpClientFactory);
|
||||
|
||||
return services
|
||||
.AddTransient<IElsaClient, ElsaClient>();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using Elsa.Activities.Webhooks.Services;
|
||||
using Elsa.Client.Services;
|
||||
|
||||
namespace Elsa.Client
|
||||
|
|
|
|||
17
src/clients/Elsa.Client/Services/IWebhookDefinitionsApi.cs
Normal file
17
src/clients/Elsa.Client/Services/IWebhookDefinitionsApi.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.Webhooks.Models;
|
||||
using Refit;
|
||||
|
||||
namespace Elsa.Client.Services
|
||||
{
|
||||
public interface IWebhookDefinitionsApi
|
||||
{
|
||||
[Get("/v1/webhook-definitions")]
|
||||
Task<IEnumerable<WebhookDefinition>> ListAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/webhook-definitions/{webhookDefinitionId}")]
|
||||
Task<WebhookDefinition> GetByIdAsync(string webhookDefinitionId, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using ProtoBuf;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace ElsaDashboard.Shared.Rpc
|
||||
{
|
||||
[ProtoContract]
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Elsa.Activities.Webhooks.Models;
|
|||
using ProtoBuf.Grpc;
|
||||
using ProtoBuf.Grpc.Configuration;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace ElsaDashboard.Shared.Rpc
|
||||
{
|
||||
[Service]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Elsa.Activities.Webhooks.Models;
|
||||
using Elsa.Client.Models;
|
||||
using ProtoBuf.Meta;
|
||||
|
||||
|
|
@ -16,7 +17,8 @@ namespace ElsaDashboard.Shared.Surrogates
|
|||
[typeof(VersionOptions)] = typeof(VersionOptionsSurrogate),
|
||||
[typeof(WorkflowInstance)] = typeof(WorkflowInstanceSurrogate),
|
||||
[typeof(WorkflowDefinition)] = typeof(WorkflowDefinitionSurrogate),
|
||||
[typeof(WorkflowBlueprint)] = typeof(WorkflowBlueprintSurrogate)
|
||||
[typeof(WorkflowBlueprint)] = typeof(WorkflowBlueprintSurrogate),
|
||||
[typeof(WebhookDefinition)] = typeof(WebhookDefinitionSurrogate),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
using Elsa.Activities.Webhooks.Models;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace ElsaDashboard.Shared.Surrogates
|
||||
{
|
||||
[ProtoContract(IgnoreListHandling = true)]
|
||||
public class WebhookDefinitionSurrogate
|
||||
{
|
||||
public WebhookDefinitionSurrogate(WebhookDefinition value)
|
||||
{
|
||||
Id = value.Id;
|
||||
TenantId = value.TenantId;
|
||||
Name = value.Name;
|
||||
Path = value.Path;
|
||||
Description = value.Description;
|
||||
PayloadTypeName = value.PayloadTypeName;
|
||||
}
|
||||
|
||||
[ProtoMember(1)] public string? Id { get; }
|
||||
[ProtoMember(2)] public string? TenantId { get; }
|
||||
[ProtoMember(3)] public string? Name { get; }
|
||||
[ProtoMember(4)] public string? Path { get; }
|
||||
[ProtoMember(5)] public string? Description { get; }
|
||||
[ProtoMember(6)] public string? PayloadTypeName { get; }
|
||||
|
||||
public static implicit operator WebhookDefinition?(WebhookDefinitionSurrogate? surrogate) =>
|
||||
surrogate != null
|
||||
? new WebhookDefinition
|
||||
{
|
||||
Id = surrogate.Id ?? string.Empty,
|
||||
TenantId = surrogate.TenantId,
|
||||
Name = surrogate.Name ?? string.Empty,
|
||||
Path = surrogate.Path ?? string.Empty,
|
||||
Description = surrogate.Description,
|
||||
PayloadTypeName = surrogate.PayloadTypeName,
|
||||
}
|
||||
: default;
|
||||
|
||||
public static implicit operator WebhookDefinitionSurrogate?(WebhookDefinition? source) =>
|
||||
source != null ? new WebhookDefinitionSurrogate(source) : default;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using ElsaDashboard.WebAssembly.Options;
|
||||
using Grpc.Core;
|
||||
using Grpc.Net.Client;
|
||||
|
|
@ -26,13 +27,15 @@ namespace ElsaDashboard.WebAssembly.Extensions
|
|||
//var tokenManager = sp.GetRequiredService<ITokenManager>();
|
||||
|
||||
var credentials = CallCredentials.FromInterceptor(
|
||||
async (context, metadata) =>
|
||||
(context, metadata) =>
|
||||
{
|
||||
//var accessToken = await tokenManager.GetAccessTokenAsync();
|
||||
var accessToken = "";
|
||||
|
||||
if (!string.IsNullOrEmpty(accessToken))
|
||||
metadata.Add("Authorization", $"Bearer {accessToken}");
|
||||
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
|
||||
var channel = GrpcChannel.ForAddress(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using ElsaDashboard.Shared.Rpc;
|
||||
using ElsaDashboard.Shared.Surrogates;
|
||||
using ElsaDashboard.WebAssembly.Options;
|
||||
|
|
@ -22,7 +22,8 @@ namespace ElsaDashboard.WebAssembly.Extensions
|
|||
.AddGrpcClient<IActivityService>()
|
||||
.AddGrpcClient<IWorkflowDefinitionService>()
|
||||
.AddGrpcClient<IWorkflowInstanceService>()
|
||||
.AddGrpcClient<IWorkflowRegistryService>();
|
||||
.AddGrpcClient<IWorkflowRegistryService>()
|
||||
.AddGrpcClient<IWebhookDefinitionService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue