diff --git a/app/src/Passingwind.WorkflowApp.Web/WorkflowAppWebModule.cs b/app/src/Passingwind.WorkflowApp.Web/WorkflowAppWebModule.cs index 927924d..529ad65 100644 --- a/app/src/Passingwind.WorkflowApp.Web/WorkflowAppWebModule.cs +++ b/app/src/Passingwind.WorkflowApp.Web/WorkflowAppWebModule.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Elsa; using Elsa.Activities.Http.OpenApi; @@ -129,6 +130,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) Configure(options => { + options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Default; options.JsonSerializerOptions.Converters.Add(new TypeJsonConverter()); options.JsonSerializerOptions.Converters.Add(new JObjectConverter()); options.JsonSerializerOptions.Converters.Add(new JArrayConverter()); @@ -136,11 +138,12 @@ public override void ConfigureServices(ServiceConfigurationContext context) Configure(options => { + options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Default; options.JsonSerializerOptions.Converters.Add(new TypeJsonConverter()); options.JsonSerializerOptions.Converters.Add(new JArrayConverter()); options.JsonSerializerOptions.Converters.Add(new JObjectConverter()); }); - + // Config default 'JsonSerializerSettings' JsonConvert.DefaultSettings = () => { @@ -395,7 +398,7 @@ private void ConfigureSwaggerServices(IServiceCollection services) return $"{part1}.{part2}"; } - return type.FullName.RemovePostFix("Dto"); + return type.FullName.RemovePostFix("Dto").Replace("Dto+", null); }); options.CustomOperationIds(e => diff --git a/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/IWorkflowDefinitionAppService.cs b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/IWorkflowDefinitionAppService.cs index a62b048..43e12bc 100644 --- a/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/IWorkflowDefinitionAppService.cs +++ b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/IWorkflowDefinitionAppService.cs @@ -2,10 +2,11 @@ using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; +using Volo.Abp.Content; namespace Passingwind.Abp.ElsaModule.WorkflowDefinitions; -public interface IWorkflowDefinitionAppService : ICrudAppService +public interface IWorkflowDefinitionAppService : ICrudAppService { Task> GetVersionsAsync(Guid id, WorkflowDefinitionVersionListRequestDto input); Task DeleteVersionAsync(Guid id, int version); @@ -32,4 +33,8 @@ public interface IWorkflowDefinitionAppService : ICrudAppService ExportAsync(WorkflowDefinitionExportRequestDto input); + Task ImportAsync(WorkflowDefinitionImportRequestDto input); + } diff --git a/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionBasicDto.cs b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionBasicDto.cs new file mode 100644 index 0000000..1323f56 --- /dev/null +++ b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionBasicDto.cs @@ -0,0 +1,28 @@ +using System; +using Elsa.Models; +using Volo.Abp.Application.Dtos; + +namespace Passingwind.Abp.ElsaModule.WorkflowDefinitions; + +public class WorkflowDefinitionBasicDto : AuditedEntityDto +{ + public string Name { get; set; } + + public string DisplayName { get; set; } + + public string Description { get; set; } + + public int LatestVersion { get; set; } + + public int? PublishedVersion { get; set; } + + public bool IsSingleton { get; set; } + + public bool DeleteCompletedInstances { get; set; } + + public string Channel { get; set; } + + public string Tag { get; set; } + + public WorkflowPersistenceBehavior PersistenceBehavior { get; set; } +} diff --git a/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionDto.cs b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionDto.cs index 3cdbd5c..3f936a7 100644 --- a/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionDto.cs +++ b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionDto.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Elsa.Models; using Volo.Abp.Application.Dtos; @@ -11,8 +11,6 @@ public class WorkflowDefinitionDto : AuditedEntityDto public string DisplayName { get; set; } - public Guid? TenantId { get; protected set; } - public string Description { get; set; } public int LatestVersion { get; set; } diff --git a/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionExportRequestDto.cs b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionExportRequestDto.cs new file mode 100644 index 0000000..304dc50 --- /dev/null +++ b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionExportRequestDto.cs @@ -0,0 +1,9 @@ +using System; + +namespace Passingwind.Abp.ElsaModule.WorkflowDefinitions; + +public class WorkflowDefinitionExportRequestDto +{ + public Guid[] Ids { get; set; } + //public string Format { get; set; } +} diff --git a/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionImportRequestDto.cs b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionImportRequestDto.cs new file mode 100644 index 0000000..d78caef --- /dev/null +++ b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionImportRequestDto.cs @@ -0,0 +1,12 @@ +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Content; + +namespace Passingwind.Abp.ElsaModule.WorkflowDefinitions; + +public class WorkflowDefinitionImportRequestDto +{ + [Required] + public IRemoteStreamContent File { get; set; } + + public bool Overwrite { get; set; } +} diff --git a/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionImportResultDto.cs b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionImportResultDto.cs new file mode 100644 index 0000000..9034473 --- /dev/null +++ b/src/Passingwind.Abp.ElsaModule.Application.Contracts/WorkflowDefinitions/WorkflowDefinitionImportResultDto.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; + +namespace Passingwind.Abp.ElsaModule.WorkflowDefinitions; + +public class WorkflowDefinitionImportResultDto +{ + public int TotalCount { get; set; } + public int SuccessCount { get; set; } + public int FailedCount { get; set; } + + public List Results { get; set; } + + public class WorkflowImportResult + { + public string FileName { get; set; } + public bool HasError { get; set; } + public string ErrorMessage { get; set; } + public WorkflowDefinitionBasicDto Workflow { get; set; } + } + + public WorkflowDefinitionImportResultDto() + { + Results = new List(); + } + + public void Add(string fileName, WorkflowDefinitionBasicDto workflow) + { + Results.Add(new WorkflowImportResult + { + Workflow = workflow, + HasError = false, + FileName = fileName, + }); + } + + public void Add(string fileName, string errorMessage) + { + Results.Add(new WorkflowImportResult + { + HasError = true, + ErrorMessage = errorMessage, + FileName = fileName, + }); + } +} diff --git a/src/Passingwind.Abp.ElsaModule.Application/ElsaModuleAppService.cs b/src/Passingwind.Abp.ElsaModule.Application/ElsaModuleAppService.cs index 8a724b8..59c226c 100644 --- a/src/Passingwind.Abp.ElsaModule.Application/ElsaModuleAppService.cs +++ b/src/Passingwind.Abp.ElsaModule.Application/ElsaModuleAppService.cs @@ -1,13 +1,19 @@ -using System; +using System; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; using Passingwind.Abp.ElsaModule.Common; using Passingwind.Abp.ElsaModule.Localization; +using Passingwind.Abp.ElsaModule.Permissions; using Volo.Abp.Application.Services; namespace Passingwind.Abp.ElsaModule; public abstract class ElsaModuleAppService : ApplicationService { + protected IWorkflowPermissionService WorkflowPermissionService => LazyServiceProvider.GetRequiredService(); + protected ElsaModuleAppService() { LocalizationResource = typeof(ElsaModuleResource); @@ -36,4 +42,25 @@ protected virtual async Task CheckWorkflowPermissionAsync(WorkflowDefinition def { await AuthorizationService.CheckAsync(definition, name); } + + protected async Task> FilterWorkflowsAsync(IEnumerable sources = null) + { + var grantedResult = await WorkflowPermissionService.GetGrantsAsync(); + + var filterIds = sources?.ToList(); + + if (!grantedResult.AllGranted) + { + if (sources?.Any() == true) + { + filterIds = grantedResult.WorkflowIds.Intersect(sources).ToList(); + } + else + { + filterIds = grantedResult.WorkflowIds.ToList(); + } + } + + return filterIds; + } } diff --git a/src/Passingwind.Abp.ElsaModule.Application/ElsaModuleApplicationAutoMapperProfile.cs b/src/Passingwind.Abp.ElsaModule.Application/ElsaModuleApplicationAutoMapperProfile.cs index e185def..ca02e0c 100644 --- a/src/Passingwind.Abp.ElsaModule.Application/ElsaModuleApplicationAutoMapperProfile.cs +++ b/src/Passingwind.Abp.ElsaModule.Application/ElsaModuleApplicationAutoMapperProfile.cs @@ -19,45 +19,12 @@ public ElsaModuleApplicationAutoMapperProfile() * Alternatively, you can split your mapping configurations * into multiple profile classes for a better organization. */ - //CreateMap() - // .Ignore(x => x.TenantId) - // .Ignore(x => x.LatestVersion) - // .Ignore(x => x.PublishedVersion) - // .Ignore(x => x.Id) - // .Ignore(x => x.ContextOptions) - // .Ignore(x => x.CustomAttributes) - // .Ignore(x => x.Variables) - // .Ignore(x => x.ConcurrencyStamp) - // .Ignore(x => x.ExtraProperties) - // .IgnoreFullAuditedObjectProperties(); - - //CreateMap() - // .Ignore(x => x.TenantId) - // //.Ignore(x => x.Definition) - // .Ignore(x => x.DefinitionId) - // .Ignore(x => x.Id) - // .Ignore(x => x.IsLatest) - // //.Ignore(x => x.IsPublished) - // .Ignore(x => x.Version) - // .IgnoreFullAuditedObjectProperties(); - - CreateMap(); CreateMap(); + CreateMap(); + CreateMap(); CreateMap() .Ignore(x => x.Definition); - //CreateMap() - // .Ignore(x => x.WorkflowDefinitionVersionId) - // .IgnoreAuditedObjectProperties(); - - //CreateMap() - // .Ignore(x => x.WorkflowDefinitionVersionId) - // .IgnoreCreationAuditedObjectProperties(); - - //CreateMap() - // .Ignore(x => x.WorkflowDefinitionVersionId) - // .IgnoreCreationAuditedObjectProperties(); - CreateMap(); CreateMap(); diff --git a/src/Passingwind.Abp.ElsaModule.Application/Passingwind.Abp.ElsaModule.Application.csproj b/src/Passingwind.Abp.ElsaModule.Application/Passingwind.Abp.ElsaModule.Application.csproj index e6c0d8d..c037df1 100644 --- a/src/Passingwind.Abp.ElsaModule.Application/Passingwind.Abp.ElsaModule.Application.csproj +++ b/src/Passingwind.Abp.ElsaModule.Application/Passingwind.Abp.ElsaModule.Application.csproj @@ -1,4 +1,4 @@ - + @@ -11,7 +11,7 @@ - + diff --git a/src/Passingwind.Abp.ElsaModule.Application/WorkflowDefinitions/WorkflowDefinitionAppService.cs b/src/Passingwind.Abp.ElsaModule.Application/WorkflowDefinitions/WorkflowDefinitionAppService.cs index 947ddc2..c0feef8 100644 --- a/src/Passingwind.Abp.ElsaModule.Application/WorkflowDefinitions/WorkflowDefinitionAppService.cs +++ b/src/Passingwind.Abp.ElsaModule.Application/WorkflowDefinitions/WorkflowDefinitionAppService.cs @@ -1,16 +1,22 @@ using System; using System.Collections.Generic; +using System.IO; +using System.IO.Compression; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Elsa.Models; using Elsa.Services; using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Logging; using Passingwind.Abp.ElsaModule.Permissions; using Passingwind.Abp.ElsaModule.WorkflowDefinitions; using Passingwind.Abp.ElsaModule.WorkflowGroups; using Volo.Abp; using Volo.Abp.Application.Dtos; +using Volo.Abp.Content; using Volo.Abp.Identity; +using Volo.Abp.Json; namespace Passingwind.Abp.ElsaModule.Common; @@ -24,6 +30,8 @@ public class WorkflowDefinitionAppService : ElsaModuleAppService, IWorkflowDefin private readonly IWorkflowPermissionService _workflowPermissionService; private readonly IWorkflowGroupManager _workflowGroupManager; private readonly IdentityUserManager _identityUserManager; + private readonly IJsonSerializer _jsonSerializer; + private readonly IWorkflowImporter _workflowImporter; public WorkflowDefinitionAppService( IWorkflowDefinitionRepository workflowDefinitionRepository, @@ -32,7 +40,9 @@ public WorkflowDefinitionAppService( IWorkflowLaunchpad workflowLaunchpad, IWorkflowPermissionService workflowPermissionService, IWorkflowGroupManager workflowGroupManager, - IdentityUserManager identityUserManager) + IdentityUserManager identityUserManager, + IJsonSerializer jsonSerializer, + IWorkflowImporter workflowImporter) { _workflowDefinitionRepository = workflowDefinitionRepository; _workflowDefinitionVersionRepository = workflowDefinitionVersionRepository; @@ -41,6 +51,8 @@ public WorkflowDefinitionAppService( _workflowPermissionService = workflowPermissionService; _workflowGroupManager = workflowGroupManager; _identityUserManager = identityUserManager; + _jsonSerializer = jsonSerializer; + _workflowImporter = workflowImporter; } [Authorize(Policy = ElsaModulePermissions.Definitions.CreateOrUpdateOrPublish)] @@ -142,7 +154,7 @@ public virtual async Task GetDefinitionAsync(Guid id) return ObjectMapper.Map(entity); } - public virtual async Task> GetListAsync(WorkflowDefinitionListRequestDto input) + public virtual async Task> GetListAsync(WorkflowDefinitionListRequestDto input) { var grantedResult = await _workflowPermissionService.GetGrantsAsync(); @@ -158,7 +170,7 @@ public virtual async Task> GetListAsync(Wo filterIds: grantedResult.AllGranted ? null : grantedResult.WorkflowIds, ordering: input.Sorting); - return new PagedResultDto(count, ObjectMapper.Map, List>(list)); + return new PagedResultDto(count, ObjectMapper.Map, List>(list)); } public virtual async Task GetVersionAsync(Guid id, int version) @@ -215,6 +227,25 @@ public virtual async Task UpdateAsync(Guid id, Wor if (input.IsPublished) await _workflowDefinitionManager.UnsetPublishedVersionAsync(id); + var activities = input.Activities?.Select(x => new Activity( + x.ActivityId, + x.Type, + x.Name, + x.DisplayName, + x.Description, + x.PersistWorkflow, + x.LoadWorkflowContext, + x.SaveWorkflowContext, + x.Attributes, + x.Properties, + x.PropertyStorageProviders))?.ToList(); + + var connections = input.Connections.Select(x => new ActivityConnection( + x.SourceId, + x.TargetId, + x.Outcome, + x.Attributes))?.ToList(); + // check version if (defintion.PublishedVersion == defintion.LatestVersion) { @@ -223,23 +254,8 @@ public virtual async Task UpdateAsync(Guid id, Wor currentVersion = await _workflowDefinitionManager.CreateDefinitionVersionAsync( id, CurrentTenant.Id, - input.Activities?.Select(x => new Activity( - x.ActivityId, - x.Type, - x.Name, - x.DisplayName, - x.Description, - x.PersistWorkflow, - x.LoadWorkflowContext, - x.SaveWorkflowContext, - x.Attributes, - x.Properties, - x.PropertyStorageProviders))?.ToList(), - input.Connections.Select(x => new ActivityConnection( - x.SourceId, - x.TargetId, - x.Outcome, - x.Attributes))?.ToList()); + activities, + connections); currentVersion.SetVersion(defintion.LatestVersion + 1); currentVersion.SetIsLatest(true); @@ -258,23 +274,10 @@ public virtual async Task UpdateAsync(Guid id, Wor if (currentVersion == null) throw new UserFriendlyException($"The latest versiont '{defintion.LatestVersion}' not found."); - await _workflowDefinitionManager.UpdateDefinitionVersionAsync(currentVersion, input.Activities?.Select(x => new Activity( - x.ActivityId, - x.Type, - x.Name, - x.DisplayName, - x.Description, - x.PersistWorkflow, - x.LoadWorkflowContext, - x.SaveWorkflowContext, - x.Attributes, - x.Properties, - x.PropertyStorageProviders))?.ToList(), - input.Connections.Select(x => new ActivityConnection( - x.SourceId, - x.TargetId, - x.Outcome, - x.Attributes))?.ToList()); + await _workflowDefinitionManager.UpdateDefinitionVersionAsync( + currentVersion, + activities, + connections); if (input.IsPublished) currentVersion.SetIsPublished(true); @@ -289,21 +292,27 @@ public virtual async Task UpdateAsync(Guid id, Wor else defintion.SetLatestVersion(currentVersion.Version); - // update - defintion.Name = input.Definition.Name; - defintion.DisplayName = input.Definition.DisplayName; - defintion.Description = input.Definition.Description; - defintion.IsSingleton = input.Definition.IsSingleton; - defintion.Channel = input.Definition.Channel; - defintion.Tag = input.Definition.Tag; - defintion.PersistenceBehavior = input.Definition.PersistenceBehavior; - defintion.ContextOptions = input.Definition.ContextOptions; - defintion.Variables = input.Definition.Variables; - await _workflowDefinitionRepository.UpdateAsync(defintion); + // update + defintion.ChangeName(input.Definition.Name); + await _workflowDefinitionManager.UpdateDefinitionAsync( + defintion, + input.Definition.DisplayName, + input.Definition.Description, + input.Definition.IsSingleton, + input.Definition.DeleteCompletedInstances, + input.Definition.Channel, + input.Definition.Tag, + input.Definition.PersistenceBehavior, + input.Definition.ContextOptions, + input.Definition.Variables, + defintion.CustomAttributes); // check name await _workflowDefinitionManager.CheckNameExistsAsync(defintion); + // update + await _workflowDefinitionRepository.UpdateAsync(defintion); + var dto = ObjectMapper.Map(currentVersion); dto.Definition = ObjectMapper.Map(defintion); return dto; @@ -315,19 +324,24 @@ public virtual async Task UpdateDefinitionAsync(Guid id, await CheckWorkflowPermissionAsync(entity, ElsaModulePermissions.Definitions.CreateOrUpdateOrPublish); - entity.Name = input.Name; - entity.DisplayName = input.DisplayName; - entity.Description = input.Description; - entity.IsSingleton = input.IsSingleton; - entity.Channel = input.Channel; - entity.Tag = input.Tag; - entity.PersistenceBehavior = input.PersistenceBehavior; - entity.ContextOptions = input.ContextOptions; - entity.Variables = input.Variables; + entity.ChangeName(input.Name); + await _workflowDefinitionManager.UpdateDefinitionAsync( + entity, + input.DisplayName, + input.Description, + input.IsSingleton, + input.DeleteCompletedInstances, + input.Channel, + input.Tag, + input.PersistenceBehavior, + input.ContextOptions, + input.Variables, + entity.CustomAttributes); // check name await _workflowDefinitionManager.CheckNameExistsAsync(entity); + // update await _workflowDefinitionRepository.UpdateAsync(entity); return ObjectMapper.Map(entity); @@ -484,4 +498,139 @@ public async Task UpdateVariablesAsync(Guid id, WorkflowVa Variables = entity.Variables, }; } + + [Authorize(Policy = ElsaModulePermissions.Definitions.Export)] + public async Task ExportAsync(WorkflowDefinitionExportRequestDto input) + { + var filterIds = await FilterWorkflowsAsync(input.Ids); + + var list = await _workflowDefinitionRepository.GetListAsync(filterIds: filterIds); + + var versionList = await _workflowDefinitionVersionRepository.GetListAsync(definitionIds: filterIds, isPublished: true, includeDetails: true); + + var randomName = Path.GetFileNameWithoutExtension(Path.GetTempFileName()); + var zipFilePath = Path.Combine(Path.GetTempPath(), "workflow", "export", $"{randomName}.zip"); + // create directory + var exportTempDir = Path.Combine(Path.GetTempPath(), "workflow", "export", randomName); + if (!Directory.Exists(exportTempDir)) + Directory.CreateDirectory(exportTempDir); + + var jsonNodeOptions = new JsonNodeOptions() { PropertyNameCaseInsensitive = true }; + + try + { + // write file + foreach (var item in list) + { + var version = versionList.FirstOrDefault(x => x.DefinitionId == item.Id); + + var content = _jsonSerializer.Serialize(item); + + if (version != null) + { + var jsonObject = JsonObject.Parse(content, jsonNodeOptions); + jsonObject["activities"] = JsonNode.Parse(_jsonSerializer.Serialize(version.Activities), jsonNodeOptions); + jsonObject["connections"] = JsonNode.Parse(_jsonSerializer.Serialize(version.Connections), jsonNodeOptions); + + content = jsonObject.ToJsonString(); + } + + var itemFile = Path.Combine(exportTempDir, item.Name + ".json"); + File.WriteAllText(itemFile, content); + } + + ZipFile.CreateFromDirectory(exportTempDir, zipFilePath); + + Logger.LogInformation("Workflow definition export zip file created: {0}", zipFilePath); + + return new RemoteStreamContent(File.OpenRead(zipFilePath), $"{DateTime.UtcNow:yyyyMMddHHmmss}.zip", "application/stream"); + } + catch (Exception ex) + { + throw new UserFriendlyException("Export workflow definition failed.", innerException: ex); + } + } + + [Authorize(Policy = ElsaModulePermissions.Definitions.Import)] + public async Task ImportAsync(WorkflowDefinitionImportRequestDto input) + { + if (input.File?.ContentLength == 0) + throw new ArgumentNullException(); + + var randomName = Path.GetFileNameWithoutExtension(Path.GetTempFileName()); + var zipFilePath = Path.Combine(Path.GetTempPath(), "workflow", "import", $"{randomName}.zip"); + var tempFileDir = Path.Combine(Path.GetTempPath(), "workflow", "import", randomName); + if (!Directory.Exists(Path.GetDirectoryName(zipFilePath))) + Directory.CreateDirectory(Path.GetDirectoryName(zipFilePath)); + + bool isZip = false; + + if (Path.GetExtension(input.File.FileName) == ".zip" || input.File.ContentType == "application/zip") + isZip = true; + + var importList = new Dictionary(); + + if (isZip) + { + // extract zip file + try + { + using MemoryStream ms = new MemoryStream(); + + await input.File.GetStream().CopyToAsync(ms); + + await File.WriteAllBytesAsync(zipFilePath, ms.ToArray()); + + ZipFile.ExtractToDirectory(zipFilePath, tempFileDir, true); + } + catch (Exception ex) + { + throw new UserFriendlyException("Unzip file failed.", innerException: ex); + } + + // read files + foreach (var item in Directory.EnumerateFiles(tempFileDir)) + { + importList[Path.GetFileName(item)] = File.ReadAllText(item); + } + } + else + { + try + { + using StreamReader sr = new StreamReader(input.File.GetStream()); + var fileContent = await sr.ReadToEndAsync(); + + importList[input.File.FileName] = fileContent; + } + catch (Exception ex) + { + throw new UserFriendlyException("Read upload file content failed.", innerException: ex); + } + } + + var result = new WorkflowDefinitionImportResultDto() + { + TotalCount = importList.Count, + }; + + foreach (var item in importList) + { + try + { + var workflow = await _workflowImporter.ImportAsync(item.Value, input.Overwrite); + + result.Add(item.Key, ObjectMapper.Map(workflow)); + + result.SuccessCount++; + } + catch (Exception ex) + { + result.FailedCount++; + result.Add(item.Key, ex.Message); + } + } + + return result; + } } diff --git a/src/Passingwind.Abp.ElsaModule.Domain/Common/IWorkflowDefinitionVersionRepository.cs b/src/Passingwind.Abp.ElsaModule.Domain/Common/IWorkflowDefinitionVersionRepository.cs index 9439890..f01a819 100644 --- a/src/Passingwind.Abp.ElsaModule.Domain/Common/IWorkflowDefinitionVersionRepository.cs +++ b/src/Passingwind.Abp.ElsaModule.Domain/Common/IWorkflowDefinitionVersionRepository.cs @@ -13,6 +13,8 @@ public interface IWorkflowDefinitionVersionRepository : IRepository> GetPagedListAsync(int skipCount, int maxResultCount, Expression> expression, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default); + Task> GetListAsync(IEnumerable definitionIds = null, bool? isLatest = null, bool? isPublished = null, bool includeDetails = false, CancellationToken cancellationToken = default); + Task GetLatestAsync(Guid definitionId, bool includeDetails = true, CancellationToken cancellationToken = default); Task GetByVersionAsync(Guid definitionId, int version, bool includeDetails = true, CancellationToken cancellationToken = default); @@ -21,4 +23,3 @@ public interface IWorkflowDefinitionVersionRepository : IRepository GetPreviousVersionNumberAsync(Guid definitionId, int version, CancellationToken cancellationToken = default); } - diff --git a/src/Passingwind.Abp.ElsaModule.Domain/Common/IWorkflowImporter.cs b/src/Passingwind.Abp.ElsaModule.Domain/Common/IWorkflowImporter.cs new file mode 100644 index 0000000..490243a --- /dev/null +++ b/src/Passingwind.Abp.ElsaModule.Domain/Common/IWorkflowImporter.cs @@ -0,0 +1,10 @@ +using System.Threading; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; + +namespace Passingwind.Abp.ElsaModule.Common; + +public interface IWorkflowImporter : ITransientDependency +{ + Task ImportAsync(string jsonContent, bool overwrite = false, CancellationToken cancellationToken = default); +} diff --git a/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowDefinition.cs b/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowDefinition.cs index 6dcd903..b45b4c3 100644 --- a/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowDefinition.cs +++ b/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowDefinition.cs @@ -1,5 +1,6 @@ -using System; +using System; using System.Collections.Generic; +using System.Text.Json.Serialization; using Elsa.Models; using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.MultiTenancy; @@ -14,9 +15,9 @@ protected WorkflowDefinition() CustomAttributes = new Dictionary(); } + [JsonConstructor] public WorkflowDefinition(Guid id) : base(id) { - } public WorkflowDefinition(Guid id, string name, string displayName, Guid? tenantId, string description, bool isSingleton, bool deleteCompletedInstances, string channel, string tag, WorkflowPersistenceBehavior persistenceBehavior, WorkflowContextOptions contextOptions, Dictionary variables, Dictionary customAttributes) : base(id) @@ -35,11 +36,19 @@ public WorkflowDefinition(Guid id, string name, string displayName, Guid? tenant CustomAttributes = customAttributes ?? new Dictionary(); } - public string Name { get; set; } + public WorkflowDefinition(Guid id, string name, Guid? tenantId) : base(id) + { + Name = name; + TenantId = tenantId; + Variables = new Dictionary(); + CustomAttributes = new Dictionary(); + } + + public string Name { get; protected set; } public string DisplayName { get; set; } - public Guid? TenantId { get; protected set; } + public Guid? TenantId { get; set; } public string Description { get; set; } @@ -79,4 +88,8 @@ public void SetPublishedVersion(int? version) PublishedVersion = version; } + public void ChangeName(string name) + { + Name = name; + } } diff --git a/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowDefinitionManager.cs b/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowDefinitionManager.cs index e7c864e..0f82cfa 100644 --- a/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowDefinitionManager.cs +++ b/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowDefinitionManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; using Elsa.Models; @@ -29,18 +29,56 @@ public virtual async Task CheckNameExistsAsync(WorkflowDefinition entity) public virtual Task CreateDefinitionAsync(string name, string displayName, Guid? tenantId, string description, bool isSingleton, bool deleteCompletedInstances, string channel, string tag, WorkflowPersistenceBehavior persistenceBehavior, WorkflowContextOptions contextOptions, Dictionary variables, Dictionary customAttributes) { - var definition = new WorkflowDefinition(GuidGenerator.Create(), name, displayName, tenantId, description, isSingleton, deleteCompletedInstances, channel, tag, persistenceBehavior, contextOptions, variables, customAttributes); + if (string.IsNullOrWhiteSpace(name)) + { + throw new ArgumentException($"'{nameof(name)}' cannot be null or whitespace.", nameof(name)); + } + + var definition = new WorkflowDefinition(GuidGenerator.Create(), name, displayName ?? name, tenantId, description, isSingleton, deleteCompletedInstances, channel, tag, persistenceBehavior, contextOptions, variables, customAttributes); return Task.FromResult(definition); } public virtual Task CreateDefinitionVersionAsync(Guid definitionId, Guid? tenantId, List activities, List connections) { + if (activities == null) + throw new ArgumentNullException(nameof(activities)); + var entity = new WorkflowDefinitionVersion(definitionId, tenantId, activities, connections); return Task.FromResult(entity); } + public virtual Task UpdateDefinitionAsync( + WorkflowDefinition entity, + string displayName, + string description, + bool isSingleton, + bool deleteCompletedInstances, + string channel, + string tag, + WorkflowPersistenceBehavior persistenceBehavior, + WorkflowContextOptions contextOptions, + Dictionary variables, + Dictionary customAttributes) + { + if (entity == null) + throw new ArgumentNullException(nameof(entity)); + + entity.DisplayName = displayName; + entity.Channel = channel; + entity.Description = description; + entity.IsSingleton = isSingleton; + entity.DeleteCompletedInstances = deleteCompletedInstances; + entity.Tag = tag; + entity.PersistenceBehavior = persistenceBehavior; + entity.ContextOptions = contextOptions; + entity.Variables = variables; + entity.CustomAttributes = customAttributes; + + return Task.CompletedTask; + } + public virtual Task UpdateDefinitionVersionAsync(WorkflowDefinitionVersion entity, List activities, List connections) { entity.Activities = activities; diff --git a/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowImporter.cs b/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowImporter.cs new file mode 100644 index 0000000..6ccb450 --- /dev/null +++ b/src/Passingwind.Abp.ElsaModule.Domain/Common/WorkflowImporter.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Threading; +using System.Threading.Tasks; +using Passingwind.Abp.ElsaModule.Permissions; +using Volo.Abp.Guids; +using Volo.Abp.MultiTenancy; + +namespace Passingwind.Abp.ElsaModule.Common; + +public class WorkflowImporter : IWorkflowImporter +{ + private readonly IGuidGenerator _guidGenerator; + private readonly ICurrentTenant _currentTenant; + private readonly WorkflowDefinitionManager _workflowDefinitionManager; + private readonly IWorkflowDefinitionRepository _workflowDefinitionRepository; + private readonly IWorkflowDefinitionVersionRepository _workflowDefinitionVersionRepository; + private readonly IWorkflowPermissionService _workflowPermissionService; + + public WorkflowImporter( + IGuidGenerator guidGenerator, + ICurrentTenant currentTenant, + WorkflowDefinitionManager workflowDefinitionManager, + IWorkflowDefinitionRepository workflowDefinitionRepository, + IWorkflowDefinitionVersionRepository workflowDefinitionVersionRepository, + IWorkflowPermissionService workflowPermissionService) + { + _guidGenerator = guidGenerator; + _currentTenant = currentTenant; + _workflowDefinitionManager = workflowDefinitionManager; + _workflowDefinitionRepository = workflowDefinitionRepository; + _workflowDefinitionVersionRepository = workflowDefinitionVersionRepository; + _workflowPermissionService = workflowPermissionService; + } + + public async Task ImportAsync(string jsonContent, bool overwrite = false, CancellationToken cancellationToken = default) + { + var jsonNode = JsonNode.Parse(jsonContent, new JsonNodeOptions() { PropertyNameCaseInsensitive = true }); + + var name = jsonNode["Name"].GetValue(); + var version = jsonNode["PublishedVersion"].GetValue(); + + var workflow = await _workflowDefinitionRepository.FindAsync(x => x.Name == name); + + // check exists workflow + if (workflow != null) + { + // check permssion + if (!await _workflowPermissionService.IsGrantedAsync(workflow.Id, ElsaModulePermissions.Definitions.Import)) + { + throw new Exception($"Workflow '{name}' unauthorized access."); + } + + if (!overwrite) + { + throw new Exception($"Workflow '{name}' already exists."); + } + + if (workflow.PublishedVersion > version) + { + throw new Exception($"Workflow '{name}' import version '{version}' less then current version '{workflow.PublishedVersion}'."); + } + } + + var jsonSerializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web); + + // definition + var inputWorkflow = jsonNode.Deserialize(jsonSerializerOptions); + + // version + var activities = jsonNode["activities"].Deserialize>(jsonSerializerOptions); + var connections = jsonNode["connections"].Deserialize>(jsonSerializerOptions); + + // workflow definition + if (workflow == null) + { + workflow = await _workflowDefinitionManager.CreateDefinitionAsync( + name, + inputWorkflow.DisplayName, + _currentTenant.Id, + inputWorkflow.Description, + inputWorkflow.IsSingleton, + inputWorkflow.DeleteCompletedInstances, + inputWorkflow.Channel, + inputWorkflow.Tag, + inputWorkflow.PersistenceBehavior, + inputWorkflow.ContextOptions, + inputWorkflow.Variables, + inputWorkflow.CustomAttributes + ); + + workflow.SetLatestVersion(version); + workflow.SetPublishedVersion(version); + + workflow = await _workflowDefinitionRepository.InsertAsync(workflow); + + // add permission + // auto added by event handler + } + else + { + // update + await _workflowDefinitionManager.UpdateDefinitionAsync( + workflow, + inputWorkflow.DisplayName, + inputWorkflow.Description, + inputWorkflow.IsSingleton, + inputWorkflow.DeleteCompletedInstances, + inputWorkflow.Channel, + inputWorkflow.Tag, + inputWorkflow.PersistenceBehavior, + inputWorkflow.ContextOptions, + inputWorkflow.Variables, + inputWorkflow.CustomAttributes); + + workflow.SetLatestVersion(version); + workflow.SetPublishedVersion(version); + + workflow = await _workflowDefinitionRepository.UpdateAsync(workflow); + } + + // version + var publishedVersion = await _workflowDefinitionVersionRepository.FindByVersionAsync(workflow.Id, version, true); + + if (publishedVersion == null) + { + // unset old version + await _workflowDefinitionManager.UnsetPublishedVersionAsync(workflow.Id); + await _workflowDefinitionManager.UnsetLatestVersionAsync(workflow.Id); + + // create new version + var workflowVersion = await _workflowDefinitionManager.CreateDefinitionVersionAsync(workflow.Id, workflow.TenantId, activities, connections); + + workflowVersion.SetVersion(version); + workflowVersion.SetIsLatest(true); + workflowVersion.SetIsPublished(true); + + workflowVersion = await _workflowDefinitionVersionRepository.InsertAsync(workflowVersion); + } + else + { + // unset old version + if (!publishedVersion.IsLatest) + await _workflowDefinitionManager.UnsetLatestVersionAsync(workflow.Id); + + if (!publishedVersion.IsPublished) + await _workflowDefinitionManager.UnsetPublishedVersionAsync(workflow.Id); + + publishedVersion.SetIsLatest(true); + publishedVersion.SetIsPublished(true); + + await _workflowDefinitionManager.UpdateDefinitionVersionAsync(publishedVersion, activities, connections); + } + + return workflow; + } +} diff --git a/src/Passingwind.Abp.ElsaModule.EntityFrameworkCore/EntityFrameworkCore/Repositories/WorkflowDefinitionVersionRepository.cs b/src/Passingwind.Abp.ElsaModule.EntityFrameworkCore/EntityFrameworkCore/Repositories/WorkflowDefinitionVersionRepository.cs index 069711e..ba172a2 100644 --- a/src/Passingwind.Abp.ElsaModule.EntityFrameworkCore/EntityFrameworkCore/Repositories/WorkflowDefinitionVersionRepository.cs +++ b/src/Passingwind.Abp.ElsaModule.EntityFrameworkCore/EntityFrameworkCore/Repositories/WorkflowDefinitionVersionRepository.cs @@ -11,102 +11,104 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; -namespace Passingwind.Abp.ElsaModule.EntityFrameworkCore.Repositories +namespace Passingwind.Abp.ElsaModule.EntityFrameworkCore.Repositories; + +public class WorkflowDefinitionVersionRepository : EfCoreRepository, IWorkflowDefinitionVersionRepository { - public class WorkflowDefinitionVersionRepository : EfCoreRepository, IWorkflowDefinitionVersionRepository + public WorkflowDefinitionVersionRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) + { + } + + public async Task FindByVersionAsync(Guid definitionId, int version, bool includeDetails = true, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + var entity = await dbset + .IncludeIf(includeDetails, x => x.Activities) + .IncludeIf(includeDetails, x => x.Connections) + .Where(x => x.DefinitionId == definitionId && x.Version == version) + .FirstOrDefaultAsync(); + + return entity; + } + + public async Task GetByVersionAsync(Guid definitionId, int version, bool includeDetails = true, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + var entity = await dbset + .IncludeIf(includeDetails, x => x.Activities) + .IncludeIf(includeDetails, x => x.Connections) + .Where(x => x.DefinitionId == definitionId && x.Version == version) + .FirstOrDefaultAsync(); + + if (entity == null) + throw new EntityNotFoundException(); + + return entity; + } + + public async Task GetCountAsync(Expression> expression, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + return await dbset + .AsNoTracking() + .AsQueryable() + .WhereIf(expression != null, expression) + .LongCountAsync(cancellationToken); + } + + public async Task GetLatestAsync(Guid id, bool includeDetails = true, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + var entity = await dbset + .IncludeIf(includeDetails, x => x.Activities) + .IncludeIf(includeDetails, x => x.Connections) + .OrderByDescending(x => x.Version) + .Where(x => x.DefinitionId == id) + .FirstOrDefaultAsync(); + + if (entity == null) + throw new EntityNotFoundException(); + + return entity; + } + + public async Task> GetListAsync(IEnumerable definitionIds = null, bool? isLatest = null, bool? isPublished = null, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + + return await dbset + .WhereIf(definitionIds != null, x => definitionIds.Contains(x.DefinitionId)) + .WhereIf(isLatest.HasValue, x => x.IsLatest == isLatest) + .WhereIf(isPublished.HasValue, x => x.IsPublished == isPublished) + .IncludeIf(includeDetails, x => x.Activities) + .IncludeIf(includeDetails, x => x.Connections) + .ToListAsync(cancellationToken); + } + + public async Task> GetPagedListAsync(int skipCount, int maxResultCount, Expression> expression, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var dbset = await GetDbSetAsync(); + return await dbset + .IncludeIf(includeDetails, x => x.Activities) + .IncludeIf(includeDetails, x => x.Connections) + .AsQueryable() + .WhereIf(expression != null, expression) + .OrderBy(sorting ?? nameof(WorkflowDefinitionVersion.CreationTime) + " desc") + .PageBy(skipCount, maxResultCount) + .ToListAsync(cancellationToken); + } + + public async Task GetPreviousVersionNumberAsync(Guid definitionId, int version, CancellationToken cancellationToken = default) { - public WorkflowDefinitionVersionRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) - { - } - - public async Task FindByVersionAsync(Guid definitionId, int version, bool includeDetails = true, CancellationToken cancellationToken = default) - { - var dbset = await GetDbSetAsync(); - - var entity = await dbset - .IncludeIf(includeDetails, x => x.Activities) - .IncludeIf(includeDetails, x => x.Connections) - .Where(x => x.DefinitionId == definitionId && x.Version == version) - .FirstOrDefaultAsync(); - - return entity; - } - - public async Task GetByVersionAsync(Guid definitionId, int version, bool includeDetails = true, CancellationToken cancellationToken = default) - { - var dbset = await GetDbSetAsync(); - - var entity = await dbset - .IncludeIf(includeDetails, x => x.Activities) - .IncludeIf(includeDetails, x => x.Connections) - .Where(x => x.DefinitionId == definitionId && x.Version == version) - .FirstOrDefaultAsync(); - - if (entity == null) - throw new EntityNotFoundException(); - - return entity; - } - - public async Task GetCountAsync(Expression> expression, CancellationToken cancellationToken = default) - { - var dbset = await GetDbSetAsync(); - return await dbset - .AsNoTracking() - .AsQueryable() - .WhereIf(expression != null, expression) - .LongCountAsync(cancellationToken); - } - - public async Task GetLatestAsync(Guid id, bool includeDetails = true, CancellationToken cancellationToken = default) - { - var dbset = await GetDbSetAsync(); - - var entity = await dbset - .IncludeIf(includeDetails, x => x.Activities) - .IncludeIf(includeDetails, x => x.Connections) - .OrderByDescending(x => x.Version) - .Where(x => x.DefinitionId == id) - .FirstOrDefaultAsync(); - - if (entity == null) - throw new EntityNotFoundException(); - - return entity; - } - - //public async Task> GetListAsync(Expression> expression, bool includeDetails = false, CancellationToken cancellationToken = default) - //{ - // var dbset = await GetDbSetAsync(); - // return await dbset - // // TODO - // //.IncludeIf(includeDetails, TODO ) - // .WhereIf(expression != null, expression) - // .ToListAsync(cancellationToken); - //} - - public async Task> GetPagedListAsync(int skipCount, int maxResultCount, Expression> expression, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default) - { - var dbset = await GetDbSetAsync(); - return await dbset - // TODO - //.IncludeIf(includeDetails, TODO ) - .AsQueryable() - .WhereIf(expression != null, expression) - .OrderBy(sorting ?? nameof(WorkflowDefinitionVersion.CreationTime) + " desc") - .PageBy(skipCount, maxResultCount) - .ToListAsync(cancellationToken); - } - - public async Task GetPreviousVersionNumberAsync(Guid definitionId, int version, CancellationToken cancellationToken = default) - { - var dbset = await GetDbSetAsync(); - return await dbset - .Where(x => x.DefinitionId == definitionId) - .OrderByDescending(x => x.Version) - .Where(x => x.Version < version) - .Select(x => x.Version) - .FirstOrDefaultAsync(); - } + var dbset = await GetDbSetAsync(); + return await dbset + .Where(x => x.DefinitionId == definitionId) + .OrderByDescending(x => x.Version) + .Where(x => x.Version < version) + .Select(x => x.Version) + .FirstOrDefaultAsync(); } } diff --git a/src/Passingwind.Abp.ElsaModule.HttpApi/WorkflowDefinitions/WorkflowDefinitionController.cs b/src/Passingwind.Abp.ElsaModule.HttpApi/WorkflowDefinitions/WorkflowDefinitionController.cs index e8c7b0a..dbf0050 100644 --- a/src/Passingwind.Abp.ElsaModule.HttpApi/WorkflowDefinitions/WorkflowDefinitionController.cs +++ b/src/Passingwind.Abp.ElsaModule.HttpApi/WorkflowDefinitions/WorkflowDefinitionController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp; using Volo.Abp.Application.Dtos; +using Volo.Abp.Content; namespace Passingwind.Abp.ElsaModule.WorkflowDefinitions; @@ -24,7 +25,7 @@ public virtual Task GetAsync(Guid id) } [HttpGet()] - public virtual Task> GetListAsync(WorkflowDefinitionListRequestDto input) + public virtual Task> GetListAsync(WorkflowDefinitionListRequestDto input) { return _service.GetListAsync(input); } @@ -148,4 +149,24 @@ public Task UpdateVariablesAsync(Guid id, WorkflowVariable { return _service.UpdateVariablesAsync(id, input); } + + [NonAction] + public Task ExportAsync(WorkflowDefinitionExportRequestDto input) + { + return _service.ExportAsync(input); + } + + [HttpPost("export")] + public async Task Export2Async(WorkflowDefinitionExportRequestDto input) + { + var result = await _service.ExportAsync(input); + + return File(result.GetStream(), result.ContentType, result.FileName, false); + } + + [HttpPost("import")] + public Task ImportAsync([FromForm] WorkflowDefinitionImportRequestDto input) + { + return _service.ImportAsync(input); + } } diff --git a/src/Passingwind.Abp.ElsaModule.MongoDB/MongoDB/Repositories/WorkflowDefinitionVersionRepository.cs b/src/Passingwind.Abp.ElsaModule.MongoDB/MongoDB/Repositories/WorkflowDefinitionVersionRepository.cs index 5896eb6..ec5985d 100644 --- a/src/Passingwind.Abp.ElsaModule.MongoDB/MongoDB/Repositories/WorkflowDefinitionVersionRepository.cs +++ b/src/Passingwind.Abp.ElsaModule.MongoDB/MongoDB/Repositories/WorkflowDefinitionVersionRepository.cs @@ -68,9 +68,22 @@ public async Task GetLatestAsync(Guid id, bool includ return entity; } + public async Task> GetListAsync(IEnumerable definitionIds = null, bool? isLatest = null, bool? isPublished = null, bool includeDetails = false, CancellationToken cancellationToken = default) + { + var query = await GetMongoQueryableAsync(cancellationToken); + + return await query + .WhereIf(definitionIds != null, x => definitionIds.Contains(x.DefinitionId)) + .WhereIf(isLatest.HasValue, x => x.IsLatest == isLatest) + .WhereIf(isPublished.HasValue, x => x.IsPublished == isPublished) + .As>() + .ToListAsync(cancellationToken); + } + public async Task> GetPagedListAsync(int skipCount, int maxResultCount, Expression> expression, string sorting, bool includeDetails = false, CancellationToken cancellationToken = default) { var query = await GetMongoQueryableAsync(cancellationToken); + return await query .WhereIf(expression != null, expression) .OrderBy(sorting ?? nameof(WorkflowDefinitionVersion.CreationTime) + " desc") @@ -82,6 +95,7 @@ public async Task> GetPagedListAsync(int skipCou public async Task GetPreviousVersionNumberAsync(Guid definitionId, int version, CancellationToken cancellationToken = default) { var query = await GetMongoQueryableAsync(cancellationToken); + return await query .Where(x => x.DefinitionId == definitionId) .OrderByDescending(x => x.Version) diff --git a/src/Passingwind.ElsaDesigner/src/locales/en-US.ts b/src/Passingwind.ElsaDesigner/src/locales/en-US.ts index 72946a6..016f6d8 100644 --- a/src/Passingwind.ElsaDesigner/src/locales/en-US.ts +++ b/src/Passingwind.ElsaDesigner/src/locales/en-US.ts @@ -48,6 +48,7 @@ export default { 'common.dict.success.tips': 'Notice', 'common.dict.general': 'General', 'common.dict.common': 'Common', + 'common.dict.uploadButton': 'Click To Upload', 'common.http.response.error.requestFailed': 'Request failed', 'common.http.response.error.networkError1': 'Network Error', 'common.http.response.error.networkError2': diff --git a/src/Passingwind.ElsaDesigner/src/locales/en-US/pages.ts b/src/Passingwind.ElsaDesigner/src/locales/en-US/pages.ts index 688f988..348c7b8 100644 --- a/src/Passingwind.ElsaDesigner/src/locales/en-US/pages.ts +++ b/src/Passingwind.ElsaDesigner/src/locales/en-US/pages.ts @@ -67,6 +67,7 @@ export default { 'page.dashboard.statistics.status.running': 'Running', 'page.dashboard.statistics.status.suspended': 'Suspended', // + 'page.definition': 'Definitions', 'page.definition.view': 'View', 'page.definition.edit.basic': 'Basic', 'page.definition.edit.variables': 'Variables', @@ -104,11 +105,25 @@ export default { 'page.definition.switchVersion': 'Switch version', 'page.definition.notFound': 'The workflow definition does not exist', 'page.definition.versionNotFound': 'The workflow definition does not exist', - 'page.definition.iam': 'Access control', + 'page.definition.iam': 'Access Control', 'page.definition.iam.owners': 'Owners', 'page.definition.iam.groups': 'Groups', 'page.definition.graph': 'Graph', 'page.definition.goInstanceDetail': 'View Instance', + 'page.definition.export.loading': 'Exporting, please wait...', + 'page.definition.import': 'Import', + 'page.definition.import.overwrite': 'Overwrite', + 'page.definition.import.overwrite.tips': 'Overwrite existing workflow', + 'page.definition.import.result.success': 'The workflow "{name}" imported successfully', + 'page.definition.import.result.failed': 'Imported failed: ', + 'page.definition.import.result.summary': + 'Import summary, success: {success}, failure: {failed}', + 'page.definition.import.result.summary.table': 'Details', + 'page.definition.import.result.table.tableTitle': 'Import Results', + 'page.definition.import.result.table.fileName': 'File Name', + 'page.definition.import.result.table.retult': 'Result', + 'page.definition.import.result.table.retult.success': 'success', + 'page.definition.import.result.table.retult.error': 'error', // 'page.definition.field.name': 'Name', 'page.definition.field.name.tips': 'A unique technical name for the workflow', diff --git a/src/Passingwind.ElsaDesigner/src/locales/zh-CN.ts b/src/Passingwind.ElsaDesigner/src/locales/zh-CN.ts index 3db0c40..e099cc7 100644 --- a/src/Passingwind.ElsaDesigner/src/locales/zh-CN.ts +++ b/src/Passingwind.ElsaDesigner/src/locales/zh-CN.ts @@ -48,6 +48,7 @@ export default { 'common.dict.success.tips': '成功提示', 'common.dict.general': '基本', 'common.dict.common': '通用', + 'common.dict.uploadButton': '点击上传', 'common.http.response.error.requestFailed': '请求失败', 'common.http.response.error.networkError1': '网络异常', 'common.http.response.error.networkError2': '您的网络发生异常,无法连接服务器', diff --git a/src/Passingwind.ElsaDesigner/src/locales/zh-CN/pages.ts b/src/Passingwind.ElsaDesigner/src/locales/zh-CN/pages.ts index eca15a4..26f356b 100644 --- a/src/Passingwind.ElsaDesigner/src/locales/zh-CN/pages.ts +++ b/src/Passingwind.ElsaDesigner/src/locales/zh-CN/pages.ts @@ -65,6 +65,7 @@ export default { 'page.dashboard.statistics.status.running': '运行中', 'page.dashboard.statistics.status.suspended': '挂起', // + 'page.definition': '流程定义', 'page.definition.view': '查看', 'page.definition.edit.basic': '基本信息', 'page.definition.edit.variables': '变量', @@ -107,6 +108,19 @@ export default { 'page.definition.iam.groups': '分组', 'page.definition.graph': '视图', 'page.definition.goInstanceDetail': '查看实例', + 'page.definition.export.loading': '正在导出....', + 'page.definition.import': '导入', + 'page.definition.import.overwrite': '覆盖', + 'page.definition.import.overwrite.tips': '覆盖已存在的工作流', + 'page.definition.import.result.success': '工作流 "{name}" 导入成功', + 'page.definition.import.result.failed': '导入失败:', + 'page.definition.import.result.summary': '导入结果: 成功: {success}, 失败: {failed}', + 'page.definition.import.result.summary.table': '详细信息', + 'page.definition.import.result.table.tableTitle': '导入结果', + 'page.definition.import.result.table.fileName': '文件名', + 'page.definition.import.result.table.retult': '结果', + 'page.definition.import.result.table.retult.success': '成功', + 'page.definition.import.result.table.retult.error': '失败', // 'page.definition.field.name': '名称', 'page.definition.field.name.tips': '工作流的唯一技术性名称', diff --git a/src/Passingwind.ElsaDesigner/src/pages/definition/index.tsx b/src/Passingwind.ElsaDesigner/src/pages/definition/index.tsx index cfeba43..1506b4f 100644 --- a/src/Passingwind.ElsaDesigner/src/pages/definition/index.tsx +++ b/src/Passingwind.ElsaDesigner/src/pages/definition/index.tsx @@ -1,6 +1,3 @@ -import type { GlobalAPI } from '@/services/global'; -import type { API } from '@/services/typings'; -import { formatTableSorter, getTableQueryConfig, saveTableQueryConfig } from '@/services/utils'; import { deleteWorkflowDefinition, deleteWorkflowDefinitionOwner, @@ -10,17 +7,45 @@ import { updateWorkflowDefinitionDefinition, workflowDefinitionAddOwner, workflowDefinitionDispatch, + workflowDefinitionExport2 as workflowDefinitionExport, + workflowDefinitionImport, workflowDefinitionPublish, workflowDefinitionUnPublish, } from '@/services/WorkflowDefinition'; -import { ProForm, ProFormInstance } from '@ant-design/pro-components'; +import type { GlobalAPI } from '@/services/global'; +import type { API } from '@/services/typings'; +import { + formatTableSorter, + getTableQueryConfig, + saveTableQueryConfig, + showDownloadFile, +} from '@/services/utils'; +import { DownloadOutlined, UploadOutlined } from '@ant-design/icons'; +import type { ProFormInstance } from '@ant-design/pro-components'; +import { ProForm } from '@ant-design/pro-components'; import { ModalForm, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-form'; import { PageContainer } from '@ant-design/pro-layout'; import type { ActionType, ProColumnType } from '@ant-design/pro-table'; import ProTable, { TableDropdown } from '@ant-design/pro-table'; -import { Button, Form, message, Modal, Popconfirm, Table, Tabs, Typography } from 'antd'; +import { + Alert, + Button, + Checkbox, + Drawer, + Form, + Modal, + Popconfirm, + Table, + Tabs, + Tag, + Tooltip, + Typography, + Upload, + message, +} from 'antd'; +import moment from 'moment'; import React, { useEffect, useRef, useState } from 'react'; -import { formatMessage, Link, useAccess, useHistory, useIntl } from 'umi'; +import { Link, formatMessage, useAccess, useHistory, useIntl } from 'umi'; import EditFormItems from './edit-form-items'; const handleEdit = async (id: string, data: any) => { @@ -49,6 +74,8 @@ const Index: React.FC = () => { const tableActionRef = useRef(); const [tableFilterCollapsed, setTableFilterCollapsed] = useState(true); const [tableQueryConfig, setTableQueryConfig] = useState(); + const [tableSelectedRowKeys, setTableSelectedRowKeys] = useState(); + const [tableSelectedRows, setTableSelectedRows] = useState([]); const history = useHistory(); @@ -65,6 +92,14 @@ const Index: React.FC = () => { const [iampModalVisible, setIampModalVisible] = useState(false); const [iamData, setIamData] = useState(); + const [exporting, setExporting] = useState(); + + const [importing, setImporting] = useState(false); + const [importModalVisible, setImportModalVisible] = useState(false); + const [importOverwrite, setImportOverwrite] = useState(false); + const [importResult, setImportResult] = useState(); + const [importResultTableVisible, setImportResultTableVisible] = useState(false); + const [editForm] = ProForm.useForm(); const loadIamData = async (id: string) => { @@ -107,6 +142,80 @@ const Index: React.FC = () => { return false; }; + const handleExport = async () => { + const loading = message.loading( + intl.formatMessage({ id: 'page.definition.export.loading' }), + ); + setExporting(true); + const res = await workflowDefinitionExport( + { + ids: tableSelectedRowKeys as string[], + }, + { responseType: 'arrayBuffer' }, + ); + if (res.response.ok) { + const fileName = + intl.formatMessage({ id: 'page.definition' }) + + '-' + + moment().format('YYYYMMDDHHmm') + + '.zip'; + showDownloadFile(fileName, res.data, 'application/stream'); + } + loading(); + setExporting(false); + }; + + const handleImport = async ( + file: any, + filename: string | undefined, + onSuccess: any, + onError: any, + ) => { + setImporting(true); + const formData = new FormData(); + formData.append('file', file); + formData.append('overwrite', importOverwrite as unknown as string); + const result = await workflowDefinitionImport( + formData as unknown as API.WorkflowDefinitionImportRequest, + ); + + setImporting(false); + setImportResult(result); + + // @ts-nocheck + const firstError = (result?.results ?? []).find((x) => x.hasError); + if (firstError) { + onError?.({ + name: firstError.fileName!, + message: firstError.errorMessage!, + }); + } else { + onSuccess?.({}); + } + + // check result + // (result?.results ?? []).forEach((item) => { + // if (item.hasError) { + // message.error( + // intl.formatMessage( + // { + // id: 'page.definition.import.result.failed', + // }, + // item.workflow, + // ) + item.errorMessage, + // 5, + // ); + // } else { + // message.success( + // intl.formatMessage( + // { id: 'page.definition.import.result.success' }, + // { ...item.workflow }, + // ), + // ); + // } + // }); + }; + const columns: ProColumnType[] = [ { dataIndex: 'filter', @@ -344,11 +453,42 @@ const Index: React.FC = () => { }} actionRef={tableActionRef} formRef={searchFormRef} + rowSelection={{ + selectedRowKeys: tableSelectedRowKeys, + onChange: (selectedRowKeys, selectedRows) => { + setTableSelectedRows(selectedRows); + setTableSelectedRowKeys(selectedRowKeys); + }, + }} search={{ labelWidth: 140 }} scroll={{ x: 1300 }} rowKey="id" toolBarRender={() => [ - access['ElsaWorkflow.Definitions.CreateOrUpdateOrPublish'] ? ( + access['ElsaWorkflow.Definitions.Export'] && ( + + ), + access['ElsaWorkflow.Definitions.Import'] && ( + + ), + access['ElsaWorkflow.Definitions.CreateOrUpdateOrPublish'] && ( - ) : ( - <> ), ]} onReset={() => { @@ -369,6 +507,8 @@ const Index: React.FC = () => { filter: null, pagination: undefined, }); + // clear selected + setTableSelectedRowKeys([]); }} pagination={tableQueryConfig?.pagination} onChange={(pagination, _, sorter) => { @@ -632,6 +772,147 @@ const Index: React.FC = () => { ]} /> + + setImportModalVisible(false)} + maskClosable={false} + width={500} + title={intl.formatMessage({ + id: 'page.definition.import', + })} + footer={false} + > + {importResult && !importing && ( + 0 ? 'warning' : 'success'} + message={intl.formatMessage( + { id: 'page.definition.import.result.summary' }, + { + success: importResult?.successCount, + failed: importResult?.failedCount, + }, + )} + action={ + + } + /> + )} +
+ + { + setImportOverwrite(e.target.checked); + }} + > + {intl.formatMessage({ + id: 'page.definition.import.overwrite', + })} + + + + { + await handleImport(file, filename, onSuccess, onError); + }} + > + + + +
+
+ + {/* import results */} + setImportResultTableVisible(false)} + width={680} + maskClosable={false} + footer={false} + title={intl.formatMessage({ id: 'page.definition.import.result.table.tableTitle' })} + > + { + return txt ? ( + + + {intl.formatMessage({ + id: 'page.definition.import.result.table.retult.error', + })} + + + ) : ( + + {intl.formatMessage({ + id: 'page.definition.import.result.table.retult.success', + })} + + ); + }, + }, + { + dataIndex: ['workflow', 'name'], + title: intl.formatMessage({ id: 'page.definition.field.name' }), + ellipsis: true, + }, + { + dataIndex: ['workflow', 'displayName'], + title: intl.formatMessage({ id: 'page.definition.field.displayName' }), + ellipsis: true, + }, + { + dataIndex: ['workflow', 'publishedVersion'], + title: intl.formatMessage({ + id: 'page.definition.field.publishedVersion', + }), + width: 120, + }, + ]} + dataSource={importResult?.results ?? []} + pagination={false} + /> + ); }; diff --git a/src/Passingwind.ElsaDesigner/src/pages/designer/index.tsx b/src/Passingwind.ElsaDesigner/src/pages/designer/index.tsx index 4f3d276..e705770 100644 --- a/src/Passingwind.ElsaDesigner/src/pages/designer/index.tsx +++ b/src/Passingwind.ElsaDesigner/src/pages/designer/index.tsx @@ -76,8 +76,7 @@ const Index: React.FC = () => { const [definitionId, setDefinitionId] = React.useState(); const [version, setVersion] = React.useState(1); const [definition, setDefinition] = React.useState(); - const [definitionVersion, setDefinitionVersion] = - React.useState(); + const [_, setDefinitionVersion] = React.useState(); const [oldVersion, setOldVersion] = React.useState(); @@ -125,11 +124,12 @@ const Index: React.FC = () => { const [variableEditModalVisible, setVariableEditModalVisible] = React.useState(); const [variableData, setVariableData] = React.useState(); - const loadServerData = async ( - definiton: API.WorkflowDefinitionVersion, + const loadGraphData = async ( + activities: API.Activity[], + connections: API.ActivityConnection[], autoLayout: boolean = false, ) => { - const gData = await conventToGraphData(definiton.activities!, definiton.connections!); + const gData = await conventToGraphData(activities, connections); // if (item.sourceActivityId) sourceId = item.sourceActivityId; // if (item.targetActivityId) targetId = item.targetActivityId; @@ -171,7 +171,6 @@ const Index: React.FC = () => { 2, ), ); - loading2(); } else { message.error('Get graph data failed'); @@ -182,11 +181,24 @@ const Index: React.FC = () => { const loading2 = message.loading(intl.formatMessage({ id: 'common.dict.loading' })); try { const content = await file.text(); - const data = JSON.parse(content); - const data2 = { connections: [], activities: data.activities }; - // compatible with offlice export json file - if (data?.connections) { - data2.connections = data.connections?.map((x: any) => { + const importData = JSON.parse(content); + // + delete importData.name; + delete importData.id; + delete importData.publishedVersion; + delete importData.latestVersion; + + const activities = importData?.activities; + + if (!activities) { + message.error('No activities found.'); + return; + } + + // compatible with elsa export json file + let connections = importData?.connections ?? []; + if (importData?.connections) { + connections = importData.connections?.map((x: any) => { return { sourceId: x.sourceId ?? x.sourceActivityId, targetId: x.targetId ?? x.targetActivityId, @@ -195,12 +207,20 @@ const Index: React.FC = () => { }); } - await loadServerData(data2 as API.WorkflowDefinition, autoLayout); - message.info('import successful.'); + // reload graph + await loadGraphData(activities, connections, autoLayout); + // update definition + setDefinition({ + ...definition, + ...importData, + }); + message.info('import successful.'); + loading2(); // return true; } catch (error) { + loading2(); console.error(error); message.error('Import file failed'); // @@ -722,7 +742,7 @@ const Index: React.FC = () => { message.error(validateResult.errors[0].toString(), 3.6); } else { setJsonEditorVisible(false); - await loadServerData(data2 as unknown as API.WorkflowDefinitionVersion, false); + await loadGraphData(data2.activities, data2.connections, false); // variables if (data.variables) { @@ -1072,26 +1092,26 @@ const Index: React.FC = () => { const loadData = async (did: string, version?: number) => { setLoading(true); - let definitonVersion: API.WorkflowDefinitionVersion; - if (version) definitonVersion = await getWorkflowDefinitionVersion(did, version); - else definitonVersion = await getWorkflowDefinition(did); + let serverVersion: API.WorkflowDefinitionVersion; + if (version) serverVersion = await getWorkflowDefinitionVersion(did, version); + else serverVersion = await getWorkflowDefinition(did); // setLoading(false); - if (definitonVersion) { - setDefinitionVersion(definitonVersion); + if (serverVersion) { + setDefinitionVersion(serverVersion); // - setDefinition(definitonVersion.definition); - setVersion(definitonVersion.version!); + setDefinition(serverVersion.definition); + setVersion(serverVersion.version!); // - await loadServerData(definitonVersion); + await loadGraphData(serverVersion.activities!, serverVersion?.connections ?? [], false); // if (fromDefinition) { // update setDefinition({ - ...definitonVersion.definition, - name: definitonVersion.definition?.name + '_copy', - displayName: definitonVersion.definition?.displayName + '_copy', + ...serverVersion.definition, + name: serverVersion.definition?.name + '_copy', + displayName: serverVersion.definition?.displayName + '_copy', }); showCreateModal(); } diff --git a/src/Passingwind.ElsaDesigner/src/services/AbpTenant.ts b/src/Passingwind.ElsaDesigner/src/services/AbpTenant.ts new file mode 100644 index 0000000..81abab2 --- /dev/null +++ b/src/Passingwind.ElsaDesigner/src/services/AbpTenant.ts @@ -0,0 +1,35 @@ +/** + * Generate from url: https://localhost:44345/swagger/v1/swagger.json + * It is recommended not to modify the document + * Total count: 2 + **/ +// @ts-ignore +/* eslint-disable */ +import type { API } from "./typings"; +import { request } from 'umi'; + +/** + * *TODO* GET /api/abp/multi-tenancy/tenants/by-id/{id} + **/ +export async function abpTenantFindTenantById( + id: string, + options?: { [key: string]: any } +) { + return request(`/api/abp/multi-tenancy/tenants/by-id/${id}`, { + method: 'GET', + ...(options || {}), + }); +} + +/** + * *TODO* GET /api/abp/multi-tenancy/tenants/by-name/{name} + **/ +export async function abpTenantFindTenantByName( + name: string, + options?: { [key: string]: any } +) { + return request(`/api/abp/multi-tenancy/tenants/by-name/${name}`, { + method: 'GET', + ...(options || {}), + }); +} diff --git a/src/Passingwind.ElsaDesigner/src/services/DispatchEndpoint.ts b/src/Passingwind.ElsaDesigner/src/services/DispatchEndpoint.ts new file mode 100644 index 0000000..fb5fbbe --- /dev/null +++ b/src/Passingwind.ElsaDesigner/src/services/DispatchEndpoint.ts @@ -0,0 +1,37 @@ +/** + * Generate from url: https://localhost:44345/swagger/v1/swagger.json + * It is recommended not to modify the document + * Total count: 2 + **/ +// @ts-ignore +/* eslint-disable */ +import type { API } from "./typings"; +import { request } from 'umi'; + +/** + * *TODO* GET /signals/dispatch/{token} + **/ +export async function dispatchEndpointHandleGET( + token: string, + options?: { [key: string]: any } +) { + return request(`/signals/dispatch/${token}`, { + method: 'GET', + getResponse: true, + ...(options || {}), + }); +} + +/** + * *TODO* POST /signals/dispatch/{token} + **/ +export async function dispatchEndpointHandlePOST( + token: string, + options?: { [key: string]: any } +) { + return request(`/signals/dispatch/${token}`, { + method: 'POST', + getResponse: true, + ...(options || {}), + }); +} diff --git a/src/Passingwind.ElsaDesigner/src/services/TriggerEndpoint.ts b/src/Passingwind.ElsaDesigner/src/services/TriggerEndpoint.ts new file mode 100644 index 0000000..6cde68c --- /dev/null +++ b/src/Passingwind.ElsaDesigner/src/services/TriggerEndpoint.ts @@ -0,0 +1,37 @@ +/** + * Generate from url: https://localhost:44345/swagger/v1/swagger.json + * It is recommended not to modify the document + * Total count: 2 + **/ +// @ts-ignore +/* eslint-disable */ +import type { API } from "./typings"; +import { request } from 'umi'; + +/** + * *TODO* GET /signals/trigger/{token} + **/ +export async function triggerEndpointHandleGET( + token: string, + options?: { [key: string]: any } +) { + return request(`/signals/trigger/${token}`, { + method: 'GET', + getResponse: true, + ...(options || {}), + }); +} + +/** + * *TODO* POST /signals/trigger/{token} + **/ +export async function triggerEndpointHandlePOST( + token: string, + options?: { [key: string]: any } +) { + return request(`/signals/trigger/${token}`, { + method: 'POST', + getResponse: true, + ...(options || {}), + }); +} diff --git a/src/Passingwind.ElsaDesigner/src/services/Workflow Endpoints.ts b/src/Passingwind.ElsaDesigner/src/services/Workflow Endpoints.ts new file mode 100644 index 0000000..25b2d8f --- /dev/null +++ b/src/Passingwind.ElsaDesigner/src/services/Workflow Endpoints.ts @@ -0,0 +1,74 @@ +/** + * Generate from url: https://localhost:44345/swagger/v1/swagger.json + * It is recommended not to modify the document + * Total count: 5 + **/ +// @ts-ignore +/* eslint-disable */ +import type { API } from "./typings"; +import { request } from 'umi'; + +/** + * *TODO* GET /test1 + **/ +export async function test1( + options?: { [key: string]: any } +) { + return request(`/test1`, { + method: 'GET', + getResponse: true, + ...(options || {}), + }); +} + +/** + * *TODO* GET /test2 + **/ +export async function test2GET( + options?: { [key: string]: any } +) { + return request(`/test2`, { + method: 'GET', + getResponse: true, + ...(options || {}), + }); +} + +/** + * *TODO* POST /test2 + **/ +export async function test2POST( + options?: { [key: string]: any } +) { + return request(`/test2`, { + method: 'POST', + getResponse: true, + ...(options || {}), + }); +} + +/** + * *TODO* GET /test3 + **/ +export async function test3GET( + options?: { [key: string]: any } +) { + return request(`/test3`, { + method: 'GET', + getResponse: true, + ...(options || {}), + }); +} + +/** + * *TODO* POST /test3 + **/ +export async function test3POST( + options?: { [key: string]: any } +) { + return request(`/test3`, { + method: 'POST', + getResponse: true, + ...(options || {}), + }); +} diff --git a/src/Passingwind.ElsaDesigner/src/services/WorkflowDefinition.ts b/src/Passingwind.ElsaDesigner/src/services/WorkflowDefinition.ts index 842727c..f3435f7 100644 --- a/src/Passingwind.ElsaDesigner/src/services/WorkflowDefinition.ts +++ b/src/Passingwind.ElsaDesigner/src/services/WorkflowDefinition.ts @@ -1,7 +1,7 @@ /** * Generate from url: https://localhost:44345/swagger/v1/swagger.json * It is recommended not to modify the document - * Total count: 22 + * Total count: 24 **/ // @ts-ignore /* eslint-disable */ @@ -116,7 +116,7 @@ export async function getWorkflowDefinitionList( }, options?: { [key: string]: any } ) { - return request(`/api/elsa/workflow/definitions`, { + return request(`/api/elsa/workflow/definitions`, { method: 'GET', params: params, ...(options || {}), @@ -272,6 +272,36 @@ export async function workflowDefinitionExecute( }); } +/** + * *TODO* POST /api/elsa/workflow/definitions/export + **/ +export async function workflowDefinitionExport2( + payload: API.WorkflowDefinitionExportRequest, + options?: { [key: string]: any } +) { + return request(`/api/elsa/workflow/definitions/export`, { + method: 'POST', + data: payload, + getResponse: true, + ...(options || {}), + }); +} + +/** + * *TODO* POST /api/elsa/workflow/definitions/import + **/ +export async function workflowDefinitionImport( + payload: API.WorkflowDefinitionImportRequest, + options?: { [key: string]: any } +) { + return request(`/api/elsa/workflow/definitions/import`, { + method: 'POST', + requestType: 'form', + data: payload, + ...(options || {}), + }); +} + /** * *TODO* PUT /api/elsa/workflow/definitions/{id}/publish **/ diff --git a/src/Passingwind.ElsaDesigner/src/services/typings.d.ts b/src/Passingwind.ElsaDesigner/src/services/typings.d.ts index fd4fa9f..5ec14cc 100644 --- a/src/Passingwind.ElsaDesigner/src/services/typings.d.ts +++ b/src/Passingwind.ElsaDesigner/src/services/typings.d.ts @@ -1,7 +1,7 @@ /** * Generate from url: https://localhost:44345/swagger/v1/swagger.json * It is recommended not to modify the document - * Total count: 186 + * Total count: 191 **/ import * as Enum from "./enums"; @@ -9,17 +9,104 @@ declare namespace API { /** * *TODO* **/ - type SelectList = { - isFlagsEnum?: boolean | undefined; - items?: SelectListItem[] | undefined; + type AbpLoginResult = { + result: Enum.LoginResultType; + description?: string | undefined; }; /** * *TODO* **/ - type SelectListItem = { - text?: string | undefined; - value?: string | undefined; + type AbpLoginResult = { + result: Enum.LoginResultType; + description?: string | undefined; + }; + + /** + * *TODO* + **/ + type AccountResult = { + enableLocalLogin?: boolean | undefined; + externalProviders?: ExternalProvider[] | undefined; + }; + + /** + * *TODO* + **/ + type ActionApiDescriptionModel = { + uniqueName?: string | undefined; + name?: string | undefined; + httpMethod?: string | undefined; + url?: string | undefined; + supportedVersions?: string[] | undefined; + parametersOnMethod?: MethodParameterApiDescriptionModel[] | undefined; + parameters?: ParameterApiDescriptionModel[] | undefined; + returnValue: ReturnValueApiDescriptionModel; + allowAnonymous?: boolean | undefined; + implementFrom?: string | undefined; + }; + + /** + * *TODO* + **/ + type Activity = { + activityId: string; + type?: string | undefined; + name?: string | undefined; + displayName?: string | undefined; + description?: string | undefined; + persistWorkflow?: boolean | undefined; + loadWorkflowContext?: boolean | undefined; + saveWorkflowContext?: boolean | undefined; + attributes?: any | undefined; + properties?: ActivityDefinitionProperty[] | undefined; + propertyStorageProviders?: any | undefined; + }; + + /** + * *TODO* + **/ + type ActivityConnection = { + sourceId: string; + targetId: string; + outcome?: string | undefined; + attributes?: any | undefined; + }; + + /** + * *TODO* + **/ + type ActivityConnectionCreate = { + sourceId: string; + targetId: string; + outcome?: string | undefined; + attributes?: any | undefined; + }; + + /** + * *TODO* + **/ + type ActivityCreateOrUpdate = { + activityId: string; + type: string; + name: string; + displayName?: string | undefined; + description?: string | undefined; + persistWorkflow?: boolean | undefined; + loadWorkflowContext?: boolean | undefined; + saveWorkflowContext?: boolean | undefined; + attributes?: any | undefined; + properties?: ActivityDefinitionProperty[] | undefined; + propertyStorageProviders?: any | undefined; + }; + + /** + * *TODO* + **/ + type ActivityDefinitionProperty = { + name?: string | undefined; + syntax?: string | undefined; + expressions?: any | undefined; }; /** @@ -60,787 +147,648 @@ declare namespace API { /** * *TODO* **/ - type ActivityDefinitionProperty = { - name?: string | undefined; - syntax?: string | undefined; - expressions?: any | undefined; + type ActivityTypeDescriptor = { + type?: string | undefined; + displayName?: string | undefined; + description?: string | undefined; + category?: string | undefined; + traits: Enum.ActivityTraits; + outcomes?: string[] | undefined; + inputProperties?: ActivityInputDescriptor[] | undefined; + outputProperties?: ActivityOutputDescriptor[] | undefined; + customAttributes?: any | undefined; }; /** * *TODO* **/ - type WorkflowContextOptions = { - contextType?: any | undefined; - contextFidelity: Enum.WorkflowContextFidelity; + type ActivityTypeDescriptorListResult = { + items?: ActivityTypeDescriptor[] | undefined; + categories?: string[] | undefined; }; /** * *TODO* **/ - type WorkflowInput = { - input?: any | undefined; - storageProviderName?: string | undefined; + type ApiKey = { + id: string; + creationTime: string; + creatorId?: string | undefined; + lastModificationTime?: string | undefined; + lastModifierId?: string | undefined; + name?: string | undefined; + expirationTime?: string | undefined; + secret?: string | undefined; }; /** * *TODO* **/ - type WorkflowInputReference = { - providerName?: string | undefined; + type ApiKeyCreateOrUpdate = { + name: string; + expirationTime?: string | undefined; }; /** * *TODO* **/ - type WorkflowOutputReference = { - providerName?: string | undefined; - activityId?: string | undefined; + type ApiKeyPagedResult = { + items?: ApiKey[] | undefined; + totalCount: number; }; /** * *TODO* **/ - type MonacoSignatureParameter = { - label?: string | undefined; - documentation?: string | undefined; + type ApplicationApiDescriptionModel = { + modules?: Record | undefined; + types?: Record | undefined; }; /** * *TODO* **/ - type MonacoSignatures = { - label?: string | undefined; - documentation?: string | undefined; - parameters?: MonacoSignatureParameter[] | undefined; + type ApplicationAuthConfiguration = { + grantedPolicies?: any | undefined; }; /** * *TODO* **/ - type WorkflowCSharpEditorCodeAnalysis = { - id?: string | undefined; - message?: string | undefined; - offsetFrom: number; - offsetTo: number; - severity: Enum.WorkflowCSharpEditorCodeAnalysisSeverity; - severityNumeric: number; + type ApplicationConfiguration = { + localization: ApplicationLocalizationConfiguration; + auth: ApplicationAuthConfiguration; + setting: ApplicationSettingConfiguration; + currentUser: CurrentUser; + features: ApplicationFeatureConfiguration; + globalFeatures: ApplicationGlobalFeatureConfiguration; + multiTenancy: MultiTenancyInfo; + currentTenant: CurrentTenant; + timing: Timing; + clock: Clock; + objectExtensions: ObjectExtensions; + extraProperties?: any | undefined; }; /** * *TODO* **/ - type WorkflowCSharpEditorCompletionItem = { - suggestion?: string | undefined; - description?: string | undefined; - symbolKind?: string | undefined; - itemKind: Enum.WorkflowCSharpEditorCompletionItemKind; + type ApplicationFeatureConfiguration = { + values?: any | undefined; }; /** * *TODO* **/ - type SimpleExceptionModel = { - type?: any | undefined; - message?: string | undefined; - stackTrace?: string | undefined; - data?: any | undefined; - innerException: SimpleExceptionModel; + type ApplicationGlobalFeatureConfiguration = { + enabledFeatures?: string[] | undefined; }; /** * *TODO* **/ - type WorkflowExecutionLog = { - id: string; - creationTime: string; - creatorId?: string | undefined; - workflowInstanceId: string; - activityId: string; - activityType?: string | undefined; - timestamp: string; - eventName?: string | undefined; - message?: string | undefined; - source?: string | undefined; - data?: any | undefined; + type ApplicationLocalization = { + resources?: Record | undefined; }; /** * *TODO* **/ - type GlobalVariable = { - id: string; - creationTime: string; - creatorId?: string | undefined; - lastModificationTime?: string | undefined; - lastModifierId?: string | undefined; - key?: string | undefined; - value?: string | undefined; - isSecret?: boolean | undefined; + type ApplicationLocalizationConfiguration = { + values?: any | undefined; + resources?: Record | undefined; + languages?: LanguageInfo[] | undefined; + currentCulture: CurrentCulture; + defaultResourceName?: string | undefined; + languagesMap?: any | undefined; + languageFilesMap?: any | undefined; }; /** * *TODO* **/ - type GlobalVariableCreateOrUpdate = { - key: string; - value?: string | undefined; - isSecret?: boolean | undefined; + type ApplicationLocalizationResource = { + texts?: any | undefined; + baseResources?: string[] | undefined; }; /** * *TODO* **/ - type Activity = { - activityId: string; - type?: string | undefined; - name?: string | undefined; - displayName?: string | undefined; - description?: string | undefined; - persistWorkflow?: boolean | undefined; - loadWorkflowContext?: boolean | undefined; - saveWorkflowContext?: boolean | undefined; - attributes?: any | undefined; - properties?: ActivityDefinitionProperty[] | undefined; - propertyStorageProviders?: any | undefined; + type ApplicationSettingConfiguration = { + values?: any | undefined; }; /** * *TODO* **/ - type ActivityConnection = { - sourceId: string; - targetId: string; - outcome?: string | undefined; - attributes?: any | undefined; + type ChangePasswordInput = { + currentPassword?: string | undefined; + newPassword: string; }; /** * *TODO* **/ - type ActivityConnectionCreate = { - sourceId: string; - targetId: string; - outcome?: string | undefined; - attributes?: any | undefined; + type Clock = { + kind?: string | undefined; }; /** * *TODO* **/ - type ActivityCreateOrUpdate = { - activityId: string; - type: string; - name: string; - displayName?: string | undefined; - description?: string | undefined; - persistWorkflow?: boolean | undefined; - loadWorkflowContext?: boolean | undefined; - saveWorkflowContext?: boolean | undefined; - attributes?: any | undefined; - properties?: ActivityDefinitionProperty[] | undefined; - propertyStorageProviders?: any | undefined; + type ControllerApiDescriptionModel = { + controllerName?: string | undefined; + controllerGroupName?: string | undefined; + isRemoteService?: boolean | undefined; + isIntegrationService?: boolean | undefined; + apiVersion?: string | undefined; + type?: string | undefined; + interfaces?: ControllerInterfaceApiDescriptionModel[] | undefined; + actions?: Record | undefined; }; /** * *TODO* **/ - type ActivityTypeDescriptor = { + type ControllerInterfaceApiDescriptionModel = { type?: string | undefined; - displayName?: string | undefined; - description?: string | undefined; - category?: string | undefined; - traits: Enum.ActivityTraits; - outcomes?: string[] | undefined; - inputProperties?: ActivityInputDescriptor[] | undefined; - outputProperties?: ActivityOutputDescriptor[] | undefined; - customAttributes?: any | undefined; + name?: string | undefined; + methods?: InterfaceMethodApiDescriptionModel[] | undefined; }; /** * *TODO* **/ - type ActivityTypeDescriptorListResult = { - items?: ActivityTypeDescriptor[] | undefined; - categories?: string[] | undefined; + type CurrentCulture = { + displayName?: string | undefined; + englishName?: string | undefined; + threeLetterIsoLanguageName?: string | undefined; + twoLetterIsoLanguageName?: string | undefined; + isRightToLeft?: boolean | undefined; + cultureName?: string | undefined; + name?: string | undefined; + nativeName?: string | undefined; + dateTimeFormat: DateTimeFormat; }; /** * *TODO* **/ - type RuntimeSelectListContext = { - providerTypeName?: string | undefined; - context?: any | undefined; + type CurrentTenant = { + id?: string | undefined; + name?: string | undefined; + isAvailable?: boolean | undefined; }; /** * *TODO* **/ - type RuntimeSelectListResult = { - selectList: SelectList; + type CurrentUser = { + isAuthenticated?: boolean | undefined; + id?: string | undefined; + tenantId?: string | undefined; + impersonatorUserId?: string | undefined; + impersonatorTenantId?: string | undefined; + impersonatorUserName?: string | undefined; + impersonatorTenantName?: string | undefined; + userName?: string | undefined; + name?: string | undefined; + surName?: string | undefined; + email?: string | undefined; + emailVerified?: boolean | undefined; + phoneNumber?: string | undefined; + phoneNumberVerified?: boolean | undefined; + roles?: string[] | undefined; }; /** * *TODO* **/ - type WorkflowDesignerCSharpLanguageAnalysisRequest = { - id: string; - text?: string | undefined; + type DateTimeFormat = { + calendarAlgorithmType?: string | undefined; + dateTimeFormatLong?: string | undefined; + shortDatePattern?: string | undefined; + fullDateTimePattern?: string | undefined; + dateSeparator?: string | undefined; + shortTimePattern?: string | undefined; + longTimePattern?: string | undefined; }; /** * *TODO* **/ - type WorkflowDesignerCSharpLanguageAnalysisResult = { - items?: WorkflowCSharpEditorCodeAnalysis[] | undefined; + type EmailSettings = { + smtpHost?: string | undefined; + smtpPort: number; + smtpUserName?: string | undefined; + smtpPassword?: string | undefined; + smtpDomain?: string | undefined; + smtpEnableSsl?: boolean | undefined; + smtpUseDefaultCredentials?: boolean | undefined; + defaultFromAddress?: string | undefined; + defaultFromDisplayName?: string | undefined; }; /** * *TODO* **/ - type WorkflowDesignerCSharpLanguageCompletionProviderRequest = { - id: string; - text?: string | undefined; - position: number; + type EntityExtension = { + properties?: Record | undefined; + configuration?: any | undefined; }; /** * *TODO* **/ - type WorkflowDesignerCSharpLanguageCompletionProviderResult = { - items?: WorkflowCSharpEditorCompletionItem[] | undefined; + type ExtensionEnum = { + fields?: ExtensionEnumField[] | undefined; + localizationResource?: string | undefined; }; /** * *TODO* **/ - type WorkflowDesignerCSharpLanguageFormatterRequest = { - id: string; - text?: string | undefined; + type ExtensionEnumField = { + name?: string | undefined; + value?: any | undefined; }; /** * *TODO* **/ - type WorkflowDesignerCSharpLanguageFormatterResult = { - success?: boolean | undefined; - code?: string | undefined; + type ExtensionProperty = { + type?: string | undefined; + typeSimple?: string | undefined; + displayName: LocalizableString; + api: ExtensionPropertyApi; + ui: ExtensionPropertyUi; + attributes?: ExtensionPropertyAttribute[] | undefined; + configuration?: any | undefined; + defaultValue?: any | undefined; }; /** * *TODO* **/ - type WorkflowDesignerCSharpLanguageHoverProviderRequest = { - id: string; - text?: string | undefined; - position: number; + type ExtensionPropertyApi = { + onGet: ExtensionPropertyApiGet; + onCreate: ExtensionPropertyApiCreate; + onUpdate: ExtensionPropertyApiUpdate; }; /** * *TODO* **/ - type WorkflowDesignerCSharpLanguageHoverProviderResult = { - information?: string | undefined; - offsetFrom: number; - offsetTo: number; + type ExtensionPropertyApiCreate = { + isAvailable?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowDesignerCSharpLanguageSignatureProviderRequest = { - id: string; - text?: string | undefined; - position: number; + type ExtensionPropertyApiGet = { + isAvailable?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowDesignerCSharpLanguageSignatureProviderResult = { - signatures?: MonacoSignatures[] | undefined; - activeParameter: number; - activeSignature: number; + type ExtensionPropertyApiUpdate = { + isAvailable?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowProviderDescriptor = { - name?: string | undefined; - type?: string | undefined; + type ExtensionPropertyAttribute = { + typeSimple?: string | undefined; + config?: any | undefined; }; /** * *TODO* **/ - type WorkflowSignalDispatchRequest = { - workflowInstanceId?: string | undefined; - correlationId?: string | undefined; - input?: any | undefined; + type ExtensionPropertyUi = { + onTable: ExtensionPropertyUiTable; + onCreateForm: ExtensionPropertyUiForm; + onEditForm: ExtensionPropertyUiForm; + lookup: ExtensionPropertyUiLookup; }; /** * *TODO* **/ - type WorkflowSignalDispatchResult = { - startedWorkflows?: WorkflowSignalResult[] | undefined; + type ExtensionPropertyUiForm = { + isVisible?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowSignalExecuteRequest = { - workflowInstanceId?: string | undefined; - correlationId?: string | undefined; - input?: any | undefined; + type ExtensionPropertyUiLookup = { + url?: string | undefined; + resultListPropertyName?: string | undefined; + displayPropertyName?: string | undefined; + valuePropertyName?: string | undefined; + filterParamName?: string | undefined; }; /** * *TODO* **/ - type WorkflowSignalExecuteResult = { - startedWorkflows?: WorkflowSignalResult[] | undefined; + type ExtensionPropertyUiTable = { + isVisible?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowSignalResult = { - workflowInstanceId: string; - activityId?: string | undefined; + type ExternalProvider = { + displayName?: string | undefined; + authenticationScheme?: string | undefined; }; /** * *TODO* **/ - type WorkflowStorageProviderInfo = { + type FindTenantResult = { + success?: boolean | undefined; + tenantId?: string | undefined; name?: string | undefined; - displayName?: string | undefined; + isActive?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowDefinition = { - id: string; - creationTime: string; - creatorId?: string | undefined; - lastModificationTime?: string | undefined; - lastModifierId?: string | undefined; - name?: string | undefined; - displayName?: string | undefined; - tenantId?: string | undefined; - description?: string | undefined; - latestVersion: number; - publishedVersion?: number | undefined; - isSingleton?: boolean | undefined; - deleteCompletedInstances?: boolean | undefined; - channel?: string | undefined; - tag?: string | undefined; - persistenceBehavior: Enum.WorkflowPersistenceBehavior; - contextOptions: WorkflowContextOptions; - variables?: any | undefined; - customAttributes?: any | undefined; + type GetPermissionListResult = { + entityDisplayName?: string | undefined; + groups?: PermissionGroup[] | undefined; }; /** * *TODO* **/ - type WorkflowDefinitionAddOwnerRequest = { - userId: string; + type GlobalVariable = { + id: string; + creationTime: string; + creatorId?: string | undefined; + lastModificationTime?: string | undefined; + lastModifierId?: string | undefined; + key?: string | undefined; + value?: string | undefined; + isSecret?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowDefinitionCreateOrUpdate = { - name: string; - displayName?: string | undefined; - description?: string | undefined; - isSingleton?: boolean | undefined; - deleteCompletedInstances?: boolean | undefined; - channel?: string | undefined; - tag?: string | undefined; - persistenceBehavior: Enum.WorkflowPersistenceBehavior; - contextOptions: WorkflowContextOptions; - variables?: any | undefined; + type GlobalVariableCreateOrUpdate = { + key: string; + value?: string | undefined; + isSecret?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowDefinitionDispatchRequest = { - activityId?: string | undefined; - correlationId?: string | undefined; - contextId?: string | undefined; - input?: any | undefined; + type GlobalVariablePagedResult = { + items?: GlobalVariable[] | undefined; + totalCount: number; }; /** * *TODO* **/ - type WorkflowDefinitionDispatchResult = { - workflowInstanceId: string; + type IanaTimeZone = { + timeZoneName?: string | undefined; }; /** * *TODO* **/ - type WorkflowDefinitionExecuteRequest = { - activityId?: string | undefined; - correlationId?: string | undefined; - contextId?: string | undefined; - input?: any | undefined; - }; - - /** - * *TODO* - **/ - type WorkflowDefinitionIamResult = { - owners?: IdentityUser[] | undefined; - groups?: WorkflowGroupBasic[] | undefined; - }; - - /** - * *TODO* - **/ - type WorkflowDefinitionRevertRequest = { - version: number; - }; - - /** - * *TODO* - **/ - type WorkflowDefinitionVersion = { + type IdentityRole = { + extraProperties?: any | undefined; id: string; - creationTime: string; - creatorId?: string | undefined; - lastModificationTime?: string | undefined; - lastModifierId?: string | undefined; - definition: WorkflowDefinition; - version: number; - isLatest?: boolean | undefined; - isPublished?: boolean | undefined; - activities?: Activity[] | undefined; - connections?: ActivityConnection[] | undefined; + name?: string | undefined; + isDefault?: boolean | undefined; + isStatic?: boolean | undefined; + isPublic?: boolean | undefined; + concurrencyStamp?: string | undefined; }; /** * *TODO* **/ - type WorkflowDefinitionVersionCreateOrUpdate = { - definition: WorkflowDefinitionCreateOrUpdate; - activities?: ActivityCreateOrUpdate[] | undefined; - connections?: ActivityConnectionCreate[] | undefined; - isPublished?: boolean | undefined; + type IdentityRoleCreate = { + extraProperties?: any | undefined; + name: string; + isDefault?: boolean | undefined; + isPublic?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowDefinitionVersionListItem = { - id: string; - creationTime: string; - creatorId?: string | undefined; - lastModificationTime?: string | undefined; - lastModifierId?: string | undefined; - version: number; - isLatest?: boolean | undefined; - isPublished?: boolean | undefined; + type IdentityRoleListResult = { + items?: IdentityRole[] | undefined; }; /** * *TODO* **/ - type WorkflowVariableUpdate = { - variables?: any | undefined; + type IdentityRolePagedResult = { + items?: IdentityRole[] | undefined; + totalCount: number; }; /** * *TODO* **/ - type WorkflowVariables = { - variables?: any | undefined; + type IdentityRoleUpdate = { + extraProperties?: any | undefined; + name: string; + isDefault?: boolean | undefined; + isPublic?: boolean | undefined; + concurrencyStamp?: string | undefined; }; /** * *TODO* **/ - type WorkflowGroup = { + type IdentityUser = { + extraProperties?: any | undefined; id: string; creationTime: string; creatorId?: string | undefined; lastModificationTime?: string | undefined; lastModifierId?: string | undefined; + isDeleted?: boolean | undefined; + deleterId?: string | undefined; + deletionTime?: string | undefined; + tenantId?: string | undefined; + userName?: string | undefined; name?: string | undefined; - description?: string | undefined; - roleId: string; - roleName?: string | undefined; - userIds?: string[] | undefined; - workflowIds?: string[] | undefined; + surname?: string | undefined; + email?: string | undefined; + emailConfirmed?: boolean | undefined; + phoneNumber?: string | undefined; + phoneNumberConfirmed?: boolean | undefined; + isActive?: boolean | undefined; + lockoutEnabled?: boolean | undefined; + lockoutEnd?: string | undefined; + concurrencyStamp?: string | undefined; }; /** * *TODO* **/ - type WorkflowGroupBasic = { - id: string; - creationTime: string; - creatorId?: string | undefined; - lastModificationTime?: string | undefined; - lastModifierId?: string | undefined; + type IdentityUserCreate = { + extraProperties?: any | undefined; + userName: string; name?: string | undefined; - description?: string | undefined; - roleId: string; - roleName?: string | undefined; - }; - - /** - * *TODO* - **/ - type WorkflowGroupCreateOrUpdate = { - name: string; - description?: string | undefined; - roleId: string; - userIds?: string[] | undefined; - workflowIds?: string[] | undefined; - }; - - /** - * *TODO* - **/ - type WorkflowGroupSetWorkflowRequest = { - workflowIds?: string[] | undefined; + surname?: string | undefined; + email: string; + phoneNumber?: string | undefined; + isActive?: boolean | undefined; + lockoutEnabled?: boolean | undefined; + roleNames?: string[] | undefined; + password: string; }; /** * *TODO* **/ - type WorkflowGroupUpdateUsersRequest = { - userIds?: string[] | undefined; + type IdentityUserPagedResult = { + items?: IdentityUser[] | undefined; + totalCount: number; }; /** * *TODO* **/ - type WorkflowInstance = { - id: string; - creationTime: string; - creatorId?: string | undefined; - lastModificationTime?: string | undefined; - lastModifierId?: string | undefined; - workflowDefinitionId: string; - workflowDefinitionVersionId: string; + type IdentityUserUpdate = { + extraProperties?: any | undefined; + userName: string; name?: string | undefined; - version: number; - workflowStatus: Enum.WorkflowInstanceStatus; - correlationId?: string | undefined; - contextType?: string | undefined; - contextId?: string | undefined; - lastExecutedTime?: string | undefined; - finishedTime?: string | undefined; - cancelledTime?: string | undefined; - faultedTime?: string | undefined; - finishedDuration: TimeSpan; - lastExecutedActivityId?: string | undefined; - input: WorkflowInputReference; - output: WorkflowOutputReference; - currentActivity: WorkflowInstanceScheduledActivity; - faults?: WorkflowInstanceFaultBasic[] | undefined; - variables?: any | undefined; - metadata?: any | undefined; - scheduledActivities?: WorkflowInstanceScheduledActivity[] | undefined; - blockingActivities?: WorkflowInstanceBlockingActivity[] | undefined; - activityScopes?: WorkflowInstanceActivityScope[] | undefined; - activityData?: WorkflowInstanceActivityData[] | undefined; - }; - - /** - * *TODO* - **/ - type WorkflowInstanceActivityData = { - activityId: string; - data?: any | undefined; + surname?: string | undefined; + email: string; + phoneNumber?: string | undefined; + isActive?: boolean | undefined; + lockoutEnabled?: boolean | undefined; + roleNames?: string[] | undefined; + password?: string | undefined; + concurrencyStamp?: string | undefined; }; /** * *TODO* **/ - type WorkflowInstanceActivityScope = { - activityId: string; - variables?: any | undefined; + type IdentityUserUpdateRoles = { + roleNames: string[]; }; /** * *TODO* **/ - type WorkflowInstanceBasic = { - id: string; - creationTime: string; - creatorId?: string | undefined; - lastModificationTime?: string | undefined; - lastModifierId?: string | undefined; - workflowDefinitionId: string; - workflowDefinitionVersionId: string; + type InterfaceMethodApiDescriptionModel = { name?: string | undefined; - version: number; - workflowStatus: Enum.WorkflowInstanceStatus; - correlationId?: string | undefined; - contextType?: string | undefined; - contextId?: string | undefined; - lastExecutedTime?: string | undefined; - finishedTime?: string | undefined; - cancelledTime?: string | undefined; - faultedTime?: string | undefined; - finishedDuration: TimeSpan; - }; - - /** - * *TODO* - **/ - type WorkflowInstanceBatchActionRequest = { - ids?: string[] | undefined; - }; - - /** - * *TODO* - **/ - type WorkflowInstanceBlockingActivity = { - activityId: string; - activityType?: string | undefined; - tag?: string | undefined; - }; - - /** - * *TODO* - **/ - type WorkflowInstanceDateCountStatistic = { - date: string; - finishedCount: number; - failedCount: number; - }; - - /** - * *TODO* - **/ - type WorkflowInstanceDateCountStatisticsResult = { - items?: WorkflowInstanceDateCountStatistic[] | undefined; - }; - - /** - * *TODO* - **/ - type WorkflowInstanceDispatchRequest = { - activityId?: string | undefined; - input: WorkflowInput; + parametersOnMethod?: MethodParameterApiDescriptionModel[] | undefined; + returnValue: ReturnValueApiDescriptionModel; }; /** * *TODO* **/ - type WorkflowInstanceExecuteRequest = { - activityId?: string | undefined; - input: WorkflowInput; + type LanguageInfo = { + cultureName?: string | undefined; + uiCultureName?: string | undefined; + displayName?: string | undefined; + twoLetterISOLanguageName?: string | undefined; + flagIcon?: string | undefined; }; /** * *TODO* **/ - type WorkflowInstanceExecutionLogSummary = { - activities?: WorkflowInstanceExecutionLogSummaryActivity[] | undefined; + type LocalizableString = { + name?: string | undefined; + resource?: string | undefined; }; /** * *TODO* **/ - type WorkflowInstanceExecutionLogSummaryActivity = { - activityId: string; - activityType?: string | undefined; - isExecuting?: boolean | undefined; - isExecuted?: boolean | undefined; - isFaulted?: boolean | undefined; - executedCount: number; - startTime: string; - endTime: string; - duration: number; - outcomes?: string[] | undefined; - stateData?: any | undefined; - journalData?: any | undefined; - message?: string | undefined; + type MethodParameterApiDescriptionModel = { + name?: string | undefined; + typeAsString?: string | undefined; + type?: string | undefined; + typeSimple?: string | undefined; + isOptional?: boolean | undefined; + defaultValue?: any | undefined; }; /** * *TODO* **/ - type WorkflowInstanceFault = { - id: string; - creationTime: string; - creatorId?: string | undefined; - workflowInstanceId: string; - faultedActivityId?: string | undefined; - resuming?: boolean | undefined; - activityInput?: any | undefined; - message?: string | undefined; - exception: SimpleExceptionModel; + type ModuleApiDescriptionModel = { + rootPath?: string | undefined; + remoteServiceName?: string | undefined; + controllers?: Record | undefined; }; /** * *TODO* **/ - type WorkflowInstanceFaultBasic = { - faultedActivityId?: string | undefined; - resuming?: boolean | undefined; - activityInput?: any | undefined; - message?: string | undefined; - exception: SimpleExceptionModel; + type ModuleExtension = { + entities?: Record | undefined; + configuration?: any | undefined; }; /** * *TODO* **/ - type WorkflowInstanceRetryRequest = { - runImmediately?: boolean | undefined; + type MonacoSignatureParameter = { + label?: string | undefined; + documentation?: string | undefined; }; /** * *TODO* **/ - type WorkflowInstanceScheduledActivity = { - activityId: string; - input?: any | undefined; + type MonacoSignatures = { + label?: string | undefined; + documentation?: string | undefined; + parameters?: MonacoSignatureParameter[] | undefined; }; /** * *TODO* **/ - type WorkflowInstanceStatusCountStatisticsResult = { - all: number; - running: number; - finished: number; - faulted: number; - suspended: number; + type MultiTenancyInfo = { + isEnabled?: boolean | undefined; }; /** * *TODO* **/ - type ApiKey = { - id: string; - creationTime: string; - creatorId?: string | undefined; - lastModificationTime?: string | undefined; - lastModifierId?: string | undefined; + type NameValue = { name?: string | undefined; - expirationTime?: string | undefined; - secret?: string | undefined; + value?: string | undefined; }; /** * *TODO* **/ - type ApiKeyCreateOrUpdate = { - name: string; - expirationTime?: string | undefined; + type OAuth2Settings = { + enabled?: boolean | undefined; + displayName?: string | undefined; + authority?: string | undefined; + metadataAddress?: string | undefined; + clientId?: string | undefined; + clientSecret?: string | undefined; + scope?: string | undefined; }; /** @@ -859,46 +807,48 @@ declare namespace API { /** * *TODO* **/ - type OAuth2Settings = { - enabled?: boolean | undefined; - displayName?: string | undefined; - authority?: string | undefined; - metadataAddress?: string | undefined; - clientId?: string | undefined; - clientSecret?: string | undefined; - scope?: string | undefined; - }; - - /** - * *TODO* - **/ - type AbpLoginResult = { - result: Enum.LoginResultType; - description?: string | undefined; + type ObjectExtensions = { + modules?: Record | undefined; + enums?: Record | undefined; }; /** * *TODO* **/ - type AccountResult = { - enableLocalLogin?: boolean | undefined; - externalProviders?: ExternalProvider[] | undefined; + type ParameterApiDescriptionModel = { + nameOnMethod?: string | undefined; + name?: string | undefined; + jsonName?: string | undefined; + type?: string | undefined; + typeSimple?: string | undefined; + isOptional?: boolean | undefined; + defaultValue?: any | undefined; + constraintTypes?: string[] | undefined; + bindingSourceId?: string | undefined; + descriptorName?: string | undefined; }; /** * *TODO* **/ - type ExternalProvider = { + type PermissionGrantInfo = { + name?: string | undefined; displayName?: string | undefined; - authenticationScheme?: string | undefined; + parentName?: string | undefined; + isGranted?: boolean | undefined; + allowedProviders?: string[] | undefined; + grantedProviders?: ProviderInfo[] | undefined; }; /** * *TODO* **/ - type ChangePasswordInput = { - currentPassword?: string | undefined; - newPassword: string; + type PermissionGroup = { + name?: string | undefined; + displayName?: string | undefined; + displayNameKey?: string | undefined; + displayNameResource?: string | undefined; + permissions?: PermissionGrantInfo[] | undefined; }; /** @@ -916,6 +866,30 @@ declare namespace API { concurrencyStamp?: string | undefined; }; + /** + * *TODO* + **/ + type PropertyApiDescriptionModel = { + name?: string | undefined; + jsonName?: string | undefined; + type?: string | undefined; + typeSimple?: string | undefined; + isRequired?: boolean | undefined; + minLength?: number | undefined; + maxLength?: number | undefined; + minimum?: string | undefined; + maximum?: string | undefined; + regex?: string | undefined; + }; + + /** + * *TODO* + **/ + type ProviderInfo = { + providerName?: string | undefined; + providerKey?: string | undefined; + }; + /** * *TODO* **/ @@ -927,6 +901,32 @@ declare namespace API { appName: string; }; + /** + * *TODO* + **/ + type RemoteServiceErrorInfo = { + code?: string | undefined; + message?: string | undefined; + details?: string | undefined; + data?: any | undefined; + validationErrors?: RemoteServiceValidationErrorInfo[] | undefined; + }; + + /** + * *TODO* + **/ + type RemoteServiceErrorResponse = { + error: RemoteServiceErrorInfo; + }; + + /** + * *TODO* + **/ + type RemoteServiceValidationErrorInfo = { + message?: string | undefined; + members?: string[] | undefined; + }; + /** * *TODO* **/ @@ -936,6 +936,45 @@ declare namespace API { password: string; }; + /** + * *TODO* + **/ + type ReturnValueApiDescriptionModel = { + type?: string | undefined; + typeSimple?: string | undefined; + }; + + /** + * *TODO* + **/ + type RuntimeSelectListContext = { + providerTypeName?: string | undefined; + context?: any | undefined; + }; + + /** + * *TODO* + **/ + type RuntimeSelectListResult = { + selectList: SelectList; + }; + + /** + * *TODO* + **/ + type SelectList = { + isFlagsEnum?: boolean | undefined; + items?: SelectListItem[] | undefined; + }; + + /** + * *TODO* + **/ + type SelectListItem = { + text?: string | undefined; + value?: string | undefined; + }; + /** * *TODO* **/ @@ -949,873 +988,889 @@ declare namespace API { /** * *TODO* **/ - type UpdateProfile = { - extraProperties?: any | undefined; - userName?: string | undefined; - email?: string | undefined; - name?: string | undefined; - surname?: string | undefined; - phoneNumber?: string | undefined; - concurrencyStamp?: string | undefined; + type SendTestEmailInput = { + senderEmailAddress: string; + targetEmailAddress: string; + subject: string; + body?: string | undefined; }; /** * *TODO* **/ - type VerifyPasswordResetTokenInput = { - userId: string; - resetToken: string; + type SimpleExceptionModel = { + type?: any | undefined; + message?: string | undefined; + stackTrace?: string | undefined; + data?: any | undefined; + innerException: SimpleExceptionModel; }; /** * *TODO* **/ - type AbpLoginResult = { - result: Enum.LoginResultType; - description?: string | undefined; + type StringListResult = { + items?: string[] | undefined; }; /** * *TODO* **/ - type UserLoginInfo = { - userNameOrEmailAddress: string; - password: string; - rememberMe?: boolean | undefined; + type TimeZone = { + iana: IanaTimeZone; + windows: WindowsTimeZone; }; /** * *TODO* **/ - type ApiKeyPagedResult = { - items?: ApiKey[] | undefined; - totalCount: number; + type Timing = { + timeZone: TimeZone; }; /** * *TODO* **/ - type GlobalVariablePagedResult = { - items?: GlobalVariable[] | undefined; - totalCount: number; + type TypeApiDescriptionModel = { + baseType?: string | undefined; + isEnum?: boolean | undefined; + enumNames?: string[] | undefined; + enumValues?: any[] | undefined; + genericArguments?: string[] | undefined; + properties?: PropertyApiDescriptionModel[] | undefined; }; /** * *TODO* **/ - type IdentityRoleListResult = { - items?: IdentityRole[] | undefined; + type UpdateEmailSettings = { + smtpHost?: string | undefined; + smtpPort: number; + smtpUserName?: string | undefined; + smtpPassword?: string | undefined; + smtpDomain?: string | undefined; + smtpEnableSsl?: boolean | undefined; + smtpUseDefaultCredentials?: boolean | undefined; + defaultFromAddress: string; + defaultFromDisplayName: string; }; /** * *TODO* **/ - type IdentityRolePagedResult = { - items?: IdentityRole[] | undefined; - totalCount: number; + type UpdatePermission = { + name?: string | undefined; + isGranted?: boolean | undefined; }; /** * *TODO* **/ - type IdentityUserPagedResult = { - items?: IdentityUser[] | undefined; - totalCount: number; + type UpdatePermissions = { + permissions?: UpdatePermission[] | undefined; }; /** * *TODO* **/ - type StringListResult = { - items?: string[] | undefined; + type UpdateProfile = { + extraProperties?: any | undefined; + userName?: string | undefined; + email?: string | undefined; + name?: string | undefined; + surname?: string | undefined; + phoneNumber?: string | undefined; + concurrencyStamp?: string | undefined; }; /** * *TODO* **/ - type UserDataListResult = { - items?: UserData[] | undefined; + type UserData = { + id: string; + tenantId?: string | undefined; + userName?: string | undefined; + name?: string | undefined; + surname?: string | undefined; + isActive?: boolean | undefined; + email?: string | undefined; + emailConfirmed?: boolean | undefined; + phoneNumber?: string | undefined; + phoneNumberConfirmed?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowDefinitionPagedResult = { - items?: WorkflowDefinition[] | undefined; - totalCount: number; + type UserDataListResult = { + items?: UserData[] | undefined; }; /** * *TODO* **/ - type WorkflowDefinitionVersionListItemPagedResult = { - items?: WorkflowDefinitionVersionListItem[] | undefined; - totalCount: number; + type UserLoginInfo = { + userNameOrEmailAddress: string; + password: string; + rememberMe?: boolean | undefined; }; /** * *TODO* **/ - type WorkflowExecutionLogListResult = { - items?: WorkflowExecutionLog[] | undefined; + type VerifyPasswordResetTokenInput = { + userId: string; + resetToken: string; }; /** * *TODO* **/ - type WorkflowExecutionLogPagedResult = { - items?: WorkflowExecutionLog[] | undefined; - totalCount: number; + type WindowsTimeZone = { + timeZoneId?: string | undefined; }; /** * *TODO* **/ - type WorkflowGroupBasicPagedResult = { - items?: WorkflowGroupBasic[] | undefined; - totalCount: number; + type WorkflowContextOptions = { + contextType?: any | undefined; + contextFidelity: Enum.WorkflowContextFidelity; }; /** * *TODO* **/ - type WorkflowInstanceBasicPagedResult = { - items?: WorkflowInstanceBasic[] | undefined; - totalCount: number; + type WorkflowCSharpEditorCodeAnalysis = { + id?: string | undefined; + message?: string | undefined; + offsetFrom: number; + offsetTo: number; + severity: Enum.WorkflowCSharpEditorCodeAnalysisSeverity; + severityNumeric: number; }; /** * *TODO* **/ - type WorkflowInstanceFaultListResult = { - items?: WorkflowInstanceFault[] | undefined; + type WorkflowCSharpEditorCompletionItem = { + suggestion?: string | undefined; + description?: string | undefined; + symbolKind?: string | undefined; + itemKind: Enum.WorkflowCSharpEditorCompletionItemKind; }; /** * *TODO* **/ - type WorkflowInstanceFaultPagedResult = { - items?: WorkflowInstanceFault[] | undefined; - totalCount: number; + type WorkflowDefinition = { + id: string; + creationTime: string; + creatorId?: string | undefined; + lastModificationTime?: string | undefined; + lastModifierId?: string | undefined; + name?: string | undefined; + displayName?: string | undefined; + description?: string | undefined; + latestVersion: number; + publishedVersion?: number | undefined; + isSingleton?: boolean | undefined; + deleteCompletedInstances?: boolean | undefined; + channel?: string | undefined; + tag?: string | undefined; + persistenceBehavior: Enum.WorkflowPersistenceBehavior; + contextOptions: WorkflowContextOptions; + variables?: any | undefined; + customAttributes?: any | undefined; }; /** * *TODO* **/ - type WorkflowProviderDescriptorListResult = { - items?: WorkflowProviderDescriptor[] | undefined; + type WorkflowDefinitionAddOwnerRequest = { + userId: string; }; /** * *TODO* **/ - type WorkflowStorageProviderInfoListResult = { - items?: WorkflowStorageProviderInfo[] | undefined; + type WorkflowDefinitionBasic = { + id: string; + creationTime: string; + creatorId?: string | undefined; + lastModificationTime?: string | undefined; + lastModifierId?: string | undefined; + name?: string | undefined; + displayName?: string | undefined; + description?: string | undefined; + latestVersion: number; + publishedVersion?: number | undefined; + isSingleton?: boolean | undefined; + deleteCompletedInstances?: boolean | undefined; + channel?: string | undefined; + tag?: string | undefined; + persistenceBehavior: Enum.WorkflowPersistenceBehavior; }; /** * *TODO* **/ - type ApplicationAuthConfiguration = { - grantedPolicies?: any | undefined; + type WorkflowDefinitionBasicPagedResult = { + items?: WorkflowDefinitionBasic[] | undefined; + totalCount: number; }; /** * *TODO* **/ - type ApplicationConfiguration = { - localization: ApplicationLocalizationConfiguration; - auth: ApplicationAuthConfiguration; - setting: ApplicationSettingConfiguration; - currentUser: CurrentUser; - features: ApplicationFeatureConfiguration; - globalFeatures: ApplicationGlobalFeatureConfiguration; - multiTenancy: MultiTenancyInfo; - currentTenant: CurrentTenant; - timing: Timing; - clock: Clock; - objectExtensions: ObjectExtensions; - extraProperties?: any | undefined; + type WorkflowDefinitionCreateOrUpdate = { + name: string; + displayName?: string | undefined; + description?: string | undefined; + isSingleton?: boolean | undefined; + deleteCompletedInstances?: boolean | undefined; + channel?: string | undefined; + tag?: string | undefined; + persistenceBehavior: Enum.WorkflowPersistenceBehavior; + contextOptions: WorkflowContextOptions; + variables?: any | undefined; }; /** * *TODO* **/ - type ApplicationFeatureConfiguration = { - values?: any | undefined; + type WorkflowDefinitionDispatchRequest = { + activityId?: string | undefined; + correlationId?: string | undefined; + contextId?: string | undefined; + input?: any | undefined; }; /** * *TODO* **/ - type ApplicationGlobalFeatureConfiguration = { - enabledFeatures?: string[] | undefined; + type WorkflowDefinitionDispatchResult = { + workflowInstanceId: string; }; /** * *TODO* **/ - type ApplicationLocalization = { - resources?: Record | undefined; + type WorkflowDefinitionExecuteRequest = { + activityId?: string | undefined; + correlationId?: string | undefined; + contextId?: string | undefined; + input?: any | undefined; }; /** * *TODO* **/ - type ApplicationLocalizationConfiguration = { - values?: any | undefined; - resources?: Record | undefined; - languages?: LanguageInfo[] | undefined; - currentCulture: CurrentCulture; - defaultResourceName?: string | undefined; - languagesMap?: any | undefined; - languageFilesMap?: any | undefined; + type WorkflowDefinitionExportRequest = { + ids?: string[] | undefined; }; /** * *TODO* **/ - type ApplicationLocalizationResource = { - texts?: any | undefined; - baseResources?: string[] | undefined; + type WorkflowDefinitionIamResult = { + owners?: IdentityUser[] | undefined; + groups?: WorkflowGroupBasic[] | undefined; }; /** * *TODO* **/ - type ApplicationSettingConfiguration = { - values?: any | undefined; + type WorkflowDefinitionImportRequest = { + file: any; + overwrite?: boolean | undefined; }; /** * *TODO* **/ - type Clock = { - kind?: string | undefined; + type WorkflowDefinitionImportResult = { + totalCount: number; + successCount: number; + failedCount: number; + results?: WorkflowDefinitionImportResultWorkflowImportResult[] | undefined; }; /** * *TODO* **/ - type CurrentCulture = { - displayName?: string | undefined; - englishName?: string | undefined; - threeLetterIsoLanguageName?: string | undefined; - twoLetterIsoLanguageName?: string | undefined; - isRightToLeft?: boolean | undefined; - cultureName?: string | undefined; - name?: string | undefined; - nativeName?: string | undefined; - dateTimeFormat: DateTimeFormat; + type WorkflowDefinitionImportResultWorkflowImportResult = { + fileName?: string | undefined; + hasError?: boolean | undefined; + errorMessage?: string | undefined; + workflow: WorkflowDefinitionBasic; }; /** * *TODO* **/ - type CurrentUser = { - isAuthenticated?: boolean | undefined; - id?: string | undefined; - tenantId?: string | undefined; - impersonatorUserId?: string | undefined; - impersonatorTenantId?: string | undefined; - impersonatorUserName?: string | undefined; - impersonatorTenantName?: string | undefined; - userName?: string | undefined; - name?: string | undefined; - surName?: string | undefined; - email?: string | undefined; - emailVerified?: boolean | undefined; - phoneNumber?: string | undefined; - phoneNumberVerified?: boolean | undefined; - roles?: string[] | undefined; + type WorkflowDefinitionRevertRequest = { + version: number; }; /** * *TODO* **/ - type DateTimeFormat = { - calendarAlgorithmType?: string | undefined; - dateTimeFormatLong?: string | undefined; - shortDatePattern?: string | undefined; - fullDateTimePattern?: string | undefined; - dateSeparator?: string | undefined; - shortTimePattern?: string | undefined; - longTimePattern?: string | undefined; + type WorkflowDefinitionVersion = { + id: string; + creationTime: string; + creatorId?: string | undefined; + lastModificationTime?: string | undefined; + lastModifierId?: string | undefined; + definition: WorkflowDefinition; + version: number; + isLatest?: boolean | undefined; + isPublished?: boolean | undefined; + activities?: Activity[] | undefined; + connections?: ActivityConnection[] | undefined; }; /** * *TODO* **/ - type IanaTimeZone = { - timeZoneName?: string | undefined; + type WorkflowDefinitionVersionCreateOrUpdate = { + definition: WorkflowDefinitionCreateOrUpdate; + activities?: ActivityCreateOrUpdate[] | undefined; + connections?: ActivityConnectionCreate[] | undefined; + isPublished?: boolean | undefined; }; /** * *TODO* **/ - type EntityExtension = { - properties?: Record | undefined; - configuration?: any | undefined; + type WorkflowDefinitionVersionListItem = { + id: string; + creationTime: string; + creatorId?: string | undefined; + lastModificationTime?: string | undefined; + lastModifierId?: string | undefined; + version: number; + isLatest?: boolean | undefined; + isPublished?: boolean | undefined; }; /** * *TODO* **/ - type ExtensionEnum = { - fields?: ExtensionEnumField[] | undefined; - localizationResource?: string | undefined; + type WorkflowDefinitionVersionListItemPagedResult = { + items?: WorkflowDefinitionVersionListItem[] | undefined; + totalCount: number; }; /** * *TODO* **/ - type ExtensionEnumField = { - name?: string | undefined; - value?: any | undefined; + type WorkflowDesignerCSharpLanguageAnalysisRequest = { + id: string; + text?: string | undefined; }; /** - * *TODO* - **/ - type ExtensionProperty = { - type?: string | undefined; - typeSimple?: string | undefined; - displayName: LocalizableString; - api: ExtensionPropertyApi; - ui: ExtensionPropertyUi; - attributes?: ExtensionPropertyAttribute[] | undefined; - configuration?: any | undefined; - defaultValue?: any | undefined; + * *TODO* + **/ + type WorkflowDesignerCSharpLanguageAnalysisResult = { + items?: WorkflowCSharpEditorCodeAnalysis[] | undefined; }; /** * *TODO* **/ - type ExtensionPropertyApi = { - onGet: ExtensionPropertyApiGet; - onCreate: ExtensionPropertyApiCreate; - onUpdate: ExtensionPropertyApiUpdate; + type WorkflowDesignerCSharpLanguageCompletionProviderRequest = { + id: string; + text?: string | undefined; + position: number; }; /** * *TODO* **/ - type ExtensionPropertyApiCreate = { - isAvailable?: boolean | undefined; + type WorkflowDesignerCSharpLanguageCompletionProviderResult = { + items?: WorkflowCSharpEditorCompletionItem[] | undefined; }; /** * *TODO* **/ - type ExtensionPropertyApiGet = { - isAvailable?: boolean | undefined; + type WorkflowDesignerCSharpLanguageFormatterRequest = { + id: string; + text?: string | undefined; }; /** * *TODO* **/ - type ExtensionPropertyApiUpdate = { - isAvailable?: boolean | undefined; + type WorkflowDesignerCSharpLanguageFormatterResult = { + success?: boolean | undefined; + code?: string | undefined; }; /** * *TODO* **/ - type ExtensionPropertyAttribute = { - typeSimple?: string | undefined; - config?: any | undefined; + type WorkflowDesignerCSharpLanguageHoverProviderRequest = { + id: string; + text?: string | undefined; + position: number; }; /** * *TODO* **/ - type ExtensionPropertyUi = { - onTable: ExtensionPropertyUiTable; - onCreateForm: ExtensionPropertyUiForm; - onEditForm: ExtensionPropertyUiForm; - lookup: ExtensionPropertyUiLookup; + type WorkflowDesignerCSharpLanguageHoverProviderResult = { + information?: string | undefined; + offsetFrom: number; + offsetTo: number; }; /** * *TODO* **/ - type ExtensionPropertyUiForm = { - isVisible?: boolean | undefined; + type WorkflowDesignerCSharpLanguageSignatureProviderRequest = { + id: string; + text?: string | undefined; + position: number; }; /** * *TODO* **/ - type ExtensionPropertyUiLookup = { - url?: string | undefined; - resultListPropertyName?: string | undefined; - displayPropertyName?: string | undefined; - valuePropertyName?: string | undefined; - filterParamName?: string | undefined; + type WorkflowDesignerCSharpLanguageSignatureProviderResult = { + signatures?: MonacoSignatures[] | undefined; + activeParameter: number; + activeSignature: number; }; /** * *TODO* **/ - type ExtensionPropertyUiTable = { - isVisible?: boolean | undefined; + type WorkflowExecutionLog = { + id: string; + creationTime: string; + creatorId?: string | undefined; + workflowInstanceId: string; + activityId: string; + activityType?: string | undefined; + timestamp: string; + eventName?: string | undefined; + message?: string | undefined; + source?: string | undefined; + data?: any | undefined; }; /** * *TODO* **/ - type LocalizableString = { - name?: string | undefined; - resource?: string | undefined; + type WorkflowExecutionLogListResult = { + items?: WorkflowExecutionLog[] | undefined; }; /** * *TODO* **/ - type ModuleExtension = { - entities?: Record | undefined; - configuration?: any | undefined; + type WorkflowExecutionLogPagedResult = { + items?: WorkflowExecutionLog[] | undefined; + totalCount: number; }; /** * *TODO* **/ - type ObjectExtensions = { - modules?: Record | undefined; - enums?: Record | undefined; + type WorkflowGroup = { + id: string; + creationTime: string; + creatorId?: string | undefined; + lastModificationTime?: string | undefined; + lastModifierId?: string | undefined; + name?: string | undefined; + description?: string | undefined; + roleId: string; + roleName?: string | undefined; + userIds?: string[] | undefined; + workflowIds?: string[] | undefined; }; /** * *TODO* **/ - type TimeZone = { - iana: IanaTimeZone; - windows: WindowsTimeZone; + type WorkflowGroupBasic = { + id: string; + creationTime: string; + creatorId?: string | undefined; + lastModificationTime?: string | undefined; + lastModifierId?: string | undefined; + name?: string | undefined; + description?: string | undefined; + roleId: string; + roleName?: string | undefined; }; /** * *TODO* **/ - type Timing = { - timeZone: TimeZone; + type WorkflowGroupBasicPagedResult = { + items?: WorkflowGroupBasic[] | undefined; + totalCount: number; }; /** * *TODO* **/ - type WindowsTimeZone = { - timeZoneId?: string | undefined; + type WorkflowGroupCreateOrUpdate = { + name: string; + description?: string | undefined; + roleId: string; + userIds?: string[] | undefined; + workflowIds?: string[] | undefined; }; /** * *TODO* **/ - type CurrentTenant = { - id?: string | undefined; - name?: string | undefined; - isAvailable?: boolean | undefined; + type WorkflowGroupSetWorkflowRequest = { + workflowIds?: string[] | undefined; }; /** * *TODO* **/ - type FindTenantResult = { - success?: boolean | undefined; - tenantId?: string | undefined; - name?: string | undefined; - isActive?: boolean | undefined; + type WorkflowGroupUpdateUsersRequest = { + userIds?: string[] | undefined; }; /** * *TODO* **/ - type MultiTenancyInfo = { - isEnabled?: boolean | undefined; + type WorkflowInput = { + input?: any | undefined; + storageProviderName?: string | undefined; }; /** * *TODO* **/ - type ActionApiDescriptionModel = { - uniqueName?: string | undefined; - name?: string | undefined; - httpMethod?: string | undefined; - url?: string | undefined; - supportedVersions?: string[] | undefined; - parametersOnMethod?: MethodParameterApiDescriptionModel[] | undefined; - parameters?: ParameterApiDescriptionModel[] | undefined; - returnValue: ReturnValueApiDescriptionModel; - allowAnonymous?: boolean | undefined; - implementFrom?: string | undefined; + type WorkflowInputReference = { + providerName?: string | undefined; }; /** * *TODO* **/ - type ApplicationApiDescriptionModel = { - modules?: Record | undefined; - types?: Record | undefined; + type WorkflowInstance = { + id: string; + creationTime: string; + creatorId?: string | undefined; + lastModificationTime?: string | undefined; + lastModifierId?: string | undefined; + workflowDefinitionId: string; + workflowDefinitionVersionId: string; + name?: string | undefined; + version: number; + workflowStatus: Enum.WorkflowInstanceStatus; + correlationId?: string | undefined; + contextType?: string | undefined; + contextId?: string | undefined; + lastExecutedTime?: string | undefined; + finishedTime?: string | undefined; + cancelledTime?: string | undefined; + faultedTime?: string | undefined; + finishedDuration: TimeSpan; + lastExecutedActivityId?: string | undefined; + input: WorkflowInputReference; + output: WorkflowOutputReference; + currentActivity: WorkflowInstanceScheduledActivity; + faults?: WorkflowInstanceFaultBasic[] | undefined; + variables?: any | undefined; + metadata?: any | undefined; + scheduledActivities?: WorkflowInstanceScheduledActivity[] | undefined; + blockingActivities?: WorkflowInstanceBlockingActivity[] | undefined; + activityScopes?: WorkflowInstanceActivityScope[] | undefined; + activityData?: WorkflowInstanceActivityData[] | undefined; }; /** * *TODO* **/ - type ControllerApiDescriptionModel = { - controllerName?: string | undefined; - controllerGroupName?: string | undefined; - isRemoteService?: boolean | undefined; - isIntegrationService?: boolean | undefined; - apiVersion?: string | undefined; - type?: string | undefined; - interfaces?: ControllerInterfaceApiDescriptionModel[] | undefined; - actions?: Record | undefined; + type WorkflowInstanceActivityData = { + activityId: string; + data?: any | undefined; }; /** * *TODO* **/ - type ControllerInterfaceApiDescriptionModel = { - type?: string | undefined; - name?: string | undefined; - methods?: InterfaceMethodApiDescriptionModel[] | undefined; + type WorkflowInstanceActivityScope = { + activityId: string; + variables?: any | undefined; }; /** * *TODO* **/ - type InterfaceMethodApiDescriptionModel = { + type WorkflowInstanceBasic = { + id: string; + creationTime: string; + creatorId?: string | undefined; + lastModificationTime?: string | undefined; + lastModifierId?: string | undefined; + workflowDefinitionId: string; + workflowDefinitionVersionId: string; name?: string | undefined; - parametersOnMethod?: MethodParameterApiDescriptionModel[] | undefined; - returnValue: ReturnValueApiDescriptionModel; + version: number; + workflowStatus: Enum.WorkflowInstanceStatus; + correlationId?: string | undefined; + contextType?: string | undefined; + contextId?: string | undefined; + lastExecutedTime?: string | undefined; + finishedTime?: string | undefined; + cancelledTime?: string | undefined; + faultedTime?: string | undefined; + finishedDuration: TimeSpan; }; /** * *TODO* **/ - type MethodParameterApiDescriptionModel = { - name?: string | undefined; - typeAsString?: string | undefined; - type?: string | undefined; - typeSimple?: string | undefined; - isOptional?: boolean | undefined; - defaultValue?: any | undefined; + type WorkflowInstanceBasicPagedResult = { + items?: WorkflowInstanceBasic[] | undefined; + totalCount: number; }; /** * *TODO* **/ - type ModuleApiDescriptionModel = { - rootPath?: string | undefined; - remoteServiceName?: string | undefined; - controllers?: Record | undefined; + type WorkflowInstanceBatchActionRequest = { + ids?: string[] | undefined; }; /** * *TODO* **/ - type ParameterApiDescriptionModel = { - nameOnMethod?: string | undefined; - name?: string | undefined; - jsonName?: string | undefined; - type?: string | undefined; - typeSimple?: string | undefined; - isOptional?: boolean | undefined; - defaultValue?: any | undefined; - constraintTypes?: string[] | undefined; - bindingSourceId?: string | undefined; - descriptorName?: string | undefined; + type WorkflowInstanceBlockingActivity = { + activityId: string; + activityType?: string | undefined; + tag?: string | undefined; }; /** * *TODO* **/ - type PropertyApiDescriptionModel = { - name?: string | undefined; - jsonName?: string | undefined; - type?: string | undefined; - typeSimple?: string | undefined; - isRequired?: boolean | undefined; - minLength?: number | undefined; - maxLength?: number | undefined; - minimum?: string | undefined; - maximum?: string | undefined; - regex?: string | undefined; + type WorkflowInstanceDateCountStatistic = { + date: string; + finishedCount: number; + failedCount: number; }; /** * *TODO* **/ - type ReturnValueApiDescriptionModel = { - type?: string | undefined; - typeSimple?: string | undefined; + type WorkflowInstanceDateCountStatisticsResult = { + items?: WorkflowInstanceDateCountStatistic[] | undefined; }; /** * *TODO* **/ - type TypeApiDescriptionModel = { - baseType?: string | undefined; - isEnum?: boolean | undefined; - enumNames?: string[] | undefined; - enumValues?: any[] | undefined; - genericArguments?: string[] | undefined; - properties?: PropertyApiDescriptionModel[] | undefined; + type WorkflowInstanceDispatchRequest = { + activityId?: string | undefined; + input: WorkflowInput; }; /** * *TODO* **/ - type RemoteServiceErrorInfo = { - code?: string | undefined; - message?: string | undefined; - details?: string | undefined; - data?: any | undefined; - validationErrors?: RemoteServiceValidationErrorInfo[] | undefined; + type WorkflowInstanceExecuteRequest = { + activityId?: string | undefined; + input: WorkflowInput; }; /** * *TODO* **/ - type RemoteServiceErrorResponse = { - error: RemoteServiceErrorInfo; + type WorkflowInstanceExecutionLogSummary = { + activities?: WorkflowInstanceExecutionLogSummaryActivity[] | undefined; }; /** * *TODO* **/ - type RemoteServiceValidationErrorInfo = { + type WorkflowInstanceExecutionLogSummaryActivity = { + activityId: string; + activityType?: string | undefined; + isExecuting?: boolean | undefined; + isExecuted?: boolean | undefined; + isFaulted?: boolean | undefined; + executedCount: number; + startTime: string; + endTime: string; + duration: number; + outcomes?: string[] | undefined; + stateData?: any | undefined; + journalData?: any | undefined; message?: string | undefined; - members?: string[] | undefined; }; /** * *TODO* **/ - type IdentityRole = { - extraProperties?: any | undefined; + type WorkflowInstanceFault = { id: string; - name?: string | undefined; - isDefault?: boolean | undefined; - isStatic?: boolean | undefined; - isPublic?: boolean | undefined; - concurrencyStamp?: string | undefined; + creationTime: string; + creatorId?: string | undefined; + workflowInstanceId: string; + faultedActivityId?: string | undefined; + resuming?: boolean | undefined; + activityInput?: any | undefined; + message?: string | undefined; + exception: SimpleExceptionModel; }; /** * *TODO* **/ - type IdentityRoleCreate = { - extraProperties?: any | undefined; - name: string; - isDefault?: boolean | undefined; - isPublic?: boolean | undefined; + type WorkflowInstanceFaultBasic = { + faultedActivityId?: string | undefined; + resuming?: boolean | undefined; + activityInput?: any | undefined; + message?: string | undefined; + exception: SimpleExceptionModel; }; /** * *TODO* **/ - type IdentityRoleUpdate = { - extraProperties?: any | undefined; - name: string; - isDefault?: boolean | undefined; - isPublic?: boolean | undefined; - concurrencyStamp?: string | undefined; + type WorkflowInstanceFaultListResult = { + items?: WorkflowInstanceFault[] | undefined; }; /** * *TODO* **/ - type IdentityUser = { - extraProperties?: any | undefined; - id: string; - creationTime: string; - creatorId?: string | undefined; - lastModificationTime?: string | undefined; - lastModifierId?: string | undefined; - isDeleted?: boolean | undefined; - deleterId?: string | undefined; - deletionTime?: string | undefined; - tenantId?: string | undefined; - userName?: string | undefined; - name?: string | undefined; - surname?: string | undefined; - email?: string | undefined; - emailConfirmed?: boolean | undefined; - phoneNumber?: string | undefined; - phoneNumberConfirmed?: boolean | undefined; - isActive?: boolean | undefined; - lockoutEnabled?: boolean | undefined; - lockoutEnd?: string | undefined; - concurrencyStamp?: string | undefined; + type WorkflowInstanceFaultPagedResult = { + items?: WorkflowInstanceFault[] | undefined; + totalCount: number; }; /** * *TODO* **/ - type IdentityUserCreate = { - extraProperties?: any | undefined; - userName: string; - name?: string | undefined; - surname?: string | undefined; - email: string; - phoneNumber?: string | undefined; - isActive?: boolean | undefined; - lockoutEnabled?: boolean | undefined; - roleNames?: string[] | undefined; - password: string; + type WorkflowInstanceRetryRequest = { + runImmediately?: boolean | undefined; }; /** * *TODO* **/ - type IdentityUserUpdate = { - extraProperties?: any | undefined; - userName: string; - name?: string | undefined; - surname?: string | undefined; - email: string; - phoneNumber?: string | undefined; - isActive?: boolean | undefined; - lockoutEnabled?: boolean | undefined; - roleNames?: string[] | undefined; - password?: string | undefined; - concurrencyStamp?: string | undefined; + type WorkflowInstanceScheduledActivity = { + activityId: string; + input?: any | undefined; }; /** * *TODO* **/ - type IdentityUserUpdateRoles = { - roleNames: string[]; + type WorkflowInstanceStatusCountStatisticsResult = { + all: number; + running: number; + finished: number; + faulted: number; + suspended: number; }; /** * *TODO* **/ - type LanguageInfo = { - cultureName?: string | undefined; - uiCultureName?: string | undefined; - displayName?: string | undefined; - twoLetterISOLanguageName?: string | undefined; - flagIcon?: string | undefined; + type WorkflowOutputReference = { + providerName?: string | undefined; + activityId?: string | undefined; }; /** * *TODO* **/ - type NameValue = { + type WorkflowProviderDescriptor = { name?: string | undefined; - value?: string | undefined; + type?: string | undefined; }; /** * *TODO* **/ - type GetPermissionListResult = { - entityDisplayName?: string | undefined; - groups?: PermissionGroup[] | undefined; + type WorkflowProviderDescriptorListResult = { + items?: WorkflowProviderDescriptor[] | undefined; }; /** * *TODO* **/ - type PermissionGrantInfo = { - name?: string | undefined; - displayName?: string | undefined; - parentName?: string | undefined; - isGranted?: boolean | undefined; - allowedProviders?: string[] | undefined; - grantedProviders?: ProviderInfo[] | undefined; + type WorkflowSignalDispatchRequest = { + workflowInstanceId?: string | undefined; + correlationId?: string | undefined; + input?: any | undefined; }; /** * *TODO* **/ - type PermissionGroup = { - name?: string | undefined; - displayName?: string | undefined; - displayNameKey?: string | undefined; - displayNameResource?: string | undefined; - permissions?: PermissionGrantInfo[] | undefined; + type WorkflowSignalDispatchResult = { + startedWorkflows?: WorkflowSignalResult[] | undefined; }; /** * *TODO* **/ - type ProviderInfo = { - providerName?: string | undefined; - providerKey?: string | undefined; + type WorkflowSignalExecuteRequest = { + workflowInstanceId?: string | undefined; + correlationId?: string | undefined; + input?: any | undefined; }; /** * *TODO* **/ - type UpdatePermission = { - name?: string | undefined; - isGranted?: boolean | undefined; + type WorkflowSignalExecuteResult = { + startedWorkflows?: WorkflowSignalResult[] | undefined; }; /** * *TODO* **/ - type UpdatePermissions = { - permissions?: UpdatePermission[] | undefined; + type WorkflowSignalResult = { + workflowInstanceId: string; + activityId?: string | undefined; }; /** * *TODO* **/ - type EmailSettings = { - smtpHost?: string | undefined; - smtpPort: number; - smtpUserName?: string | undefined; - smtpPassword?: string | undefined; - smtpDomain?: string | undefined; - smtpEnableSsl?: boolean | undefined; - smtpUseDefaultCredentials?: boolean | undefined; - defaultFromAddress?: string | undefined; - defaultFromDisplayName?: string | undefined; + type WorkflowStorageProviderInfo = { + name?: string | undefined; + displayName?: string | undefined; }; /** * *TODO* **/ - type SendTestEmailInput = { - senderEmailAddress: string; - targetEmailAddress: string; - subject: string; - body?: string | undefined; + type WorkflowStorageProviderInfoListResult = { + items?: WorkflowStorageProviderInfo[] | undefined; }; /** * *TODO* **/ - type UpdateEmailSettings = { - smtpHost?: string | undefined; - smtpPort: number; - smtpUserName?: string | undefined; - smtpPassword?: string | undefined; - smtpDomain?: string | undefined; - smtpEnableSsl?: boolean | undefined; - smtpUseDefaultCredentials?: boolean | undefined; - defaultFromAddress: string; - defaultFromDisplayName: string; + type WorkflowVariables = { + variables?: any | undefined; }; /** * *TODO* **/ - type UserData = { - id: string; - tenantId?: string | undefined; - userName?: string | undefined; - name?: string | undefined; - surname?: string | undefined; - isActive?: boolean | undefined; - email?: string | undefined; - emailConfirmed?: boolean | undefined; - phoneNumber?: string | undefined; - phoneNumberConfirmed?: boolean | undefined; + type WorkflowVariableUpdate = { + variables?: any | undefined; }; diff --git a/src/Passingwind.ElsaDesigner/src/services/utils.ts b/src/Passingwind.ElsaDesigner/src/services/utils.ts index e24844e..e2be496 100644 --- a/src/Passingwind.ElsaDesigner/src/services/utils.ts +++ b/src/Passingwind.ElsaDesigner/src/services/utils.ts @@ -28,6 +28,19 @@ export const showDownloadJsonFile = (fileName: string, json: string) => { window.URL.revokeObjectURL(url); }; +export const showDownloadFile = (fileName: string, data: any, contentType: string = '') => { + const blob = new Blob([data], { type: contentType }); + console.log(blob); + const url = window.URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = fileName; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + window.URL.revokeObjectURL(url); +}; + export const enumToStatus = (value: any) => { const result = Object.keys(value) .filter((x) => isInteger(x)) @@ -56,23 +69,18 @@ export const formatTableSorter = (sorter: Record) => { return `${x} ${sorter[x] == 'ascend' ? '' : 'desc'}`; }) ?.join(', '); -} +}; export const saveTableQueryConfig = (tableId: string, params: any) => { - if (params) - window.sessionStorage.setItem('table_query_' + tableId, JSON.stringify(params)); - else - window.sessionStorage.removeItem('table_query_' + tableId); -} + if (params) window.sessionStorage.setItem('table_query_' + tableId, JSON.stringify(params)); + else window.sessionStorage.removeItem('table_query_' + tableId); +}; export const getTableQueryConfig = (tableId: string) => { const json = window.sessionStorage.getItem('table_query_' + tableId) ?? ''; - if (json) - return JSON.parse(json) as GlobalAPI.TableQueryConfig; - else - return undefined; -} - + if (json) return JSON.parse(json) as GlobalAPI.TableQueryConfig; + else return undefined; +}; export const formatDateTimeToUtc = (value: string) => { if (value) { @@ -81,4 +89,4 @@ export const formatDateTimeToUtc = (value: string) => { } } return value; -} +};