Update Workflow model with support for Inputs, Outputs and Outcomes (#4112)

* Fix mutable prop changes warning

* Fix graph no longer scrolling to content

* Remove unused namespace imports

* Update Workflow model with support for input, output and outcomes

* Update sample with EF core persistence

* Rename FluentStorage to BlobStorage
This commit is contained in:
Sipke Schoorstra 2023-06-08 11:39:19 +02:00 committed by GitHub
parent d53eb500f2
commit c216185c5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 430 additions and 54 deletions

View file

@ -192,8 +192,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.JsonWorkflows"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.JsonWorkflowProvider", "src\samples\aspnet\Elsa.Samples.JsonWorkflowProvider\Elsa.Samples.JsonWorkflowProvider.csproj", "{C5043453-5FB8-4796-9A80-C4C766F2CB62}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.WorkflowProviders.FluentStorage", "src\modules\Elsa.WorkflowProviders.FluentStorage\Elsa.WorkflowProviders.FluentStorage.csproj", "{044C3108-FE79-460A-9C31-A03C30228836}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.AspNet.ProtoActorRuntime.AzureContainerApps", "src\samples\aspnet\Elsa.Samples.AspNet.ProtoActorRuntime.AzureContainerApps\Elsa.Samples.AspNet.ProtoActorRuntime.AzureContainerApps.csproj", "{3212A999-4AC4-4911-9AA4-92AB906BCB5E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.AspNet.HttpEndpoints", "src\samples\aspnet\Elsa.Samples.AspNet.HttpEndpoints\Elsa.Samples.AspNet.HttpEndpoints.csproj", "{165ACC9D-B67C-4B49-A818-ECFD247C899C}"
@ -224,6 +222,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.AspNet.DapperP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Dapper.Migrations", "src\modules\Elsa.Dapper.Migrations\Elsa.Dapper.Migrations.csproj", "{A86DF0F0-24E9-470E-984B-9E7332544972}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.WorkflowProviders.BlobStorage", "src\modules\Elsa.WorkflowProviders.BlobStorage\Elsa.WorkflowProviders.BlobStorage.csproj", "{A702DD84-B55C-4807-9C28-D8F5AC3CCA78}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -518,10 +518,6 @@ Global
{C5043453-5FB8-4796-9A80-C4C766F2CB62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5043453-5FB8-4796-9A80-C4C766F2CB62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5043453-5FB8-4796-9A80-C4C766F2CB62}.Release|Any CPU.Build.0 = Release|Any CPU
{044C3108-FE79-460A-9C31-A03C30228836}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{044C3108-FE79-460A-9C31-A03C30228836}.Debug|Any CPU.Build.0 = Debug|Any CPU
{044C3108-FE79-460A-9C31-A03C30228836}.Release|Any CPU.ActiveCfg = Release|Any CPU
{044C3108-FE79-460A-9C31-A03C30228836}.Release|Any CPU.Build.0 = Release|Any CPU
{3212A999-4AC4-4911-9AA4-92AB906BCB5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3212A999-4AC4-4911-9AA4-92AB906BCB5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3212A999-4AC4-4911-9AA4-92AB906BCB5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -554,6 +550,10 @@ Global
{A86DF0F0-24E9-470E-984B-9E7332544972}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A86DF0F0-24E9-470E-984B-9E7332544972}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A86DF0F0-24E9-470E-984B-9E7332544972}.Release|Any CPU.Build.0 = Release|Any CPU
{A702DD84-B55C-4807-9C28-D8F5AC3CCA78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A702DD84-B55C-4807-9C28-D8F5AC3CCA78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A702DD84-B55C-4807-9C28-D8F5AC3CCA78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A702DD84-B55C-4807-9C28-D8F5AC3CCA78}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{155227F0-A33B-40AA-A4B4-06F813EB921B} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
@ -637,7 +637,6 @@ Global
{30B49E42-AE61-4F7C-981F-923F07BB3986} = {5948B0A5-7873-4DBB-BA03-EB283D6EA91B}
{B08B4E00-C2AB-48F3-8389-449F42AEF179} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
{302BFC43-ED2F-43AE-8AD4-FCD481B0AC67} = {B08B4E00-C2AB-48F3-8389-449F42AEF179}
{044C3108-FE79-460A-9C31-A03C30228836} = {B08B4E00-C2AB-48F3-8389-449F42AEF179}
{C9539BD8-D2AE-4A8D-8281-71A05B3FBF31} = {B08B4E00-C2AB-48F3-8389-449F42AEF179}
{169E2C9B-6687-427F-A278-30BF849BFEDC} = {B08B4E00-C2AB-48F3-8389-449F42AEF179}
{B191F11D-583D-44D9-8A08-F5B0DC58B822} = {B08B4E00-C2AB-48F3-8389-449F42AEF179}
@ -655,5 +654,6 @@ Global
{4D8F3BB2-709D-481A-8FD3-0DA9762B366D} = {9B4F139F-7D26-435C-A561-89E65A67A8E5}
{D5905087-2E73-44AD-B3CC-70FE8AAA99A1} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
{A86DF0F0-24E9-470E-984B-9E7332544972} = {9B4F139F-7D26-435C-A561-89E65A67A8E5}
{A702DD84-B55C-4807-9C28-D8F5AC3CCA78} = {B08B4E00-C2AB-48F3-8389-449F42AEF179}
EndGlobalSection
EndGlobal

