diff --git a/Elsa.sln b/Elsa.sln index d206732dd..5c442c131 100644 --- a/Elsa.sln +++ b/Elsa.sln @@ -302,8 +302,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "trace-lens", "trace-lens", EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integrations", "integrations", "{EBD0CF78-C5D7-4B4B-94C9-C5D8C20B6F59}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.OrchardCore", "src\modules\Elsa.OrchardCore\Elsa.OrchardCore.csproj", "{B0460856-7E6D-4B1E-B243-8E20662FC32E}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agents", "agents", "{50470834-4CD8-479A-8B58-0A1869BA5D37}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elsa.Agents.Core", "src\modules\Elsa.Agents.Core\Elsa.Agents.Core.csproj", "{5BD671F0-9603-4C2F-8364-54B02986EAA2}" @@ -755,10 +753,6 @@ Global {47FBCB04-0C2D-453C-BE2F-7052CAC22524}.Debug|Any CPU.Build.0 = Debug|Any CPU {47FBCB04-0C2D-453C-BE2F-7052CAC22524}.Release|Any CPU.ActiveCfg = Release|Any CPU {47FBCB04-0C2D-453C-BE2F-7052CAC22524}.Release|Any CPU.Build.0 = Release|Any CPU - {B0460856-7E6D-4B1E-B243-8E20662FC32E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B0460856-7E6D-4B1E-B243-8E20662FC32E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B0460856-7E6D-4B1E-B243-8E20662FC32E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B0460856-7E6D-4B1E-B243-8E20662FC32E}.Release|Any CPU.Build.0 = Release|Any CPU {5BD671F0-9603-4C2F-8364-54B02986EAA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5BD671F0-9603-4C2F-8364-54B02986EAA2}.Debug|Any CPU.Build.0 = Debug|Any CPU {5BD671F0-9603-4C2F-8364-54B02986EAA2}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -1005,7 +999,6 @@ Global {6DDB9ECF-D454-4894-A262-A6BB3026E61E} = {B32DB9B2-AD6C-48A5-8682-4373CB045185} {16B570BC-E293-4A19-B20E-5C97BAF8476B} = {B32DB9B2-AD6C-48A5-8682-4373CB045185} {EBD0CF78-C5D7-4B4B-94C9-C5D8C20B6F59} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79} - {B0460856-7E6D-4B1E-B243-8E20662FC32E} = {EBD0CF78-C5D7-4B4B-94C9-C5D8C20B6F59} {50470834-4CD8-479A-8B58-0A1869BA5D37} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79} {5BD671F0-9603-4C2F-8364-54B02986EAA2} = {50470834-4CD8-479A-8B58-0A1869BA5D37} {154525CD-3726-45B7-9A9C-553BBC60EB10} = {50470834-4CD8-479A-8B58-0A1869BA5D37} diff --git a/src/modules/Elsa.OrchardCore/Activities/ContentItemEvent.cs b/src/modules/Elsa.OrchardCore/Activities/ContentItemEvent.cs deleted file mode 100644 index 95517d108..000000000 --- a/src/modules/Elsa.OrchardCore/Activities/ContentItemEvent.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Elsa.Expressions.Models; -using Elsa.Extensions; -using Elsa.Mediator.Contracts; -using Elsa.OrchardCore.Stimuli; -using Elsa.OrchardCore.WebhookPayloads; -using Elsa.Workflows; -using Elsa.Workflows.Attributes; - -namespace Elsa.OrchardCore.Activities; - -public class ContentItemEvent : Trigger, INotification -{ - /// - /// The content type to handle the event for. - /// - [Input(Description = "The content type to handle the event for.")] - public string ContentType { get; set; } = default!; - - /// - /// The event to handle. - /// - [Input(Description = "The event to handle the event for.")] - public string EventType { get; set; } = default!; - - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - if (!context.IsTriggerOfWorkflow()) - { - context.CreateBookmark(GetStimulus(context.ExpressionExecutionContext), OnResumeAsync); - return; - } - - await ExecuteInternalAsync(context); - } - - protected override object GetTriggerPayload(TriggerIndexingContext context) => new ContentItemEventStimulus(ContentType, EventType); - private async ValueTask OnResumeAsync(ActivityExecutionContext context) => await ExecuteInternalAsync(context); - private object GetStimulus(ExpressionExecutionContext context) => new ContentItemEventStimulus(ContentType, EventType); - - private async Task ExecuteInternalAsync(ActivityExecutionContext context) - { - var payload = context.GetWorkflowInput(); - context.SetResult(payload); - await context.CompleteActivityAsync(); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Activities/CreateContentItem.cs b/src/modules/Elsa.OrchardCore/Activities/CreateContentItem.cs deleted file mode 100644 index ed5ddd113..000000000 --- a/src/modules/Elsa.OrchardCore/Activities/CreateContentItem.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Text.Json.Nodes; -using Elsa.Expressions.Helpers; -using Elsa.Extensions; -using Elsa.OrchardCore.Client; -using Elsa.Workflows; -using Elsa.Workflows.Attributes; -using Elsa.Workflows.Models; - -namespace Elsa.OrchardCore.Activities; - -[Activity("OrchardCore", "Orchard Core", "Patches a content item", Kind = ActivityKind.Task)] -public class CreateContentItem : CodeActivity -{ - [Input(Description = "The content type of the content item to create.")] - public Input ContentType { get; set; } = default!; - - [Input(Description = "The properties to apply to the content item.")] - public Input Properties { get; set; } = default!; - - [Input(Description = "Whether to publish the content item.")] - public Input Publish { get; set; } = default!; - - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - var contentType = ContentType.Get(context); - var publish = Publish.Get(context); - var properties = Properties.Get(context).ConvertTo()!; - var apiClient = context.GetRequiredService(); - var request = new CreateContentItemRequest - { - ContentType = contentType, - Properties = properties, - Publish = publish - }; - var contentItem = await apiClient.CreateContentItemAsync(request, context.CancellationToken); - context.SetResult(contentItem); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Activities/LocalizeContentItem.cs b/src/modules/Elsa.OrchardCore/Activities/LocalizeContentItem.cs deleted file mode 100644 index 7b71e3e33..000000000 --- a/src/modules/Elsa.OrchardCore/Activities/LocalizeContentItem.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Text.Json.Nodes; -using Elsa.Extensions; -using Elsa.OrchardCore.Client; -using Elsa.Workflows; -using Elsa.Workflows.Attributes; -using Elsa.Workflows.Models; - -namespace Elsa.OrchardCore.Activities; - -[Activity("OrchardCore", "Orchard Core", "Localizes a content item", Kind = ActivityKind.Task)] -public class LocalizeContentItem : CodeActivity -{ - [Input(Description = "The ID of the content item to localize.")] - public Input ContentItemId { get; set; } = default!; - - [Input(Description = "The culture code to use when creating a localized version.")] - public Input CultureCode { get; set; } = default!; - - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - var contentItemId = ContentItemId.Get(context); - var cultureCode = CultureCode.Get(context); - var apiClient = context.GetRequiredService(); - var request = new LocalizeContentItemRequest - { - CultureCode = cultureCode - }; - var localizedContentItem = await apiClient.LocalizeContentItemAsync(contentItemId, request, context.CancellationToken); - context.SetResult(localizedContentItem); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Activities/PatchContentItem.cs b/src/modules/Elsa.OrchardCore/Activities/PatchContentItem.cs deleted file mode 100644 index 968ef61c9..000000000 --- a/src/modules/Elsa.OrchardCore/Activities/PatchContentItem.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Text.Json.Nodes; -using Elsa.Extensions; -using Elsa.OrchardCore.Client; -using Elsa.Workflows; -using Elsa.Workflows.Attributes; -using Elsa.Workflows.Models; - -namespace Elsa.OrchardCore.Activities; - -[Activity("OrchardCore", "Orchard Core", "Patches a content item", Kind = ActivityKind.Task)] -public class PatchContentItem : CodeActivity -{ - [Input(Description = "The ID of the content item to patch.")] - public Input ContentItemId { get; set; } = default!; - - [Input(Description = "The patch to apply to the content item.")] - public Input Patch { get; set; } = default!; - - [Input(Description = "Whether to publish the patched content item.")] - public Input Publish { get; set; } = default!; - - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - var contentItemId = ContentItemId.Get(context); - var publish = Publish.Get(context); - var patch = Patch.Get(context); - var apiClient = context.GetRequiredService(); - var request = new PatchContentItemRequest - { - Patch = patch, - Publish = publish - }; - var patchedContentItem = await apiClient.PatchContentItemAsync(contentItemId, request, context.CancellationToken); - context.SetResult(patchedContentItem); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Activities/ResolveTags.cs b/src/modules/Elsa.OrchardCore/Activities/ResolveTags.cs deleted file mode 100644 index 4f4a9d351..000000000 --- a/src/modules/Elsa.OrchardCore/Activities/ResolveTags.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Text.Json.Nodes; -using Elsa.Extensions; -using Elsa.OrchardCore.Client; -using Elsa.Workflows; -using Elsa.Workflows.Attributes; -using Elsa.Workflows.Models; - -namespace Elsa.OrchardCore.Activities; - -[Activity("OrchardCore", "Orchard Core", "Returns tag content items for the specified set of tags. If a tag doesn't exist, it is created.", Kind = ActivityKind.Task)] -public class ResolveTags : CodeActivity -{ - [Input(Description = "The tags to resolve.")] - public Input> Tags { get; set; } = default!; - - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - var tags = Tags.Get(context); - var apiClient = context.GetRequiredService(); - var request = new ResolveTagsRequest - { - Tags = tags - }; - var result = await apiClient.ResolveTagsAsync(request, context.CancellationToken); - context.SetResult(result); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Activities/SendGraphQLQuery.cs b/src/modules/Elsa.OrchardCore/Activities/SendGraphQLQuery.cs deleted file mode 100644 index 5c27b07ea..000000000 --- a/src/modules/Elsa.OrchardCore/Activities/SendGraphQLQuery.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Elsa.Extensions; -using Elsa.OrchardCore.Client; -using Elsa.Workflows; -using Elsa.Workflows.Attributes; -using Elsa.Workflows.Models; - -namespace Elsa.OrchardCore.Activities; - -[Activity("OrchardCore", "Orchard Core", "Send a GraphQL query to Orchard Core", DisplayName = "GraphQL Query", Kind = ActivityKind.Task)] -public class SendGraphQLQuery : CodeActivity -{ - /// - /// The content type to handle the event for. - /// - [Input(Description = "The GraphQL query string to send.")] - public Input Query { get; set; } = default!; - - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - var query = Query.Get(context); - var client = context.GetRequiredService(); - var targetType = Result.GetTargetType(context); - var output = await client.SendQueryAsync(query, targetType, context.CancellationToken); - context.SetResult(output); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Activities/UploadMedia.cs b/src/modules/Elsa.OrchardCore/Activities/UploadMedia.cs deleted file mode 100644 index 0a1dbaf30..000000000 --- a/src/modules/Elsa.OrchardCore/Activities/UploadMedia.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Text.Json.Nodes; -using Elsa.Extensions; -using Elsa.Http; -using Elsa.OrchardCore.Client; -using Elsa.Workflows; -using Elsa.Workflows.Attributes; -using Elsa.Workflows.Models; - -namespace Elsa.OrchardCore.Activities; - -[Activity("OrchardCore", "Orchard Core", "Patches a content item", Kind = ActivityKind.Task)] -public class UploadMedia : CodeActivity -{ - [Input(Description = "The files to upload into the Media Library.")] - public Input> Files { get; set; } = default!; - - [Input(Description = "The path to the media library folder to upload.")] - public Input FolderPath { get; set; } = default!; - - protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) - { - var files = Files.Get(context); - var folderPath = FolderPath.GetOrDefault(context); - var apiClient = context.GetRequiredService(); - var response = await apiClient.UploadFilesAsync(files, folderPath, context.CancellationToken); - context.SetResult(response); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/ActivityProviders/OrchardContentItemsEventActivityProvider.cs b/src/modules/Elsa.OrchardCore/ActivityProviders/OrchardContentItemsEventActivityProvider.cs deleted file mode 100644 index 88f35a545..000000000 --- a/src/modules/Elsa.OrchardCore/ActivityProviders/OrchardContentItemsEventActivityProvider.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Elsa.OrchardCore.Activities; -using Elsa.OrchardCore.Models; -using Elsa.Workflows; -using Elsa.Workflows.Models; -using Humanizer; -using JetBrains.Annotations; -using Microsoft.Extensions.Options; - -namespace Elsa.OrchardCore.ActivityProviders; - -/// -/// An activity provider that generates activity types based on Orchard content type events. -/// -[UsedImplicitly] -public class OrchardContentItemsEventActivityProvider(IOptions options, IActivityFactory activityFactory, IActivityDescriber activityDescriber) : IActivityProvider -{ - public async ValueTask> GetDescriptorsAsync(CancellationToken cancellationToken = default) - { - var contentTypes = options.Value.ContentTypes; - var matrix = - from contentType in contentTypes - from eventType in WebhookEventTypes.GetWebhookEventDescriptors() - select new - { - contentType, - eventType - }; - var activities = (await Task.WhenAll(matrix.Select(async x => await CreateActivityDescriptorAsync(x.contentType, x.eventType, cancellationToken)))).ToList(); - return activities; - } - - private async Task CreateActivityDescriptorAsync(string contentType, WebhookEventDescriptor eventDescriptor, CancellationToken cancellationToken = default) - { - var eventType = eventDescriptor.EventType; - var humanizedEventName = eventType.Humanize(); - var description = $"Handles {humanizedEventName} events for {contentType} content items"; - var name = $"{contentType}{eventType}"; - var displayName = $"{contentType} {eventType}"; - var fullTypeName = OrchardCoreActivityNameHelper.GetContentItemEventActivityFullTypeName(contentType, eventType); - var activityType = typeof(ContentItemEvent); - var activityDescriptor = await activityDescriber.DescribeActivityAsync(activityType, cancellationToken); - - activityDescriptor.TypeName = fullTypeName; - activityDescriptor.Name = name; - activityDescriptor.DisplayName = displayName; - activityDescriptor.Category = "Orchard Core"; - activityDescriptor.Description = description; - activityDescriptor.Constructor = context => - { - var activity = (ContentItemEvent)activityFactory.Create(activityType, context); - activity.Type = fullTypeName; - activity.ContentType = contentType; - activity.EventType = eventType; - return activity; - }; - - foreach (var inputDescriptor in activityDescriptor.Inputs) - inputDescriptor.IsBrowsable = false; - - return activityDescriptor; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Contracts/IGraphQLClient.cs b/src/modules/Elsa.OrchardCore/Client/Contracts/IGraphQLClient.cs deleted file mode 100644 index 70e6d6db3..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Contracts/IGraphQLClient.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Elsa.OrchardCore.Client; - -public interface IGraphQLClient -{ - Task SendQueryAsync(string query, Type? targetType, CancellationToken cancellationToken = default); -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Contracts/IRestApiClient.cs b/src/modules/Elsa.OrchardCore/Client/Contracts/IRestApiClient.cs deleted file mode 100644 index 828e46551..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Contracts/IRestApiClient.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Text.Json.Nodes; -using Elsa.Http; - -namespace Elsa.OrchardCore.Client; - -public interface IRestApiClient -{ - Task GetContentItemAsync(string contentItemId, CancellationToken cancellationToken = default); - Task PatchContentItemAsync(string contentItemId, PatchContentItemRequest request, CancellationToken cancellationToken = default); - Task LocalizeContentItemAsync(string contentItemId, LocalizeContentItemRequest request, CancellationToken cancellationToken = default); - Task CreateContentItemAsync(CreateContentItemRequest request, CancellationToken cancellationToken = default); - Task UploadFilesAsync(IEnumerable files, string? folderPath = null, CancellationToken cancellationToken = default); - Task ResolveTagsAsync(ResolveTagsRequest request, CancellationToken cancellationToken = default); -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Contracts/ISecurityTokenClient.cs b/src/modules/Elsa.OrchardCore/Client/Contracts/ISecurityTokenClient.cs deleted file mode 100644 index ecda01913..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Contracts/ISecurityTokenClient.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Elsa.OrchardCore.Client; - -public interface ISecurityTokenClient -{ - Task GetSecurityTokenAsync(string clientId, string clientSecret, CancellationToken cancellationToken = default); -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Contracts/ISecurityTokenService.cs b/src/modules/Elsa.OrchardCore/Client/Contracts/ISecurityTokenService.cs deleted file mode 100644 index ded759c1c..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Contracts/ISecurityTokenService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Elsa.OrchardCore.Client; - -public interface ISecurityTokenService -{ - Task GetTokenAsync(CancellationToken cancellationToken = default); - Task RefreshTokenAsync(CancellationToken cancellationToken = default); -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/DelegatingHandlers/AuthenticatingDelegatingHandler.cs b/src/modules/Elsa.OrchardCore/Client/DelegatingHandlers/AuthenticatingDelegatingHandler.cs deleted file mode 100644 index 8f3930f6c..000000000 --- a/src/modules/Elsa.OrchardCore/Client/DelegatingHandlers/AuthenticatingDelegatingHandler.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Net; -using System.Net.Http.Headers; - -namespace Elsa.OrchardCore.Client; - -public class AuthenticatingDelegatingHandler(ISecurityTokenService tokenService) : DelegatingHandler -{ - protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) - { - var token = await tokenService.GetTokenAsync(cancellationToken); - request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken); - - var response = await base.SendAsync(request, cancellationToken); - - if (response.StatusCode == HttpStatusCode.Unauthorized) - { - // Token might be expired; refresh it - token = await tokenService.RefreshTokenAsync(cancellationToken); - - // Retry the request with the new token - request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken); - response = await base.SendAsync(request, cancellationToken); - } - - return response; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Extensions/OrchardCoreClientServiceCollectionExtensions.cs b/src/modules/Elsa.OrchardCore/Client/Extensions/OrchardCoreClientServiceCollectionExtensions.cs deleted file mode 100644 index b4c46332d..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Extensions/OrchardCoreClientServiceCollectionExtensions.cs +++ /dev/null @@ -1,35 +0,0 @@ -using JetBrains.Annotations; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; - -namespace Elsa.OrchardCore.Client.Extensions; - -[PublicAPI] -public static class OrchardCoreClientServiceCollectionExtensions -{ - public static IServiceCollection AddOrchardCoreClient(this IServiceCollection services) - { - services.AddTransient(); - services.AddTransient(); - - services.AddHttpClient((sp, httpClient) => - { - var options = sp.GetRequiredService>().Value; - httpClient.BaseAddress = options.BaseAddress; - }); - - services.AddHttpClient((sp, httpClient) => - { - var options = sp.GetRequiredService>().Value; - httpClient.BaseAddress = options.BaseAddress; - }).AddHttpMessageHandler(); - - services.AddHttpClient((sp, httpClient) => - { - var options = sp.GetRequiredService>().Value; - httpClient.BaseAddress = options.BaseAddress; - }).AddHttpMessageHandler(); - - return services; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Models/CreateContentItemRequest.cs b/src/modules/Elsa.OrchardCore/Client/Models/CreateContentItemRequest.cs deleted file mode 100644 index 0fcd1f338..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Models/CreateContentItemRequest.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Text.Json.Nodes; - -namespace Elsa.OrchardCore.Client; - -public class CreateContentItemRequest -{ - public string ContentType { get; set; } = default!; - public JsonNode Properties { get; set; } = default!; - public bool Publish { get; set; } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Models/LocalizeContentItemRequest.cs b/src/modules/Elsa.OrchardCore/Client/Models/LocalizeContentItemRequest.cs deleted file mode 100644 index 9720a266b..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Models/LocalizeContentItemRequest.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Elsa.OrchardCore.Client; - -public class LocalizeContentItemRequest -{ - public string CultureCode { get; set; } = default!; -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Models/PatchContentItemRequest.cs b/src/modules/Elsa.OrchardCore/Client/Models/PatchContentItemRequest.cs deleted file mode 100644 index 20d8a069c..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Models/PatchContentItemRequest.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Text.Json.Nodes; - -namespace Elsa.OrchardCore.Client; - -public class PatchContentItemRequest -{ - public JsonNode Patch { get; set; } = default!; - public bool Publish { get; set; } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Models/ResolveTagsRequest.cs b/src/modules/Elsa.OrchardCore/Client/Models/ResolveTagsRequest.cs deleted file mode 100644 index 7e5c66e78..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Models/ResolveTagsRequest.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Elsa.OrchardCore.Client; - -public class ResolveTagsRequest -{ - public ICollection Tags { get; set; } = []; -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Models/SecurityToken.cs b/src/modules/Elsa.OrchardCore/Client/Models/SecurityToken.cs deleted file mode 100644 index e094e9978..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Models/SecurityToken.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Elsa.OrchardCore.Client; - -/// -/// -/// -/// -/// -/// -public record SecurityToken(string AccessToken, string TokenType, int ExpiresIn); \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Options/OrchardCoreClientOptions.cs b/src/modules/Elsa.OrchardCore/Client/Options/OrchardCoreClientOptions.cs deleted file mode 100644 index 6dfdce6c3..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Options/OrchardCoreClientOptions.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Elsa.OrchardCore.Client; - -/// -/// Options related to connecting to an Orchard Core tenant. -/// -public class OrchardCoreClientOptions -{ - /// - /// The base address of the Orchard Core tenant to interact with. - /// - public Uri BaseAddress { get; set; } = default!; - - /// - /// The client ID. - /// - public string ClientId { get; set; } = default!; - - /// - /// The client secret. - /// - public string ClientSecret { get; set; } = default!; -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Services/DefaultGraphQlClient.cs b/src/modules/Elsa.OrchardCore/Client/Services/DefaultGraphQlClient.cs deleted file mode 100644 index c4d342bd5..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Services/DefaultGraphQlClient.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Text.Json.Nodes; -using Elsa.Expressions.Helpers; - -namespace Elsa.OrchardCore.Client; - -public class DefaultGraphQlClient(HttpClient httpClient) : IGraphQLClient -{ - public async Task SendQueryAsync(string query, Type? targetType = null, CancellationToken cancellationToken = default) - { - var content = new StringContent(query, System.Text.Encoding.UTF8, "application/graphql"); - var response = await httpClient.PostAsync("api/graphql", content, cancellationToken); - response.EnsureSuccessStatusCode(); - var json = await response.Content.ReadAsStringAsync(cancellationToken); - - targetType ??= typeof(JsonObject); - return ObjectConverter.ConvertTo(json, targetType); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Services/DefaultRestApiClient.cs b/src/modules/Elsa.OrchardCore/Client/Services/DefaultRestApiClient.cs deleted file mode 100644 index f01abbd0d..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Services/DefaultRestApiClient.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Net.Http.Json; -using System.Text.Json; -using System.Text.Json.Nodes; -using Elsa.Http; - -namespace Elsa.OrchardCore.Client; - -public class DefaultRestApiClient(HttpClient httpClient) : IRestApiClient -{ - public async Task GetContentItemAsync(string contentItemId, CancellationToken cancellationToken = default) - { - var response = await httpClient.GetAsync($"api/content/{contentItemId}", cancellationToken); - response.EnsureSuccessStatusCode(); - return await response.Content.ReadFromJsonAsync(cancellationToken: cancellationToken); - } - - public async Task PatchContentItemAsync(string contentItemId, PatchContentItemRequest request, CancellationToken cancellationToken = default) - { - var content = JsonContent.Create(request); - var response = await httpClient.PatchAsync($"api/content-items/{contentItemId}", content, cancellationToken); - response.EnsureSuccessStatusCode(); - return await response.Content.ReadFromJsonAsync(cancellationToken: cancellationToken); - } - - public async Task LocalizeContentItemAsync(string contentItemId, LocalizeContentItemRequest request, CancellationToken cancellationToken = default) - { - var content = JsonContent.Create(request); - var response = await httpClient.PostAsync($"api/content-items/{contentItemId}/localize", content, cancellationToken); - response.EnsureSuccessStatusCode(); - var json = await response.Content.ReadAsStringAsync(cancellationToken); - return JsonSerializer.Deserialize(json); - } - - public async Task CreateContentItemAsync(CreateContentItemRequest request, CancellationToken cancellationToken = default) - { - var content = JsonContent.Create(request); - var response = await httpClient.PostAsync("api/content-items", content, cancellationToken); - response.EnsureSuccessStatusCode(); - return await response.Content.ReadFromJsonAsync(cancellationToken: cancellationToken); - } - - public async Task UploadFilesAsync(IEnumerable files, string? folderPath = null, CancellationToken cancellationToken = default) - { - var content = new MultipartFormDataContent(); - - foreach (var file in files) - { - var streamContent = file.GetStreamContent(); - content.Add(streamContent); - } - - var response = await httpClient.PostAsync($"api/media/upload?path={folderPath}", content, cancellationToken); - response.EnsureSuccessStatusCode(); - return await response.Content.ReadFromJsonAsync(cancellationToken: cancellationToken); - } - - public async Task ResolveTagsAsync(ResolveTagsRequest request, CancellationToken cancellationToken = default) - { - var content = JsonContent.Create(request); - var response = await httpClient.PostAsync("api/tags/resolve", content, cancellationToken); - response.EnsureSuccessStatusCode(); - return await response.Content.ReadFromJsonAsync(cancellationToken: cancellationToken); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Services/DefaultSecurityTokenClient.cs b/src/modules/Elsa.OrchardCore/Client/Services/DefaultSecurityTokenClient.cs deleted file mode 100644 index 4b4bd9cdb..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Services/DefaultSecurityTokenClient.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Text.Json; - -namespace Elsa.OrchardCore.Client; - -public class DefaultSecurityTokenClient(HttpClient httpClient) : ISecurityTokenClient -{ - private readonly JsonSerializerOptions _jsonSerializerOptions = new() - { - PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower - }; - - public async Task GetSecurityTokenAsync(string clientId, string clientSecret, CancellationToken cancellationToken = default) - { - var content = new FormUrlEncodedContent(new Dictionary - { - ["grant_type"] = "client_credentials", - ["client_id"] = clientId, - ["client_secret"] = clientSecret - }); - - var response = await httpClient.PostAsync("/connect/token", content, cancellationToken); - response.EnsureSuccessStatusCode(); - var responseContent = await response.Content.ReadAsStringAsync(cancellationToken); - return JsonSerializer.Deserialize(responseContent, _jsonSerializerOptions); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Client/Services/DefaultSecurityTokenService.cs b/src/modules/Elsa.OrchardCore/Client/Services/DefaultSecurityTokenService.cs deleted file mode 100644 index 3412201d6..000000000 --- a/src/modules/Elsa.OrchardCore/Client/Services/DefaultSecurityTokenService.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.Options; - -namespace Elsa.OrchardCore.Client; - -public class DefaultSecurityTokenService(IMemoryCache memoryCache, ISecurityTokenClient securityTokenClient, IOptions options) : ISecurityTokenService -{ - private readonly string _cacheKey = $"{nameof(DefaultSecurityTokenService)}:{Guid.NewGuid()}"; - - public async Task GetTokenAsync(CancellationToken cancellationToken = default) - { - return (await memoryCache.GetOrCreateAsync(_cacheKey, async entry => - { - var securityToken = await RequestSecurityTokenAsync(cancellationToken); - entry.AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(securityToken.ExpiresIn); - return securityToken; - }))!; - } - - public Task RefreshTokenAsync(CancellationToken cancellationToken = default) - { - return RequestSecurityTokenAsync(cancellationToken); - } - - private Task RequestSecurityTokenAsync(CancellationToken cancellationToken) - { - var clientId = options.Value.ClientId; - var clientSecret = options.Value.ClientSecret; - return securityTokenClient.GetSecurityTokenAsync(clientId, clientSecret, cancellationToken); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Elsa.OrchardCore.csproj b/src/modules/Elsa.OrchardCore/Elsa.OrchardCore.csproj deleted file mode 100644 index b01fe96e0..000000000 --- a/src/modules/Elsa.OrchardCore/Elsa.OrchardCore.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - Provides integrations with an Orchard Core application instances through activities and via HTTP. - - elsa module orchardcore - - - - - - - - - - - diff --git a/src/modules/Elsa.OrchardCore/Elsa.OrchardCore.csproj.DotSettings b/src/modules/Elsa.OrchardCore/Elsa.OrchardCore.csproj.DotSettings deleted file mode 100644 index 1cf137abd..000000000 --- a/src/modules/Elsa.OrchardCore/Elsa.OrchardCore.csproj.DotSettings +++ /dev/null @@ -1,9 +0,0 @@ - - True - True - True - True - True - True - True - True \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Extensions/ModuleExtensions.cs b/src/modules/Elsa.OrchardCore/Extensions/ModuleExtensions.cs deleted file mode 100644 index ca1ae7d83..000000000 --- a/src/modules/Elsa.OrchardCore/Extensions/ModuleExtensions.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Elsa.Features.Services; -using Elsa.OrchardCore.Features; - -// ReSharper disable once CheckNamespace -namespace Elsa.Extensions; - -/// -/// Adds extensions to that enables the feature. -/// -public static class ModuleExtensions -{ - /// - /// Enables and configures the feature. - /// - public static IModule UseOrchardCore(this IModule module, Action? configure = default) - { - module.Configure(configure); - return module; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Features/OrchardCoreFeature.cs b/src/modules/Elsa.OrchardCore/Features/OrchardCoreFeature.cs deleted file mode 100644 index 8deae86ba..000000000 --- a/src/modules/Elsa.OrchardCore/Features/OrchardCoreFeature.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Elsa.Extensions; -using Elsa.Features.Abstractions; -using Elsa.Features.Attributes; -using Elsa.Features.Services; -using Elsa.OrchardCore.ActivityProviders; -using Elsa.OrchardCore.Client.Extensions; -using Elsa.OrchardCore.WebhookPayloads; -using Elsa.Webhooks.Features; -using Microsoft.Extensions.DependencyInjection; - -namespace Elsa.OrchardCore.Features; - -[DependsOn(typeof(WebhooksFeature))] -public class OrchardCoreFeature(IModule module) : FeatureBase(module) -{ - public override void Configure() - { - Module.AddVariableTypeAndAlias("ContentItemPublished", "Orchard"); - Module.AddActivitiesFrom(); - Services - .AddActivityProvider() - .AddHandlersFrom() - ; - } - - public override void Apply() - { - Services.AddOrchardCoreClient(); - Services.AddOptions(); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/FodyWeavers.xml b/src/modules/Elsa.OrchardCore/FodyWeavers.xml deleted file mode 100644 index 00e1d9a1c..000000000 --- a/src/modules/Elsa.OrchardCore/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Handlers/InvokeOrchardWebhookEventActivities.cs b/src/modules/Elsa.OrchardCore/Handlers/InvokeOrchardWebhookEventActivities.cs deleted file mode 100644 index ec22b8aeb..000000000 --- a/src/modules/Elsa.OrchardCore/Handlers/InvokeOrchardWebhookEventActivities.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Elsa.Expressions.Helpers; -using Elsa.Mediator.Contracts; -using Elsa.OrchardCore.Stimuli; -using Elsa.OrchardCore.WebhookPayloads; -using Elsa.Webhooks.Notifications; -using Elsa.Workflows.Runtime; -using JetBrains.Annotations; -using WebhooksCore; - -namespace Elsa.OrchardCore.Handlers; - -/// -/// Invokes Orchard activities based on the received webhook. -/// -[UsedImplicitly] -public class InvokeOrchardWebhookEventActivities(IStimulusSender stimulusSender) : INotificationHandler -{ - public async Task HandleAsync(WebhookEventReceived notification, CancellationToken cancellationToken) - { - var webhookEvent = notification.WebhookEvent; - var webhookEventType = webhookEvent.EventType; - var webhookEventDescriptors = WebhookEventTypes.GetWebhookEventDescriptors().ToDictionary(x => x.WebhookEventType, x => x); - - if(!webhookEventDescriptors.TryGetValue(webhookEventType, out var webhookEventDescriptor)) - return; - - var eventType = webhookEventDescriptor.EventType; - var contentItemEventPayload = (ContentItemEventPayload)webhookEvent.Payload.ConvertTo(webhookEventDescriptor.PayloadType)!; - var contentType = contentItemEventPayload.ContentType; - var fullTypeName = OrchardCoreActivityNameHelper.GetContentItemEventActivityFullTypeName(contentType, eventType); - var stimulus = new ContentItemEventStimulus(contentType, eventType); - var metadata = new StimulusMetadata - { - Input = new Dictionary - { - [nameof(WebhookEvent)] = webhookEvent, - [nameof(ContentItemEventPayload)] = contentItemEventPayload - } - }; - await stimulusSender.SendAsync(fullTypeName, stimulus, metadata, cancellationToken); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Helpers/OrchardCoreActivityNameHelper.cs b/src/modules/Elsa.OrchardCore/Helpers/OrchardCoreActivityNameHelper.cs deleted file mode 100644 index 6abc1a104..000000000 --- a/src/modules/Elsa.OrchardCore/Helpers/OrchardCoreActivityNameHelper.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Elsa.OrchardCore; - -public static class OrchardCoreActivityNameHelper -{ - public static string GetContentItemEventActivityFullTypeName(string contentType, string eventName) - { - return $"OrchardCore.ContentItem.{contentType}.{eventName}"; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Models/WebhookEventDescriptor.cs b/src/modules/Elsa.OrchardCore/Models/WebhookEventDescriptor.cs deleted file mode 100644 index 42704fabf..000000000 --- a/src/modules/Elsa.OrchardCore/Models/WebhookEventDescriptor.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Elsa.OrchardCore.Models; - -public class WebhookEventDescriptor -{ - public string WebhookEventType { get; set; } - public string EventType { get; set; } - public Type PayloadType { get; set; } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Options/OrchardCoreOptions.cs b/src/modules/Elsa.OrchardCore/Options/OrchardCoreOptions.cs deleted file mode 100644 index 333411ab4..000000000 --- a/src/modules/Elsa.OrchardCore/Options/OrchardCoreOptions.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Elsa.OrchardCore; - -public class OrchardCoreOptions -{ - public ISet ContentTypes { get; set; } = new HashSet(); -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/Stimuli/ContentItemEventStimulus.cs b/src/modules/Elsa.OrchardCore/Stimuli/ContentItemEventStimulus.cs deleted file mode 100644 index ffe38c3a8..000000000 --- a/src/modules/Elsa.OrchardCore/Stimuli/ContentItemEventStimulus.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Elsa.OrchardCore.Stimuli; - -public record ContentItemEventStimulus(string ContentType, string EventType); \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/WebhookEventTypes.cs b/src/modules/Elsa.OrchardCore/WebhookEventTypes.cs deleted file mode 100644 index 92c6abdac..000000000 --- a/src/modules/Elsa.OrchardCore/WebhookEventTypes.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Elsa.OrchardCore.Models; -using Elsa.OrchardCore.WebhookPayloads; -using JetBrains.Annotations; - -namespace Elsa.OrchardCore; - -[UsedImplicitly] -public static class WebhookEventTypes -{ - public static IEnumerable GetWebhookEventDescriptors() - { - yield return GetWebhookEventDescriptor("content-item.created", "Created", typeof(ContentItemEventPayload)); - yield return GetWebhookEventDescriptor("content-item.published", "Published", typeof(ContentItemEventPayload)); - yield return GetWebhookEventDescriptor("content-item.unpublished", "Unpublished", typeof(ContentItemEventPayload)); - yield return GetWebhookEventDescriptor("content-item.removed", "Removed", typeof(ContentItemEventPayload)); - } - - private static WebhookEventDescriptor GetWebhookEventDescriptor(string webhookEventType, string eventType, Type payloadType) - { - return new WebhookEventDescriptor - { - WebhookEventType = webhookEventType, - EventType = eventType, - PayloadType = payloadType - }; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.OrchardCore/WebhookPayloads/ContentItemEventPayload.cs b/src/modules/Elsa.OrchardCore/WebhookPayloads/ContentItemEventPayload.cs deleted file mode 100644 index 087219c84..000000000 --- a/src/modules/Elsa.OrchardCore/WebhookPayloads/ContentItemEventPayload.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Elsa.OrchardCore.WebhookPayloads; - -public record ContentItemEventPayload( - string ContentType, - string DisplayText, - string Author, - string Owner, - string ContentItemId); \ No newline at end of file