2024-03-12 16:47:58 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
Fix Race Condition in WorkflowDefinitionActivity (#5315)
* Refactor hash method in Hasher.cs
The Hash method in the Hasher.cs file has been refactored to use more efficient code. Instead of creating a SHA256 instance, it directly hashes the data using SHA256.HashData. As a result, the private Hash method and its usage, which only has relevance to the previous approach, have been removed.
* Replace GetHashCode with SHA256 for script caching
Two unused namespaces, Esprima and Esprima.Ast, have been removed, and two new ones, System.Security.Cryptography and System.Text, have been added. These changes in Elsa.JavaScript's JintJavaScriptEvaluator file were made to replace the basic GetHashCode method, which was used earlier to generate a cache key for JavaScript scripts, with SHA256 hash function to ensure uniqueness and avoid possible hash collisions. This greatly increases the reliability of the caching mechanism.
* Set HTTP client timeout in WorkflowServer
The client timeout in WorkflowServer has been set to 1 minute for `ResrService` and `client` methods. This was done to manage long running requests and prevent timeouts.
* Refactor code and add validation in ScheduleActivityAsync methods
An unnecessary line of code in the ScheduleActivityAsync method under the ActivityExecutionContext file has been removed to simplify the function. Meanwhile, validation has been added to ensure that specified activities are part of the workflow. This improves code clarity and prevents potential errors caused by incorrect activity scheduling.
* Refactor ActivityVisitor to use ActivityVisitorContext
The ActivityVisitor class in Elsa.Workflows.Core was refactored to use an ActivityVisitorContext class. The introduction of this context class replaced the multiple hashsets that were used within function signatures, consolidating them into a single object and reducing function complexity. This change improves readability and code organization.
* Refactor WorkflowDefinitionActivity to use WorkflowGraph
Adjusted the WorkflowDefinitionActivity class in the Elsa.Workflows.Management module. The changes include migration from using Workflow to WorkflowGraph objects and condensing code blocks for clearer readability. Additionally, a new 'IsInitialized' field is added to eliminate potential race conditions during the graph construction process.
* Add activity validation to WorkflowExecutionContext
A check has been implemented in the WorkflowExecutionContextExtensions to validate that a specified activity is part of the workflow. This prevents incorrect activity references when scheduling tasks in the workflow.
* Refactor to use WorkflowGraph instead of Workflow
The codebase has been refactored to utilize the WorkflowGraph instead of the Workflow while running and manipulating workflows. Additional changes include restructuring WorkflowRunner and WorkflowDefinitionService classes, introducing WorkflowGraphBuilder usage, and mapping updates in WorkflowDefinitionMapper. The WorkflowHost, WorkflowDispatcher, and WorkflowExecutionContext have also been updated accordingly.
* Add WorkflowGraph and related services
This commit introduces the IWorkflowGraphBuilder interface, the WorkflowGraph model, and an implementation of the interface in the WorkflowGraphBuilder class. The purpose of these additions is to establish the building and structure of a workflow graph. The WorkflowGraph model also includes activity node handling and hashing capabilities.
* Add tests to ensure exception when scheduling an activity not part of workflow
Several unit tests were written to ensure that the right behavior is exhibited when scheduling an activity that is not part of the workflow. An exception is expected to be thrown in this case. Additionally, new service definitions, workflow definitions and workflow queries were added for more comprehensive testing.
* Update WorkflowGraph class and add comment descriptions
This commit updates the WorkflowGraph class by extending its descriptions and implementing an explicit mention to the Workflow reference. Additionally, more attribute descriptions have been added to increase code readability and comprehension.
* Removed unnecessary brackets
* Remove unused services from workflow management
This commit deletes "ExpressionDescriptorRegistryPopulator.cs" and "ScopedWorkflowDefinitionLookup.cs" files from Elsa.Workflows.Management.Services. These files, containing obsolete services, are no longer used in the workflow management process. The services' registration has been removed as well from "WorkflowManagementFeature.cs".
* Remove TestWorkflowDefinitionService.cs from component tests
A file, TestWorkflowDefinitionService.cs, was removed under Elsa.Workflows.ComponentTests. This is part of the improvement process where inefficient or unnecessary test files are cleaned up.
* Add comments to WorkflowDefinitionActivityTests
This commit adds explanatory comments to the WorkflowDefinitionActivityTests file. The comments provide information about the purpose of these tests and a reference to a related issue in the project's Github repository.
* Updated duplicate and missing package references
---------
Co-authored-by: Raymond den Haan <raymond.den.haan@nexxbiz.io>
2024-05-01 12:53:37 +00:00
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Text;
|
2024-03-12 16:47:58 +00:00
|
|
|
using System.Text.Encodings.Web;
|
2023-07-14 17:19:41 +00:00
|
|
|
using System.Text.Json;
|
2023-02-03 13:29:44 +00:00
|
|
|
using System.Text.Json.Serialization;
|
2023-03-15 11:29:07 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2024-03-12 16:47:58 +00:00
|
|
|
using System.Text.Unicode;
|
2023-10-13 08:34:21 +00:00
|
|
|
using Elsa.Expressions.Helpers;
|
2023-01-20 18:26:38 +00:00
|
|
|
using Elsa.Expressions.Models;
|
2022-12-31 15:16:43 +00:00
|
|
|
using Elsa.Extensions;
|
2023-02-13 11:15:20 +00:00
|
|
|
using Elsa.JavaScript.Contracts;
|
2024-01-31 20:10:13 +00:00
|
|
|
using Elsa.JavaScript.Helpers;
|
2022-05-26 10:47:31 +00:00
|
|
|
using Elsa.JavaScript.Notifications;
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
using Elsa.JavaScript.ObjectConverters;
|
2022-05-26 10:47:31 +00:00
|
|
|
using Elsa.JavaScript.Options;
|
2023-03-03 21:47:23 +00:00
|
|
|
using Elsa.Mediator.Contracts;
|
2022-12-15 21:53:56 +00:00
|
|
|
using Humanizer;
|
2022-01-12 10:43:46 +00:00
|
|
|
using Jint;
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
using Jint.Native;
|
|
|
|
|
using Jint.Native.TypedArray;
|
2024-01-31 18:48:00 +00:00
|
|
|
using Jint.Runtime.Interop;
|
2024-04-25 08:26:35 +00:00
|
|
|
using Microsoft.Extensions.Caching.Memory;
|
2024-03-18 22:20:12 +00:00
|
|
|
using Microsoft.Extensions.Configuration;
|
2022-01-12 10:43:46 +00:00
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
2023-02-03 13:29:44 +00:00
|
|
|
// ReSharper disable ConvertClosureToMethodGroup
|
2023-02-13 11:15:20 +00:00
|
|
|
namespace Elsa.JavaScript.Services;
|
2023-01-04 19:36:38 +00:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Provides a JavaScript evaluator using Jint.
|
|
|
|
|
/// </summary>
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
public class JintJavaScriptEvaluator(IConfiguration configuration, INotificationSender mediator, IOptions<JintOptions> scriptOptions, IMemoryCache memoryCache)
|
|
|
|
|
: IJavaScriptEvaluator
|
2022-01-12 10:43:46 +00:00
|
|
|
{
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
private readonly JintOptions _jintOptions = scriptOptions.Value;
|
|
|
|
|
private readonly JsonSerializerOptions _jsonSerializerOptions = CreateJsonSerializerOptions();
|
2022-01-12 10:43:46 +00:00
|
|
|
|
2023-01-04 19:36:38 +00:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
public async Task<object?> EvaluateAsync(string expression,
|
|
|
|
|
Type returnType,
|
|
|
|
|
ExpressionExecutionContext context,
|
2024-01-30 20:22:32 +00:00
|
|
|
ExpressionEvaluatorOptions? options = default,
|
2023-01-04 19:36:38 +00:00
|
|
|
Action<Engine>? configureEngine = default,
|
|
|
|
|
CancellationToken cancellationToken = default)
|
|
|
|
|
{
|
2023-12-14 09:45:37 +00:00
|
|
|
var engine = await GetConfiguredEngine(configureEngine, context, options, cancellationToken);
|
2023-01-04 19:36:38 +00:00
|
|
|
var result = ExecuteExpressionAndGetResult(engine, expression);
|
2023-11-03 19:28:10 +00:00
|
|
|
|
2023-10-13 08:34:21 +00:00
|
|
|
return result.ConvertTo(returnType);
|
2023-01-04 19:36:38 +00:00
|
|
|
}
|
2022-01-12 10:43:46 +00:00
|
|
|
|
2024-01-30 20:22:32 +00:00
|
|
|
private async Task<Engine> GetConfiguredEngine(Action<Engine>? configureEngine, ExpressionExecutionContext context, ExpressionEvaluatorOptions? options, CancellationToken cancellationToken)
|
2023-01-04 19:36:38 +00:00
|
|
|
{
|
2024-01-30 20:22:32 +00:00
|
|
|
options ??= new ExpressionEvaluatorOptions();
|
|
|
|
|
|
2023-01-04 19:36:38 +00:00
|
|
|
var engine = new Engine(opts =>
|
2022-01-12 10:43:46 +00:00
|
|
|
{
|
2023-01-04 19:36:38 +00:00
|
|
|
if (_jintOptions.AllowClrAccess)
|
|
|
|
|
opts.AllowClr();
|
2024-01-31 18:48:00 +00:00
|
|
|
|
|
|
|
|
// Wrap objects in ObjectWrapper instances and set their prototype to Array.prototype if they are array-like.
|
|
|
|
|
opts.SetWrapObjectHandler((engine, target, type) =>
|
|
|
|
|
{
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
var instance = ObjectWrapper.Create(engine, target);
|
2024-01-31 20:10:13 +00:00
|
|
|
|
|
|
|
|
if (ObjectArrayHelper.DetermineIfObjectIsArrayLikeClrCollection(target.GetType()))
|
|
|
|
|
instance.Prototype = engine.Intrinsics.Array.PrototypeObject;
|
2024-01-31 18:48:00 +00:00
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
|
});
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
|
2024-08-13 17:58:18 +00:00
|
|
|
opts.Interop.ObjectConverters.AddRange([new ByteArrayConverter(), new ExpandoObjectConverter()]);
|
2023-01-04 19:36:38 +00:00
|
|
|
});
|
2022-01-12 10:43:46 +00:00
|
|
|
|
2023-01-04 19:36:38 +00:00
|
|
|
configureEngine?.Invoke(engine);
|
2023-02-03 13:29:44 +00:00
|
|
|
|
2023-01-04 19:36:38 +00:00
|
|
|
// Add common functions.
|
2024-07-16 11:55:23 +00:00
|
|
|
engine.SetValue("getWorkflowDefinitionId", (Func<string>)(() => context.GetWorkflowExecutionContext().Workflow.Identity.DefinitionId));
|
|
|
|
|
engine.SetValue("getWorkflowDefinitionVersionId", (Func<string>)(() => context.GetWorkflowExecutionContext().Workflow.Identity.Id));
|
|
|
|
|
engine.SetValue("getWorkflowDefinitionVersion", (Func<int>)(() => context.GetWorkflowExecutionContext().Workflow.Identity.Version));
|
2023-02-03 13:29:44 +00:00
|
|
|
engine.SetValue("getWorkflowInstanceId", (Func<string>)(() => context.GetActivityExecutionContext().WorkflowExecutionContext.Id));
|
|
|
|
|
engine.SetValue("setCorrelationId", (Action<string?>)(value => context.GetActivityExecutionContext().WorkflowExecutionContext.CorrelationId = value));
|
|
|
|
|
engine.SetValue("getCorrelationId", (Func<string?>)(() => context.GetActivityExecutionContext().WorkflowExecutionContext.CorrelationId));
|
2023-11-03 19:28:10 +00:00
|
|
|
engine.SetValue("setVariable", (Action<string, object>)((name, value) => context.SetVariableInScope(name, value)));
|
|
|
|
|
engine.SetValue("getVariable", (Func<string, object?>)(name => context.GetVariableInScope(name)));
|
|
|
|
|
engine.SetValue("getInput", (Func<string, object?>)(name => context.GetInput(name)));
|
|
|
|
|
engine.SetValue("getOutputFrom", (Func<string, string?, object?>)((activityIdName, outputName) => context.GetOutput(activityIdName, outputName)));
|
|
|
|
|
engine.SetValue("getLastResult", (Func<object?>)(() => context.GetLastResult()));
|
2023-09-06 20:04:58 +00:00
|
|
|
|
2023-03-24 21:25:48 +00:00
|
|
|
// Create variable getters and setters for each variable.
|
|
|
|
|
CreateVariableAccessors(engine, context);
|
2023-09-06 20:04:58 +00:00
|
|
|
|
2023-09-06 11:50:08 +00:00
|
|
|
// Create workflow input accessors - only if the current activity is not part of a composite activity definition.
|
|
|
|
|
// Otherwise, the workflow input accessors will hide the composite activity input accessors which rely on variable accessors created above.
|
2023-11-03 19:28:10 +00:00
|
|
|
CreateWorkflowInputAccessors(engine, context);
|
2023-02-03 13:29:44 +00:00
|
|
|
|
2023-06-09 20:10:56 +00:00
|
|
|
// Create output getters for each activity.
|
2024-06-05 11:34:47 +00:00
|
|
|
await CreateActivityOutputAccessorsAsync(engine, context);
|
2024-01-30 20:22:32 +00:00
|
|
|
|
2023-12-14 09:45:37 +00:00
|
|
|
// Create argument getters for each argument.
|
|
|
|
|
foreach (var argument in options.Arguments)
|
|
|
|
|
engine.SetValue($"get{argument.Key}", (Func<object?>)(() => argument.Value));
|
2024-01-30 20:22:32 +00:00
|
|
|
|
2023-12-14 09:45:37 +00:00
|
|
|
// Add common functions.
|
2023-02-03 13:29:44 +00:00
|
|
|
engine.SetValue("isNullOrWhiteSpace", (Func<string, bool>)(value => string.IsNullOrWhiteSpace(value)));
|
|
|
|
|
engine.SetValue("isNullOrEmpty", (Func<string, bool>)(value => string.IsNullOrEmpty(value)));
|
|
|
|
|
engine.SetValue("toJson", (Func<object, string>)(value => Serialize(value)));
|
2023-05-08 20:38:59 +00:00
|
|
|
engine.SetValue("parseGuid", (Func<string, Guid>)(value => Guid.Parse(value)));
|
|
|
|
|
engine.SetValue("newGuid", (Func<Guid>)(() => Guid.NewGuid()));
|
|
|
|
|
engine.SetValue("newGuidString", (Func<string>)(() => Guid.NewGuid().ToString()));
|
|
|
|
|
engine.SetValue("newShortGuid", (Func<string>)(() => Regex.Replace(Convert.ToBase64String(Guid.NewGuid().ToByteArray()), "[/+=]", "")));
|
2023-09-06 20:04:58 +00:00
|
|
|
|
2023-08-14 12:34:40 +00:00
|
|
|
// Deprecated, use newGuidString instead.
|
|
|
|
|
engine.SetValue("getGuidString", (Func<string>)(() => Guid.NewGuid().ToString()));
|
2023-09-06 20:04:58 +00:00
|
|
|
|
2023-08-14 12:34:40 +00:00
|
|
|
// Deprecated, use newShortGuid instead.
|
|
|
|
|
engine.SetValue("getShortGuid", (Func<string>)(() => Regex.Replace(Convert.ToBase64String(Guid.NewGuid().ToByteArray()), "[/+=]", "")));
|
2022-01-12 10:43:46 +00:00
|
|
|
|
2024-03-18 22:20:12 +00:00
|
|
|
// Create configuration value accessor
|
|
|
|
|
if (_jintOptions.AllowConfigurationAccess)
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
engine.SetValue("getConfig", (Func<string, object?>)(name => configuration.GetSection(name).Value));
|
2024-03-18 22:20:12 +00:00
|
|
|
|
2023-01-04 19:36:38 +00:00
|
|
|
// Add common .NET types.
|
|
|
|
|
engine.RegisterType<DateTime>();
|
|
|
|
|
engine.RegisterType<DateTimeOffset>();
|
|
|
|
|
engine.RegisterType<TimeSpan>();
|
2023-02-03 13:29:44 +00:00
|
|
|
engine.RegisterType<Guid>();
|
2022-01-12 10:43:46 +00:00
|
|
|
|
2023-10-07 10:47:36 +00:00
|
|
|
// Invoke registered configuration callback.
|
|
|
|
|
_jintOptions.ConfigureEngineCallback(engine, context);
|
|
|
|
|
|
2023-01-04 19:36:38 +00:00
|
|
|
// Allow listeners invoked by the mediator to configure the engine.
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
await mediator.SendAsync(new EvaluatingJavaScript(engine, context), cancellationToken);
|
2022-01-12 10:43:46 +00:00
|
|
|
|
2023-01-04 19:36:38 +00:00
|
|
|
return engine;
|
|
|
|
|
}
|
2022-12-15 21:53:56 +00:00
|
|
|
|
2023-11-03 19:28:10 +00:00
|
|
|
private void CreateWorkflowInputAccessors(Engine engine, ExpressionExecutionContext context)
|
2023-09-06 11:50:08 +00:00
|
|
|
{
|
2023-11-03 19:28:10 +00:00
|
|
|
if (context.IsInsideCompositeActivity())
|
|
|
|
|
return;
|
2023-09-06 11:50:08 +00:00
|
|
|
|
2024-01-17 21:11:03 +00:00
|
|
|
var inputs = context.GetWorkflowInputs().ToDictionary(x => x.Name);
|
2024-02-02 20:09:48 +00:00
|
|
|
|
|
|
|
|
if (!context.TryGetWorkflowExecutionContext(out var workflowExecutionContext))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var inputDefinitions = workflowExecutionContext.Workflow.Inputs;
|
2023-09-06 11:50:08 +00:00
|
|
|
|
2024-01-17 21:11:03 +00:00
|
|
|
foreach (var inputDefinition in inputDefinitions)
|
|
|
|
|
{
|
|
|
|
|
var input = inputs.GetValueOrDefault(inputDefinition.Name);
|
|
|
|
|
engine.SetValue($"get{inputDefinition.Name}", (Func<object?>)(() => input?.Value));
|
|
|
|
|
}
|
2023-08-22 12:59:31 +00:00
|
|
|
}
|
2023-06-09 20:10:56 +00:00
|
|
|
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
[RequiresUnreferencedCode("Calls Jint.Engine.SetValue<T>(String, T)")]
|
2023-03-24 21:25:48 +00:00
|
|
|
private static void CreateVariableAccessors(Engine engine, ExpressionExecutionContext context)
|
2023-01-04 19:36:38 +00:00
|
|
|
{
|
2023-11-03 19:28:10 +00:00
|
|
|
var variableNames = context.GetVariableNamesInScope().ToList();
|
2022-12-15 21:53:56 +00:00
|
|
|
|
2023-03-22 21:50:26 +00:00
|
|
|
foreach (var variableName in variableNames)
|
2022-01-12 10:43:46 +00:00
|
|
|
{
|
2023-03-22 21:50:26 +00:00
|
|
|
var pascalName = variableName.Pascalize();
|
2023-11-03 19:28:10 +00:00
|
|
|
engine.SetValue($"get{pascalName}", (Func<object?>)(() => context.GetVariableInScope(variableName)));
|
|
|
|
|
engine.SetValue($"set{pascalName}", (Action<object?>)(value => context.SetVariableInScope(variableName, value)));
|
2023-03-22 21:50:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-05 11:34:47 +00:00
|
|
|
private static async Task CreateActivityOutputAccessorsAsync(Engine engine, ExpressionExecutionContext context)
|
2023-06-09 20:10:56 +00:00
|
|
|
{
|
2023-11-03 19:28:10 +00:00
|
|
|
var activityOutputs = context.GetActivityOutputs();
|
2023-08-02 20:52:02 +00:00
|
|
|
|
2024-05-15 09:06:22 +00:00
|
|
|
await foreach (var activityOutput in activityOutputs)
|
2023-11-03 19:28:10 +00:00
|
|
|
foreach (var outputName in activityOutput.OutputNames)
|
|
|
|
|
engine.SetValue($"get{outputName}From{activityOutput.ActivityName}", (Func<object?>)(() => context.GetOutput(activityOutput.ActivityId, outputName)));
|
2023-06-09 20:10:56 +00:00
|
|
|
}
|
|
|
|
|
|
2024-04-25 08:26:35 +00:00
|
|
|
private object? ExecuteExpressionAndGetResult(Engine engine, string expression)
|
2023-01-04 19:36:38 +00:00
|
|
|
{
|
Fix Race Condition in WorkflowDefinitionActivity (#5315)
* Refactor hash method in Hasher.cs
The Hash method in the Hasher.cs file has been refactored to use more efficient code. Instead of creating a SHA256 instance, it directly hashes the data using SHA256.HashData. As a result, the private Hash method and its usage, which only has relevance to the previous approach, have been removed.
* Replace GetHashCode with SHA256 for script caching
Two unused namespaces, Esprima and Esprima.Ast, have been removed, and two new ones, System.Security.Cryptography and System.Text, have been added. These changes in Elsa.JavaScript's JintJavaScriptEvaluator file were made to replace the basic GetHashCode method, which was used earlier to generate a cache key for JavaScript scripts, with SHA256 hash function to ensure uniqueness and avoid possible hash collisions. This greatly increases the reliability of the caching mechanism.
* Set HTTP client timeout in WorkflowServer
The client timeout in WorkflowServer has been set to 1 minute for `ResrService` and `client` methods. This was done to manage long running requests and prevent timeouts.
* Refactor code and add validation in ScheduleActivityAsync methods
An unnecessary line of code in the ScheduleActivityAsync method under the ActivityExecutionContext file has been removed to simplify the function. Meanwhile, validation has been added to ensure that specified activities are part of the workflow. This improves code clarity and prevents potential errors caused by incorrect activity scheduling.
* Refactor ActivityVisitor to use ActivityVisitorContext
The ActivityVisitor class in Elsa.Workflows.Core was refactored to use an ActivityVisitorContext class. The introduction of this context class replaced the multiple hashsets that were used within function signatures, consolidating them into a single object and reducing function complexity. This change improves readability and code organization.
* Refactor WorkflowDefinitionActivity to use WorkflowGraph
Adjusted the WorkflowDefinitionActivity class in the Elsa.Workflows.Management module. The changes include migration from using Workflow to WorkflowGraph objects and condensing code blocks for clearer readability. Additionally, a new 'IsInitialized' field is added to eliminate potential race conditions during the graph construction process.
* Add activity validation to WorkflowExecutionContext
A check has been implemented in the WorkflowExecutionContextExtensions to validate that a specified activity is part of the workflow. This prevents incorrect activity references when scheduling tasks in the workflow.
* Refactor to use WorkflowGraph instead of Workflow
The codebase has been refactored to utilize the WorkflowGraph instead of the Workflow while running and manipulating workflows. Additional changes include restructuring WorkflowRunner and WorkflowDefinitionService classes, introducing WorkflowGraphBuilder usage, and mapping updates in WorkflowDefinitionMapper. The WorkflowHost, WorkflowDispatcher, and WorkflowExecutionContext have also been updated accordingly.
* Add WorkflowGraph and related services
This commit introduces the IWorkflowGraphBuilder interface, the WorkflowGraph model, and an implementation of the interface in the WorkflowGraphBuilder class. The purpose of these additions is to establish the building and structure of a workflow graph. The WorkflowGraph model also includes activity node handling and hashing capabilities.
* Add tests to ensure exception when scheduling an activity not part of workflow
Several unit tests were written to ensure that the right behavior is exhibited when scheduling an activity that is not part of the workflow. An exception is expected to be thrown in this case. Additionally, new service definitions, workflow definitions and workflow queries were added for more comprehensive testing.
* Update WorkflowGraph class and add comment descriptions
This commit updates the WorkflowGraph class by extending its descriptions and implementing an explicit mention to the Workflow reference. Additionally, more attribute descriptions have been added to increase code readability and comprehension.
* Removed unnecessary brackets
* Remove unused services from workflow management
This commit deletes "ExpressionDescriptorRegistryPopulator.cs" and "ScopedWorkflowDefinitionLookup.cs" files from Elsa.Workflows.Management.Services. These files, containing obsolete services, are no longer used in the workflow management process. The services' registration has been removed as well from "WorkflowManagementFeature.cs".
* Remove TestWorkflowDefinitionService.cs from component tests
A file, TestWorkflowDefinitionService.cs, was removed under Elsa.Workflows.ComponentTests. This is part of the improvement process where inefficient or unnecessary test files are cleaned up.
* Add comments to WorkflowDefinitionActivityTests
This commit adds explanatory comments to the WorkflowDefinitionActivityTests file. The comments provide information about the purpose of these tests and a reference to a related issue in the project's Github repository.
* Updated duplicate and missing package references
---------
Co-authored-by: Raymond den Haan <raymond.den.haan@nexxbiz.io>
2024-05-01 12:53:37 +00:00
|
|
|
var cacheKey = "jint:script:" + Hash(expression);
|
2024-04-25 08:26:35 +00:00
|
|
|
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
var parsedScript = memoryCache.GetOrCreate(cacheKey, entry =>
|
2024-04-25 08:26:35 +00:00
|
|
|
{
|
|
|
|
|
if (_jintOptions.ScriptCacheTimeout.HasValue)
|
|
|
|
|
entry.SetAbsoluteExpiration(_jintOptions.ScriptCacheTimeout.Value);
|
|
|
|
|
|
2024-04-26 18:07:34 +00:00
|
|
|
var prepareOptions = new ScriptPreparationOptions
|
|
|
|
|
{
|
|
|
|
|
ParsingOptions = new ScriptParsingOptions
|
|
|
|
|
{
|
|
|
|
|
AllowReturnOutsideFunction = true
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return Engine.PrepareScript(expression, options: prepareOptions);
|
2024-04-25 08:26:35 +00:00
|
|
|
})!;
|
|
|
|
|
|
|
|
|
|
var result = engine.Evaluate(parsedScript);
|
2023-01-04 19:36:38 +00:00
|
|
|
return result.ToObject();
|
|
|
|
|
}
|
2023-02-03 13:29:44 +00:00
|
|
|
|
2024-03-12 16:47:58 +00:00
|
|
|
[RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)")]
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
private string Serialize(object value)
|
|
|
|
|
{
|
|
|
|
|
return JsonSerializer.Serialize(value, _jsonSerializerOptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static JsonSerializerOptions CreateJsonSerializerOptions()
|
2023-02-03 13:29:44 +00:00
|
|
|
{
|
2024-03-12 16:47:58 +00:00
|
|
|
var options = new JsonSerializerOptions
|
|
|
|
|
{
|
|
|
|
|
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
|
|
|
|
|
};
|
2023-02-03 13:29:44 +00:00
|
|
|
options.Converters.Add(new JsonStringEnumConverter());
|
Add HTTP file download activity and supporting classes (#5608)
* Add HTTP file download activity and supporting classes
This commit adds a new activity, DownloadHttpFile, which provides the capability to download a file from a specified URL. It introduces supporting classes like HttpFile, FileHttpContentParser, and several extensions methods related to handling HTTP headers and file content. It also contains necessary updates in existing classes to accommodate the new file-download feature.
* Add response stream to context in DownloadHttpFile
In DownloadHttpFile.cs, context data now includes response content's file stream. Changes to DefaultDownloadableManager.cs simplify the return statement when no provider is found, directly returning an empty array.
* Add byte array converter and enhance HTTP file download
A new ByteArrayConverter class has been added to Elsa.JavaScript that converts byte arrays to Uint8Arrays. In Elsa.Http, the DownloadHttpFile activity now also stores the downloaded file's content in bytes. In addition, various new type aliases have been added to the Elsa.Http and Elsa.JavaScript modules, making it easier to handle non-string responses and the transfer of data.
* Update Elsa.Studio package versions
The package versions for Elsa.Studio, Elsa.Studio.Core.BlazorWasm, and Elsa.Studio.Login.BlazorWasm have been updated from 3.2.0-preview.346 to 3.2.0
* Update Jint version and adjust configuration
Updated the Jint package version to 4.0.0-preview-644. Also, added the Jint Preview package source in the NuGet configuration. Furthermore, made a change to use ArrayBuffer instead of Uint8Array in ByteArrayConverter.cs to align with the updated Jint version.
2024-06-15 18:31:58 +00:00
|
|
|
return options;
|
2023-02-03 13:29:44 +00:00
|
|
|
}
|
Fix Race Condition in WorkflowDefinitionActivity (#5315)
* Refactor hash method in Hasher.cs
The Hash method in the Hasher.cs file has been refactored to use more efficient code. Instead of creating a SHA256 instance, it directly hashes the data using SHA256.HashData. As a result, the private Hash method and its usage, which only has relevance to the previous approach, have been removed.
* Replace GetHashCode with SHA256 for script caching
Two unused namespaces, Esprima and Esprima.Ast, have been removed, and two new ones, System.Security.Cryptography and System.Text, have been added. These changes in Elsa.JavaScript's JintJavaScriptEvaluator file were made to replace the basic GetHashCode method, which was used earlier to generate a cache key for JavaScript scripts, with SHA256 hash function to ensure uniqueness and avoid possible hash collisions. This greatly increases the reliability of the caching mechanism.
* Set HTTP client timeout in WorkflowServer
The client timeout in WorkflowServer has been set to 1 minute for `ResrService` and `client` methods. This was done to manage long running requests and prevent timeouts.
* Refactor code and add validation in ScheduleActivityAsync methods
An unnecessary line of code in the ScheduleActivityAsync method under the ActivityExecutionContext file has been removed to simplify the function. Meanwhile, validation has been added to ensure that specified activities are part of the workflow. This improves code clarity and prevents potential errors caused by incorrect activity scheduling.
* Refactor ActivityVisitor to use ActivityVisitorContext
The ActivityVisitor class in Elsa.Workflows.Core was refactored to use an ActivityVisitorContext class. The introduction of this context class replaced the multiple hashsets that were used within function signatures, consolidating them into a single object and reducing function complexity. This change improves readability and code organization.
* Refactor WorkflowDefinitionActivity to use WorkflowGraph
Adjusted the WorkflowDefinitionActivity class in the Elsa.Workflows.Management module. The changes include migration from using Workflow to WorkflowGraph objects and condensing code blocks for clearer readability. Additionally, a new 'IsInitialized' field is added to eliminate potential race conditions during the graph construction process.
* Add activity validation to WorkflowExecutionContext
A check has been implemented in the WorkflowExecutionContextExtensions to validate that a specified activity is part of the workflow. This prevents incorrect activity references when scheduling tasks in the workflow.
* Refactor to use WorkflowGraph instead of Workflow
The codebase has been refactored to utilize the WorkflowGraph instead of the Workflow while running and manipulating workflows. Additional changes include restructuring WorkflowRunner and WorkflowDefinitionService classes, introducing WorkflowGraphBuilder usage, and mapping updates in WorkflowDefinitionMapper. The WorkflowHost, WorkflowDispatcher, and WorkflowExecutionContext have also been updated accordingly.
* Add WorkflowGraph and related services
This commit introduces the IWorkflowGraphBuilder interface, the WorkflowGraph model, and an implementation of the interface in the WorkflowGraphBuilder class. The purpose of these additions is to establish the building and structure of a workflow graph. The WorkflowGraph model also includes activity node handling and hashing capabilities.
* Add tests to ensure exception when scheduling an activity not part of workflow
Several unit tests were written to ensure that the right behavior is exhibited when scheduling an activity that is not part of the workflow. An exception is expected to be thrown in this case. Additionally, new service definitions, workflow definitions and workflow queries were added for more comprehensive testing.
* Update WorkflowGraph class and add comment descriptions
This commit updates the WorkflowGraph class by extending its descriptions and implementing an explicit mention to the Workflow reference. Additionally, more attribute descriptions have been added to increase code readability and comprehension.
* Removed unnecessary brackets
* Remove unused services from workflow management
This commit deletes "ExpressionDescriptorRegistryPopulator.cs" and "ScopedWorkflowDefinitionLookup.cs" files from Elsa.Workflows.Management.Services. These files, containing obsolete services, are no longer used in the workflow management process. The services' registration has been removed as well from "WorkflowManagementFeature.cs".
* Remove TestWorkflowDefinitionService.cs from component tests
A file, TestWorkflowDefinitionService.cs, was removed under Elsa.Workflows.ComponentTests. This is part of the improvement process where inefficient or unnecessary test files are cleaned up.
* Add comments to WorkflowDefinitionActivityTests
This commit adds explanatory comments to the WorkflowDefinitionActivityTests file. The comments provide information about the purpose of these tests and a reference to a related issue in the project's Github repository.
* Updated duplicate and missing package references
---------
Co-authored-by: Raymond den Haan <raymond.den.haan@nexxbiz.io>
2024-05-01 12:53:37 +00:00
|
|
|
|
|
|
|
|
private string Hash(string input)
|
|
|
|
|
{
|
|
|
|
|
var bytes = Encoding.UTF8.GetBytes(input);
|
|
|
|
|
var hash = SHA256.HashData(bytes);
|
|
|
|
|
return Convert.ToBase64String(hash);
|
|
|
|
|
}
|
2022-01-12 10:43:46 +00:00
|
|
|
}
|