View file

@ -19,7 +19,7 @@
<ProjectReference Include="..\..\modules\Elsa.ProtoActor\Elsa.ProtoActor.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Identity\Elsa.Identity.csproj" />
<ProjectReference Include="..\..\modules\Elsa.ProtoActor.Cluster.AzureContainerApps\Elsa.ProtoActor.Cluster.AzureContainerApps.csproj" />
<ProjectReference Include="..\..\modules\Elsa.WorkflowProviders.FluentStorage\Elsa.WorkflowProviders.FluentStorage.csproj" />
<ProjectReference Include="..\..\modules\Elsa.WorkflowProviders.BlobStorage\Elsa.WorkflowProviders.BlobStorage.csproj" />
<ProjectReference Include="..\Elsa\Elsa.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Hangfire\Elsa.Hangfire.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Http\Elsa.Http.csproj" />

View file

@ -30,9 +30,9 @@ export class InputControlSwitch {
}
// Tunneled props.
@Prop() workflowDefinitionId: string;
@Prop() activityType: string;
@Prop() propertyName: string;
@Prop({mutable: true}) workflowDefinitionId: string;
@Prop({mutable: true}) activityType: string;
@Prop({mutable: true}) propertyName: string;
@Prop() label: string;
@Prop() hideLabel: boolean;

View file

