2023-10-18 23:03:55 +00:00
|
|
|
using System.Text.Json;
|
|
|
|
|
using Elsa.Studio.Dashboard.Extensions;
|
|
|
|
|
using Elsa.Studio.Shell;
|
|
|
|
|
using Elsa.Studio.Shell.Extensions;
|
|
|
|
|
using Elsa.Studio.Workflows.Extensions;
|
|
|
|
|
using Elsa.Studio.Contracts;
|
|
|
|
|
using Elsa.Studio.Core.BlazorWasm.Extensions;
|
2023-11-20 21:32:20 +00:00
|
|
|
using Elsa.Studio.Extensions;
|
2023-10-18 23:03:55 +00:00
|
|
|
using Elsa.Studio.Login.BlazorWasm.Extensions;
|
2025-05-26 06:38:34 +00:00
|
|
|
using Elsa.Studio.Login.Extensions;
|
2023-12-09 21:10:16 +00:00
|
|
|
using Elsa.Studio.Login.HttpMessageHandlers;
|
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 16:03:47 +00:00
|
|
|
using Elsa.Studio.Models;
|
2023-11-20 21:32:20 +00:00
|
|
|
using Elsa.Studio.Options;
|
2023-10-18 23:03:55 +00:00
|
|
|
using Elsa.Studio.Workflows.Designer.Extensions;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Microsoft.JSInterop;
|
|
|
|
|
|
|
|
|
|
// Build the host.
|
|
|
|
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
|
|
|
|
|
|
|
|
|
// Register root components.
|
|
|
|
|
builder.RootComponents.Add<App>("#app");
|
|
|
|
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
|
|
|
|
builder.RootComponents.RegisterCustomElsaStudioElements();
|
|
|
|
|
|
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 16:03:47 +00:00
|
|
|
// Register shell services and modules.
|
|
|
|
|
var backendApiConfig = new BackendApiConfig
|
|
|
|
|
{
|
|
|
|
|
ConfigureBackendOptions = options => builder.Configuration.GetSection("Backend").Bind(options),
|
|
|
|
|
ConfigureHttpClientBuilder = options => options.AuthenticationHandler = typeof(AuthenticatingApiHttpMessageHandler)
|
|
|
|
|
};
|
2024-09-05 15:33:16 +00:00
|
|
|
|
2023-10-18 23:03:55 +00:00
|
|
|
builder.Services.AddCore();
|
|
|
|
|
builder.Services.AddShell();
|
2024-09-05 15:33:16 +00:00
|
|
|
builder.Services.AddRemoteBackend(backendApiConfig);
|
2023-10-18 23:03:55 +00:00
|
|
|
builder.Services.AddLoginModule();
|
2025-05-26 06:38:34 +00:00
|
|
|
builder.Services.UseElsaIdentity();
|
2023-10-18 23:03:55 +00:00
|
|
|
builder.Services.AddDashboardModule();
|
|
|
|
|
builder.Services.AddWorkflowsModule();
|
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-16 00:12:13 +00:00
|
|
|
builder.Services.AddAgentsModule(backendApiConfig);
|
2023-10-18 23:03:55 +00:00
|
|
|
|
|
|
|
|
// Build the application.
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
// Apply client config.
|
|
|
|
|
var js = app.Services.GetRequiredService<IJSRuntime>();
|
|
|
|
|
var clientConfig = await js.InvokeAsync<JsonElement>("getClientConfig");
|
|
|
|
|
var apiUrl = clientConfig.GetProperty("apiUrl").GetString()!;
|
|
|
|
|
app.Services.GetRequiredService<IOptions<BackendOptions>>().Value.Url = new Uri(apiUrl);
|
|
|
|
|
|
|
|
|
|
// Run each startup task.
|
|
|
|
|
var startupTaskRunner = app.Services.GetRequiredService<IStartupTaskRunner>();
|
|
|
|
|
await startupTaskRunner.RunStartupTasksAsync();
|
|
|
|
|
|
|
|
|
|
// Run the application.
|
|
|
|
|
await app.RunAsync();
|