Commit graph

4396 commits

Author SHA1 Message Date
Raymond den Haan aa28329e47 rename DbExceptionHandlers to better reflect their intent. 2024-08-13 14:29:25 +02:00
Sipke Schoorstra c8669d1bc1
Add optional refresh parameter (#5876)
* Add optional refresh parameter

Renamed several `RefreshDescriptors` methods to `RefreshDescriptorsAsync` to reflect their asynchronous nature consistently. Added an optional refresh parameter in the `ListActivityDescriptorsRequest` class and updated related endpoints to handle this parameter, triggering a registry refresh if necessary.

* Update version to 3.2.0-rc5 in GitHub Actions

Modified the `packages.yml` workflow to change the version from `3.2.0-rc4` to `3.2.0-rc5` for non-tagged releases. This ensures version consistency with the new release candidate.
2024-08-12 09:42:25 +02:00
Sipke Schoorstra ef2dfd3957
Refactor journal data access and improve byte[] handling (#5878)
Switched to dictionary index access for "ResumeAt" in Delay.cs to ensure more efficient updating. Added handling for byte[] in ObjectConverter.cs to correctly deserialize from base64 strings.
2024-08-09 18:20:49 +02:00
rosca-sabina b6acb18dc6
Changed RegisterClassMap to TryRegisterClassMap on SerializedKeyValuePair classmap registration (#5877) 2024-08-09 18:14:09 +02:00
Raymond den Haan 7341f1f93a Add customizable DB exception handlers
Introduced customizable database exception handlers across various modules, enabling specific error handling strategies for different DbContexts. Implemented a generic interface for exception handling and provided specific implementations for PostgreSQL and a No-op handler. Updated the code to utilize these handlers in various persistence features, enhancing error management and modularity.
2024-08-08 16:08:01 +02:00
raymonddenhaan 1437635903
Merge pull request #5860 from elsa-workflows/enh/engine_ex
Add engine exception handling middleware
2024-08-07 11:37:48 +02:00
Raymond den Haan 4f90ee71d9 Add TODO 2024-08-07 11:33:38 +02:00
Raymond den Haan 9f841c70c6 Fix logger type 2024-08-07 09:48:31 +02:00
Sipke Schoorstra d2fc7fb005
Rework Workflow Context Feature (#5861)
* Refactor workflow context extension structure

Removed unused WorkflowContextWorkflowDefinitionExtensions and renamed several extension and middleware classes for clarity and consistency. Simplified context provider type handling using JsonArray in custom properties.

* Refactor context provider and update email workflow

Refactored `CustomerWorkflowContextProvider` to use constructor parameter directly, removing redundant fields and constructors. Updated comments and list syntax in `CustomerCommunicationsWorkflow`. Improved README.md documentation for workflow contexts and context providers.

* Adjust logging levels and improve workflow logic

Modified `appsettings.json` to reduce the verbosity of logging by adjusting log levels. Updated `CustomerCommunicationsWorkflow` to include a timer activity and simplified the workflow context parameter setting.

* Remove PropertyBag and related functionalities.

Deleted the PropertyBag class and extension methods, and removed all instances where PropertyBag was utilized across various modules. This simplifies the workflow configuration and management by relying solely on CustomProperties for storing metadata.

* Add workflow context management extensions and optimizations

Introduces `WorkflowExecutionContextExtensions` for loading and saving workflow contexts more efficiently. Replaces `JsonArray` usage with `List<object>` for context provider types, simplifying the type management in the workflow execution context. Streamlines `WorkflowContextActivityExecutionMiddleware` by removing redundant service scope creation and enhancing readability.

* Remove redundant timer in CustomerCommunicationsWorkflow

The timer activity that was set to not start the workflow has been removed to streamline the workflow process. Updated the README to include instructions on how to start the CustomerCommunicationsWorkflow using the REST API or Elsa Studio.

* Refactor middleware to streamline context management

Removed dependency on `IServiceScopeFactory` and refactored middleware to directly load and save workflow contexts. Simplified workflow context provider invocation, enhancing code readability and maintainability.

* Remove redundant PropertyBag property

The PropertyBag property was commented out and is no longer needed in the WorkflowDefinition class. This change removes the commented-out code to clean up the class definition.

* Add JsonSerializerOptions for deserialization

Introduce JsonSerializerOptions with camelCase policy and case insensitivity for property names. This ensures consistent deserialization of custom properties in activity workflow context settings.
2024-08-06 22:36:24 +02:00
Raymond den Haan de4a4b3505 Add engine exception handling middleware
Integrate new EngineExceptionHandlingMiddleware into the workflow execution pipeline to catch and log exceptions outside of running workflow activity.
2024-08-06 13:54:02 +02:00
raymonddenhaan c413f210a9
Add activity execution log sink (#5833)
* Add activity execution log sink

Introduced an interface `IActivityExecutionLogSink` for storing workflow execution log records and implemented it as `StoreActivityExecutionLogSink`. This centralizes and streamlines the handling of persisting execution logs into the workflow's runtime, thus making the process more modular and maintainable. The `PersistActivityExecutionLogMiddleware` has also been refactored to use this sink, replacing the direct usage of the workflow execution log store.

* Refactor logging interfaces and implementations

Replaced specific logging interfaces and implementations with generic ones. The individual interfaces for workflow and activity execution logging have been replaced with a single ILogRecordExtractor and ILogRecordSink interface. Specific implementations have been adjusted to use these new interfaces. This allows for greater flexibility and reuse of logging code.

* Introduce ILogRecordStore interface

The `ILogRecordStore` interface has been introduced to provide a centralized place for handling log records. Both `IActivityExecutionStore` and `IWorkflowExecutionLogStore` have been updated to inherit from this new interface. As a result of this change, the `SaveManyAsync` methods in these two interfaces have been removed to avoid redundancy.
2024-07-24 22:30:14 +02:00
Mohamed Ali 53cb8e75c3
fix workflow context execution middleware and scrip completion (#5802) 2024-07-20 12:35:56 +02:00
Sipke Schoorstra e5ba9a8a9d Refactor scheduling and system clock configurations
Moved specific services from Scoped to Singleton in SchedulingFeature and SystemClockFeature for better performance and consistency. Refactored DefaultWorkflowScheduler to use a constructor with an IScheduler parameter and removed redundant private field. Removed attribute RequiresUnreferencedCode in WorkflowManagementFeature.
2024-07-18 16:00:49 +02:00
Sipke Schoorstra 149f91e538
Update API endpoint for Polling Observer (#5787)
* Rename and refactor journal update endpoint

Replaced `/workflow-instances/{id}/journal/has-updates` endpoint with `/workflow-instances/{id}/updated-at` to simplify API responses. Deleted `HasUpdates` related classes and introduced `GetUpdatedAtResponse` for consistency and clarity. Updated client contracts accordingly.

* Remove HasUpdates endpoint and refactor workflow observer

Deleted the HasUpdates endpoint and refactored related code to use an updated timestamp approach instead. Improved nullable handling in WorkflowInstanceDesigner and ensured proper observer disposal to avoid memory leaks. Updated workflow observer factory and observer implementations to support observer names and enhanced logging.

* Rename updated workflow instance endpoint and handle execution state

Renamed the endpoint from "/updated-at" to "/execution-state" to better reflect its purpose. Updated related response models and documentation to capture workflow execution state details such as status, sub-status, and last updated timestamp.

* Enable SignalR for real-time workflows

Add a flag to use SignalR and activate real-time workflows when enabled. Refactor code to wrap SignalR setup in conditional checks based on the new flag. This enhances the application's interactivity through real-time capabilities.

* Remove obsolete endpoints and rename execution state paths

Deleted the outdated Api1 and DynamicWorkflows endpoints under Elsa.Server.Web. Also, renamed paths related to execution state models and endpoint to remove "Journal" from the namespace for better clarity and organization.
2024-07-18 07:51:46 +02:00
Sipke Schoorstra f448e9520a
Fix reloading logic for workflow definitions (#5781)
* Add reloading logic for workflow definitions

Introduced a new mechanism to handle reloaded workflow definitions. This includes creating a "ReloadedWorkflowDefinition" model, updating the caching logic, and modifying notification handlers to work with the enhanced workflow reloading logic. This ensures workflow definitions are updated and managed correctly when published, retracted, or deleted.

* Improve RefreshActivityRegistry documentation

Updated the XML documentation to clarify that `RefreshActivityRegistry` refreshes the `IActivityRegistry` for `WorkflowDefinitionActivityProvider` whenever workflow definitions are reloaded, instead of when they are published, retracted, or deleted.

* Add 'materializer' to user dictionary

The term 'materializer' has been added to the user dictionary to improve code spelling and naming consistency. This change ensures that 'materializer' is recognized as a correct term in the codebase.

* Organize test files by adding a 'Workflows' directory

Renamed 'http-workflow.json' to indicate it belongs under 'Workflows'. This improves file organization and clarity within the 'WorkflowDefinitionReload' scenario.

* Add TestWorkflowMaterializer and TestWorkflowProvider

Introduce `TestWorkflowMaterializer` for deserializing workflows from `TestWorkflowProvider`. Added integration of these new components in the `ReloadWorkflowTests` and `WorkflowServer`. Also renamed `RemoveReloadWorkflowTests` to `ReloadWorkflowTests`.

* Rename and expand workflow reload tests

Renamed `RemoveReloadWorkflowTests` to `ReloadWorkflowTests` to better reflect its purpose and expanded with additional test cases. Added tests to verify workflow and activity registry updates after source provider changes and workflow reloads.

* Update copy settings for workflow test scenarios

Reorganized and added 'CopyToOutputDirectory' settings for JSON files in workflow test scenarios. Ensured all necessary files are correctly included and copied during output directory builds to maintain test consistency.
2024-07-17 09:51:45 +02:00
Raymond den Haan 85c701e5d0 Overwriting System.Formats.Asn1 due to vulnerability 2024-07-16 15:04:46 +02:00
Mohamed Ali a0846effae
bugfixing issues related to new PropertyBag in workflow definition (#5778) 2024-07-16 14:54:20 +02:00
Raymond den Haan a69492d521 Overwritten System.Text.Json version due to vulnerability 2024-07-16 14:31:20 +02:00
Sipke Schoorstra 9fb51c6cd0 Add functions to get workflow definition details
Introduced three new functions: `getWorkflowDefinitionId`, `getWorkflowDefinitionVersionId`, and `getWorkflowDefinitionVersion`. These functions provide easy access to specific workflow definition details within the JavaScript evaluator. Removed redundant constructor in CommonFunctionsDefinitionProvider to streamline the code.
2024-07-16 13:55:23 +02:00
Sipke Schoorstra 1a0d4714bd
Update activity ID reference in BroadcastWorkflowProgress (#5767)
Replaced the use of ActivityId with ActivityNodeId when retrieving distinct activity IDs. This change ensures that we are using the correct node identifier for logging workflow progress.
2024-07-16 07:58:27 +02:00
raymonddenhaan a96180ed8b
Merge pull request #5751 from elsa-workflows/enh/journal_polling
Added endpoint to poll for journal updates
2024-07-12 08:43:28 +02:00
MariusVuscanNx feb7da4d28
Implemented workflows reload endpoint (#5732)
* Implemented workflows reload endpoint

* Added componenent tests for reload

* Adjusted cache handling

* Made the refresh endpoint return refreshed and not found definitions

* Update test/component/Elsa.Workflows.ComponentTests/Scenarios/WorkflowDefinitionReload/RemoveReloadWorkflowTests.cs

Fix typo

Co-authored-by: raymonddenhaan <155616759+raymonddenhaan@users.noreply.github.com>

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
Co-authored-by: raymonddenhaan <155616759+raymonddenhaan@users.noreply.github.com>
2024-07-12 08:35:46 +02:00
Raymond den Haan e52d716eaa Used DateTimeOffset instead of DateTime 2024-07-12 08:26:21 +02:00
Sipke Schoorstra 1c7a96034c Merge branch 'patch/3.2.x' of github.com:elsa-workflows/elsa-core into patch/3.2.x 2024-07-11 22:09:32 +02:00
Sipke Schoorstra 1c068373fd Refactor API client DI methods for cleaner configuration
Refactor `AddElsaApiKeyClient`, `AddElsaClient`, and related methods to improve readability and maintainability. Introduced `AddDefaultApiClientsUsingApiKey`, `AddDefaultApiClients`, and `AddApiClients` for a more structured approach, consolidating redundant code and ensuring better configurability.
2024-07-11 22:09:13 +02:00
Raymond den Haan bd3797dea5 Fix datetime conversion when sending datetime to API endpoints 2024-07-11 15:18:17 +02:00
raymonddenhaan d777252e77
Merge pull request #5728 from elsa-workflows/enh/log_extractor
Add WorkflowExecutionLogRecordExtractor
2024-07-11 10:56:14 +02:00
Raymond den Haan 99c0797438 Add endpoint for checking for journal updates 2024-07-11 10:34:09 +02:00
Sipke Schoorstra 7e29472b87 Merge branch 'patch/3.2.x' of github.com:elsa-workflows/elsa-core into patch/3.2.x 2024-07-10 19:48:10 +02:00
Sipke Schoorstra dc4f904108 Update workflow revert to return summary and location
Enhanced the Revert endpoint to return a summary of the newly created workflow definition and include its location. Adjusted the API contract and endpoint configuration accordingly.
2024-07-10 19:47:50 +02:00
raymonddenhaan c7b5caafdc
Added aliases for all missing types used in UI (#5743) 2024-07-10 18:38:11 +02:00
Sipke Schoorstra 59bc7bc6a2 Add caching modules to project references
Included Elsa.Caching.Distributed.MassTransit and Elsa.Caching.Distributed as project references in Elsa.ServerAndStudio.Web.csproj. This integration aims to enhance caching capabilities in the application.
2024-07-10 17:58:28 +02:00
Sipke Schoorstra 4d41cd743b Add DistributedCachingTransport enum
Introduced the DistributedCachingTransport enum to define caching transport options. Also cleaned up the code by removing an unnecessary using directive and a commented summary in the MassTransitBroker enum.
2024-07-10 15:32:01 +02:00
Sipke Schoorstra 073598c748 Remove obsolete project reference
Deleted the project reference to Elsa.Server.Web.csproj from Elsa.ServerAndStudio.Web.csproj. This reference is no longer needed and was causing redundancy in the project configuration.
2024-07-10 15:28:50 +02:00
Sipke Schoorstra dc89caefe8
Add ActivityNodeIds filter to journal requests (#5741)
This commit introduces the ActivityNodeIds filter to the journal request models. This enhancement allows filtering logs based on specific activity node IDs, providing more granular control over workflow instance logs. Additionally, unnecessary summary comments have been removed for clarity.
2024-07-10 11:38:09 +02:00
Sipke Schoorstra 558486920b
Add PropertyBag for non-polymorphic data transfer between server and client (#5735)
* Fix issues with workflow deletion, newline, and DB context.

Retract published workflows before deletion to avoid exceptions. Added missing newline at EOF for consistency. Removed redundant DisposeAsync call in migration service.

* Add PropertyBag for storing custom workflow properties

Replaced `CustomProperties` with `PropertyBag` class for more structured property management across workflows. Adjusted serializations, extensions, and middleware for seamless integration with the new `PropertyBag` structure.
2024-07-10 10:29:45 +02:00
Raymond den Haan 73b00fa607 Added missing service registration 2024-07-09 08:32:35 +02:00
Raymond den Haan f3a8ff5e47 Add WorkflowExecutionLogRecordExtractor
Introduced a new service, WorkflowExecutionLogRecordExtractor, to abstract the logic for extracting workflow execution logs records from the WorkflowExecutionContext. Updated StoreWorkflowExecutionLogSink to use this new service, which simplifies the execution log persistence method. This modification enhances code readability and enables potential reuse of the extraction logic.
2024-07-08 16:13:58 +02:00
Sipke Schoorstra 895598fb70 Change MassTransit broker to in-memory
Switched the MassTransit broker configuration from RabbitMQ to in-memory. This change aims to simplify local development and testing by using an easier-to-configure broker.
2024-07-05 19:07:23 +02:00
Sipke Schoorstra 85857f0312 Merge branch 'patch/3.2.x' of github.com:elsa-workflows/elsa-core into patch/3.2.x 2024-07-05 18:38:09 +02:00
MariusVuscanNx 6110eb561f
Workflow refresh feature (#5713)
* Refactor workflow definition events handling and dispatch

Removed IDistributedWorkflowDefinitionEventsDispatcher interface and related classes in favor of direct message publishing through MassTransit. Introduced new workflow definition refresh endpoints and services for better modularity and responsiveness. Adjusted caching and notification systems to support the new architecture.

* Add comment

* Added workflow definition refresh component test

* Fixed component tests issue

* Fixed id

* Fixed test

* Rename IsRaisedFromConsumer to IsConsumerExecutionContext

Updated the naming for clarity and consistency across the system. This change affects AmbientConsumerScope, related consumers, and condition checks to improve readability and understanding of the consumer context.

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-07-05 18:35:22 +02:00
Sipke Schoorstra 5c7693b4af Improve comment for workflow execution context creation.
Changed comment to enhance readability and clarity. The modification adds the article "a" to the description, providing a better understanding of the workflow execution context creation process.
2024-07-05 18:20:34 +02:00
Sipke Schoorstra dc81cbb31d Refactor RunAsync method signature in WorkflowRunner.
Updated the RunAsync method in WorkflowRunner to consolidate its parameters onto a single line for improved readability and simplicity. This change does not affect the functionality but enhances code maintainability.
2024-07-05 18:20:11 +02:00
Sipke Schoorstra 1574b491ad Fix nullability issue and improve code comments
Ensure strict nullability checks by using the null-forgiving operator in IsInitialized. Additionally, rewrite comments for conciseness and clarity to enhance readability and understanding.
2024-07-05 18:18:12 +02:00
Raymond den Haan 9c072566ce Add workflow execution log sink
Introduced an interface `IWorkflowExecutionLogSink` for storing workflow execution log records and implemented it as `StoreWorkflowExecutionLogSink`. This centralizes and streamlines the handling of persisting execution logs into the workflow's runtime, thus making the process more modular and maintainable. The `PersistWorkflowExecutionLogMiddleware` has also been refactored to use this sink, replacing the direct usage of the workflow execution log store.
2024-07-04 15:47:34 +02:00
raymonddenhaan 6f36cfff0c
Update serialization and conversion functions (#5682)
* Update serialization and conversion functions

Updated JSON conversion to be able to use type aliases when saving serialized data to the DB.

* Simplify and update type alias registration.

Removed redundant XML comments and replaced IDictionary type aliases with Dictionary equivalents for consistency. These changes improve code readability and maintainability.

* Use collection initializer syntax

* Change "_type" values to "ObjectDictionary" in test files

Updated the "_type" field in various JSON test files from multiple different values to a unified "ObjectDictionary". This ensures consistency across the test files and aligns with the expected type format.

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-07-03 20:47:46 +02:00
Sipke Schoorstra 1be3b43c76
Update endpoints for lazy loading (#5681)
* Add workflow ancestor retrieval endpoint

Implemented an API endpoint to retrieve ancestor nodes of a specified child node within a workflow definition. This includes creating models and updating relevant interfaces to support the new functionality.

* Refactor workflow graph processing logic

Refactor to check `workflowGraph.Root` for null and streamline ancestor traversal logic. Ensure segments are processed correctly even when no ancestors are present, enhancing code readability and reliability.

* Fix node lookup error and stack segment order in endpoint

Added a safeguard to handle unknown node IDs by returning an error message. Replaced the segments list with a stack to ensure correct order and adjusted the logic for processing and responding with node ancestors.

* Fix workflow definition container null reference issue

Refactored the container assignment logic to handle cases where no leaf segment is found, ensuring it defaults to `childNode` if ancestors are empty. Additionally, added a TODO comment in DiagramDesignerWrapper.razor.cs for loading activity nodes if not already loaded.

* Refactor segment retrieval logic in Endpoint.cs

Replaced the use of `FirstOrDefault()` with `LastOrDefault()` to correctly identify the leaf segment. This change ensures that the container is set based on the last segment in the sequence, aligning with the intended logic.

* Add support for excluding activity types in filters

Introduced properties to exclude specific activity types in workflow execution log filters. Updated respective APIs and database extensions to utilize these new filtering capabilities, ensuring refined and more customized query operations.

* Refactor comments and add missing annotations

Updated various comments to be more precise and added `[UsedImplicitly]` annotation to `ActivityPathSegment` in `Elsa.Api.Client.Shared.Models`. Also, removed unnecessary folder reference in the `Elsa.Workflows.Api.csproj` file. These changes enhance clarity and maintain consistency across the codebase.

* Refactor workflow type checks and add ActivityExtensions.

Replaced string type checks with type comparisons for Workflow and Flowchart activities. Introduced an extension method in the newly created ActivityExtensions class to streamline flowchart type validation.

* Remove ActivityExtensions and update workflow comments

Deleted ActivityExtensions.cs as it was no longer needed. Updated comments in Models.cs and ActivityPathSegment.cs for clarity and accuracy.
2024-07-01 11:14:04 +02:00
Raymond den Haan 63ae2ad649 Fix subscription name matching in RemoveOrphanedSubscriptions 2024-06-25 09:43:19 +02:00
Sipke Schoorstra b5e3af7b85
Lazy loading of subgraphs (#5643)
* Refactor activity serialization process

Refactored the activity serialization process in Elsa workflow API. The changes include addition, modification and deletion of code blocks across various files to accommodate the restructuring. The changes focus primarily on the handling of composite root activities and their serialization. The utility of configuration options for serializer is also implemented.

* Stash

* Add IgnoreChildActivitiesConverter and improve activity JSON conversion

A new JSON converter, IgnoreChildActivitiesConverter, has been introduced to handle specific serialization scenarios. On top of this, improvements have been made to the existing ActivityJsonConverter. This includes more robust handling of synthetic properties and the ability to ignore child activities during serialization. In DiagramDesignerWrapper, an addition has been made to facilitate the handling of embedded activities.

* "Implement activity port tracking in workflow system"

Modified several components of the workflow system to include activity port tracking for better visibility and control over workflow structures. In addition, unnecessary files were deleted, new ones were introduced, and changes were made to existing files to incorporate the new functionality. Notably, IActivityResolver interface now includes GetActivityPortsAsync method to allow retrieving activity ports. This enhances the ability to track actions in complex workflows.

* Add specialized converter check in activity serialization

The commit introduces a check for specialized JSON converters in two serialization methods inside `ActivityJsonConverter.cs` and `ActivityNodeConverter.cs`. If a specialized converter exists for a particular activity type, the serializer now uses it to serialize the activity, enhancing the serialization process's flexibility.

* Ignore serialization of ConfigureSerializerOptions

Added JsonIgnore attribute to the ConfigureSerializerOptions in the ActivityDescriptor class. This will prevent it from being included during the JSON serialization process, ensuring that it is not unnecessarily processed or exposed in serialized data formats.

* Refactor method to find WorkflowDefinition instead of WorkflowGraph

The method FindWorkflowGraphAsync was revised to find WorkflowDefinition rather than WorkflowGraph, reflecting its new purpose in the code. This change has also affected the related variables and logic where this function was called. The rationale for this revision is that the WorkflowGraph is a dynamic entity that should be computed at runtime, and hence cannot be reliably retrieved for static inspection.

* Update API endpoint and simplify request handling in workflow

The API endpoint for fetching workflow definitions graph has been changed from "/workflow-definitions/{definitionId}/graph" to "/workflow-definitions/subgraph/{id}". Similarly, the request handling has been simplified by removing version options and directly passing "Id" to the "FindWorkflowGraphAsync" method.

* Update import statements and remove unused dependencies

Some import/using statements have been adjusted to remove the 'Contracts' suffix in contexts where it's not necessary. A few unused dependencies have also been removed. These changes clean up the code and ensure proper functionality in the Elsa workflows system.

* Update .editorconfig settings

The .editorconfig settings have been revised to enforce inheritance of settings from higher directories. Additionally, the parameter 'file_header_template' has been removed. This update optimizes the configuration settings for better coding standards across C# files.

* Remove App_Data folder from Elsa.Server.Web.csproj

The App_Data folder reference has been removed from the Elsa.Server.Web project file. This change is included as the folder no longer seems necessary for the operation of the project.

* Remove unused namespace in ServiceProviderExtensions.cs

The Elsa.Workflows.Runtime.Options namespace, previously imported in the ServiceProviderExtensions file within the Elsa.Testing.Shared project, has been removed as it is not utilized. This cleanup enhances readability and maintains cleaner code.

* Implement GetActivityPortsAsync method in various classes

Added the implementation of GetActivityPortsAsync method in WorkplaceDefinitionActivityPortResolver, SendHttpRequestActivityPortResolver, OutboundActivityPortResolver, and SwitchActivityPortResolver classes. Changes also include adding inheritdoc comments for these methods, making GetActivityPortsInternal method private and static, and removing unneeded white spaces.

* Remove GetActivitiesAsync method from activity resolvers

The GetActivitiesAsync method has been removed from various activity resolver classes including WorkflowDefinitionActivityPortResolver, SendHttpRequestActivityPortResolver, OutboundActivityPortResolver, and SwitchActivityPortResolver. The corresponding interface IActivityResolver has also been updated to reflect this change. This simplifies the structure by focusing only on the activity ports.

* Simplify workflow definition serialization

Removed the cloning of serializer options and the exclusion of composite activities from being serialized in the workflow definition model. This simplification results in cleaner code with less redundancy and unnecessary operations.

* Refactor workflow definition endpoints, optimize response handling

Major refactor of workflow definition endpoints in the Elsa.Workflows.Api module. Unnecessary serialization processes have been removed. Response handling was also streamlined to use the SendOkAsync method, optimizing resource usage and increasing application performance. Commit also includes removal of some unused namespaces.

* Remove IncludeCompositeRoot property from Models

The IncludeCompositeRoot property has been removed from the Models in the GetByDefinitionId, GetById, and GetManyById endpoints. These changes simplify the code as the property was commented out and not used in current workflow logic.

* Simplify workflow definition publishing process

This commit simplifies the workflow definition publishing process in the Elsa.Workflows.Api module. The code associated with checking if a workflow definition is already published and publishing it if not has been reduced for increased readability and maintainability.

* Refactor code in workflow publish endpoint

Removed unused import for better code clarity and simplified variable declaration for publishing result. The refactoring is carried out to improve code readability and maintainability in the workflow definition publishing endpoint.

* Refactor ActivityPort in Elsa.Workflows module

This commit simplifies the code in the ActivityPort class, part of the Elsa.Workflows module. It includes a significant rework of the comments for better clarity and understanding. Effort has been made to make the code more readable and easier to maintain in this refactor.

* Refactor serialization methods and improve Synthetic Properties handling

This commit refactors the activity serialization methods and improves the handling of synthetic properties. The changes remove the IgnoreChildActivitiesConverter and move synthetic property writing to a separate helper class, SyntheticPropertiesWriter. Various refinements have been made to different converter classes to better handle activity serialization. Furthermore, a function's name was improved from "FindWorkflowGraphAsync" to "GetWorkflowDefinitionAsync" to more accurately reflects its purpose.

* Add ActivityWriter to help serialize workflow activities

This commit introduces a new class ActivityWriter, that handles the serialization of workflow activities to JSON. Other classes such as ActivityNodeConverter and ActivityJsonConverter have been refactored to utilize this new helper. The codebase is now more DRY, avoids duplicate code and increases code maintainability.

* Refactor Json serialization for ignoring specialized converters

Removed 'IActivityRegistry' from 'JsonIgnoreCompositeRootConverter'. Instead, added an 'ignoreSpecializedConverters' argument to the 'WriteActivity' method in 'ActivityWriter'. This adjustment facilitates managing specialized converter behavior more efficiently during JSON serialization.

* Update ActivityNode serialization description

The comments for the ActivityNodeConverter class have been modified to clarify the serialization process. It now explicitly states that it includes descendant nodes based on the specified depth rather than just immediate child nodes. The parameter 'depth' description has been updated to 'the number of levels of descendants to include'.

* Refine workflow serializer and update activity writer parameters

The WorkflowSerializer clone operation has been simplified to directly call GetOptions from the API Serializer. Furthermore, an unnecessary comment was removed. In the ActivityWriter, an additional parameter was introduced for controlling whether to ignore the availability of converters that can handle IActivity objects. A superfluous front slash was removed from the class description comment.

* Add WorkflowJsonStructureTests and related JSON files

This commit introduces the WorkflowJsonStructureTests class which includes tests for the structure of the workflow definition in JSON format. In addition, main.json and sub.json files, containing mock data for testing, were added to the `WorkflowJsonStructures` scenario within the Elsa Workflows Component Tests. Updates to the project file ensure these new files are included correctly.

* Update WorkflowJsonStructureTests with subgraph test

This commit introduces a new test case named 'Requesting_Subgraph_Returns_ExpectedSubgraph' in the WorkflowJsonStructureTests file. It also refactors 'Workflow_ContainingWorkflowActivity_ShouldNotIncludeChildrenOfWorkflowActivity' test to make use of constants for IDs. These changes increase the coverage and maintainability of the code.

* Update max line length in .editorconfig

This commit increases the max line length to 420 characters in the .editorconfig. Additionally, it removes the redundant 'resharper_csharp_max_line_length' setting.

* Replace ActivityNodeConverter with RootActivityNodeConverter

The commit involves a change in serialization strategy for ActivityNode in the Elsa Workflows modules. The ActivityNodeConverter has been replaced with a RootActivityNodeConverter, which changes the approach from serializing the ActivityNode type and its descendants based on specified depth to serializing the ActivityNode type without its children, with activity children now serialized as properties. Corresponding alterations have also been made in the test cases.

* Remove IActivityRegistry parameter from classes

The IActivityRegistry parameter was removed from WorkflowDefinitionActivityProvider and JsonIgnoreCompositeRootConverterFactory classes, simplifying their constructors. This change also affected Elsa.Workflows.ComponentTests where the node access through "root" was adjusted for these updates.
2024-06-25 09:21:50 +02:00
Raymond den Haan 171f147801 Update workflow definition registry and retraction handling
This update enhances the handling of workflow definition retraction across multiple files and includes new notifications for workflow definition version retraction. The logic for updating the workflow definition registry has been adapted to keep published workflows in the registry unless they are no longer marked as an activity.
2024-06-24 11:09:19 +02:00