Commit graph

6237 commits

Author SHA1 Message Date
Sipke Schoorstra c8ed08cc85
Remove obsolete properties and refactor activity evaluation (#6603)
* Remove obsolete properties and refactor activity evaluation

Refactored activity input and log persistence property evaluation using improved notification handlers. Removed redundant `ActivityState` property and associated serialization logic, ensuring payloads are only serialized when necessary. All changes streamline workflow processing and enhance maintainability.

* Refactor mediator call to inline cancellation token.

Replaced the separate variable for the cancellation token with an inline reference for clarity and reduced redundancy. This simplifies the code without altering functionality.
2025-04-18 16:21:25 +02:00
Sipke Schoorstra 476656ccce
Implement internal state activity persistence and logging mechanisms (#6601)
* Implement internal state activity persistence and logging mechanisms

Updated property handling to support nullable dictionaries and improved persistable states. Adjusted serialization logic to handle optional fields more robustly, ensuring better compatibility with log persistence mappings and internal state evaluations.

* Replace default! with null! for string properties

Updated string properties in various records to use null! instead of default! for consistency and clarity. Additionally, adjusted methods to check collection existence before serialization and streamlined object initializations with simplified syntax where possible.

* Fix nullable types in DeserializeActivityState method

Updated the method's return type and JSON deserialization to properly handle nullable values. This ensures better alignment with the method's behavior and avoids potential null reference issues.

* Fix null reference issues in InputOutputLoggingTests

Replaced forced null dereferences with safe navigation checks to prevent potential null reference exceptions. This ensures more robust and error-free test execution for activity state validations.
2025-04-18 14:29:18 +02:00
Sipke Schoorstra 67f3ceb801
Remove default commit strategy (#6599)
* Remove default commit strategy

No commit strategy = default behavior.

* Improved display names of commit strategies for clarity

* Refactor log persistence evaluation order in middleware

Ensure log persistence mode is determined before executing the next middleware to prevent issues with uncommitted changes. This change improves the reliability and predictability of log persistence behavior.
2025-04-18 09:26:29 +02:00
Sipke Schoorstra b88d12cdd8
Fixed Log Persistence Mode Evaluation For Activity Execution (#6595)
* Refactor log persistence mode evaluation for activity execution

Updated functionality to evaluate and filter log persistence modes during activity execution. Added middleware, interfaces, and supporting methods to manage log configuration, ensuring only persistable inputs and outputs are retained in execution mapping. Updated pipeline to include the new middleware.

* Refactor log persistence mapping and evaluation logic

Updated log persistence evaluation to use separate input/output maps, ensuring a more modular and maintainable structure. Adjusted property key handling and introduced a dedicated helper method for evaluating persistence properties. Added middleware for log persistence mode evaluation to the workflow execution pipeline.

* Refactor log persistence logic and restructure namespaces.

Centralizes log persistence logic under a dedicated `LogPersistence` namespace. Simplifies interfaces and methods to streamline functionality, ensuring clarity and consistency in log persistence evaluations.

* Refactor log persistence methods for encapsulation.

Converted multiple public methods to private to enhance encapsulation and adherence to the principle of least privilege. Introduced a helper method `ResolveFinalLogPersistenceMode` to improve code clarity and maintainability.

* Refactor log persistence with improved type safety and structure

Updated methods and properties related to log persistence to remove nullable types, enhance clarity, and ensure type safety. Simplified configurations and refactored logic for evaluating persistence modes, reducing redundancy and improving maintainability.

* Add XML documentation to IActivityPropertyLogPersistenceEvaluator

This commit introduces XML comments to provide clarity on the purpose and functionality of the interface and its methods, aiding developers in understanding their usage and behavior during workflow execution.

* Refine log persistence logic in activity execution mapping.

Ensure that log persistence modes are correctly handled by adding explicit checks for `LogPersistenceMode.Inherit`. This prevents potential ambiguities and ensures accurate property mapping during workflow execution.

* Refactor state handling and log persistence evaluation.

Updated method signatures for stricter type consistency and improved readability. Introduced additional resolution step in log persistence to handle legacy configurations more effectively. This enhances code maintainability and alignment with expected behavior.

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

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-04-17 18:03:06 +02:00
Sipke Schoorstra 3629a2ee69 Refactor ExceptionHandlingMiddleware imports.
Added missing imports for Workflow Models and State to support enhanced functionality. This ensures proper handling of workflow-related executions and state management within the middleware.
2025-04-16 20:43:33 +02:00
Sipke Schoorstra 9c05a4247c
Merge remote-tracking branch 'origin/main' 2025-04-16 08:41:52 +02:00
Sipke Schoorstra 2eec542f50
Merge remote-tracking branch 'origin/rc/3.4.0' 2025-04-16 08:41:04 +02:00
Sipke Schoorstra 83ae0f351e
Add support for connection vertices in flowcharts (#6585)
Introduced a `Position` model to represent coordinates. Updated connection models, serializers, and related logic to include vertices, enabling richer flowchart connections. Simplified null initialization and improved collection handling across components.
2025-04-16 08:28:16 +02:00
Sipke Schoorstra 278ed34981
Make input variable names case-insensitive in dictionary (#6590)
* Make input variable names case-insensitive in dictionary

Previously, input variable names were case-sensitive when added to the dictionary, which could lead to potential issues with naming mismatches. This change ensures that input names are now treated as case-insensitive by using `StringComparer.OrdinalIgnoreCase`, improving consistency and usability.

Fixes #6598

* Refactor default value assignments and object initialization.

Replaced `default` with explicit `null` for optional parameters to improve clarity. Simplified object instantiation by using target-typed `new` for brevity. These changes enhance code readability and maintainability.
2025-04-15 09:51:42 +02:00
Sipke Schoorstra e15baa6f44
Refactor variable storage driver mapping logic. (#6588)
Introduced a new `GetStorageDriverType` method for cleaner and modular handling of storage driver type resolution. Added dependency on `IServiceScopeFactory` to manage backward compatibility with older type namespaces.
2025-04-15 09:51:32 +02:00
Sipke Schoorstra 72370e9271
Remove alteration models and refactor to use JsonObject (#6582)
Replaced alteration model hierarchy with a simpler JsonObject-based structure for representing alterations. Updated related interfaces, parameters, and API configuration to align with this refactored approach.
2025-04-14 11:57:54 +02:00
Sipke Schoorstra e5c397d4fb
Refactor workflow instance creation and execution logic. (#6586)
Updated `CreateAndRunInstanceAsync` to separate instance creation and execution with locking to handle nested workflow scenarios. Made `RunInstanceAsync` public to facilitate reuse in the distributed workflow client.
2025-04-14 11:57:14 +02:00
Sipke Schoorstra d92512f087
Fix Container type (#6584)
Fixes an incorrect type use: IContainer lives in System.ComponentModel and does not represent a container activity. The correct type to use is `Container`.
2025-04-13 20:26:31 +02:00
Sipke Schoorstra 2ce5bbfbf1
Refactor incident creation to include NodeId and remove duplication
Replaced `activity.Id` with `activity.NodeId` in incident creation for enhanced context. Removed redundant `LogExceptionAndTransition` method by consolidating logic into existing workflow, reducing duplication and improving maintainability.
2025-04-11 21:17:41 +02:00
Sipke Schoorstra 612fd26388
Enable strict mode for ObjectConverter in unit tests
Set ObjectConverter.StrictMode to true in the test constructor to enforce stricter conversion rules during tests. This ensures better reliability and consistency in test coverage.
2025-04-10 19:57:39 +02:00
Sipke Schoorstra 8c52acece5
Fix MessageReceived not setting Result (#6562)
* Fix MessageReceived not setting Result

Fixes #6540

* Add custom equality comparer for VariableDescriptor

Introduced a `VariableDescriptorComparer` to ensure proper equality checks within `HashSet<VariableDescriptor>`. Updated related code to use the comparer and added a new message type `OrderReceived` for MassTransit integration.
2025-04-10 15:02:39 +02:00
Sipke Schoorstra 4266421a4c
Refactor Fault Propagation and Simplify Bookmark Management (#6545)
* Refactor bookmark management and add new features

Streamlined bookmark handling by eliminating temporary storage in `ActivityExecutionContext` and directly managing bookmarks in `WorkflowExecutionContext`. Documented architectural decisions using ADRs.

* Regenerate EF Core migrations

* Refactor fault tracking to use AggregatedFaultCount property.

Replaces FaultCount with AggregatedFaultCount across the codebase to improve clarity and consistency in fault tracking. Updates related methods, properties, and data mappings to align with the new terminology. Fixes initialization issue with nullable inputs in Fault class.

* Add migration to track fault counts in runtime (V3.5)

This migration adds a new column, "AggregatedFaultCount," to the "ActivityExecutionRecords" table. The column is an integer, non-nullable, with a default value of 0, and enables tracking aggregated fault occurrences. The migration also includes a rollback to remove this column if needed.

* Fix typo in ADR 0004 regarding bookmark management convention

Corrected a spelling mistake in the ADR documentation by changing "determins" to "determines." This ensures clarity and maintains the professionalism of the document. No functional changes were made.

* Refine fault propagation logic for child-parent activities

Replace automatic fault transitions of parent activities with an aggregate fault count for descendant activities. This avoids premature state changes while still indicating child activity faults, improving workflow resilience and accuracy.

* Remove signal-driven fault propagation ADR and renumber bookmarks ADR

The ADR for signal-driven fault propagation was deleted, and the direct bookmark management ADR was renamed and renumbered accordingly. Related references in the table of contents, graph, and solution file were updated to reflect these changes.

* Refactor DeleteBookmarks to improve readability.

Reformatted the BookmarkFilter initialization for better clarity and maintainability. This change ensures the code is more aligned with modern C# conventions and improves overall readability. No behavior or functionality has been altered.

* Refactor naming for "AggregatedFaultCount" to "AggregateFaultCount"

Standardized the terminology across the codebase and migrations by renaming all references of "AggregatedFaultCount" to "AggregateFaultCount" for improved consistency and readability. Updated relevant logic, models, migrations, and database contexts accordingly.
2025-04-10 15:01:49 +02:00
MariusVuscanNx 006ed54a92
Extended the incidents data to include the activityNodeId (#6570) (#6572) 2025-04-10 14:10:56 +02:00
MariusVuscanNx 455f206d36
Extended the incidents data to include the activityNodeId (#6570) 2025-04-10 14:02:38 +02:00
Sipke Schoorstra e2288d0b34
Fix infinitely waiting Alterations Workflow (#6561)
* Refactor TenantId string handling and nullability checks.

Moved `StringExtensions` to a common module for reuse. Updated tenant-related logic to utilize null-safe string extensions, enhancing consistency and simplifying nullability handling across the codebase.

* Set StrictMode to false by default in ObjectConverter

Modified the default value of StrictMode to `false` to enable the original flexible behavior. Developers can opt into strict mode by explicitly setting it to `true`. This change aims to enhance backward compatibility and minimize unexpected strict conversions.

* Add tenant ID retrieval to ElsaDbContextBase constructor

Retrieve the current tenant ID if available using ITenantAccessor and assign it to the TenantId property. This ensures proper handling of multi-tenancy scenarios in the database context initialization.

* Disable DbContext pooling, manual OTEL instrumentation, and strict mode.

DbContext pooling is turned off to prevent potential issues with shared context instances. Manual OpenTelemetry instrumentation is disabled to rely on automatic instrumentation instead. Strict mode is also disabled to allow more flexibility in object conversion.

* Fix infinitely waiting Alterations Workflow

Replaced workflow dispatch logic with BookmarkQueue and StimulusHasher for triggering workflows. This fixes the issue where the Alterations workflow would signal completion while a later step awaits a completion bookmark. The Bookmark Queue now handles this.
2025-04-05 10:37:05 +02:00
Sipke Schoorstra 286bdb22b2
Fix TenantId Missing in ActivityExecutionRecords and DB Context Isolation in Multitenancy (#6549)
* Enable multi-tenancy support for pooled DbContexts via decoration

Introduced a `TenantAwareDbContextFactory` to wrap `IDbContextFactory` and ensure tenant context is applied to `DbContext` instances. Updated dependency injection to decorate `IDbContextFactory` and enabled multi-tenancy across the application. Adjusted method signatures for consistency, simplifying multiple default parameters.

* Make ServiceProvider property protected

Changed the access modifier of the ServiceProvider property from private to protected. This allows derived classes to access and utilize the ServiceProvider directly while maintaining encapsulation.

* Disable multitenancy in Elsa.Server.Web configuration
2025-04-04 12:39:14 +02:00
MariusVuscanNx be455ee11b
Enhanced Delete of variable persistence manager to allow drivers filtering with tags (#6558) (#6559) 2025-04-04 11:52:58 +02:00
MariusVuscanNx 4bded7e4c5
Enhanced Delete of variable persistence manager to allow drivers filtering with tags (#6558) 2025-04-04 11:13:54 +02:00
raymonddenhaan d1cee77fd2
Merge pull request #6554 from elsa-workflows/rc/36595_compression
Moved compression to separate feature
2025-04-03 16:12:52 +02:00
Raymond den Haan d4b0238501 Moved compression to separate feature 2025-04-03 15:40:17 +02:00
Sipke Schoorstra 3874c0bebe
Update Docker image tags to v3.4.0-preview
Upgraded Docker image references in workflows to v3.4.0-preview from v3.3.0-preview. This ensures the workflows use the latest version for building and pushing images.
2025-04-02 16:11:38 +02:00
Sipke Schoorstra bd2fcb4d21
Update Elsa Studio packages and improve project dependencies
Upgraded Elsa Studio packages to version 3.5.0-preview.925 and updated page titles to reflect the new version. Added `Microsoft.AspNetCore.Components` dependency to `ElsaStudioWebAssembly.csproj` for improved component support. These changes ensure consistency and enhance application functionality.
2025-04-01 13:28:01 +02:00
Sipke Schoorstra a96b288117
Update Elsa.Studio packages to version 3.5.0-preview.922
Upgraded Elsa.Studio-related package versions from 3.4.0-preview.918 to 3.5.0-preview.922. This ensures the project uses the latest features and fixes available in the updated preview release.
2025-04-01 10:43:28 +02:00
Sipke Schoorstra fb1feb5ac4
Merge branch 'rc/3.4.0' 2025-04-01 10:23:04 +02:00
Sipke Schoorstra 6f7c356148
Update package versions for Elsa and add new ASP.NET component
Upgraded Elsa-related packages to version 3.4.0-preview.918 to include the latest features and improvements. Added the `Microsoft.AspNetCore.Components` package to align with other ASP.NET updates in the project.
2025-04-01 10:22:03 +02:00
Sipke Schoorstra 7fadf51be6
Fix Output Persistence of Async Activities (#6542)
* Updated output handling of asynchronously run workflows to be the same as when run synchronously

* updated tests

* Refactor activity execution mapping and output persistence

Introduced `GetPersistableOutputAsync` in `IActivityExecutionMapper` to streamline output persistence logic. Refactored the handling of activity persistence properties, replacing repetitive code with reusable methods. Removed unused dependencies and redundant methods, optimizing code readability and maintainability.

* Remove docker-compose-datadog.yml from solution file.

The docker-compose-datadog.yml file is no longer included in the solution structure. This change cleans up unused references to ensure the solution remains consistent and up-to-date.

* Refactor workflow extensions and add new utilities

Split and reorganize workflow-related extension methods into `RunActivityExtensions` and `RunWorkflowExtensions` for better modularity. Removed deprecated methods from `ServiceProviderExtensions`. Updated tests and usages to reflect these changes.

---------

Co-authored-by: Bob Hauser <rhauser@kinaxis.com>
2025-04-01 07:53:00 +02:00
Sipke Schoorstra f7743a0fe6
Fix race condition in Distributed Workflow Runtime during same-workflow event publishing (#6538)
* Add asynchronous stimulus dispatching to workflow runtime

Introduced the BackgroundStimulusDispatcher and related components to enable asynchronous stimulus dispatching. Updated event publishing logic to support both synchronous and asynchronous delivery. These changes improve extensibility and allow better performance for handling workflow stimuli.

* Update event publishing to include isAsync parameter

Added a boolean parameter to differentiate between asynchronous and synchronous event publishing. Ensured correct value is passed based on workflow execution mode, improving clarity and functionality. Removed outdated TODO comment.

* Fix default value for Asynchronous and add activity type helper

Set the default value of the Asynchronous input property to `true` in `PublishEvent`. Additionally, utilize `ActivityTypeNameHelper` in `EventPublisher` to generate activity type names for improved consistency and clarity.

* Remove unused import from EventPublisher.cs

Eliminated the unnecessary import of Elsa.Workflows.Runtime.Requests. This cleanup helps reduce code clutter and improves maintainability.

* Set default value for Asynchronous property and update Payload.

Added a default value of `true` for the `Asynchronous` property to ensure consistency in event delivery behavior. Also, removed the unnecessary default value from the `Payload` property description for clarity.

* Simplify XML doc comment in IStimulusDispatcher interface

Refined the XML documentation for the `SendAsync` method by shortening the description and clarifying the statement. This improves readability and maintains the intent of the comment.

* Add MassTransit stimulus dispatching functionality

Introduced `DispatchStimulusRequestConsumer` and associated consumer definitions to enable stimulus dispatching. Added `MassTransitStimulusDispatcher` service and related options for configuring concurrency and endpoint behavior. Updated `MassTransitWorkflowDispatcherFeature` to register the stimulus dispatcher and allow enhanced dispatch configuration.

* Refactor stimulus dispatching to use a serialized message.

Introduced `DispatchStimulus` to encapsulate serialized requests. Updated dispatch logic to utilize `IPayloadSerializer` for serialization and deserialization, enabling message transport in a lightweight format.

* Remove Asynchronous input property from PublishEvent activity

The Asynchronous input property was removed as it was unnecessary, with a hardcoded `true` value now passed directly to the event publisher. This simplifies the code and ensures consistency in how events are published.

* Remove ProtoStringExtensions and consolidate string utilities.

Moved `EmptyIfNull` and `NullIfEmpty` methods to the existing `StringExtensions` class in `Elsa.Workflows.Core` for centralization. Updated references to use the consolidated extension methods. Deleted `ProtoStringExtensions` as it is now redundant.

* Add missing imports for Elsa.Extensions across mappers

Added `using Elsa.Extensions` to multiple mapper files in the runtime module. This ensures consistent access to shared extension methods, improving code clarity and reducing potential errors.

* Add missing Elsa.Extensions namespace to WorkflowInstance

The `using Elsa.Extensions` directive was added to ensure access to required extensions. This resolves potential issues with missing dependencies or functionality in the `WorkflowInstance` class.
2025-03-31 18:11:27 +02:00
Sipke Schoorstra 952cbb4edc
Add strict type checking for variable parsing (#6536)
* Add strict type checking for variable parsing

Introduced a `StrictMode` flag for variables, enforcing stricter type validation during parsing and conversions. Updated related methods and tests to reflect the stricter parsing behavior, ensuring consistent type compatibility and error handling.

* Refactor StrictMode handling and improve ObjectConverter logic

Moved StrictMode flag from Variable to ObjectConverter for better cohesion and updated related references. Additionally, removed unused parameters and simplified ObjectConverterOptions to streamline configuration and maintain consistency across the codebase.

* Refactor type conversion logic and update logging defaults

Improve type conversion reliability by introducing `TryConvertValue` and refining exception handling. Update JSON scenarios to use "Inherit" as the default for log persistence modes, ensuring consistency across configurations.

* Refactor exception handling in ObjectConverter.

Introduce a helper method `ReturnOrThrow` to streamline and centralize exception handling logic. This change also adds support for non-strict mode, allowing value fallback instead of throwing exceptions when enabled.

* Add numeric type checks and improve type conversion handling

Introduce `IsNumericType` extension method to identify numeric types. Enhance type conversion logic in `ObjectConverter` to handle numeric, boolean, and string types more accurately. Update variable deserialization workflows to handle conversion failures gracefully.

* Set a default comment for ObjectConverter.StrictMode assignment

Added a comment clarifying that StrictMode is set to its default value. This improves code readability and helps maintainers understand the intent.

* Fix formatting inconsistencies and improve code clarity

Removed redundant whitespace and adjusted formatting to align with coding standards. These changes enhance the readability and maintainability of the code without altering functionality.

* Fix typo in Program.cs variable comment

Corrected a minor issue in the comment for `identityTokenSection` to remove the unnecessary "Modify" text. This change improves code readability and removes potential confusion for developers.

* Simplify imports in ModifyVariableHandler.cs

Removed unused `Microsoft.Extensions.Options` and `Elsa.Workflows.Options` imports to clean up dependencies and improve maintainability. This change reduces clutter without affecting the existing functionality.
2025-03-31 18:11:14 +02:00
Sipke Schoorstra 8bf58c5c60
Add support for activity output testing (#6529)
* Add support for activity output testing

Removed obsolete test workflows and updated the If activity tests to align with simplified testing practices. Introduced `GetActivityOutput` extension for retrieving activity outputs from workflow results. Refactored related APIs to simplify execution flow and unified cancellation token handling in service methods.

* Remove unused Parlot.Fluent namespace in IfTests.cs

This commit removes an unused "using" directive for the Parlot.Fluent namespace in the IfTests.cs file. Cleaning up unused references helps maintain code clarity and reduces potential confusion.
2025-03-31 18:10:59 +02:00
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 ede5d5cad2
Fix null handling for cancellation tokens and string fields
Updated `_linkedTokenSource` initialization to allow null values and improved string field handling by applying `NullIfEmpty()` for `CorrelationId`, `TriggerActivityId`, and `ParentWorkflowInstanceId`. These changes ensure proper null-state management and eliminate potential discrepancies in downstream operations.
2025-03-28 20:56:47 +01:00
Sipke Schoorstra fdc57945e8
Refactor default parameter values to use null instead of default.
Replaced `default` with `null` for optional parameters across several classes to improve clarity and consistency. This change aligns with typical .NET conventions and ensures more predictable behavior when handling optional arguments.
2025-03-28 20:44:15 +01:00
Sipke Schoorstra 0e6fdc7e0d Update package prefix logic for release candidate branches
Include release candidate (rc/*) branches in the condition to assign the "preview" package prefix. This ensures consistent versioning for branches intended for pre-production releases.
2025-03-26 16:23:17 +01:00
Sipke Schoorstra 06b9907d85
Fix DbContext pooling (#6531)
* Enable DbContext pooling and refactor DI scopes

Added support for using DbContext pooling with a configurable option. Refactored to use scoped service providers for better isolation and lifecycle management. Updated persistence feature base to integrate sensitive data logging and warning configurations.

* Update package management and Elsa Studio version references

Centralized package versioning remains enabled, while unused package references and conditional groups for specific .NET targets are removed for simplification. Elsa Studio version is upgraded from 3.3.0-rc4 to 3.4.0-rc1.

* Simplify DbContextOptions setup logic

Removed conditional compilation and unused code to streamline the DbContextOptions configuration. This improves maintainability and ensures consistent behavior across frameworks. Sensitive data logging is no longer explicitly enabled here.
2025-03-26 16:05:40 +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 9575cdeecf
Update Dapper Migrations (#6520)
* Update workflow to check for patch version 3.3.3

Revised the GitHub Actions workflow to detect the correct patch branch, updating from version 3.3.2 to 3.3.3. This ensures compatibility with the latest release process.

* Refactor WebhooksFeature to streamline configuration.

Simplified the configuration of sinks, sources, and HTTP clients by using direct actions instead of service-level options. Updated Apply method to finalize configurations and added notification handlers for better extensibility. Improved code readability and maintainability by consolidating logic and removing unnecessary dependencies.

* Update base_version in GitHub Actions workflow

Bump the base_version from 3.3.2 to 3.3.4 in the packages workflow file. This ensures compatibility and uses the latest base version for package management.

* Update release branch check to target patch 3.3.4

Modified the GitHub Actions workflow to check for the `patch/3.3.4` branch instead of `patch/3.3.3` during release events. This ensures compatibility with the latest patch branch in the release process.

* 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.

* Update base version to 3.3.5 in workflow configuration

Bump the `base_version` from 3.3.4 to 3.3.5 in the GitHub Actions workflow file. Adjust the matching branch reference to correspond with the updated version.

* Add V3.4 migration with schema updates and new column

Introduces Migration V3_4 to modify WorkflowInstances by adding the IsExecuting column. Updates Entity Framework migration to dynamically handle schema changes across tables. Ensures improved compatibility and extendability within the database layer.

* Refactor Dapper migration execution and update database schema. (#6519)

* Refactor migration execution and update database schema.

Replaced RunMigrationsHostedService with RunMigrationsStartupTask using IStartupTask for improved lifecycle management. Updated DapperMigrationsFeature to use the new startup task. Added a new "SerializedProperties" column to ActivityExecutionRecords and ensured proper schema adjustments during migrations.

* Add TenantId column to BookmarkQueueItems table

This commit introduces a nullable TenantId column to the BookmarkQueueItems table. The change ensures better multi-tenancy support by allowing tenant-specific data segregation.
2025-03-20 12:11:05 +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
Sipke Schoorstra ffe1a611d7
Remove unused datadog compose file and update branch reference.
The datadog compose file was removed from the solution as it is no longer needed. Additionally, the GitHub workflow was updated to reference the "rc/3.4.0" branch instead of "main" for the release process.
2025-03-18 19:41:46 +01:00
Sipke Schoorstra 2092b8aefe
Add 'rc/*' branch pattern to workflow triggers
This update includes the 'rc/*' branch pattern to the workflow triggers in the packages.yml file. It ensures workflows are triggered for release candidate branches, aligning with the project's branching strategy.
2025-03-18 19:30:16 +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