Commit graph

160 commits

Author SHA1 Message Date
Sipke Schoorstra ed8af61f48
Merge remote-tracking branch 'origin/develop/3.6.0' into develop/3.6.0 2025-12-09 22:12:52 +01:00
Sipke Schoorstra 9579a552ad
Downgrade JetBrains.Annotations package to version 2024.3.0.
This is a test to see if this works around an issue where the GitHub Actions CI server runs until its timeout of 30 minutes.
2025-12-09 22:12:30 +01:00
Sipke Schoorstra 47a8691c5b
Add logging-related dependencies and update package versions
Introduced new logging modules (Console, Core, Serilog) to the project references. Updated multiple package versions in Directory.Packages.props to ensure consistency across dependencies. These changes enhance diagnostics and maintain compatibility with the latest versions.
2025-12-09 20:47:37 +01:00
Matt 0f443e9419 Simplify Nuget package dependencies between .net versions. 2025-12-08 21:03:47 +00:00
Sipke Schoorstra 471ae03266
Add and update Scrutor package versions in Directory.Packages.props 2025-12-02 13:37:46 +01:00
Sipke Schoorstra bb321a8a49
Remove IntegrationTestSample.cs and related README while updating package dependencies. 2025-12-02 13:30:24 +01:00
Sipke Schoorstra 8aab381bc5
Update package dependencies and add Oracle.EntityFrameworkCore for net10.0 and net9.0 targets 2025-12-02 11:43:46 +01:00
Sipke Schoorstra a1d4e541fc
Add Elsa Script DSL (#7076)
* Update packages.yml

* Update elsa-server-and-studio.yml

* Update elsa-server.yml

* Update elsa-studio.yml (#6715)

* Update ListWorkflowDefinitionsRequest.cs (#6761)

Remove unnecessary line breaks

* Correct namespace and import for `ConfigureEngineWithVariableTypes`.

* Resolves build issues, update package versions and restructure project references

- Updated multiple package versions in `Directory.Packages.props` for better dependency management, including `BenchmarkDotNet`, `FastEndpoints`, and `Microsoft.Extensions.Http.Resilience`.
- Minor version upgrade for `System.Formats.Asn1` in `_build.csproj`.
- Replaced project reference to `Elsa.csproj` with `Elsa.IO.Http.csproj` in `Elsa.ServerAndStudio.Web.csproj`, enhancing modularity.
- Added new using directive for `Elsa.IO.Http.Features` in `Program.cs` to support new HTTP functionalities.

* Remove unused project references from Elsa.sln

These changes indicate that the associated projects or dependencies are no longer needed or have been replaced by other components in the solution.

* Rename copilot-setup-steps.yml.yml to copilot-setup-steps.yml

* Update RawStringContent encoding in JsonContentFactory (#6786)

* Update RawStringContent encoding in JsonContentFactory

Modified the instantiation of `RawStringContent` to use a
new `UTF8Encoding` instance with `encoderShouldEmitUTF8Identifier`
set to `false`, affecting the handling of the UTF-8 byte order
mark (BOM) in serialized JSON content. Fixes a bug with content length being different than expected.

* Refactor JsonContentFactory to reuse UTF8Encoding

Introduced a private static readonly field `_utf8Encoding` in the `JsonContentFactory` class to improve code readability and performance. This change replaces the instantiation of `UTF8Encoding` in the `CreateHttpContent` method, allowing for the reuse of the same encoding instance.

---------

Co-authored-by: Max Brooks <Max@compyl.com>

* Enhance thread safety with ConcurrentDictionary usage (#6760)

* Enhance thread safety with ConcurrentDictionary usage

Replaced `IDictionary` with `ConcurrentDictionary` for
both `_scheduledTasks` and `_scheduledTaskKeys` to
improve thread safety in a multi-threaded environment.

Updated methods `RegisterScheduledTask`,
`RemoveScheduledTask`, and `RemoveScheduledTasks` to
utilize the `Remove` method of `ConcurrentDictionary`,
ensuring safe and efficient removal of scheduled tasks.

* Refactor task registration and removal logic

Updated `RegisterScheduledTask` to use `AddOrUpdate` for streamlined task management. This change simplifies the addition and updating of scheduled tasks by consolidating logic into a single operation. Introduced `RemoveScheduledTask` method to handle task removal by name, improving code organization and clarity.

* Improve task removal handling in LocalScheduler

Modified the `LocalScheduler` class to enhance the removal process of scheduled tasks from the `_scheduledTaskKeys` collection. The removal operation now captures the result in a variable and includes a conditional check to log a warning if the task was not found, improving error handling and debugging capabilities.

* Refactor task removal in LocalScheduler

Updated the removal process for scheduled tasks in `_scheduledTasks`.
The new implementation collects all corresponding keys and attempts to remove them individually, logging warnings for any failures. This enhances error handling and provides better debugging information.

---------

Co-authored-by: Max Brooks <Max@compyl.com>

* Add IAsyncEnumerable check to ItemSourceActivityExecutionContextExtensions.GetItemSource (#6897)

* Use FullName in WorkflowDictionary (#6923)

* Fixed ParentWorkflowInstanceId not being set (#7029)

Co-authored-by: Peter Klooster <peter.klooster@autotaalglas.nl>

* Remove unused solution projects and update package references

- Deleted several project references from `Elsa.sln` to clean up the solution.
- Updated `Directory.Packages.props` for consistency and alignment with the latest package versions.

* Simplify CI pipeline by removing `Test` step from `Compile+Test+Pack` process.

* Initial plan

* Add ElsaScript DSL module with parser and compiler

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* Add integration tests for ElsaScript DSL

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* Add comprehensive documentation for ElsaScript DSL

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* Refactor workflow activity instantiation logic

- Removed `ActivityFactory` and its related interfaces and extensions.
- Introduced `ActivityActivator` for handling activity creation.
- Extended AST with support for comprehensive workflow structures:
  - Added nodes for flowcharts, if/else, loops, and variable declarations.
- Updated `IElsaScriptCompiler` to use asynchronous methods.
- Expanded `ElsaScriptParser` to simplify syntax for `UseNode` and argument parsing.
- Adjusted compiler and parser for compatibility with new workflow AST model.

* Refactor test method names for clarity and add new compiler and parser tests

- Updated method names in `CompilerTests` and `ParserTests` for better readability and description of test intent.
- Added tests for compiler and parser:
  - Support for workflows without the `workflow` keyword.

* Refactor `ElsaScriptParser` to improve statement parsing and introduce a tokenizer

- Added `TokenizeStatements` method to split source into statements for enhanced parsing accuracy.
- Updated logic to process statements instead of raw lines, reducing parsing complexity and improving reliability.
- Improved handling of workflow and statement parsing, including edge cases with braces, parentheses, and string literals.

* Introduce ElsaScript support for BlobStorage workflow provider

- Added the `Elsa.WorkflowProviders.BlobStorage.ElsaScript` module to enable ElsaScript-based workflow definitions for BlobStorage.
- Implemented `ElsaScriptBlobWorkflowFormatHandler` for parsing ElsaScript workflows stored in BlobStorage.
- Extended `ElsaScriptParser` to leverage Parlot for improved DSL parsing.
- Introduced `IBlobWorkflowFormatHandler` to centralize workflow format handling and parsing.
- Updated `Elsa.Server.Web` to reference the new module and include an ElsaScript "Hello World" example workflow.

* Refactor ElsaScript services, update logging, and improve workflow handling

- Changed `ElsaScriptCompiler` service registration from `Singleton` to `Scoped` for better dependency management.
- Enhanced the "Hello World" example workflow and added `CopyToOutputDirectory` configuration.
- Removed unused namespaces and adjusted references in multiple projects to improve maintainability.
- Updated logging levels in `appsettings.json` to reduce unnecessary debug output.
- Improved `PolymorphicObjectConverter` by removing redundant dependencies.
- Added missing references to enhance feature support and ensure compatibility.

* Refactor activity instantiation and improve argument handling in `ElsaScriptCompiler`

- Added support for positional arguments with constructor matching logic.
- Refactored `InstantiateActivityUsingConstructor` to enhance activity creation.
- Updated `ActivityDescriptor` and related types to include `ClrType` for streamlined activity resolution.
- Simplified `TypedActivityProvider` by annotating it with `[UsedImplicitly]`.
- Adjusted `ElsaScriptParser` to remove unnecessary options from string literal definitions.

* Add HTTP-enabled "Hello World" workflow and support for additional HTTP activity constructors

- Introduced a new ElsaScript example workflow `hello-world-http.elsa` with an HTTP endpoint and response.
- Enhanced `HttpEndpoint` and `WriteHttpResponse` activities with additional constructors for improved flexibility.
- Updated project to include the new workflow in the output directory.

* Enhance `ElsaScriptParser` with a custom parser to handle nested raw expressions for ElsaScript workflows

- Introduced `RawExpressionParser` to parse raw text after `=>` up to a matching closing parenthesis.
- Updated `elsaExpressionWithLang` and `elsaExpressionWithoutLang` to use `RawExpressionParser`.
- Trimmed whitespace in parsed expressions.
- Added integration and parser tests for complex workflows with variables and expressions.
- Updated example workflow `hello-world-http.elsa` to demonstrate expression usage.
- Added `Elsa.Http` module reference to enable HTTP-based activities.

* Update "Hello World" workflow to simplify naming and enhance response logic

- Renamed workflow from `HelloWorldHttpDsl2` to `HelloWorldHttpDsl`.
- Updated HTTP endpoint path to `/hello-world-dsl` for consistency.
- Improved response logic by utilizing `getMessage()` JavaScript function.

* Add support for `OriginalSource` in workflow materialization and enhance ElsaScript materializer

- Introduced `OriginalSource` property in `WorkflowDefinition` and `MaterializedWorkflow` for preserving original source representation (e.g., ElsaScript, JSON, YAML).
- Added `ElsaScriptWorkflowMaterializer` implementation to materialize workflows directly from ElsaScript source.
- Updated `DefaultWorkflowDefinitionStorePopulator` to determine `StringData` or `OriginalSource` based on materialized workflow format.
- Enhanced `WorkflowDefinitionMapper` to support symmetric round-tripping with `OriginalSource`.
- Registered `ElsaScriptWorkflowMaterializer` in `ElsaScriptFeature` for dependency injection.
- Updated `JsonBlobWorkflowFormatHandler` and added `OriginalSource` support for round-trip preservation.
- Simplified `ElsaScriptParser` by aligning variable and parser naming.

* Update V3_6 migrations for PostgreSQL, MySQL, and Oracle databases and associated designer files.

* Handle disposal and race conditions in `ScheduledCronTask`

- Added `_disposed` flag to prevent accessing disposed resources.
- Updated `_executionSemaphore` and `_scopeFactory` logic to safely handle `ObjectDisposedException`.
- Enhanced task scheduling and timer disposal with additional safeguards against race conditions.
- Modified tests to ensure proper disposal and logging behavior when handling edge cases.

* Add support for metadata in ElsaScript workflows and enhance parser and compiler functionality

- Introduced metadata syntax in ElsaScript workflows (e.g., `DisplayName`, `Description`, `Version`) to enable metadata-driven behavior.
- Enhanced `ElsaScriptCompiler` to process metadata and properly integrate it into `Workflow` objects.
- Updated `ElsaScriptParser` to parse program-level AST with support for multiple workflows and global use statements.
- Refactored tests to validate metadata parsing and ensure backward compatibility with existing workflows.
- Added new test cases to cover scenarios like metadata parsing, compilation, and multi-workflow programs.

* Add support for `foreach` loops in ElsaScript and remove `let` keyword

- Introduced `foreach` loop syntax in `ElsaScriptParser` and `ElsaScriptCompiler`, enabling iteration over collections with optional variable declaration.
- Updated `ForNode` and `ForEachNode` to include a `DeclaresVariable` flag for improved variable handling.
- Removed support for the `let` keyword in variable declarations, streamlining syntax to use `var` and `const` only.
- Enhanced `for` loop syntax to support optional `var` declaration and block or single-statement bodies.
- Refactored test cases to validate `foreach` and `for` loop enhancements and ensure backward compatibility.

* Simplify ElsaScript workflow syntax by removing redundant quotes in workflow identifiers and updating `for` loop syntax for clarity and consistency.

* Remove redundant quotes from workflow identifiers in integration tests

* Simplify Elsa scripts and improve error handling

- Removed redundant braces in workflow declarations for streamlined syntax.
- Enhanced logging in `JsonBlobWorkflowFormatHandler` and `ElsaScriptBlobWorkflowFormatHandler` to warn on parsing errors and provide context.
- Updated configuration to log errors for `Elsa.Workflows.ActivityRegistry`.
- Refined "Hello World" and "For Loop" workflows for clarity and added improved loop handling.

* Refine Elsa workflows and update compiler logic

- Simplified "Hello World" workflow by adding braces and improving consistency.
- Adjusted "For Loop" workflow to rename and clarify logic, including expression updates and variable handling.
- Fixed compiler mapping of `"cs"` to `"CSharp"` for better clarity.
- Enhanced "Hello World HTTP" workflow to correctly reference `variables.message` in expressions.

* Add flowchart support in ElsaScript parser, compiler, and integration tests

- Introduced `flowchart` syntax in `ElsaScriptParser` to support flowchart-based workflows.
- Updated `ElsaScriptCompiler` to compile `flowchart` nodes with labeled activities, connections, entry points, and variables.
- Added integration tests for parsing and compiling empty and simple flowcharts.
- Enhanced `FlowchartNode` and `LabeledActivityNode` for better representation of flowchart structures.
- Improved error handling and logging for invalid flowchart configurations.

* Add tests for compiling and parsing flowcharts with nodes, connections, and block nodes in ElsaScript

- Added integration tests for compiling and validating flowchart structures, including activities, connections, and entry points.
- Implemented parser tests for parsing flowcharts with node connections and block nodes.
- Updated project files to include new workflow examples for testing.

* Add Parlot package and update project file in integration tests

- Added `Parlot` package version `0.0.27` to `Directory.Packages.props`.
- Updated integration test project file to include a new `Include` directive for better targeting.

* Update Parlot package to version 1.5.2 in Directory.Packages.props

* Remove `elsa-server-and-studio.yml` workflow and update solution file

- Deleted `elsa-server-and-studio.yml` workflow as it's no longer needed.
- Updated `Elsa.sln` to remove reference to the deleted workflow.

* Remove `elsa-studio.yml` workflow and update solution and packages

- Deleted `elsa-studio.yml` workflow as it's no longer used.
- Updated `Elsa.sln` to remove reference to the deleted workflow.
- Changed `base_version` in `packages.yml` from `3.7.0` to `3.6.0`.

* Downgrade Docker image in `elsa-server.yml` workflow from `v3.7.0-preview` to `v3.6.0-preview`

* Update Docker image tag in `elsa-server.yml` workflow from `v3.6.0-preview` to `v3.6-preview`

* Add logging support to `LocalScheduler` and replace `Debug.WriteLine` with `ILogger`

* Remove unused `System.Collections.Generic` and `Elsa.Extensions` imports in `LocalScheduler`

- Cleaned up unnecessary using directives to improve code readability and maintainability.
- Minor whitespace adjustment for consistent formatting.

* Remove unnecessary whitespace in `LocalScheduler` for consistent formatting

* Improve exception handling in blob workflow format handlers

- Updated exception handling in `ElsaScriptBlobWorkflowFormatHandler` and `JsonBlobWorkflowFormatHandler` to gracefully catch and log all exceptions during workflow parsing.
- Adjusted comments to clarify behavior for invalid user-provided files, ensuring the workflow loading process is not disrupted.

* Refactor blob workflow format handlers to use `SupportedExtensions` for improved file filtering

- Added `SupportedExtensions` property to all blob format handlers to optimize blob storage browsing.
- Simplified `CanHandle` logic by removing extension checks, leveraging `SupportedExtensions` for initial filtering.
- Updated comments for clarity and consistency across handlers.

* Refactor `DefaultWorkflowDefinitionStorePopulator` to simplify `stringData` assignment logic and improve readability

* Remove outdated comment in `CompilerTests` about skipped tests

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactor `ElsaScriptCompiler` to streamline type conversion logic, improve language mapping, and enhance asynchronous flowchart compilation

* [WIP] Update ParseError printing based on feedback (#7082)

* Initial plan

* Fix ParseError formatting to use Message and Position properties

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* Replace `as` casts with direct casts in ParserTests for null safety (#7083)

* Initial plan

* Replace 'as' casts with direct casts in ParserTests for better null safety

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* Fix Oracle column types for OriginalSource and other large text fields (#7079)

* Initial plan

* Fix Oracle OriginalSource and StringData column types to handle large data

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* Refactor tests to replace type checks with `Assert.IsType` for improved clarity and type safety

* Initial plan (#7080)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* Add `Parlot` package reference and update solution structure by removing and reorganizing projects and workflows.

* Set default expression language to "JavaScript" in `ElsaScriptCompiler`.

* Add integration test to verify default expression language resets between ElsaScript compilations

* Simplify UTF-8 encoding in JsonContentFactory (#7081)

* Initial plan

* Remove explicit UTF8Encoding in JsonContentFactory and use Encoding.UTF8

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* Fix test to use Encoding.UTF8.GetByteCount for multi-byte character support

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: Ender <37611092+zengande@users.noreply.github.com>
Co-authored-by: Matt <knibbsy10@live.com>
Co-authored-by: Max Brooks <45081361+MaxBrooks114@users.noreply.github.com>
Co-authored-by: Max Brooks <Max@compyl.com>
Co-authored-by: FuJa0815 <30809803+FuJa0815@users.noreply.github.com>
Co-authored-by: Peter Klooster <crashkonijn@gmail.com>
Co-authored-by: Peter Klooster <peter.klooster@autotaalglas.nl>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-25 19:57:50 +01:00
Sipke Schoorstra b0d93d347b
Add unit and integration tests for DownloadHttpFile activity (#7094)
* Add unit and integration tests for `DownloadHttpFile` activity

- Developed comprehensive unit tests for the `DownloadHttpFile` activity validating method execution (GET, POST), URL handling, headers, and status codes.
- Added integration tests to verify functionality like authorization headers, filename extraction, and response stream handling.
- Updated `IntegrationTests` project references to include the required `Elsa.Http` module.

* Refactor `DownloadHttpFileTests` to simplify test setup and improve reusability

- Consolidated test initialization logic into `RunActivityAsync` for cleaner and reusable test setup.
- Updated existing tests to use `RunActivityAsync`, reducing boilerplate code.
- Unified filename extraction tests into a parameterized theory to improve test coverage and clarity.
- Simplified helper handlers with expression-bodied members for readability.

* Add comments to clarify HttpResponseMessage disposal responsibility in `DownloadHttpFileTests`.

* Ensure `HttpResponseMessage.Content` is always set to prevent null reference issues in `DownloadHttpFileTests`.

* Refactor `DownloadHttpFileTests` to ensure `HttpResponseMessage.Content` is always initialized and simplify content assignment logic.

* Update `DownloadHttpFileTests` to set an empty `HttpResponseMessage.Content` for testing `HasContent` behavior

* Add `GitHubActionsTestLogger` package to test projects and refactor `Directory.Packages.props`

- Updated unit and integration test projects to include `GitHubActionsTestLogger` for improved test reporting in CI.
- Refactored `Directory.Packages.props` to add conditional dependencies for .NET 8, 9, and 10 compatibility.

* Remove `GitHubActionsTestLogger` package from test projects.

* Add project reference for unit tests and update `DownloadHttpFileTests`

- Included `Elsa.Activities.UnitTests` project reference in `IntegrationTests` to reuse helpers.
- Removed redundant `TestHttpMessageHandler` by utilizing shared helper from `UnitTests`.

* Refactor `DownloadHttpFileTests` to remove unused methods and simplify imports

* Update target framework to .NET 10 and upgrade `Nuke.Components` package to v10.0.0
2025-11-24 14:37:06 +01:00
Matt f0f09e2bce Update package versions and restructure props file
Updated `MicrosoftVersion` and `ResilienceVersion` to `10.0.0`.
Restructured `<ItemGroup>` elements for better organization.
Added conditional `<ItemGroup>` entries for `net8.0`, `net9.0`,
and `net10.0` target frameworks to specify appropriate
`Microsoft.EntityFrameworkCore` package versions.
Preserved existing package versions and configurations.
2025-11-22 01:16:44 +00:00
Matt 5655192fb6 Update dependencies and refactor DbContext factory
Updated multiple package versions in `Directory.Packages.props` to ensure compatibility, security, and access to the latest features. Key updates include `MicrosoftVersion` to `9.0.11`, `BenchmarkDotNet` to `0.15.6`, `FastEndpoints` to `7.1.1`, and `System.CommandLine` to `2.0.0`.

Refactored `DesignTimeDbContextFactoryBase<TDbContext>` to align with the updated `System.CommandLine` API. Simplified `RootCommand` initialization and replaced deprecated `GetValueForOption` with `GetValue`.
2025-11-17 22:50:25 +00:00
Sipke Schoorstra ecf5b390f1
Remove Elsa.ServerAndStudio.Web and related projects
- Deleted Elsa.ServerAndStudio.Web alongside its components, configurations, and projects: Elsa.Studio.Web, ElsaStudioWebAssembly.
- Updated solution file to exclude removed projects.
- Simplified folder structure by eliminating unused files, enums, activities, settings, and resources.
2025-11-09 14:16:52 +01:00
Sipke Schoorstra db0309e9da
Update Microsoft and Resilience package versions in Directory.Packages.props 2025-11-09 10:53:24 +01:00
lukhipolito-nexxbiz fcd0b5ae9a
Feat/unit test coverage sendhttprequest (#6961)
* Unit test coverage for SendHttpRequest + useful extensions

* Update src/modules/Elsa.Workflows.Core/Extensions/ActivityExecutionContextExtensions.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Improvements on unit test and documentation for http

* Update doc/qa/test-guidelines.md

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>

* Improvements on maintainability of sendhttprequest unit tests

* Improving tests and scheduled activity evaluation for activity context

* Refactor and splitting unnecessary grouped tests

* Improvements on SendHttp Unit tests

* Improvements on tests

* Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Small suggestions from copilot

* Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* small copilot suggestion

* Introduce Scheduler Strategy Interfaces and Implementations for Workflow and Activity Execution Contexts (#6984)

* Introduce Scheduler Strategy Interfaces and Implementations for Workflow and Activity Execution Contexts

- Added `IWorkflowExecutionContextSchedulerStrategy` and `IActivityExecutionContextSchedulerStrategy` interfaces.
- Implemented `WorkflowExecutionContextSchedulerStrategy` and `ActivityExecutionContextSchedulerStrategy` for scheduling activities in workflows.
- Refactored scheduling logic to utilize the new scheduler strategies.
- Updated unit tests and test helpers to reflect refactoring, introducing fake implementations for testing purposes.
- Adjusted background execution scheduling and improved extensibility for custom scheduler strategies.

* Refactor `SendHttpRequestTests`: simplify scheduling assertions, use shared extensions, and standardize method naming. Streamline helper methods and remove unused test logic.

* Refactor: Replace `ActivityTestHelper` with `ActivityTestFixture` in unit tests for streamlined activity testing

- Introduced `ActivityTestFixture` with a fluent API for better test setup and execution of activities.
- Added extension methods `ActivityTestFixtureExtensions` and `ActivityTestFixtureHttpExtensions` for configuring attributes and HTTP services.
- Updated test guidelines and unit tests to use the new fixture and extensions.
- Removed `ActivityTestHelper`.

* Refactor: Move `ActivityTestFixture` and related extensions to shared project for reuse across test suites

- Consolidated `ActivityTestFixture`, `ActivityTestFixtureExtensions`, and `ActivityTestFixtureHttpExtensions` into `Elsa.Testing.Shared`.
- Updated namespaces and imports across unit tests to reflect new structure.
- Enhanced `AssertActivityAttributes` and added fluent configuration APIs.
- Adjusted `Directory.Packages.props` with new dependencies, including `NSubstitute` and `xunit.assert`.

* Refactor `SetVariableTests`: inline `ActivityTestFixture` initialization to simplify test setup.

* Refactor `ActivityTestFixture`: eliminate redundant field `_services`, add `UsedImplicitly` attributes, and improve service collection management

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add XML documentation for `ActivityExecutionContextExtensions`, detailing methods and parameters.

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add XML documentation for scheduler strategies and their methods

- Updated `IActivityExecutionContextSchedulerStrategy` and `IWorkflowExecutionContextSchedulerStrategy` interfaces with XML summaries for methods.
- Added XML documentation to implementations (`ActivityExecutionContextSchedulerStrategy`, `WorkflowExecutionContextSchedulerStrategy`) and test fakes for clarity.

* Refactor `WriteLineTests`: consolidate duplicate test logic, simplify setup with shared helper method, and enhance readability in assertions.

* Refactor `WriteLineTests` and `SetVariableTests`: replace `WriteLineAsync` assertions with synchronous `WriteLine`, streamline exception recording in `SetVariableTests`, and remove unused imports.

* Add `ParallelTests` for unit and integration testing with various scenarios (#6988)

- Added unit tests for `Parallel` activity to ensure proper scheduling of child activities, including empty and mixed activity cases.
- Added integration tests to validate execution flow and edge cases for `Parallel` activities (e.g., nested parallelism, fault handling).
- Enhanced `ScheduleChildrenAsync` in `Parallel` to handle no activity scenario by completing immediately.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add new unit and integration tests for activity input and expression evaluation (#6990)

* Introduce Scheduler Strategy Interfaces and Implementations for Workflow and Activity Execution Contexts

- Added `IWorkflowExecutionContextSchedulerStrategy` and `IActivityExecutionContextSchedulerStrategy` interfaces.
- Implemented `WorkflowExecutionContextSchedulerStrategy` and `ActivityExecutionContextSchedulerStrategy` for scheduling activities in workflows.
- Refactored scheduling logic to utilize the new scheduler strategies.
- Updated unit tests and test helpers to reflect refactoring, introducing fake implementations for testing purposes.
- Adjusted background execution scheduling and improved extensibility for custom scheduler strategies.

* Refactor `SendHttpRequestTests`: simplify scheduling assertions, use shared extensions, and standardize method naming. Streamline helper methods and remove unused test logic.

* Refactor: Replace `ActivityTestHelper` with `ActivityTestFixture` in unit tests for streamlined activity testing

- Introduced `ActivityTestFixture` with a fluent API for better test setup and execution of activities.
- Added extension methods `ActivityTestFixtureExtensions` and `ActivityTestFixtureHttpExtensions` for configuring attributes and HTTP services.
- Updated test guidelines and unit tests to use the new fixture and extensions.
- Removed `ActivityTestHelper`.

* Refactor: Move `ActivityTestFixture` and related extensions to shared project for reuse across test suites

- Consolidated `ActivityTestFixture`, `ActivityTestFixtureExtensions`, and `ActivityTestFixtureHttpExtensions` into `Elsa.Testing.Shared`.
- Updated namespaces and imports across unit tests to reflect new structure.
- Enhanced `AssertActivityAttributes` and added fluent configuration APIs.
- Adjusted `Directory.Packages.props` with new dependencies, including `NSubstitute` and `xunit.assert`.

* Refactor `SetVariableTests`: inline `ActivityTestFixture` initialization to simplify test setup.

* Refactor `ActivityTestFixture`: eliminate redundant field `_services`, add `UsedImplicitly` attributes, and improve service collection management

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add XML documentation for `ActivityExecutionContextExtensions`, detailing methods and parameters.

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add XML documentation for scheduler strategies and their methods

- Updated `IActivityExecutionContextSchedulerStrategy` and `IWorkflowExecutionContextSchedulerStrategy` interfaces with XML summaries for methods.
- Added XML documentation to implementations (`ActivityExecutionContextSchedulerStrategy`, `WorkflowExecutionContextSchedulerStrategy`) and test fakes for clarity.

* Refactor `WriteLineTests`: consolidate duplicate test logic, simplify setup with shared helper method, and enhance readability in assertions.

* Refactor `WriteLineTests` and `SetVariableTests`: replace `WriteLineAsync` assertions with synchronous `WriteLine`, streamline exception recording in `SetVariableTests`, and remove unused imports.

* Add new unit and integration tests for activity input and expression evaluation

- Introduced comprehensive test suites covering activity input evaluation, expression handling, and fault scenarios.
- Added unit tests for `ExpressionDescriptorRegistry`, `ExpressionEvaluator`, and activity execution context extensions.
- Added integration tests: `CustomInputEvaluatorTests`, `InputEvaluationErrorTests`, and `InputPropertyEvaluationTests`.
- Enhanced code coverage for edge cases and async evaluation logic.

* Remove unused `RunWorkflowAsync` extension method from `RunActivityExtensions`.

* Rename `CustomInputEvaluatorTests` to `InputEvaluationTests` for consistency with naming conventions.

* Remove unused `Elsa.Workflows.Activities` import from `RunActivityExtensions`.

* Remove redundant comments from `InputEvaluationErrorTests` for clarity.

* Refactor unit tests to streamline activity and expression evaluations

- Refactored `ExecuteActivityAsync` and `ExecuteWriteLineAsync` into shared helpers for consistency and reuse across tests.
- Replaced redundant mock setups with helper methods in `ExpressionDescriptorRegistryTests`.
- Simplified test setup for expression and activity evaluation by removing unused imports and consolidating configuration logic.
- Enhanced readability by reducing duplicate code and leveraging shared utility methods.

* Refactor activity input evaluation tests

- Extracted `CreateContextAsync` helper into `EvaluationTestHelpers` for reuse across evaluation test suites.
- Replaced inline activity context setup with shared helper in `InputPropertyEvaluationTests`, `WrappedInputEvaluationTests`, and related test suites.
- Simplified test method names for clarity and consistency.
- Updated test annotations to enhance readability and align with naming conventions.

* Remove redundant test cases and unused imports

- Deleted duplicated and non-essential test cases across evaluation test suites.
- Removed unused imports to improve code cleanliness and readability.
- Streamlined variable initializations and method calls within test setups.

* Remove redundant test case from `InputEvaluationErrorTests`

- Deleted the `ContinuesEvaluationForMultipleInputs` test, as it overlaps with existing tests and does not provide additional coverage.

* Remove redundant assertion from `InputPropertyEvaluationTests`

- Deleted `Assert.True(context.GetHasEvaluatedProperties())`, as it is unnecessary for verifying test outcomes.

* Remove redundant test cases from `WrappedInputEvaluationTests`

- Deleted `UsesDefaultValueWhenInputIsNull` and `EvaluatesExpression` tests as they are either duplicated or unnecessary for current test coverage.

* Add unit test projects for `Elsa.Workflows.Management` and `Elsa.Expressions`

- Introduced new test projects to separate and organize unit tests for `Elsa.Workflows.Management` and `Elsa.Expressions`.
- Updated `Elsa.sln` to include references to the newly added test projects.
- Adjusted namespaces in affected test classes for consistency with the updated project structure.

* Refactor `ExpressionEvaluatorTests` for clarity and consistency

- Simplified test method names and annotations for improved readability.
- Replaced duplicate mock setups with helper functions (`CreateContextAsync`, `CreateContextWithMockHandlerAsync`, and related methods).
- Streamlined test setups by removing redundant code and consolidating context creation logic.
- Updated test annotations to include descriptive `DisplayName` attributes.

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove redundant comment from `ExpressionEvaluatorTests` for clarity

* Remove redundant blank lines from unit test classes

- Eliminated unnecessary blank lines across `ActivityExecutionContextExtensions` test suites to improve code readability and consistency.

* Update src/modules/Elsa.Expressions/Services/ExpressionEvaluator.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Expand `test-guidelines.md` with testing best practices, helper references, and example snippets

- Added detailed guidance on test project organization, updated helper documentation, and streamlined example code for activity unit testing.
- Introduced scheduler strategy information and integration test patterns for deterministic tests.
- Clarified usage of shared infrastructure like `ActivityTestFixture` and `AsyncWorkflowRunner`.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: lucas.hipolito <lukhipolito@yahoo.com.br>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2025-10-20 20:11:46 +02:00
Sipke Schoorstra b5cc5f7ca5
Update coverlet.msbuild version to 6.0.4 in Directory.Packages.props 2025-10-08 20:36:06 +02:00
Sipke Schoorstra fe4d74189a
Add coverage enforcement for test projects (#6950)
* Add coverage enforcement for test projects

* Expand GitHub Actions triggers to include additional branch patterns

* Update `coverlet.msbuild` configuration and centralize dependency version management

- Removed inline version specification for `coverlet.msbuild` in `test/Directory.Build.props`.
- Centralized `coverlet.msbuild` version definition in `Directory.Packages.props` for consistency and maintainability.

* Remove `Elsa.Common.Core` unit test project and related test files

* Add Directory.Build.props for test project organization and update property configurations

- Introduced `Directory.Build.props` files for `test/unit` and `test/integration` to define project-specific properties.
- Updated `test/Directory.Build.props` to include new coverage formats and an exclusion for `Elsa.Testing.Shared`.
- Adjusted solution file to link new `Directory.Build.props` files.
- Configured threshold properties for `unit`, `integration`, and `component` test directories.

* Disable coverage collection for performance tests in project file

* Expand GitHub Actions workflow triggers and add PR-specific condition for test job
2025-10-07 19:59:53 +02:00
Sipke Schoorstra 3895f029da
Update dependency versions across multiple project files
Upgraded various dependencies including Elsa, ElsaStudio, ElsaExtensions, MicrosoftVersion, and Resilience to their latest preview versions. These changes ensure the project stays up-to-date with the latest improvements and bug fixes.
2025-09-28 20:51:34 +02:00
Sipke Schoorstra f24b4394cf
Add WorkflowStateCommitted notification support and update state handling logic
- Introduced `WorkflowStateCommitted` notification to encapsulate workflow execution context, state, and instance details.
- Updated `DefaultCommitStateHandler` to publish `WorkflowStateCommitted` via `IMediator`.
- Adjusted `DispatchWorkflowExtensions` to use `WorkflowStateCommitted` for workflow completion.

Updates KubernetesClient and Microsoft packages (#6917)

* Remove Proto.Cluster.Kubernetes dependency due to vulnerability

- Temporarily removed `Proto.Cluster.Kubernetes` package and provider integration because of a vulnerability in its dependency (https://avd.aquasec.com/nvd/2025/cve-2025-9708).
- Adjusted related cluster provider and remote configuration logic.
- Updated `PortAttribute` default parameter for clarity.

* Revert "Remove Proto.Cluster.Kubernetes dependency due to vulnerability"

This reverts commit 0720d970968e4f7338825407258b34ddffb1d2a4.

* Add KubernetesClient package and update MicrosoftVersion to 9.0.9

- Added `KubernetesClient` package to the project dependencies.
- Updated `MicrosoftVersion` to `9.0.9` in `Directory.Packages.props`.
Update Polly packages

- Bump Polly and Polly.Extensions package versions to 8.6.3.

Update `Microsoft.AspNetCore.Authorization` to use `MicrosoftVersion` property

Ensure Docker images ship CA trust and add TLS smoke tests (#6918)

Remove TlsSmoke project and related solution references

- Deleted `TlsSmoke` project files (`Program.cs` and `TlsSmoke.csproj`).
- Removed `TlsSmoke` project reference from the solution file (`Elsa.sln`).

Add comprehensive Copilot coding agent instructions for repository onboarding (#6920)

* Initial plan

* Add comprehensive .github/copilot-instructions.md with validated build instructions

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Add ForEach tests, introduce asynchronous workflow runner and enhance workflow events. (#6926)

* Introduce asynchronous workflow runner and enhance workflow events.

- Added `AsyncWorkflowRunner` to enable asynchronous workflow execution and result tracking.
- Introduced new event arguments, such as `ActivityExecutedEventArgs` and `WorkflowStateCommittedEventArgs`.
- Expanded `WorkflowEvents` class to include `ActivityExecuted`, `ActivityExecutedLogUpdated`, and `WorkflowStateCommitted` events.
- Refactored event arguments into the `Elsa.Testing.Shared.EventArgs` namespace.
- Enhanced tests with `AsyncWorkflowRunner` and new event-driven workflow scenarios.

* Refactor event argument classes to unify namespace and simplify inheritance

* Add shared component DotSettings file to support namespace exclusions
Refactor `WaitAsync` call in `DispatchWorkflowsTests` to remove unnecessary generic type.
2025-09-25 20:58:21 +02:00
Sipke Schoorstra 72ad243ed4
Merge 3.5.1 into 3.6.0 (#6907)
* Introduce `IWorkflowResumer` and `ActivityInputEvaluatorContext`, refactor endpoint handling, extend logging, and improve bookmark queue processing.

* Remove deprecated WorkflowContexts module and optimize project.

Deleted the Elsa.Studio.WorkflowContexts module and references from solution files. Corrected minor errors in remaining code and updated project configurations to align with the new structure.```

* Update GitHub workflows to track `develop/3.6.0` branch instead of `patch/3.5.1`.

* Fix inconsistent formatting in `InputDescriptor` constructor and properties.

* Add XML documentation for `DictionaryValueEvaluator` in `UIHints/Dictionary` module

* Refactor `DictionaryValueEvaluator` to improve readability and simplify dictionary evaluation logic.
2025-09-13 13:05:52 +02:00
Lucas Hipólito 3c871afbce
Downgrading JetBrains.Annotations for fixing the packages build (#6848) 2025-08-07 10:54:31 +02:00
Matt c36f1c977b Update package versions and use new FastEnpoints methods.
- Updated `Directory.Packages.props` with new package versions, including `ElsaStudioVersion`, `MicrosoftVersion`, and others.
- Changed `System.Formats.Asn1` version in `_build.csproj`.
- Re-factored `Endpoint.cs` to use new `Send` methods for updated FastEndpoints packages.
2025-08-05 23:50:40 +01:00
lucas.hipolito 4eac2967a1 Removing IO module (moved to Extensions) 2025-08-01 15:04:20 +02:00
Sipke Schoorstra 34ad766cad Update packages 2025-07-28 23:57:16 +02:00
Sipke Schoorstra f97e2e9e77
Updates Elsa Studio version
Updates the Elsa Studio version to the latest preview.

This ensures that the project uses the most recent features and fixes available in the Elsa Studio development environment.
2025-07-19 12:23:55 +02:00
Sipke Schoorstra 931d242f40
Merge remote-tracking branch 'origin/develop/3.5.0' into develop/3.6.0 2025-07-18 21:29:09 +02:00
Sipke Schoorstra ed14a1e577
Refactor activity execution record serialization with snapshots (#6807)
- Introduced `ActivityExecutionRecordSnapshot` for encapsulated serialized data.
- Updated `DefaultActivityExecutionMapper` to build serialized snapshots.
- Adjusted `ActivityExecutionLogStore` to persist pre-serialized snapshots.
- Streamlined package version management with `MicrosoftVersion` property.
2025-07-18 14:14:19 +02:00
Sipke Schoorstra df8a0f0e41
Upgrade package versions for ElsaStudio, Microsoft, and Resilience dependencies in Directory.Packages.props. 2025-07-15 14:41:38 +02:00
Sipke Schoorstra b535ed4b8c
Update Jint to 4.3.0 (#6794) 2025-07-15 14:09:48 +02:00
Sipke Schoorstra dec9c121f4
Merge remote-tracking branch 'origin/develop/3.6.0' into develop/3.6.0 2025-07-04 20:36:46 +02:00
Sipke Schoorstra ed49f21895
Merge remote-tracking branch 'origin/develop/3.5.0' into develop/3.6.0 2025-07-04 20:35:53 +02:00
Sipke Schoorstra b860370d9d
Add HealActivity alteration and handler with workflow fault recovery support
- Introduced `HealActivity` alteration type for resolving faulted activity states.
- Added `HealActivityHandler` to manage execution of `HealActivity`.
- Enhanced `WorkflowExecutionContextExtensions` with `FindActivityExecutionContexts` method for locating activity execution contexts based on provided handles.
- Updated `AlterationHandlerContext` to enable custom commit actions during `Succeed` calls.
- Registered `HealActivity` and its handler in alteration services.
- Upgraded `ElsaStudioVersion` to `3.5.0-preview.1092`.
2025-06-13 20:35:19 +02:00
Sipke Schoorstra 0811a4042d
Merge remote-tracking branch 'origin/patch/3.4.1' into develop/3.5.0 2025-06-13 19:04:29 +02:00
Sipke Schoorstra 38fb4cefff
Update package version properties for Microsoft and Resilience dependencies
Standardize package version references by renaming `Microsoft` to `MicrosoftVersion` and introducing `ResilienceVersion`. Adjust all relevant package declarations to use the updated property names.
2025-06-13 19:02:24 +02:00
Sipke Schoorstra 84e63f1f9e
Refactor package versioning to use shared properties for ElsaStudio and Microsoft packages. 2025-06-13 18:31:34 +02:00
Sipke Schoorstra c694a18c13
Enhances Mediator with Tenant Context Propagation (#6738)
* Update package versions in Directory.Packages.props

Upgraded multiple package dependencies to latest versions, ensuring compatibility, security, and access to the newest features.

* Refactor mediator pipeline to support tenant context propagation

- Introduced `TenantPropagatingMiddleware` to handle tenant context propagation during command execution.
- Added `SetupMediatorPipelines` hosted service for configuring mediator pipelines.
- Enhanced `CommandPipeline` and builder to allow middleware insertion, removal, and reordering.
- Updated `CommandContext` and related components to support headers for tenant context handling.
- Improved logging and refactored `BackgroundWorkflowDispatcher` to include tenant headers during command dispatch.

* Fix typos in XML documentation and improve middleware extension clarity

- Corrected duplicated slashes in XML doc comments in `ICommandSender.cs`.
- Refined phrasing in `MiddlewareExtensions.cs` to clarify method parameters and improve readability.

* Update src/common/Elsa.Mediator/Middleware/Command/Components/CommandLoggingMiddleware.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-13 14:26:51 +02:00
Sipke Schoorstra 623b75ed2c
Fix order of Order and Pagination (#6727)
* Refactor query composition to ensure consistent ordering and pagination logic.

Reordered method calls for `OrderBy` and `Paginate` across multiple stores to enhance readability and maintain consistent execution. Simplified redundant query operations for improved clarity and performance.

* Updates Elsa Studio version to 3.4.0

Updates the Elsa Studio version to the stable release.

Removes the preview tag from the version number.

* Move `ElsaStudioVersion` property to `Directory.Packages.props` for centralized management.
2025-06-12 09:25:43 +02:00
Sipke Schoorstra 6eccb3540a
Update package versions (#6722)
* Update package versions

Updated multiple package versions to their latest release, including `Polly`, `Elastic.Clients.Elasticsearch`, `System.Text.Json`, and others.

* Remove duplicate package entry

* Fix case mismatch in package name for SQL Server migration dependency.

* Add `Proto.Cluster.AzureContainerApps` package version to dependencies

* Update Directory.Packages.props

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-11 09:48:00 +02:00
Matt 2ea755a50f Revert ChecklistItem back from Record to Class and remove left over RadioListActivity. Update Nuget packages. 2025-06-06 00:44:10 +01:00
Sipke Schoorstra 1f2353cad8
Remove obsolete modules and associated code
Eliminated the `Elsa.Labels`, `Elsa.Environments`, and `Elsa.OpenTelemetry` modules along with their handlers, contracts, models, and related functionality. This cleanup improves maintainability and aligns the codebase with recent architectural changes.
2025-06-02 20:05:10 +02:00
Matt 5d1b0f8957 Update project files and dependencies to resolve Build issues.
- Removed `ElsaStudioVersion` from `Directory.Build.props`.
- Added `PackageVersions` group in `Directory.Packages.props` with `ElsaStudioVersion` and new `Moq` package version.
- Updated input retrieval method in `ConfigureLiquidEngine.cs` to use `ActivityInput`.
- Clarified import for `InvokingActivityCallback` in `ScheduledChildCallbackBehavior.cs`.
- Changed target framework to `net9.0` in `Elsa.Http.UnitTests.csproj` and updated package references for flexibility.
2025-06-01 15:57:42 +01:00
Sipke Schoorstra 7b75f0c89f
Implement retry attempt capturing (#6674)
* Update default initializations and input parameters to `null`

Replaced `default!` with explicit `null` for input parameters and properties throughout various classes. Adjusted constructors' default values for consistency and readability. This change ensures better clarity and alignment with nullable reference types.

* Add Polly-based resilience integration for retry tracking

Introduce Polly diagnostics to log retry events in the execution context. Updated resilience strategy interfaces and implementations to support Polly's context and retry event tracking.

* Refactor resilience and retry handling, add flaky endpoint.

Removed custom Polly-based diagnostic listeners and observers in favor of a transient status code utility class. Introduced a mock "flaky" endpoint for testing failure scenarios and updated configuration for resilience strategies. Minor namespace fixes

* Add retry attempt recording to resilience feature

Introduce `IRetryAttemptRecorder` and its implementations to enable recording of retry attempts during activity execution. Updated `ResilientActivityInvoker` to persist retry attempts and modified `ResilienceFeature` to support configurable retry attempt recorders.

* Add retry attempt tracking and retrieval functionality

Introduced mechanisms to track and fetch retry attempts, including new interfaces, reader implementations, API endpoints, and related models. These enhancements improve resilience tracking and data access for activity execution across workflows.

* Add GetOutcome method to RetryAttempt model

Introduce a GetOutcome method to encapsulate logic for determining the retry attempt's outcome. It prioritizes the Result, falls back to the Exception message, or defaults to "Unknown" if neither is available. This improves clarity and reusability of the outcome evaluation.

* Add scoped registration for _retryAttemptReader

This change ensures that _retryAttemptReader is registered in the DI container as a scoped service.

* Refactor retry mechanism to support detailed retry metadata

Introduced a `CollectRetryDetails` method to `IResilientActivity` for enhanced retry data collection. Updated `RetryAttemptRecord` to include a `Details` dictionary for capturing metadata, replacing previous `Result` and `Exception` fields. These changes simplify the retry recording process and improve extensibility for tracking retry details across activities.

* Add support for capturing background activity properties

Introduced functionality to capture and persist background activity properties during workflow execution. This includes defining a key for properties, capturing them in middleware, and storing them in the workflow execution context. These changes ensure properties are handled consistently alongside other activity data.

* Add support for storing and propagating activity execution properties

Introduced a `Properties` dictionary to track additional metadata in activity execution records and stats, enabling richer diagnostics and tracing. Refactored resilience logic to improve retry handling and propagate retry-related flags in workflows. Enhanced database queries to map serialized properties for execution summaries.

* Add retry propagation for background activity execution

Introduced a mechanism to propagate the retry-attempted flag across activity execution contexts. Added a new notification `BackgroundActivityExecutionCompleted` and updated related middleware to send this notification. Enhanced resilience features to handle and propagate retry state effectively.

* Refactor default parameters and values to use 'null'.

Replaced 'default' with 'null' for optional parameters and values in `AddExecutionLogEntry`, improving clarity and ensuring semantic consistency with nullable types. No functional changes were introduced.

* Refactor flaky endpoint and enhance resilience support.

Replaced the "Flaky" endpoint with a more robust "SimulateResponseEndpoint" under a new module. Introduced a status code lookup utility and improved resilience strategies with configurable backoff types. Updated serialization to support enum conversions and enhanced caching behavior for response simulation.

* Update activity execution models with nullable properties

Replaced `default!` initializations with `null!` to ensure correct handling of nullable string properties in `ActivityExecutionRecord`. Added a new `Properties` dictionary to `ActivityExecutionRecordSummary` to store additional activity execution data. This enhances model flexibility and data extensibility.

* Add support for recording resilience strategy in context

Introduced a new method to store resilience strategy details in the activity execution context for enhanced diagnostics. Updated `ResilientActivityInvoker` to serialize and set the resilience strategy using this method, leveraging `JsonSerializer`.

* Remove redundant PropertyNamingPolicy assignment

The PropertyNamingPolicy was set to the default value (CamelCase), making the assignment unnecessary. This change simplifies the code while maintaining existing functionality.

* Set JSON property naming policy to camelCase

Updated JSON serialization settings to use camelCase naming for property names. This improves consistency with standard JSON naming conventions and ensures compatibility with camelCase-based APIs.

* Remove unused Endpoints folder reference from project file

The Endpoints folder reference in the project file was unnecessary and has been removed. This cleanup helps maintain a tidy and accurate project structure.

* Remove unused RetryAttemptFilter and add Polly packages

Removed the obsolete RetryAttemptFilter class as it was no longer in use. Added Polly and Polly.Extensions packages to the project to support resilience and fault-handling strategies. This update aligns with keeping dependencies relevant and reducing unused artifacts.

* Add resilience integration test for FlowSendHttpRequest (#6692)

* Refactor and fix resilience test cases for clarity and accuracy

Simplified imports, adjusted code structure, and corrected attempt indexing logic in resilience tests. These changes improve readability, maintainability, and ensure accurate validation of retry attempts in test scenarios.
2025-05-26 11:47:09 +02:00
Sipke Schoorstra 3baf11ea49
Use centralized property for ElsaStudio version
Replaced hardcoded ElsaStudio version values with a centralized `ElsaStudioVersion` property. This ensures easier version management and reduces duplication across the project.
2025-05-26 08:55:50 +02:00
Matt 1ecbf5e93d Add back SasToken project. 2025-05-23 01:09:59 +01:00
Sipke Schoorstra 366284aed1
Updates package versions
Updates several package versions to their latest available releases.

This ensures that the project benefits from the latest features,
bug fixes, and security updates provided by the respective libraries.
2025-05-21 11:31:58 +02:00
Sipke Schoorstra ed6a20fd25
Merge remote-tracking branch 'origin/rc/3.4.0' into develop/3.5.0 2025-05-21 09:53:32 +02:00
Matt 10348c5ea3 Update all dependencies to new projects. 2025-05-21 00:20:13 +01:00
Matt 044be5c09a Rename Scripts to Expressions. 2025-05-20 12:52:19 +01:00
Sipke Schoorstra 0769b6ded2
Update ElsaStudio package version to 3.4.0-preview.1025
Changed the ElsaStudioVersion to a new preview version and referenced it consistently in package definitions. This ensures centralized management of the version and supports the updated preview release.
2025-05-16 22:16:36 +02:00
Sipke Schoorstra bbce6b6747
Merge branch 'develop/3.5.0' 2025-05-12 11:39:50 +02:00
Sipke Schoorstra 3a1ddb650f
Introduce token-centric Flowchart execution model with configurable MergeMode (#6632)
* Switch Flowchart to partial class and implement token-based logic

Refactored Flowchart to use a partial class structure for better modularity. Introduced a token-based execution option alongside the existing counter-based logic, enabling flexible activity scheduling strategies within the flowchart.

* Add token-based execution logic to Flowchart activities

Introduced token-based workflow execution for Flowcharts, enabling more granular control over activity scheduling. Refactored Start activity resolution and optimized connection handling within FlowGraph. Added extensions for improved activity query and execution management.

* Refactor token-based flowchart logic and add loopback detection

Replaced the legacy token-based flowchart logic with a cleaner, modular implementation. Introduced `LoopbackDetector` for identifying back-edges in workflows, enabling explicit handling of loopback connections for improved execution flow. Minor adjustments were also made for code consistency and clarity.

* Introduce token-centric execution model for Flowchart activity

Replaced the execution-count heuristic in Flowchart with a robust token-centric model, improving handling of loops, joins, and forks. Added join semantics via `JoinKind` and `IJoinHintProvider` to enable flexible configuration. Updated documentation and dependencies to reflect the new model.

* Refactor activity property handling and enhance JSON serialization.

Standardize key names in activity property management for consistency and improve error handling in `GetJoinKind` methods. Add support for enum serialization with `JsonStringEnumConverter` in JSON utilities.

* Refactor flowchart token handling for clarity and efficiency

Revised the flowchart token management logic to improve readability and maintainability. Simplified token creation, consumption, and scheduling while removing redundant code. Updated token structure and streamlined the flow execution process to handle dynamic and static connections effectively.

* Refactor Flowchart activity scheduling logic

Consolidated child activity scheduling into a single method, reducing duplication across token-based and counter-based workflows. Removed unused fields, redundant imports, and legacy logic to improve maintainability and clarity of the codebase.

* Update .gitignore to track Azurite data folder

Added `docker/azurite-data` to the ignore list to exclude local Azurite data files from being included in the repository. Ensures proper handling of temporary files related to Azure storage emulation.

* Refactor flowchart logic and extract activity context utilities

Reorganized flowchart logic by introducing reusable extension methods for activity context operations. Moved "HasPendingWork" and "HasFaultedChildren" methods into extensions to improve readability and maintainability. Updated related flowchart logic to utilize these methods for cleaner and more modular code.

* Refactor join logic and clean up Flowchart activities

Removed obsolete `JoinKind` enum and `IJoinHintProvider` interface, replacing them with the new `JoinMode` concept. Simplified flowchart logic by consolidating flow graph handling and refining activity execution extensions. Updated `FlowJoin` to recommend property-based configuration over explicit usage.

* Avoid invalid test execution when token flow is enabled.

The added check prevents the test from running when `Flowchart.UseTokenFlow` is enabled, as this scenario is incompatible. This ensures test reliability and avoids unnecessary execution.

* Refactor token-based logic in Flowchart activity.

Simplified token handling and introduced clearer logic for WaitAny and WaitAll joins. Improved efficiency by reducing redundant checks and streamlining activity scheduling. This ensures better maintainability and functionality in complex workflows.

* Refactor Token logic into its own model class

Moved the Token logic out of the Flowchart partial class to a standalone `Token` model for better modularity and clarity. Adjusted token consumption behavior to mutate the token in place rather than replacing it.

* Fix ancestor cancellation logic in Flowchart activities

Pass the correct activity to CancelInboundAncestorsAsync to ensure accurate ancestor determination and cancellation. Added validation to confirm the activity context is a flowchart to prevent invalid operations. These changes improve the reliability of flow control in workflows.

* Refactor Token model to add scheduling functionality

Replaced the `consumed` parameter with a `Scheduled` property and added a `Schedule` method for mark scheduling. This enhances the token model's flexibility, improving flowchart activity management.

* WIP on (no branch)

* Remove unused WaitAny guard logic from Flowchart activity.

The WaitAny guard logic and associated key have been commented out and effectively disabled. This cleanup simplifies the code, removing unnecessary operations that were no longer in use. The change ensures better maintainability and focuses on the core functionality.

* Add `MergeMode` enum and refactor flowchart merging logic

Introduced a `MergeMode` enum to define strategies for handling multiple inbound execution paths. Updated flowchart logic to replace the previous `FlowJoinMode` with `MergeMode`, and refactored related extensions to accommodate the new enum. This enhances clarity and flexibility in workflow merging behaviors.

* Mark `FlowJoin` obsolete and enhance merge mode handling

Added the `[Obsolete]` attribute to the `FlowJoin` activity and deprecated properties to encourage using `MergeMode`. Replaced synchronous `GetMergeMode` with an asynchronous `GetMergeModeAsync` to handle legacy `FlowJoin` mappings dynamically. Other minor changes include simplifying variable initialization in `WorkflowExecutionContext`.

* Mark FlowJoin activity as obsolete

The FlowJoin activity is now marked obsolete since all activities support the MergeMode property, eliminating the need for explicit join steps. This change includes an annotation update to clearly communicate its deprecated status.

* Refactor `OnActivityCanceledAsync` method location

Moved the `OnActivityCanceledAsync` method from the `Flowchart.Counters` file to the main `Flowchart` file for improved organization and readability. This ensures the method aligns better with its primary logic and related functionality.

* Refactor flowchart logic to improve cancellation handling

Refactored `OnActivityCanceledAsync` to handle token-based flow and legacy flow separately for better clarity and maintainability. Moved `CompleteIfNoPendingWorkAsync` to a single shared location and updated pending work checks to include unconsumed tokens and faulted activities. Simplified redundant logic and ensured consistency across methods.

* Remove consumed tokens after activity completion

This update ensures that consumed tokens pointing to the completed activity are purged from the token list. This helps maintain a clean state and prevents unnecessary token accumulation during workflow processing.

* Add support for blocking tokens in flowchart activities.

Introduced a `Blocked` property to the `Token` model to prevent scheduling activities prematurely in certain merge modes. Updated token processing logic to handle blocked tokens effectively and ensure proper scheduling or consumption. Simplified token management by removing redundant methods and cleaning up consumed tokens appropriately.

* Refactor Flowchart activity cancellation logic.

Streamlined cancellation logic by separating token and counter flow handling into dedicated methods. Removed redundant properties and logic, improving readability and maintainability. Simplified `OnChildCompletedAsync` and related methods for consistency.

* Refactor token-centric flowchart execution model.

Updated the flowchart ADR to clarify the token-centric approach, including `MergeMode` rules and scheduling logic. Enhanced the model to handle loops, forks, and resumable activities more robustly while improving state management and supporting cancellation. Updated sequence diagram for clarity.

* Remove JoinMode-related methods from ActivityExtensions

The GetJoinMode and SetJoinMode methods were removed as they are no longer needed. This cleanup reduces unused code and improves maintainability of the ActivityExtensions class.

* Remove unused JoinMode enum

The JoinMode enum was determined to be unnecessary and has been deleted to clean up the codebase. This helps reduce redundancy and improve maintainability.

* Remove unused LoopbackDetector class from Flowchart module

The LoopbackDetector class was removed because it is no longer used in the codebase. Its functionality appears to be obsolete or unnecessary for the current requirements of the Flowchart module.

* Update `UseTokenFlow` to be configurable

Made `UseTokenFlow` a static field to allow external configuration. This enables users to switch between the token flow and the old counter-based model as needed. Updated documentation accordingly.
2025-05-09 20:07:49 +02:00