diff --git a/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinition.cs b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinition.cs index bf3b0a565..54c50f728 100644 --- a/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinition.cs +++ b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/WorkflowDefinition.cs @@ -23,6 +23,11 @@ public class WorkflowDefinition : VersionedEntity /// public string? Description { get; set; } + /// + /// The version of the tool that created this workflow. + /// + public Version? ToolVersion { get; set; } + /// /// A set of options for the workflow. /// diff --git a/src/modules/Elsa.Dapper.Migrations/Management/Initial.cs b/src/modules/Elsa.Dapper.Migrations/Management/Initial.cs index ee2f68bf6..c8be96fee 100644 --- a/src/modules/Elsa.Dapper.Migrations/Management/Initial.cs +++ b/src/modules/Elsa.Dapper.Migrations/Management/Initial.cs @@ -17,6 +17,7 @@ public class Initial : Migration .WithColumn("Id").AsString().PrimaryKey() .WithColumn("DefinitionId").AsString().NotNullable() .WithColumn("Name").AsString().Nullable() + .WithColumn("ToolVersion").AsString().Nullable() .WithColumn("Description").AsString().Nullable() .WithColumn("ProviderName").AsString().Nullable() .WithColumn("MaterializerName").AsString().NotNullable() diff --git a/src/modules/Elsa.Dapper/Modules/Management/Records/WorkflowDefinitionRecord.cs b/src/modules/Elsa.Dapper/Modules/Management/Records/WorkflowDefinitionRecord.cs index 3717457d7..d1cd75e5d 100644 --- a/src/modules/Elsa.Dapper/Modules/Management/Records/WorkflowDefinitionRecord.cs +++ b/src/modules/Elsa.Dapper/Modules/Management/Records/WorkflowDefinitionRecord.cs @@ -5,6 +5,7 @@ internal class WorkflowDefinitionRecord public string Id { get; set; } = default!; public string DefinitionId { get; set; } = default!; public string? Name { get; set; } + public string? ToolVersion { get; set; } public string? Description { get; set; } public string? ProviderName { get; set; } public string MaterializerName { get; set; } = default!; diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Elsa.EntityFrameworkCore.MySql.csproj b/src/modules/Elsa.EntityFrameworkCore.MySql/Elsa.EntityFrameworkCore.MySql.csproj index e43b78643..604c97036 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Elsa.EntityFrameworkCore.MySql.csproj +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/Elsa.EntityFrameworkCore.MySql.csproj @@ -22,9 +22,5 @@ - - - - diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230603165710_Initial.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230706133103_Initial.Designer.cs similarity index 97% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230603165710_Initial.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230706133103_Initial.Designer.cs index c8c6d49b2..52c9b9eb6 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230603165710_Initial.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230706133103_Initial.Designer.cs @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Elsa.EntityFrameworkCore.MySql.Migrations.Management { [DbContext(typeof(ManagementElsaDbContext))] - [Migration("20230603165710_Initial")] + [Migration("20230706133103_Initial")] partial class Initial { /// @@ -69,6 +69,9 @@ namespace Elsa.EntityFrameworkCore.MySql.Migrations.Management b.Property("StringData") .HasColumnType("longtext"); + b.Property("ToolVersion") + .HasColumnType("longtext"); + b.Property("UsableAsActivity") .HasColumnType("tinyint(1)"); diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230603165710_Initial.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230706133103_Initial.cs similarity index 97% rename from src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230603165710_Initial.cs rename to src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230706133103_Initial.cs index 8e4b07b35..ab97fbf63 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230603165710_Initial.cs +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/20230706133103_Initial.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using System; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable @@ -29,6 +30,8 @@ namespace Elsa.EntityFrameworkCore.MySql.Migrations.Management .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), + ToolVersion = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), ProviderName = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), MaterializerName = table.Column(type: "longtext", nullable: false) diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs index 8fe72029c..4b50a971f 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs @@ -66,6 +66,9 @@ namespace Elsa.EntityFrameworkCore.MySql.Migrations.Management b.Property("StringData") .HasColumnType("longtext"); + b.Property("ToolVersion") + .HasColumnType("longtext"); + b.Property("UsableAsActivity") .HasColumnType("tinyint(1)"); diff --git a/src/modules/Elsa.EntityFrameworkCore.MySql/generate-migrations.cmd b/src/modules/Elsa.EntityFrameworkCore.MySql/generate-migrations.cmd index bfef70185..cb9441c69 100644 --- a/src/modules/Elsa.EntityFrameworkCore.MySql/generate-migrations.cmd +++ b/src/modules/Elsa.EntityFrameworkCore.MySql/generate-migrations.cmd @@ -1,5 +1,5 @@ -dotnet ef migrations add Initial -c ActivityDefinitionsElsaDbContext -o Migrations/ActivityDefinitions -dotnet ef migrations add Initial -c LabelsElsaDbContext -o Migrations/Labels -dotnet ef migrations add Initial -c ManagementElsaDbContext -o Migrations/Management -dotnet ef migrations add Initial -c RuntimeElsaDbContext -o Migrations/Runtime -dotnet ef migrations add Initial -c IdentityElsaDbContext -o Migrations/Identity \ No newline at end of file +dotnet ef migrations add Initial -c ActivityDefinitionsElsaDbContext -o Migrations/ActivityDefinitions -- "Server=localhost;Port=3306;Database=elsa;User=root;Password=password;" +dotnet ef migrations add Initial -c LabelsElsaDbContext -o Migrations/Labels -- "Server=localhost;Port=3306;Database=elsa;User=root;Password=password;" +dotnet ef migrations add Initial -c ManagementElsaDbContext -o Migrations/Management -- "Server=localhost;Port=3306;Database=elsa;User=root;Password=password;" +dotnet ef migrations add Initial -c RuntimeElsaDbContext -o Migrations/Runtime -- "Server=localhost;Port=3306;Database=elsa;User=root;Password=password;" +dotnet ef migrations add Initial -c IdentityElsaDbContext -o Migrations/Identity -- "Server=localhost;Port=3306;Database=elsa;User=root;Password=password;" \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Elsa.EntityFrameworkCore.PostgreSql.csproj b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Elsa.EntityFrameworkCore.PostgreSql.csproj index a8f812743..8e61316aa 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Elsa.EntityFrameworkCore.PostgreSql.csproj +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Elsa.EntityFrameworkCore.PostgreSql.csproj @@ -22,9 +22,5 @@ - - - - diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230603165731_Initial.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230706133144_Initial.Designer.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230603165731_Initial.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230706133144_Initial.Designer.cs index 5fa1f8b15..f18b541c9 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230603165731_Initial.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230706133144_Initial.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Management { [DbContext(typeof(ManagementElsaDbContext))] - [Migration("20230603165731_Initial")] + [Migration("20230706133144_Initial")] partial class Initial { /// @@ -72,6 +72,9 @@ namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Management b.Property("StringData") .HasColumnType("text"); + b.Property("ToolVersion") + .HasColumnType("text"); + b.Property("UsableAsActivity") .HasColumnType("boolean"); diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230603165731_Initial.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230706133144_Initial.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230603165731_Initial.cs rename to src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230706133144_Initial.cs index 72e2ba7aa..678ca63ea 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230603165731_Initial.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/20230706133144_Initial.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using System; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable @@ -22,6 +23,7 @@ namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Management DefinitionId = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: true), Description = table.Column(type: "text", nullable: true), + ToolVersion = table.Column(type: "text", nullable: true), ProviderName = table.Column(type: "text", nullable: true), MaterializerName = table.Column(type: "text", nullable: false), MaterializerContext = table.Column(type: "text", nullable: true), diff --git a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs index 6c8b8a61c..0951e1394 100644 --- a/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.PostgreSql/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs @@ -69,6 +69,9 @@ namespace Elsa.EntityFrameworkCore.PostgreSql.Migrations.Management b.Property("StringData") .HasColumnType("text"); + b.Property("ToolVersion") + .HasColumnType("text"); + b.Property("UsableAsActivity") .HasColumnType("boolean"); diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Elsa.EntityFrameworkCore.SqlServer.csproj b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Elsa.EntityFrameworkCore.SqlServer.csproj index a4c673fb3..f87665590 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Elsa.EntityFrameworkCore.SqlServer.csproj +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Elsa.EntityFrameworkCore.SqlServer.csproj @@ -23,8 +23,4 @@ - - - - \ No newline at end of file diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230603165756_Initial.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230706133258_Initial.Designer.cs similarity index 97% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230603165756_Initial.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230706133258_Initial.Designer.cs index 647767e17..34a8d2061 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230603165756_Initial.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230706133258_Initial.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Management { [DbContext(typeof(ManagementElsaDbContext))] - [Migration("20230603165756_Initial")] + [Migration("20230706133258_Initial")] partial class Initial { /// @@ -72,6 +72,9 @@ namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Management b.Property("StringData") .HasColumnType("nvarchar(max)"); + b.Property("ToolVersion") + .HasColumnType("nvarchar(max)"); + b.Property("UsableAsActivity") .HasColumnType("bit"); diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230603165756_Initial.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230706133258_Initial.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230603165756_Initial.cs rename to src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230706133258_Initial.cs index b318c50cc..a04666826 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230603165756_Initial.cs +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/20230706133258_Initial.cs @@ -1,4 +1,5 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using System; +using Microsoft.EntityFrameworkCore.Migrations; #nullable disable @@ -22,6 +23,7 @@ namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Management DefinitionId = table.Column(type: "nvarchar(450)", nullable: false), Name = table.Column(type: "nvarchar(450)", nullable: true), Description = table.Column(type: "nvarchar(max)", nullable: true), + ToolVersion = table.Column(type: "nvarchar(max)", nullable: true), ProviderName = table.Column(type: "nvarchar(max)", nullable: true), MaterializerName = table.Column(type: "nvarchar(max)", nullable: false), MaterializerContext = table.Column(type: "nvarchar(max)", nullable: true), diff --git a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs index 3e600bea4..579afa71a 100644 --- a/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.SqlServer/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs @@ -69,6 +69,9 @@ namespace Elsa.EntityFrameworkCore.SqlServer.Migrations.Management b.Property("StringData") .HasColumnType("nvarchar(max)"); + b.Property("ToolVersion") + .HasColumnType("nvarchar(max)"); + b.Property("UsableAsActivity") .HasColumnType("bit"); diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Elsa.EntityFrameworkCore.Sqlite.csproj b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Elsa.EntityFrameworkCore.Sqlite.csproj index af79c2a2b..7e0c99b8d 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Elsa.EntityFrameworkCore.Sqlite.csproj +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Elsa.EntityFrameworkCore.Sqlite.csproj @@ -25,7 +25,6 @@ - diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230628212338_Initial.Designer.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230706133213_Initial.Designer.cs similarity index 97% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230628212338_Initial.Designer.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230706133213_Initial.Designer.cs index 40b924bd9..a25c86aa9 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230628212338_Initial.Designer.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230706133213_Initial.Designer.cs @@ -11,7 +11,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Management { [DbContext(typeof(ManagementElsaDbContext))] - [Migration("20230628212338_Initial")] + [Migration("20230706133213_Initial")] partial class Initial { /// @@ -67,6 +67,9 @@ namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Management b.Property("StringData") .HasColumnType("TEXT"); + b.Property("ToolVersion") + .HasColumnType("TEXT"); + b.Property("UsableAsActivity") .HasColumnType("INTEGER"); diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230628212338_Initial.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230706133213_Initial.cs similarity index 98% rename from src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230628212338_Initial.cs rename to src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230706133213_Initial.cs index 703320c88..77fb1a5e7 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230628212338_Initial.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/20230706133213_Initial.cs @@ -18,6 +18,7 @@ namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Management DefinitionId = table.Column(type: "TEXT", nullable: false), Name = table.Column(type: "TEXT", nullable: true), Description = table.Column(type: "TEXT", nullable: true), + ToolVersion = table.Column(type: "TEXT", nullable: true), ProviderName = table.Column(type: "TEXT", nullable: true), MaterializerName = table.Column(type: "TEXT", nullable: false), MaterializerContext = table.Column(type: "TEXT", nullable: true), diff --git a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs index 8beb9c1ea..e599fbaa8 100644 --- a/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs +++ b/src/modules/Elsa.EntityFrameworkCore.Sqlite/Migrations/Management/ManagementElsaDbContextModelSnapshot.cs @@ -64,6 +64,9 @@ namespace Elsa.EntityFrameworkCore.Sqlite.Migrations.Management b.Property("StringData") .HasColumnType("TEXT"); + b.Property("ToolVersion") + .HasColumnType("TEXT"); + b.Property("UsableAsActivity") .HasColumnType("INTEGER"); diff --git a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/Configurations.cs b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/Configurations.cs index a72603024..a9fdc122d 100644 --- a/src/modules/Elsa.EntityFrameworkCore/Modules/Management/Configurations.cs +++ b/src/modules/Elsa.EntityFrameworkCore/Modules/Management/Configurations.cs @@ -1,3 +1,4 @@ +using System.Linq.Expressions; using Elsa.Workflows.Core.Models; using Elsa.Workflows.Management.Entities; using Microsoft.EntityFrameworkCore; @@ -8,6 +9,9 @@ namespace Elsa.EntityFrameworkCore.Modules.Management; internal class Configurations : IEntityTypeConfiguration, IEntityTypeConfiguration { + private static Expression> VersionToStringConverter => v => v != null ? v.ToString() : null; + private static Expression> StringToVersionConverter => v => v != null ? Version.Parse(v) : null; + public void Configure(EntityTypeBuilder builder) { builder.Ignore(x => x.Variables); @@ -18,6 +22,7 @@ internal class Configurations : IEntityTypeConfiguration, IE builder.Ignore(x => x.Options); builder.Property("Data"); builder.Property("UsableAsActivity"); + builder.Property(x => x.ToolVersion).HasConversion(VersionToStringConverter, StringToVersionConverter); builder.HasIndex(x => new {x.DefinitionId, x.Version}).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.DefinitionId)}_{nameof(WorkflowDefinition.Version)}").IsUnique(); builder.HasIndex(x => x.Version).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.Version)}"); diff --git a/src/modules/Elsa.MongoDb/Extensions/DocumentExtensions.cs b/src/modules/Elsa.MongoDb/Extensions/DocumentExtensions.cs index 9ded09974..47ef99c61 100644 --- a/src/modules/Elsa.MongoDb/Extensions/DocumentExtensions.cs +++ b/src/modules/Elsa.MongoDb/Extensions/DocumentExtensions.cs @@ -3,8 +3,20 @@ using MongoDB.Driver; namespace Elsa.MongoDb.Extensions; +/// +/// Provides extension methods for building expressions. +/// public static class DocumentExtensions { + /// + /// Builds a filter expression for the specified property name. + /// + /// The document. + /// The property selector. + /// The type of the document. + /// The type of the property. + /// The document is null. + /// The selector is not a member expression. public static Expression> BuildExpression(this TDocument document, Expression> selector) { if (document == null) throw new ArgumentNullException(nameof(document)); @@ -18,9 +30,20 @@ public static class DocumentExtensions return document.BuildFilter(propertyName); } + /// + /// Builds a filter expression for the Id property. + /// + /// The document. + /// The type of the document. public static Expression> BuildIdFilter(this TDocument document) => document.BuildFilter("Id"); + /// + /// Builds a filter expression for the Id property name of the specified documents. + /// + /// The documents. + /// The type of the document. + /// The type does not have an Id property. public static FilterDefinition BuildIdFilterForList(this IEnumerable documents) { var propertyName = "Id"; diff --git a/src/modules/Elsa.MongoDb/Features/MongoDbFeature.cs b/src/modules/Elsa.MongoDb/Features/MongoDbFeature.cs index 2aa00260d..8554eea66 100644 --- a/src/modules/Elsa.MongoDb/Features/MongoDbFeature.cs +++ b/src/modules/Elsa.MongoDb/Features/MongoDbFeature.cs @@ -6,6 +6,7 @@ using Elsa.Workflows.Core.Models; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using MongoDB.Bson.Serialization; +using MongoDB.Bson.Serialization.Serializers; using MongoDB.Driver; using MongoDB.Driver.Core.Extensions.DiagnosticSources; @@ -46,6 +47,7 @@ public class MongoDbFeature : FeatureBase BsonSerializer.RegisterSerializer(typeof(object), new PolymorphicSerializer()); BsonSerializer.RegisterSerializer(typeof(Type), new TypeSerializer()); BsonSerializer.RegisterSerializer(typeof(Variable), new VariableSerializer()); + BsonSerializer.RegisterSerializer(typeof(Version), new VersionSerializer()); } private static IMongoDatabase CreateDatabase(IServiceProvider sp, string connectionString) diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Export/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Export/Endpoint.cs index 31f66e0d0..98a24e96d 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Export/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Export/Endpoint.cs @@ -63,6 +63,7 @@ public class Export : ElsaEndpoint definition.Description, definition.CreatedAt, definition.Version, + definition.ToolVersion, variables, definition.Inputs, definition.Outputs, diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Post/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Post/Endpoint.cs index 3d887de3d..fd2fdc273 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Post/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Post/Endpoint.cs @@ -83,6 +83,7 @@ internal class Post : ElsaEndpoint(); draft.Variables = variables; diff --git a/src/modules/Elsa.Workflows.Core/Models/WorkflowMetadata.cs b/src/modules/Elsa.Workflows.Core/Models/WorkflowMetadata.cs index 713073499..a7f2ae0eb 100644 --- a/src/modules/Elsa.Workflows.Core/Models/WorkflowMetadata.cs +++ b/src/modules/Elsa.Workflows.Core/Models/WorkflowMetadata.cs @@ -1,5 +1,12 @@ namespace Elsa.Workflows.Core.Models; -public record WorkflowMetadata(string? Name = default, string? Description = default, DateTimeOffset CreatedAt = default) +/// +/// Represents metadata about a workflow. +/// +/// The name of the workflow. +/// The description of the workflow. +/// The date and time the workflow was created. +/// The version of the tool that created the workflow. +public record WorkflowMetadata(string? Name = default, string? Description = default, DateTimeOffset CreatedAt = default, Version? ToolVersion = default) { } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Management/Entities/WorkflowDefinition.cs b/src/modules/Elsa.Workflows.Management/Entities/WorkflowDefinition.cs index 02f243094..ad6fcc8c2 100644 --- a/src/modules/Elsa.Workflows.Management/Entities/WorkflowDefinition.cs +++ b/src/modules/Elsa.Workflows.Management/Entities/WorkflowDefinition.cs @@ -19,10 +19,15 @@ public class WorkflowDefinition : VersionedEntity public string? Name { get; set; } /// - /// A short description of that the workflow is about. + /// A short description of what the workflow is about. /// public string? Description { get; set; } + /// + /// The version of the tool that created this workflow. + /// + public Version? ToolVersion { get; set; } + /// /// A set of options for the workflow. /// diff --git a/src/modules/Elsa.Workflows.Management/Mappers/WorkflowDefinitionMapper.cs b/src/modules/Elsa.Workflows.Management/Mappers/WorkflowDefinitionMapper.cs index 1081a0d23..3c65709a9 100644 --- a/src/modules/Elsa.Workflows.Management/Mappers/WorkflowDefinitionMapper.cs +++ b/src/modules/Elsa.Workflows.Management/Mappers/WorkflowDefinitionMapper.cs @@ -60,12 +60,15 @@ public class WorkflowDefinitionMapper var options = source.Options ?? new WorkflowOptions(); // TODO: Remove this in the future when users have migrated workflows to use the new UsableAsActivity options property. + +#pragma warning disable CS0618 options.UsableAsActivity ??= source.UsableAsActivity ?? false; +#pragma warning restore CS0618 return new( new WorkflowIdentity(source.DefinitionId, source.Version, source.Id), new WorkflowPublication(source.IsLatest, source.IsPublished), - new WorkflowMetadata(source.Name, source.Description, source.CreatedAt), + new WorkflowMetadata(source.Name, source.Description, source.CreatedAt, source.ToolVersion), options, root, variables, @@ -94,6 +97,7 @@ public class WorkflowDefinitionMapper workflowDefinition.Description, workflowDefinition.CreatedAt, workflowDefinition.Version, + workflowDefinition.ToolVersion, variables, workflowDefinition.Inputs, workflowDefinition.Outputs, diff --git a/src/modules/Elsa.Workflows.Management/Models/WorkflowDefinitionModel.cs b/src/modules/Elsa.Workflows.Management/Models/WorkflowDefinitionModel.cs index 2835e526e..788e18797 100644 --- a/src/modules/Elsa.Workflows.Management/Models/WorkflowDefinitionModel.cs +++ b/src/modules/Elsa.Workflows.Management/Models/WorkflowDefinitionModel.cs @@ -32,6 +32,7 @@ public record WorkflowDefinitionModel( string? Description, DateTimeOffset CreatedAt, int Version, + Version? ToolVersion, ICollection? Variables, ICollection? Inputs, ICollection? Outputs, @@ -64,6 +65,7 @@ public record WorkflowDefinitionModel( default!, default!, default!, + default!, default!) { }