@ -441,6 +441,7 @@ export class FlowchartComponent {
this.graph.fromJSON(model, {silent: false});
this.graph.unfreeze();
rebuildGraph(this.graph);
this.graph.scrollToContent();
}
private getFlowchartModel = (): FlowchartModel => {

View file

@ -1,6 +1,6 @@
using FluentStorage.Blobs;
namespace Elsa.WorkflowProviders.FluentStorage.Contracts;
namespace Elsa.WorkflowProviders.BlobStorage.Contracts;
/// <summary>
/// A provider of <see cref="IBlobStorage"/>. The point of this interface is to provide a wrapper for actual <see cref="IBlobStorage"/> implementations.

View file

@ -1,5 +1,5 @@
using Elsa.Features.Services;
using Elsa.WorkflowProviders.FluentStorage.Features;
using Elsa.WorkflowProviders.BlobStorage.Features;
using FluentStorage.Blobs;
using JetBrains.Annotations;

View file

@ -2,15 +2,15 @@ using System.Reflection;
using Elsa.Features.Abstractions;
using Elsa.Features.Attributes;
using Elsa.Features.Services;
using Elsa.WorkflowProviders.FluentStorage.Contracts;
using Elsa.WorkflowProviders.FluentStorage.Providers;
using Elsa.WorkflowProviders.BlobStorage.Contracts;
using Elsa.WorkflowProviders.BlobStorage.Providers;
using Elsa.Workflows.Management.Features;
using FluentStorage;
using FluentStorage.Blobs;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
namespace Elsa.WorkflowProviders.FluentStorage.Features;
namespace Elsa.WorkflowProviders.BlobStorage.Features;
/// <summary>
/// A feature that enables the FluentStorage workflow definition provider.
@ -34,7 +34,7 @@ public class FluentStorageFeature : FeatureBase
public override void Apply()
{
Services.AddSingleton<IBlobStorageProvider>(sp => new BlobStorageProvider(BlobStorage(sp)));
Services.AddWorkflowDefinitionProvider<FluentStorageWorkflowProvider>();
Services.AddWorkflowDefinitionProvider<BlobStorageWorkflowProvider>();
}
/// <summary>

View file

@ -1,7 +1,7 @@
using Elsa.WorkflowProviders.FluentStorage.Contracts;
using Elsa.WorkflowProviders.BlobStorage.Contracts;
using FluentStorage.Blobs;
namespace Elsa.WorkflowProviders.FluentStorage.Providers;
namespace Elsa.WorkflowProviders.BlobStorage.Providers;
/// <summary>
/// A provider of <see cref="IBlobStorage"/>.

View file

@ -1,6 +1,6 @@
using Elsa.Common.Contracts;
using Elsa.Dsl.Contracts;
using Elsa.WorkflowProviders.FluentStorage.Contracts;
using Elsa.WorkflowProviders.BlobStorage.Contracts;
using Elsa.Workflows.Core.Contracts;
using Elsa.Workflows.Management.Mappers;
using Elsa.Workflows.Management.Materializers;
@ -10,13 +10,13 @@ using Elsa.Workflows.Runtime.Models;
using FluentStorage.Blobs;
using JetBrains.Annotations;
namespace Elsa.WorkflowProviders.FluentStorage.Providers;
namespace Elsa.WorkflowProviders.BlobStorage.Providers;
/// <summary>
/// A workflow definition provider that loads workflow definitions from a storage using FluentStorage (See https://github.com/robinrodricks/FluentStorage).
/// </summary>
[PublicAPI]
public class FluentStorageWorkflowProvider : IWorkflowProvider
public class BlobStorageWorkflowProvider : IWorkflowProvider
{
private readonly IBlobStorageProvider _blobStorageProvider;
private readonly IActivitySerializer _activitySerializer;
@ -27,9 +27,9 @@ public class FluentStorageWorkflowProvider : IWorkflowProvider
private readonly VariableDefinitionMapper _variableDefinitionMapper;
/// <summary>
/// Initializes a new instance of the <see cref="FluentStorageWorkflowProvider"/> class.
/// Initializes a new instance of the <see cref="BlobStorageWorkflowProvider"/> class.
/// </summary>
public FluentStorageWorkflowProvider(
public BlobStorageWorkflowProvider(
IBlobStorageProvider blobStorageProvider,
IActivitySerializer activitySerializer,
IDslEngine dslEngine,

View file

@ -5,7 +5,6 @@ using Elsa.JavaScript.TypeDefinitions.Contracts;
using Elsa.JavaScript.TypeDefinitions.Models;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Management.Contracts;
using FastEndpoints;
using JetBrains.Annotations;
namespace Elsa.Workflows.Api.Endpoints.Scripting.JavaScript.TypeDefinitions;

View file

@ -1,8 +1,6 @@
using System.DirectoryServices;
using Elsa.Common.Entities;
using Elsa.Common.Entities;
using Elsa.Common.Models;
using Elsa.Workflows.Management.Contracts;
using Elsa.Workflows.Management.Entities;
using Elsa.Workflows.Management.Filters;
using FastEndpoints;
using JetBrains.Annotations;

View file

@ -4,7 +4,7 @@ using System.Text.Json.Serialization;
using Elsa.Expressions.Contracts;
using Elsa.Expressions.Extensions;
using Elsa.Extensions;
using Elsa.Workflows.Management.Models;
using Elsa.Workflows.Core.Models;
namespace Elsa.Workflows.Api.Serialization;

View file

@ -1,7 +1,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Elsa.Expressions.Contracts;
using Elsa.Workflows.Management.Models;
using Elsa.Workflows.Core.Models;
namespace Elsa.Workflows.Api.Serialization;

View file

@ -44,6 +44,15 @@ public class WorkflowBuilder : IWorkflowBuilder
/// <inheritdoc />
public ICollection<Variable> Variables { get; set; } = new List<Variable>();
/// <inheritdoc />
public ICollection<InputDefinition> Inputs { get; set; } = new List<InputDefinition>();
/// <inheritdoc />
public ICollection<OutputDefinition> Outputs { get; set; } = new List<OutputDefinition>();
/// <inheritdoc />
public ICollection<string> Outcomes { get; set; } = new List<string>();
/// <inheritdoc />
public Variable? Result { get; set; }
@ -51,8 +60,8 @@ public class WorkflowBuilder : IWorkflowBuilder
public IDictionary<string, object> CustomProperties { get; set; } = new Dictionary<string, object>();
/// <inheritdoc />
public WorkflowOptions WorkflowOptions { get; } = new();
public WorkflowOptions WorkflowOptions { get; } = new();
/// <inheritdoc />
public Variable<T> WithVariable<T>()
{
@ -69,7 +78,7 @@ public class WorkflowBuilder : IWorkflowBuilder
Name = name,
Value = value
};
Variables.Add(variable);
return variable;
}
@ -88,7 +97,7 @@ public class WorkflowBuilder : IWorkflowBuilder
Variables.Add(variable);
return this;
}
/// <inheritdoc />
public IWorkflowBuilder WithVariable(Variable variable)
{
@ -126,7 +135,7 @@ public class WorkflowBuilder : IWorkflowBuilder
var identity = new WorkflowIdentity(definitionId, Version, id);
var publication = WorkflowPublication.LatestAndPublished;
var workflowMetadata = new WorkflowMetadata(Name, Description);
var workflow = new Workflow(identity, publication, workflowMetadata, WorkflowOptions, root, Variables, CustomProperties);
var workflow = new Workflow(identity, publication, workflowMetadata, WorkflowOptions, root, Variables, Inputs, Outputs, Outcomes, CustomProperties);
// If a Result variable is defined, install it into the workflow so we can capture the output into it.
if (Result != null)
@ -137,14 +146,14 @@ public class WorkflowBuilder : IWorkflowBuilder
var graph = await _activityVisitor.VisitAsync(workflow, cancellationToken);
var nodes = graph.Flatten().ToList();
// Register all activity types first. The identity graph service will need to know about all activity types.
var distinctActivityTypes = nodes.Select(x => x.Activity.GetType()).Distinct().ToList();
await _activityRegistry.RegisterAsync(distinctActivityTypes, cancellationToken);
// Assign identities to all activities.
_identityGraphService.AssignIdentities(nodes);
return workflow;
}

View file

@ -46,6 +46,21 @@ public interface IWorkflowBuilder
/// The workflow variables to store with the workflow being built.
/// </summary>
ICollection<Variable> Variables { get; set; }
/// <summary>
/// Gets or sets the inputs.
/// </summary>
ICollection<InputDefinition> Inputs { get; set; }
/// <summary>
/// Gets or sets the outputs.
/// </summary>
ICollection<OutputDefinition> Outputs { get; set; }
/// <summary>
/// Gets or sets the outcomes.
/// </summary>
ICollection<string> Outcomes { get; set; }
/// <summary>
/// An internal variable used to get and set the result of the workflow.

View file

@ -1,4 +1,4 @@
namespace Elsa.Workflows.Management.Models;
namespace Elsa.Workflows.Core.Models;
/// <summary>
/// Base class for workflow input and output definitions.

View file

@ -1,4 +1,4 @@
namespace Elsa.Workflows.Management.Models;
namespace Elsa.Workflows.Core.Models;
/// <summary>
/// A definition of a workflow's input.

View file

@ -1,4 +1,4 @@
namespace Elsa.Workflows.Management.Models;
namespace Elsa.Workflows.Core.Models;
/// <summary>
/// A definition of a workflow's output.

View file

@ -1,4 +1,4 @@
namespace Elsa.Workflows.Management.Models;
namespace Elsa.Workflows.Core.Models;
/// <summary>
/// Stores information about a workflow variable.

View file

@ -22,13 +22,19 @@ public class Workflow : Composite<object>, ICloneable
WorkflowIdentity identity,
WorkflowPublication publication,
WorkflowMetadata workflowMetadata,
WorkflowOptions? options,
WorkflowOptions options,
IActivity root,
ICollection<Variable> variables,
ICollection<InputDefinition> inputs,
ICollection<OutputDefinition> outputs,
ICollection<string> outcomes,
IDictionary<string, object> customProperties)
{
Identity = identity;
Publication = publication;
Inputs = inputs;
Outputs = outputs;
Outcomes = outcomes;
WorkflowMetadata = workflowMetadata;
Options = options;
Variables = variables;
@ -45,15 +51,45 @@ public class Workflow : Composite<object>, ICloneable
}
/// <summary>
/// Constructor.
/// Initializes a new instance of the <see cref="Workflow"/> class.
/// </summary>
public Workflow()
{
}
/// <summary>
/// Gets or sets the workflow identity.
/// </summary>
public WorkflowIdentity Identity { get; set; } = WorkflowIdentity.VersionOne;
/// <summary>
/// Gets or sets the publication status of the workflow.
/// </summary>
public WorkflowPublication Publication { get; set; } = WorkflowPublication.LatestAndPublished;
/// <summary>
/// Gets or sets input definitions.
/// </summary>
public ICollection<InputDefinition> Inputs { get; set; } = new List<InputDefinition>();
/// <summary>
/// Gets or sets output definitions.
/// </summary>
public ICollection<OutputDefinition> Outputs { get; set; } = new List<OutputDefinition>();
/// <summary>
/// Gets or sets possible outcomes for this workflow.
/// </summary>
public ICollection<string> Outcomes { get; set; } = new List<string>();
/// <summary>
/// Gets or sets metadata about the workflow.
/// </summary>
public WorkflowMetadata WorkflowMetadata { get; set; } = new();
/// <summary>
/// Gets or sets options for the workflow.
/// </summary>
public WorkflowOptions Options { get; set; } = new();
/// <summary>

View file

@ -1,6 +1,5 @@
using Elsa.Common.Entities;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Management.Models;
namespace Elsa.Workflows.Management.Entities;

View file

@ -3,7 +3,6 @@ using Elsa.Expressions.Extensions;
using Elsa.Expressions.Helpers;
using Elsa.Extensions;
using Elsa.Workflows.Core.Models;
using Elsa.Workflows.Management.Models;
namespace Elsa.Workflows.Management.Mappers;

View file

@ -33,7 +33,7 @@ public class WorkflowDefinitionMapper
public Workflow Map(WorkflowDefinition source)
{
var root = _activitySerializer.Deserialize(source.StringData!);
return new(
new WorkflowIdentity(source.DefinitionId, source.Version, source.Id),
new WorkflowPublication(source.IsLatest, source.IsPublished),
@ -41,9 +41,12 @@ public class WorkflowDefinitionMapper
source.Options,
root,
source.Variables,
source.Inputs,
source.Outputs,
source.Outcomes,
source.CustomProperties);
}
/// <summary>
/// Maps a <see cref="WorkflowDefinitionModel"/> to a <see cref="Workflow"/>.
/// </summary>
@ -54,10 +57,10 @@ public class WorkflowDefinitionMapper
var root = source.Root!;
var variables = _variableDefinitionMapper.Map(source.Variables).ToList();
var options = source.Options ?? new WorkflowOptions();
// TODO: Remove this in the future when users have migrated workflows to use the new UsableAsActivity options property.
options.UsableAsActivity ??= source.UsableAsActivity ?? false;
return new(
new WorkflowIdentity(source.DefinitionId, source.Version, source.Id),
new WorkflowPublication(source.IsLatest, source.IsPublished),
@ -65,9 +68,12 @@ public class WorkflowDefinitionMapper
options,
root,
variables,
source.Inputs ?? new List<InputDefinition>(),
source.Outputs ?? new List<OutputDefinition>(),
source.Outcomes ?? new List<string>(),
source.CustomProperties ?? new Dictionary<string, object>());
}
/// <summary>
/// Maps a <see cref="WorkflowDefinition"/> to a <see cref="Workflow"/>.
/// </summary>

