Commit graph

5387 commits

Author SHA1 Message Date
Sipke Schoorstra bdaae64e72 Add base path providers and standardize tenant accessor property
Introduce DefaultHttpEndpointBasePathProvider and TenantPrefixHttpEndpointBasePathProvider to manage HTTP endpoint base paths. Update ITenantAccessor property from CurrentTenant to Tenant for consistency across the codebase.
2024-10-17 19:47:55 +02:00
Sipke Schoorstra b8ab05ce2e Refactor WorkflowInstancesFeature class constructor
Updated the WorkflowInstancesFeature class constructor to remove an unnecessary method override, simplifying the class design. This change enhances code readability and maintains the same functionality.
2024-10-17 08:52:07 +02:00
Devin Lin 2eee58af66
fix: register SerializedKeyValuePair.Key to BsonClassMap (#6036)
Manually register SerializedKeyValuePair.Key to BsonClassMap to prevent index creation failure.
2024-10-16 19:20:17 +02:00
Sipke Schoorstra 99ab5e4ba1 Refactor StopAsync method to return completed task
Modified the StopAsync method to directly return a completed task instead of running through tenants asynchronously. This change simplifies the shutdown process and removes redundant tenant processing during service stop.
2024-10-15 23:47:17 +02:00
Sipke Schoorstra 225ad49ea8
Improved multitenancy support for HTTP workflows with per-tenant DbContext (#6032)
* Refactor: Update namespaces and add TenantExtensions

Updated namespaces throughout the project to improve clarity and consistency by moving from 'Common' to appropriate modules. Added TenantExtensions class to simplify fetching connection strings for tenants.

* Implement multitenant DB connection strings

Redesign tenant-specific classes to support multitenancy more effectively. Introduce `MultitenantBackgroundService` and `MultitenantHostedService` for handling tasks per tenant.

* Refactor constructors and remove redundant code

Simplified the constructor parameters for `MultitenantBackgroundService` and `List` class. Removed the unused parameter in `MultitenantBackgroundService` and redundant folder inclusion in the project file. Updated the method calls to use direct parameters in `List` class.

* Remove unused import in ActivityDescriptors Endpoint

The Elsa.Common.Multitenancy import was removed as it is unused in the List/Endpoint.cs file. Removing unused imports helps to improve code readability and maintainability. This change does not affect functionality.
2024-10-15 23:16:50 +02:00
Sipke Schoorstra 7e7a899bbf
Implement multitenant HTTP routing (#6031)
* Add tenant awareness to bookmark handling and route resolution

Added tenant ID support across various components, including bookmark updates, route resolution, and middleware processing. This ensures that bookmark and route operations can now appropriately handle tenant-specific data, improving the system's multitenancy capabilities.

* Add Multitenant HTTP Routing feature to Tenants module

Introduced a new MultitenantHttpRoutingFeature class to the Elsa.Tenants.AspNetCore module, enhancing the tenant resolution capabilities. Moved RoutePrefixTenantResolver from Elsa.Http to Elsa.Tenants.AspNetCore and updated relevant project references and namespaces accordingly. This refactor improves modularity and separation of concerns between HTTP and tenancy features.

* Refactor route handling and tenant configuration

Removed redundant `RouteTableExtensions` and replaced with new route providers and updaters, enhancing flexibility and modularity. Introduced tenant-specific HTTP endpoint configurations for better customization and configuration management.

* Rename HttpEndpointBookmarkStimulus to HttpEndpointBookmarkPayload

Refactor various classes and methods to reflect the renaming from `HttpEndpointBookmarkStimulus` to `HttpEndpointBookmarkPayload`. Add and configure new extension methods for tenant route handling, update the route provider to support multi-tenancy, and adjust the tenants provider to bind configuration properly.

* Add HeaderTenantResolver and refactor Http namespace.

Introduce HeaderTenantResolver to resolve tenants via HTTP headers. Refactor multiple classes and interfaces to move from the Elsa.Http.Models namespace directly into Elsa.Http for clarity and consistency.

* Add Host-based tenant resolution

Implemented a HostTenantResolver to resolve tenants based on the request's host and updated tenant configurations with host information. Modified the tenant resolver pipeline and added the new host resolver to the service registrations.

* Add tenant-aware caching and accessor support

Enhanced caching by incorporating tenant identifiers into cache keys for more granular cache management. Introduced ITenantAccessor dependencies in various services to retrieve the current tenant information. This ensures that cache entries are correctly isolated per tenant.

* Reorder tenant resolvers for pipeline setup.

Reordered the tenant resolvers in the pipeline to prioritize HostTenantResolver before RoutePrefixTenantResolver. This ensures that tenant resolution is correctly aligned with host-based resolving before checking the route prefix.

* Remove unused imports

This commit eliminates redundant `using` directives across multiple files to streamline the codebase. This cleanup helps improve code readability and maintainability by removing unnecessary dependencies.
2024-10-14 21:27:11 +02:00
jdevillard 9808020d57
Add db providers for secrets features (#6020)
* Add PostgreSql provider to Secrets

* Add SqlServer provider to Secrets

* fix sqlserver Method name

* resolve conflict Elsa.sln

* resolve conflict Elsa.sln

---------

Co-authored-by: Jérémie DEVILLARD <jdevillard@users.noreply.github.com>
2024-10-14 21:03:39 +02:00
Sipke Schoorstra 121bc52b07 Remove sample files.
Samples are moved to the elsa-samples repository.
2024-10-12 19:19:10 +02:00
Sipke Schoorstra 68f0bcb183 Update package references in Directory.Packages.props
Replaced hardcoded version of System.Text.Json with a variable. Added Microsoft.AspNetCore.DataProtection.Abstractions package for the net8.0 target framework.
2024-10-12 19:04:22 +02:00
Sipke Schoorstra 9928d56640 Merge remote-tracking branch 'origin/main' 2024-10-12 18:52:34 +02:00
Sipke Schoorstra b8f2bb5834 Update branch trigger in GitHub workflow
Changed the workflow trigger branch from 'blueberry' to 'main'. This ensures the workflow runs on pushes to the 'main' branch, aligning with our new branching strategy.
2024-10-12 18:52:01 +02:00
dependabot[bot] e90fe0a762
Bump System.Text.Json from 7.0.4 to 8.0.5 in /build (#6021)
Bumps [System.Text.Json](https://github.com/dotnet/runtime) from 7.0.4 to 8.0.5.
- [Release notes](https://github.com/dotnet/runtime/releases)
- [Commits](https://github.com/dotnet/runtime/compare/v7.0.4...v8.0.5)

---
updated-dependencies:
- dependency-name: System.Text.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-12 18:45:27 +02:00
Sipke Schoorstra a7d9ebc797 Update System.Text.Json to version 8.0.5 for all projects
Updated the System.Text.Json package to version 8.0.5 across multiple projects to address security vulnerabilities and ensure consistency. Additionally, modified the Directory.Packages.props to reflect the new version and added necessary overrides in various csproj files.
2024-10-12 18:42:16 +02:00
Sipke Schoorstra ee07b83e60 Merge remote-tracking branch 'origin/patch/3.2.x' 2024-10-12 12:30:41 +02:00
Sipke Schoorstra 1905918247 Update System.Text.Json package reference to use property variable
Switched from a hardcoded version to a property variable `$(SystemTextJsonVersion)` for the `System.Text.Json` package reference in multiple project files. This change centralizes version management and ensures consistency across all projects.
2024-10-12 12:27:54 +02:00
rosca-sabina 090a3fd1b0
Register MongoDb client as singleton (#6013)
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-10-12 12:21:39 +02:00
rosca-sabina 1b4ce452ee
Add MongoDB collection naming strategy (#6005) 2024-10-12 12:16:09 +02:00
Sipke Schoorstra a5cc3fc9e8
Refactor Tenant Resolution to Use Async Local Storage for Operation-wide Access (#6022)
* Remove obsolete tenant-related classes and add ASP.NET Core middleware

Refactored tenant resolution by removing obsolete interfaces and classes, such as `IAmbientTenantAccessor` and `ITenantResolutionStrategy`. Introduced new ASP.NET Core middleware for tenant resolution, encapsulated in the new `Elsa.Tenants.AspNetCore` project. Updated related usage in various parts of the application to align with these changes.

* Remove HttpContextTenantResolver.

Removed HttpContextTenantResolver from the multitenancy pipeline and related service registrations. This simplifies the tenant resolution by relying on remaining resolvers like ClaimsTenantResolver and RoutePrefixTenantResolver.

* Add Elsa solution definition file

This commit introduces the main solution file, Elsa.slnx, defining the folder structure, projects, and configuration for the Elsa repository. This includes folders for Docker, documentation, pipelines, samples, scripts, source code, and tests.

* Refactor DefaultAccessTokenIssuer for clarity and efficiency

Refactored the DefaultAccessTokenIssuer class by simplifying its constructor and utilizing scoped variables for token options. Improved token creation logic by adding a dedicated method to configure token options, enhancing code readability and maintainability.

* Remove Elsa.slnx solution file

No dotnet build support yet.

* Refactor tenant resolver service registrations

Updated the service registrations to use interfaces for DefaultTenantResolver and DefaultTenantResolverPipelineInvoker. This improves the code's flexibility, making it easier to replace or extend these implementations in the future.

* Add multitenancy support and tenant scope management

Introduced ITenantScopeFactory and related implementations for tenant scope management across the application. Enhanced the HTTP workflows middleware to handle tenants and updated relevant configurations and extension methods to support tenant resolution.

* Remove unnecessary folder inclusion

The <Folder> tag for "Modules\Modules\" was redundant and has been removed to clean up the project file. This change will not affect the existing functionality or project structure.

* Rename Create to CreateScope and improve authorization.

Updated the method name from Create to CreateScope for better clarity in the TenantScopeFactory. Fixed a logical error in the authorization process, ensuring proper status code setting for unauthorized requests, and refactored token expiration calculation for clarity.

* Add tenant agnostic filters and remove tenant setup

This commit introduces tenant agnostic filters in AutoUpdateTests to ensure workflows can trigger regardless of tenant. Additionally, it removes tenant configuration from WorkflowServer setup as it is no longer required for the current tests.
2024-10-12 12:08:09 +02:00
Sipke Schoorstra 4bf050788e Merge branch 'enh/multi-tenancy-refactorings' 2024-10-11 20:49:10 +02:00
Sipke Schoorstra 7417fc8738 Add OpenTelemetry middleware import to Program.cs
This change includes the addition of the `Elsa.OpenTelemetry.Middleware` namespace to `Program.cs`, enabling OpenTelemetry instrumentation and tracing. This is intended to improve observability and monitoring of the application.
2024-10-11 20:44:11 +02:00
Sipke Schoorstra f3961c0af5 Update namespaces and correct merge artefacts 2024-10-11 20:41:49 +02:00
Sipke Schoorstra ff487fad80 Merge remote-tracking branch 'origin/blueberry' into enh/multi-tenancy-refactorings 2024-10-11 19:45:40 +02:00
Sipke Schoorstra a70a199a78 Merge branch 'main' into enh/multi-tenancy-refactorings 2024-10-11 19:12:58 +02:00
Sipke Schoorstra 83238e9931
Update System.Text.Json version reference (#6019)
Replaced hardcoded System.Text.Json version 8.0.4 with a variable $(SystemTextJsonVersion) across multiple project files. This improves maintainability and consistency when updating the package version.
2024-10-11 14:35:24 +02:00
Sipke Schoorstra d2d4b6ee4a Merge remote-tracking branch 'origin/patch/3.2.x' into blueberry 2024-10-11 10:30:52 +02:00
Sipke Schoorstra 11f388338a
Add endpoints for activity execution records and summaries (#6018)
* Add endpoints for activity execution records and summaries

Created new classes and endpoints to handle activity execution records and summaries retrieval. Added related models and updated relevant interfaces.

* Rename endpoint classes for clarity

Updated endpoint classes in `ActivityExecutions` and `ActivityExecutionSummaries` to use the name `Endpoint` instead of `List`. This improves readability and consistency in the codebase.
2024-10-11 10:29:40 +02:00
Sipke Schoorstra 96d82c4210 Refactor deserialization method for entity properties.
Replaced `Deserialize` with `DeserializePayload` to align with updated deserialization strategies, ensuring consistency across the codebase and improving future maintainability. This change affects how 'SerializedProperties' are handled within `ActivityExecutionLogStore`.
2024-10-10 11:40:59 +02:00
Sipke Schoorstra 494d6e7f43 Refactor polymorphic JSON deserialization.
Simplify the handling of `JsonNode` parsing and improve type-checking. Added a guard clause in `ReadType` method to handle non-object JSON token types, ensuring safer type parsing.
2024-10-10 10:18:27 +02:00
Sipke Schoorstra 3f83a2fb51 Remove unused 'Elsa.Expressions.Services' import
Eliminates an unnecessary using directive from PolymorphicObjectConverterFactory.cs to keep the code clean and reduce potential confusion. This change has no impact on functionality.
2024-10-09 23:19:47 +02:00
Sipke Schoorstra 6cefe6ea23 Update package versions in Directory.Packages.props
Bumped versions for various Microsoft and third-party packages to improve compatibility and take advantage of recent bug fixes and performance improvements. Specific changes include updates to AspNetCore, EntityFrameworkCore, and Polly packages among others.
2024-10-09 09:44:07 +02:00
bobhauser dd711bf4ff
Enhance logging by adding logger state to activity and workflow pipelines (#5985)
* Enhance logging by adding logger state to activity and workflow pipelines

* Change logger state for ActivityExecutionContext to use key of ActivityInstanceId instead of ActivityId

* Adjusted logger state registration to conform to the Elsa Features framework delegate pattern

---------

Co-authored-by: Bob Hauser <rhauser@kinaxis.com>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-10-07 13:51:05 +02:00
Devin Lin 368d8d9770
fix: missing tenantAgnostic parameter passing (#6002)
- pass tenantAgnostic to MongoStore in WorkflowDefinitionStore, BookmarkStore, TriggerStore

Co-authored-by: devin_lin <devin_lin@gss.com.tw>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-10-07 13:46:41 +02:00
Sipke Schoorstra 02f1b56eb1 Add tracing for trigger activities in workflow execution
Enhanced the OpenTelemetry tracing middleware to include detailed information about the triggered activity within the workflow execution. This change adds tags for the activity ID, name, and type to provide better observability and debugging insights.
2024-10-07 10:15:35 +02:00
Sipke Schoorstra ca643a8611
Update README.md 2024-10-07 09:36:10 +02:00
Sipke Schoorstra e7b3cece8f Merge remote-tracking branch 'origin/main' 2024-10-06 23:23:13 +02:00
Sipke Schoorstra 074e70401e Add Lodash FP support to JavaScript engine
Introduced a new feature to integrate Lodash FP into the JavaScript engine. Updated configuration to use Lodash FP instead of Lodash. Adjusted Moment.js library handling to ensure compatibility.
2024-10-06 23:22:53 +02:00
Carmine Francesco Giugliano c8da48fb5e
feat: register ITasksApi in AddDefaultApiClients (#5999)
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-10-06 21:04:20 +02:00
Sipke Schoorstra 830aec2bd3 Add System.Text.RegularExpressions package
Included the System.Text.RegularExpressions package to Directory.Packages.props with version 4.3.1. This addition ensures regex functionalities are available within the project dependencies.
2024-10-06 20:35:37 +02:00
Sipke Schoorstra 9c8edb6581 Update Elsa.Studio packages to version 3.3.0-preview.561
This update changes the version of multiple Elsa.Studio packages from 3.3.0-preview.524 to 3.3.0-preview.561. This ensures that all dependencies are up-to-date and can include bug fixes and new features introduced in the latest preview version.
2024-10-06 20:30:06 +02:00
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
Sipke Schoorstra e1d0cc2e27 Add DefaultTenantAccessor and ITenantAccessor interface
Introduce ITenantAccessor interface and its implementation, DefaultTenantAccessor, for tenant management in the multitenancy module. This setup will allow future enhancements for tenant-specific functionality.
2024-10-06 14:49:02 +02:00
Sipke Schoorstra dd812645c7 Refactor imports to reduce use of Elsa.Common.Contracts
Consolidate imports by replacing Elsa.Common.Contracts with Elsa.Common and Elsa.Common.Multitenancy. This update streamlines import statements across various modules, improving code readability and maintainability.
2024-10-05 18:30:45 +02:00
Sipke Schoorstra 078f34fd79 Remove obsolete tag settings and correct tag schemas
Eliminated redundant `correlationId` tag setting. Adjusted `workflowInstance` and `activityInstance` tag schemas for better clarity. Simplified the processors list in `otel-collector-config.yaml`.
2024-10-05 14:12:00 +02:00
Sipke Schoorstra 54624aea77 Refactor tracing to enhance span details
Renamed variables from 'activity' to 'span' for clarity and consistency. Added additional span tags for start and end times, status updates, and detailed error information for improved traceability and debugging.
2024-10-05 13:48:59 +02:00
Sipke Schoorstra 458181c5ce Refactor activity events with status tags helper method
Replaced inline tag creation with a helper method to streamline code and ensure consistency in status tags for activity events. This change also includes a minor comment for clarity on null activity handling.
2024-10-05 13:39:58 +02:00
Sipke Schoorstra 2aa312850d Refactor incident tagging logic in tracing middleware
Reorganized the logic for setting tags when incidents are present in `OpenTelemetryTracingWorkflowExecutionMiddleware`. The new structure ensures consistent tag setting for error status and incidents, improving code readability and maintainability.
2024-10-05 11:19:02 +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 41e1062148 Enhance JSON deserialization to include service provider
Updated ReadAsJsonAsync method to accept an IServiceProvider parameter for improved JSON deserialization. Modified corresponding tests and helper classes to utilize the service provider for more flexible JSON serialization options.
2024-10-03 19:12:00 +02:00
Sipke Schoorstra 679a0515c8 Add TypeJsonConverter and enhance JSON serialization
Introduced a TypeJsonConverter to handle Type serialization and deserialization. Updated dependency injection and helper methods to support customized JSON serializer options, improving flexibility and configurability.
2024-10-03 18:50:05 +02:00