Commit graph

4910 commits

Author SHA1 Message Date
Sipke Schoorstra b8cb2caf78 Refactor workflow and update EF Core config
Removed unnecessary namespace in OrderBatchProcessor workflow and set a descriptive name for the workflow sequence. Updated the EF Core configuration in Program.cs to use SQLite with a specified connection string and ensure Order types are accessible in CSharp expressions.
2024-03-14 10:00:06 +01:00
Sipke Schoorstra a0cda3830c Add DecimalJsonConverter and update usage
Introduce a new DecimalJsonConverter class and refactor serialization setup. Renamed IntegerConverter to IntegerJsonConverter and updated its implementation to handle both number and string JSON tokens. Adjusted serializer options in ConfigurableSerializer and ObjectExpressionHandler accordingly.
2024-03-14 09:59:22 +01:00
Sipke Schoorstra 0b0e26a327 Add DisplayName attribute to BulkDispatch
Enhanced the clarity of the input field by adding a `DisplayName` attribute in the `BulkDispatchWorkflows` activity. This better describes the purpose of the input field for workflow definition selection.
2024-03-14 09:29:12 +01:00
Sipke Schoorstra ffd9ae7cc2 Fix log message parameter name
Corrected the parameter token in the error log message to match the expected variable name, ensuring accurate logging when attempting to create duplicate workflows. This helps in diagnosing the root cause of issue #5033 more efficiently.
2024-03-13 20:45:44 +01:00
Sipke Schoorstra bb4a764eb8 Revert "Prevented overwriting of existing workflows (#5067)"
This reverts commit 2dcaab9bf8.
2024-03-13 20:43:34 +01:00
Sipke Schoorstra 20d936d3c2
Alterations with Queries (#5032)
* Remove Elsa.Alteration Handlers and implement workflow alteration activities

The Elsa.Alterations.Handlers, Services, and Endpoints have been removed and replaced with Elsa.Alterations.Activities for various steps in executing an alteration plan. These activities include submitting an alteration plan, generating alteration jobs, and dispatching alteration jobs. New models for ActivityFilter, AlterationWorkflowInstanceFilter, and alteration activity summaries are also introduced for better management of alteration plans.

* Add 'PrintMessage' custom activity and update naming rules

A new 'PrintMessage' activity has been added to the custom activities of the ConsoleApp, which simply writes a 'Hello world!' message. On top of this, the naming rules in the code styling settings have been expanded, introducing separate rules for instance and static private fields.

* Remove V3_1 database migration files

The V3_1 database migration files were deleted across all database providers, including MySql, SQL Server, SQLite and PostgreSQL. This is indicative of a rollback or significant revision to the data migration strategy.

* Update product version and modify tables in Elsa DB context

Updated "Elsa" DbSet product version from "7.0.11" to "7.0.14". Additionally, added new properties as well as modified existing ones in tables like "Elsa.KeyValues.Entities.SerializedKeyValuePair" to improve data structure. Also properly ignored certain entities in the Alterations DbContext.

* Add V3_1 migration for Elsa

This commit introduces the V3_1 migration for the Elsa module. Changes involve the introduction of new tables and alteration of existing tables. Specifically, a new 'KeyValuePairs' table was added and several columns on various tables were renamed or altered.

* Remove multiple Elsa.EfCore V3_1 migration files

The commit removes several migration files related to the V3_1 migration in multiple Elsa.EntityFrameworkCore modules including SqlServer, PostgreSQL, and SQLite. These files encompass changes in table structures and alterations.

* Update default value for ArgumentDefinition Type

The default value for the `Type` property in the `ArgumentDefinition` class was updated to `typeof(object)`. The `Type` property of `inputDefinition` in the `WorkflowBuilder` class was also modified to be set as `typeof(T)`. These modifications enable more flexible type handling.

* Refactor SafeSerializer and serialization services

The SafeSerializer service and related serialization services have been comprehensively refactored. This includes the removal of internal notifications, the incorporation of [RequiresUnreferencedCode] attributes, and changes in method signatures. Methods have been simplified to return ValueTasks directly from the JsonSerializer, and the notification sender dependency was removed.

* Add JSON serialization for alterations

Implemented a JSON serializer and a custom converter for the IAlteration interface in the Elsa.Alterations.Core.Serialization namespace. Also, introduced a new IJsonSerializer interface and an implementation for standard JSON serialization in Elsa.Common. These serialization changes enhance modularity and extensibility of JSON operations, and improve handling of IAlteration objects.

* Add "IsSystem" field to Workflow Definitions and Instances

This update introduces a new boolean field "IsSystem" to the Workflow Definition and Workflow Instance models. This field is designed to identify system workflows which aren't meant to be modified by users. Management and Runtime module code, API endpoints, database migrations, and related classes have been updated to include this new field. The MongoDB indices and Dapper migrations have been updated as well, and serialization/deserialization processes for these types have been modified to handle this new attribute.

* Remove outdated database migrations

Deleted database migration files from the MySql, SqlServer, and PostgreSql projects.

* Add V3_1 migration for Elsa.EntityFrameworkCore.Sqlite

This commit introduces the V3_1 migration for the Elsa.EntityFrameworkCore.Sqlite module. It includes changes in Alterations, Runtime, Management, and Identity contexts. These changes involve table alterations, addition of new columns, and creation of new tables. Each context alteration encapsulates relevant changes for specific functionalities of the module.

* Add `IsSystem` property to workflow classes

The `IsSystem` property has been added to several sections of the codebase related to workflows, such as `WorkflowStateMapper.cs`, `ListWorkflowDefinitionsRequest.cs`, `WorkflowDefinitionStore.cs`, and `ListWorkflowInstancesRequest.cs`. This property flag allows us to include or filter system workflows in our queries and results.

* Add 'UsedImplicitly' attribute to Alteration Handlers and Types

The 'UsedImplicitly' attribute from JetBrains.Annotations has been added to all Alteration Handlers and Alteration Types in the Elsa.Alterations module. This change specifies that these classes are being used implicitly and helps tools like ReSharper prevent false unused code detection.

* Update migration script for efcore-3.1

The migration script efcore-3.1.sh has been updated. Module "Alterations" and provider "Sqlite" are added back into the lists while unused elements are removed for cleanup. The script now covers all necessary modules and providers, improving its overall effectiveness.

* Remove PrintMessage class from Elsa.Server.Web bundle

This commit deletes the PrintMessage.cs file that was previously part of the Elsa.Server.Web bundle.

* Refactor MassTransit service configuration

This commit reduces line code length by merging splitted long lines into one, improves maintainability of code. It also updates the Service configuration and removes unused namespaces across files, which help to simplify the codebase. Changes have also been made to switch the MassTransit broker from RabbitMq to memory and adjust the endpoint name formatter configuration.

* Remove extra whitespace in Program.cs

Removed a trailing whitespace on the line declaring the useSqlServer constant in the Program.cs file. No functionality changes were made, simply a minor formatting correction to maintain clean and consistent code.

* Remove AlterationJsonConverter and update other files

The AlterationJsonConverter class has been removed, simplifying the serialization process. The AlterationSerializer.cs file was updated with additional attribute tags, giving more information about serialization expectations. Lastly, the AlterationSerializationOptionConfigurator.cs was simplified by removing unnecessary overrides and the Elsa.Alterations.Core.csproj file was tidied up by removing unused services folder reference.

* Refactor code for improved readability and maintainability

The diff shows changes across multiple files in multiple modules. Primarily, these changes revolve around formatting edits such as removing unnecessary spaces or line breaks and adjusting alignments. A significant change was also made to the MySQL server version in the `DbContextOptionsBuilder.cs` file. These adjustments help improve the readability and maintainability of the code, making it easier to understand and modify in future iterations.

* Remove unnecessary notification files and refactor code

Several files pertaining to workflow serialization notifications were deemed unnecessary and removed. The Endpoint class in the `Elsa.Workflows.Api` module has been refactored for efficient usage of the `IWorkflowDefinitionStore` store, and similarly the `HttpFeature.cs` and `DesignTimeDbContextFactoryBase.cs` files have been slightly refactored for better readability and optimization.

* Refactor HttpFeature class on variable types order

The variable types order within the HttpFeature class in the Elsa Http module has been reorganized for cleaner code. No functional changes have been made - only the order of the types has been rearranged. This refactoring contributes to better readability and code maintenance.

* Add 'issue/*' branch to GitHub workflow triggers

This update includes 'issue/*' branches in the trigger configuration of GitHub workflows. Now, these branches will trigger specified GitHub actions, facilitating more effective issue tracking and resolution.

* Change version option in WorkflowDefinitionManager

The version option in the WorkflowDefinitionManager has been updated. Previously it was set to "LatestAndPublished", but this has been changed to "LatestOrPublished", adjusting the way the manager handles workflow versions.

* Update GitHub Actions to remove duplicate branch pattern

Removed the duplicated 'issue/*' entry from the branch trigger list in packages.yml to prevent redundancy in GitHub Actions workflow triggers. This ensures workflows are triggered correctly and efficiently for branch patterns intended for CI processes.

* Refactor job generation in GenerateAlterationJobs

Refactored the GenerateAlterationJobs activity to enhance code readability and maintainability. Broke down the ExecuteAsync method into smaller, purpose-specific private methods and added the missing `Elsa.Alterations.Core.Models` namespace.

* Refactor consumer concatenation logic in MassTransitFeature

Removed the commented-out code that filtered temporary queues, simplifying the concatenation of consumer types with workflow message consumers.

* Refactor whitespace and improve readability

Removed extraneous whitespaces and reformatted the `IsEmpty` property for better code readability. This enhances the code structure without affecting functionality.

* Refactor MassTransitFeature configuration

Moved transport configuration logic into the dedicated `ConfigureInMemoryTransport` method and removed unused usings to simplify the `MassTransitFeature` class setup. This streamlines setting up MassTransit in-memory transport and improves code maintainability.

---------

Co-authored-by: Raymond den Haan <raymond.den.haan@nexxbiz.io>
Co-authored-by: Marius Vasile Vușcan <marius.vuscan@nexxbiz.io>
2024-03-13 20:34:46 +01:00
Sipke Schoorstra 03beb39cff Merge branch 'issue/5068' 2024-03-13 20:00:59 +01:00
Sipke Schoorstra e0a20c2dfc Add logging to OrderBatchProcessor workflow
Added a sequence with WriteLine activity to log processing of each order. Also, ensured the activity execution context properly sets its Tag property when a completion callback is provided.
2024-03-13 19:59:56 +01:00
Sipke Schoorstra c4543848ae
Refactor workflow instance listing and enum parsing (#5069)
Refactor the endpoint for listing workflow instances to use a more robust enum parsing method and improve validation. Update models to accept string collections for statuses and sub-statuses, which enables validating and parsing these enums directly within the endpoint.
2024-03-13 19:00:44 +01:00
Sipke Schoorstra 15518ba6db Refactor workflow instance listing and enum parsing
Refactor the endpoint for listing workflow instances to use a more robust enum parsing method and improve validation. Update models to accept string collections for statuses and sub-statuses, which enables validating and parsing these enums directly within the endpoint.
2024-03-13 18:59:05 +01:00
Sipke Schoorstra cad90e4e4e Remove FetchProducts activity and model
The FetchProducts.cs and Product.cs files have been removed as they are no longer needed. Additionally, changes in the OrderBatchProcessor.cs and FetchOrders.cs reflect updates to order fetching logic to accommodate these removals.
2024-03-13 12:07:39 +01:00
Sipke Schoorstra ee89b30e13 Add variable type management methods
Extended ModuleExtensions with methods for adding variable types, including with an alias, to aid in workflow variable management and organization. These new methods allow module users to register custom variable types easily and associate them with a category or alias.
2024-03-13 12:05:01 +01:00
raymonddenhaan 2dcaab9bf8
Prevented overwriting of existing workflows (#5067) 2024-03-13 10:05:50 +01:00
raymonddenhaan 395790d4d0
Added missing text parser for HTTP responses (#5066) 2024-03-13 09:48:18 +01:00
Sipke Schoorstra f7b010a518
Add Unicode string serialization tests (#5064)
Added tests in `Elsa.Workflows.Core.UnitTests` and `Elsa.JavaScript.UnitTests` to ensure unicode string serialization works correctly. Added a shared `UnicodeRangeGenerator` for test data generation and updated project references accordingly. Renamed `WorkflowDefinitionActivityJavaScriptHandlerTests.cs` to `ToJsonTests.cs` to reflect the focused test purpose.
2024-03-12 19:31:39 +01:00
zergmk2 cef0cceef0
Enhance: Add isStart property to determine if current node is a start node. (#5040) 2024-03-12 18:08:38 +01:00
Sipke Schoorstra 519ab07a1c Enhance JSON serialization
Introduced improved encoding by setting the JavaScriptEncoder to unicode ranges and added necessary using directives. Additionally, the Serialize method is now appropriately marked to indicate its use of code that requires unreferenced code during linking, following best practices for code that may be subject to trimming in a .NET environment.
2024-03-12 17:53:09 +01:00
raymonddenhaan f568df6767
Added check preventing duplicate workflow to update (#5060) 2024-03-11 13:57:17 +01:00
Sipke Schoorstra 555558dfe8
Add Unicode encoding support to serializers (#5049)
The update enriches the serializers with Unicode encoding to handle a wider range of characters. Classes such as ConfigurableSerializer, ObjectConverter, and JsonContentFactory have been modified to use JavaScriptEncoder with UnicodeRanges.All, supporting serialization and deserialization of all Unicode characters. Furthermore, any unreferenced code now carries a note for JSON serializer stating that it's incompatible with .NET's trimming feature.
2024-03-08 14:27:32 +01:00
raymonddenhaan 6084e29d47
Reverted bulk implementation (#5047) 2024-03-08 14:25:40 +01:00
Sipke Schoorstra 13304cdb64
Add Properties field to ActivityExecutionRecord and Regenerate V3_1 migrations (#5039) 2024-03-08 08:54:08 +01:00
Sipke Schoorstra 27c03ad7c3 Handle more JsonValueKind in DefaultExpressionDescriptorProvider
The commit adds a more comprehensive handling of different JsonValueKind values in DefaultExpressionDescriptorProvider.cs. Now `JsonValueKind.Undefined`, `JsonValueKind.Null`, `JsonValueKind.Object`, and `JsonValueKind.Array` are specifically addressed, improving the reliability of JSON manipulation within Elsa workflows.
2024-03-06 19:31:41 +01:00
Sipke Schoorstra 0d2adf297b Change version option in WorkflowDefinitionManager
The version option in the WorkflowDefinitionManager has been updated. Previously it was set to "LatestAndPublished", but this has been changed to "LatestOrPublished", adjusting the way the manager handles workflow versions.
2024-03-05 20:41:46 +01:00
MariusVuscanNx 8e619e49e6
Improved search to not require exact match (#5037) 2024-03-05 19:07:09 +01:00
Paul Ramsperger 87058ac147
Update VersionOptions.LastestAndPublished to set correct property (#5036) 2024-03-05 11:34:52 +01:00
Carbon 993c20ad86
fix missing metadata when persisting bookmark (#5026) 2024-03-05 11:33:46 +01:00
Sipke Schoorstra 0eb01c01f3
Add SearchTerm to Workflow Definitions List API client (#5035)
* Refactor search filtering and move ListWorkflowDefinitionsRequest file

Updated the searching mechanism in `WorkflowDefinitionFilter.cs` by validating that Name and Description are not null before performing the search. In `ListWorkflowDefinitionsRequest.cs`, the file was moved from the Responses namespace to Requests and a new property `SearchTerm` was added, allowing filtering of workflow definitions by their name, ID or description.

* Update code style settings for csproj

The .DotSettings file for the project has been adjusted with changes to code naming rules and settings migration. These modifications adjust policies for naming conventions of Instance and Static fields, enhancing code style conformance. Also, an additional settings migration rule has been applied.

* Add 'issue/*' branch to GitHub actions workflow

The GitHub actions workflow has been updated to include the 'issue/*' branch. This ensures that any changes made in the 'issue/*' branches will trigger the workflow and any associated tests or builds, improving the overall continuous integration process.

* Remove Skip and Take methods from SqlServerDialect

The mentioned functions have been removed from SqlServerDialect class in the Elsa.Dapper module. The base class provides the correct default implementation for the SQL Server dialect.
2024-03-05 07:31:59 +01:00
raymonddenhaan aa00e37993
Added logging to pinpoint issue #5033 (#5034) 2024-03-04 20:02:08 +01:00
faith 87428bcafe
Fix incorrect comment information in EFCoreWorkflowInboxMessageStore (#4979) 2024-02-29 20:25:03 +01:00
Isaac Hayes 5aa1ce85e6
Fix Security Bug: No permissions applied to version endpoints (#5008)
List,Delete, and Revert endpoints for editing endpoints by version were set to allow anonymous, meaning no authorisation policies were applied.

I have changed these to apply permissions as per the rest of the API.
2024-02-28 13:23:43 +01:00
Sipke Schoorstra ce27c9a279
Respond with 500 in case of Incidents (#5004)
* Modify error handling in Workflow middleware

The handling for workflow faults in the Workflow Middleware has been altered. Previously, the code was checking if the workflow state status was designated as 'Faulted'. Now it checks if there are any incidents or problems in the workflow state, which provides a more comprehensive fault check.

* Prevent deletion of all records with empty conditions

Added checks in the 'Delete' and 'PagedDelete' methods in the 'Store.cs' file to prevent the deletion of all records if the conditions are empty. This will protect the system from unintentional data loss by stopping the execution of these methods when they have no parameters.
2024-02-28 09:46:24 +01:00
Sipke Schoorstra 66a620b7d9
Disable Dapper and integrate EFCore.BulkExtensions.MIT package (#5005)
The changes involve turning off the use of Dapper in Elsa.Server.Web project for database operations. In addition, the `EFCore.BulkExtensions.MIT` has been added in the Elsa.EntityFrameworkCore.Common project as a package reference. The BulkUpsertAsync function has been refactored to utilize the BulkInsertOrUpdateAsync function provided by the BulkExtensions package, streamlining the operation. The related package versions have also been introduced in the Directory.Packages.props file.
2024-02-28 09:12:00 +01:00
Sipke Schoorstra d0736e5e88 Add dependency on InstanceManagementFeature
The AzureServiceBusFeature and RabbitMqServiceBusFeature in the Elsa.MassTransit module now have an added dependency on the InstanceManagementFeature. This change ensures the proper sequencing of feature initialization, enabling improved management of instances.
2024-02-26 15:21:33 +01:00
Sipke Schoorstra 330dc1a0d7
Fix Dapper Provider (#4998)
* Update Dapper for better support and pagination

The update includes a significant enhancement to the Dapper module. Improvements were made to support SQL Server and enhanced SQL query pagination. Additionally, table column size was increased for various fields to handle more extensive data. Minor refactoring was also done to improve code readability.

* Toggle SQL Server usage in Elsa Server

The previous setting had SQL Server usage in Elsa server enabled by default. This commit changes the useSqlServer constant in Elsa.Server.Web to false, effectively switching SQL Server off unless manually activated.
2024-02-25 20:36:31 +01:00
Sipke Schoorstra e48c5e2075 Enable Dapper and update its service registration
The Dapper usage flag has been set to true in the Elsa.Server.Web program. Additionally, in the Dapper feature, the DbConnectionProvider is now registered as a singleton instead of scoped, reflecting changes in the database connection strategy.
2024-02-25 14:23:46 +01:00
Sipke Schoorstra 4c41863e47 Disable Azure ServiceBus and RabbitMQ setup in Elsa Server
The changes made in the code comments out the sections where Azure ServiceBus and RabbitMQ were previously set up for the Elsa Server. This likely disables the respective services until the necessary configurations are uncommented or modified in the future.
2024-02-25 13:43:42 +01:00
Sipke Schoorstra 2f50470480 Update Docker commands in README
The Docker commands in README.md have been updated to pull the latest version of elsa-server-and-studio container instead of elsa-v3. Additionally, a new environment variable `HTTP__BASEURL` was added to the `docker run` command for configuration purposes.
2024-02-25 13:38:48 +01:00
Sipke Schoorstra 1caba6ddd6 Normalize collections in WorkflowManagementFeature
This commit ensures uniqueness within the 'ActivityTypes' and 'VariableDescriptors' collections in the WorkflowManagementFeature. 'ActivityTypes' has been updated to only add distinct activity types, and 'VariableDescriptors' has been refined to only add descriptors with unique 'Type' properties.
2024-02-25 13:33:38 +01:00
Sipke Schoorstra 7b0871750d Merge branch 'main' of https://github.com/elsa-workflows/elsa-core 2024-02-25 13:27:19 +01:00
Sipke Schoorstra 32827e7f5b Add RequiresUnreferencedCode attributes to methods
New RequiresUnreferencedCode attributes have been added to the Configure() methods in IFeature.cs and FeatureBase.cs. These attributes indicate that the assembly containing the specified marker type will be scanned for activity types.
2024-02-25 13:27:03 +01:00
Sipke Schoorstra 44b07ddae0 Modify data types in WorkflowManagementFeature
Expanded the primitive data types representations by adding int and float types in WorkflowManagementFeature. Removed the unused System.IO.Compression import to improve code cleanliness and maintainability.

Closes #4971
2024-02-25 13:26:55 +01:00
Christoph Keller 647e4f05a5
Example: added MassTransit triggered workflow example-project (#4968) (#4981)
* Added example for a programatic MassTransit triggered workflow (#4968)

* Fixed MassTransitActivities example to include the MassTransitDispatcher (#4968)
2024-02-25 10:07:28 +01:00
Sipke Schoorstra 640e888e1a Update serializer and dependencies in ConsoleApp
The code now uses IWorkflowSerializer instead of IActivitySerializer for deserialization in the Console application. This change also entailed updating imports, specifically replacing Elsa.Workflows.Activities with Elsa.Workflows.Management.Contracts.
2024-02-24 19:38:53 +01:00
raymonddenhaan 937398e351
Added workflow instance and bulk cancellation to the UI (#4965)
* Fixed issue where updated and finished date where not set when cancelling a workflow

* Single instance cancellation

* Updated bulk cancellation to allow multiple options

* Fixed counting of bulk cancellation

* Added proto actor implementation for batch cancellation

* Moved bulk cancellation method to separate service

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-02-23 10:26:13 +01:00
Sipke Schoorstra 5f47cd0aab
Implement distributed lock for registry population (#4983)
* Implement distributed lock for registry population

Added distributed lock in 'PopulateRegistriesHostedService' to prevent concurrent registry updates. Also implemented a semaphore in 'DefaultWorkflowDefinitionStorePopulator' to control access to shared resources during add or update operations. This change helps to ensure the integrity and consistency of the workflow registries.

* Refactor dependency injection for IDistributedLockProvider

* Refactor option classes to parameter classes in workflow runtime

This refactoring enhances the clarity of the Elsa Workflow runtime by renaming "options" classes to "parameters" classes. The name "options" misrepresented the classes' role and created confusion, as they are used to parameterize method calls rather than to configure services. The change applies to various workflow methods and tests across the project.
2024-02-22 19:37:03 +01:00
raymonddenhaan 2710d6e7af
Merge pull request #4941 from elsa-workflows/feature/service-bus-pub-sub
Introduced messaging to running instances
2024-02-22 14:16:33 +01:00
Raymond den Haan 459a9ae288 Used systemclock over datetime 2024-02-21 14:24:37 +01:00
Raymond den Haan 1f28215565 Scoped admin client to singleton 2024-02-21 14:24:22 +01:00
Sipke Schoorstra f37b3c424b Expand triggers and branches for GitHub Actions
The GitHub Actions configuration has been updated to also trigger on Push events and Workflow Dispatch events. OnPushBranches and OnPullRequestBranches now also include branches prefixed with 'feature', 'patch', 'fix', and 'enhancement'. This is reflected in both the Build.CI.GitHubActions.cs file and the packages.yml GitHub workflow.
2024-02-21 11:26:09 +01:00
Sipke Schoorstra 662a076726 Add simulated latency middleware
A new middleware, SimulatedLatencyMiddleware, has been added to simulate latency in a designated range. This can be used for testing purposes by delaying a request for a random amount of time. Additionally, an extension method for IApplicationBuilder has been implemented to conveniently add this functionality to the application's pipeline.
2024-02-21 09:25:59 +01:00