View file

@ -96,6 +96,9 @@ public class DefaultWorkflowDefinitionStorePopulator : IWorkflowDefinitionStoreP
existingDefinition.IsPublished = workflow.Publication.IsPublished;
existingDefinition.CustomProperties = workflow.CustomProperties;
existingDefinition.Variables = workflow.Variables;
existingDefinition.Inputs = workflow.Inputs;
existingDefinition.Outputs = workflow.Outputs;
existingDefinition.Outcomes = workflow.Outcomes;
existingDefinition.StringData = workflowJson;
existingDefinition.CreatedAt = workflow.WorkflowMetadata.CreatedAt == default ? _systemClock.UtcNow : workflow.WorkflowMetadata.CreatedAt;
existingDefinition.Options = workflow.Options;

View file

@ -11,7 +11,7 @@
<ProjectReference Include="..\..\..\modules\Elsa.EntityFrameworkCore.Sqlite\Elsa.EntityFrameworkCore.Sqlite.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.Identity\Elsa.Identity.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.WorkflowProviders.FluentStorage\Elsa.WorkflowProviders.FluentStorage.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.WorkflowProviders.BlobStorage\Elsa.WorkflowProviders.BlobStorage.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.Workflows.Api\Elsa.Workflows.Api.csproj" />
</ItemGroup>

