Commit graph

6046 commits

Author SHA1 Message Date
Sipke Schoorstra bdec7b792c
Add Microsoft.AspNetCore.Components package version.
This commit adds the `Microsoft.AspNetCore.Components` package with version `9.0.3` to `Directory.Packages.props`. This ensures consistency with other related ASP.NET Core packages already listed.
2025-03-29 11:48:48 +01:00
Sipke Schoorstra ddcbc9527c
Update Elsa.Studio package versions to 3.5.0-preview.913
Upgraded all Elsa.Studio-related packages to the latest preview version (3.5.0-preview.913). Also removed commented-out package configurations for net8.0 and net9.0, cleaning up unnecessary clutter.
2025-03-29 11:40:10 +01:00
Sipke Schoorstra 5ab687bf5f
Refactor PersistenceFeatureBase constructor to primary style.
Updated `PersistenceFeatureBase` to use a primary constructor, improving code clarity and adherence to modern C# syntax. Removed the redundant explicit constructor implementation.
2025-03-26 14:03:46 +01:00
Sipke Schoorstra 3e3f15ae2f
Change default initialization values to null in SendHttpRequestBase
Updated the class properties' default initializers from `default!` to `null!` for better clarity and null handling. This ensures consistency in initialization and aligns with modern C# practices.
2025-03-26 13:56:20 +01:00
Sipke Schoorstra 2d1bb0c743
Refactor activity execution delegate initialization
Extract `ExecuteAsync` MethodInfo as a static field to improve efficiency and reduce repetitive reflection calls. This change streamlines the initialization of the activity execution delegate, improving code clarity and maintainability.
2025-03-26 13:56:07 +01:00
Sipke Schoorstra 51dff1a061
Support for Writing Custom Trigger Activities Using Existing Trigger Infrastructure (#6527)
* Refactor bookmark naming to use "Name" instead of "ActivityTypeName".

Replaces usages of "ActivityTypeName" with "Name" across relevant classes, filters, and database mappings for clarity and consistency. Maintains backward compatibility where necessary and updates corresponding indices, filters, and methods for proper functionality.

* Add migration for V3_5 with schema updates for EF Core

This migration modifies the `Triggers` and `Bookmarks` tables by adding the `Name` column, updating its nullable state, and creating corresponding indexes. Changes apply to both SQLite and MySQL contexts, ensuring compatibility across databases.

* Refactor bookmark filtering and tenant events handling.

Unified the bookmark filtering logic with overloads that accept multiple names, improving flexibility and reusability. Simplified object initializations in tenant events to enhance code readability and reduce verbosity. Added task continuation logic to background task execution for better task sequencing and error handling.

* Refactor bookmark creation to use target-typed `new` expressions.

Replaces explicit `CreateBookmarkArgs` instantiations with concise target-typed `new` expressions for improved readability and reduced redundancy. This does not alter functionality but simplifies the code structure.

* Make callback parameters optional and adjust OTEL settings

Updated methods to allow optional callbacks for improved flexibility. Refactored Delay activity to reuse helper methods. Adjusted OTEL instrumentation settings to enable console exporter and disable manual instrumentation.

* Refactor stimulus handling and streamline event workflows.

Introduces `WaitForEvent` and `GetEventInput` extensions to improve ActivityExecutionContext usability. Replaces generic filter methods with targeted single-name filtering, simplifying scheduling logic. Updates stimulus names for consistency and deprecates obsolete methods to enhance clarity and maintainability.

* Refactor `Event` activity handling and event stimulus logic.

Replaces inline event stimulus creation with a new `GetEventStimulus` helper method for cleaner code. Simplifies event execution handling by removing redundant logic in `ExecuteAsync`. Extends `WaitForEvent` to handle workflow triggers more efficiently.

* Refactor and enhance Timer and Delay execution logic

Introduced `TimerBase` for shared timer functionality and refactored `Timer` to extend it. Improved method names for clarity, replacing `ResumeIn`/`ResumeAt` with `DelayFor`/`DelayUntil`. Enhanced flexibility in bookmark handling and activity execution context extensions.

* Add custom activities and refactor HTTP stimulus handling

Introduce new custom activities (CustomDelay, CustomEvent, CustomHttpEndpoint, CustomTimer) to enhance workflow functionality. Refactor HTTP stimulus handling by replacing activity type names with a new centralized HttpStimulusNames constant, improving consistency and maintainability. Additionally, streamline HTTP endpoint logic with new helper extensions and simplify related services to reduce redundancy.

* Add HttpEndpointBase abstraction to simplify HTTP endpoints

Introduce a new `HttpEndpointBase` class to centralize common logic for HTTP endpoint activities. Refactored `CustomHttpEndpoint` to inherit from this new base class, reducing redundancy and improving maintainability.

* Refactor events framework with base class for event activities

Introduce `EventBase` to streamline implementations of event-driven activities. Updated `CustomEvent` to inherit from `EventBase`, reducing duplicate logic and improving maintainability. Removed unnecessary dependencies in `CustomTimer`.

* Refactor bookmark creation to use target-typed `new` expressions.

Replaces explicit `CreateBookmarkArgs` instantiations with concise target-typed `new` expressions for improved readability and reduced redundancy. This does not alter functionality but simplifies the code structure.

Make callback parameters optional and adjust OTEL settings

Updated methods to allow optional callbacks for improved flexibility. Refactored Delay activity to reuse helper methods. Adjusted OTEL instrumentation settings to enable console exporter and disable manual instrumentation.

Refactor stimulus handling and streamline event workflows.

Introduces `WaitForEvent` and `GetEventInput` extensions to improve ActivityExecutionContext usability. Replaces generic filter methods with targeted single-name filtering, simplifying scheduling logic. Updates stimulus names for consistency and deprecates obsolete methods to enhance clarity and maintainability.

Refactor `Event` activity handling and event stimulus logic.

Replaces inline event stimulus creation with a new `GetEventStimulus` helper method for cleaner code. Simplifies event execution handling by removing redundant logic in `ExecuteAsync`. Extends `WaitForEvent` to handle workflow triggers more efficiently.

Refactor and enhance Timer and Delay execution logic

Introduced `TimerBase` for shared timer functionality and refactored `Timer` to extend it. Improved method names for clarity, replacing `ResumeIn`/`ResumeAt` with `DelayFor`/`DelayUntil`. Enhanced flexibility in bookmark handling and activity execution context extensions.

Add custom activities and refactor HTTP stimulus handling

Introduce new custom activities (CustomDelay, CustomEvent, CustomHttpEndpoint, CustomTimer) to enhance workflow functionality. Refactor HTTP stimulus handling by replacing activity type names with a new centralized HttpStimulusNames constant, improving consistency and maintainability. Additionally, streamline HTTP endpoint logic with new helper extensions and simplify related services to reduce redundancy.

Add HttpEndpointBase abstraction to simplify HTTP endpoints

Introduce a new `HttpEndpointBase` class to centralize common logic for HTTP endpoint activities. Refactored `CustomHttpEndpoint` to inherit from this new base class, reducing redundancy and improving maintainability.

Refactor events framework with base class for event activities

Introduce `EventBase` to streamline implementations of event-driven activities. Updated `CustomEvent` to inherit from `EventBase`, reducing duplicate logic and improving maintainability. Removed unnecessary dependencies in `CustomTimer`.

* Move HttpEndpointOptions model to its own file

The HttpEndpointOptions class was moved from an extension file to its own dedicated file for better organization and modularity. This model defines HTTP endpoint properties such as path, methods, authorization, policies, request timeout, and size limit. The change improves code clarity and structure.

* Fix unnecessary whitespace in Timer.cs

Removed an extra whitespace line in the Timer.cs file to maintain code formatting consistency. No functional changes were made to the code.

* Remove extraneous whitespace in IStimulusSender.cs file

Eliminate unnecessary blank line in the IStimulusSender interface for improved code cleanliness. This change enhances readability and aligns with coding standards.
2025-03-21 23:16:56 +01:00
Green7 55a9c752eb
Fix incorrect Id assignment in Variable constructor (#6514) 2025-03-20 12:11:39 +01:00
Sipke Schoorstra b543366a4b
Refactor trigger indexing and update base version to 3.5.0. (#6516)
Refactored `TriggerIndexingContext` to enhance immutability and streamline trigger handling logic. Added support for generating trigger names dynamically and improved bookmark creation in HTTP workflows. Removed unused Docker Compose file and updated the base version in the build workflow to `3.5.0`.

Fixes #6512
2025-03-20 12:04:51 +01:00
Matthew Vance aa989ce13d
Catch exceptions and log instead of crashing (#6477)
* Catch exceptions and log instead of crashing

Modified both WorkflowInstance and WorkflowDefinition state loading to prevent throwing exceptions if the state fails to load successfully.

Also modified the CleanupJob to catch exceptions thrown by cleaning up and logging as errors and continuing instead of crashing.

Fixes 6473

* Use LogError instead of LogWarning for deserialization failure.

Updated the log level to LogError when workflow definition state deserialization fails. This change ensures better visibility and prioritization of critical issues during state handling.

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2025-03-18 19:27:04 +01:00
Sipke Schoorstra 8e9d5e356e
Handle conversion of enumerables to arrays in ObjectConverter (#6508)
* Handle conversion of enumerables to arrays in ObjectConverter

Added functionality to convert enumerables to arrays when the target type is an array. The implementation ensures each item is properly cast to the target array's element type and then added to the resulting array.

* Add unit test for converting object array to double array

This commit introduces a new test ensuring the proper conversion of an object array of doubles to a double array. It verifies both the validity of the conversion and that the result is not null.
2025-03-18 16:09:49 +01:00
Sipke Schoorstra ebe32288d2
Merge pull request #6502 from elsa-workflows/enh/otel
Improve OTEL Spans and Tags for Workflow and Activity Execution
2025-03-17 15:23:13 +01:00
Sipke Schoorstra caa3f05d19
Merge branch 'main' into enh/otel 2025-03-17 15:21:36 +01:00
Sipke Schoorstra 9b0aa9d922
Remove redundant span tags for activity and workflow incidents
The tags "activity.incidents" and "workflow.incidents" were removed as they are unnecessary and provide no additional value. This change simplifies the middleware implementation while retaining essential telemetry data.
2025-03-17 15:05:24 +01:00
Sipke Schoorstra 2d485d253d
Remove redundant status setting in telemetry middleware.
The `SetStatus(ActivityStatusCode.Ok)` calls were unnecessary as the default behavior already sets the appropriate status. This cleanup simplifies the code and avoids redundant operations, improving maintainability.
2025-03-17 15:01:37 +01:00
Sipke Schoorstra af63b1b59a
Ignore docker compose for local testing 2025-03-17 13:42:57 +01:00
Sipke Schoorstra 9822b9ca75
Refactor default value declarations for inputs and cleanup imports
Replaced `default!` with `null` for input property initializations to improve clarity and consistency. Removed an unused namespace import from `IErrorSpanHandler.cs` to clean up the codebase.
2025-03-17 10:56:24 +01:00
Sipke Schoorstra 2b9792b7be
Merge pull request #6506 from elsa-workflows/bug/remove-mt-retry
Remove message retry configuration in DispatchWorkflowRequestConsumer
2025-03-17 10:18:33 +01:00
Sipke Schoorstra a835eb82ed
Remove message retry configuration in DispatchWorkflowRequestConsumer.
This ensures a workflow is not executed multiple times in case of an unhandled exception.
2025-03-17 10:14:05 +01:00
Sipke Schoorstra a04aaf69e8
Merge pull request #6503 from KnibbsyMan/feat/sql-injection-prevention
FEAT - Automatic SQL Expression Parameterization
2025-03-17 10:05:22 +01:00
Sipke Schoorstra 40a6d3ea8d
Merge pull request #6498 from truthz03/feature/AddJobRunnerWorkerCountSetting
Allow to configure JobRunner worker count
2025-03-17 10:04:14 +01:00
Thomas Trummer 84191f149d Use IOptions<MediatorOptions> to get workerCount for BackgroundCommandSenderHostedService, BackgroundEventPublisherHostedService and JobRunnerHostedService 2025-03-17 08:45:34 +01:00
Sipke Schoorstra 714d8b6f3d
Merge pull request #6501 from elsa-workflows/bug/faulting-executing
Refactor activity execution state handling with IDisposable
2025-03-17 08:40:46 +01:00
Sipke Schoorstra 735a513790
Merge branch 'main' into enh/otel 2025-03-16 22:36:25 +01:00
Sipke Schoorstra 80d7c1c256
Handle null values explicitly for varbinary columns
Added explicit handling for null values in varbinary columns by applying a `CAST(NULL AS varbinary(max))` operation. This ensures proper value insertion and avoids potential type errors. Cleaned up unnecessary comments and minor whitespace inconsistencies for improved readability.
2025-03-16 22:36:09 +01:00
Sipke Schoorstra dc7b95835d
Handle null values explicitly for varbinary columns
Added explicit handling for null values in varbinary columns by applying a `CAST(NULL AS varbinary(max))` operation. This ensures proper value insertion and avoids potential type errors. Cleaned up unnecessary comments and minor whitespace inconsistencies for improved readability.
2025-03-16 22:35:34 +01:00
Sipke Schoorstra 32da99e3ec
Add docker-compose file for Datadog and OpenTelemetry setup
Introduce a new docker-compose configuration to integrate Datadog and OpenTelemetry with services like PostgreSQL, RabbitMQ, Redis, and Elsa. Updated the Datadog API key in an existing compose file for security purposes. This setup enables detailed monitoring, tracing, and metrics collection for development environments.
2025-03-16 19:49:35 +01:00
Matt 95b67ea002 Updates error handling to allow null values to be passed to the query. Errors are now thrown for when no matching properties are found. 2025-03-16 16:42:32 +00:00
Matt 5f43966233 BaseSqlClient code tidy. 2025-03-16 00:59:53 +00:00
Matt 24da6ab288 Simplify SqlEvaluator implementation and tidy code. 2025-03-16 00:44:35 +00:00
Matt d3dc6f3597 Updated the SqlEvaluator to work with {{ }} rather than @ for expression. Supporting updates also added. 2025-03-15 22:06:08 +00:00
Sipke Schoorstra 83253b2fae
Add support for starting new trace contexts in workflows
Introduced `StartNewTrace` input to workflows and updated OpenTelemetry middleware to support initiating new trace contexts. This helps improve trace isolation and linking when desired, enhancing observability during workflow execution.
2025-03-15 21:14:10 +01:00
Sipke Schoorstra 5f74a83a77
Remove redundant status handling in tracing middleware
This commit eliminates unused status checks ("running" and "pending") from OpenTelemetry tracing middlewares. The changes simplify the codebase and improve maintainability by removing unnecessary logic.
2025-03-15 20:07:15 +01:00
Sipke Schoorstra fe65476bf2
Add WorkflowExecutionState to manage execution context state
Introduce `WorkflowExecutionState` to encapsulate execution state changes for workflows. This ensures proper handling of execution flags during the lifetime of the state object and resets them upon disposal.
2025-03-15 20:03:22 +01:00
Sipke Schoorstra ba08d97b38
Refactor activity execution state handling with IDisposable
Introduce `EnterExecution` method to manage activity execution state using a `using` block for cleaner and safer resource handling. Removed manual flags for tracking execution state, streamlining workflow logic and improving maintainability.
2025-03-15 20:01:02 +01:00
Matt d8b6eda93f Simplify SQL client implementations to reduce repetitive code. 2025-03-15 01:51:42 +00:00
Matt a4e6e75e55 Adds SQL injection prevention with the use of parameters in the SqlEvaluator. 2025-03-15 01:26:11 +00:00
Sipke Schoorstra 39932a6f09
Refactor OpenTelemetry tracing and improve span tagging.
Introduced new span tags for activities and workflows to enhance trace analysis. Optimized error handling in activity tracing by selecting the first applicable handler. Removed unused manual tracing configuration and commented out console exporters in server setup.
2025-03-14 23:55:02 +01:00
Sipke Schoorstra b624b2b4af
Refactor error span handling with prioritization and predicates
Introduce `Order` property and `CanHandle` method in `IErrorSpanHandler` to enable prioritized and conditional processing of error spans. Update handler implementations to utilize these properties and streamline logic. This enhances flexibility and improves the extensibility of error span handling.
2025-03-14 23:37:46 +01:00
Sipke Schoorstra e393cca031
Update error status and exception type handling
Enhanced error status to include detailed message when the workflow is faulted, providing better context in logs. Fixed the retrieval of exception type by replacing `GetType()` with `.Type` for improved accuracy in incident tagging.
2025-03-14 23:27:16 +01:00
Sipke Schoorstra fd31b5b605
Update OTEL fields and tags
Added and updated multiple package references, including OpenTelemetry, Datadog.Trace.Bundle, and various Microsoft.Extensions libraries. This ensures compatibility with the latest dependencies and introduces enhanced features for resilience and tracing.
2025-03-14 23:17:54 +01:00
Sipke Schoorstra 62da3c8618
Merge pull request #6491 from Green7/dapper-fix-delete-without-filter
Correct the issue with DeleteAsync not executing due to a premature p…
2025-03-14 23:07:26 +01:00
Sipke Schoorstra ac7428da0b
Merge pull request #6497 from truthz03/feature/6400
#6400 Add ClearProvider again to ActivityRegistry
2025-03-14 23:06:22 +01:00
Sipke Schoorstra d8208d2fe7
Merge pull request #6495 from elsa-workflows/enh/explicit-deterministic-variable-id
Refactor variable initialization for clarity and consistency
2025-03-14 23:05:35 +01:00
Sipke Schoorstra 146791f72a
Merge pull request #6475 from KnibbsyMan/feat/sql-enhancements
Enhancement - Additional SQL Activity Features
2025-03-14 23:04:50 +01:00
Sipke Schoorstra 85eec228cf
Merge pull request #6460 from elsa-workflows/enh/workflowinstance-name
Improved support for named workflow instances
2025-03-14 23:03:51 +01:00
Sipke Schoorstra 094291b673
Merge branch 'main' into enh/workflowinstance-name 2025-03-14 23:03:33 +01:00
Sipke Schoorstra 287eef1a27
Merge pull request #6494 from KnibbsyMan/feat/datetime-picker
DateTimePicker UI Hint Missing
2025-03-14 23:00:10 +01:00
Thomas Trummer 84be58fceb Allow to configure JobRunner worker count 2025-03-14 10:14:47 +01:00
Thomas Trummer 90d8949661 #6400 Add ClearProvider again to ActivityRegistry 2025-03-14 10:13:02 +01:00
Thomas Trummer 996b831886 #6400 Add ClearProvider again to ActivityRegistry 2025-03-14 09:49:52 +01:00