Commit graph

4508 commits

Author SHA1 Message Date
Sipke Schoorstra 8388f28a89 Add JavaScript library support
Introduce support for Lodash and Moment libraries in the JavaScript engine. Also configure project settings and Weavers for consistent code quality and behavior.
2024-10-06 20:29:14 +02:00
Carmine Francesco Giugliano 19bca063da
feat: add ITasksApi to Elsa.Api.Client (#5995)
* feat: add ITasksApi to Elsa.Api.Client

* fix ReportTaskCompleted method name

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-10-03 19:33:29 +02:00
sagargolu 59164bbcf5
fix: issue fixed for triggering correct workflow definition versionId (#5979)
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-10-03 19:26:12 +02:00
Sipke Schoorstra 108e928335 Update WebhooksCore to preview.17 and add HTTP client config
Upgraded WebhooksCore package version from 0.0.1-preview.16 to 0.0.1-preview.17. Introduced a new configurable HTTP client action in the WebhooksFeature class to support extended configurations.
2024-10-02 20:53:21 +02:00
Sipke Schoorstra bbedd61138
Implement Activity State Filtering and JavaScript Integration (#5993)
* Add secret scripting integration for JavaScript

Introduced a new `Elsa.Secrets.Scripting` module that provides secret management capabilities within JavaScript workflows. This includes configuring the Jint engine to use workflow variables, adding new type and variable definition providers, and integrating with existing secret management features.

* Refactor secret name extraction to a separate method

Moved the logic for extracting secret names from the main method to a dedicated private method `GetSecretNamesFromExpression`. This improves code readability and maintains the single responsibility principle by delegating secret name extraction to its own method.

* Add input evaluation, sensitive input handling, and middleware refactor

Introduced methods for evaluating activity input properties and handling inputs marked as sensitive. Refactored `ExecutionLogMiddleware` constructor for consistency. Enhanced `SendHttpRequestBase` to mark authorization inputs as potentially containing secrets. Removed obsolete entries and adjusted persistence logic for clarity.

* Refactor IActivityStateProtector interface

Remove unused using directives and unnecessary comments. Simplify the definition of the `ProtectedActivityStateContext` record.

* Add activity state filtering mechanism

Introduce an abstract filter base class, context, and result models to enable filtering of activity state. Implement a default filter manager to run these filters and apply a specific filter for obfuscating HTTP request headers. Update necessary dependencies and extension methods to integrate the new filtering functionality.

* Add expired secrets management

Implemented services to manage expired secrets by periodically checking and updating their status. Introduced a new hosted service to perform the sweep and configurable options for the sweep interval. Updated related classes and configurations accordingly.

* Update SweepInterval in appsettings.json

Changed the Secrets Management SweepInterval from 30 seconds to 4 hours. This adjustment aims to reduce the frequency of sweep operations and improve overall system performance.

* Update comment to reflect configuring engine with secrets

The comment was changed to better describe the handler's function, specifying that it configures the Jint engine with secrets instead of workflow variables. This clarifies the purpose and usage of the handler in the context of the code.

* Remove unused inputDescriptors variable

This commit removes the inputDescriptors variable, which was declared but never used in DefaultActivityExecutionMapper.cs. This helps in cleaning up the code and potentially reducing memory usage. Ensuring that all declared variables are utilized can improve code readability and maintainability.
2024-10-02 09:11:35 +02:00
Marko Lahma 12f947cf9b
Upgrade Quartz and some warning fixes (#5949)
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-09-16 01:55:24 -07:00
Sipke Schoorstra 290eb9fe19 Update variable storage types and fix JavaScript handling
Changed storage driver types for 'Products' and 'Product' variables to `WorkflowInstanceStorageDriver`. Refactored JavaScript handling to properly process variables and exclude input names from overwriting. Re-enabled a previously skipped array sorting test.
2024-09-16 01:49:53 -07:00
Sipke Schoorstra 329a79be2e
Secrets API (#5967)
* Add initial implementation for Elsa Secrets modules

This commit introduces new projects for managing secrets within the Elsa framework: `Elsa.Secrets.Api`, `Elsa.Secrets.Core`, and `Elsa.Secrets.Management`. These projects include essential interfaces, models, entities, and endpoints to handle secret storage, retrieval, and management. Specific features include API endpoints for listing secrets, models for secret filtering, and interfaces for encryption key handling.

* Add weavers

* Refactor encryption handling in secrets management

Implemented a new architecture for handling encryption keys and algorithms within the secrets management system. Replaced old encryption key entities and related interfaces with a more modular and extensible approach. Added new services and models to improve encryption and decryption processes, enhancing maintainability and scalability.

* Add IEncryptor interface for encryption functionality

Introduced the IEncryptor interface to standardize encryption operations within the Elsa.Secrets.Management module. This interface includes the EncryptAsync method to handle encryption using a specified key ID and value.

* Add dependency on SecretsFeature and configure secrets provider

Integrate the SecretsFeature dependency and configure a secrets provider within the SecretsManagementFeature class. This adds the StoreSecretProvider to the service collection and ensures the secrets provider is correctly set up. Also, rename method from WithSecretsProvider to UseSecretsProvider for clarity.

* Add EF Core and SQLite support for Secrets module

Introduced Entity Framework Core and SQLite support for the Secrets module, including migration files, EF Core configurations, context factory, and store implementation. Added necessary extensions and configuration code to integrate with the existing API and features. Included updates to the main web application to utilize the new persistence providers.

* Update Microsoft.SemanticKernel to version 1.18.2

Upgrade Microsoft.SemanticKernel package to the latest version to ensure compatibility and new features. Remove unused Elsa.Agents.Persistence using directive from Program.cs for code cleanliness.

* Update workflows and add Agents module

Changed workflow branch targets from `main` to `feature/secrets`. Updated Docker image tags and added the `Agents` module to the Elsa Studio WebAssembly project.

* Enable agent activities in workflow configuration

This change introduces the `.UseAgentActivities()` method in the workflow configuration, enhancing the workflow capabilities. By doing so, it ensures that agent activities are appropriately integrated and available for use in the application.

* Add EF Core migrations for MySQL and SQL Server

Added Entity Framework Core migrations and related configurations to support MySQL and SQL Server for the Agents Persistence module. These changes include new migration files, context factories, and project configurations.

* Fix migration assembly reference and update method syntax

Changed the migration assembly reference in SqlServerProvidersExtensions. Updated method syntax in WorkflowManagementFeature to use array shorthand format.

* Add secret management functionalities

Introduced secret management services with CRUD operations, notifications, and bulk actions. Added unique name generation and validation for secrets, and implemented corresponding API endpoints.

* Enhance Secret Management Feature

Added Elsa.Extensions import and updated MemorySecretStore registration to use the AddMemoryStore method with Secret. This improves code modularity and adheres to the updated registration method conventions.

* Remove encryption services and update migration

Removed multiple files related to encryption services and their dependencies, including encryption algorithms and key providers. Also updated a migration script to reflect schema changes, removing specific columns and constraints.

* Implement versioning and retrieval for secrets management

Added "IsLatest" flag and cloning mechanism for secrets to support versioning. Introduced a new API endpoint for fetching decrypted secret input models. Refactored encryption and decryption logic to handle empty values gracefully.

* Add secret management functionalities

Introduced services and interfaces for secret name generation, validation, and updating. Updated secret handling to include expiration metadata. Refactored methods in ISecretManager to streamline secret creation and update processes.

* Remove DisableSyntaxSelection class and references

Deleted the DisableSyntaxSelection class and its references from various files. This includes removing its registration as a Scoped service and associated usage in the `RunJavaScript` activity.

* Add new migration for secrets and update DefaultSecretManager

Re-created migration files for V3_3 to include the ExpiresIn column. Updated DefaultSecretManager to utilize identityGenerator for generating Id and SecretId, and added additional fields like CreatedAt, UpdatedAt, and IsLatest.
2024-09-15 17:12:13 -07:00
DnikitaA 51910810c1
Remove obsolete package MassTransit.Extensions.DependencyInjection (#5955)
Co-authored-by: Никита Данилов <ndanilov@loginet.ru>
2024-09-12 09:53:55 -07:00
Sipke Schoorstra 760a3e2cb5 Refactor context property handling with JSON serialization
Refactor property handling in ParallelForEachT to use JSON serialization for tag lists. Simplify the storage and retrieval of tags using helper methods GetTagList and SetTagList. Update storage driver types for variables to use WorkflowInstanceStorageDriver.
2024-09-06 22:45:38 +02:00
Sipke Schoorstra 48f0f72009 Enable ProtoActor and Add Agent Support
Enabled ProtoActor by setting `useProtoActor` to true. Integrated Elsa Agents API and persistence mechanisms. Refined tag handling in ParallelForEachT activity.
2024-09-06 22:45:31 +02:00
Sipke Schoorstra 2c0f5bb6b7 Update For activity to support variable passing to iterations
This commit introduces support for passing variables to iterations within the For activity. It includes a null check on the iterateNode and schedules the activity with currentValue as a variable, enhancing functionality without altering existing logic.
2024-09-06 20:18:54 +02:00
Sipke Schoorstra 21eb1034a5 Move HTTP configuration to separate section
Updated Program.cs to bind HTTP options from the "Http" section instead of "Hosting". Added the new "Http" section in appsettings.json to separate concerns and better organize the configuration settings.
2024-09-06 19:08:56 +02:00
Sipke Schoorstra 0827df7d33 Update HTTP configuration to use 'Hosting' settings
Changed the binding of HTTP options to 'Hosting' settings in Program.cs to ensure consistent configuration across the application. Removed redundant 'Http' configuration section from appsettings.json.
2024-09-06 19:06:59 +02:00
Sipke Schoorstra 83a8de6aae Change default BaseUrl port to 8080
Updated the appsettings.json to change the BaseUrl port from 5001 to 8080. This modification aligns with the new server configuration requirements.
2024-09-06 18:46:20 +02:00
Sipke Schoorstra 5b583f45d6 Update base URL retrieval to use configuration setting
Replaced hardcoded base URL construction with a configuration-based approach for better management and flexibility. Updated `appsettings.json` to include the new `BaseUrl` setting under the `Hosting` section.
2024-09-06 18:40:40 +02:00
Sipke Schoorstra d6c14d9878
Simplify Workflow Variables with JS (#5946)
* Add variable support and engine configuration for JavaScript

Implemented handling of workflow variables in JavaScript expressions, including new handlers, notifications, and variable definitions. Enhanced type definition services and providers to include variable definitions, updated dependency injections, and applied modifications for improved backend API configuration.

* Add ObjectConverterHelper for JS object conversion

Implemented ObjectConverterHelper to convert .NET objects to JavaScript objects in EvaluateJavaScript context. Updated ConfigureEngineWithVariables handler to process and convert variables using the new helper utility.

* Add Customer and Order models and update Program.cs

Created new Customer and Order model classes in the Models namespace. Updated Program.cs to include and alias these models for use in the application.

* Add two new activities and integration test

Introduced `Activity1` and `Activity2` under `src/apps/Elsa.Server.Web/Activities`. Additionally, created a new integration test `VariablesInteropTests` to validate JavaScript variable modifications within workflows.

* Refactor to use IBookmarkQueue instead of IBookmarkResumer

Replaced IBookmarkResumer with IBookmarkQueue in various classes for enqueueing bookmark queue items. Added logging for better traceability and included additional helper imports for activity type name generation.

* Add correlationId tag to OpenTelemetry tracing

This change adds a correlationId tag to the tracing for workflow executions if the context contains a correlationId. This enhancement improves traceability and correlation across distributed systems.

* Set Correlation ID header in MassTransit messages

Added logic to set the "X-Correlation-ID" header in MassTransit messages if the CorrelationId is present. This ensures that the messages can be correlated properly across different parts of the system.

* Reduce logging verbosity in appsettings.json

Removed detailed debug logs for various Elsa workflows and middleware components from the appsettings.json. This change aims to streamline the log outputs, focusing on warnings and critical information to improve readability and debug efficiency.

* Add OpenTelemetry.Api package version 1.9.0

Include OpenTelemetry.Api to list of package versions in Directory.Packages.props. This addition aims to enhance application monitoring and observability.

* Add JavaScript variable handling integration test

Introduced integration tests for JavaScript activities to verify they can access and modify native variables. Added classes for data setup, test execution, and workflow definition with corresponding NUnit tests.

* Remove unused activities and models

Deleted several unused activity classes, models, and middleware to simplify the codebase. This cleanup helps reduce code complexity and improves maintainability. Updated Program.cs to reflect these deletions.

* Remove correlation ID header setting from dispatch

Simplified the workflow dispatching process by removing the redundant setting of the X-Correlation-ID header in two places. This change should improve code readability and maintainability.

* Format code block consistently

Corrected the indentation of the code block for better readability and consistency. This ensures all properties in the 'DispatchWorkflowInstance' initialization are properly aligned. No functional changes were made in this commit.

* Remove VariablesInteropTests.cs from integration tests

Deleted the VariablesInteropTests.cs file which contained a single test method testing JavaScript-to-JSON serialization. This cleanup removes unnecessary test code from the repository.
2024-09-06 18:03:47 +02:00
RenatoCapelo c24dca1ba6
Enh/5943 DropIns - Prevention of File Locks and Unloading (#5944)
* fix - supressed warning IL2072
Changed DropInDescriptor from Record to Class to be able to add the suggested DynamicallyAccesedMembers decorator.

* Add Unconfigure method to DropIn class and interface

The `DropIn` class in `DropIn.cs` now includes a new `Unconfigure` method. This method handles the unconfiguration process when a drop-in is deleted. It retrieves the `ILogger<DropIn>` and `IActivityRegistry` services from the `IServiceProvider`, removes the `SampleActivity` from the activity registry, and logs the outcome.

The `IDropIn` interface in `IDropIn.cs` has been updated to include the new `Unconfigure` method, ensuring that it is called when the drop-in is deleted.

Additional using directives have been added to `DropIn.cs` for `Elsa.Workflows`, and `Microsoft.Extensions.Logging`.

* Refactor AssemblyLoader to use memory stream for loading

Modified the `LoadPath` method in the `AssemblyLoader` class to load assemblies from a memory stream instead of directly from the file. This change prevents file locking issues by copying the file contents to a memory stream and then loading the assembly from this stream.

* Dispose packageReader after loading assembly

Ensure the packageReader is disposed of after loading the assembly from the memory stream. This change adds a call to `packageReader.Dispose()` to close the package reader and the associated `.nupkg` file, which helps in releasing resources and preventing potential file locks or memory leaks.

* Add drop-in unloading on file deletion

Updated DropInDirectoryMonitorHostedService to handle unloading of drop-ins when files are deleted. Added `_debouncedUnloader` and `_installedDropIns` fields. Modified constructor to initialize these fields. Updated `ExecuteAsync` to call `LoadDropInAssemblyAsync` initially and handle file deletion events. Added `OnDeleted` method to manage file deletions and invoke the debounced unloader. Enhanced `LoadDropInAssemblyAsync` to track loaded drop-ins. Introduced `UnloadDropInAssemblyAsync` to remove drop-ins on file deletion.

* Load assembly from MemoryStream instead of FileStream

Modified the assembly loading process to use a MemoryStream
instead of a FileStream. This change ensures that the
FileStream is properly closed before the assembly is loaded,
improving resource management and preventing potential file
access issues.

* Improve logging and error handling in DropIn services

Removed logging from DropIn.Unconfigure method and added
ILogger dependency to DropInDirectoryMonitorHostedService.
Updated csproj to include Microsoft.Extensions.Logging.Abstractions.
Enhanced error handling in UnloadDropInAssemblyAsync method.
Minor formatting improvements for readability.
2024-09-05 18:09:31 +02:00
jdevillard 0c6cc6b062
Change to backendConfig after update of AddRemoteBackend properties (#5945)
Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-09-05 17:33:16 +02:00
Sipke Schoorstra 3acb1fd055 Update agent management features and refine configuration
Renamed methods and namespaces for clarity in `AgentsFeature` and extensions. Enhanced functionality of SEO Specialist and added new role for social media in sample app settings. Re-enabled persistence and API usage in Elsa server configuration.
2024-09-01 18:50:28 +02:00
Sipke Schoorstra 1940938021 Change ActivityKind from Task to Job
Updated the `Kind` property of `activityDescriptor` to `Job` instead of `Task`. This change ensures the correct categorization and functionality within the agent activity provider.
2024-09-01 14:40:39 +02:00
Sipke Schoorstra 223536c90a Remove unused using statements and configure agents.
Removed several unused `using` statements within multiple files to clean up the codebase. Additionally, enhanced the configuration for the `Agent` module in `appsettings.json` and enabled agent-related features in `Program.cs`.
2024-09-01 14:24:43 +02:00
Sipke Schoorstra 2d62a373e0
Add Agents Module with Semantic Kernel Integration (#5937)
* Remove `ServiceProfileConfig` and `SkillConfig`

Refactored the codebase to eliminate `ServiceProfileConfig` and `SkillConfig` in favor of simplifying configurations. Updated related entities and settings to consistently use `ServiceConfig` and `AgentConfig`. Refined function execution to enhance overall system coherence and maintainability.

* Refactor agent management and plugin system

This update eliminates AgentManager and related classes, introducing new management interfaces and memory-based stores. The plugin system is refactored with better separation of concerns and the addition of provider interfaces.

* Add new Agents features and services

Introduced AgentsFeature for API endpoints, AgentManagementFeature for agent management, and AgentActivitiesFeature for activities. Updated service configurations and migrated files for cleaner and more maintainable code structure.

* Rename execute endpoints to invoke

Renamed the 'Execute' endpoints and related paths to 'Invoke' for better semantic clarity. Adjusted the namespace and updated the route configuration accordingly to reflect this change.

* Add permissions configuration to Agents Invoke endpoint

This commit adds a call to `ConfigurePermissions("agents:invoke")` in the Agents Invoke endpoint configuration. This change ensures that proper permissions are checked when this endpoint is accessed.

* Rename Management to Persistence with EF Core support

Renamed various files and classes from Management to Persistence. Introduced Entity Framework Core (EF Core) support for agents, including implementation of APIs for API key, service, and agent definitions. The changes also updated project configurations and added necessary database context and entity configurations.

* Add EntityFrameworkCore project for Agents persistence

Introduce a new Entity Framework Core provider to manage the persistence layer of the Agents module. The project includes references to the base persistence and common Entity Framework projects.

* Remove redundant exception handlers and add new SQLite migration.

Deleted unnecessary `DbExceptionTransformer` and `RethrowDbExceptionHandler` classes to streamline error handling. Introduced a new SQLite migration for the Agents module to create necessary database tables and indices. Also modified `Store` and `EntityStore` to utilize a service provider for exception handling.

* Add Sqlite configuration extension and sample updates

Introduce a new extension method for configuring EF Core to use Sqlite in the Elsa.Agents module. Updated the sample project to use a configurable Sqlite connection string and adjusted the appsettings.json accordingly. Also added necessary folder structure in the project file.

* Add agent, service, and API key CRUD operations

Introduced CRUD functionalities for agent, service, and API key entities. Added endpoint handlers, filtering capabilities, and memory/EF core stores to support these operations. Updated configuration mappings as well.

* Add Agent API endpoints and DTOs

Added CRUD endpoints for agents in Elsa.Agents.Api along with the required DTOs and Request models. These endpoints include create, read, update, delete, and list functionalities, facilitating the management of agent entities.

* Add support for agent service providers and discovery

Introduce interfaces and implementations for agent service providers and service discovery. Updated `KernelFactory` to integrate the new service discovery mechanism and restructured plugin discoverer naming for consistency.

* Add agent management features

Introduce agent management components, including pages for listing and handling agent workflows, dialogs for creating agents with Blazor components, and backend API endpoints for generating unique agent names. This enhances functionality for managing agent workflows within the application.

* Refactor exception handling and simplify event handling logic

Replaced DataProcessingDbExceptionHandler with DbExceptionTransformer for handling PostgreSQL exceptions. Streamlined event completion logic by renaming method and ensuring input retrieval before setting the result.

* Add bulk delete endpoint for agents

Introduced new API endpoint for bulk deleting agents. Implemented request and response models, and updated persistence layer to handle bulk operations. Also reorganized project structure for better modularity.

* Refactor API Key models and endpoint classes

Consolidate API Key request models into unified models and update endpoints to use these new models. Add new transformation methods to entity classes. Enhance configuration classes and streamline the dependency injection process.

* Refactor and streamline bulk delete and service APIs

Refactored the bulk delete endpoints for API keys, services, and agents, consolidating request and response models. Added new service input and model classes and updated the corresponding stores to support bulk deletions. Simplified the endpoint logic to use these new models and enhanced filtering capabilities.

* Set default values for AgentInputModel properties

Updated properties in `AgentInputModel` to use initialized default values instead of `default!`. This change ensures that string and object properties are instantiated properly, improving code stability and preventing potential null reference exceptions.

* Add plugin listing endpoint and related models

Introduced a new endpoint to list all registered plugins in the system. Added necessary models and methods for plugin description and retrieval, along with appropriate documentation comments.

* Refactor agent management to use `IAgentManager`.

Created new notifications for agent lifecycle events and introduced an `AgentManager` service for agent CRUD operations. Updated APIs and other components to use the new `IAgentManager` service instead of direct store access for a more cohesive architecture.

* Update agent activity descriptor names

Changed the activity descriptor names to use PascalCase for consistency and readability. Also added display names for input variables to improve user interfaces.

* Add overloaded RefreshDescriptorsAsync for single activity provider

Introduced a new overloaded method in IActivityRegistry and ActivityRegistry to refresh activity descriptors using a single IActivityProvider. Updated RefreshActivityRegistry to use the new method, ensuring more flexibility in descriptor refresh operations.
2024-09-01 09:03:14 +02:00
Sipke Schoorstra 9e421a166d Merge remote-tracking branch 'origin/patch/3.2.x' 2024-08-30 12:23:38 +02:00
rosca-sabina 18b0d2e70a
Add alteration logs to workflow execution logs (#5897) (#5911) 2024-08-30 12:02:41 +02:00
jdevillard 3083a400d8
Add Variable available in dropdown when configuring a activity input (#5918)
* Sample to provide a ExpressionDescriptorProvider

* fix variable accessor in VariableExpressionHandler

* remove Variable Expression to use default one

* Change the Variable Expression Provider to handle Variable Expression correctly

* need to check on UI Side and Server side is valid JSON is sent. For example, if a use change from a literal value to a Variable value, the value is sent to the API and result in an exception, we cannot handle invalid json  without using Try/Catch

---------

Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-08-30 12:01:44 +02:00
JaFonz 684717d180
Set event payload when event bookmark resumes (#5934)
* Set event payload when event bookmark resumes

* Refactor to move common code into a function

* Typo in event input workflow key

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-08-30 12:01:02 +02:00
Pedro Gama 55e9b25744
fix: parse http resposes without a content-type (#5930) 2024-08-30 11:59:37 +02:00
Raymond den Haan 302292255c Introduce UniqueKeyConstraintViolationException
Refactor DataProcessingException to remove unique key logic and create a dedicated UniqueKeyConstraintViolationException. Update DbExceptionTransformer to use the new exception for unique key violations, improving code clarity and separation of concerns.
2024-08-20 12:37:48 +02:00
Sipke Schoorstra 8a417ca765
Remove ExpandoObject support from JintJavaScriptEvaluator (#5913)
Removed the `ConverterHelper` and `ExpandoObjectConverter` classes, along with their integration in `JintJavaScriptEvaluator`. Updated unit tests to skip unsupported functionality and added references to related issues for context.
2024-08-19 09:13:45 +02:00
Sipke Schoorstra 85ed518551 Refactor HttpWorkflowsMiddleware for bookmark correlation
Reorder parameters in StartWorkflowAsync and ResumeWorkflowAsync for consistency. Update FindBookmarksAsync and ExecuteWorkflowAsync to include workflowInstanceId and correlationId, improving workflow lookup and execution logic.
2024-08-16 21:46:59 +02:00
Sipke Schoorstra 62e517b848 Merge remote-tracking branch 'origin/patch/3.2.x' 2024-08-16 20:49:56 +02:00
Chandrasekar Vijayakumar f54643ab52
Added support to retrieve the workflow details through Liquid script (#5909)
* Modified POST execute API to show body in Swagger and resolved type-casting error in GET execute API

Modified the POST execute API to display the body in Swagger documentation and resolved the type-casting error in the GET execute API

* Added IExecutionRequest interface defines a contract for Request classes

* Moved the serialization logic into request classes

* Add missing import and reformat ActivityHandle property

Included the Elsa.Workflows.Models import in Models.cs to fix missing reference. Removed redundant ActivityHandle assignment in EndpointBase.cs to improve clarity and reduce redundancy.

* Added support to retrieve the workflow details(i.e.,  WorkflowDefinitionId, WorkflowDefinitionVersionId, WorkflowDefinitionVersion, WorkflowInstanceId) through Liquid script

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-08-16 20:16:13 +02:00
Sipke Schoorstra edf365b519
Add new HTTP workflow tests and enhance middleware (#5908)
Introduce tests for resuming specific HTTP workflow instances. Enhanced `HttpWorkflowsMiddleware` to handle workflow instance IDs and correlation IDs for more precise control over workflow activation and resumption.
2024-08-16 20:15:02 +02:00
Chandrasekar Vijayakumar 2b22400c25
Modified POST Execute API to Display Body in Swagger and Fixed Type-Casting Error in GET Execute API (#5858)
* Modified POST execute API to show body in Swagger and resolved type-casting error in GET execute API

Modified the POST execute API to display the body in Swagger documentation and resolved the type-casting error in the GET execute API

* Added IExecutionRequest interface defines a contract for Request classes

* Moved the serialization logic into request classes

* Add missing import and reformat ActivityHandle property

Included the Elsa.Workflows.Models import in Models.cs to fix missing reference. Removed redundant ActivityHandle assignment in EndpointBase.cs to improve clarity and reduce redundancy.

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-08-16 12:03:18 +02:00
RenatoCapelo ba06811882
Refactor FileSystemWatcher initialization in DropInDirectoryMonitorHostedService (#5892)
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-08-15 21:30:36 +02:00
Sipke Schoorstra 96371b683c Update dependencies and streamline JavaScript engine configuration
Refactor InputFunctionsDefinitionProvider to remove unused parameter. Simplify JintJavaScriptEvaluator object wrapping configuration and update Jint package to version 4.0.1. Add type Random to ConfigureEngineWithCommonTypes and enhance error handling in TaskReporter.
2024-08-14 21:14:08 +02:00
Sipke Schoorstra d0316687c1 Merge remote-tracking branch 'origin/patch/3.2.x' 2024-08-14 19:44:39 +02:00
Sipke Schoorstra 0a76741755 Update TaskReporter and RunTask activity
Replaced IWorkflowDispatcher in TaskReporter with IWorkflowInbox to streamline task reporting. This fixes race conditions when the workflow is attempted to be resumed before it committed its bookmarks.
2024-08-14 18:40:04 +02:00
Sipke Schoorstra 5f11026ee7
Add JS functions for encoding/decoding byte arrays from and to strings (#5902)
* Add handlers and improve JavaScript engine configuration

Added several new handlers for configuring the JavaScript engine with common types, functions, variable accessors, and input/output accessors. Refactored the JintJavaScriptEvaluator for better clarity and modularity by breaking down configuration steps into separate methods. Also replaced `IsInsideCompositeActivity` with `IsContainedWithinCompositeActivity` for better semantic consistency.

* Refactor to use primary constructor syntax for TypeDefinitionProviders

Updated CommonTypeDefinitionProvider, VariableTypeDefinitionProvider, and ActivityOutputFunctionsDefinitionProvider to use primary constructors for dependency injection. This change reduces redundancy and simplifies the code structure for better readability and maintainability.

* Add byte conversion functions to JavaScript engine

Introduced functions for converting bytes to/from strings and Base64. Updated CommonFunctionsDefinitionProvider and ConfigureEngineWithCommonFunctions to incorporate these new functions. This enhances the JavaScript engine's ability to handle byte array manipulations.

* Add tests for JavaScript byte and string conversions.

Introduce integration tests to verify byte array to string, string to byte array, byte array to Base64, and Base64 to byte array conversions using JavaScript functions. Ensure accurate transformation of data within different encoding scenarios.

* Add meaningful summaries to Jint engine configuration handlers

Updated comment summaries in four handler classes to provide clear and concise descriptions of their purpose. This helps improve code readability and understanding for future developers.

* Rename and merge variable and input/output handlers

Merged the variable accessor logic into the input/output handler and renamed the class to reflect its broader functionality. This consolidation ensures the accessors are registered in the right order.

* Add string base64 conversion functions

Introduced `stringToBase64` and `stringFromBase64` functions to handle base64 encoding and decoding of strings. Updated corresponding provider, handler, and added tests to ensure functionality.
2024-08-14 17:43:35 +02:00
Sipke Schoorstra 71d56e1665 Add ExpandoObjectConverter for JavaScript object conversion
Introduced `ConverterHelper` and `ExpandoObjectConverter` to handle conversions from .NET dynamic objects to JavaScript objects. Updated integration tests to validate the conversion and sorting functionalities.

Fixes #5895
2024-08-13 19:58:18 +02:00
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 84893e6c80 Rename Model to ServiceProfile across the codebase.
Changed class names, properties, and variables from Model to ServiceProfile for improved semantics and readability. Updated corresponding filenames and configuration settings to maintain consistency.
2024-08-10 19:26:10 +02:00
Sipke Schoorstra 704009fda7 Add TenantId to workflow definition and skip multitenancy test
Included the TenantId property in the workflow definition to support tenant-specific workflows. Skipped a multitenancy test due to the current issue where not all workflows are assigned the Tenant1 tenant.
2024-08-10 10:56:34 +02:00
Sipke Schoorstra 6741db388b
Fix background activity completion (#5882)
* Enhance logging and state handling in workflows

Added debug logging in `BookmarkResumer` and `StoreBookmarkQueue` to track workflow resumptions and queue additions. Updated `ICommitStateHandler` to include `WorkflowState` parameter and modified related implementations. Adjusted logging configuration in sample app and removed unused service import.

* Add CustomProperties entry for RootType in AgentActivity

This change ensures that the `RootType` property is set to `AgentActivity` inside the `AgentActivityProvider`. It enhances the descriptor's metadata, enabling clearer classification and potentially improving integration with other components.

* Update RemoveBookmarksAsync to use BookmarkIds instead of Hashes

Modified RemoveBookmarksAsync to filter bookmarks by BookmarkIds rather than Hashes for improved accuracy. Updated filter creation logic to accommodate the new identifier field.

* Fix commit state handler call in WorkflowRunner

Add workflowState as an argument to commitStateHandler.CommitAsync. This ensures that the commitStateHandler has the necessary context to commit properly and maintains consistency in workflow state changes.
2024-08-10 10:41:35 +02:00
Sipke Schoorstra 58e4523406 Update persistence feature base classes to include self-type
Refactored multiple persistence feature classes to implement the self-referencing generic type parameter in the `PersistenceFeatureBase` class. This ensures that each feature correctly references its own type, enhancing type safety and overall code maintainability.
2024-08-09 19:20:15 +02:00
Sipke Schoorstra d7c11db280 Merge remote-tracking branch 'origin/patch/3.2.x' 2024-08-09 18:55:26 +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