View file

@ -8,8 +8,10 @@
<ItemGroup>
<ProjectReference Include="..\..\..\bundles\Elsa\Elsa.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.EntityFrameworkCore.Sqlite\Elsa.EntityFrameworkCore.Sqlite.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.Identity\Elsa.Identity.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.WorkflowProviders.FluentStorage\Elsa.WorkflowProviders.FluentStorage.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.WorkflowProviders.BlobStorage\Elsa.WorkflowProviders.BlobStorage.csproj" />
<ProjectReference Include="..\..\..\modules\Elsa.Workflows.Api\Elsa.Workflows.Api.csproj" />
</ItemGroup>
@ -22,4 +24,8 @@
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="bak\" />
</ItemGroup>
</Project>

View file

@ -1,3 +1,6 @@
using Elsa.EntityFrameworkCore.Modules.Identity;
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.Extensions;
var builder = WebApplication.CreateBuilder(args);
@ -10,11 +13,15 @@ services.AddElsa(elsa => elsa
// Expose API endpoints.
.UseWorkflowsApi()
.UseWorkflowManagement(management => management.UseEntityFrameworkCore())
.UseWorkflowRuntime(runtime => runtime.UseEntityFrameworkCore())
// Configure identity so that we can create a default admin user.
.UseIdentity(identity =>
{
identity.UseAdminUserProvider();
identity.UseEntityFrameworkCore();
identity.TokenOptions = options =>
{
options.SigningKey = "secret-token-signing-key";
@ -29,6 +36,8 @@ services.AddElsa(elsa => elsa
.UseDefaultAuthentication(auth => auth.UseAdminApiKey())
);
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()));
// Configure middleware pipeline.
var app = builder.Build();
@ -38,6 +47,7 @@ if (app.Environment.IsDevelopment())
// Configure the HTTP request pipeline.
app.UseAuthentication();
app.UseAuthorization();
app.UseCors();
app.UseWorkflowsApi();
app.UseWorkflows();
app.Run();

View file

@ -0,0 +1,200 @@
{
"id": "f608ffca0f0a419caea715233edc0259",
"definitionId": "0b1bfb787a2e464e85ef752551a4204e",
"name": "main",
"createdAt": "2023-03-28T07:47:44.969978+00:00",
"version": 6,
"variables": [
{
"id": "516509d438e44171ab68321a4b706f31",
"name": "fromSub",
"typeName": "String",
"isArray": false,
"value": "",
"storageDriverTypeName": "Elsa.Workflows.Core.Services.WorkflowStorageDriver, Elsa.Workflows.Core"
}
],
"inputs": [],
"outputs": [],
"outcomes": [],
"customProperties": {},
"usableAsActivity": false,
"isLatest": true,
"isPublished": true,
"root": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "Flowchart1",
"metadata": {},
"applicationProperties": {
"NotFoundConnectionsKey": [],
"CanStartWorkflow": false,
"RunAsynchronously": false
},
"start": "HttpEndpoint1",
"activities": [
{
"path": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "/mymain"
},
"memoryReference": {
"id": "HttpEndpoint1:input-1"
}
},
"supportedMethods": {
"typeName": "String[]",
"expression": {
"type": "Object",
"value": "[\u0022GET\u0022]"
},
"memoryReference": {
"id": "HttpEndpoint1:input-2"
}
},
"authorize": {
"typeName": "Boolean",
"expression": {
"type": "Literal",
"value": "False"
},
"memoryReference": {
"id": "HttpEndpoint1:input-3"
}
},
"policy": null,
"parsedContent": null,
"routeData": null,
"queryStringData": null,
"headers": null,
"result": null,
"id": "HttpEndpoint1",
"type": "Elsa.HttpEndpoint",
"version": 1,
"customProperties": {
"CanStartWorkflow": true,
"RunAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 1484,
"y": 2317
}
}
}
},
{
"statusCode": {
"typeName": "System.Net.HttpStatusCode, System.Net.Primitives",
"expression": {
"type": "Literal",
"value": "OK"
},
"memoryReference": {
"id": "WriteHttpResponse1:input-1"
}
},
"content": {
"typeName": "Object",
"expression": {
"type": "JavaScript",
"value": "return getFromSub();"
},
"memoryReference": {
"id": "WriteHttpResponse1:input-2"
}
},
"contentType": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "text/plain"
},
"memoryReference": {
"id": "WriteHttpResponse1:input-3"
}
},
"responseHeaders": {
"typeName": "Elsa.Http.Models.HttpResponseHeaders, Elsa.Http",
"expression": {
"type": "Literal",
"value": "{}"
},
"memoryReference": {
"id": "WriteHttpResponse1:input-4"
}
},
"id": "WriteHttpResponse1",
"type": "Elsa.WriteHttpResponse",
"version": 1,
"customProperties": {
"CanStartWorkflow": false,
"RunAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 1860,
"y": 2320
}
}
}
},
{
"workflowDefinitionId": "2f6ba5802e254082b00bd4dab00e650a",
"workflowDefinitionVersionId": "401f5e84019848ffa28d75e75d611b39",
"latestAvailablePublishedVersion": 3,
"latestAvailablePublishedVersionId": "401f5e84019848ffa28d75e75d611b39",
"result": null,
"id": "Sub1",
"type": "Sub",
"version": 3,
"customProperties": {
"CanStartWorkflow": false,
"RunAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 1740,
"y": 2320
}
}
},
"fromMain": {
"typeName": "String",
"expression": {
"type": "JavaScript",
"value": "return \u0027obi wan kenobi\u0027;"
},
"memoryReference": {
"id": "Sub1:input-1"
}
},
"toMain": {
"typeName": "String",
"memoryReference": {
"id": "516509d438e44171ab68321a4b706f31"
}
}
}
],
"connections": [
{
"source": "Sub1",
"target": "WriteHttpResponse1",
"sourcePort": "Done",
"targetPort": "In"
},
{
"source": "HttpEndpoint1",
"target": "Sub1",
"sourcePort": "Done",
"targetPort": "In"
}
]
}
}

