Merge branch 'v3-workflow-inbox-cleanup' into v3
This commit is contained in:
commit
aa8536ca7b
|
|
@ -3,7 +3,6 @@ using Elsa.EntityFrameworkCore.Modules.Management;
|
|||
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
||||
using Elsa.Extensions;
|
||||
using Elsa.Http.Handlers;
|
||||
using Elsa.JavaScript.Options;
|
||||
using Elsa.MongoDb.Extensions;
|
||||
using Elsa.MongoDb.Modules.Identity;
|
||||
using Elsa.MongoDb.Modules.Management;
|
||||
|
|
@ -108,6 +107,7 @@ services
|
|||
});
|
||||
|
||||
services.AddHealthChecks();
|
||||
services.AddControllers();
|
||||
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().WithExposedHeaders("*")));
|
||||
|
||||
// Configure middleware pipeline.
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class EFCoreWorkflowStateStore : IWorkflowStateStore
|
|||
|
||||
private async ValueTask OnSaveAsync(RuntimeElsaDbContext dbContext, WorkflowState entity, CancellationToken cancellationToken)
|
||||
{
|
||||
var state = new WorkflowStateState(entity.Bookmarks, entity.CompletionCallbacks, entity.ActivityExecutionContexts, entity.Output, entity.Properties);
|
||||
var state = new WorkflowStateState(entity.Bookmarks, entity.CompletionCallbacks, entity.ActivityExecutionContexts, entity.Output, entity.Properties, entity.Fault);
|
||||
var json = await _workflowStateSerializer.SerializeAsync(state, cancellationToken);
|
||||
var now = _systemClock.UtcNow;
|
||||
var entry = dbContext.Entry(entity);
|
||||
|
|
@ -80,6 +80,7 @@ public class EFCoreWorkflowStateStore : IWorkflowStateStore
|
|||
entity.ActivityExecutionContexts = data.ActivityExecutionContexts;
|
||||
entity.Output = data.Output;
|
||||
entity.Properties = data.Properties;
|
||||
entity.Fault = data.Fault;
|
||||
}
|
||||
|
||||
private class WorkflowStateState
|
||||
|
|
@ -89,19 +90,19 @@ public class EFCoreWorkflowStateStore : IWorkflowStateStore
|
|||
{
|
||||
}
|
||||
|
||||
public WorkflowStateState(
|
||||
ICollection<Bookmark> bookmarks,
|
||||
public WorkflowStateState(ICollection<Bookmark> bookmarks,
|
||||
ICollection<CompletionCallbackState> completionCallbacks,
|
||||
ICollection<ActivityExecutionContextState> activityExecutionContexts,
|
||||
IDictionary<string, object> output,
|
||||
IDictionary<string, object> properties
|
||||
)
|
||||
IDictionary<string, object> properties,
|
||||
WorkflowFaultState? fault)
|
||||
{
|
||||
Bookmarks = bookmarks;
|
||||
CompletionCallbacks = completionCallbacks;
|
||||
ActivityExecutionContexts = activityExecutionContexts;
|
||||
Output = output;
|
||||
Properties = properties;
|
||||
Fault = fault;
|
||||
}
|
||||
|
||||
public ICollection<Bookmark> Bookmarks { get; set; } = new List<Bookmark>();
|
||||
|
|
@ -109,5 +110,6 @@ public class EFCoreWorkflowStateStore : IWorkflowStateStore
|
|||
public ICollection<ActivityExecutionContextState> ActivityExecutionContexts { get; set; } = new List<ActivityExecutionContextState>();
|
||||
public IDictionary<string, object> Output { get; set; } = new Dictionary<string, object>();
|
||||
public IDictionary<string, object> Properties { get; set; } = new Dictionary<string, object>();
|
||||
public WorkflowFaultState? Fault { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -27,14 +27,14 @@ public class DefaultHttpEndpointWorkflowFaultHandler : IHttpEndpointWorkflowFaul
|
|||
{
|
||||
var httpContext = context.HttpContext;
|
||||
var workflowState = context.WorkflowState;
|
||||
var fault = workflowState.Fault!;
|
||||
var fault = workflowState.Fault;
|
||||
|
||||
httpContext.Response.ContentType = MediaTypeNames.Application.Json;
|
||||
httpContext.Response.StatusCode = StatusCodes.Status500InternalServerError;
|
||||
|
||||
var faultedResponse = _apiSerializer.Serialize(new
|
||||
{
|
||||
errorMessage = $"Workflow faulted with error: {fault.Message}",
|
||||
errorMessage = fault != null ? $"Workflow faulted with error: {fault.Message}" : "Workflow faulted",
|
||||
workflowState = workflowState
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ namespace Elsa.Http.Scripting.JavaScript;
|
|||
[PublicAPI]
|
||||
public class HttpJavaScriptHandler : INotificationHandler<EvaluatingJavaScript>
|
||||
{
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task HandleAsync(EvaluatingJavaScript notification, CancellationToken cancellationToken)
|
||||
public Task HandleAsync(EvaluatingJavaScript notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var engine = notification.Engine;
|
||||
engine.RegisterType<HttpRequestHeaders>();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ public class RouteMatcher : IRouteMatcher
|
|||
|
||||
foreach (var parameter in parsedTemplate.Parameters)
|
||||
if (parameter.DefaultValue != null)
|
||||
result.Add(parameter.Name, parameter.DefaultValue);
|
||||
result.Add(parameter.Name!, parameter.DefaultValue);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,12 @@ public class JintJavaScriptEvaluator : IJavaScriptEvaluator
|
|||
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()), "[/+=]", "")));
|
||||
|
||||
// Deprecated, use newGuidString instead.
|
||||
engine.SetValue("getGuidString", (Func<string>)(() => Guid.NewGuid().ToString()));
|
||||
|
||||
// Deprecated, use newShortGuid instead.
|
||||
engine.SetValue("getShortGuid", (Func<string>)(() => Regex.Replace(Convert.ToBase64String(Guid.NewGuid().ToByteArray()), "[/+=]", "")));
|
||||
|
||||
// Add common .NET types.
|
||||
engine.RegisterType<DateTime>();
|
||||
|
|
@ -143,11 +149,11 @@ public class JintJavaScriptEvaluator : IJavaScriptEvaluator
|
|||
if (obj == null)
|
||||
return null!;
|
||||
|
||||
// If it's not an IEnumerable or it's a string, return the original object
|
||||
if (obj is not IEnumerable enumerable || obj is string)
|
||||
// If it's not an IEnumerable or it's a string or dictionary, return the original object.
|
||||
if (obj is not IEnumerable enumerable || obj is string || obj is IDictionary)
|
||||
return obj;
|
||||
|
||||
// Use LINQ to convert the IEnumerable to an array
|
||||
// Use LINQ to convert the IEnumerable to an array.
|
||||
var elementType = obj.GetType().GetGenericArguments().FirstOrDefault();
|
||||
|
||||
if (elementType == null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue