diff --git a/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs b/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs index 32bb283b6..54b905329 100644 --- a/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs +++ b/src/clients/Elsa.Api.Client/Extensions/DependencyInjectionExtensions.cs @@ -6,6 +6,8 @@ using Elsa.Api.Client.Converters; using Elsa.Api.Client.Options; using Elsa.Api.Client.Resources.ActivityDescriptors.Contracts; using Elsa.Api.Client.Resources.Identity.Contracts; +using Elsa.Api.Client.Resources.StorageDrivers.Contracts; +using Elsa.Api.Client.Resources.VariableTypes.Contracts; using Elsa.Api.Client.Resources.WorkflowDefinitions.Contracts; using Elsa.Api.Client.Services; using JetBrains.Annotations; @@ -32,6 +34,8 @@ public static class DependencyInjectionExtensions services.AddApi(CreateRefitSettings); services.AddApi(CreateRefitSettings); + services.AddApi(CreateRefitSettings); + services.AddApi(CreateRefitSettings); services.AddApi(CreateRefitSettings); return services; } diff --git a/src/clients/Elsa.Api.Client/Resources/StorageDrivers/Contracts/IStorageDriversApi.cs b/src/clients/Elsa.Api.Client/Resources/StorageDrivers/Contracts/IStorageDriversApi.cs new file mode 100644 index 000000000..f672b2ad5 --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/StorageDrivers/Contracts/IStorageDriversApi.cs @@ -0,0 +1,18 @@ +using Elsa.Api.Client.Resources.StorageDrivers.Models; +using Refit; + +namespace Elsa.Api.Client.Resources.StorageDrivers.Contracts; + +/// +/// Represents a client for the storage drivers API. +/// +public interface IStorageDriversApi +{ + /// + /// Lists storage drivers. + /// + /// The cancellation token. + /// The response containing the storage drivers. + [Get("/descriptors/storage-drivers")] + Task ListAsync(CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Resources/StorageDrivers/Models/ListStorageDriversResponse.cs b/src/clients/Elsa.Api.Client/Resources/StorageDrivers/Models/ListStorageDriversResponse.cs new file mode 100644 index 000000000..c07bf9c8a --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/StorageDrivers/Models/ListStorageDriversResponse.cs @@ -0,0 +1,7 @@ +namespace Elsa.Api.Client.Resources.StorageDrivers.Models; + +/// +/// The response containing the storage drivers. +/// +/// The storage drivers. +public record ListStorageDriversResponse(ICollection Items); \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Resources/StorageDrivers/Models/StorageDriverDescriptor.cs b/src/clients/Elsa.Api.Client/Resources/StorageDrivers/Models/StorageDriverDescriptor.cs new file mode 100644 index 000000000..0298909a8 --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/StorageDrivers/Models/StorageDriverDescriptor.cs @@ -0,0 +1,3 @@ +namespace Elsa.Api.Client.Resources.StorageDrivers.Models; + +public record StorageDriverDescriptor(string TypeName, string DisplayName); \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Resources/VariableTypes/Contracts/IStorageDriversApi.cs b/src/clients/Elsa.Api.Client/Resources/VariableTypes/Contracts/IStorageDriversApi.cs new file mode 100644 index 000000000..c4faef71a --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/VariableTypes/Contracts/IStorageDriversApi.cs @@ -0,0 +1,18 @@ +using Elsa.Api.Client.Resources.VariableTypes.Models; +using Refit; + +namespace Elsa.Api.Client.Resources.VariableTypes.Contracts; + +/// +/// Represents a client for the variable types API. +/// +public interface IVariableTypesApi +{ + /// + /// Lists variable types. + /// + /// The cancellation token. + /// The response containing the variable types. + [Get("/descriptors/variables")] + Task ListAsync(CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Resources/VariableTypes/Models/ListVariableTypesResponse.cs b/src/clients/Elsa.Api.Client/Resources/VariableTypes/Models/ListVariableTypesResponse.cs new file mode 100644 index 000000000..afd6cd9d8 --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/VariableTypes/Models/ListVariableTypesResponse.cs @@ -0,0 +1,7 @@ +namespace Elsa.Api.Client.Resources.VariableTypes.Models; + +/// +/// A response containing a list of variable types. +/// +/// A list of variable types. +public record ListVariableTypesResponse(ICollection Items); \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Resources/VariableTypes/Models/VariableTypeDescriptor.cs b/src/clients/Elsa.Api.Client/Resources/VariableTypes/Models/VariableTypeDescriptor.cs new file mode 100644 index 000000000..6937c19a1 --- /dev/null +++ b/src/clients/Elsa.Api.Client/Resources/VariableTypes/Models/VariableTypeDescriptor.cs @@ -0,0 +1,10 @@ +namespace Elsa.Api.Client.Resources.VariableTypes.Models; + +/// +/// Represents a variable type. +/// +/// The .NET type name of the variable type. +/// The display name of the variable type. +/// The category of the variable type. +/// The description of the variable type. +public record VariableTypeDescriptor(string TypeName, string DisplayName, string Category, string? Description); \ No newline at end of file diff --git a/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/Variable.cs b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/Variable.cs index b9ffe884d..4a6b571f3 100644 --- a/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/Variable.cs +++ b/src/clients/Elsa.Api.Client/Resources/WorkflowDefinitions/Models/Variable.cs @@ -34,4 +34,9 @@ public class Variable /// The storage driver type to use for persistence. /// public string? StorageDriverTypeName { get; set; } + + /// + /// The type name of the variable, including the array indicator. + /// + public string GetTypeDisplayName() => IsArray ? $"{TypeName}[]" : TypeName; } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/VariableTypes/List/Endpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/VariableTypes/List/Endpoint.cs index fcbb93b3c..e92188a27 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/VariableTypes/List/Endpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/VariableTypes/List/Endpoint.cs @@ -43,7 +43,7 @@ internal class List : ElsaEndpointWithoutRequest return Task.FromResult(response); } - private VariableDescriptorModel Map(VariableDescriptor descriptor) + private VariableTypeDescriptor Map(VariableDescriptor descriptor) { var type = descriptor.Type; var hasAlias = _wellKnownTypeRegistry.TryGetAlias(type, out var alias); diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/VariableTypes/List/Models.cs b/src/modules/Elsa.Workflows.Api/Endpoints/VariableTypes/List/Models.cs index efb68f210..44e3c8ad6 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/VariableTypes/List/Models.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/VariableTypes/List/Models.cs @@ -1,13 +1,13 @@ namespace Elsa.Workflows.Api.Endpoints.VariableTypes.List; -public class Response +internal class Response { - public Response(ICollection items) + public Response(ICollection items) { Items = items; } - public ICollection Items { get; set; } + public ICollection Items { get; set; } } -public record VariableDescriptorModel(string TypeName, string DisplayName, string Category, string? Description); \ No newline at end of file +internal record VariableTypeDescriptor(string TypeName, string DisplayName, string Category, string? Description); \ No newline at end of file