View file

@ -0,0 +1,95 @@
{
"id": "401f5e84019848ffa28d75e75d611b39",
"definitionId": "2f6ba5802e254082b00bd4dab00e650a",
"name": "sub",
"createdAt": "2023-04-04T11:31:58.018203+00:00",
"version": 3,
"variables": [
{
"id": "cb1309762f244c5c8237e0547772ef12",
"name": "subvar",
"typeName": "String",
"isArray": false,
"value": "",
"storageDriverTypeName": "Elsa.Workflows.Core.Services.WorkflowStorageDriver, Elsa.Workflows.Core"
}
],
"inputs": [
{
"uiHint": "single-line",
"storageDriverType": "Elsa.Workflows.Core.Services.WorkflowStorageDriver, Elsa.Workflows.Core",
"type": "String",
"name": "fromMain",
"displayName": "fromMain",
"description": "",
"category": "",
"isArray": false
}
],
"outputs": [
{
"type": "String",
"name": "toMain",
"displayName": "toMain",
"description": "",
"isArray": false
}
],
"outcomes": [],
"customProperties": {},
"usableAsActivity": true,
"isLatest": true,
"isPublished": true,
"root": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "Flowchart1",
"metadata": {},
"applicationProperties": {
"NotFoundConnectionsKey": [],
"CanStartWorkflow": false,
"RunAsynchronously": false
},
"start": "SetOutput1",
"activities": [
{
"outputName": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "toMain"
},
"memoryReference": {
"id": "SetOutput1:input-1"
}
},
"outputValue": {
"typeName": "Object",
"expression": {
"type": "JavaScript",
"value": "return \u0027hi there\u0027 \u002B getFromMain();"
},
"memoryReference": {
"id": "SetOutput1:input-2"
}
},
"id": "SetOutput1",
"type": "Elsa.SetOutput",
"version": 1,
"customProperties": {
"CanStartWorkflow": true,
"RunAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 1660,
"y": 2260
}
}
}
}
],
"connections": []
}
}

View file

@ -24,7 +24,7 @@
<ProjectReference Include="..\..\..\src\common\Elsa.Testing.Shared\Elsa.Testing.Shared.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.JavaScript\Elsa.JavaScript.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.Scheduling\Elsa.Scheduling.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.WorkflowProviders.FluentStorage\Elsa.WorkflowProviders.FluentStorage.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.WorkflowProviders.BlobStorage\Elsa.WorkflowProviders.BlobStorage.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.Workflows.Api\Elsa.Workflows.Api.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj" />
</ItemGroup>