elsa-core/src/modules/Elsa.Http/Features/HttpFeature.cs

270 lines
12 KiB
C#
Raw Normal View History

using System.Net;
using Elsa.Extensions;
using Elsa.Features.Abstractions;
2022-11-23 10:20:00 +00:00
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.Http.Bookmarks;
using Elsa.Http.ContentWriters;
using Elsa.Http.DownloadableContentHandlers;
using Elsa.Http.FileCaches;
using Elsa.Http.Handlers;
using Elsa.Http.Options;
using Elsa.Http.Parsers;
using Elsa.Http.PortResolvers;
Add IResilienceStrategy Abstraction with Category Matching and Expression-Based Configuration (#6637) * Add resilience module with core interfaces and services Introduced a new `Elsa.Resilience` module and its core components to support resilient services and activities. This includes resilience strategies, providers, and attributes, along with integration into the existing HTTP module for enhanced fault tolerance. Added solution and project references for proper dependency management. * Add resilience strategy framework with HTTP strategy support Introduced a resilience strategy architecture, including a configurable `HttpResilienceStrategy` with retry capabilities, strategy serialization, and integration with existing modules. Enhanced ResilienceFeature to support registration of strategy types and updated application configuration to enable resilience strategies. This change ensures more robust and fault-tolerant HTTP request handling. * Add JSON serialization support for resilience configuration Introduced `ConfigurationExtensions` to enable JSON serialization of configuration sections. Updated resilience strategies to utilize the new extension methods and adjusted JSON serialization logic to support polymorphism with `$type` discriminator. Minor modifications were made to support deserialization and property mutability. * Add resilience strategy support to workflows and API clients Introduced resilience strategy configuration, serialization, and execution support across workflows and API clients. Added new APIs, models, and services to enhance fault tolerance capabilities for activities and HTTP interactions. * Refactor resilience services for improved modularity. Replaced `IResilienceService` with new modular interfaces (`IResilienceStrategyCatalog`, `IResilienceStrategyConfigEvaluator`, `IResilientActivityInvoker`) and corresponding implementations. Enhanced maintainability by simplifying components and responsibilities, ensuring better separation of concerns. * Rename methods in ResilienceStrategyCatalog for clarity Updated method names in `ResilienceStrategyCatalog` and its interfaces for better readability and alignment with naming conventions. Replaced `GetAllStrategiesAsync` with `ListAsync` and `GetStrategyAsync` with `GetAsync` across the codebase. * Refactor resilience handling in HTTP activities. Replaced `ResilienceCategory` property with `ResilienceCategoryAttribute` for a cleaner implementation. Updated `IResilientActivity` to simplify its interface and adjusted related modifications accordingly. Introduced `IResilientActivityInvoker` to enhance resilience strategy execution. * Add support for additional resilience and scripting features Extended resilience strategy handling with serialization support, added `HttpResilienceStrategy` type in JavaScript handler, and refined object conversion logic for interfaces. Minor adjustments to `Expression` class properties for consistency. * Remove `UseResilience` call from Program.cs This call was redundant and no longer necessary for the application. Its removal simplifies the code and ensures only required middleware is used. * Remove commented-out JSON converter code in serializer setup Cleaned up unused and commented-out converter initialization code in `ResilienceStrategySerializer`. This improves readability and removes unnecessary clutter from the file. * Fix typo in method names from 'Resiliency' to 'Resilience' Renamed methods to maintain consistency in naming conventions across the codebase. This change ensures clarity and alignment with established terminology. * Refactor namespace for ConfigurationResilienceStrategySource Updated the namespace of ConfigurationResilienceStrategySource to "StrategySources" for better alignment with naming conventions and structure. Removed an unused namespace reference in ResilienceFeature for cleanup. * Mark EnableResiliency as obsolete in SendHttpRequestBase. The EnableResiliency property is now marked with the [Obsolete] attribute. Developers are encouraged to use the common Resilience Strategy setting instead for managing HTTP request resiliency. This change ensures better consistency and alignment with the broader resilience strategy. * Restrict ResilienceCategoryAttribute to class targets only Removed support for using ResilienceCategoryAttribute on properties. This change enforces a stricter and more focused usage of the attribute, ensuring it applies only to class-level declarations. * Add documentation for IResilientActivityInvoker interface Include summaries and parameter descriptions for the `InvokeAsync` method. This improves code clarity and helps developers understand the functionality and usage of the resilient activity invocation process. * Fix logical operator precedence in type comparison check Parentheses were added to ensure correct evaluation of conditions when checking type compatibility. This prevents potential logical errors when determining the target type in object conversions. * Add support for resilience source identification Introduce the `ResilienceSourceNameAttribute` to allow naming of resilience sources. Updated `ResilienceStrategyCatalog` to utilize the attribute for prefixing strategy IDs, improving source identification and traceability. Applied the attribute to `ConfigurationResilienceStrategySource` as an example. * Revert "Add support for resilience source identification" This reverts commit 19b4e7121d6330b5de4f692b78da4c1e4a2d1f67. * Reapply "Add support for resilience source identification" This reverts commit 8bcba9d040c4eb247077aec6d90dc02817adcbd5. * Revert "Reapply "Add support for resilience source identification"" This reverts commit ee04d35e7930956c752dda3ed150ca34a535e66c.
2025-05-12 08:09:04 +00:00
using Elsa.Http.Resilience;
using Elsa.Http.Selectors;
using Elsa.Http.Services;
Add multitenancy support for background tasks (#6059) * Remove initial migrations Deleted obsolete initial migration files from multiple databases: MySQL, SQL Server, SQLite, and PostgreSQL. This cleanup helps maintain a streamlined and updated migration history. * Add Document base class and create tenant-specific indices Introduced a new abstract `Document` base class to unify common properties. Implemented tenant-specific unique indices across multiple collections by including `TenantId` alongside `Id` to ensure uniqueness within tenant scopes. * Remove outdated migration files Deleted various migration files under MySql, PostgreSql, Sqlite, and SqlServer directories. This cleanup removes unnecessary schema definitions and helps to streamline the codebase. * Refactor workflow identity assignment logic Streamline workflow identity handling to ensure consistent assignment of Id, DefinitionId, and TenantId values. This change integrates tenant prefix and version suffix cleanly, enhancing clarity and maintainability. * Enable multitenancy support Added configuration for a new tenant (tenant-1) in appsettings.json and enabled multitenancy feature in Program.cs. This change allows the application to support multiple tenants, with specific configurations for each. * Refactor route table update to run as startup task Replaced `UpdateRouteTableHostedService` with `UpdateRouteTableStartupTask` to ensure route table updates are executed during application startup instead of as a hosted service. Updated configuration in `HttpFeature` and adjusted trigger validation logic in `ValidateWorkflowRequestHandler`. * Add recurring task scheduling and single-node task support. Introduce `IntervalExpressionType`, recurring task scheduling classes, and `SingleNodeTaskAttribute`. Update `RecurringTasksRunner` to handle schedules and add single-node task logic to `StartupTasksRunner`. Ensure proper namespace changes and configure sample recurring tasks. * Refactor recurring tasks scheduling system Replaced existing scheduling classes with a more modular and granular approach. Introduced new classes and interfaces like `ISchedule`, `CronSchedule`, `IntervalSchedule`, and `RecurringTaskScheduleManager`. Updated related methods and code to comply with the new design. * Refactor background task management Removed `ExpiredSecretsHostedService` and refactored it into a recurring task. Introduced `TaskExecutor` for shared task execution logic. Updated and renamed feature classes to better represent their purpose, improving task scheduling and execution management. * Add BackgroundTask abstract class to Elsa.Common module This new abstract class implements the IBackgroundTask interface with default methods for executing, starting, and stopping tasks asynchronously. It provides a basic framework for background task management in the Elsa.Common module. * Switch to CreateAsyncScope in DefaultTenantScopeFactory Updated the CreateScope method to use CreateAsyncScope instead of CreateScope. This change improves asynchronous handling of service scopes within the DefaultTenantScopeFactory class. * Add tenant handling and move StartWorkers background task Introduce ITenantAccessor in Worker class for multitenancy support. Rename and relocate StartWorkers service to BackgroundTask, ensuring smoother workflow initialization. Also, update the configuration to support Azure Service Bus connection string. * Add tenant support and refactor ProtoActor client Integrated ITenantAccessor in ProtoActorWorkflowClient class to handle multi-tenancy. Refactored methods in the client to support custom headers and added async disposable pattern in various services for proper resource management. Additionally, enabled Azure Service Bus and updated related documentation. * Add support for custom headers in ProtoActor grain methods Introduced a T4 template to generate grain methods with custom headers, enabling the use of tenant ID in requests. Updated `ProtoActorWorkflowClient` to employ these methods, removing redundant code and directly utilizing the client for various workflow operations. * Add tenant middleware to MassTransit configurations Introduced multitenancy middleware for MassTransit message handling. Added new message type `OrderReceived` and updated RabbitMQ setup in Elsa Server. Applied middleware to configure tenant data on send, publish, and consume operations. * Add new product workflow and streamline ID handling Introduced a new `RequestResponseWorkflow` for handling product requests. Simplified ID handling in `WorkflowBuilder` and `ClrWorkflowsProvider` by defaulting to empty strings and adding a version prefix. Enhanced `HttpWorkflowsMiddleware` to correctly parse full request paths. * Remove redundant files and update configuration Deleted unused files `Product.cs` and `RequestResponseWorkflow.cs` to clean up the codebase. Updated `Program.cs` configuration: switched MassTransitBroker to Memory and disabled multitenancy. * Remove MultitenantRecurringTaskService and update AzureServiceBus Removed `MultitenantRecurringTaskService` and adjusted related code for Azure Service Bus to work without it. This includes removal of tenant accessor dependency from `Worker` and cleanup of service configuration flags in `Program.cs`. * Increase signal wait timeout to 10000 milliseconds. Extended the default timeout for signal awaiting methods from 8000 to 10000 milliseconds. This change ensures more flexible and resilient waiting periods, reducing timeout occurrences in scenarios with longer processing times. * Refactor scheduling service to be a background task Renamed `CreateSchedulesHostedService` to `CreateSchedulesBackgroundTask` and refactored it to inherit from `BackgroundTask` instead of `BackgroundService`. Simplified the constructor by injecting the required dependencies directly, eliminating the need for a scoped factory. * Refactor workflow version suffix formatting Changed the version suffix format from `:v{version}` to `v{version}` and adjusted the ID concatenation accordingly. This improves consistency and readability of workflow IDs. * Enable multitenancy support in Quartz scheduler Added `TenantJobListener` to inject tenant context into jobs. Modified `QuartzWorkflowScheduler` to incorporate tenant IDs into job data maps and adjusted the configuration to acknowledge multitenancy settings. * Remove ConfigureSchedulerHostedService and TenantJobListener Consolidated tenant resolution logic into JobExecutionExtensions class. Updated ResumeWorkflowJob and RunWorkflowJob to use the new extension method for tenant retrieval. This simplifies the QuartzSchedulerFeature setup by removing the hosted service configuration. * Refactor HTTP feature and update route table task Move 'UpdateRouteTableStartupTask' from 'HostedServices' to 'Tasks' and update dependency injection configurations accordingly. Simplify 'DefaultRouteTableUpdater' by removing unnecessary options and tenant-agnostic settings from filters. * Disable multitenancy in Program.cs The useMultitenancy flag has been changed from true to false. This update affects the Elsa.Server.Web application configuration. * Simplify variable usage in HttpWorkflowsMiddleware Replaced 'fullPath' variable with 'path' to streamline code. This change enhances readability by reducing redundancy and ensures consistency in variable naming throughout the method. * Enable multitenancy and refactor tenant handling logic Enable multitenancy in the application and refactor tenant handling logic to use ITenantFinder and ITenantContextInitializer interfaces. Added header constants, updated middleware to use these interfaces, and moved extension methods to the appropriate namespace. * Add input validation to user registration form Implemented checks to ensure all required fields are filled and that input data adheres to format requirements. This change reduces errors and enhances form reliability. * Remove unused import from TenantPrefixHttpEndpointRoutesProvider This change cleans up the code by removing an unnecessary import statement. It improves code readability and reduces clutter, making future maintenance easier. The functionality remains unchanged. * Rename filter scope to "tenantPublish" in Probe method Updated the Probe method in TenantPublishMiddleware.cs to use "tenantPublish" instead of "tenantSend" for better clarity. Ensures consistency with the method's context and aligns with naming conventions. * Refactor: Remove extraneous whitespace Eliminate unnecessary whitespace in ProtoActorWorkflowClient.cs for cleaner code. This change helps maintain consistent formatting and improves readability. * Refactor DefaultRegistriesPopulator for cleaner initialization Converted constructor to use read-only fields directly, removing unnecessary instance variables. This change simplifies the code by reducing redundancy and making the constructor cleaner.
2024-10-28 18:38:24 +00:00
using Elsa.Http.Tasks;
using Elsa.Http.TriggerPayloadValidators;
Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2023-12-26 17:56:29 +00:00
using Elsa.Http.UIHints;
Add IResilienceStrategy Abstraction with Category Matching and Expression-Based Configuration (#6637) * Add resilience module with core interfaces and services Introduced a new `Elsa.Resilience` module and its core components to support resilient services and activities. This includes resilience strategies, providers, and attributes, along with integration into the existing HTTP module for enhanced fault tolerance. Added solution and project references for proper dependency management. * Add resilience strategy framework with HTTP strategy support Introduced a resilience strategy architecture, including a configurable `HttpResilienceStrategy` with retry capabilities, strategy serialization, and integration with existing modules. Enhanced ResilienceFeature to support registration of strategy types and updated application configuration to enable resilience strategies. This change ensures more robust and fault-tolerant HTTP request handling. * Add JSON serialization support for resilience configuration Introduced `ConfigurationExtensions` to enable JSON serialization of configuration sections. Updated resilience strategies to utilize the new extension methods and adjusted JSON serialization logic to support polymorphism with `$type` discriminator. Minor modifications were made to support deserialization and property mutability. * Add resilience strategy support to workflows and API clients Introduced resilience strategy configuration, serialization, and execution support across workflows and API clients. Added new APIs, models, and services to enhance fault tolerance capabilities for activities and HTTP interactions. * Refactor resilience services for improved modularity. Replaced `IResilienceService` with new modular interfaces (`IResilienceStrategyCatalog`, `IResilienceStrategyConfigEvaluator`, `IResilientActivityInvoker`) and corresponding implementations. Enhanced maintainability by simplifying components and responsibilities, ensuring better separation of concerns. * Rename methods in ResilienceStrategyCatalog for clarity Updated method names in `ResilienceStrategyCatalog` and its interfaces for better readability and alignment with naming conventions. Replaced `GetAllStrategiesAsync` with `ListAsync` and `GetStrategyAsync` with `GetAsync` across the codebase. * Refactor resilience handling in HTTP activities. Replaced `ResilienceCategory` property with `ResilienceCategoryAttribute` for a cleaner implementation. Updated `IResilientActivity` to simplify its interface and adjusted related modifications accordingly. Introduced `IResilientActivityInvoker` to enhance resilience strategy execution. * Add support for additional resilience and scripting features Extended resilience strategy handling with serialization support, added `HttpResilienceStrategy` type in JavaScript handler, and refined object conversion logic for interfaces. Minor adjustments to `Expression` class properties for consistency. * Remove `UseResilience` call from Program.cs This call was redundant and no longer necessary for the application. Its removal simplifies the code and ensures only required middleware is used. * Remove commented-out JSON converter code in serializer setup Cleaned up unused and commented-out converter initialization code in `ResilienceStrategySerializer`. This improves readability and removes unnecessary clutter from the file. * Fix typo in method names from 'Resiliency' to 'Resilience' Renamed methods to maintain consistency in naming conventions across the codebase. This change ensures clarity and alignment with established terminology. * Refactor namespace for ConfigurationResilienceStrategySource Updated the namespace of ConfigurationResilienceStrategySource to "StrategySources" for better alignment with naming conventions and structure. Removed an unused namespace reference in ResilienceFeature for cleanup. * Mark EnableResiliency as obsolete in SendHttpRequestBase. The EnableResiliency property is now marked with the [Obsolete] attribute. Developers are encouraged to use the common Resilience Strategy setting instead for managing HTTP request resiliency. This change ensures better consistency and alignment with the broader resilience strategy. * Restrict ResilienceCategoryAttribute to class targets only Removed support for using ResilienceCategoryAttribute on properties. This change enforces a stricter and more focused usage of the attribute, ensuring it applies only to class-level declarations. * Add documentation for IResilientActivityInvoker interface Include summaries and parameter descriptions for the `InvokeAsync` method. This improves code clarity and helps developers understand the functionality and usage of the resilient activity invocation process. * Fix logical operator precedence in type comparison check Parentheses were added to ensure correct evaluation of conditions when checking type compatibility. This prevents potential logical errors when determining the target type in object conversions. * Add support for resilience source identification Introduce the `ResilienceSourceNameAttribute` to allow naming of resilience sources. Updated `ResilienceStrategyCatalog` to utilize the attribute for prefixing strategy IDs, improving source identification and traceability. Applied the attribute to `ConfigurationResilienceStrategySource` as an example. * Revert "Add support for resilience source identification" This reverts commit 19b4e7121d6330b5de4f692b78da4c1e4a2d1f67. * Reapply "Add support for resilience source identification" This reverts commit 8bcba9d040c4eb247077aec6d90dc02817adcbd5. * Revert "Reapply "Add support for resilience source identification"" This reverts commit ee04d35e7930956c752dda3ed150ca34a535e66c.
2025-05-12 08:09:04 +00:00
using Elsa.Resilience.Extensions;
using Elsa.Resilience.Features;
using Elsa.Workflows;
Refactor: Overhauls workflow JSON type serialization (#7549) * Avoid null endpoint DTO metadata in tests * Enforce console logs hub read permission * Remove unused console logs hub import * Support mapped endpoint metadata in auth tests * Reduce console log capture throughput impact * Address Copilot console logs review * Refactor task scheduling to support tenant-level background work and enhance logging functionality. * Introduce ConsoleStreamHook for stdout/stderr tee and enhance logging validation. Adjust test cases and startup warnings for distributed lock provider usage. * Refactor console logging pipeline with capture optimization and new ConsoleLogsHost; update tests accordingly. * Add Ansi SGR parser for console logs and associated unit tests * Remove ANSI color renderings and parsers; integrate ConsoleLogScopeAccessor for improved logging context with workflow instance ID support. * Address console logs code quality feedback * Address PR review feedback * Preserve console logs extension points * Stabilize console logs host lifecycle * Address final automated review comments * Tighten console log capture shutdown * Address console log review feedback * Address follow-up review feedback * Cover final review feedback * Avoid recursive console provider initialization * Guard console host lease shutdown * Preserve console log scope and provider lifetime * Correlate console log scope fallback * Tighten console scope correlation * Expose host services during provider construction * Redact ANSI-normalized console lines * Remove `ConsoleCaptureTee` and related services and tests * Use pipeline contributors for console log context * Update CShells package versions to 0.0.24-preview.132 * Filter live console logs by workflow instance * Enhance console logging with activity execution metadata and extend test coverage. * Address console logs stream consumption comment * Add diagnostics OpenTelemetry backend * Introduce dedicated workflow JSON type registry and hardening This change addresses GitHub issue #7541 by establishing a separate type registry (`IWorkflowJsonTypeRegistry`) for workflow JSON serialization. This decouples workflow type resolution from expression type aliases, enforcing a strict trust boundary. Key aspects: - New workflow JSON emits preferred aliases for registered types. - Existing persisted workflows can be loaded via registered legacy names. - Unknown, abstract, interface, open generic, or inappropriate collection types are rejected during deserialization, enhancing security. - Public APIs (e.g., incident strategies) now expose consistent workflow JSON type identifiers. This ensures secure, predictable, and backward-compatible handling of types within workflow definitions and payloads. * Remove unused project references and streamline console log endpoint * Move serialization type aliases to Elsa.Common * Update serialization integration fixtures for aliases * Stabilize missing rate limiter policy test
2026-05-31 09:09:39 +00:00
using Elsa.Workflows.Options;
using FluentStorage;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
Refactor: Overhauls workflow JSON type serialization (#7549) * Avoid null endpoint DTO metadata in tests * Enforce console logs hub read permission * Remove unused console logs hub import * Support mapped endpoint metadata in auth tests * Reduce console log capture throughput impact * Address Copilot console logs review * Refactor task scheduling to support tenant-level background work and enhance logging functionality. * Introduce ConsoleStreamHook for stdout/stderr tee and enhance logging validation. Adjust test cases and startup warnings for distributed lock provider usage. * Refactor console logging pipeline with capture optimization and new ConsoleLogsHost; update tests accordingly. * Add Ansi SGR parser for console logs and associated unit tests * Remove ANSI color renderings and parsers; integrate ConsoleLogScopeAccessor for improved logging context with workflow instance ID support. * Address console logs code quality feedback * Address PR review feedback * Preserve console logs extension points * Stabilize console logs host lifecycle * Address final automated review comments * Tighten console log capture shutdown * Address console log review feedback * Address follow-up review feedback * Cover final review feedback * Avoid recursive console provider initialization * Guard console host lease shutdown * Preserve console log scope and provider lifetime * Correlate console log scope fallback * Tighten console scope correlation * Expose host services during provider construction * Redact ANSI-normalized console lines * Remove `ConsoleCaptureTee` and related services and tests * Use pipeline contributors for console log context * Update CShells package versions to 0.0.24-preview.132 * Filter live console logs by workflow instance * Enhance console logging with activity execution metadata and extend test coverage. * Address console logs stream consumption comment * Add diagnostics OpenTelemetry backend * Introduce dedicated workflow JSON type registry and hardening This change addresses GitHub issue #7541 by establishing a separate type registry (`IWorkflowJsonTypeRegistry`) for workflow JSON serialization. This decouples workflow type resolution from expression type aliases, enforcing a strict trust boundary. Key aspects: - New workflow JSON emits preferred aliases for registered types. - Existing persisted workflows can be loaded via registered legacy names. - Unknown, abstract, interface, open generic, or inappropriate collection types are rejected during deserialization, enhancing security. - Public APIs (e.g., incident strategies) now expose consistent workflow JSON type identifiers. This ensures secure, predictable, and backward-compatible handling of types within workflow definitions and payloads. * Remove unused project references and streamline console log endpoint * Move serialization type aliases to Elsa.Common * Update serialization integration fixtures for aliases * Stabilize missing rate limiter policy test
2026-05-31 09:09:39 +00:00
using Elsa.Common.Serialization;
namespace Elsa.Http.Features;
2023-02-15 11:09:45 +00:00
/// <summary>
/// Installs services related to HTTP services and activities.
/// </summary>
Fix WorkflowActivity to Use Cached Workflow Definitions for Consistent Behavior (#5223) * Replace IServiceScopeFactory with IServiceProvider in WorkflowRunner Unused dependencies were removed from the workflow runner service. The IServiceScopeFactory was replaced with IServiceProvider to better handle the creation and deletion of service scopes, resulting in cleaner code with less manual scope management. Microsoft.Extensions.DependencyInjection and System.Diagnostics.CodeAnalysis were removed as they were no longer necessary. * Refactor WorkflowDefinitionActivity to use WorkflowDefinitionService The WorkflowDefinitionActivity class has been refactored to make use of the WorkflowDefinitionService instead of the WorkflowDefinitionStore. This fixes #5222 by ensuring the same activity instances are used in the graph model of the workflow execution context. * Add workflow filtering and caching functionality Added methods to `WorkflowDefinitionService` to find workflow definitions and workflows using filter criteria. A key generation method for caching filtered workflows was also added to `WorkflowDefinitionCacheManager`. The implementation includes generating a hash of the filter parameters and using this hash as a cache key, providing efficient caching functionality for filtered searches. * Refactor TriggerIndexer to handle only ITrigger activities The code in TriggerIndexer has been refactored to deal specifically with ITrigger activities, streamlining its behavior. Removed code related to handling non-ITrigger activities and simplified the workflow creation process. The extraction of "startable" nodes now directly filters and casts to ITrigger, reducing complexity and increasing readability. * Update caching service to support filter-based search The CachingWorkflowDefinitionService has been updated to support workflow definition and workflow search based on filter criteria. The update also includes change of class scope from public to internal. Further, it resolves the missing reference by switching from Elsa.Caching.Contracts to Elsa.Caching. * Optimize Elsa project imports and use explicit cache variable names This commit removes superfluous import references, relocates the 'IChangeTokenSignaler' contract into the 'Elsa.Caching' namespace, and replaces ambiguous 'cache' variable names with more explicit 'memoryCache' across several files. Additionally, new package references have been added and access modifiers have been changed to improve encapsulation. Cleanup enhances readability and maintainability of the codebase. * Add .DotSettings file to Elsa.Caching module A new .DotSettings file has been added to the Elsa.Caching module. This file is used for namespace configuration, specifically to skip the "contracts" folder in code inspections. * Update workflow interfaces to support filter queries The update extends `IWorkflowDefinitionCacheManager` and `IWorkflowDefinitionService` interfaces. Functions are added to allow creating filter cache keys and finding workflow definitions and workflows using a new `WorkflowDefinitionFilter`. This enhances querying flexibility by enabling filtered searches. * Add WorkflowDefinitionVersionId to WorkflowTriggerEqualityComparer A new property, WorkflowDefinitionVersionId, has been added to the object being serialized in WorkflowTriggerEqualityComparer. This change allows for a more accurate comparison between workflow triggers, considering not just the workflow definition ID but also its version. * Update service registration types in WorkflowsFeature Changed the registration type for both IHasher and IBookmarkHasher services from Scoped to Singleton in the workflows feature configuration. This alteration aims to improve application performance and manage service lifetimes more efficiently. * Remove Open.Linq.AsyncExtensions dependency The Open.Linq.AsyncExtensions package reference was removed across the project. The usage within the CachingWorkflowDefinitionStore was updated accordingly to maintain functionality. * Move System.Linq.Dynamic.Core package reference The System.Linq.Dynamic.Core package reference was moved from the Directory.Build.props file to the Elsa.Workflows.Management.csproj file. This change reflects the specific dependency of the Elsa.Workflows.Management module on System.Linq.Dynamic.Core, without impacting other modules. * Implement caching for HTTP workflows This update introduces caching mechanisms for HTTP workflows, which significantly improves their performance. The changes involve creating a `CacheManager` and `CachingHttpWorkflowLookupService`, and modifying some existing components to use the new caching mechanism. Additionally, the `HttpWorkflowsCacheManager` was renamed to `HttpWorkflowsCacheInvalidationManager` to better reflect its role. * Refactor cache management across modules This commit refactor the cache management across various modules. The 'ICacheManager' interface now includes methods for triggering and getting change tokens, and the 'HttpWorkflowsCacheInvalidationManager' has been renamed to 'HttpWorkflowsCacheManager'. The caching functionality in 'WorkflowDefinitionService' and other similar services have been updated to use these new methods, improving consistency and maintainability. * Enable caching in Elsa.Server.Web The "useCaching" variable has been set to true to enable caching. Simultaneously, the method name "UseCachingStores" has been refactored to "UseCache". Conditional statements have been added to check the "useCaching" variable before invoking caching. * Rename method UseCaching to UseCache In the Elsa.Server.Web and Elsa.Http project files, the method UseCaching has been renamed to UseCache. This modification is aimed at bridging naming inconsistencies and maintaining naming standards across the application. * Update HttpCacheFeature class description The class summary for HttpCacheFeature has been revised. Originally, it stated that the class was used for installing services related to HTTP services and activities, but it actually focuses more on HTTP caching. * Remove unused Configure method from HttpCacheFeature The Configure method in HttpCacheFeature was found to be redundant as it wasn't doing any significant work or contributing to any functionality. It has therefore been removed to clean up the code and avoid confusion. * Add 'bug/*' to workflow triggers This commit includes 'bug/*' to the list of triggers in our GitHub Actions workflow. Now, any push or pull request under a 'bug/*' branch will trigger the workflow.
2024-04-15 08:06:27 +00:00
[DependsOn(typeof(HttpJavaScriptFeature))]
Add IResilienceStrategy Abstraction with Category Matching and Expression-Based Configuration (#6637) * Add resilience module with core interfaces and services Introduced a new `Elsa.Resilience` module and its core components to support resilient services and activities. This includes resilience strategies, providers, and attributes, along with integration into the existing HTTP module for enhanced fault tolerance. Added solution and project references for proper dependency management. * Add resilience strategy framework with HTTP strategy support Introduced a resilience strategy architecture, including a configurable `HttpResilienceStrategy` with retry capabilities, strategy serialization, and integration with existing modules. Enhanced ResilienceFeature to support registration of strategy types and updated application configuration to enable resilience strategies. This change ensures more robust and fault-tolerant HTTP request handling. * Add JSON serialization support for resilience configuration Introduced `ConfigurationExtensions` to enable JSON serialization of configuration sections. Updated resilience strategies to utilize the new extension methods and adjusted JSON serialization logic to support polymorphism with `$type` discriminator. Minor modifications were made to support deserialization and property mutability. * Add resilience strategy support to workflows and API clients Introduced resilience strategy configuration, serialization, and execution support across workflows and API clients. Added new APIs, models, and services to enhance fault tolerance capabilities for activities and HTTP interactions. * Refactor resilience services for improved modularity. Replaced `IResilienceService` with new modular interfaces (`IResilienceStrategyCatalog`, `IResilienceStrategyConfigEvaluator`, `IResilientActivityInvoker`) and corresponding implementations. Enhanced maintainability by simplifying components and responsibilities, ensuring better separation of concerns. * Rename methods in ResilienceStrategyCatalog for clarity Updated method names in `ResilienceStrategyCatalog` and its interfaces for better readability and alignment with naming conventions. Replaced `GetAllStrategiesAsync` with `ListAsync` and `GetStrategyAsync` with `GetAsync` across the codebase. * Refactor resilience handling in HTTP activities. Replaced `ResilienceCategory` property with `ResilienceCategoryAttribute` for a cleaner implementation. Updated `IResilientActivity` to simplify its interface and adjusted related modifications accordingly. Introduced `IResilientActivityInvoker` to enhance resilience strategy execution. * Add support for additional resilience and scripting features Extended resilience strategy handling with serialization support, added `HttpResilienceStrategy` type in JavaScript handler, and refined object conversion logic for interfaces. Minor adjustments to `Expression` class properties for consistency. * Remove `UseResilience` call from Program.cs This call was redundant and no longer necessary for the application. Its removal simplifies the code and ensures only required middleware is used. * Remove commented-out JSON converter code in serializer setup Cleaned up unused and commented-out converter initialization code in `ResilienceStrategySerializer`. This improves readability and removes unnecessary clutter from the file. * Fix typo in method names from 'Resiliency' to 'Resilience' Renamed methods to maintain consistency in naming conventions across the codebase. This change ensures clarity and alignment with established terminology. * Refactor namespace for ConfigurationResilienceStrategySource Updated the namespace of ConfigurationResilienceStrategySource to "StrategySources" for better alignment with naming conventions and structure. Removed an unused namespace reference in ResilienceFeature for cleanup. * Mark EnableResiliency as obsolete in SendHttpRequestBase. The EnableResiliency property is now marked with the [Obsolete] attribute. Developers are encouraged to use the common Resilience Strategy setting instead for managing HTTP request resiliency. This change ensures better consistency and alignment with the broader resilience strategy. * Restrict ResilienceCategoryAttribute to class targets only Removed support for using ResilienceCategoryAttribute on properties. This change enforces a stricter and more focused usage of the attribute, ensuring it applies only to class-level declarations. * Add documentation for IResilientActivityInvoker interface Include summaries and parameter descriptions for the `InvokeAsync` method. This improves code clarity and helps developers understand the functionality and usage of the resilient activity invocation process. * Fix logical operator precedence in type comparison check Parentheses were added to ensure correct evaluation of conditions when checking type compatibility. This prevents potential logical errors when determining the target type in object conversions. * Add support for resilience source identification Introduce the `ResilienceSourceNameAttribute` to allow naming of resilience sources. Updated `ResilienceStrategyCatalog` to utilize the attribute for prefixing strategy IDs, improving source identification and traceability. Applied the attribute to `ConfigurationResilienceStrategySource` as an example. * Revert "Add support for resilience source identification" This reverts commit 19b4e7121d6330b5de4f692b78da4c1e4a2d1f67. * Reapply "Add support for resilience source identification" This reverts commit 8bcba9d040c4eb247077aec6d90dc02817adcbd5. * Revert "Reapply "Add support for resilience source identification"" This reverts commit ee04d35e7930956c752dda3ed150ca34a535e66c.
2025-05-12 08:09:04 +00:00
[DependsOn(typeof(ResilienceFeature))]
Implement multitenant HTTP routing (#6031) * Add tenant awareness to bookmark handling and route resolution Added tenant ID support across various components, including bookmark updates, route resolution, and middleware processing. This ensures that bookmark and route operations can now appropriately handle tenant-specific data, improving the system's multitenancy capabilities. * Add Multitenant HTTP Routing feature to Tenants module Introduced a new MultitenantHttpRoutingFeature class to the Elsa.Tenants.AspNetCore module, enhancing the tenant resolution capabilities. Moved RoutePrefixTenantResolver from Elsa.Http to Elsa.Tenants.AspNetCore and updated relevant project references and namespaces accordingly. This refactor improves modularity and separation of concerns between HTTP and tenancy features. * Refactor route handling and tenant configuration Removed redundant `RouteTableExtensions` and replaced with new route providers and updaters, enhancing flexibility and modularity. Introduced tenant-specific HTTP endpoint configurations for better customization and configuration management. * Rename HttpEndpointBookmarkStimulus to HttpEndpointBookmarkPayload Refactor various classes and methods to reflect the renaming from `HttpEndpointBookmarkStimulus` to `HttpEndpointBookmarkPayload`. Add and configure new extension methods for tenant route handling, update the route provider to support multi-tenancy, and adjust the tenants provider to bind configuration properly. * Add HeaderTenantResolver and refactor Http namespace. Introduce HeaderTenantResolver to resolve tenants via HTTP headers. Refactor multiple classes and interfaces to move from the Elsa.Http.Models namespace directly into Elsa.Http for clarity and consistency. * Add Host-based tenant resolution Implemented a HostTenantResolver to resolve tenants based on the request's host and updated tenant configurations with host information. Modified the tenant resolver pipeline and added the new host resolver to the service registrations. * Add tenant-aware caching and accessor support Enhanced caching by incorporating tenant identifiers into cache keys for more granular cache management. Introduced ITenantAccessor dependencies in various services to retrieve the current tenant information. This ensures that cache entries are correctly isolated per tenant. * Reorder tenant resolvers for pipeline setup. Reordered the tenant resolvers in the pipeline to prioritize HostTenantResolver before RoutePrefixTenantResolver. This ensures that tenant resolution is correctly aligned with host-based resolving before checking the route prefix. * Remove unused imports This commit eliminates redundant `using` directives across multiple files to streamline the codebase. This cleanup helps improve code readability and maintainability by removing unnecessary dependencies.
2024-10-14 19:27:11 +00:00
public class HttpFeature(IModule module) : FeatureBase(module)
{
Implement multitenant HTTP routing (#6031) * Add tenant awareness to bookmark handling and route resolution Added tenant ID support across various components, including bookmark updates, route resolution, and middleware processing. This ensures that bookmark and route operations can now appropriately handle tenant-specific data, improving the system's multitenancy capabilities. * Add Multitenant HTTP Routing feature to Tenants module Introduced a new MultitenantHttpRoutingFeature class to the Elsa.Tenants.AspNetCore module, enhancing the tenant resolution capabilities. Moved RoutePrefixTenantResolver from Elsa.Http to Elsa.Tenants.AspNetCore and updated relevant project references and namespaces accordingly. This refactor improves modularity and separation of concerns between HTTP and tenancy features. * Refactor route handling and tenant configuration Removed redundant `RouteTableExtensions` and replaced with new route providers and updaters, enhancing flexibility and modularity. Introduced tenant-specific HTTP endpoint configurations for better customization and configuration management. * Rename HttpEndpointBookmarkStimulus to HttpEndpointBookmarkPayload Refactor various classes and methods to reflect the renaming from `HttpEndpointBookmarkStimulus` to `HttpEndpointBookmarkPayload`. Add and configure new extension methods for tenant route handling, update the route provider to support multi-tenancy, and adjust the tenants provider to bind configuration properly. * Add HeaderTenantResolver and refactor Http namespace. Introduce HeaderTenantResolver to resolve tenants via HTTP headers. Refactor multiple classes and interfaces to move from the Elsa.Http.Models namespace directly into Elsa.Http for clarity and consistency. * Add Host-based tenant resolution Implemented a HostTenantResolver to resolve tenants based on the request's host and updated tenant configurations with host information. Modified the tenant resolver pipeline and added the new host resolver to the service registrations. * Add tenant-aware caching and accessor support Enhanced caching by incorporating tenant identifiers into cache keys for more granular cache management. Introduced ITenantAccessor dependencies in various services to retrieve the current tenant information. This ensures that cache entries are correctly isolated per tenant. * Reorder tenant resolvers for pipeline setup. Reordered the tenant resolvers in the pipeline to prioritize HostTenantResolver before RoutePrefixTenantResolver. This ensures that tenant resolution is correctly aligned with host-based resolving before checking the route prefix. * Remove unused imports This commit eliminates redundant `using` directives across multiple files to streamline the codebase. This cleanup helps improve code readability and maintainability by removing unnecessary dependencies.
2024-10-14 19:27:11 +00:00
private Func<IServiceProvider, IHttpEndpointRoutesProvider> _httpEndpointRouteProvider = sp => sp.GetRequiredService<DefaultHttpEndpointRoutesProvider>();
private Func<IServiceProvider, IHttpEndpointBasePathProvider> _httpEndpointBasePathProvider = sp => sp.GetRequiredService<DefaultHttpEndpointBasePathProvider>();
/// <summary>
/// A delegate to configure <see cref="HttpActivityOptions"/>.
/// </summary>
public Action<HttpActivityOptions>? ConfigureHttpOptions { get; set; }
/// <summary>
/// A delegate to configure <see cref="HttpFileCacheOptions"/>.
/// </summary>
public Action<HttpFileCacheOptions>? ConfigureHttpFileCacheOptions { get; set; }
2023-02-15 11:09:45 +00:00
/// <summary>
/// A delegate that is invoked when authorizing an inbound HTTP request.
/// </summary>
public Func<IServiceProvider, IHttpEndpointAuthorizationHandler> HttpEndpointAuthorizationHandler { get; set; } = sp => sp.GetRequiredService<AuthenticationBasedHttpEndpointAuthorizationHandler>();
2023-02-15 11:09:45 +00:00
/// <summary>
/// A delegate that is invoked when an HTTP workflow faults.
2023-02-15 11:09:45 +00:00
/// </summary>
public Func<IServiceProvider, IHttpEndpointFaultHandler> HttpEndpointWorkflowFaultHandler { get; set; } = sp => sp.GetRequiredService<DefaultHttpEndpointFaultHandler>();
/// <summary>
/// A delegate to configure the <see cref="IContentTypeProvider"/>.
/// </summary>
public Func<IServiceProvider, IContentTypeProvider> ContentTypeProvider { get; set; } = _ => new FileExtensionContentTypeProvider();
/// <summary>
/// A delegate to configure the <see cref="IFileCacheStorageProvider"/>.
/// </summary>
public Func<IServiceProvider, IFileCacheStorageProvider> FileCache { get; set; } = sp =>
{
var options = sp.GetRequiredService<IOptions<HttpFileCacheOptions>>().Value;
var blobStorage = StorageFactory.Blobs.DirectoryFiles(options.LocalCacheDirectory);
return new BlobFileCacheStorageProvider(blobStorage);
};
/// <summary>
/// A delegate to configure the <see cref="HttpClient"/> used when by the <see cref="FlowSendHttpRequest"/> and <see cref="SendHttpRequest"/> activities.
/// </summary>
public Action<IServiceProvider, HttpClient> HttpClient { get; set; } = (_, _) => { };
/// <summary>
/// A delegate to configure the <see cref="HttpClientBuilder"/> for <see cref="HttpClient"/>.
/// </summary>
public Action<IHttpClientBuilder> HttpClientBuilder { get; set; } = _ => { };
/// <summary>
/// A list of <see cref="IHttpCorrelationIdSelector"/> types to register with the service collection.
/// </summary>
public ICollection<Type> HttpCorrelationIdSelectorTypes { get; } = new List<Type>
{
typeof(HeaderHttpCorrelationIdSelector),
typeof(QueryStringHttpCorrelationIdSelector)
};
/// <summary>
/// A list of <see cref="IHttpWorkflowInstanceIdSelector"/> types to register with the service collection.
/// </summary>
public ICollection<Type> HttpWorkflowInstanceIdSelectorTypes { get; } = new List<Type>
{
typeof(HeaderHttpWorkflowInstanceIdSelector),
typeof(QueryStringHttpWorkflowInstanceIdSelector)
};
Implement multitenant HTTP routing (#6031) * Add tenant awareness to bookmark handling and route resolution Added tenant ID support across various components, including bookmark updates, route resolution, and middleware processing. This ensures that bookmark and route operations can now appropriately handle tenant-specific data, improving the system's multitenancy capabilities. * Add Multitenant HTTP Routing feature to Tenants module Introduced a new MultitenantHttpRoutingFeature class to the Elsa.Tenants.AspNetCore module, enhancing the tenant resolution capabilities. Moved RoutePrefixTenantResolver from Elsa.Http to Elsa.Tenants.AspNetCore and updated relevant project references and namespaces accordingly. This refactor improves modularity and separation of concerns between HTTP and tenancy features. * Refactor route handling and tenant configuration Removed redundant `RouteTableExtensions` and replaced with new route providers and updaters, enhancing flexibility and modularity. Introduced tenant-specific HTTP endpoint configurations for better customization and configuration management. * Rename HttpEndpointBookmarkStimulus to HttpEndpointBookmarkPayload Refactor various classes and methods to reflect the renaming from `HttpEndpointBookmarkStimulus` to `HttpEndpointBookmarkPayload`. Add and configure new extension methods for tenant route handling, update the route provider to support multi-tenancy, and adjust the tenants provider to bind configuration properly. * Add HeaderTenantResolver and refactor Http namespace. Introduce HeaderTenantResolver to resolve tenants via HTTP headers. Refactor multiple classes and interfaces to move from the Elsa.Http.Models namespace directly into Elsa.Http for clarity and consistency. * Add Host-based tenant resolution Implemented a HostTenantResolver to resolve tenants based on the request's host and updated tenant configurations with host information. Modified the tenant resolver pipeline and added the new host resolver to the service registrations. * Add tenant-aware caching and accessor support Enhanced caching by incorporating tenant identifiers into cache keys for more granular cache management. Introduced ITenantAccessor dependencies in various services to retrieve the current tenant information. This ensures that cache entries are correctly isolated per tenant. * Reorder tenant resolvers for pipeline setup. Reordered the tenant resolvers in the pipeline to prioritize HostTenantResolver before RoutePrefixTenantResolver. This ensures that tenant resolution is correctly aligned with host-based resolving before checking the route prefix. * Remove unused imports This commit eliminates redundant `using` directives across multiple files to streamline the codebase. This cleanup helps improve code readability and maintainability by removing unnecessary dependencies.
2024-10-14 19:27:11 +00:00
public HttpFeature WithHttpEndpointRoutesProvider<T>() where T : IHttpEndpointRoutesProvider
{
return WithHttpEndpointRoutesProvider(sp => sp.GetRequiredService<T>());
}
public HttpFeature WithHttpEndpointRoutesProvider(Func<IServiceProvider, IHttpEndpointRoutesProvider> httpEndpointRouteProvider)
{
_httpEndpointRouteProvider = httpEndpointRouteProvider;
return this;
}
public HttpFeature WithHttpEndpointBasePathProvider<T>() where T : class, IHttpEndpointBasePathProvider
{
Services.TryAddScoped<T>();
return WithHttpEndpointBasePathProvider(sp => sp.GetRequiredService<T>());
}
public HttpFeature WithHttpEndpointBasePathProvider(Func<IServiceProvider, IHttpEndpointBasePathProvider> httpEndpointBasePathProvider)
{
_httpEndpointBasePathProvider = httpEndpointBasePathProvider;
return this;
}
Implement multitenant HTTP routing (#6031) * Add tenant awareness to bookmark handling and route resolution Added tenant ID support across various components, including bookmark updates, route resolution, and middleware processing. This ensures that bookmark and route operations can now appropriately handle tenant-specific data, improving the system's multitenancy capabilities. * Add Multitenant HTTP Routing feature to Tenants module Introduced a new MultitenantHttpRoutingFeature class to the Elsa.Tenants.AspNetCore module, enhancing the tenant resolution capabilities. Moved RoutePrefixTenantResolver from Elsa.Http to Elsa.Tenants.AspNetCore and updated relevant project references and namespaces accordingly. This refactor improves modularity and separation of concerns between HTTP and tenancy features. * Refactor route handling and tenant configuration Removed redundant `RouteTableExtensions` and replaced with new route providers and updaters, enhancing flexibility and modularity. Introduced tenant-specific HTTP endpoint configurations for better customization and configuration management. * Rename HttpEndpointBookmarkStimulus to HttpEndpointBookmarkPayload Refactor various classes and methods to reflect the renaming from `HttpEndpointBookmarkStimulus` to `HttpEndpointBookmarkPayload`. Add and configure new extension methods for tenant route handling, update the route provider to support multi-tenancy, and adjust the tenants provider to bind configuration properly. * Add HeaderTenantResolver and refactor Http namespace. Introduce HeaderTenantResolver to resolve tenants via HTTP headers. Refactor multiple classes and interfaces to move from the Elsa.Http.Models namespace directly into Elsa.Http for clarity and consistency. * Add Host-based tenant resolution Implemented a HostTenantResolver to resolve tenants based on the request's host and updated tenant configurations with host information. Modified the tenant resolver pipeline and added the new host resolver to the service registrations. * Add tenant-aware caching and accessor support Enhanced caching by incorporating tenant identifiers into cache keys for more granular cache management. Introduced ITenantAccessor dependencies in various services to retrieve the current tenant information. This ensures that cache entries are correctly isolated per tenant. * Reorder tenant resolvers for pipeline setup. Reordered the tenant resolvers in the pipeline to prioritize HostTenantResolver before RoutePrefixTenantResolver. This ensures that tenant resolution is correctly aligned with host-based resolving before checking the route prefix. * Remove unused imports This commit eliminates redundant `using` directives across multiple files to streamline the codebase. This cleanup helps improve code readability and maintainability by removing unnecessary dependencies.
2024-10-14 19:27:11 +00:00
/// <inheritdoc />
public override void Configure()
{
Module.UseWorkflowManagement(management =>
{
Implement multitenant HTTP routing (#6031) * Add tenant awareness to bookmark handling and route resolution Added tenant ID support across various components, including bookmark updates, route resolution, and middleware processing. This ensures that bookmark and route operations can now appropriately handle tenant-specific data, improving the system's multitenancy capabilities. * Add Multitenant HTTP Routing feature to Tenants module Introduced a new MultitenantHttpRoutingFeature class to the Elsa.Tenants.AspNetCore module, enhancing the tenant resolution capabilities. Moved RoutePrefixTenantResolver from Elsa.Http to Elsa.Tenants.AspNetCore and updated relevant project references and namespaces accordingly. This refactor improves modularity and separation of concerns between HTTP and tenancy features. * Refactor route handling and tenant configuration Removed redundant `RouteTableExtensions` and replaced with new route providers and updaters, enhancing flexibility and modularity. Introduced tenant-specific HTTP endpoint configurations for better customization and configuration management. * Rename HttpEndpointBookmarkStimulus to HttpEndpointBookmarkPayload Refactor various classes and methods to reflect the renaming from `HttpEndpointBookmarkStimulus` to `HttpEndpointBookmarkPayload`. Add and configure new extension methods for tenant route handling, update the route provider to support multi-tenancy, and adjust the tenants provider to bind configuration properly. * Add HeaderTenantResolver and refactor Http namespace. Introduce HeaderTenantResolver to resolve tenants via HTTP headers. Refactor multiple classes and interfaces to move from the Elsa.Http.Models namespace directly into Elsa.Http for clarity and consistency. * Add Host-based tenant resolution Implemented a HostTenantResolver to resolve tenants based on the request's host and updated tenant configurations with host information. Modified the tenant resolver pipeline and added the new host resolver to the service registrations. * Add tenant-aware caching and accessor support Enhanced caching by incorporating tenant identifiers into cache keys for more granular cache management. Introduced ITenantAccessor dependencies in various services to retrieve the current tenant information. This ensures that cache entries are correctly isolated per tenant. * Reorder tenant resolvers for pipeline setup. Reordered the tenant resolvers in the pipeline to prioritize HostTenantResolver before RoutePrefixTenantResolver. This ensures that tenant resolution is correctly aligned with host-based resolving before checking the route prefix. * Remove unused imports This commit eliminates redundant `using` directives across multiple files to streamline the codebase. This cleanup helps improve code readability and maintainability by removing unnecessary dependencies.
2024-10-14 19:27:11 +00:00
management.AddVariableTypes([
typeof(HttpRouteData),
typeof(HttpRequest),
typeof(HttpResponse),
typeof(HttpResponseMessage),
typeof(HttpHeaders),
typeof(IFormFile),
typeof(HttpFile),
typeof(Downloadable)
Implement multitenant HTTP routing (#6031) * Add tenant awareness to bookmark handling and route resolution Added tenant ID support across various components, including bookmark updates, route resolution, and middleware processing. This ensures that bookmark and route operations can now appropriately handle tenant-specific data, improving the system's multitenancy capabilities. * Add Multitenant HTTP Routing feature to Tenants module Introduced a new MultitenantHttpRoutingFeature class to the Elsa.Tenants.AspNetCore module, enhancing the tenant resolution capabilities. Moved RoutePrefixTenantResolver from Elsa.Http to Elsa.Tenants.AspNetCore and updated relevant project references and namespaces accordingly. This refactor improves modularity and separation of concerns between HTTP and tenancy features. * Refactor route handling and tenant configuration Removed redundant `RouteTableExtensions` and replaced with new route providers and updaters, enhancing flexibility and modularity. Introduced tenant-specific HTTP endpoint configurations for better customization and configuration management. * Rename HttpEndpointBookmarkStimulus to HttpEndpointBookmarkPayload Refactor various classes and methods to reflect the renaming from `HttpEndpointBookmarkStimulus` to `HttpEndpointBookmarkPayload`. Add and configure new extension methods for tenant route handling, update the route provider to support multi-tenancy, and adjust the tenants provider to bind configuration properly. * Add HeaderTenantResolver and refactor Http namespace. Introduce HeaderTenantResolver to resolve tenants via HTTP headers. Refactor multiple classes and interfaces to move from the Elsa.Http.Models namespace directly into Elsa.Http for clarity and consistency. * Add Host-based tenant resolution Implemented a HostTenantResolver to resolve tenants based on the request's host and updated tenant configurations with host information. Modified the tenant resolver pipeline and added the new host resolver to the service registrations. * Add tenant-aware caching and accessor support Enhanced caching by incorporating tenant identifiers into cache keys for more granular cache management. Introduced ITenantAccessor dependencies in various services to retrieve the current tenant information. This ensures that cache entries are correctly isolated per tenant. * Reorder tenant resolvers for pipeline setup. Reordered the tenant resolvers in the pipeline to prioritize HostTenantResolver before RoutePrefixTenantResolver. This ensures that tenant resolution is correctly aligned with host-based resolving before checking the route prefix. * Remove unused imports This commit eliminates redundant `using` directives across multiple files to streamline the codebase. This cleanup helps improve code readability and maintainability by removing unnecessary dependencies.
2024-10-14 19:27:11 +00:00
], "HTTP");
management.AddActivitiesFrom<HttpFeature>();
});
Add IResilienceStrategy Abstraction with Category Matching and Expression-Based Configuration (#6637) * Add resilience module with core interfaces and services Introduced a new `Elsa.Resilience` module and its core components to support resilient services and activities. This includes resilience strategies, providers, and attributes, along with integration into the existing HTTP module for enhanced fault tolerance. Added solution and project references for proper dependency management. * Add resilience strategy framework with HTTP strategy support Introduced a resilience strategy architecture, including a configurable `HttpResilienceStrategy` with retry capabilities, strategy serialization, and integration with existing modules. Enhanced ResilienceFeature to support registration of strategy types and updated application configuration to enable resilience strategies. This change ensures more robust and fault-tolerant HTTP request handling. * Add JSON serialization support for resilience configuration Introduced `ConfigurationExtensions` to enable JSON serialization of configuration sections. Updated resilience strategies to utilize the new extension methods and adjusted JSON serialization logic to support polymorphism with `$type` discriminator. Minor modifications were made to support deserialization and property mutability. * Add resilience strategy support to workflows and API clients Introduced resilience strategy configuration, serialization, and execution support across workflows and API clients. Added new APIs, models, and services to enhance fault tolerance capabilities for activities and HTTP interactions. * Refactor resilience services for improved modularity. Replaced `IResilienceService` with new modular interfaces (`IResilienceStrategyCatalog`, `IResilienceStrategyConfigEvaluator`, `IResilientActivityInvoker`) and corresponding implementations. Enhanced maintainability by simplifying components and responsibilities, ensuring better separation of concerns. * Rename methods in ResilienceStrategyCatalog for clarity Updated method names in `ResilienceStrategyCatalog` and its interfaces for better readability and alignment with naming conventions. Replaced `GetAllStrategiesAsync` with `ListAsync` and `GetStrategyAsync` with `GetAsync` across the codebase. * Refactor resilience handling in HTTP activities. Replaced `ResilienceCategory` property with `ResilienceCategoryAttribute` for a cleaner implementation. Updated `IResilientActivity` to simplify its interface and adjusted related modifications accordingly. Introduced `IResilientActivityInvoker` to enhance resilience strategy execution. * Add support for additional resilience and scripting features Extended resilience strategy handling with serialization support, added `HttpResilienceStrategy` type in JavaScript handler, and refined object conversion logic for interfaces. Minor adjustments to `Expression` class properties for consistency. * Remove `UseResilience` call from Program.cs This call was redundant and no longer necessary for the application. Its removal simplifies the code and ensures only required middleware is used. * Remove commented-out JSON converter code in serializer setup Cleaned up unused and commented-out converter initialization code in `ResilienceStrategySerializer`. This improves readability and removes unnecessary clutter from the file. * Fix typo in method names from 'Resiliency' to 'Resilience' Renamed methods to maintain consistency in naming conventions across the codebase. This change ensures clarity and alignment with established terminology. * Refactor namespace for ConfigurationResilienceStrategySource Updated the namespace of ConfigurationResilienceStrategySource to "StrategySources" for better alignment with naming conventions and structure. Removed an unused namespace reference in ResilienceFeature for cleanup. * Mark EnableResiliency as obsolete in SendHttpRequestBase. The EnableResiliency property is now marked with the [Obsolete] attribute. Developers are encouraged to use the common Resilience Strategy setting instead for managing HTTP request resiliency. This change ensures better consistency and alignment with the broader resilience strategy. * Restrict ResilienceCategoryAttribute to class targets only Removed support for using ResilienceCategoryAttribute on properties. This change enforces a stricter and more focused usage of the attribute, ensuring it applies only to class-level declarations. * Add documentation for IResilientActivityInvoker interface Include summaries and parameter descriptions for the `InvokeAsync` method. This improves code clarity and helps developers understand the functionality and usage of the resilient activity invocation process. * Fix logical operator precedence in type comparison check Parentheses were added to ensure correct evaluation of conditions when checking type compatibility. This prevents potential logical errors when determining the target type in object conversions. * Add support for resilience source identification Introduce the `ResilienceSourceNameAttribute` to allow naming of resilience sources. Updated `ResilienceStrategyCatalog` to utilize the attribute for prefixing strategy IDs, improving source identification and traceability. Applied the attribute to `ConfigurationResilienceStrategySource` as an example. * Revert "Add support for resilience source identification" This reverts commit 19b4e7121d6330b5de4f692b78da4c1e4a2d1f67. * Reapply "Add support for resilience source identification" This reverts commit 8bcba9d040c4eb247077aec6d90dc02817adcbd5. * Revert "Reapply "Add support for resilience source identification"" This reverts commit ee04d35e7930956c752dda3ed150ca34a535e66c.
2025-05-12 08:09:04 +00:00
Module.UseResilience(resilience => resilience.AddResilienceStrategyType<HttpResilienceStrategy>());
}
/// <inheritdoc />
public override void Apply()
{
var configureOptions = ConfigureHttpOptions ?? (options =>
{
options.BasePath = "/workflows";
options.BaseUrl = new Uri("http://localhost");
});
var configureFileCacheOptions = ConfigureHttpFileCacheOptions ?? (options => { options.TimeToLive = TimeSpan.FromDays(7); });
Services.Configure(configureOptions);
Services.Configure(configureFileCacheOptions);
var httpClientBuilder = Services.AddHttpClient<SendHttpRequestBase>(HttpClient);
HttpClientBuilder(httpClientBuilder);
Services
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
.AddScoped<IRouteMatcher, RouteMatcher>()
.AddScoped<IRouteTable, RouteTable>()
.AddScoped<IAbsoluteUrlProvider, DefaultAbsoluteUrlProvider>()
.AddScoped<IRouteTableUpdater, DefaultRouteTableUpdater>()
Fix WorkflowActivity to Use Cached Workflow Definitions for Consistent Behavior (#5223) * Replace IServiceScopeFactory with IServiceProvider in WorkflowRunner Unused dependencies were removed from the workflow runner service. The IServiceScopeFactory was replaced with IServiceProvider to better handle the creation and deletion of service scopes, resulting in cleaner code with less manual scope management. Microsoft.Extensions.DependencyInjection and System.Diagnostics.CodeAnalysis were removed as they were no longer necessary. * Refactor WorkflowDefinitionActivity to use WorkflowDefinitionService The WorkflowDefinitionActivity class has been refactored to make use of the WorkflowDefinitionService instead of the WorkflowDefinitionStore. This fixes #5222 by ensuring the same activity instances are used in the graph model of the workflow execution context. * Add workflow filtering and caching functionality Added methods to `WorkflowDefinitionService` to find workflow definitions and workflows using filter criteria. A key generation method for caching filtered workflows was also added to `WorkflowDefinitionCacheManager`. The implementation includes generating a hash of the filter parameters and using this hash as a cache key, providing efficient caching functionality for filtered searches. * Refactor TriggerIndexer to handle only ITrigger activities The code in TriggerIndexer has been refactored to deal specifically with ITrigger activities, streamlining its behavior. Removed code related to handling non-ITrigger activities and simplified the workflow creation process. The extraction of "startable" nodes now directly filters and casts to ITrigger, reducing complexity and increasing readability. * Update caching service to support filter-based search The CachingWorkflowDefinitionService has been updated to support workflow definition and workflow search based on filter criteria. The update also includes change of class scope from public to internal. Further, it resolves the missing reference by switching from Elsa.Caching.Contracts to Elsa.Caching. * Optimize Elsa project imports and use explicit cache variable names This commit removes superfluous import references, relocates the 'IChangeTokenSignaler' contract into the 'Elsa.Caching' namespace, and replaces ambiguous 'cache' variable names with more explicit 'memoryCache' across several files. Additionally, new package references have been added and access modifiers have been changed to improve encapsulation. Cleanup enhances readability and maintainability of the codebase. * Add .DotSettings file to Elsa.Caching module A new .DotSettings file has been added to the Elsa.Caching module. This file is used for namespace configuration, specifically to skip the "contracts" folder in code inspections. * Update workflow interfaces to support filter queries The update extends `IWorkflowDefinitionCacheManager` and `IWorkflowDefinitionService` interfaces. Functions are added to allow creating filter cache keys and finding workflow definitions and workflows using a new `WorkflowDefinitionFilter`. This enhances querying flexibility by enabling filtered searches. * Add WorkflowDefinitionVersionId to WorkflowTriggerEqualityComparer A new property, WorkflowDefinitionVersionId, has been added to the object being serialized in WorkflowTriggerEqualityComparer. This change allows for a more accurate comparison between workflow triggers, considering not just the workflow definition ID but also its version. * Update service registration types in WorkflowsFeature Changed the registration type for both IHasher and IBookmarkHasher services from Scoped to Singleton in the workflows feature configuration. This alteration aims to improve application performance and manage service lifetimes more efficiently. * Remove Open.Linq.AsyncExtensions dependency The Open.Linq.AsyncExtensions package reference was removed across the project. The usage within the CachingWorkflowDefinitionStore was updated accordingly to maintain functionality. * Move System.Linq.Dynamic.Core package reference The System.Linq.Dynamic.Core package reference was moved from the Directory.Build.props file to the Elsa.Workflows.Management.csproj file. This change reflects the specific dependency of the Elsa.Workflows.Management module on System.Linq.Dynamic.Core, without impacting other modules. * Implement caching for HTTP workflows This update introduces caching mechanisms for HTTP workflows, which significantly improves their performance. The changes involve creating a `CacheManager` and `CachingHttpWorkflowLookupService`, and modifying some existing components to use the new caching mechanism. Additionally, the `HttpWorkflowsCacheManager` was renamed to `HttpWorkflowsCacheInvalidationManager` to better reflect its role. * Refactor cache management across modules This commit refactor the cache management across various modules. The 'ICacheManager' interface now includes methods for triggering and getting change tokens, and the 'HttpWorkflowsCacheInvalidationManager' has been renamed to 'HttpWorkflowsCacheManager'. The caching functionality in 'WorkflowDefinitionService' and other similar services have been updated to use these new methods, improving consistency and maintainability. * Enable caching in Elsa.Server.Web The "useCaching" variable has been set to true to enable caching. Simultaneously, the method name "UseCachingStores" has been refactored to "UseCache". Conditional statements have been added to check the "useCaching" variable before invoking caching. * Rename method UseCaching to UseCache In the Elsa.Server.Web and Elsa.Http project files, the method UseCaching has been renamed to UseCache. This modification is aimed at bridging naming inconsistencies and maintaining naming standards across the application. * Update HttpCacheFeature class description The class summary for HttpCacheFeature has been revised. Originally, it stated that the class was used for installing services related to HTTP services and activities, but it actually focuses more on HTTP caching. * Remove unused Configure method from HttpCacheFeature The Configure method in HttpCacheFeature was found to be redundant as it wasn't doing any significant work or contributing to any functionality. It has therefore been removed to clean up the code and avoid confusion. * Add 'bug/*' to workflow triggers This commit includes 'bug/*' to the list of triggers in our GitHub Actions workflow. Now, any push or pull request under a 'bug/*' branch will trigger the workflow.
2024-04-15 08:06:27 +00:00
.AddScoped<IHttpWorkflowLookupService, HttpWorkflowLookupService>()
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
.AddScoped(ContentTypeProvider)
.AddHttpContextAccessor()
Alterations with Queries (#5032) * Remove Elsa.Alteration Handlers and implement workflow alteration activities The Elsa.Alterations.Handlers, Services, and Endpoints have been removed and replaced with Elsa.Alterations.Activities for various steps in executing an alteration plan. These activities include submitting an alteration plan, generating alteration jobs, and dispatching alteration jobs. New models for ActivityFilter, AlterationWorkflowInstanceFilter, and alteration activity summaries are also introduced for better management of alteration plans. * Add 'PrintMessage' custom activity and update naming rules A new 'PrintMessage' activity has been added to the custom activities of the ConsoleApp, which simply writes a 'Hello world!' message. On top of this, the naming rules in the code styling settings have been expanded, introducing separate rules for instance and static private fields. * Remove V3_1 database migration files The V3_1 database migration files were deleted across all database providers, including MySql, SQL Server, SQLite and PostgreSQL. This is indicative of a rollback or significant revision to the data migration strategy. * Update product version and modify tables in Elsa DB context Updated "Elsa" DbSet product version from "7.0.11" to "7.0.14". Additionally, added new properties as well as modified existing ones in tables like "Elsa.KeyValues.Entities.SerializedKeyValuePair" to improve data structure. Also properly ignored certain entities in the Alterations DbContext. * Add V3_1 migration for Elsa This commit introduces the V3_1 migration for the Elsa module. Changes involve the introduction of new tables and alteration of existing tables. Specifically, a new 'KeyValuePairs' table was added and several columns on various tables were renamed or altered. * Remove multiple Elsa.EfCore V3_1 migration files The commit removes several migration files related to the V3_1 migration in multiple Elsa.EntityFrameworkCore modules including SqlServer, PostgreSQL, and SQLite. These files encompass changes in table structures and alterations. * Update default value for ArgumentDefinition Type The default value for the `Type` property in the `ArgumentDefinition` class was updated to `typeof(object)`. The `Type` property of `inputDefinition` in the `WorkflowBuilder` class was also modified to be set as `typeof(T)`. These modifications enable more flexible type handling. * Refactor SafeSerializer and serialization services The SafeSerializer service and related serialization services have been comprehensively refactored. This includes the removal of internal notifications, the incorporation of [RequiresUnreferencedCode] attributes, and changes in method signatures. Methods have been simplified to return ValueTasks directly from the JsonSerializer, and the notification sender dependency was removed. * Add JSON serialization for alterations Implemented a JSON serializer and a custom converter for the IAlteration interface in the Elsa.Alterations.Core.Serialization namespace. Also, introduced a new IJsonSerializer interface and an implementation for standard JSON serialization in Elsa.Common. These serialization changes enhance modularity and extensibility of JSON operations, and improve handling of IAlteration objects. * Add "IsSystem" field to Workflow Definitions and Instances This update introduces a new boolean field "IsSystem" to the Workflow Definition and Workflow Instance models. This field is designed to identify system workflows which aren't meant to be modified by users. Management and Runtime module code, API endpoints, database migrations, and related classes have been updated to include this new field. The MongoDB indices and Dapper migrations have been updated as well, and serialization/deserialization processes for these types have been modified to handle this new attribute. * Remove outdated database migrations Deleted database migration files from the MySql, SqlServer, and PostgreSql projects. * Add V3_1 migration for Elsa.EntityFrameworkCore.Sqlite This commit introduces the V3_1 migration for the Elsa.EntityFrameworkCore.Sqlite module. It includes changes in Alterations, Runtime, Management, and Identity contexts. These changes involve table alterations, addition of new columns, and creation of new tables. Each context alteration encapsulates relevant changes for specific functionalities of the module. * Add `IsSystem` property to workflow classes The `IsSystem` property has been added to several sections of the codebase related to workflows, such as `WorkflowStateMapper.cs`, `ListWorkflowDefinitionsRequest.cs`, `WorkflowDefinitionStore.cs`, and `ListWorkflowInstancesRequest.cs`. This property flag allows us to include or filter system workflows in our queries and results. * Add 'UsedImplicitly' attribute to Alteration Handlers and Types The 'UsedImplicitly' attribute from JetBrains.Annotations has been added to all Alteration Handlers and Alteration Types in the Elsa.Alterations module. This change specifies that these classes are being used implicitly and helps tools like ReSharper prevent false unused code detection. * Update migration script for efcore-3.1 The migration script efcore-3.1.sh has been updated. Module "Alterations" and provider "Sqlite" are added back into the lists while unused elements are removed for cleanup. The script now covers all necessary modules and providers, improving its overall effectiveness. * Remove PrintMessage class from Elsa.Server.Web bundle This commit deletes the PrintMessage.cs file that was previously part of the Elsa.Server.Web bundle. * Refactor MassTransit service configuration This commit reduces line code length by merging splitted long lines into one, improves maintainability of code. It also updates the Service configuration and removes unused namespaces across files, which help to simplify the codebase. Changes have also been made to switch the MassTransit broker from RabbitMq to memory and adjust the endpoint name formatter configuration. * Remove extra whitespace in Program.cs Removed a trailing whitespace on the line declaring the useSqlServer constant in the Program.cs file. No functionality changes were made, simply a minor formatting correction to maintain clean and consistent code. * Remove AlterationJsonConverter and update other files The AlterationJsonConverter class has been removed, simplifying the serialization process. The AlterationSerializer.cs file was updated with additional attribute tags, giving more information about serialization expectations. Lastly, the AlterationSerializationOptionConfigurator.cs was simplified by removing unnecessary overrides and the Elsa.Alterations.Core.csproj file was tidied up by removing unused services folder reference. * Refactor code for improved readability and maintainability The diff shows changes across multiple files in multiple modules. Primarily, these changes revolve around formatting edits such as removing unnecessary spaces or line breaks and adjusting alignments. A significant change was also made to the MySQL server version in the `DbContextOptionsBuilder.cs` file. These adjustments help improve the readability and maintainability of the code, making it easier to understand and modify in future iterations. * Remove unnecessary notification files and refactor code Several files pertaining to workflow serialization notifications were deemed unnecessary and removed. The Endpoint class in the `Elsa.Workflows.Api` module has been refactored for efficient usage of the `IWorkflowDefinitionStore` store, and similarly the `HttpFeature.cs` and `DesignTimeDbContextFactoryBase.cs` files have been slightly refactored for better readability and optimization. * Refactor HttpFeature class on variable types order The variable types order within the HttpFeature class in the Elsa Http module has been reorganized for cleaner code. No functional changes have been made - only the order of the types has been rearranged. This refactoring contributes to better readability and code maintenance. * Add 'issue/*' branch to GitHub workflow triggers This update includes 'issue/*' branches in the trigger configuration of GitHub workflows. Now, these branches will trigger specified GitHub actions, facilitating more effective issue tracking and resolution. * Change version option in WorkflowDefinitionManager The version option in the WorkflowDefinitionManager has been updated. Previously it was set to "LatestAndPublished", but this has been changed to "LatestOrPublished", adjusting the way the manager handles workflow versions. * Update GitHub Actions to remove duplicate branch pattern Removed the duplicated 'issue/*' entry from the branch trigger list in packages.yml to prevent redundancy in GitHub Actions workflow triggers. This ensures workflows are triggered correctly and efficiently for branch patterns intended for CI processes. * Refactor job generation in GenerateAlterationJobs Refactored the GenerateAlterationJobs activity to enhance code readability and maintainability. Broke down the ExecuteAsync method into smaller, purpose-specific private methods and added the missing `Elsa.Alterations.Core.Models` namespace. * Refactor consumer concatenation logic in MassTransitFeature Removed the commented-out code that filtered temporary queues, simplifying the concatenation of consumer types with workflow message consumers. * Refactor whitespace and improve readability Removed extraneous whitespaces and reformatted the `IsEmpty` property for better code readability. This enhances the code structure without affecting functionality. * Refactor MassTransitFeature configuration Moved transport configuration logic into the dedicated `ConfigureInMemoryTransport` method and removed unused usings to simplify the `MassTransitFeature` class setup. This streamlines setting up MassTransit in-memory transport and improves code maintainability. --------- Co-authored-by: Raymond den Haan <raymond.den.haan@nexxbiz.io> Co-authored-by: Marius Vasile Vușcan <marius.vuscan@nexxbiz.io>
2024-03-13 19:34:46 +00:00
// Handlers.
.AddNotificationHandler<UpdateRouteTable>()
Graceful shutdown for the workflow runtime (drain, pause, recover) (#7424) * feat(workflows-runtime): add quiescence machinery foundation for graceful shutdown Introduces the container-scoped quiescence signal, ingress-source contract, burst registry, and the Interrupted workflow sub-status — the foundational primitives the drain orchestrator and admin endpoints will build on. No behaviour change yet: workflows continue to run and shut down exactly as before. The new types are registered but no host-stop or pause path drives them. Highlights: * IQuiescenceSignal — composable Drain + AdministrativePause flags; forward-only drain, reversible pause, idempotent transitions, optional persistence via IKeyValueStore. * IIngressSource + IForceStoppable — uniform contract for components that inject external events (HTTP, schedulers, message consumers, internal workers, third-party modules); IIngressSourceRegistry collects and surfaces their states. * IBurstRegistry — atomic counter for in-flight workflow execution bursts, with per-burst ingress attribution and FR-018 inconsistency detection (a source claiming Paused but starting bursts is flipped to PauseFailed). * WorkflowSubStatus.Interrupted — new value distinct from Suspended, Cancelled, Faulted; semantics: "last burst force-cancelled by graceful drain; resumable on next runtime generation". Mirrored on the API client enum. * GracefulShutdownOptions — drain deadline, per-source pause timeout, stimulus-queue back-pressure policy, pause-persistence policy. Configurable via UseWorkflowRuntime(...).ConfigureGracefulShutdown(...). * PermissionNames.ManageWorkflowRuntime — single permission for the forthcoming admin pause/resume/status/force endpoints. Implements 31 of 77 tasks for the graceful-shutdown feature (specs/002-graceful-shutdown). Subsequent commits add the drain orchestrator (US1 / MVP), Interrupted recovery scan (US3), admin endpoints (US2), and first-party ingress adapters. Tests: 25 new xUnit unit tests; 100/100 runtime unit tests pass; all existing tests continue to pass on net8.0/net9.0/net10.0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(workflows-runtime): add drain orchestrator + host-stop integration (US1, MVP) When the host receives a stop signal (SIGTERM, Ctrl+C, orchestrator rollout), the runtime now drains gracefully: ingress sources are paused in parallel, in-flight workflow bursts run to their next natural persistence boundary within a configurable deadline, and any burst that breaches the deadline is force-cancelled and persisted with the Interrupted sub-status plus a forensic WorkflowInterrupted log entry. This is the MVP — without the activation-time recovery scan (PR 3) the existing timeout-based RestartInterruptedWorkflowsTask still picks up Interrupted instances, just on its periodic cadence. No regression in that recovery path (SC-008). Highlights: * IDrainOrchestrator + DrainOrchestrator — protocol per the contract: BeginDrainAsync → parallel ingress pause with per-source timeouts + IForceStoppable escalation → poll BurstRegistry.ActiveCount until zero or deadline → on breach iterate live handles, cancel, persist Interrupted, write log entry. All exceptions are captured into the returned DrainOutcome; only second-invocation throws. * Deadline clamping: effective deadline is min(GracefulShutdownOptions. DrainDeadline, HostOptions.ShutdownTimeout - 500ms safety epsilon), so the runtime never outlives its host process. * DrainOrchestratorHostedService — IHostedService.StopAsync wakes the orchestrator on host stop. Registered AFTER the heartbeat (Elsa.Hosting.Management) so reverse-order shutdown keeps the heartbeat alive throughout drain. Prevents sibling-node crash recovery from false-positive-recovering instances we are gracefully handling here (FR-029). * BurstTrackingMiddleware — workflow-execution-pipeline middleware that registers a BurstHandle for the lifetime of every burst. All nine IWorkflowRunner.RunAsync overloads ultimately funnel into pipeline.ExecuteAsync(context), so this single middleware covers the three "burst choke points" the spec references without nine separate decorators. Added to UseDefaultPipeline(). * Ingress attribution: optional IngressSourceName property on DispatchStimulusRequest, DispatchWorkflowDefinitionRequest, and DispatchWorkflowInstanceRequest. Adapters set it; the middleware reads it via WorkflowExecutionContext.TransientProperties (helpers in IngressAttributionExtensions). The BurstRegistry uses the name to detect the FR-018 invariant violation — a source that reports Paused but starts a burst is flipped to PauseFailed. * InterruptedLogExtensions — the LogWorkflowInterruptedAsync helper that the orchestrator calls when persisting the forensic record. Tests: 11 new unit tests (DrainOrchestrator parallel-pause + wait-for-bursts + idempotency + persistence-failure path); 5 new integration tests (full DI graph resolves, burst-tracking middleware registers handles end-to-end, no-op drain returns CompletedWithinDeadline). 100/100 runtime unit tests pass; all existing tests continue to pass on net8.0/net9.0/net10.0. Implements 14 of 77 tasks (T032–T045). Subsequent commits add Interrupted recovery scan (US3), admin endpoints (US2), and first-party ingress adapters. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(admin-endpoints): add admin endpoints for workflow runtime control Introduced admin endpoints to manage workflow runtime: `/pause`, `/resume`, `/status`, and `/force` with full authentication and audit logging. Integrated idempotency checks and error handling to ensure reliable runtime control. Added corresponding integration tests for verification. * fix(workflows-runtime): propagate drain cancellation into running workflows + initialize persisted pause + fix log-comment Addresses three findings from the PR #7424 code review: 1. **HIGH — Cancellation now propagates into the running workflow.** `BurstHandle.Cancel()` previously cancelled only its own linked CTS, which the workflow runner never observes (the runner reads from `WorkflowExecutionContext.CancellationToken`, captured at context construction and not part of the linked chain). On deadline breach the orchestrator would persist `Interrupted`, but the workflow continued executing and could overwrite the sub-status with whatever terminal state it eventually reached. Fix: `BurstHandle` accepts an optional cancel callback at construction. `BurstTrackingMiddleware` wires it to `context.Cancel()` so the burst's cancellation triggers the workflow's own cancellation chain — the workflow transitions to `Cancelled` and stops scheduling new activities. The orchestrator then awaits `BurstHandle.Disposed` (with a 2 s settle timeout) before persisting `Interrupted`, ensuring the runner's terminal commit completes BEFORE the orchestrator overwrites the sub-status. Race resolved. The settle timeout is bounded so a non-cancellable activity (genuinely pathological case) does not block drain — on timeout the orchestrator logs and proceeds, accepting the runner-clobber for that one instance, which the existing timeout-based RestartInterruptedWorkflows recovery picks up afterwards. 2. **MEDIUM — Pause persistence is now actually wired.** `QuiescenceSignal.InitializePersistedStateAsync` was implemented but nothing called it on host startup. A host configured with `PausePersistence = AcrossReactivations` would write the persisted key on pause, but on subsequent activation the new `QuiescenceSignal` instance would never read it, so the runtime would resume dispatching despite the operator having paused. Fix: `InitializePauseStateStartupTask : IStartupTask` reads the policy and calls `InitializePersistedStateAsync` once per activation when the policy demands it. Registered in both `WorkflowRuntimeFeature` flavours alongside the other graceful-shutdown services. 3. **MEDIUM — Comment in `DrainOrchestrator.PersistInterruptedAsync` no longer lies.** The previous comment promised a "synthetic log entry" that the next statement (`return`) prevented from being written. The comment is now honest about what actually happens: when no instance row exists, no log entry is emitted, but the burst metadata is still captured in the drain outcome's logged warning so operators have a forensic trail. Tests: * New unit tests on `BurstRegistry` (now 9, was 6): cancel-callback is invoked, callback exceptions are swallowed (drain remains best-effort), `BurstHandle.Disposed` completes on dispose. * Full suites continue to pass: 103/103 runtime unit tests; 247/247 workflow integration tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(workflows-runtime): address PR review feedback + close runner-clobber race + add e2e drain test Six issues raised in PR #7424 review (one e2e gap, five comments inline): 1. **Runner-clobber race closed via ICommitStateHandler decorator.** The previous fix wired `BurstHandle.Cancel()` to `WorkflowExecutionContext.Cancel()` so the workflow's cancellation chain fires on deadline breach, but the e2e test exposed that `BurstHandle` disposed at the END of the pipeline middleware (i.e., BEFORE `WorkflowRunner` calls `commitStateHandler.CommitAsync`). The orchestrator's `await handle.Disposed` therefore returned too early, the instance row didn't yet exist, and the orchestrator's Interrupted write was either a no-op (no row) or got clobbered by the runner's subsequent Cancelled commit. Fix: `BurstAwareCommitStateHandler` decorates `ICommitStateHandler`. The middleware no longer disposes the handle in the success path — it stores the handle in `WorkflowExecutionContext.TransientProperties`, and the decorator disposes it AFTER `inner.CommitAsync` completes. The exception path in the middleware still disposes for safety. Result: the orchestrator's await-disposed sequencing now correctly lands the Interrupted write last. 2. **C1: Null-instance log entry.** `DrainOrchestrator.PersistInterruptedAsync` now writes a synthetic `WorkflowInterrupted` log entry directly when no instance row exists, populating only the fields it knows. Previously the forensic trail was lost. 3. **C2: Force endpoint cached-outcome audit.** Added `WasCached` flag to `DrainOutcome` (default false). The orchestrator sets it on the cached return path (`_previousOutcome with { WasCached = true }`). The force endpoint now skips the audit notification when the flag is true, so repeated force calls no longer emit spurious `RuntimeForceRequested` events (SC-007 idempotency restored). 4. **C3: `StateChanged` raised under lock — deadlock risk closed.** `QuiescenceSignal.BeginDrainAsync`/`PauseAsync`/`ResumeAsync` now do their transitions under the lock, capture whether a transition occurred, release the lock, and only then invoke `RaiseStateChanged`. Subscribers that synchronously call back into the signal can no longer deadlock. 5. **C4: Scheduling source name.** Renamed `scheduling.cron` → `scheduling.triggers` to honestly reflect the four trigger types the adapter covers (Cron, Timer, StartAt, Delay). The name is surfaced verbatim in admin status responses. 6. **C5: Hardcoded Retry-After.** `HttpWorkflowsMiddleware`'s 503 response now sets a reason-aware `Retry-After`: 5 s during drain (host is exiting and will be replaced shortly), 60 s during administrative pause (indefinite, so a longer back-off avoids tight retry loops). Tests: * New e2e `DeadlineBreachEndToEndTests` (2 tests): verifies that drain against a real running workflow detects the in-flight burst, force-cancels it, persists the instance as `Interrupted`, and writes a `WorkflowInterrupted` log entry — closing the test gap that hid the cancellation-propagation issue identified in the previous review pass. * Updated `OperatorForceAfterPreviousReturnsCachedOutcome` to assert value-equality + the `WasCached` flag instead of reference-equality (records use `with` for the cached return path). Full suites pass: 103/103 runtime unit, 249/249 workflow integration. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(workflows-api): move runtime admin endpoints into Elsa.Workflows.Api Per PR review feedback: rather than introducing a new sub-module (Elsa.Workflows.Runtime.Admin) for the four pause/resume/status/force endpoints, fold them into the existing Elsa.Workflows.Api project. That project already references both Elsa.Workflows.Runtime and Elsa.Api.Common (FastEndpoints) and is the established home for client-facing workflow APIs — so the admin endpoints belong there. Changes: * New folder src/modules/Elsa.Workflows.Api/Endpoints/RuntimeAdmin/ with Models.cs and Pause/Resume/Status/Force/Endpoint.cs. Namespaces moved from `Elsa.Workflows.Runtime.Admin` → `Elsa.Workflows.Api.Endpoints.RuntimeAdmin`. * Deleted src/modules/Elsa.Workflows.Runtime.Admin/ entirely and removed it from Elsa.sln. The ShellFeature marker class (WorkflowRuntimeAdminFeature) is no longer needed — the existing WorkflowsApiFeature already discovers FastEndpoints in the Workflows.Api assembly. * No consumer changes: the endpoints sit in the same routes (/admin/workflow-runtime/*) and behave identically. Note on the second architectural point ("update IShellFeature if cleaner"): the IShellFeature contract is defined in the external CShells NuGet package, not in this repo, so we cannot add a DeactivateAsync hook without an upstream CShells change. The current IHostedService.StopAsync hook continues to work correctly for the host-stop path; per-shell deactivation would require either a CShells upstream addition or a separate Elsa-owned shell-feature variant — neither lighter than what we have today. Tests: 103/103 runtime unit + 249/249 workflow integration pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(common): introduce IsFatal exception extension + apply to drain best-effort catches Per PR review feedback on the static-analyzer "Generic catch clause" comments: rather than catching ALL exceptions in best-effort drain code paths, narrow the swallow to non-fatal exceptions. Process-fatal conditions (StackOverflowException, AccessViolationException, SEHException, ThreadAbortException, OutOfMemoryException) propagate so the host's failure-fast policy can act on them, while normal failures (InvalidOperationException, IOException, etc.) continue to be logged and allowed through so a single misbehaving ingress source / activity cannot abort the overall drain. Highlights: * New `Elsa.Common.Extensions.ExceptionExtensions.IsFatal` utility: classifies fatal conditions, unwraps reflection-style wrappers (TypeInitializationException, TargetInvocationException) before classification, and treats InsufficientMemoryException (the recoverable OOM subclass) as non-fatal. * Applied as a `when (!ex.IsFatal())` filter to: - BurstHandle.Cancel (cancel callback try/catch) - DrainOrchestrator.PauseOneSourceAsync (per-source exception path) - DrainOrchestrator.TryForceStopAsync - DrainOrchestrator.ForceCancelActiveBurstsAsync (per-burst loop) - DrainOrchestrator.PersistInterruptedAsync (orphan log write, instance save, log write) - DrainOrchestrator.DrainAsync outer catch (existing `not InvalidOperationException` filter extended) - InterruptedRecoveryScan (per-instance restart loop) Tests: 7 new unit tests for IsFatal classification (fatal types, recoverable types, wrapped causes, null tolerance). Full suites: 103/103 runtime unit (incl. 14/14 in Common.UnitTests including new tests) + 249/249 workflow integration pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(workflows-runtime): integrate CShells 0.0.15 lifecycle hooks (IDrainHandler + IShellInitializer) CShells 0.0.15 ships the lifecycle framework needed for first-class per-shell graceful shutdown — IDrainHandler / IShellInitializer / IShellLifecycleSubscriber. This commit bumps the package, migrates Elsa's existing usage of the removed 0.0.14 API, and registers the runtime drain orchestrator + pause-state initializer through the new primitives. Highlights: * `ElsaShellDrainHandler : IDrainHandler` — bridges per-shell drain into `IDrainOrchestrator.DrainAsync(DrainTrigger.ShellDeactivation, ct)`. Invoked by CShells when a shell enters `ShellLifecycleState.Draining`; the drain handler's CancellationToken is signalled when the per-shell deadline elapses, so the orchestrator's own deadline-bounded protocol nests cleanly. Coexists with the host-stop `DrainOrchestratorHostedService`; the orchestrator's `DrainAsync` is idempotent — second invocations log and skip. * `InitializePauseStateShellInitializer : IShellInitializer` — replaces the IStartupTask variant in shell-aware deployments. IShellInitializer fires on EVERY shell (re)activation, including reactivations after a reload — exactly what FR-028 requires. The IStartupTask remains for IModule consumers where there is no shell platform. Migrations (CShells 0.0.14 → 0.0.15 breaking changes): * `ActivateShellTenants`: was `IShellActivatedHandler` + `IShellDeactivatingHandler`, now `IShellInitializer` + `IDrainHandler`. * `MultitenancyFeature`: registrations updated to the new transient interface, `using CShells.Hosting` → `using CShells.Lifecycle`. * `Reload/Endpoint`, `ReloadAll/Endpoint`: `IShellManager` → `IShellRegistry`, `ReloadShellAsync` → `ReloadAsync` (returns `ReloadResult` with `Error`), `ReloadAllShellsAsync` → `ReloadActiveAsync` (returns `IReadOnlyList<ReloadResult>` with per-shell errors aggregated into 503). Build + restore: * `Directory.Packages.props`: all CShells.* packages bumped to 0.0.15. * `NuGet.Config`: added `cshells-feedz` source (https://f.feedz.io/sfmskywalker/cshells/nuget/index.json) and split the package-source-mapping pattern into `CShells` (exact) + `CShells.*` (prefix). Single-pattern `CShells*` does NOT match correctly under PackageSourceMapping. Tests: 103/103 runtime unit + 249/249 workflow integration pass on the new package version. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(workflows-runtime): apply PR #7424 review feedback Consolidates the architectural fixes asked for during /review: - Extract IWorkflowRuntimeAdminService to back the four /admin/workflow-runtime endpoints with a single domain service; thin Pause/Resume/Status/Force endpoints to delegating shells. - Remove StateChanged C# event from IQuiescenceSignal (Constitution VII: no external subscribers existed; mediator was suggested as the alternative if/when it's needed). - Promote InitializePersistedStateAsync to IQuiescenceSignal, dropping the concrete-cast in both InitializePauseStateStartupTask and InitializePauseStateShellInitializer. - Invert ingress-source DI to Lazy<IEnumerable<IIngressSource>> to break the cycle through IQuiescenceSignal; ingress adapters take the signal directly via primary constructor. - Replace Guid.NewGuid().ToString("N") with IIdentityGenerator in InterruptedLogExtensions and DrainOrchestrator. - Switch admin-audit timestamps to ISystemClock in WorkflowRuntimeAdminService. - Make GracefulShutdownOptions.StimulusQueueMaxDepthWhilePaused nullable (null = unlimited). - Rename RuntimeForceRequested → RuntimeForceDrainRequested. - Apply IsFatal exception filter to drain best-effort catches. - Rename IBurstRegistry.EnumerateActive → ListActiveBursts. - Refresh "Phase X" comments to user-story (USx) references. - Delete unused IngressAttributionExtensions, IngressSourceServiceCollectionExtensions, IngressSourceRegistrationOptions. - Migrate Elsa.Shells.Api.Tests to CShells 0.0.15 IShellRegistry / ReloadResult surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(graceful-shutdown): apply IsFatal filter to deadline-breach test catch Aligns the test scaffolding's swallow-everything catch with the project standard introduced in c00eee80c so the analyzer no longer flags the bare `catch` clause. The semantics are unchanged — non-fatal exceptions (OCE, TimeoutException, workflow exceptions) are still acceptable test outcomes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(workflows-runtime): close IngressSourceRegistry first-access race + spelling Replaces the non-atomic `_entries.Count > 0` early-return guard in EnsureMaterialized with a double-checked lock against a volatile `_materialized` flag, so concurrent first callers can no longer both iterate the source factory and crash one of them with a "Duplicate ingress source registration" InvalidOperationException. Adds a regression test that launches 16 readers behind a TaskCompletionSource gate and asserts every reader observes the full source set without throwing. Also flips the British spellings introduced in this PR's scope to American English (materialize/behavior) — project convention going forward. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(constitution): require American English for new code (v1.0.1) Adds a "Spelling & language" bullet under principle III (Convention-Driven Design): every newly-introduced symbol, comment, identifier, error message, XML doc, commit message, and Speckit artifact uses American English. Established public API symbols (e.g. WorkflowSubStatus.Cancelled) are not renamed retroactively. PATCH bump because this is a clarification of an existing principle, not a new principle. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Add Greploop skill and workflow for GitLab, GitHub, and Perforce integration - Introduced Greploop, an iterative optimization and review workflow for GitLab MRs, GitHub PRs, and Perforce changelists. - Added API and GraphQL references for fetching and resolving review skill. * Remove GenerateWorkflowVariableAccessorsTests; redundant ExpandoObject type check in handlers * Potential fix for pull request finding 'CodeQL / Untrusted Checkout TOCTOU' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix(graceful-shutdown): apply PR #7424 review feedback round 2 Two P1 findings from Greptile: 1. DrainOrchestrator.ForceCancelActiveBurstsAsync was sequential — each burst was cancelled, awaited up to ForceCancelSettleTimeout (2 s), and persisted before the next burst's Cancel() ran. Total wall time was O(N × 2 s) and bursts 2..N kept executing at full speed during prior bursts' settle waits, defeating the intent of force-cancel under concurrency. Refactored to three phases: - Phase A — cancel every handle synchronously (cheap CTS.Cancel calls) so all runners observe cancellation simultaneously. - Phase B — await every Disposed signal in parallel under a single shared ForceCancelSettleTimeout. Total wall time bounded regardless of N. - Phase C — persist Interrupted for each handle sequentially (keeps DbContext usage single-threaded; per-handle work is small). Per-phase failures are caught with !ex.IsFatal() and logged so a single misbehaving handle doesn't abort the rest of the batch. 2. ShellFeatures/WorkflowRuntimeFeature.ConfigureServices was missing the IWorkflowRuntimeAdminService registration that Features/WorkflowRuntimeFeature already had. Any CShells deployment that includes the Pause / Resume / Status / Force admin endpoints (in Elsa.Workflows.Api) would throw InvalidOperationException at endpoint construction. Added the singleton alongside the other graceful-shutdown registrations with a comment pointing out the symmetry with the IModule path. 17/17 graceful-shutdown integration tests pass; 103/103 runtime unit tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Potential fix for pull request finding 'CodeQL / Untrusted Checkout TOCTOU' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fix(ci): harden greploop.yml against CodeQL Actions findings CodeQL flagged 12 findings on .github/workflows/greploop.yml after the prior commit (c08183a3c) addressed an earlier round. Two distinct issue classes remain: 1. Code injection (× ~10): step-output values (steps.pr_head.outputs.head_sha / head_repo_owner / head_repo_name / head_ref) and inputs.pr_number were interpolated directly into shell `run:` blocks via `${{ ... }}`. Because PR author controls the branch name and the manual-dispatch input, those values can carry shell metacharacters. Standard fix: route every such interpolation through an `env:` block on the step, then reference $VAR inside the script. Applied to the Resolve, Resolve PR head metadata, and Checkout PR branch steps. 2. Untrusted Checkout TOCTOU + Checkout of untrusted code in trusted context: the workflow runs on `issue_comment` (a privileged trigger) and checks out PR-author code. Mitigations stacked here: - Author-association gate already restricts the trigger to OWNER / MEMBER / COLLABORATOR (existing). - Step-output values now travel via env vars (above). - Resolve step rejects pr_number that isn't ^[0-9]{1,10}$ — so downstream `gh pr view` and the prompt argument can't be hijacked. - Checkout step now validates HEAD_SHA matches ^[0-9a-f]{40}$ and the repo owner/name match ^[A-Za-z0-9_.-]+$ before either reaches a URL or a git command. - Existing TOCTOU guard preserved: re-fetch head SHA at checkout time and abort if it changed since the initial resolve. These match the canonical "Securing your GitHub Actions workflows" patterns recommended by CodeQL. No functional change to greploop's runtime behaviour. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(graceful-shutdown): drop [SingleNodeTask] from InitializePauseStateStartupTask Greptile P1: [SingleNodeTask] gates the task to a single cluster winner via distributed lock, but IQuiescenceSignal is a singleton scoped to each node's DI container — each node holds its own in-memory QuiescenceState. With the attribute, only the winning node restored the persisted pause; every other node started with QuiescenceReason.None and accepted new work, silently defeating PausePersistence = AcrossReactivations. Removed [SingleNodeTask] (and the corresponding using) so the task runs on every node. Expanded the doc <remarks> to call out the per-node requirement and point at the shell-aware counterpart (InitializePauseStateShellInitializer) which is correctly per-node by virtue of being an IShellInitializer. 17/17 graceful-shutdown integration tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Potential fix for pull request finding 'CodeQL / Code injection' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * chore(deps): bump CShells 0.0.15 → 0.0.17 0.0.17 ships our blueprint-aware-routing PR (valence-works/cshells#93) plus four follow-up fixes the maintainer added on top: - e56ebd8 — PreWarmShells removed entirely; ShellMiddleware now does cold-start endpoint matching (re-runs endpoint resolution after lazy activation so the very first request to a cold shell hits its endpoint). - cbe5ee2 — GetCandidateSnapshot returns a bounded ShellRouteCandidateSnapshot with accurate total counts; sensitive-data redaction in routing logs; DefaultShellRouteIndex implements IDisposable. - cd7d4f5 — Last-good snapshot served on rebuild failure (the deferred Copilot review concern); root-path fallback when path-by-name misses. - c3679d9 — Cold-start endpoint matching respects inline route constraints; path-name convention tightening; dead duplicate-detection cleanup. Net effect for elsa-core: - Cold blueprints serve their first request via lazy activation, with endpoints correctly resolved post-activation. - Reloaded shells re-activate and serve on the next matched request. - Non-name-mode routing keeps serving the previous snapshot during a transient blueprint-provider outage. - No need to call PreWarmShells from Elsa.ModularServer.Web — removed. The only API removal that touches elsa-core is PreWarmShells. No code references IShellRouteIndex / ShellRouteCriteria / GetCandidateSnapshot directly, so the API-shape changes in cbe5ee2 don't ripple here. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(graceful-shutdown): persist Interrupted under non-drain bounded token Greptile P? finding on the prior force-cancel two-phase fix: Phase B's inner catch on OperationCanceledException ("drain CT fired — proceed to persist anyway") was a lie in practice. Phase C immediately passed the same already-cancelled drain token into PersistInterruptedAsync; the first DB call (instanceStore.FindAsync) observed the cancellation and threw OperationCanceledException; the outer non-fatal Exception filter swallowed it and only logged an error. Net effect: on host shutdown deadline breach, every burst after cancellation could fail to be persisted as Interrupted, leaving instances in an unrecovered executing state. Phase C now creates a per-handle CancellationTokenSource bounded to a new PersistInterruptedTimeout (5 s) that is NOT linked to the drain CT. Each persist gets up to 5 s to land the row update + forensic log entry even after the drain CT has fired. The bound prevents a stuck DB from hanging shutdown indefinitely (per-handle worst case is small; total Phase C upper bound is N × 5 s, but typical persists are millisecond scale). Comment expanded to call out why the persist token is independent of the drain token, so the rationale doesn't drift again. 17/17 graceful-shutdown integration tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(graceful-shutdown): extract PassiveIngressSource base class The three IIngressSource implementations that ship with this PR (InternalBookmarkQueueIngressSource, HttpTriggerIngressSource, ScheduledTriggerIngressSource) were ~25 lines each and ~22 lines of those were verbatim copies of each other: - ctor signature `(IQuiescenceSignal signal)` - `PauseTimeout => TimeSpan.FromMilliseconds(50)` - `CurrentState => signal.IsAcceptingNewWork ? Running : Paused` - `PauseAsync` / `ResumeAsync` returning `ValueTask.CompletedTask` The shared trait is that none of them does any work at pause time — the actual pause enforcement lives in another layer (`HttpWorkflowsMiddleware` short-circuits to 503, `BookmarkQueueProcessor` consults the signal at the top of each invocation, scheduled triggers dispatch through the bookmark queue and inherit that behaviour transitively). The IIngressSource adapter is purely diagnostic: it makes the source visible in `DrainOutcome.Sources` and the admin status endpoint. Extracted that pattern into `PassiveIngressSource` (abstract base in `Elsa.Workflows.Runtime.IngressSources`). Subclasses now provide only `Name`; `PauseTimeout` is `virtual` with a 50 ms default; everything else is fixed by the base. The three concretes drop from ~25 lines to ~12 lines each. The base's XML `<remarks>` calls out when to use it ("your component already cooperates with IQuiescenceSignal at its hot path") and when to implement IIngressSource directly ("the source owns concrete pause/resume behaviour — e.g. a message-queue consumer that calls Pause() on its underlying client"), so future contributors don't mis-extend the base for sources that need real work at pause time. No behavioural change. 18 graceful-shutdown integration + 39 runtime unit tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(graceful-shutdown): align IIngressSource name to singular The three IIngressSource names were inconsistent: http.trigger (singular) internal.bookmark-queue-worker (singular) scheduling.triggers (PLURAL — outlier) The plural slipped in when addressing Greptile's earlier comment to avoid `scheduling.cron` (which would imply Cron-only coverage). The right move was to pick a generic word and stay singular like the rest of the suite — the suite's mental model is "the X source", one instance per registry slot, regardless of how many triggers or items it dispatches internally. Renamed to `scheduling.trigger`. The `<remarks>` block keeps the "covers Cron, Timer, StartAt, Delay" explanation and now also explicitly notes the singular convention so future contributors don't re-pluralize. Zero test fallout — the literal "scheduling.triggers" only appeared in the source file itself. Tests of the other two sources all use singular forms. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(runtime-admin): rename Force endpoint to ForceDrain "Force" alone is meaningless out of context — force what? — and it sits oddly next to the verb-named siblings Pause / Resume / Status. The matching admin service method is already IWorkflowRuntimeAdminService. ForceDrainAsync, so ForceDrain is the natural pair. Renamed: - src/modules/Elsa.Workflows.Api/Endpoints/RuntimeAdmin/Force/ → ForceDrain/ - namespace ...Endpoints.RuntimeAdmin.Force → ...ForceDrain - class ForceEndpoint → ForceDrainEndpoint - class ForceRequest → ForceDrainRequest - class ForceResponse → ForceDrainResponse - route POST /admin/workflow-runtime/force → /force-drain Zero external references — no tests, docs, or OpenAPI clients used the old symbols or the old route literal, so this is a contained pre-ship rename. Directory move went through `git mv` so commit history follows the file. 17/17 graceful-shutdown integration tests still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ci): correct formatting in checkout step within greploop.yml Adjusted indentation of environment variables in the checkout step for improved consistency and readability. * fix(ci): repair malformed Checkout repository step in greploop.yml The step accumulated stray env keys, an extra `uses:`, and bash commands that didn't belong inside it (line 65 onward), causing a YAML parse error on push. The valid structure has two distinct checkout steps: - Checkout repository : actions/checkout@v4 with fetch-depth: 0 - Checkout PR branch : env: + run: with SHA validation + git fetch + git checkout --detach The PR-branch step (line 78+) was already correct and unchanged. This fix restores the first step to its intended single-purpose shape (just checks out the workflow file's commit so the greploop skill is on disk before the run-greploop step uses it). No functional change to runtime behaviour or to the security posture established in the prior hardening commit (0db4ca23e). The PR-branch checkout still validates HEAD_SHA / HEAD_REPO_OWNER / HEAD_REPO_NAME shape before they reach a URL or git command. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ci): remove literal `${{ }}` from greploop.yml comment GitHub Actions parses `${{ ... }}` workflow expressions across the entire YAML file, including inside `run:` script comments. The comment that explained the env-var hardening pattern contained the literal sequence `${{ }}` (with a space, intended as an English-language description), which the expression parser rejected as "An expression was expected" (line 81 col 14). Reworded the comment to describe the substitution form in prose without the literal token sequence. Functional behaviour unchanged. * refactor(graceful-shutdown): rename burst → execution cycle The graceful-shutdown work introduced "burst of execution" as a first-class domain concept. The term arrived without rationale and isn't standard in the workflow-engine domain. Renamed to "execution cycle" — reads more naturally as the loop-with-commit unit, is more idiomatic in workflow vocabulary, pairs cleanly with the existing WorkflowExecutionContext, and avoids collisions with Elsa's existing terms (Run, Execution, Dispatch, Invocation, Stimulus, Step). Renamed types - IBurstRegistry → IExecutionCycleRegistry - BurstRegistry → ExecutionCycleRegistry - BurstHandle → ExecutionCycleHandle - BurstTrackingMiddleware → ExecutionCycleTrackingMiddleware - BurstAwareCommitStateHandler → ExecutionCycleAwareCommitStateHandler Renamed members - BeginBurst → BeginCycle - ListActiveBursts → ListActiveCycles - BurstHandleKey constant + value → ExecutionCycleHandleKey - ActiveBurstCount (IQuiescenceSignal, RuntimeAdminStatus, StatusResponse) → ActiveExecutionCycleCount - WaitForBurstsAsync (private) → WaitForCyclesAsync - ForceCancelActiveBurstsAsync (priv) → ForceCancelActiveCyclesAsync - UseBurstTracking → UseExecutionCycleTracking - DrainOutcomeDto.BurstsForceCancelledCount → ExecutionCyclesForceCancelledCount - _burstRegistry / burstRegistry → _cycleRegistry / cycleRegistry Backwards-compatibility preservation (the only persisted JSON key) - WorkflowInterruptedPayload.BurstDuration property → ExecutionCycleDuration with [JsonPropertyName("BurstDuration")] so the persisted JSON wire key stays "BurstDuration" forever. Pre-merge testers' log records still deserialise correctly. The contract test on WorkflowInterruptedPayloadContractTests still asserts the wire key "BurstDuration" appears in the serialised JSON — confirms the guarantee is enforced. Other unstructured surfaces - WorkflowExecutionLogRecord.Message text "Workflow burst was force- cancelled..." now says "Workflow execution cycle was force-cancelled ..." for new records. Old rows keep their old text — purely cosmetic free-text field. - Structured log placeholder {BurstId} in DrainOrchestrator log lines → {ExecutionCycleId}. - Lowercase prose / XML doc comments updated throughout. Test renames - BurstRegistryTests → ExecutionCycleRegistryTests - BurstTrackingMiddlewareTests → ExecutionCycleTrackingMiddlewareTests - Test method names + DisplayName strings updated. Spec docs (specs/002-graceful-shutdown/) updated to match the new vocabulary; the historical task records in tasks.md keep the old names as-is to preserve the audit trail of what was originally built. Verification - dotnet build: clean across net8.0 / net9.0 / net10.0. - 103/103 Elsa.Workflows.Runtime.UnitTests pass. - 17/17 GracefulShutdown integration tests pass. - 4/4 WorkflowInterruptedPayloadContractTests pass — confirms the "BurstDuration" JSON wire-key preservation is intact. No changes to migrations or DB column names — confirmed via grep. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ci): give greploop.yml gh-cli a repo context before checkout The "Resolve PR head metadata" step runs `gh pr view` before actions/checkout, so there is no `.git` directory and gh's "current repo" detection fails with `fatal: not a git repository`. The prior commits to this file masked the runtime failure because the workflow itself was YAML-invalid — once it became valid, the workflow_dispatch trigger surfaced this real-world execution bug. Set GH_REPO=${{ github.repository }} on both `gh pr view` steps. The gh CLI honours GH_REPO as an explicit repo override, so it no longer needs git context. Same fix on the "Checkout PR branch" validation call which also uses gh pr view before the manual fetch. The error reported as "Invalid workflow file: ... (Line 81 Col 14)" on PR #7424 was stale from commit ed580682a (which had the bad comment with literal `${{ }}`); commit 3a8ad0d08 fixed the YAML, but because greploop's `if:` condition only matches workflow_dispatch / issue_comment events, push events on later commits were skipped without re-running validation, so the GitHub UI kept showing the old error. A workflow_dispatch run on the current SHA now passes validation and reaches "Resolve PR head metadata", which is what this commit fixes. * fix(graceful-shutdown): wire IngressPauseTimeout option to drain orchestrator GracefulShutdownOptions.IngressPauseTimeout was documented as "Default per-ingress-source pause timeout" but DrainOrchestrator.PauseOneSourceAsync read source.PauseTimeout directly and never consulted the option. The configured value was silently ignored — operators who set GracefulShutdownOptions:IngressPauseTimeout = 10s were getting whatever each source's hardcoded value was (50 ms for the three PassiveIngressSource subclasses we ship), with no way to tune it globally. Precedence (per the spec's intent of "overridable at registration and by configuration"): 1. Per-source positive value wins (source.PauseTimeout > Zero). 2. Otherwise fall back to the configured GracefulShutdownOptions. IngressPauseTimeout default. 3. Resolved value is capped at the overall drain deadline so a single misbehaving source cannot exceed the host's shutdown budget. 4. 1 ms safety floor remains so a misconfigured zero default still produces a non-zero CancelAfter. Changes: - DrainOrchestrator.PauseOneSourceAsync — adds the precedence above with a comment block explaining each step. - IIngressSource.PauseTimeout — XML doc clarifies the Zero-defers-to- config semantics. - GracefulShutdownOptions.IngressPauseTimeout — XML doc says it's the fallback when the source returns Zero; <remarks> spells out the precedence and the overall-deadline cap. - PassiveIngressSource.PauseTimeout — virtual property now returns Zero (was 50 ms). The three shipped subclasses (HttpTriggerIngressSource, ScheduledTriggerIngressSource, InternalBookmarkQueueIngressSource) consequently defer to the configured default — flipping the wire-up bug from "configured value silently ignored" to "configured value honoured by default for passive sources". Passive subclasses that want a specific value can still override. 103/103 runtime unit + 17/17 graceful-shutdown integration tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(graceful-shutdown): rename IInterruptedRecoveryScan → IInterruptedRecoveryScanner The interface had a single verb-method (`ScanAndRequeueAsync`) and its XML doc described what it *does* ("Scans the workflow instance store for instances..."). That's an agent role — a scanner that performs a scan — but the noun-shaped name `IInterruptedRecoveryScan` read as "the scan itself", which is misleading because the scan results / event are not first-class types in the codebase. Renamed to `IInterruptedRecoveryScanner` / `InterruptedRecoveryScanner` to match the existing `-er` convention in this codebase (Restarter, Generator, Resolver, etc.). The method stays `ScanAndRequeueAsync` — the scanner *performs* a scan-and-requeue. Also renamed the constructor parameter `scan` → `scanner` in RecoverInterruptedWorkflowsStartupTask, and the local variable `scan` → `scanner` in InterruptedRecoveryIntegrationTests, so the "scanner does the scan" mental model is consistent throughout. Surface impact (all internal — no API or persistence touch points): - 2 source files renamed via git mv (interface + implementation) - 1 test file renamed (InterruptedRecoveryScanTests → ScannerTests) - DI registrations in both Features/ and ShellFeatures/ WorkflowRuntimeFeature - 1 startup-task constructor parameter - Spec doc references under specs/002-graceful-shutdown/ 103/103 runtime unit + 17/17 graceful-shutdown integration tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(graceful-shutdown): extract DrainTriggerExecutor ElsaShellDrainHandler (CShells IDrainHandler) and DrainOrchestratorHostedService (.NET IHostedService.StopAsync) inlined near-identical try/catch/log shapes around IDrainOrchestrator.DrainAsync: - call DrainAsync(<trigger>, ct) - branch on outcome: DeadlineExceeded/AbortedByUnhandledException → Warning, otherwise Information - catch InvalidOperationException (parallel-drain rejected by the orchestrator) → log Information and swallow The two had already drifted: host-stop's success log omitted the paused/waited durations the shell-handler version included, and the "skipped" message disagreed on the trigger label ("Host-stop drain skipped" vs "Shell drain skipped"). Centralised the shape in a small internal static helper so the two — and any future trigger source — stay uniform. Both call sites collapse to a single line. Net diff drops 22 lines from the two consumers and adds a 25-line helper that they both delegate to. The unified log copy now consistently includes paused/waited durations on the success path and uses the caller-supplied contextLabel ("Shell drain", "Graceful drain") in all three messages so operators can attribute log entries by trigger source. Files: - src/modules/Elsa.Workflows.Runtime/Services/DrainTriggerExecutor.cs (new) - src/modules/Elsa.Workflows.Runtime/Lifecycle/ElsaShellDrainHandler.cs - src/modules/Elsa.Workflows.Runtime/HostedServices/DrainOrchestratorHostedService.cs 103/103 runtime unit + 17/17 graceful-shutdown integration tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(workflows-runtime): drop redundant DrainOrchestratorHostedService from CShells path In CShells deployments, host stop already drives drain via CShellsStartupHostedService → IDrainHandler → ElsaShellDrainHandler, scoped per shell (FR-027). The additional .AddHostedService<DrainOrchestratorHostedService>() in ShellFeatures/WorkflowRuntimeFeature was firing a second non-force DrainAsync that the orchestrator rejected with InvalidOperationException — silently swallowed by DrainTriggerExecutor, but logged on every host stop and semantically muddled (IHostedService is host-level, not per-shell). Keep the registration on the IModule path (Features/WorkflowRuntimeFeature) where there is no shell platform and host-stop is the only available drain trigger. Update ElsaShellDrainHandler XML docs to reflect the now-clean single-trigger model in CShells. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(workflows-runtime): always dispose ExecutionCycleHandle in tracking middleware Previously the success path relied on ExecutionCycleAwareCommitStateHandler to dispose the handle after the runner's commit completed. If a custom dispatcher or test double exited the pipeline without invoking commit (by design or by accident), the handle stayed registered, IExecutionCycleRegistry.ActiveCount never reached zero, and drain spun in WaitForExecutionCyclesAsync until the deadline fired — incorrectly force-cancelling instances that had already finished cleanly. Collapse the existing try/catch(rethrow) into try/finally so the middleware itself disposes the handle for both exception and commit-elided paths. Disposal remains idempotent via the ExecutionCycleHandle._disposed Interlocked guard, so the normal-path dispose by ExecutionCycleAwareCommitStateHandler is a harmless no-op. Adds an integration regression test that drives the middleware with a stub Next that returns without invoking commit and asserts ActiveCount returns to zero. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(workflows-runtime): serialize QuiescenceSignal pause-state persistence Both PauseAsync and ResumeAsync used to release the inner lock before issuing the persistence I/O. A rapid Pause → Resume sequence could leave the persisted state inconsistent: PauseAsync's slow SaveAsync could land AFTER ResumeAsync's DeleteAsync, leaving the key present in the store while in-memory state was None. On host restart, InitializePersistedStateAsync would find the stale key and start the runtime in the paused state the operator had already cancelled. Introduce a dedicated SemaphoreSlim that serializes persistence I/O, with each I/O re-reading the live in-memory state inside the semaphore. N racing Pause/Resume calls now produce N serialized writes, each reflecting the most recent in-memory transition — so the final persisted state always matches final in-memory state. Adds a regression test that gates SaveAsync, races a Resume behind it, and asserts the store is empty after both complete. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(workflows-runtime): trim verbose comment in ExecutionCycleTrackingMiddleware finally block Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * refactor(workflows-runtime): use 'using var' for ExecutionCycleHandle in tracking middleware Replace the explicit try/finally that only existed to call handle.Dispose() with a `using var` declaration — identical semantics (compiler-emitted finally with idempotent dispose), more idiomatic. The regression test HandleReleasedWhenCommitIsElided continues to validate the leak-free property. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(workflows-runtime,api): proper 409 conflict shape + shell-scoped pause-persistence key ForceDrain endpoint: the 409 path returned `new ForceDrainResponse()` whose `Outcome` was null at runtime despite the `= null!` annotation, so any strongly-typed client deserializing the conflict body and reading `Outcome.OverallResult` got an NRE. Switch to the existing `ConflictResponse` shape with `Code = "DrainInProgress"` and the current runtime status. Routed via HttpContext.Response.WriteAsJsonAsync because Send.ResponseAsync is constrained to the endpoint's TResponse and cannot send a sibling DTO. QuiescenceSignal persistence key: the DI-registered `IQuiescenceSignal` was constructed with `shellName = null` (DI doesn't inject `string?` defaults), so every shell shared the key `elsa.quiescence.pause.default`. In a CShells multi-shell deployment under PausePersistencePolicy.AcrossReactivations this caused cross-shell contamination — pausing shell A would re-pause shell B on its next activation. Replace the simple AddSingleton<IQuiescenceSignal,...> registration in ShellFeatures/WorkflowRuntimeFeature with a factory that injects `CShells.ShellSettings` and forwards `Settings.Id` as the shell name. The IModule registration is unchanged (no shell platform; null shellName remains correct there). Adds a unit regression test that two QuiescenceSignal instances with different shellNames write to disjoint persistence keys and never to the legacy "default" key. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test(quiescence): use TryGetValue for ContainsKey+indexer assertions Combines existence check and value retrieval into a single dictionary lookup, addressing the code-quality bot's repeated suggestion. No behavior change — both PauseWritesKey and PersistenceKeyIncludesShellName still assert the same keys exist with the same content. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update specs/002-graceful-shutdown/contracts/admin-endpoints.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix(workflows-runtime): decouple QuiescenceSignal persistence from caller cancellation PersistAsync used to forward the caller's CancellationToken to both _persistenceMutex.WaitAsync and the store I/O. If an HTTP request was cancelled between the in-memory transition (already committed under _sync) and the persistence call, the I/O was silently skipped — leaving AdministrativePause set in memory with no persisted record. The idempotent fast-path on subsequent PauseAsync calls (transitioned == false) meant no retry would happen, so on host restart InitializePersistedStateAsync would find no key and the runtime would come back unpaused, defeating PausePersistencePolicy.AcrossReactivations. Drop the parameter from PersistAsync entirely; use CancellationToken.None for both the semaphore wait and the store I/O. The in-memory transition is already committed by the time PersistAsync runs, so persistence must complete to keep the store consistent with memory. The public PauseAsync/ResumeAsync methods still accept a CancellationToken (interface contract) — it just no longer reaches the persistence layer. Adds a regression test that calls PauseAsync with a pre-cancelled token and asserts both in-memory pause and the persisted key land correctly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(workflows-runtime,api,docs): apply Copilot review feedback batch Code: - DrainOrchestrator.TryForceStopAsync now bounds force-stop with the *remaining* drain budget (deadlineAt - now), not the full overall TimeSpan. A per-source pause that already burned the shutdown window can no longer get another full deadline's worth of force-stop runway. - DrainOrchestrator catch filter narrowed: drop `ex is not InvalidOperationException` exclusion. The "drain already in progress / completed" IOEs are thrown outside the protocol's try block, so they bubble out without entering this handler. Any IOE that lands here is incidental (e.g., from a store inside the drain) and should now be captured into the outcome rather than escaping the whole drain. - ResumeEndpoint 409 path now returns the discriminated ConflictResponse shape (matching ForceDrain) instead of a plain StatusResponse. Routed via HttpContext.Response.WriteAsJsonAsync because Send.ResponseAsync is constrained to TResponse. - Conflict codes aligned to kebab-case across both endpoints to match the contract spec (`runtime-draining` and `drain-in-progress`). Spelling sweep — American English per constitution v1.0.1 III: - DrainOrchestrator.cs: "serialised" → "serialized" - WorkflowInterruptedPayload.cs: "serialised" / "deserialise" → "serialized" / "deserialize" - PassiveIngressSource.cs: "behaviour" → "behavior" - DeadlineBreachEndToEndTests.cs: "serialisable" → "serializable" - specs/002-graceful-shutdown/quickstart.md: "behaviour" → "behavior" - specs/002-graceful-shutdown/checklists/requirements.md: "behaviour" → "behavior" Doc/contract alignment: - quickstart.md: force route corrected from /force to /force-drain. - quiescence-signal.md: removed StateChanged event from contract (interface doesn't define it); corrected persistence section to describe InitializePersistedStateAsync via shell initializer / startup task rather than constructor read; added the per-shell key discriminator. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(workflows-runtime): correct DI lifetimes for ExecutionCycleTrackingMiddleware and WorkflowRuntimeAdminService Two strict-DI-validation failures surfaced in tests using BuildServiceProvider with validate-on-build: 1. ExecutionCycleTrackingMiddleware was registered as AddSingleton<>, but its constructor takes WorkflowMiddlewareDelegate next — supplied by the workflow execution pipeline builder via UseMiddleware<>(), not from DI. The registration was both unused (no consumer resolves it through the container) and broken (DI fails to construct it because next is unregistered). Removing both registrations. 2. IWorkflowRuntimeAdminService was registered as AddSingleton<> but depends on the scoped INotificationSender (mediator) — captive-dependency violation. All consumers (Pause/Resume/ Status/ForceDrain endpoints) are FastEndpoints, which are scoped per request, so AddScoped is the correct alignment. The other deps (IQuiescenceSignal / IIngressSourceRegistry / IDrainOrchestrator / ISystemClock) are singletons and resolve fine from a scoped consumer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(workflows-runtime): restore commit-handler-only success disposal + true Cancel idempotency Two issues raised by Copilot's latest review on commit 32a9c0519: 1. ExecutionCycleTrackingMiddleware was disposing the handle at the end of InvokeAsync (via `using var`), but WorkflowRunner runs commit AFTER the pipeline returns (WorkflowRunner.cs:235). That meant the handle was disposed BEFORE the runner's terminal commit, and the drain orchestrator's `await handle.Disposed` would unblock too early — reintroducing the runner-clobber race the original design protected against (see ExecutionCycleAwareCommitStateHandler XML doc). Revert to the original shape: only dispose on exception path. ExecutionCycleAwareCommitStateHandler remains the SOLE success-path disposer, running in its finally block AFTER the inner commit lands. The earlier "leak when commit is elided" concern was a non-issue in production (the standard runner always commits); the buggy `HandleReleasedWhenCommitIsElided` test that specified the wrong contract is removed. The existing `ActiveCountReturnsToZero` test (which uses the real runner end-to-end) already verifies success-path disposal. 2. ExecutionCycleHandle.Cancel() was documented as idempotent but only short-circuited via the _disposed flag. Repeated Cancel() calls before Dispose could trigger the cancel callback multiple times — easy to accidentally fire non-idempotent cancellation side effects more than once. Add an Interlocked _cancelled guard so callback + CTS cancellation run at most once. Existing test that documented the leaky behavior is updated to assert the now-truly-idempotent contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Update logging levels and remove unused features in appsettings files * refactor(workflows-runtime): improve graceful shutdown options handling and cleanup solution Refactor the handling of `GracefulShutdownOptions` to ensure options are applied correctly without directly invoking the delegate. Update DI registrations to use appropriate lifetimes and remove redundant wrapper services. Additionally, clean up the solution by removing unused projects and documentation folders. * feat(identity, workflows-runtime): add validation for identity and graceful shutdown options Introduce validation capabilities for `IdentityTokenOptions` and `GracefulShutdownOptions`. Implement extension methods for option validation, enhance service registration, and add unit tests to ensure configurations are validated at startup. Update solution to include new unit test projects. * update(docs): clarify shutdown log message expectations and levels in quickstart.md Optimize explanation of expected log message sequence during graceful shutdown and specify logging levels. * docs: amend constitution to v1.1.0 (SRP, DRY, KISS, conciseness under Principle VII) * refactor(multitenancy): rename and restructure TenantTaskManager to TenantTaskLifecycleCoordinator Rename `TenantTaskManager` to `TenantTaskLifecycleCoordinator` and relocate to a new directory structure, enhancing code organization and test consistency. Retain functional behaviors with no logic alterations. Update unit tests to reflect the naming changes, ensuring consistency with the refactored code structure. * Update logging levels and dependencies - Set default logging level to Debug in appsettings.Development.json - Add missing using directives for Elsa workflows management and runtime features - Update CShells package versions to 0.0.18-preview.104 --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-05-02 17:27:08 +00:00
// Graceful shutdown: register HTTP ingress for diagnostic visibility in the runtime's IIngressSourceRegistry.
// The middleware short-circuits to 503 when paused (FR-006).
.AddSingleton<Elsa.Workflows.Runtime.IIngressSource, Elsa.Http.IngressSources.HttpTriggerIngressSource>()
Add caching to workflow runtime and workflow management stores (#5174) * Add caching to workflow runtime and workflow management stores The update introduces caching to workflow runtime and workflow management stores to enhance performance. This is achieved by adding decorators for several stores, which cache records to reduce database fetches. Additionally, a signaler for change tokens allows for cache invalidation when changes occur. The MemoryCache feature has also been updated to include Scrutor for decoration and the caching duration can be configured through the new CachingOptions class. * Refactor WorkflowsMiddleware for HTTP Endpoint bookmarks and triggers The WorkflowsMiddleware has been extensively refactored to handle HTTP Endpoint bookmarks and triggers. This involves breaking down the InvokeAsync method by extracting parts of its functionality into separate helper methods such as FindTriggersAsync and FindBookmarksAsync. Moreover, Assist with authorization checks, workflow execution within request timeout, and handling of workflow faults has been improved to be more efficient and clearly segmented. * Update HTTP endpoint authorization to use Workflow context The authorization process in the AuthenticationBasedHttpEndpointAuthorizationHandler class has been updated to use the Workflow context instead of the WorkflowInstanceId string. The AuthorizeHttpEndpointContext model has been correspondingly changed to include a Workflow property, thereby strengthening the link between authorization and specific workflows. * Add FindAsync methods to trigger and bookmark stores The code adjustments add new FindAsync methods to the trigger and bookmark store contracts as well as all their concrete implementations (MongoDb, Memory and EFCore). These methods support fetching the first record matching a given filter. The adjustments also include minor syntax improvements and the addition of [UsedImplicitly] attributes where needed. * Refactor WorkflowsMiddleware for improved workflow handling The code was refactored to simplify the flow of handling workflows in the WorkflowsMiddleware class. Specifically, the methods to start and resume a workflow have been extracted to improve code readability. Further, handleErrorMiddlewares was also updated to better manage instances where no valid workflows or base paths are found. * Add caching functionality to WorkflowsMiddleware Added IMemoryCache usage in the WorkflowsMiddleware to cache lookup results for workflows and their associated triggers. This will reduce the number of database operations required when searching for workflows, thus improving performance. The cache is maintained for one minute before it is refreshed. * Implement dynamic cache duration for workflows The code has been updated to have a dynamic cache duration for the workflows instead of a hardcoded one minute. By using the CachingOptions service, the cache duration can now be set in the configuration making it more flexible and adaptable to different performance needs. * Add HttpWorkflowsCacheManager for caching HTTP workflows This commit includes the implementation of IHttpWorkflowsCacheManager for caching of HTTP workflows. New handlers have been added to invalidate cache on workflow updates. Additionally, WorkflowsMiddleware has been renamed to HttpWorkflowsMiddleware. * Refactor workflow trigger handling and caching The refactoring includes deletion of `IndexWorkflowTriggersHandler.cs` and creation of `IndexTriggers.cs` thus revising the workflow trigger indexing approach. Also, revamped the `ITriggerIndexer` interface which now handles deletion of triggers with specific workflow and filter. Furthermore, the caching mechanism in `HttpWorkflowsCacheManager.cs` is modified to handle eviction of workflow definitions and triggers separately boosting its efficiency. * Add summary to IndexedWorkflowTriggers A summary has been added to the 'IndexedWorkflowTriggers' class, providing a brief description. This description outlines that it represents a collection of indexed workflow triggers, promoting clearer understanding for future reference. * Refactor memory caching feature into separate module This commit separates the memory caching feature from the Elsa.Common module into a distinct Elsa.Caching module. This includes moving and renaming related files, such as the MemoryCacheFeature class and associated dependencies. The references in other modules and in the main solution file have been updated accordingly to include the new Elsa.Caching module. * Add distributed caching and update async methods Introduced a distributed caching feature with extensible change token signal publishing. Updated various cache-related methods to be asynchronous for improved performance and responsiveness. Also updated some workflow identity references for clarity. * Add distributed caching with MassTransit support This addition includes the implementation of a distributed caching system with MassTransit transport. The changes introduce necessary interfaces and services, new distributed caching feature along with the support for MassTransit as a transport option. Moreover, the instance management feature has been renamed to clustering feature for better clarity. * Refactor queue naming and scope of MassTransitChangeTokenSignalPublisher Queue name construction is adjusted in the RabbitMqServiceBusFeature and AzureServiceBusFeature modules for better organization and readability. MassTransitChangeTokenSignalPublisher is now a singleton service, ensuring the signal publisher can be shared across the application, increasing efficiency and performance. Also, introduced use of DistributedCacheFeature in MassTransitDistributedCacheFeature module for better modularization. * Add caching capabilities to workflow definition service This commit introduces caching to the workflow definition service, improving the performance for retrieving workflow definitions. 4 new classes have been created (`CachingWorkflowDefinitionService`, `EvictWorkflowDefinitionServiceCache`, `WorkflowDefinitionCacheManager`, and `IWorkflowDefinitionCacheManager`), and several existing classes have been updated to support caching. The caching also includes invalidation mechanisms, ensuring data consistency. * Refactor caching mechanism in workflow definition In the workflow definition module, the explicit caching functionality related to workflow definition versioning has been removed in favor of a more streamlined approach. Additionally, the manner in which services are registered has been altered. As a result, the caching now directly involves the overall workflow definition rather than individual versions, simplifying the caching logic and potentially improving the performance. * Update MassTransitBroker and enable RealTimeWorkflows and SignalRHubs The MassTransitBroker has been updated to Memory from RabbitMq. In addition, the RealTimeWorkflows and UseWorkflowsSignalRHubs features are now enabled in the code. This change will impact how the service communicates and processes real-time requests for workflow operations. * Reformat variable types in HttpFeature The reformatting involves a list of variable types in the HttpFeature module. Each type now appears on a new line for improved readability, making the code easier to maintain and review. * Update HTTP workflows cache invalidation handler XML comment * Remove unnecessary using directives Unnecessary using directives were deleted across several files in the Elsa.Http module. This simplifies the code and will possibly improve execution speed. Specific deletions include those for Encoding, Unicode, Extensions, Collections.Generic, Linq, Text, and Tasks namespaces. * Refactor HttpWorkflowsMiddleware constructor This commit simplifies the HttpWorkflowsMiddleware class constructor. It removes the intermediary variables `_next` and `_options` and directly uses the passed arguments in the constructor. Now, the `next` and `options` parameters are used directly throughout the middleware. * Simplify workflow retrieval in HttpWorkflowsMiddleware This refactoring replaces the use of FindWorkflowDefinitionAsync and MaterializeWorkflowAsync with a single method, FindWorkflowAsync. This simplifies the middleware code and likely improves performance by reducing the number of database queries or service calls required to retrieve a workflow. * Refactor workflow retrieval in HttpBookmarkProcessor Simplified the workflow retrieval process in HttpBookmarkProcessor.cs. Replaced FindWorkflowDefinitionAsync and MaterializeWorkflowAsync methods with a single FindWorkflowAsync call. This reduces the complexity and improves efficiency in retrieving workflow. * Optimize FindWorkflowAsync method in HttpWorkflowsCacheManager Removed redundant lines of code to simplify workflow search functionality. This change simplified the FindWorkflowAsync method by directly calling the FindWorkflowAsync function in the workflowDefinitionService, thus increasing code readability and efficiency. * Refactor Endpoint.cs for workflow retrieval The method for obtaining a workflow in the Endpoint.cs script has been refactored and streamlined. The 'GetWorkflowDefinition' method is replaced by the 'GetWorkflowAsync' method which directly retrieves the workflow, without the intermediate step of materializing the workflow definition. This shortens the code and simplifies the process. * Refactor InputFunctionsDefinitionProvider constructor The constructor for InputFunctionsDefinitionProvider has been simplified by removing unnecessary private fields. Services are now directly used in the method instead of being stored in fields. This improves readability and reduces complexity in the class structure. * Refactor WorkflowInstance with improved state handling Simplified the methods for handling workflow and workflow state in the WorkflowInstance class. The refactoring also included some code clean-ups and variable renaming. The new implementation provides better readability and maintainability of the code by reducing unnecessary lines and improving structuring of objects and responses. * Remove unused IBookmarkManager and update workflow functions IBookmarkManager from ProtoActorWorkflowRuntime.cs file is removed due to its redundant status. Additionally, the "FindAsync" method has been updated to use a cancellation token. Also, annotations were added to the "ExportWorkflowStateAsync" and "ImportWorkflowStateAsync" methods to flag calls to functions that require unreferenced code. * Remove unused ReSharper directive Unused ReSharper directive in the file IndexTriggers.cs was identified and therefore removed. This change makes the code cleaner and easier to read. * Update activity invocation in workflow runtime Updated the DefaultBackgroundActivityInvoker service in the Elsa.Workflows.Runtime module to annotate the ExecuteAsync method with "RequiresUnreferencedCode" attribute. This change is made considering the potential code trimming issue. Additionally, simplified the process of fetching workflow by directly using FindWorkflowAsync method instead of FindWorkflowDefinitionAsync and MaterializeWorkflowAsync methods. * Refactor code to simplify workflow definition loading The code for finding and materializing workflow definitions has been simplified. Instead of loading the definition and materializing it into a workflow in separate steps, a new method called FindWorkflowAsync has been introduced to perform both actions at once. This reduces redundancy and makes the code more readable. * Refactor WorkflowHostFactory to streamline workflow creation This commit simplifies the workflow creation process in WorkflowHostFactory. It removes redundant code and extraneous methods, specifically the overloaded CreateAsync method which used WorkflowDefinition. Now, it directly finds and uses the Workflow instance, thereby simplifying the code base and improving maintainability. * Refactor workflow retrieval in WorkflowInstance.cs Changed the way workflow instances are retrieved from the WorkflowDefinitionService. Instead of obtaining the workflow definition and then materializing the workflow from it, the workflow is directly retrieved using the FindWorkflowAsync function. This simplifies the code and avoids unnecessary null-checks. * Remove unnecessary whitespace in WorkflowInstance.cs An extraneous whitespace character was identified and removed in the WorkflowInstance.cs file. This change contributes towards maintaining clean and readable code in the Elsa.ProtoActor module. * Remove unnecessary comment in ProtoActorWorkflowRuntime The unnecessary comment ("Load the workflow definition.") in the method TryStartWorkflowAsync of the ProtoActorWorkflowRuntime.cs file was removed. This is part of an ongoing effort to keep the codebase clean and readable. * Update workflow management features and handlers Added explicit notification handlers for DeleteWorkflowInstances and RefreshActivityRegistry in WorkflowManagementFeature.cs. Also, renamed RefreshActivityRegistryHandler.cs to RefreshActivityRegistry.cs for better clarity. * Add multiple log record support to workflow execution log stores The major change of this commit is the addition of methods to add multiple log records in the WorkflowExecutionLogStore, across different storage modules such as EntityFramework, MongoDB, Dapper, Elasticsearch and Memory. This ensures consistency and uniform behavior across different storage types. Furthermore, some reformatting and tidying up of the code were undertaken to maintain readability and clarity. * Remove redundant workflow definition check The workflow definition existence check and related service retrieval were removed from HttpWorkflowsMiddleware.cs. It was determined that this check was unnecessary as the workflow definition's existence is guaranteed at this point in the process, reducing redundancy in the code. * Improve cancellation token usage in workflow execution This commit refines the usage of cancellation tokens during the execution of workflows in Elsa.Server and HttpWorkflowsMiddleware. Previously, a cancellation token pair was created before ExecuteWithinTimeoutAsync was called, which limited duration control solely to that method. Now, cancellation tokens are included within ExecuteWithinTimeoutAsync method. This allows the method to observe any cancellation initiated by outer scopes, enhancing control over the timeout of operations. * Add PersistStateAsync method to WorkflowHost A new PersistStateAsync method has been added to the WorkflowHost, which enables the host to directly persist its own state. The method has been integrated into the DefaultWorkflowRuntime and HttpWorkflowsMiddleware. This update eliminates the need to continuously get instances of IWorkflowInstanceManager to save state, which improves efficiency and code readability. * Refactor DefaultAlterationRunner service This update simplifies the DefaultAlterationRunner service, reducing the number of code lines and removing unnecessary references. The workflow materialization step has been merged with the find workflow step, and unused namespaces have been dropped. * Refine wording in IWorkflowHost interface documentation The documentation for the 'CanStartWorkflowAsync' method in the IWorkflowHost interface has been cleaned up. The superfluous "or not" verbiage has been removed, making it easier to understand the method's function. * Remove Redis from DistributedCachingTransport The Redis option was removed from the DistributedCachingTransport enumeration. This transport isn't currently implemented. * Remove 'useDistributedCaching' constant The 'useDistributedCaching' constant was removed from `Program.cs`, and conditional logic was updated to use `distributedCachingTransport != DistributedCachingTransport.None`. A new option 'None' was added to the `DistributedCachingTransport` enum to facilitate this change. * Update package tags in MassTransit project file The package tags in the Elsa.Caching.Distributed.MassTransit project file was updated to consolidate the tags, changing 'mass-transit' to 'masstransit'. This change better aligns with standard naming conventions and improves searchability. * Refactor distributed caching implementation This commit involves an extensive refactor of the distributed caching implementation. Distributed caching related code and resources were moved into an independent 'Elsa.Caching.Distributed' module. The interface 'IDistributedChangeTokenSignaler' was deleted and its functionality was replaced by 'IChangeTokenSignalInvoker'. * Refactor order of parameters in GetOrCreateAsync method The order of parameters in the GetOrCreateAsync method within the CachingWorkflowDefinitionStore class has been changed. This change ensures that the `key` parameter is now first, followed by the `factory` parameter. This improves code readability and aligns with standard coding practices. * Refactor cache retrieval in Workflow service Refactoring was done to streamline the way objects are retrieved from cache in the Workflow service. Duplicated code was condensed into a new `GetFromCacheAsync` method, which is now called in the existing methods, thus increasing maintainability and reducing the possibility of errors. * Update method descriptions and fix comments formatting Method descriptions in various contracts have been updated to more accurately reflect their function regarding record addition and updating in the persistence store. All double comment markers (/// ///) have also been corrected to the standard (///) across multiple classes. * Remove unused caching methods in ModuleExtensions The commit removes the unused methods, `UseMemoryCache` and `UseDistributedCache` from the `ModuleExtensions.cs` file. The removal is part of a wider cleanup and refactoring effort to streamline the codebase and improve legibility. * Remove redundant PrimaryKeyName in DapperWorkflowExecutionLogStore The "PrimaryKeyName" constant was removed in DapperWorkflowExecutionLogStore. This change simplifies the initialization of the '_store' property, reducing unnecessary redundancy and complexity. The refactored code maintains the same functionality but improves readability and maintainability. * Refactor SaveAsync methods in Elsa.Dapper Store The SaveAsync functions have been updated in the Store.cs file inside the Elsa.Dapper module. They now include cancellation token parameters and specify that they add or update records, providing clearer distinction and flexibility. * Refactor store initialization in Elsa.Dapper modules Removed the redundant usage of primary keys during the store initialization across Elsa.Dapper module. Simplified the SaveAsync methods by removing the parameter for primary key, making the code cleaner and more maintainable. This refactoring does not affect the module's functionality. * Refactor UserStore in Elsa.Dapper module The code was adjusted to improve readability within the Elsa.Dapper module's UserStore. Two lines that were previously combined have now been separated into distinct lines, making the code structure more clear. * Refactor constructor arguments in MongoDb module Simplified several classes in the MongoDb module by injecting dependencies directly through the constructor instead of assigning them to private readonly fields. This improves readability and removes unnecessary code lines. Also added JetBrains.Annotations where applicable. * Fix comment syntax in IWorkflowInstanceStore A syntax error in the comments for the method SaveManyAsync (in IWorkflowInstanceStore interface) has been corrected. This change ensures that the remarks section of the method is properly formatted and correctly displayed in documentation. * Remove ComputeBookmarkHash from IHttpWorkflowsCacheManager The ComputeBookmarkHash method was removed from IHttpWorkflowsCacheManager to declutter the interface. The functionality was moved and adapted in the HttpWorkflowsMiddleware class to maintain the original functionality. * Add logging to HttpWorkflowsMiddleware In this update, the HttpWorkflowsMiddleware class has been modified to include logging. Specifically, warning logs have been added to track workflow-related processes and to notify if mentioned bookmarks or workflow instances are not found. * Update consumer configuration in MassTransitFeature This commit modifies the consumer configuration in the MassTransitFeature. Instead of hardcoding the consumer type to DispatchCancelWorkflowsRequestConsumer, it now uses the dynamic consumer type retrieved from the context, making the feature more adaptable for different scenarios. * Change default MassTransitBroker to Memory The default value for the variable useMassTransitBroker in Elsa.Server.Web's Program.cs file has been modified. It has been changed from RabbitMq to Memory to change the message broker used by MassTransit in the application. * Remove Datadog.Trace package from Directory.Packages.props The Datadog.Trace package with version 2.49.0 has been removed from the Directory.Packages.props file. This change reflects the fact that this package is no longer required in our project.
2024-04-10 09:51:40 +00:00
// Content parsers.
.AddSingleton<IHttpContentParser, JsonHttpContentParser>()
.AddSingleton<IHttpContentParser, XmlHttpContentParser>()
.AddSingleton<IHttpContentParser, PlainTextHttpContentParser>()
.AddSingleton<IHttpContentParser, TextHtmlHttpContentParser>()
.AddSingleton<IHttpContentParser, FileHttpContentParser>()
Add caching to workflow runtime and workflow management stores (#5174) * Add caching to workflow runtime and workflow management stores The update introduces caching to workflow runtime and workflow management stores to enhance performance. This is achieved by adding decorators for several stores, which cache records to reduce database fetches. Additionally, a signaler for change tokens allows for cache invalidation when changes occur. The MemoryCache feature has also been updated to include Scrutor for decoration and the caching duration can be configured through the new CachingOptions class. * Refactor WorkflowsMiddleware for HTTP Endpoint bookmarks and triggers The WorkflowsMiddleware has been extensively refactored to handle HTTP Endpoint bookmarks and triggers. This involves breaking down the InvokeAsync method by extracting parts of its functionality into separate helper methods such as FindTriggersAsync and FindBookmarksAsync. Moreover, Assist with authorization checks, workflow execution within request timeout, and handling of workflow faults has been improved to be more efficient and clearly segmented. * Update HTTP endpoint authorization to use Workflow context The authorization process in the AuthenticationBasedHttpEndpointAuthorizationHandler class has been updated to use the Workflow context instead of the WorkflowInstanceId string. The AuthorizeHttpEndpointContext model has been correspondingly changed to include a Workflow property, thereby strengthening the link between authorization and specific workflows. * Add FindAsync methods to trigger and bookmark stores The code adjustments add new FindAsync methods to the trigger and bookmark store contracts as well as all their concrete implementations (MongoDb, Memory and EFCore). These methods support fetching the first record matching a given filter. The adjustments also include minor syntax improvements and the addition of [UsedImplicitly] attributes where needed. * Refactor WorkflowsMiddleware for improved workflow handling The code was refactored to simplify the flow of handling workflows in the WorkflowsMiddleware class. Specifically, the methods to start and resume a workflow have been extracted to improve code readability. Further, handleErrorMiddlewares was also updated to better manage instances where no valid workflows or base paths are found. * Add caching functionality to WorkflowsMiddleware Added IMemoryCache usage in the WorkflowsMiddleware to cache lookup results for workflows and their associated triggers. This will reduce the number of database operations required when searching for workflows, thus improving performance. The cache is maintained for one minute before it is refreshed. * Implement dynamic cache duration for workflows The code has been updated to have a dynamic cache duration for the workflows instead of a hardcoded one minute. By using the CachingOptions service, the cache duration can now be set in the configuration making it more flexible and adaptable to different performance needs. * Add HttpWorkflowsCacheManager for caching HTTP workflows This commit includes the implementation of IHttpWorkflowsCacheManager for caching of HTTP workflows. New handlers have been added to invalidate cache on workflow updates. Additionally, WorkflowsMiddleware has been renamed to HttpWorkflowsMiddleware. * Refactor workflow trigger handling and caching The refactoring includes deletion of `IndexWorkflowTriggersHandler.cs` and creation of `IndexTriggers.cs` thus revising the workflow trigger indexing approach. Also, revamped the `ITriggerIndexer` interface which now handles deletion of triggers with specific workflow and filter. Furthermore, the caching mechanism in `HttpWorkflowsCacheManager.cs` is modified to handle eviction of workflow definitions and triggers separately boosting its efficiency. * Add summary to IndexedWorkflowTriggers A summary has been added to the 'IndexedWorkflowTriggers' class, providing a brief description. This description outlines that it represents a collection of indexed workflow triggers, promoting clearer understanding for future reference. * Refactor memory caching feature into separate module This commit separates the memory caching feature from the Elsa.Common module into a distinct Elsa.Caching module. This includes moving and renaming related files, such as the MemoryCacheFeature class and associated dependencies. The references in other modules and in the main solution file have been updated accordingly to include the new Elsa.Caching module. * Add distributed caching and update async methods Introduced a distributed caching feature with extensible change token signal publishing. Updated various cache-related methods to be asynchronous for improved performance and responsiveness. Also updated some workflow identity references for clarity. * Add distributed caching with MassTransit support This addition includes the implementation of a distributed caching system with MassTransit transport. The changes introduce necessary interfaces and services, new distributed caching feature along with the support for MassTransit as a transport option. Moreover, the instance management feature has been renamed to clustering feature for better clarity. * Refactor queue naming and scope of MassTransitChangeTokenSignalPublisher Queue name construction is adjusted in the RabbitMqServiceBusFeature and AzureServiceBusFeature modules for better organization and readability. MassTransitChangeTokenSignalPublisher is now a singleton service, ensuring the signal publisher can be shared across the application, increasing efficiency and performance. Also, introduced use of DistributedCacheFeature in MassTransitDistributedCacheFeature module for better modularization. * Add caching capabilities to workflow definition service This commit introduces caching to the workflow definition service, improving the performance for retrieving workflow definitions. 4 new classes have been created (`CachingWorkflowDefinitionService`, `EvictWorkflowDefinitionServiceCache`, `WorkflowDefinitionCacheManager`, and `IWorkflowDefinitionCacheManager`), and several existing classes have been updated to support caching. The caching also includes invalidation mechanisms, ensuring data consistency. * Refactor caching mechanism in workflow definition In the workflow definition module, the explicit caching functionality related to workflow definition versioning has been removed in favor of a more streamlined approach. Additionally, the manner in which services are registered has been altered. As a result, the caching now directly involves the overall workflow definition rather than individual versions, simplifying the caching logic and potentially improving the performance. * Update MassTransitBroker and enable RealTimeWorkflows and SignalRHubs The MassTransitBroker has been updated to Memory from RabbitMq. In addition, the RealTimeWorkflows and UseWorkflowsSignalRHubs features are now enabled in the code. This change will impact how the service communicates and processes real-time requests for workflow operations. * Reformat variable types in HttpFeature The reformatting involves a list of variable types in the HttpFeature module. Each type now appears on a new line for improved readability, making the code easier to maintain and review. * Update HTTP workflows cache invalidation handler XML comment * Remove unnecessary using directives Unnecessary using directives were deleted across several files in the Elsa.Http module. This simplifies the code and will possibly improve execution speed. Specific deletions include those for Encoding, Unicode, Extensions, Collections.Generic, Linq, Text, and Tasks namespaces. * Refactor HttpWorkflowsMiddleware constructor This commit simplifies the HttpWorkflowsMiddleware class constructor. It removes the intermediary variables `_next` and `_options` and directly uses the passed arguments in the constructor. Now, the `next` and `options` parameters are used directly throughout the middleware. * Simplify workflow retrieval in HttpWorkflowsMiddleware This refactoring replaces the use of FindWorkflowDefinitionAsync and MaterializeWorkflowAsync with a single method, FindWorkflowAsync. This simplifies the middleware code and likely improves performance by reducing the number of database queries or service calls required to retrieve a workflow. * Refactor workflow retrieval in HttpBookmarkProcessor Simplified the workflow retrieval process in HttpBookmarkProcessor.cs. Replaced FindWorkflowDefinitionAsync and MaterializeWorkflowAsync methods with a single FindWorkflowAsync call. This reduces the complexity and improves efficiency in retrieving workflow. * Optimize FindWorkflowAsync method in HttpWorkflowsCacheManager Removed redundant lines of code to simplify workflow search functionality. This change simplified the FindWorkflowAsync method by directly calling the FindWorkflowAsync function in the workflowDefinitionService, thus increasing code readability and efficiency. * Refactor Endpoint.cs for workflow retrieval The method for obtaining a workflow in the Endpoint.cs script has been refactored and streamlined. The 'GetWorkflowDefinition' method is replaced by the 'GetWorkflowAsync' method which directly retrieves the workflow, without the intermediate step of materializing the workflow definition. This shortens the code and simplifies the process. * Refactor InputFunctionsDefinitionProvider constructor The constructor for InputFunctionsDefinitionProvider has been simplified by removing unnecessary private fields. Services are now directly used in the method instead of being stored in fields. This improves readability and reduces complexity in the class structure. * Refactor WorkflowInstance with improved state handling Simplified the methods for handling workflow and workflow state in the WorkflowInstance class. The refactoring also included some code clean-ups and variable renaming. The new implementation provides better readability and maintainability of the code by reducing unnecessary lines and improving structuring of objects and responses. * Remove unused IBookmarkManager and update workflow functions IBookmarkManager from ProtoActorWorkflowRuntime.cs file is removed due to its redundant status. Additionally, the "FindAsync" method has been updated to use a cancellation token. Also, annotations were added to the "ExportWorkflowStateAsync" and "ImportWorkflowStateAsync" methods to flag calls to functions that require unreferenced code. * Remove unused ReSharper directive Unused ReSharper directive in the file IndexTriggers.cs was identified and therefore removed. This change makes the code cleaner and easier to read. * Update activity invocation in workflow runtime Updated the DefaultBackgroundActivityInvoker service in the Elsa.Workflows.Runtime module to annotate the ExecuteAsync method with "RequiresUnreferencedCode" attribute. This change is made considering the potential code trimming issue. Additionally, simplified the process of fetching workflow by directly using FindWorkflowAsync method instead of FindWorkflowDefinitionAsync and MaterializeWorkflowAsync methods. * Refactor code to simplify workflow definition loading The code for finding and materializing workflow definitions has been simplified. Instead of loading the definition and materializing it into a workflow in separate steps, a new method called FindWorkflowAsync has been introduced to perform both actions at once. This reduces redundancy and makes the code more readable. * Refactor WorkflowHostFactory to streamline workflow creation This commit simplifies the workflow creation process in WorkflowHostFactory. It removes redundant code and extraneous methods, specifically the overloaded CreateAsync method which used WorkflowDefinition. Now, it directly finds and uses the Workflow instance, thereby simplifying the code base and improving maintainability. * Refactor workflow retrieval in WorkflowInstance.cs Changed the way workflow instances are retrieved from the WorkflowDefinitionService. Instead of obtaining the workflow definition and then materializing the workflow from it, the workflow is directly retrieved using the FindWorkflowAsync function. This simplifies the code and avoids unnecessary null-checks. * Remove unnecessary whitespace in WorkflowInstance.cs An extraneous whitespace character was identified and removed in the WorkflowInstance.cs file. This change contributes towards maintaining clean and readable code in the Elsa.ProtoActor module. * Remove unnecessary comment in ProtoActorWorkflowRuntime The unnecessary comment ("Load the workflow definition.") in the method TryStartWorkflowAsync of the ProtoActorWorkflowRuntime.cs file was removed. This is part of an ongoing effort to keep the codebase clean and readable. * Update workflow management features and handlers Added explicit notification handlers for DeleteWorkflowInstances and RefreshActivityRegistry in WorkflowManagementFeature.cs. Also, renamed RefreshActivityRegistryHandler.cs to RefreshActivityRegistry.cs for better clarity. * Add multiple log record support to workflow execution log stores The major change of this commit is the addition of methods to add multiple log records in the WorkflowExecutionLogStore, across different storage modules such as EntityFramework, MongoDB, Dapper, Elasticsearch and Memory. This ensures consistency and uniform behavior across different storage types. Furthermore, some reformatting and tidying up of the code were undertaken to maintain readability and clarity. * Remove redundant workflow definition check The workflow definition existence check and related service retrieval were removed from HttpWorkflowsMiddleware.cs. It was determined that this check was unnecessary as the workflow definition's existence is guaranteed at this point in the process, reducing redundancy in the code. * Improve cancellation token usage in workflow execution This commit refines the usage of cancellation tokens during the execution of workflows in Elsa.Server and HttpWorkflowsMiddleware. Previously, a cancellation token pair was created before ExecuteWithinTimeoutAsync was called, which limited duration control solely to that method. Now, cancellation tokens are included within ExecuteWithinTimeoutAsync method. This allows the method to observe any cancellation initiated by outer scopes, enhancing control over the timeout of operations. * Add PersistStateAsync method to WorkflowHost A new PersistStateAsync method has been added to the WorkflowHost, which enables the host to directly persist its own state. The method has been integrated into the DefaultWorkflowRuntime and HttpWorkflowsMiddleware. This update eliminates the need to continuously get instances of IWorkflowInstanceManager to save state, which improves efficiency and code readability. * Refactor DefaultAlterationRunner service This update simplifies the DefaultAlterationRunner service, reducing the number of code lines and removing unnecessary references. The workflow materialization step has been merged with the find workflow step, and unused namespaces have been dropped. * Refine wording in IWorkflowHost interface documentation The documentation for the 'CanStartWorkflowAsync' method in the IWorkflowHost interface has been cleaned up. The superfluous "or not" verbiage has been removed, making it easier to understand the method's function. * Remove Redis from DistributedCachingTransport The Redis option was removed from the DistributedCachingTransport enumeration. This transport isn't currently implemented. * Remove 'useDistributedCaching' constant The 'useDistributedCaching' constant was removed from `Program.cs`, and conditional logic was updated to use `distributedCachingTransport != DistributedCachingTransport.None`. A new option 'None' was added to the `DistributedCachingTransport` enum to facilitate this change. * Update package tags in MassTransit project file The package tags in the Elsa.Caching.Distributed.MassTransit project file was updated to consolidate the tags, changing 'mass-transit' to 'masstransit'. This change better aligns with standard naming conventions and improves searchability. * Refactor distributed caching implementation This commit involves an extensive refactor of the distributed caching implementation. Distributed caching related code and resources were moved into an independent 'Elsa.Caching.Distributed' module. The interface 'IDistributedChangeTokenSignaler' was deleted and its functionality was replaced by 'IChangeTokenSignalInvoker'. * Refactor order of parameters in GetOrCreateAsync method The order of parameters in the GetOrCreateAsync method within the CachingWorkflowDefinitionStore class has been changed. This change ensures that the `key` parameter is now first, followed by the `factory` parameter. This improves code readability and aligns with standard coding practices. * Refactor cache retrieval in Workflow service Refactoring was done to streamline the way objects are retrieved from cache in the Workflow service. Duplicated code was condensed into a new `GetFromCacheAsync` method, which is now called in the existing methods, thus increasing maintainability and reducing the possibility of errors. * Update method descriptions and fix comments formatting Method descriptions in various contracts have been updated to more accurately reflect their function regarding record addition and updating in the persistence store. All double comment markers (/// ///) have also been corrected to the standard (///) across multiple classes. * Remove unused caching methods in ModuleExtensions The commit removes the unused methods, `UseMemoryCache` and `UseDistributedCache` from the `ModuleExtensions.cs` file. The removal is part of a wider cleanup and refactoring effort to streamline the codebase and improve legibility. * Remove redundant PrimaryKeyName in DapperWorkflowExecutionLogStore The "PrimaryKeyName" constant was removed in DapperWorkflowExecutionLogStore. This change simplifies the initialization of the '_store' property, reducing unnecessary redundancy and complexity. The refactored code maintains the same functionality but improves readability and maintainability. * Refactor SaveAsync methods in Elsa.Dapper Store The SaveAsync functions have been updated in the Store.cs file inside the Elsa.Dapper module. They now include cancellation token parameters and specify that they add or update records, providing clearer distinction and flexibility. * Refactor store initialization in Elsa.Dapper modules Removed the redundant usage of primary keys during the store initialization across Elsa.Dapper module. Simplified the SaveAsync methods by removing the parameter for primary key, making the code cleaner and more maintainable. This refactoring does not affect the module's functionality. * Refactor UserStore in Elsa.Dapper module The code was adjusted to improve readability within the Elsa.Dapper module's UserStore. Two lines that were previously combined have now been separated into distinct lines, making the code structure more clear. * Refactor constructor arguments in MongoDb module Simplified several classes in the MongoDb module by injecting dependencies directly through the constructor instead of assigning them to private readonly fields. This improves readability and removes unnecessary code lines. Also added JetBrains.Annotations where applicable. * Fix comment syntax in IWorkflowInstanceStore A syntax error in the comments for the method SaveManyAsync (in IWorkflowInstanceStore interface) has been corrected. This change ensures that the remarks section of the method is properly formatted and correctly displayed in documentation. * Remove ComputeBookmarkHash from IHttpWorkflowsCacheManager The ComputeBookmarkHash method was removed from IHttpWorkflowsCacheManager to declutter the interface. The functionality was moved and adapted in the HttpWorkflowsMiddleware class to maintain the original functionality. * Add logging to HttpWorkflowsMiddleware In this update, the HttpWorkflowsMiddleware class has been modified to include logging. Specifically, warning logs have been added to track workflow-related processes and to notify if mentioned bookmarks or workflow instances are not found. * Update consumer configuration in MassTransitFeature This commit modifies the consumer configuration in the MassTransitFeature. Instead of hardcoding the consumer type to DispatchCancelWorkflowsRequestConsumer, it now uses the dynamic consumer type retrieved from the context, making the feature more adaptable for different scenarios. * Change default MassTransitBroker to Memory The default value for the variable useMassTransitBroker in Elsa.Server.Web's Program.cs file has been modified. It has been changed from RabbitMq to Memory to change the message broker used by MassTransit in the application. * Remove Datadog.Trace package from Directory.Packages.props The Datadog.Trace package with version 2.49.0 has been removed from the Directory.Packages.props file. This change reflects the fact that this package is no longer required in our project.
2024-04-10 09:51:40 +00:00
2023-01-24 21:39:31 +00:00
// HTTP content factories.
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
.AddScoped<IHttpContentFactory, TextContentFactory>()
.AddScoped<IHttpContentFactory, JsonContentFactory>()
.AddScoped<IHttpContentFactory, XmlContentFactory>()
.AddScoped<IHttpContentFactory, FormUrlEncodedHttpContentFactory>()
2023-02-15 11:09:45 +00:00
// Activity property options providers.
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
.AddScoped<IPropertyUIHandler, HttpContentTypeOptionsProvider>()
Add Elsa.Kafka Module for Kafka Integration with Message Sending and Receiving Activities (#6108) * Add Kafka module with integration and example setup Introduced the Kafka module providing consumer integration and activities into the project. This includes new classes for consumer handling, configuration, and activities. An example setup using Docker Compose is also added to facilitate development and testing. * Refactor KafkaTransportMessage to inline Timestamp namespace Simplify the namespace usage for the Timestamp type within the KafkaTransportMessage record. This change eliminates the need for a separate using directive for Timestamp, enhancing code readability and maintainability. * Add support for handling Kafka transport messages This commit introduces the capability to handle and trigger workflows based on Kafka transport messages. It adds a new handler, notifications, and updates the message stimulus to include correlating fields. Additionally, the Kafka consumers are now managed more modularly with updated startup tasks and mediator integration. * Enable Kafka integration and fix Kafka options naming Added support for Kafka integration in Elsa.Server.Web by setting up Kafka configurations in appsettings.json and updating Program.cs. Also, renamed `ConsumerConfigs` to `ConsumerDefinitions` in Kafka options for clarity. * Add consumer definition enumeration and dropdown support Introduced `IConsumerDefinitionEnumerator` for managing consumer definitions across providers and implemented in `ConsumerDefinitionEnumerator` class. Enhanced `KafkaFeature` to register these services and updated the `MessageReceived` activity to use a dropdown UI hint for consuming definitions. Improved `StartConsumersTask` by refactoring consumer definition retrieval logic. * Add SendMessage activity and refine Kafka messaging Introduce a new SendMessage activity for Kafka, enabling message publishing to specific topics. Refine KafkaTransportMessage model by removing headers and timestamp fields. Adjust the StimulusSender logic to streamline the bookmark queuing process and fix key-value pairing in dropdown options. Update appsettings for corrected Kafka bootstrap server and topic configurations. * Add producer and topic management support Introduced interfaces and implementations for managing producer and topic definitions along with their respective enumerators and list providers. Updated `SendMessage` activity to include producer selection and refactored consumer definition providers for better consistency. * Refactor Kafka configuration property names Renamed Kafka configuration properties for better consistency and readability across the codebase. Updated property names from `ProducerDefinitions` to `Producers`, `ConsumerDefinitions` to `Consumers`, and `TopicDefinitions` to `Topics`. Added missing input attribute in `SendMessage.cs` and registered additional handlers in `KafkaFeature.cs`. * Add custom serializers for Kafka message handling Introduced `DefaultSerializers` class for custom serialization and deserialization of Kafka messages. Updated `MessageReceived` and `SendMessage` activities to use these custom serializers, and modified `KafkaOptions` to include them. * Fix ExpandoObject serialization method parameter Changed the serialization type from `ExpandoObject` to the actual type of the object to ensure proper serialization. This ensures that derived types are correctly handled during the serialization process. * Add Producer and Consumer workflows for Kafka Introduced two new workflows: `ProducerWorkflow` and `ConsumerWorkflow` for handling Kafka messages. Updated `DefaultSerializers` to use camelCase property naming and modified `appsettings.json` to include `topic-2` and format entries. * Add JSON serialization to log output in ConsumerWorkflow This change enhances the log output by serializing messages to JSON format before writing them. The addition of System.Text.Json ensures that the message content is presented in a structured and standardized format in logs. * Add correlation strategies and update Kafka features Implemented HeaderCorrelationStrategy and NullCorrelationStrategy, and updated KafkaFeature to support customizable correlation strategies. Added correlation ID handling to Kafka transport messages and updated config and handlers accordingly. * Add tenant accessor to ConsumerDefinitionWorkflowContextProvider Integrated ITenantAccessor to the provider to support tenant-specific context loading. Updated the constructor and LoadAsync method to retrieve the tenant information and use it for context-specific operations. * Switch to MySQL and disable Kafka This commit changes the SQL database provider from SQLite to MySQL and disables Kafka use. It also includes necessary adjustments such as adding MySQL handling in configuration and connection setups, updating `docker-compose` to include MySQL services, and referencing MySQL projects in the `.csproj` file. * Add UI property handlers to multiple features This commit introduces various UI property handlers across several features such as Python, JavaScript, CSharp, and Workflow features to enhance user interface property handling. It also updates the property UI handler resolution logic to better manage cases where providers are not available. Furthermore, adjustments were made in the server configuration to switch database providers and enable Kafka. * Refactor property UI handler retrieval logic Modified the logic to fetch property UI handlers by preloading them into a list and then filtering. This change improves readability and potentially performance by reducing repetitive service provider calls. * Incremental work on Kafka workers and predicate evaluation * Merge BookmarkInvoker with BookmarkResumer * Register IWorkerManager * Change lifetime scope of WorkerManager to Singleton * **Introduce topic subscription handling for Kafka workers** Added `IWorkerTopicSubscriber` interface and its implementation for managing topic subscriptions. Enhanced workers to bind triggers and bookmarks dynamically based on existing data. Updated several classes and methods to support topic-based subscriptions and headers. * Refactor trigger matching logic. Extract trigger matching conditions into `IsMatchAsync` method for reuse. This enhances code maintainability and readability by reducing redundancy. The new `GetTopic` helper method isolates the topic retrieval logic. * Add Name property to MassTransitActivityTypeProvider This commit inserts the Name property in the returned object within the MassTransitActivityTypeProvider class. It ensures that the typeName is included, providing a clearer definition of the activity type. * Add handling for deleted bookmarks and refactor bookmark removal Added a new event handler for `BookmarksDeleted` to ensure removed bookmarks are processed correctly. Refactored the bookmark removal logic into a helper method to reduce code duplication and streamline the workflow. * Switch to asynchronous bookmark queue processing Refactored the `TriggerWorkflows` handler to use `IBookmarkQueue` instead of directly invoking the `IBookmarkResumer`. This change aims to improve scalability by queueing bookmark resumption requests, enabling better load distribution and async processing. Added necessary helpers and configuration options to support this functionality. * Remove unused IBookmarkResumer dependency Simplify the constructor by removing the unused IBookmarkResumer dependency. This cleanup reduces potential confusion and improves code maintainability without impacting functionality. * Add support for local message processing Introduced an `IsLocal` property to `MessageReceivedStimulus` for determining if the message event is local to a specific workflow instance. Updated `BookmarkBinding` and related handler methods to utilize `CorrelationId` for local event matching. Removed unused `CorrelatingFields` from `MessageReceived` activity. * Add nullability checks to IWorker retrieval methods Updated `GetWorker` methods to return nullable `IWorker` to handle cases where a worker might not exist. Modified code to include null checks and conditional operations to prevent potential null reference exceptions when accessing worker methods. * Add filtering based on activity type name for triggers and bookmarks This commit introduces filtering for triggers and bookmarks based on the `MessageReceived` activity type name. It also adds an option to mark messages as local in the `SendMessage` activity, where local messages are delivered to the current workflow instance only. These changes help enhance the management and targeted delivery of messages within the workflow framework. * Add new Kafka topics and clean up producers config New topics "topic-3" and "topic-4" were added to the Kafka settings. Unused topic references were removed from the producers configuration to simplify and improve clarity. * Add predicate to KafkaConsumerActivity in ConsumerWorkflow Introduced a predicate to the KafkaConsumerActivity using JavaScript expressions to filter messages based on OrderId. This ensures only relevant messages are processed in the workflow.
2024-11-18 12:42:54 +00:00
.AddScoped<IPropertyUIHandler, HttpEndpointPathUIHandler>()
.AddScoped(_httpEndpointBasePathProvider)
// Port resolvers.
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
.AddScoped<IActivityResolver, SendHttpRequestActivityResolver>()
// HTTP endpoint handlers.
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
.AddScoped<AuthenticationBasedHttpEndpointAuthorizationHandler>()
.AddScoped<AllowAnonymousHttpEndpointAuthorizationHandler>()
.AddScoped<DefaultHttpEndpointFaultHandler>()
Implement multitenant HTTP routing (#6031) * Add tenant awareness to bookmark handling and route resolution Added tenant ID support across various components, including bookmark updates, route resolution, and middleware processing. This ensures that bookmark and route operations can now appropriately handle tenant-specific data, improving the system's multitenancy capabilities. * Add Multitenant HTTP Routing feature to Tenants module Introduced a new MultitenantHttpRoutingFeature class to the Elsa.Tenants.AspNetCore module, enhancing the tenant resolution capabilities. Moved RoutePrefixTenantResolver from Elsa.Http to Elsa.Tenants.AspNetCore and updated relevant project references and namespaces accordingly. This refactor improves modularity and separation of concerns between HTTP and tenancy features. * Refactor route handling and tenant configuration Removed redundant `RouteTableExtensions` and replaced with new route providers and updaters, enhancing flexibility and modularity. Introduced tenant-specific HTTP endpoint configurations for better customization and configuration management. * Rename HttpEndpointBookmarkStimulus to HttpEndpointBookmarkPayload Refactor various classes and methods to reflect the renaming from `HttpEndpointBookmarkStimulus` to `HttpEndpointBookmarkPayload`. Add and configure new extension methods for tenant route handling, update the route provider to support multi-tenancy, and adjust the tenants provider to bind configuration properly. * Add HeaderTenantResolver and refactor Http namespace. Introduce HeaderTenantResolver to resolve tenants via HTTP headers. Refactor multiple classes and interfaces to move from the Elsa.Http.Models namespace directly into Elsa.Http for clarity and consistency. * Add Host-based tenant resolution Implemented a HostTenantResolver to resolve tenants based on the request's host and updated tenant configurations with host information. Modified the tenant resolver pipeline and added the new host resolver to the service registrations. * Add tenant-aware caching and accessor support Enhanced caching by incorporating tenant identifiers into cache keys for more granular cache management. Introduced ITenantAccessor dependencies in various services to retrieve the current tenant information. This ensures that cache entries are correctly isolated per tenant. * Reorder tenant resolvers for pipeline setup. Reordered the tenant resolvers in the pipeline to prioritize HostTenantResolver before RoutePrefixTenantResolver. This ensures that tenant resolution is correctly aligned with host-based resolving before checking the route prefix. * Remove unused imports This commit eliminates redundant `using` directives across multiple files to streamline the codebase. This cleanup helps improve code readability and maintainability by removing unnecessary dependencies.
2024-10-14 19:27:11 +00:00
.AddScoped<DefaultHttpEndpointRoutesProvider>()
.AddScoped<DefaultHttpEndpointBasePathProvider>()
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
.AddScoped(HttpEndpointWorkflowFaultHandler)
.AddScoped(HttpEndpointAuthorizationHandler)
Implement multitenant HTTP routing (#6031) * Add tenant awareness to bookmark handling and route resolution Added tenant ID support across various components, including bookmark updates, route resolution, and middleware processing. This ensures that bookmark and route operations can now appropriately handle tenant-specific data, improving the system's multitenancy capabilities. * Add Multitenant HTTP Routing feature to Tenants module Introduced a new MultitenantHttpRoutingFeature class to the Elsa.Tenants.AspNetCore module, enhancing the tenant resolution capabilities. Moved RoutePrefixTenantResolver from Elsa.Http to Elsa.Tenants.AspNetCore and updated relevant project references and namespaces accordingly. This refactor improves modularity and separation of concerns between HTTP and tenancy features. * Refactor route handling and tenant configuration Removed redundant `RouteTableExtensions` and replaced with new route providers and updaters, enhancing flexibility and modularity. Introduced tenant-specific HTTP endpoint configurations for better customization and configuration management. * Rename HttpEndpointBookmarkStimulus to HttpEndpointBookmarkPayload Refactor various classes and methods to reflect the renaming from `HttpEndpointBookmarkStimulus` to `HttpEndpointBookmarkPayload`. Add and configure new extension methods for tenant route handling, update the route provider to support multi-tenancy, and adjust the tenants provider to bind configuration properly. * Add HeaderTenantResolver and refactor Http namespace. Introduce HeaderTenantResolver to resolve tenants via HTTP headers. Refactor multiple classes and interfaces to move from the Elsa.Http.Models namespace directly into Elsa.Http for clarity and consistency. * Add Host-based tenant resolution Implemented a HostTenantResolver to resolve tenants based on the request's host and updated tenant configurations with host information. Modified the tenant resolver pipeline and added the new host resolver to the service registrations. * Add tenant-aware caching and accessor support Enhanced caching by incorporating tenant identifiers into cache keys for more granular cache management. Introduced ITenantAccessor dependencies in various services to retrieve the current tenant information. This ensures that cache entries are correctly isolated per tenant. * Reorder tenant resolvers for pipeline setup. Reordered the tenant resolvers in the pipeline to prioritize HostTenantResolver before RoutePrefixTenantResolver. This ensures that tenant resolution is correctly aligned with host-based resolving before checking the route prefix. * Remove unused imports This commit eliminates redundant `using` directives across multiple files to streamline the codebase. This cleanup helps improve code readability and maintainability by removing unnecessary dependencies.
2024-10-14 19:27:11 +00:00
.AddScoped(_httpEndpointRouteProvider)
Add multitenancy support for background tasks (#6059) * Remove initial migrations Deleted obsolete initial migration files from multiple databases: MySQL, SQL Server, SQLite, and PostgreSQL. This cleanup helps maintain a streamlined and updated migration history. * Add Document base class and create tenant-specific indices Introduced a new abstract `Document` base class to unify common properties. Implemented tenant-specific unique indices across multiple collections by including `TenantId` alongside `Id` to ensure uniqueness within tenant scopes. * Remove outdated migration files Deleted various migration files under MySql, PostgreSql, Sqlite, and SqlServer directories. This cleanup removes unnecessary schema definitions and helps to streamline the codebase. * Refactor workflow identity assignment logic Streamline workflow identity handling to ensure consistent assignment of Id, DefinitionId, and TenantId values. This change integrates tenant prefix and version suffix cleanly, enhancing clarity and maintainability. * Enable multitenancy support Added configuration for a new tenant (tenant-1) in appsettings.json and enabled multitenancy feature in Program.cs. This change allows the application to support multiple tenants, with specific configurations for each. * Refactor route table update to run as startup task Replaced `UpdateRouteTableHostedService` with `UpdateRouteTableStartupTask` to ensure route table updates are executed during application startup instead of as a hosted service. Updated configuration in `HttpFeature` and adjusted trigger validation logic in `ValidateWorkflowRequestHandler`. * Add recurring task scheduling and single-node task support. Introduce `IntervalExpressionType`, recurring task scheduling classes, and `SingleNodeTaskAttribute`. Update `RecurringTasksRunner` to handle schedules and add single-node task logic to `StartupTasksRunner`. Ensure proper namespace changes and configure sample recurring tasks. * Refactor recurring tasks scheduling system Replaced existing scheduling classes with a more modular and granular approach. Introduced new classes and interfaces like `ISchedule`, `CronSchedule`, `IntervalSchedule`, and `RecurringTaskScheduleManager`. Updated related methods and code to comply with the new design. * Refactor background task management Removed `ExpiredSecretsHostedService` and refactored it into a recurring task. Introduced `TaskExecutor` for shared task execution logic. Updated and renamed feature classes to better represent their purpose, improving task scheduling and execution management. * Add BackgroundTask abstract class to Elsa.Common module This new abstract class implements the IBackgroundTask interface with default methods for executing, starting, and stopping tasks asynchronously. It provides a basic framework for background task management in the Elsa.Common module. * Switch to CreateAsyncScope in DefaultTenantScopeFactory Updated the CreateScope method to use CreateAsyncScope instead of CreateScope. This change improves asynchronous handling of service scopes within the DefaultTenantScopeFactory class. * Add tenant handling and move StartWorkers background task Introduce ITenantAccessor in Worker class for multitenancy support. Rename and relocate StartWorkers service to BackgroundTask, ensuring smoother workflow initialization. Also, update the configuration to support Azure Service Bus connection string. * Add tenant support and refactor ProtoActor client Integrated ITenantAccessor in ProtoActorWorkflowClient class to handle multi-tenancy. Refactored methods in the client to support custom headers and added async disposable pattern in various services for proper resource management. Additionally, enabled Azure Service Bus and updated related documentation. * Add support for custom headers in ProtoActor grain methods Introduced a T4 template to generate grain methods with custom headers, enabling the use of tenant ID in requests. Updated `ProtoActorWorkflowClient` to employ these methods, removing redundant code and directly utilizing the client for various workflow operations. * Add tenant middleware to MassTransit configurations Introduced multitenancy middleware for MassTransit message handling. Added new message type `OrderReceived` and updated RabbitMQ setup in Elsa Server. Applied middleware to configure tenant data on send, publish, and consume operations. * Add new product workflow and streamline ID handling Introduced a new `RequestResponseWorkflow` for handling product requests. Simplified ID handling in `WorkflowBuilder` and `ClrWorkflowsProvider` by defaulting to empty strings and adding a version prefix. Enhanced `HttpWorkflowsMiddleware` to correctly parse full request paths. * Remove redundant files and update configuration Deleted unused files `Product.cs` and `RequestResponseWorkflow.cs` to clean up the codebase. Updated `Program.cs` configuration: switched MassTransitBroker to Memory and disabled multitenancy. * Remove MultitenantRecurringTaskService and update AzureServiceBus Removed `MultitenantRecurringTaskService` and adjusted related code for Azure Service Bus to work without it. This includes removal of tenant accessor dependency from `Worker` and cleanup of service configuration flags in `Program.cs`. * Increase signal wait timeout to 10000 milliseconds. Extended the default timeout for signal awaiting methods from 8000 to 10000 milliseconds. This change ensures more flexible and resilient waiting periods, reducing timeout occurrences in scenarios with longer processing times. * Refactor scheduling service to be a background task Renamed `CreateSchedulesHostedService` to `CreateSchedulesBackgroundTask` and refactored it to inherit from `BackgroundTask` instead of `BackgroundService`. Simplified the constructor by injecting the required dependencies directly, eliminating the need for a scoped factory. * Refactor workflow version suffix formatting Changed the version suffix format from `:v{version}` to `v{version}` and adjusted the ID concatenation accordingly. This improves consistency and readability of workflow IDs. * Enable multitenancy support in Quartz scheduler Added `TenantJobListener` to inject tenant context into jobs. Modified `QuartzWorkflowScheduler` to incorporate tenant IDs into job data maps and adjusted the configuration to acknowledge multitenancy settings. * Remove ConfigureSchedulerHostedService and TenantJobListener Consolidated tenant resolution logic into JobExecutionExtensions class. Updated ResumeWorkflowJob and RunWorkflowJob to use the new extension method for tenant retrieval. This simplifies the QuartzSchedulerFeature setup by removing the hosted service configuration. * Refactor HTTP feature and update route table task Move 'UpdateRouteTableStartupTask' from 'HostedServices' to 'Tasks' and update dependency injection configurations accordingly. Simplify 'DefaultRouteTableUpdater' by removing unnecessary options and tenant-agnostic settings from filters. * Disable multitenancy in Program.cs The useMultitenancy flag has been changed from true to false. This update affects the Elsa.Server.Web application configuration. * Simplify variable usage in HttpWorkflowsMiddleware Replaced 'fullPath' variable with 'path' to streamline code. This change enhances readability by reducing redundancy and ensures consistency in variable naming throughout the method. * Enable multitenancy and refactor tenant handling logic Enable multitenancy in the application and refactor tenant handling logic to use ITenantFinder and ITenantContextInitializer interfaces. Added header constants, updated middleware to use these interfaces, and moved extension methods to the appropriate namespace. * Add input validation to user registration form Implemented checks to ensure all required fields are filled and that input data adheres to format requirements. This change reduces errors and enhances form reliability. * Remove unused import from TenantPrefixHttpEndpointRoutesProvider This change cleans up the code by removing an unnecessary import statement. It improves code readability and reduces clutter, making future maintenance easier. The functionality remains unchanged. * Rename filter scope to "tenantPublish" in Probe method Updated the Probe method in TenantPublishMiddleware.cs to use "tenantPublish" instead of "tenantSend" for better clarity. Ensures consistency with the method's context and aligns with naming conventions. * Refactor: Remove extraneous whitespace Eliminate unnecessary whitespace in ProtoActorWorkflowClient.cs for cleaner code. This change helps maintain consistent formatting and improves readability. * Refactor DefaultRegistriesPopulator for cleaner initialization Converted constructor to use read-only fields directly, removing unnecessary instance variables. This change simplifies the code by reducing redundancy and making the constructor cleaner.
2024-10-28 18:38:24 +00:00
// Startup tasks.
.AddStartupTask<UpdateRouteTableStartupTask>()
// Downloadable content handlers.
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
.AddScoped<IDownloadableManager, DefaultDownloadableManager>()
.AddScoped<IDownloadableContentHandler, MultiDownloadableContentHandler>()
.AddScoped<IDownloadableContentHandler, BinaryDownloadableContentHandler>()
.AddScoped<IDownloadableContentHandler, StreamDownloadableContentHandler>()
.AddScoped<IDownloadableContentHandler, FormFileDownloadableContentHandler>()
.AddScoped<IDownloadableContentHandler, DownloadableDownloadableContentHandler>()
.AddScoped<IDownloadableContentHandler, UrlDownloadableContentHandler>()
.AddScoped<IDownloadableContentHandler, StringDownloadableContentHandler>()
.AddScoped<IDownloadableContentHandler, HttpFileDownloadableContentHandler>()
//Trigger payload validators.
.AddTriggerPayloadValidator<HttpEndpointTriggerPayloadValidator, HttpEndpointBookmarkPayload>()
// File caches.
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
.AddScoped(FileCache)
.AddScoped<ZipManager>()
// AuthenticationBasedHttpEndpointAuthorizationHandler requires Authorization services.
// We could consider creating a separate module for installing authorization services.
.AddAuthorization();
// HTTP clients.
Services.AddHttpClient<IFileDownloader, HttpClientFileDownloader>();
// Add selectors.
foreach (var httpCorrelationIdSelectorType in HttpCorrelationIdSelectorTypes)
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
Services.AddScoped(typeof(IHttpCorrelationIdSelector), httpCorrelationIdSelectorType);
foreach (var httpWorkflowInstanceIdSelectorType in HttpWorkflowInstanceIdSelectorTypes)
Merge scope change into main (#4738) * Feature/change singleton to scope (#4635) * feat(scoped): move dependencies to scoped instead of singleton if possible. * fix(scoped): Timer and LiveTest * fix(scoped): change scope of python and csharp features * fix(scoped): remove FireAndForgetStrategy and replace if by BackgroundStrategy * fix(scoped): add .editorconfig to avoid changing the sort order of using (system.* first) and fix the scope in BackgroundEventPublisher * Update title in README.md The README.md file has been updated to reflect the new version of Elsa - Elsa 3.0. * Remove npm-packages workflow, adjust branch triggers in workflows The npm-packages.yml workflow has been removed. The branch triggers in the workflows npm-packages.yml, packages.yml, and all-in-one-web.yml have been changed from 'v3' to 'main'. An unnecessary reference to the deleted workflow file npm-packages.yml is also removed from Elsa.sln. * Remove obsolete files from designer packages Numerous unused and obsolete files have been removed from various designer packages including angular-workspace, elsa-workflows-designer, react-workspace, and others. This cleanup enhances the maintainability of the project by eliminating unnecessary files and reducing clutter. * Add badges to README.md The README.md file has been updated to include badges for packages, continuous delivery, and discussions related to Elsa workflows. These badges provide quick access to key information and resources like Nuget, npm, GitHub Actions, feedz.io, Docker, Discord, Stack Overflow, and subreddit subscribers. * Update README with enhanced instructions for Elsa server and studio The README updates include specific instructions for running the Elsa server on port 5001 and the Elsa studio application on port 6001. These enhanced guidelines provide comprehensive steps for configuring the applications regarding authentication, module usage, and use of API endpoints. * Add IsWorkflowDefinitionActivity method to ActivityExtensions A new method, GetIsWorkflowDefinitionActivity, has been added to the ActivityExtensions class. This method checks a given JsonObject representing an activity to determine if it's a workflow definition activity. It returns true if the activity indeed is; otherwise, it returns false. * Refactor MassTransit & AzureServiceBus configuration and delete unnecessary options AzureServiceBusOption.cs and RabbitMqOptions.cs files were removed as they're no longer needed. The system now defers the configuration of MassTransit and AzureServiceBus to the application layer (Program.cs). The configuration for PrefetchCount is also allowed at the transport-level. A new abstraction, ConsumerTypeDefinition, collects all the consumer types with their respective definitions if provided. Adjustments have been made in related extension methods and classes to reflect these changes. * Enhance configuration options for MassTransit This commit enhances the configuration options for the MassTransit integration, providing additional settings for both Azure Service Bus and RabbitMq. It also refines the MassTransit workflow dispatcher configuration by allowing for custom dispatcher options. A default RabbitMq connection string has been added to the appsettings.json. * Renamed AI file * Update Elsa.Studio package versions The package references for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm in Elsa.AllInOne.Web and ElsaStudioWebAssembly projects were updated. The version has been changed from 3.0.0-preview.160 to 3.0.0-preview.164 to incorporate the latest features and bug fixes. * Reorganize README and add Docker instructions The README file was reorganized to make it more readable by grouping related badges together. Additionally, instructions on how to start the Elsa Docker container were appended for users who want to quickly try out the Elsa Studio and Elsa Server. * Update description in README.md The current diff modifies the description of the Docker image in the README file. The revised description consolidates information about the image, its reference ASP.NET application nature, and its non-production intention into a single, more succinct sentence. * Add tests for implicit joins and fix duplicate activity scheduling This commit includes new integration tests for implicit join scenarios. The tests ensure that join and parallel join activities execute correctly and complete as expected. Additionally, a change has been made to the workflow execution context to prevent duplicate activity scheduling. Now, aside from checking if the activity is already scheduled, it also checks if the activity is scheduled for the specified owner. Fixes #4703 * Add ExpressionEvaluatorOptions to JavaScriptEvaluator The JavaScriptEvaluator now accepts an options parameter of type ExpressionEvaluatorOptions. This allows adding custom arguments to the evaluation context. An 'Empty' static instance of ExpressionEvaluatorOptions is added for convenience. Additionally, the usage of MassTransitAzureServiceBus in Program.cs is turned off by setting the flag to 'false'. * Update README to add access information when user tried to run elsa with docker (#4708) * [no ci] add link to Elsa 2 in README * Remove Console and ASP.NET examples, simplify README.md Simplified README.md by removing in-depth Console and ASP.NET Core examples, as well as mentions about building from source, serving overall clarity and readability. Added descriptions for coded and visual workflow design possibilities. * Implement batch processing in BulkDispatchWorkflows The changes introduce a batch processing mechanism in the BulkDispatchWorkflows activity. Previously, each workflow was dispatched individually. Now, the process groups the workflows in batches, processes each batch concurrently, and handles errors. This change improves performance, particularly for large data sources. * Refactor workflow methods for async execution Modified methods in the WorkflowInstance.cs to implement re-entrant approach for asynchronous execution. This is achieved by replacing 'await' with task-based calls passed through the Context.ReenterAfter method, providing more efficient non-blocking operations. Minor changes were also made in ClusterExtensions.cs and ProtoActorWorkflowRuntime.cs, including code clean up and slight modifications to maintain consistency. * Refactor background activities scheduling Background activities scheduling was moved to its own middleware where the actual scheduling happens instead of in the invoking middleware. Removed ScheduleBackgroundActivities.cs handler and added ScheduleBackgroundActivitiesMiddleware.cs instead. As a part of this change, restructured BackgroundActivityInvokerMiddleware to BackgroundActivityCollectorMiddleware, and updated all relevant references. Minor modifications to a few other files include changes in their package dependencies and activity kind settings. * Change ActivityKind from Job to Task in BulkDispatchWorkflows The ActivityKind property in BulkDispatchWorkflows class has been changed from Job to Task. This updates the type of activity associated with the BulkDispatchWorkflows process within the Elsa workflow runtime module. * Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. * Add methods to handle activity run asynchronously flag New methods have been added to handle the custom property 'runAsynchronously' on a JsonObject activity. These methods will help in getting and setting a value that indicates whether a specified activity can trigger a workflow asynchronously. This additional level of control can enhance workflow execution based on specific requirements. * Add 'Persister' to UserDictionary in DotSettings The new dictionary entry for 'Persister' has been added to Elsa.sln.DotSettings. This expands the vocabulary of the solution's user dictionary and ensures that 'Persister' is recognized as a valid term within the project context. * Add Bookmark Persister and Bookmark Updater The code introduces BookmarkPersister for processing bookmarks as part of the workflow runtime. This refactoring improves readability and maintainability by separating the bookmark persisting logic from the PersistBookmarkMiddleware class. A new class, BookmarkUpdater, is also added to handle updating of bookmarks. Changes also include adjustments to several other classes for improved functionality and code consistency. * Add bookmarks processing to DefaultBackgroundActivityInvoker The code addition includes two dependencies, IBookmarksPersister and IWorkflowStateExtractor, in the DefaultBackgroundActivityInvoker service. With these changes, during the workflow execution phase, bookmarks are captured and processed for any state changes. These modifications provide more control and efficiency over handling workflow states during the system's background operations. * Update workflow handling and simplify codebase Refactored the workflow handling logic and simplified numerous components in the codebase. Major changes include the enhancement of the Workflow Runtime handler, altering the broadcast and deliver functions in the Default Workflow Inbox, and the removal of unnecessary details in the Workflow Runtime feature. Also, unnecessary services and requests were removed for better code efficiency and readability. * Add conversion support for long type in ObjectConverter The ObjectConverter file has been updated to support conversion of 'long' type. This is done by adding an additional conditional statement for checking the underlying source type for 'long', then returning the converted value. * Add 'Noop' method to WorkflowExecutionContext A Noop method has been added to the WorkflowExecutionContext, and is now assigned to the ExecuteDelegate field when no resumption point is specified. The change, will prevent the invocation of the regular "ExecuteAsync" method, closing the activity without additional operations. * Add AutoComplete option to workflow bookmarks The AutoComplete option has been added to the workflow bookmarks, which determines whether the activity should automatically be completed if no callback is specified. This change improves the flexibility of bookmark creation and impacts various workflow elements and procedures. The corresponding adjustments have been made at functions where bookmarks are used or created. * Refactor object initialization in ActivityExecutionContext Refactoring was performed in the ActivityExecutionContext class to use object initializers for readability and clarity. This modification mainly targets the CreateBookmark and ScheduleActivityAsync methods, making their code more explicit and thus easier to understand. * Refactor code for readability and improved logging Code in several activity files and Worker.cs that involve creating bookmarks and handling messages received was refactored to improve readability and clarity. The instantiated "CreateBookmarkArgs" parameter was split into its individual arguments for improved readability. Logging in the Worker.cs file was also fine-tuned, with explicit count of workflows triggered by service bus messages being included in the debug log. * Refactor code structure for ServiceBus Integration tests Refactored the ServiceBus Integration tests for improved readability and maintenance. The changes included reducing the number of lines by removing unnecessary curly braces, removing unnecessary use of 'this' qualifier, replacing null checks with null-conditional operators, and organizing various code blocks for better understanding. * Remove specific activity instance bookmarks The change clears specific activity instance bookmarks in the context from the WorkflowExecutionContext. This is an extra step in the process of clearing bookmarks, which assists in managing and cleaning up workflow state effectively. * Update Elsa.Studio.Login.BlazorWasm version The version number of Elsa.Studio.Login.BlazorWasm has been updated in the Elsa.AllInOne.Web.csproj file. This change reflects the newest release, moving from version 3.0.0-preview.164 to 3.0.0-preview.167. * Update artwork * Implement pagination for activity descriptor fetching Updated the WorkflowDefinitionActivityProvider code to fetch activity descriptors in a paginated manner. This change will be useful to avoid overloading system resources when interacting with large amounts of data. It retrieves a limited number of descriptors per request, looping until all are fetched. Closes #4689 * Refactor task payload extraction and update workflow builder Modified the way task payload is extracted in the OrderFoodTaskHandler.cs for more robustness. The input parameter of the workflow builder in the HungryWorkflow.cs file has also been refactored for efficiency. Making these tweaks streamlines management of values within the tasks. * Update localhost port for workflow sample The localhost port for the Elsa.Samples.AspNet.RunTaskIntegration has been updated from 7211 to 5001 in both the run-workflow.http and launchSettings.json files. This adjustment ensures that the workflow sample correctly points to the new localhost port, maintaining synchronization within the application. * Refactor ExpressionExecutionContextExtensions module Modified the GetInput methods to consider the case where the method is called within a composite activity, ensuring that only local variables have precedence over workflow input when executing within a composite activity. * Feature HTTP Activity : Allow adding Authorization Header without validation (#4721) * Add capability to add Authorization Header without validation * Refactor authorization header handling in HTTP requests This commit simplifies the syntax for input attributes in the SendHttpRequestBase.cs module. It also renames the boolean value `AddAuthorizatonHeaderWithoutValidation` to `DisableAuthorizationHeaderValidation` for more clarity. This change improves code readability and understanding in relation to handling authorization headers in HTTP requests. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Add a more generic UIHandler to customize how inputAttributes can be handle by UI (#4688) * add a more generic UIHandler to customize how inputAttributes can be handle by the ui * Add IPropertyUIHandlerResolver and update PropertyUIHandlerResolver Introduced a new interface, IPropertyUIHandlerResolver, to resolve UI options for a property. Refactored PropertyUIHandlerResolver to implement this interface and removed the unnecessary partial class structure. Also, cleaned up some unnecessary usings in various files for better code organization. * Refactor variable name and description in InputDescriptor The 'uISpecifications' variable in the InputDescriptor model is renamed to 'uiSpecifications' for better readability. Additionally, the associated comment was revised to explain that the dictionary is used by the UI. * "Refactor codebase for improved organization and cleaner architecture" The codebase has been significantly refactored, moving several classes to more appropriate namespaces for improved organization and cleaner architecture. This includes shifting UI hint handlers, activities, and memory-related components, amongst others. The changes should improve code readability and maintainability, but as this is a broad refactoring effort, thorough regression testing is advised. * Add CheckList UIHint with associated handler and provider This update introduces a new UIHint called CheckList to the Elsa.Workflows.Core. This includes the necessary handler and provider classes. The handler is registered in the WorkflowsFeature.cs, and the CheckList UIHint key has been added to the InputUIHints.cs. Various associated files have been created in both the Elsa.Api.Client and Elsa.Workflows.Core project to support this new UIHint. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update GitHub actions for packages publishing This update changes the trigger for the package publishing action to only 'published' releases and prereleases. It also segregates the publishing mechanism into two separate actions: one for publishing preview packages to nuget.org, and another for publishing release packages. This change provides better clarity and control over the publishing process. * Update FastEndpoints package and enable JWT Bearer Auth The FastEndpoints package was updated to '5.20.1.7-beta' from '5.20.0-rc1'. Enabling JWT Bearer Authentication was also set from 'false' to 'true' in the SwaggerExtensions file. Removed conditions that were limiting the addition and usage of Swagger to .NET 6.0 or 7.0, which allows the Swagger to be used in any environment. * Refactor input output assignment and JSON converter The code has been updated to provide clear and meaningful block reference names using the Humanizer library in the IdentityGraphService. The redundancy in assigning input/output Id's in both IdentityGraphService and InputJsonConverter has also been removed, resulting in cleaner, less convoluted code. * Enhanced script language support in Elsa.AllInOne.Web This update introduces expanded language support in Elsa.AllInOne.Web. The changes allow CLR access in JavaScript, and also introduce the ability to use both C# and Python. The changes also include adding project references for the C# and Python modules. * Add logging to PythonGlobalInterpreterManager Implemented logging in the PythonGlobalInterpreterManager class to ensure visibility during Python engine initialization and shutdown. These changes are important for spotting errors, troubleshooting issues, and understanding potential failures in Python engine initialization. * Refactor project structure and Docker configurations The changes included in this commit are made to refactor the project structure and Docker configurations. Previously, the application was structured around the AllInOneWeb solution, but it has been split into Server.Web and ServerAndStudio.Web solutions for better separation of concerns. Additionally, the Docker configurations have been updated to reflect the new structure, which should streamline the build and deployment process. * Add GitHub Actions workflows for Elsa Docker images This commit introduces two new GitHub Actions workflows: one for building and deploying the Elsa Server + Studio Docker image, and another for the Elsa Server Docker image. Both processes automate the build and push actions to Docker Hub using the latest ubuntu version and buildx for multi-platform support. * Update Dockerfiles and add Python 3.11 Working directories in both ElsaServer.Dockerfile and ElsaServerAndStudio.Dockerfile have been updated for better consistency. Additionally, Python 3.11 has been installed in the ElsaServer.Dockerfile, accompanied by relevant environment variables and symbolic links to improve interoperability. * Update Dockerfiles for Python 3.11 installation Added lines in Dockerfiles to install Python 3.11 and set the PYTHONNET_PYDLL environment variable. This enhancement helps to ensure compatibility with recent Python updates and improves general performance. * Add Elsa.Studio.Web project to the solution A new project, Elsa.Studio.Web, was added to the solution which included adding appropriate configuration files, host pages, project settings and important dependencies. Necessary adjustments were also made in Elsa.ServerAndStudio.Web.csproj to match with the latest updates. * Add Docker build script for Elsa Studio This commit introduces a Dockerfile for the Elsa Studio application and a corresponding GitHub workflow for building and deploying the Docker image. These make it possible to automatically build and deploy Elsa Studio as a Docker image. * Update Elsa.Studio package versions Updated the version of Elsa.Studio and Elsa.Studio.Login.BlazorWasm from '3.0.0-preview.169' to '3.0.0-preview.170' in Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. This is to keep the dependencies up to date and leverage any enhancements or bug fixes in the new version. * Update Elsa.Studio packages to version 3.0.0-preview.171 The Elsa.Studio and Elsa.Studio.Login.BlazorWasm packages are updated from version 3.0.0-preview.170 to 3.0.0-preview.171 in both Elsa.Studio.Web and Elsa.ServerAndStudio.Web projects. The updated packages include satisfying the latest enhancements and bug fixes. * Update Elsa.Studio package versions The Elsa.Studio package versions in ElsaStudioWebAssembly project have been updated from "3.0.0-preview.164" to "3.0.0-preview.171". The packages include Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm. * Add CodeEditorOptions, EditorHeight, and MultiLineOptions classes This commit introduces three new classes to the CodeEditor namespace. CodeEditorOptions provides various configuration options for the code editor while EditorHeight defines available height options. MultiLineOptions is specifically built for managing multi-line editor settings. * Update Elsa.Studio packages to version 3.0.0-preview.172 The packages Elsa.Studio, Elsa.Studio.Login.BlazorWasm and Elsa.Studio.Core.BlazorWasm have been updated to version 3.0.0-preview.172 in the Elsa.Studio.Web, Elsa.ServerAndStudio.Web, and ElsaStudioWebAssembly projects. * Add non-generic GetVariable method and Python accessors A non-generic version of GetVariable method has been added to the ExecutionContextProxy.cs, allowing direct access to variables without specifying a type. To leverage this, Python accessors for getting and setting workflow variables have been added to GenerateWorkflowVariableAccessors.cs. This enhances the interaction between the Python scripts and the context variables. * Add UI hints to input fields in workflow core modules Changed a number of instances in both activities and UI Hints classes across multiple modules in the workflow core to utilize UIHints. The UI hint "DropDown" has been added to relevant input fields to improve the user interface. Special handling for Enum properties in the drop-down options provider has also been created. * Update HTTP endpoint authorization handler The default authorization handler for HTTP endpoints is now the AuthenticationBasedHttpEndpointAuthorizationHandler instead of the AllowAnonymousHttpEndpointAuthorizationHandler. The configuration was updated in HttpFeature.cs and the override in Program.cs was removed. This provides more security to HTTP endpoints by requiring authentication. * Add JSON editor UI hint to HTTP activities This commit introduces a JSON editor UI hint to HTTP activities within Elsa Workflow. It includes creating new classes for a JSON editor options provider and a handler for this UI hint. Also, these additions are registered within the Elsa Workflow. The hint is applied to the 'RequestHeaders' and 'ResponseHeaders' input fields found in HTTP-related activity classes. * Add UI hints for HTTP endpoint and single line fields Introduced HttpEndpointPathUIHandler to provide additional UI options for the Path input field in the HTTP Endpoint activity. This commits also adds SingleLineProps to offer more options for SingleLine input fields across different modules. The implementation improves UI component interactions. * Update Elsa.Studio packages to version 3.0.0-preview.174 The Elsa.Studio, Elsa.Studio.Login.BlazorWasm, and Elsa.Studio.Core.BlazorWasm packages have been updated to version 3.0.0-preview.174 across multiple projects. The updated packages should provide the latest functionalities and fixes from the Elsa framework. * Add API key authentication for Elsa client Introduced an `ApiKeyHttpMessageHandler` to use an API key as the authorization header for Elsa API client. This ensures secure interaction with the Elsa server. Also made updates to the `ElsaClientOptions` class to include the API key. An `AddElsaClient` method is added with the API key parameter in `DependencyInjectionExtensions` class for convenience. * add sample CustomUIHandler * Fix Httpendpoint Path * Refactor parameter in AddElsaClient method The parameter "configureOptions" in the AddElsaClient method has been renamed and refactored to allow direct HTTP client configuration. This change enables the actions for configuring the HTTP client to be passed directly, providing greater flexibility for customization. * Add extension method to get workflow instance ID This adds a new extension method in HttpResponseMessageExtensions class which retrieves the workflow instance ID from the response. It also includes a HeaderNames class to maintain the consistency of header names used by the Elsa API. * Remove ElsaClient and related interfaces Files ElsaClient.cs, IElsaClient.cs and IElsaClientFactory.cs have been deleted from the Elsa.Api.Client project. The commit also includes an update in the DependencyInjectionExtensions.cs file where IElsaClient service registration is removed, reflecting these changes. * Add condition to return json as string A condition has been added to check if the returnType is of type 'string'. If so, the json is returned as string directly without converting. This is particularly useful to avoid unnecessary conversion when the returnType is already a string. * Disable PythonEngine Shutdown to prevent deadlock * Improve variable resolution in workflow activity Added a reference to Variable.Id in the SetVariable activity within the Elsa.Workflows.Core module to ensure the correct variable scope is utilized. This change enhances the precision of the variable resolution process by ensuring the correct variable is identified and updated. * Refactor Elsa API client to use API key authentication The Elsa API client configuration has been refactored to use API key for authentication instead of HTTP handlers. Besides, the configuration method name was changed to 'AddElsaApiKeyClient' and its parameters were simplified for ease of use. Object 'ElsaClientBuilderOptions' has also been extended with additional properties for further customization. * Add workflow result variable to context scope In the ExpressionExecutionContextExtensions module, an additional check and yield operation has been implemented. This allows the inclusion of the workflow result variable, if it exists, to the current context scope. * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. * Add sample CustomUIHandler (#4729) * add sample CustomUIHandler * Refactor code by renaming and moving classes Renamed 'VehiculeActivity', 'VehiculeUIHandler' to 'VehicleActivity', 'VehicleUIHandler' and moved them to their separate files. A debouncer was added to InputsTab in the WorkflowDefinitionEditor to limit the rate of firing refresh requests. Optimized codes by reducing unnecessary lines and improved consistency in the 'Program.cs' file. --------- Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Update Elsa.Studio packages and modify authentication setup The Elsa.Studio packages have been updated to version "3.0.0-preview.177" from "3.0.0-preview.174" in several project files. Additionally, in the "Program.cs" of ElsaStudioWebAssembly, the way the authentication handler is set up for the remote backend has been simplified and made more straightforward. * Add System.Runtime to CSharpOptions The System.Runtime assembly and namespace has been added to CSharpOptions. This extends the functionality capabilities within the Elsa.CSharp module by providing access to the Guid class and its related methods and properties. * Improve handling of non-HTTP context in HttpEndpoint Updated the HttpEndpoint class to handle non-HTTP contexts better. Instead of throwing an exception when it finds itself in a non-HTTP context, it now creates a bookmark that allows the invoker to save the state and resume execution from there. A callback has also been added to the bookmarks creation process to prepare for resumption actions. * Add non-generic variable accessor method Added a non-generic version of the GetVariable method to the ExecutionContextProxy and GenerateWorkflowVariableAccessors classes in Elsa.CSharp module. Also, extended the CSharpOptions class to include additional namespaces and assemblies related to System.Text.Json. These adjustments provide a more flexible way to access workflow variables and extend the usability of JSON serialization within workflows. * Add UIHint for FlowJoin activity The FlowJoin activity's join mode now includes a UIHint, which indicates its input is a dropdown. This improves user interface interaction by allowing the selection of join mode from a dropdown menu rather than manual input. * Add Parser for Form data 'application/x-www-form-urlencoded' (#4733) * Update version naming in GitHub Actions The convention for naming versions in GitHub Actions was modified. Previously, all tags were assigned just a sequential version, even if they were already marked as a release by a tag. Now, if they are tagged and marked as a published release, they use the tag as the version. The change should provide more accurate version information. * Fix conditional formatting in GitHub workflow A change has been made to correct the formatting in the conditional statement within the GitHub workflow file. This rectification ensures the proper assignment of the VERSION variable when a new release is published, through proper syntax adherence. * Refactor variable names and update notification strategy The variable names '_hosted' and '_backgroundEventService' in ServiceBusTests class have been refactored for clarity. They have been changed to '_backgroundCommandSenderHostedService' and '_backgroundEventPublisherHostedService' respectively to accurately depict the services they are hosting. Also, the notification strategy in the 'BackgroundEventPublisherHostedService' was changed from 'Background' to 'Sequential', fixing the process of sending notifications. --------- Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com> * Update service lifetimes and use IServiceScopeFactory for runtime activities This commit introduces several modifications targeting the adjustment of service lifetimes. Classes that were previously instantiated as Scoped are changed to Singletons, and vice versa. Furthermore, it employs IServiceScopeFactory to resolve services required for runtime activities. This improves the application's infrastructure by ensuring more efficient service lifetimes and optimizing the runtime resource allocation. --------- Co-authored-by: jeanbaptistedalle <jean-baptiste.dalle@laposte.net> Co-authored-by: Jean-Baptiste Dalle <jean-baptiste.dalle@stereograph.fr> Co-authored-by: Vincent Doreau <vincent.doreau@stereograph.fr> Co-authored-by: zergmk2 <zergmk2@users.noreply.github.com> Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com> Co-authored-by: jdevillard <djay93@hotmail.com> Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-01-02 13:52:53 +00:00
Services.AddScoped(typeof(IHttpWorkflowInstanceIdSelector), httpWorkflowInstanceIdSelectorType);
Refactor: Overhauls workflow JSON type serialization (#7549) * Avoid null endpoint DTO metadata in tests * Enforce console logs hub read permission * Remove unused console logs hub import * Support mapped endpoint metadata in auth tests * Reduce console log capture throughput impact * Address Copilot console logs review * Refactor task scheduling to support tenant-level background work and enhance logging functionality. * Introduce ConsoleStreamHook for stdout/stderr tee and enhance logging validation. Adjust test cases and startup warnings for distributed lock provider usage. * Refactor console logging pipeline with capture optimization and new ConsoleLogsHost; update tests accordingly. * Add Ansi SGR parser for console logs and associated unit tests * Remove ANSI color renderings and parsers; integrate ConsoleLogScopeAccessor for improved logging context with workflow instance ID support. * Address console logs code quality feedback * Address PR review feedback * Preserve console logs extension points * Stabilize console logs host lifecycle * Address final automated review comments * Tighten console log capture shutdown * Address console log review feedback * Address follow-up review feedback * Cover final review feedback * Avoid recursive console provider initialization * Guard console host lease shutdown * Preserve console log scope and provider lifetime * Correlate console log scope fallback * Tighten console scope correlation * Expose host services during provider construction * Redact ANSI-normalized console lines * Remove `ConsoleCaptureTee` and related services and tests * Use pipeline contributors for console log context * Update CShells package versions to 0.0.24-preview.132 * Filter live console logs by workflow instance * Enhance console logging with activity execution metadata and extend test coverage. * Address console logs stream consumption comment * Add diagnostics OpenTelemetry backend * Introduce dedicated workflow JSON type registry and hardening This change addresses GitHub issue #7541 by establishing a separate type registry (`IWorkflowJsonTypeRegistry`) for workflow JSON serialization. This decouples workflow type resolution from expression type aliases, enforcing a strict trust boundary. Key aspects: - New workflow JSON emits preferred aliases for registered types. - Existing persisted workflows can be loaded via registered legacy names. - Unknown, abstract, interface, open generic, or inappropriate collection types are rejected during deserialization, enhancing security. - Public APIs (e.g., incident strategies) now expose consistent workflow JSON type identifiers. This ensures secure, predictable, and backward-compatible handling of types within workflow definitions and payloads. * Remove unused project references and streamline console log endpoint * Move serialization type aliases to Elsa.Common * Update serialization integration fixtures for aliases * Stabilize missing rate limiter policy test
2026-05-31 09:09:39 +00:00
Services.Configure<SerializationTypeOptions>(options =>
{
Refactor: Overhauls workflow JSON type serialization (#7549) * Avoid null endpoint DTO metadata in tests * Enforce console logs hub read permission * Remove unused console logs hub import * Support mapped endpoint metadata in auth tests * Reduce console log capture throughput impact * Address Copilot console logs review * Refactor task scheduling to support tenant-level background work and enhance logging functionality. * Introduce ConsoleStreamHook for stdout/stderr tee and enhance logging validation. Adjust test cases and startup warnings for distributed lock provider usage. * Refactor console logging pipeline with capture optimization and new ConsoleLogsHost; update tests accordingly. * Add Ansi SGR parser for console logs and associated unit tests * Remove ANSI color renderings and parsers; integrate ConsoleLogScopeAccessor for improved logging context with workflow instance ID support. * Address console logs code quality feedback * Address PR review feedback * Preserve console logs extension points * Stabilize console logs host lifecycle * Address final automated review comments * Tighten console log capture shutdown * Address console log review feedback * Address follow-up review feedback * Cover final review feedback * Avoid recursive console provider initialization * Guard console host lease shutdown * Preserve console log scope and provider lifetime * Correlate console log scope fallback * Tighten console scope correlation * Expose host services during provider construction * Redact ANSI-normalized console lines * Remove `ConsoleCaptureTee` and related services and tests * Use pipeline contributors for console log context * Update CShells package versions to 0.0.24-preview.132 * Filter live console logs by workflow instance * Enhance console logging with activity execution metadata and extend test coverage. * Address console logs stream consumption comment * Add diagnostics OpenTelemetry backend * Introduce dedicated workflow JSON type registry and hardening This change addresses GitHub issue #7541 by establishing a separate type registry (`IWorkflowJsonTypeRegistry`) for workflow JSON serialization. This decouples workflow type resolution from expression type aliases, enforcing a strict trust boundary. Key aspects: - New workflow JSON emits preferred aliases for registered types. - Existing persisted workflows can be loaded via registered legacy names. - Unknown, abstract, interface, open generic, or inappropriate collection types are rejected during deserialization, enhancing security. - Public APIs (e.g., incident strategies) now expose consistent workflow JSON type identifiers. This ensures secure, predictable, and backward-compatible handling of types within workflow definitions and payloads. * Remove unused project references and streamline console log endpoint * Move serialization type aliases to Elsa.Common * Update serialization integration fixtures for aliases * Stabilize missing rate limiter policy test
2026-05-31 09:09:39 +00:00
options.RegisterTypeAlias(typeof(HttpRequest), "HttpRequest");
options.RegisterTypeAlias(typeof(HttpResponse), "HttpResponse");
options.RegisterTypeAlias(typeof(HttpResponseMessage), "HttpResponseMessage");
options.RegisterTypeAlias(typeof(HttpHeaders), "HttpHeaders");
options.RegisterTypeAlias(typeof(HttpRouteData), "RouteData");
options.RegisterTypeAlias(typeof(IFormFile), "FormFile");
options.RegisterTypeAlias(typeof(IFormFile[]), "FormFile[]");
options.RegisterTypeAlias(typeof(HttpFile), "HttpFile");
options.RegisterTypeAlias(typeof(HttpFile[]), "HttpFile[]");
options.RegisterTypeAlias(typeof(Downloadable), "Downloadable");
options.RegisterTypeAlias(typeof(Downloadable[]), "Downloadable[]");
options.RegisterTypeAlias(typeof(HttpStatusCode), nameof(HttpStatusCode));
options.RegisterTypeAlias(typeof(HttpRequestException), nameof(HttpRequestException));
options.RegisterTypeAlias(typeof(HttpEndpointBookmarkPayload), nameof(HttpEndpointBookmarkPayload));
});
}
}